]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix updating the zvol_htable when renaming a zvol
authorAlan Somers <asomers@FreeBSD.org>
Thu, 25 Apr 2024 21:24:52 +0000 (16:24 -0500)
committerGitHub <noreply@github.com>
Thu, 25 Apr 2024 21:24:52 +0000 (14:24 -0700)
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

module/os/freebsd/zfs/zvol_os.c
module/os/linux/zfs/zvol_os.c

index 6a7c2d2811b1d7f3f63baea210b2c32dad3afc89..712ff1b837d7f8116d624024faba782f1cb0d48b 100644 (file)
@@ -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));
 
index 4b960daf89eec0383101a21ddebbe7842841300a..2a036dc5136b38ecc7fd7397b9959a7ecb8ee2e1 100644 (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));
 
        /* 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));