NFS client patches queued for 2.6.30
Subsystems (3)
cover NFS client patches queued for 2.6.30
The following series of patches are being queued for inclusion in kernel 2.6.30
---
Chuck Lever (1):
SUNRPC: Avoid spurious wake-up during UDP connect processing
NeilBrown (1):
NFS: flush cached directory information slightly more readily.
Suresh Jayaraman (1):
NFS: Minor __nfs_revalidate_inode cleanup
Tom Talpey (4):
NFS: load the rpc/rdma transport module automatically
SUNRPC: dynamically load RPC transport modules on-demand
XPRTRDMA: correct an rpc/rdma inline send marshaling error
SVCRDMA: remove faulty assertions in rpc/rdma chunk validation.
Trond Myklebust (23):
SUNRPC: xs_tcp_connect_worker{4,6}: merge common code
SUNRPC: Add a sysctl to control the duration of the socket linger timeout
SUNRPC: Add the equivalent of the linger and linger2 timeouts to RPC sockets
SUNRPC: Always report 'unrecognised error' cases...
SUNRPC: Ensure that xs_nospace return values are propagated
SUNRPC: Delay, then retry on connection errors.
SUNRPC: Return EAGAIN instead of ENOTCONN when waking up xprt->pending
SUNRPC: Handle socket errors correctly
SUNRPC: Handle ECONNREFUSED correctly in xprt_transmit()
SUNRPC: Don't disconnect if a connection is still in progress.
SUNRPC: Ensure we set XPRT_CLOSING only after we've sent a tcp FIN...
SUNRPC: Avoid an unnecessary task reschedule on ENOTCONN
NFS: Kill the "defined but not used" compile error on nommu machines
NFS: Throttle page dirtying while we're flushing to disk
NFS: cleanup - remove struct nfs_inode->ncommit
NFSv4: Simplify some cache consistency post-op GETATTRs
NFSv4: A referral is assumed to always point to a directory.
NFSv4: Make decode_getfattr() set fattr->valid to reflect what was decoded
NFSv4: Clean up decode_getfattr()
NFS: Fix the type of struct nfs_fattr->mode
NFS: Shrink the struct nfs_fattr
NFSv4: Support NFSv4 optional attributes in the struct nfs_fattr
NFSv4: Ignore errors on the post-op attributes in SETATTR calls
fs/nfs/file.c | 21 +- fs/nfs/getroot.c | 4 fs/nfs/inode.c | 268 ++++++++++++++++-------- fs/nfs/internal.h | 1 fs/nfs/nfs2xdr.c | 9 - fs/nfs/nfs3xdr.c | 37 ++- fs/nfs/nfs4proc.c | 37 ++- fs/nfs/nfs4xdr.c | 213 ++++++++++++++----- fs/nfs/pagelist.c | 11 - fs/nfs/super.c | 4 fs/nfs/write.c | 53 +++-- include/linux/nfs_fs.h | 4 include/linux/nfs_fs_sb.h | 5 include/linux/nfs_xdr.h | 58 ++++- include/linux/sunrpc/xprt.h | 2 net/sunrpc/clnt.c | 57 +++-- net/sunrpc/xprt.c | 89 +++++--- net/sunrpc/xprtrdma/rpc_rdma.c | 26 +- net/sunrpc/xprtrdma/svc_rdma_sendto.c | 8 - net/sunrpc/xprtsock.c | 361 +++++++++++++++++++++------------ 20 files changed, 810 insertions(+), 458 deletions(-)
Signature · 1 line
Signature
A message that is not in the archive (sent off-list or not yet received): 20090311184105.5578.22131.stgit-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
PATCH 1/30 SUNRPC: Avoid spurious wake-up during UDP connect processing
From: Chuck Lever <[email protected]>
To clear out old state, the UDP connect workers unconditionally invoke xs_close() before proceeding with a new connect. Nowadays this causes a spurious wake-up of the task waiting for the connect to complete.
This is a little racey, but usually harmless. The waiting task immediately retries the connect via a call_bind/call_connect sequence, which usually finds the transport already in the connected state because the connect worker has finished in the background.
To avoid a spurious wake-up, factor the xs_close() logic that resets the underlying socket into a helper, and have the UDP connect workers call that helper instead of xs_close().
---
net/sunrpc/xprtsock.c | 44 ++++++++++++++++++++++++++------------------ 1 files changed, 26 insertions(+), 18 deletions(-)
net/sunrpc/xprtsock.c +26 -18
@@ -767,23 +767,13 @@ static void xs_restore_old_callbacks(struct sock_xprt *transport, struct sock *s sk->sk_error_report = transport->old_error_report; } -/** -* xs_close - close a socket -* @xprt: transport -* -* This is used when all requests are complete; ie, no DRC state remains -* on the server we want to save. -*/ -static void xs_close (struct rpc_xprt *xprt) +static void xs_reset_transport (struct sock_xprt *transport) { - struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);struct socket *sock = transport->sock;struct sock *sk = transport->inet; -if (!sk) - goto clear_close_wait; - -dprintk ("RPC: xs_close xprt %p\n" , xprt); +if (sk ==NULL ) +return ;write_lock_bh (&sk->sk_callback_lock); transport->inet =NULL ;
@@ -797,7 +787,23 @@ static void xs_close(struct rpc_xprt *xprt) sk->sk_no_check =0 ;sock_release (sock); -clear_close_wait: +} + +/** +* xs_close - close a socket +* @xprt: transport +* +* This is used when all requests are complete; ie, no DRC state remains +* on the server we want to save. +*/ +static void xs_close (struct rpc_xprt *xprt) +{ + struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); + +dprintk ("RPC: xs_close xprt %p\n" , xprt); + +xs_reset_transport (transport); +smp_mb__before_clear_bit ();clear_bit (XPRT_CLOSE_WAIT , &xprt->state);clear_bit (XPRT_CLOSING , &xprt->state);
@@ -1537,9 +1543,10 @@ static void xs_udp_connect_worker4(struct work_struct *work) goto out;/* Start by resetting any existing state */ -xs_close (xprt); +xs_reset_transport (transport); -if ((err =sock_create_kern (PF_INET ,SOCK_DGRAM ,IPPROTO_UDP , &sock)) <0 ) { + err =sock_create_kern (PF_INET ,SOCK_DGRAM ,IPPROTO_UDP , &sock); +if (err <0 ) {dprintk ("RPC: can't create UDP transport socket (%d).\n" , -err); goto out; }
@@ -1578,9 +1585,10 @@ static void xs_udp_connect_worker6(struct work_struct *work) goto out;/* Start by resetting any existing state */ -xs_close (xprt); +xs_reset_transport (transport); -if ((err =sock_create_kern (PF_INET6 ,SOCK_DGRAM ,IPPROTO_UDP , &sock)) <0 ) { + err =sock_create_kern (PF_INET6 ,SOCK_DGRAM ,IPPROTO_UDP , &sock); +if (err <0 ) {dprintk ("RPC: can't create UDP transport socket (%d).\n" , -err); goto out; }
PATCH 2/30 NFS: Minor __nfs_revalidate_inode cleanup
In reply to a message not in the archiveFrom: Suresh Jayaraman <[email protected]>
Remove redundant NFS_STALE() check, a leftover due to the commit 691beb13cdc88358334ef0ba867c080a247a760f
---
fs/nfs/inode.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
fs/nfs/inode.c +0 -3
@@ -670,9 +670,6 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)if (NFS_STALE (inode)) goto out; -if (NFS_STALE (inode)) - goto out; -nfs_inc_stats (inode,NFSIOS_INODEREVALIDATE ); status =NFS_PROTO (inode)->getattr (server,NFS_FH (inode), &fattr);if (status !=0 ) {
PATCH 3/30 NFS: flush cached directory information slightly more readily.
In reply to a message not in the archiveFrom: NeilBrown <[email protected]>
If cached directory contents becomes incorrect, there is no way to flush the contents. This contrasts with files where file locking is the recommended way to ensure cache consistency between multiple applications (a read-lock always flushes the cache).
Also while changes to files often change the size of the file (thus triggering a cache flush), changes to directories often do not change the apparent size (as the size is often rounded to a block size).
So it is particularly important with directories to avoid the possibility of an incorrect cache wherever possible.
When the link count on a directory changes it implies a change in the number of child directories, and so a change in the contents of this directory. So use that as a trigger to flush cached contents.
When the ctime changes but the mtime does not, there are two possible reasons.
1/ The owner/mode information has been changed.
2/ utimes has been used to set the mtime backwards.
In the first case, a data-cache flush is not required. In the second case it is.
So on the basis that correctness trumps performance, flush the directory contents cache in this case also.
---
fs/nfs/inode.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-)
fs/nfs/inode.c +13 -2
@@ -1113,8 +1113,16 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)nfs_force_lookup_revalidate (inode); }/* If ctime has changed we should definitely clear access+acl caches */ -if (!timespec_equal (&inode->i_ctime, &fattr->ctime)) +if (!timespec_equal (&inode->i_ctime, &fattr->ctime)) { invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; +/* and probably clear data for a directory too as utimes can cause +* havoc with our cache. +*/ +if (S_ISDIR (inode->i_mode)) { + invalid |=NFS_INO_INVALID_DATA ; +nfs_force_lookup_revalidate (inode); + } + } }else if (nfsi->change_attr != fattr->change_attr) {dprintk ("NFS: change_attr change on server for file %s/%ld\n" , inode->i_sb->s_id, inode->i_ino);
@@ -1148,8 +1156,11 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) inode->i_gid != fattr->gid) invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; -if (inode->i_nlink != fattr->nlink) +if (inode->i_nlink != fattr->nlink) { invalid |=NFS_INO_INVALID_ATTR ; +if (S_ISDIR (inode->i_mode)) + invalid |=NFS_INO_INVALID_DATA ; + } inode->i_mode = fattr->mode; inode->i_nlink = fattr->nlink;
PATCH 4/30 NFSv4: Ignore errors on the post-op attributes in SETATTR calls
In reply to a message not in the archiveThere is no need to fail or retry a SETATTR call just because the post-op GETATTR failed.
---
fs/nfs/nfs4xdr.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
fs/nfs/nfs4xdr.c +1 -3
@@ -4078,9 +4078,7 @@ static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs_se status =decode_setattr (&xdr, res);if (status) goto out; - status =decode_getfattr (&xdr, res->fattr, res->server); -if (status ==NFS4ERR_DELAY ) - status =0 ; +decode_getfattr (&xdr, res->fattr, res->server); out:return status; }
PATCH 5/30 NFSv4: Support NFSv4 optional attributes in the struct nfs_fattr
In reply to a message not in the archiveCurrently, filling struct nfs_fattr is more or less an all or nothing operation, since NFSv2 and NFSv3 have only mandatory attributes. In NFSv4, some attributes are optional, and so we may simply not be able to fill in those fields. Furthermore, NFSv4 allows you to specify which attributes you are interested in retrieving, thus permitting you to optimise away retrieval of attributes that you know will no change...
---
fs/nfs/inode.c | 243 ++++++++++++++++++++++++++++++----------------- fs/nfs/nfs2xdr.c | 2 fs/nfs/nfs3xdr.c | 6 + fs/nfs/nfs4xdr.c | 6 + include/linux/nfs_xdr.h | 48 ++++++++- 5 files changed, 202 insertions(+), 103 deletions(-)
fs/nfs/inode.c +153 -90
@@ -249,13 +249,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)struct inode *inode =ERR_PTR (-ENOENT );unsigned long hash; -if ((fattr->valid &NFS_ATTR_FATTR ) ==0 ) +if ((fattr->valid &NFS_ATTR_FATTR_FILEID ) ==0 ) goto out_no_inode; - -if (!fattr->nlink) { -printk ("NFS: Buggy server - nlink == 0!\n" ); +if ((fattr->valid &NFS_ATTR_FATTR_TYPE ) ==0 ) goto out_no_inode; - } hash =nfs_fattr_to_ino_t (fattr);
@@ -291,7 +288,8 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) && fattr->size <= NFS_LIMIT_READDIRPLUS)set_bit (NFS_INO_ADVISE_RDPLUS , &NFS_I (inode)->flags);/* Deal with crossing mountpoints */ -if (!nfs_fsid_equal (&NFS_SB (sb)->fsid, &fattr->fsid)) { +if ((fattr->valid &NFS_ATTR_FATTR_FSID ) + && !nfs_fsid_equal (&NFS_SB (sb)->fsid, &fattr->fsid)) {if (fattr->valid &NFS_ATTR_FATTR_V4_REFERRAL ) inode->i_op = &nfs_referral_inode_operations;else
@@ -304,28 +302,45 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)else init_special_inode (inode, inode->i_mode, fattr->rdev); +memset (&inode->i_atime,0 ,sizeof (inode->i_atime)); +memset (&inode->i_mtime,0 ,sizeof (inode->i_mtime)); +memset (&inode->i_ctime,0 ,sizeof (inode->i_ctime)); + nfsi->change_attr =0 ; + inode->i_size =0 ; + inode->i_nlink =0 ; + inode->i_uid =-2 ; + inode->i_gid =-2 ; + inode->i_blocks =0 ; +memset (nfsi->cookieverf,0 ,sizeof (nfsi->cookieverf)); + nfsi->read_cache_jiffies = fattr->time_start; nfsi->attr_gencount = fattr->gencount; - inode->i_atime = fattr->atime; - inode->i_mtime = fattr->mtime; - inode->i_ctime = fattr->ctime; -if (fattr->valid &NFS_ATTR_FATTR_V4 ) +if (fattr->valid &NFS_ATTR_FATTR_ATIME ) + inode->i_atime = fattr->atime; +if (fattr->valid &NFS_ATTR_FATTR_MTIME ) + inode->i_mtime = fattr->mtime; +if (fattr->valid &NFS_ATTR_FATTR_CTIME ) + inode->i_ctime = fattr->ctime; +if (fattr->valid &NFS_ATTR_FATTR_CHANGE ) nfsi->change_attr = fattr->change_attr; - inode->i_size =nfs_size_to_loff_t (fattr->size); - inode->i_nlink = fattr->nlink; - inode->i_uid = fattr->uid; - inode->i_gid = fattr->gid; -if (fattr->valid & (NFS_ATTR_FATTR_V3 |NFS_ATTR_FATTR_V4 )) { +if (fattr->valid &NFS_ATTR_FATTR_SIZE ) + inode->i_size =nfs_size_to_loff_t (fattr->size); +if (fattr->valid &NFS_ATTR_FATTR_NLINK ) + inode->i_nlink = fattr->nlink; +if (fattr->valid &NFS_ATTR_FATTR_OWNER ) + inode->i_uid = fattr->uid; +if (fattr->valid &NFS_ATTR_FATTR_GROUP ) + inode->i_gid = fattr->gid; +if (fattr->valid &NFS_ATTR_FATTR_BLOCKS_USED ) + inode->i_blocks = fattr->du.nfs2.blocks; +if (fattr->valid &NFS_ATTR_FATTR_SPACE_USED ) {/* * report the blocks in 512byte units */ inode->i_blocks =nfs_calc_block_size (fattr->du.nfs3.used); - }else { - inode->i_blocks = fattr->du.nfs2.blocks; } nfsi->attrtimeo =NFS_MINATTRTIMEO (inode); nfsi->attrtimeo_timestamp = now; -memset (nfsi->cookieverf,0 ,sizeof (nfsi->cookieverf)); nfsi->access_cache =RB_ROOT ;unlock_new_inode (inode);
@@ -812,25 +827,31 @@ static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) {struct nfs_inode *nfsi =NFS_I (inode); -if ((fattr->valid &NFS_ATTR_WCC_V4 ) !=0 && - nfsi->change_attr == fattr->pre_change_attr) { +if ((fattr->valid &NFS_ATTR_FATTR_PRECHANGE ) + && (fattr->valid &NFS_ATTR_FATTR_CHANGE ) + && nfsi->change_attr == fattr->pre_change_attr) { nfsi->change_attr = fattr->change_attr;if (S_ISDIR (inode->i_mode)) nfsi->cache_validity |=NFS_INO_INVALID_DATA ; }/* If we have atomic WCC data, we may update some attributes */ -if ((fattr->valid &NFS_ATTR_WCC ) !=0 ) { -if (timespec_equal (&inode->i_ctime, &fattr->pre_ctime)) +if ((fattr->valid &NFS_ATTR_FATTR_PRECTIME ) + && (fattr->valid &NFS_ATTR_FATTR_CTIME ) + &×pec_equal (&inode->i_ctime, &fattr->pre_ctime))memcpy (&inode->i_ctime, &fattr->ctime,sizeof (inode->i_ctime)); -if (timespec_equal (&inode->i_mtime, &fattr->pre_mtime)) { + +if ((fattr->valid &NFS_ATTR_FATTR_PREMTIME ) + && (fattr->valid &NFS_ATTR_FATTR_MTIME ) + &×pec_equal (&inode->i_mtime, &fattr->pre_mtime)) {memcpy (&inode->i_mtime, &fattr->mtime,sizeof (inode->i_mtime));if (S_ISDIR (inode->i_mode)) nfsi->cache_validity |=NFS_INO_INVALID_DATA ; - } -if (i_size_read (inode) ==nfs_size_to_loff_t (fattr->pre_size) && - nfsi->npages ==0 ) -i_size_write (inode,nfs_size_to_loff_t (fattr->size)); } +if ((fattr->valid &NFS_ATTR_FATTR_PRESIZE ) + && (fattr->valid &NFS_ATTR_FATTR_SIZE ) + &&i_size_read (inode) ==nfs_size_to_loff_t (fattr->pre_size) + && nfsi->npages ==0 ) +i_size_write (inode,nfs_size_to_loff_t (fattr->size)); }/**
@@ -850,35 +871,39 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat/* Has the inode gone and changed behind our back? */ -if (nfsi->fileid != fattr->fileid - || (inode->i_mode &S_IFMT ) != (fattr->mode &S_IFMT )) { +if ((fattr->valid &NFS_ATTR_FATTR_FILEID ) && nfsi->fileid != fattr->fileid) +return -EIO ; +if ((fattr->valid &NFS_ATTR_FATTR_TYPE ) && (inode->i_mode &S_IFMT ) != (fattr->mode &S_IFMT ))return -EIO ; - } -if ((fattr->valid &NFS_ATTR_FATTR_V4 ) !=0 && +if ((fattr->valid &NFS_ATTR_FATTR_CHANGE ) !=0 && nfsi->change_attr != fattr->change_attr) invalid |=NFS_INO_INVALID_ATTR |NFS_INO_REVAL_PAGECACHE ;/* Verify a few of the more important attributes */ -if (!timespec_equal (&inode->i_mtime, &fattr->mtime)) +if ((fattr->valid &NFS_ATTR_FATTR_MTIME ) && !timespec_equal (&inode->i_mtime, &fattr->mtime)) invalid |=NFS_INO_INVALID_ATTR |NFS_INO_REVAL_PAGECACHE ; - cur_size =i_size_read (inode); - new_isize =nfs_size_to_loff_t (fattr->size); -if (cur_size != new_isize && nfsi->npages ==0 ) - invalid |=NFS_INO_INVALID_ATTR |NFS_INO_REVAL_PAGECACHE ; +if (fattr->valid &NFS_ATTR_FATTR_SIZE ) { + cur_size =i_size_read (inode); + new_isize =nfs_size_to_loff_t (fattr->size); +if (cur_size != new_isize && nfsi->npages ==0 ) + invalid |=NFS_INO_INVALID_ATTR |NFS_INO_REVAL_PAGECACHE ; + }/* Have any file permissions changed? */ -if ((inode->i_mode &S_IALLUGO ) != (fattr->mode &S_IALLUGO ) - || inode->i_uid != fattr->uid - || inode->i_gid != fattr->gid) +if ((fattr->valid &NFS_ATTR_FATTR_MODE ) && (inode->i_mode &S_IALLUGO ) != (fattr->mode &S_IALLUGO )) + invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; +if ((fattr->valid &NFS_ATTR_FATTR_OWNER ) && inode->i_uid != fattr->uid) + invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; +if ((fattr->valid &NFS_ATTR_FATTR_GROUP ) && inode->i_gid != fattr->gid) invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ;/* Has the link count changed? */ -if (inode->i_nlink != fattr->nlink) +if ((fattr->valid &NFS_ATTR_FATTR_NLINK ) && inode->i_nlink != fattr->nlink) invalid |=NFS_INO_INVALID_ATTR ; -if (!timespec_equal (&inode->i_atime, &fattr->atime)) +if ((fattr->valid &NFS_ATTR_FATTR_ATIME ) && !timespec_equal (&inode->i_atime, &fattr->atime)) invalid |=NFS_INO_INVALID_ATIME ;if (invalid !=0 )
@@ -890,11 +915,15 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fatstatic int nfs_ctime_need_update (const struct inode *inode,const struct nfs_fattr *fattr) { +if (!(fattr->valid &NFS_ATTR_FATTR_CTIME )) +return 0 ;return timespec_compare (&fattr->ctime, &inode->i_ctime) >0 ; }static int nfs_size_need_update (const struct inode *inode,const struct nfs_fattr *fattr) { +if (!(fattr->valid &NFS_ATTR_FATTR_SIZE )) +return 0 ;return nfs_size_to_loff_t (fattr->size) >i_size_read (inode); }
@@ -1030,20 +1059,31 @@ int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fa/* Don't do a WCC update if these attributes are already stale */ if ((fattr->valid &NFS_ATTR_FATTR ) ==0 || !nfs_inode_attrs_need_update (inode, fattr)) { - fattr->valid &= ~(NFS_ATTR_WCC_V4 |NFS_ATTR_WCC ); + fattr->valid &= ~(NFS_ATTR_FATTR_PRECHANGE + |NFS_ATTR_FATTR_PRESIZE + |NFS_ATTR_FATTR_PREMTIME + |NFS_ATTR_FATTR_PRECTIME ); goto out_noforce; } -if ((fattr->valid &NFS_ATTR_FATTR_V4 ) !=0 && - (fattr->valid &NFS_ATTR_WCC_V4 ) ==0 ) { +if ((fattr->valid &NFS_ATTR_FATTR_CHANGE ) !=0 && + (fattr->valid &NFS_ATTR_FATTR_PRECHANGE ) ==0 ) { fattr->pre_change_attr =NFS_I (inode)->change_attr; - fattr->valid |=NFS_ATTR_WCC_V4 ; + fattr->valid |=NFS_ATTR_FATTR_PRECHANGE ; } -if ((fattr->valid &NFS_ATTR_FATTR ) !=0 && - (fattr->valid &NFS_ATTR_WCC ) ==0 ) { +if ((fattr->valid &NFS_ATTR_FATTR_CTIME ) !=0 && + (fattr->valid &NFS_ATTR_FATTR_PRECTIME ) ==0 ) {memcpy (&fattr->pre_ctime, &inode->i_ctime,sizeof (fattr->pre_ctime)); + fattr->valid |=NFS_ATTR_FATTR_PRECTIME ; + } +if ((fattr->valid &NFS_ATTR_FATTR_MTIME ) !=0 && + (fattr->valid &NFS_ATTR_FATTR_PREMTIME ) ==0 ) {memcpy (&fattr->pre_mtime, &inode->i_mtime,sizeof (fattr->pre_mtime)); + fattr->valid |=NFS_ATTR_FATTR_PREMTIME ; + } +if ((fattr->valid &NFS_ATTR_FATTR_SIZE ) !=0 && + (fattr->valid &NFS_ATTR_FATTR_PRESIZE ) ==0 ) { fattr->pre_size =i_size_read (inode); - fattr->valid |=NFS_ATTR_WCC ; + fattr->valid |=NFS_ATTR_FATTR_PRESIZE ; } out_noforce: status =nfs_post_op_update_inode_locked (inode, fattr);
@@ -1075,18 +1115,18 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) __func__, inode->i_sb->s_id, inode->i_ino, atomic_read(&inode->i_count), fattr->valid); -if (nfsi->fileid != fattr->fileid) +if ((fattr->valid &NFS_ATTR_FATTR_FILEID ) && nfsi->fileid != fattr->fileid) goto out_fileid;/* * Make sure the inode's type hasn't changed. */ -if ((inode->i_mode &S_IFMT ) != (fattr->mode &S_IFMT )) +if ((fattr->valid &NFS_ATTR_FATTR_TYPE ) && (inode->i_mode &S_IFMT ) != (fattr->mode &S_IFMT )) goto out_changed; server =NFS_SERVER (inode);/* Update the fsid? */ -if (S_ISDIR (inode->i_mode) && +if (S_ISDIR (inode->i_mode) && (fattr->valid &NFS_ATTR_FATTR_FSID ) && !nfs_fsid_equal (&server->fsid, &fattr->fsid) && !test_bit (NFS_INO_MOUNTPOINT , &nfsi->flags)) server->fsid = fattr->fsid;
@@ -1096,14 +1136,27 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)*/ nfsi->read_cache_jiffies = fattr->time_start; - nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ATIME - |NFS_INO_REVAL_PAGECACHE ); +if ((fattr->valid &NFS_ATTR_FATTR_CHANGE ) || (fattr->valid & (NFS_ATTR_FATTR_MTIME |NFS_ATTR_FATTR_CTIME ))) + nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR + |NFS_INO_INVALID_ATIME + |NFS_INO_REVAL_PAGECACHE );/* Do atomic weak cache consistency updates */ nfs_wcc_update_inode (inode, fattr);/* More cache consistency checks */ -if (!(fattr->valid &NFS_ATTR_FATTR_V4 )) { +if (fattr->valid &NFS_ATTR_FATTR_CHANGE ) { +if (nfsi->change_attr != fattr->change_attr) { +dprintk ("NFS: change_attr change on server for file %s/%ld\n" , + inode->i_sb->s_id, inode->i_ino); + invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_DATA |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; +if (S_ISDIR (inode->i_mode)) +nfs_force_lookup_revalidate (inode); + nfsi->change_attr = fattr->change_attr; + } + } + +if (fattr->valid &NFS_ATTR_FATTR_MTIME ) {/* NFSv2/v3: Check if the mtime agrees */ if (!timespec_equal (&inode->i_mtime, &fattr->mtime)) { dprintk("NFS: mtime change on server for file %s/%ld\n",
@@ -1111,7 +1164,10 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_DATA ;if (S_ISDIR (inode->i_mode))nfs_force_lookup_revalidate (inode); +memcpy (&inode->i_mtime, &fattr->mtime,sizeof (inode->i_mtime)); } + } +if (fattr->valid &NFS_ATTR_FATTR_CTIME ) {/* If ctime has changed we should definitely clear access+acl caches */ if (!timespec_equal (&inode->i_ctime, &fattr->ctime)) { invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ;
@@ -1122,59 +1178,66 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) invalid |=NFS_INO_INVALID_DATA ;nfs_force_lookup_revalidate (inode); } +memcpy (&inode->i_ctime, &fattr->ctime,sizeof (inode->i_ctime)); } - }else if (nfsi->change_attr != fattr->change_attr) { -dprintk ("NFS: change_attr change on server for file %s/%ld\n" , - inode->i_sb->s_id, inode->i_ino); - invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_DATA |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; -if (S_ISDIR (inode->i_mode)) -nfs_force_lookup_revalidate (inode); }/* Check if our cached file size is stale */ - new_isize =nfs_size_to_loff_t (fattr->size); - cur_isize =i_size_read (inode); -if (new_isize != cur_isize) { -/* Do we perhaps have any outstanding writes, or has -* the file grown beyond our last write? */ -if (nfsi->npages ==0 || new_isize > cur_isize) { -i_size_write (inode, new_isize); - invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_DATA ; +if (fattr->valid &NFS_ATTR_FATTR_SIZE ) { + new_isize =nfs_size_to_loff_t (fattr->size); + cur_isize =i_size_read (inode); +if (new_isize != cur_isize) { +/* Do we perhaps have any outstanding writes, or has +* the file grown beyond our last write? */ +if (nfsi->npages ==0 || new_isize > cur_isize) { +i_size_write (inode, new_isize); + invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_DATA ; + } +dprintk ("NFS: isize change on server for file %s/%ld\n" , + inode->i_sb->s_id, inode->i_ino); } -dprintk ("NFS: isize change on server for file %s/%ld\n" , - inode->i_sb->s_id, inode->i_ino); } -memcpy (&inode->i_mtime, &fattr->mtime,sizeof (inode->i_mtime)); -memcpy (&inode->i_ctime, &fattr->ctime,sizeof (inode->i_ctime)); -memcpy (&inode->i_atime, &fattr->atime,sizeof (inode->i_atime)); - nfsi->change_attr = fattr->change_attr; +if (fattr->valid &NFS_ATTR_FATTR_ATIME ) +memcpy (&inode->i_atime, &fattr->atime,sizeof (inode->i_atime)); -if ((inode->i_mode &S_IALLUGO ) != (fattr->mode &S_IALLUGO ) || - inode->i_uid != fattr->uid || - inode->i_gid != fattr->gid) - invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; - -if (inode->i_nlink != fattr->nlink) { - invalid |=NFS_INO_INVALID_ATTR ; -if (S_ISDIR (inode->i_mode)) - invalid |=NFS_INO_INVALID_DATA ; +if (fattr->valid &NFS_ATTR_FATTR_MODE ) { +if ((inode->i_mode &S_IALLUGO ) != (fattr->mode &S_IALLUGO )) { + invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; + inode->i_mode = fattr->mode; + } + } +if (fattr->valid &NFS_ATTR_FATTR_OWNER ) { +if (inode->i_uid != fattr->uid) { + invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; + inode->i_uid = fattr->uid; + } + } +if (fattr->valid &NFS_ATTR_FATTR_GROUP ) { +if (inode->i_gid != fattr->gid) { + invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; + inode->i_gid = fattr->gid; + } } - inode->i_mode = fattr->mode; - inode->i_nlink = fattr->nlink; - inode->i_uid = fattr->uid; - inode->i_gid = fattr->gid; +if (fattr->valid &NFS_ATTR_FATTR_NLINK ) { +if (inode->i_nlink != fattr->nlink) { + invalid |=NFS_INO_INVALID_ATTR ; +if (S_ISDIR (inode->i_mode)) + invalid |=NFS_INO_INVALID_DATA ; + inode->i_nlink = fattr->nlink; + } + } -if (fattr->valid & (NFS_ATTR_FATTR_V3 |NFS_ATTR_FATTR_V4 )) { +if (fattr->valid &NFS_ATTR_FATTR_SPACE_USED ) {/* * report the blocks in 512byte units */ inode->i_blocks =nfs_calc_block_size (fattr->du.nfs3.used); - }else { - inode->i_blocks = fattr->du.nfs2.blocks; } +if (fattr->valid &NFS_ATTR_FATTR_BLOCKS_USED ) + inode->i_blocks = fattr->du.nfs2.blocks;/* Update attrtimeo value if we're out of the unstable period */ if (invalid &NFS_INO_INVALID_ATTR ) {
fs/nfs/nfs2xdr.c +1 -1
@@ -136,7 +136,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr) p =xdr_decode_time (p, &fattr->atime); p =xdr_decode_time (p, &fattr->mtime); p =xdr_decode_time (p, &fattr->ctime); - fattr->valid |=NFS_ATTR_FATTR ; + fattr->valid |=NFS_ATTR_FATTR_V2 ; fattr->rdev =new_decode_dev (rdev);if (fattr->type ==NFCHR && rdev ==NFS2_FIFO_DEV ) { fattr->type =NFFIFO ;
fs/nfs/nfs3xdr.c +4 -2
@@ -177,7 +177,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr) p =xdr_decode_time3 (p, &fattr->ctime);/* Update the mode bits */ - fattr->valid |= (NFS_ATTR_FATTR |NFS_ATTR_FATTR_V3 ); + fattr->valid |=NFS_ATTR_FATTR_V3 ;return p; }
@@ -233,7 +233,9 @@ xdr_decode_wcc_attr(__be32 *p, struct nfs_fattr *fattr) p =xdr_decode_hyper (p, &fattr->pre_size); p =xdr_decode_time3 (p, &fattr->pre_mtime); p =xdr_decode_time3 (p, &fattr->pre_ctime); - fattr->valid |=NFS_ATTR_WCC ; + fattr->valid |=NFS_ATTR_FATTR_PRESIZE + |NFS_ATTR_FATTR_PREMTIME + |NFS_ATTR_FATTR_PRECTIME ;return p; }
fs/nfs/nfs4xdr.c +3 -3
@@ -3012,7 +3012,7 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, consif ((status =decode_attr_type (xdr, bitmap, &type)) !=0 ) goto xdr_error; fattr->type = nfs_type2fmt[type].nfs2type; - fmode = nfs_type2fmt[type].mode; + fattr->mode = nfs_type2fmt[type].mode;if ((status =decode_attr_change (xdr, bitmap, &fattr->change_attr)) !=0 ) goto xdr_error;
@@ -3026,7 +3026,7 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, cons struct nfs4_fs_locations, fattr))) != 0) goto xdr_error; -if ((status =decode_attr_mode (xdr, bitmap, &fattr->mode)) !=0 ) +if ((status =decode_attr_mode (xdr, bitmap, &fmode)) !=0 ) goto xdr_error; fattr->mode |= fmode;if ((status =decode_attr_nlink (xdr, bitmap, &fattr->nlink)) !=0 )
@@ -3050,7 +3050,7 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, consif (fattr->fileid ==0 && fileid !=0 ) fattr->fileid = fileid;if ((status =verify_attr_len (xdr, savep, attrlen)) ==0 ) - fattr->valid =NFS_ATTR_FATTR |NFS_ATTR_FATTR_V3 |NFS_ATTR_FATTR_V4 ; + fattr->valid =NFS_ATTR_FATTR_V4 ; xdr_error:dprintk ("%s: xdr returned %d\n" , __func__, -status);return status;
include/linux/nfs_xdr.h +41 -7
60 lines not on this page · raw message
PATCH 6/30 NFS: Shrink the struct nfs_fattr
In reply to a message not in the archiveWe don't need the bitmap[] field anymore, since the 'valid' field tells us all we need to know about which attributes were filled in... Also move the pre-op attributes in order to improve the structure packing.
---
fs/nfs/nfs4xdr.c | 3 --- include/linux/nfs_xdr.h | 7 +++---- 2 files changed, 3 insertions(+), 7 deletions(-)
fs/nfs/nfs4xdr.c +0 -3
@@ -3002,9 +3002,6 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, consif ((status =decode_attr_bitmap (xdr, bitmap)) !=0 ) goto xdr_error; - fattr->bitmap[0 ] = bitmap[0 ]; - fattr->bitmap[1 ] = bitmap[1 ]; -if ((status =decode_attr_length (xdr, &attrlen, &savep)) !=0 ) goto xdr_error;
include/linux/nfs_xdr.h +3 -4
@@ -28,9 +28,6 @@ static inline int nfs_fsid_equal(const struct nfs_fsid *a, const struct nfs_fsidstruct nfs_fattr {unsigned int valid;/* which fields are valid */ -__u64 pre_size;/* pre_op_attr.size */ -struct timespec pre_mtime;/* pre_op_attr.mtime */ -struct timespec pre_ctime;/* pre_op_attr.ctime */ enum nfs_ftype type;/* always use NFSv2 types */ __u32 mode;__u32 nlink;
@@ -52,9 +49,11 @@ struct nfs_fattr {struct timespec atime;struct timespec mtime;struct timespec ctime; -__u32 bitmap[2 ];/* NFSv4 returned attribute bitmap */ __u64 change_attr;/* NFSv4 change attribute */ __u64 pre_change_attr;/* pre-op NFSv4 change attribute */ +__u64 pre_size;/* pre_op_attr.size */ +struct timespec pre_mtime;/* pre_op_attr.mtime */ +struct timespec pre_ctime;/* pre_op_attr.ctime */ unsigned long time_start;unsigned long gencount; };
PATCH 7/30 NFS: Fix the type of struct nfs_fattr->mode
In reply to a message not in the archiveThere is no point in using anything other than umode_t, since we copy the content pretty much directly into inode->i_mode.
---
fs/nfs/getroot.c | 4 ++-- fs/nfs/nfs2xdr.c | 7 +++---- fs/nfs/nfs3xdr.c | 31 +++++++++++++------------------ fs/nfs/nfs4xdr.c | 40 +++++++++++++++++++--------------------- include/linux/nfs_xdr.h | 3 +-- 5 files changed, 38 insertions(+), 47 deletions(-)
fs/nfs/getroot.c +2 -2
@@ -156,7 +156,7 @@ int nfs4_path_walk(struct nfs_server *server,return ret; } -if (fattr.type !=NFDIR ) { +if (!S_ISDIR (fattr.mode)) {printk (KERN_ERR "nfs4_get_root:" " getroot encountered non-directory\n" );return -ENOTDIR ;
@@ -213,7 +213,7 @@ eat_dot_dir:return ret; } -if (fattr.type !=NFDIR ) { +if (!S_ISDIR (fattr.mode)) {printk (KERN_ERR "nfs4_get_root:" " lookupfh encountered non-directory\n" );return -ENOTDIR ;
fs/nfs/nfs2xdr.c +3 -4
@@ -120,8 +120,8 @@ xdr_decode_time(__be32 *p, struct timespec *timep)static __be32 *xdr_decode_fattr (__be32 *p,struct nfs_fattr *fattr) { -u32 rdev; - fattr->type = (enum nfs_ftype )ntohl (*p++); +u32 rdev, type; + type =ntohl (*p++); fattr->mode =ntohl (*p++); fattr->nlink =ntohl (*p++); fattr->uid =ntohl (*p++);
@@ -138,8 +138,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr) p =xdr_decode_time (p, &fattr->ctime); fattr->valid |=NFS_ATTR_FATTR_V2 ; fattr->rdev =new_decode_dev (rdev); -if (fattr->type ==NFCHR && rdev ==NFS2_FIFO_DEV ) { - fattr->type =NFFIFO ; +if (type ==NFCHR && rdev ==NFS2_FIFO_DEV ) { fattr->mode = (fattr->mode & ~S_IFMT ) |S_IFIFO ; fattr->rdev =0 ; }
fs/nfs/nfs3xdr.c +13 -18
@@ -91,19 +91,15 @@/* * Map file type to S_IFMT bits */ -static struct { -unsigned int mode; -unsigned int nfs2type; -} nfs_type2fmt[] = { - {0 ,NFNON }, - {S_IFREG ,NFREG }, - {S_IFDIR ,NFDIR }, - {S_IFBLK ,NFBLK }, - {S_IFCHR ,NFCHR }, - {S_IFLNK ,NFLNK }, - {S_IFSOCK ,NFSOCK }, - {S_IFIFO ,NFFIFO }, - {0 ,NFBAD } +static const umode_t nfs_type2fmt[] = { + [NF3BAD ] =0 , + [NF3REG ] =S_IFREG , + [NF3DIR ] =S_IFDIR , + [NF3BLK ] =S_IFBLK , + [NF3CHR ] =S_IFCHR , + [NF3LNK ] =S_IFLNK , + [NF3SOCK ] =S_IFSOCK , + [NF3FIFO ] =S_IFIFO , };/*
@@ -148,13 +144,12 @@ static __be32 * xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr) {unsigned int type, major, minor; -int fmode; +umode_t fmode; type =ntohl (*p++); -if (type >=NF3BAD ) - type =NF3BAD ; - fmode = nfs_type2fmt[type].mode; - fattr->type = nfs_type2fmt[type].nfs2type; +if (type >NF3FIFO ) + type =NF3NON ; + fmode = nfs_type2fmt[type]; fattr->mode = (ntohl (*p++) & ~S_IFMT ) | fmode; fattr->nlink =ntohl (*p++); fattr->uid =ntohl (*p++);
fs/nfs/nfs4xdr.c +19 -21
@@ -522,20 +522,17 @@ static int nfs4_stat_to_errno(int); decode_lookup_maxsz + \ decode_fs_locations_maxsz) -static struct { -unsigned int mode; -unsigned int nfs2type; -} nfs_type2fmt[] = { - {0 ,NFNON }, - {S_IFREG ,NFREG }, - {S_IFDIR ,NFDIR }, - {S_IFBLK ,NFBLK }, - {S_IFCHR ,NFCHR }, - {S_IFLNK ,NFLNK }, - {S_IFSOCK ,NFSOCK }, - {S_IFIFO ,NFFIFO }, - {0 ,NFNON }, - {0 ,NFNON }, +static const umode_t nfs_type2fmt[] = { + [NF4BAD ] =0 , + [NF4REG ] =S_IFREG , + [NF4DIR ] =S_IFDIR , + [NF4BLK ] =S_IFBLK , + [NF4CHR ] =S_IFCHR , + [NF4LNK ] =S_IFLNK , + [NF4SOCK ] =S_IFSOCK , + [NF4FIFO ] =S_IFIFO , + [NF4ATTRDIR ] =0 , + [NF4NAMEDATTR ] =0 , };struct compound_hdr {
@@ -2173,7 +2170,7 @@ static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t * } bitmap[0 ] &= ~FATTR4_WORD0_TYPE ; } -dprintk ("%s: type=0%o\n" , __func__, nfs_type2fmt[*type].nfs2type); +dprintk ("%s: type=0%o\n" , __func__, nfs_type2fmt[*type]);return 0 ; }
@@ -2580,8 +2577,9 @@ static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32return status; } -static int decode_attr_mode (struct xdr_stream *xdr,uint32_t *bitmap,uint32_t *mode) +static int decode_attr_mode (struct xdr_stream *xdr,uint32_t *bitmap,umode_t *mode) { +uint32_t tmp;__be32 *p; *mode =0 ;
@@ -2589,8 +2587,8 @@ static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *return -EIO ;if (likely (bitmap[1 ] &FATTR4_WORD1_MODE )) {READ_BUF (4 ); -READ32 (*mode); - *mode &= ~S_IFMT ; +READ32 (tmp); + *mode = tmp & ~S_IFMT ; bitmap[1 ] &= ~FATTR4_WORD1_MODE ; }dprintk ("%s: file mode=0%o\n" , __func__, (unsigned int )*mode);
@@ -2994,7 +2992,8 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, consuint32_t attrlen, bitmap[2 ] = {0 }, type; -int status, fmode =0 ; +int status; +umode_t fmode =0 ;uint64_t fileid;if ((status =decode_op_hdr (xdr,OP_GETATTR )) !=0 )
@@ -3008,8 +3007,7 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, consif ((status =decode_attr_type (xdr, bitmap, &type)) !=0 ) goto xdr_error; - fattr->type = nfs_type2fmt[type].nfs2type; - fattr->mode = nfs_type2fmt[type].mode; + fattr->mode = nfs_type2fmt[type];if ((status =decode_attr_change (xdr, bitmap, &fattr->change_attr)) !=0 ) goto xdr_error;
include/linux/nfs_xdr.h +1 -2
@@ -28,8 +28,7 @@ static inline int nfs_fsid_equal(const struct nfs_fsid *a, const struct nfs_fsidstruct nfs_fattr {unsigned int valid;/* which fields are valid */ -enum nfs_ftype type;/* always use NFSv2 types */ -__u32 mode; +umode_t mode;__u32 nlink;__u32 uid;__u32 gid;
PATCH 8/30 NFSv4: Clean up decode_getfattr()
In reply to a message not in the archive---
fs/nfs/nfs4xdr.c | 78 +++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 57 insertions(+), 21 deletions(-)
fs/nfs/nfs4xdr.c +57 -21
@@ -2996,55 +2996,91 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, consumode_t fmode =0 ;uint64_t fileid; -if ((status =decode_op_hdr (xdr,OP_GETATTR )) !=0 ) + status =decode_op_hdr (xdr,OP_GETATTR ); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_bitmap (xdr, bitmap)) !=0 ) + + status =decode_attr_bitmap (xdr, bitmap); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_length (xdr, &attrlen, &savep)) !=0 ) + status =decode_attr_length (xdr, &attrlen, &savep); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_type (xdr, bitmap, &type)) !=0 ) + status =decode_attr_type (xdr, bitmap, &type); +if (status <0 ) goto xdr_error; fattr->mode = nfs_type2fmt[type]; -if ((status =decode_attr_change (xdr, bitmap, &fattr->change_attr)) !=0 ) + status =decode_attr_change (xdr, bitmap, &fattr->change_attr); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_size (xdr, bitmap, &fattr->size)) !=0 ) + + status =decode_attr_size (xdr, bitmap, &fattr->size); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_fsid (xdr, bitmap, &fattr->fsid)) !=0 ) + + status =decode_attr_fsid (xdr, bitmap, &fattr->fsid); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_fileid (xdr, bitmap, &fattr->fileid)) !=0 ) + + status =decode_attr_fileid (xdr, bitmap, &fattr->fileid); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_fs_locations (xdr, bitmap,container_of (fattr, + + status =decode_attr_fs_locations (xdr, bitmap,container_of (fattr, struct nfs4_fs_locations, - fattr))) !=0 ) + fattr)); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_mode (xdr, bitmap, &fmode)) !=0 ) + + status =decode_attr_mode (xdr, bitmap, &fmode); +if (status <0 ) goto xdr_error; fattr->mode |= fmode; -if ((status =decode_attr_nlink (xdr, bitmap, &fattr->nlink)) !=0 ) + + status =decode_attr_nlink (xdr, bitmap, &fattr->nlink); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_owner (xdr, bitmap, server->nfs_client, &fattr->uid)) !=0 ) + + status =decode_attr_owner (xdr, bitmap, server->nfs_client, &fattr->uid); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_group (xdr, bitmap, server->nfs_client, &fattr->gid)) !=0 ) + + status =decode_attr_group (xdr, bitmap, server->nfs_client, &fattr->gid); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_rdev (xdr, bitmap, &fattr->rdev)) !=0 ) + + status =decode_attr_rdev (xdr, bitmap, &fattr->rdev); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_space_used (xdr, bitmap, &fattr->du.nfs3.used)) !=0 ) + + status =decode_attr_space_used (xdr, bitmap, &fattr->du.nfs3.used); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_time_access (xdr, bitmap, &fattr->atime)) !=0 ) + + status =decode_attr_time_access (xdr, bitmap, &fattr->atime); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_time_metadata (xdr, bitmap, &fattr->ctime)) !=0 ) + + status =decode_attr_time_metadata (xdr, bitmap, &fattr->ctime); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_time_modify (xdr, bitmap, &fattr->mtime)) !=0 ) + + status =decode_attr_time_modify (xdr, bitmap, &fattr->mtime); +if (status <0 ) goto xdr_error; -if ((status =decode_attr_mounted_on_fileid (xdr, bitmap, &fileid)) !=0 ) + + status =decode_attr_mounted_on_fileid (xdr, bitmap, &fileid); +if (status <0 ) goto xdr_error;if (fattr->fileid ==0 && fileid !=0 ) fattr->fileid = fileid; -if ((status =verify_attr_len (xdr, savep, attrlen)) ==0 ) + + status =verify_attr_len (xdr, savep, attrlen); +if (status ==0 ) fattr->valid =NFS_ATTR_FATTR_V4 ; xdr_error:dprintk ("%s: xdr returned %d\n" , __func__, -status);
PATCH 9/30 NFSv4: Make decode_getfattr() set fattr->valid to reflect what was decoded
In reply to a message not in the archive---
fs/nfs/nfs4xdr.c | 92 +++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 73 insertions(+), 19 deletions(-)
fs/nfs/nfs4xdr.c +73 -19
@@ -2157,6 +2157,7 @@ static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint3static int decode_attr_type (struct xdr_stream *xdr,uint32_t *bitmap,uint32_t *type) {__be32 *p; +int ret =0 ; *type =0 ;if (unlikely (bitmap[0 ] & (FATTR4_WORD0_TYPE -1U )))
@@ -2169,14 +2170,16 @@ static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *return -EIO ; } bitmap[0 ] &= ~FATTR4_WORD0_TYPE ; + ret =NFS_ATTR_FATTR_TYPE ; }dprintk ("%s: type=0%o\n" , __func__, nfs_type2fmt[*type]); -return 0 ; +return ret; }static int decode_attr_change (struct xdr_stream *xdr,uint32_t *bitmap,uint64_t *change) {__be32 *p; +int ret =0 ; *change =0 ;if (unlikely (bitmap[0 ] & (FATTR4_WORD0_CHANGE -1U )))
@@ -2185,15 +2188,17 @@ static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_tREAD_BUF (8 );READ64 (*change); bitmap[0 ] &= ~FATTR4_WORD0_CHANGE ; + ret =NFS_ATTR_FATTR_CHANGE ; }dprintk ("%s: change attribute=%Lu\n" , __func__, (unsigned long long )*change); -return 0 ; +return ret; }static int decode_attr_size (struct xdr_stream *xdr,uint32_t *bitmap,uint64_t *size) {__be32 *p; +int ret =0 ; *size =0 ;if (unlikely (bitmap[0 ] & (FATTR4_WORD0_SIZE -1U )))
@@ -2202,9 +2207,10 @@ static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *READ_BUF (8 );READ64 (*size); bitmap[0 ] &= ~FATTR4_WORD0_SIZE ; + ret =NFS_ATTR_FATTR_SIZE ; }dprintk ("%s: file size=%Lu\n" , __func__, (unsigned long long )*size); -return 0 ; +return ret; }static int decode_attr_link_support (struct xdr_stream *xdr,uint32_t *bitmap,uint32_t *res)
@@ -2242,6 +2248,7 @@ static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap,static int decode_attr_fsid (struct xdr_stream *xdr,uint32_t *bitmap,struct nfs_fsid *fsid) {__be32 *p; +int ret =0 ; fsid->major =0 ; fsid->minor =0 ;
@@ -2252,11 +2259,12 @@ static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfsREAD64 (fsid->major);READ64 (fsid->minor); bitmap[0 ] &= ~FATTR4_WORD0_FSID ; + ret =NFS_ATTR_FATTR_FSID ; }dprintk ("%s: fsid=(0x%Lx/0x%Lx)\n" , __func__, (unsigned long long )fsid->major, (unsigned long long )fsid->minor); -return 0 ; +return ret; }static int decode_attr_lease_time (struct xdr_stream *xdr,uint32_t *bitmap,uint32_t *res)
@@ -2294,6 +2302,7 @@ static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uintstatic int decode_attr_fileid (struct xdr_stream *xdr,uint32_t *bitmap,uint64_t *fileid) {__be32 *p; +int ret =0 ; *fileid =0 ;if (unlikely (bitmap[0 ] & (FATTR4_WORD0_FILEID -1U )))
@@ -2302,14 +2311,16 @@ static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_tREAD_BUF (8 );READ64 (*fileid); bitmap[0 ] &= ~FATTR4_WORD0_FILEID ; + ret =NFS_ATTR_FATTR_FILEID ; }dprintk ("%s: fileid=%Lu\n" , __func__, (unsigned long long )*fileid); -return 0 ; +return ret; }static int decode_attr_mounted_on_fileid (struct xdr_stream *xdr,uint32_t *bitmap,uint64_t *fileid) {__be32 *p; +int ret =0 ; *fileid =0 ;if (unlikely (bitmap[1 ] & (FATTR4_WORD1_MOUNTED_ON_FILEID -1U )))
@@ -2318,9 +2329,10 @@ static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmaREAD_BUF (8 );READ64 (*fileid); bitmap[1 ] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID ; + ret =NFS_ATTR_FATTR_FILEID ; }dprintk ("%s: fileid=%Lu\n" , __func__, (unsigned long long )*fileid); -return 0 ; +return ret; }static int decode_attr_files_avail (struct xdr_stream *xdr,uint32_t *bitmap,uint64_t *res)
@@ -2476,6 +2488,8 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, stif (res->nlocations <NFS4_FS_LOCATIONS_MAXENTRIES ) res->nlocations++; } +if (res->nlocations !=0 ) + status =NFS_ATTR_FATTR_V4_REFERRAL ; out:dprintk ("%s: fs_locations done, error = %d\n" , __func__, status);return status;
@@ -2581,6 +2595,7 @@ static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *m {uint32_t tmp;__be32 *p; +int ret =0 ; *mode =0 ;if (unlikely (bitmap[1 ] & (FATTR4_WORD1_MODE -1U )))
@@ -2590,14 +2605,16 @@ static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mREAD32 (tmp); *mode = tmp & ~S_IFMT ; bitmap[1 ] &= ~FATTR4_WORD1_MODE ; + ret =NFS_ATTR_FATTR_MODE ; }dprintk ("%s: file mode=0%o\n" , __func__, (unsigned int )*mode); -return 0 ; +return ret; }static int decode_attr_nlink (struct xdr_stream *xdr,uint32_t *bitmap,uint32_t *nlink) {__be32 *p; +int ret =0 ; *nlink =1 ;if (unlikely (bitmap[1 ] & (FATTR4_WORD1_NUMLINKS -1U )))
@@ -2606,15 +2623,17 @@ static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_tREAD_BUF (4 );READ32 (*nlink); bitmap[1 ] &= ~FATTR4_WORD1_NUMLINKS ; + ret =NFS_ATTR_FATTR_NLINK ; }dprintk ("%s: nlink=%u\n" , __func__, (unsigned int )*nlink); -return 0 ; +return ret; }static int decode_attr_owner (struct xdr_stream *xdr,uint32_t *bitmap,struct nfs_client *clp,uint32_t *uid) {uint32_t len;__be32 *p; +int ret =0 ; *uid =-2 ;if (unlikely (bitmap[1 ] & (FATTR4_WORD1_OWNER -1U )))
@@ -2624,7 +2643,9 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, struct nfREAD32 (len);READ_BUF (len);if (len <XDR_MAX_NETOBJ ) { -if (nfs_map_name_to_uid (clp, (char *)p, len, uid) !=0 ) +if (nfs_map_name_to_uid (clp, (char *)p, len, uid) ==0 ) + ret =NFS_ATTR_FATTR_OWNER ; +else dprintk ("%s: nfs_map_name_to_uid failed!\n" , __func__); }else
@@ -2633,13 +2654,14 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, struct nf bitmap[1 ] &= ~FATTR4_WORD1_OWNER ; }dprintk ("%s: uid=%d\n" , __func__, (int )*uid); -return 0 ; +return ret; }static int decode_attr_group (struct xdr_stream *xdr,uint32_t *bitmap,struct nfs_client *clp,uint32_t *gid) {uint32_t len;__be32 *p; +int ret =0 ; *gid =-2 ;if (unlikely (bitmap[1 ] & (FATTR4_WORD1_OWNER_GROUP -1U )))
@@ -2649,7 +2671,9 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, struct nfREAD32 (len);READ_BUF (len);if (len <XDR_MAX_NETOBJ ) { -if (nfs_map_group_to_gid (clp, (char *)p, len, gid) !=0 ) +if (nfs_map_group_to_gid (clp, (char *)p, len, gid) ==0 ) + ret =NFS_ATTR_FATTR_GROUP ; +else dprintk ("%s: nfs_map_group_to_gid failed!\n" , __func__); }else
@@ -2658,13 +2682,14 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, struct nf bitmap[1 ] &= ~FATTR4_WORD1_OWNER_GROUP ; }dprintk ("%s: gid=%d\n" , __func__, (int )*gid); -return 0 ; +return ret; }static int decode_attr_rdev (struct xdr_stream *xdr,uint32_t *bitmap,dev_t *rdev) {uint32_t major =0 , minor =0 ;__be32 *p; +int ret =0 ; *rdev =MKDEV (0 ,0 );if (unlikely (bitmap[1 ] & (FATTR4_WORD1_RAWDEV -1U )))
@@ -2679,9 +2704,10 @@ static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdeif (MAJOR (tmp) == major &&MINOR (tmp) == minor) *rdev = tmp; bitmap[1 ] &= ~FATTR4_WORD1_RAWDEV ; + ret =NFS_ATTR_FATTR_RDEV ; }dprintk ("%s: rdev=(0x%x:0x%x)\n" , __func__, major, minor); -return 0 ; +return ret; }static int decode_attr_space_avail (struct xdr_stream *xdr,uint32_t *bitmap,uint64_t *res)
@@ -2738,6 +2764,7 @@ static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uinstatic int decode_attr_space_used (struct xdr_stream *xdr,uint32_t *bitmap,uint64_t *used) {__be32 *p; +int ret =0 ; *used =0 ;if (unlikely (bitmap[1 ] & (FATTR4_WORD1_SPACE_USED -1U )))
@@ -2746,10 +2773,11 @@ static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uintREAD_BUF (8 );READ64 (*used); bitmap[1 ] &= ~FATTR4_WORD1_SPACE_USED ; + ret =NFS_ATTR_FATTR_SPACE_USED ; }dprintk ("%s: space used=%Lu\n" , __func__, (unsigned long long )*used); -return 0 ; +return ret; }static int decode_attr_time (struct xdr_stream *xdr,struct timespec *time)
@@ -2776,6 +2804,8 @@ static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, strreturn -EIO ;if (likely (bitmap[1 ] &FATTR4_WORD1_TIME_ACCESS )) { status =decode_attr_time (xdr, time); +if (status ==0 ) + status =NFS_ATTR_FATTR_ATIME ; bitmap[1 ] &= ~FATTR4_WORD1_TIME_ACCESS ; }dprintk ("%s: atime=%ld\n" , __func__, (long )time->tv_sec);
@@ -2792,6 +2822,8 @@ static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, sreturn -EIO ;if (likely (bitmap[1 ] &FATTR4_WORD1_TIME_METADATA )) { status =decode_attr_time (xdr, time); +if (status ==0 ) + status =NFS_ATTR_FATTR_CTIME ; bitmap[1 ] &= ~FATTR4_WORD1_TIME_METADATA ; }dprintk ("%s: ctime=%ld\n" , __func__, (long )time->tv_sec);
@@ -2808,6 +2840,8 @@ static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, strreturn -EIO ;if (likely (bitmap[1 ] &FATTR4_WORD1_TIME_MODIFY )) { status =decode_attr_time (xdr, time); +if (status ==0 ) + status =NFS_ATTR_FATTR_MTIME ; bitmap[1 ] &= ~FATTR4_WORD1_TIME_MODIFY ; }dprintk ("%s: mtime=%ld\n" , __func__, (long )time->tv_sec);
@@ -3012,76 +3046,96 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, cons status =decode_attr_type (xdr, bitmap, &type);if (status <0 ) goto xdr_error; - fattr->mode = nfs_type2fmt[type]; + fattr->mode =0 ; +if (status !=0 ) { + fattr->mode |= nfs_type2fmt[type]; + fattr->valid |= status; + } status =decode_attr_change (xdr, bitmap, &fattr->change_attr);if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_size (xdr, bitmap, &fattr->size);if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_fsid (xdr, bitmap, &fattr->fsid);if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_fileid (xdr, bitmap, &fattr->fileid);if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_fs_locations (xdr, bitmap,container_of (fattr, struct nfs4_fs_locations, fattr));if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_mode (xdr, bitmap, &fmode);if (status <0 ) goto xdr_error; - fattr->mode |= fmode; +if (status !=0 ) { + fattr->mode |= fmode; + fattr->valid |= status; + } status =decode_attr_nlink (xdr, bitmap, &fattr->nlink);if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_owner (xdr, bitmap, server->nfs_client, &fattr->uid);if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_group (xdr, bitmap, server->nfs_client, &fattr->gid);if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_rdev (xdr, bitmap, &fattr->rdev);if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_space_used (xdr, bitmap, &fattr->du.nfs3.used);if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_time_access (xdr, bitmap, &fattr->atime);if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_time_metadata (xdr, bitmap, &fattr->ctime);if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_time_modify (xdr, bitmap, &fattr->mtime);if (status <0 ) goto xdr_error; + fattr->valid |= status; status =decode_attr_mounted_on_fileid (xdr, bitmap, &fileid);if (status <0 ) goto xdr_error; -if (fattr->fileid ==0 && fileid !=0 ) +if (status !=0 && !(fattr->valid & status)) { fattr->fileid = fileid; + fattr->valid |= status; + } status =verify_attr_len (xdr, savep, attrlen); -if (status ==0 ) - fattr->valid =NFS_ATTR_FATTR_V4 ; xdr_error:dprintk ("%s: xdr returned %d\n" , __func__, -status);return status;
PATCH 10/30 NFSv4: A referral is assumed to always point to a directory.
In reply to a message not in the archiveFix a bug whereby we would fail to create a mount point for a referral.
---
fs/nfs/nfs4proc.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
fs/nfs/nfs4proc.c +14 -0
@@ -3678,6 +3678,19 @@ ssize_t nfs4_listxattr(struct dentry *dentry, char *buf, size_t buflen)return len; } +static void nfs_fixup_referral_attributes (struct nfs_fattr *fattr) +{ +if (!((fattr->valid &NFS_ATTR_FATTR_FILEID ) && + (fattr->valid &NFS_ATTR_FATTR_FSID ) && + (fattr->valid &NFS_ATTR_FATTR_V4_REFERRAL ))) +return ; + + fattr->valid |=NFS_ATTR_FATTR_TYPE |NFS_ATTR_FATTR_MODE | +NFS_ATTR_FATTR_NLINK ; + fattr->mode =S_IFDIR |S_IRUGO |S_IXUGO ; + fattr->nlink =2 ; +} +int nfs4_proc_fs_locations (struct inode *dir,const struct qstr *name,struct nfs4_fs_locations *fs_locations,struct page *page) {
@@ -3704,6 +3717,7 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, fs_locations->server = server; fs_locations->nlocations =0 ; status =rpc_call_sync (server->client, &msg,0 ); +nfs_fixup_referral_attributes (&fs_locations->fattr);dprintk ("%s: returned status = %d\n" , __func__, status);return status; }
PATCH 11/30 NFSv4: Simplify some cache consistency post-op GETATTRs
In reply to a message not in the archiveCertain asynchronous operations such as write() do not expect (or care) that other metadata such as the file owner, mode, acls, ... change. All they want to do is update and/or check the change attribute, ctime, and mtime.
By skipping the file owner and group update, we also avoid having to do a potential idmapper upcall for these asynchronous RPC calls.
---
fs/nfs/nfs4proc.c | 13 ++++++++----- include/linux/nfs_fs_sb.h | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-)
fs/nfs/nfs4proc.c +8 -5
@@ -1439,7 +1439,7 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait)if (calldata->arg.seqid ==NULL ) goto out_free_calldata; calldata->arg.fmode =0 ; - calldata->arg.bitmask = server->attr_bitmask; + calldata->arg.bitmask = server->cache_consistency_bitmask; calldata->res.fattr = &calldata->fattr; calldata->res.seqid = calldata->arg.seqid; calldata->res.server = server;
@@ -1600,6 +1600,9 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f server->caps |=NFS_CAP_HARDLINKS ;if (res.has_symlinks !=0 ) server->caps |=NFS_CAP_SYMLINKS ; +memcpy (server->cache_consistency_bitmask, res.attr_bitmask,sizeof (server->cache_consistency_bitmask)); + server->cache_consistency_bitmask[0 ] &=FATTR4_WORD0_CHANGE |FATTR4_WORD0_SIZE ; + server->cache_consistency_bitmask[1 ] &=FATTR4_WORD1_TIME_METADATA |FATTR4_WORD1_TIME_MODIFY ; server->acl_bitmask = res.acl_bitmask; }return status;
@@ -2079,7 +2082,7 @@ static void nfs4_proc_unlink_setup(struct rpc_message *msg, struct inode *dir)struct nfs_removeargs *args = msg->rpc_argp;struct nfs_removeres *res = msg->rpc_resp; - args->bitmask = server->attr_bitmask; + args->bitmask = server->cache_consistency_bitmask; res->server = server; msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE ]; }
@@ -2323,7 +2326,7 @@ static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, .pages = &page, .pgbase = 0, .count = count, - .bitmask = NFS_SERVER(dentry->d_inode)->attr_bitmask, + .bitmask = NFS_SERVER(dentry->d_inode)->cache_consistency_bitmask, };struct nfs4_readdir_res res;struct rpc_message msg = {
@@ -2552,7 +2555,7 @@ static void nfs4_proc_write_setup(struct nfs_write_data *data, struct rpc_messag {struct nfs_server *server =NFS_SERVER (data->inode); - data->args.bitmask = server->attr_bitmask; + data->args.bitmask = server->cache_consistency_bitmask; data->res.server = server; data->timestamp = jiffies;
@@ -2575,7 +2578,7 @@ static void nfs4_proc_commit_setup(struct nfs_write_data *data, struct rpc_messa {struct nfs_server *server =NFS_SERVER (data->inode); - data->args.bitmask = server->attr_bitmask; + data->args.bitmask = server->cache_consistency_bitmask; data->res.server = server; msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMMIT ]; }
include/linux/nfs_fs_sb.h +5 -0
@@ -106,6 +106,11 @@ struct nfs_server {u32 attr_bitmask[2 ];/* V4 bitmask representing the set of attributes supported on this filesystem */ +u32 cache_consistency_bitmask[2 ]; +/* V4 bitmask representing the subset +of change attribute, size, ctime +and mtime attributes supported by +the server */ u32 acl_bitmask;/* V4 bitmask representing the ACEs that are supported on this filesystem */
PATCH 12/30 NFS: cleanup - remove struct nfs_inode->ncommit
In reply to a message not in the archive---
fs/nfs/inode.c | 1 - fs/nfs/write.c | 25 ++++++++++++++++--------- include/linux/nfs_fs.h | 3 +-- 3 files changed, 17 insertions(+), 12 deletions(-)
fs/nfs/inode.c +0 -1
@@ -1345,7 +1345,6 @@ static void init_once(void *foo)INIT_LIST_HEAD (&nfsi->access_cache_entry_lru);INIT_LIST_HEAD (&nfsi->access_cache_inode_lru);INIT_RADIX_TREE (&nfsi->nfs_page_tree,GFP_ATOMIC ); - nfsi->ncommit =0 ; nfsi->npages =0 ;atomic_set (&nfsi->silly_count,1 );INIT_HLIST_HEAD (&nfsi->silly_list);
fs/nfs/write.c +16 -9
@@ -404,7 +404,6 @@ nfs_mark_request_commit(struct nfs_page *req)struct nfs_inode *nfsi =NFS_I (inode);spin_lock (&inode->i_lock); - nfsi->ncommit++;set_bit (PG_CLEAN , &(req)->wb_flags); radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index,
@@ -523,6 +522,12 @@ static void nfs_cancel_commit_list(struct list_head *head) } } +static int +nfs_need_commit (struct nfs_inode *nfsi) +{ +return radix_tree_tagged (&nfsi->nfs_page_tree,NFS_PAGE_TAG_COMMIT ); +} +#if defined(CONFIG_NFS_V3 ) || defined(CONFIG_NFS_V4 )/* * nfs_scan_commit - Scan an inode for commit requests
@@ -538,16 +543,18 @@ static int nfs_scan_commit(struct inode *inode, struct list_head *dst, pgoff_t idx_start, unsigned int npages) { struct nfs_inode *nfsi = NFS_I(inode); -int res =0 ; -if (nfsi->ncommit !=0 ) { - res =nfs_scan_list (nfsi, dst, idx_start, npages, -NFS_PAGE_TAG_COMMIT ); - nfsi->ncommit -= res; - } -return res; +if (!nfs_need_commit (nfsi)) +return 0 ; + +return nfs_scan_list (nfsi, dst, idx_start, npages,NFS_PAGE_TAG_COMMIT ); }#else +static inline int nfs_need_commit (struct nfs_inode *nfsi) +{ +return 0 ; +} +static inline int nfs_scan_commit (struct inode *inode,struct list_head *dst,pgoff_t idx_start,unsigned int npages) {return 0 ;
@@ -820,7 +827,7 @@ static int nfs_write_rpcsetup(struct nfs_page *req, data->args.stable =NFS_UNSTABLE ;if (how &FLUSH_STABLE ) { data->args.stable =NFS_DATA_SYNC ; -if (!NFS_I (inode)->ncommit) +if (!nfs_need_commit (NFS_I (inode))) data->args.stable =NFS_FILE_SYNC ; }
include/linux/nfs_fs.h +1 -2
@@ -166,8 +166,7 @@ struct nfs_inode {*/ struct radix_tree_root nfs_page_tree; -unsigned long ncommit, - npages; +unsigned long npages;/* Open contexts for shared mmap writes */ struct list_head open_files;
PATCH 13/30 NFS: Throttle page dirtying while we're flushing to disk
In reply to a message not in the archiveThe following patch is a combination of a patch by myself and Peter Staubach.
Trond: If we allow other processes to dirty pages while a process is doing a consistency sync to disk, we can end up never making progress.
Peter: Attached is a patch which addresses a continuing problem with the NFS client generating out of order WRITE requests. While this is compliant with all of the current protocol specifications, there are servers in the market which can not handle out of order WRITE requests very well. Also, this may lead to sub-optimal block allocations in the underlying file system on the server. This may cause the read throughputs to be reduced when reading the file from the server.
Peter: There has been a lot of work recently done to address out of order issues on a systemic level. However, the NFS client is still susceptible to the problem. Out of order WRITE requests can occur when pdflush is in the middle of writing out pages while the process dirtying the pages calls generic_file_buffered_write which calls generic_perform_write which calls balance_dirty_pages_rate_limited which ends up calling writeback_inodes which ends up calling back into the NFS client to writes out dirty pages for the same file that pdflush happens to be working with.
---
fs/nfs/file.c | 9 +++++++++ fs/nfs/inode.c | 12 ++++++++++++ fs/nfs/internal.h | 1 + fs/nfs/nfs4proc.c | 10 +--------- fs/nfs/pagelist.c | 11 ----------- fs/nfs/write.c | 28 +++++++++++++++++++--------- include/linux/nfs_fs.h | 1 + 7 files changed, 43 insertions(+), 29 deletions(-)
fs/nfs/file.c +9 -0
@@ -354,6 +354,15 @@ static int nfs_write_begin(struct file *file, struct address_space *mapping, file->f_path.dentry->d_name.name, mapping->host->i_ino, len, (long long) pos); +/* +* Prevent starvation issues if someone is doing a consistency +* sync-to-disk +*/ + ret =wait_on_bit (&NFS_I (mapping->host)->flags,NFS_INO_FLUSHING , + nfs_wait_bit_killable,TASK_KILLABLE ); +if (ret) +return ret; + page =grab_cache_page_write_begin (mapping, index, flags);if (!page)return -ENOMEM ;
fs/nfs/inode.c +12 -0
@@ -66,6 +66,18 @@ nfs_fattr_to_ino_t(struct nfs_fattr *fattr) }/** +* nfs_wait_bit_killable - helper for functions that are sleeping on bit locks +* @word: long word containing the bit lock +*/ +int nfs_wait_bit_killable (void *word) +{ +if (fatal_signal_pending (current)) +return -ERESTARTSYS ; +schedule (); +return 0 ; +} + +/** * nfs_compat_user_ino64 - returns the user-visible inode number * @fileid: 64-bit fileid *
fs/nfs/internal.h +1 -0
@@ -165,6 +165,7 @@ extern void nfs_clear_inode(struct inode *);extern void nfs4_clear_inode (struct inode *);#endif void nfs_zap_acl_cache (struct inode *inode); +extern int nfs_wait_bit_killable (void *word);/* super.c */ void nfs_parse_ip_address (char *,size_t ,struct sockaddr *,size_t *);
fs/nfs/nfs4proc.c +1 -9
@@ -193,14 +193,6 @@ static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dentkunmap_atomic (start,KM_USER0 ); } -static int nfs4_wait_bit_killable (void *word) -{ -if (fatal_signal_pending (current)) -return -ERESTARTSYS ; -schedule (); -return 0 ; -} -static int nfs4_wait_clnt_recover (struct nfs_client *clp) {int res;
@@ -208,7 +200,7 @@ static int nfs4_wait_clnt_recover(struct nfs_client *clp)might_sleep (); res =wait_on_bit (&clp->cl_state,NFS4CLNT_MANAGER_RUNNING , - nfs4_wait_bit_killable,TASK_KILLABLE ); + nfs_wait_bit_killable,TASK_KILLABLE );return res; }
fs/nfs/pagelist.c +0 -11
@@ -176,17 +176,6 @@ void nfs_release_request(struct nfs_page *req)kref_put (&req->wb_kref, nfs_free_request); } -static int nfs_wait_bit_killable (void *word) -{ -int ret =0 ; - -if (fatal_signal_pending (current)) - ret = -ERESTARTSYS ; -else -schedule (); -return ret; -} -/** * nfs_wait_on_request - Wait for a request to complete. * @req: request to wait upon.
fs/nfs/write.c +19 -9
@@ -313,19 +313,34 @@ static int nfs_writepages_callback(struct page *page, struct writeback_control *int nfs_writepages (struct address_space *mapping,struct writeback_control *wbc) {struct inode *inode = mapping->host; +unsigned long *bitlock = &NFS_I (inode)->flags;struct nfs_pageio_descriptor pgio;int err; +/* Stop dirtying of new pages while we sync */ + err =wait_on_bit_lock (bitlock,NFS_INO_FLUSHING , + nfs_wait_bit_killable,TASK_KILLABLE ); +if (err) + goto out_err; +nfs_inc_stats (inode,NFSIOS_VFSWRITEPAGES );nfs_pageio_init_write (&pgio, inode,wb_priority (wbc)); err =write_cache_pages (mapping, wbc, nfs_writepages_callback, &pgio);nfs_pageio_complete (&pgio); + +clear_bit_unlock (NFS_INO_FLUSHING , bitlock); +smp_mb__after_clear_bit (); +wake_up_bit (bitlock,NFS_INO_FLUSHING ); +if (err <0 ) -return err; -if (pgio.pg_error <0 ) -return pgio.pg_error; + goto out_err; + err = pgio.pg_error; +if (err <0 ) + goto out_err;return 0 ; +out_err: +return err; }/*
@@ -1432,18 +1447,13 @@ static int nfs_write_mapping(struct address_space *mapping, int how) {struct writeback_control wbc = { .bdi = mapping->backing_dev_info, - .sync_mode =WB_SYNC_NONE , + .sync_mode =WB_SYNC_ALL , .nr_to_write =LONG_MAX , .range_start =0 , .range_end =LLONG_MAX , .for_writepages =1 , }; -int ret; - ret =__nfs_write_mapping (mapping, &wbc, how); -if (ret <0 ) -return ret; - wbc.sync_mode =WB_SYNC_ALL ;return __nfs_write_mapping (mapping, &wbc, how); }
include/linux/nfs_fs.h +1 -0
@@ -206,6 +206,7 @@ struct nfs_inode {#define NFS_INO_STALE (1)/* possible stale inode */ #define NFS_INO_ACL_LRU_SET (2)/* Inode is on the LRU list */ #define NFS_INO_MOUNTPOINT (3)/* inode is remote mountpoint */ +#define NFS_INO_FLUSHING (4)/* inode is flushing out data */ static inline struct nfs_inode *NFS_I (const struct inode *inode) {
PATCH 14/30 NFS: Kill the "defined but not used" compile error on nommu machines
In reply to a message not in the archiveBryan Wu reports that when compiling NFS on nommu machines he gets a "defined but not used" error on nfs_file_mmap().
The easiest fix is simply to get rid of the special casing in NFS, and just always call generic_file_mmap() to set up the file.
---
fs/nfs/file.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
fs/nfs/file.c +5 -7
@@ -64,11 +64,7 @@ const struct file_operations nfs_file_operations = { .write = do_sync_write, .aio_read = nfs_file_read, .aio_write = nfs_file_write, -#ifdef CONFIG_MMU .mmap = nfs_file_mmap, -#else - .mmap = generic_file_mmap, -#endif .open = nfs_file_open, .flush = nfs_file_flush, .release = nfs_file_release,
@@ -304,11 +300,13 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma)dprintk ("NFS: mmap(%s/%s)\n" , dentry->d_parent->d_name.name, dentry->d_name.name); - status =nfs_revalidate_mapping (inode, file->f_mapping); +/* Note: generic_file_mmap() returns ENOSYS on nommu systems +* so we call that before revalidating the mapping +*/ + status =generic_file_mmap (file, vma);if (!status) { vma->vm_ops = &nfs_file_vm_ops; - vma->vm_flags |=VM_CAN_NONLINEAR ; -file_accessed (file); + status =nfs_revalidate_mapping (inode, file->f_mapping); }return status; }
PATCH 15/30 SVCRDMA: remove faulty assertions in rpc/rdma chunk validation.
In reply to a message not in the archiveFrom: Tom Talpey <[email protected]>
Certain client-provided RPCRDMA chunk alignments result in an additional scatter/gather entry, which triggered nfs/rdma server assertions incorrectly. OpenSolaris nfs/rdma client connectathon testing was blocked by these in the special/locking section.
---
net/sunrpc/xprtrdma/svc_rdma_sendto.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
net/sunrpc/xprtrdma/svc_rdma_sendto.c +5 -3
@@ -191,7 +191,6 @@ static int map_xdr(struct svcxprt_rdma *xprt,struct xdr_buf *xdr, struct svc_rdma_req_map *vec) { - int sge_max = (xdr->len+PAGE_SIZE-1) / PAGE_SIZE + 3; int sge_no;u32 sge_bytes;u32 page_bytes;
@@ -235,7 +234,11 @@ static int map_xdr(struct svcxprt_rdma *xprt, sge_no++; } -BUG_ON (sge_no > sge_max); +dprintk ("svcrdma: map_xdr: sge_no %d page_no %d " +"page_base %zd page_len %zd head_len %d tail_len %d\n" , + sge_no, page_no, xdr->page_base, xdr->page_len, + xdr->head[0 ].iov_len, xdr->tail[0 ].iov_len); + vec->count = sge_no;return 0 ; }
@@ -579,7 +582,6 @@ static int send_reply(struct svcxprt_rdma *rdma, ctxt->sge[page_no+1 ].length =0 ; }BUG_ON (sge_no > rdma->sc_max_sge); -BUG_ON (sge_no > ctxt->count);memset (&send_wr,0 ,sizeof send_wr); ctxt->wr_op =IB_WR_SEND ; send_wr.wr_id = (unsigned long )ctxt;
PATCH 16/30 XPRTRDMA: correct an rpc/rdma inline send marshaling error
In reply to a message not in the archiveFrom: Tom Talpey <[email protected]>
Certain client rpc's which contain both lengthy page-contained metadata and a non-empty xdr_tail buffer require careful handling to avoid overlapped memory copying. Rearranging of existing rpcrdma marshaling code avoids it; this fixes an NFSv4 symlink creation error detected with connectathon basic/test8 to multiple servers.
---
net/sunrpc/xprtrdma/rpc_rdma.c | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-)
net/sunrpc/xprtrdma/rpc_rdma.c +14 -12
@@ -310,6 +310,19 @@ rpcrdma_inline_pullup(struct rpc_rqst *rqst, int pad) __func__, pad, destp, rqst->rq_slen, curlen); copy_len = rqst->rq_snd_buf.page_len; + +if (rqst->rq_snd_buf.tail[0 ].iov_len) { + curlen = rqst->rq_snd_buf.tail[0 ].iov_len; +if (destp + copy_len != rqst->rq_snd_buf.tail[0 ].iov_base) { +memmove (destp + copy_len, + rqst->rq_snd_buf.tail[0 ].iov_base, curlen); + r_xprt->rx_stats.pullup_copy_count += curlen; + } +dprintk ("RPC: %s: tail destp 0x%p len %d\n" , + __func__, destp + copy_len, curlen); + rqst->rq_svec[0 ].iov_len += curlen; + } + r_xprt->rx_stats.pullup_copy_count += copy_len; npages =PAGE_ALIGN (rqst->rq_snd_buf.page_base+copy_len) >>PAGE_SHIFT ;for (i =0 ; copy_len && i < npages; i++) {
@@ -332,17 +345,6 @@ rpcrdma_inline_pullup(struct rpc_rqst *rqst, int pad) destp += curlen; copy_len -= curlen; } -if (rqst->rq_snd_buf.tail[0 ].iov_len) { - curlen = rqst->rq_snd_buf.tail[0 ].iov_len; -if (destp != rqst->rq_snd_buf.tail[0 ].iov_base) { -memcpy (destp, - rqst->rq_snd_buf.tail[0 ].iov_base, curlen); - r_xprt->rx_stats.pullup_copy_count += curlen; - } -dprintk ("RPC: %s: tail destp 0x%p len %d curlen %d\n" , - __func__, destp, copy_len, curlen); - rqst->rq_svec[0 ].iov_len += curlen; - }/* header now contains entire send message */ return pad; }
@@ -656,7 +658,7 @@ rpcrdma_inline_fixup(struct rpc_rqst *rqst, char *srcp, int copy_len, int pad)if (curlen > rqst->rq_rcv_buf.tail[0 ].iov_len) curlen = rqst->rq_rcv_buf.tail[0 ].iov_len;if (rqst->rq_rcv_buf.tail[0 ].iov_base != srcp) -memcpy (rqst->rq_rcv_buf.tail[0 ].iov_base, srcp, curlen); +memmove (rqst->rq_rcv_buf.tail[0 ].iov_base, srcp, curlen);dprintk ("RPC: %s: tail srcp 0x%p len %d curlen %d\n" , __func__, srcp, copy_len, curlen); rqst->rq_rcv_buf.tail[0 ].iov_len = curlen;
PATCH 17/30 SUNRPC: dynamically load RPC transport modules on-demand
In reply to a message not in the archiveFrom: Tom Talpey <[email protected]>
Provide an api to attempt to load any necessary kernel RPC client transport module automatically. By convention, the desired module name is "xprt"+"transport name". For example, when NFS mounting with "-o proto=rdma", attempt to load the "xprtrdma" module.
---
include/linux/sunrpc/xprt.h | 1 + net/sunrpc/xprt.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 0 deletions(-)
include/linux/sunrpc/xprt.h +1 -0
@@ -235,6 +235,7 @@ static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 **/ int xprt_register_transport (struct xprt_class *type);int xprt_unregister_transport (struct xprt_class *type); +int xprt_load_transport (const char *);void xprt_set_retrans_timeout_def (struct rpc_task *task);void xprt_set_retrans_timeout_rtt (struct rpc_task *task);void xprt_wake_pending_tasks (struct rpc_xprt *xprt,int status);
net/sunrpc/xprt.c +31 -0
@@ -152,6 +152,37 @@ out:EXPORT_SYMBOL_GPL (xprt_unregister_transport);/** +* xprt_load_transport - load a transport implementation +* @transport_name: transport to load +* +* Returns: +* 0: transport successfully loaded +* -ENOENT: transport module not available +*/ +int xprt_load_transport (const char *transport_name) +{ +struct xprt_class *t; +char module_name[sizeof t->name +5 ]; +int result; + + result =0 ; +spin_lock (&xprt_list_lock); +list_for_each_entry (t, &xprt_list, list) { +if (strcmp (t->name, transport_name) ==0 ) { +spin_unlock (&xprt_list_lock); + goto out; + } + } +spin_unlock (&xprt_list_lock); +strcpy (module_name,"xprt" ); +strncat (module_name, transport_name,sizeof t->name); + result =request_module (module_name); +out: +return result; +} +EXPORT_SYMBOL_GPL (xprt_load_transport); + +/** * xprt_reserve_xprt - serialize write access to transports * @task: task that is requesting access to the transport *
PATCH 18/30 NFS: load the rpc/rdma transport module automatically
In reply to a message not in the archiveFrom: Tom Talpey <[email protected]>
When mounting an NFS/RDMA server with the "-o proto=rdma" or "-o rdma" options, attempt to dynamically load the necessary "xprtrdma" client transport module. Doing so improves usability, while avoiding a static module dependency and any unnecesary resources.
---
fs/nfs/super.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
fs/nfs/super.c +3 -1
@@ -1018,6 +1018,7 @@ static int nfs_parse_mount_options(char *raw,case Opt_rdma: mnt->flags |=NFS_MOUNT_TCP ;/* for side protocols */ mnt->nfs_server.protocol =XPRT_TRANSPORT_RDMA ; +xprt_load_transport (p);break ;case Opt_acl: mnt->flags &= ~NFS_MOUNT_NOACL ;
@@ -1205,12 +1206,14 @@ static int nfs_parse_mount_options(char *raw,/* vector side protocols to TCP */ mnt->flags |=NFS_MOUNT_TCP ; mnt->nfs_server.protocol =XPRT_TRANSPORT_RDMA ; +xprt_load_transport (string);break ;default : errors++;dfprintk (MOUNT ,"NFS: unrecognized " "transport protocol\n" ); } +kfree (string);break ;case Opt_mountproto: string =match_strdup (args);
@@ -1218,7 +1221,6 @@ static int nfs_parse_mount_options(char *raw, goto out_nomem; token =match_token (string, nfs_xprt_protocol_tokens, args); -kfree (string);switch (token) {case Opt_xprt_udp:
PATCH 19/30 SUNRPC: Avoid an unnecessary task reschedule on ENOTCONN
In reply to a message not in the archiveIf the socket is unconnected, and xprt_transmit() returns ENOTCONN, we currently give up the lock on the transport channel. Doing so means that the lock automatically gets assigned to the next task in the xprt->sending queue, and so that task needs to be woken up to do the actual connect.
The following patch aims to avoid that unnecessary task switch.
---
net/sunrpc/clnt.c | 26 ++++++++++++++++++-------- 1 files changed, 18 insertions(+), 8 deletions(-)
net/sunrpc/clnt.c +18 -8
@@ -1105,14 +1105,24 @@ static void call_transmit_status(struct rpc_task *task) { task->tk_action = call_status; -/* -* Special case: if we've been waiting on the socket's write_space() -* callback, then don't call xprt_end_transmit(). -*/ -if (task->tk_status == -EAGAIN ) -return ; -xprt_end_transmit (task); -rpc_task_force_reencode (task); +switch (task->tk_status) { +case -EAGAIN : +break ; +default : +xprt_end_transmit (task); +/* +* Special cases: if we've been waiting on the +* socket's write_space() callback, or if the +* socket just returned a connection error, +* then hold onto the transport lock. +*/ +case -ECONNREFUSED : +case -ENOTCONN : +case -EHOSTDOWN : +case -EHOSTUNREACH : +case -ENETUNREACH : +rpc_task_force_reencode (task); + } }/*
PATCH 20/30 SUNRPC: Ensure we set XPRT_CLOSING only after we've sent a tcp FIN...
In reply to a message not in the archive...so that we can distinguish between when we need to shutdown and when we don't. Also remove the call to xs_tcp_shutdown() from xs_tcp_connect(), since xprt_connect() makes the same test.
---
net/sunrpc/xprtsock.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
net/sunrpc/xprtsock.c +1 -4
@@ -1180,7 +1180,6 @@ static void xs_tcp_state_change(struct sock *sk)break ;case TCP_CLOSE_WAIT :/* The server initiated a shutdown of the socket */ -set_bit (XPRT_CLOSING , &xprt->state);xprt_force_disconnect (xprt);case TCP_SYN_SENT : xprt->connect_cookie++;
@@ -1193,6 +1192,7 @@ static void xs_tcp_state_change(struct sock *sk) xprt->reestablish_timeout =XS_TCP_INIT_REEST_TO ;break ;case TCP_LAST_ACK : +set_bit (XPRT_CLOSING , &xprt->state);smp_mb__before_clear_bit ();clear_bit (XPRT_CONNECTED , &xprt->state);smp_mb__after_clear_bit ();
@@ -1836,9 +1836,6 @@ static void xs_tcp_connect(struct rpc_task *task) {struct rpc_xprt *xprt = task->tk_xprt; -/* Initiate graceful shutdown of the socket if not already done */ -if (test_bit (XPRT_CONNECTED , &xprt->state)) -xs_tcp_shutdown (xprt);/* Exit if we need to wait for socket shutdown to complete */ if (test_bit (XPRT_CLOSING , &xprt->state))return ;
PATCH 21/30 SUNRPC: Don't disconnect if a connection is still in progress.
In reply to a message not in the archive---
net/sunrpc/xprtsock.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-)
net/sunrpc/xprtsock.c +14 -4
@@ -1613,10 +1613,9 @@ out:* We need to preserve the port number so the reply cache on the server can * find our cached RPC replies when we get around to reconnecting. */ -static void xs_tcp_reuse_connection (struct rpc_xprt *xprt) +static void xs_abort_connection (struct rpc_xprt *xprt,struct sock_xprt *transport) {int result; - struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);struct sockaddr any;dprintk ("RPC: disconnecting xprt %p to reuse port\n" , xprt);
@@ -1633,6 +1632,17 @@ static void xs_tcp_reuse_connection(struct rpc_xprt *xprt) result); } +static void xs_tcp_reuse_connection (struct rpc_xprt *xprt,struct sock_xprt *transport) +{ +unsigned int state = transport->inet->sk_state; + +if (state ==TCP_CLOSE && transport->sock->state ==SS_UNCONNECTED ) +return ; +if ((1 << state) & (TCPF_ESTABLISHED |TCPF_SYN_SENT )) +return ; +xs_abort_connection (xprt, transport); +} +static int xs_tcp_finish_connecting (struct rpc_xprt *xprt,struct socket *sock) { struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
@@ -1706,7 +1716,7 @@ static void xs_tcp_connect_worker4(struct work_struct *work) } }else /* "close" the socket, preserving the local port */ -xs_tcp_reuse_connection (xprt); +xs_tcp_reuse_connection (xprt, transport);dprintk ("RPC: worker connecting xprt %p to address: %s\n" , xprt, xprt->address_strings[RPC_DISPLAY_ALL ]);
@@ -1766,7 +1776,7 @@ static void xs_tcp_connect_worker6(struct work_struct *work) } }else /* "close" the socket, preserving the local port */ -xs_tcp_reuse_connection (xprt); +xs_tcp_reuse_connection (xprt, transport);dprintk ("RPC: worker connecting xprt %p to address: %s\n" , xprt, xprt->address_strings[RPC_DISPLAY_ALL ]);
PATCH 22/30 SUNRPC: Handle ECONNREFUSED correctly in xprt_transmit()
In reply to a message not in the archiveIf we get an ECONNREFUSED error, we currently go to sleep on the 'xprt->sending' wait queue. The problem is that no timeout is set there, and there is nothing else that will wake the task up later.
We should deal with ECONNREFUSED in call_status, given that is where we also deal with -EHOSTDOWN, and friends.
---
net/sunrpc/clnt.c | 7 ++++++- net/sunrpc/xprt.c | 38 ++++++++++++++++---------------------- net/sunrpc/xprtsock.c | 26 ++++++++++++-------------- 3 files changed, 34 insertions(+), 37 deletions(-)
net/sunrpc/clnt.c +6 -1
@@ -1117,10 +1117,12 @@ call_transmit_status(struct rpc_task *task)* then hold onto the transport lock. */ case -ECONNREFUSED : +case -ECONNRESET :case -ENOTCONN :case -EHOSTDOWN :case -EHOSTUNREACH :case -ENETUNREACH : +case -EPIPE :rpc_task_force_reencode (task); } }
@@ -1162,9 +1164,12 @@ call_status(struct rpc_task *task)xprt_conditional_disconnect (task->tk_xprt, req->rq_connect_cookie);break ; +case -ECONNRESET :case -ECONNREFUSED : -case -ENOTCONN :rpc_force_rebind (clnt); +rpc_delay (task,3 *HZ ); +case -EPIPE : +case -ENOTCONN : task->tk_action = call_bind;break ;case -EAGAIN :
net/sunrpc/xprt.c +16 -22
@@ -901,32 +901,26 @@ void xprt_transmit(struct rpc_task *task) req->rq_connect_cookie = xprt->connect_cookie; req->rq_xtime = jiffies; status = xprt->ops->send_request (task); -if (status ==0 ) { -dprintk ("RPC: %5u xmit complete\n" , task->tk_pid); -spin_lock_bh (&xprt->transport_lock); +if (status !=0 ) { + task->tk_status = status; +return ; + } - xprt->ops->set_retrans_timeout (task); +dprintk ("RPC: %5u xmit complete\n" , task->tk_pid); +spin_lock_bh (&xprt->transport_lock); - xprt->stat.sends++; - xprt->stat.req_u += xprt->stat.sends - xprt->stat.recvs; - xprt->stat.bklog_u += xprt->backlog.qlen; + xprt->ops->set_retrans_timeout (task); -/* Don't race with disconnect */ -if (!xprt_connected (xprt)) - task->tk_status = -ENOTCONN ; -else if (!req->rq_received) -rpc_sleep_on (&xprt->pending, task, xprt_timer); -spin_unlock_bh (&xprt->transport_lock); -return ; - } + xprt->stat.sends++; + xprt->stat.req_u += xprt->stat.sends - xprt->stat.recvs; + xprt->stat.bklog_u += xprt->backlog.qlen; -/* Note: at this point, task->tk_sleeping has not yet been set, -* hence there is no danger of the waking up task being put on -* schedq, and being picked up by a parallel run of rpciod(). -*/ - task->tk_status = status; -if (status == -ECONNREFUSED ) -rpc_sleep_on (&xprt->sending, task,NULL ); +/* Don't race with disconnect */ +if (!xprt_connected (xprt)) + task->tk_status = -ENOTCONN ; +else if (!req->rq_received) +rpc_sleep_on (&xprt->pending, task, xprt_timer); +spin_unlock_bh (&xprt->transport_lock); }static inline void do_xprt_reserve (struct rpc_task *task)
net/sunrpc/xprtsock.c +12 -14
@@ -594,6 +594,8 @@ static int xs_udp_send_request(struct rpc_task *task)/* Still some bytes left; set up for a retry later. */ status = -EAGAIN ; } +if (!transport->sock) + goto out;switch (status) {case -ENOTSOCK :
@@ -603,19 +605,17 @@ static int xs_udp_send_request(struct rpc_task *task)case -EAGAIN :xs_nospace (task);break ; +default : +dprintk ("RPC: sendmsg returned unrecognized error %d\n" , + -status);case -ENETUNREACH :case -EPIPE :case -ECONNREFUSED :/* When the server has died, an ICMP port unreachable message * prompts ECONNREFUSED. */ clear_bit (SOCK_ASYNC_NOSPACE , &transport->sock->flags); -break ; -default : -clear_bit (SOCK_ASYNC_NOSPACE , &transport->sock->flags); -dprintk ("RPC: sendmsg returned unrecognized error %d\n" , - -status); } - +out:return status; }
@@ -697,6 +697,8 @@ static int xs_tcp_send_request(struct rpc_task *task) status = -EAGAIN ;break ; } +if (!transport->sock) + goto out;switch (status) {case -ENOTSOCK :
@@ -706,21 +708,17 @@ static int xs_tcp_send_request(struct rpc_task *task)case -EAGAIN :xs_nospace (task);break ; +default : +dprintk ("RPC: sendmsg returned unrecognized error %d\n" , + -status);case -ECONNRESET :xs_tcp_shutdown (xprt);case -ECONNREFUSED :case -ENOTCONN :case -EPIPE : - status = -ENOTCONN ; -clear_bit (SOCK_ASYNC_NOSPACE , &transport->sock->flags); -break ; -default : -dprintk ("RPC: sendmsg returned unrecognized error %d\n" , - -status);clear_bit (SOCK_ASYNC_NOSPACE , &transport->sock->flags); -xs_tcp_shutdown (xprt); } - +out:return status; }
PATCH 23/30 SUNRPC: Handle socket errors correctly
In reply to a message not in the archiveEnsure that we pick up and handle socket errors as they occur.
---
net/sunrpc/xprtsock.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
net/sunrpc/xprtsock.c +5 -7
@@ -1208,23 +1208,20 @@ static void xs_tcp_state_change(struct sock *sk) }/** -* xs_tcp_error_report - callback mainly for catching RST events +* xs_error_report - callback mainly for catching socket errors * @sk: socket */ -static void xs_tcp_error_report (struct sock *sk) +static void xs_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); +xprt_wake_pending_tasks (xprt, -EAGAIN ); out:read_unlock (&sk->sk_callback_lock); }
@@ -1509,6 +1506,7 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) sk->sk_user_data = xprt; sk->sk_data_ready = xs_udp_data_ready; sk->sk_write_space = xs_udp_write_space; + sk->sk_error_report = xs_error_report; sk->sk_no_check =UDP_CSUM_NORCV ; sk->sk_allocation =GFP_ATOMIC ;
@@ -1656,7 +1654,7 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) 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_error_report = xs_error_report; sk->sk_allocation =GFP_ATOMIC ;/* socket options */
PATCH 24/30 SUNRPC: Return EAGAIN instead of ENOTCONN when waking up xprt->pending
In reply to a message not in the archiveWhile we should definitely return socket errors to the task that is currently trying to send data, there is no need to propagate the same error to all the other tasks on xprt->pending. Doing so actually slows down recovery, since it causes more than one tasks to attempt socket recovery.
---
net/sunrpc/clnt.c | 15 +++---------- net/sunrpc/xprt.c | 20 +++++------------ net/sunrpc/xprtsock.c | 58 ++++++++++++++++++++++++++----------------------- 3 files changed, 41 insertions(+), 52 deletions(-)
net/sunrpc/clnt.c +4 -11
@@ -1032,27 +1032,20 @@ call_connect_status(struct rpc_task *task)dprint_status (task); task->tk_status =0 ; -if (status >=0 ) { +if (status >=0 || status == -EAGAIN ) { clnt->cl_stats->netreconn++; task->tk_action = call_transmit;return ; } -/* Something failed: remote service port may have changed */ -rpc_force_rebind (clnt); -switch (status) { -case -ENOTCONN : -case -EAGAIN : - task->tk_action = call_bind; -if (!RPC_IS_SOFT (task)) -return ;/* if soft mounted, test if we've timed out */ case -ETIMEDOUT : task->tk_action = call_timeout; -return ; +break ; +default : +rpc_exit (task, -EIO ); } -rpc_exit (task, -EIO ); }/*
net/sunrpc/xprt.c +6 -14
@@ -611,7 +611,7 @@ void xprt_disconnect_done(struct rpc_xprt *xprt)dprintk ("RPC: disconnected transport %p\n" , xprt);spin_lock_bh (&xprt->transport_lock);xprt_clear_connected (xprt); -xprt_wake_pending_tasks (xprt, -ENOTCONN ); +xprt_wake_pending_tasks (xprt, -EAGAIN );spin_unlock_bh (&xprt->transport_lock); }EXPORT_SYMBOL_GPL (xprt_disconnect_done);
@@ -629,7 +629,7 @@ void xprt_force_disconnect(struct rpc_xprt *xprt)/* Try to schedule an autoclose RPC call */ if (test_and_set_bit (XPRT_LOCKED , &xprt->state) ==0 )queue_work (rpciod_workqueue, &xprt->task_cleanup); -xprt_wake_pending_tasks (xprt, -ENOTCONN ); +xprt_wake_pending_tasks (xprt, -EAGAIN );spin_unlock_bh (&xprt->transport_lock); }
@@ -656,7 +656,7 @@ void xprt_conditional_disconnect(struct rpc_xprt *xprt, unsigned int cookie)/* Try to schedule an autoclose RPC call */ if (test_and_set_bit (XPRT_LOCKED , &xprt->state) ==0 )queue_work (rpciod_workqueue, &xprt->task_cleanup); -xprt_wake_pending_tasks (xprt, -ENOTCONN ); +xprt_wake_pending_tasks (xprt, -EAGAIN ); out:spin_unlock_bh (&xprt->transport_lock); }
@@ -726,9 +726,8 @@ static void xprt_connect_status(struct rpc_task *task) }switch (task->tk_status) { -case -ENOTCONN : -dprintk ("RPC: %5u xprt_connect_status: connection broken\n" , - task->tk_pid); +case -EAGAIN : +dprintk ("RPC: %5u xprt_connect_status: retrying\n" , task->tk_pid);break ;case -ETIMEDOUT : dprintk("RPC: %5u xprt_connect_status: connect attempt timed "
@@ -849,15 +848,8 @@ int xprt_prepare_transmit(struct rpc_task *task) err = req->rq_received; goto out_unlock; } -if (!xprt->ops->reserve_xprt (task)) { +if (!xprt->ops->reserve_xprt (task)) err = -EAGAIN ; - goto out_unlock; - } - -if (!xprt_connected (xprt)) { - err = -ENOTCONN ; - goto out_unlock; - } out_unlock:spin_unlock_bh (&xprt->transport_lock);return err;
net/sunrpc/xprtsock.c +31 -27
78 lines not on this page · raw message
PATCH 25/30 SUNRPC: Delay, then retry on connection errors.
In reply to a message not in the archiveEnforce the comment in xs_tcp_connect_worker4/xs_tcp_connect_worker6 that we should delay, then retry on certain connection errors.
---
net/sunrpc/xprtsock.c | 34 ++++++++++++++++------------------ 1 files changed, 16 insertions(+), 18 deletions(-)
net/sunrpc/xprtsock.c +16 -18
@@ -1722,20 +1722,19 @@ static void xs_tcp_connect_worker4(struct work_struct *work) xprt, -status,xprt_connected (xprt), sock->sk->sk_state);switch (status) { +case -ECONNREFUSED : +case -ECONNRESET : +case -ENETUNREACH : +/* retry with existing socket, after a delay */ case 0 :case -EINPROGRESS :case -EALREADY : goto out_clear; -case -ECONNREFUSED : -case -ECONNRESET : -/* retry with existing socket, after a delay */ -break ; -default : -/* get rid of existing socket, and retry */ -xs_tcp_shutdown (xprt); -printk ("%s: connect returned unhandled error %d\n" , - __func__, status); } +/* get rid of existing socket, and retry */ +xs_tcp_shutdown (xprt); +printk ("%s: connect returned unhandled error %d\n" , + __func__, status); status = -EAGAIN ; out:xprt_wake_pending_tasks (xprt, status);
@@ -1783,20 +1782,19 @@ static void xs_tcp_connect_worker6(struct work_struct *work)dprintk ("RPC: %p connect status %d connected %d sock state %d\n" , xprt, -status,xprt_connected (xprt), sock->sk->sk_state);switch (status) { +case -ECONNREFUSED : +case -ECONNRESET : +case -ENETUNREACH : +/* retry with existing socket, after a delay */ case 0 :case -EINPROGRESS :case -EALREADY : goto out_clear; -case -ECONNREFUSED : -case -ECONNRESET : -/* retry with existing socket, after a delay */ -break ; -default : -/* get rid of existing socket, and retry */ -xs_tcp_shutdown (xprt); -printk ("%s: connect returned unhandled error %d\n" , - __func__, status); } +/* get rid of existing socket, and retry */ +xs_tcp_shutdown (xprt); +printk ("%s: connect returned unhandled error %d\n" , + __func__, status); status = -EAGAIN ; out:xprt_wake_pending_tasks (xprt, status);
PATCH 26/30 SUNRPC: Ensure that xs_nospace return values are propagated
In reply to a message not in the archiveIf xs_nospace() finds that the socket has disconnected, it attempts to return ENOTCONN, however that value is then squashed by the callers.
---
net/sunrpc/xprtsock.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)
net/sunrpc/xprtsock.c +7 -4
@@ -521,11 +521,12 @@ static void xs_nospace_callback(struct rpc_task *task)* @task: task to put to sleep * */ -static void xs_nospace (struct rpc_task *task) +static int xs_nospace (struct rpc_task *task) {struct rpc_rqst *req = task->tk_rqstp;struct rpc_xprt *xprt = req->rq_xprt; struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); +int ret =0 ; dprintk("RPC: %5u xmit incomplete (%u left of %u)\n", task->tk_pid, req->rq_slen - req->rq_bytes_sent,
@@ -537,6 +538,7 @@ static void xs_nospace(struct rpc_task *task)/* Don't race with disconnect */ if (xprt_connected (xprt)) {if (test_bit (SOCK_ASYNC_NOSPACE , &transport->sock->flags)) { + ret = -EAGAIN ;/* * Notify TCP that we're limited by the application * window size
@@ -548,10 +550,11 @@ static void xs_nospace(struct rpc_task *task) } }else {clear_bit (SOCK_ASYNC_NOSPACE , &transport->sock->flags); - task->tk_status = -ENOTCONN ; + ret = -ENOTCONN ; }spin_unlock_bh (&xprt->transport_lock); +return ret; }/**
@@ -603,7 +606,7 @@ static int xs_udp_send_request(struct rpc_task *task)/* Should we call xs_close() here? */ break ;case -EAGAIN : -xs_nospace (task); + status =xs_nospace (task);break ;default : dprintk("RPC: sendmsg returned unrecognized error %d\n",
@@ -706,7 +709,7 @@ static int xs_tcp_send_request(struct rpc_task *task)/* Should we call xs_close() here? */ break ;case -EAGAIN : -xs_nospace (task); + status =xs_nospace (task);break ;default : dprintk("RPC: sendmsg returned unrecognized error %d\n",
PATCH 27/30 SUNRPC: Always report 'unrecognised error' cases...
In reply to a message not in the archive---
net/sunrpc/clnt.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
net/sunrpc/clnt.c +7 -2
@@ -27,6 +27,7 @@#include <linux/types.h> #include <linux/kallsyms.h> #include <linux/mm.h> +#include <linux/net.h> #include <linux/slab.h> #include <linux/smp_lock.h> #include <linux/utsname.h>
@@ -988,8 +989,9 @@ call_bind_status(struct rpc_task *task) task->tk_action = call_bind;return ;default : -dprintk ("RPC: %5u unrecognized rpcbind error (%d)\n" , - task->tk_pid, -task->tk_status); +if (net_ratelimit ()) +printk ("RPC: %5u unrecognized rpcbind error (%d)\n" , + task->tk_pid, -task->tk_status); }rpc_exit (task, status);
@@ -1044,6 +1046,9 @@ call_connect_status(struct rpc_task *task) task->tk_action = call_timeout;break ;default : +if (net_ratelimit ()) +printk ("RPC: %5u unrecognized connect error (%d)\n" , + task->tk_pid, status);rpc_exit (task, -EIO ); } }
PATCH 28/30 SUNRPC: Add the equivalent of the linger and linger2 timeouts to RPC sockets
In reply to a message not in the archiveThis fixes a regression against FreeBSD servers as reported by Tomas Kasparek. Apparently when using RPC over a TCP socket, the FreeBSD servers don't ever react to the client closing the socket, and so commit e06799f958bf7f9f8fae15f0c6f519953fb0257c (SUNRPC: Use shutdown() instead of close() when disconnecting a TCP socket) causes the setup to hang forever whenever the client attempts to close and then reconnect.
We break the deadlock by adding a 'linger2' style timeout to the socket, after which, the client will abort the connection using a TCP 'RST'.
The default timeout is set to 15 seconds. A subsequent patch will put it under user control by means of a systctl.
---
include/linux/sunrpc/xprt.h | 1 net/sunrpc/xprtsock.c | 98 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 82 insertions(+), 17 deletions(-)
include/linux/sunrpc/xprt.h +1 -0
@@ -260,6 +260,7 @@ void xprt_conditional_disconnect(struct rpc_xprt *xprt, unsigned int cookie);#define XPRT_BOUND (4)#define XPRT_BINDING (5)#define XPRT_CLOSING (6) +#define XPRT_CONNECTION_ABORT (7)static inline void xprt_set_connected (struct rpc_xprt *xprt) {
net/sunrpc/xprtsock.c +81 -17
211 lines not on this page · raw message
PATCH 29/30 SUNRPC: Add a sysctl to control the duration of the socket linger timeout
In reply to a message not in the archive---
net/sunrpc/xprtsock.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-)
net/sunrpc/xprtsock.c +11 -2
@@ -50,6 +50,7 @@ unsigned int xprt_min_resvport = RPC_DEF_MIN_RESVPORT;unsigned int xprt_max_resvport =RPC_DEF_MAX_RESVPORT ;#define XS_TCP_LINGER_TO (15U * HZ) +static unsigned int xs_tcp_fin_timeout__read_mostly =XS_TCP_LINGER_TO ;/* * We can register our own files under /proc/sys/sunrpc by
@@ -119,6 +120,14 @@ static ctl_table xs_tunables_table[] = { .extra2 = &xprt_max_resvport_limit }, { + .procname = "tcp_fin_timeout", + .data = &xs_tcp_fin_timeout, + .maxlen = sizeof(xs_tcp_fin_timeout), + .mode = 0644, + .proc_handler = &proc_dointvec_jiffies, + .strategy = sysctl_jiffies + }, + { .ctl_name = 0, }, };
@@ -1222,7 +1231,7 @@ static void xs_tcp_state_change(struct sock *sk)clear_bit (XPRT_CONNECTED , &xprt->state);clear_bit (XPRT_CLOSE_WAIT , &xprt->state);smp_mb__after_clear_bit (); -xs_tcp_schedule_linger_timeout (xprt,XS_TCP_LINGER_TO ); +xs_tcp_schedule_linger_timeout (xprt, xs_tcp_fin_timeout);break ;case TCP_CLOSE_WAIT :/* The server initiated a shutdown of the socket */
@@ -1239,7 +1248,7 @@ static void xs_tcp_state_change(struct sock *sk)break ;case TCP_LAST_ACK :set_bit (XPRT_CLOSING , &xprt->state); -xs_tcp_schedule_linger_timeout (xprt,XS_TCP_LINGER_TO ); +xs_tcp_schedule_linger_timeout (xprt, xs_tcp_fin_timeout);smp_mb__before_clear_bit ();clear_bit (XPRT_CONNECTED , &xprt->state);smp_mb__after_clear_bit ();
A message that is not in the archive (sent off-list or not yet received): 20090311184110.5578.89380.stgit-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
Re: [PATCH 29/30] SUNRPC: Add a sysctl to control the duration of the socket linger timeout
Out of curiosity: how would a user decide what to set this to?
--b.
Quoted 57 lines · Trond Myklebust
Signed-off-by Trond Myklebust <[email protected]>---
net/sunrpc/xprtsock.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-)net/sunrpc/xprtsock.c +11
-3@@ -50,6 +50,7 @@ unsigned int xprt_min_resvport = RPC_DEF_MIN_RESVPORT;unsigned int xprt_max_resvport =RPC_DEF_MAX_RESVPORT ;#define XS_TCP_LINGER_TO (15U * HZ) +static unsigned int xs_tcp_fin_timeout__read_mostly =XS_TCP_LINGER_TO ;/* * We can register our own files under /proc/sys/sunrpc by @@ -119,6 +120,14 @@ static ctl_table xs_tunables_table[] = { .extra2 = &xprt_max_resvport_limit }, { + .procname = "tcp_fin_timeout", + .data = &xs_tcp_fin_timeout, + .maxlen = sizeof(xs_tcp_fin_timeout), + .mode = 0644, + .proc_handler = &proc_dointvec_jiffies, + .strategy = sysctl_jiffies + }, + { .ctl_name = 0, }, };@@ -1222,7 +1231,7 @@ static void xs_tcp_state_change(struct sock *sk)clear_bit (XPRT_CONNECTED , &xprt->state);clear_bit (XPRT_CLOSE_WAIT , &xprt->state);smp_mb__after_clear_bit (); -xs_tcp_schedule_linger_timeout (xprt,XS_TCP_LINGER_TO ); +xs_tcp_schedule_linger_timeout (xprt, xs_tcp_fin_timeout);break ;case TCP_CLOSE_WAIT :/* The server initiated a shutdown of the socket */ @@ -1239,7 +1248,7 @@ static void xs_tcp_state_change(struct sock *sk)break ;case TCP_LAST_ACK :set_bit (XPRT_CLOSING , &xprt->state); -xs_tcp_schedule_linger_timeout (xprt,XS_TCP_LINGER_TO ); +xs_tcp_schedule_linger_timeout (xprt, xs_tcp_fin_timeout);smp_mb__before_clear_bit ();clear_bit (XPRT_CONNECTED , &xprt->state);smp_mb__after_clear_bit (); --To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 29/30] SUNRPC: Add a sysctl to control the duration of the socket linger timeout
Quoted 1 line · J. Bruce Fields
Out of curiosity: how would a user decide what to set this to?
Most people would want to set it to a large value. The only ones who would really care would be those who have broken servers, and they would probably want to tune it so as to provide a decent interactive response when pressing ^C....
Trond
Quoted 60 lines
--b.
Quoted 57 lines · Trond Myklebust
Signed-off-by Trond Myklebust <[email protected]>---
net/sunrpc/xprtsock.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-)net/sunrpc/xprtsock.c +11
-3@@ -50,6 +50,7 @@ unsigned int xprt_min_resvport = RPC_DEF_MIN_RESVPORT;unsigned int xprt_max_resvport =RPC_DEF_MAX_RESVPORT ;#define XS_TCP_LINGER_TO (15U * HZ) +static unsigned int xs_tcp_fin_timeout__read_mostly =XS_TCP_LINGER_TO ;/* * We can register our own files under /proc/sys/sunrpc by @@ -119,6 +120,14 @@ static ctl_table xs_tunables_table[] = { .extra2 = &xprt_max_resvport_limit }, { + .procname = "tcp_fin_timeout", + .data = &xs_tcp_fin_timeout, + .maxlen = sizeof(xs_tcp_fin_timeout), + .mode = 0644, + .proc_handler = &proc_dointvec_jiffies, + .strategy = sysctl_jiffies + }, + { .ctl_name = 0, }, };@@ -1222,7 +1231,7 @@ static void xs_tcp_state_change(struct sock *sk)clear_bit (XPRT_CONNECTED , &xprt->state);clear_bit (XPRT_CLOSE_WAIT , &xprt->state);smp_mb__after_clear_bit (); -xs_tcp_schedule_linger_timeout (xprt,XS_TCP_LINGER_TO ); +xs_tcp_schedule_linger_timeout (xprt, xs_tcp_fin_timeout);break ;case TCP_CLOSE_WAIT :/* The server initiated a shutdown of the socket */ @@ -1239,7 +1248,7 @@ static void xs_tcp_state_change(struct sock *sk)break ;case TCP_LAST_ACK :set_bit (XPRT_CLOSING , &xprt->state); -xs_tcp_schedule_linger_timeout (xprt,XS_TCP_LINGER_TO ); +xs_tcp_schedule_linger_timeout (xprt, xs_tcp_fin_timeout);smp_mb__before_clear_bit ();clear_bit (XPRT_CONNECTED , &xprt->state);smp_mb__after_clear_bit (); --To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
PATCH 30/30 SUNRPC: xs_tcp_connect_worker{4,6}: merge common code
In reply to a message not in the archive---
net/sunrpc/xprtsock.c | 140 +++++++++++++++++++++++++------------------------ 1 files changed, 72 insertions(+), 68 deletions(-)
net/sunrpc/xprtsock.c +72 -68
@@ -1738,33 +1738,29 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) }/** -* xs_tcp_connect_worker4 - connect a TCP socket to a remote endpoint -* @work: RPC transport to connect +* xs_tcp_setup_socket - create a TCP socket and connect to a remote endpoint +* @xprt: RPC transport to connect +* @transport: socket transport to connect +* @create_sock: function to create a socket of the correct type * * Invoked by a work queue tasklet. */ -static void xs_tcp_connect_worker4 (struct work_struct *work) +static void xs_tcp_setup_socket (struct rpc_xprt *xprt, +struct sock_xprt *transport, +struct socket *(*create_sock)(struct rpc_xprt *, +struct sock_xprt *)) { -struct sock_xprt *transport = - container_of(work, struct sock_xprt, connect_worker.work); -struct rpc_xprt *xprt = &transport->xprt;struct socket *sock = transport->sock; -int err, status = -EIO ; +int status = -EIO ;if (xprt->shutdown) goto out;if (!sock) {clear_bit (XPRT_CONNECTION_ABORT , &xprt->state); -/* start from scratch */ -if ((err =sock_create_kern (PF_INET ,SOCK_STREAM ,IPPROTO_TCP , &sock)) <0 ) { -dprintk ("RPC: can't create TCP transport socket (%d).\n" , -err); - goto out; - } -xs_reclassify_socket4 (sock); - -if (xs_bind4 (transport, sock) <0 ) { -sock_release (sock); + sock =create_sock (xprt, transport); +if (IS_ERR (sock)) { + status =PTR_ERR (sock); goto out; } }else {
@@ -1808,74 +1804,82 @@ out:xprt_wake_pending_tasks (xprt, status); } +static struct socket *xs_create_tcp_sock4 (struct rpc_xprt *xprt, +struct sock_xprt *transport) +{ +struct socket *sock; +int err; + +/* start from scratch */ + err =sock_create_kern (PF_INET ,SOCK_STREAM ,IPPROTO_TCP , &sock); +if (err <0 ) { +dprintk ("RPC: can't create TCP transport socket (%d).\n" , + -err); + goto out_err; + } +xs_reclassify_socket4 (sock); + +if (xs_bind4 (transport, sock) <0 ) { +sock_release (sock); + goto out_err; + } +return sock; +out_err: +return ERR_PTR (-EIO ); +} +/** -* xs_tcp_connect_worker6 - connect a TCP socket to a remote endpoint +* xs_tcp_connect_worker4 - connect a TCP socket to a remote endpoint * @work: RPC transport to connect * * Invoked by a work queue tasklet. */ -static void xs_tcp_connect_worker6 (struct work_struct *work) +static void xs_tcp_connect_worker4 (struct work_struct *work) {struct sock_xprt *transport = container_of(work, struct sock_xprt, connect_worker.work);struct rpc_xprt *xprt = &transport->xprt; -struct socket *sock = transport->sock; -int err, status = -EIO ; -if (xprt->shutdown) - goto out; - -if (!sock) { -clear_bit (XPRT_CONNECTION_ABORT , &xprt->state); -/* start from scratch */ -if ((err =sock_create_kern (PF_INET6 ,SOCK_STREAM ,IPPROTO_TCP , &sock)) <0 ) { -dprintk ("RPC: can't create TCP transport socket (%d).\n" , -err); - goto out; - } -xs_reclassify_socket6 (sock); +xs_tcp_setup_socket (xprt, transport, xs_create_tcp_sock4); +} -if (xs_bind6 (transport, sock) <0 ) { -sock_release (sock); - goto out; - } - }else { -int abort_and_exit; +static struct socket *xs_create_tcp_sock6 (struct rpc_xprt *xprt, +struct sock_xprt *transport) +{ +struct socket *sock; +int err; - abort_and_exit =test_and_clear_bit (XPRT_CONNECTION_ABORT , - &xprt->state); -/* "close" the socket, preserving the local port */ -xs_tcp_reuse_connection (xprt, transport); +/* start from scratch */ + err =sock_create_kern (PF_INET6 ,SOCK_STREAM ,IPPROTO_TCP , &sock); +if (err <0 ) { +dprintk ("RPC: can't create TCP transport socket (%d).\n" , + -err); + goto out_err; + } +xs_reclassify_socket6 (sock); -if (abort_and_exit) - goto out_eagain; +if (xs_bind6 (transport, sock) <0 ) { +sock_release (sock); + goto out_err; } +return sock; +out_err: +return ERR_PTR (-EIO ); +} -dprintk ("RPC: worker connecting xprt %p to address: %s\n" , - xprt, xprt->address_strings[RPC_DISPLAY_ALL ]); +/** +* xs_tcp_connect_worker6 - connect a TCP socket to a remote endpoint +* @work: RPC transport to connect +* +* Invoked by a work queue tasklet. +*/ +static void xs_tcp_connect_worker6 (struct work_struct *work) +{ +struct sock_xprt *transport = + container_of(work, struct sock_xprt, connect_worker.work); +struct rpc_xprt *xprt = &transport->xprt; - status =xs_tcp_finish_connecting (xprt, sock); -dprintk ("RPC: %p connect status %d connected %d sock state %d\n" , - xprt, -status,xprt_connected (xprt), sock->sk->sk_state); -switch (status) { -case -ECONNREFUSED : -case -ECONNRESET : -case -ENETUNREACH : -/* retry with existing socket, after a delay */ -case 0 : -case -EINPROGRESS : -case -EALREADY : -xprt_clear_connecting (xprt); -return ; - } -/* get rid of existing socket, and retry */ -xs_tcp_shutdown (xprt); -printk ("%s: connect returned unhandled error %d\n" , - __func__, status); -out_eagain: - status = -EAGAIN ; -out: -xprt_clear_connecting (xprt); -xprt_wake_pending_tasks (xprt, status); +xs_tcp_setup_socket (xprt, transport, xs_create_tcp_sock6); }/**