Source-Changes-HG archive

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

[src/netbsd-8]: src Pull up following revision(s) (requested by maya in ticke...



details:   https://anonhg.NetBSD.org/src/rev/2e0d6ff8b3e5
branches:  netbsd-8
changeset: 851089:2e0d6ff8b3e5
user:      snj <snj%NetBSD.org@localhost>
date:      Mon Oct 30 09:29:04 2017 +0000

description:
Pull up following revision(s) (requested by maya in ticket #330):
        sbin/fsck_lfs/inode.c: 1.69
        sbin/fsck_lfs/lfs.c: 1.73
        sbin/fsck_lfs/pass6.c: 1.50
        sbin/fsck_lfs/segwrite.c: 1.46
        sys/ufs/lfs/lfs.h: 1.202-1.203
        sys/ufs/lfs/lfs_accessors.h: 1.48
        sys/ufs/lfs/lfs_alloc.c: 1.136-1.137
        sys/ufs/lfs/lfs_balloc.c: 1.94
        sys/ufs/lfs/lfs_bio.c: 1.141
        sys/ufs/lfs/lfs_extern.h: 1.113
        sys/ufs/lfs/lfs_inode.c: 1.156-1.157
        sys/ufs/lfs/lfs_inode.h: 1.20, 1.21, 1.23
        sys/ufs/lfs/lfs_itimes.c: 1.20
        sys/ufs/lfs/lfs_pages.c: 1.13-1.15
        sys/ufs/lfs/lfs_rename.c: 1.22
        sys/ufs/lfs/lfs_segment.c: 1.270-1.275
        sys/ufs/lfs/lfs_subr.c: 1.94-1.97
        sys/ufs/lfs/lfs_syscalls.c: 1.175
        sys/ufs/lfs/lfs_vfsops.c: 1.360
        sys/ufs/lfs/lfs_vnops.c: 1.316-1.321
        sys/ufs/lfs/ulfs_inode.c: 1.20
        sys/ufs/lfs/ulfs_inode.h: 1.24
        sys/ufs/lfs/ulfs_lookup.c: 1.41
        sys/ufs/lfs/ulfs_quota2.c: 1.31
        sys/ufs/lfs/ulfs_readwrite.c: 1.24
        sys/ufs/lfs/ulfs_vnops.c: 1.49-1.50
Update inode member i_flag --> i_state to keep up with kernel changes
Move definition of IN_ALLMOD near the flag it's a mask for.
Now we can see that it doesn't match all the flags, but changing that will
require more careful thought.
Correct confusion between i_flag and i_flags
These will have to be renamed.
Spotted by Riastradh, thanks!
Add an XXX about the missing flags so it's not buried in a commit
message.
now the XXX count for LFS is 260
Rename i_flag to i_state.
The similarity to i_flags has previously caused errors.
Use continue to denote the no-op loop to match netbsd style
newline for extra clarity.
It isn't safe to drain dirops with seglock held, it'll deadlock if there
are any dirops. drain before grabbing seglock.
lfs_dirops == 0 is always true (as we already drained dirops), so omit
that part of the comparison.
Fixes a lot of LFS deadlocks. PR kern/52301
Many thanks to dholland for help analyzing coredumps
Ifdef out KDASSERT which fires on my machine.
Deduplicate sanity check that seglock is held on segunlock
Revert r1.272 fix to PR kern/52301, the performance hit is making things
unusable.
change lfs_nextsegsleep and lfs_allclean_wakeup to use condvar
XXX had to use lfs_lock in lfs_segwait, removed kernel_lock, is this
appropriate?
fix buffer overflow/KASSERT when cookies are supplied
lfs no longer uses the ffs-style struct direct, use the correct minimum
size
from dholland
XXX more wrong
Consistently use {,UN}MARK_VNODE macros rather than function calls.
Not much point doing anything after a panic call
Ask some question about the code in a XXX comment
XXX question our double-flushing of dirops
Fix typo in comment

diffstat:

 sbin/fsck_lfs/inode.c        |   4 +-
 sbin/fsck_lfs/lfs.c          |  10 ++--
 sbin/fsck_lfs/pass6.c        |   4 +-
 sbin/fsck_lfs/segwrite.c     |   4 +-
 sys/ufs/lfs/lfs.h            |  11 +-----
 sys/ufs/lfs/lfs_accessors.h  |  30 ++++++++--------
 sys/ufs/lfs/lfs_alloc.c      |  10 ++--
 sys/ufs/lfs/lfs_balloc.c     |   8 ++--
 sys/ufs/lfs/lfs_bio.c        |  10 ++--
 sys/ufs/lfs/lfs_extern.h     |   4 +-
 sys/ufs/lfs/lfs_inode.c      |  26 +++++++-------
 sys/ufs/lfs/lfs_inode.h      |  39 ++++++++++++----------
 sys/ufs/lfs/lfs_itimes.c     |  20 +++++-----
 sys/ufs/lfs/lfs_pages.c      |  23 +++++++-----
 sys/ufs/lfs/lfs_rename.c     |  16 ++++----
 sys/ufs/lfs/lfs_segment.c    |  41 +++++++++++++----------
 sys/ufs/lfs/lfs_subr.c       |  22 ++++++-----
 sys/ufs/lfs/lfs_syscalls.c   |  10 ++--
 sys/ufs/lfs/lfs_vfsops.c     |  14 ++++++-
 sys/ufs/lfs/lfs_vnops.c      |  76 ++++++++++++++++++++-----------------------
 sys/ufs/lfs/ulfs_inode.c     |   8 ++--
 sys/ufs/lfs/ulfs_inode.h     |   4 +-
 sys/ufs/lfs/ulfs_lookup.c    |  22 ++++++------
 sys/ufs/lfs/ulfs_quota2.c    |   6 +-
 sys/ufs/lfs/ulfs_readwrite.c |  10 ++--
 sys/ufs/lfs/ulfs_vnops.c     |  38 +++++++++++-----------
 26 files changed, 241 insertions(+), 229 deletions(-)

diffs (truncated from 1663 to 300 lines):

diff -r 1b78f211a9be -r 2e0d6ff8b3e5 sbin/fsck_lfs/inode.c
--- a/sbin/fsck_lfs/inode.c     Wed Oct 25 07:19:29 2017 +0000
+++ b/sbin/fsck_lfs/inode.c     Mon Oct 30 09:29:04 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inode.c,v 1.68 2015/09/21 01:24:23 dholland Exp $   */
+/* $NetBSD: inode.c,v 1.68.8.1 2017/10/30 09:29:04 snj Exp $    */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -436,7 +436,7 @@
 void
 inodirty(struct inode *ip)
 {
-       ip->i_flag |= IN_MODIFIED;
+       ip->i_state |= IN_MODIFIED;
 }
 
 void
diff -r 1b78f211a9be -r 2e0d6ff8b3e5 sbin/fsck_lfs/lfs.c
--- a/sbin/fsck_lfs/lfs.c       Wed Oct 25 07:19:29 2017 +0000
+++ b/sbin/fsck_lfs/lfs.c       Mon Oct 30 09:29:04 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.72 2016/09/16 11:13:47 christos Exp $ */
+/* $NetBSD: lfs.c,v 1.72.6.1 2017/10/30 09:29:04 snj Exp $ */
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -366,7 +366,7 @@
        ip->i_number = ino;
        ip->i_lockf = 0;
        ip->i_lfs_effnblks = 0;
-       ip->i_flag = 0;
+       ip->i_state = 0;
 
        /* Load inode block and find inode */
        if (daddr > 0) {
@@ -952,7 +952,7 @@
        lfs_balloc(vp, lfs_dino_getsize(fs, ip->i_din), lfs_sb_getbsize(fs), &bp);
        lfs_dino_setsize(fs, ip->i_din,
            lfs_dino_getsize(fs, ip->i_din) + lfs_sb_getbsize(fs));
-       ip->i_flag |= IN_MODIFIED;
+       ip->i_state |= IN_MODIFIED;
        
        i = (blkno - lfs_sb_getsegtabsz(fs) - lfs_sb_getcleansz(fs)) *
                lfs_sb_getifpb(fs);
@@ -1058,7 +1058,7 @@
                                                    (bpp ? &bp : NULL))))
                                return (error);
                        lfs_dino_setsize(fs, ip->i_din, (lastblock + 1) * lfs_sb_getbsize(fs));
