* [PATCH 1/2] f2fs: prevent atomic write on pinned file
@ 2024-03-11 23:59 Daeho Jeong
2024-03-11 23:59 ` [PATCH 2/2] f2fs: prevent writing without fallocate() for pinned files Daeho Jeong
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Daeho Jeong @ 2024-03-11 23:59 UTC (permalink / raw)
To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong
From: Daeho Jeong <daehojeong@google.com>
Since atomic write way was changed to out-place-update, we should
prevent it on pinned files.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
fs/f2fs/file.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 1c044fb19c87..82277e95c88f 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2085,7 +2085,8 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
inode_lock(inode);
- if (!f2fs_disable_compressed_file(inode)) {
+ if (!f2fs_disable_compressed_file(inode) ||
+ f2fs_is_pinned_file(inode)) {
ret = -EINVAL;
goto out;
}
--
2.44.0.278.ge034bb2e1d-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] f2fs: prevent writing without fallocate() for pinned files 2024-03-11 23:59 [PATCH 1/2] f2fs: prevent atomic write on pinned file Daeho Jeong @ 2024-03-11 23:59 ` Daeho Jeong 2024-03-12 1:50 ` [f2fs-dev] " Chao Yu 2024-03-12 1:43 ` [f2fs-dev] [PATCH 1/2] f2fs: prevent atomic write on pinned file Chao Yu 2024-03-13 1:30 ` patchwork-bot+f2fs 2 siblings, 1 reply; 5+ messages in thread From: Daeho Jeong @ 2024-03-11 23:59 UTC (permalink / raw) To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong From: Daeho Jeong <daehojeong@google.com> In a case writing without fallocate(), we can't guarantee it's allocated in the conventional area for zoned stroage. Signed-off-by: Daeho Jeong <daehojeong@google.com> --- fs/f2fs/data.c | 7 +++++++ fs/f2fs/file.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index c21b92f18463..5e4c11a719a0 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3378,6 +3378,8 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi, f2fs_map_lock(sbi, flag); locked = true; } else if ((pos & PAGE_MASK) >= i_size_read(inode)) { + if (f2fs_is_pinned_file(inode)) + return -EIO; f2fs_map_lock(sbi, flag); locked = true; } @@ -3407,6 +3409,11 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi, if (!f2fs_lookup_read_extent_cache_block(inode, index, &dn.data_blkaddr)) { + if (f2fs_is_pinned_file(inode)) { + err = -EIO; + goto out; + } + if (locked) { err = f2fs_reserve_block(&dn, index); goto out; diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 82277e95c88f..f98730932fc4 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4611,6 +4611,10 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter, return ret; } + /* For pinned files, it should be fallocate()-ed in advance. */ + if (f2fs_is_pinned_file(inode)) + return 0; + /* Do not preallocate blocks that will be written partially in 4KB. */ map.m_lblk = F2FS_BLK_ALIGN(pos); map.m_len = F2FS_BYTES_TO_BLK(pos + count); -- 2.44.0.278.ge034bb2e1d-goog ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [f2fs-dev] [PATCH 2/2] f2fs: prevent writing without fallocate() for pinned files 2024-03-11 23:59 ` [PATCH 2/2] f2fs: prevent writing without fallocate() for pinned files Daeho Jeong @ 2024-03-12 1:50 ` Chao Yu 0 siblings, 0 replies; 5+ messages in thread From: Chao Yu @ 2024-03-12 1:50 UTC (permalink / raw) To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong On 2024/3/12 7:59, Daeho Jeong wrote: > From: Daeho Jeong <daehojeong@google.com> > > In a case writing without fallocate(), we can't guarantee it's allocated > in the conventional area for zoned stroage. > > Signed-off-by: Daeho Jeong <daehojeong@google.com> > --- > fs/f2fs/data.c | 7 +++++++ > fs/f2fs/file.c | 4 ++++ > 2 files changed, 11 insertions(+) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index c21b92f18463..5e4c11a719a0 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -3378,6 +3378,8 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi, > f2fs_map_lock(sbi, flag); > locked = true; > } else if ((pos & PAGE_MASK) >= i_size_read(inode)) { > + if (f2fs_is_pinned_file(inode)) > + return -EIO; > f2fs_map_lock(sbi, flag); > locked = true; > } > @@ -3407,6 +3409,11 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi, > > if (!f2fs_lookup_read_extent_cache_block(inode, index, > &dn.data_blkaddr)) { > + if (f2fs_is_pinned_file(inode)) { > + err = -EIO; > + goto out; > + } Daeho, Do we need to check in DIO path as well? Thanks, > + > if (locked) { > err = f2fs_reserve_block(&dn, index); > goto out; > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 82277e95c88f..f98730932fc4 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -4611,6 +4611,10 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter, > return ret; > } > > + /* For pinned files, it should be fallocate()-ed in advance. */ > + if (f2fs_is_pinned_file(inode)) > + return 0; > + > /* Do not preallocate blocks that will be written partially in 4KB. */ > map.m_lblk = F2FS_BLK_ALIGN(pos); > map.m_len = F2FS_BYTES_TO_BLK(pos + count); ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [f2fs-dev] [PATCH 1/2] f2fs: prevent atomic write on pinned file 2024-03-11 23:59 [PATCH 1/2] f2fs: prevent atomic write on pinned file Daeho Jeong 2024-03-11 23:59 ` [PATCH 2/2] f2fs: prevent writing without fallocate() for pinned files Daeho Jeong @ 2024-03-12 1:43 ` Chao Yu 2024-03-13 1:30 ` patchwork-bot+f2fs 2 siblings, 0 replies; 5+ messages in thread From: Chao Yu @ 2024-03-12 1:43 UTC (permalink / raw) To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong On 2024/3/12 7:59, Daeho Jeong wrote: > From: Daeho Jeong <daehojeong@google.com> > > Since atomic write way was changed to out-place-update, we should > prevent it on pinned files. > > Signed-off-by: Daeho Jeong <daehojeong@google.com> Reviewed-by: Chao Yu <chao@kernel.org> Thanks, ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [f2fs-dev] [PATCH 1/2] f2fs: prevent atomic write on pinned file 2024-03-11 23:59 [PATCH 1/2] f2fs: prevent atomic write on pinned file Daeho Jeong 2024-03-11 23:59 ` [PATCH 2/2] f2fs: prevent writing without fallocate() for pinned files Daeho Jeong 2024-03-12 1:43 ` [f2fs-dev] [PATCH 1/2] f2fs: prevent atomic write on pinned file Chao Yu @ 2024-03-13 1:30 ` patchwork-bot+f2fs 2 siblings, 0 replies; 5+ messages in thread From: patchwork-bot+f2fs @ 2024-03-13 1:30 UTC (permalink / raw) To: Daeho Jeong; +Cc: linux-kernel, linux-f2fs-devel, kernel-team, daehojeong Hello: This series was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <jaegeuk@kernel.org>: On Mon, 11 Mar 2024 16:59:19 -0700 you wrote: > From: Daeho Jeong <daehojeong@google.com> > > Since atomic write way was changed to out-place-update, we should > prevent it on pinned files. > > Signed-off-by: Daeho Jeong <daehojeong@google.com> > > [...] Here is the summary with links: - [f2fs-dev,1/2] f2fs: prevent atomic write on pinned file https://git.kernel.org/jaegeuk/f2fs/c/c644af133283 - [f2fs-dev,2/2] f2fs: prevent writing without fallocate() for pinned files (no matching commit) You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-13 1:30 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-03-11 23:59 [PATCH 1/2] f2fs: prevent atomic write on pinned file Daeho Jeong 2024-03-11 23:59 ` [PATCH 2/2] f2fs: prevent writing without fallocate() for pinned files Daeho Jeong 2024-03-12 1:50 ` [f2fs-dev] " Chao Yu 2024-03-12 1:43 ` [f2fs-dev] [PATCH 1/2] f2fs: prevent atomic write on pinned file Chao Yu 2024-03-13 1:30 ` patchwork-bot+f2fs
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox