* [PATCH] f2fs: fix a problem of a truncated inmem page
@ 2017-03-15 12:45 Yunlei He
2017-03-16 0:13 ` Jaegeuk Kim
0 siblings, 1 reply; 4+ messages in thread
From: Yunlei He @ 2017-03-15 12:45 UTC (permalink / raw)
To: jaegeuk, yuchao0, linux-f2fs-devel
-start atomic write
-set_page_dirty
-register_inmem_page
<--- truncate or punch hole
-commit atomic write
Here, may cause memory reclaim painc for page->mapping is null,
but private is -1.
Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
fs/f2fs/data.c | 8 --------
fs/f2fs/segment.c | 5 ++++-
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 1375fef..a91e479 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1948,10 +1948,6 @@ void f2fs_invalidate_page(struct page *page, unsigned int offset,
}
}
- /* This is atomic written page, keep Private */
- if (IS_ATOMIC_WRITTEN_PAGE(page))
- return;
-
set_page_private(page, 0);
ClearPagePrivate(page);
}
@@ -1962,10 +1958,6 @@ int f2fs_release_page(struct page *page, gfp_t wait)
if (PageDirty(page))
return 0;
- /* This is atomic written page, keep Private */
- if (IS_ATOMIC_WRITTEN_PAGE(page))
- return 0;
-
set_page_private(page, 0);
ClearPagePrivate(page);
return 1;
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 42727e4..bebac9a 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -207,6 +207,9 @@ static int __revoke_inmem_pages(struct inode *inode,
lock_page(page);
+ if (page->mapping != inode->i_mapping)
+ goto delete;
+
if (recover) {
struct dnode_of_data dn;
struct node_info ni;
@@ -230,7 +233,7 @@ static int __revoke_inmem_pages(struct inode *inode,
set_page_private(page, 0);
ClearPagePrivate(page);
f2fs_put_page(page, 1);
-
+delete:
list_del(&cur->list);
kmem_cache_free(inmem_entry_slab, cur);
dec_page_count(F2FS_I_SB(inode), F2FS_INMEM_PAGES);
--
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] 4+ messages in thread
* Re: [PATCH] f2fs: fix a problem of a truncated inmem page
2017-03-15 12:45 [PATCH] f2fs: fix a problem of a truncated inmem page Yunlei He
@ 2017-03-16 0:13 ` Jaegeuk Kim
2017-03-17 2:11 ` Jaegeuk Kim
0 siblings, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2017-03-16 0:13 UTC (permalink / raw)
To: Yunlei He; +Cc: linux-f2fs-devel
On 03/15, Yunlei He wrote:
> -start atomic write
> -set_page_dirty
> -register_inmem_page
> <--- truncate or punch hole
SQLite bug?
> -commit atomic write
>
> Here, may cause memory reclaim painc for page->mapping is null,
> but private is -1.
>
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
> fs/f2fs/data.c | 8 --------
> fs/f2fs/segment.c | 5 ++++-
> 2 files changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 1375fef..a91e479 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1948,10 +1948,6 @@ void f2fs_invalidate_page(struct page *page, unsigned int offset,
> }
> }
>
> - /* This is atomic written page, keep Private */
> - if (IS_ATOMIC_WRITTEN_PAGE(page))
> - return;
> -
We need to give a kernel message like "atomic writes were broken", and
unresitering the page from the inmem page list here to keep consistency
between IS_ATOMIC_WRITTEN_PAGE(page) and its link to the inmem list.
> set_page_private(page, 0);
> ClearPagePrivate(page);
> }
> @@ -1962,10 +1958,6 @@ int f2fs_release_page(struct page *page, gfp_t wait)
> if (PageDirty(page))
> return 0;
>
> - /* This is atomic written page, keep Private */
> - if (IS_ATOMIC_WRITTEN_PAGE(page))
> - return 0;
We should keep this in order not to be invalidated by someone.
Thanks,
> -
> set_page_private(page, 0);
> ClearPagePrivate(page);
> return 1;
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 42727e4..bebac9a 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -207,6 +207,9 @@ static int __revoke_inmem_pages(struct inode *inode,
>
> lock_page(page);
>
> + if (page->mapping != inode->i_mapping)
> + goto delete;
> +
> if (recover) {
> struct dnode_of_data dn;
> struct node_info ni;
> @@ -230,7 +233,7 @@ static int __revoke_inmem_pages(struct inode *inode,
> set_page_private(page, 0);
> ClearPagePrivate(page);
> f2fs_put_page(page, 1);
> -
> +delete:
> list_del(&cur->list);
> kmem_cache_free(inmem_entry_slab, cur);
> dec_page_count(F2FS_I_SB(inode), F2FS_INMEM_PAGES);
> --
> 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
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
------------------------------------------------------------------------------
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 [flat|nested] 4+ messages in thread
* Re: [PATCH] f2fs: fix a problem of a truncated inmem page
2017-03-16 0:13 ` Jaegeuk Kim
@ 2017-03-17 2:11 ` Jaegeuk Kim
2017-03-17 2:36 ` heyunlei
0 siblings, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2017-03-17 2:11 UTC (permalink / raw)
To: Yunlei He; +Cc: linux-f2fs-devel
Hi Yunlei,
I could reproduce this. Could you check the patches that I sent just ago?
Thanks,
On 03/16, Jaegeuk Kim wrote:
> On 03/15, Yunlei He wrote:
> > -start atomic write
> > -set_page_dirty
> > -register_inmem_page
> > <--- truncate or punch hole
>
> SQLite bug?
>
> > -commit atomic write
> >
> > Here, may cause memory reclaim painc for page->mapping is null,
> > but private is -1.
> >
> > Signed-off-by: Yunlei He <heyunlei@huawei.com>
> > ---
> > fs/f2fs/data.c | 8 --------
> > fs/f2fs/segment.c | 5 ++++-
> > 2 files changed, 4 insertions(+), 9 deletions(-)
> >
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index 1375fef..a91e479 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -1948,10 +1948,6 @@ void f2fs_invalidate_page(struct page *page, unsigned int offset,
> > }
> > }
> >
> > - /* This is atomic written page, keep Private */
> > - if (IS_ATOMIC_WRITTEN_PAGE(page))
> > - return;
> > -
>
> We need to give a kernel message like "atomic writes were broken", and
> unresitering the page from the inmem page list here to keep consistency
> between IS_ATOMIC_WRITTEN_PAGE(page) and its link to the inmem list.
>
> > set_page_private(page, 0);
> > ClearPagePrivate(page);
> > }
> > @@ -1962,10 +1958,6 @@ int f2fs_release_page(struct page *page, gfp_t wait)
> > if (PageDirty(page))
> > return 0;
> >
> > - /* This is atomic written page, keep Private */
> > - if (IS_ATOMIC_WRITTEN_PAGE(page))
> > - return 0;
>
> We should keep this in order not to be invalidated by someone.
>
> Thanks,
>
> > -
> > set_page_private(page, 0);
> > ClearPagePrivate(page);
> > return 1;
> > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > index 42727e4..bebac9a 100644
> > --- a/fs/f2fs/segment.c
> > +++ b/fs/f2fs/segment.c
> > @@ -207,6 +207,9 @@ static int __revoke_inmem_pages(struct inode *inode,
> >
> > lock_page(page);
> >
> > + if (page->mapping != inode->i_mapping)
> > + goto delete;
> > +
> > if (recover) {
> > struct dnode_of_data dn;
> > struct node_info ni;
> > @@ -230,7 +233,7 @@ static int __revoke_inmem_pages(struct inode *inode,
> > set_page_private(page, 0);
> > ClearPagePrivate(page);
> > f2fs_put_page(page, 1);
> > -
> > +delete:
> > list_del(&cur->list);
> > kmem_cache_free(inmem_entry_slab, cur);
> > dec_page_count(F2FS_I_SB(inode), F2FS_INMEM_PAGES);
> > --
> > 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
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
------------------------------------------------------------------------------
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 [flat|nested] 4+ messages in thread
* Re: [PATCH] f2fs: fix a problem of a truncated inmem page
2017-03-17 2:11 ` Jaegeuk Kim
@ 2017-03-17 2:36 ` heyunlei
0 siblings, 0 replies; 4+ messages in thread
From: heyunlei @ 2017-03-17 2:36 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-f2fs-devel
Hi Jaegeuk,
On 2017/3/17 10:11, Jaegeuk Kim wrote:
> Hi Yunlei,
>
> I could reproduce this. Could you check the patches that I sent just ago?
I have test it with my test case, it's OK.
Thanks,
>
> Thanks,
>
> On 03/16, Jaegeuk Kim wrote:
>> On 03/15, Yunlei He wrote:
>>> -start atomic write
>>> -set_page_dirty
>>> -register_inmem_page
>>> <--- truncate or punch hole
>>
>> SQLite bug?
>>
>>> -commit atomic write
>>>
>>> Here, may cause memory reclaim painc for page->mapping is null,
>>> but private is -1.
>>>
>>> Signed-off-by: Yunlei He <heyunlei@huawei.com>
>>> ---
>>> fs/f2fs/data.c | 8 --------
>>> fs/f2fs/segment.c | 5 ++++-
>>> 2 files changed, 4 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
>>> index 1375fef..a91e479 100644
>>> --- a/fs/f2fs/data.c
>>> +++ b/fs/f2fs/data.c
>>> @@ -1948,10 +1948,6 @@ void f2fs_invalidate_page(struct page *page, unsigned int offset,
>>> }
>>> }
>>>
>>> - /* This is atomic written page, keep Private */
>>> - if (IS_ATOMIC_WRITTEN_PAGE(page))
>>> - return;
>>> -
>>
>> We need to give a kernel message like "atomic writes were broken", and
>> unresitering the page from the inmem page list here to keep consistency
>> between IS_ATOMIC_WRITTEN_PAGE(page) and its link to the inmem list.
>>
>>> set_page_private(page, 0);
>>> ClearPagePrivate(page);
>>> }
>>> @@ -1962,10 +1958,6 @@ int f2fs_release_page(struct page *page, gfp_t wait)
>>> if (PageDirty(page))
>>> return 0;
>>>
>>> - /* This is atomic written page, keep Private */
>>> - if (IS_ATOMIC_WRITTEN_PAGE(page))
>>> - return 0;
>>
>> We should keep this in order not to be invalidated by someone.
>>
>> Thanks,
>>
>>> -
>>> set_page_private(page, 0);
>>> ClearPagePrivate(page);
>>> return 1;
>>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>>> index 42727e4..bebac9a 100644
>>> --- a/fs/f2fs/segment.c
>>> +++ b/fs/f2fs/segment.c
>>> @@ -207,6 +207,9 @@ static int __revoke_inmem_pages(struct inode *inode,
>>>
>>> lock_page(page);
>>>
>>> + if (page->mapping != inode->i_mapping)
>>> + goto delete;
>>> +
>>> if (recover) {
>>> struct dnode_of_data dn;
>>> struct node_info ni;
>>> @@ -230,7 +233,7 @@ static int __revoke_inmem_pages(struct inode *inode,
>>> set_page_private(page, 0);
>>> ClearPagePrivate(page);
>>> f2fs_put_page(page, 1);
>>> -
>>> +delete:
>>> list_del(&cur->list);
>>> kmem_cache_free(inmem_entry_slab, cur);
>>> dec_page_count(F2FS_I_SB(inode), F2FS_INMEM_PAGES);
>>> --
>>> 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
>>> _______________________________________________
>>> Linux-f2fs-devel mailing list
>>> Linux-f2fs-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> Linux-f2fs-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>
> .
>
------------------------------------------------------------------------------
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 [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-17 2:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-15 12:45 [PATCH] f2fs: fix a problem of a truncated inmem page Yunlei He
2017-03-16 0:13 ` Jaegeuk Kim
2017-03-17 2:11 ` Jaegeuk Kim
2017-03-17 2:36 ` heyunlei
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).