From: Jaegeuk Kim <jaegeuk@kernel.org>
To: wangzijie <wangzijie1@honor.com>
Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, bintian.wang@honor.com,
feng.han@honor.com, niuzhiguo84@gmail.com
Subject: Re: [f2fs-dev] [PATCH v3 1/2] f2fs: don't allow unaligned truncation to smaller/equal size on pinned file
Date: Mon, 23 Jun 2025 17:54:11 +0000 [thread overview]
Message-ID: <aFmUw46N1ibXcgIj@google.com> (raw)
In-Reply-To: <20250618064303.2477852-1-wangzijie1@honor.com>
Hi,
Please do sbi conversion first, and apply this change.
On 06/18, wangzijie wrote:
> To prevent scattered pin block generation, don't allow non-section aligned truncation
> to smaller or equal size on pinned file. But for truncation to larger size, after
> commit 3fdd89b452c2("f2fs: prevent writing without fallocate() for pinned files"),
> we only support overwrite IO to pinned file, so we don't need to consider
> attr->ia_size > i_size case.
>
> Signed-off-by: wangzijie <wangzijie1@honor.com>
> ---
> v3:
> - cover attr->ia_size == i_size case
> v2:
> - add comments and change a proper subject
> ---
> fs/f2fs/file.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 6bd3de64f..9e0f1c98f 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1026,6 +1026,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> {
> struct inode *inode = d_inode(dentry);
> struct f2fs_inode_info *fi = F2FS_I(inode);
> + struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
> int err;
>
> if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> @@ -1047,6 +1048,17 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> !IS_ALIGNED(attr->ia_size,
> F2FS_BLK_TO_BYTES(fi->i_cluster_size)))
> return -EINVAL;
> + /*
> + * To prevent scattered pin block generation, we don't allow
> + * smaller/equal size unaligned truncation for pinned file.
> + * We only support overwrite IO to pinned file, so don't
> + * care about larger size truncation.
> + */
> + if (f2fs_is_pinned_file(inode) &&
> + attr->ia_size <= i_size_read(inode) &&
> + !IS_ALIGNED(attr->ia_size,
> + F2FS_BLK_TO_BYTES(CAP_BLKS_PER_SEC(sbi))))
> + return -EINVAL;
> }
>
> err = setattr_prepare(idmap, dentry, attr);
> --
> 2.25.1
prev parent reply other threads:[~2025-06-23 17:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-18 6:43 wangzijie
2025-06-18 6:43 ` [f2fs-dev] [PATCH v3 2/2] f2fs: cleanup F2FS_I_SB in f2fs_setattr() wangzijie
2025-06-23 17:54 ` Jaegeuk Kim [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aFmUw46N1ibXcgIj@google.com \
--to=jaegeuk@kernel.org \
--cc=bintian.wang@honor.com \
--cc=chao@kernel.org \
--cc=feng.han@honor.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=niuzhiguo84@gmail.com \
--cc=wangzijie1@honor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®