diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 13:18:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 13:18:44 -0400 |
commit | ade61088bc77dd209f8edadbe544f1e5dad6c287 (patch) | |
tree | 50a2eb0b78a470f379801a5abc73ff822f1e47c0 | |
parent | 7eb1053fd00a8f0e2263697638e17da8a251aa74 (diff) | |
parent | 0522f6adedd2736cbca3c0e16ca51df668993eee (diff) |
Merge branch 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6
* 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6:
NFS: Fix another nfs_wb_page() deadlock
NFS: Ensure that we mark the inode as dirty if we exit early from commit
NFS: Fix a lock imbalance typo in nfs_access_cache_shrinker
sunrpc: fix leak on error on socket xprt setup
-rw-r--r-- | fs/nfs/dir.c | 1 | ||||
-rw-r--r-- | fs/nfs/write.c | 20 | ||||
-rw-r--r-- | net/sunrpc/xprtsock.c | 29 |
3 files changed, 35 insertions, 15 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index ee9a179ebdf..db64854b7b0 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1741,6 +1741,7 @@ remove_lru_entry: | |||
1741 | 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(); | 1742 | smp_mb__after_clear_bit(); |
1743 | } | 1743 | } |
1744 | spin_unlock(&inode->i_lock); | ||
1744 | } | 1745 | } |
1745 | spin_unlock(&nfs_access_lru_lock); | 1746 | spin_unlock(&nfs_access_lru_lock); |
1746 | nfs_access_free_list(&head); | 1747 | nfs_access_free_list(&head); |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 3aea3ca98ab..91679e2631e 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -1386,7 +1386,7 @@ static int nfs_commit_inode(struct inode *inode, int how) | |||
1386 | int res = 0; | 1386 | int res = 0; |
1387 | 1387 | ||
1388 | if (!nfs_commit_set_lock(NFS_I(inode), may_wait)) | 1388 | if (!nfs_commit_set_lock(NFS_I(inode), may_wait)) |
1389 | goto out; | 1389 | goto out_mark_dirty; |
1390 | spin_lock(&inode->i_lock); | 1390 | spin_lock(&inode->i_lock); |
1391 | res = nfs_scan_commit(inode, &head, 0, 0); | 1391 | res = nfs_scan_commit(inode, &head, 0, 0); |
1392 | spin_unlock(&inode->i_lock); | 1392 | spin_unlock(&inode->i_lock); |
@@ -1398,9 +1398,18 @@ static int nfs_commit_inode(struct inode *inode, int how) | |||
1398 | wait_on_bit(&NFS_I(inode)->flags, NFS_INO_COMMIT, | 1398 | wait_on_bit(&NFS_I(inode)->flags, NFS_INO_COMMIT, |
1399 | nfs_wait_bit_killable, | 1399 | nfs_wait_bit_killable, |
1400 | TASK_KILLABLE); | 1400 | TASK_KILLABLE); |
1401 | else | ||
1402 | goto out_mark_dirty; | ||
1401 | } else | 1403 | } else |
1402 | nfs_commit_clear_lock(NFS_I(inode)); | 1404 | nfs_commit_clear_lock(NFS_I(inode)); |
1403 | out: | 1405 | return res; |
1406 | /* Note: If we exit without ensuring that the commit is complete, | ||
1407 | * we must mark the inode as dirty. Otherwise, future calls to | ||
1408 | * sync_inode() with the WB_SYNC_ALL flag set will fail to ensure | ||
1409 | * that the data is on the disk. | ||
1410 | */ | ||
1411 | out_mark_dirty: | ||
1412 | __mark_inode_dirty(inode, I_DIRTY_DATASYNC); | ||
1404 | return res; | 1413 | return res; |
1405 | } | 1414 | } |
1406 | 1415 | ||
@@ -1509,14 +1518,17 @@ int nfs_wb_page(struct inode *inode, struct page *page) | |||
1509 | }; | 1518 | }; |
1510 | int ret; | 1519 | int ret; |
1511 | 1520 | ||
1512 | while(PagePrivate(page)) { | 1521 | for (;;) { |
1513 | wait_on_page_writeback(page); | 1522 | wait_on_page_writeback(page); |
1514 | if (clear_page_dirty_for_io(page)) { | 1523 | if (clear_page_dirty_for_io(page)) { |
1515 | ret = nfs_writepage_locked(page, &wbc); | 1524 | ret = nfs_writepage_locked(page, &wbc); |
1516 | if (ret < 0) | 1525 | if (ret < 0) |
1517 | goto out_error; | 1526 | goto out_error; |
1527 | continue; | ||
1518 | } | 1528 | } |
1519 | ret = sync_inode(inode, &wbc); | 1529 | if (!PagePrivate(page)) |
1530 | break; | ||
1531 | ret = nfs_commit_inode(inode, FLUSH_SYNC); | ||
1520 | if (ret < 0) | 1532 | if (ret < 0) |
1521 | goto out_error; | 1533 | goto out_error; |
1522 | } | 1534 | } |
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index b7cd8cccbe7..2a9675136c6 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -2293,6 +2293,7 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args) | |||
2293 | struct sockaddr *addr = args->dstaddr; | 2293 | struct sockaddr *addr = args->dstaddr; |
2294 | struct rpc_xprt *xprt; | 2294 | struct rpc_xprt *xprt; |
2295 | struct sock_xprt *transport; | 2295 | struct sock_xprt *transport; |
2296 | struct rpc_xprt *ret; | ||
2296 | 2297 | ||
2297 | xprt = xs_setup_xprt(args, xprt_udp_slot_table_entries); | 2298 | xprt = xs_setup_xprt(args, xprt_udp_slot_table_entries); |
2298 | if (IS_ERR(xprt)) | 2299 | if (IS_ERR(xprt)) |
@@ -2330,8 +2331,8 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args) | |||
2330 | xs_format_peer_addresses(xprt, "udp", RPCBIND_NETID_UDP6); | 2331 | xs_format_peer_addresses(xprt, "udp", RPCBIND_NETID_UDP6); |
2331 | break; | 2332 | break; |
2332 | default: | 2333 | default: |
2333 | kfree(xprt); | 2334 | ret = ERR_PTR(-EAFNOSUPPORT); |
2334 | return ERR_PTR(-EAFNOSUPPORT); | 2335 | goto out_err; |
2335 | } | 2336 | } |
2336 | 2337 | ||
2337 | if (xprt_bound(xprt)) | 2338 | if (xprt_bound(xprt)) |
@@ -2346,10 +2347,11 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args) | |||
2346 | 2347 | ||
2347 | if (try_module_get(THIS_MODULE)) | 2348 | if (try_module_get(THIS_MODULE)) |
2348 | return xprt; | 2349 | return xprt; |
2349 | 2350 | ret = ERR_PTR(-EINVAL); | |
2351 | out_err: | ||
2350 | kfree(xprt->slot); | 2352 | kfree(xprt->slot); |
2351 | kfree(xprt); | 2353 | kfree(xprt); |
2352 | return ERR_PTR(-EINVAL); | 2354 | return ret; |
2353 | } | 2355 | } |
2354 | 2356 | ||
2355 | static const struct rpc_timeout xs_tcp_default_timeout = { | 2357 | static const struct rpc_timeout xs_tcp_default_timeout = { |
@@ -2368,6 +2370,7 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) | |||
2368 | struct sockaddr *addr = args->dstaddr; | 2370 | struct sockaddr *addr = args->dstaddr; |
2369 | struct rpc_xprt *xprt; | 2371 | struct rpc_xprt *xprt; |
2370 | struct sock_xprt *transport; | 2372 | struct sock_xprt *transport; |
2373 | struct rpc_xprt *ret; | ||
2371 | 2374 | ||
2372 | xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries); | 2375 | xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries); |
2373 | if (IS_ERR(xprt)) | 2376 | if (IS_ERR(xprt)) |
@@ -2403,8 +2406,8 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) | |||
2403 | xs_format_peer_addresses(xprt, "tcp", RPCBIND_NETID_TCP6); | 2406 | xs_format_peer_addresses(xprt, "tcp", RPCBIND_NETID_TCP6); |
2404 | break; | 2407 | break; |
2405 | default: | 2408 | default: |
2406 | kfree(xprt); | 2409 | ret = ERR_PTR(-EAFNOSUPPORT); |
2407 | return ERR_PTR(-EAFNOSUPPORT); | 2410 | goto out_err; |
2408 | } | 2411 | } |
2409 | 2412 | ||
2410 | if (xprt_bound(xprt)) | 2413 | if (xprt_bound(xprt)) |
@@ -2420,10 +2423,11 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) | |||
2420 | 2423 | ||
2421 | if (try_module_get(THIS_MODULE)) | 2424 | if (try_module_get(THIS_MODULE)) |
2422 | return xprt; | 2425 | return xprt; |
2423 | 2426 | ret = ERR_PTR(-EINVAL); | |
2427 | out_err: | ||
2424 | kfree(xprt->slot); | 2428 | kfree(xprt->slot); |
2425 | kfree(xprt); | 2429 | kfree(xprt); |
2426 | return ERR_PTR(-EINVAL); | 2430 | return ret; |
2427 | } | 2431 | } |
2428 | 2432 | ||
2429 | /** | 2433 | /** |
@@ -2437,6 +2441,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args) | |||
2437 | struct rpc_xprt *xprt; | 2441 | struct rpc_xprt *xprt; |
2438 | struct sock_xprt *transport; | 2442 | struct sock_xprt *transport; |
2439 | struct svc_sock *bc_sock; | 2443 | struct svc_sock *bc_sock; |
2444 | struct rpc_xprt *ret; | ||
2440 | 2445 | ||
2441 | xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries); | 2446 | xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries); |
2442 | if (IS_ERR(xprt)) | 2447 | if (IS_ERR(xprt)) |
@@ -2476,8 +2481,8 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args) | |||
2476 | RPCBIND_NETID_TCP6); | 2481 | RPCBIND_NETID_TCP6); |
2477 | break; | 2482 | break; |
2478 | default: | 2483 | default: |
2479 | kfree(xprt); | 2484 | ret = ERR_PTR(-EAFNOSUPPORT); |
2480 | return ERR_PTR(-EAFNOSUPPORT); | 2485 | goto out_err; |
2481 | } | 2486 | } |
2482 | 2487 | ||
2483 | if (xprt_bound(xprt)) | 2488 | if (xprt_bound(xprt)) |
@@ -2499,9 +2504,11 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args) | |||
2499 | 2504 | ||
2500 | if (try_module_get(THIS_MODULE)) | 2505 | if (try_module_get(THIS_MODULE)) |
2501 | return xprt; | 2506 | return xprt; |
2507 | ret = ERR_PTR(-EINVAL); | ||
2508 | out_err: | ||
2502 | kfree(xprt->slot); | 2509 | kfree(xprt->slot); |
2503 | kfree(xprt); | 2510 | kfree(xprt); |
2504 | return ERR_PTR(-EINVAL); | 2511 | return ret; |
2505 | } | 2512 | } |
2506 | 2513 | ||
2507 | static struct xprt_class xs_udp_transport = { | 2514 | static struct xprt_class xs_udp_transport = { |