Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add visibility into arc_read through a new kstat #1748

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/sys/spa.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ typedef struct zilog zilog_t;
typedef struct spa_aux_vdev spa_aux_vdev_t;
typedef struct ddt ddt_t;
typedef struct ddt_entry ddt_entry_t;
typedef struct zbookmark zbookmark_t;

struct dsl_pool;

/*
Expand Down Expand Up @@ -533,6 +535,12 @@ extern boolean_t spa_refcount_zero(spa_t *spa);
#define SCL_ALL ((1 << SCL_LOCKS) - 1)
#define SCL_STATE_ALL (SCL_STATE | SCL_L2ARC | SCL_ZIO)

/* Pool read history statistics */
extern void spa_read_history_init(spa_t *spa);
extern void spa_read_history_destroy(spa_t *spa);
extern void spa_read_history_add(spa_t *spa, const zbookmark_t *zb,
uint32_t aflags);

/* Pool configuration locks */
extern int spa_config_tryenter(spa_t *spa, int locks, void *tag, krw_t rw);
extern void spa_config_enter(spa_t *spa, int locks, void *tag, krw_t rw);
Expand Down
6 changes: 6 additions & 0 deletions include/sys/spa_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ struct spa {
uint64_t spa_deadman_calls; /* number of deadman calls */
uint64_t spa_sync_starttime; /* starting time fo spa_sync */
uint64_t spa_deadman_synctime; /* deadman expiration timer */
kmutex_t spa_read_history_lock; /* read history list lock */
uint64_t spa_read_history_count; /* running count of # of reads */
uint64_t spa_read_history_size; /* read history list size */
kstat_t *spa_read_history_kstat;/* read history list kstat */
list_t spa_read_history; /* read history list */

/*
* spa_refcnt & spa_config_lock must be the last elements
* because refcount_t changes size based on compilation options.
Expand Down
1 change: 1 addition & 0 deletions include/sys/zfs_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ typedef struct kthread {
#define tsd_get(key) pthread_getspecific(key)
#define tsd_set(key, val) pthread_setspecific(key, val)
#define curthread zk_thread_current()
#define getcomm() "unknown"
#define thread_exit zk_thread_exit
#define thread_create(stk, stksize, func, arg, len, pp, state, pri) \
zk_thread_create(stk, stksize, (thread_func_t)func, arg, \
Expand Down
6 changes: 4 additions & 2 deletions include/sys/zio.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,21 @@ extern char *zio_type_name[ZIO_TYPES];
* Therefore it must not change size or alignment between 32/64 bit
* compilation options.
*/
typedef struct zbookmark {
struct zbookmark {
uint64_t zb_objset;
uint64_t zb_object;
int64_t zb_level;
uint64_t zb_blkid;
} zbookmark_t;
char * zb_func;
};

#define SET_BOOKMARK(zb, objset, object, level, blkid) \
{ \
(zb)->zb_objset = objset; \
(zb)->zb_object = object; \
(zb)->zb_level = level; \
(zb)->zb_blkid = blkid; \
(zb)->zb_func = FTAG; \
}

#define ZB_DESTROYED_OBJSET (-1ULL)
Expand Down
1 change: 1 addition & 0 deletions lib/libzpool/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ libzpool_la_SOURCES = \
$(top_srcdir)/module/zfs/spa_errlog.c \
$(top_srcdir)/module/zfs/spa_history.c \
$(top_srcdir)/module/zfs/spa_misc.c \
$(top_srcdir)/module/zfs/spa_stats.c \
$(top_srcdir)/module/zfs/space_map.c \
$(top_srcdir)/module/zfs/txg.c \
$(top_srcdir)/module/zfs/uberblock.c \
Expand Down
8 changes: 8 additions & 0 deletions lib/libzpool/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ void
kstat_delete(kstat_t *ksp)
{}

/*ARGSUSED*/
void
kstat_set_raw_ops(kstat_t *ksp,
void (*headers)(char *buf, size_t size),
void (*data)(char *buf, size_t size, void *data),
void* (*addr)(kstat_t *ksp, loff_t index))
{}

/*
* =========================================================================
* mutexes
Expand Down
1 change: 1 addition & 0 deletions module/zfs/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ $(MODULE)-objs += @top_srcdir@/module/zfs/spa_config.o
$(MODULE)-objs += @top_srcdir@/module/zfs/spa_errlog.o
$(MODULE)-objs += @top_srcdir@/module/zfs/spa_history.o
$(MODULE)-objs += @top_srcdir@/module/zfs/spa_misc.o
$(MODULE)-objs += @top_srcdir@/module/zfs/spa_stats.o
$(MODULE)-objs += @top_srcdir@/module/zfs/space_map.o
$(MODULE)-objs += @top_srcdir@/module/zfs/txg.o
$(MODULE)-objs += @top_srcdir@/module/zfs/uberblock.o
Expand Down
20 changes: 13 additions & 7 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2943,6 +2943,7 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, arc_done_func_t *done,
kmutex_t *hash_lock;
zio_t *rzio;
uint64_t guid = spa_load_guid(spa);
int rc = 0;

top:
hdr = buf_hash_find(guid, BP_IDENTITY(bp), BP_PHYSICAL_BIRTH(bp),
Expand Down Expand Up @@ -2976,10 +2977,10 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, arc_done_func_t *done,
hdr->b_acb = acb;
add_reference(hdr, hash_lock, private);
mutex_exit(hash_lock);
return (0);
goto out;
}
mutex_exit(hash_lock);
return (0);
goto out;
}

ASSERT(hdr->b_state == arc_mru || hdr->b_state == arc_mfu);
Expand Down Expand Up @@ -3174,12 +3175,12 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, arc_done_func_t *done,

if (*arc_flags & ARC_NOWAIT) {
zio_nowait(rzio);
return (0);
goto out;
}

ASSERT(*arc_flags & ARC_WAIT);
if (zio_wait(rzio) == 0)
return (0);
goto out;

/* l2arc read error; goto zio_read() */
} else {
Expand All @@ -3203,13 +3204,18 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, arc_done_func_t *done,
rzio = zio_read(pio, spa, bp, buf->b_data, size,
arc_read_done, buf, priority, zio_flags, zb);

if (*arc_flags & ARC_WAIT)
return (zio_wait(rzio));
if (*arc_flags & ARC_WAIT) {
rc = zio_wait(rzio);
goto out;
}

ASSERT(*arc_flags & ARC_NOWAIT);
zio_nowait(rzio);
}
return (0);

out:
spa_read_history_add(spa, zb, *arc_flags);
return (rc);
}

arc_prune_t *
Expand Down
6 changes: 5 additions & 1 deletion module/zfs/spa_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <sys/metaslab_impl.h>
#include <sys/arc.h>
#include <sys/ddt.h>
#include <sys/kstat.h>
#include "zfs_prop.h"
#include "zfeature_common.h"

Expand Down Expand Up @@ -253,7 +254,6 @@ unsigned long zfs_deadman_synctime = 1000ULL;
*/
int zfs_deadman_enabled = 1;


/*
* ==========================================================================
* SPA config locking
Expand Down Expand Up @@ -499,6 +499,8 @@ spa_add(const char *name, nvlist_t *config, const char *altroot)
refcount_create(&spa->spa_refcount);
spa_config_lock_init(spa);

spa_read_history_init(spa);

avl_add(&spa_namespace_avl, spa);

/*
Expand Down Expand Up @@ -581,6 +583,8 @@ spa_remove(spa_t *spa)

refcount_destroy(&spa->spa_refcount);

spa_read_history_destroy(spa);

spa_config_lock_destroy(spa);

for (t = 0; t < TXG_SIZE; t++)
Expand Down
Loading