Whamcloud - gitweb
LU-709 compat: remove all reference to LINUX_VERSION_CODE
authorPeng Tao <tao.peng@emc.com>
Mon, 23 Jul 2012 05:26:48 +0000 (13:26 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Mon, 23 Jul 2012 18:31:52 +0000 (14:31 -0400)
All LINUX_VERSION_CODE refereces are used to note kernel version older
than 2.6.18. So we can drop them all.

Affected variables are inlined as much as possible to minimize compat
code definition.

Signed-off-by: Peng Tao <tao.peng@emc.com>
Change-Id: If3b94ceb5e21db8f96b11526399e9cd8f174fd6f
Reviewed-on: http://review.whamcloud.com/3442
Tested-by: Hudson
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Prakash Surya <surya1@llnl.gov>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
13 files changed:
libcfs/include/libcfs/darwin/darwin-prim.h
libcfs/include/libcfs/winnt/winnt-prim.h
libcfs/libcfs/linux/linux-tcpip.c
lnet/klnds/socklnd/socklnd_lib-linux.c
lustre/include/liblustre.h
lustre/include/linux/lustre_compat25.h
lustre/include/linux/obd.h
lustre/include/obd.h
lustre/llite/llite_lib.c
lustre/llite/namei.c
lustre/llite/vvp_dev.c
lustre/lvfs/fsfilt_ext3.c
lustre/obdclass/obd_mount.c

index 9e76a50..7bc7af3 100644 (file)
@@ -491,9 +491,6 @@ static inline int request_module(const char *name, ...)
 #define MODULE_PARM(a, b)
 #define MODULE_PARM_DESC(a, b)
 
-#define KERNEL_VERSION(a,b,c) ((a)*100+(b)*10+c)
-#define LINUX_VERSION_CODE KERNEL_VERSION(2,5,0)
-
 #define NR_IRQS                                512
 #define in_interrupt()                 ml_at_interrupt_context()
 
index 988e9b5..4cf73c6 100644 (file)
@@ -1174,12 +1174,6 @@ sigpending(cfs_sigset_t *what) {
 
 
 /*
- *  Linux kernel version definition
- */
-
-#define KERNEL_VERSION(a,b,c) ((a)*100+(b)*10+c)
-
-/*
  *  linux ioctl coding definitions
  */
  
index 43b2496..81fa932 100644 (file)
@@ -572,22 +572,6 @@ libcfs_sock_listen (struct socket **sockp,
 
 EXPORT_SYMBOL(libcfs_sock_listen);
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
-int sock_create_lite(int family, int type, int protocol, struct socket **res)
-{
-        struct socket *sock;
-
-        sock = sock_alloc();
-        if (sock == NULL)
-                return -ENOMEM;
-
-        sock->type = type;
-        *res = sock;
-
-        return 0;
-}
-#endif
-
 int
 libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
 {
index ae9f5b7..a375342 100644 (file)
@@ -1014,25 +1014,11 @@ ksocknal_lib_setup_sock (struct socket *sock)
         return (0);
 }
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10))
-#define sock2tcp_opt(sk) tcp_sk(sk)
-#else
-struct tcp_opt *sock2tcp_opt(struct sock *sk)
-{
-        struct tcp_sock *s = (struct tcp_sock *)sk;
-        return &s->tcp;
-}
-#endif
-
 void
 ksocknal_lib_push_conn (ksock_conn_t *conn)
 {
         struct sock    *sk;
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
-        struct tcp_opt *tp;
-#else
         struct tcp_sock *tp;
-#endif
         int             nonagle;
         int             val = 1;
         int             rc;
@@ -1042,8 +1028,8 @@ ksocknal_lib_push_conn (ksock_conn_t *conn)
         if (rc != 0)                            /* being shut down */
                 return;
 
-        sk = conn->ksnc_sock->sk;
-        tp = sock2tcp_opt(sk);
+       sk = conn->ksnc_sock->sk;
+       tp = tcp_sk(sk);
 
         lock_sock (sk);
         nonagle = tp->nonagle;
index 8afeaaa..4e10448 100644 (file)
@@ -65,10 +65,6 @@ typedef unsigned short cfs_umode_t;
 
 #endif
 
-/* always adopt 2.6.9 definitions */
-#define KERNEL_VERSION(a,b,c) ((a)*100+(b)*10+c)
-#define LINUX_VERSION_CODE KERNEL_VERSION(2,6,9)
-
 #ifndef page_private
 #define page_private(page) ((page)->private)
 #define set_page_private(page, v) ((page)->private = (v))
@@ -205,8 +201,6 @@ struct iattr {
         unsigned int    ia_attr_flags;
 };
 
-#define ll_iattr iattr
-
 /* defined in kernel header include/linux/namei.h */
 #define INTENT_MAGIC 0x19620323
 
index f3f4cf4..dcbbda8 100644 (file)
 
 #ifdef __KERNEL__
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
-#error sorry, lustre requires at least linux kernel 2.6.9 or later
-#endif
-
 #include <linux/fs_struct.h>
 #include <linux/namei.h>
 #include <libcfs/linux/portals_compat25.h>
  #define SEEK_END 2
 #endif
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
-struct ll_iattr {
-        struct iattr    iattr;
-        unsigned int    ia_attr_flags;
-};
-#else
-#define ll_iattr iattr
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) */
-
 #ifdef HAVE_FS_STRUCT_RWLOCK
 # define LOCK_FS_STRUCT(fs)   cfs_write_lock(&(fs)->lock)
 # define UNLOCK_FS_STRUCT(fs) cfs_write_unlock(&(fs)->lock)
@@ -121,11 +108,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
  */
 #define ATTR_BLOCKS    (1 << 27)
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
-#define d_child d_u.d_child
-#define d_rcu d_u.d_rcu
-#endif
-
 #define current_ngroups current_cred()->group_info->ngroups
 #define current_groups current_cred()->group_info->small_block
 
index 5ece5fd..0566456 100644 (file)
 # include <linux/lustre_intent.h>
 #endif
 
+struct ll_iattr {
+       struct iattr    iattr;
+       unsigned int    ia_attr_flags;
+};
+
 #define CLIENT_OBD_LIST_LOCK_DEBUG 1
 typedef struct {
         cfs_spinlock_t          lock;
index d5818a1..80f8ec7 100644 (file)
@@ -1281,9 +1281,7 @@ struct md_op_data {
         /* iattr fields and blocks. */
         struct iattr            op_attr;
 #ifdef __KERNEL__
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
-        unsigned int            op_attr_flags;
-#endif
+       unsigned int            op_attr_flags;
 #endif
         __u64                   op_valid;
         loff_t                  op_attr_blocks;
index f6dd8ac..1a24d72 100644 (file)
@@ -639,10 +639,10 @@ void lustre_dump_dentry(struct dentry *dentry, int recur)
         if (recur == 0)
                 return;
 
-       list_for_each(tmp, &dentry->d_subdirs) {
-                struct dentry *d = list_entry(tmp, struct dentry, d_child);
-                lustre_dump_dentry(d, recur - 1);
-        }
+       list_for_each(tmp, &dentry->d_subdirs) {
+               struct dentry *d = list_entry(tmp, struct dentry, d_u.d_child);
+               lustre_dump_dentry(d, recur - 1);
+       }
 }
 
 void client_common_put_super(struct super_block *sb)
index e73f203..7521e3d 100644 (file)
@@ -177,7 +177,7 @@ static void ll_invalidate_negative_children(struct inode *dir)
 
                        list_for_each_entry_safe(child, tmp_subdir,
                                                 &dentry->d_subdirs,
-                                                d_child) {
+                                                d_u.d_child) {
                                if (child->d_inode == NULL)
                                        d_lustre_invalidate(child);
                        }
@@ -580,13 +580,6 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,
         if (nd && !(nd->flags & (LOOKUP_CONTINUE|LOOKUP_PARENT))) {
                 struct lookup_intent *it;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)
-                /* Did we came here from failed revalidate just to propagate
-                 * its error? */
-                if (nd->flags & LOOKUP_OPEN)
-                        if (IS_ERR(nd->intent.open.file))
-                                RETURN((struct dentry *)nd->intent.open.file);
-#endif
                 if (ll_d2d(dentry) && ll_d2d(dentry)->lld_it) {
                         it = ll_d2d(dentry)->lld_it;
                         ll_d2d(dentry)->lld_it = NULL;
index 90f43b2..b203de3 100644 (file)
@@ -430,9 +430,6 @@ static void vvp_pgcache_page_show(const struct lu_env *env,
         seq_page_flag(seq, vmpage, referenced, has_flags);
         seq_page_flag(seq, vmpage, uptodate, has_flags);
         seq_page_flag(seq, vmpage, dirty, has_flags);
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,12))
-        seq_page_flag(seq, vmpage, highmem, has_flags);
-#endif
         seq_page_flag(seq, vmpage, writeback, has_flags);
         seq_printf(seq, "%s]\n", has_flags ? "" : "-");
 }
index 9c1cf63..ac96837 100644 (file)
@@ -94,14 +94,6 @@ extern int ext3_xattr_set_handle(handle_t *, struct inode *, int, const char *,
 
 #include "lustre_quota_fmt.h"
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
-#define FSFILT_DATA_TRANS_BLOCKS(sb)      EXT3_DATA_TRANS_BLOCKS
-#define FSFILT_DELETE_TRANS_BLOCKS(sb)    EXT3_DELETE_TRANS_BLOCKS
-#else
-#define FSFILT_DATA_TRANS_BLOCKS(sb)      EXT3_DATA_TRANS_BLOCKS(sb)
-#define FSFILT_DELETE_TRANS_BLOCKS(sb)    EXT3_DELETE_TRANS_BLOCKS(sb)
-#endif
-
 /* for kernels 2.6.18 and later */
 #define FSFILT_SINGLEDATA_TRANS_BLOCKS(sb) EXT3_SINGLEDATA_TRANS_BLOCKS(sb)
 
@@ -252,11 +244,11 @@ static void *fsfilt_ext3_start(struct inode *inode, int op, void *desc_private,
         switch(op) {
         case FSFILT_OP_RMDIR:
         case FSFILT_OP_UNLINK:
-                /* delete one file + create/update logs for each stripe */
-                nblocks += FSFILT_DELETE_TRANS_BLOCKS(inode->i_sb);
-                nblocks += (EXT3_INDEX_EXTRA_TRANS_BLOCKS +
-                            FSFILT_SINGLEDATA_TRANS_BLOCKS(inode->i_sb)) * logs;
-                break;
+               /* delete one file + create/update logs for each stripe */
+               nblocks += EXT3_DELETE_TRANS_BLOCKS(inode->i_sb);
+               nblocks += (EXT3_INDEX_EXTRA_TRANS_BLOCKS +
+                           FSFILT_SINGLEDATA_TRANS_BLOCKS(inode->i_sb)) * logs;
+               break;
         case FSFILT_OP_RENAME:
                 /* modify additional directory */
                 nblocks += FSFILT_SINGLEDATA_TRANS_BLOCKS(inode->i_sb);
@@ -275,17 +267,17 @@ static void *fsfilt_ext3_start(struct inode *inode, int op, void *desc_private,
                 /* no break */
         case FSFILT_OP_LINK:
                 /* modify parent directory */
-                nblocks += EXT3_INDEX_EXTRA_TRANS_BLOCKS +
-                         FSFILT_DATA_TRANS_BLOCKS(inode->i_sb);
+               nblocks += EXT3_INDEX_EXTRA_TRANS_BLOCKS +
+                          EXT3_DATA_TRANS_BLOCKS(inode->i_sb);
                 /* create/update logs for each stripe */
                 nblocks += (EXT3_INDEX_EXTRA_TRANS_BLOCKS +
                             FSFILT_SINGLEDATA_TRANS_BLOCKS(inode->i_sb)) * logs;
                 break;
         case FSFILT_OP_SETATTR:
                 /* Setattr on inode */
-                nblocks += 1;
-                nblocks += EXT3_INDEX_EXTRA_TRANS_BLOCKS +
-                         FSFILT_DATA_TRANS_BLOCKS(inode->i_sb);
+               nblocks += 1;
+               nblocks += EXT3_INDEX_EXTRA_TRANS_BLOCKS +
+                          EXT3_DATA_TRANS_BLOCKS(inode->i_sb);
                 /* quota chown log for each stripe */
                 nblocks += (EXT3_INDEX_EXTRA_TRANS_BLOCKS +
                             FSFILT_SINGLEDATA_TRANS_BLOCKS(inode->i_sb)) * logs;
@@ -293,9 +285,9 @@ static void *fsfilt_ext3_start(struct inode *inode, int op, void *desc_private,
         case FSFILT_OP_CANCEL_UNLINK:
                 /* blocks for log header bitmap update OR
                  * blocks for catalog header bitmap update + unlink of logs */
-                nblocks = (LLOG_CHUNK_SIZE >> inode->i_blkbits) +
-                        FSFILT_DELETE_TRANS_BLOCKS(inode->i_sb) * logs;
-                break;
+               nblocks = (LLOG_CHUNK_SIZE >> inode->i_blkbits) +
+                       EXT3_DELETE_TRANS_BLOCKS(inode->i_sb) * logs;
+               break;
         default: CERROR("unknown transaction start op %d\n", op);
                 LBUG();
         }
@@ -389,8 +381,8 @@ static int fsfilt_ext3_credits_needed(int objcount, struct fsfilt_objinfo *fso,
 
         needed += nbitmaps + ngdblocks;
 
-        /* last_rcvd update */
-        needed += FSFILT_DATA_TRANS_BLOCKS(sb);
+       /* last_rcvd update */
+       needed += EXT3_DATA_TRANS_BLOCKS(sb);
 
 #if defined(CONFIG_QUOTA)
         /* We assume that there will be 1 bit set in s_dquot.flags for each
@@ -825,14 +817,6 @@ static int fsfilt_ext3_sync(struct super_block *sb)
 #define EXT3_EXTENTS_FL                 0x00080000 /* Inode uses extents */
 #endif
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
-# define fsfilt_up_truncate_sem(inode)  up(&LDISKFS_I(inode)->truncate_sem);
-# define fsfilt_down_truncate_sem(inode)  down(&LDISKFS_I(inode)->truncate_sem);
-#else
-# define fsfilt_up_truncate_sem(inode) do{ }while(0)
-# define fsfilt_down_truncate_sem(inode) do{ }while(0)
-#endif
-
 #ifndef EXT_ASSERT
 #define EXT_ASSERT(cond)  BUG_ON(!(cond))
 #endif
@@ -994,17 +978,14 @@ static int ext3_ext_new_extent_cb(struct ext3_ext_base *base,
                 return EXT_CONTINUE;
         }
 
-        tgen = EXT_GENERATION(base);
-        count = ext3_ext_calc_credits_for_insert(base, path);
-        fsfilt_up_truncate_sem(inode);
+       tgen = EXT_GENERATION(base);
+       count = ext3_ext_calc_credits_for_insert(base, path);
 
-        handle = ext3_journal_start(inode, count+EXT3_ALLOC_NEEDED+1);
-        if (IS_ERR(handle)) {
-                fsfilt_down_truncate_sem(inode);
-                return PTR_ERR(handle);
-        }
+       handle = ext3_journal_start(inode, count+EXT3_ALLOC_NEEDED+1);
+       if (IS_ERR(handle)) {
+               return PTR_ERR(handle);
+       }
 
-        fsfilt_down_truncate_sem(inode);
         if (tgen != EXT_GENERATION(base)) {
                 /* the tree has changed. so path can be invalid at moment */
                 ext3_journal_stop(handle);
@@ -1124,11 +1105,9 @@ int fsfilt_map_nblocks(struct inode *inode, unsigned long block,
         bp.init_num = bp.num = num;
         bp.create = create;
 
-        fsfilt_down_truncate_sem(inode);
-        err = fsfilt_ext3_ext_walk_space(base, block, num,
-                                         ext3_ext_new_extent_cb, &bp);
-        ext3_ext_invalidate_cache(base);
-        fsfilt_up_truncate_sem(inode);
+       err = fsfilt_ext3_ext_walk_space(base, block, num,
+                                        ext3_ext_new_extent_cb, &bp);
+       ext3_ext_invalidate_cache(base);
 
         return err;
 }
@@ -1362,13 +1341,14 @@ static int fsfilt_ext3_write_record(struct file *file, void *buf, int bufsize,
         block_count = (*offs & (blocksize - 1)) + bufsize;
         block_count = (block_count + blocksize - 1) >> inode->i_blkbits;
 
-        handle = ext3_journal_start(inode,
-                               block_count * FSFILT_DATA_TRANS_BLOCKS(inode->i_sb) + 2);
-        if (IS_ERR(handle)) {
-                CERROR("can't start transaction for %d blocks (%d bytes)\n",
-                       block_count * FSFILT_DATA_TRANS_BLOCKS(inode->i_sb) + 2, bufsize);
-                return PTR_ERR(handle);
-        }
+       handle = ext3_journal_start(inode,
+                       block_count * EXT3_DATA_TRANS_BLOCKS(inode->i_sb) + 2);
+       if (IS_ERR(handle)) {
+               CERROR("can't start transaction for %d blocks (%d bytes)\n",
+                      block_count * EXT3_DATA_TRANS_BLOCKS(inode->i_sb) + 2,
+                      bufsize);
+               return PTR_ERR(handle);
+       }
 
         err = fsfilt_ext3_write_handle(inode, buf, bufsize, offs, handle);
 
@@ -1382,8 +1362,7 @@ static int fsfilt_ext3_write_record(struct file *file, void *buf, int bufsize,
 
 static int fsfilt_ext3_setup(struct super_block *sb)
 {
-#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,6)) && \
-     defined(HAVE_QUOTA_SUPPORT)) || defined(S_PDIROPS)
+#if defined(HAVE_QUOTA_SUPPORT) || defined(S_PDIROPS)
         struct ext3_sb_info *sbi = EXT3_SB(sb);
 #if 0
         sbi->dx_lock = fsfilt_ext3_dx_lock;
@@ -1403,7 +1382,7 @@ static int fsfilt_ext3_setup(struct super_block *sb)
 #endif
         if (!EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_DIR_INDEX))
                 CWARN("filesystem doesn't have dir_index feature enabled\n");
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,6)) && defined(HAVE_QUOTA_SUPPORT)
+#ifdef HAVE_QUOTA_SUPPORT
         /* enable journaled quota support */
         /* kfreed in ext3_put_super() */
         sbi->s_qf_names[USRQUOTA] = kstrdup("lquota.user.reserved", GFP_KERNEL);
@@ -1416,10 +1395,8 @@ static int fsfilt_ext3_setup(struct super_block *sb)
                 return -ENOMEM;
         }
         sbi->s_jquota_fmt = QFMT_LUSTRE;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13))
         set_opt(sbi->s_mount_opt, QUOTA);
 #endif
-#endif
         return 0;
 }
 
@@ -2233,17 +2210,17 @@ void *lustre_quota_journal_start(struct inode *inode, int delete)
                 /* each indirect block (+4) may become free, attaching to the
                  * header list of free blocks (+1); the data block (+1) may
                  * become a free block (+0) or a block with free dqentries (+0) */
-                block_count = (4 + 1) + 1;
-                handle = ext3_journal_start(inode,
-                            block_count*FSFILT_DATA_TRANS_BLOCKS(inode->i_sb)+2);
+               block_count = (4 + 1) + 1;
+               handle = ext3_journal_start(inode,
+                            block_count*EXT3_DATA_TRANS_BLOCKS(inode->i_sb)+2);
         } else {
                 /* indirect blocks are touched (+4), each causes file expansion (+0) or
                  * freeblk reusage with a header update (+1); dqentry is either reused
                  * causing update of the entry block (+1), prev (+1) and next (+1) or
                  * a new block allocation (+1) with a header update (+1)              */
-                block_count = (4 + 1) + 3;
-                handle = ext3_journal_start(inode,
-                             block_count*FSFILT_DATA_TRANS_BLOCKS(inode->i_sb)+2);
+               block_count = (4 + 1) + 3;
+               handle = ext3_journal_start(inode,
+                            block_count*EXT3_DATA_TRANS_BLOCKS(inode->i_sb)+2);
 
         }
 
index e2cd921..56a4492 100644 (file)
@@ -2567,13 +2567,6 @@ void lustre_register_kill_super_cb(void (*cfs)(struct super_block *sb))
 
 /***************** FS registration ******************/
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
-struct super_block * lustre_get_sb(struct file_system_type *fs_type, int flags,
-                                   const char *devname, void * data)
-{
-        return get_sb_nodev(fs_type, flags, data, lustre_fill_super);
-}
-#else
 int lustre_get_sb(struct file_system_type *fs_type, int flags,
                   const char *devname, void * data, struct vfsmount *mnt)
 {
@@ -2581,7 +2574,6 @@ int lustre_get_sb(struct file_system_type *fs_type, int flags,
 
         return get_sb_nodev(fs_type, flags, &lmd2, lustre_fill_super, mnt);
 }
-#endif
 
 void lustre_kill_super(struct super_block *sb)
 {