diff options
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/cache_lib.c | 1 | ||||
-rw-r--r-- | fs/nfs/callback_proc.c | 1 | ||||
-rw-r--r-- | fs/nfs/callback_xdr.c | 2 | ||||
-rw-r--r-- | fs/nfs/client.c | 61 | ||||
-rw-r--r-- | fs/nfs/delegation.c | 89 | ||||
-rw-r--r-- | fs/nfs/delegation.h | 6 | ||||
-rw-r--r-- | fs/nfs/dir.c | 151 | ||||
-rw-r--r-- | fs/nfs/direct.c | 1 | ||||
-rw-r--r-- | fs/nfs/dns_resolve.c | 1 | ||||
-rw-r--r-- | fs/nfs/file.c | 20 | ||||
-rw-r--r-- | fs/nfs/fscache.c | 4 | ||||
-rw-r--r-- | fs/nfs/getroot.c | 191 | ||||
-rw-r--r-- | fs/nfs/inode.c | 69 | ||||
-rw-r--r-- | fs/nfs/internal.h | 4 | ||||
-rw-r--r-- | fs/nfs/iostat.h | 6 | ||||
-rw-r--r-- | fs/nfs/namespace.c | 21 | ||||
-rw-r--r-- | fs/nfs/nfs2xdr.c | 1 | ||||
-rw-r--r-- | fs/nfs/nfs3acl.c | 24 | ||||
-rw-r--r-- | fs/nfs/nfs3proc.c | 129 | ||||
-rw-r--r-- | fs/nfs/nfs3xdr.c | 3 | ||||
-rw-r--r-- | fs/nfs/nfs4_fs.h | 8 | ||||
-rw-r--r-- | fs/nfs/nfs4namespace.c | 13 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 186 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 36 | ||||
-rw-r--r-- | fs/nfs/nfs4xdr.c | 25 | ||||
-rw-r--r-- | fs/nfs/nfsroot.c | 14 | ||||
-rw-r--r-- | fs/nfs/pagelist.c | 37 | ||||
-rw-r--r-- | fs/nfs/proc.c | 145 | ||||
-rw-r--r-- | fs/nfs/read.c | 4 | ||||
-rw-r--r-- | fs/nfs/super.c | 176 | ||||
-rw-r--r-- | fs/nfs/symlink.c | 1 | ||||
-rw-r--r-- | fs/nfs/unlink.c | 4 | ||||
-rw-r--r-- | fs/nfs/write.c | 95 |
33 files changed, 930 insertions, 599 deletions
diff --git a/fs/nfs/cache_lib.c b/fs/nfs/cache_lib.c index b4ffd0146ea6..84690319e625 100644 --- a/fs/nfs/cache_lib.c +++ b/fs/nfs/cache_lib.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/moduleparam.h> | 10 | #include <linux/moduleparam.h> |
11 | #include <linux/mount.h> | 11 | #include <linux/mount.h> |
12 | #include <linux/namei.h> | 12 | #include <linux/namei.h> |
13 | #include <linux/slab.h> | ||
13 | #include <linux/sunrpc/cache.h> | 14 | #include <linux/sunrpc/cache.h> |
14 | #include <linux/sunrpc/rpc_pipe_fs.h> | 15 | #include <linux/sunrpc/rpc_pipe_fs.h> |
15 | 16 | ||
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index 84761b5bb8e2..a08770a7e857 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c | |||
@@ -7,6 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | #include <linux/nfs4.h> | 8 | #include <linux/nfs4.h> |
9 | #include <linux/nfs_fs.h> | 9 | #include <linux/nfs_fs.h> |
10 | #include <linux/slab.h> | ||
10 | #include "nfs4_fs.h" | 11 | #include "nfs4_fs.h" |
11 | #include "callback.h" | 12 | #include "callback.h" |
12 | #include "delegation.h" | 13 | #include "delegation.h" |
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index db30c0b398b5..05af212f0edf 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/sunrpc/svc.h> | 9 | #include <linux/sunrpc/svc.h> |
10 | #include <linux/nfs4.h> | 10 | #include <linux/nfs4.h> |
11 | #include <linux/nfs_fs.h> | 11 | #include <linux/nfs_fs.h> |
12 | #include <linux/slab.h> | ||
12 | #include "nfs4_fs.h" | 13 | #include "nfs4_fs.h" |
13 | #include "callback.h" | 14 | #include "callback.h" |
14 | 15 | ||
@@ -782,6 +783,7 @@ struct svc_version nfs4_callback_version1 = { | |||
782 | .vs_proc = nfs4_callback_procedures1, | 783 | .vs_proc = nfs4_callback_procedures1, |
783 | .vs_xdrsize = NFS4_CALLBACK_XDRSIZE, | 784 | .vs_xdrsize = NFS4_CALLBACK_XDRSIZE, |
784 | .vs_dispatch = NULL, | 785 | .vs_dispatch = NULL, |
786 | .vs_hidden = 1, | ||
785 | }; | 787 | }; |
786 | 788 | ||
787 | struct svc_version nfs4_callback_version4 = { | 789 | struct svc_version nfs4_callback_version4 = { |
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 2274f1737336..7ec9b34a59f8 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/vfs.h> | 35 | #include <linux/vfs.h> |
36 | #include <linux/inet.h> | 36 | #include <linux/inet.h> |
37 | #include <linux/in6.h> | 37 | #include <linux/in6.h> |
38 | #include <linux/slab.h> | ||
38 | #include <net/ipv6.h> | 39 | #include <net/ipv6.h> |
39 | #include <linux/nfs_xdr.h> | 40 | #include <linux/nfs_xdr.h> |
40 | #include <linux/sunrpc/bc_xprt.h> | 41 | #include <linux/sunrpc/bc_xprt.h> |
@@ -933,7 +934,6 @@ static int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, str | |||
933 | } | 934 | } |
934 | 935 | ||
935 | fsinfo.fattr = fattr; | 936 | fsinfo.fattr = fattr; |
936 | nfs_fattr_init(fattr); | ||
937 | error = clp->rpc_ops->fsinfo(server, mntfh, &fsinfo); | 937 | error = clp->rpc_ops->fsinfo(server, mntfh, &fsinfo); |
938 | if (error < 0) | 938 | if (error < 0) |
939 | goto out_error; | 939 | goto out_error; |
@@ -965,6 +965,8 @@ out_error: | |||
965 | static void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_server *source) | 965 | static void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_server *source) |
966 | { | 966 | { |
967 | target->flags = source->flags; | 967 | target->flags = source->flags; |
968 | target->rsize = source->rsize; | ||
969 | target->wsize = source->wsize; | ||
968 | target->acregmin = source->acregmin; | 970 | target->acregmin = source->acregmin; |
969 | target->acregmax = source->acregmax; | 971 | target->acregmax = source->acregmax; |
970 | target->acdirmin = source->acdirmin; | 972 | target->acdirmin = source->acdirmin; |
@@ -1044,13 +1046,18 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, | |||
1044 | struct nfs_fh *mntfh) | 1046 | struct nfs_fh *mntfh) |
1045 | { | 1047 | { |
1046 | struct nfs_server *server; | 1048 | struct nfs_server *server; |
1047 | struct nfs_fattr fattr; | 1049 | struct nfs_fattr *fattr; |
1048 | int error; | 1050 | int error; |
1049 | 1051 | ||
1050 | server = nfs_alloc_server(); | 1052 | server = nfs_alloc_server(); |
1051 | if (!server) | 1053 | if (!server) |
1052 | return ERR_PTR(-ENOMEM); | 1054 | return ERR_PTR(-ENOMEM); |
1053 | 1055 | ||
1056 | error = -ENOMEM; | ||
1057 | fattr = nfs_alloc_fattr(); | ||
1058 | if (fattr == NULL) | ||
1059 | goto error; | ||
1060 | |||
1054 | /* Get a client representation */ | 1061 | /* Get a client representation */ |
1055 | error = nfs_init_server(server, data); | 1062 | error = nfs_init_server(server, data); |
1056 | if (error < 0) | 1063 | if (error < 0) |
@@ -1061,7 +1068,7 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, | |||
1061 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); | 1068 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); |
1062 | 1069 | ||
1063 | /* Probe the root fh to retrieve its FSID */ | 1070 | /* Probe the root fh to retrieve its FSID */ |
1064 | error = nfs_probe_fsinfo(server, mntfh, &fattr); | 1071 | error = nfs_probe_fsinfo(server, mntfh, fattr); |
1065 | if (error < 0) | 1072 | if (error < 0) |
1066 | goto error; | 1073 | goto error; |
1067 | if (server->nfs_client->rpc_ops->version == 3) { | 1074 | if (server->nfs_client->rpc_ops->version == 3) { |
@@ -1074,14 +1081,14 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, | |||
1074 | server->namelen = NFS2_MAXNAMLEN; | 1081 | server->namelen = NFS2_MAXNAMLEN; |
1075 | } | 1082 | } |
1076 | 1083 | ||
1077 | if (!(fattr.valid & NFS_ATTR_FATTR)) { | 1084 | if (!(fattr->valid & NFS_ATTR_FATTR)) { |
1078 | error = server->nfs_client->rpc_ops->getattr(server, mntfh, &fattr); | 1085 | error = server->nfs_client->rpc_ops->getattr(server, mntfh, fattr); |
1079 | if (error < 0) { | 1086 | if (error < 0) { |
1080 | dprintk("nfs_create_server: getattr error = %d\n", -error); | 1087 | dprintk("nfs_create_server: getattr error = %d\n", -error); |
1081 | goto error; | 1088 | goto error; |
1082 | } | 1089 | } |
1083 | } | 1090 | } |
1084 | memcpy(&server->fsid, &fattr.fsid, sizeof(server->fsid)); | 1091 | memcpy(&server->fsid, &fattr->fsid, sizeof(server->fsid)); |
1085 | 1092 | ||
1086 | dprintk("Server FSID: %llx:%llx\n", | 1093 | dprintk("Server FSID: %llx:%llx\n", |
1087 | (unsigned long long) server->fsid.major, | 1094 | (unsigned long long) server->fsid.major, |
@@ -1093,9 +1100,11 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, | |||
1093 | spin_unlock(&nfs_client_lock); | 1100 | spin_unlock(&nfs_client_lock); |
1094 | 1101 | ||
1095 | server->mount_time = jiffies; | 1102 | server->mount_time = jiffies; |
1103 | nfs_free_fattr(fattr); | ||
1096 | return server; | 1104 | return server; |
1097 | 1105 | ||
1098 | error: | 1106 | error: |
1107 | nfs_free_fattr(fattr); | ||
1099 | nfs_free_server(server); | 1108 | nfs_free_server(server); |
1100 | return ERR_PTR(error); | 1109 | return ERR_PTR(error); |
1101 | } | 1110 | } |
@@ -1293,7 +1302,8 @@ static int nfs4_init_server(struct nfs_server *server, | |||
1293 | 1302 | ||
1294 | /* Initialise the client representation from the mount data */ | 1303 | /* Initialise the client representation from the mount data */ |
1295 | server->flags = data->flags; | 1304 | server->flags = data->flags; |
1296 | server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR; | 1305 | server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR| |
1306 | NFS_CAP_POSIX_LOCK; | ||
1297 | server->options = data->options; | 1307 | server->options = data->options; |
1298 | 1308 | ||
1299 | /* Get a client record */ | 1309 | /* Get a client record */ |
@@ -1336,7 +1346,7 @@ error: | |||
1336 | struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, | 1346 | struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, |
1337 | struct nfs_fh *mntfh) | 1347 | struct nfs_fh *mntfh) |
1338 | { | 1348 | { |
1339 | struct nfs_fattr fattr; | 1349 | struct nfs_fattr *fattr; |
1340 | struct nfs_server *server; | 1350 | struct nfs_server *server; |
1341 | int error; | 1351 | int error; |
1342 | 1352 | ||
@@ -1346,6 +1356,11 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, | |||
1346 | if (!server) | 1356 | if (!server) |
1347 | return ERR_PTR(-ENOMEM); | 1357 | return ERR_PTR(-ENOMEM); |
1348 | 1358 | ||
1359 | error = -ENOMEM; | ||
1360 | fattr = nfs_alloc_fattr(); | ||
1361 | if (fattr == NULL) | ||
1362 | goto error; | ||
1363 | |||
1349 | /* set up the general RPC client */ | 1364 | /* set up the general RPC client */ |
1350 | error = nfs4_init_server(server, data); | 1365 | error = nfs4_init_server(server, data); |
1351 | if (error < 0) | 1366 | if (error < 0) |
@@ -1360,7 +1375,7 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, | |||
1360 | goto error; | 1375 | goto error; |
1361 | 1376 | ||
1362 | /* Probe the root fh to retrieve its FSID */ | 1377 | /* Probe the root fh to retrieve its FSID */ |
1363 | error = nfs4_path_walk(server, mntfh, data->nfs_server.export_path); | 1378 | error = nfs4_get_rootfh(server, mntfh); |
1364 | if (error < 0) | 1379 | if (error < 0) |
1365 | goto error; | 1380 | goto error; |
1366 | 1381 | ||
@@ -1371,7 +1386,7 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, | |||
1371 | 1386 | ||
1372 | nfs4_session_set_rwsize(server); | 1387 | nfs4_session_set_rwsize(server); |
1373 | 1388 | ||
1374 | error = nfs_probe_fsinfo(server, mntfh, &fattr); | 1389 | error = nfs_probe_fsinfo(server, mntfh, fattr); |
1375 | if (error < 0) | 1390 | if (error < 0) |
1376 | goto error; | 1391 | goto error; |
1377 | 1392 | ||
@@ -1385,9 +1400,11 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, | |||
1385 | 1400 | ||
1386 | server->mount_time = jiffies; | 1401 | server->mount_time = jiffies; |
1387 | dprintk("<-- nfs4_create_server() = %p\n", server); | 1402 | dprintk("<-- nfs4_create_server() = %p\n", server); |
1403 | nfs_free_fattr(fattr); | ||
1388 | return server; | 1404 | return server; |
1389 | 1405 | ||
1390 | error: | 1406 | error: |
1407 | nfs_free_fattr(fattr); | ||
1391 | nfs_free_server(server); | 1408 | nfs_free_server(server); |
1392 | dprintk("<-- nfs4_create_server() = error %d\n", error); | 1409 | dprintk("<-- nfs4_create_server() = error %d\n", error); |
1393 | return ERR_PTR(error); | 1410 | return ERR_PTR(error); |
@@ -1401,7 +1418,7 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, | |||
1401 | { | 1418 | { |
1402 | struct nfs_client *parent_client; | 1419 | struct nfs_client *parent_client; |
1403 | struct nfs_server *server, *parent_server; | 1420 | struct nfs_server *server, *parent_server; |
1404 | struct nfs_fattr fattr; | 1421 | struct nfs_fattr *fattr; |
1405 | int error; | 1422 | int error; |
1406 | 1423 | ||
1407 | dprintk("--> nfs4_create_referral_server()\n"); | 1424 | dprintk("--> nfs4_create_referral_server()\n"); |
@@ -1410,6 +1427,11 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, | |||
1410 | if (!server) | 1427 | if (!server) |
1411 | return ERR_PTR(-ENOMEM); | 1428 | return ERR_PTR(-ENOMEM); |
1412 | 1429 | ||
1430 | error = -ENOMEM; | ||
1431 | fattr = nfs_alloc_fattr(); | ||
1432 | if (fattr == NULL) | ||
1433 | goto error; | ||
1434 | |||
1413 | parent_server = NFS_SB(data->sb); | 1435 | parent_server = NFS_SB(data->sb); |
1414 | parent_client = parent_server->nfs_client; | 1436 | parent_client = parent_server->nfs_client; |
1415 | 1437 | ||
@@ -1439,12 +1461,12 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, | |||
1439 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); | 1461 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); |
1440 | 1462 | ||
1441 | /* Probe the root fh to retrieve its FSID and filehandle */ | 1463 | /* Probe the root fh to retrieve its FSID and filehandle */ |
1442 | error = nfs4_path_walk(server, mntfh, data->mnt_path); | 1464 | error = nfs4_get_rootfh(server, mntfh); |
1443 | if (error < 0) | 1465 | if (error < 0) |
1444 | goto error; | 1466 | goto error; |
1445 | 1467 | ||
1446 | /* probe the filesystem info for this server filesystem */ | 1468 | /* probe the filesystem info for this server filesystem */ |
1447 | error = nfs_probe_fsinfo(server, mntfh, &fattr); | 1469 | error = nfs_probe_fsinfo(server, mntfh, fattr); |
1448 | if (error < 0) | 1470 | if (error < 0) |
1449 | goto error; | 1471 | goto error; |
1450 | 1472 | ||
@@ -1462,10 +1484,12 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, | |||
1462 | 1484 | ||
1463 | server->mount_time = jiffies; | 1485 | server->mount_time = jiffies; |
1464 | 1486 | ||
1487 | nfs_free_fattr(fattr); | ||
1465 | dprintk("<-- nfs_create_referral_server() = %p\n", server); | 1488 | dprintk("<-- nfs_create_referral_server() = %p\n", server); |
1466 | return server; | 1489 | return server; |
1467 | 1490 | ||
1468 | error: | 1491 | error: |
1492 | nfs_free_fattr(fattr); | ||
1469 | nfs_free_server(server); | 1493 | nfs_free_server(server); |
1470 | dprintk("<-- nfs4_create_referral_server() = error %d\n", error); | 1494 | dprintk("<-- nfs4_create_referral_server() = error %d\n", error); |
1471 | return ERR_PTR(error); | 1495 | return ERR_PTR(error); |
@@ -1481,7 +1505,7 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source, | |||
1481 | struct nfs_fattr *fattr) | 1505 | struct nfs_fattr *fattr) |
1482 | { | 1506 | { |
1483 | struct nfs_server *server; | 1507 | struct nfs_server *server; |
1484 | struct nfs_fattr fattr_fsinfo; | 1508 | struct nfs_fattr *fattr_fsinfo; |
1485 | int error; | 1509 | int error; |
1486 | 1510 | ||
1487 | dprintk("--> nfs_clone_server(,%llx:%llx,)\n", | 1511 | dprintk("--> nfs_clone_server(,%llx:%llx,)\n", |
@@ -1492,6 +1516,11 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source, | |||
1492 | if (!server) | 1516 | if (!server) |
1493 | return ERR_PTR(-ENOMEM); | 1517 | return ERR_PTR(-ENOMEM); |
1494 | 1518 | ||
1519 | error = -ENOMEM; | ||
1520 | fattr_fsinfo = nfs_alloc_fattr(); | ||
1521 | if (fattr_fsinfo == NULL) | ||
1522 | goto out_free_server; | ||
1523 | |||
1495 | /* Copy data from the source */ | 1524 | /* Copy data from the source */ |
1496 | server->nfs_client = source->nfs_client; | 1525 | server->nfs_client = source->nfs_client; |
1497 | atomic_inc(&server->nfs_client->cl_count); | 1526 | atomic_inc(&server->nfs_client->cl_count); |
@@ -1508,7 +1537,7 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source, | |||
1508 | nfs_init_server_aclclient(server); | 1537 | nfs_init_server_aclclient(server); |
1509 | 1538 | ||
1510 | /* probe the filesystem info for this server filesystem */ | 1539 | /* probe the filesystem info for this server filesystem */ |
1511 | error = nfs_probe_fsinfo(server, fh, &fattr_fsinfo); | 1540 | error = nfs_probe_fsinfo(server, fh, fattr_fsinfo); |
1512 | if (error < 0) | 1541 | if (error < 0) |
1513 | goto out_free_server; | 1542 | goto out_free_server; |
1514 | 1543 | ||
@@ -1530,10 +1559,12 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source, | |||
1530 | 1559 | ||
1531 | server->mount_time = jiffies; | 1560 | server->mount_time = jiffies; |
1532 | 1561 | ||
1562 | nfs_free_fattr(fattr_fsinfo); | ||
1533 | dprintk("<-- nfs_clone_server() = %p\n", server); | 1563 | dprintk("<-- nfs_clone_server() = %p\n", server); |
1534 | return server; | 1564 | return server; |
1535 | 1565 | ||
1536 | out_free_server: | 1566 | out_free_server: |
1567 | nfs_free_fattr(fattr_fsinfo); | ||
1537 | nfs_free_server(server); | 1568 | nfs_free_server(server); |
1538 | dprintk("<-- nfs_clone_server() = error %d\n", error); | 1569 | dprintk("<-- nfs_clone_server() = error %d\n", error); |
1539 | return ERR_PTR(error); | 1570 | return ERR_PTR(error); |
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 2563bebc4c67..301634543974 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/kthread.h> | 10 | #include <linux/kthread.h> |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/sched.h> | 12 | #include <linux/sched.h> |
13 | #include <linux/slab.h> | ||
13 | #include <linux/smp_lock.h> | 14 | #include <linux/smp_lock.h> |
14 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
15 | 16 | ||
@@ -23,6 +24,8 @@ | |||
23 | 24 | ||
24 | static void nfs_do_free_delegation(struct nfs_delegation *delegation) | 25 | static void nfs_do_free_delegation(struct nfs_delegation *delegation) |
25 | { | 26 | { |
27 | if (delegation->cred) | ||
28 | put_rpccred(delegation->cred); | ||
26 | kfree(delegation); | 29 | kfree(delegation); |
27 | } | 30 | } |
28 | 31 | ||
@@ -35,13 +38,7 @@ static void nfs_free_delegation_callback(struct rcu_head *head) | |||
35 | 38 | ||
36 | static void nfs_free_delegation(struct nfs_delegation *delegation) | 39 | static void nfs_free_delegation(struct nfs_delegation *delegation) |
37 | { | 40 | { |
38 | struct rpc_cred *cred; | ||
39 | |||
40 | cred = rcu_dereference(delegation->cred); | ||
41 | rcu_assign_pointer(delegation->cred, NULL); | ||
42 | call_rcu(&delegation->rcu, nfs_free_delegation_callback); | 41 | call_rcu(&delegation->rcu, nfs_free_delegation_callback); |
43 | if (cred) | ||
44 | put_rpccred(cred); | ||
45 | } | 42 | } |
46 | 43 | ||
47 | void nfs_mark_delegation_referenced(struct nfs_delegation *delegation) | 44 | void nfs_mark_delegation_referenced(struct nfs_delegation *delegation) |
@@ -128,21 +125,35 @@ again: | |||
128 | */ | 125 | */ |
129 | void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res) | 126 | void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res) |
130 | { | 127 | { |
131 | struct nfs_delegation *delegation = NFS_I(inode)->delegation; | 128 | struct nfs_delegation *delegation; |
132 | struct rpc_cred *oldcred; | 129 | struct rpc_cred *oldcred = NULL; |
133 | 130 | ||
134 | if (delegation == NULL) | 131 | rcu_read_lock(); |
135 | return; | 132 | delegation = rcu_dereference(NFS_I(inode)->delegation); |
136 | memcpy(delegation->stateid.data, res->delegation.data, | 133 | if (delegation != NULL) { |
137 | sizeof(delegation->stateid.data)); | 134 | spin_lock(&delegation->lock); |
138 | delegation->type = res->delegation_type; | 135 | if (delegation->inode != NULL) { |
139 | delegation->maxsize = res->maxsize; | 136 | memcpy(delegation->stateid.data, res->delegation.data, |
140 | oldcred = delegation->cred; | 137 | sizeof(delegation->stateid.data)); |
141 | delegation->cred = get_rpccred(cred); | 138 | delegation->type = res->delegation_type; |
142 | clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags); | 139 | delegation->maxsize = res->maxsize; |
143 | NFS_I(inode)->delegation_state = delegation->type; | 140 | oldcred = delegation->cred; |
144 | smp_wmb(); | 141 | delegation->cred = get_rpccred(cred); |
145 | put_rpccred(oldcred); | 142 | clear_bit(NFS_DELEGATION_NEED_RECLAIM, |
143 | &delegation->flags); | ||
144 | NFS_I(inode)->delegation_state = delegation->type; | ||
145 | spin_unlock(&delegation->lock); | ||
146 | put_rpccred(oldcred); | ||
147 | rcu_read_unlock(); | ||
148 | } else { | ||
149 | /* We appear to have raced with a delegation return. */ | ||
150 | spin_unlock(&delegation->lock); | ||
151 | rcu_read_unlock(); | ||
152 | nfs_inode_set_delegation(inode, cred, res); | ||
153 | } | ||
154 | } else { | ||
155 | rcu_read_unlock(); | ||
156 | } | ||
146 | } | 157 | } |
147 | 158 | ||
148 | static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync) | 159 | static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync) |
@@ -165,9 +176,13 @@ static struct inode *nfs_delegation_grab_inode(struct nfs_delegation *delegation | |||
165 | return inode; | 176 | return inode; |
166 | } | 177 | } |
167 | 178 | ||
168 | static struct nfs_delegation *nfs_detach_delegation_locked(struct nfs_inode *nfsi, const nfs4_stateid *stateid) | 179 | static struct nfs_delegation *nfs_detach_delegation_locked(struct nfs_inode *nfsi, |
180 | const nfs4_stateid *stateid, | ||
181 | struct nfs_client *clp) | ||
169 | { | 182 | { |
170 | struct nfs_delegation *delegation = rcu_dereference(nfsi->delegation); | 183 | struct nfs_delegation *delegation = |
184 | rcu_dereference_protected(nfsi->delegation, | ||
185 | lockdep_is_held(&clp->cl_lock)); | ||
171 | 186 | ||
172 | if (delegation == NULL) | 187 | if (delegation == NULL) |
173 | goto nomatch; | 188 | goto nomatch; |
@@ -194,11 +209,11 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct | |||
194 | { | 209 | { |
195 | struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; | 210 | struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; |
196 | struct nfs_inode *nfsi = NFS_I(inode); | 211 | struct nfs_inode *nfsi = NFS_I(inode); |
197 | struct nfs_delegation *delegation; | 212 | struct nfs_delegation *delegation, *old_delegation; |
198 | struct nfs_delegation *freeme = NULL; | 213 | struct nfs_delegation *freeme = NULL; |
199 | int status = 0; | 214 | int status = 0; |
200 | 215 | ||
201 | delegation = kmalloc(sizeof(*delegation), GFP_KERNEL); | 216 | delegation = kmalloc(sizeof(*delegation), GFP_NOFS); |
202 | if (delegation == NULL) | 217 | if (delegation == NULL) |
203 | return -ENOMEM; | 218 | return -ENOMEM; |
204 | memcpy(delegation->stateid.data, res->delegation.data, | 219 | memcpy(delegation->stateid.data, res->delegation.data, |
@@ -212,10 +227,12 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct | |||
212 | spin_lock_init(&delegation->lock); | 227 | spin_lock_init(&delegation->lock); |
213 | 228 | ||
214 | spin_lock(&clp->cl_lock); | 229 | spin_lock(&clp->cl_lock); |
215 | if (rcu_dereference(nfsi->delegation) != NULL) { | 230 | old_delegation = rcu_dereference_protected(nfsi->delegation, |
216 | if (memcmp(&delegation->stateid, &nfsi->delegation->stateid, | 231 | lockdep_is_held(&clp->cl_lock)); |
217 | sizeof(delegation->stateid)) == 0 && | 232 | if (old_delegation != NULL) { |
218 | delegation->type == nfsi->delegation->type) { | 233 | if (memcmp(&delegation->stateid, &old_delegation->stateid, |
234 | sizeof(old_delegation->stateid)) == 0 && | ||
235 | delegation->type == old_delegation->type) { | ||
219 | goto out; | 236 | goto out; |
220 | } | 237 | } |
221 | /* | 238 | /* |
@@ -225,12 +242,12 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct | |||
225 | dfprintk(FILE, "%s: server %s handed out " | 242 | dfprintk(FILE, "%s: server %s handed out " |
226 | "a duplicate delegation!\n", | 243 | "a duplicate delegation!\n", |
227 | __func__, clp->cl_hostname); | 244 | __func__, clp->cl_hostname); |
228 | if (delegation->type <= nfsi->delegation->type) { | 245 | if (delegation->type <= old_delegation->type) { |
229 | freeme = delegation; | 246 | freeme = delegation; |
230 | delegation = NULL; | 247 | delegation = NULL; |
231 | goto out; | 248 | goto out; |
232 | } | 249 | } |
233 | freeme = nfs_detach_delegation_locked(nfsi, NULL); | 250 | freeme = nfs_detach_delegation_locked(nfsi, NULL, clp); |
234 | } | 251 | } |
235 | list_add_rcu(&delegation->super_list, &clp->cl_delegations); | 252 | list_add_rcu(&delegation->super_list, &clp->cl_delegations); |
236 | nfsi->delegation_state = delegation->type; | 253 | nfsi->delegation_state = delegation->type; |
@@ -300,7 +317,7 @@ restart: | |||
300 | if (inode == NULL) | 317 | if (inode == NULL) |
301 | continue; | 318 | continue; |
302 | spin_lock(&clp->cl_lock); | 319 | spin_lock(&clp->cl_lock); |
303 | delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL); | 320 | delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL, clp); |
304 | spin_unlock(&clp->cl_lock); | 321 | spin_unlock(&clp->cl_lock); |
305 | rcu_read_unlock(); | 322 | rcu_read_unlock(); |
306 | if (delegation != NULL) { | 323 | if (delegation != NULL) { |
@@ -329,9 +346,9 @@ void nfs_inode_return_delegation_noreclaim(struct inode *inode) | |||
329 | struct nfs_inode *nfsi = NFS_I(inode); | 346 | struct nfs_inode *nfsi = NFS_I(inode); |
330 | struct nfs_delegation *delegation; | 347 | struct nfs_delegation *delegation; |
331 | 348 | ||
332 | if (rcu_dereference(nfsi->delegation) != NULL) { | 349 | if (rcu_access_pointer(nfsi->delegation) != NULL) { |
333 | spin_lock(&clp->cl_lock); | 350 | spin_lock(&clp->cl_lock); |
334 | delegation = nfs_detach_delegation_locked(nfsi, NULL); | 351 | delegation = nfs_detach_delegation_locked(nfsi, NULL, clp); |
335 | spin_unlock(&clp->cl_lock); | 352 | spin_unlock(&clp->cl_lock); |
336 | if (delegation != NULL) | 353 | if (delegation != NULL) |
337 | nfs_do_return_delegation(inode, delegation, 0); | 354 | nfs_do_return_delegation(inode, delegation, 0); |
@@ -345,9 +362,9 @@ int nfs_inode_return_delegation(struct inode *inode) | |||
345 | struct nfs_delegation *delegation; | 362 | struct nfs_delegation *delegation; |
346 | int err = 0; | 363 | int err = 0; |
347 | 364 | ||
348 | if (rcu_dereference(nfsi->delegation) != NULL) { | 365 | if (rcu_access_pointer(nfsi->delegation) != NULL) { |
349 | spin_lock(&clp->cl_lock); | 366 | spin_lock(&clp->cl_lock); |
350 | delegation = nfs_detach_delegation_locked(nfsi, NULL); | 367 | delegation = nfs_detach_delegation_locked(nfsi, NULL, clp); |
351 | spin_unlock(&clp->cl_lock); | 368 | spin_unlock(&clp->cl_lock); |
352 | if (delegation != NULL) { | 369 | if (delegation != NULL) { |
353 | nfs_msync_inode(inode); | 370 | nfs_msync_inode(inode); |
@@ -525,7 +542,7 @@ restart: | |||
525 | if (inode == NULL) | 542 | if (inode == NULL) |
526 | continue; | 543 | continue; |
527 | spin_lock(&clp->cl_lock); | 544 | spin_lock(&clp->cl_lock); |
528 | delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL); | 545 | delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL, clp); |
529 | spin_unlock(&clp->cl_lock); | 546 | spin_unlock(&clp->cl_lock); |
530 | rcu_read_unlock(); | 547 | rcu_read_unlock(); |
531 | if (delegation != NULL) | 548 | if (delegation != NULL) |
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 944b627ec6e1..69e7b8140122 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h | |||
@@ -71,4 +71,10 @@ static inline int nfs_inode_return_delegation(struct inode *inode) | |||
71 | } | 71 | } |
72 | #endif | 72 | #endif |
73 | 73 | ||
74 | static inline int nfs_have_delegated_attributes(struct inode *inode) | ||
75 | { | ||
76 | return nfs_have_delegation(inode, FMODE_READ) && | ||
77 | !(NFS_I(inode)->cache_validity & NFS_INO_REVAL_FORCED); | ||
78 | } | ||
79 | |||
74 | #endif | 80 | #endif |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index a1f6b4438fb1..ee9a179ebdf3 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -530,9 +530,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
530 | nfs_readdir_descriptor_t my_desc, | 530 | nfs_readdir_descriptor_t my_desc, |
531 | *desc = &my_desc; | 531 | *desc = &my_desc; |
532 | struct nfs_entry my_entry; | 532 | struct nfs_entry my_entry; |
533 | struct nfs_fh fh; | 533 | int res = -ENOMEM; |
534 | struct nfs_fattr fattr; | ||
535 | long res; | ||
536 | 534 | ||
537 | dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n", | 535 | dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n", |
538 | dentry->d_parent->d_name.name, dentry->d_name.name, | 536 | dentry->d_parent->d_name.name, dentry->d_name.name, |
@@ -554,9 +552,11 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
554 | 552 | ||
555 | my_entry.cookie = my_entry.prev_cookie = 0; | 553 | my_entry.cookie = my_entry.prev_cookie = 0; |
556 | my_entry.eof = 0; | 554 | my_entry.eof = 0; |
557 | my_entry.fh = &fh; | 555 | my_entry.fh = nfs_alloc_fhandle(); |
558 | my_entry.fattr = &fattr; | 556 | my_entry.fattr = nfs_alloc_fattr(); |
559 | nfs_fattr_init(&fattr); | 557 | if (my_entry.fh == NULL || my_entry.fattr == NULL) |
558 | goto out_alloc_failed; | ||
559 | |||
560 | desc->entry = &my_entry; | 560 | desc->entry = &my_entry; |
561 | 561 | ||
562 | nfs_block_sillyrename(dentry); | 562 | nfs_block_sillyrename(dentry); |
@@ -598,7 +598,10 @@ out: | |||
598 | nfs_unblock_sillyrename(dentry); | 598 | nfs_unblock_sillyrename(dentry); |
599 | if (res > 0) | 599 | if (res > 0) |
600 | res = 0; | 600 | res = 0; |
601 | dfprintk(FILE, "NFS: readdir(%s/%s) returns %ld\n", | 601 | out_alloc_failed: |
602 | nfs_free_fattr(my_entry.fattr); | ||
603 | nfs_free_fhandle(my_entry.fh); | ||
604 | dfprintk(FILE, "NFS: readdir(%s/%s) returns %d\n", | ||
602 | dentry->d_parent->d_name.name, dentry->d_name.name, | 605 | dentry->d_parent->d_name.name, dentry->d_name.name, |
603 | res); | 606 | res); |
604 | return res; | 607 | return res; |
@@ -776,9 +779,9 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
776 | struct inode *dir; | 779 | struct inode *dir; |
777 | struct inode *inode; | 780 | struct inode *inode; |
778 | struct dentry *parent; | 781 | struct dentry *parent; |
782 | struct nfs_fh *fhandle = NULL; | ||
783 | struct nfs_fattr *fattr = NULL; | ||
779 | int error; | 784 | int error; |
780 | struct nfs_fh fhandle; | ||
781 | struct nfs_fattr fattr; | ||
782 | 785 | ||
783 | parent = dget_parent(dentry); | 786 | parent = dget_parent(dentry); |
784 | dir = parent->d_inode; | 787 | dir = parent->d_inode; |
@@ -811,14 +814,22 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
811 | if (NFS_STALE(inode)) | 814 | if (NFS_STALE(inode)) |
812 | goto out_bad; | 815 | goto out_bad; |
813 | 816 | ||
814 | error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, &fhandle, &fattr); | 817 | error = -ENOMEM; |
818 | fhandle = nfs_alloc_fhandle(); | ||
819 | fattr = nfs_alloc_fattr(); | ||
820 | if (fhandle == NULL || fattr == NULL) | ||
821 | goto out_error; | ||
822 | |||
823 | error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr); | ||
815 | if (error) | 824 | if (error) |
816 | goto out_bad; | 825 | goto out_bad; |
817 | if (nfs_compare_fh(NFS_FH(inode), &fhandle)) | 826 | if (nfs_compare_fh(NFS_FH(inode), fhandle)) |
818 | goto out_bad; | 827 | goto out_bad; |
819 | if ((error = nfs_refresh_inode(inode, &fattr)) != 0) | 828 | if ((error = nfs_refresh_inode(inode, fattr)) != 0) |
820 | goto out_bad; | 829 | goto out_bad; |
821 | 830 | ||
831 | nfs_free_fattr(fattr); | ||
832 | nfs_free_fhandle(fhandle); | ||
822 | out_set_verifier: | 833 | out_set_verifier: |
823 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 834 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
824 | out_valid: | 835 | out_valid: |
@@ -837,14 +848,26 @@ out_zap_parent: | |||
837 | /* If we have submounts, don't unhash ! */ | 848 | /* If we have submounts, don't unhash ! */ |
838 | if (have_submounts(dentry)) | 849 | if (have_submounts(dentry)) |
839 | goto out_valid; | 850 | goto out_valid; |
851 | if (dentry->d_flags & DCACHE_DISCONNECTED) | ||
852 | goto out_valid; | ||
840 | shrink_dcache_parent(dentry); | 853 | shrink_dcache_parent(dentry); |
841 | } | 854 | } |
842 | d_drop(dentry); | 855 | d_drop(dentry); |
856 | nfs_free_fattr(fattr); | ||
857 | nfs_free_fhandle(fhandle); | ||
843 | dput(parent); | 858 | dput(parent); |
844 | dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n", | 859 | dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n", |
845 | __func__, dentry->d_parent->d_name.name, | 860 | __func__, dentry->d_parent->d_name.name, |
846 | dentry->d_name.name); | 861 | dentry->d_name.name); |
847 | return 0; | 862 | return 0; |
863 | out_error: | ||
864 | nfs_free_fattr(fattr); | ||
865 | nfs_free_fhandle(fhandle); | ||
866 | dput(parent); | ||
867 | dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) lookup returned error %d\n", | ||
868 | __func__, dentry->d_parent->d_name.name, | ||
869 | dentry->d_name.name, error); | ||
870 | return error; | ||
848 | } | 871 | } |
849 | 872 | ||
850 | /* | 873 | /* |
@@ -909,9 +932,9 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru | |||
909 | struct dentry *res; | 932 | struct dentry *res; |
910 | struct dentry *parent; | 933 | struct dentry *parent; |
911 | struct inode *inode = NULL; | 934 | struct inode *inode = NULL; |
935 | struct nfs_fh *fhandle = NULL; | ||
936 | struct nfs_fattr *fattr = NULL; | ||
912 | int error; | 937 | int error; |
913 | struct nfs_fh fhandle; | ||
914 | struct nfs_fattr fattr; | ||
915 | 938 | ||
916 | dfprintk(VFS, "NFS: lookup(%s/%s)\n", | 939 | dfprintk(VFS, "NFS: lookup(%s/%s)\n", |
917 | dentry->d_parent->d_name.name, dentry->d_name.name); | 940 | dentry->d_parent->d_name.name, dentry->d_name.name); |
@@ -921,7 +944,6 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru | |||
921 | if (dentry->d_name.len > NFS_SERVER(dir)->namelen) | 944 | if (dentry->d_name.len > NFS_SERVER(dir)->namelen) |
922 | goto out; | 945 | goto out; |
923 | 946 | ||
924 | res = ERR_PTR(-ENOMEM); | ||
925 | dentry->d_op = NFS_PROTO(dir)->dentry_ops; | 947 | dentry->d_op = NFS_PROTO(dir)->dentry_ops; |
926 | 948 | ||
927 | /* | 949 | /* |
@@ -934,17 +956,23 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru | |||
934 | goto out; | 956 | goto out; |
935 | } | 957 | } |
936 | 958 | ||
959 | res = ERR_PTR(-ENOMEM); | ||
960 | fhandle = nfs_alloc_fhandle(); | ||
961 | fattr = nfs_alloc_fattr(); | ||
962 | if (fhandle == NULL || fattr == NULL) | ||
963 | goto out; | ||
964 | |||
937 | parent = dentry->d_parent; | 965 | parent = dentry->d_parent; |
938 | /* Protect against concurrent sillydeletes */ | 966 | /* Protect against concurrent sillydeletes */ |
939 | nfs_block_sillyrename(parent); | 967 | nfs_block_sillyrename(parent); |
940 | error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, &fhandle, &fattr); | 968 | error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr); |
941 | if (error == -ENOENT) | 969 | if (error == -ENOENT) |
942 | goto no_entry; | 970 | goto no_entry; |
943 | if (error < 0) { | 971 | if (error < 0) { |
944 | res = ERR_PTR(error); | 972 | res = ERR_PTR(error); |
945 | goto out_unblock_sillyrename; | 973 | goto out_unblock_sillyrename; |
946 | } | 974 | } |
947 | inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr); | 975 | inode = nfs_fhget(dentry->d_sb, fhandle, fattr); |
948 | res = (struct dentry *)inode; | 976 | res = (struct dentry *)inode; |
949 | if (IS_ERR(res)) | 977 | if (IS_ERR(res)) |
950 | goto out_unblock_sillyrename; | 978 | goto out_unblock_sillyrename; |
@@ -960,6 +988,8 @@ no_entry: | |||
960 | out_unblock_sillyrename: | 988 | out_unblock_sillyrename: |
961 | nfs_unblock_sillyrename(parent); | 989 | nfs_unblock_sillyrename(parent); |
962 | out: | 990 | out: |
991 | nfs_free_fattr(fattr); | ||
992 | nfs_free_fhandle(fhandle); | ||
963 | return res; | 993 | return res; |
964 | } | 994 | } |
965 | 995 | ||
@@ -1025,12 +1055,12 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry | |||
1025 | res = NULL; | 1055 | res = NULL; |
1026 | goto out; | 1056 | goto out; |
1027 | /* This turned out not to be a regular file */ | 1057 | /* This turned out not to be a regular file */ |
1058 | case -EISDIR: | ||
1028 | case -ENOTDIR: | 1059 | case -ENOTDIR: |
1029 | goto no_open; | 1060 | goto no_open; |
1030 | case -ELOOP: | 1061 | case -ELOOP: |
1031 | if (!(nd->intent.open.flags & O_NOFOLLOW)) | 1062 | if (!(nd->intent.open.flags & O_NOFOLLOW)) |
1032 | goto no_open; | 1063 | goto no_open; |
1033 | /* case -EISDIR: */ | ||
1034 | /* case -EINVAL: */ | 1064 | /* case -EINVAL: */ |
1035 | default: | 1065 | default: |
1036 | goto out; | 1066 | goto out; |
@@ -1050,7 +1080,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1050 | struct inode *dir; | 1080 | struct inode *dir; |
1051 | int openflags, ret = 0; | 1081 | int openflags, ret = 0; |
1052 | 1082 | ||
1053 | if (!is_atomic_open(nd)) | 1083 | if (!is_atomic_open(nd) || d_mountpoint(dentry)) |
1054 | goto no_open; | 1084 | goto no_open; |
1055 | parent = dget_parent(dentry); | 1085 | parent = dget_parent(dentry); |
1056 | dir = parent->d_inode; | 1086 | dir = parent->d_inode; |
@@ -1667,28 +1697,33 @@ static void nfs_access_free_entry(struct nfs_access_entry *entry) | |||
1667 | smp_mb__after_atomic_dec(); | 1697 | smp_mb__after_atomic_dec(); |
1668 | } | 1698 | } |
1669 | 1699 | ||
1700 | static void nfs_access_free_list(struct list_head *head) | ||
1701 | { | ||
1702 | struct nfs_access_entry *cache; | ||
1703 | |||
1704 | while (!list_empty(head)) { | ||
1705 | cache = list_entry(head->next, struct nfs_access_entry, lru); | ||
1706 | list_del(&cache->lru); | ||
1707 | nfs_access_free_entry(cache); | ||
1708 | } | ||
1709 | } | ||
1710 | |||
1670 | int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask) | 1711 | int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask) |
1671 | { | 1712 | { |
1672 | LIST_HEAD(head); | 1713 | LIST_HEAD(head); |
1673 | struct nfs_inode *nfsi; | 1714 | struct nfs_inode *nfsi; |
1674 | struct nfs_access_entry *cache; | 1715 | struct nfs_access_entry *cache; |
1675 | 1716 | ||
1676 | restart: | 1717 | if ((gfp_mask & GFP_KERNEL) != GFP_KERNEL) |
1718 | return (nr_to_scan == 0) ? 0 : -1; | ||
1719 | |||
1677 | spin_lock(&nfs_access_lru_lock); | 1720 | spin_lock(&nfs_access_lru_lock); |
1678 | list_for_each_entry(nfsi, &nfs_access_lru_list, access_cache_inode_lru) { | 1721 | list_for_each_entry(nfsi, &nfs_access_lru_list, access_cache_inode_lru) { |
1679 | struct rw_semaphore *s_umount; | ||
1680 | struct inode *inode; | 1722 | struct inode *inode; |
1681 | 1723 | ||
1682 | if (nr_to_scan-- == 0) | 1724 | if (nr_to_scan-- == 0) |
1683 | break; | 1725 | break; |
1684 | s_umount = &nfsi->vfs_inode.i_sb->s_umount; | 1726 | inode = &nfsi->vfs_inode; |
1685 | if (!down_read_trylock(s_umount)) | ||
1686 | continue; | ||
1687 | inode = igrab(&nfsi->vfs_inode); | ||
1688 | if (inode == NULL) { | ||
1689 | up_read(s_umount); | ||
1690 | continue; | ||
1691 | } | ||
1692 | spin_lock(&inode->i_lock); | 1727 | spin_lock(&inode->i_lock); |
1693 | if (list_empty(&nfsi->access_cache_entry_lru)) | 1728 | if (list_empty(&nfsi->access_cache_entry_lru)) |
1694 | goto remove_lru_entry; | 1729 | goto remove_lru_entry; |
@@ -1702,61 +1737,47 @@ restart: | |||
1702 | else { | 1737 | else { |
1703 | remove_lru_entry: | 1738 | remove_lru_entry: |
1704 | list_del_init(&nfsi->access_cache_inode_lru); | 1739 | list_del_init(&nfsi->access_cache_inode_lru); |
1740 | smp_mb__before_clear_bit(); | ||
1705 | clear_bit(NFS_INO_ACL_LRU_SET, &nfsi->flags); | 1741 | clear_bit(NFS_INO_ACL_LRU_SET, &nfsi->flags); |
1742 | smp_mb__after_clear_bit(); | ||
1706 | } | 1743 | } |
1707 | spin_unlock(&inode->i_lock); | ||
1708 | spin_unlock(&nfs_access_lru_lock); | ||
1709 | iput(inode); | ||
1710 | up_read(s_umount); | ||
1711 | goto restart; | ||
1712 | } | 1744 | } |
1713 | spin_unlock(&nfs_access_lru_lock); | 1745 | spin_unlock(&nfs_access_lru_lock); |
1714 | while (!list_empty(&head)) { | 1746 | nfs_access_free_list(&head); |
1715 | cache = list_entry(head.next, struct nfs_access_entry, lru); | ||
1716 | list_del(&cache->lru); | ||
1717 | nfs_access_free_entry(cache); | ||
1718 | } | ||
1719 | return (atomic_long_read(&nfs_access_nr_entries) / 100) * sysctl_vfs_cache_pressure; | 1747 | return (atomic_long_read(&nfs_access_nr_entries) / 100) * sysctl_vfs_cache_pressure; |
1720 | } | 1748 | } |
1721 | 1749 | ||
1722 | static void __nfs_access_zap_cache(struct inode *inode) | 1750 | static void __nfs_access_zap_cache(struct nfs_inode *nfsi, struct list_head *head) |
1723 | { | 1751 | { |
1724 | struct nfs_inode *nfsi = NFS_I(inode); | ||
1725 | struct rb_root *root_node = &nfsi->access_cache; | 1752 | struct rb_root *root_node = &nfsi->access_cache; |
1726 | struct rb_node *n, *dispose = NULL; | 1753 | struct rb_node *n; |
1727 | struct nfs_access_entry *entry; | 1754 | struct nfs_access_entry *entry; |
1728 | 1755 | ||
1729 | /* Unhook entries from the cache */ | 1756 | /* Unhook entries from the cache */ |
1730 | while ((n = rb_first(root_node)) != NULL) { | 1757 | while ((n = rb_first(root_node)) != NULL) { |
1731 | entry = rb_entry(n, struct nfs_access_entry, rb_node); | 1758 | entry = rb_entry(n, struct nfs_access_entry, rb_node); |
1732 | rb_erase(n, root_node); | 1759 | rb_erase(n, root_node); |
1733 | list_del(&entry->lru); | 1760 | list_move(&entry->lru, head); |
1734 | n->rb_left = dispose; | ||
1735 | dispose = n; | ||
1736 | } | 1761 | } |
1737 | nfsi->cache_validity &= ~NFS_INO_INVALID_ACCESS; | 1762 | nfsi->cache_validity &= ~NFS_INO_INVALID_ACCESS; |
1738 | spin_unlock(&inode->i_lock); | ||
1739 | |||
1740 | /* Now kill them all! */ | ||
1741 | while (dispose != NULL) { | ||
1742 | n = dispose; | ||
1743 | dispose = n->rb_left; | ||
1744 | nfs_access_free_entry(rb_entry(n, struct nfs_access_entry, rb_node)); | ||
1745 | } | ||
1746 | } | 1763 | } |
1747 | 1764 | ||
1748 | void nfs_access_zap_cache(struct inode *inode) | 1765 | void nfs_access_zap_cache(struct inode *inode) |
1749 | { | 1766 | { |
1767 | LIST_HEAD(head); | ||
1768 | |||
1769 | if (test_bit(NFS_INO_ACL_LRU_SET, &NFS_I(inode)->flags) == 0) | ||
1770 | return; | ||
1750 | /* Remove from global LRU init */ | 1771 | /* Remove from global LRU init */ |
1751 | if (test_and_clear_bit(NFS_INO_ACL_LRU_SET, &NFS_I(inode)->flags)) { | 1772 | spin_lock(&nfs_access_lru_lock); |
1752 | spin_lock(&nfs_access_lru_lock); | 1773 | if (test_and_clear_bit(NFS_INO_ACL_LRU_SET, &NFS_I(inode)->flags)) |
1753 | list_del_init(&NFS_I(inode)->access_cache_inode_lru); | 1774 | list_del_init(&NFS_I(inode)->access_cache_inode_lru); |
1754 | spin_unlock(&nfs_access_lru_lock); | ||
1755 | } | ||
1756 | 1775 | ||
1757 | spin_lock(&inode->i_lock); | 1776 | spin_lock(&inode->i_lock); |
1758 | /* This will release the spinlock */ | 1777 | __nfs_access_zap_cache(NFS_I(inode), &head); |
1759 | __nfs_access_zap_cache(inode); | 1778 | spin_unlock(&inode->i_lock); |
1779 | spin_unlock(&nfs_access_lru_lock); | ||
1780 | nfs_access_free_list(&head); | ||
1760 | } | 1781 | } |
1761 | 1782 | ||
1762 | static struct nfs_access_entry *nfs_access_search_rbtree(struct inode *inode, struct rpc_cred *cred) | 1783 | static struct nfs_access_entry *nfs_access_search_rbtree(struct inode *inode, struct rpc_cred *cred) |
@@ -1789,7 +1810,7 @@ static int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, str | |||
1789 | cache = nfs_access_search_rbtree(inode, cred); | 1810 | cache = nfs_access_search_rbtree(inode, cred); |
1790 | if (cache == NULL) | 1811 | if (cache == NULL) |
1791 | goto out; | 1812 | goto out; |
1792 | if (!nfs_have_delegation(inode, FMODE_READ) && | 1813 | if (!nfs_have_delegated_attributes(inode) && |
1793 | !time_in_range_open(jiffies, cache->jiffies, cache->jiffies + nfsi->attrtimeo)) | 1814 | !time_in_range_open(jiffies, cache->jiffies, cache->jiffies + nfsi->attrtimeo)) |
1794 | goto out_stale; | 1815 | goto out_stale; |
1795 | res->jiffies = cache->jiffies; | 1816 | res->jiffies = cache->jiffies; |
@@ -1807,8 +1828,8 @@ out_stale: | |||
1807 | nfs_access_free_entry(cache); | 1828 | nfs_access_free_entry(cache); |
1808 | return -ENOENT; | 1829 | return -ENOENT; |
1809 | out_zap: | 1830 | out_zap: |
1810 | /* This will release the spinlock */ | 1831 | spin_unlock(&inode->i_lock); |
1811 | __nfs_access_zap_cache(inode); | 1832 | nfs_access_zap_cache(inode); |
1812 | return -ENOENT; | 1833 | return -ENOENT; |
1813 | } | 1834 | } |
1814 | 1835 | ||
@@ -1863,9 +1884,11 @@ static void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *s | |||
1863 | smp_mb__after_atomic_inc(); | 1884 | smp_mb__after_atomic_inc(); |
1864 | 1885 | ||
1865 | /* Add inode to global LRU list */ | 1886 | /* Add inode to global LRU list */ |
1866 | if (!test_and_set_bit(NFS_INO_ACL_LRU_SET, &NFS_I(inode)->flags)) { | 1887 | if (!test_bit(NFS_INO_ACL_LRU_SET, &NFS_I(inode)->flags)) { |
1867 | spin_lock(&nfs_access_lru_lock); | 1888 | spin_lock(&nfs_access_lru_lock); |
1868 | list_add_tail(&NFS_I(inode)->access_cache_inode_lru, &nfs_access_lru_list); | 1889 | if (!test_and_set_bit(NFS_INO_ACL_LRU_SET, &NFS_I(inode)->flags)) |
1890 | list_add_tail(&NFS_I(inode)->access_cache_inode_lru, | ||
1891 | &nfs_access_lru_list); | ||
1869 | spin_unlock(&nfs_access_lru_lock); | 1892 | spin_unlock(&nfs_access_lru_lock); |
1870 | } | 1893 | } |
1871 | } | 1894 | } |
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 0d289823e856..ad4cd31d6050 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/file.h> | 44 | #include <linux/file.h> |
45 | #include <linux/pagemap.h> | 45 | #include <linux/pagemap.h> |
46 | #include <linux/kref.h> | 46 | #include <linux/kref.h> |
47 | #include <linux/slab.h> | ||
47 | 48 | ||
48 | #include <linux/nfs_fs.h> | 49 | #include <linux/nfs_fs.h> |
49 | #include <linux/nfs_page.h> | 50 | #include <linux/nfs_page.h> |
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c index 3f0cd4dfddaf..76fd235d0024 100644 --- a/fs/nfs/dns_resolve.c +++ b/fs/nfs/dns_resolve.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/hash.h> | 9 | #include <linux/hash.h> |
10 | #include <linux/string.h> | 10 | #include <linux/string.h> |
11 | #include <linux/kmod.h> | 11 | #include <linux/kmod.h> |
12 | #include <linux/slab.h> | ||
12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
13 | #include <linux/socket.h> | 14 | #include <linux/socket.h> |
14 | #include <linux/seq_file.h> | 15 | #include <linux/seq_file.h> |
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index ae8d02294e46..cac96bcc91e4 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
@@ -24,9 +24,9 @@ | |||
24 | #include <linux/nfs_fs.h> | 24 | #include <linux/nfs_fs.h> |
25 | #include <linux/nfs_mount.h> | 25 | #include <linux/nfs_mount.h> |
26 | #include <linux/mm.h> | 26 | #include <linux/mm.h> |
27 | #include <linux/slab.h> | ||
28 | #include <linux/pagemap.h> | 27 | #include <linux/pagemap.h> |
29 | #include <linux/aio.h> | 28 | #include <linux/aio.h> |
29 | #include <linux/gfp.h> | ||
30 | 30 | ||
31 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
32 | #include <asm/system.h> | 32 | #include <asm/system.h> |
@@ -161,14 +161,17 @@ static int nfs_revalidate_file_size(struct inode *inode, struct file *filp) | |||
161 | struct nfs_server *server = NFS_SERVER(inode); | 161 | struct nfs_server *server = NFS_SERVER(inode); |
162 | struct nfs_inode *nfsi = NFS_I(inode); | 162 | struct nfs_inode *nfsi = NFS_I(inode); |
163 | 163 | ||
164 | if (server->flags & NFS_MOUNT_NOAC) | 164 | if (nfs_have_delegated_attributes(inode)) |
165 | goto force_reval; | 165 | goto out_noreval; |
166 | |||
166 | if (filp->f_flags & O_DIRECT) | 167 | if (filp->f_flags & O_DIRECT) |
167 | goto force_reval; | 168 | goto force_reval; |
168 | if (nfsi->npages != 0) | 169 | if (nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) |
169 | return 0; | 170 | goto force_reval; |
170 | if (!(nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) && !nfs_attribute_timeout(inode)) | 171 | if (nfs_attribute_timeout(inode)) |
171 | return 0; | 172 | goto force_reval; |
173 | out_noreval: | ||
174 | return 0; | ||
172 | force_reval: | 175 | force_reval: |
173 | return __nfs_revalidate_inode(server, inode); | 176 | return __nfs_revalidate_inode(server, inode); |
174 | } | 177 | } |
@@ -491,7 +494,8 @@ static int nfs_release_page(struct page *page, gfp_t gfp) | |||
491 | { | 494 | { |
492 | dfprintk(PAGECACHE, "NFS: release_page(%p)\n", page); | 495 | dfprintk(PAGECACHE, "NFS: release_page(%p)\n", page); |
493 | 496 | ||
494 | if (gfp & __GFP_WAIT) | 497 | /* Only do I/O if gfp is a superset of GFP_KERNEL */ |
498 | if ((gfp & GFP_KERNEL) == GFP_KERNEL) | ||
495 | nfs_wb_page(page->mapping->host, page); | 499 | nfs_wb_page(page->mapping->host, page); |
496 | /* If PagePrivate() is set, then the page is not freeable */ | 500 | /* If PagePrivate() is set, then the page is not freeable */ |
497 | if (PagePrivate(page)) | 501 | if (PagePrivate(page)) |
diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c index 237874f1af23..ce153a6b3aec 100644 --- a/fs/nfs/fscache.c +++ b/fs/nfs/fscache.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/nfs_fs_sb.h> | 17 | #include <linux/nfs_fs_sb.h> |
18 | #include <linux/in6.h> | 18 | #include <linux/in6.h> |
19 | #include <linux/seq_file.h> | 19 | #include <linux/seq_file.h> |
20 | #include <linux/slab.h> | ||
20 | 21 | ||
21 | #include "internal.h" | 22 | #include "internal.h" |
22 | #include "iostat.h" | 23 | #include "iostat.h" |
@@ -466,7 +467,8 @@ int __nfs_readpages_from_fscache(struct nfs_open_context *ctx, | |||
466 | struct list_head *pages, | 467 | struct list_head *pages, |
467 | unsigned *nr_pages) | 468 | unsigned *nr_pages) |
468 | { | 469 | { |
469 | int ret, npages = *nr_pages; | 470 | unsigned npages = *nr_pages; |
471 | int ret; | ||
470 | 472 | ||
471 | dfprintk(FSCACHE, "NFS: nfs_getpages_from_fscache (0x%p/%u/0x%p)\n", | 473 | dfprintk(FSCACHE, "NFS: nfs_getpages_from_fscache (0x%p/%u/0x%p)\n", |
472 | NFS_I(inode)->fscache, npages, inode); | 474 | NFS_I(inode)->fscache, npages, inode); |
diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c index b35d2a616066..7428f7d6273b 100644 --- a/fs/nfs/getroot.c +++ b/fs/nfs/getroot.c | |||
@@ -78,159 +78,94 @@ struct dentry *nfs_get_root(struct super_block *sb, struct nfs_fh *mntfh) | |||
78 | { | 78 | { |
79 | struct nfs_server *server = NFS_SB(sb); | 79 | struct nfs_server *server = NFS_SB(sb); |
80 | struct nfs_fsinfo fsinfo; | 80 | struct nfs_fsinfo fsinfo; |
81 | struct nfs_fattr fattr; | 81 | struct dentry *ret; |
82 | struct dentry *mntroot; | ||
83 | struct inode *inode; | 82 | struct inode *inode; |
84 | int error; | 83 | int error; |
85 | 84 | ||
86 | /* get the actual root for this mount */ | 85 | /* get the actual root for this mount */ |
87 | fsinfo.fattr = &fattr; | 86 | fsinfo.fattr = nfs_alloc_fattr(); |
87 | if (fsinfo.fattr == NULL) | ||
88 | return ERR_PTR(-ENOMEM); | ||
88 | 89 | ||
89 | error = server->nfs_client->rpc_ops->getroot(server, mntfh, &fsinfo); | 90 | error = server->nfs_client->rpc_ops->getroot(server, mntfh, &fsinfo); |
90 | if (error < 0) { | 91 | if (error < 0) { |
91 | dprintk("nfs_get_root: getattr error = %d\n", -error); | 92 | dprintk("nfs_get_root: getattr error = %d\n", -error); |
92 | return ERR_PTR(error); | 93 | ret = ERR_PTR(error); |
94 | goto out; | ||
93 | } | 95 | } |
94 | 96 | ||
95 | inode = nfs_fhget(sb, mntfh, fsinfo.fattr); | 97 | inode = nfs_fhget(sb, mntfh, fsinfo.fattr); |
96 | if (IS_ERR(inode)) { | 98 | if (IS_ERR(inode)) { |
97 | dprintk("nfs_get_root: get root inode failed\n"); | 99 | dprintk("nfs_get_root: get root inode failed\n"); |
98 | return ERR_CAST(inode); | 100 | ret = ERR_CAST(inode); |
101 | goto out; | ||
99 | } | 102 | } |
100 | 103 | ||
101 | error = nfs_superblock_set_dummy_root(sb, inode); | 104 | error = nfs_superblock_set_dummy_root(sb, inode); |
102 | if (error != 0) | 105 | if (error != 0) { |
103 | return ERR_PTR(error); | 106 | ret = ERR_PTR(error); |
107 | goto out; | ||
108 | } | ||
104 | 109 | ||
105 | /* root dentries normally start off anonymous and get spliced in later | 110 | /* root dentries normally start off anonymous and get spliced in later |
106 | * if the dentry tree reaches them; however if the dentry already | 111 | * if the dentry tree reaches them; however if the dentry already |
107 | * exists, we'll pick it up at this point and use it as the root | 112 | * exists, we'll pick it up at this point and use it as the root |
108 | */ | 113 | */ |
109 | mntroot = d_obtain_alias(inode); | 114 | ret = d_obtain_alias(inode); |
110 | if (IS_ERR(mntroot)) { | 115 | if (IS_ERR(ret)) { |
111 | dprintk("nfs_get_root: get root dentry failed\n"); | 116 | dprintk("nfs_get_root: get root dentry failed\n"); |
112 | return mntroot; | 117 | goto out; |
113 | } | 118 | } |
114 | 119 | ||
115 | security_d_instantiate(mntroot, inode); | 120 | security_d_instantiate(ret, inode); |
116 | |||
117 | if (!mntroot->d_op) | ||
118 | mntroot->d_op = server->nfs_client->rpc_ops->dentry_ops; | ||
119 | 121 | ||
120 | return mntroot; | 122 | if (ret->d_op == NULL) |
123 | ret->d_op = server->nfs_client->rpc_ops->dentry_ops; | ||
124 | out: | ||
125 | nfs_free_fattr(fsinfo.fattr); | ||
126 | return ret; | ||
121 | } | 127 | } |
122 | 128 | ||
123 | #ifdef CONFIG_NFS_V4 | 129 | #ifdef CONFIG_NFS_V4 |
124 | 130 | ||
125 | /* | 131 | int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh) |
126 | * Do a simple pathwalk from the root FH of the server to the nominated target | ||
127 | * of the mountpoint | ||
128 | * - give error on symlinks | ||
129 | * - give error on ".." occurring in the path | ||
130 | * - follow traversals | ||
131 | */ | ||
132 | int nfs4_path_walk(struct nfs_server *server, | ||
133 | struct nfs_fh *mntfh, | ||
134 | const char *path) | ||
135 | { | 132 | { |
136 | struct nfs_fsinfo fsinfo; | 133 | struct nfs_fsinfo fsinfo; |
137 | struct nfs_fattr fattr; | 134 | int ret = -ENOMEM; |
138 | struct nfs_fh lastfh; | ||
139 | struct qstr name; | ||
140 | int ret; | ||
141 | 135 | ||
142 | dprintk("--> nfs4_path_walk(,,%s)\n", path); | 136 | dprintk("--> nfs4_get_rootfh()\n"); |
143 | 137 | ||
144 | fsinfo.fattr = &fattr; | 138 | fsinfo.fattr = nfs_alloc_fattr(); |
145 | nfs_fattr_init(&fattr); | 139 | if (fsinfo.fattr == NULL) |
146 | 140 | goto out; | |
147 | /* Eat leading slashes */ | ||
148 | while (*path == '/') | ||
149 | path++; | ||
150 | 141 | ||
151 | /* Start by getting the root filehandle from the server */ | 142 | /* Start by getting the root filehandle from the server */ |
152 | ret = server->nfs_client->rpc_ops->getroot(server, mntfh, &fsinfo); | 143 | ret = server->nfs_client->rpc_ops->getroot(server, mntfh, &fsinfo); |
153 | if (ret < 0) { | 144 | if (ret < 0) { |
154 | dprintk("nfs4_get_root: getroot error = %d\n", -ret); | 145 | dprintk("nfs4_get_rootfh: getroot error = %d\n", -ret); |
155 | return ret; | 146 | goto out; |
156 | } | 147 | } |
157 | 148 | ||
158 | if (!S_ISDIR(fattr.mode)) { | 149 | if (!(fsinfo.fattr->valid & NFS_ATTR_FATTR_MODE) |
159 | printk(KERN_ERR "nfs4_get_root:" | 150 | || !S_ISDIR(fsinfo.fattr->mode)) { |
151 | printk(KERN_ERR "nfs4_get_rootfh:" | ||
160 | " getroot encountered non-directory\n"); | 152 | " getroot encountered non-directory\n"); |
161 | return -ENOTDIR; | 153 | ret = -ENOTDIR; |
154 | goto out; | ||
162 | } | 155 | } |
163 | 156 | ||
164 | /* FIXME: It is quite valid for the server to return a referral here */ | 157 | if (fsinfo.fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) { |
165 | if (fattr.valid & NFS_ATTR_FATTR_V4_REFERRAL) { | 158 | printk(KERN_ERR "nfs4_get_rootfh:" |
166 | printk(KERN_ERR "nfs4_get_root:" | ||
167 | " getroot obtained referral\n"); | 159 | " getroot obtained referral\n"); |
168 | return -EREMOTE; | 160 | ret = -EREMOTE; |
169 | } | 161 | goto out; |
170 | |||
171 | next_component: | ||
172 | dprintk("Next: %s\n", path); | ||
173 | |||
174 | /* extract the next bit of the path */ | ||
175 | if (!*path) | ||
176 | goto path_walk_complete; | ||
177 | |||
178 | name.name = path; | ||
179 | while (*path && *path != '/') | ||
180 | path++; | ||
181 | name.len = path - (const char *) name.name; | ||
182 | |||
183 | if (name.len > NFS4_MAXNAMLEN) | ||
184 | return -ENAMETOOLONG; | ||
185 | |||
186 | eat_dot_dir: | ||
187 | while (*path == '/') | ||
188 | path++; | ||
189 | |||
190 | if (path[0] == '.' && (path[1] == '/' || !path[1])) { | ||
191 | path += 2; | ||
192 | goto eat_dot_dir; | ||
193 | } | ||
194 | |||
195 | /* FIXME: Why shouldn't the user be able to use ".." in the path? */ | ||
196 | if (path[0] == '.' && path[1] == '.' && (path[2] == '/' || !path[2]) | ||
197 | ) { | ||
198 | printk(KERN_ERR "nfs4_get_root:" | ||
199 | " Mount path contains reference to \"..\"\n"); | ||
200 | return -EINVAL; | ||
201 | } | 162 | } |
202 | 163 | ||
203 | /* lookup the next FH in the sequence */ | 164 | memcpy(&server->fsid, &fsinfo.fattr->fsid, sizeof(server->fsid)); |
204 | memcpy(&lastfh, mntfh, sizeof(lastfh)); | 165 | out: |
205 | 166 | nfs_free_fattr(fsinfo.fattr); | |
206 | dprintk("LookupFH: %*.*s [%s]\n", name.len, name.len, name.name, path); | 167 | dprintk("<-- nfs4_get_rootfh() = %d\n", ret); |
207 | 168 | return ret; | |
208 | ret = server->nfs_client->rpc_ops->lookupfh(server, &lastfh, &name, | ||
209 | mntfh, &fattr); | ||
210 | if (ret < 0) { | ||
211 | dprintk("nfs4_get_root: getroot error = %d\n", -ret); | ||
212 | return ret; | ||
213 | } | ||
214 | |||
215 | if (!S_ISDIR(fattr.mode)) { | ||
216 | printk(KERN_ERR "nfs4_get_root:" | ||
217 | " lookupfh encountered non-directory\n"); | ||
218 | return -ENOTDIR; | ||
219 | } | ||
220 | |||
221 | /* FIXME: Referrals are quite valid here too */ | ||
222 | if (fattr.valid & NFS_ATTR_FATTR_V4_REFERRAL) { | ||
223 | printk(KERN_ERR "nfs4_get_root:" | ||
224 | " lookupfh obtained referral\n"); | ||
225 | return -EREMOTE; | ||
226 | } | ||
227 | |||
228 | goto next_component; | ||
229 | |||
230 | path_walk_complete: | ||
231 | memcpy(&server->fsid, &fattr.fsid, sizeof(server->fsid)); | ||
232 | dprintk("<-- nfs4_path_walk() = 0\n"); | ||
233 | return 0; | ||
234 | } | 169 | } |
235 | 170 | ||
236 | /* | 171 | /* |
@@ -239,8 +174,8 @@ path_walk_complete: | |||
239 | struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh) | 174 | struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh) |
240 | { | 175 | { |
241 | struct nfs_server *server = NFS_SB(sb); | 176 | struct nfs_server *server = NFS_SB(sb); |
242 | struct nfs_fattr fattr; | 177 | struct nfs_fattr *fattr = NULL; |
243 | struct dentry *mntroot; | 178 | struct dentry *ret; |
244 | struct inode *inode; | 179 | struct inode *inode; |
245 | int error; | 180 | int error; |
246 | 181 | ||
@@ -254,40 +189,50 @@ struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh) | |||
254 | return ERR_PTR(error); | 189 | return ERR_PTR(error); |
255 | } | 190 | } |
256 | 191 | ||
192 | fattr = nfs_alloc_fattr(); | ||
193 | if (fattr == NULL) | ||
194 | return ERR_PTR(-ENOMEM);; | ||
195 | |||
257 | /* get the actual root for this mount */ | 196 | /* get the actual root for this mount */ |
258 | error = server->nfs_client->rpc_ops->getattr(server, mntfh, &fattr); | 197 | error = server->nfs_client->rpc_ops->getattr(server, mntfh, fattr); |
259 | if (error < 0) { | 198 | if (error < 0) { |
260 | dprintk("nfs_get_root: getattr error = %d\n", -error); | 199 | dprintk("nfs_get_root: getattr error = %d\n", -error); |
261 | return ERR_PTR(error); | 200 | ret = ERR_PTR(error); |
201 | goto out; | ||
262 | } | 202 | } |
263 | 203 | ||
264 | inode = nfs_fhget(sb, mntfh, &fattr); | 204 | inode = nfs_fhget(sb, mntfh, fattr); |
265 | if (IS_ERR(inode)) { | 205 | if (IS_ERR(inode)) { |
266 | dprintk("nfs_get_root: get root inode failed\n"); | 206 | dprintk("nfs_get_root: get root inode failed\n"); |
267 | return ERR_CAST(inode); | 207 | ret = ERR_CAST(inode); |
208 | goto out; | ||
268 | } | 209 | } |
269 | 210 | ||
270 | error = nfs_superblock_set_dummy_root(sb, inode); | 211 | error = nfs_superblock_set_dummy_root(sb, inode); |
271 | if (error != 0) | 212 | if (error != 0) { |
272 | return ERR_PTR(error); | 213 | ret = ERR_PTR(error); |
214 | goto out; | ||
215 | } | ||
273 | 216 | ||
274 | /* root dentries normally start off anonymous and get spliced in later | 217 | /* root dentries normally start off anonymous and get spliced in later |
275 | * if the dentry tree reaches them; however if the dentry already | 218 | * if the dentry tree reaches them; however if the dentry already |
276 | * exists, we'll pick it up at this point and use it as the root | 219 | * exists, we'll pick it up at this point and use it as the root |
277 | */ | 220 | */ |
278 | mntroot = d_obtain_alias(inode); | 221 | ret = d_obtain_alias(inode); |
279 | if (IS_ERR(mntroot)) { | 222 | if (IS_ERR(ret)) { |
280 | dprintk("nfs_get_root: get root dentry failed\n"); | 223 | dprintk("nfs_get_root: get root dentry failed\n"); |
281 | return mntroot; | 224 | goto out; |
282 | } | 225 | } |
283 | 226 | ||
284 | security_d_instantiate(mntroot, inode); | 227 | security_d_instantiate(ret, inode); |
285 | 228 | ||
286 | if (!mntroot->d_op) | 229 | if (ret->d_op == NULL) |
287 | mntroot->d_op = server->nfs_client->rpc_ops->dentry_ops; | 230 | ret->d_op = server->nfs_client->rpc_ops->dentry_ops; |
288 | 231 | ||
232 | out: | ||
233 | nfs_free_fattr(fattr); | ||
289 | dprintk("<-- nfs4_get_root()\n"); | 234 | dprintk("<-- nfs4_get_root()\n"); |
290 | return mntroot; | 235 | return ret; |
291 | } | 236 | } |
292 | 237 | ||
293 | #endif /* CONFIG_NFS_V4 */ | 238 | #endif /* CONFIG_NFS_V4 */ |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 657201acda84..099b3518feea 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/vfs.h> | 36 | #include <linux/vfs.h> |
37 | #include <linux/inet.h> | 37 | #include <linux/inet.h> |
38 | #include <linux/nfs_xdr.h> | 38 | #include <linux/nfs_xdr.h> |
39 | #include <linux/slab.h> | ||
39 | 40 | ||
40 | #include <asm/system.h> | 41 | #include <asm/system.h> |
41 | #include <asm/uaccess.h> | 42 | #include <asm/uaccess.h> |
@@ -392,8 +393,8 @@ int | |||
392 | nfs_setattr(struct dentry *dentry, struct iattr *attr) | 393 | nfs_setattr(struct dentry *dentry, struct iattr *attr) |
393 | { | 394 | { |
394 | struct inode *inode = dentry->d_inode; | 395 | struct inode *inode = dentry->d_inode; |
395 | struct nfs_fattr fattr; | 396 | struct nfs_fattr *fattr; |
396 | int error; | 397 | int error = -ENOMEM; |
397 | 398 | ||
398 | nfs_inc_stats(inode, NFSIOS_VFSSETATTR); | 399 | nfs_inc_stats(inode, NFSIOS_VFSSETATTR); |
399 | 400 | ||
@@ -416,14 +417,20 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
416 | filemap_write_and_wait(inode->i_mapping); | 417 | filemap_write_and_wait(inode->i_mapping); |
417 | nfs_wb_all(inode); | 418 | nfs_wb_all(inode); |
418 | } | 419 | } |
420 | |||
421 | fattr = nfs_alloc_fattr(); | ||
422 | if (fattr == NULL) | ||
423 | goto out; | ||
419 | /* | 424 | /* |
420 | * Return any delegations if we're going to change ACLs | 425 | * Return any delegations if we're going to change ACLs |
421 | */ | 426 | */ |
422 | if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) | 427 | if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) |
423 | nfs_inode_return_delegation(inode); | 428 | nfs_inode_return_delegation(inode); |
424 | error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); | 429 | error = NFS_PROTO(inode)->setattr(dentry, fattr, attr); |
425 | if (error == 0) | 430 | if (error == 0) |
426 | nfs_refresh_inode(inode, &fattr); | 431 | nfs_refresh_inode(inode, fattr); |
432 | nfs_free_fattr(fattr); | ||
433 | out: | ||
427 | return error; | 434 | return error; |
428 | } | 435 | } |
429 | 436 | ||
@@ -622,10 +629,10 @@ struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_c | |||
622 | list_for_each_entry(pos, &nfsi->open_files, list) { | 629 | list_for_each_entry(pos, &nfsi->open_files, list) { |
623 | if (cred != NULL && pos->cred != cred) | 630 | if (cred != NULL && pos->cred != cred) |
624 | continue; | 631 | continue; |
625 | if ((pos->mode & mode) == mode) { | 632 | if ((pos->mode & (FMODE_READ|FMODE_WRITE)) != mode) |
626 | ctx = get_nfs_open_context(pos); | 633 | continue; |
627 | break; | 634 | ctx = get_nfs_open_context(pos); |
628 | } | 635 | break; |
629 | } | 636 | } |
630 | spin_unlock(&inode->i_lock); | 637 | spin_unlock(&inode->i_lock); |
631 | return ctx; | 638 | return ctx; |
@@ -681,7 +688,7 @@ int | |||
681 | __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | 688 | __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) |
682 | { | 689 | { |
683 | int status = -ESTALE; | 690 | int status = -ESTALE; |
684 | struct nfs_fattr fattr; | 691 | struct nfs_fattr *fattr = NULL; |
685 | struct nfs_inode *nfsi = NFS_I(inode); | 692 | struct nfs_inode *nfsi = NFS_I(inode); |
686 | 693 | ||
687 | dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", | 694 | dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", |
@@ -692,8 +699,13 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
692 | if (NFS_STALE(inode)) | 699 | if (NFS_STALE(inode)) |
693 | goto out; | 700 | goto out; |
694 | 701 | ||
702 | status = -ENOMEM; | ||
703 | fattr = nfs_alloc_fattr(); | ||
704 | if (fattr == NULL) | ||
705 | goto out; | ||
706 | |||
695 | nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); | 707 | nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); |
696 | status = NFS_PROTO(inode)->getattr(server, NFS_FH(inode), &fattr); | 708 | status = NFS_PROTO(inode)->getattr(server, NFS_FH(inode), fattr); |
697 | if (status != 0) { | 709 | if (status != 0) { |
698 | dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) getattr failed, error=%d\n", | 710 | dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) getattr failed, error=%d\n", |
699 | inode->i_sb->s_id, | 711 | inode->i_sb->s_id, |
@@ -706,7 +718,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
706 | goto out; | 718 | goto out; |
707 | } | 719 | } |
708 | 720 | ||
709 | status = nfs_refresh_inode(inode, &fattr); | 721 | status = nfs_refresh_inode(inode, fattr); |
710 | if (status) { | 722 | if (status) { |
711 | dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) refresh failed, error=%d\n", | 723 | dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) refresh failed, error=%d\n", |
712 | inode->i_sb->s_id, | 724 | inode->i_sb->s_id, |
@@ -722,6 +734,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
722 | (long long)NFS_FILEID(inode)); | 734 | (long long)NFS_FILEID(inode)); |
723 | 735 | ||
724 | out: | 736 | out: |
737 | nfs_free_fattr(fattr); | ||
725 | return status; | 738 | return status; |
726 | } | 739 | } |
727 | 740 | ||
@@ -729,11 +742,16 @@ int nfs_attribute_timeout(struct inode *inode) | |||
729 | { | 742 | { |
730 | struct nfs_inode *nfsi = NFS_I(inode); | 743 | struct nfs_inode *nfsi = NFS_I(inode); |
731 | 744 | ||
732 | if (nfs_have_delegation(inode, FMODE_READ)) | ||
733 | return 0; | ||
734 | return !time_in_range_open(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo); | 745 | return !time_in_range_open(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo); |
735 | } | 746 | } |
736 | 747 | ||
748 | static int nfs_attribute_cache_expired(struct inode *inode) | ||
749 | { | ||
750 | if (nfs_have_delegated_attributes(inode)) | ||
751 | return 0; | ||
752 | return nfs_attribute_timeout(inode); | ||
753 | } | ||
754 | |||
737 | /** | 755 | /** |
738 | * nfs_revalidate_inode - Revalidate the inode attributes | 756 | * nfs_revalidate_inode - Revalidate the inode attributes |
739 | * @server - pointer to nfs_server struct | 757 | * @server - pointer to nfs_server struct |
@@ -744,7 +762,7 @@ int nfs_attribute_timeout(struct inode *inode) | |||
744 | int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | 762 | int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) |
745 | { | 763 | { |
746 | if (!(NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATTR) | 764 | if (!(NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATTR) |
747 | && !nfs_attribute_timeout(inode)) | 765 | && !nfs_attribute_cache_expired(inode)) |
748 | return NFS_STALE(inode) ? -ESTALE : 0; | 766 | return NFS_STALE(inode) ? -ESTALE : 0; |
749 | return __nfs_revalidate_inode(server, inode); | 767 | return __nfs_revalidate_inode(server, inode); |
750 | } | 768 | } |
@@ -781,7 +799,8 @@ int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping) | |||
781 | int ret = 0; | 799 | int ret = 0; |
782 | 800 | ||
783 | if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) | 801 | if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) |
784 | || nfs_attribute_timeout(inode) || NFS_STALE(inode)) { | 802 | || nfs_attribute_cache_expired(inode) |
803 | || NFS_STALE(inode)) { | ||
785 | ret = __nfs_revalidate_inode(NFS_SERVER(inode), inode); | 804 | ret = __nfs_revalidate_inode(NFS_SERVER(inode), inode); |
786 | if (ret < 0) | 805 | if (ret < 0) |
787 | goto out; | 806 | goto out; |
@@ -915,6 +934,26 @@ void nfs_fattr_init(struct nfs_fattr *fattr) | |||
915 | fattr->gencount = nfs_inc_attr_generation_counter(); | 934 | fattr->gencount = nfs_inc_attr_generation_counter(); |
916 | } | 935 | } |
917 | 936 | ||
937 | struct nfs_fattr *nfs_alloc_fattr(void) | ||
938 | { | ||
939 | struct nfs_fattr *fattr; | ||
940 | |||
941 | fattr = kmalloc(sizeof(*fattr), GFP_NOFS); | ||
942 | if (fattr != NULL) | ||
943 | nfs_fattr_init(fattr); | ||
944 | return fattr; | ||
945 | } | ||
946 | |||
947 | struct nfs_fh *nfs_alloc_fhandle(void) | ||
948 | { | ||
949 | struct nfs_fh *fh; | ||
950 | |||
951 | fh = kmalloc(sizeof(struct nfs_fh), GFP_NOFS); | ||
952 | if (fh != NULL) | ||
953 | fh->size = 0; | ||
954 | return fh; | ||
955 | } | ||
956 | |||
918 | /** | 957 | /** |
919 | * nfs_inode_attrs_need_update - check if the inode attributes need updating | 958 | * nfs_inode_attrs_need_update - check if the inode attributes need updating |
920 | * @inode - pointer to inode | 959 | * @inode - pointer to inode |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 11f82f03c5de..d8bd619e386c 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -244,9 +244,7 @@ extern struct dentry *nfs_get_root(struct super_block *, struct nfs_fh *); | |||
244 | #ifdef CONFIG_NFS_V4 | 244 | #ifdef CONFIG_NFS_V4 |
245 | extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *); | 245 | extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *); |
246 | 246 | ||
247 | extern int nfs4_path_walk(struct nfs_server *server, | 247 | extern int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh); |
248 | struct nfs_fh *mntfh, | ||
249 | const char *path); | ||
250 | #endif | 248 | #endif |
251 | 249 | ||
252 | /* read.c */ | 250 | /* read.c */ |
diff --git a/fs/nfs/iostat.h b/fs/nfs/iostat.h index 1d8d5c813b01..c5832487c456 100644 --- a/fs/nfs/iostat.h +++ b/fs/nfs/iostat.h | |||
@@ -36,14 +36,14 @@ static inline void nfs_inc_stats(const struct inode *inode, | |||
36 | 36 | ||
37 | static inline void nfs_add_server_stats(const struct nfs_server *server, | 37 | static inline void nfs_add_server_stats(const struct nfs_server *server, |
38 | enum nfs_stat_bytecounters stat, | 38 | enum nfs_stat_bytecounters stat, |
39 | unsigned long addend) | 39 | long addend) |
40 | { | 40 | { |
41 | this_cpu_add(server->io_stats->bytes[stat], addend); | 41 | this_cpu_add(server->io_stats->bytes[stat], addend); |
42 | } | 42 | } |
43 | 43 | ||
44 | static inline void nfs_add_stats(const struct inode *inode, | 44 | static inline void nfs_add_stats(const struct inode *inode, |
45 | enum nfs_stat_bytecounters stat, | 45 | enum nfs_stat_bytecounters stat, |
46 | unsigned long addend) | 46 | long addend) |
47 | { | 47 | { |
48 | nfs_add_server_stats(NFS_SERVER(inode), stat, addend); | 48 | nfs_add_server_stats(NFS_SERVER(inode), stat, addend); |
49 | } | 49 | } |
@@ -51,7 +51,7 @@ static inline void nfs_add_stats(const struct inode *inode, | |||
51 | #ifdef CONFIG_NFS_FSCACHE | 51 | #ifdef CONFIG_NFS_FSCACHE |
52 | static inline void nfs_add_fscache_stats(struct inode *inode, | 52 | static inline void nfs_add_fscache_stats(struct inode *inode, |
53 | enum nfs_stat_fscachecounters stat, | 53 | enum nfs_stat_fscachecounters stat, |
54 | unsigned long addend) | 54 | long addend) |
55 | { | 55 | { |
56 | this_cpu_add(NFS_SERVER(inode)->io_stats->fscache[stat], addend); | 56 | this_cpu_add(NFS_SERVER(inode)->io_stats->fscache[stat], addend); |
57 | } | 57 | } |
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c index 40c766782891..db6aa3673cf3 100644 --- a/fs/nfs/namespace.c +++ b/fs/nfs/namespace.c | |||
@@ -8,6 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/dcache.h> | 10 | #include <linux/dcache.h> |
11 | #include <linux/gfp.h> | ||
11 | #include <linux/mount.h> | 12 | #include <linux/mount.h> |
12 | #include <linux/namei.h> | 13 | #include <linux/namei.h> |
13 | #include <linux/nfs_fs.h> | 14 | #include <linux/nfs_fs.h> |
@@ -104,8 +105,8 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) | |||
104 | struct vfsmount *mnt; | 105 | struct vfsmount *mnt; |
105 | struct nfs_server *server = NFS_SERVER(dentry->d_inode); | 106 | struct nfs_server *server = NFS_SERVER(dentry->d_inode); |
106 | struct dentry *parent; | 107 | struct dentry *parent; |
107 | struct nfs_fh fh; | 108 | struct nfs_fh *fh = NULL; |
108 | struct nfs_fattr fattr; | 109 | struct nfs_fattr *fattr = NULL; |
109 | int err; | 110 | int err; |
110 | 111 | ||
111 | dprintk("--> nfs_follow_mountpoint()\n"); | 112 | dprintk("--> nfs_follow_mountpoint()\n"); |
@@ -114,6 +115,12 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) | |||
114 | if (IS_ROOT(dentry)) | 115 | if (IS_ROOT(dentry)) |
115 | goto out_err; | 116 | goto out_err; |
116 | 117 | ||
118 | err = -ENOMEM; | ||
119 | fh = nfs_alloc_fhandle(); | ||
120 | fattr = nfs_alloc_fattr(); | ||
121 | if (fh == NULL || fattr == NULL) | ||
122 | goto out_err; | ||
123 | |||
117 | dprintk("%s: enter\n", __func__); | 124 | dprintk("%s: enter\n", __func__); |
118 | dput(nd->path.dentry); | 125 | dput(nd->path.dentry); |
119 | nd->path.dentry = dget(dentry); | 126 | nd->path.dentry = dget(dentry); |
@@ -122,16 +129,16 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) | |||
122 | parent = dget_parent(nd->path.dentry); | 129 | parent = dget_parent(nd->path.dentry); |
123 | err = server->nfs_client->rpc_ops->lookup(parent->d_inode, | 130 | err = server->nfs_client->rpc_ops->lookup(parent->d_inode, |
124 | &nd->path.dentry->d_name, | 131 | &nd->path.dentry->d_name, |
125 | &fh, &fattr); | 132 | fh, fattr); |
126 | dput(parent); | 133 | dput(parent); |
127 | if (err != 0) | 134 | if (err != 0) |
128 | goto out_err; | 135 | goto out_err; |
129 | 136 | ||
130 | if (fattr.valid & NFS_ATTR_FATTR_V4_REFERRAL) | 137 | if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) |
131 | mnt = nfs_do_refmount(nd->path.mnt, nd->path.dentry); | 138 | mnt = nfs_do_refmount(nd->path.mnt, nd->path.dentry); |
132 | else | 139 | else |
133 | mnt = nfs_do_submount(nd->path.mnt, nd->path.dentry, &fh, | 140 | mnt = nfs_do_submount(nd->path.mnt, nd->path.dentry, fh, |
134 | &fattr); | 141 | fattr); |
135 | err = PTR_ERR(mnt); | 142 | err = PTR_ERR(mnt); |
136 | if (IS_ERR(mnt)) | 143 | if (IS_ERR(mnt)) |
137 | goto out_err; | 144 | goto out_err; |
@@ -150,6 +157,8 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) | |||
150 | nd->path.dentry = dget(mnt->mnt_root); | 157 | nd->path.dentry = dget(mnt->mnt_root); |
151 | schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout); | 158 | schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout); |
152 | out: | 159 | out: |
160 | nfs_free_fattr(fattr); | ||
161 | nfs_free_fhandle(fh); | ||
153 | dprintk("%s: done, returned %d\n", __func__, err); | 162 | dprintk("%s: done, returned %d\n", __func__, err); |
154 | 163 | ||
155 | dprintk("<-- nfs_follow_mountpoint() = %d\n", err); | 164 | dprintk("<-- nfs_follow_mountpoint() = %d\n", err); |
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c index 7bc2da8efd4a..81cf14257916 100644 --- a/fs/nfs/nfs2xdr.c +++ b/fs/nfs/nfs2xdr.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/param.h> | 12 | #include <linux/param.h> |
13 | #include <linux/time.h> | 13 | #include <linux/time.h> |
14 | #include <linux/mm.h> | 14 | #include <linux/mm.h> |
15 | #include <linux/slab.h> | ||
16 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
17 | #include <linux/string.h> | 16 | #include <linux/string.h> |
18 | #include <linux/in.h> | 17 | #include <linux/in.h> |
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c index bac60515a4b3..9f88c5f4c7e2 100644 --- a/fs/nfs/nfs3acl.c +++ b/fs/nfs/nfs3acl.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <linux/fs.h> | 1 | #include <linux/fs.h> |
2 | #include <linux/gfp.h> | ||
2 | #include <linux/nfs.h> | 3 | #include <linux/nfs.h> |
3 | #include <linux/nfs3.h> | 4 | #include <linux/nfs3.h> |
4 | #include <linux/nfs_fs.h> | 5 | #include <linux/nfs_fs.h> |
@@ -184,7 +185,6 @@ static void nfs3_cache_acls(struct inode *inode, struct posix_acl *acl, | |||
184 | struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type) | 185 | struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type) |
185 | { | 186 | { |
186 | struct nfs_server *server = NFS_SERVER(inode); | 187 | struct nfs_server *server = NFS_SERVER(inode); |
187 | struct nfs_fattr fattr; | ||
188 | struct page *pages[NFSACL_MAXPAGES] = { }; | 188 | struct page *pages[NFSACL_MAXPAGES] = { }; |
189 | struct nfs3_getaclargs args = { | 189 | struct nfs3_getaclargs args = { |
190 | .fh = NFS_FH(inode), | 190 | .fh = NFS_FH(inode), |
@@ -192,7 +192,7 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type) | |||
192 | .pages = pages, | 192 | .pages = pages, |
193 | }; | 193 | }; |
194 | struct nfs3_getaclres res = { | 194 | struct nfs3_getaclres res = { |
195 | .fattr = &fattr, | 195 | 0 |
196 | }; | 196 | }; |
197 | struct rpc_message msg = { | 197 | struct rpc_message msg = { |
198 | .rpc_argp = &args, | 198 | .rpc_argp = &args, |
@@ -227,7 +227,10 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type) | |||
227 | 227 | ||
228 | dprintk("NFS call getacl\n"); | 228 | dprintk("NFS call getacl\n"); |
229 | msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_GETACL]; | 229 | msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_GETACL]; |
230 | nfs_fattr_init(&fattr); | 230 | res.fattr = nfs_alloc_fattr(); |
231 | if (res.fattr == NULL) | ||
232 | return ERR_PTR(-ENOMEM); | ||
233 | |||
231 | status = rpc_call_sync(server->client_acl, &msg, 0); | 234 | status = rpc_call_sync(server->client_acl, &msg, 0); |
232 | dprintk("NFS reply getacl: %d\n", status); | 235 | dprintk("NFS reply getacl: %d\n", status); |
233 | 236 | ||
@@ -237,7 +240,7 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type) | |||
237 | 240 | ||
238 | switch (status) { | 241 | switch (status) { |
239 | case 0: | 242 | case 0: |
240 | status = nfs_refresh_inode(inode, &fattr); | 243 | status = nfs_refresh_inode(inode, res.fattr); |
241 | break; | 244 | break; |
242 | case -EPFNOSUPPORT: | 245 | case -EPFNOSUPPORT: |
243 | case -EPROTONOSUPPORT: | 246 | case -EPROTONOSUPPORT: |
@@ -277,6 +280,7 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type) | |||
277 | getout: | 280 | getout: |
278 | posix_acl_release(res.acl_access); | 281 | posix_acl_release(res.acl_access); |
279 | posix_acl_release(res.acl_default); | 282 | posix_acl_release(res.acl_default); |
283 | nfs_free_fattr(res.fattr); | ||
280 | 284 | ||
281 | if (status != 0) { | 285 | if (status != 0) { |
282 | posix_acl_release(acl); | 286 | posix_acl_release(acl); |
@@ -289,7 +293,7 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, | |||
289 | struct posix_acl *dfacl) | 293 | struct posix_acl *dfacl) |
290 | { | 294 | { |
291 | struct nfs_server *server = NFS_SERVER(inode); | 295 | struct nfs_server *server = NFS_SERVER(inode); |
292 | struct nfs_fattr fattr; | 296 | struct nfs_fattr *fattr; |
293 | struct page *pages[NFSACL_MAXPAGES]; | 297 | struct page *pages[NFSACL_MAXPAGES]; |
294 | struct nfs3_setaclargs args = { | 298 | struct nfs3_setaclargs args = { |
295 | .inode = inode, | 299 | .inode = inode, |
@@ -334,8 +338,13 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, | |||
334 | } | 338 | } |
335 | 339 | ||
336 | dprintk("NFS call setacl\n"); | 340 | dprintk("NFS call setacl\n"); |
341 | status = -ENOMEM; | ||
342 | fattr = nfs_alloc_fattr(); | ||
343 | if (fattr == NULL) | ||
344 | goto out_freepages; | ||
345 | |||
337 | msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_SETACL]; | 346 | msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_SETACL]; |
338 | nfs_fattr_init(&fattr); | 347 | msg.rpc_resp = fattr; |
339 | status = rpc_call_sync(server->client_acl, &msg, 0); | 348 | status = rpc_call_sync(server->client_acl, &msg, 0); |
340 | nfs_access_zap_cache(inode); | 349 | nfs_access_zap_cache(inode); |
341 | nfs_zap_acl_cache(inode); | 350 | nfs_zap_acl_cache(inode); |
@@ -343,7 +352,7 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, | |||
343 | 352 | ||
344 | switch (status) { | 353 | switch (status) { |
345 | case 0: | 354 | case 0: |
346 | status = nfs_refresh_inode(inode, &fattr); | 355 | status = nfs_refresh_inode(inode, fattr); |
347 | nfs3_cache_acls(inode, acl, dfacl); | 356 | nfs3_cache_acls(inode, acl, dfacl); |
348 | break; | 357 | break; |
349 | case -EPFNOSUPPORT: | 358 | case -EPFNOSUPPORT: |
@@ -354,6 +363,7 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, | |||
354 | case -ENOTSUPP: | 363 | case -ENOTSUPP: |
355 | status = -EOPNOTSUPP; | 364 | status = -EOPNOTSUPP; |
356 | } | 365 | } |
366 | nfs_free_fattr(fattr); | ||
357 | out_freepages: | 367 | out_freepages: |
358 | while (args.npages != 0) { | 368 | while (args.npages != 0) { |
359 | args.npages--; | 369 | args.npages--; |
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 24992f0a29f2..fabb4f2849a1 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
11 | #include <linux/string.h> | 11 | #include <linux/string.h> |
12 | #include <linux/sunrpc/clnt.h> | 12 | #include <linux/sunrpc/clnt.h> |
13 | #include <linux/slab.h> | ||
13 | #include <linux/nfs.h> | 14 | #include <linux/nfs.h> |
14 | #include <linux/nfs3.h> | 15 | #include <linux/nfs3.h> |
15 | #include <linux/nfs_fs.h> | 16 | #include <linux/nfs_fs.h> |
@@ -143,14 +144,12 @@ static int | |||
143 | nfs3_proc_lookup(struct inode *dir, struct qstr *name, | 144 | nfs3_proc_lookup(struct inode *dir, struct qstr *name, |
144 | struct nfs_fh *fhandle, struct nfs_fattr *fattr) | 145 | struct nfs_fh *fhandle, struct nfs_fattr *fattr) |
145 | { | 146 | { |
146 | struct nfs_fattr dir_attr; | ||
147 | struct nfs3_diropargs arg = { | 147 | struct nfs3_diropargs arg = { |
148 | .fh = NFS_FH(dir), | 148 | .fh = NFS_FH(dir), |
149 | .name = name->name, | 149 | .name = name->name, |
150 | .len = name->len | 150 | .len = name->len |
151 | }; | 151 | }; |
152 | struct nfs3_diropres res = { | 152 | struct nfs3_diropres res = { |
153 | .dir_attr = &dir_attr, | ||
154 | .fh = fhandle, | 153 | .fh = fhandle, |
155 | .fattr = fattr | 154 | .fattr = fattr |
156 | }; | 155 | }; |
@@ -162,29 +161,30 @@ nfs3_proc_lookup(struct inode *dir, struct qstr *name, | |||
162 | int status; | 161 | int status; |
163 | 162 | ||
164 | dprintk("NFS call lookup %s\n", name->name); | 163 | dprintk("NFS call lookup %s\n", name->name); |
165 | nfs_fattr_init(&dir_attr); | 164 | res.dir_attr = nfs_alloc_fattr(); |
165 | if (res.dir_attr == NULL) | ||
166 | return -ENOMEM; | ||
167 | |||
166 | nfs_fattr_init(fattr); | 168 | nfs_fattr_init(fattr); |
167 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 169 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
168 | nfs_refresh_inode(dir, &dir_attr); | 170 | nfs_refresh_inode(dir, res.dir_attr); |
169 | if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR)) { | 171 | if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR)) { |
170 | msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR]; | 172 | msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR]; |
171 | msg.rpc_argp = fhandle; | 173 | msg.rpc_argp = fhandle; |
172 | msg.rpc_resp = fattr; | 174 | msg.rpc_resp = fattr; |
173 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 175 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
174 | } | 176 | } |
177 | nfs_free_fattr(res.dir_attr); | ||
175 | dprintk("NFS reply lookup: %d\n", status); | 178 | dprintk("NFS reply lookup: %d\n", status); |
176 | return status; | 179 | return status; |
177 | } | 180 | } |
178 | 181 | ||
179 | static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry) | 182 | static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry) |
180 | { | 183 | { |
181 | struct nfs_fattr fattr; | ||
182 | struct nfs3_accessargs arg = { | 184 | struct nfs3_accessargs arg = { |
183 | .fh = NFS_FH(inode), | 185 | .fh = NFS_FH(inode), |
184 | }; | 186 | }; |
185 | struct nfs3_accessres res = { | 187 | struct nfs3_accessres res; |
186 | .fattr = &fattr, | ||
187 | }; | ||
188 | struct rpc_message msg = { | 188 | struct rpc_message msg = { |
189 | .rpc_proc = &nfs3_procedures[NFS3PROC_ACCESS], | 189 | .rpc_proc = &nfs3_procedures[NFS3PROC_ACCESS], |
190 | .rpc_argp = &arg, | 190 | .rpc_argp = &arg, |
@@ -192,7 +192,7 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry) | |||
192 | .rpc_cred = entry->cred, | 192 | .rpc_cred = entry->cred, |
193 | }; | 193 | }; |
194 | int mode = entry->mask; | 194 | int mode = entry->mask; |
195 | int status; | 195 | int status = -ENOMEM; |
196 | 196 | ||
197 | dprintk("NFS call access\n"); | 197 | dprintk("NFS call access\n"); |
198 | 198 | ||
@@ -209,9 +209,13 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry) | |||
209 | if (mode & MAY_EXEC) | 209 | if (mode & MAY_EXEC) |
210 | arg.access |= NFS3_ACCESS_EXECUTE; | 210 | arg.access |= NFS3_ACCESS_EXECUTE; |
211 | } | 211 | } |
212 | nfs_fattr_init(&fattr); | 212 | |
213 | res.fattr = nfs_alloc_fattr(); | ||
214 | if (res.fattr == NULL) | ||
215 | goto out; | ||
216 | |||
213 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 217 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
214 | nfs_refresh_inode(inode, &fattr); | 218 | nfs_refresh_inode(inode, res.fattr); |
215 | if (status == 0) { | 219 | if (status == 0) { |
216 | entry->mask = 0; | 220 | entry->mask = 0; |
217 | if (res.access & NFS3_ACCESS_READ) | 221 | if (res.access & NFS3_ACCESS_READ) |
@@ -221,6 +225,8 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry) | |||
221 | if (res.access & (NFS3_ACCESS_LOOKUP|NFS3_ACCESS_EXECUTE)) | 225 | if (res.access & (NFS3_ACCESS_LOOKUP|NFS3_ACCESS_EXECUTE)) |
222 | entry->mask |= MAY_EXEC; | 226 | entry->mask |= MAY_EXEC; |
223 | } | 227 | } |
228 | nfs_free_fattr(res.fattr); | ||
229 | out: | ||
224 | dprintk("NFS reply access: %d\n", status); | 230 | dprintk("NFS reply access: %d\n", status); |
225 | return status; | 231 | return status; |
226 | } | 232 | } |
@@ -228,7 +234,7 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry) | |||
228 | static int nfs3_proc_readlink(struct inode *inode, struct page *page, | 234 | static int nfs3_proc_readlink(struct inode *inode, struct page *page, |
229 | unsigned int pgbase, unsigned int pglen) | 235 | unsigned int pgbase, unsigned int pglen) |
230 | { | 236 | { |
231 | struct nfs_fattr fattr; | 237 | struct nfs_fattr *fattr; |
232 | struct nfs3_readlinkargs args = { | 238 | struct nfs3_readlinkargs args = { |
233 | .fh = NFS_FH(inode), | 239 | .fh = NFS_FH(inode), |
234 | .pgbase = pgbase, | 240 | .pgbase = pgbase, |
@@ -238,14 +244,19 @@ static int nfs3_proc_readlink(struct inode *inode, struct page *page, | |||
238 | struct rpc_message msg = { | 244 | struct rpc_message msg = { |
239 | .rpc_proc = &nfs3_procedures[NFS3PROC_READLINK], | 245 | .rpc_proc = &nfs3_procedures[NFS3PROC_READLINK], |
240 | .rpc_argp = &args, | 246 | .rpc_argp = &args, |
241 | .rpc_resp = &fattr, | ||
242 | }; | 247 | }; |
243 | int status; | 248 | int status = -ENOMEM; |
244 | 249 | ||
245 | dprintk("NFS call readlink\n"); | 250 | dprintk("NFS call readlink\n"); |
246 | nfs_fattr_init(&fattr); | 251 | fattr = nfs_alloc_fattr(); |
252 | if (fattr == NULL) | ||
253 | goto out; | ||
254 | msg.rpc_resp = fattr; | ||
255 | |||
247 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 256 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
248 | nfs_refresh_inode(inode, &fattr); | 257 | nfs_refresh_inode(inode, fattr); |
258 | nfs_free_fattr(fattr); | ||
259 | out: | ||
249 | dprintk("NFS reply readlink: %d\n", status); | 260 | dprintk("NFS reply readlink: %d\n", status); |
250 | return status; | 261 | return status; |
251 | } | 262 | } |
@@ -395,12 +406,17 @@ nfs3_proc_remove(struct inode *dir, struct qstr *name) | |||
395 | .rpc_argp = &arg, | 406 | .rpc_argp = &arg, |
396 | .rpc_resp = &res, | 407 | .rpc_resp = &res, |
397 | }; | 408 | }; |
398 | int status; | 409 | int status = -ENOMEM; |
399 | 410 | ||
400 | dprintk("NFS call remove %s\n", name->name); | 411 | dprintk("NFS call remove %s\n", name->name); |
401 | nfs_fattr_init(&res.dir_attr); | 412 | res.dir_attr = nfs_alloc_fattr(); |
413 | if (res.dir_attr == NULL) | ||
414 | goto out; | ||
415 | |||
402 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 416 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
403 | nfs_post_op_update_inode(dir, &res.dir_attr); | 417 | nfs_post_op_update_inode(dir, res.dir_attr); |
418 | nfs_free_fattr(res.dir_attr); | ||
419 | out: | ||
404 | dprintk("NFS reply remove: %d\n", status); | 420 | dprintk("NFS reply remove: %d\n", status); |
405 | return status; | 421 | return status; |
406 | } | 422 | } |
@@ -418,7 +434,7 @@ nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir) | |||
418 | if (nfs3_async_handle_jukebox(task, dir)) | 434 | if (nfs3_async_handle_jukebox(task, dir)) |
419 | return 0; | 435 | return 0; |
420 | res = task->tk_msg.rpc_resp; | 436 | res = task->tk_msg.rpc_resp; |
421 | nfs_post_op_update_inode(dir, &res->dir_attr); | 437 | nfs_post_op_update_inode(dir, res->dir_attr); |
422 | return 1; | 438 | return 1; |
423 | } | 439 | } |
424 | 440 | ||
@@ -426,7 +442,6 @@ static int | |||
426 | nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, | 442 | nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, |
427 | struct inode *new_dir, struct qstr *new_name) | 443 | struct inode *new_dir, struct qstr *new_name) |
428 | { | 444 | { |
429 | struct nfs_fattr old_dir_attr, new_dir_attr; | ||
430 | struct nfs3_renameargs arg = { | 445 | struct nfs3_renameargs arg = { |
431 | .fromfh = NFS_FH(old_dir), | 446 | .fromfh = NFS_FH(old_dir), |
432 | .fromname = old_name->name, | 447 | .fromname = old_name->name, |
@@ -435,23 +450,27 @@ nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, | |||
435 | .toname = new_name->name, | 450 | .toname = new_name->name, |
436 | .tolen = new_name->len | 451 | .tolen = new_name->len |
437 | }; | 452 | }; |
438 | struct nfs3_renameres res = { | 453 | struct nfs3_renameres res; |
439 | .fromattr = &old_dir_attr, | ||
440 | .toattr = &new_dir_attr | ||
441 | }; | ||
442 | struct rpc_message msg = { | 454 | struct rpc_message msg = { |
443 | .rpc_proc = &nfs3_procedures[NFS3PROC_RENAME], | 455 | .rpc_proc = &nfs3_procedures[NFS3PROC_RENAME], |
444 | .rpc_argp = &arg, | 456 | .rpc_argp = &arg, |
445 | .rpc_resp = &res, | 457 | .rpc_resp = &res, |
446 | }; | 458 | }; |
447 | int status; | 459 | int status = -ENOMEM; |
448 | 460 | ||
449 | dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name); | 461 | dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name); |
450 | nfs_fattr_init(&old_dir_attr); | 462 | |
451 | nfs_fattr_init(&new_dir_attr); | 463 | res.fromattr = nfs_alloc_fattr(); |
464 | res.toattr = nfs_alloc_fattr(); | ||
465 | if (res.fromattr == NULL || res.toattr == NULL) | ||
466 | goto out; | ||
467 | |||
452 | status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0); | 468 | status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0); |
453 | nfs_post_op_update_inode(old_dir, &old_dir_attr); | 469 | nfs_post_op_update_inode(old_dir, res.fromattr); |
454 | nfs_post_op_update_inode(new_dir, &new_dir_attr); | 470 | nfs_post_op_update_inode(new_dir, res.toattr); |
471 | out: | ||
472 | nfs_free_fattr(res.toattr); | ||
473 | nfs_free_fattr(res.fromattr); | ||
455 | dprintk("NFS reply rename: %d\n", status); | 474 | dprintk("NFS reply rename: %d\n", status); |
456 | return status; | 475 | return status; |
457 | } | 476 | } |
@@ -459,30 +478,32 @@ nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, | |||
459 | static int | 478 | static int |
460 | nfs3_proc_link(struct inode *inode, struct inode *dir, struct qstr *name) | 479 | nfs3_proc_link(struct inode *inode, struct inode *dir, struct qstr *name) |
461 | { | 480 | { |
462 | struct nfs_fattr dir_attr, fattr; | ||
463 | struct nfs3_linkargs arg = { | 481 | struct nfs3_linkargs arg = { |
464 | .fromfh = NFS_FH(inode), | 482 | .fromfh = NFS_FH(inode), |
465 | .tofh = NFS_FH(dir), | 483 | .tofh = NFS_FH(dir), |
466 | .toname = name->name, | 484 | .toname = name->name, |
467 | .tolen = name->len | 485 | .tolen = name->len |
468 | }; | 486 | }; |
469 | struct nfs3_linkres res = { | 487 | struct nfs3_linkres res; |
470 | .dir_attr = &dir_attr, | ||
471 | .fattr = &fattr | ||
472 | }; | ||
473 | struct rpc_message msg = { | 488 | struct rpc_message msg = { |
474 | .rpc_proc = &nfs3_procedures[NFS3PROC_LINK], | 489 | .rpc_proc = &nfs3_procedures[NFS3PROC_LINK], |
475 | .rpc_argp = &arg, | 490 | .rpc_argp = &arg, |
476 | .rpc_resp = &res, | 491 | .rpc_resp = &res, |
477 | }; | 492 | }; |
478 | int status; | 493 | int status = -ENOMEM; |
479 | 494 | ||
480 | dprintk("NFS call link %s\n", name->name); | 495 | dprintk("NFS call link %s\n", name->name); |
481 | nfs_fattr_init(&dir_attr); | 496 | res.fattr = nfs_alloc_fattr(); |
482 | nfs_fattr_init(&fattr); | 497 | res.dir_attr = nfs_alloc_fattr(); |
498 | if (res.fattr == NULL || res.dir_attr == NULL) | ||
499 | goto out; | ||
500 | |||
483 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 501 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
484 | nfs_post_op_update_inode(dir, &dir_attr); | 502 | nfs_post_op_update_inode(dir, res.dir_attr); |
485 | nfs_post_op_update_inode(inode, &fattr); | 503 | nfs_post_op_update_inode(inode, res.fattr); |
504 | out: | ||
505 | nfs_free_fattr(res.dir_attr); | ||
506 | nfs_free_fattr(res.fattr); | ||
486 | dprintk("NFS reply link: %d\n", status); | 507 | dprintk("NFS reply link: %d\n", status); |
487 | return status; | 508 | return status; |
488 | } | 509 | } |
@@ -553,7 +574,7 @@ out: | |||
553 | static int | 574 | static int |
554 | nfs3_proc_rmdir(struct inode *dir, struct qstr *name) | 575 | nfs3_proc_rmdir(struct inode *dir, struct qstr *name) |
555 | { | 576 | { |
556 | struct nfs_fattr dir_attr; | 577 | struct nfs_fattr *dir_attr; |
557 | struct nfs3_diropargs arg = { | 578 | struct nfs3_diropargs arg = { |
558 | .fh = NFS_FH(dir), | 579 | .fh = NFS_FH(dir), |
559 | .name = name->name, | 580 | .name = name->name, |
@@ -562,14 +583,19 @@ nfs3_proc_rmdir(struct inode *dir, struct qstr *name) | |||
562 | struct rpc_message msg = { | 583 | struct rpc_message msg = { |
563 | .rpc_proc = &nfs3_procedures[NFS3PROC_RMDIR], | 584 | .rpc_proc = &nfs3_procedures[NFS3PROC_RMDIR], |
564 | .rpc_argp = &arg, | 585 | .rpc_argp = &arg, |
565 | .rpc_resp = &dir_attr, | ||
566 | }; | 586 | }; |
567 | int status; | 587 | int status = -ENOMEM; |
568 | 588 | ||
569 | dprintk("NFS call rmdir %s\n", name->name); | 589 | dprintk("NFS call rmdir %s\n", name->name); |
570 | nfs_fattr_init(&dir_attr); | 590 | dir_attr = nfs_alloc_fattr(); |
591 | if (dir_attr == NULL) | ||
592 | goto out; | ||
593 | |||
594 | msg.rpc_resp = dir_attr; | ||
571 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 595 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
572 | nfs_post_op_update_inode(dir, &dir_attr); | 596 | nfs_post_op_update_inode(dir, dir_attr); |
597 | nfs_free_fattr(dir_attr); | ||
598 | out: | ||
573 | dprintk("NFS reply rmdir: %d\n", status); | 599 | dprintk("NFS reply rmdir: %d\n", status); |
574 | return status; | 600 | return status; |
575 | } | 601 | } |
@@ -588,7 +614,6 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, | |||
588 | u64 cookie, struct page *page, unsigned int count, int plus) | 614 | u64 cookie, struct page *page, unsigned int count, int plus) |
589 | { | 615 | { |
590 | struct inode *dir = dentry->d_inode; | 616 | struct inode *dir = dentry->d_inode; |
591 | struct nfs_fattr dir_attr; | ||
592 | __be32 *verf = NFS_COOKIEVERF(dir); | 617 | __be32 *verf = NFS_COOKIEVERF(dir); |
593 | struct nfs3_readdirargs arg = { | 618 | struct nfs3_readdirargs arg = { |
594 | .fh = NFS_FH(dir), | 619 | .fh = NFS_FH(dir), |
@@ -599,7 +624,6 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, | |||
599 | .pages = &page | 624 | .pages = &page |
600 | }; | 625 | }; |
601 | struct nfs3_readdirres res = { | 626 | struct nfs3_readdirres res = { |
602 | .dir_attr = &dir_attr, | ||
603 | .verf = verf, | 627 | .verf = verf, |
604 | .plus = plus | 628 | .plus = plus |
605 | }; | 629 | }; |
@@ -609,7 +633,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, | |||
609 | .rpc_resp = &res, | 633 | .rpc_resp = &res, |
610 | .rpc_cred = cred | 634 | .rpc_cred = cred |
611 | }; | 635 | }; |
612 | int status; | 636 | int status = -ENOMEM; |
613 | 637 | ||
614 | if (plus) | 638 | if (plus) |
615 | msg.rpc_proc = &nfs3_procedures[NFS3PROC_READDIRPLUS]; | 639 | msg.rpc_proc = &nfs3_procedures[NFS3PROC_READDIRPLUS]; |
@@ -617,12 +641,17 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, | |||
617 | dprintk("NFS call readdir%s %d\n", | 641 | dprintk("NFS call readdir%s %d\n", |
618 | plus? "plus" : "", (unsigned int) cookie); | 642 | plus? "plus" : "", (unsigned int) cookie); |
619 | 643 | ||
620 | nfs_fattr_init(&dir_attr); | 644 | res.dir_attr = nfs_alloc_fattr(); |
645 | if (res.dir_attr == NULL) | ||
646 | goto out; | ||
647 | |||
621 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 648 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
622 | 649 | ||
623 | nfs_invalidate_atime(dir); | 650 | nfs_invalidate_atime(dir); |
651 | nfs_refresh_inode(dir, res.dir_attr); | ||
624 | 652 | ||
625 | nfs_refresh_inode(dir, &dir_attr); | 653 | nfs_free_fattr(res.dir_attr); |
654 | out: | ||
626 | dprintk("NFS reply readdir: %d\n", status); | 655 | dprintk("NFS reply readdir: %d\n", status); |
627 | return status; | 656 | return status; |
628 | } | 657 | } |
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c index 5fe5492fbd29..75dcfc7da365 100644 --- a/fs/nfs/nfs3xdr.c +++ b/fs/nfs/nfs3xdr.c | |||
@@ -9,7 +9,6 @@ | |||
9 | #include <linux/param.h> | 9 | #include <linux/param.h> |
10 | #include <linux/time.h> | 10 | #include <linux/time.h> |
11 | #include <linux/mm.h> | 11 | #include <linux/mm.h> |
12 | #include <linux/slab.h> | ||
13 | #include <linux/errno.h> | 12 | #include <linux/errno.h> |
14 | #include <linux/string.h> | 13 | #include <linux/string.h> |
15 | #include <linux/in.h> | 14 | #include <linux/in.h> |
@@ -763,7 +762,7 @@ nfs3_xdr_wccstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr) | |||
763 | static int | 762 | static int |
764 | nfs3_xdr_removeres(struct rpc_rqst *req, __be32 *p, struct nfs_removeres *res) | 763 | nfs3_xdr_removeres(struct rpc_rqst *req, __be32 *p, struct nfs_removeres *res) |
765 | { | 764 | { |
766 | return nfs3_xdr_wccstat(req, p, &res->dir_attr); | 765 | return nfs3_xdr_wccstat(req, p, res->dir_attr); |
767 | } | 766 | } |
768 | 767 | ||
769 | /* | 768 | /* |
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index a187200a7aac..c538c6106e16 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -206,14 +206,14 @@ extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t); | |||
206 | 206 | ||
207 | 207 | ||
208 | /* nfs4proc.c */ | 208 | /* nfs4proc.c */ |
209 | extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *); | 209 | extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *); |
210 | extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct rpc_cred *); | 210 | extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *); |
211 | extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred); | 211 | extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred); |
212 | extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *); | 212 | extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *); |
213 | extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); | 213 | extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); |
214 | extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); | 214 | extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); |
215 | extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); | 215 | extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); |
216 | extern int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait); | 216 | extern int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait); |
217 | extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); | 217 | extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); |
218 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); | 218 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); |
219 | extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); | 219 | extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); |
@@ -286,7 +286,7 @@ extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp); | |||
286 | extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); | 286 | extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); |
287 | extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t); | 287 | extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t); |
288 | 288 | ||
289 | extern struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter); | 289 | extern struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter, gfp_t gfp_mask); |
290 | extern int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task); | 290 | extern int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task); |
291 | extern void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid); | 291 | extern void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid); |
292 | extern void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid); | 292 | extern void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid); |
diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c index fa3408f20112..3c2a1724fbd2 100644 --- a/fs/nfs/nfs4namespace.c +++ b/fs/nfs/nfs4namespace.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/mount.h> | 11 | #include <linux/mount.h> |
12 | #include <linux/namei.h> | 12 | #include <linux/namei.h> |
13 | #include <linux/nfs_fs.h> | 13 | #include <linux/nfs_fs.h> |
14 | #include <linux/slab.h> | ||
14 | #include <linux/string.h> | 15 | #include <linux/string.h> |
15 | #include <linux/sunrpc/clnt.h> | 16 | #include <linux/sunrpc/clnt.h> |
16 | #include <linux/vfs.h> | 17 | #include <linux/vfs.h> |
@@ -114,6 +115,7 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata, | |||
114 | char *page, char *page2, | 115 | char *page, char *page2, |
115 | const struct nfs4_fs_location *location) | 116 | const struct nfs4_fs_location *location) |
116 | { | 117 | { |
118 | const size_t addr_bufsize = sizeof(struct sockaddr_storage); | ||
117 | struct vfsmount *mnt = ERR_PTR(-ENOENT); | 119 | struct vfsmount *mnt = ERR_PTR(-ENOENT); |
118 | char *mnt_path; | 120 | char *mnt_path; |
119 | unsigned int maxbuflen; | 121 | unsigned int maxbuflen; |
@@ -125,9 +127,12 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata, | |||
125 | mountdata->mnt_path = mnt_path; | 127 | mountdata->mnt_path = mnt_path; |
126 | maxbuflen = mnt_path - 1 - page2; | 128 | maxbuflen = mnt_path - 1 - page2; |
127 | 129 | ||
130 | mountdata->addr = kmalloc(addr_bufsize, GFP_KERNEL); | ||
131 | if (mountdata->addr == NULL) | ||
132 | return ERR_PTR(-ENOMEM); | ||
133 | |||
128 | for (s = 0; s < location->nservers; s++) { | 134 | for (s = 0; s < location->nservers; s++) { |
129 | const struct nfs4_string *buf = &location->servers[s]; | 135 | const struct nfs4_string *buf = &location->servers[s]; |
130 | struct sockaddr_storage addr; | ||
131 | 136 | ||
132 | if (buf->len <= 0 || buf->len >= maxbuflen) | 137 | if (buf->len <= 0 || buf->len >= maxbuflen) |
133 | continue; | 138 | continue; |
@@ -136,11 +141,10 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata, | |||
136 | continue; | 141 | continue; |
137 | 142 | ||
138 | mountdata->addrlen = nfs_parse_server_name(buf->data, buf->len, | 143 | mountdata->addrlen = nfs_parse_server_name(buf->data, buf->len, |
139 | (struct sockaddr *)&addr, sizeof(addr)); | 144 | mountdata->addr, addr_bufsize); |
140 | if (mountdata->addrlen == 0) | 145 | if (mountdata->addrlen == 0) |
141 | continue; | 146 | continue; |
142 | 147 | ||
143 | mountdata->addr = (struct sockaddr *)&addr; | ||
144 | rpc_set_port(mountdata->addr, NFS_PORT); | 148 | rpc_set_port(mountdata->addr, NFS_PORT); |
145 | 149 | ||
146 | memcpy(page2, buf->data, buf->len); | 150 | memcpy(page2, buf->data, buf->len); |
@@ -155,6 +159,7 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata, | |||
155 | if (!IS_ERR(mnt)) | 159 | if (!IS_ERR(mnt)) |
156 | break; | 160 | break; |
157 | } | 161 | } |
162 | kfree(mountdata->addr); | ||
158 | return mnt; | 163 | return mnt; |
159 | } | 164 | } |
160 | 165 | ||
@@ -220,8 +225,8 @@ out: | |||
220 | 225 | ||
221 | /* | 226 | /* |
222 | * nfs_do_refmount - handle crossing a referral on server | 227 | * nfs_do_refmount - handle crossing a referral on server |
228 | * @mnt_parent - mountpoint of referral | ||
223 | * @dentry - dentry of referral | 229 | * @dentry - dentry of referral |
224 | * @nd - nameidata info | ||
225 | * | 230 | * |
226 | */ | 231 | */ |
227 | struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry) | 232 | struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry) |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index eda74c42d552..70015dd60a98 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/delay.h> | 39 | #include <linux/delay.h> |
40 | #include <linux/errno.h> | 40 | #include <linux/errno.h> |
41 | #include <linux/string.h> | 41 | #include <linux/string.h> |
42 | #include <linux/slab.h> | ||
42 | #include <linux/sunrpc/clnt.h> | 43 | #include <linux/sunrpc/clnt.h> |
43 | #include <linux/nfs.h> | 44 | #include <linux/nfs.h> |
44 | #include <linux/nfs4.h> | 45 | #include <linux/nfs4.h> |
@@ -69,6 +70,9 @@ static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinf | |||
69 | static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *, struct nfs4_state *); | 70 | static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *, struct nfs4_state *); |
70 | static int _nfs4_proc_lookup(struct inode *dir, const struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr); | 71 | static int _nfs4_proc_lookup(struct inode *dir, const struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr); |
71 | static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr); | 72 | static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr); |
73 | static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, | ||
74 | struct nfs_fattr *fattr, struct iattr *sattr, | ||
75 | struct nfs4_state *state); | ||
72 | 76 | ||
73 | /* Prevent leaks of NFSv4 errors into userland */ | 77 | /* Prevent leaks of NFSv4 errors into userland */ |
74 | static int nfs4_map_errors(int err) | 78 | static int nfs4_map_errors(int err) |
@@ -713,17 +717,18 @@ static void nfs4_init_opendata_res(struct nfs4_opendata *p) | |||
713 | 717 | ||
714 | static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path, | 718 | static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path, |
715 | struct nfs4_state_owner *sp, fmode_t fmode, int flags, | 719 | struct nfs4_state_owner *sp, fmode_t fmode, int flags, |
716 | const struct iattr *attrs) | 720 | const struct iattr *attrs, |
721 | gfp_t gfp_mask) | ||
717 | { | 722 | { |
718 | struct dentry *parent = dget_parent(path->dentry); | 723 | struct dentry *parent = dget_parent(path->dentry); |
719 | struct inode *dir = parent->d_inode; | 724 | struct inode *dir = parent->d_inode; |
720 | struct nfs_server *server = NFS_SERVER(dir); | 725 | struct nfs_server *server = NFS_SERVER(dir); |
721 | struct nfs4_opendata *p; | 726 | struct nfs4_opendata *p; |
722 | 727 | ||
723 | p = kzalloc(sizeof(*p), GFP_KERNEL); | 728 | p = kzalloc(sizeof(*p), gfp_mask); |
724 | if (p == NULL) | 729 | if (p == NULL) |
725 | goto err; | 730 | goto err; |
726 | p->o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid); | 731 | p->o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid, gfp_mask); |
727 | if (p->o_arg.seqid == NULL) | 732 | if (p->o_arg.seqid == NULL) |
728 | goto err_free; | 733 | goto err_free; |
729 | path_get(path); | 734 | path_get(path); |
@@ -1059,7 +1064,7 @@ static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context | |||
1059 | { | 1064 | { |
1060 | struct nfs4_opendata *opendata; | 1065 | struct nfs4_opendata *opendata; |
1061 | 1066 | ||
1062 | opendata = nfs4_opendata_alloc(&ctx->path, state->owner, 0, 0, NULL); | 1067 | opendata = nfs4_opendata_alloc(&ctx->path, state->owner, 0, 0, NULL, GFP_NOFS); |
1063 | if (opendata == NULL) | 1068 | if (opendata == NULL) |
1064 | return ERR_PTR(-ENOMEM); | 1069 | return ERR_PTR(-ENOMEM); |
1065 | opendata->state = state; | 1070 | opendata->state = state; |
@@ -1522,6 +1527,8 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) | |||
1522 | nfs_post_op_update_inode(dir, o_res->dir_attr); | 1527 | nfs_post_op_update_inode(dir, o_res->dir_attr); |
1523 | } else | 1528 | } else |
1524 | nfs_refresh_inode(dir, o_res->dir_attr); | 1529 | nfs_refresh_inode(dir, o_res->dir_attr); |
1530 | if ((o_res->rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) == 0) | ||
1531 | server->caps &= ~NFS_CAP_POSIX_LOCK; | ||
1525 | if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { | 1532 | if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { |
1526 | status = _nfs4_proc_open_confirm(data); | 1533 | status = _nfs4_proc_open_confirm(data); |
1527 | if (status != 0) | 1534 | if (status != 0) |
@@ -1645,7 +1652,7 @@ static int _nfs4_do_open(struct inode *dir, struct path *path, fmode_t fmode, in | |||
1645 | if (path->dentry->d_inode != NULL) | 1652 | if (path->dentry->d_inode != NULL) |
1646 | nfs4_return_incompatible_delegation(path->dentry->d_inode, fmode); | 1653 | nfs4_return_incompatible_delegation(path->dentry->d_inode, fmode); |
1647 | status = -ENOMEM; | 1654 | status = -ENOMEM; |
1648 | opendata = nfs4_opendata_alloc(path, sp, fmode, flags, sattr); | 1655 | opendata = nfs4_opendata_alloc(path, sp, fmode, flags, sattr, GFP_KERNEL); |
1649 | if (opendata == NULL) | 1656 | if (opendata == NULL) |
1650 | goto err_put_state_owner; | 1657 | goto err_put_state_owner; |
1651 | 1658 | ||
@@ -1656,15 +1663,24 @@ static int _nfs4_do_open(struct inode *dir, struct path *path, fmode_t fmode, in | |||
1656 | if (status != 0) | 1663 | if (status != 0) |
1657 | goto err_opendata_put; | 1664 | goto err_opendata_put; |
1658 | 1665 | ||
1659 | if (opendata->o_arg.open_flags & O_EXCL) | ||
1660 | nfs4_exclusive_attrset(opendata, sattr); | ||
1661 | |||
1662 | state = nfs4_opendata_to_nfs4_state(opendata); | 1666 | state = nfs4_opendata_to_nfs4_state(opendata); |
1663 | status = PTR_ERR(state); | 1667 | status = PTR_ERR(state); |
1664 | if (IS_ERR(state)) | 1668 | if (IS_ERR(state)) |
1665 | goto err_opendata_put; | 1669 | goto err_opendata_put; |
1666 | if ((opendata->o_res.rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) != 0) | 1670 | if (server->caps & NFS_CAP_POSIX_LOCK) |
1667 | set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); | 1671 | set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); |
1672 | |||
1673 | if (opendata->o_arg.open_flags & O_EXCL) { | ||
1674 | nfs4_exclusive_attrset(opendata, sattr); | ||
1675 | |||
1676 | nfs_fattr_init(opendata->o_res.f_attr); | ||
1677 | status = nfs4_do_setattr(state->inode, cred, | ||
1678 | opendata->o_res.f_attr, sattr, | ||
1679 | state); | ||
1680 | if (status == 0) | ||
1681 | nfs_setattr_update_inode(state->inode, sattr); | ||
1682 | nfs_post_op_update_inode(state->inode, opendata->o_res.f_attr); | ||
1683 | } | ||
1668 | nfs4_opendata_put(opendata); | 1684 | nfs4_opendata_put(opendata); |
1669 | nfs4_put_state_owner(sp); | 1685 | nfs4_put_state_owner(sp); |
1670 | *res = state; | 1686 | *res = state; |
@@ -1911,7 +1927,7 @@ static const struct rpc_call_ops nfs4_close_ops = { | |||
1911 | * | 1927 | * |
1912 | * NOTE: Caller must be holding the sp->so_owner semaphore! | 1928 | * NOTE: Caller must be holding the sp->so_owner semaphore! |
1913 | */ | 1929 | */ |
1914 | int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait) | 1930 | int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait) |
1915 | { | 1931 | { |
1916 | struct nfs_server *server = NFS_SERVER(state->inode); | 1932 | struct nfs_server *server = NFS_SERVER(state->inode); |
1917 | struct nfs4_closedata *calldata; | 1933 | struct nfs4_closedata *calldata; |
@@ -1930,7 +1946,7 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait) | |||
1930 | }; | 1946 | }; |
1931 | int status = -ENOMEM; | 1947 | int status = -ENOMEM; |
1932 | 1948 | ||
1933 | calldata = kzalloc(sizeof(*calldata), GFP_KERNEL); | 1949 | calldata = kzalloc(sizeof(*calldata), gfp_mask); |
1934 | if (calldata == NULL) | 1950 | if (calldata == NULL) |
1935 | goto out; | 1951 | goto out; |
1936 | calldata->inode = state->inode; | 1952 | calldata->inode = state->inode; |
@@ -1938,7 +1954,7 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait) | |||
1938 | calldata->arg.fh = NFS_FH(state->inode); | 1954 | calldata->arg.fh = NFS_FH(state->inode); |
1939 | calldata->arg.stateid = &state->open_stateid; | 1955 | calldata->arg.stateid = &state->open_stateid; |
1940 | /* Serialization for the sequence id */ | 1956 | /* Serialization for the sequence id */ |
1941 | calldata->arg.seqid = nfs_alloc_seqid(&state->owner->so_seqid); | 1957 | calldata->arg.seqid = nfs_alloc_seqid(&state->owner->so_seqid, gfp_mask); |
1942 | if (calldata->arg.seqid == NULL) | 1958 | if (calldata->arg.seqid == NULL) |
1943 | goto out_free_calldata; | 1959 | goto out_free_calldata; |
1944 | calldata->arg.fmode = 0; | 1960 | calldata->arg.fmode = 0; |
@@ -2067,8 +2083,7 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st | |||
2067 | case -EDQUOT: | 2083 | case -EDQUOT: |
2068 | case -ENOSPC: | 2084 | case -ENOSPC: |
2069 | case -EROFS: | 2085 | case -EROFS: |
2070 | lookup_instantiate_filp(nd, (struct dentry *)state, NULL); | 2086 | return PTR_ERR(state); |
2071 | return 1; | ||
2072 | default: | 2087 | default: |
2073 | goto out_drop; | 2088 | goto out_drop; |
2074 | } | 2089 | } |
@@ -2402,14 +2417,12 @@ static int nfs4_proc_lookup(struct inode *dir, struct qstr *name, struct nfs_fh | |||
2402 | static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) | 2417 | static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) |
2403 | { | 2418 | { |
2404 | struct nfs_server *server = NFS_SERVER(inode); | 2419 | struct nfs_server *server = NFS_SERVER(inode); |
2405 | struct nfs_fattr fattr; | ||
2406 | struct nfs4_accessargs args = { | 2420 | struct nfs4_accessargs args = { |
2407 | .fh = NFS_FH(inode), | 2421 | .fh = NFS_FH(inode), |
2408 | .bitmask = server->attr_bitmask, | 2422 | .bitmask = server->attr_bitmask, |
2409 | }; | 2423 | }; |
2410 | struct nfs4_accessres res = { | 2424 | struct nfs4_accessres res = { |
2411 | .server = server, | 2425 | .server = server, |
2412 | .fattr = &fattr, | ||
2413 | }; | 2426 | }; |
2414 | struct rpc_message msg = { | 2427 | struct rpc_message msg = { |
2415 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_ACCESS], | 2428 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_ACCESS], |
@@ -2436,7 +2449,11 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry | |||
2436 | if (mode & MAY_EXEC) | 2449 | if (mode & MAY_EXEC) |
2437 | args.access |= NFS4_ACCESS_EXECUTE; | 2450 | args.access |= NFS4_ACCESS_EXECUTE; |
2438 | } | 2451 | } |
2439 | nfs_fattr_init(&fattr); | 2452 | |
2453 | res.fattr = nfs_alloc_fattr(); | ||
2454 | if (res.fattr == NULL) | ||
2455 | return -ENOMEM; | ||
2456 | |||
2440 | status = nfs4_call_sync(server, &msg, &args, &res, 0); | 2457 | status = nfs4_call_sync(server, &msg, &args, &res, 0); |
2441 | if (!status) { | 2458 | if (!status) { |
2442 | entry->mask = 0; | 2459 | entry->mask = 0; |
@@ -2446,8 +2463,9 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry | |||
2446 | entry->mask |= MAY_WRITE; | 2463 | entry->mask |= MAY_WRITE; |
2447 | if (res.access & (NFS4_ACCESS_LOOKUP|NFS4_ACCESS_EXECUTE)) | 2464 | if (res.access & (NFS4_ACCESS_LOOKUP|NFS4_ACCESS_EXECUTE)) |
2448 | entry->mask |= MAY_EXEC; | 2465 | entry->mask |= MAY_EXEC; |
2449 | nfs_refresh_inode(inode, &fattr); | 2466 | nfs_refresh_inode(inode, res.fattr); |
2450 | } | 2467 | } |
2468 | nfs_free_fattr(res.fattr); | ||
2451 | return status; | 2469 | return status; |
2452 | } | 2470 | } |
2453 | 2471 | ||
@@ -2560,13 +2578,6 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
2560 | } | 2578 | } |
2561 | d_add(dentry, igrab(state->inode)); | 2579 | d_add(dentry, igrab(state->inode)); |
2562 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 2580 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
2563 | if (flags & O_EXCL) { | ||
2564 | struct nfs_fattr fattr; | ||
2565 | status = nfs4_do_setattr(state->inode, cred, &fattr, sattr, state); | ||
2566 | if (status == 0) | ||
2567 | nfs_setattr_update_inode(state->inode, sattr); | ||
2568 | nfs_post_op_update_inode(state->inode, &fattr); | ||
2569 | } | ||
2570 | if (status == 0 && (nd->flags & LOOKUP_OPEN) != 0) | 2581 | if (status == 0 && (nd->flags & LOOKUP_OPEN) != 0) |
2571 | status = nfs4_intent_set_file(nd, &path, state, fmode); | 2582 | status = nfs4_intent_set_file(nd, &path, state, fmode); |
2572 | else | 2583 | else |
@@ -2594,14 +2605,19 @@ static int _nfs4_proc_remove(struct inode *dir, struct qstr *name) | |||
2594 | .rpc_argp = &args, | 2605 | .rpc_argp = &args, |
2595 | .rpc_resp = &res, | 2606 | .rpc_resp = &res, |
2596 | }; | 2607 | }; |
2597 | int status; | 2608 | int status = -ENOMEM; |
2609 | |||
2610 | res.dir_attr = nfs_alloc_fattr(); | ||
2611 | if (res.dir_attr == NULL) | ||
2612 | goto out; | ||
2598 | 2613 | ||
2599 | nfs_fattr_init(&res.dir_attr); | ||
2600 | status = nfs4_call_sync(server, &msg, &args, &res, 1); | 2614 | status = nfs4_call_sync(server, &msg, &args, &res, 1); |
2601 | if (status == 0) { | 2615 | if (status == 0) { |
2602 | update_changeattr(dir, &res.cinfo); | 2616 | update_changeattr(dir, &res.cinfo); |
2603 | nfs_post_op_update_inode(dir, &res.dir_attr); | 2617 | nfs_post_op_update_inode(dir, res.dir_attr); |
2604 | } | 2618 | } |
2619 | nfs_free_fattr(res.dir_attr); | ||
2620 | out: | ||
2605 | return status; | 2621 | return status; |
2606 | } | 2622 | } |
2607 | 2623 | ||
@@ -2636,7 +2652,7 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir) | |||
2636 | if (nfs4_async_handle_error(task, res->server, NULL) == -EAGAIN) | 2652 | if (nfs4_async_handle_error(task, res->server, NULL) == -EAGAIN) |
2637 | return 0; | 2653 | return 0; |
2638 | update_changeattr(dir, &res->cinfo); | 2654 | update_changeattr(dir, &res->cinfo); |
2639 | nfs_post_op_update_inode(dir, &res->dir_attr); | 2655 | nfs_post_op_update_inode(dir, res->dir_attr); |
2640 | return 1; | 2656 | return 1; |
2641 | } | 2657 | } |
2642 | 2658 | ||
@@ -2651,29 +2667,31 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name, | |||
2651 | .new_name = new_name, | 2667 | .new_name = new_name, |
2652 | .bitmask = server->attr_bitmask, | 2668 | .bitmask = server->attr_bitmask, |
2653 | }; | 2669 | }; |
2654 | struct nfs_fattr old_fattr, new_fattr; | ||
2655 | struct nfs4_rename_res res = { | 2670 | struct nfs4_rename_res res = { |
2656 | .server = server, | 2671 | .server = server, |
2657 | .old_fattr = &old_fattr, | ||
2658 | .new_fattr = &new_fattr, | ||
2659 | }; | 2672 | }; |
2660 | struct rpc_message msg = { | 2673 | struct rpc_message msg = { |
2661 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME], | 2674 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME], |
2662 | .rpc_argp = &arg, | 2675 | .rpc_argp = &arg, |
2663 | .rpc_resp = &res, | 2676 | .rpc_resp = &res, |
2664 | }; | 2677 | }; |
2665 | int status; | 2678 | int status = -ENOMEM; |
2666 | 2679 | ||
2667 | nfs_fattr_init(res.old_fattr); | 2680 | res.old_fattr = nfs_alloc_fattr(); |
2668 | nfs_fattr_init(res.new_fattr); | 2681 | res.new_fattr = nfs_alloc_fattr(); |
2669 | status = nfs4_call_sync(server, &msg, &arg, &res, 1); | 2682 | if (res.old_fattr == NULL || res.new_fattr == NULL) |
2683 | goto out; | ||
2670 | 2684 | ||
2685 | status = nfs4_call_sync(server, &msg, &arg, &res, 1); | ||
2671 | if (!status) { | 2686 | if (!status) { |
2672 | update_changeattr(old_dir, &res.old_cinfo); | 2687 | update_changeattr(old_dir, &res.old_cinfo); |
2673 | nfs_post_op_update_inode(old_dir, res.old_fattr); | 2688 | nfs_post_op_update_inode(old_dir, res.old_fattr); |
2674 | update_changeattr(new_dir, &res.new_cinfo); | 2689 | update_changeattr(new_dir, &res.new_cinfo); |
2675 | nfs_post_op_update_inode(new_dir, res.new_fattr); | 2690 | nfs_post_op_update_inode(new_dir, res.new_fattr); |
2676 | } | 2691 | } |
2692 | out: | ||
2693 | nfs_free_fattr(res.new_fattr); | ||
2694 | nfs_free_fattr(res.old_fattr); | ||
2677 | return status; | 2695 | return status; |
2678 | } | 2696 | } |
2679 | 2697 | ||
@@ -2700,28 +2718,30 @@ static int _nfs4_proc_link(struct inode *inode, struct inode *dir, struct qstr * | |||
2700 | .name = name, | 2718 | .name = name, |
2701 | .bitmask = server->attr_bitmask, | 2719 | .bitmask = server->attr_bitmask, |
2702 | }; | 2720 | }; |
2703 | struct nfs_fattr fattr, dir_attr; | ||
2704 | struct nfs4_link_res res = { | 2721 | struct nfs4_link_res res = { |
2705 | .server = server, | 2722 | .server = server, |
2706 | .fattr = &fattr, | ||
2707 | .dir_attr = &dir_attr, | ||
2708 | }; | 2723 | }; |
2709 | struct rpc_message msg = { | 2724 | struct rpc_message msg = { |
2710 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LINK], | 2725 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LINK], |
2711 | .rpc_argp = &arg, | 2726 | .rpc_argp = &arg, |
2712 | .rpc_resp = &res, | 2727 | .rpc_resp = &res, |
2713 | }; | 2728 | }; |
2714 | int status; | 2729 | int status = -ENOMEM; |
2730 | |||
2731 | res.fattr = nfs_alloc_fattr(); | ||
2732 | res.dir_attr = nfs_alloc_fattr(); | ||
2733 | if (res.fattr == NULL || res.dir_attr == NULL) | ||
2734 | goto out; | ||
2715 | 2735 | ||
2716 | nfs_fattr_init(res.fattr); | ||
2717 | nfs_fattr_init(res.dir_attr); | ||
2718 | status = nfs4_call_sync(server, &msg, &arg, &res, 1); | 2736 | status = nfs4_call_sync(server, &msg, &arg, &res, 1); |
2719 | if (!status) { | 2737 | if (!status) { |
2720 | update_changeattr(dir, &res.cinfo); | 2738 | update_changeattr(dir, &res.cinfo); |
2721 | nfs_post_op_update_inode(dir, res.dir_attr); | 2739 | nfs_post_op_update_inode(dir, res.dir_attr); |
2722 | nfs_post_op_update_inode(inode, res.fattr); | 2740 | nfs_post_op_update_inode(inode, res.fattr); |
2723 | } | 2741 | } |
2724 | 2742 | out: | |
2743 | nfs_free_fattr(res.dir_attr); | ||
2744 | nfs_free_fattr(res.fattr); | ||
2725 | return status; | 2745 | return status; |
2726 | } | 2746 | } |
2727 | 2747 | ||
@@ -3144,23 +3164,31 @@ static void nfs4_proc_commit_setup(struct nfs_write_data *data, struct rpc_messa | |||
3144 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMMIT]; | 3164 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMMIT]; |
3145 | } | 3165 | } |
3146 | 3166 | ||
3167 | struct nfs4_renewdata { | ||
3168 | struct nfs_client *client; | ||
3169 | unsigned long timestamp; | ||
3170 | }; | ||
3171 | |||
3147 | /* | 3172 | /* |
3148 | * nfs4_proc_async_renew(): This is not one of the nfs_rpc_ops; it is a special | 3173 | * nfs4_proc_async_renew(): This is not one of the nfs_rpc_ops; it is a special |
3149 | * standalone procedure for queueing an asynchronous RENEW. | 3174 | * standalone procedure for queueing an asynchronous RENEW. |
3150 | */ | 3175 | */ |
3151 | static void nfs4_renew_release(void *data) | 3176 | static void nfs4_renew_release(void *calldata) |
3152 | { | 3177 | { |
3153 | struct nfs_client *clp = data; | 3178 | struct nfs4_renewdata *data = calldata; |
3179 | struct nfs_client *clp = data->client; | ||
3154 | 3180 | ||
3155 | if (atomic_read(&clp->cl_count) > 1) | 3181 | if (atomic_read(&clp->cl_count) > 1) |
3156 | nfs4_schedule_state_renewal(clp); | 3182 | nfs4_schedule_state_renewal(clp); |
3157 | nfs_put_client(clp); | 3183 | nfs_put_client(clp); |
3184 | kfree(data); | ||
3158 | } | 3185 | } |
3159 | 3186 | ||
3160 | static void nfs4_renew_done(struct rpc_task *task, void *data) | 3187 | static void nfs4_renew_done(struct rpc_task *task, void *calldata) |
3161 | { | 3188 | { |
3162 | struct nfs_client *clp = data; | 3189 | struct nfs4_renewdata *data = calldata; |
3163 | unsigned long timestamp = task->tk_start; | 3190 | struct nfs_client *clp = data->client; |
3191 | unsigned long timestamp = data->timestamp; | ||
3164 | 3192 | ||
3165 | if (task->tk_status < 0) { | 3193 | if (task->tk_status < 0) { |
3166 | /* Unless we're shutting down, schedule state recovery! */ | 3194 | /* Unless we're shutting down, schedule state recovery! */ |
@@ -3186,11 +3214,17 @@ int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred) | |||
3186 | .rpc_argp = clp, | 3214 | .rpc_argp = clp, |
3187 | .rpc_cred = cred, | 3215 | .rpc_cred = cred, |
3188 | }; | 3216 | }; |
3217 | struct nfs4_renewdata *data; | ||
3189 | 3218 | ||
3190 | if (!atomic_inc_not_zero(&clp->cl_count)) | 3219 | if (!atomic_inc_not_zero(&clp->cl_count)) |
3191 | return -EIO; | 3220 | return -EIO; |
3221 | data = kmalloc(sizeof(*data), GFP_KERNEL); | ||
3222 | if (data == NULL) | ||
3223 | return -ENOMEM; | ||
3224 | data->client = clp; | ||
3225 | data->timestamp = jiffies; | ||
3192 | return rpc_call_async(clp->cl_rpcclient, &msg, RPC_TASK_SOFT, | 3226 | return rpc_call_async(clp->cl_rpcclient, &msg, RPC_TASK_SOFT, |
3193 | &nfs4_renew_ops, clp); | 3227 | &nfs4_renew_ops, data); |
3194 | } | 3228 | } |
3195 | 3229 | ||
3196 | int nfs4_proc_renew(struct nfs_client *clp, struct rpc_cred *cred) | 3230 | int nfs4_proc_renew(struct nfs_client *clp, struct rpc_cred *cred) |
@@ -3492,7 +3526,9 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server, | |||
3492 | return _nfs4_async_handle_error(task, server, server->nfs_client, state); | 3526 | return _nfs4_async_handle_error(task, server, server->nfs_client, state); |
3493 | } | 3527 | } |
3494 | 3528 | ||
3495 | int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short port, struct rpc_cred *cred) | 3529 | int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, |
3530 | unsigned short port, struct rpc_cred *cred, | ||
3531 | struct nfs4_setclientid_res *res) | ||
3496 | { | 3532 | { |
3497 | nfs4_verifier sc_verifier; | 3533 | nfs4_verifier sc_verifier; |
3498 | struct nfs4_setclientid setclientid = { | 3534 | struct nfs4_setclientid setclientid = { |
@@ -3502,7 +3538,7 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short po | |||
3502 | struct rpc_message msg = { | 3538 | struct rpc_message msg = { |
3503 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID], | 3539 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID], |
3504 | .rpc_argp = &setclientid, | 3540 | .rpc_argp = &setclientid, |
3505 | .rpc_resp = clp, | 3541 | .rpc_resp = res, |
3506 | .rpc_cred = cred, | 3542 | .rpc_cred = cred, |
3507 | }; | 3543 | }; |
3508 | __be32 *p; | 3544 | __be32 *p; |
@@ -3545,12 +3581,14 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short po | |||
3545 | return status; | 3581 | return status; |
3546 | } | 3582 | } |
3547 | 3583 | ||
3548 | static int _nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cred *cred) | 3584 | static int _nfs4_proc_setclientid_confirm(struct nfs_client *clp, |
3585 | struct nfs4_setclientid_res *arg, | ||
3586 | struct rpc_cred *cred) | ||
3549 | { | 3587 | { |
3550 | struct nfs_fsinfo fsinfo; | 3588 | struct nfs_fsinfo fsinfo; |
3551 | struct rpc_message msg = { | 3589 | struct rpc_message msg = { |
3552 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM], | 3590 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM], |
3553 | .rpc_argp = clp, | 3591 | .rpc_argp = arg, |
3554 | .rpc_resp = &fsinfo, | 3592 | .rpc_resp = &fsinfo, |
3555 | .rpc_cred = cred, | 3593 | .rpc_cred = cred, |
3556 | }; | 3594 | }; |
@@ -3568,12 +3606,14 @@ static int _nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cre | |||
3568 | return status; | 3606 | return status; |
3569 | } | 3607 | } |
3570 | 3608 | ||
3571 | int nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cred *cred) | 3609 | int nfs4_proc_setclientid_confirm(struct nfs_client *clp, |
3610 | struct nfs4_setclientid_res *arg, | ||
3611 | struct rpc_cred *cred) | ||
3572 | { | 3612 | { |
3573 | long timeout = 0; | 3613 | long timeout = 0; |
3574 | int err; | 3614 | int err; |
3575 | do { | 3615 | do { |
3576 | err = _nfs4_proc_setclientid_confirm(clp, cred); | 3616 | err = _nfs4_proc_setclientid_confirm(clp, arg, cred); |
3577 | switch (err) { | 3617 | switch (err) { |
3578 | case 0: | 3618 | case 0: |
3579 | return err; | 3619 | return err; |
@@ -3665,7 +3705,7 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co | |||
3665 | }; | 3705 | }; |
3666 | int status = 0; | 3706 | int status = 0; |
3667 | 3707 | ||
3668 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 3708 | data = kzalloc(sizeof(*data), GFP_NOFS); |
3669 | if (data == NULL) | 3709 | if (data == NULL) |
3670 | return -ENOMEM; | 3710 | return -ENOMEM; |
3671 | data->args.fhandle = &data->fh; | 3711 | data->args.fhandle = &data->fh; |
@@ -3821,7 +3861,7 @@ static struct nfs4_unlockdata *nfs4_alloc_unlockdata(struct file_lock *fl, | |||
3821 | struct nfs4_unlockdata *p; | 3861 | struct nfs4_unlockdata *p; |
3822 | struct inode *inode = lsp->ls_state->inode; | 3862 | struct inode *inode = lsp->ls_state->inode; |
3823 | 3863 | ||
3824 | p = kzalloc(sizeof(*p), GFP_KERNEL); | 3864 | p = kzalloc(sizeof(*p), GFP_NOFS); |
3825 | if (p == NULL) | 3865 | if (p == NULL) |
3826 | return NULL; | 3866 | return NULL; |
3827 | p->arg.fh = NFS_FH(inode); | 3867 | p->arg.fh = NFS_FH(inode); |
@@ -3959,7 +3999,7 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * | |||
3959 | if (test_bit(NFS_DELEGATED_STATE, &state->flags)) | 3999 | if (test_bit(NFS_DELEGATED_STATE, &state->flags)) |
3960 | goto out; | 4000 | goto out; |
3961 | lsp = request->fl_u.nfs4_fl.owner; | 4001 | lsp = request->fl_u.nfs4_fl.owner; |
3962 | seqid = nfs_alloc_seqid(&lsp->ls_seqid); | 4002 | seqid = nfs_alloc_seqid(&lsp->ls_seqid, GFP_KERNEL); |
3963 | status = -ENOMEM; | 4003 | status = -ENOMEM; |
3964 | if (seqid == NULL) | 4004 | if (seqid == NULL) |
3965 | goto out; | 4005 | goto out; |
@@ -3987,22 +4027,23 @@ struct nfs4_lockdata { | |||
3987 | }; | 4027 | }; |
3988 | 4028 | ||
3989 | static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl, | 4029 | static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl, |
3990 | struct nfs_open_context *ctx, struct nfs4_lock_state *lsp) | 4030 | struct nfs_open_context *ctx, struct nfs4_lock_state *lsp, |
4031 | gfp_t gfp_mask) | ||
3991 | { | 4032 | { |
3992 | struct nfs4_lockdata *p; | 4033 | struct nfs4_lockdata *p; |
3993 | struct inode *inode = lsp->ls_state->inode; | 4034 | struct inode *inode = lsp->ls_state->inode; |
3994 | struct nfs_server *server = NFS_SERVER(inode); | 4035 | struct nfs_server *server = NFS_SERVER(inode); |
3995 | 4036 | ||
3996 | p = kzalloc(sizeof(*p), GFP_KERNEL); | 4037 | p = kzalloc(sizeof(*p), gfp_mask); |
3997 | if (p == NULL) | 4038 | if (p == NULL) |
3998 | return NULL; | 4039 | return NULL; |
3999 | 4040 | ||
4000 | p->arg.fh = NFS_FH(inode); | 4041 | p->arg.fh = NFS_FH(inode); |
4001 | p->arg.fl = &p->fl; | 4042 | p->arg.fl = &p->fl; |
4002 | p->arg.open_seqid = nfs_alloc_seqid(&lsp->ls_state->owner->so_seqid); | 4043 | p->arg.open_seqid = nfs_alloc_seqid(&lsp->ls_state->owner->so_seqid, gfp_mask); |
4003 | if (p->arg.open_seqid == NULL) | 4044 | if (p->arg.open_seqid == NULL) |
4004 | goto out_free; | 4045 | goto out_free; |
4005 | p->arg.lock_seqid = nfs_alloc_seqid(&lsp->ls_seqid); | 4046 | p->arg.lock_seqid = nfs_alloc_seqid(&lsp->ls_seqid, gfp_mask); |
4006 | if (p->arg.lock_seqid == NULL) | 4047 | if (p->arg.lock_seqid == NULL) |
4007 | goto out_free_seqid; | 4048 | goto out_free_seqid; |
4008 | p->arg.lock_stateid = &lsp->ls_stateid; | 4049 | p->arg.lock_stateid = &lsp->ls_stateid; |
@@ -4156,7 +4197,8 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f | |||
4156 | 4197 | ||
4157 | dprintk("%s: begin!\n", __func__); | 4198 | dprintk("%s: begin!\n", __func__); |
4158 | data = nfs4_alloc_lockdata(fl, nfs_file_open_context(fl->fl_file), | 4199 | data = nfs4_alloc_lockdata(fl, nfs_file_open_context(fl->fl_file), |
4159 | fl->fl_u.nfs4_fl.owner); | 4200 | fl->fl_u.nfs4_fl.owner, |
4201 | recovery_type == NFS_LOCK_NEW ? GFP_KERNEL : GFP_NOFS); | ||
4160 | if (data == NULL) | 4202 | if (data == NULL) |
4161 | return -ENOMEM; | 4203 | return -ENOMEM; |
4162 | if (IS_SETLKW(cmd)) | 4204 | if (IS_SETLKW(cmd)) |
@@ -4645,7 +4687,7 @@ static int nfs4_reset_slot_table(struct nfs4_slot_table *tbl, u32 max_reqs, | |||
4645 | if (max_reqs != tbl->max_slots) { | 4687 | if (max_reqs != tbl->max_slots) { |
4646 | ret = -ENOMEM; | 4688 | ret = -ENOMEM; |
4647 | new = kmalloc(max_reqs * sizeof(struct nfs4_slot), | 4689 | new = kmalloc(max_reqs * sizeof(struct nfs4_slot), |
4648 | GFP_KERNEL); | 4690 | GFP_NOFS); |
4649 | if (!new) | 4691 | if (!new) |
4650 | goto out; | 4692 | goto out; |
4651 | ret = 0; | 4693 | ret = 0; |
@@ -4710,7 +4752,7 @@ static int nfs4_init_slot_table(struct nfs4_slot_table *tbl, | |||
4710 | 4752 | ||
4711 | dprintk("--> %s: max_reqs=%u\n", __func__, max_slots); | 4753 | dprintk("--> %s: max_reqs=%u\n", __func__, max_slots); |
4712 | 4754 | ||
4713 | slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_KERNEL); | 4755 | slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_NOFS); |
4714 | if (!slot) | 4756 | if (!slot) |
4715 | goto out; | 4757 | goto out; |
4716 | ret = 0; | 4758 | ret = 0; |
@@ -4759,7 +4801,7 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp) | |||
4759 | struct nfs4_session *session; | 4801 | struct nfs4_session *session; |
4760 | struct nfs4_slot_table *tbl; | 4802 | struct nfs4_slot_table *tbl; |
4761 | 4803 | ||
4762 | session = kzalloc(sizeof(struct nfs4_session), GFP_KERNEL); | 4804 | session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS); |
4763 | if (!session) | 4805 | if (!session) |
4764 | return NULL; | 4806 | return NULL; |
4765 | 4807 | ||
@@ -5103,10 +5145,11 @@ static int nfs41_proc_async_sequence(struct nfs_client *clp, | |||
5103 | 5145 | ||
5104 | if (!atomic_inc_not_zero(&clp->cl_count)) | 5146 | if (!atomic_inc_not_zero(&clp->cl_count)) |
5105 | return -EIO; | 5147 | return -EIO; |
5106 | args = kzalloc(sizeof(*args), GFP_KERNEL); | 5148 | args = kzalloc(sizeof(*args), GFP_NOFS); |
5107 | res = kzalloc(sizeof(*res), GFP_KERNEL); | 5149 | res = kzalloc(sizeof(*res), GFP_NOFS); |
5108 | if (!args || !res) { | 5150 | if (!args || !res) { |
5109 | kfree(args); | 5151 | kfree(args); |
5152 | kfree(res); | ||
5110 | nfs_put_client(clp); | 5153 | nfs_put_client(clp); |
5111 | return -ENOMEM; | 5154 | return -ENOMEM; |
5112 | } | 5155 | } |
@@ -5204,7 +5247,7 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp) | |||
5204 | int status = -ENOMEM; | 5247 | int status = -ENOMEM; |
5205 | 5248 | ||
5206 | dprintk("--> %s\n", __func__); | 5249 | dprintk("--> %s\n", __func__); |
5207 | calldata = kzalloc(sizeof(*calldata), GFP_KERNEL); | 5250 | calldata = kzalloc(sizeof(*calldata), GFP_NOFS); |
5208 | if (calldata == NULL) | 5251 | if (calldata == NULL) |
5209 | goto out; | 5252 | goto out; |
5210 | calldata->clp = clp; | 5253 | calldata->clp = clp; |
@@ -5215,9 +5258,12 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp) | |||
5215 | msg.rpc_resp = &calldata->res; | 5258 | msg.rpc_resp = &calldata->res; |
5216 | task_setup_data.callback_data = calldata; | 5259 | task_setup_data.callback_data = calldata; |
5217 | task = rpc_run_task(&task_setup_data); | 5260 | task = rpc_run_task(&task_setup_data); |
5218 | if (IS_ERR(task)) | 5261 | if (IS_ERR(task)) { |
5219 | status = PTR_ERR(task); | 5262 | status = PTR_ERR(task); |
5263 | goto out; | ||
5264 | } | ||
5220 | rpc_put_task(task); | 5265 | rpc_put_task(task); |
5266 | return 0; | ||
5221 | out: | 5267 | out: |
5222 | dprintk("<-- %s status=%d\n", __func__, status); | 5268 | dprintk("<-- %s status=%d\n", __func__, status); |
5223 | return status; | 5269 | return status; |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 6c5ed51f105e..34acf5926fdc 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -62,6 +62,7 @@ static LIST_HEAD(nfs4_clientid_list); | |||
62 | 62 | ||
63 | int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) | 63 | int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) |
64 | { | 64 | { |
65 | struct nfs4_setclientid_res clid; | ||
65 | unsigned short port; | 66 | unsigned short port; |
66 | int status; | 67 | int status; |
67 | 68 | ||
@@ -69,11 +70,15 @@ int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) | |||
69 | if (clp->cl_addr.ss_family == AF_INET6) | 70 | if (clp->cl_addr.ss_family == AF_INET6) |
70 | port = nfs_callback_tcpport6; | 71 | port = nfs_callback_tcpport6; |
71 | 72 | ||
72 | status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, port, cred); | 73 | status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, port, cred, &clid); |
73 | if (status == 0) | 74 | if (status != 0) |
74 | status = nfs4_proc_setclientid_confirm(clp, cred); | 75 | goto out; |
75 | if (status == 0) | 76 | status = nfs4_proc_setclientid_confirm(clp, &clid, cred); |
76 | nfs4_schedule_state_renewal(clp); | 77 | if (status != 0) |
78 | goto out; | ||
79 | clp->cl_clientid = clid.clientid; | ||
80 | nfs4_schedule_state_renewal(clp); | ||
81 | out: | ||
77 | return status; | 82 | return status; |
78 | } | 83 | } |
79 | 84 | ||
@@ -361,7 +366,7 @@ nfs4_alloc_state_owner(void) | |||
361 | { | 366 | { |
362 | struct nfs4_state_owner *sp; | 367 | struct nfs4_state_owner *sp; |
363 | 368 | ||
364 | sp = kzalloc(sizeof(*sp),GFP_KERNEL); | 369 | sp = kzalloc(sizeof(*sp),GFP_NOFS); |
365 | if (!sp) | 370 | if (!sp) |
366 | return NULL; | 371 | return NULL; |
367 | spin_lock_init(&sp->so_lock); | 372 | spin_lock_init(&sp->so_lock); |
@@ -435,7 +440,7 @@ nfs4_alloc_open_state(void) | |||
435 | { | 440 | { |
436 | struct nfs4_state *state; | 441 | struct nfs4_state *state; |
437 | 442 | ||
438 | state = kzalloc(sizeof(*state), GFP_KERNEL); | 443 | state = kzalloc(sizeof(*state), GFP_NOFS); |
439 | if (!state) | 444 | if (!state) |
440 | return NULL; | 445 | return NULL; |
441 | atomic_set(&state->count, 1); | 446 | atomic_set(&state->count, 1); |
@@ -537,7 +542,8 @@ void nfs4_put_open_state(struct nfs4_state *state) | |||
537 | /* | 542 | /* |
538 | * Close the current file. | 543 | * Close the current file. |
539 | */ | 544 | */ |
540 | static void __nfs4_close(struct path *path, struct nfs4_state *state, fmode_t fmode, int wait) | 545 | static void __nfs4_close(struct path *path, struct nfs4_state *state, |
546 | fmode_t fmode, gfp_t gfp_mask, int wait) | ||
541 | { | 547 | { |
542 | struct nfs4_state_owner *owner = state->owner; | 548 | struct nfs4_state_owner *owner = state->owner; |
543 | int call_close = 0; | 549 | int call_close = 0; |
@@ -578,17 +584,17 @@ static void __nfs4_close(struct path *path, struct nfs4_state *state, fmode_t fm | |||
578 | nfs4_put_open_state(state); | 584 | nfs4_put_open_state(state); |
579 | nfs4_put_state_owner(owner); | 585 | nfs4_put_state_owner(owner); |
580 | } else | 586 | } else |
581 | nfs4_do_close(path, state, wait); | 587 | nfs4_do_close(path, state, gfp_mask, wait); |
582 | } | 588 | } |
583 | 589 | ||
584 | void nfs4_close_state(struct path *path, struct nfs4_state *state, fmode_t fmode) | 590 | void nfs4_close_state(struct path *path, struct nfs4_state *state, fmode_t fmode) |
585 | { | 591 | { |
586 | __nfs4_close(path, state, fmode, 0); | 592 | __nfs4_close(path, state, fmode, GFP_NOFS, 0); |
587 | } | 593 | } |
588 | 594 | ||
589 | void nfs4_close_sync(struct path *path, struct nfs4_state *state, fmode_t fmode) | 595 | void nfs4_close_sync(struct path *path, struct nfs4_state *state, fmode_t fmode) |
590 | { | 596 | { |
591 | __nfs4_close(path, state, fmode, 1); | 597 | __nfs4_close(path, state, fmode, GFP_KERNEL, 1); |
592 | } | 598 | } |
593 | 599 | ||
594 | /* | 600 | /* |
@@ -618,7 +624,7 @@ static struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, f | |||
618 | struct nfs4_lock_state *lsp; | 624 | struct nfs4_lock_state *lsp; |
619 | struct nfs_client *clp = state->owner->so_client; | 625 | struct nfs_client *clp = state->owner->so_client; |
620 | 626 | ||
621 | lsp = kzalloc(sizeof(*lsp), GFP_KERNEL); | 627 | lsp = kzalloc(sizeof(*lsp), GFP_NOFS); |
622 | if (lsp == NULL) | 628 | if (lsp == NULL) |
623 | return NULL; | 629 | return NULL; |
624 | rpc_init_wait_queue(&lsp->ls_sequence.wait, "lock_seqid_waitqueue"); | 630 | rpc_init_wait_queue(&lsp->ls_sequence.wait, "lock_seqid_waitqueue"); |
@@ -754,11 +760,11 @@ void nfs4_copy_stateid(nfs4_stateid *dst, struct nfs4_state *state, fl_owner_t f | |||
754 | nfs4_put_lock_state(lsp); | 760 | nfs4_put_lock_state(lsp); |
755 | } | 761 | } |
756 | 762 | ||
757 | struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter) | 763 | struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter, gfp_t gfp_mask) |
758 | { | 764 | { |
759 | struct nfs_seqid *new; | 765 | struct nfs_seqid *new; |
760 | 766 | ||
761 | new = kmalloc(sizeof(*new), GFP_KERNEL); | 767 | new = kmalloc(sizeof(*new), gfp_mask); |
762 | if (new != NULL) { | 768 | if (new != NULL) { |
763 | new->sequence = counter; | 769 | new->sequence = counter; |
764 | INIT_LIST_HEAD(&new->list); | 770 | INIT_LIST_HEAD(&new->list); |
@@ -1347,7 +1353,7 @@ static int nfs4_recall_slot(struct nfs_client *clp) | |||
1347 | 1353 | ||
1348 | nfs4_begin_drain_session(clp); | 1354 | nfs4_begin_drain_session(clp); |
1349 | new = kmalloc(fc_tbl->target_max_slots * sizeof(struct nfs4_slot), | 1355 | new = kmalloc(fc_tbl->target_max_slots * sizeof(struct nfs4_slot), |
1350 | GFP_KERNEL); | 1356 | GFP_NOFS); |
1351 | if (!new) | 1357 | if (!new) |
1352 | return -ENOMEM; | 1358 | return -ENOMEM; |
1353 | 1359 | ||
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 4d338be492cb..6bdef28efa33 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/param.h> | 38 | #include <linux/param.h> |
39 | #include <linux/time.h> | 39 | #include <linux/time.h> |
40 | #include <linux/mm.h> | 40 | #include <linux/mm.h> |
41 | #include <linux/slab.h> | ||
42 | #include <linux/errno.h> | 41 | #include <linux/errno.h> |
43 | #include <linux/string.h> | 42 | #include <linux/string.h> |
44 | #include <linux/in.h> | 43 | #include <linux/in.h> |
@@ -1505,14 +1504,14 @@ static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclie | |||
1505 | hdr->replen += decode_setclientid_maxsz; | 1504 | hdr->replen += decode_setclientid_maxsz; |
1506 | } | 1505 | } |
1507 | 1506 | ||
1508 | static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs_client *client_state, struct compound_hdr *hdr) | 1507 | static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_setclientid_res *arg, struct compound_hdr *hdr) |
1509 | { | 1508 | { |
1510 | __be32 *p; | 1509 | __be32 *p; |
1511 | 1510 | ||
1512 | p = reserve_space(xdr, 12 + NFS4_VERIFIER_SIZE); | 1511 | p = reserve_space(xdr, 12 + NFS4_VERIFIER_SIZE); |
1513 | *p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM); | 1512 | *p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM); |
1514 | p = xdr_encode_hyper(p, client_state->cl_clientid); | 1513 | p = xdr_encode_hyper(p, arg->clientid); |
1515 | xdr_encode_opaque_fixed(p, client_state->cl_confirm.data, NFS4_VERIFIER_SIZE); | 1514 | xdr_encode_opaque_fixed(p, arg->confirm.data, NFS4_VERIFIER_SIZE); |
1516 | hdr->nops++; | 1515 | hdr->nops++; |
1517 | hdr->replen += decode_setclientid_confirm_maxsz; | 1516 | hdr->replen += decode_setclientid_confirm_maxsz; |
1518 | } | 1517 | } |
@@ -2325,7 +2324,7 @@ static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, __be32 *p, struct nfs4 | |||
2325 | /* | 2324 | /* |
2326 | * a SETCLIENTID_CONFIRM request | 2325 | * a SETCLIENTID_CONFIRM request |
2327 | */ | 2326 | */ |
2328 | static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_client *clp) | 2327 | static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid_res *arg) |
2329 | { | 2328 | { |
2330 | struct xdr_stream xdr; | 2329 | struct xdr_stream xdr; |
2331 | struct compound_hdr hdr = { | 2330 | struct compound_hdr hdr = { |
@@ -2335,7 +2334,7 @@ static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, str | |||
2335 | 2334 | ||
2336 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2335 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
2337 | encode_compound_hdr(&xdr, req, &hdr); | 2336 | encode_compound_hdr(&xdr, req, &hdr); |
2338 | encode_setclientid_confirm(&xdr, clp, &hdr); | 2337 | encode_setclientid_confirm(&xdr, arg, &hdr); |
2339 | encode_putrootfh(&xdr, &hdr); | 2338 | encode_putrootfh(&xdr, &hdr); |
2340 | encode_fsinfo(&xdr, lease_bitmap, &hdr); | 2339 | encode_fsinfo(&xdr, lease_bitmap, &hdr); |
2341 | encode_nops(&hdr); | 2340 | encode_nops(&hdr); |
@@ -4398,7 +4397,7 @@ out_overflow: | |||
4398 | return -EIO; | 4397 | return -EIO; |
4399 | } | 4398 | } |
4400 | 4399 | ||
4401 | static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp) | 4400 | static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_res *res) |
4402 | { | 4401 | { |
4403 | __be32 *p; | 4402 | __be32 *p; |
4404 | uint32_t opnum; | 4403 | uint32_t opnum; |
@@ -4418,8 +4417,8 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp) | |||
4418 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); | 4417 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
4419 | if (unlikely(!p)) | 4418 | if (unlikely(!p)) |
4420 | goto out_overflow; | 4419 | goto out_overflow; |
4421 | p = xdr_decode_hyper(p, &clp->cl_clientid); | 4420 | p = xdr_decode_hyper(p, &res->clientid); |
4422 | memcpy(clp->cl_confirm.data, p, NFS4_VERIFIER_SIZE); | 4421 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
4423 | } else if (nfserr == NFSERR_CLID_INUSE) { | 4422 | } else if (nfserr == NFSERR_CLID_INUSE) { |
4424 | uint32_t len; | 4423 | uint32_t len; |
4425 | 4424 | ||
@@ -4816,7 +4815,7 @@ static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs_rem | |||
4816 | goto out; | 4815 | goto out; |
4817 | if ((status = decode_remove(&xdr, &res->cinfo)) != 0) | 4816 | if ((status = decode_remove(&xdr, &res->cinfo)) != 0) |
4818 | goto out; | 4817 | goto out; |
4819 | decode_getfattr(&xdr, &res->dir_attr, res->server, | 4818 | decode_getfattr(&xdr, res->dir_attr, res->server, |
4820 | !RPC_IS_ASYNC(rqstp->rq_task)); | 4819 | !RPC_IS_ASYNC(rqstp->rq_task)); |
4821 | out: | 4820 | out: |
4822 | return status; | 4821 | return status; |
@@ -5499,7 +5498,7 @@ static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy) | |||
5499 | * Decode SETCLIENTID response | 5498 | * Decode SETCLIENTID response |
5500 | */ | 5499 | */ |
5501 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, | 5500 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, |
5502 | struct nfs_client *clp) | 5501 | struct nfs4_setclientid_res *res) |
5503 | { | 5502 | { |
5504 | struct xdr_stream xdr; | 5503 | struct xdr_stream xdr; |
5505 | struct compound_hdr hdr; | 5504 | struct compound_hdr hdr; |
@@ -5508,7 +5507,7 @@ static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, | |||
5508 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 5507 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); |
5509 | status = decode_compound_hdr(&xdr, &hdr); | 5508 | status = decode_compound_hdr(&xdr, &hdr); |
5510 | if (!status) | 5509 | if (!status) |
5511 | status = decode_setclientid(&xdr, clp); | 5510 | status = decode_setclientid(&xdr, res); |
5512 | return status; | 5511 | return status; |
5513 | } | 5512 | } |
5514 | 5513 | ||
@@ -5552,6 +5551,8 @@ static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nf | |||
5552 | if (status != 0) | 5551 | if (status != 0) |
5553 | goto out; | 5552 | goto out; |
5554 | status = decode_delegreturn(&xdr); | 5553 | status = decode_delegreturn(&xdr); |
5554 | if (status != 0) | ||
5555 | goto out; | ||
5555 | decode_getfattr(&xdr, res->fattr, res->server, | 5556 | decode_getfattr(&xdr, res->fattr, res->server, |
5556 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5557 | !RPC_IS_ASYNC(rqstp->rq_task)); |
5557 | out: | 5558 | out: |
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index 8c55b27c0de4..6bd19d843af7 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c | |||
@@ -488,7 +488,6 @@ static int __init root_nfs_ports(void) | |||
488 | */ | 488 | */ |
489 | static int __init root_nfs_get_handle(void) | 489 | static int __init root_nfs_get_handle(void) |
490 | { | 490 | { |
491 | struct nfs_fh fh; | ||
492 | struct sockaddr_in sin; | 491 | struct sockaddr_in sin; |
493 | unsigned int auth_flav_len = 0; | 492 | unsigned int auth_flav_len = 0; |
494 | struct nfs_mount_request request = { | 493 | struct nfs_mount_request request = { |
@@ -499,21 +498,24 @@ static int __init root_nfs_get_handle(void) | |||
499 | NFS_MNT3_VERSION : NFS_MNT_VERSION, | 498 | NFS_MNT3_VERSION : NFS_MNT_VERSION, |
500 | .protocol = (nfs_data.flags & NFS_MOUNT_TCP) ? | 499 | .protocol = (nfs_data.flags & NFS_MOUNT_TCP) ? |
501 | XPRT_TRANSPORT_TCP : XPRT_TRANSPORT_UDP, | 500 | XPRT_TRANSPORT_TCP : XPRT_TRANSPORT_UDP, |
502 | .fh = &fh, | ||
503 | .auth_flav_len = &auth_flav_len, | 501 | .auth_flav_len = &auth_flav_len, |
504 | }; | 502 | }; |
505 | int status; | 503 | int status = -ENOMEM; |
506 | 504 | ||
505 | request.fh = nfs_alloc_fhandle(); | ||
506 | if (!request.fh) | ||
507 | goto out; | ||
507 | set_sockaddr(&sin, servaddr, htons(mount_port)); | 508 | set_sockaddr(&sin, servaddr, htons(mount_port)); |
508 | status = nfs_mount(&request); | 509 | status = nfs_mount(&request); |
509 | if (status < 0) | 510 | if (status < 0) |
510 | printk(KERN_ERR "Root-NFS: Server returned error %d " | 511 | printk(KERN_ERR "Root-NFS: Server returned error %d " |
511 | "while mounting %s\n", status, nfs_export_path); | 512 | "while mounting %s\n", status, nfs_export_path); |
512 | else { | 513 | else { |
513 | nfs_data.root.size = fh.size; | 514 | nfs_data.root.size = request.fh->size; |
514 | memcpy(nfs_data.root.data, fh.data, fh.size); | 515 | memcpy(&nfs_data.root.data, request.fh->data, request.fh->size); |
515 | } | 516 | } |
516 | 517 | nfs_free_fhandle(request.fh); | |
518 | out: | ||
517 | return status; | 519 | return status; |
518 | } | 520 | } |
519 | 521 | ||
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index a12c45b65dd4..a3654e57b589 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c | |||
@@ -60,16 +60,10 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode, | |||
60 | { | 60 | { |
61 | struct nfs_page *req; | 61 | struct nfs_page *req; |
62 | 62 | ||
63 | for (;;) { | 63 | /* try to allocate the request struct */ |
64 | /* try to allocate the request struct */ | 64 | req = nfs_page_alloc(); |
65 | req = nfs_page_alloc(); | 65 | if (req == NULL) |
66 | if (req != NULL) | 66 | return ERR_PTR(-ENOMEM); |
67 | break; | ||
68 | |||
69 | if (fatal_signal_pending(current)) | ||
70 | return ERR_PTR(-ERESTARTSYS); | ||
71 | yield(); | ||
72 | } | ||
73 | 67 | ||
74 | /* Initialize the request struct. Initially, we assume a | 68 | /* Initialize the request struct. Initially, we assume a |
75 | * long write-back delay. This will be adjusted in | 69 | * long write-back delay. This will be adjusted in |
@@ -112,12 +106,10 @@ void nfs_unlock_request(struct nfs_page *req) | |||
112 | */ | 106 | */ |
113 | int nfs_set_page_tag_locked(struct nfs_page *req) | 107 | int nfs_set_page_tag_locked(struct nfs_page *req) |
114 | { | 108 | { |
115 | struct nfs_inode *nfsi = NFS_I(req->wb_context->path.dentry->d_inode); | ||
116 | |||
117 | if (!nfs_lock_request_dontget(req)) | 109 | if (!nfs_lock_request_dontget(req)) |
118 | return 0; | 110 | return 0; |
119 | if (req->wb_page != NULL) | 111 | if (req->wb_page != NULL) |
120 | radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); | 112 | radix_tree_tag_set(&NFS_I(req->wb_context->path.dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); |
121 | return 1; | 113 | return 1; |
122 | } | 114 | } |
123 | 115 | ||
@@ -126,10 +118,10 @@ int nfs_set_page_tag_locked(struct nfs_page *req) | |||
126 | */ | 118 | */ |
127 | void nfs_clear_page_tag_locked(struct nfs_page *req) | 119 | void nfs_clear_page_tag_locked(struct nfs_page *req) |
128 | { | 120 | { |
129 | struct inode *inode = req->wb_context->path.dentry->d_inode; | ||
130 | struct nfs_inode *nfsi = NFS_I(inode); | ||
131 | |||
132 | if (req->wb_page != NULL) { | 121 | if (req->wb_page != NULL) { |
122 | struct inode *inode = req->wb_context->path.dentry->d_inode; | ||
123 | struct nfs_inode *nfsi = NFS_I(inode); | ||
124 | |||
133 | spin_lock(&inode->i_lock); | 125 | spin_lock(&inode->i_lock); |
134 | radix_tree_tag_clear(&nfsi->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); | 126 | radix_tree_tag_clear(&nfsi->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); |
135 | nfs_unlock_request(req); | 127 | nfs_unlock_request(req); |
@@ -142,16 +134,22 @@ void nfs_clear_page_tag_locked(struct nfs_page *req) | |||
142 | * nfs_clear_request - Free up all resources allocated to the request | 134 | * nfs_clear_request - Free up all resources allocated to the request |
143 | * @req: | 135 | * @req: |
144 | * | 136 | * |
145 | * Release page resources associated with a write request after it | 137 | * Release page and open context resources associated with a read/write |
146 | * has completed. | 138 | * request after it has completed. |
147 | */ | 139 | */ |
148 | void nfs_clear_request(struct nfs_page *req) | 140 | void nfs_clear_request(struct nfs_page *req) |
149 | { | 141 | { |
150 | struct page *page = req->wb_page; | 142 | struct page *page = req->wb_page; |
143 | struct nfs_open_context *ctx = req->wb_context; | ||
144 | |||
151 | if (page != NULL) { | 145 | if (page != NULL) { |
152 | page_cache_release(page); | 146 | page_cache_release(page); |
153 | req->wb_page = NULL; | 147 | req->wb_page = NULL; |
154 | } | 148 | } |
149 | if (ctx != NULL) { | ||
150 | put_nfs_open_context(ctx); | ||
151 | req->wb_context = NULL; | ||
152 | } | ||
155 | } | 153 | } |
156 | 154 | ||
157 | 155 | ||
@@ -165,9 +163,8 @@ static void nfs_free_request(struct kref *kref) | |||
165 | { | 163 | { |
166 | struct nfs_page *req = container_of(kref, struct nfs_page, wb_kref); | 164 | struct nfs_page *req = container_of(kref, struct nfs_page, wb_kref); |
167 | 165 | ||
168 | /* Release struct file or cached credential */ | 166 | /* Release struct file and open context */ |
169 | nfs_clear_request(req); | 167 | nfs_clear_request(req); |
170 | put_nfs_open_context(req->wb_context); | ||
171 | nfs_page_free(req); | 168 | nfs_page_free(req); |
172 | } | 169 | } |
173 | 170 | ||
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index c752d944fe9e..611bec22f552 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | #include <linux/types.h> | 30 | #include <linux/types.h> |
31 | #include <linux/param.h> | 31 | #include <linux/param.h> |
32 | #include <linux/slab.h> | ||
33 | #include <linux/time.h> | 32 | #include <linux/time.h> |
34 | #include <linux/mm.h> | 33 | #include <linux/mm.h> |
35 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
@@ -225,35 +224,60 @@ static int nfs_proc_readlink(struct inode *inode, struct page *page, | |||
225 | return status; | 224 | return status; |
226 | } | 225 | } |
227 | 226 | ||
227 | struct nfs_createdata { | ||
228 | struct nfs_createargs arg; | ||
229 | struct nfs_diropok res; | ||
230 | struct nfs_fh fhandle; | ||
231 | struct nfs_fattr fattr; | ||
232 | }; | ||
233 | |||
234 | static struct nfs_createdata *nfs_alloc_createdata(struct inode *dir, | ||
235 | struct dentry *dentry, struct iattr *sattr) | ||
236 | { | ||
237 | struct nfs_createdata *data; | ||
238 | |||
239 | data = kmalloc(sizeof(*data), GFP_KERNEL); | ||
240 | |||
241 | if (data != NULL) { | ||
242 | data->arg.fh = NFS_FH(dir); | ||
243 | data->arg.name = dentry->d_name.name; | ||
244 | data->arg.len = dentry->d_name.len; | ||
245 | data->arg.sattr = sattr; | ||
246 | nfs_fattr_init(&data->fattr); | ||
247 | data->fhandle.size = 0; | ||
248 | data->res.fh = &data->fhandle; | ||
249 | data->res.fattr = &data->fattr; | ||
250 | } | ||
251 | return data; | ||
252 | }; | ||
253 | |||
254 | static void nfs_free_createdata(const struct nfs_createdata *data) | ||
255 | { | ||
256 | kfree(data); | ||
257 | } | ||
258 | |||
228 | static int | 259 | static int |
229 | nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | 260 | nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, |
230 | int flags, struct nameidata *nd) | 261 | int flags, struct nameidata *nd) |
231 | { | 262 | { |
232 | struct nfs_fh fhandle; | 263 | struct nfs_createdata *data; |
233 | struct nfs_fattr fattr; | ||
234 | struct nfs_createargs arg = { | ||
235 | .fh = NFS_FH(dir), | ||
236 | .name = dentry->d_name.name, | ||
237 | .len = dentry->d_name.len, | ||
238 | .sattr = sattr | ||
239 | }; | ||
240 | struct nfs_diropok res = { | ||
241 | .fh = &fhandle, | ||
242 | .fattr = &fattr | ||
243 | }; | ||
244 | struct rpc_message msg = { | 264 | struct rpc_message msg = { |
245 | .rpc_proc = &nfs_procedures[NFSPROC_CREATE], | 265 | .rpc_proc = &nfs_procedures[NFSPROC_CREATE], |
246 | .rpc_argp = &arg, | ||
247 | .rpc_resp = &res, | ||
248 | }; | 266 | }; |
249 | int status; | 267 | int status = -ENOMEM; |
250 | 268 | ||
251 | nfs_fattr_init(&fattr); | ||
252 | dprintk("NFS call create %s\n", dentry->d_name.name); | 269 | dprintk("NFS call create %s\n", dentry->d_name.name); |
270 | data = nfs_alloc_createdata(dir, dentry, sattr); | ||
271 | if (data == NULL) | ||
272 | goto out; | ||
273 | msg.rpc_argp = &data->arg; | ||
274 | msg.rpc_resp = &data->res; | ||
253 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 275 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
254 | nfs_mark_for_revalidate(dir); | 276 | nfs_mark_for_revalidate(dir); |
255 | if (status == 0) | 277 | if (status == 0) |
256 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 278 | status = nfs_instantiate(dentry, data->res.fh, data->res.fattr); |
279 | nfs_free_createdata(data); | ||
280 | out: | ||
257 | dprintk("NFS reply create: %d\n", status); | 281 | dprintk("NFS reply create: %d\n", status); |
258 | return status; | 282 | return status; |
259 | } | 283 | } |
@@ -265,24 +289,12 @@ static int | |||
265 | nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | 289 | nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, |
266 | dev_t rdev) | 290 | dev_t rdev) |
267 | { | 291 | { |
268 | struct nfs_fh fhandle; | 292 | struct nfs_createdata *data; |
269 | struct nfs_fattr fattr; | ||
270 | struct nfs_createargs arg = { | ||
271 | .fh = NFS_FH(dir), | ||
272 | .name = dentry->d_name.name, | ||
273 | .len = dentry->d_name.len, | ||
274 | .sattr = sattr | ||
275 | }; | ||
276 | struct nfs_diropok res = { | ||
277 | .fh = &fhandle, | ||
278 | .fattr = &fattr | ||
279 | }; | ||
280 | struct rpc_message msg = { | 293 | struct rpc_message msg = { |
281 | .rpc_proc = &nfs_procedures[NFSPROC_CREATE], | 294 | .rpc_proc = &nfs_procedures[NFSPROC_CREATE], |
282 | .rpc_argp = &arg, | ||
283 | .rpc_resp = &res, | ||
284 | }; | 295 | }; |
285 | int status, mode; | 296 | umode_t mode; |
297 | int status = -ENOMEM; | ||
286 | 298 | ||
287 | dprintk("NFS call mknod %s\n", dentry->d_name.name); | 299 | dprintk("NFS call mknod %s\n", dentry->d_name.name); |
288 | 300 | ||
@@ -295,17 +307,24 @@ nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
295 | sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */ | 307 | sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */ |
296 | } | 308 | } |
297 | 309 | ||
298 | nfs_fattr_init(&fattr); | 310 | data = nfs_alloc_createdata(dir, dentry, sattr); |
311 | if (data == NULL) | ||
312 | goto out; | ||
313 | msg.rpc_argp = &data->arg; | ||
314 | msg.rpc_resp = &data->res; | ||
315 | |||
299 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 316 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
300 | nfs_mark_for_revalidate(dir); | 317 | nfs_mark_for_revalidate(dir); |
301 | 318 | ||
302 | if (status == -EINVAL && S_ISFIFO(mode)) { | 319 | if (status == -EINVAL && S_ISFIFO(mode)) { |
303 | sattr->ia_mode = mode; | 320 | sattr->ia_mode = mode; |
304 | nfs_fattr_init(&fattr); | 321 | nfs_fattr_init(data->res.fattr); |
305 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 322 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
306 | } | 323 | } |
307 | if (status == 0) | 324 | if (status == 0) |
308 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 325 | status = nfs_instantiate(dentry, data->res.fh, data->res.fattr); |
326 | nfs_free_createdata(data); | ||
327 | out: | ||
309 | dprintk("NFS reply mknod: %d\n", status); | 328 | dprintk("NFS reply mknod: %d\n", status); |
310 | return status; | 329 | return status; |
311 | } | 330 | } |
@@ -399,8 +418,8 @@ static int | |||
399 | nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, | 418 | nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, |
400 | unsigned int len, struct iattr *sattr) | 419 | unsigned int len, struct iattr *sattr) |
401 | { | 420 | { |
402 | struct nfs_fh fhandle; | 421 | struct nfs_fh *fh; |
403 | struct nfs_fattr fattr; | 422 | struct nfs_fattr *fattr; |
404 | struct nfs_symlinkargs arg = { | 423 | struct nfs_symlinkargs arg = { |
405 | .fromfh = NFS_FH(dir), | 424 | .fromfh = NFS_FH(dir), |
406 | .fromname = dentry->d_name.name, | 425 | .fromname = dentry->d_name.name, |
@@ -413,12 +432,18 @@ nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, | |||
413 | .rpc_proc = &nfs_procedures[NFSPROC_SYMLINK], | 432 | .rpc_proc = &nfs_procedures[NFSPROC_SYMLINK], |
414 | .rpc_argp = &arg, | 433 | .rpc_argp = &arg, |
415 | }; | 434 | }; |
416 | int status; | 435 | int status = -ENAMETOOLONG; |
436 | |||
437 | dprintk("NFS call symlink %s\n", dentry->d_name.name); | ||
417 | 438 | ||
418 | if (len > NFS2_MAXPATHLEN) | 439 | if (len > NFS2_MAXPATHLEN) |
419 | return -ENAMETOOLONG; | 440 | goto out; |
420 | 441 | ||
421 | dprintk("NFS call symlink %s\n", dentry->d_name.name); | 442 | fh = nfs_alloc_fhandle(); |
443 | fattr = nfs_alloc_fattr(); | ||
444 | status = -ENOMEM; | ||
445 | if (fh == NULL || fattr == NULL) | ||
446 | goto out; | ||
422 | 447 | ||
423 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 448 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
424 | nfs_mark_for_revalidate(dir); | 449 | nfs_mark_for_revalidate(dir); |
@@ -428,12 +453,12 @@ nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, | |||
428 | * filehandle size to zero indicates to nfs_instantiate that it | 453 | * filehandle size to zero indicates to nfs_instantiate that it |
429 | * should fill in the data with a LOOKUP call on the wire. | 454 | * should fill in the data with a LOOKUP call on the wire. |
430 | */ | 455 | */ |
431 | if (status == 0) { | 456 | if (status == 0) |
432 | nfs_fattr_init(&fattr); | 457 | status = nfs_instantiate(dentry, fh, fattr); |
433 | fhandle.size = 0; | ||
434 | status = nfs_instantiate(dentry, &fhandle, &fattr); | ||
435 | } | ||
436 | 458 | ||
459 | nfs_free_fattr(fattr); | ||
460 | nfs_free_fhandle(fh); | ||
461 | out: | ||
437 | dprintk("NFS reply symlink: %d\n", status); | 462 | dprintk("NFS reply symlink: %d\n", status); |
438 | return status; | 463 | return status; |
439 | } | 464 | } |
@@ -441,31 +466,25 @@ nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, | |||
441 | static int | 466 | static int |
442 | nfs_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr) | 467 | nfs_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr) |
443 | { | 468 | { |
444 | struct nfs_fh fhandle; | 469 | struct nfs_createdata *data; |
445 | struct nfs_fattr fattr; | ||
446 | struct nfs_createargs arg = { | ||
447 | .fh = NFS_FH(dir), | ||
448 | .name = dentry->d_name.name, | ||
449 | .len = dentry->d_name.len, | ||
450 | .sattr = sattr | ||
451 | }; | ||
452 | struct nfs_diropok res = { | ||
453 | .fh = &fhandle, | ||
454 | .fattr = &fattr | ||
455 | }; | ||
456 | struct rpc_message msg = { | 470 | struct rpc_message msg = { |
457 | .rpc_proc = &nfs_procedures[NFSPROC_MKDIR], | 471 | .rpc_proc = &nfs_procedures[NFSPROC_MKDIR], |
458 | .rpc_argp = &arg, | ||
459 | .rpc_resp = &res, | ||
460 | }; | 472 | }; |
461 | int status; | 473 | int status = -ENOMEM; |
462 | 474 | ||
463 | dprintk("NFS call mkdir %s\n", dentry->d_name.name); | 475 | dprintk("NFS call mkdir %s\n", dentry->d_name.name); |
464 | nfs_fattr_init(&fattr); | 476 | data = nfs_alloc_createdata(dir, dentry, sattr); |
477 | if (data == NULL) | ||
478 | goto out; | ||
479 | msg.rpc_argp = &data->arg; | ||
480 | msg.rpc_resp = &data->res; | ||
481 | |||
465 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 482 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
466 | nfs_mark_for_revalidate(dir); | 483 | nfs_mark_for_revalidate(dir); |
467 | if (status == 0) | 484 | if (status == 0) |
468 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 485 | status = nfs_instantiate(dentry, data->res.fh, data->res.fattr); |
486 | nfs_free_createdata(data); | ||
487 | out: | ||
469 | dprintk("NFS reply mkdir: %d\n", status); | 488 | dprintk("NFS reply mkdir: %d\n", status); |
470 | return status; | 489 | return status; |
471 | } | 490 | } |
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index db9b360ae19d..6e2b06e6ca79 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -40,7 +40,7 @@ static mempool_t *nfs_rdata_mempool; | |||
40 | 40 | ||
41 | struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount) | 41 | struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount) |
42 | { | 42 | { |
43 | struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, GFP_NOFS); | 43 | struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, GFP_KERNEL); |
44 | 44 | ||
45 | if (p) { | 45 | if (p) { |
46 | memset(p, 0, sizeof(*p)); | 46 | memset(p, 0, sizeof(*p)); |
@@ -50,7 +50,7 @@ struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount) | |||
50 | if (pagecount <= ARRAY_SIZE(p->page_array)) | 50 | if (pagecount <= ARRAY_SIZE(p->page_array)) |
51 | p->pagevec = p->page_array; | 51 | p->pagevec = p->page_array; |
52 | else { | 52 | else { |
53 | p->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_NOFS); | 53 | p->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_KERNEL); |
54 | if (!p->pagevec) { | 54 | if (!p->pagevec) { |
55 | mempool_free(p, nfs_rdata_mempool); | 55 | mempool_free(p, nfs_rdata_mempool); |
56 | p = NULL; | 56 | p = NULL; |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index f1afee4eea77..2f8b1157daa2 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/vfs.h> | 48 | #include <linux/vfs.h> |
49 | #include <linux/inet.h> | 49 | #include <linux/inet.h> |
50 | #include <linux/in6.h> | 50 | #include <linux/in6.h> |
51 | #include <linux/slab.h> | ||
51 | #include <net/ipv6.h> | 52 | #include <net/ipv6.h> |
52 | #include <linux/netdevice.h> | 53 | #include <linux/netdevice.h> |
53 | #include <linux/nfs_xdr.h> | 54 | #include <linux/nfs_xdr.h> |
@@ -140,7 +141,6 @@ static const match_table_t nfs_mount_option_tokens = { | |||
140 | { Opt_resvport, "resvport" }, | 141 | { Opt_resvport, "resvport" }, |
141 | { Opt_noresvport, "noresvport" }, | 142 | { Opt_noresvport, "noresvport" }, |
142 | { Opt_fscache, "fsc" }, | 143 | { Opt_fscache, "fsc" }, |
143 | { Opt_fscache_uniq, "fsc=%s" }, | ||
144 | { Opt_nofscache, "nofsc" }, | 144 | { Opt_nofscache, "nofsc" }, |
145 | 145 | ||
146 | { Opt_port, "port=%s" }, | 146 | { Opt_port, "port=%s" }, |
@@ -170,6 +170,7 @@ static const match_table_t nfs_mount_option_tokens = { | |||
170 | { Opt_mountaddr, "mountaddr=%s" }, | 170 | { Opt_mountaddr, "mountaddr=%s" }, |
171 | 171 | ||
172 | { Opt_lookupcache, "lookupcache=%s" }, | 172 | { Opt_lookupcache, "lookupcache=%s" }, |
173 | { Opt_fscache_uniq, "fsc=%s" }, | ||
173 | 174 | ||
174 | { Opt_err, NULL } | 175 | { Opt_err, NULL } |
175 | }; | 176 | }; |
@@ -422,15 +423,19 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
422 | unsigned char blockbits; | 423 | unsigned char blockbits; |
423 | unsigned long blockres; | 424 | unsigned long blockres; |
424 | struct nfs_fh *fh = NFS_FH(dentry->d_inode); | 425 | struct nfs_fh *fh = NFS_FH(dentry->d_inode); |
425 | struct nfs_fattr fattr; | 426 | struct nfs_fsstat res; |
426 | struct nfs_fsstat res = { | 427 | int error = -ENOMEM; |
427 | .fattr = &fattr, | 428 | |
428 | }; | 429 | res.fattr = nfs_alloc_fattr(); |
429 | int error; | 430 | if (res.fattr == NULL) |
431 | goto out_err; | ||
430 | 432 | ||
431 | error = server->nfs_client->rpc_ops->statfs(server, fh, &res); | 433 | error = server->nfs_client->rpc_ops->statfs(server, fh, &res); |
434 | |||
435 | nfs_free_fattr(res.fattr); | ||
432 | if (error < 0) | 436 | if (error < 0) |
433 | goto out_err; | 437 | goto out_err; |
438 | |||
434 | buf->f_type = NFS_SUPER_MAGIC; | 439 | buf->f_type = NFS_SUPER_MAGIC; |
435 | 440 | ||
436 | /* | 441 | /* |
@@ -1045,14 +1050,6 @@ static int nfs_parse_mount_options(char *raw, | |||
1045 | kfree(mnt->fscache_uniq); | 1050 | kfree(mnt->fscache_uniq); |
1046 | mnt->fscache_uniq = NULL; | 1051 | mnt->fscache_uniq = NULL; |
1047 | break; | 1052 | break; |
1048 | case Opt_fscache_uniq: | ||
1049 | string = match_strdup(args); | ||
1050 | if (!string) | ||
1051 | goto out_nomem; | ||
1052 | kfree(mnt->fscache_uniq); | ||
1053 | mnt->fscache_uniq = string; | ||
1054 | mnt->options |= NFS_OPTION_FSCACHE; | ||
1055 | break; | ||
1056 | 1053 | ||
1057 | /* | 1054 | /* |
1058 | * options that take numeric values | 1055 | * options that take numeric values |
@@ -1383,6 +1380,14 @@ static int nfs_parse_mount_options(char *raw, | |||
1383 | return 0; | 1380 | return 0; |
1384 | }; | 1381 | }; |
1385 | break; | 1382 | break; |
1383 | case Opt_fscache_uniq: | ||
1384 | string = match_strdup(args); | ||
1385 | if (string == NULL) | ||
1386 | goto out_nomem; | ||
1387 | kfree(mnt->fscache_uniq); | ||
1388 | mnt->fscache_uniq = string; | ||
1389 | mnt->options |= NFS_OPTION_FSCACHE; | ||
1390 | break; | ||
1386 | 1391 | ||
1387 | /* | 1392 | /* |
1388 | * Special options | 1393 | * Special options |
@@ -2171,7 +2176,7 @@ static int nfs_get_sb(struct file_system_type *fs_type, | |||
2171 | int error = -ENOMEM; | 2176 | int error = -ENOMEM; |
2172 | 2177 | ||
2173 | data = nfs_alloc_parsed_mount_data(3); | 2178 | data = nfs_alloc_parsed_mount_data(3); |
2174 | mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); | 2179 | mntfh = nfs_alloc_fhandle(); |
2175 | if (data == NULL || mntfh == NULL) | 2180 | if (data == NULL || mntfh == NULL) |
2176 | goto out_free_fh; | 2181 | goto out_free_fh; |
2177 | 2182 | ||
@@ -2186,6 +2191,7 @@ static int nfs_get_sb(struct file_system_type *fs_type, | |||
2186 | if (data->version == 4) { | 2191 | if (data->version == 4) { |
2187 | error = nfs4_try_mount(flags, dev_name, data, mnt); | 2192 | error = nfs4_try_mount(flags, dev_name, data, mnt); |
2188 | kfree(data->client_address); | 2193 | kfree(data->client_address); |
2194 | kfree(data->nfs_server.export_path); | ||
2189 | goto out; | 2195 | goto out; |
2190 | } | 2196 | } |
2191 | #endif /* CONFIG_NFS_V4 */ | 2197 | #endif /* CONFIG_NFS_V4 */ |
@@ -2214,7 +2220,7 @@ static int nfs_get_sb(struct file_system_type *fs_type, | |||
2214 | } else { | 2220 | } else { |
2215 | error = nfs_bdi_register(server); | 2221 | error = nfs_bdi_register(server); |
2216 | if (error) | 2222 | if (error) |
2217 | goto error_splat_super; | 2223 | goto error_splat_bdi; |
2218 | } | 2224 | } |
2219 | 2225 | ||
2220 | if (!s->s_root) { | 2226 | if (!s->s_root) { |
@@ -2245,7 +2251,7 @@ out: | |||
2245 | kfree(data->fscache_uniq); | 2251 | kfree(data->fscache_uniq); |
2246 | security_free_mnt_opts(&data->lsm_opts); | 2252 | security_free_mnt_opts(&data->lsm_opts); |
2247 | out_free_fh: | 2253 | out_free_fh: |
2248 | kfree(mntfh); | 2254 | nfs_free_fhandle(mntfh); |
2249 | kfree(data); | 2255 | kfree(data); |
2250 | return error; | 2256 | return error; |
2251 | 2257 | ||
@@ -2256,6 +2262,9 @@ out_err_nosb: | |||
2256 | error_splat_root: | 2262 | error_splat_root: |
2257 | dput(mntroot); | 2263 | dput(mntroot); |
2258 | error_splat_super: | 2264 | error_splat_super: |
2265 | if (server && !s->s_root) | ||
2266 | bdi_unregister(&server->backing_dev_info); | ||
2267 | error_splat_bdi: | ||
2259 | deactivate_locked_super(s); | 2268 | deactivate_locked_super(s); |
2260 | goto out; | 2269 | goto out; |
2261 | } | 2270 | } |
@@ -2326,7 +2335,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags, | |||
2326 | } else { | 2335 | } else { |
2327 | error = nfs_bdi_register(server); | 2336 | error = nfs_bdi_register(server); |
2328 | if (error) | 2337 | if (error) |
2329 | goto error_splat_super; | 2338 | goto error_splat_bdi; |
2330 | } | 2339 | } |
2331 | 2340 | ||
2332 | if (!s->s_root) { | 2341 | if (!s->s_root) { |
@@ -2363,6 +2372,9 @@ out_err_noserver: | |||
2363 | return error; | 2372 | return error; |
2364 | 2373 | ||
2365 | error_splat_super: | 2374 | error_splat_super: |
2375 | if (server && !s->s_root) | ||
2376 | bdi_unregister(&server->backing_dev_info); | ||
2377 | error_splat_bdi: | ||
2366 | deactivate_locked_super(s); | 2378 | deactivate_locked_super(s); |
2367 | dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error); | 2379 | dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error); |
2368 | return error; | 2380 | return error; |
@@ -2548,7 +2560,7 @@ static int nfs4_remote_get_sb(struct file_system_type *fs_type, | |||
2548 | }; | 2560 | }; |
2549 | int error = -ENOMEM; | 2561 | int error = -ENOMEM; |
2550 | 2562 | ||
2551 | mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); | 2563 | mntfh = nfs_alloc_fhandle(); |
2552 | if (data == NULL || mntfh == NULL) | 2564 | if (data == NULL || mntfh == NULL) |
2553 | goto out_free_fh; | 2565 | goto out_free_fh; |
2554 | 2566 | ||
@@ -2578,7 +2590,7 @@ static int nfs4_remote_get_sb(struct file_system_type *fs_type, | |||
2578 | } else { | 2590 | } else { |
2579 | error = nfs_bdi_register(server); | 2591 | error = nfs_bdi_register(server); |
2580 | if (error) | 2592 | if (error) |
2581 | goto error_splat_super; | 2593 | goto error_splat_bdi; |
2582 | } | 2594 | } |
2583 | 2595 | ||
2584 | if (!s->s_root) { | 2596 | if (!s->s_root) { |
@@ -2606,7 +2618,7 @@ static int nfs4_remote_get_sb(struct file_system_type *fs_type, | |||
2606 | out: | 2618 | out: |
2607 | security_free_mnt_opts(&data->lsm_opts); | 2619 | security_free_mnt_opts(&data->lsm_opts); |
2608 | out_free_fh: | 2620 | out_free_fh: |
2609 | kfree(mntfh); | 2621 | nfs_free_fhandle(mntfh); |
2610 | return error; | 2622 | return error; |
2611 | 2623 | ||
2612 | out_free: | 2624 | out_free: |
@@ -2616,6 +2628,9 @@ out_free: | |||
2616 | error_splat_root: | 2628 | error_splat_root: |
2617 | dput(mntroot); | 2629 | dput(mntroot); |
2618 | error_splat_super: | 2630 | error_splat_super: |
2631 | if (server && !s->s_root) | ||
2632 | bdi_unregister(&server->backing_dev_info); | ||
2633 | error_splat_bdi: | ||
2619 | deactivate_locked_super(s); | 2634 | deactivate_locked_super(s); |
2620 | goto out; | 2635 | goto out; |
2621 | } | 2636 | } |
@@ -2647,7 +2662,7 @@ static void nfs_fix_devname(const struct path *path, struct vfsmount *mnt) | |||
2647 | devname = nfs_path(path->mnt->mnt_devname, | 2662 | devname = nfs_path(path->mnt->mnt_devname, |
2648 | path->mnt->mnt_root, path->dentry, | 2663 | path->mnt->mnt_root, path->dentry, |
2649 | page, PAGE_SIZE); | 2664 | page, PAGE_SIZE); |
2650 | if (devname == NULL) | 2665 | if (IS_ERR(devname)) |
2651 | goto out_freepage; | 2666 | goto out_freepage; |
2652 | tmp = kstrdup(devname, GFP_KERNEL); | 2667 | tmp = kstrdup(devname, GFP_KERNEL); |
2653 | if (tmp == NULL) | 2668 | if (tmp == NULL) |
@@ -2658,41 +2673,120 @@ out_freepage: | |||
2658 | free_page((unsigned long)page); | 2673 | free_page((unsigned long)page); |
2659 | } | 2674 | } |
2660 | 2675 | ||
2676 | struct nfs_referral_count { | ||
2677 | struct list_head list; | ||
2678 | const struct task_struct *task; | ||
2679 | unsigned int referral_count; | ||
2680 | }; | ||
2681 | |||
2682 | static LIST_HEAD(nfs_referral_count_list); | ||
2683 | static DEFINE_SPINLOCK(nfs_referral_count_list_lock); | ||
2684 | |||
2685 | static struct nfs_referral_count *nfs_find_referral_count(void) | ||
2686 | { | ||
2687 | struct nfs_referral_count *p; | ||
2688 | |||
2689 | list_for_each_entry(p, &nfs_referral_count_list, list) { | ||
2690 | if (p->task == current) | ||
2691 | return p; | ||
2692 | } | ||
2693 | return NULL; | ||
2694 | } | ||
2695 | |||
2696 | #define NFS_MAX_NESTED_REFERRALS 2 | ||
2697 | |||
2698 | static int nfs_referral_loop_protect(void) | ||
2699 | { | ||
2700 | struct nfs_referral_count *p, *new; | ||
2701 | int ret = -ENOMEM; | ||
2702 | |||
2703 | new = kmalloc(sizeof(*new), GFP_KERNEL); | ||
2704 | if (!new) | ||
2705 | goto out; | ||
2706 | new->task = current; | ||
2707 | new->referral_count = 1; | ||
2708 | |||
2709 | ret = 0; | ||
2710 | spin_lock(&nfs_referral_count_list_lock); | ||
2711 | p = nfs_find_referral_count(); | ||
2712 | if (p != NULL) { | ||
2713 | if (p->referral_count >= NFS_MAX_NESTED_REFERRALS) | ||
2714 | ret = -ELOOP; | ||
2715 | else | ||
2716 | p->referral_count++; | ||
2717 | } else { | ||
2718 | list_add(&new->list, &nfs_referral_count_list); | ||
2719 | new = NULL; | ||
2720 | } | ||
2721 | spin_unlock(&nfs_referral_count_list_lock); | ||
2722 | kfree(new); | ||
2723 | out: | ||
2724 | return ret; | ||
2725 | } | ||
2726 | |||
2727 | static void nfs_referral_loop_unprotect(void) | ||
2728 | { | ||
2729 | struct nfs_referral_count *p; | ||
2730 | |||
2731 | spin_lock(&nfs_referral_count_list_lock); | ||
2732 | p = nfs_find_referral_count(); | ||
2733 | p->referral_count--; | ||
2734 | if (p->referral_count == 0) | ||
2735 | list_del(&p->list); | ||
2736 | else | ||
2737 | p = NULL; | ||
2738 | spin_unlock(&nfs_referral_count_list_lock); | ||
2739 | kfree(p); | ||
2740 | } | ||
2741 | |||
2661 | static int nfs_follow_remote_path(struct vfsmount *root_mnt, | 2742 | static int nfs_follow_remote_path(struct vfsmount *root_mnt, |
2662 | const char *export_path, struct vfsmount *mnt_target) | 2743 | const char *export_path, struct vfsmount *mnt_target) |
2663 | { | 2744 | { |
2745 | struct nameidata *nd = NULL; | ||
2664 | struct mnt_namespace *ns_private; | 2746 | struct mnt_namespace *ns_private; |
2665 | struct nameidata nd; | ||
2666 | struct super_block *s; | 2747 | struct super_block *s; |
2667 | int ret; | 2748 | int ret; |
2668 | 2749 | ||
2750 | nd = kmalloc(sizeof(*nd), GFP_KERNEL); | ||
2751 | if (nd == NULL) | ||
2752 | return -ENOMEM; | ||
2753 | |||
2669 | ns_private = create_mnt_ns(root_mnt); | 2754 | ns_private = create_mnt_ns(root_mnt); |
2670 | ret = PTR_ERR(ns_private); | 2755 | ret = PTR_ERR(ns_private); |
2671 | if (IS_ERR(ns_private)) | 2756 | if (IS_ERR(ns_private)) |
2672 | goto out_mntput; | 2757 | goto out_mntput; |
2673 | 2758 | ||
2759 | ret = nfs_referral_loop_protect(); | ||
2760 | if (ret != 0) | ||
2761 | goto out_put_mnt_ns; | ||
2762 | |||
2674 | ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, | 2763 | ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, |
2675 | export_path, LOOKUP_FOLLOW, &nd); | 2764 | export_path, LOOKUP_FOLLOW, nd); |
2676 | 2765 | ||
2766 | nfs_referral_loop_unprotect(); | ||
2677 | put_mnt_ns(ns_private); | 2767 | put_mnt_ns(ns_private); |
2678 | 2768 | ||
2679 | if (ret != 0) | 2769 | if (ret != 0) |
2680 | goto out_err; | 2770 | goto out_err; |
2681 | 2771 | ||
2682 | s = nd.path.mnt->mnt_sb; | 2772 | s = nd->path.mnt->mnt_sb; |
2683 | atomic_inc(&s->s_active); | 2773 | atomic_inc(&s->s_active); |
2684 | mnt_target->mnt_sb = s; | 2774 | mnt_target->mnt_sb = s; |
2685 | mnt_target->mnt_root = dget(nd.path.dentry); | 2775 | mnt_target->mnt_root = dget(nd->path.dentry); |
2686 | 2776 | ||
2687 | /* Correct the device pathname */ | 2777 | /* Correct the device pathname */ |
2688 | nfs_fix_devname(&nd.path, mnt_target); | 2778 | nfs_fix_devname(&nd->path, mnt_target); |
2689 | 2779 | ||
2690 | path_put(&nd.path); | 2780 | path_put(&nd->path); |
2781 | kfree(nd); | ||
2691 | down_write(&s->s_umount); | 2782 | down_write(&s->s_umount); |
2692 | return 0; | 2783 | return 0; |
2784 | out_put_mnt_ns: | ||
2785 | put_mnt_ns(ns_private); | ||
2693 | out_mntput: | 2786 | out_mntput: |
2694 | mntput(root_mnt); | 2787 | mntput(root_mnt); |
2695 | out_err: | 2788 | out_err: |
2789 | kfree(nd); | ||
2696 | return ret; | 2790 | return ret; |
2697 | } | 2791 | } |
2698 | 2792 | ||
@@ -2811,7 +2905,7 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags, | |||
2811 | } else { | 2905 | } else { |
2812 | error = nfs_bdi_register(server); | 2906 | error = nfs_bdi_register(server); |
2813 | if (error) | 2907 | if (error) |
2814 | goto error_splat_super; | 2908 | goto error_splat_bdi; |
2815 | } | 2909 | } |
2816 | 2910 | ||
2817 | if (!s->s_root) { | 2911 | if (!s->s_root) { |
@@ -2847,6 +2941,9 @@ out_err_noserver: | |||
2847 | return error; | 2941 | return error; |
2848 | 2942 | ||
2849 | error_splat_super: | 2943 | error_splat_super: |
2944 | if (server && !s->s_root) | ||
2945 | bdi_unregister(&server->backing_dev_info); | ||
2946 | error_splat_bdi: | ||
2850 | deactivate_locked_super(s); | 2947 | deactivate_locked_super(s); |
2851 | dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error); | 2948 | dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error); |
2852 | return error; | 2949 | return error; |
@@ -2860,17 +2957,21 @@ static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type, | |||
2860 | struct super_block *s; | 2957 | struct super_block *s; |
2861 | struct nfs_server *server; | 2958 | struct nfs_server *server; |
2862 | struct dentry *mntroot; | 2959 | struct dentry *mntroot; |
2863 | struct nfs_fh mntfh; | 2960 | struct nfs_fh *mntfh; |
2864 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; | 2961 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; |
2865 | struct nfs_sb_mountdata sb_mntdata = { | 2962 | struct nfs_sb_mountdata sb_mntdata = { |
2866 | .mntflags = flags, | 2963 | .mntflags = flags, |
2867 | }; | 2964 | }; |
2868 | int error; | 2965 | int error = -ENOMEM; |
2869 | 2966 | ||
2870 | dprintk("--> nfs4_referral_get_sb()\n"); | 2967 | dprintk("--> nfs4_referral_get_sb()\n"); |
2871 | 2968 | ||
2969 | mntfh = nfs_alloc_fhandle(); | ||
2970 | if (mntfh == NULL) | ||
2971 | goto out_err_nofh; | ||
2972 | |||
2872 | /* create a new volume representation */ | 2973 | /* create a new volume representation */ |
2873 | server = nfs4_create_referral_server(data, &mntfh); | 2974 | server = nfs4_create_referral_server(data, mntfh); |
2874 | if (IS_ERR(server)) { | 2975 | if (IS_ERR(server)) { |
2875 | error = PTR_ERR(server); | 2976 | error = PTR_ERR(server); |
2876 | goto out_err_noserver; | 2977 | goto out_err_noserver; |
@@ -2893,7 +2994,7 @@ static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type, | |||
2893 | } else { | 2994 | } else { |
2894 | error = nfs_bdi_register(server); | 2995 | error = nfs_bdi_register(server); |
2895 | if (error) | 2996 | if (error) |
2896 | goto error_splat_super; | 2997 | goto error_splat_bdi; |
2897 | } | 2998 | } |
2898 | 2999 | ||
2899 | if (!s->s_root) { | 3000 | if (!s->s_root) { |
@@ -2902,7 +3003,7 @@ static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type, | |||
2902 | nfs_fscache_get_super_cookie(s, NULL, data); | 3003 | nfs_fscache_get_super_cookie(s, NULL, data); |
2903 | } | 3004 | } |
2904 | 3005 | ||
2905 | mntroot = nfs4_get_root(s, &mntfh); | 3006 | mntroot = nfs4_get_root(s, mntfh); |
2906 | if (IS_ERR(mntroot)) { | 3007 | if (IS_ERR(mntroot)) { |
2907 | error = PTR_ERR(mntroot); | 3008 | error = PTR_ERR(mntroot); |
2908 | goto error_splat_super; | 3009 | goto error_splat_super; |
@@ -2919,17 +3020,24 @@ static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type, | |||
2919 | 3020 | ||
2920 | security_sb_clone_mnt_opts(data->sb, s); | 3021 | security_sb_clone_mnt_opts(data->sb, s); |
2921 | 3022 | ||
3023 | nfs_free_fhandle(mntfh); | ||
2922 | dprintk("<-- nfs4_referral_get_sb() = 0\n"); | 3024 | dprintk("<-- nfs4_referral_get_sb() = 0\n"); |
2923 | return 0; | 3025 | return 0; |
2924 | 3026 | ||
2925 | out_err_nosb: | 3027 | out_err_nosb: |
2926 | nfs_free_server(server); | 3028 | nfs_free_server(server); |
2927 | out_err_noserver: | 3029 | out_err_noserver: |
3030 | nfs_free_fhandle(mntfh); | ||
3031 | out_err_nofh: | ||
2928 | dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error); | 3032 | dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error); |
2929 | return error; | 3033 | return error; |
2930 | 3034 | ||
2931 | error_splat_super: | 3035 | error_splat_super: |
3036 | if (server && !s->s_root) | ||
3037 | bdi_unregister(&server->backing_dev_info); | ||
3038 | error_splat_bdi: | ||
2932 | deactivate_locked_super(s); | 3039 | deactivate_locked_super(s); |
3040 | nfs_free_fhandle(mntfh); | ||
2933 | dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error); | 3041 | dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error); |
2934 | return error; | 3042 | return error; |
2935 | } | 3043 | } |
diff --git a/fs/nfs/symlink.c b/fs/nfs/symlink.c index 2ea9e5c27e55..05c9e02f4153 100644 --- a/fs/nfs/symlink.c +++ b/fs/nfs/symlink.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/pagemap.h> | 19 | #include <linux/pagemap.h> |
20 | #include <linux/stat.h> | 20 | #include <linux/stat.h> |
21 | #include <linux/mm.h> | 21 | #include <linux/mm.h> |
22 | #include <linux/slab.h> | ||
23 | #include <linux/string.h> | 22 | #include <linux/string.h> |
24 | #include <linux/namei.h> | 23 | #include <linux/namei.h> |
25 | 24 | ||
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 6da3d3ff6edd..a2242af6a17d 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c | |||
@@ -23,6 +23,7 @@ struct nfs_unlinkdata { | |||
23 | struct nfs_removeres res; | 23 | struct nfs_removeres res; |
24 | struct inode *dir; | 24 | struct inode *dir; |
25 | struct rpc_cred *cred; | 25 | struct rpc_cred *cred; |
26 | struct nfs_fattr dir_attr; | ||
26 | }; | 27 | }; |
27 | 28 | ||
28 | /** | 29 | /** |
@@ -169,7 +170,7 @@ static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct n | |||
169 | } | 170 | } |
170 | nfs_sb_active(dir->i_sb); | 171 | nfs_sb_active(dir->i_sb); |
171 | data->args.fh = NFS_FH(dir); | 172 | data->args.fh = NFS_FH(dir); |
172 | nfs_fattr_init(&data->res.dir_attr); | 173 | nfs_fattr_init(data->res.dir_attr); |
173 | 174 | ||
174 | NFS_PROTO(dir)->unlink_setup(&msg, dir); | 175 | NFS_PROTO(dir)->unlink_setup(&msg, dir); |
175 | 176 | ||
@@ -259,6 +260,7 @@ nfs_async_unlink(struct inode *dir, struct dentry *dentry) | |||
259 | goto out_free; | 260 | goto out_free; |
260 | } | 261 | } |
261 | data->res.seq_res.sr_slotid = NFS4_MAX_SLOT_TABLE; | 262 | data->res.seq_res.sr_slotid = NFS4_MAX_SLOT_TABLE; |
263 | data->res.dir_attr = &data->dir_attr; | ||
262 | 264 | ||
263 | status = -EBUSY; | 265 | status = -EBUSY; |
264 | spin_lock(&dentry->d_lock); | 266 | spin_lock(&dentry->d_lock); |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 53ff70e23993..3aea3ca98ab7 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -201,6 +201,7 @@ static int nfs_set_page_writeback(struct page *page) | |||
201 | struct inode *inode = page->mapping->host; | 201 | struct inode *inode = page->mapping->host; |
202 | struct nfs_server *nfss = NFS_SERVER(inode); | 202 | struct nfs_server *nfss = NFS_SERVER(inode); |
203 | 203 | ||
204 | page_cache_get(page); | ||
204 | if (atomic_long_inc_return(&nfss->writeback) > | 205 | if (atomic_long_inc_return(&nfss->writeback) > |
205 | NFS_CONGESTION_ON_THRESH) { | 206 | NFS_CONGESTION_ON_THRESH) { |
206 | set_bdi_congested(&nfss->backing_dev_info, | 207 | set_bdi_congested(&nfss->backing_dev_info, |
@@ -216,6 +217,7 @@ static void nfs_end_page_writeback(struct page *page) | |||
216 | struct nfs_server *nfss = NFS_SERVER(inode); | 217 | struct nfs_server *nfss = NFS_SERVER(inode); |
217 | 218 | ||
218 | end_page_writeback(page); | 219 | end_page_writeback(page); |
220 | page_cache_release(page); | ||
219 | if (atomic_long_dec_return(&nfss->writeback) < NFS_CONGESTION_OFF_THRESH) | 221 | if (atomic_long_dec_return(&nfss->writeback) < NFS_CONGESTION_OFF_THRESH) |
220 | clear_bdi_congested(&nfss->backing_dev_info, BLK_RW_ASYNC); | 222 | clear_bdi_congested(&nfss->backing_dev_info, BLK_RW_ASYNC); |
221 | } | 223 | } |
@@ -421,6 +423,7 @@ static void | |||
421 | nfs_mark_request_dirty(struct nfs_page *req) | 423 | nfs_mark_request_dirty(struct nfs_page *req) |
422 | { | 424 | { |
423 | __set_page_dirty_nobuffers(req->wb_page); | 425 | __set_page_dirty_nobuffers(req->wb_page); |
426 | __mark_inode_dirty(req->wb_page->mapping->host, I_DIRTY_DATASYNC); | ||
424 | } | 427 | } |
425 | 428 | ||
426 | #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) | 429 | #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) |
@@ -660,9 +663,11 @@ static int nfs_writepage_setup(struct nfs_open_context *ctx, struct page *page, | |||
660 | req = nfs_setup_write_request(ctx, page, offset, count); | 663 | req = nfs_setup_write_request(ctx, page, offset, count); |
661 | if (IS_ERR(req)) | 664 | if (IS_ERR(req)) |
662 | return PTR_ERR(req); | 665 | return PTR_ERR(req); |
666 | nfs_mark_request_dirty(req); | ||
663 | /* Update file length */ | 667 | /* Update file length */ |
664 | nfs_grow_file(page, offset, count); | 668 | nfs_grow_file(page, offset, count); |
665 | nfs_mark_uptodate(page, req->wb_pgbase, req->wb_bytes); | 669 | nfs_mark_uptodate(page, req->wb_pgbase, req->wb_bytes); |
670 | nfs_mark_request_dirty(req); | ||
666 | nfs_clear_page_tag_locked(req); | 671 | nfs_clear_page_tag_locked(req); |
667 | return 0; | 672 | return 0; |
668 | } | 673 | } |
@@ -739,8 +744,6 @@ int nfs_updatepage(struct file *file, struct page *page, | |||
739 | status = nfs_writepage_setup(ctx, page, offset, count); | 744 | status = nfs_writepage_setup(ctx, page, offset, count); |
740 | if (status < 0) | 745 | if (status < 0) |
741 | nfs_set_pageerror(page); | 746 | nfs_set_pageerror(page); |
742 | else | ||
743 | __set_page_dirty_nobuffers(page); | ||
744 | 747 | ||
745 | dprintk("NFS: nfs_updatepage returns %d (isize %lld)\n", | 748 | dprintk("NFS: nfs_updatepage returns %d (isize %lld)\n", |
746 | status, (long long)i_size_read(inode)); | 749 | status, (long long)i_size_read(inode)); |
@@ -749,13 +752,12 @@ int nfs_updatepage(struct file *file, struct page *page, | |||
749 | 752 | ||
750 | static void nfs_writepage_release(struct nfs_page *req) | 753 | static void nfs_writepage_release(struct nfs_page *req) |
751 | { | 754 | { |
755 | struct page *page = req->wb_page; | ||
752 | 756 | ||
753 | if (PageError(req->wb_page) || !nfs_reschedule_unstable_write(req)) { | 757 | if (PageError(req->wb_page) || !nfs_reschedule_unstable_write(req)) |
754 | nfs_end_page_writeback(req->wb_page); | ||
755 | nfs_inode_remove_request(req); | 758 | nfs_inode_remove_request(req); |
756 | } else | ||
757 | nfs_end_page_writeback(req->wb_page); | ||
758 | nfs_clear_page_tag_locked(req); | 759 | nfs_clear_page_tag_locked(req); |
760 | nfs_end_page_writeback(page); | ||
759 | } | 761 | } |
760 | 762 | ||
761 | static int flush_task_priority(int how) | 763 | static int flush_task_priority(int how) |
@@ -779,7 +781,6 @@ static int nfs_write_rpcsetup(struct nfs_page *req, | |||
779 | int how) | 781 | int how) |
780 | { | 782 | { |
781 | struct inode *inode = req->wb_context->path.dentry->d_inode; | 783 | struct inode *inode = req->wb_context->path.dentry->d_inode; |
782 | int flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; | ||
783 | int priority = flush_task_priority(how); | 784 | int priority = flush_task_priority(how); |
784 | struct rpc_task *task; | 785 | struct rpc_task *task; |
785 | struct rpc_message msg = { | 786 | struct rpc_message msg = { |
@@ -794,9 +795,10 @@ static int nfs_write_rpcsetup(struct nfs_page *req, | |||
794 | .callback_ops = call_ops, | 795 | .callback_ops = call_ops, |
795 | .callback_data = data, | 796 | .callback_data = data, |
796 | .workqueue = nfsiod_workqueue, | 797 | .workqueue = nfsiod_workqueue, |
797 | .flags = flags, | 798 | .flags = RPC_TASK_ASYNC, |
798 | .priority = priority, | 799 | .priority = priority, |
799 | }; | 800 | }; |
801 | int ret = 0; | ||
800 | 802 | ||
801 | /* Set up the RPC argument and reply structs | 803 | /* Set up the RPC argument and reply structs |
802 | * NB: take care not to mess about with data->commit et al. */ | 804 | * NB: take care not to mess about with data->commit et al. */ |
@@ -835,10 +837,18 @@ static int nfs_write_rpcsetup(struct nfs_page *req, | |||
835 | (unsigned long long)data->args.offset); | 837 | (unsigned long long)data->args.offset); |
836 | 838 | ||
837 | task = rpc_run_task(&task_setup_data); | 839 | task = rpc_run_task(&task_setup_data); |
838 | if (IS_ERR(task)) | 840 | if (IS_ERR(task)) { |
839 | return PTR_ERR(task); | 841 | ret = PTR_ERR(task); |
842 | goto out; | ||
843 | } | ||
844 | if (how & FLUSH_SYNC) { | ||
845 | ret = rpc_wait_for_completion_task(task); | ||
846 | if (ret == 0) | ||
847 | ret = task->tk_status; | ||
848 | } | ||
840 | rpc_put_task(task); | 849 | rpc_put_task(task); |
841 | return 0; | 850 | out: |
851 | return ret; | ||
842 | } | 852 | } |
843 | 853 | ||
844 | /* If a nfs_flush_* function fails, it should remove reqs from @head and | 854 | /* If a nfs_flush_* function fails, it should remove reqs from @head and |
@@ -847,9 +857,11 @@ static int nfs_write_rpcsetup(struct nfs_page *req, | |||
847 | */ | 857 | */ |
848 | static void nfs_redirty_request(struct nfs_page *req) | 858 | static void nfs_redirty_request(struct nfs_page *req) |
849 | { | 859 | { |
860 | struct page *page = req->wb_page; | ||
861 | |||
850 | nfs_mark_request_dirty(req); | 862 | nfs_mark_request_dirty(req); |
851 | nfs_end_page_writeback(req->wb_page); | ||
852 | nfs_clear_page_tag_locked(req); | 863 | nfs_clear_page_tag_locked(req); |
864 | nfs_end_page_writeback(page); | ||
853 | } | 865 | } |
854 | 866 | ||
855 | /* | 867 | /* |
@@ -1084,16 +1096,15 @@ static void nfs_writeback_release_full(void *calldata) | |||
1084 | if (nfs_write_need_commit(data)) { | 1096 | if (nfs_write_need_commit(data)) { |
1085 | memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf)); | 1097 | memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf)); |
1086 | nfs_mark_request_commit(req); | 1098 | nfs_mark_request_commit(req); |
1087 | nfs_end_page_writeback(page); | ||
1088 | dprintk(" marked for commit\n"); | 1099 | dprintk(" marked for commit\n"); |
1089 | goto next; | 1100 | goto next; |
1090 | } | 1101 | } |
1091 | dprintk(" OK\n"); | 1102 | dprintk(" OK\n"); |
1092 | remove_request: | 1103 | remove_request: |
1093 | nfs_end_page_writeback(page); | ||
1094 | nfs_inode_remove_request(req); | 1104 | nfs_inode_remove_request(req); |
1095 | next: | 1105 | next: |
1096 | nfs_clear_page_tag_locked(req); | 1106 | nfs_clear_page_tag_locked(req); |
1107 | nfs_end_page_writeback(page); | ||
1097 | } | 1108 | } |
1098 | nfs_writedata_release(calldata); | 1109 | nfs_writedata_release(calldata); |
1099 | } | 1110 | } |
@@ -1190,6 +1201,25 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data) | |||
1190 | 1201 | ||
1191 | 1202 | ||
1192 | #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) | 1203 | #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) |
1204 | static int nfs_commit_set_lock(struct nfs_inode *nfsi, int may_wait) | ||
1205 | { | ||
1206 | if (!test_and_set_bit(NFS_INO_COMMIT, &nfsi->flags)) | ||
1207 | return 1; | ||
1208 | if (may_wait && !out_of_line_wait_on_bit_lock(&nfsi->flags, | ||
1209 | NFS_INO_COMMIT, nfs_wait_bit_killable, | ||
1210 | TASK_KILLABLE)) | ||
1211 | return 1; | ||
1212 | return 0; | ||
1213 | } | ||
1214 | |||
1215 | static void nfs_commit_clear_lock(struct nfs_inode *nfsi) | ||
1216 | { | ||
1217 | clear_bit(NFS_INO_COMMIT, &nfsi->flags); | ||
1218 | smp_mb__after_clear_bit(); | ||
1219 | wake_up_bit(&nfsi->flags, NFS_INO_COMMIT); | ||
1220 | } | ||
1221 | |||
1222 | |||
1193 | static void nfs_commitdata_release(void *data) | 1223 | static void nfs_commitdata_release(void *data) |
1194 | { | 1224 | { |
1195 | struct nfs_write_data *wdata = data; | 1225 | struct nfs_write_data *wdata = data; |
@@ -1207,7 +1237,6 @@ static int nfs_commit_rpcsetup(struct list_head *head, | |||
1207 | { | 1237 | { |
1208 | struct nfs_page *first = nfs_list_entry(head->next); | 1238 | struct nfs_page *first = nfs_list_entry(head->next); |
1209 | struct inode *inode = first->wb_context->path.dentry->d_inode; | 1239 | struct inode *inode = first->wb_context->path.dentry->d_inode; |
1210 | int flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; | ||
1211 | int priority = flush_task_priority(how); | 1240 | int priority = flush_task_priority(how); |
1212 | struct rpc_task *task; | 1241 | struct rpc_task *task; |
1213 | struct rpc_message msg = { | 1242 | struct rpc_message msg = { |
@@ -1222,7 +1251,7 @@ static int nfs_commit_rpcsetup(struct list_head *head, | |||
1222 | .callback_ops = &nfs_commit_ops, | 1251 | .callback_ops = &nfs_commit_ops, |
1223 | .callback_data = data, | 1252 | .callback_data = data, |
1224 | .workqueue = nfsiod_workqueue, | 1253 | .workqueue = nfsiod_workqueue, |
1225 | .flags = flags, | 1254 | .flags = RPC_TASK_ASYNC, |
1226 | .priority = priority, | 1255 | .priority = priority, |
1227 | }; | 1256 | }; |
1228 | 1257 | ||
@@ -1282,6 +1311,7 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how) | |||
1282 | BDI_RECLAIMABLE); | 1311 | BDI_RECLAIMABLE); |
1283 | nfs_clear_page_tag_locked(req); | 1312 | nfs_clear_page_tag_locked(req); |
1284 | } | 1313 | } |
1314 | nfs_commit_clear_lock(NFS_I(inode)); | ||
1285 | return -ENOMEM; | 1315 | return -ENOMEM; |
1286 | } | 1316 | } |
1287 | 1317 | ||
@@ -1337,6 +1367,7 @@ static void nfs_commit_release(void *calldata) | |||
1337 | next: | 1367 | next: |
1338 | nfs_clear_page_tag_locked(req); | 1368 | nfs_clear_page_tag_locked(req); |
1339 | } | 1369 | } |
1370 | nfs_commit_clear_lock(NFS_I(data->inode)); | ||
1340 | nfs_commitdata_release(calldata); | 1371 | nfs_commitdata_release(calldata); |
1341 | } | 1372 | } |
1342 | 1373 | ||
@@ -1351,8 +1382,11 @@ static const struct rpc_call_ops nfs_commit_ops = { | |||
1351 | static int nfs_commit_inode(struct inode *inode, int how) | 1382 | static int nfs_commit_inode(struct inode *inode, int how) |
1352 | { | 1383 | { |
1353 | LIST_HEAD(head); | 1384 | LIST_HEAD(head); |
1354 | int res; | 1385 | int may_wait = how & FLUSH_SYNC; |
1386 | int res = 0; | ||
1355 | 1387 | ||
1388 | if (!nfs_commit_set_lock(NFS_I(inode), may_wait)) | ||
1389 | goto out; | ||
1356 | spin_lock(&inode->i_lock); | 1390 | spin_lock(&inode->i_lock); |
1357 | res = nfs_scan_commit(inode, &head, 0, 0); | 1391 | res = nfs_scan_commit(inode, &head, 0, 0); |
1358 | spin_unlock(&inode->i_lock); | 1392 | spin_unlock(&inode->i_lock); |
@@ -1360,7 +1394,13 @@ static int nfs_commit_inode(struct inode *inode, int how) | |||
1360 | int error = nfs_commit_list(inode, &head, how); | 1394 | int error = nfs_commit_list(inode, &head, how); |
1361 | if (error < 0) | 1395 | if (error < 0) |
1362 | return error; | 1396 | return error; |
1363 | } | 1397 | if (may_wait) |
1398 | wait_on_bit(&NFS_I(inode)->flags, NFS_INO_COMMIT, | ||
1399 | nfs_wait_bit_killable, | ||
1400 | TASK_KILLABLE); | ||
1401 | } else | ||
1402 | nfs_commit_clear_lock(NFS_I(inode)); | ||
1403 | out: | ||
1364 | return res; | 1404 | return res; |
1365 | } | 1405 | } |
1366 | 1406 | ||
@@ -1432,6 +1472,7 @@ int nfs_wb_page_cancel(struct inode *inode, struct page *page) | |||
1432 | 1472 | ||
1433 | BUG_ON(!PageLocked(page)); | 1473 | BUG_ON(!PageLocked(page)); |
1434 | for (;;) { | 1474 | for (;;) { |
1475 | wait_on_page_writeback(page); | ||
1435 | req = nfs_page_find_request(page); | 1476 | req = nfs_page_find_request(page); |
1436 | if (req == NULL) | 1477 | if (req == NULL) |
1437 | break; | 1478 | break; |
@@ -1466,30 +1507,18 @@ int nfs_wb_page(struct inode *inode, struct page *page) | |||
1466 | .range_start = range_start, | 1507 | .range_start = range_start, |
1467 | .range_end = range_end, | 1508 | .range_end = range_end, |
1468 | }; | 1509 | }; |
1469 | struct nfs_page *req; | ||
1470 | int need_commit; | ||
1471 | int ret; | 1510 | int ret; |
1472 | 1511 | ||
1473 | while(PagePrivate(page)) { | 1512 | while(PagePrivate(page)) { |
1513 | wait_on_page_writeback(page); | ||
1474 | if (clear_page_dirty_for_io(page)) { | 1514 | if (clear_page_dirty_for_io(page)) { |
1475 | ret = nfs_writepage_locked(page, &wbc); | 1515 | ret = nfs_writepage_locked(page, &wbc); |
1476 | if (ret < 0) | 1516 | if (ret < 0) |
1477 | goto out_error; | 1517 | goto out_error; |
1478 | } | 1518 | } |
1479 | req = nfs_find_and_lock_request(page); | 1519 | ret = sync_inode(inode, &wbc); |
1480 | if (!req) | 1520 | if (ret < 0) |
1481 | break; | ||
1482 | if (IS_ERR(req)) { | ||
1483 | ret = PTR_ERR(req); | ||
1484 | goto out_error; | 1521 | goto out_error; |
1485 | } | ||
1486 | need_commit = test_bit(PG_CLEAN, &req->wb_flags); | ||
1487 | nfs_clear_page_tag_locked(req); | ||
1488 | if (need_commit) { | ||
1489 | ret = nfs_commit_inode(inode, FLUSH_SYNC); | ||
1490 | if (ret < 0) | ||
1491 | goto out_error; | ||
1492 | } | ||
1493 | } | 1522 | } |
1494 | return 0; | 1523 | return 0; |
1495 | out_error: | 1524 | out_error: |