diff options
author | Damien Le Moal <damien.lemoal@opensource.wdc.com> | 2022-11-16 12:15:40 +0300 |
---|---|---|
committer | Damien Le Moal <damien.lemoal@opensource.wdc.com> | 2023-01-23 03:25:51 +0300 |
commit | aa7f243f32e1d18036ee00d71d3ccfad70ae2121 (patch) | |
tree | 90aa9554803f63416dbf63ce75092f5b6326c8cd /fs/zonefs/zonefs.h | |
parent | 34422914dc00b291d1c47dbdabe93b154c2f2b25 (diff) | |
download | linux-aa7f243f32e1d18036ee00d71d3ccfad70ae2121.tar.xz |
zonefs: Separate zone information from inode information
In preparation for adding dynamic inode allocation, separate an inode
zone information from the zonefs inode structure. The new data structure
zonefs_zone is introduced to store in memory information about a zone
that must be kept throughout the lifetime of the device mount.
Linking between a zone file inode and its zone information is done by
setting the inode i_private field to point to a struct zonefs_zone.
Using the i_private pointer avoids the need for adding a pointer in
struct zonefs_inode_info. Beside the vfs inode, this structure is
reduced to a mutex and a write open counter.
One struct zonefs_zone is created per file inode on mount. These
structures are organized in an array using the new struct
zonefs_zone_group data structure to represent zone groups. The
zonefs_zone arrays are indexed per file number (the index of a struct
zonefs_zone in its array directly gives the file number/name for that
zone file 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/zonefs.h')
-rw-r--r-- | fs/zonefs/zonefs.h | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h index 1a225f74015a..2d626e18b141 100644 --- a/fs/zonefs/zonefs.h +++ b/fs/zonefs/zonefs.h @@ -47,22 +47,39 @@ static inline enum zonefs_ztype zonefs_zone_type(struct blk_zone *zone) #define ZONEFS_ZONE_CNV (1U << 31) /* - * In-memory inode data. + * In-memory per-file inode zone data. */ -struct zonefs_inode_info { - struct inode i_vnode; +struct zonefs_zone { + /* Zone state flags */ + unsigned int z_flags; - /* File zone start sector (512B unit) */ - sector_t i_zsector; + /* Zone start sector (512B unit) */ + sector_t z_sector; - /* File zone write pointer position (sequential zones only) */ - loff_t i_wpoffset; + /* Zone size (bytes) */ + loff_t z_size; - /* File maximum size */ - loff_t i_max_size; + /* Zone capacity (file maximum size, bytes) */ + loff_t z_capacity; - /* File zone size */ - loff_t i_zone_size; + /* Write pointer offset in the zone (sequential zones only, bytes) */ + loff_t z_wpoffset; +}; + +/* + * In memory zone group information: all zones of a group are exposed + * as files, one file per zone. + */ +struct zonefs_zone_group { + unsigned int g_nr_zones; + struct zonefs_zone *g_zones; +}; + +/* + * In-memory inode data. + */ +struct zonefs_inode_info { + struct inode i_vnode; /* * To serialise fully against both syscall and mmap based IO and @@ -81,7 +98,6 @@ struct zonefs_inode_info { /* guarded by i_truncate_mutex */ unsigned int i_wr_refcnt; - unsigned int i_flags; }; static inline struct zonefs_inode_info *ZONEFS_I(struct inode *inode) @@ -89,24 +105,29 @@ static inline struct zonefs_inode_info *ZONEFS_I(struct inode *inode) return container_of(inode, struct zonefs_inode_info, i_vnode); } -static inline bool zonefs_zone_is_cnv(struct zonefs_inode_info *zi) +static inline bool zonefs_zone_is_cnv(struct zonefs_zone *z) +{ + return z->z_flags & ZONEFS_ZONE_CNV; +} + +static inline bool zonefs_zone_is_seq(struct zonefs_zone *z) { - return zi->i_flags & ZONEFS_ZONE_CNV; + return !zonefs_zone_is_cnv(z); } -static inline bool zonefs_zone_is_seq(struct zonefs_inode_info *zi) +static inline struct zonefs_zone *zonefs_inode_zone(struct inode *inode) { - return !zonefs_zone_is_cnv(zi); + return inode->i_private; } static inline bool zonefs_inode_is_cnv(struct inode *inode) { - return zonefs_zone_is_cnv(ZONEFS_I(inode)); + return zonefs_zone_is_cnv(zonefs_inode_zone(inode)); } static inline bool zonefs_inode_is_seq(struct inode *inode) { - return zonefs_zone_is_seq(ZONEFS_I(inode)); + return zonefs_zone_is_seq(zonefs_inode_zone(inode)); } /* @@ -200,7 +221,7 @@ struct zonefs_sb_info { uuid_t s_uuid; unsigned int s_zone_sectors_shift; - unsigned int s_nr_files[ZONEFS_ZTYPE_MAX]; + struct zonefs_zone_group s_zgroup[ZONEFS_ZTYPE_MAX]; loff_t s_blocks; loff_t s_used_blocks; @@ -229,8 +250,8 @@ static inline struct zonefs_sb_info *ZONEFS_SB(struct super_block *sb) pr_warn("zonefs (%s) WARNING: " format, sb->s_id, ## args) /* In super.c */ -void zonefs_account_active(struct inode *inode); -int zonefs_zone_mgmt(struct inode *inode, enum req_op op); +void zonefs_inode_account_active(struct inode *inode); +int zonefs_inode_zone_mgmt(struct inode *inode, enum req_op op); void zonefs_i_size_write(struct inode *inode, loff_t isize); void zonefs_update_stats(struct inode *inode, loff_t new_isize); void __zonefs_io_error(struct inode *inode, bool write); |