Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp131824rdb; Thu, 1 Feb 2024 04:27:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IEkt+Bnh2MXFmuPUWYUs4dcuKLT3E72CqCe/DCqZjfcEdngC0HhDnvdE9csS9e89kee2S6v X-Received: by 2002:ad4:5caa:0:b0:68c:627f:ed53 with SMTP id q10-20020ad45caa000000b0068c627fed53mr2726042qvh.59.1706790454651; Thu, 01 Feb 2024 04:27:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706790454; cv=pass; d=google.com; s=arc-20160816; b=BphNQxfq8FvRgFVwV+jpE2yyuW7u3YhC2MuBMs+PFUcoRoubHLde1V9dJkBLJzU/3W uEFItexI264x1kV4vPuJnqNH7Lofq18+baIcBzj1iYouuZETAnHfJtH0xGcUGTUzAJp5 v/GJHBhGczs6Z/dvNukzDuL5hR6mRgBVNlKq37UZRD8UM8Vb5In9IO5ebdkoX/CJ1MVf 613Y4QteRSrRmbXAHjrvzU7Hd1xBQD2GdS0xZTSVwkqjISIbcnSq0ZZ15voOrd8eAL8y 4LD3cp38Wf+MnLOP1+7lnFAyZfPlk6uG7W74hO4WG5/rFIo5ghdrzgMwvaWNYBbml7eT IuWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=lcRUNPyInAKEv1mkGvahJHmp+dIIdi1X+j/XP0cxACY=; fh=mcO9dTHPX48uVTt550s4ADJCleaRZltWWAff9llJKj8=; b=k+50HR1ruW/9rRcPse2iWgV0ACby3xtDLXfqj9xoH3DBzt4DJFqC0ULlGTvKptUrhH 6RaCo0uZ4oXDprNBoKr7YqRReZ8HW+y+ZuSlKyAj5fyz4PE/RfTeGARirvhsC3MDV7Fx ROsijxpndEAWq2wqbKzlIzOiXtkYG1S+yNxjQBgKT+FtFq26I/GIDVedjau4MZOCV8BN eDf2WpaDrQEljT9J4pHXCQtZ7zMwddKqYvYQvyCHg3tbENN2ookTeoUtMRvdxN8YY1cQ BCCg+V8yu31Ptu07cGgaHNILg5saud6mwbUqHtlNF3imP3p0Q4Rb5+pECLVNz6yyVNgD SWcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kfQNtAH5; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-48121-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48121-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCVITo/lNXDkRP5r7hLB97bxT/ss3jQ1VGOLdImtIvWX8StnCTKcSDpdMXWoPoVYQMWXX2EO/pNKh851+fTL8LRKxtG+L1n8LGgt+4em+Q== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d10-20020a05621416ca00b0068c6891d423si2172943qvz.528.2024.02.01.04.27.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 04:27:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48121-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kfQNtAH5; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-48121-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48121-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5B87B1C21FAA for ; Thu, 1 Feb 2024 12:27:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE0CC5B688; Thu, 1 Feb 2024 12:24:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kfQNtAH5" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 165DF5B684; Thu, 1 Feb 2024 12:24:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706790259; cv=none; b=KsQdVS8KZcfaQ19WospgyvBRNuHeqdAPD9/TVzD4rZxNisJeE5jy94l80JAKFTq+NIcYvkj78t/8rt7B0rxCcx1Q2iVJth+gBPR+2dtJE3mEyFcTCF1ELfy318ARyhTBsHTA7l5C2SM3KICqiJx2oOrq68d4Wdy7jQq6gVCxyX4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706790259; c=relaxed/simple; bh=RG5js9dP2LCkjaHuyMBPje0qS5gbpb/z4Xt4qb6+buc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TVBQ2eEQMOIYf2se0GSZ0rqsebFWki1tjXqzPDB47kxd7pwuXnbyKJayqQH+rGEpoWmHgqCfVhGKz8eoSBsVAGZxd8Syy3pTMIhrySb5Ms4RVfpi2DQkUEEfn0U6vPL7WEYtnxbydESh0RANsu7OzvupXJ3Io1/J18T3eMahvKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kfQNtAH5; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706790259; x=1738326259; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RG5js9dP2LCkjaHuyMBPje0qS5gbpb/z4Xt4qb6+buc=; b=kfQNtAH5AMw9xGfjPfZ0KH50NgPXskegm9fzJJG23uCElH7QjA5Q5GmS IeV2mCcmvVY6GWbGT/da8p3bRPPcI0KEvLfsDicQOD+MA2juibk4XFEsC zO4NJDqVEEuPNaOf28G9ZA3dnVaz8jS2GtebHZJmEqcGr96o6Ebt+6EJR 5SmlKBz8KmC6mu9ZfBn9riUI4sDVtBv7kH4jOh3ezMLFwHO7gdg34tx6H 0FIeQrhjXOUqARLIRA4YhwI81aoLjciAq19nAQ9+tljfNcEAHGoXs7KYO 1PA7/DqQaNCmqOQK0tAm1z5JIuMJYDaqtQJw9WEtXz+1npZFeTrACkAFq w==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="3747058" X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="3747058" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 04:24:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="4499114" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orviesa004.jf.intel.com with ESMTP; 01 Feb 2024 04:24:13 -0800 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Michal Swiatkowski , Marcin Szycik , Wojciech Drewek , Yury Norov , Andy Shevchenko , Rasmus Villemoes , Alexander Potapenko , Jiri Pirko , Ido Schimmel , Przemek Kitszel , Simon Horman , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, ntfs3@lists.linux.dev, linux-s390@vger.kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v5 09/21] fs/ntfs3: add prefix to bitmap_size() and use BITS_TO_U64() Date: Thu, 1 Feb 2024 13:22:04 +0100 Message-ID: <20240201122216.2634007-10-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240201122216.2634007-1-aleksander.lobakin@intel.com> References: <20240201122216.2634007-1-aleksander.lobakin@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit bitmap_size() is a pretty generic name and one may want to use it for a generic bitmap API function. At the same time, its logic is NTFS-specific, as it aligns to the sizeof(u64), not the sizeof(long) (although it uses ideologically right ALIGN() instead of division). Add the prefix 'ntfs3_' used for that FS (not just 'ntfs_' to not mix it with the legacy module) and use generic BITS_TO_U64() while at it. Suggested-by: Yury Norov # BITS_TO_U64() Reviewed-by: Przemek Kitszel Signed-off-by: Alexander Lobakin --- fs/ntfs3/ntfs_fs.h | 4 ++-- fs/ntfs3/bitmap.c | 4 ++-- fs/ntfs3/fsntfs.c | 2 +- fs/ntfs3/index.c | 11 ++++++----- fs/ntfs3/super.c | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index f6706143d14b..16b84d605cd2 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -961,9 +961,9 @@ static inline bool run_is_empty(struct runs_tree *run) } /* 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); + return BITS_TO_U64(bits) * sizeof(u64); } #define _100ns2seconds 10000000 diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c index 63f14a0232f6..a19a73ed630b 100644 --- a/fs/ntfs3/bitmap.c +++ b/fs/ntfs3/bitmap.c @@ -654,7 +654,7 @@ int wnd_init(struct wnd_bitmap *wnd, struct super_block *sb, size_t nbits) wnd->total_zeroes = nbits; wnd->extent_max = MINUS_ONE_T; wnd->zone_bit = wnd->zone_end = 0; - wnd->nwnd = bytes_to_block(sb, bitmap_size(nbits)); + wnd->nwnd = bytes_to_block(sb, ntfs3_bitmap_size(nbits)); wnd->bits_last = nbits & (wbits - 1); if (!wnd->bits_last) wnd->bits_last = wbits; @@ -1347,7 +1347,7 @@ int wnd_extend(struct wnd_bitmap *wnd, size_t new_bits) return -EINVAL; /* Align to 8 byte boundary. */ - new_wnd = bytes_to_block(sb, bitmap_size(new_bits)); + new_wnd = bytes_to_block(sb, ntfs3_bitmap_size(new_bits)); new_last = new_bits & (wbits - 1); if (!new_last) new_last = wbits; diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index fbfe21dbb425..e18de9c4c2fa 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -522,7 +522,7 @@ static int ntfs_extend_mft(struct ntfs_sb_info *sbi) ni->mi.dirty = true; /* Step 2: Resize $MFT::BITMAP. */ - new_bitmap_bytes = bitmap_size(new_mft_total); + new_bitmap_bytes = ntfs3_bitmap_size(new_mft_total); err = 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 cf92b2433f7a..e0cef8f4e414 100644 --- a/fs/ntfs3/index.c +++ b/fs/ntfs3/index.c @@ -1456,8 +1456,8 @@ static int indx_create_allocate(struct ntfs_index *indx, struct ntfs_inode *ni, alloc->nres.valid_size = alloc->nres.data_size = cpu_to_le64(data_size); - err = ni_insert_resident(ni, bitmap_size(1), ATTR_BITMAP, in->name, - in->name_len, &bitmap, NULL, NULL); + err = ni_insert_resident(ni, ntfs3_bitmap_size(1), ATTR_BITMAP, + in->name, in->name_len, &bitmap, NULL, NULL); if (err) goto out2; @@ -1518,8 +1518,9 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni, if (bmp) { /* Increase bitmap. */ err = attr_set_size(ni, ATTR_BITMAP, in->name, in->name_len, - &indx->bitmap_run, bitmap_size(bit + 1), - NULL, true, NULL); + &indx->bitmap_run, + ntfs3_bitmap_size(bit + 1), NULL, true, + NULL); if (err) goto out1; } @@ -2092,7 +2093,7 @@ static int indx_shrink(struct ntfs_index *indx, struct ntfs_inode *ni, if (in->name == I30_NAME) ni->vfs_inode.i_size = new_data; - bpb = bitmap_size(bit); + bpb = ntfs3_bitmap_size(bit); if (bpb * 8 == nbits) return 0; diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 9153dffde950..0248db1e5c01 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1331,7 +1331,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) /* Check bitmap boundary. */ tt = sbi->used.bitmap.nbits; - if (inode->i_size < bitmap_size(tt)) { + if (inode->i_size < ntfs3_bitmap_size(tt)) { ntfs_err(sb, "$Bitmap is corrupted."); err = -EINVAL; goto put_inode_out; -- 2.43.0