Source-Changes-HG archive

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

[src/trunk]: src/sys Need vnode locked fot VOP_FDISCARD().



details:   https://anonhg.NetBSD.org/src/rev/e4d0c1e4d935
branches:  trunk
changeset: 365759:e4d0c1e4d935
user:      hannken <hannken%NetBSD.org@localhost>
date:      Sat Apr 23 16:22:23 2022 +0000

description:
Need vnode locked fot VOP_FDISCARD().

diffstat:

 sys/dev/dkwedge/dk.c    |  12 +++++++++---
 sys/ufs/ffs/ffs_alloc.c |   6 ++++--
 2 files changed, 13 insertions(+), 5 deletions(-)

diffs (71 lines):

diff -r 38606a120aac -r e4d0c1e4d935 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Sat Apr 23 13:08:49 2022 +0000
+++ b/sys/dev/dkwedge/dk.c      Sat Apr 23 16:22:23 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.110 2022/01/15 19:34:11 riastradh Exp $       */
+/*     $NetBSD: dk.c,v 1.111 2022/04/23 16:22:23 hannken Exp $ */
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.110 2022/01/15 19:34:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.111 2022/04/23 16:22:23 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1592,6 +1592,7 @@
        struct dkwedge_softc *sc = dkwedge_lookup(dev);
        unsigned shift;
        off_t offset, maxlen;
+       int error;
 
        if (sc == NULL)
                return (ENODEV);
@@ -1615,7 +1616,12 @@
                return (EINVAL);
 
        pos += offset;
-       return VOP_FDISCARD(sc->sc_parent->dk_rawvp, pos, len);
+
+       vn_lock(sc->sc_parent->dk_rawvp, LK_EXCLUSIVE | LK_RETRY);
+       error = VOP_FDISCARD(sc->sc_parent->dk_rawvp, pos, len);
+       VOP_UNLOCK(sc->sc_parent->dk_rawvp);
+
+       return error;
 }
 
 /*
diff -r 38606a120aac -r e4d0c1e4d935 sys/ufs/ffs/ffs_alloc.c
--- a/sys/ufs/ffs/ffs_alloc.c   Sat Apr 23 13:08:49 2022 +0000
+++ b/sys/ufs/ffs/ffs_alloc.c   Sat Apr 23 16:22:23 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_alloc.c,v 1.170 2021/09/03 21:55:01 andvar Exp $   */
+/*     $NetBSD: ffs_alloc.c,v 1.171 2022/04/23 16:22:23 hannken Exp $  */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.170 2021/09/03 21:55:01 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.171 2022/04/23 16:22:23 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1649,10 +1649,12 @@
 
        start = FFS_FSBTOBYTES(fs, td->bno);
        len = td->size;
+       vn_lock(td->devvp, LK_EXCLUSIVE | LK_RETRY);
 #ifdef TRIMDEBUG
        error =
 #endif
                VOP_FDISCARD(td->devvp, start, len);
+       VOP_UNLOCK(td->devvp);
 #ifdef TRIMDEBUG
        printf("trim(%" PRId64 ",%ld):%d\n", td->bno, td->size, error);
 #endif



Home | Main Index | Thread Index | Old Index