Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use struct path in fs_struct

* Use struct path in fs_struct.

Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: Jan Blunck <jblunck@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jan Blunck and committed by
Linus Torvalds
6ac08c39 5dd784d0

+87 -111
+15 -19
fs/dcache.c
··· 1849 1849 char *buf, int buflen) 1850 1850 { 1851 1851 char *res; 1852 - struct vfsmount *rootmnt; 1853 - struct dentry *root; 1852 + struct path root; 1854 1853 1855 1854 /* 1856 1855 * We have various synthetic filesystems that never get mounted. On ··· 1862 1863 return dentry->d_op->d_dname(dentry, buf, buflen); 1863 1864 1864 1865 read_lock(&current->fs->lock); 1865 - rootmnt = mntget(current->fs->rootmnt); 1866 - root = dget(current->fs->root); 1866 + root = current->fs->root; 1867 + path_get(&current->fs->root); 1867 1868 read_unlock(&current->fs->lock); 1868 1869 spin_lock(&dcache_lock); 1869 - res = __d_path(dentry, vfsmnt, root, rootmnt, buf, buflen); 1870 + res = __d_path(dentry, vfsmnt, root.dentry, root.mnt, buf, buflen); 1870 1871 spin_unlock(&dcache_lock); 1871 - dput(root); 1872 - mntput(rootmnt); 1872 + path_put(&root); 1873 1873 return res; 1874 1874 } 1875 1875 ··· 1914 1916 asmlinkage long sys_getcwd(char __user *buf, unsigned long size) 1915 1917 { 1916 1918 int error; 1917 - struct vfsmount *pwdmnt, *rootmnt; 1918 - struct dentry *pwd, *root; 1919 + struct path pwd, root; 1919 1920 char *page = (char *) __get_free_page(GFP_USER); 1920 1921 1921 1922 if (!page) 1922 1923 return -ENOMEM; 1923 1924 1924 1925 read_lock(&current->fs->lock); 1925 - pwdmnt = mntget(current->fs->pwdmnt); 1926 - pwd = dget(current->fs->pwd); 1927 - rootmnt = mntget(current->fs->rootmnt); 1928 - root = dget(current->fs->root); 1926 + pwd = current->fs->pwd; 1927 + path_get(&current->fs->pwd); 1928 + root = current->fs->root; 1929 + path_get(&current->fs->root); 1929 1930 read_unlock(&current->fs->lock); 1930 1931 1931 1932 error = -ENOENT; 1932 1933 /* Has the current directory has been unlinked? */ 1933 1934 spin_lock(&dcache_lock); 1934 - if (pwd->d_parent == pwd || !d_unhashed(pwd)) { 1935 + if (pwd.dentry->d_parent == pwd.dentry || !d_unhashed(pwd.dentry)) { 1935 1936 unsigned long len; 1936 1937 char * cwd; 1937 1938 1938 - cwd = __d_path(pwd, pwdmnt, root, rootmnt, page, PAGE_SIZE); 1939 + cwd = __d_path(pwd.dentry, pwd.mnt, root.dentry, root.mnt, 1940 + page, PAGE_SIZE); 1939 1941 spin_unlock(&dcache_lock); 1940 1942 1941 1943 error = PTR_ERR(cwd); ··· 1953 1955 spin_unlock(&dcache_lock); 1954 1956 1955 1957 out: 1956 - dput(pwd); 1957 - mntput(pwdmnt); 1958 - dput(root); 1959 - mntput(rootmnt); 1958 + path_put(&pwd); 1959 + path_put(&root); 1960 1960 free_page((unsigned long) page); 1961 1961 return error; 1962 1962 }
+23 -30
fs/namei.c
··· 549 549 struct fs_struct *fs = current->fs; 550 550 551 551 read_lock(&fs->lock); 552 - if (fs->altroot && !(nd->flags & LOOKUP_NOALT)) { 553 - nd->path.mnt = mntget(fs->altrootmnt); 554 - nd->path.dentry = dget(fs->altroot); 552 + if (fs->altroot.dentry && !(nd->flags & LOOKUP_NOALT)) { 553 + nd->path = fs->altroot; 554 + path_get(&fs->altroot); 555 555 read_unlock(&fs->lock); 556 556 if (__emul_lookup_dentry(name,nd)) 557 557 return 0; 558 558 read_lock(&fs->lock); 559 559 } 560 - nd->path.mnt = mntget(fs->rootmnt); 561 - nd->path.dentry = dget(fs->root); 560 + nd->path = fs->root; 561 + path_get(&fs->root); 562 562 read_unlock(&fs->lock); 563 563 return 1; 564 564 } ··· 755 755 struct dentry *old = nd->path.dentry; 756 756 757 757 read_lock(&fs->lock); 758 - if (nd->path.dentry == fs->root && 759 - nd->path.mnt == fs->rootmnt) { 758 + if (nd->path.dentry == fs->root.dentry && 759 + nd->path.mnt == fs->root.mnt) { 760 760 read_unlock(&fs->lock); 761 761 break; 762 762 } ··· 1078 1078 */ 1079 1079 nd->last_type = LAST_ROOT; 1080 1080 read_lock(&fs->lock); 1081 - nd->path.mnt = mntget(fs->rootmnt); 1082 - nd->path.dentry = dget(fs->root); 1081 + nd->path = fs->root; 1082 + path_get(&fs->root); 1083 1083 read_unlock(&fs->lock); 1084 1084 if (path_walk(name, nd) == 0) { 1085 1085 if (nd->path.dentry->d_inode) { ··· 1099 1099 { 1100 1100 char *emul = __emul_prefix(); 1101 1101 struct nameidata nd; 1102 - struct vfsmount *mnt = NULL, *oldmnt; 1103 - struct dentry *dentry = NULL, *olddentry; 1102 + struct path path = {}, old_path; 1104 1103 int err; 1105 1104 struct fs_struct *fs = current->fs; 1106 1105 1107 1106 if (!emul) 1108 1107 goto set_it; 1109 1108 err = path_lookup(emul, LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_NOALT, &nd); 1110 - if (!err) { 1111 - mnt = nd.path.mnt; 1112 - dentry = nd.path.dentry; 1113 - } 1109 + if (!err) 1110 + path = nd.path; 1114 1111 set_it: 1115 1112 write_lock(&fs->lock); 1116 - oldmnt = fs->altrootmnt; 1117 - olddentry = fs->altroot; 1118 - fs->altrootmnt = mnt; 1119 - fs->altroot = dentry; 1113 + old_path = fs->altroot; 1114 + fs->altroot = path; 1120 1115 write_unlock(&fs->lock); 1121 - if (olddentry) { 1122 - dput(olddentry); 1123 - mntput(oldmnt); 1124 - } 1116 + if (old_path.dentry) 1117 + path_put(&old_path); 1125 1118 } 1126 1119 1127 1120 /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ ··· 1132 1139 1133 1140 if (*name=='/') { 1134 1141 read_lock(&fs->lock); 1135 - if (fs->altroot && !(nd->flags & LOOKUP_NOALT)) { 1136 - nd->path.mnt = mntget(fs->altrootmnt); 1137 - nd->path.dentry = dget(fs->altroot); 1142 + if (fs->altroot.dentry && !(nd->flags & LOOKUP_NOALT)) { 1143 + nd->path = fs->altroot; 1144 + path_get(&fs->altroot); 1138 1145 read_unlock(&fs->lock); 1139 1146 if (__emul_lookup_dentry(name,nd)) 1140 1147 goto out; /* found in altroot */ 1141 1148 read_lock(&fs->lock); 1142 1149 } 1143 - nd->path.mnt = mntget(fs->rootmnt); 1144 - nd->path.dentry = dget(fs->root); 1150 + nd->path = fs->root; 1151 + path_get(&fs->root); 1145 1152 read_unlock(&fs->lock); 1146 1153 } else if (dfd == AT_FDCWD) { 1147 1154 read_lock(&fs->lock); 1148 - nd->path.mnt = mntget(fs->pwdmnt); 1149 - nd->path.dentry = dget(fs->pwd); 1155 + nd->path = fs->pwd; 1156 + path_get(&fs->pwd); 1150 1157 read_unlock(&fs->lock); 1151 1158 } else { 1152 1159 struct dentry *dentry;
+25 -32
fs/namespace.c
··· 593 593 * (2) the usage count == 1 [parent vfsmount] + 1 [sys_umount] 594 594 */ 595 595 if (flags & MNT_EXPIRE) { 596 - if (mnt == current->fs->rootmnt || 596 + if (mnt == current->fs->root.mnt || 597 597 flags & (MNT_FORCE | MNT_DETACH)) 598 598 return -EINVAL; 599 599 ··· 628 628 * /reboot - static binary that would close all descriptors and 629 629 * call reboot(9). Then init(8) could umount root and exec /reboot. 630 630 */ 631 - if (mnt == current->fs->rootmnt && !(flags & MNT_DETACH)) { 631 + if (mnt == current->fs->root.mnt && !(flags & MNT_DETACH)) { 632 632 /* 633 633 * Special case for "unmounting" root ... 634 634 * we just try to remount it readonly. ··· 1559 1559 while (p) { 1560 1560 q->mnt_ns = new_ns; 1561 1561 if (fs) { 1562 - if (p == fs->rootmnt) { 1562 + if (p == fs->root.mnt) { 1563 1563 rootmnt = p; 1564 - fs->rootmnt = mntget(q); 1564 + fs->root.mnt = mntget(q); 1565 1565 } 1566 - if (p == fs->pwdmnt) { 1566 + if (p == fs->pwd.mnt) { 1567 1567 pwdmnt = p; 1568 - fs->pwdmnt = mntget(q); 1568 + fs->pwd.mnt = mntget(q); 1569 1569 } 1570 - if (p == fs->altrootmnt) { 1570 + if (p == fs->altroot.mnt) { 1571 1571 altrootmnt = p; 1572 - fs->altrootmnt = mntget(q); 1572 + fs->altroot.mnt = mntget(q); 1573 1573 } 1574 1574 } 1575 1575 p = next_mnt(p, mnt_ns->root); ··· 1653 1653 void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt, 1654 1654 struct dentry *dentry) 1655 1655 { 1656 - struct dentry *old_root; 1657 - struct vfsmount *old_rootmnt; 1656 + struct path old_root; 1657 + 1658 1658 write_lock(&fs->lock); 1659 1659 old_root = fs->root; 1660 - old_rootmnt = fs->rootmnt; 1661 - fs->rootmnt = mntget(mnt); 1662 - fs->root = dget(dentry); 1660 + fs->root.mnt = mntget(mnt); 1661 + fs->root.dentry = dget(dentry); 1663 1662 write_unlock(&fs->lock); 1664 - if (old_root) { 1665 - dput(old_root); 1666 - mntput(old_rootmnt); 1667 - } 1663 + if (old_root.dentry) 1664 + path_put(&old_root); 1668 1665 } 1669 1666 1670 1667 /* ··· 1671 1674 void set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, 1672 1675 struct dentry *dentry) 1673 1676 { 1674 - struct dentry *old_pwd; 1675 - struct vfsmount *old_pwdmnt; 1677 + struct path old_pwd; 1676 1678 1677 1679 write_lock(&fs->lock); 1678 1680 old_pwd = fs->pwd; 1679 - old_pwdmnt = fs->pwdmnt; 1680 - fs->pwdmnt = mntget(mnt); 1681 - fs->pwd = dget(dentry); 1681 + fs->pwd.mnt = mntget(mnt); 1682 + fs->pwd.dentry = dget(dentry); 1682 1683 write_unlock(&fs->lock); 1683 1684 1684 - if (old_pwd) { 1685 - dput(old_pwd); 1686 - mntput(old_pwdmnt); 1687 - } 1685 + if (old_pwd.dentry) 1686 + path_put(&old_pwd); 1688 1687 } 1689 1688 1690 1689 static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd) ··· 1695 1702 if (fs) { 1696 1703 atomic_inc(&fs->count); 1697 1704 task_unlock(p); 1698 - if (fs->root == old_nd->path.dentry 1699 - && fs->rootmnt == old_nd->path.mnt) 1705 + if (fs->root.dentry == old_nd->path.dentry 1706 + && fs->root.mnt == old_nd->path.mnt) 1700 1707 set_fs_root(fs, new_nd->path.mnt, 1701 1708 new_nd->path.dentry); 1702 - if (fs->pwd == old_nd->path.dentry 1703 - && fs->pwdmnt == old_nd->path.mnt) 1709 + if (fs->pwd.dentry == old_nd->path.dentry 1710 + && fs->pwd.mnt == old_nd->path.mnt) 1704 1711 set_fs_pwd(fs, new_nd->path.mnt, 1705 1712 new_nd->path.dentry); 1706 1713 put_fs_struct(fs); ··· 1766 1773 } 1767 1774 1768 1775 read_lock(&current->fs->lock); 1769 - user_nd.path.mnt = mntget(current->fs->rootmnt); 1770 - user_nd.path.dentry = dget(current->fs->root); 1776 + user_nd.path = current->fs->root; 1777 + path_get(&current->fs->root); 1771 1778 read_unlock(&current->fs->lock); 1772 1779 down_write(&namespace_sem); 1773 1780 mutex_lock(&old_nd.path.dentry->d_inode->i_mutex);
+4 -4
fs/proc/base.c
··· 165 165 } 166 166 if (fs) { 167 167 read_lock(&fs->lock); 168 - *mnt = mntget(fs->pwdmnt); 169 - *dentry = dget(fs->pwd); 168 + *mnt = mntget(fs->pwd.mnt); 169 + *dentry = dget(fs->pwd.dentry); 170 170 read_unlock(&fs->lock); 171 171 result = 0; 172 172 put_fs_struct(fs); ··· 186 186 } 187 187 if (fs) { 188 188 read_lock(&fs->lock); 189 - *mnt = mntget(fs->rootmnt); 190 - *dentry = dget(fs->root); 189 + *mnt = mntget(fs->root.mnt); 190 + *dentry = dget(fs->root.dentry); 191 191 read_unlock(&fs->lock); 192 192 result = 0; 193 193 put_fs_struct(fs);
+2 -4
include/linux/fs_struct.h
··· 1 1 #ifndef _LINUX_FS_STRUCT_H 2 2 #define _LINUX_FS_STRUCT_H 3 3 4 - struct dentry; 5 - struct vfsmount; 4 + #include <linux/path.h> 6 5 7 6 struct fs_struct { 8 7 atomic_t count; 9 8 rwlock_t lock; 10 9 int umask; 11 - struct dentry * root, * pwd, * altroot; 12 - struct vfsmount * rootmnt, * pwdmnt, * altrootmnt; 10 + struct path root, pwd, altroot; 13 11 }; 14 12 15 13 #define INIT_FS { \
+3 -3
init/do_mounts.c
··· 193 193 return err; 194 194 195 195 sys_chdir("/root"); 196 - ROOT_DEV = current->fs->pwdmnt->mnt_sb->s_dev; 196 + ROOT_DEV = current->fs->pwd.mnt->mnt_sb->s_dev; 197 197 printk("VFS: Mounted root (%s filesystem)%s.\n", 198 - current->fs->pwdmnt->mnt_sb->s_type->name, 199 - current->fs->pwdmnt->mnt_sb->s_flags & MS_RDONLY ? 198 + current->fs->pwd.mnt->mnt_sb->s_type->name, 199 + current->fs->pwd.mnt->mnt_sb->s_flags & MS_RDONLY ? 200 200 " readonly" : ""); 201 201 return 0; 202 202 }
+2 -2
kernel/auditsc.c
··· 1697 1697 ++context->name_count; 1698 1698 if (!context->pwd) { 1699 1699 read_lock(&current->fs->lock); 1700 - context->pwd = dget(current->fs->pwd); 1701 - context->pwdmnt = mntget(current->fs->pwdmnt); 1700 + context->pwd = dget(current->fs->pwd.dentry); 1701 + context->pwdmnt = mntget(current->fs->pwd.mnt); 1702 1702 read_unlock(&current->fs->lock); 1703 1703 } 1704 1704
+4 -8
kernel/exit.c
··· 512 512 { 513 513 /* No need to hold fs->lock if we are killing it */ 514 514 if (atomic_dec_and_test(&fs->count)) { 515 - dput(fs->root); 516 - mntput(fs->rootmnt); 517 - dput(fs->pwd); 518 - mntput(fs->pwdmnt); 519 - if (fs->altroot) { 520 - dput(fs->altroot); 521 - mntput(fs->altrootmnt); 522 - } 515 + path_put(&fs->root); 516 + path_put(&fs->pwd); 517 + if (fs->altroot.dentry) 518 + path_put(&fs->altroot); 523 519 kmem_cache_free(fs_cachep, fs); 524 520 } 525 521 }
+9 -9
kernel/fork.c
··· 600 600 rwlock_init(&fs->lock); 601 601 fs->umask = old->umask; 602 602 read_lock(&old->lock); 603 - fs->rootmnt = mntget(old->rootmnt); 604 - fs->root = dget(old->root); 605 - fs->pwdmnt = mntget(old->pwdmnt); 606 - fs->pwd = dget(old->pwd); 607 - if (old->altroot) { 608 - fs->altrootmnt = mntget(old->altrootmnt); 609 - fs->altroot = dget(old->altroot); 603 + fs->root = old->root; 604 + path_get(&old->root); 605 + fs->pwd = old->pwd; 606 + path_get(&old->pwd); 607 + if (old->altroot.dentry) { 608 + fs->altroot = old->altroot; 609 + path_get(&old->altroot); 610 610 } else { 611 - fs->altrootmnt = NULL; 612 - fs->altroot = NULL; 611 + fs->altroot.mnt = NULL; 612 + fs->altroot.dentry = NULL; 613 613 } 614 614 read_unlock(&old->lock); 615 615 }