Skip to content

Commit 4ac9137

Browse files
Jan BlunckLinus Torvalds
Jan Blunck
authored and
Linus Torvalds
committed
Embed a struct path into struct nameidata instead of nd->{dentry,mnt}
This is the central patch of a cleanup series. In most cases there is no good reason why someone would want to use a dentry for itself. This series reflects that fact and embeds a struct path into nameidata. Together with the other patches of this series - it enforced the correct order of getting/releasing the reference count on <dentry,vfsmount> pairs - it prepares the VFS for stacking support since it is essential to have a struct path in every place where the stack can be traversed - it reduces the overall code size: without patch series: text data bss dec hex filename 5321639 858418 715768 6895825 6938d1 vmlinux with patch series: text data bss dec hex filename 5320026 858418 715768 6894212 693284 vmlinux This patch: Switch from nd->{dentry,mnt} to nd->path.{dentry,mnt} everywhere. [akpm@linux-foundation.org: coding-style fixes] [akpm@linux-foundation.org: fix cifs] [akpm@linux-foundation.org: fix smack] Signed-off-by: Jan Blunck <jblunck@suse.de> Signed-off-by: Andreas Gruenbacher <agruen@suse.de> Acked-by: Christoph Hellwig <hch@lst.de> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent c5e725f commit 4ac9137

Some content is hidden

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

47 files changed

+431
-402
lines changed

