Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3927213imm; Mon, 8 Oct 2018 11:49:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV61kFGN48kbMu3AteCsP7LB6Y+QEFzO+6gYpuqFyK1VxOx3li8ktVgEGEWDvdLE6cComaHY0 X-Received: by 2002:a63:80c6:: with SMTP id j189-v6mr22573201pgd.40.1539024563208; Mon, 08 Oct 2018 11:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024563; cv=none; d=google.com; s=arc-20160816; b=qi6K47p394CwZDmSOac4wwyN4hLIM+ol1SY6A8X5VqMLFmoAqWN/0i8rofvJ13gaag o+skwLABOKROmzrgEYN2wy2O/q2ScG4Kpj1vih+EQOn0spCS47fLTZAOJDBUJPQ8kVIT MMVPGyxyFdw0LJ77w+xe9geblshIJmZWuXI+R+g6BL5bk3ps/oVMG7DOLJdfW4jhuu9G Fipq8yW7BA302s98nLaObFkkj8uU/vttFWzlMjgzD/xwgz7CpZ3XAiGWZXTTTFpXD7nn +pbv9xaodCMWzWR4FFRHqshIYvTrJpIA+tAU//K1Xp99Ge0db3/N2bLn/7cgAKRRO00Z 4aKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BU0CFBOmgkTyucETx7IH+8KpcUy6MdoIrFRokQRyLEI=; b=bwvU4sxl20w2EsqYKlruPxrQWU7WcgwBjICOTmlGhKxhXHUrMl8FmV7UJFHTwnCmSz 9LLGINbm0+m1BH7FstVhdNTTD0eYMdg7lfAvEa8FbUPgyz7OUWw8AsWY8BOKJyQAOe1r 7W9r4d+ZS7iuucPTWUmBM8Y9zk3S14pq9d5UA+dIRThIHeEjtncLYydoMVsX4ADdqZQn cJ3bliZwGG2tbEvlAERHgIJOq9EdpJOoYN7uO11oeJ/AIt+uP5StYg3Bm8tVNW9VzLLj DU5tdJPmF8Sd1Qv6zs01bjSyuNtYnDk9YxjhV3zQnxwwrifs+L/uRSzKF7Gc4XhDa4rM TFiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K2YlGjIy; 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 x7-v6si18930271plr.146.2018.10.08.11.49.07; Mon, 08 Oct 2018 11:49:23 -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; dkim=pass header.i=@kernel.org header.s=default header.b=K2YlGjIy; 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 S1731502AbeJICAs (ORCPT + 99 others); Mon, 8 Oct 2018 22:00:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:49594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730798AbeJICAr (ORCPT ); Mon, 8 Oct 2018 22:00:47 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0119B204FD; Mon, 8 Oct 2018 18:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024460; bh=xyBeoWttcRQQV6Etp3eCO+mYN6HTkDgL/hoc0KZCffg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K2YlGjIyDaZJzh0wAnWkv9pa/Hj8R/OPM0ttgmFN77Qllogg8ZaggVDr8g4XA6m/g 3o3D9cE+UrGdcZZ2mQLoyZvCDbYMseABefsg1cZNN1YXOWHA2BdsHy9q+6eagOSS3w cVGR6dofjHywbnhrHIEbcWpg6YgYSiDEdlnWs7NY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiao Ni , Neil Brown , Shaohua Li , Sasha Levin Subject: [PATCH 4.18 047/168] RAID10 BUG_ON in raise_barrier when force is true and conf->barrier is 0 Date: Mon, 8 Oct 2018 20:30:27 +0200 Message-Id: <20181008175621.848482192@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiao Ni [ Upstream commit 1d0ffd264204eba1861865560f1f7f7a92919384 ] In raid10 reshape_request it gets max_sectors in read_balance. If the underlayer disks have bad blocks, the max_sectors is less than last. It will call goto read_more many times. It calls raise_barrier(conf, sectors_done != 0) every time. In this condition sectors_done is not 0. So the value passed to the argument force of raise_barrier is true. In raise_barrier it checks conf->barrier when force is true. If force is true and conf->barrier is 0, it panic. In this case reshape_request submits bio to under layer disks. And in the callback function of the bio it calls lower_barrier. If the bio finishes before calling raise_barrier again, it can trigger the BUG_ON. Add one pair of raise_barrier/lower_barrier to fix this bug. Signed-off-by: Xiao Ni Suggested-by: Neil Brown Signed-off-by: Shaohua Li Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/md/raid10.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -4531,11 +4531,12 @@ static sector_t reshape_request(struct m allow_barrier(conf); } + raise_barrier(conf, 0); read_more: /* Now schedule reads for blocks from sector_nr to last */ r10_bio = raid10_alloc_init_r10buf(conf); r10_bio->state = 0; - raise_barrier(conf, sectors_done != 0); + raise_barrier(conf, 1); atomic_set(&r10_bio->remaining, 0); r10_bio->mddev = mddev; r10_bio->sector = sector_nr; @@ -4631,6 +4632,8 @@ read_more: if (sector_nr <= last) goto read_more; + lower_barrier(conf); + /* Now that we have done the whole section we can * update reshape_progress */