Merge remote-tracking branch 'aneesh/for-upstream-3' into staging

This commit is contained in:
Anthony Liguori 2011-09-08 08:52:59 -05:00
commit 63236c15e9
6 changed files with 445 additions and 103 deletions

View File

@ -97,15 +97,19 @@ int v9fs_co_opendir(V9fsState *s, V9fsFidState *fidp)
err = 0;
}
});
if (!err) {
total_open_fd++;
if (total_open_fd > open_fd_hw) {
v9fs_reclaim_fd(s);
}
}
return err;
}
int v9fs_co_closedir(V9fsState *s, V9fsFidState *fidp)
int v9fs_co_closedir(V9fsState *s, DIR *dir)
{
int err;
DIR *dir;
dir = fidp->fs.dir;
v9fs_co_run_in_worker(
{
err = s->ops->closedir(&s->ctx, dir);
@ -113,5 +117,8 @@ int v9fs_co_closedir(V9fsState *s, V9fsFidState *fidp)
err = -errno;
}
});
if (!err) {
total_open_fd--;
}
return err;
}

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;
}

View File

@ -83,8 +83,8 @@ extern int v9fs_co_open2(V9fsState *, V9fsFidState *, char *, gid_t, int, int);
extern int v9fs_co_lsetxattr(V9fsState *, V9fsString *, V9fsString *,
void *, size_t, int);
extern int v9fs_co_lremovexattr(V9fsState *, V9fsString *, V9fsString *);
extern int v9fs_co_closedir(V9fsState *, V9fsFidState *);
extern int v9fs_co_close(V9fsState *, V9fsFidState *);
extern int v9fs_co_closedir(V9fsState *, DIR *);
extern int v9fs_co_close(V9fsState *, int);
extern int v9fs_co_fsync(V9fsState *, V9fsFidState *, int);
extern int v9fs_co_symlink(V9fsState *, V9fsFidState *, const char *,
const char *, gid_t);

View File

@ -130,6 +130,7 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
s->config_size = sizeof(struct virtio_9p_config) +
s->tag_len;
s->vdev.get_config = virtio_9p_get_config;
s->fid_list = NULL;
if (v9fs_init_worker_threads() < 0) {
fprintf(stderr, "worker thread initialization failed\n");
@ -171,6 +172,7 @@ static PCIDeviceInfo virtio_9p_info = {
static void virtio_9p_register_devices(void)
{
pci_qdev_register(&virtio_9p_info);
virtio_9p_set_fd_limit();
}
device_init(virtio_9p_register_devices)

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@
#include <dirent.h>
#include <sys/time.h>
#include <utime.h>
#include <sys/resource.h>
#include "hw/virtio.h"
#include "fsdev/file-op-9p.h"
@ -101,6 +102,9 @@ enum p9_proto_version {
#define P9_NOTAG (u16)(~0)
#define P9_NOFID (u32)(~0)
#define P9_MAXWELEM 16
#define FID_REFERENCED 0x1
#define FID_NON_RECLAIMABLE 0x2
static inline const char *rpath(FsContext *ctx, const char *path, char *buffer)
{
snprintf(buffer, PATH_MAX, "%s/%s", ctx->fs_root, path);
@ -198,12 +202,21 @@ struct V9fsFidState
int32_t fid;
V9fsString path;
union {
int fd;
DIR *dir;
V9fsXattr xattr;
int fd;
DIR *dir;
V9fsXattr xattr;
} fs;
union {
int fd;
DIR *dir;
} fs_reclaim;
int flags;
int open_flags;
uid_t uid;
int ref;
int clunked;
V9fsFidState *next;
V9fsFidState *rclm_lst;
};
typedef struct V9fsState
@ -352,6 +365,9 @@ typedef struct V9fsGetlock
V9fsString client_id;
} V9fsGetlock;
extern int open_fd_hw;
extern int total_open_fd;
size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
size_t offset, size_t size, int pack);
@ -362,4 +378,6 @@ static inline size_t do_pdu_unpack(void *dst, struct iovec *sg, int sg_count,
}
extern void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq);
extern void virtio_9p_set_fd_limit(void);
extern void v9fs_reclaim_fd(V9fsState *s);
#endif