]> git.proxmox.com Git - mirror_spl.git/commitdiff
Add missing headers
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Fri, 14 Mar 2008 00:04:01 +0000 (00:04 +0000)
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Fri, 14 Mar 2008 00:04:01 +0000 (00:04 +0000)
Rework vnodes to be based on the slab cache, just like on Solaris.

git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@45 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c

15 files changed:
FIXME
include/fs/fs_subr.h [new file with mode: 0644]
include/sys/file.h [new file with mode: 0644]
include/sys/mkdev.h [new file with mode: 0644]
include/sys/mntent.h [new file with mode: 0644]
include/sys/mode.h [new file with mode: 0644]
include/sys/pathname.h [new file with mode: 0644]
include/sys/unistd.h [new file with mode: 0644]
include/sys/vfs_opreg.h [new file with mode: 0644]
include/sys/vmsystm.h
include/sys/vnode.h
include/vm/anon.h
include/vm/pvn.h [new file with mode: 0644]
modules/spl/spl-generic.c
modules/spl/spl-vnode.c

diff --git a/FIXME b/FIXME
index 887616efbd612c408442c9e90c3809cd49b39683..0785df5f802afc7edc8f26f2d0d9a668912669cd 100644 (file)
--- a/FIXME
+++ b/FIXME
@@ -6,8 +6,6 @@ sys/dkio.h              - All borrowed from libsolcompat
 sys/dklabel.h          - All borrowed from libsolcompat
 sys/types32.h          - All borrowed from libsolcompat
 sys/isa_defs.h         - AlL borrowed from libsolcompat
-sys/u8_textprep.h      - AlL borrowed from libsolcompat
-sys/u8_textprep_data   - AlL borrowed from libsolcompat
 sys/acl.h              _ All borrowed from libsolcompat
 sys/acl_impl.h         _ All borrowed from libsolcompat
 
diff --git a/include/fs/fs_subr.h b/include/fs/fs_subr.h
new file mode 100644 (file)
index 0000000..2a73076
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _SPL_FS_FS_SUBR_H
+#define _SPL_FS_FS_SUBR_H
+
+#endif /* SPL_FS_FS_SUBR_H */
diff --git a/include/sys/file.h b/include/sys/file.h
new file mode 100644 (file)
index 0000000..63d6622
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _SPL_FILE_H
+#define _SPL_FILE_H
+
+#endif /* SPL_FILE_H */
diff --git a/include/sys/mkdev.h b/include/sys/mkdev.h
new file mode 100644 (file)
index 0000000..f92ad08
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _SPL_MKDEV_H
+#define _SPL_MKDEV_H
+
+#endif /* SPL_MKDEV_H */
diff --git a/include/sys/mntent.h b/include/sys/mntent.h
new file mode 100644 (file)
index 0000000..b124e34
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _SPL_MNTENT_H
+#define _SPL_MNTENT_H
+
+#endif /* SPL_MNTENT_H */
diff --git a/include/sys/mode.h b/include/sys/mode.h
new file mode 100644 (file)
index 0000000..7ca1b48
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _SPL_MODE_H
+#define _SPL_MODE_H
+
+#endif /* SPL_MODE_H */
diff --git a/include/sys/pathname.h b/include/sys/pathname.h
new file mode 100644 (file)
index 0000000..ffdf585
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef _SPL_PATHNAME_H
+#define _SPL_PATHNAME_H
+
+typedef struct pathname {
+       char    *pn_buf;                /* underlying storage */
+       char    *pn_path;               /* remaining pathname */
+       size_t  pn_pathlen;             /* remaining length */
+       size_t  pn_bufsize;             /* total size of pn_buf */
+} pathname_t;
+
+#endif /* SPL_PATHNAME_H */
diff --git a/include/sys/unistd.h b/include/sys/unistd.h
new file mode 100644 (file)
index 0000000..c6b298a
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _SPL_UNISTD_H
+#define _SPL_UNISTD_H
+
+#endif /* SPL_UNISTD_H */
diff --git a/include/sys/vfs_opreg.h b/include/sys/vfs_opreg.h
new file mode 100644 (file)
index 0000000..8f3f556
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _SPL_OPREG_H
+#define _SPL_OPREG_H
+
+#endif /* SPL_OPREG_H */
index bb23da965b5f1315fd36b98be46f52d840a80182..443c376c9ada20373e6f4a31734d787e419fd730 100644 (file)
@@ -2,6 +2,9 @@
 #define _SPL_VMSYSTM_H
 
 #include <linux/mm.h>
