Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix device expansion when VM is powered off #9111

Merged
merged 1 commit into from
Aug 14, 2019
Merged

Fix device expansion when VM is powered off #9111

merged 1 commit into from
Aug 14, 2019

Commits on Aug 13, 2019

  1. Fix device expansion when VM is powered off

    When running on an ESXi based VM, I've found that "zpool online -e" will
    not expand the zpool, if the disk was expanded in ESXi while the VM was
    powered off.
    
    For example, take the following scenario:
    
     1. VM running on top of VMware ESXi
     2. ZFS pool created with a given device "sda" of size 8GB
     3. VM powered off
     4. Device "sda" size expanded to 16GB
     5. VM powered on
     6. "zpool online -e" used on device "sda"
    
    In this situation, after (2) the zpool will be roughly 8GB in size.
    After (6), the expectation is the zpool's size will expand to roughly
    16GB in size; i.e. expand to the new size of the "sda" device.
    Unfortuantely, I've seen that after (6), the zpool size does not change.
    
    What's happening is after (5), the EFI label of the "sda" device will be
    such that fields "efi_last_u_lba", "efi_last_lba", and "efi_altern_lba"
    all reflect the new size of the disk; i.e. "33554398", "33554431", and
    "33554431" respectively.
    
    Thus, the check that we perform in "efi_use_whole_disk":
    
        if ((efi_label->efi_altern_lba == 1) || (efi_label->efi_altern_lba
            >= efi_label->efi_last_lba)) {
    
    This will return true, and then we return from the function without
    having expanded the size of the zpool/device.
    
    In contrast, if we remove steps (3) and (5) in the sequence above, i.e.
    the device is expanded while the VM is powered on, things change. In
    that case, the fields "efi_last_u_lba" and "efi_altern_lba" do not
    change (i.e. they still reflect the old 8GB device size), but the
    "efi_last_lba" field does change (i.e. it now reflects the new 16GB
    device size). Thus, when we evaluate the same conditional in
    "efi_use_whole_disk", it'll return false, so the zpool is expanded.
    
    Taking all of this into account, this PR updates "efi_use_whole_disk" to
    properly expand the zpool when the underlying disk is expanded while the
    VM is powered off.
    
    Signed-off-by: Prakash Surya <prakash.surya@delphix.com>
    Prakash Surya committed Aug 13, 2019
    Configuration menu
    Copy the full SHA
    233f95e View commit details
    Browse the repository at this point in the history