Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs Pass the ufs_lookup_results pointer around instead o...



details:   https://anonhg.NetBSD.org/src/rev/71449810f93d
branches:  trunk
changeset: 767233:71449810f93d
user:      dholland <dholland%NetBSD.org@localhost>
date:      Tue Jul 12 16:59:48 2011 +0000

description:
Pass the ufs_lookup_results pointer around instead of fetching it from
the inode in the guts of ufs. Now, in VOPs where i_crap is used it is
used (directly) only immediately on entry to the VOP call and then
passed around by reference.

Except for rename, which needs explicit sorting out. The code in
ufs_wapbl_rename is unchanged in behavior but I'm increasingly
inclined to think it's wrong.

diffstat:

 sys/ufs/ext2fs/ext2fs_extern.h |  10 ++-
 sys/ufs/ext2fs/ext2fs_lookup.c |  29 +++--------
 sys/ufs/ext2fs/ext2fs_vnops.c  |  47 +++++++++++++++----
 sys/ufs/lfs/lfs_vnops.c        |  11 +++-
 sys/ufs/ufs/ufs_extern.h       |  16 ++++--
 sys/ufs/ufs/ufs_lookup.c       |  29 +++++-------
 sys/ufs/ufs/ufs_vnops.c        |  99 +++++++++++++++++++++++++++++++----------
 sys/ufs/ufs/ufs_wapbl.c        |  20 +++++--
 8 files changed, 170 insertions(+), 91 deletions(-)

diffs (truncated from 806 to 300 lines):

diff -r 358d32f09511 -r 71449810f93d sys/ufs/ext2fs/ext2fs_extern.h
--- a/sys/ufs/ext2fs/ext2fs_extern.h    Tue Jul 12 16:40:41 2011 +0000
+++ b/sys/ufs/ext2fs/ext2fs_extern.h    Tue Jul 12 16:59:48 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ext2fs_extern.h,v 1.42 2009/10/21 17:37:21 pooka Exp $ */
+/*     $NetBSD: ext2fs_extern.h,v 1.43 2011/07/12 16:59:48 dholland Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -118,10 +118,12 @@
 int ext2fs_readdir(void *);
 int ext2fs_lookup(void *);
 int ext2fs_direnter(struct inode *, struct vnode *,
+                        const struct ufs_lookup_results *,
                         struct componentname *);
-int ext2fs_dirremove(struct vnode *, struct componentname *);
-int ext2fs_dirrewrite(struct inode *, struct inode *,
-                          struct componentname *);
+int ext2fs_dirremove(struct vnode *, const struct ufs_lookup_results *,
+                    struct componentname *);
+int ext2fs_dirrewrite(struct inode *, const struct ufs_lookup_results *,
+                          struct inode *, struct componentname *);
 int ext2fs_dirempty(struct inode *, ino_t, kauth_cred_t);
 int ext2fs_checkpath(struct inode *, struct inode *, kauth_cred_t);
 
diff -r 358d32f09511 -r 71449810f93d sys/ufs/ext2fs/ext2fs_lookup.c
--- a/sys/ufs/ext2fs/ext2fs_lookup.c    Tue Jul 12 16:40:41 2011 +0000
+++ b/sys/ufs/ext2fs/ext2fs_lookup.c    Tue Jul 12 16:59:48 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ext2fs_lookup.c,v 1.65 2011/07/12 02:22:13 dholland Exp $      */
+/*     $NetBSD: ext2fs_lookup.c,v 1.66 2011/07/12 16:59:48 dholland Exp $      */
 
 /*
  * Modified for NetBSD 1.2E
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.65 2011/07/12 02:22:13 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.66 2011/07/12 16:59:48 dholland Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -747,7 +747,9 @@
  * entry is to be obtained.
  */
 int
