Skip to content

Commit 21bc066

Browse files
authored
Fix updating the zvol_htable when renaming a zvol
When renaming a zvol, insert it into zvol_htable using the new name, not the old name. Otherwise some operations won't work. For example, "zfs set volsize" while the zvol is open. Sponsored by: Axcient Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alek Pinchuk <[email protected]> Signed-off-by: Alan Somers <[email protected]> Closes #16127 Closes #16128
1 parent 317b31e commit 21bc066

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

module/os/freebsd/zfs/zvol_os.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ zvol_os_rename_minor(zvol_state_t *zv, const char *newname)
12591259
ASSERT(MUTEX_HELD(&zv->zv_state_lock));
12601260

12611261
/* Move to a new hashtable entry. */
1262-
zv->zv_hash = zvol_name_hash(zv->zv_name);
1262+
zv->zv_hash = zvol_name_hash(newname);
12631263
hlist_del(&zv->zv_hlink);
12641264
hlist_add_head(&zv->zv_hlink, ZVOL_HT_HEAD(zv->zv_hash));
12651265

module/os/linux/zfs/zvol_os.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ zvol_os_rename_minor(zvol_state_t *zv, const char *newname)
15711571
strlcpy(zv->zv_name, newname, sizeof (zv->zv_name));
15721572

15731573
/* move to new hashtable entry */
1574-
zv->zv_hash = zvol_name_hash(zv->zv_name);
1574+
zv->zv_hash = zvol_name_hash(newname);
15751575
hlist_del(&zv->zv_hlink);
15761576
hlist_add_head(&zv->zv_hlink, ZVOL_HT_HEAD(zv->zv_hash));
15771577

0 commit comments

Comments
 (0)