diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-04-16 16:22:46 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-05-14 15:09:22 -0400 |
commit | fbca779a8d240d82ef1439247033fd491f81547c (patch) | |
tree | 10e4a7469326c63127f6d5f419dd8048fb743cff /fs/nfs/client.c | |
parent | a4d7f16806e98cee752006d3a8c10067a7c2aa6b (diff) |
NFS: Reduce the stack footprint of nfs_create_server
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/client.c')
-rw-r--r-- | fs/nfs/client.c | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index ac5ff21bef16..7ec9b34a59f8 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -934,7 +934,6 @@ static int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, str | |||
934 | } | 934 | } |
935 | 935 | ||
936 | fsinfo.fattr = fattr; | 936 | fsinfo.fattr = fattr; |
937 | nfs_fattr_init(fattr); | ||
938 | error = clp->rpc_ops->fsinfo(server, mntfh, &fsinfo); | 937 | error = clp->rpc_ops->fsinfo(server, mntfh, &fsinfo); |
939 | if (error < 0) | 938 | if (error < 0) |
940 | goto out_error; | 939 | goto out_error; |
@@ -1047,13 +1046,18 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, | |||
1047 | struct nfs_fh *mntfh) | 1046 | struct nfs_fh *mntfh) |
1048 | { | 1047 | { |
1049 | struct nfs_server *server; | 1048 | struct nfs_server *server; |
1050 | struct nfs_fattr fattr; | 1049 | struct nfs_fattr *fattr; |
1051 | int error; | 1050 | int error; |
1052 | 1051 | ||
1053 | server = nfs_alloc_server(); | 1052 | server = nfs_alloc_server(); |
1054 | if (!server) | 1053 | if (!server) |
1055 | return ERR_PTR(-ENOMEM); | 1054 | return ERR_PTR(-ENOMEM); |
1056 | 1055 | ||
1056 | error = -ENOMEM; | ||
1057 | fattr = nfs_alloc_fattr(); | ||
1058 | if (fattr == NULL) | ||
1059 | goto error; | ||
1060 | |||
1057 | /* Get a client representation */ | 1061 | /* Get a client representation */ |
1058 | error = nfs_init_server(server, data); | 1062 | error = nfs_init_server(server, data); |
1059 | if (error < 0) | 1063 | if (error < 0) |
@@ -1064,7 +1068,7 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, | |||
1064 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); | 1068 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); |
1065 | 1069 | ||
1066 | /* Probe the root fh to retrieve its FSID */ | 1070 | /* Probe the root fh to retrieve its FSID */ |
1067 | error = nfs_probe_fsinfo(server, mntfh, &fattr); | 1071 | error = nfs_probe_fsinfo(server, mntfh, fattr); |
1068 | if (error < 0) | 1072 | if (error < 0) |
1069 | goto error; | 1073 | goto error; |
1070 | if (server->nfs_client->rpc_ops->version == 3) { | 1074 | if (server->nfs_client->rpc_ops->version == 3) { |
@@ -1077,14 +1081,14 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, | |||
1077 | server->namelen = NFS2_MAXNAMLEN; | 1081 | server->namelen = NFS2_MAXNAMLEN; |
1078 | } | 1082 | } |
1079 | 1083 | ||
1080 | if (!(fattr.valid & NFS_ATTR_FATTR)) { | 1084 | if (!(fattr->valid & NFS_ATTR_FATTR)) { |
1081 | error = server->nfs_client->rpc_ops->getattr(server, mntfh, &fattr); | 1085 | error = server->nfs_client->rpc_ops->getattr(server, mntfh, fattr); |
1082 | if (error < 0) { | 1086 | if (error < 0) { |
1083 | dprintk("nfs_create_server: getattr error = %d\n", -error); | 1087 | dprintk("nfs_create_server: getattr error = %d\n", -error); |
1084 | goto error; | 1088 | goto error; |
1085 | } | 1089 | } |
1086 | } | 1090 | } |
1087 | memcpy(&server->fsid, &fattr.fsid, sizeof(server->fsid)); | 1091 | memcpy(&server->fsid, &fattr->fsid, sizeof(server->fsid)); |
1088 | 1092 | ||
1089 | dprintk("Server FSID: %llx:%llx\n", | 1093 | dprintk("Server FSID: %llx:%llx\n", |
1090 | (unsigned long long) server->fsid.major, | 1094 | (unsigned long long) server->fsid.major, |
@@ -1096,9 +1100,11 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, | |||
1096 | spin_unlock(&nfs_client_lock); | 1100 | spin_unlock(&nfs_client_lock); |
1097 | 1101 | ||
1098 | server->mount_time = jiffies; | 1102 | server->mount_time = jiffies; |
1103 | nfs_free_fattr(fattr); | ||
1099 | return server; | 1104 | return server; |
1100 | 1105 | ||
1101 | error: | 1106 | error: |
1107 | nfs_free_fattr(fattr); | ||
1102 | nfs_free_server(server); | 1108 | nfs_free_server(server); |
1103 | return ERR_PTR(error); | 1109 | return ERR_PTR(error); |
1104 | } | 1110 | } |
@@ -1340,7 +1346,7 @@ error: | |||
1340 | 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, |
1341 | struct nfs_fh *mntfh) | 1347 | struct nfs_fh *mntfh) |
1342 | { | 1348 | { |
1343 | struct nfs_fattr fattr; | 1349 | struct nfs_fattr *fattr; |
1344 | struct nfs_server *server; | 1350 | struct nfs_server *server; |
1345 | int error; | 1351 | int error; |
1346 | 1352 | ||
@@ -1350,6 +1356,11 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, | |||
1350 | if (!server) | 1356 | if (!server) |
1351 | return ERR_PTR(-ENOMEM); | 1357 | return ERR_PTR(-ENOMEM); |
1352 | 1358 | ||
1359 | error = -ENOMEM; | ||
1360 | fattr = nfs_alloc_fattr(); | ||
1361 | if (fattr == NULL) | ||
1362 | goto error; | ||
1363 | |||
1353 | /* set up the general RPC client */ | 1364 | /* set up the general RPC client */ |
1354 | error = nfs4_init_server(server, data); | 1365 | error = nfs4_init_server(server, data); |
1355 | if (error < 0) | 1366 | if (error < 0) |
@@ -1375,7 +1386,7 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, | |||
1375 | 1386 | ||
1376 | nfs4_session_set_rwsize(server); | 1387 | nfs4_session_set_rwsize(server); |
1377 | 1388 | ||
1378 | error = nfs_probe_fsinfo(server, mntfh, &fattr); | 1389 | error = nfs_probe_fsinfo(server, mntfh, fattr); |
1379 | if (error < 0) | 1390 | if (error < 0) |
1380 | goto error; | 1391 | goto error; |
1381 | 1392 | ||
@@ -1389,9 +1400,11 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, | |||
1389 | 1400 | ||
1390 | server->mount_time = jiffies; | 1401 | server->mount_time = jiffies; |
1391 | dprintk("<-- nfs4_create_server() = %p\n", server); | 1402 | dprintk("<-- nfs4_create_server() = %p\n", server); |
1403 | nfs_free_fattr(fattr); | ||
1392 | return server; | 1404 | return server; |
1393 | 1405 | ||
1394 | error: | 1406 | error: |
1407 | nfs_free_fattr(fattr); | ||
1395 | nfs_free_server(server); | 1408 | nfs_free_server(server); |
1396 | dprintk("<-- nfs4_create_server() = error %d\n", error); | 1409 | dprintk("<-- nfs4_create_server() = error %d\n", error); |
1397 | return ERR_PTR(error); | 1410 | return ERR_PTR(error); |
@@ -1405,7 +1418,7 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, | |||
1405 | { | 1418 | { |
1406 | struct nfs_client *parent_client; | 1419 | struct nfs_client *parent_client; |
1407 | struct nfs_server *server, *parent_server; | 1420 | struct nfs_server *server, *parent_server; |
1408 | struct nfs_fattr fattr; | 1421 | struct nfs_fattr *fattr; |
1409 | int error; | 1422 | int error; |
1410 | 1423 | ||
1411 | dprintk("--> nfs4_create_referral_server()\n"); | 1424 | dprintk("--> nfs4_create_referral_server()\n"); |
@@ -1414,6 +1427,11 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, | |||
1414 | if (!server) | 1427 | if (!server) |
1415 | return ERR_PTR(-ENOMEM); | 1428 | return ERR_PTR(-ENOMEM); |
1416 | 1429 | ||
1430 | error = -ENOMEM; | ||
1431 | fattr = nfs_alloc_fattr(); | ||
1432 | if (fattr == NULL) | ||
1433 | goto error; | ||
1434 | |||
1417 | parent_server = NFS_SB(data->sb); | 1435 | parent_server = NFS_SB(data->sb); |
1418 | parent_client = parent_server->nfs_client; | 1436 | parent_client = parent_server->nfs_client; |
1419 | 1437 | ||
@@ -1448,7 +1466,7 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, | |||
1448 | goto error; | 1466 | goto error; |
1449 | 1467 | ||
1450 | /* probe the filesystem info for this server filesystem */ | 1468 | /* probe the filesystem info for this server filesystem */ |
1451 | error = nfs_probe_fsinfo(server, mntfh, &fattr); | 1469 | error = nfs_probe_fsinfo(server, mntfh, fattr); |
1452 | if (error < 0) | 1470 | if (error < 0) |
1453 | goto error; | 1471 | goto error; |
1454 | 1472 | ||
@@ -1466,10 +1484,12 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, | |||
1466 | 1484 | ||
1467 | server->mount_time = jiffies; | 1485 | server->mount_time = jiffies; |
1468 | 1486 | ||
1487 | nfs_free_fattr(fattr); | ||
1469 | dprintk("<-- nfs_create_referral_server() = %p\n", server); | 1488 | dprintk("<-- nfs_create_referral_server() = %p\n", server); |
1470 | return server; | 1489 | return server; |
1471 | 1490 | ||
1472 | error: | 1491 | error: |
1492 | nfs_free_fattr(fattr); | ||
1473 | nfs_free_server(server); | 1493 | nfs_free_server(server); |
1474 | dprintk("<-- nfs4_create_referral_server() = error %d\n", error); | 1494 | dprintk("<-- nfs4_create_referral_server() = error %d\n", error); |
1475 | return ERR_PTR(error); | 1495 | return ERR_PTR(error); |
@@ -1485,7 +1505,7 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source, | |||
1485 | struct nfs_fattr *fattr) | 1505 | struct nfs_fattr *fattr) |
1486 | { | 1506 | { |
1487 | struct nfs_server *server; | 1507 | struct nfs_server *server; |
1488 | struct nfs_fattr fattr_fsinfo; | 1508 | struct nfs_fattr *fattr_fsinfo; |
1489 | int error; | 1509 | int error; |
1490 | 1510 | ||
1491 | dprintk("--> nfs_clone_server(,%llx:%llx,)\n", | 1511 | dprintk("--> nfs_clone_server(,%llx:%llx,)\n", |
@@ -1496,6 +1516,11 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source, | |||
1496 | if (!server) | 1516 | if (!server) |
1497 | return ERR_PTR(-ENOMEM); | 1517 | return ERR_PTR(-ENOMEM); |
1498 | 1518 | ||
1519 | error = -ENOMEM; | ||
1520 | fattr_fsinfo = nfs_alloc_fattr(); | ||
1521 | if (fattr_fsinfo == NULL) | ||
1522 | goto out_free_server; | ||
1523 | |||
1499 | /* Copy data from the source */ | 1524 | /* Copy data from the source */ |
1500 | server->nfs_client = source->nfs_client; | 1525 | server->nfs_client = source->nfs_client; |
1501 | atomic_inc(&server->nfs_client->cl_count); | 1526 | atomic_inc(&server->nfs_client->cl_count); |
@@ -1512,7 +1537,7 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source, | |||
1512 | nfs_init_server_aclclient(server); | 1537 | nfs_init_server_aclclient(server); |
1513 | 1538 | ||
1514 | /* probe the filesystem info for this server filesystem */ | 1539 | /* probe the filesystem info for this server filesystem */ |
1515 | error = nfs_probe_fsinfo(server, fh, &fattr_fsinfo); | 1540 | error = nfs_probe_fsinfo(server, fh, fattr_fsinfo); |
1516 | if (error < 0) | 1541 | if (error < 0) |
1517 | goto out_free_server; | 1542 | goto out_free_server; |
1518 | 1543 | ||
@@ -1534,10 +1559,12 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source, | |||
1534 | 1559 | ||
1535 | server->mount_time = jiffies; | 1560 | server->mount_time = jiffies; |
1536 | 1561 | ||
1562 | nfs_free_fattr(fattr_fsinfo); | ||
1537 | dprintk("<-- nfs_clone_server() = %p\n", server); | 1563 | dprintk("<-- nfs_clone_server() = %p\n", server); |
1538 | return server; | 1564 | return server; |
1539 | 1565 | ||
1540 | out_free_server: | 1566 | out_free_server: |
1567 | nfs_free_fattr(fattr_fsinfo); | ||
1541 | nfs_free_server(server); | 1568 | nfs_free_server(server); |
1542 | dprintk("<-- nfs_clone_server() = error %d\n", error); | 1569 | dprintk("<-- nfs_clone_server() = error %d\n", error); |
1543 | return ERR_PTR(error); | 1570 | return ERR_PTR(error); |