-
Notifications
You must be signed in to change notification settings - Fork 94
[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] fs: backport VFS-related patches in preparation for EROFS file-backed mount #966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: linux-6.6.y
Are you sure you want to change the base?
Conversation
Reviewer's GuideThis PR backports upstream VFS patches to introduce filesystem UUID and sysfs‐path support by extending super_block, adding new ioctls, and updating existing filesystems to use a unified super_set_uuid interface. Sequence diagram for FS_IOC_GETFSUUID ioctl handlingsequenceDiagram
actor User
participant Kernel as Kernel (do_vfs_ioctl)
participant File as file
participant SB as super_block
User->>Kernel: ioctl(fd, FS_IOC_GETFSUUID, ...)
Kernel->>File: get file_inode(file)
File->>SB: access s_uuid, s_uuid_len
Kernel-->>User: copy fsuuid2 struct to user
Sequence diagram for FS_IOC_GETFSSYSFSPATH ioctl handlingsequenceDiagram
actor User
participant Kernel as Kernel (do_vfs_ioctl)
participant File as file
participant SB as super_block
User->>Kernel: ioctl(fd, FS_IOC_GETFSSYSFSPATH, ...)
Kernel->>File: get file_inode(file)
File->>SB: access s_sysfs_name
Kernel-->>User: copy fs_sysfs_path struct to user
Class diagram for updated struct super_block and new helpersclassDiagram
class super_block {
char s_id[32]
uuid_t s_uuid
u8 s_uuid_len
char s_sysfs_name[UUID_STRING_LEN + 1]
...
}
class super_set_uuid {
+void super_set_uuid(super_block *sb, const u8 *uuid, unsigned len)
}
class super_set_sysfs_name_bdev {
+void super_set_sysfs_name_bdev(super_block *sb)
}
class super_set_sysfs_name_uuid {
+void super_set_sysfs_name_uuid(super_block *sb)
}
class super_set_sysfs_name_id {
+void super_set_sysfs_name_id(super_block *sb)
}
class super_set_sysfs_name_generic {
+void super_set_sysfs_name_generic(super_block *sb, const char *fmt, ...)
}
super_set_uuid --|> super_block : modifies
super_set_sysfs_name_bdev --|> super_block : modifies
super_set_sysfs_name_uuid --|> super_block : modifies
super_set_sysfs_name_id --|> super_block : modifies
super_set_sysfs_name_generic --|> super_block : modifies
Class diagram for new ioctl data structuresclassDiagram
class fsuuid2 {
__u8 len
__u8 uuid[16]
}
class fs_sysfs_path {
__u8 len
__u8 name[128]
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR backports VFS-related patches from upstream to prepare for EROFS file-backed mount support. The changes introduce new filesystem ioctl operations and standardize UUID handling across filesystems.
- Adds new FS_IOC_GETFSUUID and FS_IOC_GETFSSYSFSPATH ioctl operations for filesystem introspection
- Introduces super_set_uuid() helper function and updates all filesystem drivers to use it consistently
- Extends super_block structure with s_uuid_len and s_sysfs_name fields for better filesystem identification
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
include/uapi/linux/fs.h | Defines new ioctl structures and command constants |
include/linux/fs.h | Adds new super_block fields and UUID helper functions |
fs/ioctl.c | Implements the new ioctl handlers |
mm/shmem.c | Updates to use new super_set_uuid() helper |
fs/kernfs/mount.c | Updates to use new super_set_uuid() helper |
fs/xfs/xfs_mount.c | Updates to use new super_set_uuid() helper |
fs/ubifs/super.c | Updates to use new super_set_uuid() helper |
fs/ocfs2/super.c | Updates to use new super_set_uuid() helper |
fs/gfs2/ops_fstype.c | Updates to use new super_set_uuid() helper |
fs/f2fs/super.c | Updates to use new super_set_uuid() helper |
fs/ext4/super.c | Updates to use new super_set_uuid() helper |
Documentation/userspace-api/ioctl/ioctl-number.rst | Updates ioctl number documentation |
* We include a length field because some filesystems (vfat) have an identifier | ||
* that we do want to expose as a UUID, but doesn't have the standard length. | ||
* | ||
* We use a fixed size buffer beacuse this interface will, by fiat, never |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error: 'beacuse' should be 'because'.
* We use a fixed size buffer beacuse this interface will, by fiat, never | |
* We use a fixed size buffer because this interface will, by fiat, never |
Copilot uses AI. Check for mistakes.
|
||
if (!strlen(sb->s_sysfs_name)) | ||
return -ENOIOCTLCMD; | ||
|
||
struct fs_sysfs_path u = {}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable declaration should be at the beginning of the function scope for C89 compatibility, not in the middle of the function after other statements.
if (!strlen(sb->s_sysfs_name)) | |
return -ENOIOCTLCMD; | |
struct fs_sysfs_path u = {}; | |
struct fs_sysfs_path u = {}; | |
if (!strlen(sb->s_sysfs_name)) | |
return -ENOIOCTLCMD; |
Copilot uses AI. Check for mistakes.
commit a4af51c upstream. Some weird old filesytems have UUID-like things that we wish to expose as UUIDs, but are smaller; add a length field so that the new FS_IOC_(GET|SET)UUID ioctls can handle them in generic code. And add a helper super_set_uuid(), for setting nonstandard length uuids. Helper is now required for the new FS_IOC_GETUUID ioctl; if super_set_uuid() hasn't been called, the ioctl won't be supported. Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> Link: https://lore.kernel.org/r/20240207025624.1019754-2-kent.overstreet@linux.dev Signed-off-by: Christian Brauner <brauner@kernel.org> [ Backport from v6.9 ] Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com> Signed-off-by: WangYuli <wangyuli@uniontech.com>
commit 41bcbe5 upstream. Add a new generic ioctls for querying the filesystem UUID. These are lifted versions of the ext4 ioctls, with one change: we're not using a flexible array member, because UUIDs will never be more than 16 bytes. This patch adds a generic implementation of FS_IOC_GETFSUUID, which reads from super_block->s_uuid. We're not lifting SETFSUUID from ext4 - that can be done on offline filesystems by the people who need it, trying to do it online is just asking for too much trouble. Cc: Christian Brauner <brauner@kernel.org> Cc: Jan Kara <jack@suse.cz> Cc: Dave Chinner <dchinner@redhat.com> Cc: Darrick J. Wong <djwong@kernel.org> Cc: Theodore Ts'o <tytso@mit.edu> Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> Link: https://lore.kernel.org/r/20240207025624.1019754-4-kent.overstreet@linux.dev Signed-off-by: Christian Brauner <brauner@kernel.org> [ Backport from v6.9 ] Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com> Signed-off-by: WangYuli <wangyuli@uniontech.com>
commit ae8c511 upstream. Add a new ioctl for getting the sysfs name of a filesystem - the path under /sys/fs. This is going to let us standardize exporting data from sysfs across filesystems, e.g. time stats. The returned path will always be of the form "$FSTYP/$SYSFS_IDENTIFIER", where the sysfs identifier may be a UUID (for bcachefs) or a device name (xfs). Cc: Christian Brauner <brauner@kernel.org> Cc: Jan Kara <jack@suse.cz> Cc: Dave Chinner <dchinner@redhat.com> Cc: Darrick J. Wong <djwong@kernel.org> Cc: Theodore Ts'o <tytso@mit.edu> Cc: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> Link: https://lore.kernel.org/r/20240207025624.1019754-6-kent.overstreet@linux.dev Signed-off-by: Christian Brauner <brauner@kernel.org> [ Backport from v6.9 ] Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com> Signed-off-by: WangYuli <wangyuli@uniontech.com>
cdd54f9
to
d047b31
Compare
deepin pr auto review代码审查意见:
总体来说,这些改动提高了代码的可读性、可维护性和功能性,但应进一步确保所有新增函数和结构体的正确性和一致性。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Avenger-285714 - I've reviewed your changes - here's some feedback:
- The new IOCTL FS_IOC_GETFSSYSFSPATH exposes internal sysfs paths without any capability checks; consider adding a permission check (e.g. CAP_SYS_ADMIN) to avoid leaking kernel internals to unprivileged users.
- The Q/A style comment block added above the super_block fields deviates from kernel coding style—please convert it into a concise explanatory comment or remove the ‘q:/a:’ lines.
- In ioctl_get_fs_sysfs_path, replace strlen(sb->s_sysfs_name) with a simple sb->s_sysfs_name[0] check to avoid scanning the entire buffer for emptiness.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new IOCTL FS_IOC_GETFSSYSFSPATH exposes internal sysfs paths without any capability checks; consider adding a permission check (e.g. CAP_SYS_ADMIN) to avoid leaking kernel internals to unprivileged users.
- The Q/A style comment block added above the super_block fields deviates from kernel coding style—please convert it into a concise explanatory comment or remove the ‘q:/a:’ lines.
- In ioctl_get_fs_sysfs_path, replace strlen(sb->s_sysfs_name) with a simple sb->s_sysfs_name[0] check to avoid scanning the entire buffer for emptiness.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This cherry picks the following VFS patches from upstream:
fs: add FS_IOC_GETFSSYSFSPATH
fs: FS_IOC_GETUUID
fs: super_set_uuid()
There are no conflicts.
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=11101
Link: https://gitee.com/anolis/cloud-kernel/pulls/4230
Summary by Sourcery
Backport upstream VFS patches to expose filesystem UUID and sysfs path via new ioctls, extend super_block with metadata fields and helpers, update filesystem code to use the new helpers, and update the ioctl documentation
New Features:
Enhancements:
Documentation: