Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp129998lqo; Wed, 27 Mar 2024 08:41:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+E0UPaSuShZ4NPlHpmOABQnCvQd6Z+4jfzwD3cRIYkGctUNxzqXAGLoHF54SA9fqnssBUWpwCjgQ9prcLBwJZ0lD73mDkgyjgf1Zaaw== X-Google-Smtp-Source: AGHT+IHFhDMC5mzlPh8zyGAWsA+KBTKVuSqb3LeOKnQfmP8iOMivF90rP1oCUMd73LMh8xAJW8c4 X-Received: by 2002:a17:902:ecd1:b0:1e0:b287:c1d8 with SMTP id a17-20020a170902ecd100b001e0b287c1d8mr86328plh.5.1711554114643; Wed, 27 Mar 2024 08:41:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711554114; cv=pass; d=google.com; s=arc-20160816; b=SU9OdafW2BNfRUMF6G3BzWaLcXsP28j3n2YqVQK0+4xUIinSIy0EOJacU/4wYH6kqy rX07G726ZpC7M7yhfMwSfeexKxVTQfBtWsc4nK95jlQMX5+tEzpGMX5glThiVcrm992p F8v+2RIoHpDdJM88vhq/Qam5xvwTj7gJ3afQ87A6cEb5XGVFesZKPWdwxZEerxJx/AaV S9Vdwi7to4Dnoq98VWi2JAA5wE0pWCjb1Jc3ldMiH3cN/oFV4On8+b2WWZz+PlCfAt2i aecctbeu+X69mQFu0Rbu+4MH5/jGQzmrRrwUlKdrhM0wHg+FfapgkYQMY6pw/8HUxAVI jyyA== 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=pNHm1AyLJHs3zPZYQJCU8Iim9j4UiStbgV1GBhwtX7g=; fh=Z7nwqFw9jo7mwUVP6sFBJfcE9oHe3fvGcHvWZvLmnnc=; b=UkhqzXubeZpBHAOZ+J87Y86torTxtU8UplUBQ184bKFH1hMLuHC59DlR0urXwMLdaU 8y072nYlDYsbntbvN/BRaBs/CSESeUrnaQVpgEGF/tv3Ceo1CpcI8X1HbMlUfUfe+KH/ VXGl27acOjZLXfGpT1sAOVpRkqCw1mSGJsMF8SScuB5tXP6HWgu+IF2nFXoOQgf3swWO m6AfW4VYBRHfEaBFCi4qJ5fAxUE8z5GqvMd8Q3M/z/yUYPTq9gcdOAoJ0SrNoSLlkNjS EGOwBmreDJqjiY+kug3Ed7eeQmTKT2mlSWCKkhRIx4srL6cVkKOHF12XM110giuhp5M7 mhmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Et7m7mJh; 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-121519-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121519-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p10-20020a1709028a8a00b001db45912e79si9172893plo.594.2024.03.27.08.41.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:41:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121519-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Et7m7mJh; 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-121519-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121519-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0B6D9290EAA for ; Wed, 27 Mar 2024 15:33:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C00411487DB; Wed, 27 Mar 2024 15:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Et7m7mJh" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 3822559B71; Wed, 27 Mar 2024 15:25:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711553105; cv=none; b=fuVeQuKvzb7yeTznypqIMRG6g0oKx7E2jyXgF375Idf1jP1duO9pCQ5L75ZcBVg8wtm9GcFAyC0BHuGVnQjxv1XXInFWHq0q16CXRvnx8qHdJ8neFZWPBCWRsV1r0/Yfy/iFGajbzT8lOznxgGMLhyn+9BUOSmf44NT49uGqie0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711553105; c=relaxed/simple; bh=9FH8aw4dGuAYnk5oSyIJywDfG0vyXaG4gNHbxtWks0Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vxw1Z9eC1cgajdHzJKUSsB6q9gEonMm2vntVxklBUOLSqi3P8RcUgecylj/xkU8XhKsomYQYoECQqljC9WcDKWqHNll7iCixPD0F2K9kqhG/Xp9fTZaDDs7/9kBzJktZsgCWTWZgnCsXaOXcVnURnTOBLjBdGo9ILgyg9Vv3cg8= 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=Et7m7mJh; arc=none smtp.client-ip=198.175.65.19 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=1711553104; x=1743089104; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9FH8aw4dGuAYnk5oSyIJywDfG0vyXaG4gNHbxtWks0Y=; b=Et7m7mJhQdqBJB+jj987fOH4SCFLy2zJKsdHKaY7mKFxf7Y0IIazcPlV L8Up+MXnSbTdt7dS5oPEl2a0Rc6KiP1dqr5FBDbLHLptgQdzpDawxqVVB YiqT3NcuRV9Uto3MbgUitJrh+HcGklYIGTJewPaNPuiY2Lf9n4jXXXCrd s6U8Jo9e1G1RBx2UY3+AT1+0Tj5/DJVhzbg49jSZv2EPukWLxErccFylA oqUEhmlRTgomk5Mg0bdPcSO/C0xeF+ehvc1cP820WBras/RMTqAwzpfcF LglsQ+uPw3a3aS58rR+AifMp4YdNG4x2q5D45SwC3aM74jcCf64/aBy2v Q==; X-CSE-ConnectionGUID: IR6qa2mBS7uLoUP7hsMnww== X-CSE-MsgGUID: qb3Y7HnRRRm7hxBTfZ+cNA== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="6518187" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="6518187" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 08:25:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16414219" Received: from newjersey.igk.intel.com ([10.102.20.203]) by fmviesa008.fm.intel.com with ESMTP; 27 Mar 2024 08:25:01 -0700 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Yury Norov , Alexander Potapenko , nex.sw.ncis.osdt.itp.upstreaming@intel.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Przemek Kitszel Subject: [PATCH net-next v6 09/21] fs/ntfs3: add prefix to bitmap_size() and use BITS_TO_U64() Date: Wed, 27 Mar 2024 16:23:46 +0100 Message-ID: <20240327152358.2368467-10-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327152358.2368467-1-aleksander.lobakin@intel.com> References: <20240327152358.2368467-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 Reviewed-by: Yury Norov 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 79356fd29a14..ea5b5e814e63 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -966,9 +966,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 845f9b22deef..c9eb01ccee51 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 ae2ef5c11868..626d3f2c7e2d 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 daabaad63aaf..43796aaa3d97 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) i_size_write(&ni->vfs_inode, 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 9df7c20d066f..71dfeb0c4323 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1341,7 +1341,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.44.0