public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC: 2.6 patch] ext2: make ext2_count_free a static inline
@ 2005-04-22 23:51 Adrian Bunk
  0 siblings, 0 replies; 5+ messages in thread
From: Adrian Bunk @ 2005-04-22 23:51 UTC (permalink / raw)
  To: ext2-devel; +Cc: linux-kernel

ext2_count_free is a small function that is only used
#ifdef EXT2FS_DEBUG.

We could offer the function itself only #ifdef EXT2FS_DEBUG, but what 
about this patch to change ot to a static inline?

Signed-off-by: Adrian Bunk <bunk@stusta.de>

---

 fs/ext2/Makefile |    2 +-
 fs/ext2/bitmap.c |   25 -------------------------
 fs/ext2/ext2.h   |   18 +++++++++++++++++-
 3 files changed, 18 insertions(+), 27 deletions(-)

--- linux-2.6.12-rc2-mm3-full/fs/ext2/ext2.h.old	2005-04-20 23:08:52.000000000 +0200
+++ linux-2.6.12-rc2-mm3-full/fs/ext2/ext2.h	2005-04-20 23:14:21.000000000 +0200
@@ -1,5 +1,6 @@
 #include <linux/fs.h>
 #include <linux/ext2_fs.h>
+#include <linux/buffer_head.h>
 
 /*
  * second extended file system inode data in memory
@@ -79,6 +80,22 @@
 	return container_of(inode, struct ext2_inode_info, vfs_inode);
 }
 
+static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
+
+static inline unsigned long ext2_count_free (struct buffer_head * map,
+					     unsigned int numchars)
+{
+	unsigned int i;
+	unsigned long sum = 0;
+	
+	if (!map) 
+		return (0);
+	for (i = 0; i < numchars; i++)
+		sum += nibblemap[map->b_data[i] & 0xf] +
+			nibblemap[(map->b_data[i] >> 4) & 0xf];
+	return (sum);
+}
+
 /* balloc.c */
 extern int ext2_bg_has_super(struct super_block *sb, int group);
 extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
@@ -111,7 +128,6 @@
 extern void ext2_free_inode (struct inode *);
 extern unsigned long ext2_count_free_inodes (struct super_block *);
 extern void ext2_check_inodes_bitmap (struct super_block *);
-extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
 
 /* inode.c */
 extern void ext2_read_inode (struct inode *);
--- linux-2.6.12-rc2-mm3-full/fs/ext2/Makefile.old	2005-04-20 23:14:35.000000000 +0200
+++ linux-2.6.12-rc2-mm3-full/fs/ext2/Makefile	2005-04-20 23:14:45.000000000 +0200
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_EXT2_FS) += ext2.o
 
-ext2-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
+ext2-y := balloc.o dir.o file.o fsync.o ialloc.o inode.o \
 	  ioctl.o namei.o super.o symlink.o
 
 ext2-$(CONFIG_EXT2_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o
--- linux-2.6.12-rc2-mm3-full/fs/ext2/bitmap.c	2005-03-02 08:38:08.000000000 +0100
+++ /dev/null	2005-03-19 22:42:59.000000000 +0100
@@ -1,25 +0,0 @@
-/*
- *  linux/fs/ext2/bitmap.c
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- */
-
-#include <linux/buffer_head.h>
-
-static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
-
-unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
-{
-	unsigned int i;
-	unsigned long sum = 0;
-	
-	if (!map) 
-		return (0);
-	for (i = 0; i < numchars; i++)
-		sum += nibblemap[map->b_data[i] & 0xf] +
-			nibblemap[(map->b_data[i] >> 4) & 0xf];
-	return (sum);
-}


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

* [RFC: 2.6 patch] ext2: make ext2_count_free a static inline
@ 2005-04-30 20:07 Adrian Bunk
  0 siblings, 0 replies; 5+ messages in thread
From: Adrian Bunk @ 2005-04-30 20:07 UTC (permalink / raw)
  To: Andrew Morton; +Cc: ext2-devel, linux-kernel

ext2_count_free is a small function that is only used
#ifdef EXT2FS_DEBUG.

We could offer the function itself only #ifdef EXT2FS_DEBUG, but what 
about this patch to change ot to a static inline?

Signed-off-by: Adrian Bunk <bunk@stusta.de>

---

This patch was already sent on:
- 23 Apr 2005

 fs/ext2/Makefile |    2 +-
 fs/ext2/bitmap.c |   25 -------------------------
 fs/ext2/ext2.h   |   18 +++++++++++++++++-
 3 files changed, 18 insertions(+), 27 deletions(-)

--- linux-2.6.12-rc2-mm3-full/fs/ext2/ext2.h.old	2005-04-20 23:08:52.000000000 +0200
+++ linux-2.6.12-rc2-mm3-full/fs/ext2/ext2.h	2005-04-20 23:14:21.000000000 +0200
@@ -1,5 +1,6 @@
 #include <linux/fs.h>
 #include <linux/ext2_fs.h>
+#include <linux/buffer_head.h>
 
 /*
  * second extended file system inode data in memory
@@ -79,6 +80,22 @@
 	return container_of(inode, struct ext2_inode_info, vfs_inode);
 }
 
+static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
+
+static inline unsigned long ext2_count_free (struct buffer_head * map,
+					     unsigned int numchars)
+{
+	unsigned int i;
+	unsigned long sum = 0;
+	
+	if (!map) 
+		return (0);
+	for (i = 0; i < numchars; i++)
+		sum += nibblemap[map->b_data[i] & 0xf] +
+			nibblemap[(map->b_data[i] >> 4) & 0xf];
+	return (sum);
+}
+
 /* balloc.c */
 extern int ext2_bg_has_super(struct super_block *sb, int group);
 extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
@@ -111,7 +128,6 @@
 extern void ext2_free_inode (struct inode *);
 extern unsigned long ext2_count_free_inodes (struct super_block *);
 extern void ext2_check_inodes_bitmap (struct super_block *);
-extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
 
 /* inode.c */
 extern void ext2_read_inode (struct inode *);
--- linux-2.6.12-rc2-mm3-full/fs/ext2/Makefile.old	2005-04-20 23:14:35.000000000 +0200
+++ linux-2.6.12-rc2-mm3-full/fs/ext2/Makefile	2005-04-20 23:14:45.000000000 +0200
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_EXT2_FS) += ext2.o
 
