LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] Introduce ext4_find_next_bit
@ 2007-09-21  5:25 Aneesh Kumar K.V
  2007-09-21  5:25 ` [PATCH] ext4: Fix spare warnings Aneesh Kumar K.V
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Aneesh Kumar K.V @ 2007-09-21  5:25 UTC (permalink / raw)
  To: akpm; +Cc: linux-ext4, linux-kernel, Aneesh Kumar K.V

Also add generic_find_next_le_bit

This gets used by the ext4 multi block allocator patches.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 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(-)

diff --git a/include/asm-generic/bitops/ext2-non-atomic.h b/include/asm-generic/bitops/ext2-non-atomic.h
index 1697404..63cf822 100644
--- a/include/asm-generic/bitops/ext2-non-atomic.h
+++ b/include/asm-generic/bitops/ext2-non-atomic.h
@@ -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_ */
diff --git a/include/asm-generic/bitops/le.h b/include/asm-generic/bitops/le.h
index b9c7e5d..80e3bf1 100644
--- a/include/asm-generic/bitops/le.h
+++ b/include/asm-generic/bitops/le.h
@@ -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>"
diff --git a/include/asm-powerpc/bitops.h b/include/asm-powerpc/bitops.h
index 8144a27..60652a3 100644
--- a/include/asm-powerpc/bitops.h
+++ b/include/asm-powerpc/bitops.h
@@ -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) \
diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h
index cdee7aa..c7b9bb2 100644
--- a/include/linux/ext4_fs.h
+++ b/include/linux/ext4_fs.h
@@ -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
diff --git a/lib/find_next_bit.c b/lib/find_next_bit.c
index bda0d71..0306c04 100644
--- a/lib/find_next_bit.c
+++ b/lib/find_next_bit.c
@@ -178,4 +178,48 @@ 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 */
-- 
1.5.3.1.91.gd3392-dirty


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] ext4: Fix spare warnings
  2007-09-21  5:25 [PATCH] Introduce ext4_find_next_bit Aneesh Kumar K.V
@ 2007-09-21  5:25 ` Aneesh Kumar K.V
  2007-09-21  6:02   ` Balbir Singh
  2007-09-21  6:43 ` [PATCH] Introduce ext4_find_next_bit Balbir Singh
  2007-11-13  7:59 ` Andrew Morton
  2 siblings, 1 reply; 9+ messages in thread
From: Aneesh Kumar K.V @ 2007-09-21  5:25 UTC (permalink / raw)
  To: akpm; +Cc: linux-ext4, linux-kernel, Aneesh Kumar K.V

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 fs/ext4/inode.c         |    6 ++++--
 include/linux/ext4_fs.h |   16 ++++++++--------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index a4848e0..307e240 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -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);
 				}
 			}
 		}
diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h
index c7b9bb2..ab7edaa 100644
--- a/include/linux/ext4_fs.h
+++ b/include/linux/ext4_fs.h
@@ -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 */
 };
 
-- 
1.5.3.1.91.gd3392-dirty


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ext4: Fix spare warnings
  2007-09-21  5:25 ` [PATCH] ext4: Fix spare warnings Aneesh Kumar K.V
@ 2007-09-21  6:02   ` Balbir Singh
  2007-09-21  9:04     ` Aneesh Kumar K.V
  0 siblings, 1 reply; 9+ messages in thread
From: Balbir Singh @ 2007-09-21  6:02 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: akpm, linux-ext4, linux-kernel

Aneesh,

The subject is a bit confusing,  I presume you mean sparse warnings

Balbir

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Introduce ext4_find_next_bit
  2007-09-21  5:25 [PATCH] Introduce ext4_find_next_bit Aneesh Kumar K.V
  2007-09-21  5:25 ` [PATCH] ext4: Fix spare warnings Aneesh Kumar K.V
@ 2007-09-21  6:43 ` Balbir Singh
  2007-09-21  9:08   ` Aneesh Kumar K.V
  2007-11-13  7:59 ` Andrew Morton
  2 siblings, 1 reply; 9+ messages in thread
From: Balbir Singh @ 2007-09-21  6:43 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: akpm, linux-ext4, linux-kernel

