nfsv4 client: replace while loops with LIST_FOREACH() loops
This patch replaces a couple of while() loops with LIST_FOREACH() loops. While here, declare a couple of variables "bool". I think LIST_FOREACH() is preferred and makes the code more readable. This also 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
befb0817bd
commit
fdc9b2d50f
@ -507,7 +507,8 @@ nfscl_getstateid(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t mode,
|
|||||||
struct nfsnode *np;
|
struct nfsnode *np;
|
||||||
struct nfsmount *nmp;
|
struct nfsmount *nmp;
|
||||||
u_int8_t own[NFSV4CL_LOCKNAMELEN];
|
u_int8_t own[NFSV4CL_LOCKNAMELEN];
|
||||||
int error, done;
|
int error;
|
||||||
|
bool done;
|
||||||
|
|
||||||
*lckpp = NULL;
|
*lckpp = NULL;
|
||||||
/*
|
/*
|
||||||
@ -596,9 +597,8 @@ nfscl_getstateid(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t mode,
|
|||||||
if (op == NULL) {
|
if (op == NULL) {
|
||||||
/* If not found, just look for any OpenOwner that will work. */
|
/* If not found, just look for any OpenOwner that will work. */
|
||||||
top = NULL;
|
top = NULL;
|
||||||
done = 0;
|
done = false;
|
||||||
owp = LIST_FIRST(&clp->nfsc_owner);
|
LIST_FOREACH(owp, &clp->nfsc_owner, nfsow_list) {
|
||||||
while (!done && owp != NULL) {
|
|
||||||
LIST_FOREACH(op, &owp->nfsow_open, nfso_list) {
|
LIST_FOREACH(op, &owp->nfsow_open, nfso_list) {
|
||||||
if (op->nfso_fhlen == fhlen &&
|
if (op->nfso_fhlen == fhlen &&
|
||||||
!NFSBCMP(op->nfso_fh, nfhp, fhlen)) {
|
!NFSBCMP(op->nfso_fh, nfhp, fhlen)) {
|
||||||
@ -607,13 +607,13 @@ nfscl_getstateid(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t mode,
|
|||||||
(mode & NFSV4OPEN_ACCESSREAD) != 0)
|
(mode & NFSV4OPEN_ACCESSREAD) != 0)
|
||||||
top = op;
|
top = op;
|
||||||
if ((mode & op->nfso_mode) == mode) {
|
if ((mode & op->nfso_mode) == mode) {
|
||||||
done = 1;
|
done = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!done)
|
if (done)
|
||||||
owp = LIST_NEXT(owp, nfsow_list);
|
break;
|
||||||
}
|
}
|
||||||
if (!done) {
|
if (!done) {
|
||||||
NFSCL_DEBUG(2, "openmode top=%p\n", top);
|
NFSCL_DEBUG(2, "openmode top=%p\n", top);
|
||||||
@ -653,7 +653,7 @@ nfscl_getopen(struct nfsclownerhead *ohp, u_int8_t *nfhp, int fhlen,
|
|||||||
struct nfsclowner *owp;
|
struct nfsclowner *owp;
|
||||||
struct nfsclopen *op, *rop, *rop2;
|
struct nfsclopen *op, *rop, *rop2;
|
||||||
struct nfscllockowner *lp;
|
struct nfscllockowner *lp;
|
||||||
int keep_looping;
|
bool keep_looping;
|
||||||
|
|
||||||
if (lpp != NULL)
|
if (lpp != NULL)
|
||||||
*lpp = NULL;
|
*lpp = NULL;
|
||||||
@ -669,13 +669,11 @@ nfscl_getopen(struct nfsclownerhead *ohp, u_int8_t *nfhp, int fhlen,
|
|||||||
*/
|
*/
|
||||||
rop = NULL;
|
rop = NULL;
|
||||||
rop2 = NULL;
|
rop2 = NULL;
|
||||||
keep_looping = 1;
|
keep_looping = true;
|
||||||
/* Search the client list */
|
/* Search the client list */
|
||||||
owp = LIST_FIRST(ohp);
|
LIST_FOREACH(owp, ohp, nfsow_list) {
|
||||||
while (owp != NULL && keep_looping != 0) {
|
|
||||||
/* and look for the correct open */
|
/* and look for the correct open */
|
||||||
op = LIST_FIRST(&owp->nfsow_open);
|
LIST_FOREACH(op, &owp->nfsow_open, nfso_list) {
|
||||||
while (op != NULL && keep_looping != 0) {
|
|
||||||
if (op->nfso_fhlen == fhlen &&
|
if (op->nfso_fhlen == fhlen &&
|
||||||
!NFSBCMP(op->nfso_fh, nfhp, fhlen)
|
!NFSBCMP(op->nfso_fh, nfhp, fhlen)
|
||||||
&& (op->nfso_mode & mode) == mode) {
|
&& (op->nfso_mode & mode) == mode) {
|
||||||
@ -688,7 +686,7 @@ nfscl_getopen(struct nfsclownerhead *ohp, u_int8_t *nfhp, int fhlen,
|
|||||||
NFSV4CL_LOCKNAMELEN)) {
|
NFSV4CL_LOCKNAMELEN)) {
|
||||||
*lpp = lp;
|
*lpp = lp;
|
||||||
rop = op;
|
rop = op;
|
||||||
keep_looping = 0;
|
keep_looping = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -697,14 +695,16 @@ nfscl_getopen(struct nfsclownerhead *ohp, u_int8_t *nfhp, int fhlen,
|
|||||||
openown, NFSV4CL_LOCKNAMELEN)) {
|
openown, NFSV4CL_LOCKNAMELEN)) {
|
||||||
rop = op;
|
rop = op;
|
||||||
if (lpp == NULL)
|
if (lpp == NULL)
|
||||||
keep_looping = 0;
|
keep_looping = false;
|
||||||
}
|
}
|
||||||
if (rop2 == NULL)
|
if (rop2 == NULL)
|
||||||
rop2 = op;
|
rop2 = op;
|
||||||
}
|
}
|
||||||
op = LIST_NEXT(op, nfso_list);
|
if (!keep_looping)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
owp = LIST_NEXT(owp, nfsow_list);
|
if (!keep_looping)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (rop == NULL)
|
if (rop == NULL)
|
||||||
rop = rop2;
|
rop = rop2;
|
||||||
|
Loading…
Reference in New Issue
Block a user