-ext2-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
+ext2-y := balloc.o dir.o file.o fsync.o ialloc.o inode.o \
 	  ioctl.o namei.o super.o symlink.o
 
 ext2-$(CONFIG_EXT2_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o
--- linux-2.6.12-rc2-mm3-full/fs/ext2/bitmap.c	2005-03-02 08:38:08.000000000 +0100
+++ /dev/null	2005-03-19 22:42:59.000000000 +0100
@@ -1,25 +0,0 @@
-/*
- *  linux/fs/ext2/bitmap.c
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- */
-
-#include <linux/buffer_head.h>
-
-static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
-
-unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
-{
-	unsigned int i;
-	unsigned long sum = 0;
-	
-	if (!map) 
-		return (0);
-	for (i = 0; i < numchars; i++)
-		sum += nibblemap[map->b_data[i] & 0xf] +
-			nibblemap[(map->b_data[i] >> 4) & 0xf];
-	return (sum);
-}



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

* [RFC: 2.6 patch] ext2: make ext2_count_free a static inline
@ 2005-05-13  0:47 Adrian Bunk
  2005-05-14  5:40 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Adrian Bunk @ 2005-05-13  0:47 UTC (permalink / raw)
  To: Andrew Morton; +Cc: ext2-devel, linux-kernel

ext2_count_free is a small function that is only used
#ifdef EXT2FS_DEBUG.

We could offer the function itself only #ifdef EXT2FS_DEBUG, but what 
about this patch to change ot to a static inline?

Signed-off-by: Adrian Bunk <bunk@stusta.de>

---

This patch was already sent on:
- 30 Apr 2005
- 23 Apr 2005

 fs/ext2/Makefile |    2 +-
 fs/ext2/bitmap.c |   25 -------------------------
 fs/ext2/ext2.h   |   18 +++++++++++++++++-
 3 files changed, 18 insertions(+), 27 deletions(-)

--- linux-2.6.12-rc2-mm3-full/fs/ext2/ext2.h.old	2005-04-20 23:08:52.000000000 +0200
+++ linux-2.6.12-rc2-mm3-full/fs/ext2/ext2.h	2005-04-20 23:14:21.000000000 +0200
@@ -1,5 +1,6 @@
 #include <linux/fs.h>
 #include <linux/ext2_fs.h>
+#include <linux/buffer_head.h>
 
 /*
  * second extended file system inode data in memory
@@ -79,6 +80,22 @@
 	return container_of(inode, struct ext2_inode_info, vfs_inode);
 }
 
+static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
+
+static inline unsigned long ext2_count_free (struct buffer_head * map,
+					     unsigned int numchars)
+{
+	unsigned int i;
+	unsigned long sum = 0;
+	
+	if (!map) 
+		return (0);
+	for (i = 0; i < numchars; i++)
+		sum += nibblemap[map->b_data[i] & 0xf] +
+			nibblemap[(map->b_data[i] >> 4) & 0xf];
+	return (sum);
+}
+
 /* balloc.c */
 extern int ext2_bg_has_super(struct super_block *sb, int group);
 extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
@@ -111,7 +128,6 @@
 extern void ext2_free_inode (struct inode *);
 extern unsigned long ext2_count_free_inodes (struct super_block *);
 extern void ext2_check_inodes_bitmap (struct super_block *);
-extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
 
 /* inode.c */
 extern void ext2_read_inode (struct inode *);
--- linux-2.6.12-rc2-mm3-full/fs/ext2/Makefile.old	2005-04-20 23:14:35.000000000 +0200
+++ linux-2.6.12-rc2-mm3-full/fs/ext2/Makefile	2005-04-20 23:14:45.000000000 +0200
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_EXT2_FS) += ext2.o
 
-ext2-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
+ext2-y := balloc.o dir.o file.o fsync.o ialloc.o inode.o \
 	  ioctl.o namei.o super.o symlink.o
 
 ext2-$(CONFIG_EXT2_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o
--- linux-2.6.12-rc2-mm3-full/fs/ext2/bitmap.c	2005-03-02 08:38:08.000000000 +0100
+++ /dev/null	2005-03-19 22:42:59.000000000 +0100
@@ -1,25 +0,0 @@
-/*
- *  linux/fs/ext2/bitmap.c
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- */
-
-#include <linux/buffer_head.h>
-
-static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
-
-unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
-{
-	unsigned int i;
-	unsigned long sum = 0;
-	
-	if (!map) 
-		return (0);
-	for (i = 0; i < numchars; i++)
-		sum += nibblemap[map->b_data[i] & 0xf] +
-			nibblemap[(map->b_data[i] >> 4) & 0xf];
-	return (sum);
-}



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

* Re: [RFC: 2.6 patch] ext2: make ext2_count_free a static inline
  2005-05-13  0:47 Adrian Bunk
@ 2005-05-14  5:40 ` Andrew Morton
  2005-05-16 18:51   ` Adrian Bunk
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2005-05-14  5:40 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: ext2-devel, linux-kernel

Adrian Bunk <bunk@stusta.de> wrote:
>
>  --- linux-2.6.12-rc2-mm3-full/fs/ext2/ext2.h.old	2005-04-20 23:08:52.000000000 +0200
>  +++ linux-2.6.12-rc2-mm3-full/fs/ext2/ext2.h	2005-04-20 23:14:21.000000000 +0200
>  @@ -1,5 +1,6 @@
>   #include <linux/fs.h>
>   #include <linux/ext2_fs.h>
>  +#include <linux/buffer_head.h>
>   
>   /*
>    * second extended file system inode data in memory
>  @@ -79,6 +80,22 @@
>   	return container_of(inode, struct ext2_inode_info, vfs_inode);
>   }
>   
>  +static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
>  +

This will cause a copy of `nibblemap' to be included in each compilation
unit which uses ext2.h.  Unless the compiler is sufficiently smart to elide
it, which it might be.  But then it might be sufficiently smart to generate
a "you're not usig this" warning too.

If it's only needed for EXT2_DEBUG then I'd be inclined to move it into one
of the other .c files, inside EXT2_DEBUG.  Or just leave it as-is.

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

* Re: [RFC: 2.6 patch] ext2: make ext2_count_free a static inline
  2005-05-14  5:40 ` Andrew Morton
@ 2005-05-16 18:51   ` Adrian Bunk
  0 siblings, 0 replies; 5+ messages in thread
From: Adrian Bunk @ 2005-05-16 18:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: ext2-devel, linux-kernel

On Fri, May 13, 2005 at 10:40:04PM -0700, Andrew Morton wrote:
> Adrian Bunk <bunk@stusta.de> wrote:
> >
> >  --- linux-2.6.12-rc2-mm3-full/fs/ext2/ext2.h.old	2005-04-20 23:08:52.000000000 +0200
> >  +++ linux-2.6.12-rc2-mm3-full/fs/ext2/ext2.h	2005-04-20 23:14:21.000000000 +0200
> >  @@ -1,5 +1,6 @@
> >   #include <linux/fs.h>
> >   #include <linux/ext2_fs.h>
> >  +#include <linux/buffer_head.h>
> >   
> >   /*
> >    * second extended file system inode data in memory
> >  @@ -79,6 +80,22 @@
> >   	return container_of(inode, struct ext2_inode_info, vfs_inode);
> >   }
> >   
> >  +static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
> >  +
> 
> This will cause a copy of `nibblemap' to be included in each compilation
> unit which uses ext2.h.  Unless the compiler is sufficiently smart to elide
> it, which it might be.  But then it might be sufficiently smart to generate
> a "you're not usig this" warning too.

gcc never generates a warning because it's used in the "static inline" 
function ext2_count_free (whether this function is used or not doesn't 
matter).

But I get your point.

> If it's only needed for EXT2_DEBUG then I'd be inclined to move it into one
> of the other .c files, inside EXT2_DEBUG.  Or just leave it as-is.

Sounds good.

Any suggestion into which file it should be moved?

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


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

end of thread, other threads:[~2005-05-16 18:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-30 20:07 [RFC: 2.6 patch] ext2: make ext2_count_free a static inline Adrian Bunk
  -- strict thread matches above, loose matches on Subject: below --
2005-05-13  0:47 Adrian Bunk
2005-05-14  5:40 ` Andrew Morton
2005-05-16 18:51   ` Adrian Bunk
2005-04-22 23:51 Adrian Bunk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox