hw/9pfs: Avoid unnecessary get_fid in v9fs_clunk

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
This commit is contained in:
Aneesh Kumar K.V 2011-08-02 11:36:24 +05:30
parent 532decb715
commit ce421a1961
1 changed files with 10 additions and 10 deletions

View File

@ -417,7 +417,7 @@ static void put_fid(V9fsState *s, V9fsFidState *fidp)
} }
} }
static int clunk_fid(V9fsState *s, int32_t fid) static V9fsFidState *clunk_fid(V9fsState *s, int32_t fid)
{ {
V9fsFidState **fidpp, *fidp; V9fsFidState **fidpp, *fidp;
@ -426,14 +426,13 @@ static int clunk_fid(V9fsState *s, int32_t fid)
break; break;
} }
} }
if (*fidpp == NULL) { if (*fidpp == NULL) {
return -ENOENT; return NULL;
} }
fidp = *fidpp; fidp = *fidpp;
*fidpp = fidp->next; *fidpp = fidp->next;
fidp->clunked = 1; fidp->clunked = 1;
return 0; return fidp;
} }
void v9fs_reclaim_fd(V9fsState *s) void v9fs_reclaim_fd(V9fsState *s)
@ -1700,17 +1699,18 @@ static void v9fs_clunk(void *opaque)
pdu_unmarshal(pdu, offset, "d", &fid); pdu_unmarshal(pdu, offset, "d", &fid);
fidp = get_fid(s, fid); fidp = clunk_fid(s, fid);
if (fidp == NULL) { if (fidp == NULL) {
err = -ENOENT; err = -ENOENT;
goto out_nofid; goto out_nofid;
} }
err = clunk_fid(s, fidp->fid); /*
if (err < 0) { * Bump the ref so that put_fid will
goto out; * free the fid.
} */
fidp->ref++;
err = offset; err = offset;
out:
put_fid(s, fidp); put_fid(s, fidp);
out_nofid: out_nofid:
complete_pdu(s, pdu, err); complete_pdu(s, pdu, err);