From aa2ef419e46b3ad7c2ad8848b7a308a5a949aba7 Mon Sep 17 00:00:00 2001 From: Tim Chase Date: Mon, 2 Feb 2015 23:55:20 -0600 Subject: [PATCH] Spurious ENOMEM returns when reading dbufs kstat Commit 7b2d78a046aa4695d434478a439a9438521d73af fixed some improper uses of snprintf(), however, in __dbuf_stats_hash_table_data() the return value of snprintf is propagated to the caller. This caused spurious ENOMEM errors when reading the dbufs kstat. This commit causes the actual number of characters written to be returned. Signed-off-by: Tim Chase Signed-off-by: Brian Behlendorf Closes #3072 --- module/zfs/dbuf_stats.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/module/zfs/dbuf_stats.c b/module/zfs/dbuf_stats.c index 0e4c18ed7..3b9c63d31 100644 --- a/module/zfs/dbuf_stats.c +++ b/module/zfs/dbuf_stats.c @@ -67,6 +67,7 @@ __dbuf_stats_hash_table_data(char *buf, size_t size, dmu_buf_impl_t *db) arc_buf_info_t abi = { 0 }; dmu_object_info_t doi = { 0 }; dnode_t *dn = DB_DNODE(db); + size_t nwritten; if (db->db_buf) arc_buf_info(db->db_buf, &abi, zfs_dbuf_state_index); @@ -74,7 +75,7 @@ __dbuf_stats_hash_table_data(char *buf, size_t size, dmu_buf_impl_t *db) if (dn) __dmu_object_info_from_dnode(dn, &doi); - (void) snprintf(buf, size, + nwritten = snprintf(buf, size, "%-16s %-8llu %-8lld %-8lld %-8lld %-8llu %-8llu %-5d %-5d %-5lu | " "%-5d %-5d %-6lld 0x%-6x %-6lu %-8llu %-12llu " "%-6lu %-6lu %-6lu %-6lu %-6lu %-8llu %-8llu %-8d %-5lu | " @@ -118,7 +119,10 @@ __dbuf_stats_hash_table_data(char *buf, size_t size, dmu_buf_impl_t *db) (u_longlong_t)doi.doi_fill_count, (u_longlong_t)doi.doi_max_offset); - return (size); + if (nwritten >= size) + return (size); + + return (nwritten + 1); } static int