The diff below changes the UFS DIP macros to only check for UFS1 vs
UFS2 when the FFS2 compile option is actually enabled.  There's no
binary change when FFS2 is enabled, and it shrinks a non-FFS2 amd64
kernel by about 8KB and still works with my FFS1 filesystem.

ok?

Index: inode.h
===================================================================
RCS file: /cvs/src/sys/ufs/ufs/inode.h,v
retrieving revision 1.37
diff -u -p -r1.37 inode.h
--- inode.h     17 Jan 2009 18:50:25 -0000      1.37
+++ inode.h     20 Aug 2010 11:06:01 -0000
@@ -261,45 +261,44 @@ struct inode_vtbl {
 /*
  * The DIP macros are used to access fields in the dinode.
  */
+
+#ifdef FFS2
 #define DIP(ip, field) \
        (((ip)->i_ump->um_fstype == UM_UFS1) ? \
        (ip)->i_ffs1_##field : (ip)->i_ffs2_##field)
+#else
+#define DIP(ip, field) \
+       ((ip)->i_ffs1_##field)
+#endif
 
-#define DIP_ASSIGN(ip, field, value)                                   \
+#ifdef FFS2
+#define DIP_OP(ip, field, op, value)                                   \
        do {                                                            \
                if ((ip)->i_ump->um_fstype == UM_UFS1)                  \
-                       (ip)->i_ffs1_##field = (value);                 \
+                       (ip)->i_ffs1_##field op (value);                \
                else                                                    \
-                       (ip)->i_ffs2_##field = (value);                 \
+                       (ip)->i_ffs2_##field op (value);                \
        } while (0)
-
-#define DIP_ADD(ip, field, value)                                      \
+#else
+#define DIP_OP(ip, field, op, value)                                   \
        do {                                                            \
-               if ((ip)->i_ump->um_fstype == UM_UFS1)                  \
-                       (ip)->i_ffs1_##field += (value);                \
-               else                                                    \
-                       (ip)->i_ffs2_##field += (value);                \
+               (ip)->i_ffs1_##field op (value);                        \
        } while (0)
+#endif
 
-#define DIP_AND(ip, field, value)                                      \
-       do {                                                            \
-               if ((ip)->i_ump->um_fstype == UM_UFS1)                  \
-                       (ip)->i_ffs1_##field &= (value);                \
-               else                                                    \
-                       (ip)->i_ffs2_##field &= (value);                \
-       } while (0)
-
-#define DIP_OR(ip, field, value)                                       \
-       do {                                                            \
-               if ((ip)->i_ump->um_fstype == UM_UFS1)                  \
-                       (ip)->i_ffs1_##field |= (value);                \
-               else                                                    \
-                       (ip)->i_ffs2_##field |= (value);                \
-       } while (0)
+#define DIP_ASSIGN(ip, field, value)   DIP_OP(ip, field, =, value)
+#define DIP_ADD(ip, field, value)      DIP_OP(ip, field, +=, value)
+#define DIP_AND(ip, field, value)      DIP_OP(ip, field, &=, value)
+#define DIP_OR(ip, field, value)       DIP_OP(ip, field, |=, value)
 
+#ifdef FFS2
 #define SHORTLINK(ip) \
        (((ip)->i_ump->um_fstype == UM_UFS1) ? \
        (caddr_t)(ip)->i_ffs1_db : (caddr_t)(ip)->i_ffs2_db)
+#else
+#define SHORTLINK(ip) \
+       ((caddr_t)(ip)->i_ffs1_db)
+#endif
 
 /*
  * Structure used to pass around logical block paths generated by

Reply via email to