diff mbox series

[f2fs-dev,3/4] f2fs: atomic: fix to truncate pagecache before on-disk metadata truncation

Message ID 20240625031351.3586955-3-chao@kernel.org (mailing list archive)
State New
Headers show
Series [f2fs-dev,1/4] f2fs: atomic: fix to avoid racing w/ GC | expand

Commit Message

Chao Yu June 25, 2024, 3:13 a.m. UTC
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>
---
 fs/f2fs/file.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Jaegeuk Kim July 25, 2024, 8:54 p.m. UTC | #1
On 06/25, 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>
> ---
>  fs/f2fs/file.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 2203904383a6..0355cb054521 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -2185,6 +2185,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
>  		clear_inode_flag(fi->cow_inode, FI_INLINE_DATA);
>  	} else {
>  		/* Reuse the already created COW inode */
> +		truncate_setsize(inode, 0);

		fi->cow_inode?

>  		ret = f2fs_do_truncate_blocks(fi->cow_inode, 0, true);
>  		if (ret) {
>  			f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
> -- 
> 2.40.1
Chao Yu July 26, 2024, 1:06 a.m. UTC | #2
On 2024/7/26 4:54, Jaegeuk Kim wrote:
> On 06/25, 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>
>> ---
>>   fs/f2fs/file.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index 2203904383a6..0355cb054521 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -2185,6 +2185,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
>>   		clear_inode_flag(fi->cow_inode, FI_INLINE_DATA);
>>   	} else {
>>   		/* Reuse the already created COW inode */
>> +		truncate_setsize(inode, 0);
> 
> 		fi->cow_inode?

Oh, yes, let me fix this.

Thanks,

> 
>>   		ret = f2fs_do_truncate_blocks(fi->cow_inode, 0, true);
>>   		if (ret) {
>>   			f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
>> -- 
>> 2.40.1
diff mbox series

Patch

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 2203904383a6..0355cb054521 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2185,6 +2185,7 @@  static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
 		clear_inode_flag(fi->cow_inode, FI_INLINE_DATA);
 	} else {
 		/* Reuse the already created COW inode */
+		truncate_setsize(inode, 0);
 		ret = f2fs_do_truncate_blocks(fi->cow_inode, 0, true);
 		if (ret) {
 			f2fs_up_write(&fi->i_gc_rwsem[WRITE]);