From nobody Sun Apr 19 10:41:26 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 E2A2CC433EF for ; Sat, 2 Jul 2022 18:29:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232506AbiGBS3R (ORCPT ); Sat, 2 Jul 2022 14:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232322AbiGBS3P (ORCPT ); Sat, 2 Jul 2022 14:29:15 -0400 Received: from smtp.smtpout.orange.fr (smtp10.smtpout.orange.fr [80.12.242.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14C5EDED0 for ; Sat, 2 Jul 2022 11:29:15 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id 7hrio8ivT2ovC7hrioywFJ; Sat, 02 Jul 2022 20:29:13 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 02 Jul 2022 20:29:13 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: agk@redhat.com, snitzer@kernel.org, dm-devel@redhat.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, almaz.alexandrovich@paragon-software.com, yury.norov@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk Cc: linux-s390@vger.kernel.org, ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 1/4] s390/cio: Rename bitmap_size() as idset_bitmap_size() Date: Sat, 2 Jul 2022 20:29:09 +0200 Message-Id: <3f2ad7fb91948525f6c52e0d36ec223cd3049c88.1656785856.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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" In order to introduce a bitmap_size() function in the bitmap API, we have to rename functions with a similar name. Add a "idset_" prefix and change bitmap_size() into idset_bitmap_size(). No functional change. Signed-off-by: Christophe JAILLET --- drivers/s390/cio/idset.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/s390/cio/idset.c b/drivers/s390/cio/idset.c index 45f9c0736be4..e1e77fe080bf 100644 --- a/drivers/s390/cio/idset.c +++ b/drivers/s390/cio/idset.c @@ -16,7 +16,7 @@ struct idset { unsigned long bitmap[]; }; =20 -static inline unsigned long bitmap_size(int num_ssid, int num_id) +static inline unsigned long idset_bitmap_size(int num_ssid, int num_id) { return BITS_TO_LONGS(num_ssid * num_id) * sizeof(unsigned long); } @@ -25,11 +25,11 @@ static struct idset *idset_new(int num_ssid, int num_id) { struct idset *set; =20 - set =3D vmalloc(sizeof(struct idset) + bitmap_size(num_ssid, num_id)); + set =3D vmalloc(sizeof(struct idset) + idset_bitmap_size(num_ssid, num_id= )); if (set) { set->num_ssid =3D num_ssid; set->num_id =3D num_id; - memset(set->bitmap, 0, bitmap_size(num_ssid, num_id)); + memset(set->bitmap, 0, idset_bitmap_size(num_ssid, num_id)); } return set; } @@ -41,7 +41,7 @@ void idset_free(struct idset *set) =20 void idset_fill(struct idset *set) { - memset(set->bitmap, 0xff, bitmap_size(set->num_ssid, set->num_id)); + memset(set->bitmap, 0xff, idset_bitmap_size(set->num_ssid, set->num_id)); } =20 static inline void idset_add(struct idset *set, int ssid, int id) --=20 2.34.1 From nobody Sun Apr 19 10:41:26 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 5004EC433EF for ; Sat, 2 Jul 2022 18:29:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232525AbiGBS3i (ORCPT ); Sat, 2 Jul 2022 14:29:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232322AbiGBS3d (ORCPT ); Sat, 2 Jul 2022 14:29:33 -0400 Received: from smtp.smtpout.orange.fr (smtp06.smtpout.orange.fr [80.12.242.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60E6ADED2 for ; Sat, 2 Jul 2022 11:29:32 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id 7hs0oEF0sWo1m7hs1ouSBQ; Sat, 02 Jul 2022 20:29:30 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 02 Jul 2022 20:29:30 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: agk@redhat.com, snitzer@kernel.org, dm-devel@redhat.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, almaz.alexandrovich@paragon-software.com, yury.norov@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk Cc: linux-s390@vger.kernel.org, ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 2/4] fs/ntfs3: Rename bitmap_size() as ntfs3_bitmap_size() Date: Sat, 2 Jul 2022 20:29:27 +0200 Message-Id: <56a3cb896ec446ca24e4756042d9f0829afc671a.1656785856.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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" In order to introduce a bitmap_size() function in the bitmap API, we have to rename functions with a similar name. Add a "ntfs3_" prefix and change bitmap_size() into ntfs3_bitmap_size(). No functional change. Signed-off-by: Christophe JAILLET Acked-by: Yury Norov --- fs/ntfs3/bitmap.c | 4 ++-- fs/ntfs3/fsntfs.c | 2 +- fs/ntfs3/index.c | 6 +++--- fs/ntfs3/ntfs_fs.h | 2 +- fs/ntfs3/super.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c index e3b5680fd516..f98327453d83 100644 --- a/fs/ntfs3/bitmap.c +++ b/fs/ntfs3/bitmap.c @@ -661,7 +661,7 @@ int wnd_init(struct wnd_bitmap *wnd, struct super_block= *sb, size_t nbits) wnd->total_zeroes =3D nbits; wnd->extent_max =3D MINUS_ONE_T; wnd->zone_bit =3D wnd->zone_end =3D 0; - wnd->nwnd =3D bytes_to_block(sb, bitmap_size(nbits)); + wnd->nwnd =3D bytes_to_block(sb, ntfs3_bitmap_size(nbits)); wnd->bits_last =3D nbits & (wbits - 1); if (!wnd->bits_last) wnd->bits_last =3D wbits; @@ -1323,7 +1323,7 @@ int wnd_extend(struct wnd_bitmap *wnd, size_t new_bit= s) return -EINVAL; =20 /* Align to 8 byte boundary. */ - new_wnd =3D bytes_to_block(sb, bitmap_size(new_bits)); + new_wnd =3D bytes_to_block(sb, ntfs3_bitmap_size(new_bits)); new_last =3D new_bits & (wbits - 1); if (!new_last) new_last =3D wbits; diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 3de5700a9b83..9c74d88ce0f0 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -493,7 +493,7 @@ static int ntfs_extend_mft(struct ntfs_sb_info *sbi) ni->mi.dirty =3D true; =20 /* Step 2: Resize $MFT::BITMAP. */ - new_bitmap_bytes =3D bitmap_size(new_mft_total); + new_bitmap_bytes =3D ntfs3_bitmap_size(new_mft_total); =20 err =3D attr_set_size(ni, ATTR_BITMAP, NULL, 0, &sbi->mft.bitmap.run, new_bitmap_bytes, &new_bitmap_bytes, true, NULL); diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c index 84ccc1409874..5c5ea05a5ef1 100644 --- a/fs/ntfs3/index.c +++ b/fs/ntfs3/index.c @@ -1353,7 +1353,7 @@ static int indx_create_allocate(struct ntfs_index *in= dx, struct ntfs_inode *ni, =20 alloc->nres.valid_size =3D alloc->nres.data_size =3D cpu_to_le64(data_siz= e); =20 - err =3D ni_insert_resident(ni, bitmap_size(1), ATTR_BITMAP, in->name, + err =3D ni_insert_resident(ni, ntfs3_bitmap_size(1), ATTR_BITMAP, in->nam= e, in->name_len, &bitmap, NULL, NULL); if (err) goto out2; @@ -1415,7 +1415,7 @@ static int indx_add_allocate(struct ntfs_index *indx,= struct ntfs_inode *ni, if (bmp) { /* Increase bitmap. */ err =3D attr_set_size(ni, ATTR_BITMAP, in->name, in->name_len, - &indx->bitmap_run, bitmap_size(bit + 1), + &indx->bitmap_run, ntfs3_bitmap_size(bit + 1), NULL, true, NULL); if (err) goto out1; @@ -1973,7 +1973,7 @@ static int indx_shrink(struct ntfs_index *indx, struc= t ntfs_inode *ni, if (err) return err; =20 - bpb =3D bitmap_size(bit); + bpb =3D ntfs3_bitmap_size(bit); if (bpb * 8 =3D=3D nbits) return 0; =20 diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 55d686e3c4ec..85210e610a3a 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -945,7 +945,7 @@ static inline bool run_is_empty(struct runs_tree *run) } =20 /* NTFS uses quad aligned bitmaps. */ -static inline size_t bitmap_size(size_t bits) +static inline size_t ntfs3_bitmap_size(size_t bits) { return ALIGN((bits + 7) >> 3, 8); } diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index b41d7c824a50..7d48f886ac82 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1101,7 +1101,7 @@ static int ntfs_fill_super(struct super_block *sb, st= ruct fs_context *fc) =20 /* Check bitmap boundary. */ tt =3D sbi->used.bitmap.nbits; - if (inode->i_size < bitmap_size(tt)) { + if (inode->i_size < ntfs3_bitmap_size(tt)) { err =3D -EINVAL; goto put_inode_out; } --=20 2.34.1 From nobody Sun Apr 19 10:41:26 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 7792DC433EF for ; Sat, 2 Jul 2022 18:29:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232537AbiGBS3o (ORCPT ); Sat, 2 Jul 2022 14:29:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232322AbiGBS3m (ORCPT ); Sat, 2 Jul 2022 14:29:42 -0400 Received: from smtp.smtpout.orange.fr (smtp08.smtpout.orange.fr [80.12.242.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69455DF1A for ; Sat, 2 Jul 2022 11:29:41 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id 7hsAo7wOSYwJ77hsAo61iK; Sat, 02 Jul 2022 20:29:39 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 02 Jul 2022 20:29:39 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: agk@redhat.com, snitzer@kernel.org, dm-devel@redhat.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, almaz.alexandrovich@paragon-software.com, yury.norov@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk Cc: linux-s390@vger.kernel.org, ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 3/4] bitmap: Introduce bitmap_size() Date: Sat, 2 Jul 2022 20:29:36 +0200 Message-Id: <98f5d3d855a9c687ccc035edf62016b02a6876b7.1656785856.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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" The new bitmap_size() function returns the size, in bytes, of a bitmap. Remove the already existing bitmap_size() functions and macro in some files. These files already use the bitmap API and will use the new function in bitmap.h automatically. Signed-off-by: Christophe JAILLET Reviewed-by: Andy Shevchenko --- drivers/md/dm-clone-metadata.c | 5 ----- include/linux/bitmap.h | 6 ++++++ lib/math/prime_numbers.c | 2 -- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/md/dm-clone-metadata.c b/drivers/md/dm-clone-metadata.c index c43d55672bce..47c1fa7aad8b 100644 --- a/drivers/md/dm-clone-metadata.c +++ b/drivers/md/dm-clone-metadata.c @@ -465,11 +465,6 @@ static void __destroy_persistent_data_structures(struc= t dm_clone_metadata *cmd) =20 /*------------------------------------------------------------------------= ---*/ =20 -static size_t bitmap_size(unsigned long nr_bits) -{ - return BITS_TO_LONGS(nr_bits) * sizeof(long); -} - static int __dirty_map_init(struct dirty_map *dmap, unsigned long nr_words, unsigned long nr_regions) { diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index f091a1664bf1..f66fb98a4126 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -48,6 +48,7 @@ struct device; * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal? * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap? * bitmap_subset(src1, src2, nbits) Is *src1 a subset of *src2? + * bitmap_size(nbits) Size, in bytes, of a bitmap * bitmap_empty(src, nbits) Are all bits zero in *src? * bitmap_full(src, nbits) Are all bits set in *src? * bitmap_weight(src, nbits) Hamming Weight: number set= bits @@ -124,6 +125,11 @@ unsigned long *bitmap_alloc_node(unsigned int nbits, g= fp_t flags, int node); unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int nod= e); void bitmap_free(const unsigned long *bitmap); =20 +static __always_inline size_t bitmap_size(unsigned long nbits) +{ + return BITS_TO_LONGS(nbits) * sizeof(unsigned long); +} + /* Managed variants of the above. */ unsigned long *devm_bitmap_alloc(struct device *dev, unsigned int nbits, gfp_t flags); diff --git a/lib/math/prime_numbers.c b/lib/math/prime_numbers.c index d42cebf7407f..d3b64b10da1c 100644 --- a/lib/math/prime_numbers.c +++ b/lib/math/prime_numbers.c @@ -6,8 +6,6 @@ #include #include =20 -#define bitmap_size(nbits) (BITS_TO_LONGS(nbits) * sizeof(unsigned long)) - struct primes { struct rcu_head rcu; unsigned long last, sz; --=20 2.34.1 From nobody Sun Apr 19 10:41:26 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 D04E5C433EF for ; Sat, 2 Jul 2022 18:29:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232558AbiGBS3v (ORCPT ); Sat, 2 Jul 2022 14:29:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbiGBS3t (ORCPT ); Sat, 2 Jul 2022 14:29:49 -0400 Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70C69DED2 for ; Sat, 2 Jul 2022 11:29:48 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id 7hsIoTjZy4Ltq7hsIonixx; Sat, 02 Jul 2022 20:29:46 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 02 Jul 2022 20:29:46 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: agk@redhat.com, snitzer@kernel.org, dm-devel@redhat.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, almaz.alexandrovich@paragon-software.com, yury.norov@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk Cc: linux-s390@vger.kernel.org, ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 4/4] bitmap: Use bitmap_size() Date: Sat, 2 Jul 2022 20:29:44 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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" Simplify code and take advantage of the new bitmap_size() function. Signed-off-by: Christophe JAILLET --- include/linux/bitmap.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index f66fb98a4126..668b47c1e5de 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -243,21 +243,18 @@ extern int bitmap_print_list_to_buf(char *buf, const = unsigned long *maskp, =20 static inline void bitmap_zero(unsigned long *dst, unsigned int nbits) { - unsigned int len =3D BITS_TO_LONGS(nbits) * sizeof(unsigned long); - memset(dst, 0, len); + memset(dst, 0, bitmap_size(nbits)); } =20 static inline void bitmap_fill(unsigned long *dst, unsigned int nbits) { - unsigned int len =3D BITS_TO_LONGS(nbits) * sizeof(unsigned long); - memset(dst, 0xff, len); + memset(dst, 0xff, bitmap_size(nbits)); } =20 static inline void bitmap_copy(unsigned long *dst, const unsigned long *sr= c, unsigned int nbits) { - unsigned int len =3D BITS_TO_LONGS(nbits) * sizeof(unsigned long); - memcpy(dst, src, len); + memcpy(dst, src, bitmap_size(nbits)); } =20 /* --=20 2.34.1