diff --git a/kmod/src/Makefile b/kmod/src/Makefile index 21058481..31093000 100644 --- a/kmod/src/Makefile +++ b/kmod/src/Makefile @@ -1,4 +1,6 @@ obj-$(CONFIG_SCOUTFS_FS) := scoutfs.o + +CFLAGS_scoutfs_trace.o = -I$(src) # define_trace.h double include scoutfs-y += block.o bloom.o chunk.o crc.o dir.o filerw.o inode.o manifest.o \ - msg.o ring.o segment.o skip.o super.o + msg.o ring.o scoutfs_trace.o segment.o skip.o super.o diff --git a/kmod/src/bloom.c b/kmod/src/bloom.c index df528afd..d41fa57c 100644 --- a/kmod/src/bloom.c +++ b/kmod/src/bloom.c @@ -20,6 +20,7 @@ #include "format.h" #include "block.h" #include "bloom.h" +#include "scoutfs_trace.h" /* * Each log segment starts with a bloom filters that spans multiple @@ -100,6 +101,7 @@ int scoutfs_set_bloom_bits(struct super_block *sb, u64 blkno, * might, and -errno if IO fails. */ int scoutfs_test_bloom_bits(struct super_block *sb, u64 blkno, + struct scoutfs_key *key, struct scoutfs_bloom_bits *bits) { struct scoutfs_bloom_block *blm; @@ -121,5 +123,10 @@ int scoutfs_test_bloom_bits(struct super_block *sb, u64 blkno, break; } + if (ret) + trace_scoutfs_bloom_hit(key); + else + trace_scoutfs_bloom_miss(key); + return ret; } diff --git a/kmod/src/bloom.h b/kmod/src/bloom.h index 4e843fbe..59739bb1 100644 --- a/kmod/src/bloom.h +++ b/kmod/src/bloom.h @@ -9,6 +9,7 @@ struct scoutfs_bloom_bits { void scoutfs_calc_bloom_bits(struct scoutfs_bloom_bits *bits, struct scoutfs_key *key, __le32 *salts); int scoutfs_test_bloom_bits(struct super_block *sb, u64 blkno, + struct scoutfs_key *key, struct scoutfs_bloom_bits *bits); int scoutfs_set_bloom_bits(struct super_block *sb, u64 blkno, struct scoutfs_bloom_bits *bits); diff --git a/kmod/src/scoutfs_trace.c b/kmod/src/scoutfs_trace.c new file mode 100644 index 00000000..38e147dc --- /dev/null +++ b/kmod/src/scoutfs_trace.c @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2016 Versity Software, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License v2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ +#include +#include +#include +#include +#include +#include +#include + +#include "super.h" +#include "format.h" +#include "inode.h" +#include "dir.h" +#include "msg.h" +#include "block.h" +#include "manifest.h" +#include "ring.h" +#include "segment.h" + +#define CREATE_TRACE_POINTS +#include "scoutfs_trace.h" diff --git a/kmod/src/scoutfs_trace.h b/kmod/src/scoutfs_trace.h new file mode 100644 index 00000000..50dde60e --- /dev/null +++ b/kmod/src/scoutfs_trace.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2016 Versity Software, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License v2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ +/* + * This has a crazy name because it's in an external module build at + * the moment. When it's merged upstream it'll move to + * include/trace/events/scoutfs.h + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM scoutfs + +#if !defined(_TRACE_SCOUTFS_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_SCOUTFS_H + +#include + +TRACE_EVENT(scoutfs_bloom_hit, + TP_PROTO(struct scoutfs_key *key), + + TP_ARGS(key), + + TP_STRUCT__entry( + __field(__u64, inode) + __field(__u8, type) + __field(__u64, offset) + ), + + TP_fast_assign( + __entry->inode = le64_to_cpu(key->inode); + __entry->type = key->type; + __entry->offset = le64_to_cpu(key->offset); + ), + + TP_printk("key %llu.%u.%llu", + __entry->inode, __entry->type, __entry->offset) +); + +TRACE_EVENT(scoutfs_bloom_miss, + TP_PROTO(struct scoutfs_key *key), + + TP_ARGS(key), + + TP_STRUCT__entry( + __field(__u64, inode) + __field(__u8, type) + __field(__u64, offset) + ), + + TP_fast_assign( + __entry->inode = le64_to_cpu(key->inode); + __entry->type = key->type; + __entry->offset = le64_to_cpu(key->offset); + ), + + TP_printk("key %llu.%u.%llu", + __entry->inode, __entry->type, __entry->offset) +); + + +#endif /* _TRACE_SCOUTFS_H */ + +/* This part must be outside protection */ +/* This part must be outside protection */ +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE scoutfs_trace +#include diff --git a/kmod/src/segment.c b/kmod/src/segment.c index 85e51c90..8dc7b696 100644 --- a/kmod/src/segment.c +++ b/kmod/src/segment.c @@ -146,7 +146,7 @@ int scoutfs_read_item(struct super_block *sb, struct scoutfs_key *key, /* XXX read-ahead all bloom blocks */ ret = scoutfs_test_bloom_bits(sb, le64_to_cpu(ment.blkno), - &bits); + key, &bits); if (ret < 0) break; if (!ret) {