Message ID | 20200909102614.40585-2-johannes.thumshirn@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | zonefs: introduce -o explicit-open mount option | expand |
On 2020/09/09 19:26, Johannes Thumshirn wrote: > Introduce a helper function for sending zone management commands to the > block device. > > As zone management commands can change a zone write pointer position > reflected in the size of the zone file, this function expects the truncate > mutex to be held. > > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> > > --- > Changes to v1: > - centralize failure logging > --- > fs/zonefs/super.c | 29 ++++++++++++++++++++++------- > 1 file changed, 22 insertions(+), 7 deletions(-) > > diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c > index 8ec7c8f109d7..dc828bd1210b 100644 > --- a/fs/zonefs/super.c > +++ b/fs/zonefs/super.c > @@ -24,6 +24,26 @@ > > #include "zonefs.h" > > +static inline int zonefs_zone_mgmt(struct inode *inode, > + enum req_opf op) > +{ > + struct zonefs_inode_info *zi = ZONEFS_I(inode); > + int ret; > + > + lockdep_assert_held(&zi->i_truncate_mutex); > + > + ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector, > + zi->i_zone_size >> SECTOR_SHIFT, GFP_NOFS); > + if (ret) { > + zonefs_err(inode->i_sb, > + "Zone management operation %s at %llu failed %d", It looks like it was not there in the first place, but there is a "\n" missing at the end of the format string. > + blk_op_str(op), zi->i_zsector, ret); > + return ret; > + } > + > + return 0; > +} > + > static int zonefs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, > unsigned int flags, struct iomap *iomap, > struct iomap *srcmap) > @@ -397,14 +417,9 @@ static int zonefs_file_truncate(struct inode *inode, loff_t isize) > if (isize == old_isize) > goto unlock; > > - ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector, > - zi->i_zone_size >> SECTOR_SHIFT, GFP_NOFS); > - if (ret) { > - zonefs_err(inode->i_sb, > - "Zone management operation at %llu failed %d", > - zi->i_zsector, ret); > + ret = zonefs_zone_mgmt(inode, op); > + if (ret) > goto unlock; > - } > > zonefs_update_stats(inode, isize); > truncate_setsize(inode, isize); > Apart from the nit above, looks good. Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
On 09/09/2020 14:43, Damien Le Moal wrote: >> + if (ret) { >> + zonefs_err(inode->i_sb, >> + "Zone management operation %s at %llu failed %d", > It looks like it was not there in the first place, but there is a "\n" missing > at the end of the format string. > Fixed
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c index 8ec7c8f109d7..dc828bd1210b 100644 --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@ -24,6 +24,26 @@ #include "zonefs.h" +static inline int zonefs_zone_mgmt(struct inode *inode, + enum req_opf op) +{ + struct zonefs_inode_info *zi = ZONEFS_I(inode); + int ret; + + lockdep_assert_held(&zi->i_truncate_mutex); + + ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector, + zi->i_zone_size >> SECTOR_SHIFT, GFP_NOFS); + if (ret) { + zonefs_err(inode->i_sb, + "Zone management operation %s at %llu failed %d", + blk_op_str(op), zi->i_zsector, ret); + return ret; + } + + return 0; +} + static int zonefs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, unsigned int flags, struct iomap *iomap, struct iomap *srcmap) @@ -397,14 +417,9 @@ static int zonefs_file_truncate(struct inode *inode, loff_t isize) if (isize == old_isize) goto unlock; - ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector, - zi->i_zone_size >> SECTOR_SHIFT, GFP_NOFS); - if (ret) { - zonefs_err(inode->i_sb, - "Zone management operation at %llu failed %d", - zi->i_zsector, ret); + ret = zonefs_zone_mgmt(inode, op); + if (ret) goto unlock; - } zonefs_update_stats(inode, isize); truncate_setsize(inode, isize);
Introduce a helper function for sending zone management commands to the block device. As zone management commands can change a zone write pointer position reflected in the size of the zone file, this function expects the truncate mutex to be held. Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> --- Changes to v1: - centralize failure logging --- fs/zonefs/super.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)