diff options
Diffstat (limited to 'fs/dcache.c')
-rw-r--r-- | fs/dcache.c | 342 |
1 files changed, 187 insertions, 155 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index ae6ebb88ceff..1f24cd684c51 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -343,6 +343,7 @@ static void dentry_unlink_inode(struct dentry * dentry) | |||
343 | __releases(dentry->d_inode->i_lock) | 343 | __releases(dentry->d_inode->i_lock) |
344 | { | 344 | { |
345 | struct inode *inode = dentry->d_inode; | 345 | struct inode *inode = dentry->d_inode; |
346 | __d_clear_type(dentry); | ||
346 | dentry->d_inode = NULL; | 347 | dentry->d_inode = NULL; |
347 | hlist_del_init(&dentry->d_alias); | 348 | hlist_del_init(&dentry->d_alias); |
348 | dentry_rcuwalk_barrier(dentry); | 349 | dentry_rcuwalk_barrier(dentry); |
@@ -483,27 +484,6 @@ static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent) | |||
483 | return parent; | 484 | return parent; |
484 | } | 485 | } |
485 | 486 | ||
486 | /* | ||
487 | * Unhash a dentry without inserting an RCU walk barrier or checking that | ||
488 | * dentry->d_lock is locked. The caller must take care of that, if | ||
489 | * appropriate. | ||
490 | */ | ||
491 | static void __d_shrink(struct dentry *dentry) | ||
492 | { | ||
493 | if (!d_unhashed(dentry)) { | ||
494 | struct hlist_bl_head *b; | ||
495 | if (unlikely(dentry->d_flags & DCACHE_DISCONNECTED)) | ||
496 | b = &dentry->d_sb->s_anon; | ||
497 | else | ||
498 | b = d_hash(dentry->d_parent, dentry->d_name.hash); | ||
499 | |||
500 | hlist_bl_lock(b); | ||
501 | __hlist_bl_del(&dentry->d_hash); | ||
502 | dentry->d_hash.pprev = NULL; | ||
503 | hlist_bl_unlock(b); | ||
504 | } | ||
505 | } | ||
506 | |||
507 | /** | 487 | /** |
508 | * d_drop - drop a dentry | 488 | * d_drop - drop a dentry |
509 | * @dentry: dentry to drop | 489 | * @dentry: dentry to drop |
@@ -522,7 +502,21 @@ static void __d_shrink(struct dentry *dentry) | |||
522 | void __d_drop(struct dentry *dentry) | 502 | void __d_drop(struct dentry *dentry) |
523 | { | 503 | { |
524 | if (!d_unhashed(dentry)) { | 504 | if (!d_unhashed(dentry)) { |
525 | __d_shrink(dentry); | 505 | struct hlist_bl_head *b; |
506 | /* | ||
507 | * Hashed dentries are normally on the dentry hashtable, | ||
508 | * with the exception of those newly allocated by | ||
509 | * d_obtain_alias, which are always IS_ROOT: | ||
510 | */ | ||
511 | if (unlikely(IS_ROOT(dentry))) | ||
512 | b = &dentry->d_sb->s_anon; | ||
513 | else | ||
514 | b = d_hash(dentry->d_parent, dentry->d_name.hash); | ||
515 | |||
516 | hlist_bl_lock(b); | ||
517 | __hlist_bl_del(&dentry->d_hash); | ||
518 | dentry->d_hash.pprev = NULL; | ||
519 | hlist_bl_unlock(b); | ||
526 | dentry_rcuwalk_barrier(dentry); | 520 | dentry_rcuwalk_barrier(dentry); |
527 | } | 521 | } |
528 | } | 522 | } |
@@ -1076,116 +1070,6 @@ void shrink_dcache_sb(struct super_block *sb) | |||
1076 | EXPORT_SYMBOL(shrink_dcache_sb); | 1070 | EXPORT_SYMBOL(shrink_dcache_sb); |
1077 | 1071 | ||
1078 | /* | 1072 | /* |
1079 | * destroy a single subtree of dentries for unmount | ||
1080 | * - see the comments on shrink_dcache_for_umount() for a description of the | ||
1081 | * locking | ||
1082 | */ | ||
1083 | static void shrink_dcache_for_umount_subtree(struct dentry *dentry) | ||
1084 | { | ||
1085 | struct dentry *parent; | ||
1086 | |||
1087 | BUG_ON(!IS_ROOT(dentry)); | ||
1088 | |||
1089 | for (;;) { | ||
1090 | /* descend to the first leaf in the current subtree */ | ||
1091 | while (!list_empty(&dentry->d_subdirs)) | ||
1092 | dentry = list_entry(dentry->d_subdirs.next, | ||
1093 | struct dentry, d_u.d_child); | ||
1094 | |||
1095 | /* consume the dentries from this leaf up through its parents | ||
1096 | * until we find one with children or run out altogether */ | ||
1097 | do { | ||
1098 | struct inode *inode; | ||
1099 | |||
1100 | /* | ||
1101 | * inform the fs that this dentry is about to be | ||
1102 | * unhashed and destroyed. | ||
1103 | */ | ||
1104 | if ((dentry->d_flags & DCACHE_OP_PRUNE) && | ||
1105 | !d_unhashed(dentry)) | ||
1106 | dentry->d_op->d_prune(dentry); | ||
1107 | |||
1108 | dentry_lru_del(dentry); | ||
1109 | __d_shrink(dentry); | ||
1110 | |||
1111 | if (dentry->d_lockref.count != 0) { | ||
1112 | printk(KERN_ERR | ||
1113 | "BUG: Dentry %p{i=%lx,n=%s}" | ||
1114 | " still in use (%d)" | ||
1115 | " [unmount of %s %s]\n", | ||
1116 | dentry, | ||
1117 | dentry->d_inode ? | ||
1118 | dentry->d_inode->i_ino : 0UL, | ||
1119 | dentry->d_name.name, | ||
1120 | dentry->d_lockref.count, | ||
1121 | dentry->d_sb->s_type->name, | ||
1122 | dentry->d_sb->s_id); | ||
1123 | BUG(); | ||
1124 | } | ||
1125 | |||
1126 | if (IS_ROOT(dentry)) { | ||
1127 | parent = NULL; | ||
1128 | list_del(&dentry->d_u.d_child); | ||
1129 | } else { | ||
1130 | parent = dentry->d_parent; | ||
1131 | parent->d_lockref.count--; | ||
1132 | list_del(&dentry->d_u.d_child); | ||
1133 | } | ||
1134 | |||
1135 | inode = dentry->d_inode; | ||
1136 | if (inode) { | ||
1137 | dentry->d_inode = NULL; | ||
1138 | hlist_del_init(&dentry->d_alias); | ||
1139 | if (dentry->d_op && dentry->d_op->d_iput) | ||
1140 | dentry->d_op->d_iput(dentry, inode); | ||
1141 | else | ||
1142 | iput(inode); | ||
1143 | } | ||
1144 | |||
1145 | d_free(dentry); | ||
1146 | |||
1147 | /* finished when we fall off the top of the tree, | ||
1148 | * otherwise we ascend to the parent and move to the | ||
1149 | * next sibling if there is one */ | ||
1150 | if (!parent) | ||
1151 | return; | ||
1152 | dentry = parent; | ||
1153 | } while (list_empty(&dentry->d_subdirs)); | ||
1154 | |||
1155 | dentry = list_entry(dentry->d_subdirs.next, | ||
1156 | struct dentry, d_u.d_child); | ||
1157 | } | ||
1158 | } | ||
1159 | |||
1160 | /* | ||
1161 | * destroy the dentries attached to a superblock on unmounting | ||
1162 | * - we don't need to use dentry->d_lock because: | ||
1163 | * - the superblock is detached from all mountings and open files, so the | ||
1164 | * dentry trees will not be rearranged by the VFS | ||
1165 | * - s_umount is write-locked, so the memory pressure shrinker will ignore | ||
1166 | * any dentries belonging to this superblock that it comes across | ||
1167 | * - the filesystem itself is no longer permitted to rearrange the dentries | ||
1168 | * in this superblock | ||
1169 | */ | ||
1170 | void shrink_dcache_for_umount(struct super_block *sb) | ||
1171 | { | ||
1172 | struct dentry *dentry; | ||
1173 | |||
1174 | if (down_read_trylock(&sb->s_umount)) | ||
1175 | BUG(); | ||
1176 | |||
1177 | dentry = sb->s_root; | ||
1178 | sb->s_root = NULL; | ||
1179 | dentry->d_lockref.count--; | ||
1180 | shrink_dcache_for_umount_subtree(dentry); | ||
1181 | |||
1182 | while (!hlist_bl_empty(&sb->s_anon)) { | ||
1183 | dentry = hlist_bl_entry(hlist_bl_first(&sb->s_anon), struct dentry, d_hash); | ||
1184 | shrink_dcache_for_umount_subtree(dentry); | ||
1185 | } | ||
1186 | } | ||
1187 | |||
1188 | /* | ||
1189 | * This tries to ascend one level of parenthood, but | 1073 | * This tries to ascend one level of parenthood, but |
1190 | * we can race with renaming, so we need to re-check | 1074 | * we can race with renaming, so we need to re-check |
1191 | * the parenthood after dropping the lock and check | 1075 | * the parenthood after dropping the lock and check |
@@ -1478,6 +1362,91 @@ void shrink_dcache_parent(struct dentry *parent) | |||
1478 | } | 1362 | } |
1479 | EXPORT_SYMBOL(shrink_dcache_parent); | 1363 | EXPORT_SYMBOL(shrink_dcache_parent); |
1480 | 1364 | ||
1365 | static enum d_walk_ret umount_collect(void *_data, struct dentry *dentry) | ||
1366 | { | ||
1367 | struct select_data *data = _data; | ||
1368 | enum d_walk_ret ret = D_WALK_CONTINUE; | ||
1369 | |||
1370 | if (dentry->d_lockref.count) { | ||
1371 | dentry_lru_del(dentry); | ||
1372 | if (likely(!list_empty(&dentry->d_subdirs))) | ||
1373 | goto out; | ||
1374 | if (dentry == data->start && dentry->d_lockref.count == 1) | ||
1375 | goto out; | ||
1376 | printk(KERN_ERR | ||
1377 | "BUG: Dentry %p{i=%lx,n=%s}" | ||
1378 | " still in use (%d)" | ||
1379 | " [unmount of %s %s]\n", | ||
1380 | dentry, | ||
1381 | dentry->d_inode ? | ||
1382 | dentry->d_inode->i_ino : 0UL, | ||
1383 | dentry->d_name.name, | ||
1384 | dentry->d_lockref.count, | ||
1385 | dentry->d_sb->s_type->name, | ||
1386 | dentry->d_sb->s_id); | ||
1387 | BUG(); | ||
1388 | } else if (!(dentry->d_flags & DCACHE_SHRINK_LIST)) { | ||
1389 | /* | ||
1390 | * We can't use d_lru_shrink_move() because we | ||
1391 | * need to get the global LRU lock and do the | ||
1392 | * LRU accounting. | ||
1393 | */ | ||
1394 | if (dentry->d_flags & DCACHE_LRU_LIST) | ||
1395 | d_lru_del(dentry); | ||
1396 | d_shrink_add(dentry, &data->dispose); | ||
1397 | data->found++; | ||
1398 | ret = D_WALK_NORETRY; | ||
1399 | } | ||
1400 | out: | ||
1401 | if (data->found && need_resched()) | ||
1402 | ret = D_WALK_QUIT; | ||
1403 | return ret; | ||
1404 | } | ||
1405 | |||
1406 | /* | ||
1407 | * destroy the dentries attached to a superblock on unmounting | ||
1408 | */ | ||
1409 | void shrink_dcache_for_umount(struct super_block *sb) | ||
1410 | { | ||
1411 | struct dentry *dentry; | ||
1412 | |||
1413 | if (down_read_trylock(&sb->s_umount)) | ||
1414 | BUG(); | ||
1415 | |||
1416 | dentry = sb->s_root; | ||
1417 | sb->s_root = NULL; | ||
1418 | for (;;) { | ||
1419 | struct select_data data; | ||
1420 | |||
1421 | INIT_LIST_HEAD(&data.dispose); | ||
1422 | data.start = dentry; | ||
1423 | data.found = 0; | ||
1424 | |||
1425 | d_walk(dentry, &data, umount_collect, NULL); | ||
1426 | if (!data.found) | ||
1427 | break; | ||
1428 | |||
1429 | shrink_dentry_list(&data.dispose); | ||
1430 | cond_resched(); | ||
1431 | } | ||
1432 | d_drop(dentry); | ||
1433 | dput(dentry); | ||
1434 | |||
1435 | while (!hlist_bl_empty(&sb->s_anon)) { | ||
1436 | struct select_data data; | ||
1437 | dentry = hlist_bl_entry(hlist_bl_first(&sb->s_anon), struct dentry, d_hash); | ||
1438 | |||
1439 | INIT_LIST_HEAD(&data.dispose); | ||
1440 | data.start = NULL; | ||
1441 | data.found = 0; | ||
1442 | |||
1443 | d_walk(dentry, &data, umount_collect, NULL); | ||
1444 | if (data.found) | ||
1445 | shrink_dentry_list(&data.dispose); | ||
1446 | cond_resched(); | ||
1447 | } | ||
1448 | } | ||
1449 | |||
1481 | static enum d_walk_ret check_and_collect(void *_data, struct dentry *dentry) | 1450 | static enum d_walk_ret check_and_collect(void *_data, struct dentry *dentry) |
1482 | { | 1451 | { |
1483 | struct select_data *data = _data; | 1452 | struct select_data *data = _data; |
@@ -1638,12 +1607,17 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name) | |||
1638 | } | 1607 | } |
1639 | EXPORT_SYMBOL(d_alloc); | 1608 | EXPORT_SYMBOL(d_alloc); |
1640 | 1609 | ||
1610 | /** | ||
1611 | * d_alloc_pseudo - allocate a dentry (for lookup-less filesystems) | ||
1612 | * @sb: the superblock | ||
1613 | * @name: qstr of the name | ||
1614 | * | ||
1615 | * For a filesystem that just pins its dentries in memory and never | ||
1616 | * performs lookups at all, return an unhashed IS_ROOT dentry. | ||
1617 | */ | ||
1641 | struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name) | 1618 | struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name) |
1642 | { | 1619 | { |
1643 | struct dentry *dentry = __d_alloc(sb, name); | 1620 | return __d_alloc(sb, name); |
1644 | if (dentry) | ||
1645 | dentry->d_flags |= DCACHE_DISCONNECTED; | ||
1646 | return dentry; | ||
1647 | } | 1621 | } |
1648 | EXPORT_SYMBOL(d_alloc_pseudo); | 1622 | EXPORT_SYMBOL(d_alloc_pseudo); |
1649 | 1623 | ||
@@ -1685,14 +1659,42 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) | |||
1685 | } | 1659 | } |
1686 | EXPORT_SYMBOL(d_set_d_op); | 1660 | EXPORT_SYMBOL(d_set_d_op); |
1687 | 1661 | ||
1662 | static unsigned d_flags_for_inode(struct inode *inode) | ||
1663 | { | ||
1664 | unsigned add_flags = DCACHE_FILE_TYPE; | ||
1665 | |||
1666 | if (!inode) | ||
1667 | return DCACHE_MISS_TYPE; | ||
1668 | |||
1669 | if (S_ISDIR(inode->i_mode)) { | ||
1670 | add_flags = DCACHE_DIRECTORY_TYPE; | ||
1671 | if (unlikely(!(inode->i_opflags & IOP_LOOKUP))) { | ||
1672 | if (unlikely(!inode->i_op->lookup)) | ||
1673 | add_flags = DCACHE_AUTODIR_TYPE; | ||
1674 | else | ||
1675 | inode->i_opflags |= IOP_LOOKUP; | ||
1676 | } | ||
1677 | } else if (unlikely(!(inode->i_opflags & IOP_NOFOLLOW))) { | ||
1678 | if (unlikely(inode->i_op->follow_link)) | ||
1679 | add_flags = DCACHE_SYMLINK_TYPE; | ||
1680 | else | ||
1681 | inode->i_opflags |= IOP_NOFOLLOW; | ||
1682 | } | ||
1683 | |||
1684 | if (unlikely(IS_AUTOMOUNT(inode))) | ||
1685 | add_flags |= DCACHE_NEED_AUTOMOUNT; | ||
1686 | return add_flags; | ||
1687 | } | ||
1688 | |||
1688 | static void __d_instantiate(struct dentry *dentry, struct inode *inode) | 1689 | static void __d_instantiate(struct dentry *dentry, struct inode *inode) |
1689 | { | 1690 | { |
1691 | unsigned add_flags = d_flags_for_inode(inode); | ||
1692 | |||
1690 | spin_lock(&dentry->d_lock); | 1693 | spin_lock(&dentry->d_lock); |
1691 | if (inode) { | 1694 | dentry->d_flags &= ~DCACHE_ENTRY_TYPE; |
1692 | if (unlikely(IS_AUTOMOUNT(inode))) | 1695 | dentry->d_flags |= add_flags; |
1693 | dentry->d_flags |= DCACHE_NEED_AUTOMOUNT; | 1696 | if (inode) |
1694 | hlist_add_head(&dentry->d_alias, &inode->i_dentry); | 1697 | hlist_add_head(&dentry->d_alias, &inode->i_dentry); |
1695 | } | ||
1696 | dentry->d_inode = inode; | 1698 | dentry->d_inode = inode; |
1697 | dentry_rcuwalk_barrier(dentry); | 1699 | dentry_rcuwalk_barrier(dentry); |
1698 | spin_unlock(&dentry->d_lock); | 1700 | spin_unlock(&dentry->d_lock); |
@@ -1801,6 +1803,33 @@ struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode) | |||
1801 | 1803 | ||
1802 | EXPORT_SYMBOL(d_instantiate_unique); | 1804 | EXPORT_SYMBOL(d_instantiate_unique); |
1803 | 1805 | ||
1806 | /** | ||
1807 | * d_instantiate_no_diralias - instantiate a non-aliased dentry | ||
1808 | * @entry: dentry to complete | ||
1809 | * @inode: inode to attach to this dentry | ||
1810 | * | ||
1811 | * Fill in inode information in the entry. If a directory alias is found, then | ||
1812 | * return an error (and drop inode). Together with d_materialise_unique() this | ||
1813 | * guarantees that a directory inode may never have more than one alias. | ||
1814 | */ | ||
1815 | int d_instantiate_no_diralias(struct dentry *entry, struct inode *inode) | ||
1816 | { | ||
1817 | BUG_ON(!hlist_unhashed(&entry->d_alias)); | ||
1818 | |||
1819 | spin_lock(&inode->i_lock); | ||
1820 | if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry)) { | ||
1821 | spin_unlock(&inode->i_lock); | ||
1822 | iput(inode); | ||
1823 | return -EBUSY; | ||
1824 | } | ||
1825 | __d_instantiate(entry, inode); | ||
1826 | spin_unlock(&inode->i_lock); | ||
1827 | security_d_instantiate(entry, inode); | ||
1828 | |||
1829 | return 0; | ||
1830 | } | ||
1831 | EXPORT_SYMBOL(d_instantiate_no_diralias); | ||
1832 | |||
1804 | struct dentry *d_make_root(struct inode *root_inode) | 1833 | struct dentry *d_make_root(struct inode *root_inode) |
1805 | { | 1834 | { |
1806 | struct dentry *res = NULL; | 1835 | struct dentry *res = NULL; |
@@ -1870,6 +1899,7 @@ struct dentry *d_obtain_alias(struct inode *inode) | |||
1870 | static const struct qstr anonstring = QSTR_INIT("/", 1); | 1899 | static const struct qstr anonstring = QSTR_INIT("/", 1); |
1871 | struct dentry *tmp; | 1900 | struct dentry *tmp; |
1872 | struct dentry *res; | 1901 | struct dentry *res; |
1902 | unsigned add_flags; | ||
1873 | 1903 | ||
1874 | if (!inode) | 1904 | if (!inode) |
1875 | return ERR_PTR(-ESTALE); | 1905 | return ERR_PTR(-ESTALE); |
@@ -1895,9 +1925,11 @@ struct dentry *d_obtain_alias(struct inode *inode) | |||
1895 | } | 1925 | } |
1896 | 1926 | ||
1897 | /* attach a disconnected dentry */ | 1927 | /* attach a disconnected dentry */ |
1928 | add_flags = d_flags_for_inode(inode) | DCACHE_DISCONNECTED; | ||
1929 | |||
1898 | spin_lock(&tmp->d_lock); | 1930 | spin_lock(&tmp->d_lock); |
1899 | tmp->d_inode = inode; | 1931 | tmp->d_inode = inode; |
1900 | tmp->d_flags |= DCACHE_DISCONNECTED; | 1932 | tmp->d_flags |= add_flags; |
1901 | hlist_add_head(&tmp->d_alias, &inode->i_dentry); | 1933 | hlist_add_head(&tmp->d_alias, &inode->i_dentry); |
1902 | hlist_bl_lock(&tmp->d_sb->s_anon); | 1934 | hlist_bl_lock(&tmp->d_sb->s_anon); |
1903 | hlist_bl_add_head(&tmp->d_hash, &tmp->d_sb->s_anon); | 1935 | hlist_bl_add_head(&tmp->d_hash, &tmp->d_sb->s_anon); |
@@ -2725,7 +2757,6 @@ static void __d_materialise_dentry(struct dentry *dentry, struct dentry *anon) | |||
2725 | spin_unlock(&dentry->d_lock); | 2757 | spin_unlock(&dentry->d_lock); |
2726 | 2758 | ||
2727 | /* anon->d_lock still locked, returns locked */ | 2759 | /* anon->d_lock still locked, returns locked */ |
2728 | anon->d_flags &= ~DCACHE_DISCONNECTED; | ||
2729 | } | 2760 | } |
2730 | 2761 | ||
2731 | /** | 2762 | /** |
@@ -2885,23 +2916,28 @@ static int prepend_path(const struct path *path, | |||
2885 | struct vfsmount *vfsmnt = path->mnt; | 2916 | struct vfsmount *vfsmnt = path->mnt; |
2886 | struct mount *mnt = real_mount(vfsmnt); | 2917 | struct mount *mnt = real_mount(vfsmnt); |
2887 | int error = 0; | 2918 | int error = 0; |
2888 | unsigned seq = 0; | 2919 | unsigned seq, m_seq = 0; |
2889 | char *bptr; | 2920 | char *bptr; |
2890 | int blen; | 2921 | int blen; |
2891 | 2922 | ||
2892 | rcu_read_lock(); | 2923 | rcu_read_lock(); |
2924 | restart_mnt: | ||
2925 | read_seqbegin_or_lock(&mount_lock, &m_seq); | ||
2926 | seq = 0; | ||
2893 | restart: | 2927 | restart: |
2894 | bptr = *buffer; | 2928 | bptr = *buffer; |
2895 | blen = *buflen; | 2929 | blen = *buflen; |
2930 | error = 0; | ||
2896 | read_seqbegin_or_lock(&rename_lock, &seq); | 2931 | read_seqbegin_or_lock(&rename_lock, &seq); |
2897 | while (dentry != root->dentry || vfsmnt != root->mnt) { | 2932 | while (dentry != root->dentry || vfsmnt != root->mnt) { |
2898 | struct dentry * parent; | 2933 | struct dentry * parent; |
2899 | 2934 | ||
2900 | if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) { | 2935 | if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) { |
2936 | struct mount *parent = ACCESS_ONCE(mnt->mnt_parent); | ||
2901 | /* Global root? */ | 2937 | /* Global root? */ |
2902 | if (mnt_has_parent(mnt)) { | 2938 | if (mnt != parent) { |
2903 | dentry = mnt->mnt_mountpoint; | 2939 | dentry = ACCESS_ONCE(mnt->mnt_mountpoint); |
2904 | mnt = mnt->mnt_parent; | 2940 | mnt = parent; |
2905 | vfsmnt = &mnt->mnt; | 2941 | vfsmnt = &mnt->mnt; |
2906 | continue; | 2942 | continue; |
2907 | } | 2943 | } |
@@ -2935,6 +2971,11 @@ restart: | |||
2935 | goto restart; | 2971 | goto restart; |
2936 | } | 2972 | } |
2937 | done_seqretry(&rename_lock, seq); | 2973 | done_seqretry(&rename_lock, seq); |
2974 | if (need_seqretry(&mount_lock, m_seq)) { | ||
2975 | m_seq = 1; | ||
2976 | goto restart_mnt; | ||
2977 | } | ||
2978 | done_seqretry(&mount_lock, m_seq); | ||
2938 | 2979 | ||
2939 | if (error >= 0 && bptr == *buffer) { | 2980 | if (error >= 0 && bptr == *buffer) { |
2940 | if (--blen < 0) | 2981 | if (--blen < 0) |
@@ -2971,9 +3012,7 @@ char *__d_path(const struct path *path, | |||
2971 | int error; | 3012 | int error; |
2972 | 3013 | ||
2973 | prepend(&res, &buflen, "\0", 1); | 3014 | prepend(&res, &buflen, "\0", 1); |
2974 | br_read_lock(&vfsmount_lock); | ||
2975 | error = prepend_path(path, root, &res, &buflen); | 3015 | error = prepend_path(path, root, &res, &buflen); |
2976 | br_read_unlock(&vfsmount_lock); | ||
2977 | 3016 | ||
2978 | if (error < 0) | 3017 | if (error < 0) |
2979 | return ERR_PTR(error); | 3018 | return ERR_PTR(error); |
@@ -2990,9 +3029,7 @@ char *d_absolute_path(const struct path *path, | |||
2990 | int error; | 3029 | int error; |
2991 | 3030 | ||
2992 | prepend(&res, &buflen, "\0", 1); | 3031 | prepend(&res, &buflen, "\0", 1); |
2993 | br_read_lock(&vfsmount_lock); | ||
2994 | error = prepend_path(path, &root, &res, &buflen); | 3032 | error = prepend_path(path, &root, &res, &buflen); |
2995 | br_read_unlock(&vfsmount_lock); | ||
2996 | 3033 | ||
2997 | if (error > 1) | 3034 | if (error > 1) |
2998 | error = -EINVAL; | 3035 | error = -EINVAL; |
@@ -3067,9 +3104,7 @@ char *d_path(const struct path *path, char *buf, int buflen) | |||
3067 | 3104 | ||
3068 | rcu_read_lock(); | 3105 | rcu_read_lock(); |
3069 | get_fs_root_rcu(current->fs, &root); | 3106 | get_fs_root_rcu(current->fs, &root); |
3070 | br_read_lock(&vfsmount_lock); | ||
3071 | error = path_with_deleted(path, &root, &res, &buflen); | 3107 | error = path_with_deleted(path, &root, &res, &buflen); |
3072 | br_read_unlock(&vfsmount_lock); | ||
3073 | rcu_read_unlock(); | 3108 | rcu_read_unlock(); |
3074 | 3109 | ||
3075 | if (error < 0) | 3110 | if (error < 0) |
@@ -3224,7 +3259,6 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size) | |||
3224 | get_fs_root_and_pwd_rcu(current->fs, &root, &pwd); | 3259 | get_fs_root_and_pwd_rcu(current->fs, &root, &pwd); |
3225 | 3260 | ||
3226 | error = -ENOENT; | 3261 | error = -ENOENT; |
3227 | br_read_lock(&vfsmount_lock); | ||
3228 | if (!d_unlinked(pwd.dentry)) { | 3262 | if (!d_unlinked(pwd.dentry)) { |
3229 | unsigned long len; | 3263 | unsigned long len; |
3230 | char *cwd = page + PATH_MAX; | 3264 | char *cwd = page + PATH_MAX; |
@@ -3232,7 +3266,6 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size) | |||
3232 | 3266 | ||
3233 | prepend(&cwd, &buflen, "\0", 1); | 3267 | prepend(&cwd, &buflen, "\0", 1); |
3234 | error = prepend_path(&pwd, &root, &cwd, &buflen); | 3268 | error = prepend_path(&pwd, &root, &cwd, &buflen); |
3235 | br_read_unlock(&vfsmount_lock); | ||
3236 | rcu_read_unlock(); | 3269 | rcu_read_unlock(); |
3237 | 3270 | ||
3238 | if (error < 0) | 3271 | if (error < 0) |
@@ -3253,7 +3286,6 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size) | |||
3253 | error = -EFAULT; | 3286 | error = -EFAULT; |
3254 | } | 3287 | } |
3255 | } else { | 3288 | } else { |
3256 | br_read_unlock(&vfsmount_lock); | ||
3257 | rcu_read_unlock(); | 3289 | rcu_read_unlock(); |
3258 | } | 3290 | } |
3259 | 3291 | ||