aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/fs/f2fs/segment.c
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@wdc.com>2019-03-16 09:13:08 +0900
committerJaegeuk Kim <jaegeuk@kernel.org>2019-04-05 09:33:55 -0700
commit7f3d7719c1888f98f12b584bcd6058e2c23d1961 (patch)
tree308a957eaa2551365c2849a5d298d769f3580e84 /fs/f2fs/segment.c
parentf2fs: Reduce zoned block device memory usage (diff)
downloadwireguard-linux-7f3d7719c1888f98f12b584bcd6058e2c23d1961.tar.xz
wireguard-linux-7f3d7719c1888f98f12b584bcd6058e2c23d1961.zip
f2fs: improve discard handling with multi-device volumes
f2fs_hw_support_discard() only tests if the super block device supports discard. However, for a multi-device volume, not all disks used may support discard. Improve the check performed to test all devices of the volume and report discard as supported if at least one device of the volume supports discard. To implement this, introduce the helper function f2fs_bdev_support_discard(), which returns true for zoned block devices (where discard is processed as a zone reset) and for regular disks supporting the discard command. f2fs_bdev_support_discard() is also used in __queue_discard_cmd() to handle discard command issuing for a particular device of the volume. That is, prevent issuing a discard command for block devices that do not support it. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r--fs/f2fs/segment.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 584d1127f295..a3380d1de600 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1368,6 +1368,9 @@ static int __queue_discard_cmd(struct f2fs_sb_info *sbi,
{
block_t lblkstart = blkstart;
+ if (!f2fs_bdev_support_discard(bdev))
+ return 0;
+
trace_f2fs_queue_discard(bdev, blkstart, blklen);
if (f2fs_is_multi_device(sbi)) {
@@ -1762,8 +1765,6 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
}
/* For conventional zones, use regular discard if supported */
- if (!blk_queue_discard(bdev_get_queue(bdev)))
- return 0;
return __queue_discard_cmd(sbi, bdev, lblkstart, blklen);
}
#endif
@@ -1772,8 +1773,7 @@ static int __issue_discard_async(struct f2fs_sb_info *sbi,
struct block_device *bdev, block_t blkstart, block_t blklen)
{
#ifdef CONFIG_BLK_DEV_ZONED
- if (f2fs_sb_has_blkzoned(sbi) &&
- bdev_zoned_model(bdev) != BLK_ZONED_NONE)
+ if (f2fs_sb_has_blkzoned(sbi) && bdev_is_zoned(bdev))
return __f2fs_issue_discard_zone(sbi, bdev, blkstart, blklen);
#endif
return __queue_discard_cmd(sbi, bdev, blkstart, blklen);