Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1415853imm; Thu, 5 Jul 2018 23:00:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfp5JozNjC8lNJch0PZ8h18whsmtA24KyRZwqO8Chn4TlLJikFa6CKgyx321Svxb/3U75rb X-Received: by 2002:a62:968f:: with SMTP id s15-v6mr9263374pfk.191.1530856821207; Thu, 05 Jul 2018 23:00:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530856821; cv=none; d=google.com; s=arc-20160816; b=sc1iZzbgBIkAwujJ6rDgVY4+emSUJ8W/Frl6ZZk8URK95rOXQGraVrKb4gMg3xTqL0 zq648fqW/oXubKs94MFmTrs8ZAcl22JCVb6XPuIANbQvcBUWIJDy6y+k0idG32533iy7 7/GBJ5107I1jghOTTmLBNrFMvEAV9r4096zwE/BxBKj5BFbei5Nd6TiyGejwM6zsDad9 qTl2BlZsWBa7wNmJB2q0nNBXjMobAABsukEehled9gZs6n8Bq6iKyblYQJpCqXn4w/Ww 7bs7vrMD2pTiUKxUo7dUPBulnaGZOs4dSAxZ+Or/8rUUOf9E9v8JrEzFColQ43+Bcy7K Jtfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=PT4GrprwXGMJMB7uXcJCLiriwqSCMsMOerwi33/rhF8=; b=CQItZhUnWyl3eUnzSIp5SF5EfVCOKzFQ5DvWXpQc0tjDRiGG7jVOhlAwdaKWA4wxsZ ksG/we+Emolnuu1ia/vP8nqVwHif/dEnK1to1cR+ALhVG4FkrUi7ARFQTu+TZVA4nFTw qtslxKeJ9IJ9tCwQqjOWQH8CJIPPjIozgecOfCQIlNuRMnAq+Z9uq04bSB1ylSA7v8l5 KGP+bMQz5Tb5p2p7pIfz0vzQ92GcTvBLmsYHZ3HfgBx1HCFCcUBUrz9KIcDwtwqnI/S6 hBNlS9/GHDpHUC9TZIxZsCv3V4vqcy7EVu4WikrQqr04K8L/mKhyqhROdpEHT2BRGzre 5ykw== 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 f17-v6si6878023pgv.383.2018.07.05.23.00.07; Thu, 05 Jul 2018 23:00:21 -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 S934235AbeGFFvT (ORCPT + 99 others); Fri, 6 Jul 2018 01:51:19 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33260 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934160AbeGFFvS (ORCPT ); Fri, 6 Jul 2018 01:51:18 -0400 Received: from localhost (D57D388D.static.ziggozakelijk.nl [213.125.56.141]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BE2D486A; Fri, 6 Jul 2018 05:51:17 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, NeilBrown , Shaohua Li , Jack Wang Subject: [PATCH 4.14 35/61] md: dont call bitmap_create() while array is quiesced. Date: Fri, 6 Jul 2018 07:46:59 +0200 Message-Id: <20180706054713.679536995@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180706054712.332416244@linuxfoundation.org> References: <20180706054712.332416244@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: NeilBrown commit 52a0d49de3d592a3118e13f35985e3d99eaf43df upstream. bitmap_create() allocates memory with GFP_KERNEL and so can wait for IO. If called while the array is quiesced, it could wait indefinitely for write out to the array - deadlock. So call bitmap_create() before quiescing the array. Signed-off-by: NeilBrown Signed-off-by: Shaohua Li Signed-off-by: Jack Wang Signed-off-by: Greg Kroah-Hartman --- drivers/md/md.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -6645,22 +6645,26 @@ static int set_bitmap_file(struct mddev return -ENOENT; /* cannot remove what isn't there */ err = 0; if (mddev->pers) { - mddev->pers->quiesce(mddev, 1); if (fd >= 0) { struct bitmap *bitmap; bitmap = bitmap_create(mddev, -1); + mddev->pers->quiesce(mddev, 1); if (!IS_ERR(bitmap)) { mddev->bitmap = bitmap; err = bitmap_load(mddev); } else err = PTR_ERR(bitmap); - } - if (fd < 0 || err) { + if (err) { + bitmap_destroy(mddev); + fd = -1; + } + mddev->pers->quiesce(mddev, 0); + } else if (fd < 0) { + mddev->pers->quiesce(mddev, 1); bitmap_destroy(mddev); - fd = -1; /* make sure to put the file */ + mddev->pers->quiesce(mddev, 0); } - mddev->pers->quiesce(mddev, 0); } if (fd < 0) { struct file *f = mddev->bitmap_info.file; @@ -6944,8 +6948,8 @@ static int update_array_info(struct mdde mddev->bitmap_info.default_offset; mddev->bitmap_info.space = mddev->bitmap_info.default_space; - mddev->pers->quiesce(mddev, 1); bitmap = bitmap_create(mddev, -1); + mddev->pers->quiesce(mddev, 1); if (!IS_ERR(bitmap)) { mddev->bitmap = bitmap; rv = bitmap_load(mddev);