-                       ip->i_flag |= IN_CHANGE | IN_UPDATE;
+                       ip->i_state |= IN_CHANGE | IN_UPDATE;
                        if (bpp)
                                (void) VOP_BWRITE(bp);
                }
@@ -1252,7 +1252,7 @@
 
        lfs_sb_subbfree(fs, frags);
        ip->i_lfs_effnblks += frags;
-       ip->i_flag |= IN_CHANGE | IN_UPDATE;
+       ip->i_state |= IN_CHANGE | IN_UPDATE;
 
        if (bpp) {
                (*bpp)->b_data = erealloc((*bpp)->b_data, nsize);
diff -r 1b78f211a9be -r 2e0d6ff8b3e5 sbin/fsck_lfs/pass6.c
--- a/sbin/fsck_lfs/pass6.c     Wed Oct 25 07:19:29 2017 +0000
+++ b/sbin/fsck_lfs/pass6.c     Mon Oct 30 09:29:04 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass6.c,v 1.49 2015/10/03 08:29:21 dholland Exp $   */
+/* $NetBSD: pass6.c,v 1.49.8.1 2017/10/30 09:29:04 snj Exp $    */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
        u_int32_t oldsn, sn;
 
        ip = VTOI(vp);
-       ip->i_flag |= IN_MODIFIED;
+       ip->i_state |= IN_MODIFIED;
 
        error = ulfs_bmaparray(fs, vp, lbn, &daddr, a, &num);
        if (error)
diff -r 1b78f211a9be -r 2e0d6ff8b3e5 sbin/fsck_lfs/segwrite.c
--- a/sbin/fsck_lfs/segwrite.c  Wed Oct 25 07:19:29 2017 +0000
+++ b/sbin/fsck_lfs/segwrite.c  Mon Oct 30 09:29:04 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: segwrite.c,v 1.45 2015/10/03 08:28:15 dholland Exp $ */
+/* $NetBSD: segwrite.c,v 1.45.8.1 2017/10/30 09:29:04 snj Exp $ */
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -1027,7 +1027,7 @@
                /*
                 * Write the inode/file if dirty and it's not the IFILE.
                 */
-               if (ip->i_flag & IN_ALLMOD || !LIST_EMPTY(&vp->v_dirtyblkhd)) {
+               if (ip->i_state & IN_ALLMOD || !LIST_EMPTY(&vp->v_dirtyblkhd)) {
                        if (ip->i_number != LFS_IFILE_INUM)
                                lfs_writefile(fs, sp, vp);
                        (void) lfs_writeinode(fs, sp, ip);
diff -r 1b78f211a9be -r 2e0d6ff8b3e5 sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Wed Oct 25 07:19:29 2017 +0000
+++ b/sys/ufs/lfs/lfs.h Mon Oct 30 09:29:04 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs.h,v 1.201 2017/04/01 14:43:00 maya Exp $   */
+/*     $NetBSD: lfs.h,v 1.201.6.1 2017/10/30 09:29:04 snj Exp $        */
 
 /*  from NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp  */
 /*  from NetBSD: dir.h,v 1.25 2015/09/01 06:16:03 dholland Exp  */
@@ -511,13 +511,6 @@
 #define LFS_UNUSED_LBN -1
 
 /*
- * "struct inode" associated definitions
- */
-
-/* For convenience */
-#define IN_ALLMOD (IN_MODIFIED|IN_ACCESS|IN_CHANGE|IN_UPDATE|IN_MODIFY|IN_ACCESSED|IN_CLEANING)
-
-/*
  * On-disk and in-memory checkpoint segment usage structure.
  */
 typedef struct segusage SEGUSE;
@@ -1054,7 +1047,7 @@
        /* XXX: should be replaced with a condvar */
        int lfs_availsleep;
        /* This one replaces &lfs_nextseg... all ditto */
-       int lfs_nextsegsleep;
+       kcondvar_t lfs_nextsegsleep;
 
        /* Cleaner lwp, set on first bmapv syscall. */
        struct lwp *lfs_cleaner_thread;
diff -r 1b78f211a9be -r 2e0d6ff8b3e5 sys/ufs/lfs/lfs_accessors.h
--- a/sys/ufs/lfs/lfs_accessors.h       Wed Oct 25 07:19:29 2017 +0000
+++ b/sys/ufs/lfs/lfs_accessors.h       Mon Oct 30 09:29:04 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_accessors.h,v 1.47 2017/01/12 18:40:02 christos Exp $      */
+/*     $NetBSD: lfs_accessors.h,v 1.47.8.1 2017/10/30 09:29:04 snj Exp $       */
 
 /*  from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp  */
 /*  from NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp  */
@@ -619,31 +619,31 @@
  * "struct inode" associated definitions
  */
 
-#define LFS_SET_UINO(ip, flags) do {                                   \
-       if (((flags) & IN_ACCESSED) && !((ip)->i_flag & IN_ACCESSED))   \
+#define LFS_SET_UINO(ip, states) do {                                  \
+       if (((states) & IN_ACCESSED) && !((ip)->i_state & IN_ACCESSED)) \
                lfs_sb_adduinodes((ip)->i_lfs, 1);                      \
-       if (((flags) & IN_CLEANING) && !((ip)->i_flag & IN_CLEANING))   \
+       if (((states) & IN_CLEANING) && !((ip)->i_state & IN_CLEANING)) \
                lfs_sb_adduinodes((ip)->i_lfs, 1);                      \
-       if (((flags) & IN_MODIFIED) && !((ip)->i_flag & IN_MODIFIED))   \
+       if (((states) & IN_MODIFIED) && !((ip)->i_state & IN_MODIFIED)) \
                lfs_sb_adduinodes((ip)->i_lfs, 1);                      \
-       (ip)->i_flag |= (flags);                                        \
+       (ip)->i_state |= (states);                                      \
 } while (0)
 
-#define LFS_CLR_UINO(ip, flags) do {                                   \
-       if (((flags) & IN_ACCESSED) && ((ip)->i_flag & IN_ACCESSED))    \
+#define LFS_CLR_UINO(ip, states) do {                                  \
+       if (((states) & IN_ACCESSED) && ((ip)->i_state & IN_ACCESSED))  \
                lfs_sb_subuinodes((ip)->i_lfs, 1);                      \
-       if (((flags) & IN_CLEANING) && ((ip)->i_flag & IN_CLEANING))    \
+       if (((states) & IN_CLEANING) && ((ip)->i_state & IN_CLEANING))  \
                lfs_sb_subuinodes((ip)->i_lfs, 1);                      \
-       if (((flags) & IN_MODIFIED) && ((ip)->i_flag & IN_MODIFIED))    \
+       if (((states) & IN_MODIFIED) && ((ip)->i_state & IN_MODIFIED))  \
                lfs_sb_subuinodes((ip)->i_lfs, 1);                      \
-       (ip)->i_flag &= ~(flags);                                       \
+       (ip)->i_state &= ~(states);                                     \
        if (lfs_sb_getuinodes((ip)->i_lfs) < 0) {                       \
                panic("lfs_uinodes < 0");                               \
        }                                                               \
 } while (0)
 
 #define LFS_ITIMES(ip, acc, mod, cre) \
-       while ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \
+       while ((ip)->i_state & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \
                lfs_itimes(ip, acc, mod, cre)
 
 /*
@@ -672,7 +672,7 @@
 #define        LFS_SEGENTRY(SP, F, IN, BP) do {                                \
        int _e;                                                         \
        SHARE_IFLOCK(F);                                                \
-       VTOI((F)->lfs_ivnode)->i_flag |= IN_ACCESS;                     \
+       VTOI((F)->lfs_ivnode)->i_state |= IN_ACCESS;                    \
        if ((_e = bread((F)->lfs_ivnode,                                \
            ((IN) / lfs_sb_getsepb(F)) + lfs_sb_getcleansz(F),          \
            lfs_sb_getbsize(F), 0, &(BP))) != 0)                        \
@@ -825,7 +825,7 @@
 #define        LFS_IENTRY(IP, F, IN, BP) do {                                  \
        int _e;                                                         \
        SHARE_IFLOCK(F);                                                \
-       VTOI((F)->lfs_ivnode)->i_flag |= IN_ACCESS;                     \
+       VTOI((F)->lfs_ivnode)->i_state |= IN_ACCESS;                    \
        if ((_e = bread((F)->lfs_ivnode,                                \
        (IN) / lfs_sb_getifpb(F) + lfs_sb_getcleansz(F) + lfs_sb_getsegtabsz(F), \
        lfs_sb_getbsize(F), 0, &(BP))) != 0)                            \
@@ -941,7 +941,7 @@
 #define LFS_CLEANERINFO(CP, F, BP) do {                                        \
        int _e;                                                         \
        SHARE_IFLOCK(F);                                                \
-       VTOI((F)->lfs_ivnode)->i_flag |= IN_ACCESS;                     \
+       VTOI((F)->lfs_ivnode)->i_state |= IN_ACCESS;                    \
        _e = bread((F)->lfs_ivnode,                                     \
            (daddr_t)0, lfs_sb_getbsize(F), 0, &(BP));                  \
        if (_e)                                                         \
diff -r 1b78f211a9be -r 2e0d6ff8b3e5 sys/ufs/lfs/lfs_alloc.c
--- a/sys/ufs/lfs/lfs_alloc.c   Wed Oct 25 07:19:29 2017 +0000
+++ b/sys/ufs/lfs/lfs_alloc.c   Mon Oct 30 09:29:04 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_alloc.c,v 1.135 2017/03/13 20:15:50 maya Exp $     */
+/*     $NetBSD: lfs_alloc.c,v 1.135.6.1 2017/10/30 09:29:04 snj Exp $  */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.135 2017/03/13 20:15:50 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.135.6.1 2017/10/30 09:29:04 snj Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -506,11 +506,11 @@
        /*
         * If the inode was in a dirop, it isn't now.
         *
-        * XXX: why are (v_uflag & VU_DIROP) and (ip->i_flag & IN_ADIROP)
+        * XXX: why are (v_uflag & VU_DIROP) and (ip->i_state & IN_ADIROP)
         * not updated together in one function? (and why do both exist,
         * anyway?)
         */
-       lfs_unmark_vnode(vp);
+       UNMARK_VNODE(vp);
 
        mutex_enter(&lfs_lock);
        if (vp->v_uflag & VU_DIROP) {
@@ -551,7 +551,7 @@
        mutex_exit(&lfs_lock);
 
        /* Turn off all inode modification flags */
-       ip->i_flag &= ~IN_ALLMOD;
+       ip->i_state &= ~IN_ALLMOD;
 
        /* Mark it deleted */
        ip->i_lfs_iflags |= LFSI_DELETED;
diff -r 1b78f211a9be -r 2e0d6ff8b3e5 sys/ufs/lfs/lfs_balloc.c
--- a/sys/ufs/lfs/lfs_balloc.c  Wed Oct 25 07:19:29 2017 +0000
+++ b/sys/ufs/lfs/lfs_balloc.c  Mon Oct 30 09:29:04 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_balloc.c,v 1.92 2017/04/06 02:38:08 maya Exp $     */
+/*     $NetBSD: lfs_balloc.c,v 1.92.6.1 2017/10/30 09:29:04 snj 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_balloc.c,v 1.92 2017/04/06 02:38:08 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.92.6.1 2017/10/30 09:29:04 snj Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -194,7 +194,7 @@
                        ip->i_size = (lastblock + 1) * lfs_sb_getbsize(fs);
                        lfs_dino_setsize(fs, ip->i_din, ip->i_size);
                        uvm_vnp_setsize(vp, ip->i_size);
-                       ip->i_flag |= IN_CHANGE | IN_UPDATE;
+                       ip->i_state |= IN_CHANGE | IN_UPDATE;
                        /* if we got a buffer for this, write it out now */
                        if (bpp)
                                (void) VOP_BWRITE(bp->b_vp, bp);
@@ -580,7 +580,7 @@
        /* increase the file's effective block count */
        ip->i_lfs_effnblks += frags;
        /* mark the inode dirty */
-       ip->i_flag |= IN_CHANGE | IN_UPDATE;
+       ip->i_state |= IN_CHANGE | IN_UPDATE;
 
        if (bpp) {
                obufsize = (*bpp)->b_bufsize;
diff -r 1b78f211a9be -r 2e0d6ff8b3e5 sys/ufs/lfs/lfs_bio.c
--- a/sys/ufs/lfs/lfs_bio.c     Wed Oct 25 07:19:29 2017 +0000
+++ b/sys/ufs/lfs/lfs_bio.c     Mon Oct 30 09:29:04 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_bio.c,v 1.139 2017/04/17 08:32:01 hannken Exp $    */
+/*     $NetBSD: lfs_bio.c,v 1.139.4.1 2017/10/30 09:29:04 snj Exp $    */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2008 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>



Home | Main Index | Thread Index | Old Index