diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-07-15 18:34:58 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-07-15 18:34:58 -0400 |
commit | cadc723cc19ce6b881d973d3c04e25ebb83058e6 (patch) | |
tree | 9256b4bc0685bca22469eab87cd3ec3c2deba60d /fs/nfs | |
parent | e89e896d31b11a51a54ddcd3f72a76bd286dd86c (diff) | |
parent | f839c4c1991cc9b580ae38f98f54554938a7f49c (diff) |
Merge branch 'bkl-removal' into next
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/dir.c | 62 | ||||
-rw-r--r-- | fs/nfs/file.c | 4 | ||||
-rw-r--r-- | fs/nfs/inode.c | 71 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 2 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 2 | ||||
-rw-r--r-- | fs/nfs/super.c | 4 | ||||
-rw-r--r-- | fs/nfs/write.c | 15 |
7 files changed, 83 insertions, 77 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index b1940660502f..28a238dab23a 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -139,10 +139,8 @@ nfs_opendir(struct inode *inode, struct file *filp) | |||
139 | 139 | ||
140 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); | 140 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); |
141 | 141 | ||
142 | lock_kernel(); | ||
143 | /* Call generic open code in order to cache credentials */ | 142 | /* Call generic open code in order to cache credentials */ |
144 | res = nfs_open(inode, filp); | 143 | res = nfs_open(inode, filp); |
145 | unlock_kernel(); | ||
146 | return res; | 144 | return res; |
147 | } | 145 | } |
148 | 146 | ||
@@ -536,8 +534,6 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
536 | (long long)filp->f_pos); | 534 | (long long)filp->f_pos); |
537 | nfs_inc_stats(inode, NFSIOS_VFSGETDENTS); | 535 | nfs_inc_stats(inode, NFSIOS_VFSGETDENTS); |
538 | 536 | ||
539 | lock_kernel(); | ||
540 | |||
541 | /* | 537 | /* |
542 | * filp->f_pos points to the dirent entry number. | 538 | * filp->f_pos points to the dirent entry number. |
543 | * *desc->dir_cookie has the cookie for the next entry. We have | 539 | * *desc->dir_cookie has the cookie for the next entry. We have |
@@ -595,7 +591,6 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
595 | } | 591 | } |
596 | out: | 592 | out: |
597 | nfs_unblock_sillyrename(dentry); | 593 | nfs_unblock_sillyrename(dentry); |
598 | unlock_kernel(); | ||
599 | if (res > 0) | 594 | if (res > 0) |
600 | res = 0; | 595 | res = 0; |
601 | dfprintk(FILE, "NFS: readdir(%s/%s) returns %ld\n", | 596 | dfprintk(FILE, "NFS: readdir(%s/%s) returns %ld\n", |
@@ -779,7 +774,6 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
779 | struct nfs_fattr fattr; | 774 | struct nfs_fattr fattr; |
780 | 775 | ||
781 | parent = dget_parent(dentry); | 776 | parent = dget_parent(dentry); |
782 | lock_kernel(); | ||
783 | dir = parent->d_inode; | 777 | dir = parent->d_inode; |
784 | nfs_inc_stats(dir, NFSIOS_DENTRYREVALIDATE); | 778 | nfs_inc_stats(dir, NFSIOS_DENTRYREVALIDATE); |
785 | inode = dentry->d_inode; | 779 | inode = dentry->d_inode; |
@@ -817,7 +811,6 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
817 | 811 | ||
818 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 812 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
819 | out_valid: | 813 | out_valid: |
820 | unlock_kernel(); | ||
821 | dput(parent); | 814 | dput(parent); |
822 | dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is valid\n", | 815 | dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is valid\n", |
823 | __func__, dentry->d_parent->d_name.name, | 816 | __func__, dentry->d_parent->d_name.name, |
@@ -836,7 +829,6 @@ out_zap_parent: | |||
836 | shrink_dcache_parent(dentry); | 829 | shrink_dcache_parent(dentry); |
837 | } | 830 | } |
838 | d_drop(dentry); | 831 | d_drop(dentry); |
839 | unlock_kernel(); | ||
840 | dput(parent); | 832 | dput(parent); |
841 | dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n", | 833 | dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n", |
842 | __func__, dentry->d_parent->d_name.name, | 834 | __func__, dentry->d_parent->d_name.name, |
@@ -870,6 +862,14 @@ static int nfs_dentry_delete(struct dentry *dentry) | |||
870 | 862 | ||
871 | } | 863 | } |
872 | 864 | ||
865 | static void nfs_drop_nlink(struct inode *inode) | ||
866 | { | ||
867 | spin_lock(&inode->i_lock); | ||
868 | if (inode->i_nlink > 0) | ||
869 | drop_nlink(inode); | ||
870 | spin_unlock(&inode->i_lock); | ||
871 | } | ||
872 | |||
873 | /* | 873 | /* |
874 | * Called when the dentry loses inode. | 874 | * Called when the dentry loses inode. |
875 | * We use it to clean up silly-renamed files. | 875 | * We use it to clean up silly-renamed files. |
@@ -881,10 +881,8 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode) | |||
881 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA; | 881 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA; |
882 | 882 | ||
883 | if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { | 883 | if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { |
884 | lock_kernel(); | ||
885 | drop_nlink(inode); | 884 | drop_nlink(inode); |
886 | nfs_complete_unlink(dentry, inode); | 885 | nfs_complete_unlink(dentry, inode); |
887 | unlock_kernel(); | ||
888 | } | 886 | } |
889 | iput(inode); | 887 | iput(inode); |
890 | } | 888 | } |
@@ -915,8 +913,6 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru | |||
915 | res = ERR_PTR(-ENOMEM); | 913 | res = ERR_PTR(-ENOMEM); |
916 | dentry->d_op = NFS_PROTO(dir)->dentry_ops; | 914 | dentry->d_op = NFS_PROTO(dir)->dentry_ops; |
917 | 915 | ||
918 | lock_kernel(); | ||
919 | |||
920 | /* | 916 | /* |
921 | * If we're doing an exclusive create, optimize away the lookup | 917 | * If we're doing an exclusive create, optimize away the lookup |
922 | * but don't hash the dentry. | 918 | * but don't hash the dentry. |
@@ -924,7 +920,7 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru | |||
924 | if (nfs_is_exclusive_create(dir, nd)) { | 920 | if (nfs_is_exclusive_create(dir, nd)) { |
925 | d_instantiate(dentry, NULL); | 921 | d_instantiate(dentry, NULL); |
926 | res = NULL; | 922 | res = NULL; |
927 | goto out_unlock; | 923 | goto out; |
928 | } | 924 | } |
929 | 925 | ||
930 | parent = dentry->d_parent; | 926 | parent = dentry->d_parent; |
@@ -952,8 +948,6 @@ no_entry: | |||
952 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 948 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
953 | out_unblock_sillyrename: | 949 | out_unblock_sillyrename: |
954 | nfs_unblock_sillyrename(parent); | 950 | nfs_unblock_sillyrename(parent); |
955 | out_unlock: | ||
956 | unlock_kernel(); | ||
957 | out: | 951 | out: |
958 | return res; | 952 | return res; |
959 | } | 953 | } |
@@ -1011,9 +1005,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry | |||
1011 | } | 1005 | } |
1012 | 1006 | ||
1013 | /* Open the file on the server */ | 1007 | /* Open the file on the server */ |
1014 | lock_kernel(); | ||
1015 | res = nfs4_atomic_open(dir, dentry, nd); | 1008 | res = nfs4_atomic_open(dir, dentry, nd); |
1016 | unlock_kernel(); | ||
1017 | if (IS_ERR(res)) { | 1009 | if (IS_ERR(res)) { |
1018 | error = PTR_ERR(res); | 1010 | error = PTR_ERR(res); |
1019 | switch (error) { | 1011 | switch (error) { |
@@ -1075,9 +1067,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1075 | * operations that change the directory. We therefore save the | 1067 | * operations that change the directory. We therefore save the |
1076 | * change attribute *before* we do the RPC call. | 1068 | * change attribute *before* we do the RPC call. |
1077 | */ | 1069 | */ |
1078 | lock_kernel(); | ||
1079 | ret = nfs4_open_revalidate(dir, dentry, openflags, nd); | 1070 | ret = nfs4_open_revalidate(dir, dentry, openflags, nd); |
1080 | unlock_kernel(); | ||
1081 | out: | 1071 | out: |
1082 | dput(parent); | 1072 | dput(parent); |
1083 | if (!ret) | 1073 | if (!ret) |
@@ -1230,14 +1220,11 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
1230 | if ((nd->flags & LOOKUP_CREATE) != 0) | 1220 | if ((nd->flags & LOOKUP_CREATE) != 0) |
1231 | open_flags = nd->intent.open.flags; | 1221 | open_flags = nd->intent.open.flags; |
1232 | 1222 | ||
1233 | lock_kernel(); | ||
1234 | error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, nd); | 1223 | error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, nd); |
1235 | if (error != 0) | 1224 | if (error != 0) |
1236 | goto out_err; | 1225 | goto out_err; |
1237 | unlock_kernel(); | ||
1238 | return 0; | 1226 | return 0; |
1239 | out_err: | 1227 | out_err: |
1240 | unlock_kernel(); | ||
1241 | d_drop(dentry); | 1228 | d_drop(dentry); |
1242 | return error; | 1229 | return error; |
1243 | } | 1230 | } |
@@ -1260,14 +1247,11 @@ nfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) | |||
1260 | attr.ia_mode = mode; | 1247 | attr.ia_mode = mode; |
1261 | attr.ia_valid = ATTR_MODE; | 1248 | attr.ia_valid = ATTR_MODE; |
1262 | 1249 | ||
1263 | lock_kernel(); | ||
1264 | status = NFS_PROTO(dir)->mknod(dir, dentry, &attr, rdev); | 1250 | status = NFS_PROTO(dir)->mknod(dir, dentry, &attr, rdev); |
1265 | if (status != 0) | 1251 | if (status != 0) |
1266 | goto out_err; | 1252 | goto out_err; |
1267 | unlock_kernel(); | ||
1268 | return 0; | 1253 | return 0; |
1269 | out_err: | 1254 | out_err: |
1270 | unlock_kernel(); | ||
1271 | d_drop(dentry); | 1255 | d_drop(dentry); |
1272 | return status; | 1256 | return status; |
1273 | } | 1257 | } |
@@ -1286,15 +1270,12 @@ static int nfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
1286 | attr.ia_valid = ATTR_MODE; | 1270 | attr.ia_valid = ATTR_MODE; |
1287 | attr.ia_mode = mode | S_IFDIR; | 1271 | attr.ia_mode = mode | S_IFDIR; |
1288 | 1272 | ||
1289 | lock_kernel(); | ||
1290 | error = NFS_PROTO(dir)->mkdir(dir, dentry, &attr); | 1273 | error = NFS_PROTO(dir)->mkdir(dir, dentry, &attr); |
1291 | if (error != 0) | 1274 | if (error != 0) |
1292 | goto out_err; | 1275 | goto out_err; |
1293 | unlock_kernel(); | ||
1294 | return 0; | 1276 | return 0; |
1295 | out_err: | 1277 | out_err: |
1296 | d_drop(dentry); | 1278 | d_drop(dentry); |
1297 | unlock_kernel(); | ||
1298 | return error; | 1279 | return error; |
1299 | } | 1280 | } |
1300 | 1281 | ||
@@ -1311,14 +1292,12 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
1311 | dfprintk(VFS, "NFS: rmdir(%s/%ld), %s\n", | 1292 | dfprintk(VFS, "NFS: rmdir(%s/%ld), %s\n", |
1312 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); | 1293 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); |
1313 | 1294 | ||
1314 | lock_kernel(); | ||
1315 | error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); | 1295 | error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); |
1316 | /* Ensure the VFS deletes this inode */ | 1296 | /* Ensure the VFS deletes this inode */ |
1317 | if (error == 0 && dentry->d_inode != NULL) | 1297 | if (error == 0 && dentry->d_inode != NULL) |
1318 | clear_nlink(dentry->d_inode); | 1298 | clear_nlink(dentry->d_inode); |
1319 | else if (error == -ENOENT) | 1299 | else if (error == -ENOENT) |
1320 | nfs_dentry_handle_enoent(dentry); | 1300 | nfs_dentry_handle_enoent(dentry); |
1321 | unlock_kernel(); | ||
1322 | 1301 | ||
1323 | return error; | 1302 | return error; |
1324 | } | 1303 | } |
@@ -1420,7 +1399,7 @@ static int nfs_safe_remove(struct dentry *dentry) | |||
1420 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); | 1399 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); |
1421 | /* The VFS may want to delete this inode */ | 1400 | /* The VFS may want to delete this inode */ |
1422 | if (error == 0) | 1401 | if (error == 0) |
1423 | drop_nlink(inode); | 1402 | nfs_drop_nlink(inode); |
1424 | nfs_mark_for_revalidate(inode); | 1403 | nfs_mark_for_revalidate(inode); |
1425 | } else | 1404 | } else |
1426 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); | 1405 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); |
@@ -1443,7 +1422,6 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry) | |||
1443 | dfprintk(VFS, "NFS: unlink(%s/%ld, %s)\n", dir->i_sb->s_id, | 1422 | dfprintk(VFS, "NFS: unlink(%s/%ld, %s)\n", dir->i_sb->s_id, |
1444 | dir->i_ino, dentry->d_name.name); | 1423 | dir->i_ino, dentry->d_name.name); |
1445 | 1424 | ||
1446 | lock_kernel(); | ||
1447 | spin_lock(&dcache_lock); | 1425 | spin_lock(&dcache_lock); |
1448 | spin_lock(&dentry->d_lock); | 1426 | spin_lock(&dentry->d_lock); |
1449 | if (atomic_read(&dentry->d_count) > 1) { | 1427 | if (atomic_read(&dentry->d_count) > 1) { |
@@ -1452,7 +1430,6 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry) | |||
1452 | /* Start asynchronous writeout of the inode */ | 1430 | /* Start asynchronous writeout of the inode */ |
1453 | write_inode_now(dentry->d_inode, 0); | 1431 | write_inode_now(dentry->d_inode, 0); |
1454 | error = nfs_sillyrename(dir, dentry); | 1432 | error = nfs_sillyrename(dir, dentry); |
1455 | unlock_kernel(); | ||
1456 | return error; | 1433 | return error; |
1457 | } | 1434 | } |
1458 | if (!d_unhashed(dentry)) { | 1435 | if (!d_unhashed(dentry)) { |
@@ -1466,7 +1443,6 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry) | |||
1466 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 1443 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
1467 | } else if (need_rehash) | 1444 | } else if (need_rehash) |
1468 | d_rehash(dentry); | 1445 | d_rehash(dentry); |
1469 | unlock_kernel(); | ||
1470 | return error; | 1446 | return error; |
1471 | } | 1447 | } |
1472 | 1448 | ||
@@ -1503,13 +1479,9 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym | |||
1503 | attr.ia_mode = S_IFLNK | S_IRWXUGO; | 1479 | attr.ia_mode = S_IFLNK | S_IRWXUGO; |
1504 | attr.ia_valid = ATTR_MODE; | 1480 | attr.ia_valid = ATTR_MODE; |
1505 | 1481 | ||
1506 | lock_kernel(); | ||
1507 | |||
1508 | page = alloc_page(GFP_HIGHUSER); | 1482 | page = alloc_page(GFP_HIGHUSER); |
1509 | if (!page) { | 1483 | if (!page) |
1510 | unlock_kernel(); | ||
1511 | return -ENOMEM; | 1484 | return -ENOMEM; |
1512 | } | ||
1513 | 1485 | ||
1514 | kaddr = kmap_atomic(page, KM_USER0); | 1486 | kaddr = kmap_atomic(page, KM_USER0); |
1515 | memcpy(kaddr, symname, pathlen); | 1487 | memcpy(kaddr, symname, pathlen); |
@@ -1524,7 +1496,6 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym | |||
1524 | dentry->d_name.name, symname, error); | 1496 | dentry->d_name.name, symname, error); |
1525 | d_drop(dentry); | 1497 | d_drop(dentry); |
1526 | __free_page(page); | 1498 | __free_page(page); |
1527 | unlock_kernel(); | ||
1528 | return error; | 1499 | return error; |
1529 | } | 1500 | } |
1530 | 1501 | ||
@@ -1542,7 +1513,6 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym | |||
1542 | } else | 1513 | } else |
1543 | __free_page(page); | 1514 | __free_page(page); |
1544 | 1515 | ||
1545 | unlock_kernel(); | ||
1546 | return 0; | 1516 | return 0; |
1547 | } | 1517 | } |
1548 | 1518 | ||
@@ -1556,14 +1526,12 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) | |||
1556 | old_dentry->d_parent->d_name.name, old_dentry->d_name.name, | 1526 | old_dentry->d_parent->d_name.name, old_dentry->d_name.name, |
1557 | dentry->d_parent->d_name.name, dentry->d_name.name); | 1527 | dentry->d_parent->d_name.name, dentry->d_name.name); |
1558 | 1528 | ||
1559 | lock_kernel(); | ||
1560 | d_drop(dentry); | 1529 | d_drop(dentry); |
1561 | error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); | 1530 | error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); |
1562 | if (error == 0) { | 1531 | if (error == 0) { |
1563 | atomic_inc(&inode->i_count); | 1532 | atomic_inc(&inode->i_count); |
1564 | d_add(dentry, inode); | 1533 | d_add(dentry, inode); |
1565 | } | 1534 | } |
1566 | unlock_kernel(); | ||
1567 | return error; | 1535 | return error; |
1568 | } | 1536 | } |
1569 | 1537 | ||
@@ -1603,7 +1571,6 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1603 | * To prevent any new references to the target during the rename, | 1571 | * To prevent any new references to the target during the rename, |
1604 | * we unhash the dentry and free the inode in advance. | 1572 | * we unhash the dentry and free the inode in advance. |
1605 | */ | 1573 | */ |
1606 | lock_kernel(); | ||
1607 | if (!d_unhashed(new_dentry)) { | 1574 | if (!d_unhashed(new_dentry)) { |
1608 | d_drop(new_dentry); | 1575 | d_drop(new_dentry); |
1609 | rehash = new_dentry; | 1576 | rehash = new_dentry; |
@@ -1647,7 +1614,7 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1647 | /* dentry still busy? */ | 1614 | /* dentry still busy? */ |
1648 | goto out; | 1615 | goto out; |
1649 | } else | 1616 | } else |
1650 | drop_nlink(new_inode); | 1617 | nfs_drop_nlink(new_inode); |
1651 | 1618 | ||
1652 | go_ahead: | 1619 | go_ahead: |
1653 | /* | 1620 | /* |
@@ -1681,7 +1648,6 @@ out: | |||
1681 | /* new dentry created? */ | 1648 | /* new dentry created? */ |
1682 | if (dentry) | 1649 | if (dentry) |
1683 | dput(dentry); | 1650 | dput(dentry); |
1684 | unlock_kernel(); | ||
1685 | return error; | 1651 | return error; |
1686 | } | 1652 | } |
1687 | 1653 | ||
@@ -1974,8 +1940,6 @@ int nfs_permission(struct inode *inode, int mask, struct nameidata *nd) | |||
1974 | } | 1940 | } |
1975 | 1941 | ||
1976 | force_lookup: | 1942 | force_lookup: |
1977 | lock_kernel(); | ||
1978 | |||
1979 | if (!NFS_PROTO(inode)->access) | 1943 | if (!NFS_PROTO(inode)->access) |
1980 | goto out_notsup; | 1944 | goto out_notsup; |
1981 | 1945 | ||
@@ -1985,7 +1949,6 @@ force_lookup: | |||
1985 | put_rpccred(cred); | 1949 | put_rpccred(cred); |
1986 | } else | 1950 | } else |
1987 | res = PTR_ERR(cred); | 1951 | res = PTR_ERR(cred); |
1988 | unlock_kernel(); | ||
1989 | out: | 1952 | out: |
1990 | dfprintk(VFS, "NFS: permission(%s/%ld), mask=0x%x, res=%d\n", | 1953 | dfprintk(VFS, "NFS: permission(%s/%ld), mask=0x%x, res=%d\n", |
1991 | inode->i_sb->s_id, inode->i_ino, mask, res); | 1954 | inode->i_sb->s_id, inode->i_ino, mask, res); |
@@ -1994,7 +1957,6 @@ out_notsup: | |||
1994 | res = nfs_revalidate_inode(NFS_SERVER(inode), inode); | 1957 | res = nfs_revalidate_inode(NFS_SERVER(inode), inode); |
1995 | if (res == 0) | 1958 | if (res == 0) |
1996 | res = generic_permission(inode, mask, NULL); | 1959 | res = generic_permission(inode, mask, NULL); |
1997 | unlock_kernel(); | ||
1998 | goto out; | 1960 | goto out; |
1999 | } | 1961 | } |
2000 | 1962 | ||
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 43164fe86069..78460657f5cb 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
@@ -128,9 +128,7 @@ nfs_file_open(struct inode *inode, struct file *filp) | |||
128 | return res; | 128 | return res; |
129 | 129 | ||
130 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); | 130 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); |
131 | lock_kernel(); | ||
132 | res = nfs_open(inode, filp); | 131 | res = nfs_open(inode, filp); |
133 | unlock_kernel(); | ||
134 | return res; | 132 | return res; |
135 | } | 133 | } |
136 | 134 | ||
@@ -398,9 +396,7 @@ static int nfs_write_end(struct file *file, struct address_space *mapping, | |||
398 | zero_user_segment(page, pglen, PAGE_CACHE_SIZE); | 396 | zero_user_segment(page, pglen, PAGE_CACHE_SIZE); |
399 | } | 397 | } |
400 | 398 | ||
401 | lock_kernel(); | ||
402 | status = nfs_updatepage(file, page, offset, copied); | 399 | status = nfs_updatepage(file, page, offset, copied); |
403 | unlock_kernel(); | ||
404 | 400 | ||
405 | unlock_page(page); | 401 | unlock_page(page); |
406 | page_cache_release(page); | 402 | page_cache_release(page); |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 2c23d067e2a6..df23f987da6b 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -370,7 +370,6 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
370 | if ((attr->ia_valid & ~ATTR_FILE) == 0) | 370 | if ((attr->ia_valid & ~ATTR_FILE) == 0) |
371 | return 0; | 371 | return 0; |
372 | 372 | ||
373 | lock_kernel(); | ||
374 | /* Write all dirty data */ | 373 | /* Write all dirty data */ |
375 | if (S_ISREG(inode->i_mode)) { | 374 | if (S_ISREG(inode->i_mode)) { |
376 | filemap_write_and_wait(inode->i_mapping); | 375 | filemap_write_and_wait(inode->i_mapping); |
@@ -384,11 +383,66 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
384 | error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); | 383 | error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); |
385 | if (error == 0) | 384 | if (error == 0) |
386 | nfs_refresh_inode(inode, &fattr); | 385 | nfs_refresh_inode(inode, &fattr); |
387 | unlock_kernel(); | ||
388 | return error; | 386 | return error; |
389 | } | 387 | } |
390 | 388 | ||
391 | /** | 389 | /** |
390 | * nfs_vmtruncate - unmap mappings "freed" by truncate() syscall | ||
391 | * @inode: inode of the file used | ||
392 | * @offset: file offset to start truncating | ||
393 | * | ||
394 | * This is a copy of the common vmtruncate, but with the locking | ||
395 | * corrected to take into account the fact that NFS requires | ||
396 | * inode->i_size to be updated under the inode->i_lock. | ||
397 | */ | ||
398 | static int nfs_vmtruncate(struct inode * inode, loff_t offset) | ||
399 | { | ||
400 | if (i_size_read(inode) < offset) { | ||
401 | unsigned long limit; | ||
402 | |||
403 | limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; | ||
404 | if (limit != RLIM_INFINITY && offset > limit) | ||
405 | goto out_sig; | ||
406 | if (offset > inode->i_sb->s_maxbytes) | ||
407 | goto out_big; | ||
408 | spin_lock(&inode->i_lock); | ||
409 | i_size_write(inode, offset); | ||
410 | spin_unlock(&inode->i_lock); | ||
411 | } else { | ||
412 | struct address_space *mapping = inode->i_mapping; | ||
413 | |||
414 | /* | ||
415 | * truncation of in-use swapfiles is disallowed - it would | ||
416 | * cause subsequent swapout to scribble on the now-freed | ||
417 | * blocks. | ||
418 | */ | ||
419 | if (IS_SWAPFILE(inode)) | ||
420 | return -ETXTBSY; | ||
421 | spin_lock(&inode->i_lock); | ||
422 | i_size_write(inode, offset); | ||
423 | spin_unlock(&inode->i_lock); | ||
424 | |||
425 | /* | ||
426 | * unmap_mapping_range is called twice, first simply for | ||
427 | * efficiency so that truncate_inode_pages does fewer | ||
428 | * single-page unmaps. However after this first call, and | ||
429 | * before truncate_inode_pages finishes, it is possible for | ||
430 | * private pages to be COWed, which remain after | ||
431 | * truncate_inode_pages finishes, hence the second | ||
432 | * unmap_mapping_range call must be made for correctness. | ||
433 | */ | ||
434 | unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); | ||
435 | truncate_inode_pages(mapping, offset); | ||
436 | unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); | ||
437 | } | ||
438 | return 0; | ||
439 | out_sig: | ||
440 | send_sig(SIGXFSZ, current, 0); | ||
441 | out_big: | ||
442 | return -EFBIG; | ||
443 | } | ||
444 | |||
445 | /** | ||
392 | * nfs_setattr_update_inode - Update inode metadata after a setattr call. | 446 | * nfs_setattr_update_inode - Update inode metadata after a setattr call. |
393 | * @inode: pointer to struct inode | 447 | * @inode: pointer to struct inode |
394 | * @attr: pointer to struct iattr | 448 | * @attr: pointer to struct iattr |
@@ -414,8 +468,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr) | |||
414 | } | 468 | } |
415 | if ((attr->ia_valid & ATTR_SIZE) != 0) { | 469 | if ((attr->ia_valid & ATTR_SIZE) != 0) { |
416 | nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC); | 470 | nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC); |
417 | inode->i_size = attr->ia_size; | 471 | nfs_vmtruncate(inode, attr->ia_size); |
418 | vmtruncate(inode, attr->ia_size); | ||
419 | } | 472 | } |
420 | } | 473 | } |
421 | 474 | ||
@@ -645,7 +698,6 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
645 | inode->i_sb->s_id, (long long)NFS_FILEID(inode)); | 698 | inode->i_sb->s_id, (long long)NFS_FILEID(inode)); |
646 | 699 | ||
647 | nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); | 700 | nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); |
648 | lock_kernel(); | ||
649 | if (is_bad_inode(inode)) | 701 | if (is_bad_inode(inode)) |
650 | goto out_nowait; | 702 | goto out_nowait; |
651 | if (NFS_STALE(inode)) | 703 | if (NFS_STALE(inode)) |
@@ -694,7 +746,6 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
694 | nfs_wake_up_inode(inode); | 746 | nfs_wake_up_inode(inode); |
695 | 747 | ||
696 | out_nowait: | 748 | out_nowait: |
697 | unlock_kernel(); | ||
698 | return status; | 749 | return status; |
699 | } | 750 | } |
700 | 751 | ||
@@ -829,9 +880,9 @@ static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
829 | if (S_ISDIR(inode->i_mode)) | 880 | if (S_ISDIR(inode->i_mode)) |
830 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; | 881 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; |
831 | } | 882 | } |
832 | if (inode->i_size == nfs_size_to_loff_t(fattr->pre_size) && | 883 | if (i_size_read(inode) == nfs_size_to_loff_t(fattr->pre_size) && |
833 | nfsi->npages == 0) | 884 | nfsi->npages == 0) |
834 | inode->i_size = nfs_size_to_loff_t(fattr->size); | 885 | i_size_write(inode, nfs_size_to_loff_t(fattr->size)); |
835 | } | 886 | } |
836 | } | 887 | } |
837 | 888 | ||
@@ -972,7 +1023,7 @@ int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fa | |||
972 | (fattr->valid & NFS_ATTR_WCC) == 0) { | 1023 | (fattr->valid & NFS_ATTR_WCC) == 0) { |
973 | memcpy(&fattr->pre_ctime, &inode->i_ctime, sizeof(fattr->pre_ctime)); | 1024 | memcpy(&fattr->pre_ctime, &inode->i_ctime, sizeof(fattr->pre_ctime)); |
974 | memcpy(&fattr->pre_mtime, &inode->i_mtime, sizeof(fattr->pre_mtime)); | 1025 | memcpy(&fattr->pre_mtime, &inode->i_mtime, sizeof(fattr->pre_mtime)); |
975 | fattr->pre_size = inode->i_size; | 1026 | fattr->pre_size = i_size_read(inode); |
976 | fattr->valid |= NFS_ATTR_WCC; | 1027 | fattr->valid |= NFS_ATTR_WCC; |
977 | } | 1028 | } |
978 | return nfs_post_op_update_inode(inode, fattr); | 1029 | return nfs_post_op_update_inode(inode, fattr); |
@@ -1057,7 +1108,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1057 | /* Do we perhaps have any outstanding writes, or has | 1108 | /* Do we perhaps have any outstanding writes, or has |
1058 | * the file grown beyond our last write? */ | 1109 | * the file grown beyond our last write? */ |
1059 | if (nfsi->npages == 0 || new_isize > cur_isize) { | 1110 | if (nfsi->npages == 0 || new_isize > cur_isize) { |
1060 | inode->i_size = new_isize; | 1111 | i_size_write(inode, new_isize); |
1061 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; | 1112 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; |
1062 | } | 1113 | } |
1063 | dprintk("NFS: isize change on server for file %s/%ld\n", | 1114 | dprintk("NFS: isize change on server for file %s/%ld\n", |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 4451287a81d1..c910413eaeca 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -451,9 +451,7 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) | |||
451 | /* Save the delegation */ | 451 | /* Save the delegation */ |
452 | memcpy(stateid.data, delegation->stateid.data, sizeof(stateid.data)); | 452 | memcpy(stateid.data, delegation->stateid.data, sizeof(stateid.data)); |
453 | rcu_read_unlock(); | 453 | rcu_read_unlock(); |
454 | lock_kernel(); | ||
455 | ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode); | 454 | ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode); |
456 | unlock_kernel(); | ||
457 | if (ret != 0) | 455 | if (ret != 0) |
458 | goto out; | 456 | goto out; |
459 | ret = -EAGAIN; | 457 | ret = -EAGAIN; |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 856a8934f610..401ef8b28f97 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -940,7 +940,6 @@ static int reclaimer(void *ptr) | |||
940 | allow_signal(SIGKILL); | 940 | allow_signal(SIGKILL); |
941 | 941 | ||
942 | /* Ensure exclusive access to NFSv4 state */ | 942 | /* Ensure exclusive access to NFSv4 state */ |
943 | lock_kernel(); | ||
944 | down_write(&clp->cl_sem); | 943 | down_write(&clp->cl_sem); |
945 | /* Are there any NFS mounts out there? */ | 944 | /* Are there any NFS mounts out there? */ |
946 | if (list_empty(&clp->cl_superblocks)) | 945 | if (list_empty(&clp->cl_superblocks)) |
@@ -1000,7 +999,6 @@ restart_loop: | |||
1000 | nfs_delegation_reap_unclaimed(clp); | 999 | nfs_delegation_reap_unclaimed(clp); |
1001 | out: | 1000 | out: |
1002 | up_write(&clp->cl_sem); | 1001 | up_write(&clp->cl_sem); |
1003 | unlock_kernel(); | ||
1004 | if (status == -NFS4ERR_CB_PATH_DOWN) | 1002 | if (status == -NFS4ERR_CB_PATH_DOWN) |
1005 | nfs_handle_cb_pathdown(clp); | 1003 | nfs_handle_cb_pathdown(clp); |
1006 | nfs4_clear_recover_bit(clp); | 1004 | nfs4_clear_recover_bit(clp); |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 47cf83e917be..1b94e3650f5c 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -374,8 +374,6 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
374 | }; | 374 | }; |
375 | int error; | 375 | int error; |
376 | 376 | ||
377 | lock_kernel(); | ||
378 | |||
379 | error = server->nfs_client->rpc_ops->statfs(server, fh, &res); | 377 | error = server->nfs_client->rpc_ops->statfs(server, fh, &res); |
380 | if (error < 0) | 378 | if (error < 0) |
381 | goto out_err; | 379 | goto out_err; |
@@ -407,12 +405,10 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
407 | 405 | ||
408 | buf->f_namelen = server->namelen; | 406 | buf->f_namelen = server->namelen; |
409 | 407 | ||
410 | unlock_kernel(); | ||
411 | return 0; | 408 | return 0; |
412 | 409 | ||
413 | out_err: | 410 | out_err: |
414 | dprintk("%s: statfs error = %d\n", __func__, -error); | 411 | dprintk("%s: statfs error = %d\n", __func__, -error); |
415 | unlock_kernel(); | ||
416 | return error; | 412 | return error; |
417 | } | 413 | } |
418 | 414 | ||
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index feca8c648766..3229e217c773 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -133,16 +133,21 @@ static struct nfs_page *nfs_page_find_request(struct page *page) | |||
133 | static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count) | 133 | static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count) |
134 | { | 134 | { |
135 | struct inode *inode = page->mapping->host; | 135 | struct inode *inode = page->mapping->host; |
136 | loff_t end, i_size = i_size_read(inode); | 136 | loff_t end, i_size; |
137 | pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; | 137 | pgoff_t end_index; |
138 | 138 | ||
139 | spin_lock(&inode->i_lock); | ||
140 | i_size = i_size_read(inode); | ||
141 | end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; | ||
139 | if (i_size > 0 && page->index < end_index) | 142 | if (i_size > 0 && page->index < end_index) |
140 | return; | 143 | goto out; |
141 | end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + ((loff_t)offset+count); | 144 | end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + ((loff_t)offset+count); |
142 | if (i_size >= end) | 145 | if (i_size >= end) |
143 | return; | 146 | goto out; |
144 | nfs_inc_stats(inode, NFSIOS_EXTENDWRITE); | ||
145 | i_size_write(inode, end); | 147 | i_size_write(inode, end); |
148 | nfs_inc_stats(inode, NFSIOS_EXTENDWRITE); | ||
149 | out: | ||
150 | spin_unlock(&inode->i_lock); | ||
146 | } | 151 | } |
147 | 152 | ||
148 | /* A writeback failed: mark the page as bad, and invalidate the page cache */ | 153 | /* A writeback failed: mark the page as bad, and invalidate the page cache */ |