summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/super.c1
-rw-r--r--fs/btrfs/tree-log.c16
-rw-r--r--include/trace/events/btrfs.h116
3 files changed, 128 insertions, 5 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index fb15decb0861..9de67276a8ed 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -60,6 +60,7 @@
#include "verity.h"
#include "super.h"
#include "extent-tree.h"
+#include "tree-log.h"
#define CREATE_TRACE_POINTS
#include <trace/events/btrfs.h>
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 70795cd76d6f..22066635f75f 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -6884,7 +6884,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
struct btrfs_log_ctx *ctx)
{
struct btrfs_path *path;
- struct btrfs_path *dst_path;
+ struct btrfs_path *dst_path = NULL;
struct btrfs_key min_key;
struct btrfs_key max_key;
struct btrfs_root *log = inode->root->log_root;
@@ -6900,13 +6900,17 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
LIST_HEAD(delayed_ins_list);
LIST_HEAD(delayed_del_list);
+ trace_btrfs_log_inode_enter(trans, inode, ctx, log_mode);
+
path = btrfs_alloc_path();
- if (!path)
- return -ENOMEM;
+ if (!path) {
+ ret = -ENOMEM;
+ goto out;
+ }
dst_path = btrfs_alloc_path();
if (!dst_path) {
- btrfs_free_path(path);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto out;
}
min_key.objectid = ino;
@@ -7221,6 +7225,8 @@ out:
&delayed_del_list);
}
+ trace_btrfs_log_inode_exit(trans, inode, ret);
+
return ret;
}
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index cd127c79a535..9f195d0d5378 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -33,6 +33,7 @@ struct raid56_bio_trace_info;
struct find_free_extent_ctl;
struct btrfs_trans_handle;
struct btrfs_transaction;
+struct btrfs_log_ctx;
#define show_inode_type(mode) \
__print_symbolic((mode) & S_IFMT, \
@@ -124,6 +125,9 @@ struct btrfs_transaction;
EM( TRANS_STATE_SUPER_COMMITTED, "TRANS_STATE_SUPER_COMMITTED") \
EMe(TRANS_STATE_COMPLETED, "TRANS_STATE_COMPLETED")
+#define LOG_MODES \
+ EM( LOG_INODE_ALL, "LOG_INODE_ALL") \
+ EMe(LOG_INODE_EXISTS, "LOG_INODE_EXISTS")
/*
* First define the enums in the above macros to be exported to userspace via
* TRACE_DEFINE_ENUM().
@@ -140,6 +144,7 @@ QGROUP_RSV_TYPES
IO_TREE_OWNER
FLUSH_STATES
TRANSACTION_STATES
+LOG_MODES
/*
* Now redefine the EM and EMe macros to map the enums to the strings that will
@@ -951,6 +956,117 @@ TRACE_EVENT(btrfs_log_inode_parent_exit,
__entry->transid, __entry->ret)
);
+TRACE_EVENT(btrfs_log_inode_enter,
+
+ TP_PROTO(const struct btrfs_trans_handle *trans, struct btrfs_inode *inode,
+ const struct btrfs_log_ctx *ctx, int log_mode),
+
+ TP_ARGS(trans, inode, ctx, log_mode),
+
+ TP_STRUCT__entry_btrfs(
+ __field( u64, root_objectid )
+ __field( u64, ino )
+ __field( umode_t, mode )
+ __field( u64, transid )
+ __field( u64, generation )
+ __field( u64, logged_trans )
+ __field( u64, last_unlink_trans )
+ __field( u64, last_reflink_trans )
+ __field( int, last_sub_trans )
+ __field( int, last_log_commit )
+ __field( bool, logging_new_name )
+ __field( bool, logging_new_delayed_dentries )
+ __field( bool, is_conflict_inode )
+ __field( bool, full_sync )
+ __field( bool, copy_everything )
+ __field( bool, no_xattrs )
+ __field( int, log_mode )
+ ),
+
+ TP_fast_assign(
+ TP_fast_assign_fsid(inode->root->fs_info);
+ __entry->root_objectid = btrfs_root_id(inode->root);
+ __entry->ino = btrfs_ino(inode);
+ __entry->mode = inode->vfs_inode.i_mode;
+ __entry->transid = trans->transid;
+ __entry->generation = inode->generation;
+ spin_lock(&inode->lock);
+ __entry->logged_trans = inode->logged_trans;
+ __entry->last_unlink_trans = inode->last_unlink_trans;
+ __entry->last_reflink_trans = inode->last_reflink_trans;
+ __entry->last_sub_trans = inode->last_sub_trans;
+ __entry->last_log_commit = inode->last_log_commit;
+ spin_unlock(&inode->lock);
+ __entry->logging_new_name = ctx->logging_new_name;
+ __entry->logging_new_delayed_dentries = ctx->logging_new_delayed_dentries;
+ __entry->is_conflict_inode = ctx->logging_conflict_inodes;
+ __entry->full_sync =
+ test_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &inode->runtime_flags);
+ __entry->copy_everything =
+ test_bit(BTRFS_INODE_COPY_EVERYTHING, &inode->runtime_flags);
+ __entry->no_xattrs =
+ test_bit(BTRFS_INODE_NO_XATTRS, &inode->runtime_flags);
+ __entry->log_mode = log_mode;
+ ),
+
+ TP_printk_btrfs("root=%llu(%s) ino=%llu type=%s transid=%llu gen=%llu"
+ " logged_trans=%llu last_unlink_trans=%llu"
+ " last_reflink_trans=%llu last_sub_trans=%d last_log_commit=%d"
+ " logging_new_name=%d logging_new_delayed_dentries=%d"
+ " is_conflict_inode=%d full_sync=%d copy_everything=%d"
+ " no_xattrs=%d log_mode=%d(%s)",
+ show_root_type(__entry->root_objectid), __entry->ino,
+ show_inode_type(__entry->mode), __entry->transid,
+ __entry->generation, __entry->logged_trans,
+ __entry->last_unlink_trans, __entry->last_reflink_trans,
+ __entry->last_sub_trans, __entry->last_log_commit,
+ __entry->logging_new_name, __entry->logging_new_delayed_dentries,
+ __entry->is_conflict_inode, __entry->log_mode,
+ __entry->full_sync, __entry->copy_everything, __entry->no_xattrs,
+ __print_symbolic(__entry->log_mode, LOG_MODES))
+);
+
+TRACE_EVENT(btrfs_log_inode_exit,
+
+ TP_PROTO(const struct btrfs_trans_handle *trans, struct btrfs_inode *inode,
+ int ret),
+
+ TP_ARGS(trans, inode, ret),
+
+ TP_STRUCT__entry_btrfs(
+ __field( u64, root_objectid )
+ __field( u64, ino )
+ __field( u64, transid )
+ __field( u64, logged_trans )
+ __field( u64, last_reflink_trans )
+ __field( int, last_sub_trans )
+ __field( int, last_log_commit )
+ __field( int, ret )
+ ),
+
+ TP_fast_assign(
+ TP_fast_assign_fsid(inode->root->fs_info);
+ __entry->root_objectid = btrfs_root_id(inode->root);
+ __entry->ino = btrfs_ino(inode);
+ __entry->transid = trans->transid;
+ spin_lock(&inode->lock);
+ __entry->logged_trans = inode->logged_trans;
+ __entry->last_reflink_trans = inode->last_reflink_trans;
+ __entry->last_sub_trans = inode->last_sub_trans;
+ __entry->last_log_commit = inode->last_log_commit;
+ spin_unlock(&inode->lock);
+ __entry->ret = ret;
+ ),
+
+ TP_printk_btrfs("root=%llu(%s) ino=%llu transid=%llu logged_trans=%llu"
+ " last_reflink_trans=%llu last_sub_trans=%d"
+ " last_log_commit=%d ret=%d",
+ show_root_type(__entry->root_objectid), __entry->ino,
+ __entry->transid, __entry->logged_trans,
+ __entry->last_reflink_trans, __entry->last_sub_trans,
+ __entry->last_log_commit, __entry->ret)
+);
+
TRACE_EVENT(btrfs_sync_fs,
TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),