Update the dataset name in handle after zfs_rename (#17040)

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]>
Reviewed-by: Ameer Hamza <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
This commit is contained in:
Umer Saleem authored and GitHub committed 2025-02-11 09:07:29 -08:00
1 parent b8c73ab780
commit b901d4a0b6
1 file changed
+1
+1
View File
@@ -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: