Skip to content

Commit

Permalink
Update the dataset name in handle after zfs_rename
Browse files Browse the repository at this point in the history
For zfs_rename, after the dataset name is successfully updated,
the dataset handle that was passed to zfs_rename, still contains
the old name, due to which, the dataset handle becomes invalid.
The following operations performed using this handle result in
error since the dataset with old name cannot be found anymore.

changelist_rename does update the names in dataset handles,
but those are temporary handles that were created during
changelist_gather. The original handle that was used to call
zfs_rename is not updated.

We should update the name in original ZFS handle after the IOCTL
for rename returns success for the operation.

Signed-off-by: Umer Saleem <[email protected]>
  • Loading branch information
usaleem-ix authored and [email protected] committed Feb 10, 2025
1 parent 2cccbac commit 31664ed
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/libzfs/libzfs_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -4673,6 +4673,7 @@ zfs_rename(zfs_handle_t *zhp, const char *target, renameflags_t flags)
changelist_rename(cl, zfs_get_name(zhp), target);
ret = changelist_postfix(cl);
}
(void) strlcpy(zhp->zfs_name, target, sizeof (zhp->zfs_name));
}

error:
Expand Down

0 comments on commit 31664ed

Please sign in to comment.