diff options
-rw-r--r-- | fs/nfs/client.c | 122 | ||||
-rw-r--r-- | fs/nfs/getroot.c | 2 | ||||
-rw-r--r-- | fs/nfs/nfs4xdr.c | 4 | ||||
-rw-r--r-- | fs/nfs/super.c | 22 | ||||
-rw-r--r-- | net/sunrpc/xprtsock.c | 38 |
5 files changed, 94 insertions, 94 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 7ec9b34a59f8..d25b5257b7a1 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -1286,6 +1286,55 @@ static void nfs4_session_set_rwsize(struct nfs_server *server) | |||
1286 | #endif /* CONFIG_NFS_V4_1 */ | 1286 | #endif /* CONFIG_NFS_V4_1 */ |
1287 | } | 1287 | } |
1288 | 1288 | ||
1289 | static int nfs4_server_common_setup(struct nfs_server *server, | ||
1290 | struct nfs_fh *mntfh) | ||
1291 | { | ||
1292 | struct nfs_fattr *fattr; | ||
1293 | int error; | ||
1294 | |||
1295 | BUG_ON(!server->nfs_client); | ||
1296 | BUG_ON(!server->nfs_client->rpc_ops); | ||
1297 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); | ||
1298 | |||
1299 | fattr = nfs_alloc_fattr(); | ||
1300 | if (fattr == NULL) | ||
1301 | return -ENOMEM; | ||
1302 | |||
1303 | /* We must ensure the session is initialised first */ | ||
1304 | error = nfs4_init_session(server); | ||
1305 | if (error < 0) | ||
1306 | goto out; | ||
1307 | |||
1308 | /* Probe the root fh to retrieve its FSID and filehandle */ | ||
1309 | error = nfs4_get_rootfh(server, mntfh); | ||
1310 | if (error < 0) | ||
1311 | goto out; | ||
1312 | |||
1313 | dprintk("Server FSID: %llx:%llx\n", | ||
1314 | (unsigned long long) server->fsid.major, | ||
1315 | (unsigned long long) server->fsid.minor); | ||
1316 | dprintk("Mount FH: %d\n", mntfh->size); | ||
1317 | |||
1318 | nfs4_session_set_rwsize(server); | ||
1319 | |||
1320 | error = nfs_probe_fsinfo(server, mntfh, fattr); | ||
1321 | if (error < 0) | ||
1322 | goto out; | ||
1323 | |||
1324 | if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN) | ||
1325 | server->namelen = NFS4_MAXNAMLEN; | ||
1326 | |||
1327 | spin_lock(&nfs_client_lock); | ||
1328 | list_add_tail(&server->client_link, &server->nfs_client->cl_superblocks); | ||
1329 | list_add_tail(&server->master_link, &nfs_volume_list); | ||
1330 | spin_unlock(&nfs_client_lock); | ||
1331 | |||
1332 | server->mount_time = jiffies; | ||
1333 | out: | ||
1334 | nfs_free_fattr(fattr); | ||
1335 | return error; | ||
1336 | } | ||
1337 | |||
1289 | /* | 1338 | /* |
1290 | * Create a version 4 volume record | 1339 | * Create a version 4 volume record |
1291 | */ | 1340 | */ |
@@ -1346,7 +1395,6 @@ error: | |||
1346 | struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, | 1395 | struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, |
1347 | struct nfs_fh *mntfh) | 1396 | struct nfs_fh *mntfh) |
1348 | { | 1397 | { |
1349 | struct nfs_fattr *fattr; | ||
1350 | struct nfs_server *server; | 1398 | struct nfs_server *server; |
1351 | int error; | 1399 | int error; |
1352 | 1400 | ||
@@ -1356,55 +1404,19 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, | |||
1356 | if (!server) | 1404 | if (!server) |
1357 | return ERR_PTR(-ENOMEM); | 1405 | return ERR_PTR(-ENOMEM); |
1358 | 1406 | ||
1359 | error = -ENOMEM; | ||
1360 | fattr = nfs_alloc_fattr(); | ||
1361 | if (fattr == NULL) | ||
1362 | goto error; | ||
1363 | |||
1364 | /* set up the general RPC client */ | 1407 | /* set up the general RPC client */ |
1365 | error = nfs4_init_server(server, data); | 1408 | error = nfs4_init_server(server, data); |
1366 | if (error < 0) | 1409 | if (error < 0) |
1367 | goto error; | 1410 | goto error; |
1368 | 1411 | ||
1369 | BUG_ON(!server->nfs_client); | 1412 | error = nfs4_server_common_setup(server, mntfh); |
1370 | BUG_ON(!server->nfs_client->rpc_ops); | ||
1371 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); | ||
1372 | |||
1373 | error = nfs4_init_session(server); | ||
1374 | if (error < 0) | ||
1375 | goto error; | ||
1376 | |||
1377 | /* Probe the root fh to retrieve its FSID */ | ||
1378 | error = nfs4_get_rootfh(server, mntfh); | ||
1379 | if (error < 0) | 1413 | if (error < 0) |
1380 | goto error; | 1414 | goto error; |
1381 | 1415 | ||
1382 | dprintk("Server FSID: %llx:%llx\n", | ||
1383 | (unsigned long long) server->fsid.major, | ||
1384 | (unsigned long long) server->fsid.minor); | ||
1385 | dprintk("Mount FH: %d\n", mntfh->size); | ||
1386 | |||
1387 | nfs4_session_set_rwsize(server); | ||
1388 | |||
1389 | error = nfs_probe_fsinfo(server, mntfh, fattr); | ||
1390 | if (error < 0) | ||
1391 | goto error; | ||
1392 | |||
1393 | if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN) | ||
1394 | server->namelen = NFS4_MAXNAMLEN; | ||
1395 | |||
1396 | spin_lock(&nfs_client_lock); | ||
1397 | list_add_tail(&server->client_link, &server->nfs_client->cl_superblocks); | ||
1398 | list_add_tail(&server->master_link, &nfs_volume_list); | ||
1399 | spin_unlock(&nfs_client_lock); | ||
1400 | |||
1401 | server->mount_time = jiffies; | ||
1402 | dprintk("<-- nfs4_create_server() = %p\n", server); | 1416 | dprintk("<-- nfs4_create_server() = %p\n", server); |
1403 | nfs_free_fattr(fattr); | ||
1404 | return server; | 1417 | return server; |
1405 | 1418 | ||
1406 | error: | 1419 | error: |
1407 | nfs_free_fattr(fattr); | ||
1408 | nfs_free_server(server); | 1420 | nfs_free_server(server); |
1409 | dprintk("<-- nfs4_create_server() = error %d\n", error); | 1421 | dprintk("<-- nfs4_create_server() = error %d\n", error); |
1410 | return ERR_PTR(error); | 1422 | return ERR_PTR(error); |
@@ -1418,7 +1430,6 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, | |||
1418 | { | 1430 | { |
1419 | struct nfs_client *parent_client; | 1431 | struct nfs_client *parent_client; |
1420 | struct nfs_server *server, *parent_server; | 1432 | struct nfs_server *server, *parent_server; |
1421 | struct nfs_fattr *fattr; | ||
1422 | int error; | 1433 | int error; |
1423 | 1434 | ||
1424 | dprintk("--> nfs4_create_referral_server()\n"); | 1435 | dprintk("--> nfs4_create_referral_server()\n"); |
@@ -1427,11 +1438,6 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, | |||
1427 | if (!server) | 1438 | if (!server) |
1428 | return ERR_PTR(-ENOMEM); | 1439 | return ERR_PTR(-ENOMEM); |
1429 | 1440 | ||
1430 | error = -ENOMEM; | ||
1431 | fattr = nfs_alloc_fattr(); | ||
1432 | if (fattr == NULL) | ||
1433 | goto error; | ||
1434 | |||
1435 | parent_server = NFS_SB(data->sb); | 1441 | parent_server = NFS_SB(data->sb); |
1436 | parent_client = parent_server->nfs_client; | 1442 | parent_client = parent_server->nfs_client; |
1437 | 1443 | ||
@@ -1456,40 +1462,14 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, | |||
1456 | if (error < 0) | 1462 | if (error < 0) |
1457 | goto error; | 1463 | goto error; |
1458 | 1464 | ||
1459 | BUG_ON(!server->nfs_client); | 1465 | error = nfs4_server_common_setup(server, mntfh); |
1460 | BUG_ON(!server->nfs_client->rpc_ops); | ||
1461 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); | ||
1462 | |||
1463 | /* Probe the root fh to retrieve its FSID and filehandle */ | ||
1464 | error = nfs4_get_rootfh(server, mntfh); | ||
1465 | if (error < 0) | ||
1466 | goto error; | ||
1467 | |||
1468 | /* probe the filesystem info for this server filesystem */ | ||
1469 | error = nfs_probe_fsinfo(server, mntfh, fattr); | ||
1470 | if (error < 0) | 1466 | if (error < 0) |
1471 | goto error; | 1467 | goto error; |
1472 | 1468 | ||
1473 | if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN) | ||
1474 | server->namelen = NFS4_MAXNAMLEN; | ||
1475 | |||
1476 | dprintk("Referral FSID: %llx:%llx\n", | ||
1477 | (unsigned long long) server->fsid.major, | ||
1478 | (unsigned long long) server->fsid.minor); | ||
1479 | |||
1480 | spin_lock(&nfs_client_lock); | ||
1481 | list_add_tail(&server->client_link, &server->nfs_client->cl_superblocks); | ||
1482 | list_add_tail(&server->master_link, &nfs_volume_list); | ||
1483 | spin_unlock(&nfs_client_lock); | ||
1484 | |||
1485 | server->mount_time = jiffies; | ||
1486 | |||
1487 | nfs_free_fattr(fattr); | ||
1488 | dprintk("<-- nfs_create_referral_server() = %p\n", server); | 1469 | dprintk("<-- nfs_create_referral_server() = %p\n", server); |
1489 | return server; | 1470 | return server; |
1490 | 1471 | ||
1491 | error: | 1472 | error: |
1492 | nfs_free_fattr(fattr); | ||
1493 | nfs_free_server(server); | 1473 | nfs_free_server(server); |
1494 | dprintk("<-- nfs4_create_referral_server() = error %d\n", error); | 1474 | dprintk("<-- nfs4_create_referral_server() = error %d\n", error); |
1495 | return ERR_PTR(error); | 1475 | return ERR_PTR(error); |
diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c index 7428f7d6273b..a70e446e1605 100644 --- a/fs/nfs/getroot.c +++ b/fs/nfs/getroot.c | |||
@@ -146,7 +146,7 @@ int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh) | |||
146 | goto out; | 146 | goto out; |
147 | } | 147 | } |
148 | 148 | ||
149 | if (!(fsinfo.fattr->valid & NFS_ATTR_FATTR_MODE) | 149 | if (!(fsinfo.fattr->valid & NFS_ATTR_FATTR_TYPE) |
150 | || !S_ISDIR(fsinfo.fattr->mode)) { | 150 | || !S_ISDIR(fsinfo.fattr->mode)) { |
151 | printk(KERN_ERR "nfs4_get_rootfh:" | 151 | printk(KERN_ERR "nfs4_get_rootfh:" |
152 | " getroot encountered non-directory\n"); | 152 | " getroot encountered non-directory\n"); |
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 6bdef28efa33..65c8dae4b267 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -862,8 +862,8 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const | |||
862 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; | 862 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
863 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); | 863 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
864 | *p++ = cpu_to_be32(0); | 864 | *p++ = cpu_to_be32(0); |
865 | *p++ = cpu_to_be32(iap->ia_mtime.tv_sec); | 865 | *p++ = cpu_to_be32(iap->ia_atime.tv_sec); |
866 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); | 866 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); |
867 | } | 867 | } |
868 | else if (iap->ia_valid & ATTR_ATIME) { | 868 | else if (iap->ia_valid & ATTR_ATIME) { |
869 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; | 869 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 04214fc5c304..f9df16de4a56 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -570,6 +570,22 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, | |||
570 | nfs_show_mountd_netid(m, nfss, showdefaults); | 570 | nfs_show_mountd_netid(m, nfss, showdefaults); |
571 | } | 571 | } |
572 | 572 | ||
573 | #ifdef CONFIG_NFS_V4 | ||
574 | static void nfs_show_nfsv4_options(struct seq_file *m, struct nfs_server *nfss, | ||
575 | int showdefaults) | ||
576 | { | ||
577 | struct nfs_client *clp = nfss->nfs_client; | ||
578 | |||
579 | seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr); | ||
580 | seq_printf(m, ",minorversion=%u", clp->cl_minorversion); | ||
581 | } | ||
582 | #else | ||
583 | static void nfs_show_nfsv4_options(struct seq_file *m, struct nfs_server *nfss, | ||
584 | int showdefaults) | ||
585 | { | ||
586 | } | ||
587 | #endif | ||
588 | |||
573 | /* | 589 | /* |
574 | * Describe the mount options in force on this server representation | 590 | * Describe the mount options in force on this server representation |
575 | */ | 591 | */ |
@@ -631,11 +647,9 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, | |||
631 | 647 | ||
632 | if (version != 4) | 648 | if (version != 4) |
633 | nfs_show_mountd_options(m, nfss, showdefaults); | 649 | nfs_show_mountd_options(m, nfss, showdefaults); |
650 | else | ||
651 | nfs_show_nfsv4_options(m, nfss, showdefaults); | ||
634 | 652 | ||
635 | #ifdef CONFIG_NFS_V4 | ||
636 | if (clp->rpc_ops->version == 4) | ||
637 | seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr); | ||
638 | #endif | ||
639 | if (nfss->options & NFS_OPTION_FSCACHE) | 653 | if (nfss->options & NFS_OPTION_FSCACHE) |
640 | seq_printf(m, ",fsc"); | 654 | seq_printf(m, ",fsc"); |
641 | } | 655 | } |
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 2a9675136c68..7ca65c7005ea 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -210,7 +210,8 @@ struct sock_xprt { | |||
210 | * State of TCP reply receive | 210 | * State of TCP reply receive |
211 | */ | 211 | */ |
212 | __be32 tcp_fraghdr, | 212 | __be32 tcp_fraghdr, |
213 | tcp_xid; | 213 | tcp_xid, |
214 | tcp_calldir; | ||
214 | 215 | ||
215 | u32 tcp_offset, | 216 | u32 tcp_offset, |
216 | tcp_reclen; | 217 | tcp_reclen; |
@@ -927,7 +928,7 @@ static inline void xs_tcp_read_calldir(struct sock_xprt *transport, | |||
927 | { | 928 | { |
928 | size_t len, used; | 929 | size_t len, used; |
929 | u32 offset; | 930 | u32 offset; |
930 | __be32 calldir; | 931 | char *p; |
931 | 932 | ||
932 | /* | 933 | /* |
933 | * We want transport->tcp_offset to be 8 at the end of this routine | 934 | * We want transport->tcp_offset to be 8 at the end of this routine |
@@ -936,26 +937,33 @@ static inline void xs_tcp_read_calldir(struct sock_xprt *transport, | |||
936 | * transport->tcp_offset is 4 (after having already read the xid). | 937 | * transport->tcp_offset is 4 (after having already read the xid). |
937 | */ | 938 | */ |
938 | offset = transport->tcp_offset - sizeof(transport->tcp_xid); | 939 | offset = transport->tcp_offset - sizeof(transport->tcp_xid); |
939 | len = sizeof(calldir) - offset; | 940 | len = sizeof(transport->tcp_calldir) - offset; |
940 | dprintk("RPC: reading CALL/REPLY flag (%Zu bytes)\n", len); | 941 | dprintk("RPC: reading CALL/REPLY flag (%Zu bytes)\n", len); |
941 | used = xdr_skb_read_bits(desc, &calldir, len); | 942 | p = ((char *) &transport->tcp_calldir) + offset; |
943 | used = xdr_skb_read_bits(desc, p, len); | ||
942 | transport->tcp_offset += used; | 944 | transport->tcp_offset += used; |
943 | if (used != len) | 945 | if (used != len) |
944 | return; | 946 | return; |
945 | transport->tcp_flags &= ~TCP_RCV_READ_CALLDIR; | 947 | transport->tcp_flags &= ~TCP_RCV_READ_CALLDIR; |
946 | transport->tcp_flags |= TCP_RCV_COPY_CALLDIR; | ||
947 | transport->tcp_flags |= TCP_RCV_COPY_DATA; | ||
948 | /* | 948 | /* |
949 | * We don't yet have the XDR buffer, so we will write the calldir | 949 | * We don't yet have the XDR buffer, so we will write the calldir |
950 | * out after we get the buffer from the 'struct rpc_rqst' | 950 | * out after we get the buffer from the 'struct rpc_rqst' |
951 | */ | 951 | */ |
952 | if (ntohl(calldir) == RPC_REPLY) | 952 | switch (ntohl(transport->tcp_calldir)) { |
953 | case RPC_REPLY: | ||
954 | transport->tcp_flags |= TCP_RCV_COPY_CALLDIR; | ||
955 | transport->tcp_flags |= TCP_RCV_COPY_DATA; | ||
953 | transport->tcp_flags |= TCP_RPC_REPLY; | 956 | transport->tcp_flags |= TCP_RPC_REPLY; |
954 | else | 957 | break; |
958 | case RPC_CALL: | ||
959 | transport->tcp_flags |= TCP_RCV_COPY_CALLDIR; | ||
960 | transport->tcp_flags |= TCP_RCV_COPY_DATA; | ||
955 | transport->tcp_flags &= ~TCP_RPC_REPLY; | 961 | transport->tcp_flags &= ~TCP_RPC_REPLY; |
956 | dprintk("RPC: reading %s CALL/REPLY flag %08x\n", | 962 | break; |
957 | (transport->tcp_flags & TCP_RPC_REPLY) ? | 963 | default: |
958 | "reply for" : "request with", calldir); | 964 | dprintk("RPC: invalid request message type\n"); |
965 | xprt_force_disconnect(&transport->xprt); | ||
966 | } | ||
959 | xs_tcp_check_fraghdr(transport); | 967 | xs_tcp_check_fraghdr(transport); |
960 | } | 968 | } |
961 | 969 | ||
@@ -975,12 +983,10 @@ static inline void xs_tcp_read_common(struct rpc_xprt *xprt, | |||
975 | /* | 983 | /* |
976 | * Save the RPC direction in the XDR buffer | 984 | * Save the RPC direction in the XDR buffer |
977 | */ | 985 | */ |
978 | __be32 calldir = transport->tcp_flags & TCP_RPC_REPLY ? | ||
979 | htonl(RPC_REPLY) : 0; | ||
980 | |||
981 | memcpy(rcvbuf->head[0].iov_base + transport->tcp_copied, | 986 | memcpy(rcvbuf->head[0].iov_base + transport->tcp_copied, |
982 | &calldir, sizeof(calldir)); | 987 | &transport->tcp_calldir, |
983 | transport->tcp_copied += sizeof(calldir); | 988 | sizeof(transport->tcp_calldir)); |
989 | transport->tcp_copied += sizeof(transport->tcp_calldir); | ||
984 | transport->tcp_flags &= ~TCP_RCV_COPY_CALLDIR; | 990 | transport->tcp_flags &= ~TCP_RCV_COPY_CALLDIR; |
985 | } | 991 | } |
986 | 992 | ||