From patchwork Wed Dec 7 21:45:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 9465257 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EA63060236 for ; Wed, 7 Dec 2016 21:37:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D27E328533 for ; Wed, 7 Dec 2016 21:37:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C74ED28589; Wed, 7 Dec 2016 21:37:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 516BE28533 for ; Wed, 7 Dec 2016 21:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933040AbcLGVhl (ORCPT ); Wed, 7 Dec 2016 16:37:41 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:43341 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932791AbcLGVhg (ORCPT ); Wed, 7 Dec 2016 16:37:36 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uB7LbUrC028189 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 7 Dec 2016 21:37:30 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id uB7LbUSN021689 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 7 Dec 2016 21:37:30 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id uB7LbUdE012206; Wed, 7 Dec 2016 21:37:30 GMT Received: from localhost.us.oracle.com (/10.211.47.181) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 07 Dec 2016 13:37:29 -0800 From: Liu Bo To: linux-btrfs@vger.kernel.org Cc: Chris Mason , Jan Kara , David Sterba Subject: [PATCH 6/6] Btrfs: add tracepoint for btrfs_get_blocks_dax_fault Date: Wed, 7 Dec 2016 13:45:10 -0800 Message-Id: <1481147110-20048-7-git-send-email-bo.li.liu@oracle.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1481147110-20048-1-git-send-email-bo.li.liu@oracle.com> References: <1481147110-20048-1-git-send-email-bo.li.liu@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These TPs can help us monitor iomap content for dax reads and writes. Signed-off-by: Liu Bo --- fs/btrfs/inode.c | 9 ++++ include/trace/events/btrfs.h | 106 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9851422..b5bee38 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8067,6 +8067,8 @@ btrfs_get_blocks_dax_fault(struct inode *inode, u64 start, u64 len, struct extent_map *em; int ret = 0; + trace_btrfs_get_blocks_dax_entry(inode, start, len, create); + if (!create && start >= i_size_read(inode)) { return 0; } @@ -8190,12 +8192,19 @@ btrfs_get_blocks_dax_fault(struct inode *inode, u64 start, u64 len, map_block: ret = btrfs_em_to_iomap(root->fs_info, start, len, em, create, iomap); + if (!ret) { + if (create) + trace_btrfs_iomap_alloc(inode, start, len, iomap); + else + trace_btrfs_iomap_found(inode, start, len, iomap); + } out: free_extent_map(em); ASSERT(lockstart < lockend); unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart, lockend, &cached_state, GFP_NOFS); + trace_btrfs_get_blocks_dax_exit(inode, start, len, create); return ret; } diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index 0e04208..f7eb44f 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -7,6 +7,7 @@ #include #include #include +#include struct btrfs_root; struct btrfs_fs_info; @@ -1471,6 +1472,111 @@ TRACE_EVENT(qgroup_update_counters, __entry->cur_new_count) ); +DECLARE_EVENT_CLASS(btrfs_iomap_class, + + TP_PROTO(struct inode *inode, u64 offset, u64 len, struct iomap *iomap), + + TP_ARGS(inode, offset, len, iomap), + + TP_STRUCT__entry_btrfs( + __field( u64, ino ) + __field( u64, isize ) + __field( u64, disk_isize ) + __field( u64, root_objectid ) + __field( u64, offset ) + __field( u64, len ) + __field( u64, startoff ) + __field( u64, blockstart ) + __field( u64, blocklen ) + __field( int, type ) + ), + + TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), + __entry->ino = btrfs_ino(inode); + __entry->isize = i_size_read(inode); + __entry->disk_isize = BTRFS_I(inode)->disk_i_size; + __entry->root_objectid = + BTRFS_I(inode)->root->root_key.objectid; + __entry->offset = offset; + __entry->len = len; + __entry->startoff = iomap ? iomap->offset : 0; + __entry->blockstart = iomap ? (iomap->blkno << 9) : 0; + __entry->blocklen = iomap ? iomap->length : 0; + __entry->type = iomap ? iomap->type : 0; + ), + + TP_printk_btrfs("root 0x%llx(%s) ino 0x%llx size 0x%llx " + "disk_isize 0x%llx offset 0x%llx len 0x%llx " + "startoff 0x%llx blockstart %llu blocklen 0x%llx " + " type %d", + show_root_type(__entry->root_objectid), + __entry->ino, + __entry->isize, + __entry->disk_isize, + __entry->offset, + __entry->len, + __entry->startoff, + __entry->blockstart, + __entry->blocklen, + __entry->type) +); + +#define DEFINE_IOMAP_EVENT(name) \ +DEFINE_EVENT(btrfs_iomap_class, name, \ + TP_PROTO(struct inode *inode, u64 offset, u64 len, \ + struct iomap *iomap), \ + TP_ARGS(inode, offset, len, iomap)); + +DEFINE_IOMAP_EVENT(btrfs_iomap_alloc) +DEFINE_IOMAP_EVENT(btrfs_iomap_found) + +DECLARE_EVENT_CLASS(btrfs_get_blocks_dax, + + TP_PROTO(struct inode *inode, u64 offset, u64 len, int create), + + TP_ARGS(inode, offset, len, create), + + TP_STRUCT__entry_btrfs( + __field( u64, root_objectid ) + __field( u64, ino ) + __field( u64, isize ) + __field( u64, disk_isize ) + __field( u64, offset ) + __field( u64, len ) + __field( int, create ) + ), + + TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), + __entry->root_objectid = BTRFS_I(inode)->root->objectid; + __entry->ino = btrfs_ino(inode); + __entry->isize = i_size_read(inode); + __entry->disk_isize = BTRFS_I(inode)->disk_i_size; + __entry->offset = offset; + __entry->len = len; + __entry->create = create; + ), + + TP_printk_btrfs("root 0x%llx(%s) ino 0x%llx isize 0x%llx " + "disk_isize 0x%llx offset 0x%llx len 0x%llx create %d", + show_root_type(__entry->root_objectid), + __entry->ino, + __entry->isize, + __entry->disk_isize, + __entry->offset, + __entry->len, + __entry->create + ) +); + +#define DEFINE_GETBLOCKS_DAX_EVENT(name) \ +DEFINE_EVENT(btrfs_get_blocks_dax, name, \ + TP_PROTO(struct inode *inode, u64 offset, u64 len, \ + int create), \ + TP_ARGS(inode, offset, len, create)); + +DEFINE_GETBLOCKS_DAX_EVENT(btrfs_get_blocks_dax_entry) +DEFINE_GETBLOCKS_DAX_EVENT(btrfs_get_blocks_dax_exit) + #endif /* _TRACE_BTRFS_H */ /* This part must be outside protection */