1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-29 08:08:37 +00:00

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 <behlendorf1@llnl.gov>
Reviewed-by: Alek Pinchuk <apinchuk@axcient.com>
Signed-off-by:	Alan Somers <asomers@FreeBSD.org>
Closes #16127
Closes #16128
This commit is contained in:
Alan Somers 2024-04-25 16:24:52 -05:00 committed by GitHub
parent 317b31eedb
commit 21bc066ece
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -1259,7 +1259,7 @@ zvol_os_rename_minor(zvol_state_t *zv, const char *newname)
ASSERT(MUTEX_HELD(&zv->zv_state_lock)); ASSERT(MUTEX_HELD(&zv->zv_state_lock));
/* Move to a new hashtable entry. */ /* 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_del(&zv->zv_hlink);
hlist_add_head(&zv->zv_hlink, ZVOL_HT_HEAD(zv->zv_hash)); hlist_add_head(&zv->zv_hlink, ZVOL_HT_HEAD(zv->zv_hash));

View File

@ -1571,7 +1571,7 @@ zvol_os_rename_minor(zvol_state_t *zv, const char *newname)
strlcpy(zv->zv_name, newname, sizeof (zv->zv_name)); strlcpy(zv->zv_name, newname, sizeof (zv->zv_name));
/* move to new hashtable entry */ /* 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_del(&zv->zv_hlink);
hlist_add_head(&zv->zv_hlink, ZVOL_HT_HEAD(zv->zv_hash)); hlist_add_head(&zv->zv_hlink, ZVOL_HT_HEAD(zv->zv_hash));