mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 19:04:45 +03:00
Use dsl_dataset_snap_lookup()
Retire the dmu_snapshot_id() function which was introduced in the initial .zfs control directory implementation. There is already an existing dsl_dataset_snap_lookup() which does exactly what we need, and the dmu_snapshot_id() function as implemented is racy. https://github.com/zfsonlinux/zfs/issues/1215#issuecomment-12579879 Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #1238
This commit is contained in:
+2
-31
@@ -1573,39 +1573,10 @@ dmu_snapshot_list_next(objset_t *os, int namelen, char *name,
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the objset id for a given snapshot name.
|
||||
*/
|
||||
int
|
||||
dmu_snapshot_id(objset_t *os, const char *snapname, uint64_t *idp)
|
||||
dmu_snapshot_lookup(objset_t *os, const char *name, uint64_t *value)
|
||||
{
|
||||
dsl_dataset_t *ds = os->os_dsl_dataset;
|
||||
zap_cursor_t cursor;
|
||||
zap_attribute_t attr;
|
||||
int error;
|
||||
|
||||
if (ds->ds_phys->ds_snapnames_zapobj == 0)
|
||||
return (ENOENT);
|
||||
|
||||
zap_cursor_init(&cursor, ds->ds_dir->dd_pool->dp_meta_objset,
|
||||
ds->ds_phys->ds_snapnames_zapobj);
|
||||
|
||||
error = zap_cursor_move_to_key(&cursor, snapname, MT_EXACT);
|
||||
if (error) {
|
||||
zap_cursor_fini(&cursor);
|
||||
return (error);
|
||||
}
|
||||
|
||||
error = zap_cursor_retrieve(&cursor, &attr);
|
||||
if (error) {
|
||||
zap_cursor_fini(&cursor);
|
||||
return (error);
|
||||
}
|
||||
|
||||
*idp = attr.za_first_integer;
|
||||
zap_cursor_fini(&cursor);
|
||||
|
||||
return (0);
|
||||
return dsl_dataset_snap_lookup(os->os_dsl_dataset, name, value);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user