tech-kern archive

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

Re: could fstat(1) show files in use by vnd(4)?



woods%planix.ca@localhost ("Greg A. Woods") writes:

>After a reboot we can see the vnd(4) uses:

>	# vndconfig -l
>	vnd0: /build (/dev/mapper/vg0-build) inode 861956
>	vnd1: /build (/dev/mapper/vg0-build) inode 861966
>	vnd2: /build (/dev/mapper/vg0-build) inode 861953
>	vnd3: not in use

>So, might it be possible to have fstat show these somehow?  (perhaps
>with the/a kernel thread identified as having them open)

fstat reports file descriptors, not the underlying file handles.

pstat -f reports the file handles, but it dumps only a pointer to a vnode
and nothing that identifies a file directly.

pstat -v does dump the vnodes.

# ls -li testimage 
23471029 -rw-r--r--  1 mlelstv  staff  10485760 Aug 12 07:11 testimage
...

# vnconfig -l
vnd0: /home (/dev/dk5) inode 23471029
...

# pstat -v
...
*** MOUNT ffs /dev/dk5 on /home (log,nodev,nosuid,local)
ADDR             TYP VFLAG  USE HOLD TAG NPAGE FILEID IFLAG RDEV|SZ
...
ffff000019fe4c00 reg     M    2    0   1     0 23471029   - 10485760
...

N.B.

# pstat -f | grep ffff000019fe4c00
#

There is no file handle, vnd uses the vnode directly.



>Also, is this a crash that should be fixed, or is "umount -f" always a
>Buyer-Beware operation with expected "undefined behaviour"?

umount -f should either do nothing or do the umount, while mogrifying
each vnode to reference deadfs where all operations are supposed to
fail except for releasing the vnode. Still buyer-beware, but otherwise
a clearly defined behaviour.

The crash seems to happen at:

    error = VOP_BMAP(vnd->sc_vp, bn / bsize, &vp, &nbn, &nra);

where

    bsize = vnd->sc_vp->v_mount->mnt_stat.f_iosize;

deadfs hasn't initialized f_iosize. Maybe:

Index: vnd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/vnd.c,v
retrieving revision 1.289
diff -p -u -r1.289 vnd.c
--- vnd.c       19 May 2023 15:42:43 -0000      1.289
+++ vnd.c       12 Aug 2024 05:31:36 -0000
@@ -875,6 +875,9 @@ handle_with_strategy(struct vnd_softc *v
        bn = obp->b_rawblkno * vnd->sc_dkdev.dk_label->d_secsize;
 
        bsize = vnd->sc_vp->v_mount->mnt_stat.f_iosize;
+       /* use default if the filesystem didn't specify a block size */
+       if (bsize <= 0)
+               bsize = BLKDEV_IOSIZE;
        skipped = 0;
 
        /*



Home | Main Index | Thread Index | Old Index