svn commit: r277583 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Xin LI
delphij at FreeBSD.org
Fri Jan 23 18:23:20 UTC 2015
Author: delphij
Date: Fri Jan 23 18:23:19 2015
New Revision: 277583
URL: https://svnweb.freebsd.org/changeset/base/277583
Log:
MFC r275748: MFV r247174:
Expose arc_meta_limit, et al via kstats.
Note that as a result, vfs.zfs.arc_meta_used is removed.
The existing vfs.zfs.arc_meta_limit sysctl/tunable is retained
with a SYSCTL_PROC wrapper.
Illumos ZFS issues:
3561 arc_meta_limit should be exposed via kstats
Relnotes: yes
Modified:
stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Fri Jan 23 18:16:36 2015 (r277582)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Fri Jan 23 18:23:19 2015 (r277583)
@@ -205,6 +205,7 @@ uint64_t zfs_arc_average_blocksize = 8 *
u_int zfs_arc_free_target = 0;
static int sysctl_vfs_zfs_arc_free_target(SYSCTL_HANDLER_ARGS);
+static int sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HANDLER_ARGS);
#ifdef _KERNEL
static void
@@ -262,6 +263,15 @@ sysctl_vfs_zfs_arc_free_target(SYSCTL_HA
return (0);
}
+
+/*
+ * Must be declared here, before the definition of corresponding kstat
+ * macro which uses the same names will confuse the compiler.
+ */
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_meta_limit,
+ CTLTYPE_U64 | CTLFLAG_MPSAFE | CTLFLAG_RW, 0, sizeof(uint64_t),
+ sysctl_vfs_zfs_arc_meta_limit, "QU",
+ "ARC metadata limit");
#endif
/*
@@ -416,6 +426,9 @@ typedef struct arc_stats {
kstat_named_t arcstat_duplicate_buffers;
kstat_named_t arcstat_duplicate_buffers_size;
kstat_named_t arcstat_duplicate_reads;
+ kstat_named_t arcstat_meta_used;
+ kstat_named_t arcstat_meta_limit;
+ kstat_named_t arcstat_meta_max;
} arc_stats_t;
static arc_stats_t arc_stats = {
@@ -493,7 +506,10 @@ static arc_stats_t arc_stats = {
{ "memory_throttle_count", KSTAT_DATA_UINT64 },
{ "duplicate_buffers", KSTAT_DATA_UINT64 },
{ "duplicate_buffers_size", KSTAT_DATA_UINT64 },
- { "duplicate_reads", KSTAT_DATA_UINT64 }
+ { "duplicate_reads", KSTAT_DATA_UINT64 },
+ { "arc_meta_used", KSTAT_DATA_UINT64 },
+ { "arc_meta_limit", KSTAT_DATA_UINT64 },
+ { "arc_meta_max", KSTAT_DATA_UINT64 }
};
#define ARCSTAT(stat) (arc_stats.stat.value.ui64)
@@ -555,6 +571,9 @@ static arc_state_t *arc_l2c_only;
#define arc_c ARCSTAT(arcstat_c) /* target size of cache */
#define arc_c_min ARCSTAT(arcstat_c_min) /* min target cache size */
#define arc_c_max ARCSTAT(arcstat_c_max) /* max target cache size */
+#define arc_meta_limit ARCSTAT(arcstat_meta_limit) /* max size for metadata */
+#define arc_meta_used ARCSTAT(arcstat_meta_used) /* size of metadata */
+#define arc_meta_max ARCSTAT(arcstat_meta_max) /* max size of metadata */
#define L2ARC_IS_VALID_COMPRESS(_c_) \
((_c_) == ZIO_COMPRESS_LZ4 || (_c_) == ZIO_COMPRESS_EMPTY)
@@ -562,13 +581,6 @@ static arc_state_t *arc_l2c_only;
static int arc_no_grow; /* Don't try to grow cache size */
static uint64_t arc_tempreserve;
static uint64_t arc_loaned_bytes;
-static uint64_t arc_meta_used;
-static uint64_t arc_meta_limit;
-static uint64_t arc_meta_max = 0;
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_meta_used, CTLFLAG_RD, &arc_meta_used, 0,
- "ARC metadata used");
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_meta_limit, CTLFLAG_RW, &arc_meta_limit, 0,
- "ARC metadata limit");
typedef struct l2arc_buf_hdr l2arc_buf_hdr_t;
@@ -629,6 +641,26 @@ struct arc_buf_hdr {
list_node_t b_l2node;
};
+#ifdef _KERNEL
+static int
+sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HANDLER_ARGS)
+{
+ uint64_t val;
+ int err;
+
+ val = arc_meta_limit;
+ err = sysctl_handle_64(oidp, &val, 0, req);
+ if (err != 0 || req->newptr == NULL)
+ return (err);
+
+ if (val <= 0 || val > arc_c_max)
+ return (EINVAL);
+
+ arc_meta_limit = val;
+ return (0);
+}
+#endif
+
static arc_buf_t *arc_eviction_list;
static kmutex_t arc_eviction_mtx;
static arc_buf_hdr_t arc_eviction_hdr;
@@ -1482,7 +1514,7 @@ arc_space_consume(uint64_t space, arc_sp
break;
}
- atomic_add_64(&arc_meta_used, space);
+ ARCSTAT_INCR(arcstat_meta_used, space);
atomic_add_64(&arc_size, space);
}
@@ -1509,7 +1541,7 @@ arc_space_return(uint64_t space, arc_spa
ASSERT(arc_meta_used >= space);
if (arc_meta_max < arc_meta_used)
arc_meta_max = arc_meta_used;
- atomic_add_64(&arc_meta_used, -space);
+ ARCSTAT_INCR(arcstat_meta_used, -space);
ASSERT(arc_size >= space);
atomic_add_64(&arc_size, -space);
}
More information about the svn-src-stable
mailing list