fix for per-mount i/o counting in ffs

Bruce Evans brde at optusnet.com.au
Thu May 19 00:24:04 UTC 2016


On Thu, 19 May 2016, Bruce Evans wrote:

>  ...
> I think the following works to prevent multiple mounts via all of the
> known buggy paths: early in every fsmount():
>
> 	dev = devvp->v_rdev;
> 	if (dev->si_mountpt != NULL) {
> 		cleanup();
> 		return (EBUSY);
> 	}
> 	dev->si_mountpt = mp;
>
> This also prevents other mounts racing with us before we complete.  Too
> bad if we fail but the other mount would have succeeded.  In fsunmount(),
> move clearing si_mountpt to near the end.  I hope si_mountpt is locked
> by the device reference and that this makes si_mountpt robust enough to
> use as an exclusive access flag.

Nah, the reference is not a lock.  This needs dev_lock() or similar to
be robust.

struct cdef has no documented locking, bug dev_lock() should work and is
probably needed for writes.  It is never used for accesses to si_mountpt
now.  Reads are safe enough since the are of the form
'mp = dev->si_mountpt; if (mp == NULL) dont_use_mp();'.

Bruce


More information about the freebsd-fs mailing list