public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix filestreams on 32-bit boxes
@ 2007-08-24  0:44 Eric Sandeen
  2007-08-24  1:36 ` Christoph Hellwig
  2007-08-24  1:48 ` David Chinner
  0 siblings, 2 replies; 4+ messages in thread
From: Eric Sandeen @ 2007-08-24  0:44 UTC (permalink / raw)
  To: xfs

xfs_filestream_mount() sets up an mru cache with:

        err = xfs_mru_cache_create(&mp->m_filestream, lifetime, grp_count,
                             (xfs_mru_cache_free_func_t)xfs_fstrm_free_func);

but that cast is causing problems...

typedef void (*xfs_mru_cache_free_func_t)(unsigned long, void*);

but:

void xfs_fstrm_free_func( 
        xfs_ino_t       ino,
        fstrm_item_t    *item)

so on a 32-bit box, it's casting (32, 32) args into (64, 32) and I assume 
it's getting garbage for *item, which subsequently causes an explosion.

With this change the filestreams xfsqa tests don't oops on my 32-bit box.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>

Index: linux-2.6.22.i386/fs/xfs/xfs_filestream.c
===================================================================
--- linux-2.6.22.i386.orig/fs/xfs/xfs_filestream.c
+++ linux-2.6.22.i386/fs/xfs/xfs_filestream.c
@@ -350,7 +350,7 @@ _xfs_filestream_update_ag(
 /* xfs_fstrm_free_func(): callback for freeing cached stream items. */
 void
 xfs_fstrm_free_func(
-	xfs_ino_t	ino,
+	unsigned long	ino,
 	fstrm_item_t	*item)
 {
 	xfs_inode_t	*ip = item->ip;

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

* Re: [PATCH] fix filestreams on 32-bit boxes
  2007-08-24  0:44 [PATCH] fix filestreams on 32-bit boxes Eric Sandeen
@ 2007-08-24  1:36 ` Christoph Hellwig
  2007-08-24  1:48 ` David Chinner
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2007-08-24  1:36 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

On Thu, Aug 23, 2007 at 07:44:55PM -0500, Eric Sandeen wrote:
> xfs_filestream_mount() sets up an mru cache with:
> 
>         err = xfs_mru_cache_create(&mp->m_filestream, lifetime, grp_count,
>                              (xfs_mru_cache_free_func_t)xfs_fstrm_free_func);
> 
> but that cast is causing problems...
> 
> typedef void (*xfs_mru_cache_free_func_t)(unsigned long, void*);
> 
> but:
> 
> void xfs_fstrm_free_func( 
>         xfs_ino_t       ino,
>         fstrm_item_t    *item)
> 
> so on a 32-bit box, it's casting (32, 32) args into (64, 32) and I assume 
> it's getting garbage for *item, which subsequently causes an explosion.
> 
> With this change the filestreams xfsqa tests don't oops on my 32-bit box.

Please also kill that blody cast.  Function pointer casts are wonderful
for hiding bugs like the one you just fixed from compilers, but that's it.

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

* Re: [PATCH] fix filestreams on 32-bit boxes
  2007-08-24  0:44 [PATCH] fix filestreams on 32-bit boxes Eric Sandeen
  2007-08-24  1:36 ` Christoph Hellwig
@ 2007-08-24  1:48 ` David Chinner
  2007-08-24  2:03   ` Eric Sandeen
  1 sibling, 1 reply; 4+ messages in thread
From: David Chinner @ 2007-08-24  1:48 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

On Thu, Aug 23, 2007 at 07:44:55PM -0500, Eric Sandeen wrote:
> xfs_filestream_mount() sets up an mru cache with:
> 
>         err = xfs_mru_cache_create(&mp->m_filestream, lifetime, grp_count,
>                              (xfs_mru_cache_free_func_t)xfs_fstrm_free_func);
> 
> but that cast is causing problems...
> 
> typedef void (*xfs_mru_cache_free_func_t)(unsigned long, void*);
> 
> but:
> 
> void xfs_fstrm_free_func( 
>         xfs_ino_t       ino,
>         fstrm_item_t    *item)
> 
> so on a 32-bit box, it's casting (32, 32) args into (64, 32) and I assume 
> it's getting garbage for *item, which subsequently causes an explosion.
> 
> With this change the filestreams xfsqa tests don't oops on my 32-bit box.
> 
> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
> 
> Index: linux-2.6.22.i386/fs/xfs/xfs_filestream.c
> ===================================================================
> --- linux-2.6.22.i386.orig/fs/xfs/xfs_filestream.c
> +++ linux-2.6.22.i386/fs/xfs/xfs_filestream.c
> @@ -350,7 +350,7 @@ _xfs_filestream_update_ag(
>  /* xfs_fstrm_free_func(): callback for freeing cached stream items. */
>  void
>  xfs_fstrm_free_func(
> -	xfs_ino_t	ino,
> +	unsigned long	ino,
>  	fstrm_item_t	*item)
>  {
>  	xfs_inode_t	*ip = item->ip;

hmmm - probably should make xfs_fstrm_free_func follow the correct prototype
and convert the item into an opaque void * as well. Then we can remove the
cast that hid this problem in xfs_filestream_mount()....

Nice catch, though, Eric.

Cheers,

Dave.
-- 
Dave Chinner
Principal Engineer
SGI Australian Software Group

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

* Re: [PATCH] fix filestreams on 32-bit boxes
  2007-08-24  1:48 ` David Chinner
@ 2007-08-24  2:03   ` Eric Sandeen
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Sandeen @ 2007-08-24  2:03 UTC (permalink / raw)
  To: David Chinner; +Cc: xfs

David Chinner wrote:

>
> hmmm - probably should make xfs_fstrm_free_func follow the correct prototype
> and convert the item into an opaque void * as well. Then we can remove the
> cast that hid this problem in xfs_filestream_mount()....
>
> Nice catch, though, Eric.
>
> Cheers,
>
> Dave.

Yep, I thought of removing the cast on the way home, as did Christoph, wherever he is :)

---------------------

xfs_filestream_mount() sets up an mru cache with:

        err = xfs_mru_cache_create(&mp->m_filestream, lifetime, grp_count,
                             (xfs_mru_cache_free_func_t)xfs_fstrm_free_func);

but that cast is causing problems...

typedef void (*xfs_mru_cache_free_func_t)(unsigned long, void*);

but:

void xfs_fstrm_free_func( 
        xfs_ino_t       ino,
        fstrm_item_t    *item)

so on a 32-bit box, it's casting (32, 32) args into (64, 32) and I assume 
it's getting garbage for *item, which subsequently causes an explosion.

With this change the filestreams xfsqa tests don't oops on my 32-bit box.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>

Index: linux-2.6.22.i386/fs/xfs/xfs_filestream.c
===================================================================
--- linux-2.6.22.i386.orig/fs/xfs/xfs_filestream.c
+++ linux-2.6.22.i386/fs/xfs/xfs_filestream.c
@@ -350,9 +350,10 @@ _xfs_filestream_update_ag(
 /* xfs_fstrm_free_func(): callback for freeing cached stream items. */
 void
 xfs_fstrm_free_func(
-	xfs_ino_t	ino,
-	fstrm_item_t	*item)
+	unsigned long	ino,
+	void		*data)
 {
+	fstrm_item_t	*item  = (fstrm_item_t *)data;
 	xfs_inode_t	*ip = item->ip;
 	int ref;
 
@@ -438,7 +439,7 @@ xfs_filestream_mount(
 	grp_count = 10;
 
 	err = xfs_mru_cache_create(&mp->m_filestream, lifetime, grp_count,
-	                     (xfs_mru_cache_free_func_t)xfs_fstrm_free_func);
+	                     xfs_fstrm_free_func);
 
 	return err;
 }

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

end of thread, other threads:[~2007-08-24  2:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-24  0:44 [PATCH] fix filestreams on 32-bit boxes Eric Sandeen
2007-08-24  1:36 ` Christoph Hellwig
2007-08-24  1:48 ` David Chinner
2007-08-24  2:03   ` Eric Sandeen

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