Changeset View
Standalone View
etc/rc.initdiskless
Show First 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | handle_remount() { # $1 = mount point | ||||
log "nfspt ${nfspt} mountopts ${mountopts}" | log "nfspt ${nfspt} mountopts ${mountopts}" | ||||
# prepend the nfs root if not present | # prepend the nfs root if not present | ||||
[ `expr "$nfspt" : '\(.\)'` = "/" ] && nfspt="${nfsroot}${nfspt}" | [ `expr "$nfspt" : '\(.\)'` = "/" ] && nfspt="${nfsroot}${nfspt}" | ||||
mount_nfs $mountopts $nfspt $b | mount_nfs $mountopts $nfspt $b | ||||
chkerr $? "mount_nfs $nfspt $b" | chkerr $? "mount_nfs $nfspt $b" | ||||
to_umount="$b ${to_umount}" | to_umount="$b ${to_umount}" | ||||
} | } | ||||
# Create a generic memory disk (using tmpfs) | # Attempt to load tmpfs, if it is not already available | ||||
# tmpfs_status is empty if load_tmpfs has not been called, | |||||
# 0 if tmpfs is available, and some other status code otherwise | |||||
# | # | ||||
tmpfs_status="" | |||||
load_tmpfs() { | |||||
kldstat -q -m tmpfs || kldload -q tmpfs >/dev/null 2>&1 | |||||
tmpfs_status=$? | |||||
} | |||||
# Create a generic memory disk | |||||
# Use tmpfs, if available, otherwise fall back to using mfs | |||||
# | |||||
mount_md() { | mount_md() { | ||||
# Only try to load tmpfs once | |||||
${tmpfs_status:+:} load_tmpfs | |||||
if [ $tmpfs_status -eq 0 ]; then | |||||
mount -t tmpfs -o size=$(($1 * 512)) tmpfs $2 | mount -t tmpfs -o size=$(($1 * 512)) tmpfs $2 | ||||
ngie: The multiplier here seems incorrect (in the previous commit as well) for tmpfs -- the comments… | |||||
stevekAuthorUnsubmitted Not Done Inline ActionsI think that comment block needs updating, as it doesn't use 8192 sectors for the default. See create_md below where it uses md_size=10240 if md_size_$1 is empty. Why do you think that the value is 8 times higher than it should be? And which value are you referring to here? From the mdmfs(8) man page: -s size Specify the size of the disk to create. This only makes sense if -F is not specified. That is, this will work for the default swap-backed (MD_SWAP) disks, and the optional (-M) malloc(9) backed disks (MD_MALLOC). Looking at the mdmfs sources, the -s flag is passed on to newfs. According to newfs(8) man page: -s size The size of the file system in sectors. This value defaults to the size of the raw partition specified in special less the reserved space at its end (see -r). A size of 0 can also be used to choose the default value. A valid size value cannot be larger than the default one, which means that the file system cannot extend into the reserved space. ... -S sector-size The size of a sector in bytes (almost never anything but 512). So if we're using tmpfs, we need to convert the md_size to number of bytes. Since sector size is 512 for mdmfs usage, we multiply the size by 512. Also note that I have verified this is correct with empirical data. stevek: I think that comment block needs updating, as it doesn't use 8192 sectors for the default. See… | |||||
ianUnsubmitted Not Done Inline ActionsIt's even more complicated than all that. mdmfs doesn't pass the size arg to newfs at all, it just lets newfs use the size of the device. mdmfs does pass the size arg to either mdconfig or mount -t tmpfs, and both of those recipients know how to interpret the usual size suffixes (10m, 30G, etc). Where it gets weird, but nobody has complained for years, is when the -s arg has no suffix the interpretation changes based on the md-device arg type, mdconfig treats it as a count of 512-byte "sectors", and tmpfs treats it as bytes. So now to get it right, this script code has to sniff out possible size suffixes. I have an alternative patchset from years ago that just moves all this functionality into mdmfs. It lets you use "auto" as the md-device value, and it will use tmpfs is available or mdconfig if not. I can dust it off and see if it still applies if there's any interest. (The main point of that change was that it lets a user set a new mfs_type var in rc.conf to 'md', 'tmpfs' or the default value is 'auto'.) ian: It's even more complicated than all that. mdmfs doesn't pass the size arg to newfs at all, it… | |||||
else | |||||
/sbin/mdmfs -S -i 4096 -s $1 -M md $2 | |||||
fi | |||||
} | } | ||||
# Create the memory filesystem if it has not already been created | # Create the memory filesystem if it has not already been created | ||||
# | # | ||||
create_md() { | create_md() { | ||||
[ "x`eval echo \\$md_created_$1`" = "x" ] || return # only once | [ "x`eval echo \\$md_created_$1`" = "x" ] || return # only once | ||||
if [ "x`eval echo \\$md_size_$1`" = "x" ]; then | if [ "x`eval echo \\$md_size_$1`" = "x" ]; then | ||||
md_size=10240 | md_size=10240 | ||||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |
The multiplier here seems incorrect (in the previous commit as well) for tmpfs -- the comments below claim that the value should be in 512 byte sectors (this value is 8 times higher than it should be):