* [f2fs-dev] [PATCH v3 3/4] f2fs: atomic: fix to truncate pagecache before on-disk metadata truncation
@ 2024-08-01 1:13 Chao Yu
2024-08-06 2:43 ` Jaegeuk Kim
0 siblings, 1 reply; 2+ messages in thread
From: Chao Yu @ 2024-08-01 1:13 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel
We should always truncate pagecache while truncating on-disk data.
Fixes: a46bebd502fe ("f2fs: synchronize atomic write aborts")
Signed-off-by: Chao Yu <chao@kernel.org>
---
v3:
- check dirty page before truncation
- use invalidate_mapping_pages() instead of truncate_inode_pages()
- set i_size to zero after truncation
fs/f2fs/file.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index ac61c88f7688..a316c21539d1 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2199,11 +2199,17 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
F2FS_I(fi->cow_inode)->atomic_inode = inode;
} else {
/* Reuse the already created COW inode */
+ f2fs_bug_on(sbi, get_dirty_pages(fi->cow_inode));
+
+ invalidate_mapping_pages(fi->cow_inode->i_mapping, 0, -1);
+
ret = f2fs_do_truncate_blocks(fi->cow_inode, 0, true);
if (ret) {
f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
goto out;
}
+
+ i_size_write(fi->cow_inode, 0);
}
f2fs_write_inode(inode, NULL);
--
2.40.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] 2+ messages in thread* Re: [f2fs-dev] [PATCH v3 3/4] f2fs: atomic: fix to truncate pagecache before on-disk metadata truncation
2024-08-01 1:13 [f2fs-dev] [PATCH v3 3/4] f2fs: atomic: fix to truncate pagecache before on-disk metadata truncation Chao Yu
@ 2024-08-06 2:43 ` Jaegeuk Kim
0 siblings, 0 replies; 2+ messages in thread
From: Jaegeuk Kim @ 2024-08-06 2:43 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel
On 08/01, Chao Yu wrote:
> We should always truncate pagecache while truncating on-disk data.
>
> Fixes: a46bebd502fe ("f2fs: synchronize atomic write aborts")
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> v3:
> - check dirty page before truncation
> - use invalidate_mapping_pages() instead of truncate_inode_pages()
> - set i_size to zero after truncation
> fs/f2fs/file.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index ac61c88f7688..a316c21539d1 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -2199,11 +2199,17 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
> F2FS_I(fi->cow_inode)->atomic_inode = inode;
> } else {
> /* Reuse the already created COW inode */
> + f2fs_bug_on(sbi, get_dirty_pages(fi->cow_inode));
> +
> + invalidate_mapping_pages(fi->cow_inode->i_mapping, 0, -1);
> +
> ret = f2fs_do_truncate_blocks(fi->cow_inode, 0, true);
> if (ret) {
> f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
> goto out;
> }
> +
> + i_size_write(fi->cow_inode, 0);
Do we really need this?
> }
>
> f2fs_write_inode(inode, NULL);
> --
> 2.40.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] 2+ messages in thread
end of thread, other threads:[~2024-08-06 2:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-01 1:13 [f2fs-dev] [PATCH v3 3/4] f2fs: atomic: fix to truncate pagecache before on-disk metadata truncation Chao Yu
2024-08-06 2:43 ` 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).