9pfs: Convert reclaim list to QSLIST
Use QSLIST instead of open-coding for a slightly improved readability. No behavioral change. Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Message-Id: <20210122143514.215780-1-groug@kaod.org> Signed-off-by: Greg Kurz <groug@kaod.org>
This commit is contained in:
parent
20b7f45b22
commit
81f9766b7a
17
hw/9pfs/9p.c
17
hw/9pfs/9p.c
@ -416,7 +416,9 @@ void coroutine_fn v9fs_reclaim_fd(V9fsPDU *pdu)
|
|||||||
{
|
{
|
||||||
int reclaim_count = 0;
|
int reclaim_count = 0;
|
||||||
V9fsState *s = pdu->s;
|
V9fsState *s = pdu->s;
|
||||||
V9fsFidState *f, *reclaim_list = NULL;
|
V9fsFidState *f;
|
||||||
|
QSLIST_HEAD(, V9fsFidState) reclaim_list =
|
||||||
|
QSLIST_HEAD_INITIALIZER(reclaim_list);
|
||||||
|
|
||||||
QSIMPLEQ_FOREACH(f, &s->fid_list, next) {
|
QSIMPLEQ_FOREACH(f, &s->fid_list, next) {
|
||||||
/*
|
/*
|
||||||
@ -448,8 +450,7 @@ void coroutine_fn v9fs_reclaim_fd(V9fsPDU *pdu)
|
|||||||
* a clunk request won't free this fid
|
* a clunk request won't free this fid
|
||||||
*/
|
*/
|
||||||
f->ref++;
|
f->ref++;
|
||||||
f->rclm_lst = reclaim_list;
|
QSLIST_INSERT_HEAD(&reclaim_list, f, reclaim_next);
|
||||||
reclaim_list = f;
|
|
||||||
f->fs_reclaim.fd = f->fs.fd;
|
f->fs_reclaim.fd = f->fs.fd;
|
||||||
f->fs.fd = -1;
|
f->fs.fd = -1;
|
||||||
reclaim_count++;
|
reclaim_count++;
|
||||||
@ -461,8 +462,7 @@ void coroutine_fn v9fs_reclaim_fd(V9fsPDU *pdu)
|
|||||||
* a clunk request won't free this fid
|
* a clunk request won't free this fid
|
||||||
*/
|
*/
|
||||||
f->ref++;
|
f->ref++;
|
||||||
f->rclm_lst = reclaim_list;
|
QSLIST_INSERT_HEAD(&reclaim_list, f, reclaim_next);
|
||||||
reclaim_list = f;
|
|
||||||
f->fs_reclaim.dir.stream = f->fs.dir.stream;
|
f->fs_reclaim.dir.stream = f->fs.dir.stream;
|
||||||
f->fs.dir.stream = NULL;
|
f->fs.dir.stream = NULL;
|
||||||
reclaim_count++;
|
reclaim_count++;
|
||||||
@ -476,15 +476,14 @@ void coroutine_fn v9fs_reclaim_fd(V9fsPDU *pdu)
|
|||||||
* Now close the fid in reclaim list. Free them if they
|
* Now close the fid in reclaim list. Free them if they
|
||||||
* are already clunked.
|
* are already clunked.
|
||||||
*/
|
*/
|
||||||
while (reclaim_list) {
|
while (!QSLIST_EMPTY(&reclaim_list)) {
|
||||||
f = reclaim_list;
|
f = QSLIST_FIRST(&reclaim_list);
|
||||||
reclaim_list = f->rclm_lst;
|
QSLIST_REMOVE(&reclaim_list, f, V9fsFidState, reclaim_next);
|
||||||
if (f->fid_type == P9_FID_FILE) {
|
if (f->fid_type == P9_FID_FILE) {
|
||||||
v9fs_co_close(pdu, &f->fs_reclaim);
|
v9fs_co_close(pdu, &f->fs_reclaim);
|
||||||
} else if (f->fid_type == P9_FID_DIR) {
|
} else if (f->fid_type == P9_FID_DIR) {
|
||||||
v9fs_co_closedir(pdu, &f->fs_reclaim);
|
v9fs_co_closedir(pdu, &f->fs_reclaim);
|
||||||
}
|
}
|
||||||
f->rclm_lst = NULL;
|
|
||||||
/*
|
/*
|
||||||
* Now drop the fid reference, free it
|
* Now drop the fid reference, free it
|
||||||
* if clunked.
|
* if clunked.
|
||||||
|
@ -281,7 +281,7 @@ struct V9fsFidState {
|
|||||||
int ref;
|
int ref;
|
||||||
bool clunked;
|
bool clunked;
|
||||||
QSIMPLEQ_ENTRY(V9fsFidState) next;
|
QSIMPLEQ_ENTRY(V9fsFidState) next;
|
||||||
V9fsFidState *rclm_lst;
|
QSLIST_ENTRY(V9fsFidState) reclaim_next;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum AffixType_t {
|
typedef enum AffixType_t {
|
||||||
|
Loading…
Reference in New Issue
Block a user