Re: [PATCH v2 2/4] fscrypt: update fscrypt_prepare_setflags() to use xflags
From: Amir Goldstein
Date: Fri Nov 27 2026 - 07:03:05 EST
On Fri, Nov 27, 2026 at 12:38 PM koraynilay <koray.fra@xxxxxxxxx> wrote:
>
> On Fri Nov 27, 2026 at 12:35 PM CET, Amir Goldstein wrote:
> > On Thu, Nov 26, 2026 at 5:31 PM koraynilay <koray.fra@xxxxxxxxx> wrote:
> >>
> >> Update fscrypt_prepare_setflags() to use FS_XFLAG_* xflags instead of
> >> legacy FS_*_FL flags.
> >>
> >> Signed-off-by: koraynilay <koray.fra@xxxxxxxxx>
> >> ---
> >> fs/crypto/hooks.c | 10 +++++-----
> >> fs/file_attr.c | 2 +-
> >> include/linux/fscrypt.h | 6 +++---
> >> 3 files changed, 9 insertions(+), 9 deletions(-)
> >>
> >> diff --git a/fs/crypto/hooks.c b/fs/crypto/hooks.c
> >> index 149498bdab94..52d6a33fc9e9 100644
> >> --- a/fs/crypto/hooks.c
> >> +++ b/fs/crypto/hooks.c
> >> @@ -182,10 +182,10 @@ int __fscrypt_prepare_setattr(struct dentry *dentry, struct iattr *attr)
> >> EXPORT_SYMBOL_GPL(__fscrypt_prepare_setattr);
> >>
> >> /**
> >> - * fscrypt_prepare_setflags() - prepare to change flags with FS_IOC_SETFLAGS
> >> + * fscrypt_prepare_setflags() - prepare to change xflags
> >
> > prepare to change the file attributes with file_setattr() or one of
> > the legacy ioctls
>
> Ah yes.
>
> >> * @inode: the inode on which flags are being changed
> >> - * @oldflags: the old flags
> >> - * @flags: the new flags
> >> + * @oldxflags: the old xflags
> >> + * @xflags: the new xflags
> >> *
> >> * The caller should be holding i_rwsem for write.
> >> *
> >> @@ -193,7 +193,7 @@ EXPORT_SYMBOL_GPL(__fscrypt_prepare_setattr);
> >> * another error occurs.
> >> */
> >> int fscrypt_prepare_setflags(struct inode *inode,
> >> - unsigned int oldflags, unsigned int flags)
> >> + unsigned int oldxflags, unsigned int xflags)
> >
> > This here is a backporting landmine -
> >
> > Changing the semantics drastically without changing the helper name
> > or signature.
> >
> > Please rename the helper something like fscrypt_prepare_fileattr_set()
> > so that backporting mistakes will be caught at build time.
>
> Yes, though, would it maybe be better to just use xflags_to_flags() in
> the vfs patch instead of changing the fscrypt function at all?
Yes, much better. I agree.
Now looking at the /* initialize missing bits from old_ma */
hunk my reaction is to look away its huge and it should be
using helpers probably called from within fileattr_set_prepare()
itself - because if this is de-facto preparing for a set.
Thanks,
Amir.