reiserfs: use little-endian bitops directly
PATCH 1/3 reiserfs: use little-endian bitops directly
s/reiserfs_test_and_set_le_bit/__test_and_set_bit_le/ s/reiserfs_test_and_clear_le_bit/__test_and_clear_bit_le/ s/reiserfs_test_le_bit/test_bit_le/ s/reiserfs_find_next_zero_le_bit/find_next_zero_bit_le/
This change reveals that there are some __test_and_{set,clear}_bit_le() calls which ignore the return value. These can be replaced with __{set,clear}_bit_le().
Signed-off-by Akinobu Mita <[email protected]>
--- fs/reiserfs/bitmap.c | 16 +++++++--------- fs/reiserfs/resize.c | 6 +++--- include/linux/reiserfs_fs.h | 5 ----- 3 files changed, 10 insertions(+), 17 deletions(-)
fs/reiserfs/bitmap.c +7 -9
@@ -170,8 +170,7 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th, }/* search for a first zero bit -- beginning of a window */ - *beg =reiserfs_find_next_zero_le_bit - ((unsigned long *)(bh->b_data), boundary, *beg); + *beg =find_next_zero_bit_le (bh->b_data, boundary, *beg);if (*beg + min > boundary) {/* search for a zero bit fails or the rest of bitmap block * cannot contain a zero window of minimum size */
@@ -184,7 +183,7 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th,/* first zero bit found; we check next bits */ for (end = *beg +1 ;; end++) {if (end >= *beg + max || end >= boundary - ||reiserfs_test_le_bit (end, bh->b_data)) { + ||test_bit_le (end, bh->b_data)) { next = end;break ; }
@@ -202,8 +201,7 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th,/* try to set all blocks used checking are they still free */ for (i = *beg; i < end; i++) {/* It seems that we should not check in journal again. */ -if (reiserfs_test_and_set_le_bit - (i, bh->b_data)) { +if (__test_and_set_bit_le (i, bh->b_data)) {/* bit was set by another process * while we slept in prepare_for_journal() */ PROC_INFO_INC (s, scan_bitmap.stolen);
@@ -214,7 +212,7 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th, }/* otherwise we clear all bit were set ... */ while (--i >= *beg) -reiserfs_test_and_clear_le_bit +__test_and_clear_bit_le (i, bh->b_data);reiserfs_restore_prepared_buffer (s, bh); *beg = org;
@@ -411,7 +409,7 @@ static void _reiserfs_free_block(struct reiserfs_transaction_handle *th,reiserfs_prepare_for_journal (s, bmbh,1 );/* clear bit for the given block in bit map */ -if (!reiserfs_test_and_clear_le_bit (offset, bmbh->b_data)) { +if (!__test_and_clear_bit_le (offset, bmbh->b_data)) {reiserfs_error (s,"vs-4080" ,"block %lu: bit already cleared" , block); }
@@ -1215,7 +1213,7 @@ void reiserfs_cache_bitmap_metadata(struct super_block *sb,unsigned long *cur = (unsigned long *)(bh->b_data + bh->b_size);/* The first bit must ALWAYS be 1 */ -if (!reiserfs_test_le_bit (0 , (unsigned long *)bh->b_data)) +if (!test_bit_le (0 , bh->b_data))reiserfs_error (sb,"reiserfs-2025" ,"bitmap block %lu is " "corrupted: first bit must be 1" , bh->b_blocknr);
@@ -1229,7 +1227,7 @@ void reiserfs_cache_bitmap_metadata(struct super_block *sb, info->free_count +=BITS_PER_LONG ; else if (*cur != ~0L) /* A mix, investigate */ for (i = BITS_PER_LONG - 1; i >= 0; i--) -if (!reiserfs_test_le_bit (i, cur)) +if (!test_bit_le (i, cur)) info->free_count++; } }
fs/reiserfs/resize.c +3 -3
@@ -136,7 +136,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)return -EIO ; }memset (bh->b_data,0 ,sb_blocksize (sb)); -reiserfs_test_and_set_le_bit (0 , bh->b_data); +__test_and_set_bit_le (0 , bh->b_data);reiserfs_cache_bitmap_metadata (s, bh, bitmap + i);set_buffer_uptodate (bh);
@@ -172,7 +172,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)reiserfs_prepare_for_journal (s, bh,1 );for (i = block_r; i < s->s_blocksize *8 ; i++) -reiserfs_test_and_clear_le_bit (i, bh->b_data); +__test_and_clear_bit_le (i, bh->b_data); info->free_count += s->s_blocksize *8 - block_r;journal_mark_dirty (&th, s, bh);
@@ -190,7 +190,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)reiserfs_prepare_for_journal (s, bh,1 );for (i = block_r_new; i < s->s_blocksize *8 ; i++) -reiserfs_test_and_set_le_bit (i, bh->b_data); +__test_and_set_bit_le (i, bh->b_data);journal_mark_dirty (&th, s, bh);brelse (bh);
include/linux/reiserfs_fs.h +0 -5
@@ -2332,11 +2332,6 @@ __u32 keyed_hash(const signed char *msg, int len);__u32 yura_hash (const signed char *msg,int len);__u32 r5_hash (const signed char *msg,int len); -#define reiserfs_test_and_set_le_bit __test_and_set_bit_le -#define reiserfs_test_and_clear_le_bit __test_and_clear_bit_le -#define reiserfs_test_le_bit test_bit_le -#define reiserfs_find_next_zero_le_bit find_next_zero_bit_le -/* sometimes reiserfs_truncate may require to allocate few new blocks to perform indirect2direct conversion. People probably used to think, that truncate should work without problems on a filesystem
Signature · 1 line
1.7.4.4
PATCH 2/3 reiserfs: use proper little-endian bitops
Using __test_and_{set,clear}_bit_le() with ignoring its return value can be replaced with __{set,clear}_bit_le().
Signed-off-by Akinobu Mita <[email protected]>
--- fs/reiserfs/bitmap.c | 3 +-- fs/reiserfs/resize.c | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-)
fs/reiserfs/bitmap.c +1 -2
@@ -212,8 +212,7 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th, }/* otherwise we clear all bit were set ... */ while (--i >= *beg) -__test_and_clear_bit_le - (i, bh->b_data); +__clear_bit_le (i, bh->b_data);reiserfs_restore_prepared_buffer (s, bh); *beg = org;/* ... and search again in current block from beginning */
fs/reiserfs/resize.c +3 -3
@@ -136,7 +136,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)return -EIO ; }memset (bh->b_data,0 ,sb_blocksize (sb)); -__test_and_set_bit_le (0 , bh->b_data); +__set_bit_le (0 , bh->b_data);reiserfs_cache_bitmap_metadata (s, bh, bitmap + i);set_buffer_uptodate (bh);
@@ -172,7 +172,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)reiserfs_prepare_for_journal (s, bh,1 );for (i = block_r; i < s->s_blocksize *8 ; i++) -__test_and_clear_bit_le (i, bh->b_data); +__clear_bit_le (i, bh->b_data); info->free_count += s->s_blocksize *8 - block_r;journal_mark_dirty (&th, s, bh);
@@ -190,7 +190,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)reiserfs_prepare_for_journal (s, bh,1 );for (i = block_r_new; i < s->s_blocksize *8 ; i++) -__test_and_set_bit_le (i, bh->b_data); +__set_bit_le (i, bh->b_data);journal_mark_dirty (&th, s, bh);brelse (bh);
Signature · 1 line
1.7.4.4
PATCH 3/3 reiserfs: use hweight_long
In reply to Akinobu MitaUse hweight_long() to count free bits in the bitmap.
Signed-off-by Akinobu Mita <[email protected]>
--- fs/reiserfs/bitmap.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
fs/reiserfs/bitmap.c +1 -5
@@ -1219,15 +1219,11 @@ void reiserfs_cache_bitmap_metadata(struct super_block *sb, info->free_count =0 ;while (--cur >= (unsigned long *)bh->b_data) { -int i; -/* 0 and ~0 are special, we can optimize for them */ if (*cur ==0 ) info->free_count +=BITS_PER_LONG ;else if (*cur != ~0L )/* A mix, investigate */ -for (i =BITS_PER_LONG -1 ; i >=0 ; i--) -if (!test_bit_le (i, cur)) - info->free_count++; + info->free_count +=BITS_PER_LONG -hweight_long (*cur); } }
Signature · 1 line
1.7.4.4