Skip to content

Commit

Permalink
Fix generation of kernel uevents for snapshot rename on linux
Browse files Browse the repository at this point in the history
`zvol_rename_minors()` needs to be given the full path not just the
snapshot name.  Use code removed in a0bd735 as a guide
to providing the necessary values.

Add ZTS check for /dev changes after snapshot rename.  After
renaming a snapshot with 'snapdev=visible' ensure that the /dev
entries are updated to reflect the rename.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: James Dingwall <james@dingwall.me.uk>
Closes #14223 
Closes #16600
  • Loading branch information
JKDingwall authored Oct 6, 2024
1 parent 995a3a6 commit 0b4dcbe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
11 changes: 9 additions & 2 deletions module/zfs/dsl_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -2987,6 +2987,7 @@ dsl_dataset_rename_snapshot_sync_impl(dsl_pool_t *dp,
dsl_dataset_t *ds;
uint64_t val;
dmu_tx_t *tx = ddrsa->ddrsa_tx;
char *oldname, *newname;
int error;

error = dsl_dataset_snap_lookup(hds, ddrsa->ddrsa_oldsnapname, &val);
Expand All @@ -3011,8 +3012,14 @@ dsl_dataset_rename_snapshot_sync_impl(dsl_pool_t *dp,
VERIFY0(zap_add(dp->dp_meta_objset,
dsl_dataset_phys(hds)->ds_snapnames_zapobj,
ds->ds_snapname, 8, 1, &ds->ds_object, tx));
zvol_rename_minors(dp->dp_spa, ddrsa->ddrsa_oldsnapname,
ddrsa->ddrsa_newsnapname, B_TRUE);

oldname = kmem_asprintf("%s@%s", ddrsa->ddrsa_fsname,
ddrsa->ddrsa_oldsnapname);
newname = kmem_asprintf("%s@%s", ddrsa->ddrsa_fsname,
ddrsa->ddrsa_newsnapname);
zvol_rename_minors(dp->dp_spa, oldname, newname, B_TRUE);
kmem_strfree(oldname);
kmem_strfree(newname);

dsl_dataset_rele(ds, FTAG);
return (0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,18 @@ log_must zfs set snapdev=visible $TESTPOOL
verify_inherited 'snapdev' 'hidden' $SUBZVOL $VOLFS
blockdev_missing $SUBSNAPDEV
blockdev_exists $SNAPDEV
log_must zfs destroy $SNAP

# 4. Verify "rename" is correctly reflected when "snapdev=visible"
# 4.1 First create a snapshot and verify the device is present
log_must zfs snapshot $SNAP
log_must zfs set snapdev=visible $ZVOL
blockdev_exists $SNAPDEV
# 4.2 rename the snapshot and verify the devices are updated
log_must zfs rename $SNAP $SNAP-new
blockdev_missing $SNAPDEV
blockdev_exists $SNAPDEV-new
# 4.3 cleanup
log_must zfs destroy $SNAP-new

log_pass "ZFS volume property 'snapdev' works as expected"

0 comments on commit 0b4dcbe

Please sign in to comment.