From 7b49a683a689fdd538da8b9d86362b7534840b59 Mon Sep 17 00:00:00 2001 From: shadow <shadow> Date: Wed, 21 Nov 2007 12:11:10 +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 e1e4eb6cf7..16069ddbbc 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1151,6 +1151,65 @@ LB_LINUX_TRY_COMPILE([ ]) ]) +# 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 <linux/buffer_head.h> +],[ + 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 <linux/fs.h> +],[ + 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 <linux/fs.h> +],[ + 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_PROG_LINUX # @@ -1236,7 +1295,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 e216129451..4ee81fbd5d 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -554,5 +554,22 @@ generic_file_write(struct file *filp, const char __user *buf, size_t len, loff_t #define p_pptr parent #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 2f9add926a..6ba424a691 100644 --- a/lustre/llite/llite_nfs.c +++ b/lustre/llite/llite_nfs.c @@ -24,6 +24,9 @@ #define DEBUG_SUBSYSTEM S_LLITE #include <lustre_lite.h> #include "llite_internal.h" +#ifdef HAVE_LINUX_EXPORTFS_H +#include <linux/exportfs.h> +#endif __u32 get_uuid2int(const char *name, int len) { diff --git a/lustre/llite/lloop.c b/lustre/llite/lloop.c index 7d9e857aa8..f42fd4a7c0 100644 --- a/lustre/llite/lloop.c +++ b/lustre/llite/lloop.c @@ -73,7 +73,9 @@ * */ +#ifndef AUTOCONF_INCLUDED #include <linux/config.h> +#endif #include <linux/module.h> #include <linux/sched.h> @@ -478,7 +480,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); @@ -746,7 +748,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); -- GitLab