diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-07 20:03:32 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-07 20:03:32 -0700 |
commit | d27fb65bc2389621040e5107baedb94b4cccf641 (patch) | |
tree | 4123a7b82dd048dc8b0602994a5db6f4b9885998 /fs | |
parent | d3511f53bb2475f2a4e8460bee5a1ae6dea2a433 (diff) | |
parent | 795d673af1afae8146ac3070a2d77cfae5287c43 (diff) |
Merge branch 'work.dcache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull misc dcache updates from Al Viro:
"Most of this pile is putting name length into struct name_snapshot and
making use of it.
The beginning of this series ("ovl_lookup_real_one(): don't bother
with strlen()") ought to have been split in two (separate switch of
name_snapshot to struct qstr from overlayfs reaping the trivial
benefits of that), but I wanted to avoid a rebase - by the time I'd
spotted that it was (a) in -next and (b) close to 5.1-final ;-/"
* 'work.dcache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
audit_compare_dname_path(): switch to const struct qstr *
audit_update_watch(): switch to const struct qstr *
inotify_handle_event(): don't bother with strlen()
fsnotify: switch send_to_group() and ->handle_event to const struct qstr *
fsnotify(): switch to passing const struct qstr * for file_name
switch fsnotify_move() to passing const struct qstr * for old_name
ovl_lookup_real_one(): don't bother with strlen()
sysv: bury the broken "quietly truncate the long filenames" logics
nsfs: unobfuscate
unexport d_alloc_pseudo()
Diffstat (limited to 'fs')
-rw-r--r-- | fs/dcache.c | 18 | ||||
-rw-r--r-- | fs/debugfs/inode.c | 2 | ||||
-rw-r--r-- | fs/internal.h | 1 | ||||
-rw-r--r-- | fs/kernfs/file.c | 6 | ||||
-rw-r--r-- | fs/namei.c | 4 | ||||
-rw-r--r-- | fs/notify/dnotify/dnotify.c | 2 | ||||
-rw-r--r-- | fs/notify/fanotify/fanotify.c | 2 | ||||
-rw-r--r-- | fs/notify/fsnotify.c | 8 | ||||
-rw-r--r-- | fs/notify/inotify/inotify.h | 2 | ||||
-rw-r--r-- | fs/notify/inotify/inotify_fsnotify.c | 6 | ||||
-rw-r--r-- | fs/nsfs.c | 23 | ||||
-rw-r--r-- | fs/overlayfs/export.c | 2 | ||||
-rw-r--r-- | fs/sysv/namei.c | 15 | ||||
-rw-r--r-- | fs/sysv/super.c | 3 | ||||
-rw-r--r-- | fs/sysv/sysv.h | 3 |
15 files changed, 38 insertions, 59 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index c663c602f9ef..982d97bbb72c 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -284,25 +284,23 @@ static inline int dname_external(const struct dentry *dentry) void take_dentry_name_snapshot(struct name_snapshot *name, struct dentry *dentry) { spin_lock(&dentry->d_lock); + name->name = dentry->d_name; if (unlikely(dname_external(dentry))) { - struct external_name *p = external_name(dentry); - atomic_inc(&p->u.count); - spin_unlock(&dentry->d_lock); - name->name = p->name; + atomic_inc(&external_name(dentry)->u.count); } else { memcpy(name->inline_name, dentry->d_iname, dentry->d_name.len + 1); - spin_unlock(&dentry->d_lock); - name->name = name->inline_name; + name->name.name = name->inline_name; } + spin_unlock(&dentry->d_lock); } EXPORT_SYMBOL(take_dentry_name_snapshot); void release_dentry_name_snapshot(struct name_snapshot *name) { - if (unlikely(name->name != name->inline_name)) { + if (unlikely(name->name.name != name->inline_name)) { struct external_name *p; - p = container_of(name->name, struct external_name, name[0]); + p = container_of(name->name.name, struct external_name, name[0]); if (unlikely(atomic_dec_and_test(&p->u.count))) kfree_rcu(p, u.head); } @@ -1742,6 +1740,9 @@ struct dentry *d_alloc_cursor(struct dentry * parent) * never be anyone's children or parents. Unlike all other * dentries, these will not have RCU delay between dropping the * last reference and freeing them. + * + * The only user is alloc_file_pseudo() and that's what should + * be considered a public interface. Don't use directly. */ struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name) { @@ -1750,7 +1751,6 @@ struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name) dentry->d_flags |= DCACHE_NORCU; return dentry; } -EXPORT_SYMBOL(d_alloc_pseudo); struct dentry *d_alloc_name(struct dentry *parent, const char *name) { diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 414fa4752047..acef14ad53db 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -818,7 +818,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, goto exit; } d_move(old_dentry, dentry); - fsnotify_move(d_inode(old_dir), d_inode(new_dir), old_name.name, + fsnotify_move(d_inode(old_dir), d_inode(new_dir), &old_name.name, d_is_dir(old_dentry), NULL, old_dentry); release_dentry_name_snapshot(&old_name); diff --git a/fs/internal.h b/fs/internal.h index 82b78aec1ce9..17a8ae967493 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -155,6 +155,7 @@ extern struct dentry *__d_alloc(struct super_block *, const struct qstr *); extern int d_set_mounted(struct dentry *dentry); extern long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc); extern struct dentry *d_alloc_cursor(struct dentry *); +extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *); /* * read_write.c diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index ae948aaa4c53..553ce0a92b05 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -885,6 +885,7 @@ repeat: list_for_each_entry(info, &kernfs_root(kn)->supers, node) { struct kernfs_node *parent; struct inode *inode; + struct qstr name; /* * We want fsnotify_modify() on @kn but as the @@ -896,6 +897,7 @@ repeat: if (!inode) continue; + name = (struct qstr)QSTR_INIT(kn->name, strlen(kn->name)); parent = kernfs_get_parent(kn); if (parent) { struct inode *p_inode; @@ -903,7 +905,7 @@ repeat: p_inode = ilookup(info->sb, parent->id.ino); if (p_inode) { fsnotify(p_inode, FS_MODIFY | FS_EVENT_ON_CHILD, - inode, FSNOTIFY_EVENT_INODE, kn->name, 0); + inode, FSNOTIFY_EVENT_INODE, &name, 0); iput(p_inode); } @@ -911,7 +913,7 @@ repeat: } fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE, - kn->name, 0); + &name, 0); iput(inode); } diff --git a/fs/namei.c b/fs/namei.c index dede0147b3f6..5ebd64b21970 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4498,10 +4498,10 @@ out: inode_unlock(target); dput(new_dentry); if (!error) { - fsnotify_move(old_dir, new_dir, old_name.name, is_dir, + fsnotify_move(old_dir, new_dir, &old_name.name, is_dir, !(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry); if (flags & RENAME_EXCHANGE) { - fsnotify_move(new_dir, old_dir, old_dentry->d_name.name, + fsnotify_move(new_dir, old_dir, &old_dentry->d_name, new_is_dir, NULL, new_dentry); } } diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c index 58d77dc696eb..250369d6901d 100644 --- a/fs/notify/dnotify/dnotify.c +++ b/fs/notify/dnotify/dnotify.c @@ -81,7 +81,7 @@ static void dnotify_recalc_inode_mask(struct fsnotify_mark *fsn_mark) static int dnotify_handle_event(struct fsnotify_group *group, struct inode *inode, u32 mask, const void *data, int data_type, - const unsigned char *file_name, u32 cookie, + const struct qstr *file_name, u32 cookie, struct fsnotify_iter_info *iter_info) { struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info); diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 63c6bb1f8c4d..e6fde1a5c072 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -367,7 +367,7 @@ static __kernel_fsid_t fanotify_get_fsid(struct fsnotify_iter_info *iter_info) static int fanotify_handle_event(struct fsnotify_group *group, struct inode *inode, u32 mask, const void *data, int data_type, - const unsigned char *file_name, u32 cookie, + const struct qstr *file_name, u32 cookie, struct fsnotify_iter_info *iter_info) { int ret = 0; diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index df06f3da166c..5433e37fb0c5 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -179,10 +179,10 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask take_dentry_name_snapshot(&name, dentry); if (path) ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH, - name.name, 0); + &name.name, 0); else ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE, - name.name, 0); + &name.name, 0); release_dentry_name_snapshot(&name); } @@ -195,7 +195,7 @@ EXPORT_SYMBOL_GPL(__fsnotify_parent); static int send_to_group(struct inode *to_tell, __u32 mask, const void *data, int data_is, u32 cookie, - const unsigned char *file_name, + const struct qstr *file_name, struct fsnotify_iter_info *iter_info) { struct fsnotify_group *group = NULL; @@ -325,7 +325,7 @@ static void fsnotify_iter_next(struct fsnotify_iter_info *iter_info) * notification event in whatever means they feel necessary. */ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, - const unsigned char *file_name, u32 cookie) + const struct qstr *file_name, u32 cookie) { struct fsnotify_iter_info iter_info = {}; struct super_block *sb = to_tell->i_sb; diff --git a/fs/notify/inotify/inotify.h b/fs/notify/inotify/inotify.h index 74ae60305189..3f246f7b8a92 100644 --- a/fs/notify/inotify/inotify.h +++ b/fs/notify/inotify/inotify.h @@ -27,7 +27,7 @@ extern void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark, extern int inotify_handle_event(struct fsnotify_group *group, struct inode *inode, u32 mask, const void *data, int data_type, - const unsigned char *file_name, u32 cookie, + const struct qstr *file_name, u32 cookie, struct fsnotify_iter_info *iter_info); extern const struct fsnotify_ops inotify_fsnotify_ops; diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c index ff30abd6a49b..7e8b131029f8 100644 --- a/fs/notify/inotify/inotify_fsnotify.c +++ b/fs/notify/inotify/inotify_fsnotify.c @@ -67,7 +67,7 @@ static int inotify_merge(struct list_head *list, int inotify_handle_event(struct fsnotify_group *group, struct inode *inode, u32 mask, const void *data, int data_type, - const unsigned char *file_name, u32 cookie, + const struct qstr *file_name, u32 cookie, struct fsnotify_iter_info *iter_info) { struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info); @@ -89,7 +89,7 @@ int inotify_handle_event(struct fsnotify_group *group, return 0; } if (file_name) { - len = strlen(file_name); + len = file_name->len; alloc_len += len + 1; } @@ -129,7 +129,7 @@ int inotify_handle_event(struct fsnotify_group *group, event->sync_cookie = cookie; event->name_len = len; if (len) - strcpy(event->name, file_name); + strcpy(event->name, file_name->name); ret = fsnotify_add_event(group, fsn_event, inotify_merge); if (ret) { diff --git a/fs/nsfs.c b/fs/nsfs.c index 30d150a4f0c6..e3bf08c5af41 100644 --- a/fs/nsfs.c +++ b/fs/nsfs.c @@ -105,17 +105,16 @@ slow: void *ns_get_path_cb(struct path *path, ns_get_path_helper_t *ns_get_cb, void *private_data) { - struct ns_common *ns; void *ret; -again: - ns = ns_get_cb(private_data); - if (!ns) - return ERR_PTR(-ENOENT); + do { + struct ns_common *ns = ns_get_cb(private_data); + if (!ns) + return ERR_PTR(-ENOENT); + + ret = __ns_get_path(path, ns); + } while (ret == ERR_PTR(-EAGAIN)); - ret = __ns_get_path(path, ns); - if (IS_ERR(ret) && PTR_ERR(ret) == -EAGAIN) - goto again; return ret; } @@ -154,7 +153,7 @@ int open_related_ns(struct ns_common *ns, if (fd < 0) return fd; - while (1) { + do { struct ns_common *relative; relative = get_ns(ns); @@ -164,10 +163,8 @@ int open_related_ns(struct ns_common *ns, } err = __ns_get_path(&path, relative); - if (IS_ERR(err) && PTR_ERR(err) == -EAGAIN) - continue; - break; - } + } while (err == ERR_PTR(-EAGAIN)); + if (IS_ERR(err)) { put_unused_fd(fd); return PTR_ERR(err); diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c index 54e5d17d7f3e..cc1c9e5606ba 100644 --- a/fs/overlayfs/export.c +++ b/fs/overlayfs/export.c @@ -398,7 +398,7 @@ static struct dentry *ovl_lookup_real_one(struct dentry *connected, * pointer because we hold no lock on the real dentry. */ take_dentry_name_snapshot(&name, real); - this = lookup_one_len(name.name, connected, strlen(name.name)); + this = lookup_one_len(name.name.name, connected, name.name.len); err = PTR_ERR(this); if (IS_ERR(this)) { goto fail; diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index 4d5d20491ffd..ea2414b385ec 100644 --- a/fs/sysv/namei.c +++ b/fs/sysv/namei.c @@ -28,21 +28,6 @@ static int add_nondir(struct dentry *dentry, struct inode *inode) return err; } -static int sysv_hash(const struct dentry *dentry, struct qstr *qstr) -{ - /* Truncate the name in place, avoids having to define a compare - function. */ - if (qstr->len > SYSV_NAMELEN) { - qstr->len = SYSV_NAMELEN; - qstr->hash = full_name_hash(dentry, qstr->name, qstr->len); - } - return 0; -} - -const struct dentry_operations sysv_dentry_operations = { - .d_hash = sysv_hash, -}; - static struct dentry *sysv_lookup(struct inode * dir, struct dentry * dentry, unsigned int flags) { struct inode * inode = NULL; diff --git a/fs/sysv/super.c b/fs/sysv/super.c index 89765ddfb738..d3b2f54d6449 100644 --- a/fs/sysv/super.c +++ b/fs/sysv/super.c @@ -312,7 +312,6 @@ static int complete_read_super(struct super_block *sb, int silent, int size) flavour_setup[sbi->s_type](sbi, &sb->s_max_links); - sbi->s_truncate = 1; sbi->s_ndatazones = sbi->s_nzones - sbi->s_firstdatazone; sbi->s_inodes_per_block = bsize >> 6; sbi->s_inodes_per_block_1 = (bsize >> 6)-1; @@ -334,8 +333,6 @@ static int complete_read_super(struct super_block *sb, int silent, int size) sb->s_op = &sysv_sops; if (sbi->s_forced_ro) sb->s_flags |= SB_RDONLY; - if (sbi->s_truncate) - sb->s_d_op = &sysv_dentry_operations; root_inode = sysv_iget(sb, SYSV_ROOT_INO); if (IS_ERR(root_inode)) { printk("SysV FS: get root inode failed\n"); diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h index e913698779c0..1cff585526b1 100644 --- a/fs/sysv/sysv.h +++ b/fs/sysv/sysv.h @@ -23,8 +23,6 @@ struct sysv_sb_info { struct super_block *s_sb; /* VFS superblock */ int s_type; /* file system type: FSTYPE_{XENIX|SYSV|COH} */ char s_bytesex; /* bytesex (le/be/pdp) */ - char s_truncate; /* if 1: names > SYSV_NAMELEN chars are truncated */ - /* if 0: they are disallowed (ENAMETOOLONG) */ unsigned int s_inodes_per_block; /* number of inodes per block */ unsigned int s_inodes_per_block_1; /* inodes_per_block - 1 */ unsigned int s_inodes_per_block_bits; /* log2(inodes_per_block) */ @@ -166,7 +164,6 @@ extern const struct file_operations sysv_file_operations; extern const struct file_operations sysv_dir_operations; extern const struct address_space_operations sysv_aops; extern const struct super_operations sysv_sops; -extern const struct dentry_operations sysv_dentry_operations; enum { |