Skip to content

Commit 5498d5f

Browse files
morbidrsadamien-lemoal
authored andcommitted
zonefs: introduce helper for zone management
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> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
1 parent d012a71 commit 5498d5f

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

fs/zonefs/super.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,26 @@
2424

2525
#include "zonefs.h"
2626

27+
static inline int zonefs_zone_mgmt(struct inode *inode,
28+
enum req_opf op)
29+
{
30+
struct zonefs_inode_info *zi = ZONEFS_I(inode);
31+
int ret;
32+
33+
lockdep_assert_held(&zi->i_truncate_mutex);
34+
35+
ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector,
36+
zi->i_zone_size >> SECTOR_SHIFT, GFP_NOFS);
37+
if (ret) {
38+
zonefs_err(inode->i_sb,
39+
"Zone management operation %s at %llu failed %d\n",
40+
blk_op_str(op), zi->i_zsector, ret);
41+
return ret;
42+
}
43+
44+
return 0;
45+
}
46+
2747
static int zonefs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
2848
unsigned int flags, struct iomap *iomap,
2949
struct iomap *srcmap)
@@ -397,14 +417,9 @@ static int zonefs_file_truncate(struct inode *inode, loff_t isize)
397417
if (isize == old_isize)
398418
goto unlock;
399419

400-
ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector,
401-
zi->i_zone_size >> SECTOR_SHIFT, GFP_NOFS);
402-
if (ret) {
403-
zonefs_err(inode->i_sb,
404-
"Zone management operation at %llu failed %d",
405-
zi->i_zsector, ret);
420+
ret = zonefs_zone_mgmt(inode, op);
421+
if (ret)
406422
goto unlock;
407-
}
408423

409424
zonefs_update_stats(inode, isize);
410425
truncate_setsize(inode, isize);

0 commit comments

Comments
 (0)