Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp260931ybv; Wed, 12 Feb 2020 23:41:46 -0800 (PST) X-Google-Smtp-Source: APXvYqxjuybDtpiLwixQT4OzG/DrlOSM9ShRk5v9bsCLrXblY0eLiFFVqx5Z+rfRbr66cH4dPx1V X-Received: by 2002:a9d:3e43:: with SMTP id h3mr11798554otg.84.1581579706302; Wed, 12 Feb 2020 23:41:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581579706; cv=none; d=google.com; s=arc-20160816; b=JxIyBEvd1NAAzdi9mskvDQEP7mMFqRl66IR7K+1vIuI6sM9EMkMtEDXrtumhFk401M +vQMY7QL/Z6SwuCV7d6JQSgf6oBLWvolGtefDeaCVNKyaY/zOiwQsoxijlF1OobSSE7j LIvil6gtwFPXTapxuUhXrrY93LMeBngG5DuexWUMhOvrv4+Pgrmh3eVyUfibPTp49ru1 Zu6o6uyrsgdYqv5YvDSLXWOamsXwzKoGsHKxxroy2I9UqRRlEfLsAWTWjrt25Ra0VGeU yr/8W7E6NsLQh/ekm5q0GDhVpWpfSqIKxuTCplOUiPS3uFX++AgQk+bBMmde2sZx6+k8 blXw== 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:cc:to:from :subject; bh=F3cy+oQUmHsH2jObd62KPJQ4n6V/LfTbJXFYi06mwrY=; b=EunkBZFsQtbSI691AKgNwQI2PtZoE7gp07Dpo5YiV9bp5yEdQlfUGgzXvqAZ8pVdcc IyarNpZpx72A7Jwcq3Wj9mWy4c3uvLQR7sYnXpLwouL9CoCdxoIQzsUXp0cu83fjXUqo dW0BajU3u/XxEIJ1veKaw74zCgO4TuaaO5yS9SyOg9ZSET8QTMd4kyuHFZU9C1V73lHl h22kDwbCIenu3YohL+2XrBLvVr3fejsc1KEYE49scEw+u0AecKLMoYJkkuXjSSwdh2HF iEi3ZYe5/hApxV52XDZdpjW3Ib2O0KkLdA8t7qqaOi2Kr+NDiR6WEjrEsnvDTVObWSqS zv9w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6si752498ote.72.2020.02.12.23.41.33; Wed, 12 Feb 2020 23:41:46 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729923AbgBMHkI (ORCPT + 99 others); Thu, 13 Feb 2020 02:40:08 -0500 Received: from relay.sw.ru ([185.231.240.75]:41046 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729383AbgBMHj4 (ORCPT ); Thu, 13 Feb 2020 02:39:56 -0500 Received: from [192.168.15.156] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j295j-0001TZ-7I; Thu, 13 Feb 2020 10:39:19 +0300 Subject: [PATCH v7 3/6] block: Introduce blk_queue_get_max_write_zeroes_sectors() From: Kirill Tkhai To: martin.petersen@oracle.com, bob.liu@oracle.com, axboe@kernel.dk, darrick.wong@oracle.com Cc: agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, song@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, Chaitanya.Kulkarni@wdc.com, ming.lei@redhat.com, osandov@fb.com, jthumshirn@suse.de, minwoo.im.dev@gmail.com, damien.lemoal@wdc.com, andrea.parri@amarulasolutions.com, hare@suse.com, tj@kernel.org, ajay.joshi@wdc.com, sagi@grimberg.me, dsterba@suse.com, chaitanya.kulkarni@wdc.com, bvanassche@acm.org, dhowells@redhat.com, asml.silence@gmail.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ktkhai@virtuozzo.com Date: Thu, 13 Feb 2020 10:39:18 +0300 Message-ID: <158157955888.111879.4517095626498945551.stgit@localhost.localdomain> In-Reply-To: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> References: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This introduces a new primitive, which returns max sectors for REQ_OP_WRITE_ZEROES operation. @op_flags is unused now, and it will be enabled in next patch. Signed-off-by: Kirill Tkhai Reviewed-by: Bob Liu --- block/blk-core.c | 2 +- block/blk-merge.c | 9 ++++++--- include/linux/blkdev.h | 8 +++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 28a6d46eb982..c7387b0d69e5 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -949,7 +949,7 @@ generic_make_request_checks(struct bio *bio) goto not_supported; break; case REQ_OP_WRITE_ZEROES: - if (!q->limits.max_write_zeroes_sectors) + if (!blk_queue_get_max_write_zeroes_sectors(q, bio->bi_opf)) goto not_supported; break; default: diff --git a/block/blk-merge.c b/block/blk-merge.c index 1534ed736363..467b292bc6e8 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -105,15 +105,18 @@ static struct bio *blk_bio_discard_split(struct request_queue *q, static struct bio *blk_bio_write_zeroes_split(struct request_queue *q, struct bio *bio, struct bio_set *bs, unsigned *nsegs) { + unsigned int max_sectors; + + max_sectors = blk_queue_get_max_write_zeroes_sectors(q, bio->bi_opf); *nsegs = 0; - if (!q->limits.max_write_zeroes_sectors) + if (!max_sectors) return NULL; - if (bio_sectors(bio) <= q->limits.max_write_zeroes_sectors) + if (bio_sectors(bio) <= max_sectors) return NULL; - return bio_split(bio, q->limits.max_write_zeroes_sectors, GFP_NOIO, bs); + return bio_split(bio, max_sectors, GFP_NOIO, bs); } static struct bio *blk_bio_write_same_split(struct request_queue *q, diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index f4ec7ae214ab..55a714161684 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -987,6 +987,12 @@ static inline struct bio_vec req_bvec(struct request *rq) return mp_bvec_iter_bvec(rq->bio->bi_io_vec, rq->bio->bi_iter); } +static inline unsigned int blk_queue_get_max_write_zeroes_sectors( + struct request_queue *q, unsigned int op_flags) +{ + return q->limits.max_write_zeroes_sectors; +} + static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, unsigned int op_flags) { @@ -1000,7 +1006,7 @@ static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, return q->limits.max_write_same_sectors; if (unlikely(op == REQ_OP_WRITE_ZEROES)) - return q->limits.max_write_zeroes_sectors; + return blk_queue_get_max_write_zeroes_sectors(q, op_flags); return q->limits.max_sectors; }