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
This commit is contained in:
commit
1b2d3d94ec
@ -908,21 +908,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
|
||||
return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
|
||||
}
|
||||
|
||||
static unsigned long nfs_attr_generation_counter;
|
||||
static atomic_long_t nfs_attr_generation_counter;
|
||||
|
||||
static unsigned long nfs_read_attr_generation_counter(void)
|
||||
{
|
||||
smp_rmb();
|
||||
return nfs_attr_generation_counter;
|
||||
return atomic_long_read(&nfs_attr_generation_counter);
|
||||
}
|
||||
|
||||
unsigned long nfs_inc_attr_generation_counter(void)
|
||||
{
|
||||
unsigned long ret;
|
||||
smp_rmb();
|
||||
ret = ++nfs_attr_generation_counter;
|
||||
smp_wmb();
|
||||
return ret;
|
||||
return atomic_long_inc_return(&nfs_attr_generation_counter);
|
||||
}
|
||||
|
||||
void nfs_fattr_init(struct nfs_fattr *fattr)
|
||||
|
@ -228,19 +228,21 @@ static int
|
||||
rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
|
||||
{
|
||||
spinlock_t *cache_lock;
|
||||
struct rpc_cred *cred;
|
||||
struct rpc_cred *cred, *next;
|
||||
unsigned long expired = jiffies - RPC_AUTH_EXPIRY_MORATORIUM;
|
||||
|
||||
while (!list_empty(&cred_unused)) {
|
||||
cred = list_entry(cred_unused.next, struct rpc_cred, cr_lru);
|
||||
list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) {
|
||||
|
||||
/* Enforce a 60 second garbage collection moratorium */
|
||||
if (time_in_range(cred->cr_expire, expired, jiffies) &&
|
||||
test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0)
|
||||
continue;
|
||||
|
||||
list_del_init(&cred->cr_lru);
|
||||
number_cred_unused--;
|
||||
if (atomic_read(&cred->cr_count) != 0)
|
||||
continue;
|
||||
/* Enforce a 5 second garbage collection moratorium */
|
||||
if (time_in_range(cred->cr_expire, expired, jiffies) &&
|
||||
test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0)
|
||||
continue;
|
||||
|
||||
cache_lock = &cred->cr_auth->au_credcache->lock;
|
||||
spin_lock(cache_lock);
|
||||
if (atomic_read(&cred->cr_count) == 0) {
|
||||
@ -453,7 +455,7 @@ put_rpccred(struct rpc_cred *cred)
|
||||
}
|
||||
if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) == 0)
|
||||
rpcauth_unhash_cred(cred);
|
||||
else if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) {
|
||||
if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) {
|
||||
cred->cr_expire = jiffies;
|
||||
list_add_tail(&cred->cr_lru, &cred_unused);
|
||||
number_cred_unused++;
|
||||
|
@ -249,6 +249,7 @@ struct sock_xprt {
|
||||
void (*old_data_ready)(struct sock *, int);
|
||||
void (*old_state_change)(struct sock *);
|
||||
void (*old_write_space)(struct sock *);
|
||||
void (*old_error_report)(struct sock *);
|
||||
};
|
||||
|
||||
/*
|
||||
@ -698,8 +699,9 @@ static int xs_tcp_send_request(struct rpc_task *task)
|
||||
case -EAGAIN:
|
||||
xs_nospace(task);
|
||||
break;
|
||||
case -ECONNREFUSED:
|
||||
case -ECONNRESET:
|
||||
xs_tcp_shutdown(xprt);
|
||||
case -ECONNREFUSED:
|
||||
case -ENOTCONN:
|
||||
case -EPIPE:
|
||||
status = -ENOTCONN;
|
||||
@ -742,6 +744,22 @@ static void xs_tcp_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task)
|
||||
xprt_release_xprt(xprt, task);
|
||||
}
|
||||
|
||||
static void xs_save_old_callbacks(struct sock_xprt *transport, struct sock *sk)
|
||||
{
|
||||
transport->old_data_ready = sk->sk_data_ready;
|
||||
transport->old_state_change = sk->sk_state_change;
|
||||
transport->old_write_space = sk->sk_write_space;
|
||||
transport->old_error_report = sk->sk_error_report;
|
||||
}
|
||||
|
||||
static void xs_restore_old_callbacks(struct sock_xprt *transport, struct sock *sk)
|
||||
{
|
||||
sk->sk_data_ready = transport->old_data_ready;
|
||||
sk->sk_state_change = transport->old_state_change;
|
||||
sk->sk_write_space = transport->old_write_space;
|
||||
sk->sk_error_report = transport->old_error_report;
|
||||
}
|
||||
|
||||
/**
|
||||
* xs_close - close a socket
|
||||
* @xprt: transport
|
||||
@ -765,9 +783,8 @@ static void xs_close(struct rpc_xprt *xprt)
|
||||
transport->sock = NULL;
|
||||
|
||||
sk->sk_user_data = NULL;
|
||||
sk->sk_data_ready = transport->old_data_ready;
|
||||
sk->sk_state_change = transport->old_state_change;
|
||||
sk->sk_write_space = transport->old_write_space;
|
||||
|
||||
xs_restore_old_callbacks(transport, sk);
|
||||
write_unlock_bh(&sk->sk_callback_lock);
|
||||
|
||||
sk->sk_no_check = 0;
|
||||
@ -1179,6 +1196,28 @@ static void xs_tcp_state_change(struct sock *sk)
|
||||
read_unlock(&sk->sk_callback_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* xs_tcp_error_report - callback mainly for catching RST events
|
||||
* @sk: socket
|
||||
*/
|
||||
static void xs_tcp_error_report(struct sock *sk)
|
||||
{
|
||||
struct rpc_xprt *xprt;
|
||||
|
||||
read_lock(&sk->sk_callback_lock);
|
||||
if (sk->sk_err != ECONNRESET || sk->sk_state != TCP_ESTABLISHED)
|
||||
goto out;
|
||||
if (!(xprt = xprt_from_sock(sk)))
|
||||
goto out;
|
||||
dprintk("RPC: %s client %p...\n"
|
||||
"RPC: error %d\n",
|
||||
__func__, xprt, sk->sk_err);
|
||||
|
||||
xprt_force_disconnect(xprt);
|
||||
out:
|
||||
read_unlock(&sk->sk_callback_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* xs_udp_write_space - callback invoked when socket buffer space
|
||||
* becomes available
|
||||
@ -1454,10 +1493,9 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
|
||||
|
||||
write_lock_bh(&sk->sk_callback_lock);
|
||||
|
||||
xs_save_old_callbacks(transport, sk);
|
||||
|
||||
sk->sk_user_data = xprt;
|
||||
transport->old_data_ready = sk->sk_data_ready;
|
||||
transport->old_state_change = sk->sk_state_change;
|
||||
transport->old_write_space = sk->sk_write_space;
|
||||
sk->sk_data_ready = xs_udp_data_ready;
|
||||
sk->sk_write_space = xs_udp_write_space;
|
||||
sk->sk_no_check = UDP_CSUM_NORCV;
|
||||
@ -1589,13 +1627,13 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
|
||||
|
||||
write_lock_bh(&sk->sk_callback_lock);
|
||||
|
||||
xs_save_old_callbacks(transport, sk);
|
||||
|
||||
sk->sk_user_data = xprt;
|
||||
transport->old_data_ready = sk->sk_data_ready;
|
||||
transport->old_state_change = sk->sk_state_change;
|
||||
transport->old_write_space = sk->sk_write_space;
|
||||
sk->sk_data_ready = xs_tcp_data_ready;
|
||||
sk->sk_state_change = xs_tcp_state_change;
|
||||
sk->sk_write_space = xs_tcp_write_space;
|
||||
sk->sk_error_report = xs_tcp_error_report;
|
||||
sk->sk_allocation = GFP_ATOMIC;
|
||||
|
||||
/* socket options */
|
||||
|
Loading…
Reference in New Issue
Block a user