Source-Changes-HG archive

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

[src/netbsd-7]: src/sys/ufs Pull up following revision(s) (requested by chris...



details:   https://anonhg.NetBSD.org/src/rev/462fd59fbe54
branches:  netbsd-7
changeset: 798916:462fd59fbe54
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Jan 28 18:34:11 2015 +0000

description:
Pull up following revision(s) (requested by christos in ticket #425):
        sys/ufs/ufs/ufs_inode.c: revision 1.91-1.92
        sys/ufs/ufs/ufs_vnops.c: revision 1.223-1.224
        sys/ufs/ufs/ufs_extern.h: revision 1.76-1.77
        sys/ufs/ffs/ffs_vfsops.c: revision 1.303-1.305
Add debugging for mount...
Merge some error returns
Check more errors
Restore apple ufs error handling.
Move and unify indirect block truncate algorithm into a separate function.
PR/39371: Tobias Nygren: Don't fail mounting root if WAPBL log is corrupt.
Patch from Sergio L. Pascual.

diffstat:

 sys/ufs/ffs/ffs_vfsops.c |  201 ++++++++++++++++++++++++++++++++++------------
 sys/ufs/ufs/ufs_extern.h |    3 +-
 sys/ufs/ufs/ufs_inode.c  |  101 ++++++++++++----------
 sys/ufs/ufs/ufs_vnops.c  |   38 +--------
 4 files changed, 208 insertions(+), 135 deletions(-)

diffs (truncated from 695 to 300 lines):

diff -r ee60397240cf -r 462fd59fbe54 sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c  Wed Jan 28 11:28:32 2015 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c  Wed Jan 28 18:34:11 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_vfsops.c,v 1.299.2.2 2014/12/29 16:28:14 martin Exp $      */
+/*     $NetBSD: ffs_vfsops.c,v 1.299.2.3 2015/01/28 18:34:11 martin Exp $      */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.299.2.2 2014/12/29 16:28:14 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.299.2.3 2015/01/28 18:34:11 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -120,6 +120,12 @@
 /* how many times ffs_init() was called */
 int ffs_initcount = 0;
 
+#ifdef DEBUG_FFS_MOUNT
+#define DPRINTF(a)     printf a
+#else
+#define DPRINTF(a)     do {} while (/*CONSTCOND*/0)
+#endif
+
 extern const struct vnodeopv_desc ffs_vnodeop_opv_desc;
 extern const struct vnodeopv_desc ffs_specop_opv_desc;
 extern const struct vnodeopv_desc ffs_fifoop_opv_desc;
@@ -346,15 +352,22 @@
        int error = 0, flags, update;
        mode_t accessmode;
 
-       if (args == NULL)
+       if (args == NULL) {
+               DPRINTF(("%s: NULL args\n", __func__));
                return EINVAL;
-       if (*data_len < sizeof *args)
+       }
+       if (*data_len < sizeof(*args)) {
+               DPRINTF(("%s: bad size args %zu != %zu\n",
+                   __func__, *data_len, sizeof(*args)));
                return EINVAL;
+       }
 
        if (mp->mnt_flag & MNT_GETARGS) {
                ump = VFSTOUFS(mp);
-               if (ump == NULL)
+               if (ump == NULL) {
+                       DPRINTF(("%s: no ump\n", __func__));
                        return EIO;
+               }
                args->fspec = NULL;
                *data_len = sizeof *args;
                return 0;
@@ -368,18 +381,26 @@
                 * Look up the name and verify that it's sane.
                 */
                error = namei_simple_user(args->fspec,
-                                       NSM_FOLLOW_NOEMULROOT, &devvp);
-               if (error != 0)
-                       return (error);
+                   NSM_FOLLOW_NOEMULROOT, &devvp);
+               if (error != 0) {
+                       DPRINTF(("%s: namei_simple_user %d\n", __func__,
+                           error));
+                       return error;
+               }
 
                if (!update) {
                        /*
                         * Be sure this is a valid block device
                         */
-                       if (devvp->v_type != VBLK)
+                       if (devvp->v_type != VBLK) {
+                               DPRINTF(("%s: non block device %d\n",
+                                   __func__, devvp->v_type));
                                error = ENOTBLK;
-                       else if (bdevsw_lookup(devvp->v_rdev) == NULL)
+                       } else if (bdevsw_lookup(devvp->v_rdev) == NULL) {
+                               DPRINTF(("%s: can't find block device 0x%jx\n",
+                                   __func__, devvp->v_rdev));
                                error = ENXIO;
+                       }
                } else {
                        /*
                         * Be sure we're still naming the same device
@@ -387,9 +408,13 @@
                         */
                        ump = VFSTOUFS(mp);
                        if (devvp != ump->um_devvp) {
-                               if (devvp->v_rdev != ump->um_devvp->v_rdev)
+                               if (devvp->v_rdev != ump->um_devvp->v_rdev) {
+                                       DPRINTF(("%s: wrong device 0x%jx"
+                                           " != 0x%jx\n", __func__,
+                                           (uintmax_t)devvp->v_rdev,
+                                           (uintmax_t)ump->um_devvp->v_rdev));
                                        error = EINVAL;
-                               else {
+                               } else {
                                        vrele(devvp);
                                        devvp = ump->um_devvp;
                                        vref(devvp);
@@ -399,7 +424,8 @@
        } else {
                if (!update) {
                        /* New mounts must have a filename for the device */
-                       return (EINVAL);
+                       DPRINTF(("%s: no filename for mount\n", __func__));
+                       return EINVAL;
                } else {
                        /* Use the extant mount */
                        ump = VFSTOUFS(mp);
@@ -426,6 +452,9 @@
                error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_MOUNT,
                    KAUTH_REQ_SYSTEM_MOUNT_DEVICE, mp, devvp,
                    KAUTH_ARG(accessmode));
+               if (error) {
+                       DPRINTF(("%s: kauth %d\n", __func__, error));
+               }
                VOP_UNLOCK(devvp);
        }
 
@@ -453,10 +482,13 @@
                vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
                error = VOP_OPEN(devvp, xflags, FSCRED);
                VOP_UNLOCK(devvp);
-               if (error)
+               if (error) {    
+                       DPRINTF(("%s: VOP_OPEN %d\n", __func__, error));
                        goto fail;
+               }
                error = ffs_mountfs(devvp, mp, l);
                if (error) {
+                       DPRINTF(("%s: ffs_mountfs %d\n", __func__, error));
                        vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
                        (void)VOP_CLOSE(devvp, xflags, NOCRED);
                        VOP_UNLOCK(devvp);
@@ -497,17 +529,21 @@
                                fs->fs_clean = FS_ISCLEAN;
                                (void) ffs_sbupdate(ump, MNT_WAIT);
                        }
-                       if (error == 0)
-                               UFS_WAPBL_END(mp);
-                       if (error)
-                               return (error);
+                       if (error) {
+                               DPRINTF(("%s: wapbl %d\n", __func__, error));
+                               return error;
+                       }
+                       UFS_WAPBL_END(mp);
                }
 
 #ifdef WAPBL
                if ((mp->mnt_flag & MNT_LOG) == 0) {
                        error = ffs_wapbl_stop(mp, mp->mnt_flag & MNT_FORCE);
-                       if (error)
+                       if (error) {
+                               DPRINTF(("%s: ffs_wapbl_stop %d\n",
+                                   __func__, error));
                                return error;
+                       }
                }
 #endif /* WAPBL */
 
@@ -521,8 +557,11 @@
 
                if (mp->mnt_flag & MNT_RELOAD) {
                        error = ffs_reload(mp, l->l_cred, l);
-                       if (error)
-                               return (error);
+                       if (error) {
+                               DPRINTF(("%s: ffs_reload %d\n",
+                                   __func__, error));
+                               return error;
+                       }
                }
 
                if (fs->fs_ronly && (mp->mnt_iflag & IMNT_WANTRDWR)) {
@@ -536,6 +575,8 @@
                                    mp->mnt_stat.f_mntonname,
                                    (mp->mnt_flag & MNT_FORCE) ? "" :
                                    ", not mounting");
+                               DPRINTF(("%s: ffs_quota2 %d\n",
+                                   __func__, EINVAL));
                                return EINVAL;
                        }
 #endif
@@ -544,12 +585,19 @@
                        fs->fs_fmod = 1;
 #ifdef WAPBL
                        if (fs->fs_flags & FS_DOWAPBL) {
-                               printf("%s: replaying log to disk\n",
-                                   mp->mnt_stat.f_mntonname);
-                               KDASSERT(mp->mnt_wapbl_replay);
+                               const char *nm = mp->mnt_stat.f_mntonname;
+                               if (!mp->mnt_wapbl_replay) {
+                                       printf("%s: log corrupted;"
+                                           " replay cancelled\n", nm);
+                                       return EFTYPE;
+                               }
+                               printf("%s: replaying log to disk\n", nm);
                                error = wapbl_replay_write(mp->mnt_wapbl_replay,
-                                                          devvp);
+                                   devvp);
                                if (error) {
+                                       DPRINTF((
+                                           "%s: %s: wapbl_replay_write %d\n",
+                                           __func__, nm, error));
                                        return error;
                                }
                                wapbl_replay_stop(mp->mnt_wapbl_replay);
@@ -562,14 +610,19 @@
 
 #ifdef WAPBL
                error = ffs_wapbl_start(mp);
-               if (error)
+               if (error) {
+                       DPRINTF(("%s: ffs_wapbl_start %d\n",
+                           __func__, error));
                        return error;
+               }
 #endif /* WAPBL */
 
 #ifdef QUOTA2
                if (!fs->fs_ronly) {
                        error = ffs_quota2_mount(mp);
                        if (error) {
+                               DPRINTF(("%s: ffs_quota2_mount %d\n",
+                                   __func__, error));
                                return error;
                        }
                }
@@ -587,6 +640,9 @@
        if (error == 0)
                (void)strncpy(fs->fs_fsmnt, mp->mnt_stat.f_mntonname,
                    sizeof(fs->fs_fsmnt));
+       else {
+           DPRINTF(("%s: set_statvfs_info %d\n", __func__, error));
+       }
        fs->fs_flags &= ~FS_DOSOFTDEP;
        if (fs->fs_fmod != 0) { /* XXX */
                int err;
@@ -722,10 +778,11 @@
                 * EINVAL is most probably a blocksize or alignment problem,
                 * it is unlikely that this is an Apple UFS filesystem then.
                 */
-               error = bread(devvp, (daddr_t)(APPLEUFS_LABEL_OFFSET / DEV_BSIZE),
-                       APPLEUFS_LABEL_SIZE, cred, 0, &bp);
+               error = bread(devvp,
+                   (daddr_t)(APPLEUFS_LABEL_OFFSET / DEV_BSIZE),
+                   APPLEUFS_LABEL_SIZE, cred, 0, &bp);
                if (error && error != EINVAL) {
-                       return (error);
+                       return error;
                }
                if (error == 0) {
                        error = ffs_appleufs_validate(fs->fs_fsmnt,
@@ -877,8 +934,10 @@
        vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
        error = vinvalbuf(devvp, V_SAVE, cred, l, 0, 0);
        VOP_UNLOCK(devvp);
-       if (error)
-               return (error);
+       if (error) {
+               DPRINTF(("%s: vinvalbuf %d\n", __func__, error));
+               return error;
+       }
 
        ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
 
@@ -889,14 +948,18 @@
        fstype = 0;
 
        error = fstrans_mount(mp);
-       if (error)
+       if (error) {
+               DPRINTF(("%s: fstrans_mount %d\n", __func__, error));
                return error;
+       }
 
        ump = kmem_zalloc(sizeof(*ump), KM_SLEEP);
        mutex_init(&ump->um_lock, MUTEX_DEFAULT, IPL_NONE);
        error = ffs_snapshot_init(ump);
-       if (error)
+       if (error) {
+               DPRINTF(("%s: ffs_snapshot_init %d\n", __func__, error));
                goto out;
+       }
        ump->um_ops = &ffs_ufsops;
 
 #ifdef WAPBL
@@ -911,18 +974,22 @@
                        bp = NULL;
                }
                if (sblock_try[i] == -1) {
+                       DPRINTF(("%s: sblock_try\n", __func__));
                        error = EINVAL;



Home | Main Index | Thread Index | Old Index