From patchwork Tue Jan 31 22:53:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9548757 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 38B2160236 for ; Tue, 31 Jan 2017 23:01:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FE862832B for ; Tue, 31 Jan 2017 23:01:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24439283EC; Tue, 31 Jan 2017 23:01:08 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 BACEB2832B for ; Tue, 31 Jan 2017 23:01:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750830AbdAaXBH (ORCPT ); Tue, 31 Jan 2017 18:01:07 -0500 Received: from mail-pf0-f175.google.com ([209.85.192.175]:32977 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750796AbdAaXBG (ORCPT ); Tue, 31 Jan 2017 18:01:06 -0500 Received: by mail-pf0-f175.google.com with SMTP id y143so112699878pfb.0 for ; Tue, 31 Jan 2017 15:01:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=p4LDn414uejKhY36qP/8O9Ux564EKF+d0+s9p2Tj1YY=; b=qTpssmO5Q/bwXt1QG7ZTakgl29ho5ND42JHzhiSIAr6uDlk3jN2/rYSbK77BBVKvzy ValADSk2sqI6wR0V1um8PMZ/TNJXfxrqKpaOUPboDv7Se9nQG9tMemOhPaVMB9yJpFwq wSUub/zOPS+O4BI5RLpauc3P8HJLVndANiMXvZH/iEWbMjNjFG7rYWlPr9kLdKmH96H4 Vn1b5U+mQUfMsmFzzYBXIKlXzzU1MXzv2MJuIMvFZcJWzcWS+nCcKpNyu893jInP0dR4 LM9lDtVtUGOFKuhw3hTM34dkg8oiR3OzbrB4xJU+O4fMw9Q0JHlreLWIUBwUowo4N2Sj I1dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=p4LDn414uejKhY36qP/8O9Ux564EKF+d0+s9p2Tj1YY=; b=RJ3PEo2TqEuCBGGI5GnVwnhogHCEWGCSg+e7sY1l0YhE6WMjzsht1h4XH8FofU5rao V9guVtQ83LxMMC6qOMiyHnALCKFuqyioSGvpE1JUrzobbQ+P2k6Wg5lpj7ViM4pDnDKA GnjK69NQlM4Ieu3zq8TDBFmggtUCIOBQp7puTjUAtDoRyhh+iCmiFxbfmR0Dh37e18G+ 7NRNfzBaEmy+S7HoKrT4IMzE0bUjhU6lUdwIYjSlJgtjDET0PBcQ/6UMOYBwfOOG5j+M U/14id6gQdTXr97ChR9RfiNSNTYF5Yu3o7dNRh9SeVqXueLLcD05Lj7OUCYzUaP29tW1 h1IA== X-Gm-Message-State: AIkVDXLfTghVWHwIoX+MlIwhjsB1T4INMnugRkOiRVgpEWDcfQiBoUFRBOipsgSKsgCk4Ldj X-Received: by 10.84.194.37 with SMTP id g34mr43072140pld.105.1485903251279; Tue, 31 Jan 2017 14:54:11 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:200::b:7f05]) by smtp.gmail.com with ESMTPSA id e127sm43614618pfh.89.2017.01.31.14.54.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Jan 2017 14:54:10 -0800 (PST) From: Omar Sandoval To: Jens Axboe , linux-block@vger.kernel.org Cc: kernel-team@fb.com Subject: [PATCH 6/6] blktrace: use existing disk debugfs directory Date: Tue, 31 Jan 2017 14:53:22 -0800 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval We may already have a directory to put the blktrace stuff in if 1. The disk uses blk-mq 2. CONFIG_BLK_DEBUG_FS is enabled 3. We are tracing the whole disk and not a partition Instead of hardcoding this very specific case, let's use the new debugfs_lookup(). If the directory exists, we use it, otherwise we create one and clean it up later. Fixes: 07e4fead45e6 ("blk-mq: create debugfs directory tree") Signed-off-by: Omar Sandoval --- kernel/trace/blktrace.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 38052f625a0f..cc9d23692a35 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -470,12 +470,12 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, if (!blk_debugfs_root) goto err; - dir = debugfs_create_dir(buts->name, blk_debugfs_root); - + dir = debugfs_lookup(buts->name, blk_debugfs_root); + if (!dir) + bt->dir = dir = debugfs_create_dir(buts->name, blk_debugfs_root); if (!dir) goto err; - bt->dir = dir; bt->dev = dev; atomic_set(&bt->dropped, 0); INIT_LIST_HEAD(&bt->running_list); @@ -517,9 +517,12 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, if (atomic_inc_return(&blk_probes_ref) == 1) blk_register_tracepoints(); - return 0; + ret = 0; err: - blk_trace_free(bt); + if (dir && !bt->dir) + dput(dir); + if (ret) + blk_trace_free(bt); return ret; }