* [PATCH v2] f2fs: add a punch discard command function
@ 2017-03-02 2:36 Yunlei He
2017-03-08 1:36 ` Jaegeuk Kim
0 siblings, 1 reply; 5+ messages in thread
From: Yunlei He @ 2017-03-02 2:36 UTC (permalink / raw)
To: jaegeuk, yuchao0, linux-f2fs-devel
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 <heyunlei@huawei.com>
---
fs/f2fs/segment.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 4bd7a8b..1e1d5d3 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -672,6 +672,22 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *d
kmem_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);
--
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] f2fs: add a punch discard command function
2017-03-02 2:36 [PATCH v2] f2fs: add a punch discard command function Yunlei He
@ 2017-03-08 1:36 ` Jaegeuk Kim
2017-03-08 2:49 ` Jaegeuk Kim
0 siblings, 1 reply; 5+ messages in thread
From: Jaegeuk Kim @ 2017-03-08 1:36 UTC (permalink / raw)
To: Yunlei He; +Cc: linux-f2fs-devel
Hi Yunlei,
On 03/02, Yunlei He wrote:
> 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 <heyunlei@huawei.com>
> ---
> fs/f2fs/segment.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 4bd7a8b..1e1d5d3 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -672,6 +672,22 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *d
> kmem_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);
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,
> + } 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);
> --
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] f2fs: add a punch discard command function
2017-03-08 1:36 ` Jaegeuk Kim
@ 2017-03-08 2:49 ` Jaegeuk Kim
2017-03-08 7:33 ` heyunlei
0 siblings, 1 reply; 5+ messages in thread
From: Jaegeuk Kim @ 2017-03-08 2:49 UTC (permalink / raw)
To: Yunlei He; +Cc: linux-f2fs-devel
On 03/07, Jaegeuk Kim wrote:
> Hi Yunlei,
>
> On 03/02, Yunlei He wrote:
> > 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 <heyunlei@huawei.com>
> > ---
> > fs/f2fs/segment.c | 18 +++++++++++++++++-
> > 1 file changed, 17 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > index 4bd7a8b..1e1d5d3 100644
> > --- a/fs/f2fs/segment.c
> > +++ b/fs/f2fs/segment.c
> > @@ -672,6 +672,22 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *d
> > kmem_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);
>
> 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.
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,
>
> Thanks,
>
> > + } 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);
> > --
> > 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
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] f2fs: add a punch discard command function
2017-03-08 2:49 ` Jaegeuk Kim
@ 2017-03-08 7:33 ` heyunlei
2017-03-08 21:33 ` Jaegeuk Kim
0 siblings, 1 reply; 5+ messages in thread
From: heyunlei @ 2017-03-08 7:33 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-f2fs-devel
Hi Jaegeuk,
On 2017/3/8 10:49, Jaegeuk Kim wrote:
> On 03/07, Jaegeuk Kim wrote:
>> Hi Yunlei,
>>
>> On 03/02, Yunlei He wrote:
>>> 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 <heyunlei@huawei.com>
>>> ---
>>> fs/f2fs/segment.c | 18 +++++++++++++++++-
>>> 1 file changed, 17 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>>> index 4bd7a8b..1e1d5d3 100644
>>> --- a/fs/f2fs/segment.c
>>> +++ b/fs/f2fs/segment.c
>>> @@ -672,6 +672,22 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *d
>>> kmem_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);
>>
>> 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.
>
> 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.
>
> Thanks,
>
>>
>> Thanks,
>>
>>> + } 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);
>>> --
>>> 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
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> Linux-f2fs-devel@lists.sourceforge.net
>> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] f2fs: add a punch discard command function
2017-03-08 7:33 ` heyunlei
@ 2017-03-08 21:33 ` Jaegeuk Kim
0 siblings, 0 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2017-03-08 21:33 UTC (permalink / raw)
To: heyunlei; +Cc: linux-f2fs-devel
On 03/08, heyunlei wrote:
> Hi Jaegeuk,
>
> On 2017/3/8 10:49, Jaegeuk Kim wrote:
> > On 03/07, Jaegeuk Kim wrote:
> > > Hi Yunlei,
> > >
> > > On 03/02, Yunlei He wrote:
> > > > 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 <heyunlei@huawei.com>
> > > > ---
> > > > fs/f2fs/segment.c | 18 +++++++++++++++++-
> > > > 1 file changed, 17 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > > > index 4bd7a8b..1e1d5d3 100644
> > > > --- a/fs/f2fs/segment.c
> > > > +++ b/fs/f2fs/segment.c
> > > > @@ -672,6 +672,22 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *d
> > > > kmem_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);
> > >
> > > 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.
> >
> > 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.
One more bug fix.
http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=bd9c4619e81d42c7df1758b6841fd0909840c687
Thanks,
>
> Thanks.
> >
> > Thanks,
> >
> > >
> > > Thanks,
> > >
> > > > + } 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);
> > > > --
> > > > 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
> > > _______________________________________________
> > > Linux-f2fs-devel mailing list
> > > Linux-f2fs-devel@lists.sourceforge.net
> > > 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-03-08 21:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-02 2:36 [PATCH v2] f2fs: add a punch discard command function Yunlei He
2017-03-08 1:36 ` Jaegeuk Kim
2017-03-08 2:49 ` Jaegeuk Kim
2017-03-08 7:33 ` heyunlei
2017-03-08 21:33 ` Jaegeuk Kim
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).