+#include <sys/types.h>
+
+extern vmem_t *zio_alloc_arena;                /* arena for zio caches */
 
 #define physmem                                num_physpages
 #define ptob(pages)                    (pages * PAGE_SIZE)
index 6a1ba0a25c41496bb23974b4e841407bdaffa6c7..3ec11abe26c970f290e7f192289633e82c9b2b91 100644 (file)
@@ -9,6 +9,8 @@
 #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>
@@ -72,11 +74,6 @@ typedef enum vtype {
        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 */
@@ -130,6 +127,20 @@ typedef struct vsecattr {
         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,
@@ -143,6 +154,9 @@ extern int vn_rename(const char *path1, const char *path2, int x1);
 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)
 {
index 81c585a6adbb9cdb03db22715f63957de8c0b352..0198e729e90714be8fbb98ef041477db3d977868 100644 (file)
@@ -1,4 +1,4 @@
-#ifndef _SPL_ANON_H
-#define _SPL_ANON_H
+#ifndef _SPL_VM_ANON_H
+#define _SPL_VM_ANON_H
 
-#endif /* SPL_ANON_H */
+#endif /* SPL_VM_ANON_H */
diff --git a/include/vm/pvn.h b/include/vm/pvn.h
new file mode 100644 (file)
index 0000000..e89ee17
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _SPL_VM_PVN_H
+#define _SPL_VM_PVN_H
+
+#endif /* SPL_VM_PVN_H */
index 52d06b827a5c3465dffb38cf03ac51e6850d50b3..cae4223f33bf362879b7eb6beb3db2281de859fb 100644 (file)
@@ -1,4 +1,6 @@
 #include <sys/sysmacros.h>
+#include <sys/vmsystm.h>
+#include <sys/vnode.h>
 #include "config.h"
 
 /*
@@ -11,6 +13,9 @@ EXPORT_SYMBOL(p0);
 char hw_serial[11];
 EXPORT_SYMBOL(hw_serial);
 
+vmem_t *zio_alloc_arena = NULL;
+EXPORT_SYMBOL(zio_alloc_arena);
+
 int
 highbit(unsigned long i)
 {
@@ -52,13 +57,21 @@ EXPORT_SYMBOL(ddi_strtoul);
 
 static int __init spl_init(void)
 {
+       int rc;
+
+       rc = vn_init();
+       if (rc)
+               return rc;
+
        strcpy(hw_serial, "007f0100"); /* loopback */
         printk(KERN_INFO "spl: Loaded Solaris Porting Layer v%s\n", VERSION);
+
        return 0;
 }
 
 static void spl_fini(void)
 {
+       vn_fini();
        return;
 }
 
index 0ec53e73ed477d2f9d575d2e93d218f1343bb6ac..5776de6ddacbdd1031ce6a5f99f80b28c8348709 100644 (file)
@@ -5,6 +5,8 @@
 void *rootdir = NULL;
 EXPORT_SYMBOL(rootdir);
 
+kmem_cache_t *vn_cache;
+
 static vtype_t
 vn_get_sol_type(umode_t mode)
 {
@@ -35,8 +37,31 @@ 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;
@@ -76,7 +101,7 @@ vn_open(const char *path, int seg, int flags, int mode,
                return rc;
        }
 
-       vp = kmalloc(sizeof(vnode_t), GFP_ATOMIC);
+       vp = vn_alloc(KM_SLEEP);
        if (!vp) {
                filp_close(fp, 0);
                return -ENOMEM;
@@ -91,7 +116,7 @@ vn_open(const char *path, int seg, int flags, int mode,
 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;
@@ -114,7 +139,7 @@ EXPORT_SYMBOL(vn_openat);
 
 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;
@@ -167,7 +192,7 @@ vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4)
        BUG_ON(!vp->v_fp);
 
         rc = filp_close(vp->v_fp, 0);
-        kfree(vp);
+        vn_free(vp);
 
        return rc;
 } /* vn_close() */
@@ -180,7 +205,7 @@ static struct dentry *lookup_hash(struct nameidata *nd)
 
 /* 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;
@@ -364,3 +389,36 @@ int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4)
        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() */