Skip to content

Commit

Permalink
Merge tag 'pull-misc' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/viro/vfs

Pull misc vfs cleanups from Al Viro:
 "Two unrelated patches - one is a removal of long-obsolete include in
  overlayfs (it used to need fs/internal.h, but the extern it wanted has
  been moved back to include/linux/namei.h) and another introduces
  convenience helper constructing struct qstr by a NUL-terminated
  string"

* tag 'pull-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  add a string-to-qstr constructor
  fs/overlayfs/namei.c: get rid of include ../internal.h
  • Loading branch information
torvalds committed Feb 1, 2025
2 parents c270ab5 + c1feab9 commit a86bf22
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 24 deletions.
4 changes: 2 additions & 2 deletions fs/anon_inodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ static struct inode *anon_inode_make_secure_inode(
const struct inode *context_inode)
{
struct inode *inode;
const struct qstr qname = QSTR_INIT(name, strlen(name));
int error;

inode = alloc_anon_inode(anon_inode_mnt->mnt_sb);
if (IS_ERR(inode))
return inode;
inode->i_flags &= ~S_PRIVATE;
error = security_inode_init_security_anon(inode, &qname, context_inode);
error = security_inode_init_security_anon(inode, &QSTR(name),
context_inode);
if (error) {
iput(inode);
return ERR_PTR(error);
Expand Down
2 changes: 1 addition & 1 deletion fs/bcachefs/fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ static int reattach_inode(struct btree_trans *trans, struct bch_inode_unpacked *
return ret;

struct bch_hash_info dir_hash = bch2_hash_info_init(c, &lostfound);
struct qstr name = (struct qstr) QSTR(name_buf);
struct qstr name = QSTR(name_buf);

inode->bi_dir = lostfound.bi_inum;

Expand Down
1 change: 0 additions & 1 deletion fs/bcachefs/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <linux/sort.h>
#include <linux/stat.h>

#define QSTR(n) { { { .len = strlen(n) } }, .name = n }

int bch2_btree_lost_data(struct bch_fs *c, enum btree_id btree)
{
Expand Down
2 changes: 0 additions & 2 deletions fs/bcachefs/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,6 @@ static inline int cmp_le32(__le32 l, __le32 r)

#include <linux/uuid.h>

#define QSTR(n) { { { .len = strlen(n) } }, .name = n }

static inline bool qstr_eq(const struct qstr l, const struct qstr r)
{
return l.len == r.len && !memcmp(l.name, r.name, l.len);
Expand Down
2 changes: 1 addition & 1 deletion fs/erofs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ int erofs_getxattr(struct inode *inode, int index, const char *name,
}

it.index = index;
it.name = (struct qstr)QSTR_INIT(name, strlen(name));
it.name = QSTR(name);
if (it.name.len > EROFS_NAME_LEN)
return -ERANGE;

Expand Down
4 changes: 1 addition & 3 deletions fs/file_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,7 @@ static struct file *alloc_file(const struct path *path, int flags,
static inline int alloc_path_pseudo(const char *name, struct inode *inode,
struct vfsmount *mnt, struct path *path)
{
struct qstr this = QSTR_INIT(name, strlen(name));

path->dentry = d_alloc_pseudo(mnt->mnt_sb, &this);
path->dentry = d_alloc_pseudo(mnt->mnt_sb, &QSTR(name));
if (!path->dentry)
return -ENOMEM;
path->mnt = mntget(mnt);
Expand Down
2 changes: 1 addition & 1 deletion fs/kernfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ static void kernfs_notify_workfn(struct work_struct *work)
if (!inode)
continue;

name = (struct qstr)QSTR_INIT(kn->name, strlen(kn->name));
name = QSTR(kn->name);
parent = kernfs_get_parent(kn);
if (parent) {
p_inode = ilookup(info->sb, kernfs_ino(parent));
Expand Down
2 changes: 0 additions & 2 deletions fs/overlayfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include <linux/exportfs.h>
#include "overlayfs.h"

#include "../internal.h" /* for vfs_path_lookup */

struct ovl_lookup_data {
struct super_block *sb;
const struct ovl_layer *layer;
Expand Down
1 change: 1 addition & 0 deletions include/linux/dcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct qstr {
};

#define QSTR_INIT(n,l) { { { .len = l } }, .name = n }
#define QSTR(n) (struct qstr)QSTR_INIT(n, strlen(n))

extern const struct qstr empty_name;
extern const struct qstr slash_name;
Expand Down
3 changes: 1 addition & 2 deletions mm/secretmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,13 @@ static struct file *secretmem_file_create(unsigned long flags)
struct file *file;
struct inode *inode;
const char *anon_name = "[secretmem]";
const struct qstr qname = QSTR_INIT(anon_name, strlen(anon_name));
int err;

inode = alloc_anon_inode(secretmem_mnt->mnt_sb);
if (IS_ERR(inode))
return ERR_CAST(inode);

err = security_inode_init_security_anon(inode, &qname, NULL);
err = security_inode_init_security_anon(inode, &QSTR(anon_name), NULL);
if (err) {
file = ERR_PTR(err);
goto err_free_inode;
Expand Down
14 changes: 5 additions & 9 deletions net/sunrpc/rpc_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ static int __rpc_rmpipe(struct inode *dir, struct dentry *dentry)
static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent,
const char *name)
{
struct qstr q = QSTR_INIT(name, strlen(name));
struct qstr q = QSTR(name);
struct dentry *dentry = d_hash_and_lookup(parent, &q);
if (!dentry) {
dentry = d_alloc(parent, &q);
Expand Down Expand Up @@ -1190,8 +1190,7 @@ static const struct rpc_filelist files[] = {
struct dentry *rpc_d_lookup_sb(const struct super_block *sb,
const unsigned char *dir_name)
{
struct qstr dir = QSTR_INIT(dir_name, strlen(dir_name));
return d_hash_and_lookup(sb->s_root, &dir);
return d_hash_and_lookup(sb->s_root, &QSTR(dir_name));
}
EXPORT_SYMBOL_GPL(rpc_d_lookup_sb);

Expand Down Expand Up @@ -1300,11 +1299,9 @@ rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data)
struct dentry *gssd_dentry;
struct dentry *clnt_dentry = NULL;
struct dentry *pipe_dentry = NULL;
struct qstr q = QSTR_INIT(files[RPCAUTH_gssd].name,
strlen(files[RPCAUTH_gssd].name));

/* We should never get this far if "gssd" doesn't exist */
gssd_dentry = d_hash_and_lookup(root, &q);
gssd_dentry = d_hash_and_lookup(root, &QSTR(files[RPCAUTH_gssd].name));
if (!gssd_dentry)
return ERR_PTR(-ENOENT);

Expand All @@ -1314,9 +1311,8 @@ rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data)
goto out;
}

q.name = gssd_dummy_clnt_dir[0].name;
q.len = strlen(gssd_dummy_clnt_dir[0].name);
clnt_dentry = d_hash_and_lookup(gssd_dentry, &q);
clnt_dentry = d_hash_and_lookup(gssd_dentry,
&QSTR(gssd_dummy_clnt_dir[0].name));
if (!clnt_dentry) {
__rpc_depopulate(gssd_dentry, gssd_dummy_clnt_dir, 0, 1);
pipe_dentry = ERR_PTR(-ENOENT);
Expand Down

0 comments on commit a86bf22

Please sign in to comment.