From patchwork Wed Mar 2 19:01:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sorenson X-Patchwork-Id: 8484791 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9AC20C0553 for ; Wed, 2 Mar 2016 19:02:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D83220351 for ; Wed, 2 Mar 2016 19:02:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7141F2037E for ; Wed, 2 Mar 2016 19:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932071AbcCBTCG (ORCPT ); Wed, 2 Mar 2016 14:02:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53880 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754826AbcCBTCE (ORCPT ); Wed, 2 Mar 2016 14:02:04 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 50E24804EB for ; Wed, 2 Mar 2016 19:02:04 +0000 (UTC) Received: from fez.sorensonfamily.com (ovpn-116-27.rdu2.redhat.com [10.10.116.27]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u22J1xXa018926 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 2 Mar 2016 14:02:03 -0500 From: Frank Sorenson To: linux-fsdevel@vger.kernel.org Cc: dwysocha@redhat.com, lvaz@redhat.com Subject: [PATCH 4/5] fs/block_dev.c: add trace events for freeze_bdev() and thaw_bdev() Date: Wed, 2 Mar 2016 13:01:58 -0600 Message-Id: <1456945319-16283-5-git-send-email-sorenson@redhat.com> In-Reply-To: <1456945319-16283-1-git-send-email-sorenson@redhat.com> References: <1456945319-16283-1-git-send-email-sorenson@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 There is currently no visibility into when or how the filesystem on a block device became frozen, and no record of freeze/thaw activity. Add tracepoints for these events. Signed-off-by: Frank Sorenson --- include/trace/events/fs_bdev.h | 155 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 include/trace/events/fs_bdev.h diff --git a/include/trace/events/fs_bdev.h b/include/trace/events/fs_bdev.h new file mode 100644 index 0000000..8ba01c8 --- /dev/null +++ b/include/trace/events/fs_bdev.h @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2016 Red Hat, Inc., All Rights Reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM fs +#define TRACE_INCLUDE_FILE fs_bdev + +#if !defined(_TRACE_FS_BDEV_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_FS_BDEV_H_ +#include + +struct block_device; +struct super_block; +#include + +#define SUPER_ID_MAX_LEN FIELD_SIZEOF(struct super_block, s_id) +#define FSTYPE_MAX_LEN 32 /* choose an arbitrary limit */ + +TRACE_EVENT(freeze_bdev_enter, + TP_PROTO(struct block_device *bdev), + TP_ARGS(bdev), + TP_STRUCT__entry( + __array(char, comm, TASK_COMM_LEN ) + __array(char, bdevname, BDEVNAME_SIZE ) + __array(char, super_id, SUPER_ID_MAX_LEN ) + __array(char, fstype, FSTYPE_MAX_LEN ) + __field(dev_t, dev ) + __field(int, frozen ) + __field(pid_t, pid ) + ), + TP_fast_assign( + memcpy(__entry->comm, current->comm, TASK_COMM_LEN); + bdevname(bdev, __entry->bdevname); + memcpy(__entry->super_id, get_super(bdev)->s_id, SUPER_ID_MAX_LEN); + memcpy(__entry->fstype, get_super(bdev)->s_type->name, FSTYPE_MAX_LEN); + __entry->dev = get_super(bdev)->s_dev; + __entry->frozen = get_super(bdev)->s_writers.frozen; + __entry->pid = current->pid; + ), + TP_printk("comm=%s pid=%d for %s filesystem '%s' (%d:%d) bdev=%s frozen=%d", + __entry->comm, __entry->pid, + __entry->fstype, __entry->super_id, + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->bdevname, __entry->frozen + ) +); + +TRACE_EVENT(freeze_bdev_exit, + TP_PROTO(struct block_device *bdev, void *ret), + TP_ARGS(bdev, ret), + TP_STRUCT__entry( + __array(char, comm, TASK_COMM_LEN ) + __array(char, bdevname, BDEVNAME_SIZE ) + __array(char, super_id, SUPER_ID_MAX_LEN ) + __array(char, fstype, FSTYPE_MAX_LEN ) + __field(dev_t, dev ) + __field(int, frozen ) + __field(pid_t, pid ) + __field(int, ret ) + ), + TP_fast_assign( + memcpy(__entry->comm, current->comm, TASK_COMM_LEN); + bdevname(bdev, __entry->bdevname); + memcpy(__entry->super_id, get_super(bdev)->s_id, SUPER_ID_MAX_LEN); + memcpy(__entry->fstype, get_super(bdev)->s_type->name, FSTYPE_MAX_LEN); + __entry->dev = get_super(bdev)->s_dev; + __entry->frozen = get_super(bdev)->s_writers.frozen; + __entry->pid = current->pid; + __entry->ret = IS_ERR(ret) ? PTR_ERR(ret) : 0; + ), + TP_printk("comm=%s pid=%d for %s filesystem '%s' (%d:%d) bdev=%s frozen=%d ret=%d", + __entry->comm, __entry->pid, + __entry->fstype, __entry->super_id, + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->bdevname, __entry->frozen, __entry->ret + ) +); + +TRACE_EVENT(thaw_bdev_enter, + TP_PROTO(struct block_device *bdev, struct super_block *sb), + TP_ARGS(bdev, sb), + TP_STRUCT__entry( + __array(char, comm, TASK_COMM_LEN ) + __array(char, bdevname, BDEVNAME_SIZE ) + __array(char, super_id, SUPER_ID_MAX_LEN ) + __array(char, fstype, FSTYPE_MAX_LEN ) + __field(dev_t, dev ) + __field(int, frozen ) + __field(pid_t, pid ) + ), + TP_fast_assign( + memcpy(__entry->comm, current->comm, TASK_COMM_LEN); + bdevname(bdev, __entry->bdevname); + memcpy(__entry->super_id, sb->s_id, SUPER_ID_MAX_LEN); + memcpy(__entry->fstype, sb->s_type->name, FSTYPE_MAX_LEN); + __entry->dev = sb->s_dev; + __entry->frozen = sb->s_writers.frozen; + __entry->pid = current->pid; + ), + TP_printk("comm=%s pid=%d for %s filesystem '%s' (%d:%d) bdev=%s frozen=%d", + __entry->comm, __entry->pid, + __entry->fstype, __entry->super_id, + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->bdevname, __entry->frozen + ) +); + +TRACE_EVENT(thaw_bdev_exit, + TP_PROTO(struct block_device *bdev, struct super_block *sb, int ret), + TP_ARGS(bdev, sb, ret), + TP_STRUCT__entry( + __array(char, comm, TASK_COMM_LEN ) + __array(char, bdevname, BDEVNAME_SIZE ) + __array(char, super_id, SUPER_ID_MAX_LEN ) + __array(char, fstype, FSTYPE_MAX_LEN ) + __field(dev_t, dev ) + __field(int, frozen ) + __field(pid_t, pid ) + __field(int, ret ) + ), + TP_fast_assign( + memcpy(__entry->comm, current->comm, TASK_COMM_LEN); + bdevname(bdev, __entry->bdevname); + memcpy(__entry->super_id, sb->s_id, SUPER_ID_MAX_LEN); + memcpy(__entry->fstype, sb->s_type->name, FSTYPE_MAX_LEN); + __entry->dev = sb->s_dev; + __entry->frozen = sb->s_writers.frozen; + __entry->pid = current->pid; + __entry->ret = ret; + ), + TP_printk("comm=%s pid=%d for %s filesystem '%s' (%d:%d) bdev=%s frozen=%d ret=%d", + __entry->comm, __entry->pid, + __entry->fstype, __entry->super_id, + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->bdevname, __entry->frozen, __entry->ret + ) +); + +#endif /* _TRACE_FS_BDEV_H */ + +/* This part must be outside protection */ +#include