Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/ntfs Change ntfs to vcache.



details:   https://anonhg.NetBSD.org/src/rev/9954220fbbb4
branches:  trunk
changeset: 803824:9954220fbbb4
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Nov 13 16:51:53 2014 +0000

description:
Change ntfs to vcache.
- Use (inumber, attrtype, attrname) as key.
- Inline ntfs_fget() and ntfs_frele() as they only get called once.

diffstat:

 sys/fs/ntfs/ntfs.h        |    3 +-
 sys/fs/ntfs/ntfs_inode.h  |   20 +-
 sys/fs/ntfs/ntfs_subr.c   |   88 +------------
 sys/fs/ntfs/ntfs_subr.h   |    5 +-
 sys/fs/ntfs/ntfs_vfsops.c |  305 ++++++++++++++++++++++-----------------------
 sys/fs/ntfs/ntfs_vnops.c  |   32 ++-
 6 files changed, 188 insertions(+), 265 deletions(-)

diffs (truncated from 703 to 300 lines):

diff -r 0483350bdffd -r 9954220fbbb4 sys/fs/ntfs/ntfs.h
--- a/sys/fs/ntfs/ntfs.h        Thu Nov 13 16:51:10 2014 +0000
+++ b/sys/fs/ntfs/ntfs.h        Thu Nov 13 16:51:53 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs.h,v 1.19 2008/05/05 17:11:16 ad Exp $     */
+/*     $NetBSD: ntfs.h,v 1.20 2014/11/13 16:51:53 hannken Exp $        */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko
@@ -294,7 +294,6 @@
 #ifdef _KERNEL
 MALLOC_DECLARE(M_NTFSMNT);
 MALLOC_DECLARE(M_NTFSNTNODE);
-MALLOC_DECLARE(M_NTFSFNODE);
 MALLOC_DECLARE(M_NTFSDIR);
 MALLOC_DECLARE(M_NTFSNTVATTR);
 MALLOC_DECLARE(M_NTFSRDATA);
diff -r 0483350bdffd -r 9954220fbbb4 sys/fs/ntfs/ntfs_inode.h
--- a/sys/fs/ntfs/ntfs_inode.h  Thu Nov 13 16:51:10 2014 +0000
+++ b/sys/fs/ntfs/ntfs_inode.h  Thu Nov 13 16:51:53 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_inode.h,v 1.8 2014/11/13 16:49:56 hannken Exp $   */
+/*     $NetBSD: ntfs_inode.h,v 1.9 2014/11/13 16:51:53 hannken Exp $   */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko
@@ -64,7 +64,6 @@
        int             i_usecount;
        int             i_busy;
 
-       LIST_HEAD(,fnode)       i_fnlist;
        LIST_HEAD(,ntvattr)     i_valist;
 
        long            i_nlink;        /* MFR */
@@ -72,15 +71,19 @@
        u_int32_t       i_frflag;       /* MFR */
 };
 
