From patchwork Thu Apr 12 18:11:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Jenkins X-Patchwork-Id: 10339113 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 1ACD360365 for ; Thu, 12 Apr 2018 18:12:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BDE522376 for ; Thu, 12 Apr 2018 18:12:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F23FB2267B; Thu, 12 Apr 2018 18:12:44 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 D24C922376 for ; Thu, 12 Apr 2018 18:12:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752946AbeDLSMj (ORCPT ); Thu, 12 Apr 2018 14:12:39 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:51409 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752934AbeDLSMh (ORCPT ); Thu, 12 Apr 2018 14:12:37 -0400 Received: by mail-wm0-f67.google.com with SMTP id u189so31038wmd.1; Thu, 12 Apr 2018 11:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SFkUKjh+FuqQgilAjijXlfqIaPxDjTkwax6kkxBtPPU=; b=d1QCZnLLmClwEachOvLvaV1FjIwov0g/L52QC5tL8jeIGy4jbvWOwFzIRNUffvWlqn yFD5sR0BmVOm04ft7eFUfb0FCmZs6DSaCHflcqS9rGAg/mb+ApZVYI3c8UmAVHZxLJFy /+CndT7E3dYkBlKNTAKuyU+fLNSd7pNKLsYlbiJSnrJpmRwXJOWm0AHMg348dmTisVAa Y4O3MWDYD3bHxCBbT/ww5wvxia614eFbMYJouB27zeuq/ch/np+QT9jiTTGRVZY0Cein OUI83ZwagP4EzKookt83KoObwSA99ziJKzo4YyNtCUy83ymqjxq0OG58by+NN5J++bx7 VCQw== 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; bh=SFkUKjh+FuqQgilAjijXlfqIaPxDjTkwax6kkxBtPPU=; b=Zjuict9srV+eTvSkvKJH8/R4FLVsNkar8gvnhKqFQC12PjFfwkmMJKt93vMTNjZikE 1RnKiGHMkhutRH2PxfadYtqrLVOpTnTO6VS5td3ZUWjJ8NLFgaB6eYq7KG3qaL7gfIjZ f8aLcLKXvB3GJOyV1CeOzyTS5OwYiW3JyBa21UPb+eg10oQtq5weYTdjquF140Aj2UvV qa0pQiC5gz+RPQA3WQlcSB2f11nYrqdwtLFqhsSF/e3OwJZrhRlYu9uJpiLdecBJhZu+ 8Nfl3WtatQno4qYXzdGNrAKpkWrxN9+ZtSwap3a3+diG569OI4gRYhss0QvZSDPrd+YX E+9w== X-Gm-Message-State: ALQs6tAsmao3ZC2zi+/ijvHEUOoudXCsMJrqn+k+3QMXmjpY6nskJBko cJ1yVVMCKNnEQdKQCAyKhFDBJQ== X-Google-Smtp-Source: AIpwx48TuaJGKpgvRFaWijoSxnC/4TjUp6ib0U7r7aVm2k2R0VL8uiB1iiRusSlaXgIJGo5NlWycNQ== X-Received: by 10.28.236.152 with SMTP id h24mr1554595wmi.92.1523556756121; Thu, 12 Apr 2018 11:12:36 -0700 (PDT) Received: from alan-laptop.carrier.duckdns.org (host-89-243-165-90.as13285.net. [89.243.165.90]) by smtp.gmail.com with ESMTPSA id c21sm3519546wre.43.2018.04.12.11.12.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Apr 2018 11:12:35 -0700 (PDT) From: Alan Jenkins To: Jens Axboe , linux-block@vger.kernel.org Cc: Bart Van Assche , linux-kernel@vger.kernel.org, Alan Jenkins , stable@vger.kernel.org Subject: [PATCH v2] block: do not use interruptible wait anywhere Date: Thu, 12 Apr 2018 19:11:58 +0100 Message-Id: <20180412181158.8884-1-alan.christopher.jenkins@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <13e67e1243ebd96f3f56a150d47444ada47ebde0.camel@wdc.com> References: <13e67e1243ebd96f3f56a150d47444ada47ebde0.camel@wdc.com> 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 When blk_queue_enter() waits for a queue to unfreeze, or unset the PREEMPT_ONLY flag, do not allow it to be interrupted by a signal. The PREEMPT_ONLY flag was introduced later in commit 3a0a529971ec ("block, scsi: Make SCSI quiesce and resume work reliably"). Note the SCSI device is resumed asynchronously, i.e. after un-freezing userspace tasks. So that commit exposed the bug as a regression in v4.15. A mysterious SIGBUS (or -EIO) sometimes happened during the time the device was being resumed. Most frequently, there was no kernel log message, and we saw Xorg or Xwayland killed by SIGBUS.[1] [1] E.g. https://bugzilla.redhat.com/show_bug.cgi?id=1553979 Without this fix, I get an IO error in this test: # dd if=/dev/sda of=/dev/null iflag=direct & \ while killall -SIGUSR1 dd; do sleep 0.1; done & \ echo mem > /sys/power/state ; \ sleep 5; killall dd # stop after 5 seconds The interruptible wait was added to blk_queue_enter in commit 3ef28e83ab15 ("block: generic request_queue reference counting"). Before then, the interruptible wait was only in blk-mq, but I don't think it could ever have been correct. Reviewed-by: Bart Van Assche Cc: stable@vger.kernel.org Signed-off-by: Alan Jenkins --- v2: fix indentation block/blk-core.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index abcb8684ba67..1a762f3980f2 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -915,7 +915,6 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) while (true) { bool success = false; - int ret; rcu_read_lock(); if (percpu_ref_tryget_live(&q->q_usage_counter)) { @@ -947,14 +946,12 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) */ smp_rmb(); - ret = wait_event_interruptible(q->mq_freeze_wq, - (atomic_read(&q->mq_freeze_depth) == 0 && - (preempt || !blk_queue_preempt_only(q))) || - blk_queue_dying(q)); + wait_event(q->mq_freeze_wq, + (atomic_read(&q->mq_freeze_depth) == 0 && + (preempt || !blk_queue_preempt_only(q))) || + blk_queue_dying(q)); if (blk_queue_dying(q)) return -ENODEV; - if (ret) - return ret; } }