#include <linux/dcache.h>
#include <linux/namei.h>
#include <linux/fs.h>
+#include <sys/kmem.h>
+#include <sys/mutex.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/uio.h>
VBAD = 11
} vtype_t;
-typedef struct vnode {
- struct file *v_fp;
- vtype_t v_type;
-} vnode_t;
-
typedef struct vattr {
enum vtype va_type; /* vnode type */
u_int va_mask; /* attribute bit-mask */
size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */
} vsecattr_t;
+typedef struct vnode {
+ struct file *v_fp;
+ kmutex_t v_lock; /* protects vnode fields */
+ uint_t v_flag; /* vnode flags (see below) */
+ uint_t v_count; /* reference count */
+ void *v_data; /* private data for fs */
+ struct vfs *v_vfsp; /* ptr to containing VFS */
+ struct stdata *v_stream; /* associated stream */
+ enum vtype v_type; /* vnode type */
+ dev_t v_rdev; /* device (VCHR, VBLK) */
+} vnode_t;
+
+extern vnode_t *vn_alloc(int flag);
+void vn_free(vnode_t *vp);
extern int vn_open(const char *path, uio_seg_t seg, int flags, int mode,
vnode_t **vpp, int x1, void *x2);
extern int vn_openat(const char *path, uio_seg_t seg, int flags, int mode,
extern int vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4);
extern int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4);
+int vn_init(void);
+void vn_fini(void);
+
static __inline__ int
vn_rele(vnode_t *vp)
{
void *rootdir = NULL;
EXPORT_SYMBOL(rootdir);
+kmem_cache_t *vn_cache;
+
static vtype_t
vn_get_sol_type(umode_t mode)
{
return VNON;
} /* vn_get_sol_type() */
+vnode_t *
+vn_alloc(int flag)
+{
+ vnode_t *vp;
+
+ vp = kmem_cache_alloc(vn_cache, flag);
+
+ if (vp != NULL) {
+ vp->v_fp = NULL;
+ vp->v_type = 0;
+ }
+
+ return (vp);
+} /* vn_alloc() */
+EXPORT_SYMBOL(vn_alloc);
+
+void
+vn_free(vnode_t *vp)
+{
+ kmem_cache_free(vn_cache, vp);
+} /* vn_free() */
+EXPORT_SYMBOL(vn_free);
+
int
-vn_open(const char *path, int seg, int flags, int mode,
+vn_open(const char *path, uio_seg_t seg, int flags, int mode,
vnode_t **vpp, int x1, void *x2)
{
struct file *fp;
return rc;
}
- vp = kmalloc(sizeof(vnode_t), GFP_ATOMIC);
+ vp = vn_alloc(KM_SLEEP);
if (!vp) {
filp_close(fp, 0);
return -ENOMEM;
EXPORT_SYMBOL(vn_open);
int
-vn_openat(const char *path, int seg, int flags, int mode,
+vn_openat(const char *path, uio_seg_t seg, int flags, int mode,
vnode_t **vpp, int x1, void *x2, vnode_t *vp, int fd)
{
char *realpath;
int
vn_rdwr(uio_rw_t uio, vnode_t *vp, void *addr, ssize_t len, offset_t off,
- int seg, int x1, rlim64_t x2, void *x3, ssize_t *residp)
+ uio_seg_t seg, int x1, rlim64_t x2, void *x3, ssize_t *residp)
{
loff_t offset;
mm_segment_t saved_fs;
BUG_ON(!vp->v_fp);
rc = filp_close(vp->v_fp, 0);
- kfree(vp);
+ vn_free(vp);
return rc;
} /* vn_close() */
/* Modified do_unlinkat() from linux/fs/namei.c, only uses exported symbols */
int
-vn_remove(const char *path, int seg, int flags)
+vn_remove(const char *path, uio_seg_t seg, int flags)
{
struct dentry *dentry;
struct nameidata nd;
return file_fsync(vp->v_fp, vp->v_fp->f_dentry, datasync);
} /* vn_fsync() */
EXPORT_SYMBOL(vn_fsync);
+
+static int
+vn_cache_constructor(void *buf, void *cdrarg, int kmflags)
+{
+ struct vnode *vp = buf;
+
+ mutex_init(&vp->v_lock, NULL, MUTEX_DEFAULT, NULL);
+
+ return (0);
+} /* vn_cache_constructor() */
+
+static void
+vn_cache_destructor(void *buf, void *cdrarg)
+{
+ struct vnode *vp = buf;
+
+ mutex_destroy(&vp->v_lock);
+} /* vn_cache_destructor() */
+
+int
+vn_init(void)
+{
+ vn_cache = kmem_cache_create("vn_cache", sizeof(struct vnode), 64,
+ vn_cache_constructor, vn_cache_destructor,
+ NULL, NULL, NULL, 0);
+ return 0;
+} /* vn_init() */
+
+void
+vn_fini(void)
+{
+ kmem_cache_destroy(vn_cache);
+} /* vn_fini() */