Skip to content

Commit 4ac9137

Browse files
Jan BlunckLinus Torvalds
authored andcommitted
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

47 files changed

Lines changed: 431 additions & 402 deletions

File tree

Some content is hidden

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

‎arch/alpha/kernel/osf_sys.c‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 3 additions & 3 deletions
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‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 10 additions & 8 deletions
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‎

Lines changed: 4 additions & 4 deletions
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‎

Lines changed: 3 additions & 3 deletions
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‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 5 additions & 5 deletions
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‎

Lines changed: 11 additions & 11 deletions
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‎

Lines changed: 2 additions & 1 deletion
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
}

0 commit comments

Comments
 (0)