Source-Changes-HG archive

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

[src/trunk]: src/sys Undo unlock/relock for VOP_IOCTL().



details:   https://anonhg.NetBSD.org/src/rev/943789ff04ed
branches:  trunk
changeset: 376389:943789ff04ed
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Jun 15 09:15:54 2023 +0000

description:
Undo unlock/relock for VOP_IOCTL().

PR kern/57450 (unplugging hung USB disk triggers panic via _vstate_assert)

diffstat:

 sys/dev/raidframe/rf_netbsdkintf.c |  10 +++-------
 sys/ufs/ffs/ffs_vfsops.c           |   8 ++------
 2 files changed, 5 insertions(+), 13 deletions(-)

diffs (102 lines):

diff -r ac98d83d302b -r 943789ff04ed sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Thu Jun 15 09:15:13 2023 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Thu Jun 15 09:15:54 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.411 2023/03/30 11:02:15 riastradh Exp $   */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.412 2023/06/15 09:15:54 hannken Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.411 2023/03/30 11:02:15 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.412 2023/06/15 09:15:54 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_raid_autoconfig.h"
@@ -2956,7 +2956,6 @@ rf_find_raid_components(void)
                                continue;
                        }
 
-                       VOP_UNLOCK(vp);
                        error = getdisksize(vp, &numsecs, &secsize);
                        if (error) {
                                /*
@@ -2968,7 +2967,6 @@ rf_find_raid_components(void)
                                        printf("RAIDframe: can't get disk size"
                                            " for dev %s (%d)\n",
                                            device_xname(dv), error);
-                               vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
                                VOP_CLOSE(vp, FREAD | FWRITE, NOCRED);
                                vput(vp);
                                continue;
@@ -2980,19 +2978,18 @@ rf_find_raid_components(void)
                                if (error) {
                                        printf("RAIDframe: can't get wedge info for "
                                            "dev %s (%d)\n", device_xname(dv), error);
-                                       vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
                                        VOP_CLOSE(vp, FREAD | FWRITE, NOCRED);
                                        vput(vp);
                                        continue;
                                }
 
                                if (strcmp(dkw.dkw_ptype, DKW_PTYPE_RAIDFRAME) != 0) {
-                                       vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
                                        VOP_CLOSE(vp, FREAD | FWRITE, NOCRED);
                                        vput(vp);
                                        continue;
                                }
 
+                               VOP_UNLOCK(vp);
                                ac_list = rf_get_component(ac_list, dev, vp,
                                    device_xname(dv), dkw.dkw_size, numsecs, secsize);
                                rf_part_found = 1; /*There is a raid component on this disk*/
@@ -3013,7 +3010,6 @@ rf_find_raid_components(void)
 
                        /* don't need this any more.  We'll allocate it again
                           a little later if we really do... */
-                       vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
                        VOP_CLOSE(vp, FREAD | FWRITE, NOCRED);
                        vput(vp);
 
diff -r ac98d83d302b -r 943789ff04ed sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c  Thu Jun 15 09:15:13 2023 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c  Thu Jun 15 09:15:54 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_vfsops.c,v 1.380 2023/06/05 04:59:46 rin Exp $     */
+/*     $NetBSD: ffs_vfsops.c,v 1.381 2023/06/15 09:15:54 hannken 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.380 2023/06/05 04:59:46 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.381 2023/06/15 09:15:54 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -2523,9 +2523,7 @@ ffs_vfs_fsync(vnode_t *vp, int flags)
                 * contains no dirty buffers that could be in the log.
                 */
                if (!LIST_EMPTY(&vp->v_dirtyblkhd)) {
-                       VOP_UNLOCK(vp);
                        error = wapbl_flush(mp->mnt_wapbl, 0);
-                       vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
                        if (error)
                                return error;
                }
@@ -2544,10 +2542,8 @@ ffs_vfs_fsync(vnode_t *vp, int flags)
        error = vflushbuf(vp, flags);
        if (error == 0 && (flags & FSYNC_CACHE) != 0) {
                i = 1;
-               VOP_UNLOCK(vp);
                (void)VOP_IOCTL(vp, DIOCCACHESYNC, &i, FWRITE,
                    kauth_cred_get());
-               vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
        }
 
        return error;



Home | Main Index | Thread Index | Old Index