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:
SUNRPC: Fix potential race in put_rpccred()
SUNRPC: Fix rpcauth_prune_expired
NFS: Convert nfs_attr_generation_counter into an atomic_long
SUNRPC: Respond promptly to server TCP resets

+61 -26
+3 -8
fs/nfs/inode.c
··· 908 908 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode); 909 909 } 910 910 911 - static unsigned long nfs_attr_generation_counter; 911 + static atomic_long_t nfs_attr_generation_counter; 912 912 913 913 static unsigned long nfs_read_attr_generation_counter(void) 914 914 { 915 - smp_rmb(); 916 - return nfs_attr_generation_counter; 915 + return atomic_long_read(&nfs_attr_generation_counter); 917 916 } 918 917 919 918 unsigned long nfs_inc_attr_generation_counter(void) 920 919 { 921 - unsigned long ret; 922 - smp_rmb(); 923 - ret = ++nfs_attr_generation_counter; 924 - smp_wmb(); 925 - return ret; 920 + return atomic_long_inc_return(&nfs_attr_generation_counter); 926 921 } 927 922 928 923 void nfs_fattr_init(struct nfs_fattr *fattr)
+10 -8
net/sunrpc/auth.c
··· 228 228 rpcauth_prune_expired(struct list_head *free, int nr_to_scan) 229 229 { 230 230 spinlock_t *cache_lock; 231 - struct rpc_cred *cred; 231 + struct rpc_cred *cred, *next; 232 232 unsigned long expired = jiffies - RPC_AUTH_EXPIRY_MORATORIUM; 233 233 234 - while (!list_empty(&cred_unused)) { 235 - cred = list_entry(cred_unused.next, struct rpc_cred, cr_lru); 234 + list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) { 235 + 236 + /* Enforce a 60 second garbage collection moratorium */ 237 + if (time_in_range(cred->cr_expire, expired, jiffies) && 238 + test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) 239 + continue; 240 + 236 241 list_del_init(&cred->cr_lru); 237 242 number_cred_unused--; 238 243 if (atomic_read(&cred->cr_count) != 0) 239 244 continue; 240 - /* Enforce a 5 second garbage collection moratorium */ 241 - if (time_in_range(cred->cr_expire, expired, jiffies) && 242 - test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0) 243 - continue; 245 + 244 246 cache_lock = &cred->cr_auth->au_credcache->lock; 245 247 spin_lock(cache_lock); 246 248 if (atomic_read(&cred->cr_count) == 0) { ··· 455 453 } 456 454 if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) == 0) 457 455 rpcauth_unhash_cred(cred); 458 - else if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) { 456 + if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) { 459 457 cred->cr_expire = jiffies; 460 458 list_add_tail(&cred->cr_lru, &cred_unused); 461 459 number_cred_unused++;
+48 -10
net/sunrpc/xprtsock.c
··· 249 249 void (*old_data_ready)(struct sock *, int); 250 250 void (*old_state_change)(struct sock *); 251 251 void (*old_write_space)(struct sock *); 252 + void (*old_error_report)(struct sock *); 252 253 }; 253 254 254 255 /* ··· 699 698 case -EAGAIN: 700 699 xs_nospace(task); 701 700 break; 702 - case -ECONNREFUSED: 703 701 case -ECONNRESET: 702 + xs_tcp_shutdown(xprt); 703 + case -ECONNREFUSED: 704 704 case -ENOTCONN: 705 705 case -EPIPE: 706 706 status = -ENOTCONN; ··· 744 742 xprt_release_xprt(xprt, task); 745 743 } 746 744 745 + static void xs_save_old_callbacks(struct sock_xprt *transport, struct sock *sk) 746 + { 747 + transport->old_data_ready = sk->sk_data_ready; 748 + transport->old_state_change = sk->sk_state_change; 749 + transport->old_write_space = sk->sk_write_space; 750 + transport->old_error_report = sk->sk_error_report; 751 + } 752 + 753 + static void xs_restore_old_callbacks(struct sock_xprt *transport, struct sock *sk) 754 + { 755 + sk->sk_data_ready = transport->old_data_ready; 756 + sk->sk_state_change = transport->old_state_change; 757 + sk->sk_write_space = transport->old_write_space; 758 + sk->sk_error_report = transport->old_error_report; 759 + } 760 + 747 761 /** 748 762 * xs_close - close a socket 749 763 * @xprt: transport ··· 783 765 transport->sock = NULL; 784 766 785 767 sk->sk_user_data = NULL; 786 - sk->sk_data_ready = transport->old_data_ready; 787 - sk->sk_state_change = transport->old_state_change; 788 - sk->sk_write_space = transport->old_write_space; 768 + 769 + xs_restore_old_callbacks(transport, sk); 789 770 write_unlock_bh(&sk->sk_callback_lock); 790 771 791 772 sk->sk_no_check = 0; ··· 1197 1180 } 1198 1181 1199 1182 /** 1183 + * xs_tcp_error_report - callback mainly for catching RST events 1184 + * @sk: socket 1185 + */ 1186 + static void xs_tcp_error_report(struct sock *sk) 1187 + { 1188 + struct rpc_xprt *xprt; 1189 + 1190 + read_lock(&sk->sk_callback_lock); 1191 + if (sk->sk_err != ECONNRESET || sk->sk_state != TCP_ESTABLISHED) 1192 + goto out; 1193 + if (!(xprt = xprt_from_sock(sk))) 1194 + goto out; 1195 + dprintk("RPC: %s client %p...\n" 1196 + "RPC: error %d\n", 1197 + __func__, xprt, sk->sk_err); 1198 + 1199 + xprt_force_disconnect(xprt); 1200 + out: 1201 + read_unlock(&sk->sk_callback_lock); 1202 + } 1203 + 1204 + /** 1200 1205 * xs_udp_write_space - callback invoked when socket buffer space 1201 1206 * becomes available 1202 1207 * @sk: socket whose state has changed ··· 1493 1454 1494 1455 write_lock_bh(&sk->sk_callback_lock); 1495 1456 1457 + xs_save_old_callbacks(transport, sk); 1458 + 1496 1459 sk->sk_user_data = xprt; 1497 - transport->old_data_ready = sk->sk_data_ready; 1498 - transport->old_state_change = sk->sk_state_change; 1499 - transport->old_write_space = sk->sk_write_space; 1500 1460 sk->sk_data_ready = xs_udp_data_ready; 1501 1461 sk->sk_write_space = xs_udp_write_space; 1502 1462 sk->sk_no_check = UDP_CSUM_NORCV; ··· 1627 1589 1628 1590 write_lock_bh(&sk->sk_callback_lock); 1629 1591 1592 + xs_save_old_callbacks(transport, sk); 1593 + 1630 1594 sk->sk_user_data = xprt; 1631 - transport->old_data_ready = sk->sk_data_ready; 1632 - transport->old_state_change = sk->sk_state_change; 1633 - transport->old_write_space = sk->sk_write_space; 1634 1595 sk->sk_data_ready = xs_tcp_data_ready; 1635 1596 sk->sk_state_change = xs_tcp_state_change; 1636 1597 sk->sk_write_space = xs_tcp_write_space; 1598 + sk->sk_error_report = xs_tcp_error_report; 1637 1599 sk->sk_allocation = GFP_ATOMIC; 1638 1600 1639 1601 /* socket options */