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

Add recursive/limited -a mount & unmount | introduce -A for noauto bypass #15264

Closed
wants to merge 5 commits into from

Commits on Oct 13, 2023

  1. This commit adds functions to libzfs to check if one dataset is related

    to another.
    
    The `related_dataset()` function checks if the second provided dataset
    is the same as or a child dataset of the first provided dataset. The
    function returns a `boolean_t` value (`B_TRUE` if related).
    
    The `zfs_related_dataset()` helper function takes a `zfs_handle_t` and
    checks if the provided handle is related to the provided dataset. The
    function returns a `boolean_t` value (`B_TRUE` if related).
    
    libzfs_dataset.c:
    - `related_dataset()`
    - `zfs_related_dataset()`
    
    libzfs.h:
    - `zfs_related_dataset()`
    
    Signed-off-by: QORTEC <[email protected]>
    QORTEC committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    f476a37 View commit details
    Browse the repository at this point in the history
  2. Added limited/recursive operation to zfs mount

    This commit introduces limited/recursive filesystem mounting by
    leveraging the existing `zfs mount -a` codebase with minor additions
    and modifications.
    
    Now, when running `zfs mount <-a|-A> zpool/dataset`, the command will
    mount all datasets that are the specified dataset itself or it's
    children, provided they are available. In addition, `-A` flag  will also
    mount datasets with `canmount=noauto` property.
    
    Changes in `zfs_main.c`:
    - `HELP_MOUNT`
      - Updated `usage()` message to reflect the changes.
    - `get_all_state_t`
      - Added `const char *ga_parent`; used to specify the parent dataset.
    - `get_one_dataset()`
      - Added a check; if `ga_parent` is set, skips any datasets that are
        not `ga_parent` itself or it's children.
    - `get_all_datasets()`
      - Added `const char *parent` property; used to pass the parent dataset
        to the `get_all_state_t` struct.
    - `share_mount_state_t`
      - Added `boolean_t sm_mount_noauto`; used to treat datasets with
      `canmount=noauto` property as as if it were `canmount=on`.
    - `share_mount_one()`;
      - Added `boolean_t mount_noauto` property.
      - Modified the 'noauto' check; when mounting datasets,
        if `mount_noauto` is true, treat the mount as if `canmount=on` or
        `explicit` is `B_TRUE`.
    - `share_mount_one_cb()`
      - Updated `share_mount_one()` call to include the new property,
        passes the value of `sm_mount_noauto`.
    - `share_mount()`
      - Changed `do_all` from `int` to `boolean_t`
      - Added `boolean_t do_noauto` property; used for mounting datasets
        with `canmount=noauto` as `canmount=on`.
      - Added the `-A` flag; when used sets `do_noauto` to `B_TRUE`.
      - Updated argument check; displaies the correct error messages.
      - Limited the usage of `<-a|-A> filesystem` to `zfs mount` only
      - Added a check; to validate that the specified filesystem is indeed a
        valid ZFS filesystem.
      - Updated `get_all_datasets()` call to include the new property,
        passes the value of `filesystem`.
      - Added `share_mount_state.sm_mount_noauto`; the `share_mount_state_t`
        has a new member, uses value of `do_noauto`
      - Updated `share_mount_one()` call to include the new property,
        passes the value `B_FALSE`.
    
    Signed-off-by: QORTEC <[email protected]>
    QORTEC committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    a1295cd View commit details
    Browse the repository at this point in the history
  3. Updated/added documentation & tests for the changes to zfs mount -a

    zfs-mount.8:
    - Updated usage and documentation for the changes to `zfs mount`
    
    common.run:
    - Added `zfs_mount_all_002_pos`
    
    Makefile.am:
    - Added `functional/cli_root/zfs_mount/zfs_mount_all_002_pos.ksh`
    
    zfs_mount_009_neg.ksh:
    - Corrected comment spacing.
    - Removed negative check for `-a filesystem`.
    - Added negative check for mounting multiple specified filesystems.
    
    zfs_mount_011_neg.ksh:
    - Removed negative check for `-a filesystem` and `-A`.
    
    zfs_mount_all_001_pos.ksh:
    - Corrected comment spacing.
    
    zfs_mount_all_002_pos.ksh:
    - Checks that only the specified filesystem and its children are
      mounted.
    
    Signed-off-by: QORTEC <[email protected]>
    QORTEC committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    e07de81 View commit details
    Browse the repository at this point in the history
  4. Added limited/recursive operation to zfs unmount

    This commit introduces limited/recursive filesystem unmounting by
    leveraging the existing `zfs unmount -a` codebase with minor additions
    and modifications.
    
    Now, when running `zfs unmount <-a|-A> zpool/dataset`, the command will
    unmount all datasets that are the specified dataset itself or it's
    children, provided they are available. In addition, `-A` flag  will also
    mount datasets with `canmount=noauto` property.
    
    Changes in `zfs_main.c`:
    - `HELP_UNMOUNT`
      - Updated `usage()` message to reflect the changes.
    - `unshare_unmount()`
      - Changed `do_all` from `int` to `boolean_t`
      - Added `boolean_t do_noauto` property; used for mounting datasets
        with `canmount=noauto` as `canmount=on`.
      - Added the `-A` flag; when used sets `do_noauto` to `B_TRUE`.
      - Updated argument check; displaies the correct error messages.
      - Limited the usage of `<-a|-A> filesystem` to `zfs unmount` only
      - Added a check; to validate that the specified filesystem is indeed a
        valid ZFS filesystem.
      - Modified the 'noauto' check; when unmounting datasets,
        if `do_noauto` is true, treat the unmount as if `canmount=on`.
      - Added a check; if `filesystem` is set, skips any datasets that are
        not `filesystem` itself or it's children.
    
    Signed-off-by: QORTEC <[email protected]>
    QORTEC committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    9246667 View commit details
    Browse the repository at this point in the history
  5. Updated/added documentation & tests for the changes to zfs unmount -a

    zfs-mount.8:
    - Updated usage and documentation for the changes to `zfs unmount`
    
    common.run:
    - Added `zfs_unmount_all_002_pos`
    
    Makefile.am:
    - Added `functional/cli_root/zfs_unmount/zfs_unmount_all_002_pos.ksh`
    
    zfs_unmount_007_neg.ksh:
    - Removed negative check for `-a filesystem`.
    - Added negative check for unmounting multiple specified filesystems.
    
    zfs_unmount_008_neg.ksh:
    - Removed negative check for `-A`.
    
    zfs_unmount_all_001_pos.ksh:
    - Corrected comment spacing.
    
    zfs_unmount_all_002_pos.ksh:
    - Checks that only the specified filesystem and its children are
      unmounted.
    
    Signed-off-by: QORTEC <[email protected]>
    QORTEC committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    64400c3 View commit details
    Browse the repository at this point in the history