HomeFreeBSD

Fix 'zfs set volsize=N pool/dataset'

Description

Fix 'zfs set volsize=N pool/dataset'

This change fixes a kernel panic which would occur when resizing
a dataset which was not open. The objset_t stored in the
zvol_state_t will be set to NULL when the block device is closed.
To avoid this issue we pass the correct objset_t as the third arg.

The code has also been updated to correctly notify the kernel
when the block device capacity changes. For 2.6.28 and newer
kernels the capacity change will be immediately detected. For
earlier kernels the capacity change will be detected when the
device is next opened. This is a known limitation of older
kernels.

Online ext3 resize test case passes on 2.6.28+ kernels:
$ dd if=/dev/zero of=/tmp/zvol bs=1M count=1 seek=1023
$ zpool create tank /tmp/zvol
$ zfs create -V 500M tank/zd0
$ mkfs.ext3 /dev/zd0
$ mkdir /mnt/zd0
$ mount /dev/zd0 /mnt/zd0
$ df -h /mnt/zd0
$ zfs set volsize=800M tank/zd0
$ resize2fs /dev/zd0
$ df -h /mnt/zd0

Original-patch-by: Fajar A. Nugraha <github@fajar.net>
Closes #68
Closes #84

Details

Provenance
Brian Behlendorf <behlendorf1@llnl.gov>Authored on Feb 25 2011, 7:36 AM
Parents
rGe90a3de3e8b5: Add zpl_export.c to the list of targets.
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rGdf554c148ecf: Fix 'zfs set volsize=N pool/dataset' (authored by Brian Behlendorf <behlendorf1@llnl.gov>).May 2 2011, 3:54 PM