From patchwork Wed Dec 27 09:23:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13505247 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC56128E20 for ; Wed, 27 Dec 2023 09:23:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Tc+T5RA6" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=7ZQ9sgh4lzc2YX0ii/mderRNgkEwLQ3NyMb5S4zuxgo=; b=Tc+T5RA6BDaqTNnhhYTDsxlKsG QIPlLn6En9iLL4X0g8GgjlODpQDN3vlPsNjbxiXAz2J0L3+YzhA50B8Dlgb2z34rsj0Q6mx3TRQCB Jwg/2hwZapx0fDWyW79247PjhjU4gcakX2RiCKVsVIbaF5llHeDUUN17cWr9KTtMH8UvxocRwevdW oEFyyW4iznoVqHGgrp18bu/crRMH6RD81ByBWZjvvgD/T/3b08j5JhRT872JfbwAZU23tUU/3XDqW ZOeiUtrAAxwToghAn1m9N6bgeHTlCQpCVw/bxaYiMJZFzMY/O70gjMi/WXi31ZXJmIm1EarwZzEIa 4BTI37rA==; Received: from 128.red-83-57-75.dynamicip.rima-tde.net ([83.57.75.128] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rIQ8F-00EI3a-2d; Wed, 27 Dec 2023 09:23:20 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Justin Sanders , Damien Le Moal , linux-block@vger.kernel.org Subject: [PATCH 1/4] null_blk: don't cap max_hw_sectors to BLK_DEF_MAX_SECTORS Date: Wed, 27 Dec 2023 09:23:02 +0000 Message-Id: <20231227092305.279567-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231227092305.279567-1-hch@lst.de> References: <20231227092305.279567-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html null_blk has some rather odd capping of the max_hw_sectors value to BLK_DEF_MAX_SECTORS, which doesn't make sense - max_hw_sector is the hardware limit, and BLK_DEF_MAX_SECTORS despite the confusing name is the default cap for the max_sectors field used for normal file system I/O. Remove all the capping, and simply leave it to the block layer or user to take up or not all of that for file system I/O. Fixes: ea17fd354ca8 ("null_blk: Allow controlling max_hw_sectors limit") Signed-off-by: Christoph Hellwig --- drivers/block/null_blk/main.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 3021d58ca51c1f..13ed446b5e198e 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -2186,10 +2186,8 @@ static int null_add_dev(struct nullb_device *dev) blk_queue_logical_block_size(nullb->q, dev->blocksize); blk_queue_physical_block_size(nullb->q, dev->blocksize); - if (!dev->max_sectors) - dev->max_sectors = queue_max_hw_sectors(nullb->q); - dev->max_sectors = min(dev->max_sectors, BLK_DEF_MAX_SECTORS); - blk_queue_max_hw_sectors(nullb->q, dev->max_sectors); + if (dev->max_sectors) + blk_queue_max_hw_sectors(nullb->q, dev->max_sectors); if (dev->virt_boundary) blk_queue_virt_boundary(nullb->q, PAGE_SIZE - 1); @@ -2289,12 +2287,6 @@ static int __init null_init(void) g_bs = PAGE_SIZE; } - if (g_max_sectors > BLK_DEF_MAX_SECTORS) { - pr_warn("invalid max sectors\n"); - pr_warn("defaults max sectors to %u\n", BLK_DEF_MAX_SECTORS); - g_max_sectors = BLK_DEF_MAX_SECTORS; - } - if (g_home_node != NUMA_NO_NODE && g_home_node >= nr_online_nodes) { pr_err("invalid home_node value\n"); g_home_node = NUMA_NO_NODE; From patchwork Wed Dec 27 09:23:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13505248 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 751C92C852 for ; Wed, 27 Dec 2023 09:23:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="djJrQQ/j" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=eMCnfUfwfjnx1cIujAEol9qEJieEAMerBUeT3X9hUNI=; b=djJrQQ/jiHkrHCd4PXqsrnHRHk fCDuoTS69KaDey1flB2+piHPQfGAA9k8dmE+9bG4emiCa1mSDP/+m2yRzgxqynIicz4ZTsuVSSoNn fZmeVAcyqPCaJ81PdJ8fLB7F+f0R4M6Z6W/AJNSQx/Y3LgpjUoHK9ecjPn0ZcjOpnUQWj+BW6J+oj jaEcN0MA3EuzG2kSvLXB2uUGywv7VrxnHi+HwlJJoao7FYMPqXYW1eys++RlWQlWF30fO7TTEVlTa oRnqgMB8GZiks/uF/wLatGpDXWvd5boZJMh4babRJMewacFNy+cxmlo8+e3eqNjknjiR2JTXH/8SP PACB/RRQ==; Received: from 128.red-83-57-75.dynamicip.rima-tde.net ([83.57.75.128] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rIQ8K-00EI49-2l; Wed, 27 Dec 2023 09:23:25 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Justin Sanders , Damien Le Moal , linux-block@vger.kernel.org Subject: [PATCH 2/4] aoe: don't abuse BLK_DEF_MAX_SECTORS Date: Wed, 27 Dec 2023 09:23:03 +0000 Message-Id: <20231227092305.279567-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231227092305.279567-1-hch@lst.de> References: <20231227092305.279567-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html BLK_DEF_MAX_SECTORS despite the confusing name is the default cap for the max_sectors limits. Don't use it to initialize max_hw_setors, which is a hardware / driver capacility. Signed-off-by: Christoph Hellwig --- drivers/block/aoe/aoeblk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index cf6883756155a3..d2dbf8aaccb5b1 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -383,7 +383,8 @@ aoeblk_gdalloc(void *vp) WARN_ON(d->flags & DEVFL_TKILL); WARN_ON(d->gd); WARN_ON(d->flags & DEVFL_UP); - blk_queue_max_hw_sectors(gd->queue, BLK_DEF_MAX_SECTORS); + /* random number picked from the history block max_sectors cap */ + blk_queue_max_hw_sectors(gd->queue, 2560u); blk_queue_io_opt(gd->queue, SZ_2M); d->bufpool = mp; d->blkq = gd->queue; From patchwork Wed Dec 27 09:23:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13505249 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E2932C852 for ; Wed, 27 Dec 2023 09:23:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="CDgzcfKo" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=1emDS7V1lza113/w0hXx2Nd3dNmQOBpt+EiNB49VMmU=; b=CDgzcfKoDH55W218iLD9Q2TG4X OKPlHwxq7/R9Nln5+jClSGZ0wzDlTueH9Toh/bTOeYMT4KOEBiXzQYdRVUnV3jfhFFeTnCu8l+RFE 8kjAGfnLkrK3BKHNyj4IsfREZerF5wiPS+JvYDDSg647h8pUpUtQ2MM1ykf9sbqDSXD5Id9ILeQbU cGasLupjKB2iq+cBZNHT6CZGoy2g9d+q3Mq6nAMTJr9wJ2krzcUgjNdKNOgakcLQzq8qFxeUC4h72 44wo2ysmubll/zOCKTsiiOrG6bbpWNNoEbEpazhCWmHsRlh7lVUHAdDaMLaKgm8T427b+SKqKRzx/ mTIfsfaA==; Received: from 128.red-83-57-75.dynamicip.rima-tde.net ([83.57.75.128] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rIQ8Q-00EI4k-2U; Wed, 27 Dec 2023 09:23:31 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Justin Sanders , Damien Le Moal , linux-block@vger.kernel.org Subject: [PATCH 3/4] loop: don't abuse BLK_DEF_MAX_SECTORS Date: Wed, 27 Dec 2023 09:23:04 +0000 Message-Id: <20231227092305.279567-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231227092305.279567-1-hch@lst.de> References: <20231227092305.279567-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html BLK_DEF_MAX_SECTORS despite the confusing name is the default cap for the max_sectors limits. Don't use it to initialize max_hw_setors, which is a hardware / driver capacility. Signed-off-by: Christoph Hellwig --- drivers/block/loop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 9f2d412fc560e1..6106303fcc4677 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2038,7 +2038,8 @@ static int loop_add(int i) } lo->lo_queue = lo->lo_disk->queue; - blk_queue_max_hw_sectors(lo->lo_queue, BLK_DEF_MAX_SECTORS); + /* random number picked from the history block max_sectors cap */ + blk_queue_max_hw_sectors(lo->lo_queue, 2560u); /* * By default, we do buffer IO, so it doesn't make sense to enable From patchwork Wed Dec 27 09:23:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13505250 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D9362C865 for ; Wed, 27 Dec 2023 09:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="tDv6bLut" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=J5fLPXWrQzodzztAaisOKjkOGrm1QVNAOSMH6Hp8Tps=; b=tDv6bLutgoBpyAaq/BrAUiKrao nZP1XM8ZPPiHs7y5gnHp4sgM6rDhFOwW7mMTBkZ3kWqmCv2DrFnjInwJr7OiNvjFktRoDXPCx7YBh 2bKYqyO79Rw1q6DpcMnS9Qd5zvO8W2vdTVnYGmy+KLK+tPmfA7ljKysjUzWmoQLYEnE0Or/0j7YX8 hFVrtN+NClcg9IY6yG9lOoyLl2IMxGDU6b/e/x1fy9Oks796J2OAiuclR2GgT9jX5neOU6Ld6SCMO D6g/NeySsq/Pr7pUw7bvzIuPisp1wfKjAB+mXZ6ObsSih1qfq0trKCF7/2BJ3WXLKpPmUJbfzc+xX qV+MVamg==; Received: from 128.red-83-57-75.dynamicip.rima-tde.net ([83.57.75.128] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rIQ8V-00EI6a-2r; Wed, 27 Dec 2023 09:23:36 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Justin Sanders , Damien Le Moal , linux-block@vger.kernel.org Subject: [PATCH 4/4] block: rename and document BLK_DEF_MAX_SECTORS Date: Wed, 27 Dec 2023 09:23:05 +0000 Message-Id: <20231227092305.279567-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231227092305.279567-1-hch@lst.de> References: <20231227092305.279567-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Give BLK_DEF_MAX_SECTORS a _CAP postfix and document what it is used for. Signed-off-by: Christoph Hellwig --- block/blk-settings.c | 2 +- block/blk-sysfs.c | 2 +- drivers/scsi/sd.c | 2 +- include/linux/blkdev.h | 9 ++++++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index 33b3f767b81e24..ba6e0e97118c08 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -139,7 +139,7 @@ void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_secto if (limits->max_user_sectors) max_sectors = min(max_sectors, limits->max_user_sectors); else - max_sectors = min(max_sectors, BLK_DEF_MAX_SECTORS); + max_sectors = min(max_sectors, BLK_DEF_MAX_SECTORS_CAP); max_sectors = round_down(max_sectors, limits->logical_block_size >> SECTOR_SHIFT); diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index d5e669a401b0cc..40bab5975c5612 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -241,7 +241,7 @@ queue_max_sectors_store(struct request_queue *q, const char *page, size_t count) if (max_sectors_kb == 0) { q->limits.max_user_sectors = 0; max_sectors_kb = min(max_hw_sectors_kb, - BLK_DEF_MAX_SECTORS >> 1); + BLK_DEF_MAX_SECTORS_CAP >> 1); } else { if (max_sectors_kb > max_hw_sectors_kb || max_sectors_kb < page_kb) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 8c8ac5cd1833b4..6bedd2d5298f6d 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3500,7 +3500,7 @@ static int sd_revalidate_disk(struct gendisk *disk) } else { q->limits.io_opt = 0; rw_max = min_not_zero(logical_to_sectors(sdp, dev_max), - (sector_t)BLK_DEF_MAX_SECTORS); + (sector_t)BLK_DEF_MAX_SECTORS_CAP); } /* diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index ce1ab712552e3c..9f9fbc22c4b037 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1056,7 +1056,14 @@ enum blk_default_limits { BLK_SEG_BOUNDARY_MASK = 0xFFFFFFFFUL, }; -#define BLK_DEF_MAX_SECTORS 2560u +/* + * Default upper limit for the software max_sectors limit used for + * regular file system I/O. This can be increased through sysfs. + * + * Not to be confused with the max_hw_sector limit that is entirely + * controlled by the driver, usually based on hardware limits. + */ +#define BLK_DEF_MAX_SECTORS_CAP 2560u static inline unsigned long queue_segment_boundary(const struct request_queue *q) {