Whamcloud - gitweb
b=19808 2.6.29-fc11 patchless client support changes.
authorRahul Deshmukh <Rahul.Deshmukh@Sun.COM>
Thu, 28 Jan 2010 11:36:39 +0000 (17:06 +0530)
committerRobert Read <rread@sun.com>
Thu, 28 Jan 2010 19:13:44 +0000 (11:13 -0800)
Final changes (except build related changes) for adding FC11
patchless client support.

i=alexey.lyashkov
i=oleg.drokin

39 files changed:
build/autoconf/lustre-build.m4
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/curproc.h
libcfs/include/libcfs/linux/libcfs.h
libcfs/include/libcfs/linux/linux-tcpip.h
libcfs/include/libcfs/list.h
libcfs/include/libcfs/user-prim.h
libcfs/libcfs/linux/linux-curproc.c
libcfs/libcfs/linux/linux-module.c
libcfs/libcfs/linux/linux-prim.c
libcfs/libcfs/user-prim.c
libsysio/configure.in
lustre/autoconf/lustre-core.m4
lustre/include/liblustre.h
lustre/include/linux/lustre_compat25.h
lustre/include/lprocfs_status.h
lustre/include/lustre/ll_fiemap.h
lustre/include/lustre_dlm.h
lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_request.c
lustre/llite/dir.c
lustre/llite/llite_lib.c
lustre/llite/llite_nfs.c
lustre/llite/lloop.c
lustre/llite/lproc_llite.c
lustre/llite/namei.c
lustre/llite/remote_perm.c
lustre/llite/rw26.c
lustre/llite/xattr.c
lustre/lmv/lmv_obd.c
lustre/lov/lov_obd.c
lustre/lov/lov_pack.c
lustre/lvfs/lvfs_linux.c
lustre/mdc/mdc_lib.c
lustre/mdc/mdc_locks.c
lustre/mdc/mdc_request.c
lustre/obdclass/lprocfs_status.c
lustre/ptlrpc/sec.c
lustre/tests/test-framework.sh

index b85f5d5..10f1905 100644 (file)
@@ -274,7 +274,7 @@ if test x$RHEL_KERNEL = xyes; then
 else
        case $LINUXRELEASE in
        # ext4 was in 2.6.22-2.6.26 but not stable enough to use
-       2.6.2[0-6]*) enable_ext4='no' ;;
+       2.6.2[[0-9]]*) enable_ext4='no' ;;
        *)  LC_KERNEL_WITH_EXT4([enable_ext4='yes'],
                                [enable_ext4='no']) ;;
        esac
