From: James Simmons Date: Fri, 13 Jul 2012 13:22:55 +0000 (-0400) Subject: LU-1497 client: SLES11 SP0 client build is broken. X-Git-Tag: 2.2.92~10 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=2c84a5f145e1c28e43c1b8174fc42c7dd58f86e1 LU-1497 client: SLES11 SP0 client build is broken. With the addition of client improvements new linux kernel apis are exposed to the llite layer. Those apis can be missing or have a different format in earlier kernels. This is the case for SLES11 SP0 clients for the case of the vma handling and the function inode_newsize_ok that is missing. This patch fixes those issues. Final bug is a fix to a configure test for a function from the linux crypto api. Signed-off-by: James Simmons Change-Id: I699c67baec030e61133ff0a44e0ab03261b2f2d0 Reviewed-on: http://review.whamcloud.com/3063 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin --- diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index 8ff37b5..da15da9 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -101,13 +101,10 @@ AC_DEFUN([LIBCFS_DIGEST_SETKEY_FLAGS], LB_LINUX_TRY_COMPILE([ #include #include - - static int foo(struct crypto_tfm *tfm, const u8 *key, unsigned int l, u32* f) - { - return 1; - } ],[ - struct digest_alg alg = {.dia_setkey=foo}; + struct digest_alg alg; + + alg.dia_setkey(NULL, NULL, 0, NULL); ],[ AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_DIGEST_SETKEY_FLAGS, 1, [kernel dia_setkey takes 4 args]) @@ -116,7 +113,6 @@ LB_LINUX_TRY_COMPILE([ ]) ]) - # 2.6.19 API changes # kmem_cache_destroy(cachep) return void instead of # int diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 6ba9205..930ace4 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -941,7 +941,6 @@ LB_LINUX_TRY_COMPILE([ ]) ]) - # # 2.6.27 # @@ -982,6 +981,27 @@ LB_LINUX_TRY_COMPILE([ EXTRA_KCFLAGS="$tmp_flags" ]) +AC_DEFUN([LC_PGMKWRITE_COMPACT], +[AC_MSG_CHECKING([if kernel .page_mkwrite is located in vm_operation_struct._pmkw]) +tmp_flags="$EXTRA_KCFLAGS" +EXTRA_KCFLAGS="-Werror" +LB_LINUX_TRY_COMPILE([ + #include +],[ + struct vm_operations_struct *vm_ops; + + vm_ops = NULL; + vm_ops->_pmkw.page_mkwrite(NULL, NULL); +], [ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_PGMKWRITE_COMPACT, 1, + [kernel .page_mkwrite is located in vm_operation_struct._pmkw]) +],[ + AC_MSG_RESULT([no]) +]) +EXTRA_KCFLAGS="$tmp_flags" +]) + AC_DEFUN([LC_INODE_PERMISION_2ARGS], [AC_MSG_CHECKING([inode_operations->permission has two args]) LB_LINUX_TRY_COMPILE([ @@ -1253,6 +1273,22 @@ LB_LINUX_TRY_COMPILE([ # 2.6.32 +# 2.6.32 introduced inode_newsize_ok +AC_DEFUN([LC_VFS_INODE_NEWSIZE_OK], +[AC_MSG_CHECKING([if inode_newsize_ok is defined]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + return inode_newsize_ok(NULL, 0); +],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_VFS_INODE_NEWSIZE_OK, 1, + [inode_newsize_ok is defined]) +],[ + AC_MSG_RESULT(no) +]) +]) + # 2.6.32 changes cache_detail's member cache_request to cache_upcall # in kernel commit bc74b4f5e63a09fb78e245794a0de1e5a2716bbe AC_DEFUN([LC_CACHE_UPCALL], @@ -1819,6 +1855,7 @@ AC_DEFUN([LC_PROG_LINUX], # 2.6.27 LC_SECURITY_PLUG # for SLES10 SP2 LC_PGMKWRITE_USE_VMFAULT + LC_PGMKWRITE_COMPACT LC_INODE_PERMISION_2ARGS LC_FILE_REMOVE_SUID LC_TRYLOCKPAGE @@ -1857,6 +1894,7 @@ AC_DEFUN([LC_PROG_LINUX], LC_EXPORT_GENERIC_ERROR_REMOVE_PAGE LC_SELINUX_IS_ENABLED LC_EXPORT_ACCESS_PROCESS_VM + LC_VFS_INODE_NEWSIZE_OK # 2.6.35, 3.0.0 LC_FILE_FSYNC diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 674f47a..e62cff7 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1315,6 +1315,50 @@ static int ll_setattr_ost(struct inode *inode, struct iattr *attr) return rc; } +#ifndef HAVE_VFS_INODE_NEWSIZE_OK +/** + * inode_newsize_ok - may this inode be truncated to a given size + * @inode: the inode to be truncated + * @offset: the new size to assign to the inode + * @Returns: 0 on success, -ve errno on failure + * + * inode_newsize_ok will check filesystem limits and ulimits to check that the + * new inode size is within limits. inode_newsize_ok will also send SIGXFSZ + * when necessary. Caller must not proceed with inode size change if failure is + * returned. @inode must be a file (not directory), with appropriate + * permissions to allow truncate (inode_newsize_ok does NOT check these + * conditions). + * + * inode_newsize_ok must be called with i_mutex held. + */ +int inode_newsize_ok(const struct inode *inode, loff_t offset) +{ + if (inode->i_size < offset) { + unsigned long limit; + + limit = rlimit(RLIMIT_FSIZE); + if (limit != RLIM_INFINITY && offset > limit) + goto out_sig; + if (offset > inode->i_sb->s_maxbytes) + goto out_big; + } else { + /* + * truncation of in-use swapfiles is disallowed - it would + * cause subsequent swapout to scribble on the now-freed + * blocks. + */ + if (IS_SWAPFILE(inode)) + return -ETXTBSY; + } + + return 0; +out_sig: + send_sig(SIGXFSZ, current, 0); +out_big: + return -EFBIG; +} +#endif + /* If this inode has objects allocated to it (lsm != NULL), then the OST * object(s) determine the file size and mtime. Otherwise, the MDS will * keep these values until such a time that objects are allocated for it. diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c index ec74d35..2549bad 100644 --- a/lustre/llite/llite_mmap.c +++ b/lustre/llite/llite_mmap.c @@ -599,15 +599,18 @@ int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last) static struct vm_operations_struct ll_file_vm_ops = { #ifndef HAVE_VM_OP_FAULT - .nopage = ll_nopage, - .populate = ll_populate, - + .nopage = ll_nopage, + .populate = ll_populate, +#else + .fault = ll_fault, +#endif +#ifndef HAVE_PGMKWRITE_COMPACT + .page_mkwrite = ll_page_mkwrite, #else - .fault = ll_fault, + ._pmkw.page_mkwrite = ll_page_mkwrite, #endif - .page_mkwrite = ll_page_mkwrite, - .open = ll_vm_open, - .close = ll_vm_close, + .open = ll_vm_open, + .close = ll_vm_close, }; int ll_file_mmap(struct file *file, struct vm_area_struct * vma)