Speed up ZFS list operation with objset prefetching.

Partial import of OpenSolaris onnv revisions:
8415:8809e849f63e, 10474:0e96dd3b905a

PR:		kern/146297
Submitted by:	myself
Approved by:	pjd, delphij (mentor)
Obtained from:	OpenSolaris (Bug ID 6386929, 6755389, 6847118)
MFC after:	2 weeks
This commit is contained in:
Martin Matuska 2010-05-04 17:40:24 +00:00
parent 7135e11ef9
commit 7d4daf9a10
3 changed files with 45 additions and 2 deletions

View File

@ -1213,6 +1213,39 @@ dmu_objset_find_spa(spa_t *spa, const char *name,
return (err);
}
/* ARGSUSED */
int
dmu_objset_prefetch(char *name, void *arg)
{
dsl_dataset_t *ds;
if (dsl_dataset_hold(name, FTAG, &ds))
return (0);
if (!BP_IS_HOLE(&ds->ds_phys->ds_bp)) {
mutex_enter(&ds->ds_opening_lock);
if (!dsl_dataset_get_user_ptr(ds)) {
uint32_t aflags = ARC_NOWAIT | ARC_PREFETCH;
zbookmark_t zb;
zb.zb_objset = ds->ds_object;
zb.zb_object = 0;
zb.zb_level = -1;
zb.zb_blkid = 0;
(void) arc_read_nolock(NULL, dsl_dataset_get_spa(ds),
&ds->ds_phys->ds_bp, NULL, NULL,
ZIO_PRIORITY_ASYNC_READ,
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE,
&aflags, &zb);
}
mutex_exit(&ds->ds_opening_lock);
}
dsl_dataset_rele(ds, FTAG);
return (0);
}
void
dmu_objset_set_user(objset_t *os, void *user_ptr)
{

View File

@ -26,8 +26,6 @@
#ifndef _SYS_DMU_OBJSET_H
#define _SYS_DMU_OBJSET_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/spa.h>
#include <sys/arc.h>
#include <sys/txg.h>
@ -118,6 +116,7 @@ int dmu_objset_find(char *name, int func(char *, void *), void *arg,
int flags);
int dmu_objset_find_spa(spa_t *spa, const char *name,
int func(spa_t *, uint64_t, const char *, void *), void *arg, int flags);
int dmu_objset_prefetch(char *name, void *arg);
void dmu_objset_byteswap(void *buf, size_t size);
int dmu_objset_evict_dbufs(objset_t *os);

View File

@ -1349,6 +1349,14 @@ zfs_ioc_dataset_list_next(zfs_cmd_t *zc)
(void) strlcat(zc->zc_name, "/", sizeof (zc->zc_name));
p = zc->zc_name + strlen(zc->zc_name);
if (zc->zc_cookie == 0) {
uint64_t cookie = 0;
int len = sizeof (zc->zc_name) - (p - zc->zc_name);
while (dmu_dir_list_next(os, len, p, NULL, &cookie) == 0)
dmu_objset_prefetch(p, NULL);
}
do {
error = dmu_dir_list_next(os,
sizeof (zc->zc_name) - (p - zc->zc_name), p,
@ -1387,6 +1395,9 @@ zfs_ioc_snapshot_list_next(zfs_cmd_t *zc)
objset_t *os;
int error;
if (zc->zc_cookie == 0)
dmu_objset_find(zc->zc_name, dmu_objset_prefetch,
NULL, DS_FIND_SNAPSHOTS);
error = dmu_objset_open(zc->zc_name,
DMU_OST_ANY, DS_MODE_USER | DS_MODE_READONLY, &os);
if (error)