Merge tag '5.9-rc-smb3-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6
[linux-block.git] / fs / zonefs / super.c
index 4a0bff65d3d652c77c2bcb3ea560e62da29c8a48..8ec7c8f109d7d8ed0826cdc34e1a3d2b32ba926c 100644 (file)
@@ -335,7 +335,7 @@ static void zonefs_io_error(struct inode *inode, bool write)
        struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
        unsigned int noio_flag;
        unsigned int nr_zones =
-               zi->i_max_size >> (sbi->s_zone_sectors_shift + SECTOR_SHIFT);
+               zi->i_zone_size >> (sbi->s_zone_sectors_shift + SECTOR_SHIFT);
        struct zonefs_ioerr_data err = {
                .inode = inode,
                .write = write,
@@ -398,7 +398,7 @@ static int zonefs_file_truncate(struct inode *inode, loff_t isize)
                goto unlock;
 
        ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector,
-                              zi->i_max_size >> SECTOR_SHIFT, GFP_NOFS);
+                              zi->i_zone_size >> SECTOR_SHIFT, GFP_NOFS);
        if (ret) {
                zonefs_err(inode->i_sb,
                           "Zone management operation at %llu failed %d",
@@ -1053,14 +1053,16 @@ static void zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
 
        zi->i_ztype = type;
        zi->i_zsector = zone->start;
+       zi->i_zone_size = zone->len << SECTOR_SHIFT;
+
        zi->i_max_size = min_t(loff_t, MAX_LFS_FILESIZE,
-                              zone->len << SECTOR_SHIFT);
+                              zone->capacity << SECTOR_SHIFT);
        zi->i_wpoffset = zonefs_check_zone_condition(inode, zone, true, true);
 
        inode->i_uid = sbi->s_uid;
        inode->i_gid = sbi->s_gid;
        inode->i_size = zi->i_wpoffset;
-       inode->i_blocks = zone->len;
+       inode->i_blocks = zi->i_max_size >> SECTOR_SHIFT;
 
        inode->i_op = &zonefs_file_inode_operations;
        inode->i_fop = &zonefs_file_operations;
@@ -1167,12 +1169,18 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
                                if (zonefs_zone_type(next) != type)
                                        break;
                                zone->len += next->len;
+                               zone->capacity += next->capacity;
                                if (next->cond == BLK_ZONE_COND_READONLY &&
                                    zone->cond != BLK_ZONE_COND_OFFLINE)
                                        zone->cond = BLK_ZONE_COND_READONLY;
                                else if (next->cond == BLK_ZONE_COND_OFFLINE)
                                        zone->cond = BLK_ZONE_COND_OFFLINE;
                        }
+                       if (zone->capacity != zone->len) {
+                               zonefs_err(sb, "Invalid conventional zone capacity\n");
+                               ret = -EINVAL;
+                               goto free;
+                       }
                }
 
                /*