Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1172018yba; Tue, 2 Apr 2019 03:56:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaG/iS5u3IcUx4+2xAl+rNW+4xR6cJ35b3HsH4kDRjAUO2GSQzxHbKua3FbnyUgqVNzevI X-Received: by 2002:a63:fa46:: with SMTP id g6mr10662015pgk.382.1554202573498; Tue, 02 Apr 2019 03:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554202573; cv=none; d=google.com; s=arc-20160816; b=jo3FXPCNr++Yf1/6dKEO8ckj++/QVsh7THY0Bcjxk8q4RgaDtxuVUqoMdVIJTNEoxJ LQ9FBNQ65eEEZ2KYdK9slw80nnVU46K+MOh+k/LFGUkouEnsE+IhNhbQyFLYar2eogTK G/FLADOJylxTgcXDqIyUgwNvVc5WlQp2ujLDi37a/D4+kKF1boVx9P3q1DOCH547YL4E s2IUnp8G3VPEhIM23yCKOGIgGFwFzNrKI0XqdcLavfsOsWVqiLK0iF9e9Jf0297NnV+b Euj9MC0eVFLu9LluX9jaEfrvRfy+IfCgxBHd41xsTgWp4eeVs695ixmamlEFZzQI9RPI Q4oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=YmERn3xAcnmi/WFiIONPHgM/mVlnKciBWMNTci4mCXM=; b=tJ5SScJmYN2wU88C7W3tyFKx3FeVQrGmZfjfpVJffOdRWWzx+m8u0F9xR9flAuWBSM 4WTJsp1uMd2bWFpOLk2qa64TtNmTJh/Z4kiLMtfXYsmYtogof+PLYD30woqdJjIwgoHI ssxH3cJR0pn5TxjMAD+4EcmSbNLkn61ycer8T4+w5kz9HNklmq+G6TZcJhZO5UB4yYjY JQT/EGa7PLNIEvNa1/uogfdw7gmQeylrzm7ytIcQfD5aHoxwFjCmBLBoZPL9bWmDTVmH 8UQtotJIu8cAFgq/HEu4Gd93maEcxtv5Ob23haaZ/SX+d7Xlq/cnP8JoPgfV17OYzd+5 o3lQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si11400175pgi.449.2019.04.02.03.55.57; Tue, 02 Apr 2019 03:56:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730087AbfDBKxK (ORCPT + 99 others); Tue, 2 Apr 2019 06:53:10 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:2521 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729575AbfDBKwx (ORCPT ); Tue, 2 Apr 2019 06:52:53 -0400 Received: from DGGEMM405-HUB.china.huawei.com (unknown [10.3.20.213]) by Forcepoint Email with ESMTP id 14953D123829FF00D58E; Tue, 2 Apr 2019 18:52:52 +0800 (CST) Received: from dggeme763-chm.china.huawei.com (10.3.19.109) by DGGEMM405-HUB.china.huawei.com (10.3.20.213) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 2 Apr 2019 18:52:51 +0800 Received: from szvp000201624.huawei.com (10.120.216.130) by dggeme763-chm.china.huawei.com (10.3.19.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Tue, 2 Apr 2019 18:52:51 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH 5/5] f2fs: add tracepoint for f2fs_file_write_iter() Date: Tue, 2 Apr 2019 18:52:22 +0800 Message-ID: <20190402105222.28374-5-yuchao0@huawei.com> X-Mailer: git-send-email 2.18.0.rc1 In-Reply-To: <20190402105222.28374-1-yuchao0@huawei.com> References: <20190402105222.28374-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.120.216.130] X-ClientProxiedBy: dggeme710-chm.china.huawei.com (10.1.199.106) To dggeme763-chm.china.huawei.com (10.3.19.109) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds tracepoint for f2fs_file_write_iter(). Signed-off-by: Chao Yu --- fs/f2fs/file.c | 28 +++++++++++++++++++--------- include/trace/events/f2fs.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 578486e03427..65e14ec7366f 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3037,15 +3037,21 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) struct inode *inode = file_inode(file); ssize_t ret; - if (unlikely(f2fs_cp_error(F2FS_I_SB(inode)))) - return -EIO; + if (unlikely(f2fs_cp_error(F2FS_I_SB(inode)))) { + ret = -EIO; + goto out; + } - if ((iocb->ki_flags & IOCB_NOWAIT) && !(iocb->ki_flags & IOCB_DIRECT)) - return -EINVAL; + if ((iocb->ki_flags & IOCB_NOWAIT) && !(iocb->ki_flags & IOCB_DIRECT)) { + ret = -EINVAL; + goto out; + } if (!inode_trylock(inode)) { - if (iocb->ki_flags & IOCB_NOWAIT) - return -EAGAIN; + if (iocb->ki_flags & IOCB_NOWAIT) { + ret = -EAGAIN; + goto out; + } inode_lock(inode); } @@ -3068,7 +3074,8 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) clear_inode_flag(inode, FI_NO_PREALLOC); inode_unlock(inode); - return -EAGAIN; + ret = -EAGAIN; + goto out; } } else { @@ -3079,7 +3086,8 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) if (err) { clear_inode_flag(inode, FI_NO_PREALLOC); inode_unlock(inode); - return err; + ret = err; + goto out; } } ret = __generic_file_write_iter(iocb, from); @@ -3093,7 +3101,9 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) f2fs_update_iostat(F2FS_I_SB(inode), APP_WRITE_IO, ret); } inode_unlock(inode); - +out: + trace_f2fs_file_write_iter(inode, iocb->ki_pos, + iov_iter_count(from), ret); if (ret > 0) ret = generic_write_sync(iocb, ret); return ret; diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h index 1b39b50511f5..9d63457c1232 100644 --- a/include/trace/events/f2fs.h +++ b/include/trace/events/f2fs.h @@ -533,6 +533,37 @@ TRACE_EVENT(f2fs_truncate_partial_nodes, __entry->err) ); +TRACE_EVENT(f2fs_file_write_iter, + + TP_PROTO(struct inode *inode, unsigned long offset, + unsigned long length, int ret), + + TP_ARGS(inode, offset, length, ret), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(unsigned long, offset) + __field(unsigned long, length) + __field(int, ret) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->offset = offset; + __entry->length = length; + __entry->ret = ret; + ), + + TP_printk("dev = (%d,%d), ino = %lu, " + "offset = %lu, length = %lu, written(err) = %d", + show_dev_ino(__entry), + __entry->offset, + __entry->length, + __entry->ret) +); + TRACE_EVENT(f2fs_map_blocks, TP_PROTO(struct inode *inode, struct f2fs_map_blocks *map, int ret), -- 2.18.0.rc1