Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/cd9660 Remove the hints "isodir" and "relocated" from...



details:   https://anonhg.NetBSD.org/src/rev/9933df574d2e
branches:  trunk
changeset: 329928:9933df574d2e
user:      hannken <hannken%NetBSD.org@localhost>
date:      Sat Jun 14 07:39:28 2014 +0000

description:
Remove the hints "isodir" and "relocated" from cd9660_vget_internal()
and always reread the directory entry by inumber.  For directories
the directory entry is always its "." entry.

Always read directories via the device vnode to prevent buffer cache
inconsistency.  Keep i_devvp as a hint for fstat(1) and friends and
always use im_devvp for reads.  No need to vref()/vrele() i_devvp.

The additional bread is either cached because cd9660_lookup() just
released the buffer or will be used in the near future when the
directory gets traversed during lookup.

No objections on tech-kern@

diffstat:

 sys/fs/cd9660/cd9660_bmap.c   |    6 +-
 sys/fs/cd9660/cd9660_lookup.c |   17 +++--
 sys/fs/cd9660/cd9660_node.c   |    8 +-
 sys/fs/cd9660/cd9660_node.h   |    5 +-
 sys/fs/cd9660/cd9660_vfsops.c |  130 ++++++++++++++---------------------------
 sys/fs/cd9660/cd9660_vnops.c  |    6 +-
 6 files changed, 65 insertions(+), 107 deletions(-)

diffs (truncated from 350 to 300 lines):

diff -r d343eb3f3b61 -r 9933df574d2e sys/fs/cd9660/cd9660_bmap.c
--- a/sys/fs/cd9660/cd9660_bmap.c       Sat Jun 14 07:39:00 2014 +0000
+++ b/sys/fs/cd9660/cd9660_bmap.c       Sat Jun 14 07:39:28 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_bmap.c,v 1.4 2008/02/27 19:43:36 matt Exp $     */
+/*     $NetBSD: cd9660_bmap.c,v 1.5 2014/06/14 07:39:28 hannken Exp $  */
 
 /*-
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_bmap.c,v 1.4 2008/02/27 19:43:36 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_bmap.c,v 1.5 2014/06/14 07:39:28 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/namei.h>
@@ -74,7 +74,7 @@
         * to physical mapping is requested.
         */
        if (ap->a_vpp != NULL)
-               *ap->a_vpp = ip->i_devvp;
+               *ap->a_vpp = ip->i_mnt->im_devvp;
        if (ap->a_bnp == NULL)
                return (0);
 
diff -r d343eb3f3b61 -r 9933df574d2e sys/fs/cd9660/cd9660_lookup.c
--- a/sys/fs/cd9660/cd9660_lookup.c     Sat Jun 14 07:39:00 2014 +0000
+++ b/sys/fs/cd9660/cd9660_lookup.c     Sat Jun 14 07:39:28 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_lookup.c,v 1.27 2014/06/03 19:30:30 joerg Exp $ */
+/*     $NetBSD: cd9660_lookup.c,v 1.28 2014/06/14 07:39:28 hannken Exp $       */
 
 /*-
  * Copyright (c) 1989, 1993, 1994
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_lookup.c,v 1.27 2014/06/03 19:30:30 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_lookup.c,v 1.28 2014/06/14 07:39:28 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/namei.h>
@@ -379,8 +379,7 @@
        brelse(bp, 0);
        if (flags & ISDOTDOT) {
                VOP_UNLOCK(pdp);        /* race to get the inode */
-               error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, &tdp,
-                                            dp->i_ino != ino, ep);
+               error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, &tdp);
                vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY);
                if (error)
                        return error;
@@ -389,8 +388,7 @@
                vref(vdp);      /* we want ourself, ie "." */
                *vpp = vdp;
        } else {
-               error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, &tdp,
-                                            dp->i_ino != ino, ep);
+               error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, &tdp);
                if (error)
                        return (error);
                *vpp = tdp;