-#define        FN_PRELOADED    0x0001
-#define        FN_VALID        0x0002
+#define NTKEY_SIZE(attrlen) (sizeof(struct ntkey) + (attrlen))
+struct ntkey {
+       ino_t           k_ino;          /* Inode number of ntnode. */
+       u_int32_t       k_attrtype;     /* Attribute type. */
+       char            k_attrname[1];  /* Attribute name (variable length). */
+} __packed;
+
 struct fnode {
        struct genfs_node f_gnode;
 
        LIST_ENTRY(fnode) f_fnlist;
        struct vnode   *f_vp;           /* Associatied vnode */
        struct ntnode  *f_ip;           /* Associated ntnode */
-       u_long          f_flag;
 
        ntfs_times_t    f_times;        /* $NAME/dirinfo */
        ino_t           f_pnumber;      /* $NAME/dirinfo */
@@ -88,8 +91,11 @@
        u_int64_t       f_size;         /* defattr/dirinfo: */
        u_int64_t       f_allocated;    /* defattr/dirinfo */
 
-       u_int32_t       f_attrtype;
-       char           *f_attrname;
+       struct ntkey   *f_key;
+       struct ntkey    f_smallkey;
+#define f_ino f_key->k_ino
+#define f_attrtype f_key->k_attrtype
+#define f_attrname f_key->k_attrname
 
        /* for ntreaddir */
        u_int32_t       f_lastdattr;
diff -r 0483350bdffd -r 9954220fbbb4 sys/fs/ntfs/ntfs_subr.c
--- a/sys/fs/ntfs/ntfs_subr.c   Thu Nov 13 16:51:10 2014 +0000
+++ b/sys/fs/ntfs/ntfs_subr.c   Thu Nov 13 16:51:53 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_subr.c,v 1.53 2014/11/13 16:51:10 hannken Exp $   */
+/*     $NetBSD: ntfs_subr.c,v 1.54 2014/11/13 16:51:53 hannken Exp $   */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko (semenu%FreeBSD.org@localhost)
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.53 2014/11/13 16:51:10 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.54 2014/11/13 16:51:53 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -428,8 +428,6 @@
        ip->i_number = ino;
        ip->i_mp = ntmp;
 
-       LIST_INIT(&ip->i_fnlist);
-
        /* init lock and lock the newborn ntnode */
        cv_init(&ip->i_lock, "ntfslk");
        mutex_init(&ip->i_interlock, MUTEX_DEFAULT, IPL_NONE);
@@ -479,9 +477,6 @@
                dprintf(("%s: deallocating ntnode: %llu\n", __func__,
                    (unsigned long long)ip->i_number));
 
-               if (ip->i_fnlist.lh_first)
-                       panic("ntfs_ntput: ntnode has fnodes");
-
                ntfs_nthashrem(ip);
 
                while (ip->i_valist.lh_first != NULL) {
@@ -726,79 +721,6 @@
 }
 
 /*
- * Search fnode in ntnode, if not found allocate and preinitialize.
- *
- * ntnode should be locked on entry.
- */
-int
-ntfs_fget(
-    struct ntfsmount *ntmp,
-    struct ntnode *ip,
-    int attrtype,
-    const char *attrname,
-    struct fnode **fpp
-)
-{
-       struct fnode *fp;
-
-       dprintf(("%s: ino: %llu, attrtype: 0x%x, attrname: %s\n", __func__,
-           (unsigned long long)ip->i_number, attrtype, attrname));
-       *fpp = NULL;
-       for (fp = ip->i_fnlist.lh_first; fp != NULL; fp = fp->f_fnlist.le_next){
-               dprintf(("%s: fnode: attrtype: %d, attrname: %s\n", __func__,
-                       fp->f_attrtype, fp->f_attrname));
-
-               if ((attrtype == fp->f_attrtype) &&
-                   strcmp(attrname, fp->f_attrname) == 0) {
-                       dprintf(("%s: found existed: %p\n", __func__, fp));
-                       *fpp = fp;
-               }
-       }
-
-       if (*fpp)
-               return (0);
-
-       fp = malloc(sizeof(*fp), M_NTFSFNODE, M_WAITOK|M_ZERO);
-       dprintf(("%s: allocating fnode: %p\n", __func__, fp));
-
-       fp->f_ip = ip;
-       fp->f_attrname = malloc(strlen(attrname)+1, M_TEMP, M_WAITOK);
-       strcpy(fp->f_attrname, attrname);
-       fp->f_attrtype = attrtype;
-
-       ntfs_ntref(ip);
-
-       LIST_INSERT_HEAD(&ip->i_fnlist, fp, f_fnlist);
-
-       *fpp = fp;
-
-       return (0);
-}
-
-/*
- * Deallocate fnode, remove it from ntnode's fnode list.
- *
- * ntnode should be locked.
- */
-void
-ntfs_frele(
-       struct fnode *fp)
-{
-       struct ntnode *ip = FTONT(fp);
-
-       dprintf(("%s: fnode: %p for %llu: %p\n", __func__, fp,
-           (unsigned long long)ip->i_number, ip));
-
-       dprintf(("%s: deallocating fnode\n", __func__));
-       LIST_REMOVE(fp,f_fnlist);
-       free(fp->f_attrname, M_TEMP);
-       if (fp->f_dirblbuf)
-               free(fp->f_dirblbuf, M_NTFSDIR);
-       free(fp, M_NTFSFNODE);
-       ntfs_ntrele(ip);
-}
-
-/*
  * Lookup attribute name in format: [[:$ATTR_TYPE]:$ATTR_NAME],
  * $ATTR_TYPE is searched in attrdefs read from $AttrDefs.
  * If $ATTR_TYPE not specified, ATTR_A_DATA assumed.
@@ -855,7 +777,7 @@
 
 /*
  * Lookup specified node for filename, matching cnp,
- * return fnode filled.
+ * return referenced vnode with fnode filled.
  */
 int
 ntfs_ntlookupfile(
@@ -987,7 +909,7 @@
                        /* vget node */
                        error = ntfs_vgetex(ntmp->ntm_mountp, iep->ie_number,
                                   attrtype, attrname ? attrname : "",
-                                  LK_EXCLUSIVE, &nvp);
+                                  0, &nvp);
 
                        /* free the buffer returned by ntfs_ntlookupattr() */
                        if (attrname) {
@@ -998,8 +920,6 @@
                        if (error)
                                goto fail;
 
-                       KASSERT(VTOF(nvp)->f_flag & FN_VALID);
-
                        *vpp = nvp;
                        goto fail;
                }
diff -r 0483350bdffd -r 9954220fbbb4 sys/fs/ntfs/ntfs_subr.h
--- a/sys/fs/ntfs/ntfs_subr.h   Thu Nov 13 16:51:10 2014 +0000
+++ b/sys/fs/ntfs/ntfs_subr.h   Thu Nov 13 16:51:53 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_subr.h,v 1.8 2014/11/13 16:51:10 hannken Exp $    */
+/*     $NetBSD: ntfs_subr.h,v 1.9 2014/11/13 16:51:53 hannken Exp $    */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko
@@ -111,9 +111,6 @@
 void ntfs_toupper_init(void);
 int ntfs_toupper_use(struct mount *, struct ntfsmount *);
 void ntfs_toupper_unuse(void);
-int ntfs_fget(struct ntfsmount *, struct ntnode *, int, const char *,
-       struct fnode **);
-void ntfs_frele(struct fnode *);
 
 /* ntfs_conv.c stuff */
 ntfs_wget_func_t ntfs_utf8_wget;
diff -r 0483350bdffd -r 9954220fbbb4 sys/fs/ntfs/ntfs_vfsops.c
--- a/sys/fs/ntfs/ntfs_vfsops.c Thu Nov 13 16:51:10 2014 +0000
+++ b/sys/fs/ntfs/ntfs_vfsops.c Thu Nov 13 16:51:53 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_vfsops.c,v 1.96 2014/11/13 16:51:10 hannken Exp $ */
+/*     $NetBSD: ntfs_vfsops.c,v 1.97 2014/11/13 16:51:53 hannken Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.96 2014/11/13 16:51:10 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.97 2014/11/13 16:51:53 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,7 +63,6 @@
 
 MALLOC_JUSTDEFINE(M_NTFSMNT, "NTFS mount", "NTFS mount structure");
 MALLOC_JUSTDEFINE(M_NTFSNTNODE,"NTFS ntnode",  "NTFS ntnode information");
-MALLOC_JUSTDEFINE(M_NTFSFNODE,"NTFS fnode",  "NTFS fnode information");
 MALLOC_JUSTDEFINE(M_NTFSDIR,"NTFS dir",  "NTFS dir buffer");
 
 static int     ntfs_mount(struct mount *, const char *, void *, size_t *);
@@ -74,6 +73,8 @@
 static int     ntfs_unmount(struct mount *, int);
 static int     ntfs_vget(struct mount *mp, ino_t ino,
                               struct vnode **vpp);
+static int     ntfs_loadvnode(struct mount *, struct vnode *,
+                                   const void *, size_t, const void **);
 static int     ntfs_mountfs(struct vnode *, struct mount *,
                                  struct ntfs_args *, struct lwp *);
 static int     ntfs_vptofh(struct vnode *, struct fid *, size_t *);
@@ -130,7 +131,6 @@
 
        malloc_type_attach(M_NTFSMNT);
        malloc_type_attach(M_NTFSNTNODE);
-       malloc_type_attach(M_NTFSFNODE);
        malloc_type_attach(M_NTFSDIR);
        malloc_type_attach(M_NTFSNTVATTR);
        malloc_type_attach(M_NTFSRDATA);
@@ -152,7 +152,6 @@
        ntfs_nthashdone();
        malloc_type_detach(M_NTFSMNT);
        malloc_type_detach(M_NTFSNTNODE);
-       malloc_type_detach(M_NTFSFNODE);
        malloc_type_detach(M_NTFSDIR);
        malloc_type_detach(M_NTFSNTVATTR);
        malloc_type_detach(M_NTFSRDATA);
@@ -703,6 +702,129 @@
        return (0);
 }
 
+static int
+ntfs_loadvnode(struct mount *mp, struct vnode *vp,
+    const void *key, size_t key_len, const void **new_key)
+{
+       int error;
+       struct ntvattr *vap;
+       struct ntkey small_key, *ntkey;
+       struct ntfsmount *ntmp;
+       struct ntnode *ip;
+       struct fnode *fp = NULL;
+       enum vtype f_type = VBAD;



Home | Main Index | Thread Index | Old Index