From 903f02ad3cb37940b1cadce598a2a802b940ad37 Mon Sep 17 00:00:00 2001 From: shadow Date: Wed, 21 Nov 2007 12:25:30 +0000 Subject: [PATCH] fix building problem with 2.6.22 kernel. b=14255 i=adilger --- lustre/autoconf/lustre-core.m4 | 69 +++++++++++++++++++++++++++++++++- lustre/include/linux/lustre_compat25.h | 17 +++++++++ lustre/llite/llite_nfs.c | 3 ++ lustre/llite/lloop.c | 6 ++- 4 files changed, 92 insertions(+), 3 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 23fa733..75758bc 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1163,6 +1163,65 @@ AC_DEFUN([LC_EXPORT_NODE_TO_CPUMASK], the kernel])]) # i386 ]) +# 2.6.22 lost second parameter for invalidate_bdev +AC_DEFUN([LC_INVALIDATE_BDEV_2ARG], +[AC_MSG_CHECKING([if invalidate_bdev has second argument]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + invalidate_bdev(NULL,0); +],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_INVALIDATE_BDEV_2ARG, 1, + [invalidate_bdev has second argument]) +],[ + AC_MSG_RESULT([no]) +]) +]) + +# 2.6.23 have return type 'void' for unregister_blkdev +AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT], +[AC_MSG_CHECKING([if unregister_blkdev return int]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + int i = unregister_blkdev(0,NULL); +],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_UNREGISTER_BLKDEV_RETURN_INT, 1, + [unregister_blkdev return int]) +],[ + AC_MSG_RESULT([no]) +]) +]) + +# 2.6.23 change .sendfile to .splice_read +AC_DEFUN([LC_KERNEL_SPLICE_READ], +[AC_MSG_CHECKING([if kernel has .splice_read]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + struct file_operations file; + + file.splice_read = NULL; +], [ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_KERNEL_SPLICE_READ, 1, + [kernel has .slice_read]) +],[ + AC_MSG_RESULT([no]) +]) +]) + +# 2.6.23 extract nfs export related data into exportfs.h +AC_DEFUN([LC_HAVE_EXPORTFS_H], +[ +tmpfl="$CFLAGS" +CFLAGS="$CFLAGS -I$LINUX_OBJ/include" +AC_CHECK_HEADERS([linux/exportfs.h]) +CFLAGS="$tmpfl" +]) + # # LC_VFS_INTENT_PATCHES # @@ -1380,7 +1439,15 @@ AC_DEFUN([LC_PROG_LINUX], LC_CANCEL_DIRTY_PAGE # raid5-zerocopy patch - LC_PAGE_CONSTANT]) + LC_PAGE_CONSTANT + + # 2.6.22 + LC_INVALIDATE_BDEV_2ARG + # 2.6.23 + LC_UNREGISTER_BLKDEV_RETURN_INT + LC_KERNEL_SPLICE_READ + LC_HAVE_EXPORTFS_H +]) # # LC_CONFIG_CLIENT_SERVER diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index b72ea7f..633b7b0 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -354,5 +354,22 @@ static inline u32 get_sb_time_gran(struct super_block *sb) #define TREE_READ_UNLOCK_IRQ(mapping) spin_unlock_irq(&(mapping)->tree_lock) #endif +#ifdef HAVE_UNREGISTER_BLKDEV_RETURN_INT +#define ll_unregister_blkdev(a,b) unregister_blkdev((a),(b)) +#else +static inline +int ll_unregister_blkdev(unsigned int dev, const char *name) +{ + unregister_blkdev(dev, name); + return 0; +} +#endif + +#ifdef HAVE_INVALIDATE_BDEV_2ARG +#define ll_invalidate_bdev(a,b) invalidate_bdev((a),(b)) +#else +#define ll_invalidate_bdev(a,b) invalidate_bdev((a)) +#endif + #endif /* __KERNEL__ */ #endif /* _COMPAT25_H */ diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c index a568f0a..754e49d 100644 --- a/lustre/llite/llite_nfs.c +++ b/lustre/llite/llite_nfs.c @@ -27,6 +27,9 @@ #define DEBUG_SUBSYSTEM S_LLITE #include #include "llite_internal.h" +#ifdef HAVE_LINUX_EXPORTFS_H +#include +#endif static int ll_nfs_test_inode(struct inode *inode, void *opaque) { diff --git a/lustre/llite/lloop.c b/lustre/llite/lloop.c index ad30120..28c5b34 100644 --- a/lustre/llite/lloop.c +++ b/lustre/llite/lloop.c @@ -73,7 +73,9 @@ * */ +#ifndef AUTOCONF_INCLUDED #include +#endif #include #include @@ -483,7 +485,7 @@ static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev, lo->lo_offset = 0; lo->lo_sizelimit = 0; lo->lo_flags = 0; - invalidate_bdev(bdev, 0); + ll_invalidate_bdev(bdev, 0); set_capacity(disks[lo->lo_number], 0); bd_set_size(bdev, 0); mapping_set_gfp_mask(filp->f_mapping, gfp); @@ -753,7 +755,7 @@ static void lloop_exit(void) blk_put_queue(loop_dev[i].lo_queue); put_disk(disks[i]); } - if (unregister_blkdev(lloop_major, "lloop")) + if (ll_unregister_blkdev(lloop_major, "lloop")) CWARN("lloop: cannot unregister blkdev\n"); kfree(disks); -- 1.8.3.1