OSDN Git Service

9pfs: Improve unreclaim loop
authorGreg Kurz <groug@kaod.org>
Thu, 21 Jan 2021 18:15:10 +0000 (19:15 +0100)
committerGreg Kurz <groug@kaod.org>
Fri, 22 Jan 2021 14:17:19 +0000 (15:17 +0100)
commit20b7f45b22c3c00dc6f8bc73a66dffb6d436aa85
treea91323e882fbddb64f6a5299cabd142ccbb5aa53
parentfeabd6cf78ca3b57da2ce48e95b704e72147bf2c
9pfs: Improve unreclaim loop

If a fid was actually re-opened by v9fs_reopen_fid(), we re-traverse the
fid list from the head in case some other request created a fid that
needs to be marked unreclaimable as well (i.e. the client opened a new
handle on the path that is being unlinked). This is suboptimal since
most if not all fids that require it have likely been taken care of
already.

This is mostly the result of new fids being added to the head of the
list. Since the list is now a QSIMPLEQ, add new fids at the end instead
to avoid the need to rewind. Take a reference on the fid to ensure it
doesn't go away during v9fs_reopen_fid() and that it can be safely
passed to QSIMPLEQ_NEXT() afterwards. Since the associated put_fid()
can also yield, same is done with the next fid. So the logic here is
to get a reference on a fid and only put it back during the next
iteration after we could get a reference on the next fid.

Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Message-Id: <20210121181510.1459390-1-groug@kaod.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
hw/9pfs/9p.c