Source-Changes-HG archive

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

[src/trunk]: src/sys Move pointer to fstrans private data into "struct lwp".



details:   https://anonhg.NetBSD.org/src/rev/930bdd0bdbc6
branches:  trunk
changeset: 449270:930bdd0bdbc6
user:      hannken <hannken%NetBSD.org@localhost>
date:      Fri Mar 01 09:02:03 2019 +0000

description:
Move pointer to fstrans private data into "struct lwp".

Ride NetBSD 8.99.35

diffstat:

 sys/kern/kern_exit.c |   8 ++++++--
 sys/kern/kern_lwp.c  |   8 ++++++--
 sys/kern/vfs_trans.c |  44 +++++++++++++++++++-------------------------
 sys/sys/fstrans.h    |   3 ++-
 sys/sys/lwp.h        |   3 ++-
 5 files changed, 35 insertions(+), 31 deletions(-)

diffs (256 lines):

diff -r dd51ce68ffac -r 930bdd0bdbc6 sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c      Fri Mar 01 08:17:51 2019 +0000
+++ b/sys/kern/kern_exit.c      Fri Mar 01 09:02:03 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exit.c,v 1.273 2018/11/29 12:37:22 maxv Exp $     */
+/*     $NetBSD: kern_exit.c,v 1.274 2019/03/01 09:02:03 hannken Exp $  */
 
 /*-
  * Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.273 2018/11/29 12:37:22 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.274 2019/03/01 09:02:03 hannken Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -84,6 +84,7 @@
 #include <sys/buf.h>
 #include <sys/wait.h>
 #include <sys/file.h>
+#include <sys/fstrans.h>
 #include <sys/vnode.h>
 #include <sys/syslog.h>
 #include <sys/pool.h>
@@ -400,6 +401,9 @@
        }
        fixjobc(p, p->p_pgrp, 0);
 
+       /* Release fstrans private data. */
+       fstrans_lwp_dtor(l);
+
        /*
         * Finalize the last LWP's specificdata, as well as the
         * specificdata for the proc itself.
diff -r dd51ce68ffac -r 930bdd0bdbc6 sys/kern/kern_lwp.c
--- a/sys/kern/kern_lwp.c       Fri Mar 01 08:17:51 2019 +0000
+++ b/sys/kern/kern_lwp.c       Fri Mar 01 09:02:03 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_lwp.c,v 1.195 2018/11/26 17:18:01 skrll Exp $     */
+/*     $NetBSD: kern_lwp.c,v 1.196 2019/03/01 09:02:03 hannken Exp $   */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -211,7 +211,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.195 2018/11/26 17:18:01 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.196 2019/03/01 09:02:03 hannken Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -236,6 +236,7 @@
 #include <sys/lwpctl.h>
 #include <sys/atomic.h>
 #include <sys/filedesc.h>
+#include <sys/fstrans.h>
 #include <sys/dtrace_bsd.h>
 #include <sys/sdt.h>
 #include <sys/xcall.h>
@@ -1093,6 +1094,9 @@
        /* Drop filedesc reference. */
        fd_free();
 
+       /* Release fstrans private data. */
+       fstrans_lwp_dtor(l);
+
        /* Delete the specificdata while it's still safe to sleep. */
        lwp_finispecific(l);
 
diff -r dd51ce68ffac -r 930bdd0bdbc6 sys/kern/vfs_trans.c
--- a/sys/kern/vfs_trans.c      Fri Mar 01 08:17:51 2019 +0000
+++ b/sys/kern/vfs_trans.c      Fri Mar 01 09:02:03 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_trans.c,v 1.56 2019/02/24 16:11:24 hannken Exp $   */
+/*     $NetBSD: vfs_trans.c,v 1.57 2019/03/01 09:02:03 hannken Exp $   */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.56 2019/02/24 16:11:24 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.57 2019/03/01 09:02:03 hannken Exp $");
 
 /*
  * File system transaction operations.
@@ -84,7 +84,6 @@
        struct mount *fmi_mount;
 };
 
-static specificdata_key_t lwp_data_key;        /* Our specific data key. */
 static kmutex_t vfs_suspend_lock;      /* Serialize suspensions. */
 static kmutex_t fstrans_lock;          /* Fstrans big lock. */
 static kmutex_t fstrans_mount_lock;    /* Fstrans mount big lock. */
@@ -95,7 +94,6 @@
                                        /* List of all fstrans_lwp_info. */
 static int fstrans_gone_count;         /* Number of fstrans_mount_info gone. */
 
-static void fstrans_lwp_dtor(void *);
 static void fstrans_mount_dtor(struct fstrans_mount_info *);
 static void fstrans_clear_lwp_info(void);
 static inline struct fstrans_lwp_info *