Aneesh Kumar K.V wrote:
> Also add generic_find_next_le_bit
> 
> This 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?

> 
> +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.

> +	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 */


-- 
	Warm Regards,
	Balbir Singh
	Linux Technology Center
	IBM, ISTL

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ext4: Fix spare warnings
  2007-09-21  6:02   ` Balbir Singh
@ 2007-09-21  9:04     ` Aneesh Kumar K.V
  0 siblings, 0 replies; 9+ messages in thread
From: Aneesh Kumar K.V @ 2007-09-21  9:04 UTC (permalink / raw)
  To: Balbir Singh; +Cc: akpm, linux-ext4, linux-kernel



Balbir Singh wrote:
> 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Introduce ext4_find_next_bit
  2007-09-21  6:43 ` [PATCH] Introduce ext4_find_next_bit Balbir Singh
@ 2007-09-21  9:08   ` Aneesh Kumar K.V
  0 siblings, 0 replies; 9+ messages in thread
From: Aneesh Kumar K.V @ 2007-09-21  9:08 UTC (permalink / raw)
  To: balbir; +Cc: akpm, linux-ext4, linux-kernel



Balbir Singh wrote:
> Aneesh Kumar K.V wrote:
>> Also add generic_find_next_le_bit
>>
>> This 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Introduce ext4_find_next_bit
  2007-09-21  5:25 [PATCH] Introduce ext4_find_next_bit Aneesh Kumar K.V
  2007-09-21  5:25 ` [PATCH] ext4: Fix spare warnings Aneesh Kumar K.V
  2007-09-21  6:43 ` [PATCH] Introduce ext4_find_next_bit Balbir Singh
@ 2007-11-13  7:59 ` Andrew Morton
  2007-11-13 19:11   ` Aneesh Kumar K.V
  2 siblings, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2007-11-13  7:59 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: linux-ext4, linux-kernel

On Fri, 21 Sep 2007 10:55:05 +0530 "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:

> Also add generic_find_next_le_bit
> 
> This 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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Introduce ext4_find_next_bit
  2007-11-13  7:59 ` Andrew Morton
@ 2007-11-13 19:11   ` Aneesh Kumar K.V
  2007-11-13 20:43     ` Andrew Morton
  0 siblings, 1 reply; 9+ messages in thread
From: Aneesh Kumar K.V @ 2007-11-13 19:11 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-ext4, linux-kernel



Andrew Morton wrote:
> On Fri, 21 Sep 2007 10:55:05 +0530 "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> 
>> Also add generic_find_next_le_bit
>>
>> This 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)?
> 

I was following the coding style used for rest of the APIs
like ext4_set_bit.


> 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

> 
> 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 mb
md/bitmap.c +799
md/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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Introduce ext4_find_next_bit
  2007-11-13 19:11   ` Aneesh Kumar K.V
@ 2007-11-13 20:43     ` Andrew Morton
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2007-11-13 20:43 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: linux-ext4, linux-kernel

On Wed, 14 Nov 2007 00:41:03 +0530 "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:

> 
> 
> Andrew Morton wrote:
> > On Fri, 21 Sep 2007 10:55:05 +0530 "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> > 
> >> Also add generic_find_next_le_bit
> >>
> >> This 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)?
> > 
> 
> 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.

> 
> > 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
> 
> > 
> > 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 mb
> md/bitmap.c +799
> md/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 ? 
> 

Yes, that's a separate work, thanks.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-11-13 20:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-21  5:25 [PATCH] Introduce ext4_find_next_bit Aneesh Kumar K.V
2007-09-21  5:25 ` [PATCH] ext4: Fix spare warnings Aneesh Kumar K.V
2007-09-21  6:02   ` Balbir Singh
2007-09-21  9:04     ` Aneesh Kumar K.V
2007-09-21  6:43 ` [PATCH] Introduce ext4_find_next_bit Balbir Singh
2007-09-21  9:08   ` Aneesh Kumar K.V
2007-11-13  7:59 ` Andrew Morton
2007-11-13 19:11   ` Aneesh Kumar K.V
2007-11-13 20:43     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).