diff options
Diffstat (limited to 'drivers/staging/lustre/lustre')
265 files changed, 2025 insertions, 13624 deletions
diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig index 209e4c7e6f8a..4f65ba1158bf 100644 --- a/drivers/staging/lustre/lustre/Kconfig +++ b/drivers/staging/lustre/lustre/Kconfig @@ -57,4 +57,5 @@ config LUSTRE_TRANSLATE_ERRNOS config LUSTRE_LLITE_LLOOP tristate "Lustre virtual block device" depends on LUSTRE_FS && BLOCK + depends on !PPC_64K_PAGES && !ARM64_64K_PAGES default m diff --git a/drivers/staging/lustre/lustre/fid/Makefile b/drivers/staging/lustre/lustre/fid/Makefile index d24f2df7c0af..5513ce416a35 100644 --- a/drivers/staging/lustre/lustre/fid/Makefile +++ b/drivers/staging/lustre/lustre/fid/Makefile @@ -1,6 +1,3 @@ obj-$(CONFIG_LUSTRE_FS) += fid.o fid-y := fid_request.o fid_lib.o fid-$(CONFIG_PROC_FS) += lproc_fid.o - - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h b/drivers/staging/lustre/lustre/fid/fid_internal.h index 1dbe46be0f41..eb607c52ef3b 100644 --- a/drivers/staging/lustre/lustre/fid/fid_internal.h +++ b/drivers/staging/lustre/lustre/fid/fid_internal.h @@ -40,16 +40,16 @@ #ifndef __FID_INTERNAL_H #define __FID_INTERNAL_H -#include <lustre/lustre_idl.h> -#include <linux/libcfs/libcfs.h> +#include "../include/lustre/lustre_idl.h" +#include "../../include/linux/libcfs/libcfs.h" /* Functions used internally in module. */ int seq_client_alloc_super(struct lu_client_seq *seq, const struct lu_env *env); -# ifdef LPROCFS +#if defined (CONFIG_PROC_FS) extern struct lprocfs_vars seq_client_proc_list[]; -# endif +#endif extern struct proc_dir_entry *seq_type_proc_dir; diff --git a/drivers/staging/lustre/lustre/fid/fid_lib.c b/drivers/staging/lustre/lustre/fid/fid_lib.c index f03afdec027a..dd65159ebb38 100644 --- a/drivers/staging/lustre/lustre/fid/fid_lib.c +++ b/drivers/staging/lustre/lustre/fid/fid_lib.c @@ -43,10 +43,10 @@ #define DEBUG_SUBSYSTEM S_FID -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" #include <linux/module.h> -#include <lustre/lustre_idl.h> -#include <lustre_fid.h> +#include "../include/lustre/lustre_idl.h" +#include "../include/lustre_fid.h" /** * A cluster-wide range from which fid-sequences are granted to servers and diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 3401c9ad42ac..992d07591b08 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -42,15 +42,15 @@ #define DEBUG_SUBSYSTEM S_FID -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" #include <linux/module.h> -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre_fid.h> +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/lustre_fid.h" /* mdc RPC locks */ -#include <lustre_mdc.h> +#include "../include/lustre_mdc.h" #include "fid_internal.h" static int seq_client_rpc(struct lu_client_seq *seq, @@ -197,7 +197,7 @@ static int seq_client_alloc_seq(const struct lu_env *env, rc = seq_client_alloc_meta(env, seq); if (rc) { CERROR("%s: Can't allocate new meta-sequence, rc %d\n", - seq->lcs_name, rc); + seq->lcs_name, rc); return rc; } else { CDEBUG(D_INFO, "%s: New range - "DRANGE"\n", @@ -211,7 +211,7 @@ static int seq_client_alloc_seq(const struct lu_env *env, *seqnr = seq->lcs_space.lsr_start; seq->lcs_space.lsr_start += 1; - CDEBUG(D_INFO, "%s: Allocated sequence ["LPX64"]\n", seq->lcs_name, + CDEBUG(D_INFO, "%s: Allocated sequence [%#llx]\n", seq->lcs_name, *seqnr); return rc; @@ -267,14 +267,14 @@ int seq_client_get_seq(const struct lu_env *env, rc = seq_client_alloc_seq(env, seq, seqnr); if (rc) { CERROR("%s: Can't allocate new sequence, rc %d\n", - seq->lcs_name, rc); + seq->lcs_name, rc); seq_fid_alloc_fini(seq); mutex_unlock(&seq->lcs_mutex); return rc; } - CDEBUG(D_INFO, "%s: allocate sequence [0x%16.16"LPF64"x]\n", - seq->lcs_name, *seqnr); + CDEBUG(D_INFO, "%s: allocate sequence [0x%16.16Lx]\n", + seq->lcs_name, *seqnr); /* Since the caller require the whole seq, * so marked this seq to be used */ @@ -330,14 +330,14 @@ int seq_client_alloc_fid(const struct lu_env *env, rc = seq_client_alloc_seq(env, seq, &seqnr); if (rc) { CERROR("%s: Can't allocate new sequence, rc %d\n", - seq->lcs_name, rc); + seq->lcs_name, rc); seq_fid_alloc_fini(seq); mutex_unlock(&seq->lcs_mutex); return rc; } - CDEBUG(D_INFO, "%s: Switch to sequence [0x%16.16"LPF64"x]\n", - seq->lcs_name, seqnr); + CDEBUG(D_INFO, "%s: Switch to sequence [0x%16.16Lx]\n", + seq->lcs_name, seqnr); seq->lcs_fid.f_oid = LUSTRE_FID_INIT_OID; seq->lcs_fid.f_seq = seqnr; @@ -400,18 +400,18 @@ EXPORT_SYMBOL(seq_client_flush); static void seq_client_proc_fini(struct lu_client_seq *seq) { -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) if (seq->lcs_proc_dir) { if (!IS_ERR(seq->lcs_proc_dir)) lprocfs_remove(&seq->lcs_proc_dir); seq->lcs_proc_dir = NULL; } -#endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS */ } static int seq_client_proc_init(struct lu_client_seq *seq) { -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) int rc; seq->lcs_proc_dir = lprocfs_register(seq->lcs_name, @@ -429,7 +429,7 @@ static int seq_client_proc_init(struct lu_client_seq *seq) seq_client_proc_list, seq); if (rc) { CERROR("%s: Can't init sequence manager proc, rc %d\n", - seq->lcs_name, rc); + seq->lcs_name, rc); GOTO(out_cleanup, rc); } @@ -439,7 +439,7 @@ out_cleanup: seq_client_proc_fini(seq); return rc; -#else /* LPROCFS */ +#else /* CONFIG_PROC_FS */ return 0; #endif } diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index 6f5674d1aa72..92a27fa9667c 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -42,16 +42,16 @@ #define DEBUG_SUBSYSTEM S_FID -# include <linux/libcfs/libcfs.h> -# include <linux/module.h> - -#include <obd.h> -#include <obd_class.h> -#include <dt_object.h> -#include <md_object.h> -#include <obd_support.h> -#include <lustre_req_layout.h> -#include <lustre_fid.h> +#include "../../include/linux/libcfs/libcfs.h" +#include <linux/module.h> + +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/dt_object.h" +#include "../include/md_object.h" +#include "../include/obd_support.h" +#include "../include/lustre_req_layout.h" +#include "../include/lustre_fid.h" #include "fid_internal.h" /* Format: [0x64BIT_INT - 0x64BIT_INT] + 32 bytes just in case */ @@ -98,9 +98,10 @@ static ssize_t lprocfs_fid_space_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private; + struct lu_client_seq *seq; int rc; + seq = ((struct seq_file *)file->private_data)->private; LASSERT(seq != NULL); mutex_lock(&seq->lcs_mutex); @@ -125,7 +126,7 @@ lprocfs_fid_space_seq_show(struct seq_file *m, void *unused) LASSERT(seq != NULL); mutex_lock(&seq->lcs_mutex); - rc = seq_printf(m, "["LPX64" - "LPX64"]:%x:%s\n", PRANGE(&seq->lcs_space)); + rc = seq_printf(m, "[%#llx - %#llx]:%x:%s\n", PRANGE(&seq->lcs_space)); mutex_unlock(&seq->lcs_mutex); return rc; @@ -135,10 +136,11 @@ static ssize_t lprocfs_fid_width_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private; + struct lu_client_seq *seq; __u64 max; int rc, val; + seq = ((struct seq_file *)file->private_data)->private; LASSERT(seq != NULL); rc = lprocfs_write_helper(buffer, count, &val); @@ -155,7 +157,7 @@ static ssize_t lprocfs_fid_width_seq_write(struct file *file, seq->lcs_width = val; if (rc == 0) { - CDEBUG(D_INFO, "%s: Sequence size: "LPU64"\n", + CDEBUG(D_INFO, "%s: Sequence size: %llu\n", seq->lcs_name, seq->lcs_width); } } @@ -174,7 +176,7 @@ lprocfs_fid_width_seq_show(struct seq_file *m, void *unused) LASSERT(seq != NULL); mutex_lock(&seq->lcs_mutex); - rc = seq_printf(m, LPU64"\n", seq->lcs_width); + rc = seq_printf(m, "%llu\n", seq->lcs_width); mutex_unlock(&seq->lcs_mutex); return rc; diff --git a/drivers/staging/lustre/lustre/fld/Makefile b/drivers/staging/lustre/lustre/fld/Makefile index 640fba4b827d..2bbf08433dca 100644 --- a/drivers/staging/lustre/lustre/fld/Makefile +++ b/drivers/staging/lustre/lustre/fld/Makefile @@ -1,6 +1,3 @@ obj-$(CONFIG_LUSTRE_FS) += fld.o fld-y := fld_request.o fld_cache.o fld-$(CONFIG_PROC_FS) += lproc_fld.o - - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index a06a642f549e..759a233a7028 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -43,20 +43,20 @@ #define DEBUG_SUBSYSTEM S_FLD -# include <linux/libcfs/libcfs.h> -# include <linux/module.h> -# include <asm/div64.h> - -#include <obd.h> -#include <obd_class.h> -#include <lustre_ver.h> -#include <obd_support.h> -#include <lprocfs_status.h> - -#include <dt_object.h> -#include <md_object.h> -#include <lustre_req_layout.h> -#include <lustre_fld.h> +#include "../../include/linux/libcfs/libcfs.h" +#include <linux/module.h> +#include <asm/div64.h> + +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/lustre_ver.h" +#include "../include/obd_support.h" +#include "../include/lprocfs_status.h" + +#include "../include/dt_object.h" +#include "../include/md_object.h" +#include "../include/lustre_req_layout.h" +#include "../include/lustre_fld.h" #include "fld_internal.h" /** @@ -113,9 +113,9 @@ void fld_cache_fini(struct fld_cache *cache) } CDEBUG(D_INFO, "FLD cache statistics (%s):\n", cache->fci_name); - CDEBUG(D_INFO, " Total reqs: "LPU64"\n", cache->fci_stat.fst_count); - CDEBUG(D_INFO, " Cache reqs: "LPU64"\n", cache->fci_stat.fst_cache); - CDEBUG(D_INFO, " Cache hits: "LPU64"%%\n", pct); + CDEBUG(D_INFO, " Total reqs: %llu\n", cache->fci_stat.fst_count); + CDEBUG(D_INFO, " Cache reqs: %llu\n", cache->fci_stat.fst_cache); + CDEBUG(D_INFO, " Cache hits: %llu%%\n", pct); OBD_FREE_PTR(cache); } diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h index 8661a788f120..5da0c1da0d39 100644 --- a/drivers/staging/lustre/lustre/fld/fld_internal.h +++ b/drivers/staging/lustre/lustre/fld/fld_internal.h @@ -41,12 +41,12 @@ #ifndef __FLD_INTERNAL_H #define __FLD_INTERNAL_H -#include <lustre/lustre_idl.h> -#include <dt_object.h> +#include "../include/lustre/lustre_idl.h" +#include "../include/dt_object.h" -#include <linux/libcfs/libcfs.h> -#include <lustre_req_layout.h> -#include <lustre_fld.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/lustre_req_layout.h" +#include "../include/lustre_fld.h" enum { LUSTRE_FLD_INIT = 1 << 0, @@ -142,7 +142,7 @@ extern struct lu_fld_hash fld_hash[]; int fld_client_rpc(struct obd_export *exp, struct lu_seq_range *range, __u32 fld_op); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) extern struct lprocfs_vars fld_client_proc_list[]; #endif diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 1f8abba31428..8e512f9c3db0 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -42,21 +42,21 @@ #define DEBUG_SUBSYSTEM S_FLD -# include <linux/libcfs/libcfs.h> -# include <linux/module.h> -# include <asm/div64.h> - -#include <obd.h> -#include <obd_class.h> -#include <lustre_ver.h> -#include <obd_support.h> -#include <lprocfs_status.h> - -#include <dt_object.h> -#include <md_object.h> -#include <lustre_req_layout.h> -#include <lustre_fld.h> -#include <lustre_mdc.h> +#include "../../include/linux/libcfs/libcfs.h" +#include <linux/module.h> +#include <asm/div64.h> + +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/lustre_ver.h" +#include "../include/obd_support.h" +#include "../include/lprocfs_status.h" + +#include "../include/dt_object.h" +#include "../include/md_object.h" +#include "../include/lustre_req_layout.h" +#include "../include/lustre_fld.h" +#include "../include/lustre_mdc.h" #include "fld_internal.h" /* TODO: these 3 functions are copies of flow-control code from mdc_lib.c @@ -138,7 +138,7 @@ fld_rrb_scan(struct lu_client_fld *fld, seqno_t seq) return target; } - CERROR("%s: Can't find target by hash %d (seq "LPX64"). Targets (%d):\n", + CERROR("%s: Can't find target by hash %d (seq %#llx). Targets (%d):\n", fld->lcf_name, hash, seq, fld->lcf_count); list_for_each_entry(target, &fld->lcf_targets, ft_chain) { @@ -148,7 +148,7 @@ fld_rrb_scan(struct lu_client_fld *fld, seqno_t seq) (char *)target->ft_exp->exp_obd->obd_uuid.uuid : "<null>"; - CERROR(" exp: 0x%p (%s), srv: 0x%p (%s), idx: "LPU64"\n", + CERROR(" exp: 0x%p (%s), srv: 0x%p (%s), idx: %llu\n", target->ft_exp, exp_name, target->ft_srv, srv_name, target->ft_idx); } @@ -168,7 +168,7 @@ struct lu_fld_hash fld_hash[] = { .fh_scan_func = fld_rrb_scan }, { - 0, + NULL, } }; @@ -184,9 +184,8 @@ fld_client_get_target(struct lu_client_fld *fld, seqno_t seq) spin_unlock(&fld->lcf_lock); if (target != NULL) { - CDEBUG(D_INFO, "%s: Found target (idx "LPU64 - ") by seq "LPX64"\n", fld->lcf_name, - target->ft_idx, seq); + CDEBUG(D_INFO, "%s: Found target (idx %llu) by seq %#llx\n", + fld->lcf_name, target->ft_idx, seq); } return target; @@ -208,12 +207,12 @@ int fld_client_add_target(struct lu_client_fld *fld, LASSERT(tar->ft_srv != NULL || tar->ft_exp != NULL); if (fld->lcf_flags != LUSTRE_FLD_INIT) { - CERROR("%s: Attempt to add target %s (idx "LPU64") on fly - skip it\n", + CERROR("%s: Attempt to add target %s (idx %llu) on fly - skip it\n", fld->lcf_name, name, tar->ft_idx); return 0; } else { - CDEBUG(D_INFO, "%s: Adding target %s (idx " - LPU64")\n", fld->lcf_name, name, tar->ft_idx); + CDEBUG(D_INFO, "%s: Adding target %s (idx %llu)\n", + fld->lcf_name, name, tar->ft_idx); } OBD_ALLOC_PTR(target); @@ -225,7 +224,7 @@ int fld_client_add_target(struct lu_client_fld *fld, if (tmp->ft_idx == tar->ft_idx) { spin_unlock(&fld->lcf_lock); OBD_FREE_PTR(target); - CERROR("Target %s exists in FLD and known as %s:#"LPU64"\n", + CERROR("Target %s exists in FLD and known as %s:#%llu\n", name, fld_target_name(tmp), tmp->ft_idx); return -EEXIST; } @@ -274,7 +273,7 @@ EXPORT_SYMBOL(fld_client_del_target); struct proc_dir_entry *fld_type_proc_dir = NULL; -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) static int fld_client_proc_init(struct lu_client_fld *fld) { int rc; @@ -324,7 +323,6 @@ void fld_client_proc_fini(struct lu_client_fld *fld) return; } #endif - EXPORT_SYMBOL(fld_client_proc_fini); static inline int hash_is_sane(int hash) @@ -474,7 +472,7 @@ int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds, target = fld_client_get_target(fld, seq); LASSERT(target != NULL); - CDEBUG(D_INFO, "%s: Lookup fld entry (seq: "LPX64") on target %s (idx "LPU64")\n", + CDEBUG(D_INFO, "%s: Lookup fld entry (seq: %#llx) on target %s (idx %llu)\n", fld->lcf_name, seq, fld_target_name(target), target->ft_idx); res.lsr_start = seq; diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index 530adde46963..7f6bcc63c5eb 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -43,17 +43,17 @@ #define DEBUG_SUBSYSTEM S_FLD -# include <linux/libcfs/libcfs.h> -# include <linux/module.h> - -#include <obd.h> -#include <obd_class.h> -#include <dt_object.h> -#include <md_object.h> -#include <obd_support.h> -#include <lustre_req_layout.h> -#include <lustre_fld.h> -#include <lustre_fid.h> +#include "../../include/linux/libcfs/libcfs.h" +#include <linux/module.h> + +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/dt_object.h" +#include "../include/md_object.h" +#include "../include/obd_support.h" +#include "../include/lustre_req_layout.h" +#include "../include/lustre_fld.h" +#include "../include/lustre_fid.h" #include "fld_internal.h" static int @@ -91,10 +91,11 @@ static ssize_t fld_proc_hash_seq_write(struct file *file, const char *buffer, size_t count, loff_t *off) { - struct lu_client_fld *fld = ((struct seq_file *)file->private_data)->private; + struct lu_client_fld *fld; struct lu_fld_hash *hash = NULL; int i; + fld = ((struct seq_file *)file->private_data)->private; LASSERT(fld != NULL); for (i = 0; fld_hash[i].fh_name != NULL; i++) { diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index c809239c0866..e51cd690f907 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -97,10 +97,10 @@ /* * super-class definitions. */ -#include <lu_object.h> -#include <lvfs.h> -# include <linux/mutex.h> -# include <linux/radix-tree.h> +#include "lu_object.h" +#include "lvfs.h" +#include <linux/mutex.h> +#include <linux/radix-tree.h> struct inode; diff --git a/drivers/staging/lustre/lustre/include/dt_object.h b/drivers/staging/lustre/lustre/include/dt_object.h index 9b7921d1dea8..212ebaea8555 100644 --- a/drivers/staging/lustre/lustre/include/dt_object.h +++ b/drivers/staging/lustre/lustre/include/dt_object.h @@ -53,9 +53,9 @@ /* * super-class definitions. */ -#include <lu_object.h> +#include "lu_object.h" -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" struct seq_file; struct proc_dir_entry; @@ -1481,7 +1481,7 @@ static inline struct dt_thread_info *dt_info(const struct lu_env *env) int dt_global_init(void); void dt_global_fini(void); -# ifdef LPROCFS +#if defined (CONFIG_PROC_FS) int lprocfs_dt_rd_blksize(char *page, char **start, off_t off, int count, int *eof, void *data); int lprocfs_dt_rd_kbytestotal(char *page, char **start, off_t off, @@ -1494,6 +1494,6 @@ int lprocfs_dt_rd_filestotal(char *page, char **start, off_t off, int count, int *eof, void *data); int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off, int count, int *eof, void *data); -# endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS */ #endif /* __LUSTRE_DT_OBJECT_H */ diff --git a/drivers/staging/lustre/lustre/include/interval_tree.h b/drivers/staging/lustre/lustre/include/interval_tree.h index dfdb8aa4e035..1815783edae6 100644 --- a/drivers/staging/lustre/lustre/include/interval_tree.h +++ b/drivers/staging/lustre/lustre/include/interval_tree.h @@ -40,7 +40,7 @@ #ifndef _INTERVAL_H__ #define _INTERVAL_H__ -#include <linux/libcfs/libcfs.h> /* LASSERT. */ +#include "../../include/linux/libcfs/libcfs.h" /* LASSERT. */ struct interval_node { struct interval_node *in_left; diff --git a/drivers/staging/lustre/lustre/include/linux/lprocfs_status.h b/drivers/staging/lustre/lustre/include/linux/lprocfs_status.h index 4bcc4dcca3da..cb76b5d6f71a 100644 --- a/drivers/staging/lustre/lustre/include/linux/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/linux/lprocfs_status.h @@ -50,7 +50,7 @@ #include <linux/seq_file.h> #include <linux/smp.h> #include <linux/rwsem.h> -#include <linux/libcfs/libcfs.h> +#include "../../../include/linux/libcfs/libcfs.h" #include <linux/statfs.h> diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_acl.h b/drivers/staging/lustre/lustre/include/linux/lustre_acl.h index a91c5497d22c..b17273d403bb 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_acl.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_acl.h @@ -56,7 +56,7 @@ (sizeof(posix_acl_xattr_header) + \ LUSTRE_POSIX_ACL_MAX_ENTRIES * sizeof(posix_acl_xattr_entry)) -#include <linux/lustre_intent.h> +#include "lustre_intent.h" #include <linux/xattr.h> /* XATTR_{REPLACE,CREATE} */ #ifndef LUSTRE_POSIX_ACL_MAX_SIZE diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 81cc7a0134bb..8621bac5058b 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -39,9 +39,9 @@ #include <linux/fs_struct.h> #include <linux/namei.h> -#include <linux/libcfs/linux/portals_compat25.h> +#include "../../../include/linux/libcfs/linux/portals_compat25.h" -#include <linux/lustre_patchless_compat.h> +#include "lustre_patchless_compat.h" # define LOCK_FS_STRUCT(fs) spin_lock(&(fs)->lock) # define UNLOCK_FS_STRUCT(fs) spin_unlock(&(fs)->lock) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h b/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h index 4da6e372e00b..d5c97beb66f5 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h @@ -46,8 +46,8 @@ #endif -#include <obd.h> -#include <obd_class.h> +#include "../obd.h" +#include "../obd_class.h" typedef void (*fsfilt_cb_t)(struct obd_device *obd, __u64 last_rcvd, void *data, int error); @@ -90,12 +90,12 @@ static inline char *fsfilt_get_label(struct obd_device *obd, #define __fsfilt_check_slow(obd, start, msg) \ do { \ - if (cfs_time_before(jiffies, start + 15 * HZ)) \ + if (time_before(jiffies, start + 15 * HZ)) \ break; \ - else if (cfs_time_before(jiffies, start + 30 * HZ)) \ + else if (time_before(jiffies, start + 30 * HZ)) \ CDEBUG(D_VFSTRACE, "%s: slow %s %lus\n", obd->obd_name, \ msg, (jiffies-start) / HZ); \ - else if (cfs_time_before(jiffies, start + DISK_TIMEOUT * HZ)) \ + else if (time_before(jiffies, start + DISK_TIMEOUT * HZ)) \ CWARN("%s: slow %s %lus\n", obd->obd_name, msg, \ (jiffies - start) / HZ); \ else \ diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_lib.h b/drivers/staging/lustre/lustre/include/linux/lustre_lib.h index 57f3b01d1a32..0a4c65ae9242 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_lib.h @@ -49,8 +49,8 @@ # include <linux/sched.h> # include <linux/signal.h> # include <linux/types.h> -# include <linux/lustre_compat25.h> -# include <linux/lustre_common.h> +#include "lustre_compat25.h" +#include "lustre_common.h" #ifndef LP_POISON # define LI_POISON 0x5a5a5a5a diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h index df9391275617..99eed4987635 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h @@ -46,13 +46,13 @@ #include <linux/dcache.h> #include <linux/proc_fs.h> -#include <obd_class.h> -#include <lustre_net.h> -#include <lustre_ha.h> +#include "../obd_class.h" +#include "../lustre_net.h" +#include "../lustre_ha.h" #include <linux/rbtree.h> -#include <linux/lustre_compat25.h> -#include <linux/lustre_common.h> +#include "../../include/linux/lustre_compat25.h" +#include "../../include/linux/lustre_common.h" #include <linux/pagemap.h> /* lprocfs.c */ diff --git a/drivers/staging/lustre/lustre/include/linux/lvfs.h b/drivers/staging/lustre/lustre/include/linux/lvfs.h index e61f1b87f822..dd1be9c39829 100644 --- a/drivers/staging/lustre/lustre/include/linux/lvfs.h +++ b/drivers/staging/lustre/lustre/include/linux/lvfs.h @@ -45,9 +45,9 @@ #error Do not #include this file directly. #include <lvfs.h> instead #endif -#include <linux/lustre_compat25.h> -#include <linux/lustre_common.h> -#include <linux/lvfs_linux.h> +#include "lustre_compat25.h" +#include "lustre_common.h" +#include "lvfs_linux.h" #define LLOG_LVFS diff --git a/drivers/staging/lustre/lustre/include/linux/lvfs_linux.h b/drivers/staging/lustre/lustre/include/linux/lvfs_linux.h index 140a60f1f0c9..fff22ec1f869 100644 --- a/drivers/staging/lustre/lustre/include/linux/lvfs_linux.h +++ b/drivers/staging/lustre/lustre/include/linux/lvfs_linux.h @@ -41,15 +41,10 @@ #include <linux/namei.h> #include <linux/sched.h> -#include <lvfs.h> - -#define l_file file -#define l_dentry dentry - -#define l_filp_open filp_open +#include "../lvfs.h" struct lvfs_run_ctxt; -struct l_file *l_dentry_open(struct lvfs_run_ctxt *, struct l_dentry *, +struct file *l_dentry_open(struct lvfs_run_ctxt *, struct dentry *, int flags); struct l_linux_dirent { diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h index f96f65d5168f..2a3a88cbb192 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd.h +++ b/drivers/staging/lustre/lustre/include/linux/obd.h @@ -41,14 +41,14 @@ #error Do not #include this file directly. #include <obd.h> instead #endif -#include <obd_support.h> +#include "../obd_support.h" # include <linux/fs.h> # include <linux/list.h> # include <linux/sched.h> /* for struct task_struct, for current.h */ # include <linux/proc_fs.h> # include <linux/mount.h> -# include <linux/lustre_intent.h> +#include "lustre_intent.h" struct ll_iattr { struct iattr iattr; diff --git a/drivers/staging/lustre/lustre/include/linux/obd_support.h b/drivers/staging/lustre/lustre/include/linux/obd_support.h index 9166503408aa..ea03b8434f62 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd_support.h +++ b/drivers/staging/lustre/lustre/include/linux/obd_support.h @@ -50,14 +50,14 @@ #include <linux/slab.h> #include <linux/highmem.h> #include <linux/swap.h> -#include <linux/lustre_compat25.h> -#include <linux/lustre_common.h> -#include <linux/libcfs/libcfs.h> -#include <lustre/lustre_idl.h> +#include "../../include/linux/lustre_compat25.h" +#include "lustre_common.h" +#include "../../../include/linux/libcfs/libcfs.h" +#include "../lustre/lustre_idl.h" # include <linux/types.h> # include <linux/blkdev.h> -# include <lvfs.h> +# include "../lvfs.h" #endif diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 1b7f6a9bf62c..16b3d6887ff6 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -42,9 +42,8 @@ #ifndef _LPROCFS_SNMP_H #define _LPROCFS_SNMP_H -#include <linux/lprocfs_status.h> -#include <lustre/lustre_idl.h> -#include <linux/libcfs/params_tree.h> +#include "linux/lprocfs_status.h" +#include "lustre/lustre_idl.h" struct lprocfs_vars { const char *name; @@ -375,7 +374,7 @@ extern int lprocfs_write_frac_helper(const char *buffer, unsigned long count, int *val, int mult); extern int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, int mult); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid); @@ -605,7 +604,7 @@ extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name, extern int lprocfs_rd_u64(struct seq_file *m, void *data); extern int lprocfs_rd_atomic(struct seq_file *m, void *data); -extern int lprocfs_wr_atomic(struct file *file, const char *buffer, +extern int lprocfs_wr_atomic(struct file *file, const char __user *buffer, unsigned long count, void *data); extern int lprocfs_rd_uint(struct seq_file *m, void *data); extern int lprocfs_wr_uint(struct file *file, const char *buffer, @@ -662,8 +661,8 @@ unsigned long lprocfs_oh_sum(struct obd_histogram *oh); void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, struct lprocfs_counter *cnt); -extern int lprocfs_single_release(cfs_inode_t *, struct file *); -extern int lprocfs_seq_release(cfs_inode_t *, struct file *); +extern int lprocfs_single_release(struct inode *, struct file *); +extern int lprocfs_seq_release(struct inode *, struct file *); /* You must use these macros when you want to refer to * the import in a client obd_device for a lprocfs entry */ @@ -684,7 +683,7 @@ extern int lprocfs_seq_release(cfs_inode_t *, struct file *); a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally, call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */ #define __LPROC_SEQ_FOPS(name, custom_seq_write) \ -static int name##_single_open(cfs_inode_t *inode, struct file *file) \ +static int name##_single_open(struct inode *inode, struct file *file) \ { \ return single_open(file, name##_seq_show, PDE_DATA(inode)); \ } \ @@ -727,7 +726,7 @@ static struct file_operations name##_fops = { \ { \ return lprocfs_wr_##type(file, buffer, count, off); \ } \ - static int name##_##type##_open(cfs_inode_t *inode, struct file *file) \ + static int name##_##type##_open(struct inode *inode, struct file *file) \ { \ return single_open(file, NULL, PDE_DATA(inode)); \ } \ @@ -806,7 +805,7 @@ extern int lprocfs_quota_wr_qs_factor(struct file *file, const char *buffer, unsigned long count, void *data); #else -/* LPROCFS is not defined */ +/* CONFIG_PROC_FS is not defined */ #define proc_lustre_root NULL @@ -1000,6 +999,6 @@ __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx, /* lproc_ptlrpc.c */ #define target_print_req NULL -#endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS */ #endif /* LPROCFS_SNMP_H */ diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index 98149f5da153..d5c368bab5bd 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -38,9 +38,9 @@ #define __LUSTRE_LU_OBJECT_H #include <stdarg.h> -#include <linux/libcfs/libcfs.h> -#include <lustre/lustre_idl.h> -#include <lu_ref.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "lustre/lustre_idl.h" +#include "lu_ref.h" struct seq_file; struct proc_dir_entry; diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 83014c9fea65..757146273724 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -91,14 +91,11 @@ #ifndef _LUSTRE_IDL_H_ #define _LUSTRE_IDL_H_ -#if !defined(LPU64) -#include <linux/libcfs/libcfs.h> /* for LPUX64, etc */ -#endif +#include "../../../include/linux/libcfs/libcfs.h" /* Defn's shared with user-space. */ -#include <lustre/lustre_user.h> - -#include <lustre/lustre_errno.h> +#include "lustre_user.h" +#include "lustre_errno.h" /* * GENERAL STUFF @@ -302,7 +299,7 @@ static inline int range_compare_loc(const struct lu_seq_range *r1, r1->lsr_flags != r2->lsr_flags; } -#define DRANGE "[%#16.16"LPF64"x-%#16.16"LPF64"x):%x:%s" +#define DRANGE "[%#16.16Lx-%#16.16Lx):%x:%s" #define PRANGE(range) \ (range)->lsr_start, \ @@ -682,14 +679,14 @@ static inline void ostid_set_id(struct ost_id *oi, __u64 oid) { if (fid_seq_is_mdt0(ostid_seq(oi))) { if (oid >= IDIF_MAX_OID) { - CERROR("Bad "LPU64" to set "DOSTID"\n", + CERROR("Bad %llu to set "DOSTID"\n", oid, POSTID(oi)); return; } oi->oi.oi_id = oid; } else { if (oid > OBIF_MAX_OID) { - CERROR("Bad "LPU64" to set "DOSTID"\n", + CERROR("Bad %llu to set "DOSTID"\n", oid, POSTID(oi)); return; } @@ -2748,7 +2745,7 @@ struct ldlm_res_id { __u64 name[RES_NAME_SIZE]; }; -#define DLDLMRES "["LPX64":"LPX64":"LPX64"]."LPX64i +#define DLDLMRES "[%#llx:%#llx:%#llx].%llx" #define PLDLMRES(res) (res)->lr_name.name[0], (res)->lr_name.name[1], \ (res)->lr_name.name[2], (res)->lr_name.name[3] diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 95c754f2075f..a69b27a78042 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -46,8 +46,8 @@ * @{ */ -#include <lustre/ll_fiemap.h> -#include <linux/lustre_user.h> +#include "ll_fiemap.h" +#include "../linux/lustre_user.h" /* for statfs() */ #define LL_SUPER_MAGIC 0x0BD00BD0 @@ -179,7 +179,7 @@ struct ost_id { }; }; -#define DOSTID LPX64":"LPU64 +#define DOSTID "%#llx:%llu" #define POSTID(oi) ostid_seq(oi), ostid_id(oi) /* @@ -475,7 +475,7 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) e.g. printf("file FID is "DFID"\n", PFID(fid)); */ #define FID_NOBRACE_LEN 40 #define FID_LEN (FID_NOBRACE_LEN + 2) -#define DFID_NOBRACE LPX64":0x%x:0x%x" +#define DFID_NOBRACE "%#llx:0x%x:0x%x" #define DFID "["DFID_NOBRACE"]" #define PFID(fid) \ (fid)->f_seq, \ @@ -484,11 +484,7 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) /* scanf input parse format -- strip '[' first. e.g. sscanf(fidstr, SFID, RFID(&fid)); */ -/* #define SFID "0x"LPX64i":0x"LPSZX":0x"LPSZX"" -liblustreapi.c:2893: warning: format '%lx' expects type 'long unsigned int *', but argument 4 has type 'unsigned int *' -liblustreapi.c:2893: warning: format '%lx' expects type 'long unsigned int *', but argument 5 has type 'unsigned int *' -*/ -#define SFID "0x"LPX64i":0x%x:0x%x" +#define SFID "0x%llx:0x%x:0x%x" #define RFID(fid) \ &((fid)->f_seq), \ &((fid)->f_oid), \ diff --git a/drivers/staging/lustre/lustre/include/lustre_acl.h b/drivers/staging/lustre/lustre/include/lustre_acl.h index 5cfb87b180c3..0b6ea0782229 100644 --- a/drivers/staging/lustre/lustre/include/lustre_acl.h +++ b/drivers/staging/lustre/lustre/include/lustre_acl.h @@ -37,6 +37,6 @@ #ifndef _LUSTRE_ACL_H #define _LUSTRE_ACL_H -#include <linux/lustre_acl.h> +#include "linux/lustre_acl.h" #endif diff --git a/drivers/staging/lustre/lustre/include/lustre_capa.h b/drivers/staging/lustre/lustre/include/lustre_capa.h index d77bffc0b59d..ab6b9ea98a70 100644 --- a/drivers/staging/lustre/lustre/include/lustre_capa.h +++ b/drivers/staging/lustre/lustre/include/lustre_capa.h @@ -50,7 +50,7 @@ * capability */ #include <linux/crypto.h> -#include <lustre/lustre_idl.h> +#include "lustre/lustre_idl.h" #define CAPA_TIMEOUT 1800 /* sec, == 30 min */ #define CAPA_KEY_TIMEOUT (24 * 60 * 60) /* sec, == 1 days */ @@ -82,7 +82,7 @@ struct obd_capa { struct lustre_capa c_capa; /* capa */ atomic_t c_refc; /* ref count */ - cfs_time_t c_expiry; /* jiffies */ + unsigned long c_expiry; /* jiffies */ spinlock_t c_lock; /* protect capa content */ int c_site; @@ -167,7 +167,7 @@ do { \ #define DEBUG_CAPA_KEY(level, k, fmt, args...) \ do { \ -CDEBUG(level, fmt " capability key@%p seq "LPU64" keyid %u\n", \ +CDEBUG(level, fmt " capability key@%p seq %llu keyid %u\n", \ ##args, k, capa_key_seq(k), capa_key_keyid(k)); \ } while (0) @@ -266,20 +266,20 @@ static inline __u64 capa_open_opc(int mode) static inline void set_capa_expiry(struct obd_capa *ocapa) { - cfs_time_t expiry = cfs_time_sub((cfs_time_t)ocapa->c_capa.lc_expiry, - cfs_time_current_sec()); + unsigned long expiry = cfs_time_sub((unsigned long)ocapa->c_capa.lc_expiry, + get_seconds()); ocapa->c_expiry = cfs_time_add(cfs_time_current(), cfs_time_seconds(expiry)); } static inline int capa_is_expired_sec(struct lustre_capa *capa) { - return (capa->lc_expiry - cfs_time_current_sec() <= 0); + return (capa->lc_expiry - get_seconds() <= 0); } static inline int capa_is_expired(struct obd_capa *ocapa) { - return cfs_time_beforeq(ocapa->c_expiry, cfs_time_current()); + return time_before_eq(ocapa->c_expiry, cfs_time_current()); } static inline int capa_opc_supported(struct lustre_capa *capa, __u64 opc) diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index 3680668a8920..03017fe49d46 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -222,7 +222,7 @@ static inline int lustre_cfg_len(__u32 bufcount, __u32 *buflens) } -#include <obd_support.h> +#include "obd_support.h" static inline struct lustre_cfg *lustre_cfg_new(int cmd, struct lustre_cfg_bufs *bufs) @@ -286,7 +286,7 @@ static inline int lustre_cfg_sanity_check(void *buf, int len) return 0; } -#include <lustre/lustre_user.h> +#include "lustre/lustre_user.h" /** @} cfg */ diff --git a/drivers/staging/lustre/lustre/include/lustre_debug.h b/drivers/staging/lustre/lustre/include/lustre_debug.h index 6146ccb8cce0..6c92d0bc943b 100644 --- a/drivers/staging/lustre/lustre/include/lustre_debug.h +++ b/drivers/staging/lustre/lustre/include/lustre_debug.h @@ -42,8 +42,8 @@ * @{ */ -#include <lustre_net.h> -#include <obd.h> +#include "lustre_net.h" +#include "obd.h" /* lib/debug.c */ void dump_lniobuf(struct niobuf_local *lnb); diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index ac08164793cb..7f191eed2a81 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -48,8 +48,8 @@ * @{ */ -#include <linux/libcfs/libcfs.h> -#include <linux/lnet/types.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../../include/linux/lnet/types.h" #include <linux/backing-dev.h> /****************** on-disk files *********************/ diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 0c6b7841e56d..30b1812f4bf6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -48,14 +48,14 @@ #ifndef _LUSTRE_DLM_H__ #define _LUSTRE_DLM_H__ -#include <linux/lustre_dlm.h> +#include "linux/lustre_dlm.h" -#include <lustre_lib.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_handles.h> -#include <interval_tree.h> /* for interval_node{}, ldlm_extent */ -#include <lu_ref.h> +#include "lustre_lib.h" +#include "lustre_net.h" +#include "lustre_import.h" +#include "lustre_handles.h" +#include "interval_tree.h" /* for interval_node{}, ldlm_extent */ +#include "lu_ref.h" #include "lustre_dlm_flags.h" @@ -441,7 +441,7 @@ struct ldlm_namespace { * \see ldlm_namespace_dump. Increased by 10 seconds every time * it is called. */ - cfs_time_t ns_next_dump; + unsigned long ns_next_dump; /** "policy" function that does actual lock conflict determination */ ldlm_res_policy ns_policy; @@ -783,13 +783,13 @@ struct ldlm_lock { * Seconds. It will be updated if there is any activity related to * the lock, e.g. enqueue the lock or send blocking AST. */ - cfs_time_t l_last_activity; + unsigned long l_last_activity; /** * Time last used by e.g. being matched by lock match. * Jiffies. Should be converted to time if needed. */ - cfs_time_t l_last_used; + unsigned long l_last_used; /** Originally requested extent for the extent lock. */ struct ldlm_extent l_req_extent; @@ -837,7 +837,7 @@ struct ldlm_lock { * under this lock. * \see ost_rw_prolong_locks */ - cfs_time_t l_callback_timeout; + unsigned long l_callback_timeout; /** Local PID of process which created this lock. */ __u32 l_pid; @@ -951,7 +951,7 @@ struct ldlm_resource { void *lr_lvb_data; /** When the resource was considered as contended. */ - cfs_time_t lr_contention_time; + unsigned long lr_contention_time; /** List of references to this resource. For debugging. */ struct lu_ref lr_reference; @@ -1285,7 +1285,7 @@ void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client); void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client); void ldlm_namespace_get(struct ldlm_namespace *ns); void ldlm_namespace_put(struct ldlm_namespace *ns); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) int ldlm_proc_setup(void); void ldlm_proc_cleanup(void); #else @@ -1390,7 +1390,7 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *head, int ldlm_cancel_resource_local(struct ldlm_resource *res, struct list_head *cancels, ldlm_policy_data_t *policy, - ldlm_mode_t mode, int lock_flags, + ldlm_mode_t mode, __u64 lock_flags, ldlm_cancel_flags_t cancel_flags, void *opaque); int ldlm_cli_cancel_list_local(struct list_head *cancels, int count, ldlm_cancel_flags_t flags); diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index 103f7a8bd83f..e5f8e86cd887 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -46,9 +46,9 @@ * @{ */ -#include <lprocfs_status.h> -#include <lustre/lustre_idl.h> -#include <lustre_dlm.h> +#include "lprocfs_status.h" +#include "lustre/lustre_idl.h" +#include "lustre_dlm.h" struct mds_client_data; struct mdt_client_data; @@ -209,7 +209,7 @@ struct obd_export { /** Last committed transno for this export */ __u64 exp_last_committed; /** When was last request received */ - cfs_time_t exp_last_request_time; + unsigned long exp_last_request_time; /** On replay all requests waiting for replay are linked here */ struct list_head exp_req_replay_queue; /** @@ -245,7 +245,7 @@ struct obd_export { enum lustre_sec_part exp_sp_peer; struct sptlrpc_flavor exp_flvr; /* current */ struct sptlrpc_flavor exp_flvr_old[2]; /* about-to-expire */ - cfs_time_t exp_flvr_expire[2]; /* seconds */ + unsigned long exp_flvr_expire[2]; /* seconds */ /** protects exp_hp_rpcs */ spinlock_t exp_rpc_lock; @@ -294,11 +294,11 @@ static inline int exp_connect_multibulk(struct obd_export *exp) return exp_max_brw_size(exp) > ONE_MB_BRW_SIZE; } -static inline int exp_expired(struct obd_export *exp, cfs_duration_t age) +static inline int exp_expired(struct obd_export *exp, long age) { LASSERT(exp->exp_delayed); - return cfs_time_before(cfs_time_add(exp->exp_last_request_time, age), - cfs_time_current_sec()); + return time_before(cfs_time_add(exp->exp_last_request_time, age), + get_seconds()); } static inline int exp_connect_cancelset(struct obd_export *exp) diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index 5e7b3165a851..ffb00f171240 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -152,8 +152,8 @@ * Even so, the MDT and OST resources are also in different LDLM namespaces. */ -#include <linux/libcfs/libcfs.h> -#include <lustre/lustre_idl.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "lustre/lustre_idl.h" struct lu_env; struct lu_site; @@ -312,7 +312,7 @@ static inline void lu_last_id_fid(struct lu_fid *fid, __u64 seq) fid->f_seq = fid_idif_seq(0, 0); } else { LASSERTF(fid_seq_is_norm(seq) || fid_seq_is_echo(seq) || - fid_seq_is_idif(seq), LPX64"\n", seq); + fid_seq_is_idif(seq), "%#llx\n", seq); fid->f_seq = seq; } fid->f_oid = 0; diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index 550fff587458..ce6330f9bb50 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/drivers/staging/lustre/lustre/include/lustre_fld.h @@ -42,8 +42,8 @@ * @{ */ -#include <lustre/lustre_idl.h> -#include <linux/libcfs/libcfs.h> +#include "lustre/lustre_idl.h" +#include "../../include/linux/libcfs/libcfs.h" struct lu_client_fld; struct lu_server_fld; diff --git a/drivers/staging/lustre/lustre/include/lustre_fsfilt.h b/drivers/staging/lustre/lustre/include/lustre_fsfilt.h index 9dcc332cb2f3..9749c3f5568e 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fsfilt.h +++ b/drivers/staging/lustre/lustre/include/lustre_fsfilt.h @@ -41,7 +41,7 @@ #ifndef _LUSTRE_FSFILT_H #define _LUSTRE_FSFILT_H -#include <linux/lustre_fsfilt.h> +#include "../include/linux/lustre_fsfilt.h" #define LU221_BAD_TIME (0x80000000U + 24 * 3600) diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index fcd40f33426a..94989c5e361f 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/lustre_handles.h @@ -42,9 +42,9 @@ * @{ */ -#include <linux/lustre_handles.h> +#include "linux/lustre_handles.h" -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" struct portals_handle_ops { diff --git a/drivers/staging/lustre/lustre/include/lustre_idmap.h b/drivers/staging/lustre/lustre/include/lustre_idmap.h index 2da859691d6a..5624b8bae919 100644 --- a/drivers/staging/lustre/lustre/include/lustre_idmap.h +++ b/drivers/staging/lustre/lustre/include/lustre_idmap.h @@ -47,7 +47,7 @@ * @{ */ -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" #define CFS_NGROUPS_PER_BLOCK ((int)(PAGE_CACHE_SIZE / sizeof(gid_t))) diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index 01ed786b40b9..8304a55b92f9 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -47,8 +47,8 @@ * @{ */ -#include <lustre_handles.h> -#include <lustre/lustre_idl.h> +#include "lustre_handles.h" +#include "lustre/lustre_idl.h" /** @@ -200,7 +200,7 @@ struct obd_import { */ struct ptlrpc_sec *imp_sec; struct mutex imp_sec_mutex; - cfs_time_t imp_sec_expire; + unsigned long imp_sec_expire; /** @} */ /** Wait queue for those who need to wait for recovery completion */ @@ -247,7 +247,7 @@ struct obd_import { */ struct lustre_handle imp_remote_handle; /** When to perform next ping. time in jiffies. */ - cfs_time_t imp_next_ping; + unsigned long imp_next_ping; /** When we last successfully connected. time in 64bit jiffies */ __u64 imp_last_success_conn; @@ -350,7 +350,7 @@ static inline void at_reset(struct adaptive_timeout *at, int val) { spin_lock(&at->at_lock); at->at_current = val; at->at_worst_ever = val; - at->at_worst_time = cfs_time_current_sec(); + at->at_worst_time = get_seconds(); spin_unlock(&at->at_lock); } static inline void at_init(struct adaptive_timeout *at, int val, int flags) { diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index 3c26bbdc44b7..de493fabab46 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -46,20 +46,20 @@ * @{ */ -#include <linux/libcfs/libcfs.h> -#include <lustre/lustre_idl.h> -#include <lustre_ver.h> -#include <lustre_cfg.h> -#include <linux/lustre_lib.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "lustre/lustre_idl.h" +#include "lustre_ver.h" +#include "lustre_cfg.h" +#include "linux/lustre_lib.h" /* target.c */ struct ptlrpc_request; struct obd_export; struct lu_target; struct l_wait_info; -#include <lustre_ha.h> -#include <lustre_net.h> -#include <lvfs.h> +#include "lustre_ha.h" +#include "lustre_net.h" +#include "lvfs.h" int target_pack_pool_reply(struct ptlrpc_request *req); @@ -241,7 +241,7 @@ static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data) } -#include <obd_support.h> +#include "obd_support.h" /* function defined in lustre/obdclass/<platform>/<platform>-module.c */ int obd_ioctl_getdata(char **buf, int *len, void *arg); @@ -459,8 +459,8 @@ static inline int back_to_sleep(void *arg) #define LWI_ON_SIGNAL_NOOP ((void (*)(void *))(-1)) struct l_wait_info { - cfs_duration_t lwi_timeout; - cfs_duration_t lwi_interval; + long lwi_timeout; + long lwi_interval; int lwi_allow_intr; int (*lwi_on_timeout)(void *); void (*lwi_on_signal)(void *); @@ -516,7 +516,7 @@ struct l_wait_info { #define __l_wait_event(wq, condition, info, ret, l_add_wait) \ do { \ wait_queue_t __wait; \ - cfs_duration_t __timeout = info->lwi_timeout; \ + long __timeout = info->lwi_timeout; \ sigset_t __blocked; \ int __allow_intr = info->lwi_allow_intr; \ \ @@ -548,11 +548,11 @@ do { \ if (__timeout == 0) { \ schedule(); \ } else { \ - cfs_duration_t interval = info->lwi_interval? \ - min_t(cfs_duration_t, \ + long interval = info->lwi_interval? \ + min_t(long, \ info->lwi_interval,__timeout):\ __timeout; \ - cfs_duration_t remaining = schedule_timeout(interval);\ + long remaining = schedule_timeout(interval);\ __timeout = cfs_time_sub(__timeout, \ cfs_time_sub(interval, remaining));\ if (__timeout == 0) { \ diff --git a/drivers/staging/lustre/lustre/include/lustre_lite.h b/drivers/staging/lustre/lustre/include/lustre_lite.h index beccb5e4065f..eee900638720 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lite.h +++ b/drivers/staging/lustre/lustre/include/lustre_lite.h @@ -42,19 +42,19 @@ * @{ */ -#include <linux/lustre_lite.h> +#include "linux/lustre_lite.h" -#include <obd_class.h> -#include <obd_ost.h> -#include <lustre_net.h> -#include <lustre_mds.h> -#include <lustre_ha.h> +#include "obd_class.h" +#include "obd_ost.h" +#include "lustre_net.h" +#include "lustre_mds.h" +#include "lustre_ha.h" /* 4UL * 1024 * 1024 */ #define LL_MAX_BLKSIZE_BITS (22) #define LL_MAX_BLKSIZE (1UL<<LL_MAX_BLKSIZE_BITS) -#include <lustre/lustre_user.h> +#include "lustre/lustre_user.h" struct lustre_rw_params { diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index 1a9a9228b795..d02ea24a7e40 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -56,12 +56,12 @@ * @{ */ -#include <linux/lustre_log.h> +#include "linux/lustre_log.h" -#include <obd_class.h> -#include <obd_ost.h> -#include <lustre/lustre_idl.h> -#include <dt_object.h> +#include "obd_class.h" +#include "obd_ost.h" +#include "lustre/lustre_idl.h" +#include "dt_object.h" #define LOG_NAME_LIMIT(logname, name) \ snprintf(logname, sizeof(logname), "LOGS/%s", name) diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index 66765d4d201d..39bbc3634b06 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -50,14 +50,14 @@ #include <linux/fs.h> #include <linux/dcache.h> -#include <linux/lustre_intent.h> -#include <lustre_handles.h> -#include <linux/libcfs/libcfs.h> -#include <obd_class.h> -#include <lustre/lustre_idl.h> -#include <lustre_lib.h> -#include <lustre_dlm.h> -#include <lustre_export.h> +#include "linux/lustre_intent.h" +#include "lustre_handles.h" +#include "../../include/linux/libcfs/libcfs.h" +#include "obd_class.h" +#include "lustre/lustre_idl.h" +#include "lustre_lib.h" +#include "lustre_dlm.h" +#include "lustre_export.h" struct ptlrpc_client; struct obd_export; diff --git a/drivers/staging/lustre/lustre/include/lustre_mds.h b/drivers/staging/lustre/lustre/include/lustre_mds.h index b386f87471e3..f0cce41c55c0 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mds.h +++ b/drivers/staging/lustre/lustre/include/lustre_mds.h @@ -47,12 +47,12 @@ * @{ */ -#include <lustre_handles.h> -#include <linux/libcfs/libcfs.h> -#include <lustre/lustre_idl.h> -#include <lustre_lib.h> -#include <lustre_dlm.h> -#include <lustre_export.h> +#include "lustre_handles.h" +#include "../../include/linux/libcfs/libcfs.h" +#include "lustre/lustre_idl.h" +#include "lustre_lib.h" +#include "lustre_dlm.h" +#include "lustre_export.h" struct mds_group_info { struct obd_uuid *uuid; diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index f6b7d10cb78c..d6af2ca3acdb 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -55,21 +55,21 @@ * @{ */ -#include <linux/lustre_net.h> +#include "linux/lustre_net.h" -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" // #include <obd.h> -#include <linux/lnet/lnet.h> -#include <lustre/lustre_idl.h> -#include <lustre_ha.h> -#include <lustre_sec.h> -#include <lustre_import.h> -#include <lprocfs_status.h> -#include <lu_object.h> -#include <lustre_req_layout.h> - -#include <obd_support.h> -#include <lustre_ver.h> +#include "../../include/linux/lnet/lnet.h" +#include "lustre/lustre_idl.h" +#include "lustre_ha.h" +#include "lustre_sec.h" +#include "lustre_import.h" +#include "lprocfs_status.h" +#include "lu_object.h" +#include "lustre_req_layout.h" + +#include "obd_support.h" +#include "lustre_ver.h" /* MD flags we _always_ use */ #define PTLRPC_MD_OPTIONS 0 @@ -1591,7 +1591,8 @@ struct ptlrpc_request { rq_replay:1, rq_no_resend:1, rq_waiting:1, rq_receiving_reply:1, rq_no_delay:1, rq_net_err:1, rq_wait_ctx:1, - rq_early:1, rq_must_unlink:1, + rq_early:1, + rq_req_unlink:1, rq_reply_unlink:1, rq_memalloc:1, /* req originated from "kswapd" */ /* server-side flags */ rq_packed_final:1, /* packed final reply */ @@ -1712,9 +1713,9 @@ struct ptlrpc_request { lnet_handle_md_t rq_req_md_h; struct ptlrpc_cb_id rq_req_cbid; /** optional time limit for send attempts */ - cfs_duration_t rq_delay_limit; + long rq_delay_limit; /** time request was first queued */ - cfs_time_t rq_queued_time; + unsigned long rq_queued_time; /* server-side... */ /** request arrival time */ @@ -2355,7 +2356,7 @@ struct ptlrpc_service_part { /** incoming reqs */ struct list_head scp_req_incoming; /** timeout before re-posting reqs, in tick */ - cfs_duration_t scp_rqbd_timeout; + long scp_rqbd_timeout; /** * all threads sleep on this. This wait-queue is signalled when new * incoming request arrives and when difficult reply has to be handled. @@ -2406,7 +2407,7 @@ struct ptlrpc_service_part { /** early reply timer */ struct timer_list scp_at_timer; /** debug */ - cfs_time_t scp_at_checktime; + unsigned long scp_at_checktime; /** check early replies */ unsigned scp_at_check; /** @} */ @@ -2593,7 +2594,7 @@ static inline int ptlrpc_client_bulk_active(struct ptlrpc_request *req) desc = req->rq_bulk; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK) && - req->rq_bulk_deadline > cfs_time_current_sec()) + req->rq_bulk_deadline > get_seconds()) return 1; if (!desc) @@ -3001,7 +3002,7 @@ static inline int ptlrpc_client_early(struct ptlrpc_request *req) { if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - req->rq_reply_deadline > cfs_time_current_sec()) + req->rq_reply_deadline > get_seconds()) return 0; return req->rq_early; } @@ -3013,7 +3014,7 @@ static inline int ptlrpc_client_replied(struct ptlrpc_request *req) { if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - req->rq_reply_deadline > cfs_time_current_sec()) + req->rq_reply_deadline > get_seconds()) return 0; return req->rq_replied; } @@ -3023,7 +3024,7 @@ static inline int ptlrpc_client_recv(struct ptlrpc_request *req) { if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - req->rq_reply_deadline > cfs_time_current_sec()) + req->rq_reply_deadline > get_seconds()) return 1; return req->rq_receiving_reply; } @@ -3035,11 +3036,12 @@ ptlrpc_client_recv_or_unlink(struct ptlrpc_request *req) spin_lock(&req->rq_lock); if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - req->rq_reply_deadline > cfs_time_current_sec()) { + req->rq_reply_deadline > get_seconds()) { spin_unlock(&req->rq_lock); return 1; } - rc = req->rq_receiving_reply || req->rq_must_unlink; + rc = req->rq_receiving_reply; + rc = rc || req->rq_req_unlink || req->rq_reply_unlink; spin_unlock(&req->rq_lock); return rc; } @@ -3098,9 +3100,9 @@ static inline int ptlrpc_req_get_repsize(struct ptlrpc_request *req) static inline int ptlrpc_send_limit_expired(struct ptlrpc_request *req) { if (req->rq_delay_limit != 0 && - cfs_time_before(cfs_time_add(req->rq_queued_time, - cfs_time_seconds(req->rq_delay_limit)), - cfs_time_current())) { + time_before(cfs_time_add(req->rq_queued_time, + cfs_time_seconds(req->rq_delay_limit)), + cfs_time_current())) { return 1; } return 0; @@ -3227,7 +3229,7 @@ void ptlrpcd_decref(void); * @{ */ const char* ll_opcode2str(__u32 opcode); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) void ptlrpc_lprocfs_register_obd(struct obd_device *obd); void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd); void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes); diff --git a/drivers/staging/lustre/lustre/include/lustre_quota.h b/drivers/staging/lustre/lustre/include/lustre_quota.h index 07cb7c310bcc..1ae72e3ff1bf 100644 --- a/drivers/staging/lustre/lustre/include/lustre_quota.h +++ b/drivers/staging/lustre/lustre/include/lustre_quota.h @@ -32,11 +32,11 @@ * */ -#include <linux/lustre_quota.h> +#include "linux/lustre_quota.h" -#include <dt_object.h> -#include <lustre_fid.h> -#include <lustre_dlm.h> +#include "dt_object.h" +#include "lustre_fid.h" +#include "lustre_dlm.h" #ifndef MAX_IQ_TIME #define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */ diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h b/drivers/staging/lustre/lustre/include/lustre_req_layout.h index a83db61a30be..c6457b27c4e7 100644 --- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h +++ b/drivers/staging/lustre/lustre/include/lustre_req_layout.h @@ -73,7 +73,7 @@ struct req_capsule { #if !defined(__REQ_LAYOUT_USER__) /* struct ptlrpc_request, lustre_msg* */ -#include <lustre_net.h> +#include "lustre_net.h" void req_capsule_init(struct req_capsule *pill, struct ptlrpc_request *req, enum req_location location); diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h index bf3ee3915c28..dc31bf93a1d7 100644 --- a/drivers/staging/lustre/lustre/include/lustre_sec.h +++ b/drivers/staging/lustre/lustre/include/lustre_sec.h @@ -387,7 +387,7 @@ struct ptlrpc_ctx_ops { /** * Force the \a ctx to die. */ - void (*die) (struct ptlrpc_cli_ctx *ctx, + void (*force_die) (struct ptlrpc_cli_ctx *ctx, int grace); int (*display) (struct ptlrpc_cli_ctx *ctx, char *buf, int bufsize); @@ -510,7 +510,7 @@ struct ptlrpc_cli_ctx { atomic_t cc_refcount; struct ptlrpc_sec *cc_sec; struct ptlrpc_ctx_ops *cc_ops; - cfs_time_t cc_expire; /* in seconds */ + unsigned long cc_expire; /* in seconds */ unsigned int cc_early_expire:1; unsigned long cc_flags; struct vfs_cred cc_vcred; @@ -835,8 +835,8 @@ struct ptlrpc_sec { * garbage collection */ struct list_head ps_gc_list; - cfs_time_t ps_gc_interval; /* in seconds */ - cfs_time_t ps_gc_next; /* in seconds */ + unsigned long ps_gc_interval; /* in seconds */ + unsigned long ps_gc_next; /* in seconds */ }; static inline int sec_is_reverse(struct ptlrpc_sec *sec) @@ -1064,7 +1064,7 @@ const char * sec2target_str(struct ptlrpc_sec *sec); /* * lprocfs */ -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) struct proc_dir_entry; extern struct proc_dir_entry *sptlrpc_proc_root; int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev); diff --git a/drivers/staging/lustre/lustre/include/lvfs.h b/drivers/staging/lustre/lustre/include/lvfs.h index 28f1a6b76f73..32dcd57c47cc 100644 --- a/drivers/staging/lustre/lustre/include/lvfs.h +++ b/drivers/staging/lustre/lustre/include/lvfs.h @@ -41,10 +41,10 @@ #define LL_FID_NAMELEN (16 + 1 + 8 + 1) -#include <linux/libcfs/libcfs.h> -#include <linux/lvfs.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "linux/lvfs.h" -#include <linux/libcfs/lucache.h> +#include "../../include/linux/libcfs/lucache.h" /* lvfs_common.c */ diff --git a/drivers/staging/lustre/lustre/include/md_object.h b/drivers/staging/lustre/lustre/include/md_object.h index ef46b2c461a6..2e5d55030a63 100644 --- a/drivers/staging/lustre/lustre/include/md_object.h +++ b/drivers/staging/lustre/lustre/include/md_object.h @@ -56,7 +56,7 @@ /* * super-class definitions. */ -#include <dt_object.h> +#include "dt_object.h" struct md_device; struct md_device_operations; diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index d5c4613f182d..489bdd399627 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -37,7 +37,7 @@ #ifndef __OBD_H #define __OBD_H -#include <linux/obd.h> +#include "linux/obd.h" #define IOC_OSC_TYPE 'h' #define IOC_OSC_MIN_NR 20 @@ -48,14 +48,13 @@ #define IOC_MDC_MIN_NR 20 #define IOC_MDC_MAX_NR 50 -#include <lustre/lustre_idl.h> -#include <lustre_lib.h> -#include <linux/libcfs/bitmap.h> -#include <lu_ref.h> -#include <lustre_export.h> -#include <lustre_fid.h> -#include <lustre_fld.h> -#include <lustre_capa.h> +#include "lustre/lustre_idl.h" +#include "lustre_lib.h" +#include "lu_ref.h" +#include "lustre_export.h" +#include "lustre_fid.h" +#include "lustre_fld.h" +#include "lustre_capa.h" #define MAX_OBD_DEVICES 8192 @@ -282,7 +281,7 @@ enum llog_ctxt_id { struct timeout_item { enum timeout_event ti_event; - cfs_time_t ti_timeout; + unsigned long ti_timeout; timeout_cb_t ti_cb; void *ti_cb_data; struct list_head ti_obd_list; @@ -338,7 +337,7 @@ struct client_obd { * See osc_{reserve|unreserve}_grant for details. */ long cl_reserved_grant; struct list_head cl_cache_waiters; /* waiting for cache/grant */ - cfs_time_t cl_next_shrink_grant; /* jiffies */ + unsigned long cl_next_shrink_grant; /* jiffies */ struct list_head cl_grant_shrink_list; /* Timeout event list */ int cl_grant_shrink_interval; /* seconds */ diff --git a/drivers/staging/lustre/lustre/include/obd_cksum.h b/drivers/staging/lustre/lustre/include/obd_cksum.h index 5f740f1743ca..662a78062963 100644 --- a/drivers/staging/lustre/lustre/include/obd_cksum.h +++ b/drivers/staging/lustre/lustre/include/obd_cksum.h @@ -34,8 +34,8 @@ #ifndef __OBD_CKSUM #define __OBD_CKSUM -#include <linux/libcfs/libcfs.h> -#include <lustre/lustre_idl.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "lustre/lustre_idl.h" static inline unsigned char cksum_obd2cfs(cksum_type_t cksum_type) { diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index e265820c009f..1d401c9e5e8c 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -37,15 +37,15 @@ #define __CLASS_OBD_H -#include <obd_support.h> -#include <lustre_import.h> -#include <lustre_net.h> -#include <obd.h> -#include <lustre_lib.h> -#include <lustre/lustre_idl.h> -#include <lprocfs_status.h> +#include "obd_support.h" +#include "lustre_import.h" +#include "lustre_net.h" +#include "obd.h" +#include "lustre_lib.h" +#include "lustre/lustre_idl.h" +#include "lprocfs_status.h" -#include <linux/obd_class.h> +#include "linux/obd_class.h" #define OBD_STATFS_NODELAY 0x0001 /* requests should be send without delay * and resends for avoid deadlocks */ @@ -141,7 +141,7 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg); int class_add_uuid(const char *uuid, __u64 nid); /*obdecho*/ -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) extern void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars); #else static inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars) @@ -347,7 +347,7 @@ do { \ } while (0) -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) #define OBD_COUNTER_OFFSET(op) \ ((offsetof(struct obd_ops, o_ ## op) - \ offsetof(struct obd_ops, o_iocontrol)) \ @@ -1160,13 +1160,12 @@ static inline int obd_statfs_async(struct obd_export *exp, OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, statfs); - CDEBUG(D_SUPER, "%s: osfs %p age "LPU64", max_age "LPU64"\n", + CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n", obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age); if (cfs_time_before_64(obd->obd_osfs_age, max_age)) { rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset); } else { - CDEBUG(D_SUPER,"%s: use %p cache blocks "LPU64"/"LPU64 - " objects "LPU64"/"LPU64"\n", + CDEBUG(D_SUPER,"%s: use %p cache blocks %llu/%llu objects %llu/%llu\n", obd->obd_name, &obd->obd_osfs, obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks, obd->obd_osfs.os_ffree, obd->obd_osfs.os_files); @@ -1217,7 +1216,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, statfs); - CDEBUG(D_SUPER, "osfs "LPU64", max_age "LPU64"\n", + CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n", obd->obd_osfs_age, max_age); if (cfs_time_before_64(obd->obd_osfs_age, max_age)) { rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags); @@ -1228,8 +1227,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, spin_unlock(&obd->obd_osfs_lock); } } else { - CDEBUG(D_SUPER, "%s: use %p cache blocks "LPU64"/"LPU64 - " objects "LPU64"/"LPU64"\n", + CDEBUG(D_SUPER, "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n", obd->obd_name, &obd->obd_osfs, obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks, obd->obd_osfs.os_ffree, obd->obd_osfs.os_files); @@ -1818,7 +1816,7 @@ static inline int md_enqueue(struct obd_export *exp, struct lustre_handle *lockh, void *lmm, int lmmsize, struct ptlrpc_request **req, - int extra_lock_flags) + __u64 extra_lock_flags) { int rc; diff --git a/drivers/staging/lustre/lustre/include/obd_ost.h b/drivers/staging/lustre/lustre/include/obd_ost.h index af89843c312b..60de42972ec9 100644 --- a/drivers/staging/lustre/lustre/include/obd_ost.h +++ b/drivers/staging/lustre/lustre/include/obd_ost.h @@ -43,7 +43,7 @@ #ifndef _LUSTRE_OST_H #define _LUSTRE_OST_H -#include <obd_class.h> +#include "obd_class.h" struct osc_brw_async_args { struct obdo *aa_oa; @@ -87,6 +87,10 @@ struct osc_enqueue_args { unsigned int oa_agl:1; }; +extern void osc_update_enqueue(struct lustre_handle *lov_lockhp, + struct lov_oinfo *loi, __u64 flags, + struct ost_lvb *lvb, __u32 mode, int rc); + #if 0 int osc_extent_blocking_cb(struct ldlm_lock *lock, struct ldlm_lock_desc *new, void *data, diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index cc5af509b261..92c89925ff67 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -37,11 +37,10 @@ #ifndef _OBD_SUPPORT #define _OBD_SUPPORT -#include <linux/libcfs/libcfs.h> -#include <lvfs.h> -#include <lprocfs_status.h> - -#include <linux/obd_support.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "lvfs.h" +#include "lprocfs_status.h" +#include "linux/obd_support.h" /* global variables */ extern struct lprocfs_stats *obd_memory; @@ -509,7 +508,7 @@ extern atomic_t libcfs_kmemory; extern void obd_update_maxusage(void); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) #define obd_memory_add(size) \ lprocfs_counter_add(obd_memory, OBD_MEMORY_STAT, (long)(size)) #define obd_memory_sub(size) \ @@ -663,7 +662,7 @@ do { \ if (unlikely((ptr) == NULL)) { \ CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n", \ (int)(size)); \ - CERROR(LPU64" total bytes allocated by Lustre, %d by LNET\n", \ + CERROR("%llu total bytes allocated by Lustre, %d by LNET\n", \ obd_memory_sum(), atomic_read(&libcfs_kmemory)); \ } else { \ OBD_ALLOC_POST(ptr, size, "vmalloced"); \ @@ -823,11 +822,11 @@ do { \ alloc_page(gfp_mask) : \ alloc_pages_node(cfs_cpt_spread_node(cptab, cpt), gfp_mask, 0);\ if (unlikely((ptr) == NULL)) { \ - CERROR("alloc_pages of '" #ptr "' %d page(s) / "LPU64" bytes "\ + CERROR("alloc_pages of '" #ptr "' %d page(s) / %llu bytes "\ "failed\n", (int)1, \ (__u64)(1 << PAGE_CACHE_SHIFT)); \ - CERROR(LPU64" total bytes and "LPU64" total pages " \ - "("LPU64" bytes) allocated by Lustre, " \ + CERROR("%llu total bytes and %llu total pages " \ + "(%llu bytes) allocated by Lustre, " \ "%d total bytes by LNET\n", \ obd_memory_sum(), \ obd_pages_sum() << PAGE_CACHE_SHIFT, \ @@ -836,7 +835,7 @@ do { \ } else { \ obd_pages_add(0); \ CDEBUG(D_MALLOC, "alloc_pages '" #ptr "': %d page(s) / " \ - LPU64" bytes at %p.\n", \ + "%llu bytes at %p.\n", \ (int)1, \ (__u64)(1 << PAGE_CACHE_SHIFT), ptr); \ } \ @@ -851,7 +850,7 @@ do { \ do { \ LASSERT(ptr); \ obd_pages_sub(0); \ - CDEBUG(D_MALLOC, "free_pages '" #ptr "': %d page(s) / "LPU64" bytes " \ + CDEBUG(D_MALLOC, "free_pages '" #ptr "': %d page(s) / %llu bytes " \ "at %p.\n", \ (int)1, (__u64)(1 << PAGE_CACHE_SHIFT), \ ptr); \ diff --git a/drivers/staging/lustre/lustre/lclient/glimpse.c b/drivers/staging/lustre/lustre/lclient/glimpse.c index 7bbca4bf6b82..b9f2bb66de21 100644 --- a/drivers/staging/lustre/lustre/lclient/glimpse.c +++ b/drivers/staging/lustre/lustre/lclient/glimpse.c @@ -40,20 +40,20 @@ * Author: Oleg Drokin <oleg.drokin@sun.com> */ -#include <linux/libcfs/libcfs.h> -#include <obd_class.h> -#include <obd_support.h> -#include <obd.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/obd.h" -# include <lustre_dlm.h> -# include <lustre_lite.h> -# include <lustre_mdc.h> -# include <linux/pagemap.h> -# include <linux/file.h> +#include "../include/lustre_dlm.h" +#include "../include/lustre_lite.h" +#include "../include/lustre_mdc.h" +#include <linux/pagemap.h> +#include <linux/file.h> -#include "cl_object.h" -#include "lclient.h" -# include "../llite/llite_internal.h" +#include "../include/cl_object.h" +#include "../include/lclient.h" +#include "../llite/llite_internal.h" static const struct cl_lock_descr whole_file = { .cld_start = 0, @@ -177,7 +177,7 @@ static int cl_io_get(struct inode *inode, struct lu_env **envout, io->ci_obj = clob; *envout = env; *ioout = io; - result = +1; + result = 1; } else result = PTR_ERR(env); } else @@ -204,7 +204,7 @@ int cl_glimpse_size0(struct inode *inode, int agl) result = cl_io_get(inode, &env, &io, &refcheck); if (result > 0) { - again: +again: io->ci_verify_layout = 1; result = cl_io_init(env, io, CIT_MISC, io->ci_obj); if (result > 0) diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 1b0c216bc568..94f759d0b5ad 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -41,7 +41,7 @@ #define DEBUG_SUBSYSTEM S_LLITE -# include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" # include <linux/fs.h> # include <linux/sched.h> # include <linux/mm.h> @@ -50,16 +50,16 @@ # include <linux/pagemap.h> # include <linux/rbtree.h> -#include <obd.h> -#include <obd_support.h> -#include <lustre_fid.h> -#include <lustre_lite.h> -#include <lustre_dlm.h> -#include <lustre_ver.h> -#include <lustre_mdc.h> -#include <cl_object.h> +#include "../include/obd.h" +#include "../include/obd_support.h" +#include "../include/lustre_fid.h" +#include "../include/lustre_lite.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_ver.h" +#include "../include/lustre_mdc.h" +#include "../include/cl_object.h" -#include <lclient.h> +#include "../include/lclient.h" #include "../llite/llite_internal.h" @@ -126,6 +126,7 @@ void ccc_key_fini(const struct lu_context *ctx, struct lu_context_key *key, void *data) { struct ccc_thread_info *info = data; + OBD_SLAB_FREE_PTR(info, ccc_thread_kmem); } @@ -144,6 +145,7 @@ void ccc_session_key_fini(const struct lu_context *ctx, struct lu_context_key *key, void *data) { struct ccc_session *session = data; + OBD_SLAB_FREE_PTR(session, ccc_session_kmem); } @@ -264,7 +266,7 @@ int ccc_req_init(const struct lu_env *env, struct cl_device *dev, * fails. Access to this environment is serialized by ccc_inode_fini_guard * mutex. */ -static struct lu_env *ccc_inode_fini_env = NULL; +static struct lu_env *ccc_inode_fini_env; /** * A mutex serializing calls to slp_inode_fini() under extreme memory @@ -572,6 +574,7 @@ void ccc_lock_delete(const struct lu_env *env, void ccc_lock_fini(const struct lu_env *env, struct cl_lock_slice *slice) { struct ccc_lock *clk = cl2ccc_lock(slice); + OBD_SLAB_FREE_PTR(clk, ccc_lock_kmem); } @@ -733,6 +736,7 @@ int ccc_io_one_lock(const struct lu_env *env, struct cl_io *io, loff_t start, loff_t end) { struct cl_object *obj = io->ci_obj; + return ccc_io_one_lock_index(env, io, enqflags, mode, cl_index(obj, start), cl_index(obj, end)); } @@ -817,11 +821,12 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj, * linux-2.6.18-128.1.1 miss to do that. * --bug 17336 */ loff_t size = cl_isize_read(inode); - unsigned long cur_index = start >> PAGE_CACHE_SHIFT; + loff_t cur_index = start >> PAGE_CACHE_SHIFT; + loff_t size_index = ((size - 1) >> PAGE_CACHE_SHIFT); if ((size == 0 && cur_index != 0) || - (((size - 1) >> PAGE_CACHE_SHIFT) < cur_index)) - *exceed = 1; + size_index < cur_index) + *exceed = 1; } return result; } else { @@ -838,7 +843,7 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj, if (cl_isize_read(inode) < kms) { cl_isize_write_nolock(inode, kms); CDEBUG(D_VFSTRACE, - DFID" updating i_size "LPU64"\n", + DFID" updating i_size %llu\n", PFID(lu_object_fid(&obj->co_lu)), (__u64)cl_isize_read(inode)); @@ -1269,7 +1274,7 @@ struct lov_stripe_md *ccc_inode_lsm_get(struct inode *inode) return lov_lsm_get(cl_i2info(inode)->lli_clob); } -void inline ccc_inode_lsm_put(struct inode *inode, struct lov_stripe_md *lsm) +inline void ccc_inode_lsm_put(struct inode *inode, struct lov_stripe_md *lsm) { lov_lsm_put(cl_i2info(inode)->lli_clob, lsm); } diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c index 21de1cd2afba..01bf894d4a87 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c @@ -37,13 +37,13 @@ * future). * */ -#include <obd_class.h> -#include <obd_support.h> -#include <obd.h> -#include <cl_object.h> -#include <lclient.h> +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/obd.h" +#include "../include/cl_object.h" +#include "../include/lclient.h" -#include <lustre_lite.h> +#include "../include/lustre_lite.h" /* Initialize the default and maximum LOV EA and cookie sizes. This allows @@ -63,7 +63,7 @@ int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp) if (rc) return rc; - stripes = min(desc.ld_tgt_count, (__u32)LOV_MAX_STRIPE_COUNT); + stripes = min_t(__u32, desc.ld_tgt_count, LOV_MAX_STRIPE_COUNT); lsm.lsm_stripe_count = stripes; easize = obd_size_diskmd(dt_exp, &lsm); @@ -103,7 +103,7 @@ int cl_ocd_update(struct obd_device *host, cli = &watched->u.cli; lco = owner; flags = cli->cl_import->imp_connect_data.ocd_connect_flags; - CDEBUG(D_SUPER, "Changing connect_flags: "LPX64" -> "LPX64"\n", + CDEBUG(D_SUPER, "Changing connect_flags: %#llx -> %#llx\n", lco->lco_flags, flags); mutex_lock(&lco->lco_lock); lco->lco_flags &= flags; diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index 1de1d8eb9b41..a3d7a7292417 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c @@ -38,9 +38,9 @@ * Author: Huang Wei <huangwei@clusterfs.com> * Author: Jay Xiong <jinshan.xiong@sun.com> */ -# include <lustre_dlm.h> -#include <obd_support.h> -#include <interval_tree.h> +#include "../include/lustre_dlm.h" +#include "../include/obd_support.h" +#include "../include/interval_tree.h" enum { INTERVAL_RED = 0, diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c b/drivers/staging/lustre/lustre/ldlm/l_lock.c index 32f4d52b5362..cd8ab40e3267 100644 --- a/drivers/staging/lustre/lustre/ldlm/l_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c @@ -35,10 +35,10 @@ */ #define DEBUG_SUBSYSTEM S_LDLM -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <lustre_dlm.h> -#include <lustre_lib.h> +#include "../include/lustre_dlm.h" +#include "../include/lustre_lib.h" /** * Lock a lock and its resource. diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index bde3a82ce0dd..0c09b611f4a6 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -50,14 +50,12 @@ */ #define DEBUG_SUBSYSTEM S_LDLM -# include <linux/libcfs/libcfs.h> - -#include <lustre_dlm.h> -#include <obd_support.h> -#include <obd.h> -#include <obd_class.h> -#include <lustre_lib.h> - +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/lustre_dlm.h" +#include "../include/obd_support.h" +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/lustre_lib.h" #include "ldlm_internal.h" @@ -92,7 +90,7 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms) if (lck->l_policy_data.l_extent.end + 1 > kms) kms = lck->l_policy_data.l_extent.end + 1; } - LASSERTF(kms <= old_kms, "kms "LPU64" old_kms "LPU64"\n", kms, old_kms); + LASSERTF(kms <= old_kms, "kms %llu old_kms %llu\n", kms, old_kms); return kms; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index 986bf384bff7..b798daa094bc 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -56,12 +56,11 @@ #define DEBUG_SUBSYSTEM S_LDLM -#include <lustre_dlm.h> -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_lib.h> +#include "../include/lustre_dlm.h" +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_lib.h" #include <linux/list.h> - #include "ldlm_internal.h" int ldlm_flock_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, @@ -261,9 +260,8 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, int splitted = 0; const struct ldlm_callback_suite null_cbs = { NULL }; - CDEBUG(D_DLMTRACE, "flags %#llx owner "LPU64" pid %u mode %u start " - LPU64" end "LPU64"\n", *flags, - new->l_policy_data.l_flock.owner, + CDEBUG(D_DLMTRACE, "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", + *flags, new->l_policy_data.l_flock.owner, new->l_policy_data.l_flock.pid, mode, req->l_policy_data.l_flock.start, req->l_policy_data.l_flock.end); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c index 574b2ff43b74..40d3338506ae 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c @@ -53,10 +53,9 @@ #define DEBUG_SUBSYSTEM S_LDLM -#include <lustre_dlm.h> -#include <obd_support.h> -#include <lustre_lib.h> - +#include "../include/lustre_dlm.h" +#include "../include/obd_support.h" +#include "../include/lustre_lib.h" #include "ldlm_internal.h" diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 8bb59155968f..fda9926bea3b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -43,12 +43,12 @@ #define DEBUG_SUBSYSTEM S_LDLM -# include <linux/libcfs/libcfs.h> -#include <obd.h> -#include <obd_class.h> -#include <lustre_dlm.h> -#include <lustre_net.h> -#include <lustre_sec.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_net.h" +#include "../include/lustre_sec.h" #include "ldlm_internal.h" /* @priority: If non-zero, move the selected connection to the list head. @@ -74,9 +74,8 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, if (create) { OBD_ALLOC(imp_conn, sizeof(*imp_conn)); - if (!imp_conn) { + if (!imp_conn) GOTO(out_put, rc = -ENOMEM); - } } spin_lock(&imp->imp_lock); @@ -511,14 +510,14 @@ int client_connect_import(const struct lu_env *env, rc = ptlrpc_connect_import(imp); if (rc != 0) { - LASSERT (imp->imp_state == LUSTRE_IMP_DISCON); + LASSERT(imp->imp_state == LUSTRE_IMP_DISCON); GOTO(out_ldlm, rc); } LASSERT(*exp != NULL && (*exp)->exp_connection); if (data) { LASSERTF((ocd->ocd_connect_flags & data->ocd_connect_flags) == - ocd->ocd_connect_flags, "old "LPX64", new "LPX64"\n", + ocd->ocd_connect_flags, "old %#llx, new %#llx\n", data->ocd_connect_flags, ocd->ocd_connect_flags); data->ocd_connect_flags = ocd->ocd_connect_flags; } @@ -546,7 +545,7 @@ int client_disconnect_export(struct obd_export *exp) int rc = 0, err; if (!obd) { - CERROR("invalid export for disconnect: exp %p cookie "LPX64"\n", + CERROR("invalid export for disconnect: exp %p cookie %#llx\n", exp, exp ? exp->exp_handle.h_cookie : -1); return -EINVAL; } @@ -662,33 +661,32 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) struct ptlrpc_reply_state *rs; struct obd_export *exp; - if (req->rq_no_reply) { + if (req->rq_no_reply) return; - } svcpt = req->rq_rqbd->rqbd_svcpt; rs = req->rq_reply_state; if (rs == NULL || !rs->rs_difficult) { /* no notifiers */ - target_send_reply_msg (req, rc, fail_id); + target_send_reply_msg(req, rc, fail_id); return; } /* must be an export if locks saved */ - LASSERT (req->rq_export != NULL); + LASSERT(req->rq_export != NULL); /* req/reply consistent */ LASSERT(rs->rs_svcpt == svcpt); /* "fresh" reply */ - LASSERT (!rs->rs_scheduled); - LASSERT (!rs->rs_scheduled_ever); - LASSERT (!rs->rs_handled); - LASSERT (!rs->rs_on_net); - LASSERT (rs->rs_export == NULL); - LASSERT (list_empty(&rs->rs_obd_list)); - LASSERT (list_empty(&rs->rs_exp_list)); + LASSERT(!rs->rs_scheduled); + LASSERT(!rs->rs_scheduled_ever); + LASSERT(!rs->rs_handled); + LASSERT(!rs->rs_on_net); + LASSERT(rs->rs_export == NULL); + LASSERT(list_empty(&rs->rs_obd_list)); + LASSERT(list_empty(&rs->rs_exp_list)); - exp = class_export_get (req->rq_export); + exp = class_export_get(req->rq_export); /* disable reply scheduling while I'm setting up */ rs->rs_scheduled = 1; @@ -699,7 +697,7 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) rs->rs_opc = lustre_msg_get_opc(req->rq_reqmsg); spin_lock(&exp->exp_uncommitted_replies_lock); - CDEBUG(D_NET, "rs transno = "LPU64", last committed = "LPU64"\n", + CDEBUG(D_NET, "rs transno = %llu, last committed = %llu\n", rs->rs_transno, exp->exp_last_committed); if (rs->rs_transno > exp->exp_last_committed) { /* not committed already */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 1b3f5c1eb808..d022666fb705 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -41,10 +41,9 @@ #define DEBUG_SUBSYSTEM S_LDLM -# include <linux/libcfs/libcfs.h> -# include <linux/lustre_intent.h> - -#include <obd_class.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/linux/lustre_intent.h" +#include "../include/obd_class.h" #include "ldlm_internal.h" /* lock types */ @@ -625,8 +624,7 @@ void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc) LASSERTF(lock->l_policy_data.l_inodebits.bits == (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE | MDS_INODELOCK_LAYOUT), - "Inappropriate inode lock bits during " - "conversion " LPU64 "\n", + "Inappropriate inode lock bits during conversion %llu\n", lock->l_policy_data.l_inodebits.bits); ldlm_res2desc(lock->l_resource, &desc->l_resource); @@ -899,7 +897,7 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode) { struct ldlm_lock *lock = __ldlm_handle2lock(lockh, 0); - LASSERTF(lock != NULL, "Non-existing lock: "LPX64"\n", lockh->cookie); + LASSERTF(lock != NULL, "Non-existing lock: %#llx\n", lockh->cookie); ldlm_lock_decref_internal(lock, mode); LDLM_LOCK_PUT(lock); } @@ -1351,7 +1349,7 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, } out2: if (rc) { - LDLM_DEBUG(lock, "matched ("LPU64" "LPU64")", + LDLM_DEBUG(lock, "matched (%llu %llu)", (type == LDLM_PLAIN || type == LDLM_IBITS) ? res_id->name[2] : policy->l_extent.start, (type == LDLM_PLAIN || type == LDLM_IBITS) ? @@ -1370,9 +1368,8 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, LDLM_LOCK_RELEASE(lock); } else if (!(flags & LDLM_FL_TEST_LOCK)) {/*less verbose for test-only*/ - LDLM_DEBUG_NOLOCK("not matched ns %p type %u mode %u res " - LPU64"/"LPU64" ("LPU64" "LPU64")", ns, - type, mode, res_id->name[0], res_id->name[1], + LDLM_DEBUG_NOLOCK("not matched ns %p type %u mode %u res %llu/%llu (%llu %llu)", + ns, type, mode, res_id->name[0], res_id->name[1], (type == LDLM_PLAIN || type == LDLM_IBITS) ? res_id->name[2] :policy->l_extent.start, (type == LDLM_PLAIN || type == LDLM_IBITS) ? @@ -1595,7 +1592,7 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, ldlm_error_t rc = ELDLM_OK; struct ldlm_interval *node = NULL; - lock->l_last_activity = cfs_time_current_sec(); + lock->l_last_activity = get_seconds(); /* policies are not executed on the client or during replay */ if ((*flags & (LDLM_FL_HAS_INTENT|LDLM_FL_REPLAY)) == LDLM_FL_HAS_INTENT && !local && ns->ns_policy) { @@ -2258,9 +2255,9 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, if (resource == NULL) { libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: \?\? lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " - "res: \?\? rrc=\?\? type: \?\?\? flags: "LPX64" nid: %s " - "remote: "LPX64" expref: %d pid: %u timeout: %lu " + " ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s " + "res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s " + "remote: %#llx expref: %d pid: %u timeout: %lu " "lvb_type: %d\n", lock, lock->l_handle.h_cookie, atomic_read(&lock->l_refc), @@ -2277,10 +2274,10 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, switch (resource->lr_type) { case LDLM_EXTENT: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " - "res: "DLDLMRES" rrc: %d type: %s ["LPU64"->"LPU64"] " - "(req "LPU64"->"LPU64") flags: "LPX64" nid: %s remote: " - LPX64" expref: %d pid: %u timeout: %lu lvb_type: %d\n", + " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s " + "res: "DLDLMRES" rrc: %d type: %s [%llu->%llu] " + "(req %llu->%llu) flags: %#llx nid: %s remote: " + "%#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", ldlm_lock_to_ns_name(lock), lock, lock->l_handle.h_cookie, atomic_read(&lock->l_refc), lock->l_readers, lock->l_writers, @@ -2300,10 +2297,10 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, case LDLM_FLOCK: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " + " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s " "res: "DLDLMRES" rrc: %d type: %s pid: %d " - "["LPU64"->"LPU64"] flags: "LPX64" nid: %s " - "remote: "LPX64" expref: %d pid: %u timeout: %lu\n", + "[%llu->%llu] flags: %#llx nid: %s " + "remote: %#llx expref: %d pid: %u timeout: %lu\n", ldlm_lock_to_ns_name(lock), lock, lock->l_handle.h_cookie, atomic_read(&lock->l_refc), lock->l_readers, lock->l_writers, @@ -2322,9 +2319,9 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, case LDLM_IBITS: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " - "res: "DLDLMRES" bits "LPX64" rrc: %d type: %s " - "flags: "LPX64" nid: %s remote: "LPX64" expref: %d " + " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s " + "res: "DLDLMRES" bits %#llx rrc: %d type: %s " + "flags: %#llx nid: %s remote: %#llx expref: %d " "pid: %u timeout: %lu lvb_type: %d\n", ldlm_lock_to_ns_name(lock), lock, lock->l_handle.h_cookie, @@ -2344,9 +2341,9 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, default: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " - "res: "DLDLMRES" rrc: %d type: %s flags: "LPX64" " - "nid: %s remote: "LPX64" expref: %d pid: %u " + " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s " + "res: "DLDLMRES" rrc: %d type: %s flags: %#llx " + "nid: %s remote: %#llx expref: %d pid: %u " "timeout: %lu lvb_type: %d\n", ldlm_lock_to_ns_name(lock), lock, lock->l_handle.h_cookie, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 7e63cf355cd9..952e10eb6178 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -41,10 +41,9 @@ #define DEBUG_SUBSYSTEM S_LDLM -# include <linux/libcfs/libcfs.h> - -#include <lustre_dlm.h> -#include <obd_class.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/lustre_dlm.h" +#include "../include/obd_class.h" #include <linux/list.h> #include "ldlm_internal.h" @@ -70,7 +69,7 @@ struct ldlm_cb_async_args { static struct ldlm_state *ldlm_state; -inline cfs_time_t round_timeout(cfs_time_t timeout) +inline unsigned long round_timeout(unsigned long timeout) { return cfs_time_seconds((int)cfs_duration_sec(cfs_time_sub(timeout, 0)) + 1); } @@ -526,7 +525,7 @@ static inline void ldlm_callback_errmsg(struct ptlrpc_request *req, struct lustre_handle *handle) { DEBUG_REQ((req->rq_no_reply || rc) ? D_WARNING : D_DLMTRACE, req, - "%s: [nid %s] [rc %d] [lock "LPX64"]", + "%s: [nid %s] [rc %d] [lock %#llx]", msg, libcfs_id2str(req->rq_peer), rc, handle ? handle->cookie : 0); if (req->rq_no_reply) @@ -636,7 +635,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) lock = ldlm_handle2lock_long(&dlm_req->lock_handle[0], 0); if (!lock) { - CDEBUG(D_DLMTRACE, "callback on lock "LPX64" - lock " + CDEBUG(D_DLMTRACE, "callback on lock %#llx - lock " "disappeared\n", dlm_req->lock_handle[0].cookie); rc = ldlm_callback_reply(req, -EINVAL); ldlm_callback_errmsg(req, "Operate with invalid parameter", rc, @@ -661,7 +660,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) (lock->l_flags & LDLM_FL_BL_DONE)) || (lock->l_flags & LDLM_FL_FAILED)) { LDLM_DEBUG(lock, "callback on lock " - LPX64" - lock disappeared\n", + "%#llx - lock disappeared\n", dlm_req->lock_handle[0].cookie); unlock_res_and_lock(lock); LDLM_LOCK_RELEASE(lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c b/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c index ec29e28624fe..a1fe2c161e38 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c @@ -52,9 +52,9 @@ #define DEBUG_SUBSYSTEM S_LDLM -#include <lustre_dlm.h> -#include <obd_support.h> -#include <lustre_lib.h> +#include "../include/lustre_dlm.h" +#include "../include/obd_support.h" +#include "../include/lustre_lib.h" #include "ldlm_internal.h" diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 2cc698179b63..db36b3f46e49 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -97,12 +97,10 @@ #define DEBUG_SUBSYSTEM S_LDLM -# include <lustre_dlm.h> - -#include <cl_object.h> - -#include <obd_class.h> -#include <obd_support.h> +#include "../include/lustre_dlm.h" +#include "../include/cl_object.h" +#include "../include/obd_class.h" +#include "../include/obd_support.h" #include "ldlm_internal.h" @@ -336,12 +334,12 @@ static int ldlm_srv_pool_recalc(struct ldlm_pool *pl) { time_t recalc_interval_sec; - recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; + recalc_interval_sec = get_seconds() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) return 0; spin_lock(&pl->pl_lock); - recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; + recalc_interval_sec = get_seconds() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) { spin_unlock(&pl->pl_lock); return 0; @@ -362,7 +360,7 @@ static int ldlm_srv_pool_recalc(struct ldlm_pool *pl) */ ldlm_pool_recalc_grant_plan(pl); - pl->pl_recalc_time = cfs_time_current_sec(); + pl->pl_recalc_time = get_seconds(); lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT, recalc_interval_sec); spin_unlock(&pl->pl_lock); @@ -473,7 +471,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) { time_t recalc_interval_sec; - recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; + recalc_interval_sec = get_seconds() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) return 0; @@ -481,7 +479,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) /* * Check if we need to recalc lists now. */ - recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; + recalc_interval_sec = get_seconds() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) { spin_unlock(&pl->pl_lock); return 0; @@ -492,7 +490,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) */ ldlm_cli_pool_pop_slv(pl); - pl->pl_recalc_time = cfs_time_current_sec(); + pl->pl_recalc_time = get_seconds(); lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT, recalc_interval_sec); spin_unlock(&pl->pl_lock); @@ -566,7 +564,7 @@ int ldlm_pool_recalc(struct ldlm_pool *pl) time_t recalc_interval_sec; int count; - recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; + recalc_interval_sec = get_seconds() - pl->pl_recalc_time; if (recalc_interval_sec <= 0) goto recalc; @@ -591,7 +589,7 @@ int ldlm_pool_recalc(struct ldlm_pool *pl) lprocfs_counter_add(pl->pl_stats, LDLM_POOL_RECALC_STAT, count); } - recalc_interval_sec = pl->pl_recalc_time - cfs_time_current_sec() + + recalc_interval_sec = pl->pl_recalc_time - get_seconds() + pl->pl_recalc_period; return recalc_interval_sec; @@ -638,7 +636,7 @@ int ldlm_pool_setup(struct ldlm_pool *pl, int limit) } EXPORT_SYMBOL(ldlm_pool_setup); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused) { int granted, grant_rate, cancel_rate, grant_step; @@ -661,8 +659,8 @@ static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused) spin_unlock(&pl->pl_lock); seq_printf(m, "LDLM pool state (%s):\n" - " SLV: "LPU64"\n" - " CLV: "LPU64"\n" + " SLV: %llu\n" + " CLV: %llu\n" " LVF: %d\n", pl->pl_name, slv, clv, lvf); @@ -823,14 +821,14 @@ static void ldlm_pool_proc_fini(struct ldlm_pool *pl) pl->pl_proc_dir = NULL; } } -#else /* !LPROCFS */ +#else /* !CONFIG_PROC_FS */ static int ldlm_pool_proc_init(struct ldlm_pool *pl) { return 0; } static void ldlm_pool_proc_fini(struct ldlm_pool *pl) {} -#endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS */ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, int idx, ldlm_side_t client) @@ -839,7 +837,7 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, spin_lock_init(&pl->pl_lock); atomic_set(&pl->pl_granted, 0); - pl->pl_recalc_time = cfs_time_current_sec(); + pl->pl_recalc_time = get_seconds(); atomic_set(&pl->pl_lock_volume_factor, 1); atomic_set(&pl->pl_grant_rate, 0); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index fcc7a99ce395..8867dc175325 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -61,9 +61,9 @@ #define DEBUG_SUBSYSTEM S_LDLM -#include <lustre_dlm.h> -#include <obd_class.h> -#include <obd.h> +#include "../include/lustre_dlm.h" +#include "../include/obd_class.h" +#include "../include/obd.h" #include "ldlm_internal.h" @@ -95,18 +95,18 @@ int ldlm_expired_completion_wait(void *data) struct obd_device *obd; if (lock->l_conn_export == NULL) { - static cfs_time_t next_dump = 0, last_dump = 0; + static unsigned long next_dump = 0, last_dump = 0; LCONSOLE_WARN("lock timed out (enqueued at "CFS_TIME_T", " CFS_DURATION_T"s ago)\n", lock->l_last_activity, - cfs_time_sub(cfs_time_current_sec(), + cfs_time_sub(get_seconds(), lock->l_last_activity)); LDLM_DEBUG(lock, "lock timed out (enqueued at "CFS_TIME_T", " CFS_DURATION_T"s ago); not entering recovery in " "server code, just going back to sleep", lock->l_last_activity, - cfs_time_sub(cfs_time_current_sec(), + cfs_time_sub(get_seconds(), lock->l_last_activity)); if (cfs_time_after(cfs_time_current(), next_dump)) { last_dump = next_dump; @@ -125,7 +125,7 @@ int ldlm_expired_completion_wait(void *data) LDLM_ERROR(lock, "lock timed out (enqueued at "CFS_TIME_T", " CFS_DURATION_T"s ago), entering recovery for %s@%s", lock->l_last_activity, - cfs_time_sub(cfs_time_current_sec(), lock->l_last_activity), + cfs_time_sub(get_seconds(), lock->l_last_activity), obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid); return 0; @@ -160,7 +160,7 @@ static int ldlm_completion_tail(struct ldlm_lock *lock) LDLM_DEBUG(lock, "client-side enqueue: destroyed"); result = -EIO; } else { - delay = cfs_time_sub(cfs_time_current_sec(), + delay = cfs_time_sub(get_seconds(), lock->l_last_activity); LDLM_DEBUG(lock, "client-side enqueue: granted after " CFS_DURATION_T"s", delay); @@ -592,7 +592,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, LDLM_FL_NO_TIMEOUT); unlock_res_and_lock(lock); - CDEBUG(D_INFO, "local: %p, remote cookie: "LPX64", flags: 0x%llx\n", + CDEBUG(D_INFO, "local: %p, remote cookie: %#llx, flags: 0x%llx\n", lock, reply->lock_handle.cookie, *flags); /* If enqueue returned a blocked lock but the completion handler has @@ -1276,8 +1276,7 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) * server-side namespace is not possible. */ if (lustre_msg_get_slv(req->rq_repmsg) == 0 || lustre_msg_get_limit(req->rq_repmsg) == 0) { - DEBUG_REQ(D_HA, req, "Zero SLV or Limit found " - "(SLV: "LPU64", Limit: %u)", + DEBUG_REQ(D_HA, req, "Zero SLV or Limit found (SLV: %llu, Limit: %u)", lustre_msg_get_slv(req->rq_repmsg), lustre_msg_get_limit(req->rq_repmsg)); return 0; @@ -1447,10 +1446,10 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns, int unused, int added, int count) { - cfs_time_t cur = cfs_time_current(); + unsigned long cur = cfs_time_current(); struct ldlm_pool *pl = &ns->ns_pool; __u64 slv, lvf, lv; - cfs_time_t la; + unsigned long la; /* Stop LRU processing when we reach past @count or have checked all * locks in LRU. */ @@ -1508,9 +1507,8 @@ static ldlm_policy_res_t ldlm_cancel_aged_policy(struct ldlm_namespace *ns, { /* Stop LRU processing if young lock is found and we reach past count */ return ((added >= count) && - cfs_time_before(cfs_time_current(), - cfs_time_add(lock->l_last_used, - ns->ns_max_age))) ? + time_before(cfs_time_current(), + cfs_time_add(lock->l_last_used, ns->ns_max_age))) ? LDLM_POLICY_KEEP_LOCK : LDLM_POLICY_CANCEL_LOCK; } @@ -1768,7 +1766,7 @@ int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, int ldlm_cancel_resource_local(struct ldlm_resource *res, struct list_head *cancels, ldlm_policy_data_t *policy, - ldlm_mode_t mode, int lock_flags, + ldlm_mode_t mode, __u64 lock_flags, ldlm_cancel_flags_t cancel_flags, void *opaque) { struct ldlm_lock *lock; @@ -1894,7 +1892,7 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, res = ldlm_resource_get(ns, NULL, res_id, 0, 0); if (res == NULL) { /* This is not a problem. */ - CDEBUG(D_INFO, "No resource "LPU64"\n", res_id->name[0]); + CDEBUG(D_INFO, "No resource %llu\n", res_id->name[0]); return 0; } @@ -2105,8 +2103,8 @@ static int replay_lock_interpret(const struct lu_env *env, lock = ldlm_handle2lock(&aa->lock_handle); if (!lock) { - CERROR("received replay ack for unknown local cookie "LPX64 - " remote cookie "LPX64 " from server %s id %s\n", + CERROR("received replay ack for unknown local cookie %#llx" + " remote cookie %#llx from server %s id %s\n", aa->lock_handle.cookie, reply->lock_handle.cookie, req->rq_export->exp_client_uuid.uuid, libcfs_id2str(req->rq_peer)); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index c55d72f79b26..efd45e513416 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -40,10 +40,9 @@ */ #define DEBUG_SUBSYSTEM S_LDLM -# include <lustre_dlm.h> - -#include <lustre_fid.h> -#include <obd_class.h> +#include "../include/lustre_dlm.h" +#include "../include/lustre_fid.h" +#include "../include/obd_class.h" #include "ldlm_internal.h" struct kmem_cache *ldlm_resource_slab, *ldlm_lock_slab; @@ -72,7 +71,7 @@ extern unsigned int ldlm_cancel_unused_locks_before_replay; * DDOS. */ unsigned int ldlm_dump_granted_max = 256; -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) static ssize_t lprocfs_wr_dump_ns(struct file *file, const char *buffer, size_t count, loff_t *off) { @@ -190,13 +189,15 @@ static int lprocfs_lru_size_seq_show(struct seq_file *m, void *v) return lprocfs_rd_uint(m, nr); } -static ssize_t lprocfs_lru_size_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t lprocfs_lru_size_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private; - char dummy[MAX_STRING_SIZE + 1], *end; + char dummy[MAX_STRING_SIZE + 1]; unsigned long tmp; int lru_resize; + int err; dummy[MAX_STRING_SIZE] = '\0'; if (copy_from_user(dummy, buffer, MAX_STRING_SIZE)) @@ -228,8 +229,8 @@ static ssize_t lprocfs_lru_size_seq_write(struct file *file, const char *buffer, return count; } - tmp = simple_strtoul(dummy, &end, 0); - if (dummy == end) { + err = kstrtoul(dummy, 10, &tmp); + if (err != 0) { CERROR("invalid value written\n"); return -EINVAL; } @@ -382,12 +383,12 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) return 0; } #undef MAX_STRING_SIZE -#else /* LPROCFS */ +#else /* CONFIG_PROC_FS */ #define ldlm_namespace_proc_unregister(ns) ({;}) #define ldlm_namespace_proc_register(ns) ({0;}) -#endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS */ static unsigned ldlm_res_hop_hash(struct cfs_hash *hs, const void *key, unsigned mask) @@ -854,9 +855,8 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns, { int rc; - if (!ns) { + if (!ns) return; - } spin_lock(&ns->ns_lock); ns->ns_stopping = 1; @@ -888,9 +888,8 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns, */ void ldlm_namespace_free_post(struct ldlm_namespace *ns) { - if (!ns) { + if (!ns) return; - } /* Make sure that nobody can find this ns in its list. */ ldlm_namespace_unregister(ns, ns->ns_client); @@ -1135,9 +1134,9 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CREATE_RESOURCE, 2); rc = ns->ns_lvbo->lvbo_init(res); if (rc < 0) { - CERROR("%s: lvbo_init failed for resource "LPX64":" - LPX64": rc = %d\n", ns->ns_obd->obd_name, - name->name[0], name->name[1], rc); + CERROR("%s: lvbo_init failed for resource %#llx:%#llx: rc = %d\n", + ns->ns_obd->obd_name, name->name[0], + name->name[1], rc); if (res->lr_lvb_data) { OBD_FREE(res->lr_lvb_data, res->lr_lvb_len); res->lr_lvb_data = NULL; @@ -1371,7 +1370,7 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns) ldlm_ns_name(ns), atomic_read(&ns->ns_bref), ns_is_client(ns) ? "client" : "server"); - if (cfs_time_before(cfs_time_current(), ns->ns_next_dump)) + if (time_before(cfs_time_current(), ns->ns_next_dump)) return; cfs_hash_for_each_nolock(ns->ns_rs_hash, diff --git a/drivers/staging/lustre/lustre/libcfs/Makefile b/drivers/staging/lustre/lustre/libcfs/Makefile index 6e489d7aaa8b..aeeaab73a1fd 100644 --- a/drivers/staging/lustre/lustre/libcfs/Makefile +++ b/drivers/staging/lustre/lustre/libcfs/Makefile @@ -16,6 +16,3 @@ libcfs-all-objs := debug.o fail.o nidstrings.o module.o tracefile.o \ libcfs_mem.o libcfs_lock.o libcfs-objs := $(libcfs-linux-objs) $(libcfs-all-objs) - -ccflags-y := -I$(src)/../include -ccflags-y += -I$(src)/ diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index 1e4c5ad26157..6b584698d3ae 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -41,7 +41,7 @@ # define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" #include "tracefile.h" static char debug_file_name[1024]; @@ -342,8 +342,8 @@ void libcfs_debug_dumplog_internal(void *arg) if (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0) { snprintf(debug_file_name, sizeof(debug_file_name) - 1, - "%s.%ld." LPLD, libcfs_debug_file_path_arr, - cfs_time_current_sec(), (long_ptr_t)arg); + "%s.%ld.%ld", libcfs_debug_file_path_arr, + get_seconds(), (long_ptr_t)arg); printk(KERN_ALERT "LustreError: dumping log to %s\n", debug_file_name); cfs_tracefile_dump_all_pages(debug_file_name); @@ -463,7 +463,7 @@ EXPORT_SYMBOL(libcfs_debug_set_level); void libcfs_log_goto(struct libcfs_debug_msg_data *msgdata, const char *label, long_ptr_t rc) { - libcfs_debug_msg(msgdata, "Process leaving via %s (rc=" LPLU " : " LPLD - " : " LPLX ")\n", label, (ulong_ptr_t)rc, rc, rc); + libcfs_debug_msg(msgdata, "Process leaving via %s (rc=%lu : %ld : %#lx)\n", + label, (ulong_ptr_t)rc, rc, rc); } EXPORT_SYMBOL(libcfs_log_goto); diff --git a/drivers/staging/lustre/lustre/libcfs/fail.c b/drivers/staging/lustre/lustre/libcfs/fail.c index ba43ff7f7900..1bf9c90b4789 100644 --- a/drivers/staging/lustre/lustre/libcfs/fail.c +++ b/drivers/staging/lustre/lustre/libcfs/fail.c @@ -33,16 +33,18 @@ * Lustre is a trademark of Oracle Corporation, Inc. */ -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" unsigned long cfs_fail_loc = 0; -unsigned int cfs_fail_val = 0; -wait_queue_head_t cfs_race_waitq; -int cfs_race_state; - EXPORT_SYMBOL(cfs_fail_loc); + +unsigned int cfs_fail_val = 0; EXPORT_SYMBOL(cfs_fail_val); + +wait_queue_head_t cfs_race_waitq; EXPORT_SYMBOL(cfs_race_waitq); + +int cfs_race_state; EXPORT_SYMBOL(cfs_race_state); int __cfs_fail_check_set(__u32 id, __u32 value, int set) diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index 6d2b455d1be4..8ef1deb59d4a 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -107,7 +107,7 @@ * table. Also, user can break the iteration by return 1 in callback. */ -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" #include <linux/seq_file.h> #if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1 @@ -351,7 +351,7 @@ cfs_hash_dh_hnode_add(struct cfs_hash *hs, struct cfs_hash_bd *bd, cfs_hash_dhead_t, dh_head); if (dh->dh_tail != NULL) /* not empty */ - hlist_add_after(dh->dh_tail, hnode); + hlist_add_behind(hnode, dh->dh_tail); else /* empty list */ hlist_add_head(hnode, &dh->dh_head); dh->dh_tail = hnode; @@ -406,7 +406,7 @@ cfs_hash_dd_hnode_add(struct cfs_hash *hs, struct cfs_hash_bd *bd, cfs_hash_dhead_dep_t, dd_head); if (dh->dd_tail != NULL) /* not empty */ - hlist_add_after(dh->dd_tail, hnode); + hlist_add_behind(hnode, dh->dd_tail); else /* empty list */ hlist_add_head(hnode, &dh->dd_head); dh->dd_tail = hnode; diff --git a/drivers/staging/lustre/lustre/libcfs/heap.c b/drivers/staging/lustre/lustre/libcfs/heap.c index 147e4fe4762d..bf6d0b91c35f 100644 --- a/drivers/staging/lustre/lustre/libcfs/heap.c +++ b/drivers/staging/lustre/lustre/libcfs/heap.c @@ -35,7 +35,7 @@ #define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" #define CBH_ALLOC(ptr, h) \ do { \ diff --git a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c index b6ddc998f750..e2aa637abcf9 100644 --- a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c +++ b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c @@ -42,7 +42,7 @@ #define DEBUG_SUBSYSTEM S_CLASS #define D_KUC D_OTHER -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" /* This is the kernel side (liblustre as well). */ diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c index a1a7bf44cccf..dbb81b6cc200 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c @@ -35,7 +35,7 @@ #define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" /** Global CPU partition table */ struct cfs_cpt_table *cfs_cpt_table __read_mostly = NULL; diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c b/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c index a2ce4c0eb3dc..2c199c7259fe 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c @@ -32,7 +32,7 @@ #define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" /** destroy cpu-partition lock, see libcfs_private.h for more detail */ diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c b/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c index feab537c728c..1debdda72e72 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c @@ -33,7 +33,7 @@ #define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" struct cfs_var_array { unsigned int va_count; /* # of buffers */ diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c index ed0a6b531058..fb88733607a9 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c @@ -40,7 +40,7 @@ * Author: Nathan Rutman <nathan.rutman@sun.com> */ -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" /* Convert a text string to a bitmask */ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c index fc21210d77ec..224c65b5ce4e 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c @@ -35,7 +35,7 @@ #include <linux/cpu.h> #include <linux/sched.h> -#include <linux/libcfs/libcfs.h> +#include "../../../include/linux/libcfs/libcfs.h" #ifdef CONFIG_SMP diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto-adler.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto-adler.c index 20b2d61d9ff2..5e185fa5942a 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto-adler.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto-adler.c @@ -32,12 +32,11 @@ #include <linux/module.h> #include <linux/zutil.h> #include <crypto/internal/hash.h> - +#include "linux-crypto.h" #define CHKSUM_BLOCK_SIZE 1 #define CHKSUM_DIGEST_SIZE 4 - static u32 __adler32(u32 cksum, unsigned char const *p, size_t len) { return zlib_adler32(cksum, p, len); @@ -135,10 +134,8 @@ int cfs_crypto_adler32_register(void) { return crypto_register_shash(&alg); } -EXPORT_SYMBOL(cfs_crypto_adler32_register); void cfs_crypto_adler32_unregister(void) { crypto_unregister_shash(&alg); } -EXPORT_SYMBOL(cfs_crypto_adler32_unregister); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c index b6c79bc177ad..aa3fffed1519 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c @@ -29,8 +29,8 @@ #include <linux/crypto.h> #include <linux/scatterlist.h> -#include <linux/libcfs/libcfs.h> -#include <linux/libcfs/linux/linux-crypto.h> +#include "../../../include/linux/libcfs/libcfs.h" +#include "linux-crypto.h" /** * Array of hash algorithm speed in MByte per second */ diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.h b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.h new file mode 100644 index 000000000000..18e8cd4d8758 --- /dev/null +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.h @@ -0,0 +1,29 @@ + /* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see http://www.gnu.org/licenses + * + * Please visit http://www.xyratex.com/contact if you need additional + * information or have any questions. + * + * GPL HEADER END + */ + +/** + * Functions for start/stop shash adler32 algorithm. + */ +int cfs_crypto_adler32_register(void); +void cfs_crypto_adler32_unregister(void); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index bd301ce02255..d71ad5ed1f6d 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -48,7 +48,7 @@ #define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> +#include "../../../include/linux/libcfs/libcfs.h" /* * Implementation of cfs_curproc API (see portals/include/libcfs/curproc.h) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index cc565b1fb994..eaa423d13650 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -55,10 +55,10 @@ # define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> -#include <linux/libcfs/linux/portals_compat25.h> +#include "../../../include/linux/libcfs/libcfs.h" +#include "../../../include/linux/libcfs/linux/portals_compat25.h" -#include "tracefile.h" +#include "../tracefile.h" #include <linux/kallsyms.h> diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index 581b4728c6ca..de3c199654a0 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -36,7 +36,7 @@ #define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> +#include "../../../include/linux/libcfs/libcfs.h" #define LNET_MINOR 240 @@ -99,7 +99,7 @@ int libcfs_ioctl_popdata(void *arg, void *data, int size) extern struct cfs_psdev_ops libcfs_psdev_ops; static int -libcfs_psdev_open(struct inode * inode, struct file * file) +libcfs_psdev_open(struct inode *inode, struct file *file) { struct libcfs_device_userstate **pdu = NULL; int rc = 0; @@ -116,7 +116,7 @@ libcfs_psdev_open(struct inode * inode, struct file * file) /* called when closing /dev/device */ static int -libcfs_psdev_release(struct inode * inode, struct file * file) +libcfs_psdev_release(struct inode *inode, struct file *file) { struct libcfs_device_userstate *pdu; int rc = 0; @@ -140,9 +140,9 @@ static long libcfs_ioctl(struct file *file, if (!capable(CAP_SYS_ADMIN)) return -EACCES; - if ( _IOC_TYPE(cmd) != IOC_LIBCFS_TYPE || + if (_IOC_TYPE(cmd) != IOC_LIBCFS_TYPE || _IOC_NR(cmd) < IOC_LIBCFS_MIN_NR || - _IOC_NR(cmd) > IOC_LIBCFS_MAX_NR ) { + _IOC_NR(cmd) > IOC_LIBCFS_MAX_NR) { CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n", _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd)); return (-EINVAL); @@ -154,7 +154,7 @@ static long libcfs_ioctl(struct file *file, if (!capable(CFS_CAP_SYS_BOOT)) return (-EPERM); panic("debugctl-invoked panic"); - return (0); + return 0; case IOC_LIBCFS_MEMHOG: if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; @@ -167,10 +167,10 @@ static long libcfs_ioctl(struct file *file, rc = libcfs_psdev_ops.p_ioctl(&pfile, cmd, (void *)arg); else rc = -EPERM; - return (rc); + return rc; } -static struct file_operations libcfs_fops = { +static const struct file_operations libcfs_fops = { .unlocked_ioctl = libcfs_ioctl, .open = libcfs_psdev_open, .release = libcfs_psdev_release, diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c index 9a40d1415a65..871ba44b29f3 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c @@ -40,7 +40,7 @@ #include <linux/fs_struct.h> #include <linux/sched.h> -#include <linux/libcfs/libcfs.h> +#include "../../../include/linux/libcfs/libcfs.h" #if defined(CONFIG_KGDB) #include <asm/kgdb.h> @@ -90,7 +90,7 @@ void cfs_timer_done(struct timer_list *t) } EXPORT_SYMBOL(cfs_timer_done); -void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline) +void cfs_timer_arm(struct timer_list *t, unsigned long deadline) { mod_timer(t, deadline); } @@ -108,7 +108,7 @@ int cfs_timer_is_armed(struct timer_list *t) } EXPORT_SYMBOL(cfs_timer_is_armed); -cfs_time_t cfs_timer_deadline(struct timer_list *t) +unsigned long cfs_timer_deadline(struct timer_list *t) { return t->expires; } diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c index e947b9128c58..13a9266acfa0 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c @@ -61,11 +61,11 @@ # define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> +#include "../../../include/linux/libcfs/libcfs.h" #include <asm/div64.h> -#include "tracefile.h" +#include "../tracefile.h" -static ctl_table_header_t *lnet_table_header = NULL; +static struct ctl_table_header *lnet_table_header = NULL; extern char lnet_upcall[1024]; /** * The path of debug log dump upcall script. @@ -98,11 +98,9 @@ enum { PSDEV_LNET_FAIL_VAL, /* userdata for fail loc */ }; -int -proc_call_handler(void *data, int write, - loff_t *ppos, void *buffer, size_t *lenp, - int (*handler)(void *data, int write, - loff_t pos, void *buffer, int len)) +static int proc_call_handler(void *data, int write, loff_t *ppos, void *buffer, + size_t *lenp, int (*handler)(void *data, int write, + loff_t pos, void *buffer, int len)) { int rc = handler(data, write, *ppos, buffer, *lenp); @@ -117,7 +115,6 @@ proc_call_handler(void *data, int write, } return 0; } -EXPORT_SYMBOL(proc_call_handler); static int __proc_dobitmasks(void *data, int write, loff_t pos, void *buffer, int nob) @@ -160,7 +157,12 @@ static int __proc_dobitmasks(void *data, int write, return rc; } -DECLARE_PROC_HANDLER(proc_dobitmasks) +static int proc_dobitmasks(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_dobitmasks); +} static int min_watchdog_ratelimit = 0; /* disable ratelimiting */ static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */ @@ -174,7 +176,12 @@ static int __proc_dump_kernel(void *data, int write, return cfs_trace_dump_debug_buffer_usrstr(buffer, nob); } -DECLARE_PROC_HANDLER(proc_dump_kernel) +static int proc_dump_kernel(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_dump_kernel); +} static int __proc_daemon_file(void *data, int write, loff_t pos, void *buffer, int nob) @@ -192,7 +199,12 @@ static int __proc_daemon_file(void *data, int write, return cfs_trace_daemon_command_usrstr(buffer, nob); } -DECLARE_PROC_HANDLER(proc_daemon_file) +static int proc_daemon_file(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_daemon_file); +} static int __proc_debug_mb(void *data, int write, loff_t pos, void *buffer, int nob) @@ -212,26 +224,32 @@ static int __proc_debug_mb(void *data, int write, return cfs_trace_set_debug_mb_usrstr(buffer, nob); } -DECLARE_PROC_HANDLER(proc_debug_mb) +static int proc_debug_mb(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_debug_mb); +} -int LL_PROC_PROTO(proc_console_max_delay_cs) +int proc_console_max_delay_cs(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int rc, max_delay_cs; - ctl_table_t dummy = *table; - cfs_duration_t d; + struct ctl_table dummy = *table; + long d; dummy.data = &max_delay_cs; dummy.proc_handler = &proc_dointvec; if (!write) { /* read */ max_delay_cs = cfs_duration_sec(libcfs_console_max_delay * 100); - rc = ll_proc_dointvec(&dummy, write, filp, buffer, lenp, ppos); + rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); return rc; } /* write */ max_delay_cs = 0; - rc = ll_proc_dointvec(&dummy, write, filp, buffer, lenp, ppos); + rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); if (rc < 0) return rc; if (max_delay_cs <= 0) @@ -245,24 +263,25 @@ int LL_PROC_PROTO(proc_console_max_delay_cs) return rc; } -int LL_PROC_PROTO(proc_console_min_delay_cs) +int proc_console_min_delay_cs(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int rc, min_delay_cs; - ctl_table_t dummy = *table; - cfs_duration_t d; + struct ctl_table dummy = *table; + long d; dummy.data = &min_delay_cs; dummy.proc_handler = &proc_dointvec; if (!write) { /* read */ min_delay_cs = cfs_duration_sec(libcfs_console_min_delay * 100); - rc = ll_proc_dointvec(&dummy, write, filp, buffer, lenp, ppos); + rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); return rc; } /* write */ min_delay_cs = 0; - rc = ll_proc_dointvec(&dummy, write, filp, buffer, lenp, ppos); + rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); if (rc < 0) return rc; if (min_delay_cs <= 0) @@ -276,23 +295,24 @@ int LL_PROC_PROTO(proc_console_min_delay_cs) return rc; } -int LL_PROC_PROTO(proc_console_backoff) +int proc_console_backoff(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int rc, backoff; - ctl_table_t dummy = *table; + struct ctl_table dummy = *table; dummy.data = &backoff; dummy.proc_handler = &proc_dointvec; if (!write) { /* read */ backoff= libcfs_console_backoff; - rc = ll_proc_dointvec(&dummy, write, filp, buffer, lenp, ppos); + rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); return rc; } /* write */ backoff = 0; - rc = ll_proc_dointvec(&dummy, write, filp, buffer, lenp, ppos); + rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); if (rc < 0) return rc; if (backoff <= 0) @@ -303,19 +323,21 @@ int LL_PROC_PROTO(proc_console_backoff) return rc; } -int LL_PROC_PROTO(libcfs_force_lbug) +int libcfs_force_lbug(struct ctl_table *table, int write, void __user *buffer, + size_t *lenp, loff_t *ppos) { if (write) LBUG(); return 0; } -int LL_PROC_PROTO(proc_fail_loc) +int proc_fail_loc(struct ctl_table *table, int write, void __user *buffer, + size_t *lenp, loff_t *ppos) { int rc; long old_fail_loc = cfs_fail_loc; - rc = ll_proc_dolongvec(table, write, filp, buffer, lenp, ppos); + rc = proc_doulongvec_minmax(table, write, buffer, lenp, ppos); if (old_fail_loc != cfs_fail_loc) wake_up(&cfs_race_waitq); return rc; @@ -361,9 +383,15 @@ static int __proc_cpt_table(void *data, int write, LIBCFS_FREE(buf, len); return rc; } -DECLARE_PROC_HANDLER(proc_cpt_table) -static ctl_table_t lnet_table[] = { +static int proc_cpt_table(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_cpt_table); +} + +static struct ctl_table lnet_table[] = { /* * NB No .strategy entries have been provided since sysctl(8) prefers * to go via /proc for portability. @@ -516,7 +544,7 @@ static ctl_table_t lnet_table[] = { } }; -static ctl_table_t top_table[] = { +static struct ctl_table top_table[] = { { .procname = "lnet", .mode = 0555, diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c index ac3a444a918d..a93b6210705b 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c @@ -35,7 +35,7 @@ */ #define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> +#include "../../../include/linux/libcfs/libcfs.h" #include <linux/if.h> #include <linux/in.h> @@ -46,16 +46,31 @@ int libcfs_sock_ioctl(int cmd, unsigned long arg) { + mm_segment_t oldmm = get_fs(); struct socket *sock; - int rc; + int rc; + struct file *sock_filp; rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock); if (rc != 0) { CERROR ("Can't create socket: %d\n", rc); return rc; } - rc = kernel_sock_ioctl(sock, cmd, arg); - sock_release(sock); + + sock_filp = sock_alloc_file(sock, 0, NULL); + if (IS_ERR(sock_filp)) { + sock_release(sock); + rc = PTR_ERR(sock_filp); + goto out; + } + + set_fs(KERNEL_DS); + if (sock_filp->f_op->unlocked_ioctl) + rc = sock_filp->f_op->unlocked_ioctl(sock_filp, cmd, arg); + set_fs(oldmm); + + fput(sock_filp); +out: return rc; } @@ -183,8 +198,6 @@ libcfs_ipif_enumerate (char ***namesp) rc = -ENOMEM; goto out1; } - /* NULL out all names[i] */ - memset (names, 0, nfound * sizeof(*names)); for (i = 0; i < nfound; i++) { @@ -532,7 +545,7 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock) newsock->ops = sock->ops; set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(cfs_sk_sleep(sock->sk), &wait); + add_wait_queue(sk_sleep(sock->sk), &wait); rc = sock->ops->accept(sock, newsock, O_NONBLOCK); if (rc == -EAGAIN) { @@ -541,7 +554,7 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock) rc = sock->ops->accept(sock, newsock, O_NONBLOCK); } - remove_wait_queue(cfs_sk_sleep(sock->sk), &wait); + remove_wait_queue(sk_sleep(sock->sk), &wait); set_current_state(TASK_RUNNING); if (rc != 0) @@ -560,7 +573,7 @@ EXPORT_SYMBOL(libcfs_sock_accept); void libcfs_sock_abort_accept (struct socket *sock) { - wake_up_all(cfs_sk_sleep(sock->sk)); + wake_up_all(sk_sleep(sock->sk)); } EXPORT_SYMBOL(libcfs_sock_abort_accept); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index 162beee24a73..976c61ed49f4 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -37,8 +37,8 @@ #define DEBUG_SUBSYSTEM S_LNET #define LUSTRE_TRACEFILE_PRIVATE -#include <linux/libcfs/libcfs.h> -#include "tracefile.h" +#include "../../../include/linux/libcfs/libcfs.h" +#include "../tracefile.h" /* percents to share the total debug memory for each type */ static unsigned int pages_factor[CFS_TCD_TYPE_MAX] = { @@ -112,8 +112,6 @@ void cfs_tracefile_fini_arch(void) kfree(cfs_trace_data[i]); cfs_trace_data[i] = NULL; } - - fini_rwsem(&cfs_tracefile_sem); } void cfs_tracefile_read_lock(void) diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index b16ee08fe742..3396858098b0 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -36,10 +36,10 @@ #define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> -#include <linux/libcfs/libcfs_crypto.h> -#include <linux/lnet/lib-lnet.h> -#include <linux/lnet/lnet.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../../include/linux/libcfs/libcfs_crypto.h" +#include "../../include/linux/lnet/lib-lnet.h" +#include "../../include/linux/lnet/lnet.h" #include "tracefile.h" void @@ -439,9 +439,6 @@ static void exit_libcfs_module(void) printk(KERN_ERR "LustreError: libcfs_debug_cleanup: %d\n", rc); - fini_rwsem(&ioctl_list_sem); - fini_rwsem(&cfs_tracefile_sem); - libcfs_arch_cleanup(); } diff --git a/drivers/staging/lustre/lustre/libcfs/nidstrings.c b/drivers/staging/lustre/lustre/libcfs/nidstrings.c index 87705ae4480f..47c239f22ba8 100644 --- a/drivers/staging/lustre/lustre/libcfs/nidstrings.c +++ b/drivers/staging/lustre/lustre/libcfs/nidstrings.c @@ -40,8 +40,8 @@ #define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> -#include <linux/lnet/lnet.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../../include/linux/lnet/lnet.h" /* CAVEAT VENDITOR! Keep the canonical string representation of nets/nids * consistent in all conversion functions. Some code fragments are copied @@ -74,8 +74,7 @@ libcfs_next_nidstring(void) spin_lock_irqsave(&libcfs_nidstring_lock, flags); str = libcfs_nidstrings[libcfs_nidstring_idx++]; - if (libcfs_nidstring_idx == - sizeof(libcfs_nidstrings)/sizeof(libcfs_nidstrings[0])) + if (libcfs_nidstring_idx == ARRAY_SIZE(libcfs_nidstrings)) libcfs_nidstring_idx = 0; spin_unlock_irqrestore(&libcfs_nidstring_lock, flags); @@ -198,7 +197,7 @@ static struct netstrfns libcfs_netstrfns[] = { {/* .nf_type */ -1}, }; -const int libcfs_nnetstrfns = sizeof(libcfs_netstrfns)/sizeof(libcfs_netstrfns[0]); +const int libcfs_nnetstrfns = ARRAY_SIZE(libcfs_netstrfns); int libcfs_lo_str2addr(const char *str, int nob, __u32 *addr) diff --git a/drivers/staging/lustre/lustre/libcfs/prng.c b/drivers/staging/lustre/lustre/libcfs/prng.c index f87e9e516546..4147664ff57a 100644 --- a/drivers/staging/lustre/lustre/libcfs/prng.c +++ b/drivers/staging/lustre/lustre/libcfs/prng.c @@ -39,7 +39,7 @@ * algorithm recommended by Marsaglia */ -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" /* From: George Marsaglia <geo@stat.fsu.edu> diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index 07845e844243..0569bf8c75f3 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -44,7 +44,7 @@ #define LUSTRE_TRACEFILE_PRIVATE #include "tracefile.h" -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" /* XXX move things up to the top, comment */ union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS] __cacheline_aligned; diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.h b/drivers/staging/lustre/lustre/libcfs/tracefile.h index 55ecfc9f201b..8df4af36c91d 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.h +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.h @@ -37,7 +37,7 @@ #ifndef __LIBCFS_TRACEFILE_H__ #define __LIBCFS_TRACEFILE_H__ -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" #include "linux/linux-tracefile.h" diff --git a/drivers/staging/lustre/lustre/libcfs/upcall_cache.c b/drivers/staging/lustre/lustre/libcfs/upcall_cache.c index 8085e32e5e7a..88af82034e92 100644 --- a/drivers/staging/lustre/lustre/libcfs/upcall_cache.c +++ b/drivers/staging/lustre/lustre/libcfs/upcall_cache.c @@ -39,7 +39,7 @@ */ #define DEBUG_SUBSYSTEM S_SEC -#include <linux/libcfs/lucache.h> +#include "../../include/linux/libcfs/lucache.h" static struct upcall_cache_entry *alloc_entry(struct upcall_cache *cache, __u64 key, void *args) @@ -68,7 +68,7 @@ static void free_entry(struct upcall_cache *cache, cache->uc_ops->free_entry(cache, entry); list_del(&entry->ue_hash); - CDEBUG(D_OTHER, "destroy cache entry %p for key "LPU64"\n", + CDEBUG(D_OTHER, "destroy cache entry %p for key %llu\n", entry, entry->ue_key); LIBCFS_FREE(entry, sizeof(*entry)); } @@ -117,13 +117,12 @@ static int check_unlink_entry(struct upcall_cache *cache, struct upcall_cache_entry *entry) { if (UC_CACHE_IS_VALID(entry) && - cfs_time_before(cfs_time_current(), entry->ue_expire)) + time_before(cfs_time_current(), entry->ue_expire)) return 0; if (UC_CACHE_IS_ACQUIRING(entry)) { if (entry->ue_acquire_expire == 0 || - cfs_time_before(cfs_time_current(), - entry->ue_acquire_expire)) + time_before(cfs_time_current(), entry->ue_acquire_expire)) return 0; UC_CACHE_SET_EXPIRED(entry); @@ -230,7 +229,7 @@ find_again: if (UC_CACHE_IS_ACQUIRING(entry)) { /* we're interrupted or upcall failed in the middle */ rc = left > 0 ? -EINTR : -ETIMEDOUT; - CERROR("acquire for key "LPU64": error %d\n", + CERROR("acquire for key %llu: error %d\n", entry->ue_key, rc); put_entry(cache, entry); GOTO(out, entry = ERR_PTR(rc)); @@ -303,7 +302,7 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key, } if (!found) { - CDEBUG(D_OTHER, "%s: upcall for key "LPU64" not expected\n", + CDEBUG(D_OTHER, "%s: upcall for key %llu not expected\n", cache->uc_name, key); /* haven't found, it's possible */ spin_unlock(&cache->uc_lock); @@ -311,19 +310,19 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key, } if (err) { - CDEBUG(D_OTHER, "%s: upcall for key "LPU64" returned %d\n", + CDEBUG(D_OTHER, "%s: upcall for key %llu returned %d\n", cache->uc_name, entry->ue_key, err); GOTO(out, rc = -EINVAL); } if (!UC_CACHE_IS_ACQUIRING(entry)) { - CDEBUG(D_RPCTRACE,"%s: found uptodate entry %p (key "LPU64")\n", + CDEBUG(D_RPCTRACE,"%s: found uptodate entry %p (key %llu)\n", cache->uc_name, entry, entry->ue_key); GOTO(out, rc = 0); } if (UC_CACHE_IS_INVALID(entry) || UC_CACHE_IS_EXPIRED(entry)) { - CERROR("%s: found a stale entry %p (key "LPU64") in ioctl\n", + CERROR("%s: found a stale entry %p (key %llu) in ioctl\n", cache->uc_name, entry, entry->ue_key); GOTO(out, rc = -EINVAL); } @@ -337,7 +336,7 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key, entry->ue_expire = cfs_time_shift(cache->uc_entry_expire); UC_CACHE_SET_VALID(entry); - CDEBUG(D_OTHER, "%s: created upcall cache entry %p for key "LPU64"\n", + CDEBUG(D_OTHER, "%s: created upcall cache entry %p for key %llu\n", cache->uc_name, entry, entry->ue_key); out: if (rc) { @@ -402,11 +401,10 @@ void upcall_cache_flush_one(struct upcall_cache *cache, __u64 key, void *args) } if (found) { - CWARN("%s: flush entry %p: key "LPU64", ref %d, fl %x, " - "cur %lu, ex %ld/%ld\n", + CWARN("%s: flush entry %p: key %llu, ref %d, fl %x, cur %lu, ex %ld/%ld\n", cache->uc_name, entry, entry->ue_key, atomic_read(&entry->ue_refcount), entry->ue_flags, - cfs_time_current_sec(), entry->ue_acquire_expire, + get_seconds(), entry->ue_acquire_expire, entry->ue_expire); UC_CACHE_SET_EXPIRED(entry); if (!atomic_read(&entry->ue_refcount)) diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c index 0a03bf7ba3eb..65629579bd7d 100644 --- a/drivers/staging/lustre/lustre/libcfs/workitem.c +++ b/drivers/staging/lustre/lustre/libcfs/workitem.c @@ -41,7 +41,7 @@ #define DEBUG_SUBSYSTEM S_LNET -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" #define CFS_WS_NAME_LEN 16 diff --git a/drivers/staging/lustre/lustre/llite/Makefile b/drivers/staging/lustre/lustre/llite/Makefile index c76f3cfedab0..7d70115d5bc7 100644 --- a/drivers/staging/lustre/lustre/llite/Makefile +++ b/drivers/staging/lustre/lustre/llite/Makefile @@ -9,6 +9,3 @@ lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \ lustre-$(CONFIG_PROC_FS) += lproc_llite.o llite_lloop-y := lloop.o - - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 7d520d8f4a69..49ae207ad425 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -40,10 +40,10 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <obd_support.h> -#include <lustre_lite.h> -#include <lustre/lustre_idl.h> -#include <lustre_dlm.h> +#include "../include/obd_support.h" +#include "../include/lustre_lite.h" +#include "../include/lustre/lustre_idl.h" +#include "../include/lustre_dlm.h" #include "llite_internal.h" @@ -213,8 +213,8 @@ void ll_intent_drop_lock(struct lookup_intent *it) handle.cookie = it->d.lustre.it_lock_handle; - CDEBUG(D_DLMTRACE, "releasing lock with cookie "LPX64 - " from it %p\n", handle.cookie, it); + CDEBUG(D_DLMTRACE, "releasing lock with cookie %#llx from it %p\n", + handle.cookie, it); ldlm_lock_decref(&handle, it->d.lustre.it_lock_mode); /* bug 494: intent_release may be called multiple times, from @@ -223,8 +223,8 @@ void ll_intent_drop_lock(struct lookup_intent *it) if (it->d.lustre.it_remote_lock_mode != 0) { handle.cookie = it->d.lustre.it_remote_lock_handle; - CDEBUG(D_DLMTRACE, "releasing remote lock with cookie" - LPX64" from it %p\n", handle.cookie, it); + CDEBUG(D_DLMTRACE, "releasing remote lock with cookie%#llx from it %p\n", + handle.cookie, it); ldlm_lock_decref(&handle, it->d.lustre.it_remote_lock_mode); it->d.lustre.it_remote_lock_mode = 0; diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index ae6f61aa4da6..efa2faf080d7 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -48,13 +48,13 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_lib.h> -#include <lustre/lustre_idl.h> -#include <lustre_lite.h> -#include <lustre_dlm.h> -#include <lustre_fid.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_lib.h" +#include "../include/lustre/lustre_idl.h" +#include "../include/lustre_lite.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_fid.h" #include "llite_internal.h" /* @@ -158,7 +158,7 @@ static int ll_dir_filler(void *_hash, struct page *page0) int i; int rc; - CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) hash "LPU64"\n", + CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) hash %llu\n", inode->i_ino, inode->i_generation, inode, hash); LASSERT(max_pages > 0 && max_pages <= MD_MAX_BRW_PAGES); @@ -302,9 +302,9 @@ static struct page *ll_dir_page_locate(struct inode *dir, __u64 *hash, *start = le64_to_cpu(dp->ldp_hash_start); *end = le64_to_cpu(dp->ldp_hash_end); } - LASSERTF(*start <= *hash, "start = "LPX64",end = " - LPX64",hash = "LPX64"\n", *start, *end, *hash); - CDEBUG(D_VFSTRACE, "page %lu [%llu %llu], hash "LPU64"\n", + LASSERTF(*start <= *hash, "start = %#llx,end = %#llx,hash = %#llx\n", + *start, *end, *hash); + CDEBUG(D_VFSTRACE, "page %lu [%llu %llu], hash %llu\n", offset, *start, *end, *hash); if (*hash > *end) { ll_release_page(page, 0); @@ -376,7 +376,7 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, if (request) ptlrpc_req_finished(request); if (rc < 0) { - CERROR("lock enqueue: "DFID" at "LPU64": rc %d\n", + CERROR("lock enqueue: "DFID" at %llu: rc %d\n", PFID(ll_inode2fid(dir)), hash, rc); return ERR_PTR(rc); } @@ -396,7 +396,7 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, mutex_lock(&lli->lli_readdir_mutex); page = ll_dir_page_locate(dir, &lhash, &start, &end); if (IS_ERR(page)) { - CERROR("dir page locate: "DFID" at "LPU64": rc %ld\n", + CERROR("dir page locate: "DFID" at %llu: rc %ld\n", PFID(ll_inode2fid(dir)), lhash, PTR_ERR(page)); GOTO(out_unlock, page); } else if (page != NULL) { @@ -420,7 +420,7 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, page = read_cache_page(mapping, hash_x_index(hash, hash64), ll_dir_filler, &lhash); if (IS_ERR(page)) { - CERROR("read cache page: "DFID" at "LPU64": rc %ld\n", + CERROR("read cache page: "DFID" at %llu: rc %ld\n", PFID(ll_inode2fid(dir)), hash, PTR_ERR(page)); GOTO(out_unlock, page); } @@ -428,14 +428,14 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, wait_on_page_locked(page); (void)kmap(page); if (!PageUptodate(page)) { - CERROR("page not updated: "DFID" at "LPU64": rc %d\n", + CERROR("page not updated: "DFID" at %llu: rc %d\n", PFID(ll_inode2fid(dir)), hash, -5); goto fail; } if (!PageChecked(page)) ll_check_page(dir, page); if (PageError(page)) { - CERROR("page error: "DFID" at "LPU64": rc %d\n", + CERROR("page error: "DFID" at %llu: rc %d\n", PFID(ll_inode2fid(dir)), hash, -5); goto fail; } @@ -452,10 +452,9 @@ hash_collision: } if (end == start) { LASSERT(start == lhash); - CWARN("Page-wide hash collision: "LPU64"\n", end); + CWARN("Page-wide hash collision: %llu\n", end); if (BITS_PER_LONG == 32 && hash64) - CWARN("Real page-wide hash collision at ["LPU64" "LPU64 - "] with hash "LPU64"\n", + CWARN("Real page-wide hash collision at [%llu %llu] with hash %llu\n", le64_to_cpu(dp->ldp_hash_start), le64_to_cpu(dp->ldp_hash_end), hash); /* @@ -926,8 +925,7 @@ static int ll_ioc_copy_start(struct super_block *sb, struct hsm_copy *copy) iput(inode); if (rc != 0) { CDEBUG(D_HSM, "Could not read file data version of " - DFID" (rc = %d). Archive request (" - LPX64") could not be done.\n", + DFID" (rc = %d). Archive request (%#llx) could not be done.\n", PFID(©->hc_hai.hai_fid), rc, copy->hc_hai.hai_cookie); hpk.hpk_flags |= HP_FLAG_RETRY; @@ -1023,7 +1021,7 @@ static int ll_ioc_copy_end(struct super_block *sb, struct hsm_copy *copy) (copy->hc_data_version != data_version)) { CDEBUG(D_HSM, "File data version mismatched. " "File content was changed during archiving. " - DFID", start:"LPX64" current:"LPX64"\n", + DFID", start:%#llx current:%#llx\n", PFID(©->hc_hai.hai_fid), copy->hc_data_version, data_version); /* File was changed, send error to cdt. Do not ask for @@ -1266,7 +1264,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (mdtidx < 0) return mdtidx; - if (put_user((int)mdtidx, (int*)arg)) + if (put_user((int)mdtidx, (int *)arg)) return -EFAULT; return 0; @@ -1501,7 +1499,7 @@ out_rmdir: GOTO(out_req, rc = -EFAULT); rc = -EOVERFLOW; } - skip_lmm: +skip_lmm: if (cmd == IOC_MDC_GETFILEINFO || cmd == LL_IOC_MDC_GETINFO) { struct lov_user_mds_data *lmdp; lstat_t st = { 0 }; @@ -1525,7 +1523,7 @@ out_rmdir: GOTO(out_req, rc = -EFAULT); } - out_req: +out_req: ptlrpc_req_finished(request); if (filename) ll_putname(filename); @@ -1589,9 +1587,9 @@ out_rmdir: if (copy_to_user(&lumd->lmd_st, &st, sizeof(st))) GOTO(free_lsm, rc = -EFAULT); - free_lsm: +free_lsm: obd_free_memmd(sbi->ll_dt_exp, &lsm); - free_lmm: +free_lmm: OBD_FREE_LARGE(lmm, lmmsize); return rc; } @@ -1653,7 +1651,7 @@ out_rmdir: CDEBUG(D_QUOTA, "copy_to_user failed\n"); GOTO(out_poll, rc); } - out_poll: +out_poll: OBD_FREE_PTR(check); return rc; } @@ -1702,9 +1700,9 @@ out_rmdir: rc = -EFAULT; } - out_quotactl_20: +out_quotactl_20: OBD_FREE_PTR(qctl_20); - out_quotactl_18: +out_quotactl_18: OBD_FREE_PTR(qctl_18); return rc; } @@ -1726,7 +1724,7 @@ out_rmdir: if (rc == 0 && copy_to_user((void *)arg,qctl,sizeof(*qctl))) rc = -EFAULT; - out_quotactl: +out_quotactl: OBD_FREE_PTR(qctl); return rc; } @@ -1778,7 +1776,7 @@ out_rmdir: return -EFAULT; return 0; case LL_IOC_GET_CONNECT_FLAGS: { - return obd_iocontrol(cmd, sbi->ll_md_exp, 0, NULL, (void*)arg); + return obd_iocontrol(cmd, sbi->ll_md_exp, 0, NULL, (void *)arg); } case OBD_IOC_CHANGELOG_SEND: case OBD_IOC_CHANGELOG_CLEAR: diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 716e1ee0104f..fd1b75a3a569 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -41,14 +41,14 @@ */ #define DEBUG_SUBSYSTEM S_LLITE -#include <lustre_dlm.h> -#include <lustre_lite.h> +#include "../include/lustre_dlm.h" +#include "../include/lustre_lite.h" #include <linux/pagemap.h> #include <linux/file.h> #include "llite_internal.h" -#include <lustre/ll_fiemap.h> +#include "../include/lustre/ll_fiemap.h" -#include "cl_object.h" +#include "../include/cl_object.h" static int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg); @@ -140,7 +140,7 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, * XXX: in case of LMV, is this correct to access * ->exp_handle? */ - CERROR("Invalid MDC connection handle "LPX64"\n", + CERROR("Invalid MDC connection handle %#llx\n", ll_i2mdexp(inode)->exp_handle.h_cookie); GOTO(out, rc = 0); } @@ -290,7 +290,7 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode, we can skip talking to MDS */ if (file->f_dentry->d_inode) { /* Can this ever be false? */ int lockmode; - int flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK; + __u64 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK; struct lustre_handle lockh; struct inode *inode = file->f_dentry->d_inode; ldlm_policy_data_t policy = {.l_inodebits={MDS_INODELOCK_OPEN}}; @@ -471,7 +471,7 @@ void ll_ioepoch_open(struct ll_inode_info *lli, __u64 ioepoch) { if (ioepoch && lli->lli_ioepoch != ioepoch) { lli->lli_ioepoch = ioepoch; - CDEBUG(D_INODE, "Epoch "LPU64" opened on "DFID"\n", + CDEBUG(D_INODE, "Epoch %llu opened on "DFID"\n", ioepoch, PFID(&lli->lli_fid)); } } @@ -1008,7 +1008,7 @@ int ll_merge_lvb(const struct lu_env *env, struct inode *inode) if (lvb.lvb_mtime < attr->cat_mtime) lvb.lvb_mtime = attr->cat_mtime; - CDEBUG(D_VFSTRACE, DFID" updating i_size "LPU64"\n", + CDEBUG(D_VFSTRACE, DFID" updating i_size %llu\n", PFID(&lli->lli_fid), attr->cat_size); cl_isize_write_nolock(inode, attr->cat_size); @@ -2623,7 +2623,7 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) struct md_op_data *op_data; struct lustre_handle lockh = {0}; ldlm_policy_data_t flock = {{0}}; - int flags = 0; + __u64 flags = 0; int rc; int rc2 = 0; @@ -2708,9 +2708,9 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) if (IS_ERR(op_data)) return PTR_ERR(op_data); - CDEBUG(D_DLMTRACE, "inode=%lu, pid=%u, flags=%#x, mode=%u, " - "start="LPU64", end="LPU64"\n", inode->i_ino, flock.l_flock.pid, - flags, einfo.ei_mode, flock.l_flock.start, flock.l_flock.end); + CDEBUG(D_DLMTRACE, "inode=%lu, pid=%u, flags=%#llx, mode=%u, start=%llu, end=%llu\n", + inode->i_ino, flock.l_flock.pid, flags, einfo.ei_mode, + flock.l_flock.start, flock.l_flock.end); rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL, op_data, &lockh, &flock, 0, NULL /* req */, flags); diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c index d06d0b1ab08a..023c40518c6d 100644 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ b/drivers/staging/lustre/lustre/llite/llite_capa.c @@ -41,11 +41,11 @@ #define DEBUG_SUBSYSTEM S_LLITE #include <linux/fs.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/file.h> #include <linux/kmod.h> -#include <lustre_lite.h> +#include "../include/lustre_lite.h" #include "llite_internal.h" /* for obd_capa.c_list, client capa might stay in three places: @@ -63,16 +63,16 @@ static struct list_head *ll_capa_list = &capa_list[CAPA_SITE_CLIENT]; struct timer_list ll_capa_timer; /* for debug: indicate whether capa on llite is enabled or not */ static atomic_t ll_capa_debug = ATOMIC_INIT(0); -static unsigned long long ll_capa_renewed = 0; -static unsigned long long ll_capa_renewal_noent = 0; -static unsigned long long ll_capa_renewal_failed = 0; -static unsigned long long ll_capa_renewal_retries = 0; +static unsigned long long ll_capa_renewed; +static unsigned long long ll_capa_renewal_noent; +static unsigned long long ll_capa_renewal_failed; +static unsigned long long ll_capa_renewal_retries; static int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa); -static inline void update_capa_timer(struct obd_capa *ocapa, cfs_time_t expiry) +static inline void update_capa_timer(struct obd_capa *ocapa, unsigned long expiry) { - if (cfs_time_before(expiry, ll_capa_timer.expires) || + if (time_before(expiry, ll_capa_timer.expires) || !timer_pending(&ll_capa_timer)) { mod_timer(&ll_capa_timer, expiry); DEBUG_CAPA(D_SEC, &ocapa->c_capa, @@ -80,7 +80,7 @@ static inline void update_capa_timer(struct obd_capa *ocapa, cfs_time_t expiry) } } -static inline cfs_time_t capa_renewal_time(struct obd_capa *ocapa) +static inline unsigned long capa_renewal_time(struct obd_capa *ocapa) { return cfs_time_sub(ocapa->c_expiry, cfs_time_seconds(ocapa->c_capa.lc_timeout) / 2); @@ -88,7 +88,7 @@ static inline cfs_time_t capa_renewal_time(struct obd_capa *ocapa) static inline int capa_is_to_expire(struct obd_capa *ocapa) { - return cfs_time_beforeq(capa_renewal_time(ocapa), cfs_time_current()); + return time_before_eq(capa_renewal_time(ocapa), cfs_time_current()); } static inline int have_expired_capa(void) @@ -359,7 +359,7 @@ struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc) ocapa = NULL; if (atomic_read(&ll_capa_debug)) { - CERROR("no capability for "DFID" opc "LPX64"\n", + CERROR("no capability for "DFID" opc %#llx\n", PFID(&lli->lli_fid), opc); atomic_set(&ll_capa_debug, 0); } @@ -511,7 +511,7 @@ struct obd_capa *ll_add_capa(struct inode *inode, struct obd_capa *ocapa) return ocapa; } -static inline void delay_capa_renew(struct obd_capa *oc, cfs_time_t delay) +static inline void delay_capa_renew(struct obd_capa *oc, unsigned long delay) { /* NB: set a fake expiry for this capa to prevent it renew too soon */ oc->c_expiry = cfs_time_add(oc->c_expiry, cfs_time_seconds(delay)); diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index 38c2d0e947db..6a3a7a303043 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -42,7 +42,7 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <lustre_lite.h> +#include "../include/lustre_lite.h" #include "llite_internal.h" /** records that a write is in flight */ @@ -170,7 +170,7 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, GOTO(out, 0); } } - CDEBUG(D_INODE, "Epoch "LPU64" closed on "DFID"\n", + CDEBUG(D_INODE, "Epoch %llu closed on "DFID"\n", ll_i2info(inode)->lli_ioepoch, PFID(&lli->lli_fid)); op_data->op_flags |= MF_EPOCH_CLOSE; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 140ee947ba49..634ffa645e06 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -36,16 +36,16 @@ #ifndef LLITE_INTERNAL_H #define LLITE_INTERNAL_H -#include <lustre_debug.h> -#include <lustre_ver.h> -#include <lustre_disk.h> /* for s2sbi */ -#include <lustre_eacl.h> +#include "../include/lustre_debug.h" +#include "../include/lustre_ver.h" +#include "../include/lustre_disk.h" /* for s2sbi */ +#include "../include/lustre_eacl.h" /* for struct cl_lock_descr and struct cl_io */ -#include <cl_object.h> -#include <lclient.h> -#include <lustre_mdc.h> -#include <linux/lustre_intent.h> +#include "../include/cl_object.h" +#include "../include/lclient.h" +#include "../include/lustre_mdc.h" +#include "../include/linux/lustre_intent.h" #include <linux/compat.h> #include <linux/posix_acl_xattr.h> @@ -145,7 +145,7 @@ struct ll_inode_info { * capability needs renewal */ atomic_t lli_open_count; struct obd_capa *lli_mds_capa; - cfs_time_t lli_rmtperm_time; + unsigned long lli_rmtperm_time; /* handle is to be sent to MDS later on done_writing and setattr. * Open handle data are needed for the recovery to reconstruct @@ -213,7 +213,7 @@ struct ll_inode_info { struct mutex f_write_mutex; struct rw_semaphore f_glimpse_sem; - cfs_time_t f_glimpse_time; + unsigned long f_glimpse_time; struct list_head f_agl_list; __u64 f_agl_index; @@ -670,7 +670,7 @@ void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar); struct ll_ra_read *ll_ra_read_get(struct file *f); /* llite/lproc_llite.c */ -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) int lprocfs_register_mountpoint(struct proc_dir_entry *parent, struct super_block *sb, char *osc, char *mdc); void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi); @@ -1432,7 +1432,7 @@ static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode, if (it->d.lustre.it_remote_lock_mode) { handle.cookie = it->d.lustre.it_remote_lock_handle; CDEBUG(D_DLMTRACE, "setting l_data to inode %p" - "(%lu/%u) for remote lock "LPX64"\n", inode, + "(%lu/%u) for remote lock %#llx\n", inode, inode->i_ino, inode->i_generation, handle.cookie); md_set_lock_data(exp, &handle.cookie, inode, NULL); @@ -1441,7 +1441,7 @@ static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode, handle.cookie = it->d.lustre.it_lock_handle; CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)" - " for lock "LPX64"\n", inode, inode->i_ino, + " for lock %#llx\n", inode, inode->i_ino, inode->i_generation, handle.cookie); md_set_lock_data(exp, &handle.cookie, inode, diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index deca27ea33fe..0367f5a2cfe4 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -44,15 +44,15 @@ #include <linux/types.h> #include <linux/mm.h> -#include <lustre_lite.h> -#include <lustre_ha.h> -#include <lustre_dlm.h> -#include <lprocfs_status.h> -#include <lustre_disk.h> -#include <lustre_param.h> -#include <lustre_log.h> -#include <cl_object.h> -#include <obd_cksum.h> +#include "../include/lustre_lite.h" +#include "../include/lustre_ha.h" +#include "../include/lustre_dlm.h" +#include "../include/lprocfs_status.h" +#include "../include/lustre_disk.h" +#include "../include/lustre_param.h" +#include "../include/lustre_log.h" +#include "../include/cl_object.h" +#include "../include/obd_cksum.h" #include "llite_internal.h" struct kmem_cache *ll_file_data_slab; @@ -152,7 +152,7 @@ static void ll_free_sbi(struct super_block *sb) static int client_common_fill_super(struct super_block *sb, char *md, char *dt, struct vfsmount *mnt) { - struct inode *root = 0; + struct inode *root = NULL; struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; struct obd_capa *oc = NULL; @@ -426,7 +426,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (sbi->ll_flags & LL_SBI_RMT_CLIENT) data->ocd_connect_flags |= OBD_CONNECT_RMT_CLIENT_FORCE; - CDEBUG(D_RPCTRACE, "ocd_connect_flags: "LPX64" ocd_version: %d " + CDEBUG(D_RPCTRACE, "ocd_connect_flags: %#llx ocd_version: %d " "ocd_grant: %d\n", data->ocd_connect_flags, data->ocd_version, data->ocd_grant); @@ -1296,7 +1296,7 @@ static int ll_setattr_done_writing(struct inode *inode, if (!S_ISREG(inode->i_mode)) return 0; - CDEBUG(D_INODE, "Epoch "LPU64" closed on "DFID" for truncate\n", + CDEBUG(D_INODE, "Epoch %llu closed on "DFID" for truncate\n", op_data->op_ioepoch, PFID(&lli->lli_fid)); op_data->op_flags = MF_EPOCH_CLOSE; @@ -1377,7 +1377,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) * OST maximum object size and number of stripes. This * needs another check in addition to the VFS check above. */ if (attr->ia_size > ll_file_maxbytes(inode)) { - CDEBUG(D_INODE,"file "DFID" too large %llu > "LPU64"\n", + CDEBUG(D_INODE,"file "DFID" too large %llu > %llu\n", PFID(&lli->lli_fid), attr->ia_size, ll_file_maxbytes(inode)); return -EFBIG; @@ -1412,7 +1412,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME)) CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n", LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime), - cfs_time_current_sec()); + get_seconds()); /* If we are changing file size, file content is modified, flag it. */ if (attr->ia_valid & ATTR_SIZE) { @@ -1537,12 +1537,14 @@ int ll_setattr(struct dentry *de, struct iattr *attr) !(attr->ia_mode & S_ISGID)))) attr->ia_valid |= ATTR_FORCE; - if ((mode & S_ISUID) && + if ((attr->ia_valid & ATTR_MODE) && + (mode & S_ISUID) && !(attr->ia_mode & S_ISUID) && !(attr->ia_valid & ATTR_KILL_SUID)) attr->ia_valid |= ATTR_KILL_SUID; - if (((mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP)) && + if ((attr->ia_valid & ATTR_MODE) && + ((mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP)) && !(attr->ia_mode & S_ISGID) && !(attr->ia_valid & ATTR_KILL_SGID)) attr->ia_valid |= ATTR_KILL_SGID; @@ -1565,7 +1567,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, osfs->os_type = sb->s_magic; - CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n", + CDEBUG(D_SUPER, "MDC blocks %llu/%llu objects %llu/%llu\n", osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files); if (sbi->ll_flags & LL_SBI_LAZYSTATFS) @@ -1577,7 +1579,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, return rc; } - CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n", + CDEBUG(D_SUPER, "OSC blocks %llu/%llu objects %llu/%llu\n", obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree, obd_osfs.os_files); @@ -1604,7 +1606,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs) struct obd_statfs osfs; int rc; - CDEBUG(D_VFSTRACE, "VFS Op: at "LPU64" jiffies\n", get_jiffies_64()); + CDEBUG(D_VFSTRACE, "VFS Op: at %llu jiffies\n", get_jiffies_64()); ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_STAFS, 1); /* Some amount of caching on the client is allowed */ @@ -1697,9 +1699,9 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) } if (body->valid & OBD_MD_FLMTIME) { if (body->mtime > LTIME_S(inode->i_mtime)) { - CDEBUG(D_INODE, "setting ino %lu mtime from %lu " - "to "LPU64"\n", inode->i_ino, - LTIME_S(inode->i_mtime), body->mtime); + CDEBUG(D_INODE, "setting ino %lu mtime from %lu to %llu\n", + inode->i_ino, LTIME_S(inode->i_mtime), + body->mtime); LTIME_S(inode->i_mtime) = body->mtime; } lli->lli_lvb.lvb_mtime = body->mtime; @@ -1997,7 +1999,7 @@ void ll_umount_begin(struct super_block *sb) obd = class_exp2obd(sbi->ll_md_exp); if (obd == NULL) { - CERROR("Invalid MDC connection handle "LPX64"\n", + CERROR("Invalid MDC connection handle %#llx\n", sbi->ll_md_exp->exp_handle.h_cookie); return; } @@ -2005,7 +2007,7 @@ void ll_umount_begin(struct super_block *sb) obd = class_exp2obd(sbi->ll_dt_exp); if (obd == NULL) { - CERROR("Invalid LOV connection handle "LPX64"\n", + CERROR("Invalid LOV connection handle %#llx\n", sbi->ll_dt_exp->exp_handle.h_cookie); return; } @@ -2245,7 +2247,7 @@ struct md_op_data * ll_prep_md_op_data(struct md_op_data *op_data, op_data->op_name = name; op_data->op_namelen = namelen; op_data->op_mode = mode; - op_data->op_mod_time = cfs_time_current_sec(); + op_data->op_mod_time = get_seconds(); op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid()); op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid()); op_data->op_cap = cfs_curproc_cap_pack(); diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index 426c73961665..7dae610f5c86 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -47,9 +47,9 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <lustre_lite.h> +#include "../include/lustre_lite.h" #include "llite_internal.h" -#include <linux/lustre_compat25.h> +#include "../include/linux/lustre_compat25.h" static const struct vm_operations_struct ll_file_vm_ops; @@ -449,7 +449,7 @@ int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last) { int rc = -ENOENT; - LASSERTF(last > first, "last "LPU64" first "LPU64"\n", last, first); + LASSERTF(last > first, "last %llu first %llu\n", last, first); if (mapping_mapped(mapping)) { rc = 0; unmap_mapping_range(mapping, first + PAGE_CACHE_SIZE - 1, diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index a614b913ddc2..8fdd6e093d1a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -42,7 +42,7 @@ */ #define DEBUG_SUBSYSTEM S_LLITE -#include <lustre_lite.h> +#include "../include/lustre_lite.h" #include "llite_internal.h" #include <linux/exportfs.h> diff --git a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c index 4c610369cb9b..be0c3eff108c 100644 --- a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c +++ b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c @@ -44,8 +44,8 @@ #ifdef CONFIG_FS_POSIX_ACL -#include <lustre_lite.h> -#include <lustre_eacl.h> +#include "../include/lustre_lite.h" +#include "../include/lustre_eacl.h" #include "llite_internal.h" static inline __u32 rce_hashfunc(uid_t id) diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 0ff8c3362a8d..808663898b73 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -103,8 +103,8 @@ #include <asm/uaccess.h> -#include <lustre_lib.h> -#include <lustre_lite.h> +#include "../include/lustre_lib.h" +#include "../include/lustre_lite.h" #include "llite_internal.h" #define LLOOP_MAX_SEGMENTS LNET_MAX_IOV diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 77ee9e58cf87..77f68b507fea 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -35,10 +35,10 @@ */ #define DEBUG_SUBSYSTEM S_LLITE -#include <lustre_lite.h> -#include <lprocfs_status.h> +#include "../include/lustre_lite.h" +#include "../include/lprocfs_status.h" #include <linux/seq_file.h> -#include <obd_support.h> +#include "../include/obd_support.h" #include "llite_internal.h" #include "vvp_internal.h" @@ -82,7 +82,7 @@ static int ll_kbytestotal_seq_show(struct seq_file *m, void *v) while (blk_size >>= 1) result <<= 1; - rc = seq_printf(m, LPU64"\n", result); + rc = seq_printf(m, "%llu\n", result); } return rc; } @@ -105,7 +105,7 @@ static int ll_kbytesfree_seq_show(struct seq_file *m, void *v) while (blk_size >>= 1) result <<= 1; - rc = seq_printf(m, LPU64"\n", result); + rc = seq_printf(m, "%llu\n", result); } return rc; } @@ -128,7 +128,7 @@ static int ll_kbytesavail_seq_show(struct seq_file *m, void *v) while (blk_size >>= 1) result <<= 1; - rc = seq_printf(m, LPU64"\n", result); + rc = seq_printf(m, "%llu\n", result); } return rc; } @@ -145,7 +145,7 @@ static int ll_filestotal_seq_show(struct seq_file *m, void *v) cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - rc = seq_printf(m, LPU64"\n", osfs.os_files); + rc = seq_printf(m, "%llu\n", osfs.os_files); return rc; } LPROC_SEQ_FOPS_RO(ll_filestotal); @@ -161,7 +161,7 @@ static int ll_filesfree_seq_show(struct seq_file *m, void *v) cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - rc = seq_printf(m, LPU64"\n", osfs.os_ffree); + rc = seq_printf(m, "%llu\n", osfs.os_ffree); return rc; } LPROC_SEQ_FOPS_RO(ll_filesfree); @@ -811,38 +811,39 @@ static ssize_t ll_xattr_cache_seq_write(struct file *file, const char *buffer, LPROC_SEQ_FOPS(ll_xattr_cache); static struct lprocfs_vars lprocfs_llite_obd_vars[] = { - { "uuid", &ll_sb_uuid_fops, 0, 0 }, + { "uuid", &ll_sb_uuid_fops, NULL, 0 }, //{ "mntpt_path", ll_rd_path, 0, 0 }, - { "fstype", &ll_fstype_fops, 0, 0 }, - { "site", &ll_site_stats_fops, 0, 0 }, - { "blocksize", &ll_blksize_fops, 0, 0 }, - { "kbytestotal", &ll_kbytestotal_fops, 0, 0 }, - { "kbytesfree", &ll_kbytesfree_fops, 0, 0 }, - { "kbytesavail", &ll_kbytesavail_fops, 0, 0 }, - { "filestotal", &ll_filestotal_fops, 0, 0 }, - { "filesfree", &ll_filesfree_fops, 0, 0 }, - { "client_type", &ll_client_type_fops, 0, 0 }, + { "fstype", &ll_fstype_fops, NULL, 0 }, + { "site", &ll_site_stats_fops, NULL, 0 }, + { "blocksize", &ll_blksize_fops, NULL, 0 }, + { "kbytestotal", &ll_kbytestotal_fops, NULL, 0 }, + { "kbytesfree", &ll_kbytesfree_fops, NULL, 0 }, + { "kbytesavail", &ll_kbytesavail_fops, NULL, 0 }, + { "filestotal", &ll_filestotal_fops, NULL, 0 }, + { "filesfree", &ll_filesfree_fops, NULL, 0 }, + { "client_type", &ll_client_type_fops, NULL, 0 }, //{ "filegroups", lprocfs_rd_filegroups, 0, 0 }, - { "max_read_ahead_mb", &ll_max_readahead_mb_fops, 0 }, - { "max_read_ahead_per_file_mb", &ll_max_readahead_per_file_mb_fops, 0 }, - { "max_read_ahead_whole_mb", &ll_max_read_ahead_whole_mb_fops, 0 }, - { "max_cached_mb", &ll_max_cached_mb_fops, 0 }, - { "checksum_pages", &ll_checksum_fops, 0 }, - { "max_rw_chunk", &ll_max_rw_chunk_fops, 0 }, - { "stats_track_pid", &ll_track_pid_fops, 0 }, - { "stats_track_ppid", &ll_track_ppid_fops, 0 }, - { "stats_track_gid", &ll_track_gid_fops, 0 }, - { "statahead_max", &ll_statahead_max_fops, 0 }, - { "statahead_agl", &ll_statahead_agl_fops, 0 }, - { "statahead_stats", &ll_statahead_stats_fops, 0, 0 }, - { "lazystatfs", &ll_lazystatfs_fops, 0 }, - { "max_easize", &ll_max_easize_fops, 0, 0 }, - { "default_easize", &ll_defult_easize_fops, 0, 0 }, - { "max_cookiesize", &ll_max_cookiesize_fops, 0, 0 }, - { "default_cookiesize", &ll_defult_cookiesize_fops, 0, 0 }, - { "sbi_flags", &ll_sbi_flags_fops, 0, 0 }, - { "xattr_cache", &ll_xattr_cache_fops, 0, 0 }, - { 0 } + { "max_read_ahead_mb", &ll_max_readahead_mb_fops, NULL }, + { "max_read_ahead_per_file_mb", &ll_max_readahead_per_file_mb_fops, + NULL }, + { "max_read_ahead_whole_mb", &ll_max_read_ahead_whole_mb_fops, NULL }, + { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, + { "checksum_pages", &ll_checksum_fops, NULL }, + { "max_rw_chunk", &ll_max_rw_chunk_fops, NULL }, + { "stats_track_pid", &ll_track_pid_fops, NULL }, + { "stats_track_ppid", &ll_track_ppid_fops, NULL }, + { "stats_track_gid", &ll_track_gid_fops, NULL }, + { "statahead_max", &ll_statahead_max_fops, NULL }, + { "statahead_agl", &ll_statahead_agl_fops, NULL }, + { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, + { "lazystatfs", &ll_lazystatfs_fops, NULL }, + { "max_easize", &ll_max_easize_fops, NULL, 0 }, + { "default_easize", &ll_defult_easize_fops, NULL, 0 }, + { "max_cookiesize", &ll_max_cookiesize_fops, NULL, 0 }, + { "default_cookiesize", &ll_defult_cookiesize_fops, NULL, 0 }, + { "sbi_flags", &ll_sbi_flags_fops, NULL, 0 }, + { "xattr_cache", &ll_xattr_cache_fops, NULL, 0 }, + { NULL } }; #define MAX_STRING_SIZE 128 @@ -909,7 +910,7 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) sbi->ll_stats_track_id == current->pid) lprocfs_counter_add(sbi->ll_stats, op, count); else if (sbi->ll_stats_track_type == STATS_TRACK_PPID && - sbi->ll_stats_track_id == current->parent->pid) + sbi->ll_stats_track_id == current->real_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 == diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index dfa1e745dfd6..0dc7173bbd41 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -44,11 +44,11 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <obd_support.h> -#include <lustre_fid.h> -#include <lustre_lite.h> -#include <lustre_dlm.h> -#include <lustre_ver.h> +#include "../include/obd_support.h" +#include "../include/lustre_fid.h" +#include "../include/lustre_lite.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_ver.h" #include "llite_internal.h" static int ll_create_it(struct inode *, struct dentry *, @@ -105,7 +105,7 @@ static int ll_set_inode(struct inode *inode, void *opaque) lli->lli_fid = body->fid1; if (unlikely(!(body->valid & OBD_MD_FLTYPE))) { CERROR("Can not initialize inode "DFID" without object type: " - "valid = "LPX64"\n", PFID(&lli->lli_fid), body->valid); + "valid = %#llx\n", PFID(&lli->lli_fid), body->valid); return -EINVAL; } @@ -758,7 +758,7 @@ static void ll_update_times(struct ptlrpc_request *request, LASSERT(body); if (body->valid & OBD_MD_FLMTIME && body->mtime > LTIME_S(inode->i_mtime)) { - CDEBUG(D_INODE, "setting ino %lu mtime from %lu to "LPU64"\n", + CDEBUG(D_INODE, "setting ino %lu mtime from %lu to %llu\n", inode->i_ino, LTIME_S(inode->i_mtime), body->mtime); LTIME_S(inode->i_mtime) = body->mtime; } diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c index a8b1117b8f60..f61fefc9baf0 100644 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ b/drivers/staging/lustre/lustre/llite/remote_perm.c @@ -46,12 +46,12 @@ #include <linux/module.h> #include <linux/types.h> -#include <lustre_lite.h> -#include <lustre_ha.h> -#include <lustre_dlm.h> -#include <lprocfs_status.h> -#include <lustre_disk.h> -#include <lustre_param.h> +#include "../include/lustre_lite.h" +#include "../include/lustre_ha.h" +#include "../include/lustre_dlm.h" +#include "../include/lprocfs_status.h" +#include "../include/lustre_disk.h" +#include "../include/lustre_param.h" #include "llite_internal.h" struct kmem_cache *ll_remote_perm_cachep = NULL; @@ -249,7 +249,7 @@ int lustre_check_remote_perm(struct inode *inode, int mask) struct ptlrpc_request *req = NULL; struct mdt_remote_perm *perm; struct obd_capa *oc; - cfs_time_t save; + unsigned long save; int i = 0, rc; do { diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index 56162103cc79..ecd7a229cf9b 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -54,10 +54,10 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <lustre_lite.h> -#include <obd_cksum.h> +#include "../include/lustre_lite.h" +#include "../include/obd_cksum.h" #include "llite_internal.h" -#include <linux/lustre_compat25.h> +#include "../include/linux/lustre_compat25.h" /** * Finalizes cl-data before exiting typical address_space operation. Dual to @@ -496,14 +496,9 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, struct cl_object *clob = ll_i2info(mapping->host)->lli_clob; struct cl_page *page; enum ra_stat which = _NR_RA_STAT; /* keep gcc happy */ - unsigned int gfp_mask; int rc = 0; const char *msg = NULL; - gfp_mask = GFP_HIGHUSER & ~__GFP_WAIT; -#ifdef __GFP_NOWARN - gfp_mask |= __GFP_NOWARN; -#endif vmpage = grab_cache_page_nowait(mapping, index); if (vmpage != NULL) { /* Check if vmpage was truncated or reclaimed */ @@ -601,7 +596,7 @@ stride_pg_count(pgoff_t st_off, unsigned long st_len, unsigned long st_pgs, if (end_left > st_pgs) end_left = st_pgs; - CDEBUG(D_READA, "start "LPU64", end "LPU64" start_left %lu end_left %lu \n", + CDEBUG(D_READA, "start %llu, end %llu start_left %lu end_left %lu \n", start, end, start_left, end_left); if (start == end) @@ -1013,7 +1008,7 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, kms_pages = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; - CDEBUG(D_READA, "kmsp "LPU64" mwp %lu mp %lu\n", kms_pages, + CDEBUG(D_READA, "kmsp %llu mwp %lu mp %lu\n", kms_pages, ra->ra_max_read_ahead_whole_pages, ra->ra_max_pages_per_file); if (kms_pages && diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index af84c1aaa5f8..3f157e76a15c 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -55,9 +55,9 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <lustre_lite.h> +#include "../include/lustre_lite.h" #include "llite_internal.h" -#include <linux/lustre_compat25.h> +#include "../include/linux/lustre_compat25.h" /** * Implements Linux VM address_space::invalidatepage() method. This method is diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 1b47774d7447..c39cf8d47d6e 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -42,9 +42,9 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <obd_support.h> -#include <lustre_lite.h> -#include <lustre_dlm.h> +#include "../include/obd_support.h" +#include "../include/lustre_lite.h" +#include "../include/lustre_dlm.h" #include "llite_internal.h" #define SA_OMITTED_ENTRY_MAX 8ULL @@ -206,7 +206,7 @@ ll_sa_entry_alloc(struct ll_statahead_info *sai, __u64 index, if (unlikely(entry == NULL)) return ERR_PTR(-ENOMEM); - CDEBUG(D_READA, "alloc sa entry %.*s(%p) index "LPU64"\n", + CDEBUG(D_READA, "alloc sa entry %.*s(%p) index %llu\n", len, name, entry, index); entry->se_index = index; @@ -325,7 +325,7 @@ static void ll_sa_entry_put(struct ll_statahead_info *sai, struct ll_sa_entry *entry) { if (atomic_dec_and_test(&entry->se_refcount)) { - CDEBUG(D_READA, "free sa entry %.*s(%p) index "LPU64"\n", + CDEBUG(D_READA, "free sa entry %.*s(%p) index %llu\n", entry->se_qstr.len, entry->se_qstr.name, entry, entry->se_index); @@ -528,8 +528,8 @@ static void ll_sai_put(struct ll_statahead_info *sai) spin_unlock(&lli->lli_sa_lock); if (sai->sai_sent > sai->sai_replied) - CDEBUG(D_READA,"statahead for dir "DFID" does not " - "finish: [sent:"LPU64"] [replied:"LPU64"]\n", + CDEBUG(D_READA,"statahead for dir "DFID + " does not finish: [sent:%llu] [replied:%llu]\n", PFID(&lli->lli_fid), sai->sai_sent, sai->sai_replied); @@ -587,7 +587,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) * affect the performance. */ if (lli->lli_glimpse_time != 0 && - cfs_time_before(cfs_time_shift(-1), lli->lli_glimpse_time)) { + time_before(cfs_time_shift(-1), lli->lli_glimpse_time)) { up_write(&lli->lli_glimpse_sem); lli->lli_agl_index = 0; iput(inode); @@ -595,7 +595,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) } CDEBUG(D_READA, "Handling (init) async glimpse: inode = " - DFID", idx = "LPU64"\n", PFID(&lli->lli_fid), index); + DFID", idx = %llu\n", PFID(&lli->lli_fid), index); cl_agl(inode); lli->lli_agl_index = 0; @@ -603,7 +603,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) up_write(&lli->lli_glimpse_sem); CDEBUG(D_READA, "Handled (init) async glimpse: inode= " - DFID", idx = "LPU64", rc = %d\n", + DFID", idx = %llu, rc = %d\n", PFID(&lli->lli_fid), index, rc); iput(inode); @@ -1081,8 +1081,7 @@ static int ll_statahead_thread(void *arg) if (IS_ERR(page)) { rc = PTR_ERR(page); - CDEBUG(D_READA, "error reading dir "DFID" at "LPU64 - "/"LPU64": [rc %d] [parent %u]\n", + CDEBUG(D_READA, "error reading dir "DFID" at %llu/%llu: [rc %d] [parent %u]\n", PFID(ll_inode2fid(dir)), pos, sai->sai_index, rc, plli->lli_opendir_pid); GOTO(out, rc); @@ -1362,8 +1361,7 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry) struct ll_inode_info *lli = ll_i2info(dir); rc = PTR_ERR(page); - CERROR("error reading dir "DFID" at "LPU64": " - "[rc %d] [parent %u]\n", + CERROR("error reading dir "DFID" at %llu: [rc %d] [parent %u]\n", PFID(ll_inode2fid(dir)), pos, rc, lli->lli_opendir_pid); break; @@ -1479,8 +1477,8 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry) if (sa_low_hit(sai) && thread_is_running(thread)) { atomic_inc(&sbi->ll_sa_wrong); CDEBUG(D_READA, "Statahead for dir "DFID" hit " - "ratio too low: hit/miss "LPU64"/"LPU64 - ", sent/replied "LPU64"/"LPU64", stopping " + "ratio too low: hit/miss %llu/%llu" + ", sent/replied %llu/%llu, stopping " "statahead thread\n", PFID(&lli->lli_fid), sai->sai_hit, sai->sai_miss, sai->sai_sent, diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 951fdb1265b9..078c0e95f4cf 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -38,12 +38,12 @@ #include <linux/module.h> #include <linux/types.h> -#include <lustre_lite.h> -#include <lustre_ha.h> -#include <lustre_dlm.h> +#include "../include/lustre_lite.h" +#include "../include/lustre_ha.h" +#include "../include/lustre_dlm.h" #include <linux/init.h> #include <linux/fs.h> -#include <lprocfs_status.h> +#include "../include/lprocfs_status.h" #include "llite_internal.h" static struct kmem_cache *ll_inode_cachep; diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index 129d3023dcea..20e678b31c7b 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -39,7 +39,7 @@ #include <linux/stat.h> #define DEBUG_SUBSYSTEM S_LLITE -#include <lustre_lite.h> +#include "../include/lustre_lite.h" #include "llite_internal.h" static int ll_readlink_internal(struct inode *inode, diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index 0f68c16abe30..0f2e79d6b7f8 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -41,8 +41,8 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <obd.h> -#include <lustre_lite.h> +#include "../include/obd.h" +#include "../include/lustre_lite.h" #include "llite_internal.h" #include "vvp_internal.h" diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h index 3c9a03d99559..2162bf6c08a7 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h @@ -40,7 +40,7 @@ #define VVP_INTERNAL_H -#include <cl_object.h> +#include "../include/cl_object.h" #include "llite_internal.h" int vvp_io_init (const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 0e0b404cb5e6..a4117d6a3866 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -42,8 +42,8 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <obd.h> -#include <lustre_lite.h> +#include "../include/obd.h" +#include "../include/lustre_lite.h" #include "vvp_internal.h" @@ -269,8 +269,10 @@ static int vvp_mmap_locks(const struct lu_env *env, descr->cld_mode, descr->cld_start, descr->cld_end); - if (result < 0) + if (result < 0) { + up_read(&mm->mmap_sem); return result; + } if (vma->vm_end - addr >= count) break; @@ -622,7 +624,7 @@ static int vvp_io_kernel_fault(struct vvp_fault_io *cfio) page_private(vmf->page), vmf->virtual_address); if (unlikely(!(cfio->fault.ft_flags & VM_FAULT_LOCKED))) { lock_page(vmf->page); - cfio->fault.ft_flags &= VM_FAULT_LOCKED; + cfio->fault.ft_flags |= VM_FAULT_LOCKED; } cfio->ft_vmpage = vmf->page; diff --git a/drivers/staging/lustre/lustre/llite/vvp_lock.c b/drivers/staging/lustre/lustre/llite/vvp_lock.c index e16b31e4ff72..372633e164b9 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_lock.c +++ b/drivers/staging/lustre/lustre/llite/vvp_lock.c @@ -39,8 +39,8 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <obd.h> -#include <lustre_lite.h> +#include "../include/obd.h" +#include "../include/lustre_lite.h" #include "vvp_internal.h" diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c index 65b6db1b71b4..b6f6d4cb6e41 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_object.c +++ b/drivers/staging/lustre/lustre/llite/vvp_object.c @@ -41,10 +41,10 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd.h> -#include <lustre_lite.h> +#include "../include/obd.h" +#include "../include/lustre_lite.h" #include "vvp_internal.h" diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index 1c02c128e0ee..4626346f6ee1 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c @@ -42,8 +42,8 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <obd.h> -#include <lustre_lite.h> +#include "../include/obd.h" +#include "../include/lustre_lite.h" #include "vvp_internal.h" diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index c6c27bbb43b4..665ca572027f 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -41,11 +41,11 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include <obd_support.h> -#include <lustre_lite.h> -#include <lustre_dlm.h> -#include <lustre_ver.h> -#include <lustre_eacl.h> +#include "../include/obd_support.h" +#include "../include/lustre_lite.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_ver.h" +#include "../include/lustre_eacl.h" #include "llite_internal.h" @@ -246,6 +246,7 @@ int ll_setxattr(struct dentry *dentry, const char *name, int lum_size = (lump->lmm_magic == LOV_USER_MAGIC_V1) ? sizeof(*lump) : sizeof(struct lov_user_md_v3); + memset(&f, 0, sizeof(f)); /* f.f_flags is used below */ f.f_dentry = dentry; rc = ll_lov_setstripe_ea_info(inode, &f, flags, lump, lum_size); diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index 4dd83fc03687..edec945d2eb3 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -10,10 +10,10 @@ #include <linux/fs.h> #include <linux/sched.h> #include <linux/mm.h> -#include <obd_support.h> -#include <lustre_lite.h> -#include <lustre_dlm.h> -#include <lustre_ver.h> +#include "../include/obd_support.h" +#include "../include/lustre_lite.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_ver.h" #include "llite_internal.h" /* If we ever have hundreds of extended attributes, we might want to consider diff --git a/drivers/staging/lustre/lustre/lmv/Makefile b/drivers/staging/lustre/lustre/lmv/Makefile index 9162ef724aea..a7a15369af15 100644 --- a/drivers/staging/lustre/lustre/lmv/Makefile +++ b/drivers/staging/lustre/lustre/lmv/Makefile @@ -1,5 +1,3 @@ obj-$(CONFIG_LUSTRE_FS) += lmv.o lmv-y := lmv_obd.o lmv_intent.o lmv_fld.o lmv-$(CONFIG_PROC_FS) += lproc_lmv.o - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/lmv/lmv_fld.c b/drivers/staging/lustre/lustre/lmv/lmv_fld.c index fd6b5ec61d8a..8289bcc5f8e1 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_fld.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_fld.c @@ -41,14 +41,14 @@ #include <asm/div64.h> #include <linux/seq_file.h> -#include <obd_support.h> -#include <lustre/lustre_idl.h> -#include <lustre_fid.h> -#include <lustre_lib.h> -#include <lustre_net.h> -#include <lustre_dlm.h> -#include <obd_class.h> -#include <lprocfs_status.h> +#include "../include/obd_support.h" +#include "../include/lustre/lustre_idl.h" +#include "../include/lustre_fid.h" +#include "../include/lustre_lib.h" +#include "../include/lustre_net.h" +#include "../include/lustre_dlm.h" +#include "../include/obd_class.h" +#include "../include/lprocfs_status.h" #include "lmv_internal.h" int lmv_fld_lookup(struct lmv_obd *lmv, @@ -66,8 +66,8 @@ int lmv_fld_lookup(struct lmv_obd *lmv, rc = fld_client_lookup(&lmv->lmv_fld, fid_seq(fid), mds, LU_SEQ_RANGE_MDT, NULL); if (rc) { - CERROR("Error while looking for mds number. Seq "LPX64 - ", err = %d\n", fid_seq(fid), rc); + CERROR("Error while looking for mds number. Seq %#llx, err = %d\n", + fid_seq(fid), rc); return rc; } diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index 9ba5a0a57390..aba698f4489c 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -41,15 +41,14 @@ #include <asm/div64.h> #include <linux/seq_file.h> #include <linux/namei.h> -#include <linux/lustre_intent.h> - -#include <obd_support.h> -#include <lustre/lustre_idl.h> -#include <lustre_lib.h> -#include <lustre_net.h> -#include <lustre_dlm.h> -#include <obd_class.h> -#include <lprocfs_status.h> +#include "../include/linux/lustre_intent.h" +#include "../include/obd_support.h" +#include "../include/lustre/lustre_idl.h" +#include "../include/lustre_lib.h" +#include "../include/lustre_net.h" +#include "../include/lustre_dlm.h" +#include "../include/obd_class.h" +#include "../include/lprocfs_status.h" #include "lmv_internal.h" static int lmv_intent_remote(struct obd_export *exp, void *lmm, diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index f75b0a987681..eb18a5900e13 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -37,8 +37,8 @@ #ifndef _LMV_INTERNAL_H_ #define _LMV_INTERNAL_H_ -#include <lustre/lustre_idl.h> -#include <obd.h> +#include "../include/lustre/lustre_idl.h" +#include "../include/obd.h" #define LMV_MAX_TGT_COUNT 128 @@ -146,7 +146,7 @@ struct lmv_tgt_desc *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data, struct lu_fid *fid); /* lproc_lmv.c */ -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars); #else static inline void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 4edf8a31221c..a66b3e000d57 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -45,14 +45,14 @@ #include <linux/namei.h> #include <asm/uaccess.h> -#include <lustre/lustre_idl.h> -#include <obd_support.h> -#include <lustre_lib.h> -#include <lustre_net.h> -#include <obd_class.h> -#include <lprocfs_status.h> -#include <lustre_lite.h> -#include <lustre_fid.h> +#include "../include/lustre/lustre_idl.h" +#include "../include/obd_support.h" +#include "../include/lustre_lib.h" +#include "../include/lustre_net.h" +#include "../include/obd_class.h" +#include "../include/lprocfs_status.h" +#include "../include/lustre_lite.h" +#include "../include/lustre_fid.h" #include "lmv_internal.h" static void lmv_activate_target(struct lmv_obd *lmv, @@ -90,7 +90,7 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, if (tgt == NULL || tgt->ltd_exp == NULL) continue; - CDEBUG(D_INFO, "Target idx %d is %s conn "LPX64"\n", i, + CDEBUG(D_INFO, "Target idx %d is %s conn %#llx\n", i, tgt->ltd_uuid.uuid, tgt->ltd_exp->exp_handle.h_cookie); if (obd_uuid_equals(uuid, &tgt->ltd_uuid)) @@ -735,7 +735,7 @@ repeat_fid2path: *ptr = '/'; } - CDEBUG(D_INFO, "%s: get path %s "DFID" rec: "LPU64" ln: %u\n", + CDEBUG(D_INFO, "%s: get path %s "DFID" rec: %llu ln: %u\n", tgt->ltd_exp->exp_obd->obd_name, gf->gf_path, PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno); @@ -1339,7 +1339,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lprocfs_lmv_init_vars(&lvars); lprocfs_obd_setup(obd, lvars.obd_vars); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) { rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd", 0444, &lmv_proc_target_fops, obd); @@ -1715,7 +1715,7 @@ static int lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, struct lookup_intent *it, struct md_op_data *op_data, struct lustre_handle *lockh, void *lmm, int lmmsize, - int extra_lock_flags) + __u64 extra_lock_flags) { struct ptlrpc_request *req = it->d.lustre.it_data; struct obd_device *obd = exp->exp_obd; @@ -2173,7 +2173,7 @@ static int lmv_readpage(struct obd_export *exp, struct md_op_data *op_data, if (rc) return rc; - CDEBUG(D_INODE, "READPAGE at "LPX64" from "DFID"\n", + CDEBUG(D_INODE, "READPAGE at %#llx from "DFID"\n", offset, PFID(&op_data->op_fid1)); tgt = lmv_find_target(lmv, &op_data->op_fid1); @@ -2315,7 +2315,7 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, obd = class_exp2obd(exp); if (obd == NULL) { - CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n", + CDEBUG(D_IOCTL, "Invalid client cookie %#llx\n", exp->exp_handle.h_cookie); return -EINVAL; } @@ -2381,7 +2381,7 @@ int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, obd = class_exp2obd(exp); if (obd == NULL) { - CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n", + CDEBUG(D_IOCTL, "Invalid client cookie %#llx\n", exp->exp_handle.h_cookie); return -EINVAL; } diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index ae73c82ce499..310df44f948d 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -38,8 +38,8 @@ #include <linux/seq_file.h> #include <asm/statfs.h> -#include <lprocfs_status.h> -#include <obd_class.h> +#include "../include/lprocfs_status.h" +#include "../include/obd_class.h" static int lmv_numobd_seq_show(struct seq_file *m, void *v) { diff --git a/drivers/staging/lustre/lustre/lov/Makefile b/drivers/staging/lustre/lustre/lov/Makefile index a908edb533d3..6fe56a24b165 100644 --- a/drivers/staging/lustre/lustre/lov/Makefile +++ b/drivers/staging/lustre/lustre/lov/Makefile @@ -4,7 +4,3 @@ lov-y := lov_obd.o lov_pack.o lov_offset.o lov_merge.o \ lov_lock.o lov_io.o lovsub_dev.o lovsub_object.o lovsub_page.o \ lovsub_lock.o lovsub_io.o lov_pool.o lov-$(CONFIG_PROC_FS) += lproc_lov.o - - - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h index 3965d5e4e725..99ade92c5e64 100644 --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h @@ -46,10 +46,10 @@ #ifndef LOV_CL_INTERNAL_H #define LOV_CL_INTERNAL_H -# include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd.h> -#include <cl_object.h> +#include "../include/obd.h" +#include "../include/cl_object.h" #include "lov_internal.h" /** \defgroup lov lov diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index 53e5781ba1d9..796a015d070c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -41,7 +41,7 @@ #define DEBUG_SUBSYSTEM S_LOV /* class_name2obd() */ -#include <obd_class.h> +#include "../include/obd_class.h" #include "lov_cl_internal.h" #include "lov_internal.h" @@ -453,7 +453,7 @@ static int lov_process_config(const struct lu_env *env, case LCFG_LOV_ADD_INA: rc = lov_cl_add_target(env, d, index); if (rc != 0) - lov_del_target(d->ld_obd, index, 0, 0); + lov_del_target(d->ld_obd, index, NULL, 0); break; case LCFG_LOV_DEL_OBD: lov_cl_del_target(env, d, index); diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index a0c148e31f69..2401ca872507 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -41,10 +41,10 @@ #define DEBUG_SUBSYSTEM S_LOV #include <asm/div64.h> -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd_class.h> -#include <lustre/lustre_idl.h> +#include "../include/obd_class.h" +#include "../include/lustre/lustre_idl.h" #include "lov_internal.h" @@ -348,7 +348,7 @@ const struct lsm_operations lsm_v3_ops = { void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm) { - CDEBUG(level, "lsm %p, objid "DOSTID", maxbytes "LPX64", magic 0x%08X," + CDEBUG(level, "lsm %p, objid "DOSTID", maxbytes %#llx, magic 0x%08X," " stripe_size %u, stripe_count %u, refc: %d," " layout_gen %u, pool ["LOV_POOLNAMEF"]\n", lsm, POSTID(&lsm->lsm_oi), lsm->lsm_maxbytes, lsm->lsm_magic, diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index 38508a5c827f..017961a5cc3e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -37,8 +37,8 @@ #ifndef LOV_INTERNAL_H #define LOV_INTERNAL_H -#include <obd_class.h> -#include <lustre/lustre_user.h> +#include "../include/obd_class.h" +#include "../include/lustre/lustre_user.h" /* lov_do_div64(a, b) returns a % b, and a = a / b. * The 32-bit code is LOV-specific due to knowing about stripe limits in @@ -252,7 +252,7 @@ int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo, ldlm_policy_data_t *policy, __u32 mode, struct lustre_handle *lockh, struct lov_request_set **reqset); -int lov_fini_match_set(struct lov_request_set *set, __u32 mode, int flags); +int lov_fini_match_set(struct lov_request_set *set, __u32 mode, __u64 flags); int lov_prep_cancel_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_stripe_md *lsm, __u32 mode, struct lustre_handle *lockh, @@ -310,7 +310,7 @@ void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm); int lovea_destroy_object(struct lov_obd *lov, struct lov_stripe_md *lsm, struct obdo *oa, void *data); /* lproc_lov.c */ -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) extern const struct file_operations lov_proc_target_fops; void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars); #else diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index 65133ea308b6..ce074c54a003 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -398,7 +398,7 @@ static int lov_io_iter_init(const struct lu_env *env, start, end); rc = cl_io_iter_init(sub->sub_env, sub->sub_io); lov_sub_put(sub); - CDEBUG(D_VFSTRACE, "shrink: %d ["LPU64", "LPU64")\n", + CDEBUG(D_VFSTRACE, "shrink: %d [%llu, %llu)\n", stripe, start, end); } else rc = PTR_ERR(sub); @@ -436,8 +436,8 @@ static int lov_io_rw_iter_init(const struct lu_env *env, next) - io->u.ci_rw.crw_pos; lio->lis_pos = io->u.ci_rw.crw_pos; lio->lis_endpos = io->u.ci_rw.crw_pos + io->u.ci_rw.crw_count; - CDEBUG(D_VFSTRACE, "stripe: "LPU64" chunk: ["LPU64", "LPU64") " - LPU64"\n", (__u64)start, lio->lis_pos, lio->lis_endpos, + CDEBUG(D_VFSTRACE, "stripe: %llu chunk: [%llu, %llu) %llu\n", + (__u64)start, lio->lis_pos, lio->lis_endpos, (__u64)lio->lis_io_endpos); } /* diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c b/drivers/staging/lustre/lustre/lov/lov_merge.c index da959e901371..85144b8da96d 100644 --- a/drivers/staging/lustre/lustre/lov/lov_merge.c +++ b/drivers/staging/lustre/lustre/lov/lov_merge.c @@ -36,9 +36,9 @@ #define DEBUG_SUBSYSTEM S_LOV -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd_class.h> +#include "../include/obd_class.h" #include "lov_internal.h" /** Merge the lock value block(&lvb) attributes and KMS from each of the @@ -61,10 +61,9 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, assert_spin_locked(&lsm->lsm_lock); LASSERT(lsm->lsm_lock_owner == current_pid()); - CDEBUG(D_INODE, "MDT ID "DOSTID" initial value: s="LPU64" m="LPU64 - " a="LPU64" c="LPU64" b="LPU64"\n", POSTID(&lsm->lsm_oi), - lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, - lvb->lvb_blocks); + CDEBUG(D_INODE, "MDT ID "DOSTID" initial value: s=%llu m=%llu a=%llu c=%llu b=%llu\n", + POSTID(&lsm->lsm_oi), lvb->lvb_size, lvb->lvb_mtime, + lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); for (i = 0; i < lsm->lsm_stripe_count; i++) { struct lov_oinfo *loi = lsm->lsm_oinfo[i]; obd_size lov_size, tmpsize; @@ -94,11 +93,11 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, if (loi->loi_lvb.lvb_ctime > current_ctime) current_ctime = loi->loi_lvb.lvb_ctime; - CDEBUG(D_INODE, "MDT ID "DOSTID" on OST[%u]: s="LPU64" m="LPU64 - " a="LPU64" c="LPU64" b="LPU64"\n", POSTID(&lsm->lsm_oi), - loi->loi_ost_idx, loi->loi_lvb.lvb_size, - loi->loi_lvb.lvb_mtime, loi->loi_lvb.lvb_atime, - loi->loi_lvb.lvb_ctime, loi->loi_lvb.lvb_blocks); + CDEBUG(D_INODE, "MDT ID "DOSTID" on OST[%u]: s=%llu m=%llu a=%llu c=%llu b=%llu\n", + POSTID(&lsm->lsm_oi), loi->loi_ost_idx, + loi->loi_lvb.lvb_size, loi->loi_lvb.lvb_mtime, + loi->loi_lvb.lvb_atime, loi->loi_lvb.lvb_ctime, + loi->loi_lvb.lvb_blocks); } *kms_place = kms; @@ -131,9 +130,9 @@ int lov_merge_lvb(struct obd_export *exp, if (kms_only) lvb->lvb_size = kms; - CDEBUG(D_INODE, "merged for ID "DOSTID" s="LPU64" m="LPU64" a="LPU64 - " c="LPU64" b="LPU64"\n", POSTID(&lsm->lsm_oi), lvb->lvb_size, - lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); + CDEBUG(D_INODE, "merged for ID "DOSTID" s=%llu m=%llu a=%llu c=%llu b=%llu\n", + POSTID(&lsm->lsm_oi), lvb->lvb_size, lvb->lvb_mtime, + lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); return rc; } @@ -153,7 +152,7 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, struct lov_oinfo *loi = lsm->lsm_oinfo[stripe]; kms = lov_size_to_stripe(lsm, size, stripe); CDEBUG(D_INODE, - "stripe %d KMS %sing "LPU64"->"LPU64"\n", + "stripe %d KMS %sing %llu->%llu\n", stripe, kms > loi->loi_kms ? "increase":"shrink", loi->loi_kms, kms); loi_kms_set(loi, loi->loi_lvb.lvb_size = kms); @@ -166,7 +165,7 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, kms = lov_size_to_stripe(lsm, size, stripe); loi = lsm->lsm_oinfo[stripe]; - CDEBUG(D_INODE, "stripe %d KMS %sincreasing "LPU64"->"LPU64"\n", + CDEBUG(D_INODE, "stripe %d KMS %sincreasing %llu->%llu\n", stripe, kms > loi->loi_kms ? "" : "not ", loi->loi_kms, kms); if (kms > loi->loi_kms) loi_kms_set(loi, kms); diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 2d843b1c1ded..e4f4fe3f71c7 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -42,22 +42,22 @@ */ #define DEBUG_SUBSYSTEM S_LOV -#include <linux/libcfs/libcfs.h> - -#include <obd_support.h> -#include <lustre_lib.h> -#include <lustre_net.h> -#include <lustre/lustre_idl.h> -#include <lustre_dlm.h> -#include <lustre_mds.h> -#include <obd_class.h> -#include <obd_ost.h> -#include <lprocfs_status.h> -#include <lustre_param.h> -#include <cl_object.h> -#include <lclient.h> /* for cl_client_lru */ -#include <lustre/ll_fiemap.h> -#include <lustre_fid.h> +#include "../../include/linux/libcfs/libcfs.h" + +#include "../include/obd_support.h" +#include "../include/lustre_lib.h" +#include "../include/lustre_net.h" +#include "../include/lustre/lustre_idl.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_mds.h" +#include "../include/obd_class.h" +#include "../include/obd_ost.h" +#include "../include/lprocfs_status.h" +#include "../include/lustre_param.h" +#include "../include/cl_object.h" +#include "../include/lclient.h" /* for cl_client_lru */ +#include "../include/lustre/ll_fiemap.h" +#include "../include/lustre_fid.h" #include "lov_internal.h" @@ -382,7 +382,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, if (!tgt->ltd_exp) continue; - CDEBUG(D_INFO, "lov idx %d is %s conn "LPX64"\n", + CDEBUG(D_INFO, "lov idx %d is %s conn %#llx\n", index, obd_uuid2str(&tgt->ltd_uuid), tgt->ltd_exp->exp_handle.h_cookie); if (obd_uuid_equals(uuid, &tgt->ltd_uuid)) @@ -727,8 +727,7 @@ void lov_fix_desc_stripe_size(__u64 *val) *val = LOV_DESC_STRIPE_SIZE_DEFAULT; } else if (*val & (LOV_MIN_STRIPE_SIZE - 1)) { *val &= ~(LOV_MIN_STRIPE_SIZE - 1); - LCONSOLE_WARN("Changing default stripe size to "LPU64" (a " - "multiple of %u)\n", + LCONSOLE_WARN("Changing default stripe size to %llu (a multiple of %u)\n", *val, LOV_MIN_STRIPE_SIZE); } } @@ -821,7 +820,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lprocfs_lov_init_vars(&lvars); lprocfs_obd_setup(obd, lvars.obd_vars); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) { int rc1; @@ -900,7 +899,7 @@ static int lov_cleanup(struct obd_device *obd) " deathrow=%d, lovrc=%d\n", i, lov->lov_death_row, atomic_read(&lov->lov_refcount)); - lov_del_target(obd, i, 0, 0); + lov_del_target(obd, i, NULL, 0); } obd_putref(obd); OBD_FREE(lov->lov_tgts, sizeof(*lov->lov_tgts) * @@ -944,7 +943,7 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, GOTO(out, rc); } case LCFG_PARAM: { - struct lprocfs_static_vars lvars = { 0 }; + struct lprocfs_static_vars lvars = { NULL }; struct lov_desc *desc = &(obd->u.lov.desc); if (!desc) @@ -1463,7 +1462,7 @@ static int lov_sync(const struct lu_env *env, struct obd_export *exp, if (rc) return rc; - CDEBUG(D_INFO, "fsync objid "DOSTID" ["LPX64", "LPX64"]\n", + CDEBUG(D_INFO, "fsync objid "DOSTID" [%#llx, %#llx]\n", POSTID(&set->set_oi->oi_oa->o_oi), start, end); list_for_each(pos, &set->set_list) { @@ -2636,9 +2635,8 @@ static int lov_extent_calc(struct obd_export *exp, struct lov_stripe_md *lsm, lov_do_div64(start, ssize); start = start * ssize; - CDEBUG(D_DLMTRACE, "offset "LPU64", stripe %u, start "LPU64 - ", end "LPU64"\n", *offset, ssize, start, - start + ssize - 1); + CDEBUG(D_DLMTRACE, "offset %llu, stripe %u, start %llu, end %llu\n", + *offset, ssize, start, start + ssize - 1); if (cmd == OBD_CALC_STRIPE_END) { *offset = start + ssize - 1; } else if (cmd == OBD_CALC_STRIPE_START) { @@ -2818,7 +2816,7 @@ struct kmem_cache *lov_oinfo_slab; int __init lov_init(void) { - struct lprocfs_static_vars lvars = { 0 }; + struct lprocfs_static_vars lvars = { NULL }; int rc; /* print an address of _any_ initialized kernel symbol from this diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c index 379568f8245c..8e1c3bacc0a0 100644 --- a/drivers/staging/lustre/lustre/lov/lov_offset.c +++ b/drivers/staging/lustre/lustre/lov/lov_offset.c @@ -36,9 +36,9 @@ #define DEBUG_SUBSYSTEM S_LOV -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd_class.h> +#include "../include/obd_class.h" #include "lov_internal.h" @@ -223,7 +223,7 @@ int lov_stripe_intersects(struct lov_stripe_md *lsm, int stripeno, start_side = lov_stripe_offset(lsm, start, stripeno, obd_start); end_side = lov_stripe_offset(lsm, end, stripeno, obd_end); - CDEBUG(D_INODE, "["LPU64"->"LPU64"] -> [(%d) "LPU64"->"LPU64" (%d)]\n", + CDEBUG(D_INODE, "[%llu->%llu] -> [(%d) %llu->%llu (%d)]\n", start, end, start_side, *obd_start, *obd_end, end_side); /* this stripe doesn't intersect the file extent when neither diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 59ab7c30ffbf..a5b190f32c0f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -42,11 +42,11 @@ #define DEBUG_SUBSYSTEM S_LOV -#include <lustre_net.h> -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre/lustre_user.h> +#include "../include/lustre_net.h" +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/lustre/lustre_user.h" #include "lov_internal.h" @@ -555,7 +555,7 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp, return rc; if (ostid_id(&lmm_objects[i].l_ost_oi) > last_id) { CERROR("Setting EA for object > than last id on" - " ost idx %d "DOSTID" > "LPD64" \n", + " ost idx %d "DOSTID" > %lld \n", lmm_objects[i].l_ost_idx, POSTID(&lmm_objects[i].l_ost_oi), last_id); return -EINVAL; diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index 3bda0c1f3c19..91b3509a8083 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -44,9 +44,9 @@ #define DEBUG_SUBSYSTEM S_LOV -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd.h> +#include "../include/obd.h" #include "lov_internal.h" #define pool_tgt(_p, _i) \ @@ -152,7 +152,7 @@ cfs_hash_ops_t pool_hash_operations = { }; -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) /* ifdef needed for liblustre support */ /* * pool /proc seq_file methods @@ -294,7 +294,7 @@ static struct file_operations pool_proc_operations = { .llseek = seq_lseek, .release = seq_release, }; -#endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS */ void lov_dump_pool(int level, struct pool_desc *pool) { @@ -452,7 +452,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname) INIT_HLIST_NODE(&new_pool->pool_hash); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) /* we need this assert seq_file is not implemented for liblustre */ /* get ref for /proc file */ lov_pool_getref(new_pool); diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index bd6490d0129c..e4bb02a54b0d 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -36,11 +36,11 @@ #define DEBUG_SUBSYSTEM S_LOV -#include <linux/libcfs/libcfs.h> - -#include <obd_class.h> -#include <lustre/lustre_idl.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/obd_class.h" +#include "../include/obd_ost.h" +#include "../include/lustre/lustre_idl.h" #include "lov_internal.h" static void lov_init_set(struct lov_request_set *set) @@ -140,16 +140,16 @@ void lov_set_add_req(struct lov_request *req, struct lov_request_set *set) static int lov_check_set(struct lov_obd *lov, int idx) { - int rc = 0; - mutex_lock(&lov->lov_lock); - - if (lov->lov_tgts[idx] == NULL || - lov->lov_tgts[idx]->ltd_active || - (lov->lov_tgts[idx]->ltd_exp != NULL && - class_exp2cliimp(lov->lov_tgts[idx]->ltd_exp)->imp_connect_tried)) - rc = 1; + int rc; + struct lov_tgt_desc *tgt; + mutex_lock(&lov->lov_lock); + tgt = lov->lov_tgts[idx]; + rc = !tgt || tgt->ltd_active || + (tgt->ltd_exp && + class_exp2cliimp(tgt->ltd_exp)->imp_connect_tried); mutex_unlock(&lov->lov_lock); + return rc; } @@ -194,13 +194,9 @@ out: return rc; } -extern void osc_update_enqueue(struct lustre_handle *lov_lockhp, - struct lov_oinfo *loi, int flags, - struct ost_lvb *lvb, __u32 mode, int rc); - static int lov_update_enqueue_lov(struct obd_export *exp, struct lustre_handle *lov_lockhp, - struct lov_oinfo *loi, int flags, int idx, + struct lov_oinfo *loi, __u64 flags, int idx, struct ost_id *oi, int rc) { struct lov_obd *lov = &exp->exp_obd->u.lov; @@ -443,7 +439,7 @@ out_set: return rc; } -int lov_fini_match_set(struct lov_request_set *set, __u32 mode, int flags) +int lov_fini_match_set(struct lov_request_set *set, __u32 mode, __u64 flags) { int rc = 0; @@ -482,7 +478,7 @@ int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo, GOTO(out_set, rc = -ENOMEM); lockh->cookie = set->set_lockh->llh_handle.h_cookie; - for (i = 0; i < lsm->lsm_stripe_count; i++){ + for (i = 0; i < lsm->lsm_stripe_count; i++) { struct lov_oinfo *loi; struct lov_request *req; obd_off start, end; @@ -570,7 +566,7 @@ int lov_prep_cancel_set(struct obd_export *exp, struct obd_info *oinfo, } lockh->cookie = set->set_lockh->llh_handle.h_cookie; - for (i = 0; i < lsm->lsm_stripe_count; i++){ + for (i = 0; i < lsm->lsm_stripe_count; i++) { struct lov_request *req; struct lustre_handle *lov_lockhp; struct lov_oinfo *loi = lsm->lsm_oinfo[i]; @@ -738,7 +734,7 @@ int lov_prep_brw_set(struct obd_export *exp, struct obd_info *oinfo, /* alloc and initialize lov request */ shift = 0; - for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++){ + for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) { struct lov_oinfo *loi = NULL; struct lov_request *req; @@ -840,6 +836,7 @@ static int cb_getattr_update(void *cookie, int rc) { struct obd_info *oinfo = cookie; struct lov_request *lovreq; + lovreq = container_of(oinfo, struct lov_request, rq_oi); return lov_update_common_set(lovreq->rq_rqset, lovreq, rc); } @@ -1022,6 +1019,7 @@ static int cb_setattr_update(void *cookie, int rc) { struct obd_info *oinfo = cookie; struct lov_request *lovreq; + lovreq = container_of(oinfo, struct lov_request, rq_oi); return lov_update_setattr_set(lovreq->rq_rqset, lovreq, rc); } @@ -1080,7 +1078,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, if (off < 0 && req->rq_oi.oi_oa->o_size) req->rq_oi.oi_oa->o_size--; - CDEBUG(D_INODE, "stripe %d has size "LPU64"/"LPU64"\n", + CDEBUG(D_INODE, "stripe %d has size %llu/%llu\n", i, req->rq_oi.oi_oa->o_size, oinfo->oi_oa->o_size); } @@ -1145,6 +1143,7 @@ static int cb_update_punch(void *cookie, int rc) { struct obd_info *oinfo = cookie; struct lov_request *lovreq; + lovreq = container_of(oinfo, struct lov_request, rq_oi); return lov_update_punch_set(lovreq->rq_rqset, lovreq, rc); } diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index bd7da56b0713..c993f25fb303 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -36,8 +36,8 @@ #define DEBUG_SUBSYSTEM S_CLASS #include <asm/statfs.h> -#include <lprocfs_status.h> -#include <obd_class.h> +#include "../include/lprocfs_status.h" +#include "../include/obd_class.h" #include <linux/seq_file.h> #include "lov_internal.h" @@ -48,7 +48,7 @@ static int lov_stripesize_seq_show(struct seq_file *m, void *v) LASSERT(dev != NULL); desc = &dev->u.lov.desc; - return seq_printf(m, LPU64"\n", desc->ld_default_stripe_size); + return seq_printf(m, "%llu\n", desc->ld_default_stripe_size); } static ssize_t lov_stripesize_seq_write(struct file *file, const char *buffer, @@ -78,7 +78,7 @@ static int lov_stripeoffset_seq_show(struct seq_file *m, void *v) LASSERT(dev != NULL); desc = &dev->u.lov.desc; - return seq_printf(m, LPU64"\n", desc->ld_default_stripe_offset); + return seq_printf(m, "%llu\n", desc->ld_default_stripe_offset); } static ssize_t lov_stripeoffset_seq_write(struct file *file, const char *buffer, diff --git a/drivers/staging/lustre/lustre/lvfs/Makefile b/drivers/staging/lustre/lustre/lvfs/Makefile index e0367c3fc416..387eee307e2d 100644 --- a/drivers/staging/lustre/lustre/lvfs/Makefile +++ b/drivers/staging/lustre/lustre/lvfs/Makefile @@ -2,6 +2,3 @@ obj-$(CONFIG_LUSTRE_FS) += lvfs.o lvfs-y := lvfs_linux.o fsfilt.o lvfs-$(CONFIG_PROC_FS) += lvfs_lib.o - - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/lvfs/fsfilt.c b/drivers/staging/lustre/lustre/lvfs/fsfilt.c index 0d6ed69ddb22..a4df056a2853 100644 --- a/drivers/staging/lustre/lustre/lvfs/fsfilt.c +++ b/drivers/staging/lustre/lustre/lvfs/fsfilt.c @@ -38,8 +38,8 @@ #include <linux/module.h> #include <linux/kmod.h> #include <linux/slab.h> -#include <linux/libcfs/libcfs.h> -#include <lustre_fsfilt.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/lustre_fsfilt.h" LIST_HEAD(fsfilt_types); diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_lib.c b/drivers/staging/lustre/lustre/lvfs/lvfs_lib.c index 7e47fc4a7e4e..cfc4f896b127 100644 --- a/drivers/staging/lustre/lustre/lvfs/lvfs_lib.c +++ b/drivers/staging/lustre/lustre/lvfs/lvfs_lib.c @@ -40,8 +40,8 @@ * Author: Andreas Dilger <adilger@clusterfs.com> */ #include <linux/module.h> -#include <lustre_lib.h> -#include <lprocfs_status.h> +#include "../include/lustre_lib.h" +#include "../include/lprocfs_status.h" void lprocfs_counter_add(struct lprocfs_stats *stats, int idx, long amount) { diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c index 374a9b78e1d2..eea0b2c94ba9 100644 --- a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c +++ b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c @@ -45,13 +45,13 @@ #include <linux/slab.h> #include <linux/pagemap.h> #include <linux/quotaops.h> -#include <linux/libcfs/libcfs.h> #include <linux/module.h> -#include <linux/lustre_compat25.h> -#include <lvfs.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/linux/lustre_compat25.h" +#include "../include/lvfs.h" -#include <obd.h> -#include <lustre_lib.h> +#include "../include/obd.h" +#include "../include/lustre_lib.h" struct lprocfs_stats *obd_memory = NULL; EXPORT_SYMBOL(obd_memory); @@ -233,8 +233,8 @@ put_old: EXPORT_SYMBOL(lustre_rename); /* Note: dput(dchild) will *not* be called if there is an error */ -struct l_file *l_dentry_open(struct lvfs_run_ctxt *ctxt, struct l_dentry *de, - int flags) +struct file *l_dentry_open(struct lvfs_run_ctxt *ctxt, struct dentry *de, + int flags) { struct path path = { .dentry = de, @@ -244,7 +244,7 @@ struct l_file *l_dentry_open(struct lvfs_run_ctxt *ctxt, struct l_dentry *de, } EXPORT_SYMBOL(l_dentry_open); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) __s64 lprocfs_read_helper(struct lprocfs_counter *lc, struct lprocfs_counter_header *header, enum lprocfs_stats_flags flags, @@ -286,7 +286,7 @@ __s64 lprocfs_read_helper(struct lprocfs_counter *lc, return ret; } EXPORT_SYMBOL(lprocfs_read_helper); -#endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS*/ MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); MODULE_DESCRIPTION("Lustre VFS Filesystem Helper v0.1"); diff --git a/drivers/staging/lustre/lustre/mdc/Makefile b/drivers/staging/lustre/lustre/mdc/Makefile index 4c0bed14de80..2516551a6dc3 100644 --- a/drivers/staging/lustre/lustre/mdc/Makefile +++ b/drivers/staging/lustre/lustre/mdc/Makefile @@ -1,6 +1,3 @@ obj-$(CONFIG_LUSTRE_FS) += mdc.o mdc-y := mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o mdc-$(CONFIG_PROC_FS) += lproc_mdc.o - - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 2663480a68c5..d1d891b91663 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -36,8 +36,8 @@ #define DEBUG_SUBSYSTEM S_CLASS #include <linux/vfs.h> -#include <obd_class.h> -#include <lprocfs_status.h> +#include "../include/obd_class.h" +#include "../include/lprocfs_status.h" static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v) { @@ -172,39 +172,39 @@ LPROC_SEQ_FOPS_RW_TYPE(mdc, import); LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov); static struct lprocfs_vars lprocfs_mdc_obd_vars[] = { - { "uuid", &mdc_uuid_fops, 0, 0 }, - { "ping", &mdc_ping_fops, 0, 0222 }, - { "connect_flags", &mdc_connect_flags_fops, 0, 0 }, - { "blocksize", &mdc_blksize_fops, 0, 0 }, - { "kbytestotal", &mdc_kbytestotal_fops, 0, 0 }, - { "kbytesfree", &mdc_kbytesfree_fops, 0, 0 }, - { "kbytesavail", &mdc_kbytesavail_fops, 0, 0 }, - { "filestotal", &mdc_filestotal_fops, 0, 0 }, - { "filesfree", &mdc_filesfree_fops, 0, 0 }, - /*{ "filegroups", lprocfs_rd_filegroups, 0, 0 },*/ - { "mds_server_uuid", &mdc_server_uuid_fops, 0, 0 }, - { "mds_conn_uuid", &mdc_conn_uuid_fops, 0, 0 }, + { "uuid", &mdc_uuid_fops, NULL, 0 }, + { "ping", &mdc_ping_fops, NULL, 0222 }, + { "connect_flags", &mdc_connect_flags_fops, NULL, 0 }, + { "blocksize", &mdc_blksize_fops, NULL, 0 }, + { "kbytestotal", &mdc_kbytestotal_fops, NULL, 0 }, + { "kbytesfree", &mdc_kbytesfree_fops, NULL, 0 }, + { "kbytesavail", &mdc_kbytesavail_fops, NULL, 0 }, + { "filestotal", &mdc_filestotal_fops, NULL, 0 }, + { "filesfree", &mdc_filesfree_fops, NULL, 0 }, + /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ + { "mds_server_uuid", &mdc_server_uuid_fops, NULL, 0 }, + { "mds_conn_uuid", &mdc_conn_uuid_fops, NULL, 0 }, /* * FIXME: below proc entry is provided, but not in used, instead * sbi->sb_md_brw_size is used, the per obd variable should be used * when CMD is enabled, and dir pages are managed in MDC layer. * Remember to enable proc write function. */ - { "max_pages_per_rpc", &mdc_obd_max_pages_per_rpc_fops, 0, 0 }, - { "max_rpcs_in_flight", &mdc_max_rpcs_in_flight_fops, 0, 0 }, - { "timeouts", &mdc_timeouts_fops, 0, 0 }, - { "import", &mdc_import_fops, 0 }, - { "state", &mdc_state_fops, 0, 0 }, - { "hsm_nl", &mdc_kuc_fops, 0, 0200 }, - { "pinger_recov", &mdc_pinger_recov_fops, 0, 0 }, - { 0 } + { "max_pages_per_rpc", &mdc_obd_max_pages_per_rpc_fops, NULL, 0 }, + { "max_rpcs_in_flight", &mdc_max_rpcs_in_flight_fops, NULL, 0 }, + { "timeouts", &mdc_timeouts_fops, NULL, 0 }, + { "import", &mdc_import_fops, NULL, 0 }, + { "state", &mdc_state_fops, NULL, 0 }, + { "hsm_nl", &mdc_kuc_fops, NULL, 0200 }, + { "pinger_recov", &mdc_pinger_recov_fops, NULL, 0 }, + { NULL } }; LPROC_SEQ_FOPS_RO_TYPE(mdc, numrefs); static struct lprocfs_vars lprocfs_mdc_module_vars[] = { - { "num_refs", &mdc_numrefs_fops, 0, 0 }, - { 0 } + { "num_refs", &mdc_numrefs_fops, NULL, 0 }, + { NULL } }; void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index c78bf003c2c5..e8235559e27f 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -37,10 +37,10 @@ #ifndef _MDC_INTERNAL_H #define _MDC_INTERNAL_H -#include <lustre_mdc.h> -#include <lustre_mds.h> +#include "../include/lustre_mdc.h" +#include "../include/lustre_mds.h" -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars); #else static inline void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index 5b9f37141512..f54dd90c7e50 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -35,8 +35,8 @@ */ #define DEBUG_SUBSYSTEM S_MDC -#include <lustre_net.h> -#include <lustre/lustre_idl.h> +#include "../include/lustre_net.h" +#include "../include/lustre/lustre_idl.h" #include "mdc_internal.h" diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 1a8cd98ad6d7..71219b90e22b 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -38,14 +38,14 @@ # include <linux/module.h> -#include <linux/lustre_intent.h> -#include <obd.h> -#include <obd_class.h> -#include <lustre_dlm.h> -#include <lustre_fid.h> /* fid_res_name_eq() */ -#include <lustre_mdc.h> -#include <lustre_net.h> -#include <lustre_req_layout.h> +#include "../include/linux/lustre_intent.h" +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_fid.h" /* fid_res_name_eq() */ +#include "../include/lustre_mdc.h" +#include "../include/lustre_net.h" +#include "../include/lustre_req_layout.h" #include "mdc_internal.h" struct mdc_getattr_args { @@ -860,7 +860,7 @@ resend: if (resends) { req->rq_generation_set = 1; req->rq_import_generation = generation; - req->rq_sent = cfs_time_current_sec() + resends; + req->rq_sent = get_seconds() + resends; } /* It is important to obtain rpc_lock first (if applicable), so that diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index 08e80940ee4d..c5420a42bc33 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -39,9 +39,9 @@ # include <linux/module.h> # include <linux/kernel.h> -#include <obd_class.h> +#include "../include/obd_class.h" #include "mdc_internal.h" -#include <lustre_fid.h> +#include "../include/lustre_fid.h" /* mdc_setattr does its own semaphore handling */ static int mdc_reint(struct ptlrpc_request *request, @@ -273,7 +273,7 @@ rebuild: if (resends) { req->rq_generation_set = 1; req->rq_import_generation = generation; - req->rq_sent = cfs_time_current_sec() + resends; + req->rq_sent = get_seconds() + resends; } level = LUSTRE_IMP_FULL; resend: diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index fca43cf1d671..4a1cc4eb73d5 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -42,12 +42,12 @@ # include <linux/init.h> # include <linux/utsname.h> -#include <lustre_acl.h> -#include <obd_class.h> -#include <lustre_fid.h> -#include <lprocfs_status.h> -#include <lustre_param.h> -#include <lustre_log.h> +#include "../include/lustre_acl.h" +#include "../include/obd_class.h" +#include "../include/lustre_fid.h" +#include "../include/lprocfs_status.h" +#include "../include/lustre_param.h" +#include "../include/lustre_log.h" #include "mdc_internal.h" @@ -136,7 +136,7 @@ static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid, *rootfid = body->fid1; CDEBUG(D_NET, - "root fid="DFID", last_committed="LPU64"\n", + "root fid="DFID", last_committed=%llu\n", PFID(rootfid), lustre_msg_get_last_committed(req->rq_repmsg)); out: @@ -397,7 +397,7 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, rec->sx_suppgid2 = -1; rec->sx_fid = *fid; rec->sx_valid = valid | OBD_MD_FLCTIME; - rec->sx_time = cfs_time_current_sec(); + rec->sx_time = get_seconds(); rec->sx_size = output_size; rec->sx_flags = flags; @@ -670,7 +670,7 @@ void mdc_replay_open(struct ptlrpc_request *req) LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC); file_fh = &och->och_fh; - CDEBUG(D_HA, "updating handle from "LPX64" to "LPX64"\n", + CDEBUG(D_HA, "updating handle from %#llx to %#llx\n", file_fh->cookie, body->handle.cookie); old = *file_fh; *file_fh = body->handle; @@ -1182,7 +1182,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH)); memcpy(key + cfs_size_round(sizeof(KEY_FID2PATH)), gf, sizeof(*gf)); - CDEBUG(D_IOCTL, "path get "DFID" from "LPU64" #%d\n", + CDEBUG(D_IOCTL, "path get "DFID" from %llu #%d\n", PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno); if (!fid_is_sane(&gf->gf_fid)) @@ -1200,7 +1200,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) else if (vallen > sizeof(*gf) + gf->gf_pathlen) GOTO(out, rc = -EOVERFLOW); - CDEBUG(D_IOCTL, "path get "DFID" from "LPU64" #%d\n%s\n", + CDEBUG(D_IOCTL, "path get "DFID" from %llu #%d\n%s\n", PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path); out: @@ -1515,12 +1515,12 @@ static int changelog_kkuc_cb(const struct lu_env *env, struct llog_handle *llh, if (rec->cr.cr_index < cs->cs_startrec) { /* Skip entries earlier than what we are interested in */ - CDEBUG(D_CHANGELOG, "rec="LPU64" start="LPU64"\n", + CDEBUG(D_CHANGELOG, "rec=%llu start=%llu\n", rec->cr.cr_index, cs->cs_startrec); return 0; } - CDEBUG(D_CHANGELOG, LPU64" %02d%-5s "LPU64" 0x%x t="DFID" p="DFID + CDEBUG(D_CHANGELOG, "%llu %02d%-5s %llu 0x%x t="DFID" p="DFID " %.*s\n", rec->cr.cr_index, rec->cr.cr_type, changelog_type2str(rec->cr.cr_type), rec->cr.cr_time, rec->cr.cr_flags & CLF_FLAGMASK, @@ -1547,7 +1547,7 @@ static int mdc_changelog_send_thread(void *csdata) struct kuc_hdr *kuch; int rc; - CDEBUG(D_CHANGELOG, "changelog to fp=%p start "LPU64"\n", + CDEBUG(D_CHANGELOG, "changelog to fp=%p start %llu\n", cs->cs_fp, cs->cs_startrec); OBD_ALLOC(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE); @@ -2423,7 +2423,7 @@ struct ldlm_valblock_ops inode_lvbo = { static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) { struct client_obd *cli = &obd->u.cli; - struct lprocfs_static_vars lvars = { 0 }; + struct lprocfs_static_vars lvars = { NULL }; int rc; OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock)); @@ -2566,7 +2566,7 @@ static int mdc_llog_finish(struct obd_device *obd, int count) static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf) { struct lustre_cfg *lcfg = buf; - struct lprocfs_static_vars lvars = { 0 }; + struct lprocfs_static_vars lvars = { NULL }; int rc = 0; lprocfs_mdc_init_vars(&lvars); @@ -2737,7 +2737,7 @@ struct md_ops mdc_md_ops = { int __init mdc_init(void) { int rc; - struct lprocfs_static_vars lvars = { 0 }; + struct lprocfs_static_vars lvars = { NULL }; lprocfs_mdc_init_vars(&lvars); rc = class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars, diff --git a/drivers/staging/lustre/lustre/mgc/Makefile b/drivers/staging/lustre/lustre/mgc/Makefile index 2f5ee649456d..cc6e9f51a8e8 100644 --- a/drivers/staging/lustre/lustre/mgc/Makefile +++ b/drivers/staging/lustre/lustre/mgc/Makefile @@ -1,6 +1,3 @@ obj-$(CONFIG_LUSTRE_FS) += mgc.o mgc-y := mgc_request.o mgc-$(CONFIG_PROC_FS) += lproc_mgc.o - - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/mgc/libmgc.c b/drivers/staging/lustre/lustre/mgc/libmgc.c index 9b40c57d3cd4..8012f0f1bfcd 100644 --- a/drivers/staging/lustre/lustre/mgc/libmgc.c +++ b/drivers/staging/lustre/lustre/mgc/libmgc.c @@ -44,13 +44,13 @@ #define DEBUG_SUBSYSTEM S_MGC -#include <liblustre.h> +#include "../include/liblustre.h" -#include <obd_class.h> -#include <lustre_dlm.h> -#include <lustre_log.h> -#include <lustre_fsfilt.h> -#include <lustre_disk.h> +#include "../include/obd_class.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_log.h" +#include "../include/lustre_fsfilt.h" +#include "../include/lustre_disk.h" static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index 6c877c5a6a71..c4ea38e5f077 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -36,8 +36,8 @@ #define DEBUG_SUBSYSTEM S_CLASS #include <linux/vfs.h> -#include <obd_class.h> -#include <lprocfs_status.h> +#include "../include/obd_class.h" +#include "../include/lprocfs_status.h" #include "mgc_internal.h" LPROC_SEQ_FOPS_RO_TYPE(mgc, uuid); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h index 73b454898844..a6f8b3ced2e7 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h +++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h @@ -37,14 +37,14 @@ #ifndef _MGC_INTERNAL_H #define _MGC_INTERNAL_H -#include <linux/libcfs/libcfs.h> -#include <lustre/lustre_idl.h> -#include <lustre_lib.h> -#include <lustre_dlm.h> -#include <lustre_log.h> -#include <lustre_export.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/lustre/lustre_idl.h" +#include "../include/lustre_lib.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_log.h" +#include "../include/lustre_export.h" -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars); int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data); #else @@ -56,7 +56,7 @@ static inline int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) { return 0; } -#endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS */ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index a806aeffe026..f520591d5784 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -42,12 +42,12 @@ #define D_MGC D_CONFIG /*|D_WARNING*/ #include <linux/module.h> -#include <obd_class.h> -#include <lustre_dlm.h> -#include <lprocfs_status.h> -#include <lustre_log.h> -#include <lustre_disk.h> -#include <dt_object.h> +#include "../include/obd_class.h" +#include "../include/lustre_dlm.h" +#include "../include/lprocfs_status.h" +#include "../include/lustre_log.h" +#include "../include/lustre_disk.h" +#include "../include/dt_object.h" #include "mgc_internal.h" @@ -83,7 +83,7 @@ static int mgc_name2resid(char *name, int len, struct ldlm_res_id *res_id, LBUG(); } res_id->name[1] = cpu_to_le64(resname); - CDEBUG(D_MGC, "log %s to resid "LPX64"/"LPX64" (%.8s)\n", name, + CDEBUG(D_MGC, "log %s to resid %#llx/%#llx (%.8s)\n", name, res_id->name[0], res_id->name[1], (char *)&res_id->name[0]); return 0; } @@ -197,7 +197,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, int rc; CDEBUG(D_MGC, "do adding config log %s:%p\n", logname, - cfg ? cfg->cfg_instance : 0); + cfg ? cfg->cfg_instance : NULL); OBD_ALLOC(cld, sizeof(*cld) + strlen(logname) + 1); if (!cld) @@ -445,7 +445,7 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) return rc; } -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) { struct obd_device *obd = data; @@ -950,7 +950,10 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, } /* Not sure where this should go... */ -#define MGC_ENQUEUE_LIMIT 50 +/* This is the timeout value for MGS_CONNECT request plus a ping interval, such + * that we can have a chance to try the secondary MGS if any. */ +#define MGC_ENQUEUE_LIMIT (INITIAL_CONNECT_TIMEOUT + (AT_OFF ? 0 : at_min) \ + + PING_INTERVAL) #define MGC_TARGET_REG_LIMIT 10 #define MGC_SEND_PARAM_LIMIT 10 @@ -1008,7 +1011,7 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm, int short_limit = cld_is_sptlrpc(cld); int rc; - CDEBUG(D_MGC, "Enqueue for %s (res "LPX64")\n", cld->cld_logname, + CDEBUG(D_MGC, "Enqueue for %s (res %#llx)\n", cld->cld_logname, cld->cld_resid.name[0]); /* We need a callback for every lockholder, so don't try to @@ -1454,7 +1457,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, break; } - CDEBUG(D_INFO, "ir apply logs "LPD64"/"LPD64" for %s -> %s\n", + CDEBUG(D_INFO, "ir apply logs %lld/%lld for %s -> %s\n", prev_version, max_version, obdname, params); rc = class_process_config(lcfg); @@ -1557,7 +1560,7 @@ again: cfg->cfg_last_idx = res->mcr_offset; eof = res->mcr_offset == res->mcr_size; - CDEBUG(D_INFO, "Latest version "LPD64", more %d.\n", + CDEBUG(D_INFO, "Latest version %lld, more %d.\n", res->mcr_offset, eof == false); ealen = sptlrpc_cli_unwrap_bulk_read(req, req->rq_bulk, 0); diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index 8a0e08ced454..ba10043fdd50 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -8,6 +8,3 @@ obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \ mea.o lu_object.o dt_object.o capa.o cl_object.o \ cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o idmap.o \ lu_ucred.o - - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index f0bb632a70aa..3b394a0bff9d 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/drivers/staging/lustre/lustre/obdclass/acl.c @@ -41,10 +41,10 @@ */ #define DEBUG_SUBSYSTEM S_SEC -#include <lu_object.h> -#include <lustre_acl.h> -#include <lustre_eacl.h> -#include <obd_support.h> +#include "../include/lu_object.h" +#include "../include/lustre_acl.h" +#include "../include/lustre_eacl.h" +#include "../include/obd_support.h" #ifdef CONFIG_FS_POSIX_ACL diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c index be1c613383a6..5af61a8c0b85 100644 --- a/drivers/staging/lustre/lustre/obdclass/capa.c +++ b/drivers/staging/lustre/lustre/obdclass/capa.c @@ -48,12 +48,12 @@ #include <linux/module.h> #include <linux/crypto.h> -#include <obd_class.h> -#include <lustre_debug.h> -#include <lustre/lustre_idl.h> +#include "../include/obd_class.h" +#include "../include/lustre_debug.h" +#include "../include/lustre/lustre_idl.h" #include <linux/list.h> -#include <lustre_capa.h> +#include "../include/lustre_capa.h" #define NR_CAPAHASH 32 #define CAPA_HASH_SIZE 3000 /* for MDS & OSS */ @@ -143,9 +143,9 @@ static inline int capa_hashfn(struct lu_fid *fid) * client renew right after obtaining it. */ static inline int capa_is_to_expire(struct obd_capa *oc) { - return cfs_time_before(cfs_time_sub(oc->c_expiry, - cfs_time_seconds(oc->c_capa.lc_timeout)*2/3), - cfs_time_current()); + return time_before(cfs_time_sub(oc->c_expiry, + cfs_time_seconds(oc->c_capa.lc_timeout)*2/3), + cfs_time_current()); } static struct obd_capa *find_capa(struct lustre_capa *capa, @@ -279,6 +279,7 @@ int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key) } keylen = alg->ha_keylen; + sg_init_table(&sl, 1); sg_set_page(&sl, virt_to_page(capa), offsetof(struct lustre_capa, lc_hmac), (unsigned long)(capa) % PAGE_CACHE_SIZE); @@ -320,9 +321,11 @@ int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) GOTO(out, rc); } + sg_init_table(&sd, 1); sg_set_page(&sd, virt_to_page(d), 16, (unsigned long)(d) % PAGE_CACHE_SIZE); + sg_init_table(&ss, 1); sg_set_page(&ss, virt_to_page(s), 16, (unsigned long)(s) % PAGE_CACHE_SIZE); desc.tfm = tfm; @@ -370,9 +373,11 @@ int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) GOTO(out, rc); } + sg_init_table(&sd, 1); sg_set_page(&sd, virt_to_page(d), 16, (unsigned long)(d) % PAGE_CACHE_SIZE); + sg_init_table(&ss, 1); sg_set_page(&ss, virt_to_page(s), 16, (unsigned long)(s) % PAGE_CACHE_SIZE); @@ -406,8 +411,8 @@ void _debug_capa(struct lustre_capa *c, va_list args; va_start(args, fmt); libcfs_debug_vmsg2(msgdata, fmt, args, - " capability@%p fid "DFID" opc "LPX64" uid "LPU64 - " gid "LPU64" flags %u alg %d keyid %u timeout %u " + " capability@%p fid "DFID" opc %#llx uid %llu" + " gid %llu flags %u alg %d keyid %u timeout %u " "expiry %u\n", c, PFID(capa_fid(c)), capa_opc(c), capa_uid(c), capa_gid(c), capa_flags(c), capa_alg(c), capa_keyid(c), capa_timeout(c), diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 3bebc78e7673..6870ee823736 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -40,11 +40,11 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <obd_class.h> -#include <obd_support.h> -#include <lustre_fid.h> +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/lustre_fid.h" #include <linux/list.h> -#include <cl_object.h> +#include "../include/cl_object.h" #include "cl_internal.h" /***************************************************************************** @@ -227,7 +227,7 @@ int cl_io_rw_init(const struct lu_env *env, struct cl_io *io, LINVRNT(io->ci_obj != NULL); LU_OBJECT_HEADER(D_VFSTRACE, env, &io->ci_obj->co_lu, - "io range: %u ["LPU64", "LPU64") %u %u\n", + "io range: %u [%llu, %llu) %u %u\n", iot, (__u64)pos, (__u64)pos + count, io->u.ci_rw.crw_nonblock, io->u.ci_wr.wr_append); io->u.ci_rw.crw_pos = pos; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index df77c4fc0eac..7d99319b714e 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -40,11 +40,11 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <obd_class.h> -#include <obd_support.h> -#include <lustre_fid.h> +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/lustre_fid.h" #include <linux/list.h> -#include <cl_object.h> +#include "../include/cl_object.h" #include "cl_internal.h" /** Lock class of cl_lock::cll_guard */ diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index 41cbc95b916e..ce96bd279111 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -51,14 +51,14 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" /* class_put_type() */ -#include <obd_class.h> -#include <obd_support.h> -#include <lustre_fid.h> +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/lustre_fid.h" #include <linux/list.h> -#include <linux/libcfs/libcfs_hash.h> /* for cfs_hash stuff */ -#include <cl_object.h> +#include "../../include/linux/libcfs/libcfs_hash.h" /* for cfs_hash stuff */ +#include "../include/cl_object.h" #include "cl_internal.h" static struct kmem_cache *cl_env_kmem; @@ -295,8 +295,7 @@ int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, } } LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(top), - "size: "LPU64" mtime: "LPU64" atime: "LPU64" " - "ctime: "LPU64" blocks: "LPU64"\n", + "size: %llu mtime: %llu atime: %llu ctime: %llu blocks: %llu\n", lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); return result; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 1b616e4fe140..b7dd04808060 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -40,12 +40,12 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <linux/libcfs/libcfs.h> -#include <obd_class.h> -#include <obd_support.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/obd_class.h" +#include "../include/obd_support.h" #include <linux/list.h> -#include <cl_object.h> +#include "../include/cl_object.h" #include "cl_internal.h" static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg, diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index dde04b767a6d..8b19f3caa68f 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -37,14 +37,14 @@ #define DEBUG_SUBSYSTEM S_CLASS # include <asm/atomic.h> -#include <obd_support.h> -#include <obd_class.h> -#include <linux/lnet/lnetctl.h> -#include <lustre_debug.h> -#include <lprocfs_status.h> -#include <lustre/lustre_build_version.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../../include/linux/lnet/lnetctl.h" +#include "../include/lustre_debug.h" +#include "../include/lprocfs_status.h" +#include "../include/lustre/lustre_build_version.h" #include <linux/list.h> -#include <cl_object.h> +#include "../include/cl_object.h" #include "llog_internal.h" @@ -141,11 +141,11 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, { if (ptr == NULL || (cfs_rand() & OBD_ALLOC_FAIL_MASK) < obd_alloc_fail_rate) { - CERROR("%s%salloc of %s ("LPU64" bytes) failed at %s:%d\n", + CERROR("%s%salloc of %s (%llu bytes) failed at %s:%d\n", ptr ? "force " :"", type, name, (__u64)size, file, line); - CERROR(LPU64" total bytes and "LPU64" total pages " - "("LPU64" bytes) allocated by Lustre, " + CERROR("%llu total bytes and %llu total pages " + "(%llu bytes) allocated by Lustre, " "%d total bytes by LNET\n", obd_memory_sum(), obd_pages_sum() << PAGE_CACHE_SHIFT, @@ -420,61 +420,61 @@ int obd_init_checks(void) char buf[64]; int len, ret = 0; - CDEBUG(D_INFO, "LPU64=%s, LPD64=%s, LPX64=%s\n", LPU64, LPD64, LPX64); + CDEBUG(D_INFO, "LPU64=%s, LPD64=%s, LPX64=%s\n", "%llu", "%lld", "%#llx"); - CDEBUG(D_INFO, "OBD_OBJECT_EOF = "LPX64"\n", (__u64)OBD_OBJECT_EOF); + CDEBUG(D_INFO, "OBD_OBJECT_EOF = %#llx\n", (__u64)OBD_OBJECT_EOF); u64val = OBD_OBJECT_EOF; - CDEBUG(D_INFO, "u64val OBD_OBJECT_EOF = "LPX64"\n", u64val); + CDEBUG(D_INFO, "u64val OBD_OBJECT_EOF = %#llx\n", u64val); if (u64val != OBD_OBJECT_EOF) { - CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n", + CERROR("__u64 %#llx(%d) != 0xffffffffffffffff\n", u64val, (int)sizeof(u64val)); ret = -EINVAL; } - len = snprintf(buf, sizeof(buf), LPX64, u64val); + len = snprintf(buf, sizeof(buf), "%#llx", u64val); if (len != 18) { CWARN("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len); ret = -EINVAL; } div64val = OBD_OBJECT_EOF; - CDEBUG(D_INFO, "u64val OBD_OBJECT_EOF = "LPX64"\n", u64val); + CDEBUG(D_INFO, "u64val OBD_OBJECT_EOF = %#llx\n", u64val); if (u64val != OBD_OBJECT_EOF) { - CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n", + CERROR("__u64 %#llx(%d) != 0xffffffffffffffff\n", u64val, (int)sizeof(u64val)); ret = -EOVERFLOW; } if (u64val >> 8 != OBD_OBJECT_EOF >> 8) { - CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n", + CERROR("__u64 %#llx(%d) != 0xffffffffffffffff\n", u64val, (int)sizeof(u64val)); return -EOVERFLOW; } if (do_div(div64val, 256) != (u64val & 255)) { - CERROR("do_div("LPX64",256) != "LPU64"\n", u64val, u64val &255); + CERROR("do_div(%#llx,256) != %llu\n", u64val, u64val &255); return -EOVERFLOW; } if (u64val >> 8 != div64val) { - CERROR("do_div("LPX64",256) "LPU64" != "LPU64"\n", + CERROR("do_div(%#llx,256) %llu != %llu\n", u64val, div64val, u64val >> 8); return -EOVERFLOW; } - len = snprintf(buf, sizeof(buf), LPX64, u64val); + len = snprintf(buf, sizeof(buf), "%#llx", u64val); if (len != 18) { CWARN("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len); ret = -EINVAL; } - len = snprintf(buf, sizeof(buf), LPU64, u64val); + len = snprintf(buf, sizeof(buf), "%llu", u64val); if (len != 20) { CWARN("LPU64 wrong length! strlen(%s)=%d != 20\n", buf, len); ret = -EINVAL; } - len = snprintf(buf, sizeof(buf), LPD64, u64val); + len = snprintf(buf, sizeof(buf), "%lld", u64val); if (len != 2) { CWARN("LPD64 wrong length! strlen(%s)=%d != 2\n", buf, len); ret = -EINVAL; } if ((u64val & ~CFS_PAGE_MASK) >= PAGE_CACHE_SIZE) { - CWARN("mask failed: u64val "LPU64" >= "LPU64"\n", u64val, + CWARN("mask failed: u64val %llu >= %llu\n", u64val, (__u64)PAGE_CACHE_SIZE); ret = -EINVAL; } @@ -483,7 +483,7 @@ int obd_init_checks(void) } extern spinlock_t obd_types_lock; -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) extern int class_procfs_init(void); extern int class_procfs_clean(void); #else @@ -594,7 +594,7 @@ void obd_update_maxusage(void) } EXPORT_SYMBOL(obd_update_maxusage); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) __u64 obd_memory_max(void) { __u64 ret; @@ -662,10 +662,10 @@ static void cleanup_obdclass(void) lprocfs_free_stats(&obd_memory); CDEBUG((memory_leaked) ? D_ERROR : D_INFO, - "obd_memory max: "LPU64", leaked: "LPU64"\n", + "obd_memory max: %llu, leaked: %llu\n", memory_max, memory_leaked); CDEBUG((pages_leaked) ? D_ERROR : D_INFO, - "obd_memory_pages max: "LPU64", leaked: "LPU64"\n", + "obd_memory_pages max: %llu, leaked: %llu\n", pages_max, pages_leaked); } diff --git a/drivers/staging/lustre/lustre/obdclass/debug.c b/drivers/staging/lustre/lustre/obdclass/debug.c index a4e7e754177f..e8aa42beb3c7 100644 --- a/drivers/staging/lustre/lustre/obdclass/debug.c +++ b/drivers/staging/lustre/lustre/obdclass/debug.c @@ -41,15 +41,15 @@ #define DEBUG_SUBSYSTEM D_OTHER -#include <obd_ost.h> -#include <obd_support.h> -#include <lustre_debug.h> -#include <lustre_net.h> +#include "../include/obd_ost.h" +#include "../include/obd_support.h" +#include "../include/lustre_debug.h" +#include "../include/lustre_net.h" void dump_lniobuf(struct niobuf_local *nb) { CDEBUG(D_RPCTRACE, - "niobuf_local: file_offset="LPD64", len=%d, page=%p, rc=%d\n", + "niobuf_local: file_offset=%lld, len=%d, page=%p, rc=%d\n", nb->lnb_file_offset, nb->len, nb->page, nb->rc); CDEBUG(D_RPCTRACE, "nb->page: index = %ld\n", nb->page ? page_index(nb->page) : -1); @@ -84,25 +84,25 @@ int block_debug_check(char *who, void *addr, int end, __u64 off, __u64 id) ne_off = le64_to_cpu (off); id = le64_to_cpu (id); if (memcmp(addr, (char *)&ne_off, LPDS)) { - CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" off: "LPX64" != " - LPX64"\n", who, id, off, *(__u64 *)addr, ne_off); + CDEBUG(D_ERROR, "%s: id %#llx offset %llu off: %#llx != %#llx\n", + who, id, off, *(__u64 *)addr, ne_off); err = -EINVAL; } if (memcmp(addr + LPDS, (char *)&id, LPDS)) { - CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" id: "LPX64" != "LPX64"\n", + CDEBUG(D_ERROR, "%s: id %#llx offset %llu id: %#llx != %#llx\n", who, id, off, *(__u64 *)(addr + LPDS), id); err = -EINVAL; } addr += end - LPDS - LPDS; if (memcmp(addr, (char *)&ne_off, LPDS)) { - CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" end off: "LPX64" != " - LPX64"\n", who, id, off, *(__u64 *)addr, ne_off); + CDEBUG(D_ERROR, "%s: id %#llx offset %llu end off: %#llx != %#llx\n", + who, id, off, *(__u64 *)addr, ne_off); err = -EINVAL; } if (memcmp(addr + LPDS, (char *)&id, LPDS)) { - CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" end id: "LPX64" != " - LPX64"\n", who, id, off, *(__u64 *)(addr + LPDS), id); + CDEBUG(D_ERROR, "%s: id %#llx offset %llu end id: %#llx != %#llx\n", + who, id, off, *(__u64 *)(addr + LPDS), id); err = -EINVAL; } diff --git a/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c index 1b164c7027b1..130b8dd0b418 100644 --- a/drivers/staging/lustre/lustre/obdclass/dt_object.c +++ b/drivers/staging/lustre/lustre/obdclass/dt_object.c @@ -43,13 +43,13 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <obd.h> -#include <dt_object.h> +#include "../include/obd.h" +#include "../include/dt_object.h" #include <linux/list.h> /* fid_be_to_cpu() */ -#include <lustre_fid.h> +#include "../include/lustre_fid.h" -#include <lustre_quota.h> +#include "../include/lustre_quota.h" /* context key constructor/destructor: dt_global_key_init, dt_global_key_fini */ LU_KEY_INIT(dt_global, struct dt_thread_info); @@ -929,7 +929,7 @@ out: } EXPORT_SYMBOL(dt_index_read); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) int lprocfs_dt_rd_blksize(char *page, char **start, off_t off, int count, int *eof, void *data) @@ -963,7 +963,7 @@ int lprocfs_dt_rd_kbytestotal(char *page, char **start, off_t off, result <<= 1; *eof = 1; - rc = snprintf(page, count, LPU64"\n", result); + rc = snprintf(page, count, "%llu\n", result); } return rc; @@ -985,7 +985,7 @@ int lprocfs_dt_rd_kbytesfree(char *page, char **start, off_t off, result <<= 1; *eof = 1; - rc = snprintf(page, count, LPU64"\n", result); + rc = snprintf(page, count, "%llu\n", result); } return rc; @@ -1007,7 +1007,7 @@ int lprocfs_dt_rd_kbytesavail(char *page, char **start, off_t off, result <<= 1; *eof = 1; - rc = snprintf(page, count, LPU64"\n", result); + rc = snprintf(page, count, "%llu\n", result); } return rc; @@ -1023,7 +1023,7 @@ int lprocfs_dt_rd_filestotal(char *page, char **start, off_t off, int rc = dt_statfs(NULL, dt, &osfs); if (rc == 0) { *eof = 1; - rc = snprintf(page, count, LPU64"\n", osfs.os_files); + rc = snprintf(page, count, "%llu\n", osfs.os_files); } return rc; @@ -1039,11 +1039,11 @@ int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off, int rc = dt_statfs(NULL, dt, &osfs); if (rc == 0) { *eof = 1; - rc = snprintf(page, count, LPU64"\n", osfs.os_ffree); + rc = snprintf(page, count, "%llu\n", osfs.os_ffree); } return rc; } EXPORT_SYMBOL(lprocfs_dt_rd_filesfree); -#endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS */ diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 3210ad8184b9..504c59aabaef 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -40,9 +40,9 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#include <obd_ost.h> -#include <obd_class.h> -#include <lprocfs_status.h> +#include "../include/obd_ost.h" +#include "../include/obd_class.h" +#include "../include/lprocfs_status.h" extern struct list_head obd_types; spinlock_t obd_types_lock; @@ -699,7 +699,7 @@ struct obd_export *class_conn2export(struct lustre_handle *conn) return NULL; } - CDEBUG(D_INFO, "looking for export cookie "LPX64"\n", conn->cookie); + CDEBUG(D_INFO, "looking for export cookie %#llx\n", conn->cookie); export = class_handle2object(conn->cookie); return export; } @@ -842,7 +842,7 @@ struct obd_export *class_new_export(struct obd_device *obd, INIT_LIST_HEAD(&export->exp_handle.h_link); INIT_LIST_HEAD(&export->exp_hp_rpcs); class_handle_hash(&export->exp_handle, &export_handle_ops); - export->exp_last_request_time = cfs_time_current_sec(); + export->exp_last_request_time = get_seconds(); spin_lock_init(&export->exp_lock); spin_lock_init(&export->exp_rpc_lock); INIT_HLIST_NODE(&export->exp_uuid_hash); @@ -1113,7 +1113,7 @@ int class_connect(struct lustre_handle *conn, struct obd_device *obd, conn->cookie = export->exp_handle.h_cookie; class_export_put(export); - CDEBUG(D_IOCTL, "connect: client %s, cookie "LPX64"\n", + CDEBUG(D_IOCTL, "connect: client %s, cookie %#llx\n", cluuid->uuid, conn->cookie); return 0; } @@ -1190,7 +1190,7 @@ int class_disconnect(struct obd_export *export) GOTO(no_disconn, already_disconnected); } - CDEBUG(D_IOCTL, "disconnect: cookie "LPX64"\n", + CDEBUG(D_IOCTL, "disconnect: cookie %#llx\n", export->exp_handle.h_cookie); if (!hlist_unhashed(&export->exp_nid_hash)) @@ -1493,7 +1493,7 @@ static void print_export_data(struct obd_export *exp, const char *status, } spin_unlock(&exp->exp_lock); - CDEBUG(D_HA, "%s: %s %p %s %s %d (%d %d %d) %d %d %d %d: %p %s "LPU64"\n", + CDEBUG(D_HA, "%s: %s %p %s %s %d (%d %d %d) %d %d %d %d: %p %s %llu\n", exp->exp_obd->obd_name, status, exp, exp->exp_client_uuid.uuid, obd_export_nid2str(exp), atomic_read(&exp->exp_refcount), atomic_read(&exp->exp_rpc_count), diff --git a/drivers/staging/lustre/lustre/obdclass/idmap.c b/drivers/staging/lustre/lustre/obdclass/idmap.c index ec2590f5cfe9..1190885c06b6 100644 --- a/drivers/staging/lustre/lustre/obdclass/idmap.c +++ b/drivers/staging/lustre/lustre/obdclass/idmap.c @@ -42,9 +42,9 @@ #define DEBUG_SUBSYSTEM S_SEC -#include <lustre_idmap.h> -#include <md_object.h> -#include <obd_support.h> +#include "../include/lustre_idmap.h" +#include "../include/md_object.h" +#include "../include/obd_support.h" #define lustre_get_group_info(group_info) do { \ atomic_inc(&(group_info)->usage); \ diff --git a/drivers/staging/lustre/lustre/obdclass/linkea.c b/drivers/staging/lustre/lustre/obdclass/linkea.c index b5c19ac1470f..8a1c7b6fefe9 100644 --- a/drivers/staging/lustre/lustre/obdclass/linkea.c +++ b/drivers/staging/lustre/lustre/obdclass/linkea.c @@ -27,9 +27,9 @@ * Author: Di Wang <di.wang@intel.com> */ -#include <lustre/lustre_idl.h> -#include <obd.h> -#include <lustre_linkea.h> +#include "../include/lustre/lustre_idl.h" +#include "../include/obd.h" +#include "../include/lustre_linkea.h" int linkea_data_new(struct linkea_data *ldata, struct lu_buf *buf) { diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index bdf2eed2952a..9ce3d36c685d 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -65,13 +65,13 @@ #include <linux/miscdevice.h> #include <linux/seq_file.h> -#include <linux/libcfs/libcfs.h> -#include <obd_support.h> -#include <obd_class.h> -#include <linux/lnet/lnetctl.h> -#include <lprocfs_status.h> -#include <lustre_ver.h> -#include <lustre/lustre_build_version.h> +#include "../../../include/linux/libcfs/libcfs.h" +#include "../../../include/linux/lnet/lnetctl.h" +#include "../../include/obd_support.h" +#include "../../include/obd_class.h" +#include "../../include/lprocfs_status.h" +#include "../../include/lustre_ver.h" +#include "../../include/lustre/lustre_build_version.h" int proc_version; @@ -212,7 +212,7 @@ struct miscdevice obd_psdev = { }; -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) int obd_proc_version_seq_show(struct seq_file *m, void *v) { return seq_printf(m, "lustre: %s\nkernel: %s\nbuild: %s\n", @@ -328,7 +328,7 @@ struct lprocfs_vars lprocfs_base[] = { { "jobid_var", &obd_proc_jobid_var_fops }, { .name = "jobid_name", .fops = &obd_proc_jobid_name_fops}, - { 0 } + { NULL } }; static void *obd_device_list_seq_start(struct seq_file *p, loff_t *pos) @@ -435,4 +435,4 @@ int class_procfs_clean(void) } return 0; } -#endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS */ diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c index d3bb5ffc564b..bb15202f1aae 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c @@ -43,8 +43,8 @@ #define DEBUG_SUBSYSTEM S_CLASS #include <linux/module.h> -#include <obd_class.h> -#include <lustre/lustre_idl.h> +#include "../../include/obd_class.h" +#include "../../include/lustre/lustre_idl.h" #include <linux/fs.h> #include <linux/pagemap.h> /* for PAGE_CACHE_SIZE */ @@ -151,7 +151,7 @@ void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid) if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME)) CDEBUG(D_INODE, - "valid "LPX64", cur time %lu/%lu, new "LPU64"/"LPU64"\n", + "valid %#llx, cur time %lu/%lu, new %llu/%llu\n", src->o_valid, LTIME_S(dst->i_mtime), LTIME_S(dst->i_ctime), src->o_mtime, src->o_ctime); @@ -190,7 +190,7 @@ void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid) if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME)) CDEBUG(D_INODE, - "valid "LPX64", cur time %lu/%lu, new "LPU64"/"LPU64"\n", + "valid %#llx, cur time %lu/%lu, new %llu/%llu\n", src->o_valid, LTIME_S(dst->i_mtime), LTIME_S(dst->i_ctime), src->o_mtime, src->o_ctime); diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index c1ef0c9b5a1a..38a9b319355e 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -42,17 +42,17 @@ #include <linux/slab.h> #include <linux/stat.h> #include <linux/ctype.h> -#include <asm/bitops.h> -#include <asm/uaccess.h> +#include <linux/bitops.h> +#include <linux/uaccess.h> #include <linux/utsname.h> #define DEBUG_SUBSYSTEM S_CLASS -#include <obd_support.h> -#include <lprocfs_status.h> +#include "../../include/obd_support.h" +#include "../../include/lprocfs_status.h" #ifdef CONFIG_SYSCTL -ctl_table_header_t *obd_table_header = NULL; +static struct ctl_table_header *obd_table_header; #endif @@ -79,21 +79,22 @@ enum { }; -int LL_PROC_PROTO(proc_set_timeout) +static int proc_set_timeout(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int rc; - rc = ll_proc_dointvec(table, write, filp, buffer, lenp, ppos); + rc = proc_dointvec(table, write, buffer, lenp, ppos); if (ldlm_timeout >= obd_timeout) ldlm_timeout = max(obd_timeout / 3, 1U); return rc; } -int LL_PROC_PROTO(proc_memory_alloc) +static int proc_memory_alloc(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { char buf[22]; int len; - DECLARE_LL_PROC_PPOS_DECL; if (!*lenp || (*ppos && !write)) { *lenp = 0; @@ -102,7 +103,7 @@ int LL_PROC_PROTO(proc_memory_alloc) if (write) return -EINVAL; - len = snprintf(buf, sizeof(buf), LPU64"\n", obd_memory_sum()); + len = snprintf(buf, sizeof(buf), "%llu\n", obd_memory_sum()); if (len > *lenp) len = *lenp; buf[len] = '\0'; @@ -113,11 +114,11 @@ int LL_PROC_PROTO(proc_memory_alloc) return 0; } -int LL_PROC_PROTO(proc_pages_alloc) +static int proc_pages_alloc(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { char buf[22]; int len; - DECLARE_LL_PROC_PPOS_DECL; if (!*lenp || (*ppos && !write)) { *lenp = 0; @@ -126,7 +127,7 @@ int LL_PROC_PROTO(proc_pages_alloc) if (write) return -EINVAL; - len = snprintf(buf, sizeof(buf), LPU64"\n", obd_pages_sum()); + len = snprintf(buf, sizeof(buf), "%llu\n", obd_pages_sum()); if (len > *lenp) len = *lenp; buf[len] = '\0'; @@ -137,11 +138,11 @@ int LL_PROC_PROTO(proc_pages_alloc) return 0; } -int LL_PROC_PROTO(proc_mem_max) +static int proc_mem_max(struct ctl_table *table, int write, void __user *buffer, + size_t *lenp, loff_t *ppos) { char buf[22]; int len; - DECLARE_LL_PROC_PPOS_DECL; if (!*lenp || (*ppos && !write)) { *lenp = 0; @@ -150,7 +151,7 @@ int LL_PROC_PROTO(proc_mem_max) if (write) return -EINVAL; - len = snprintf(buf, sizeof(buf), LPU64"\n", obd_memory_max()); + len = snprintf(buf, sizeof(buf), "%llu\n", obd_memory_max()); if (len > *lenp) len = *lenp; buf[len] = '\0'; @@ -161,11 +162,11 @@ int LL_PROC_PROTO(proc_mem_max) return 0; } -int LL_PROC_PROTO(proc_pages_max) +static int proc_pages_max(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { char buf[22]; int len; - DECLARE_LL_PROC_PPOS_DECL; if (!*lenp || (*ppos && !write)) { *lenp = 0; @@ -174,7 +175,7 @@ int LL_PROC_PROTO(proc_pages_max) if (write) return -EINVAL; - len = snprintf(buf, sizeof(buf), LPU64"\n", obd_pages_max()); + len = snprintf(buf, sizeof(buf), "%llu\n", obd_pages_max()); if (len > *lenp) len = *lenp; buf[len] = '\0'; @@ -185,10 +186,10 @@ int LL_PROC_PROTO(proc_pages_max) return 0; } -int LL_PROC_PROTO(proc_max_dirty_pages_in_mb) +static int proc_max_dirty_pages_in_mb(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int rc = 0; - DECLARE_LL_PROC_PPOS_DECL; if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) { *lenp = 0; @@ -196,7 +197,7 @@ int LL_PROC_PROTO(proc_max_dirty_pages_in_mb) } if (write) { rc = lprocfs_write_frac_helper(buffer, *lenp, - (unsigned int*)table->data, + (unsigned int *)table->data, 1 << (20 - PAGE_CACHE_SHIFT)); /* Don't allow them to let dirty pages exceed 90% of system * memory and set a hard minimum of 4MB. */ @@ -214,7 +215,7 @@ int LL_PROC_PROTO(proc_max_dirty_pages_in_mb) int len; len = lprocfs_read_frac_helper(buf, sizeof(buf), - *(unsigned int*)table->data, + *(unsigned int *)table->data, 1 << (20 - PAGE_CACHE_SHIFT)); if (len > *lenp) len = *lenp; @@ -227,10 +228,10 @@ int LL_PROC_PROTO(proc_max_dirty_pages_in_mb) return rc; } -int LL_PROC_PROTO(proc_alloc_fail_rate) +static int proc_alloc_fail_rate(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int rc = 0; - DECLARE_LL_PROC_PPOS_DECL; if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) { *lenp = 0; @@ -238,14 +239,14 @@ int LL_PROC_PROTO(proc_alloc_fail_rate) } if (write) { rc = lprocfs_write_frac_helper(buffer, *lenp, - (unsigned int*)table->data, + (unsigned int *)table->data, OBD_ALLOC_FAIL_MULT); } else { char buf[21]; int len; len = lprocfs_read_frac_helper(buf, 21, - *(unsigned int*)table->data, + *(unsigned int *)table->data, OBD_ALLOC_FAIL_MULT); if (len > *lenp) len = *lenp; @@ -258,29 +259,8 @@ int LL_PROC_PROTO(proc_alloc_fail_rate) return rc; } -int LL_PROC_PROTO(proc_at_min) -{ - return ll_proc_dointvec(table, write, filp, buffer, lenp, ppos); -} -int LL_PROC_PROTO(proc_at_max) -{ - return ll_proc_dointvec(table, write, filp, buffer, lenp, ppos); -} -int LL_PROC_PROTO(proc_at_extra) -{ - return ll_proc_dointvec(table, write, filp, buffer, lenp, ppos); -} -int LL_PROC_PROTO(proc_at_early_margin) -{ - return ll_proc_dointvec(table, write, filp, buffer, lenp, ppos); -} -int LL_PROC_PROTO(proc_at_history) -{ - return ll_proc_dointvec(table, write, filp, buffer, lenp, ppos); -} - #ifdef CONFIG_SYSCTL -static ctl_table_t obd_table[] = { +static struct ctl_table obd_table[] = { { .procname = "timeout", .data = &obd_timeout, @@ -363,40 +343,40 @@ static ctl_table_t obd_table[] = { .data = &at_min, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &proc_at_min + .proc_handler = &proc_dointvec, }, { .procname = "at_max", .data = &at_max, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &proc_at_max + .proc_handler = &proc_dointvec, }, { .procname = "at_extra", .data = &at_extra, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &proc_at_extra + .proc_handler = &proc_dointvec, }, { .procname = "at_early_margin", .data = &at_early_margin, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &proc_at_early_margin + .proc_handler = &proc_dointvec, }, { .procname = "at_history", .data = &at_history, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &proc_at_history + .proc_handler = &proc_dointvec, }, {} }; -static ctl_table_t parent_table[] = { +static struct ctl_table parent_table[] = { { .procname = "lustre", .data = NULL, @@ -408,18 +388,18 @@ static ctl_table_t parent_table[] = { }; #endif -void obd_sysctl_init (void) +void obd_sysctl_init(void) { #ifdef CONFIG_SYSCTL - if ( !obd_table_header ) + if (!obd_table_header) obd_table_header = register_sysctl_table(parent_table); #endif } -void obd_sysctl_clean (void) +void obd_sysctl_clean(void) { #ifdef CONFIG_SYSCTL - if ( obd_table_header ) + if (obd_table_header) unregister_sysctl_table(obd_table_header); obd_table_header = NULL; #endif diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index e0dfb089dd90..cce86890c563 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -48,8 +48,8 @@ #define DEBUG_SUBSYSTEM S_LOG -#include <obd_class.h> -#include <lustre_log.h> +#include "../include/obd_class.h" +#include "../include/lustre_log.h" #include "llog_internal.h" /* @@ -188,7 +188,7 @@ static int llog_read_header(const struct lu_env *env, llh->llh_hdr.lrh_type = LLOG_HDR_MAGIC; llh->llh_hdr.lrh_len = llh->llh_tail.lrt_len = LLOG_CHUNK_SIZE; llh->llh_hdr.lrh_index = llh->llh_tail.lrt_index = 0; - llh->llh_timestamp = cfs_time_current_sec(); + llh->llh_timestamp = get_seconds(); if (uuid) memcpy(&llh->llh_tgtuuid, uuid, sizeof(llh->llh_tgtuuid)); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index 1d999310ec92..ca9927ccde68 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -49,7 +49,7 @@ #define DEBUG_SUBSYSTEM S_LOG -#include <obd_class.h> +#include "../include/obd_class.h" #include "llog_internal.h" diff --git a/drivers/staging/lustre/lustre/obdclass/llog_internal.h b/drivers/staging/lustre/lustre/obdclass/llog_internal.h index 539e1d4f9d4c..5332131a2a2e 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_internal.h +++ b/drivers/staging/lustre/lustre/obdclass/llog_internal.h @@ -37,7 +37,7 @@ #ifndef __LLOG_INTERNAL_H__ #define __LLOG_INTERNAL_H__ -#include <lustre_log.h> +#include "../include/lustre_log.h" struct llog_process_info { struct llog_handle *lpi_loghandle; diff --git a/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c b/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c index e192aab193bb..9b7fa1d5e79a 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c @@ -36,8 +36,8 @@ #define DEBUG_SUBSYSTEM S_LOG -#include <obd_class.h> -#include <lustre_log.h> +#include "../include/obd_class.h" +#include "../include/lustre_log.h" #include "llog_internal.h" static int str2logid(struct llog_logid *logid, char *str, int len) diff --git a/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c b/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c index d86bb8c60354..fd48d59cf315 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c @@ -46,20 +46,20 @@ #define DEBUG_SUBSYSTEM S_LOG -#include <obd.h> -#include <obd_class.h> -#include <lustre_log.h> -#include <obd_ost.h> +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/lustre_log.h" +#include "../include/obd_ost.h" #include <linux/list.h> -#include <lvfs.h> -#include <lustre_fsfilt.h> -#include <lustre_disk.h> +#include "../include/lvfs.h" +#include "../include/lustre_fsfilt.h" +#include "../include/lustre_disk.h" #include "llog_internal.h" #if defined(LLOG_LVFS) -static int llog_lvfs_pad(struct obd_device *obd, struct l_file *file, - int len, int index) +static int llog_lvfs_pad(struct obd_device *obd, struct file *file, int len, + int index) { struct llog_rec_hdr rec = { 0 }; struct llog_rec_tail tail; @@ -88,7 +88,7 @@ static int llog_lvfs_pad(struct obd_device *obd, struct l_file *file, return rc; } -static int llog_lvfs_write_blob(struct obd_device *obd, struct l_file *file, +static int llog_lvfs_write_blob(struct obd_device *obd, struct file *file, struct llog_rec_hdr *rec, void *buf, loff_t off) { int rc; @@ -140,7 +140,7 @@ static int llog_lvfs_write_blob(struct obd_device *obd, struct l_file *file, return rc; } -static int llog_lvfs_read_blob(struct obd_device *obd, struct l_file *file, +static int llog_lvfs_read_blob(struct obd_device *obd, struct file *file, void *buf, int size, loff_t off) { loff_t offset = off; @@ -389,7 +389,7 @@ static int llog_lvfs_next_block(const struct lu_env *env, if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) return -EINVAL; - CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off "LPU64")\n", + CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off %llu)\n", next_idx, *cur_idx, *cur_offset); while (*cur_offset < i_size_read(loghandle->lgh_file->f_dentry->d_inode)) { @@ -408,7 +408,7 @@ static int llog_lvfs_next_block(const struct lu_env *env, cur_offset); if (rc < 0) { CERROR("Cant read llog block at log id "DOSTID - "/%u offset "LPU64"\n", + "/%u offset %llu\n", POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, *cur_offset); @@ -426,8 +426,8 @@ static int llog_lvfs_next_block(const struct lu_env *env, return 0; if (rc < sizeof(*tail)) { - CERROR("Invalid llog block at log id "DOSTID"/%u offset" - LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi), + CERROR("Invalid llog block at log id "DOSTID"/%u offset%llu\n", + POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, *cur_offset); return -EINVAL; } @@ -451,8 +451,8 @@ static int llog_lvfs_next_block(const struct lu_env *env, /* this shouldn't happen */ if (tail->lrt_index == 0) { - CERROR("Invalid llog tail at log id "DOSTID"/%u offset " - LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi), + CERROR("Invalid llog tail at log id "DOSTID"/%u offset %llu\n", + POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, *cur_offset); return -EINVAL; } @@ -496,7 +496,7 @@ static int llog_lvfs_prev_block(const struct lu_env *env, &cur_offset); if (rc < 0) { CERROR("Cant read llog block at log id "DOSTID - "/%u offset "LPU64"\n", + "/%u offset %llu\n", POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, cur_offset); @@ -510,8 +510,8 @@ static int llog_lvfs_prev_block(const struct lu_env *env, return 0; if (rc < sizeof(*tail)) { - CERROR("Invalid llog block at log id "DOSTID"/%u offset" - LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi), + CERROR("Invalid llog block at log id "DOSTID"/%u offset%llu\n", + POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, cur_offset); return -EINVAL; } @@ -533,8 +533,8 @@ static int llog_lvfs_prev_block(const struct lu_env *env, /* this shouldn't happen */ if (tail->lrt_index == 0) { - CERROR("Invalid llog tail at log id "DOSTID"/%u offset" - LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi), + CERROR("Invalid llog tail at log id "DOSTID"/%u offset%llu\n", + POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, cur_offset); return -EINVAL; } @@ -567,7 +567,7 @@ static struct file *llog_filp_open(char *dir, char *name, int flags, int mode) if (len >= PATH_MAX - 1) { filp = ERR_PTR(-ENAMETOOLONG); } else { - filp = l_filp_open(logname, flags, mode); + filp = filp_open(logname, flags, mode); if (IS_ERR(filp) && PTR_ERR(filp) != -ENOENT) CERROR("logfile creation %s: %ld\n", logname, PTR_ERR(filp)); @@ -581,7 +581,7 @@ static int llog_lvfs_open(const struct lu_env *env, struct llog_handle *handle, enum llog_open_param open_param) { struct llog_ctxt *ctxt = handle->lgh_ctxt; - struct l_dentry *dchild = NULL; + struct dentry *dchild = NULL; struct obd_device *obd; int rc = 0; @@ -672,7 +672,7 @@ static int llog_lvfs_create(const struct lu_env *env, { struct llog_ctxt *ctxt = handle->lgh_ctxt; struct obd_device *obd; - struct l_dentry *dchild = NULL; + struct dentry *dchild = NULL; struct file *file; struct obdo *oa = NULL; int rc = 0; diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 2c6d81eb5c65..8ff01d3f90b4 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -37,8 +37,8 @@ #define DEBUG_SUBSYSTEM S_LOG -#include <obd_class.h> -#include <lustre_log.h> +#include "../include/obd_class.h" +#include "../include/lustre_log.h" #include "llog_internal.h" /* helper functions for calling the llog obd methods */ diff --git a/drivers/staging/lustre/lustre/obdclass/llog_osd.c b/drivers/staging/lustre/lustre/obdclass/llog_osd.c index 682279de8bea..2c6a51e90697 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_osd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_osd.c @@ -41,10 +41,10 @@ #define DEBUG_SUBSYSTEM S_LOG -#include <obd.h> -#include <obd_class.h> -#include <lustre_fid.h> -#include <dt_object.h> +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/lustre_fid.h" +#include "../include/dt_object.h" #include "llog_internal.h" #include "local_storage.h" @@ -533,7 +533,7 @@ static int llog_osd_next_block(const struct lu_env *env, if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) return -EINVAL; - CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off "LPU64")\n", + CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off %llu)\n", next_idx, *cur_idx, *cur_offset); LASSERT(loghandle); @@ -574,7 +574,7 @@ static int llog_osd_next_block(const struct lu_env *env, dt_read_unlock(env, o); if (rc < 0) { CERROR("%s: can't read llog block from log "DFID - " offset "LPU64": rc = %d\n", + " offset %llu: rc = %d\n", o->do_lu.lo_dev->ld_obd->obd_name, PFID(lu_object_fid(&o->do_lu)), *cur_offset, rc); @@ -592,7 +592,7 @@ static int llog_osd_next_block(const struct lu_env *env, if (rc < sizeof(*tail)) { CERROR("%s: invalid llog block at log id "DOSTID"/%u " - "offset "LPU64"\n", + "offset %llu\n", o->do_lu.lo_dev->ld_obd->obd_name, POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, *cur_offset); @@ -618,7 +618,7 @@ static int llog_osd_next_block(const struct lu_env *env, /* this shouldn't happen */ if (tail->lrt_index == 0) { CERROR("%s: invalid llog tail at log id "DOSTID"/%u " - "offset "LPU64"\n", + "offset %llu\n", o->do_lu.lo_dev->ld_obd->obd_name, POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, *cur_offset); @@ -687,7 +687,7 @@ static int llog_osd_prev_block(const struct lu_env *env, dt_read_unlock(env, o); if (rc < 0) { CERROR("%s: can't read llog block from log "DFID - " offset "LPU64": rc = %d\n", + " offset %llu: rc = %d\n", o->do_lu.lo_dev->ld_obd->obd_name, PFID(lu_object_fid(&o->do_lu)), cur_offset, rc); GOTO(out, rc); @@ -698,7 +698,7 @@ static int llog_osd_prev_block(const struct lu_env *env, if (rc < sizeof(*tail)) { CERROR("%s: invalid llog block at log id "DOSTID"/%u " - "offset "LPU64"\n", + "offset %llu\n", o->do_lu.lo_dev->ld_obd->obd_name, POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, cur_offset); @@ -722,7 +722,7 @@ static int llog_osd_prev_block(const struct lu_env *env, /* this shouldn't happen */ if (tail->lrt_index == 0) { CERROR("%s: invalid llog tail at log id "DOSTID"/%u " - "offset "LPU64"\n", + "offset %llu\n", o->do_lu.lo_dev->ld_obd->obd_name, POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, cur_offset); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index 24ca099b01da..b3247fb7a35a 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -43,7 +43,7 @@ #define DEBUG_SUBSYSTEM S_LOG -#include <lustre_log.h> +#include "../include/lustre_log.h" static void print_llogd_body(struct llogd_body *d) { @@ -56,7 +56,7 @@ static void print_llogd_body(struct llogd_body *d) CDEBUG(D_OTHER, "\tlgd_index: %#x\n", d->lgd_index); CDEBUG(D_OTHER, "\tlgd_saved_index: %#x\n", d->lgd_saved_index); CDEBUG(D_OTHER, "\tlgd_len: %#x\n", d->lgd_len); - CDEBUG(D_OTHER, "\tlgd_cur_offset: "LPX64"\n", d->lgd_cur_offset); + CDEBUG(D_OTHER, "\tlgd_cur_offset: %#llx\n", d->lgd_cur_offset); } void lustre_swab_lu_fid(struct lu_fid *fid) @@ -284,7 +284,7 @@ static void print_llog_hdr(struct llog_log_hdr *h) CDEBUG(D_OTHER, "\tllh_hdr.lrh_index: %#x\n", h->llh_hdr.lrh_index); CDEBUG(D_OTHER, "\tllh_hdr.lrh_len: %#x\n", h->llh_hdr.lrh_len); CDEBUG(D_OTHER, "\tllh_hdr.lrh_type: %#x\n", h->llh_hdr.lrh_type); - CDEBUG(D_OTHER, "\tllh_timestamp: "LPX64"\n", h->llh_timestamp); + CDEBUG(D_OTHER, "\tllh_timestamp: %#llx\n", h->llh_timestamp); CDEBUG(D_OTHER, "\tllh_count: %#x\n", h->llh_count); CDEBUG(D_OTHER, "\tllh_bitmap_offset: %#x\n", h->llh_bitmap_offset); CDEBUG(D_OTHER, "\tllh_flags: %#x\n", h->llh_flags); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_test.c b/drivers/staging/lustre/lustre/obdclass/llog_test.c index 764068fc4ef7..ef008abd331c 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_test.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_test.c @@ -44,9 +44,9 @@ #include <linux/module.h> #include <linux/init.h> -#include <obd_class.h> -#include <lustre_fid.h> -#include <lustre_log.h> +#include "../include/obd_class.h" +#include "../include/lustre_fid.h" +#include "../include/lustre_log.h" /* This is slightly more than the number of records that can fit into a * single llog file, because the llog_log_header takes up some of the @@ -939,9 +939,9 @@ cleanup_ctxt: return rc; } -#ifdef LPROCFS -static struct lprocfs_vars lprocfs_llog_test_obd_vars[] = { {0} }; -static struct lprocfs_vars lprocfs_llog_test_module_vars[] = { {0} }; +#if defined (CONFIG_PROC_FS) +static struct lprocfs_vars lprocfs_llog_test_obd_vars[] = { { NULL } }; +static struct lprocfs_vars lprocfs_llog_test_module_vars[] = { { NULL } }; static void lprocfs_llog_test_init_vars(struct lprocfs_static_vars *lvars) { lvars->module_vars = lprocfs_llog_test_module_vars; diff --git a/drivers/staging/lustre/lustre/obdclass/local_storage.c b/drivers/staging/lustre/lustre/obdclass/local_storage.c index e76f7d044231..78190225ac7a 100644 --- a/drivers/staging/lustre/lustre/obdclass/local_storage.c +++ b/drivers/staging/lustre/lustre/obdclass/local_storage.c @@ -670,7 +670,7 @@ int lastid_compat_check(const struct lu_env *env, struct dt_device *dev, return PTR_ERR(root); /* find old last_id file */ - snprintf(dti->dti_buf, sizeof(dti->dti_buf), "seq-"LPX64"-lastid", + snprintf(dti->dti_buf, sizeof(dti->dti_buf), "seq-%#llx-lastid", lastid_seq); rc = dt_lookup_dir(env, root, dti->dti_buf, &dti->dti_fid); lu_object_put_nocache(env, &root->do_lu); @@ -693,7 +693,7 @@ int lastid_compat_check(const struct lu_env *env, struct dt_device *dev, } else if (rc < 0) { return rc; } else { - CDEBUG(D_INFO, "Found old lastid file for sequence "LPX64"\n", + CDEBUG(D_INFO, "Found old lastid file for sequence %#llx\n", lastid_seq); o = ls_locate(env, ls, &dti->dti_fid); if (IS_ERR(o)) @@ -709,12 +709,12 @@ int lastid_compat_check(const struct lu_env *env, struct dt_device *dev, dt_read_unlock(env, o); lu_object_put_nocache(env, &o->do_lu); if (rc == 0 && le32_to_cpu(losd.lso_magic) != LOS_MAGIC) { - CERROR("%s: wrong content of seq-"LPX64"-lastid file, magic %x\n", + CERROR("%s: wrong content of seq-%#llx-lastid file, magic %x\n", o->do_lu.lo_dev->ld_obd->obd_name, lastid_seq, le32_to_cpu(losd.lso_magic)); return -EINVAL; } else if (rc < 0) { - CERROR("%s: failed to read seq-"LPX64"-lastid: rc = %d\n", + CERROR("%s: failed to read seq-%#llx-lastid: rc = %d\n", o->do_lu.lo_dev->ld_obd->obd_name, lastid_seq, rc); return rc; } @@ -837,7 +837,7 @@ out_trans: rc = dt_record_read(env, o, &dti->dti_lb, &dti->dti_off); dt_read_unlock(env, o); if (rc == 0 && le64_to_cpu(lastid) > OBIF_MAX_OID) { - CERROR("%s: bad oid "LPU64" is read from LAST_ID\n", + CERROR("%s: bad oid %llu is read from LAST_ID\n", o->do_lu.lo_dev->ld_obd->obd_name, le64_to_cpu(lastid)); rc = -EINVAL; diff --git a/drivers/staging/lustre/lustre/obdclass/local_storage.h b/drivers/staging/lustre/lustre/obdclass/local_storage.h index 0f63b8c073b4..0b9ad33d1152 100644 --- a/drivers/staging/lustre/lustre/obdclass/local_storage.h +++ b/drivers/staging/lustre/lustre/obdclass/local_storage.h @@ -32,10 +32,10 @@ #ifndef __LOCAL_STORAGE_H #define __LOCAL_STORAGE_H -#include <dt_object.h> -#include <obd.h> -#include <lustre_fid.h> -#include <lustre_disk.h> +#include "../include/dt_object.h" +#include "../include/obd.h" +#include "../include/lustre_fid.h" +#include "../include/lustre_disk.h" struct ls_device { struct dt_device ls_top_dev; diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 1432dd74fe95..8309d4ce6d60 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -41,9 +41,9 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <obd_class.h> -#include <lprocfs_status.h> -#include <lustre/lustre_idl.h> +#include "../include/obd_class.h" +#include "../include/lprocfs_status.h" +#include "../include/lustre/lustre_idl.h" #include <linux/seq_file.h> static const char * const obd_connect_names[] = { @@ -116,7 +116,7 @@ int obd_connect_flags2str(char *page, int count, __u64 flags, char *sep) } if (flags & ~(mask - 1)) ret += snprintf(page + ret, count - ret, - "%sunknown flags "LPX64, + "%sunknown flags %#llx", ret ? sep : "", flags & ~(mask - 1)); return ret; } @@ -220,7 +220,7 @@ int lprocfs_write_frac_helper(const char *buffer, unsigned long count, } EXPORT_SYMBOL(lprocfs_write_frac_helper); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) static int lprocfs_no_percpu_stats = 0; module_param(lprocfs_no_percpu_stats, int, 0644); @@ -400,7 +400,7 @@ EXPORT_SYMBOL(lprocfs_wr_uint); int lprocfs_rd_u64(struct seq_file *m, void *data) { - return seq_printf(m, LPU64"\n", *(__u64 *)data); + return seq_printf(m, "%llu\n", *(__u64 *)data); } EXPORT_SYMBOL(lprocfs_rd_u64); @@ -476,7 +476,7 @@ int lprocfs_rd_kbytestotal(struct seq_file *m, void *data) while (blk_size >>= 1) result <<= 1; - rc = seq_printf(m, LPU64"\n", result); + rc = seq_printf(m, "%llu\n", result); } return rc; } @@ -496,7 +496,7 @@ int lprocfs_rd_kbytesfree(struct seq_file *m, void *data) while (blk_size >>= 1) result <<= 1; - rc = seq_printf(m, LPU64"\n", result); + rc = seq_printf(m, "%llu\n", result); } return rc; } @@ -516,7 +516,7 @@ int lprocfs_rd_kbytesavail(struct seq_file *m, void *data) while (blk_size >>= 1) result <<= 1; - rc = seq_printf(m, LPU64"\n", result); + rc = seq_printf(m, "%llu\n", result); } return rc; } @@ -530,7 +530,7 @@ int lprocfs_rd_filestotal(struct seq_file *m, void *data) cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - rc = seq_printf(m, LPU64"\n", osfs.os_files); + rc = seq_printf(m, "%llu\n", osfs.os_files); return rc; } @@ -544,7 +544,7 @@ int lprocfs_rd_filesfree(struct seq_file *m, void *data) cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - rc = seq_printf(m, LPU64"\n", osfs.os_ffree); + rc = seq_printf(m, "%llu\n", osfs.os_ffree); return rc; } EXPORT_SYMBOL(lprocfs_rd_filesfree); @@ -667,7 +667,7 @@ static void obd_connect_seq_flags2str(struct seq_file *m, __u64 flags, char *sep } } if (flags & ~(mask - 1)) - seq_printf(m, "%sunknown flags "LPX64, + seq_printf(m, "%sunknown flags %#llx", first ? sep : "", flags & ~(mask - 1)); } @@ -744,7 +744,7 @@ int lprocfs_rd_import(struct seq_file *m, void *data) " inflight: %u\n" " unregistering: %u\n" " timeouts: %u\n" - " avg_waittime: "LPU64" %s\n", + " avg_waittime: %llu %s\n", atomic_read(&imp->imp_inflight), atomic_read(&imp->imp_unregistering), atomic_read(&imp->imp_timeouts), @@ -766,9 +766,9 @@ int lprocfs_rd_import(struct seq_file *m, void *data) seq_printf(m, " transactions:\n" - " last_replay: "LPU64"\n" - " peer_committed: "LPU64"\n" - " last_checked: "LPU64"\n", + " last_replay: %llu\n" + " peer_committed: %llu\n" + " last_checked: %llu\n", imp->imp_last_replay_transno, imp->imp_peer_committed_transno, imp->imp_last_transno_checked); @@ -785,7 +785,7 @@ int lprocfs_rd_import(struct seq_file *m, void *data) ret.lc_sum = sum; seq_printf(m, " %s_data_averages:\n" - " bytes_per_rpc: "LPU64"\n", + " bytes_per_rpc: %llu\n", rw ? "write" : "read", ret.lc_sum); } @@ -799,7 +799,7 @@ int lprocfs_rd_import(struct seq_file *m, void *data) do_div(sum, ret.lc_count); ret.lc_sum = sum; seq_printf(m, - " %s_per_rpc: "LPU64"\n", + " %s_per_rpc: %llu\n", header->lc_units, ret.lc_sum); j = (int)ret.lc_sum; if (j > 0) @@ -868,7 +868,7 @@ int lprocfs_rd_timeouts(struct seq_file *m, void *data) LPROCFS_CLIMP_CHECK(obd); imp = obd->u.cli.cl_import; - now = cfs_time_current_sec(); + now = get_seconds(); /* Some network health info for kicks */ s2dhms(&ts, now - imp->imp_last_reply_time); @@ -908,7 +908,7 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) LPROCFS_CLIMP_CHECK(obd); flags = obd->u.cli.cl_import->imp_connect_data.ocd_connect_flags; - seq_printf(m, "flags="LPX64"\n", flags); + seq_printf(m, "flags=%#llx\n", flags); obd_connect_seq_flags2str(m, flags, "\n"); seq_printf(m, "\n"); LPROCFS_CLIMP_EXIT(obd); @@ -1175,19 +1175,19 @@ static int lprocfs_stats_seq_show(struct seq_file *p, void *v) if (ctr.lc_count == 0) goto out; - rc = seq_printf(p, "%-25s "LPD64" samples [%s]", hdr->lc_name, + rc = seq_printf(p, "%-25s %lld samples [%s]", hdr->lc_name, ctr.lc_count, hdr->lc_units); if (rc < 0) goto out; if ((hdr->lc_config & LPROCFS_CNTR_AVGMINMAX) && (ctr.lc_count > 0)) { - rc = seq_printf(p, " "LPD64" "LPD64" "LPD64, + rc = seq_printf(p, " %lld %lld %lld", ctr.lc_min, ctr.lc_max, ctr.lc_sum); if (rc < 0) goto out; if (hdr->lc_config & LPROCFS_CNTR_STDDEV) - rc = seq_printf(p, " "LPD64, ctr.lc_sumsquare); + rc = seq_printf(p, " %lld", ctr.lc_sumsquare); if (rc < 0) goto out; } @@ -1196,7 +1196,7 @@ out: return (rc < 0) ? rc : 0; } -struct seq_operations lprocfs_stats_seq_sops = { +static const struct seq_operations lprocfs_stats_seq_sops = { .start = lprocfs_stats_seq_start, .stop = lprocfs_stats_seq_stop, .next = lprocfs_stats_seq_next, diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 92e8a15a5e5d..2fc037cfb62f 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -44,18 +44,18 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" # include <linux/module.h> /* hash_long() */ -#include <linux/libcfs/libcfs_hash.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre_disk.h> -#include <lustre_fid.h> -#include <lu_object.h> -#include <lu_ref.h> +#include "../../include/linux/libcfs/libcfs_hash.h" +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/lustre_disk.h" +#include "../include/lustre_fid.h" +#include "../include/lu_object.h" +#include "../include/lu_ref.h" #include <linux/list.h> static void lu_object_free(const struct lu_env *env, struct lu_object *o); @@ -1994,7 +1994,7 @@ void lu_global_fini(void) static __u32 ls_stats_read(struct lprocfs_stats *stats, int idx) { -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) struct lprocfs_counter ret; lprocfs_stats_collect(stats, idx, &ret); diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ref.c b/drivers/staging/lustre/lustre/obdclass/lu_ref.c index 23a76f158356..993697b660f6 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_ref.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_ref.c @@ -42,9 +42,9 @@ #define DEBUG_SUBSYSTEM S_CLASS -# include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lu_ref.h> +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/lu_ref.h" diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ucred.c b/drivers/staging/lustre/lustre/obdclass/lu_ucred.c index e23e545b0d66..3676563ab330 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_ucred.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_ucred.c @@ -44,10 +44,10 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <linux/libcfs/libcfs.h> -#include <obd_support.h> -#include <lu_object.h> -#include <md_object.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/obd_support.h" +#include "../include/lu_object.h" +#include "../include/md_object.h" /* context key constructor/destructor: lu_ucred_key_init, lu_ucred_key_fini */ LU_KEY_INIT_FINI(lu_ucred, struct lu_ucred); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index be31d32b82c8..2010463429b1 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -40,9 +40,9 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <obd_support.h> -#include <lustre_handles.h> -#include <lustre_lib.h> +#include "../include/obd_support.h" +#include "../include/lustre_handles.h" +#include "../include/lustre_lib.h" static __u64 handle_base; @@ -97,7 +97,7 @@ void class_handle_hash(struct portals_handle *h, h->h_in = 1; spin_unlock(&bucket->lock); - CDEBUG(D_INFO, "added object %p with handle "LPX64" to hash\n", + CDEBUG(D_INFO, "added object %p with handle %#llx to hash\n", h, h->h_cookie); } EXPORT_SYMBOL(class_handle_hash); @@ -105,12 +105,12 @@ EXPORT_SYMBOL(class_handle_hash); static void class_handle_unhash_nolock(struct portals_handle *h) { if (list_empty(&h->h_link)) { - CERROR("removing an already-removed handle ("LPX64")\n", + CERROR("removing an already-removed handle (%#llx)\n", h->h_cookie); return; } - CDEBUG(D_INFO, "removing object %p with handle "LPX64" from hash\n", + CDEBUG(D_INFO, "removing object %p with handle %#llx from hash\n", h, h->h_cookie); spin_lock(&h->h_lock); @@ -230,7 +230,7 @@ static int cleanup_all_handles(void) spin_lock(&handle_hash[i].lock); list_for_each_entry_rcu(h, &(handle_hash[i].head), h_link) { - CERROR("force clean handle "LPX64" addr %p ops %p\n", + CERROR("force clean handle %#llx addr %p ops %p\n", h->h_cookie, h, h->h_ops); class_handle_unhash_nolock(h); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c index df4936ad2375..64b2f35e224f 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c @@ -36,13 +36,13 @@ #define DEBUG_SUBSYSTEM S_RPC -#include <obd.h> -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_lib.h> -#include <lustre_ha.h> -#include <lustre_net.h> -#include <lprocfs_status.h> +#include "../include/obd.h" +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_lib.h" +#include "../include/lustre_ha.h" +#include "../include/lustre_net.h" +#include "../include/lprocfs_status.h" #define NIDS_MAX 32 diff --git a/drivers/staging/lustre/lustre/obdclass/md_attrs.c b/drivers/staging/lustre/lustre/obdclass/md_attrs.c index f080cceb384c..d9e6348de4fa 100644 --- a/drivers/staging/lustre/lustre/obdclass/md_attrs.c +++ b/drivers/staging/lustre/lustre/obdclass/md_attrs.c @@ -27,9 +27,9 @@ * Author: Johann Lombardi <johann.lombardi@intel.com> */ -#include <lustre/lustre_idl.h> -#include <obd.h> -#include <md_object.h> +#include "../include/lustre/lustre_idl.h" +#include "../include/obd.h" +#include "../include/md_object.h" /** * Initialize new \a lma. Only fid is stored. diff --git a/drivers/staging/lustre/lustre/obdclass/mea.c b/drivers/staging/lustre/lustre/obdclass/mea.c index c4f0dbc23611..d6ce084da902 100644 --- a/drivers/staging/lustre/lustre/obdclass/mea.c +++ b/drivers/staging/lustre/lustre/obdclass/mea.c @@ -33,13 +33,13 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#include <obd_class.h> +#include "../include/obd_class.h" #include <linux/kmod.h> /* for request_module() */ #include <linux/module.h> #include <linux/slab.h> #include <linux/pagemap.h> -#include <lprocfs_status.h> -#include <lustre/lustre_idl.h> +#include "../include/lprocfs_status.h" +#include "../include/lustre/lustre_idl.h" static int mea_last_char_hash(int count, char *name, int namelen) { diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 2d5777699f47..0d81d3232f31 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -39,11 +39,11 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#include <obd_class.h> +#include "../include/obd_class.h" #include <linux/string.h> -#include <lustre_log.h> -#include <lprocfs_status.h> -#include <lustre_param.h> +#include "../include/lustre_log.h" +#include "../include/lprocfs_status.h" +#include "../include/lustre_param.h" #include "llog_internal.h" @@ -1093,9 +1093,9 @@ int class_process_config(struct lustre_cfg *lcfg) GOTO(out, err); } case LCFG_ADD_UUID: { - CDEBUG(D_IOCTL, "adding mapping from uuid %s to nid "LPX64 - " (%s)\n", lustre_cfg_string(lcfg, 1), - lcfg->lcfg_nid, libcfs_nid2str(lcfg->lcfg_nid)); + CDEBUG(D_IOCTL, "adding mapping from uuid %s to nid %#llx (%s)\n", + lustre_cfg_string(lcfg, 1), lcfg->lcfg_nid, + libcfs_nid2str(lcfg->lcfg_nid)); err = class_add_uuid(lustre_cfg_string(lcfg, 1), lcfg->lcfg_nid); GOTO(out, err); @@ -1161,7 +1161,7 @@ int class_process_config(struct lustre_cfg *lcfg) char *tmp; /* llite has no obd */ if ((class_match_param(lustre_cfg_string(lcfg, 1), - PARAM_LLITE, 0) == 0) && + PARAM_LLITE, NULL) == 0) && client_process_config) { err = (*client_process_config)(lcfg); GOTO(out, err); @@ -1303,8 +1303,8 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, /* Search proc entries */ while (lvars[j].name) { var = &lvars[j]; - if (class_match_param(key, (char *)var->name, 0) == 0 && - keylen == strlen(var->name)) { + if (class_match_param(key, (char *)var->name, NULL) == 0 + && keylen == strlen(var->name)) { matched++; rc = -EROFS; if (var->fops && var->fops->write) { @@ -1614,7 +1614,7 @@ int class_config_parse_rec(struct llog_rec_hdr *rec, char *buf, int size) ptr += snprintf(ptr, end-ptr, "num=%#08x ", lcfg->lcfg_num); if (lcfg->lcfg_nid) - ptr += snprintf(ptr, end-ptr, "nid=%s("LPX64")\n ", + ptr += snprintf(ptr, end-ptr, "nid=%s(%#llx)\n ", libcfs_nid2str(lcfg->lcfg_nid), lcfg->lcfg_nid); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index a034aee37fc1..d972f71c9d97 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -45,13 +45,13 @@ #define D_MOUNT (D_SUPER|D_CONFIG/*|D_WARNING */) #define PRINT_CMD CDEBUG -#include <obd.h> -#include <lvfs.h> -#include <obd_class.h> -#include <lustre/lustre_user.h> -#include <lustre_log.h> -#include <lustre_disk.h> -#include <lustre_param.h> +#include "../include/obd.h" +#include "../include/lvfs.h" +#include "../include/obd_class.h" +#include "../include/lustre/lustre_user.h" +#include "../include/lustre_log.h" +#include "../include/lustre_disk.h" +#include "../include/lustre_param.h" static int (*client_fill_super)(struct super_block *sb, struct vfsmount *mnt); @@ -219,7 +219,6 @@ int lustre_start_mgc(struct super_block *sb) lnet_nid_t nid; char *mgcname = NULL, *niduuid = NULL, *mgssec = NULL; char *ptr; - int recov_bk; int rc = 0, i = 0, j, len; LASSERT(lsi->lsi_lmd); @@ -269,6 +268,8 @@ int lustre_start_mgc(struct super_block *sb) obd = class_name2obd(mgcname); if (obd && !obd->obd_stopping) { + int recov_bk; + rc = obd_set_info_async(NULL, obd->obd_self_export, strlen(KEY_MGSSEC), KEY_MGSSEC, strlen(mgssec), mgssec, NULL); @@ -429,16 +430,6 @@ int lustre_start_mgc(struct super_block *sb) so we know when we can get rid of the mgc. */ atomic_set(&obd->u.cli.cl_mgc_refcount, 1); - /* Try all connections, but only once. */ - recov_bk = 1; - rc = obd_set_info_async(NULL, obd->obd_self_export, - sizeof(KEY_INIT_RECOV_BACKUP), - KEY_INIT_RECOV_BACKUP, - sizeof(recov_bk), &recov_bk, NULL); - if (rc) - /* nonfatal */ - CWARN("can't set %s %d\n", KEY_INIT_RECOV_BACKUP, rc); - /* We connect to the MGS at setup, and don't disconnect until cleanup */ data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_AT | OBD_CONNECT_FULL20 | OBD_CONNECT_IMP_RECOV | @@ -1225,7 +1216,9 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) if (lmd_is_client(lmd)) { CDEBUG(D_MOUNT, "Mounting client %s\n", lmd->lmd_profile); - if (!client_fill_super) { + if (client_fill_super == NULL) + request_module("lustre"); + if (client_fill_super == NULL) { LCONSOLE_ERROR_MSG(0x165, "Nothing registered for " "client mount! Is the 'lustre' " "module loaded?\n"); @@ -1308,6 +1301,7 @@ struct file_system_type lustre_fs_type = { .fs_flags = FS_BINARY_MOUNTDATA | FS_REQUIRES_DEV | FS_HAS_FIEMAP | FS_RENAME_DOES_D_MOVE, }; +MODULE_ALIAS_FS("lustre"); int lustre_register_fs(void) { diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index 3b1b28afd6b1..c9fa36b17919 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/obdo.c @@ -42,8 +42,8 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <obd_class.h> -#include <lustre/lustre_idl.h> +#include "../include/obd_class.h" +#include "../include/lustre/lustre_idl.h" void obdo_set_parent_fid(struct obdo *dst, const struct lu_fid *parent) { @@ -117,7 +117,7 @@ EXPORT_SYMBOL(obdo_from_inode); void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_flag valid) { - CDEBUG(D_INODE, "src obdo "DOSTID" valid "LPX64", dst obdo "DOSTID"\n", + CDEBUG(D_INODE, "src obdo "DOSTID" valid %#llx, dst obdo "DOSTID"\n", POSTID(&src->o_oi), src->o_valid, POSTID(&dst->o_oi)); if (valid & OBD_MD_FLATIME) dst->o_atime = src->o_atime; @@ -252,7 +252,7 @@ void iattr_from_obdo(struct iattr *attr, struct obdo *oa, obd_flag valid) valid &= oa->o_valid; if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME)) - CDEBUG(D_INODE, "valid "LPX64", new time "LPU64"/"LPU64"\n", + CDEBUG(D_INODE, "valid %#llx, new time %llu/%llu\n", oa->o_valid, oa->o_mtime, oa->o_ctime); attr->ia_valid = 0; diff --git a/drivers/staging/lustre/lustre/obdclass/statfs_pack.c b/drivers/staging/lustre/lustre/obdclass/statfs_pack.c index c3b7a78dba50..33b1a83f4014 100644 --- a/drivers/staging/lustre/lustre/obdclass/statfs_pack.c +++ b/drivers/staging/lustre/lustre/obdclass/statfs_pack.c @@ -41,10 +41,10 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <lustre_export.h> -#include <lustre_net.h> -#include <obd_support.h> -#include <obd_class.h> +#include "../include/lustre_export.h" +#include "../include/lustre_net.h" +#include "../include/obd_support.h" +#include "../include/obd_class.h" void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs) { diff --git a/drivers/staging/lustre/lustre/obdclass/uuid.c b/drivers/staging/lustre/lustre/obdclass/uuid.c index e87a19900770..ff0a01bcf8da 100644 --- a/drivers/staging/lustre/lustre/obdclass/uuid.c +++ b/drivers/staging/lustre/lustre/obdclass/uuid.c @@ -38,10 +38,10 @@ #define DEBUG_SUBSYSTEM S_CLASS -# include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd_support.h> -#include <obd_class.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" static inline __u32 consume(int nob, __u8 **ptr) diff --git a/drivers/staging/lustre/lustre/obdecho/Makefile b/drivers/staging/lustre/lustre/obdecho/Makefile index 4c48e2432f9b..672028fc7f6e 100644 --- a/drivers/staging/lustre/lustre/obdecho/Makefile +++ b/drivers/staging/lustre/lustre/obdecho/Makefile @@ -1,5 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += obdecho.o obdecho-y := echo_client.o lproc_echo.o - - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/obdecho/echo.c b/drivers/staging/lustre/lustre/obdecho/echo.c index 96a807f82ec1..dae1599af384 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo.c +++ b/drivers/staging/lustre/lustre/obdecho/echo.c @@ -41,11 +41,11 @@ #define DEBUG_SUBSYSTEM S_ECHO -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_debug.h> -#include <lustre_dlm.h> -#include <lprocfs_status.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_debug.h" +#include "../include/lustre_dlm.h" +#include "../include/lprocfs_status.h" #include "echo_internal.h" @@ -120,18 +120,18 @@ static int echo_create(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd = class_exp2obd(exp); if (!obd) { - CERROR("invalid client cookie "LPX64"\n", + CERROR("invalid client cookie %#llx\n", exp->exp_handle.h_cookie); return -EINVAL; } - if (!(oa->o_mode && S_IFMT)) { + if (!(oa->o_mode & S_IFMT)) { CERROR("echo obd: no type!\n"); return -ENOENT; } if (!(oa->o_valid & OBD_MD_FLTYPE)) { - CERROR("invalid o_valid "LPX64"\n", oa->o_valid); + CERROR("invalid o_valid %#llx\n", oa->o_valid); return -EINVAL; } @@ -150,13 +150,13 @@ static int echo_destroy(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd = class_exp2obd(exp); if (!obd) { - CERROR("invalid client cookie "LPX64"\n", + CERROR("invalid client cookie %#llx\n", exp->exp_handle.h_cookie); return -EINVAL; } if (!(oa->o_valid & OBD_MD_FLID)) { - CERROR("obdo missing FLID valid flag: "LPX64"\n", oa->o_valid); + CERROR("obdo missing FLID valid flag: %#llx\n", oa->o_valid); return -EINVAL; } @@ -176,13 +176,13 @@ static int echo_getattr(const struct lu_env *env, struct obd_export *exp, obd_id id = ostid_id(&oinfo->oi_oa->o_oi); if (!obd) { - CERROR("invalid client cookie "LPX64"\n", + CERROR("invalid client cookie %#llx\n", exp->exp_handle.h_cookie); return -EINVAL; } if (!(oinfo->oi_oa->o_valid & OBD_MD_FLID)) { - CERROR("obdo missing FLID valid flag: "LPX64"\n", + CERROR("obdo missing FLID valid flag: %#llx\n", oinfo->oi_oa->o_valid); return -EINVAL; } @@ -200,13 +200,13 @@ static int echo_setattr(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd = class_exp2obd(exp); if (!obd) { - CERROR("invalid client cookie "LPX64"\n", + CERROR("invalid client cookie %#llx\n", exp->exp_handle.h_cookie); return -EINVAL; } if (!(oinfo->oi_oa->o_valid & OBD_MD_FLID)) { - CERROR("obdo missing FLID valid flag: "LPX64"\n", + CERROR("obdo missing FLID valid flag: %#llx\n", oinfo->oi_oa->o_valid); return -EINVAL; } @@ -327,7 +327,7 @@ static int echo_map_nb_to_lb(struct obdo *oa, struct obd_ioobj *obj, } } - CDEBUG(D_PAGE, "$$$$ get page %p @ "LPU64" for %d\n", + CDEBUG(D_PAGE, "$$$$ get page %p @ %llu for %d\n", res->page, res->lnb_file_offset, res->len); if (cmd & OBD_BRW_READ) @@ -365,7 +365,7 @@ static int echo_finalize_lb(struct obdo *oa, struct obd_ioobj *obj, void *addr; if (page == NULL) { - CERROR("null page objid "LPU64":%p, buf %d/%d\n", + CERROR("null page objid %llu:%p, buf %d/%d\n", ostid_id(&obj->ioo_oid), page, i, obj->ioo_bufcnt); return -EFAULT; @@ -373,7 +373,7 @@ static int echo_finalize_lb(struct obdo *oa, struct obd_ioobj *obj, addr = kmap(page); - CDEBUG(D_PAGE, "$$$$ use page %p, addr %p@"LPU64"\n", + CDEBUG(D_PAGE, "$$$$ use page %p, addr %p@%llu\n", res->page, addr, res->lnb_file_offset); if (verify) { diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index cdc46719bbd4..f1847f3f579d 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -35,18 +35,18 @@ */ #define DEBUG_SUBSYSTEM S_ECHO -#include <linux/libcfs/libcfs.h> - -#include <obd.h> -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_debug.h> -#include <lprocfs_status.h> -#include <cl_object.h> -#include <md_object.h> -#include <lustre_fid.h> -#include <lustre_acl.h> -#include <lustre_net.h> +#include "../../include/linux/libcfs/libcfs.h" + +#include "../include/obd.h" +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_debug.h" +#include "../include/lprocfs_status.h" +#include "../include/cl_object.h" +#include "../include/md_object.h" +#include "../include/lustre_fid.h" +#include "../include/lustre_acl.h" +#include "../include/lustre_net.h" #include "echo_internal.h" @@ -1228,7 +1228,7 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed, spin_lock(&ec->ec_lock); list_for_each (el, &ec->ec_locks) { ecl = list_entry (el, struct echo_lock, el_chain); - CDEBUG(D_INFO, "ecl: %p, cookie: "LPX64"\n", ecl, ecl->el_cookie); + CDEBUG(D_INFO, "ecl: %p, cookie: %#llx\n", ecl, ecl->el_cookie); found = (ecl->el_cookie == cookie); if (found) { if (atomic_dec_and_test(&ecl->el_refcount)) @@ -1430,7 +1430,7 @@ echo_copyin_lsm (struct echo_device *ed, struct lov_stripe_md *lsm, static inline void echo_md_build_name(struct lu_name *lname, char *name, __u64 id) { - sprintf(name, LPU64, id); + sprintf(name, "%llu", id); lname->ln_name = name; lname->ln_namelen = strlen(name); } @@ -1540,7 +1540,7 @@ int echo_attr_get_complex(const struct lu_env *env, struct md_object *next, #endif out: ma->ma_need = need; - CDEBUG(D_INODE, "after getattr rc = %d, ma_valid = "LPX64" ma_lmm=%p\n", + CDEBUG(D_INODE, "after getattr rc = %d, ma_valid = %#llx ma_lmm=%p\n", rc, ma->ma_valid, ma->ma_lmm); return rc; } @@ -2408,7 +2408,7 @@ static int echo_client_page_debug_check(struct lov_stripe_md *lsm, addr + delta, OBD_ECHO_BLOCK_SIZE, stripe_off, stripe_id); if (rc2 != 0) { - CERROR ("Error in echo object "LPX64"\n", id); + CERROR ("Error in echo object %#llx\n", id); rc = rc2; } } @@ -2703,7 +2703,7 @@ echo_client_enqueue(struct obd_export *exp, struct obdo *oa, rc = cl_echo_enqueue(eco, offset, end, mode, &ulh->cookie); if (rc == 0) { oa->o_valid |= OBD_MD_FLHANDLE; - CDEBUG(D_INFO, "Cookie is "LPX64"\n", ulh->cookie); + CDEBUG(D_INFO, "Cookie is %#llx\n", ulh->cookie); } echo_put_object(eco); return rc; @@ -2718,7 +2718,7 @@ echo_client_cancel(struct obd_export *exp, struct obdo *oa) if ((oa->o_valid & OBD_MD_FLHANDLE) == 0) return -EINVAL; - CDEBUG(D_INFO, "Cookie is "LPX64"\n", cookie); + CDEBUG(D_INFO, "Cookie is %#llx\n", cookie); return cl_echo_cancel(ed, cookie); } @@ -3084,7 +3084,7 @@ static int echo_client_disconnect(struct obd_export *exp) rc = obd_cancel(ec->ec_exp, ecl->ecl_object->eco_lsm, ecl->ecl_mode, &ecl->ecl_lock_handle); - CDEBUG (D_INFO, "Cancel lock on object "LPX64" on disconnect " + CDEBUG (D_INFO, "Cancel lock on object %#llx on disconnect " "(%d)\n", ecl->ecl_object->eco_id, rc); echo_put_object (ecl->ecl_object); @@ -3113,7 +3113,7 @@ static struct obd_ops echo_client_obd_ops = { int echo_client_init(void) { - struct lprocfs_static_vars lvars = { 0 }; + struct lprocfs_static_vars lvars = { NULL }; int rc; lprocfs_echo_init_vars(&lvars); diff --git a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c b/drivers/staging/lustre/lustre/obdecho/lproc_echo.c index 8fe9245a8aad..1d3bf6c93129 100644 --- a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c +++ b/drivers/staging/lustre/lustre/obdecho/lproc_echo.c @@ -33,25 +33,25 @@ */ #define DEBUG_SUBSYSTEM S_ECHO -#include <lprocfs_status.h> -#include <obd_class.h> +#include "../include/lprocfs_status.h" +#include "../include/obd_class.h" -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) LPROC_SEQ_FOPS_RO_TYPE(echo, uuid); static struct lprocfs_vars lprocfs_echo_obd_vars[] = { { "uuid", &echo_uuid_fops, NULL, 0 }, - { 0 } + { NULL } }; LPROC_SEQ_FOPS_RO_TYPE(echo, numrefs); static struct lprocfs_vars lprocfs_echo_module_vars[] = { { "num_refs", &echo_numrefs_fops, NULL, 0 }, - { 0 } + { NULL } }; void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_echo_module_vars; - lvars->obd_vars = lprocfs_echo_obd_vars; + lvars->module_vars = lprocfs_echo_module_vars; + lvars->obd_vars = lprocfs_echo_obd_vars; } -#endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS */ diff --git a/drivers/staging/lustre/lustre/osc/Makefile b/drivers/staging/lustre/lustre/osc/Makefile index 4488162d228a..54927fba4eb4 100644 --- a/drivers/staging/lustre/lustre/osc/Makefile +++ b/drivers/staging/lustre/lustre/osc/Makefile @@ -2,7 +2,3 @@ obj-$(CONFIG_LUSTRE_FS) += osc.o osc-y := osc_request.o osc_dev.o osc_object.o \ osc_page.o osc_lock.o osc_io.o osc_quota.o osc_cache.o osc-$(CONFIG_PROC_FS) += lproc_osc.o - - - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 0cadfcd92262..2ab403548b5e 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -36,9 +36,9 @@ #define DEBUG_SUBSYSTEM S_CLASS #include <asm/statfs.h> -#include <obd_cksum.h> -#include <obd_class.h> -#include <lprocfs_status.h> +#include "../include/obd_cksum.h" +#include "../include/obd_class.h" +#include "../include/lprocfs_status.h" #include <linux/seq_file.h> #include "osc_internal.h" @@ -693,11 +693,11 @@ static int osc_stats_seq_show(struct seq_file *seq, void *v) seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", now.tv_sec, (unsigned long)now.tv_usec); - seq_printf(seq, "lockless_write_bytes\t\t"LPU64"\n", + seq_printf(seq, "lockless_write_bytes\t\t%llu\n", stats->os_lockless_writes); - seq_printf(seq, "lockless_read_bytes\t\t"LPU64"\n", + seq_printf(seq, "lockless_read_bytes\t\t%llu\n", stats->os_lockless_reads); - seq_printf(seq, "lockless_truncate\t\t"LPU64"\n", + seq_printf(seq, "lockless_truncate\t\t%llu\n", stats->os_lockless_truncates); return 0; } diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 00f38eeb5786..57d7dba23479 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -871,7 +871,8 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, LASSERT(sanity_check_nolock(ext) == 0); /* `Kick' this extent only if the caller is waiting for it to be * written out. */ - if (state == OES_INV && !ext->oe_urgent && !ext->oe_hp) { + if (state == OES_INV && !ext->oe_urgent && !ext->oe_hp && + !ext->oe_trunc_pending) { if (ext->oe_state == OES_ACTIVE) { ext->oe_urgent = 1; } else if (ext->oe_state == OES_CACHE) { @@ -922,8 +923,8 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, int rc = 0; LASSERT(sanity_check(ext) == 0); - LASSERT(ext->oe_state == OES_TRUNC); - LASSERT(!ext->oe_urgent); + EASSERT(ext->oe_state == OES_TRUNC, ext); + EASSERT(!ext->oe_urgent, ext); /* Request new lu_env. * We can't use that env from osc_cache_truncate_start() because @@ -2153,7 +2154,7 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, INIT_LIST_HEAD(&oap->oap_rpc_item); spin_lock_init(&oap->oap_lock); - CDEBUG(D_INFO, "oap %p page %p obj off "LPU64"\n", + CDEBUG(D_INFO, "oap %p page %p obj off %llu\n", oap, page, oap->oap_obj_off); return 0; } @@ -2594,7 +2595,7 @@ again: break; } - OSC_EXTENT_DUMP(D_CACHE, ext, "try to trunc:"LPU64".\n", size); + OSC_EXTENT_DUMP(D_CACHE, ext, "try to trunc:%llu.\n", size); osc_extent_get(ext); if (ext->oe_state == OES_ACTIVE) { @@ -2655,7 +2656,7 @@ again: LASSERT(oio->oi_trunc == NULL); oio->oi_trunc = osc_extent_get(ext); OSC_EXTENT_DUMP(D_CACHE, ext, - "trunc at "LPU64"\n", size); + "trunc at %llu\n", size); } osc_extent_put(env, ext); } diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index e74b7bb9776c..2d1f977dca36 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -46,13 +46,13 @@ #ifndef OSC_CL_INTERNAL_H #define OSC_CL_INTERNAL_H -# include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd.h> +#include "../include/obd.h" /* osc_build_res_name() */ -#include <obd_ost.h> -#include <cl_object.h> -#include <lclient.h> +#include "../include/obd_ost.h" +#include "../include/cl_object.h" +#include "../include/lclient.h" #include "osc_internal.h" /** \defgroup osc osc @@ -118,7 +118,7 @@ struct osc_object { * True if locking against this stripe got -EUSERS. */ int oo_contended; - cfs_time_t oo_contention_time; + unsigned long oo_contention_time; /** * List of pages in transfer. */ @@ -387,7 +387,7 @@ struct osc_page { /** * Submit time - the time when the page is starting RPC. For debugging. */ - cfs_time_t ops_submit_time; + unsigned long ops_submit_time; /** * A lock of which we hold a reference covers this page. Only used by diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index a7c1ec0d56fe..4935fc7c0706 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -41,7 +41,7 @@ #define DEBUG_SUBSYSTEM S_OSC /* class_name2obd() */ -#include <obd_class.h> +#include "../include/obd_class.h" #include "osc_cl_internal.h" @@ -61,32 +61,32 @@ struct lu_kmem_descr osc_caches[] = { { .ckd_cache = &osc_lock_kmem, .ckd_name = "osc_lock_kmem", - .ckd_size = sizeof (struct osc_lock) + .ckd_size = sizeof(struct osc_lock) }, { .ckd_cache = &osc_object_kmem, .ckd_name = "osc_object_kmem", - .ckd_size = sizeof (struct osc_object) + .ckd_size = sizeof(struct osc_object) }, { .ckd_cache = &osc_thread_kmem, .ckd_name = "osc_thread_kmem", - .ckd_size = sizeof (struct osc_thread_info) + .ckd_size = sizeof(struct osc_thread_info) }, { .ckd_cache = &osc_session_kmem, .ckd_name = "osc_session_kmem", - .ckd_size = sizeof (struct osc_session) + .ckd_size = sizeof(struct osc_session) }, { .ckd_cache = &osc_req_kmem, .ckd_name = "osc_req_kmem", - .ckd_size = sizeof (struct osc_req) + .ckd_size = sizeof(struct osc_req) }, { .ckd_cache = &osc_extent_kmem, .ckd_name = "osc_extent_kmem", - .ckd_size = sizeof (struct osc_extent) + .ckd_size = sizeof(struct osc_extent) }, { .ckd_cache = &osc_quota_kmem, @@ -132,6 +132,7 @@ static void osc_key_fini(const struct lu_context *ctx, struct lu_context_key *key, void *data) { struct osc_thread_info *info = data; + OBD_SLAB_FREE_PTR(info, osc_thread_kmem); } @@ -156,6 +157,7 @@ static void osc_session_fini(const struct lu_context *ctx, struct lu_context_key *key, void *data) { struct osc_session *info = data; + OBD_SLAB_FREE_PTR(info, osc_session_kmem); } diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index efc5db47c260..f67a70083621 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -97,7 +97,7 @@ void osc_update_next_shrink(struct client_obd *cli); /* * cl integration. */ -#include <cl_object.h> +#include "../include/cl_object.h" extern struct ptlrpc_request_set *PTLRPCD_SET; @@ -112,7 +112,7 @@ int osc_cancel_base(struct lustre_handle *lockh, __u32 mode); int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, __u32 type, ldlm_policy_data_t *policy, __u32 mode, - int *flags, void *data, struct lustre_handle *lockh, + __u64 *flags, void *data, struct lustre_handle *lockh, int unref); int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, @@ -136,7 +136,7 @@ extern spinlock_t osc_ast_guard; int osc_cleanup(struct obd_device *obd); int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) int lproc_osc_attach_seqstat(struct obd_device *dev); void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars); #else diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 09e06eb08530..54fe836a64cd 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -204,7 +204,7 @@ static void osc_page_touch_at(const struct lu_env *env, * * here */ - CDEBUG(D_INODE, "stripe KMS %sincreasing "LPU64"->"LPU64" "LPU64"\n", + CDEBUG(D_INODE, "stripe KMS %sincreasing %llu->%llu %llu\n", kms > loi->loi_kms ? "" : "not ", loi->loi_kms, kms, loi->loi_lvb.lvb_size); @@ -355,7 +355,7 @@ static int trunc_check_cb(const struct lu_env *env, struct cl_io *io, if (oap->oap_cmd & OBD_BRW_WRITE && !list_empty(&oap->oap_pending_item)) - CL_PAGE_DEBUG(D_ERROR, env, page, "exists " LPU64 "/%s.\n", + CL_PAGE_DEBUG(D_ERROR, env, page, "exists %llu/%s.\n", start, current->comm); { diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index a46129bec17a..8138856fda8c 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -40,9 +40,9 @@ #define DEBUG_SUBSYSTEM S_OSC -# include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" /* fid_build_reg_res_name() */ -#include <lustre_fid.h> +#include "../include/lustre_fid.h" #include "osc_cl_internal.h" @@ -369,20 +369,19 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, if (size > dlmlock->l_policy_data.l_extent.end) size = dlmlock->l_policy_data.l_extent.end + 1; if (size >= oinfo->loi_kms) { - LDLM_DEBUG(dlmlock, "lock acquired, setting rss="LPU64 - ", kms="LPU64, lvb->lvb_size, size); + LDLM_DEBUG(dlmlock, "lock acquired, setting rss=%llu, kms=%llu", + lvb->lvb_size, size); valid |= CAT_KMS; attr->cat_kms = size; } else { - LDLM_DEBUG(dlmlock, "lock acquired, setting rss=" - LPU64"; leaving kms="LPU64", end="LPU64, + LDLM_DEBUG(dlmlock, "lock acquired, setting rss=%llu; leaving kms=%llu, end=%llu", lvb->lvb_size, oinfo->loi_kms, dlmlock->l_policy_data.l_extent.end); } ldlm_lock_allow_match_locked(dlmlock); } else if (rc == -ENAVAIL && olck->ols_glimpse) { - CDEBUG(D_INODE, "glimpsed, setting rss="LPU64"; leaving" - " kms="LPU64"\n", lvb->lvb_size, oinfo->loi_kms); + CDEBUG(D_INODE, "glimpsed, setting rss=%llu; leaving kms=%llu\n", + lvb->lvb_size, oinfo->loi_kms); } else valid = 0; @@ -1400,7 +1399,7 @@ static int osc_lock_print(const struct lu_env *env, void *cookie, /* * XXX print ldlm lock and einfo properly. */ - (*p)(env, cookie, "%p %#16llx "LPX64" %d %p ", + (*p)(env, cookie, "%p %#16llx %#llx %d %p ", lock->ols_lock, lock->ols_flags, lock->ols_handle.cookie, lock->ols_state, lock->ols_owner); osc_lvb_print(env, cookie, p, &lock->ols_lvb); diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index f9bfdc820125..69000584619d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -128,8 +128,7 @@ static void osc_object_free(const struct lu_env *env, struct lu_object *obj) int osc_lvb_print(const struct lu_env *env, void *cookie, lu_printer_t p, const struct ost_lvb *lvb) { - return (*p)(env, cookie, "size: "LPU64" mtime: "LPU64" atime: "LPU64" " - "ctime: "LPU64" blocks: "LPU64, + return (*p)(env, cookie, "size: %llu mtime: %llu atime: %llu ctime: %llu blocks: %llu", lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); } @@ -142,8 +141,7 @@ static int osc_object_print(const struct lu_env *env, void *cookie, struct osc_async_rc *ar = &oinfo->loi_ar; (*p)(env, cookie, "id: "DOSTID" " - "idx: %d gen: %d kms_valid: %u kms "LPU64" " - "rc: %d force_sync: %d min_xid: "LPU64" ", + "idx: %d gen: %d kms_valid: %u kms %llu rc: %d force_sync: %d min_xid: %llu ", POSTID(&oinfo->loi_oi), oinfo->loi_ost_idx, oinfo->loi_ost_gen, oinfo->loi_kms_valid, oinfo->loi_kms, ar->ar_rc, ar->ar_force_sync, ar->ar_min_xid); @@ -179,7 +177,7 @@ int osc_attr_set(const struct lu_env *env, struct cl_object *obj, if (valid & CAT_BLOCKS) lvb->lvb_blocks = attr->cat_blocks; if (valid & CAT_KMS) { - CDEBUG(D_CACHE, "set kms from "LPU64"to "LPU64"\n", + CDEBUG(D_CACHE, "set kms from %llu to %llu\n", oinfo->loi_kms, (__u64)attr->cat_kms); loi_kms_set(oinfo, attr->cat_kms); } @@ -213,8 +211,8 @@ int osc_object_is_contended(struct osc_object *obj) { struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev); int osc_contention_time = dev->od_contention_time; - cfs_time_t cur_time = cfs_time_current(); - cfs_time_t retry_time; + unsigned long cur_time = cfs_time_current(); + unsigned long retry_time; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION)) return 1; diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 96cb6e2b9c4e..fcd079b1af01 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -70,7 +70,7 @@ static int osc_page_is_dlocked(const struct lu_env *env, struct lustre_handle *lockh; ldlm_policy_data_t *policy; ldlm_mode_t dlmmode; - int flags; + __u64 flags; might_sleep(); @@ -352,7 +352,7 @@ static const char *osc_list(struct list_head *head) return list_empty(head) ? "-" : "+"; } -static inline cfs_time_t osc_submit_duration(struct osc_page *opg) +static inline unsigned long osc_submit_duration(struct osc_page *opg) { if (opg->ops_submit_time == 0) return 0; @@ -371,7 +371,7 @@ static int osc_page_print(const struct lu_env *env, return (*printer)(env, cookie, LUSTRE_OSC_NAME"-page@%p: " "1< %#x %d %u %s %s > " - "2< "LPU64" %u %u %#x %#x | %p %p %p > " + "2< %llu %u %u %#x %#x | %p %p %p > " "3< %s %p %d %lu %d > " "4< %d %d %d %lu %s | %s %s %s %s > " "5< %s %s %s %s | %d %s | %d %s %s>\n", diff --git a/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c index 0235fabaaffe..3563809072b4 100644 --- a/drivers/staging/lustre/lustre/osc/osc_quota.c +++ b/drivers/staging/lustre/lustre/osc/osc_quota.c @@ -28,7 +28,7 @@ * Code originally extracted from quota directory */ -#include <obd_ost.h> +#include "../include/obd_ost.h" #include "osc_internal.h" static inline struct osc_quota_info *osc_oqi_alloc(obd_uid id) diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 294db843012b..fb0d9fb9cebc 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -36,21 +36,21 @@ #define DEBUG_SUBSYSTEM S_OSC -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <lustre_dlm.h> -#include <lustre_net.h> -#include <lustre/lustre_user.h> -#include <obd_cksum.h> -#include <obd_ost.h> +#include "../include/lustre_dlm.h" +#include "../include/lustre_net.h" +#include "../include/lustre/lustre_user.h" +#include "../include/obd_cksum.h" +#include "../include/obd_ost.h" -#include <lustre_ha.h> -#include <lprocfs_status.h> -#include <lustre_log.h> -#include <lustre_debug.h> -#include <lustre_param.h> -#include <lustre_fid.h> +#include "../include/lustre_ha.h" +#include "../include/lprocfs_status.h" +#include "../include/lustre_log.h" +#include "../include/lustre_debug.h" +#include "../include/lustre_param.h" +#include "../include/lustre_fid.h" #include "osc_internal.h" #include "osc_cl_internal.h" @@ -483,7 +483,7 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, } } - CDEBUG(D_HA, "transno: "LPD64"\n", + CDEBUG(D_HA, "transno: %lld\n", lustre_msg_get_transno(req->rq_repmsg)); out_req: ptlrpc_req_finished(req); @@ -635,7 +635,7 @@ static int osc_sync(const struct lu_env *env, struct obd_export *exp, * locks added to @cancels list. */ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa, struct list_head *cancels, - ldlm_mode_t mode, int lock_flags) + ldlm_mode_t mode, __u64 lock_flags) { struct ldlm_namespace *ns = exp->exp_obd->obd_namespace; struct ldlm_res_id res_id; @@ -836,7 +836,7 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, oa->o_dropped = cli->cl_lost_grant; cli->cl_lost_grant = 0; client_obd_list_unlock(&cli->cl_loi_list_lock); - CDEBUG(D_CACHE,"dirty: "LPU64" undirty: %u dropped %u grant: "LPU64"\n", + CDEBUG(D_CACHE,"dirty: %llu undirty: %u dropped %u grant: %llu\n", oa->o_dirty, oa->o_undirty, oa->o_dropped, oa->o_grant); } @@ -859,7 +859,7 @@ static void __osc_update_grant(struct client_obd *cli, obd_size grant) static void osc_update_grant(struct client_obd *cli, struct ost_body *body) { if (body->oa.o_valid & OBD_MD_FLGRANT) { - CDEBUG(D_CACHE, "got "LPU64" extra grant\n", body->oa.o_grant); + CDEBUG(D_CACHE, "got %llu extra grant\n", body->oa.o_grant); __osc_update_grant(cli, body->oa.o_grant); } } @@ -966,8 +966,8 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) static int osc_should_shrink_grant(struct client_obd *client) { - cfs_time_t time = cfs_time_current(); - cfs_time_t next_shrink = client->cl_next_shrink_grant; + unsigned long time = cfs_time_current(); + unsigned long next_shrink = client->cl_next_shrink_grant; if ((client->cl_import->imp_connect_data.ocd_connect_flags & OBD_CONNECT_GRANT_SHRINK) == 0) @@ -1313,11 +1313,11 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, ergo(i > 0 && i < page_count - 1, poff == 0 && pg->count == PAGE_CACHE_SIZE) && ergo(i == page_count - 1, poff == 0)), - "i: %d/%d pg: %p off: "LPU64", count: %u\n", + "i: %d/%d pg: %p off: %llu, count: %u\n", i, page_count, pg, pg->off, pg->count); LASSERTF(i == 0 || pg->off > pg_prev->off, - "i %d p_c %u pg %p [pri %lu ind %lu] off "LPU64 - " prev_pg %p [pri %lu ind %lu] off "LPU64"\n", + "i %d p_c %u pg %p [pri %lu ind %lu] off %llu" + " prev_pg %p [pri %lu ind %lu] off %llu\n", i, page_count, pg->pg, page_private(pg->pg), pg->pg->index, pg->off, pg_prev->pg, page_private(pg_prev->pg), @@ -1452,7 +1452,7 @@ static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer, "likely false positive due to mmap IO (bug 11742)"; LCONSOLE_ERROR_MSG(0x132, "BAD WRITE CHECKSUM: %s: from %s inode "DFID - " object "DOSTID" extent ["LPU64"-"LPU64"]\n", + " object "DOSTID" extent [%llu-%llu]\n", msg, libcfs_nid2str(peer->nid), oa->o_valid & OBD_MD_FLFID ? oa->o_parent_seq : (__u64)0, oa->o_valid & OBD_MD_FLFID ? oa->o_parent_oid : 0, @@ -1492,7 +1492,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) body->oa.o_valid & (OBD_MD_FLUSRQUOTA | OBD_MD_FLGRPQUOTA)) { unsigned int qid[MAXQUOTAS] = { body->oa.o_uid, body->oa.o_gid }; - CDEBUG(D_QUOTA, "setdq for [%u %u] with valid "LPX64", flags %x\n", + CDEBUG(D_QUOTA, "setdq for [%u %u] with valid %#llx, flags %x\n", body->oa.o_uid, body->oa.o_gid, body->oa.o_valid, body->oa.o_flags); osc_quota_setdq(cli, qid, body->oa.o_valid, body->oa.o_flags); @@ -1570,15 +1570,10 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) router = libcfs_nid2str(req->rq_bulk->bd_sender); } - if (server_cksum == ~0 && rc > 0) { - CERROR("Protocol error: server %s set the 'checksum' " - "bit, but didn't send a checksum. Not fatal, " - "but please notify on http://bugs.whamcloud.com/\n", - libcfs_nid2str(peer->nid)); - } else if (server_cksum != client_cksum) { + if (server_cksum != client_cksum) { LCONSOLE_ERROR_MSG(0x133, "%s: BAD READ CHECKSUM: from " "%s%s%s inode "DFID" object "DOSTID - " extent ["LPU64"-"LPU64"]\n", + " extent [%llu-%llu]\n", req->rq_import->imp_obd->obd_name, libcfs_nid2str(peer->nid), via, router, @@ -1644,7 +1639,7 @@ restart_bulk: if (resends) { req->rq_generation_set = 1; req->rq_import_generation = generation; - req->rq_sent = cfs_time_current_sec() + resends; + req->rq_sent = get_seconds() + resends; } rc = ptlrpc_queue_wait(req); @@ -1727,9 +1722,9 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, /* cap resend delay to the current request timeout, this is similar to * what ptlrpc does (see after_reply()) */ if (aa->aa_resends > new_req->rq_timeout) - new_req->rq_sent = cfs_time_current_sec() + new_req->rq_timeout; + new_req->rq_sent = get_seconds() + new_req->rq_timeout; else - new_req->rq_sent = cfs_time_current_sec() + aa->aa_resends; + new_req->rq_sent = get_seconds() + aa->aa_resends; new_req->rq_generation_set = 1; new_req->rq_import_generation = request->rq_import_generation; @@ -1935,8 +1930,7 @@ static int brw_interpret(const struct lu_env *env, client_should_resend(aa->aa_resends, aa->aa_cli)) { rc = osc_brw_redo_request(req, aa, rc); } else { - CERROR("%s: too many resent retries for object: " - ""LPU64":"LPU64", rc = %d.\n", + CERROR("%s: too many resent retries for object: %llu:%llu, rc = %d.\n", req->rq_import->imp_obd->obd_name, POSTID(&aa->aa_oa->o_oi), rc); } @@ -2326,7 +2320,7 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, if ((intent != 0 && rc == ELDLM_LOCK_ABORTED && agl == 0) || (rc == 0)) { *flags |= LDLM_FL_LVB_READY; - CDEBUG(D_INODE,"got kms "LPU64" blocks "LPU64" mtime "LPU64"\n", + CDEBUG(D_INODE,"got kms %llu blocks %llu mtime %llu\n", lvb->lvb_size, lvb->lvb_blocks, lvb->lvb_mtime); } @@ -2398,7 +2392,7 @@ static int osc_enqueue_interpret(const struct lu_env *env, } void osc_update_enqueue(struct lustre_handle *lov_lockhp, - struct lov_oinfo *loi, int flags, + struct lov_oinfo *loi, __u64 flags, struct ost_lvb *lvb, __u32 mode, int rc) { struct ldlm_lock *lock = ldlm_handle2lock(lov_lockhp); @@ -2414,12 +2408,11 @@ void osc_update_enqueue(struct lustre_handle *lov_lockhp, if (tmp > lock->l_policy_data.l_extent.end) tmp = lock->l_policy_data.l_extent.end + 1; if (tmp >= loi->loi_kms) { - LDLM_DEBUG(lock, "lock acquired, setting rss="LPU64 - ", kms="LPU64, loi->loi_lvb.lvb_size, tmp); + LDLM_DEBUG(lock, "lock acquired, setting rss=%llu, kms=%llu", + loi->loi_lvb.lvb_size, tmp); loi_kms_set(loi, tmp); } else { - LDLM_DEBUG(lock, "lock acquired, setting rss=" - LPU64"; leaving kms="LPU64", end="LPU64, + LDLM_DEBUG(lock, "lock acquired, setting rss=%llu; leaving kms=%llu, end=%llu", loi->loi_lvb.lvb_size, loi->loi_kms, lock->l_policy_data.l_extent.end); } @@ -2428,8 +2421,8 @@ void osc_update_enqueue(struct lustre_handle *lov_lockhp, LASSERT(lock != NULL); loi->loi_lvb = *lvb; ldlm_lock_allow_match(lock); - CDEBUG(D_INODE, "glimpsed, setting rss="LPU64"; leaving" - " kms="LPU64"\n", loi->loi_lvb.lvb_size, loi->loi_kms); + CDEBUG(D_INODE, "glimpsed, setting rss=%llu; leaving kms=%llu\n", + loi->loi_lvb.lvb_size, loi->loi_kms); rc = ELDLM_OK; } @@ -2462,7 +2455,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, struct obd_device *obd = exp->exp_obd; struct ptlrpc_request *req = NULL; int intent = *flags & LDLM_FL_HAS_INTENT; - int match_lvb = (agl != 0 ? 0 : LDLM_FL_LVB_READY); + __u64 match_lvb = (agl != 0 ? 0 : LDLM_FL_LVB_READY); ldlm_mode_t mode; int rc; @@ -2613,11 +2606,11 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, __u32 type, ldlm_policy_data_t *policy, __u32 mode, - int *flags, void *data, struct lustre_handle *lockh, + __u64 *flags, void *data, struct lustre_handle *lockh, int unref) { struct obd_device *obd = exp->exp_obd; - int lflags = *flags; + __u64 lflags = *flags; ldlm_mode_t rc; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_MATCH)) @@ -3267,7 +3260,7 @@ static int osc_reconnect(const struct lu_env *env, cli->cl_lost_grant = 0; client_obd_list_unlock(&cli->cl_loi_list_lock); - CDEBUG(D_RPCTRACE, "ocd_connect_flags: "LPX64" ocd_version: %d" + CDEBUG(D_RPCTRACE, "ocd_connect_flags: %#llx ocd_version: %d" " ocd_grant: %d, lost: %ld.\n", data->ocd_connect_flags, data->ocd_version, data->ocd_grant, lost_grant); } @@ -3428,7 +3421,7 @@ static int brw_queue_work(const struct lu_env *env, void *data) int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { - struct lprocfs_static_vars lvars = { 0 }; + struct lprocfs_static_vars lvars = { NULL }; struct client_obd *cli = &obd->u.cli; void *handler; int rc; @@ -3552,7 +3545,7 @@ int osc_cleanup(struct obd_device *obd) int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg) { - struct lprocfs_static_vars lvars = { 0 }; + struct lprocfs_static_vars lvars = { NULL }; int rc = 0; lprocfs_osc_init_vars(&lvars); @@ -3619,7 +3612,7 @@ extern struct lock_class_key osc_ast_guard_class; int __init osc_init(void) { - struct lprocfs_static_vars lvars = { 0 }; + struct lprocfs_static_vars lvars = { NULL }; int rc; /* print an address of _any_ initialized kernel symbol from this diff --git a/drivers/staging/lustre/lustre/ptlrpc/Makefile b/drivers/staging/lustre/lustre/ptlrpc/Makefile index 1c338aaf18a6..fb50cd4c65b6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/Makefile +++ b/drivers/staging/lustre/lustre/ptlrpc/Makefile @@ -18,8 +18,3 @@ ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs) ptlrpc-$(CONFIG_PROC_FS) += sec_lproc.o ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.o - -obj-$(CONFIG_PTLRPC_GSS) += gss/ - - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 7246e8ce9c19..4146e8b29a6d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -38,12 +38,12 @@ #define DEBUG_SUBSYSTEM S_RPC -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_lib.h> -#include <lustre_ha.h> -#include <lustre_import.h> -#include <lustre_req_layout.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_lib.h" +#include "../include/lustre_ha.h" +#include "../include/lustre_import.h" +#include "../include/lustre_req_layout.h" #include "ptlrpc_internal.h" @@ -283,7 +283,7 @@ static void ptlrpc_at_adj_net_latency(struct ptlrpc_request *req, { unsigned int nl, oldnl; struct imp_at *at; - time_t now = cfs_time_current_sec(); + time_t now = get_seconds(); LASSERT(req->rq_import); at = &req->rq_import->imp_at; @@ -367,13 +367,13 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) olddl = req->rq_deadline; /* server assumes it now has rq_timeout from when it sent the * early reply, so client should give it at least that long. */ - req->rq_deadline = cfs_time_current_sec() + req->rq_timeout + + req->rq_deadline = get_seconds() + req->rq_timeout + ptlrpc_at_get_net_latency(req); DEBUG_REQ(D_ADAPTTO, req, "Early reply #%d, new deadline in "CFS_DURATION_T"s " "("CFS_DURATION_T"s)", req->rq_early_count, - cfs_time_sub(req->rq_deadline, cfs_time_current_sec()), + cfs_time_sub(req->rq_deadline, get_seconds()), cfs_time_sub(req->rq_deadline, olddl)); return rc; @@ -1181,7 +1181,7 @@ static void ptlrpc_save_versions(struct ptlrpc_request *req) LASSERT(versions); lustre_msg_set_versions(reqmsg, versions); - CDEBUG(D_INFO, "Client save versions ["LPX64"/"LPX64"]\n", + CDEBUG(D_INFO, "Client save versions [%#llx/%#llx]\n", versions[0], versions[1]); } @@ -1202,7 +1202,7 @@ static int after_reply(struct ptlrpc_request *req) LASSERT(obd != NULL); /* repbuf must be unlinked */ - LASSERT(!req->rq_receiving_reply && !req->rq_must_unlink); + LASSERT(!req->rq_receiving_reply && !req->rq_reply_unlink); if (req->rq_reply_truncate) { if (ptlrpc_no_resend(req)) { @@ -1248,7 +1248,7 @@ static int after_reply(struct ptlrpc_request *req) /* retry indefinitely on EINPROGRESS */ if (lustre_msg_get_status(req->rq_repmsg) == -EINPROGRESS && ptlrpc_no_resend(req) == 0 && !req->rq_no_retry_einprogress) { - time_t now = cfs_time_current_sec(); + time_t now = get_seconds(); DEBUG_REQ(D_RPCTRACE, req, "Resending request on EINPROGRESS"); req->rq_resend = 1; @@ -1395,7 +1395,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) int rc; LASSERT(req->rq_phase == RQ_PHASE_NEW); - if (req->rq_sent && (req->rq_sent > cfs_time_current_sec()) && + if (req->rq_sent && (req->rq_sent > get_seconds()) && (!req->rq_generation_set || req->rq_import_generation == imp->imp_generation)) return 0; @@ -1451,7 +1451,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) } CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:nid:opc" - " %s:%s:%d:"LPU64":%s:%d\n", current_comm(), + " %s:%s:%d:%llu:%s:%d\n", current_comm(), imp->imp_obd->obd_uuid.uuid, lustre_msg_get_status(req->rq_reqmsg), req->rq_xid, libcfs_nid2str(imp->imp_connection->c_peer.nid), @@ -1496,6 +1496,8 @@ static inline int ptlrpc_set_producer(struct ptlrpc_request_set *set) * and no more replies are expected. * (it is possible to get less replies than requests sent e.g. due to timed out * requests or requests that we had trouble to send out) + * + * NOTE: This function contains a potential schedule point (cond_resched()). */ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) { @@ -1513,6 +1515,14 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) int unregistered = 0; int rc = 0; + /* This schedule point is mainly for the ptlrpcd caller of this + * function. Most ptlrpc sets are not long-lived and unbounded + * in length, but at the least the set used by the ptlrpcd is. + * Since the processing time is unbounded, we need to insert an + * explicit schedule point to make the thread well-behaved. + */ + cond_resched(); + if (req->rq_phase == RQ_PHASE_NEW && ptlrpc_send_new_req(req)) { force_timer_recalc = 1; @@ -1524,7 +1534,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) /* delayed resend - skip */ if (req->rq_phase == RQ_PHASE_RPC && req->rq_resend && - req->rq_sent > cfs_time_current_sec()) + req->rq_sent > get_seconds()) continue; if (!(req->rq_phase == RQ_PHASE_RPC || @@ -1688,9 +1698,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) /* ensure previous bulk fails */ old_xid = req->rq_xid; req->rq_xid = ptlrpc_next_xid(); - CDEBUG(D_HA, "resend bulk " - "old x"LPU64 - " new x"LPU64"\n", + CDEBUG(D_HA, "resend bulk old x%llu new x%llu\n", old_xid, req->rq_xid); } } @@ -1821,7 +1829,7 @@ interpret: CDEBUG(req->rq_reqmsg != NULL ? D_RPCTRACE : 0, "Completed RPC pname:cluuid:pid:xid:nid:" - "opc %s:%s:%d:"LPU64":%s:%d\n", + "opc %s:%s:%d:%llu:%s:%d\n", current_comm(), imp->imp_obd->obd_uuid.uuid, lustre_msg_get_status(req->rq_reqmsg), req->rq_xid, libcfs_nid2str(imp->imp_connection->c_peer.nid), @@ -1884,7 +1892,7 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) "/real "CFS_DURATION_T"]", req->rq_net_err ? "failed due to network error" : ((req->rq_real_sent == 0 || - cfs_time_before(req->rq_real_sent, req->rq_sent) || + time_before((unsigned long)req->rq_real_sent, (unsigned long)req->rq_sent) || cfs_time_aftereq(req->rq_real_sent, req->rq_deadline)) ? "timed out for sent delay" : "timed out for slow reply"), req->rq_sent, req->rq_real_sent); @@ -1945,7 +1953,7 @@ int ptlrpc_expired_set(void *data) { struct ptlrpc_request_set *set = data; struct list_head *tmp; - time_t now = cfs_time_current_sec(); + time_t now = get_seconds(); LASSERT(set != NULL); @@ -2028,7 +2036,7 @@ EXPORT_SYMBOL(ptlrpc_interrupted_set); int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) { struct list_head *tmp; - time_t now = cfs_time_current_sec(); + time_t now = get_seconds(); int timeout = 0; struct ptlrpc_request *req; int deadline; @@ -2346,7 +2354,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) */ if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && async && request->rq_reply_deadline == 0) - request->rq_reply_deadline = cfs_time_current_sec()+LONG_UNLINK; + request->rq_reply_deadline = get_seconds()+LONG_UNLINK; /* * Nothing left to do. @@ -2396,9 +2404,10 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) } LASSERT(rc == -ETIMEDOUT); - DEBUG_REQ(D_WARNING, request, "Unexpectedly long timeout " - "rvcng=%d unlnk=%d", request->rq_receiving_reply, - request->rq_must_unlink); + DEBUG_REQ(D_WARNING, request, + "Unexpectedly long timeout rvcng=%d unlnk=%d/%d", + request->rq_receiving_reply, + request->rq_req_unlink, request->rq_reply_unlink); } return 0; } @@ -2456,11 +2465,11 @@ void ptlrpc_free_committed(struct obd_import *imp) if (imp->imp_peer_committed_transno == imp->imp_last_transno_checked && imp->imp_generation == imp->imp_last_generation_checked) { - CDEBUG(D_INFO, "%s: skip recheck: last_committed "LPU64"\n", + CDEBUG(D_INFO, "%s: skip recheck: last_committed %llu\n", imp->imp_obd->obd_name, imp->imp_peer_committed_transno); return; } - CDEBUG(D_RPCTRACE, "%s: committing for last_committed "LPU64" gen %d\n", + CDEBUG(D_RPCTRACE, "%s: committing for last_committed %llu gen %d\n", imp->imp_obd->obd_name, imp->imp_peer_committed_transno, imp->imp_generation); @@ -2498,7 +2507,7 @@ void ptlrpc_free_committed(struct obd_import *imp) continue; } - DEBUG_REQ(D_INFO, req, "commit (last_committed "LPU64")", + DEBUG_REQ(D_INFO, req, "commit (last_committed %llu)", imp->imp_peer_committed_transno); free_req: ptlrpc_free_request(req); @@ -2530,10 +2539,19 @@ EXPORT_SYMBOL(ptlrpc_cleanup_client); void ptlrpc_resend_req(struct ptlrpc_request *req) { DEBUG_REQ(D_HA, req, "going to resend"); + spin_lock(&req->rq_lock); + + /* Request got reply but linked to the import list still. + Let ptlrpc_check_set() to process it. */ + if (ptlrpc_client_replied(req)) { + spin_unlock(&req->rq_lock); + DEBUG_REQ(D_HA, req, "it has reply, so skip it"); + return; + } + lustre_msg_set_handle(req->rq_reqmsg, &(struct lustre_handle){ 0 }); req->rq_status = -EAGAIN; - spin_lock(&req->rq_lock); req->rq_resend = 1; req->rq_net_err = 0; req->rq_timedout = 0; @@ -2542,7 +2560,7 @@ void ptlrpc_resend_req(struct ptlrpc_request *req) /* ensure previous bulk fails */ req->rq_xid = ptlrpc_next_xid(); - CDEBUG(D_HA, "resend bulk old x"LPU64" new x"LPU64"\n", + CDEBUG(D_HA, "resend bulk old x%llu new x%llu\n", old_xid, req->rq_xid); } ptlrpc_client_wake_req(req); @@ -2705,7 +2723,7 @@ static int ptlrpc_replay_interpret(const struct lu_env *env, LASSERTF(lustre_msg_get_transno(req->rq_reqmsg) == lustre_msg_get_transno(req->rq_repmsg) || lustre_msg_get_transno(req->rq_repmsg) == 0, - LPX64"/"LPX64"\n", + "%#llx/%#llx\n", lustre_msg_get_transno(req->rq_reqmsg), lustre_msg_get_transno(req->rq_repmsg)); } @@ -2721,8 +2739,8 @@ static int ptlrpc_replay_interpret(const struct lu_env *env, /* transaction number shouldn't be bigger than the latest replayed */ if (req->rq_transno > lustre_msg_get_transno(req->rq_reqmsg)) { DEBUG_REQ(D_ERROR, req, - "Reported transno "LPU64" is bigger than the " - "replayed one: "LPU64, req->rq_transno, + "Reported transno %llu is bigger than the replayed one: %llu", + req->rq_transno, lustre_msg_get_transno(req->rq_reqmsg)); GOTO(out, rc = -EINVAL); } @@ -2907,7 +2925,7 @@ static spinlock_t ptlrpc_last_xid_lock; #define YEAR_2004 (1ULL << 30) void ptlrpc_init_xid(void) { - time_t now = cfs_time_current_sec(); + time_t now = get_seconds(); spin_lock_init(&ptlrpc_last_xid_lock); if (now < YEAR_2004) { @@ -2996,7 +3014,7 @@ static void ptlrpcd_add_work_req(struct ptlrpc_request *req) { /* re-initialize the req */ req->rq_timeout = obd_timeout; - req->rq_sent = cfs_time_current_sec(); + req->rq_sent = get_seconds(); req->rq_deadline = req->rq_sent + req->rq_timeout; req->rq_reply_deadline = req->rq_deadline; req->rq_phase = RQ_PHASE_INTERPRET; @@ -3062,7 +3080,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, req->rq_interpret_reply = work_interpreter; /* don't want reply */ req->rq_receiving_reply = 0; - req->rq_must_unlink = 0; + req->rq_req_unlink = req->rq_reply_unlink = 0; req->rq_no_delay = req->rq_no_resend = 1; req->rq_pill.rc_fmt = (void *)&worker_format; diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index 6756356faac1..adff1ab4f5a4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -35,9 +35,9 @@ */ #define DEBUG_SUBSYSTEM S_RPC -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_net.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_net.h" #include "ptlrpc_internal.h" diff --git a/drivers/staging/lustre/lustre/ptlrpc/errno.c b/drivers/staging/lustre/lustre/ptlrpc/errno.c index 1c1006333960..73f8374f190e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/errno.c +++ b/drivers/staging/lustre/lustre/ptlrpc/errno.c @@ -25,8 +25,8 @@ * Copyright (c) 2013, Intel Corporation. */ -#include <linux/libcfs/libcfs.h> -#include <lustre/lustre_errno.h> +#include "../../include/linux/libcfs/libcfs.h" +#include "../include/lustre/lustre_errno.h" /* * The two translation tables below must define a one-to-one mapping between diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index aa85239f6cd5..c3ec21d5d29f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -36,14 +36,14 @@ #define DEBUG_SUBSYSTEM S_RPC -# include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" # ifdef __mips64__ # include <linux/kernel.h> # endif -#include <obd_class.h> -#include <lustre_net.h> -#include <lustre_sec.h> +#include "../include/obd_class.h" +#include "../include/lustre_net.h" +#include "../include/lustre_sec.h" #include "ptlrpc_internal.h" lnet_handle_eq_t ptlrpc_eq_h; @@ -63,19 +63,20 @@ void request_out_callback(lnet_event_t *ev) DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status); sptlrpc_request_out_callback(req); - req->rq_real_sent = cfs_time_current_sec(); + spin_lock(&req->rq_lock); + req->rq_real_sent = get_seconds(); + if (ev->unlinked) + req->rq_req_unlink = 0; if (ev->type == LNET_EVENT_UNLINK || ev->status != 0) { /* Failed send: make it seem like the reply timed out, just * like failing sends in client.c does currently... */ - spin_lock(&req->rq_lock); req->rq_net_err = 1; - spin_unlock(&req->rq_lock); - ptlrpc_client_wake_req(req); } + spin_unlock(&req->rq_lock); ptlrpc_req_finished(req); } @@ -102,7 +103,7 @@ void reply_in_callback(lnet_event_t *ev) req->rq_receiving_reply = 0; req->rq_early = 0; if (ev->unlinked) - req->rq_must_unlink = 0; + req->rq_reply_unlink = 0; if (ev->status) goto out_wake; @@ -145,6 +146,8 @@ void reply_in_callback(lnet_event_t *ev) /* Real reply */ req->rq_rep_swab_mask = 0; req->rq_replied = 1; + /* Got reply, no resend required */ + req->rq_resend = 0; req->rq_reply_off = ev->offset; req->rq_nob_received = ev->mlength; /* LNetMDUnlink can't be called under the LNET_LOCK, @@ -155,7 +158,7 @@ void reply_in_callback(lnet_event_t *ev) ev->mlength, ev->offset, req->rq_replen); } - req->rq_import->imp_last_reply_time = cfs_time_current_sec(); + req->rq_import->imp_last_reply_time = get_seconds(); out_wake: /* NB don't unlock till after wakeup; req can disappear under us @@ -307,7 +310,7 @@ void request_in_callback(lnet_event_t *ev) /* We moaned above already... */ return; } - req = ptlrpc_request_cache_alloc(ALLOC_ATOMIC_TRY); + req = ptlrpc_request_cache_alloc(GFP_ATOMIC); if (req == NULL) { CERROR("Can't allocate incoming request descriptor: " "Dropping %s RPC from %s\n", @@ -334,7 +337,7 @@ void request_in_callback(lnet_event_t *ev) INIT_LIST_HEAD(&req->rq_exp_list); atomic_set(&req->rq_refcount, 1); if (ev->type == LNET_EVENT_PUT) - CDEBUG(D_INFO, "incoming req@%p x"LPU64" msgsize %u\n", + CDEBUG(D_INFO, "incoming req@%p x%llu msgsize %u\n", req, req->rq_xid, ev->mlength); CDEBUG(D_RPCTRACE, "peer: %s\n", libcfs_id2str(req->rq_peer)); diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/Makefile b/drivers/staging/lustre/lustre/ptlrpc/gss/Makefile deleted file mode 100644 index 8cdfbeed64e6..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -obj-$(CONFIG_LUSTRE_FS) := ptlrpc_gss.o - -ptlrpc_gss-y := sec_gss.o gss_bulk.o gss_cli_upcall.o gss_svc_upcall.o \ - gss_rawobj.o lproc_gss.o gss_generic_token.o \ - gss_mech_switch.o gss_krb5_mech.o - - -ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_api.h b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_api.h deleted file mode 100644 index 0e9f6c472a37..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_api.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Modifications for Lustre - * - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -/* - * Somewhat simplified version of the gss api. - * - * Dug Song <dugsong@monkey.org> - * Andy Adamson <andros@umich.edu> - * Bruce Fields <bfields@umich.edu> - * Copyright (c) 2000 The Regents of the University of Michigan - * - */ - -#ifndef __PTLRPC_GSS_GSS_API_H_ -#define __PTLRPC_GSS_GSS_API_H_ - -struct gss_api_mech; - -/* The mechanism-independent gss-api context: */ -struct gss_ctx { - struct gss_api_mech *mech_type; - void *internal_ctx_id; -}; - -#define GSS_C_NO_BUFFER ((rawobj_t) 0) -#define GSS_C_NO_CONTEXT ((struct gss_ctx *) 0) -#define GSS_C_NULL_OID ((rawobj_t) 0) - -/* - * gss-api prototypes; note that these are somewhat simplified versions of - * the prototypes specified in RFC 2744. - */ -__u32 lgss_import_sec_context( - rawobj_t *input_token, - struct gss_api_mech *mech, - struct gss_ctx **ctx); -__u32 lgss_copy_reverse_context( - struct gss_ctx *ctx, - struct gss_ctx **ctx_new); -__u32 lgss_inquire_context( - struct gss_ctx *ctx, - unsigned long *endtime); -__u32 lgss_get_mic( - struct gss_ctx *ctx, - int msgcnt, - rawobj_t *msgs, - int iovcnt, - lnet_kiov_t *iovs, - rawobj_t *mic_token); -__u32 lgss_verify_mic( - struct gss_ctx *ctx, - int msgcnt, - rawobj_t *msgs, - int iovcnt, - lnet_kiov_t *iovs, - rawobj_t *mic_token); -__u32 lgss_wrap( - struct gss_ctx *ctx, - rawobj_t *gsshdr, - rawobj_t *msg, - int msg_buflen, - rawobj_t *out_token); -__u32 lgss_unwrap( - struct gss_ctx *ctx, - rawobj_t *gsshdr, - rawobj_t *token, - rawobj_t *out_msg); -__u32 lgss_prep_bulk( - struct gss_ctx *gctx, - struct ptlrpc_bulk_desc *desc); -__u32 lgss_wrap_bulk( - struct gss_ctx *gctx, - struct ptlrpc_bulk_desc *desc, - rawobj_t *token, - int adj_nob); -__u32 lgss_unwrap_bulk( - struct gss_ctx *gctx, - struct ptlrpc_bulk_desc *desc, - rawobj_t *token, - int adj_nob); -__u32 lgss_delete_sec_context( - struct gss_ctx **ctx); -int lgss_display( - struct gss_ctx *ctx, - char *buf, - int bufsize); - -struct subflavor_desc { - __u32 sf_subflavor; - __u32 sf_qop; - __u32 sf_service; - char *sf_name; -}; - -/* Each mechanism is described by the following struct: */ -struct gss_api_mech { - struct list_head gm_list; - struct module *gm_owner; - char *gm_name; - rawobj_t gm_oid; - atomic_t gm_count; - struct gss_api_ops *gm_ops; - int gm_sf_num; - struct subflavor_desc *gm_sfs; -}; - -/* and must provide the following operations: */ -struct gss_api_ops { - __u32 (*gss_import_sec_context)( - rawobj_t *input_token, - struct gss_ctx *ctx); - __u32 (*gss_copy_reverse_context)( - struct gss_ctx *ctx, - struct gss_ctx *ctx_new); - __u32 (*gss_inquire_context)( - struct gss_ctx *ctx, - unsigned long *endtime); - __u32 (*gss_get_mic)( - struct gss_ctx *ctx, - int msgcnt, - rawobj_t *msgs, - int iovcnt, - lnet_kiov_t *iovs, - rawobj_t *mic_token); - __u32 (*gss_verify_mic)( - struct gss_ctx *ctx, - int msgcnt, - rawobj_t *msgs, - int iovcnt, - lnet_kiov_t *iovs, - rawobj_t *mic_token); - __u32 (*gss_wrap)( - struct gss_ctx *ctx, - rawobj_t *gsshdr, - rawobj_t *msg, - int msg_buflen, - rawobj_t *out_token); - __u32 (*gss_unwrap)( - struct gss_ctx *ctx, - rawobj_t *gsshdr, - rawobj_t *token, - rawobj_t *out_msg); - __u32 (*gss_prep_bulk)( - struct gss_ctx *gctx, - struct ptlrpc_bulk_desc *desc); - __u32 (*gss_wrap_bulk)( - struct gss_ctx *gctx, - struct ptlrpc_bulk_desc *desc, - rawobj_t *token, - int adj_nob); - __u32 (*gss_unwrap_bulk)( - struct gss_ctx *gctx, - struct ptlrpc_bulk_desc *desc, - rawobj_t *token, - int adj_nob); - void (*gss_delete_sec_context)( - void *ctx); - int (*gss_display)( - struct gss_ctx *ctx, - char *buf, - int bufsize); -}; - -int lgss_mech_register(struct gss_api_mech *mech); -void lgss_mech_unregister(struct gss_api_mech *mech); - -struct gss_api_mech * lgss_OID_to_mech(rawobj_t *oid); -struct gss_api_mech * lgss_name_to_mech(char *name); -struct gss_api_mech * lgss_subflavor_to_mech(__u32 subflavor); - -struct gss_api_mech * lgss_mech_get(struct gss_api_mech *mech); -void lgss_mech_put(struct gss_api_mech *mech); - -#endif /* __PTLRPC_GSS_GSS_API_H_ */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_asn1.h b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_asn1.h deleted file mode 100644 index bdfd83880422..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_asn1.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Modifications for Lustre - * - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -/* - * minimal asn1 for generic encoding/decoding of gss tokens - * - * Adapted from MIT Kerberos 5-1.2.1 lib/include/krb5.h, - * lib/gssapi/krb5/gssapiP_krb5.h, and others - * - * Copyright (c) 2000 The Regents of the University of Michigan. - * All rights reserved. - * - * Andy Adamson <andros@umich.edu> - */ - -/* - * Copyright 1995 by the Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - * - */ - -#define SIZEOF_INT 4 - -/* from gssapi_err_generic.h */ -#define G_BAD_SERVICE_NAME (-2045022976L) -#define G_BAD_STRING_UID (-2045022975L) -#define G_NOUSER (-2045022974L) -#define G_VALIDATE_FAILED (-2045022973L) -#define G_BUFFER_ALLOC (-2045022972L) -#define G_BAD_MSG_CTX (-2045022971L) -#define G_WRONG_SIZE (-2045022970L) -#define G_BAD_USAGE (-2045022969L) -#define G_UNKNOWN_QOP (-2045022968L) -#define G_NO_HOSTNAME (-2045022967L) -#define G_BAD_HOSTNAME (-2045022966L) -#define G_WRONG_MECH (-2045022965L) -#define G_BAD_TOK_HEADER (-2045022964L) -#define G_BAD_DIRECTION (-2045022963L) -#define G_TOK_TRUNC (-2045022962L) -#define G_REFLECT (-2045022961L) -#define G_WRONG_TOKID (-2045022960L) - -#define g_OID_equal(o1, o2) \ - (((o1)->len == (o2)->len) && \ - (memcmp((o1)->data, (o2)->data, (int) (o1)->len) == 0)) - -__u32 g_verify_token_header(rawobj_t *mech, - int *body_size, - unsigned char **buf_in, - int toksize); - -__u32 g_get_mech_oid(rawobj_t *mech, - rawobj_t *in_buf); - -int g_token_size(rawobj_t *mech, - unsigned int body_size); - -void g_make_token_header(rawobj_t *mech, - int body_size, - unsigned char **buf); diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c deleted file mode 100644 index 93794bd928cb..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c +++ /dev/null @@ -1,505 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/ptlrpc/gss/gss_bulk.c - * - * Author: Eric Mei <eric.mei@sun.com> - */ - -#define DEBUG_SUBSYSTEM S_SEC -#include <linux/module.h> -#include <linux/slab.h> -#include <linux/dcache.h> -#include <linux/fs.h> -#include <linux/mutex.h> -#include <linux/crypto.h> - -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre/lustre_idl.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_sec.h> - -#include "gss_err.h" -#include "gss_internal.h" -#include "gss_api.h" - -int gss_cli_ctx_wrap_bulk(struct ptlrpc_cli_ctx *ctx, - struct ptlrpc_request *req, - struct ptlrpc_bulk_desc *desc) -{ - struct gss_cli_ctx *gctx; - struct lustre_msg *msg; - struct ptlrpc_bulk_sec_desc *bsd; - rawobj_t token; - __u32 maj; - int offset; - int rc; - - LASSERT(req->rq_pack_bulk); - LASSERT(req->rq_bulk_read || req->rq_bulk_write); - - gctx = container_of(ctx, struct gss_cli_ctx, gc_base); - LASSERT(gctx->gc_mechctx); - - switch (SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc)) { - case SPTLRPC_SVC_NULL: - LASSERT(req->rq_reqbuf->lm_bufcount >= 3); - msg = req->rq_reqbuf; - offset = msg->lm_bufcount - 1; - break; - case SPTLRPC_SVC_AUTH: - case SPTLRPC_SVC_INTG: - LASSERT(req->rq_reqbuf->lm_bufcount >= 4); - msg = req->rq_reqbuf; - offset = msg->lm_bufcount - 2; - break; - case SPTLRPC_SVC_PRIV: - LASSERT(req->rq_clrbuf->lm_bufcount >= 2); - msg = req->rq_clrbuf; - offset = msg->lm_bufcount - 1; - break; - default: - LBUG(); - } - - bsd = lustre_msg_buf(msg, offset, sizeof(*bsd)); - bsd->bsd_version = 0; - bsd->bsd_flags = 0; - bsd->bsd_type = SPTLRPC_BULK_DEFAULT; - bsd->bsd_svc = SPTLRPC_FLVR_BULK_SVC(req->rq_flvr.sf_rpc); - - if (bsd->bsd_svc == SPTLRPC_BULK_SVC_NULL) - return 0; - - LASSERT(bsd->bsd_svc == SPTLRPC_BULK_SVC_INTG || - bsd->bsd_svc == SPTLRPC_BULK_SVC_PRIV); - - if (req->rq_bulk_read) { - /* - * bulk read: prepare receiving pages only for privacy mode. - */ - if (bsd->bsd_svc == SPTLRPC_BULK_SVC_PRIV) - return gss_cli_prep_bulk(req, desc); - } else { - /* - * bulk write: sign or encrypt bulk pages. - */ - bsd->bsd_nob = desc->bd_nob; - - if (bsd->bsd_svc == SPTLRPC_BULK_SVC_INTG) { - /* integrity mode */ - token.data = bsd->bsd_data; - token.len = lustre_msg_buflen(msg, offset) - - sizeof(*bsd); - - maj = lgss_get_mic(gctx->gc_mechctx, 0, NULL, - desc->bd_iov_count, desc->bd_iov, - &token); - if (maj != GSS_S_COMPLETE) { - CWARN("failed to sign bulk data: %x\n", maj); - return -EACCES; - } - } else { - /* privacy mode */ - if (desc->bd_iov_count == 0) - return 0; - - rc = sptlrpc_enc_pool_get_pages(desc); - if (rc) { - CERROR("bulk write: failed to allocate " - "encryption pages: %d\n", rc); - return rc; - } - - token.data = bsd->bsd_data; - token.len = lustre_msg_buflen(msg, offset) - - sizeof(*bsd); - - maj = lgss_wrap_bulk(gctx->gc_mechctx, desc, &token, 0); - if (maj != GSS_S_COMPLETE) { - CWARN("fail to encrypt bulk data: %x\n", maj); - return -EACCES; - } - } - } - - return 0; -} - -int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, - struct ptlrpc_request *req, - struct ptlrpc_bulk_desc *desc) -{ - struct gss_cli_ctx *gctx; - struct lustre_msg *rmsg, *vmsg; - struct ptlrpc_bulk_sec_desc *bsdr, *bsdv; - rawobj_t token; - __u32 maj; - int roff, voff; - - LASSERT(req->rq_pack_bulk); - LASSERT(req->rq_bulk_read || req->rq_bulk_write); - - switch (SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc)) { - case SPTLRPC_SVC_NULL: - vmsg = req->rq_repdata; - LASSERT(vmsg != NULL && vmsg->lm_bufcount >= 3); - voff = vmsg->lm_bufcount - 1; - - rmsg = req->rq_reqbuf; - LASSERT(rmsg != NULL && rmsg->lm_bufcount >= 3); - roff = rmsg->lm_bufcount - 1; /* last segment */ - break; - case SPTLRPC_SVC_AUTH: - case SPTLRPC_SVC_INTG: - vmsg = req->rq_repdata; - LASSERT(vmsg != NULL && vmsg->lm_bufcount >= 4); - voff = vmsg->lm_bufcount - 2; - - rmsg = req->rq_reqbuf; - LASSERT(rmsg != NULL && rmsg->lm_bufcount >= 4); - roff = rmsg->lm_bufcount - 2; /* second last segment */ - break; - case SPTLRPC_SVC_PRIV: - vmsg = req->rq_repdata; - LASSERT(vmsg != NULL && vmsg->lm_bufcount >= 2); - voff = vmsg->lm_bufcount - 1; - - rmsg = req->rq_clrbuf; - LASSERT(rmsg != NULL && rmsg->lm_bufcount >= 2); - roff = rmsg->lm_bufcount - 1; /* last segment */ - break; - default: - LBUG(); - } - - bsdr = lustre_msg_buf(rmsg, roff, sizeof(*bsdr)); - bsdv = lustre_msg_buf(vmsg, voff, sizeof(*bsdv)); - LASSERT(bsdr && bsdv); - - if (bsdr->bsd_version != bsdv->bsd_version || - bsdr->bsd_type != bsdv->bsd_type || - bsdr->bsd_svc != bsdv->bsd_svc) { - CERROR("bulk security descriptor mismatch: " - "(%u,%u,%u) != (%u,%u,%u)\n", - bsdr->bsd_version, bsdr->bsd_type, bsdr->bsd_svc, - bsdv->bsd_version, bsdv->bsd_type, bsdv->bsd_svc); - return -EPROTO; - } - - LASSERT(bsdv->bsd_svc == SPTLRPC_BULK_SVC_NULL || - bsdv->bsd_svc == SPTLRPC_BULK_SVC_INTG || - bsdv->bsd_svc == SPTLRPC_BULK_SVC_PRIV); - - /* - * in privacy mode if return success, make sure bd_nob_transferred - * is the actual size of the clear text, otherwise upper layer - * may be surprised. - */ - if (req->rq_bulk_write) { - if (bsdv->bsd_flags & BSD_FL_ERR) { - CERROR("server reported bulk i/o failure\n"); - return -EIO; - } - - if (bsdv->bsd_svc == SPTLRPC_BULK_SVC_PRIV) - desc->bd_nob_transferred = desc->bd_nob; - } else { - /* - * bulk read, upon return success, bd_nob_transferred is - * the size of plain text actually received. - */ - gctx = container_of(ctx, struct gss_cli_ctx, gc_base); - LASSERT(gctx->gc_mechctx); - - if (bsdv->bsd_svc == SPTLRPC_BULK_SVC_INTG) { - int i, nob; - - /* fix the actual data size */ - for (i = 0, nob = 0; i < desc->bd_iov_count; i++) { - if (desc->bd_iov[i].kiov_len + nob > - desc->bd_nob_transferred) { - desc->bd_iov[i].kiov_len = - desc->bd_nob_transferred - nob; - } - nob += desc->bd_iov[i].kiov_len; - } - - token.data = bsdv->bsd_data; - token.len = lustre_msg_buflen(vmsg, voff) - - sizeof(*bsdv); - - maj = lgss_verify_mic(gctx->gc_mechctx, 0, NULL, - desc->bd_iov_count, desc->bd_iov, - &token); - if (maj != GSS_S_COMPLETE) { - CERROR("failed to verify bulk read: %x\n", maj); - return -EACCES; - } - } else if (bsdv->bsd_svc == SPTLRPC_BULK_SVC_PRIV) { - desc->bd_nob = bsdv->bsd_nob; - if (desc->bd_nob == 0) - return 0; - - token.data = bsdv->bsd_data; - token.len = lustre_msg_buflen(vmsg, voff) - - sizeof(*bsdr); - - maj = lgss_unwrap_bulk(gctx->gc_mechctx, desc, - &token, 1); - if (maj != GSS_S_COMPLETE) { - CERROR("failed to decrypt bulk read: %x\n", - maj); - return -EACCES; - } - - desc->bd_nob_transferred = desc->bd_nob; - } - } - - return 0; -} - -static int gss_prep_bulk(struct ptlrpc_bulk_desc *desc, - struct gss_ctx *mechctx) -{ - int rc; - - if (desc->bd_iov_count == 0) - return 0; - - rc = sptlrpc_enc_pool_get_pages(desc); - if (rc) - return rc; - - if (lgss_prep_bulk(mechctx, desc) != GSS_S_COMPLETE) - return -EACCES; - - return 0; -} - -int gss_cli_prep_bulk(struct ptlrpc_request *req, - struct ptlrpc_bulk_desc *desc) -{ - int rc; - - LASSERT(req->rq_cli_ctx); - LASSERT(req->rq_pack_bulk); - LASSERT(req->rq_bulk_read); - - if (SPTLRPC_FLVR_BULK_SVC(req->rq_flvr.sf_rpc) != SPTLRPC_BULK_SVC_PRIV) - return 0; - - rc = gss_prep_bulk(desc, ctx2gctx(req->rq_cli_ctx)->gc_mechctx); - if (rc) - CERROR("bulk read: failed to prepare encryption " - "pages: %d\n", rc); - - return rc; -} - -int gss_svc_prep_bulk(struct ptlrpc_request *req, - struct ptlrpc_bulk_desc *desc) -{ - struct gss_svc_reqctx *grctx; - struct ptlrpc_bulk_sec_desc *bsd; - int rc; - - LASSERT(req->rq_svc_ctx); - LASSERT(req->rq_pack_bulk); - LASSERT(req->rq_bulk_write); - - grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); - LASSERT(grctx->src_reqbsd); - LASSERT(grctx->src_repbsd); - LASSERT(grctx->src_ctx); - LASSERT(grctx->src_ctx->gsc_mechctx); - - bsd = grctx->src_reqbsd; - if (bsd->bsd_svc != SPTLRPC_BULK_SVC_PRIV) - return 0; - - rc = gss_prep_bulk(desc, grctx->src_ctx->gsc_mechctx); - if (rc) - CERROR("bulk write: failed to prepare encryption " - "pages: %d\n", rc); - - return rc; -} - -int gss_svc_unwrap_bulk(struct ptlrpc_request *req, - struct ptlrpc_bulk_desc *desc) -{ - struct gss_svc_reqctx *grctx; - struct ptlrpc_bulk_sec_desc *bsdr, *bsdv; - rawobj_t token; - __u32 maj; - - LASSERT(req->rq_svc_ctx); - LASSERT(req->rq_pack_bulk); - LASSERT(req->rq_bulk_write); - - grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); - - LASSERT(grctx->src_reqbsd); - LASSERT(grctx->src_repbsd); - LASSERT(grctx->src_ctx); - LASSERT(grctx->src_ctx->gsc_mechctx); - - bsdr = grctx->src_reqbsd; - bsdv = grctx->src_repbsd; - - /* bsdr has been sanity checked during unpacking */ - bsdv->bsd_version = 0; - bsdv->bsd_type = SPTLRPC_BULK_DEFAULT; - bsdv->bsd_svc = bsdr->bsd_svc; - bsdv->bsd_flags = 0; - - switch (bsdv->bsd_svc) { - case SPTLRPC_BULK_SVC_INTG: - token.data = bsdr->bsd_data; - token.len = grctx->src_reqbsd_size - sizeof(*bsdr); - - maj = lgss_verify_mic(grctx->src_ctx->gsc_mechctx, 0, NULL, - desc->bd_iov_count, desc->bd_iov, &token); - if (maj != GSS_S_COMPLETE) { - bsdv->bsd_flags |= BSD_FL_ERR; - CERROR("failed to verify bulk signature: %x\n", maj); - return -EACCES; - } - break; - case SPTLRPC_BULK_SVC_PRIV: - if (bsdr->bsd_nob != desc->bd_nob) { - bsdv->bsd_flags |= BSD_FL_ERR; - CERROR("prepared nob %d doesn't match the actual " - "nob %d\n", desc->bd_nob, bsdr->bsd_nob); - return -EPROTO; - } - - if (desc->bd_iov_count == 0) { - LASSERT(desc->bd_nob == 0); - break; - } - - token.data = bsdr->bsd_data; - token.len = grctx->src_reqbsd_size - sizeof(*bsdr); - - maj = lgss_unwrap_bulk(grctx->src_ctx->gsc_mechctx, - desc, &token, 0); - if (maj != GSS_S_COMPLETE) { - bsdv->bsd_flags |= BSD_FL_ERR; - CERROR("failed decrypt bulk data: %x\n", maj); - return -EACCES; - } - break; - } - - return 0; -} - -int gss_svc_wrap_bulk(struct ptlrpc_request *req, - struct ptlrpc_bulk_desc *desc) -{ - struct gss_svc_reqctx *grctx; - struct ptlrpc_bulk_sec_desc *bsdr, *bsdv; - rawobj_t token; - __u32 maj; - int rc; - - LASSERT(req->rq_svc_ctx); - LASSERT(req->rq_pack_bulk); - LASSERT(req->rq_bulk_read); - - grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); - - LASSERT(grctx->src_reqbsd); - LASSERT(grctx->src_repbsd); - LASSERT(grctx->src_ctx); - LASSERT(grctx->src_ctx->gsc_mechctx); - - bsdr = grctx->src_reqbsd; - bsdv = grctx->src_repbsd; - - /* bsdr has been sanity checked during unpacking */ - bsdv->bsd_version = 0; - bsdv->bsd_type = SPTLRPC_BULK_DEFAULT; - bsdv->bsd_svc = bsdr->bsd_svc; - bsdv->bsd_flags = 0; - - switch (bsdv->bsd_svc) { - case SPTLRPC_BULK_SVC_INTG: - token.data = bsdv->bsd_data; - token.len = grctx->src_repbsd_size - sizeof(*bsdv); - - maj = lgss_get_mic(grctx->src_ctx->gsc_mechctx, 0, NULL, - desc->bd_iov_count, desc->bd_iov, &token); - if (maj != GSS_S_COMPLETE) { - bsdv->bsd_flags |= BSD_FL_ERR; - CERROR("failed to sign bulk data: %x\n", maj); - return -EACCES; - } - break; - case SPTLRPC_BULK_SVC_PRIV: - bsdv->bsd_nob = desc->bd_nob; - - if (desc->bd_iov_count == 0) { - LASSERT(desc->bd_nob == 0); - break; - } - - rc = sptlrpc_enc_pool_get_pages(desc); - if (rc) { - bsdv->bsd_flags |= BSD_FL_ERR; - CERROR("bulk read: failed to allocate encryption " - "pages: %d\n", rc); - return rc; - } - - token.data = bsdv->bsd_data; - token.len = grctx->src_repbsd_size - sizeof(*bsdv); - - maj = lgss_wrap_bulk(grctx->src_ctx->gsc_mechctx, - desc, &token, 1); - if (maj != GSS_S_COMPLETE) { - bsdv->bsd_flags |= BSD_FL_ERR; - CERROR("failed to encrypt bulk data: %x\n", maj); - return -EACCES; - } - break; - } - - return 0; -} diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c deleted file mode 100644 index c279edf5b2a5..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c +++ /dev/null @@ -1,446 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/ptlrpc/gss/gss_cli_upcall.c - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -#define DEBUG_SUBSYSTEM S_SEC -#include <linux/init.h> -#include <linux/module.h> -#include <linux/slab.h> -#include <linux/dcache.h> -#include <linux/fs.h> -#include <linux/mutex.h> - -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre/lustre_idl.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_sec.h> - -#include "gss_err.h" -#include "gss_internal.h" -#include "gss_api.h" - -/********************************************** - * gss context init/fini helper * - **********************************************/ - -static -int ctx_init_pack_request(struct obd_import *imp, - struct ptlrpc_request *req, - int lustre_srv, - uid_t uid, gid_t gid, - long token_size, - char __user *token) -{ - struct lustre_msg *msg = req->rq_reqbuf; - struct gss_sec *gsec; - struct gss_header *ghdr; - struct ptlrpc_user_desc *pud; - __u32 *p, size, offset = 2; - rawobj_t obj; - - LASSERT(msg->lm_bufcount <= 4); - LASSERT(req->rq_cli_ctx); - LASSERT(req->rq_cli_ctx->cc_sec); - - /* gss hdr */ - ghdr = lustre_msg_buf(msg, 0, sizeof(*ghdr)); - ghdr->gh_version = PTLRPC_GSS_VERSION; - ghdr->gh_sp = (__u8) imp->imp_sec->ps_part; - ghdr->gh_flags = 0; - ghdr->gh_proc = PTLRPC_GSS_PROC_INIT; - ghdr->gh_seq = 0; - ghdr->gh_svc = SPTLRPC_SVC_NULL; - ghdr->gh_handle.len = 0; - - /* fix the user desc */ - if (req->rq_pack_udesc) { - ghdr->gh_flags |= LUSTRE_GSS_PACK_USER; - - pud = lustre_msg_buf(msg, offset, sizeof(*pud)); - LASSERT(pud); - pud->pud_uid = pud->pud_fsuid = uid; - pud->pud_gid = pud->pud_fsgid = gid; - pud->pud_cap = 0; - pud->pud_ngroups = 0; - offset++; - } - - /* security payload */ - p = lustre_msg_buf(msg, offset, 0); - size = msg->lm_buflens[offset]; - LASSERT(p); - - /* 1. lustre svc type */ - LASSERT(size > 4); - *p++ = cpu_to_le32(lustre_srv); - size -= 4; - - /* 2. target uuid */ - obj.len = strlen(imp->imp_obd->u.cli.cl_target_uuid.uuid) + 1; - obj.data = imp->imp_obd->u.cli.cl_target_uuid.uuid; - if (rawobj_serialize(&obj, &p, &size)) - LBUG(); - - /* 3. reverse context handle. actually only needed by root user, - * but we send it anyway. */ - gsec = sec2gsec(req->rq_cli_ctx->cc_sec); - obj.len = sizeof(gsec->gs_rvs_hdl); - obj.data = (__u8 *) &gsec->gs_rvs_hdl; - if (rawobj_serialize(&obj, &p, &size)) - LBUG(); - - /* 4. now the token */ - LASSERT(size >= (sizeof(__u32) + token_size)); - *p++ = cpu_to_le32(((__u32) token_size)); - if (copy_from_user(p, token, token_size)) { - CERROR("can't copy token\n"); - return -EFAULT; - } - size -= sizeof(__u32) + cfs_size_round4(token_size); - - req->rq_reqdata_len = lustre_shrink_msg(req->rq_reqbuf, offset, - msg->lm_buflens[offset] - size, 0); - return 0; -} - -static -int ctx_init_parse_reply(struct lustre_msg *msg, int swabbed, - char __user *outbuf, long outlen) -{ - struct gss_rep_header *ghdr; - __u32 obj_len, round_len; - __u32 status, effective = 0; - - if (msg->lm_bufcount != 3) { - CERROR("unexpected bufcount %u\n", msg->lm_bufcount); - return -EPROTO; - } - - ghdr = (struct gss_rep_header *) gss_swab_header(msg, 0, swabbed); - if (ghdr == NULL) { - CERROR("unable to extract gss reply header\n"); - return -EPROTO; - } - - if (ghdr->gh_version != PTLRPC_GSS_VERSION) { - CERROR("invalid gss version %u\n", ghdr->gh_version); - return -EPROTO; - } - - if (outlen < (4 + 2) * 4 + cfs_size_round4(ghdr->gh_handle.len) + - cfs_size_round4(msg->lm_buflens[2])) { - CERROR("output buffer size %ld too small\n", outlen); - return -EFAULT; - } - - status = 0; - effective = 0; - - if (copy_to_user(outbuf, &status, 4)) - return -EFAULT; - outbuf += 4; - if (copy_to_user(outbuf, &ghdr->gh_major, 4)) - return -EFAULT; - outbuf += 4; - if (copy_to_user(outbuf, &ghdr->gh_minor, 4)) - return -EFAULT; - outbuf += 4; - if (copy_to_user(outbuf, &ghdr->gh_seqwin, 4)) - return -EFAULT; - outbuf += 4; - effective += 4 * 4; - - /* handle */ - obj_len = ghdr->gh_handle.len; - round_len = (obj_len + 3) & ~ 3; - if (copy_to_user(outbuf, &obj_len, 4)) - return -EFAULT; - outbuf += 4; - if (copy_to_user(outbuf, (char *) ghdr->gh_handle.data, round_len)) - return -EFAULT; - outbuf += round_len; - effective += 4 + round_len; - - /* out token */ - obj_len = msg->lm_buflens[2]; - round_len = (obj_len + 3) & ~ 3; - if (copy_to_user(outbuf, &obj_len, 4)) - return -EFAULT; - outbuf += 4; - if (copy_to_user(outbuf, lustre_msg_buf(msg, 2, 0), round_len)) - return -EFAULT; - outbuf += round_len; - effective += 4 + round_len; - - return effective; -} - -/* XXX move to where lgssd could see */ -struct lgssd_ioctl_param { - int version; /* in */ - int secid; /* in */ - char *uuid; /* in */ - int lustre_svc; /* in */ - uid_t uid; /* in */ - gid_t gid; /* in */ - long send_token_size;/* in */ - char *send_token; /* in */ - long reply_buf_size; /* in */ - char *reply_buf; /* in */ - long status; /* out */ - long reply_length; /* out */ -}; - -int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) -{ - struct obd_import *imp; - struct ptlrpc_request *req; - struct lgssd_ioctl_param param; - struct obd_device *obd; - char obdname[64]; - long lsize; - int rc; - - if (count != sizeof(param)) { - CERROR("ioctl size %lu, expect %lu, please check lgss_keyring " - "version\n", count, (unsigned long) sizeof(param)); - return -EINVAL; - } - if (copy_from_user(¶m, buffer, sizeof(param))) { - CERROR("failed copy data from lgssd\n"); - return -EFAULT; - } - - if (param.version != GSSD_INTERFACE_VERSION) { - CERROR("gssd interface version %d (expect %d)\n", - param.version, GSSD_INTERFACE_VERSION); - return -EINVAL; - } - - /* take name */ - if (strncpy_from_user(obdname, param.uuid, sizeof(obdname)) <= 0) { - CERROR("Invalid obdname pointer\n"); - return -EFAULT; - } - - obd = class_name2obd(obdname); - if (!obd) { - CERROR("no such obd %s\n", obdname); - return -EINVAL; - } - - if (unlikely(!obd->obd_set_up)) { - CERROR("obd %s not setup\n", obdname); - return -EINVAL; - } - - spin_lock(&obd->obd_dev_lock); - if (obd->obd_stopping) { - CERROR("obd %s has stopped\n", obdname); - spin_unlock(&obd->obd_dev_lock); - return -EINVAL; - } - - if (strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) && - strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) && - strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME)) { - CERROR("obd %s is not a client device\n", obdname); - spin_unlock(&obd->obd_dev_lock); - return -EINVAL; - } - spin_unlock(&obd->obd_dev_lock); - - down_read(&obd->u.cli.cl_sem); - if (obd->u.cli.cl_import == NULL) { - CERROR("obd %s: import has gone\n", obd->obd_name); - up_read(&obd->u.cli.cl_sem); - return -EINVAL; - } - imp = class_import_get(obd->u.cli.cl_import); - up_read(&obd->u.cli.cl_sem); - - if (imp->imp_deactive) { - CERROR("import has been deactivated\n"); - class_import_put(imp); - return -EINVAL; - } - - req = ptlrpc_request_alloc_pack(imp, &RQF_SEC_CTX, LUSTRE_OBD_VERSION, - SEC_CTX_INIT); - if (req == NULL) { - param.status = -ENOMEM; - goto out_copy; - } - - if (req->rq_cli_ctx->cc_sec->ps_id != param.secid) { - CWARN("original secid %d, now has changed to %d, " - "cancel this negotiation\n", param.secid, - req->rq_cli_ctx->cc_sec->ps_id); - param.status = -EINVAL; - goto out_copy; - } - - /* get token */ - rc = ctx_init_pack_request(imp, req, - param.lustre_svc, - param.uid, param.gid, - param.send_token_size, - param.send_token); - if (rc) { - param.status = rc; - goto out_copy; - } - - ptlrpc_request_set_replen(req); - - rc = ptlrpc_queue_wait(req); - if (rc) { - /* If any _real_ denial be made, we expect server return - * -EACCES reply or return success but indicate gss error - * inside reply message. All other errors are treated as - * timeout, caller might try the negotiation repeatedly, - * leave recovery decisions to general ptlrpc layer. - * - * FIXME maybe some other error code shouldn't be treated - * as timeout. */ - param.status = rc; - if (rc != -EACCES) - param.status = -ETIMEDOUT; - goto out_copy; - } - - LASSERT(req->rq_repdata); - lsize = ctx_init_parse_reply(req->rq_repdata, - ptlrpc_rep_need_swab(req), - param.reply_buf, param.reply_buf_size); - if (lsize < 0) { - param.status = (int) lsize; - goto out_copy; - } - - param.status = 0; - param.reply_length = lsize; - -out_copy: - if (copy_to_user(buffer, ¶m, sizeof(param))) - rc = -EFAULT; - else - rc = 0; - - class_import_put(imp); - ptlrpc_req_finished(req); - return rc; -} - -int gss_do_ctx_fini_rpc(struct gss_cli_ctx *gctx) -{ - struct ptlrpc_cli_ctx *ctx = &gctx->gc_base; - struct obd_import *imp = ctx->cc_sec->ps_import; - struct ptlrpc_request *req; - struct ptlrpc_user_desc *pud; - int rc; - - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - - if (cli_ctx_is_error(ctx) || !cli_ctx_is_uptodate(ctx)) { - CDEBUG(D_SEC, "ctx %p(%u->%s) not uptodate, " - "don't send destroy rpc\n", ctx, - ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec)); - return 0; - } - - might_sleep(); - - CWARN("%s ctx %p idx "LPX64" (%u->%s)\n", - sec_is_reverse(ctx->cc_sec) ? - "server finishing reverse" : "client finishing forward", - ctx, gss_handle_to_u64(&gctx->gc_handle), - ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec)); - - gctx->gc_proc = PTLRPC_GSS_PROC_DESTROY; - - req = ptlrpc_request_alloc(imp, &RQF_SEC_CTX); - if (req == NULL) { - CWARN("ctx %p(%u): fail to prepare rpc, destroy locally\n", - ctx, ctx->cc_vcred.vc_uid); - GOTO(out, rc = -ENOMEM); - } - - rc = ptlrpc_request_bufs_pack(req, LUSTRE_OBD_VERSION, SEC_CTX_FINI, - NULL, ctx); - if (rc) { - ptlrpc_request_free(req); - GOTO(out_ref, rc); - } - - /* fix the user desc */ - if (req->rq_pack_udesc) { - /* we rely the fact that this request is in AUTH mode, - * and user_desc at offset 2. */ - pud = lustre_msg_buf(req->rq_reqbuf, 2, sizeof(*pud)); - LASSERT(pud); - pud->pud_uid = pud->pud_fsuid = ctx->cc_vcred.vc_uid; - pud->pud_gid = pud->pud_fsgid = ctx->cc_vcred.vc_gid; - pud->pud_cap = 0; - pud->pud_ngroups = 0; - } - - req->rq_phase = RQ_PHASE_RPC; - rc = ptl_send_rpc(req, 1); - if (rc) - CWARN("ctx %p(%u->%s): rpc error %d, destroy locally\n", ctx, - ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec), rc); - -out_ref: - ptlrpc_req_finished(req); -out: - return rc; -} - -int __init gss_init_cli_upcall(void) -{ - return 0; -} - -void __exit gss_exit_cli_upcall(void) -{ -} diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_err.h b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_err.h deleted file mode 100644 index 37ec101e14e5..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_err.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Modifications for Lustre - * - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -/* - * Adapted from MIT Kerberos 5-1.2.1 include/gssapi/gssapi.h - * - * Copyright (c) 2002 The Regents of the University of Michigan. - * All rights reserved. - * - * Andy Adamson <andros@umich.edu> - */ - -/* - * Copyright 1993 by OpenVision Technologies, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appears in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of OpenVision not be used - * in advertising or publicity pertaining to distribution of the software - * without specific, written prior permission. OpenVision makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef __PTLRPC_GSS_GSS_ERR_H_ -#define __PTLRPC_GSS_GSS_ERR_H_ - -typedef unsigned int OM_uint32; - -/* - * Flag bits for context-level services. - */ -#define GSS_C_DELEG_FLAG (1) -#define GSS_C_MUTUAL_FLAG (2) -#define GSS_C_REPLAY_FLAG (4) -#define GSS_C_SEQUENCE_FLAG (8) -#define GSS_C_CONF_FLAG (16) -#define GSS_C_INTEG_FLAG (32) -#define GSS_C_ANON_FLAG (64) -#define GSS_C_PROT_READY_FLAG (128) -#define GSS_C_TRANS_FLAG (256) - -/* - * Credential usage options - */ -#define GSS_C_BOTH (0) -#define GSS_C_INITIATE (1) -#define GSS_C_ACCEPT (2) - -/* - * Status code types for gss_display_status - */ -#define GSS_C_GSS_CODE (1) -#define GSS_C_MECH_CODE (2) - - -/* - * Define the default Quality of Protection for per-message services. Note - * that an implementation that offers multiple levels of QOP may either reserve - * a value (for example zero, as assumed here) to mean "default protection", or - * alternatively may simply equate GSS_C_QOP_DEFAULT to a specific explicit - * QOP value. However a value of 0 should always be interpreted by a GSSAPI - * implementation as a request for the default protection level. - */ -#define GSS_C_QOP_DEFAULT (0) - -/* - * Expiration time of 2^32-1 seconds means infinite lifetime for a - * credential or security context - */ -#define GSS_C_INDEFINITE ((OM_uint32) 0xfffffffful) - - -/* Major status codes */ - -#define GSS_S_COMPLETE (0) - -/* - * Some "helper" definitions to make the status code macros obvious. - */ -#define GSS_C_CALLING_ERROR_OFFSET (24) -#define GSS_C_ROUTINE_ERROR_OFFSET (16) -#define GSS_C_SUPPLEMENTARY_OFFSET (0) -#define GSS_C_CALLING_ERROR_MASK ((OM_uint32) 0377ul) -#define GSS_C_ROUTINE_ERROR_MASK ((OM_uint32) 0377ul) -#define GSS_C_SUPPLEMENTARY_MASK ((OM_uint32) 0177777ul) - -/* - * The macros that test status codes for error conditions. Note that the - * GSS_ERROR() macro has changed slightly from the V1 GSSAPI so that it now - * evaluates its argument only once. - */ -#define GSS_CALLING_ERROR(x) \ - ((x) & (GSS_C_CALLING_ERROR_MASK << GSS_C_CALLING_ERROR_OFFSET)) -#define GSS_ROUTINE_ERROR(x) \ - ((x) & (GSS_C_ROUTINE_ERROR_MASK << GSS_C_ROUTINE_ERROR_OFFSET)) -#define GSS_SUPPLEMENTARY_INFO(x) \ - ((x) & (GSS_C_SUPPLEMENTARY_MASK << GSS_C_SUPPLEMENTARY_OFFSET)) -#define GSS_ERROR(x) \ - ((x) & ((GSS_C_CALLING_ERROR_MASK << GSS_C_CALLING_ERROR_OFFSET) | \ - (GSS_C_ROUTINE_ERROR_MASK << GSS_C_ROUTINE_ERROR_OFFSET))) - -/* - * Now the actual status code definitions - */ - -/* - * Calling errors: - */ -#define GSS_S_CALL_INACCESSIBLE_READ \ - (((OM_uint32) 1ul) << GSS_C_CALLING_ERROR_OFFSET) -#define GSS_S_CALL_INACCESSIBLE_WRITE \ - (((OM_uint32) 2ul) << GSS_C_CALLING_ERROR_OFFSET) -#define GSS_S_CALL_BAD_STRUCTURE \ - (((OM_uint32) 3ul) << GSS_C_CALLING_ERROR_OFFSET) - -/* - * Routine errors: - */ -#define GSS_S_BAD_MECH \ - (((OM_uint32) 1ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_BAD_NAME \ - (((OM_uint32) 2ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_BAD_NAMETYPE \ - (((OM_uint32) 3ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_BAD_BINDINGS \ - (((OM_uint32) 4ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_BAD_STATUS \ - (((OM_uint32) 5ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_BAD_SIG \ - (((OM_uint32) 6ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_NO_CRED \ - (((OM_uint32) 7ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_NO_CONTEXT \ - (((OM_uint32) 8ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_DEFECTIVE_TOKEN \ - (((OM_uint32) 9ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_DEFECTIVE_CREDENTIAL \ - (((OM_uint32) 10ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_CREDENTIALS_EXPIRED \ - (((OM_uint32) 11ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_CONTEXT_EXPIRED \ - (((OM_uint32) 12ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_FAILURE \ - (((OM_uint32) 13ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_BAD_QOP \ - (((OM_uint32) 14ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_UNAUTHORIZED \ - (((OM_uint32) 15ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_UNAVAILABLE \ - (((OM_uint32) 16ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_DUPLICATE_ELEMENT \ - (((OM_uint32) 17ul) << GSS_C_ROUTINE_ERROR_OFFSET) -#define GSS_S_NAME_NOT_MN \ - (((OM_uint32) 18ul) << GSS_C_ROUTINE_ERROR_OFFSET) - -/* - * Supplementary info bits: - */ -#define GSS_S_CONTINUE_NEEDED (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 0)) -#define GSS_S_DUPLICATE_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 1)) -#define GSS_S_OLD_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 2)) -#define GSS_S_UNSEQ_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 3)) -#define GSS_S_GAP_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 4)) - -/* XXXX these are not part of the GSSAPI C bindings! (but should be) */ - -#define GSS_CALLING_ERROR_FIELD(x) \ - (((x) >> GSS_C_CALLING_ERROR_OFFSET) & GSS_C_CALLING_ERROR_MASK) -#define GSS_ROUTINE_ERROR_FIELD(x) \ - (((x) >> GSS_C_ROUTINE_ERROR_OFFSET) & GSS_C_ROUTINE_ERROR_MASK) -#define GSS_SUPPLEMENTARY_INFO_FIELD(x) \ - (((x) >> GSS_C_SUPPLEMENTARY_OFFSET) & GSS_C_SUPPLEMENTARY_MASK) - -/* XXXX This is a necessary evil until the spec is fixed */ -#define GSS_S_CRED_UNAVAIL GSS_S_FAILURE - -#endif /* __PTLRPC_GSS_GSS_ERR_H_ */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_generic_token.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_generic_token.c deleted file mode 100644 index 8dc5c724958d..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_generic_token.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Modifications for Lustre - * - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * - * Copyright (c) 2011, Intel Corporation. - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -/* - * linux/net/sunrpc/gss_generic_token.c - * - * Adapted from MIT Kerberos 5-1.2.1 lib/gssapi/generic/util_token.c - * - * Copyright (c) 2000 The Regents of the University of Michigan. - * All rights reserved. - * - * Andy Adamson <andros@umich.edu> - */ - -/* - * Copyright 1993 by OpenVision Technologies, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appears in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of OpenVision not be used - * in advertising or publicity pertaining to distribution of the software - * without specific, written prior permission. OpenVision makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#define DEBUG_SUBSYSTEM S_SEC -#include <linux/module.h> -#include <linux/slab.h> -#include <linux/mutex.h> - -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre/lustre_idl.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_sec.h> - -#include "gss_err.h" -#include "gss_internal.h" -#include "gss_api.h" -#include "gss_krb5.h" -#include "gss_asn1.h" - - -/* TWRITE_STR from gssapiP_generic.h */ -#define TWRITE_STR(ptr, str, len) \ - memcpy((ptr), (char *) (str), (len)); \ - (ptr) += (len); - -/* XXXX this code currently makes the assumption that a mech oid will - never be longer than 127 bytes. This assumption is not inherent in - the interfaces, so the code can be fixed if the OSI namespace - balloons unexpectedly. */ - -/* Each token looks like this: - -0x60 tag for APPLICATION 0, SEQUENCE - (constructed, definite-length) - <length> possible multiple bytes, need to parse/generate - 0x06 tag for OBJECT IDENTIFIER - <moid_length> compile-time constant string (assume 1 byte) - <moid_bytes> compile-time constant string - <inner_bytes> the ANY containing the application token - bytes 0,1 are the token type - bytes 2,n are the token data - -For the purposes of this abstraction, the token "header" consists of -the sequence tag and length octets, the mech OID DER encoding, and the -first two inner bytes, which indicate the token type. The token -"body" consists of everything else. - -*/ - -static -int der_length_size(int length) -{ - if (length < (1 << 7)) - return 1; - else if (length < (1 << 8)) - return 2; -#if (SIZEOF_INT == 2) - else - return 3; -#else - else if (length < (1 << 16)) - return 3; - else if (length < (1 << 24)) - return 4; - else - return 5; -#endif -} - -static -void der_write_length(unsigned char **buf, int length) -{ - if (length < (1 << 7)) { - *(*buf)++ = (unsigned char) length; - } else { - *(*buf)++ = (unsigned char) (der_length_size(length) + 127); -#if (SIZEOF_INT > 2) - if (length >= (1 << 24)) - *(*buf)++ = (unsigned char) (length >> 24); - if (length >= (1 << 16)) - *(*buf)++ = (unsigned char) ((length >> 16) & 0xff); -#endif - if (length >= (1 << 8)) - *(*buf)++ = (unsigned char) ((length >> 8) & 0xff); - *(*buf)++ = (unsigned char) (length & 0xff); - } -} - -/* - * returns decoded length, or < 0 on failure. Advances buf and - * decrements bufsize - */ -static -int der_read_length(unsigned char **buf, int *bufsize) -{ - unsigned char sf; - int ret; - - if (*bufsize < 1) - return -1; - sf = *(*buf)++; - (*bufsize)--; - if (sf & 0x80) { - sf &= 0x7f; - if (((*bufsize) - 1) < sf) - return -1; - if (sf > SIZEOF_INT) - return -1; - ret = 0; - for (; sf; sf--) { - ret = (ret << 8) + (*(*buf)++); - (*bufsize)--; - } - } else { - ret = sf; - } - - return ret; -} - -/* - * returns the length of a token, given the mech oid and the body size - */ -int g_token_size(rawobj_t *mech, unsigned int body_size) -{ - /* set body_size to sequence contents size */ - body_size += 4 + (int) mech->len; /* NEED overflow check */ - return (1 + der_length_size(body_size) + body_size); -} - -/* - * fills in a buffer with the token header. The buffer is assumed to - * be the right size. buf is advanced past the token header - */ -void g_make_token_header(rawobj_t *mech, int body_size, unsigned char **buf) -{ - *(*buf)++ = 0x60; - der_write_length(buf, 4 + mech->len + body_size); - *(*buf)++ = 0x06; - *(*buf)++ = (unsigned char) mech->len; - TWRITE_STR(*buf, mech->data, ((int) mech->len)); -} - -/* - * Given a buffer containing a token, reads and verifies the token, - * leaving buf advanced past the token header, and setting body_size - * to the number of remaining bytes. Returns 0 on success, - * G_BAD_TOK_HEADER for a variety of errors, and G_WRONG_MECH if the - * mechanism in the token does not match the mech argument. buf and - * *body_size are left unmodified on error. - */ -__u32 g_verify_token_header(rawobj_t *mech, int *body_size, - unsigned char **buf_in, int toksize) -{ - unsigned char *buf = *buf_in; - int seqsize; - rawobj_t toid; - int ret = 0; - - toksize -= 1; - if (0 > toksize) - return (G_BAD_TOK_HEADER); - if (*buf++ != 0x60) - return (G_BAD_TOK_HEADER); - - seqsize = der_read_length(&buf, &toksize); - if (seqsize < 0) - return(G_BAD_TOK_HEADER); - - if (seqsize != toksize) - return (G_BAD_TOK_HEADER); - - toksize -= 1; - if (0 > toksize) - return (G_BAD_TOK_HEADER); - if (*buf++ != 0x06) - return (G_BAD_TOK_HEADER); - - toksize -= 1; - if (0 > toksize) - return (G_BAD_TOK_HEADER); - toid.len = *buf++; - - toksize -= toid.len; - if (0 > toksize) - return (G_BAD_TOK_HEADER); - toid.data = buf; - buf += toid.len; - - if (!g_OID_equal(&toid, mech)) - ret = G_WRONG_MECH; - - /* G_WRONG_MECH is not returned immediately because it's more - * important to return G_BAD_TOK_HEADER if the token header is - * in fact bad - */ - toksize -= 2; - if (0 > toksize) - return (G_BAD_TOK_HEADER); - - if (ret) - return (ret); - - if (!ret) { - *buf_in = buf; - *body_size = toksize; - } - - return (ret); -} - -/* - * Given a buffer containing a token, returns a copy of the mech oid in - * the parameter mech. - */ -__u32 g_get_mech_oid(rawobj_t *mech, rawobj_t *in_buf) -{ - unsigned char *buf = in_buf->data; - int len = in_buf->len; - int ret = 0; - int seqsize; - - len -= 1; - if (0 > len) - return (G_BAD_TOK_HEADER); - if (*buf++ != 0x60) - return (G_BAD_TOK_HEADER); - - seqsize = der_read_length(&buf, &len); - if (seqsize < 0) - return (G_BAD_TOK_HEADER); - - len -= 1; - if (0 > len) - return (G_BAD_TOK_HEADER); - if (*buf++ != 0x06) - return (G_BAD_TOK_HEADER); - - len -= 1; - if (0 > len) - return (G_BAD_TOK_HEADER); - mech->len = *buf++; - - len -= mech->len; - if (0 > len) - return (G_BAD_TOK_HEADER); - OBD_ALLOC_LARGE(mech->data, mech->len); - if (!mech->data) - return (G_BUFFER_ALLOC); - memcpy(mech->data, buf, mech->len); - - return ret; -} diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_internal.h b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_internal.h deleted file mode 100644 index cbfc47cb3f7b..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_internal.h +++ /dev/null @@ -1,526 +0,0 @@ -/* - * Modified from NFSv4 project for Lustre - * - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * - * Copyright (c) 2012, Intel Corporation. - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -#ifndef __PTLRPC_GSS_GSS_INTERNAL_H_ -#define __PTLRPC_GSS_GSS_INTERNAL_H_ - -#include <lustre_sec.h> - -/* - * rawobj stuff - */ -typedef struct netobj_s { - __u32 len; - __u8 data[0]; -} netobj_t; - -#define NETOBJ_EMPTY ((netobj_t) { 0 }) - -typedef struct rawobj_s { - __u32 len; - __u8 *data; -} rawobj_t; - -#define RAWOBJ_EMPTY ((rawobj_t) { 0, NULL }) - -typedef struct rawobj_buf_s { - __u32 dataoff; - __u32 datalen; - __u32 buflen; - __u8 *buf; -} rawobj_buf_t; - -int rawobj_empty(rawobj_t *obj); -int rawobj_alloc(rawobj_t *obj, char *buf, int len); -void rawobj_free(rawobj_t *obj); -int rawobj_equal(rawobj_t *a, rawobj_t *b); -int rawobj_dup(rawobj_t *dest, rawobj_t *src); -int rawobj_serialize(rawobj_t *obj, __u32 **buf, __u32 *buflen); -int rawobj_extract(rawobj_t *obj, __u32 **buf, __u32 *buflen); -int rawobj_extract_alloc(rawobj_t *obj, __u32 **buf, __u32 *buflen); -int rawobj_extract_local(rawobj_t *obj, __u32 **buf, __u32 *buflen); -int rawobj_extract_local_alloc(rawobj_t *obj, __u32 **buf, __u32 *buflen); -int rawobj_from_netobj(rawobj_t *rawobj, netobj_t *netobj); -int rawobj_from_netobj_alloc(rawobj_t *obj, netobj_t *netobj); - -int buffer_extract_bytes(const void **buf, __u32 *buflen, - void *res, __u32 reslen); - -/* - * several timeout values. client refresh upcall timeout we using - * default in pipefs implemnetation. - */ -#define __TIMEOUT_DELTA (10) - -#define GSS_SECINIT_RPC_TIMEOUT \ - (obd_timeout < __TIMEOUT_DELTA ? \ - __TIMEOUT_DELTA : obd_timeout - __TIMEOUT_DELTA) - -#define GSS_SECFINI_RPC_TIMEOUT (__TIMEOUT_DELTA) -#define GSS_SECSVC_UPCALL_TIMEOUT (GSS_SECINIT_RPC_TIMEOUT) - -/* - * default gc interval - */ -#define GSS_GC_INTERVAL (60 * 60) /* 60 minutes */ - -static inline -unsigned long gss_round_ctx_expiry(unsigned long expiry, - unsigned long sec_flags) -{ - if (sec_flags & PTLRPC_SEC_FL_REVERSE) - return expiry; - - if (get_seconds() + __TIMEOUT_DELTA <= expiry) - return expiry - __TIMEOUT_DELTA; - - return expiry; -} - -/* - * Max encryption element in block cipher algorithms. - */ -#define GSS_MAX_CIPHER_BLOCK (16) - -/* - * XXX make it visible of kernel and lgssd/lsvcgssd - */ -#define GSSD_INTERFACE_VERSION (1) - -#define PTLRPC_GSS_VERSION (1) - - -enum ptlrpc_gss_proc { - PTLRPC_GSS_PROC_DATA = 0, - PTLRPC_GSS_PROC_INIT = 1, - PTLRPC_GSS_PROC_CONTINUE_INIT = 2, - PTLRPC_GSS_PROC_DESTROY = 3, - PTLRPC_GSS_PROC_ERR = 4, -}; - -enum ptlrpc_gss_tgt { - LUSTRE_GSS_TGT_MGS = 0, - LUSTRE_GSS_TGT_MDS = 1, - LUSTRE_GSS_TGT_OSS = 2, -}; - -enum ptlrpc_gss_header_flags { - LUSTRE_GSS_PACK_BULK = 1, - LUSTRE_GSS_PACK_USER = 2, -}; - -static inline -__u32 import_to_gss_svc(struct obd_import *imp) -{ - const char *name = imp->imp_obd->obd_type->typ_name; - - if (!strcmp(name, LUSTRE_MGC_NAME)) - return LUSTRE_GSS_TGT_MGS; - if (!strcmp(name, LUSTRE_MDC_NAME)) - return LUSTRE_GSS_TGT_MDS; - if (!strcmp(name, LUSTRE_OSC_NAME)) - return LUSTRE_GSS_TGT_OSS; - LBUG(); - return 0; -} - -/* - * following 3 header must have the same size and offset - */ -struct gss_header { - __u8 gh_version; /* gss version */ - __u8 gh_sp; /* sec part */ - __u16 gh_pad0; - __u32 gh_flags; /* wrap flags */ - __u32 gh_proc; /* proc */ - __u32 gh_seq; /* sequence */ - __u32 gh_svc; /* service */ - __u32 gh_pad1; - __u32 gh_pad2; - __u32 gh_pad3; - netobj_t gh_handle; /* context handle */ -}; - -struct gss_rep_header { - __u8 gh_version; - __u8 gh_sp; - __u16 gh_pad0; - __u32 gh_flags; - __u32 gh_proc; - __u32 gh_major; - __u32 gh_minor; - __u32 gh_seqwin; - __u32 gh_pad2; - __u32 gh_pad3; - netobj_t gh_handle; -}; - -struct gss_err_header { - __u8 gh_version; - __u8 gh_sp; - __u16 gh_pad0; - __u32 gh_flags; - __u32 gh_proc; - __u32 gh_major; - __u32 gh_minor; - __u32 gh_pad1; - __u32 gh_pad2; - __u32 gh_pad3; - netobj_t gh_handle; -}; - -/* - * part of wire context information send from client which be saved and - * used later by server. - */ -struct gss_wire_ctx { - __u32 gw_flags; - __u32 gw_proc; - __u32 gw_seq; - __u32 gw_svc; - rawobj_t gw_handle; -}; - -#define PTLRPC_GSS_MAX_HANDLE_SIZE (8) -#define PTLRPC_GSS_HEADER_SIZE (sizeof(struct gss_header) + \ - PTLRPC_GSS_MAX_HANDLE_SIZE) - - -static inline __u64 gss_handle_to_u64(rawobj_t *handle) -{ - if (handle->len != PTLRPC_GSS_MAX_HANDLE_SIZE) - return -1; - return *((__u64 *) handle->data); -} - -#define GSS_SEQ_WIN (2048) -#define GSS_SEQ_WIN_MAIN GSS_SEQ_WIN -#define GSS_SEQ_WIN_BACK (128) -#define GSS_SEQ_REPACK_THRESHOLD (GSS_SEQ_WIN_MAIN / 2 + \ - GSS_SEQ_WIN_MAIN / 4) - -struct gss_svc_seq_data { - spinlock_t ssd_lock; - /* - * highest sequence number seen so far, for main and back window - */ - __u32 ssd_max_main; - __u32 ssd_max_back; - /* - * main and back window - * for i such that ssd_max - GSS_SEQ_WIN < i <= ssd_max, the i-th bit - * of ssd_win is nonzero iff sequence number i has been seen already. - */ - unsigned long ssd_win_main[GSS_SEQ_WIN_MAIN/BITS_PER_LONG]; - unsigned long ssd_win_back[GSS_SEQ_WIN_BACK/BITS_PER_LONG]; -}; - -struct gss_svc_ctx { - struct gss_ctx *gsc_mechctx; - struct gss_svc_seq_data gsc_seqdata; - rawobj_t gsc_rvs_hdl; - __u32 gsc_rvs_seq; - uid_t gsc_uid; - gid_t gsc_gid; - uid_t gsc_mapped_uid; - unsigned int gsc_usr_root:1, - gsc_usr_mds:1, - gsc_usr_oss:1, - gsc_remote:1, - gsc_reverse:1; -}; - -struct gss_svc_reqctx { - struct ptlrpc_svc_ctx src_base; - /* - * context - */ - struct gss_wire_ctx src_wirectx; - struct gss_svc_ctx *src_ctx; - /* - * record place of bulk_sec_desc in request/reply buffer - */ - struct ptlrpc_bulk_sec_desc *src_reqbsd; - int src_reqbsd_size; - struct ptlrpc_bulk_sec_desc *src_repbsd; - int src_repbsd_size; - /* - * flags - */ - unsigned int src_init:1, - src_init_continue:1, - src_err_notify:1; - int src_reserve_len; -}; - -struct gss_cli_ctx { - struct ptlrpc_cli_ctx gc_base; - __u32 gc_flavor; - __u32 gc_proc; - __u32 gc_win; - atomic_t gc_seq; - rawobj_t gc_handle; - struct gss_ctx *gc_mechctx; - /* handle for the buddy svc ctx */ - rawobj_t gc_svc_handle; -}; - -struct gss_cli_ctx_keyring { - struct gss_cli_ctx gck_base; - struct key *gck_key; - struct timer_list *gck_timer; -}; - -struct gss_sec { - struct ptlrpc_sec gs_base; - struct gss_api_mech *gs_mech; - spinlock_t gs_lock; - __u64 gs_rvs_hdl; -}; - -struct gss_sec_pipefs { - struct gss_sec gsp_base; - int gsp_chash_size; /* must be 2^n */ - struct hlist_head gsp_chash[0]; -}; - -/* - * FIXME cleanup the keyring upcall mutexes - */ -#define HAVE_KEYRING_UPCALL_SERIALIZED 1 - -struct gss_sec_keyring { - struct gss_sec gsk_base; - /* - * all contexts listed here. access is protected by sec spinlock. - */ - struct hlist_head gsk_clist; - /* - * specially point to root ctx (only one at a time). access is - * protected by sec spinlock. - */ - struct ptlrpc_cli_ctx *gsk_root_ctx; - /* - * specially serialize upcalls for root context. - */ - struct mutex gsk_root_uc_lock; - -#ifdef HAVE_KEYRING_UPCALL_SERIALIZED - struct mutex gsk_uc_lock; /* serialize upcalls */ -#endif -}; - -static inline struct gss_cli_ctx *ctx2gctx(struct ptlrpc_cli_ctx *ctx) -{ - return container_of(ctx, struct gss_cli_ctx, gc_base); -} - -static inline -struct gss_cli_ctx_keyring *ctx2gctx_keyring(struct ptlrpc_cli_ctx *ctx) -{ - return container_of(ctx2gctx(ctx), - struct gss_cli_ctx_keyring, gck_base); -} - -static inline struct gss_sec *sec2gsec(struct ptlrpc_sec *sec) -{ - return container_of(sec, struct gss_sec, gs_base); -} - -static inline struct gss_sec_pipefs *sec2gsec_pipefs(struct ptlrpc_sec *sec) -{ - return container_of(sec2gsec(sec), struct gss_sec_pipefs, gsp_base); -} - -static inline struct gss_sec_keyring *sec2gsec_keyring(struct ptlrpc_sec *sec) -{ - return container_of(sec2gsec(sec), struct gss_sec_keyring, gsk_base); -} - - -#define GSS_CTX_INIT_MAX_LEN (1024) - -/* - * This only guaranteed be enough for current krb5 des-cbc-crc . We might - * adjust this when new enc type or mech added in. - */ -#define GSS_PRIVBUF_PREFIX_LEN (32) -#define GSS_PRIVBUF_SUFFIX_LEN (32) - -static inline -struct gss_svc_reqctx *gss_svc_ctx2reqctx(struct ptlrpc_svc_ctx *ctx) -{ - LASSERT(ctx); - return container_of(ctx, struct gss_svc_reqctx, src_base); -} - -static inline -struct gss_svc_ctx *gss_svc_ctx2gssctx(struct ptlrpc_svc_ctx *ctx) -{ - LASSERT(ctx); - return gss_svc_ctx2reqctx(ctx)->src_ctx; -} - -/* sec_gss.c */ -int gss_cli_ctx_match(struct ptlrpc_cli_ctx *ctx, struct vfs_cred *vcred); -int gss_cli_ctx_display(struct ptlrpc_cli_ctx *ctx, char *buf, int bufsize); -int gss_cli_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req); -int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req); -int gss_cli_ctx_seal(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req); -int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req); - -int gss_sec_install_rctx(struct obd_import *imp, struct ptlrpc_sec *sec, - struct ptlrpc_cli_ctx *ctx); -int gss_alloc_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req, - int msgsize); -void gss_free_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req); -int gss_alloc_repbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req, - int msgsize); -void gss_free_repbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req); -int gss_enlarge_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req, - int segment, int newsize); - -int gss_svc_accept(struct ptlrpc_sec_policy *policy, - struct ptlrpc_request *req); -void gss_svc_invalidate_ctx(struct ptlrpc_svc_ctx *svc_ctx); -int gss_svc_alloc_rs(struct ptlrpc_request *req, int msglen); -int gss_svc_authorize(struct ptlrpc_request *req); -void gss_svc_free_rs(struct ptlrpc_reply_state *rs); -void gss_svc_free_ctx(struct ptlrpc_svc_ctx *ctx); - -int cli_ctx_expire(struct ptlrpc_cli_ctx *ctx); -int cli_ctx_check_death(struct ptlrpc_cli_ctx *ctx); - -int gss_copy_rvc_cli_ctx(struct ptlrpc_cli_ctx *cli_ctx, - struct ptlrpc_svc_ctx *svc_ctx); - -struct gss_header *gss_swab_header(struct lustre_msg *msg, int segment, - int swabbed); -netobj_t *gss_swab_netobj(struct lustre_msg *msg, int segment); - -void gss_cli_ctx_uptodate(struct gss_cli_ctx *gctx); -int gss_pack_err_notify(struct ptlrpc_request *req, __u32 major, __u32 minor); -int gss_check_seq_num(struct gss_svc_seq_data *sd, __u32 seq_num, int set); - -int gss_sec_create_common(struct gss_sec *gsec, - struct ptlrpc_sec_policy *policy, - struct obd_import *imp, - struct ptlrpc_svc_ctx *ctx, - struct sptlrpc_flavor *sf); -void gss_sec_destroy_common(struct gss_sec *gsec); -void gss_sec_kill(struct ptlrpc_sec *sec); - -int gss_cli_ctx_init_common(struct ptlrpc_sec *sec, - struct ptlrpc_cli_ctx *ctx, - struct ptlrpc_ctx_ops *ctxops, - struct vfs_cred *vcred); -int gss_cli_ctx_fini_common(struct ptlrpc_sec *sec, - struct ptlrpc_cli_ctx *ctx); - -void gss_cli_ctx_flags2str(unsigned long flags, char *buf, int bufsize); - -/* gss_keyring.c */ -int __init gss_init_keyring(void); -void __exit gss_exit_keyring(void); - -/* gss_pipefs.c */ -int __init gss_init_pipefs(void); -void __exit gss_exit_pipefs(void); - -/* gss_bulk.c */ -int gss_cli_prep_bulk(struct ptlrpc_request *req, - struct ptlrpc_bulk_desc *desc); -int gss_cli_ctx_wrap_bulk(struct ptlrpc_cli_ctx *ctx, - struct ptlrpc_request *req, - struct ptlrpc_bulk_desc *desc); -int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, - struct ptlrpc_request *req, - struct ptlrpc_bulk_desc *desc); -int gss_svc_prep_bulk(struct ptlrpc_request *req, - struct ptlrpc_bulk_desc *desc); -int gss_svc_unwrap_bulk(struct ptlrpc_request *req, - struct ptlrpc_bulk_desc *desc); -int gss_svc_wrap_bulk(struct ptlrpc_request *req, - struct ptlrpc_bulk_desc *desc); - -/* gss_mech_switch.c */ -int init_kerberos_module(void); -void cleanup_kerberos_module(void); - -/* gss_generic_token.c */ -int g_token_size(rawobj_t *mech, unsigned int body_size); -void g_make_token_header(rawobj_t *mech, int body_size, unsigned char **buf); -__u32 g_verify_token_header(rawobj_t *mech, int *body_size, - unsigned char **buf_in, int toksize); - - -/* gss_cli_upcall.c */ -int gss_do_ctx_init_rpc(char *buffer, unsigned long count); -int gss_do_ctx_fini_rpc(struct gss_cli_ctx *gctx); - -int __init gss_init_cli_upcall(void); -void __exit gss_exit_cli_upcall(void); - -/* gss_svc_upcall.c */ -__u64 gss_get_next_ctx_index(void); -int gss_svc_upcall_install_rvs_ctx(struct obd_import *imp, - struct gss_sec *gsec, - struct gss_cli_ctx *gctx); -int gss_svc_upcall_expire_rvs_ctx(rawobj_t *handle); -int gss_svc_upcall_dup_handle(rawobj_t *handle, struct gss_svc_ctx *ctx); -int gss_svc_upcall_update_sequence(rawobj_t *handle, __u32 seq); -int gss_svc_upcall_handle_init(struct ptlrpc_request *req, - struct gss_svc_reqctx *grctx, - struct gss_wire_ctx *gw, - struct obd_device *target, - __u32 lustre_svc, - rawobj_t *rvs_hdl, - rawobj_t *in_token); -struct gss_svc_ctx *gss_svc_upcall_get_ctx(struct ptlrpc_request *req, - struct gss_wire_ctx *gw); -void gss_svc_upcall_put_ctx(struct gss_svc_ctx *ctx); -void gss_svc_upcall_destroy_ctx(struct gss_svc_ctx *ctx); - -int __init gss_init_svc_upcall(void); -void __exit gss_exit_svc_upcall(void); - -/* lproc_gss.c */ -void gss_stat_oos_record_cli(int behind); -void gss_stat_oos_record_svc(int phase, int replay); - -int __init gss_init_lproc(void); -void __exit gss_exit_lproc(void); - -/* gss_krb5_mech.c */ -int __init init_kerberos_module(void); -void __exit cleanup_kerberos_module(void); - - -/* debug */ -static inline -void __dbg_memdump(char *name, void *ptr, int size) -{ - char *buf, *p = (char *) ptr; - int bufsize = size * 2 + 1, i; - - OBD_ALLOC(buf, bufsize); - if (!buf) { - CDEBUG(D_ERROR, "DUMP ERROR: can't alloc %d bytes\n", bufsize); - return; - } - - for (i = 0; i < size; i++) - sprintf(&buf[i+i], "%02x", (__u8) p[i]); - buf[size + size] = '\0'; - LCONSOLE_INFO("DUMP %s@%p(%d): %s\n", name, ptr, size, buf); - OBD_FREE(buf, bufsize); -} - -#endif /* __PTLRPC_GSS_GSS_INTERNAL_H_ */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c deleted file mode 100644 index 4642bbfb9273..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c +++ /dev/null @@ -1,1409 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/ptlrpc/gss/gss_keyring.c - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -#define DEBUG_SUBSYSTEM S_SEC -#include <linux/init.h> -#include <linux/module.h> -#include <linux/slab.h> -#include <linux/dcache.h> -#include <linux/fs.h> -#include <linux/crypto.h> -#include <linux/key.h> -#include <linux/keyctl.h> -#include <linux/key-type.h> -#include <linux/mutex.h> -#include <asm/atomic.h> - -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre/lustre_idl.h> -#include <lustre_sec.h> -#include <lustre_net.h> -#include <lustre_import.h> - -#include "gss_err.h" -#include "gss_internal.h" -#include "gss_api.h" - -static struct ptlrpc_sec_policy gss_policy_keyring; -static struct ptlrpc_ctx_ops gss_keyring_ctxops; -static struct key_type gss_key_type; - -static int sec_install_rctx_kr(struct ptlrpc_sec *sec, - struct ptlrpc_svc_ctx *svc_ctx); - -/* - * the timeout is only for the case that upcall child process die abnormally. - * in any other cases it should finally update kernel key. - * - * FIXME we'd better to incorporate the client & server side upcall timeouts - * into the framework of Adaptive Timeouts, but we need to figure out how to - * make sure that kernel knows the upcall processes is in-progress or died - * unexpectedly. - */ -#define KEYRING_UPCALL_TIMEOUT (obd_timeout + obd_timeout) - -/**************************************** - * internal helpers * - ****************************************/ - -#define DUMP_PROCESS_KEYRINGS(tsk) \ -{ \ - CWARN("DUMP PK: %s[%u,%u/%u](<-%s[%u,%u/%u]): " \ - "a %d, t %d, p %d, s %d, u %d, us %d, df %d\n", \ - tsk->comm, tsk->pid, tsk->uid, tsk->fsuid, \ - tsk->parent->comm, tsk->parent->pid, \ - tsk->parent->uid, tsk->parent->fsuid, \ - tsk->request_key_auth ? \ - tsk->request_key_auth->serial : 0, \ - key_cred(tsk)->thread_keyring ? \ - key_cred(tsk)->thread_keyring->serial : 0, \ - key_tgcred(tsk)->process_keyring ? \ - key_tgcred(tsk)->process_keyring->serial : 0, \ - key_tgcred(tsk)->session_keyring ? \ - key_tgcred(tsk)->session_keyring->serial : 0, \ - key_cred(tsk)->user->uid_keyring ? \ - key_cred(tsk)->user->uid_keyring->serial : 0, \ - key_cred(tsk)->user->session_keyring ? \ - key_cred(tsk)->user->session_keyring->serial : 0, \ - key_cred(tsk)->jit_keyring \ - ); \ -} - -#define DUMP_KEY(key) \ -{ \ - CWARN("DUMP KEY: %p(%d) ref %d u%u/g%u desc %s\n", \ - key, key->serial, atomic_read(&key->usage), \ - key->uid, key->gid, \ - key->description ? key->description : "n/a" \ - ); \ -} - -#define key_cred(tsk) ((tsk)->cred) -#define key_tgcred(tsk) ((tsk)->cred->tgcred) - -static inline void keyring_upcall_lock(struct gss_sec_keyring *gsec_kr) -{ -#ifdef HAVE_KEYRING_UPCALL_SERIALIZED - mutex_lock(&gsec_kr->gsk_uc_lock); -#endif -} - -static inline void keyring_upcall_unlock(struct gss_sec_keyring *gsec_kr) -{ -#ifdef HAVE_KEYRING_UPCALL_SERIALIZED - mutex_unlock(&gsec_kr->gsk_uc_lock); -#endif -} - -static inline void key_revoke_locked(struct key *key) -{ - set_bit(KEY_FLAG_REVOKED, &key->flags); -} - -static void ctx_upcall_timeout_kr(unsigned long data) -{ - struct ptlrpc_cli_ctx *ctx = (struct ptlrpc_cli_ctx *) data; - struct key *key = ctx2gctx_keyring(ctx)->gck_key; - - CWARN("ctx %p, key %p\n", ctx, key); - - LASSERT(key); - - cli_ctx_expire(ctx); - key_revoke_locked(key); -} - -static -void ctx_start_timer_kr(struct ptlrpc_cli_ctx *ctx, long timeout) -{ - struct gss_cli_ctx_keyring *gctx_kr = ctx2gctx_keyring(ctx); - struct timer_list *timer = gctx_kr->gck_timer; - - LASSERT(timer); - - CDEBUG(D_SEC, "ctx %p: start timer %lds\n", ctx, timeout); - timeout = timeout * HZ + cfs_time_current(); - - init_timer(timer); - timer->expires = timeout; - timer->data = (unsigned long) ctx; - timer->function = ctx_upcall_timeout_kr; - - add_timer(timer); -} - -/* - * caller should make sure no race with other threads - */ -static -void ctx_clear_timer_kr(struct ptlrpc_cli_ctx *ctx) -{ - struct gss_cli_ctx_keyring *gctx_kr = ctx2gctx_keyring(ctx); - struct timer_list *timer = gctx_kr->gck_timer; - - if (timer == NULL) - return; - - CDEBUG(D_SEC, "ctx %p, key %p\n", ctx, gctx_kr->gck_key); - - gctx_kr->gck_timer = NULL; - - del_singleshot_timer_sync(timer); - - OBD_FREE_PTR(timer); -} - -static -struct ptlrpc_cli_ctx *ctx_create_kr(struct ptlrpc_sec *sec, - struct vfs_cred *vcred) -{ - struct ptlrpc_cli_ctx *ctx; - struct gss_cli_ctx_keyring *gctx_kr; - - OBD_ALLOC_PTR(gctx_kr); - if (gctx_kr == NULL) - return NULL; - - OBD_ALLOC_PTR(gctx_kr->gck_timer); - if (gctx_kr->gck_timer == NULL) { - OBD_FREE_PTR(gctx_kr); - return NULL; - } - init_timer(gctx_kr->gck_timer); - - ctx = &gctx_kr->gck_base.gc_base; - - if (gss_cli_ctx_init_common(sec, ctx, &gss_keyring_ctxops, vcred)) { - OBD_FREE_PTR(gctx_kr->gck_timer); - OBD_FREE_PTR(gctx_kr); - return NULL; - } - - ctx->cc_expire = cfs_time_current_sec() + KEYRING_UPCALL_TIMEOUT; - clear_bit(PTLRPC_CTX_NEW_BIT, &ctx->cc_flags); - atomic_inc(&ctx->cc_refcount); /* for the caller */ - - return ctx; -} - -static void ctx_destroy_kr(struct ptlrpc_cli_ctx *ctx) -{ - struct ptlrpc_sec *sec = ctx->cc_sec; - struct gss_cli_ctx_keyring *gctx_kr = ctx2gctx_keyring(ctx); - - CDEBUG(D_SEC, "destroying ctx %p\n", ctx); - - /* at this time the association with key has been broken. */ - LASSERT(sec); - LASSERT(atomic_read(&sec->ps_refcount) > 0); - LASSERT(atomic_read(&sec->ps_nctx) > 0); - LASSERT(test_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags) == 0); - LASSERT(gctx_kr->gck_key == NULL); - - ctx_clear_timer_kr(ctx); - LASSERT(gctx_kr->gck_timer == NULL); - - if (gss_cli_ctx_fini_common(sec, ctx)) - return; - - OBD_FREE_PTR(gctx_kr); - - atomic_dec(&sec->ps_nctx); - sptlrpc_sec_put(sec); -} - -static void ctx_release_kr(struct ptlrpc_cli_ctx *ctx, int sync) -{ - if (sync) { - ctx_destroy_kr(ctx); - } else { - atomic_inc(&ctx->cc_refcount); - sptlrpc_gc_add_ctx(ctx); - } -} - -static void ctx_put_kr(struct ptlrpc_cli_ctx *ctx, int sync) -{ - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - - if (atomic_dec_and_test(&ctx->cc_refcount)) - ctx_release_kr(ctx, sync); -} - -/* - * key <-> ctx association and rules: - * - ctx might not bind with any key - * - key/ctx binding is protected by key semaphore (if the key present) - * - key and ctx each take a reference of the other - * - ctx enlist/unlist is protected by ctx spinlock - * - never enlist a ctx after it's been unlisted - * - whoever do enlist should also do bind, lock key before enlist: - * - lock key -> lock ctx -> enlist -> unlock ctx -> bind -> unlock key - * - whoever do unlist should also do unbind: - * - lock key -> lock ctx -> unlist -> unlock ctx -> unbind -> unlock key - * - lock ctx -> unlist -> unlock ctx -> lock key -> unbind -> unlock key - */ - -static inline void spin_lock_if(spinlock_t *lock, int condition) -{ - if (condition) - spin_lock(lock); -} - -static inline void spin_unlock_if(spinlock_t *lock, int condition) -{ - if (condition) - spin_unlock(lock); -} - -static void ctx_enlist_kr(struct ptlrpc_cli_ctx *ctx, int is_root, int locked) -{ - struct ptlrpc_sec *sec = ctx->cc_sec; - struct gss_sec_keyring *gsec_kr = sec2gsec_keyring(sec); - - LASSERT(!test_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags)); - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - - spin_lock_if(&sec->ps_lock, !locked); - - atomic_inc(&ctx->cc_refcount); - set_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags); - hlist_add_head(&ctx->cc_cache, &gsec_kr->gsk_clist); - if (is_root) - gsec_kr->gsk_root_ctx = ctx; - - spin_unlock_if(&sec->ps_lock, !locked); -} - -/* - * Note after this get called, caller should not access ctx again because - * it might have been freed, unless caller hold at least one refcount of - * the ctx. - * - * return non-zero if we indeed unlist this ctx. - */ -static int ctx_unlist_kr(struct ptlrpc_cli_ctx *ctx, int locked) -{ - struct ptlrpc_sec *sec = ctx->cc_sec; - struct gss_sec_keyring *gsec_kr = sec2gsec_keyring(sec); - - /* if hashed bit has gone, leave the job to somebody who is doing it */ - if (test_and_clear_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags) == 0) - return 0; - - /* drop ref inside spin lock to prevent race with other operations */ - spin_lock_if(&sec->ps_lock, !locked); - - if (gsec_kr->gsk_root_ctx == ctx) - gsec_kr->gsk_root_ctx = NULL; - hlist_del_init(&ctx->cc_cache); - atomic_dec(&ctx->cc_refcount); - - spin_unlock_if(&sec->ps_lock, !locked); - - return 1; -} - -/* - * bind a key with a ctx together. - * caller must hold write lock of the key, as well as ref on key & ctx. - */ -static void bind_key_ctx(struct key *key, struct ptlrpc_cli_ctx *ctx) -{ - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - LASSERT(atomic_read(&key->usage) > 0); - LASSERT(ctx2gctx_keyring(ctx)->gck_key == NULL); - LASSERT(key->payload.data == NULL); - - /* at this time context may or may not in list. */ - key_get(key); - atomic_inc(&ctx->cc_refcount); - ctx2gctx_keyring(ctx)->gck_key = key; - key->payload.data = ctx; -} - -/* - * unbind a key and a ctx. - * caller must hold write lock, as well as a ref of the key. - */ -static void unbind_key_ctx(struct key *key, struct ptlrpc_cli_ctx *ctx) -{ - LASSERT(key->payload.data == ctx); - LASSERT(test_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags) == 0); - - /* must revoke the key, or others may treat it as newly created */ - key_revoke_locked(key); - - key->payload.data = NULL; - ctx2gctx_keyring(ctx)->gck_key = NULL; - - /* once ctx get split from key, the timer is meaningless */ - ctx_clear_timer_kr(ctx); - - ctx_put_kr(ctx, 1); - key_put(key); -} - -/* - * given a ctx, unbind with its coupled key, if any. - * unbind could only be called once, so we don't worry the key be released - * by someone else. - */ -static void unbind_ctx_kr(struct ptlrpc_cli_ctx *ctx) -{ - struct key *key = ctx2gctx_keyring(ctx)->gck_key; - - if (key) { - LASSERT(key->payload.data == ctx); - - key_get(key); - down_write(&key->sem); - unbind_key_ctx(key, ctx); - up_write(&key->sem); - key_put(key); - } -} - -/* - * given a key, unbind with its coupled ctx, if any. - * caller must hold write lock, as well as a ref of the key. - */ -static void unbind_key_locked(struct key *key) -{ - struct ptlrpc_cli_ctx *ctx = key->payload.data; - - if (ctx) - unbind_key_ctx(key, ctx); -} - -/* - * unlist a ctx, and unbind from coupled key - */ -static void kill_ctx_kr(struct ptlrpc_cli_ctx *ctx) -{ - if (ctx_unlist_kr(ctx, 0)) - unbind_ctx_kr(ctx); -} - -/* - * given a key, unlist and unbind with the coupled ctx (if any). - * caller must hold write lock, as well as a ref of the key. - */ -static void kill_key_locked(struct key *key) -{ - struct ptlrpc_cli_ctx *ctx = key->payload.data; - - if (ctx && ctx_unlist_kr(ctx, 0)) - unbind_key_locked(key); -} - -/* - * caller should hold one ref on contexts in freelist. - */ -static void dispose_ctx_list_kr(struct hlist_head *freelist) -{ - struct hlist_node *next; - struct ptlrpc_cli_ctx *ctx; - struct gss_cli_ctx *gctx; - - hlist_for_each_entry_safe(ctx, next, freelist, cc_cache) { - hlist_del_init(&ctx->cc_cache); - - /* reverse ctx: update current seq to buddy svcctx if exist. - * ideally this should be done at gss_cli_ctx_finalize(), but - * the ctx destroy could be delayed by: - * 1) ctx still has reference; - * 2) ctx destroy is asynchronous; - * and reverse import call inval_all_ctx() require this be done - *_immediately_ otherwise newly created reverse ctx might copy - * the very old sequence number from svcctx. */ - gctx = ctx2gctx(ctx); - if (!rawobj_empty(&gctx->gc_svc_handle) && - sec_is_reverse(gctx->gc_base.cc_sec)) { - gss_svc_upcall_update_sequence(&gctx->gc_svc_handle, - (__u32) atomic_read(&gctx->gc_seq)); - } - - /* we need to wakeup waiting reqs here. the context might - * be forced released before upcall finished, then the - * late-arrived downcall can't find the ctx even. */ - sptlrpc_cli_ctx_wakeup(ctx); - - unbind_ctx_kr(ctx); - ctx_put_kr(ctx, 0); - } -} - -/* - * lookup a root context directly in a sec, return root ctx with a - * reference taken or NULL. - */ -static -struct ptlrpc_cli_ctx * sec_lookup_root_ctx_kr(struct ptlrpc_sec *sec) -{ - struct gss_sec_keyring *gsec_kr = sec2gsec_keyring(sec); - struct ptlrpc_cli_ctx *ctx = NULL; - - spin_lock(&sec->ps_lock); - - ctx = gsec_kr->gsk_root_ctx; - - if (ctx == NULL && unlikely(sec_is_reverse(sec))) { - struct ptlrpc_cli_ctx *tmp; - - /* reverse ctx, search root ctx in list, choose the one - * with shortest expire time, which is most possibly have - * an established peer ctx at client side. */ - hlist_for_each_entry(tmp, &gsec_kr->gsk_clist, cc_cache) { - if (ctx == NULL || ctx->cc_expire == 0 || - ctx->cc_expire > tmp->cc_expire) { - ctx = tmp; - /* promote to be root_ctx */ - gsec_kr->gsk_root_ctx = ctx; - } - } - } - - if (ctx) { - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - LASSERT(!hlist_empty(&gsec_kr->gsk_clist)); - atomic_inc(&ctx->cc_refcount); - } - - spin_unlock(&sec->ps_lock); - - return ctx; -} - -#define RVS_CTX_EXPIRE_NICE (10) - -static -void rvs_sec_install_root_ctx_kr(struct ptlrpc_sec *sec, - struct ptlrpc_cli_ctx *new_ctx, - struct key *key) -{ - struct gss_sec_keyring *gsec_kr = sec2gsec_keyring(sec); - struct ptlrpc_cli_ctx *ctx; - cfs_time_t now; - - LASSERT(sec_is_reverse(sec)); - - spin_lock(&sec->ps_lock); - - now = cfs_time_current_sec(); - - /* set all existing ctxs short expiry */ - hlist_for_each_entry(ctx, &gsec_kr->gsk_clist, cc_cache) { - if (ctx->cc_expire > now + RVS_CTX_EXPIRE_NICE) { - ctx->cc_early_expire = 1; - ctx->cc_expire = now + RVS_CTX_EXPIRE_NICE; - } - } - - /* if there's root_ctx there, instead obsolete the current - * immediately, we leave it continue operating for a little while. - * hopefully when the first backward rpc with newest ctx send out, - * the client side already have the peer ctx well established. */ - ctx_enlist_kr(new_ctx, gsec_kr->gsk_root_ctx ? 0 : 1, 1); - - if (key) - bind_key_ctx(key, new_ctx); - - spin_unlock(&sec->ps_lock); -} - -static void construct_key_desc(void *buf, int bufsize, - struct ptlrpc_sec *sec, uid_t uid) -{ - snprintf(buf, bufsize, "%d@%x", uid, sec->ps_id); - ((char *)buf)[bufsize - 1] = '\0'; -} - -/**************************************** - * sec apis * - ****************************************/ - -static -struct ptlrpc_sec * gss_sec_create_kr(struct obd_import *imp, - struct ptlrpc_svc_ctx *svcctx, - struct sptlrpc_flavor *sf) -{ - struct gss_sec_keyring *gsec_kr; - - OBD_ALLOC(gsec_kr, sizeof(*gsec_kr)); - if (gsec_kr == NULL) - return NULL; - - INIT_HLIST_HEAD(&gsec_kr->gsk_clist); - gsec_kr->gsk_root_ctx = NULL; - mutex_init(&gsec_kr->gsk_root_uc_lock); -#ifdef HAVE_KEYRING_UPCALL_SERIALIZED - mutex_init(&gsec_kr->gsk_uc_lock); -#endif - - if (gss_sec_create_common(&gsec_kr->gsk_base, &gss_policy_keyring, - imp, svcctx, sf)) - goto err_free; - - if (svcctx != NULL && - sec_install_rctx_kr(&gsec_kr->gsk_base.gs_base, svcctx)) { - gss_sec_destroy_common(&gsec_kr->gsk_base); - goto err_free; - } - - return &gsec_kr->gsk_base.gs_base; - -err_free: - OBD_FREE(gsec_kr, sizeof(*gsec_kr)); - return NULL; -} - -static -void gss_sec_destroy_kr(struct ptlrpc_sec *sec) -{ - struct gss_sec *gsec = sec2gsec(sec); - struct gss_sec_keyring *gsec_kr = sec2gsec_keyring(sec); - - CDEBUG(D_SEC, "destroy %s@%p\n", sec->ps_policy->sp_name, sec); - - LASSERT(hlist_empty(&gsec_kr->gsk_clist)); - LASSERT(gsec_kr->gsk_root_ctx == NULL); - - gss_sec_destroy_common(gsec); - - OBD_FREE(gsec_kr, sizeof(*gsec_kr)); -} - -static inline int user_is_root(struct ptlrpc_sec *sec, struct vfs_cred *vcred) -{ - /* except the ROOTONLY flag, treat it as root user only if real uid - * is 0, euid/fsuid being 0 are handled as setuid scenarios */ - if (sec_is_rootonly(sec) || (vcred->vc_uid == 0)) - return 1; - else - return 0; -} - -/* - * unlink request key from it's ring, which is linked during request_key(). - * sadly, we have to 'guess' which keyring it's linked to. - * - * FIXME this code is fragile, depend on how request_key_link() is implemented. - */ -static void request_key_unlink(struct key *key) -{ - struct task_struct *tsk = current; - struct key *ring; - - switch (key_cred(tsk)->jit_keyring) { - case KEY_REQKEY_DEFL_DEFAULT: - case KEY_REQKEY_DEFL_THREAD_KEYRING: - ring = key_get(key_cred(tsk)->thread_keyring); - if (ring) - break; - case KEY_REQKEY_DEFL_PROCESS_KEYRING: - ring = key_get(key_tgcred(tsk)->process_keyring); - if (ring) - break; - case KEY_REQKEY_DEFL_SESSION_KEYRING: - rcu_read_lock(); - ring = key_get(rcu_dereference(key_tgcred(tsk) - ->session_keyring)); - rcu_read_unlock(); - if (ring) - break; - case KEY_REQKEY_DEFL_USER_SESSION_KEYRING: - ring = key_get(key_cred(tsk)->user->session_keyring); - break; - case KEY_REQKEY_DEFL_USER_KEYRING: - ring = key_get(key_cred(tsk)->user->uid_keyring); - break; - case KEY_REQKEY_DEFL_GROUP_KEYRING: - default: - LBUG(); - } - - LASSERT(ring); - key_unlink(ring, key); - key_put(ring); -} - -static -struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_kr(struct ptlrpc_sec *sec, - struct vfs_cred *vcred, - int create, int remove_dead) -{ - struct obd_import *imp = sec->ps_import; - struct gss_sec_keyring *gsec_kr = sec2gsec_keyring(sec); - struct ptlrpc_cli_ctx *ctx = NULL; - unsigned int is_root = 0, create_new = 0; - struct key *key; - char desc[24]; - char *coinfo; - int coinfo_size; - char *co_flags = ""; - - LASSERT(imp != NULL); - - is_root = user_is_root(sec, vcred); - - /* a little bit optimization for root context */ - if (is_root) { - ctx = sec_lookup_root_ctx_kr(sec); - /* - * Only lookup directly for REVERSE sec, which should - * always succeed. - */ - if (ctx || sec_is_reverse(sec)) - return ctx; - } - - LASSERT(create != 0); - - /* for root context, obtain lock and check again, this time hold - * the root upcall lock, make sure nobody else populated new root - * context after last check. */ - if (is_root) { - mutex_lock(&gsec_kr->gsk_root_uc_lock); - - ctx = sec_lookup_root_ctx_kr(sec); - if (ctx) - goto out; - - /* update reverse handle for root user */ - sec2gsec(sec)->gs_rvs_hdl = gss_get_next_ctx_index(); - - switch (sec->ps_part) { - case LUSTRE_SP_MDT: - co_flags = "m"; - break; - case LUSTRE_SP_OST: - co_flags = "o"; - break; - case LUSTRE_SP_MGC: - co_flags = "rmo"; - break; - case LUSTRE_SP_CLI: - co_flags = "r"; - break; - case LUSTRE_SP_MGS: - default: - LBUG(); - } - } - - /* in case of setuid, key will be constructed as owner of fsuid/fsgid, - * but we do authentication based on real uid/gid. the key permission - * bits will be exactly as POS_ALL, so only processes who subscribed - * this key could have the access, although the quota might be counted - * on others (fsuid/fsgid). - * - * keyring will use fsuid/fsgid as upcall parameters, so we have to - * encode real uid/gid into callout info. - */ - - construct_key_desc(desc, sizeof(desc), sec, vcred->vc_uid); - - /* callout info format: - * secid:mech:uid:gid:flags:svc_type:peer_nid:target_uuid - */ - coinfo_size = sizeof(struct obd_uuid) + MAX_OBD_NAME + 64; - OBD_ALLOC(coinfo, coinfo_size); - if (coinfo == NULL) - goto out; - - snprintf(coinfo, coinfo_size, "%d:%s:%u:%u:%s:%d:"LPX64":%s", - sec->ps_id, sec2gsec(sec)->gs_mech->gm_name, - vcred->vc_uid, vcred->vc_gid, - co_flags, import_to_gss_svc(imp), - imp->imp_connection->c_peer.nid, imp->imp_obd->obd_name); - - CDEBUG(D_SEC, "requesting key for %s\n", desc); - - keyring_upcall_lock(gsec_kr); - key = request_key(&gss_key_type, desc, coinfo); - keyring_upcall_unlock(gsec_kr); - - OBD_FREE(coinfo, coinfo_size); - - if (IS_ERR(key)) { - CERROR("failed request key: %ld\n", PTR_ERR(key)); - goto out; - } - CDEBUG(D_SEC, "obtained key %08x for %s\n", key->serial, desc); - - /* once payload.data was pointed to a ctx, it never changes until - * we de-associate them; but parallel request_key() may return - * a key with payload.data == NULL at the same time. so we still - * need wirtelock of key->sem to serialize them. */ - down_write(&key->sem); - - if (likely(key->payload.data != NULL)) { - ctx = key->payload.data; - - LASSERT(atomic_read(&ctx->cc_refcount) >= 1); - LASSERT(ctx2gctx_keyring(ctx)->gck_key == key); - LASSERT(atomic_read(&key->usage) >= 2); - - /* simply take a ref and return. it's upper layer's - * responsibility to detect & replace dead ctx. */ - atomic_inc(&ctx->cc_refcount); - } else { - /* pre initialization with a cli_ctx. this can't be done in - * key_instantiate() because we'v no enough information - * there. */ - ctx = ctx_create_kr(sec, vcred); - if (ctx != NULL) { - ctx_enlist_kr(ctx, is_root, 0); - bind_key_ctx(key, ctx); - - ctx_start_timer_kr(ctx, KEYRING_UPCALL_TIMEOUT); - - CDEBUG(D_SEC, "installed key %p <-> ctx %p (sec %p)\n", - key, ctx, sec); - } else { - /* we'd prefer to call key_revoke(), but we more like - * to revoke it within this key->sem locked period. */ - key_revoke_locked(key); - } - - create_new = 1; - } - - up_write(&key->sem); - - if (is_root && create_new) - request_key_unlink(key); - - key_put(key); -out: - if (is_root) - mutex_unlock(&gsec_kr->gsk_root_uc_lock); - return ctx; -} - -static -void gss_sec_release_ctx_kr(struct ptlrpc_sec *sec, - struct ptlrpc_cli_ctx *ctx, - int sync) -{ - LASSERT(atomic_read(&sec->ps_refcount) > 0); - LASSERT(atomic_read(&ctx->cc_refcount) == 0); - ctx_release_kr(ctx, sync); -} - -/* - * flush context of normal user, we must resort to keyring itself to find out - * contexts which belong to me. - * - * Note here we suppose only to flush _my_ context, the "uid" will - * be ignored in the search. - */ -static -void flush_user_ctx_cache_kr(struct ptlrpc_sec *sec, - uid_t uid, - int grace, int force) -{ - struct key *key; - char desc[24]; - - /* nothing to do for reverse or rootonly sec */ - if (sec_is_reverse(sec) || sec_is_rootonly(sec)) - return; - - construct_key_desc(desc, sizeof(desc), sec, uid); - - /* there should be only one valid key, but we put it in the - * loop in case of any weird cases */ - for (;;) { - key = request_key(&gss_key_type, desc, NULL); - if (IS_ERR(key)) { - CDEBUG(D_SEC, "No more key found for current user\n"); - break; - } - - down_write(&key->sem); - - kill_key_locked(key); - - /* kill_key_locked() should usually revoke the key, but we - * revoke it again to make sure, e.g. some case the key may - * not well coupled with a context. */ - key_revoke_locked(key); - - up_write(&key->sem); - - key_put(key); - } -} - -/* - * flush context of root or all, we iterate through the list. - */ -static -void flush_spec_ctx_cache_kr(struct ptlrpc_sec *sec, - uid_t uid, - int grace, int force) -{ - struct gss_sec_keyring *gsec_kr; - struct hlist_head freelist = HLIST_HEAD_INIT; - struct hlist_node *next; - struct ptlrpc_cli_ctx *ctx; - - gsec_kr = sec2gsec_keyring(sec); - - spin_lock(&sec->ps_lock); - hlist_for_each_entry_safe(ctx, next, - &gsec_kr->gsk_clist, cc_cache) { - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - - if (uid != -1 && uid != ctx->cc_vcred.vc_uid) - continue; - - /* at this moment there's at least 2 base reference: - * key association and in-list. */ - if (atomic_read(&ctx->cc_refcount) > 2) { - if (!force) - continue; - CWARN("flush busy ctx %p(%u->%s, extra ref %d)\n", - ctx, ctx->cc_vcred.vc_uid, - sec2target_str(ctx->cc_sec), - atomic_read(&ctx->cc_refcount) - 2); - } - - set_bit(PTLRPC_CTX_DEAD_BIT, &ctx->cc_flags); - if (!grace) - clear_bit(PTLRPC_CTX_UPTODATE_BIT, &ctx->cc_flags); - - atomic_inc(&ctx->cc_refcount); - - if (ctx_unlist_kr(ctx, 1)) { - hlist_add_head(&ctx->cc_cache, &freelist); - } else { - LASSERT(atomic_read(&ctx->cc_refcount) >= 2); - atomic_dec(&ctx->cc_refcount); - } - } - spin_unlock(&sec->ps_lock); - - dispose_ctx_list_kr(&freelist); -} - -static -int gss_sec_flush_ctx_cache_kr(struct ptlrpc_sec *sec, - uid_t uid, int grace, int force) -{ - CDEBUG(D_SEC, "sec %p(%d, nctx %d), uid %d, grace %d, force %d\n", - sec, atomic_read(&sec->ps_refcount), - atomic_read(&sec->ps_nctx), - uid, grace, force); - - if (uid != -1 && uid != 0) - flush_user_ctx_cache_kr(sec, uid, grace, force); - else - flush_spec_ctx_cache_kr(sec, uid, grace, force); - - return 0; -} - -static -void gss_sec_gc_ctx_kr(struct ptlrpc_sec *sec) -{ - struct gss_sec_keyring *gsec_kr = sec2gsec_keyring(sec); - struct hlist_head freelist = HLIST_HEAD_INIT; - struct hlist_node *next; - struct ptlrpc_cli_ctx *ctx; - - CWARN("running gc\n"); - - spin_lock(&sec->ps_lock); - hlist_for_each_entry_safe(ctx, next, - &gsec_kr->gsk_clist, cc_cache) { - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - - atomic_inc(&ctx->cc_refcount); - - if (cli_ctx_check_death(ctx) && ctx_unlist_kr(ctx, 1)) { - hlist_add_head(&ctx->cc_cache, &freelist); - CWARN("unhashed ctx %p\n", ctx); - } else { - LASSERT(atomic_read(&ctx->cc_refcount) >= 2); - atomic_dec(&ctx->cc_refcount); - } - } - spin_unlock(&sec->ps_lock); - - dispose_ctx_list_kr(&freelist); -} - -static -int gss_sec_display_kr(struct ptlrpc_sec *sec, struct seq_file *seq) -{ - struct gss_sec_keyring *gsec_kr = sec2gsec_keyring(sec); - struct hlist_node *next; - struct ptlrpc_cli_ctx *ctx; - struct gss_cli_ctx *gctx; - time_t now = cfs_time_current_sec(); - - spin_lock(&sec->ps_lock); - hlist_for_each_entry_safe(ctx, next, - &gsec_kr->gsk_clist, cc_cache) { - struct key *key; - char flags_str[40]; - char mech[40]; - - gctx = ctx2gctx(ctx); - key = ctx2gctx_keyring(ctx)->gck_key; - - gss_cli_ctx_flags2str(ctx->cc_flags, - flags_str, sizeof(flags_str)); - - if (gctx->gc_mechctx) - lgss_display(gctx->gc_mechctx, mech, sizeof(mech)); - else - snprintf(mech, sizeof(mech), "N/A"); - mech[sizeof(mech) - 1] = '\0'; - - seq_printf(seq, "%p: uid %u, ref %d, expire %ld(%+ld), fl %s, " - "seq %d, win %u, key %08x(ref %d), " - "hdl "LPX64":"LPX64", mech: %s\n", - ctx, ctx->cc_vcred.vc_uid, - atomic_read(&ctx->cc_refcount), - ctx->cc_expire, - ctx->cc_expire ? ctx->cc_expire - now : 0, - flags_str, - atomic_read(&gctx->gc_seq), - gctx->gc_win, - key ? key->serial : 0, - key ? atomic_read(&key->usage) : 0, - gss_handle_to_u64(&gctx->gc_handle), - gss_handle_to_u64(&gctx->gc_svc_handle), - mech); - } - spin_unlock(&sec->ps_lock); - - return 0; -} - -/**************************************** - * cli_ctx apis * - ****************************************/ - -static -int gss_cli_ctx_refresh_kr(struct ptlrpc_cli_ctx *ctx) -{ - /* upcall is already on the way */ - return 0; -} - -static -int gss_cli_ctx_validate_kr(struct ptlrpc_cli_ctx *ctx) -{ - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - LASSERT(ctx->cc_sec); - - if (cli_ctx_check_death(ctx)) { - kill_ctx_kr(ctx); - return 1; - } - - if (cli_ctx_is_ready(ctx)) - return 0; - return 1; -} - -static -void gss_cli_ctx_die_kr(struct ptlrpc_cli_ctx *ctx, int grace) -{ - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - LASSERT(ctx->cc_sec); - - cli_ctx_expire(ctx); - kill_ctx_kr(ctx); -} - -/**************************************** - * (reverse) service * - ****************************************/ - -/* - * reverse context could have nothing to do with keyrings. here we still keep - * the version which bind to a key, for future reference. - */ -#define HAVE_REVERSE_CTX_NOKEY - - -static -int sec_install_rctx_kr(struct ptlrpc_sec *sec, - struct ptlrpc_svc_ctx *svc_ctx) -{ - struct ptlrpc_cli_ctx *cli_ctx; - struct vfs_cred vcred = { 0, 0 }; - int rc; - - LASSERT(sec); - LASSERT(svc_ctx); - - cli_ctx = ctx_create_kr(sec, &vcred); - if (cli_ctx == NULL) - return -ENOMEM; - - rc = gss_copy_rvc_cli_ctx(cli_ctx, svc_ctx); - if (rc) { - CERROR("failed copy reverse cli ctx: %d\n", rc); - - ctx_put_kr(cli_ctx, 1); - return rc; - } - - rvs_sec_install_root_ctx_kr(sec, cli_ctx, NULL); - - ctx_put_kr(cli_ctx, 1); - - return 0; -} - - -/**************************************** - * service apis * - ****************************************/ - -static -int gss_svc_accept_kr(struct ptlrpc_request *req) -{ - return gss_svc_accept(&gss_policy_keyring, req); -} - -static -int gss_svc_install_rctx_kr(struct obd_import *imp, - struct ptlrpc_svc_ctx *svc_ctx) -{ - struct ptlrpc_sec *sec; - int rc; - - sec = sptlrpc_import_sec_ref(imp); - LASSERT(sec); - - rc = sec_install_rctx_kr(sec, svc_ctx); - sptlrpc_sec_put(sec); - - return rc; -} - -/**************************************** - * key apis * - ****************************************/ - -static -int gss_kt_instantiate(struct key *key, const void *data, size_t datalen) -{ - int rc; - - if (data != NULL || datalen != 0) { - CERROR("invalid: data %p, len %lu\n", data, (long)datalen); - return -EINVAL; - } - - if (key->payload.data != 0) { - CERROR("key already have payload\n"); - return -EINVAL; - } - - /* link the key to session keyring, so following context negotiation - * rpc fired from user space could find this key. This will be unlinked - * automatically when upcall processes die. - * - * we can't do this through keyctl from userspace, because the upcall - * might be neither possessor nor owner of the key (setuid). - * - * the session keyring is created upon upcall, and don't change all - * the way until upcall finished, so rcu lock is not needed here. - */ - LASSERT(key_tgcred(current)->session_keyring); - - lockdep_off(); - rc = key_link(key_tgcred(current)->session_keyring, key); - lockdep_on(); - if (unlikely(rc)) { - CERROR("failed to link key %08x to keyring %08x: %d\n", - key->serial, - key_tgcred(current)->session_keyring->serial, rc); - return rc; - } - - CDEBUG(D_SEC, "key %p instantiated, ctx %p\n", key, key->payload.data); - return 0; -} - -/* - * called with key semaphore write locked. it means we can operate - * on the context without fear of losing refcount. - */ -static -int gss_kt_update(struct key *key, const void *data, size_t datalen) -{ - struct ptlrpc_cli_ctx *ctx = key->payload.data; - struct gss_cli_ctx *gctx; - rawobj_t tmpobj = RAWOBJ_EMPTY; - __u32 datalen32 = (__u32) datalen; - int rc; - - if (data == NULL || datalen == 0) { - CWARN("invalid: data %p, len %lu\n", data, (long)datalen); - return -EINVAL; - } - - /* if upcall finished negotiation too fast (mostly likely because - * of local error happened) and call kt_update(), the ctx - * might be still NULL. but the key will finally be associate - * with a context, or be revoked. if key status is fine, return - * -EAGAIN to allow userspace sleep a while and call again. */ - if (ctx == NULL) { - CDEBUG(D_SEC, "update too soon: key %p(%x) flags %lx\n", - key, key->serial, key->flags); - - rc = key_validate(key); - if (rc == 0) - return -EAGAIN; - else - return rc; - } - - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - LASSERT(ctx->cc_sec); - - ctx_clear_timer_kr(ctx); - - /* don't proceed if already refreshed */ - if (cli_ctx_is_refreshed(ctx)) { - CWARN("ctx already done refresh\n"); - return 0; - } - - sptlrpc_cli_ctx_get(ctx); - gctx = ctx2gctx(ctx); - - rc = buffer_extract_bytes(&data, &datalen32, &gctx->gc_win, - sizeof(gctx->gc_win)); - if (rc) { - CERROR("failed extract seq_win\n"); - goto out; - } - - if (gctx->gc_win == 0) { - __u32 nego_rpc_err, nego_gss_err; - - rc = buffer_extract_bytes(&data, &datalen32, &nego_rpc_err, - sizeof(nego_rpc_err)); - if (rc) { - CERROR("failed to extrace rpc rc\n"); - goto out; - } - - rc = buffer_extract_bytes(&data, &datalen32, &nego_gss_err, - sizeof(nego_gss_err)); - if (rc) { - CERROR("failed to extrace gss rc\n"); - goto out; - } - - CERROR("negotiation: rpc err %d, gss err %x\n", - nego_rpc_err, nego_gss_err); - - rc = nego_rpc_err ? nego_rpc_err : -EACCES; - } else { - rc = rawobj_extract_local_alloc(&gctx->gc_handle, - (__u32 **) &data, &datalen32); - if (rc) { - CERROR("failed extract handle\n"); - goto out; - } - - rc = rawobj_extract_local(&tmpobj, (__u32 **) &data,&datalen32); - if (rc) { - CERROR("failed extract mech\n"); - goto out; - } - - rc = lgss_import_sec_context(&tmpobj, - sec2gsec(ctx->cc_sec)->gs_mech, - &gctx->gc_mechctx); - if (rc != GSS_S_COMPLETE) - CERROR("failed import context\n"); - else - rc = 0; - } -out: - /* we don't care what current status of this ctx, even someone else - * is operating on the ctx at the same time. we just add up our own - * opinions here. */ - if (rc == 0) { - gss_cli_ctx_uptodate(gctx); - } else { - /* this will also revoke the key. has to be done before - * wakeup waiters otherwise they can find the stale key */ - kill_key_locked(key); - - cli_ctx_expire(ctx); - - if (rc != -ERESTART) - set_bit(PTLRPC_CTX_ERROR_BIT, &ctx->cc_flags); - } - - /* let user space think it's a success */ - sptlrpc_cli_ctx_put(ctx, 1); - return 0; -} - -static -int gss_kt_match(const struct key *key, const void *desc) -{ - return (strcmp(key->description, (const char *) desc) == 0); -} - -static -void gss_kt_destroy(struct key *key) -{ - LASSERT(key->payload.data == NULL); - CDEBUG(D_SEC, "destroy key %p\n", key); -} - -static -void gss_kt_describe(const struct key *key, struct seq_file *s) -{ - if (key->description == NULL) - seq_puts(s, "[null]"); - else - seq_puts(s, key->description); -} - -static struct key_type gss_key_type = -{ - .name = "lgssc", - .def_datalen = 0, - .instantiate = gss_kt_instantiate, - .update = gss_kt_update, - .match = gss_kt_match, - .destroy = gss_kt_destroy, - .describe = gss_kt_describe, -}; - -/**************************************** - * lustre gss keyring policy * - ****************************************/ - -static struct ptlrpc_ctx_ops gss_keyring_ctxops = { - .match = gss_cli_ctx_match, - .refresh = gss_cli_ctx_refresh_kr, - .validate = gss_cli_ctx_validate_kr, - .die = gss_cli_ctx_die_kr, - .sign = gss_cli_ctx_sign, - .verify = gss_cli_ctx_verify, - .seal = gss_cli_ctx_seal, - .unseal = gss_cli_ctx_unseal, - .wrap_bulk = gss_cli_ctx_wrap_bulk, - .unwrap_bulk = gss_cli_ctx_unwrap_bulk, -}; - -static struct ptlrpc_sec_cops gss_sec_keyring_cops = { - .create_sec = gss_sec_create_kr, - .destroy_sec = gss_sec_destroy_kr, - .kill_sec = gss_sec_kill, - .lookup_ctx = gss_sec_lookup_ctx_kr, - .release_ctx = gss_sec_release_ctx_kr, - .flush_ctx_cache = gss_sec_flush_ctx_cache_kr, - .gc_ctx = gss_sec_gc_ctx_kr, - .install_rctx = gss_sec_install_rctx, - .alloc_reqbuf = gss_alloc_reqbuf, - .free_reqbuf = gss_free_reqbuf, - .alloc_repbuf = gss_alloc_repbuf, - .free_repbuf = gss_free_repbuf, - .enlarge_reqbuf = gss_enlarge_reqbuf, - .display = gss_sec_display_kr, -}; - -static struct ptlrpc_sec_sops gss_sec_keyring_sops = { - .accept = gss_svc_accept_kr, - .invalidate_ctx = gss_svc_invalidate_ctx, - .alloc_rs = gss_svc_alloc_rs, - .authorize = gss_svc_authorize, - .free_rs = gss_svc_free_rs, - .free_ctx = gss_svc_free_ctx, - .prep_bulk = gss_svc_prep_bulk, - .unwrap_bulk = gss_svc_unwrap_bulk, - .wrap_bulk = gss_svc_wrap_bulk, - .install_rctx = gss_svc_install_rctx_kr, -}; - -static struct ptlrpc_sec_policy gss_policy_keyring = { - .sp_owner = THIS_MODULE, - .sp_name = "gss.keyring", - .sp_policy = SPTLRPC_POLICY_GSS, - .sp_cops = &gss_sec_keyring_cops, - .sp_sops = &gss_sec_keyring_sops, -}; - - -int __init gss_init_keyring(void) -{ - int rc; - - rc = register_key_type(&gss_key_type); - if (rc) { - CERROR("failed to register keyring type: %d\n", rc); - return rc; - } - - rc = sptlrpc_register_policy(&gss_policy_keyring); - if (rc) { - unregister_key_type(&gss_key_type); - return rc; - } - - return 0; -} - -void __exit gss_exit_keyring(void) -{ - unregister_key_type(&gss_key_type); - sptlrpc_unregister_policy(&gss_policy_keyring); -} diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5.h b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5.h deleted file mode 100644 index 676d4b96311a..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Modifications for Lustre - * - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -/* - * linux/include/linux/sunrpc/gss_krb5_types.h - * - * Adapted from MIT Kerberos 5-1.2.1 lib/include/krb5.h, - * lib/gssapi/krb5/gssapiP_krb5.h, and others - * - * Copyright (c) 2000 The Regents of the University of Michigan. - * All rights reserved. - * - * Andy Adamson <andros@umich.edu> - * Bruce Fields <bfields@umich.edu> - */ - -/* - * Copyright 1995 by the Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - * - */ - -#ifndef PTLRPC_GSS_KRB5_H -#define PTLRPC_GSS_KRB5_H - -/* - * RFC 4142 - */ - -#define KG_USAGE_ACCEPTOR_SEAL 22 -#define KG_USAGE_ACCEPTOR_SIGN 23 -#define KG_USAGE_INITIATOR_SEAL 24 -#define KG_USAGE_INITIATOR_SIGN 25 - -#define KG_TOK_MIC_MSG 0x0404 -#define KG_TOK_WRAP_MSG 0x0504 - -#define FLAG_SENDER_IS_ACCEPTOR 0x01 -#define FLAG_WRAP_CONFIDENTIAL 0x02 -#define FLAG_ACCEPTOR_SUBKEY 0x04 - -struct krb5_header { - __u16 kh_tok_id; /* token id */ - __u8 kh_flags; /* acceptor flags */ - __u8 kh_filler; /* 0xff */ - __u16 kh_ec; /* extra count */ - __u16 kh_rrc; /* right rotation count */ - __u64 kh_seq; /* sequence number */ - __u8 kh_cksum[0]; /* checksum */ -}; - -struct krb5_keyblock { - rawobj_t kb_key; - struct ll_crypto_cipher *kb_tfm; -}; - -struct krb5_ctx { - unsigned int kc_initiate:1, - kc_cfx:1, - kc_seed_init:1, - kc_have_acceptor_subkey:1; - __s32 kc_endtime; - __u8 kc_seed[16]; - __u64 kc_seq_send; - __u64 kc_seq_recv; - __u32 kc_enctype; - struct krb5_keyblock kc_keye; /* encryption */ - struct krb5_keyblock kc_keyi; /* integrity */ - struct krb5_keyblock kc_keyc; /* checksum */ - rawobj_t kc_mech_used; -}; - -enum sgn_alg { - SGN_ALG_DES_MAC_MD5 = 0x0000, - SGN_ALG_MD2_5 = 0x0001, - SGN_ALG_DES_MAC = 0x0002, - SGN_ALG_3 = 0x0003, /* not published */ - SGN_ALG_HMAC_MD5 = 0x0011, /* microsoft w2k; no support */ - SGN_ALG_HMAC_SHA1_DES3_KD = 0x0004 -}; - -enum seal_alg { - SEAL_ALG_NONE = 0xffff, - SEAL_ALG_DES = 0x0000, - SEAL_ALG_1 = 0x0001, /* not published */ - SEAL_ALG_MICROSOFT_RC4 = 0x0010, /* microsoft w2k; no support */ - SEAL_ALG_DES3KD = 0x0002 -}; - -#define CKSUMTYPE_CRC32 0x0001 -#define CKSUMTYPE_RSA_MD4 0x0002 -#define CKSUMTYPE_RSA_MD4_DES 0x0003 -#define CKSUMTYPE_DESCBC 0x0004 -/* des-mac-k */ -/* rsa-md4-des-k */ -#define CKSUMTYPE_RSA_MD5 0x0007 -#define CKSUMTYPE_RSA_MD5_DES 0x0008 -#define CKSUMTYPE_NIST_SHA 0x0009 -#define CKSUMTYPE_HMAC_SHA1_DES3 0x000c -#define CKSUMTYPE_HMAC_SHA1_96_AES128 0x000f -#define CKSUMTYPE_HMAC_SHA1_96_AES256 0x0010 -#define CKSUMTYPE_HMAC_MD5_ARCFOUR -138 - -/* from gssapi_err_krb5.h */ -#define KG_CCACHE_NOMATCH (39756032L) -#define KG_KEYTAB_NOMATCH (39756033L) -#define KG_TGT_MISSING (39756034L) -#define KG_NO_SUBKEY (39756035L) -#define KG_CONTEXT_ESTABLISHED (39756036L) -#define KG_BAD_SIGN_TYPE (39756037L) -#define KG_BAD_LENGTH (39756038L) -#define KG_CTX_INCOMPLETE (39756039L) -#define KG_CONTEXT (39756040L) -#define KG_CRED (39756041L) -#define KG_ENC_DESC (39756042L) -#define KG_BAD_SEQ (39756043L) -#define KG_EMPTY_CCACHE (39756044L) -#define KG_NO_CTYPES (39756045L) - -/* per Kerberos v5 protocol spec crypto types from the wire. - * these get mapped to linux kernel crypto routines. - */ -#define ENCTYPE_NULL 0x0000 -#define ENCTYPE_DES_CBC_CRC 0x0001 /* DES cbc mode with CRC-32 */ -#define ENCTYPE_DES_CBC_MD4 0x0002 /* DES cbc mode with RSA-MD4 */ -#define ENCTYPE_DES_CBC_MD5 0x0003 /* DES cbc mode with RSA-MD5 */ -#define ENCTYPE_DES_CBC_RAW 0x0004 /* DES cbc mode raw */ -/* XXX deprecated? */ -#define ENCTYPE_DES3_CBC_SHA 0x0005 /* DES-3 cbc mode with NIST-SHA */ -#define ENCTYPE_DES3_CBC_RAW 0x0006 /* DES-3 cbc mode raw */ -#define ENCTYPE_DES_HMAC_SHA1 0x0008 -#define ENCTYPE_DES3_CBC_SHA1 0x0010 -#define ENCTYPE_AES128_CTS_HMAC_SHA1_96 0x0011 -#define ENCTYPE_AES256_CTS_HMAC_SHA1_96 0x0012 -#define ENCTYPE_ARCFOUR_HMAC 0x0017 -#define ENCTYPE_ARCFOUR_HMAC_EXP 0x0018 -#define ENCTYPE_UNKNOWN 0x01ff - -#endif /* PTLRPC_GSS_KRB5_H */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c deleted file mode 100644 index d03f6c114171..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c +++ /dev/null @@ -1,1786 +0,0 @@ -/* - * Modifications for Lustre - * - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * - * Copyright (c) 2011, 2012, Intel Corporation. - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -/* - * linux/net/sunrpc/gss_krb5_mech.c - * linux/net/sunrpc/gss_krb5_crypto.c - * linux/net/sunrpc/gss_krb5_seal.c - * linux/net/sunrpc/gss_krb5_seqnum.c - * linux/net/sunrpc/gss_krb5_unseal.c - * - * Copyright (c) 2001 The Regents of the University of Michigan. - * All rights reserved. - * - * Andy Adamson <andros@umich.edu> - * J. Bruce Fields <bfields@umich.edu> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define DEBUG_SUBSYSTEM S_SEC -#include <linux/init.h> -#include <linux/module.h> -#include <linux/slab.h> -#include <linux/crypto.h> -#include <linux/mutex.h> - -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre/lustre_idl.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_sec.h> - -#include "gss_err.h" -#include "gss_internal.h" -#include "gss_api.h" -#include "gss_asn1.h" -#include "gss_krb5.h" - -static spinlock_t krb5_seq_lock; - -struct krb5_enctype { - char *ke_dispname; - char *ke_enc_name; /* linux tfm name */ - char *ke_hash_name; /* linux tfm name */ - int ke_enc_mode; /* linux tfm mode */ - int ke_hash_size; /* checksum size */ - int ke_conf_size; /* confounder size */ - unsigned int ke_hash_hmac:1; /* is hmac? */ -}; - -/* - * NOTE: for aes128-cts and aes256-cts, MIT implementation use CTS encryption. - * but currently we simply CBC with padding, because linux doesn't support CTS - * yet. this need to be fixed in the future. - */ -static struct krb5_enctype enctypes[] = { - [ENCTYPE_DES_CBC_RAW] = { /* des-cbc-md5 */ - "des-cbc-md5", - "cbc(des)", - "md5", - 0, - 16, - 8, - 0, - }, - [ENCTYPE_DES3_CBC_RAW] = { /* des3-hmac-sha1 */ - "des3-hmac-sha1", - "cbc(des3_ede)", - "hmac(sha1)", - 0, - 20, - 8, - 1, - }, - [ENCTYPE_AES128_CTS_HMAC_SHA1_96] = { /* aes128-cts */ - "aes128-cts-hmac-sha1-96", - "cbc(aes)", - "hmac(sha1)", - 0, - 12, - 16, - 1, - }, - [ENCTYPE_AES256_CTS_HMAC_SHA1_96] = { /* aes256-cts */ - "aes256-cts-hmac-sha1-96", - "cbc(aes)", - "hmac(sha1)", - 0, - 12, - 16, - 1, - }, - [ENCTYPE_ARCFOUR_HMAC] = { /* arcfour-hmac-md5 */ - "arcfour-hmac-md5", - "ecb(arc4)", - "hmac(md5)", - 0, - 16, - 8, - 1, - }, -}; - -#define MAX_ENCTYPES sizeof(enctypes)/sizeof(struct krb5_enctype) - -static const char * enctype2str(__u32 enctype) -{ - if (enctype < MAX_ENCTYPES && enctypes[enctype].ke_dispname) - return enctypes[enctype].ke_dispname; - - return "unknown"; -} - -static -int keyblock_init(struct krb5_keyblock *kb, char *alg_name, int alg_mode) -{ - kb->kb_tfm = crypto_alloc_blkcipher(alg_name, alg_mode, 0); - if (IS_ERR(kb->kb_tfm)) { - CERROR("failed to alloc tfm: %s, mode %d\n", - alg_name, alg_mode); - return -1; - } - - if (crypto_blkcipher_setkey(kb->kb_tfm, kb->kb_key.data, kb->kb_key.len)) { - CERROR("failed to set %s key, len %d\n", - alg_name, kb->kb_key.len); - return -1; - } - - return 0; -} - -static -int krb5_init_keys(struct krb5_ctx *kctx) -{ - struct krb5_enctype *ke; - - if (kctx->kc_enctype >= MAX_ENCTYPES || - enctypes[kctx->kc_enctype].ke_hash_size == 0) { - CERROR("unsupported enctype %x\n", kctx->kc_enctype); - return -1; - } - - ke = &enctypes[kctx->kc_enctype]; - - /* tfm arc4 is stateful, user should alloc-use-free by his own */ - if (kctx->kc_enctype != ENCTYPE_ARCFOUR_HMAC && - keyblock_init(&kctx->kc_keye, ke->ke_enc_name, ke->ke_enc_mode)) - return -1; - - /* tfm hmac is stateful, user should alloc-use-free by his own */ - if (ke->ke_hash_hmac == 0 && - keyblock_init(&kctx->kc_keyi, ke->ke_enc_name, ke->ke_enc_mode)) - return -1; - if (ke->ke_hash_hmac == 0 && - keyblock_init(&kctx->kc_keyc, ke->ke_enc_name, ke->ke_enc_mode)) - return -1; - - return 0; -} - -static -void keyblock_free(struct krb5_keyblock *kb) -{ - rawobj_free(&kb->kb_key); - if (kb->kb_tfm) - crypto_free_blkcipher(kb->kb_tfm); -} - -static -int keyblock_dup(struct krb5_keyblock *new, struct krb5_keyblock *kb) -{ - return rawobj_dup(&new->kb_key, &kb->kb_key); -} - -static -int get_bytes(char **ptr, const char *end, void *res, int len) -{ - char *p, *q; - p = *ptr; - q = p + len; - if (q > end || q < p) - return -1; - memcpy(res, p, len); - *ptr = q; - return 0; -} - -static -int get_rawobj(char **ptr, const char *end, rawobj_t *res) -{ - char *p, *q; - __u32 len; - - p = *ptr; - if (get_bytes(&p, end, &len, sizeof(len))) - return -1; - - q = p + len; - if (q > end || q < p) - return -1; - - OBD_ALLOC_LARGE(res->data, len); - if (!res->data) - return -1; - - res->len = len; - memcpy(res->data, p, len); - *ptr = q; - return 0; -} - -static -int get_keyblock(char **ptr, const char *end, - struct krb5_keyblock *kb, __u32 keysize) -{ - char *buf; - - OBD_ALLOC_LARGE(buf, keysize); - if (buf == NULL) - return -1; - - if (get_bytes(ptr, end, buf, keysize)) { - OBD_FREE_LARGE(buf, keysize); - return -1; - } - - kb->kb_key.len = keysize; - kb->kb_key.data = buf; - return 0; -} - -static -void delete_context_kerberos(struct krb5_ctx *kctx) -{ - rawobj_free(&kctx->kc_mech_used); - - keyblock_free(&kctx->kc_keye); - keyblock_free(&kctx->kc_keyi); - keyblock_free(&kctx->kc_keyc); -} - -static -__u32 import_context_rfc1964(struct krb5_ctx *kctx, char *p, char *end) -{ - unsigned int tmp_uint, keysize; - - /* seed_init flag */ - if (get_bytes(&p, end, &tmp_uint, sizeof(tmp_uint))) - goto out_err; - kctx->kc_seed_init = (tmp_uint != 0); - - /* seed */ - if (get_bytes(&p, end, kctx->kc_seed, sizeof(kctx->kc_seed))) - goto out_err; - - /* sign/seal algorithm, not really used now */ - if (get_bytes(&p, end, &tmp_uint, sizeof(tmp_uint)) || - get_bytes(&p, end, &tmp_uint, sizeof(tmp_uint))) - goto out_err; - - /* end time */ - if (get_bytes(&p, end, &kctx->kc_endtime, sizeof(kctx->kc_endtime))) - goto out_err; - - /* seq send */ - if (get_bytes(&p, end, &tmp_uint, sizeof(tmp_uint))) - goto out_err; - kctx->kc_seq_send = tmp_uint; - - /* mech oid */ - if (get_rawobj(&p, end, &kctx->kc_mech_used)) - goto out_err; - - /* old style enc/seq keys in format: - * - enctype (u32) - * - keysize (u32) - * - keydata - * we decompose them to fit into the new context - */ - - /* enc key */ - if (get_bytes(&p, end, &kctx->kc_enctype, sizeof(kctx->kc_enctype))) - goto out_err; - - if (get_bytes(&p, end, &keysize, sizeof(keysize))) - goto out_err; - - if (get_keyblock(&p, end, &kctx->kc_keye, keysize)) - goto out_err; - - /* seq key */ - if (get_bytes(&p, end, &tmp_uint, sizeof(tmp_uint)) || - tmp_uint != kctx->kc_enctype) - goto out_err; - - if (get_bytes(&p, end, &tmp_uint, sizeof(tmp_uint)) || - tmp_uint != keysize) - goto out_err; - - if (get_keyblock(&p, end, &kctx->kc_keyc, keysize)) - goto out_err; - - /* old style fallback */ - if (keyblock_dup(&kctx->kc_keyi, &kctx->kc_keyc)) - goto out_err; - - if (p != end) - goto out_err; - - CDEBUG(D_SEC, "successfully imported rfc1964 context\n"); - return 0; -out_err: - return GSS_S_FAILURE; -} - -/* Flags for version 2 context flags */ -#define KRB5_CTX_FLAG_INITIATOR 0x00000001 -#define KRB5_CTX_FLAG_CFX 0x00000002 -#define KRB5_CTX_FLAG_ACCEPTOR_SUBKEY 0x00000004 - -static -__u32 import_context_rfc4121(struct krb5_ctx *kctx, char *p, char *end) -{ - unsigned int tmp_uint, keysize; - - /* end time */ - if (get_bytes(&p, end, &kctx->kc_endtime, sizeof(kctx->kc_endtime))) - goto out_err; - - /* flags */ - if (get_bytes(&p, end, &tmp_uint, sizeof(tmp_uint))) - goto out_err; - - if (tmp_uint & KRB5_CTX_FLAG_INITIATOR) - kctx->kc_initiate = 1; - if (tmp_uint & KRB5_CTX_FLAG_CFX) - kctx->kc_cfx = 1; - if (tmp_uint & KRB5_CTX_FLAG_ACCEPTOR_SUBKEY) - kctx->kc_have_acceptor_subkey = 1; - - /* seq send */ - if (get_bytes(&p, end, &kctx->kc_seq_send, sizeof(kctx->kc_seq_send))) - goto out_err; - - /* enctype */ - if (get_bytes(&p, end, &kctx->kc_enctype, sizeof(kctx->kc_enctype))) - goto out_err; - - /* size of each key */ - if (get_bytes(&p, end, &keysize, sizeof(keysize))) - goto out_err; - - /* number of keys - should always be 3 */ - if (get_bytes(&p, end, &tmp_uint, sizeof(tmp_uint))) - goto out_err; - - if (tmp_uint != 3) { - CERROR("Invalid number of keys: %u\n", tmp_uint); - goto out_err; - } - - /* ke */ - if (get_keyblock(&p, end, &kctx->kc_keye, keysize)) - goto out_err; - /* ki */ - if (get_keyblock(&p, end, &kctx->kc_keyi, keysize)) - goto out_err; - /* ki */ - if (get_keyblock(&p, end, &kctx->kc_keyc, keysize)) - goto out_err; - - CDEBUG(D_SEC, "successfully imported v2 context\n"); - return 0; -out_err: - return GSS_S_FAILURE; -} - -/* - * The whole purpose here is trying to keep user level gss context parsing - * from nfs-utils unchanged as possible as we can, they are not quite mature - * yet, and many stuff still not clear, like heimdal etc. - */ -static -__u32 gss_import_sec_context_kerberos(rawobj_t *inbuf, - struct gss_ctx *gctx) -{ - struct krb5_ctx *kctx; - char *p = (char *) inbuf->data; - char *end = (char *) (inbuf->data + inbuf->len); - unsigned int tmp_uint, rc; - - if (get_bytes(&p, end, &tmp_uint, sizeof(tmp_uint))) { - CERROR("Fail to read version\n"); - return GSS_S_FAILURE; - } - - /* only support 0, 1 for the moment */ - if (tmp_uint > 2) { - CERROR("Invalid version %u\n", tmp_uint); - return GSS_S_FAILURE; - } - - OBD_ALLOC_PTR(kctx); - if (!kctx) - return GSS_S_FAILURE; - - if (tmp_uint == 0 || tmp_uint == 1) { - kctx->kc_initiate = tmp_uint; - rc = import_context_rfc1964(kctx, p, end); - } else { - rc = import_context_rfc4121(kctx, p, end); - } - - if (rc == 0) - rc = krb5_init_keys(kctx); - - if (rc) { - delete_context_kerberos(kctx); - OBD_FREE_PTR(kctx); - - return GSS_S_FAILURE; - } - - gctx->internal_ctx_id = kctx; - return GSS_S_COMPLETE; -} - -static -__u32 gss_copy_reverse_context_kerberos(struct gss_ctx *gctx, - struct gss_ctx *gctx_new) -{ - struct krb5_ctx *kctx = gctx->internal_ctx_id; - struct krb5_ctx *knew; - - OBD_ALLOC_PTR(knew); - if (!knew) - return GSS_S_FAILURE; - - knew->kc_initiate = kctx->kc_initiate ? 0 : 1; - knew->kc_cfx = kctx->kc_cfx; - knew->kc_seed_init = kctx->kc_seed_init; - knew->kc_have_acceptor_subkey = kctx->kc_have_acceptor_subkey; - knew->kc_endtime = kctx->kc_endtime; - - memcpy(knew->kc_seed, kctx->kc_seed, sizeof(kctx->kc_seed)); - knew->kc_seq_send = kctx->kc_seq_recv; - knew->kc_seq_recv = kctx->kc_seq_send; - knew->kc_enctype = kctx->kc_enctype; - - if (rawobj_dup(&knew->kc_mech_used, &kctx->kc_mech_used)) - goto out_err; - - if (keyblock_dup(&knew->kc_keye, &kctx->kc_keye)) - goto out_err; - if (keyblock_dup(&knew->kc_keyi, &kctx->kc_keyi)) - goto out_err; - if (keyblock_dup(&knew->kc_keyc, &kctx->kc_keyc)) - goto out_err; - if (krb5_init_keys(knew)) - goto out_err; - - gctx_new->internal_ctx_id = knew; - CDEBUG(D_SEC, "successfully copied reverse context\n"); - return GSS_S_COMPLETE; - -out_err: - delete_context_kerberos(knew); - OBD_FREE_PTR(knew); - return GSS_S_FAILURE; -} - -static -__u32 gss_inquire_context_kerberos(struct gss_ctx *gctx, - unsigned long *endtime) -{ - struct krb5_ctx *kctx = gctx->internal_ctx_id; - - *endtime = (unsigned long) ((__u32) kctx->kc_endtime); - return GSS_S_COMPLETE; -} - -static -void gss_delete_sec_context_kerberos(void *internal_ctx) -{ - struct krb5_ctx *kctx = internal_ctx; - - delete_context_kerberos(kctx); - OBD_FREE_PTR(kctx); -} - -static -void buf_to_sg(struct scatterlist *sg, void *ptr, int len) -{ - sg_set_buf(sg, ptr, len); -} - -static -__u32 krb5_encrypt(struct crypto_blkcipher *tfm, - int decrypt, - void * iv, - void * in, - void * out, - int length) -{ - struct blkcipher_desc desc; - struct scatterlist sg; - __u8 local_iv[16] = {0}; - __u32 ret = -EINVAL; - - LASSERT(tfm); - desc.tfm = tfm; - desc.info = local_iv; - desc.flags= 0; - - if (length % crypto_blkcipher_blocksize(tfm) != 0) { - CERROR("output length %d mismatch blocksize %d\n", - length, crypto_blkcipher_blocksize(tfm)); - goto out; - } - - if (crypto_blkcipher_ivsize(tfm) > 16) { - CERROR("iv size too large %d\n", crypto_blkcipher_ivsize(tfm)); - goto out; - } - - if (iv) - memcpy(local_iv, iv, crypto_blkcipher_ivsize(tfm)); - - memcpy(out, in, length); - buf_to_sg(&sg, out, length); - - if (decrypt) - ret = crypto_blkcipher_decrypt_iv(&desc, &sg, &sg, length); - else - ret = crypto_blkcipher_encrypt_iv(&desc, &sg, &sg, length); - -out: - return(ret); -} - - -static inline -int krb5_digest_hmac(struct crypto_hash *tfm, - rawobj_t *key, - struct krb5_header *khdr, - int msgcnt, rawobj_t *msgs, - int iovcnt, lnet_kiov_t *iovs, - rawobj_t *cksum) -{ - struct hash_desc desc; - struct scatterlist sg[1]; - int i; - - crypto_hash_setkey(tfm, key->data, key->len); - desc.tfm = tfm; - desc.flags= 0; - - crypto_hash_init(&desc); - - for (i = 0; i < msgcnt; i++) { - if (msgs[i].len == 0) - continue; - buf_to_sg(sg, (char *) msgs[i].data, msgs[i].len); - crypto_hash_update(&desc, sg, msgs[i].len); - } - - for (i = 0; i < iovcnt; i++) { - if (iovs[i].kiov_len == 0) - continue; - - sg_set_page(&sg[0], iovs[i].kiov_page, iovs[i].kiov_len, - iovs[i].kiov_offset); - crypto_hash_update(&desc, sg, iovs[i].kiov_len); - } - - if (khdr) { - buf_to_sg(sg, (char *) khdr, sizeof(*khdr)); - crypto_hash_update(&desc, sg, sizeof(*khdr)); - } - - return crypto_hash_final(&desc, cksum->data); -} - - -static inline -int krb5_digest_norm(struct crypto_hash *tfm, - struct krb5_keyblock *kb, - struct krb5_header *khdr, - int msgcnt, rawobj_t *msgs, - int iovcnt, lnet_kiov_t *iovs, - rawobj_t *cksum) -{ - struct hash_desc desc; - struct scatterlist sg[1]; - int i; - - LASSERT(kb->kb_tfm); - desc.tfm = tfm; - desc.flags= 0; - - crypto_hash_init(&desc); - - for (i = 0; i < msgcnt; i++) { - if (msgs[i].len == 0) - continue; - buf_to_sg(sg, (char *) msgs[i].data, msgs[i].len); - crypto_hash_update(&desc, sg, msgs[i].len); - } - - for (i = 0; i < iovcnt; i++) { - if (iovs[i].kiov_len == 0) - continue; - - sg_set_page(&sg[0], iovs[i].kiov_page, iovs[i].kiov_len, - iovs[i].kiov_offset); - crypto_hash_update(&desc, sg, iovs[i].kiov_len); - } - - if (khdr) { - buf_to_sg(sg, (char *) khdr, sizeof(*khdr)); - crypto_hash_update(&desc, sg, sizeof(*khdr)); - } - - crypto_hash_final(&desc, cksum->data); - - return krb5_encrypt(kb->kb_tfm, 0, NULL, cksum->data, - cksum->data, cksum->len); -} - -/* - * compute (keyed/keyless) checksum against the plain text which appended - * with krb5 wire token header. - */ -static -__s32 krb5_make_checksum(__u32 enctype, - struct krb5_keyblock *kb, - struct krb5_header *khdr, - int msgcnt, rawobj_t *msgs, - int iovcnt, lnet_kiov_t *iovs, - rawobj_t *cksum) -{ - struct krb5_enctype *ke = &enctypes[enctype]; - struct crypto_hash *tfm; - __u32 code = GSS_S_FAILURE; - int rc; - - tfm = ll_crypto_alloc_hash(ke->ke_hash_name, 0, 0); - if (!tfm) { - CERROR("failed to alloc TFM: %s\n", ke->ke_hash_name); - return GSS_S_FAILURE; - } - - cksum->len = crypto_hash_digestsize(tfm); - OBD_ALLOC_LARGE(cksum->data, cksum->len); - if (!cksum->data) { - cksum->len = 0; - goto out_tfm; - } - - if (ke->ke_hash_hmac) - rc = krb5_digest_hmac(tfm, &kb->kb_key, - khdr, msgcnt, msgs, iovcnt, iovs, cksum); - else - rc = krb5_digest_norm(tfm, kb, - khdr, msgcnt, msgs, iovcnt, iovs, cksum); - - if (rc == 0) - code = GSS_S_COMPLETE; -out_tfm: - crypto_free_hash(tfm); - return code; -} - -static void fill_krb5_header(struct krb5_ctx *kctx, - struct krb5_header *khdr, - int privacy) -{ - unsigned char acceptor_flag; - - acceptor_flag = kctx->kc_initiate ? 0 : FLAG_SENDER_IS_ACCEPTOR; - - if (privacy) { - khdr->kh_tok_id = cpu_to_be16(KG_TOK_WRAP_MSG); - khdr->kh_flags = acceptor_flag | FLAG_WRAP_CONFIDENTIAL; - khdr->kh_ec = cpu_to_be16(0); - khdr->kh_rrc = cpu_to_be16(0); - } else { - khdr->kh_tok_id = cpu_to_be16(KG_TOK_MIC_MSG); - khdr->kh_flags = acceptor_flag; - khdr->kh_ec = cpu_to_be16(0xffff); - khdr->kh_rrc = cpu_to_be16(0xffff); - } - - khdr->kh_filler = 0xff; - spin_lock(&krb5_seq_lock); - khdr->kh_seq = cpu_to_be64(kctx->kc_seq_send++); - spin_unlock(&krb5_seq_lock); -} - -static __u32 verify_krb5_header(struct krb5_ctx *kctx, - struct krb5_header *khdr, - int privacy) -{ - unsigned char acceptor_flag; - __u16 tok_id, ec_rrc; - - acceptor_flag = kctx->kc_initiate ? FLAG_SENDER_IS_ACCEPTOR : 0; - - if (privacy) { - tok_id = KG_TOK_WRAP_MSG; - ec_rrc = 0x0; - } else { - tok_id = KG_TOK_MIC_MSG; - ec_rrc = 0xffff; - } - - /* sanity checks */ - if (be16_to_cpu(khdr->kh_tok_id) != tok_id) { - CERROR("bad token id\n"); - return GSS_S_DEFECTIVE_TOKEN; - } - if ((khdr->kh_flags & FLAG_SENDER_IS_ACCEPTOR) != acceptor_flag) { - CERROR("bad direction flag\n"); - return GSS_S_BAD_SIG; - } - if (privacy && (khdr->kh_flags & FLAG_WRAP_CONFIDENTIAL) == 0) { - CERROR("missing confidential flag\n"); - return GSS_S_BAD_SIG; - } - if (khdr->kh_filler != 0xff) { - CERROR("bad filler\n"); - return GSS_S_DEFECTIVE_TOKEN; - } - if (be16_to_cpu(khdr->kh_ec) != ec_rrc || - be16_to_cpu(khdr->kh_rrc) != ec_rrc) { - CERROR("bad EC or RRC\n"); - return GSS_S_DEFECTIVE_TOKEN; - } - return GSS_S_COMPLETE; -} - -static -__u32 gss_get_mic_kerberos(struct gss_ctx *gctx, - int msgcnt, - rawobj_t *msgs, - int iovcnt, - lnet_kiov_t *iovs, - rawobj_t *token) -{ - struct krb5_ctx *kctx = gctx->internal_ctx_id; - struct krb5_enctype *ke = &enctypes[kctx->kc_enctype]; - struct krb5_header *khdr; - rawobj_t cksum = RAWOBJ_EMPTY; - - /* fill krb5 header */ - LASSERT(token->len >= sizeof(*khdr)); - khdr = (struct krb5_header *) token->data; - fill_krb5_header(kctx, khdr, 0); - - /* checksum */ - if (krb5_make_checksum(kctx->kc_enctype, &kctx->kc_keyc, - khdr, msgcnt, msgs, iovcnt, iovs, &cksum)) - return GSS_S_FAILURE; - - LASSERT(cksum.len >= ke->ke_hash_size); - LASSERT(token->len >= sizeof(*khdr) + ke->ke_hash_size); - memcpy(khdr + 1, cksum.data + cksum.len - ke->ke_hash_size, - ke->ke_hash_size); - - token->len = sizeof(*khdr) + ke->ke_hash_size; - rawobj_free(&cksum); - return GSS_S_COMPLETE; -} - -static -__u32 gss_verify_mic_kerberos(struct gss_ctx *gctx, - int msgcnt, - rawobj_t *msgs, - int iovcnt, - lnet_kiov_t *iovs, - rawobj_t *token) -{ - struct krb5_ctx *kctx = gctx->internal_ctx_id; - struct krb5_enctype *ke = &enctypes[kctx->kc_enctype]; - struct krb5_header *khdr; - rawobj_t cksum = RAWOBJ_EMPTY; - __u32 major; - - if (token->len < sizeof(*khdr)) { - CERROR("short signature: %u\n", token->len); - return GSS_S_DEFECTIVE_TOKEN; - } - - khdr = (struct krb5_header *) token->data; - - major = verify_krb5_header(kctx, khdr, 0); - if (major != GSS_S_COMPLETE) { - CERROR("bad krb5 header\n"); - return major; - } - - if (token->len < sizeof(*khdr) + ke->ke_hash_size) { - CERROR("short signature: %u, require %d\n", - token->len, (int) sizeof(*khdr) + ke->ke_hash_size); - return GSS_S_FAILURE; - } - - if (krb5_make_checksum(kctx->kc_enctype, &kctx->kc_keyc, - khdr, msgcnt, msgs, iovcnt, iovs, &cksum)) { - CERROR("failed to make checksum\n"); - return GSS_S_FAILURE; - } - - LASSERT(cksum.len >= ke->ke_hash_size); - if (memcmp(khdr + 1, cksum.data + cksum.len - ke->ke_hash_size, - ke->ke_hash_size)) { - CERROR("checksum mismatch\n"); - rawobj_free(&cksum); - return GSS_S_BAD_SIG; - } - - rawobj_free(&cksum); - return GSS_S_COMPLETE; -} - -static -int add_padding(rawobj_t *msg, int msg_buflen, int blocksize) -{ - int padding; - - padding = (blocksize - (msg->len & (blocksize - 1))) & - (blocksize - 1); - if (!padding) - return 0; - - if (msg->len + padding > msg_buflen) { - CERROR("bufsize %u too small: datalen %u, padding %u\n", - msg_buflen, msg->len, padding); - return -EINVAL; - } - - memset(msg->data + msg->len, padding, padding); - msg->len += padding; - return 0; -} - -static -int krb5_encrypt_rawobjs(struct crypto_blkcipher *tfm, - int mode_ecb, - int inobj_cnt, - rawobj_t *inobjs, - rawobj_t *outobj, - int enc) -{ - struct blkcipher_desc desc; - struct scatterlist src, dst; - __u8 local_iv[16] = {0}, *buf; - __u32 datalen = 0; - int i, rc; - - buf = outobj->data; - desc.tfm = tfm; - desc.info = local_iv; - desc.flags = 0; - - for (i = 0; i < inobj_cnt; i++) { - LASSERT(buf + inobjs[i].len <= outobj->data + outobj->len); - - buf_to_sg(&src, inobjs[i].data, inobjs[i].len); - buf_to_sg(&dst, buf, outobj->len - datalen); - - if (mode_ecb) { - if (enc) - rc = crypto_blkcipher_encrypt( - &desc, &dst, &src, src.length); - else - rc = crypto_blkcipher_decrypt( - &desc, &dst, &src, src.length); - } else { - if (enc) - rc = crypto_blkcipher_encrypt_iv( - &desc, &dst, &src, src.length); - else - rc = crypto_blkcipher_decrypt_iv( - &desc, &dst, &src, src.length); - } - - if (rc) { - CERROR("encrypt error %d\n", rc); - return rc; - } - - datalen += inobjs[i].len; - buf += inobjs[i].len; - } - - outobj->len = datalen; - return 0; -} - -/* - * if adj_nob != 0, we adjust desc->bd_nob to the actual cipher text size. - */ -static -int krb5_encrypt_bulk(struct crypto_blkcipher *tfm, - struct krb5_header *khdr, - char *confounder, - struct ptlrpc_bulk_desc *desc, - rawobj_t *cipher, - int adj_nob) -{ - struct blkcipher_desc ciph_desc; - __u8 local_iv[16] = {0}; - struct scatterlist src, dst; - int blocksize, i, rc, nob = 0; - - LASSERT(desc->bd_iov_count); - LASSERT(desc->bd_enc_iov); - - blocksize = crypto_blkcipher_blocksize(tfm); - LASSERT(blocksize > 1); - LASSERT(cipher->len == blocksize + sizeof(*khdr)); - - ciph_desc.tfm = tfm; - ciph_desc.info = local_iv; - ciph_desc.flags = 0; - - /* encrypt confounder */ - buf_to_sg(&src, confounder, blocksize); - buf_to_sg(&dst, cipher->data, blocksize); - - rc = crypto_blkcipher_encrypt_iv(&ciph_desc, &dst, &src, blocksize); - if (rc) { - CERROR("error to encrypt confounder: %d\n", rc); - return rc; - } - - /* encrypt clear pages */ - for (i = 0; i < desc->bd_iov_count; i++) { - sg_set_page(&src, desc->bd_iov[i].kiov_page, - (desc->bd_iov[i].kiov_len + blocksize - 1) & - (~(blocksize - 1)), - desc->bd_iov[i].kiov_offset); - if (adj_nob) - nob += src.length; - sg_set_page(&dst, desc->bd_enc_iov[i].kiov_page, src.length, - src.offset); - - desc->bd_enc_iov[i].kiov_offset = dst.offset; - desc->bd_enc_iov[i].kiov_len = dst.length; - - rc = crypto_blkcipher_encrypt_iv(&ciph_desc, &dst, &src, - src.length); - if (rc) { - CERROR("error to encrypt page: %d\n", rc); - return rc; - } - } - - /* encrypt krb5 header */ - buf_to_sg(&src, khdr, sizeof(*khdr)); - buf_to_sg(&dst, cipher->data + blocksize, sizeof(*khdr)); - - rc = crypto_blkcipher_encrypt_iv(&ciph_desc, - &dst, &src, sizeof(*khdr)); - if (rc) { - CERROR("error to encrypt krb5 header: %d\n", rc); - return rc; - } - - if (adj_nob) - desc->bd_nob = nob; - - return 0; -} - -/* - * desc->bd_nob_transferred is the size of cipher text received. - * desc->bd_nob is the target size of plain text supposed to be. - * - * if adj_nob != 0, we adjust each page's kiov_len to the actual - * plain text size. - * - for client read: we don't know data size for each page, so - * bd_iov[]->kiov_len is set to PAGE_SIZE, but actual data received might - * be smaller, so we need to adjust it according to bd_enc_iov[]->kiov_len. - * this means we DO NOT support the situation that server send an odd size - * data in a page which is not the last one. - * - for server write: we knows exactly data size for each page being expected, - * thus kiov_len is accurate already, so we should not adjust it at all. - * and bd_enc_iov[]->kiov_len should be round_up(bd_iov[]->kiov_len) which - * should have been done by prep_bulk(). - */ -static -int krb5_decrypt_bulk(struct crypto_blkcipher *tfm, - struct krb5_header *khdr, - struct ptlrpc_bulk_desc *desc, - rawobj_t *cipher, - rawobj_t *plain, - int adj_nob) -{ - struct blkcipher_desc ciph_desc; - __u8 local_iv[16] = {0}; - struct scatterlist src, dst; - int ct_nob = 0, pt_nob = 0; - int blocksize, i, rc; - - LASSERT(desc->bd_iov_count); - LASSERT(desc->bd_enc_iov); - LASSERT(desc->bd_nob_transferred); - - blocksize = crypto_blkcipher_blocksize(tfm); - LASSERT(blocksize > 1); - LASSERT(cipher->len == blocksize + sizeof(*khdr)); - - ciph_desc.tfm = tfm; - ciph_desc.info = local_iv; - ciph_desc.flags = 0; - - if (desc->bd_nob_transferred % blocksize) { - CERROR("odd transferred nob: %d\n", desc->bd_nob_transferred); - return -EPROTO; - } - - /* decrypt head (confounder) */ - buf_to_sg(&src, cipher->data, blocksize); - buf_to_sg(&dst, plain->data, blocksize); - - rc = crypto_blkcipher_decrypt_iv(&ciph_desc, &dst, &src, blocksize); - if (rc) { - CERROR("error to decrypt confounder: %d\n", rc); - return rc; - } - - for (i = 0; i < desc->bd_iov_count && ct_nob < desc->bd_nob_transferred; - i++) { - if (desc->bd_enc_iov[i].kiov_offset % blocksize != 0 || - desc->bd_enc_iov[i].kiov_len % blocksize != 0) { - CERROR("page %d: odd offset %u len %u, blocksize %d\n", - i, desc->bd_enc_iov[i].kiov_offset, - desc->bd_enc_iov[i].kiov_len, blocksize); - return -EFAULT; - } - - if (adj_nob) { - if (ct_nob + desc->bd_enc_iov[i].kiov_len > - desc->bd_nob_transferred) - desc->bd_enc_iov[i].kiov_len = - desc->bd_nob_transferred - ct_nob; - - desc->bd_iov[i].kiov_len = desc->bd_enc_iov[i].kiov_len; - if (pt_nob + desc->bd_enc_iov[i].kiov_len >desc->bd_nob) - desc->bd_iov[i].kiov_len = desc->bd_nob -pt_nob; - } else { - /* this should be guaranteed by LNET */ - LASSERT(ct_nob + desc->bd_enc_iov[i].kiov_len <= - desc->bd_nob_transferred); - LASSERT(desc->bd_iov[i].kiov_len <= - desc->bd_enc_iov[i].kiov_len); - } - - if (desc->bd_enc_iov[i].kiov_len == 0) - continue; - - sg_set_page(&src, desc->bd_enc_iov[i].kiov_page, - desc->bd_enc_iov[i].kiov_len, - desc->bd_enc_iov[i].kiov_offset); - dst = src; - if (desc->bd_iov[i].kiov_len % blocksize == 0) - sg_assign_page(&dst, desc->bd_iov[i].kiov_page); - - rc = crypto_blkcipher_decrypt_iv(&ciph_desc, &dst, &src, - src.length); - if (rc) { - CERROR("error to decrypt page: %d\n", rc); - return rc; - } - - if (desc->bd_iov[i].kiov_len % blocksize != 0) { - memcpy(page_address(desc->bd_iov[i].kiov_page) + - desc->bd_iov[i].kiov_offset, - page_address(desc->bd_enc_iov[i].kiov_page) + - desc->bd_iov[i].kiov_offset, - desc->bd_iov[i].kiov_len); - } - - ct_nob += desc->bd_enc_iov[i].kiov_len; - pt_nob += desc->bd_iov[i].kiov_len; - } - - if (unlikely(ct_nob != desc->bd_nob_transferred)) { - CERROR("%d cipher text transferred but only %d decrypted\n", - desc->bd_nob_transferred, ct_nob); - return -EFAULT; - } - - if (unlikely(!adj_nob && pt_nob != desc->bd_nob)) { - CERROR("%d plain text expected but only %d received\n", - desc->bd_nob, pt_nob); - return -EFAULT; - } - - /* if needed, clear up the rest unused iovs */ - if (adj_nob) - while (i < desc->bd_iov_count) - desc->bd_iov[i++].kiov_len = 0; - - /* decrypt tail (krb5 header) */ - buf_to_sg(&src, cipher->data + blocksize, sizeof(*khdr)); - buf_to_sg(&dst, cipher->data + blocksize, sizeof(*khdr)); - - rc = crypto_blkcipher_decrypt_iv(&ciph_desc, - &dst, &src, sizeof(*khdr)); - if (rc) { - CERROR("error to decrypt tail: %d\n", rc); - return rc; - } - - if (memcmp(cipher->data + blocksize, khdr, sizeof(*khdr))) { - CERROR("krb5 header doesn't match\n"); - return -EACCES; - } - - return 0; -} - -static -__u32 gss_wrap_kerberos(struct gss_ctx *gctx, - rawobj_t *gsshdr, - rawobj_t *msg, - int msg_buflen, - rawobj_t *token) -{ - struct krb5_ctx *kctx = gctx->internal_ctx_id; - struct krb5_enctype *ke = &enctypes[kctx->kc_enctype]; - struct krb5_header *khdr; - int blocksize; - rawobj_t cksum = RAWOBJ_EMPTY; - rawobj_t data_desc[3], cipher; - __u8 conf[GSS_MAX_CIPHER_BLOCK]; - int rc = 0; - - LASSERT(ke); - LASSERT(ke->ke_conf_size <= GSS_MAX_CIPHER_BLOCK); - LASSERT(kctx->kc_keye.kb_tfm == NULL || - ke->ke_conf_size >= - crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm)); - - /* - * final token format: - * --------------------------------------------------- - * | krb5 header | cipher text | checksum (16 bytes) | - * --------------------------------------------------- - */ - - /* fill krb5 header */ - LASSERT(token->len >= sizeof(*khdr)); - khdr = (struct krb5_header *) token->data; - fill_krb5_header(kctx, khdr, 1); - - /* generate confounder */ - cfs_get_random_bytes(conf, ke->ke_conf_size); - - /* get encryption blocksize. note kc_keye might not associated with - * a tfm, currently only for arcfour-hmac */ - if (kctx->kc_enctype == ENCTYPE_ARCFOUR_HMAC) { - LASSERT(kctx->kc_keye.kb_tfm == NULL); - blocksize = 1; - } else { - LASSERT(kctx->kc_keye.kb_tfm); - blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); - } - LASSERT(blocksize <= ke->ke_conf_size); - - /* padding the message */ - if (add_padding(msg, msg_buflen, blocksize)) - return GSS_S_FAILURE; - - /* - * clear text layout for checksum: - * ------------------------------------------------------ - * | confounder | gss header | clear msgs | krb5 header | - * ------------------------------------------------------ - */ - data_desc[0].data = conf; - data_desc[0].len = ke->ke_conf_size; - data_desc[1].data = gsshdr->data; - data_desc[1].len = gsshdr->len; - data_desc[2].data = msg->data; - data_desc[2].len = msg->len; - - /* compute checksum */ - if (krb5_make_checksum(kctx->kc_enctype, &kctx->kc_keyi, - khdr, 3, data_desc, 0, NULL, &cksum)) - return GSS_S_FAILURE; - LASSERT(cksum.len >= ke->ke_hash_size); - - /* - * clear text layout for encryption: - * ----------------------------------------- - * | confounder | clear msgs | krb5 header | - * ----------------------------------------- - */ - data_desc[0].data = conf; - data_desc[0].len = ke->ke_conf_size; - data_desc[1].data = msg->data; - data_desc[1].len = msg->len; - data_desc[2].data = (__u8 *) khdr; - data_desc[2].len = sizeof(*khdr); - - /* cipher text will be directly inplace */ - cipher.data = (__u8 *) (khdr + 1); - cipher.len = token->len - sizeof(*khdr); - LASSERT(cipher.len >= ke->ke_conf_size + msg->len + sizeof(*khdr)); - - if (kctx->kc_enctype == ENCTYPE_ARCFOUR_HMAC) { - rawobj_t arc4_keye; - struct crypto_blkcipher *arc4_tfm; - - if (krb5_make_checksum(ENCTYPE_ARCFOUR_HMAC, &kctx->kc_keyi, - NULL, 1, &cksum, 0, NULL, &arc4_keye)) { - CERROR("failed to obtain arc4 enc key\n"); - GOTO(arc4_out, rc = -EACCES); - } - - arc4_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, 0); - if (IS_ERR(arc4_tfm)) { - CERROR("failed to alloc tfm arc4 in ECB mode\n"); - GOTO(arc4_out_key, rc = -EACCES); - } - - if (crypto_blkcipher_setkey(arc4_tfm, arc4_keye.data, - arc4_keye.len)) { - CERROR("failed to set arc4 key, len %d\n", - arc4_keye.len); - GOTO(arc4_out_tfm, rc = -EACCES); - } - - rc = krb5_encrypt_rawobjs(arc4_tfm, 1, - 3, data_desc, &cipher, 1); -arc4_out_tfm: - crypto_free_blkcipher(arc4_tfm); -arc4_out_key: - rawobj_free(&arc4_keye); -arc4_out: - do {} while (0); /* just to avoid compile warning */ - } else { - rc = krb5_encrypt_rawobjs(kctx->kc_keye.kb_tfm, 0, - 3, data_desc, &cipher, 1); - } - - if (rc != 0) { - rawobj_free(&cksum); - return GSS_S_FAILURE; - } - - /* fill in checksum */ - LASSERT(token->len >= sizeof(*khdr) + cipher.len + ke->ke_hash_size); - memcpy((char *)(khdr + 1) + cipher.len, - cksum.data + cksum.len - ke->ke_hash_size, - ke->ke_hash_size); - rawobj_free(&cksum); - - /* final token length */ - token->len = sizeof(*khdr) + cipher.len + ke->ke_hash_size; - return GSS_S_COMPLETE; -} - -static -__u32 gss_prep_bulk_kerberos(struct gss_ctx *gctx, - struct ptlrpc_bulk_desc *desc) -{ - struct krb5_ctx *kctx = gctx->internal_ctx_id; - int blocksize, i; - - LASSERT(desc->bd_iov_count); - LASSERT(desc->bd_enc_iov); - LASSERT(kctx->kc_keye.kb_tfm); - - blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); - - for (i = 0; i < desc->bd_iov_count; i++) { - LASSERT(desc->bd_enc_iov[i].kiov_page); - /* - * offset should always start at page boundary of either - * client or server side. - */ - if (desc->bd_iov[i].kiov_offset & blocksize) { - CERROR("odd offset %d in page %d\n", - desc->bd_iov[i].kiov_offset, i); - return GSS_S_FAILURE; - } - - desc->bd_enc_iov[i].kiov_offset = desc->bd_iov[i].kiov_offset; - desc->bd_enc_iov[i].kiov_len = (desc->bd_iov[i].kiov_len + - blocksize - 1) & (~(blocksize - 1)); - } - - return GSS_S_COMPLETE; -} - -static -__u32 gss_wrap_bulk_kerberos(struct gss_ctx *gctx, - struct ptlrpc_bulk_desc *desc, - rawobj_t *token, int adj_nob) -{ - struct krb5_ctx *kctx = gctx->internal_ctx_id; - struct krb5_enctype *ke = &enctypes[kctx->kc_enctype]; - struct krb5_header *khdr; - int blocksize; - rawobj_t cksum = RAWOBJ_EMPTY; - rawobj_t data_desc[1], cipher; - __u8 conf[GSS_MAX_CIPHER_BLOCK]; - int rc = 0; - - LASSERT(ke); - LASSERT(ke->ke_conf_size <= GSS_MAX_CIPHER_BLOCK); - - /* - * final token format: - * -------------------------------------------------- - * | krb5 header | head/tail cipher text | checksum | - * -------------------------------------------------- - */ - - /* fill krb5 header */ - LASSERT(token->len >= sizeof(*khdr)); - khdr = (struct krb5_header *) token->data; - fill_krb5_header(kctx, khdr, 1); - - /* generate confounder */ - cfs_get_random_bytes(conf, ke->ke_conf_size); - - /* get encryption blocksize. note kc_keye might not associated with - * a tfm, currently only for arcfour-hmac */ - if (kctx->kc_enctype == ENCTYPE_ARCFOUR_HMAC) { - LASSERT(kctx->kc_keye.kb_tfm == NULL); - blocksize = 1; - } else { - LASSERT(kctx->kc_keye.kb_tfm); - blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); - } - - /* - * we assume the size of krb5_header (16 bytes) must be n * blocksize. - * the bulk token size would be exactly (sizeof(krb5_header) + - * blocksize + sizeof(krb5_header) + hashsize) - */ - LASSERT(blocksize <= ke->ke_conf_size); - LASSERT(sizeof(*khdr) >= blocksize && sizeof(*khdr) % blocksize == 0); - LASSERT(token->len >= sizeof(*khdr) + blocksize + sizeof(*khdr) + 16); - - /* - * clear text layout for checksum: - * ------------------------------------------ - * | confounder | clear pages | krb5 header | - * ------------------------------------------ - */ - data_desc[0].data = conf; - data_desc[0].len = ke->ke_conf_size; - - /* compute checksum */ - if (krb5_make_checksum(kctx->kc_enctype, &kctx->kc_keyi, - khdr, 1, data_desc, - desc->bd_iov_count, desc->bd_iov, - &cksum)) - return GSS_S_FAILURE; - LASSERT(cksum.len >= ke->ke_hash_size); - - /* - * clear text layout for encryption: - * ------------------------------------------ - * | confounder | clear pages | krb5 header | - * ------------------------------------------ - * | | | - * ---------- (cipher pages) | - * result token: | | - * ------------------------------------------- - * | krb5 header | cipher text | cipher text | - * ------------------------------------------- - */ - data_desc[0].data = conf; - data_desc[0].len = ke->ke_conf_size; - - cipher.data = (__u8 *) (khdr + 1); - cipher.len = blocksize + sizeof(*khdr); - - if (kctx->kc_enctype == ENCTYPE_ARCFOUR_HMAC) { - LBUG(); - rc = 0; - } else { - rc = krb5_encrypt_bulk(kctx->kc_keye.kb_tfm, khdr, - conf, desc, &cipher, adj_nob); - } - - if (rc != 0) { - rawobj_free(&cksum); - return GSS_S_FAILURE; - } - - /* fill in checksum */ - LASSERT(token->len >= sizeof(*khdr) + cipher.len + ke->ke_hash_size); - memcpy((char *)(khdr + 1) + cipher.len, - cksum.data + cksum.len - ke->ke_hash_size, - ke->ke_hash_size); - rawobj_free(&cksum); - - /* final token length */ - token->len = sizeof(*khdr) + cipher.len + ke->ke_hash_size; - return GSS_S_COMPLETE; -} - -static -__u32 gss_unwrap_kerberos(struct gss_ctx *gctx, - rawobj_t *gsshdr, - rawobj_t *token, - rawobj_t *msg) -{ - struct krb5_ctx *kctx = gctx->internal_ctx_id; - struct krb5_enctype *ke = &enctypes[kctx->kc_enctype]; - struct krb5_header *khdr; - unsigned char *tmpbuf; - int blocksize, bodysize; - rawobj_t cksum = RAWOBJ_EMPTY; - rawobj_t cipher_in, plain_out; - rawobj_t hash_objs[3]; - int rc = 0; - __u32 major; - - LASSERT(ke); - - if (token->len < sizeof(*khdr)) { - CERROR("short signature: %u\n", token->len); - return GSS_S_DEFECTIVE_TOKEN; - } - - khdr = (struct krb5_header *) token->data; - - major = verify_krb5_header(kctx, khdr, 1); - if (major != GSS_S_COMPLETE) { - CERROR("bad krb5 header\n"); - return major; - } - - /* block size */ - if (kctx->kc_enctype == ENCTYPE_ARCFOUR_HMAC) { - LASSERT(kctx->kc_keye.kb_tfm == NULL); - blocksize = 1; - } else { - LASSERT(kctx->kc_keye.kb_tfm); - blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); - } - - /* expected token layout: - * ---------------------------------------- - * | krb5 header | cipher text | checksum | - * ---------------------------------------- - */ - bodysize = token->len - sizeof(*khdr) - ke->ke_hash_size; - - if (bodysize % blocksize) { - CERROR("odd bodysize %d\n", bodysize); - return GSS_S_DEFECTIVE_TOKEN; - } - - if (bodysize <= ke->ke_conf_size + sizeof(*khdr)) { - CERROR("incomplete token: bodysize %d\n", bodysize); - return GSS_S_DEFECTIVE_TOKEN; - } - - if (msg->len < bodysize - ke->ke_conf_size - sizeof(*khdr)) { - CERROR("buffer too small: %u, require %d\n", - msg->len, bodysize - ke->ke_conf_size); - return GSS_S_FAILURE; - } - - /* decrypting */ - OBD_ALLOC_LARGE(tmpbuf, bodysize); - if (!tmpbuf) - return GSS_S_FAILURE; - - major = GSS_S_FAILURE; - - cipher_in.data = (__u8 *) (khdr + 1); - cipher_in.len = bodysize; - plain_out.data = tmpbuf; - plain_out.len = bodysize; - - if (kctx->kc_enctype == ENCTYPE_ARCFOUR_HMAC) { - rawobj_t arc4_keye; - struct crypto_blkcipher *arc4_tfm; - - cksum.data = token->data + token->len - ke->ke_hash_size; - cksum.len = ke->ke_hash_size; - - if (krb5_make_checksum(ENCTYPE_ARCFOUR_HMAC, &kctx->kc_keyi, - NULL, 1, &cksum, 0, NULL, &arc4_keye)) { - CERROR("failed to obtain arc4 enc key\n"); - GOTO(arc4_out, rc = -EACCES); - } - - arc4_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, 0); - if (IS_ERR(arc4_tfm)) { - CERROR("failed to alloc tfm arc4 in ECB mode\n"); - GOTO(arc4_out_key, rc = -EACCES); - } - - if (crypto_blkcipher_setkey(arc4_tfm, - arc4_keye.data, arc4_keye.len)) { - CERROR("failed to set arc4 key, len %d\n", - arc4_keye.len); - GOTO(arc4_out_tfm, rc = -EACCES); - } - - rc = krb5_encrypt_rawobjs(arc4_tfm, 1, - 1, &cipher_in, &plain_out, 0); -arc4_out_tfm: - crypto_free_blkcipher(arc4_tfm); -arc4_out_key: - rawobj_free(&arc4_keye); -arc4_out: - cksum = RAWOBJ_EMPTY; - } else { - rc = krb5_encrypt_rawobjs(kctx->kc_keye.kb_tfm, 0, - 1, &cipher_in, &plain_out, 0); - } - - if (rc != 0) { - CERROR("error decrypt\n"); - goto out_free; - } - LASSERT(plain_out.len == bodysize); - - /* expected clear text layout: - * ----------------------------------------- - * | confounder | clear msgs | krb5 header | - * ----------------------------------------- - */ - - /* verify krb5 header in token is not modified */ - if (memcmp(khdr, plain_out.data + plain_out.len - sizeof(*khdr), - sizeof(*khdr))) { - CERROR("decrypted krb5 header mismatch\n"); - goto out_free; - } - - /* verify checksum, compose clear text as layout: - * ------------------------------------------------------ - * | confounder | gss header | clear msgs | krb5 header | - * ------------------------------------------------------ - */ - hash_objs[0].len = ke->ke_conf_size; - hash_objs[0].data = plain_out.data; - hash_objs[1].len = gsshdr->len; - hash_objs[1].data = gsshdr->data; - hash_objs[2].len = plain_out.len - ke->ke_conf_size - sizeof(*khdr); - hash_objs[2].data = plain_out.data + ke->ke_conf_size; - if (krb5_make_checksum(kctx->kc_enctype, &kctx->kc_keyi, - khdr, 3, hash_objs, 0, NULL, &cksum)) - goto out_free; - - LASSERT(cksum.len >= ke->ke_hash_size); - if (memcmp((char *)(khdr + 1) + bodysize, - cksum.data + cksum.len - ke->ke_hash_size, - ke->ke_hash_size)) { - CERROR("checksum mismatch\n"); - goto out_free; - } - - msg->len = bodysize - ke->ke_conf_size - sizeof(*khdr); - memcpy(msg->data, tmpbuf + ke->ke_conf_size, msg->len); - - major = GSS_S_COMPLETE; -out_free: - OBD_FREE_LARGE(tmpbuf, bodysize); - rawobj_free(&cksum); - return major; -} - -static -__u32 gss_unwrap_bulk_kerberos(struct gss_ctx *gctx, - struct ptlrpc_bulk_desc *desc, - rawobj_t *token, int adj_nob) -{ - struct krb5_ctx *kctx = gctx->internal_ctx_id; - struct krb5_enctype *ke = &enctypes[kctx->kc_enctype]; - struct krb5_header *khdr; - int blocksize; - rawobj_t cksum = RAWOBJ_EMPTY; - rawobj_t cipher, plain; - rawobj_t data_desc[1]; - int rc; - __u32 major; - - LASSERT(ke); - - if (token->len < sizeof(*khdr)) { - CERROR("short signature: %u\n", token->len); - return GSS_S_DEFECTIVE_TOKEN; - } - - khdr = (struct krb5_header *) token->data; - - major = verify_krb5_header(kctx, khdr, 1); - if (major != GSS_S_COMPLETE) { - CERROR("bad krb5 header\n"); - return major; - } - - /* block size */ - if (kctx->kc_enctype == ENCTYPE_ARCFOUR_HMAC) { - LASSERT(kctx->kc_keye.kb_tfm == NULL); - blocksize = 1; - LBUG(); - } else { - LASSERT(kctx->kc_keye.kb_tfm); - blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); - } - LASSERT(sizeof(*khdr) >= blocksize && sizeof(*khdr) % blocksize == 0); - - /* - * token format is expected as: - * ----------------------------------------------- - * | krb5 header | head/tail cipher text | cksum | - * ----------------------------------------------- - */ - if (token->len < sizeof(*khdr) + blocksize + sizeof(*khdr) + - ke->ke_hash_size) { - CERROR("short token size: %u\n", token->len); - return GSS_S_DEFECTIVE_TOKEN; - } - - cipher.data = (__u8 *) (khdr + 1); - cipher.len = blocksize + sizeof(*khdr); - plain.data = cipher.data; - plain.len = cipher.len; - - rc = krb5_decrypt_bulk(kctx->kc_keye.kb_tfm, khdr, - desc, &cipher, &plain, adj_nob); - if (rc) - return GSS_S_DEFECTIVE_TOKEN; - - /* - * verify checksum, compose clear text as layout: - * ------------------------------------------ - * | confounder | clear pages | krb5 header | - * ------------------------------------------ - */ - data_desc[0].data = plain.data; - data_desc[0].len = blocksize; - - if (krb5_make_checksum(kctx->kc_enctype, &kctx->kc_keyi, - khdr, 1, data_desc, - desc->bd_iov_count, desc->bd_iov, - &cksum)) - return GSS_S_FAILURE; - LASSERT(cksum.len >= ke->ke_hash_size); - - if (memcmp(plain.data + blocksize + sizeof(*khdr), - cksum.data + cksum.len - ke->ke_hash_size, - ke->ke_hash_size)) { - CERROR("checksum mismatch\n"); - rawobj_free(&cksum); - return GSS_S_BAD_SIG; - } - - rawobj_free(&cksum); - return GSS_S_COMPLETE; -} - -int gss_display_kerberos(struct gss_ctx *ctx, - char *buf, - int bufsize) -{ - struct krb5_ctx *kctx = ctx->internal_ctx_id; - int written; - - written = snprintf(buf, bufsize, "krb5 (%s)", - enctype2str(kctx->kc_enctype)); - return written; -} - -static struct gss_api_ops gss_kerberos_ops = { - .gss_import_sec_context = gss_import_sec_context_kerberos, - .gss_copy_reverse_context = gss_copy_reverse_context_kerberos, - .gss_inquire_context = gss_inquire_context_kerberos, - .gss_get_mic = gss_get_mic_kerberos, - .gss_verify_mic = gss_verify_mic_kerberos, - .gss_wrap = gss_wrap_kerberos, - .gss_unwrap = gss_unwrap_kerberos, - .gss_prep_bulk = gss_prep_bulk_kerberos, - .gss_wrap_bulk = gss_wrap_bulk_kerberos, - .gss_unwrap_bulk = gss_unwrap_bulk_kerberos, - .gss_delete_sec_context = gss_delete_sec_context_kerberos, - .gss_display = gss_display_kerberos, -}; - -static struct subflavor_desc gss_kerberos_sfs[] = { - { - .sf_subflavor = SPTLRPC_SUBFLVR_KRB5N, - .sf_qop = 0, - .sf_service = SPTLRPC_SVC_NULL, - .sf_name = "krb5n" - }, - { - .sf_subflavor = SPTLRPC_SUBFLVR_KRB5A, - .sf_qop = 0, - .sf_service = SPTLRPC_SVC_AUTH, - .sf_name = "krb5a" - }, - { - .sf_subflavor = SPTLRPC_SUBFLVR_KRB5I, - .sf_qop = 0, - .sf_service = SPTLRPC_SVC_INTG, - .sf_name = "krb5i" - }, - { - .sf_subflavor = SPTLRPC_SUBFLVR_KRB5P, - .sf_qop = 0, - .sf_service = SPTLRPC_SVC_PRIV, - .sf_name = "krb5p" - }, -}; - -/* - * currently we leave module owner NULL - */ -static struct gss_api_mech gss_kerberos_mech = { - .gm_owner = NULL, /*THIS_MODULE, */ - .gm_name = "krb5", - .gm_oid = (rawobj_t) - {9, "\052\206\110\206\367\022\001\002\002"}, - .gm_ops = &gss_kerberos_ops, - .gm_sf_num = 4, - .gm_sfs = gss_kerberos_sfs, -}; - -int __init init_kerberos_module(void) -{ - int status; - - spin_lock_init(&krb5_seq_lock); - - status = lgss_mech_register(&gss_kerberos_mech); - if (status) - CERROR("Failed to register kerberos gss mechanism!\n"); - return status; -} - -void __exit cleanup_kerberos_module(void) -{ - lgss_mech_unregister(&gss_kerberos_mech); -} diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_mech_switch.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_mech_switch.c deleted file mode 100644 index 99462e085da7..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_mech_switch.c +++ /dev/null @@ -1,358 +0,0 @@ -/* - * Modifications for Lustre - * - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * - * Copyright (c) 2012, Intel Corporation. - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -/* - * linux/net/sunrpc/gss_mech_switch.c - * - * Copyright (c) 2001 The Regents of the University of Michigan. - * All rights reserved. - * - * J. Bruce Fields <bfields@umich.edu> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define DEBUG_SUBSYSTEM S_SEC -#include <linux/module.h> -#include <linux/slab.h> -#include <linux/mutex.h> - -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre/lustre_idl.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_sec.h> - -#include "gss_err.h" -#include "gss_internal.h" -#include "gss_api.h" - -static LIST_HEAD(registered_mechs); -static DEFINE_SPINLOCK(registered_mechs_lock); - -int lgss_mech_register(struct gss_api_mech *gm) -{ - spin_lock(®istered_mechs_lock); - list_add(&gm->gm_list, ®istered_mechs); - spin_unlock(®istered_mechs_lock); - CWARN("Register %s mechanism\n", gm->gm_name); - return 0; -} - -void lgss_mech_unregister(struct gss_api_mech *gm) -{ - spin_lock(®istered_mechs_lock); - list_del(&gm->gm_list); - spin_unlock(®istered_mechs_lock); - CWARN("Unregister %s mechanism\n", gm->gm_name); -} - - -struct gss_api_mech *lgss_mech_get(struct gss_api_mech *gm) -{ - __module_get(gm->gm_owner); - return gm; -} - -struct gss_api_mech *lgss_name_to_mech(char *name) -{ - struct gss_api_mech *pos, *gm = NULL; - - spin_lock(®istered_mechs_lock); - list_for_each_entry(pos, ®istered_mechs, gm_list) { - if (0 == strcmp(name, pos->gm_name)) { - if (!try_module_get(pos->gm_owner)) - continue; - gm = pos; - break; - } - } - spin_unlock(®istered_mechs_lock); - return gm; - -} - -static inline -int mech_supports_subflavor(struct gss_api_mech *gm, __u32 subflavor) -{ - int i; - - for (i = 0; i < gm->gm_sf_num; i++) { - if (gm->gm_sfs[i].sf_subflavor == subflavor) - return 1; - } - return 0; -} - -struct gss_api_mech *lgss_subflavor_to_mech(__u32 subflavor) -{ - struct gss_api_mech *pos, *gm = NULL; - - spin_lock(®istered_mechs_lock); - list_for_each_entry(pos, ®istered_mechs, gm_list) { - if (!try_module_get(pos->gm_owner)) - continue; - if (!mech_supports_subflavor(pos, subflavor)) { - module_put(pos->gm_owner); - continue; - } - gm = pos; - break; - } - spin_unlock(®istered_mechs_lock); - return gm; -} - -void lgss_mech_put(struct gss_api_mech *gm) -{ - module_put(gm->gm_owner); -} - -/* The mech could probably be determined from the token instead, but it's just - * as easy for now to pass it in. */ -__u32 lgss_import_sec_context(rawobj_t *input_token, - struct gss_api_mech *mech, - struct gss_ctx **ctx_id) -{ - OBD_ALLOC_PTR(*ctx_id); - if (*ctx_id == NULL) - return GSS_S_FAILURE; - - (*ctx_id)->mech_type = lgss_mech_get(mech); - - LASSERT(mech); - LASSERT(mech->gm_ops); - LASSERT(mech->gm_ops->gss_import_sec_context); - return mech->gm_ops->gss_import_sec_context(input_token, *ctx_id); -} - -__u32 lgss_copy_reverse_context(struct gss_ctx *ctx_id, - struct gss_ctx **ctx_id_new) -{ - struct gss_api_mech *mech = ctx_id->mech_type; - __u32 major; - - LASSERT(mech); - - OBD_ALLOC_PTR(*ctx_id_new); - if (*ctx_id_new == NULL) - return GSS_S_FAILURE; - - (*ctx_id_new)->mech_type = lgss_mech_get(mech); - - LASSERT(mech); - LASSERT(mech->gm_ops); - LASSERT(mech->gm_ops->gss_copy_reverse_context); - - major = mech->gm_ops->gss_copy_reverse_context(ctx_id, *ctx_id_new); - if (major != GSS_S_COMPLETE) { - lgss_mech_put(mech); - OBD_FREE_PTR(*ctx_id_new); - *ctx_id_new = NULL; - } - return major; -} - -/* - * this interface is much simplified, currently we only need endtime. - */ -__u32 lgss_inquire_context(struct gss_ctx *context_handle, - unsigned long *endtime) -{ - LASSERT(context_handle); - LASSERT(context_handle->mech_type); - LASSERT(context_handle->mech_type->gm_ops); - LASSERT(context_handle->mech_type->gm_ops->gss_inquire_context); - - return context_handle->mech_type->gm_ops - ->gss_inquire_context(context_handle, - endtime); -} - -/* gss_get_mic: compute a mic over message and return mic_token. */ -__u32 lgss_get_mic(struct gss_ctx *context_handle, - int msgcnt, - rawobj_t *msg, - int iovcnt, - lnet_kiov_t *iovs, - rawobj_t *mic_token) -{ - LASSERT(context_handle); - LASSERT(context_handle->mech_type); - LASSERT(context_handle->mech_type->gm_ops); - LASSERT(context_handle->mech_type->gm_ops->gss_get_mic); - - return context_handle->mech_type->gm_ops - ->gss_get_mic(context_handle, - msgcnt, - msg, - iovcnt, - iovs, - mic_token); -} - -/* gss_verify_mic: check whether the provided mic_token verifies message. */ -__u32 lgss_verify_mic(struct gss_ctx *context_handle, - int msgcnt, - rawobj_t *msg, - int iovcnt, - lnet_kiov_t *iovs, - rawobj_t *mic_token) -{ - LASSERT(context_handle); - LASSERT(context_handle->mech_type); - LASSERT(context_handle->mech_type->gm_ops); - LASSERT(context_handle->mech_type->gm_ops->gss_verify_mic); - - return context_handle->mech_type->gm_ops - ->gss_verify_mic(context_handle, - msgcnt, - msg, - iovcnt, - iovs, - mic_token); -} - -__u32 lgss_wrap(struct gss_ctx *context_handle, - rawobj_t *gsshdr, - rawobj_t *msg, - int msg_buflen, - rawobj_t *out_token) -{ - LASSERT(context_handle); - LASSERT(context_handle->mech_type); - LASSERT(context_handle->mech_type->gm_ops); - LASSERT(context_handle->mech_type->gm_ops->gss_wrap); - - return context_handle->mech_type->gm_ops - ->gss_wrap(context_handle, gsshdr, msg, msg_buflen, out_token); -} - -__u32 lgss_unwrap(struct gss_ctx *context_handle, - rawobj_t *gsshdr, - rawobj_t *token, - rawobj_t *out_msg) -{ - LASSERT(context_handle); - LASSERT(context_handle->mech_type); - LASSERT(context_handle->mech_type->gm_ops); - LASSERT(context_handle->mech_type->gm_ops->gss_unwrap); - - return context_handle->mech_type->gm_ops - ->gss_unwrap(context_handle, gsshdr, token, out_msg); -} - - -__u32 lgss_prep_bulk(struct gss_ctx *context_handle, - struct ptlrpc_bulk_desc *desc) -{ - LASSERT(context_handle); - LASSERT(context_handle->mech_type); - LASSERT(context_handle->mech_type->gm_ops); - LASSERT(context_handle->mech_type->gm_ops->gss_prep_bulk); - - return context_handle->mech_type->gm_ops - ->gss_prep_bulk(context_handle, desc); -} - -__u32 lgss_wrap_bulk(struct gss_ctx *context_handle, - struct ptlrpc_bulk_desc *desc, - rawobj_t *token, - int adj_nob) -{ - LASSERT(context_handle); - LASSERT(context_handle->mech_type); - LASSERT(context_handle->mech_type->gm_ops); - LASSERT(context_handle->mech_type->gm_ops->gss_wrap_bulk); - - return context_handle->mech_type->gm_ops - ->gss_wrap_bulk(context_handle, desc, token, adj_nob); -} - -__u32 lgss_unwrap_bulk(struct gss_ctx *context_handle, - struct ptlrpc_bulk_desc *desc, - rawobj_t *token, - int adj_nob) -{ - LASSERT(context_handle); - LASSERT(context_handle->mech_type); - LASSERT(context_handle->mech_type->gm_ops); - LASSERT(context_handle->mech_type->gm_ops->gss_unwrap_bulk); - - return context_handle->mech_type->gm_ops - ->gss_unwrap_bulk(context_handle, desc, token, adj_nob); -} - -/* gss_delete_sec_context: free all resources associated with context_handle. - * Note this differs from the RFC 2744-specified prototype in that we don't - * bother returning an output token, since it would never be used anyway. */ - -__u32 lgss_delete_sec_context(struct gss_ctx **context_handle) -{ - struct gss_api_mech *mech; - - CDEBUG(D_SEC, "deleting %p\n", *context_handle); - - if (!*context_handle) - return(GSS_S_NO_CONTEXT); - - mech = (*context_handle)->mech_type; - if ((*context_handle)->internal_ctx_id != 0) { - LASSERT(mech); - LASSERT(mech->gm_ops); - LASSERT(mech->gm_ops->gss_delete_sec_context); - mech->gm_ops->gss_delete_sec_context( - (*context_handle)->internal_ctx_id); - } - if (mech) - lgss_mech_put(mech); - - OBD_FREE_PTR(*context_handle); - *context_handle=NULL; - return GSS_S_COMPLETE; -} - -int lgss_display(struct gss_ctx *ctx, - char *buf, - int bufsize) -{ - LASSERT(ctx); - LASSERT(ctx->mech_type); - LASSERT(ctx->mech_type->gm_ops); - LASSERT(ctx->mech_type->gm_ops->gss_display); - - return ctx->mech_type->gm_ops->gss_display(ctx, buf, bufsize); -} diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c deleted file mode 100644 index 3be5bc14c4ed..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c +++ /dev/null @@ -1,1233 +0,0 @@ -/* - * Modifications for Lustre - * - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * - * Copyright (c) 2012, Intel Corporation. - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -/* - * linux/net/sunrpc/auth_gss.c - * - * RPCSEC_GSS client authentication. - * - * Copyright (c) 2000 The Regents of the University of Michigan. - * All rights reserved. - * - * Dug Song <dugsong@monkey.org> - * Andy Adamson <andros@umich.edu> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define DEBUG_SUBSYSTEM S_SEC -#include <linux/init.h> -#include <linux/module.h> -#include <linux/slab.h> -#include <linux/dcache.h> -#include <linux/fs.h> -#include <linux/mutex.h> -#include <linux/crypto.h> -#include <asm/atomic.h> -struct rpc_clnt; /* for rpc_pipefs */ -#include <linux/sunrpc/rpc_pipe_fs.h> - -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre/lustre_idl.h> -#include <lustre_sec.h> -#include <lustre_net.h> -#include <lustre_import.h> - -#include "gss_err.h" -#include "gss_internal.h" -#include "gss_api.h" - -static struct ptlrpc_sec_policy gss_policy_pipefs; -static struct ptlrpc_ctx_ops gss_pipefs_ctxops; - -static int gss_cli_ctx_refresh_pf(struct ptlrpc_cli_ctx *ctx); - -static int gss_sec_pipe_upcall_init(struct gss_sec *gsec) -{ - return 0; -} - -static void gss_sec_pipe_upcall_fini(struct gss_sec *gsec) -{ -} - -/**************************************** - * internal context helpers * - ****************************************/ - -static -struct ptlrpc_cli_ctx *ctx_create_pf(struct ptlrpc_sec *sec, - struct vfs_cred *vcred) -{ - struct gss_cli_ctx *gctx; - int rc; - - OBD_ALLOC_PTR(gctx); - if (gctx == NULL) - return NULL; - - rc = gss_cli_ctx_init_common(sec, &gctx->gc_base, - &gss_pipefs_ctxops, vcred); - if (rc) { - OBD_FREE_PTR(gctx); - return NULL; - } - - return &gctx->gc_base; -} - -static -void ctx_destroy_pf(struct ptlrpc_sec *sec, struct ptlrpc_cli_ctx *ctx) -{ - struct gss_cli_ctx *gctx = ctx2gctx(ctx); - - if (gss_cli_ctx_fini_common(sec, ctx)) - return; - - OBD_FREE_PTR(gctx); - - atomic_dec(&sec->ps_nctx); - sptlrpc_sec_put(sec); -} - -static -void ctx_enhash_pf(struct ptlrpc_cli_ctx *ctx, struct hlist_head *hash) -{ - set_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags); - atomic_inc(&ctx->cc_refcount); - hlist_add_head(&ctx->cc_cache, hash); -} - -/* - * caller must hold spinlock - */ -static -void ctx_unhash_pf(struct ptlrpc_cli_ctx *ctx, struct hlist_head *freelist) -{ - assert_spin_locked(&ctx->cc_sec->ps_lock); - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - LASSERT(test_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags)); - LASSERT(!hlist_unhashed(&ctx->cc_cache)); - - clear_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags); - - if (atomic_dec_and_test(&ctx->cc_refcount)) { - __hlist_del(&ctx->cc_cache); - hlist_add_head(&ctx->cc_cache, freelist); - } else { - hlist_del_init(&ctx->cc_cache); - } -} - -/* - * return 1 if the context is dead. - */ -static -int ctx_check_death_pf(struct ptlrpc_cli_ctx *ctx, - struct hlist_head *freelist) -{ - if (cli_ctx_check_death(ctx)) { - if (freelist) - ctx_unhash_pf(ctx, freelist); - return 1; - } - - return 0; -} - -static inline -int ctx_check_death_locked_pf(struct ptlrpc_cli_ctx *ctx, - struct hlist_head *freelist) -{ - LASSERT(ctx->cc_sec); - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - LASSERT(test_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags)); - - return ctx_check_death_pf(ctx, freelist); -} - -static inline -int ctx_match_pf(struct ptlrpc_cli_ctx *ctx, struct vfs_cred *vcred) -{ - /* a little bit optimization for null policy */ - if (!ctx->cc_ops->match) - return 1; - - return ctx->cc_ops->match(ctx, vcred); -} - -static -void ctx_list_destroy_pf(struct hlist_head *head) -{ - struct ptlrpc_cli_ctx *ctx; - - while (!hlist_empty(head)) { - ctx = hlist_entry(head->first, struct ptlrpc_cli_ctx, - cc_cache); - - LASSERT(atomic_read(&ctx->cc_refcount) == 0); - LASSERT(test_bit(PTLRPC_CTX_CACHED_BIT, - &ctx->cc_flags) == 0); - - hlist_del_init(&ctx->cc_cache); - ctx_destroy_pf(ctx->cc_sec, ctx); - } -} - -/**************************************** - * context apis * - ****************************************/ - -static -int gss_cli_ctx_validate_pf(struct ptlrpc_cli_ctx *ctx) -{ - if (ctx_check_death_pf(ctx, NULL)) - return 1; - if (cli_ctx_is_ready(ctx)) - return 0; - return 1; -} - -static -void gss_cli_ctx_die_pf(struct ptlrpc_cli_ctx *ctx, int grace) -{ - LASSERT(ctx->cc_sec); - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - - cli_ctx_expire(ctx); - - spin_lock(&ctx->cc_sec->ps_lock); - - if (test_and_clear_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags)) { - LASSERT(!hlist_unhashed(&ctx->cc_cache)); - LASSERT(atomic_read(&ctx->cc_refcount) > 1); - - hlist_del_init(&ctx->cc_cache); - if (atomic_dec_and_test(&ctx->cc_refcount)) - LBUG(); - } - - spin_unlock(&ctx->cc_sec->ps_lock); -} - -/**************************************** - * reverse context installation * - ****************************************/ - -static inline -unsigned int ctx_hash_index(int hashsize, __u64 key) -{ - return (unsigned int) (key & ((__u64) hashsize - 1)); -} - -static -void gss_sec_ctx_replace_pf(struct gss_sec *gsec, - struct ptlrpc_cli_ctx *new) -{ - struct gss_sec_pipefs *gsec_pf; - struct ptlrpc_cli_ctx *ctx; - struct hlist_node *next; - HLIST_HEAD(freelist); - unsigned int hash; - - gsec_pf = container_of(gsec, struct gss_sec_pipefs, gsp_base); - - hash = ctx_hash_index(gsec_pf->gsp_chash_size, - (__u64) new->cc_vcred.vc_uid); - LASSERT(hash < gsec_pf->gsp_chash_size); - - spin_lock(&gsec->gs_base.ps_lock); - - hlist_for_each_entry_safe(ctx, next, - &gsec_pf->gsp_chash[hash], cc_cache) { - if (!ctx_match_pf(ctx, &new->cc_vcred)) - continue; - - cli_ctx_expire(ctx); - ctx_unhash_pf(ctx, &freelist); - break; - } - - ctx_enhash_pf(new, &gsec_pf->gsp_chash[hash]); - - spin_unlock(&gsec->gs_base.ps_lock); - - ctx_list_destroy_pf(&freelist); -} - -static -int gss_install_rvs_cli_ctx_pf(struct gss_sec *gsec, - struct ptlrpc_svc_ctx *svc_ctx) -{ - struct vfs_cred vcred; - struct ptlrpc_cli_ctx *cli_ctx; - int rc; - - vcred.vc_uid = 0; - vcred.vc_gid = 0; - - cli_ctx = ctx_create_pf(&gsec->gs_base, &vcred); - if (!cli_ctx) - return -ENOMEM; - - rc = gss_copy_rvc_cli_ctx(cli_ctx, svc_ctx); - if (rc) { - ctx_destroy_pf(cli_ctx->cc_sec, cli_ctx); - return rc; - } - - gss_sec_ctx_replace_pf(gsec, cli_ctx); - return 0; -} - -static -void gss_ctx_cache_gc_pf(struct gss_sec_pipefs *gsec_pf, - struct hlist_head *freelist) -{ - struct ptlrpc_sec *sec; - struct ptlrpc_cli_ctx *ctx; - struct hlist_node *next; - int i; - - sec = &gsec_pf->gsp_base.gs_base; - - CDEBUG(D_SEC, "do gc on sec %s@%p\n", sec->ps_policy->sp_name, sec); - - for (i = 0; i < gsec_pf->gsp_chash_size; i++) { - hlist_for_each_entry_safe(ctx, next, - &gsec_pf->gsp_chash[i], cc_cache) - ctx_check_death_locked_pf(ctx, freelist); - } - - sec->ps_gc_next = cfs_time_current_sec() + sec->ps_gc_interval; -} - -static -struct ptlrpc_sec* gss_sec_create_pf(struct obd_import *imp, - struct ptlrpc_svc_ctx *ctx, - struct sptlrpc_flavor *sf) -{ - struct gss_sec_pipefs *gsec_pf; - int alloc_size, hash_size, i; - -#define GSS_SEC_PIPEFS_CTX_HASH_SIZE (32) - - if (ctx || - sf->sf_flags & (PTLRPC_SEC_FL_ROOTONLY | PTLRPC_SEC_FL_REVERSE)) - hash_size = 1; - else - hash_size = GSS_SEC_PIPEFS_CTX_HASH_SIZE; - - alloc_size = sizeof(*gsec_pf) + - sizeof(struct hlist_head) * hash_size; - - OBD_ALLOC(gsec_pf, alloc_size); - if (!gsec_pf) - return NULL; - - gsec_pf->gsp_chash_size = hash_size; - for (i = 0; i < hash_size; i++) - INIT_HLIST_HEAD(&gsec_pf->gsp_chash[i]); - - if (gss_sec_create_common(&gsec_pf->gsp_base, &gss_policy_pipefs, - imp, ctx, sf)) - goto err_free; - - if (ctx == NULL) { - if (gss_sec_pipe_upcall_init(&gsec_pf->gsp_base)) - goto err_destroy; - } else { - if (gss_install_rvs_cli_ctx_pf(&gsec_pf->gsp_base, ctx)) - goto err_destroy; - } - - return &gsec_pf->gsp_base.gs_base; - -err_destroy: - gss_sec_destroy_common(&gsec_pf->gsp_base); -err_free: - OBD_FREE(gsec_pf, alloc_size); - return NULL; -} - -static -void gss_sec_destroy_pf(struct ptlrpc_sec *sec) -{ - struct gss_sec_pipefs *gsec_pf; - struct gss_sec *gsec; - - CWARN("destroy %s@%p\n", sec->ps_policy->sp_name, sec); - - gsec = container_of(sec, struct gss_sec, gs_base); - gsec_pf = container_of(gsec, struct gss_sec_pipefs, gsp_base); - - LASSERT(gsec_pf->gsp_chash); - LASSERT(gsec_pf->gsp_chash_size); - - gss_sec_pipe_upcall_fini(gsec); - - gss_sec_destroy_common(gsec); - - OBD_FREE(gsec, sizeof(*gsec_pf) + - sizeof(struct hlist_head) * gsec_pf->gsp_chash_size); -} - -static -struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_pf(struct ptlrpc_sec *sec, - struct vfs_cred *vcred, - int create, int remove_dead) -{ - struct gss_sec *gsec; - struct gss_sec_pipefs *gsec_pf; - struct ptlrpc_cli_ctx *ctx = NULL, *new = NULL; - struct hlist_head *hash_head; - struct hlist_node *next; - HLIST_HEAD(freelist); - unsigned int hash, gc = 0, found = 0; - - might_sleep(); - - gsec = container_of(sec, struct gss_sec, gs_base); - gsec_pf = container_of(gsec, struct gss_sec_pipefs, gsp_base); - - hash = ctx_hash_index(gsec_pf->gsp_chash_size, - (__u64) vcred->vc_uid); - hash_head = &gsec_pf->gsp_chash[hash]; - LASSERT(hash < gsec_pf->gsp_chash_size); - -retry: - spin_lock(&sec->ps_lock); - - /* gc_next == 0 means never do gc */ - if (remove_dead && sec->ps_gc_next && - cfs_time_after(cfs_time_current_sec(), sec->ps_gc_next)) { - gss_ctx_cache_gc_pf(gsec_pf, &freelist); - gc = 1; - } - - hlist_for_each_entry_safe(ctx, next, hash_head, cc_cache) { - if (gc == 0 && - ctx_check_death_locked_pf(ctx, - remove_dead ? &freelist : NULL)) - continue; - - if (ctx_match_pf(ctx, vcred)) { - found = 1; - break; - } - } - - if (found) { - if (new && new != ctx) { - /* lost the race, just free it */ - hlist_add_head(&new->cc_cache, &freelist); - new = NULL; - } - - /* hot node, move to head */ - if (hash_head->first != &ctx->cc_cache) { - __hlist_del(&ctx->cc_cache); - hlist_add_head(&ctx->cc_cache, hash_head); - } - } else { - /* don't allocate for reverse sec */ - if (sec_is_reverse(sec)) { - spin_unlock(&sec->ps_lock); - return NULL; - } - - if (new) { - ctx_enhash_pf(new, hash_head); - ctx = new; - } else if (create) { - spin_unlock(&sec->ps_lock); - new = ctx_create_pf(sec, vcred); - if (new) { - clear_bit(PTLRPC_CTX_NEW_BIT, &new->cc_flags); - goto retry; - } - } else { - ctx = NULL; - } - } - - /* hold a ref */ - if (ctx) - atomic_inc(&ctx->cc_refcount); - - spin_unlock(&sec->ps_lock); - - /* the allocator of the context must give the first push to refresh */ - if (new) { - LASSERT(new == ctx); - gss_cli_ctx_refresh_pf(new); - } - - ctx_list_destroy_pf(&freelist); - return ctx; -} - -static -void gss_sec_release_ctx_pf(struct ptlrpc_sec *sec, - struct ptlrpc_cli_ctx *ctx, - int sync) -{ - LASSERT(test_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags) == 0); - LASSERT(hlist_unhashed(&ctx->cc_cache)); - - /* if required async, we must clear the UPTODATE bit to prevent extra - * rpcs during destroy procedure. */ - if (!sync) - clear_bit(PTLRPC_CTX_UPTODATE_BIT, &ctx->cc_flags); - - /* destroy this context */ - ctx_destroy_pf(sec, ctx); -} - -/* - * @uid: which user. "-1" means flush all. - * @grace: mark context DEAD, allow graceful destroy like notify - * server side, etc. - * @force: also flush busy entries. - * - * return the number of busy context encountered. - * - * In any cases, never touch "eternal" contexts. - */ -static -int gss_sec_flush_ctx_cache_pf(struct ptlrpc_sec *sec, - uid_t uid, - int grace, int force) -{ - struct gss_sec *gsec; - struct gss_sec_pipefs *gsec_pf; - struct ptlrpc_cli_ctx *ctx; - struct hlist_node *next; - HLIST_HEAD(freelist); - int i, busy = 0; - - might_sleep_if(grace); - - gsec = container_of(sec, struct gss_sec, gs_base); - gsec_pf = container_of(gsec, struct gss_sec_pipefs, gsp_base); - - spin_lock(&sec->ps_lock); - for (i = 0; i < gsec_pf->gsp_chash_size; i++) { - hlist_for_each_entry_safe(ctx, next, - &gsec_pf->gsp_chash[i], - cc_cache) { - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - - if (uid != -1 && uid != ctx->cc_vcred.vc_uid) - continue; - - if (atomic_read(&ctx->cc_refcount) > 1) { - busy++; - if (!force) - continue; - - CWARN("flush busy(%d) ctx %p(%u->%s) by force, " - "grace %d\n", - atomic_read(&ctx->cc_refcount), - ctx, ctx->cc_vcred.vc_uid, - sec2target_str(ctx->cc_sec), grace); - } - ctx_unhash_pf(ctx, &freelist); - - set_bit(PTLRPC_CTX_DEAD_BIT, &ctx->cc_flags); - if (!grace) - clear_bit(PTLRPC_CTX_UPTODATE_BIT, - &ctx->cc_flags); - } - } - spin_unlock(&sec->ps_lock); - - ctx_list_destroy_pf(&freelist); - return busy; -} - -/**************************************** - * service apis * - ****************************************/ - -static -int gss_svc_accept_pf(struct ptlrpc_request *req) -{ - return gss_svc_accept(&gss_policy_pipefs, req); -} - -static -int gss_svc_install_rctx_pf(struct obd_import *imp, - struct ptlrpc_svc_ctx *ctx) -{ - struct ptlrpc_sec *sec; - int rc; - - sec = sptlrpc_import_sec_ref(imp); - LASSERT(sec); - rc = gss_install_rvs_cli_ctx_pf(sec2gsec(sec), ctx); - - sptlrpc_sec_put(sec); - return rc; -} - -/**************************************** - * rpc_pipefs definitions * - ****************************************/ - -#define LUSTRE_PIPE_ROOT "/lustre" -#define LUSTRE_PIPE_KRB5 LUSTRE_PIPE_ROOT"/krb5" - -struct gss_upcall_msg_data { - __u32 gum_seq; - __u32 gum_uid; - __u32 gum_gid; - __u32 gum_svc; /* MDS/OSS... */ - __u64 gum_nid; /* peer NID */ - __u8 gum_obd[64]; /* client obd name */ -}; - -struct gss_upcall_msg { - struct rpc_pipe_msg gum_base; - atomic_t gum_refcount; - struct list_head gum_list; - __u32 gum_mechidx; - struct gss_sec *gum_gsec; - struct gss_cli_ctx *gum_gctx; - struct gss_upcall_msg_data gum_data; -}; - -static atomic_t upcall_seq = ATOMIC_INIT(0); - -static inline -__u32 upcall_get_sequence(void) -{ - return (__u32) atomic_inc_return(&upcall_seq); -} - -enum mech_idx_t { - MECH_KRB5 = 0, - MECH_MAX -}; - -static inline -__u32 mech_name2idx(const char *name) -{ - LASSERT(!strcmp(name, "krb5")); - return MECH_KRB5; -} - -/* pipefs dentries for each mechanisms */ -static struct dentry *de_pipes[MECH_MAX] = { NULL, }; -/* all upcall messages linked here */ -static struct list_head upcall_lists[MECH_MAX]; -/* and protected by this */ -static spinlock_t upcall_locks[MECH_MAX]; - -static inline -void upcall_list_lock(int idx) -{ - spin_lock(&upcall_locks[idx]); -} - -static inline -void upcall_list_unlock(int idx) -{ - spin_unlock(&upcall_locks[idx]); -} - -static -void upcall_msg_enlist(struct gss_upcall_msg *msg) -{ - __u32 idx = msg->gum_mechidx; - - upcall_list_lock(idx); - list_add(&msg->gum_list, &upcall_lists[idx]); - upcall_list_unlock(idx); -} - -static -void upcall_msg_delist(struct gss_upcall_msg *msg) -{ - __u32 idx = msg->gum_mechidx; - - upcall_list_lock(idx); - list_del_init(&msg->gum_list); - upcall_list_unlock(idx); -} - -/**************************************** - * rpc_pipefs upcall helpers * - ****************************************/ - -static -void gss_release_msg(struct gss_upcall_msg *gmsg) -{ - LASSERT(atomic_read(&gmsg->gum_refcount) > 0); - - if (!atomic_dec_and_test(&gmsg->gum_refcount)) { - return; - } - - if (gmsg->gum_gctx) { - sptlrpc_cli_ctx_wakeup(&gmsg->gum_gctx->gc_base); - sptlrpc_cli_ctx_put(&gmsg->gum_gctx->gc_base, 1); - gmsg->gum_gctx = NULL; - } - - LASSERT(list_empty(&gmsg->gum_list)); - LASSERT(list_empty(&gmsg->gum_base.list)); - OBD_FREE_PTR(gmsg); -} - -static -void gss_unhash_msg_nolock(struct gss_upcall_msg *gmsg) -{ - __u32 idx = gmsg->gum_mechidx; - - LASSERT(idx < MECH_MAX); - assert_spin_locked(&upcall_locks[idx]); - - if (list_empty(&gmsg->gum_list)) - return; - - list_del_init(&gmsg->gum_list); - LASSERT(atomic_read(&gmsg->gum_refcount) > 1); - atomic_dec(&gmsg->gum_refcount); -} - -static -void gss_unhash_msg(struct gss_upcall_msg *gmsg) -{ - __u32 idx = gmsg->gum_mechidx; - - LASSERT(idx < MECH_MAX); - upcall_list_lock(idx); - gss_unhash_msg_nolock(gmsg); - upcall_list_unlock(idx); -} - -static -void gss_msg_fail_ctx(struct gss_upcall_msg *gmsg) -{ - if (gmsg->gum_gctx) { - struct ptlrpc_cli_ctx *ctx = &gmsg->gum_gctx->gc_base; - - LASSERT(atomic_read(&ctx->cc_refcount) > 0); - sptlrpc_cli_ctx_expire(ctx); - set_bit(PTLRPC_CTX_ERROR_BIT, &ctx->cc_flags); - } -} - -static -struct gss_upcall_msg * gss_find_upcall(__u32 mechidx, __u32 seq) -{ - struct gss_upcall_msg *gmsg; - - upcall_list_lock(mechidx); - list_for_each_entry(gmsg, &upcall_lists[mechidx], gum_list) { - if (gmsg->gum_data.gum_seq != seq) - continue; - - LASSERT(atomic_read(&gmsg->gum_refcount) > 0); - LASSERT(gmsg->gum_mechidx == mechidx); - - atomic_inc(&gmsg->gum_refcount); - upcall_list_unlock(mechidx); - return gmsg; - } - upcall_list_unlock(mechidx); - return NULL; -} - -static -int simple_get_bytes(char **buf, __u32 *buflen, void *res, __u32 reslen) -{ - if (*buflen < reslen) { - CERROR("buflen %u < %u\n", *buflen, reslen); - return -EINVAL; - } - - memcpy(res, *buf, reslen); - *buf += reslen; - *buflen -= reslen; - return 0; -} - -/**************************************** - * rpc_pipefs apis * - ****************************************/ - -static -ssize_t gss_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, - char *dst, size_t buflen) -{ - char *data = (char *)msg->data + msg->copied; - ssize_t mlen = msg->len; - ssize_t left; - - if (mlen > buflen) - mlen = buflen; - left = copy_to_user(dst, data, mlen); - if (left < 0) { - msg->errno = left; - return left; - } - mlen -= left; - msg->copied += mlen; - msg->errno = 0; - return mlen; -} - -static -ssize_t gss_pipe_downcall(struct file *filp, const char *src, size_t mlen) -{ - struct rpc_inode *rpci = RPC_I(filp->f_dentry->d_inode); - struct gss_upcall_msg *gss_msg; - struct ptlrpc_cli_ctx *ctx; - struct gss_cli_ctx *gctx = NULL; - char *buf, *data; - int datalen; - int timeout, rc; - __u32 mechidx, seq, gss_err; - - mechidx = (__u32) (long) rpci->private; - LASSERT(mechidx < MECH_MAX); - - OBD_ALLOC(buf, mlen); - if (!buf) - return -ENOMEM; - - if (copy_from_user(buf, src, mlen)) { - CERROR("failed copy user space data\n"); - GOTO(out_free, rc = -EFAULT); - } - data = buf; - datalen = mlen; - - /* data passed down format: - * - seq - * - timeout - * - gc_win / error - * - wire_ctx (rawobj) - * - mech_ctx (rawobj) - */ - if (simple_get_bytes(&data, &datalen, &seq, sizeof(seq))) { - CERROR("fail to get seq\n"); - GOTO(out_free, rc = -EFAULT); - } - - gss_msg = gss_find_upcall(mechidx, seq); - if (!gss_msg) { - CERROR("upcall %u has aborted earlier\n", seq); - GOTO(out_free, rc = -EINVAL); - } - - gss_unhash_msg(gss_msg); - gctx = gss_msg->gum_gctx; - LASSERT(gctx); - LASSERT(atomic_read(&gctx->gc_base.cc_refcount) > 0); - - /* timeout is not in use for now */ - if (simple_get_bytes(&data, &datalen, &timeout, sizeof(timeout))) - GOTO(out_msg, rc = -EFAULT); - - /* lgssd signal an error by gc_win == 0 */ - if (simple_get_bytes(&data, &datalen, &gctx->gc_win, - sizeof(gctx->gc_win))) - GOTO(out_msg, rc = -EFAULT); - - if (gctx->gc_win == 0) { - /* followed by: - * - rpc error - * - gss error - */ - if (simple_get_bytes(&data, &datalen, &rc, sizeof(rc))) - GOTO(out_msg, rc = -EFAULT); - if (simple_get_bytes(&data, &datalen, &gss_err,sizeof(gss_err))) - GOTO(out_msg, rc = -EFAULT); - - if (rc == 0 && gss_err == GSS_S_COMPLETE) { - CWARN("both rpc & gss error code not set\n"); - rc = -EPERM; - } - } else { - rawobj_t tmpobj; - - /* handle */ - if (rawobj_extract_local(&tmpobj, (__u32 **) &data, &datalen)) - GOTO(out_msg, rc = -EFAULT); - if (rawobj_dup(&gctx->gc_handle, &tmpobj)) - GOTO(out_msg, rc = -ENOMEM); - - /* mechctx */ - if (rawobj_extract_local(&tmpobj, (__u32 **) &data, &datalen)) - GOTO(out_msg, rc = -EFAULT); - gss_err = lgss_import_sec_context(&tmpobj, - gss_msg->gum_gsec->gs_mech, - &gctx->gc_mechctx); - rc = 0; - } - - if (likely(rc == 0 && gss_err == GSS_S_COMPLETE)) { - gss_cli_ctx_uptodate(gctx); - } else { - ctx = &gctx->gc_base; - sptlrpc_cli_ctx_expire(ctx); - if (rc != -ERESTART || gss_err != GSS_S_COMPLETE) - set_bit(PTLRPC_CTX_ERROR_BIT, &ctx->cc_flags); - - CERROR("refresh ctx %p(uid %d) failed: %d/0x%08x: %s\n", - ctx, ctx->cc_vcred.vc_uid, rc, gss_err, - test_bit(PTLRPC_CTX_ERROR_BIT, &ctx->cc_flags) ? - "fatal error" : "non-fatal"); - } - - rc = mlen; - -out_msg: - gss_release_msg(gss_msg); - -out_free: - OBD_FREE(buf, mlen); - /* FIXME - * hack pipefs: always return asked length unless all following - * downcalls might be messed up. */ - rc = mlen; - return rc; -} - -static -void gss_pipe_destroy_msg(struct rpc_pipe_msg *msg) -{ - struct gss_upcall_msg *gmsg; - struct gss_upcall_msg_data *gumd; - static cfs_time_t ratelimit = 0; - - LASSERT(list_empty(&msg->list)); - - /* normally errno is >= 0 */ - if (msg->errno >= 0) { - return; - } - - gmsg = container_of(msg, struct gss_upcall_msg, gum_base); - gumd = &gmsg->gum_data; - LASSERT(atomic_read(&gmsg->gum_refcount) > 0); - - CERROR("failed msg %p (seq %u, uid %u, svc %u, nid "LPX64", obd %.*s): " - "errno %d\n", msg, gumd->gum_seq, gumd->gum_uid, gumd->gum_svc, - gumd->gum_nid, (int) sizeof(gumd->gum_obd), - gumd->gum_obd, msg->errno); - - atomic_inc(&gmsg->gum_refcount); - gss_unhash_msg(gmsg); - if (msg->errno == -ETIMEDOUT || msg->errno == -EPIPE) { - cfs_time_t now = cfs_time_current_sec(); - - if (cfs_time_after(now, ratelimit)) { - CWARN("upcall timed out, is lgssd running?\n"); - ratelimit = now + 15; - } - } - gss_msg_fail_ctx(gmsg); - gss_release_msg(gmsg); -} - -static -void gss_pipe_release(struct inode *inode) -{ - struct rpc_inode *rpci = RPC_I(inode); - __u32 idx; - - idx = (__u32) (long) rpci->private; - LASSERT(idx < MECH_MAX); - - upcall_list_lock(idx); - while (!list_empty(&upcall_lists[idx])) { - struct gss_upcall_msg *gmsg; - struct gss_upcall_msg_data *gumd; - - gmsg = list_entry(upcall_lists[idx].next, - struct gss_upcall_msg, gum_list); - gumd = &gmsg->gum_data; - LASSERT(list_empty(&gmsg->gum_base.list)); - - CERROR("failing remaining msg %p:seq %u, uid %u, svc %u, " - "nid "LPX64", obd %.*s\n", gmsg, - gumd->gum_seq, gumd->gum_uid, gumd->gum_svc, - gumd->gum_nid, (int) sizeof(gumd->gum_obd), - gumd->gum_obd); - - gmsg->gum_base.errno = -EPIPE; - atomic_inc(&gmsg->gum_refcount); - gss_unhash_msg_nolock(gmsg); - - gss_msg_fail_ctx(gmsg); - - upcall_list_unlock(idx); - gss_release_msg(gmsg); - upcall_list_lock(idx); - } - upcall_list_unlock(idx); -} - -static struct rpc_pipe_ops gss_upcall_ops = { - .upcall = gss_pipe_upcall, - .downcall = gss_pipe_downcall, - .destroy_msg = gss_pipe_destroy_msg, - .release_pipe = gss_pipe_release, -}; - -/**************************************** - * upcall helper functions * - ****************************************/ - -static -int gss_ctx_refresh_pf(struct ptlrpc_cli_ctx *ctx) -{ - struct obd_import *imp; - struct gss_sec *gsec; - struct gss_upcall_msg *gmsg; - int rc = 0; - - might_sleep(); - - LASSERT(ctx->cc_sec); - LASSERT(ctx->cc_sec->ps_import); - LASSERT(ctx->cc_sec->ps_import->imp_obd); - - imp = ctx->cc_sec->ps_import; - if (!imp->imp_connection) { - CERROR("import has no connection set\n"); - return -EINVAL; - } - - gsec = container_of(ctx->cc_sec, struct gss_sec, gs_base); - - OBD_ALLOC_PTR(gmsg); - if (!gmsg) - return -ENOMEM; - - /* initialize pipefs base msg */ - INIT_LIST_HEAD(&gmsg->gum_base.list); - gmsg->gum_base.data = &gmsg->gum_data; - gmsg->gum_base.len = sizeof(gmsg->gum_data); - gmsg->gum_base.copied = 0; - gmsg->gum_base.errno = 0; - - /* init upcall msg */ - atomic_set(&gmsg->gum_refcount, 1); - gmsg->gum_mechidx = mech_name2idx(gsec->gs_mech->gm_name); - gmsg->gum_gsec = gsec; - gmsg->gum_gctx = container_of(sptlrpc_cli_ctx_get(ctx), - struct gss_cli_ctx, gc_base); - gmsg->gum_data.gum_seq = upcall_get_sequence(); - gmsg->gum_data.gum_uid = ctx->cc_vcred.vc_uid; - gmsg->gum_data.gum_gid = 0; /* not used for now */ - gmsg->gum_data.gum_svc = import_to_gss_svc(imp); - gmsg->gum_data.gum_nid = imp->imp_connection->c_peer.nid; - strncpy(gmsg->gum_data.gum_obd, imp->imp_obd->obd_name, - sizeof(gmsg->gum_data.gum_obd)); - - /* This only could happen when sysadmin set it dead/expired - * using lctl by force. */ - if (ctx->cc_flags & PTLRPC_CTX_STATUS_MASK) { - CWARN("ctx %p(%u->%s) was set flags %lx unexpectedly\n", - ctx, ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec), - ctx->cc_flags); - - LASSERT(!(ctx->cc_flags & PTLRPC_CTX_UPTODATE)); - ctx->cc_flags |= PTLRPC_CTX_DEAD | PTLRPC_CTX_ERROR; - - rc = -EIO; - goto err_free; - } - - upcall_msg_enlist(gmsg); - - rc = rpc_queue_upcall(de_pipes[gmsg->gum_mechidx]->d_inode, - &gmsg->gum_base); - if (rc) { - CERROR("rpc_queue_upcall failed: %d\n", rc); - - upcall_msg_delist(gmsg); - goto err_free; - } - - return 0; -err_free: - OBD_FREE_PTR(gmsg); - return rc; -} - -static -int gss_cli_ctx_refresh_pf(struct ptlrpc_cli_ctx *ctx) -{ - /* if we are refreshing for root, also update the reverse - * handle index, do not confuse reverse contexts. */ - if (ctx->cc_vcred.vc_uid == 0) { - struct gss_sec *gsec; - - gsec = container_of(ctx->cc_sec, struct gss_sec, gs_base); - gsec->gs_rvs_hdl = gss_get_next_ctx_index(); - } - - return gss_ctx_refresh_pf(ctx); -} - -/**************************************** - * lustre gss pipefs policy * - ****************************************/ - -static struct ptlrpc_ctx_ops gss_pipefs_ctxops = { - .match = gss_cli_ctx_match, - .refresh = gss_cli_ctx_refresh_pf, - .validate = gss_cli_ctx_validate_pf, - .die = gss_cli_ctx_die_pf, - .sign = gss_cli_ctx_sign, - .verify = gss_cli_ctx_verify, - .seal = gss_cli_ctx_seal, - .unseal = gss_cli_ctx_unseal, - .wrap_bulk = gss_cli_ctx_wrap_bulk, - .unwrap_bulk = gss_cli_ctx_unwrap_bulk, -}; - -static struct ptlrpc_sec_cops gss_sec_pipefs_cops = { - .create_sec = gss_sec_create_pf, - .destroy_sec = gss_sec_destroy_pf, - .kill_sec = gss_sec_kill, - .lookup_ctx = gss_sec_lookup_ctx_pf, - .release_ctx = gss_sec_release_ctx_pf, - .flush_ctx_cache = gss_sec_flush_ctx_cache_pf, - .install_rctx = gss_sec_install_rctx, - .alloc_reqbuf = gss_alloc_reqbuf, - .free_reqbuf = gss_free_reqbuf, - .alloc_repbuf = gss_alloc_repbuf, - .free_repbuf = gss_free_repbuf, - .enlarge_reqbuf = gss_enlarge_reqbuf, -}; - -static struct ptlrpc_sec_sops gss_sec_pipefs_sops = { - .accept = gss_svc_accept_pf, - .invalidate_ctx = gss_svc_invalidate_ctx, - .alloc_rs = gss_svc_alloc_rs, - .authorize = gss_svc_authorize, - .free_rs = gss_svc_free_rs, - .free_ctx = gss_svc_free_ctx, - .unwrap_bulk = gss_svc_unwrap_bulk, - .wrap_bulk = gss_svc_wrap_bulk, - .install_rctx = gss_svc_install_rctx_pf, -}; - -static struct ptlrpc_sec_policy gss_policy_pipefs = { - .sp_owner = THIS_MODULE, - .sp_name = "gss.pipefs", - .sp_policy = SPTLRPC_POLICY_GSS_PIPEFS, - .sp_cops = &gss_sec_pipefs_cops, - .sp_sops = &gss_sec_pipefs_sops, -}; - -static -int __init gss_init_pipefs_upcall(void) -{ - struct dentry *de; - - /* pipe dir */ - de = rpc_mkdir(LUSTRE_PIPE_ROOT, NULL); - if (IS_ERR(de) && PTR_ERR(de) != -EEXIST) { - CERROR("Failed to create gss pipe dir: %ld\n", PTR_ERR(de)); - return PTR_ERR(de); - } - - /* FIXME hack pipefs: dput will sometimes cause oops during module - * unload and lgssd close the pipe fds. */ - - /* krb5 mechanism */ - de = rpc_mkpipe(LUSTRE_PIPE_KRB5, (void *) MECH_KRB5, &gss_upcall_ops, - RPC_PIPE_WAIT_FOR_OPEN); - if (!de || IS_ERR(de)) { - CERROR("failed to make rpc_pipe %s: %ld\n", - LUSTRE_PIPE_KRB5, PTR_ERR(de)); - rpc_rmdir(LUSTRE_PIPE_ROOT); - return PTR_ERR(de); - } - - de_pipes[MECH_KRB5] = de; - INIT_LIST_HEAD(&upcall_lists[MECH_KRB5]); - spin_lock_init(&upcall_locks[MECH_KRB5]); - - return 0; -} - -static -void __exit gss_exit_pipefs_upcall(void) -{ - __u32 i; - - for (i = 0; i < MECH_MAX; i++) { - LASSERT(list_empty(&upcall_lists[i])); - - /* dput pipe dentry here might cause lgssd oops. */ - de_pipes[i] = NULL; - } - - rpc_unlink(LUSTRE_PIPE_KRB5); - rpc_rmdir(LUSTRE_PIPE_ROOT); -} - -int __init gss_init_pipefs(void) -{ - int rc; - - rc = gss_init_pipefs_upcall(); - if (rc) - return rc; - - rc = sptlrpc_register_policy(&gss_policy_pipefs); - if (rc) { - gss_exit_pipefs_upcall(); - return rc; - } - - return 0; -} - -void __exit gss_exit_pipefs(void) -{ - gss_exit_pipefs_upcall(); - sptlrpc_unregister_policy(&gss_policy_pipefs); -} diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_rawobj.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_rawobj.c deleted file mode 100644 index fb298aef66eb..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_rawobj.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/ptlrpc/gss/gss_rawobj.c - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -#define DEBUG_SUBSYSTEM S_SEC - -#include <linux/mutex.h> - -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre_sec.h> - -#include "gss_internal.h" - -int rawobj_empty(rawobj_t *obj) -{ - LASSERT(equi(obj->len, obj->data)); - return (obj->len == 0); -} - -int rawobj_alloc(rawobj_t *obj, char *buf, int len) -{ - LASSERT(obj); - LASSERT(len >= 0); - - obj->len = len; - if (len) { - OBD_ALLOC_LARGE(obj->data, len); - if (!obj->data) { - obj->len = 0; - return -ENOMEM; - } - memcpy(obj->data, buf, len); - } else - obj->data = NULL; - return 0; -} - -void rawobj_free(rawobj_t *obj) -{ - LASSERT(obj); - - if (obj->len) { - LASSERT(obj->data); - OBD_FREE_LARGE(obj->data, obj->len); - obj->len = 0; - obj->data = NULL; - } else - LASSERT(!obj->data); -} - -int rawobj_equal(rawobj_t *a, rawobj_t *b) -{ - LASSERT(a && b); - - return (a->len == b->len && - (!a->len || !memcmp(a->data, b->data, a->len))); -} - -int rawobj_dup(rawobj_t *dest, rawobj_t *src) -{ - LASSERT(src && dest); - - dest->len = src->len; - if (dest->len) { - OBD_ALLOC_LARGE(dest->data, dest->len); - if (!dest->data) { - dest->len = 0; - return -ENOMEM; - } - memcpy(dest->data, src->data, dest->len); - } else - dest->data = NULL; - return 0; -} - -int rawobj_serialize(rawobj_t *obj, __u32 **buf, __u32 *buflen) -{ - __u32 len; - - LASSERT(obj); - LASSERT(buf); - LASSERT(buflen); - - len = cfs_size_round4(obj->len); - - if (*buflen < 4 + len) { - CERROR("buflen %u < %u\n", *buflen, 4 + len); - return -EINVAL; - } - - *(*buf)++ = cpu_to_le32(obj->len); - memcpy(*buf, obj->data, obj->len); - *buf += (len >> 2); - *buflen -= (4 + len); - - return 0; -} - -static int __rawobj_extract(rawobj_t *obj, __u32 **buf, __u32 *buflen, - int alloc, int local) -{ - __u32 len; - - if (*buflen < sizeof(__u32)) { - CERROR("buflen %u\n", *buflen); - return -EINVAL; - } - - obj->len = *(*buf)++; - if (!local) - obj->len = le32_to_cpu(obj->len); - *buflen -= sizeof(__u32); - - if (!obj->len) { - obj->data = NULL; - return 0; - } - - len = local ? obj->len : cfs_size_round4(obj->len); - if (*buflen < len) { - CERROR("buflen %u < %u\n", *buflen, len); - obj->len = 0; - return -EINVAL; - } - - if (!alloc) - obj->data = (__u8 *) *buf; - else { - OBD_ALLOC_LARGE(obj->data, obj->len); - if (!obj->data) { - CERROR("fail to alloc %u bytes\n", obj->len); - obj->len = 0; - return -ENOMEM; - } - memcpy(obj->data, *buf, obj->len); - } - - *((char **)buf) += len; - *buflen -= len; - - return 0; -} - -int rawobj_extract(rawobj_t *obj, __u32 **buf, __u32 *buflen) -{ - return __rawobj_extract(obj, buf, buflen, 0, 0); -} - -int rawobj_extract_alloc(rawobj_t *obj, __u32 **buf, __u32 *buflen) -{ - return __rawobj_extract(obj, buf, buflen, 1, 0); -} - -int rawobj_extract_local(rawobj_t *obj, __u32 **buf, __u32 *buflen) -{ - return __rawobj_extract(obj, buf, buflen, 0, 1); -} - -int rawobj_extract_local_alloc(rawobj_t *obj, __u32 **buf, __u32 *buflen) -{ - return __rawobj_extract(obj, buf, buflen, 1, 1); -} - -int rawobj_from_netobj(rawobj_t *rawobj, netobj_t *netobj) -{ - rawobj->len = netobj->len; - rawobj->data = netobj->data; - return 0; -} - -int rawobj_from_netobj_alloc(rawobj_t *rawobj, netobj_t *netobj) -{ - rawobj->len = 0; - rawobj->data = NULL; - - if (netobj->len == 0) - return 0; - - OBD_ALLOC_LARGE(rawobj->data, netobj->len); - if (rawobj->data == NULL) - return -ENOMEM; - - rawobj->len = netobj->len; - memcpy(rawobj->data, netobj->data, netobj->len); - return 0; -} - -/**************************************** - * misc more * - ****************************************/ - -int buffer_extract_bytes(const void **buf, __u32 *buflen, - void *res, __u32 reslen) -{ - if (*buflen < reslen) { - CERROR("buflen %u < %u\n", *buflen, reslen); - return -EINVAL; - } - - memcpy(res, *buf, reslen); - *buf += reslen; - *buflen -= reslen; - return 0; -} diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c deleted file mode 100644 index 359c48ec2f5b..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c +++ /dev/null @@ -1,1093 +0,0 @@ -/* - * Modifications for Lustre - * - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * - * Copyright (c) 2011, 2012, Intel Corporation. - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -/* - * Neil Brown <neilb@cse.unsw.edu.au> - * J. Bruce Fields <bfields@umich.edu> - * Andy Adamson <andros@umich.edu> - * Dug Song <dugsong@monkey.org> - * - * RPCSEC_GSS server authentication. - * This implements RPCSEC_GSS as defined in rfc2203 (rpcsec_gss) and rfc2078 - * (gssapi) - * - * The RPCSEC_GSS involves three stages: - * 1/ context creation - * 2/ data exchange - * 3/ context destruction - * - * Context creation is handled largely by upcalls to user-space. - * In particular, GSS_Accept_sec_context is handled by an upcall - * Data exchange is handled entirely within the kernel - * In particular, GSS_GetMIC, GSS_VerifyMIC, GSS_Seal, GSS_Unseal are in-kernel. - * Context destruction is handled in-kernel - * GSS_Delete_sec_context is in-kernel - * - * Context creation is initiated by a RPCSEC_GSS_INIT request arriving. - * The context handle and gss_token are used as a key into the rpcsec_init cache. - * The content of this cache includes some of the outputs of GSS_Accept_sec_context, - * being major_status, minor_status, context_handle, reply_token. - * These are sent back to the client. - * Sequence window management is handled by the kernel. The window size if currently - * a compile time constant. - * - * When user-space is happy that a context is established, it places an entry - * in the rpcsec_context cache. The key for this cache is the context_handle. - * The content includes: - * uid/gidlist - for determining access rights - * mechanism type - * mechanism specific information, such as a key - * - */ - -#define DEBUG_SUBSYSTEM S_SEC -#include <linux/types.h> -#include <linux/init.h> -#include <linux/module.h> -#include <linux/slab.h> -#include <linux/hash.h> -#include <linux/mutex.h> -#include <linux/sunrpc/cache.h> - -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre/lustre_idl.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_sec.h> - -#include "gss_err.h" -#include "gss_internal.h" -#include "gss_api.h" - -#define GSS_SVC_UPCALL_TIMEOUT (20) - -static spinlock_t __ctx_index_lock; -static __u64 __ctx_index; - -__u64 gss_get_next_ctx_index(void) -{ - __u64 idx; - - spin_lock(&__ctx_index_lock); - idx = __ctx_index++; - spin_unlock(&__ctx_index_lock); - - return idx; -} - -static inline unsigned long hash_mem(char *buf, int length, int bits) -{ - unsigned long hash = 0; - unsigned long l = 0; - int len = 0; - unsigned char c; - - do { - if (len == length) { - c = (char) len; - len = -1; - } else - c = *buf++; - - l = (l << 8) | c; - len++; - - if ((len & (BITS_PER_LONG/8-1)) == 0) - hash = hash_long(hash^l, BITS_PER_LONG); - } while (len); - - return hash >> (BITS_PER_LONG - bits); -} - -/**************************************** - * rsi cache * - ****************************************/ - -#define RSI_HASHBITS (6) -#define RSI_HASHMAX (1 << RSI_HASHBITS) -#define RSI_HASHMASK (RSI_HASHMAX - 1) - -struct rsi { - struct cache_head h; - __u32 lustre_svc; - __u64 nid; - wait_queue_head_t waitq; - rawobj_t in_handle, in_token; - rawobj_t out_handle, out_token; - int major_status, minor_status; -}; - -static struct cache_head *rsi_table[RSI_HASHMAX]; -static struct cache_detail rsi_cache; -static struct rsi *rsi_update(struct rsi *new, struct rsi *old); -static struct rsi *rsi_lookup(struct rsi *item); - -static inline int rsi_hash(struct rsi *item) -{ - return hash_mem((char *)item->in_handle.data, item->in_handle.len, - RSI_HASHBITS) ^ - hash_mem((char *)item->in_token.data, item->in_token.len, - RSI_HASHBITS); -} - -static inline int __rsi_match(struct rsi *item, struct rsi *tmp) -{ - return (rawobj_equal(&item->in_handle, &tmp->in_handle) && - rawobj_equal(&item->in_token, &tmp->in_token)); -} - -static void rsi_free(struct rsi *rsi) -{ - rawobj_free(&rsi->in_handle); - rawobj_free(&rsi->in_token); - rawobj_free(&rsi->out_handle); - rawobj_free(&rsi->out_token); -} - -static void rsi_request(struct cache_detail *cd, - struct cache_head *h, - char **bpp, int *blen) -{ - struct rsi *rsi = container_of(h, struct rsi, h); - __u64 index = 0; - - /* if in_handle is null, provide kernel suggestion */ - if (rsi->in_handle.len == 0) - index = gss_get_next_ctx_index(); - - qword_addhex(bpp, blen, (char *) &rsi->lustre_svc, - sizeof(rsi->lustre_svc)); - qword_addhex(bpp, blen, (char *) &rsi->nid, sizeof(rsi->nid)); - qword_addhex(bpp, blen, (char *) &index, sizeof(index)); - qword_addhex(bpp, blen, rsi->in_handle.data, rsi->in_handle.len); - qword_addhex(bpp, blen, rsi->in_token.data, rsi->in_token.len); - (*bpp)[-1] = '\n'; -} - -static int rsi_upcall(struct cache_detail *cd, struct cache_head *h) -{ - return sunrpc_cache_pipe_upcall(cd, h, rsi_request); -} - -static inline void __rsi_init(struct rsi *new, struct rsi *item) -{ - new->out_handle = RAWOBJ_EMPTY; - new->out_token = RAWOBJ_EMPTY; - - new->in_handle = item->in_handle; - item->in_handle = RAWOBJ_EMPTY; - new->in_token = item->in_token; - item->in_token = RAWOBJ_EMPTY; - - new->lustre_svc = item->lustre_svc; - new->nid = item->nid; - init_waitqueue_head(&new->waitq); -} - -static inline void __rsi_update(struct rsi *new, struct rsi *item) -{ - LASSERT(new->out_handle.len == 0); - LASSERT(new->out_token.len == 0); - - new->out_handle = item->out_handle; - item->out_handle = RAWOBJ_EMPTY; - new->out_token = item->out_token; - item->out_token = RAWOBJ_EMPTY; - - new->major_status = item->major_status; - new->minor_status = item->minor_status; -} - -static void rsi_put(struct kref *ref) -{ - struct rsi *rsi = container_of(ref, struct rsi, h.ref); - - LASSERT(rsi->h.next == NULL); - rsi_free(rsi); - OBD_FREE_PTR(rsi); -} - -static int rsi_match(struct cache_head *a, struct cache_head *b) -{ - struct rsi *item = container_of(a, struct rsi, h); - struct rsi *tmp = container_of(b, struct rsi, h); - - return __rsi_match(item, tmp); -} - -static void rsi_init(struct cache_head *cnew, struct cache_head *citem) -{ - struct rsi *new = container_of(cnew, struct rsi, h); - struct rsi *item = container_of(citem, struct rsi, h); - - __rsi_init(new, item); -} - -static void update_rsi(struct cache_head *cnew, struct cache_head *citem) -{ - struct rsi *new = container_of(cnew, struct rsi, h); - struct rsi *item = container_of(citem, struct rsi, h); - - __rsi_update(new, item); -} - -static struct cache_head *rsi_alloc(void) -{ - struct rsi *rsi; - - OBD_ALLOC_PTR(rsi); - if (rsi) - return &rsi->h; - else - return NULL; -} - -static int rsi_parse(struct cache_detail *cd, char *mesg, int mlen) -{ - char *buf = mesg; - char *ep; - int len; - struct rsi rsii, *rsip = NULL; - time_t expiry; - int status = -EINVAL; - - memset(&rsii, 0, sizeof(rsii)); - - /* handle */ - len = qword_get(&mesg, buf, mlen); - if (len < 0) - goto out; - if (rawobj_alloc(&rsii.in_handle, buf, len)) { - status = -ENOMEM; - goto out; - } - - /* token */ - len = qword_get(&mesg, buf, mlen); - if (len < 0) - goto out; - if (rawobj_alloc(&rsii.in_token, buf, len)) { - status = -ENOMEM; - goto out; - } - - rsip = rsi_lookup(&rsii); - if (!rsip) - goto out; - - rsii.h.flags = 0; - /* expiry */ - expiry = get_expiry(&mesg); - if (expiry == 0) - goto out; - - len = qword_get(&mesg, buf, mlen); - if (len <= 0) - goto out; - - /* major */ - rsii.major_status = simple_strtol(buf, &ep, 10); - if (*ep) - goto out; - - /* minor */ - len = qword_get(&mesg, buf, mlen); - if (len <= 0) - goto out; - rsii.minor_status = simple_strtol(buf, &ep, 10); - if (*ep) - goto out; - - /* out_handle */ - len = qword_get(&mesg, buf, mlen); - if (len < 0) - goto out; - if (rawobj_alloc(&rsii.out_handle, buf, len)) { - status = -ENOMEM; - goto out; - } - - /* out_token */ - len = qword_get(&mesg, buf, mlen); - if (len < 0) - goto out; - if (rawobj_alloc(&rsii.out_token, buf, len)) { - status = -ENOMEM; - goto out; - } - - rsii.h.expiry_time = expiry; - rsip = rsi_update(&rsii, rsip); - status = 0; -out: - rsi_free(&rsii); - if (rsip) { - wake_up_all(&rsip->waitq); - cache_put(&rsip->h, &rsi_cache); - } else { - status = -ENOMEM; - } - - if (status) - CERROR("rsi parse error %d\n", status); - return status; -} - -static struct cache_detail rsi_cache = { - .hash_size = RSI_HASHMAX, - .hash_table = rsi_table, - .name = "auth.sptlrpc.init", - .cache_put = rsi_put, - .cache_upcall = rsi_upcall, - .cache_parse = rsi_parse, - .match = rsi_match, - .init = rsi_init, - .update = update_rsi, - .alloc = rsi_alloc, -}; - -static struct rsi *rsi_lookup(struct rsi *item) -{ - struct cache_head *ch; - int hash = rsi_hash(item); - - ch = sunrpc_cache_lookup(&rsi_cache, &item->h, hash); - if (ch) - return container_of(ch, struct rsi, h); - else - return NULL; -} - -static struct rsi *rsi_update(struct rsi *new, struct rsi *old) -{ - struct cache_head *ch; - int hash = rsi_hash(new); - - ch = sunrpc_cache_update(&rsi_cache, &new->h, &old->h, hash); - if (ch) - return container_of(ch, struct rsi, h); - else - return NULL; -} - -/**************************************** - * rsc cache * - ****************************************/ - -#define RSC_HASHBITS (10) -#define RSC_HASHMAX (1 << RSC_HASHBITS) -#define RSC_HASHMASK (RSC_HASHMAX - 1) - -struct rsc { - struct cache_head h; - struct obd_device *target; - rawobj_t handle; - struct gss_svc_ctx ctx; -}; - -static struct cache_head *rsc_table[RSC_HASHMAX]; -static struct cache_detail rsc_cache; -static struct rsc *rsc_update(struct rsc *new, struct rsc *old); -static struct rsc *rsc_lookup(struct rsc *item); - -static void rsc_free(struct rsc *rsci) -{ - rawobj_free(&rsci->handle); - rawobj_free(&rsci->ctx.gsc_rvs_hdl); - lgss_delete_sec_context(&rsci->ctx.gsc_mechctx); -} - -static inline int rsc_hash(struct rsc *rsci) -{ - return hash_mem((char *)rsci->handle.data, - rsci->handle.len, RSC_HASHBITS); -} - -static inline int __rsc_match(struct rsc *new, struct rsc *tmp) -{ - return rawobj_equal(&new->handle, &tmp->handle); -} - -static inline void __rsc_init(struct rsc *new, struct rsc *tmp) -{ - new->handle = tmp->handle; - tmp->handle = RAWOBJ_EMPTY; - - new->target = NULL; - memset(&new->ctx, 0, sizeof(new->ctx)); - new->ctx.gsc_rvs_hdl = RAWOBJ_EMPTY; -} - -static inline void __rsc_update(struct rsc *new, struct rsc *tmp) -{ - new->ctx = tmp->ctx; - tmp->ctx.gsc_rvs_hdl = RAWOBJ_EMPTY; - tmp->ctx.gsc_mechctx = NULL; - - memset(&new->ctx.gsc_seqdata, 0, sizeof(new->ctx.gsc_seqdata)); - spin_lock_init(&new->ctx.gsc_seqdata.ssd_lock); -} - -static void rsc_put(struct kref *ref) -{ - struct rsc *rsci = container_of(ref, struct rsc, h.ref); - - LASSERT(rsci->h.next == NULL); - rsc_free(rsci); - OBD_FREE_PTR(rsci); -} - -static int rsc_match(struct cache_head *a, struct cache_head *b) -{ - struct rsc *new = container_of(a, struct rsc, h); - struct rsc *tmp = container_of(b, struct rsc, h); - - return __rsc_match(new, tmp); -} - -static void rsc_init(struct cache_head *cnew, struct cache_head *ctmp) -{ - struct rsc *new = container_of(cnew, struct rsc, h); - struct rsc *tmp = container_of(ctmp, struct rsc, h); - - __rsc_init(new, tmp); -} - -static void update_rsc(struct cache_head *cnew, struct cache_head *ctmp) -{ - struct rsc *new = container_of(cnew, struct rsc, h); - struct rsc *tmp = container_of(ctmp, struct rsc, h); - - __rsc_update(new, tmp); -} - -static struct cache_head * rsc_alloc(void) -{ - struct rsc *rsc; - - OBD_ALLOC_PTR(rsc); - if (rsc) - return &rsc->h; - else - return NULL; -} - -static int rsc_parse(struct cache_detail *cd, char *mesg, int mlen) -{ - char *buf = mesg; - int len, rv, tmp_int; - struct rsc rsci, *rscp = NULL; - time_t expiry; - int status = -EINVAL; - struct gss_api_mech *gm = NULL; - - memset(&rsci, 0, sizeof(rsci)); - - /* context handle */ - len = qword_get(&mesg, buf, mlen); - if (len < 0) goto out; - status = -ENOMEM; - if (rawobj_alloc(&rsci.handle, buf, len)) - goto out; - - rsci.h.flags = 0; - /* expiry */ - expiry = get_expiry(&mesg); - status = -EINVAL; - if (expiry == 0) - goto out; - - /* remote flag */ - rv = get_int(&mesg, &tmp_int); - if (rv) { - CERROR("fail to get remote flag\n"); - goto out; - } - rsci.ctx.gsc_remote = (tmp_int != 0); - - /* root user flag */ - rv = get_int(&mesg, &tmp_int); - if (rv) { - CERROR("fail to get oss user flag\n"); - goto out; - } - rsci.ctx.gsc_usr_root = (tmp_int != 0); - - /* mds user flag */ - rv = get_int(&mesg, &tmp_int); - if (rv) { - CERROR("fail to get mds user flag\n"); - goto out; - } - rsci.ctx.gsc_usr_mds = (tmp_int != 0); - - /* oss user flag */ - rv = get_int(&mesg, &tmp_int); - if (rv) { - CERROR("fail to get oss user flag\n"); - goto out; - } - rsci.ctx.gsc_usr_oss = (tmp_int != 0); - - /* mapped uid */ - rv = get_int(&mesg, (int *) &rsci.ctx.gsc_mapped_uid); - if (rv) { - CERROR("fail to get mapped uid\n"); - goto out; - } - - rscp = rsc_lookup(&rsci); - if (!rscp) - goto out; - - /* uid, or NEGATIVE */ - rv = get_int(&mesg, (int *) &rsci.ctx.gsc_uid); - if (rv == -EINVAL) - goto out; - if (rv == -ENOENT) { - CERROR("NOENT? set rsc entry negative\n"); - set_bit(CACHE_NEGATIVE, &rsci.h.flags); - } else { - rawobj_t tmp_buf; - unsigned long ctx_expiry; - - /* gid */ - if (get_int(&mesg, (int *) &rsci.ctx.gsc_gid)) - goto out; - - /* mech name */ - len = qword_get(&mesg, buf, mlen); - if (len < 0) - goto out; - gm = lgss_name_to_mech(buf); - status = -EOPNOTSUPP; - if (!gm) - goto out; - - status = -EINVAL; - /* mech-specific data: */ - len = qword_get(&mesg, buf, mlen); - if (len < 0) - goto out; - - tmp_buf.len = len; - tmp_buf.data = (unsigned char *)buf; - if (lgss_import_sec_context(&tmp_buf, gm, - &rsci.ctx.gsc_mechctx)) - goto out; - - /* currently the expiry time passed down from user-space - * is invalid, here we retrieve it from mech. */ - if (lgss_inquire_context(rsci.ctx.gsc_mechctx, &ctx_expiry)) { - CERROR("unable to get expire time, drop it\n"); - goto out; - } - expiry = (time_t) ctx_expiry; - } - - rsci.h.expiry_time = expiry; - rscp = rsc_update(&rsci, rscp); - status = 0; -out: - if (gm) - lgss_mech_put(gm); - rsc_free(&rsci); - if (rscp) - cache_put(&rscp->h, &rsc_cache); - else - status = -ENOMEM; - - if (status) - CERROR("parse rsc error %d\n", status); - return status; -} - -static struct cache_detail rsc_cache = { - .hash_size = RSC_HASHMAX, - .hash_table = rsc_table, - .name = "auth.sptlrpc.context", - .cache_put = rsc_put, - .cache_parse = rsc_parse, - .match = rsc_match, - .init = rsc_init, - .update = update_rsc, - .alloc = rsc_alloc, -}; - -static struct rsc *rsc_lookup(struct rsc *item) -{ - struct cache_head *ch; - int hash = rsc_hash(item); - - ch = sunrpc_cache_lookup(&rsc_cache, &item->h, hash); - if (ch) - return container_of(ch, struct rsc, h); - else - return NULL; -} - -static struct rsc *rsc_update(struct rsc *new, struct rsc *old) -{ - struct cache_head *ch; - int hash = rsc_hash(new); - - ch = sunrpc_cache_update(&rsc_cache, &new->h, &old->h, hash); - if (ch) - return container_of(ch, struct rsc, h); - else - return NULL; -} - -#define COMPAT_RSC_PUT(item, cd) cache_put((item), (cd)) - -/**************************************** - * rsc cache flush * - ****************************************/ - -typedef int rsc_entry_match(struct rsc *rscp, long data); - -static void rsc_flush(rsc_entry_match *match, long data) -{ - struct cache_head **ch; - struct rsc *rscp; - int n; - - write_lock(&rsc_cache.hash_lock); - for (n = 0; n < RSC_HASHMAX; n++) { - for (ch = &rsc_cache.hash_table[n]; *ch;) { - rscp = container_of(*ch, struct rsc, h); - - if (!match(rscp, data)) { - ch = &((*ch)->next); - continue; - } - - /* it seems simply set NEGATIVE doesn't work */ - *ch = (*ch)->next; - rscp->h.next = NULL; - cache_get(&rscp->h); - set_bit(CACHE_NEGATIVE, &rscp->h.flags); - COMPAT_RSC_PUT(&rscp->h, &rsc_cache); - rsc_cache.entries--; - } - } - write_unlock(&rsc_cache.hash_lock); -} - -static int match_uid(struct rsc *rscp, long uid) -{ - if ((int) uid == -1) - return 1; - return ((int) rscp->ctx.gsc_uid == (int) uid); -} - -static int match_target(struct rsc *rscp, long target) -{ - return (rscp->target == (struct obd_device *) target); -} - -static inline void rsc_flush_uid(int uid) -{ - if (uid == -1) - CWARN("flush all gss contexts...\n"); - - rsc_flush(match_uid, (long) uid); -} - -static inline void rsc_flush_target(struct obd_device *target) -{ - rsc_flush(match_target, (long) target); -} - -void gss_secsvc_flush(struct obd_device *target) -{ - rsc_flush_target(target); -} -EXPORT_SYMBOL(gss_secsvc_flush); - -static struct rsc *gss_svc_searchbyctx(rawobj_t *handle) -{ - struct rsc rsci; - struct rsc *found; - - memset(&rsci, 0, sizeof(rsci)); - if (rawobj_dup(&rsci.handle, handle)) - return NULL; - - found = rsc_lookup(&rsci); - rsc_free(&rsci); - if (!found) - return NULL; - if (cache_check(&rsc_cache, &found->h, NULL)) - return NULL; - return found; -} - -int gss_svc_upcall_install_rvs_ctx(struct obd_import *imp, - struct gss_sec *gsec, - struct gss_cli_ctx *gctx) -{ - struct rsc rsci, *rscp = NULL; - unsigned long ctx_expiry; - __u32 major; - int rc; - - memset(&rsci, 0, sizeof(rsci)); - - if (rawobj_alloc(&rsci.handle, (char *) &gsec->gs_rvs_hdl, - sizeof(gsec->gs_rvs_hdl))) - GOTO(out, rc = -ENOMEM); - - rscp = rsc_lookup(&rsci); - if (rscp == NULL) - GOTO(out, rc = -ENOMEM); - - major = lgss_copy_reverse_context(gctx->gc_mechctx, - &rsci.ctx.gsc_mechctx); - if (major != GSS_S_COMPLETE) - GOTO(out, rc = -ENOMEM); - - if (lgss_inquire_context(rsci.ctx.gsc_mechctx, &ctx_expiry)) { - CERROR("unable to get expire time, drop it\n"); - GOTO(out, rc = -EINVAL); - } - rsci.h.expiry_time = (time_t) ctx_expiry; - - if (strcmp(imp->imp_obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0) - rsci.ctx.gsc_usr_mds = 1; - else if (strcmp(imp->imp_obd->obd_type->typ_name, LUSTRE_OSC_NAME) == 0) - rsci.ctx.gsc_usr_oss = 1; - else - rsci.ctx.gsc_usr_root = 1; - - rscp = rsc_update(&rsci, rscp); - if (rscp == NULL) - GOTO(out, rc = -ENOMEM); - - rscp->target = imp->imp_obd; - rawobj_dup(&gctx->gc_svc_handle, &rscp->handle); - - CWARN("create reverse svc ctx %p to %s: idx "LPX64"\n", - &rscp->ctx, obd2cli_tgt(imp->imp_obd), gsec->gs_rvs_hdl); - rc = 0; -out: - if (rscp) - cache_put(&rscp->h, &rsc_cache); - rsc_free(&rsci); - - if (rc) - CERROR("create reverse svc ctx: idx "LPX64", rc %d\n", - gsec->gs_rvs_hdl, rc); - return rc; -} - -int gss_svc_upcall_expire_rvs_ctx(rawobj_t *handle) -{ - const cfs_time_t expire = 20; - struct rsc *rscp; - - rscp = gss_svc_searchbyctx(handle); - if (rscp) { - CDEBUG(D_SEC, "reverse svcctx %p (rsc %p) expire soon\n", - &rscp->ctx, rscp); - - rscp->h.expiry_time = cfs_time_current_sec() + expire; - COMPAT_RSC_PUT(&rscp->h, &rsc_cache); - } - return 0; -} - -int gss_svc_upcall_dup_handle(rawobj_t *handle, struct gss_svc_ctx *ctx) -{ - struct rsc *rscp = container_of(ctx, struct rsc, ctx); - - return rawobj_dup(handle, &rscp->handle); -} - -int gss_svc_upcall_update_sequence(rawobj_t *handle, __u32 seq) -{ - struct rsc *rscp; - - rscp = gss_svc_searchbyctx(handle); - if (rscp) { - CDEBUG(D_SEC, "reverse svcctx %p (rsc %p) update seq to %u\n", - &rscp->ctx, rscp, seq + 1); - - rscp->ctx.gsc_rvs_seq = seq + 1; - COMPAT_RSC_PUT(&rscp->h, &rsc_cache); - } - return 0; -} - -static struct cache_deferred_req* cache_upcall_defer(struct cache_req *req) -{ - return NULL; -} -static struct cache_req cache_upcall_chandle = { cache_upcall_defer }; - -int gss_svc_upcall_handle_init(struct ptlrpc_request *req, - struct gss_svc_reqctx *grctx, - struct gss_wire_ctx *gw, - struct obd_device *target, - __u32 lustre_svc, - rawobj_t *rvs_hdl, - rawobj_t *in_token) -{ - struct ptlrpc_reply_state *rs; - struct rsc *rsci = NULL; - struct rsi *rsip = NULL, rsikey; - wait_queue_t wait; - int replen = sizeof(struct ptlrpc_body); - struct gss_rep_header *rephdr; - int first_check = 1; - int rc = SECSVC_DROP; - - memset(&rsikey, 0, sizeof(rsikey)); - rsikey.lustre_svc = lustre_svc; - rsikey.nid = (__u64) req->rq_peer.nid; - - /* duplicate context handle. for INIT it always 0 */ - if (rawobj_dup(&rsikey.in_handle, &gw->gw_handle)) { - CERROR("fail to dup context handle\n"); - GOTO(out, rc); - } - - if (rawobj_dup(&rsikey.in_token, in_token)) { - CERROR("can't duplicate token\n"); - rawobj_free(&rsikey.in_handle); - GOTO(out, rc); - } - - rsip = rsi_lookup(&rsikey); - rsi_free(&rsikey); - if (!rsip) { - CERROR("error in rsi_lookup.\n"); - - if (!gss_pack_err_notify(req, GSS_S_FAILURE, 0)) - rc = SECSVC_COMPLETE; - - GOTO(out, rc); - } - - cache_get(&rsip->h); /* take an extra ref */ - init_waitqueue_head(&rsip->waitq); - init_waitqueue_entry(&wait, current); - add_wait_queue(&rsip->waitq, &wait); - -cache_check: - /* Note each time cache_check() will drop a reference if return - * non-zero. We hold an extra reference on initial rsip, but must - * take care of following calls. */ - rc = cache_check(&rsi_cache, &rsip->h, &cache_upcall_chandle); - switch (rc) { - case -EAGAIN: { - int valid; - - if (first_check) { - first_check = 0; - - read_lock(&rsi_cache.hash_lock); - valid = test_bit(CACHE_VALID, &rsip->h.flags); - if (valid == 0) - set_current_state(TASK_INTERRUPTIBLE); - read_unlock(&rsi_cache.hash_lock); - - if (valid == 0) - schedule_timeout(GSS_SVC_UPCALL_TIMEOUT * - HZ); - - cache_get(&rsip->h); - goto cache_check; - } - CWARN("waited %ds timeout, drop\n", GSS_SVC_UPCALL_TIMEOUT); - break; - } - case -ENOENT: - CWARN("cache_check return ENOENT, drop\n"); - break; - case 0: - /* if not the first check, we have to release the extra - * reference we just added on it. */ - if (!first_check) - cache_put(&rsip->h, &rsi_cache); - CDEBUG(D_SEC, "cache_check is good\n"); - break; - } - - remove_wait_queue(&rsip->waitq, &wait); - cache_put(&rsip->h, &rsi_cache); - - if (rc) - GOTO(out, rc = SECSVC_DROP); - - rc = SECSVC_DROP; - rsci = gss_svc_searchbyctx(&rsip->out_handle); - if (!rsci) { - CERROR("authentication failed\n"); - - if (!gss_pack_err_notify(req, GSS_S_FAILURE, 0)) - rc = SECSVC_COMPLETE; - - GOTO(out, rc); - } else { - cache_get(&rsci->h); - grctx->src_ctx = &rsci->ctx; - } - - if (rawobj_dup(&rsci->ctx.gsc_rvs_hdl, rvs_hdl)) { - CERROR("failed duplicate reverse handle\n"); - GOTO(out, rc); - } - - rsci->target = target; - - CDEBUG(D_SEC, "server create rsc %p(%u->%s)\n", - rsci, rsci->ctx.gsc_uid, libcfs_nid2str(req->rq_peer.nid)); - - if (rsip->out_handle.len > PTLRPC_GSS_MAX_HANDLE_SIZE) { - CERROR("handle size %u too large\n", rsip->out_handle.len); - GOTO(out, rc = SECSVC_DROP); - } - - grctx->src_init = 1; - grctx->src_reserve_len = cfs_size_round4(rsip->out_token.len); - - rc = lustre_pack_reply_v2(req, 1, &replen, NULL, 0); - if (rc) { - CERROR("failed to pack reply: %d\n", rc); - GOTO(out, rc = SECSVC_DROP); - } - - rs = req->rq_reply_state; - LASSERT(rs->rs_repbuf->lm_bufcount == 3); - LASSERT(rs->rs_repbuf->lm_buflens[0] >= - sizeof(*rephdr) + rsip->out_handle.len); - LASSERT(rs->rs_repbuf->lm_buflens[2] >= rsip->out_token.len); - - rephdr = lustre_msg_buf(rs->rs_repbuf, 0, 0); - rephdr->gh_version = PTLRPC_GSS_VERSION; - rephdr->gh_flags = 0; - rephdr->gh_proc = PTLRPC_GSS_PROC_ERR; - rephdr->gh_major = rsip->major_status; - rephdr->gh_minor = rsip->minor_status; - rephdr->gh_seqwin = GSS_SEQ_WIN; - rephdr->gh_handle.len = rsip->out_handle.len; - memcpy(rephdr->gh_handle.data, rsip->out_handle.data, - rsip->out_handle.len); - - memcpy(lustre_msg_buf(rs->rs_repbuf, 2, 0), rsip->out_token.data, - rsip->out_token.len); - - rs->rs_repdata_len = lustre_shrink_msg(rs->rs_repbuf, 2, - rsip->out_token.len, 0); - - rc = SECSVC_OK; - -out: - /* it looks like here we should put rsip also, but this mess up - * with NFS cache mgmt code... FIXME */ -#if 0 - if (rsip) - rsi_put(&rsip->h, &rsi_cache); -#endif - - if (rsci) { - /* if anything went wrong, we don't keep the context too */ - if (rc != SECSVC_OK) - set_bit(CACHE_NEGATIVE, &rsci->h.flags); - else - CDEBUG(D_SEC, "create rsc with idx "LPX64"\n", - gss_handle_to_u64(&rsci->handle)); - - COMPAT_RSC_PUT(&rsci->h, &rsc_cache); - } - return rc; -} - -struct gss_svc_ctx *gss_svc_upcall_get_ctx(struct ptlrpc_request *req, - struct gss_wire_ctx *gw) -{ - struct rsc *rsc; - - rsc = gss_svc_searchbyctx(&gw->gw_handle); - if (!rsc) { - CWARN("Invalid gss ctx idx "LPX64" from %s\n", - gss_handle_to_u64(&gw->gw_handle), - libcfs_nid2str(req->rq_peer.nid)); - return NULL; - } - - return &rsc->ctx; -} - -void gss_svc_upcall_put_ctx(struct gss_svc_ctx *ctx) -{ - struct rsc *rsc = container_of(ctx, struct rsc, ctx); - - COMPAT_RSC_PUT(&rsc->h, &rsc_cache); -} - -void gss_svc_upcall_destroy_ctx(struct gss_svc_ctx *ctx) -{ - struct rsc *rsc = container_of(ctx, struct rsc, ctx); - - /* can't be found */ - set_bit(CACHE_NEGATIVE, &rsc->h.flags); - /* to be removed at next scan */ - rsc->h.expiry_time = 1; -} - -int __init gss_init_svc_upcall(void) -{ - int i; - - spin_lock_init(&__ctx_index_lock); - /* - * this helps reducing context index confliction. after server reboot, - * conflicting request from clients might be filtered out by initial - * sequence number checking, thus no chance to sent error notification - * back to clients. - */ - cfs_get_random_bytes(&__ctx_index, sizeof(__ctx_index)); - - - cache_register(&rsi_cache); - cache_register(&rsc_cache); - - /* FIXME this looks stupid. we intend to give lsvcgssd a chance to open - * the init upcall channel, otherwise there's big chance that the first - * upcall issued before the channel be opened thus nfsv4 cache code will - * drop the request direclty, thus lead to unnecessary recovery time. - * here we wait at maximum 1.5 seconds. */ - for (i = 0; i < 6; i++) { - if (atomic_read(&rsi_cache.readers) > 0) - break; - set_current_state(TASK_UNINTERRUPTIBLE); - LASSERT(HZ >= 4); - schedule_timeout(HZ / 4); - } - - if (atomic_read(&rsi_cache.readers) == 0) - CWARN("Init channel is not opened by lsvcgssd, following " - "request might be dropped until lsvcgssd is active\n"); - - return 0; -} - -void __exit gss_exit_svc_upcall(void) -{ - cache_purge(&rsi_cache); - cache_unregister(&rsi_cache); - - cache_purge(&rsc_cache); - cache_unregister(&rsc_cache); -} diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/lproc_gss.c b/drivers/staging/lustre/lustre/ptlrpc/gss/lproc_gss.c deleted file mode 100644 index a0a74e5542ed..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/lproc_gss.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#define DEBUG_SUBSYSTEM S_SEC -#include <linux/module.h> -#include <linux/slab.h> -#include <linux/dcache.h> -#include <linux/fs.h> -#include <linux/mutex.h> - -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre/lustre_idl.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lprocfs_status.h> -#include <lustre_sec.h> - -#include "gss_err.h" -#include "gss_internal.h" -#include "gss_api.h" - -static struct proc_dir_entry *gss_proc_root = NULL; -static struct proc_dir_entry *gss_proc_lk = NULL; - -/* - * statistic of "out-of-sequence-window" - */ -static struct { - spinlock_t oos_lock; - atomic_t oos_cli_count; /* client occurrence */ - int oos_cli_behind; /* client max seqs behind */ - atomic_t oos_svc_replay[3]; /* server replay detected */ - atomic_t oos_svc_pass[3]; /* server verified ok */ -} gss_stat_oos = { - .oos_cli_count = ATOMIC_INIT(0), - .oos_cli_behind = 0, - .oos_svc_replay = { ATOMIC_INIT(0), }, - .oos_svc_pass = { ATOMIC_INIT(0), }, -}; - -void gss_stat_oos_record_cli(int behind) -{ - atomic_inc(&gss_stat_oos.oos_cli_count); - - spin_lock(&gss_stat_oos.oos_lock); - if (behind > gss_stat_oos.oos_cli_behind) - gss_stat_oos.oos_cli_behind = behind; - spin_unlock(&gss_stat_oos.oos_lock); -} - -void gss_stat_oos_record_svc(int phase, int replay) -{ - LASSERT(phase >= 0 && phase <= 2); - - if (replay) - atomic_inc(&gss_stat_oos.oos_svc_replay[phase]); - else - atomic_inc(&gss_stat_oos.oos_svc_pass[phase]); -} - -static int gss_proc_oos_seq_show(struct seq_file *m, void *v) -{ - return seq_printf(m, - "seqwin: %u\n" - "backwin: %u\n" - "client fall behind seqwin\n" - " occurrence: %d\n" - " max seq behind: %d\n" - "server replay detected:\n" - " phase 0: %d\n" - " phase 1: %d\n" - " phase 2: %d\n" - "server verify ok:\n" - " phase 2: %d\n", - GSS_SEQ_WIN_MAIN, - GSS_SEQ_WIN_BACK, - atomic_read(&gss_stat_oos.oos_cli_count), - gss_stat_oos.oos_cli_behind, - atomic_read(&gss_stat_oos.oos_svc_replay[0]), - atomic_read(&gss_stat_oos.oos_svc_replay[1]), - atomic_read(&gss_stat_oos.oos_svc_replay[2]), - atomic_read(&gss_stat_oos.oos_svc_pass[2])); -} -LPROC_SEQ_FOPS_RO(gss_proc_oos); - -static int gss_proc_write_secinit(struct file *file, const char *buffer, - size_t count, off_t *off) -{ - int rc; - - rc = gss_do_ctx_init_rpc((char *) buffer, count); - if (rc) { - LASSERT(rc < 0); - return rc; - } - - return count; -} - -static const struct file_operations gss_proc_secinit = { - .write = gss_proc_write_secinit, -}; - -static struct lprocfs_vars gss_lprocfs_vars[] = { - { "replays", &gss_proc_oos_fops }, - { "init_channel", &gss_proc_secinit, NULL, 0222 }, - { NULL } -}; - -/* - * for userspace helper lgss_keyring. - * - * debug_level: [0, 4], defined in utils/gss/lgss_utils.h - */ -static int gss_lk_debug_level = 1; - -static int gss_lk_proc_dl_seq_show(struct seq_file *m, void *v) -{ - return seq_printf(m, "%u\n", gss_lk_debug_level); -} - -static int gss_lk_proc_dl_seq_write(struct file *file, const char *buffer, - size_t count, off_t *off) -{ - int val, rc; - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc < 0) - return rc; - - if (val < 0 || val > 4) - return -ERANGE; - - gss_lk_debug_level = val; - return count; -} -LPROC_SEQ_FOPS(gss_lk_proc_dl); - -static struct lprocfs_vars gss_lk_lprocfs_vars[] = { - { "debug_level", &gss_lk_proc_dl_fops }, - { NULL } -}; - -void gss_exit_lproc(void) -{ - if (gss_proc_lk) { - lprocfs_remove(&gss_proc_lk); - gss_proc_lk = NULL; - } - - if (gss_proc_root) { - lprocfs_remove(&gss_proc_root); - gss_proc_root = NULL; - } -} - -int gss_init_lproc(void) -{ - int rc; - - spin_lock_init(&gss_stat_oos.oos_lock); - - gss_proc_root = lprocfs_register("gss", sptlrpc_proc_root, - gss_lprocfs_vars, NULL); - if (IS_ERR(gss_proc_root)) { - rc = PTR_ERR(gss_proc_root); - gss_proc_root = NULL; - GOTO(err_out, rc); - } - - gss_proc_lk = lprocfs_register("lgss_keyring", gss_proc_root, - gss_lk_lprocfs_vars, NULL); - if (IS_ERR(gss_proc_lk)) { - rc = PTR_ERR(gss_proc_lk); - gss_proc_lk = NULL; - GOTO(err_out, rc); - } - - return 0; - -err_out: - CERROR("failed to initialize gss lproc entries: %d\n", rc); - gss_exit_lproc(); - return rc; -} diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c deleted file mode 100644 index 383601cdd4e6..000000000000 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c +++ /dev/null @@ -1,2889 +0,0 @@ -/* - * Modifications for Lustre - * - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * - * Copyright (c) 2011, 2012, Intel Corporation. - * - * Author: Eric Mei <ericm@clusterfs.com> - */ - -/* - * linux/net/sunrpc/auth_gss.c - * - * RPCSEC_GSS client authentication. - * - * Copyright (c) 2000 The Regents of the University of Michigan. - * All rights reserved. - * - * Dug Song <dugsong@monkey.org> - * Andy Adamson <andros@umich.edu> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define DEBUG_SUBSYSTEM S_SEC -#include <linux/init.h> -#include <linux/module.h> -#include <linux/slab.h> -#include <linux/dcache.h> -#include <linux/fs.h> -#include <linux/mutex.h> -#include <asm/atomic.h> - -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <obd_cksum.h> -#include <lustre/lustre_idl.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_sec.h> - -#include "gss_err.h" -#include "gss_internal.h" -#include "gss_api.h" - -#include <linux/crypto.h> -#include <linux/crc32.h> - -/* - * early reply have fixed size, respectively in privacy and integrity mode. - * so we calculate them only once. - */ -static int gss_at_reply_off_integ; -static int gss_at_reply_off_priv; - - -static inline int msg_last_segidx(struct lustre_msg *msg) -{ - LASSERT(msg->lm_bufcount > 0); - return msg->lm_bufcount - 1; -} -static inline int msg_last_seglen(struct lustre_msg *msg) -{ - return msg->lm_buflens[msg_last_segidx(msg)]; -} - -/******************************************** - * wire data swabber * - ********************************************/ - -static -void gss_header_swabber(struct gss_header *ghdr) -{ - __swab32s(&ghdr->gh_flags); - __swab32s(&ghdr->gh_proc); - __swab32s(&ghdr->gh_seq); - __swab32s(&ghdr->gh_svc); - __swab32s(&ghdr->gh_pad1); - __swab32s(&ghdr->gh_handle.len); -} - -struct gss_header *gss_swab_header(struct lustre_msg *msg, int segment, - int swabbed) -{ - struct gss_header *ghdr; - - ghdr = lustre_msg_buf(msg, segment, sizeof(*ghdr)); - if (ghdr == NULL) - return NULL; - - if (swabbed) - gss_header_swabber(ghdr); - - if (sizeof(*ghdr) + ghdr->gh_handle.len > msg->lm_buflens[segment]) { - CERROR("gss header has length %d, now %u received\n", - (int) sizeof(*ghdr) + ghdr->gh_handle.len, - msg->lm_buflens[segment]); - return NULL; - } - - return ghdr; -} - -#if 0 -static -void gss_netobj_swabber(netobj_t *obj) -{ - __swab32s(&obj->len); -} - -netobj_t *gss_swab_netobj(struct lustre_msg *msg, int segment) -{ - netobj_t *obj; - - obj = lustre_swab_buf(msg, segment, sizeof(*obj), gss_netobj_swabber); - if (obj && sizeof(*obj) + obj->len > msg->lm_buflens[segment]) { - CERROR("netobj require length %u but only %u received\n", - (unsigned int) sizeof(*obj) + obj->len, - msg->lm_buflens[segment]); - return NULL; - } - - return obj; -} -#endif - -/* - * payload should be obtained from mechanism. but currently since we - * only support kerberos, we could simply use fixed value. - * krb5 "meta" data: - * - krb5 header: 16 - * - krb5 checksum: 20 - * - * for privacy mode, payload also include the cipher text which has the same - * size as plain text, plus possible confounder, padding both at maximum cipher - * block size. - */ -#define GSS_KRB5_INTEG_MAX_PAYLOAD (40) - -static inline -int gss_mech_payload(struct gss_ctx *mechctx, int msgsize, int privacy) -{ - if (privacy) - return GSS_KRB5_INTEG_MAX_PAYLOAD + 16 + 16 + 16 + msgsize; - else - return GSS_KRB5_INTEG_MAX_PAYLOAD; -} - -/* - * return signature size, otherwise < 0 to indicate error - */ -static int gss_sign_msg(struct lustre_msg *msg, - struct gss_ctx *mechctx, - enum lustre_sec_part sp, - __u32 flags, __u32 proc, __u32 seq, __u32 svc, - rawobj_t *handle) -{ - struct gss_header *ghdr; - rawobj_t text[4], mic; - int textcnt, max_textcnt, mic_idx; - __u32 major; - - LASSERT(msg->lm_bufcount >= 2); - - /* gss hdr */ - LASSERT(msg->lm_buflens[0] >= - sizeof(*ghdr) + (handle ? handle->len : 0)); - ghdr = lustre_msg_buf(msg, 0, 0); - - ghdr->gh_version = PTLRPC_GSS_VERSION; - ghdr->gh_sp = (__u8) sp; - ghdr->gh_flags = flags; - ghdr->gh_proc = proc; - ghdr->gh_seq = seq; - ghdr->gh_svc = svc; - if (!handle) { - /* fill in a fake one */ - ghdr->gh_handle.len = 0; - } else { - ghdr->gh_handle.len = handle->len; - memcpy(ghdr->gh_handle.data, handle->data, handle->len); - } - - /* no actual signature for null mode */ - if (svc == SPTLRPC_SVC_NULL) - return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens); - - /* MIC */ - mic_idx = msg_last_segidx(msg); - max_textcnt = (svc == SPTLRPC_SVC_AUTH) ? 1 : mic_idx; - - for (textcnt = 0; textcnt < max_textcnt; textcnt++) { - text[textcnt].len = msg->lm_buflens[textcnt]; - text[textcnt].data = lustre_msg_buf(msg, textcnt, 0); - } - - mic.len = msg->lm_buflens[mic_idx]; - mic.data = lustre_msg_buf(msg, mic_idx, 0); - - major = lgss_get_mic(mechctx, textcnt, text, 0, NULL, &mic); - if (major != GSS_S_COMPLETE) { - CERROR("fail to generate MIC: %08x\n", major); - return -EPERM; - } - LASSERT(mic.len <= msg->lm_buflens[mic_idx]); - - return lustre_shrink_msg(msg, mic_idx, mic.len, 0); -} - -/* - * return gss error - */ -static -__u32 gss_verify_msg(struct lustre_msg *msg, - struct gss_ctx *mechctx, - __u32 svc) -{ - rawobj_t text[4], mic; - int textcnt, max_textcnt; - int mic_idx; - __u32 major; - - LASSERT(msg->lm_bufcount >= 2); - - if (svc == SPTLRPC_SVC_NULL) - return GSS_S_COMPLETE; - - mic_idx = msg_last_segidx(msg); - max_textcnt = (svc == SPTLRPC_SVC_AUTH) ? 1 : mic_idx; - - for (textcnt = 0; textcnt < max_textcnt; textcnt++) { - text[textcnt].len = msg->lm_buflens[textcnt]; - text[textcnt].data = lustre_msg_buf(msg, textcnt, 0); - } - - mic.len = msg->lm_buflens[mic_idx]; - mic.data = lustre_msg_buf(msg, mic_idx, 0); - - major = lgss_verify_mic(mechctx, textcnt, text, 0, NULL, &mic); - if (major != GSS_S_COMPLETE) - CERROR("mic verify error: %08x\n", major); - - return major; -} - -/* - * return gss error code - */ -static -__u32 gss_unseal_msg(struct gss_ctx *mechctx, - struct lustre_msg *msgbuf, - int *msg_len, int msgbuf_len) -{ - rawobj_t clear_obj, hdrobj, token; - __u8 *clear_buf; - int clear_buflen; - __u32 major; - - if (msgbuf->lm_bufcount != 2) { - CERROR("invalid bufcount %d\n", msgbuf->lm_bufcount); - return GSS_S_FAILURE; - } - - /* allocate a temporary clear text buffer, same sized as token, - * we assume the final clear text size <= token size */ - clear_buflen = lustre_msg_buflen(msgbuf, 1); - OBD_ALLOC_LARGE(clear_buf, clear_buflen); - if (!clear_buf) - return GSS_S_FAILURE; - - /* buffer objects */ - hdrobj.len = lustre_msg_buflen(msgbuf, 0); - hdrobj.data = lustre_msg_buf(msgbuf, 0, 0); - token.len = lustre_msg_buflen(msgbuf, 1); - token.data = lustre_msg_buf(msgbuf, 1, 0); - clear_obj.len = clear_buflen; - clear_obj.data = clear_buf; - - major = lgss_unwrap(mechctx, &hdrobj, &token, &clear_obj); - if (major != GSS_S_COMPLETE) { - CERROR("unwrap message error: %08x\n", major); - GOTO(out_free, major = GSS_S_FAILURE); - } - LASSERT(clear_obj.len <= clear_buflen); - LASSERT(clear_obj.len <= msgbuf_len); - - /* now the decrypted message */ - memcpy(msgbuf, clear_obj.data, clear_obj.len); - *msg_len = clear_obj.len; - - major = GSS_S_COMPLETE; -out_free: - OBD_FREE_LARGE(clear_buf, clear_buflen); - return major; -} - -/******************************************** - * gss client context manipulation helpers * - ********************************************/ - -int cli_ctx_expire(struct ptlrpc_cli_ctx *ctx) -{ - LASSERT(atomic_read(&ctx->cc_refcount)); - - if (!test_and_set_bit(PTLRPC_CTX_DEAD_BIT, &ctx->cc_flags)) { - if (!ctx->cc_early_expire) - clear_bit(PTLRPC_CTX_UPTODATE_BIT, &ctx->cc_flags); - - CWARN("ctx %p(%u->%s) get expired: %lu(%+lds)\n", - ctx, ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec), - ctx->cc_expire, - ctx->cc_expire == 0 ? 0 : - cfs_time_sub(ctx->cc_expire, cfs_time_current_sec())); - - sptlrpc_cli_ctx_wakeup(ctx); - return 1; - } - - return 0; -} - -/* - * return 1 if the context is dead. - */ -int cli_ctx_check_death(struct ptlrpc_cli_ctx *ctx) -{ - if (unlikely(cli_ctx_is_dead(ctx))) - return 1; - - /* expire is 0 means never expire. a newly created gss context - * which during upcall may has 0 expiration */ - if (ctx->cc_expire == 0) - return 0; - - /* check real expiration */ - if (cfs_time_after(ctx->cc_expire, cfs_time_current_sec())) - return 0; - - cli_ctx_expire(ctx); - return 1; -} - -void gss_cli_ctx_uptodate(struct gss_cli_ctx *gctx) -{ - struct ptlrpc_cli_ctx *ctx = &gctx->gc_base; - unsigned long ctx_expiry; - - if (lgss_inquire_context(gctx->gc_mechctx, &ctx_expiry)) { - CERROR("ctx %p(%u): unable to inquire, expire it now\n", - gctx, ctx->cc_vcred.vc_uid); - ctx_expiry = 1; /* make it expired now */ - } - - ctx->cc_expire = gss_round_ctx_expiry(ctx_expiry, - ctx->cc_sec->ps_flvr.sf_flags); - - /* At this point this ctx might have been marked as dead by - * someone else, in which case nobody will make further use - * of it. we don't care, and mark it UPTODATE will help - * destroying server side context when it be destroyed. */ - set_bit(PTLRPC_CTX_UPTODATE_BIT, &ctx->cc_flags); - - if (sec_is_reverse(ctx->cc_sec)) { - CWARN("server installed reverse ctx %p idx "LPX64", " - "expiry %lu(%+lds)\n", ctx, - gss_handle_to_u64(&gctx->gc_handle), - ctx->cc_expire, ctx->cc_expire - cfs_time_current_sec()); - } else { - CWARN("client refreshed ctx %p idx "LPX64" (%u->%s), " - "expiry %lu(%+lds)\n", ctx, - gss_handle_to_u64(&gctx->gc_handle), - ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec), - ctx->cc_expire, ctx->cc_expire - cfs_time_current_sec()); - - /* install reverse svc ctx for root context */ - if (ctx->cc_vcred.vc_uid == 0) - gss_sec_install_rctx(ctx->cc_sec->ps_import, - ctx->cc_sec, ctx); - } - - sptlrpc_cli_ctx_wakeup(ctx); -} - -static void gss_cli_ctx_finalize(struct gss_cli_ctx *gctx) -{ - LASSERT(gctx->gc_base.cc_sec); - - if (gctx->gc_mechctx) { - lgss_delete_sec_context(&gctx->gc_mechctx); - gctx->gc_mechctx = NULL; - } - - if (!rawobj_empty(&gctx->gc_svc_handle)) { - /* forward ctx: mark buddy reverse svcctx soon-expire. */ - if (!sec_is_reverse(gctx->gc_base.cc_sec) && - !rawobj_empty(&gctx->gc_svc_handle)) - gss_svc_upcall_expire_rvs_ctx(&gctx->gc_svc_handle); - - rawobj_free(&gctx->gc_svc_handle); - } - - rawobj_free(&gctx->gc_handle); -} - -/* - * Based on sequence number algorithm as specified in RFC 2203. - * - * modified for our own problem: arriving request has valid sequence number, - * but unwrapping request might cost a long time, after that its sequence - * are not valid anymore (fall behind the window). It rarely happen, mostly - * under extreme load. - * - * note we should not check sequence before verify the integrity of incoming - * request, because just one attacking request with high sequence number might - * cause all following request be dropped. - * - * so here we use a multi-phase approach: prepare 2 sequence windows, - * "main window" for normal sequence and "back window" for fall behind sequence. - * and 3-phase checking mechanism: - * 0 - before integrity verification, perform a initial sequence checking in - * main window, which only try and don't actually set any bits. if the - * sequence is high above the window or fit in the window and the bit - * is 0, then accept and proceed to integrity verification. otherwise - * reject this sequence. - * 1 - after integrity verification, check in main window again. if this - * sequence is high above the window or fit in the window and the bit - * is 0, then set the bit and accept; if it fit in the window but bit - * already set, then reject; if it fall behind the window, then proceed - * to phase 2. - * 2 - check in back window. if it is high above the window or fit in the - * window and the bit is 0, then set the bit and accept. otherwise reject. - * - * return value: - * 1: looks like a replay - * 0: is ok - * -1: is a replay - * - * note phase 0 is necessary, because otherwise replay attacking request of - * sequence which between the 2 windows can't be detected. - * - * this mechanism can't totally solve the problem, but could help much less - * number of valid requests be dropped. - */ -static -int gss_do_check_seq(unsigned long *window, __u32 win_size, __u32 *max_seq, - __u32 seq_num, int phase) -{ - LASSERT(phase >= 0 && phase <= 2); - - if (seq_num > *max_seq) { - /* - * 1. high above the window - */ - if (phase == 0) - return 0; - - if (seq_num >= *max_seq + win_size) { - memset(window, 0, win_size / 8); - *max_seq = seq_num; - } else { - while (*max_seq < seq_num) { - (*max_seq)++; - __clear_bit((*max_seq) % win_size, window); - } - } - __set_bit(seq_num % win_size, window); - } else if (seq_num + win_size <= *max_seq) { - /* - * 2. low behind the window - */ - if (phase == 0 || phase == 2) - goto replay; - - CWARN("seq %u is %u behind (size %d), check backup window\n", - seq_num, *max_seq - win_size - seq_num, win_size); - return 1; - } else { - /* - * 3. fit into the window - */ - switch (phase) { - case 0: - if (test_bit(seq_num % win_size, window)) - goto replay; - break; - case 1: - case 2: - if (__test_and_set_bit(seq_num % win_size, window)) - goto replay; - break; - } - } - - return 0; - -replay: - CERROR("seq %u (%s %s window) is a replay: max %u, winsize %d\n", - seq_num, - seq_num + win_size > *max_seq ? "in" : "behind", - phase == 2 ? "backup " : "main", - *max_seq, win_size); - return -1; -} - -/* - * Based on sequence number algorithm as specified in RFC 2203. - * - * if @set == 0: initial check, don't set any bit in window - * if @sec == 1: final check, set bit in window - */ -int gss_check_seq_num(struct gss_svc_seq_data *ssd, __u32 seq_num, int set) -{ - int rc = 0; - - spin_lock(&ssd->ssd_lock); - - if (set == 0) { - /* - * phase 0 testing - */ - rc = gss_do_check_seq(ssd->ssd_win_main, GSS_SEQ_WIN_MAIN, - &ssd->ssd_max_main, seq_num, 0); - if (unlikely(rc)) - gss_stat_oos_record_svc(0, 1); - } else { - /* - * phase 1 checking main window - */ - rc = gss_do_check_seq(ssd->ssd_win_main, GSS_SEQ_WIN_MAIN, - &ssd->ssd_max_main, seq_num, 1); - switch (rc) { - case -1: - gss_stat_oos_record_svc(1, 1); - /* fall through */ - case 0: - goto exit; - } - /* - * phase 2 checking back window - */ - rc = gss_do_check_seq(ssd->ssd_win_back, GSS_SEQ_WIN_BACK, - &ssd->ssd_max_back, seq_num, 2); - if (rc) - gss_stat_oos_record_svc(2, 1); - else - gss_stat_oos_record_svc(2, 0); - } -exit: - spin_unlock(&ssd->ssd_lock); - return rc; -} - -/*************************************** - * cred APIs * - ***************************************/ - -static inline int gss_cli_payload(struct ptlrpc_cli_ctx *ctx, - int msgsize, int privacy) -{ - return gss_mech_payload(NULL, msgsize, privacy); -} - -static int gss_cli_bulk_payload(struct ptlrpc_cli_ctx *ctx, - struct sptlrpc_flavor *flvr, - int reply, int read) -{ - int payload = sizeof(struct ptlrpc_bulk_sec_desc); - - LASSERT(SPTLRPC_FLVR_BULK_TYPE(flvr->sf_rpc) == SPTLRPC_BULK_DEFAULT); - - if ((!reply && !read) || (reply && read)) { - switch (SPTLRPC_FLVR_BULK_SVC(flvr->sf_rpc)) { - case SPTLRPC_BULK_SVC_NULL: - break; - case SPTLRPC_BULK_SVC_INTG: - payload += gss_cli_payload(ctx, 0, 0); - break; - case SPTLRPC_BULK_SVC_PRIV: - payload += gss_cli_payload(ctx, 0, 1); - break; - case SPTLRPC_BULK_SVC_AUTH: - default: - LBUG(); - } - } - - return payload; -} - -int gss_cli_ctx_match(struct ptlrpc_cli_ctx *ctx, struct vfs_cred *vcred) -{ - return (ctx->cc_vcred.vc_uid == vcred->vc_uid); -} - -void gss_cli_ctx_flags2str(unsigned long flags, char *buf, int bufsize) -{ - buf[0] = '\0'; - - if (flags & PTLRPC_CTX_NEW) - strncat(buf, "new,", bufsize); - if (flags & PTLRPC_CTX_UPTODATE) - strncat(buf, "uptodate,", bufsize); - if (flags & PTLRPC_CTX_DEAD) - strncat(buf, "dead,", bufsize); - if (flags & PTLRPC_CTX_ERROR) - strncat(buf, "error,", bufsize); - if (flags & PTLRPC_CTX_CACHED) - strncat(buf, "cached,", bufsize); - if (flags & PTLRPC_CTX_ETERNAL) - strncat(buf, "eternal,", bufsize); - if (buf[0] == '\0') - strncat(buf, "-,", bufsize); - - buf[strlen(buf) - 1] = '\0'; -} - -int gss_cli_ctx_sign(struct ptlrpc_cli_ctx *ctx, - struct ptlrpc_request *req) -{ - struct gss_cli_ctx *gctx = ctx2gctx(ctx); - __u32 flags = 0, seq, svc; - int rc; - - LASSERT(req->rq_reqbuf); - LASSERT(req->rq_reqbuf->lm_bufcount >= 2); - LASSERT(req->rq_cli_ctx == ctx); - - /* nothing to do for context negotiation RPCs */ - if (req->rq_ctx_init) - return 0; - - svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc); - if (req->rq_pack_bulk) - flags |= LUSTRE_GSS_PACK_BULK; - if (req->rq_pack_udesc) - flags |= LUSTRE_GSS_PACK_USER; - -redo: - seq = atomic_inc_return(&gctx->gc_seq); - - rc = gss_sign_msg(req->rq_reqbuf, gctx->gc_mechctx, - ctx->cc_sec->ps_part, - flags, gctx->gc_proc, seq, svc, - &gctx->gc_handle); - if (rc < 0) - return rc; - - /* gss_sign_msg() msg might take long time to finish, in which period - * more rpcs could be wrapped up and sent out. if we found too many - * of them we should repack this rpc, because sent it too late might - * lead to the sequence number fall behind the window on server and - * be dropped. also applies to gss_cli_ctx_seal(). - * - * Note: null mode doesn't check sequence number. */ - if (svc != SPTLRPC_SVC_NULL && - atomic_read(&gctx->gc_seq) - seq > GSS_SEQ_REPACK_THRESHOLD) { - int behind = atomic_read(&gctx->gc_seq) - seq; - - gss_stat_oos_record_cli(behind); - CWARN("req %p: %u behind, retry signing\n", req, behind); - goto redo; - } - - req->rq_reqdata_len = rc; - return 0; -} - -static -int gss_cli_ctx_handle_err_notify(struct ptlrpc_cli_ctx *ctx, - struct ptlrpc_request *req, - struct gss_header *ghdr) -{ - struct gss_err_header *errhdr; - int rc; - - LASSERT(ghdr->gh_proc == PTLRPC_GSS_PROC_ERR); - - errhdr = (struct gss_err_header *) ghdr; - - CWARN("req x"LPU64"/t"LPU64", ctx %p idx "LPX64"(%u->%s): " - "%sserver respond (%08x/%08x)\n", - req->rq_xid, req->rq_transno, ctx, - gss_handle_to_u64(&ctx2gctx(ctx)->gc_handle), - ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec), - sec_is_reverse(ctx->cc_sec) ? "reverse" : "", - errhdr->gh_major, errhdr->gh_minor); - - /* context fini rpc, let it failed */ - if (req->rq_ctx_fini) { - CWARN("context fini rpc failed\n"); - return -EINVAL; - } - - /* reverse sec, just return error, don't expire this ctx because it's - * crucial to callback rpcs. note if the callback rpc failed because - * of bit flip during network transfer, the client will be evicted - * directly. so more gracefully we probably want let it retry for - * number of times. */ - if (sec_is_reverse(ctx->cc_sec)) - return -EINVAL; - - if (errhdr->gh_major != GSS_S_NO_CONTEXT && - errhdr->gh_major != GSS_S_BAD_SIG) - return -EACCES; - - /* server return NO_CONTEXT might be caused by context expire - * or server reboot/failover. we try to refresh a new ctx which - * be transparent to upper layer. - * - * In some cases, our gss handle is possible to be incidentally - * identical to another handle since the handle itself is not - * fully random. In krb5 case, the GSS_S_BAD_SIG will be - * returned, maybe other gss error for other mechanism. - * - * if we add new mechanism, make sure the correct error are - * returned in this case. */ - CWARN("%s: server might lost the context, retrying\n", - errhdr->gh_major == GSS_S_NO_CONTEXT ? "NO_CONTEXT" : "BAD_SIG"); - - sptlrpc_cli_ctx_expire(ctx); - - /* we need replace the ctx right here, otherwise during - * resent we'll hit the logic in sptlrpc_req_refresh_ctx() - * which keep the ctx with RESEND flag, thus we'll never - * get rid of this ctx. */ - rc = sptlrpc_req_replace_dead_ctx(req); - if (rc == 0) - req->rq_resend = 1; - - return rc; -} - -int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, - struct ptlrpc_request *req) -{ - struct gss_cli_ctx *gctx; - struct gss_header *ghdr, *reqhdr; - struct lustre_msg *msg = req->rq_repdata; - __u32 major; - int pack_bulk, swabbed, rc = 0; - - LASSERT(req->rq_cli_ctx == ctx); - LASSERT(msg); - - gctx = container_of(ctx, struct gss_cli_ctx, gc_base); - - /* special case for context negotiation, rq_repmsg/rq_replen actually - * are not used currently. but early reply always be treated normally */ - if (req->rq_ctx_init && !req->rq_early) { - req->rq_repmsg = lustre_msg_buf(msg, 1, 0); - req->rq_replen = msg->lm_buflens[1]; - return 0; - } - - if (msg->lm_bufcount < 2 || msg->lm_bufcount > 4) { - CERROR("unexpected bufcount %u\n", msg->lm_bufcount); - return -EPROTO; - } - - swabbed = ptlrpc_rep_need_swab(req); - - ghdr = gss_swab_header(msg, 0, swabbed); - if (ghdr == NULL) { - CERROR("can't decode gss header\n"); - return -EPROTO; - } - - /* sanity checks */ - reqhdr = lustre_msg_buf(msg, 0, sizeof(*reqhdr)); - LASSERT(reqhdr); - - if (ghdr->gh_version != reqhdr->gh_version) { - CERROR("gss version %u mismatch, expect %u\n", - ghdr->gh_version, reqhdr->gh_version); - return -EPROTO; - } - - switch (ghdr->gh_proc) { - case PTLRPC_GSS_PROC_DATA: - pack_bulk = ghdr->gh_flags & LUSTRE_GSS_PACK_BULK; - - if (!req->rq_early && - !equi(req->rq_pack_bulk == 1, pack_bulk)) { - CERROR("%s bulk flag in reply\n", - req->rq_pack_bulk ? "missing" : "unexpected"); - return -EPROTO; - } - - if (ghdr->gh_seq != reqhdr->gh_seq) { - CERROR("seqnum %u mismatch, expect %u\n", - ghdr->gh_seq, reqhdr->gh_seq); - return -EPROTO; - } - - if (ghdr->gh_svc != reqhdr->gh_svc) { - CERROR("svc %u mismatch, expect %u\n", - ghdr->gh_svc, reqhdr->gh_svc); - return -EPROTO; - } - - if (swabbed) - gss_header_swabber(ghdr); - - major = gss_verify_msg(msg, gctx->gc_mechctx, reqhdr->gh_svc); - if (major != GSS_S_COMPLETE) { - CERROR("failed to verify reply: %x\n", major); - return -EPERM; - } - - if (req->rq_early && reqhdr->gh_svc == SPTLRPC_SVC_NULL) { - __u32 cksum; - - cksum = crc32_le(!(__u32) 0, - lustre_msg_buf(msg, 1, 0), - lustre_msg_buflen(msg, 1)); - if (cksum != msg->lm_cksum) { - CWARN("early reply checksum mismatch: " - "%08x != %08x\n", cksum, msg->lm_cksum); - return -EPROTO; - } - } - - if (pack_bulk) { - /* bulk checksum is right after the lustre msg */ - if (msg->lm_bufcount < 3) { - CERROR("Invalid reply bufcount %u\n", - msg->lm_bufcount); - return -EPROTO; - } - - rc = bulk_sec_desc_unpack(msg, 2, swabbed); - if (rc) { - CERROR("unpack bulk desc: %d\n", rc); - return rc; - } - } - - req->rq_repmsg = lustre_msg_buf(msg, 1, 0); - req->rq_replen = msg->lm_buflens[1]; - break; - case PTLRPC_GSS_PROC_ERR: - if (req->rq_early) { - CERROR("server return error with early reply\n"); - rc = -EPROTO; - } else { - rc = gss_cli_ctx_handle_err_notify(ctx, req, ghdr); - } - break; - default: - CERROR("unknown gss proc %d\n", ghdr->gh_proc); - rc = -EPROTO; - } - - return rc; -} - -int gss_cli_ctx_seal(struct ptlrpc_cli_ctx *ctx, - struct ptlrpc_request *req) -{ - struct gss_cli_ctx *gctx; - rawobj_t hdrobj, msgobj, token; - struct gss_header *ghdr; - __u32 buflens[2], major; - int wiresize, rc; - - LASSERT(req->rq_clrbuf); - LASSERT(req->rq_cli_ctx == ctx); - LASSERT(req->rq_reqlen); - - gctx = container_of(ctx, struct gss_cli_ctx, gc_base); - - /* final clear data length */ - req->rq_clrdata_len = lustre_msg_size_v2(req->rq_clrbuf->lm_bufcount, - req->rq_clrbuf->lm_buflens); - - /* calculate wire data length */ - buflens[0] = PTLRPC_GSS_HEADER_SIZE; - buflens[1] = gss_cli_payload(&gctx->gc_base, req->rq_clrdata_len, 1); - wiresize = lustre_msg_size_v2(2, buflens); - - /* allocate wire buffer */ - if (req->rq_pool) { - /* pre-allocated */ - LASSERT(req->rq_reqbuf); - LASSERT(req->rq_reqbuf != req->rq_clrbuf); - LASSERT(req->rq_reqbuf_len >= wiresize); - } else { - OBD_ALLOC_LARGE(req->rq_reqbuf, wiresize); - if (!req->rq_reqbuf) - return -ENOMEM; - req->rq_reqbuf_len = wiresize; - } - - lustre_init_msg_v2(req->rq_reqbuf, 2, buflens, NULL); - req->rq_reqbuf->lm_secflvr = req->rq_flvr.sf_rpc; - - /* gss header */ - ghdr = lustre_msg_buf(req->rq_reqbuf, 0, 0); - ghdr->gh_version = PTLRPC_GSS_VERSION; - ghdr->gh_sp = (__u8) ctx->cc_sec->ps_part; - ghdr->gh_flags = 0; - ghdr->gh_proc = gctx->gc_proc; - ghdr->gh_svc = SPTLRPC_SVC_PRIV; - ghdr->gh_handle.len = gctx->gc_handle.len; - memcpy(ghdr->gh_handle.data, gctx->gc_handle.data, gctx->gc_handle.len); - if (req->rq_pack_bulk) - ghdr->gh_flags |= LUSTRE_GSS_PACK_BULK; - if (req->rq_pack_udesc) - ghdr->gh_flags |= LUSTRE_GSS_PACK_USER; - -redo: - ghdr->gh_seq = atomic_inc_return(&gctx->gc_seq); - - /* buffer objects */ - hdrobj.len = PTLRPC_GSS_HEADER_SIZE; - hdrobj.data = (__u8 *) ghdr; - msgobj.len = req->rq_clrdata_len; - msgobj.data = (__u8 *) req->rq_clrbuf; - token.len = lustre_msg_buflen(req->rq_reqbuf, 1); - token.data = lustre_msg_buf(req->rq_reqbuf, 1, 0); - - major = lgss_wrap(gctx->gc_mechctx, &hdrobj, &msgobj, - req->rq_clrbuf_len, &token); - if (major != GSS_S_COMPLETE) { - CERROR("priv: wrap message error: %08x\n", major); - GOTO(err_free, rc = -EPERM); - } - LASSERT(token.len <= buflens[1]); - - /* see explain in gss_cli_ctx_sign() */ - if (unlikely(atomic_read(&gctx->gc_seq) - ghdr->gh_seq > - GSS_SEQ_REPACK_THRESHOLD)) { - int behind = atomic_read(&gctx->gc_seq) - ghdr->gh_seq; - - gss_stat_oos_record_cli(behind); - CWARN("req %p: %u behind, retry sealing\n", req, behind); - - ghdr->gh_seq = atomic_inc_return(&gctx->gc_seq); - goto redo; - } - - /* now set the final wire data length */ - req->rq_reqdata_len = lustre_shrink_msg(req->rq_reqbuf, 1, token.len,0); - return 0; - -err_free: - if (!req->rq_pool) { - OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); - req->rq_reqbuf = NULL; - req->rq_reqbuf_len = 0; - } - return rc; -} - -int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, - struct ptlrpc_request *req) -{ - struct gss_cli_ctx *gctx; - struct gss_header *ghdr; - struct lustre_msg *msg = req->rq_repdata; - int msglen, pack_bulk, swabbed, rc; - __u32 major; - - LASSERT(req->rq_cli_ctx == ctx); - LASSERT(req->rq_ctx_init == 0); - LASSERT(msg); - - gctx = container_of(ctx, struct gss_cli_ctx, gc_base); - swabbed = ptlrpc_rep_need_swab(req); - - ghdr = gss_swab_header(msg, 0, swabbed); - if (ghdr == NULL) { - CERROR("can't decode gss header\n"); - return -EPROTO; - } - - /* sanity checks */ - if (ghdr->gh_version != PTLRPC_GSS_VERSION) { - CERROR("gss version %u mismatch, expect %u\n", - ghdr->gh_version, PTLRPC_GSS_VERSION); - return -EPROTO; - } - - switch (ghdr->gh_proc) { - case PTLRPC_GSS_PROC_DATA: - pack_bulk = ghdr->gh_flags & LUSTRE_GSS_PACK_BULK; - - if (!req->rq_early && - !equi(req->rq_pack_bulk == 1, pack_bulk)) { - CERROR("%s bulk flag in reply\n", - req->rq_pack_bulk ? "missing" : "unexpected"); - return -EPROTO; - } - - if (swabbed) - gss_header_swabber(ghdr); - - /* use rq_repdata_len as buffer size, which assume unseal - * doesn't need extra memory space. for precise control, we'd - * better calculate out actual buffer size as - * (repbuf_len - offset - repdata_len) */ - major = gss_unseal_msg(gctx->gc_mechctx, msg, - &msglen, req->rq_repdata_len); - if (major != GSS_S_COMPLETE) { - CERROR("failed to unwrap reply: %x\n", major); - rc = -EPERM; - break; - } - - swabbed = __lustre_unpack_msg(msg, msglen); - if (swabbed < 0) { - CERROR("Failed to unpack after decryption\n"); - return -EPROTO; - } - - if (msg->lm_bufcount < 1) { - CERROR("Invalid reply buffer: empty\n"); - return -EPROTO; - } - - if (pack_bulk) { - if (msg->lm_bufcount < 2) { - CERROR("bufcount %u: missing bulk sec desc\n", - msg->lm_bufcount); - return -EPROTO; - } - - /* bulk checksum is the last segment */ - if (bulk_sec_desc_unpack(msg, msg->lm_bufcount - 1, - swabbed)) - return -EPROTO; - } - - req->rq_repmsg = lustre_msg_buf(msg, 0, 0); - req->rq_replen = msg->lm_buflens[0]; - - rc = 0; - break; - case PTLRPC_GSS_PROC_ERR: - if (req->rq_early) { - CERROR("server return error with early reply\n"); - rc = -EPROTO; - } else { - rc = gss_cli_ctx_handle_err_notify(ctx, req, ghdr); - } - break; - default: - CERROR("unexpected proc %d\n", ghdr->gh_proc); - rc = -EPERM; - } - - return rc; -} - -/********************************************* - * reverse context installation * - *********************************************/ - -static inline -int gss_install_rvs_svc_ctx(struct obd_import *imp, - struct gss_sec *gsec, - struct gss_cli_ctx *gctx) -{ - return gss_svc_upcall_install_rvs_ctx(imp, gsec, gctx); -} - -/********************************************* - * GSS security APIs * - *********************************************/ -int gss_sec_create_common(struct gss_sec *gsec, - struct ptlrpc_sec_policy *policy, - struct obd_import *imp, - struct ptlrpc_svc_ctx *svcctx, - struct sptlrpc_flavor *sf) -{ - struct ptlrpc_sec *sec; - - LASSERT(imp); - LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_GSS); - - gsec->gs_mech = lgss_subflavor_to_mech( - SPTLRPC_FLVR_BASE_SUB(sf->sf_rpc)); - if (!gsec->gs_mech) { - CERROR("gss backend 0x%x not found\n", - SPTLRPC_FLVR_BASE_SUB(sf->sf_rpc)); - return -EOPNOTSUPP; - } - - spin_lock_init(&gsec->gs_lock); - gsec->gs_rvs_hdl = 0ULL; - - /* initialize upper ptlrpc_sec */ - sec = &gsec->gs_base; - sec->ps_policy = policy; - atomic_set(&sec->ps_refcount, 0); - atomic_set(&sec->ps_nctx, 0); - sec->ps_id = sptlrpc_get_next_secid(); - sec->ps_flvr = *sf; - sec->ps_import = class_import_get(imp); - spin_lock_init(&sec->ps_lock); - INIT_LIST_HEAD(&sec->ps_gc_list); - - if (!svcctx) { - sec->ps_gc_interval = GSS_GC_INTERVAL; - } else { - LASSERT(sec_is_reverse(sec)); - - /* never do gc on reverse sec */ - sec->ps_gc_interval = 0; - } - - if (SPTLRPC_FLVR_BULK_SVC(sec->ps_flvr.sf_rpc) == SPTLRPC_BULK_SVC_PRIV) - sptlrpc_enc_pool_add_user(); - - CDEBUG(D_SEC, "create %s%s@%p\n", (svcctx ? "reverse " : ""), - policy->sp_name, gsec); - return 0; -} - -void gss_sec_destroy_common(struct gss_sec *gsec) -{ - struct ptlrpc_sec *sec = &gsec->gs_base; - - LASSERT(sec->ps_import); - LASSERT(atomic_read(&sec->ps_refcount) == 0); - LASSERT(atomic_read(&sec->ps_nctx) == 0); - - if (gsec->gs_mech) { - lgss_mech_put(gsec->gs_mech); - gsec->gs_mech = NULL; - } - - class_import_put(sec->ps_import); - - if (SPTLRPC_FLVR_BULK_SVC(sec->ps_flvr.sf_rpc) == SPTLRPC_BULK_SVC_PRIV) - sptlrpc_enc_pool_del_user(); -} - -void gss_sec_kill(struct ptlrpc_sec *sec) -{ - sec->ps_dying = 1; -} - -int gss_cli_ctx_init_common(struct ptlrpc_sec *sec, - struct ptlrpc_cli_ctx *ctx, - struct ptlrpc_ctx_ops *ctxops, - struct vfs_cred *vcred) -{ - struct gss_cli_ctx *gctx = ctx2gctx(ctx); - - gctx->gc_win = 0; - atomic_set(&gctx->gc_seq, 0); - - INIT_HLIST_NODE(&ctx->cc_cache); - atomic_set(&ctx->cc_refcount, 0); - ctx->cc_sec = sec; - ctx->cc_ops = ctxops; - ctx->cc_expire = 0; - ctx->cc_flags = PTLRPC_CTX_NEW; - ctx->cc_vcred = *vcred; - spin_lock_init(&ctx->cc_lock); - INIT_LIST_HEAD(&ctx->cc_req_list); - INIT_LIST_HEAD(&ctx->cc_gc_chain); - - /* take a ref on belonging sec, balanced in ctx destroying */ - atomic_inc(&sec->ps_refcount); - /* statistic only */ - atomic_inc(&sec->ps_nctx); - - CDEBUG(D_SEC, "%s@%p: create ctx %p(%u->%s)\n", - sec->ps_policy->sp_name, ctx->cc_sec, - ctx, ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec)); - return 0; -} - -/* - * return value: - * 1: the context has been taken care of by someone else - * 0: proceed to really destroy the context locally - */ -int gss_cli_ctx_fini_common(struct ptlrpc_sec *sec, - struct ptlrpc_cli_ctx *ctx) -{ - struct gss_cli_ctx *gctx = ctx2gctx(ctx); - - LASSERT(atomic_read(&sec->ps_nctx) > 0); - LASSERT(atomic_read(&ctx->cc_refcount) == 0); - LASSERT(ctx->cc_sec == sec); - - /* - * remove UPTODATE flag of reverse ctx thus we won't send fini rpc, - * this is to avoid potential problems of client side reverse svc ctx - * be mis-destroyed in various recovery scenarios. anyway client can - * manage its reverse ctx well by associating it with its buddy ctx. - */ - if (sec_is_reverse(sec)) - ctx->cc_flags &= ~PTLRPC_CTX_UPTODATE; - - if (gctx->gc_mechctx) { - /* the final context fini rpc will use this ctx too, and it's - * asynchronous which finished by request_out_callback(). so - * we add refcount, whoever drop finally drop the refcount to - * 0 should responsible for the rest of destroy. */ - atomic_inc(&ctx->cc_refcount); - - gss_do_ctx_fini_rpc(gctx); - gss_cli_ctx_finalize(gctx); - - if (!atomic_dec_and_test(&ctx->cc_refcount)) - return 1; - } - - if (sec_is_reverse(sec)) - CWARN("reverse sec %p: destroy ctx %p\n", - ctx->cc_sec, ctx); - else - CWARN("%s@%p: destroy ctx %p(%u->%s)\n", - sec->ps_policy->sp_name, ctx->cc_sec, - ctx, ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec)); - - return 0; -} - -static -int gss_alloc_reqbuf_intg(struct ptlrpc_sec *sec, - struct ptlrpc_request *req, - int svc, int msgsize) -{ - int bufsize, txtsize; - int bufcnt = 2; - __u32 buflens[5]; - - /* - * on-wire data layout: - * - gss header - * - lustre message - * - user descriptor (optional) - * - bulk sec descriptor (optional) - * - signature (optional) - * - svc == NULL: NULL - * - svc == AUTH: signature of gss header - * - svc == INTG: signature of all above - * - * if this is context negotiation, reserver fixed space - * at the last (signature) segment regardless of svc mode. - */ - - buflens[0] = PTLRPC_GSS_HEADER_SIZE; - txtsize = buflens[0]; - - buflens[1] = msgsize; - if (svc == SPTLRPC_SVC_INTG) - txtsize += buflens[1]; - - if (req->rq_pack_udesc) { - buflens[bufcnt] = sptlrpc_current_user_desc_size(); - if (svc == SPTLRPC_SVC_INTG) - txtsize += buflens[bufcnt]; - bufcnt++; - } - - if (req->rq_pack_bulk) { - buflens[bufcnt] = gss_cli_bulk_payload(req->rq_cli_ctx, - &req->rq_flvr, - 0, req->rq_bulk_read); - if (svc == SPTLRPC_SVC_INTG) - txtsize += buflens[bufcnt]; - bufcnt++; - } - - if (req->rq_ctx_init) - buflens[bufcnt++] = GSS_CTX_INIT_MAX_LEN; - else if (svc != SPTLRPC_SVC_NULL) - buflens[bufcnt++] = gss_cli_payload(req->rq_cli_ctx, txtsize,0); - - bufsize = lustre_msg_size_v2(bufcnt, buflens); - - if (!req->rq_reqbuf) { - bufsize = size_roundup_power2(bufsize); - - OBD_ALLOC_LARGE(req->rq_reqbuf, bufsize); - if (!req->rq_reqbuf) - return -ENOMEM; - - req->rq_reqbuf_len = bufsize; - } else { - LASSERT(req->rq_pool); - LASSERT(req->rq_reqbuf_len >= bufsize); - memset(req->rq_reqbuf, 0, bufsize); - } - - lustre_init_msg_v2(req->rq_reqbuf, bufcnt, buflens, NULL); - req->rq_reqbuf->lm_secflvr = req->rq_flvr.sf_rpc; - - req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, 1, msgsize); - LASSERT(req->rq_reqmsg); - - /* pack user desc here, later we might leave current user's process */ - if (req->rq_pack_udesc) - sptlrpc_pack_user_desc(req->rq_reqbuf, 2); - - return 0; -} - -static -int gss_alloc_reqbuf_priv(struct ptlrpc_sec *sec, - struct ptlrpc_request *req, - int msgsize) -{ - __u32 ibuflens[3], wbuflens[2]; - int ibufcnt; - int clearsize, wiresize; - - LASSERT(req->rq_clrbuf == NULL); - LASSERT(req->rq_clrbuf_len == 0); - - /* Inner (clear) buffers - * - lustre message - * - user descriptor (optional) - * - bulk checksum (optional) - */ - ibufcnt = 1; - ibuflens[0] = msgsize; - - if (req->rq_pack_udesc) - ibuflens[ibufcnt++] = sptlrpc_current_user_desc_size(); - if (req->rq_pack_bulk) - ibuflens[ibufcnt++] = gss_cli_bulk_payload(req->rq_cli_ctx, - &req->rq_flvr, 0, - req->rq_bulk_read); - - clearsize = lustre_msg_size_v2(ibufcnt, ibuflens); - /* to allow append padding during encryption */ - clearsize += GSS_MAX_CIPHER_BLOCK; - - /* Wrapper (wire) buffers - * - gss header - * - cipher text - */ - wbuflens[0] = PTLRPC_GSS_HEADER_SIZE; - wbuflens[1] = gss_cli_payload(req->rq_cli_ctx, clearsize, 1); - wiresize = lustre_msg_size_v2(2, wbuflens); - - if (req->rq_pool) { - /* rq_reqbuf is preallocated */ - LASSERT(req->rq_reqbuf); - LASSERT(req->rq_reqbuf_len >= wiresize); - - memset(req->rq_reqbuf, 0, req->rq_reqbuf_len); - - /* if the pre-allocated buffer is big enough, we just pack - * both clear buf & request buf in it, to avoid more alloc. */ - if (clearsize + wiresize <= req->rq_reqbuf_len) { - req->rq_clrbuf = - (void *) (((char *) req->rq_reqbuf) + wiresize); - } else { - CWARN("pre-allocated buf size %d is not enough for " - "both clear (%d) and cipher (%d) text, proceed " - "with extra allocation\n", req->rq_reqbuf_len, - clearsize, wiresize); - } - } - - if (!req->rq_clrbuf) { - clearsize = size_roundup_power2(clearsize); - - OBD_ALLOC_LARGE(req->rq_clrbuf, clearsize); - if (!req->rq_clrbuf) - return -ENOMEM; - } - req->rq_clrbuf_len = clearsize; - - lustre_init_msg_v2(req->rq_clrbuf, ibufcnt, ibuflens, NULL); - req->rq_reqmsg = lustre_msg_buf(req->rq_clrbuf, 0, msgsize); - - if (req->rq_pack_udesc) - sptlrpc_pack_user_desc(req->rq_clrbuf, 1); - - return 0; -} - -/* - * NOTE: any change of request buffer allocation should also consider - * changing enlarge_reqbuf() series functions. - */ -int gss_alloc_reqbuf(struct ptlrpc_sec *sec, - struct ptlrpc_request *req, - int msgsize) -{ - int svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc); - - LASSERT(!req->rq_pack_bulk || - (req->rq_bulk_read || req->rq_bulk_write)); - - switch (svc) { - case SPTLRPC_SVC_NULL: - case SPTLRPC_SVC_AUTH: - case SPTLRPC_SVC_INTG: - return gss_alloc_reqbuf_intg(sec, req, svc, msgsize); - case SPTLRPC_SVC_PRIV: - return gss_alloc_reqbuf_priv(sec, req, msgsize); - default: - LASSERTF(0, "bad rpc flavor %x\n", req->rq_flvr.sf_rpc); - return 0; - } -} - -void gss_free_reqbuf(struct ptlrpc_sec *sec, - struct ptlrpc_request *req) -{ - int privacy; - - LASSERT(!req->rq_pool || req->rq_reqbuf); - privacy = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc) == SPTLRPC_SVC_PRIV; - - if (!req->rq_clrbuf) - goto release_reqbuf; - - /* release clear buffer */ - LASSERT(privacy); - LASSERT(req->rq_clrbuf_len); - - if (req->rq_pool == NULL || - req->rq_clrbuf < req->rq_reqbuf || - (char *) req->rq_clrbuf >= - (char *) req->rq_reqbuf + req->rq_reqbuf_len) - OBD_FREE_LARGE(req->rq_clrbuf, req->rq_clrbuf_len); - - req->rq_clrbuf = NULL; - req->rq_clrbuf_len = 0; - -release_reqbuf: - if (!req->rq_pool && req->rq_reqbuf) { - LASSERT(req->rq_reqbuf_len); - - OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); - req->rq_reqbuf = NULL; - req->rq_reqbuf_len = 0; - } -} - -static int do_alloc_repbuf(struct ptlrpc_request *req, int bufsize) -{ - bufsize = size_roundup_power2(bufsize); - - OBD_ALLOC_LARGE(req->rq_repbuf, bufsize); - if (!req->rq_repbuf) - return -ENOMEM; - - req->rq_repbuf_len = bufsize; - return 0; -} - -static -int gss_alloc_repbuf_intg(struct ptlrpc_sec *sec, - struct ptlrpc_request *req, - int svc, int msgsize) -{ - int txtsize; - __u32 buflens[4]; - int bufcnt = 2; - int alloc_size; - - /* - * on-wire data layout: - * - gss header - * - lustre message - * - bulk sec descriptor (optional) - * - signature (optional) - * - svc == NULL: NULL - * - svc == AUTH: signature of gss header - * - svc == INTG: signature of all above - * - * if this is context negotiation, reserver fixed space - * at the last (signature) segment regardless of svc mode. - */ - - buflens[0] = PTLRPC_GSS_HEADER_SIZE; - txtsize = buflens[0]; - - buflens[1] = msgsize; - if (svc == SPTLRPC_SVC_INTG) - txtsize += buflens[1]; - - if (req->rq_pack_bulk) { - buflens[bufcnt] = gss_cli_bulk_payload(req->rq_cli_ctx, - &req->rq_flvr, - 1, req->rq_bulk_read); - if (svc == SPTLRPC_SVC_INTG) - txtsize += buflens[bufcnt]; - bufcnt++; - } - - if (req->rq_ctx_init) - buflens[bufcnt++] = GSS_CTX_INIT_MAX_LEN; - else if (svc != SPTLRPC_SVC_NULL) - buflens[bufcnt++] = gss_cli_payload(req->rq_cli_ctx, txtsize,0); - - alloc_size = lustre_msg_size_v2(bufcnt, buflens); - - /* add space for early reply */ - alloc_size += gss_at_reply_off_integ; - - return do_alloc_repbuf(req, alloc_size); -} - -static -int gss_alloc_repbuf_priv(struct ptlrpc_sec *sec, - struct ptlrpc_request *req, - int msgsize) -{ - int txtsize; - __u32 buflens[2]; - int bufcnt; - int alloc_size; - - /* inner buffers */ - bufcnt = 1; - buflens[0] = msgsize; - - if (req->rq_pack_bulk) - buflens[bufcnt++] = gss_cli_bulk_payload(req->rq_cli_ctx, - &req->rq_flvr, - 1, req->rq_bulk_read); - txtsize = lustre_msg_size_v2(bufcnt, buflens); - txtsize += GSS_MAX_CIPHER_BLOCK; - - /* wrapper buffers */ - bufcnt = 2; - buflens[0] = PTLRPC_GSS_HEADER_SIZE; - buflens[1] = gss_cli_payload(req->rq_cli_ctx, txtsize, 1); - - alloc_size = lustre_msg_size_v2(bufcnt, buflens); - /* add space for early reply */ - alloc_size += gss_at_reply_off_priv; - - return do_alloc_repbuf(req, alloc_size); -} - -int gss_alloc_repbuf(struct ptlrpc_sec *sec, - struct ptlrpc_request *req, - int msgsize) -{ - int svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc); - - LASSERT(!req->rq_pack_bulk || - (req->rq_bulk_read || req->rq_bulk_write)); - - switch (svc) { - case SPTLRPC_SVC_NULL: - case SPTLRPC_SVC_AUTH: - case SPTLRPC_SVC_INTG: - return gss_alloc_repbuf_intg(sec, req, svc, msgsize); - case SPTLRPC_SVC_PRIV: - return gss_alloc_repbuf_priv(sec, req, msgsize); - default: - LASSERTF(0, "bad rpc flavor %x\n", req->rq_flvr.sf_rpc); - return 0; - } -} - -void gss_free_repbuf(struct ptlrpc_sec *sec, - struct ptlrpc_request *req) -{ - OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len); - req->rq_repbuf = NULL; - req->rq_repbuf_len = 0; - req->rq_repdata = NULL; - req->rq_repdata_len = 0; -} - -static int get_enlarged_msgsize(struct lustre_msg *msg, - int segment, int newsize) -{ - int save, newmsg_size; - - LASSERT(newsize >= msg->lm_buflens[segment]); - - save = msg->lm_buflens[segment]; - msg->lm_buflens[segment] = newsize; - newmsg_size = lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens); - msg->lm_buflens[segment] = save; - - return newmsg_size; -} - -static int get_enlarged_msgsize2(struct lustre_msg *msg, - int segment1, int newsize1, - int segment2, int newsize2) -{ - int save1, save2, newmsg_size; - - LASSERT(newsize1 >= msg->lm_buflens[segment1]); - LASSERT(newsize2 >= msg->lm_buflens[segment2]); - - save1 = msg->lm_buflens[segment1]; - save2 = msg->lm_buflens[segment2]; - msg->lm_buflens[segment1] = newsize1; - msg->lm_buflens[segment2] = newsize2; - newmsg_size = lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens); - msg->lm_buflens[segment1] = save1; - msg->lm_buflens[segment2] = save2; - - return newmsg_size; -} - -static -int gss_enlarge_reqbuf_intg(struct ptlrpc_sec *sec, - struct ptlrpc_request *req, - int svc, - int segment, int newsize) -{ - struct lustre_msg *newbuf; - int txtsize, sigsize = 0, i; - int newmsg_size, newbuf_size; - - /* - * gss header is at seg 0; - * embedded msg is at seg 1; - * signature (if any) is at the last seg - */ - LASSERT(req->rq_reqbuf); - LASSERT(req->rq_reqbuf_len > req->rq_reqlen); - LASSERT(req->rq_reqbuf->lm_bufcount >= 2); - LASSERT(lustre_msg_buf(req->rq_reqbuf, 1, 0) == req->rq_reqmsg); - - /* 1. compute new embedded msg size */ - newmsg_size = get_enlarged_msgsize(req->rq_reqmsg, segment, newsize); - LASSERT(newmsg_size >= req->rq_reqbuf->lm_buflens[1]); - - /* 2. compute new wrapper msg size */ - if (svc == SPTLRPC_SVC_NULL) { - /* no signature, get size directly */ - newbuf_size = get_enlarged_msgsize(req->rq_reqbuf, - 1, newmsg_size); - } else { - txtsize = req->rq_reqbuf->lm_buflens[0]; - - if (svc == SPTLRPC_SVC_INTG) { - for (i = 1; i < req->rq_reqbuf->lm_bufcount; i++) - txtsize += req->rq_reqbuf->lm_buflens[i]; - txtsize += newmsg_size - req->rq_reqbuf->lm_buflens[1]; - } - - sigsize = gss_cli_payload(req->rq_cli_ctx, txtsize, 0); - LASSERT(sigsize >= msg_last_seglen(req->rq_reqbuf)); - - newbuf_size = get_enlarged_msgsize2( - req->rq_reqbuf, - 1, newmsg_size, - msg_last_segidx(req->rq_reqbuf), - sigsize); - } - - /* request from pool should always have enough buffer */ - LASSERT(!req->rq_pool || req->rq_reqbuf_len >= newbuf_size); - - if (req->rq_reqbuf_len < newbuf_size) { - newbuf_size = size_roundup_power2(newbuf_size); - - OBD_ALLOC_LARGE(newbuf, newbuf_size); - if (newbuf == NULL) - return -ENOMEM; - - memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len); - - OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); - req->rq_reqbuf = newbuf; - req->rq_reqbuf_len = newbuf_size; - req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, 1, 0); - } - - /* do enlargement, from wrapper to embedded, from end to begin */ - if (svc != SPTLRPC_SVC_NULL) - _sptlrpc_enlarge_msg_inplace(req->rq_reqbuf, - msg_last_segidx(req->rq_reqbuf), - sigsize); - - _sptlrpc_enlarge_msg_inplace(req->rq_reqbuf, 1, newmsg_size); - _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize); - - req->rq_reqlen = newmsg_size; - return 0; -} - -static -int gss_enlarge_reqbuf_priv(struct ptlrpc_sec *sec, - struct ptlrpc_request *req, - int segment, int newsize) -{ - struct lustre_msg *newclrbuf; - int newmsg_size, newclrbuf_size, newcipbuf_size; - __u32 buflens[3]; - - /* - * embedded msg is at seg 0 of clear buffer; - * cipher text is at seg 2 of cipher buffer; - */ - LASSERT(req->rq_pool || - (req->rq_reqbuf == NULL && req->rq_reqbuf_len == 0)); - LASSERT(req->rq_reqbuf == NULL || - (req->rq_pool && req->rq_reqbuf->lm_bufcount == 3)); - LASSERT(req->rq_clrbuf); - LASSERT(req->rq_clrbuf_len > req->rq_reqlen); - LASSERT(lustre_msg_buf(req->rq_clrbuf, 0, 0) == req->rq_reqmsg); - - /* compute new embedded msg size */ - newmsg_size = get_enlarged_msgsize(req->rq_reqmsg, segment, newsize); - - /* compute new clear buffer size */ - newclrbuf_size = get_enlarged_msgsize(req->rq_clrbuf, 0, newmsg_size); - newclrbuf_size += GSS_MAX_CIPHER_BLOCK; - - /* compute new cipher buffer size */ - buflens[0] = PTLRPC_GSS_HEADER_SIZE; - buflens[1] = gss_cli_payload(req->rq_cli_ctx, buflens[0], 0); - buflens[2] = gss_cli_payload(req->rq_cli_ctx, newclrbuf_size, 1); - newcipbuf_size = lustre_msg_size_v2(3, buflens); - - /* handle the case that we put both clear buf and cipher buf into - * pre-allocated single buffer. */ - if (unlikely(req->rq_pool) && - req->rq_clrbuf >= req->rq_reqbuf && - (char *) req->rq_clrbuf < - (char *) req->rq_reqbuf + req->rq_reqbuf_len) { - /* it couldn't be better we still fit into the - * pre-allocated buffer. */ - if (newclrbuf_size + newcipbuf_size <= req->rq_reqbuf_len) { - void *src, *dst; - - /* move clear text backward. */ - src = req->rq_clrbuf; - dst = (char *) req->rq_reqbuf + newcipbuf_size; - - memmove(dst, src, req->rq_clrbuf_len); - - req->rq_clrbuf = (struct lustre_msg *) dst; - req->rq_clrbuf_len = newclrbuf_size; - req->rq_reqmsg = lustre_msg_buf(req->rq_clrbuf, 0, 0); - } else { - /* sadly we have to split out the clear buffer */ - LASSERT(req->rq_reqbuf_len >= newcipbuf_size); - LASSERT(req->rq_clrbuf_len < newclrbuf_size); - } - } - - if (req->rq_clrbuf_len < newclrbuf_size) { - newclrbuf_size = size_roundup_power2(newclrbuf_size); - - OBD_ALLOC_LARGE(newclrbuf, newclrbuf_size); - if (newclrbuf == NULL) - return -ENOMEM; - - memcpy(newclrbuf, req->rq_clrbuf, req->rq_clrbuf_len); - - if (req->rq_reqbuf == NULL || - req->rq_clrbuf < req->rq_reqbuf || - (char *) req->rq_clrbuf >= - (char *) req->rq_reqbuf + req->rq_reqbuf_len) { - OBD_FREE_LARGE(req->rq_clrbuf, req->rq_clrbuf_len); - } - - req->rq_clrbuf = newclrbuf; - req->rq_clrbuf_len = newclrbuf_size; - req->rq_reqmsg = lustre_msg_buf(req->rq_clrbuf, 0, 0); - } - - _sptlrpc_enlarge_msg_inplace(req->rq_clrbuf, 0, newmsg_size); - _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize); - req->rq_reqlen = newmsg_size; - - return 0; -} - -int gss_enlarge_reqbuf(struct ptlrpc_sec *sec, - struct ptlrpc_request *req, - int segment, int newsize) -{ - int svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc); - - LASSERT(!req->rq_ctx_init && !req->rq_ctx_fini); - - switch (svc) { - case SPTLRPC_SVC_NULL: - case SPTLRPC_SVC_AUTH: - case SPTLRPC_SVC_INTG: - return gss_enlarge_reqbuf_intg(sec, req, svc, segment, newsize); - case SPTLRPC_SVC_PRIV: - return gss_enlarge_reqbuf_priv(sec, req, segment, newsize); - default: - LASSERTF(0, "bad rpc flavor %x\n", req->rq_flvr.sf_rpc); - return 0; - } -} - -int gss_sec_install_rctx(struct obd_import *imp, - struct ptlrpc_sec *sec, - struct ptlrpc_cli_ctx *ctx) -{ - struct gss_sec *gsec; - struct gss_cli_ctx *gctx; - int rc; - - gsec = container_of(sec, struct gss_sec, gs_base); - gctx = container_of(ctx, struct gss_cli_ctx, gc_base); - - rc = gss_install_rvs_svc_ctx(imp, gsec, gctx); - return rc; -} - -/******************************************** - * server side API * - ********************************************/ - -static inline -int gss_svc_reqctx_is_special(struct gss_svc_reqctx *grctx) -{ - LASSERT(grctx); - return (grctx->src_init || grctx->src_init_continue || - grctx->src_err_notify); -} - -static -void gss_svc_reqctx_free(struct gss_svc_reqctx *grctx) -{ - if (grctx->src_ctx) - gss_svc_upcall_put_ctx(grctx->src_ctx); - - sptlrpc_policy_put(grctx->src_base.sc_policy); - OBD_FREE_PTR(grctx); -} - -static inline -void gss_svc_reqctx_addref(struct gss_svc_reqctx *grctx) -{ - LASSERT(atomic_read(&grctx->src_base.sc_refcount) > 0); - atomic_inc(&grctx->src_base.sc_refcount); -} - -static inline -void gss_svc_reqctx_decref(struct gss_svc_reqctx *grctx) -{ - LASSERT(atomic_read(&grctx->src_base.sc_refcount) > 0); - - if (atomic_dec_and_test(&grctx->src_base.sc_refcount)) - gss_svc_reqctx_free(grctx); -} - -static -int gss_svc_sign(struct ptlrpc_request *req, - struct ptlrpc_reply_state *rs, - struct gss_svc_reqctx *grctx, - __u32 svc) -{ - __u32 flags = 0; - int rc; - - LASSERT(rs->rs_msg == lustre_msg_buf(rs->rs_repbuf, 1, 0)); - - /* embedded lustre_msg might have been shrunk */ - if (req->rq_replen != rs->rs_repbuf->lm_buflens[1]) - lustre_shrink_msg(rs->rs_repbuf, 1, req->rq_replen, 1); - - if (req->rq_pack_bulk) - flags |= LUSTRE_GSS_PACK_BULK; - - rc = gss_sign_msg(rs->rs_repbuf, grctx->src_ctx->gsc_mechctx, - LUSTRE_SP_ANY, flags, PTLRPC_GSS_PROC_DATA, - grctx->src_wirectx.gw_seq, svc, NULL); - if (rc < 0) - return rc; - - rs->rs_repdata_len = rc; - - if (likely(req->rq_packed_final)) { - if (lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT) - req->rq_reply_off = gss_at_reply_off_integ; - else - req->rq_reply_off = 0; - } else { - if (svc == SPTLRPC_SVC_NULL) - rs->rs_repbuf->lm_cksum = crc32_le(!(__u32) 0, - lustre_msg_buf(rs->rs_repbuf, 1, 0), - lustre_msg_buflen(rs->rs_repbuf, 1)); - req->rq_reply_off = 0; - } - - return 0; -} - -int gss_pack_err_notify(struct ptlrpc_request *req, __u32 major, __u32 minor) -{ - struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); - struct ptlrpc_reply_state *rs; - struct gss_err_header *ghdr; - int replen = sizeof(struct ptlrpc_body); - int rc; - - //if (OBD_FAIL_CHECK_ORSET(OBD_FAIL_SVCGSS_ERR_NOTIFY, OBD_FAIL_ONCE)) - // return -EINVAL; - - grctx->src_err_notify = 1; - grctx->src_reserve_len = 0; - - rc = lustre_pack_reply_v2(req, 1, &replen, NULL, 0); - if (rc) { - CERROR("could not pack reply, err %d\n", rc); - return rc; - } - - /* gss hdr */ - rs = req->rq_reply_state; - LASSERT(rs->rs_repbuf->lm_buflens[1] >= sizeof(*ghdr)); - ghdr = lustre_msg_buf(rs->rs_repbuf, 0, 0); - ghdr->gh_version = PTLRPC_GSS_VERSION; - ghdr->gh_flags = 0; - ghdr->gh_proc = PTLRPC_GSS_PROC_ERR; - ghdr->gh_major = major; - ghdr->gh_minor = minor; - ghdr->gh_handle.len = 0; /* fake context handle */ - - rs->rs_repdata_len = lustre_msg_size_v2(rs->rs_repbuf->lm_bufcount, - rs->rs_repbuf->lm_buflens); - - CDEBUG(D_SEC, "prepare gss error notify(0x%x/0x%x) to %s\n", - major, minor, libcfs_nid2str(req->rq_peer.nid)); - return 0; -} - -static -int gss_svc_handle_init(struct ptlrpc_request *req, - struct gss_wire_ctx *gw) -{ - struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); - struct lustre_msg *reqbuf = req->rq_reqbuf; - struct obd_uuid *uuid; - struct obd_device *target; - rawobj_t uuid_obj, rvs_hdl, in_token; - __u32 lustre_svc; - __u32 *secdata, seclen; - int swabbed, rc; - - CDEBUG(D_SEC, "processing gss init(%d) request from %s\n", gw->gw_proc, - libcfs_nid2str(req->rq_peer.nid)); - - req->rq_ctx_init = 1; - - if (gw->gw_flags & LUSTRE_GSS_PACK_BULK) { - CERROR("unexpected bulk flag\n"); - return SECSVC_DROP; - } - - if (gw->gw_proc == PTLRPC_GSS_PROC_INIT && gw->gw_handle.len != 0) { - CERROR("proc %u: invalid handle length %u\n", - gw->gw_proc, gw->gw_handle.len); - return SECSVC_DROP; - } - - if (reqbuf->lm_bufcount < 3 || reqbuf->lm_bufcount > 4) { - CERROR("Invalid bufcount %d\n", reqbuf->lm_bufcount); - return SECSVC_DROP; - } - - swabbed = ptlrpc_req_need_swab(req); - - /* ctx initiate payload is in last segment */ - secdata = lustre_msg_buf(reqbuf, reqbuf->lm_bufcount - 1, 0); - seclen = reqbuf->lm_buflens[reqbuf->lm_bufcount - 1]; - - if (seclen < 4 + 4) { - CERROR("sec size %d too small\n", seclen); - return SECSVC_DROP; - } - - /* lustre svc type */ - lustre_svc = le32_to_cpu(*secdata++); - seclen -= 4; - - /* extract target uuid, note this code is somewhat fragile - * because touched internal structure of obd_uuid */ - if (rawobj_extract(&uuid_obj, &secdata, &seclen)) { - CERROR("failed to extract target uuid\n"); - return SECSVC_DROP; - } - uuid_obj.data[uuid_obj.len - 1] = '\0'; - - uuid = (struct obd_uuid *) uuid_obj.data; - target = class_uuid2obd(uuid); - if (!target || target->obd_stopping || !target->obd_set_up) { - CERROR("target '%s' is not available for context init (%s)\n", - uuid->uuid, target == NULL ? "no target" : - (target->obd_stopping ? "stopping" : "not set up")); - return SECSVC_DROP; - } - - /* extract reverse handle */ - if (rawobj_extract(&rvs_hdl, &secdata, &seclen)) { - CERROR("failed extract reverse handle\n"); - return SECSVC_DROP; - } - - /* extract token */ - if (rawobj_extract(&in_token, &secdata, &seclen)) { - CERROR("can't extract token\n"); - return SECSVC_DROP; - } - - rc = gss_svc_upcall_handle_init(req, grctx, gw, target, lustre_svc, - &rvs_hdl, &in_token); - if (rc != SECSVC_OK) - return rc; - - if (grctx->src_ctx->gsc_usr_mds || grctx->src_ctx->gsc_usr_oss || - grctx->src_ctx->gsc_usr_root) - CWARN("create svc ctx %p: user from %s authenticated as %s\n", - grctx->src_ctx, libcfs_nid2str(req->rq_peer.nid), - grctx->src_ctx->gsc_usr_mds ? "mds" : - (grctx->src_ctx->gsc_usr_oss ? "oss" : "root")); - else - CWARN("create svc ctx %p: accept user %u from %s\n", - grctx->src_ctx, grctx->src_ctx->gsc_uid, - libcfs_nid2str(req->rq_peer.nid)); - - if (gw->gw_flags & LUSTRE_GSS_PACK_USER) { - if (reqbuf->lm_bufcount < 4) { - CERROR("missing user descriptor\n"); - return SECSVC_DROP; - } - if (sptlrpc_unpack_user_desc(reqbuf, 2, swabbed)) { - CERROR("Mal-formed user descriptor\n"); - return SECSVC_DROP; - } - - req->rq_pack_udesc = 1; - req->rq_user_desc = lustre_msg_buf(reqbuf, 2, 0); - } - - req->rq_reqmsg = lustre_msg_buf(reqbuf, 1, 0); - req->rq_reqlen = lustre_msg_buflen(reqbuf, 1); - - return rc; -} - -/* - * last segment must be the gss signature. - */ -static -int gss_svc_verify_request(struct ptlrpc_request *req, - struct gss_svc_reqctx *grctx, - struct gss_wire_ctx *gw, - __u32 *major) -{ - struct gss_svc_ctx *gctx = grctx->src_ctx; - struct lustre_msg *msg = req->rq_reqbuf; - int offset = 2; - int swabbed; - - *major = GSS_S_COMPLETE; - - if (msg->lm_bufcount < 2) { - CERROR("Too few segments (%u) in request\n", msg->lm_bufcount); - return -EINVAL; - } - - if (gw->gw_svc == SPTLRPC_SVC_NULL) - goto verified; - - if (gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 0)) { - CERROR("phase 0: discard replayed req: seq %u\n", gw->gw_seq); - *major = GSS_S_DUPLICATE_TOKEN; - return -EACCES; - } - - *major = gss_verify_msg(msg, gctx->gsc_mechctx, gw->gw_svc); - if (*major != GSS_S_COMPLETE) { - CERROR("failed to verify request: %x\n", *major); - return -EACCES; - } - - if (gctx->gsc_reverse == 0 && - gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 1)) { - CERROR("phase 1+: discard replayed req: seq %u\n", gw->gw_seq); - *major = GSS_S_DUPLICATE_TOKEN; - return -EACCES; - } - -verified: - swabbed = ptlrpc_req_need_swab(req); - - /* user descriptor */ - if (gw->gw_flags & LUSTRE_GSS_PACK_USER) { - if (msg->lm_bufcount < (offset + 1)) { - CERROR("no user desc included\n"); - return -EINVAL; - } - - if (sptlrpc_unpack_user_desc(msg, offset, swabbed)) { - CERROR("Mal-formed user descriptor\n"); - return -EINVAL; - } - - req->rq_pack_udesc = 1; - req->rq_user_desc = lustre_msg_buf(msg, offset, 0); - offset++; - } - - /* check bulk_sec_desc data */ - if (gw->gw_flags & LUSTRE_GSS_PACK_BULK) { - if (msg->lm_bufcount < (offset + 1)) { - CERROR("missing bulk sec descriptor\n"); - return -EINVAL; - } - - if (bulk_sec_desc_unpack(msg, offset, swabbed)) - return -EINVAL; - - req->rq_pack_bulk = 1; - grctx->src_reqbsd = lustre_msg_buf(msg, offset, 0); - grctx->src_reqbsd_size = lustre_msg_buflen(msg, offset); - } - - req->rq_reqmsg = lustre_msg_buf(msg, 1, 0); - req->rq_reqlen = msg->lm_buflens[1]; - return 0; -} - -static -int gss_svc_unseal_request(struct ptlrpc_request *req, - struct gss_svc_reqctx *grctx, - struct gss_wire_ctx *gw, - __u32 *major) -{ - struct gss_svc_ctx *gctx = grctx->src_ctx; - struct lustre_msg *msg = req->rq_reqbuf; - int swabbed, msglen, offset = 1; - - if (gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 0)) { - CERROR("phase 0: discard replayed req: seq %u\n", gw->gw_seq); - *major = GSS_S_DUPLICATE_TOKEN; - return -EACCES; - } - - *major = gss_unseal_msg(gctx->gsc_mechctx, msg, - &msglen, req->rq_reqdata_len); - if (*major != GSS_S_COMPLETE) { - CERROR("failed to unwrap request: %x\n", *major); - return -EACCES; - } - - if (gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 1)) { - CERROR("phase 1+: discard replayed req: seq %u\n", gw->gw_seq); - *major = GSS_S_DUPLICATE_TOKEN; - return -EACCES; - } - - swabbed = __lustre_unpack_msg(msg, msglen); - if (swabbed < 0) { - CERROR("Failed to unpack after decryption\n"); - return -EINVAL; - } - req->rq_reqdata_len = msglen; - - if (msg->lm_bufcount < 1) { - CERROR("Invalid buffer: is empty\n"); - return -EINVAL; - } - - if (gw->gw_flags & LUSTRE_GSS_PACK_USER) { - if (msg->lm_bufcount < offset + 1) { - CERROR("no user descriptor included\n"); - return -EINVAL; - } - - if (sptlrpc_unpack_user_desc(msg, offset, swabbed)) { - CERROR("Mal-formed user descriptor\n"); - return -EINVAL; - } - - req->rq_pack_udesc = 1; - req->rq_user_desc = lustre_msg_buf(msg, offset, 0); - offset++; - } - - if (gw->gw_flags & LUSTRE_GSS_PACK_BULK) { - if (msg->lm_bufcount < offset + 1) { - CERROR("no bulk checksum included\n"); - return -EINVAL; - } - - if (bulk_sec_desc_unpack(msg, offset, swabbed)) - return -EINVAL; - - req->rq_pack_bulk = 1; - grctx->src_reqbsd = lustre_msg_buf(msg, offset, 0); - grctx->src_reqbsd_size = lustre_msg_buflen(msg, offset); - } - - req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, 0, 0); - req->rq_reqlen = req->rq_reqbuf->lm_buflens[0]; - return 0; -} - -static -int gss_svc_handle_data(struct ptlrpc_request *req, - struct gss_wire_ctx *gw) -{ - struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); - __u32 major = 0; - int rc = 0; - - grctx->src_ctx = gss_svc_upcall_get_ctx(req, gw); - if (!grctx->src_ctx) { - major = GSS_S_NO_CONTEXT; - goto error; - } - - switch (gw->gw_svc) { - case SPTLRPC_SVC_NULL: - case SPTLRPC_SVC_AUTH: - case SPTLRPC_SVC_INTG: - rc = gss_svc_verify_request(req, grctx, gw, &major); - break; - case SPTLRPC_SVC_PRIV: - rc = gss_svc_unseal_request(req, grctx, gw, &major); - break; - default: - CERROR("unsupported gss service %d\n", gw->gw_svc); - rc = -EINVAL; - } - - if (rc == 0) - return SECSVC_OK; - - CERROR("svc %u failed: major 0x%08x: req xid "LPU64" ctx %p idx " - LPX64"(%u->%s)\n", gw->gw_svc, major, req->rq_xid, - grctx->src_ctx, gss_handle_to_u64(&gw->gw_handle), - grctx->src_ctx->gsc_uid, libcfs_nid2str(req->rq_peer.nid)); -error: - /* we only notify client in case of NO_CONTEXT/BAD_SIG, which - * might happen after server reboot, to allow recovery. */ - if ((major == GSS_S_NO_CONTEXT || major == GSS_S_BAD_SIG) && - gss_pack_err_notify(req, major, 0) == 0) - return SECSVC_COMPLETE; - - return SECSVC_DROP; -} - -static -int gss_svc_handle_destroy(struct ptlrpc_request *req, - struct gss_wire_ctx *gw) -{ - struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); - __u32 major; - - req->rq_ctx_fini = 1; - req->rq_no_reply = 1; - - grctx->src_ctx = gss_svc_upcall_get_ctx(req, gw); - if (!grctx->src_ctx) { - CDEBUG(D_SEC, "invalid gss context handle for destroy.\n"); - return SECSVC_DROP; - } - - if (gw->gw_svc != SPTLRPC_SVC_INTG) { - CERROR("svc %u is not supported in destroy.\n", gw->gw_svc); - return SECSVC_DROP; - } - - if (gss_svc_verify_request(req, grctx, gw, &major)) - return SECSVC_DROP; - - CWARN("destroy svc ctx %p idx "LPX64" (%u->%s)\n", - grctx->src_ctx, gss_handle_to_u64(&gw->gw_handle), - grctx->src_ctx->gsc_uid, libcfs_nid2str(req->rq_peer.nid)); - - gss_svc_upcall_destroy_ctx(grctx->src_ctx); - - if (gw->gw_flags & LUSTRE_GSS_PACK_USER) { - if (req->rq_reqbuf->lm_bufcount < 4) { - CERROR("missing user descriptor, ignore it\n"); - return SECSVC_OK; - } - if (sptlrpc_unpack_user_desc(req->rq_reqbuf, 2, - ptlrpc_req_need_swab(req))) { - CERROR("Mal-formed user descriptor, ignore it\n"); - return SECSVC_OK; - } - - req->rq_pack_udesc = 1; - req->rq_user_desc = lustre_msg_buf(req->rq_reqbuf, 2, 0); - } - - return SECSVC_OK; -} - -int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) -{ - struct gss_header *ghdr; - struct gss_svc_reqctx *grctx; - struct gss_wire_ctx *gw; - int swabbed, rc; - - LASSERT(req->rq_reqbuf); - LASSERT(req->rq_svc_ctx == NULL); - - if (req->rq_reqbuf->lm_bufcount < 2) { - CERROR("buf count only %d\n", req->rq_reqbuf->lm_bufcount); - return SECSVC_DROP; - } - - swabbed = ptlrpc_req_need_swab(req); - - ghdr = gss_swab_header(req->rq_reqbuf, 0, swabbed); - if (ghdr == NULL) { - CERROR("can't decode gss header\n"); - return SECSVC_DROP; - } - - /* sanity checks */ - if (ghdr->gh_version != PTLRPC_GSS_VERSION) { - CERROR("gss version %u, expect %u\n", ghdr->gh_version, - PTLRPC_GSS_VERSION); - return SECSVC_DROP; - } - - req->rq_sp_from = ghdr->gh_sp; - - /* alloc grctx data */ - OBD_ALLOC_PTR(grctx); - if (!grctx) - return SECSVC_DROP; - - grctx->src_base.sc_policy = sptlrpc_policy_get(policy); - atomic_set(&grctx->src_base.sc_refcount, 1); - req->rq_svc_ctx = &grctx->src_base; - gw = &grctx->src_wirectx; - - /* save wire context */ - gw->gw_flags = ghdr->gh_flags; - gw->gw_proc = ghdr->gh_proc; - gw->gw_seq = ghdr->gh_seq; - gw->gw_svc = ghdr->gh_svc; - rawobj_from_netobj(&gw->gw_handle, &ghdr->gh_handle); - - /* keep original wire header which subject to checksum verification */ - if (swabbed) - gss_header_swabber(ghdr); - - switch (ghdr->gh_proc) { - case PTLRPC_GSS_PROC_INIT: - case PTLRPC_GSS_PROC_CONTINUE_INIT: - rc = gss_svc_handle_init(req, gw); - break; - case PTLRPC_GSS_PROC_DATA: - rc = gss_svc_handle_data(req, gw); - break; - case PTLRPC_GSS_PROC_DESTROY: - rc = gss_svc_handle_destroy(req, gw); - break; - default: - CERROR("unknown proc %u\n", gw->gw_proc); - rc = SECSVC_DROP; - break; - } - - switch (rc) { - case SECSVC_OK: - LASSERT(grctx->src_ctx); - - req->rq_auth_gss = 1; - req->rq_auth_remote = grctx->src_ctx->gsc_remote; - req->rq_auth_usr_mdt = grctx->src_ctx->gsc_usr_mds; - req->rq_auth_usr_ost = grctx->src_ctx->gsc_usr_oss; - req->rq_auth_usr_root = grctx->src_ctx->gsc_usr_root; - req->rq_auth_uid = grctx->src_ctx->gsc_uid; - req->rq_auth_mapped_uid = grctx->src_ctx->gsc_mapped_uid; - break; - case SECSVC_COMPLETE: - break; - case SECSVC_DROP: - gss_svc_reqctx_free(grctx); - req->rq_svc_ctx = NULL; - break; - } - - return rc; -} - -void gss_svc_invalidate_ctx(struct ptlrpc_svc_ctx *svc_ctx) -{ - struct gss_svc_reqctx *grctx; - - if (svc_ctx == NULL) { - return; - } - - grctx = gss_svc_ctx2reqctx(svc_ctx); - - CWARN("gss svc invalidate ctx %p(%u)\n", - grctx->src_ctx, grctx->src_ctx->gsc_uid); - gss_svc_upcall_destroy_ctx(grctx->src_ctx); -} - -static inline -int gss_svc_payload(struct gss_svc_reqctx *grctx, int early, - int msgsize, int privacy) -{ - /* we should treat early reply normally, but which is actually sharing - * the same ctx with original request, so in this case we should - * ignore the special ctx's special flags */ - if (early == 0 && gss_svc_reqctx_is_special(grctx)) - return grctx->src_reserve_len; - - return gss_mech_payload(NULL, msgsize, privacy); -} - -static int gss_svc_bulk_payload(struct gss_svc_ctx *gctx, - struct sptlrpc_flavor *flvr, - int read) -{ - int payload = sizeof(struct ptlrpc_bulk_sec_desc); - - if (read) { - switch (SPTLRPC_FLVR_BULK_SVC(flvr->sf_rpc)) { - case SPTLRPC_BULK_SVC_NULL: - break; - case SPTLRPC_BULK_SVC_INTG: - payload += gss_mech_payload(NULL, 0, 0); - break; - case SPTLRPC_BULK_SVC_PRIV: - payload += gss_mech_payload(NULL, 0, 1); - break; - case SPTLRPC_BULK_SVC_AUTH: - default: - LBUG(); - } - } - - return payload; -} - -int gss_svc_alloc_rs(struct ptlrpc_request *req, int msglen) -{ - struct gss_svc_reqctx *grctx; - struct ptlrpc_reply_state *rs; - int early, privacy, svc, bsd_off = 0; - __u32 ibuflens[2], buflens[4]; - int ibufcnt = 0, bufcnt; - int txtsize, wmsg_size, rs_size; - - LASSERT(msglen % 8 == 0); - - if (req->rq_pack_bulk && !req->rq_bulk_read && !req->rq_bulk_write) { - CERROR("client request bulk sec on non-bulk rpc\n"); - return -EPROTO; - } - - svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc); - early = (req->rq_packed_final == 0); - - grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); - if (!early && gss_svc_reqctx_is_special(grctx)) - privacy = 0; - else - privacy = (svc == SPTLRPC_SVC_PRIV); - - if (privacy) { - /* inner clear buffers */ - ibufcnt = 1; - ibuflens[0] = msglen; - - if (req->rq_pack_bulk) { - LASSERT(grctx->src_reqbsd); - - bsd_off = ibufcnt; - ibuflens[ibufcnt++] = gss_svc_bulk_payload( - grctx->src_ctx, - &req->rq_flvr, - req->rq_bulk_read); - } - - txtsize = lustre_msg_size_v2(ibufcnt, ibuflens); - txtsize += GSS_MAX_CIPHER_BLOCK; - - /* wrapper buffer */ - bufcnt = 2; - buflens[0] = PTLRPC_GSS_HEADER_SIZE; - buflens[1] = gss_svc_payload(grctx, early, txtsize, 1); - } else { - bufcnt = 2; - buflens[0] = PTLRPC_GSS_HEADER_SIZE; - buflens[1] = msglen; - - txtsize = buflens[0]; - if (svc == SPTLRPC_SVC_INTG) - txtsize += buflens[1]; - - if (req->rq_pack_bulk) { - LASSERT(grctx->src_reqbsd); - - bsd_off = bufcnt; - buflens[bufcnt] = gss_svc_bulk_payload( - grctx->src_ctx, - &req->rq_flvr, - req->rq_bulk_read); - if (svc == SPTLRPC_SVC_INTG) - txtsize += buflens[bufcnt]; - bufcnt++; - } - - if ((!early && gss_svc_reqctx_is_special(grctx)) || - svc != SPTLRPC_SVC_NULL) - buflens[bufcnt++] = gss_svc_payload(grctx, early, - txtsize, 0); - } - - wmsg_size = lustre_msg_size_v2(bufcnt, buflens); - - rs_size = sizeof(*rs) + wmsg_size; - rs = req->rq_reply_state; - - if (rs) { - /* pre-allocated */ - LASSERT(rs->rs_size >= rs_size); - } else { - OBD_ALLOC_LARGE(rs, rs_size); - if (rs == NULL) - return -ENOMEM; - - rs->rs_size = rs_size; - } - - rs->rs_repbuf = (struct lustre_msg *) (rs + 1); - rs->rs_repbuf_len = wmsg_size; - - /* initialize the buffer */ - if (privacy) { - lustre_init_msg_v2(rs->rs_repbuf, ibufcnt, ibuflens, NULL); - rs->rs_msg = lustre_msg_buf(rs->rs_repbuf, 0, msglen); - } else { - lustre_init_msg_v2(rs->rs_repbuf, bufcnt, buflens, NULL); - rs->rs_repbuf->lm_secflvr = req->rq_flvr.sf_rpc; - - rs->rs_msg = lustre_msg_buf(rs->rs_repbuf, 1, 0); - } - - if (bsd_off) { - grctx->src_repbsd = lustre_msg_buf(rs->rs_repbuf, bsd_off, 0); - grctx->src_repbsd_size = lustre_msg_buflen(rs->rs_repbuf, - bsd_off); - } - - gss_svc_reqctx_addref(grctx); - rs->rs_svc_ctx = req->rq_svc_ctx; - - LASSERT(rs->rs_msg); - req->rq_reply_state = rs; - return 0; -} - -static int gss_svc_seal(struct ptlrpc_request *req, - struct ptlrpc_reply_state *rs, - struct gss_svc_reqctx *grctx) -{ - struct gss_svc_ctx *gctx = grctx->src_ctx; - rawobj_t hdrobj, msgobj, token; - struct gss_header *ghdr; - __u8 *token_buf; - int token_buflen; - __u32 buflens[2], major; - int msglen, rc; - - /* get clear data length. note embedded lustre_msg might - * have been shrunk */ - if (req->rq_replen != lustre_msg_buflen(rs->rs_repbuf, 0)) - msglen = lustre_shrink_msg(rs->rs_repbuf, 0, req->rq_replen, 1); - else - msglen = lustre_msg_size_v2(rs->rs_repbuf->lm_bufcount, - rs->rs_repbuf->lm_buflens); - - /* temporarily use tail of buffer to hold gss header data */ - LASSERT(msglen + PTLRPC_GSS_HEADER_SIZE <= rs->rs_repbuf_len); - ghdr = (struct gss_header *) ((char *) rs->rs_repbuf + - rs->rs_repbuf_len - PTLRPC_GSS_HEADER_SIZE); - ghdr->gh_version = PTLRPC_GSS_VERSION; - ghdr->gh_sp = LUSTRE_SP_ANY; - ghdr->gh_flags = 0; - ghdr->gh_proc = PTLRPC_GSS_PROC_DATA; - ghdr->gh_seq = grctx->src_wirectx.gw_seq; - ghdr->gh_svc = SPTLRPC_SVC_PRIV; - ghdr->gh_handle.len = 0; - if (req->rq_pack_bulk) - ghdr->gh_flags |= LUSTRE_GSS_PACK_BULK; - - /* allocate temporary cipher buffer */ - token_buflen = gss_mech_payload(gctx->gsc_mechctx, msglen, 1); - OBD_ALLOC_LARGE(token_buf, token_buflen); - if (token_buf == NULL) - return -ENOMEM; - - hdrobj.len = PTLRPC_GSS_HEADER_SIZE; - hdrobj.data = (__u8 *) ghdr; - msgobj.len = msglen; - msgobj.data = (__u8 *) rs->rs_repbuf; - token.len = token_buflen; - token.data = token_buf; - - major = lgss_wrap(gctx->gsc_mechctx, &hdrobj, &msgobj, - rs->rs_repbuf_len - PTLRPC_GSS_HEADER_SIZE, &token); - if (major != GSS_S_COMPLETE) { - CERROR("wrap message error: %08x\n", major); - GOTO(out_free, rc = -EPERM); - } - LASSERT(token.len <= token_buflen); - - /* we are about to override data at rs->rs_repbuf, nullify pointers - * to which to catch further illegal usage. */ - if (req->rq_pack_bulk) { - grctx->src_repbsd = NULL; - grctx->src_repbsd_size = 0; - } - - /* now fill the actual wire data - * - gss header - * - gss token - */ - buflens[0] = PTLRPC_GSS_HEADER_SIZE; - buflens[1] = token.len; - - rs->rs_repdata_len = lustre_msg_size_v2(2, buflens); - LASSERT(rs->rs_repdata_len <= rs->rs_repbuf_len); - - lustre_init_msg_v2(rs->rs_repbuf, 2, buflens, NULL); - rs->rs_repbuf->lm_secflvr = req->rq_flvr.sf_rpc; - - memcpy(lustre_msg_buf(rs->rs_repbuf, 0, 0), ghdr, - PTLRPC_GSS_HEADER_SIZE); - memcpy(lustre_msg_buf(rs->rs_repbuf, 1, 0), token.data, token.len); - - /* reply offset */ - if (req->rq_packed_final && - (lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT)) - req->rq_reply_off = gss_at_reply_off_priv; - else - req->rq_reply_off = 0; - - /* to catch upper layer's further access */ - rs->rs_msg = NULL; - req->rq_repmsg = NULL; - req->rq_replen = 0; - - rc = 0; -out_free: - OBD_FREE_LARGE(token_buf, token_buflen); - return rc; -} - -int gss_svc_authorize(struct ptlrpc_request *req) -{ - struct ptlrpc_reply_state *rs = req->rq_reply_state; - struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); - struct gss_wire_ctx *gw = &grctx->src_wirectx; - int early, rc; - - early = (req->rq_packed_final == 0); - - if (!early && gss_svc_reqctx_is_special(grctx)) { - LASSERT(rs->rs_repdata_len != 0); - - req->rq_reply_off = gss_at_reply_off_integ; - return 0; - } - - /* early reply could happen in many cases */ - if (!early && - gw->gw_proc != PTLRPC_GSS_PROC_DATA && - gw->gw_proc != PTLRPC_GSS_PROC_DESTROY) { - CERROR("proc %d not support\n", gw->gw_proc); - return -EINVAL; - } - - LASSERT(grctx->src_ctx); - - switch (gw->gw_svc) { - case SPTLRPC_SVC_NULL: - case SPTLRPC_SVC_AUTH: - case SPTLRPC_SVC_INTG: - rc = gss_svc_sign(req, rs, grctx, gw->gw_svc); - break; - case SPTLRPC_SVC_PRIV: - rc = gss_svc_seal(req, rs, grctx); - break; - default: - CERROR("Unknown service %d\n", gw->gw_svc); - GOTO(out, rc = -EINVAL); - } - rc = 0; - -out: - return rc; -} - -void gss_svc_free_rs(struct ptlrpc_reply_state *rs) -{ - struct gss_svc_reqctx *grctx; - - LASSERT(rs->rs_svc_ctx); - grctx = container_of(rs->rs_svc_ctx, struct gss_svc_reqctx, src_base); - - gss_svc_reqctx_decref(grctx); - rs->rs_svc_ctx = NULL; - - if (!rs->rs_prealloc) - OBD_FREE_LARGE(rs, rs->rs_size); -} - -void gss_svc_free_ctx(struct ptlrpc_svc_ctx *ctx) -{ - LASSERT(atomic_read(&ctx->sc_refcount) == 0); - gss_svc_reqctx_free(gss_svc_ctx2reqctx(ctx)); -} - -int gss_copy_rvc_cli_ctx(struct ptlrpc_cli_ctx *cli_ctx, - struct ptlrpc_svc_ctx *svc_ctx) -{ - struct gss_cli_ctx *cli_gctx = ctx2gctx(cli_ctx); - struct gss_svc_ctx *svc_gctx = gss_svc_ctx2gssctx(svc_ctx); - struct gss_ctx *mechctx = NULL; - - LASSERT(cli_gctx); - LASSERT(svc_gctx && svc_gctx->gsc_mechctx); - - cli_gctx->gc_proc = PTLRPC_GSS_PROC_DATA; - cli_gctx->gc_win = GSS_SEQ_WIN; - - /* The problem is the reverse ctx might get lost in some recovery - * situations, and the same svc_ctx will be used to re-create it. - * if there's callback be sentout before that, new reverse ctx start - * with sequence 0 will lead to future callback rpc be treated as - * replay. - * - * each reverse root ctx will record its latest sequence number on its - * buddy svcctx before be destroyed, so here we continue use it. - */ - atomic_set(&cli_gctx->gc_seq, svc_gctx->gsc_rvs_seq); - - if (gss_svc_upcall_dup_handle(&cli_gctx->gc_svc_handle, svc_gctx)) { - CERROR("failed to dup svc handle\n"); - goto err_out; - } - - if (lgss_copy_reverse_context(svc_gctx->gsc_mechctx, &mechctx) != - GSS_S_COMPLETE) { - CERROR("failed to copy mech context\n"); - goto err_svc_handle; - } - - if (rawobj_dup(&cli_gctx->gc_handle, &svc_gctx->gsc_rvs_hdl)) { - CERROR("failed to dup reverse handle\n"); - goto err_ctx; - } - - cli_gctx->gc_mechctx = mechctx; - gss_cli_ctx_uptodate(cli_gctx); - - return 0; - -err_ctx: - lgss_delete_sec_context(&mechctx); -err_svc_handle: - rawobj_free(&cli_gctx->gc_svc_handle); -err_out: - return -ENOMEM; -} - -static void gss_init_at_reply_offset(void) -{ - __u32 buflens[3]; - int clearsize; - - buflens[0] = PTLRPC_GSS_HEADER_SIZE; - buflens[1] = lustre_msg_early_size(); - buflens[2] = gss_cli_payload(NULL, buflens[1], 0); - gss_at_reply_off_integ = lustre_msg_size_v2(3, buflens); - - buflens[0] = lustre_msg_early_size(); - clearsize = lustre_msg_size_v2(1, buflens); - buflens[0] = PTLRPC_GSS_HEADER_SIZE; - buflens[1] = gss_cli_payload(NULL, clearsize, 0); - buflens[2] = gss_cli_payload(NULL, clearsize, 1); - gss_at_reply_off_priv = lustre_msg_size_v2(3, buflens); -} - -int __init sptlrpc_gss_init(void) -{ - int rc; - - rc = gss_init_lproc(); - if (rc) - return rc; - - rc = gss_init_cli_upcall(); - if (rc) - goto out_lproc; - - rc = gss_init_svc_upcall(); - if (rc) - goto out_cli_upcall; - - rc = init_kerberos_module(); - if (rc) - goto out_svc_upcall; - - /* register policy after all other stuff be initialized, because it - * might be in used immediately after the registration. */ - - rc = gss_init_keyring(); - if (rc) - goto out_kerberos; - -#ifdef HAVE_GSS_PIPEFS - rc = gss_init_pipefs(); - if (rc) - goto out_keyring; -#endif - - gss_init_at_reply_offset(); - - return 0; - -#ifdef HAVE_GSS_PIPEFS -out_keyring: - gss_exit_keyring(); -#endif - -out_kerberos: - cleanup_kerberos_module(); -out_svc_upcall: - gss_exit_svc_upcall(); -out_cli_upcall: - gss_exit_cli_upcall(); -out_lproc: - gss_exit_lproc(); - return rc; -} - -static void __exit sptlrpc_gss_exit(void) -{ - gss_exit_keyring(); -#ifdef HAVE_GSS_PIPEFS - gss_exit_pipefs(); -#endif - cleanup_kerberos_module(); - gss_exit_svc_upcall(); - gss_exit_cli_upcall(); - gss_exit_lproc(); -} - -MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); -MODULE_DESCRIPTION("GSS security policy for Lustre"); -MODULE_LICENSE("GPL"); - -module_init(sptlrpc_gss_init); -module_exit(sptlrpc_gss_exit); diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 8573f328bd2a..f522fc5d3a93 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -40,14 +40,14 @@ #define DEBUG_SUBSYSTEM S_RPC -#include <obd_support.h> -#include <lustre_ha.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_export.h> -#include <obd.h> -#include <obd_cksum.h> -#include <obd_class.h> +#include "../include/obd_support.h" +#include "../include/lustre_ha.h" +#include "../include/lustre_net.h" +#include "../include/lustre_import.h" +#include "../include/lustre_export.h" +#include "../include/obd.h" +#include "../include/obd_cksum.h" +#include "../include/obd_class.h" #include "ptlrpc_internal.h" @@ -66,7 +66,7 @@ static void __import_set_state(struct obd_import *imp, imp->imp_state = state; imp->imp_state_hist[imp->imp_state_hist_idx].ish_state = state; imp->imp_state_hist[imp->imp_state_hist_idx].ish_time = - cfs_time_current_sec(); + get_seconds(); imp->imp_state_hist_idx = (imp->imp_state_hist_idx + 1) % IMP_STATE_HIST_LEN; } @@ -242,7 +242,7 @@ ptlrpc_inflight_deadline(struct ptlrpc_request *req, time_t now) static unsigned int ptlrpc_inflight_timeout(struct obd_import *imp) { - time_t now = cfs_time_current_sec(); + time_t now = get_seconds(); struct list_head *tmp, *n; struct ptlrpc_request *req; unsigned int timeout = 0; @@ -275,6 +275,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp) if (!imp->imp_invalid || imp->imp_obd->obd_no_recov) ptlrpc_deactivate_import(imp); + CFS_FAIL_TIMEOUT(OBD_FAIL_MGS_CONNECT_NET, 3 * cfs_fail_val / 2); LASSERT(imp->imp_invalid); /* Wait forever until inflight == 0. We really can't do it another @@ -392,6 +393,19 @@ void ptlrpc_activate_import(struct obd_import *imp) } EXPORT_SYMBOL(ptlrpc_activate_import); +static void ptlrpc_pinger_force(struct obd_import *imp) +{ + CDEBUG(D_HA, "%s: waking up pinger s:%s\n", obd2cli_tgt(imp->imp_obd), + ptlrpc_import_state_name(imp->imp_state)); + + spin_lock(&imp->imp_lock); + imp->imp_force_verify = 1; + spin_unlock(&imp->imp_lock); + + if (imp->imp_state != LUSTRE_IMP_CONNECTING) + ptlrpc_pinger_wake_up(); +} + void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt) { LASSERT(!imp->imp_dlm_fake); @@ -406,20 +420,30 @@ void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt) ptlrpc_deactivate_import(imp); } - CDEBUG(D_HA, "%s: waking up pinger\n", - obd2cli_tgt(imp->imp_obd)); - - spin_lock(&imp->imp_lock); - imp->imp_force_verify = 1; - spin_unlock(&imp->imp_lock); - - ptlrpc_pinger_wake_up(); + ptlrpc_pinger_force(imp); } } EXPORT_SYMBOL(ptlrpc_fail_import); int ptlrpc_reconnect_import(struct obd_import *imp) { +#ifdef ENABLE_PINGER + struct l_wait_info lwi; + int secs = cfs_time_seconds(obd_timeout); + int rc; + + ptlrpc_pinger_force(imp); + + CDEBUG(D_HA, "%s: recovery started, waiting %u seconds\n", + obd2cli_tgt(imp->imp_obd), secs); + + lwi = LWI_TIMEOUT(secs, NULL, NULL); + rc = l_wait_event(imp->imp_recovery_waitq, + !ptlrpc_import_in_recovery(imp), &lwi); + CDEBUG(D_HA, "%s: recovery finished s:%s\n", obd2cli_tgt(imp->imp_obd), + ptlrpc_import_state_name(imp->imp_state)); + return rc; +#else ptlrpc_set_import_discon(imp, 0); /* Force a new connect attempt */ ptlrpc_invalidate_import(imp); @@ -444,6 +468,7 @@ int ptlrpc_reconnect_import(struct obd_import *imp) /* Attempt a new connect */ ptlrpc_recover_import(imp, NULL, 0); return 0; +#endif } EXPORT_SYMBOL(ptlrpc_reconnect_import); @@ -469,7 +494,7 @@ static int import_select_connection(struct obd_import *imp) } list_for_each_entry(conn, &imp->imp_conn_list, oic_item) { - CDEBUG(D_HA, "%s: connect to NID %s last attempt "LPU64"\n", + CDEBUG(D_HA, "%s: connect to NID %s last attempt %llu\n", imp->imp_obd->obd_name, libcfs_nid2str(conn->oic_conn->c_peer.nid), conn->oic_last_attempt); @@ -817,8 +842,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, /* check that server granted subset of flags we asked for. */ if ((ocd->ocd_connect_flags & imp->imp_connect_flags_orig) != ocd->ocd_connect_flags) { - CERROR("%s: Server didn't granted asked subset of flags: " - "asked="LPX64" grranted="LPX64"\n", + CERROR("%s: Server didn't granted asked subset of flags: asked=%#llx grranted=%#llx\n", imp->imp_obd->obd_name,imp->imp_connect_flags_orig, ocd->ocd_connect_flags); GOTO(out, rc = -EPROTO); @@ -876,8 +900,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, memset(&old_hdl, 0, sizeof(old_hdl)); if (!memcmp(&old_hdl, lustre_msg_get_handle(request->rq_repmsg), sizeof(old_hdl))) { - LCONSOLE_WARN("Reconnect to %s (at @%s) failed due " - "bad handle "LPX64"\n", + LCONSOLE_WARN("Reconnect to %s (at @%s) failed due bad handle %#llx\n", obd2cli_tgt(imp->imp_obd), imp->imp_connection->c_remote_uuid.uuid, imp->imp_dlm_handle.cookie); @@ -898,9 +921,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, * participate since we can reestablish all of our state * with server again */ if ((MSG_CONNECT_RECOVERING & msg_flags)) { - CDEBUG(level,"%s@%s changed server handle from " - LPX64" to "LPX64 - " but is still in recovery\n", + CDEBUG(level,"%s@%s changed server handle from %#llx to %#llx but is still in recovery\n", obd2cli_tgt(imp->imp_obd), imp->imp_connection->c_remote_uuid.uuid, imp->imp_remote_handle.cookie, @@ -908,8 +929,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, request->rq_repmsg)->cookie); } else { LCONSOLE_WARN("Evicted from %s (at %s) " - "after server handle changed from " - LPX64" to "LPX64"\n", + "after server handle changed from %#llx to %#llx\n", obd2cli_tgt(imp->imp_obd), imp->imp_connection-> \ c_remote_uuid.uuid, @@ -973,8 +993,8 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, if (lustre_msg_get_last_committed(request->rq_repmsg) > 0 && lustre_msg_get_last_committed(request->rq_repmsg) < aa->pcaa_peer_committed) { - CERROR("%s went back in time (transno "LPD64 - " was previously committed, server now claims "LPD64 + CERROR("%s went back in time (transno %lld" + " was previously committed, server now claims %lld" ")! See https://bugzilla.lustre.org/show_bug.cgi?" "id=9646\n", obd2cli_tgt(imp->imp_obd), aa->pcaa_peer_committed, @@ -1092,9 +1112,8 @@ finish: * disable lru_resize, etc. */ if (old_connect_flags != exp_connect_flags(exp) || aa->pcaa_initial_connect) { - CDEBUG(D_HA, "%s: Resetting ns_connect_flags to server " - "flags: "LPX64"\n", imp->imp_obd->obd_name, - ocd->ocd_connect_flags); + CDEBUG(D_HA, "%s: Resetting ns_connect_flags to server flags: %#llx\n", + imp->imp_obd->obd_name, ocd->ocd_connect_flags); imp->imp_obd->obd_namespace->ns_connect_flags = ocd->ocd_connect_flags; imp->imp_obd->obd_namespace->ns_orig_connect_flags = @@ -1429,7 +1448,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) if (ptlrpc_import_in_recovery(imp)) { struct l_wait_info lwi; - cfs_duration_t timeout; + long timeout; if (AT_OFF) { if (imp->imp_server_timeout) @@ -1512,7 +1531,7 @@ extern unsigned int at_min, at_max, at_history; int at_measured(struct adaptive_timeout *at, unsigned int val) { unsigned int old = at->at_current; - time_t now = cfs_time_current_sec(); + time_t now = get_seconds(); time_t binlimit = max_t(time_t, at_history / AT_BINS, 1); LASSERT(at); diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index 41c12e00129f..511cb9cbf0d4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -53,21 +53,21 @@ #include <linux/module.h> /* LUSTRE_VERSION_CODE */ -#include <lustre_ver.h> +#include "../include/lustre_ver.h" -#include <obd_support.h> +#include "../include/obd_support.h" /* lustre_swab_mdt_body */ -#include <lustre/lustre_idl.h> +#include "../include/lustre/lustre_idl.h" /* obd2cli_tgt() (required by DEBUG_REQ()) */ -#include <obd.h> +#include "../include/obd.h" /* __REQ_LAYOUT_USER__ */ #endif /* struct ptlrpc_request, lustre_msg* */ -#include <lustre_req_layout.h> -#include <lustre_update.h> -#include <lustre_acl.h> -#include <lustre_debug.h> +#include "../include/lustre_req_layout.h" +#include "../include/lustre_update.h" +#include "../include/lustre_acl.h" +#include "../include/lustre_debug.h" /* * RQFs (see below) refer to two struct req_msg_field arrays describing the diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index ab084541fddb..6a1ab5c98bc6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -42,11 +42,11 @@ #define DEBUG_SUBSYSTEM S_LOG -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd_class.h> -#include <lustre_log.h> -#include <lustre_net.h> +#include "../include/obd_class.h" +#include "../include/lustre_log.h" +#include "../include/lustre_net.h" #include <linux/list.h> #define LLOG_CLIENT_ENTRY(ctxt, imp) do { \ diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c index 17c06a32df62..e9052bba6692 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c @@ -46,13 +46,13 @@ #define DEBUG_SUBSYSTEM S_LOG -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd_class.h> -#include <lustre_log.h> +#include "../include/obd_class.h" +#include "../include/lustre_log.h" #include <linux/list.h> -#include <lvfs.h> -#include <lustre_fsfilt.h> +#include "../include/lvfs.h" +#include "../include/lustre_fsfilt.h" int llog_initiator_connect(struct llog_ctxt *ctxt) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 6b9c6db1f2df..bc220308e7d7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -36,12 +36,12 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <obd_support.h> -#include <obd.h> -#include <lprocfs_status.h> -#include <lustre/lustre_idl.h> -#include <lustre_net.h> -#include <obd_class.h> +#include "../include/obd_support.h" +#include "../include/obd.h" +#include "../include/lprocfs_status.h" +#include "../include/lustre/lustre_idl.h" +#include "../include/lustre_net.h" +#include "../include/obd_class.h" #include "ptlrpc_internal.h" @@ -180,7 +180,7 @@ const char* ll_eopcode2str(__u32 opcode) LASSERT(ll_eopcode_table[opcode].opcode == opcode); return ll_eopcode_table[opcode].opname; } -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir, char *name, struct proc_dir_entry **procroot_ret, struct lprocfs_stats **stats_ret) @@ -628,7 +628,8 @@ out: * if the optional token is omitted, the operation is performed on both the * regular and high-priority (if the service has one) NRS head. */ -static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, const char *buffer, +static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, + const char __user *buffer, size_t count, loff_t *off) { struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; @@ -726,12 +727,12 @@ ptlrpc_lprocfs_svc_req_history_seek(struct ptlrpc_service_part *svcpt, * be near the head), we shouldn't have to do long * re-scans */ LASSERTF(srhi->srhi_seq == srhi->srhi_req->rq_history_seq, - "%s:%d: seek seq "LPU64", request seq "LPU64"\n", + "%s:%d: seek seq %llu, request seq %llu\n", svcpt->scp_service->srv_name, svcpt->scp_cpt, srhi->srhi_seq, srhi->srhi_req->rq_history_seq); LASSERTF(!list_empty(&svcpt->scp_hist_reqs), - "%s:%d: seek offset "LPU64", request seq "LPU64", " - "last culled "LPU64"\n", + "%s:%d: seek offset %llu, request seq %llu, " + "last culled %llu\n", svcpt->scp_service->srv_name, svcpt->scp_cpt, seq, srhi->srhi_seq, svcpt->scp_hist_seq_culled); e = &srhi->srhi_req->rq_history_list; @@ -932,7 +933,7 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter) * must be just as careful as the service's request * parser. Currently I only print stuff here I know is OK * to look at coz it was set up in request_in_callback()!!! */ - seq_printf(s, LPD64":%s:%s:x"LPU64":%d:%s:%ld:%lds(%+lds) ", + seq_printf(s, "%lld:%s:%s:x%llu:%d:%s:%ld:%lds(%+lds) ", req->rq_history_seq, libcfs_nid2str(req->rq_self), libcfs_id2str(req->rq_peer), req->rq_xid, req->rq_reqlen, ptlrpc_rqphase2str(req), @@ -991,7 +992,7 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) cur = at_get(&svcpt->scp_at_estimate); worst = svcpt->scp_at_estimate.at_worst_ever; worstt = svcpt->scp_at_estimate.at_worst_time; - s2dhms(&ts, cfs_time_current_sec() - worstt); + s2dhms(&ts, get_seconds() - worstt); seq_printf(m, "%10s : cur %3u worst %3u (at %ld, " DHMS_FMT" ago) ", "service", @@ -1339,4 +1340,4 @@ int lprocfs_wr_pinger_recov(struct file *file, const char *buffer, } EXPORT_SYMBOL(lprocfs_wr_pinger_recov); -#endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index a47a8d807d5b..89fc7f77b498 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -35,11 +35,11 @@ */ #define DEBUG_SUBSYSTEM S_RPC -#include <obd_support.h> -#include <lustre_net.h> -#include <lustre_lib.h> -#include <obd.h> -#include <obd_class.h> +#include "../include/obd_support.h" +#include "../include/lustre_net.h" +#include "../include/lustre_lib.h" +#include "../include/obd.h" +#include "../include/obd_class.h" #include "ptlrpc_internal.h" /** @@ -79,7 +79,7 @@ static int ptl_send_buf(lnet_handle_md_t *mdh, void *base, int len, return -ENOMEM; } - CDEBUG(D_NET, "Sending %d bytes to portal %d, xid "LPD64", offset %u\n", + CDEBUG(D_NET, "Sending %d bytes to portal %d, xid %lld, offset %u\n", len, portal, xid, offset); rc = LNetPut(conn->c_self, *mdh, ack, @@ -89,7 +89,7 @@ static int ptl_send_buf(lnet_handle_md_t *mdh, void *base, int len, /* We're going to get an UNLINK event when I unlink below, * which will complete just like any other failed send, so * I fall through and return success here! */ - CERROR("LNetPut(%s, %d, "LPD64") failed: %d\n", + CERROR("LNetPut(%s, %d, %lld) failed: %d\n", libcfs_id2str(conn->c_peer), portal, xid, rc); rc2 = LNetMDUnlink(*mdh); LASSERTF(rc2 == 0, "rc2 = %d\n", rc2); @@ -159,7 +159,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) LASSERTF(!(desc->bd_registered && req->rq_send_state != LUSTRE_IMP_REPLAY) || xid != desc->bd_last_xid, - "registered: %d rq_xid: "LPU64" bd_last_xid: "LPU64"\n", + "registered: %d rq_xid: %llu bd_last_xid: %llu\n", desc->bd_registered, xid, desc->bd_last_xid); total_md = (desc->bd_iov_count + LNET_MAX_IOV - 1) / LNET_MAX_IOV; @@ -179,7 +179,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) rc = LNetMEAttach(desc->bd_portal, peer, xid, 0, LNET_UNLINK, LNET_INS_AFTER, &me_h); if (rc != 0) { - CERROR("%s: LNetMEAttach failed x"LPU64"/%d: rc = %d\n", + CERROR("%s: LNetMEAttach failed x%llu/%d: rc = %d\n", desc->bd_import->imp_obd->obd_name, xid, posted_md, rc); break; @@ -189,7 +189,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) rc = LNetMDAttach(me_h, md, LNET_UNLINK, &desc->bd_mds[posted_md]); if (rc != 0) { - CERROR("%s: LNetMDAttach failed x"LPU64"/%d: rc = %d\n", + CERROR("%s: LNetMDAttach failed x%llu/%d: rc = %d\n", desc->bd_import->imp_obd->obd_name, xid, posted_md, rc); rc2 = LNetMEUnlink(me_h); @@ -213,7 +213,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) * infer the number of bulks that were prepared */ req->rq_xid = --xid; LASSERTF(desc->bd_last_xid == (req->rq_xid & PTLRPC_BULK_OPS_MASK), - "bd_last_xid = x"LPU64", rq_xid = x"LPU64"\n", + "bd_last_xid = x%llu, rq_xid = x%llu\n", desc->bd_last_xid, req->rq_xid); spin_lock(&desc->bd_lock); @@ -225,7 +225,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) spin_unlock(&desc->bd_lock); CDEBUG(D_NET, "Setup %u bulk %s buffers: %u pages %u bytes, " - "xid x"LPX64"-"LPX64", portal %u\n", desc->bd_md_count, + "xid x%#llx-%#llx, portal %u\n", desc->bd_md_count, desc->bd_type == BULK_GET_SOURCE ? "get-source" : "put-sink", desc->bd_iov_count, desc->bd_nob, desc->bd_last_xid, req->rq_xid, desc->bd_portal); @@ -252,7 +252,7 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) /* Let's setup deadline for reply unlink. */ if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK) && async && req->rq_bulk_deadline == 0) - req->rq_bulk_deadline = cfs_time_current_sec() + LONG_UNLINK; + req->rq_bulk_deadline = get_seconds() + LONG_UNLINK; if (ptlrpc_client_bulk_active(req) == 0) /* completed or */ return 1; /* never registered */ @@ -303,7 +303,7 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags) { struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; struct ptlrpc_service *svc = svcpt->scp_service; - int service_time = max_t(int, cfs_time_current_sec() - + int service_time = max_t(int, get_seconds() - req->rq_arrival_time.tv_sec, 1); if (!(flags & PTLRPC_REPLY_EARLY) && @@ -422,7 +422,7 @@ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags) if (unlikely(rc)) goto out; - req->rq_sent = cfs_time_current_sec(); + req->rq_sent = get_seconds(); rc = ptl_send_buf(&rs->rs_md_h, rs->rs_repbuf, rs->rs_repdata_len, (rs->rs_difficult && !rs->rs_no_ack) ? @@ -505,11 +505,12 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) /* If this is a re-transmit, we're required to have disengaged * cleanly from the previous attempt */ LASSERT(!request->rq_receiving_reply); + LASSERT(!((lustre_msg_get_flags(request->rq_reqmsg) & MSG_REPLAY) && + (request->rq_import->imp_state == LUSTRE_IMP_FULL))); - if (request->rq_import->imp_obd && - request->rq_import->imp_obd->obd_fail) { + if (unlikely(obd != NULL && obd->obd_fail)) { CDEBUG(D_HA, "muting rpc for failed imp obd %s\n", - request->rq_import->imp_obd->obd_name); + obd->obd_name); /* this prevents us from waiting in ptlrpc_queue_wait */ spin_lock(&request->rq_lock); request->rq_err = 1; @@ -579,8 +580,9 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) spin_lock(&request->rq_lock); /* If the MD attach succeeds, there _will_ be a reply_in callback */ request->rq_receiving_reply = !noreply; + request->rq_req_unlink = 1; /* We are responsible for unlinking the reply buffer */ - request->rq_must_unlink = !noreply; + request->rq_reply_unlink = !noreply; /* Clear any flags that may be present from previous sends. */ request->rq_replied = 0; request->rq_err = 0; @@ -603,7 +605,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) reply_md.user_ptr = &request->rq_reply_cbid; reply_md.eq_handle = ptlrpc_eq_h; - /* We must see the unlink callback to unset rq_must_unlink, + /* We must see the unlink callback to unset rq_reply_unlink, so we can't auto-unlink */ rc = LNetMDAttach(reply_me_h, reply_md, LNET_RETAIN, &request->rq_reply_md_h); @@ -617,22 +619,21 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) GOTO(cleanup_me, rc = -ENOMEM); } - CDEBUG(D_NET, "Setup reply buffer: %u bytes, xid "LPU64 - ", portal %u\n", + CDEBUG(D_NET, "Setup reply buffer: %u bytes, xid %llu, portal %u\n", request->rq_repbuf_len, request->rq_xid, request->rq_reply_portal); } /* add references on request for request_out_callback */ ptlrpc_request_addref(request); - if (obd->obd_svc_stats != NULL) + if (obd != NULL && obd->obd_svc_stats != NULL) lprocfs_counter_add(obd->obd_svc_stats, PTLRPC_REQACTIVE_CNTR, atomic_read(&request->rq_import->imp_inflight)); OBD_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_SEND, request->rq_timeout + 5); do_gettimeofday(&request->rq_arrival_time); - request->rq_sent = cfs_time_current_sec(); + request->rq_sent = get_seconds(); /* We give the server rq_timeout secs to process the req, and add the network latency for our local timeout. */ request->rq_deadline = request->rq_sent + request->rq_timeout + diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 12151aa2a1e5..9ea24f8d9865 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -40,11 +40,11 @@ */ #define DEBUG_SUBSYSTEM S_RPC -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_net.h> -#include <lprocfs_status.h> -#include <linux/libcfs/libcfs.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_net.h" +#include "../include/lprocfs_status.h" +#include "../../include/linux/libcfs/libcfs.h" #include "ptlrpc_internal.h" /* XXX: This is just for liblustre. Remove the #if defined directive when the diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c index 7d3ee9706c9b..28363307ee35 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c @@ -47,9 +47,9 @@ */ #define DEBUG_SUBSYSTEM S_RPC -#include <obd_support.h> -#include <obd_class.h> -#include <linux/libcfs/libcfs.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../../include/linux/libcfs/libcfs.h" #include "ptlrpc_internal.h" /** @@ -174,9 +174,9 @@ struct ptlrpc_nrs_request * nrs_fifo_req_get(struct ptlrpc_nrs_policy *policy, list_del_init(&nrq->nr_u.fifo.fr_list); - CDEBUG(D_RPCTRACE, "NRS start %s request from %s, seq: "LPU64 - "\n", policy->pol_desc->pd_name, - libcfs_id2str(req->rq_peer), nrq->nr_u.fifo.fr_sequence); + CDEBUG(D_RPCTRACE, "NRS start %s request from %s, seq: %llu\n", + policy->pol_desc->pd_name, libcfs_id2str(req->rq_peer), + nrq->nr_u.fifo.fr_sequence); } return nrq; @@ -236,7 +236,7 @@ static void nrs_fifo_req_stop(struct ptlrpc_nrs_policy *policy, struct ptlrpc_request *req = container_of(nrq, struct ptlrpc_request, rq_nrq); - CDEBUG(D_RPCTRACE, "NRS stop %s request from %s, seq: "LPU64"\n", + CDEBUG(D_RPCTRACE, "NRS stop %s request from %s, seq: %llu\n", policy->pol_desc->pd_name, libcfs_id2str(req->rq_peer), nrq->nr_u.fifo.fr_sequence); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index cddeeb6bb23d..ac562932ccdf 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -44,13 +44,13 @@ #define DEBUG_SUBSYSTEM S_RPC -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_net.h> -#include <obd_cksum.h> -#include <lustre/ll_fiemap.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_net.h" +#include "../include/obd_cksum.h" +#include "../include/lustre/ll_fiemap.h" static inline int lustre_msg_hdr_size_v2(int count) { @@ -2140,8 +2140,8 @@ static void print_lum(struct lov_user_md *lum) CDEBUG(D_OTHER, "lov_user_md %p:\n", lum); CDEBUG(D_OTHER, "\tlmm_magic: %#x\n", lum->lmm_magic); CDEBUG(D_OTHER, "\tlmm_pattern: %#x\n", lum->lmm_pattern); - CDEBUG(D_OTHER, "\tlmm_object_id: "LPU64"\n", lmm_oi_id(&lum->lmm_oi)); - CDEBUG(D_OTHER, "\tlmm_object_gr: "LPU64"\n", lmm_oi_seq(&lum->lmm_oi)); + CDEBUG(D_OTHER, "\tlmm_object_id: %llu\n", lmm_oi_id(&lum->lmm_oi)); + CDEBUG(D_OTHER, "\tlmm_object_gr: %llu\n", lmm_oi_seq(&lum->lmm_oi)); CDEBUG(D_OTHER, "\tlmm_stripe_size: %#x\n", lum->lmm_stripe_size); CDEBUG(D_OTHER, "\tlmm_stripe_count: %#x\n", lum->lmm_stripe_count); CDEBUG(D_OTHER, "\tlmm_stripe_offset/lmm_layout_gen: %#x\n", @@ -2292,7 +2292,7 @@ EXPORT_SYMBOL(dump_ioo); void dump_rniobuf(struct niobuf_remote *nb) { - CDEBUG(D_RPCTRACE, "niobuf_remote: offset="LPU64", len=%d, flags=%x\n", + CDEBUG(D_RPCTRACE, "niobuf_remote: offset=%llu, len=%d, flags=%x\n", nb->offset, nb->len, nb->flags); } EXPORT_SYMBOL(dump_rniobuf); @@ -2305,20 +2305,20 @@ void dump_obdo(struct obdo *oa) if (valid & OBD_MD_FLID) CDEBUG(D_RPCTRACE, "obdo: id = "DOSTID"\n", POSTID(&oa->o_oi)); if (valid & OBD_MD_FLFID) - CDEBUG(D_RPCTRACE, "obdo: o_parent_seq = "LPX64"\n", + CDEBUG(D_RPCTRACE, "obdo: o_parent_seq = %#llx\n", oa->o_parent_seq); if (valid & OBD_MD_FLSIZE) - CDEBUG(D_RPCTRACE, "obdo: o_size = "LPD64"\n", oa->o_size); + CDEBUG(D_RPCTRACE, "obdo: o_size = %lld\n", oa->o_size); if (valid & OBD_MD_FLMTIME) - CDEBUG(D_RPCTRACE, "obdo: o_mtime = "LPD64"\n", oa->o_mtime); + CDEBUG(D_RPCTRACE, "obdo: o_mtime = %lld\n", oa->o_mtime); if (valid & OBD_MD_FLATIME) - CDEBUG(D_RPCTRACE, "obdo: o_atime = "LPD64"\n", oa->o_atime); + CDEBUG(D_RPCTRACE, "obdo: o_atime = %lld\n", oa->o_atime); if (valid & OBD_MD_FLCTIME) - CDEBUG(D_RPCTRACE, "obdo: o_ctime = "LPD64"\n", oa->o_ctime); + CDEBUG(D_RPCTRACE, "obdo: o_ctime = %lld\n", oa->o_ctime); if (valid & OBD_MD_FLBLOCKS) /* allocation of space */ - CDEBUG(D_RPCTRACE, "obdo: o_blocks = "LPD64"\n", oa->o_blocks); + CDEBUG(D_RPCTRACE, "obdo: o_blocks = %lld\n", oa->o_blocks); if (valid & OBD_MD_FLGRANT) - CDEBUG(D_RPCTRACE, "obdo: o_grant = "LPD64"\n", oa->o_grant); + CDEBUG(D_RPCTRACE, "obdo: o_grant = %lld\n", oa->o_grant); if (valid & OBD_MD_FLBLKSZ) CDEBUG(D_RPCTRACE, "obdo: o_blksize = %d\n", oa->o_blksize); if (valid & (OBD_MD_FLTYPE | OBD_MD_FLMODE)) @@ -2344,7 +2344,7 @@ void dump_obdo(struct obdo *oa) CDEBUG(D_RPCTRACE, "obdo: o_parent_oid = %x\n", oa->o_parent_oid); if (valid & OBD_MD_FLEPOCH) - CDEBUG(D_RPCTRACE, "obdo: o_ioepoch = "LPD64"\n", + CDEBUG(D_RPCTRACE, "obdo: o_ioepoch = %lld\n", oa->o_ioepoch); if (valid & OBD_MD_FLFID) { CDEBUG(D_RPCTRACE, "obdo: o_stripe_idx = %u\n", @@ -2353,7 +2353,7 @@ void dump_obdo(struct obdo *oa) oa->o_parent_ver); } if (valid & OBD_MD_FLHANDLE) - CDEBUG(D_RPCTRACE, "obdo: o_handle = "LPD64"\n", + CDEBUG(D_RPCTRACE, "obdo: o_handle = %lld\n", oa->o_handle.cookie); if (valid & OBD_MD_FLCOOKIE) CDEBUG(D_RPCTRACE, "obdo: o_lcookie = " @@ -2421,7 +2421,7 @@ void _debug_req(struct ptlrpc_request *req, va_start(args, fmt); libcfs_debug_vmsg2(msgdata, fmt, args, - " req@%p x"LPU64"/t"LPD64"("LPD64") o%d->%s@%s:%d/%d" + " req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d" " lens %d/%d e %d to %d dl "CFS_TIME_T" ref %d " "fl "REQ_FLAGS_FMT"/%x/%x rc %d/%d\n", req, req->rq_xid, req->rq_transno, diff --git a/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c index d926d2b36fb4..e1334c24ebe3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pers.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pers.c @@ -34,11 +34,11 @@ #define DEBUG_SUBSYSTEM S_RPC -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_lib.h> -#include <lustre_ha.h> -#include <lustre_import.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_lib.h" +#include "../include/lustre_ha.h" +#include "../include/lustre_import.h" #include "ptlrpc_internal.h" diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 38099d9dfdae..5e4e49fab63c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -40,8 +40,8 @@ #define DEBUG_SUBSYSTEM S_RPC -#include <obd_support.h> -#include <obd_class.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" #include "ptlrpc_internal.h" static int suppress_pings; @@ -141,10 +141,10 @@ static inline int ptlrpc_next_reconnect(struct obd_import *imp) return cfs_time_shift(obd_timeout); } -cfs_duration_t pinger_check_timeout(cfs_time_t time) +long pinger_check_timeout(unsigned long time) { struct timeout_item *item; - cfs_time_t timeout = PING_INTERVAL; + unsigned long timeout = PING_INTERVAL; /* The timeout list is a increase order sorted list */ mutex_lock(&pinger_mutex); @@ -224,6 +224,11 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp, "or recovery disabled: %s)\n", imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd), ptlrpc_import_state_name(level)); + if (force) { + spin_lock(&imp->imp_lock); + imp->imp_force_verify = 1; + spin_unlock(&imp->imp_lock); + } } else if ((imp->imp_pingable && !suppress) || force_next || force) { ptlrpc_ping(imp); } @@ -239,9 +244,9 @@ static int ptlrpc_pinger_main(void *arg) /* And now, loop forever, pinging as needed. */ while (1) { - cfs_time_t this_ping = cfs_time_current(); + unsigned long this_ping = cfs_time_current(); struct l_wait_info lwi; - cfs_duration_t time_to_next_wake; + long time_to_next_wake; struct timeout_item *item; struct list_head *iter; @@ -278,8 +283,7 @@ static int ptlrpc_pinger_main(void *arg) CFS_TIME_T")\n", time_to_next_wake, cfs_time_add(this_ping,cfs_time_seconds(PING_INTERVAL))); if (time_to_next_wake > 0) { - lwi = LWI_TIMEOUT(max_t(cfs_duration_t, - time_to_next_wake, + lwi = LWI_TIMEOUT(max_t(long, time_to_next_wake, cfs_time_seconds(1)), NULL, NULL); l_wait_event(thread->t_ctl_waitq, @@ -601,7 +605,7 @@ static int ping_evictor_main(void *arg) obd_evict_list); spin_unlock(&pet_lock); - expire_time = cfs_time_current_sec() - PING_EVICT_TIMEOUT; + expire_time = get_seconds() - PING_EVICT_TIMEOUT; CDEBUG(D_HA, "evicting all exports of obd %s older than %ld\n", obd->obd_name, expire_time); @@ -626,9 +630,9 @@ static int ping_evictor_main(void *arg) obd->obd_name, obd_uuid2str(&exp->exp_client_uuid), obd_export_nid2str(exp), - (long)(cfs_time_current_sec() - + (long)(get_seconds() - exp->exp_last_request_time), - exp, (long)cfs_time_current_sec(), + exp, (long)get_seconds(), (long)expire_time, (long)exp->exp_last_request_time); CDEBUG(D_HA, "Last request was at %ld\n", diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index 7c9405530596..f7be007c88cb 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -76,7 +76,7 @@ void ptlrpc_initiate_recovery(struct obd_import *imp); int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset); int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset); -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry, struct ptlrpc_service *svc); void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc); @@ -88,7 +88,7 @@ void ptlrpc_lprocfs_do_request_stat(struct ptlrpc_request *req, #define ptlrpc_lprocfs_unregister_service(params...) do {} while (0) #define ptlrpc_lprocfs_rpc_sent(params...) do {} while (0) #define ptlrpc_lprocfs_do_request_stat(params...) do {} while (0) -#endif /* LPROCFS */ +#endif /* CONFIG_PROC_FS */ /* NRS */ @@ -263,7 +263,7 @@ void sptlrpc_enc_pool_fini(void); int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v); /* sec_lproc.c */ -#ifdef LPROCFS +#if defined (CONFIG_PROC_FS) int sptlrpc_lproc_init(void); void sptlrpc_lproc_fini(void); #else diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c index 251ae75c2dd9..6d92a56da620 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c @@ -37,10 +37,10 @@ #define DEBUG_SUBSYSTEM S_RPC -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_net.h> -#include <lustre_req_layout.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_net.h" +#include "../include/lustre_req_layout.h" #include "ptlrpc_internal.h" diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index ca734ce079c1..9c60e2af43bf 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -55,16 +55,15 @@ #define DEBUG_SUBSYSTEM S_RPC -# include <linux/libcfs/libcfs.h> - -#include <lustre_net.h> -# include <lustre_lib.h> - -#include <lustre_ha.h> -#include <obd_class.h> /* for obd_zombie */ -#include <obd_support.h> /* for OBD_FAIL_CHECK */ -#include <cl_object.h> /* cl_env_{get,put}() */ -#include <lprocfs_status.h> +#include "../../include/linux/libcfs/libcfs.h" + +#include "../include/lustre_net.h" +#include "../include/lustre_lib.h" +#include "../include/lustre_ha.h" +#include "../include/obd_class.h" /* for obd_zombie */ +#include "../include/obd_support.h" /* for OBD_FAIL_CHECK */ +#include "../include/cl_object.h" /* cl_env_{get,put}() */ +#include "../include/lprocfs_status.h" #include "ptlrpc_internal.h" diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index 9cec8a649dc3..5e4a1a52e0da 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -39,16 +39,16 @@ */ #define DEBUG_SUBSYSTEM S_RPC -# include <linux/libcfs/libcfs.h> - -#include <obd_support.h> -#include <lustre_ha.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_export.h> -#include <obd.h> -#include <obd_ost.h> -#include <obd_class.h> +#include "../../include/linux/libcfs/libcfs.h" + +#include "../include/obd_support.h" +#include "../include/lustre_ha.h" +#include "../include/lustre_net.h" +#include "../include/lustre_import.h" +#include "../include/lustre_export.h" +#include "../include/obd.h" +#include "../include/obd_ost.h" +#include "../include/obd_class.h" #include <linux/list.h> #include "ptlrpc_internal.h" @@ -85,7 +85,7 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) last_transno = imp->imp_last_replay_transno; spin_unlock(&imp->imp_lock); - CDEBUG(D_HA, "import %p from %s committed "LPU64" last "LPU64"\n", + CDEBUG(D_HA, "import %p from %s committed %llu last %llu\n", imp, obd2cli_tgt(imp->imp_obd), imp->imp_peer_committed_transno, last_transno); @@ -164,8 +164,8 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) if (req != NULL) { rc = ptlrpc_replay_req(req); if (rc) { - CERROR("recovery replay error %d for req " - LPU64"\n", rc, req->rq_xid); + CERROR("recovery replay error %d for req %llu\n", + rc, req->rq_xid); return rc; } *inflight = 1; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 28ac824a73fb..5cff7ee6ee7b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -40,17 +40,17 @@ #define DEBUG_SUBSYSTEM S_SEC -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" #include <linux/crypto.h> #include <linux/key.h> -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_dlm.h> -#include <lustre_sec.h> +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/lustre_net.h" +#include "../include/lustre_import.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_sec.h" #include "ptlrpc_internal.h" @@ -305,8 +305,8 @@ EXPORT_SYMBOL(sptlrpc_cli_ctx_put); */ void sptlrpc_cli_ctx_expire(struct ptlrpc_cli_ctx *ctx) { - LASSERT(ctx->cc_ops->die); - ctx->cc_ops->die(ctx, 0); + LASSERT(ctx->cc_ops->force_die); + ctx->cc_ops->force_die(ctx, 0); } EXPORT_SYMBOL(sptlrpc_cli_ctx_expire); @@ -344,7 +344,7 @@ static int import_sec_check_expire(struct obd_import *imp) spin_lock(&imp->imp_lock); if (imp->imp_sec_expire && - imp->imp_sec_expire < cfs_time_current_sec()) { + imp->imp_sec_expire < get_seconds()) { adapt = 1; imp->imp_sec_expire = 0; } @@ -591,7 +591,7 @@ int ctx_refresh_timeout(void *data) * later than the context refresh expire time. */ if (rc == 0) - req->rq_cli_ctx->cc_ops->die(req->rq_cli_ctx, 0); + req->rq_cli_ctx->cc_ops->force_die(req->rq_cli_ctx, 0); return rc; } @@ -992,7 +992,7 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) case 0: break; default: - CERROR("failed unpack reply: x"LPU64"\n", req->rq_xid); + CERROR("failed unpack reply: x%llu\n", req->rq_xid); return -EPROTO; } @@ -1774,7 +1774,7 @@ int sptlrpc_target_export_check(struct obd_export *exp, exp->exp_flvr_old[1] = exp->exp_flvr_old[0]; exp->exp_flvr_expire[1] = exp->exp_flvr_expire[0]; exp->exp_flvr_old[0] = exp->exp_flvr; - exp->exp_flvr_expire[0] = cfs_time_current_sec() + + exp->exp_flvr_expire[0] = get_seconds() + EXP_FLVR_UPDATE_EXPIRE; exp->exp_flvr = flavor; @@ -1848,7 +1848,7 @@ int sptlrpc_target_export_check(struct obd_export *exp, } if (exp->exp_flvr_expire[0]) { - if (exp->exp_flvr_expire[0] >= cfs_time_current_sec()) { + if (exp->exp_flvr_expire[0] >= get_seconds()) { if (flavor_allowed(&exp->exp_flvr_old[0], req)) { CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the " "middle one ("CFS_DURATION_T")\n", exp, @@ -1856,7 +1856,7 @@ int sptlrpc_target_export_check(struct obd_export *exp, exp->exp_flvr_old[0].sf_rpc, exp->exp_flvr_old[1].sf_rpc, exp->exp_flvr_expire[0] - - cfs_time_current_sec()); + get_seconds()); spin_unlock(&exp->exp_lock); return 0; } @@ -1873,7 +1873,7 @@ int sptlrpc_target_export_check(struct obd_export *exp, /* now it doesn't match the current flavor, the only chance we can * accept it is match the old flavors which is not expired. */ if (exp->exp_flvr_changed == 0 && exp->exp_flvr_expire[1]) { - if (exp->exp_flvr_expire[1] >= cfs_time_current_sec()) { + if (exp->exp_flvr_expire[1] >= get_seconds()) { if (flavor_allowed(&exp->exp_flvr_old[1], req)) { CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the " "oldest one ("CFS_DURATION_T")\n", exp, @@ -1881,7 +1881,7 @@ int sptlrpc_target_export_check(struct obd_export *exp, exp->exp_flvr_old[0].sf_rpc, exp->exp_flvr_old[1].sf_rpc, exp->exp_flvr_expire[1] - - cfs_time_current_sec()); + get_seconds()); spin_unlock(&exp->exp_lock); return 0; } @@ -1911,11 +1911,11 @@ int sptlrpc_target_export_check(struct obd_export *exp, exp->exp_flvr_old[0].sf_rpc, exp->exp_flvr_expire[0] ? (unsigned long) (exp->exp_flvr_expire[0] - - cfs_time_current_sec()) : 0, + get_seconds()) : 0, exp->exp_flvr_old[1].sf_rpc, exp->exp_flvr_expire[1] ? (unsigned long) (exp->exp_flvr_expire[1] - - cfs_time_current_sec()) : 0); + get_seconds()) : 0); return -EACCES; } EXPORT_SYMBOL(sptlrpc_target_export_check); @@ -2033,7 +2033,7 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) case 0: break; default: - CERROR("error unpacking request from %s x"LPU64"\n", + CERROR("error unpacking request from %s x%llu\n", libcfs_id2str(req->rq_peer), req->rq_xid); return SECSVC_DROP; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 9d51badea73d..874789b200a3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -40,17 +40,17 @@ #define DEBUG_SUBSYSTEM S_SEC -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" #include <linux/crypto.h> -#include <obd.h> -#include <obd_cksum.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_dlm.h> -#include <lustre_sec.h> +#include "../include/obd.h" +#include "../include/obd_cksum.h" +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/lustre_net.h" +#include "../include/lustre_import.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_sec.h" #include "ptlrpc_internal.h" @@ -113,7 +113,7 @@ static struct ptlrpc_enc_page_pool { unsigned long epp_st_missings; /* # of cache missing */ unsigned long epp_st_lowfree; /* lowest free pages reached */ unsigned int epp_st_max_wqlen; /* highest waitqueue length */ - cfs_time_t epp_st_max_wait; /* in jiffies */ + unsigned long epp_st_max_wait; /* in jiffies */ /* * pointers to pools */ @@ -156,8 +156,8 @@ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v) page_pools.epp_total_pages, page_pools.epp_free_pages, page_pools.epp_idle_idx, - cfs_time_current_sec() - page_pools.epp_last_shrink, - cfs_time_current_sec() - page_pools.epp_last_access, + get_seconds() - page_pools.epp_last_shrink, + get_seconds() - page_pools.epp_last_access, page_pools.epp_st_max_pages, page_pools.epp_st_grows, page_pools.epp_st_grow_fails, @@ -228,7 +228,7 @@ static unsigned long enc_pools_shrink_count(struct shrinker *s, * if no pool access for a long time, we consider it's fully idle. * a little race here is fine. */ - if (unlikely(cfs_time_current_sec() - page_pools.epp_last_access > + if (unlikely(get_seconds() - page_pools.epp_last_access > CACHE_QUIESCENT_PERIOD)) { spin_lock(&page_pools.epp_lock); page_pools.epp_idle_idx = IDLE_IDX_MAX; @@ -255,7 +255,7 @@ static unsigned long enc_pools_shrink_scan(struct shrinker *s, (long)sc->nr_to_scan, page_pools.epp_free_pages); page_pools.epp_st_shrinks++; - page_pools.epp_last_shrink = cfs_time_current_sec(); + page_pools.epp_last_shrink = get_seconds(); } spin_unlock(&page_pools.epp_lock); @@ -263,7 +263,7 @@ static unsigned long enc_pools_shrink_scan(struct shrinker *s, * if no pool access for a long time, we consider it's fully idle. * a little race here is fine. */ - if (unlikely(cfs_time_current_sec() - page_pools.epp_last_access > + if (unlikely(get_seconds() - page_pools.epp_last_access > CACHE_QUIESCENT_PERIOD)) { spin_lock(&page_pools.epp_lock); page_pools.epp_idle_idx = IDLE_IDX_MAX; @@ -498,7 +498,7 @@ int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc) { wait_queue_t waitlink; unsigned long this_idle = -1; - cfs_time_t tick = 0; + unsigned long tick = 0; long now; int p_idx, g_idx; int i; @@ -523,7 +523,7 @@ again: if (tick == 0) tick = cfs_time_current(); - now = cfs_time_current_sec(); + now = get_seconds(); page_pools.epp_st_missings++; page_pools.epp_pages_short += desc->bd_iov_count; @@ -602,7 +602,7 @@ again: this_idle) / (IDLE_IDX_WEIGHT + 1); - page_pools.epp_last_access = cfs_time_current_sec(); + page_pools.epp_last_access = get_seconds(); spin_unlock(&page_pools.epp_lock); return 0; @@ -729,8 +729,8 @@ int sptlrpc_enc_pool_init(void) page_pools.epp_growing = 0; page_pools.epp_idle_idx = 0; - page_pools.epp_last_shrink = cfs_time_current_sec(); - page_pools.epp_last_access = cfs_time_current_sec(); + page_pools.epp_last_shrink = get_seconds(); + page_pools.epp_last_access = get_seconds(); spin_lock_init(&page_pools.epp_lock); page_pools.epp_total_pages = 0; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index 231656ed7660..01f8b0d6660e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -36,20 +36,20 @@ #define DEBUG_SUBSYSTEM S_SEC -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" #include <linux/crypto.h> #include <linux/key.h> -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_log.h> -#include <lustre_disk.h> -#include <lustre_dlm.h> -#include <lustre_param.h> -#include <lustre_sec.h> +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/lustre_net.h" +#include "../include/lustre_import.h" +#include "../include/lustre_log.h" +#include "../include/lustre_disk.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_param.h" +#include "../include/lustre_sec.h" #include "ptlrpc_internal.h" @@ -918,7 +918,7 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd) if (imp) { spin_lock(&imp->imp_lock); if (imp->imp_sec) - imp->imp_sec_expire = cfs_time_current_sec() + + imp->imp_sec_expire = get_seconds() + SEC_ADAPT_DELAY; spin_unlock(&imp->imp_lock); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index d2eb20eb56db..c500aff66193 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c @@ -40,12 +40,12 @@ #define DEBUG_SUBSYSTEM S_SEC -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_net.h> -#include <lustre_sec.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_net.h" +#include "../include/lustre_sec.h" #define SEC_GC_INTERVAL (30 * 60) @@ -67,7 +67,7 @@ void sptlrpc_gc_add_sec(struct ptlrpc_sec *sec) LASSERT(sec->ps_gc_interval > 0); LASSERT(list_empty(&sec->ps_gc_list)); - sec->ps_gc_next = cfs_time_current_sec() + sec->ps_gc_interval; + sec->ps_gc_next = get_seconds() + sec->ps_gc_interval; spin_lock(&sec_gc_list_lock); list_add_tail(&sec_gc_list, &sec->ps_gc_list); @@ -152,11 +152,11 @@ static void sec_do_gc(struct ptlrpc_sec *sec) CDEBUG(D_SEC, "check on sec %p(%s)\n", sec, sec->ps_policy->sp_name); - if (cfs_time_after(sec->ps_gc_next, cfs_time_current_sec())) + if (cfs_time_after(sec->ps_gc_next, get_seconds())) return; sec->ps_policy->sp_cops->gc_ctx(sec); - sec->ps_gc_next = cfs_time_current_sec() + sec->ps_gc_interval; + sec->ps_gc_next = get_seconds() + sec->ps_gc_interval; } static int sec_gc_main(void *arg) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c index 1213621ca5aa..0d08145a6c7e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c @@ -38,16 +38,16 @@ #define DEBUG_SUBSYSTEM S_SEC -#include <linux/libcfs/libcfs.h> +#include "../../include/linux/libcfs/libcfs.h" #include <linux/crypto.h> -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lustre_net.h> -#include <lustre_import.h> -#include <lustre_dlm.h> -#include <lustre_sec.h> +#include "../include/obd.h" +#include "../include/obd_class.h" +#include "../include/obd_support.h" +#include "../include/lustre_net.h" +#include "../include/lustre_import.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_sec.h" #include "ptlrpc_internal.h" @@ -55,7 +55,7 @@ struct proc_dir_entry *sptlrpc_proc_root = NULL; EXPORT_SYMBOL(sptlrpc_proc_root); -char *sec_flags2str(unsigned long flags, char *buf, int bufsize) +static char *sec_flags2str(unsigned long flags, char *buf, int bufsize) { buf[0] = '\0'; @@ -104,7 +104,7 @@ static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v) seq_printf(seq, "gc internal %ld\n", sec->ps_gc_interval); seq_printf(seq, "gc next %ld\n", sec->ps_gc_interval ? - sec->ps_gc_next - cfs_time_current_sec() : 0); + sec->ps_gc_next - get_seconds() : 0); sptlrpc_sec_put(sec); out: diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index ff1137fe4dd6..a47791411149 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c @@ -41,11 +41,11 @@ #define DEBUG_SUBSYSTEM S_SEC -#include <obd_support.h> -#include <obd_cksum.h> -#include <obd_class.h> -#include <lustre_net.h> -#include <lustre_sec.h> +#include "../include/obd_support.h" +#include "../include/obd_cksum.h" +#include "../include/obd_class.h" +#include "../include/lustre_net.h" +#include "../include/lustre_sec.h" static struct ptlrpc_sec_policy null_policy; static struct ptlrpc_sec null_sec; @@ -260,11 +260,22 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, if (newbuf == NULL) return -ENOMEM; + /* Must lock this, so that otherwise unprotected change of + * rq_reqmsg is not racing with parallel processing of + * imp_replay_list traversing threads. See LU-3333 + * This is a bandaid at best, we really need to deal with this + * in request enlarging code before unpacking that's already + * there */ + if (req->rq_import) + spin_lock(&req->rq_import->imp_lock); memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen); OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); req->rq_reqbuf = req->rq_reqmsg = newbuf; req->rq_reqbuf_len = alloc_size; + + if (req->rq_import) + spin_unlock(&req->rq_import->imp_lock); } _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index 416401be6d4f..3d72b810c45c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -41,11 +41,11 @@ #define DEBUG_SUBSYSTEM S_SEC -#include <obd_support.h> -#include <obd_cksum.h> -#include <obd_class.h> -#include <lustre_net.h> -#include <lustre_sec.h> +#include "../include/obd_support.h" +#include "../include/obd_cksum.h" +#include "../include/obd_class.h" +#include "../include/lustre_net.h" +#include "../include/lustre_sec.h" struct plain_sec { struct ptlrpc_sec pls_base; @@ -669,6 +669,15 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, if (newbuf == NULL) return -ENOMEM; + /* Must lock this, so that otherwise unprotected change of + * rq_reqmsg is not racing with parallel processing of + * imp_replay_list traversing threads. See LU-3333 + * This is a bandaid at best, we really need to deal with this + * in request enlarging code before unpacking that's already + * there */ + if (req->rq_import) + spin_lock(&req->rq_import->imp_lock); + memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len); OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); @@ -676,6 +685,9 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, req->rq_reqbuf_len = newbuf_size; req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, PLAIN_PACK_MSG_OFF, 0); + + if (req->rq_import) + spin_unlock(&req->rq_import->imp_lock); } _sptlrpc_enlarge_msg_inplace(req->rq_reqbuf, PLAIN_PACK_MSG_OFF, diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index d278f2e21803..c88eae27bbf4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -35,11 +35,11 @@ */ #define DEBUG_SUBSYSTEM S_RPC -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_net.h> -#include <lu_object.h> -#include <linux/lnet/types.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_net.h" +#include "../include/lu_object.h" +#include "../../include/linux/lnet/types.h" #include "ptlrpc_internal.h" /* The following are visible and mutable through /sys/module/ptlrpc */ @@ -1037,7 +1037,7 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) will make it to the top of the list. */ /* Do not pay attention on 1sec or smaller renewals. */ - new_time = cfs_time_current_sec() + extra_delay; + new_time = get_seconds() + extra_delay; if (exp->exp_last_request_time + 1 /*second */ >= new_time) return; @@ -1070,20 +1070,20 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) /* Note - racing to start/reset the obd_eviction timer is safe */ if (exp->exp_obd->obd_eviction_timer == 0) { /* Check if the oldest entry is expired. */ - if (cfs_time_current_sec() > (oldest_time + PING_EVICT_TIMEOUT + + if (get_seconds() > (oldest_time + PING_EVICT_TIMEOUT + extra_delay)) { /* We need a second timer, in case the net was down and * it just came back. Since the pinger may skip every * other PING_INTERVAL (see note in ptlrpc_pinger_main), * we better wait for 3. */ exp->exp_obd->obd_eviction_timer = - cfs_time_current_sec() + 3 * PING_INTERVAL; + get_seconds() + 3 * PING_INTERVAL; CDEBUG(D_HA, "%s: Think about evicting %s from "CFS_TIME_T"\n", exp->exp_obd->obd_name, obd_export_nid2str(oldest_exp), oldest_time); } } else { - if (cfs_time_current_sec() > + if (get_seconds() > (exp->exp_obd->obd_eviction_timer + extra_delay)) { /* The evictor won't evict anyone who we've heard from * recently, so we don't have to check before we start @@ -1100,6 +1100,7 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) */ static int ptlrpc_check_req(struct ptlrpc_request *req) { + struct obd_device *obd = req->rq_export->exp_obd; int rc = 0; if (unlikely(lustre_msg_get_conn_cnt(req->rq_reqmsg) < @@ -1110,26 +1111,24 @@ static int ptlrpc_check_req(struct ptlrpc_request *req) req->rq_export->exp_conn_cnt); return -EEXIST; } - if (unlikely(req->rq_export->exp_obd && - req->rq_export->exp_obd->obd_fail)) { + if (unlikely(obd == NULL || obd->obd_fail)) { /* * Failing over, don't handle any more reqs, send * error response instead. */ CDEBUG(D_RPCTRACE, "Dropping req %p for failed obd %s\n", - req, req->rq_export->exp_obd->obd_name); + req, (obd != NULL) ? obd->obd_name : "unknown"); rc = -ENODEV; } else if (lustre_msg_get_flags(req->rq_reqmsg) & (MSG_REPLAY | MSG_REQ_REPLAY_DONE) && - !(req->rq_export->exp_obd->obd_recovering)) { + !obd->obd_recovering) { DEBUG_REQ(D_ERROR, req, "Invalid replay without recovery"); class_fail_export(req->rq_export); rc = -ENODEV; } else if (lustre_msg_get_transno(req->rq_reqmsg) != 0 && - !(req->rq_export->exp_obd->obd_recovering)) { - DEBUG_REQ(D_ERROR, req, "Invalid req with transno " - LPU64" without recovery", + !obd->obd_recovering) { + DEBUG_REQ(D_ERROR, req, "Invalid req with transno %llu without recovery", lustre_msg_get_transno(req->rq_reqmsg)); class_fail_export(req->rq_export); rc = -ENODEV; @@ -1153,7 +1152,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt) } /* Set timer for closest deadline */ - next = (__s32)(array->paa_deadline - cfs_time_current_sec() - + next = (__s32)(array->paa_deadline - get_seconds() - at_early_margin); if (next <= 0) { ptlrpc_at_timer((unsigned long)svcpt); @@ -1243,7 +1242,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; struct ptlrpc_request *reqcopy; struct lustre_msg *reqmsg; - cfs_duration_t olddl = req->rq_deadline - cfs_time_current_sec(); + long olddl = req->rq_deadline - get_seconds(); time_t newdl; int rc; @@ -1288,7 +1287,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) /* Fake our processing time into the future to ask the clients * for some extra amount of time */ at_measured(&svcpt->scp_at_estimate, at_extra + - cfs_time_current_sec() - + get_seconds() - req->rq_arrival_time.tv_sec); /* Check to see if we've actually increased the deadline - @@ -1299,11 +1298,11 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) "(%ld/%ld), not sending early reply\n", olddl, req->rq_arrival_time.tv_sec + at_get(&svcpt->scp_at_estimate) - - cfs_time_current_sec()); + get_seconds()); return -ETIMEDOUT; } } - newdl = cfs_time_current_sec() + at_get(&svcpt->scp_at_estimate); + newdl = get_seconds() + at_get(&svcpt->scp_at_estimate); reqcopy = ptlrpc_request_cache_alloc(GFP_NOFS); if (reqcopy == NULL) @@ -1381,8 +1380,8 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) struct list_head work_list; __u32 index, count; time_t deadline; - time_t now = cfs_time_current_sec(); - cfs_duration_t delay; + time_t now = get_seconds(); + long delay; int first, counter = 0; spin_lock(&svcpt->scp_at_lock); @@ -1766,24 +1765,24 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, if (SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc) != SPTLRPC_POLICY_NULL) { rc = ptlrpc_unpack_req_msg(req, req->rq_reqlen); if (rc != 0) { - CERROR("error unpacking request: ptl %d from %s " - "x"LPU64"\n", svc->srv_req_portal, - libcfs_id2str(req->rq_peer), req->rq_xid); + CERROR("error unpacking request: ptl %d from %s x%llu\n", + svc->srv_req_portal, libcfs_id2str(req->rq_peer), + req->rq_xid); goto err_req; } } rc = lustre_unpack_req_ptlrpc_body(req, MSG_PTLRPC_BODY_OFF); if (rc) { - CERROR("error unpacking ptlrpc body: ptl %d from %s x" - LPU64"\n", svc->srv_req_portal, - libcfs_id2str(req->rq_peer), req->rq_xid); + CERROR("error unpacking ptlrpc body: ptl %d from %s x%llu\n", + svc->srv_req_portal, libcfs_id2str(req->rq_peer), + req->rq_xid); goto err_req; } if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_DROP_REQ_OPC) && lustre_msg_get_opc(req->rq_reqmsg) == cfs_fail_val) { - CERROR("drop incoming rpc opc %u, x"LPU64"\n", + CERROR("drop incoming rpc opc %u, x%llu\n", cfs_fail_val, req->rq_xid); goto err_req; } @@ -1808,7 +1807,7 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, break; } - CDEBUG(D_RPCTRACE, "got req x"LPU64"\n", req->rq_xid); + CDEBUG(D_RPCTRACE, "got req x%llu\n", req->rq_xid); req->rq_export = class_conn2export( lustre_msg_get_handle(req->rq_reqmsg)); @@ -1827,9 +1826,9 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, } /* req_in handling should/must be fast */ - if (cfs_time_current_sec() - req->rq_arrival_time.tv_sec > 5) + if (get_seconds() - req->rq_arrival_time.tv_sec > 5) DEBUG_REQ(D_WARNING, req, "Slow req_in handling "CFS_DURATION_T"s", - cfs_time_sub(cfs_time_current_sec(), + cfs_time_sub(get_seconds(), req->rq_arrival_time.tv_sec)); /* Set rpc server deadline and add it to the timed list */ @@ -1918,7 +1917,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, request->rq_session.lc_cookie = 0x5; lu_context_enter(&request->rq_session); - CDEBUG(D_NET, "got req "LPU64"\n", request->rq_xid); + CDEBUG(D_NET, "got req %llu\n", request->rq_xid); request->rq_svc_thread = thread; if (thread) @@ -1932,19 +1931,19 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, /* Discard requests queued for longer than the deadline. The deadline is increased if we send an early reply. */ - if (cfs_time_current_sec() > request->rq_deadline) { + if (get_seconds() > request->rq_deadline) { DEBUG_REQ(D_ERROR, request, "Dropping timed-out request from %s" ": deadline "CFS_DURATION_T":"CFS_DURATION_T"s ago\n", libcfs_id2str(request->rq_peer), cfs_time_sub(request->rq_deadline, request->rq_arrival_time.tv_sec), - cfs_time_sub(cfs_time_current_sec(), + cfs_time_sub(get_seconds(), request->rq_deadline)); goto put_conn; } CDEBUG(D_RPCTRACE, "Handling RPC pname:cluuid+ref:pid:xid:nid:opc " - "%s:%s+%d:%d:x"LPU64":%s:%d\n", current_comm(), + "%s:%s+%d:%d:x%llu:%s:%d\n", current_comm(), (request->rq_export ? (char *)request->rq_export->exp_client_uuid.uuid : "0"), (request->rq_export ? @@ -1964,22 +1963,22 @@ put_conn: lu_context_exit(&request->rq_session); lu_context_fini(&request->rq_session); - if (unlikely(cfs_time_current_sec() > request->rq_deadline)) { + if (unlikely(get_seconds() > request->rq_deadline)) { DEBUG_REQ(D_WARNING, request, "Request took longer than estimated (" CFS_DURATION_T":"CFS_DURATION_T "s); client may timeout.", cfs_time_sub(request->rq_deadline, request->rq_arrival_time.tv_sec), - cfs_time_sub(cfs_time_current_sec(), + cfs_time_sub(get_seconds(), request->rq_deadline)); } do_gettimeofday(&work_end); timediff = cfs_timeval_sub(&work_end, &work_start, NULL); CDEBUG(D_RPCTRACE, "Handled RPC pname:cluuid+ref:pid:xid:nid:opc " - "%s:%s+%d:%d:x"LPU64":%s:%d Request processed in " - "%ldus (%ldus total) trans "LPU64" rc %d/%d\n", + "%s:%s+%d:%d:x%llu:%s:%d Request processed in " + "%ldus (%ldus total) trans %llu rc %d/%d\n", current_comm(), (request->rq_export ? (char *)request->rq_export->exp_client_uuid.uuid : "0"), @@ -2084,8 +2083,7 @@ ptlrpc_handle_rs(struct ptlrpc_reply_state *rs) if (nlocks == 0 && !been_handled) { /* If we see this, we should already have seen the warning * in mds_steal_ack_locks() */ - CDEBUG(D_HA, "All locks stolen from rs %p x"LPD64".t"LPD64 - " o%d NID %s\n", + CDEBUG(D_HA, "All locks stolen from rs %p x%lld.t%lld o%d NID %s\n", rs, rs->rs_xid, rs->rs_transno, rs->rs_opc, libcfs_nid2str(exp->exp_connection->c_peer.nid)); diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index 3c8846006a7b..0624420135c2 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -39,10 +39,10 @@ #include <linux/fs.h> #include <linux/posix_acl_xattr.h> -#include <obd_support.h> -#include <obd_class.h> -#include <lustre_net.h> -#include <lustre_disk.h> +#include "../include/obd_support.h" +#include "../include/obd_class.h" +#include "../include/lustre_net.h" +#include "../include/lustre_disk.h" void lustre_assert_wire_constants(void) { /* Wire protocol assertions generated by 'wirecheck' |