V9fsFidState *f;
V9fsState *s = pdu->s;
- for (f = s->fid_list; f; f = f->next) {
+ QSIMPLEQ_FOREACH(f, &s->fid_list, next) {
BUG_ON(f->clunked);
if (f->fid == fid) {
/*
{
V9fsFidState *f;
- for (f = s->fid_list; f; f = f->next) {
+ QSIMPLEQ_FOREACH(f, &s->fid_list, next) {
/* If fid is already there return NULL */
BUG_ON(f->clunked);
if (f->fid == fid) {
* reclaim won't close the file descriptor
*/
f->flags |= FID_REFERENCED;
- f->next = s->fid_list;
- s->fid_list = f;
+ QSIMPLEQ_INSERT_HEAD(&s->fid_list, f, next);
v9fs_readdir_init(s->proto_version, &f->fs.dir);
v9fs_readdir_init(s->proto_version, &f->fs_reclaim.dir);
static V9fsFidState *clunk_fid(V9fsState *s, int32_t fid)
{
- V9fsFidState **fidpp, *fidp;
+ V9fsFidState *fidp;
- for (fidpp = &s->fid_list; *fidpp; fidpp = &(*fidpp)->next) {
- if ((*fidpp)->fid == fid) {
- break;
+ QSIMPLEQ_FOREACH(fidp, &s->fid_list, next) {
+ if (fidp->fid == fid) {
+ QSIMPLEQ_REMOVE(&s->fid_list, fidp, V9fsFidState, next);
+ fidp->clunked = true;
+ return fidp;
}
}
- if (*fidpp == NULL) {
- return NULL;
- }
- fidp = *fidpp;
- *fidpp = fidp->next;
- fidp->clunked = true;
- return fidp;
+ return NULL;
}
void coroutine_fn v9fs_reclaim_fd(V9fsPDU *pdu)
V9fsState *s = pdu->s;
V9fsFidState *f, *reclaim_list = NULL;
- for (f = s->fid_list; f; f = f->next) {
+ QSIMPLEQ_FOREACH(f, &s->fid_list, next) {
/*
* Unlink fids cannot be reclaimed. Check
* for them and skip them. Also skip fids
V9fsFidState *fidp;
again:
- for (fidp = s->fid_list; fidp; fidp = fidp->next) {
+ QSIMPLEQ_FOREACH(fidp, &s->fid_list, next) {
if (fidp->path.size != path->size) {
continue;
}
V9fsFidState *fidp;
/* Free all fids */
- while (s->fid_list) {
+ while (!QSIMPLEQ_EMPTY(&s->fid_list)) {
/* Get fid */
- fidp = s->fid_list;
+ fidp = QSIMPLEQ_FIRST(&s->fid_list);
fidp->ref++;
/* Clunk fid */
- s->fid_list = fidp->next;
+ QSIMPLEQ_REMOVE(&s->fid_list, fidp, V9fsFidState, next);
fidp->clunked = true;
put_fid(pdu, fidp);
* Fixup fid's pointing to the old name to
* start pointing to the new name
*/
- for (tfidp = s->fid_list; tfidp; tfidp = tfidp->next) {
+ QSIMPLEQ_FOREACH(tfidp, &s->fid_list, next) {
if (v9fs_path_is_ancestor(&fidp->path, &tfidp->path)) {
/* replace the name */
v9fs_fix_path(&tfidp->path, &new_path, strlen(fidp->path.data));
* Fixup fid's pointing to the old name to
* start pointing to the new name
*/
- for (tfidp = s->fid_list; tfidp; tfidp = tfidp->next) {
+ QSIMPLEQ_FOREACH(tfidp, &s->fid_list, next) {
if (v9fs_path_is_ancestor(&oldpath, &tfidp->path)) {
/* replace the name */
v9fs_fix_path(&tfidp->path, &newpath, strlen(oldpath.data));
s->ctx.fmode = fse->fmode;
s->ctx.dmode = fse->dmode;
- s->fid_list = NULL;
+ QSIMPLEQ_INIT(&s->fid_list);
qemu_co_rwlock_init(&s->rename_lock);
if (s->ops->init(&s->ctx, errp) < 0) {