Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp358325pxx; Wed, 28 Oct 2020 06:39:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkTbPXAhFtgtVoVw9PqgulvoAWI9FFG0bnO2y5h20RbthGkZi/nzwVI+CfPFyiUu3q1ZEF X-Received: by 2002:a17:906:1fda:: with SMTP id e26mr7194836ejt.528.1603892347375; Wed, 28 Oct 2020 06:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603892347; cv=none; d=google.com; s=arc-20160816; b=005hh4qSIXm1GOx6h3z29o/NdWL8X2A7WuDi4oK5QCk8vSSp6mtuu2D5KGREA97ZnI KZcJrwyU14r5ew4ZQXG5gxpDYK9BXd01cV464pSSrf4LD77B8L+kPloidzDnmL9Qp1pq WChZFcLeno9zJ6TGtHpJS+IFzVsSeBQAC7Vonh9+H0NL/3mi+dCZoEYLd/mkENMY2+ga jbb/DV0w4ybhBnA+HM6lnKrFBb27uqpYAoUG38xcsFpz/kcnkykiROnGi6E7qmTUBlFG uG4eivCl6Nb7M/DV59sndSzCGx1OOsGfKiJ6HBZ0QtUxVXW6b5PufmE4p2CasXwlR5cZ EWJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kyM19NI5oMO7AsckneFmsPo0m8yuOQhBLohM2HQLFrc=; b=L/2fYO/pcCkffZpa6ew+Mwqw7oD+PNJCyeN/a+ojSyGxdyg9S32cw8rKa4sDO2nIPt ibFGEW1eswU9uKaDMgjEknfpT2pyNTZB+mnxurZplPIymghgwVZNofzVlB5rlvr2R5Dw Hd4U5ubhYoeNeAcLuunLepvVMEZL1aXwdOgqd4elwMlc+3DFtajo/wrQoSc7fdqheNj+ TWFrIonNSgs6CYtYAX/USBXPKMYl5ArcReotPFBYuGKSQy1Pykuua4ADdZel6tm4mfCR Eo5NRRzxbe5zTH8f8PKE1Dpfpr/YgrClbGv+n98BqAfUp0XGlUdq/ycH/FMqQKTRkLnS 3MzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pDytOAtR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si2736409edx.542.2020.10.28.06.38.45; Wed, 28 Oct 2020 06:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pDytOAtR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1802707AbgJ0PvC (ORCPT + 99 others); Tue, 27 Oct 2020 11:51:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:52504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1799967AbgJ0PeY (ORCPT ); Tue, 27 Oct 2020 11:34:24 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 ADFC122202; Tue, 27 Oct 2020 15:34:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812863; bh=76kdpGoWy43gNIh6VEjUCOyF0dmmkr5cmldvPVhRa8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pDytOAtRFxHkGiO8j09jVGD8mjoK/WDRurF7adWA6ZeWYXYmUnh+3jH0m/1G6rO+f 8gy7lSgkqnH+Zmj5+lLyci3SOmrTc4CJ4NxrBE3QOmso9yMqf7KqU7YfVm+kow/dH3 cyflSz1o6gb9+MS6jMu0QUamccvH4GltU/N0pGDc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeffle Xu , Mikulas Patocka , Mike Snitzer , Sasha Levin Subject: [PATCH 5.9 357/757] dm: fix missing imposition of queue_limits from dm_wq_work() thread Date: Tue, 27 Oct 2020 14:50:07 +0100 Message-Id: <20201027135507.312793690@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Snitzer [ Upstream commit 0c2915b8c6db108b1dfb240391cc5a175f97f15b ] If a DM device was suspended when bios were issued to it, those bios would be deferred using queue_io(). Once the DM device was resumed dm_process_bio() could be called by dm_wq_work() for original bio that still needs splitting. dm_process_bio()'s check for current->bio_list (meaning call chain is within ->submit_bio) as a prerequisite for calling blk_queue_split() for "abnormal IO" would result in dm_process_bio() never imposing corresponding queue_limits (e.g. discard_granularity, discard_max_bytes, etc). Fix this by always having dm_wq_work() resubmit deferred bios using submit_bio_noacct(). Side-effect is blk_queue_split() is always called for "abnormal IO" from ->submit_bio, be it from application thread or dm_wq_work() workqueue, so proper bio splitting and depth-first bio submission is performed. For sake of clarity, remove current->bio_list check before call to blk_queue_split(). Also, remove dm_wq_work()'s use of dm_{get,put}_live_table() -- no longer needed since IO will be reissued in terms of ->submit_bio. And rename bio variable from 'c' to 'bio'. Fixes: cf9c37865557 ("dm: fix comment in dm_process_bio()") Reported-by: Jeffle Xu Reviewed-by: Mikulas Patocka Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin --- drivers/md/dm.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 6ed05ca65a0f8..b060a28ff1c6d 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1744,17 +1744,11 @@ static blk_qc_t dm_process_bio(struct mapped_device *md, } /* - * If in ->submit_bio we need to use blk_queue_split(), otherwise - * queue_limits for abnormal requests (e.g. discard, writesame, etc) - * won't be imposed. - * If called from dm_wq_work() for deferred bio processing, bio - * was already handled by following code with previous ->submit_bio. + * Use blk_queue_split() for abnormal IO (e.g. discard, writesame, etc) + * otherwise associated queue_limits won't be imposed. */ - if (current->bio_list) { - if (is_abnormal_io(bio)) - blk_queue_split(&bio); - /* regular IO is split by __split_and_process_bio */ - } + if (is_abnormal_io(bio)) + blk_queue_split(&bio); if (dm_get_md_type(md) == DM_TYPE_NVME_BIO_BASED) return __process_bio(md, map, bio, ti); @@ -2461,29 +2455,19 @@ static int dm_wait_for_completion(struct mapped_device *md, long task_state) */ static void dm_wq_work(struct work_struct *work) { - struct mapped_device *md = container_of(work, struct mapped_device, - work); - struct bio *c; - int srcu_idx; - struct dm_table *map; - - map = dm_get_live_table(md, &srcu_idx); + struct mapped_device *md = container_of(work, struct mapped_device, work); + struct bio *bio; while (!test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags)) { spin_lock_irq(&md->deferred_lock); - c = bio_list_pop(&md->deferred); + bio = bio_list_pop(&md->deferred); spin_unlock_irq(&md->deferred_lock); - if (!c) + if (!bio) break; - if (dm_request_based(md)) - (void) submit_bio_noacct(c); - else - (void) dm_process_bio(md, map, c); + submit_bio_noacct(bio); } - - dm_put_live_table(md, srcu_idx); } static void dm_queue_flush(struct mapped_device *md) -- 2.25.1