From 08a6fab7256634690e7bb87f51088de3512a6e26 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 7 May 2018 11:42:31 -0700 Subject: [PATCH] scoutfs: always trace item create/delete ret Add a trace event for item creation and always trace the return value of create and delete events. Signed-off-by: Zach Brown --- kmod/src/item.c | 25 ++++++++++++++++--------- kmod/src/scoutfs_trace.h | 4 ++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/kmod/src/item.c b/kmod/src/item.c index 6dc2731e..15f4d326 100644 --- a/kmod/src/item.c +++ b/kmod/src/item.c @@ -1046,15 +1046,17 @@ int scoutfs_item_create(struct super_block *sb, struct scoutfs_key *key, unsigned long flags; int ret; - if (invalid_key_val(key, val)) - return -EINVAL; - - if (WARN_ON_ONCE(!lock_coverage(lock, key, DLM_LOCK_EX))) - return -EINVAL; + if (invalid_key_val(key, val) || + WARN_ON_ONCE(!lock_coverage(lock, key, DLM_LOCK_EX))) { + ret = -EINVAL; + goto out; + } item = alloc_item(sb, key, val); - if (!item) - return -ENOMEM; + if (!item) { + ret = -ENOMEM; + goto out; + } do { spin_lock_irqsave(&cac->lock, flags); @@ -1078,6 +1080,8 @@ int scoutfs_item_create(struct super_block *sb, struct scoutfs_key *key, if (ret) free_item(sb, item); +out: + trace_scoutfs_item_create(sb, key, ret); return ret; } @@ -1355,8 +1359,10 @@ int scoutfs_item_delete(struct super_block *sb, struct scoutfs_key *key, unsigned long flags; int ret; - if (WARN_ON_ONCE(!lock_coverage(lock, key, DLM_LOCK_EX))) - return -EINVAL; + if (WARN_ON_ONCE(!lock_coverage(lock, key, DLM_LOCK_EX))) { + ret = -EINVAL; + goto out; + } do { spin_lock_irqsave(&cac->lock, flags); @@ -1377,6 +1383,7 @@ int scoutfs_item_delete(struct super_block *sb, struct scoutfs_key *key, (ret = scoutfs_manifest_read_items(sb, key, &lock->start, &lock->end)) == 0); +out: trace_scoutfs_item_delete(sb, key, ret); return ret; } diff --git a/kmod/src/scoutfs_trace.h b/kmod/src/scoutfs_trace.h index 29c3b3bf..d31c8d3d 100644 --- a/kmod/src/scoutfs_trace.h +++ b/kmod/src/scoutfs_trace.h @@ -249,6 +249,10 @@ DECLARE_EVENT_CLASS(scoutfs_key_ret_class, __entry->fsid, SK_ARG(&__entry->key), __entry->ret) ); +DEFINE_EVENT(scoutfs_key_ret_class, scoutfs_item_create, + TP_PROTO(struct super_block *sb, struct scoutfs_key *key, int ret), + TP_ARGS(sb, key, ret) +); DEFINE_EVENT(scoutfs_key_ret_class, scoutfs_item_delete, TP_PROTO(struct super_block *sb, struct scoutfs_key *key, int ret), TP_ARGS(sb, key, ret)