diff options
author | Damien Le Moal <damien.lemoal@opensource.wdc.com> | 2022-11-24 11:43:30 +0100 |
---|---|---|
committer | Damien Le Moal <damien.lemoal@opensource.wdc.com> | 2023-01-23 01:25:51 +0100 |
commit | 34422914dc00b291d1c47dbdabe93b154c2f2b25 (patch) | |
tree | cfdee6d1827c4ae351743d38e4086457958fd96b /fs/zonefs/super.c | |
parent | zonefs: Simplify IO error handling (diff) | |
download | linux-34422914dc00b291d1c47dbdabe93b154c2f2b25.tar.xz linux-34422914dc00b291d1c47dbdabe93b154c2f2b25.zip |
zonefs: Reduce struct zonefs_inode_info size
Instead of using the i_ztype field in struct zonefs_inode_info to
indicate the zone type of an inode, introduce the new inode flag
ZONEFS_ZONE_CNV to be set in the i_flags field of struct
zonefs_inode_info to identify conventional zones. If this flag is not
set, the zone of an inode is considered to be a sequential zone.
The helpers zonefs_zone_is_cnv(), zonefs_zone_is_seq(),
zonefs_inode_is_cnv() and zonefs_inode_is_seq() are introduced to
simplify testing the zone type of a struct zonefs_inode_info and of a
struct inode.
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Diffstat (limited to 'fs/zonefs/super.c')
-rw-r--r-- | fs/zonefs/super.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c index 6307cc95be06..a4af29dc32e7 100644 --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@ -37,7 +37,7 @@ void zonefs_account_active(struct inode *inode) lockdep_assert_held(&zi->i_truncate_mutex); - if (zi->i_ztype != ZONEFS_ZTYPE_SEQ) + if (zonefs_zone_is_cnv(zi)) return; /* @@ -177,14 +177,14 @@ static loff_t zonefs_check_zone_condition(struct inode *inode, zonefs_warn(inode->i_sb, "inode %lu: read-only zone\n", inode->i_ino); zi->i_flags |= ZONEFS_ZONE_READONLY; - if (zi->i_ztype == ZONEFS_ZTYPE_CNV) + if (zonefs_zone_is_cnv(zi)) return zi->i_max_size; return zi->i_wpoffset; case BLK_ZONE_COND_FULL: /* The write pointer of full zones is invalid. */ return zi->i_max_size; default: - if (zi->i_ztype == ZONEFS_ZTYPE_CNV) + if (zonefs_zone_is_cnv(zi)) return zi->i_max_size; return (zone->wp - zone->start) << SECTOR_SHIFT; } @@ -260,7 +260,7 @@ static int zonefs_io_error_cb(struct blk_zone *zone, unsigned int idx, * In all cases, warn about inode size inconsistency and handle the * IO error according to the zone condition and to the mount options. */ - if (zi->i_ztype == ZONEFS_ZTYPE_SEQ && isize != data_size) + if (zonefs_zone_is_seq(zi) && isize != data_size) zonefs_warn(sb, "inode %lu: invalid size %lld (should be %lld)\n", inode->i_ino, isize, data_size); @@ -584,7 +584,9 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone, inode->i_ino = zone->start >> sbi->s_zone_sectors_shift; inode->i_mode = S_IFREG | sbi->s_perm; - zi->i_ztype = type; + if (type == ZONEFS_ZTYPE_CNV) + zi->i_flags |= ZONEFS_ZONE_CNV; + zi->i_zsector = zone->start; zi->i_zone_size = zone->len << SECTOR_SHIFT; if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev) << SECTOR_SHIFT && |