diff options
author | Brian Behlendorf <[email protected]> | 2013-01-25 14:57:53 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-01-25 15:07:40 -0800 |
commit | 6772fb679a4205427a385d174359b2a5826da613 (patch) | |
tree | 02ce78b8720573be954e81b4d121df8c9a855886 /module | |
parent | ba43f4565aa151065dd2b64c1aab8f1051ce1295 (diff) |
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 <[email protected]>
Closes #1238
Diffstat (limited to 'module')
-rw-r--r-- | module/zfs/dmu_objset.c | 33 | ||||
-rw-r--r-- | module/zfs/dsl_dataset.c | 2 | ||||
-rw-r--r-- | module/zfs/zfs_ctldir.c | 4 |
3 files changed, 5 insertions, 34 deletions
diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c index 628b23be1..c59973a77 100644 --- a/module/zfs/dmu_objset.c +++ b/module/zfs/dmu_objset.c @@ -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 diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c index c5b84a26c..55a8b0fc1 100644 --- a/module/zfs/dsl_dataset.c +++ b/module/zfs/dsl_dataset.c @@ -314,7 +314,7 @@ dsl_dataset_get_snapname(dsl_dataset_t *ds) return (err); } -static int +int dsl_dataset_snap_lookup(dsl_dataset_t *ds, const char *name, uint64_t *value) { objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset; diff --git a/module/zfs/zfs_ctldir.c b/module/zfs/zfs_ctldir.c index b3801d494..4fa530b6c 100644 --- a/module/zfs/zfs_ctldir.c +++ b/module/zfs/zfs_ctldir.c @@ -443,7 +443,7 @@ zfsctl_snapdir_lookup(struct inode *dip, char *name, struct inode **ipp, ZFS_ENTER(zsb); - error = dmu_snapshot_id(zsb->z_os, name, &id); + error = dmu_snapshot_lookup(zsb->z_os, name, &id); if (error) { ZFS_EXIT(zsb); return (error); @@ -909,7 +909,7 @@ zfsctl_lookup_objset(struct super_block *sb, uint64_t objsetid, zfs_sb_t **zsbp) */ sep = avl_first(&zsb->z_ctldir_snaps); while (sep != NULL) { - error = dmu_snapshot_id(zsb->z_os, sep->se_name, &id); + error = dmu_snapshot_lookup(zsb->z_os, sep->se_name, &id); if (error) goto out; |