mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
fs/ntfs3: add prefix to bitmap_size() and use BITS_TO_U64()
commit 3f5ef5109f6a054ce58b3bec7214ed76c9cc269f upstream. 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 <yury.norov@gmail.com> # BITS_TO_U64() Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Reviewed-by: Yury Norov <yury.norov@gmail.com> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
437741eba6
commit
2db69eaa3d
@@ -656,7 +656,7 @@ int wnd_init(struct wnd_bitmap *wnd, struct super_block *sb, size_t nbits)
|
|||||||
wnd->total_zeroes = nbits;
|
wnd->total_zeroes = nbits;
|
||||||
wnd->extent_max = MINUS_ONE_T;
|
wnd->extent_max = MINUS_ONE_T;
|
||||||
wnd->zone_bit = wnd->zone_end = 0;
|
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);
|
wnd->bits_last = nbits & (wbits - 1);
|
||||||
if (!wnd->bits_last)
|
if (!wnd->bits_last)
|
||||||
wnd->bits_last = wbits;
|
wnd->bits_last = wbits;
|
||||||
@@ -1320,7 +1320,7 @@ int wnd_extend(struct wnd_bitmap *wnd, size_t new_bits)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Align to 8 byte boundary. */
|
/* 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);
|
new_last = new_bits & (wbits - 1);
|
||||||
if (!new_last)
|
if (!new_last)
|
||||||
new_last = wbits;
|
new_last = wbits;
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ static int ntfs_extend_mft(struct ntfs_sb_info *sbi)
|
|||||||
ni->mi.dirty = true;
|
ni->mi.dirty = true;
|
||||||
|
|
||||||
/* Step 2: Resize $MFT::BITMAP. */
|
/* 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,
|
err = attr_set_size(ni, ATTR_BITMAP, NULL, 0, &sbi->mft.bitmap.run,
|
||||||
new_bitmap_bytes, &new_bitmap_bytes, true, NULL);
|
new_bitmap_bytes, &new_bitmap_bytes, true, NULL);
|
||||||
|
|||||||
@@ -1454,8 +1454,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);
|
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,
|
err = ni_insert_resident(ni, ntfs3_bitmap_size(1), ATTR_BITMAP,
|
||||||
in->name_len, &bitmap, NULL, NULL);
|
in->name, in->name_len, &bitmap, NULL, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
goto out2;
|
goto out2;
|
||||||
|
|
||||||
@@ -1516,8 +1516,9 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
|
|||||||
if (bmp) {
|
if (bmp) {
|
||||||
/* Increase bitmap. */
|
/* Increase bitmap. */
|
||||||
err = attr_set_size(ni, ATTR_BITMAP, in->name, in->name_len,
|
err = attr_set_size(ni, ATTR_BITMAP, in->name, in->name_len,
|
||||||
&indx->bitmap_run, bitmap_size(bit + 1),
|
&indx->bitmap_run,
|
||||||
NULL, true, NULL);
|
ntfs3_bitmap_size(bit + 1), NULL, true,
|
||||||
|
NULL);
|
||||||
if (err)
|
if (err)
|
||||||
goto out1;
|
goto out1;
|
||||||
}
|
}
|
||||||
@@ -2080,7 +2081,7 @@ static int indx_shrink(struct ntfs_index *indx, struct ntfs_inode *ni,
|
|||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
bpb = bitmap_size(bit);
|
bpb = ntfs3_bitmap_size(bit);
|
||||||
if (bpb * 8 == nbits)
|
if (bpb * 8 == nbits)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
@@ -951,9 +951,9 @@ static inline bool run_is_empty(struct runs_tree *run)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* NTFS uses quad aligned bitmaps. */
|
/* 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
|
#define _100ns2seconds 10000000
|
||||||
|
|||||||
@@ -1108,7 +1108,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
|
|||||||
|
|
||||||
/* Check bitmap boundary. */
|
/* Check bitmap boundary. */
|
||||||
tt = sbi->used.bitmap.nbits;
|
tt = sbi->used.bitmap.nbits;
|
||||||
if (inode->i_size < bitmap_size(tt)) {
|
if (inode->i_size < ntfs3_bitmap_size(tt)) {
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto put_inode_out;
|
goto put_inode_out;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user