diff --git a/kmod/src/super.c b/kmod/src/super.c index 27630b6a..5e409db0 100644 --- a/kmod/src/super.c +++ b/kmod/src/super.c @@ -128,6 +128,12 @@ static int read_supers(struct super_block *sb) return 0; } +/* + * Only used for tracing output, it's a convenient way to cheaply differentiate + * messages from different super blocks. + */ +static atomic64_t scoutfs_sb_ctr = ATOMIC64_INIT(0); + static int scoutfs_fill_super(struct super_block *sb, void *data, int silent) { struct scoutfs_sb_info *sbi; @@ -158,6 +164,8 @@ static int scoutfs_fill_super(struct super_block *sb, void *data, int silent) init_waitqueue_head(&sbi->trans_write_wq); INIT_LIST_HEAD(&sbi->roster_head); + sbi->ctr = atomic64_inc_return(&scoutfs_sb_ctr); + /* XXX can have multiple mounts of a device, need mount id */ sbi->kset = kset_create_and_add(sb->s_id, NULL, &scoutfs_kset->kobj); if (!sbi->kset) diff --git a/kmod/src/super.h b/kmod/src/super.h index 2d0392ac..c99a77d7 100644 --- a/kmod/src/super.h +++ b/kmod/src/super.h @@ -14,6 +14,8 @@ struct wrlock_context; struct scoutfs_sb_info { struct super_block *sb; + u64 ctr; + struct scoutfs_super_block super; spinlock_t next_ino_lock; diff --git a/kmod/src/trace.h b/kmod/src/trace.h index 96e0cd77..0e9e3735 100644 --- a/kmod/src/trace.h +++ b/kmod/src/trace.h @@ -97,18 +97,22 @@ static inline void only_check_format(const char *fmt, ...) */ #define scoutfs_trace(sb, fmt, ...) \ do { \ + struct scoutfs_sb_info *__sbi = SCOUTFS_SB(sb); \ static char __scoutfs_trace_section __fmt[] = \ - "ns %llu sb %llx pid %llu cpu %llu "fmt; \ + "[%llu.%llu] %llu %llu %llu " __stringify(__LINE__) ": "\ + fmt; \ + struct timeval __tv; \ \ BUILD_BUG_ON(fmt[sizeof(fmt) - 2] == '\n'); \ \ /* check the caller's format before we prepend things to it */ \ only_check_format(fmt, CAST_ARGS_U64(__VA_ARGS__)); \ \ - __trace_write(__fmt, \ - CAST_ARGS_U64(sched_clock(), (long)(sb), \ - current->pid, get_cpu(), \ - __VA_ARGS__)); \ + do_gettimeofday(&__tv); \ + \ + __trace_write(__fmt, CAST_ARGS_U64(__tv.tv_sec, __tv.tv_usec, \ + __sbi->ctr, current->pid, get_cpu(), \ + __VA_ARGS__)); \ put_cpu(); \ } while (0)