hw/9pfs: Add file descriptor reclaim support

[M. Mohan Kumar <mohan@in.ibm.com> removed some unused variables]

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
This commit is contained in:
Aneesh Kumar K.V 2011-05-18 15:40:57 +05:30
parent 84dfb926e5
commit 7a46274529
6 changed files with 223 additions and 14 deletions

View file

@ -58,6 +58,12 @@ int v9fs_co_open(V9fsState *s, V9fsFidState *fidp, int flags)
err = 0;
}
});
if (!err) {
total_open_fd++;
if (total_open_fd > open_fd_hw) {
v9fs_reclaim_fd(s);
}
}
return err;
}
@ -79,15 +85,19 @@ int v9fs_co_open2(V9fsState *s, V9fsFidState *fidp, char *fullname, gid_t gid,
err = -errno;
}
});
if (!err) {
total_open_fd++;
if (total_open_fd > open_fd_hw) {
v9fs_reclaim_fd(s);
}
}
return err;
}
int v9fs_co_close(V9fsState *s, V9fsFidState *fidp)
int v9fs_co_close(V9fsState *s, int fd)
{
int fd;
int err;
fd = fidp->fs.fd;
v9fs_co_run_in_worker(
{
err = s->ops->close(&s->ctx, fd);
@ -95,6 +105,9 @@ int v9fs_co_close(V9fsState *s, V9fsFidState *fidp)
err = -errno;
}
});
if (!err) {
total_open_fd--;
}
return err;
}