From patchwork Tue Sep 15 17:23:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 11777577 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 533D1618 for ; Tue, 15 Sep 2020 18:52:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D7EF21D1B for ; Tue, 15 Sep 2020 18:52:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p6GMQaA8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727683AbgIOSv7 (ORCPT ); Tue, 15 Sep 2020 14:51:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727834AbgIORZO (ORCPT ); Tue, 15 Sep 2020 13:25:14 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D46EC061788 for ; Tue, 15 Sep 2020 10:24:00 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id d20so5061727qka.5 for ; Tue, 15 Sep 2020 10:24:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Kx5MVQ6xbvL7SHYiOkls0hYmmDYxo6c0riPFgM+lrnY=; b=p6GMQaA8hmceMnb+5kwya+bzED6xKn8OGXbLxSIfMluBX06j6KehloBobDOAp+/9Ya Lx1mw9+l42SVWztlPyHzrXxAgiRD5QwHvmxrsV0bgZj0i9b9M4BCz5Xt2+DhfJiqDAdt egxzt5B84faJQQ9g5UciXDyFBGScsuekTfkSAOQT+H+HDpRqHCXt7g54ztyW0CoxYwP0 QFow0Sr4rSLFm44giwNBSEkEOVEHjw9hAXXkw25j3VxS/YMYtInfSQ06PDXeJdX9s2Tf Az/LnwWbRxaglE1+gocO2IjuLBpyx8zD6h4rS9u36q7Nj16Q6Carae9Wbg1CuTLItPLL 446w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Kx5MVQ6xbvL7SHYiOkls0hYmmDYxo6c0riPFgM+lrnY=; b=FdWSQCfLKYxQnpKiZMC5vewe7akWp+H6F/cyMeL4qojOg7IU10XUlGzqQMIHFrBi87 dEtsL2EG3H7JLKPYdvXOIMNS2xh2x1/Nw0HXNEFgS2NdzXfi2rMI+U/SFjLIMt4vbS5p lg5RYx8zmYnQd//dIOQxJ1KHdgO1y8jeYa/Fkgr1fg5aM7EF+RdC4SSOgli6vHCLCMPM xSQVrhlFIAZ8abudBDPNOZ80yzr4LgfNykE2gS5DNskRU7WPcdzDGXObkj1V5Dv6kO+9 M6XCdBRvtx1Tl5Evrud7gpbKQ62OPmgNpiYZSoaFCUV6MMP3JNfBYNZn2jBx+IJhQKsI 3LTg== X-Gm-Message-State: AOAM530HiSSJ/St4mP7hMFSjKdrcA/vyvcANpSG2BJWBd3JX2j96fz+X SOOpVrL0niFF89cLKQ4xIyI= X-Google-Smtp-Source: ABdhPJzKaUpJoi0KDI4Qkd/096qDGqB8xHMUklj32DH+7MIkhoQilpcZPSpn/qOUshcAtyBcNDuOPw== X-Received: by 2002:a05:620a:13f6:: with SMTP id h22mr19848092qkl.9.1600190640218; Tue, 15 Sep 2020 10:24:00 -0700 (PDT) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id g18sm16371219qtu.69.2020.09.15.10.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 10:23:59 -0700 (PDT) From: Mike Snitzer To: Jens Axboe Cc: Ming Lei , Vijayendra Suman , dm-devel@redhat.com, linux-block@vger.kernel.org Subject: [PATCH v2 1/4] block: use lcm_not_zero() when stacking chunk_sectors Date: Tue, 15 Sep 2020 13:23:54 -0400 Message-Id: <20200915172357.83215-2-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200915172357.83215-1-snitzer@redhat.com> References: <20200915172357.83215-1-snitzer@redhat.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Like 'io_opt', blk_stack_limits() should stack 'chunk_sectors' using lcm_not_zero() rather than min_not_zero() -- otherwise the final 'chunk_sectors' could result in sub-optimal alignment of IO to component devices in the IO stack. Also, if 'chunk_sectors' isn't a multiple of 'physical_block_size' then it is a bug in the driver and the device should be flagged as 'misaligned'. Signed-off-by: Mike Snitzer Reviewed-by: Ming Lei --- block/blk-settings.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index 76a7e03bcd6c..b2e1a929a6db 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -534,6 +534,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->io_min = max(t->io_min, b->io_min); t->io_opt = lcm_not_zero(t->io_opt, b->io_opt); + t->chunk_sectors = lcm_not_zero(t->chunk_sectors, b->chunk_sectors); /* Physical block size a multiple of the logical block size? */ if (t->physical_block_size & (t->logical_block_size - 1)) { @@ -556,6 +557,13 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, ret = -1; } + /* chunk_sectors a multiple of the physical block size? */ + if ((t->chunk_sectors << 9) & (t->physical_block_size - 1)) { + t->chunk_sectors = 0; + t->misaligned = 1; + ret = -1; + } + t->raid_partial_stripes_expensive = max(t->raid_partial_stripes_expensive, b->raid_partial_stripes_expensive); @@ -594,10 +602,6 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->discard_granularity; } - if (b->chunk_sectors) - t->chunk_sectors = min_not_zero(t->chunk_sectors, - b->chunk_sectors); - t->zoned = max(t->zoned, b->zoned); return ret; } From patchwork Tue Sep 15 17:23:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 11777579 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB225618 for ; Tue, 15 Sep 2020 18:52:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B41E221E2 for ; Tue, 15 Sep 2020 18:52:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WG3o+qI8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727591AbgIOSwS (ORCPT ); Tue, 15 Sep 2020 14:52:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727835AbgIORZO (ORCPT ); Tue, 15 Sep 2020 13:25:14 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7084CC06178B for ; Tue, 15 Sep 2020 10:24:02 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id r8so3744726qtp.13 for ; Tue, 15 Sep 2020 10:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZeX8V7Gb+jyRqRtlgs7NF1BRzrZm/6v3hKPdNUeahLM=; b=WG3o+qI8Cw3yk4Of2qOx3HWYkFQikC1L+LbatZwA9NEF0liTx0f12GzVIgjOIcRggk ybOBBsIu1DrocYotXMqBUrDPIsWOzbCeuDMvFKbDkN3syykn9SYx7aNT0zXq/s96qVvZ Os7uMIdaf4smKjNX0INspAjc+okNc/a8KjoJILplukcsNeYDIKK4tmJv8fw/RnZjj4Ht kGWpSjuWZaRtiHZK+xRo54Ks8Q/twluWB0SurSwyy27FURW1onuXd2c/NiYDKT6eVGw7 a0GgHNeJAUiJKyZXLWiT6eorcokY4xHG6R84r1ELeiAbwtbNRrI822nynCEFhsVQjI7R /0Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ZeX8V7Gb+jyRqRtlgs7NF1BRzrZm/6v3hKPdNUeahLM=; b=Ty7vwxtwvhMy8hIwPtNyBvU6n9HZj5ArB1eKiGl9H+aZG6yGQmcf57OYs8imiYzcNj 2s4WUaRXN7fg7B/fC/e9D15fh1bxY1VS1EGDQvd4U2/XOCVEYHP37IoRjAa30fcX7eN7 UiaMZQx7TIK58b6ytaJ0l/UaKocp7adZwe7OVZ9yx29XchnL+PgtS9TcGAaPg274a+Ia j56Wdw4NMyzk7yQRVRajt6JgUS+fldSvftOeDWPW6Uykcna2oqZYMXF6KTpBoyRngREV bBD7l2t53jxe0doL2M0nBvMVUdaxq9LaXrgicsm6KXnLXqoj2zYR1nxGoM4I0+e0WFzD 5/tg== X-Gm-Message-State: AOAM530UctYVE5wWXHKGzT3pLfe5ZZ3VkQZvelTJ8rM12zLWWWwOBqEV SfdczsMVDD4JFk3qxan9MaU= X-Google-Smtp-Source: ABdhPJxrNthacXH+fyYZJ5rnayPOSYCU9MD/k5XzuTD8OsypSir6w5+0Cqu7Ydt5jXOHJtWRCM82aA== X-Received: by 2002:ac8:3704:: with SMTP id o4mr17825222qtb.330.1600190641615; Tue, 15 Sep 2020 10:24:01 -0700 (PDT) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id z2sm17349244qkg.40.2020.09.15.10.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 10:24:01 -0700 (PDT) From: Mike Snitzer To: Jens Axboe Cc: Ming Lei , Vijayendra Suman , dm-devel@redhat.com, linux-block@vger.kernel.org Subject: [PATCH v2 2/4] block: allow 'chunk_sectors' to be non-power-of-2 Date: Tue, 15 Sep 2020 13:23:55 -0400 Message-Id: <20200915172357.83215-3-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200915172357.83215-1-snitzer@redhat.com> References: <20200915172357.83215-1-snitzer@redhat.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org It is possible for a block device to use a non power-of-2 for chunk size which results in a full-stripe size that is also a non power-of-2. Update blk_queue_chunk_sectors() and blk_max_size_offset() to accommodate drivers that need a non power-of-2 chunk_sectors. Signed-off-by: Mike Snitzer Reviewed-by: Ming Lei --- block/blk-settings.c | 10 ++++------ include/linux/blkdev.h | 12 +++++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index b2e1a929a6db..5ea3de48afba 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -172,15 +172,13 @@ EXPORT_SYMBOL(blk_queue_max_hw_sectors); * * Description: * If a driver doesn't want IOs to cross a given chunk size, it can set - * this limit and prevent merging across chunks. Note that the chunk size - * must currently be a power-of-2 in sectors. Also note that the block - * layer must accept a page worth of data at any offset. So if the - * crossing of chunks is a hard limitation in the driver, it must still be - * prepared to split single page bios. + * this limit and prevent merging across chunks. Note that the block layer + * must accept a page worth of data at any offset. So if the crossing of + * chunks is a hard limitation in the driver, it must still be prepared + * to split single page bios. **/ void blk_queue_chunk_sectors(struct request_queue *q, unsigned int chunk_sectors) { - BUG_ON(!is_power_of_2(chunk_sectors)); q->limits.chunk_sectors = chunk_sectors; } EXPORT_SYMBOL(blk_queue_chunk_sectors); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index bb5636cc17b9..bbfbda33e993 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1059,11 +1059,17 @@ static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, static inline unsigned int blk_max_size_offset(struct request_queue *q, sector_t offset) { - if (!q->limits.chunk_sectors) + unsigned int chunk_sectors = q->limits.chunk_sectors; + + if (!chunk_sectors) return q->limits.max_sectors; - return min(q->limits.max_sectors, (unsigned int)(q->limits.chunk_sectors - - (offset & (q->limits.chunk_sectors - 1)))); + if (is_power_of_2(chunk_sectors)) + chunk_sectors -= offset & (chunk_sectors - 1); + else + chunk_sectors -= sector_div(offset, chunk_sectors); + + return min(q->limits.max_sectors, chunk_sectors); } static inline unsigned int blk_rq_get_max_sectors(struct request *rq, From patchwork Tue Sep 15 17:23:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 11777575 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A0B7618 for ; Tue, 15 Sep 2020 18:51:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F37320B1F for ; Tue, 15 Sep 2020 18:51:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PUPVJVT4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbgIOSto (ORCPT ); Tue, 15 Sep 2020 14:49:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727842AbgIORZO (ORCPT ); Tue, 15 Sep 2020 13:25:14 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45222C06178C for ; Tue, 15 Sep 2020 10:24:04 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id n133so5022043qkn.11 for ; Tue, 15 Sep 2020 10:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=dqwxkVTd5/jHYQSEXF8VtnLj+gaZ69idekW/tSuak/4=; b=PUPVJVT4ak4nDk1bqvG2puF1SWMub6klBCbLVVpdT/rbAQ6XsUxeAhh6AV5x0SJgFo TP31TJU5kQ3K2gOTD21dpmVJu0pgFe5iqeH/LmwPk60E76w5wdyK1kPO0KYWlDuamQ0v /JYPkgK+CxLFn0XCqAsO2eGnJ37kZ7mVR0qahy9D3BrxQaglggqGPtu5dk1tNUfB7cHE r3Ye6P5T7BENd3kZv3y7kgDcaLZcNmo9wdpw3y7dTPTXSM2sR3IqnfIftw4DReSSjanh 9H97Tk1HJz2Mu/VCqn5NcUrurTYNPW2zjyuZNMJT19KgFtIDOieLv98pDj0s0l8RiBMJ Cg9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=dqwxkVTd5/jHYQSEXF8VtnLj+gaZ69idekW/tSuak/4=; b=B7SJi+fCLR/du/rSdBz6HKQtlmQA3J3VDvc9X1rVUy0NH2ECtGxsuBHPoYCxRJByWt 5hV089cDqjlsAu4/Isjgs8vLmkS4kQTXqbROcxNrEXAeXjYciJVhWMRXbtBwuj/3M8bq XjMuFYxvPsbBRAl/QMZlH6rvJ8nA89irjwcwZRAeqEOB9nlXODkcjwwBD+wCyu+0AnYb LmUo27TJz44pzYrvVw6kkZDwuAo5pQVcIN30SRVNHjcbCBr9gUUoFixxRbAnYOKdDMe3 CY6X5r/diRmmuVqE1A+AuHpPRq8pFFcLxSQRM7P3qKGWHit0JZf5x8YgfyIFjzMpqfb6 pyxg== X-Gm-Message-State: AOAM532d8NJbnvEYAnwzRqxkJuDfdfOfqnK8GOV+DmUveGtWyYIO3vrp v+uKUIoj8jSHGNhRwfiCPgY= X-Google-Smtp-Source: ABdhPJxiR4Ue6DgxQjUkZ0Cqffe6uNtsKfw0d7romunYOFP/MQ/XemUbad9vhcfTDChNaw/ffFS7Ng== X-Received: by 2002:a05:620a:34c:: with SMTP id t12mr18171543qkm.431.1600190642969; Tue, 15 Sep 2020 10:24:02 -0700 (PDT) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id d9sm18088289qtg.51.2020.09.15.10.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 10:24:02 -0700 (PDT) From: Mike Snitzer To: Jens Axboe Cc: Ming Lei , Vijayendra Suman , dm-devel@redhat.com, linux-block@vger.kernel.org Subject: [PATCH v2 3/4] dm table: stack 'chunk_sectors' limit to account for target-specific splitting Date: Tue, 15 Sep 2020 13:23:56 -0400 Message-Id: <20200915172357.83215-4-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200915172357.83215-1-snitzer@redhat.com> References: <20200915172357.83215-1-snitzer@redhat.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org If target set ti->max_io_len it must be used when stacking DM device's queue_limits to establish a 'chunk_sectors' that is compatible with the IO stack. By using lcm_not_zero() care is taken to avoid blindly overriding the chunk_sectors limit stacked up by blk_stack_limits(). Signed-off-by: Mike Snitzer --- drivers/md/dm-table.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 5edc3079e7c1..248c5a1074a7 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1502,6 +1503,10 @@ int dm_calculate_queue_limits(struct dm_table *table, zone_sectors = ti_limits.chunk_sectors; } + /* Stack chunk_sectors if target-specific splitting is required */ + if (ti->max_io_len) + ti_limits.chunk_sectors = lcm_not_zero(ti->max_io_len, + ti_limits.chunk_sectors); /* Set I/O hints portion of queue limits */ if (ti->type->io_hints) ti->type->io_hints(ti, &ti_limits); From patchwork Tue Sep 15 17:23:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 11777573 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B5BC618 for ; Tue, 15 Sep 2020 18:51:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F41BB20B1F for ; Tue, 15 Sep 2020 18:51:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sYvFE6iK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727689AbgIOStr (ORCPT ); Tue, 15 Sep 2020 14:49:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727854AbgIORZO (ORCPT ); Tue, 15 Sep 2020 13:25:14 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F257C061351 for ; Tue, 15 Sep 2020 10:24:05 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id f142so4993948qke.13 for ; Tue, 15 Sep 2020 10:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=7cplhJ+CMOio2eKSlQ3A9qenyuRaLVK7gDFC2tp/7iE=; b=sYvFE6iKk88aXGk3ud0cBpRkzDDwcUC1YidZa0ZloImjRpjWWm06AtYr/2tKD+MLOg +BG/38FOoIElT4iqQxA3/QfU9VLUnz10xcCx6/FWmyGhKYSajqsJr1V7P6rYABfa65Ge wt/zaRPN7Ixi4H1W8i+g6RzJ/g5Dqq+t7lv/GHyroHNOfYqk5qZIeB0BO4BcdjcOQkYT Gxa60yq1s7UK1DqEByiG5OEuBghzCANxBLckEMbs0sPsCZnZ0voAhjZ7VkTJSsziq7S0 Fj9VfYgDUSBhGeRNYUIWIJ1soTjhNcqjQHCmxWbZQ9S727jw9xcutrsDCQ9Gw6AIFO4/ XHbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=7cplhJ+CMOio2eKSlQ3A9qenyuRaLVK7gDFC2tp/7iE=; b=DxkpP+QOtbzXpQSM16yaHdCcRekqCaNZFh6CM8X8uuuFRFHPNFwPunX6XEIsM2SDiV xtxgWGrPrJV7NpAILSHwOjOVpbH+Tghh3PGg5RyHPyEeRv9sVVn6Hg9wXzWYxyWrxfKP m0p5K74WcXd5rID4SpGCvBFXai8ekfwA6NMDdH3sSiOJvVSm9yq7hldz7erf4/ngy/LW hgUVMbMbASKUgFweHwwKIUogpLQXvuMJaWGd1A98r6UFiL/3Batxos96CfokTkyDmP7x sK73OaucyvTpA7wcOkuRPcqeYBzUiNN0Efabu0mpPhuVo6NQh71ND17xExBMkRm3+98w Z08g== X-Gm-Message-State: AOAM5305U++Pz6vMua0LyPWlEweAGLDPuznfiEC5g2bk4DBqY9les+Nk Mm3Ikc6sZEHHDDRpjUwcXwo= X-Google-Smtp-Source: ABdhPJy0pc0fArTWbJ7e53JSflriiZAjMa8KQwK/gnTN75ljPFBUSMbdOP8I6gyV5ZGZiH5h588Kgg== X-Received: by 2002:a37:2f42:: with SMTP id v63mr17521380qkh.261.1600190644615; Tue, 15 Sep 2020 10:24:04 -0700 (PDT) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id t1sm17823515qtj.12.2020.09.15.10.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 10:24:03 -0700 (PDT) From: Mike Snitzer To: Jens Axboe Cc: Ming Lei , Vijayendra Suman , dm-devel@redhat.com, linux-block@vger.kernel.org Subject: [PATCH v2 4/4] dm: unconditionally call blk_queue_split() in dm_process_bio() Date: Tue, 15 Sep 2020 13:23:57 -0400 Message-Id: <20200915172357.83215-5-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200915172357.83215-1-snitzer@redhat.com> References: <20200915172357.83215-1-snitzer@redhat.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org blk_queue_split() has become compulsory from .submit_bio -- regardless of whether it is recursing. Update DM core to always call blk_queue_split(). dm_queue_split() is removed because __split_and_process_bio() handles splitting as needed. Signed-off-by: Mike Snitzer --- drivers/md/dm.c | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index fb0255d25e4b..0bae9f26dc8e 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1530,22 +1530,6 @@ static int __send_write_zeroes(struct clone_info *ci, struct dm_target *ti) return __send_changing_extent_only(ci, ti, get_num_write_zeroes_bios(ti)); } -static bool is_abnormal_io(struct bio *bio) -{ - bool r = false; - - switch (bio_op(bio)) { - case REQ_OP_DISCARD: - case REQ_OP_SECURE_ERASE: - case REQ_OP_WRITE_SAME: - case REQ_OP_WRITE_ZEROES: - r = true; - break; - } - - return r; -} - static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti, int *result) { @@ -1723,23 +1707,6 @@ static blk_qc_t __process_bio(struct mapped_device *md, struct dm_table *map, return ret; } -static void dm_queue_split(struct mapped_device *md, struct dm_target *ti, struct bio **bio) -{ - unsigned len, sector_count; - - sector_count = bio_sectors(*bio); - len = min_t(sector_t, max_io_len((*bio)->bi_iter.bi_sector, ti), sector_count); - - if (sector_count > len) { - struct bio *split = bio_split(*bio, len, GFP_NOIO, &md->queue->bio_split); - - bio_chain(split, *bio); - trace_block_split(md->queue, split, (*bio)->bi_iter.bi_sector); - submit_bio_noacct(*bio); - *bio = split; - } -} - static blk_qc_t dm_process_bio(struct mapped_device *md, struct dm_table *map, struct bio *bio) { @@ -1759,17 +1726,7 @@ static blk_qc_t dm_process_bio(struct mapped_device *md, } } - /* - * If in ->queue_bio we need to use blk_queue_split(), otherwise - * queue_limits for abnormal requests (e.g. discard, writesame, etc) - * won't be imposed. - */ - if (current->bio_list) { - if (is_abnormal_io(bio)) - blk_queue_split(&bio); - else - dm_queue_split(md, ti, &bio); - } + blk_queue_split(&bio); if (dm_get_md_type(md) == DM_TYPE_NVME_BIO_BASED) return __process_bio(md, map, bio, ti);