-ext2fs_direnter(struct inode *ip, struct vnode *dvp, struct componentname *cnp)
+ext2fs_direnter(struct inode *ip, struct vnode *dvp,
+               const struct ufs_lookup_results *ulr,
+               struct componentname *cnp)
 {
        struct ext2fs_direct *ep, *nep;
        struct inode *dp;
@@ -760,13 +762,9 @@
        char *dirbuf;
        struct ufsmount *ump = VFSTOUFS(dvp->v_mount);
        int dirblksiz = ump->um_dirblksiz;
-       struct ufs_lookup_results *ulr;
 
        dp = VTOI(dvp);
 
-       ulr = &dp->i_crap;
-       UFS_CHECK_CRAPCOUNTER(dp);
-
        newdir.e2d_ino = h2fs32(ip->i_number);
        newdir.e2d_namlen = cnp->cn_namelen;
        if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
@@ -893,20 +891,16 @@
  * to the size of the previous entry.
  */
 int
-ext2fs_dirremove(struct vnode *dvp, struct componentname *cnp)
+ext2fs_dirremove(struct vnode *dvp, const struct ufs_lookup_results *ulr,
+                struct componentname *cnp)
 {
        struct inode *dp;
        struct ext2fs_direct *ep;
        struct buf *bp;
        int error;
-       struct ufs_lookup_results *ulr;
 
        dp = VTOI(dvp);
 
-       /* XXX should handle this material another way */
-       ulr = &dp->i_crap;
-       UFS_CHECK_CRAPCOUNTER(dp);
-
        if (ulr->ulr_count == 0) {
                /*
                 * First entry in block: set d_ino to zero.
@@ -939,18 +933,13 @@
  * set up by a call to namei.
  */
 int
-ext2fs_dirrewrite(struct inode *dp, struct inode *ip,
-    struct componentname *cnp)
+ext2fs_dirrewrite(struct inode *dp, const struct ufs_lookup_results *ulr,
+    struct inode *ip, struct componentname *cnp)
 {
        struct buf *bp;
        struct ext2fs_direct *ep;
        struct vnode *vdp = ITOV(dp);
        int error;
-       struct ufs_lookup_results *ulr;
-
-       /* XXX should handle this material another way */
-       ulr = &dp->i_crap;
-       UFS_CHECK_CRAPCOUNTER(dp);
 
        error = ext2fs_blkatoff(vdp, (off_t)ulr->ulr_offset, (void *)&ep, &bp);
        if (error != 0)
diff -r 358d32f09511 -r 71449810f93d sys/ufs/ext2fs/ext2fs_vnops.c
--- a/sys/ufs/ext2fs/ext2fs_vnops.c     Tue Jul 12 16:40:41 2011 +0000
+++ b/sys/ufs/ext2fs/ext2fs_vnops.c     Tue Jul 12 16:59:48 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ext2fs_vnops.c,v 1.99 2011/04/26 11:32:40 hannken Exp $        */
+/*     $NetBSD: ext2fs_vnops.c,v 1.100 2011/07/12 16:59:48 dholland Exp $      */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.99 2011/04/26 11:32:40 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.100 2011/07/12 16:59:48 dholland Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -526,15 +526,20 @@
        struct inode *ip;
        struct vnode *vp = ap->a_vp;
        struct vnode *dvp = ap->a_dvp;
+       struct ufs_lookup_results *ulr;
        int error;
 
+       /* XXX should handle this material another way */
+       ulr = &VTOI(dvp)->i_crap;
+       UFS_CHECK_CRAPCOUNTER(VTOI(dvp));
+
        ip = VTOI(vp);
        if (vp->v_type == VDIR ||
                (ip->i_e2fs_flags & (EXT2_IMMUTABLE | EXT2_APPEND)) ||
                (VTOI(dvp)->i_e2fs_flags & EXT2_APPEND)) {
                error = EPERM;
        } else {
-               error = ext2fs_dirremove(dvp, ap->a_cnp);
+               error = ext2fs_dirremove(dvp, ulr, ap->a_cnp);
                if (error == 0) {
                        ip->i_e2fs_nlink--;
                        ip->i_flag |= IN_CHANGE;
@@ -567,11 +572,16 @@
        struct componentname *cnp = ap->a_cnp;
        struct inode *ip;
        int error;
+       struct ufs_lookup_results *ulr;
 
        KASSERT(dvp != vp);
        KASSERT(vp->v_type != VDIR);
        KASSERT(dvp->v_mount == vp->v_mount);
 
+       /* XXX should handle this material another way */
+       ulr = &VTOI(dvp)->i_crap;
+       UFS_CHECK_CRAPCOUNTER(VTOI(dvp));
+
        error = vn_lock(vp, LK_EXCLUSIVE);
        if (error) {
                VOP_ABORTOP(dvp, cnp);
@@ -592,7 +602,7 @@
        ip->i_flag |= IN_CHANGE;
        error = ext2fs_update(vp, NULL, NULL, UPDATE_WAIT);
        if (!error)
-               error = ext2fs_direnter(ip, dvp, cnp);
+               error = ext2fs_direnter(ip, dvp, ulr, cnp);
        if (error) {
                ip->i_e2fs_nlink--;
                ip->i_flag |= IN_CHANGE;
@@ -829,7 +839,7 @@
                            UPDATE_WAIT)) != 0)
                                goto bad;
                }
-               error = ext2fs_direnter(ip, tdvp, tcnp);
+               error = ext2fs_direnter(ip, tdvp, &VTOI(tdvp)->i_crap, tcnp);
                if (error != 0) {
                        if (doingdirectory && newparent) {
                                dp->i_e2fs_nlink--;
@@ -883,7 +893,7 @@
                        error = EISDIR;
                        goto bad;
                }
-               error = ext2fs_dirrewrite(dp, ip, tcnp);
+               error = ext2fs_dirrewrite(dp, &dp->i_crap, ip, tcnp);
                if (error != 0)
                        goto bad;
                /*
@@ -992,7 +1002,7 @@
                                }
                        }
                }
-               error = ext2fs_dirremove(fdvp, fcnp);
+               error = ext2fs_dirremove(fdvp, &VTOI(fdvp)->i_crap, fcnp);
                if (!error) {
                        xp->i_e2fs_nlink--;
                        xp->i_flag |= IN_CHANGE;
@@ -1043,6 +1053,11 @@
        struct vnode            *tvp;
        struct ext2fs_dirtemplate dirtemplate;
        int                     error, dmode;
+       struct ufs_lookup_results *ulr;
+
+       /* XXX should handle this material another way */
+       ulr = &VTOI(dvp)->i_crap;
+       UFS_CHECK_CRAPCOUNTER(VTOI(dvp));
 
        if ((nlink_t)dp->i_e2fs_nlink >= LINK_MAX) {
                error = EMLINK;
@@ -1125,7 +1140,7 @@
        }
 
        /* Directory set up, now install it's entry in the parent directory. */
-       error = ext2fs_direnter(ip, dvp, cnp);
+       error = ext2fs_direnter(ip, dvp, ulr, cnp);
        if (error != 0) {
                dp->i_e2fs_nlink--;
                dp->i_flag |= IN_CHANGE;
@@ -1164,9 +1179,15 @@
        struct componentname *cnp = ap->a_cnp;
        struct inode *ip, *dp;
        int error;
+       struct ufs_lookup_results *ulr;
 
        ip = VTOI(vp);
        dp = VTOI(dvp);
+
+       /* XXX should handle this material another way */
+       ulr = &dp->i_crap;
+       UFS_CHECK_CRAPCOUNTER(dp);
+
        /*
         * No rmdir "." please.
         */
@@ -1198,7 +1219,7 @@
         * inode.  If we crash in between, the directory
         * will be reattached to lost+found,
         */
-       error = ext2fs_dirremove(dvp, cnp);
+       error = ext2fs_dirremove(dvp, ulr, cnp);
        if (error != 0)
                goto out;
        dp->i_e2fs_nlink--;
@@ -1401,8 +1422,14 @@
        struct inode *ip, *pdir;
        struct vnode *tvp;
        int error, ismember = 0;
+       struct ufs_lookup_results *ulr;
 
        pdir = VTOI(dvp);
+
+       /* XXX should handle this material another way */
+       ulr = &pdir->i_crap;
+       UFS_CHECK_CRAPCOUNTER(pdir);
+
        *vpp = NULL;
        if ((mode & IFMT) == 0)
                mode |= IFREG;
@@ -1437,7 +1464,7 @@
         */
        if ((error = ext2fs_update(tvp, NULL, NULL, UPDATE_WAIT)) != 0)
                goto bad;
-       error = ext2fs_direnter(ip, dvp, cnp);
+       error = ext2fs_direnter(ip, dvp, ulr, cnp);
        if (error != 0)
                goto bad;
        vput(dvp);
diff -r 358d32f09511 -r 71449810f93d sys/ufs/lfs/lfs_vnops.c
--- a/sys/ufs/lfs/lfs_vnops.c   Tue Jul 12 16:40:41 2011 +0000
+++ b/sys/ufs/lfs/lfs_vnops.c   Tue Jul 12 16:59:48 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_vnops.c,v 1.236 2011/07/11 08:27:41 hannken Exp $  */
+/*     $NetBSD: lfs_vnops.c,v 1.237 2011/07/12 16:59:48 dholland Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.236 2011/07/11 08:27:41 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.237 2011/07/12 16:59:48 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -606,13 +606,18 @@
        int error;
        struct mount    *mp;
        ino_t           ino;
+       struct ufs_lookup_results *ulr;
+
+       /* XXX should handle this material another way */



Home | Main Index | Thread Index | Old Index