diff options
author | Brian Behlendorf <[email protected]> | 2012-11-19 13:48:06 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-11-19 16:59:44 -0800 |
commit | 0e20a31b4bb7f9745fe6d5cafe513c9c1df3e933 (patch) | |
tree | 6594f76c329dafe6e9f22a6fd6ebd4581857826a /lib | |
parent | 33364b15d302abfb2945129994b9cf42e61dc302 (diff) |
Recreate minors when renaming zvols
When a zvol with snapshots is renamed the device files under
/dev/zvol/ are not renamed. This patch resolves the problem
by destroying and recreating the minors with the new name so
the links can be recreated bu udev.
Original-patch-by: Suman Chakravartula <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #408
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzfs/libzfs_changelist.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/libzfs/libzfs_changelist.c b/lib/libzfs/libzfs_changelist.c index 0bcfc0423..3a83e2d71 100644 --- a/lib/libzfs/libzfs_changelist.c +++ b/lib/libzfs/libzfs_changelist.c @@ -291,22 +291,30 @@ changelist_rename(prop_changelist_t *clp, const char *src, const char *dst) for (cn = uu_list_first(clp->cl_list); cn != NULL; cn = uu_list_next(clp->cl_list, cn)) { + zfs_handle_t *hdl; + + hdl = cn->cn_handle; + /* * Do not rename a clone that's not in the source hierarchy. */ - if (!isa_child_of(cn->cn_handle->zfs_name, src)) + if (!isa_child_of(hdl->zfs_name, src)) continue; /* * Destroy the previous mountpoint if needed. */ - remove_mountpoint(cn->cn_handle); + remove_mountpoint(hdl); (void) strlcpy(newname, dst, sizeof (newname)); - (void) strcat(newname, cn->cn_handle->zfs_name + strlen(src)); + (void) strcat(newname, hdl->zfs_name + strlen(src)); + + if (ZFS_IS_VOLUME(hdl)) { + (void) zvol_remove_link(hdl->zfs_hdl, hdl->zfs_name); + (void) zvol_create_link(hdl->zfs_hdl, newname); + } - (void) strlcpy(cn->cn_handle->zfs_name, newname, - sizeof (cn->cn_handle->zfs_name)); + (void) strlcpy(hdl->zfs_name, newname, sizeof (hdl->zfs_name)); } } |