Using 7.8-stable/amd64, I'm seeing curious behavior when setting up
a softraid-crypto filesystem on a vnd device (backed by a container
file stored under /home).



Here's what I did:

(as an ordinary user)
// create the container file
% mkdir /home/jonathan/tmp.x
% chmod go-rwx /home/jonathan/tmp.x
% dd if=/dev/random bs=1m count=1k of=/home/jonathan/tmp.x/data
% chmod go-rwx /home/jonathan/tmp.x/data

(then everything else is as root)
// set up a vnd device backed by the container file
# vnconfig -v vnd0 /home/jonathan/tmp.x/data
vnd0: 1073741824 bytes on /home/jonathan/tmp.x/data
# 

// partition the vnd device
# fdisk -iy vnd0
Writing MBR at offset 0.
#
# disklabel -E vnd0
// add partition j: offset=256, fstype=RAID
// ... larger-than-default offset is to try to ensure
//     we don't clobber the fdisk partition table

// confirm the disklabel partitions
# disklabel vnd0
# /dev/rvnd0c:
type: vnd
disk: vnd device
label: fictitious
duid: d994c4b4a2436716
flags:
bytes/sector: 512
sectors/track: 100
tracks/cylinder: 1
sectors/cylinder: 100
cylinders: 20971
total sectors: 2097152
boundstart: 128
boundend: 2097152

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  c:          2097152                0  unused                    
  j:          2096896              256    RAID                    
#

// create a softraid-crypto disk backed by the just-created RAID partition
# bioctl -c C -r 1024 -l /dev/vnd0j softraid0
New passphrase: 
Re-type passphrase: 
softraid0: CRYPTO volume attached as sd3
#

// partition the just-created softraid-crypto disk
# fdisk -iy sd3
Writing MBR at offset 0.
# 

# disklabel -E sd3
// add partition a: offset=256, fstype=4.2BSD
// ... again use larger-than-default offset to try to ensure
//     we don't clobber the fdisk partition table

// confirm the partitioning
# disklabel sd3
# /dev/rsd3c:
type: SCSI
disk: SCSI disk
label: SR CRYPTO
duid: 8e47c8fd3b1c430e
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 130
total sectors: 2096368
boundstart: 64
boundend: 2096368

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  a:          2096096              256  4.2BSD   2048 16384     1 
  c:          2096368                0  unused                    
#

// now create and mount a filesystem on the softraid disk
# newfs -i 65536 sd3a
/dev/rsd3a: 1023.5MB in 2096096 sectors of 512 bytes
5 cylinder groups of 245.47MB, 15710 blocks, 3968 inodes each
super-block backups (for fsck -b #) at:
 160, 502880, 1005600, 1508320, 2011040,
# mount -o noatime,nodev,nosuid /dev/sd3a /home/jonathan/crypt/tmp
#

// the mount changed the mount-point ownership from jonathan:jonathan
// to root:wheel, and the permissions from drx------ to drxr-xr-x,
// so change these back
# chown jonathan:jonathan /home/jonathan/crypt/tmp
# chmod go-rwx /home/jonathan/crypt/tmp



At this point everything seems fine:

% mount|grep /home/jonathan/crypt/tmp
/dev/sd3a on /home/jonathan/crypt/tmp type ffs (local, noatime, nodev, nosuid)
% rsync -aHESvv --delete /home/jonathan/some/stuff/ /home/jonathan/crypt/tmp/



Now the problem:
If I repeatedly unconfigure then reconfigure a few times, the softraid-disk
filesystem shows up as uncleanly-unmounted (and needs fsck before mounting):

// unconfigure
# umount /home/jonathan/crypt/tmp
# bioctl -d sd3
# vnconfig -u vnd0

// reconfigure
# vnconfig -v vnd0 /home/jonathan/tmp.x/data 
vnd0: 1073741824 bytes on /home/jonathan/tmp.x/data
# bioctl -c C -r 1024 -l /dev/vnd0j softraid0
Passphrase: 
softraid0: CRYPTO volume attached as sd3
# mount -o noatime,nodev,nosuid /dev/sd3a /home/jonathan/crypt/tmp
mount_ffs: /dev/sd3a on /home/jonathan/crypt/tmp: filesystem must be mounted 
read-only; you may need to run fsck
# 

# fsck -p /dev/rsd3a
/dev/rsd3a: 794 files, 123804 used, 397619 free (595 frags, 49628 blocks, 0.1% 
fragmentation)
/dev/rsd3a: MARKING FILE SYSTEM CLEAN
# mount -o noatime,nodev,nosuid /dev/sd3a /home/jonathan/crypt/tmp
# 



Question: why is the file system showing up as unclean, given that I
explicitly unmounted it before unconfiguring the softraid disk?



Finally, I see wierd timestamps on the mount point:

If everything is unconfigured, the mount point has some timestamp
from when I last used that directory before starting this project:

# ls -lFgd /home/jonathan/crypt/tmp
drwx------  2 jonathan  jonathan  512 Jun  2  2024 /home/jonathan/crypt/tmp/
# 

But if I re-configure, then the mount point has a wierd mtime:

# vnconfig -v vnd0 /home/jonathan/tmp.x/data
vnd0: 1073741824 bytes on /home/jonathan/tmp.x/data
# bioctl -c C -l /dev/fnd0j softraid0
bioctl: could not open /dev/fnd0j: No such file or directory
# bioctl -c C -l /dev/vnd0j softraid0
Passphrase: 
softraid0: CRYPTO volume attached as sd3
# mount -o noatime,nodev,nosuid /dev/sd3a /home/jonathan/crypt/tmp
# 
# ls -lFgd /home/jonathan/crypt/tmp
drwx------  31 jonathan  jonathan  1024 Jan 30 19:11 /home/jonathan/crypt/tmp/
# stat /home/jonathan/crypt/tmp
1072 2 drwx------ 31 jonathan jonathan 560 1024 "Apr 17 23:28:43 2026" "Jan 30 
19:11:50 2026" "Apr 18 00:27:21 2026" 16384 4 0 /home/jonathan/crypt/tmp
#

What's going on here?  (How) am I corrupting the filesystem?

Thanks for any insights anyone can offer,
-- 
-- "Jonathan Thornburg [remove -color to reply]" <[email protected]>
   (he/him; currently on the west coast of Canada)
     Alberto Moreira (comp.arch, Jan 1999):
       "Cache is, basically, a kluge generated by technological restrictions."
     Donald C. Lindsay (also comp.arch, Jan 1999):
       "No. It's a kluge generated by deeply fundamental restrictions,
        like the speed of light."

Reply via email to