Introduction
Subsystems (4)
PATCH 1/1 Introduction
54 (!!) patches for knfsd. Mostly nfsv4 related from Bruce Fields and co.
First 3 are trivial, silencing a pointless warning and replacing schedule_timeout with msleep or usleep as appropriate.
The last three mail changes to 'leases' in fs/locks.c
The only substantial change is the last one which removes "remove_lease", which is currently only used by nfsv4 server.
[PATCH kNFSd 1 of 54] Fix error reported by nfsd which it gets ETXTBSY [PATCH kNFSd 2 of 54] replace schedule_timeout() with msleep()
[PATCH kNFSd 3 of 54] fs/nfs4callback: replace schedule_timeout() with ssleep() [PATCH kNFSd 4 of 54] nfsd4: remove utf8 checking
[PATCH kNFSd 5 of 54] nfsd4: create a slab cache for stateowners
[PATCH kNFSd 6 of 54] nfsd4: remove stateowner debug counters
[PATCH kNFSd 7 of 54] nfsd4: Fix oops on nfsd4 shutdown
[PATCH kNFSd 8 of 54] nfsd4: cbnull refcount leak
[PATCH kNFSd 9 of 54] nfsd4: reclaim cleanup
[PATCH kNFSd 10 of 54] nfsd4: move special stateid processing
[PATCH kNFSd 11 of 54] nfsd4: allow some reads and writes during the grace period [PATCH kNFSd 12 of 54] nfsd4: use existing open instead of reopening on read and write [PATCH kNFSd 13 of 54] nfsd4: miscellaneous open cleanup
[PATCH kNFSd 14 of 54] nfsd4: miscellaneous open cleanup 2
[PATCH kNFSd 15 of 54] nfsd4: miscellaneous open cleanup 3
[PATCH kNFSd 16 of 54] nfsd4: don't release nfs4_file with associated delegations [PATCH kNFSd 17 of 54] nfsd4: do callback replays by hand
[PATCH kNFSd 18 of 54] nfsd4: simplify open_delegation
[PATCH kNFSd 19 of 54] nfsd4: simplify open_delegation 2
[PATCH kNFSd 20 of 54] nfsd4: miscellaneous delegation fixes
[PATCH kNFSd 21 of 54] nfsd4: remove unnecessary check in find_delegation_stateid [PATCH kNFSd 22 of 54] nfsd4: fix nfs4_check_delegmode()
[PATCH kNFSd 23 of 54] nfsd4: simplify clientid hash table searches [PATCH kNFSd 24 of 54] nfsd4: simplify verify_clientid
[PATCH kNFSd 25 of 54] nfsd4: don't allow unconfirmed renew
[PATCH kNFSd 26 of 54] nfsd4: provide no_cb_path error on renew
[PATCH kNFSd 27 of 54] nfsd4: simplify find_openstateowner_str
[PATCH kNFSd 28 of 54] nfsd4: simplify find functions
[PATCH kNFSd 29 of 54] nfsd4: return callback_ident in callbacks
[PATCH kNFSd 30 of 54] nfsd4: remove incorrect kfree from callback [PATCH kNFSd 31 of 54] nfsd4: make nfsd4_cb_recall return void
[PATCH kNFSd 32 of 54] nfsd4: fix callback cred refcnt leak
[PATCH kNFSd 33 of 54] nfsd4: use sync rpc for delegation recall
[PATCH kNFSd 34 of 54] nfsd4: trivial callback cleanup
[PATCH kNFSd 35 of 54] nfsd4: nfs4_cb_recall cleanup
[PATCH kNFSd 36 of 54] nfsd4: remove dl_recall_cnt
[PATCH kNFSd 37 of 54] nfsd4: rename release_stateid_lockowner
[PATCH kNFSd 38 of 54] nfsd4: keep lockowners off perclient list
[PATCH kNFSd 39 of 54] nfsd4: fix laundromat delegation reaping
[PATCH kNFSd 40 of 54] nfsd4: remove st_vfs_set
[PATCH kNFSd 41 of 54] nfsd4: remove st_vfs_file checks
[PATCH kNFSd 42 of 54] nfsd4: fix cb-race
[PATCH kNFSd 43 of 54] nfsd4: fix delegation refcounting
[PATCH kNFSd 44 of 54] nfsd4: reorganize release_deleg
[PATCH kNFSd 45 of 54] nfsd4: store-file-with-deleg
[PATCH kNFSd 46 of 54] nfsd4: fix delegation filp sharing
[PATCH kNFSd 47 of 54] nfsd4: fix sleep under spinlock
[PATCH kNFSd 48 of 54] nfsd4: allow io to use deleg stateid file
[PATCH kNFSd 49 of 54] nfsd4: remove dl_state
[PATCH kNFSd 50 of 54] nfsd4: fix delegation refcount leak
[PATCH kNFSd 51 of 54] nfsd4: fix_release_state_owner prototype
[PATCH kNFSd 52 of 54] locks: remove unnecessary BUG()
[PATCH kNFSd 53 of 54] nfsd4: move delegation decisions to lock_manager callbacks [PATCH kNFSd 54 of 54] nfsd4: eliminate unnecessary remove_lease
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: create a slab cache for stateowners
Create a slab cache for nfsv4 stateowners.
### Diffstat output
./fs/nfsd/nfs4state.c | 55 ++++++++++++++++++++++++++++++++++++-------- ./fs/nfsd/nfssvc.c | 6 +++- ./include/linux/nfsd/nfsd.h | 4 +-- 3 files changed, 52 insertions(+), 13 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +46 -9
@@ -985,14 +985,38 @@ release_all_files(void) } } -/* should use a slab cache */ +kmem_cache_t *stateowner_slab =NULL ; + +static int +nfsd4_init_slabs (void ) +{ + stateowner_slab =kmem_cache_create ("nfsd4_stateowners" , +sizeof (struct nfs4_stateowner ),0 ,0 ,NULL ,NULL ); +if (stateowner_slab ==NULL ) { +dprintk ("nfsd4: out of memory while initializing nfsv4\n" ); +return -ENOMEM ; + } +return 0 ; +} + +static void +nfsd4_free_slabs (void ) +{ +int status =0 ; + +if (stateowner_slab) + status =kmem_cache_destroy (stateowner_slab); + stateowner_slab =NULL ; +BUG_ON (status); +} +void nfs4_free_stateowner (struct kref *kref) {struct nfs4_stateowner *sop = container_of(kref, struct nfs4_stateowner, so_ref);kfree (sop->so_owner.data); -kfree (sop); +kmem_cache_free (stateowner_slab, sop); free_sowner++; }
@@ -1001,14 +1025,14 @@ alloc_stateowner(struct xdr_netobj *owne {struct nfs4_stateowner *sop; -if ((sop =kmalloc (sizeof (struct nfs4_stateowner ),GFP_KERNEL ))) { +if ((sop =kmem_cache_alloc (stateowner_slab,GFP_KERNEL ))) {if ((sop->so_owner.data =kmalloc (owner->len,GFP_KERNEL ))) {memcpy (sop->so_owner.data, owner->data, owner->len); sop->so_owner.len = owner->len;kref_init (&sop->so_ref);return sop; } -kfree (sop); +kmem_cache_free (stateowner_slab, sop); }return NULL ; }
@@ -3129,14 +3153,12 @@ nfs4_check_open_reclaim(clientid_t *clid* Start and stop routines */ -void -nfs4_state_init (void ) +static void +__nfs4_state_init (void ) {int i;time_t grace_time; -if (nfs4_init) -return ;if (!nfs4_reclaim_init) {for (i =0 ; i <CLIENT_HASH_SIZE ; i++)INIT_LIST_HEAD (&reclaim_str_hashtbl[i]);
@@ -3180,7 +3202,21 @@ nfs4_state_init(void) grace_end = boot_time + grace_time;INIT_WORK (&laundromat_work,laundromat_main,NULL );schedule_delayed_work (&laundromat_work,NFSD_LEASE_TIME *HZ ); +} + +int +nfs4_state_init (void ) +{ +int status; + +if (nfs4_init) +return 0 ; + status =nfsd4_init_slabs (); +if (status) +return status; +__nfs4_state_init (); nfs4_init =1 ; +return 0 ; }int
@@ -3253,6 +3289,7 @@ nfs4_state_shutdown(void)nfs4_lock_state ();nfs4_release_reclaim ();__nfs4_state_shutdown (); +nfsd4_free_slabs ();nfs4_unlock_state (); }
@@ -3305,7 +3342,7 @@ nfs4_reset_lease(time_t leasetime) } init_state:__nfs4_state_shutdown (); -nfs4_state_init (); +__nfs4_state_init ();nfs4_unlock_state (); }
fs/nfsd/nfssvc.c renamed from fs/nfsd/nfssvc.c~current~ +4 -2
@@ -94,8 +94,10 @@ nfsd_svc(unsigned short port, int nrserv nrservs =NFSD_MAXSERVS ;/* Readahead param cache - will no-op if it already exists */ - error =nfsd_racache_init (2 *nrservs); -nfs4_state_init (); + error =nfsd_racache_init (2 *nrservs); +if (error<0 ) + goto out; + error =nfs4_state_init ();if (error<0 ) goto out;if (!nfsd_serv) {
include/linux/nfsd/nfsd.h renamed from include/linux/nfsd/nfsd.h~current~ +2 -2
@@ -148,12 +148,12 @@ nfsd_set_posix_acl(struct svc_fh *fhp, i* NFSv4 State */ #ifdef CONFIG_NFSD_V4 -void nfs4_state_init (void ); +int nfs4_state_init (void );void nfs4_state_shutdown (void );time_t nfs4_lease_time (void );void nfs4_reset_lease (time_t leasetime);#else -static inline void nfs4_state_init (void ){} +static inline int nfs4_state_init (void ){}static inline void nfs4_state_shutdown (void ){}static inline time_t nfs4_lease_time (void ){return 0 ;}static inline void nfs4_reset_lease (time_t leasetime){}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: reclaim cleanup
In reply to NeilBrownRemove unnecessary fields in the nfs4_client_reclaim structure. Initialize reclaim_str_hashtbl_size and increment it inside of nfs4_client_to_reclaim. Modify client_to_reclaim() in preparation for reboot recovery.
### Diffstat output
./fs/nfsd/nfs4state.c | 38 +++++++++++++------------------------- ./include/linux/nfsd/state.h | 3 --- 2 files changed, 13 insertions(+), 28 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +13 -25
@@ -257,7 +257,7 @@ release_delegation(struct nfs4_delegatio* for last close replay. */ static struct list_head reclaim_str_hashtbl[CLIENT_HASH_SIZE ]; -static int reclaim_str_hashtbl_size; +static int reclaim_str_hashtbl_size =0 ;static struct list_head conf_id_hashtbl[CLIENT_HASH_SIZE ];static struct list_head conf_str_hashtbl[CLIENT_HASH_SIZE ];static struct list_head unconf_str_hashtbl[CLIENT_HASH_SIZE ];
@@ -2207,17 +2207,6 @@ check_replay: goto out; } -/* -* eventually, this will perform an upcall to the 'state daemon' as well as -* set the cl_first_state field. -*/ -void -first_state (struct nfs4_client *clp) -{ -if (!clp->cl_first_state) - clp->cl_first_state =get_seconds (); -} -int nfsd4_open_confirm (struct svc_rqst *rqstp,struct svc_fh *current_fh,struct nfsd4_open_confirm *oc) {
@@ -2250,8 +2239,6 @@ nfsd4_open_confirm(struct svc_rqst *rqst stp->st_stateid.si_stateownerid, stp->st_stateid.si_fileid, stp->st_stateid.si_generation); - status = nfs_ok; -first_state (sop->so_client); out:if (oc->oc_stateowner)nfs4_get_stateowner (oc->oc_stateowner);
@@ -3057,21 +3044,21 @@ alloc_reclaim(int namelen)* failure => all reset bets are off, nfserr_no_grace... */ static int -nfs4_client_to_reclaim (struct nfs4_client *clp) +nfs4_client_to_reclaim (char *name,int namlen) {unsigned int strhashval;struct nfs4_client_reclaim *crp =NULL ; - crp =alloc_reclaim (clp->cl_name.len); +dprintk ("NFSD nfs4_client_to_reclaim NAME: %.*s\n" , namlen, name); + crp =alloc_reclaim (namlen);if (!crp)return 0 ; - strhashval =clientstr_hashval (clp->cl_name.data, clp->cl_name.len); + strhashval =clientstr_hashval (name, namlen);INIT_LIST_HEAD (&crp->cr_strhash);list_add (&crp->cr_strhash, &reclaim_str_hashtbl[strhashval]); -memcpy (crp->cr_name.data, clp->cl_name.data, clp->cl_name.len); - crp->cr_name.len = clp->cl_name.len; - crp->cr_first_state = clp->cl_first_state; - crp->cr_expired =0 ; +memcpy (crp->cr_name.data, name, namlen); + crp->cr_name.len = namlen; + reclaim_str_hashtbl_size++;return 1 ; }
@@ -3116,6 +3103,9 @@ nfs4_find_reclaim_client(clientid_t *cliif (!client)return NULL ; +dprintk ("NFSD: nfs4_find_reclaim_client for %.*s\n" , + clp->cl_name.len, clp->cl_name.data); +/* find clp->cl_name in reclaim_str_hashtbl */ strhashval =clientstr_hashval (client->cl_name.data, client->cl_name.len);
@@ -3137,8 +3127,6 @@ nfs4_check_open_reclaim(clientid_t *clidif ((crp =nfs4_find_reclaim_client (clid)) ==NULL )return nfserr_reclaim_bad; -if (crp->cr_expired) -return nfserr_no_grace;return nfs_ok; }
@@ -3332,11 +3320,11 @@ nfs4_reset_lease(time_t leasetime)/* populate reclaim_str_hashtbl with current confirmed nfs4_clientid */ for (i =0 ; i <CLIENT_HASH_SIZE ; i++) {list_for_each_entry (clp, &conf_id_hashtbl[i], cl_idhash) { -if (!nfs4_client_to_reclaim (clp)) { +if (!nfs4_client_to_reclaim (clp->cl_name.data, + clp->cl_name.len)) {nfs4_release_reclaim (); goto init_state; } - reclaim_str_hashtbl_size++; } } init_state:
include/linux/nfsd/state.h renamed from include/linux/nfsd/state.h~current~ +0 -3
@@ -141,7 +141,6 @@ struct nfs4_client {clientid_t cl_clientid;/* generated by server */ nfs4_verifier cl_confirm;/* generated by server */ struct nfs4_callback cl_callback;/* callback info */ -time_t cl_first_state;/* first state aquisition*/ atomic_t cl_count;/* ref count */ };
@@ -153,8 +152,6 @@ struct nfs4_client {struct nfs4_client_reclaim {struct list_head cr_strhash;/* hash by cr_name */ struct xdr_netobj cr_name;/* id generated by client */ -time_t cr_first_state;/* first state aquisition */ -u32 cr_expired;/* boolean: lease expired? */ }; static inline void
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: miscellaneous open cleanup 2
In reply to NeilBrownReplace sequence of if {... goto} 's by if-elseif's, other minor simplification of logic.
### Diffstat output
./fs/nfsd/nfs4state.c | 45 +++++++++++++++++++++------------------------ 1 files changed, 21 insertions(+), 24 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +21 -24
@@ -1464,7 +1464,9 @@ nfsd4_process_open1(struct nfsd4_open *o open->op_stateowner = sop;/* check for replay */ if (open->op_seqid == sop->so_seqid){ -if (!sop->so_replay.rp_buflen) { +if (sop->so_replay.rp_buflen) +return NFSERR_REPLAY_ME ; +else {/* The original OPEN failed so spectacularly * that we don't even have replay data saved! * Therefore, we have no choice but to continue
@@ -1476,37 +1478,32 @@ nfsd4_process_open1(struct nfsd4_open *o status =NFS_OK ; goto renew; } - status =NFSERR_REPLAY_ME ; -return status; - } -if (sop->so_confirmed) { + }else if (sop->so_confirmed) {if (open->op_seqid == sop->so_seqid +1 ) { status = nfs_ok; goto renew; } status = nfserr_bad_seqid; goto out; + }else { +/* If we get here, we received an OPEN for an +* unconfirmed nfs4_stateowner. Since the seqid's are +* different, purge the existing nfs4_stateowner, and +* instantiate a new one. +*/ + clp = sop->so_client; +release_stateowner (sop); } -/* If we get here, we received an OPEN for an unconfirmed -* nfs4_stateowner. -* Since the sequid's are different, purge the -* existing nfs4_stateowner, and instantiate a new one. + }else { +/* nfs4_stateowner not found. +* Verify clientid and instantiate new nfs4_stateowner. +* If verify fails this is presumably the result of the +* client's lease expiring. */ - clp = sop->so_client; -release_stateowner (sop); - goto instantiate_new_owner; - } -/* nfs4_stateowner not found. -* verify clientid and instantiate new nfs4_stateowner -* if verify fails this is presumably the result of the -* client's lease expiring. -* -* XXX compare clp->cl_addr with rqstp addr? -*/ - status = nfserr_expired; -if (!verify_clientid (&clp, clientid)) - goto out; -instantiate_new_owner: + status = nfserr_expired; +if (!verify_clientid (&clp, clientid)) + goto out; + } status = nfserr_resource;if (!(sop =alloc_init_open_stateowner (strhashval, clp, open))) goto out;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 Fix error reported by nfsd which it gets ETXTBSY
In reply to NeilBrownETXTBSY doesn't have a direct anaolog in NFS, so just map it to nfserr_io.
As this is the default error code this does not change the operation of nfsd. It only reduces logging.
From: "G. Allen Morris III" <[email protected]>
### Diffstat output
./fs/nfsd/nfsproc.c | 1 + 1 files changed, 1 insertion(+)
fs/nfsd/nfsproc.c renamed from fs/nfsd/nfsproc.c~current~ +1 -0
@@ -590,6 +590,7 @@ nfserrno (int errno) { nfserr_dropit, -EAGAIN }, { nfserr_dropit, -ENOMEM }, { nfserr_badname, -ESRCH }, + { nfserr_io, -ETXTBSY }, { nfserr_notsupp, -EOPNOTSUPP }, { -1, -EIO } };
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 fs/nfs4callback: replace schedule_timeout() with ssleep()
In reply to NeilBrownUse ssleep() instead of schedule_timeout() to guarantee the task delays as expected.
### Diffstat output
./fs/nfsd/nfs4callback.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +2 -2
@@ -38,6 +38,7 @@#include <linux/list.h> #include <linux/inet.h> #include <linux/errno.h> +#include <linux/delay.h> #include <linux/sunrpc/xdr.h> #include <linux/sunrpc/svc.h> #include <linux/sunrpc/clnt.h>
@@ -531,8 +532,7 @@ out: retry:atomic_inc (&dp->dl_recall_cnt);/* sleep 2 seconds before retrying recall */ -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (2 *HZ ); +ssleep (2 ); status =nfsd4_cb_recall (dp);dprintk ("NFSD: nfs4_cb_recall_done: retry status: %d dp %p dl_flock %p\n" ,status,dp, dp->dl_flock); }
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: remove stateowner debug counters
In reply to NeilBrownGet rid of these debug counters. Since they're no longer necessarily incremented under state lock, we'd need to convert them to atomic_t to guarantee them correct. It doesn't seem worth it.
Also, the debug checks in kmem_cache_destroy() should be sufficient for at least one of the purposes the debugging counters existed for--we'll get a dump_stack() if there are still stateowners left when we shut down.
### Diffstat output
./fs/nfsd/nfs4state.c | 8 -------- 1 files changed, 8 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +0 -8
@@ -72,11 +72,8 @@ u32 add_perclient = 0;u32 del_perclient =0 ;u32 alloc_file =0 ;u32 free_file =0 ; -u32 alloc_sowner =0 ; -u32 free_sowner =0 ;u32 vfsopen =0 ;u32 vfsclose =0 ; -u32 alloc_lsowner=0 ;u32 alloc_delegation=0 ;u32 free_delegation=0 ;
@@ -1017,7 +1014,6 @@ nfs4_free_stateowner(struct kref *kref) container_of(kref, struct nfs4_stateowner, so_ref);kfree (sop->so_owner.data);kmem_cache_free (stateowner_slab, sop); - free_sowner++; } static inline struct nfs4_stateowner *
@@ -1066,7 +1062,6 @@ alloc_init_open_stateowner(unsigned int rp->rp_status =NFSERR_SERVERFAULT ; rp->rp_buflen =0 ; rp->rp_buf = rp->rp_ibuf; - alloc_sowner++;return sop; }
@@ -2589,7 +2584,6 @@ alloc_init_lock_stateowner(unsigned int rp->rp_status =NFSERR_SERVERFAULT ; rp->rp_buflen =0 ; rp->rp_buf = rp->rp_ibuf; - alloc_lsowner++;return sop; }
@@ -3274,8 +3268,6 @@ __nfs4_state_shutdown(void) add_perclient, del_perclient);dprintk ("NFSD: alloc_file %d free_file %d\n" , alloc_file, free_file); -dprintk ("NFSD: alloc_sowner %d alloc_lsowner %d free_sowner %d\n" , - alloc_sowner, alloc_lsowner, free_sowner);dprintk ("NFSD: vfsopen %d vfsclose %d\n" , vfsopen, vfsclose); dprintk("NFSD: alloc_delegation %d free_delegation %d\n",
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: Fix oops on nfsd4 shutdown
In reply to NeilBrownFix Oops at nfsd shutdown. Reap any open nfs4_stateowners remaining on the close_lru hash list prior to reaping nfs4_clients at shutdown.
### Diffstat output
./fs/nfsd/nfs4state.c | 7 +++++++ 1 files changed, 7 insertions(+)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +7 -0
@@ -3238,8 +3238,15 @@ __nfs4_state_shutdown(void)int i;struct nfs4_client *clp =NULL ;struct nfs4_delegation *dp =NULL ; +struct nfs4_stateowner *sop =NULL ;struct list_head *pos, *next; +list_for_each_safe (pos, next, &close_lru) { + sop = list_entry(pos, struct nfs4_stateowner, so_close_lru); +list_del (&sop->so_close_lru); +nfs4_put_stateowner (sop); + } +for (i =0 ; i <CLIENT_HASH_SIZE ; i++) {while (!list_empty (&conf_id_hashtbl[i])) { clp = list_entry(conf_id_hashtbl[i].next, struct nfs4_client, cl_idhash);
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: simplify open_delegation
In reply to NeilBrownThe DONT_DELEGATE flag is superfluous.
### Diffstat output
./fs/nfsd/nfs4state.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +2 -6
@@ -1522,8 +1522,6 @@ nfs4_deleg_conflict(u32 share, u32 dtype dtype == NFS4_OPEN_DELEGATE_WRITE)); } -#define DONT_DELEGATE 8 -/* * nfs4_check_deleg_recall() *
@@ -1544,7 +1542,7 @@ nfs4_check_deleg_recall(struct nfs4_fileif (nfs4_deleg_conflict (op->op_share_access, dp->dl_type)) status = nfserr_jukebox;else - *flag =DONT_DELEGATE ; + *flag =NFS4_OPEN_DELEGATE_NONE ; } }return status;
@@ -1663,10 +1661,8 @@ nfs4_open_delegation(struct svc_fh *fh,struct file_lock fl, *flp = &fl;int status; -if (*flag ==DONT_DELEGATE ) { - *flag =NFS4_OPEN_DELEGATE_NONE ; +if (*flag ==NFS4_OPEN_DELEGATE_NONE )return ; - }/* set flag */ *flag =NFS4_OPEN_DELEGATE_NONE ;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: cbnull refcount leak
In reply to NeilBrownProperly decrement refcount on failure in nfsd4_probe_callback.
### Diffstat output
./fs/nfsd/nfs4callback.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +2 -1
@@ -435,7 +435,6 @@ nfsd4_probe_callback(struct nfs4_client clnt->cl_intr =1 ; clnt->cl_softrtry =1 ; clnt->cl_chatty =1 ; - cb->cb_client = clnt;/* Kick rpciod, put the call on the wire. */
@@ -445,6 +444,7 @@ nfsd4_probe_callback(struct nfs4_client }/* the task holds a reference to the nfs4_client struct */ + cb->cb_client = clnt;atomic_inc (&clp->cl_count); msg.rpc_cred =nfsd4_lookupcred (clp,0 );
@@ -457,6 +457,7 @@ nfsd4_probe_callback(struct nfs4_clientreturn ; out_rpciod: +atomic_dec (&clp->cl_count);rpciod_down (); out_clnt:rpc_shutdown_client (clnt);
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: move special stateid processing
In reply to NeilBrownMove special stateid processing to nfs4_preprocess_stateid_op(). Also make stateid processing for setattr the same as that for write.
### Diffstat output
./fs/nfsd/nfs4proc.c | 38 +------------------------------------- ./fs/nfsd/nfs4state.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 37 deletions(-)
fs/nfsd/nfs4proc.c renamed from fs/nfsd/nfs4proc.c~current~ +1 -37
@@ -473,25 +473,6 @@ nfsd4_read(struct svc_rqst *rqstp, strucreturn nfserr_inval;nfs4_lock_state (); - status = nfs_ok; -/* For stateid -1, we don't check share reservations. */ -if (ONE_STATEID (&read->rd_stateid)) { -dprintk ("NFSD: nfsd4_read: -1 stateid...\n" ); - goto out; - } -/* -* For stateid 0, the client doesn't have to have the file open, but -* we still check for share reservation conflicts. -*/ -if (ZERO_STATEID (&read->rd_stateid)) { -dprintk ("NFSD: nfsd4_read: zero stateid...\n" ); -if ((status =nfs4_share_conflict (current_fh,NFS4_SHARE_DENY_READ ))) { -dprintk ("NFSD: nfsd4_read: conflicting share reservation!\n" ); - goto out; - } - status = nfs_ok; - goto out; - }/* check stateid */ if ((status =nfs4_preprocess_stateid_op (current_fh, &read->rd_stateid,CHECK_FH |RD_STATE ))) {
@@ -595,13 +576,6 @@ nfsd4_setattr(struct svc_rqst *rqstp, st status = nfs_ok; if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { - - status = nfserr_bad_stateid; - if (ZERO_STATEID(&setattr->sa_stateid) || ONE_STATEID(&setattr->sa_stateid)) { - dprintk("NFSD: nfsd4_setattr: magic stateid!\n"); - goto out; - } - nfs4_lock_state(); if ((status = nfs4_preprocess_stateid_op(current_fh, &setattr->sa_stateid,
@@ -641,23 +615,13 @@ nfsd4_write(struct svc_rqst *rqstp, strureturn nfserr_inval;nfs4_lock_state (); -if (ZERO_STATEID (stateid) ||ONE_STATEID (stateid)) { -dprintk ("NFSD: nfsd4_write: zero stateid...\n" ); -if ((status =nfs4_share_conflict (current_fh,NFS4_SHARE_DENY_WRITE ))) { -dprintk ("NFSD: nfsd4_write: conflicting share reservation!\n" ); - goto out; - } - goto zero_stateid; - }if ((status =nfs4_preprocess_stateid_op (current_fh, stateid,CHECK_FH |WR_STATE ))) {dprintk ("NFSD: nfsd4_write: couldn't process stateid!\n" ); goto out; } - -zero_stateid: -nfs4_unlock_state (); + write->wr_bytes_written = write->wr_buflen; write->wr_how_written = write->wr_stable_how; p = (u32 *)write->wr_verifier.data;
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +19 -0
@@ -2007,6 +2007,22 @@ out:return status; } +static inline int +check_special_stateids (svc_fh *current_fh,stateid_t *stateid,int flags) +{ +/* Trying to call delegreturn with a special stateid? Yuch: */ +if (!(flags & (RD_STATE |WR_STATE ))) +return nfserr_bad_stateid; +else if (ONE_STATEID (stateid) && (flags &RD_STATE )) +return nfs_ok; +else if (flags &WR_STATE ) +return nfs4_share_conflict (current_fh, +NFS4_SHARE_DENY_WRITE ); +else /* (flags & RD_STATE) && ZERO_STATEID(stateid) */ +return nfs4_share_conflict (current_fh, +NFS4_SHARE_DENY_READ ); +} +/* * Checks for stateid operations */
@@ -2022,6 +2038,9 @@ nfs4_preprocess_stateid_op(struct svc_fh stateid->si_boot, stateid->si_stateownerid, stateid->si_fileid, stateid->si_generation); +if (ZERO_STATEID (stateid) ||ONE_STATEID (stateid)) +return check_special_stateids (current_fh, stateid, flags); +/* STALE STATEID */ status = nfserr_stale_stateid;if (STALE_STATEID (stateid))
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: don't release nfs4_file with associated delegations
In reply to NeilBrownOnly release a struct nfs4_file if there are no associated delegations.
### Diffstat output
./fs/nfsd/nfs4state.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +1 -1
@@ -1791,7 +1791,7 @@ nfsd4_process_open2(struct svc_rqst *rqs stp->st_stateid.si_fileid, stp->st_stateid.si_generation); out:/* take the opportunity to clean up unused state */ -if (fp &&list_empty (&fp->fi_perfile)) +if (fp &&list_empty (&fp->fi_perfile) &&list_empty (&fp->fi_del_perfile))release_file (fp);/* CLAIM_PREVIOUS has different error returns */
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: use sync rpc for delegation recall
In reply to NeilBrownUse a synchronous rpc for the delegation recall. This is simpler and avoids putting rpciod to sleep for 2 seconds on retries.
### Diffstat output
./fs/nfsd/nfs4callback.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +7 -7
@@ -496,17 +496,16 @@ out:* Called with dp->dl_count incremented */ static void -nfs4_cb_recall_done (struct rpc_task *task) +nfs4_cb_recall_done (struct nfs4_cb_recall *cbr,int status) { -struct nfs4_cb_recall *cbr = (struct nfs4_cb_recall *)task->tk_calldata;struct nfs4_delegation *dp = cbr->cbr_dp;/* all is well... */ -if (task->tk_status ==0 ) +if (status ==0 ) goto out;/* network partition, retry nfsd4_cb_recall once. */ -if (task->tk_status == -EIO ) { +if (status == -EIO ) {if (atomic_read (&dp->dl_recall_cnt) ==0 ) goto retry;else
@@ -518,7 +517,7 @@ nfs4_cb_recall_done(struct rpc_task *tas* Client may have received recall prior to delegation. retry recall * once. */ -if ((task->tk_status == -EBADHANDLE ) || (task->tk_status == -NFS4ERR_BAD_STATEID )){ +if ((status == -EBADHANDLE ) || (status == -NFS4ERR_BAD_STATEID )){if (atomic_read (&dp->dl_recall_cnt) ==0 ) goto retry; }
@@ -570,10 +569,11 @@ nfsd4_cb_recall(struct nfs4_delegation * cbr->cbr_trunc =0 ;/* XXX need to implement truncate optimization */ cbr->cbr_dp = dp; -if ((status =rpc_call_async (clnt, &msg,RPC_TASK_SOFT , - nfs4_cb_recall_done, cbr ))) + status =rpc_call_sync (clnt, &msg,RPC_TASK_SOFT ); +if (status)dprintk ("NFSD: recall_delegation: rpc_call_async failed %d\n" , status); +nfs4_cb_recall_done (cbr, status);put_rpccred (msg.rpc_cred);return ; }
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: miscellaneous open cleanup 3
In reply to NeilBrownMore minor logic cleanup.
### Diffstat output
./fs/nfsd/nfs4state.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +3 -7
@@ -1455,9 +1455,8 @@ nfsd4_process_open1(struct nfsd4_open *oif (!check_name (open->op_owner)) goto out; - status = nfserr_stale_clientid;if (STALE_CLIENTID (&open->op_clientid)) -return status; +return nfserr_stale_clientid; strhashval =ownerstr_hashval (clientid->cl_id, open->op_owner);if (find_openstateowner_str (strhashval, open, &sop)) {
@@ -1475,14 +1474,11 @@ nfsd4_process_open1(struct nfsd4_open *o*/ dprintk ("nfsd4_process_open1:" " replay with no replay cache\n" ); - status =NFS_OK ; goto renew; } }else if (sop->so_confirmed) { -if (open->op_seqid == sop->so_seqid +1 ) { - status = nfs_ok; +if (open->op_seqid == sop->so_seqid +1 ) goto renew; - } status = nfserr_bad_seqid; goto out; }else {
@@ -1508,8 +1504,8 @@ nfsd4_process_open1(struct nfsd4_open *oif (!(sop =alloc_init_open_stateowner (strhashval, clp, open))) goto out; open->op_stateowner = sop; - status = nfs_ok; renew: + status = nfs_ok;renew_client (sop->so_client); out:if (status && open->op_claim_type ==NFS4_OPEN_CLAIM_PREVIOUS )
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: allow some reads and writes during the grace period
In reply to NeilBrownAllow READ and WRITE during the grace period on OPEN or LOCK state that has been reclaimed, for files for which mandatory locking is not in force. (Reads and writes to files with mandatory locking must be delayed until we're sure all the other clients have had a chance to recover locks.)
### Diffstat output
./fs/nfsd/nfs4proc.c | 8 -------- ./fs/nfsd/nfs4state.c | 27 ++++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 11 deletions(-)
fs/nfsd/nfs4proc.c renamed from fs/nfsd/nfs4proc.c~current~ +0 -8
@@ -466,8 +466,6 @@ nfsd4_read(struct svc_rqst *rqstp, strucint status;/* no need to check permission - this will be done in nfsd_read() */ -if (nfs4_in_grace ()) -return nfserr_grace;if (read->rd_offset >=OFFSET_MAX )return nfserr_inval;
@@ -568,9 +566,6 @@ nfsd4_setattr(struct svc_rqst *rqstp, st {int status = nfs_ok; -if (nfs4_in_grace ()) -return nfserr_grace; -if (!current_fh->fh_dentry)return nfserr_nofilehandle;
@@ -606,9 +601,6 @@ nfsd4_write(struct svc_rqst *rqstp, struu32 *p;int status = nfs_ok; -if (nfs4_in_grace ()) -return nfserr_grace; -/* no need to check permission - this will be done in nfsd_write() */ if (write->wr_offset >=OFFSET_MAX )
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +24 -3
@@ -2015,7 +2015,11 @@ check_special_stateids(svc_fh *current_freturn nfserr_bad_stateid; else if (ONE_STATEID(stateid) && (flags & RD_STATE)) return nfs_ok; - else if (flags & WR_STATE) + else if (nfs4_in_grace()) { +/* Answer in remaining cases depends on existance of +* conflicting state; so we must wait out the grace period. */ +return nfserr_grace; + } else if (flags & WR_STATE) return nfs4_share_conflict(current_fh, NFS4_SHARE_DENY_WRITE); else/* (flags & RD_STATE) && ZERO_STATEID(stateid) */
@@ -2024,6 +2028,17 @@ check_special_stateids(svc_fh *current_f }/* +* Allow READ/WRITE during grace period on recovered state only for files +* that are not able to provide mandatory locking. +*/ +static inline int +io_during_grace_disallowed (struct inode *inode,int flags) +{ +return nfs4_in_grace () && (flags & (RD_STATE |WR_STATE )) + &&MANDATORY_LOCK (inode); +} + +/* * Checks for stateid operations */ int
@@ -2032,12 +2047,16 @@ nfs4_preprocess_stateid_op(struct svc_fhstruct nfs4_stateid *stp =NULL ;struct nfs4_delegation *dp =NULL ;stateid_t *stidp; +struct inode *ino = current_fh->fh_dentry->d_inode;int status;dprintk ("NFSD: preprocess_stateid_op: stateid = (%08x/%08x/%08x/%08x)\n" , stateid->si_boot, stateid->si_stateownerid, stateid->si_fileid, stateid->si_generation); +if (io_during_grace_disallowed (ino, flags)) +return nfserr_grace; +if (ZERO_STATEID (stateid) ||ONE_STATEID (stateid))return check_special_stateids (current_fh, stateid, flags);
@@ -2049,16 +2068,18 @@ nfs4_preprocess_stateid_op(struct svc_fh/* BAD STATEID */ status = nfserr_bad_stateid;if (!stateid->si_fileid) {/* delegation stateid */ -struct inode *ino = current_fh->fh_dentry->d_inode; -if (!(dp =find_delegation_stateid (ino, stateid))) {dprintk ("NFSD: delegation stateid not found\n" ); +if (nfs4_in_grace ()) + status = nfserr_grace; goto out; } stidp = &dp->dl_stateid; }else {/* open or lock stateid */ if (!(stp =find_stateid (stateid, flags))) {dprintk ("NFSD: open or lock stateid not found\n" ); +if (nfs4_in_grace ()) + status = nfserr_grace; goto out; }if ((flags &CHECK_FH ) &&nfs4_check_fh (current_fh, stp))
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: fix nfs4_check_delegmode()
In reply to NeilBrownInline nfs4_check_delegmode, replace & by &&, remove incorrect check. (Note that it's fine to read using the stateid for a write delegation.)
While we're at it, the status return logic seems like overkill for one simple check.
### Diffstat output
./fs/nfsd/nfs4state.c | 15 +++++---------- 1 files changed, 5 insertions(+), 10 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +5 -10
@@ -1969,18 +1969,13 @@ out:return status; } -static int +static inline int nfs4_check_delegmode (struct nfs4_delegation *dp,int flags) { -int status = nfserr_openmode; - -if ((flags &WR_STATE ) & (dp->dl_type ==NFS4_OPEN_DELEGATE_READ )) - goto out; -if ((flags &RD_STATE ) & (dp->dl_type ==NFS4_OPEN_DELEGATE_WRITE )) - goto out; - status = nfs_ok; -out: -return status; +if ((flags &WR_STATE ) && (dp->dl_type ==NFS4_OPEN_DELEGATE_READ )) +return nfserr_openmode; +else +return nfs_ok; } static inline int
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: provide no_cb_path error on renew
In reply to NeilBrownIf the client was given a delegation, but our callback path to the client has since failed for some reason, then our only chance to inform the client of this is to return the cb_path_down error next time the client attempts to renew its state.
### Diffstat output
./fs/nfsd/nfs4state.c | 20 ++++++++++---------- ./include/linux/nfsd/nfsd.h | 1 + 2 files changed, 11 insertions(+), 10 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +10 -10
@@ -1809,19 +1809,19 @@ nfsd4_renew(clientid_t *clid) status = nfserr_stale_clientid;if (STALE_CLIENTID (clid)) goto out; - status = nfs_ok; clp =find_confirmed_client (clid); -if (clp) { -renew_client (clp); + status = nfserr_expired; +if (clp ==NULL ) { +/* We assume the client took too long to RENEW. */ +dprintk ("nfsd4_renew: clientid not found!\n" ); goto out; } -/* -* Couldn't find an nfs4_client for this clientid. -* Presumably this is because the client took too long to -* RENEW, so return NFS4ERR_EXPIRED. -*/ -dprintk ("nfsd4_renew: clientid not found!\n" ); - status = nfserr_expired; +renew_client (clp); + status = nfserr_cb_path_down; +if (!list_empty (&clp->cl_del_perclnt) + && !atomic_read (&clp->cl_callback.cb_set)) + goto out; + status = nfs_ok; out:nfs4_unlock_state ();return status;
include/linux/nfsd/nfsd.h renamed from include/linux/nfsd/nfsd.h~current~ +1 -0
@@ -228,6 +228,7 @@ void nfsd_lockd_shutdown(void);#define nfserr_no_grace __constant_htonl(NFSERR_NO_GRACE)#define nfserr_reclaim_bad __constant_htonl(NFSERR_RECLAIM_BAD)#define nfserr_badname __constant_htonl(NFSERR_BADNAME) +#define nfserr_cb_path_down __constant_htonl(NFSERR_CB_PATH_DOWN)/* error codes for internal use */ /* if a request fails due to kmalloc failure, it gets dropped.
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: make nfsd4_cb_recall return void
In reply to NeilBrownThe return value of nfsd4_cb_recall isn't really used (and the errors we were returning were incorrect anyway).
### Diffstat output
./fs/nfsd/nfs4callback.c | 21 +++++++-------------- ./include/linux/nfsd/state.h | 2 +- 2 files changed, 8 insertions(+), 15 deletions(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +7 -14
@@ -499,7 +499,6 @@ nfs4_cb_recall_done(struct rpc_task *tas {struct nfs4_cb_recall *cbr = (struct nfs4_cb_recall *)task->tk_calldata;struct nfs4_delegation *dp = cbr->cbr_dp; -int status;/* all is well... */ if (task->tk_status ==0 )
@@ -536,15 +535,14 @@ retry:atomic_inc (&dp->dl_recall_cnt);/* sleep 2 seconds before retrying recall */ ssleep (2 ); - status =nfsd4_cb_recall (dp); -dprintk ("NFSD: nfs4_cb_recall_done: retry status: %d dp %p dl_flock %p\n" ,status,dp, dp->dl_flock); +nfsd4_cb_recall (dp); }/* * called with dp->dl_count inc'ed. * nfs4_lock_state() may or may not have been called. */ -int +void nfsd4_cb_recall (struct nfs4_delegation *dp) {struct nfs4_client *clp;
@@ -559,26 +557,21 @@ nfsd4_cb_recall(struct nfs4_delegation * clp = dp->dl_client; clnt = clp->cl_callback.cb_client; - status =EIO ;if ((!atomic_read (&clp->cl_callback.cb_set)) || !clnt) - goto out_fail; +return ; msg.rpc_argp = cbr; msg.rpc_resp = cbr; msg.rpc_cred =nfsd4_lookupcred (clp,0 ); +if (IS_ERR (msg.rpc_cred)) +return ; cbr->cbr_trunc =0 ;/* XXX need to implement truncate optimization */ cbr->cbr_dp = dp;if ((status =rpc_call_async (clnt, &msg,RPC_TASK_SOFT , - nfs4_cb_recall_done, cbr ))) { + nfs4_cb_recall_done, cbr )))dprintk ("NFSD: recall_delegation: rpc_call_async failed %d\n" , status); - goto out_fail; - } -out: -return status; -out_fail: - status =nfserrno (status); - goto out; +return ; }
include/linux/nfsd/state.h renamed from include/linux/nfsd/state.h~current~ +1 -1
@@ -289,7 +289,7 @@ extern int nfs4_check_open_reclaim(clienextern void put_nfs4_client (struct nfs4_client *clp);extern void nfs4_free_stateowner (struct kref *kref);extern void nfsd4_probe_callback (struct nfs4_client *clp); -extern int nfsd4_cb_recall (struct nfs4_delegation *dp); +extern void nfsd4_cb_recall (struct nfs4_delegation *dp);static inline void nfs4_put_stateowner (struct nfs4_stateowner *so)
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: miscellaneous open cleanup
In reply to NeilBrownMinor trivial cleanup, mostly whitespace.
### Diffstat output
./fs/nfsd/nfs4proc.c | 3 +-- ./fs/nfsd/nfs4state.c | 19 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-)
fs/nfsd/nfs4proc.c renamed from fs/nfsd/nfs4proc.c~current~ +1 -2
@@ -117,7 +117,6 @@ do_open_lookup(struct svc_rqst *rqstp, s/* set reply cache */ fh_dup2 (current_fh, &resfh); -/* XXXJBF: keep a saved svc_fh struct instead?? */ open->op_stateowner->so_replay.rp_openfh_len = resfh.fh_handle.fh_size; memcpy(open->op_stateowner->so_replay.rp_openfh,
@@ -153,7 +152,7 @@ do_open_fhandle(struct svc_rqst *rqstp, current_fh->fh_handle.fh_size); open->op_truncate = (open->op_iattr.ia_valid &ATTR_SIZE ) && - !open->op_iattr.ia_size; + (open->op_iattr.ia_size ==0 ); status =do_open_permission (rqstp, current_fh, open);
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +9 -10
@@ -1465,18 +1465,17 @@ nfsd4_process_open1(struct nfsd4_open *o/* check for replay */ if (open->op_seqid == sop->so_seqid){if (!sop->so_replay.rp_buflen) { -/* -* The original OPEN failed in so spectacularly that we -* don't even have replay data saved! Therefore, we -* have no choice but to continue processing -* this OPEN; presumably, we'll fail again for the same -* reason. -*/ -dprintk ("nfsd4_process_open1: replay with no replay cache\n" ); +/* The original OPEN failed so spectacularly +* that we don't even have replay data saved! +* Therefore, we have no choice but to continue +* processing this OPEN; presumably, we'll +* fail again for the same reason. +*/ +dprintk ("nfsd4_process_open1:" +" replay with no replay cache\n" ); status =NFS_OK ; goto renew; } -/* replay: indicate to calling function */ status =NFSERR_REPLAY_ME ;return status; }
@@ -1488,7 +1487,7 @@ nfsd4_process_open1(struct nfsd4_open *o status = nfserr_bad_seqid; goto out; } -/* If we get here, we received and OPEN for an unconfirmed +/* If we get here, we received an OPEN for an unconfirmed * nfs4_stateowner. * Since the sequid's are different, purge the * existing nfs4_stateowner, and instantiate a new one.
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: remove dl_recall_cnt
In reply to NeilBrownWe don't need dl_recall_cnt any more, we're just using a local variable in nfsd4_cb_recall.
### Diffstat output
./fs/nfsd/nfs4state.c | 1 - ./include/linux/nfsd/state.h | 1 - 2 files changed, 2 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +0 -1
@@ -161,7 +161,6 @@ alloc_init_deleg(struct nfs4_client *clp dp->dl_time =0 ;atomic_set (&dp->dl_state,NFS4_NO_RECALL );atomic_set (&dp->dl_count,1 ); -atomic_set (&dp->dl_recall_cnt,0 );list_add (&dp->dl_del_perfile, &fp->fi_del_perfile);list_add (&dp->dl_del_perclnt, &clp->cl_del_perclnt); alloc_delegation++;
include/linux/nfsd/state.h renamed from include/linux/nfsd/state.h~current~ +0 -1
@@ -86,7 +86,6 @@ struct nfs4_delegation {struct list_head dl_del_perfile;/* nfs4_file->fi_del_perfile */ struct list_head dl_del_perclnt;/* nfs4_client->cl_del_perclnt*/ struct list_head dl_recall_lru;/* delegation recalled */ -atomic_t dl_recall_cnt;/* resend cb_recall only once */ atomic_t dl_count;/* ref count */ atomic_t dl_state;/* recall state */ struct nfs4_client *dl_client;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: fix cb-race
In reply to NeilBrownWe weren't taking the reference count in the delegation recall thread until we'd already started the new delegation thread (and possibly returned from the break_lease callback). That's too late.
Also document some assumptions.
### Diffstat output
./fs/nfsd/nfs4state.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +10 -4
@@ -1345,7 +1345,6 @@ do_recall(void *__dp)daemonize ("nfsv4-recall" ); -atomic_inc (&dp->dl_count);nfsd4_cb_recall (dp);return 0 ; }
@@ -1354,8 +1353,9 @@ do_recall(void *__dp)* Spawn a thread to perform a recall on the delegation represented * by the lease (file_lock) * -* Called from break_lease() with lock_kernel() held, -* +* Called from break_lease() with lock_kernel() held. +* Note: we assume break_lease will only call this *once* for any given +* lease. */ static void nfsd_break_deleg_cb (struct file_lock *fl)
@@ -1367,7 +1367,13 @@ void nfsd_break_deleg_cb(struct file_locif (!dp)return ; -/* schedule delegation for recall */ +/* We're assuming the state code never drops its reference +* without first removing the lease. Since we're in this lease +* callback (and since the lease code is serialized by the kernel +* lock) we know the server hasn't removed the lease yet, we know +* it's safe to take a reference: */ +atomic_inc (&dp->dl_count); +spin_lock (&recall_lock);atomic_set (&dp->dl_state,NFS4_RECALL_IN_PROGRESS );list_add_tail (&dp->dl_recall_lru, &del_recall_lru);
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: reorganize release_deleg
In reply to NeilBrownJust separate part of release_deleg into a separate function.
### Diffstat output
./fs/nfsd/nfs4state.c | 28 +++++++++++++++++----------- 1 files changed, 17 insertions(+), 11 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +17 -11
@@ -80,7 +80,6 @@ u32 free_delegation= 0;/* forward declarations */ struct nfs4_stateid *find_stateid (stateid_t *stid,int flags);static struct nfs4_delegation *find_delegation_stateid (struct inode *ino,stateid_t *stid); -static void release_delegation (struct nfs4_delegation *dp);static void release_stateid_lockowners (struct nfs4_stateid *open_stp);/* Locking:
@@ -197,19 +196,26 @@ nfs4_put_delegation(struct nfs4_delegati*/ static void +nfs4_close_delegation (struct nfs4_delegation *dp) +{ +struct file *filp = dp->dl_stp->st_vfs_file; + +dprintk ("NFSD: close_delegation dp %p\n" ,dp); +release_stateid_lockowners (dp->dl_stp); +kfree (dp->dl_stp); + dp->dl_stp =NULL ; +atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE ); +nfsd_close (filp); + vfsclose++; +} + +/* Called under the state lock. */ +static void release_delegation (struct nfs4_delegation *dp) {/* delayed nfsd_close */ -if (dp->dl_stp) { -struct file *filp = dp->dl_stp->st_vfs_file; - -dprintk ("NFSD: release_delegation CLOSE\n" ); -release_stateid_lockowners (dp->dl_stp); -kfree (dp->dl_stp); - dp->dl_stp =NULL ; -atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE ); -nfsd_close (filp); - vfsclose++; +if (dp->dl_stp) +nfs4_close_delegation (dp); } else {dprintk ("NFSD: release_delegation remove lease dl_flock %p\n" , dp->dl_flock);
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: allow io to use deleg stateid file
In reply to NeilBrownAllow io using a delegation stateid to proceed without the need to reopen the file, as is done already with open stateid's.
### Diffstat output
./fs/nfsd/nfs4state.c | 2 ++ 1 files changed, 2 insertions(+)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +2 -0
@@ -2068,6 +2068,8 @@ nfs4_preprocess_stateid_op(struct svc_fhatomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE );release_delegation (dp); } +if (filpp) + *filpp = dp->dl_vfs_file; } status = nfs_ok; out:
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: use existing open instead of reopening on read and write
In reply to NeilBrownUse the struct file * obtained in nfsd4_open for nfsd_read and nfsd_write when available.
To do this we add a struct file * argument to nfsd_read and nfsd_write. If a struct file is passed in, nfsd_read and nfsd_write will use it, doing just an access check instead of an open and close. If the new argument is NULL, they will fall back on the old behaviour.
### Diffstat output
./fs/nfsd/nfs3proc.c | 4 - ./fs/nfsd/nfs4proc.c | 18 ++++--- ./fs/nfsd/nfs4state.c | 8 ++- ./fs/nfsd/nfs4xdr.c | 8 +-- ./fs/nfsd/nfsproc.c | 4 - ./fs/nfsd/vfs.c | 103 +++++++++++++++++++++++++++++-------------- ./include/linux/nfsd/nfsd.h | 6 +- ./include/linux/nfsd/state.h | 2 ./include/linux/nfsd/xdr4.h | 1 9 files changed, 100 insertions(+), 54 deletions(-)
fs/nfsd/nfs3proc.c renamed from fs/nfsd/nfs3proc.c~current~ +2 -2
@@ -172,7 +172,7 @@ nfsd3_proc_read(struct svc_rqst *rqstp,svc_reserve (rqstp, ((1 +NFS3_POST_OP_ATTR_WORDS +3 )<<2 ) + resp->count +4 );fh_copy (&resp->fh, &argp->fh); - nfserr =nfsd_read (rqstp, &resp->fh, + nfserr =nfsd_read (rqstp, &resp->fh,NULL , argp->offset, argp->vec, argp->vlen, &resp->count);
@@ -202,7 +202,7 @@ nfsd3_proc_write(struct svc_rqst *rqstp,fh_copy (&resp->fh, &argp->fh); resp->committed = argp->stable; - nfserr = nfsd_write(rqstp, &resp->fh, + nfserr = nfsd_write(rqstp, &resp->fh, NULL, argp->offset, argp->vec, argp->vlen, argp->len,
fs/nfsd/nfs4proc.c renamed from fs/nfsd/nfs4proc.c~current~ +11 -7
@@ -464,6 +464,7 @@ static inline int nfsd4_read(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_read *read) { int status; +struct file *filp =NULL ;/* no need to check permission - this will be done in nfsd_read() */
@@ -472,8 +473,8 @@ nfsd4_read(struct svc_rqst *rqstp, strucnfs4_lock_state ();/* check stateid */ -if ((status =nfs4_preprocess_stateid_op (current_fh, &read->rd_stateid, -CHECK_FH |RD_STATE ))) { +if ((status =nfs4_preprocess_stateid_op (current_fh, &read->rd_stateid, +CHECK_FH |RD_STATE , &filp))) {dprintk ("NFSD: nfsd4_read: couldn't process stateid!\n" ); goto out; }
@@ -482,6 +483,7 @@ out:nfs4_unlock_state (); read->rd_rqstp = rqstp; read->rd_fhp = current_fh; + read->rd_filp = filp;return status; }
@@ -574,7 +576,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, stnfs4_lock_state ();if ((status =nfs4_preprocess_stateid_op (current_fh, &setattr->sa_stateid, -CHECK_FH |WR_STATE ))) { +CHECK_FH |WR_STATE ,NULL ))) {dprintk ("NFSD: nfsd4_setattr: couldn't process stateid!\n" ); goto out_unlock; }
@@ -598,6 +600,7 @@ static inline int nfsd4_write(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_write *write) { stateid_t *stateid = &write->wr_stateid; +struct file *filp =NULL ;u32 *p;int status = nfs_ok;
@@ -608,7 +611,7 @@ nfsd4_write(struct svc_rqst *rqstp, strunfs4_lock_state ();if ((status =nfs4_preprocess_stateid_op (current_fh, stateid, -CHECK_FH |WR_STATE ))) { +CHECK_FH |WR_STATE , &filp))) {dprintk ("NFSD: nfsd4_write: couldn't process stateid!\n" ); goto out; }
@@ -620,9 +623,10 @@ nfsd4_write(struct svc_rqst *rqstp, stru *p++ = nfssvc_boot.tv_sec; *p++ = nfssvc_boot.tv_usec; - status =nfsd_write (rqstp, current_fh, write->wr_offset, - write->wr_vec, write->wr_vlen, write->wr_buflen, - &write->wr_how_written); + status =nfsd_write (rqstp, current_fh, filp, write->wr_offset, + write->wr_vec, write->wr_vlen, write->wr_buflen, + &write->wr_how_written); +if (status == nfserr_symlink) status = nfserr_inval;return status;
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +6 -2
@@ -2042,7 +2042,7 @@ io_during_grace_disallowed(struct inode* Checks for stateid operations */ int -nfs4_preprocess_stateid_op (struct svc_fh *current_fh,stateid_t *stateid,int flags) +nfs4_preprocess_stateid_op (struct svc_fh *current_fh,stateid_t *stateid,int flags,struct file **filpp) {struct nfs4_stateid *stp =NULL ;struct nfs4_delegation *dp =NULL ;
@@ -2053,6 +2053,8 @@ nfs4_preprocess_stateid_op(struct svc_fhdprintk ("NFSD: preprocess_stateid_op: stateid = (%08x/%08x/%08x/%08x)\n" , stateid->si_boot, stateid->si_stateownerid, stateid->si_fileid, stateid->si_generation); +if (filpp) + *filpp =NULL ;if (io_during_grace_disallowed (ino, flags))return nfserr_grace;
@@ -2099,6 +2101,8 @@ nfs4_preprocess_stateid_op(struct svc_fhif ((status =nfs4_check_openmode (stp,flags))) goto out;renew_client (stp->st_stateowner->so_client); +if (filpp) + *filpp = stp->st_vfs_file; }else if (dp) {if ((status =nfs4_check_delegmode (dp, flags))) goto out;
@@ -2405,7 +2409,7 @@ nfsd4_delegreturn(struct svc_rqst *rqstp goto out;nfs4_lock_state (); - status =nfs4_preprocess_stateid_op (current_fh, &dr->dr_stateid,DELEG_RET ); + status =nfs4_preprocess_stateid_op (current_fh, &dr->dr_stateid,DELEG_RET ,NULL );nfs4_unlock_state (); out:return status;
fs/nfsd/nfs4xdr.c renamed from fs/nfsd/nfs4xdr.c~current~ +4 -4
@@ -2068,10 +2068,10 @@ nfsd4_encode_read(struct nfsd4_compoundr } read->rd_vlen = v; - nfserr =nfsd_read (read->rd_rqstp, read->rd_fhp, - read->rd_offset, - read->rd_iov, read->rd_vlen, - &maxcount); + nfserr =nfsd_read (read->rd_rqstp, read->rd_fhp, read->rd_filp, + read->rd_offset, read->rd_iov, read->rd_vlen, + &maxcount); +if (nfserr == nfserr_symlink) nfserr = nfserr_inval;if (nfserr)
fs/nfsd/nfsproc.c renamed from fs/nfsd/nfsproc.c~current~ +2 -2
@@ -137,7 +137,7 @@ nfsd_proc_read(struct svc_rqst *rqstp, ssvc_reserve (rqstp, (19 <<2 ) + argp->count +4 ); resp->count = argp->count; - nfserr =nfsd_read (rqstp,fh_copy (&resp->fh, &argp->fh), + nfserr =nfsd_read (rqstp,fh_copy (&resp->fh, &argp->fh),NULL , argp->offset, argp->vec, argp->vlen, &resp->count);
@@ -160,7 +160,7 @@ nfsd_proc_write(struct svc_rqst *rqstp,SVCFH_fmt (&argp->fh), argp->len, argp->offset); - nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), + nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), NULL, argp->offset, argp->vec, argp->vlen, argp->len,
fs/nfsd/vfs.c renamed from fs/nfsd/vfs.c~current~ +70 -33
153 lines not on this page · raw message
include/linux/nfsd/nfsd.h renamed from include/linux/nfsd/nfsd.h~current~ +3 -3
@@ -99,9 +99,9 @@ int nfsd_commit(struct svc_rqst *, struint nfsd_open (struct svc_rqst *,struct svc_fh *,int ,int ,struct file **);void nfsd_close (struct file *); -int nfsd_read (struct svc_rqst *,struct svc_fh *, -loff_t ,struct kvec *,int ,unsigned long *); -int nfsd_write (struct svc_rqst *,struct svc_fh *, +int nfsd_read (struct svc_rqst *,struct svc_fh *,struct file *, +loff_t ,struct kvec *,int ,unsigned long *); +int nfsd_write (struct svc_rqst *,struct svc_fh *,struct file *,loff_t ,struct kvec *,int ,unsigned long ,int *);int nfsd_readlink (struct svc_rqst *,struct svc_fh *,char *,int *);
include/linux/nfsd/state.h renamed from include/linux/nfsd/state.h~current~ +1 -1
@@ -279,7 +279,7 @@ struct nfs4_stateid {extern time_t nfs4_laundromat (void );extern int nfsd4_renew (clientid_t *clid);extern int nfs4_preprocess_stateid_op (struct svc_fh *current_fh, -stateid_t *stateid,int flags); +stateid_t *stateid,int flags,struct file **filp);extern int nfs4_share_conflict (struct svc_fh *current_fh,unsigned int deny_type);extern void nfs4_lock_state (void );
include/linux/nfsd/xdr4.h renamed from include/linux/nfsd/xdr4.h~current~ +1 -0
@@ -241,6 +241,7 @@ struct nfsd4_read {u32 rd_length;/* request */ struct kvec rd_iov[RPCSVC_MAXPAGES ];int rd_vlen; +struct file *rd_filp;struct svc_rqst *rd_rqstp;/* response */ struct svc_fh * rd_fhp;/* response */
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: return callback_ident in callbacks
In reply to NeilBrownPass the callback_ident received in SETCLIENTID to the CB_RECALL rpc.
### Diffstat output
./fs/nfsd/nfs4callback.c | 1 + ./fs/nfsd/nfs4state.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +1 -0
@@ -247,6 +247,7 @@ nfs4_xdr_enc_cb_recall(struct rpc_rqst * {struct xdr_stream xdr;struct nfs4_cb_compound_hdr hdr = { + .ident = args->cbr_ident, .nops =1 , };
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +5 -3
@@ -130,9 +130,11 @@ spinlock_t recall_lock;static struct list_head del_recall_lru; static struct nfs4_delegation * -alloc_init_deleg(struct nfs4_client *clp, struct nfs4_file *fp, struct svc_fh *current_fh, u32 type) +alloc_init_deleg(struct nfs4_client *clp, struct nfs4_stateid *stp, struct svc_fh *current_fh, u32 type) { struct nfs4_delegation *dp; + struct nfs4_file *fp = stp->st_file; + struct nfs4_callback *cb = &stp->st_stateowner->so_client->cl_callback; dprintk("NFSD alloc_init_deleg\n"); if ((dp = kmalloc(sizeof(struct nfs4_delegation),
@@ -147,7 +149,7 @@ alloc_init_deleg(struct nfs4_client *clp dp->dl_stp =NULL ; dp->dl_type = type; dp->dl_recall.cbr_dp =NULL ; - dp->dl_recall.cbr_ident =0 ; + dp->dl_recall.cbr_ident = cb->cb_ident; dp->dl_recall.cbr_trunc =0 ; dp->dl_stateid.si_boot = boot_time; dp->dl_stateid.si_stateownerid = current_delegid++;
@@ -1666,7 +1668,7 @@ nfs4_open_delegation(struct svc_fh *fh,else *flag =NFS4_OPEN_DELEGATE_READ ; - dp =alloc_init_deleg (sop->so_client, stp->st_file, fh, *flag); + dp =alloc_init_deleg (sop->so_client, stp, fh, *flag);if (dp ==NULL ) { *flag =NFS4_OPEN_DELEGATE_NONE ;return ;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: fix callback cred refcnt leak
In reply to NeilBrownThe rpc creds we look up in the callback code need puts.
### Diffstat output
./fs/nfsd/nfs4callback.c | 2 ++ 1 files changed, 2 insertions(+)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +2 -0
@@ -450,6 +450,7 @@ nfsd4_probe_callback(struct nfs4_client msg.rpc_cred =nfsd4_lookupcred (clp,0 ); status =rpc_call_async (clnt, &msg,RPC_TASK_ASYNC , nfs4_cb_null,NULL ); +put_rpccred (msg.rpc_cred);if (status !=0 ) {dprintk ("NFSD: asynchronous NFSPROC4_CB_NULL failed!\n" );
@@ -573,5 +574,6 @@ nfsd4_cb_recall(struct nfs4_delegation * nfs4_cb_recall_done, cbr )))dprintk ("NFSD: recall_delegation: rpc_call_async failed %d\n" , status); +put_rpccred (msg.rpc_cred);return ; }
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Re: [PATCH kNFSd 32 of 54] nfsd4: fix callback cred refcnt leak
ty den 08.03.2005 Klokka 17:06 (+1100) skreiv NeilBrown:
Quoted 3 lines
The rpc creds we look up in the callback code need puts.
<cough> Error checking on the results of nfsd4_lookupcred()? </cough>
Cheers,
Trond
Signature · 12 lines
Trond Myklebust <[email protected]> ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ NFS maillist - [email protected] https://lists.sourceforge.net/lists/listinfo/nfs
Re: [PATCH kNFSd 32 of 54] nfsd4: fix callback cred refcnt leak
Quoted 6 lines · Trond Myklebust
ty den 08.03.2005 Klokka 17:06 (+1100) skreiv NeilBrown:
Quoted 3 lines
The rpc creds we look up in the callback code need puts.
<cough> Error checking on the results of
nfsd4_lookupcred()? </cough>
Yeah, sorry for the confusion here. My fault, but partly also a result of there being another patch in Trond's NFS_ALL that changes rpcauth_lookup_credcache() to return error codes instead of just NULL on failure. Depending on which patches get in first, there'll be some trivial fixup to do.
Removing the spurious (!clnt) check, as in the following, will also simplify that conflict resolution a bit.
---
linux-2.6.11-mm2-bfields/fs/nfsd/nfs4callback.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~nfsd4-fix-callback-cred-lookup +8 -9
@@ -353,10 +353,8 @@ nfsd4_lookupcred(struct nfs4_client *clp {struct auth_cred acred;struct rpc_clnt *clnt = clp->cl_callback.cb_client; -struct rpc_cred *ret =NULL ; +struct rpc_cred *ret; -if (!clnt) - goto out;get_group_info (clp->cl_cred.cr_group_info); acred.uid = clp->cl_cred.cr_uid; acred.gid = clp->cl_cred.cr_gid;
@@ -366,7 +364,6 @@ nfsd4_lookupcred(struct nfs4_client *clp clnt->cl_auth->au_ops->au_name); ret =rpcauth_lookup_credcache (clnt->cl_auth, &acred, taskflags);put_group_info (clp->cl_cred.cr_group_info); -out:return ret; }
@@ -449,6 +446,8 @@ nfsd4_probe_callback(struct nfs4_clientatomic_inc (&clp->cl_count); msg.rpc_cred =nfsd4_lookupcred (clp,0 ); +if (msg.rpc_cred ==NULL ) + goto out_rpciod; status =rpc_call_async (clnt, &msg,RPC_TASK_ASYNC , nfs4_cb_null,NULL );put_rpccred (msg.rpc_cred);
@@ -513,7 +512,7 @@ nfsd4_cb_recall(struct nfs4_delegation *return ; msg.rpc_cred =nfsd4_lookupcred (clp,0 ); -if (IS_ERR (msg.rpc_cred)) +if (msg.rpc_cred ==NULL ) goto out; cbr->cbr_trunc =0 ;/* XXX need to implement truncate optimization */
@@ -530,19 +529,19 @@ nfsd4_cb_recall(struct nfs4_delegation ** before open reply granting delegation */ break ;default : - goto out; + goto out_put_cred; }ssleep (2 ); status =rpc_call_sync (clnt, &msg,RPC_TASK_SOFT ); } - - out: +out_put_cred: +put_rpccred (msg.rpc_cred); +out:if (status == -EIO )atomic_set (&clp->cl_callback.cb_set,0 );/* Success or failure, now we're either waiting for lease expiration * or deleg_return. */ nfs4_put_delegation (dp);dprintk ("NFSD: nfs4_cb_recall: dp %p dl_flock %p dl_count %d\n" ,dp, dp->dl_flock,atomic_read (&dp->dl_count)); -put_rpccred (msg.rpc_cred);return ; }
_
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: remove st_vfs_file checks
In reply to NeilBrownThe st_vfs_file field *must* be non-NULL as long as the stateid is in use, so there's no point testing for it, unless we want to just BUG(). But since we'd immediately hit a NULL dereference in every case, there's no need even for that.
### Diffstat output
./fs/nfsd/nfs4state.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +5 -8
@@ -1171,7 +1171,7 @@ release_stateid(struct nfs4_stateid *stp list_del_perfile++;list_del (&stp->st_perfile);list_del (&stp->st_perfilestate); -if ((stp->st_vfs_file) && (flags &OPEN_STATE )) { +if (flags &OPEN_STATE ) {list_for_each_entry (dp, &fp->fi_del_perfile, dl_del_perfile) {if (cmp_clid (&dp->dl_client->cl_clientid, &stp->st_stateowner->so_client->cl_clientid)) {
@@ -1182,7 +1182,7 @@ release_stateid(struct nfs4_stateid *stprelease_stateid_lockowners (stp);nfsd_close (stp->st_vfs_file); vfsclose++; - }else if ((stp->st_vfs_file) && (flags &LOCK_STATE )) { + }else if (flags &LOCK_STATE ) {struct file *filp = stp->st_vfs_file;locks_remove_posix (filp, (fl_owner_t ) stp->st_stateowner);
@@ -1921,8 +1921,7 @@ find_openstateowner_id(u32 st_id, int flstatic inline int nfs4_check_fh (struct svc_fh *fhp,struct nfs4_stateid *stp) { -return (stp->st_vfs_file ==NULL || - fhp->fh_dentry->d_inode != stp->st_vfs_file->f_dentry->d_inode); +return fhp->fh_dentry->d_inode != stp->st_vfs_file->f_dentry->d_inode; } static int
@@ -3015,10 +3014,8 @@ nfsd4_release_lockowner(struct svc_rqst status = nfserr_locks_held;list_for_each_entry (stp, &local->so_perfilestate, st_perfilestate) { -if (stp->st_vfs_file) { -if (check_for_locks (stp->st_vfs_file, local)) - goto out; - } +if (check_for_locks (stp->st_vfs_file, local)) + goto out; }/* no locks held by (lock) stateowner */ status = nfs_ok;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: store-file-with-deleg
In reply to NeilBrownThe only reason we're keeping a pointer to the stateid in the delegation is so we can get at st_vfs_file. So we should just keep a pointer to the struct file instead.
### Diffstat output
./fs/nfsd/nfs4state.c | 15 +++++++-------- ./include/linux/nfsd/state.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +7 -8
@@ -145,7 +145,7 @@ alloc_init_deleg(struct nfs4_client *clp dp->dl_client = clp; dp->dl_file = fp; dp->dl_flock =NULL ; - dp->dl_stp =NULL ; + dp->dl_vfs_file =NULL ; dp->dl_type = type; dp->dl_recall.cbr_dp =NULL ; dp->dl_recall.cbr_ident = cb->cb_ident;
@@ -198,12 +198,10 @@ nfs4_put_delegation(struct nfs4_delegatistatic void nfs4_close_delegation (struct nfs4_delegation *dp) { -struct file *filp = dp->dl_stp->st_vfs_file; +struct file *filp = dp->dl_vfs_file;dprintk ("NFSD: close_delegation dp %p\n" ,dp); -release_stateid_lockowners (dp->dl_stp); -kfree (dp->dl_stp); - dp->dl_stp =NULL ; + dp->dl_vfs_file =NULL ;atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE );nfsd_close (filp); vfsclose++;
@@ -214,9 +212,9 @@ static void release_delegation(struct nfs4_delegation *dp) {/* delayed nfsd_close */ -if (dp->dl_stp) +if (dp->dl_vfs_file)nfs4_close_delegation (dp); - } else { +else {dprintk ("NFSD: release_delegation remove lease dl_flock %p\n" , dp->dl_flock);remove_lease (dp->dl_flock);
@@ -1174,7 +1172,8 @@ release_stateid(struct nfs4_stateid *stplist_for_each_entry (dp, &fp->fi_del_perfile, dl_del_perfile) {if (cmp_clid (&dp->dl_client->cl_clientid, &stp->st_stateowner->so_client->cl_clientid)) { - dp->dl_stp = stp; + dp->dl_vfs_file = stp->st_vfs_file; +release_stateid_lockowners (stp);return ; } }
include/linux/nfsd/state.h renamed from include/linux/nfsd/state.h~current~ +1 -1
@@ -91,7 +91,7 @@ struct nfs4_delegation {struct nfs4_client *dl_client;struct nfs4_file *dl_file;struct file_lock *dl_flock; -struct nfs4_stateid *dl_stp; +struct file *dl_vfs_file;u32 dl_type;time_t dl_time;struct nfs4_cb_recall dl_recall;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: fix sleep under spinlock
In reply to NeilBrownWe shouldn't be calling release_deleg under a spinlock.
### Diffstat output
./fs/nfsd/nfs4state.c | 35 ++++++++++++++++++++++++++++------- 1 files changed, 28 insertions(+), 7 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +28 -7
@@ -207,7 +207,9 @@ release_delegation(struct nfs4_delegatio {list_del_init (&dp->dl_del_perfile);list_del_init (&dp->dl_del_perclnt); +spin_lock (&recall_lock);list_del_init (&dp->dl_recall_lru); +spin_unlock (&recall_lock);nfs4_close_delegation (dp);nfs4_put_delegation (dp); }
@@ -321,6 +323,7 @@ expire_client(struct nfs4_client *clp)struct nfs4_delegation *dp;struct nfs4_callback *cb = &clp->cl_callback;struct rpc_clnt *clnt = clp->cl_callback.cb_client; +struct list_head reaplist;dprintk ("NFSD: expire_client cl_count %d\n" ,atomic_read (&clp->cl_count));
@@ -330,6 +333,8 @@ expire_client(struct nfs4_client *clp)rpc_shutdown_client (clnt); clnt = clp->cl_callback.cb_client =NULL ; } + +INIT_LIST_HEAD (&reaplist);spin_lock (&recall_lock);while (!list_empty (&clp->cl_del_perclnt)) { dp = list_entry(clp->cl_del_perclnt.next, struct nfs4_delegation, dl_del_perclnt);
@@ -338,9 +343,15 @@ expire_client(struct nfs4_client *clp)/* force release of delegation. */ atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE ); -release_delegation (dp); +list_del_init (&dp->dl_del_perclnt); +list_move (&dp->dl_recall_lru, &reaplist); }spin_unlock (&recall_lock); +while (!list_empty (&reaplist)) { + dp = list_entry(reaplist.next, struct nfs4_delegation, dl_recall_lru); +list_del_init (&dp->dl_recall_lru); +release_delegation (dp); + }list_del (&clp->cl_idhash);list_del (&clp->cl_strhash);list_del (&clp->cl_lru);
@@ -1812,7 +1823,7 @@ nfs4_laundromat(void)struct nfs4_client *clp;struct nfs4_stateowner *sop;struct nfs4_delegation *dp; -struct list_head *pos, *next; +struct list_head *pos, *next, reaplist;time_t cutoff =get_seconds () -NFSD_LEASE_TIME ;time_t t, clientid_val =NFSD_LEASE_TIME ;time_t u, test_val =NFSD_LEASE_TIME ;
@@ -1832,6 +1843,7 @@ nfs4_laundromat(void) clp->cl_clientid.cl_id);expire_client (clp); } +INIT_LIST_HEAD (&reaplist);spin_lock (&recall_lock);list_for_each_safe (pos, next, &del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);
@@ -1843,9 +1855,14 @@ nfs4_laundromat(void) }dprintk ("NFSD: purging unused delegation dp %p, fp %p\n" , dp, dp->dl_flock); -release_delegation (dp); +list_move (&dp->dl_recall_lru, &reaplist); }spin_unlock (&recall_lock); +list_for_each_safe (pos, next, &reaplist) { + dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); +list_del_init (&dp->dl_recall_lru); +release_delegation (dp); + } test_val =NFSD_LEASE_TIME ;list_for_each_safe (pos, next, &close_lru) { sop = list_entry(pos, struct nfs4_stateowner, so_close_lru);
@@ -2049,9 +2066,7 @@ nfs4_preprocess_stateid_op(struct svc_fhrenew_client (dp->dl_client);if (flags &DELEG_RET ) {atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE ); -spin_lock (&recall_lock);release_delegation (dp); -spin_unlock (&recall_lock); } } status = nfs_ok;
@@ -3197,7 +3212,7 @@ __nfs4_state_shutdown(void)struct nfs4_client *clp =NULL ;struct nfs4_delegation *dp =NULL ;struct nfs4_stateowner *sop =NULL ; -struct list_head *pos, *next; +struct list_head *pos, *next, reaplist;list_for_each_safe (pos, next, &close_lru) { sop = list_entry(pos, struct nfs4_stateowner, so_close_lru);
@@ -3215,13 +3230,19 @@ __nfs4_state_shutdown(void)expire_client (clp); } } +INIT_LIST_HEAD (&reaplist);spin_lock (&recall_lock);list_for_each_safe (pos, next, &del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE ); -release_delegation (dp); +list_move (&dp->dl_recall_lru, &reaplist); }spin_unlock (&recall_lock); +list_for_each_safe (pos, next, &reaplist) { + dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); +list_del_init (&dp->dl_recall_lru); +release_delegation (dp); + }release_all_files ();cancel_delayed_work (&laundromat_work);
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: fix delegation refcount leak
In reply to NeilBrownIt is the responsibility of the code that runs in the do_recall thread to drop the reference to the delegation. So if we fail to run that thread, then we need to do it ourselves here.
### Diffstat output
./fs/nfsd/nfs4state.c | 1 + 1 files changed, 1 insertion(+)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +1 -0
@@ -1366,6 +1366,7 @@ void nfsd_break_deleg_cb(struct file_locprintk (KERN_INFO "NFSD: Callback thread failed for " "for client (clientid %08x/%08x)\n" , clp->cl_clientid.cl_boot, clp->cl_clientid.cl_id); +nfs4_put_delegation (dp); } }
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: fix_release_state_owner prototype
In reply to NeilBrownNote that the second parameter is unused.
### Diffstat output
./fs/nfsd/nfs4state.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +3 -4
@@ -1186,8 +1186,7 @@ move_to_close_lru(struct nfs4_stateowner }void -release_state_owner (struct nfs4_stateid *stp,struct nfs4_stateowner **sopp, -int flag) +release_state_owner (struct nfs4_stateid *stp,int flag) {struct nfs4_stateowner *sop = stp->st_stateowner;struct nfs4_file *fp = stp->st_file;
@@ -2337,7 +2336,7 @@ nfsd4_close(struct svc_rqst *rqstp, strumemcpy (&close->cl_stateid, &stp->st_stateid,sizeof (stateid_t));/* release_state_owner() calls nfsd_close() if needed */ -release_state_owner (stp, &close->cl_stateowner,OPEN_STATE ); +release_state_owner (stp,OPEN_STATE ); out:if (close->cl_stateowner)nfs4_get_stateowner (close->cl_stateowner);
@@ -2780,7 +2779,7 @@ out_destroy_new_stateid:if (!seqid_mutating_err (status)) open_sop->so_seqid--; -release_state_owner (lock_stp, &lock->lk_stateowner,LOCK_STATE ); +release_state_owner (lock_stp,LOCK_STATE ); } out:if (lock->lk_stateowner)
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 locks: remove unnecessary BUG()
In reply to NeilBrownWe get a NULL dereference here anyway, no need to BUG() explicitly.
### Diffstat output
./fs/locks.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
fs/locks.c renamed from fs/locks.c~current~ +2 -4
@@ -1172,10 +1172,8 @@ int __break_lease(struct inode *inode, uif (fl->fl_type != future) { fl->fl_type = future; fl->fl_break_time = break_time; -if (fl->fl_lmops && fl->fl_lmops->fl_break) - fl->fl_lmops->fl_break (fl); -else /* lease must have lmops break callback */ -BUG (); +/* lease must have lmops break callback */ + fl->fl_lmops->fl_break (fl); } }
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: simplify find functions
In reply to NeilBrownFix "find" functions that use return value redundantly. Calculate hashes on demand. Miscellaneous kernel style.
### Diffstat output
./fs/nfsd/nfs4state.c | 83 +++++++++++++++++++++++++------------------------- 1 files changed, 43 insertions(+), 40 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +43 -40
@@ -968,8 +968,11 @@ static struct list_head stateid_hashtbl[/* OPEN Share state helper functions */ static inline struct nfs4_file * -alloc_init_file (unsigned int hashval,struct inode *ino) { +alloc_init_file (struct inode *ino) +{struct nfs4_file *fp; +unsigned int hashval =file_hashval (ino); +if ((fp =kmalloc (sizeof (struct nfs4_file ),GFP_KERNEL ))) {INIT_LIST_HEAD (&fp->fi_hash);INIT_LIST_HEAD (&fp->fi_perfile);
@@ -1246,17 +1249,17 @@ find_openstateowner_str(unsigned int has }/* search file_hashtbl[] for file */ -static int -find_file (unsigned int hashval,struct inode *ino,struct nfs4_file **fp) { -struct nfs4_file *local =NULL ; +static struct nfs4_file * +find_file (struct inode *ino) +{ +unsigned int hashval =file_hashval (ino); +struct nfs4_file *fp; -list_for_each_entry (local, &file_hashtbl[hashval], fi_hash) { -if (local->fi_inode == ino) { - *fp = local; -return (1 ); - } +list_for_each_entry (fp, &file_hashtbl[hashval], fi_hash) { +if (fp->fi_inode == ino) +return fp; } -return 0 ; +return NULL ; }#define TEST_ACCESS (x) ((x > 0 || x < 4)?1:0)
@@ -1303,14 +1306,13 @@ int nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type) { struct inode *ino = current_fh->fh_dentry->d_inode; -unsigned int fi_hashval;struct nfs4_file *fp;struct nfs4_stateid *stp;dprintk ("NFSD: nfs4_share_conflict\n" ); - fi_hashval =file_hashval (ino); -if (find_file (fi_hashval, ino, &fp)) { + fp =find_file (ino); +if (fp) {/* Search for conflicting share reservations */ list_for_each_entry (stp, &fp->fi_perfile, st_perfile) { if (test_bit(deny_type, &stp->st_deny_bmap) ||
@@ -1706,7 +1708,6 @@ nfsd4_process_open2(struct svc_rqst *rqsstruct nfs4_stateowner *sop = open->op_stateowner;struct nfs4_file *fp =NULL ;struct inode *ino = current_fh->fh_dentry->d_inode; -unsigned int fi_hashval;struct nfs4_stateid *stp =NULL ;int status, delegflag =-1 ;
@@ -1718,15 +1719,16 @@ nfsd4_process_open2(struct svc_rqst *rqs* and check for delegations in the process of being recalled. * If not found, create the nfs4_file struct */ - fi_hashval =file_hashval (ino); -if (find_file (fi_hashval, ino, &fp)) { + fp =find_file (ino); +if (fp) {if ((status =nfs4_check_open (fp, sop, open, &stp))) goto out;if ((status =nfs4_check_deleg_recall (fp, open, &delegflag))) goto out; }else { status = nfserr_resource; -if ((fp =alloc_init_file (fi_hashval, ino)) ==NULL ) + fp =alloc_init_file (ino); +if (fp ==NULL ) goto out; }
@@ -2391,8 +2393,15 @@ out:#define lockownerid_hashval (id) \ ((id) & LOCK_HASH_MASK) -#define lock_ownerstr_hashval (x, clientid, ownername) \ - ((file_hashval(x) + (clientid) + opaque_hashval((ownername.data), (ownername.len))) & LOCK_HASH_MASK) + +static inline unsigned int +lock_ownerstr_hashval (struct inode *inode,u32 cl_id, +struct xdr_netobj *ownername) +{ +return (file_hashval (inode) + cl_id + +opaque_hashval (ownername->data, ownername->len)) + &LOCK_HASH_MASK ; +}static struct list_head lock_ownerid_hashtbl[LOCK_HASH_SIZE ];static struct list_head lock_ownerstr_hashtbl[LOCK_HASH_SIZE ];
@@ -2433,15 +2442,14 @@ find_delegation_stateid(struct inode *instruct nfs4_delegation *dp =NULL ;struct nfs4_file *fp =NULL ;u32 st_id; -unsigned int fi_hashval;dprintk ("NFSD:find_delegation_stateid stateid=(%08x/%08x/%08x/%08x)\n" , stid->si_boot, stid->si_stateownerid, stid->si_fileid, stid->si_generation); st_id = stid->si_stateownerid; - fi_hashval =file_hashval (ino); -if (find_file (fi_hashval, ino, &fp)) { + fp =find_file (ino); +if (fp) {list_for_each_entry (dp, &fp->fi_del_perfile, dl_del_perfile) {if (dp->dl_stateid.si_stateownerid == st_id) {dprintk ("NFSD: find_delegation dp %p\n" ,dp);
@@ -2525,18 +2533,18 @@ find_lockstateowner(struct xdr_netobj *oreturn NULL ; } -static int -find_lockstateowner_str (unsigned int hashval,struct xdr_netobj *owner,clientid_t *clid,struct nfs4_stateowner **op) { -struct nfs4_stateowner *local =NULL ; +static struct nfs4_stateowner * +find_lockstateowner_str (struct inode *inode,clientid_t *clid, +struct xdr_netobj *owner) +{ +unsigned int hashval =lock_ownerstr_hashval (inode, clid->cl_id, owner); +struct nfs4_stateowner *op; -list_for_each_entry (local, &lock_ownerstr_hashtbl[hashval], so_strhash) { -if (!cmp_owner_str (local, owner, clid)) -continue ; - *op = local; -return (1 ); +list_for_each_entry (op, &lock_ownerstr_hashtbl[hashval], so_strhash) { +if (cmp_owner_str (op, owner, clid)) +return op; } - *op =NULL ; -return 0 ; +return NULL ; }/*
@@ -2684,7 +2692,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struc fp = open_stp->st_file; strhashval =lock_ownerstr_hashval (fp->fi_inode, open_sop->so_client->cl_clientid.cl_id, - lock->v.new.owner); + &lock->v.new.owner);/* * If we already have this lock owner, the client is in * error (or our bookeeping is wrong!)
@@ -2816,7 +2824,6 @@ nfsd4_lockt(struct svc_rqst *rqstp, strustruct file file;struct file_lock file_lock;struct file_lock *conflicting_lock; -unsigned int strhashval;int status;if (nfs4_in_grace ())
@@ -2858,12 +2865,8 @@ nfsd4_lockt(struct svc_rqst *rqstp, stru goto out; } - strhashval =lock_ownerstr_hashval (inode, - lockt->lt_clientid.cl_id, lockt->lt_owner); - -find_lockstateowner_str (strhashval, &lockt->lt_owner, - &lockt->lt_clientid, - &lockt->lt_stateowner); + lockt->lt_stateowner =find_lockstateowner_str (inode, + &lockt->lt_clientid, &lockt->lt_owner);if (lockt->lt_stateowner) file_lock.fl_owner = (fl_owner_t )lockt->lt_stateowner; file_lock.fl_pid = current->tgid;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: trivial callback cleanup
In reply to NeilBrownWhitespace, etc.
### Diffstat output
./fs/nfsd/nfs4callback.c | 18 +++++++----------- 1 files changed, 7 insertions(+), 11 deletions(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +7 -11
@@ -310,7 +310,7 @@ nfs4_xdr_dec_cb_recall(struct rpc_rqst *if (status) goto out; status =decode_cb_op_hdr (&xdr,OP_CB_RECALL ); -out : +out:return status; }
@@ -545,24 +545,20 @@ retry:void nfsd4_cb_recall (struct nfs4_delegation *dp) { -struct nfs4_client *clp; -struct rpc_clnt *clnt; +struct nfs4_client *clp = dp->dl_client; +struct rpc_clnt *clnt = clp->cl_callback.cb_client; +struct nfs4_cb_recall *cbr = &dp->dl_recall;struct rpc_message msg = { .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_RECALL ], + .rpc_argp = cbr, + .rpc_resp = cbr, }; -struct nfs4_cb_recall *cbr = &dp->dl_recall;int status; -dprintk ("NFSD: nfsd4_cb_recall NFS4_enc_cb_recall_sz %d NFS4_dec_cb_recall_sz %d \n" ,NFS4_enc_cb_recall_sz,NFS4_dec_cb_recall_sz); - - clp = dp->dl_client; - clnt = clp->cl_callback.cb_client;if ((!atomic_read (&clp->cl_callback.cb_set)) || !clnt)return ; - msg.rpc_argp = cbr; - msg.rpc_resp = cbr; - msg.rpc_cred =nfsd4_lookupcred (clp,0 ); + msg.rpc_cred =nfsd4_lookupcred (clp,0 );if (IS_ERR (msg.rpc_cred))return ;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: rename release_stateid_lockowner
In reply to NeilBrownThe name makes it sounds like the job of this function is to release a single lockowner; the plural seems clearer.
### Diffstat output
./fs/nfsd/nfs4state.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +4 -4
@@ -81,7 +81,7 @@ u32 free_delegation= 0;struct nfs4_stateid *find_stateid (stateid_t *stid,int flags);static struct nfs4_delegation *find_delegation_stateid (struct inode *ino,stateid_t *stid);static void release_delegation (struct nfs4_delegation *dp); -static void release_stateid_lockowner (struct nfs4_stateid *open_stp); +static void release_stateid_lockowners (struct nfs4_stateid *open_stp);/* Locking: *
@@ -207,7 +207,7 @@ release_delegation(struct nfs4_delegatiostruct file *filp = dp->dl_stp->st_vfs_file;dprintk ("NFSD: release_delegation CLOSE\n" ); -release_stateid_lockowner (dp->dl_stp); +release_stateid_lockowners (dp->dl_stp);kfree (dp->dl_stp); dp->dl_stp =NULL ;atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE );
@@ -1089,7 +1089,7 @@ alloc_init_open_stateowner(unsigned int }static void -release_stateid_lockowner (struct nfs4_stateid *open_stp) +release_stateid_lockowners (struct nfs4_stateid *open_stp) {struct nfs4_stateowner *lock_sop;
@@ -1177,7 +1177,7 @@ release_stateid(struct nfs4_stateid *stpreturn ; } } -release_stateid_lockowner (stp); +release_stateid_lockowners (stp);nfsd_close (stp->st_vfs_file); vfsclose++; }else if ((stp->st_vfs_set) && (flags &LOCK_STATE )) {
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: keep lockowners off perclient list
In reply to NeilBrownThere's no reason to have the lockowners hang off the same list on the client struct as the openowners do; you can always get to the lockowners from their original openowners instead.
### Diffstat output
./fs/nfsd/nfs4state.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +4 -4
@@ -1109,9 +1109,11 @@ unhash_stateowner(struct nfs4_stateownerlist_del (&sop->so_idhash);list_del (&sop->so_strhash); -list_del (&sop->so_perclient); +if (sop->so_is_open_owner) { +list_del (&sop->so_perclient); + del_perclient++; + }list_del (&sop->so_perlockowner); - del_perclient++;while (!list_empty (&sop->so_perfilestate)) { stp =list_entry (sop->so_perfilestate.next, struct nfs4_stateid, st_perfilestate);
@@ -2575,9 +2577,7 @@ alloc_init_lock_stateowner(unsigned int sop->so_time =0 ;list_add (&sop->so_idhash, &lock_ownerid_hashtbl[idhashval]);list_add (&sop->so_strhash, &lock_ownerstr_hashtbl[strhashval]); -list_add (&sop->so_perclient, &clp->cl_perclient);list_add (&sop->so_perlockowner, &open_stp->st_perlockowner); - add_perclient++; sop->so_is_open_owner =0 ; sop->so_id = current_ownerid++; sop->so_client = clp;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: fix delegation filp sharing
In reply to NeilBrownThe st_vfs_file pointer is set when the open that originally got the delegation is closed, and then in release_deleg we attempt to distinguish between the case when the original open has been closed and when it hasn't. The resulting logic is complicated and buggy.
It's much simpler just to keep a reference count on the struct file.
### Diffstat output
./fs/nfsd/nfs4state.c | 57 ++++++++++++-------------------------------------- 1 files changed, 14 insertions(+), 43 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +14 -43
@@ -145,7 +145,8 @@ alloc_init_deleg(struct nfs4_client *clp dp->dl_client = clp; dp->dl_file = fp; dp->dl_flock =NULL ; - dp->dl_vfs_file =NULL ; +get_file (stp->st_vfs_file); + dp->dl_vfs_file = stp->st_vfs_file; dp->dl_type = type; dp->dl_recall.cbr_dp =NULL ; dp->dl_recall.cbr_ident = cb->cb_ident;
@@ -183,16 +184,6 @@ nfs4_put_delegation(struct nfs4_delegati* the i_flock list, eventually calling nfsd's lock_manager * fl_release_callback. * -* call either: -* nfsd_close : if last close, locks_remove_flock calls lease_modify. -* otherwise, recalled state set to NFS4_RECALL_COMPLETE -* so that it will be reaped by the laundromat service. -* or -* remove_lease (calls time_out_lease which calls lease_modify). -* and nfs4_free_delegation. -* -* Called with nfs_lock_state() held. -* Called with the recall_lock held. */ static void
@@ -203,6 +194,9 @@ nfs4_close_delegation(struct nfs4_delegadprintk ("NFSD: close_delegation dp %p\n" ,dp); dp->dl_vfs_file =NULL ;atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE ); +/* The following nfsd_close may not actually close the file, +* but we want to remove the lease in any case. */ +remove_lease (dp->dl_flock);nfsd_close (filp); vfsclose++; }
@@ -211,18 +205,11 @@ nfs4_close_delegation(struct nfs4_delegastatic void release_delegation (struct nfs4_delegation *dp) { -/* delayed nfsd_close */ -if (dp->dl_vfs_file) -nfs4_close_delegation (dp); -else { -dprintk ("NFSD: release_delegation remove lease dl_flock %p\n" , - dp->dl_flock); -remove_lease (dp->dl_flock); -list_del_init (&dp->dl_del_perfile); -list_del_init (&dp->dl_del_perclnt); -list_del_init (&dp->dl_recall_lru); -nfs4_put_delegation (dp); - } +list_del_init (&dp->dl_del_perfile); +list_del_init (&dp->dl_del_perclnt); +list_del_init (&dp->dl_recall_lru); +nfs4_close_delegation (dp); +nfs4_put_delegation (dp); }/*
@@ -1153,38 +1140,22 @@ init_stateid(struct nfs4_stateid *stp, s__set_bit (open->op_share_deny, &stp->st_deny_bmap); } -/* -* Because nfsd_close() can call locks_remove_flock() which removes leases, -* delay nfsd_close() for delegations from the nfsd_open() clientid -* until the delegation is reaped. -*/ static void release_stateid (struct nfs4_stateid *stp,int flags) { -struct nfs4_delegation *dp; -struct nfs4_file *fp = stp->st_file; +struct file *filp = stp->st_vfs_file;list_del (&stp->st_hash); list_del_perfile++;list_del (&stp->st_perfile);list_del (&stp->st_perfilestate);if (flags &OPEN_STATE ) { -list_for_each_entry (dp, &fp->fi_del_perfile, dl_del_perfile) { -if (cmp_clid (&dp->dl_client->cl_clientid, - &stp->st_stateowner->so_client->cl_clientid)) { - dp->dl_vfs_file = stp->st_vfs_file; -release_stateid_lockowners (stp); -return ; - } - }release_stateid_lockowners (stp); -nfsd_close (stp->st_vfs_file); + stp->st_vfs_file =NULL ; +nfsd_close (filp); vfsclose++; - }else if (flags &LOCK_STATE ) { -struct file *filp = stp->st_vfs_file; - + }else if (flags &LOCK_STATE )locks_remove_posix (filp, (fl_owner_t ) stp->st_stateowner); - }kfree (stp); stp =NULL ; }
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: remove dl_state
In reply to NeilBrownThe dl_state flag isn't actually useful.
### Diffstat output
./fs/nfsd/nfs4callback.c | 1 - ./fs/nfsd/nfs4state.c | 23 +++++------------------ ./include/linux/nfsd/state.h | 7 ------- 3 files changed, 5 insertions(+), 26 deletions(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +0 -1
@@ -540,7 +540,6 @@ nfsd4_cb_recall(struct nfs4_delegation *atomic_set (&clp->cl_callback.cb_set,0 );/* Success or failure, now we're either waiting for lease expiration * or deleg_return. */ -atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE );nfs4_put_delegation (dp);dprintk ("NFSD: nfs4_cb_recall: dp %p dl_flock %p dl_count %d\n" ,dp, dp->dl_flock,atomic_read (&dp->dl_count));put_rpccred (msg.rpc_cred);
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +5 -18
@@ -159,7 +159,6 @@ alloc_init_deleg(struct nfs4_client *clpmemcpy (dp->dl_fhval, ¤t_fh->fh_handle.fh_base, current_fh->fh_handle.fh_size); dp->dl_time =0 ; -atomic_set (&dp->dl_state,NFS4_NO_RECALL );atomic_set (&dp->dl_count,1 );list_add (&dp->dl_del_perfile, &fp->fi_del_perfile);list_add (&dp->dl_del_perclnt, &clp->cl_del_perclnt);
@@ -193,7 +192,6 @@ nfs4_close_delegation(struct nfs4_delegadprintk ("NFSD: close_delegation dp %p\n" ,dp); dp->dl_vfs_file =NULL ; -atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE );/* The following nfsd_close may not actually close the file, * but we want to remove the lease in any case. */ remove_lease (dp->dl_flock);
@@ -338,11 +336,8 @@ expire_client(struct nfs4_client *clp)spin_lock (&recall_lock);while (!list_empty (&clp->cl_del_perclnt)) { dp = list_entry(clp->cl_del_perclnt.next, struct nfs4_delegation, dl_del_perclnt); -dprintk ("NFSD: expire client. dp %p, dl_state %d, fp %p\n" , - dp,atomic_read (&dp->dl_state), dp->dl_flock); - -/* force release of delegation. */ -atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE ); +dprintk ("NFSD: expire client. dp %p, fp %p\n" , dp, + dp->dl_flock);list_del_init (&dp->dl_del_perclnt);list_move (&dp->dl_recall_lru, &reaplist); }
@@ -1355,7 +1350,6 @@ void nfsd_break_deleg_cb(struct file_locatomic_inc (&dp->dl_count);spin_lock (&recall_lock); -atomic_set (&dp->dl_state,NFS4_RECALL_IN_PROGRESS );list_add_tail (&dp->dl_recall_lru, &del_recall_lru);spin_unlock (&recall_lock);
@@ -1385,11 +1379,10 @@ void nfsd_release_deleg_cb(struct file_l {struct nfs4_delegation *dp = (struct nfs4_delegation *)fl->fl_owner; -dprintk ("NFSD nfsd_release_deleg_cb: fl %p dp %p dl_count %d, dl_state %d\n" , fl,dp,atomic_read (&dp->dl_count),atomic_read (&dp->dl_state)); +dprintk ("NFSD nfsd_release_deleg_cb: fl %p dp %p dl_count %d\n" , fl,dp,atomic_read (&dp->dl_count));if (!(fl->fl_flags &FL_LEASE ) || !dp)return ; -atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE ); dp->dl_flock =NULL ; }
@@ -1514,11 +1507,8 @@ nfs4_check_deleg_recall(struct nfs4_fileint status =0 ;list_for_each_entry (dp, &fp->fi_del_perfile, dl_del_perfile) { -dprintk ("NFSD: found delegation %p with dl_state %d\n" , - dp,atomic_read (&dp->dl_state));if (op->op_share_access &NFS4_SHARE_ACCESS_WRITE - || op->op_stateowner->so_client == dp->dl_client - ||atomic_read (&dp->dl_state) !=NFS4_NO_RECALL ) { + || op->op_stateowner->so_client == dp->dl_client) { *flag =NFS4_OPEN_DELEGATE_NONE ; goto out; }
@@ -2064,10 +2054,8 @@ nfs4_preprocess_stateid_op(struct svc_fhif ((status =nfs4_check_delegmode (dp, flags))) goto out;renew_client (dp->dl_client); -if (flags &DELEG_RET ) { -atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE ); +if (flags &DELEG_RET )release_delegation (dp); - }if (filpp) *filpp = dp->dl_vfs_file; }
@@ -3236,7 +3224,6 @@ __nfs4_state_shutdown(void)spin_lock (&recall_lock);list_for_each_safe (pos, next, &del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); -atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE );list_move (&dp->dl_recall_lru, &reaplist); }spin_unlock (&recall_lock);
include/linux/nfsd/state.h renamed from include/linux/nfsd/state.h~current~ +0 -7
@@ -67,12 +67,6 @@ extern stateid_t onestateid;#define ZERO_STATEID (stateid) (!memcmp((stateid), &zerostateid, sizeof(stateid_t)))#define ONE_STATEID (stateid) (!memcmp((stateid), &onestateid, sizeof(stateid_t))) -/* Delegation recall states */ -#define NFS4_NO_RECALL 0x000 -#define NFS4_RECALL_IN_PROGRESS 0x001 -#define NFS4_RECALL_COMPLETE 0x002 -#define NFS4_REAP_DELEG 0x004 -struct nfs4_cb_recall {u32 cbr_ident;int cbr_trunc;
@@ -87,7 +81,6 @@ struct nfs4_delegation {struct list_head dl_del_perclnt;/* nfs4_client->cl_del_perclnt*/ struct list_head dl_recall_lru;/* delegation recalled */ atomic_t dl_count;/* ref count */ -atomic_t dl_state;/* recall state */ struct nfs4_client *dl_client;struct nfs4_file *dl_file;struct file_lock *dl_flock;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: nfs4_cb_recall cleanup
In reply to NeilBrownMiscellaneous cleanup including:
remove recursion
use a local variable instead of dl_recall_cnt
### Diffstat output
./fs/nfsd/nfs4callback.c | 85 +++++++++++++++++------------------------------ 1 files changed, 31 insertions(+), 54 deletions(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +31 -54
@@ -493,54 +493,7 @@ out: }/* -* Called with dp->dl_count incremented -*/ -static void -nfs4_cb_recall_done (struct nfs4_cb_recall *cbr,int status) -{ -struct nfs4_delegation *dp = cbr->cbr_dp; - -/* all is well... */ -if (status ==0 ) - goto out; - -/* network partition, retry nfsd4_cb_recall once. */ -if (status == -EIO ) { -if (atomic_read (&dp->dl_recall_cnt) ==0 ) - goto retry; -else -/* callback channel no longer available */ -atomic_set (&dp->dl_client->cl_callback.cb_set,0 ); - } - -/* Race: a recall occurred miliseconds after a delegation was granted. -* Client may have received recall prior to delegation. retry recall -* once. -*/ -if ((status == -EBADHANDLE ) || (status == -NFS4ERR_BAD_STATEID )){ -if (atomic_read (&dp->dl_recall_cnt) ==0 ) - goto retry; - } -atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE ); - -out: -if (atomic_dec_and_test (&dp->dl_count)) -atomic_set (&dp->dl_state,NFS4_REAP_DELEG ); -BUG_ON (atomic_read (&dp->dl_count) <0 ); -dprintk ("NFSD: nfs4_cb_recall_done: dp %p dl_flock %p dl_count %d\n" ,dp, dp->dl_flock,atomic_read (&dp->dl_count)); -return ; - -retry: -dprintk ("NFSD: nfs4_cb_recall_done RETRY\n" ); -atomic_inc (&dp->dl_recall_cnt); -/* sleep 2 seconds before retrying recall */ -ssleep (2 ); -nfsd4_cb_recall (dp); -} - -/* * called with dp->dl_count inc'ed. -* nfs4_lock_state() may or may not have been called. */ void nfsd4_cb_recall (struct nfs4_delegation *dp)
@@ -551,25 +504,49 @@ nfsd4_cb_recall(struct nfs4_delegation *struct rpc_message msg = { .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_RECALL ], .rpc_argp = cbr, - .rpc_resp = cbr, }; -int status; +int retries =1 ; +int status =0 ;if ((!atomic_read (&clp->cl_callback.cb_set)) || !clnt)return ; msg.rpc_cred =nfsd4_lookupcred (clp,0 );if (IS_ERR (msg.rpc_cred)) -return ; + goto out; cbr->cbr_trunc =0 ;/* XXX need to implement truncate optimization */ cbr->cbr_dp = dp; status =rpc_call_sync (clnt, &msg,RPC_TASK_SOFT ); -if (status) -dprintk ("NFSD: recall_delegation: rpc_call_async failed %d\n" , - status); -nfs4_cb_recall_done (cbr, status); +while (retries--) { +switch (status) { +case -EIO : +/* Network partition? */ +case -EBADHANDLE : +case -NFS4ERR_BAD_STATEID : +/* Race: client probably got cb_recall +* before open reply granting delegation */ +break ; +default : + goto out; + } +ssleep (2 ); + status =rpc_call_sync (clnt, &msg,RPC_TASK_SOFT ); + } + + out: +if (status == -EIO ) +atomic_set (&clp->cl_callback.cb_set,0 ); +/* Success or failure, now we're either waiting for lease expiration +* or deleg_return. */ +atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE ); + +if (atomic_dec_and_test (&dp->dl_count)) +atomic_set (&dp->dl_state,NFS4_REAP_DELEG ); +BUG_ON (atomic_read (&dp->dl_count) <0 ); + +dprintk ("NFSD: nfs4_cb_recall: dp %p dl_flock %p dl_count %d\n" ,dp, dp->dl_flock,atomic_read (&dp->dl_count));put_rpccred (msg.rpc_cred);return ; }
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: remove st_vfs_set
In reply to NeilBrownNote st_vfs_set is redundant; we can always just check whether st_vfs_file is set.
Fix one inconsistency along the way: we were setting st_vfs_file to 0 in one case without fput()'ing st_vfs_file. It doesn't appear there was a need to do either one in that case.
### Diffstat output
./fs/nfsd/nfs4state.c | 11 ++++------- ./include/linux/nfsd/state.h | 1 - 2 files changed, 4 insertions(+), 8 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +4 -7
@@ -1171,7 +1171,7 @@ release_stateid(struct nfs4_stateid *stp list_del_perfile++;list_del (&stp->st_perfile);list_del (&stp->st_perfilestate); -if ((stp->st_vfs_set) && (flags &OPEN_STATE )) { +if ((stp->st_vfs_file) && (flags &OPEN_STATE )) {list_for_each_entry (dp, &fp->fi_del_perfile, dl_del_perfile) {if (cmp_clid (&dp->dl_client->cl_clientid, &stp->st_stateowner->so_client->cl_clientid)) {
@@ -1182,7 +1182,7 @@ release_stateid(struct nfs4_stateid *stprelease_stateid_lockowners (stp);nfsd_close (stp->st_vfs_file); vfsclose++; - }else if ((stp->st_vfs_set) && (flags &LOCK_STATE )) { + }else if ((stp->st_vfs_file) && (flags &LOCK_STATE )) {struct file *filp = stp->st_vfs_file;locks_remove_posix (filp, (fl_owner_t ) stp->st_stateowner);
@@ -1586,7 +1586,6 @@ nfs4_new_open(struct svc_rqst *rqstp, streturn status; } vfsopen++; - stp->st_vfs_set =1 ; *stpp = stp;return 0 ; }
@@ -1922,7 +1921,7 @@ find_openstateowner_id(u32 st_id, int flstatic inline int nfs4_check_fh (struct svc_fh *fhp,struct nfs4_stateid *stp) { -return (stp->st_vfs_set ==0 || +return (stp->st_vfs_file ==NULL || fhp->fh_dentry->d_inode != stp->st_vfs_file->f_dentry->d_inode); }
@@ -2147,7 +2146,6 @@ nfs4_preprocess_seqid_op(struct svc_fh *if ((flags &CHECK_FH ) &&nfs4_check_fh (current_fh, stp)) {printk ("NFSD: preprocess_seqid_op: fh-stateid mismatch!\n" ); - stp->st_vfs_set =0 ; goto out; }
@@ -2611,7 +2609,6 @@ alloc_init_lock_stateid(struct nfs4_stat stp->st_stateid.si_fileid = fp->fi_id; stp->st_stateid.si_generation =0 ; stp->st_vfs_file = open_stp->st_vfs_file;/* FIXME refcount?? */ - stp->st_vfs_set = open_stp->st_vfs_set; stp->st_access_bmap = open_stp->st_access_bmap; stp->st_deny_bmap = open_stp->st_deny_bmap;
@@ -3018,7 +3015,7 @@ nfsd4_release_lockowner(struct svc_rqst status = nfserr_locks_held;list_for_each_entry (stp, &local->so_perfilestate, st_perfilestate) { -if (stp->st_vfs_set) { +if (stp->st_vfs_file) {if (check_for_locks (stp->st_vfs_file, local)) goto out; }
include/linux/nfsd/state.h renamed from include/linux/nfsd/state.h~current~ +0 -1
@@ -254,7 +254,6 @@ struct nfs4_stateid {struct nfs4_file * st_file;stateid_t st_stateid;struct file * st_vfs_file; -int st_vfs_set;unsigned long st_access_bmap;unsigned long st_deny_bmap; };
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: move delegation decisions to lock_manager callbacks
In reply to NeilBrownRemove nfs4_check_deleg_recall(). Move its checks into __setlease() via two new lock_manager callbacks, fl_mylease and fl_change, so that all leases (not just NFSv4 lease as with nfs4_check_deleg_recall) are checked. Default implementations of fl_mylease and fl_change are provided for the sake of the fcntl_setlease interface. Both callbacks must always be defined.
fl_mylease:
for the NFSv4 server, this check is used to see if an existing lease comes from the same client.
For the fcntl_setlease interface, the existing logic is preserved. the fl_mylease check sees if the existing lease is from the input filp.
fl_change: called if the fl_mylease returns true
the NFSv4 server does not hand out a delegation to a client that already has one. -EAGAIN is returned. Otherwise lease_modify is used. For the fcntl_setlease interface, the exisiting logic is preserved: The callback used in lease_modify().
### Diffstat output
./fs/locks.c | 15 ++++++-- ./fs/nfsd/nfs4state.c | 93 +++++++++++++++++++++++++++----------------------- ./include/linux/fs.h | 3 + 3 files changed, 66 insertions(+), 45 deletions(-)
fs/locks.c renamed from fs/locks.c~current~ +12 -3
@@ -406,9 +406,16 @@ static void lease_release_private_callba fl->fl_file->f_owner.signum =0 ; } +static int lease_mylease_callback (struct file_lock *fl,struct file_lock *try) +{ +return fl->fl_file == try->fl_file; +} +struct lock_manager_operations lease_manager_ops = { .fl_break = lease_break_callback, .fl_release_private = lease_release_private_callback, + .fl_mylease = lease_mylease_callback, + .fl_change = lease_modify, };/*
@@ -1058,7 +1065,7 @@ int locks_mandatory_area(int read_write,EXPORT_SYMBOL (locks_mandatory_area);/* We already had a lease on this file; just change its type */ -static int lease_modify (struct file_lock **before,int arg) +int lease_modify (struct file_lock **before,int arg) {struct file_lock *fl = *before;int error =assign_type (fl, arg);
@@ -1071,6 +1078,8 @@ static int lease_modify(struct file_lockreturn 0 ; } +EXPORT_SYMBOL (lease_modify); +static void time_out_leases (struct inode *inode) {struct file_lock **before;
@@ -1315,7 +1324,7 @@ int __setlease(struct file *filp, long afor (before = &inode->i_flock; ((fl = *before) !=NULL ) &&IS_LEASE (fl); before = &fl->fl_next) { -if (fl->fl_file == filp) +if (lease->fl_lmops->fl_mylease (fl, lease)) my_before = before;else if (fl->fl_type == (F_INPROGRESS |F_UNLCK ))/*
@@ -1333,7 +1342,7 @@ int __setlease(struct file *filp, long a goto out;if (my_before !=NULL ) { - error =lease_modify (my_before, arg); + error = lease->fl_lmops->fl_change (my_before, arg); goto out; }
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +51 -42
161 lines not on this page · raw message
include/linux/fs.h renamed from include/linux/fs.h~current~ +3 -0
@@ -654,6 +654,8 @@ struct lock_manager_operations {void (*fl_copy_lock)(struct file_lock *,struct file_lock *);void (*fl_release_private)(struct file_lock *);void (*fl_break)(struct file_lock *); +int (*fl_mylease)(struct file_lock *,struct file_lock *); +int (*fl_change)(struct file_lock **,int ); };/* that will die - we need it for nfs_lock_info */
@@ -720,6 +722,7 @@ extern int flock_lock_file_wait(struct fextern int __break_lease (struct inode *inode,unsigned int flags);extern void lease_get_mtime (struct inode *,struct timespec *time);extern int setlease (struct file *,long ,struct file_lock **); +extern int lease_modify (struct file_lock **,int );extern void remove_lease (struct file_lock *);extern int lock_may_read (struct inode *,loff_t start,unsigned long count);extern int lock_may_write (struct inode *,loff_t start,unsigned long count);
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: fix laundromat delegation reaping
In reply to NeilBrownThe laundromat is freeing any delegation it finds in the RECALL_COMPLETE state. But note that RECALL_COMPLETE is the state that the delegation recall callback leaves the state in. We shouldn't actually be giving up on the delegation till either the client has had a chance to call delegreturn, or the lease time has run out.
### Diffstat output
./fs/nfsd/nfs4state.c | 3 --- 1 files changed, 3 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +0 -3
@@ -1861,15 +1861,12 @@ nfs4_laundromat(void)spin_lock (&recall_lock);list_for_each_safe (pos, next, &del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); -if (atomic_read (&dp->dl_state) ==NFS4_RECALL_COMPLETE ) - goto reap;if (time_after ((unsigned long )dp->dl_time, (unsigned long )cutoff)) { u = dp->dl_time - cutoff;if (test_val > u) test_val = u;break ; } -reap:dprintk ("NFSD: purging unused delegation dp %p, fp %p\n" , dp, dp->dl_flock);release_delegation (dp);
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: remove utf8 checking
In reply to NeilBrownRFC3530 says NFSv4 filenames are in UTF-8, and that servers "should" reject filenames that aren't valid UTF-8. Currently we do some incomplete UTF-8 checking, but this turns out to be more of a hindrance than a help--if we export a filesystem with non-UTF8 names, things break. We might be able to help things if we had some idea of the exported filesystem's charset and could do some translation. For now, though, the simplest solution by far seems to be just to remove the UTF-8 checks, making NFSv4's behaviour just like NFSv2/v3's.
Similar problems exist with usernames.
### Diffstat output
./fs/nfsd/nfs4xdr.c | 125 ---------------------------------------------------- 1 files changed, 1 insertion(+), 124 deletions(-)
fs/nfsd/nfs4xdr.c renamed from fs/nfsd/nfs4xdr.c~current~ +1 -124
@@ -60,121 +60,6 @@#define NFSDDBG_FACILITY NFSDDBG_XDR -static const char utf8_byte_len[256 ] = { -1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 , -1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 , -1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 , -1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 , -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -0 ,0 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 , -3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,5 ,5 ,5 ,5 ,6 ,6 ,0 ,0 -}; - -static inline int -is_legal_utf8_sequence (unsigned char *source,int length) -{ -unsigned char *ptr; -unsigned char c; - -if (length==1 )return 1 ; - -/* Check for overlong sequence, and check second byte */ - c = *(source +1 ); -switch (*source) { -case 0xE0 :/* 3 bytes */ -if ( c <0xA0 )return 0 ; -break ; -case 0xF0 :/* 4 bytes */ -if ( c <0x90 )return 0 ; -break ; -case 0xF8 :/* 5 bytes */ -if ( c <0xC8 )return 0 ; -break ; -case 0xFC :/* 6 bytes */ -if ( c <0x84 )return 0 ; -break ; -default : -if ( (c &0xC0 ) !=0x80 )return 0 ; - } - -/* Check that trailing bytes look like 10xxxxxx */ -for (ptr = source++ + length -1 ; ptr>source; ptr--) -if ( ((*ptr) &0xC0 ) !=0x80 )return 0 ; -return 1 ; -} - -/* This does some screening on disallowed unicode characters. It is NOT -* comprehensive. -*/ -static int -is_allowed_utf8_char (unsigned char *source,int length) -{ -/* We assume length and source point to a valid utf8 sequence */ -unsigned char c; - -/* Disallow F0000 and up (in utf8, F3B08080) */ -if (*source >0xF3 )return 0 ; - c = *(source +1 ); -switch (*source) { -case 0xF3 : -if (c >=0xB0 )return 0 ; -break ; -/* Disallow D800-F8FF (in utf8, EDA080-EFA3BF */ -case 0xED : -if (c >=0xA0 )return 0 ; -break ; -case 0xEE : -return 0 ; -break ; -case 0xEF : -if (c <=0xA3 )return 0 ; -/* Disallow FFF9-FFFF (EFBFB9-EFBFBF) */ -if (c==0xBF ) -/* Don't need to check <=0xBF, since valid utf8 */ -if ( *(source+2 ) >=0xB9 )return 0 ; -break ; - } -return 1 ; -} - -/* This routine should really check to see that the proper stringprep -* mappings have been applied. Instead, we do a simple screen of some -* of the more obvious illegal values by calling is_allowed_utf8_char. -* This will allow many illegal strings through, but if a client behaves, -* it will get full functionality. The other option (apart from full -* stringprep checking) is to limit everything to an easily handled subset, -* such as 7-bit ascii. -* -* Note - currently calling routines ignore return value except as boolean. -*/ -static int -check_utf8 (char *str,int len) -{ -unsigned char *chunk, *sourceend; -int chunklen; - - chunk = str; - sourceend = str + len; - -while (chunk < sourceend) { - chunklen = utf8_byte_len[*chunk]; -if (!chunklen) -return nfserr_inval; -if (chunk + chunklen > sourceend) -return nfserr_inval; -if (!is_legal_utf8_sequence (chunk, chunklen)) -return nfserr_inval; -if (!is_allowed_utf8_char (chunk, chunklen)) -return nfserr_inval; -if ( (chunklen==1 ) && (!*chunk) ) -return nfserr_inval;/* Disallow embedded nulls */ - chunk += chunklen; - } - -return 0 ; -} -static int check_filename (char *str,int len,int err) {
@@ -187,7 +72,7 @@ check_filename(char *str, int len, int efor (i =0 ; i < len; i++)if (str[i] =='/' )return err; -return check_utf8 (str, len); +return 0 ; }/*
@@ -403,8 +288,6 @@ nfsd4_decode_fattr(struct nfsd4_compoundREAD_BUF (dummy32); len +=XDR_QUADLEN (dummy32) <<2 ;READMEM (buf, dummy32); -if (check_utf8 (buf, dummy32)) -return nfserr_inval; ace.whotype =nfs4_acl_get_whotype (buf, dummy32); status =0 ;if (ace.whotype !=NFS4_ACL_WHO_NAMED )
@@ -439,8 +322,6 @@ nfsd4_decode_fattr(struct nfsd4_compoundREAD_BUF (dummy32); len += (XDR_QUADLEN (dummy32) <<2 );READMEM (buf, dummy32); -if (check_utf8 (buf, dummy32)) -return nfserr_inval;if ((status =nfsd_map_name_to_uid (argp->rqstp, buf, dummy32, &iattr->ia_uid))) goto out_nfserr; iattr->ia_valid |=ATTR_UID ;
@@ -452,8 +333,6 @@ nfsd4_decode_fattr(struct nfsd4_compoundREAD_BUF (dummy32); len += (XDR_QUADLEN (dummy32) <<2 );READMEM (buf, dummy32); -if (check_utf8 (buf, dummy32)) -return nfserr_inval;if ((status =nfsd_map_name_to_gid (argp->rqstp, buf, dummy32, &iattr->ia_gid))) goto out_nfserr; iattr->ia_valid |=ATTR_GID ;
@@ -585,8 +464,6 @@ nfsd4_decode_create(struct nfsd4_compounREAD32 (create->cr_linklen);READ_BUF (create->cr_linklen);SAVEMEM (create->cr_linkname, create->cr_linklen); -if (check_utf8 (create->cr_linkname, create->cr_linklen)) -return nfserr_inval;break ;case NF4BLK :case NF4CHR :
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: do callback replays by hand
In reply to NeilBrownTurn off rpc layer timeout replay for the NFSv4 server callback client. Rely on manual replay in nfs4_cb_recall_done instead.
### Diffstat output
./fs/nfsd/nfs4callback.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +3 -2
@@ -402,7 +402,7 @@ nfsd4_probe_callback(struct nfs4_client/* Initialize timeout */ timeparms.to_initval = (NFSD_LEASE_TIME /4 ) *HZ ; - timeparms.to_retries =5 ; + timeparms.to_retries =0 ; timeparms.to_maxval = (NFSD_LEASE_TIME /2 ) *HZ ; timeparms.to_exponential =1 ;
@@ -432,7 +432,7 @@ nfsd4_probe_callback(struct nfs4_clientdprintk ("NFSD: couldn't create callback client\n" ); goto out_xprt; } - clnt->cl_intr =1 ; + clnt->cl_intr =0 ; clnt->cl_softrtry =1 ; clnt->cl_chatty =1 ;
@@ -531,6 +531,7 @@ out:return ; retry: +dprintk ("NFSD: nfs4_cb_recall_done RETRY\n" );atomic_inc (&dp->dl_recall_cnt);/* sleep 2 seconds before retrying recall */ ssleep (2 );
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: miscellaneous delegation fixes
In reply to NeilBrownDon't hand out a delegation to a client that already has one.
Minor simplification and reformatting.
### Diffstat output
./fs/nfsd/nfs4state.c | 31 +++++++++---------------------- 1 files changed, 9 insertions(+), 22 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +9 -22
@@ -1514,22 +1514,6 @@ out: }static int -nfs4_deleg_conflict (u32 share,u32 dtype) -{ -return (((share &NFS4_SHARE_ACCESS_WRITE ) && - dtype ==NFS4_OPEN_DELEGATE_READ ) || - ((share &NFS4_SHARE_ACCESS_READ ) && - dtype ==NFS4_OPEN_DELEGATE_WRITE )); -} - -/* -* nfs4_check_deleg_recall() -* -* Test any delegation that is currently within an incompleted recalled -* state, and return NFSERR_DELAY for conflicting open share. -* flag is set to DONT_DELEGATE for shares that match the deleg type. -*/ -static int nfs4_check_deleg_recall (struct nfs4_file *fp,struct nfsd4_open *op,int *flag) {struct nfs4_delegation *dp;
@@ -1538,13 +1522,16 @@ nfs4_check_deleg_recall(struct nfs4_filelist_for_each_entry (dp, &fp->fi_del_perfile, dl_del_perfile) {dprintk ("NFSD: found delegation %p with dl_state %d\n" , dp,atomic_read (&dp->dl_state)); -if (atomic_read (&dp->dl_state) ==NFS4_RECALL_IN_PROGRESS ) { -if (nfs4_deleg_conflict (op->op_share_access, dp->dl_type)) - status = nfserr_jukebox; -else - *flag =NFS4_OPEN_DELEGATE_NONE ; +if (op->op_share_access &NFS4_SHARE_ACCESS_WRITE + || op->op_stateowner->so_client == dp->dl_client + ||atomic_read (&dp->dl_state) !=NFS4_NO_RECALL ) { + *flag =NFS4_OPEN_DELEGATE_NONE ; + goto out; } } +out: +dprintk ("NFSD: nfs4_check_deleg_recall returns %d with flag %d\n" , + status, *flag);return status; }
@@ -1718,7 +1705,7 @@ nfsd4_process_open2(struct svc_rqst *rqsstruct inode *ino = current_fh->fh_dentry->d_inode;unsigned int fi_hashval;struct nfs4_stateid *stp =NULL ; -int status, delegflag =0 ; +int status, delegflag =-1 ; status = nfserr_inval;if (!TEST_ACCESS (open->op_share_access) || !TEST_DENY (open->op_share_deny))
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: simplify clientid hash table searches
In reply to NeilBrownWe repeat the same hash table searches in a bunch of places, and keep making the mistake of assuming the variable iterating over the list will be NULL when the search fails. Some helper functions here simplify things a bit.
While we're at it, make move_to_confirmed take just a clp instead of making the caller compute the hash. This means we sometimes have to compute the hash multiple times, but it's only an &, so no big deal.
### Diffstat output
./fs/nfsd/nfs4state.c | 84 ++++++++++++++++++++++++++------------------------ 1 files changed, 45 insertions(+), 39 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +45 -39
@@ -471,8 +471,9 @@ add_to_unconfirmed(struct nfs4_client *c }void -move_to_confirmed (struct nfs4_client *clp,unsigned int idhashval) +move_to_confirmed (struct nfs4_client *clp) { +unsigned int idhashval =clientid_hashval (clp->cl_clientid.cl_id);unsigned int strhashval;dprintk ("NFSD: move_to_confirm nfs4_client %p\n" , clp);
@@ -485,6 +486,31 @@ move_to_confirmed(struct nfs4_client *clrenew_client (clp); } +static struct nfs4_client * +find_confirmed_client (clientid_t *clid) +{ +struct nfs4_client *clp; +unsigned int idhashval =clientid_hashval (clid->cl_id); + +list_for_each_entry (clp, &conf_id_hashtbl[idhashval], cl_idhash) { +if (cmp_clid (&clp->cl_clientid, clid)) +return clp; + } +return NULL ; +} + +static struct nfs4_client * +find_unconfirmed_client (clientid_t *clid) +{ +struct nfs4_client *clp; +unsigned int idhashval =clientid_hashval (clid->cl_id); + +list_for_each_entry (clp, &unconf_id_hashtbl[idhashval], cl_idhash) { +if (cmp_clid (&clp->cl_clientid, clid)) +return clp; + } +return NULL ; +}/* a helper function for parse_callback */ static int
@@ -793,7 +819,6 @@ int nfsd4_setclientid_confirm(struct svc_rqst *rqstp, struct nfsd4_setclientid_confirm *setclientid_confirm) { u32 ip_addr = rqstp->rq_addr.sin_addr.s_addr; -unsigned int idhashval;struct nfs4_client *clp, *conf =NULL , *unconf =NULL ;nfs4_verifier confirm = setclientid_confirm->sc_confirm;clientid_t * clid = &setclientid_confirm->sc_clientid;
@@ -806,12 +831,9 @@ nfsd4_setclientid_confirm(struct svc_rqs* We get here on a DRC miss. */ - idhashval =clientid_hashval (clid->cl_id);nfs4_lock_state (); -list_for_each_entry (clp, &conf_id_hashtbl[idhashval], cl_idhash) { -if (!cmp_clid (&clp->cl_clientid, clid)) -continue ; - + clp =find_confirmed_client (clid); +if (clp) { status = nfserr_inval;/* * Found a record for this clientid. If the IP addresses
@@ -825,11 +847,9 @@ nfsd4_setclientid_confirm(struct svc_rqs goto out; } conf = clp; -break ; } -list_for_each_entry (clp, &unconf_id_hashtbl[idhashval], cl_idhash) { -if (!cmp_clid (&clp->cl_clientid, clid)) -continue ; + clp =find_unconfirmed_client (clid); +if (clp) { status = nfserr_inval;if (clp->cl_addr != ip_addr) { printk("NFSD: setclientid: string in use by client"
@@ -838,7 +858,6 @@ nfsd4_setclientid_confirm(struct svc_rqs goto out; } unconf = clp; -break ; }/* CASE 1: * unconf record that matches input clientid and input confirm.
@@ -855,7 +874,7 @@ nfsd4_setclientid_confirm(struct svc_rqselse {expire_client (conf); clp = unconf; -move_to_confirmed (unconf, idhashval); +move_to_confirmed (unconf); status = nfs_ok; } goto out;
@@ -888,7 +907,7 @@ nfsd4_setclientid_confirm(struct svc_rqs }else { status = nfs_ok; clp = unconf; -move_to_confirmed (unconf, idhashval); +move_to_confirmed (unconf); } goto out; }
@@ -1233,11 +1252,9 @@ static int verify_clientid(struct nfs4_client **client, clientid_t *clid) { struct nfs4_client *clp; -unsigned int idhashval =clientid_hashval (clid->cl_id); -list_for_each_entry (clp, &conf_id_hashtbl[idhashval], cl_idhash) { -if (!cmp_clid (&clp->cl_clientid, clid)) -continue ; + clp =find_confirmed_client (clid); +if (clp) { *client = clp;return 1 ; }
@@ -1798,7 +1815,6 @@ int nfsd4_renew(clientid_t *clid) {struct nfs4_client *clp; -unsigned int idhashval;int status;nfs4_lock_state ();
@@ -1808,18 +1824,15 @@ nfsd4_renew(clientid_t *clid)if (STALE_CLIENTID (clid)) goto out; status = nfs_ok; - idhashval =clientid_hashval (clid->cl_id); -list_for_each_entry (clp, &conf_id_hashtbl[idhashval], cl_idhash) { -if (!cmp_clid (&clp->cl_clientid, clid)) -continue ; + clp =find_confirmed_client (clid); +if (clp) {renew_client (clp); goto out; } -list_for_each_entry (clp, &unconf_id_hashtbl[idhashval], cl_idhash) { -if (!cmp_clid (&clp->cl_clientid, clid)) -continue ; + clp =find_unconfirmed_client (clid); +if (clp) {renew_client (clp); - goto out; + goto out; }/* * Couldn't find an nfs4_client for this clientid.
@@ -3100,30 +3113,23 @@ nfs4_release_reclaim(void)struct nfs4_client_reclaim *nfs4_find_reclaim_client (clientid_t *clid) { -unsigned int idhashval =clientid_hashval (clid->cl_id);unsigned int strhashval; -struct nfs4_client *clp, *client =NULL ; +struct nfs4_client *clp;struct nfs4_client_reclaim *crp =NULL ;/* find clientid in conf_id_hashtbl */ -list_for_each_entry (clp, &conf_id_hashtbl[idhashval], cl_idhash) { -if (cmp_clid (&clp->cl_clientid, clid)) { - client = clp; -break ; - } - } -if (!client) + clp =find_confirmed_client (clid); +if (clp ==NULL )return NULL ;dprintk ("NFSD: nfs4_find_reclaim_client for %.*s\n" , clp->cl_name.len, clp->cl_name.data);/* find clp->cl_name in reclaim_str_hashtbl */ - strhashval =clientstr_hashval (client->cl_name.data, - client->cl_name.len); + strhashval =clientstr_hashval (clp->cl_name.data, clp->cl_name.len);list_for_each_entry (crp, &reclaim_str_hashtbl[strhashval], cr_strhash) { -if (cmp_name (&crp->cr_name, &client->cl_name)) { +if (cmp_name (&crp->cr_name, &clp->cl_name)) {return crp; } }
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: fix delegation refcounting
In reply to NeilBrownThe delegation recall callback is setting the REAP_DELEGATION state when it drops the reference count to zero instead of just freeing the thing itself, which is needlessly complicated and bug-prone. It's simpler just to define a nfs4_put_delegation() which works in the usual way and have the delegation recall code do call that itself.
Eventually I'll convert all the nfsd4 state reference counts to struct krefs which will be harder to abuse in this way....
### Diffstat output
./fs/nfsd/nfs4callback.c | 6 +----- ./fs/nfsd/nfs4state.c | 27 ++++++++++----------------- ./include/linux/nfsd/state.h | 1 + 3 files changed, 12 insertions(+), 22 deletions(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +1 -5
@@ -541,11 +541,7 @@ nfsd4_cb_recall(struct nfs4_delegation */* Success or failure, now we're either waiting for lease expiration * or deleg_return. */ atomic_set (&dp->dl_state,NFS4_RECALL_COMPLETE ); - -if (atomic_dec_and_test (&dp->dl_count)) -atomic_set (&dp->dl_state,NFS4_REAP_DELEG ); -BUG_ON (atomic_read (&dp->dl_count) <0 ); - +nfs4_put_delegation (dp);dprintk ("NFSD: nfs4_cb_recall: dp %p dl_flock %p dl_count %d\n" ,dp, dp->dl_flock,atomic_read (&dp->dl_count));put_rpccred (msg.rpc_cred);return ;
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +10 -17
@@ -167,17 +167,14 @@ alloc_init_deleg(struct nfs4_client *clpreturn dp; } -/* -* Free the delegation structure. -* Called with the recall_lock held. -*/ -static void -nfs4_free_delegation (struct nfs4_delegation *dp) +void +nfs4_put_delegation (struct nfs4_delegation *dp) { -dprintk ("NFSD: nfs4_free_delegation freeing dp %p\n" ,dp); -list_del (&dp->dl_recall_lru); -kfree (dp); - free_delegation++; +if (atomic_dec_and_test (&dp->dl_count)) { +dprintk ("NFSD: freeing dp %p\n" ,dp); +kfree (dp); + free_delegation++; + } }/* release_delegation:
@@ -219,12 +216,8 @@ release_delegation(struct nfs4_delegatioremove_lease (dp->dl_flock);list_del_init (&dp->dl_del_perfile);list_del_init (&dp->dl_del_perclnt); -/* dl_count > 0 => outstanding recall rpc */ -dprintk ("NFSD: release_delegation free deleg dl_count %d\n" , -atomic_read (&dp->dl_count)); -if ((atomic_read (&dp->dl_state) ==NFS4_REAP_DELEG ) - ||atomic_dec_and_test (&dp->dl_count)) -nfs4_free_delegation (dp); +list_del_init (&dp->dl_recall_lru); +nfs4_put_delegation (dp); } }
@@ -1692,7 +1685,7 @@ nfs4_open_delegation(struct svc_fh *fh,dprintk ("NFSD: setlease failed [%d], no delegation\n" , status);list_del (&dp->dl_del_perfile);list_del (&dp->dl_del_perclnt); -kfree (dp); +nfs4_put_delegation (dp); free_delegation++; *flag =NFS4_OPEN_DELEGATE_NONE ;return ;
include/linux/nfsd/state.h renamed from include/linux/nfsd/state.h~current~ +1 -0
@@ -288,6 +288,7 @@ extern void put_nfs4_client(struct nfs4_extern void nfs4_free_stateowner (struct kref *kref);extern void nfsd4_probe_callback (struct nfs4_client *clp);extern void nfsd4_cb_recall (struct nfs4_delegation *dp); +extern void nfs4_put_delegation (struct nfs4_delegation *dp);static inline void nfs4_put_stateowner (struct nfs4_stateowner *so)
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: simplify open_delegation 2
In reply to NeilBrownSimplify logic in nfs4_open_delegation, fix a small bug on allocation failure.
### Diffstat output
./fs/nfsd/nfs4state.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +7 -6
@@ -1664,20 +1664,21 @@ nfs4_open_delegation(struct svc_fh *fh,if (*flag ==NFS4_OPEN_DELEGATE_NONE )return ; -/* set flag */ *flag =NFS4_OPEN_DELEGATE_NONE ;if (open->op_claim_type !=NFS4_OPEN_CLAIM_NULL || !atomic_read (&cb->cb_set) || !sop->so_confirmed)return ; -if (!(open->op_share_access &NFS4_SHARE_ACCESS_WRITE )) - *flag =NFS4_OPEN_DELEGATE_READ ; - -else if (!(open->op_share_access &NFS4_SHARE_ACCESS_READ )) +if (open->op_share_access &NFS4_SHARE_ACCESS_WRITE ) *flag =NFS4_OPEN_DELEGATE_WRITE ; +else + *flag =NFS4_OPEN_DELEGATE_READ ; -if (!(dp =alloc_init_deleg (sop->so_client, stp->st_file, fh, *flag))) + dp =alloc_init_deleg (sop->so_client, stp->st_file, fh, *flag); +if (dp ==NULL ) { + *flag =NFS4_OPEN_DELEGATE_NONE ;return ; + }locks_init_lock (&fl); fl.fl_lmops = &nfsd_lease_mng_ops; fl.fl_flags =FL_LEASE ;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: remove incorrect kfree from callback
In reply to NeilBrownRemove incorrect kfree.
### Diffstat output
./fs/nfsd/nfs4callback.c | 4 +--- 1 files changed, 1 insertion(+), 3 deletions(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +1 -3
@@ -561,7 +561,7 @@ nfsd4_cb_recall(struct nfs4_delegation * clnt = clp->cl_callback.cb_client; status =EIO ;if ((!atomic_read (&clp->cl_callback.cb_set)) || !clnt) - goto out_free; + goto out_fail; msg.rpc_argp = cbr; msg.rpc_resp = cbr;
@@ -580,7 +580,5 @@ out:return status; out_fail: status =nfserrno (status); - out_free: -kfree (cbr); goto out; }
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: remove unnecessary check in find_delegation_stateid
In reply to NeilBrownWe would have oopsed some time ago if either of these parameters were NULL.
### Diffstat output
./fs/nfsd/nfs4state.c | 2 -- 1 files changed, 2 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +0 -2
@@ -2450,8 +2450,6 @@ find_delegation_stateid(struct inode *in stid->si_boot, stid->si_stateownerid, stid->si_fileid, stid->si_generation); -if (!ino || !stid) -return NULL ; st_id = stid->si_stateownerid; fi_hashval =file_hashval (ino);if (find_file (fi_hashval, ino, &fp)) {
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 replace schedule_timeout() with msleep()
In reply to NeilBrownUse msleep() instead of schedule_timeout() to guarantee the task delays as expected.
### Diffstat output
./fs/nfsd/vfs.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/nfsd/vfs.c renamed from fs/nfsd/vfs.c~current~ +2 -2
@@ -36,6 +36,7 @@#include <linux/module.h> #include <linux/namei.h> #include <linux/vfs.h> +#include <linux/delay.h> #include <linux/sunrpc/svc.h> #include <linux/nfsd/nfsd.h> #ifdef CONFIG_NFSD_V3
@@ -969,8 +970,7 @@ nfsd_write(struct svc_rqst *rqstp, strucif (atomic_read (&inode->i_writecount) >1 || (last_ino == inode->i_ino && last_dev == inode->i_sb->s_dev)) {dprintk ("nfsd: write defer %d\n" , current->pid); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout ((HZ +99 )/100 ); +msleep (10 );dprintk ("nfsd: write resume %d\n" , current->pid); }
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: simplify verify_clientid
In reply to NeilBrownSimplify verify_clientid out of existance.
### Diffstat output
./fs/nfsd/nfs4state.c | 18 ++---------------- 1 files changed, 2 insertions(+), 16 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +2 -16
@@ -1247,21 +1247,6 @@ find_openstateowner_str(unsigned int hasreturn 0 ; } -/* see if clientid is in confirmed hash table */ -static int -verify_clientid (struct nfs4_client **client,clientid_t *clid) { - -struct nfs4_client *clp; - - clp =find_confirmed_client (clid); -if (clp) { - *client = clp; -return 1 ; - } - *client =NULL ; -return 0 ; -} -/* search file_hashtbl[] for file */ static int find_file (unsigned int hashval,struct inode *ino,struct nfs4_file **fp) {
@@ -1514,7 +1499,8 @@ nfsd4_process_open1(struct nfsd4_open *o* client's lease expiring. */ status = nfserr_expired; -if (!verify_clientid (&clp, clientid)) + clp =find_confirmed_client (clientid); +if (clp ==NULL ) goto out; } status = nfserr_resource;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: don't allow unconfirmed renew
In reply to NeilBrownDon't bother searching for unconfirmed clients when handling RENEW; a client is pretty sick if it's trying to renew state it hasn't even finished acquiring yet.
### Diffstat output
./fs/nfsd/nfs4state.c | 5 ----- 1 files changed, 5 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +0 -5
@@ -1815,11 +1815,6 @@ nfsd4_renew(clientid_t *clid)renew_client (clp); goto out; } - clp =find_unconfirmed_client (clid); -if (clp) { -renew_client (clp); - goto out; - }/* * Couldn't find an nfs4_client for this clientid. * Presumably this is because the client took too long to
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: simplify find_openstateowner_str
In reply to NeilBrownThere's no need to return duplicate information through the return value and an argument. Other minor cleanup.
### Diffstat output
./fs/nfsd/nfs4state.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +12 -12
@@ -1233,18 +1233,16 @@ cmp_owner_str(struct nfs4_stateowner *so (sop->so_client->cl_clientid.cl_id == clid->cl_id)); } -/* search ownerstr_hashtbl[] for owner */ -static int -find_openstateowner_str (unsigned int hashval,struct nfsd4_open *open,struct nfs4_stateowner **op) { -struct nfs4_stateowner *local =NULL ; +static struct nfs4_stateowner * +find_openstateowner_str (unsigned int hashval,struct nfsd4_open *open) +{ +struct nfs4_stateowner *so =NULL ; -list_for_each_entry (local, &ownerstr_hashtbl[hashval], so_strhash) { -if (!cmp_owner_str (local, &open->op_owner, &open->op_clientid)) -continue ; - *op = local; -return (1 ); +list_for_each_entry (so, &ownerstr_hashtbl[hashval], so_strhash) { +if (cmp_owner_str (so, &open->op_owner, &open->op_clientid)) +return so; } -return 0 ; +return NULL ; }/* search file_hashtbl[] for file */
@@ -1461,7 +1459,8 @@ nfsd4_process_open1(struct nfsd4_open *oreturn nfserr_stale_clientid; strhashval =ownerstr_hashval (clientid->cl_id, open->op_owner); -if (find_openstateowner_str (strhashval, open, &sop)) { + sop =find_openstateowner_str (strhashval, open); +if (sop) { open->op_stateowner = sop;/* check for replay */ if (open->op_seqid == sop->so_seqid){
@@ -1504,7 +1503,8 @@ nfsd4_process_open1(struct nfsd4_open *o goto out; } status = nfserr_resource; -if (!(sop =alloc_init_open_stateowner (strhashval, clp, open))) + sop =alloc_init_open_stateowner (strhashval, clp, open); +if (sop ==NULL ) goto out; open->op_stateowner = sop; renew:
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 nfsd4: eliminate unnecessary remove_lease
In reply to NeilBrownGet rid of remove_lease, use setlease() with F_UNLCK
### Diffstat output
./fs/locks.c | 20 +------------------- ./fs/nfsd/nfs4state.c | 3 +-- ./include/linux/fs.h | 1 - 3 files changed, 2 insertions(+), 22 deletions(-)
fs/locks.c renamed from fs/locks.c~current~ +1 -19
@@ -406,7 +406,7 @@ static void lease_release_private_callba fl->fl_file->f_owner.signum =0 ; } -static int lease_mylease_callback (struct file_lock *fl,struct file_lock *try) +int lease_mylease_callback (struct file_lock *fl,struct file_lock *try) {return fl->fl_file == try->fl_file; }
@@ -1099,24 +1099,6 @@ static void time_out_leases(struct inode } } -/** -* remove_lease - let time_out_leases remove the lease. -* @@file_lock: the lease to remove -*/ -void remove_lease (struct file_lock *fl) -{ -lock_kernel (); -if (!fl || !IS_LEASE (fl)) - goto out; - fl->fl_type =F_UNLCK |F_INPROGRESS ; - fl->fl_break_time = jiffies -10 ; -time_out_leases (fl->fl_file->f_dentry->d_inode); -out: -unlock_kernel (); -} - -EXPORT_SYMBOL (remove_lease); -/** * __break_lease - revoke all outstanding leases on file * @inode: the inode of the file to return
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +1 -2
@@ -194,7 +194,7 @@ nfs4_close_delegation(struct nfs4_delega dp->dl_vfs_file =NULL ;/* The following nfsd_close may not actually close the file, * but we want to remove the lease in any case. */ -remove_lease (dp->dl_flock); +setlease (filp,F_UNLCK , &dp->dl_flock);nfsd_close (filp); vfsclose++; }
@@ -1438,7 +1438,6 @@ struct lock_manager_operations nfsd_leas }; -/* * nfsd4_process_open1() * lookup stateowner.
include/linux/fs.h renamed from include/linux/fs.h~current~ +0 -1
@@ -723,7 +723,6 @@ extern int __break_lease(struct inode *iextern void lease_get_mtime (struct inode *,struct timespec *time);extern int setlease (struct file *,long ,struct file_lock **);extern int lease_modify (struct file_lock **,int ); -extern void remove_lease (struct file_lock *);extern int lock_may_read (struct inode *,loff_t start,unsigned long count);extern int lock_may_write (struct inode *,loff_t start,unsigned long count);extern void steal_locks (fl_owner_t from);
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 2 lines · NeilBrown
54 (!!) patches for knfsd. Mostly nfsv4 related from Bruce Fields and co.
Fun, I'm up to 944 patches.
I assume that nfsv4 is still "experimental", so we can scoot these in fairly promptly?
There were a few rejects against things in Linus's tree now, or something. I fixed them up. I'll try to do another -mm 24 hours hence - please check that everything landed OK.
I can tell you right now that the compiler will get huffy about this:
-void static inline nfs4_state_init(void){}
+int static inline nfs4_state_init(void){}
I'll stick a `return 0;' in there...
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 8 lines · On Tuesday March 8, [email protected] wrote:
Quoted 2 lines · NeilBrown
54 (!!) patches for knfsd. Mostly nfsv4 related from Bruce Fields and co.
Fun, I'm up to 944 patches.
I assume that nfsv4 is still "experimental", so we can scoot these in fairly promptly?
Yes.
Quoted 4 lines
There were a few rejects against things in Linus's tree now, or something. I fixed them up. I'll try to do another -mm 24 hours hence - please check that everything landed OK.
I checked. It all looks fine.
Quoted 9 lines
I can tell you right now that the compiler will get huffy about this:
(quoted diff) +1
-1-void static inline nfs4_state_init(void){} +int static inline nfs4_state_init(void){}I'll stick a `return 0;' in there...
:-) Thanks.
NeilBrown
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs