Skip to content

Commit a4f7fae

Browse files
committed
Merge branch 'miklos.fileattr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull fileattr conversion updates from Miklos Szeredi via Al Viro: "This splits the handling of FS_IOC_[GS]ETFLAGS from ->ioctl() into a separate method. The interface is reasonably uniform across the filesystems that support it and gives nice boilerplate removal" * 'miklos.fileattr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (23 commits) ovl: remove unneeded ioctls fuse: convert to fileattr fuse: add internal open/release helpers fuse: unsigned open flags fuse: move ioctl to separate source file vfs: remove unused ioctl helpers ubifs: convert to fileattr reiserfs: convert to fileattr ocfs2: convert to fileattr nilfs2: convert to fileattr jfs: convert to fileattr hfsplus: convert to fileattr efivars: convert to fileattr xfs: convert to fileattr orangefs: convert to fileattr gfs2: convert to fileattr f2fs: convert to fileattr ext4: convert to fileattr ext2: convert to fileattr btrfs: convert to fileattr ...
2 parents 5e67208 + c4fe8ae commit a4f7fae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1727
-2010
lines changed

Documentation/filesystems/locking.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,16 @@ prototypes::
8080
struct file *, unsigned open_flag,
8181
umode_t create_mode);
8282
int (*tmpfile) (struct inode *, struct dentry *, umode_t);
83+
int (*fileattr_set)(struct user_namespace *mnt_userns,
84+
struct dentry *dentry, struct fileattr *fa);
85+
int (*fileattr_get)(struct dentry *dentry, struct fileattr *fa);
8386

8487
locking rules:
8588
all may block
8689

87-
============ =============================================
90+
============= =============================================
8891
ops i_rwsem(inode)
89-
============ =============================================
92+
============= =============================================
9093
lookup: shared
9194
create: exclusive
9295
link: exclusive (both)
@@ -107,7 +110,9 @@ fiemap: no
107110
update_time: no
108111
atomic_open: shared (exclusive if O_CREAT is set in open flags)
109112
tmpfile: no
110-
============ =============================================
113+
fileattr_get: no or exclusive
114+
fileattr_set: exclusive
115+
============= =============================================
111116

112117

113118
Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_rwsem

Documentation/filesystems/vfs.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,9 @@ As of kernel 2.6.22, the following members are defined:
441441
unsigned open_flag, umode_t create_mode);
442442
int (*tmpfile) (struct user_namespace *, struct inode *, struct dentry *, umode_t);
443443
int (*set_acl)(struct user_namespace *, struct inode *, struct posix_acl *, int);
444+
int (*fileattr_set)(struct user_namespace *mnt_userns,
445+
struct dentry *dentry, struct fileattr *fa);
446+
int (*fileattr_get)(struct dentry *dentry, struct fileattr *fa);
444447
};
445448
446449
Again, all methods are called without any locks being held, unless
@@ -588,6 +591,18 @@ otherwise noted.
588591
atomically creating, opening and unlinking a file in given
589592
directory.
590593

594+
``fileattr_get``
595+
called on ioctl(FS_IOC_GETFLAGS) and ioctl(FS_IOC_FSGETXATTR) to
596+
retrieve miscellaneous file flags and attributes. Also called
597+
before the relevant SET operation to check what is being changed
598+
(in this case with i_rwsem locked exclusive). If unset, then
599+
fall back to f_op->ioctl().
600+
601+
``fileattr_set``
602+
called on ioctl(FS_IOC_SETFLAGS) and ioctl(FS_IOC_FSSETXATTR) to
603+
change miscellaneous file flags and attributes. Callers hold
604+
i_rwsem exclusive. If unset, then fall back to f_op->ioctl().
605+
591606

592607
The Address Space Object
593608
========================

fs/btrfs/ctree.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3207,6 +3207,9 @@ void btrfs_update_inode_bytes(struct btrfs_inode *inode,
32073207
/* ioctl.c */
32083208
long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
32093209
long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
3210+
int btrfs_fileattr_get(struct dentry *dentry, struct fileattr *fa);
3211+
int btrfs_fileattr_set(struct user_namespace *mnt_userns,
3212+
struct dentry *dentry, struct fileattr *fa);
32103213
int btrfs_ioctl_get_supported_features(void __user *arg);
32113214
void btrfs_sync_inode_flags_to_i_flags(struct inode *inode);
32123215
int __pure btrfs_is_empty_uuid(u8 *uuid);

fs/btrfs/inode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10620,6 +10620,8 @@ static const struct inode_operations btrfs_dir_inode_operations = {
1062010620
.set_acl = btrfs_set_acl,
1062110621
.update_time = btrfs_update_time,
1062210622
.tmpfile = btrfs_tmpfile,
10623+
.fileattr_get = btrfs_fileattr_get,
10624+
.fileattr_set = btrfs_fileattr_set,
1062310625
};
1062410626

1062510627
static const struct file_operations btrfs_dir_file_operations = {
@@ -10673,6 +10675,8 @@ static const struct inode_operations btrfs_file_inode_operations = {
1067310675
.get_acl = btrfs_get_acl,
1067410676
.set_acl = btrfs_set_acl,
1067510677
.update_time = btrfs_update_time,
10678+
.fileattr_get = btrfs_fileattr_get,
10679+
.fileattr_set = btrfs_fileattr_set,
1067610680
};
1067710681
static const struct inode_operations btrfs_special_inode_operations = {
1067810682
.getattr = btrfs_getattr,

0 commit comments

Comments
 (0)