nfsv4 client: factor loop contents out into a separate function
Commit fdc9b2d50f
replaced a couple of while loops with LIST_FOREACH()
loops. This patch factors the body of that loop out into a separate
function called nfscl_checkown().
This prepares the code for future changes to use a hash table of
lists for open searches via file handle.
This patch should not result in a semantics change.
MFC after: 2 weeks
This commit is contained in:
parent
b43fe9eb4b
commit
4e6c2a1ee9
@ -102,6 +102,9 @@ static int nfscl_delegcnt = 0;
|
||||
static int nfscl_layoutcnt = 0;
|
||||
static int nfscl_getopen(struct nfsclownerhead *, u_int8_t *, int, u_int8_t *,
|
||||
u_int8_t *, u_int32_t, struct nfscllockowner **, struct nfsclopen **);
|
||||
static bool nfscl_checkown(struct nfsclowner *, struct nfsclopen *, uint8_t *,
|
||||
uint8_t *, struct nfscllockowner **, struct nfsclopen **,
|
||||
struct nfsclopen **);
|
||||
static void nfscl_clrelease(struct nfsclclient *);
|
||||
static void nfscl_cleanclient(struct nfsclclient *);
|
||||
static void nfscl_expireclient(struct nfsclclient *, struct nfsmount *,
|
||||
@ -652,7 +655,6 @@ nfscl_getopen(struct nfsclownerhead *ohp, u_int8_t *nfhp, int fhlen,
|
||||
{
|
||||
struct nfsclowner *owp;
|
||||
struct nfsclopen *op, *rop, *rop2;
|
||||
struct nfscllockowner *lp;
|
||||
bool keep_looping;
|
||||
|
||||
if (lpp != NULL)
|
||||
@ -676,30 +678,9 @@ nfscl_getopen(struct nfsclownerhead *ohp, u_int8_t *nfhp, int fhlen,
|
||||
LIST_FOREACH(op, &owp->nfsow_open, nfso_list) {
|
||||
if (op->nfso_fhlen == fhlen &&
|
||||
!NFSBCMP(op->nfso_fh, nfhp, fhlen)
|
||||
&& (op->nfso_mode & mode) == mode) {
|
||||
if (lpp != NULL) {
|
||||
/* Now look for a matching lockowner. */
|
||||
LIST_FOREACH(lp, &op->nfso_lock,
|
||||
nfsl_list) {
|
||||
if (!NFSBCMP(lp->nfsl_owner,
|
||||
lockown,
|
||||
NFSV4CL_LOCKNAMELEN)) {
|
||||
*lpp = lp;
|
||||
rop = op;
|
||||
keep_looping = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rop == NULL && !NFSBCMP(owp->nfsow_owner,
|
||||
openown, NFSV4CL_LOCKNAMELEN)) {
|
||||
rop = op;
|
||||
if (lpp == NULL)
|
||||
keep_looping = false;
|
||||
}
|
||||
if (rop2 == NULL)
|
||||
rop2 = op;
|
||||
}
|
||||
&& (op->nfso_mode & mode) == mode)
|
||||
keep_looping = nfscl_checkown(owp, op, openown,
|
||||
lockown, lpp, &rop, &rop2);
|
||||
if (!keep_looping)
|
||||
break;
|
||||
}
|
||||
@ -714,6 +695,38 @@ nfscl_getopen(struct nfsclownerhead *ohp, u_int8_t *nfhp, int fhlen,
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Check for an owner match. */
|
||||
static bool
|
||||
nfscl_checkown(struct nfsclowner *owp, struct nfsclopen *op, uint8_t *openown,
|
||||
uint8_t *lockown, struct nfscllockowner **lpp, struct nfsclopen **ropp,
|
||||
struct nfsclopen **ropp2)
|
||||
{
|
||||
struct nfscllockowner *lp;
|
||||
bool keep_looping;
|
||||
|
||||
keep_looping = true;
|
||||
if (lpp != NULL) {
|
||||
/* Now look for a matching lockowner. */
|
||||
LIST_FOREACH(lp, &op->nfso_lock, nfsl_list) {
|
||||
if (!NFSBCMP(lp->nfsl_owner, lockown,
|
||||
NFSV4CL_LOCKNAMELEN)) {
|
||||
*lpp = lp;
|
||||
*ropp = op;
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (*ropp == NULL && !NFSBCMP(owp->nfsow_owner, openown,
|
||||
NFSV4CL_LOCKNAMELEN)) {
|
||||
*ropp = op;
|
||||
if (lpp == NULL)
|
||||
keep_looping = false;
|
||||
}
|
||||
if (*ropp2 == NULL)
|
||||
*ropp2 = op;
|
||||
return (keep_looping);
|
||||
}
|
||||
|
||||
/*
|
||||
* Release use of an open owner. Called when open operations are done
|
||||
* with the open owner.
|
||||
|
Loading…
Reference in New Issue
Block a user