Skip to content

Commit 309ce63

Browse files
amotinbehlendorf
authored andcommitted
ZAP: Add by_dnode variants to lookup/prefetch_uint64
Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Pawel Jakub Dawidek <[email protected]> Reviewed-by: Brian Atkinson <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes #16740
1 parent 1ee251b commit 309ce63

File tree

2 files changed

+62
-13
lines changed

2 files changed

+62
-13
lines changed

include/sys/zap.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,15 @@ int zap_lookup_norm(objset_t *ds, uint64_t zapobj, const char *name,
223223
boolean_t *normalization_conflictp);
224224
int zap_lookup_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
225225
int key_numints, uint64_t integer_size, uint64_t num_integers, void *buf);
226+
int zap_lookup_uint64_by_dnode(dnode_t *dn, const uint64_t *key,
227+
int key_numints, uint64_t integer_size, uint64_t num_integers, void *buf);
226228
int zap_contains(objset_t *ds, uint64_t zapobj, const char *name);
227229
int zap_prefetch(objset_t *os, uint64_t zapobj, const char *name);
228230
int zap_prefetch_object(objset_t *os, uint64_t zapobj);
229231
int zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
230232
int key_numints);
233+
int zap_prefetch_uint64_by_dnode(dnode_t *dn, const uint64_t *key,
234+
int key_numints);
231235

232236
int zap_lookup_by_dnode(dnode_t *dn, const char *name,
233237
uint64_t integer_size, uint64_t num_integers, void *buf);
@@ -236,9 +240,6 @@ int zap_lookup_norm_by_dnode(dnode_t *dn, const char *name,
236240
matchtype_t mt, char *realname, int rn_len,
237241
boolean_t *ncp);
238242

239-
int zap_count_write_by_dnode(dnode_t *dn, const char *name,
240-
int add, zfs_refcount_t *towrite, zfs_refcount_t *tooverwrite);
241-
242243
/*
243244
* Create an attribute with the given name and value.
244245
*

module/zfs/zap_micro.c

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,21 @@ zap_lookup_norm_by_dnode(dnode_t *dn, const char *name,
12271227
return (err);
12281228
}
12291229

1230+
static int
1231+
zap_prefetch_uint64_impl(zap_t *zap, const uint64_t *key, int key_numints)
1232+
{
1233+
zap_name_t *zn = zap_name_alloc_uint64(zap, key, key_numints);
1234+
if (zn == NULL) {
1235+
zap_unlockdir(zap, FTAG);
1236+
return (SET_ERROR(ENOTSUP));
1237+
}
1238+
1239+
fzap_prefetch(zn);
1240+
zap_name_free(zn);
1241+
zap_unlockdir(zap, FTAG);
1242+
return (0);
1243+
}
1244+
12301245
int
12311246
zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
12321247
int key_numints)
@@ -1237,13 +1252,37 @@ zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
12371252
zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap);
12381253
if (err != 0)
12391254
return (err);
1255+
err = zap_prefetch_uint64_impl(zap, key, key_numints);
1256+
/* zap_prefetch_uint64_impl() calls zap_unlockdir() */
1257+
return (err);
1258+
}
1259+
1260+
int
1261+
zap_prefetch_uint64_by_dnode(dnode_t *dn, const uint64_t *key, int key_numints)
1262+
{
1263+
zap_t *zap;
1264+
1265+
int err =
1266+
zap_lockdir_by_dnode(dn, NULL, RW_READER, TRUE, FALSE, FTAG, &zap);
1267+
if (err != 0)
1268+
return (err);
1269+
err = zap_prefetch_uint64_impl(zap, key, key_numints);
1270+
/* zap_prefetch_uint64_impl() calls zap_unlockdir() */
1271+
return (err);
1272+
}
1273+
1274+
static int
1275+
zap_lookup_uint64_impl(zap_t *zap, const uint64_t *key,
1276+
int key_numints, uint64_t integer_size, uint64_t num_integers, void *buf)
1277+
{
12401278
zap_name_t *zn = zap_name_alloc_uint64(zap, key, key_numints);
12411279
if (zn == NULL) {
12421280
zap_unlockdir(zap, FTAG);
12431281
return (SET_ERROR(ENOTSUP));
12441282
}
12451283

1246-
fzap_prefetch(zn);
1284+
int err = fzap_lookup(zn, integer_size, num_integers, buf,
1285+
NULL, 0, NULL);
12471286
zap_name_free(zn);
12481287
zap_unlockdir(zap, FTAG);
12491288
return (err);
@@ -1259,16 +1298,25 @@ zap_lookup_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
12591298
zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap);
12601299
if (err != 0)
12611300
return (err);
1262-
zap_name_t *zn = zap_name_alloc_uint64(zap, key, key_numints);
1263-
if (zn == NULL) {
1264-
zap_unlockdir(zap, FTAG);
1265-
return (SET_ERROR(ENOTSUP));
1266-
}
1301+
err = zap_lookup_uint64_impl(zap, key, key_numints, integer_size,
1302+
num_integers, buf);
1303+
/* zap_lookup_uint64_impl() calls zap_unlockdir() */
1304+
return (err);
1305+
}
12671306

1268-
err = fzap_lookup(zn, integer_size, num_integers, buf,
1269-
NULL, 0, NULL);
1270-
zap_name_free(zn);
1271-
zap_unlockdir(zap, FTAG);
1307+
int
1308+
zap_lookup_uint64_by_dnode(dnode_t *dn, const uint64_t *key,
1309+
int key_numints, uint64_t integer_size, uint64_t num_integers, void *buf)
1310+
{
1311+
zap_t *zap;
1312+
1313+
int err =
1314+
zap_lockdir_by_dnode(dn, NULL, RW_READER, TRUE, FALSE, FTAG, &zap);
1315+
if (err != 0)
1316+
return (err);
1317+
err = zap_lookup_uint64_impl(zap, key, key_numints, integer_size,
1318+
num_integers, buf);
1319+
/* zap_lookup_uint64_impl() calls zap_unlockdir() */
12721320
return (err);
12731321
}
12741322

0 commit comments

Comments
 (0)