]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
VFS: Provide empty name qstr
authorDavid Howells <dhowells@redhat.com>
Tue, 4 Jul 2017 16:25:22 +0000 (17:25 +0100)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 6 Jul 2017 07:27:09 +0000 (03:27 -0400)
Provide an empty name (ie. "") qstr for general use.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/dcache.c
fs/gfs2/dir.c
fs/namei.c
fs/nsfs.c
fs/pipe.c
include/linux/dcache.h

index a9f995f6859eb19ea3c5cddac19d86512ccf1d1e..95efb7b2bf841fe3d3f6aff9bf9759a937a1ddd5 100644 (file)
@@ -90,6 +90,11 @@ EXPORT_SYMBOL(rename_lock);
 
 static struct kmem_cache *dentry_cache __read_mostly;
 
+const struct qstr empty_name = QSTR_INIT("", 0);
+EXPORT_SYMBOL(empty_name);
+const struct qstr slash_name = QSTR_INIT("/", 1);
+EXPORT_SYMBOL(slash_name);
+
 /*
  * This is the single most critical data structure when it comes
  * to the dcache: the hashtable for lookups. Somebody should try
@@ -1578,8 +1583,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
         */
        dentry->d_iname[DNAME_INLINE_LEN-1] = 0;
        if (unlikely(!name)) {
-               static const struct qstr anon = QSTR_INIT("/", 1);
-               name = &anon;
+               name = &slash_name;
                dname = dentry->d_iname;
        } else if (name->len > DNAME_INLINE_LEN-1) {
                size_t size = offsetof(struct external_name, name[1]);
index 79113219be5f983c7ecf62d56c5fd6d6f87a57b6..a5dfff6a033ebdf86ef19f9b00e12853a2c0a202 100644 (file)
@@ -872,7 +872,6 @@ static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh,
        struct buffer_head *bh;
        struct gfs2_leaf *leaf;
        struct gfs2_dirent *dent;
-       struct qstr name = { .name = "" };
        struct timespec tv = current_time(inode);
 
        error = gfs2_alloc_blocks(ip, &bn, &n, 0, NULL);
@@ -896,7 +895,7 @@ static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh,
        leaf->lf_sec = cpu_to_be64(tv.tv_sec);
        memset(leaf->lf_reserved2, 0, sizeof(leaf->lf_reserved2));
        dent = (struct gfs2_dirent *)(leaf+1);
-       gfs2_qstr2dirent(&name, bh->b_size - sizeof(struct gfs2_leaf), dent);
+       gfs2_qstr2dirent(&empty_name, bh->b_size - sizeof(struct gfs2_leaf), dent);
        *pbh = bh;
        return leaf;
 }
index 6571a5f5112ed82894fdbec1c9b6dfaf557d93b1..0d35760fee00a5be32856d36f3d519ee5bf33b55 100644 (file)
@@ -3400,7 +3400,6 @@ out:
 
 struct dentry *vfs_tmpfile(struct dentry *dentry, umode_t mode, int open_flag)
 {
-       static const struct qstr name = QSTR_INIT("/", 1);
        struct dentry *child = NULL;
        struct inode *dir = dentry->d_inode;
        struct inode *inode;
@@ -3414,7 +3413,7 @@ struct dentry *vfs_tmpfile(struct dentry *dentry, umode_t mode, int open_flag)
        if (!dir->i_op->tmpfile)
                goto out_err;
        error = -ENOMEM;
-       child = d_alloc(dentry, &name);
+       child = d_alloc(dentry, &slash_name);
        if (unlikely(!child))
                goto out_err;
        error = dir->i_op->tmpfile(dir, child, mode);
index f3db56e83dd204279895751e8cd885f15c28b2f5..08127a2b8559ab9660b7dcced023770ff8588c59 100644 (file)
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -53,7 +53,6 @@ static void nsfs_evict(struct inode *inode)
 static void *__ns_get_path(struct path *path, struct ns_common *ns)
 {
        struct vfsmount *mnt = nsfs_mnt;
-       struct qstr qname = { .name = "", };
        struct dentry *dentry;
        struct inode *inode;
        unsigned long d;
@@ -85,7 +84,7 @@ slow:
        inode->i_fop = &ns_file_operations;
        inode->i_private = ns;
 
-       dentry = d_alloc_pseudo(mnt->mnt_sb, &qname);
+       dentry = d_alloc_pseudo(mnt->mnt_sb, &empty_name);
        if (!dentry) {
                iput(inode);
                return ERR_PTR(-ENOMEM);
index 73b84baf58f8751393a3adda7cd288fbd044d252..97e5be897753ef61c67b3534205f9839b715942e 100644 (file)
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -739,13 +739,12 @@ int create_pipe_files(struct file **res, int flags)
        struct inode *inode = get_pipe_inode();
        struct file *f;
        struct path path;
-       static struct qstr name = { .name = "" };
 
        if (!inode)
                return -ENFILE;
 
        err = -ENOMEM;
-       path.dentry = d_alloc_pseudo(pipe_mnt->mnt_sb, &name);
+       path.dentry = d_alloc_pseudo(pipe_mnt->mnt_sb, &empty_name);
        if (!path.dentry)
                goto err_inode;
        path.mnt = mntget(pipe_mnt);
index d2e38dc6172c0670472e654103f2f0bfa0d1b2ba..3f65a4fa72edad0dc90ebd1373f2c57629701579 100644 (file)
@@ -55,6 +55,11 @@ struct qstr {
 
 #define QSTR_INIT(n,l) { { { .len = l } }, .name = n }
 
+extern const char empty_string[];
+extern const struct qstr empty_name;
+extern const char slash_string[];
+extern const struct qstr slash_name;
+
 struct dentry_stat_t {
        long nr_dentry;
        long nr_unused;