diff options
author | Sebastien Marie <semarie@cvs.openbsd.org> | 2022-04-12 14:34:12 +0000 |
---|---|---|
committer | Sebastien Marie <semarie@cvs.openbsd.org> | 2022-04-12 14:34:12 +0000 |
commit | 12924cec7d1149d3722bcca9474d242cd82e0af0 (patch) | |
tree | 8f876d084c5159a0ca500a3a5f906a3280954b43 | |
parent | 0514e666eb89fe7d0e3a716c54cf6ed338fd1ec3 (diff) |
struct vnode: document the protection required for manipulating v_numoutput
correct sr_rw() and sr_ccb_rw() to properly manipulate v_numoutput under splbio.
ok visa@
-rw-r--r-- | sys/dev/softraid.c | 14 | ||||
-rw-r--r-- | sys/sys/vnode.h | 5 |
2 files changed, 14 insertions, 5 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 735a61e078e..607989f7069 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.423 2022/04/06 18:59:27 naddy Exp $ */ +/* $OpenBSD: softraid.c,v 1.424 2022/04/12 14:34:11 semarie Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -404,6 +404,7 @@ sr_rw(struct sr_softc *sc, dev_t dev, char *buf, size_t size, daddr_t blkno, size_t bufsize, dma_bufsize; int rv = 1; char *dma_buf; + int s; DNPRINTF(SR_D_MISC, "%s: sr_rw(0x%x, %p, %zu, %lld 0x%lx)\n", DEVNAME(sc), dev, buf, size, (long long)blkno, flags); @@ -437,8 +438,11 @@ sr_rw(struct sr_softc *sc, dev_t dev, char *buf, size_t size, daddr_t blkno, b.b_resid = bufsize; b.b_vp = vp; - if ((b.b_flags & B_READ) == 0) + if ((b.b_flags & B_READ) == 0) { + s = splbio(); vp->v_numoutput++; + splx(s); + } LIST_INIT(&b.b_dep); VOP_STRATEGY(vp, &b); @@ -1980,6 +1984,7 @@ sr_ccb_rw(struct sr_discipline *sd, int chunk, daddr_t blkno, { struct sr_chunk *sc = sd->sd_vol.sv_chunks[chunk]; struct sr_ccb *ccb = NULL; + int s; ccb = sr_ccb_get(sd); if (ccb == NULL) @@ -2006,8 +2011,11 @@ sr_ccb_rw(struct sr_discipline *sd, int chunk, daddr_t blkno, ccb->ccb_buf.b_vp = sc->src_vn; ccb->ccb_buf.b_bq = NULL; - if (!ISSET(ccb->ccb_buf.b_flags, B_READ)) + if (!ISSET(ccb->ccb_buf.b_flags, B_READ)) { + s = splbio(); ccb->ccb_buf.b_vp->v_numoutput++; + splx(s); + } LIST_INIT(&ccb->ccb_buf.b_dep); diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index f7dc8d8bc36..0ba69cdb12e 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.164 2022/03/27 16:19:39 semarie Exp $ */ +/* $OpenBSD: vnode.h,v 1.165 2022/04/12 14:34:11 semarie Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -89,6 +89,7 @@ RBT_HEAD(namecache_rb_cache, namecache); * Locks used to protect struct members in struct vnode: * a atomic * V vnode_mtx + * B IPL_BIO */ struct uvm_vnode; struct vnode { @@ -113,7 +114,7 @@ struct vnode { struct buf_rb_bufs v_bufs_tree; /* lookup of all bufs */ struct buflists v_cleanblkhd; /* clean blocklist head */ struct buflists v_dirtyblkhd; /* dirty blocklist head */ - u_int v_numoutput; /* num of writes in progress */ + u_int v_numoutput; /* [B] num of writes in progress */ LIST_ENTRY(vnode) v_synclist; /* vnode with dirty buffers */ union { struct mount *vu_mountedhere;/* ptr to mounted vfs (VDIR) */ |