linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix the fault of calculating blkstart twice
@ 2017-03-04  1:12 Kinglong Mee
  2017-03-08  1:11 ` Jaegeuk Kim
  0 siblings, 1 reply; 5+ messages in thread
From: Kinglong Mee @ 2017-03-04  1:12 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel

When the zone type is BLK_ZONE_TYPE_CONVENTIONAL, the blkstart is 
calculated twice.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fs/f2fs/segment.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 4bd7a8b..ed181d1 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -772,11 +772,6 @@ static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,
 
 	trace_f2fs_issue_discard(bdev, blkstart, blklen);
 
-	if (sbi->s_ndevs) {
-		int devi = f2fs_target_device_index(sbi, blkstart);
-
-		blkstart -= FDEV(devi).start_blk;
-	}
 	err = __blkdev_issue_discard(bdev,
 				SECTOR_FROM_BLOCK(blkstart),
 				SECTOR_FROM_BLOCK(blklen),
@@ -796,12 +791,6 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
 		struct block_device *bdev, block_t blkstart, block_t blklen)
 {
 	sector_t sector, nr_sects;
-	int devi = 0;
-
-	if (sbi->s_ndevs) {
-		devi = f2fs_target_device_index(sbi, blkstart);
-		blkstart -= FDEV(devi).start_blk;
-	}
 
 	/*
 	 * We need to know the type of the zone: for conventional zones,
@@ -822,8 +811,8 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
 		if (sector & (bdev_zone_sectors(bdev) - 1) ||
 				nr_sects != bdev_zone_sectors(bdev)) {
 			f2fs_msg(sbi->sb, KERN_INFO,
-				"(%d) %s: Unaligned discard attempted (block %x + %x)",
-				devi, sbi->s_ndevs ? FDEV(devi).path: "",
+				"Dev(%u:%u): Unaligned discard attempted (block %x + %x)",
+				MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev),
 				blkstart, blklen);
 			return -EIO;
 		}
@@ -840,6 +829,13 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
 static int __issue_discard_async(struct f2fs_sb_info *sbi,
 		struct block_device *bdev, block_t blkstart, block_t blklen)
 {
+	int devi = 0;
+
+	if (sbi->s_ndevs) {
+		devi = f2fs_target_device_index(sbi, blkstart);
+		blkstart -= FDEV(devi).start_blk;
+	}
+
 #ifdef CONFIG_BLK_DEV_ZONED
 	if (f2fs_sb_mounted_blkzoned(sbi->sb) &&
 				bdev_zoned_model(bdev) != BLK_ZONED_NONE)
-- 
2.9.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-09  6:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-04  1:12 [PATCH] f2fs: fix the fault of calculating blkstart twice Kinglong Mee
2017-03-08  1:11 ` Jaegeuk Kim
2017-03-08  1:53   ` Kinglong Mee
2017-03-08  2:07     ` Jaegeuk Kim
2017-03-09  6:53     ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).