From patchwork Fri Jun 21 03:15:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13706777 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9A48286AEE for ; Fri, 21 Jun 2024 03:15:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718939708; cv=none; b=V1E5vAl40n/GQE4nCORDVB34zB18i3ZS+fTg/cqPuPLEtU6NWRAG/qWL8uux9teaDr9tHVTt2+Q74yCdKjySImrFZ+ab0JNVCnqtky1FLcI446XE6j92OPgQGBM9VAZXwzAQvjkOW/hcY7ZgwrOm/kSF8wDkJFYa+8YQY0KZP2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718939708; c=relaxed/simple; bh=gWCcBHRP9xuXXFoCVET9UdGuxhCqH/vZNBSd9ErS+1Q=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IeaOHAIH7dJHzIoD5d3q1kq5ECnPHbApQyujsX4Ppd6zUCApqv5Me3k27OBQbcYkKGjyXv6NvBOuVcLko9PFkItynW1p6rKvJMsULwhE4XLNctkLaKkuvA9NPbcIKwO5Wadui0dmgtLgaO9+2m2kHsXxBi7gZaGmczK/QiLY0cY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I5B+RM5C; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I5B+RM5C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9084C32786; Fri, 21 Jun 2024 03:15:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718939708; bh=gWCcBHRP9xuXXFoCVET9UdGuxhCqH/vZNBSd9ErS+1Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=I5B+RM5CtH3VRrs6qzgp+TjPKg/F3cy/uCqwzf6eh6bPwzMDxHz1+s8ZejXlj1cIX k5IlKzpCF5D9GYNaZeIwdWr52xD6/EWaBbCv54C9eSw8PiAlqDBwA9B4LWt16TH+0V 7dIlpWYVAK210To9h7X0G6hn1tr6g66m7AiFcocleWljdik2eD81eVb9u60ctjwOOV xKpilcCendo9MW5z4c8ZoZehoTbARktBJgHetkd55S0R0DDYMqiYvBiJn84WtgcTpc /OaM/co7C8wCwRgRv09cjugsu/odf9pxkqaKFV+5boofVUHyjLaVNbt+f4EvyF++m8 Eev8XkrkAKROA== From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Subject: [PATCH 1/3] null_blk: Do not set disk->nr_zones Date: Fri, 21 Jun 2024 12:15:04 +0900 Message-ID: <20240621031506.759397-2-dlemoal@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240621031506.759397-1-dlemoal@kernel.org> References: <20240621031506.759397-1-dlemoal@kernel.org> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In null_register_zoned_dev(), there is no need to set disk->nr_zones as the now uncoditional call to blk_revalidate_disk_zones() will do that. So remove the assignment using bdev_nr_zones(). Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- drivers/block/null_blk/zoned.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c index b42c00f13132..9f7151ad93cf 100644 --- a/drivers/block/null_blk/zoned.c +++ b/drivers/block/null_blk/zoned.c @@ -171,8 +171,6 @@ int null_register_zoned_dev(struct nullb *nullb) struct request_queue *q = nullb->q; struct gendisk *disk = nullb->disk; - disk->nr_zones = bdev_nr_zones(disk->part0); - pr_info("%s: using %s zone append\n", disk->disk_name, queue_emulates_zone_append(q) ? "emulated" : "native"); From patchwork Fri Jun 21 03:15:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13706778 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 22C9C126F2A for ; Fri, 21 Jun 2024 03:15:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718939709; cv=none; b=kNZdftL/SgiowZ40A42UmBOiucrQtM4EvnIZeD9sMJA6GHoep3PpM4BP4ixUJwBozT8zNWwpgEJPXEURPJEnXg8Ak06QQUe+0IVRBd7xgckG4cP/K9NejcC1BIgWHzZly6X+7LzcifdkMUo4uimzKLCY+VSeUw+waizcHVQEtAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718939709; c=relaxed/simple; bh=hyeHUQzKxHu0Z0rCElV+wnnqHZEk3blNqU8GFCUKn4Y=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a38NVEocz/hLwrhH8YSOWn/Ph85oJ+MlEXqFmRcIPzeyyPw4/HSz9q7gHhwypsGBIpMBAU8y8b+HWRXO5fymmrXaLWjPTAKGfPMxiuOu441px3dSJfpx8LzZa5IuzjTEJd03e34xqjc+GDj2SyW09NnM5u52mDUi2CrOQ28sadk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f7QiM+YR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f7QiM+YR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C931C4AF07; Fri, 21 Jun 2024 03:15:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718939708; bh=hyeHUQzKxHu0Z0rCElV+wnnqHZEk3blNqU8GFCUKn4Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=f7QiM+YRET9QTSXVotAYVQMibgOt/fSxZmcpccT+dK/N2rY7v7lXUcb8MGaXqDftT DNCMamp2L543v3iX6eooW532U7orLRnMlw8aaMcD+YpIlEKEgGV7+PSzaQSZGaRpX7 L/fXdsSkBwP3arimVwAtOlZ/TBp8Wxy8mrdSrOLw3f5UJcj0gddWD+p3wifOCX7N55 us14dncwmDZUYwue4XTutmrxZQ51vqY+SfBMKxwbEUd8sQcLEVZbTNkOZFcs8/VGaS 3RE6/k2W3NsEJL1CC4RnrmzjZNzihXgbyaj0Hj2nF2StIm0ea0JJmO2ZUl3EW9v9ud MlAi1ZZqnxORA== From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Subject: [PATCH 2/3] block: Define bdev_nr_zones() as an inline function Date: Fri, 21 Jun 2024 12:15:05 +0900 Message-ID: <20240621031506.759397-3-dlemoal@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240621031506.759397-1-dlemoal@kernel.org> References: <20240621031506.759397-1-dlemoal@kernel.org> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is no need for bdev_nr_zones() to be an exported function calculating the number of zones of a block device. Instead, given that all callers use this helper with a fully initialized block device that has a gendisk, we can redefine this function as an inline helper in blkdev.h. Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- block/blk-zoned.c | 18 ------------------ include/linux/blkdev.h | 6 +++++- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 137842dbb59a..07831fb67201 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -115,24 +115,6 @@ const char *blk_zone_cond_str(enum blk_zone_cond zone_cond) } EXPORT_SYMBOL_GPL(blk_zone_cond_str); -/** - * bdev_nr_zones - Get number of zones - * @bdev: Target device - * - * Return the total number of zones of a zoned block device. For a block - * device without zone capabilities, the number of zones is always 0. - */ -unsigned int bdev_nr_zones(struct block_device *bdev) -{ - sector_t zone_sectors = bdev_zone_sectors(bdev); - - if (!bdev_is_zoned(bdev)) - return 0; - return (bdev_nr_sectors(bdev) + zone_sectors - 1) >> - ilog2(zone_sectors); -} -EXPORT_SYMBOL_GPL(bdev_nr_zones); - /** * blkdev_report_zones - Get zones information * @bdev: Target block device diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 2800231046a9..1078a7d51295 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -673,7 +673,6 @@ static inline bool blk_queue_is_zoned(struct request_queue *q) } #ifdef CONFIG_BLK_DEV_ZONED -unsigned int bdev_nr_zones(struct block_device *bdev); static inline unsigned int disk_nr_zones(struct gendisk *disk) { @@ -687,6 +686,11 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector) return sector >> ilog2(disk->queue->limits.chunk_sectors); } +static inline unsigned int bdev_nr_zones(struct block_device *bdev) +{ + return disk_nr_zones(bdev->bd_disk); +} + static inline unsigned int bdev_max_open_zones(struct block_device *bdev) { return bdev->bd_disk->queue->limits.max_open_zones; From patchwork Fri Jun 21 03:15:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13706779 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9944412BF25 for ; Fri, 21 Jun 2024 03:15:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718939709; cv=none; b=T6K2om152w5A5dMa6/RuUcawRw5GALM/vbm/SDTGkOnXWY/wn8r+OdxR6NCMxSHIUOvohdqkjLmiWt562xoZKLkgiB+glw8wyeq5VevixSz5WUQ+ph947smJsijk4lSWCwtyaX8gB0cmNg5+VfzjQlh7l48DkrTcYLPZPXqGuh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718939709; c=relaxed/simple; bh=QINgyjZ7UZVheyZ1tdvxh92Kxr1t65kNwRGhecM5Kfg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pzCz+oCZ3EaBEBUonNLXNC+FUdkfrq8XFv54MTCRML9xZH2MNcAfcXS1cnMlWhz4z0Q2LJq4z1tNF1eW8AtmXnHNntdunv08GkuhGcPQoaWnX9OJxL0Va1FPILtbB9K65AoNUlUgtf6WhBCQdw/J9Tn/urbr63Xw7KFhkt7ItVY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fb7Tt69V; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Fb7Tt69V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDA5FC4AF0A; Fri, 21 Jun 2024 03:15:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718939709; bh=QINgyjZ7UZVheyZ1tdvxh92Kxr1t65kNwRGhecM5Kfg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Fb7Tt69V/BTil6F/++xTRz4Nqggvg1rf+5suIigo5kVmubV3ikr2awOme0NahxGZp 9IRFtild1kWZah7X9yq9OnC1zkU0FLp/wm6Fk/ZYlC4cok93P4O1U8cO+OWXhzmKZw TpCDnB3gVsWciCyKjjcPTwO5GKC5Yr7IZWpzSwH5x44k6bHyTtGiZrHGuoF+A3+mX3 kA9VBdHXcgQlcVrJ8nzlT/UrRui82KOwk60Ynj2cXfU50xUna0gjV77l8udDBxm72T Z6+T3lTOmokN2801CiY6W0sHZlmcJt27Ab74d6QlEuE7k8eqRppJe7M3AvhuIV4/yh 2wn9fGCyrkaIg== From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Subject: [PATCH 3/3] block: Cleanup block device zone helpers Date: Fri, 21 Jun 2024 12:15:06 +0900 Message-ID: <20240621031506.759397-4-dlemoal@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240621031506.759397-1-dlemoal@kernel.org> References: <20240621031506.759397-1-dlemoal@kernel.org> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is no need to conditionally define on CONFIG_BLK_DEV_ZONED the inline helper functions bdev_nr_zones(), bdev_max_open_zones(), bdev_max_active_zones() and disk_zone_no() as these function will return the correct valu in all cases (zoned device or not, including when CONFIG_BLK_DEV_ZONED is not set). Furthermore, disk_nr_zones() definition can be simplified as disk->nr_zones is always 0 for regular block devices. Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- include/linux/blkdev.h | 44 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1078a7d51295..e89003360c17 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -673,11 +673,21 @@ static inline bool blk_queue_is_zoned(struct request_queue *q) } #ifdef CONFIG_BLK_DEV_ZONED - static inline unsigned int disk_nr_zones(struct gendisk *disk) { - return blk_queue_is_zoned(disk->queue) ? disk->nr_zones : 0; + return disk->nr_zones; +} +bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs); +#else /* CONFIG_BLK_DEV_ZONED */ +static inline unsigned int disk_nr_zones(struct gendisk *disk) +{ + return 0; +} +static inline bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs) +{ + return false; } +#endif /* CONFIG_BLK_DEV_ZONED */ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector) { @@ -701,36 +711,6 @@ static inline unsigned int bdev_max_active_zones(struct block_device *bdev) return bdev->bd_disk->queue->limits.max_active_zones; } -bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs); -#else /* CONFIG_BLK_DEV_ZONED */ -static inline unsigned int bdev_nr_zones(struct block_device *bdev) -{ - return 0; -} - -static inline unsigned int disk_nr_zones(struct gendisk *disk) -{ - return 0; -} -static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector) -{ - return 0; -} -static inline unsigned int bdev_max_open_zones(struct block_device *bdev) -{ - return 0; -} - -static inline unsigned int bdev_max_active_zones(struct block_device *bdev) -{ - return 0; -} -static inline bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs) -{ - return false; -} -#endif /* CONFIG_BLK_DEV_ZONED */ - static inline unsigned int blk_queue_depth(struct request_queue *q) { if (q->queue_depth)