@@ -180,10 +178,6 @@
 void
 fstrans_init(void)
 {
-       int error __diagused;
-
-       error = lwp_specific_key_create(&lwp_data_key, fstrans_lwp_dtor);
-       KASSERT(error == 0);
 
        mutex_init(&vfs_suspend_lock, MUTEX_DEFAULT, IPL_NONE);
        mutex_init(&fstrans_lock, MUTEX_DEFAULT, IPL_NONE);
@@ -197,14 +191,15 @@
 /*
  * Deallocate lwp state.
  */
-static void
-fstrans_lwp_dtor(void *arg)
+void
+fstrans_lwp_dtor(lwp_t *l)
 {
        struct fstrans_lwp_info *fli, *fli_next;
 
-       for (fli = arg; fli; fli = fli_next) {
+       for (fli = l->l_fstrans; fli; fli = fli_next) {
                KASSERT(fli->fli_trans_cnt == 0);
                KASSERT(fli->fli_cow_cnt == 0);
+               KASSERT(fli->fli_self == l);
                if (fli->fli_mount != NULL)
                        fstrans_mount_dtor(fli->fli_mountinfo);
                fli_next = fli->fli_succ;
@@ -214,6 +209,8 @@
                membar_sync();
                fli->fli_self = NULL;
        }
+
+       l->l_fstrans = NULL;
 }
 
 /*
@@ -294,13 +291,12 @@
 static void
 fstrans_clear_lwp_info(void)
 {
-       struct fstrans_lwp_info *head, **p, *fli;
+       struct fstrans_lwp_info **p, *fli;
 
        /*
         * Scan our list clearing entries whose mount is gone.
         */
-       head = lwp_getspecific(lwp_data_key);
-       for (p = &head; *p; p = &(*p)->fli_succ) {
+       for (p = &curlwp->l_fstrans; *p; p = &(*p)->fli_succ) {
                fli = *p;
                if (fli->fli_mount != NULL &&
                    fli->fli_mountinfo->fmi_gone &&
@@ -317,7 +313,6 @@
                                break;
                }
        }
-       lwp_setspecific(lwp_data_key, head);
 }
 
 /*
@@ -329,7 +324,7 @@
        struct fstrans_lwp_info *fli, *fli2;
        struct fstrans_mount_info *fmi;
 
-       for (fli = lwp_getspecific(lwp_data_key); fli; fli = fli->fli_succ) {
+       for (fli = curlwp->l_fstrans; fli; fli = fli->fli_succ) {
                if (fli->fli_mount == mp)
                        return fli;
        }
@@ -345,8 +340,8 @@
                        KASSERT(fli->fli_trans_cnt == 0);
                        KASSERT(fli->fli_cow_cnt == 0);
                        fli->fli_self = curlwp;
-                       fli->fli_succ = lwp_getspecific(lwp_data_key);
-                       lwp_setspecific(lwp_data_key, fli);
+                       fli->fli_succ = curlwp->l_fstrans;
+                       curlwp->l_fstrans = fli;
                        break;
                }
        }
@@ -359,8 +354,8 @@
                fli->fli_self = curlwp;
                LIST_INSERT_HEAD(&fstrans_fli_head, fli, fli_list);
                mutex_exit(&fstrans_lock);
-               fli->fli_succ = lwp_getspecific(lwp_data_key);
-               lwp_setspecific(lwp_data_key, fli);
+               fli->fli_succ = curlwp->l_fstrans;
+               curlwp->l_fstrans = fli;
        }
 
        /*
@@ -393,17 +388,16 @@
 static inline struct fstrans_lwp_info *
 fstrans_get_lwp_info(struct mount *mp, bool do_alloc)
 {
-       struct fstrans_lwp_info *head, *fli, *fli2;
-
-       head = lwp_getspecific(lwp_data_key);
+       struct fstrans_lwp_info *fli, *fli2;
 
        /*
         * Scan our list for a match.
         */
-       for (fli = head; fli; fli = fli->fli_succ) {
+       for (fli = curlwp->l_fstrans; fli; fli = fli->fli_succ) {
                if (fli->fli_mount == mp) {
                        if (fli->fli_alias != NULL) {
-                               for (fli2 = head; fli2; fli2 = fli2->fli_succ) {
+                               for (fli2 = curlwp->l_fstrans; fli2;
+                                   fli2 = fli2->fli_succ) {
                                        if (fli2->fli_mount == fli->fli_alias)
                                                break;
                                }
diff -r dd51ce68ffac -r 930bdd0bdbc6 sys/sys/fstrans.h
--- a/sys/sys/fstrans.h Fri Mar 01 08:17:51 2019 +0000
+++ b/sys/sys/fstrans.h Fri Mar 01 09:02:03 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fstrans.h,v 1.12 2018/10/05 09:51:56 hannken Exp $     */
+/*     $NetBSD: fstrans.h,v 1.13 2019/03/01 09:02:03 hannken Exp $     */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -48,6 +48,7 @@
 };
 
 void   fstrans_init(void);
+void   fstrans_lwp_dtor(lwp_t *);
 void   fstrans_start(struct mount *);
 int    fstrans_start_nowait(struct mount *);
 void   fstrans_start_lazy(struct mount *);
diff -r dd51ce68ffac -r 930bdd0bdbc6 sys/sys/lwp.h
--- a/sys/sys/lwp.h     Fri Mar 01 08:17:51 2019 +0000
+++ b/sys/sys/lwp.h     Fri Mar 01 09:02:03 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lwp.h,v 1.180 2018/11/28 19:46:22 mlelstv Exp $        */
+/*     $NetBSD: lwp.h,v 1.181 2019/03/01 09:02:03 hannken Exp $        */
 
 /*
  * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010
@@ -180,6 +180,7 @@
        struct kauth_cred *l_cred;      /* !: cached credentials */
        struct filedesc *l_fd;          /* !: cached copy of proc::p_fd */
        void            *l_emuldata;    /* !: kernel lwp-private data */
+       struct fstrans_lwp_info *l_fstrans; /* (: fstrans private data */
        u_int           l_cv_signalled; /* c: restarted by cv_signal() */
        u_short         l_shlocks;      /* !: lockdebug: shared locks held */
        u_short         l_exlocks;      /* !: lockdebug: excl. locks held */



Home | Main Index | Thread Index | Old Index