[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d9c118eb-45b3-7f35-70bd-cb016957e6e8@kernel.org>
Date: Tue, 23 Mar 2021 21:56:22 +0800
From: Chao Yu <chao@...nel.org>
To: jaegeuk@...nel.org
Cc: linux-f2fs-devel@...ts.sourceforge.net,
linux-kernel@...r.kernel.org, Chao Yu <yuchao0@...wei.com>
Subject: Re: [PATCH] f2fs: fix to align to section for fallocate() on pinned
file
On 2021/3/5 17:56, Chao Yu wrote:
> Now, fallocate() on a pinned file only allocates blocks which aligns
> to segment rather than section, so GC may try to migrate pinned file's
> block, and after several times of failure, pinned file's block could
> be migrated to other place, however user won't be aware of such
> condition, and then old obsolete block address may be readed/written
> incorrectly.
>
> To avoid such condition, let's try to allocate pinned file's blocks
> with section alignment.
>
> Signed-off-by: Chao Yu <yuchao0@...wei.com>
Jaegeuk,
Could you please check and apply below diff into original patch?
---
fs/f2fs/file.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 236f3f69681a..24fa68fdcaa0 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1648,13 +1648,13 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
return 0;
if (f2fs_is_pinned_file(inode)) {
- block_t len = (map.m_len >> sbi->log_blocks_per_seg) <<
- sbi->log_blocks_per_seg;
+ block_t sec_blks = BLKS_PER_SEC(sbi);
+ block_t len = rounddown(map.m_len, sec_blks);
- if (map.m_len % sbi->blocks_per_seg)
- len += sbi->blocks_per_seg;
+ if (map.m_len % sec_blks)
+ len += sec_blks;
- map.m_len = sbi->blocks_per_seg;
+ map.m_len = sec_blks;
next_alloc:
if (has_not_enough_free_secs(sbi, 0,
GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))) {
--
2.22.1
Powered by blists - more mailing lists