Introduce ext4_find_next_bit
PATCH 1/1 Introduce ext4_find_next_bit
Also add generic_find_next_le_bit
This gets used by the ext4 multi block allocator patches.
--- include/asm-generic/bitops/ext2-non-atomic.h | 2 + include/asm-generic/bitops/le.h | 4 ++ include/asm-powerpc/bitops.h | 4 ++ include/linux/ext4_fs.h | 1 + lib/find_next_bit.c | 44 ++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 0 deletions(-)
include/asm-generic/bitops/ext2-non-atomic.h +2 -0
@@ -14,5 +14,7 @@ generic_find_first_zero_le_bit((unsigned long *)(addr), (size))#define ext2_find_next_zero_bit (addr, size, off) \ generic_find_next_zero_le_bit((unsigned long *)(addr), (size), (off)) +#define ext2_find_next_bit (addr, size, off) \ + generic_find_next_le_bit((unsigned long *)(addr), (size), (off))#endif /* _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_ */
include/asm-generic/bitops/le.h +4 -0
@@ -20,6 +20,8 @@#define generic___test_and_clear_le_bit (nr, addr) __test_and_clear_bit(nr, addr)#define generic_find_next_zero_le_bit (addr, size, offset) find_next_zero_bit(addr, size, offset) +#define generic_find_next_le_bit (addr, size, offset) \ + find_next_bit(addr, size, offset)#elif defined(__BIG_ENDIAN)
@@ -42,6 +44,8 @@extern unsigned long generic_find_next_zero_le_bit (const unsigned long *addr,unsigned long size,unsigned long offset); +extern unsigned long generic_find_next_le_bit (const unsigned long *addr, +unsigned long size,unsigned long offset);#else #error "Please fix <asm/byteorder.h>"
include/asm-powerpc/bitops.h +4 -0
@@ -310,6 +310,8 @@ static __inline__ int test_le_bit(unsigned long nr,unsigned long generic_find_next_zero_le_bit (const unsigned long *addr,unsigned long size,unsigned long offset); +unsigned long generic_find_next_le_bit (const unsigned long *addr, +unsigned long size,unsigned long offset);/* Bitmap functions for the ext2 filesystem */ #define ext2_set_bit (nr,addr) \
@@ -329,6 +331,8 @@ unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,#define ext2_find_next_zero_bit (addr, size, off) \ generic_find_next_zero_le_bit((unsigned long*)addr, size, off) +#define ext2_find_next_bit (addr, size, off) \ + generic_find_next_le_bit((unsigned long *)addr, size, off)/* Bitmap functions for the minix filesystem. */ #define minix_test_and_set_bit (nr,addr) \
include/linux/ext4_fs.h +1 -0
@@ -502,6 +502,7 @@ do { \#define ext4_test_bit ext2_test_bit#define ext4_find_first_zero_bit ext2_find_first_zero_bit#define ext4_find_next_zero_bit ext2_find_next_zero_bit +#define ext4_find_next_bit ext2_find_next_bit/* * Maximal mount counts between two filesystem checks
lib/find_next_bit.c +44 -0
48 lines not on this page · raw message
Signature · 1 line
1.5.3.1.91.gd3392-dirty
PATCH 1/1 ext4: Fix spare warnings
--- fs/ext4/inode.c | 6 ++++-- include/linux/ext4_fs.h | 16 ++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-)
fs/ext4/inode.c +4 -2
@@ -3177,12 +3177,14 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode) iloc, handle);if (ret) {EXT4_I (inode)->i_state |=EXT4_STATE_NO_EXPAND ; -if (mnt_count != sbi->s_es->s_mnt_count) { +if (mnt_count != +le16_to_cpu (sbi->s_es->s_mnt_count)) {ext4_warning (inode->i_sb, __FUNCTION__,"Unable to expand inode %lu. Delete" " some EAs or run e2fsck." , inode->i_ino); - mnt_count = sbi->s_es->s_mnt_count; + mnt_count = +le16_to_cpu (sbi->s_es->s_mnt_count); } } }
include/linux/ext4_fs.h +8 -8
@@ -129,7 +129,7 @@ struct ext4_group_desc__le16 bg_free_blocks_count;/* Free blocks count */ __le16 bg_free_inodes_count;/* Free inodes count */ __le16 bg_used_dirs_count;/* Directories count */ -__u16 bg_flags; +__le16 bg_flags;__u32 bg_reserved[3 ];__le32 bg_block_bitmap_hi;/* Blocks bitmap block MSB */ __le32 bg_inode_bitmap_hi;/* Inodes bitmap block MSB */
@@ -596,13 +596,13 @@ struct ext4_super_block {/*150*/ __le32 s_blocks_count_hi;/* Blocks count */ __le32 s_r_blocks_count_hi;/* Reserved blocks count */ __le32 s_free_blocks_count_hi;/* Free blocks count */ -__u16 s_min_extra_isize;/* All inodes have at least # bytes */ -__u16 s_want_extra_isize;/* New inodes should reserve # bytes */ -__u32 s_flags;/* Miscellaneous flags */ -__u16 s_raid_stride;/* RAID stride */ -__u16 s_mmp_interval;/* # seconds to wait in MMP checking */ -__u64 s_mmp_block;/* Block for multi-mount protection */ -__u32 s_raid_stripe_width;/* blocks on all data disks (N*stride)*/ +__le16 s_min_extra_isize;/* All inodes have at least # bytes */ +__le16 s_want_extra_isize;/* New inodes should reserve # bytes */ +__le32 s_flags;/* Miscellaneous flags */ +__le16 s_raid_stride;/* RAID stride */ +__le16 s_mmp_interval;/* # seconds to wait in MMP checking */ +__le64 s_mmp_block;/* Block for multi-mount protection */ +__le32 s_raid_stripe_width;/* blocks on all data disks (N*stride)*/ __u32 s_reserved[163 ];/* Padding to the end of the block */ };
Signature · 1 line
1.5.3.1.91.gd3392-dirty
Re: [PATCH] ext4: Fix spare warnings
Aneesh,
The subject is a bit confusing, I presume you mean sparse warnings
Balbir
Quoted 4 lines · Aneesh Kumar K.V
Also add
generic_find_next_le_bitThis gets used by the ext4 multi block allocator patches.
Looks like it's a straight forward on Little Endian Architectures. I see something for powerpc, what about other architectures?
lib/find_next_bit.c found_middle_swap: · line 183
Quoted 4 lines
lib/find_next_bit.c +3
-0+unsigned long generic_find_next_le_bit (const unsigned long *addr,unsigned +long size,unsigned long offset) +{
Docbook style comments on the function and arguments would be nice.
Quoted 42 lines
lib/find_next_bit.c +41
-0+const unsigned long *p = addr +BITOP_WORD (offset); +unsigned long result = offset & ~(BITS_PER_LONG -1 ); +unsigned long tmp; + +if (offset >= size) +return size; + size -= result; + offset &= (BITS_PER_LONG -1UL ); +if (offset) { + tmp =ext2_swabp (p++); + tmp &= (~0UL << offset); +if (size <BITS_PER_LONG ) + goto found_first; +if (tmp) + goto found_middle; + size -=BITS_PER_LONG ; + result +=BITS_PER_LONG ; + } + +while (size & ~(BITS_PER_LONG -1 )) { + tmp = *(p++); +if (tmp) + goto found_middle_swap; + result +=BITS_PER_LONG ; + size -=BITS_PER_LONG ; + } +if (!size) +return result; + tmp =ext2_swabp (p); +found_first: + tmp &= (~0UL >> (BITS_PER_LONG - size)); +if (tmp ==0UL )/* Are any bits set? */ +return result + size;/* Nope. */ +found_middle: +return result +__ffs (tmp); + +found_middle_swap: + return result + __ffs(ext2_swab(tmp)); +} +EXPORT_SYMBOL (generic_find_next_le_bit); +#endif /* __BIG_ENDIAN */
Signature · 4 lines
Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL
Re: [PATCH] ext4: Fix spare warnings
In reply to Balbir SinghQuoted 3 lines · Balbir Singh
Aneesh,
The subject is a bit confusing, I presume you mean sparse warnings
yes. I will send an updated patch. The group descriptor bg_flags -> le16 conversion should actually go with the uninitialized block group patch.
-aneesh.
Quoted 10 lines · Balbir Singh
Quoted 4 lines · Aneesh Kumar K.V
Also add
generic_find_next_le_bitThis gets used by the ext4 multi block allocator patches.
Looks like it's a straight forward on Little Endian Architectures. I see something for powerpc, what about other architectures?
All include/asm-<arch>/bitops.h except powerpc have
#include <asm-generic/bitops/ext2-non-atomic.h>
and ext2-non-atomic.h have #include <asm-generic/bitops/le.h>
-aneesh
Andrew Morton
maintainerQuoted 4 lines · On Fri, 21 Sep 2007 10:55:05 +0530 "Aneesh Kumar K.V"…
Also add
generic_find_next_le_bitThis gets used by the ext4 multi block allocator patches.
arm allmodconfig:
fs/ext4/mballoc.c: In function `ext4_mb_generate_buddy':fs/ext4/mballoc.c:836: error: implicit declaration of function `ext2_find_next_bit'
This patch makes my head spin.
Why did we declare generic_find_next_le_bit() in include/asm-powerpc/bitops.h (wrong) as well as in include/asm-generic/bitops/le.h (presumably correct)?
Why is it touching a powerpc file and no any other architectures? Something screwed up in powerpc land?
And why did arm break?
Shudder. Anyway, please fix, and if that fix requires that various braindamaged be repaired, please repair the braindamage rather than going along with it.
Thanks.
Quoted 9 lines · Andrew Morton
Quoted 4 lines · On Fri, 21 Sep 2007 10:55:05 +0530 "Aneesh Kumar K.V"…
Also add
generic_find_next_le_bitThis gets used by the ext4 multi block allocator patches.
arm allmodconfig:
Quoted 9 lines
fs/ext4/mballoc.c: In function `ext4_mb_generate_buddy':fs/ext4/mballoc.c:836: error: implicit declaration of function `ext2_find_next_bit'This patch makes my head spin.
Why did we declare
generic_find_next_le_bit()ininclude/asm-powerpc/bitops.h(wrong) as well as ininclude/asm-generic/bitops/le.h(presumably correct)?
I was following the coding style used for rest of the APIs like ext4_set_bit.
Quoted 3 lines
Why is it touching a powerpc file and no any other architectures? Something screwed up in powerpc land?
And why did arm break?
arm and below list of arch doesn't include the asm-generic/bitops/ext2-non-atomic.h
I did a grep and that list the below architectures as also affected. arm, m68k, m68knommu, s390
Quoted 6 lines
Shudder. Anyway, please fix, and if that fix requires that various braindamaged be repaired, please repair the braindamage rather than going along with it.
That should be a separate patch altogether. I wanted to do the cleanup along with the usages such as but never got time to do the same.
#define ocfs2_set_bit ext2_set_bit
#define udf_set_bit(nr,addr) ext2_set_bit(nr,addr) direct usage in mbmd/bitmap.c +799md/dm-log.c +177
I will send a patch tomorrow that fix arm and other architectures. I guess the cleanup can be a separate patch ?
-aneesh
Andrew Morton
maintainerQuoted 17 lines · On Wed, 14 Nov 2007 00:41:03 +0530 "Aneesh Kumar K.V"…
Quoted 14 lines · Andrew Morton
Quoted 4 lines · On Fri, 21 Sep 2007 10:55:05 +0530 "Aneesh Kumar K.V"…
Also add
generic_find_next_le_bitThis gets used by the ext4 multi block allocator patches.
arm allmodconfig:
fs/ext4/mballoc.c: In function `ext4_mb_generate_buddy':fs/ext4/mballoc.c:836: error: implicit declaration of function `ext2_find_next_bit'This patch makes my head spin.
Quoted 7 lines
Quoted 4 lines
Why did we declare
generic_find_next_le_bit()ininclude/asm-powerpc/bitops.h(wrong) as well as ininclude/asm-generic/bitops/le.h(presumably correct)?I was following the coding style used for rest of the APIs like
ext4_set_bit.
Well. There's quite a bit of cruft in there. If you do come across something which isn't right, please do try to find the time to fix it up first.
That might be non-trivial - powerpc does seem to have gone off on a strange tangent there.
Quoted 21 lines
Quoted 5 lines
Why is it touching a powerpc file and no any other architectures? Something screwed up in powerpc land?
And why did arm break?
arm and below list of arch doesn't include the
asm-generic/bitops/ext2-non-atomic.hI did a grep and that list the below architectures as also affected. arm, m68k, m68knommu, s390
Quoted 6 lines
Shudder. Anyway, please fix, and if that fix requires that various braindamaged be repaired, please repair the braindamage rather than going along with it.
That should be a separate patch altogether. I wanted to do the cleanup along with the usages such as but never got time to do the same.
Quoted 9 lines
#define
ocfs2_set_bitext2_set_bit
#defineudf_set_bit(nr,addr)ext2_set_bit(nr,addr)direct usage in mbmd/bitmap.c+799md/dm-log.c+177I will send a patch tomorrow that fix arm and other architectures. I guess the cleanup can be a separate patch ?
Yes, that's a separate work, thanks.