From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72CE0C433E1 for ; Sat, 16 May 2020 03:20:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3C59520657 for ; Sat, 16 May 2020 03:20:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C59520657 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6EAEA80007; Fri, 15 May 2020 23:20:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C7FC80005; Fri, 15 May 2020 23:20:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 516C280007; Fri, 15 May 2020 23:20:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0100.hostedemail.com [216.40.44.100]) by kanga.kvack.org (Postfix) with ESMTP id 391C480005 for ; Fri, 15 May 2020 23:20:08 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D87F6181AEF1A for ; Sat, 16 May 2020 03:20:07 +0000 (UTC) X-FDA: 76821128454.02.screw75_1e33b8dc0103e X-HE-Tag: screw75_1e33b8dc0103e X-Filterd-Recvd-Size: 5184 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Sat, 16 May 2020 03:20:07 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id y198so347179pfb.4 for ; Fri, 15 May 2020 20:20:07 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=vwSG5ItKx2r5dbDOPcw9Nyt7jOYmxP5wgs6FTcAWgW0=; b=sBwlConO4K9smh/0MXcEIXVvH2AHZsl1Hslj5EtzysCRKcTIK/0iwd8wNUcNXZc1/6 t5ZDpFxMrlfOZzOj42GSM0j7lEQRrEmytKP3Kw2lcsPRei3bbeNVMm8LNBgz4SljVq0X O1FaypV88tcApuffqgYYDbjyKB8hOEXg2I/+sstkEAcYI5LyatVdyah4DXptZcAM4fQT rs3Rn3NVQpSpC/YX0FVjSofQ6F2GcmfzbuMI4r2kkP0hGzY4UqsIMwvIXgc0Te0lDLWl HzTDDFBop/sz25D2ZhZJ98p9SCdpyf1pSBaaAtt/pCKdIpU7QBYJo10VrR+XoDhhKYUY aoJw== X-Gm-Message-State: AOAM530muLmTGhGNpDR3w83p/oGJn7eMwFKH93fHaQHD3VVPqVijVcJ7 TNFEytUJfsvNnUd1TnyjW/k= X-Google-Smtp-Source: ABdhPJwU3+TI8g+EyIeQPhXO+/cx+sT8afNbB1U4k6Kb4bGm6M4IeutMRhzShn9t7OeCKVjIaOL/UA== X-Received: by 2002:a63:da10:: with SMTP id c16mr2649800pgh.208.1589599206435; Fri, 15 May 2020 20:20:06 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id z18sm3070391pfj.148.2020.05.15.20.20.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 20:20:04 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id BBBAC422E5; Sat, 16 May 2020 03:19:59 +0000 (UTC) From: Luis Chamberlain To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bvanassche@acm.org, gregkh@linuxfoundation.org, rostedt@goodmis.org, mingo@redhat.com, jack@suse.cz, ming.lei@redhat.com, nstange@suse.de, akpm@linux-foundation.org Cc: mhocko@suse.com, yukuai3@huawei.com, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH v5 6/7] blktrace: break out of blktrace setup on concurrent calls Date: Sat, 16 May 2020 03:19:55 +0000 Message-Id: <20200516031956.2605-7-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200516031956.2605-1-mcgrof@kernel.org> References: <20200516031956.2605-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: We use one blktrace per request_queue, that means one per the entire disk. So we cannot run one blktrace on say /dev/vda and then /dev/vda1, or just two calls on /dev/vda. We check for concurrent setup only at the very end of the blktrace setup = though. If we try to run two concurrent blktraces on the same block device the second one will fail, and the first one seems to go on. However when one tries to kill the first one one will see things like this: The kernel will show these: ``` debugfs: File 'dropped' in directory 'nvme1n1' already present! debugfs: File 'msg' in directory 'nvme1n1' already present! debugfs: File 'trace0' in directory 'nvme1n1' already present! `` And userspace just sees this error message for the second call: ``` blktrace /dev/nvme1n1 BLKTRACESETUP(2) /dev/nvme1n1 failed: 5/Input/output error ``` The first userspace process #1 will also claim that the files were taken underneath their nose as well. The files are taken away form the first process given that when the second blktrace fails, it will follow up with a BLKTRACESTOP and BLKTRACETEARDOWN. This means that even if go-happy process #1 is waiting for blktrace data, we *have* been asked to take teardown the blktrace. This can easily be reproduced with break-blktrace [0] run_0005.sh test. Just break out early if we know we're already going to fail, this will prevent trying to create the files all over again, which we know still exist. [0] https://github.com/mcgrof/break-blktrace Signed-off-by: Luis Chamberlain --- kernel/trace/blktrace.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 6c10a1427de2..ac6650828d49 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -3,6 +3,9 @@ * Copyright (C) 2006 Jens Axboe * */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -493,6 +496,16 @@ static int do_blk_trace_setup(struct request_queue *= q, char *name, dev_t dev, */ strreplace(buts->name, '/', '_'); =20 + /* + * bdev can be NULL, as with scsi-generic, this is a helpful as + * we can be. + */ + if (q->blk_trace) { + pr_warn("Concurrent blktraces are not allowed on %s\n", + buts->name); + return -EBUSY; + } + bt =3D kzalloc(sizeof(*bt), GFP_KERNEL); if (!bt) return -ENOMEM; --=20 2.26.2