f2fs: add a punch discard command function
PATCH v2 1/1 f2fs: add a punch discard command function
This patch add a function to punch discard command if one segment reuse before discard. Split this segment from multi-segments discard range, and discard the left bigger range.
--- fs/f2fs/segment.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +17 -1
@@ -672,6 +672,22 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *dkmem_cache_free (discard_cmd_slab, dc); } +static void __punch_discard_cmd (struct f2fs_sb_info *sbi,struct discard_cmd *dc,block_t blkaddr) +{ +block_t end_block =START_BLOCK (sbi,GET_SEGNO (sbi, blkaddr) +1 ); + +if (dc->lstart + dc->len <= end_block) { +__remove_discard_cmd (sbi, dc); +return ; + } + +if (blkaddr - dc->lstart < dc->lstart + dc->len - end_block) { + dc->lstart = end_block; + dc->len -= (end_block - dc->lstart); + }else + dc->len = blkaddr - dc->lstart; +} +/* This should be covered by global mutex, &sit_i->sentry_lock */ void f2fs_wait_discard_bio (struct f2fs_sb_info *sbi,block_t blkaddr) {
@@ -708,7 +724,7 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)if (blkaddr ==NULL_ADDR ) {list_for_each_entry_safe (dc, tmp, wait_list, list) {wait_for_completion_io (&dc->wait); -__remove_discard_cmd (sbi, dc); +__punch_discard_cmd (sbi, dc, blkaddr); } }mutex_unlock (&dcc->cmd_lock);
Signature · 6 lines
2.10.1 ------------------------------------------------------------------------------ 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 Yunlei,
Quoted 19 lines · Yunlei He
This patch add a function to punch discard command if one segment reuse before discard. Split this segment from multi-segments discard range, and discard the left bigger range.
Signed-off-by Yunlei He <[email protected]>--- fs/f2fs/segment.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)fs/f2fs/segment.c +2
-0@@ -672,6 +672,22 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *dkmem_cache_free (discard_cmd_slab, dc); } +static void __punch_discard_cmd (struct f2fs_sb_info *sbi,struct discard_cmd *dc,block_t blkaddr) +{
fs/f2fs/segment.c static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *d · line 686
Quoted 10 lines
fs/f2fs/segment.c +10
-0+block_t end_block =START_BLOCK (sbi,GET_SEGNO (sbi, blkaddr) +1 ); + +if (dc->lstart + dc->len <= end_block) { +__remove_discard_cmd (sbi, dc); +return ; + } + +if (blkaddr - dc->lstart < dc->lstart + dc->len - end_block) { + dc->lstart = end_block; + dc->len -= (end_block - dc->lstart);
I just missed one thing which we already have a bio to submit later. So, in order to do this, we should manage dc->bio as well.
Let me think about whole flow again.
Thanks,
Quoted 18 lines
fs/f2fs/segment.c +5
-1+ }else + dc->len = blkaddr - dc->lstart; +} +/* This should be covered by global mutex, &sit_i->sentry_lock */ void f2fs_wait_discard_bio (struct f2fs_sb_info *sbi,block_t blkaddr) {@@ -708,7 +724,7 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)if (blkaddr ==NULL_ADDR ) {list_for_each_entry_safe (dc, tmp, wait_list, list) {wait_for_completion_io (&dc->wait); -__remove_discard_cmd (sbi, dc); +__punch_discard_cmd (sbi, dc, blkaddr); } }mutex_unlock (&dcc->cmd_lock);Signature · 1 line
2.10.1
------------------------------------------------------------------------------
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 20 lines · Jaegeuk Kim
Hi Yunlei,
Quoted 17 lines · Yunlei He
This patch add a function to punch discard command if one segment reuse before discard. Split this segment from multi-segments discard range, and discard the left bigger range.
Signed-off-by Yunlei He <[email protected]>--- fs/f2fs/segment.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)fs/f2fs/segment.c +0
-0@@ -672,6 +672,22 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *dkmem_cache_free (discard_cmd_slab, dc); }
Quoted 16 lines
fs/f2fs/segment.c static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *d · line 686
Quoted 12 lines
fs/f2fs/segment.c +12
-0+static void __punch_discard_cmd (struct f2fs_sb_info *sbi,struct discard_cmd *dc,block_t blkaddr) +{ +block_t end_block =START_BLOCK (sbi,GET_SEGNO (sbi, blkaddr) +1 ); + +if (dc->lstart + dc->len <= end_block) { +__remove_discard_cmd (sbi, dc); +return ; + } + +if (blkaddr - dc->lstart < dc->lstart + dc->len - end_block) { + dc->lstart = end_block; + dc->len -= (end_block - dc->lstart);I just missed one thing which we already have a bio to submit later. So, in order to do this, we should manage
dc->bioas well.
Let me think about whole flow again.
Please take a look at:
http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=ef63d148d469f249622afe9e89fc273848ee427b
http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=eea59dd279d5d34eb8d9652b7af1bd9e45a3b69e
Thanks,
Quoted 24 lines
Thanks,
Quoted 18 lines
fs/f2fs/segment.c +5
-1+ }else + dc->len = blkaddr - dc->lstart; +} +/* This should be covered by global mutex, &sit_i->sentry_lock */ void f2fs_wait_discard_bio (struct f2fs_sb_info *sbi,block_t blkaddr) {@@ -708,7 +724,7 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)if (blkaddr ==NULL_ADDR ) {list_for_each_entry_safe (dc, tmp, wait_list, list) {wait_for_completion_io (&dc->wait); -__remove_discard_cmd (sbi, dc); +__punch_discard_cmd (sbi, dc, blkaddr); } }mutex_unlock (&dcc->cmd_lock);Signature · 1 line
2.10.1------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
Quoted 8 lines
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
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
------------------------------------------------------------------------------
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
Hi Jaegeuk,
Quoted 38 lines · Jaegeuk Kim
Quoted 20 lines · Jaegeuk Kim
Hi Yunlei,
Quoted 17 lines · Yunlei He
This patch add a function to punch discard command if one segment reuse before discard. Split this segment from multi-segments discard range, and discard the left bigger range.
Signed-off-by Yunlei He <[email protected]>--- fs/f2fs/segment.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)fs/f2fs/segment.c +0
-0@@ -672,6 +672,22 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *dkmem_cache_free (discard_cmd_slab, dc); }Quoted 16 lines
fs/f2fs/segment.c static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *d · line 686
Quoted 12 lines
fs/f2fs/segment.c +12
-0+static void __punch_discard_cmd (struct f2fs_sb_info *sbi,struct discard_cmd *dc,block_t blkaddr) +{ +block_t end_block =START_BLOCK (sbi,GET_SEGNO (sbi, blkaddr) +1 ); + +if (dc->lstart + dc->len <= end_block) { +__remove_discard_cmd (sbi, dc); +return ; + } + +if (blkaddr - dc->lstart < dc->lstart + dc->len - end_block) { + dc->lstart = end_block; + dc->len -= (end_block - dc->lstart);I just missed one thing which we already have a bio to submit later. So, in order to do this, we should manage
dc->bioas well.
Let me think about whole flow again.
Quoted 4 lines
Please take a look at:
http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=ef63d148d469f249622afe9e89fc273848ee427b
http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=eea59dd279d5d34eb8d9652b7af1bd9e45a3b69e
It looks good to me.
Thanks.
Quoted 36 lines
Thanks,
Quoted 24 lines
Thanks,
Quoted 17 lines
fs/f2fs/segment.c +5
-2+ }else + dc->len = blkaddr - dc->lstart; +} +/* This should be covered by global mutex, &sit_i->sentry_lock */ void f2fs_wait_discard_bio (struct f2fs_sb_info *sbi,block_t blkaddr) {@@ -708,7 +724,7 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)if (blkaddr ==NULL_ADDR ) {list_for_each_entry_safe (dc, tmp, wait_list, list) {wait_for_completion_io (&dc->wait); -__remove_discard_cmd (sbi, dc); +__punch_discard_cmd (sbi, dc, blkaddr); } }mutex_unlock (&dcc->cmd_lock); --Quoted 1 line
2.10.1
------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renownedQuoted 8 lines
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
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 2 lines
.
------------------------------------------------------------------------------
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 41 lines · heyunlei
Hi Jaegeuk,
Quoted 38 lines · Jaegeuk Kim
Quoted 36 lines · Jaegeuk Kim
Hi Yunlei,
Quoted 19 lines · Yunlei He
This patch add a function to punch discard command if one segment reuse before discard. Split this segment from multi-segments discard range, and discard the left bigger range.
Signed-off-by Yunlei He <[email protected]>--- fs/f2fs/segment.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)fs/f2fs/segment.c +2
-0@@ -672,6 +672,22 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *dkmem_cache_free (discard_cmd_slab, dc); } +static void __punch_discard_cmd (struct f2fs_sb_info *sbi,struct discard_cmd *dc,block_t blkaddr) +{fs/f2fs/segment.c static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *d · line 686
Quoted 10 lines
fs/f2fs/segment.c +10
-0+block_t end_block =START_BLOCK (sbi,GET_SEGNO (sbi, blkaddr) +1 ); + +if (dc->lstart + dc->len <= end_block) { +__remove_discard_cmd (sbi, dc); +return ; + } + +if (blkaddr - dc->lstart < dc->lstart + dc->len - end_block) { + dc->lstart = end_block; + dc->len -= (end_block - dc->lstart);I just missed one thing which we already have a bio to submit later. So, in order to do this, we should manage
dc->bioas well.
Let me think about whole flow again.
Quoted 6 lines
Quoted 4 lines
Please take a look at:
http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=ef63d148d469f249622afe9e89fc273848ee427b
http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=eea59dd279d5d34eb8d9652b7af1bd9e45a3b69eIt looks good to me.
One more bug fix.
Thanks,
Quoted 40 lines
Thanks.
Quoted 38 lines
Thanks,
Quoted 24 lines
Thanks,
Quoted 17 lines
fs/f2fs/segment.c +5
-2+ }else + dc->len = blkaddr - dc->lstart; +} +/* This should be covered by global mutex, &sit_i->sentry_lock */ void f2fs_wait_discard_bio (struct f2fs_sb_info *sbi,block_t blkaddr) {@@ -708,7 +724,7 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)if (blkaddr ==NULL_ADDR ) {list_for_each_entry_safe (dc, tmp, wait_list, list) {wait_for_completion_io (&dc->wait); -__remove_discard_cmd (sbi, dc); +__punch_discard_cmd (sbi, dc, blkaddr); } }mutex_unlock (&dcc->cmd_lock); --Quoted 1 line
2.10.1
------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renownedQuoted 8 lines
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
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel.
------------------------------------------------------------------------------
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