summaryrefslogtreecommitdiff
path: root/hw/9pfs/cofile.c
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-05-18 15:40:57 +0530
committerAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-08-25 20:16:41 +0530
commit7a46274529c2a1866e4344b4385739db674d6a35 (patch)
treefc525a06dc10ee2edb81f5c7f4f1b5d24ab37f95 /hw/9pfs/cofile.c
parent84dfb926e508aeedd5088a4f029464bf2d5b3791 (diff)
downloadqemu-7a46274529c2a1866e4344b4385739db674d6a35.tar.gz
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>
Diffstat (limited to 'hw/9pfs/cofile.c')
-rw-r--r--hw/9pfs/cofile.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/hw/9pfs/cofile.c b/hw/9pfs/cofile.c
index e388146422..0caf1e3cee 100644
--- a/hw/9pfs/cofile.c
+++ b/hw/9pfs/cofile.c
@@ -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;
}