Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4560168pja; Thu, 21 Nov 2019 21:52:43 -0800 (PST) X-Google-Smtp-Source: APXvYqyzSHIYja5vl2lz/M5TeOBLDWvHUB+ERlTDwCBHmi8e+zSj7BgKdE20UekCwfukolesgW92 X-Received: by 2002:a17:906:f24d:: with SMTP id gy13mr19641253ejb.159.1574401963275; Thu, 21 Nov 2019 21:52:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574401963; cv=none; d=google.com; s=arc-20160816; b=DoeJeiiCJpuHbwgJShlwN2KDPIJSAZqR2Ch5G8dFtcmMUX3rXbv15Q8dX2+QDX0peI ozWMtXlYW57qeCuf11n/VbzExG7AG3fm+m06ognJDh7Q/agoG4LXptVwd1+twxrbWgk9 Wynaq9cgmIPBqGLW0u3yd6dD9iM/zSQCqb2b9xixfz9KkLGzehFARTc86lJKAec0DDpp ZRN3GVAgvdJsizolPUwjZXGaB07996Dhx7sRYZMybTmX1D+suQkXOaAQCQfuJPutB1oZ 302zsL+1UPm4wKX6b13JmeZl9vjv9LXNjipwpRgMruWD+X9Ex5YFP38WlWVO0bJbz9io etyg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6eWcfK/UaxHGrDW9VUp69BMoANJ07RlTu/+9xOxr9ME=; b=d35G9eEGUGNerG8Yf6h9H9rGHgE3qZBAa9eFCmC2bAz5q8joHfy/GS9nWwWY1NFUO1 iy7McVGTt91mCfSEvesW1hn0CHLelzG3MIwJDdG6cw946VhM39jIMdZG/KlR5k+zr1hg 6vErclk/m/K+9krvvB/65t8Bl9cX3UPzbv2PBswRMM7OoAZ0A0+OOL/TP1wvPtsQufJw nGOnqbKlSzxoRTX2IDLqUA7hRH1eeXFTOtho1nnVh94ODqVqTrJfyf2Cr+hfKJUHqPWx AcYjS4/iGfelpubE+zm1dx2nMMsZjYkqxzV9O/he6rHF40xBblP1bLMqqDNmlQnYRPHk 0ACQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="w2u/orVw"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w19si4584090edd.51.2019.11.21.21.52.19; Thu, 21 Nov 2019 21:52:43 -0800 (PST) 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="w2u/orVw"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727333AbfKVFue (ORCPT + 99 others); Fri, 22 Nov 2019 00:50:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:55034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727740AbfKVFua (ORCPT ); Fri, 22 Nov 2019 00:50:30 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D39282070A; Fri, 22 Nov 2019 05:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401829; bh=Ig6GLgtVxG8RAfqsFCQe+ELgsgqLjsT/38hfFIajrIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w2u/orVw4eWwRUsL15jfmo11VQwPJtk181UfXq939KtYBpC28Y8ru84TUIBIwb720 N2MUSOcnQRz831BItJIrg67Ccjtjel9/nq9TTNIoOEofWjfeQ1i5bvOLqPMJSpVNUJ VW6ZwKbA8twmq8L2uw1hIgEwjXLj/N+eejxHX0YQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nikolay Borisov , Josef Bacik , Anand Jain , David Sterba , Sasha Levin , linux-btrfs@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 071/219] btrfs: Check for missing device before bio submission in btrfs_map_bio Date: Fri, 22 Nov 2019 00:46:43 -0500 Message-Id: <20191122054911.1750-64-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikolay Borisov [ Upstream commit fc8a168aa9ab1680c2bd52bf9db7c994e0f2524f ] Before btrfs_map_bio submits all stripe bios it does a number of checks to ensure the device for every stripe is present. However, it doesn't do a DEV_STATE_MISSING check, instead this is relegated to the lower level btrfs_schedule_bio (in the async submission case, sync submission doesn't check DEV_STATE_MISSING at all). Additionally btrfs_schedule_bios does the duplicate device->bdev check which has already been performed in btrfs_map_bio. This patch moves the DEV_STATE_MISSING check in btrfs_map_bio and removes the duplicate device->bdev check. Doing so ensures that no bio cloning/submission happens for both async/sync requests in the face of missing device. This makes the async io submission path slightly shorter in terms of instruction count. No functional changes. Reviewed-by: Josef Bacik Reviewed-by: Anand Jain Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/volumes.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index a8297e7489d98..f84c18e86c816 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -6106,12 +6106,6 @@ static noinline void btrfs_schedule_bio(struct btrfs_device *device, int should_queue = 1; struct btrfs_pending_bios *pending_bios; - if (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state) || - !device->bdev) { - bio_io_error(bio); - return; - } - /* don't bother with additional async steps for reads, right now */ if (bio_op(bio) == REQ_OP_READ) { btrfsic_submit_bio(bio); @@ -6240,7 +6234,8 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio, for (dev_nr = 0; dev_nr < total_devs; dev_nr++) { dev = bbio->stripes[dev_nr].dev; - if (!dev || !dev->bdev || + if (!dev || !dev->bdev || test_bit(BTRFS_DEV_STATE_MISSING, + &dev->dev_state) || (bio_op(first_bio) == REQ_OP_WRITE && !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))) { bbio_error(bbio, first_bio, logical); -- 2.20.1