smb/client: handle compression flags through fileattr
Subsystems (3)
cover smb/client: handle compression flags through fileattr
From: Huiwen He <[email protected]>
This series moves CIFS compression flag updates to the generic VFS fileattr path.
- Patch1 implements ->fileattr_set for CIFS compression flags so FS_IOC_SETFLAGS uses the generic VFS permission and serialization checks.
- Patch 2 removes the old FS_IOC_GETFLAGS and FS_IOC_SETFLAGS handlers from cifs_ioctl(), which are no longer reachable.
Thanks,
Huiwen
Huiwen He (2):
smb/client: implement fileattr_set for compression flags smb/client: remove unused file flags ioctl handlers
fs/smb/client/cifsfs.c | 6 +- fs/smb/client/cifsfs.h | 2 + fs/smb/client/ioctl.c | 165 ++++++++++++++++++----------------------- 3 files changed, 79 insertions(+), 94 deletions(-)
Signature · 1 line
2.43.0
PATCH RESEND 1/2 smb/client: implement fileattr_set for compression flags
From: Huiwen He <[email protected]>
CIFS handles FS_IOC_SETFLAGS in cifs_ioctl() because it does not implement ->fileattr_set. This causes the request to fall back from the generic fileattr path and bypass its permission and serialization checks.
Implement ->fileattr_set for regular files and directories and use the existing compression helper for FS_COMPR_FL. Accept an unchanged FS_CASEFOLD_FL reported by fileattr_get so chattr can update compression on case-insensitive shares.
Tested chattr +c and -c on files and directories against Samba. Non-owner and read-only mount requests were rejected by the VFS checks.
--- fs/smb/client/cifsfs.c | 4 +- fs/smb/client/cifsfs.h | 2 + fs/smb/client/ioctl.c | 89 ++++++++++++++++++++++++++++++++++++------ 3 files changed, 81 insertions(+), 14 deletions(-)
fs/smb/client/cifsfs.c +3 -1
@@ -1195,7 +1195,7 @@ int cifs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)u32 attrs;/* Preserve FS_COMPR_FL previously reported by cifs_ioctl(). */ -if (CIFS_I (inode)->cifsAttrs &ATTR_COMPRESSED ) +if (READ_ONCE (CIFS_I (inode)->cifsAttrs) &ATTR_COMPRESSED ) fa->flags |=FS_COMPR_FL ;/*
@@ -1256,6 +1256,7 @@ const struct inode_operations cifs_dir_inode_ops = { .get_acl = cifs_get_acl, .set_acl = cifs_set_acl, .fileattr_get = cifs_fileattr_get, + .fileattr_set = cifs_fileattr_set, };const struct inode_operations cifs_file_inode_ops = {
@@ -1267,6 +1268,7 @@ const struct inode_operations cifs_file_inode_ops = { .get_acl = cifs_get_acl, .set_acl = cifs_set_acl, .fileattr_get = cifs_fileattr_get, + .fileattr_set = cifs_fileattr_set, }; const char *cifs_get_link(struct dentry *dentry, struct inode *inode,
fs/smb/client/cifsfs.h +2 -0
@@ -91,6 +91,8 @@ extern const struct inode_operations cifs_namespace_inode_operations;struct file_kattr ;int cifs_fileattr_get (struct dentry *dentry,struct file_kattr *fa); +int cifs_fileattr_set (struct mnt_idmap *idmap,struct dentry *dentry, +struct file_kattr *fa);/* Functions related to files and directories */
fs/smb/client/ioctl.c +76 -13
143 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH RESEND 2/2 smb/client: remove unused file flags ioctl handlers
In reply to Huiwen HeFrom: Huiwen He <[email protected]>
FS_IOC_GETFLAGS and FS_IOC_SETFLAGS are now handled by the generic VFS fileattr path, so their cifs_ioctl() handlers are unreachable. Remove the handlers and associated state.
--- fs/smb/client/cifsfs.c | 2 +- fs/smb/client/ioctl.c | 82 ------------------------------------------ 2 files changed, 1 insertion(+), 83 deletions(-)
fs/smb/client/cifsfs.c +1 -1
@@ -1194,7 +1194,7 @@ int cifs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)struct inode *inode =d_inode (dentry);u32 attrs; -/* Preserve FS_COMPR_FL previously reported by cifs_ioctl(). */ +/* Report the cached SMB compressed attribute as FS_COMPR_FL. */ if (READ_ONCE (CIFS_I (inode)->cifsAttrs) &ATTR_COMPRESSED ) fa->flags |=FS_COMPR_FL ;
fs/smb/client/ioctl.c +0 -82
94 lines not on this page · raw message
Signature · 1 line
2.43.0
Namjae Jeon
maintainerQuoted 12 lines · Huiwen He
From: Huiwen He <[email protected]>
This series moves CIFS compression flag updates to the generic VFS fileattr path.
- Patch1 implements ->fileattr_set for CIFS compression flags so
FS_IOC_SETFLAGSuses the generic VFS permission and serialization checks.- Patch 2 removes the old
FS_IOC_GETFLAGSandFS_IOC_SETFLAGShandlers fromcifs_ioctl(), which are no longer reachable.
Quoted 6 lines
Thanks,
HuiwenHuiwen He (2):
smb/client: implementfileattr_setfor compression flags smb/client: remove unused file flags ioctl handlers
Will apply these to #for-next.
Thanks!