f2fs: fix the fault of calculating blkstart twice
PATCH 1/1 f2fs: fix the fault of calculating blkstart twice
When the zone type is BLK_ZONE_TYPE_CONVENTIONAL, the blkstart is calculated twice.
--- fs/f2fs/segment.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
fs/f2fs/segment.c +9 -13
@@ -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 )
Signature · 6 lines
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
Jaegeuk Kim
maintainerHi,
Quoted 13 lines · Kinglong Mee
When the zone type is
BLK_ZONE_TYPE_CONVENTIONAL, the blkstart is calculated twice.Signed-off-by Kinglong Mee <[email protected]>--- fs/f2fs/segment.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)fs/f2fs/segment.c +0
-0
fs/f2fs/segment.c static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi, · line 779
Quoted 8 lines
fs/f2fs/segment.c +0
-5@@ -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; - }
No, you can't do this, since the blkstart will be used for dc->lstart. So, it needs to do like this?
Quoted 1 line
From
01cfee96f3568590ba58f6d2b36150dce7054491Mon Sep 17 00:00:00 2001
From: Jaegeuk Kim <[email protected]>
Date: Tue, 7 Mar 2017 16:32:35 -0800
Subject: [PATCH] f2fs: fix the fault of calculating blkstart twice
When the zone type is BLK_ZONE_TYPE_CONVENTIONAL, the blkstart is calculated twice.
--- fs/f2fs/segment.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/f2fs/segment.c +6 -5
@@ -818,11 +818,6 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,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, * use regular discard if the drive supports it. For sequential
@@ -836,6 +831,12 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,return __f2fs_issue_discard_async (sbi, bdev, blkstart, blklen);case BLK_ZONE_TYPE_SEQWRITE_REQ :case BLK_ZONE_TYPE_SEQWRITE_PREF : + +if (sbi->s_ndevs) { + devi =f2fs_target_device_index (sbi, blkstart); + blkstart -=FDEV (devi).start_blk; + } + sector =SECTOR_FROM_BLOCK (blkstart); nr_sects =SECTOR_FROM_BLOCK (blklen);
Signature · 9 lines
2.11.0 ------------------------------------------------------------------------------ Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition. http://sdm.link/oxford
Quoted 19 lines · Jaegeuk Kim
Hi,
Quoted 16 lines · Kinglong Mee
When the zone type is
BLK_ZONE_TYPE_CONVENTIONAL, the blkstart is calculated twice.Signed-off-by Kinglong Mee <[email protected]>--- fs/f2fs/segment.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)fs/f2fs/segment.c +0
-0@@ -772,11 +772,6 @@ static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,trace_f2fs_issue_discard (bdev, blkstart, blklen);
Quoted 8 lines
fs/f2fs/segment.c static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi, · line 779
Quoted 5 lines
fs/f2fs/segment.c +0
-5-if (sbi->s_ndevs) { -int devi =f2fs_target_device_index (sbi, blkstart); - - blkstart -=FDEV (devi).start_blk; - }No, you can't do this, since the blkstart will be used for
dc->lstart. So, it needs to do like this?
Sorry, I miss that.
But, get_blkz_type() needs the new blkaddr for blkz_type as "FDEV(i).blkz_type[zno]", so that, the blkaddr must be calculated in front of __f2fs_issue_discard_zone, just like this?
Quoted 1 line
From
efd182428830898cc31d49f74d4bd2ab7455cec4Mon Sep 17 00:00:00 2001
From: Kinglong Mee <[email protected]>
Date: Wed, 8 Mar 2017 09:49:53 +0800
Subject: [PATCH] f2fs: fix the fault of calculating blkstart twice
When the zone type is BLK_ZONE_TYPE_CONVENTIONAL, the blkstart is calculated twice.
--- fs/f2fs/segment.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -1
@@ -816,6 +816,7 @@ 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; +block_t lblkstart = blkstart;int devi =0 ;if (sbi->s_ndevs) {
@@ -833,7 +834,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,case BLK_ZONE_TYPE_CONVENTIONAL :if (!blk_queue_discard (bdev_get_queue (bdev)))return 0 ; -return __f2fs_issue_discard_async (sbi, bdev, blkstart, blklen); +return __f2fs_issue_discard_async (sbi, bdev, lblkstart, blklen);case BLK_ZONE_TYPE_SEQWRITE_REQ :case BLK_ZONE_TYPE_SEQWRITE_PREF : sector =SECTOR_FROM_BLOCK (blkstart);
Signature · 10 lines
2.9.3 ------------------------------------------------------------------------------ Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition. http://sdm.link/oxford
Jaegeuk Kim
maintainerQuoted 29 lines · Kinglong Mee
Quoted 19 lines · Jaegeuk Kim
Hi,
Quoted 16 lines · Kinglong Mee
When the zone type is
BLK_ZONE_TYPE_CONVENTIONAL, the blkstart is calculated twice.Signed-off-by Kinglong Mee <[email protected]>--- fs/f2fs/segment.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)fs/f2fs/segment.c +0
-0@@ -772,11 +772,6 @@ static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,trace_f2fs_issue_discard (bdev, blkstart, blklen);Quoted 8 lines
fs/f2fs/segment.c static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi, · line 779
Quoted 5 lines
fs/f2fs/segment.c +0
-5-if (sbi->s_ndevs) { -int devi =f2fs_target_device_index (sbi, blkstart); - - blkstart -=FDEV (devi).start_blk; - }No, you can't do this, since the blkstart will be used for
dc->lstart. So, it needs to do like this?
Quoted 5 lines
Sorry, I miss that.
But,
get_blkz_type()needs the new blkaddr forblkz_typeas "FDEV(i).blkz_type[zno]", so that, the blkaddr must be calculated in front of__f2fs_issue_discard_zone, just like this?
Alright~
Added this. ;)
Thanks,
Quoted 39 lines
Quoted 2 lines
From
efd182428830898cc31d49f74d4bd2ab7455cec4Mon Sep 17 00:00:00 2001From: Kinglong Mee <[email protected]>
Date: Wed, 8 Mar 2017 09:49:53 +0800
Subject: [PATCH] f2fs: fix the fault of calculating blkstart twiceWhen the zone type is
BLK_ZONE_TYPE_CONVENTIONAL, the blkstart is calculated twice.Signed-off-by Kinglong Mee <[email protected]>Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/segment.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/f2fs/segment.c +2
-1@@ -816,6 +816,7 @@ 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; +block_t lblkstart = blkstart;int devi =0 ;if (sbi->s_ndevs) {@@ -833,7 +834,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,case BLK_ZONE_TYPE_CONVENTIONAL :if (!blk_queue_discard (bdev_get_queue (bdev)))return 0 ; -return __f2fs_issue_discard_async (sbi, bdev, blkstart, blklen); +return __f2fs_issue_discard_async (sbi, bdev, lblkstart, blklen);case BLK_ZONE_TYPE_SEQWRITE_REQ :case BLK_ZONE_TYPE_SEQWRITE_PREF : sector =SECTOR_FROM_BLOCK (blkstart);Signature · 1 line
2.9.3
------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition.
http://sdm.link/oxford
Chao Yu
Reviewed-byQuoted 40 lines · Kinglong Mee
Quoted 19 lines · Jaegeuk Kim
Hi,
Quoted 16 lines · Kinglong Mee
When the zone type is
BLK_ZONE_TYPE_CONVENTIONAL, the blkstart is calculated twice.Signed-off-by Kinglong Mee <[email protected]>--- fs/f2fs/segment.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)fs/f2fs/segment.c +0
-0@@ -772,11 +772,6 @@ static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,trace_f2fs_issue_discard (bdev, blkstart, blklen);Quoted 8 lines
fs/f2fs/segment.c static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi, · line 779
Quoted 5 lines
fs/f2fs/segment.c +0
-5-if (sbi->s_ndevs) { -int devi =f2fs_target_device_index (sbi, blkstart); - - blkstart -=FDEV (devi).start_blk; - }No, you can't do this, since the blkstart will be used for
dc->lstart. So, it needs to do like this?Sorry, I miss that.
But,
get_blkz_type()needs the new blkaddr forblkz_typeas "FDEV(i).blkz_type[zno]", so that, the blkaddr must be calculated in front of__f2fs_issue_discard_zone, just like this?Quoted 1 line
From
efd182428830898cc31d49f74d4bd2ab7455cec4Mon Sep 17 00:00:00 2001From: Kinglong Mee <[email protected]>
Date: Wed, 8 Mar 2017 09:49:53 +0800
Subject: [PATCH] f2fs: fix the fault of calculating blkstart twice
Quoted 5 lines
When the zone type is
BLK_ZONE_TYPE_CONVENTIONAL, the blkstart is calculated twice.Signed-off-by Kinglong Mee <[email protected]>Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,
Quoted 18 lines
--- fs/f2fs/segment.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/f2fs/segment.c +1
-0@@ -816,6 +816,7 @@ 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; +block_t lblkstart = blkstart;int devi =0 ;if (sbi->s_ndevs) {
fs/f2fs/segment.c static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi, · line 840
Quoted 8 lines
fs/f2fs/segment.c +1
-1@@ -833,7 +834,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,case BLK_ZONE_TYPE_CONVENTIONAL :if (!blk_queue_discard (bdev_get_queue (bdev)))return 0 ; -return __f2fs_issue_discard_async (sbi, bdev, blkstart, blklen); +return __f2fs_issue_discard_async (sbi, bdev, lblkstart, blklen);case BLK_ZONE_TYPE_SEQWRITE_REQ :case BLK_ZONE_TYPE_SEQWRITE_PREF : sector =SECTOR_FROM_BLOCK (blkstart);
------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition.
http://sdm.link/oxford