From: Rahul Deshmukh Date: Tue, 5 Jan 2010 07:17:35 +0000 (+0530) Subject: b=19808 2.6.29-fc11 patchless client support X-Git-Tag: 1.10.0.34~4 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=95dbd166988cf0a2912c51305572c78a9aa2d324 b=19808 2.6.29-fc11 patchless client support Changes required to support fc11 patchless client on HEAD. i=oleg.drokin i=tappro --- diff --git a/build/autoconf/lustre-build.m4 b/build/autoconf/lustre-build.m4 index b85f5d5..10f1905 100644 --- a/build/autoconf/lustre-build.m4 +++ b/build/autoconf/lustre-build.m4 @@ -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 diff --git a/build/lbuild b/build/lbuild index e3380ba..dcb4dd7 100755 --- a/build/lbuild +++ b/build/lbuild @@ -1045,7 +1045,7 @@ find_linux_devel_paths() { # RHEL-style and SLES-style rpms # XXX - until bug 19336 cleans this up, we need to extricate the # ${lnxmin}- from the $lnxrel - local paths="kernels/${lnxmaj}${lnxmin}${delimiter}${lnxrel}-${TARGET_ARCH} linux-${lnxmaj}${lnxmin}${delimiter}${lnxrel##${lnxmin#.}-}" + local paths="kernels/${lnxmaj}${lnxmin}${delimiter}${lnxrel}-${TARGET_ARCH} kernels/${lnxmaj}${lnxmin}${delimiter}${lnxrel}.${TARGET_ARCH} linux-${lnxmaj}${lnxmin}${delimiter}${lnxrel##${lnxmin#.}-}" local path for path in $paths; do diff --git a/build/lbuild.old_school b/build/lbuild.old_school index 869be39..3b77c8e 100644 --- a/build/lbuild.old_school +++ b/build/lbuild.old_school @@ -519,7 +519,7 @@ patchless_build_sequence() { # default to source type -source and special case below local type=-source case "$DISTRO" in - rhel*) + rhel* | fc*) type=-devel ;; esac @@ -546,7 +546,7 @@ patchless_build_sequence() { if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then $rpmfound && build_kernel_ib fi - ( $rpmfound ) && build_lustre && buildsuccess=true && find_linux_source_rpm + ( $rpmfound ) && build_lustre "$LINUX" && buildsuccess=true && find_linux_source_rpm fi if $buildsuccess; then diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index 51a5889..6cba402 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -508,7 +508,7 @@ AC_DEFUN([LIBCFS_NETWORK_NAMESPACE], LB_LINUX_TRY_COMPILE([ #include ],[ - 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 +],[ + 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 +],[ + 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 + #include +],[ + 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 ]) diff --git a/libcfs/include/libcfs/curproc.h b/libcfs/include/libcfs/curproc.h index b79caf1..332799b 100644 --- a/libcfs/include/libcfs/curproc.h +++ b/libcfs/include/libcfs/curproc.h @@ -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); diff --git a/libcfs/include/libcfs/linux/libcfs.h b/libcfs/include/libcfs/linux/libcfs.h index 9e75d75..c7f946d 100644 --- a/libcfs/include/libcfs/linux/libcfs.h +++ b/libcfs/include/libcfs/linux/libcfs.h @@ -126,4 +126,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 */ diff --git a/libcfs/include/libcfs/linux/linux-tcpip.h b/libcfs/include/libcfs/linux/linux-tcpip.h index 84dd41b..175911e 100644 --- a/libcfs/include/libcfs/linux/linux-tcpip.h +++ b/libcfs/include/libcfs/linux/linux-tcpip.h @@ -51,6 +51,21 @@ #include +#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)) diff --git a/libcfs/include/libcfs/list.h b/libcfs/include/libcfs/list.h index bbdbff5..c70c34c 100644 --- a/libcfs/include/libcfs/list.h +++ b/libcfs/include/libcfs/list.h @@ -450,6 +450,16 @@ static inline void hlist_add_after(struct hlist_node *n, list_for_each_entry(pos, head, member) #endif +#ifndef list_for_each_entry_rcu +#define list_for_each_entry_rcu(pos, head, member) \ + list_for_each_entry(pos, head, member) +#endif + +#ifndef list_for_each_entry_rcu +#define list_for_each_entry_rcu(pos, head, member) \ + list_for_each_entry(pos, head, member) +#endif + #ifndef list_for_each_entry_reverse /** * Iterate backwards over a list of given type. diff --git a/libcfs/include/libcfs/user-prim.h b/libcfs/include/libcfs/user-prim.h index a5c4213..ad99755 100644 --- a/libcfs/include/libcfs/user-prim.h +++ b/libcfs/include/libcfs/user-prim.h @@ -149,6 +149,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) diff --git a/libcfs/libcfs/linux/linux-curproc.c b/libcfs/libcfs/linux/linux-curproc.c index be37723..385bbef 100644 --- a/libcfs/libcfs/linux/linux-curproc.c +++ b/libcfs/libcfs/linux/linux-curproc.c @@ -41,6 +41,7 @@ */ #include +#include #define DEBUG_SUBSYSTEM S_LNET @@ -53,22 +54,32 @@ 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); diff --git a/libcfs/libcfs/linux/linux-module.c b/libcfs/libcfs/linux/linux-module.c index 88eab3e..ae6034c 100644 --- a/libcfs/libcfs/linux/linux-module.c +++ b/libcfs/libcfs/linux/linux-module.c @@ -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 || diff --git a/libcfs/libcfs/linux/linux-prim.c b/libcfs/libcfs/linux/linux-prim.c index decc551..be9822d 100644 --- a/libcfs/libcfs/linux/linux-prim.c +++ b/libcfs/libcfs/linux/linux-prim.c @@ -40,6 +40,7 @@ #endif #include #include +#include #include #include @@ -233,19 +234,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) { diff --git a/libcfs/libcfs/user-prim.c b/libcfs/libcfs/user-prim.c index 03e4bea..45f80f3 100644 --- a/libcfs/libcfs/user-prim.c +++ b/libcfs/libcfs/user-prim.c @@ -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) { /* diff --git a/libsysio/configure.in b/libsysio/configure.in index 5ce600f..510ce21 100644 --- a/libsysio/configure.in +++ b/libsysio/configure.in @@ -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 +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 +#include + +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 < +],[ + 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' # @@ -1997,6 +2017,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 + #include +#ifdef HAVE_LINUX_MMTYPES_H + #include +#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 +],[ + 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 +],[ + 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 # @@ -2361,6 +2438,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 + ]) # @@ -2409,6 +2492,7 @@ lustre/kernel_patches/targets/2.6-patchless.target lustre/kernel_patches/targets/2.6-sles10.target lustre/kernel_patches/targets/2.6-sles11.target lustre/kernel_patches/targets/2.6-oel5.target +lustre/kernel_patches/targets/2.6-fc11.target lustre/ldlm/Makefile lustre/fid/Makefile lustre/fid/autoMakefile diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h index e72fdbf..ae5e012 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -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 in_group_p(gid_t gid); diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index 46b72a7..df7927c 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -43,6 +43,7 @@ #error sorry, lustre requires at least linux kernel 2.6.9 or later #endif +#include #include #include @@ -137,8 +138,8 @@ do {mutex_lock_nested(&(inode)->i_mutex, I_MUTEX_PARENT); } while(0) #define LOCK_DQONOFF_MUTEX(dqopt) do {down(&(dqopt)->dqonoff_sem); } while(0) #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) @@ -195,6 +196,18 @@ do {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 static inline int cleanup_group_info(void) @@ -427,6 +440,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 #ifdef HAVE_ASYNC_BLOCK_CIPHER diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index cad6c92..bb783e7 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -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) {} diff --git a/lustre/include/lustre/ll_fiemap.h b/lustre/include/lustre/ll_fiemap.h index 265ea65..9b751a8 100644 --- a/lustre/include/lustre/ll_fiemap.h +++ b/lustre/include/lustre/ll_fiemap.h @@ -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. diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 509756d..163f837 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -1057,7 +1057,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, diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 2a6dc54..01dd399 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -105,7 +105,8 @@ */ #define LDLM_THREADS_AUTO_MIN (2) -#define LDLM_THREADS_AUTO_MAX min(num_online_cpus()*num_online_cpus()*32, 128) +#define LDLM_THREADS_AUTO_MAX min_t(unsigned int, \ + num_online_cpus()*num_online_cpus()*32, 128) #define LDLM_BL_THREADS LDLM_THREADS_AUTO_MIN #define LDLM_NBUFS (64 * num_online_cpus()) #define LDLM_BUFSIZE (8 * 1024) diff --git a/lustre/kernel_patches/targets/2.6-fc11.target.in b/lustre/kernel_patches/targets/2.6-fc11.target.in new file mode 100644 index 0000000..959443f --- /dev/null +++ b/lustre/kernel_patches/targets/2.6-fc11.target.in @@ -0,0 +1,18 @@ +lnxmaj="2.6.29.4" +lnxrel="167.fc11" + +KERNEL=linux-${lnxmaj}-${lnxrel}.tar.bz2 +SERIES=2.6-fc5.series +VERSION=${lnxmaj} +EXTRA_VERSION=${lnxrel}_lustre.@VERSION@ +RHBUILD=1 +LINUX26=1 +LUSTRE_VERSION=@VERSION@ + +BASE_ARCHS="i686 x86_64" +BIGMEM_ARCHS="" +BOOT_ARCHS="" +JENSEN_ARCHS="" +SMP_ARCHS="i686 x86_64" +UP_ARCHS="" + diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 096bf9b..28bc704 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -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) || diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 3cabd3d..40dfb8a 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -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) { diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index ff45b5f..a44bf29 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -1086,7 +1086,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)) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index ed63c2b..8901da4 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1283,7 +1283,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); } @@ -1857,7 +1857,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, @@ -1880,7 +1880,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 @@ -1904,8 +1904,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) { @@ -1914,10 +1912,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, @@ -2116,8 +2123,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; diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c index 98e1e62..a2ce959 100644 --- a/lustre/llite/llite_nfs.c +++ b/lustre/llite/llite_nfs.c @@ -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)); diff --git a/lustre/llite/lloop.c b/lustre/llite/lloop.c index 0acd41e..eb567c5 100644 --- a/lustre/llite/lloop.c +++ b/lustre/llite/lloop.c @@ -599,9 +599,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 down(&lo->lo_ctl_mutex); lo->lo_refcnt++; @@ -610,9 +616,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 down(&lo->lo_ctl_mutex); --lo->lo_refcnt; @@ -622,11 +634,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; down(&lloop_mutex); @@ -634,7 +653,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; } @@ -724,7 +743,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; @@ -748,7 +767,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; } diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 943123e..eb7e394 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -699,7 +699,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); diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 61fb628..9514012 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -855,7 +855,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) diff --git a/lustre/llite/remote_perm.c b/lustre/llite/remote_perm.c index 08c4bc1..26c3350 100644 --- a/lustre/llite/remote_perm.c +++ b/lustre/llite/remote_perm.c @@ -130,17 +130,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()); spin_lock(&lli->lli_lock); 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; diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index d3b26b4..22dc711 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -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 diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c index f00f4f0..1d7a4f7 100644 --- a/lustre/llite/xattr.c +++ b/lustre/llite/xattr.c @@ -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); diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 3e7dfc8..b453edb 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -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.", @@ -1969,8 +1967,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); @@ -2063,8 +2061,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); @@ -2452,8 +2450,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(); /* diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index f8bdec2..86c4baea 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -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); } } diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c index 0ed24bb..660dfc4 100644 --- a/lustre/lov/lov_pack.c +++ b/lustre/lov/lov_pack.c @@ -388,8 +388,9 @@ 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; @@ -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 (copy_from_user(&lumv3, lump, sizeof(lumv3))) + if (copy_from_user(lumv3, lump, sizeof(*lumv3))) RETURN(-EFAULT); } else if (lmm_magic == __swab32(LOV_USER_MAGIC_V3)) { - if (copy_from_user(&lumv3, lump, sizeof(lumv3))) + if (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; } diff --git a/lustre/lvfs/lvfs_linux.c b/lustre/lvfs/lvfs_linux.c index 82b2d66..5d4608b 100644 --- a/lustre/lvfs/lvfs_linux.c +++ b/lustre/lvfs/lvfs_linux.c @@ -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); diff --git a/lustre/mdc/mdc_lib.c b/lustre/mdc/mdc_lib.c index 1bab2b6..f4223c2 100644 --- a/lustre/mdc/mdc_lib.c +++ b/lustre/mdc/mdc_lib.c @@ -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) diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index 5606b46..d533f11 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -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; diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 3076ce8..e1ebd0a 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -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; diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index d059730..89d18f2 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -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; } diff --git a/lustre/ptlrpc/sec.c b/lustre/ptlrpc/sec.c index 6926fc9..462a3a8 100644 --- a/lustre/ptlrpc/sec.c +++ b/lustre/ptlrpc/sec.c @@ -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, @@ -1471,7 +1471,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); @@ -2288,10 +2288,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; @@ -2299,7 +2299,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 diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 296073b..d3dbb63 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -1467,7 +1467,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 @@ -1476,12 +1476,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]} } @@ -1522,9 +1522,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]} } @@ -3218,7 +3218,7 @@ do_rpc_nodes () { local list=$1 shift - do_nodes --verbose $list "PATH=$LUSTRE/tests/:$PATH sh rpc.sh $@ " + do_nodes --verbose $list "PATH=$RLUSTRE/tests/:$PATH sh rpc.sh $@ " } wait_clients_import_state () {