linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH -next] f2fs: add flush_dcache_page after page was written
@ 2022-08-25  2:41 Zhang Qilong via Linux-f2fs-devel
  2022-09-06  2:53 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Zhang Qilong via Linux-f2fs-devel @ 2022-08-25  2:41 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel

If the written page was mapped more than twice, the
written data here will not be seen by others. We add
the flush_dcache_page to fix it.

Fixes:0a2aa8fbb9693 ("f2fs: refactor __exchange_data_block for speed up")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 fs/f2fs/file.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index ab9844eaa62c..b593e41dbfb3 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1273,6 +1273,7 @@ static int __clone_blkaddrs(struct inode *src_inode, struct inode *dst_inode,
 				return PTR_ERR(pdst);
 			}
 			memcpy_page(pdst, 0, psrc, 0, PAGE_SIZE);
+			flush_dcache_page(pdst);
 			set_page_dirty(pdst);
 			f2fs_put_page(pdst, 1);
 			f2fs_put_page(psrc, 1);
-- 
2.25.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH -next] f2fs: add flush_dcache_page after page was written
  2022-08-25  2:41 [f2fs-dev] [PATCH -next] f2fs: add flush_dcache_page after page was written Zhang Qilong via Linux-f2fs-devel
@ 2022-09-06  2:53 ` Chao Yu
  2022-09-12  9:30   ` [f2fs-dev] 答复: " zhangqilong via Linux-f2fs-devel
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2022-09-06  2:53 UTC (permalink / raw)
  To: Zhang Qilong, jaegeuk; +Cc: linux-f2fs-devel

On 2022/8/25 10:41, Zhang Qilong wrote:
> If the written page was mapped more than twice, the
> written data here will not be seen by others. We add
> the flush_dcache_page to fix it.
> 
> Fixes:0a2aa8fbb9693 ("f2fs: refactor __exchange_data_block for speed up")
> Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
> ---
>   fs/f2fs/file.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index ab9844eaa62c..b593e41dbfb3 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1273,6 +1273,7 @@ static int __clone_blkaddrs(struct inode *src_inode, struct inode *dst_inode,
>   				return PTR_ERR(pdst);
>   			}
>   			memcpy_page(pdst, 0, psrc, 0, PAGE_SIZE);
> +			flush_dcache_page(pdst);

__clone_blkaddrs() was introduced for fallocate() w/ FALLOC_FL_COLLAPSE_RANGE
and FALLOC_FL_INSERT_RANGE cases, they are both covered w/ invalidate_lock, and
before __clone_blkaddrs(), it will call truncate_pagecache() to drop all mapping
of pagecache, so it's safe here?

Instead, in f2fs_move_file_range(), we need to cover __exchange_data_block()
w/ invalidate_lock and drop pagecache as well as fallocate() does?

Thanks,

>   			set_page_dirty(pdst);
>   			f2fs_put_page(pdst, 1);
>   			f2fs_put_page(psrc, 1);


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* [f2fs-dev] 答复: [PATCH -next] f2fs: add flush_dcache_page after page was written
  2022-09-06  2:53 ` Chao Yu
@ 2022-09-12  9:30   ` zhangqilong via Linux-f2fs-devel
  0 siblings, 0 replies; 3+ messages in thread
From: zhangqilong via Linux-f2fs-devel @ 2022-09-12  9:30 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-f2fs-devel

> 
> On 2022/8/25 10:41, Zhang Qilong wrote:
> > If the written page was mapped more than twice, the written data here
> > will not be seen by others. We add the flush_dcache_page to fix it.
> >
> > Fixes:0a2aa8fbb9693 ("f2fs: refactor __exchange_data_block for speed
> > up")
> > Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
> > ---
> >   fs/f2fs/file.c | 1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index
> > ab9844eaa62c..b593e41dbfb3 100644
> > --- a/fs/f2fs/file.c
> > +++ b/fs/f2fs/file.c
> > @@ -1273,6 +1273,7 @@ static int __clone_blkaddrs(struct inode
> *src_inode, struct inode *dst_inode,
> >   				return PTR_ERR(pdst);
> >   			}
> >   			memcpy_page(pdst, 0, psrc, 0, PAGE_SIZE);
> > +			flush_dcache_page(pdst);
> 
> __clone_blkaddrs() was introduced for fallocate() w/
> FALLOC_FL_COLLAPSE_RANGE and FALLOC_FL_INSERT_RANGE cases, they
> are both covered w/ invalidate_lock, and before __clone_blkaddrs(), it
> will call truncate_pagecache() to drop all mapping of pagecache, so it's
> safe here?
> 
> Instead, in f2fs_move_file_range(), we need to cover
> __exchange_data_block() w/ invalidate_lock and drop pagecache as well
> as fallocate() does?

Yes ,it seems has the problem. I test it just now through the POC( ioctl(fd1, F2FS_IOC_MOVE_RANGE, &arg). I read the old data before dropping the cache. It refreshes the source file data after manually dropping cache. I will propose a new patch to solve this problem.

Thanks,

> 
> Thanks,
> 
> >   			set_page_dirty(pdst);
> >   			f2fs_put_page(pdst, 1);
> >   			f2fs_put_page(psrc, 1);

_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2022-09-12  9:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-25  2:41 [f2fs-dev] [PATCH -next] f2fs: add flush_dcache_page after page was written Zhang Qilong via Linux-f2fs-devel
2022-09-06  2:53 ` Chao Yu
2022-09-12  9:30   ` [f2fs-dev] 答复: " zhangqilong via Linux-f2fs-devel

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).