index 467874c..5d063ed 100644 (file)
@@ -508,7 +508,7 @@ AC_DEFUN([LIBCFS_NETWORK_NAMESPACE],
 LB_LINUX_TRY_COMPILE([
         #include <net/net_namespace.h>
 ],[
-        struct net *net = &init_ns;
+        struct net *net = &init_net;
 ],[
         AC_MSG_RESULT(yes)
         AC_DEFINE(HAVE_INIT_NET, 1,
@@ -644,6 +644,70 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+# LIBCFS_CRED_WRAPPERS
+#
+# wrappers for task's credentials are in sles11
+#
+AC_DEFUN([LIBCFS_CRED_WRAPPERS],
+[AC_MSG_CHECKING([if kernel has wrappers for task's credentials])
+LB_LINUX_TRY_COMPILE([
+       #include <linux/sched.h>
+],[
+       uid_t uid;
+
+       uid = current_uid();
+],[
+       AC_MSG_RESULT([yes])
+       AC_DEFINE(HAVE_CRED_WRAPPERS, 1, [task's cred wrappers found])
+],[
+       AC_MSG_RESULT([no])
+])
+])
+
+#
+# LN_STRUCT_CRED_IN_TASK
+#
+# struct cred was introduced in 2.6.29 to streamline credentials in task struct
+#
+AC_DEFUN([LIBCFS_STRUCT_CRED_IN_TASK],
+[AC_MSG_CHECKING([if kernel has struct cred])
+LB_LINUX_TRY_COMPILE([
+       #include <linux/sched.h>
+],[
+       struct task_struct *tsk = NULL;
+       tsk->real_cred = NULL;
+],[
+       AC_MSG_RESULT([yes])
+       AC_DEFINE(HAVE_STRUCT_CRED, 1, [struct cred found])
+],[
+       AC_MSG_RESULT([no])
+])
+])
+
+#
+# LIBCFS_FUNC_UNSHARE_FS_STRUCT
+#
+# unshare_fs_struct was introduced in 2.6.30 to prevent others to directly
+# mess with copy_fs_struct
+#
+AC_DEFUN([LIBCFS_FUNC_UNSHARE_FS_STRUCT],
+[AC_MSG_CHECKING([if kernel defines unshare_fs_struct()])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+       #include <linux/sched.h>
+       #include <linux/fs_struct.h>
+],[
+       unshare_fs_struct();
+],[
+       AC_MSG_RESULT([yes])
+       AC_DEFINE(HAVE_UNSHARE_FS_STRUCT, 1, [unshare_fs_struct found])
+],[
+       AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
 #
 # LIBCFS_PROG_LINUX
 #
@@ -687,6 +751,12 @@ LIBCFS_NETLINK_NETNS
 LIBCFS_FUNC_DUMP_TRACE
 # 2.6.26
 LIBCFS_SEM_COUNT
+# 2.6.27
+LIBCFS_CRED_WRAPPERS
+# 2.6.29
+LIBCFS_STRUCT_CRED_IN_TASK
+# 2.6.30
+LIBCFS_FUNC_UNSHARE_FS_STRUCT
 LIBCFS_SOCK_MAP_FD_2ARG
 ])
 
index b79caf1..332799b 100644 (file)
@@ -51,6 +51,8 @@
  */
 uid_t  cfs_curproc_uid(void);
 gid_t  cfs_curproc_gid(void);
+uid_t  cfs_curproc_euid(void);
+gid_t  cfs_curproc_egid(void);
 uid_t  cfs_curproc_fsuid(void);
 gid_t  cfs_curproc_fsgid(void);
 pid_t  cfs_curproc_pid(void);
index eb27038..acaac13 100644 (file)
@@ -129,4 +129,38 @@ typedef long long_ptr_t;
 #define WITH_WATCHDOG
 #endif
 
+#ifndef HAVE_STRUCT_CRED
+
+#define current_cred() (current)
+
+#define current_cred_xxx(xxx)                   \
+({                                              \
+        current->xxx;                     \
+})
+
+#ifndef HAVE_CRED_WRAPPERS
+
+#define current_uid()           (current_cred_xxx(uid))
+#define current_gid()           (current_cred_xxx(gid))
+#define current_euid()          (current_cred_xxx(euid))
+#define current_egid()          (current_cred_xxx(egid))
+#define current_suid()          (current_cred_xxx(suid))
+#define current_sgid()          (current_cred_xxx(sgid))
+#define current_fsuid()         (current_cred_xxx(fsuid))
+#define current_fsgid()         (current_cred_xxx(fsgid))
+#define current_cap()           (current_cred_xxx(cap_effective))
+
+#endif /* HAVE_LINUX_CRED_H */
+
+#define current_user()          (current_cred_xxx(user))
+#define current_user_ns()       (current_cred_xxx(user)->user_ns)
+#define current_security()      (current_cred_xxx(security))
+
+#define cred task_struct
+
+#define prepare_creds() (current)
+#define commit_creds(a)
+
+#endif /* HAVE_STRUCT_CRED */
+
 #endif /* _LINUX_LIBCFS_H */
index 84dd41b..175911e 100644 (file)
 
 #include <net/sock.h>
 
+#ifndef HIPQUAD
+// XXX Should just kill all users
+#if defined(__LITTLE_ENDIAN)
+#define HIPQUAD(addr) \
+        ((unsigned char *)&addr)[3], \
+        ((unsigned char *)&addr)[2], \
+        ((unsigned char *)&addr)[1], \
+        ((unsigned char *)&addr)[0]
+#elif defined(__BIG_ENDIAN)
+#define HIPQUAD NIPQUAD
+#else
+#error "Please fix asm/byteorder.h"
+#endif /* __LITTLE_ENDIAN */
+#endif
+
 typedef struct socket   cfs_socket_t;
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,72))
index 7b9f9cc..f07b1b9 100644 (file)
@@ -525,6 +525,16 @@ static inline void cfs_hlist_add_after(cfs_hlist_node_t *n,
             prefetch(pos->member.next))
 #endif /* cfs_list_for_each_entry */
 
+#ifndef cfs_list_for_each_entry_rcu
+#define cfs_list_for_each_entry_rcu(pos, head, member) \
+       list_for_each_entry(pos, head, member)
+#endif
+
+#ifndef cfs_list_for_each_entry_rcu
+#define cfs_list_for_each_entry_rcu(pos, head, member) \
+       list_for_each_entry(pos, head, member)
+#endif
+
 #ifndef cfs_list_for_each_entry_reverse
 /**
  * Iterate backwards over a list of given type.
index a39a4d7..b32db0a 100644 (file)
@@ -152,6 +152,9 @@ int cfs_create_thread(cfs_thread_t func, void *arg);
 #endif
 
 uid_t cfs_curproc_uid(void);
+gid_t cfs_curproc_gid(void);
+uid_t cfs_curproc_fsuid(void);
+gid_t cfs_curproc_fsgid(void);
 
 #define LIBCFS_REALLOC(ptr, size) realloc(ptr, size)
 
index be37723..385bbef 100644 (file)
@@ -41,6 +41,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/fs_struct.h>
 
 #define DEBUG_SUBSYSTEM S_LNET
 
 
 uid_t  cfs_curproc_uid(void)
 {
-        return current->uid;
+        return current_uid();
 }
 
 gid_t  cfs_curproc_gid(void)
 {
-        return current->gid;
+        return current_gid();
 }
 
 uid_t  cfs_curproc_fsuid(void)
 {
-        return current->fsuid;
+        return current_fsuid();
+}
+
+uid_t  cfs_curproc_euid(void)
+{
+        return current_egid();
+}
+
+uid_t  cfs_curproc_egid(void)
+{
+        return current_egid();
 }
 
 gid_t  cfs_curproc_fsgid(void)
 {
-        return current->fsgid;
+        return current_fsgid();
 }
 
 pid_t  cfs_curproc_pid(void)
@@ -82,7 +93,7 @@ int    cfs_curproc_groups_nr(void)
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
         task_lock(current);
-        nr = current->group_info->ngroups;
+        nr = current_cred()->group_info->ngroups;
         task_unlock(current);
 #else
         nr = current->ngroups;
@@ -94,8 +105,8 @@ void   cfs_curproc_groups_dump(gid_t *array, int size)
 {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
         task_lock(current);
-        size = min_t(int, size, current->group_info->ngroups);
-        memcpy(array, current->group_info->blocks[0], size * sizeof(__u32));
+        size = min_t(int, size, current_cred()->group_info->ngroups);
+        memcpy(array, current_cred()->group_info->blocks[0], size * sizeof(__u32));
         task_unlock(current);
 #else
         LASSERT(size <= NGROUPS);
@@ -126,46 +137,70 @@ char  *cfs_curproc_comm(void)
 
 void cfs_cap_raise(cfs_cap_t cap)
 {
-        cap_raise(cfs_current()->cap_effective, cfs_cap_unpack(cap));
+        struct cred *cred;
+        if ((cred = prepare_creds())) {
+                cap_raise(cred->cap_effective, cfs_cap_unpack(cap));
+                commit_creds(cred);
+        }
 }
 
 void cfs_cap_lower(cfs_cap_t cap)
 {
-        cap_lower(cfs_current()->cap_effective, cfs_cap_unpack(cap));
+        struct cred *cred;
+        if ((cred = prepare_creds())) {
+                cap_lower(cred->cap_effective, cfs_cap_unpack(cap));
+                commit_creds(cred);
+        }
 }
 
 int cfs_cap_raised(cfs_cap_t cap)
 {
-        return cap_raised(cfs_current()->cap_effective, cfs_cap_unpack(cap));
+        return cap_raised(current_cap(), cfs_cap_unpack(cap));
 }
 
-cfs_cap_t cfs_curproc_cap_pack(void)
+void cfs_kernel_cap_pack(cfs_kernel_cap_t kcap, cfs_cap_t *cap)
 {
 #if defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x19980330
-        return cfs_cap_pack(current->cap_effective);
+        *cap = cfs_cap_pack(kcap);
 #elif defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x20071026
-        return cfs_cap_pack(current->cap_effective[0]);
+        *cap = cfs_cap_pack(kcap[0]);
 #elif defined(_KERNEL_CAPABILITY_VERSION) && _KERNEL_CAPABILITY_VERSION == 0x20080522
         /* XXX lost high byte */
-        return cfs_cap_pack(current->cap_effective.cap[0]);
+        *cap = cfs_cap_pack(kcap.cap[0]);
 #else
         #error "need correct _KERNEL_CAPABILITY_VERSION "
 #endif
 }
 
-void cfs_curproc_cap_unpack(cfs_cap_t cap)
+void cfs_kernel_cap_unpack(cfs_kernel_cap_t *kcap, cfs_cap_t cap)
 {
 #if defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x19980330
-        current->cap_effective = cfs_cap_unpack(cap);
+        *kcap = cfs_cap_unpack(cap);
 #elif defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x20071026
-        current->cap_effective[0] = cfs_cap_unpack(cap);
+        (*kcap)[0] = cfs_cap_unpack(cap);
 #elif defined(_KERNEL_CAPABILITY_VERSION) && _KERNEL_CAPABILITY_VERSION == 0x20080522
-        current->cap_effective.cap[0] = cfs_cap_unpack(cap);
+        kcap->cap[0] = cfs_cap_unpack(cap);
 #else
         #error "need correct _KERNEL_CAPABILITY_VERSION "
 #endif
 }
 
+cfs_cap_t cfs_curproc_cap_pack(void)
+{
+        cfs_cap_t cap;
+        cfs_kernel_cap_pack(current_cap(), &cap);
+        return cap;
+}
+
+void cfs_curproc_cap_unpack(cfs_cap_t cap)
+{
+        struct cred *cred;
+        if ((cred = prepare_creds())) {
+                cfs_kernel_cap_unpack(&cred->cap_effective, cap);
+                commit_creds(cred);
+        }
+}
+
 int cfs_capable(cfs_cap_t cap)
 {
         return capable(cfs_cap_unpack(cap));
@@ -173,7 +208,9 @@ int cfs_capable(cfs_cap_t cap)
 
 EXPORT_SYMBOL(cfs_curproc_uid);
 EXPORT_SYMBOL(cfs_curproc_pid);
+EXPORT_SYMBOL(cfs_curproc_euid);
 EXPORT_SYMBOL(cfs_curproc_gid);
+EXPORT_SYMBOL(cfs_curproc_egid);
 EXPORT_SYMBOL(cfs_curproc_fsuid);
 EXPORT_SYMBOL(cfs_curproc_fsgid);
 EXPORT_SYMBOL(cfs_curproc_umask);
index f7daa3d..b8e9984 100644 (file)
@@ -138,7 +138,7 @@ libcfs_ioctl(struct inode *inode, struct file *file,
        struct cfs_psdev_file    pfile;
        int    rc = 0;
 
-       if (current->fsuid != 0)
+       if (current_fsuid() != 0)
                return -EACCES;
 
        if ( _IOC_TYPE(cmd) != IOC_LIBCFS_TYPE ||
index 3cb1a8c..76b9863 100644 (file)
@@ -40,6 +40,7 @@
 #endif
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/fs_struct.h>
 #include <linux/sched.h>
 
 #include <libcfs/libcfs.h>
@@ -241,19 +242,24 @@ void cfs_daemonize(char *str) {
 }
 
 int cfs_daemonize_ctxt(char *str) {
-        struct task_struct *tsk = current;
-        struct fs_struct *fs = NULL;
 
         cfs_daemonize(str);
+#ifndef HAVE_UNSHARE_FS_STRUCT
+        {
+        struct task_struct *tsk = current;
+        struct fs_struct *fs = NULL;
         fs = copy_fs_struct(tsk->fs);
         if (fs == NULL)
                 return -ENOMEM;
         exit_fs(tsk);
         tsk->fs = fs;
+        }
+#else
+        unshare_fs_struct();
+#endif
         return 0;
 }
 
-
 sigset_t
 cfs_get_blockedsigs(void)
 {
index 44aad40..f5de83b 100644 (file)
@@ -242,6 +242,21 @@ uid_t cfs_curproc_uid(void)
         return getuid();
 }
 
+gid_t cfs_curproc_gid(void)
+{
+        return getgid();
+}
+
+uid_t cfs_curproc_fsuid(void)
+{
+        return getuid();
+}
+
+gid_t cfs_curproc_fsgid(void)
+{
+        return getgid();
+}
+
 void cfs_enter_debugger(void)
 {
         /*
index 5ce600f..510ce21 100644 (file)
@@ -405,6 +405,51 @@ AC_MSG_RESULT(no)
 CFLAGS="$tmp_flags"
 
 
+AC_MSG_CHECKING(for POSIX 2008 preadv)
+tmp_flags="$CFLAGS"
+CFLAGS="$CFLAGS -Wall -Werror"
+AC_TRY_COMPILE([
+#include <sys/uio.h>
+ssize_t preadv (int __fd, const struct iovec *__iovec,
+                int __count, off_t off)
+{
+    return 0;
+}
+],[
+],[
+AC_DEFINE(HAVE_POSIX2008_PREADV, 1, [POSIX 2008 preadv])
+AC_MSG_RESULT(yes)
+],[
+AC_MSG_RESULT(no)
+])
+CFLAGS="$tmp_flags"
+
+AC_MSG_CHECKING(for POSIX 2008 scandir)
+tmp_flags="$CFLAGS"
+CFLAGS="$CFLAGS -Wall -Werror"
+AC_TRY_COMPILE([
+#define _BSD_SOURCE
+
+#include <stdio.h>
+#include <dirent.h>
+
+int scandir(const char *dir,
+        struct dirent ***namelist,
+        int(*filter)(const struct dirent *),
+        int(*compar)(const struct dirent **,
+                     const struct dirent **)
+       );
+
+],[
+], [
+AC_DEFINE(HAVE_POSIX2008_SCANDIR, 1, [POSIX 2008 scandir])
+AC_MSG_RESULT(yes) 
+],[
+AC_MSG_RESULT(no)
+])
+CFLAGS="$tmp_flags"
+
+
 AC_MSG_CHECKING(whether .text pseudo-op must be used)
 AC_CACHE_VAL(am_cv_sysio_asm_dot_text, [dnl
 cat > conftest.s <<EOF
index 553df33..bc1af26 100644 (file)
@@ -688,6 +688,26 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
+# LC_D_OBTAIN_ALIAS
+# starting from 2.6.18 kernel don't export do_kern_mount
+# and want to use vfs_kern_mount instead.
+#
+AC_DEFUN([LC_D_OBTAIN_ALIAS],
+[AC_MSG_CHECKING([d_obtain_alias exist in kernel])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/dcache.h>
+],[
+        d_obtain_alias(NULL);
+],[
+        AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
+                [d_obtain_alias 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'
 #
@@ -1999,6 +2019,63 @@ if test x$enable_liblustre_acl = xyes ; then
   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
 fi
 
+# 2.6.29 change prepare/commit_write to write_begin/end
+AC_DEFUN([LC_WRITE_BEGIN_END],
+[AC_MSG_CHECKING([if kernel has .write_begin/end])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+        #include <linux/pagemap.h>
+#ifdef HAVE_LINUX_MMTYPES_H
+        #include <linux/mm_types.h>
+#endif
+],[
+        struct address_space_operations aops;
+        struct page *page;
+
+        aops.write_begin = NULL;
+        aops.write_end = NULL;
+        page = grab_cache_page_write_begin(NULL, 0, 0);
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_KERNEL_WRITE_BEGIN_END, 1,
+                [kernel has .write_begin/end])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.29 blkdev_put has 2 arguments
+AC_DEFUN([LC_BLKDEV_PUT_2ARGS],
+[AC_MSG_CHECKING([blkdev_put needs 2 parameters])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        blkdev_put(NULL, 0);
+],[
+        AC_DEFINE(HAVE_BLKDEV_PUT_2ARGS, 1,
+                [blkdev_put needs 2 paramters])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.29 dentry_open has 4 arguments
+AC_DEFUN([LC_DENTRY_OPEN_4ARGS],
+[AC_MSG_CHECKING([dentry_open needs 4 parameters])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        dentry_open(NULL, NULL, 0, NULL);
+],[
+        AC_DEFINE(HAVE_DENTRY_OPEN_4ARGS, 1,
+                [dentry_open needs 4 paramters])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
 #
 # --enable-mpitest
 #
@@ -2363,6 +2440,12 @@ if test x$enable_lu_ref = xyes ; then
         AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
 fi
 
+         #2.6.29
+         LC_WRITE_BEGIN_END
+         LC_D_OBTAIN_ALIAS
+         LC_BLKDEV_PUT_2ARGS
+         LC_DENTRY_OPEN_4ARGS
+
 ])
 
 #
index 6d3bddd..bc91d39 100644 (file)
@@ -277,6 +277,8 @@ typedef struct task_struct cfs_task_t;
 #define cfs_current()           current
 #define cfs_curproc_pid()       (current->pid)
 #define cfs_curproc_comm()      (current->comm)
+#define cfs_curproc_fsuid()     (current->fsuid)
+#define cfs_curproc_fsgid()     (current->fsgid)
 
 extern struct task_struct *current;
 int cfs_curproc_is_in_groups(gid_t gid);
index 81f8cc1..fe7a720 100644 (file)
@@ -43,6 +43,7 @@
 #error sorry, lustre requires at least linux kernel 2.6.9 or later
 #endif
 
+#include <linux/fs_struct.h>
 #include <libcfs/linux/portals_compat25.h>
 
 #include <linux/lustre_patchless_compat.h>
@@ -139,8 +140,8 @@ do {cfs_mutex_lock_nested(&(inode)->i_mutex, I_MUTEX_PARENT); } while(0)
 #define LOCK_DQONOFF_MUTEX(dqopt) cfs_down(&(dqopt)->dqonoff_sem)
 #endif /* HAVE_DQUOTOFF_MUTEX */
 
-#define current_ngroups current->group_info->ngroups
-#define current_groups current->group_info->small_block
+#define current_ngroups current_cred()->group_info->ngroups
+#define current_groups current_cred()->group_info->small_block
 
 #ifndef page_private
 #define page_private(page) ((page)->private)
@@ -197,6 +198,18 @@ do {cfs_mutex_lock_nested(&(inode)->i_mutex, I_MUTEX_PARENT); } while(0)
 #define val_to_kdev(dev)                (dev)
 #define ILOOKUP(sb, ino, test, data)    ilookup5(sb, ino, test, (void *)(data));
 
+#ifdef HAVE_BLKDEV_PUT_2ARGS
+#define ll_blkdev_put(a, b) blkdev_put(a, b)
+#else
+#define ll_blkdev_put(a, b) blkdev_put(a)
+#endif
+
+#ifdef HAVE_DENTRY_OPEN_4ARGS
+#define ll_dentry_open(a, b, c, d) dentry_open(a, b, c, d)
+#else
+#define ll_dentry_open(a, b, c, d) dentry_open(a, b, c)
+#endif
+
 #include <linux/writeback.h>
 
 static inline int cfs_cleanup_group_info(void)
@@ -429,6 +442,10 @@ int ll_unregister_blkdev(unsigned int dev, const char *name)
 #define LL_RENAME_DOES_D_MOVE   FS_ODD_RENAME
 #endif
 
+#ifndef HAVE_D_OBTAIN_ALIAS
+#define d_obtain_alias(inode) d_alloc_anon(inode)
+#endif
+
 /* add a lustre compatible layer for crypto API */
 #include <linux/crypto.h>
 #ifdef HAVE_ASYNC_BLOCK_CIPHER
index 8670666..ad308df 100644 (file)
@@ -439,7 +439,7 @@ extern cfs_proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root,
                                                 void *data,
                                                 struct file_operations *fops);
 extern struct proc_dir_entry *lprocfs_add_symlink(const char *name,
-                        struct proc_dir_entry *parent, const char *dest);
+                        struct proc_dir_entry *parent, const char *format, ...);
 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
 extern int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
                                          unsigned long count, void *data);
@@ -778,7 +778,7 @@ static inline cfs_proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *ro
                                      struct file_operations *fops)
 {return 0; }
 static inline struct proc_dir_entry *lprocfs_add_symlink(const char *name,
-                        struct proc_dir_entry *parent, const char *dest)
+                        struct proc_dir_entry *parent, const char *format, ...)
 {return NULL; }
 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
 {}
index 265ea65..9b751a8 100644 (file)
@@ -122,9 +122,6 @@ static inline unsigned fiemap_size_to_count(size_t array_size)
 #undef FIEMAP_FLAGS_COMPAT
 #endif
 
-#define FIEMAP_FLAGS_COMPAT    (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR | \
-                                FIEMAP_FLAG_DEVICE_ORDER)
-
 /* Lustre specific flags - use a high bit, don't conflict with upstream flag */
 #define FIEMAP_EXTENT_NO_DIRECT         0x40000000 /* Data mapping undefined */
 #define FIEMAP_EXTENT_NET               0x80000000 /* Data stored remotely.
index 4ac220d..6c9464b 100644 (file)
@@ -1058,7 +1058,7 @@ int ldlm_completion_ast(struct ldlm_lock *lock, int flags, void *data);
 int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp,
                      struct ldlm_enqueue_info *einfo,
                      const struct ldlm_res_id *res_id,
-                     ldlm_policy_data_t *policy, int *flags,
+                     ldlm_policy_data_t const *policy, int *flags,
                      void *lvb, __u32 lvb_len, struct lustre_handle *lockh,
                      int async);
 int ldlm_prep_enqueue_req(struct obd_export *exp,
index a167aca..834697e 100644 (file)
@@ -504,8 +504,6 @@ void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc)
          */
         if ((lock->l_resource->lr_type == LDLM_IBITS) &&
             (exp && !(exp->exp_connect_flags & OBD_CONNECT_IBITS))) {
-                struct ldlm_resource res = *lock->l_resource;
-
                 /* Make sure all the right bits are set in this lock we
                    are going to pass to client */
                 LASSERTF(lock->l_policy_data.l_inodebits.bits ==
@@ -513,8 +511,10 @@ void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc)
                          "Inappropriate inode lock bits during "
                          "conversion " LPU64 "\n",
                          lock->l_policy_data.l_inodebits.bits);
-                res.lr_type = LDLM_PLAIN;
-                ldlm_res2desc(&res, &desc->l_resource);
+
+                ldlm_res2desc(lock->l_resource, &desc->l_resource);
+                desc->l_resource.lr_type = LDLM_PLAIN;
+
                 /* Convert "new" lock mode to something old client can
                    understand */
                 if ((lock->l_req_mode == LCK_CR) ||
index b65b432..50377c9 100644 (file)
@@ -750,7 +750,7 @@ int ldlm_prep_enqueue_req(struct obd_export *exp, struct ptlrpc_request *req,
 int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp,
                      struct ldlm_enqueue_info *einfo,
                      const struct ldlm_res_id *res_id,
-                     ldlm_policy_data_t *policy, int *flags,
+                     ldlm_policy_data_t const *policy, int *flags,
                      void *lvb, __u32 lvb_len, struct lustre_handle *lockh,
                      int async)
 {
index 35f331e..dcff870 100644 (file)
@@ -1080,7 +1080,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
                                 GOTO(out_quotactl, rc = -EPERM);
                         break;
                 case Q_GETQUOTA:
-                        if (((type == USRQUOTA && current->euid != id) ||
+                        if (((type == USRQUOTA && cfs_curproc_euid() != id) ||
                              (type == GRPQUOTA && !in_egroup_p(id))) &&
                             (!cfs_capable(CFS_CAP_SYS_ADMIN) ||
                              sbi->ll_flags & LL_SBI_RMT_CLIENT))
index 53f5019..dad4ec2 100644 (file)
@@ -1284,7 +1284,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
 
         /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
         if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
-                if (current->fsuid != inode->i_uid &&
+                if (cfs_curproc_fsuid() != inode->i_uid &&
                     !cfs_capable(CFS_CAP_FOWNER))
                         RETURN(-EPERM);
         }
@@ -1858,7 +1858,7 @@ int ll_flush_ctx(struct inode *inode)
 {
         struct ll_sb_info  *sbi = ll_i2sbi(inode);
 
-        CDEBUG(D_SEC, "flush context for user %d\n", current->uid);
+        CDEBUG(D_SEC, "flush context for user %d\n", cfs_curproc_uid());
 
         obd_set_info_async(sbi->ll_md_exp,
                            sizeof(KEY_FLUSH_CTX), KEY_FLUSH_CTX,
@@ -1881,7 +1881,7 @@ void ll_umount_begin(struct super_block *sb)
         struct lustre_sb_info *lsi = s2lsi(sb);
         struct ll_sb_info *sbi = ll_s2sbi(sb);
         struct obd_device *obd;
-        struct obd_ioctl_data ioc_data = { 0 };
+        struct obd_ioctl_data *ioc_data;
         ENTRY;
 
 #ifdef HAVE_UMOUNTBEGIN_VFSMOUNT
@@ -1905,8 +1905,6 @@ void ll_umount_begin(struct super_block *sb)
                 return;
         }
         obd->obd_force = 1;
-        obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp, sizeof ioc_data,
-                      &ioc_data, NULL);
 
         obd = class_exp2obd(sbi->ll_dt_exp);
         if (obd == NULL) {
@@ -1915,10 +1913,19 @@ void ll_umount_begin(struct super_block *sb)
                 EXIT;
                 return;
         }
-
         obd->obd_force = 1;
-        obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp, sizeof ioc_data,
-                      &ioc_data, NULL);
+
+        OBD_ALLOC_PTR(ioc_data);
+        if (ioc_data) {
+                obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp,
+                              sizeof ioc_data, ioc_data, NULL);
+
+                obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp,
+                              sizeof ioc_data, ioc_data, NULL);
+
+                OBD_FREE_PTR(ioc_data);
+        }
+
 
         /* Really, we'd like to wait until there are no requests outstanding,
          * and then continue.  For now, we just invalidate the requests,
@@ -2117,8 +2124,8 @@ struct md_op_data * ll_prep_md_op_data(struct md_op_data *op_data,
         op_data->op_namelen = namelen;
         op_data->op_mode = mode;
         op_data->op_mod_time = cfs_time_current_sec();
-        op_data->op_fsuid = current->fsuid;
-        op_data->op_fsgid = current->fsgid;
+        op_data->op_fsuid = cfs_curproc_fsuid();
+        op_data->op_fsgid = cfs_curproc_fsgid();
         op_data->op_cap = cfs_curproc_cap_pack();
         op_data->op_bias = MDS_CHECK_SPLIT;
         op_data->op_opc = opc;
index 98e1e62..a2ce959 100644 (file)
@@ -129,7 +129,7 @@ static struct dentry *ll_iget_for_nfs(struct super_block *sb,
                 RETURN(ERR_PTR(-ESTALE));
         }
 
-        result = d_alloc_anon(inode);
+        result = d_obtain_alias(inode);
         if (!result) {
                 iput(inode);
                 RETURN(ERR_PTR(-ENOMEM));
index bbbb0ea..4f56ef9 100644 (file)
@@ -600,9 +600,15 @@ static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev,
         return 0;
 }
 
+#ifdef HAVE_BLKDEV_PUT_2ARGS
+static int lo_open(struct block_device *bdev, fmode_t mode)
+{
+        struct lloop_device *lo = bdev->bd_disk->private_data;
+#else
 static int lo_open(struct inode *inode, struct file *file)
 {
         struct lloop_device *lo = inode->i_bdev->bd_disk->private_data;
+#endif
 
         cfs_down(&lo->lo_ctl_mutex);
         lo->lo_refcnt++;
@@ -611,9 +617,15 @@ static int lo_open(struct inode *inode, struct file *file)
         return 0;
 }
 
+#ifdef HAVE_BLKDEV_PUT_2ARGS
+static int lo_release(struct gendisk *disk, fmode_t mode)
+{
+        struct lloop_device *lo = disk->private_data;
+#else
 static int lo_release(struct inode *inode, struct file *file)
 {
         struct lloop_device *lo = inode->i_bdev->bd_disk->private_data;
+#endif
 
         cfs_down(&lo->lo_ctl_mutex);
         --lo->lo_refcnt;
@@ -623,11 +635,18 @@ static int lo_release(struct inode *inode, struct file *file)
 }
 
 /* lloop device node's ioctl function. */
+#ifdef HAVE_BLKDEV_PUT_2ARGS
+static int lo_ioctl(struct block_device *bdev, fmode_t mode,
+                    unsigned int cmd, unsigned long arg)
+{
+        struct lloop_device *lo = bdev->bd_disk->private_data;
+#else
 static int lo_ioctl(struct inode *inode, struct file *unused,
                     unsigned int cmd, unsigned long arg)
 {
         struct lloop_device *lo = inode->i_bdev->bd_disk->private_data;
         struct block_device *bdev = inode->i_bdev;
+#endif
         int err = 0;
 
         cfs_down(&lloop_mutex);
@@ -635,7 +654,7 @@ static int lo_ioctl(struct inode *inode, struct file *unused,
         case LL_IOC_LLOOP_DETACH: {
                 err = loop_clr_fd(lo, bdev, 2);
                 if (err == 0)
-                        blkdev_put(bdev); /* grabbed in LLOOP_ATTACH */
+                        ll_blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */
                 break;
         }
 
@@ -725,7 +744,7 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file,
                 err = loop_set_fd(lo, NULL, bdev, file);
                 if (err) {
                         fput(file);
-                        blkdev_put(bdev);
+                        ll_blkdev_put(bdev, 0);
                 }
 
                 break;
@@ -749,7 +768,7 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file,
                 bdev = lo->lo_device;
                 err = loop_clr_fd(lo, bdev, 1);
                 if (err == 0)
-                        blkdev_put(bdev); /* grabbed in LLOOP_ATTACH */
+                        ll_blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */
 
                 break;
         }
index de3907a..7265cdc 100644 (file)
@@ -708,7 +708,7 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count)
                  sbi->ll_stats_track_id == current->parent->pid)
                 lprocfs_counter_add(sbi->ll_stats, op, count);
         else if (sbi->ll_stats_track_type == STATS_TRACK_GID &&
-                 sbi->ll_stats_track_id == current->gid)
+                 sbi->ll_stats_track_id == cfs_curproc_gid())
                 lprocfs_counter_add(sbi->ll_stats, op, count);
 }
 EXPORT_SYMBOL(ll_stats_ops_tally);
index efc469b..dea4fe1 100644 (file)
@@ -861,7 +861,7 @@ static int ll_new_node(struct inode *dir, struct qstr *name,
                 GOTO(err_exit, err = PTR_ERR(op_data));
 
         err = md_create(sbi->ll_md_exp, op_data, tgt, tgt_len, mode,
-                        current->fsuid, current->fsgid,
+                        cfs_curproc_fsuid(), cfs_curproc_fsgid(),
                         cfs_curproc_cap_pack(), rdev, &request);
         ll_finish_md_op_data(op_data);
         if (err)
index 9d26e87..2b5efe2 100644 (file)
@@ -131,17 +131,17 @@ static int do_check_remote_perm(struct ll_inode_info *lli, int mask)
         if (!lli->lli_remote_perms)
                 RETURN(-ENOENT);
 
-        head = lli->lli_remote_perms + remote_perm_hashfunc(current->uid);
+        head = lli->lli_remote_perms + remote_perm_hashfunc(cfs_curproc_uid());
 
         cfs_spin_lock(&lli->lli_lock);
         cfs_hlist_for_each_entry(lrp, node, head, lrp_list) {
-                if (lrp->lrp_uid != current->uid)
+                if (lrp->lrp_uid != cfs_curproc_uid())
                         continue;
-                if (lrp->lrp_gid != current->gid)
+                if (lrp->lrp_gid != cfs_curproc_gid())
                         continue;
-                if (lrp->lrp_fsuid != current->fsuid)
+                if (lrp->lrp_fsuid != cfs_curproc_fsuid())
                         continue;
-                if (lrp->lrp_fsgid != current->fsgid)
+                if (lrp->lrp_fsgid != cfs_curproc_fsgid())
                         continue;
                 found = 1;
                 break;
index d3b26b4..22dc711 100644 (file)
@@ -468,6 +468,45 @@ out:
         RETURN(tot_bytes ? : result);
 }
 
+#ifdef HAVE_KERNEL_WRITE_BEGIN_END
+static int ll_write_begin(struct file *file, struct address_space *mapping,
+                         loff_t pos, unsigned len, unsigned flags,
+                         struct page **pagep, void **fsdata)
+{
+        pgoff_t index = pos >> PAGE_CACHE_SHIFT;
+        struct page *page;
+        int rc;
+        unsigned from = pos & (PAGE_CACHE_SIZE - 1);
+        ENTRY;
+
+        page = grab_cache_page_write_begin(mapping, index, flags);
+        if (!page)
+                RETURN(-ENOMEM);
+
+        *pagep = page;
+
+        rc = ll_prepare_write(file, page, from, from + len);
+        if (rc) {
+                unlock_page(page);
+                page_cache_release(page);
+        }
+        RETURN(rc);
+}
+
+static int ll_write_end(struct file *file, struct address_space *mapping,
+                        loff_t pos, unsigned len, unsigned copied,
+                        struct page *page, void *fsdata)
+{
+        unsigned from = pos & (PAGE_CACHE_SIZE - 1);
+        int rc;
+        rc = ll_commit_write(file, page, from, from + copied);
+
+        unlock_page(page);
+        page_cache_release(page);
+        return rc?rc:copied;
+}
+#endif
+
 struct address_space_operations ll_aops = {
         .readpage       = ll_readpage,
 //        .readpages      = ll_readpages,
@@ -476,8 +515,13 @@ struct address_space_operations ll_aops = {
         .writepages     = generic_writepages,
         .set_page_dirty = ll_set_page_dirty,
         .sync_page      = NULL,
+#ifdef HAVE_KERNEL_WRITE_BEGIN_END
+        .write_begin    = ll_write_begin,
+        .write_end      = ll_write_end,
+#else
         .prepare_write  = ll_prepare_write,
         .commit_write   = ll_commit_write,
+#endif
         .invalidatepage = ll_invalidatepage,
         .releasepage    = (void *)ll_releasepage,
         .bmap           = NULL
index 9fd0842..29d3a67 100644 (file)
@@ -358,6 +358,9 @@ do_getxattr:
                 GOTO(out, rc = -ERANGE);
         }
 
+        if (body->eadatasize == 0)
+                GOTO(out, rc = -ENODATA);
+
         /* do not need swab xattr data */
         xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
                                              body->eadatasize);
index caa7e8b..46bc2a2 100644 (file)
@@ -469,16 +469,14 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
         lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
         if (lmv_proc_dir) {
                 struct proc_dir_entry *mdc_symlink;
-                char name[MAX_STRING_SIZE + 1];
 
                 LASSERT(mdc_obd->obd_type != NULL);
                 LASSERT(mdc_obd->obd_type->typ_name != NULL);
-                name[MAX_STRING_SIZE] = '\0';
-                snprintf(name, MAX_STRING_SIZE, "../../../%s/%s",
-                         mdc_obd->obd_type->typ_name,
-                         mdc_obd->obd_name);
-                mdc_symlink = proc_symlink(mdc_obd->obd_name,
-                                           lmv_proc_dir, name);
+                mdc_symlink = lprocfs_add_symlink(mdc_obd->obd_name,
+                                                  lmv_proc_dir,
+                                                  "../../../%s/%s",
+                                                  mdc_obd->obd_type->typ_name,
+                                                  mdc_obd->obd_name);
                 if (mdc_symlink == NULL) {
                         CERROR("Could not register LMV target "
                                "/proc/fs/lustre/%s/%s/target_obds/%s.",
@@ -1970,8 +1968,8 @@ repeat:
         CDEBUG(D_INODE, "Forward to mds #%x ("DFID")\n",
                mds, PFID(&op_data->op_fid1));
 
-        op_data->op_fsuid = current->fsuid;
-        op_data->op_fsgid = current->fsgid;
+        op_data->op_fsuid = cfs_curproc_fsuid();
+        op_data->op_fsgid = cfs_curproc_fsgid();
         op_data->op_cap = cfs_curproc_cap_pack();
         tgt = lmv_get_target(lmv, mds);
 
@@ -2064,8 +2062,8 @@ repeat:
                         RETURN(rc);
         }
 
-        op_data->op_fsuid = current->fsuid;
-        op_data->op_fsgid = current->fsgid;
+        op_data->op_fsuid = cfs_curproc_fsuid();
+        op_data->op_fsgid = cfs_curproc_fsgid();
         op_data->op_cap = cfs_curproc_cap_pack();
 
         src_tgt = lmv_get_target(lmv, mds1);
@@ -2453,8 +2451,8 @@ repeat:
                 op_data->op_bias |= MDS_CHECK_SPLIT;
         }
 
-        op_data->op_fsuid = current->fsuid;
-        op_data->op_fsgid = current->fsgid;
+        op_data->op_fsuid = cfs_curproc_fsuid();
+        op_data->op_fsgid = cfs_curproc_fsgid();
         op_data->op_cap = cfs_curproc_cap_pack();
 
         /*
index 135458d..a73ff2f 100644 (file)
@@ -131,11 +131,10 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
                     struct obd_connect_data *data)
 {
         struct lov_obd *lov = &obd->u.lov;
-        struct obd_uuid tgt_uuid;
+        struct obd_uuid *tgt_uuid;
         struct obd_device *tgt_obd;
         static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" };
         struct obd_import *imp;
-
 #ifdef __KERNEL__
         cfs_proc_dir_entry_t *lov_proc_dir;
 #endif
@@ -145,11 +144,11 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
         if (!lov->lov_tgts[index])
                 RETURN(-EINVAL);
 
-        tgt_uuid = lov->lov_tgts[index]->ltd_uuid;
+        tgt_uuid = &lov->lov_tgts[index]->ltd_uuid;
         tgt_obd = lov->lov_tgts[index]->ltd_obd;
 
         if (!tgt_obd->obd_set_up) {
-                CERROR("Target %s not set up\n", obd_uuid2str(&tgt_uuid));
+                CERROR("Target %s not set up\n", obd_uuid2str(tgt_uuid));
                 RETURN(-EINVAL);
         }
 
@@ -174,14 +173,14 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
         rc = obd_register_observer(tgt_obd, obd);
         if (rc) {
                 CERROR("Target %s register_observer error %d\n",
-                       obd_uuid2str(&tgt_uuid), rc);
+                       obd_uuid2str(tgt_uuid), rc);
                 RETURN(rc);
         }
 
 
         if (imp->imp_invalid) {
                 CERROR("not connecting OSC %s; administratively "
-                       "disabled\n", obd_uuid2str(&tgt_uuid));
+                       "disabled\n", obd_uuid2str(tgt_uuid));
                 RETURN(0);
         }
 
@@ -189,35 +188,35 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
                          &lov_osc_uuid, data, NULL);
         if (rc || !lov->lov_tgts[index]->ltd_exp) {
                 CERROR("Target %s connect error %d\n",
-                       obd_uuid2str(&tgt_uuid), rc);
+                       obd_uuid2str(tgt_uuid), rc);
                 RETURN(-ENODEV);
         }
 
         lov->lov_tgts[index]->ltd_reap = 0;
 
         CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index,
-               obd_uuid2str(&tgt_uuid), tgt_obd->obd_name, activate ? "":"in");
+               obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in");
 
 #ifdef __KERNEL__
         lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
         if (lov_proc_dir) {
                 struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd;
                 cfs_proc_dir_entry_t *osc_symlink;
-                char name[MAX_STRING_SIZE];
 
                 LASSERT(osc_obd != NULL);
                 LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC);
                 LASSERT(osc_obd->obd_type->typ_name != NULL);
-                snprintf(name, MAX_STRING_SIZE, "../../../%s/%s",
-                         osc_obd->obd_type->typ_name,
-                         osc_obd->obd_name);
-                osc_symlink = lprocfs_add_symlink(osc_obd->obd_name, lov_proc_dir,
-                                                  name);
+
+                osc_symlink = lprocfs_add_symlink(osc_obd->obd_name,
+                                                  lov_proc_dir,
+                                                  "../../../%s/%s",
+                                                  osc_obd->obd_type->typ_name,
+                                                  osc_obd->obd_name);
                 if (osc_symlink == NULL) {
                         CERROR("could not register LOV target "
-                               "/proc/fs/lustre/%s/%s/target_obds/%s.",
-                               obd->obd_type->typ_name, obd->obd_name,
-                               osc_obd->obd_name);
+                                "/proc/fs/lustre/%s/%s/target_obds/%s.",
+                                obd->obd_type->typ_name, obd->obd_name,
+                                osc_obd->obd_name);
                         lprocfs_remove(&lov_proc_dir);
                 }
         }
index 4163434..ca92e35 100644 (file)
@@ -388,14 +388,15 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size,
 {
         struct obd_device *obd = class_exp2obd(exp);
         struct lov_obd *lov = &obd->u.lov;
-        struct lov_user_md_v3 lumv3;
-        struct lov_user_md_v1 *lumv1 = (struct lov_user_md_v1 *)&lumv3;
+        char buffer[sizeof(struct lov_user_md_v3)];
+        struct lov_user_md_v3 *lumv3 = (struct lov_user_md_v3 *)&buffer[0];
+        struct lov_user_md_v1 *lumv1 = (struct lov_user_md_v1 *)&buffer[0];
         int lmm_magic;
         int stripe_count;
         int rc;
         ENTRY;
 
-        if (cfs_copy_from_user(&lumv3, lump, sizeof(struct lov_user_md_v1)))
+        if (cfs_copy_from_user(lumv3, lump, sizeof(struct lov_user_md_v1)))
                 RETURN(-EFAULT);
 
         lmm_magic = lumv1->lmm_magic;
@@ -404,12 +405,12 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size,
                 lustre_swab_lov_user_md_v1(lumv1);
                 lmm_magic = LOV_USER_MAGIC_V1;
         } else if (lmm_magic == LOV_USER_MAGIC_V3) {
-                if (cfs_copy_from_user(&lumv3, lump, sizeof(lumv3)))
+                if (cfs_copy_from_user(lumv3, lump, sizeof(*lumv3)))
                         RETURN(-EFAULT);
         } else if (lmm_magic == __swab32(LOV_USER_MAGIC_V3)) {
-                if (cfs_copy_from_user(&lumv3, lump, sizeof(lumv3)))
+                if (cfs_copy_from_user(lumv3, lump, sizeof(*lumv3)))
                         RETURN(-EFAULT);
-                lustre_swab_lov_user_md_v3(&lumv3);
+                lustre_swab_lov_user_md_v3(lumv3);
                 lmm_magic = LOV_USER_MAGIC_V3;
         } else if (lmm_magic != LOV_USER_MAGIC_V1) {
                 CDEBUG(D_IOCTL,
@@ -463,12 +464,12 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size,
         if (lmm_magic == LOV_USER_MAGIC_V3) {
                 struct pool_desc *pool;
 
-                pool = lov_find_pool(lov, lumv3.lmm_pool_name);
+                pool = lov_find_pool(lov, lumv3->lmm_pool_name);
                 if (pool != NULL) {
-                        if (lumv3.lmm_stripe_offset !=
-                            (typeof(lumv3.lmm_stripe_offset))(-1)) {
+                        if (lumv3->lmm_stripe_offset !=
+                            (typeof(lumv3->lmm_stripe_offset))(-1)) {
                                 rc = lov_check_index_in_pool(
-                                        lumv3.lmm_stripe_offset, pool);
+                                        lumv3->lmm_stripe_offset, pool);
                                 if (rc < 0) {
                                         lov_pool_putref(pool);
                                         RETURN(-EINVAL);
@@ -488,7 +489,7 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size,
                 (*lsmp)->lsm_oinfo[0]->loi_ost_idx = lumv1->lmm_stripe_offset;
                 (*lsmp)->lsm_stripe_size = lumv1->lmm_stripe_size;
                 if (lmm_magic == LOV_USER_MAGIC_V3)
-                        strncpy((*lsmp)->lsm_pool_name, lumv3.lmm_pool_name,
+                        strncpy((*lsmp)->lsm_pool_name, lumv3->lmm_pool_name,
                                 LOV_MAXPOOLNAME);
                 rc = 0;
         }
index 7e01051..fbd038d 100644 (file)
@@ -89,9 +89,13 @@ static void push_group_info(struct lvfs_run_ctxt *save,
                 save->ngroups = current_ngroups;
                 current_ngroups = 0;
         } else {
+                struct cred *cred;
                 task_lock(current);
-                save->group_info = current->group_info;
-                current->group_info = ginfo;
+                save->group_info = current_cred()->group_info;
+                if ((cred = prepare_creds())) {
+                        cred->group_info = ginfo;
+                        commit_creds(cred);
+                }
                 task_unlock(current);
         }
 }
@@ -102,8 +106,12 @@ static void pop_group_info(struct lvfs_run_ctxt *save,
         if (!ginfo) {
                 current_ngroups = save->ngroups;
         } else {
+                struct cred *cred;
                 task_lock(current);
-                current->group_info = save->group_info;
+                if ((cred = prepare_creds())) {
+                        cred->group_info = save->group_info;
+                        commit_creds(cred);
+                }
                 task_unlock(current);
         }
 }
@@ -122,7 +130,7 @@ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
         save->pwd = dget(cfs_fs_pwd(current->fs));
         save->pwdmnt = mntget(cfs_fs_mnt(current->fs));
         save->luc.luc_umask = current->fs->umask;
-        save->ngroups = current->group_info->ngroups;
+        save->ngroups = current_cred()->group_info->ngroups;
 
         LASSERT(save->pwd);
         LASSERT(save->pwdmnt);
@@ -130,17 +138,21 @@ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
         LASSERT(new_ctx->pwdmnt);
 
         if (uc) {
-                save->luc.luc_uid = current->uid;
-                save->luc.luc_gid = current->gid;
-                save->luc.luc_fsuid = current->fsuid;
-                save->luc.luc_fsgid = current->fsgid;
-                save->luc.luc_cap = current->cap_effective;
-
-                current->uid = uc->luc_uid;
-                current->gid = uc->luc_gid;
-                current->fsuid = uc->luc_fsuid;
-                current->fsgid = uc->luc_fsgid;
-                current->cap_effective = uc->luc_cap;
+                struct cred *cred;
+                save->luc.luc_uid = current_uid();
+                save->luc.luc_gid = current_gid();
+                save->luc.luc_fsuid = current_fsuid();
+                save->luc.luc_fsgid = current_fsgid();
+                save->luc.luc_cap = current_cap();
+
+                if ((cred = prepare_creds())) {
+                        cred->uid = uc->luc_uid;
+                        cred->gid = uc->luc_gid;
+                        cred->fsuid = uc->luc_fsuid;
+                        cred->fsgid = uc->luc_fsgid;
+                        cred->cap_effective = uc->luc_cap;
+                        commit_creds(cred);
+                }
 
                 push_group_info(save,
                                 uc->luc_ginfo ?:
@@ -171,11 +183,16 @@ void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
         mntput(saved->pwdmnt);
         current->fs->umask = saved->luc.luc_umask;
         if (uc) {
-                current->uid = saved->luc.luc_uid;
-                current->gid = saved->luc.luc_gid;
-                current->fsuid = saved->luc.luc_fsuid;
-                current->fsgid = saved->luc.luc_fsgid;
-                current->cap_effective = saved->luc.luc_cap;
+                struct cred *cred;
+                if ((cred = prepare_creds())) {
+                        cred->uid = saved->luc.luc_uid;
+                        cred->gid = saved->luc.luc_gid;
+                        cred->fsuid = saved->luc.luc_fsuid;
+                        cred->fsgid = saved->luc.luc_fsgid;
+                        cred->cap_effective = saved->luc.luc_cap;
+                        commit_creds(cred);
+                }
+
                 pop_group_info(saved,
                                uc->luc_ginfo ?:
                                uc->luc_identity ? uc->luc_identity->mi_ginfo :
@@ -367,7 +384,7 @@ struct l_file *l_dentry_open(struct lvfs_run_ctxt *ctxt, struct l_dentry *de,
                              int flags)
 {
         mntget(ctxt->pwdmnt);
-        return dentry_open(de, ctxt->pwdmnt, flags);
+        return ll_dentry_open(de, ctxt->pwdmnt, flags, current_cred());
 }
 EXPORT_SYMBOL(l_dentry_open);
 
index 4d86793..a76e408 100644 (file)
@@ -55,10 +55,10 @@ static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid)
         LASSERT (b != NULL);
 
         b->suppgid = suppgid;
-        b->uid = current->uid;
-        b->gid = current->gid;
-        b->fsuid = current->fsuid;
-        b->fsgid = current->fsgid;
+        b->uid = cfs_curproc_uid();
+        b->gid = cfs_curproc_gid();
+        b->fsuid = cfs_curproc_fsuid();
+        b->fsgid = cfs_curproc_fsgid();
         b->capability = cfs_curproc_cap_pack();
 }
 
@@ -204,8 +204,8 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
 
         /* XXX do something about time, uid, gid */
         rec->cr_opcode   = REINT_OPEN;
-        rec->cr_fsuid    = current->fsuid;
-        rec->cr_fsgid    = current->fsgid;
+        rec->cr_fsuid   = cfs_curproc_fsuid();
+        rec->cr_fsgid   = cfs_curproc_fsgid();
         rec->cr_cap      = cfs_curproc_cap_pack();
         if (op_data != NULL) {
                 rec->cr_fid1 = op_data->op_fid1;
@@ -284,8 +284,8 @@ static void mdc_setattr_pack_rec(struct mdt_rec_setattr *rec,
                                  struct md_op_data *op_data)
 {
         rec->sa_opcode  = REINT_SETATTR;
-        rec->sa_fsuid   = current->fsuid;
-        rec->sa_fsgid   = current->fsgid;
+        rec->sa_fsuid   = cfs_curproc_fsuid();
+        rec->sa_fsgid   = cfs_curproc_fsgid();
         rec->sa_cap     = cfs_curproc_cap_pack();
         rec->sa_suppgid = -1;
 
@@ -439,8 +439,8 @@ void mdc_getattr_pack(struct ptlrpc_request *req, __u64 valid, int flags,
         struct mdt_body *b = req_capsule_client_get(&req->rq_pill,
                                                     &RMF_MDT_BODY);
 
-        b->fsuid = current->fsuid;
-        b->fsgid = current->fsgid;
+        b->fsuid = cfs_curproc_fsuid();
+        b->fsgid = cfs_curproc_fsgid();
         b->capability = cfs_curproc_cap_pack();
         b->valid = valid;
         if (op_data->op_bias & MDS_CHECK_SPLIT)
index 1dc107f..6785d35 100644 (file)
@@ -608,7 +608,11 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
         int                    flags = extra_lock_flags;
         int                    rc;
         struct ldlm_res_id res_id;
-        ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_LOOKUP } };
+        static const ldlm_policy_data_t lookup_policy =
+                            { .l_inodebits = { MDS_INODELOCK_LOOKUP } };
+        static const ldlm_policy_data_t update_policy =
+                            { .l_inodebits = { MDS_INODELOCK_UPDATE } };
+        ldlm_policy_data_t const *policy = &lookup_policy;
         ENTRY;
 
         LASSERTF(!it || einfo->ei_type == LDLM_IBITS, "lock type %d\n",
@@ -619,7 +623,7 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
         if (it)
                 flags |= LDLM_FL_HAS_INTENT;
         if (it && it->it_op & (IT_UNLINK | IT_GETATTR | IT_READDIR))
-                policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
+                policy = &update_policy;
 
         if (reqp)
                 req = *reqp;
@@ -630,12 +634,12 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
                 LASSERT(lmm && lmmsize == 0);
                 LASSERTF(einfo->ei_type == LDLM_FLOCK, "lock type %d\n",
                          einfo->ei_type);
-                policy = *(ldlm_policy_data_t *)lmm;
+                policy = (ldlm_policy_data_t *)lmm;
                 res_id.name[3] = LDLM_FLOCK;
         } else if (it->it_op & IT_OPEN) {
                 req = mdc_intent_open_pack(exp, it, op_data, lmm, lmmsize,
                                            einfo->ei_cbdata);
-                policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
+                policy = &update_policy;
                 einfo->ei_cbdata = NULL;
                 lmm = NULL;
         } else if (it->it_op & IT_UNLINK)
@@ -660,7 +664,8 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
                 mdc_get_rpc_lock(obddev->u.cli.cl_rpc_lock, it);
                 mdc_enter_request(&obddev->u.cli);
         }
-        rc = ldlm_cli_enqueue(exp, &req, einfo, &res_id, &policy, &flags, NULL,
+
+        rc = ldlm_cli_enqueue(exp, &req, einfo, &res_id, policy, &flags, NULL,
                               0, lockh, 0);
         if (reqp)
                 *reqp = req;
index dc0fefb..0755097 100644 (file)
@@ -362,8 +362,8 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt,
                  *  cfs_curproc_fs{u,g}id() should replace
                  *  current->fs{u,g}id for portability.
                  */
-                rec->sx_fsuid  = current->fsuid;
-                rec->sx_fsgid  = current->fsgid;
+                rec->sx_fsuid  = cfs_curproc_fsuid();
+                rec->sx_fsgid  = cfs_curproc_fsgid();
                 rec->sx_cap    = cfs_curproc_cap_pack();
                 rec->sx_suppgid1 = suppgid;
                 rec->sx_suppgid2 = -1;
index e2ec7ce..754c515 100644 (file)
@@ -145,17 +145,29 @@ cfs_proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root,
 }
 
 struct proc_dir_entry *lprocfs_add_symlink(const char *name,
-                        struct proc_dir_entry *parent, const char *dest)
+                        struct proc_dir_entry *parent, const char *format, ...)
 {
         struct proc_dir_entry *entry;
+        char *dest;
+        va_list ap;
 
-        if (parent == NULL || dest == NULL)
+        if (parent == NULL || format == NULL)
                 return NULL;
 
+        OBD_ALLOC_WAIT(dest, MAX_STRING_SIZE + 1);
+        if (dest == NULL)
+                return NULL;
+
+        va_start(ap, format);
+        vsnprintf(dest, MAX_STRING_SIZE, format, ap);
+        va_end(ap);
+
         entry = proc_symlink(name, parent, dest);
         if (entry == NULL)
                 CERROR("LprocFS: Could not create symbolic link from %s to %s",
                         name, dest);
+
+        OBD_FREE(dest, MAX_STRING_SIZE + 1);
         return entry;
 }
 
index 55bd19d..84669c3 100644 (file)
@@ -277,8 +277,8 @@ struct ptlrpc_cli_ctx *get_my_ctx(struct ptlrpc_sec *sec)
                         remove_dead = 0;
                 }
         } else {
-                vcred.vc_uid = cfs_current()->uid;
-                vcred.vc_gid = cfs_current()->gid;
+                vcred.vc_uid = cfs_curproc_uid();
+                vcred.vc_gid = cfs_curproc_gid();
         }
 
         return sec->ps_policy->sp_cops->lookup_ctx(sec, &vcred,
@@ -1473,7 +1473,7 @@ void sptlrpc_import_flush_root_ctx(struct obd_import *imp)
 
 void sptlrpc_import_flush_my_ctx(struct obd_import *imp)
 {
-        import_flush_ctx_common(imp, cfs_current()->uid, 1, 1);
+        import_flush_ctx_common(imp, cfs_curproc_uid(), 1, 1);
 }
 EXPORT_SYMBOL(sptlrpc_import_flush_my_ctx);
 
@@ -2290,10 +2290,10 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int offset)
 
         pud = lustre_msg_buf(msg, offset, 0);
 
