On Sun, Mar 27, 2022 at 03:36:20PM +0200, Sebastien Marie wrote: > v_numoutput is a struct member of vnode which is used to keep track the > number > of writes in progress. > > in several function comments, it is marked as "Manipulates v_numoutput. Must > be > called at splbio()". > > So I added a "[B]" mark in the comment to properly document the need of > IPL_BIO > protection. > > Next, I audited the tree for usage. I found 2 occurrences of v_numoutput > (modification) without the required protection, inside dev/softraid.c. I > added > them. > > Comments or OK ?
Please move the declarations of `s' next to the other variable declarations at the starts of the functions. With that, OK visa@ > Index: dev/softraid.c > =================================================================== > RCS file: /cvs/src/sys/dev/softraid.c,v > retrieving revision 1.422 > diff -u -p -r1.422 softraid.c > --- dev/softraid.c 20 Mar 2022 13:14:02 -0000 1.422 > +++ dev/softraid.c 27 Mar 2022 13:28:55 -0000 > @@ -437,8 +437,12 @@ sr_rw(struct sr_softc *sc, dev_t dev, ch > b.b_resid = bufsize; > b.b_vp = vp; > > - if ((b.b_flags & B_READ) == 0) > + if ((b.b_flags & B_READ) == 0) { > + int s; > + s = splbio(); > vp->v_numoutput++; > + splx(s); > + } > > LIST_INIT(&b.b_dep); > VOP_STRATEGY(vp, &b); > @@ -2006,8 +2010,12 @@ sr_ccb_rw(struct sr_discipline *sd, int > 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)) { > + int s; > + s = splbio(); > ccb->ccb_buf.b_vp->v_numoutput++; > + splx(s); > + } > > LIST_INIT(&ccb->ccb_buf.b_dep); > > Index: sys/vnode.h > =================================================================== > RCS file: /cvs/src/sys/sys/vnode.h,v > retrieving revision 1.163 > diff -u -p -r1.163 vnode.h > --- sys/vnode.h 12 Dec 2021 09:14:59 -0000 1.163 > +++ sys/vnode.h 27 Mar 2022 13:28:56 -0000 > @@ -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) */ >