Fix 'zfs set volsize=N pool/dataset'
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 25 Feb 2011 07:36:01 +0000 (14:36 +0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 2 May 2011 15:54:40 +0000 (08:54 -0700)
commitdf554c148ecfdfb7e597f8ab7eee71388b24a19d
treef55979c7c3c842464a896e1551f93b3cfbd3e66f
parente90a3de3e8b52061aeb0717b031a956cc1e705d5
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
57 files changed:
Makefile.in
cmd/Makefile.in
cmd/mount_zfs/Makefile.in
cmd/zdb/Makefile.in
cmd/zfs/Makefile.in
cmd/zinject/Makefile.in
cmd/zpios/Makefile.in
cmd/zpool/Makefile.in
cmd/zpool_id/Makefile.in
cmd/zpool_layout/Makefile.in
cmd/ztest/Makefile.in
cmd/zvol_id/Makefile.in
config/kernel-check-disk-size-change.m4 [new file with mode: 0644]
config/kernel.m4
configure
dracut/90zfs/Makefile.in
dracut/Makefile.in
etc/Makefile.in
etc/init.d/Makefile.in
etc/udev/Makefile.in
etc/udev/rules.d/Makefile.in
etc/zfs/Makefile.in
include/Makefile.in
include/linux/Makefile.in
include/sys/Makefile.in
include/sys/fm/Makefile.in
include/sys/fm/fs/Makefile.in
include/sys/fs/Makefile.in
lib/Makefile.in
lib/libavl/Makefile.in
lib/libefi/Makefile.in
lib/libnvpair/Makefile.in
lib/libspl/Makefile.in
lib/libspl/asm-generic/Makefile.in
lib/libspl/asm-i386/Makefile.in
lib/libspl/asm-x86_64/Makefile.in
lib/libspl/include/Makefile.in
lib/libspl/include/ia32/Makefile.in
lib/libspl/include/ia32/sys/Makefile.in
lib/libspl/include/rpc/Makefile.in
lib/libspl/include/sys/Makefile.in
lib/libspl/include/sys/dktp/Makefile.in
lib/libspl/include/sys/sysevent/Makefile.in
lib/libspl/include/util/Makefile.in
lib/libunicode/Makefile.in
lib/libuutil/Makefile.in
lib/libzfs/Makefile.in
lib/libzpool/Makefile.in
man/Makefile.in
man/man8/Makefile.in
module/zfs/zvol.c
scripts/Makefile.in
scripts/zpios-profile/Makefile.in
scripts/zpios-test/Makefile.in
scripts/zpool-config/Makefile.in
scripts/zpool-layout/Makefile.in
zfs_config.h.in