diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-06-17 11:45:12 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-06-22 13:22:53 -0400 |
commit | 44950b67a6239b377a9e6fd52c498b310bcdd713 (patch) | |
tree | 9984e218b109965d5ac4b55a047838a385301010 | |
parent | b76ce56192bcf618013fb9aecd83488cffd645cc (diff) |
NFSv4.1: Ensure that we initialise the session when following a referral
Put the code that is common to both the referral and ordinary mount cases
into a common helper routine.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/client.c | 122 |
1 files changed, 51 insertions, 71 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); |