Commit 4477196c authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] knfsd: allocate and initialize the delegation structure.

Declare and initialize the recall_lru list.
Signed-off-by: default avatarAndy Adamson <andros@citi.umich.edu>
Signed-off-by: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1dcde038
......@@ -57,8 +57,9 @@ static u32 nfs4_reclaim_init = 0;
time_t boot_time;
static time_t grace_end = 0;
static u32 current_clientid = 1;
static u32 current_ownerid;
static u32 current_fileid;
static u32 current_ownerid = 1;
static u32 current_fileid = 1;
static u32 current_delegid = 1;
static u32 nfs4_init;
stateid_t zerostateid; /* bits all 0 */
stateid_t onestateid; /* bits all 1 */
......@@ -75,6 +76,8 @@ u32 free_sowner = 0;
u32 vfsopen = 0;
u32 vfsclose = 0;
u32 alloc_lsowner= 0;
u32 alloc_delegation= 0;
u32 free_delegation= 0;
/* forward declarations */
struct nfs4_stateid * find_stateid(stateid_t *stid, int flags);
......@@ -117,6 +120,50 @@ static void release_stateowner(struct nfs4_stateowner *sop);
static void release_stateid(struct nfs4_stateid *stp, int flags);
static void release_file(struct nfs4_file *fp);
/*
* Delegation state
*/
/* recall_lock protects the del_recall_lru */
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)
{
struct nfs4_delegation *dp;
dprintk("NFSD alloc_init_deleg\n");
if ((dp = kmalloc(sizeof(struct nfs4_delegation),
GFP_KERNEL)) == NULL)
return dp;
INIT_LIST_HEAD(&dp->dl_del_perfile);
INIT_LIST_HEAD(&dp->dl_del_perclnt);
INIT_LIST_HEAD(&dp->dl_recall_lru);
dp->dl_client = clp;
dp->dl_file = fp;
dp->dl_flock = NULL;
dp->dl_stp = NULL;
dp->dl_type = type;
dp->dl_recall.cbr_dp = NULL;
dp->dl_recall.cbr_ident = 0;
dp->dl_recall.cbr_trunc = 0;
dp->dl_stateid.si_boot = boot_time;
dp->dl_stateid.si_stateownerid = current_delegid++;
dp->dl_stateid.si_fileid = 0;
dp->dl_stateid.si_generation = 0;
dp->dl_fhlen = current_fh->fh_handle.fh_size;
memcpy(dp->dl_fhval, &current_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);
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++;
return dp;
}
/*
* SETCLIENTID state
......@@ -248,6 +295,7 @@ create_client(struct xdr_netobj name) {
INIT_LIST_HEAD(&clp->cl_idhash);
INIT_LIST_HEAD(&clp->cl_strhash);
INIT_LIST_HEAD(&clp->cl_perclient);
INIT_LIST_HEAD(&clp->cl_del_perclnt);
INIT_LIST_HEAD(&clp->cl_lru);
out:
return clp;
......@@ -824,6 +872,7 @@ alloc_init_file(unsigned int hashval, struct inode *ino) {
if ((fp = kmalloc(sizeof(struct nfs4_file),GFP_KERNEL))) {
INIT_LIST_HEAD(&fp->fi_hash);
INIT_LIST_HEAD(&fp->fi_perfile);
INIT_LIST_HEAD(&fp->fi_del_perfile);
list_add(&fp->fi_hash, &file_hashtbl[hashval]);
fp->fi_inode = igrab(ino);
fp->fi_id = current_fileid++;
......@@ -2738,6 +2787,8 @@ nfs4_state_init(void)
INIT_LIST_HEAD(&close_lru);
INIT_LIST_HEAD(&client_lru);
INIT_LIST_HEAD(&del_recall_lru);
spin_lock_init(&recall_lock);
boot_time = get_seconds();
grace_time = max(old_lease_time, lease_time);
if (reclaim_str_hashtbl_size == 0)
......@@ -2799,6 +2850,9 @@ __nfs4_state_shutdown(void)
alloc_sowner, alloc_lsowner, free_sowner);
dprintk("NFSD: vfsopen %d vfsclose %d\n",
vfsopen, vfsclose);
dprintk("NFSD: alloc_delegation %d free_delegation %d\n",
alloc_delegation, free_delegation);
}
void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment