Skip to content

Commit

Permalink
Fix updating the zvol_htable when renaming a zvol
Browse files Browse the repository at this point in the history
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 openzfs#16127
Closes openzfs#16128
  • Loading branch information
asomers authored Apr 25, 2024
1 parent 317b31e commit 21bc066
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion module/os/freebsd/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ zvol_os_rename_minor(zvol_state_t *zv, const char *newname)
ASSERT(MUTEX_HELD(&zv->zv_state_lock));

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

Expand Down
2 changes: 1 addition & 1 deletion module/os/linux/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ zvol_os_rename_minor(zvol_state_t *zv, const char *newname)
strlcpy(zv->zv_name, newname, sizeof (zv->zv_name));

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

Expand Down

0 comments on commit 21bc066

Please sign in to comment.