Illumos 5369 - arc flags should be an enum

5369 arc flags should be an enum
5370 consistent arc_buf_hdr_t naming scheme
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Alex Reece <alex.reece@delphix.com>
Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed by: Richard Elling <richard.elling@richardelling.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

Porting notes:

ZoL has moved some ARC definitions into arc_impl.h.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported by: Tim Chase <tim@chase2k.com>
This commit is contained in:
George Wilson 2014-12-06 09:24:32 -08:00 committed by Brian Behlendorf
parent ad4af89561
commit 2a4324141f
13 changed files with 396 additions and 387 deletions

View File

@ -1250,7 +1250,7 @@ visit_indirect(spa_t *spa, const dnode_phys_t *dnp,
print_indirect(bp, zb, dnp); print_indirect(bp, zb, dnp);
if (BP_GET_LEVEL(bp) > 0 && !BP_IS_HOLE(bp)) { if (BP_GET_LEVEL(bp) > 0 && !BP_IS_HOLE(bp)) {
uint32_t flags = ARC_WAIT; arc_flags_t flags = ARC_FLAG_WAIT;
int i; int i;
blkptr_t *cbp; blkptr_t *cbp;
int epb = BP_GET_LSIZE(bp) >> SPA_BLKPTRSHIFT; int epb = BP_GET_LSIZE(bp) >> SPA_BLKPTRSHIFT;

View File

@ -57,6 +57,36 @@ struct arc_prune {
refcount_t p_refcnt; refcount_t p_refcnt;
}; };
typedef enum arc_flags
{
/*
* Public flags that can be passed into the ARC by external consumers.
*/
ARC_FLAG_NONE = 1 << 0, /* No flags set */
ARC_FLAG_WAIT = 1 << 1, /* perform sync I/O */
ARC_FLAG_NOWAIT = 1 << 2, /* perform async I/O */
ARC_FLAG_PREFETCH = 1 << 3, /* I/O is a prefetch */
ARC_FLAG_CACHED = 1 << 4, /* I/O was in cache */
ARC_FLAG_L2CACHE = 1 << 5, /* cache in L2ARC */
ARC_FLAG_L2COMPRESS = 1 << 6, /* compress in L2ARC */
/*
* Private ARC flags. These flags are private ARC only flags that
* will show up in b_flags in the arc_hdr_buf_t. These flags should
* only be set by ARC code.
*/
ARC_FLAG_IN_HASH_TABLE = 1 << 7, /* buffer is hashed */
ARC_FLAG_IO_IN_PROGRESS = 1 << 8, /* I/O in progress */
ARC_FLAG_IO_ERROR = 1 << 9, /* I/O failed for buf */
ARC_FLAG_FREED_IN_READ = 1 << 10, /* freed during read */
ARC_FLAG_BUF_AVAILABLE = 1 << 11, /* block not in use */
ARC_FLAG_INDIRECT = 1 << 12, /* indirect block */
ARC_FLAG_FREE_IN_PROGRESS = 1 << 13, /* about to be freed */
ARC_FLAG_L2_WRITING = 1 << 14, /* write in progress */
ARC_FLAG_L2_EVICTED = 1 << 15, /* evicted during I/O */
ARC_FLAG_L2_WRITE_HEAD = 1 << 16, /* head of write list */
} arc_flags_t;
struct arc_buf { struct arc_buf {
arc_buf_hdr_t *b_hdr; arc_buf_hdr_t *b_hdr;
arc_buf_t *b_next; arc_buf_t *b_next;
@ -71,15 +101,6 @@ typedef enum arc_buf_contents {
ARC_BUFC_METADATA, /* buffer contains metadata */ ARC_BUFC_METADATA, /* buffer contains metadata */
ARC_BUFC_NUMTYPES ARC_BUFC_NUMTYPES
} arc_buf_contents_t; } arc_buf_contents_t;
/*
* These are the flags we pass into calls to the arc
*/
#define ARC_WAIT (1 << 1) /* perform I/O synchronously */
#define ARC_NOWAIT (1 << 2) /* perform I/O asynchronously */
#define ARC_PREFETCH (1 << 3) /* I/O is a prefetch */
#define ARC_CACHED (1 << 4) /* I/O was already in cache */
#define ARC_L2CACHE (1 << 5) /* cache in L2ARC */
#define ARC_L2COMPRESS (1 << 6) /* compress in L2ARC */
/* /*
* The following breakdows of arc_size exist for kstat only. * The following breakdows of arc_size exist for kstat only.
@ -146,7 +167,7 @@ int arc_referenced(arc_buf_t *buf);
int arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, int arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
arc_done_func_t *done, void *private, zio_priority_t priority, int flags, arc_done_func_t *done, void *private, zio_priority_t priority, int flags,
uint32_t *arc_flags, const zbookmark_phys_t *zb); arc_flags_t *arc_flags, const zbookmark_phys_t *zb);
zio_t *arc_write(zio_t *pio, spa_t *spa, uint64_t txg, zio_t *arc_write(zio_t *pio, spa_t *spa, uint64_t txg,
blkptr_t *bp, arc_buf_t *buf, boolean_t l2arc, boolean_t l2arc_compress, blkptr_t *bp, arc_buf_t *buf, boolean_t l2arc, boolean_t l2arc_compress,
const zio_prop_t *zp, arc_done_func_t *ready, arc_done_func_t *physdone, const zio_prop_t *zp, arc_done_func_t *ready, arc_done_func_t *physdone,

View File

@ -107,7 +107,7 @@ struct arc_buf_hdr {
arc_buf_hdr_t *b_hash_next; arc_buf_hdr_t *b_hash_next;
arc_buf_t *b_buf; arc_buf_t *b_buf;
uint32_t b_flags; arc_flags_t b_flags;
uint32_t b_datacnt; uint32_t b_datacnt;
arc_callback_t *b_acb; arc_callback_t *b_acb;

File diff suppressed because it is too large Load Diff

View File

@ -653,7 +653,7 @@ dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t *flags)
{ {
dnode_t *dn; dnode_t *dn;
zbookmark_phys_t zb; zbookmark_phys_t zb;
uint32_t aflags = ARC_NOWAIT; uint32_t aflags = ARC_FLAG_NOWAIT;
int err; int err;
DB_DNODE_ENTER(db); DB_DNODE_ENTER(db);
@ -707,9 +707,9 @@ dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t *flags)
mutex_exit(&db->db_mtx); mutex_exit(&db->db_mtx);
if (DBUF_IS_L2CACHEABLE(db)) if (DBUF_IS_L2CACHEABLE(db))
aflags |= ARC_L2CACHE; aflags |= ARC_FLAG_L2CACHE;
if (DBUF_IS_L2COMPRESSIBLE(db)) if (DBUF_IS_L2COMPRESSIBLE(db))
aflags |= ARC_L2COMPRESS; aflags |= ARC_FLAG_L2COMPRESS;
SET_BOOKMARK(&zb, db->db_objset->os_dsl_dataset ? SET_BOOKMARK(&zb, db->db_objset->os_dsl_dataset ?
db->db_objset->os_dsl_dataset->ds_object : DMU_META_OBJSET, db->db_objset->os_dsl_dataset->ds_object : DMU_META_OBJSET,
@ -721,7 +721,7 @@ dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t *flags)
dbuf_read_done, db, ZIO_PRIORITY_SYNC_READ, dbuf_read_done, db, ZIO_PRIORITY_SYNC_READ,
(*flags & DB_RF_CANFAIL) ? ZIO_FLAG_CANFAIL : ZIO_FLAG_MUSTSUCCEED, (*flags & DB_RF_CANFAIL) ? ZIO_FLAG_CANFAIL : ZIO_FLAG_MUSTSUCCEED,
&aflags, &zb); &aflags, &zb);
if (aflags & ARC_CACHED) if (aflags & ARC_FLAG_CACHED)
*flags |= DB_RF_CACHED; *flags |= DB_RF_CACHED;
return (SET_ERROR(err)); return (SET_ERROR(err));
@ -2028,7 +2028,8 @@ dbuf_prefetch(dnode_t *dn, uint64_t blkid, zio_priority_t prio)
if (dbuf_findbp(dn, 0, blkid, TRUE, &db, &bp, NULL) == 0) { if (dbuf_findbp(dn, 0, blkid, TRUE, &db, &bp, NULL) == 0) {
if (bp && !BP_IS_HOLE(bp) && !BP_IS_EMBEDDED(bp)) { if (bp && !BP_IS_HOLE(bp) && !BP_IS_EMBEDDED(bp)) {
dsl_dataset_t *ds = dn->dn_objset->os_dsl_dataset; dsl_dataset_t *ds = dn->dn_objset->os_dsl_dataset;
uint32_t aflags = ARC_NOWAIT | ARC_PREFETCH; arc_flags_t aflags =
ARC_FLAG_NOWAIT | ARC_FLAG_PREFETCH;
zbookmark_phys_t zb; zbookmark_phys_t zb;
SET_BOOKMARK(&zb, ds ? ds->ds_object : DMU_META_OBJSET, SET_BOOKMARK(&zb, ds ? ds->ds_object : DMU_META_OBJSET,

View File

@ -129,7 +129,7 @@ diff_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
} else if (zb->zb_level == 0) { } else if (zb->zb_level == 0) {
dnode_phys_t *blk; dnode_phys_t *blk;
arc_buf_t *abuf; arc_buf_t *abuf;
uint32_t aflags = ARC_WAIT; arc_flags_t aflags = ARC_FLAG_WAIT;
int blksz = BP_GET_LSIZE(bp); int blksz = BP_GET_LSIZE(bp);
int i; int i;

View File

@ -306,15 +306,15 @@ dmu_objset_open_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp,
os->os_spa = spa; os->os_spa = spa;
os->os_rootbp = bp; os->os_rootbp = bp;
if (!BP_IS_HOLE(os->os_rootbp)) { if (!BP_IS_HOLE(os->os_rootbp)) {
uint32_t aflags = ARC_WAIT; arc_flags_t aflags = ARC_FLAG_WAIT;
zbookmark_phys_t zb; zbookmark_phys_t zb;
SET_BOOKMARK(&zb, ds ? ds->ds_object : DMU_META_OBJSET, SET_BOOKMARK(&zb, ds ? ds->ds_object : DMU_META_OBJSET,
ZB_ROOT_OBJECT, ZB_ROOT_LEVEL, ZB_ROOT_BLKID); ZB_ROOT_OBJECT, ZB_ROOT_LEVEL, ZB_ROOT_BLKID);
if (DMU_OS_IS_L2CACHEABLE(os)) if (DMU_OS_IS_L2CACHEABLE(os))
aflags |= ARC_L2CACHE; aflags |= ARC_FLAG_L2CACHE;
if (DMU_OS_IS_L2COMPRESSIBLE(os)) if (DMU_OS_IS_L2COMPRESSIBLE(os))
aflags |= ARC_L2COMPRESS; aflags |= ARC_FLAG_L2COMPRESS;
dprintf_bp(os->os_rootbp, "reading %s", ""); dprintf_bp(os->os_rootbp, "reading %s", "");
err = arc_read(NULL, spa, os->os_rootbp, err = arc_read(NULL, spa, os->os_rootbp,

View File

@ -486,7 +486,7 @@ backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
dnode_phys_t *blk; dnode_phys_t *blk;
int i; int i;
int blksz = BP_GET_LSIZE(bp); int blksz = BP_GET_LSIZE(bp);
uint32_t aflags = ARC_WAIT; arc_flags_t aflags = ARC_FLAG_WAIT;
arc_buf_t *abuf; arc_buf_t *abuf;
if (arc_read(NULL, spa, bp, arc_getbuf_func, &abuf, if (arc_read(NULL, spa, bp, arc_getbuf_func, &abuf,
@ -504,7 +504,7 @@ backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
} }
(void) arc_buf_remove_ref(abuf, &abuf); (void) arc_buf_remove_ref(abuf, &abuf);
} else if (type == DMU_OT_SA) { } else if (type == DMU_OT_SA) {
uint32_t aflags = ARC_WAIT; arc_flags_t aflags = ARC_FLAG_WAIT;
arc_buf_t *abuf; arc_buf_t *abuf;
int blksz = BP_GET_LSIZE(bp); int blksz = BP_GET_LSIZE(bp);
@ -521,8 +521,8 @@ backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
err = dump_write_embedded(dsp, zb->zb_object, err = dump_write_embedded(dsp, zb->zb_object,
zb->zb_blkid * blksz, blksz, bp); zb->zb_blkid * blksz, blksz, bp);
} else { /* it's a level-0 block of a regular object */ } else { /* it's a level-0 block of a regular object */
uint32_t aflags = ARC_WAIT;
uint64_t offset; uint64_t offset;
arc_flags_t aflags = ARC_FLAG_WAIT;
arc_buf_t *abuf; arc_buf_t *abuf;
int blksz = BP_GET_LSIZE(bp); int blksz = BP_GET_LSIZE(bp);

View File

@ -177,7 +177,7 @@ static void
traverse_prefetch_metadata(traverse_data_t *td, traverse_prefetch_metadata(traverse_data_t *td,
const blkptr_t *bp, const zbookmark_phys_t *zb) const blkptr_t *bp, const zbookmark_phys_t *zb)
{ {
uint32_t flags = ARC_NOWAIT | ARC_PREFETCH; arc_flags_t flags = ARC_FLAG_NOWAIT | ARC_FLAG_PREFETCH;
if (!(td->td_flags & TRAVERSE_PREFETCH_METADATA)) if (!(td->td_flags & TRAVERSE_PREFETCH_METADATA))
return; return;
@ -273,7 +273,7 @@ traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp,
} }
if (BP_GET_LEVEL(bp) > 0) { if (BP_GET_LEVEL(bp) > 0) {
uint32_t flags = ARC_WAIT; uint32_t flags = ARC_FLAG_WAIT;
int32_t i; int32_t i;
int32_t epb = BP_GET_LSIZE(bp) >> SPA_BLKPTRSHIFT; int32_t epb = BP_GET_LSIZE(bp) >> SPA_BLKPTRSHIFT;
zbookmark_phys_t *czb; zbookmark_phys_t *czb;
@ -307,7 +307,7 @@ traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp,
kmem_free(czb, sizeof (zbookmark_phys_t)); kmem_free(czb, sizeof (zbookmark_phys_t));
} else if (BP_GET_TYPE(bp) == DMU_OT_DNODE) { } else if (BP_GET_TYPE(bp) == DMU_OT_DNODE) {
uint32_t flags = ARC_WAIT; uint32_t flags = ARC_FLAG_WAIT;
int32_t i; int32_t i;
int32_t epb = BP_GET_LSIZE(bp) >> DNODE_SHIFT; int32_t epb = BP_GET_LSIZE(bp) >> DNODE_SHIFT;
dnode_phys_t *cdnp; dnode_phys_t *cdnp;
@ -331,7 +331,7 @@ traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp,
break; break;
} }
} else if (BP_GET_TYPE(bp) == DMU_OT_OBJSET) { } else if (BP_GET_TYPE(bp) == DMU_OT_OBJSET) {
uint32_t flags = ARC_WAIT; arc_flags_t flags = ARC_FLAG_WAIT;
objset_phys_t *osp; objset_phys_t *osp;
dnode_phys_t *mdnp, *gdnp, *udnp; dnode_phys_t *mdnp, *gdnp, *udnp;
@ -448,7 +448,7 @@ traverse_prefetcher(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
const zbookmark_phys_t *zb, const dnode_phys_t *dnp, void *arg) const zbookmark_phys_t *zb, const dnode_phys_t *dnp, void *arg)
{ {
prefetch_data_t *pfd = arg; prefetch_data_t *pfd = arg;
uint32_t aflags = ARC_NOWAIT | ARC_PREFETCH; arc_flags_t aflags = ARC_FLAG_NOWAIT | ARC_FLAG_PREFETCH;
ASSERT(pfd->pd_bytes_fetched >= 0); ASSERT(pfd->pd_bytes_fetched >= 0);
if (pfd->pd_cancel) if (pfd->pd_cancel)
@ -545,7 +545,7 @@ traverse_impl(spa_t *spa, dsl_dataset_t *ds, uint64_t objset, blkptr_t *rootbp,
/* See comment on ZIL traversal in dsl_scan_visitds. */ /* See comment on ZIL traversal in dsl_scan_visitds. */
if (ds != NULL && !ds->ds_is_snapshot && !BP_IS_HOLE(rootbp)) { if (ds != NULL && !ds->ds_is_snapshot && !BP_IS_HOLE(rootbp)) {
uint32_t flags = ARC_WAIT; uint32_t flags = ARC_FLAG_WAIT;
objset_phys_t *osp; objset_phys_t *osp;
arc_buf_t *buf; arc_buf_t *buf;

View File

@ -590,7 +590,7 @@ dsl_scan_prefetch(dsl_scan_t *scn, arc_buf_t *buf, blkptr_t *bp,
uint64_t objset, uint64_t object, uint64_t blkid) uint64_t objset, uint64_t object, uint64_t blkid)
{ {
zbookmark_phys_t czb; zbookmark_phys_t czb;
uint32_t flags = ARC_NOWAIT | ARC_PREFETCH; arc_flags_t flags = ARC_FLAG_NOWAIT | ARC_FLAG_PREFETCH;
if (zfs_no_scrub_prefetch) if (zfs_no_scrub_prefetch)
return; return;
@ -655,7 +655,7 @@ dsl_scan_recurse(dsl_scan_t *scn, dsl_dataset_t *ds, dmu_objset_type_t ostype,
int err; int err;
if (BP_GET_LEVEL(bp) > 0) { if (BP_GET_LEVEL(bp) > 0) {
uint32_t flags = ARC_WAIT; arc_flags_t flags = ARC_FLAG_WAIT;
int i; int i;
blkptr_t *cbp; blkptr_t *cbp;
int epb = BP_GET_LSIZE(bp) >> SPA_BLKPTRSHIFT; int epb = BP_GET_LSIZE(bp) >> SPA_BLKPTRSHIFT;
@ -682,7 +682,7 @@ dsl_scan_recurse(dsl_scan_t *scn, dsl_dataset_t *ds, dmu_objset_type_t ostype,
} }
(void) arc_buf_remove_ref(buf, &buf); (void) arc_buf_remove_ref(buf, &buf);
} else if (BP_GET_TYPE(bp) == DMU_OT_DNODE) { } else if (BP_GET_TYPE(bp) == DMU_OT_DNODE) {
uint32_t flags = ARC_WAIT; arc_flags_t flags = ARC_FLAG_WAIT;
dnode_phys_t *cdnp; dnode_phys_t *cdnp;
int i, j; int i, j;
int epb = BP_GET_LSIZE(bp) >> DNODE_SHIFT; int epb = BP_GET_LSIZE(bp) >> DNODE_SHIFT;
@ -708,7 +708,7 @@ dsl_scan_recurse(dsl_scan_t *scn, dsl_dataset_t *ds, dmu_objset_type_t ostype,
(void) arc_buf_remove_ref(buf, &buf); (void) arc_buf_remove_ref(buf, &buf);
} else if (BP_GET_TYPE(bp) == DMU_OT_OBJSET) { } else if (BP_GET_TYPE(bp) == DMU_OT_OBJSET) {
uint32_t flags = ARC_WAIT; arc_flags_t flags = ARC_FLAG_WAIT;
objset_phys_t *osp; objset_phys_t *osp;
arc_buf_t *buf; arc_buf_t *buf;

View File

@ -200,7 +200,7 @@ spa_read_history_add(spa_t *spa, const zbookmark_phys_t *zb, uint32_t aflags)
if (zfs_read_history == 0 && ssh->size == 0) if (zfs_read_history == 0 && ssh->size == 0)
return; return;
if (zfs_read_history_hits == 0 && (aflags & ARC_CACHED)) if (zfs_read_history_hits == 0 && (aflags & ARC_FLAG_CACHED))
return; return;
srh = kmem_zalloc(sizeof (spa_read_history_t), KM_SLEEP); srh = kmem_zalloc(sizeof (spa_read_history_t), KM_SLEEP);

View File

@ -204,7 +204,7 @@ zil_read_log_block(zilog_t *zilog, const blkptr_t *bp, blkptr_t *nbp, void *dst,
char **end) char **end)
{ {
enum zio_flag zio_flags = ZIO_FLAG_CANFAIL; enum zio_flag zio_flags = ZIO_FLAG_CANFAIL;
uint32_t aflags = ARC_WAIT; arc_flags_t aflags = ARC_FLAG_WAIT;
arc_buf_t *abuf = NULL; arc_buf_t *abuf = NULL;
zbookmark_phys_t zb; zbookmark_phys_t zb;
int error; int error;
@ -280,7 +280,7 @@ zil_read_log_data(zilog_t *zilog, const lr_write_t *lr, void *wbuf)
{ {
enum zio_flag zio_flags = ZIO_FLAG_CANFAIL; enum zio_flag zio_flags = ZIO_FLAG_CANFAIL;
const blkptr_t *bp = &lr->lr_blkptr; const blkptr_t *bp = &lr->lr_blkptr;
uint32_t aflags = ARC_WAIT; arc_flags_t aflags = ARC_FLAG_WAIT;
arc_buf_t *abuf = NULL; arc_buf_t *abuf = NULL;
zbookmark_phys_t zb; zbookmark_phys_t zb;
int error; int error;

View File

@ -2241,7 +2241,7 @@ zio_ddt_collision(zio_t *zio, ddt_t *ddt, ddt_entry_t *dde)
if (ddp->ddp_phys_birth != 0) { if (ddp->ddp_phys_birth != 0) {
arc_buf_t *abuf = NULL; arc_buf_t *abuf = NULL;
uint32_t aflags = ARC_WAIT; arc_flags_t aflags = ARC_FLAG_WAIT;
blkptr_t blk = *zio->io_bp; blkptr_t blk = *zio->io_bp;
int error; int error;