From 774512ea1e17efb99713e29f4dff03c71843b211 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Sat, 25 Feb 2012 12:20:49 +0800 Subject: [PATCH] LU-709 build: cleanup VFS_KERN_MOUNT/INVALIDATEPAGE_RETURN_INT 1. vfs_kern_mount is added since v2.6.18 2. invalidatepage returns void since v2.6.17 Signed-off-by: Peng Tao Change-Id: I9926072d2d519c64ef927e02a13a6e9b0c72f2af Reviewed-on: http://review.whamcloud.com/2320 Reviewed-by: Andreas Dilger Tested-by: Hudson Tested-by: Maloo --- lustre/autoconf/lustre-core.m4 | 41 ---------------------------------- lustre/include/linux/lustre_compat25.h | 16 ------------- lustre/llite/rw26.c | 18 +-------------- lustre/obdclass/obd_mount.c | 20 +++++++++++++---- lustre/obdfilter/filter.c | 12 +++++++--- 5 files changed, 26 insertions(+), 81 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index b1ef9c2..b0dcb51 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -840,45 +840,6 @@ LB_LINUX_TRY_COMPILE([ EXTRA_KCFLAGS="$tmp_flags" ]) -# -# LC_VFS_KERN_MOUNT -# starting from 2.6.18 kernel don't export do_kern_mount -# and want to use vfs_kern_mount instead. -# -AC_DEFUN([LC_VFS_KERN_MOUNT], -[AC_MSG_CHECKING([vfs_kern_mount exist in kernel]) -LB_LINUX_TRY_COMPILE([ - #include -],[ - vfs_kern_mount(NULL, 0, NULL, NULL); -],[ - AC_DEFINE(HAVE_VFS_KERN_MOUNT, 1, - [vfs_kern_mount exist in kernel]) - AC_MSG_RESULT([yes]) -],[ - AC_MSG_RESULT([no]) -]) -]) - -# -# LC_INVALIDATEPAGE_RETURN_INT -# 2.6.17 changes return type for invalidatepage to 'void' from 'int' -# -AC_DEFUN([LC_INVALIDATEPAGE_RETURN_INT], -[AC_MSG_CHECKING([invalidatepage has return int]) -LB_LINUX_TRY_COMPILE([ - #include -],[ - int rc = block_invalidatepage(NULL, 0); -],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_INVALIDATEPAGE_RETURN_INT, 1, - [Define if return type of invalidatepage should be int]) -],[ - AC_MSG_RESULT(no) -]) -]) - # LC_UMOUNTBEGIN_HAS_VFSMOUNT # after 2.6.18 umount_begin has different parameters AC_DEFUN([LC_UMOUNTBEGIN_HAS_VFSMOUNT], @@ -2179,8 +2140,6 @@ AC_DEFUN([LC_PROG_LINUX], # 2.6.18 LC_NR_PAGECACHE LC_STATFS_DENTRY_PARAM - LC_VFS_KERN_MOUNT - LC_INVALIDATEPAGE_RETURN_INT LC_UMOUNTBEGIN_HAS_VFSMOUNT LC_SEQ_LOCK LC_EXPORT_FILEMAP_FDATAWRITE_RANGE diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index d2939b5..d6d46e4 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -385,22 +385,6 @@ int filemap_fdatawrite_range(struct address_space *mapping, loff_t start, loff_t end); #endif /* HAVE_FILEMAP_FDATAWRITE_RANGE */ -#ifdef HAVE_VFS_KERN_MOUNT -static inline struct vfsmount * -ll_kern_mount(const char *fstype, int flags, const char *name, void *data) -{ - struct file_system_type *type = get_fs_type(fstype); - struct vfsmount *mnt; - if (!type) - return ERR_PTR(-ENODEV); - mnt = vfs_kern_mount(type, flags, name, data); - cfs_module_put(type->owner); - return mnt; -} -#else -#define ll_kern_mount(fstype, flags, name, data) do_kern_mount((fstype), (flags), (name), (data)) -#endif - #ifndef HAVE_ATOMIC_MNT_COUNT static inline unsigned int mnt_get_count(struct vfsmount *mnt) { diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 4577bc8..4e0a189 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -79,14 +79,13 @@ * aligned truncate). Lustre leaves partially truncated page in the cache, * relying on struct inode::i_size to limit further accesses. */ -static int cl_invalidatepage(struct page *vmpage, unsigned long offset) +static void ll_invalidatepage(struct page *vmpage, unsigned long offset) { struct inode *inode; struct lu_env *env; struct cl_page *page; struct cl_object *obj; - int result; int refcheck; LASSERT(PageLocked(vmpage)); @@ -97,7 +96,6 @@ static int cl_invalidatepage(struct page *vmpage, unsigned long offset) * below because they are run with page locked and all our io is * happening with locked page too */ - result = 0; if (offset == 0) { env = cl_env_get(&refcheck); if (!IS_ERR(env)) { @@ -109,7 +107,6 @@ static int cl_invalidatepage(struct page *vmpage, unsigned long offset) lu_ref_add(&page->cp_reference, "delete", vmpage); cl_page_delete(env, page); - result = 1; lu_ref_del(&page->cp_reference, "delete", vmpage); cl_page_put(env, page); @@ -119,20 +116,7 @@ static int cl_invalidatepage(struct page *vmpage, unsigned long offset) cl_env_put(env, &refcheck); } } - return result; -} - -#ifdef HAVE_INVALIDATEPAGE_RETURN_INT -static int ll_invalidatepage(struct page *page, unsigned long offset) -{ - return cl_invalidatepage(page, offset); -} -#else /* !HAVE_INVALIDATEPAGE_RETURN_INT */ -static void ll_invalidatepage(struct page *page, unsigned long offset) -{ - cl_invalidatepage(page, offset); } -#endif #ifdef HAVE_RELEASEPAGE_WITH_INT #define RELEASEPAGE_ARG_TYPE int diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index fe9de98..c57916b 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -1405,6 +1405,7 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb) struct lustre_disk_data *ldd; struct lustre_mount_data *lmd = lsi->lsi_lmd; struct vfsmount *mnt; + struct file_system_type *type; char *options = NULL; unsigned long page, s_flags; struct page *__page; @@ -1436,7 +1437,13 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb) /* Pre-mount ldiskfs to read the MOUNT_DATA_FILE */ CDEBUG(D_MOUNT, "Pre-mount ldiskfs %s\n", lmd->lmd_dev); - mnt = ll_kern_mount("ldiskfs", s_flags, lmd->lmd_dev, (void *)options); + type = get_fs_type("ldiskfs"); + if (!type) { + CERROR("premount failed: cannot find ldiskfs module\n"); + GOTO(out_free, rc = -ENODEV); + } + mnt = vfs_kern_mount(type, s_flags, lmd->lmd_dev, (void *)options); + cfs_module_put(type->owner); if (IS_ERR(mnt)) { rc = PTR_ERR(mnt); CERROR("premount %s:%#lx ldiskfs failed: %d " @@ -1482,11 +1489,16 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb) CDEBUG(D_MOUNT, "kern_mount: %s %s %s\n", MT_STR(ldd), lmd->lmd_dev, options); - mnt = ll_kern_mount(MT_STR(ldd), s_flags, lmd->lmd_dev, - (void *)options); + type = get_fs_type(MT_STR(ldd)); + if (!type) { + CERROR("get_fs_type failed\n"); + GOTO(out_free, rc = -ENODEV); + } + mnt = vfs_kern_mount(type, s_flags, lmd->lmd_dev, (void *)options); + cfs_module_put(type->owner); if (IS_ERR(mnt)) { rc = PTR_ERR(mnt); - CERROR("ll_kern_mount failed: rc = %d\n", rc); + CERROR("vfs_kern_mount failed: rc = %d\n", rc); GOTO(out_free, rc); } diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 527b02f..9dc6584 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -1969,6 +1969,7 @@ int filter_common_setup(struct obd_device *obd, struct lustre_cfg* lcfg, { struct filter_obd *filter = &obd->u.filter; struct vfsmount *mnt; + struct file_system_type *type; struct lustre_mount_info *lmi; struct obd_uuid uuid; __u8 *uuid_ptr; @@ -1993,9 +1994,14 @@ int filter_common_setup(struct obd_device *obd, struct lustre_cfg* lcfg, } else { /* old path - used by lctl */ CERROR("Using old MDS mount method\n"); - mnt = ll_kern_mount(lustre_cfg_string(lcfg, 2), - MS_NOATIME|MS_NODIRATIME, - lustre_cfg_string(lcfg, 1), option); + type = get_fs_type(lustre_cfg_string(lcfg, 2)); + if (!type) { + CERROR("get_fs_type failed\n"); + RETURN(-ENODEV); + } + mnt = vfs_kern_mount(type, MS_NOATIME|MS_NODIRATIME, + lustre_cfg_string(lcfg, 1), option); + cfs_module_put(type->owner); if (IS_ERR(mnt)) { rc = PTR_ERR(mnt); LCONSOLE_ERROR_MSG(0x135, "Can't mount disk %s (%d)\n", -- 1.8.3.1