]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
ext4: Add ext4_find_next_bit()
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Tue, 29 Jan 2008 04:58:27 +0000 (23:58 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 29 Jan 2008 04:58:27 +0000 (23:58 -0500)
This function is used by the ext4 multi block allocator patches.

Also add generic_find_next_le_bit

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: <linux-ext4@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/asm-arm/bitops.h
include/asm-generic/bitops/ext2-non-atomic.h
include/asm-generic/bitops/le.h
include/asm-m68k/bitops.h
include/asm-m68knommu/bitops.h
include/asm-powerpc/bitops.h
include/asm-s390/bitops.h
include/linux/ext4_fs.h
lib/find_next_bit.c

index 47a6b086eee27fd3ef5dc9a9a04a09db8c5488ee..5c60bfc1a84ddd92e67a20c0bd82ed194654bfdf 100644 (file)
@@ -310,6 +310,8 @@ static inline int constant_fls(int x)
                _find_first_zero_bit_le(p,sz)
 #define ext2_find_next_zero_bit(p,sz,off)      \
                _find_next_zero_bit_le(p,sz,off)
+#define ext2_find_next_bit(p, sz, off) \
+               _find_next_bit_le(p, sz, off)
 
 /*
  * Minix is defined to use little-endian byte ordering.
index 1697404afa052fdec4d1d1528e91fcc012df7408..63cf822431a295b6d6ec2b05e4656eb20675ebaa 100644 (file)
@@ -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_ */
index b9c7e5d2d2ad67631e4318665fe900ac36634097..80e3bf13b2b97ed613c4126413bfbde8766dbda4 100644 (file)
@@ -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>"
index 2976b5d68e96cbb5189cb1a348312939a699dab8..83d1f286230b6da68492a6b64fedaaaad8e5746e 100644 (file)
@@ -410,6 +410,8 @@ static inline int ext2_find_next_zero_bit(const void *vaddr, unsigned size,
        res = ext2_find_first_zero_bit (p, size - 32 * (p - addr));
        return (p - addr) * 32 + res;
 }
+#define ext2_find_next_bit(addr, size, off) \
+       generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
 
 #endif /* __KERNEL__ */
 
index f8dfb7ba2e2573566a58cf97d01942adc48d4785..f43afe1fc3b33940dc1c46178045830f4bf01b44 100644 (file)
@@ -294,6 +294,8 @@ found_middle:
        return result + ffz(__swab32(tmp));
 }
 
+#define ext2_find_next_bit(addr, size, off) \
+       generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
 #include <asm-generic/bitops/minix.h>
 
 #endif /* __KERNEL__ */
index 733b4af7f4f1e7e49269b17856bbf7e47924d7b6..220d9a781ab9c0f64030f15e45543472a950de2f 100644 (file)
@@ -359,6 +359,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) \
@@ -378,6 +380,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) \
index 34d9a6357c38941c70d7b638b2d2f19045291872..dba6fecad0be25353c535ddc1ac3feb64341dbcd 100644 (file)
@@ -772,6 +772,8 @@ static inline int sched_find_first_bit(unsigned long *b)
        test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr)
 #define ext2_test_bit(nr, addr)      \
        test_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr)
+#define ext2_find_next_bit(addr, size, off) \
+       generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
 
 #ifndef __s390x__
 
index 213974f7c5d8c61c42d41ba84084d055284900c8..d0b7ca99b91fd99721eed47aa5282d1d44cc5c66 100644 (file)
@@ -493,6 +493,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
index bda0d71a25144c110df24920b6320470e9c213a8..78ccd73a884188f9e9348df1e4ad6e0e527e24c0 100644 (file)
@@ -178,4 +178,47 @@ found_middle_swap:
 
 EXPORT_SYMBOL(generic_find_next_zero_le_bit);
 
+unsigned long generic_find_next_le_bit(const unsigned long *addr, unsigned
+               long size, unsigned long offset)
+{
+       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 */