Skip to content

Commit

Permalink
Add zap_prefetch() interface
Browse files Browse the repository at this point in the history
Provide a generic interface to prefetch ZAP entries by name.  This
functionality is being added for external consumers such as Lustre.
It is based of the existing zap_prefetch_uint64() version which is
used by the deduplication code.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes openzfs#4061
  • Loading branch information
behlendorf committed Dec 4, 2015
1 parent 917b8c5 commit 0724845
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/sys/zap.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ int zap_lookup_norm(objset_t *ds, uint64_t zapobj, const char *name,
int zap_lookup_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
int key_numints, uint64_t integer_size, uint64_t num_integers, void *buf);
int zap_contains(objset_t *ds, uint64_t zapobj, const char *name);
int zap_prefetch(objset_t *os, uint64_t zapobj, const char *name);
int zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
int key_numints);

Expand Down
23 changes: 23 additions & 0 deletions module/zfs/zap_micro.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,28 @@ zap_lookup_norm(objset_t *os, uint64_t zapobj, const char *name,
return (err);
}

int
zap_prefetch(objset_t *os, uint64_t zapobj, const char *name)
{
zap_t *zap;
int err;
zap_name_t *zn;

err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap);
if (err)
return (err);
zn = zap_name_alloc(zap, name, MT_EXACT);
if (zn == NULL) {
zap_unlockdir(zap);
return (SET_ERROR(ENOTSUP));
}

fzap_prefetch(zn);
zap_name_free(zn);
zap_unlockdir(zap);
return (err);
}

int
zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
int key_numints)
Expand Down Expand Up @@ -1427,6 +1449,7 @@ EXPORT_SYMBOL(zap_lookup);
EXPORT_SYMBOL(zap_lookup_norm);
EXPORT_SYMBOL(zap_lookup_uint64);
EXPORT_SYMBOL(zap_contains);
EXPORT_SYMBOL(zap_prefetch);
EXPORT_SYMBOL(zap_prefetch_uint64);
EXPORT_SYMBOL(zap_count_write);
EXPORT_SYMBOL(zap_add);
Expand Down

0 comments on commit 0724845

Please sign in to comment.