mirror of https://github.com/xemu-project/xemu.git
9pfs: split out fs driver core of v9fs_co_readdir()
The implementation of v9fs_co_readdir() has two parts: the outer part is executed by main I/O thread, whereas the inner part is executed by fs driver on a background I/O thread. Move the inner part to its own new, private function do_readdir(), so it can be shared by another upcoming new function. This is just a preparatory patch for the subsequent patch, with the purpose to avoid the next patch to clutter the overall diff. Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Reviewed-by: Greg Kurz <groug@kaod.org> Message-Id: <a426ee06e77584fa2d8253ce5d8bea519eb3ffd4.1596012787.git.qemu_oss@crudebyte.com> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
This commit is contained in:
parent
29c9d2ca80
commit
dd8151f4fe
|
@ -18,28 +18,38 @@
|
|||
#include "qemu/main-loop.h"
|
||||
#include "coth.h"
|
||||
|
||||
/*
|
||||
* Intended to be called from bottom-half (e.g. background I/O thread)
|
||||
* context.
|
||||
*/
|
||||
static int do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, struct dirent **dent)
|
||||
{
|
||||
int err = 0;
|
||||
V9fsState *s = pdu->s;
|
||||
struct dirent *entry;
|
||||
|
||||
errno = 0;
|
||||
entry = s->ops->readdir(&s->ctx, &fidp->fs);
|
||||
if (!entry && errno) {
|
||||
*dent = NULL;
|
||||
err = -errno;
|
||||
} else {
|
||||
*dent = entry;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
int coroutine_fn v9fs_co_readdir(V9fsPDU *pdu, V9fsFidState *fidp,
|
||||
struct dirent **dent)
|
||||
{
|
||||
int err;
|
||||
V9fsState *s = pdu->s;
|
||||
|
||||
if (v9fs_request_cancelled(pdu)) {
|
||||
return -EINTR;
|
||||
}
|
||||
v9fs_co_run_in_worker(
|
||||
{
|
||||
struct dirent *entry;
|
||||
|
||||
errno = 0;
|
||||
entry = s->ops->readdir(&s->ctx, &fidp->fs);
|
||||
if (!entry && errno) {
|
||||
err = -errno;
|
||||
} else {
|
||||
*dent = entry;
|
||||
err = 0;
|
||||
}
|
||||
});
|
||||
v9fs_co_run_in_worker({
|
||||
err = do_readdir(pdu, fidp, dent);
|
||||
});
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue