2006-03-20 21:09:46

by Jan Engelhardt

[permalink] [raw]
Subject: Parenthesize macros in xfs

Hello xfs list,


while browsing through the xfs/linux source, I noticed that many macros do
not do proper bracing. I have started to cook up a patch, but would like
feedback first before I continue for nothing.
It goes like this:

diff --fast -dpru linux-2.6.16~/fs/xfs/xfs_acl.h linux-2.6.16/fs/xfs/xfs_acl.h
--- linux-2.6.16~/fs/xfs/xfs_acl.h 2006-03-20 06:53:29.000000000 +0100
+++ linux-2.6.16/fs/xfs/xfs_acl.h 2006-03-20 21:23:02.235418000 +0100
@@ -55,7 +55,7 @@ struct xfs_inode;

extern struct kmem_zone *xfs_acl_zone;
#define xfs_acl_zone_init(zone, name) \
- (zone) = kmem_zone_init(sizeof(xfs_acl_t), name)
+ (zone) = kmem_zone_init(sizeof(xfs_acl_t), (name))
#define xfs_acl_zone_destroy(zone) kmem_cache_destroy(zone)

extern int xfs_acl_inherit(struct vnode *, struct vattr *, xfs_acl_t *);



Jan Engelhardt
--
| Software Engineer and Linux/Unix Network Administrator


2006-03-20 21:23:50

by Nathan Scott

[permalink] [raw]
Subject: Re: Parenthesize macros in xfs

On Mon, Mar 20, 2006 at 10:09:31PM +0100, Jan Engelhardt wrote:
> Hello xfs list,

Hi Jan,

> while browsing through the xfs/linux source, I noticed that many macros do
> not do proper bracing. I have started to cook up a patch, but would like
> feedback first before I continue for nothing.
> It goes like this:
> ...

That looks fine. Please be sure to work on the -mm tree or on
CVS on oss.sgi.com, so as to reduce your level of patch conflict.

thanks.

--
Nathan

2006-03-20 21:39:51

by Jan Engelhardt

[permalink] [raw]
Subject: Re: Parenthesize macros in xfs

>> Hello xfs list,
>
>Hi Jan,
>
>> while browsing through the xfs/linux source, I noticed that many macros do
>> not do proper bracing. I have started to cook up a patch, but would like
>> feedback first before I continue for nothing.
>> It goes like this:
>> ...
>
>That looks fine. Please be sure to work on the -mm tree or on
>CVS on oss.sgi.com, so as to reduce your level of patch conflict.
>

Hm, would not it even be better to make them 'static inline' functions?


Jan Engelhardt
--
| Software Engineer and Linux/Unix Network Administrator

2006-03-20 21:46:41

by Nathan Scott

[permalink] [raw]
Subject: Re: Parenthesize macros in xfs

Hi Jan,

On Mon, Mar 20, 2006 at 10:39:45PM +0100, Jan Engelhardt wrote:
> >> while browsing through the xfs/linux source, I noticed that many macros do
> >> not do proper bracing. I have started to cook up a patch, but would like
> >> feedback first before I continue for nothing.
> >> It goes like this:
> >> ...
> >
> >That looks fine. Please be sure to work on the -mm tree or on
> >CVS on oss.sgi.com, so as to reduce your level of patch conflict.
> >
>
> Hm, would not it even be better to make them 'static inline' functions?

Probably, I guess I'd want to see how invasive the patch becomes...?
I really dislike those _ACL macros (around that example you gave, that
could do with a cleanup all of its own - switching to xfs_acl_ maybe).
Also watch for macros that modify their parameters, I got burned by
doing an inline conversion a few releases back on just such a beast..

cheers.

--
Nathan

2006-03-25 21:35:20

by Jan Engelhardt

[permalink] [raw]
Subject: Re: Parenthesize macros in xfs

>> >> while browsing through the xfs/linux source, I noticed that many macros do
>> >> not do proper bracing. I have started to cook up a patch, but would like
>> >> feedback first before I continue for nothing.
>> >> It goes like this:
>> >> ...
>> >
>> >That looks fine. Please be sure to work on the -mm tree or on
>> >CVS on oss.sgi.com, so as to reduce your level of patch conflict.
>>
>> Hm, would not it even be better to make them 'static inline' functions?
>
>Probably, I guess I'd want to see how invasive the patch becomes...?
>I really dislike those _ACL macros (around that example you gave, that
>could do with a cleanup all of its own - switching to xfs_acl_ maybe).
>Also watch for macros that modify their parameters, I got burned by
>doing an inline conversion a few releases back on just such a beast..
>

To implement static inline, it requires that header files be corrected
first so that they could 'compile on their own'. Shall I post a patch for
that too?

Here is the first patch in the series of 'fix most things that annoyed me'.

- - - - - - - - - -

Multiple instruction #defines should be wrapped into do{}while(0).

Signed-off-by: Jan Engelhardt <[email protected]>
Compile-tested.

diff -dpru xfs-cvs/dmapi/xfs_dm.c xfs-mod/dmapi/xfs_dm.c
--- xfs-cvs/dmapi/xfs_dm.c 2006-03-17 15:28:04.000000000 +0100
+++ xfs-mod/dmapi/xfs_dm.c 2006-03-25 21:23:45.035287000 +0100
@@ -52,9 +52,10 @@

#define MAXNAMLEN MAXNAMELEN

-#define XFS_BHV_LOOKUP(vp, xbdp) \
+#define XFS_BHV_LOOKUP(vp, xbdp) do { \
xbdp = vn_bhv_lookup(VN_BHV_HEAD(vp), &xfs_vnodeops); \
- ASSERT(xbdp);
+ ASSERT(xbdp); \
+ } while(0)

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
#define MIN_DIO_SIZE(mp) ((mp)->m_sb.sb_sectsize)
@@ -156,7 +157,7 @@ STATIC dm_size_t dm_min_dio_xfer = 0; /
#define DM_STAT_ALIGN (sizeof(__uint64_t))

/* DMAPI's E2BIG == EA's ERANGE */
-#define DM_EA_XLATE_ERR(err) { if (err == ERANGE) err = E2BIG; }
+#define DM_EA_XLATE_ERR(err) do { if (err == ERANGE) err = E2BIG; } while(0)

/*
* xfs_dm_send_data_event()
diff -dpru xfs-mod-01/support/qsort.c xfs-mod-02/support/qsort.c
--- xfs-mod-01/support/qsort.c 2005-09-23 05:51:28.000000000 +0200
+++ xfs-mod-02/support/qsort.c 2006-03-25 22:20:37.055287000 +0100
@@ -55,13 +55,14 @@ swapfunc(char *a, char *b, int n, int sw
swapcode(char, a, b, n)
}

-#define swap(a, b) \
+#define swap(a, b) do { \
if (swaptype == 0) { \
long t = *(long *)(a); \
*(long *)(a) = *(long *)(b); \
*(long *)(b) = t; \
} else \
- swapfunc(a, b, es, swaptype)
+ swapfunc(a, b, es, swaptype) \
+} while(0)

#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)

diff -dpru xfs-cvs/xfs_arch.h xfs-mod/xfs_arch.h
--- xfs-cvs/xfs_arch.h 2006-01-12 03:43:50.000000000 +0100
+++ xfs-mod/xfs_arch.h 2006-03-25 21:37:04.775287000 +0100
@@ -161,14 +161,14 @@
*/

/* does not return a value */
-#define INT_XLATE(buf,mem,dir,arch) {\
+#define INT_XLATE(buf,mem,dir,arch) do { \
ASSERT(dir); \
if (dir>0) { \
(mem)=INT_GET(buf, arch); \
} else { \
INT_SET(buf, arch, mem); \
} \
-}
+} while(0)

static inline void be16_add(__be16 *a, __s16 b)
{
diff -dpru xfs-cvs/xfs_fs.h xfs-mod/xfs_fs.h
--- xfs-cvs/xfs_fs.h 2005-12-02 03:48:45.000000000 +0100
+++ xfs-mod/xfs_fs.h 2006-03-25 21:37:22.325287000 +0100
@@ -122,12 +122,13 @@ struct getbmapx {
#define BMV_OF_PREALLOC 0x1 /* segment = unwritten pre-allocation */

/* Convert getbmap <-> getbmapx - move fields from p1 to p2. */
-#define GETBMAP_CONVERT(p1,p2) { \
+#define GETBMAP_CONVERT(p1,p2) do { \
p2.bmv_offset = p1.bmv_offset; \
p2.bmv_block = p1.bmv_block; \
p2.bmv_length = p1.bmv_length; \
p2.bmv_count = p1.bmv_count; \
- p2.bmv_entries = p1.bmv_entries; }
+ p2.bmv_entries = p1.bmv_entries; \
+ } while(0)


/*
diff -dpru xfs-cvs/xfs_vfsops.c xfs-mod/xfs_vfsops.c
--- xfs-cvs/xfs_vfsops.c 2006-03-25 21:10:18.925287000 +0100
+++ xfs-mod/xfs_vfsops.c 2006-03-25 21:37:36.765287000 +0100
@@ -949,7 +949,7 @@ xfs_sync_inodes(
* must be locked when this is called. After the call the list will no
* longer be locked.
*/
-#define IPOINTER_INSERT(ip, mp) { \
+#define IPOINTER_INSERT(ip, mp) do { \
ASSERT(ipointer_in == B_FALSE); \
ipointer->ip_mnext = ip->i_mnext; \
ipointer->ip_mprev = ip; \
@@ -959,14 +959,14 @@ xfs_sync_inodes(
XFS_MOUNT_IUNLOCK(mp); \
mount_locked = B_FALSE; \
IPOINTER_SET; \
- }
+ } while(0)

/* Remove the marker from the inode list. If the marker was the only item
* in the list then there are no remaining inodes and we should zero out
* the whole list. If we are the current head of the list then move the head
* past us.
*/
-#define IPOINTER_REMOVE(ip, mp) { \
+#define IPOINTER_REMOVE(ip, mp) do { \
ASSERT(ipointer_in == B_TRUE); \
if (ipointer->ip_mnext != (xfs_inode_t *)ipointer) { \
ip = ipointer->ip_mnext; \
@@ -981,7 +981,7 @@ xfs_sync_inodes(
ip = NULL; \
} \
IPOINTER_CLR; \
- }
+ } while(0)

#define XFS_PREEMPT_MASK 0x7f

diff -dpru xfs-cvs/xfs_vnodeops.c xfs-mod/xfs_vnodeops.c
--- xfs-cvs/xfs_vnodeops.c 2006-03-25 21:10:19.085287000 +0100
+++ xfs-mod/xfs_vnodeops.c 2006-03-25 21:37:48.405287000 +0100
@@ -2307,7 +2307,7 @@ again:
}

#ifdef DEBUG
-#define REMOVE_DEBUG_TRACE(x) {remove_which_error_return = (x);}
+#define REMOVE_DEBUG_TRACE(x) do { remove_which_error_return = (x); } while(0)
int remove_which_error_return = 0;
#else /* ! DEBUG */
#define REMOVE_DEBUG_TRACE(x)
diff -dpru xfs-cvs/xfsidbg.c xfs-mod/xfsidbg.c
--- xfs-cvs/xfsidbg.c 2006-03-25 21:10:19.105287000 +0100
+++ xfs-mod/xfsidbg.c 2006-03-25 21:37:58.325287000 +0100
@@ -7354,7 +7354,7 @@ xfsidbg_xqm_dquot(xfs_dquot_t *dqp)


#define XQMIDBG_LIST_PRINT(l, NXT) \
-{ \
+do { \
xfs_dquot_t *dqp;\
int i = 0; \
kdb_printf("[#%d dquots]\n", (int) (l)->qh_nelems); \
@@ -7367,7 +7367,7 @@ xfsidbg_xqm_dquot(xfs_dquot_t *dqp)
(int) be64_to_cpu(dqp->q_core.d_icount), \
(int) dqp->q_nrefs); }\
kdb_printf("\n"); \
-}
+} while(0)

static void
xfsidbg_xqm_dqattached_inos(xfs_mount_t *mp)
#<<eof>>

Jan Engelhardt
--
| Software Engineer and Linux/Unix Network Administrator

2006-03-25 22:38:43

by Andreas Schwab

[permalink] [raw]
Subject: Re: Parenthesize macros in xfs

Jan Engelhardt <[email protected]> writes:

> diff -dpru xfs-mod-01/support/qsort.c xfs-mod-02/support/qsort.c
> --- xfs-mod-01/support/qsort.c 2005-09-23 05:51:28.000000000 +0200
> +++ xfs-mod-02/support/qsort.c 2006-03-25 22:20:37.055287000 +0100
> @@ -55,13 +55,14 @@ swapfunc(char *a, char *b, int n, int sw
> swapcode(char, a, b, n)
> }
>
> -#define swap(a, b) \
> +#define swap(a, b) do { \
> if (swaptype == 0) { \
> long t = *(long *)(a); \
> *(long *)(a) = *(long *)(b); \
> *(long *)(b) = t; \
> } else \
> - swapfunc(a, b, es, swaptype)
> + swapfunc(a, b, es, swaptype) \
> +} while(0)
^^

Missing semicolon.

Andreas.

--
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstra?e 5, 90409 N?rnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."

2006-03-25 23:24:24

by Jan Engelhardt

[permalink] [raw]
Subject: Re: Parenthesize macros in xfs

>> -#define swap(a, b) \
>> +#define swap(a, b) do { \
>> if (swaptype == 0) { \
>> long t = *(long *)(a); \
>> *(long *)(a) = *(long *)(b); \
>> *(long *)(b) = t; \
>> } else \
>> - swapfunc(a, b, es, swaptype)
>> + swapfunc(a, b, es, swaptype) \
>> +} while(0)
> ^^
>Missing semicolon.
>

It was missing before too. ;)


Jan Engelhardt
--

2006-03-25 23:27:41

by Jan Engelhardt

[permalink] [raw]
Subject: Re: Parenthesize macros in xfs


Here is the second patch in the row which tries to make every .h 'compile
on its own'. It is not complete since the xfs directory (cvs copy)
references things not present in ws (copy of 2.6.16, _not_ cvs).
(I know I should work on the full xfs cvs, but I did not want to download
all that.)

diff --fast -pru ws~/fs/xfs/dmapi/xfs_dm.h ws/fs/xfs/dmapi/xfs_dm.h
--- ws~/fs/xfs/dmapi/xfs_dm.h 2006-02-15 03:48:07.000000000 +0100
+++ ws/fs/xfs/dmapi/xfs_dm.h 2006-03-25 23:46:04.315287000 +0100
@@ -18,9 +18,14 @@
#ifndef __XFS_DM_H__
#define __XFS_DM_H__

-extern int xfs_dm_get_fsys_vector(bhv_desc_t *, caddr_t);
+#include <linux/types.h>
+#include "xfs_types.h"

-extern xfs_dmops_t xfs_dmcore_xfs;
+struct bhv_desc;
+
+extern int xfs_dm_get_fsys_vector(struct bhv_desc *, caddr_t);
+
+extern struct xfs_dmops xfs_dmcore_xfs;
extern struct file_system_type xfs_fs_type;
extern struct filesystem_dmapi_operations xfs_dmapiops;

diff --fast -pru ws~/fs/xfs/linux-2.6/kmem.h ws/fs/xfs/linux-2.6/kmem.h
--- ws~/fs/xfs/linux-2.6/kmem.h 2006-03-06 15:18:30.000000000 +0100
+++ ws/fs/xfs/linux-2.6/kmem.h 2006-03-25 23:12:21.925287000 +0100
@@ -18,6 +18,8 @@
#ifndef __XFS_SUPPORT_KMEM_H__
#define __XFS_SUPPORT_KMEM_H__

+#include <linux/compiler.h>
+#include <linux/gfp.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/mm.h>
diff --fast -pru ws~/fs/xfs/linux-2.6/xfs_aops.h ws/fs/xfs/linux-2.6/xfs_aops.h
--- ws~/fs/xfs/linux-2.6/xfs_aops.h 2006-03-06 15:19:18.000000000 +0100
+++ ws/fs/xfs/linux-2.6/xfs_aops.h 2006-03-25 23:19:08.925287000 +0100
@@ -18,6 +18,13 @@
#ifndef __XFS_AOPS_H__
#define __XFS_AOPS_H__

+#include <asm/atomic.h>
+#include <linux/mempool.h>
+#include <linux/workqueue.h>
+#include "xfs_types.h"
+
+struct inode;
+
extern struct workqueue_struct *xfsdatad_workqueue;
extern mempool_t *xfs_ioend_pool;

diff --fast -pru ws~/fs/xfs/linux-2.6/xfs_buf.h ws/fs/xfs/linux-2.6/xfs_buf.h
--- ws~/fs/xfs/linux-2.6/xfs_buf.h 2005-12-17 12:31:50.000000000 +0100
+++ ws/fs/xfs/linux-2.6/xfs_buf.h 2006-03-26 00:17:38.675287000 +0100
@@ -28,6 +28,9 @@
#include <linux/buffer_head.h>
#include <linux/uio.h>

+#include <xfs_lrw.h>
+#include "xfs_types.h"
+
/*
* Base types
*/
diff --fast -pru ws~/fs/xfs/linux-2.6/xfs_export.h ws/fs/xfs/linux-2.6/xfs_export.h
--- ws~/fs/xfs/linux-2.6/xfs_export.h 2006-03-25 21:10:19.000000000 +0100
+++ ws/fs/xfs/linux-2.6/xfs_export.h 2006-03-25 23:29:33.815287000 +0100
@@ -18,6 +18,10 @@
#ifndef __XFS_EXPORT_H__
#define __XFS_EXPORT_H__

+#include <asm/types.h>
+#include <linux/fs.h>
+#include "xfs_fs.h"
+
/*
* Common defines for code related to exporting XFS filesystems over NFS.
*
diff --fast -pru ws~/fs/xfs/linux-2.6/xfs_fs_subr.h ws/fs/xfs/linux-2.6/xfs_fs_subr.h
--- ws~/fs/xfs/linux-2.6/xfs_fs_subr.h 2005-09-23 05:51:28.000000000 +0200
+++ ws/fs/xfs/linux-2.6/xfs_fs_subr.h 2006-03-25 23:30:52.135287000 +0100
@@ -18,12 +18,17 @@
#ifndef __XFS_FS_SUBR_H__
#define __XFS_FS_SUBR_H__

+#include <linux/types.h>
+#include "xfs_types.h"
+
+struct bhv_desc;
struct cred;
+
extern int fs_noerr(void);
extern int fs_nosys(void);
extern void fs_noval(void);
-extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
-extern void fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
-extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int);
+extern void fs_tosspages(struct bhv_desc *, xfs_off_t, xfs_off_t, int);
+extern void fs_flushinval_pages(struct bhv_desc *, xfs_off_t, xfs_off_t, int);
+extern int fs_flush_pages(struct bhv_desc *, xfs_off_t, xfs_off_t, uint64_t, int);

#endif /* __XFS_FS_SUBR_H__ */
diff --fast -pru ws~/fs/xfs/linux-2.6/xfs_globals.h ws/fs/xfs/linux-2.6/xfs_globals.h
--- ws~/fs/xfs/linux-2.6/xfs_globals.h 2005-09-23 05:51:28.000000000 +0200
+++ ws/fs/xfs/linux-2.6/xfs_globals.h 2006-03-25 23:31:10.535287000 +0100
@@ -18,6 +18,8 @@
#ifndef __XFS_GLOBALS_H__
#define __XFS_GLOBALS_H__

+#include <linux/types.h>
+
extern uint64_t xfs_panic_mask; /* set to cause more panics */
extern unsigned long xfs_physmem;
extern struct cred *sys_cred;
diff --fast -pru ws~/fs/xfs/linux-2.6/xfs_ioctl32.h ws/fs/xfs/linux-2.6/xfs_ioctl32.h
--- ws~/fs/xfs/linux-2.6/xfs_ioctl32.h 2006-03-20 03:46:07.000000000 +0100
+++ ws/fs/xfs/linux-2.6/xfs_ioctl32.h 2006-03-25 23:31:29.215287000 +0100
@@ -18,6 +18,8 @@
#ifndef __XFS_IOCTL32_H__
#define __XFS_IOCTL32_H__

+struct file;
+
extern long xfs_file_compat_ioctl(struct file *, unsigned, unsigned long);
extern long xfs_file_compat_invis_ioctl(struct file *, unsigned, unsigned long);

diff --fast -pru ws~/fs/xfs/linux-2.6/xfs_iops.h ws/fs/xfs/linux-2.6/xfs_iops.h
--- ws~/fs/xfs/linux-2.6/xfs_iops.h 2006-03-06 15:20:54.000000000 +0100
+++ ws/fs/xfs/linux-2.6/xfs_iops.h 2006-03-25 23:32:29.695287000 +0100
@@ -18,6 +18,13 @@
#ifndef __XFS_IOPS_H__
#define __XFS_IOPS_H__

+#include <linux/compiler.h>
+
+struct bhv_desc;
+struct file;
+struct inode;
+struct xfs_inode;
+
extern struct inode_operations xfs_inode_operations;
extern struct inode_operations xfs_dir_inode_operations;
extern struct inode_operations xfs_symlink_inode_operations;
@@ -29,7 +36,6 @@ extern struct file_operations xfs_invis_
extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *,
int, unsigned int, void __user *);

-struct xfs_inode;
extern void xfs_ichgtime(struct xfs_inode *, int);
extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);

diff --fast -pru ws~/fs/xfs/linux-2.6/xfs_lrw.h ws/fs/xfs/linux-2.6/xfs_lrw.h
--- ws~/fs/xfs/linux-2.6/xfs_lrw.h 2005-09-23 05:51:28.000000000 +0200
+++ ws/fs/xfs/linux-2.6/xfs_lrw.h 2006-03-25 23:26:43.925287000 +0100
@@ -18,8 +18,15 @@
#ifndef __XFS_LRW_H__
#define __XFS_LRW_H__

+#include <linux/fs.h> /* read_actor_t */
+#include <linux/types.h> /* ssize_t */
+#include "xfs_types.h"
+
struct vnode;
struct bhv_desc;
+struct cred;
+struct iovec;
+struct kiocb;
struct xfs_mount;
struct xfs_iocore;
struct xfs_inode;
diff --fast -pru ws~/fs/xfs/linux-2.6/xfs_stats.h ws/fs/xfs/linux-2.6/xfs_stats.h
--- ws~/fs/xfs/linux-2.6/xfs_stats.h 2005-12-17 12:31:50.000000000 +0100
+++ ws/fs/xfs/linux-2.6/xfs_stats.h 2006-03-25 23:37:39.235287000 +0100
@@ -21,7 +21,9 @@

#if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF)

+#include <asm/types.h>
#include <linux/percpu.h>
+#include "xfs_types.h"

/*
* XFS global statistics
diff --fast -pru ws~/fs/xfs/linux-2.6/xfs_super.h ws/fs/xfs/linux-2.6/xfs_super.h
--- ws~/fs/xfs/linux-2.6/xfs_super.h 2006-03-17 15:28:04.000000000 +0100
+++ ws/fs/xfs/linux-2.6/xfs_super.h 2006-03-25 23:38:47.435287000 +0100
@@ -18,6 +18,8 @@
#ifndef __XFS_SUPER_H__
#define __XFS_SUPER_H__

+#include "xfs_types.h"
+
#ifdef CONFIG_XFS_POSIX_ACL
# define XFS_ACL_STRING "ACLs, "
# define set_posix_acl_flag(sb) ((sb)->s_flags |= MS_POSIXACL)
@@ -69,15 +71,17 @@
XFS_TRACE_STRING \
XFS_DBG_STRING /* DBG must be last */

+struct bhv_desc;
+struct block_device;
+struct vnode;
struct xfs_inode;
struct xfs_mount;
struct xfs_buftarg;
-struct block_device;

extern __uint64_t xfs_max_file_offset(unsigned int);

-extern struct inode *xfs_get_inode(bhv_desc_t *, xfs_ino_t, int);
-extern void xfs_initialize_vnode(bhv_desc_t *, vnode_t *, bhv_desc_t *, int);
+extern struct inode *xfs_get_inode(struct bhv_desc *, xfs_ino_t, int);
+extern void xfs_initialize_vnode(struct bhv_desc *, struct vnode *, struct bhv_desc *, int);

extern void xfs_flush_inode(struct xfs_inode *);
extern void xfs_flush_device(struct xfs_inode *);
diff --fast -pru ws~/fs/xfs/linux-2.6/xfs_vfs.h ws/fs/xfs/linux-2.6/xfs_vfs.h
--- ws~/fs/xfs/linux-2.6/xfs_vfs.h 2006-03-25 21:10:19.000000000 +0100
+++ ws/fs/xfs/linux-2.6/xfs_vfs.h 2006-03-25 23:41:08.605287000 +0100
@@ -18,14 +18,20 @@
#ifndef __XFS_VFS_H__
#define __XFS_VFS_H__

+#include <linux/list.h>
+#include <linux/spinlock.h>
#include <linux/vfs.h>
+#include <linux/wait.h>
+#include "xfs_behavior.h"
#include "xfs_fs.h"
+#include "xfs_types.h"

struct fid;
struct vfs;
struct cred;
struct vnode;
struct kstatfs;
+struct module;
struct seq_file;
struct super_block;
struct xfs_mount_args;
diff --fast -pru ws~/fs/xfs/linux-2.6/xfs_vnode.h ws/fs/xfs/linux-2.6/xfs_vnode.h
--- ws~/fs/xfs/linux-2.6/xfs_vnode.h 2006-03-17 15:28:04.000000000 +0100
+++ ws/fs/xfs/linux-2.6/xfs_vnode.h 2006-03-25 23:44:12.215287000 +0100
@@ -45,7 +45,15 @@
#ifndef __XFS_VNODE_H__
#define __XFS_VNODE_H__

+#include <linux/fs.h>
+#include <linux/spinlock.h>
+#include "xfs_behavior.h"
+#include "xfs_fs.h"
+#include "xfs_types.h"
+
struct uio;
+struct cred;
+struct fid;
struct file;
struct vattr;
struct xfs_iomap;
@@ -490,7 +498,7 @@ extern vnode_t *vn_initialize(struct ino
* vnode_map structures _must_ match vn_epoch and vnode structure sizes.
*/
typedef struct vnode_map {
- vfs_t *v_vfsp;
+ struct vfs *v_vfsp;
vnumber_t v_number; /* in-core vnode number */
xfs_ino_t v_ino; /* inode # */
} vmap_t;
diff --fast -pru ws~/fs/xfs/quota/xfs_dquot.h ws/fs/xfs/quota/xfs_dquot.h
--- ws~/fs/xfs/quota/xfs_dquot.h 2005-09-26 05:46:03.000000000 +0200
+++ ws/fs/xfs/quota/xfs_dquot.h 2006-03-25 23:56:11.155287000 +0100
@@ -18,6 +18,12 @@
#ifndef __XFS_DQUOT_H__
#define __XFS_DQUOT_H__

+#include <mutex.h>
+#include <sv.h>
+#include "quota/xfs_dquot_item.h"
+#include "xfs_quota.h"
+#include "xfs_types.h"
+
/*
* Dquots are structures that hold quota information about a user or a group,
* much like inodes are for files. In fact, dquots share many characteristics
@@ -44,9 +50,6 @@ typedef struct xfs_dqlink {
struct xfs_dquot **ql_prevp; /* pointer to prev ql_next */
} xfs_dqlink_t;

-struct xfs_mount;
-struct xfs_trans;
-
/*
* This is the marker which is designed to occupy the first few
* bytes of the xfs_dquot_t structure. Even inside this, the freelist pointers
@@ -174,11 +177,11 @@ extern void xfs_qm_dqunpin_wait(xfs_dqu
extern int xfs_qm_dqlock_nowait(xfs_dquot_t *);
extern int xfs_qm_dqflock_nowait(xfs_dquot_t *);
extern void xfs_qm_dqflock_pushbuf_wait(xfs_dquot_t *dqp);
-extern void xfs_qm_adjust_dqtimers(xfs_mount_t *,
+extern void xfs_qm_adjust_dqtimers(struct xfs_mount *,
xfs_disk_dquot_t *);
-extern void xfs_qm_adjust_dqlimits(xfs_mount_t *,
+extern void xfs_qm_adjust_dqlimits(struct xfs_mount *,
xfs_disk_dquot_t *);
-extern int xfs_qm_dqget(xfs_mount_t *, xfs_inode_t *,
+extern int xfs_qm_dqget(struct xfs_mount *, struct xfs_inode *,
xfs_dqid_t, uint, uint, xfs_dquot_t **);
extern void xfs_qm_dqput(xfs_dquot_t *);
extern void xfs_qm_dqrele(xfs_dquot_t *);
diff --fast -pru ws~/fs/xfs/quota/xfs_dquot_item.h ws/fs/xfs/quota/xfs_dquot_item.h
--- ws~/fs/xfs/quota/xfs_dquot_item.h 2005-09-26 05:46:03.000000000 +0200
+++ ws/fs/xfs/quota/xfs_dquot_item.h 2006-03-25 23:56:34.055287000 +0100
@@ -18,10 +18,8 @@
#ifndef __XFS_DQUOT_ITEM_H__
#define __XFS_DQUOT_ITEM_H__

-struct xfs_dquot;
-struct xfs_trans;
-struct xfs_mount;
-struct xfs_qoff_logitem;
+#include "xfs_quota.h"
+#include "xfs_trans.h"

typedef struct xfs_dq_logitem {
xfs_log_item_t qli_item; /* common portion */
diff --fast -pru ws~/fs/xfs/quota/xfs_qm.h ws/fs/xfs/quota/xfs_qm.h
--- ws~/fs/xfs/quota/xfs_qm.h 2006-01-25 01:34:27.000000000 +0100
+++ ws/fs/xfs/quota/xfs_qm.h 2006-03-26 00:00:55.085287000 +0100
@@ -18,13 +18,13 @@
#ifndef __XFS_QM_H__
#define __XFS_QM_H__

+#include <spin.h>
#include "xfs_dquot_item.h"
#include "xfs_dquot.h"
#include "xfs_quota_priv.h"
#include "xfs_qm_stats.h"

-struct xfs_qm;
-struct xfs_inode;
+struct bhv_desc;

extern uint ndquot;
extern mutex_t xfs_Gqm_lock;
@@ -110,8 +110,8 @@ typedef struct xfs_qm {
* The mount structure keeps a pointer to this.
*/
typedef struct xfs_quotainfo {
- xfs_inode_t *qi_uquotaip; /* user quota inode */
- xfs_inode_t *qi_gquotaip; /* group quota inode */
+ struct xfs_inode *qi_uquotaip; /* user quota inode */
+ struct xfs_inode *qi_gquotaip; /* group quota inode */
lock_t qi_pinlock; /* dquot pinning mutex */
xfs_dqlist_t qi_dqlist; /* all dquots in filesys */
int qi_dqreclaims; /* a change here indicates
@@ -137,7 +137,7 @@ typedef struct xfs_quotainfo {
extern xfs_dqtrxops_t xfs_trans_dquot_ops;

extern void xfs_trans_mod_dquot(xfs_trans_t *, xfs_dquot_t *, uint, long);
-extern int xfs_trans_reserve_quota_bydquots(xfs_trans_t *, xfs_mount_t *,
+extern int xfs_trans_reserve_quota_bydquots(xfs_trans_t *, struct xfs_mount *,
xfs_dquot_t *, xfs_dquot_t *, long, long, uint);
extern void xfs_trans_dqjoin(xfs_trans_t *, xfs_dquot_t *);
extern void xfs_trans_log_dquot(xfs_trans_t *, xfs_dquot_t *);
@@ -170,33 +170,33 @@ typedef struct xfs_dquot_acct {
#define XFS_QM_HOLD(xqm) ((xqm)->qm_nrefs++)
#define XFS_QM_RELE(xqm) ((xqm)->qm_nrefs--)

-extern void xfs_qm_destroy_quotainfo(xfs_mount_t *);
-extern int xfs_qm_mount_quotas(xfs_mount_t *, int);
-extern void xfs_qm_mount_quotainit(xfs_mount_t *, uint);
-extern int xfs_qm_quotacheck(xfs_mount_t *);
-extern void xfs_qm_unmount_quotadestroy(xfs_mount_t *);
-extern int xfs_qm_unmount_quotas(xfs_mount_t *);
-extern int xfs_qm_write_sb_changes(xfs_mount_t *, __int64_t);
-extern int xfs_qm_sync(xfs_mount_t *, short);
+extern void xfs_qm_destroy_quotainfo(struct xfs_mount *);
+extern int xfs_qm_mount_quotas(struct xfs_mount *, int);
+extern void xfs_qm_mount_quotainit(struct xfs_mount *, uint);
+extern int xfs_qm_quotacheck(struct xfs_mount *);
+extern void xfs_qm_unmount_quotadestroy(struct xfs_mount *);
+extern int xfs_qm_unmount_quotas(struct xfs_mount *);
+extern int xfs_qm_write_sb_changes(struct xfs_mount *, __int64_t);
+extern int xfs_qm_sync(struct xfs_mount *, short);

/* dquot stuff */
extern boolean_t xfs_qm_dqalloc_incore(xfs_dquot_t **);
-extern int xfs_qm_dqattach(xfs_inode_t *, uint);
-extern void xfs_qm_dqdetach(xfs_inode_t *);
-extern int xfs_qm_dqpurge_all(xfs_mount_t *, uint);
-extern void xfs_qm_dqrele_all_inodes(xfs_mount_t *, uint);
+extern int xfs_qm_dqattach(struct xfs_inode *, uint);
+extern void xfs_qm_dqdetach(struct xfs_inode *);
+extern int xfs_qm_dqpurge_all(struct xfs_mount *, uint);
+extern void xfs_qm_dqrele_all_inodes(struct xfs_mount *, uint);

/* vop stuff */
-extern int xfs_qm_vop_dqalloc(xfs_mount_t *, xfs_inode_t *,
+extern int xfs_qm_vop_dqalloc(struct xfs_mount *, struct xfs_inode *,
uid_t, gid_t, prid_t, uint,
xfs_dquot_t **, xfs_dquot_t **);
extern void xfs_qm_vop_dqattach_and_dqmod_newinode(
- xfs_trans_t *, xfs_inode_t *,
+ xfs_trans_t *, struct xfs_inode *,
xfs_dquot_t *, xfs_dquot_t *);
-extern int xfs_qm_vop_rename_dqattach(xfs_inode_t **);
-extern xfs_dquot_t * xfs_qm_vop_chown(xfs_trans_t *, xfs_inode_t *,
+extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **);
+extern xfs_dquot_t * xfs_qm_vop_chown(xfs_trans_t *, struct xfs_inode *,
xfs_dquot_t **, xfs_dquot_t *);
-extern int xfs_qm_vop_chown_reserve(xfs_trans_t *, xfs_inode_t *,
+extern int xfs_qm_vop_chown_reserve(xfs_trans_t *, struct xfs_inode *,
xfs_dquot_t *, xfs_dquot_t *, uint);

/* list stuff */
@@ -205,10 +205,10 @@ extern void xfs_qm_freelist_unlink(xfs_
extern int xfs_qm_freelist_lock_nowait(xfs_qm_t *);

/* system call interface */
-extern int xfs_qm_quotactl(bhv_desc_t *, int, int, xfs_caddr_t);
+extern int xfs_qm_quotactl(struct bhv_desc *, int, int, xfs_caddr_t);

#ifdef DEBUG
-extern int xfs_qm_internalqcheck(xfs_mount_t *);
+extern int xfs_qm_internalqcheck(struct xfs_mount *);
#else
#define xfs_qm_internalqcheck(mp) (0)
#endif
diff --fast -pru ws~/fs/xfs/quota/xfs_qm_stats.h ws/fs/xfs/quota/xfs_qm_stats.h
--- ws~/fs/xfs/quota/xfs_qm_stats.h 2005-09-26 05:46:03.000000000 +0200
+++ ws/fs/xfs/quota/xfs_qm_stats.h 2006-03-26 00:01:13.795287000 +0100
@@ -18,6 +18,8 @@
#ifndef __XFS_QM_STATS_H__
#define __XFS_QM_STATS_H__

+#include "xfs_types.h"
+
#if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF)

/*
diff --fast -pru ws~/fs/xfs/support/move.h ws/fs/xfs/support/move.h
--- ws~/fs/xfs/support/move.h 2005-09-23 05:51:28.000000000 +0200
+++ ws/fs/xfs/support/move.h 2006-03-26 00:03:26.295287000 +0100
@@ -47,6 +47,7 @@

#include <linux/uio.h>
#include <asm/uaccess.h>
+#include "xfs_types.h"

/* Segment flag values. */
enum uio_seg {
diff --fast -pru ws~/fs/xfs/support/qsort.h ws/fs/xfs/support/qsort.h
--- ws~/fs/xfs/support/qsort.h 2005-09-23 05:51:28.000000000 +0200
+++ ws/fs/xfs/support/qsort.h 2006-03-26 00:03:52.865287000 +0100
@@ -18,6 +18,8 @@
#ifndef __XFS_SUPPORT_QSORT_H__
#define __XFS_SUPPORT_QSORT_H__

+#include <linux/types.h>
+
extern void qsort(void *const pbase, size_t total_elems, size_t size,
int (*cmp)(const void *, const void *));

diff --fast -pru ws~/fs/xfs/support/uuid.h ws/fs/xfs/support/uuid.h
--- ws~/fs/xfs/support/uuid.h 2005-09-23 05:51:28.000000000 +0200
+++ ws/fs/xfs/support/uuid.h 2006-03-26 00:04:16.305287000 +0100
@@ -18,6 +18,8 @@
#ifndef __XFS_SUPPORT_UUID_H__
#define __XFS_SUPPORT_UUID_H__

+#include "xfs_types.h"
+
typedef struct {
unsigned char __u_bits[16];
} uuid_t;
diff --fast -pru ws~/fs/xfs/xfs_acl.h ws/fs/xfs/xfs_acl.h
--- ws~/fs/xfs/xfs_acl.h 2006-03-25 21:10:18.000000000 +0100
+++ ws/fs/xfs/xfs_acl.h 2006-03-26 00:06:06.045287000 +0100
@@ -18,6 +18,9 @@
#ifndef __XFS_ACL_H__
#define __XFS_ACL_H__

+#include <linux/types.h>
+#include "xfs_types.h"
+
/*
* Access Control Lists
*/
@@ -49,6 +52,7 @@ typedef struct xfs_acl {

#ifdef CONFIG_XFS_POSIX_ACL

+struct cred;
struct vattr;
struct vnode;
struct xfs_inode;
@@ -59,7 +63,7 @@ extern struct kmem_zone *xfs_acl_zone;
#define xfs_acl_zone_destroy(zone) kmem_zone_destroy(zone)

extern int xfs_acl_inherit(struct vnode *, struct vattr *, xfs_acl_t *);
-extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *);
+extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, struct cred *);
extern int xfs_acl_vtoacl(struct vnode *, xfs_acl_t *, xfs_acl_t *);
extern int xfs_acl_vhasacl_access(struct vnode *);
extern int xfs_acl_vhasacl_default(struct vnode *);
diff --fast -pru ws~/fs/xfs/xfs_ag.h ws/fs/xfs/xfs_ag.h
--- ws~/fs/xfs/xfs_ag.h 2006-03-25 21:10:18.000000000 +0100
+++ ws/fs/xfs/xfs_ag.h 2006-03-26 00:07:29.455287000 +0100
@@ -18,6 +18,11 @@
#ifndef __XFS_AG_H__
#define __XFS_AG_H__

+#include <linux/types.h>
+#include <spin.h>
+#include "xfs_inum.h"
+#include "xfs_types.h"
+
/*
* Allocation group header
* This is divided into three structures, placed in sequential 512-byte
diff --fast -pru ws~/fs/xfs/xfs_alloc.h ws/fs/xfs/xfs_alloc.h
--- ws~/fs/xfs/xfs_alloc.h 2006-03-25 21:10:18.000000000 +0100
+++ ws/fs/xfs/xfs_alloc.h 2006-03-26 00:08:07.455287000 +0100
@@ -18,6 +18,8 @@
#ifndef __XFS_ALLOC_H__
#define __XFS_ALLOC_H__

+#include "xfs_types.h"
+
struct xfs_buf;
struct xfs_mount;
struct xfs_perag;
@@ -173,13 +175,13 @@ xfs_free_extent(
xfs_extlen_t len); /* length of extent */

void
-xfs_alloc_mark_busy(xfs_trans_t *tp,
+xfs_alloc_mark_busy(struct xfs_trans *tp,
xfs_agnumber_t agno,
xfs_agblock_t bno,
xfs_extlen_t len);

void
-xfs_alloc_clear_busy(xfs_trans_t *tp,
+xfs_alloc_clear_busy(struct xfs_trans *tp,
xfs_agnumber_t ag,
int idx);

diff --fast -pru ws~/fs/xfs/xfs_alloc_btree.h ws/fs/xfs/xfs_alloc_btree.h
--- ws~/fs/xfs/xfs_alloc_btree.h 2005-10-21 20:08:47.000000000 +0200
+++ ws/fs/xfs/xfs_alloc_btree.h 2006-03-26 00:08:31.585287000 +0100
@@ -18,6 +18,9 @@
#ifndef __XFS_ALLOC_BTREE_H__
#define __XFS_ALLOC_BTREE_H__

+#include <linux/types.h>
+#include "xfs_types.h"
+
/*
* Freespace on-disk structures
*/
diff --fast -pru ws~/fs/xfs/xfs_arch.h ws/fs/xfs/xfs_arch.h
--- ws~/fs/xfs/xfs_arch.h 2006-03-25 22:24:11.255287000 +0100
+++ ws/fs/xfs/xfs_arch.h 2006-03-25 23:34:09.425287000 +0100
@@ -25,6 +25,8 @@
#ifdef __KERNEL__

#include <asm/byteorder.h>
+#include <asm/types.h>
+#include "xfs_types.h"

#ifdef __BIG_ENDIAN
#define XFS_NATIVE_HOST 1
diff --fast -pru ws~/fs/xfs/xfs_attr.h ws/fs/xfs/xfs_attr.h
--- ws~/fs/xfs/xfs_attr.h 2005-09-23 05:51:28.000000000 +0200
+++ ws/fs/xfs/xfs_attr.h 2006-03-26 00:09:18.815287000 +0100
@@ -18,6 +18,8 @@
#ifndef __XFS_ATTR_H__
#define __XFS_ATTR_H__

+#include <linux/types.h>
+
/*
* xfs_attr.h
*
@@ -35,6 +37,7 @@
* External interfaces
*========================================================================*/

+struct bhv_desc;
struct cred;
struct vnode;

@@ -158,10 +161,10 @@ struct xfs_da_args;
/*
* Overall external interface routines.
*/
-int xfs_attr_get(bhv_desc_t *, const char *, char *, int *, int, struct cred *);
-int xfs_attr_set(bhv_desc_t *, const char *, char *, int, int, struct cred *);
-int xfs_attr_remove(bhv_desc_t *, const char *, int, struct cred *);
-int xfs_attr_list(bhv_desc_t *, char *, int, int,
+int xfs_attr_get(struct bhv_desc *, const char *, char *, int *, int, struct cred *);
+int xfs_attr_set(struct bhv_desc *, const char *, char *, int, int, struct cred *);
+int xfs_attr_remove(struct bhv_desc *, const char *, int, struct cred *);
+int xfs_attr_list(struct bhv_desc *, char *, int, int,
struct attrlist_cursor_kern *, struct cred *);
int xfs_attr_inactive(struct xfs_inode *dp);

diff --fast -pru ws~/fs/xfs/xfs_attr_leaf.h ws/fs/xfs/xfs_attr_leaf.h
--- ws~/fs/xfs/xfs_attr_leaf.h 2006-03-17 15:44:48.000000000 +0100
+++ ws/fs/xfs/xfs_attr_leaf.h 2006-03-26 00:12:13.175287000 +0100
@@ -18,6 +18,10 @@
#ifndef __XFS_ATTR_LEAF_H__
#define __XFS_ATTR_LEAF_H__

+#include <asm/byteorder.h>
+#include <linux/types.h>
+#include "xfs_da_btree.h"
+
/*
* Attribute storage layout, internal structure, access macros, etc.
*
@@ -232,7 +236,7 @@ int xfs_attr_shortform_to_leaf(struct xf
int xfs_attr_shortform_remove(struct xfs_da_args *args);
int xfs_attr_shortform_list(struct xfs_attr_list_context *context);
int xfs_attr_shortform_allfit(struct xfs_dabuf *bp, struct xfs_inode *dp);
-int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes);
+int xfs_attr_shortform_bytesfit(struct xfs_inode *dp, int bytes);


/*
diff --fast -pru ws~/fs/xfs/xfs_attr_sf.h ws/fs/xfs/xfs_attr_sf.h
--- ws~/fs/xfs/xfs_attr_sf.h 2006-03-17 15:45:34.000000000 +0100
+++ ws/fs/xfs/xfs_attr_sf.h 2006-03-26 00:12:33.025287000 +0100
@@ -18,6 +18,9 @@
#ifndef __XFS_ATTR_SF_H__
#define __XFS_ATTR_SF_H__

+#include <linux/types.h>
+#include "xfs_types.h"
+
/*
* Attribute storage when stored inside the inode.
*
diff --fast -pru ws~/fs/xfs/xfs_behavior.h ws/fs/xfs/xfs_behavior.h
--- ws~/fs/xfs/xfs_behavior.h 2006-03-25 21:10:18.000000000 +0100
+++ ws/fs/xfs/xfs_behavior.h 2006-03-25 23:35:45.865287000 +0100
@@ -78,7 +78,13 @@
*
*/

+#include <asm/types.h>
+#include <linux/stddef.h>
+
struct bhv_head_lock;
+struct vnode;
+struct vnodeops;
+struct xfs_inode;

/*
* Behavior head. Head of the chain of behaviors.
@@ -183,6 +173,24 @@ extern bhv_desc_t * bhv_lookup(bhv_head_
extern bhv_desc_t * bhv_lookup_range(bhv_head_t *bhp, int low, int high);
extern bhv_desc_t * bhv_base(bhv_head_t *bhp);

+/*
+ * Remove a behavior descriptor from a behavior chain.
+ */
+static inline void bhv_remove(bhv_head_t *bhp, struct bhv_desc *bdp) {
+ if(bhp->bh_first == bdp)
+ /*
+ * Remove from front of chain.
+ * Atomic wrt oip's.
+ */
+ bhp->bh_first = bdp->bd_next;
+ else
+ /* remove from non-front of chain */
+ bhv_remove_not_first(bhp, bdp);
+
+ bdp->bd_vobj = NULL;
+ return;
+}
+
/* No bhv locking on Linux */
#define bhv_lookup_unlocked bhv_lookup
#define bhv_base_unlocked bhv_base
diff --fast -pru ws~/fs/xfs/xfs_bit.h ws/fs/xfs/xfs_bit.h
--- ws~/fs/xfs/xfs_bit.h 2005-09-23 05:51:28.000000000 +0200
+++ ws/fs/xfs/xfs_bit.h 2006-03-26 00:13:16.515287000 +0100
@@ -18,6 +18,9 @@
#ifndef __XFS_BIT_H__
#define __XFS_BIT_H__

+#include <linux/types.h>
+#include "xfs_types.h"
+
/*
* XFS bit manipulation routines.
*/
diff --fast -pru ws~/fs/xfs/xfs_bmap.h ws/fs/xfs/xfs_bmap.h
--- ws~/fs/xfs/xfs_bmap.h 2006-03-03 01:40:32.000000000 +0100
+++ ws/fs/xfs/xfs_bmap.h 2006-03-26 00:14:07.995287000 +0100
@@ -18,6 +18,9 @@
#ifndef __XFS_BMAP_H__
#define __XFS_BMAP_H__

+#include "xfs_inode.h"
+#include "xfs_types.h"
+
struct getbmap;
struct xfs_bmbt_irec;
struct xfs_ifork;
diff --fast -pru ws~/fs/xfs/xfs_da_btree.h ws/fs/xfs/xfs_da_btree.h
--- ws~/fs/xfs/xfs_da_btree.h 2006-03-17 15:48:35.000000000 +0100
+++ ws/fs/xfs/xfs_da_btree.h 2006-03-26 00:10:50.305287000 +0100
@@ -18,6 +18,8 @@
#ifndef __XFS_DA_BTREE_H__
#define __XFS_DA_BTREE_H__

+#include "xfs_types.h"
+
struct xfs_buf;
struct xfs_bmap_free;
struct xfs_inode;
diff --fast -pru ws~/fs/xfs/xfs_fs.h ws/fs/xfs/xfs_fs.h
--- ws~/fs/xfs/xfs_fs.h 2006-03-25 22:24:11.265287000 +0100
+++ ws/fs/xfs/xfs_fs.h 2006-03-25 23:28:56.635287000 +0100
@@ -18,6 +18,10 @@
#ifndef __XFS_FS_H__
#define __XFS_FS_H__

+#include <linux/types.h>
+
+struct inode;
+
/*
* SGI's XFS filesystem's major stuff (constants, structures)
*/
diff --fast -pru ws~/fs/xfs/xfs_inum.h ws/fs/xfs/xfs_inum.h
--- ws~/fs/xfs/xfs_inum.h 2005-09-23 05:51:28.000000000 +0200
+++ ws/fs/xfs/xfs_inum.h 2006-03-26 00:07:03.615287000 +0100
@@ -18,6 +18,8 @@
#ifndef __XFS_INUM_H__
#define __XFS_INUM_H__

+#include "xfs_types.h"
+
/*
* Inode number format:
* low inopblog bits - offset in block
diff --fast -pru ws~/fs/xfs/xfs_log.h ws/fs/xfs/xfs_log.h
--- ws~/fs/xfs/xfs_log.h 2006-03-25 21:10:18.000000000 +0100
+++ ws/fs/xfs/xfs_log.h 2006-03-25 23:53:46.815287000 +0100
@@ -18,6 +18,12 @@
#ifndef __XFS_LOG_H__
#define __XFS_LOG_H__

+#include <linux/types.h>
+#include "xfs_types.h"
+
+struct xfs_buf;
+struct xfs_buftarg;
+
/* get lsn fields */

#define CYCLE_LSN(lsn) ((uint)((lsn)>>32))
diff --fast -pru ws~/fs/xfs/xfs_quota.h ws/fs/xfs/xfs_quota.h
--- ws~/fs/xfs/xfs_quota.h 2006-03-25 21:10:18.000000000 +0100
+++ ws/fs/xfs/xfs_quota.h 2006-03-25 23:49:42.575287000 +0100
@@ -18,6 +18,13 @@
#ifndef __XFS_QUOTA_H__
#define __XFS_QUOTA_H__

+#include <linux/types.h>
+#include "xfs_types.h"
+
+struct xfs_inode;
+struct xfs_mount;
+struct xfs_trans;
+
/*
* The ondisk form of a dquot structure.
*/
diff --fast -pru ws~/fs/xfs/xfs_trans.h ws/fs/xfs/xfs_trans.h
--- ws~/fs/xfs/xfs_trans.h 2006-03-25 21:10:18.000000000 +0100
+++ ws/fs/xfs/xfs_trans.h 2006-03-25 23:53:59.705287000 +0100
@@ -18,6 +18,11 @@
#ifndef __XFS_TRANS_H__
#define __XFS_TRANS_H__

+#include <linux/types.h>
+#include <sema.h>
+#include "xfs_log.h"
+#include "xfs_types.h"
+
/*
* This is the structure written in the log at the head of
* every transaction. It identifies the type and id of the
diff --fast -pru ws~/fs/xfs/xfs_types.h ws/fs/xfs/xfs_types.h
--- ws~/fs/xfs/xfs_types.h 2005-09-23 05:51:28.000000000 +0200
+++ ws/fs/xfs/xfs_types.h 2006-03-25 23:25:11.955287000 +0100
@@ -20,6 +20,8 @@

#ifdef __KERNEL__

+#include <asm/types.h>
+
/*
* POSIX Extensions
*/
#<eof>


Jan Engelhardt
--

2006-03-25 23:45:23

by Andreas Schwab

[permalink] [raw]
Subject: Re: Parenthesize macros in xfs

Jan Engelhardt <[email protected]> writes:

>>> -#define swap(a, b) \
>>> +#define swap(a, b) do { \
>>> if (swaptype == 0) { \
>>> long t = *(long *)(a); \
>>> *(long *)(a) = *(long *)(b); \
>>> *(long *)(b) = t; \
>>> } else \
>>> - swapfunc(a, b, es, swaptype)
>>> + swapfunc(a, b, es, swaptype) \
>>> +} while(0)
>> ^^
>>Missing semicolon.
>>
>
> It was missing before too. ;)

No, previously it was provided at the call site.

Andreas.

--
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstra?e 5, 90409 N?rnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."

2006-03-26 09:26:57

by Jan Engelhardt

[permalink] [raw]
Subject: Re: Parenthesize macros in xfs

>>>> + swapfunc(a, b, es, swaptype) \
>>>> +} while(0)
>>> ^^
>>>Missing semicolon.
>>
>> It was missing before too. ;)
>
>No, previously it was provided at the call site.

Bad habit IMO. It does not hurt to provide it in both the macro and
the call site, GCC can handle empty instructions.


Jan Engelhardt
--

2006-03-26 12:19:26

by Måns Rullgård

[permalink] [raw]
Subject: Re: Parenthesize macros in xfs

Jan Engelhardt <[email protected]> writes:

>>>>> + swapfunc(a, b, es, swaptype) \
>>>>> +} while(0)
>>>> ^^
>>>>Missing semicolon.
>>>
>>> It was missing before too. ;)
>>
>>No, previously it was provided at the call site.
>
> Bad habit IMO. It does not hurt to provide it in both the macro and
> the call site, GCC can handle empty instructions.

A double semicolon can cause all sorts of hard to debug problems.
Consider this:

#define foo() bar();
/* ... */
if(x)
foo();
else
baz();

This will expand to syntactically invalid code because of the extra
semicolon.

--
M?ns Rullg?rd
[email protected]

2006-03-26 12:30:35

by Kyle Moffett

[permalink] [raw]
Subject: Re: Parenthesize macros in xfs

On Mar 26, 2006, at 07:19:14, M?ns Rullg?rd wrote:
> A double semicolon can cause all sorts of hard to debug problems.
> Consider this:
>
> #define foo() bar();
> /* ... */
> if(x)
> foo();
> else
> baz();
>
> This will expand to syntactically invalid code because of the extra
> semicolon.

More generically, the code "do { [...] } while(0)" can _always_ be
substituted for the code "function_returning_void()" without changing
the meaning of the surrounding code. Look at the following examples:

for (i = 0; i < 10; i++) {
macro();
}

for (i = 0; i < 10; i++)
if (i > 5)
macro1();
else
macro2();

Cheers,
Kyle Moffett

2006-03-26 14:23:14

by Andreas Schwab

[permalink] [raw]
Subject: Re: Parenthesize macros in xfs

Jan Engelhardt <[email protected]> writes:

>>>>> + swapfunc(a, b, es, swaptype) \
>>>>> +} while(0)
>>>> ^^
>>>>Missing semicolon.
>>>
>>> It was missing before too. ;)
>>
>>No, previously it was provided at the call site.
>
> Bad habit IMO. It does not hurt to provide it in both the macro and
> the call site, GCC can handle empty instructions.

There is no way to provide the missing semicolon at the call site.
swapfunc can't provide it either, since it's not a macro.

Andreas.

--
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstra?e 5, 90409 N?rnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."