@@ -416,6 +414,7 @@
 {
        struct iso_node *ip;
        struct iso_mnt *imp;
+       struct vnode *devvp;
        struct buf *bp;
        daddr_t lbn;
        int bsize, error;
@@ -425,7 +424,11 @@
        lbn = cd9660_lblkno(imp, offset);
        bsize = cd9660_blksize(imp, ip, lbn);
 
-       if ((error = bread(vp, lbn, bsize, NOCRED, 0, &bp)) != 0) {
+       if ((error = VOP_BMAP(vp, lbn, &devvp, &lbn, NULL)) != 0) {
+               *bpp = NULL;
+               return error;
+       }
+       if ((error = bread(devvp, lbn, bsize, NOCRED, 0, &bp)) != 0) {
                *bpp = NULL;
                return (error);
        }
diff -r d343eb3f3b61 -r 9933df574d2e sys/fs/cd9660/cd9660_node.c
--- a/sys/fs/cd9660/cd9660_node.c       Sat Jun 14 07:39:00 2014 +0000
+++ b/sys/fs/cd9660/cd9660_node.c       Sat Jun 14 07:39:28 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_node.c,v 1.31 2014/05/10 14:11:58 martin Exp $  */
+/*     $NetBSD: cd9660_node.c,v 1.32 2014/06/14 07:39:28 hannken Exp $ */
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1994
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_node.c,v 1.31 2014/05/10 14:11:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_node.c,v 1.32 2014/06/14 07:39:28 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -241,10 +241,6 @@
        /*
         * Purge old data structures associated with the inode.
         */
-       if (ip->i_devvp) {
-               vrele(ip->i_devvp);
-               ip->i_devvp = 0;
-       }
        genfs_node_destroy(vp);
        pool_put(&cd9660_node_pool, vp->v_data);
        vp->v_data = NULL;
diff -r d343eb3f3b61 -r 9933df574d2e sys/fs/cd9660/cd9660_node.h
--- a/sys/fs/cd9660/cd9660_node.h       Sat Jun 14 07:39:00 2014 +0000
+++ b/sys/fs/cd9660/cd9660_node.h       Sat Jun 14 07:39:28 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_node.h,v 1.14 2008/02/27 19:43:36 matt Exp $    */
+/*     $NetBSD: cd9660_node.h,v 1.15 2014/06/14 07:39:28 hannken Exp $ */
 
 /*-
  * Copyright (c) 1994
@@ -133,8 +133,7 @@
 void   cd9660_ihashrem(struct iso_node *);
 int    cd9660_tstamp_conv7(const u_char *, struct timespec *);
 int    cd9660_tstamp_conv17(const u_char *, struct timespec *);
-int    cd9660_vget_internal(struct mount *, ino_t, struct vnode **, int,
-                             struct iso_directory_record *);
+int    cd9660_vget_internal(struct mount *, ino_t, struct vnode **);
 
 extern kmutex_t cd9660_hashlock;
 
diff -r d343eb3f3b61 -r 9933df574d2e sys/fs/cd9660/cd9660_vfsops.c
--- a/sys/fs/cd9660/cd9660_vfsops.c     Sat Jun 14 07:39:00 2014 +0000
+++ b/sys/fs/cd9660/cd9660_vfsops.c     Sat Jun 14 07:39:28 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_vfsops.c,v 1.85 2014/05/13 17:05:26 martin Exp $        */
+/*     $NetBSD: cd9660_vfsops.c,v 1.86 2014/06/14 07:39:28 hannken Exp $       */
 
 /*-
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.85 2014/05/13 17:05:26 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.86 2014/06/14 07:39:28 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -586,12 +586,7 @@
            (struct iso_directory_record *)imp->root;
        ino_t ino = isodirino(dp, imp);
 
-       /*
-        * With RRIP we must use the `.' entry of the root directory.
-        * Simply tell vget, that it's a relocated directory.
-        */
-       return (cd9660_vget_internal(mp, ino, vpp,
-                                    imp->iso_ftype == ISO_FTYPE_RRIP, dp));
+       return cd9660_vget(mp, ino, vpp);
 }
 
 /*
@@ -683,30 +678,19 @@
 cd9660_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
 {
 
-       /*
-        * XXXX
-        * It would be nice if we didn't always set the `relocated' flag
-        * and force the extra read, but I don't want to think about fixing
-        * that right now.
-        */
-       return (cd9660_vget_internal(mp, ino, vpp,
-#if 0
-                                    VFSTOISOFS(mp)->iso_ftype == ISO_FTYPE_RRIP,
-#else
-                                    0,
-#endif
-                                    NULL));
+       return cd9660_vget_internal(mp, ino, vpp);
 }
 
 int
-cd9660_vget_internal(struct mount *mp, ino_t ino, struct vnode **vpp,
-       int relocated, struct iso_directory_record *isodir)
+cd9660_vget_internal(struct mount *mp, ino_t ino, struct vnode **vpp)
 {
        struct iso_mnt *imp;
        struct iso_node *ip;
+       struct iso_directory_record *isodir;
        struct buf *bp;
        struct vnode *vp;
        dev_t dev;
+       int lbn, off;
        int error;
 
        imp = VFSTOISOFS(mp);
@@ -754,75 +738,52 @@
        cd9660_ihashins(ip);
        mutex_exit(&cd9660_hashlock);
 
-       if (isodir == 0) {
-               int lbn, off;
+       lbn = cd9660_lblkno(imp, ino);
+       if (lbn >= imp->volume_space_size) {
+               vput(vp);
+               printf("fhtovp: lbn exceed volume space %d\n", lbn);
+               return (ESTALE);
+       }
 
-               lbn = cd9660_lblkno(imp, ino);
-               if (lbn >= imp->volume_space_size) {
-                       vput(vp);
-                       printf("fhtovp: lbn exceed volume space %d\n", lbn);
-                       return (ESTALE);
-               }
-
-               off = cd9660_blkoff(imp, ino);
-               if (off + ISO_DIRECTORY_RECORD_SIZE > imp->logical_block_size) {
-                       vput(vp);
-                       printf("fhtovp: crosses block boundary %d\n",
-                           off + ISO_DIRECTORY_RECORD_SIZE);
-                       return (ESTALE);
-               }
+       off = cd9660_blkoff(imp, ino);
+       if (off + ISO_DIRECTORY_RECORD_SIZE > imp->logical_block_size) {
+               vput(vp);
+               printf("fhtovp: crosses block boundary %d\n",
+                   off + ISO_DIRECTORY_RECORD_SIZE);
+               return (ESTALE);
+       }
 
-               error = bread(imp->im_devvp,
-                             lbn << (imp->im_bshift - DEV_BSHIFT),
-                             imp->logical_block_size, NOCRED, 0, &bp);
-               if (error) {
-                       vput(vp);
-                       printf("fhtovp: bread error %d\n",error);
-                       return (error);
-               }
-               isodir = (struct iso_directory_record *)((char *)bp->b_data + off);
+       error = bread(imp->im_devvp,
+                     lbn << (imp->im_bshift - DEV_BSHIFT),
+                     imp->logical_block_size, NOCRED, 0, &bp);
+       if (error) {
+               vput(vp);
+               printf("fhtovp: bread error %d\n",error);
+               return (error);
+       }
+       isodir = (struct iso_directory_record *)((char *)bp->b_data + off);
 
-               if (off + isonum_711(isodir->length) >
-                   imp->logical_block_size) {
-                       vput(vp);
-                       if (bp != 0)
-                               brelse(bp, 0);
-                       printf("fhtovp: directory crosses block boundary %d[off=%d/len=%d]\n",
-                           off +isonum_711(isodir->length), off,
-                           isonum_711(isodir->length));
-                       return (ESTALE);
-               }
+       if (off + isonum_711(isodir->length) > imp->logical_block_size) {
+               vput(vp);
+               if (bp != 0)
+                       brelse(bp, 0);
+               printf("fhtovp: directory crosses block boundary %d[off=%d/len=%d]\n",
+                   off +isonum_711(isodir->length), off,
+                   isonum_711(isodir->length));
+               return (ESTALE);
+       }
 
 #if 0
-               if (isonum_733(isodir->extent) +
-                   isonum_711(isodir->ext_attr_length) != ifhp->ifid_start) {
-                       if (bp != 0)
-                               brelse(bp, 0);
-                       printf("fhtovp: file start miss %d vs %d\n",
-                           isonum_733(isodir->extent) + isonum_711(isodir->ext_attr_length),
-                           ifhp->ifid_start);
-                       return (ESTALE);
-               }
-#endif
-       } else
-               bp = 0;
-
-       vref(ip->i_devvp);
-
-       if (relocated) {
-               /*
-                * On relocated directories we must
-                * read the `.' entry out of a dir.
-                */
-               ip->iso_start = ino >> imp->im_bshift;
+       if (isonum_733(isodir->extent) +
+           isonum_711(isodir->ext_attr_length) != ifhp->ifid_start) {
                if (bp != 0)



Home | Main Index | Thread Index | Old Index