aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2008-07-15 18:34:58 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-07-15 18:34:58 -0400
commitcadc723cc19ce6b881d973d3c04e25ebb83058e6 (patch)
tree9256b4bc0685bca22469eab87cd3ec3c2deba60d /fs
parente89e896d31b11a51a54ddcd3f72a76bd286dd86c (diff)
parentf839c4c1991cc9b580ae38f98f54554938a7f49c (diff)
Merge branch 'bkl-removal' into next
Diffstat (limited to 'fs')
-rw-r--r--fs/lockd/clntproc.c6
-rw-r--r--fs/lockd/svc4proc.c2
-rw-r--r--fs/lockd/svclock.c7
-rw-r--r--fs/lockd/svcproc.c2
-rw-r--r--fs/nfs/dir.c62
-rw-r--r--fs/nfs/file.c4
-rw-r--r--fs/nfs/inode.c71
-rw-r--r--fs/nfs/nfs4proc.c2
-rw-r--r--fs/nfs/nfs4state.c2
-rw-r--r--fs/nfs/super.c4
-rw-r--r--fs/nfs/write.c15
11 files changed, 99 insertions, 78 deletions
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index fd7d4669776e..1f6dc518505c 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -224,7 +224,9 @@ void nlm_release_call(struct nlm_rqst *call)
224 224
225static void nlmclnt_rpc_release(void *data) 225static void nlmclnt_rpc_release(void *data)
226{ 226{
227 lock_kernel();
227 nlm_release_call(data); 228 nlm_release_call(data);
229 unlock_kernel();
228} 230}
229 231
230static int nlm_wait_on_grace(wait_queue_head_t *queue) 232static int nlm_wait_on_grace(wait_queue_head_t *queue)
@@ -710,7 +712,9 @@ static void nlmclnt_unlock_callback(struct rpc_task *task, void *data)
710die: 712die:
711 return; 713 return;
712 retry_rebind: 714 retry_rebind:
715 lock_kernel();
713 nlm_rebind_host(req->a_host); 716 nlm_rebind_host(req->a_host);
717 unlock_kernel();
714 retry_unlock: 718 retry_unlock:
715 rpc_restart_call(task); 719 rpc_restart_call(task);
716} 720}
@@ -788,7 +792,9 @@ retry_cancel:
788 /* Don't ever retry more than 3 times */ 792 /* Don't ever retry more than 3 times */
789 if (req->a_retries++ >= NLMCLNT_MAX_RETRIES) 793 if (req->a_retries++ >= NLMCLNT_MAX_RETRIES)
790 goto die; 794 goto die;
795 lock_kernel();
791 nlm_rebind_host(req->a_host); 796 nlm_rebind_host(req->a_host);
797 unlock_kernel();
792 rpc_restart_call(task); 798 rpc_restart_call(task);
793 rpc_delay(task, 30 * HZ); 799 rpc_delay(task, 30 * HZ);
794} 800}
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index 385437e3387d..2e27176ff42f 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -248,7 +248,9 @@ static void nlm4svc_callback_exit(struct rpc_task *task, void *data)
248 248
249static void nlm4svc_callback_release(void *data) 249static void nlm4svc_callback_release(void *data)
250{ 250{
251 lock_kernel();
251 nlm_release_call(data); 252 nlm_release_call(data);
253 unlock_kernel();
252} 254}
253 255
254static const struct rpc_call_ops nlm4svc_callback_ops = { 256static const struct rpc_call_ops nlm4svc_callback_ops = {
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 81aca859bfde..56a08ab9a4cb 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -795,6 +795,7 @@ static void nlmsvc_grant_callback(struct rpc_task *task, void *data)
795 795
796 dprintk("lockd: GRANT_MSG RPC callback\n"); 796 dprintk("lockd: GRANT_MSG RPC callback\n");
797 797
798 lock_kernel();
798 /* if the block is not on a list at this point then it has 799 /* if the block is not on a list at this point then it has
799 * been invalidated. Don't try to requeue it. 800 * been invalidated. Don't try to requeue it.
800 * 801 *
@@ -804,7 +805,7 @@ static void nlmsvc_grant_callback(struct rpc_task *task, void *data)
804 * for nlm_blocked? 805 * for nlm_blocked?
805 */ 806 */
806 if (list_empty(&block->b_list)) 807 if (list_empty(&block->b_list))
807 return; 808 goto out;
808 809
809 /* Technically, we should down the file semaphore here. Since we 810 /* Technically, we should down the file semaphore here. Since we
810 * move the block towards the head of the queue only, no harm 811 * move the block towards the head of the queue only, no harm
@@ -818,13 +819,17 @@ static void nlmsvc_grant_callback(struct rpc_task *task, void *data)
818 } 819 }
819 nlmsvc_insert_block(block, timeout); 820 nlmsvc_insert_block(block, timeout);
820 svc_wake_up(block->b_daemon); 821 svc_wake_up(block->b_daemon);
822out:
823 unlock_kernel();
821} 824}
822 825
823static void nlmsvc_grant_release(void *data) 826static void nlmsvc_grant_release(void *data)
824{ 827{
825 struct nlm_rqst *call = data; 828 struct nlm_rqst *call = data;
826 829
830 lock_kernel();
827 nlmsvc_release_block(call->a_block); 831 nlmsvc_release_block(call->a_block);
832 unlock_kernel();
828} 833}
829 834
830static const struct rpc_call_ops nlmsvc_grant_ops = { 835static const struct rpc_call_ops nlmsvc_grant_ops = {
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index 88379cc6e0b1..ce6952b50a75 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -278,7 +278,9 @@ static void nlmsvc_callback_exit(struct rpc_task *task, void *data)
278 278
279static void nlmsvc_callback_release(void *data) 279static void nlmsvc_callback_release(void *data)
280{ 280{
281 lock_kernel();
281 nlm_release_call(data); 282 nlm_release_call(data);
283 unlock_kernel();
282} 284}
283 285
284static const struct rpc_call_ops nlmsvc_callback_ops = { 286static const struct rpc_call_ops nlmsvc_callback_ops = {
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 }
596out: 592out:
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
865static 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));
953out_unblock_sillyrename: 949out_unblock_sillyrename:
954 nfs_unblock_sillyrename(parent); 950 nfs_unblock_sillyrename(parent);
955out_unlock:
956 unlock_kernel();
957out: 951out:
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();
1081out: 1071out:
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;
1239out_err: 1227out_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;
1269out_err: 1254out_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;
1295out_err: 1277out_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
1652go_ahead: 1619go_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
1976force_lookup: 1942force_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();
1989out: 1952out:
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 */
398static 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;
439out_sig:
440 send_sig(SIGXFSZ, current, 0);
441out_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);
1001out: 1000out:
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)
133static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count) 133static 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);
149out:
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 */