+ reiserfs-fix-is_reusable-bitmap-check-to-not-traverse-the-bitmap-info-array.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     reiserfs: fix is_reusable bitmap check to not traverse the bitmap info array

has been added to the -mm tree.  Its filename is

     reiserfs-fix-is_reusable-bitmap-check-to-not-traverse-the-bitmap-info-array.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: reiserfs: fix is_reusable bitmap check to not traverse the bitmap info array
From: Jeff Mahoney <jeffm@xxxxxxxx>


There is a check in is_reusable to determine if a particular block is a bitmap
block.  It verifies this by going through the array of bitmap block buffer
heads and comparing the block number to each one.

Bitmap blocks are at defined locations on the disk in both old and current
formats.  Simply checking against the known good values is enough.

This is a trivial optimization for a non-production codepath, but this is the
first in a series of patches that will ultimately remove the buffer heads from
that array.

Signed-off-by: Jeff Mahoney <jeffm@xxxxxxxx>
Cc: <reiserfs-dev@xxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 fs/reiserfs/bitmap.c           |   40 +++++++++++++++++++------------
 fs/reiserfs/super.c            |    2 +
 include/linux/reiserfs_fs_sb.h |    1 
 3 files changed, 28 insertions(+), 15 deletions(-)

diff -puN fs/reiserfs/bitmap.c~reiserfs-fix-is_reusable-bitmap-check-to-not-traverse-the-bitmap-info-array fs/reiserfs/bitmap.c
--- 25/fs/reiserfs/bitmap.c~reiserfs-fix-is_reusable-bitmap-check-to-not-traverse-the-bitmap-info-array	Mon Jun 19 18:17:27 2006
+++ 25-akpm/fs/reiserfs/bitmap.c	Mon Jun 19 18:17:27 2006
@@ -51,16 +51,15 @@ static inline void get_bit_address(struc
 {
 	/* It is in the bitmap block number equal to the block
 	 * number divided by the number of bits in a block. */
-	*bmap_nr = block / (s->s_blocksize << 3);
+	*bmap_nr = block >> (s->s_blocksize_bits + 3);
 	/* Within that bitmap block it is located at bit offset *offset. */
 	*offset = block & ((s->s_blocksize << 3) - 1);
-	return;
 }
 
 #ifdef CONFIG_REISERFS_CHECK
 int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value)
 {
-	int i, j;
+	int bmap, offset;
 
 	if (block == 0 || block >= SB_BLOCK_COUNT(s)) {
 		reiserfs_warning(s,
@@ -69,34 +68,45 @@ int is_reusable(struct super_block *s, b
 		return 0;
 	}
 
-	/* it can't be one of the bitmap blocks */
-	for (i = 0; i < SB_BMAP_NR(s); i++)
-		if (block == SB_AP_BITMAP(s)[i].bh->b_blocknr) {
+	get_bit_address(s, block, &bmap, &offset);
+
+	/* Old format filesystem? Unlikely, but the bitmaps are all up front so
+	 * we need to account for it. */
+	if (unlikely(test_bit(REISERFS_OLD_FORMAT,
+			      &(REISERFS_SB(s)->s_properties)))) {
+		b_blocknr_t bmap1 = REISERFS_SB(s)->s_sbh->b_blocknr + 1;
+		if (block >= bmap1 && block <= bmap1 + SB_BMAP_NR(s)) {
+			reiserfs_warning(s, "vs: 4019: is_reusable: "
+					 "bitmap block %lu(%u) can't be freed or reused",
+					 block, SB_BMAP_NR(s));
+			return 0;
+		}
+	} else {
+		if (offset == 0) {
 			reiserfs_warning(s, "vs: 4020: is_reusable: "
 					 "bitmap block %lu(%u) can't be freed or reused",
 					 block, SB_BMAP_NR(s));
 			return 0;
 		}
+	}
 
-	get_bit_address(s, block, &i, &j);
-
-	if (i >= SB_BMAP_NR(s)) {
+	if (bmap >= SB_BMAP_NR(s)) {
 		reiserfs_warning(s,
 				 "vs-4030: is_reusable: there is no so many bitmap blocks: "
-				 "block=%lu, bitmap_nr=%d", block, i);
+				 "block=%lu, bitmap_nr=%d", block, bmap);
 		return 0;
 	}
 
 	if ((bit_value == 0 &&
-	     reiserfs_test_le_bit(j, SB_AP_BITMAP(s)[i].bh->b_data)) ||
+	     reiserfs_test_le_bit(offset, SB_AP_BITMAP(s)[bmap].bh->b_data)) ||
 	    (bit_value == 1 &&
-	     reiserfs_test_le_bit(j, SB_AP_BITMAP(s)[i].bh->b_data) == 0)) {
+	     reiserfs_test_le_bit(offset, SB_AP_BITMAP(s)[bmap].bh->b_data) == 0)) {
 		reiserfs_warning(s,
 				 "vs-4040: is_reusable: corresponding bit of block %lu does not "
-				 "match required value (i==%d, j==%d) test_bit==%d",
-				 block, i, j, reiserfs_test_le_bit(j,
+				 "match required value (bmap==%d, offset==%d) test_bit==%d",
+				 block, bmap, offset, reiserfs_test_le_bit(offset,
 								   SB_AP_BITMAP
-								   (s)[i].bh->
+								   (s)[bmap].bh->
 								   b_data));
 
 		return 0;
diff -puN fs/reiserfs/super.c~reiserfs-fix-is_reusable-bitmap-check-to-not-traverse-the-bitmap-info-array fs/reiserfs/super.c
--- 25/fs/reiserfs/super.c~reiserfs-fix-is_reusable-bitmap-check-to-not-traverse-the-bitmap-info-array	Mon Jun 19 18:17:27 2006
+++ 25-akpm/fs/reiserfs/super.c	Mon Jun 19 18:17:27 2006
@@ -1832,6 +1832,8 @@ static int reiserfs_fill_super(struct su
 	if (is_reiserfs_3_5(rs)
 	    || (is_reiserfs_jr(rs) && SB_VERSION(s) == REISERFS_VERSION_1))
 		set_bit(REISERFS_3_5, &(sbi->s_properties));
+	else if (old_format)
+		set_bit(REISERFS_OLD_FORMAT, &(sbi->s_properties));
 	else
 		set_bit(REISERFS_3_6, &(sbi->s_properties));
 
diff -puN include/linux/reiserfs_fs_sb.h~reiserfs-fix-is_reusable-bitmap-check-to-not-traverse-the-bitmap-info-array include/linux/reiserfs_fs_sb.h
--- 25/include/linux/reiserfs_fs_sb.h~reiserfs-fix-is_reusable-bitmap-check-to-not-traverse-the-bitmap-info-array	Mon Jun 19 18:17:27 2006
+++ 25-akpm/include/linux/reiserfs_fs_sb.h	Mon Jun 19 18:17:27 2006
@@ -414,6 +414,7 @@ struct reiserfs_sb_info {
 /* Definitions of reiserfs on-disk properties: */
 #define REISERFS_3_5 0
 #define REISERFS_3_6 1
+#define REISERFS_OLD_FORMAT 2
 
 enum reiserfs_mount_options {
 /* Mount options */
_

Patches currently in -mm which might be from jeffm@xxxxxxxx are

reiserfs-fix-is_reusable-bitmap-check-to-not-traverse-the-bitmap-info-array.patch
reiserfs-clean-up-bitmap-block-buffer-head-references.patch
reiserfs-reorganize-bitmap-loading-functions.patch
reiserfs-on-demand-bitmap-loading.patch
lib-add-idr_replace.patch
lib-add-idr_replace-tidy.patch
dm-fix-idr-minor-allocation.patch
dm-move-idr_pre_get.patch
dm-change-minor_lock-to-spinlock.patch
dm-add-dmf_freeing.patch
dm-fix-mapped-device-ref-counting.patch
dm-add-module-ref-counting.patch
dm-fix-block-device-initialisation.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux