From nobody Mon Feb 9 13:05:35 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 218F2C7EE29 for ; Wed, 7 Jun 2023 03:26:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240696AbjFGD0g (ORCPT ); Tue, 6 Jun 2023 23:26:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234983AbjFGD0d (ORCPT ); Tue, 6 Jun 2023 23:26:33 -0400 Received: from smtp.smtpout.orange.fr (smtp-21.smtpout.orange.fr [80.12.242.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2655B1 for ; Tue, 6 Jun 2023 20:26:31 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 6joaqCNZMZvWO6joaq99Zz; Wed, 07 Jun 2023 05:26:29 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686108389; bh=HmXZpoupl67vmqpYTDqcmmy+1ehWH3IsOXimAF/m20M=; h=From:To:Cc:Subject:Date; b=HBpjQn7rxjCIpAnMpKlEwynLZeX56QyvY5X+oKLe5NGYlIg/LEPG4uxlMq24PDGjB dpMEdsSX6IjiGGbo9ZkB8N8YOrU8nQMp4I0AUnlOksEUVf5k2tA1CNoWxAADf3dzep 4HwxDt9T6pOHdgqI/KTN4PPq3U0jszMJX4KQGf2YL4jzhOx7ke02wVAcRqYm0dGlqm qzqgnIeLK9repDagoC9d050kpt/malsw66JInq6Imk+txk9NV+kKp90m3U+DANTpSW vizR8fspgbNR1wVLl8eE0yg3Ah1dVMp9+NecEq8ULc/ciXHgFfs2u1PFqLATMPUad6 LMJN5PrmJ4ntw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 07 Jun 2023 05:26:29 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] dm/zone: Use the bitmap API to allocate bitmaps Date: Wed, 7 Jun 2023 05:26:27 +0200 Message-Id: <9014ccd13d83e9f78bfa86811a8012784333af56.1686108356.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. It is less verbose and it improves the semantic. Signed-off-by: Christophe JAILLET --- drivers/md/dm-zone.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c index 4b82b7798ce4..16776ad3794b 100644 --- a/drivers/md/dm-zone.c +++ b/drivers/md/dm-zone.c @@ -140,9 +140,9 @@ bool dm_is_zone_write(struct mapped_device *md, struct = bio *bio) void dm_cleanup_zoned_dev(struct mapped_device *md) { if (md->disk) { - kfree(md->disk->conv_zones_bitmap); + bitmap_free(md->disk->conv_zones_bitmap); md->disk->conv_zones_bitmap =3D NULL; - kfree(md->disk->seq_zones_wlock); + bitmap_free(md->disk->seq_zones_wlock); md->disk->seq_zones_wlock =3D NULL; } =20 @@ -182,9 +182,8 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone,= unsigned int idx, switch (zone->type) { case BLK_ZONE_TYPE_CONVENTIONAL: if (!disk->conv_zones_bitmap) { - disk->conv_zones_bitmap =3D - kcalloc(BITS_TO_LONGS(disk->nr_zones), - sizeof(unsigned long), GFP_NOIO); + disk->conv_zones_bitmap =3D bitmap_zalloc(disk->nr_zones, + GFP_NOIO); if (!disk->conv_zones_bitmap) return -ENOMEM; } @@ -193,9 +192,8 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone,= unsigned int idx, case BLK_ZONE_TYPE_SEQWRITE_REQ: case BLK_ZONE_TYPE_SEQWRITE_PREF: if (!disk->seq_zones_wlock) { - disk->seq_zones_wlock =3D - kcalloc(BITS_TO_LONGS(disk->nr_zones), - sizeof(unsigned long), GFP_NOIO); + disk->seq_zones_wlock =3D bitmap_zalloc(disk->nr_zones, + GFP_NOIO); if (!disk->seq_zones_wlock) return -ENOMEM; } --=20 2.34.1