From patchwork Fri Mar 25 17:25:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 8672601 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CDF5C9F44D for ; Fri, 25 Mar 2016 17:26:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF870202E9 for ; Fri, 25 Mar 2016 17:26:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B32EF202E5 for ; Fri, 25 Mar 2016 17:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754197AbcCYR0l (ORCPT ); Fri, 25 Mar 2016 13:26:41 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:57067 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754145AbcCYR00 (ORCPT ); Fri, 25 Mar 2016 13:26:26 -0400 Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.11/8.16.0.11) with SMTP id u2PHOIkf008879 for ; Fri, 25 Mar 2016 10:26:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=adDL77Vw6BpVTxyAdnL6bHUBhFWkbCqX8Gr18hF7LXk=; b=lsWHkfmMRcILvnwgcjMAab2/fjxCVKQkduuPyRZqVimEdrAPBw+t6tZXBis/6ejLT6vP 0ETx89TJBxWeVJcIsybnh5l6eWRMGnEvRpHAcWU1c3AGJ39WIqd1S2nBO9eL+i9pZVbp vuWGXabSCZhdB44gfF9D+mKl4vcD0y3ikOE= Received: from mail.thefacebook.com ([199.201.64.23]) by m0001303.ppops.net with ESMTP id 21vybh2pk6-1 (version=TLSv1 cipher=AES128-SHA bits=128 verify=NOT) for ; Fri, 25 Mar 2016 10:26:25 -0700 Received: from localhost (192.168.52.123) by mail.thefacebook.com (192.168.16.22) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 25 Mar 2016 10:26:22 -0700 From: Josef Bacik To: Subject: [PATCH 10/14] Btrfs: add tracepoints for flush events Date: Fri, 25 Mar 2016 13:25:56 -0400 Message-ID: <1458926760-17563-11-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1458926760-17563-1-git-send-email-jbacik@fb.com> References: <1458926760-17563-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-03-25_04:, , signatures=0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We want to track when we're triggering flushing from our reservation code and what flushing is being done when we start flushing. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/ctree.h | 9 +++++ fs/btrfs/extent-tree.c | 22 ++++++------ include/trace/events/btrfs.h | 82 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 7437c8a..55a24c5 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3611,6 +3611,15 @@ enum btrfs_reserve_flush_enum { BTRFS_RESERVE_FLUSH_ALL, }; +enum btrfs_flush_state { + FLUSH_DELAYED_ITEMS_NR = 1, + FLUSH_DELAYED_ITEMS = 2, + FLUSH_DELALLOC = 3, + FLUSH_DELALLOC_WAIT = 4, + ALLOC_CHUNK = 5, + COMMIT_TRANS = 6, +}; + int btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len); int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes); void btrfs_free_reserved_data_space(struct inode *inode, u64 start, u64 len); diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 1221c07..0ecceea 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4762,15 +4762,6 @@ commit: return btrfs_commit_transaction(trans, root); } -enum flush_state { - FLUSH_DELAYED_ITEMS_NR = 1, - FLUSH_DELAYED_ITEMS = 2, - FLUSH_DELALLOC = 3, - FLUSH_DELALLOC_WAIT = 4, - ALLOC_CHUNK = 5, - COMMIT_TRANS = 6, -}; - struct reserve_ticket { u64 bytes; int error; @@ -4828,6 +4819,8 @@ static int flush_space(struct btrfs_root *root, break; } + trace_btrfs_flush_space(root->fs_info, space_info->flags, num_bytes, + orig_bytes, state, ret); return ret; } @@ -5105,6 +5098,10 @@ static int __reserve_metadata_bytes(struct btrfs_root *root, list_add_tail(&ticket.list, &space_info->tickets); if (!space_info->flush) { space_info->flush = 1; + trace_btrfs_trigger_flush(root->fs_info, + space_info->flags, + orig_bytes, flush, + "enospc"); queue_work(system_unbound_wq, &root->fs_info->async_reclaim_work); } @@ -5121,9 +5118,14 @@ static int __reserve_metadata_bytes(struct btrfs_root *root, */ if (!root->fs_info->log_root_recovering && need_do_async_reclaim(space_info, root->fs_info, used) && - !work_busy(&root->fs_info->async_reclaim_work)) + !work_busy(&root->fs_info->async_reclaim_work)) { + trace_btrfs_trigger_flush(root->fs_info, + space_info->flags, + orig_bytes, flush, + "preempt"); queue_work(system_unbound_wq, &root->fs_info->async_reclaim_work); + } } spin_unlock(&space_info->lock); if (!ret || flush == BTRFS_RESERVE_NO_FLUSH) diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index 3e61deb8..6c192dc 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -784,6 +784,88 @@ TRACE_EVENT(btrfs_space_reservation, __entry->bytes) ); +#define show_flush_action(action) \ + __print_symbolic(action, \ + { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \ + { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \ + { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"}) + +TRACE_EVENT(btrfs_trigger_flush, + + TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 bytes, + int flush, char *reason), + + TP_ARGS(fs_info, flags, bytes, flush, reason), + + TP_STRUCT__entry( + __array( u8, fsid, BTRFS_UUID_SIZE ) + __field( u64, flags ) + __field( u64, bytes ) + __field( int, flush ) + __string( reason, reason ) + ), + + TP_fast_assign( + memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE); + __entry->flags = flags; + __entry->bytes = bytes; + __entry->flush = flush; + __assign_str(reason, reason) + ), + + TP_printk("%pU: %s: flush = %d(%s), flags = %llu(%s), bytes = %llu", + __entry->fsid, __get_str(reason), __entry->flush, + show_flush_action(__entry->flush), + (unsigned long long)__entry->flags, + __print_flags((unsigned long)__entry->flags, "|", + BTRFS_GROUP_FLAGS), + (unsigned long long)__entry->bytes) +); + +#define show_flush_state(state) \ + __print_symbolic(state, \ + { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \ + { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \ + { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \ + { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \ + { ALLOC_CHUNK, "ALLOC_CHUNK"}, \ + { COMMIT_TRANS, "COMMIT_TRANS"}) + +TRACE_EVENT(btrfs_flush_space, + + TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes, + u64 orig_bytes, int state, int ret), + + TP_ARGS(fs_info, flags, num_bytes, orig_bytes, state, ret), + + TP_STRUCT__entry( + __array( u8, fsid, BTRFS_UUID_SIZE ) + __field( u64, flags ) + __field( u64, num_bytes ) + __field( u64, orig_bytes ) + __field( int, state ) + __field( int, ret ) + ), + + TP_fast_assign( + memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE); + __entry->flags = flags; + __entry->num_bytes = num_bytes; + __entry->orig_bytes = orig_bytes; + __entry->state = state; + __entry->ret = ret; + ), + + TP_printk("%pU: state = %d(%s), flags = %llu(%s), num_bytes = %llu, " + "orig_bytes = %llu, ret = %d", __entry->fsid, __entry->state, + show_flush_state(__entry->state), + (unsigned long long)__entry->flags, + __print_flags((unsigned long)__entry->flags, "|", + BTRFS_GROUP_FLAGS), + (unsigned long long)__entry->num_bytes, + (unsigned long long)__entry->orig_bytes, __entry->ret) +); + DECLARE_EVENT_CLASS(btrfs__reserved_extent, TP_PROTO(struct btrfs_root *root, u64 start, u64 len),