From b5a28807cdec3c05aa69cbe4689cd914dc94783a Mon Sep 17 00:00:00 2001 From: Etienne Dechamps Date: Wed, 11 Jul 2012 15:06:32 +0200 Subject: Move partition scanning from userspace to module. Currently, zpool online -e (dynamic vdev expansion) doesn't work on whole disks because we're invoking ioctl(BLKRRPART) from userspace while ZFS still has a partition open on the disk, which results in EBUSY. This patch moves the BLKRRPART invocation from the zpool utility to the module. Specifically, this is done just before opening the device in vdev_disk_open() which is called inside vdev_reopen(). This requires jumping through some hoops to get to the disk device from the partition device, and to make sure we can still open the partition after the BLKRRPART call. Note that this new code path is triggered on dynamic vdev expansion only; other actions, like creating a new pool, are unchanged and still call BLKRRPART from userspace. This change also depends on API changes which are available in 2.6.37 and latter kernels. The build system has been updated to detect this, but there is no compatibility mode for older kernels. This means that online expansion will NOT be available in older kernels. However, it will still be possible to expand the vdev offline. Signed-off-by: Brian Behlendorf Closes #808 --- lib/libefi/Makefile.in | 2 ++ lib/libefi/rdwr_efi.c | 13 +++---------- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'lib/libefi') diff --git a/lib/libefi/Makefile.in b/lib/libefi/Makefile.in index e6ba6a15a..88fb19cd3 100644 --- a/lib/libefi/Makefile.in +++ b/lib/libefi/Makefile.in @@ -64,6 +64,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-blk-rq-pos.m4 \ $(top_srcdir)/config/kernel-blk-rq-sectors.m4 \ $(top_srcdir)/config/kernel-blkdev-get-by-path.m4 \ + $(top_srcdir)/config/kernel-blkdev-get.m4 \ $(top_srcdir)/config/kernel-check-disk-size-change.m4 \ $(top_srcdir)/config/kernel-create-umode-t.m4 \ $(top_srcdir)/config/kernel-d-make-root.m4 \ @@ -73,6 +74,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-fmode-t.m4 \ $(top_srcdir)/config/kernel-fsync.m4 \ $(top_srcdir)/config/kernel-get-disk-ro.m4 \ + $(top_srcdir)/config/kernel-get-gendisk.m4 \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ diff --git a/lib/libefi/rdwr_efi.c b/lib/libefi/rdwr_efi.c index 80886bb44..f4cf41712 100644 --- a/lib/libefi/rdwr_efi.c +++ b/lib/libefi/rdwr_efi.c @@ -497,10 +497,9 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc) return (error); } -#if defined(__linux__) -static int -efi_rescan(int fd) +int efi_rescan(int fd) { +#if defined(__linux__) int retry = 5; int error; @@ -512,10 +511,10 @@ efi_rescan(int fd) return (-1); } } +#endif return (0); } -#endif static int check_label(int fd, dk_efi_t *dk_ioc) @@ -1304,12 +1303,6 @@ efi_write(int fd, struct dk_gpt *vtoc) (void) write_pmbr(fd, vtoc); free(dk_ioc.dki_data); -#if defined(__linux__) - rval = efi_rescan(fd); - if (rval) - return (VT_ERROR); -#endif - return (0); } -- cgit v1.2.3