zonefs: Rename super block information fields
authorDamien Le Moal <damien.lemoal@opensource.wdc.com>
Tue, 12 Apr 2022 08:00:13 +0000 (17:00 +0900)
committerDamien Le Moal <damien.lemoal@opensource.wdc.com>
Wed, 20 Apr 2022 23:37:41 +0000 (08:37 +0900)
The s_open_zones field of struct zonefs_sb_info is used to count the
number of files that are open for writing and may not necessarilly
correspond to the number of open zones on the device. For instance, an
application may open for writing a sequential zone file, fully write it
and keep the file open. In such case, the zone of the file is not open
anymore (it is in the full state).

Avoid confusion about this counter meaning by renaming it to
s_wro_seq_files. To keep things consistent, the field s_max_open_zones
is renamed to s_max_wro_seq_files.

Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
fs/zonefs/super.c
fs/zonefs/zonefs.h

index e20e7c8414896c0fde07647c5065799a927ab03c..dafacde65659e8a12efd804b731ca40bf1c853bb 100644 (file)
@@ -1035,8 +1035,10 @@ static int zonefs_open_zone(struct inode *inode)
        mutex_lock(&zi->i_truncate_mutex);
 
        if (!zi->i_wr_refcnt) {
-               if (atomic_inc_return(&sbi->s_open_zones) > sbi->s_max_open_zones) {
-                       atomic_dec(&sbi->s_open_zones);
+               unsigned int wro = atomic_inc_return(&sbi->s_wro_seq_files);
+
+               if (wro > sbi->s_max_wro_seq_files) {
+                       atomic_dec(&sbi->s_wro_seq_files);
                        ret = -EBUSY;
                        goto unlock;
                }
@@ -1044,7 +1046,7 @@ static int zonefs_open_zone(struct inode *inode)
                if (i_size_read(inode) < zi->i_max_size) {
                        ret = zonefs_zone_mgmt(inode, REQ_OP_ZONE_OPEN);
                        if (ret) {
-                               atomic_dec(&sbi->s_open_zones);
+                               atomic_dec(&sbi->s_wro_seq_files);
                                goto unlock;
                        }
                        zi->i_flags |= ZONEFS_ZONE_OPEN;
@@ -1108,7 +1110,7 @@ static void zonefs_close_zone(struct inode *inode)
                }
                zi->i_flags &= ~ZONEFS_ZONE_OPEN;
 dec:
-               atomic_dec(&sbi->s_open_zones);
+               atomic_dec(&sbi->s_wro_seq_files);
        }
        mutex_unlock(&zi->i_truncate_mutex);
 }
@@ -1688,9 +1690,10 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
        sbi->s_gid = GLOBAL_ROOT_GID;
        sbi->s_perm = 0640;
        sbi->s_mount_opts = ZONEFS_MNTOPT_ERRORS_RO;
-       sbi->s_max_open_zones = bdev_max_open_zones(sb->s_bdev);
-       atomic_set(&sbi->s_open_zones, 0);
-       if (!sbi->s_max_open_zones &&
+
+       atomic_set(&sbi->s_wro_seq_files, 0);
+       sbi->s_max_wro_seq_files = bdev_max_open_zones(sb->s_bdev);
+       if (!sbi->s_max_wro_seq_files &&
            sbi->s_mount_opts & ZONEFS_MNTOPT_EXPLICIT_OPEN) {
                zonefs_info(sb, "No open zones limit. Ignoring explicit_open mount option\n");
                sbi->s_mount_opts &= ~ZONEFS_MNTOPT_EXPLICIT_OPEN;
index 7b147907c328ed2615b718c4cb17e2e18f148dad..67fd00ab173ff994709e7a92dbb44e9ad1d5d5c7 100644 (file)
@@ -182,8 +182,8 @@ struct zonefs_sb_info {
        loff_t                  s_blocks;
        loff_t                  s_used_blocks;
 
-       unsigned int            s_max_open_zones;
-       atomic_t                s_open_zones;
+       unsigned int            s_max_wro_seq_files;
+       atomic_t                s_wro_seq_files;
 };
 
 static inline struct zonefs_sb_info *ZONEFS_SB(struct super_block *sb)