Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs/ntfs3: add prefix to bitmap_size() and use BITS_TO_U64()

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>

authored by

Alexander Lobakin and committed by
David S. Miller
3f5ef510 c1023f56

+12 -11
+2 -2
fs/ntfs3/bitmap.c
··· 654 654 wnd->total_zeroes = nbits; 655 655 wnd->extent_max = MINUS_ONE_T; 656 656 wnd->zone_bit = wnd->zone_end = 0; 657 - wnd->nwnd = bytes_to_block(sb, bitmap_size(nbits)); 657 + wnd->nwnd = bytes_to_block(sb, ntfs3_bitmap_size(nbits)); 658 658 wnd->bits_last = nbits & (wbits - 1); 659 659 if (!wnd->bits_last) 660 660 wnd->bits_last = wbits; ··· 1347 1347 return -EINVAL; 1348 1348 1349 1349 /* Align to 8 byte boundary. */ 1350 - new_wnd = bytes_to_block(sb, bitmap_size(new_bits)); 1350 + new_wnd = bytes_to_block(sb, ntfs3_bitmap_size(new_bits)); 1351 1351 new_last = new_bits & (wbits - 1); 1352 1352 if (!new_last) 1353 1353 new_last = wbits;
+1 -1
fs/ntfs3/fsntfs.c
··· 522 522 ni->mi.dirty = true; 523 523 524 524 /* Step 2: Resize $MFT::BITMAP. */ 525 - new_bitmap_bytes = bitmap_size(new_mft_total); 525 + new_bitmap_bytes = ntfs3_bitmap_size(new_mft_total); 526 526 527 527 err = attr_set_size(ni, ATTR_BITMAP, NULL, 0, &sbi->mft.bitmap.run, 528 528 new_bitmap_bytes, &new_bitmap_bytes, true, NULL);
+6 -5
fs/ntfs3/index.c
··· 1456 1456 1457 1457 alloc->nres.valid_size = alloc->nres.data_size = cpu_to_le64(data_size); 1458 1458 1459 - err = ni_insert_resident(ni, bitmap_size(1), ATTR_BITMAP, in->name, 1460 - in->name_len, &bitmap, NULL, NULL); 1459 + err = ni_insert_resident(ni, ntfs3_bitmap_size(1), ATTR_BITMAP, 1460 + in->name, in->name_len, &bitmap, NULL, NULL); 1461 1461 if (err) 1462 1462 goto out2; 1463 1463 ··· 1518 1518 if (bmp) { 1519 1519 /* Increase bitmap. */ 1520 1520 err = attr_set_size(ni, ATTR_BITMAP, in->name, in->name_len, 1521 - &indx->bitmap_run, bitmap_size(bit + 1), 1522 - NULL, true, NULL); 1521 + &indx->bitmap_run, 1522 + ntfs3_bitmap_size(bit + 1), NULL, true, 1523 + NULL); 1523 1524 if (err) 1524 1525 goto out1; 1525 1526 } ··· 2093 2092 if (in->name == I30_NAME) 2094 2093 i_size_write(&ni->vfs_inode, new_data); 2095 2094 2096 - bpb = bitmap_size(bit); 2095 + bpb = ntfs3_bitmap_size(bit); 2097 2096 if (bpb * 8 == nbits) 2098 2097 return 0; 2099 2098
+2 -2
fs/ntfs3/ntfs_fs.h
··· 966 966 } 967 967 968 968 /* NTFS uses quad aligned bitmaps. */ 969 - static inline size_t bitmap_size(size_t bits) 969 + static inline size_t ntfs3_bitmap_size(size_t bits) 970 970 { 971 - return ALIGN((bits + 7) >> 3, 8); 971 + return BITS_TO_U64(bits) * sizeof(u64); 972 972 } 973 973 974 974 #define _100ns2seconds 10000000
+1 -1
fs/ntfs3/super.c
··· 1341 1341 1342 1342 /* Check bitmap boundary. */ 1343 1343 tt = sbi->used.bitmap.nbits; 1344 - if (inode->i_size < bitmap_size(tt)) { 1344 + if (inode->i_size < ntfs3_bitmap_size(tt)) { 1345 1345 ntfs_err(sb, "$Bitmap is corrupted."); 1346 1346 err = -EINVAL; 1347 1347 goto put_inode_out;