Commit 95402a16 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] knfsd: helper functions for deciding to grant a delegation.

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 0fe1a2ea
......@@ -1503,6 +1503,43 @@ nfsd4_process_open1(struct nfsd4_open *open)
return status;
}
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));
}
#define DONT_DELEGATE 8
/*
* 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;
int 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 (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 = DONT_DELEGATE;
}
}
return status;
}
static int
nfs4_check_open(struct nfs4_file *fp, struct nfs4_stateowner *sop, struct nfsd4_open *open, struct nfs4_stateid **stpp)
{
......
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