-        pud->pud_uid = cfs_current()->uid;
-        pud->pud_gid = cfs_current()->gid;
-        pud->pud_fsuid = cfs_current()->fsuid;
-        pud->pud_fsgid = cfs_current()->fsgid;
+        pud->pud_uid = cfs_curproc_uid();
+        pud->pud_gid = cfs_curproc_gid();
+        pud->pud_fsuid = cfs_curproc_fsuid();
+        pud->pud_fsgid = cfs_curproc_fsgid();
         pud->pud_cap = cfs_curproc_cap_pack();
         pud->pud_ngroups = (msg->lm_buflens[offset] - sizeof(*pud)) / 4;
 
@@ -2301,7 +2301,7 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int offset)
         task_lock(current);
         if (pud->pud_ngroups > current_ngroups)
                 pud->pud_ngroups = current_ngroups;
-        memcpy(pud->pud_groups, cfs_current()->group_info->blocks[0],
+        memcpy(pud->pud_groups, current_cred()->group_info->blocks[0],
                pud->pud_ngroups * sizeof(__u32));
         task_unlock(current);
 #endif
index 4b8d7d0..7c237c4 100644 (file)
@@ -1482,7 +1482,7 @@ do_node() {
         local command_status="$TMP/cs"
         rsh $HOST ":> $command_status"
         rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
-                    cd $RPWD; sh -c \"$@\") ||
+                    cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
                     echo command failed >$command_status"
         [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
         return 0
@@ -1491,12 +1491,12 @@ do_node() {
     if $verbose ; then
         # print HOSTNAME for myPDSH="no_dsh"
         if [[ $myPDSH = no_dsh ]]; then
-            $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
+            $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
         else
-            $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
+            $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
         fi
     else
-        $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
+        $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
     fi
     return ${PIPESTATUS[0]}
 }
@@ -1537,9 +1537,9 @@ do_nodes() {
     fi
 
     if $verbose ; then
-        $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
+        $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
     else
-        $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
+        $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -re "s/\w+:\s//g"
     fi
     return ${PIPESTATUS[0]}
 }
@@ -3275,8 +3275,8 @@ do_rpc_nodes () {
     shift
 
     # Add paths to lustre tests for 32 and 64 bit systems.
-    local RPATH="$LUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
-    do_nodes --verbose $list "PATH=$RPATH sh rpc.sh $@ " 
+    local RPATH="$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
+    do_nodes --verbose $list "PATH=$RPATH sh rpc.sh $@ "
 }
 
 wait_clients_import_state () {