arch/alpha/kernel/osf_sys.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ osf_statfs(char __user *path, struct osf_statfs __user *buffer, unsigned long bu
259259

260260
retval = user_path_walk(path, &nd);
261261
if (!retval) {
262-
retval = do_osf_statfs(nd.dentry, buffer, bufsiz);
262+
retval = do_osf_statfs(nd.path.dentry, buffer, bufsiz);
263263
path_release(&nd);
264264
}
265265
return retval;

arch/mips/kernel/sysirix.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ asmlinkage int irix_statfs(const char __user *path,
694694
if (error)
695695
goto out;
696696

697-
error = vfs_statfs(nd.dentry, &kbuf);
697+
error = vfs_statfs(nd.path.dentry, &kbuf);
698698
if (error)
699699
goto dput_and_out;
700700

@@ -1360,7 +1360,7 @@ asmlinkage int irix_statvfs(char __user *fname, struct irix_statvfs __user *buf)
13601360
error = user_path_walk(fname, &nd);
13611361
if (error)
13621362
goto out;
1363-
error = vfs_statfs(nd.dentry, &kbuf);
1363+
error = vfs_statfs(nd.path.dentry, &kbuf);
13641364
if (error)
13651365
goto dput_and_out;
13661366

@@ -1611,7 +1611,7 @@ asmlinkage int irix_statvfs64(char __user *fname, struct irix_statvfs64 __user *
16111611
error = user_path_walk(fname, &nd);
16121612
if (error)
16131613
goto out;
1614-
error = vfs_statfs(nd.dentry, &kbuf);
1614+
error = vfs_statfs(nd.path.dentry, &kbuf);
16151615
if (error)
16161616
goto dput_and_out;
16171617

arch/parisc/hpux/sys_hpux.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ asmlinkage long hpux_statfs(const char __user *path,
219219
error = user_path_walk(path, &nd);
220220
if (!error) {
221221
struct hpux_statfs tmp;
222-
error = vfs_statfs_hpux(nd.dentry, &tmp);
222+
error = vfs_statfs_hpux(nd.path.dentry, &tmp);
223223
if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
224224
error = -EFAULT;
225225
path_release(&nd);

arch/powerpc/platforms/cell/spufs/inode.c

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/*
23
* SPU file system
34
*
@@ -592,17 +593,17 @@ long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
592593

593594
ret = -EINVAL;
594595
/* check if we are on spufs */
595-
if (nd->dentry->d_sb->s_type != &spufs_type)
596+
if (nd->path.dentry->d_sb->s_type != &spufs_type)
596597
goto out;
597598

598599
/* don't accept undefined flags */
599600
if (flags & (~SPU_CREATE_FLAG_ALL))
600601
goto out;
601602

602603
/* only threads can be underneath a gang */
603-
if (nd->dentry != nd->dentry->d_sb->s_root) {
604+
if (nd->path.dentry != nd->path.dentry->d_sb->s_root) {
604605
if ((flags & SPU_CREATE_GANG) ||
605-
!SPUFS_I(nd->dentry->d_inode)->i_gang)
606+
!SPUFS_I(nd->path.dentry->d_inode)->i_gang)
606607
goto out;
607608
}
608609

@@ -618,16 +619,17 @@ long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
618619
mode &= ~current->fs->umask;
619620

620621
if (flags & SPU_CREATE_GANG)
621-
return spufs_create_gang(nd->dentry->d_inode,
622-
dentry, nd->mnt, mode);
622+
return spufs_create_gang(nd->path.dentry->d_inode,
623+
dentry, nd->path.mnt, mode);
623624
else
624-
return spufs_create_context(nd->dentry->d_inode,
625-
dentry, nd->mnt, flags, mode, filp);
625+
return spufs_create_context(nd->path.dentry->d_inode,
626+
dentry, nd->path.mnt, flags, mode,
627+
filp);
626628

627629
out_dput:
628630
dput(dentry);
629631
out_dir:
630-
mutex_unlock(&nd->dentry->d_inode->i_mutex);
632+
mutex_unlock(&nd->path.dentry->d_inode->i_mutex);
631633
out:
632634
return ret;
633635
}

arch/sparc64/solaris/fs.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,8 @@ asmlinkage int solaris_statvfs(u32 path, u32 buf)
434434

435435
error = user_path_walk(A(path),&nd);
436436
if (!error) {
437-
struct inode * inode = nd.dentry->d_inode;
438-
error = report_statvfs(nd.mnt, inode, buf);
437+
struct inode *inode = nd.path.dentry->d_inode;
438+
error = report_statvfs(nd.path.mnt, inode, buf);
439439
path_release(&nd);
440440
}
441441
return error;
@@ -464,8 +464,8 @@ asmlinkage int solaris_statvfs64(u32 path, u32 buf)
464464
lock_kernel();
465465
error = user_path_walk(A(path), &nd);
466466
if (!error) {
467-
struct inode * inode = nd.dentry->d_inode;
468-
error = report_statvfs64(nd.mnt, inode, buf);
467+
struct inode *inode = nd.path.dentry->d_inode;
468+
error = report_statvfs64(nd.path.mnt, inode, buf);
469469
path_release(&nd);
470470
}
471471
unlock_kernel();

arch/um/drivers/mconsole_kern.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ void mconsole_proc(struct mc_request *req)
145145
}
146146
up_write(&super->s_umount);
147147

148-
nd.dentry = super->s_root;
149-
nd.mnt = NULL;
148+
nd.path.dentry = super->s_root;
149+
nd.path.mnt = NULL;
150150
nd.flags = O_RDONLY + 1;
151151
nd.last_type = LAST_ROOT;
152152

@@ -159,7 +159,7 @@ void mconsole_proc(struct mc_request *req)
159159
goto out_kill;
160160
}
161161

162-
file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
162+
file = dentry_open(nd.path.dentry, nd.path.mnt, O_RDONLY);
163163
if (IS_ERR(file)) {
164164
mconsole_reply(req, "Failed to open file", 1, 0);
165165
goto out_kill;

drivers/md/dm-table.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ static int lookup_device(const char *path, dev_t *dev)
361361
if ((r = path_lookup(path, LOOKUP_FOLLOW, &nd)))
362362
return r;
363363

364-
inode = nd.dentry->d_inode;
364+
inode = nd.path.dentry->d_inode;
365365
if (!inode) {
366366
r = -ENOENT;
367367
goto out;

drivers/mtd/mtdsuper.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,25 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
184184
ret = path_lookup(dev_name, LOOKUP_FOLLOW, &nd);
185185

186186
DEBUG(1, "MTDSB: path_lookup() returned %d, inode %p\n",
187-
ret, nd.dentry ? nd.dentry->d_inode : NULL);
187+
ret, nd.path.dentry ? nd.path.dentry->d_inode : NULL);
188188

189189
if (ret)
190190
return ret;
191191

192192
ret = -EINVAL;
193193

194-
if (!S_ISBLK(nd.dentry->d_inode->i_mode))
194+
if (!S_ISBLK(nd.path.dentry->d_inode->i_mode))
195195
goto out;
196196

197-
if (nd.mnt->mnt_flags & MNT_NODEV) {
197+
if (nd.path.mnt->mnt_flags & MNT_NODEV) {
198198
ret = -EACCES;
199199
goto out;
200200
}
201201

202-
if (imajor(nd.dentry->d_inode) != MTD_BLOCK_MAJOR)
202+
if (imajor(nd.path.dentry->d_inode) != MTD_BLOCK_MAJOR)
203203
goto not_an_MTD_device;
204204

205-
mtdnr = iminor(nd.dentry->d_inode);
205+
mtdnr = iminor(nd.path.dentry->d_inode);
206206
path_release(&nd);
207207

208208
return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super,

fs/afs/mntpt.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,14 @@ static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)
218218
_enter("%p{%s},{%s:%p{%s},}",
219219
dentry,
220220
dentry->d_name.name,
221-
nd->mnt->mnt_devname,
221+
nd->path.mnt->mnt_devname,
222222
dentry,
223-
nd->dentry->d_name.name);
223+
nd->path.dentry->d_name.name);
224224

225-
dput(nd->dentry);
226-
nd->dentry = dget(dentry);
225+
dput(nd->path.dentry);
226+
nd->path.dentry = dget(dentry);
227227

228-
newmnt = afs_mntpt_do_automount(nd->dentry);
228+
newmnt = afs_mntpt_do_automount(nd->path.dentry);
229229
if (IS_ERR(newmnt)) {
230230
path_release(nd);
231231
return (void *)newmnt;
@@ -235,17 +235,17 @@ static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)
235235
err = do_add_mount(newmnt, nd, MNT_SHRINKABLE, &afs_vfsmounts);
236236
switch (err) {
237237
case 0:
238-
dput(nd->dentry);
239-
mntput(nd->mnt);
240-
nd->mnt = newmnt;
241-
nd->dentry = dget(newmnt->mnt_root);
238+
dput(nd->path.dentry);
239+
mntput(nd->path.mnt);
240+
nd->path.mnt = newmnt;
241+
nd->path.dentry = dget(newmnt->mnt_root);
242242
schedule_delayed_work(&afs_mntpt_expiry_timer,
243243
afs_mntpt_expiry_timeout * HZ);
244244
break;
245245
case -EBUSY:
246246
/* someone else made a mount here whilst we were busy */
247-
while (d_mountpoint(nd->dentry) &&
248-
follow_down(&nd->mnt, &nd->dentry))
247+
while (d_mountpoint(nd->path.dentry) &&
248+
follow_down(&nd->path.mnt, &nd->path.dentry))
249249
;
250250
err = 0;
251251
default:

fs/autofs4/root.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
368368
* so we don't need to follow the mount.
369369
*/
370370
if (d_mountpoint(dentry)) {
371-
if (!autofs4_follow_mount(&nd->mnt, &nd->dentry)) {
371+
if (!autofs4_follow_mount(&nd->path.mnt,
372+
&nd->path.dentry)) {
372373
status = -ENOENT;
373374
goto out_error;
374375
}

fs/block_dev.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1397,12 +1397,12 @@ struct block_device *lookup_bdev(const char *path)
13971397
if (error)
13981398
return ERR_PTR(error);
13991399

1400-
inode = nd.dentry->d_inode;
1400+
inode = nd.path.dentry->d_inode;
14011401
error = -ENOTBLK;
14021402
if (!S_ISBLK(inode->i_mode))
14031403
goto fail;
14041404
error = -EACCES;
1405-
if (nd.mnt->mnt_flags & MNT_NODEV)
1405+
if (nd.path.mnt->mnt_flags & MNT_NODEV)
14061406
goto fail;
14071407
error = -ENOMEM;
14081408
bdev = bd_acquire(inode);

fs/cifs/cifs_dfs_ref.c

+12-11
Original file line numberDiff line numberDiff line change
@@ -259,18 +259,18 @@ static int add_mount_helper(struct vfsmount *newmnt, struct nameidata *nd,
259259
int err;
260260

261261
mntget(newmnt);
262-
err = do_add_mount(newmnt, nd, nd->mnt->mnt_flags, mntlist);
262+
err = do_add_mount(newmnt, nd, nd->path.mnt->mnt_flags, mntlist);
263263
switch (err) {
264264
case 0:
265-
dput(nd->dentry);
266-
mntput(nd->mnt);
267-
nd->mnt = newmnt;
268-
nd->dentry = dget(newmnt->mnt_root);
265+
dput(nd->path.dentry);
266+
mntput(nd->path.mnt);
267+
nd->path.mnt = newmnt;
268+
nd->path.dentry = dget(newmnt->mnt_root);
269269
break;
270270
case -EBUSY:
271271
/* someone else made a mount here whilst we were busy */
272-
while (d_mountpoint(nd->dentry) &&
273-
follow_down(&nd->mnt, &nd->dentry))
272+
while (d_mountpoint(nd->path.dentry) &&
273+
follow_down(&nd->path.mnt, &nd->path.dentry))
274274
;
275275
err = 0;
276276
default:
@@ -307,8 +307,8 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
307307

308308
xid = GetXid();
309309

310-
dput(nd->dentry);
311-
nd->dentry = dget(dentry);
310+
dput(nd->path.dentry);
311+
nd->path.dentry = dget(dentry);
312312

313313
cifs_sb = CIFS_SB(dentry->d_inode->i_sb);
314314
ses = cifs_sb->tcon->ses;
@@ -340,7 +340,8 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
340340
rc = -EINVAL;
341341
goto out_err;
342342
}
343-
mnt = cifs_dfs_do_refmount(nd->mnt, nd->dentry,
343+
mnt = cifs_dfs_do_refmount(nd->path.mnt,
344+
nd->path.dentry,
344345
referrals[i].node_name);
345346
cFYI(1, ("%s: cifs_dfs_do_refmount:%s , mnt:%p",
346347
__FUNCTION__,
@@ -357,7 +358,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
357358
if (IS_ERR(mnt))
358359
goto out_err;
359360

360-
nd->mnt->mnt_flags |= MNT_SHRINKABLE;
361+
nd->path.mnt->mnt_flags |= MNT_SHRINKABLE;
361362
rc = add_mount_helper(mnt, nd, &cifs_dfs_automount_list);
362363

363364
out:

fs/coda/pioctl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static int coda_pioctl(struct inode * inode, struct file * filp,
7575
if ( error ) {
7676
return error;
7777
} else {
78-
target_inode = nd.dentry->d_inode;
78+
target_inode = nd.path.dentry->d_inode;
7979
}
8080

8181
/* return if it is not a Coda inode */

fs/compat.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ asmlinkage long compat_sys_statfs(const char __user *path, struct compat_statfs
241241
error = user_path_walk(path, &nd);
242242
if (!error) {
243243
struct kstatfs tmp;
244-
error = vfs_statfs(nd.dentry, &tmp);
244+
error = vfs_statfs(nd.path.dentry, &tmp);
245245
if (!error)
246246
error = put_compat_statfs(buf, &tmp);
247247
path_release(&nd);
@@ -309,7 +309,7 @@ asmlinkage long compat_sys_statfs64(const char __user *path, compat_size_t sz, s
309309
error = user_path_walk(path, &nd);
310310
if (!error) {
311311
struct kstatfs tmp;
312-
error = vfs_statfs(nd.dentry, &tmp);
312+
error = vfs_statfs(nd.path.dentry, &tmp);
313313
if (!error)
314314
error = put_compat_statfs64(buf, &tmp);
315315
path_release(&nd);

fs/configfs/symlink.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ static int get_target(const char *symname, struct nameidata *nd,
9999

100100
ret = path_lookup(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, nd);
101101
if (!ret) {
102-
if (nd->dentry->d_sb == configfs_sb) {
103-
*target = configfs_get_config_item(nd->dentry);
102+
if (nd->path.dentry->d_sb == configfs_sb) {
103+
*target = configfs_get_config_item(nd->path.dentry);
104104
if (!*target) {
105105
ret = -ENOENT;
106106
path_release(nd);

fs/dquot.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -1633,14 +1633,15 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path)
16331633
error = path_lookup(path, LOOKUP_FOLLOW, &nd);
16341634
if (error < 0)
16351635
return error;
1636-
error = security_quota_on(nd.dentry);
1636+
error = security_quota_on(nd.path.dentry);
16371637
if (error)
16381638
goto out_path;
16391639
/* Quota file not on the same filesystem? */
1640-
if (nd.mnt->mnt_sb != sb)
1640+
if (nd.path.mnt->mnt_sb != sb)
16411641
error = -EXDEV;
16421642
else
1643-
error = vfs_quota_on_inode(nd.dentry->d_inode, type, format_id);
1643+
error = vfs_quota_on_inode(nd.path.dentry->d_inode, type,
1644+
format_id);
16441645
out_path:
16451646
path_release(&nd);
16461647
return error;

fs/ecryptfs/dentry.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
5151

5252
if (!lower_dentry->d_op || !lower_dentry->d_op->d_revalidate)
5353
goto out;
54-
dentry_save = nd->dentry;
55-
vfsmount_save = nd->mnt;
56-
nd->dentry = lower_dentry;
57-
nd->mnt = lower_mnt;
54+
dentry_save = nd->path.dentry;
55+
vfsmount_save = nd->path.mnt;
56+
nd->path.dentry = lower_dentry;
57+
nd->path.mnt = lower_mnt;
5858
rc = lower_dentry->d_op->d_revalidate(lower_dentry, nd);
59-
nd->dentry = dentry_save;
60-
nd->mnt = vfsmount_save;
59+
nd->path.dentry = dentry_save;
60+
nd->path.mnt = vfsmount_save;
6161
if (dentry->d_inode) {
6262
struct inode *lower_inode =
6363
ecryptfs_inode_to_lower(dentry->d_inode);

0 commit comments

Comments
 (0)