diff options
Diffstat (limited to 'drivers/staging/lustre')
277 files changed, 6626 insertions, 11312 deletions
diff --git a/drivers/staging/lustre/Makefile b/drivers/staging/lustre/Makefile index 26162893fd2..fb0e0faf076 100644 --- a/drivers/staging/lustre/Makefile +++ b/drivers/staging/lustre/Makefile @@ -1,4 +1,4 @@ subdir-ccflags-y := -I$(src)/include/ -obj-$(CONFIG_LUSTRE_FS) += lustre/ obj-$(CONFIG_LNET) += lnet/ +obj-$(CONFIG_LUSTRE_FS) += lustre/ diff --git a/drivers/staging/lustre/include/linux/libcfs/bitmap.h b/drivers/staging/lustre/include/linux/libcfs/bitmap.h index 3f1c37b4bb7..f3d4a896a75 100644 --- a/drivers/staging/lustre/include/linux/libcfs/bitmap.h +++ b/drivers/staging/lustre/include/linux/libcfs/bitmap.h @@ -52,11 +52,11 @@ cfs_bitmap_t *CFS_ALLOCATE_BITMAP(int size) OBD_ALLOC(ptr, CFS_BITMAP_SIZE(size)); if (ptr == NULL) - RETURN(ptr); + return ptr; ptr->size = size; - RETURN (ptr); + return ptr; } #define CFS_FREE_BITMAP(ptr) OBD_FREE(ptr, CFS_BITMAP_SIZE(ptr->size)) diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h index 90d7ce630e9..de8e35b796a 100644 --- a/drivers/staging/lustre/include/linux/libcfs/curproc.h +++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h @@ -49,8 +49,6 @@ * Implemented in portals/include/libcfs/<os>/ */ int cfs_curproc_groups_nr(void); -int current_is_in_group(gid_t group); -void cfs_curproc_groups_dump(gid_t *array, int size); /* * Plus, platform-specific constant diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 1ab1f2be9aa..687dbab2c4e 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -80,26 +80,10 @@ static inline int __is_po2(unsigned long long val) #define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \ ((hexnum) >> 8 & 0xf)) - -/* - * Some (nomina odiosa sunt) platforms define NULL as naked 0. This confuses - * Lustre RETURN(NULL) macro. - */ -#if defined(NULL) -#undef NULL -#endif - -#define NULL ((void *)0) - #define LUSTRE_SRV_LNET_PID LUSTRE_LNET_PID - #include <linux/list.h> -#ifndef cfs_for_each_possible_cpu -# error cfs_for_each_possible_cpu is not supported by kernel! -#endif - /* libcfs tcpip */ int libcfs_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask); int libcfs_ipif_enumerate(char ***names); @@ -117,31 +101,6 @@ int libcfs_sock_write(socket_t *sock, void *buffer, int nob, int timeout); int libcfs_sock_read(socket_t *sock, void *buffer, int nob, int timeout); void libcfs_sock_release(socket_t *sock); -/* libcfs watchdogs */ -struct lc_watchdog; - -/* Add a watchdog which fires after "time" milliseconds of delay. You have to - * touch it once to enable it. */ -struct lc_watchdog *lc_watchdog_add(int time, - void (*cb)(pid_t pid, void *), - void *data); - -/* Enables a watchdog and resets its timer. */ -void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout); -#define CFS_GET_TIMEOUT(svc) (max_t(int, obd_timeout, \ - AT_OFF ? 0 : at_get(&svc->srv_at_estimate)) * \ - svc->srv_watchdog_factor) - -/* Disable a watchdog; touch it to restart it. */ -void lc_watchdog_disable(struct lc_watchdog *lcw); - -/* Clean up the watchdog */ -void lc_watchdog_delete(struct lc_watchdog *lcw); - -/* Dump a debug log */ -void lc_watchdog_dumplog(pid_t pid, void *data); - - /* need both kernel and user-land acceptor */ #define LNET_ACCEPTOR_MIN_RESERVED_PORT 512 #define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023 @@ -149,11 +108,6 @@ void lc_watchdog_dumplog(pid_t pid, void *data); /* * libcfs pseudo device operations * - * struct psdev_t and - * misc_register() and - * misc_deregister() are declared in - * libcfs/<os>/<os>-prim.h - * * It's just draft now. */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h index 6ae7415a3b9..c87efb49ebc 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h @@ -75,11 +75,19 @@ #ifndef __LIBCFS_CPU_H__ #define __LIBCFS_CPU_H__ -#ifndef HAVE_LIBCFS_CPT - -typedef unsigned long cpumask_t; -typedef unsigned long nodemask_t; +/* any CPU partition */ +#define CFS_CPT_ANY (-1) +#ifdef CONFIG_SMP +/** + * return cpumask of CPU partition \a cpt + */ +cpumask_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt); +/** + * print string information of cpt-table + */ +int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len); +#else /* !CONFIG_SMP */ struct cfs_cpt_table { /* # of CPU partitions */ int ctb_nparts; @@ -91,10 +99,18 @@ struct cfs_cpt_table { __u64 ctb_version; }; -#endif /* !HAVE_LIBCFS_CPT */ +static inline cpumask_t * +cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) +{ + return NULL; +} -/* any CPU partition */ -#define CFS_CPT_ANY (-1) +static inline int +cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) +{ + return 0; +} +#endif /* CONFIG_SMP */ extern struct cfs_cpt_table *cfs_cpt_table; @@ -107,10 +123,6 @@ void cfs_cpt_table_free(struct cfs_cpt_table *cptab); */ struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt); /** - * print string information of cpt-table - */ -int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len); -/** * return total number of CPU partitions in \a cptab */ int @@ -124,10 +136,6 @@ int cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt); */ int cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt); /** - * return cpumask of CPU partition \a cpt - */ -cpumask_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt); -/** * return nodemask of CPU partition \a cpt */ nodemask_t *cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt); @@ -200,14 +208,6 @@ int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt); #define cfs_cpt_for_each(i, cptab) \ for (i = 0; i < cfs_cpt_number(cptab); i++) -#ifndef __read_mostly -# define __read_mostly -#endif - -#ifndef ____cacheline_aligned -#define ____cacheline_aligned -#endif - int cfs_cpu_init(void); void cfs_cpu_fini(void); diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h index 64ca62f0cc9..776e9c0e48c 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h @@ -136,13 +136,13 @@ int cfs_crypto_hash_digest(unsigned char alg, /* cfs crypto hash descriptor */ struct cfs_crypto_hash_desc; -/** Allocate and initialize desriptor for hash algorithm. +/** Allocate and initialize descriptor for hash algorithm. * @param alg algorithm id * @param key initial value for algorithm, if it is NULL, * default initial value should be used. * @param key_len len of initial value * @returns pointer to descriptor of hash instance - * @retval ERR_PTR(error) when errors occured. + * @retval ERR_PTR(error) when errors occurred. */ struct cfs_crypto_hash_desc* cfs_crypto_hash_init(unsigned char alg, @@ -175,7 +175,7 @@ int cfs_crypto_hash_update(struct cfs_crypto_hash_desc *desc, const void *buf, * @param desc hash descriptor * @param hash buffer pointer to store hash digest * @param hash_len pointer to hash buffer size, if NULL - * destory hash descriptor + * destroy hash descriptor * @returns status of operation * @retval -ENOSPC if hash is NULL, or *hash_len less than * digest size @@ -195,7 +195,7 @@ int cfs_crypto_register(void); void cfs_crypto_unregister(void); /** Return hash speed in Mbytes per second for valid hash algorithm - * identifier. If test was unsuccessfull -1 would be return. + * identifier. If test was unsuccessful -1 would be returned. */ int cfs_crypto_hash_speed(unsigned char hash_alg); #endif diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index dd8ac2f52c9..e6439d19f3e 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -262,74 +262,6 @@ do { \ } while (0) -/* - * if rc == NULL, we need to code as RETURN((void *)NULL), otherwise - * there will be a warning in osx. - */ -#if defined(__GNUC__) - -long libcfs_log_return(struct libcfs_debug_msg_data *, long rc); -#if BITS_PER_LONG > 32 -#define RETURN(rc) \ -do { \ - EXIT_NESTING; \ - if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ - LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ - return (typeof(rc))libcfs_log_return(&msgdata, \ - (long)(rc)); \ - } \ - \ - return (rc); \ -} while (0) -#else /* BITS_PER_LONG == 32 */ -/* We need an on-stack variable, because we cannot case a 32-bit pointer - * directly to (long long) without generating a complier warning/error, yet - * casting directly to (long) will truncate 64-bit return values. The log - * values will print as 32-bit values, but they always have been. LU-1436 - */ -#define RETURN(rc) \ -do { \ - EXIT_NESTING; \ - if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ - typeof(rc) __rc = (rc); \ - LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ - libcfs_log_return(&msgdata, (long_ptr_t)__rc); \ - return __rc; \ - } \ - \ - return (rc); \ -} while (0) -#endif /* BITS_PER_LONG > 32 */ - -#elif defined(_MSC_VER) -#define RETURN(rc) \ -do { \ - CDEBUG(D_TRACE, "Process leaving.\n"); \ - EXIT_NESTING; \ - return (rc); \ -} while (0) -#else -# error "Unkown compiler" -#endif /* __GNUC__ */ - -#define ENTRY \ -ENTRY_NESTING; \ -do { \ - CDEBUG(D_TRACE, "Process entered\n"); \ -} while (0) - -#define EXIT \ -do { \ - CDEBUG(D_TRACE, "Process leaving\n"); \ - EXIT_NESTING; \ -} while(0) - -#define RETURN_EXIT \ -do { \ - EXIT; \ - return; \ -} while (0) - extern int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata, const char *format1, ...) __attribute__ ((format (printf, 2, 3))); diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h index f6361b3f0a0..98f5be243c8 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h @@ -720,7 +720,7 @@ __u64 cfs_hash_size_get(cfs_hash_t *hs); /* * Rehash - Theta is calculated to be the average chained - * hash depth assuming a perfectly uniform hash funcion. + * hash depth assuming a perfectly uniform hash function. */ void cfs_hash_rehash_cancel_locked(cfs_hash_t *hs); void cfs_hash_rehash_cancel(cfs_hash_t *hs); diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h index 9c40ed904da..e6e417aeefd 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h @@ -40,10 +40,6 @@ #ifndef __LIBCFS_PRIM_H__ #define __LIBCFS_PRIM_H__ -#ifndef EXPORT_SYMBOL -# define EXPORT_SYMBOL(s) -#endif - /* * Schedule */ @@ -53,20 +49,20 @@ void cfs_pause(cfs_duration_t ticks); * Timer */ typedef void (cfs_timer_func_t)(ulong_ptr_t); -void schedule_timeout_and_set_state(cfs_task_state_t, int64_t); +void schedule_timeout_and_set_state(long, int64_t); void init_waitqueue_entry_current(wait_queue_t *link); -int64_t waitq_timedwait(wait_queue_t *, cfs_task_state_t, int64_t); -void waitq_wait(wait_queue_t *, cfs_task_state_t); +int64_t waitq_timedwait(wait_queue_t *, long, int64_t); +void waitq_wait(wait_queue_t *, long); void add_wait_queue_exclusive_head(wait_queue_head_t *, wait_queue_t *); -void cfs_init_timer(timer_list_t *t); -void cfs_timer_init(timer_list_t *t, cfs_timer_func_t *func, void *arg); -void cfs_timer_done(timer_list_t *t); -void cfs_timer_arm(timer_list_t *t, cfs_time_t deadline); -void cfs_timer_disarm(timer_list_t *t); -int cfs_timer_is_armed(timer_list_t *t); -cfs_time_t cfs_timer_deadline(timer_list_t *t); +void cfs_init_timer(struct timer_list *t); +void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg); +void cfs_timer_done(struct timer_list *t); +void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline); +void cfs_timer_disarm(struct timer_list *t); +int cfs_timer_is_armed(struct timer_list *t); +cfs_time_t cfs_timer_deadline(struct timer_list *t); /* * Memory diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index 056caa46712..d0d942ced01 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -210,7 +210,6 @@ do { \ #define ntohs(x) ___ntohs(x) #endif -void libcfs_debug_dumpstack(task_t *tsk); void libcfs_run_upcall(char **argv); void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *); void libcfs_debug_dumplog(void); @@ -230,7 +229,7 @@ void libcfs_debug_set_level(unsigned int debug_level); */ void *cfs_percpt_alloc(struct cfs_cpt_table *cptab, unsigned int size); /* - * destory per-cpu-partition variable + * destroy per-cpu-partition variable */ void cfs_percpt_free(void *vars); int cfs_percpt_number(void *vars); @@ -456,10 +455,6 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *list); /* logical equivalence */ #define equi(a, b) (!!(a) == !!(b)) -#ifndef CFS_CURRENT_TIME -# define CFS_CURRENT_TIME time(0) -#endif - /* -------------------------------------------------------------------- * Light-weight trace * Support for temporary event tracing with minimal Heisenberg effect. diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h b/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h index 4b7ae1c5bd3..c204b677796 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h @@ -55,7 +55,6 @@ #include <linux/interrupt.h> #include <linux/highmem.h> #include <linux/module.h> -#include <linux/version.h> #include <asm/atomic.h> #include <asm/uaccess.h> #include <linux/rwsem.h> @@ -74,34 +73,6 @@ #include <linux/libcfs/linux/portals_compat25.h> -#define prepare_work(wq,cb,cbdata) \ -do { \ - INIT_WORK((wq), (void *)(cb)); \ -} while (0) - -#define cfs_get_work_data(type,field,data) container_of(data,type,field) - - -#define our_recalc_sigpending(current) recalc_sigpending() -#define strtok(a,b) strpbrk(a, b) -#define work_struct_t struct work_struct - -#ifdef CONFIG_SMP -#else -#endif - - -#define SEM_COUNT(sem) ((sem)->count) - - -/* ------------------------------------------------------------------- */ - -#define PORTAL_SYMBOL_REGISTER(x) -#define PORTAL_SYMBOL_UNREGISTER(x) - - - - /******************************************************************************/ /* Module parameter support */ #define CFS_MODULE_PARM(name, t, type, perm, desc) \ @@ -111,26 +82,6 @@ do { \ #define CFS_SYSFS_MODULE_PARM 1 /* module parameters accessible via sysfs */ /******************************************************************************/ - -#if (__GNUC__) -/* Use the special GNU C __attribute__ hack to have the compiler check the - * printf style argument string against the actual argument count and - * types. - */ -#ifdef printf -# warning printf has been defined as a macro... -# undef printf -#endif - -#endif /* __GNUC__ */ - -# define fprintf(a, format, b...) CDEBUG(D_OTHER, format , ## b) -# define printf(format, b...) CDEBUG(D_OTHER, format , ## b) -# define time(a) CURRENT_TIME - -# define cfs_num_present_cpus() num_present_cpus() - -/******************************************************************************/ /* Light-weight trace * Support for temporary event tracing with minimal Heisenberg effect. */ #define LWT_SUPPORT 0 @@ -236,9 +187,13 @@ extern int lwt_snapshot (cfs_cycles_t *now, int *ncpu, int *total_size, # endif #endif -# define LI_POISON ((int)0x5a5a5a5a5a5a5a5a) -# define LL_POISON ((long)0x5a5a5a5a5a5a5a5a) -# define LP_POISON ((void *)(long)0x5a5a5a5a5a5a5a5a) +# define LI_POISON 0x5a5a5a5a +#if BITS_PER_LONG > 32 +# define LL_POISON 0x5a5a5a5a5a5a5a5aL +#else +# define LL_POISON 0x5a5a5a5aL +#endif +# define LP_POISON ((void *)LL_POISON) /* this is a bit chunky */ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h index 292a3ba1fb9..60ecaf63f9f 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h @@ -97,9 +97,6 @@ do { \ /* initial pid */ #define LUSTRE_LNET_PID 12345 -#define ENTRY_NESTING_SUPPORT (1) -#define ENTRY_NESTING do {;} while (0) -#define EXIT_NESTING do {;} while (0) #define __current_nesting_level() (0) /** diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h index 224371c92f7..8dd354d5160 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h @@ -46,8 +46,6 @@ #include <linux/cpu.h> #include <linux/cpuset.h> #include <linux/topology.h> -#include <linux/version.h> - #ifdef CONFIG_SMP @@ -81,15 +79,8 @@ struct cfs_cpt_table { nodemask_t *ctb_nodemask; }; -void cfs_cpu_core_siblings(int cpu, cpumask_t *mask); -void cfs_cpu_ht_siblings(int cpu, cpumask_t *mask); -void cfs_node_to_cpumask(int node, cpumask_t *mask); -int cfs_cpu_core_nsiblings(int cpu); -int cfs_cpu_ht_nsiblings(int cpu); - /** * comment out definitions for compatible layer - * #define CFS_CPU_NR NR_CPUS * * typedef cpumask_t cfs_cpumask_t; * diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h index 6fbcbf3ab0d..d6e00f92e4a 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h @@ -52,7 +52,7 @@ * IMPORTANT !!!!!!!! * * All locks' declaration are not guaranteed to be initialized, - * Althought some of they are initialized in Linux. All locks + * although some of them are initialized in Linux. All locks * declared by CFS_DECL_* should be initialized explicitly. */ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h index 042a2bc432b..2af15d41e77 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h @@ -63,9 +63,9 @@ #if BITS_PER_LONG == 32 /* limit to lowmem on 32-bit systems */ #define NUM_CACHEPAGES \ - min(num_physpages, 1UL << (30 - PAGE_CACHE_SHIFT) * 3 / 4) + min(totalram_pages, 1UL << (30 - PAGE_CACHE_SHIFT) * 3 / 4) #else -#define NUM_CACHEPAGES num_physpages +#define NUM_CACHEPAGES totalram_pages #endif /* @@ -79,42 +79,4 @@ do { __oldfs = get_fs(); set_fs(get_ds());} while(0) #define MMSPACE_CLOSE set_fs(__oldfs) -/* - * Shrinker - */ - -# define SHRINKER_ARGS(sc, nr_to_scan, gfp_mask) \ - struct shrinker *shrinker, \ - struct shrink_control *sc -# define shrink_param(sc, var) ((sc)->var) - -typedef int (*shrinker_t)(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask)); - -static inline -struct shrinker *set_shrinker(int seek, shrinker_t func) -{ - struct shrinker *s; - - s = kmalloc(sizeof(*s), GFP_KERNEL); - if (s == NULL) - return (NULL); - - s->shrink = func; - s->seeks = seek; - - register_shrinker(s); - - return s; -} - -static inline -void remove_shrinker(struct shrinker *shrinker) -{ - if (shrinker == NULL) - return; - - unregister_shrinker(shrinker); - kfree(shrinker); -} - #endif /* __LINUX_CFS_MEM_H__ */ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index a4963a8dfdd..1ec4ca1a6e3 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -49,7 +49,6 @@ #include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> -#include <linux/version.h> #include <linux/proc_fs.h> #include <linux/mm.h> #include <linux/timer.h> @@ -64,43 +63,12 @@ #include <linux/libcfs/linux/linux-time.h> - -/* - * CPU - */ -#ifdef for_each_possible_cpu -#define cfs_for_each_possible_cpu(cpu) for_each_possible_cpu(cpu) -#elif defined(for_each_cpu) -#define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu) -#endif - -#ifdef NR_CPUS -#else -#define NR_CPUS 1 -#endif - -/* - * cache - */ - -/* - * IRQs - */ - - -/* - * Pseudo device register - */ -typedef struct miscdevice psdev_t; - /* * Sysctl register */ typedef struct ctl_table ctl_table_t; typedef struct ctl_table_header ctl_table_header_t; -#define cfs_register_sysctl_table(t, a) register_sysctl_table(t) - #define DECLARE_PROC_HANDLER(name) \ static int \ LL_PROC_PROTO(name) \ @@ -112,130 +80,4 @@ LL_PROC_PROTO(name) \ __##name); \ } -/* - * Symbol register - */ -#define cfs_symbol_register(s, p) do {} while(0) -#define cfs_symbol_unregister(s) do {} while(0) -#define cfs_symbol_get(s) symbol_get(s) -#define cfs_symbol_put(s) symbol_put(s) - -typedef struct module module_t; - -/* - * Proc file system APIs - */ -typedef struct proc_dir_entry proc_dir_entry_t; - -/* - * Wait Queue - */ - - -typedef long cfs_task_state_t; - -#define CFS_DECL_WAITQ(wq) DECLARE_WAIT_QUEUE_HEAD(wq) - -/* - * Task struct - */ -typedef struct task_struct task_t; -#define DECL_JOURNAL_DATA void *journal_info -#define PUSH_JOURNAL do { \ - journal_info = current->journal_info; \ - current->journal_info = NULL; \ - } while(0) -#define POP_JOURNAL do { \ - current->journal_info = journal_info; \ - } while(0) - -/* Module interfaces */ -#define cfs_module(name, version, init, fini) \ - module_init(init); \ - module_exit(fini) - -/* - * Signal - */ - -/* - * Timer - */ -typedef struct timer_list timer_list_t; - - -#ifndef wait_event_timeout /* Only for RHEL3 2.4.21 kernel */ -#define __wait_event_timeout(wq, condition, timeout, ret) \ -do { \ - int __ret = 0; \ - if (!(condition)) { \ - wait_queue_t __wait; \ - unsigned long expire; \ - \ - init_waitqueue_entry(&__wait, current); \ - expire = timeout + jiffies; \ - add_wait_queue(&wq, &__wait); \ - for (;;) { \ - set_current_state(TASK_UNINTERRUPTIBLE); \ - if (condition) \ - break; \ - if (jiffies > expire) { \ - ret = jiffies - expire; \ - break; \ - } \ - schedule_timeout(timeout); \ - } \ - current->state = TASK_RUNNING; \ - remove_wait_queue(&wq, &__wait); \ - } \ -} while (0) -/* - retval == 0; condition met; we're good. - retval > 0; timed out. -*/ -#define cfs_waitq_wait_event_timeout(wq, condition, timeout, ret) \ -do { \ - ret = 0; \ - if (!(condition)) \ - __wait_event_timeout(wq, condition, timeout, ret); \ -} while (0) -#else -#define cfs_waitq_wait_event_timeout(wq, condition, timeout, ret) \ - ret = wait_event_timeout(wq, condition, timeout) -#endif - -#define cfs_waitq_wait_event_interruptible_timeout(wq, c, timeout, ret) \ - ret = wait_event_interruptible_timeout(wq, c, timeout) - -/* - * atomic - */ - - -#define cfs_atomic_add_unless(atom, a, u) atomic_add_unless(atom, a, u) -#define cfs_atomic_cmpxchg(atom, old, nv) atomic_cmpxchg(atom, old, nv) - -/* - * membar - */ - - -/* - * interrupt - */ - - -/* - * might_sleep - */ - -/* - * group_info - */ -typedef struct group_info group_info_t; - - -/* - * Random bytes - */ #endif diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-tcpip.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-tcpip.h index 687f33f4e8a..7a8d006903b 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-tcpip.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-tcpip.h @@ -48,21 +48,6 @@ #include <net/sock.h> -#ifndef HIPQUAD -// XXX Should just kill all users -#if defined(__LITTLE_ENDIAN) -#define HIPQUAD(addr) \ - ((unsigned char *)&addr)[3], \ - ((unsigned char *)&addr)[2], \ - ((unsigned char *)&addr)[1], \ - ((unsigned char *)&addr)[0] -#elif defined(__BIG_ENDIAN) -#define HIPQUAD NIPQUAD -#else -#error "Please fix asm/byteorder.h" -#endif /* __LITTLE_ENDIAN */ -#endif - typedef struct socket socket_t; #define SOCK_SNDBUF(so) ((so)->sk->sk_sndbuf) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h index 4a48b914b42..a386d1b1286 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h @@ -91,7 +91,6 @@ #include <linux/module.h> #include <linux/kernel.h> -#include <linux/version.h> #include <linux/time.h> #include <asm/div64.h> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h b/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h index 132a4bec357..fe4c63fb40a 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h @@ -95,20 +95,5 @@ 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)); -/* - * CPU - */ -#ifdef for_each_possible_cpu -#define cfs_for_each_possible_cpu(cpu) for_each_possible_cpu(cpu) -#elif defined(for_each_cpu) -#define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu) -#endif - -#ifdef NR_CPUS -#else -#define NR_CPUS 1 -#endif - -#define cfs_register_sysctl_table(t, a) register_sysctl_table(t) #endif /* _PORTALS_COMPAT_H */ diff --git a/drivers/staging/lustre/include/linux/libcfs/lucache.h b/drivers/staging/lustre/include/linux/libcfs/lucache.h index 7ae36fc88d7..9668b397f0f 100644 --- a/drivers/staging/lustre/include/linux/libcfs/lucache.h +++ b/drivers/staging/lustre/include/linux/libcfs/lucache.h @@ -77,7 +77,7 @@ struct md_identity { struct upcall_cache_entry *mi_uc_entry; uid_t mi_uid; gid_t mi_gid; - group_info_t *mi_ginfo; + struct group_info *mi_ginfo; int mi_nperms; struct md_perm *mi_perms; }; diff --git a/drivers/staging/lustre/include/linux/libcfs/params_tree.h b/drivers/staging/lustre/include/linux/libcfs/params_tree.h index 3f18a446703..78a2c4ed4d6 100644 --- a/drivers/staging/lustre/include/linux/libcfs/params_tree.h +++ b/drivers/staging/lustre/include/linux/libcfs/params_tree.h @@ -54,7 +54,6 @@ typedef struct proc_inode cfs_proc_inode_t; typedef struct seq_file cfs_seq_file_t; typedef struct seq_operations cfs_seq_ops_t; typedef struct file_operations cfs_param_file_ops_t; -typedef module_t *cfs_param_module_t; typedef struct proc_dir_entry cfs_param_dentry_t; typedef struct poll_table_struct cfs_poll_table_t; #define CFS_PARAM_MODULE THIS_MODULE @@ -115,11 +114,10 @@ typedef struct cfs_seq_operations { int (*show) (cfs_seq_file_t *m, void *v); } cfs_seq_ops_t; -typedef void *cfs_param_module_t; typedef void *cfs_poll_table_t; typedef struct cfs_param_file_ops { - cfs_param_module_t owner; + struct module *owner; int (*open) (cfs_inode_t *, struct file *); loff_t (*llseek)(struct file *, loff_t, int); int (*release) (cfs_inode_t *, cfs_param_file_t *); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 86428d4b993..e579e7ed507 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -181,11 +181,11 @@ typedef struct lnet_msg { lnet_nid_t msg_from; __u32 msg_type; - /* commited for sending */ + /* committed for sending */ unsigned int msg_tx_committed:1; /* CPT # this message committed for sending */ unsigned int msg_tx_cpt:15; - /* commited for receiving */ + /* committed for receiving */ unsigned int msg_rx_committed:1; /* CPT # this message committed for receiving */ unsigned int msg_rx_cpt:15; @@ -619,7 +619,7 @@ typedef struct lnet_portal { unsigned int ptl_index; /* portal ID, reserved */ /* flags on this portal: lazy, unique... */ unsigned int ptl_options; - /* list of messags which are stealing buffer */ + /* list of messages which are stealing buffer */ struct list_head ptl_msg_stealing; /* messages blocking for MD */ struct list_head ptl_msg_delayed; diff --git a/drivers/staging/lustre/include/linux/lnet/lnetst.h b/drivers/staging/lustre/include/linux/lnet/lnetst.h index d90f94e9460..e060599314d 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetst.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetst.h @@ -59,7 +59,7 @@ #define LSTIO_SESSION_INFO 0xC03 /* query session */ #define LSTIO_GROUP_ADD 0xC10 /* add group */ #define LSTIO_GROUP_LIST 0xC11 /* list all groups in session */ -#define LSTIO_GROUP_INFO 0xC12 /* query defailt infomation of specified group */ +#define LSTIO_GROUP_INFO 0xC12 /* query default information of specified group */ #define LSTIO_GROUP_DEL 0xC13 /* delete group */ #define LSTIO_NODES_ADD 0xC14 /* add nodes to specified group */ #define LSTIO_GROUP_UPDATE 0xC15 /* update group */ diff --git a/drivers/staging/lustre/include/linux/lnet/ptllnd.h b/drivers/staging/lustre/include/linux/lnet/ptllnd.h index fc1ce8ed1f8..564f5d3a9b4 100644 --- a/drivers/staging/lustre/include/linux/lnet/ptllnd.h +++ b/drivers/staging/lustre/include/linux/lnet/ptllnd.h @@ -68,7 +68,7 @@ /* Can compare handles directly on Cray Portals */ #define PtlHandleIsEqual(a,b) ((a) == (b)) -/* Diffrent error types on Cray Portals*/ +/* Different error types on Cray Portals*/ #define ptl_err_t ptl_ni_fail_t /* @@ -76,7 +76,7 @@ * maximum is limited only by memory and size of the * int parameters (2^31-1). * Lustre only really require that the underyling - * implemenation to support at least LNET_MAX_IOV, + * implementation to support at least LNET_MAX_IOV, * so for Cray portals we can safely just use that * value here. * diff --git a/drivers/staging/lustre/lnet/Makefile b/drivers/staging/lustre/lnet/Makefile index 374212b1555..f6f03e304d8 100644 --- a/drivers/staging/lustre/lnet/Makefile +++ b/drivers/staging/lustre/lnet/Makefile @@ -1 +1 @@ -obj-$(CONFIG_LNET) := klnds/ lnet/ selftest/ +obj-$(CONFIG_LNET) += lnet/ klnds/ selftest/ diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 29a97943e4c..86397f96b03 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -702,6 +702,8 @@ kiblnd_get_completion_vector(kib_conn_t *conn, int cpt) return 0; mask = cfs_cpt_cpumask(lnet_cpt_table(), cpt); + if (mask == NULL) + return 0; /* hash NID to CPU id in this partition... */ off = do_div(nid, cpus_weight(*mask)); @@ -2574,8 +2576,8 @@ kiblnd_dev_need_failover(kib_dev_t *dev) rc = rdma_resolve_addr(cmid, (struct sockaddr *)&srcaddr, (struct sockaddr *)&dstaddr, 1); if (rc != 0 || cmid->device == NULL) { - CERROR("Failed to bind %s:%u.%u.%u.%u to device(%p): %d\n", - dev->ibd_ifname, HIPQUAD(dev->ibd_ifip), + CERROR("Failed to bind %s:%pI4h to device(%p): %d\n", + dev->ibd_ifname, &dev->ibd_ifip, cmid->device, rc); rdma_destroy_id(cmid); return rc; @@ -2647,8 +2649,8 @@ kiblnd_dev_failover(kib_dev_t *dev) /* Bind to failover device or port */ rc = rdma_bind_addr(cmid, (struct sockaddr *)&addr); if (rc != 0 || cmid->device == NULL) { - CERROR("Failed to bind %s:%u.%u.%u.%u to device(%p): %d\n", - dev->ibd_ifname, HIPQUAD(dev->ibd_ifip), + CERROR("Failed to bind %s:%pI4h to device(%p): %d\n", + dev->ibd_ifname, &dev->ibd_ifip, cmid->device, rc); rdma_destroy_id(cmid); goto out; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index e4626bf82fc..938df0cf8c6 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -53,7 +53,6 @@ #include <linux/init.h> #include <linux/fs.h> #include <linux/file.h> -#include <linux/stat.h> #include <linux/list.h> #include <linux/kmod.h> #include <linux/sysctl.h> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index cc6232126dd..26b49a24b3d 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -1319,9 +1319,9 @@ kiblnd_connect_peer (kib_peer_t *peer) } LASSERT (cmid->device != NULL); - CDEBUG(D_NET, "%s: connection bound to %s:%u.%u.%u.%u:%s\n", + CDEBUG(D_NET, "%s: connection bound to %s:%pI4h:%s\n", libcfs_nid2str(peer->ibp_nid), dev->ibd_ifname, - HIPQUAD(dev->ibd_ifip), cmid->device->name); + &dev->ibd_ifip, cmid->device->name); return; @@ -1802,7 +1802,7 @@ kiblnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, int kiblnd_thread_start(int (*fn)(void *arg), void *arg, char *name) { - task_t *task = kthread_run(fn, arg, name); + struct task_struct *task = kthread_run(fn, arg, "%s", name); if (IS_ERR(task)) return PTR_ERR(task); @@ -2209,8 +2209,8 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob) if (*kiblnd_tunables.kib_require_priv_port && ntohs(peer_addr->sin_port) >= PROT_SOCK) { __u32 ip = ntohl(peer_addr->sin_addr.s_addr); - CERROR("Peer's port (%u.%u.%u.%u:%hu) is not privileged\n", - HIPQUAD(ip), ntohs(peer_addr->sin_port)); + CERROR("Peer's port (%pI4h:%hu) is not privileged\n", + &ip, ntohs(peer_addr->sin_port)); goto failed; } @@ -2254,11 +2254,11 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob) if (ni == NULL || /* no matching net */ ni->ni_nid != reqmsg->ibm_dstnid || /* right NET, wrong NID! */ net->ibn_dev != ibdev) { /* wrong device */ - CERROR("Can't accept %s on %s (%s:%d:%u.%u.%u.%u): " + CERROR("Can't accept %s on %s (%s:%d:%pI4h): " "bad dst nid %s\n", libcfs_nid2str(nid), ni == NULL ? "NA" : libcfs_nid2str(ni->ni_nid), ibdev->ibd_ifname, ibdev->ibd_nnets, - HIPQUAD(ibdev->ibd_ifip), + &ibdev->ibd_ifip, libcfs_nid2str(reqmsg->ibm_dstnid)); goto failed; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c index e21028b7230..92dc5672e2d 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -404,7 +404,7 @@ kiblnd_sysctl_init (void) sizeof(ipif_basename_space)); kiblnd_tunables.kib_sysctl = - cfs_register_sysctl_table(kiblnd_top_ctl_table, 0); + register_sysctl_table(kiblnd_top_ctl_table); if (kiblnd_tunables.kib_sysctl == NULL) CWARN("Can't setup /proc tunables\n"); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index c826bf9d49a..6825b452e5f 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -334,17 +334,17 @@ ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn) if (route->ksnr_myipaddr != conn->ksnc_myipaddr) { if (route->ksnr_myipaddr == 0) { /* route wasn't bound locally yet (the initial route) */ - CDEBUG(D_NET, "Binding %s %u.%u.%u.%u to %u.%u.%u.%u\n", + CDEBUG(D_NET, "Binding %s %pI4h to %pI4h\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(route->ksnr_ipaddr), - HIPQUAD(conn->ksnc_myipaddr)); + &route->ksnr_ipaddr, + &conn->ksnc_myipaddr); } else { - CDEBUG(D_NET, "Rebinding %s %u.%u.%u.%u from " - "%u.%u.%u.%u to %u.%u.%u.%u\n", + CDEBUG(D_NET, "Rebinding %s %pI4h from " + "%pI4h to %pI4h\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(route->ksnr_ipaddr), - HIPQUAD(route->ksnr_myipaddr), - HIPQUAD(conn->ksnc_myipaddr)); + &route->ksnr_ipaddr, + &route->ksnr_myipaddr, + &conn->ksnc_myipaddr); iface = ksocknal_ip2iface(route->ksnr_peer->ksnp_ni, route->ksnr_myipaddr); @@ -384,9 +384,9 @@ ksocknal_add_route_locked (ksock_peer_t *peer, ksock_route_t *route) route2 = list_entry(tmp, ksock_route_t, ksnr_list); if (route2->ksnr_ipaddr == route->ksnr_ipaddr) { - CERROR ("Duplicate route %s %u.%u.%u.%u\n", + CERROR("Duplicate route %s %pI4h\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(route->ksnr_ipaddr)); + &route->ksnr_ipaddr); LBUG(); } } @@ -982,8 +982,8 @@ ksocknal_accept (lnet_ni_t *ni, socket_t *sock) LIBCFS_ALLOC(cr, sizeof(*cr)); if (cr == NULL) { LCONSOLE_ERROR_MSG(0x12f, "Dropping connection request from " - "%u.%u.%u.%u: memory exhausted\n", - HIPQUAD(peer_ip)); + "%pI4h: memory exhausted\n", + &peer_ip); return -ENOMEM; } @@ -1236,10 +1236,10 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route, * code below probably isn't going to work. */ if (active && route->ksnr_ipaddr != conn->ksnc_ipaddr) { - CERROR("Route %s %u.%u.%u.%u connected to %u.%u.%u.%u\n", + CERROR("Route %s %pI4h connected to %pI4h\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(route->ksnr_ipaddr), - HIPQUAD(conn->ksnc_ipaddr)); + &route->ksnr_ipaddr, + &conn->ksnc_ipaddr); } /* Search for a route corresponding to the new connection and @@ -1297,10 +1297,10 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route, * socket callbacks. */ - CDEBUG(D_NET, "New conn %s p %d.x %u.%u.%u.%u -> %u.%u.%u.%u/%d" + CDEBUG(D_NET, "New conn %s p %d.x %pI4h -> %pI4h/%d" " incarnation:"LPD64" sched[%d:%d]\n", libcfs_id2str(peerid), conn->ksnc_proto->pro_version, - HIPQUAD(conn->ksnc_myipaddr), HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_myipaddr, &conn->ksnc_ipaddr, conn->ksnc_port, incarnation, cpt, (int)(sched - &sched->kss_info->ksi_scheds[0])); @@ -1441,7 +1441,7 @@ ksocknal_close_conn_locked (ksock_conn_t *conn, int error) conn->ksnc_route = NULL; -#if 0 /* irrelevent with only eager routes */ +#if 0 /* irrelevant with only eager routes */ /* make route least favourite */ list_del (&route->ksnr_list); list_add_tail (&route->ksnr_list, &peer->ksnp_routes); @@ -1496,7 +1496,7 @@ ksocknal_peer_failed (ksock_peer_t *peer) /* There has been a connection failure or comms error; but I'll only * tell LNET I think the peer is dead if it's to another kernel and - * there are no connections or connection attempts in existance. */ + * there are no connections or connection attempts in existence. */ read_lock(&ksocknal_data.ksnd_global_lock); @@ -1648,10 +1648,10 @@ ksocknal_destroy_conn (ksock_conn_t *conn) last_rcv = conn->ksnc_rx_deadline - cfs_time_seconds(*ksocknal_tunables.ksnd_timeout); CERROR("Completing partial receive from %s[%d]" - ", ip %d.%d.%d.%d:%d, with error, wanted: %d, left: %d, " + ", ip %pI4h:%d, with error, wanted: %d, left: %d, " "last alive is %ld secs ago\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type, - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port, + &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_rx_nob_wanted, conn->ksnc_rx_nob_left, cfs_duration_sec(cfs_time_sub(cfs_time_current(), last_rcv))); @@ -1661,25 +1661,25 @@ ksocknal_destroy_conn (ksock_conn_t *conn) case SOCKNAL_RX_LNET_HEADER: if (conn->ksnc_rx_started) CERROR("Incomplete receive of lnet header from %s" - ", ip %d.%d.%d.%d:%d, with error, protocol: %d.x.\n", + ", ip %pI4h:%d, with error, protocol: %d.x.\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port, + &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_proto->pro_version); break; case SOCKNAL_RX_KSM_HEADER: if (conn->ksnc_rx_started) CERROR("Incomplete receive of ksock message from %s" - ", ip %d.%d.%d.%d:%d, with error, protocol: %d.x.\n", + ", ip %pI4h:%d, with error, protocol: %d.x.\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port, + &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_proto->pro_version); break; case SOCKNAL_RX_SLOP: if (conn->ksnc_rx_started) CERROR("Incomplete receive of slops from %s" - ", ip %d.%d.%d.%d:%d, with error\n", + ", ip %pI4h:%d, with error\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + &conn->ksnc_ipaddr, conn->ksnc_port); break; default: LBUG (); @@ -2358,7 +2358,7 @@ ksocknal_new_incarnation (void) /* The incarnation number is the time this module loaded and it * identifies this particular instance of the socknal. Hopefully * we won't be able to reboot more frequently than 1MHz for the - * forseeable future :) */ + * foreseeable future :) */ do_gettimeofday(&tv); @@ -2898,5 +2898,7 @@ ksocknal_module_init (void) MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); MODULE_DESCRIPTION("Kernel TCP Socket LND v3.0.0"); MODULE_LICENSE("GPL"); +MODULE_VERSION("3.0.0"); -cfs_module(ksocknal, "3.0.0", ksocknal_module_init, ksocknal_module_fini); +module_init(ksocknal_module_init); +module_exit(ksocknal_module_fini); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index ad5e2410423..68a4f52ec99 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -343,7 +343,6 @@ ksocknal_receive (ksock_conn_t *conn) * Caller checks ksnc_rx_nob_wanted to determine * progress/completion. */ int rc; - ENTRY; if (ksocknal_data.ksnd_stall_rx != 0) { cfs_pause(cfs_time_seconds (ksocknal_data.ksnd_stall_rx)); @@ -381,7 +380,7 @@ ksocknal_receive (ksock_conn_t *conn) } ksocknal_connsock_decref(conn); - RETURN (rc); + return rc; } void @@ -389,7 +388,6 @@ ksocknal_tx_done (lnet_ni_t *ni, ksock_tx_t *tx) { lnet_msg_t *lnetmsg = tx->tx_lnetmsg; int rc = (tx->tx_resid == 0 && !tx->tx_zc_aborted) ? 0 : -EIO; - ENTRY; LASSERT(ni != NULL || tx->tx_conn != NULL); @@ -402,8 +400,6 @@ ksocknal_tx_done (lnet_ni_t *ni, ksock_tx_t *tx) ksocknal_free_tx (tx); if (lnetmsg != NULL) /* KSOCK_MSG_NOOP go without lnetmsg */ lnet_finalize (ni, lnetmsg, rc); - - EXIT; } void @@ -553,21 +549,21 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx) if (!conn->ksnc_closing) { switch (rc) { case -ECONNRESET: - LCONSOLE_WARN("Host %u.%u.%u.%u reset our connection " + LCONSOLE_WARN("Host %pI4h reset our connection " "while we were sending data; it may have " "rebooted.\n", - HIPQUAD(conn->ksnc_ipaddr)); + &conn->ksnc_ipaddr); break; default: LCONSOLE_WARN("There was an unexpected network error " - "while writing to %u.%u.%u.%u: %d.\n", - HIPQUAD(conn->ksnc_ipaddr), rc); + "while writing to %pI4h: %d.\n", + &conn->ksnc_ipaddr, rc); break; } CDEBUG(D_NET, "[%p] Error %d on write to %s" - " ip %d.%d.%d.%d:%d\n", conn, rc, + " ip %pI4h:%d\n", conn, rc, libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); } @@ -700,9 +696,9 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn) * ksnc_sock... */ LASSERT(!conn->ksnc_closing); - CDEBUG (D_NET, "Sending to %s ip %d.%d.%d.%d:%d\n", + CDEBUG(D_NET, "Sending to %s ip %pI4h:%d\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); ksocknal_tx_prep(conn, tx); @@ -801,9 +797,9 @@ ksocknal_find_connectable_route_locked (ksock_peer_t *peer) if (!(route->ksnr_retry_interval == 0 || /* first attempt */ cfs_time_aftereq(now, route->ksnr_timeout))) { CDEBUG(D_NET, - "Too soon to retry route %u.%u.%u.%u " + "Too soon to retry route %pI4h " "(cnted %d, interval %ld, %ld secs later)\n", - HIPQUAD(route->ksnr_ipaddr), + &route->ksnr_ipaddr, route->ksnr_connected, route->ksnr_retry_interval, cfs_duration_sec(route->ksnr_timeout - now)); @@ -1009,7 +1005,7 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) int ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name) { - task_t *task = kthread_run(fn, arg, name); + struct task_struct *task = kthread_run(fn, arg, "%s", name); if (IS_ERR(task)) return PTR_ERR(task); @@ -1120,7 +1116,7 @@ ksocknal_process_receive (ksock_conn_t *conn) LASSERT (atomic_read(&conn->ksnc_conn_refcount) > 0); /* NB: sched lock NOT held */ - /* SOCKNAL_RX_LNET_HEADER is here for backward compatability */ + /* SOCKNAL_RX_LNET_HEADER is here for backward compatibility */ LASSERT (conn->ksnc_rx_state == SOCKNAL_RX_KSM_HEADER || conn->ksnc_rx_state == SOCKNAL_RX_LNET_PAYLOAD || conn->ksnc_rx_state == SOCKNAL_RX_LNET_HEADER || @@ -1133,17 +1129,17 @@ ksocknal_process_receive (ksock_conn_t *conn) LASSERT (rc != -EAGAIN); if (rc == 0) - CDEBUG (D_NET, "[%p] EOF from %s" - " ip %d.%d.%d.%d:%d\n", conn, + CDEBUG(D_NET, "[%p] EOF from %s" + " ip %pI4h:%d\n", conn, libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); else if (!conn->ksnc_closing) - CERROR ("[%p] Error %d on read from %s" - " ip %d.%d.%d.%d:%d\n", + CERROR("[%p] Error %d on read from %s" + " ip %pI4h:%d\n", conn, rc, libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); /* it's not an error if conn is being closed */ @@ -1562,7 +1558,6 @@ int ksocknal_scheduler(void *arg) void ksocknal_read_callback (ksock_conn_t *conn) { ksock_sched_t *sched; - ENTRY; sched = conn->ksnc_scheduler; @@ -1580,8 +1575,6 @@ void ksocknal_read_callback (ksock_conn_t *conn) wake_up (&sched->kss_waitq); } spin_unlock_bh(&sched->kss_lock); - - EXIT; } /* @@ -1591,7 +1584,6 @@ void ksocknal_read_callback (ksock_conn_t *conn) void ksocknal_write_callback (ksock_conn_t *conn) { ksock_sched_t *sched; - ENTRY; sched = conn->ksnc_scheduler; @@ -1611,8 +1603,6 @@ void ksocknal_write_callback (ksock_conn_t *conn) } spin_unlock_bh(&sched->kss_lock); - - EXIT; } ksock_proto_t * @@ -1722,8 +1712,8 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, rc = libcfs_sock_read(sock, &hello->kshm_magic, sizeof (hello->kshm_magic), timeout); if (rc != 0) { - CERROR ("Error %d reading HELLO from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Error %d reading HELLO from %pI4h\n", + rc, &conn->ksnc_ipaddr); LASSERT (rc < 0); return rc; } @@ -1732,18 +1722,18 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, hello->kshm_magic != __swab32(LNET_PROTO_MAGIC) && hello->kshm_magic != le32_to_cpu (LNET_PROTO_TCP_MAGIC)) { /* Unexpected magic! */ - CERROR ("Bad magic(1) %#08x (%#08x expected) from " - "%u.%u.%u.%u\n", __cpu_to_le32 (hello->kshm_magic), + CERROR("Bad magic(1) %#08x (%#08x expected) from " + "%pI4h\n", __cpu_to_le32 (hello->kshm_magic), LNET_PROTO_TCP_MAGIC, - HIPQUAD(conn->ksnc_ipaddr)); + &conn->ksnc_ipaddr); return -EPROTO; } rc = libcfs_sock_read(sock, &hello->kshm_version, sizeof(hello->kshm_version), timeout); if (rc != 0) { - CERROR ("Error %d reading HELLO from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Error %d reading HELLO from %pI4h\n", + rc, &conn->ksnc_ipaddr); LASSERT (rc < 0); return rc; } @@ -1763,10 +1753,10 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, ksocknal_send_hello(ni, conn, ni->ni_nid, hello); } - CERROR ("Unknown protocol version (%d.x expected)" - " from %u.%u.%u.%u\n", + CERROR("Unknown protocol version (%d.x expected)" + " from %pI4h\n", conn->ksnc_proto->pro_version, - HIPQUAD(conn->ksnc_ipaddr)); + &conn->ksnc_ipaddr); return -EPROTO; } @@ -1777,8 +1767,8 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, /* receive the rest of hello message anyway */ rc = conn->ksnc_proto->pro_recv_hello(conn, hello, timeout); if (rc != 0) { - CERROR("Error %d reading or checking hello from from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Error %d reading or checking hello from from %pI4h\n", + rc, &conn->ksnc_ipaddr); LASSERT (rc < 0); return rc; } @@ -1787,7 +1777,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, if (hello->kshm_src_nid == LNET_NID_ANY) { CERROR("Expecting a HELLO hdr with a NID, but got LNET_NID_ANY" - "from %u.%u.%u.%u\n", HIPQUAD(conn->ksnc_ipaddr)); + "from %pI4h\n", &conn->ksnc_ipaddr); return -EPROTO; } @@ -1807,9 +1797,9 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, /* peer determines type */ conn->ksnc_type = ksocknal_invert_type(hello->kshm_ctype); if (conn->ksnc_type == SOCKLND_CONN_NONE) { - CERROR ("Unexpected type %d from %s ip %u.%u.%u.%u\n", + CERROR("Unexpected type %d from %s ip %pI4h\n", hello->kshm_ctype, libcfs_id2str(*peerid), - HIPQUAD(conn->ksnc_ipaddr)); + &conn->ksnc_ipaddr); return -EPROTO; } @@ -1819,11 +1809,11 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, if (peerid->pid != recv_id.pid || peerid->nid != recv_id.nid) { LCONSOLE_ERROR_MSG(0x130, "Connected successfully to %s on host" - " %u.%u.%u.%u, but they claimed they were " + " %pI4h, but they claimed they were " "%s; please check your Lustre " "configuration.\n", libcfs_id2str(*peerid), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, libcfs_id2str(recv_id)); return -EPROTO; } @@ -1834,9 +1824,9 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, } if (ksocknal_invert_type(hello->kshm_ctype) != conn->ksnc_type) { - CERROR ("Mismatched types: me %d, %s ip %u.%u.%u.%u %d\n", + CERROR("Mismatched types: me %d, %s ip %pI4h %d\n", conn->ksnc_type, libcfs_id2str(*peerid), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, hello->kshm_ctype); return -EPROTO; } @@ -1995,7 +1985,7 @@ ksocknal_connect (ksock_route_t *route) list_splice_init(&peer->ksnp_tx_queue, &zombies); } -#if 0 /* irrelevent with only eager routes */ +#if 0 /* irrelevant with only eager routes */ if (!route->ksnr_deleted) { /* make this route least-favourite for re-selection */ list_del(&route->ksnr_list); @@ -2208,8 +2198,8 @@ ksocknal_connd (void *arg) /* consecutive retry */ if (cons_retry++ > SOCKNAL_INSANITY_RECONN) { CWARN("massive consecutive " - "re-connecting to %u.%u.%u.%u\n", - HIPQUAD(route->ksnr_ipaddr)); + "re-connecting to %pI4h\n", + &route->ksnr_ipaddr); cons_retry = 0; } } else { @@ -2274,26 +2264,26 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) switch (error) { case ECONNRESET: CNETERR("A connection with %s " - "(%u.%u.%u.%u:%d) was reset; " + "(%pI4h:%d) was reset; " "it may have rebooted.\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); break; case ETIMEDOUT: CNETERR("A connection with %s " - "(%u.%u.%u.%u:%d) timed out; the " + "(%pI4h:%d) timed out; the " "network or node may be down.\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); break; default: CNETERR("An unexpected network error %d " "occurred with %s " - "(%u.%u.%u.%u:%d\n", error, + "(%pI4h:%d\n", error, libcfs_id2str(peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); break; } @@ -2306,10 +2296,10 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) conn->ksnc_rx_deadline)) { /* Timed out incomplete incoming message */ ksocknal_conn_addref(conn); - CNETERR("Timeout receiving from %s (%u.%u.%u.%u:%d), " + CNETERR("Timeout receiving from %s (%pI4h:%d), " "state %d wanted %d left %d\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_rx_state, conn->ksnc_rx_nob_wanted, @@ -2324,10 +2314,10 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) /* Timed out messages queued for sending or * buffered in the socket's send buffer */ ksocknal_conn_addref(conn); - CNETERR("Timeout sending data to %s (%u.%u.%u.%u:%d) " + CNETERR("Timeout sending data to %s (%pI4h:%d) " "the network or that node may be down.\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); return (conn); } diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c index 3e08fe2d148..a1c6a519bf5 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c @@ -316,7 +316,7 @@ ksocknal_lib_tunables_init () *ksocknal_tunables.ksnd_zc_recv_min_nfrags = LNET_MAX_IOV; ksocknal_tunables.ksnd_sysctl = - cfs_register_sysctl_table(ksocknal_top_ctl_table, 0); + register_sysctl_table(ksocknal_top_ctl_table); if (ksocknal_tunables.ksnd_sysctl == NULL) CWARN("Can't setup /proc tunables\n"); @@ -325,20 +325,20 @@ ksocknal_lib_tunables_init () } void -ksocknal_lib_tunables_fini () +ksocknal_lib_tunables_fini(void) { if (ksocknal_tunables.ksnd_sysctl != NULL) unregister_sysctl_table(ksocknal_tunables.ksnd_sysctl); } #else int -ksocknal_lib_tunables_init () +ksocknal_lib_tunables_init(void) { return 0; } void -ksocknal_lib_tunables_fini () +ksocknal_lib_tunables_fini(void) { } #endif /* # if CONFIG_SYSCTL && !CFS_SYSFS_MODULE_PARM */ @@ -964,7 +964,6 @@ static void ksocknal_data_ready (struct sock *sk, int n) { ksock_conn_t *conn; - ENTRY; /* interleave correctly with closing sockets... */ LASSERT(!in_irq()); @@ -978,8 +977,6 @@ ksocknal_data_ready (struct sock *sk, int n) ksocknal_read_callback(conn); read_unlock(&ksocknal_data.ksnd_global_lock); - - EXIT; } static void diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h index 3c135786dc1..1cfc1b168be 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h @@ -41,7 +41,6 @@ #include <linux/module.h> #include <linux/kernel.h> -#include <linux/version.h> #include <linux/mm.h> #include <linux/string.h> #include <linux/stat.h> @@ -58,11 +57,9 @@ #include <linux/init.h> #include <linux/fs.h> #include <linux/file.h> -#include <linux/stat.h> #include <linux/list.h> #include <linux/kmod.h> #include <linux/sysctl.h> -#include <asm/uaccess.h> #include <asm/div64.h> #include <linux/syscalls.h> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index ec57179f8d2..71205e2015c 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -218,7 +218,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn, if (tx->tx_msg.ksm_zc_cookies[0] > tx->tx_msg.ksm_zc_cookies[1]) { __u64 tmp = 0; - /* two seperated cookies: (a+2, a) or (a+1, a) */ + /* two separated cookies: (a+2, a) or (a+1, a) */ LASSERT (tx->tx_msg.ksm_zc_cookies[0] - tx->tx_msg.ksm_zc_cookies[1] <= 2); @@ -496,8 +496,8 @@ ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello) rc = libcfs_sock_write(sock, hdr, sizeof(*hdr),lnet_acceptor_timeout()); if (rc != 0) { - CNETERR("Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n", - rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n", + rc, &conn->ksnc_ipaddr, conn->ksnc_port); goto out; } @@ -513,8 +513,8 @@ ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello) lnet_acceptor_timeout()); if (rc != 0) { CNETERR("Error %d sending HELLO payload (%d)" - " to %u.%u.%u.%u/%d\n", rc, hello->kshm_nips, - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + " to %pI4h/%d\n", rc, hello->kshm_nips, + &conn->ksnc_ipaddr, conn->ksnc_port); } out: LIBCFS_FREE(hdr, sizeof(*hdr)); @@ -545,8 +545,8 @@ ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello) lnet_acceptor_timeout()); if (rc != 0) { - CNETERR("Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n", - rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n", + rc, &conn->ksnc_ipaddr, conn->ksnc_port); return rc; } @@ -558,8 +558,8 @@ ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello) lnet_acceptor_timeout()); if (rc != 0) { CNETERR("Error %d sending HELLO payload (%d)" - " to %u.%u.%u.%u/%d\n", rc, hello->kshm_nips, - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + " to %pI4h/%d\n", rc, hello->kshm_nips, + &conn->ksnc_ipaddr, conn->ksnc_port); } return rc; @@ -583,18 +583,18 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) sizeof (*hdr) - offsetof (lnet_hdr_t, src_nid), timeout); if (rc != 0) { - CERROR ("Error %d reading rest of HELLO hdr from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Error %d reading rest of HELLO hdr from %pI4h\n", + rc, &conn->ksnc_ipaddr); LASSERT (rc < 0 && rc != -EALREADY); goto out; } /* ...and check we got what we expected */ if (hdr->type != cpu_to_le32 (LNET_MSG_HELLO)) { - CERROR ("Expecting a HELLO hdr," - " but got type %d from %u.%u.%u.%u\n", + CERROR("Expecting a HELLO hdr," + " but got type %d from %pI4h\n", le32_to_cpu (hdr->type), - HIPQUAD(conn->ksnc_ipaddr)); + &conn->ksnc_ipaddr); rc = -EPROTO; goto out; } @@ -607,8 +607,8 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) sizeof (__u32); if (hello->kshm_nips > LNET_MAX_INTERFACES) { - CERROR("Bad nips %d from ip %u.%u.%u.%u\n", - hello->kshm_nips, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Bad nips %d from ip %pI4h\n", + hello->kshm_nips, &conn->ksnc_ipaddr); rc = -EPROTO; goto out; } @@ -619,9 +619,9 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) rc = libcfs_sock_read(sock, hello->kshm_ips, hello->kshm_nips * sizeof(__u32), timeout); if (rc != 0) { - CERROR ("Error %d reading IPs from ip %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); - LASSERT (rc < 0 && rc != -EALREADY); + CERROR("Error %d reading IPs from ip %pI4h\n", + rc, &conn->ksnc_ipaddr); + LASSERT(rc < 0 && rc != -EALREADY); goto out; } @@ -629,8 +629,8 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) hello->kshm_ips[i] = __le32_to_cpu(hello->kshm_ips[i]); if (hello->kshm_ips[i] == 0) { - CERROR("Zero IP[%d] from ip %u.%u.%u.%u\n", - i, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Zero IP[%d] from ip %pI4h\n", + i, &conn->ksnc_ipaddr); rc = -EPROTO; break; } @@ -658,9 +658,9 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou offsetof(ksock_hello_msg_t, kshm_src_nid), timeout); if (rc != 0) { - CERROR ("Error %d reading HELLO from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); - LASSERT (rc < 0 && rc != -EALREADY); + CERROR("Error %d reading HELLO from %pI4h\n", + rc, &conn->ksnc_ipaddr); + LASSERT(rc < 0 && rc != -EALREADY); return rc; } @@ -676,8 +676,8 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou } if (hello->kshm_nips > LNET_MAX_INTERFACES) { - CERROR("Bad nips %d from ip %u.%u.%u.%u\n", - hello->kshm_nips, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Bad nips %d from ip %pI4h\n", + hello->kshm_nips, &conn->ksnc_ipaddr); return -EPROTO; } @@ -687,9 +687,9 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou rc = libcfs_sock_read(sock, hello->kshm_ips, hello->kshm_nips * sizeof(__u32), timeout); if (rc != 0) { - CERROR ("Error %d reading IPs from ip %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); - LASSERT (rc < 0 && rc != -EALREADY); + CERROR("Error %d reading IPs from ip %pI4h\n", + rc, &conn->ksnc_ipaddr); + LASSERT(rc < 0 && rc != -EALREADY); return rc; } @@ -698,8 +698,8 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou __swab32s(&hello->kshm_ips[i]); if (hello->kshm_ips[i] == 0) { - CERROR("Zero IP[%d] from ip %u.%u.%u.%u\n", - i, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Zero IP[%d] from ip %pI4h\n", + i, &conn->ksnc_ipaddr); return -EPROTO; } } diff --git a/drivers/staging/lustre/lnet/lnet/Makefile b/drivers/staging/lustre/lnet/lnet/Makefile index 1bd9ef77420..b815fe12b10 100644 --- a/drivers/staging/lustre/lnet/lnet/Makefile +++ b/drivers/staging/lustre/lnet/lnet/Makefile @@ -1,6 +1,6 @@ obj-$(CONFIG_LNET) += lnet.o -lnet-y := api-errno.o api-ni.o config.o lib-me.o lib-msg.o lib-eq.o \ +lnet-y := api-ni.o config.o lib-me.o lib-msg.o lib-eq.o \ lib-md.o lib-ptl.o lib-move.o module.o lo.o router.o \ router_proc.o acceptor.o peer.o diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 81ef28bbcba..bb15bde0704 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -101,52 +101,52 @@ lnet_connect_console_error (int rc, lnet_nid_t peer_nid, switch (rc) { /* "normal" errors */ case -ECONNREFUSED: - CNETERR("Connection to %s at host %u.%u.%u.%u on port %d was " + CNETERR("Connection to %s at host %pI4h on port %d was " "refused: check that Lustre is running on that node.\n", libcfs_nid2str(peer_nid), - HIPQUAD(peer_ip), peer_port); + &peer_ip, peer_port); break; case -EHOSTUNREACH: case -ENETUNREACH: - CNETERR("Connection to %s at host %u.%u.%u.%u " + CNETERR("Connection to %s at host %pI4h " "was unreachable: the network or that node may " "be down, or Lustre may be misconfigured.\n", - libcfs_nid2str(peer_nid), HIPQUAD(peer_ip)); + libcfs_nid2str(peer_nid), &peer_ip); break; case -ETIMEDOUT: - CNETERR("Connection to %s at host %u.%u.%u.%u on " + CNETERR("Connection to %s at host %pI4h on " "port %d took too long: that node may be hung " "or experiencing high load.\n", libcfs_nid2str(peer_nid), - HIPQUAD(peer_ip), peer_port); + &peer_ip, peer_port); break; case -ECONNRESET: - LCONSOLE_ERROR_MSG(0x11b, "Connection to %s at host %u.%u.%u.%u" + LCONSOLE_ERROR_MSG(0x11b, "Connection to %s at host %pI4h" " on port %d was reset: " "is it running a compatible version of " "Lustre and is %s one of its NIDs?\n", libcfs_nid2str(peer_nid), - HIPQUAD(peer_ip), peer_port, + &peer_ip, peer_port, libcfs_nid2str(peer_nid)); break; case -EPROTO: LCONSOLE_ERROR_MSG(0x11c, "Protocol error connecting to %s at " - "host %u.%u.%u.%u on port %d: is it running " + "host %pI4h on port %d: is it running " "a compatible version of Lustre?\n", libcfs_nid2str(peer_nid), - HIPQUAD(peer_ip), peer_port); + &peer_ip, peer_port); break; case -EADDRINUSE: LCONSOLE_ERROR_MSG(0x11d, "No privileged ports available to " - "connect to %s at host %u.%u.%u.%u on port " + "connect to %s at host %pI4h on port " "%d\n", libcfs_nid2str(peer_nid), - HIPQUAD(peer_ip), peer_port); + &peer_ip, peer_port); break; default: LCONSOLE_ERROR_MSG(0x11e, "Unexpected error %d connecting to %s" - " at host %u.%u.%u.%u on port %d\n", rc, + " at host %pI4h on port %d\n", rc, libcfs_nid2str(peer_nid), - HIPQUAD(peer_ip), peer_port); + &peer_ip, peer_port); break; } } @@ -253,8 +253,8 @@ lnet_accept(socket_t *sock, __u32 magic) if (rc != 0) CERROR("Error sending magic+version in response" - "to LNET magic from %u.%u.%u.%u: %d\n", - HIPQUAD(peer_ip), rc); + "to LNET magic from %pI4h: %d\n", + &peer_ip, rc); return -EPROTO; } @@ -265,9 +265,9 @@ lnet_accept(socket_t *sock, __u32 magic) else str = "unrecognised"; - LCONSOLE_ERROR_MSG(0x11f, "Refusing connection from %u.%u.%u.%u" + LCONSOLE_ERROR_MSG(0x11f, "Refusing connection from %pI4h" " magic %08x: %s acceptor protocol\n", - HIPQUAD(peer_ip), magic, str); + &peer_ip, magic, str); return -EPROTO; } @@ -278,7 +278,7 @@ lnet_accept(socket_t *sock, __u32 magic) accept_timeout); if (rc != 0) { CERROR("Error %d reading connection request version from " - "%u.%u.%u.%u\n", rc, HIPQUAD(peer_ip)); + "%pI4h\n", rc, &peer_ip); return -EIO; } @@ -301,8 +301,8 @@ lnet_accept(socket_t *sock, __u32 magic) if (rc != 0) CERROR("Error sending magic+version in response" - "to version %d from %u.%u.%u.%u: %d\n", - peer_version, HIPQUAD(peer_ip), rc); + "to version %d from %pI4h: %d\n", + peer_version, &peer_ip, rc); return -EPROTO; } @@ -312,7 +312,7 @@ lnet_accept(socket_t *sock, __u32 magic) accept_timeout); if (rc != 0) { CERROR("Error %d reading connection request from " - "%u.%u.%u.%u\n", rc, HIPQUAD(peer_ip)); + "%pI4h\n", rc, &peer_ip); return -EIO; } @@ -324,23 +324,23 @@ lnet_accept(socket_t *sock, __u32 magic) ni->ni_nid != cr.acr_nid) { /* right NET, wrong NID! */ if (ni != NULL) lnet_ni_decref(ni); - LCONSOLE_ERROR_MSG(0x120, "Refusing connection from %u.%u.%u.%u" + LCONSOLE_ERROR_MSG(0x120, "Refusing connection from %pI4h" " for %s: No matching NI\n", - HIPQUAD(peer_ip), libcfs_nid2str(cr.acr_nid)); + &peer_ip, libcfs_nid2str(cr.acr_nid)); return -EPERM; } if (ni->ni_lnd->lnd_accept == NULL) { /* This catches a request for the loopback LND */ lnet_ni_decref(ni); - LCONSOLE_ERROR_MSG(0x121, "Refusing connection from %u.%u.%u.%u" + LCONSOLE_ERROR_MSG(0x121, "Refusing connection from %pI4h" " for %s: NI doesn not accept IP connections\n", - HIPQUAD(peer_ip), libcfs_nid2str(cr.acr_nid)); + &peer_ip, libcfs_nid2str(cr.acr_nid)); return -EPERM; } - CDEBUG(D_NET, "Accept %s from %u.%u.%u.%u\n", - libcfs_nid2str(cr.acr_nid), HIPQUAD(peer_ip)); + CDEBUG(D_NET, "Accept %s from %pI4h\n", + libcfs_nid2str(cr.acr_nid), &peer_ip); rc = ni->ni_lnd->lnd_accept(ni, sock); @@ -410,9 +410,9 @@ lnet_acceptor(void *arg) } if (secure && peer_port > LNET_ACCEPTOR_MAX_RESERVED_PORT) { - CERROR("Refusing connection from %u.%u.%u.%u: " + CERROR("Refusing connection from %pI4h: " "insecure port %d\n", - HIPQUAD(peer_ip), peer_port); + &peer_ip, peer_port); goto failed; } @@ -420,7 +420,7 @@ lnet_acceptor(void *arg) accept_timeout); if (rc != 0) { CERROR("Error %d reading connection request from " - "%u.%u.%u.%u\n", rc, HIPQUAD(peer_ip)); + "%pI4h\n", rc, &peer_ip); goto failed; } diff --git a/drivers/staging/lustre/lnet/lnet/api-errno.c b/drivers/staging/lustre/lnet/lnet/api-errno.c deleted file mode 100644 index 695b27265e2..00000000000 --- a/drivers/staging/lustre/lnet/lnet/api-errno.c +++ /dev/null @@ -1,39 +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) 2003, 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. - * - * lnet/lnet/api-errno.c - * - * Instantiate the string table of errors - */ - -/* If you change these, you must update the number table in portals/errno.h */ diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index e88bee36249..160a4292c6c 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1371,7 +1371,7 @@ EXPORT_SYMBOL(LNetNIInit); * \return always 0 for current implementation. */ int -LNetNIFini() +LNetNIFini(void) { LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex); @@ -1541,7 +1541,10 @@ LNetGetId(unsigned int index, lnet_process_id_t *id) int rc = -ENOENT; LASSERT(the_lnet.ln_init); - LASSERT(the_lnet.ln_refcount > 0); + + /* LNetNI initilization failed? */ + if (the_lnet.ln_refcount == 0) + return rc; cpt = lnet_net_lock_current(); diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 78297a7d94e..4ce68d3b093 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -244,11 +244,10 @@ lnet_eq_dequeue_event(lnet_eq_t *eq, lnet_event_t *ev) int new_index = eq->eq_deq_seq & (eq->eq_size - 1); lnet_event_t *new_event = &eq->eq_events[new_index]; int rc; - ENTRY; /* must called with lnet_eq_wait_lock hold */ if (LNET_SEQ_GT(eq->eq_deq_seq, new_event->sequence)) - RETURN(0); + return 0; /* We've got a new event... */ *ev = *new_event; @@ -268,7 +267,7 @@ lnet_eq_dequeue_event(lnet_eq_t *eq, lnet_event_t *ev) } eq->eq_deq_seq = new_event->sequence + 1; - RETURN(rc); + return rc; } /** @@ -400,13 +399,12 @@ LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, int wait = 1; int rc; int i; - ENTRY; LASSERT (the_lnet.ln_init); LASSERT (the_lnet.ln_refcount > 0); if (neq < 1) - RETURN(-ENOENT); + return -ENOENT; lnet_eq_wait_lock(); @@ -416,14 +414,14 @@ LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, if (eq == NULL) { lnet_eq_wait_unlock(); - RETURN(-ENOENT); + return -ENOENT; } rc = lnet_eq_dequeue_event(eq, event); if (rc != 0) { lnet_eq_wait_unlock(); *which = i; - RETURN(rc); + return rc; } } @@ -443,5 +441,5 @@ LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, } lnet_eq_wait_unlock(); - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index 8f3a50bd5f6..61ae88be6f0 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -45,8 +45,6 @@ void lnet_build_unlink_event (lnet_libmd_t *md, lnet_event_t *ev) { - ENTRY; - memset(ev, 0, sizeof(*ev)); ev->status = 0; @@ -54,7 +52,6 @@ lnet_build_unlink_event (lnet_libmd_t *md, lnet_event_t *ev) ev->type = LNET_EVENT_UNLINK; lnet_md_deconstruct(md, &ev->md); lnet_md2handle(&ev->md_handle, md); - EXIT; } /* @@ -319,7 +316,7 @@ lnet_msg_attach_md(lnet_msg_t *msg, lnet_libmd_t *md, LASSERT(!msg->msg_routing); msg->msg_md = md; - if (msg->msg_receiving) { /* commited for receiving */ + if (msg->msg_receiving) { /* committed for receiving */ msg->msg_offset = offset; msg->msg_wanted = mlen; } @@ -395,7 +392,7 @@ lnet_complete_msg_locked(lnet_msg_t *msg, int cpt) * NB: message is committed for sending, we should return * on success because LND will finalize this message later. * - * Also, there is possibility that message is commited for + * Also, there is possibility that message is committed for * sending and also failed before delivering to LND, * i.e: ENOMEM, in that case we can't fall through either * because CPT for sending can be different with CPT for @@ -417,7 +414,7 @@ lnet_complete_msg_locked(lnet_msg_t *msg, int cpt) * NB: message is committed for sending, we should return * on success because LND will finalize this message later. * - * Also, there is possibility that message is commited for + * Also, there is possibility that message is committed for * sending and also failed before delivering to LND, * i.e: ENOMEM, in that case we can't fall through either: * - The rule is message must decommit for sending first if @@ -477,14 +474,14 @@ lnet_finalize (lnet_ni_t *ni, lnet_msg_t *msg, int status) again: rc = 0; if (!msg->msg_tx_committed && !msg->msg_rx_committed) { - /* not commited to network yet */ + /* not committed to network yet */ LASSERT(!msg->msg_onactivelist); lnet_msg_free(msg); return; } /* - * NB: routed message can be commited for both receiving and sending, + * NB: routed message can be committed for both receiving and sending, * we should finalize in LIFO order and keep counters correct. * (finalize sending first then finalize receiving) */ diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index c8323854580..afb81755cba 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -114,14 +114,13 @@ int init_lnet(void) { int rc; - ENTRY; mutex_init(&lnet_config_mutex); rc = LNetInit(); if (rc != 0) { CERROR("LNetInit: error %d\n", rc); - RETURN(rc); + return rc; } rc = libcfs_register_ioctl(&lnet_ioctl_handler); @@ -133,7 +132,7 @@ init_lnet(void) (void) kthread_run(lnet_configure, NULL, "lnet_initd"); } - RETURN(0); + return 0; } void @@ -150,5 +149,7 @@ fini_lnet(void) MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>"); MODULE_DESCRIPTION("Portals v3.1"); MODULE_LICENSE("GPL"); +MODULE_VERSION("1.0.0"); -cfs_module(lnet, "1.0.0", init_lnet, fini_lnet); +module_init(init_lnet); +module_exit(fini_lnet); diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index 3084b0c7598..931f6ca25dc 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -920,7 +920,7 @@ lnet_proc_init(void) { #ifdef CONFIG_SYSCTL if (lnet_table_header == NULL) - lnet_table_header = cfs_register_sysctl_table(top_table, 0); + lnet_table_header = register_sysctl_table(top_table); #endif } diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index 3bb6fbe23f7..ef5064e0055 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -361,7 +361,7 @@ brw_server_rpc_done (srpc_server_rpc_t *rpc) blk->bk_sink ? "from" : "to", libcfs_id2str(rpc->srpc_peer), rpc->srpc_status); else - CDEBUG (D_NET, "Transfered %d pages bulk data %s %s\n", + CDEBUG (D_NET, "Transferred %d pages bulk data %s %s\n", blk->bk_niov, blk->bk_sink ? "from" : "to", libcfs_id2str(rpc->srpc_peer)); diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index 446de0e4672..cbce662b987 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -1356,7 +1356,7 @@ lstcon_rpc_cleanup_wait(void) lst_wait_until((atomic_read(&console_session.ses_rpc_counter) == 0), console_session.ses_rpc_lock, - "Network is not accessable or target is down, " + "Network is not accessible or target is down, " "waiting for %d console RPCs to being recycled\n", atomic_read(&console_session.ses_rpc_counter)); diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 78e8d046726..09e4700af64 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -1773,7 +1773,7 @@ lstcon_session_info(lst_sid_t *sid_up, int *key_up, unsigned *featp, } int -lstcon_session_end() +lstcon_session_end(void) { lstcon_rpc_trans_t *trans; lstcon_group_t *grp; diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c index 5257e5630a0..6dd4309dc5e 100644 --- a/drivers/staging/lustre/lnet/selftest/module.c +++ b/drivers/staging/lustre/lnet/selftest/module.c @@ -165,5 +165,7 @@ error: MODULE_DESCRIPTION("LNet Selftest"); MODULE_LICENSE("GPL"); +MODULE_VERSION("0.9.0"); -cfs_module(lnet, "0.9.0", lnet_selftest_init, lnet_selftest_fini); +module_init(lnet_selftest_init); +module_exit(lnet_selftest_fini); diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index bc1f38b8048..7659a26676b 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -661,8 +661,10 @@ srpc_finish_service(struct srpc_service *sv) cfs_percpt_for_each(scd, i, sv->sv_cpt_data) { spin_lock(&scd->scd_lock); - if (!swi_deschedule_workitem(&scd->scd_buf_wi)) + if (!swi_deschedule_workitem(&scd->scd_buf_wi)) { + spin_unlock(&scd->scd_lock); return 0; + } if (scd->scd_buf_nposted > 0) { CDEBUG(D_NET, "waiting for %d posted buffers to unlink", @@ -1115,7 +1117,7 @@ srpc_del_client_rpc_timer (srpc_client_rpc_t *rpc) if (rpc->crpc_timeout == 0) return; - /* timer sucessfully defused */ + /* timer successfully defused */ if (stt_del_timer(&rpc->crpc_timer)) return; diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c index 2c078550277..3bf4afb42ff 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.c +++ b/drivers/staging/lustre/lnet/selftest/timer.c @@ -195,7 +195,7 @@ stt_timer_main (void *arg) int stt_start_timer_thread (void) { - task_t *task; + struct task_struct *task; LASSERT(!stt_data.stt_shuttingdown); diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig index e0eb8303a50..2156a44d074 100644 --- a/drivers/staging/lustre/lustre/Kconfig +++ b/drivers/staging/lustre/lustre/Kconfig @@ -1,6 +1,6 @@ config LUSTRE_FS tristate "Lustre file system client support" - depends on STAGING && INET && BROKEN + depends on INET && m && !MIPS && !XTENSA && !SUPERH select LNET select CRYPTO select CRYPTO_CRC32 @@ -43,9 +43,18 @@ config LUSTRE_OBD_MAX_IOCTL_BUFFER config LUSTRE_DEBUG_EXPENSIVE_CHECK bool "Enable Lustre DEBUG checks" depends on LUSTRE_FS - default false help This option is mainly for debug purpose. It enables Lustre code to do expensive checks that may have a performance impact. Use with caution. If unsure, say N. + +config LUSTRE_TRANSLATE_ERRNOS + bool + depends on LUSTRE_FS && !X86 + default y + +config LUSTRE_LLITE_LLOOP + bool "Lustre virtual block device" + depends on LUSTRE_FS && BLOCK + default m diff --git a/drivers/staging/lustre/lustre/Makefile b/drivers/staging/lustre/lustre/Makefile index 3fb94fc1206..d1eb0bdef06 100644 --- a/drivers/staging/lustre/lustre/Makefile +++ b/drivers/staging/lustre/lustre/Makefile @@ -1,2 +1,2 @@ -obj-$(CONFIG_LUSTRE_FS) := fid/ lvfs/ obdclass/ ptlrpc/ obdecho/ mgc/ lov/ \ - osc/ mdc/ lmv/ llite/ fld/ libcfs/ +obj-$(CONFIG_LUSTRE_FS) += libcfs/ lvfs/ obdclass/ ptlrpc/ fld/ osc/ mgc/ \ + fid/ lov/ mdc/ lmv/ llite/ obdecho/ diff --git a/drivers/staging/lustre/lustre/fid/Makefile b/drivers/staging/lustre/lustre/fid/Makefile index b8d6d21b39f..ed21bea162b 100644 --- a/drivers/staging/lustre/lustre/fid/Makefile +++ b/drivers/staging/lustre/lustre/fid/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_LUSTRE_FS) += fid.o -fid-y := fid_handler.o fid_store.o fid_request.o lproc_fid.o fid_lib.o +fid-y := fid_request.o lproc_fid.o fid_lib.o ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/fid/fid_handler.c b/drivers/staging/lustre/lustre/fid/fid_handler.c deleted file mode 100644 index bbbb3cfe57b..00000000000 --- a/drivers/staging/lustre/lustre/fid/fid_handler.c +++ /dev/null @@ -1,661 +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/fid/fid_handler.c - * - * Lustre Sequence Manager - * - * Author: Yury Umanets <umka@clusterfs.com> - */ - -#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 "fid_internal.h" - -int client_fid_init(struct obd_device *obd, - struct obd_export *exp, enum lu_cli_type type) -{ - struct client_obd *cli = &obd->u.cli; - char *prefix; - int rc; - ENTRY; - - OBD_ALLOC_PTR(cli->cl_seq); - if (cli->cl_seq == NULL) - RETURN(-ENOMEM); - - OBD_ALLOC(prefix, MAX_OBD_NAME + 5); - if (prefix == NULL) - GOTO(out_free_seq, rc = -ENOMEM); - - snprintf(prefix, MAX_OBD_NAME + 5, "cli-%s", obd->obd_name); - - /* Init client side sequence-manager */ - rc = seq_client_init(cli->cl_seq, exp, type, prefix, NULL); - OBD_FREE(prefix, MAX_OBD_NAME + 5); - if (rc) - GOTO(out_free_seq, rc); - - RETURN(rc); -out_free_seq: - OBD_FREE_PTR(cli->cl_seq); - cli->cl_seq = NULL; - return rc; -} -EXPORT_SYMBOL(client_fid_init); - -int client_fid_fini(struct obd_device *obd) -{ - struct client_obd *cli = &obd->u.cli; - ENTRY; - - if (cli->cl_seq != NULL) { - seq_client_fini(cli->cl_seq); - OBD_FREE_PTR(cli->cl_seq); - cli->cl_seq = NULL; - } - - RETURN(0); -} -EXPORT_SYMBOL(client_fid_fini); - -static void seq_server_proc_fini(struct lu_server_seq *seq); - -/* Assigns client to sequence controller node. */ -int seq_server_set_cli(struct lu_server_seq *seq, - struct lu_client_seq *cli, - const struct lu_env *env) -{ - int rc = 0; - ENTRY; - - /* - * Ask client for new range, assign that range to ->seq_space and write - * seq state to backing store should be atomic. - */ - mutex_lock(&seq->lss_mutex); - - if (cli == NULL) { - CDEBUG(D_INFO, "%s: Detached sequence client %s\n", - seq->lss_name, cli->lcs_name); - seq->lss_cli = cli; - GOTO(out_up, rc = 0); - } - - if (seq->lss_cli != NULL) { - CDEBUG(D_HA, "%s: Sequence controller is already " - "assigned\n", seq->lss_name); - GOTO(out_up, rc = -EEXIST); - } - - CDEBUG(D_INFO, "%s: Attached sequence controller %s\n", - seq->lss_name, cli->lcs_name); - - seq->lss_cli = cli; - cli->lcs_space.lsr_index = seq->lss_site->ss_node_id; - EXIT; -out_up: - mutex_unlock(&seq->lss_mutex); - return rc; -} -EXPORT_SYMBOL(seq_server_set_cli); -/* - * allocate \a w units of sequence from range \a from. - */ -static inline void range_alloc(struct lu_seq_range *to, - struct lu_seq_range *from, - __u64 width) -{ - width = min(range_space(from), width); - to->lsr_start = from->lsr_start; - to->lsr_end = from->lsr_start + width; - from->lsr_start += width; -} - -/** - * On controller node, allocate new super sequence for regular sequence server. - * As this super sequence controller, this node suppose to maintain fld - * and update index. - * \a out range always has currect mds node number of requester. - */ - -static int __seq_server_alloc_super(struct lu_server_seq *seq, - struct lu_seq_range *out, - const struct lu_env *env) -{ - struct lu_seq_range *space = &seq->lss_space; - int rc; - ENTRY; - - LASSERT(range_is_sane(space)); - - if (range_is_exhausted(space)) { - CERROR("%s: Sequences space is exhausted\n", - seq->lss_name); - RETURN(-ENOSPC); - } else { - range_alloc(out, space, seq->lss_width); - } - - rc = seq_store_update(env, seq, out, 1 /* sync */); - - LCONSOLE_INFO("%s: super-sequence allocation rc = %d " DRANGE"\n", - seq->lss_name, rc, PRANGE(out)); - - RETURN(rc); -} - -int seq_server_alloc_super(struct lu_server_seq *seq, - struct lu_seq_range *out, - const struct lu_env *env) -{ - int rc; - ENTRY; - - mutex_lock(&seq->lss_mutex); - rc = __seq_server_alloc_super(seq, out, env); - mutex_unlock(&seq->lss_mutex); - - RETURN(rc); -} - -static int __seq_set_init(const struct lu_env *env, - struct lu_server_seq *seq) -{ - struct lu_seq_range *space = &seq->lss_space; - int rc; - - range_alloc(&seq->lss_lowater_set, space, seq->lss_set_width); - range_alloc(&seq->lss_hiwater_set, space, seq->lss_set_width); - - rc = seq_store_update(env, seq, NULL, 1); - - return rc; -} - -/* - * This function implements new seq allocation algorithm using async - * updates to seq file on disk. ref bug 18857 for details. - * there are four variable to keep track of this process - * - * lss_space; - available lss_space - * lss_lowater_set; - lu_seq_range for all seqs before barrier, i.e. safe to use - * lss_hiwater_set; - lu_seq_range after barrier, i.e. allocated but may be - * not yet committed - * - * when lss_lowater_set reaches the end it is replaced with hiwater one and - * a write operation is initiated to allocate new hiwater range. - * if last seq write opearion is still not commited, current operation is - * flaged as sync write op. - */ -static int range_alloc_set(const struct lu_env *env, - struct lu_seq_range *out, - struct lu_server_seq *seq) -{ - struct lu_seq_range *space = &seq->lss_space; - struct lu_seq_range *loset = &seq->lss_lowater_set; - struct lu_seq_range *hiset = &seq->lss_hiwater_set; - int rc = 0; - - if (range_is_zero(loset)) - __seq_set_init(env, seq); - - if (OBD_FAIL_CHECK(OBD_FAIL_SEQ_ALLOC)) /* exhaust set */ - loset->lsr_start = loset->lsr_end; - - if (range_is_exhausted(loset)) { - /* reached high water mark. */ - struct lu_device *dev = seq->lss_site->ss_lu->ls_top_dev; - int obd_num_clients = dev->ld_obd->obd_num_exports; - __u64 set_sz; - - /* calculate new seq width based on number of clients */ - set_sz = max(seq->lss_set_width, - obd_num_clients * seq->lss_width); - set_sz = min(range_space(space), set_sz); - - /* Switch to hiwater range now */ - *loset = *hiset; - /* allocate new hiwater range */ - range_alloc(hiset, space, set_sz); - - /* update ondisk seq with new *space */ - rc = seq_store_update(env, seq, NULL, seq->lss_need_sync); - } - - LASSERTF(!range_is_exhausted(loset) || range_is_sane(loset), - DRANGE"\n", PRANGE(loset)); - - if (rc == 0) - range_alloc(out, loset, seq->lss_width); - - RETURN(rc); -} - -static int __seq_server_alloc_meta(struct lu_server_seq *seq, - struct lu_seq_range *out, - const struct lu_env *env) -{ - struct lu_seq_range *space = &seq->lss_space; - int rc = 0; - - ENTRY; - - LASSERT(range_is_sane(space)); - - /* Check if available space ends and allocate new super seq */ - if (range_is_exhausted(space)) { - if (!seq->lss_cli) { - CERROR("%s: No sequence controller is attached.\n", - seq->lss_name); - RETURN(-ENODEV); - } - - rc = seq_client_alloc_super(seq->lss_cli, env); - if (rc) { - CERROR("%s: Can't allocate super-sequence, rc %d\n", - seq->lss_name, rc); - RETURN(rc); - } - - /* Saving new range to allocation space. */ - *space = seq->lss_cli->lcs_space; - LASSERT(range_is_sane(space)); - } - - rc = range_alloc_set(env, out, seq); - if (rc != 0) { - CERROR("%s: Allocated meta-sequence failed: rc = %d\n", - seq->lss_name, rc); - RETURN(rc); - } - - CDEBUG(D_INFO, "%s: Allocated meta-sequence " DRANGE"\n", - seq->lss_name, PRANGE(out)); - - RETURN(rc); -} - -int seq_server_alloc_meta(struct lu_server_seq *seq, - struct lu_seq_range *out, - const struct lu_env *env) -{ - int rc; - ENTRY; - - mutex_lock(&seq->lss_mutex); - rc = __seq_server_alloc_meta(seq, out, env); - mutex_unlock(&seq->lss_mutex); - - RETURN(rc); -} -EXPORT_SYMBOL(seq_server_alloc_meta); - -static int seq_server_handle(struct lu_site *site, - const struct lu_env *env, - __u32 opc, struct lu_seq_range *out) -{ - int rc; - struct seq_server_site *ss_site; - ENTRY; - - ss_site = lu_site2seq(site); - - switch (opc) { - case SEQ_ALLOC_META: - if (!ss_site->ss_server_seq) { - CERROR("Sequence server is not " - "initialized\n"); - RETURN(-EINVAL); - } - rc = seq_server_alloc_meta(ss_site->ss_server_seq, out, env); - break; - case SEQ_ALLOC_SUPER: - if (!ss_site->ss_control_seq) { - CERROR("Sequence controller is not " - "initialized\n"); - RETURN(-EINVAL); - } - rc = seq_server_alloc_super(ss_site->ss_control_seq, out, env); - break; - default: - rc = -EINVAL; - break; - } - - RETURN(rc); -} - -static int seq_req_handle(struct ptlrpc_request *req, - const struct lu_env *env, - struct seq_thread_info *info) -{ - struct lu_seq_range *out, *tmp; - struct lu_site *site; - int rc = -EPROTO; - __u32 *opc; - ENTRY; - - LASSERT(!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)); - site = req->rq_export->exp_obd->obd_lu_dev->ld_site; - LASSERT(site != NULL); - - rc = req_capsule_server_pack(info->sti_pill); - if (rc) - RETURN(err_serious(rc)); - - opc = req_capsule_client_get(info->sti_pill, &RMF_SEQ_OPC); - if (opc != NULL) { - out = req_capsule_server_get(info->sti_pill, &RMF_SEQ_RANGE); - if (out == NULL) - RETURN(err_serious(-EPROTO)); - - tmp = req_capsule_client_get(info->sti_pill, &RMF_SEQ_RANGE); - - /* seq client passed mdt id, we need to pass that using out - * range parameter */ - - out->lsr_index = tmp->lsr_index; - out->lsr_flags = tmp->lsr_flags; - rc = seq_server_handle(site, env, *opc, out); - } else - rc = err_serious(-EPROTO); - - RETURN(rc); -} - -/* context key constructor/destructor: seq_key_init, seq_key_fini */ -LU_KEY_INIT_FINI(seq, struct seq_thread_info); - -/* context key: seq_thread_key */ -LU_CONTEXT_KEY_DEFINE(seq, LCT_MD_THREAD | LCT_DT_THREAD); - -static void seq_thread_info_init(struct ptlrpc_request *req, - struct seq_thread_info *info) -{ - info->sti_pill = &req->rq_pill; - /* Init request capsule */ - req_capsule_init(info->sti_pill, req, RCL_SERVER); - req_capsule_set(info->sti_pill, &RQF_SEQ_QUERY); -} - -static void seq_thread_info_fini(struct seq_thread_info *info) -{ - req_capsule_fini(info->sti_pill); -} - -int seq_handle(struct ptlrpc_request *req) -{ - const struct lu_env *env; - struct seq_thread_info *info; - int rc; - - env = req->rq_svc_thread->t_env; - LASSERT(env != NULL); - - info = lu_context_key_get(&env->le_ctx, &seq_thread_key); - LASSERT(info != NULL); - - seq_thread_info_init(req, info); - rc = seq_req_handle(req, env, info); - /* XXX: we don't need replay but MDT assign transno in any case, - * remove it manually before reply*/ - lustre_msg_set_transno(req->rq_repmsg, 0); - seq_thread_info_fini(info); - - return rc; -} -EXPORT_SYMBOL(seq_handle); - -/* - * Entry point for handling FLD RPCs called from MDT. - */ -int seq_query(struct com_thread_info *info) -{ - return seq_handle(info->cti_pill->rc_req); -} -EXPORT_SYMBOL(seq_query); - - -#ifdef LPROCFS -static int seq_server_proc_init(struct lu_server_seq *seq) -{ - int rc; - ENTRY; - - seq->lss_proc_dir = lprocfs_register(seq->lss_name, - seq_type_proc_dir, - NULL, NULL); - if (IS_ERR(seq->lss_proc_dir)) { - rc = PTR_ERR(seq->lss_proc_dir); - RETURN(rc); - } - - rc = lprocfs_add_vars(seq->lss_proc_dir, - seq_server_proc_list, seq); - if (rc) { - CERROR("%s: Can't init sequence manager " - "proc, rc %d\n", seq->lss_name, rc); - GOTO(out_cleanup, rc); - } - - RETURN(0); - -out_cleanup: - seq_server_proc_fini(seq); - return rc; -} - -static void seq_server_proc_fini(struct lu_server_seq *seq) -{ - ENTRY; - if (seq->lss_proc_dir != NULL) { - if (!IS_ERR(seq->lss_proc_dir)) - lprocfs_remove(&seq->lss_proc_dir); - seq->lss_proc_dir = NULL; - } - EXIT; -} -#else -static int seq_server_proc_init(struct lu_server_seq *seq) -{ - return 0; -} - -static void seq_server_proc_fini(struct lu_server_seq *seq) -{ - return; -} -#endif - - -int seq_server_init(struct lu_server_seq *seq, - struct dt_device *dev, - const char *prefix, - enum lu_mgr_type type, - struct seq_server_site *ss, - const struct lu_env *env) -{ - int rc, is_srv = (type == LUSTRE_SEQ_SERVER); - ENTRY; - - LASSERT(dev != NULL); - LASSERT(prefix != NULL); - LASSERT(ss != NULL); - LASSERT(ss->ss_lu != NULL); - - seq->lss_cli = NULL; - seq->lss_type = type; - seq->lss_site = ss; - range_init(&seq->lss_space); - - range_init(&seq->lss_lowater_set); - range_init(&seq->lss_hiwater_set); - seq->lss_set_width = LUSTRE_SEQ_BATCH_WIDTH; - - mutex_init(&seq->lss_mutex); - - seq->lss_width = is_srv ? - LUSTRE_SEQ_META_WIDTH : LUSTRE_SEQ_SUPER_WIDTH; - - snprintf(seq->lss_name, sizeof(seq->lss_name), - "%s-%s", (is_srv ? "srv" : "ctl"), prefix); - - rc = seq_store_init(seq, env, dev); - if (rc) - GOTO(out, rc); - /* Request backing store for saved sequence info. */ - rc = seq_store_read(seq, env); - if (rc == -ENODATA) { - - /* Nothing is read, init by default value. */ - seq->lss_space = is_srv ? - LUSTRE_SEQ_ZERO_RANGE: - LUSTRE_SEQ_SPACE_RANGE; - - LASSERT(ss != NULL); - seq->lss_space.lsr_index = ss->ss_node_id; - LCONSOLE_INFO("%s: No data found " - "on store. Initialize space\n", - seq->lss_name); - - rc = seq_store_update(env, seq, NULL, 0); - if (rc) { - CERROR("%s: Can't write space data, " - "rc %d\n", seq->lss_name, rc); - } - } else if (rc) { - CERROR("%s: Can't read space data, rc %d\n", - seq->lss_name, rc); - GOTO(out, rc); - } - - if (is_srv) { - LASSERT(range_is_sane(&seq->lss_space)); - } else { - LASSERT(!range_is_zero(&seq->lss_space) && - range_is_sane(&seq->lss_space)); - } - - rc = seq_server_proc_init(seq); - if (rc) - GOTO(out, rc); - - EXIT; -out: - if (rc) - seq_server_fini(seq, env); - return rc; -} -EXPORT_SYMBOL(seq_server_init); - -void seq_server_fini(struct lu_server_seq *seq, - const struct lu_env *env) -{ - ENTRY; - - seq_server_proc_fini(seq); - seq_store_fini(seq, env); - - EXIT; -} -EXPORT_SYMBOL(seq_server_fini); - -int seq_site_fini(const struct lu_env *env, struct seq_server_site *ss) -{ - if (ss == NULL) - RETURN(0); - - if (ss->ss_server_seq) { - seq_server_fini(ss->ss_server_seq, env); - OBD_FREE_PTR(ss->ss_server_seq); - ss->ss_server_seq = NULL; - } - - if (ss->ss_control_seq) { - seq_server_fini(ss->ss_control_seq, env); - OBD_FREE_PTR(ss->ss_control_seq); - ss->ss_control_seq = NULL; - } - - if (ss->ss_client_seq) { - seq_client_fini(ss->ss_client_seq); - OBD_FREE_PTR(ss->ss_client_seq); - ss->ss_client_seq = NULL; - } - - RETURN(0); -} -EXPORT_SYMBOL(seq_site_fini); - -proc_dir_entry_t *seq_type_proc_dir = NULL; - -static int __init fid_mod_init(void) -{ - seq_type_proc_dir = lprocfs_register(LUSTRE_SEQ_NAME, - proc_lustre_root, - NULL, NULL); - if (IS_ERR(seq_type_proc_dir)) - return PTR_ERR(seq_type_proc_dir); - - LU_CONTEXT_KEY_INIT(&seq_thread_key); - lu_context_key_register(&seq_thread_key); - return 0; -} - -static void __exit fid_mod_exit(void) -{ - lu_context_key_degister(&seq_thread_key); - if (seq_type_proc_dir != NULL && !IS_ERR(seq_type_proc_dir)) { - lprocfs_remove(&seq_type_proc_dir); - seq_type_proc_dir = NULL; - } -} - -MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); -MODULE_DESCRIPTION("Lustre FID Module"); -MODULE_LICENSE("GPL"); - -cfs_module(fid, "0.1.0", fid_mod_init, fid_mod_exit); diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h b/drivers/staging/lustre/lustre/fid/fid_internal.h index 407a7435583..1dbe46be0f4 100644 --- a/drivers/staging/lustre/lustre/fid/fid_internal.h +++ b/drivers/staging/lustre/lustre/fid/fid_internal.h @@ -41,44 +41,16 @@ #define __FID_INTERNAL_H #include <lustre/lustre_idl.h> -#include <dt_object.h> - #include <linux/libcfs/libcfs.h> -struct seq_thread_info { - struct req_capsule *sti_pill; - struct lu_seq_range sti_space; - struct lu_buf sti_buf; -}; - -enum { - SEQ_TXN_STORE_CREDITS = 20 -}; - -extern struct lu_context_key seq_thread_key; - +/* Functions used internally in module. */ int seq_client_alloc_super(struct lu_client_seq *seq, const struct lu_env *env); -/* Store API functions. */ -int seq_store_init(struct lu_server_seq *seq, - const struct lu_env *env, - struct dt_device *dt); -void seq_store_fini(struct lu_server_seq *seq, - const struct lu_env *env); - -int seq_store_read(struct lu_server_seq *seq, - const struct lu_env *env); - -int seq_store_update(const struct lu_env *env, struct lu_server_seq *seq, - struct lu_seq_range *out, int sync); - -#ifdef LPROCFS -extern struct lprocfs_vars seq_server_proc_list[]; +# ifdef LPROCFS extern struct lprocfs_vars seq_client_proc_list[]; -#endif - +# endif -extern proc_dir_entry_t *seq_type_proc_dir; +extern struct proc_dir_entry *seq_type_proc_dir; #endif /* __FID_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/fid/fid_lib.c b/drivers/staging/lustre/lustre/fid/fid_lib.c index eaff51a555f..f03afdec027 100644 --- a/drivers/staging/lustre/lustre/fid/fid_lib.c +++ b/drivers/staging/lustre/lustre/fid/fid_lib.c @@ -43,11 +43,9 @@ #define DEBUG_SUBSYSTEM S_FID -# include <linux/libcfs/libcfs.h> -# include <linux/module.h> - -#include <obd.h> -#include <lu_object.h> +#include <linux/libcfs/libcfs.h> +#include <linux/module.h> +#include <lustre/lustre_idl.h> #include <lustre_fid.h> /** @@ -56,9 +54,9 @@ * * Fid namespace: * <pre> - * Normal FID: seq:64 [2^33,2^64-1] oid:32 ver:32 - * IGIF : 0:32, ino:32 gen:32 0:32 - * IDIF : 0:31, 1:1, ost-index:16, objd:48 0:32 + * Normal FID: seq:64 [2^33,2^64-1] oid:32 ver:32 + * IGIF : 0:32, ino:32 gen:32 0:32 + * IDIF : 0:31, 1:1, ost-index:16, objd:48 0:32 * </pre> * * The first 0x400 sequences of normal FID are reserved for special purpose. diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index fcaaca7e2e0..66007b57018 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -27,7 +27,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2012, Intel Corporation. + * Copyright (c) 2011, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -42,15 +42,12 @@ #define DEBUG_SUBSYSTEM S_FID -# include <linux/libcfs/libcfs.h> -# include <linux/module.h> +#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> /* mdc RPC locks */ #include <lustre_mdc.h> @@ -63,15 +60,14 @@ static int seq_client_rpc(struct lu_client_seq *seq, struct obd_export *exp = seq->lcs_exp; struct ptlrpc_request *req; struct lu_seq_range *out, *in; - __u32 *op; - unsigned int debug_mask; - int rc; - ENTRY; + __u32 *op; + unsigned int debug_mask; + int rc; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_SEQ_QUERY, LUSTRE_MDS_VERSION, SEQ_QUERY); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* Init operation code */ op = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_OPC); @@ -137,7 +133,6 @@ static int seq_client_rpc(struct lu_client_seq *seq, CDEBUG_LIMIT(debug_mask, "%s: Allocated %s-sequence "DRANGE"]\n", seq->lcs_name, opcname, PRANGE(output)); - EXIT; out_req: ptlrpc_req_finished(req); return rc; @@ -148,27 +143,24 @@ int seq_client_alloc_super(struct lu_client_seq *seq, const struct lu_env *env) { int rc; - ENTRY; mutex_lock(&seq->lcs_mutex); if (seq->lcs_srv) { - LASSERT(env != NULL); - rc = seq_server_alloc_super(seq->lcs_srv, &seq->lcs_space, - env); + rc = 0; } else { /* Check whether the connection to seq controller has been * setup (lcs_exp != NULL) */ if (seq->lcs_exp == NULL) { mutex_unlock(&seq->lcs_mutex); - RETURN(-EINPROGRESS); + return -EINPROGRESS; } rc = seq_client_rpc(seq, &seq->lcs_space, SEQ_ALLOC_SUPER, "super"); } mutex_unlock(&seq->lcs_mutex); - RETURN(rc); + return rc; } /* Request sequence-controller node to allocate new meta-sequence. */ @@ -176,11 +168,9 @@ static int seq_client_alloc_meta(const struct lu_env *env, struct lu_client_seq *seq) { int rc; - ENTRY; if (seq->lcs_srv) { - LASSERT(env != NULL); - rc = seq_server_alloc_meta(seq->lcs_srv, &seq->lcs_space, env); + rc = 0; } else { do { /* If meta server return -EINPROGRESS or EAGAIN, @@ -191,7 +181,8 @@ static int seq_client_alloc_meta(const struct lu_env *env, SEQ_ALLOC_META, "meta"); } while (rc == -EINPROGRESS || rc == -EAGAIN); } - RETURN(rc); + + return rc; } /* Allocate new sequence for client. */ @@ -199,7 +190,6 @@ static int seq_client_alloc_seq(const struct lu_env *env, struct lu_client_seq *seq, seqno_t *seqnr) { int rc; - ENTRY; LASSERT(range_is_sane(&seq->lcs_space)); @@ -208,7 +198,7 @@ static int seq_client_alloc_seq(const struct lu_env *env, if (rc) { CERROR("%s: Can't allocate new meta-sequence," "rc %d\n", seq->lcs_name, rc); - RETURN(rc); + return rc; } else { CDEBUG(D_INFO, "%s: New range - "DRANGE"\n", seq->lcs_name, PRANGE(&seq->lcs_space)); @@ -224,7 +214,7 @@ static int seq_client_alloc_seq(const struct lu_env *env, CDEBUG(D_INFO, "%s: Allocated sequence ["LPX64"]\n", seq->lcs_name, *seqnr); - RETURN(rc); + return rc; } static int seq_fid_alloc_prep(struct lu_client_seq *seq, @@ -312,7 +302,6 @@ int seq_client_alloc_fid(const struct lu_env *env, { wait_queue_t link; int rc; - ENTRY; LASSERT(seq != NULL); LASSERT(fid != NULL); @@ -344,7 +333,7 @@ int seq_client_alloc_fid(const struct lu_env *env, "rc %d\n", seq->lcs_name, rc); seq_fid_alloc_fini(seq); mutex_unlock(&seq->lcs_mutex); - RETURN(rc); + return rc; } CDEBUG(D_INFO, "%s: Switch to sequence " @@ -368,7 +357,7 @@ int seq_client_alloc_fid(const struct lu_env *env, mutex_unlock(&seq->lcs_mutex); CDEBUG(D_INFO, "%s: Allocated FID "DFID"\n", seq->lcs_name, PFID(fid)); - RETURN(rc); + return rc; } EXPORT_SYMBOL(seq_client_alloc_fid); @@ -409,13 +398,21 @@ void seq_client_flush(struct lu_client_seq *seq) } EXPORT_SYMBOL(seq_client_flush); -static void seq_client_proc_fini(struct lu_client_seq *seq); - +static void seq_client_proc_fini(struct lu_client_seq *seq) +{ #ifdef LPROCFS + 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 */ +} + static int seq_client_proc_init(struct lu_client_seq *seq) { +#ifdef LPROCFS int rc; - ENTRY; seq->lcs_proc_dir = lprocfs_register(seq->lcs_name, seq_type_proc_dir, @@ -425,7 +422,7 @@ static int seq_client_proc_init(struct lu_client_seq *seq) CERROR("%s: LProcFS failed in seq-init\n", seq->lcs_name); rc = PTR_ERR(seq->lcs_proc_dir); - RETURN(rc); + return rc; } rc = lprocfs_add_vars(seq->lcs_proc_dir, @@ -436,34 +433,16 @@ static int seq_client_proc_init(struct lu_client_seq *seq) GOTO(out_cleanup, rc); } - RETURN(0); + return 0; out_cleanup: seq_client_proc_fini(seq); return rc; -} -static void seq_client_proc_fini(struct lu_client_seq *seq) -{ - ENTRY; - if (seq->lcs_proc_dir) { - if (!IS_ERR(seq->lcs_proc_dir)) - lprocfs_remove(&seq->lcs_proc_dir); - seq->lcs_proc_dir = NULL; - } - EXIT; -} -#else -static int seq_client_proc_init(struct lu_client_seq *seq) -{ +#else /* LPROCFS */ return 0; -} - -static void seq_client_proc_fini(struct lu_client_seq *seq) -{ - return; -} #endif +} int seq_client_init(struct lu_client_seq *seq, struct obd_export *exp, @@ -472,7 +451,6 @@ int seq_client_init(struct lu_client_seq *seq, struct lu_server_seq *srv) { int rc; - ENTRY; LASSERT(seq != NULL); LASSERT(prefix != NULL); @@ -501,14 +479,12 @@ int seq_client_init(struct lu_client_seq *seq, rc = seq_client_proc_init(seq); if (rc) seq_client_fini(seq); - RETURN(rc); + return rc; } EXPORT_SYMBOL(seq_client_init); void seq_client_fini(struct lu_client_seq *seq) { - ENTRY; - seq_client_proc_fini(seq); if (seq->lcs_exp != NULL) { @@ -517,6 +493,78 @@ void seq_client_fini(struct lu_client_seq *seq) } seq->lcs_srv = NULL; - EXIT; } EXPORT_SYMBOL(seq_client_fini); + +int client_fid_init(struct obd_device *obd, + struct obd_export *exp, enum lu_cli_type type) +{ + struct client_obd *cli = &obd->u.cli; + char *prefix; + int rc; + + OBD_ALLOC_PTR(cli->cl_seq); + if (cli->cl_seq == NULL) + return -ENOMEM; + + OBD_ALLOC(prefix, MAX_OBD_NAME + 5); + if (prefix == NULL) + GOTO(out_free_seq, rc = -ENOMEM); + + snprintf(prefix, MAX_OBD_NAME + 5, "cli-%s", obd->obd_name); + + /* Init client side sequence-manager */ + rc = seq_client_init(cli->cl_seq, exp, type, prefix, NULL); + OBD_FREE(prefix, MAX_OBD_NAME + 5); + if (rc) + GOTO(out_free_seq, rc); + + return rc; +out_free_seq: + OBD_FREE_PTR(cli->cl_seq); + cli->cl_seq = NULL; + return rc; +} +EXPORT_SYMBOL(client_fid_init); + +int client_fid_fini(struct obd_device *obd) +{ + struct client_obd *cli = &obd->u.cli; + + if (cli->cl_seq != NULL) { + seq_client_fini(cli->cl_seq); + OBD_FREE_PTR(cli->cl_seq); + cli->cl_seq = NULL; + } + + return 0; +} +EXPORT_SYMBOL(client_fid_fini); + +struct proc_dir_entry *seq_type_proc_dir; + +static int __init fid_mod_init(void) +{ + seq_type_proc_dir = lprocfs_register(LUSTRE_SEQ_NAME, + proc_lustre_root, + NULL, NULL); + if (IS_ERR(seq_type_proc_dir)) + return PTR_ERR(seq_type_proc_dir); + return 0; +} + +static void __exit fid_mod_exit(void) +{ + if (seq_type_proc_dir != NULL && !IS_ERR(seq_type_proc_dir)) { + lprocfs_remove(&seq_type_proc_dir); + seq_type_proc_dir = NULL; + } +} + +MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); +MODULE_DESCRIPTION("Lustre FID Module"); +MODULE_LICENSE("GPL"); +MODULE_VERSION("0.1.0"); + +module_init(fid_mod_init); +module_exit(fid_mod_exit); diff --git a/drivers/staging/lustre/lustre/fid/fid_store.c b/drivers/staging/lustre/lustre/fid/fid_store.c deleted file mode 100644 index a90e6e37d68..00000000000 --- a/drivers/staging/lustre/lustre/fid/fid_store.c +++ /dev/null @@ -1,259 +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, 2013, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/fid/fid_store.c - * - * Lustre Sequence Manager - * - * Author: Yury Umanets <umka@clusterfs.com> - */ - -#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 "fid_internal.h" - - -static struct lu_buf *seq_store_buf(struct seq_thread_info *info) -{ - struct lu_buf *buf; - - buf = &info->sti_buf; - buf->lb_buf = &info->sti_space; - buf->lb_len = sizeof(info->sti_space); - return buf; -} - -struct seq_update_callback { - struct dt_txn_commit_cb suc_cb; - struct lu_server_seq *suc_seq; -}; - -void seq_update_cb(struct lu_env *env, struct thandle *th, - struct dt_txn_commit_cb *cb, int err) -{ - struct seq_update_callback *ccb; - - ccb = container_of0(cb, struct seq_update_callback, suc_cb); - - LASSERT(ccb->suc_seq != NULL); - - ccb->suc_seq->lss_need_sync = 0; - OBD_FREE_PTR(ccb); -} - -int seq_update_cb_add(struct thandle *th, struct lu_server_seq *seq) -{ - struct seq_update_callback *ccb; - struct dt_txn_commit_cb *dcb; - int rc; - - OBD_ALLOC_PTR(ccb); - if (ccb == NULL) - return -ENOMEM; - - ccb->suc_seq = seq; - seq->lss_need_sync = 1; - - dcb = &ccb->suc_cb; - dcb->dcb_func = seq_update_cb; - INIT_LIST_HEAD(&dcb->dcb_linkage); - strncpy(dcb->dcb_name, "seq_update_cb", MAX_COMMIT_CB_STR_LEN); - dcb->dcb_name[MAX_COMMIT_CB_STR_LEN - 1] = '\0'; - - rc = dt_trans_cb_add(th, dcb); - if (rc) - OBD_FREE_PTR(ccb); - return rc; -} - -/* This function implies that caller takes care about locking. */ -int seq_store_update(const struct lu_env *env, struct lu_server_seq *seq, - struct lu_seq_range *out, int sync) -{ - struct dt_device *dt_dev = lu2dt_dev(seq->lss_obj->do_lu.lo_dev); - struct seq_thread_info *info; - struct thandle *th; - loff_t pos = 0; - int rc; - - info = lu_context_key_get(&env->le_ctx, &seq_thread_key); - LASSERT(info != NULL); - - th = dt_trans_create(env, dt_dev); - if (IS_ERR(th)) - RETURN(PTR_ERR(th)); - - rc = dt_declare_record_write(env, seq->lss_obj, - sizeof(struct lu_seq_range), 0, th); - if (rc) - GOTO(exit, rc); - - if (out != NULL) { - rc = fld_declare_server_create(env, - seq->lss_site->ss_server_fld, - out, th); - if (rc) - GOTO(exit, rc); - } - - rc = dt_trans_start_local(env, dt_dev, th); - if (rc) - GOTO(exit, rc); - - /* Store ranges in le format. */ - range_cpu_to_le(&info->sti_space, &seq->lss_space); - - rc = dt_record_write(env, seq->lss_obj, seq_store_buf(info), &pos, th); - if (rc) { - CERROR("%s: Can't write space data, rc %d\n", - seq->lss_name, rc); - GOTO(exit, rc); - } else if (out != NULL) { - rc = fld_server_create(env, seq->lss_site->ss_server_fld, out, - th); - if (rc) { - CERROR("%s: Can't Update fld database, rc %d\n", - seq->lss_name, rc); - GOTO(exit, rc); - } - } - /* next sequence update will need sync until this update is committed - * in case of sync operation this is not needed obviously */ - if (!sync) - /* if callback can't be added then sync always */ - sync = !!seq_update_cb_add(th, seq); - - th->th_sync |= sync; -exit: - dt_trans_stop(env, dt_dev, th); - return rc; -} - -/* - * This function implies that caller takes care about locking or locking is not - * needed (init time). - */ -int seq_store_read(struct lu_server_seq *seq, - const struct lu_env *env) -{ - struct seq_thread_info *info; - loff_t pos = 0; - int rc; - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &seq_thread_key); - LASSERT(info != NULL); - - rc = seq->lss_obj->do_body_ops->dbo_read(env, seq->lss_obj, - seq_store_buf(info), - &pos, BYPASS_CAPA); - - if (rc == sizeof(info->sti_space)) { - range_le_to_cpu(&seq->lss_space, &info->sti_space); - CDEBUG(D_INFO, "%s: Space - "DRANGE"\n", - seq->lss_name, PRANGE(&seq->lss_space)); - rc = 0; - } else if (rc == 0) { - rc = -ENODATA; - } else if (rc > 0) { - CERROR("%s: Read only %d bytes of %d\n", seq->lss_name, - rc, (int)sizeof(info->sti_space)); - rc = -EIO; - } - - RETURN(rc); -} - -int seq_store_init(struct lu_server_seq *seq, - const struct lu_env *env, - struct dt_device *dt) -{ - struct dt_object *dt_obj; - struct lu_fid fid; - struct lu_attr attr; - struct dt_object_format dof; - const char *name; - int rc; - ENTRY; - - name = seq->lss_type == LUSTRE_SEQ_SERVER ? - LUSTRE_SEQ_SRV_NAME : LUSTRE_SEQ_CTL_NAME; - - if (seq->lss_type == LUSTRE_SEQ_SERVER) - lu_local_obj_fid(&fid, FID_SEQ_SRV_OID); - else - lu_local_obj_fid(&fid, FID_SEQ_CTL_OID); - - memset(&attr, 0, sizeof(attr)); - attr.la_valid = LA_MODE; - attr.la_mode = S_IFREG | 0666; - dof.dof_type = DFT_REGULAR; - - dt_obj = dt_find_or_create(env, dt, &fid, &dof, &attr); - if (!IS_ERR(dt_obj)) { - seq->lss_obj = dt_obj; - rc = 0; - } else { - CERROR("%s: Can't find \"%s\" obj %d\n", - seq->lss_name, name, (int)PTR_ERR(dt_obj)); - rc = PTR_ERR(dt_obj); - } - - RETURN(rc); -} - -void seq_store_fini(struct lu_server_seq *seq, - const struct lu_env *env) -{ - ENTRY; - - if (seq->lss_obj != NULL) { - if (!IS_ERR(seq->lss_obj)) - lu_object_put(env, &seq->lss_obj->do_lu); - seq->lss_obj = NULL; - } - - EXIT; -} diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index af817a867f8..294070da9d4 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -65,7 +65,6 @@ lprocfs_fid_write_common(const char *buffer, unsigned long count, { struct lu_seq_range tmp; int rc; - ENTRY; LASSERT(range != NULL); @@ -73,9 +72,9 @@ lprocfs_fid_write_common(const char *buffer, unsigned long count, (long long unsigned *)&tmp.lsr_start, (long long unsigned *)&tmp.lsr_end); if (rc != 2 || !range_is_sane(&tmp) || range_is_zero(&tmp)) - RETURN(-EINVAL); + return -EINVAL; *range = tmp; - RETURN(0); + return 0; } /* Client side procfs stuff */ @@ -85,7 +84,6 @@ lprocfs_fid_space_seq_write(struct file *file, const char *buffer, { struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private; int rc; - ENTRY; LASSERT(seq != NULL); @@ -99,7 +97,7 @@ lprocfs_fid_space_seq_write(struct file *file, const char *buffer, mutex_unlock(&seq->lcs_mutex); - RETURN(count); + return count; } static int @@ -107,7 +105,6 @@ lprocfs_fid_space_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; int rc; - ENTRY; LASSERT(seq != NULL); @@ -115,7 +112,7 @@ lprocfs_fid_space_seq_show(struct seq_file *m, void *unused) rc = seq_printf(m, "["LPX64" - "LPX64"]:%x:%s\n", PRANGE(&seq->lcs_space)); mutex_unlock(&seq->lcs_mutex); - RETURN(rc); + return rc; } static ssize_t @@ -125,13 +122,12 @@ lprocfs_fid_width_seq_write(struct file *file, const char *buffer, struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private; __u64 max; int rc, val; - ENTRY; LASSERT(seq != NULL); rc = lprocfs_write_helper(buffer, count, &val); if (rc) - RETURN(rc); + return rc; mutex_lock(&seq->lcs_mutex); if (seq->lcs_type == LUSTRE_SEQ_DATA) @@ -150,7 +146,7 @@ lprocfs_fid_width_seq_write(struct file *file, const char *buffer, mutex_unlock(&seq->lcs_mutex); - RETURN(count); + return count; } static int @@ -158,7 +154,6 @@ lprocfs_fid_width_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; int rc; - ENTRY; LASSERT(seq != NULL); @@ -166,7 +161,7 @@ lprocfs_fid_width_seq_show(struct seq_file *m, void *unused) rc = seq_printf(m, LPU64"\n", seq->lcs_width); mutex_unlock(&seq->lcs_mutex); - RETURN(rc); + return rc; } static int @@ -174,7 +169,6 @@ lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; int rc; - ENTRY; LASSERT(seq != NULL); @@ -182,7 +176,7 @@ lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused) rc = seq_printf(m, DFID"\n", PFID(&seq->lcs_fid)); mutex_unlock(&seq->lcs_mutex); - RETURN(rc); + return rc; } static int @@ -191,7 +185,6 @@ lprocfs_fid_server_seq_show(struct seq_file *m, void *unused) struct lu_client_seq *seq = (struct lu_client_seq *)m->private; struct client_obd *cli; int rc; - ENTRY; LASSERT(seq != NULL); @@ -201,12 +194,9 @@ lprocfs_fid_server_seq_show(struct seq_file *m, void *unused) } else { rc = seq_printf(m, "%s\n", seq->lcs_srv->lss_name); } - RETURN(rc); + return rc; } -struct lprocfs_vars seq_server_proc_list[] = { -}; - LPROC_SEQ_FOPS(lprocfs_fid_space); LPROC_SEQ_FOPS(lprocfs_fid_width); LPROC_SEQ_FOPS_RO(lprocfs_fid_server); diff --git a/drivers/staging/lustre/lustre/fld/Makefile b/drivers/staging/lustre/lustre/fld/Makefile index e7f2881a1d9..90d46d84fbb 100644 --- a/drivers/staging/lustre/lustre/fld/Makefile +++ b/drivers/staging/lustre/lustre/fld/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_LUSTRE_FS) += fld.o -fld-y := fld_handler.o fld_request.o fld_cache.o fld_index.o lproc_fld.o +fld-y := fld_request.o fld_cache.o 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 347f2ae83bc..25099cbe37e 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -45,7 +45,6 @@ # include <linux/libcfs/libcfs.h> # include <linux/module.h> -# include <linux/jbd.h> # include <asm/div64.h> #include <obd.h> @@ -67,14 +66,13 @@ struct fld_cache *fld_cache_init(const char *name, int cache_size, int cache_threshold) { struct fld_cache *cache; - ENTRY; LASSERT(name != NULL); LASSERT(cache_threshold < cache_size); OBD_ALLOC_PTR(cache); if (cache == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); INIT_LIST_HEAD(&cache->fci_entries_head); INIT_LIST_HEAD(&cache->fci_lru); @@ -94,7 +92,7 @@ struct fld_cache *fld_cache_init(const char *name, CDEBUG(D_INFO, "%s: FLD cache - Size: %d, Threshold: %d\n", cache->fci_name, cache_size, cache_threshold); - RETURN(cache); + return cache; } /** @@ -103,7 +101,6 @@ struct fld_cache *fld_cache_init(const char *name, void fld_cache_fini(struct fld_cache *cache) { __u64 pct; - ENTRY; LASSERT(cache != NULL); fld_cache_flush(cache); @@ -121,8 +118,6 @@ void fld_cache_fini(struct fld_cache *cache) CDEBUG(D_INFO, " Cache hits: "LPU64"%%\n", pct); OBD_FREE_PTR(cache); - - EXIT; } /** @@ -147,7 +142,6 @@ static void fld_fix_new_list(struct fld_cache *cache) struct lu_seq_range *c_range; struct lu_seq_range *n_range; struct list_head *head = &cache->fci_entries_head; - ENTRY; restart_fixup: @@ -200,8 +194,6 @@ restart_fixup: c_range->lsr_end == n_range->lsr_end) fld_cache_entry_delete(cache, f_curr); } - - EXIT; } /** @@ -227,12 +219,11 @@ static int fld_cache_shrink(struct fld_cache *cache) struct fld_cache_entry *flde; struct list_head *curr; int num = 0; - ENTRY; LASSERT(cache != NULL); if (cache->fci_cache_count < cache->fci_cache_size) - RETURN(0); + return 0; curr = cache->fci_lru.prev; @@ -248,7 +239,7 @@ static int fld_cache_shrink(struct fld_cache *cache) CDEBUG(D_INFO, "%s: FLD cache - Shrunk by " "%d entries\n", cache->fci_name, num); - RETURN(0); + return 0; } /** @@ -256,14 +247,10 @@ static int fld_cache_shrink(struct fld_cache *cache) */ void fld_cache_flush(struct fld_cache *cache) { - ENTRY; - write_lock(&cache->fci_lock); cache->fci_cache_size = 0; fld_cache_shrink(cache); write_unlock(&cache->fci_lock); - - EXIT; } /** @@ -280,11 +267,9 @@ void fld_cache_punch_hole(struct fld_cache *cache, const seqno_t new_end = range->lsr_end; struct fld_cache_entry *fldt; - ENTRY; OBD_ALLOC_GFP(fldt, sizeof *fldt, GFP_ATOMIC); if (!fldt) { OBD_FREE_PTR(f_new); - EXIT; /* overlap is not allowed, so dont mess up list. */ return; } @@ -307,7 +292,6 @@ void fld_cache_punch_hole(struct fld_cache *cache, fld_cache_entry_add(cache, fldt, &f_new->fce_list); /* no need to fixup */ - EXIT; } /** @@ -383,10 +367,10 @@ struct fld_cache_entry OBD_ALLOC_PTR(f_new); if (!f_new) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); f_new->fce_range = *range; - RETURN(f_new); + return f_new; } /** @@ -405,7 +389,6 @@ int fld_cache_insert_nolock(struct fld_cache *cache, const seqno_t new_start = f_new->fce_range.lsr_start; const seqno_t new_end = f_new->fce_range.lsr_end; __u32 new_flags = f_new->fce_range.lsr_flags; - ENTRY; /* * Duplicate entries are eliminated in insert op. @@ -441,7 +424,7 @@ int fld_cache_insert_nolock(struct fld_cache *cache, /* Add new entry to cache and lru list. */ fld_cache_entry_add(cache, f_new, prev); out: - RETURN(0); + return 0; } int fld_cache_insert(struct fld_cache *cache, @@ -452,7 +435,7 @@ int fld_cache_insert(struct fld_cache *cache, flde = fld_cache_entry_create(range); if (IS_ERR(flde)) - RETURN(PTR_ERR(flde)); + return PTR_ERR(flde); write_lock(&cache->fci_lock); rc = fld_cache_insert_nolock(cache, flde); @@ -460,7 +443,7 @@ int fld_cache_insert(struct fld_cache *cache, if (rc) OBD_FREE_PTR(flde); - RETURN(rc); + return rc; } void fld_cache_delete_nolock(struct fld_cache *cache, @@ -512,7 +495,7 @@ struct fld_cache_entry } } - RETURN(got); + return got; } /** @@ -522,12 +505,11 @@ struct fld_cache_entry *fld_cache_entry_lookup(struct fld_cache *cache, struct lu_seq_range *range) { struct fld_cache_entry *got = NULL; - ENTRY; read_lock(&cache->fci_lock); got = fld_cache_entry_lookup_nolock(cache, range); read_unlock(&cache->fci_lock); - RETURN(got); + return got; } /** @@ -539,7 +521,6 @@ int fld_cache_lookup(struct fld_cache *cache, struct fld_cache_entry *flde; struct fld_cache_entry *prev = NULL; struct list_head *head; - ENTRY; read_lock(&cache->fci_lock); head = &cache->fci_entries_head; @@ -558,9 +539,9 @@ int fld_cache_lookup(struct fld_cache *cache, cache->fci_stat.fst_cache++; read_unlock(&cache->fci_lock); - RETURN(0); + return 0; } } read_unlock(&cache->fci_lock); - RETURN(-ENOENT); + return -ENOENT; } diff --git a/drivers/staging/lustre/lustre/fld/fld_handler.c b/drivers/staging/lustre/lustre/fld/fld_handler.c deleted file mode 100644 index d2707ae4ad5..00000000000 --- a/drivers/staging/lustre/lustre/fld/fld_handler.c +++ /dev/null @@ -1,447 +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, 2013, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/fld/fld_handler.c - * - * FLD (Fids Location Database) - * - * Author: Yury Umanets <umka@clusterfs.com> - * Author: WangDi <wangdi@clusterfs.com> - * Author: Pravin Shelar <pravin.shelar@sun.com> - */ - -#define DEBUG_SUBSYSTEM S_FLD - -# include <linux/libcfs/libcfs.h> -# include <linux/module.h> -# include <linux/jbd.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 <md_object.h> -#include <lustre_fid.h> -#include <lustre_req_layout.h> -#include "fld_internal.h" -#include <lustre_fid.h> - - -/* context key constructor/destructor: fld_key_init, fld_key_fini */ -LU_KEY_INIT_FINI(fld, struct fld_thread_info); - -/* context key: fld_thread_key */ -LU_CONTEXT_KEY_DEFINE(fld, LCT_MD_THREAD | LCT_DT_THREAD | LCT_MG_THREAD); - -proc_dir_entry_t *fld_type_proc_dir = NULL; - -static int __init fld_mod_init(void) -{ - fld_type_proc_dir = lprocfs_register(LUSTRE_FLD_NAME, - proc_lustre_root, - NULL, NULL); - if (IS_ERR(fld_type_proc_dir)) - return PTR_ERR(fld_type_proc_dir); - - LU_CONTEXT_KEY_INIT(&fld_thread_key); - lu_context_key_register(&fld_thread_key); - return 0; -} - -static void __exit fld_mod_exit(void) -{ - lu_context_key_degister(&fld_thread_key); - if (fld_type_proc_dir != NULL && !IS_ERR(fld_type_proc_dir)) { - lprocfs_remove(&fld_type_proc_dir); - fld_type_proc_dir = NULL; - } -} - -int fld_declare_server_create(const struct lu_env *env, - struct lu_server_fld *fld, - struct lu_seq_range *range, - struct thandle *th) -{ - int rc; - - rc = fld_declare_index_create(env, fld, range, th); - RETURN(rc); -} -EXPORT_SYMBOL(fld_declare_server_create); - -/** - * Insert FLD index entry and update FLD cache. - * - * This function is called from the sequence allocator when a super-sequence - * is granted to a server. - */ -int fld_server_create(const struct lu_env *env, struct lu_server_fld *fld, - struct lu_seq_range *range, struct thandle *th) -{ - int rc; - - mutex_lock(&fld->lsf_lock); - rc = fld_index_create(env, fld, range, th); - mutex_unlock(&fld->lsf_lock); - - RETURN(rc); -} -EXPORT_SYMBOL(fld_server_create); - -/** - * Lookup mds by seq, returns a range for given seq. - * - * If that entry is not cached in fld cache, request is sent to super - * sequence controller node (MDT0). All other MDT[1...N] and client - * cache fld entries, but this cache is not persistent. - */ -int fld_server_lookup(const struct lu_env *env, struct lu_server_fld *fld, - seqno_t seq, struct lu_seq_range *range) -{ - struct lu_seq_range *erange; - struct fld_thread_info *info; - int rc; - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - LASSERT(info != NULL); - erange = &info->fti_lrange; - - /* Lookup it in the cache. */ - rc = fld_cache_lookup(fld->lsf_cache, seq, erange); - if (rc == 0) { - if (unlikely(fld_range_type(erange) != fld_range_type(range) && - !fld_range_is_any(range))) { - CERROR("%s: FLD cache range "DRANGE" does not match" - "requested flag %x: rc = %d\n", fld->lsf_name, - PRANGE(erange), range->lsr_flags, -EIO); - RETURN(-EIO); - } - *range = *erange; - RETURN(0); - } - - if (fld->lsf_obj) { - /* On server side, all entries should be in cache. - * If we can not find it in cache, just return error */ - CERROR("%s: Cannot find sequence "LPX64": rc = %d\n", - fld->lsf_name, seq, -EIO); - RETURN(-EIO); - } else { - LASSERT(fld->lsf_control_exp); - /* send request to mdt0 i.e. super seq. controller. - * This is temporary solution, long term solution is fld - * replication on all mdt servers. - */ - range->lsr_start = seq; - rc = fld_client_rpc(fld->lsf_control_exp, - range, FLD_LOOKUP); - if (rc == 0) - fld_cache_insert(fld->lsf_cache, range); - } - RETURN(rc); -} -EXPORT_SYMBOL(fld_server_lookup); - -/** - * All MDT server handle fld lookup operation. But only MDT0 has fld index. - * if entry is not found in cache we need to forward lookup request to MDT0 - */ - -static int fld_server_handle(struct lu_server_fld *fld, - const struct lu_env *env, - __u32 opc, struct lu_seq_range *range, - struct fld_thread_info *info) -{ - int rc; - ENTRY; - - switch (opc) { - case FLD_LOOKUP: - rc = fld_server_lookup(env, fld, range->lsr_start, range); - break; - default: - rc = -EINVAL; - break; - } - - CDEBUG(D_INFO, "%s: FLD req handle: error %d (opc: %d, range: " - DRANGE"\n", fld->lsf_name, rc, opc, PRANGE(range)); - - RETURN(rc); - -} - -static int fld_req_handle(struct ptlrpc_request *req, - struct fld_thread_info *info) -{ - struct obd_export *exp = req->rq_export; - struct lu_site *site = exp->exp_obd->obd_lu_dev->ld_site; - struct lu_seq_range *in; - struct lu_seq_range *out; - int rc; - __u32 *opc; - ENTRY; - - rc = req_capsule_server_pack(info->fti_pill); - if (rc) - RETURN(err_serious(rc)); - - opc = req_capsule_client_get(info->fti_pill, &RMF_FLD_OPC); - if (opc != NULL) { - in = req_capsule_client_get(info->fti_pill, &RMF_FLD_MDFLD); - if (in == NULL) - RETURN(err_serious(-EPROTO)); - out = req_capsule_server_get(info->fti_pill, &RMF_FLD_MDFLD); - if (out == NULL) - RETURN(err_serious(-EPROTO)); - *out = *in; - - /* For old 2.0 client, the 'lsr_flags' is uninitialized. - * Set it as 'LU_SEQ_RANGE_MDT' by default. */ - if (!(exp_connect_flags(exp) & OBD_CONNECT_64BITHASH) && - !(exp_connect_flags(exp) & OBD_CONNECT_MDS_MDS) && - !(exp_connect_flags(exp) & OBD_CONNECT_LIGHTWEIGHT) && - !exp->exp_libclient) - fld_range_set_mdt(out); - - rc = fld_server_handle(lu_site2seq(site)->ss_server_fld, - req->rq_svc_thread->t_env, - *opc, out, info); - } else { - rc = err_serious(-EPROTO); - } - - RETURN(rc); -} - -static void fld_thread_info_init(struct ptlrpc_request *req, - struct fld_thread_info *info) -{ - info->fti_pill = &req->rq_pill; - /* Init request capsule. */ - req_capsule_init(info->fti_pill, req, RCL_SERVER); - req_capsule_set(info->fti_pill, &RQF_FLD_QUERY); -} - -static void fld_thread_info_fini(struct fld_thread_info *info) -{ - req_capsule_fini(info->fti_pill); -} - -static int fld_handle(struct ptlrpc_request *req) -{ - struct fld_thread_info *info; - const struct lu_env *env; - int rc; - - env = req->rq_svc_thread->t_env; - LASSERT(env != NULL); - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - LASSERT(info != NULL); - - fld_thread_info_init(req, info); - rc = fld_req_handle(req, info); - fld_thread_info_fini(info); - - return rc; -} - -/* - * Entry point for handling FLD RPCs called from MDT. - */ -int fld_query(struct com_thread_info *info) -{ - return fld_handle(info->cti_pill->rc_req); -} -EXPORT_SYMBOL(fld_query); - -/* - * Returns true, if fid is local to this server node. - * - * WARNING: this function is *not* guaranteed to return false if fid is - * remote: it makes an educated conservative guess only. - * - * fid_is_local() is supposed to be used in assertion checks only. - */ -int fid_is_local(const struct lu_env *env, - struct lu_site *site, const struct lu_fid *fid) -{ - int result; - struct seq_server_site *ss_site; - struct lu_seq_range *range; - struct fld_thread_info *info; - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - range = &info->fti_lrange; - - result = 1; /* conservatively assume fid is local */ - ss_site = lu_site2seq(site); - if (ss_site->ss_client_fld != NULL) { - int rc; - - rc = fld_cache_lookup(ss_site->ss_client_fld->lcf_cache, - fid_seq(fid), range); - if (rc == 0) - result = (range->lsr_index == ss_site->ss_node_id); - } - return result; -} -EXPORT_SYMBOL(fid_is_local); - -static void fld_server_proc_fini(struct lu_server_fld *fld); - -#ifdef LPROCFS -static int fld_server_proc_init(struct lu_server_fld *fld) -{ - int rc = 0; - ENTRY; - - fld->lsf_proc_dir = lprocfs_register(fld->lsf_name, - fld_type_proc_dir, - fld_server_proc_list, fld); - if (IS_ERR(fld->lsf_proc_dir)) { - rc = PTR_ERR(fld->lsf_proc_dir); - RETURN(rc); - } - - rc = lprocfs_seq_create(fld->lsf_proc_dir, "fldb", 0444, - &fld_proc_seq_fops, fld); - if (rc) { - lprocfs_remove(&fld->lsf_proc_dir); - fld->lsf_proc_dir = NULL; - } - - RETURN(rc); -} - -static void fld_server_proc_fini(struct lu_server_fld *fld) -{ - ENTRY; - if (fld->lsf_proc_dir != NULL) { - if (!IS_ERR(fld->lsf_proc_dir)) - lprocfs_remove(&fld->lsf_proc_dir); - fld->lsf_proc_dir = NULL; - } - EXIT; -} -#else -static int fld_server_proc_init(struct lu_server_fld *fld) -{ - return 0; -} - -static void fld_server_proc_fini(struct lu_server_fld *fld) -{ - return; -} -#endif - -int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld, - struct dt_device *dt, const char *prefix, int mds_node_id, - int type) -{ - int cache_size, cache_threshold; - int rc; - ENTRY; - - snprintf(fld->lsf_name, sizeof(fld->lsf_name), - "srv-%s", prefix); - - cache_size = FLD_SERVER_CACHE_SIZE / - sizeof(struct fld_cache_entry); - - cache_threshold = cache_size * - FLD_SERVER_CACHE_THRESHOLD / 100; - - mutex_init(&fld->lsf_lock); - fld->lsf_cache = fld_cache_init(fld->lsf_name, - cache_size, cache_threshold); - if (IS_ERR(fld->lsf_cache)) { - rc = PTR_ERR(fld->lsf_cache); - fld->lsf_cache = NULL; - GOTO(out, rc); - } - - if (!mds_node_id && type == LU_SEQ_RANGE_MDT) { - rc = fld_index_init(env, fld, dt); - if (rc) - GOTO(out, rc); - } else { - fld->lsf_obj = NULL; - } - - rc = fld_server_proc_init(fld); - if (rc) - GOTO(out, rc); - - fld->lsf_control_exp = NULL; - - GOTO(out, rc); - -out: - if (rc) - fld_server_fini(env, fld); - return rc; -} -EXPORT_SYMBOL(fld_server_init); - -void fld_server_fini(const struct lu_env *env, struct lu_server_fld *fld) -{ - ENTRY; - - fld_server_proc_fini(fld); - fld_index_fini(env, fld); - - if (fld->lsf_cache != NULL) { - if (!IS_ERR(fld->lsf_cache)) - fld_cache_fini(fld->lsf_cache); - fld->lsf_cache = NULL; - } - - EXIT; -} -EXPORT_SYMBOL(fld_server_fini); - -MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); -MODULE_DESCRIPTION("Lustre FLD"); -MODULE_LICENSE("GPL"); - -cfs_module(mdd, "0.1.0", fld_mod_init, fld_mod_exit); diff --git a/drivers/staging/lustre/lustre/fld/fld_index.c b/drivers/staging/lustre/lustre/fld/fld_index.c deleted file mode 100644 index ec68a54c23b..00000000000 --- a/drivers/staging/lustre/lustre/fld/fld_index.c +++ /dev/null @@ -1,426 +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, 2013, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/fld/fld_index.c - * - * Author: WangDi <wangdi@clusterfs.com> - * Author: Yury Umanets <umka@clusterfs.com> - */ - -#define DEBUG_SUBSYSTEM S_FLD - -# include <linux/libcfs/libcfs.h> -# include <linux/module.h> -# include <linux/jbd.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_mdc.h> -#include <lustre_fid.h> -#include <lustre_fld.h> -#include "fld_internal.h" - -const char fld_index_name[] = "fld"; - -static const struct lu_seq_range IGIF_FLD_RANGE = { - .lsr_start = FID_SEQ_IGIF, - .lsr_end = FID_SEQ_IGIF_MAX + 1, - .lsr_index = 0, - .lsr_flags = LU_SEQ_RANGE_MDT -}; - -static const struct lu_seq_range DOT_LUSTRE_FLD_RANGE = { - .lsr_start = FID_SEQ_DOT_LUSTRE, - .lsr_end = FID_SEQ_DOT_LUSTRE + 1, - .lsr_index = 0, - .lsr_flags = LU_SEQ_RANGE_MDT -}; - -static const struct lu_seq_range ROOT_FLD_RANGE = { - .lsr_start = FID_SEQ_ROOT, - .lsr_end = FID_SEQ_ROOT + 1, - .lsr_index = 0, - .lsr_flags = LU_SEQ_RANGE_MDT -}; - -const struct dt_index_features fld_index_features = { - .dif_flags = DT_IND_UPDATE, - .dif_keysize_min = sizeof(seqno_t), - .dif_keysize_max = sizeof(seqno_t), - .dif_recsize_min = sizeof(struct lu_seq_range), - .dif_recsize_max = sizeof(struct lu_seq_range), - .dif_ptrsize = 4 -}; - -extern struct lu_context_key fld_thread_key; - -int fld_declare_index_create(const struct lu_env *env, - struct lu_server_fld *fld, - const struct lu_seq_range *new_range, - struct thandle *th) -{ - struct lu_seq_range *tmp; - struct lu_seq_range *range; - struct fld_thread_info *info; - int rc = 0; - - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - range = &info->fti_lrange; - tmp = &info->fti_irange; - memset(range, 0, sizeof(*range)); - - rc = fld_index_lookup(env, fld, new_range->lsr_start, range); - if (rc == 0) { - /* In case of duplicate entry, the location must be same */ - LASSERT((range_compare_loc(new_range, range) == 0)); - GOTO(out, rc = -EEXIST); - } - - if (rc != -ENOENT) { - CERROR("%s: lookup range "DRANGE" error: rc = %d\n", - fld->lsf_name, PRANGE(range), rc); - GOTO(out, rc); - } - - /* Check for merge case, since the fld entry can only be increamental, - * so we will only check whether it can be merged from the left. */ - if (new_range->lsr_start == range->lsr_end && range->lsr_end != 0 && - range_compare_loc(new_range, range) == 0) { - range_cpu_to_be(tmp, range); - rc = dt_declare_delete(env, fld->lsf_obj, - (struct dt_key *)&tmp->lsr_start, th); - if (rc) { - CERROR("%s: declare record "DRANGE" failed: rc = %d\n", - fld->lsf_name, PRANGE(range), rc); - GOTO(out, rc); - } - memcpy(tmp, new_range, sizeof(*new_range)); - tmp->lsr_start = range->lsr_start; - } else { - memcpy(tmp, new_range, sizeof(*new_range)); - } - - range_cpu_to_be(tmp, tmp); - rc = dt_declare_insert(env, fld->lsf_obj, (struct dt_rec *)tmp, - (struct dt_key *)&tmp->lsr_start, th); -out: - RETURN(rc); -} - -/** - * insert range in fld store. - * - * \param range range to be inserted - * \param th transaction for this operation as it could compound - * transaction. - * - * \retval 0 success - * \retval -ve error - * - * The whole fld index insertion is protected by seq->lss_mutex (see - * seq_server_alloc_super), i.e. only one thread will access fldb each - * time, so we do not need worry the fld file and cache will being - * changed between declare and create. - * Because the fld entry can only be increamental, so we will only check - * whether it can be merged from the left. - **/ -int fld_index_create(const struct lu_env *env, struct lu_server_fld *fld, - const struct lu_seq_range *new_range, struct thandle *th) -{ - struct lu_seq_range *range; - struct lu_seq_range *tmp; - struct fld_thread_info *info; - int rc = 0; - int deleted = 0; - struct fld_cache_entry *flde; - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - - LASSERT(mutex_is_locked(&fld->lsf_lock)); - - range = &info->fti_lrange; - memset(range, 0, sizeof(*range)); - tmp = &info->fti_irange; - rc = fld_index_lookup(env, fld, new_range->lsr_start, range); - if (rc != -ENOENT) { - rc = rc == 0 ? -EEXIST : rc; - GOTO(out, rc); - } - - if (new_range->lsr_start == range->lsr_end && range->lsr_end != 0 && - range_compare_loc(new_range, range) == 0) { - range_cpu_to_be(tmp, range); - rc = dt_delete(env, fld->lsf_obj, - (struct dt_key *)&tmp->lsr_start, th, - BYPASS_CAPA); - if (rc != 0) - GOTO(out, rc); - memcpy(tmp, new_range, sizeof(*new_range)); - tmp->lsr_start = range->lsr_start; - deleted = 1; - } else { - memcpy(tmp, new_range, sizeof(*new_range)); - } - - range_cpu_to_be(tmp, tmp); - rc = dt_insert(env, fld->lsf_obj, (struct dt_rec *)tmp, - (struct dt_key *)&tmp->lsr_start, th, BYPASS_CAPA, 1); - if (rc != 0) { - CERROR("%s: insert range "DRANGE" failed: rc = %d\n", - fld->lsf_name, PRANGE(new_range), rc); - GOTO(out, rc); - } - - flde = fld_cache_entry_create(new_range); - if (IS_ERR(flde)) - GOTO(out, rc = PTR_ERR(flde)); - - write_lock(&fld->lsf_cache->fci_lock); - if (deleted) - fld_cache_delete_nolock(fld->lsf_cache, new_range); - rc = fld_cache_insert_nolock(fld->lsf_cache, flde); - write_unlock(&fld->lsf_cache->fci_lock); - if (rc) - OBD_FREE_PTR(flde); -out: - RETURN(rc); -} - -/** - * lookup range for a seq passed. note here we only care about the start/end, - * caller should handle the attached location data (flags, index). - * - * \param seq seq for lookup. - * \param range result of lookup. - * - * \retval 0 found, \a range is the matched range; - * \retval -ENOENT not found, \a range is the left-side range; - * \retval -ve other error; - */ -int fld_index_lookup(const struct lu_env *env, struct lu_server_fld *fld, - seqno_t seq, struct lu_seq_range *range) -{ - struct lu_seq_range *fld_rec; - struct fld_thread_info *info; - int rc; - - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - fld_rec = &info->fti_rec; - - rc = fld_cache_lookup(fld->lsf_cache, seq, fld_rec); - if (rc == 0) { - *range = *fld_rec; - if (range_within(range, seq)) - rc = 0; - else - rc = -ENOENT; - } - - CDEBUG(D_INFO, "%s: lookup seq = "LPX64" range : "DRANGE" rc = %d\n", - fld->lsf_name, seq, PRANGE(range), rc); - - RETURN(rc); -} - -int fld_insert_entry(const struct lu_env *env, - struct lu_server_fld *fld, - const struct lu_seq_range *range) -{ - struct thandle *th; - int rc; - ENTRY; - - th = dt_trans_create(env, lu2dt_dev(fld->lsf_obj->do_lu.lo_dev)); - if (IS_ERR(th)) - RETURN(PTR_ERR(th)); - - rc = fld_declare_index_create(env, fld, range, th); - if (rc != 0) { - if (rc == -EEXIST) - rc = 0; - GOTO(out, rc); - } - - rc = dt_trans_start_local(env, lu2dt_dev(fld->lsf_obj->do_lu.lo_dev), - th); - if (rc) - GOTO(out, rc); - - rc = fld_index_create(env, fld, range, th); - if (rc == -EEXIST) - rc = 0; -out: - dt_trans_stop(env, lu2dt_dev(fld->lsf_obj->do_lu.lo_dev), th); - RETURN(rc); -} -EXPORT_SYMBOL(fld_insert_entry); - -static int fld_insert_special_entries(const struct lu_env *env, - struct lu_server_fld *fld) -{ - int rc; - - rc = fld_insert_entry(env, fld, &IGIF_FLD_RANGE); - if (rc != 0) - RETURN(rc); - - rc = fld_insert_entry(env, fld, &DOT_LUSTRE_FLD_RANGE); - if (rc != 0) - RETURN(rc); - - rc = fld_insert_entry(env, fld, &ROOT_FLD_RANGE); - - RETURN(rc); -} - -int fld_index_init(const struct lu_env *env, struct lu_server_fld *fld, - struct dt_device *dt) -{ - struct dt_object *dt_obj = NULL; - struct lu_fid fid; - struct lu_attr *attr = NULL; - struct lu_seq_range *range = NULL; - struct fld_thread_info *info; - struct dt_object_format dof; - struct dt_it *it; - const struct dt_it_ops *iops; - int rc; - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - LASSERT(info != NULL); - - lu_local_obj_fid(&fid, FLD_INDEX_OID); - OBD_ALLOC_PTR(attr); - if (attr == NULL) - RETURN(-ENOMEM); - - memset(attr, 0, sizeof(*attr)); - attr->la_valid = LA_MODE; - attr->la_mode = S_IFREG | 0666; - dof.dof_type = DFT_INDEX; - dof.u.dof_idx.di_feat = &fld_index_features; - - dt_obj = dt_find_or_create(env, dt, &fid, &dof, attr); - if (IS_ERR(dt_obj)) { - rc = PTR_ERR(dt_obj); - CERROR("%s: Can't find \"%s\" obj %d\n", fld->lsf_name, - fld_index_name, rc); - dt_obj = NULL; - GOTO(out, rc); - } - - fld->lsf_obj = dt_obj; - rc = dt_obj->do_ops->do_index_try(env, dt_obj, &fld_index_features); - if (rc != 0) { - CERROR("%s: File \"%s\" is not an index: rc = %d!\n", - fld->lsf_name, fld_index_name, rc); - GOTO(out, rc); - } - - range = &info->fti_rec; - /* Load fld entry to cache */ - iops = &dt_obj->do_index_ops->dio_it; - it = iops->init(env, dt_obj, 0, NULL); - if (IS_ERR(it)) - GOTO(out, rc = PTR_ERR(it)); - - rc = iops->load(env, it, 0); - if (rc < 0) - GOTO(out_it_fini, rc); - - if (rc > 0) { - /* Load FLD entry into server cache */ - do { - rc = iops->rec(env, it, (struct dt_rec *)range, 0); - if (rc != 0) - GOTO(out_it_put, rc); - LASSERT(range != NULL); - range_be_to_cpu(range, range); - rc = fld_cache_insert(fld->lsf_cache, range); - if (rc != 0) - GOTO(out_it_put, rc); - rc = iops->next(env, it); - } while (rc == 0); - } - - /* Note: fld_insert_entry will detect whether these - * special entries already exist inside FLDB */ - mutex_lock(&fld->lsf_lock); - rc = fld_insert_special_entries(env, fld); - mutex_unlock(&fld->lsf_lock); - if (rc != 0) { - CERROR("%s: insert special entries failed!: rc = %d\n", - fld->lsf_name, rc); - GOTO(out_it_put, rc); - } - -out_it_put: - iops->put(env, it); -out_it_fini: - iops->fini(env, it); -out: - if (attr != NULL) - OBD_FREE_PTR(attr); - - if (rc != 0) { - if (dt_obj != NULL) - lu_object_put(env, &dt_obj->do_lu); - fld->lsf_obj = NULL; - } - RETURN(rc); -} - -void fld_index_fini(const struct lu_env *env, struct lu_server_fld *fld) -{ - ENTRY; - if (fld->lsf_obj != NULL) { - if (!IS_ERR(fld->lsf_obj)) - lu_object_put(env, &fld->lsf_obj->do_lu); - fld->lsf_obj = NULL; - } - EXIT; -} diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h index 9fa9e01cdb6..56686b138ac 100644 --- a/drivers/staging/lustre/lustre/fld/fld_internal.h +++ b/drivers/staging/lustre/lustre/fld/fld_internal.h @@ -139,38 +139,10 @@ enum { extern struct lu_fld_hash fld_hash[]; - -struct fld_thread_info { - struct req_capsule *fti_pill; - __u64 fti_key; - struct lu_seq_range fti_rec; - struct lu_seq_range fti_lrange; - struct lu_seq_range fti_irange; -}; - -extern struct lu_context_key fld_thread_key; - -int fld_index_init(const struct lu_env *env, struct lu_server_fld *fld, - struct dt_device *dt); - -void fld_index_fini(const struct lu_env *env, struct lu_server_fld *fld); - -int fld_declare_index_create(const struct lu_env *env, - struct lu_server_fld *fld, - const struct lu_seq_range *new, - struct thandle *th); - -int fld_index_create(const struct lu_env *env, struct lu_server_fld *fld, - const struct lu_seq_range *new, struct thandle *th); - -int fld_index_lookup(const struct lu_env *env, struct lu_server_fld *fld, - seqno_t seq, struct lu_seq_range *range); - int fld_client_rpc(struct obd_export *exp, struct lu_seq_range *range, __u32 fld_op); #ifdef LPROCFS -extern struct lprocfs_vars fld_server_proc_list[]; extern struct lprocfs_vars fld_client_proc_list[]; #endif @@ -218,6 +190,5 @@ fld_target_name(struct lu_fld_target *tar) return (const char *)tar->ft_exp->exp_obd->obd_name; } -extern proc_dir_entry_t *fld_type_proc_dir; -extern struct file_operations fld_proc_seq_fops; +extern struct proc_dir_entry *fld_type_proc_dir; #endif /* __FLD_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index e9f07398b68..078e98bda68 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -44,7 +44,6 @@ # include <linux/libcfs/libcfs.h> # include <linux/module.h> -# include <linux/jbd.h> # include <asm/div64.h> #include <obd.h> @@ -60,16 +59,18 @@ #include <lustre_mdc.h> #include "fld_internal.h" +struct lu_context_key fld_thread_key; + /* TODO: these 3 functions are copies of flow-control code from mdc_lib.c * It should be common thing. The same about mdc RPC lock */ static int fld_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw) { int rc; - ENTRY; + client_obd_list_lock(&cli->cl_loi_list_lock); rc = list_empty(&mcw->mcw_entry); client_obd_list_unlock(&cli->cl_loi_list_lock); - RETURN(rc); + return rc; }; static void fld_enter_request(struct client_obd *cli) @@ -123,7 +124,6 @@ fld_rrb_scan(struct lu_client_fld *fld, seqno_t seq) { struct lu_fld_target *target; int hash; - ENTRY; /* Because almost all of special sequence located in MDT0, * it should go to index 0 directly, instead of calculating @@ -137,7 +137,7 @@ fld_rrb_scan(struct lu_client_fld *fld, seqno_t seq) list_for_each_entry(target, &fld->lcf_targets, ft_chain) { if (target->ft_idx == hash) - RETURN(target); + return target; } CERROR("%s: Can't find target by hash %d (seq "LPX64"). " @@ -161,7 +161,7 @@ fld_rrb_scan(struct lu_client_fld *fld, seqno_t seq) * LBUG() to catch this situation. */ LBUG(); - RETURN(NULL); + return NULL; } struct lu_fld_hash fld_hash[] = { @@ -179,7 +179,6 @@ static struct lu_fld_target * fld_client_get_target(struct lu_client_fld *fld, seqno_t seq) { struct lu_fld_target *target; - ENTRY; LASSERT(fld->lcf_hash != NULL); @@ -193,7 +192,7 @@ fld_client_get_target(struct lu_client_fld *fld, seqno_t seq) target->ft_idx, seq); } - RETURN(target); + return target; } /* @@ -205,7 +204,6 @@ int fld_client_add_target(struct lu_client_fld *fld, { const char *name; struct lu_fld_target *target, *tmp; - ENTRY; LASSERT(tar != NULL); name = fld_target_name(tar); @@ -216,7 +214,7 @@ int fld_client_add_target(struct lu_client_fld *fld, CERROR("%s: Attempt to add target %s (idx "LPU64") " "on fly - skip it\n", fld->lcf_name, name, tar->ft_idx); - RETURN(0); + return 0; } else { CDEBUG(D_INFO, "%s: Adding target %s (idx " LPU64")\n", fld->lcf_name, name, tar->ft_idx); @@ -224,7 +222,7 @@ int fld_client_add_target(struct lu_client_fld *fld, OBD_ALLOC_PTR(target); if (target == NULL) - RETURN(-ENOMEM); + return -ENOMEM; spin_lock(&fld->lcf_lock); list_for_each_entry(tmp, &fld->lcf_targets, ft_chain) { @@ -233,7 +231,7 @@ int fld_client_add_target(struct lu_client_fld *fld, OBD_FREE_PTR(target); CERROR("Target %s exists in FLD and known as %s:#"LPU64"\n", name, fld_target_name(tmp), tmp->ft_idx); - RETURN(-EEXIST); + return -EEXIST; } } @@ -249,7 +247,7 @@ int fld_client_add_target(struct lu_client_fld *fld, fld->lcf_count++; spin_unlock(&fld->lcf_lock); - RETURN(0); + return 0; } EXPORT_SYMBOL(fld_client_add_target); @@ -257,7 +255,6 @@ EXPORT_SYMBOL(fld_client_add_target); int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) { struct lu_fld_target *target, *tmp; - ENTRY; spin_lock(&fld->lcf_lock); list_for_each_entry_safe(target, tmp, @@ -271,19 +268,20 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) class_export_put(target->ft_exp); OBD_FREE_PTR(target); - RETURN(0); + return 0; } } spin_unlock(&fld->lcf_lock); - RETURN(-ENOENT); + return -ENOENT; } EXPORT_SYMBOL(fld_client_del_target); #ifdef LPROCFS +struct proc_dir_entry *fld_type_proc_dir = NULL; + static int fld_client_proc_init(struct lu_client_fld *fld) { int rc; - ENTRY; fld->lcf_proc_dir = lprocfs_register(fld->lcf_name, fld_type_proc_dir, @@ -293,7 +291,7 @@ static int fld_client_proc_init(struct lu_client_fld *fld) CERROR("%s: LProcFS failed in fld-init\n", fld->lcf_name); rc = PTR_ERR(fld->lcf_proc_dir); - RETURN(rc); + return rc; } rc = lprocfs_add_vars(fld->lcf_proc_dir, @@ -304,7 +302,7 @@ static int fld_client_proc_init(struct lu_client_fld *fld) GOTO(out_cleanup, rc); } - RETURN(0); + return 0; out_cleanup: fld_client_proc_fini(fld); @@ -313,13 +311,11 @@ out_cleanup: void fld_client_proc_fini(struct lu_client_fld *fld) { - ENTRY; if (fld->lcf_proc_dir) { if (!IS_ERR(fld->lcf_proc_dir)) lprocfs_remove(&fld->lcf_proc_dir); fld->lcf_proc_dir = NULL; } - EXIT; } #else static int fld_client_proc_init(struct lu_client_fld *fld) @@ -345,7 +341,6 @@ int fld_client_init(struct lu_client_fld *fld, { int cache_size, cache_threshold; int rc; - ENTRY; LASSERT(fld != NULL); @@ -355,7 +350,7 @@ int fld_client_init(struct lu_client_fld *fld, if (!hash_is_sane(hash)) { CERROR("%s: Wrong hash function %#x\n", fld->lcf_name, hash); - RETURN(-EINVAL); + return -EINVAL; } fld->lcf_count = 0; @@ -381,7 +376,6 @@ int fld_client_init(struct lu_client_fld *fld, rc = fld_client_proc_init(fld); if (rc) GOTO(out, rc); - EXIT; out: if (rc) fld_client_fini(fld); @@ -395,7 +389,6 @@ EXPORT_SYMBOL(fld_client_init); void fld_client_fini(struct lu_client_fld *fld) { struct lu_fld_target *target, *tmp; - ENTRY; spin_lock(&fld->lcf_lock); list_for_each_entry_safe(target, tmp, @@ -413,8 +406,6 @@ void fld_client_fini(struct lu_client_fld *fld) fld_cache_fini(fld->lcf_cache); fld->lcf_cache = NULL; } - - EXIT; } EXPORT_SYMBOL(fld_client_fini); @@ -426,7 +417,6 @@ int fld_client_rpc(struct obd_export *exp, __u32 *op; int rc; struct obd_import *imp; - ENTRY; LASSERT(exp != NULL); @@ -434,7 +424,7 @@ int fld_client_rpc(struct obd_export *exp, req = ptlrpc_request_alloc_pack(imp, &RQF_FLD_QUERY, LUSTRE_MDS_VERSION, FLD_QUERY); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; op = req_capsule_client_get(&req->rq_pill, &RMF_FLD_OPC); *op = fld_op; @@ -464,7 +454,6 @@ int fld_client_rpc(struct obd_export *exp, if (prange == NULL) GOTO(out_req, rc = -EFAULT); *range = *prange; - EXIT; out_req: ptlrpc_req_finished(req); return rc; @@ -476,14 +465,13 @@ int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds, struct lu_seq_range res = { 0 }; struct lu_fld_target *target; int rc; - ENTRY; fld->lcf_flags |= LUSTRE_FLD_RUN; rc = fld_cache_lookup(fld->lcf_cache, seq, &res); if (rc == 0) { *mds = res.lsr_index; - RETURN(0); + return 0; } /* Can not find it in the cache */ @@ -496,19 +484,14 @@ int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds, res.lsr_start = seq; fld_range_set_type(&res, flags); - if (target->ft_srv != NULL) { - LASSERT(env != NULL); - rc = fld_server_lookup(env, target->ft_srv, seq, &res); - } else { - rc = fld_client_rpc(target->ft_exp, &res, FLD_LOOKUP); - } + rc = fld_client_rpc(target->ft_exp, &res, FLD_LOOKUP); if (rc == 0) { *mds = res.lsr_index; fld_cache_insert(fld->lcf_cache, &res); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(fld_client_lookup); @@ -517,3 +500,32 @@ void fld_client_flush(struct lu_client_fld *fld) fld_cache_flush(fld->lcf_cache); } EXPORT_SYMBOL(fld_client_flush); + +static int __init fld_mod_init(void) +{ + fld_type_proc_dir = lprocfs_register(LUSTRE_FLD_NAME, + proc_lustre_root, + NULL, NULL); + if (IS_ERR(fld_type_proc_dir)) + return PTR_ERR(fld_type_proc_dir); + + LU_CONTEXT_KEY_INIT(&fld_thread_key); + lu_context_key_register(&fld_thread_key); + return 0; +} + +static void __exit fld_mod_exit(void) +{ + lu_context_key_degister(&fld_thread_key); + if (fld_type_proc_dir != NULL && !IS_ERR(fld_type_proc_dir)) { + lprocfs_remove(&fld_type_proc_dir); + fld_type_proc_dir = NULL; + } +} + +MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); +MODULE_DESCRIPTION("Lustre FLD"); +MODULE_LICENSE("GPL"); + +module_init(fld_mod_init) +module_exit(fld_mod_exit) diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index c1bd80339e6..052f7d51a07 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -62,7 +62,6 @@ fld_proc_targets_seq_show(struct seq_file *m, void *unused) { struct lu_client_fld *fld = (struct lu_client_fld *)m->private; struct lu_fld_target *target; - ENTRY; LASSERT(fld != NULL); @@ -72,14 +71,13 @@ fld_proc_targets_seq_show(struct seq_file *m, void *unused) seq_printf(m, "%s\n", fld_target_name(target)); spin_unlock(&fld->lcf_lock); - RETURN(0); + return 0; } static int fld_proc_hash_seq_show(struct seq_file *m, void *unused) { struct lu_client_fld *fld = (struct lu_client_fld *)m->private; - ENTRY; LASSERT(fld != NULL); @@ -87,7 +85,7 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused) seq_printf(m, "%s\n", fld->lcf_hash->fh_name); spin_unlock(&fld->lcf_lock); - RETURN(0); + return 0; } static ssize_t @@ -97,7 +95,6 @@ fld_proc_hash_seq_write(struct file *file, const char *buffer, struct lu_client_fld *fld = ((struct seq_file *)file->private_data)->private; struct lu_fld_hash *hash = NULL; int i; - ENTRY; LASSERT(fld != NULL); @@ -120,7 +117,7 @@ fld_proc_hash_seq_write(struct file *file, const char *buffer, fld->lcf_name, hash->fh_name); } - RETURN(count); + return count; } static ssize_t @@ -128,7 +125,6 @@ fld_proc_cache_flush_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { struct lu_client_fld *fld = file->private_data; - ENTRY; LASSERT(fld != NULL); @@ -136,7 +132,7 @@ fld_proc_cache_flush_write(struct file *file, const char __user *buffer, CDEBUG(D_INFO, "%s: Lookup cache is flushed\n", fld->lcf_name); - RETURN(count); + return count; } static int fld_proc_cache_flush_open(struct inode *inode, struct file *file) @@ -158,202 +154,6 @@ struct file_operations fld_proc_cache_flush_fops = { .release = fld_proc_cache_flush_release, }; -struct fld_seq_param { - struct lu_env fsp_env; - struct dt_it *fsp_it; - struct lu_server_fld *fsp_fld; - unsigned int fsp_stop:1; -}; - -static void *fldb_seq_start(struct seq_file *p, loff_t *pos) -{ - struct fld_seq_param *param = p->private; - struct lu_server_fld *fld; - struct dt_object *obj; - const struct dt_it_ops *iops; - - if (param == NULL || param->fsp_stop) - return NULL; - - fld = param->fsp_fld; - obj = fld->lsf_obj; - LASSERT(obj != NULL); - iops = &obj->do_index_ops->dio_it; - - iops->load(¶m->fsp_env, param->fsp_it, *pos); - - *pos = be64_to_cpu(*(__u64 *)iops->key(¶m->fsp_env, param->fsp_it)); - return param; -} - -static void fldb_seq_stop(struct seq_file *p, void *v) -{ - struct fld_seq_param *param = p->private; - const struct dt_it_ops *iops; - struct lu_server_fld *fld; - struct dt_object *obj; - - if (param == NULL) - return; - - fld = param->fsp_fld; - obj = fld->lsf_obj; - LASSERT(obj != NULL); - iops = &obj->do_index_ops->dio_it; - - iops->put(¶m->fsp_env, param->fsp_it); -} - -static void *fldb_seq_next(struct seq_file *p, void *v, loff_t *pos) -{ - struct fld_seq_param *param = p->private; - struct lu_server_fld *fld; - struct dt_object *obj; - const struct dt_it_ops *iops; - int rc; - - if (param == NULL || param->fsp_stop) - return NULL; - - fld = param->fsp_fld; - obj = fld->lsf_obj; - LASSERT(obj != NULL); - iops = &obj->do_index_ops->dio_it; - - rc = iops->next(¶m->fsp_env, param->fsp_it); - if (rc > 0) { - param->fsp_stop = 1; - return NULL; - } - - *pos = be64_to_cpu(*(__u64 *)iops->key(¶m->fsp_env, param->fsp_it)); - return param; -} - -static int fldb_seq_show(struct seq_file *p, void *v) -{ - struct fld_seq_param *param = p->private; - struct lu_server_fld *fld; - struct dt_object *obj; - const struct dt_it_ops *iops; - struct fld_thread_info *info; - struct lu_seq_range *fld_rec; - int rc; - - if (param == NULL || param->fsp_stop) - return 0; - - fld = param->fsp_fld; - obj = fld->lsf_obj; - LASSERT(obj != NULL); - iops = &obj->do_index_ops->dio_it; - - info = lu_context_key_get(¶m->fsp_env.le_ctx, - &fld_thread_key); - fld_rec = &info->fti_rec; - rc = iops->rec(¶m->fsp_env, param->fsp_it, - (struct dt_rec *)fld_rec, 0); - if (rc != 0) { - CERROR("%s:read record error: rc %d\n", - fld->lsf_name, rc); - } else if (fld_rec->lsr_start != 0) { - range_be_to_cpu(fld_rec, fld_rec); - rc = seq_printf(p, DRANGE"\n", PRANGE(fld_rec)); - } - - return rc; -} - -struct seq_operations fldb_sops = { - .start = fldb_seq_start, - .stop = fldb_seq_stop, - .next = fldb_seq_next, - .show = fldb_seq_show, -}; - -static int fldb_seq_open(struct inode *inode, struct file *file) -{ - struct seq_file *seq; - struct lu_server_fld *fld = (struct lu_server_fld *)PDE_DATA(inode); - struct dt_object *obj; - const struct dt_it_ops *iops; - struct fld_seq_param *param = NULL; - int env_init = 0; - int rc; - - rc = seq_open(file, &fldb_sops); - if (rc) - GOTO(out, rc); - - obj = fld->lsf_obj; - if (obj == NULL) { - seq = file->private_data; - seq->private = NULL; - return 0; - } - - OBD_ALLOC_PTR(param); - if (param == NULL) - GOTO(out, rc = -ENOMEM); - - rc = lu_env_init(¶m->fsp_env, LCT_MD_THREAD); - if (rc != 0) - GOTO(out, rc); - - env_init = 1; - iops = &obj->do_index_ops->dio_it; - param->fsp_it = iops->init(¶m->fsp_env, obj, 0, NULL); - if (IS_ERR(param->fsp_it)) - GOTO(out, rc = PTR_ERR(param->fsp_it)); - - param->fsp_fld = fld; - param->fsp_stop = 0; - - seq = file->private_data; - seq->private = param; -out: - if (rc != 0) { - if (env_init == 1) - lu_env_fini(¶m->fsp_env); - if (param != NULL) - OBD_FREE_PTR(param); - } - return rc; -} - -static int fldb_seq_release(struct inode *inode, struct file *file) -{ - struct seq_file *seq = file->private_data; - struct fld_seq_param *param; - struct lu_server_fld *fld; - struct dt_object *obj; - const struct dt_it_ops *iops; - - param = seq->private; - if (param == NULL) { - lprocfs_seq_release(inode, file); - return 0; - } - - fld = param->fsp_fld; - obj = fld->lsf_obj; - LASSERT(obj != NULL); - iops = &obj->do_index_ops->dio_it; - - LASSERT(iops != NULL); - LASSERT(obj != NULL); - LASSERT(param->fsp_it != NULL); - iops->fini(¶m->fsp_env, param->fsp_it); - lu_env_fini(¶m->fsp_env); - OBD_FREE_PTR(param); - lprocfs_seq_release(inode, file); - - return 0; -} - -struct lprocfs_vars fld_server_proc_list[] = { - { NULL }}; - LPROC_SEQ_FOPS_RO(fld_proc_targets); LPROC_SEQ_FOPS(fld_proc_hash); @@ -363,11 +163,4 @@ struct lprocfs_vars fld_client_proc_list[] = { { "cache_flush", &fld_proc_cache_flush_fops }, { NULL }}; -struct file_operations fld_proc_seq_fops = { - .owner = THIS_MODULE, - .open = fldb_seq_open, - .read = seq_read, - .release = fldb_seq_release, -}; - -#endif +#endif /* LPROCFS */ diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index 4bb68801d3a..edb40afe66f 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -758,7 +758,7 @@ struct cl_page { /** * Debug information, the task is owning the page. */ - task_t *cp_task; + struct task_struct *cp_task; /** * Owning IO request in cl_page_state::CPS_PAGEOUT and * cl_page_state::CPS_PAGEIN states. This field is maintained only in @@ -768,11 +768,11 @@ struct cl_page { /** List of references to this page, for debugging. */ struct lu_ref cp_reference; /** Link to an object, for debugging. */ - struct lu_ref_link *cp_obj_ref; + struct lu_ref_link cp_obj_ref; /** Link to a queue, for debugging. */ - struct lu_ref_link *cp_queue_ref; + struct lu_ref_link cp_queue_ref; /** Per-page flags from enum cl_page_flags. Protected by a VM lock. */ - unsigned cp_flags; + unsigned cp_flags; /** Assigned if doing a sync_io */ struct cl_sync_io *cp_sync_io; }; @@ -1576,13 +1576,13 @@ struct cl_lock { * \see osc_lock_enqueue_wait(), lov_lock_cancel(), lov_sublock_wait(). */ struct mutex cll_guard; - task_t *cll_guarder; + struct task_struct *cll_guarder; int cll_depth; /** * the owner for INTRANSIT state */ - task_t *cll_intransit_owner; + struct task_struct *cll_intransit_owner; int cll_error; /** * Number of holds on a lock. A hold prevents a lock from being @@ -1625,7 +1625,7 @@ struct cl_lock { /** * A reference for cl_lock::cll_descr::cld_obj. For debugging. */ - struct lu_ref_link *cll_obj_ref; + struct lu_ref_link cll_obj_ref; #ifdef CONFIG_LOCKDEP /* "dep_map" name is assumed by lockdep.h macros. */ struct lockdep_map dep_map; @@ -1869,7 +1869,7 @@ do { \ struct cl_page_list { unsigned pl_nr; struct list_head pl_pages; - task_t *pl_owner; + struct task_struct *pl_owner; }; /** @@ -2517,7 +2517,7 @@ struct cl_req_obj { /** object itself */ struct cl_object *ro_obj; /** reference to cl_req_obj::ro_obj. For debugging. */ - struct lu_ref_link *ro_obj_ref; + struct lu_ref_link ro_obj_ref; /* something else? Number of pages for a given object? */ }; diff --git a/drivers/staging/lustre/lustre/include/linux/lprocfs_status.h b/drivers/staging/lustre/lustre/include/linux/lprocfs_status.h index 586692272d7..4bcc4dcca3d 100644 --- a/drivers/staging/lustre/lustre/include/linux/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/linux/lprocfs_status.h @@ -48,7 +48,6 @@ #include <linux/proc_fs.h> #include <linux/seq_file.h> -#include <linux/version.h> #include <linux/smp.h> #include <linux/rwsem.h> #include <linux/libcfs/libcfs.h> diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index dff04688945..9243dfab43d 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -87,22 +87,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define LTIME_S(time) (time.tv_sec) -#define ll_permission(inode,mask,nd) inode_permission(inode,mask) - -# define ll_generic_permission(inode, mask, flags, check_acl) \ - generic_permission(inode, mask) - -#define ll_blkdev_put(a, b) blkdev_put(a, b) - -#define ll_dentry_open(a,b,c) dentry_open(a,b,c) - -#define ll_vfs_symlink(dir, dentry, mnt, path, mode) \ - vfs_symlink(dir, dentry, path) - - -#define ll_generic_file_llseek_size(file, offset, origin, maxbytes, eof) \ - generic_file_llseek_size(file, offset, origin, maxbytes, eof); - /* inode_dio_wait(i) use as-is for write lock */ # define inode_dio_write_done(i) do {} while (0) /* for write unlock */ # define inode_dio_read(i) atomic_inc(&(i)->i_dio_count) @@ -111,88 +95,10 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define TREE_READ_LOCK_IRQ(mapping) spin_lock_irq(&(mapping)->tree_lock) #define TREE_READ_UNLOCK_IRQ(mapping) spin_unlock_irq(&(mapping)->tree_lock) -static inline -int ll_unregister_blkdev(unsigned int dev, const char *name) -{ - unregister_blkdev(dev, name); - return 0; -} - -#define ll_invalidate_bdev(a,b) invalidate_bdev((a)) - #ifndef FS_HAS_FIEMAP #define FS_HAS_FIEMAP (0) #endif - - -/* add a lustre compatible layer for crypto API */ -#include <linux/crypto.h> -#define ll_crypto_hash crypto_hash -#define ll_crypto_cipher crypto_blkcipher -#define ll_crypto_alloc_hash(name, type, mask) crypto_alloc_hash(name, type, mask) -#define ll_crypto_hash_setkey(tfm, key, keylen) crypto_hash_setkey(tfm, key, keylen) -#define ll_crypto_hash_init(desc) crypto_hash_init(desc) -#define ll_crypto_hash_update(desc, sl, bytes) crypto_hash_update(desc, sl, bytes) -#define ll_crypto_hash_final(desc, out) crypto_hash_final(desc, out) -#define ll_crypto_blkcipher_setkey(tfm, key, keylen) \ - crypto_blkcipher_setkey(tfm, key, keylen) -#define ll_crypto_blkcipher_set_iv(tfm, src, len) \ - crypto_blkcipher_set_iv(tfm, src, len) -#define ll_crypto_blkcipher_get_iv(tfm, dst, len) \ - crypto_blkcipher_get_iv(tfm, dst, len) -#define ll_crypto_blkcipher_encrypt(desc, dst, src, bytes) \ - crypto_blkcipher_encrypt(desc, dst, src, bytes) -#define ll_crypto_blkcipher_decrypt(desc, dst, src, bytes) \ - crypto_blkcipher_decrypt(desc, dst, src, bytes) -#define ll_crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) \ - crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) -#define ll_crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) \ - crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) - -static inline -struct ll_crypto_cipher *ll_crypto_alloc_blkcipher(const char *name, - u32 type, u32 mask) -{ - struct ll_crypto_cipher *rtn = crypto_alloc_blkcipher(name, type, mask); - - return (rtn == NULL ? ERR_PTR(-ENOMEM) : rtn); -} - -static inline int ll_crypto_hmac(struct ll_crypto_hash *tfm, - u8 *key, unsigned int *keylen, - struct scatterlist *sg, - unsigned int size, u8 *result) -{ - struct hash_desc desc; - int rv; - desc.tfm = tfm; - desc.flags = 0; - rv = crypto_hash_setkey(desc.tfm, key, *keylen); - if (rv) { - CERROR("failed to hash setkey: %d\n", rv); - return rv; - } - return crypto_hash_digest(&desc, sg, size, result); -} -static inline -unsigned int ll_crypto_tfm_alg_max_keysize(struct crypto_blkcipher *tfm) -{ - return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.max_keysize; -} -static inline -unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm) -{ - return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.min_keysize; -} - -#define ll_crypto_hash_blocksize(tfm) crypto_hash_blocksize(tfm) -#define ll_crypto_hash_digestsize(tfm) crypto_hash_digestsize(tfm) -#define ll_crypto_blkcipher_ivsize(tfm) crypto_blkcipher_ivsize(tfm) -#define ll_crypto_blkcipher_blocksize(tfm) crypto_blkcipher_blocksize(tfm) -#define ll_crypto_free_hash(tfm) crypto_free_hash(tfm) -#define ll_crypto_free_blkcipher(tfm) crypto_free_blkcipher(tfm) - #define ll_vfs_rmdir(dir,entry,mnt) vfs_rmdir(dir,entry) #define ll_vfs_mkdir(inode,dir,mnt,mode) vfs_mkdir(inode,dir,mode) #define ll_vfs_link(old,mnt,dir,new,mnt1) vfs_link(old,dir,new) @@ -202,12 +108,6 @@ unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm) #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \ vfs_rename(old,old_dir,new,new_dir) -#ifdef for_each_possible_cpu -#define cfs_for_each_possible_cpu(cpu) for_each_possible_cpu(cpu) -#elif defined(for_each_cpu) -#define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu) -#endif - #define cfs_bio_io_error(a,b) bio_io_error((a)) #define cfs_bio_endio(a,b,c) bio_endio((a),(c)) @@ -266,9 +166,6 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount) #define queue_max_phys_segments(rq) queue_max_segments(rq) #define queue_max_hw_segments(rq) queue_max_segments(rq) -#define ll_kmap_atomic(a, b) kmap_atomic(a) -#define ll_kunmap_atomic(a, b) kunmap_atomic(a) - #define ll_d_hlist_node hlist_node #define ll_d_hlist_empty(list) hlist_empty(list) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h b/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h index 6c726095738..4da6e372e00 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h @@ -54,7 +54,7 @@ typedef void (*fsfilt_cb_t)(struct obd_device *obd, __u64 last_rcvd, struct fsfilt_operations { struct list_head fs_list; - module_t *fs_owner; + struct module *fs_owner; char *fs_type; char *(* fs_getlabel)(struct super_block *sb); void *(* fs_start)(struct inode *inode, int op, void *desc_private, @@ -145,16 +145,6 @@ static inline int fsfilt_commit(struct obd_device *obd, struct inode *inode, return rc; } -static inline int fsfilt_map_inode_pages(struct obd_device *obd, - struct inode *inode, - struct page **page, int pages, - unsigned long *blocks, - int create, struct mutex *mutex) -{ - return obd->obd_fsops->fs_map_inode_pages(inode, page, pages, blocks, - create, mutex); -} - static inline int fsfilt_read_record(struct obd_device *obd, struct file *file, void *buf, loff_t size, loff_t *offs) { diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_handles.h b/drivers/staging/lustre/lustre/include/linux/lustre_handles.h index ecf18405125..459b2380600 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_handles.h @@ -42,7 +42,6 @@ #include <asm/types.h> #include <asm/atomic.h> #include <linux/list.h> -#include <linux/version.h> #include <linux/spinlock.h> #include <linux/types.h> diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_lib.h b/drivers/staging/lustre/lustre/include/linux/lustre_lib.h index b2f755acadf..57f3b01d1a3 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_lib.h @@ -53,15 +53,13 @@ # include <linux/lustre_common.h> #ifndef LP_POISON +# define LI_POISON 0x5a5a5a5a #if BITS_PER_LONG > 32 -# define LI_POISON ((int)0x5a5a5a5a5a5a5a5a) -# define LL_POISON ((long)0x5a5a5a5a5a5a5a5a) -# define LP_POISON ((void *)(long)0x5a5a5a5a5a5a5a5a) +# define LL_POISON 0x5a5a5a5a5a5a5a5aL #else -# define LI_POISON ((int)0x5a5a5a5a) -# define LL_POISON ((long)0x5a5a5a5a) -# define LP_POISON ((void *)(long)0x5a5a5a5a) +# define LL_POISON 0x5a5a5a5aL #endif +# define LP_POISON ((void *)LL_POISON) #endif /* This macro is only for compatibility reasons with older Linux Lustre user diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h index c95dff900b5..9e5df8dabe8 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h @@ -40,8 +40,6 @@ #endif -#include <linux/version.h> - #include <asm/statfs.h> #include <linux/fs.h> diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_net.h b/drivers/staging/lustre/lustre/include/linux/lustre_net.h index 2d7c425d701..05de4d87db9 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_net.h @@ -39,7 +39,6 @@ #error Do not #include this file directly. #include <lustre_net.h> instead #endif -#include <linux/version.h> #include <linux/workqueue.h> /* XXX Liang: should be moved to other header instead of here */ diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h index a8e9c0c8ffd..a260e99a444 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h @@ -53,7 +53,7 @@ truncate_complete_page(struct address_space *mapping, struct page *page) return; if (PagePrivate(page)) - page->mapping->a_ops->invalidatepage(page, 0); + page->mapping->a_ops->invalidatepage(page, 0, PAGE_CACHE_SIZE); cancel_dirty_page(page, PAGE_SIZE); ClearPageMappedToDisk(page); diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_quota.h b/drivers/staging/lustre/lustre/include/linux/lustre_quota.h index 421866b004c..a39505014c8 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_quota.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_quota.h @@ -39,7 +39,6 @@ #error Do not #include this file directly. #include <lustre_quota.h> instead #endif -#include <linux/version.h> #include <linux/fs.h> #include <linux/quota.h> #include <linux/quotaops.h> diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_user.h b/drivers/staging/lustre/lustre/include/linux/lustre_user.h index ebaf92977f7..9cc2849f3f8 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_user.h @@ -41,7 +41,6 @@ #ifndef _LINUX_LUSTRE_USER_H #define _LINUX_LUSTRE_USER_H -# include <linux/version.h> # include <linux/quota.h> /* @@ -53,15 +52,19 @@ #include <linux/string.h> -#if defined(__x86_64__) || defined(__ia64__) || defined(__ppc64__) || \ - defined(__craynv) || defined (__mips64__) || defined(__powerpc64__) -typedef struct stat lstat_t; -#define lstat_f lstat -#define HAVE_LOV_USER_MDS_DATA -#else +/* + * We need to always use 64bit version because the structure + * is shared across entire cluster where 32bit and 64bit machines + * are co-existing. + */ +#if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64) typedef struct stat64 lstat_t; #define lstat_f lstat64 -#define HAVE_LOV_USER_MDS_DATA +#else +typedef struct stat lstat_t; +#define lstat_f lstat #endif +#define HAVE_LOV_USER_MDS_DATA + #endif /* _LUSTRE_USER_H */ diff --git a/drivers/staging/lustre/lustre/include/linux/lvfs.h b/drivers/staging/lustre/lustre/include/linux/lvfs.h index eb59ac7d594..e61f1b87f82 100644 --- a/drivers/staging/lustre/lustre/include/linux/lvfs.h +++ b/drivers/staging/lustre/lustre/include/linux/lvfs.h @@ -54,10 +54,10 @@ /* simple.c */ struct lvfs_ucred { - __u32 luc_uid; - __u32 luc_gid; - __u32 luc_fsuid; - __u32 luc_fsgid; + kuid_t luc_uid; + kgid_t luc_gid; + kuid_t luc_fsuid; + kgid_t luc_fsgid; kernel_cap_t luc_cap; __u32 luc_umask; struct group_info *luc_ginfo; diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h index 2c36c0d19d0..01a50265239 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd.h +++ b/drivers/staging/lustre/lustre/include/linux/obd.h @@ -93,11 +93,8 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock, lock, task->comm, task->pid, lock->func, lock->line, (jiffies - lock->time) / HZ); - LCONSOLE_WARN("====== for process holding the " - "lock =====\n"); - libcfs_debug_dumpstack(task); LCONSOLE_WARN("====== for current process =====\n"); - libcfs_debug_dumpstack(NULL); + dump_stack(); LCONSOLE_WARN("====== end =======\n"); cfs_pause(1000 * HZ); } diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 55f182205d7..56b05728f61 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -345,7 +345,7 @@ enum { #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE /* class_obd.c */ -extern proc_dir_entry_t *proc_lustre_root; +extern struct proc_dir_entry *proc_lustre_root; struct obd_device; struct obd_histogram; @@ -370,18 +370,6 @@ static inline void s2dhms(struct dhms *ts, time_t secs) #define JOBSTATS_DISABLE "disable" #define JOBSTATS_PROCNAME_UID "procname_uid" -typedef void (*cntr_init_callback)(struct lprocfs_stats *stats); - -struct obd_job_stats { - cfs_hash_t *ojs_hash; - struct list_head ojs_list; - rwlock_t ojs_lock; /* protect the obj_list */ - cntr_init_callback ojs_cntr_init_fn; - int ojs_cntr_num; - int ojs_cleanup_interval; - time_t ojs_last_cleanup; -}; - #ifdef LPROCFS extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, @@ -562,11 +550,11 @@ extern void lprocfs_free_md_stats(struct obd_device *obddev); struct obd_export; struct nid_stat; extern int lprocfs_add_clear_entry(struct obd_device * obd, - proc_dir_entry_t *entry); + struct proc_dir_entry *entry); extern int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *peer_nid, int *newnid); extern int lprocfs_exp_cleanup(struct obd_export *exp); -extern proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root, +extern struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, char *name, void *data, struct file_operations *fops); @@ -579,27 +567,27 @@ lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, unsigned long count, void *data); extern int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data); -extern int lprocfs_register_stats(proc_dir_entry_t *root, const char *name, +extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, struct lprocfs_stats *stats); /* lprocfs_status.c */ -extern int lprocfs_add_vars(proc_dir_entry_t *root, +extern int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *var, void *data); -extern proc_dir_entry_t *lprocfs_register(const char *name, - proc_dir_entry_t *parent, +extern struct proc_dir_entry *lprocfs_register(const char *name, + struct proc_dir_entry *parent, struct lprocfs_vars *list, void *data); -extern void lprocfs_remove(proc_dir_entry_t **root); +extern void lprocfs_remove(struct proc_dir_entry **root); extern void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent); extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list); extern int lprocfs_obd_cleanup(struct obd_device *obd); -extern int lprocfs_seq_create(proc_dir_entry_t *parent, const char *name, +extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name, umode_t mode, const struct file_operations *seq_fops, void *data); @@ -663,8 +651,8 @@ extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count, extern int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count, __u64 *val, int mult); -char *lprocfs_find_named_value(const char *buffer, const char *name, - unsigned long *count); +extern char *lprocfs_find_named_value(const char *buffer, const char *name, + size_t *count); void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value); void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value); void lprocfs_oh_clear(struct obd_histogram *oh); @@ -748,16 +736,6 @@ struct file_operations name##_fops = { \ .release = lprocfs_single_release, \ }; -/* lprocfs_jobstats.c */ -int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, - int event, long amount); -void lprocfs_job_stats_fini(struct obd_device *obd); -int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num, - cntr_init_callback fn); -int lprocfs_rd_job_interval(struct seq_file *m, void *data); -int lprocfs_wr_job_interval(struct file *file, const char *buffer, - unsigned long count, void *data); - /* lproc_ptlrpc.c */ struct ptlrpc_request; extern void target_print_req(void *seq_file, struct ptlrpc_request *req); @@ -826,9 +804,6 @@ extern int lprocfs_quota_rd_qs_factor(char *page, char **start, loff_t off, extern int lprocfs_quota_wr_qs_factor(struct file *file, const char *buffer, unsigned long count, void *data); - - - #else /* LPROCFS is not defined */ @@ -863,7 +838,7 @@ static inline void lprocfs_clear_stats(struct lprocfs_stats *stats) { return; } static inline void lprocfs_free_stats(struct lprocfs_stats **stats) { return; } -static inline int lprocfs_register_stats(proc_dir_entry_t *root, +static inline int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, struct lprocfs_stats *stats) { return 0; } @@ -894,7 +869,7 @@ static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid, { return 0; } static inline int lprocfs_exp_cleanup(struct obd_export *exp) { return 0; } -static inline proc_dir_entry_t * +static inline struct proc_dir_entry * lprocfs_add_simple(struct proc_dir_entry *root, char *name, void *data, struct file_operations *fops) {return 0; } @@ -912,15 +887,15 @@ static inline int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data) { return 0; } -static inline proc_dir_entry_t * -lprocfs_register(const char *name, proc_dir_entry_t *parent, +static inline struct proc_dir_entry * +lprocfs_register(const char *name, struct proc_dir_entry *parent, struct lprocfs_vars *list, void *data) { return NULL; } -static inline int lprocfs_add_vars(proc_dir_entry_t *root, +static inline int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *var, void *data) { return 0; } -static inline void lprocfs_remove(proc_dir_entry_t **root) +static inline void lprocfs_remove(struct proc_dir_entry **root) { return; } static inline void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent) @@ -1021,20 +996,6 @@ __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx, #define LPROC_SEQ_FOPS_RW_TYPE(name, type) #define LPROC_SEQ_FOPS_WR_ONLY(name, type) -/* lprocfs_jobstats.c */ -static inline -int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event, - long amount) -{ return 0; } -static inline -void lprocfs_job_stats_fini(struct obd_device *obd) -{ return; } -static inline -int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num, - cntr_init_callback fn) -{ return 0; } - - /* lproc_ptlrpc.c */ #define target_print_req NULL diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index d40ad81b4eb..fa31be886ef 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -496,7 +496,7 @@ struct lu_object { /** * Link to the device, for debugging. */ - struct lu_ref_link *lo_dev_ref; + struct lu_ref_link lo_dev_ref; }; enum lu_object_header_flags { @@ -665,6 +665,11 @@ lu_site_bkt_from_fid(struct lu_site *site, struct lu_fid *fid) return cfs_hash_bd_extra_get(site->ls_obj_hash, &bd); } +static inline struct seq_server_site *lu_site2seq(const struct lu_site *s) +{ + return s->ld_seq_site; +} + /** \name ctors * Constructors/destructors. * @{ @@ -868,11 +873,19 @@ static inline __u32 lu_object_attr(const struct lu_object *o) return o->lo_header->loh_attr; } -static inline struct lu_ref_link *lu_object_ref_add(struct lu_object *o, - const char *scope, - const void *source) +static inline void lu_object_ref_add(struct lu_object *o, + const char *scope, + const void *source) +{ + lu_ref_add(&o->lo_header->loh_reference, scope, source); +} + +static inline void lu_object_ref_add_at(struct lu_object *o, + struct lu_ref_link *link, + const char *scope, + const void *source) { - return lu_ref_add(&o->lo_header->loh_reference, scope, source); + lu_ref_add_at(&o->lo_header->loh_reference, link, scope, source); } static inline void lu_object_ref_del(struct lu_object *o, @@ -1118,7 +1131,7 @@ struct lu_context_key { /** * Internal implementation detail: module for this key. */ - module_t *lct_owner; + struct module *lct_owner; /** * References to this key. For debugging. */ diff --git a/drivers/staging/lustre/lustre/include/lu_ref.h b/drivers/staging/lustre/lustre/include/lu_ref.h index 624c19be152..50a2a7f786d 100644 --- a/drivers/staging/lustre/lustre/include/lu_ref.h +++ b/drivers/staging/lustre/lustre/include/lu_ref.h @@ -108,7 +108,12 @@ */ -struct lu_ref {}; +/* + * dummy data structures/functions to pass compile for now. + * We need to reimplement them with kref. + */ +struct lu_ref {}; +struct lu_ref_link {}; static inline void lu_ref_init(struct lu_ref *ref) { @@ -132,6 +137,13 @@ static inline struct lu_ref_link *lu_ref_add_atomic(struct lu_ref *ref, return NULL; } +static inline void lu_ref_add_at(struct lu_ref *ref, + struct lu_ref_link *link, + const char *scope, + const void *source) +{ +} + static inline void lu_ref_del(struct lu_ref *ref, const char *scope, const void *source) { diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h b/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h new file mode 100644 index 00000000000..2870487dd28 --- /dev/null +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h @@ -0,0 +1,215 @@ +/* + * 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/gpl-2.0.txt + * + * GPL HEADER END + */ +/* + * Copyright (C) 2011 FUJITSU LIMITED. All rights reserved. + * + * Copyright (c) 2013, Intel Corporation. + */ + +#ifndef LUSTRE_ERRNO_H +#define LUSTRE_ERRNO_H + +/* + * Only "network" errnos, which are defined below, are allowed on wire (or on + * disk). Generic routines exist to help translate between these and a subset + * of the "host" errnos. Some host errnos (e.g., EDEADLOCK) are intentionally + * left out. See also the comment on lustre_errno_hton_mapping[]. + * + * To maintain compatibility with existing x86 clients and servers, each of + * these network errnos has the same numerical value as its corresponding host + * errno on x86. + */ +#define LUSTRE_EPERM 1 /* Operation not permitted */ +#define LUSTRE_ENOENT 2 /* No such file or directory */ +#define LUSTRE_ESRCH 3 /* No such process */ +#define LUSTRE_EINTR 4 /* Interrupted system call */ +#define LUSTRE_EIO 5 /* I/O error */ +#define LUSTRE_ENXIO 6 /* No such device or address */ +#define LUSTRE_E2BIG 7 /* Argument list too long */ +#define LUSTRE_ENOEXEC 8 /* Exec format error */ +#define LUSTRE_EBADF 9 /* Bad file number */ +#define LUSTRE_ECHILD 10 /* No child processes */ +#define LUSTRE_EAGAIN 11 /* Try again */ +#define LUSTRE_ENOMEM 12 /* Out of memory */ +#define LUSTRE_EACCES 13 /* Permission denied */ +#define LUSTRE_EFAULT 14 /* Bad address */ +#define LUSTRE_ENOTBLK 15 /* Block device required */ +#define LUSTRE_EBUSY 16 /* Device or resource busy */ +#define LUSTRE_EEXIST 17 /* File exists */ +#define LUSTRE_EXDEV 18 /* Cross-device link */ +#define LUSTRE_ENODEV 19 /* No such device */ +#define LUSTRE_ENOTDIR 20 /* Not a directory */ +#define LUSTRE_EISDIR 21 /* Is a directory */ +#define LUSTRE_EINVAL 22 /* Invalid argument */ +#define LUSTRE_ENFILE 23 /* File table overflow */ +#define LUSTRE_EMFILE 24 /* Too many open files */ +#define LUSTRE_ENOTTY 25 /* Not a typewriter */ +#define LUSTRE_ETXTBSY 26 /* Text file busy */ +#define LUSTRE_EFBIG 27 /* File too large */ +#define LUSTRE_ENOSPC 28 /* No space left on device */ +#define LUSTRE_ESPIPE 29 /* Illegal seek */ +#define LUSTRE_EROFS 30 /* Read-only file system */ +#define LUSTRE_EMLINK 31 /* Too many links */ +#define LUSTRE_EPIPE 32 /* Broken pipe */ +#define LUSTRE_EDOM 33 /* Math argument out of domain of + func */ +#define LUSTRE_ERANGE 34 /* Math result not representable */ +#define LUSTRE_EDEADLK 35 /* Resource deadlock would occur */ +#define LUSTRE_ENAMETOOLONG 36 /* File name too long */ +#define LUSTRE_ENOLCK 37 /* No record locks available */ +#define LUSTRE_ENOSYS 38 /* Function not implemented */ +#define LUSTRE_ENOTEMPTY 39 /* Directory not empty */ +#define LUSTRE_ELOOP 40 /* Too many symbolic links + encountered */ +#define LUSTRE_ENOMSG 42 /* No message of desired type */ +#define LUSTRE_EIDRM 43 /* Identifier removed */ +#define LUSTRE_ECHRNG 44 /* Channel number out of range */ +#define LUSTRE_EL2NSYNC 45 /* Level 2 not synchronized */ +#define LUSTRE_EL3HLT 46 /* Level 3 halted */ +#define LUSTRE_EL3RST 47 /* Level 3 reset */ +#define LUSTRE_ELNRNG 48 /* Link number out of range */ +#define LUSTRE_EUNATCH 49 /* Protocol driver not attached */ +#define LUSTRE_ENOCSI 50 /* No CSI structure available */ +#define LUSTRE_EL2HLT 51 /* Level 2 halted */ +#define LUSTRE_EBADE 52 /* Invalid exchange */ +#define LUSTRE_EBADR 53 /* Invalid request descriptor */ +#define LUSTRE_EXFULL 54 /* Exchange full */ +#define LUSTRE_ENOANO 55 /* No anode */ +#define LUSTRE_EBADRQC 56 /* Invalid request code */ +#define LUSTRE_EBADSLT 57 /* Invalid slot */ +#define LUSTRE_EBFONT 59 /* Bad font file format */ +#define LUSTRE_ENOSTR 60 /* Device not a stream */ +#define LUSTRE_ENODATA 61 /* No data available */ +#define LUSTRE_ETIME 62 /* Timer expired */ +#define LUSTRE_ENOSR 63 /* Out of streams resources */ +#define LUSTRE_ENONET 64 /* Machine is not on the network */ +#define LUSTRE_ENOPKG 65 /* Package not installed */ +#define LUSTRE_EREMOTE 66 /* Object is remote */ +#define LUSTRE_ENOLINK 67 /* Link has been severed */ +#define LUSTRE_EADV 68 /* Advertise error */ +#define LUSTRE_ESRMNT 69 /* Srmount error */ +#define LUSTRE_ECOMM 70 /* Communication error on send */ +#define LUSTRE_EPROTO 71 /* Protocol error */ +#define LUSTRE_EMULTIHOP 72 /* Multihop attempted */ +#define LUSTRE_EDOTDOT 73 /* RFS specific error */ +#define LUSTRE_EBADMSG 74 /* Not a data message */ +#define LUSTRE_EOVERFLOW 75 /* Value too large for defined data + type */ +#define LUSTRE_ENOTUNIQ 76 /* Name not unique on network */ +#define LUSTRE_EBADFD 77 /* File descriptor in bad state */ +#define LUSTRE_EREMCHG 78 /* Remote address changed */ +#define LUSTRE_ELIBACC 79 /* Can not access a needed shared + library */ +#define LUSTRE_ELIBBAD 80 /* Accessing a corrupted shared + library */ +#define LUSTRE_ELIBSCN 81 /* .lib section in a.out corrupted */ +#define LUSTRE_ELIBMAX 82 /* Attempting to link in too many shared + libraries */ +#define LUSTRE_ELIBEXEC 83 /* Cannot exec a shared library + directly */ +#define LUSTRE_EILSEQ 84 /* Illegal byte sequence */ +#define LUSTRE_ERESTART 85 /* Interrupted system call should be + restarted */ +#define LUSTRE_ESTRPIPE 86 /* Streams pipe error */ +#define LUSTRE_EUSERS 87 /* Too many users */ +#define LUSTRE_ENOTSOCK 88 /* Socket operation on non-socket */ +#define LUSTRE_EDESTADDRREQ 89 /* Destination address required */ +#define LUSTRE_EMSGSIZE 90 /* Message too long */ +#define LUSTRE_EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define LUSTRE_ENOPROTOOPT 92 /* Protocol not available */ +#define LUSTRE_EPROTONOSUPPORT 93 /* Protocol not supported */ +#define LUSTRE_ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define LUSTRE_EOPNOTSUPP 95 /* Operation not supported on transport + endpoint */ +#define LUSTRE_EPFNOSUPPORT 96 /* Protocol family not supported */ +#define LUSTRE_EAFNOSUPPORT 97 /* Address family not supported by + protocol */ +#define LUSTRE_EADDRINUSE 98 /* Address already in use */ +#define LUSTRE_EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define LUSTRE_ENETDOWN 100 /* Network is down */ +#define LUSTRE_ENETUNREACH 101 /* Network is unreachable */ +#define LUSTRE_ENETRESET 102 /* Network dropped connection because of + reset */ +#define LUSTRE_ECONNABORTED 103 /* Software caused connection abort */ +#define LUSTRE_ECONNRESET 104 /* Connection reset by peer */ +#define LUSTRE_ENOBUFS 105 /* No buffer space available */ +#define LUSTRE_EISCONN 106 /* Transport endpoint is already + connected */ +#define LUSTRE_ENOTCONN 107 /* Transport endpoint is not + connected */ +#define LUSTRE_ESHUTDOWN 108 /* Cannot send after transport endpoint + shutdown */ +#define LUSTRE_ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define LUSTRE_ETIMEDOUT 110 /* Connection timed out */ +#define LUSTRE_ECONNREFUSED 111 /* Connection refused */ +#define LUSTRE_EHOSTDOWN 112 /* Host is down */ +#define LUSTRE_EHOSTUNREACH 113 /* No route to host */ +#define LUSTRE_EALREADY 114 /* Operation already in progress */ +#define LUSTRE_EINPROGRESS 115 /* Operation now in progress */ +#define LUSTRE_ESTALE 116 /* Stale NFS file handle */ +#define LUSTRE_EUCLEAN 117 /* Structure needs cleaning */ +#define LUSTRE_ENOTNAM 118 /* Not a XENIX named type file */ +#define LUSTRE_ENAVAIL 119 /* No XENIX semaphores available */ +#define LUSTRE_EISNAM 120 /* Is a named type file */ +#define LUSTRE_EREMOTEIO 121 /* Remote I/O error */ +#define LUSTRE_EDQUOT 122 /* Quota exceeded */ +#define LUSTRE_ENOMEDIUM 123 /* No medium found */ +#define LUSTRE_EMEDIUMTYPE 124 /* Wrong medium type */ +#define LUSTRE_ECANCELED 125 /* Operation Canceled */ +#define LUSTRE_ENOKEY 126 /* Required key not available */ +#define LUSTRE_EKEYEXPIRED 127 /* Key has expired */ +#define LUSTRE_EKEYREVOKED 128 /* Key has been revoked */ +#define LUSTRE_EKEYREJECTED 129 /* Key was rejected by service */ +#define LUSTRE_EOWNERDEAD 130 /* Owner died */ +#define LUSTRE_ENOTRECOVERABLE 131 /* State not recoverable */ +#define LUSTRE_ERESTARTSYS 512 +#define LUSTRE_ERESTARTNOINTR 513 +#define LUSTRE_ERESTARTNOHAND 514 /* restart if no handler.. */ +#define LUSTRE_ENOIOCTLCMD 515 /* No ioctl command */ +#define LUSTRE_ERESTART_RESTARTBLOCK 516 /* restart by calling + sys_restart_syscall */ +#define LUSTRE_EBADHANDLE 521 /* Illegal NFS file handle */ +#define LUSTRE_ENOTSYNC 522 /* Update synchronization mismatch */ +#define LUSTRE_EBADCOOKIE 523 /* Cookie is stale */ +#define LUSTRE_ENOTSUPP 524 /* Operation is not supported */ +#define LUSTRE_ETOOSMALL 525 /* Buffer or request is too small */ +#define LUSTRE_ESERVERFAULT 526 /* An untranslatable error occurred */ +#define LUSTRE_EBADTYPE 527 /* Type not supported by server */ +#define LUSTRE_EJUKEBOX 528 /* Request initiated, but will not + complete before timeout */ +#define LUSTRE_EIOCBQUEUED 529 /* iocb queued, will get completion + event */ +#define LUSTRE_EIOCBRETRY 530 /* iocb queued, will trigger a retry */ + +/* + * Translations are optimized away on x86. Host errnos that shouldn't be put + * on wire could leak through as a result. Do not count on this side effect. + */ +#ifdef CONFIG_LUSTRE_TRANSLATE_ERRNOS +unsigned int lustre_errno_hton(unsigned int h); +unsigned int lustre_errno_ntoh(unsigned int n); +#else +#define lustre_errno_hton(h) (h) +#define lustre_errno_ntoh(n) (n) +#endif + +#endif /* LUSTRE_ERRNO_H */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 8825460f12a..984235ccd3a 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -98,6 +98,8 @@ /* Defn's shared with user-space. */ #include <lustre/lustre_user.h> +#include <lustre/lustre_errno.h> + /* * GENERAL STUFF */ @@ -911,7 +913,7 @@ static inline int lu_fid_cmp(const struct lu_fid *f0, __diff_normalize(fid_ver(f0), fid_ver(f1)); } -static inline void ostid_cpu_to_le(struct ost_id *src_oi, +static inline void ostid_cpu_to_le(const struct ost_id *src_oi, struct ost_id *dst_oi) { if (fid_seq_is_mdt0(ostid_seq(src_oi))) { @@ -922,7 +924,7 @@ static inline void ostid_cpu_to_le(struct ost_id *src_oi, } } -static inline void ostid_le_to_cpu(struct ost_id *src_oi, +static inline void ostid_le_to_cpu(const struct ost_id *src_oi, struct ost_id *dst_oi) { if (fid_seq_is_mdt0(ostid_seq(src_oi))) { @@ -1544,10 +1546,16 @@ enum obdo_flags { #define LOV_MAGIC_V1_DEF 0x0CD10BD0 #define LOV_MAGIC_V3_DEF 0x0CD30BD0 -#define LOV_PATTERN_RAID0 0x001 /* stripes are used round-robin */ -#define LOV_PATTERN_RAID1 0x002 /* stripes are mirrors of each other */ -#define LOV_PATTERN_FIRST 0x100 /* first stripe is not in round-robin */ -#define LOV_PATTERN_CMOBD 0x200 +#define LOV_PATTERN_RAID0 0x001 /* stripes are used round-robin */ +#define LOV_PATTERN_RAID1 0x002 /* stripes are mirrors of each other */ +#define LOV_PATTERN_FIRST 0x100 /* first stripe is not in round-robin */ +#define LOV_PATTERN_CMOBD 0x200 + +#define LOV_PATTERN_F_MASK 0xffff0000 +#define LOV_PATTERN_F_RELEASED 0x80000000 /* HSM released file */ + +#define lov_pattern(pattern) (pattern & ~LOV_PATTERN_F_MASK) +#define lov_pattern_flags(pattern) (pattern & LOV_PATTERN_F_MASK) #define lov_ost_data lov_ost_data_v1 struct lov_ost_data_v1 { /* per-stripe data structure (little-endian)*/ @@ -1662,6 +1670,17 @@ struct lov_mds_md_v3 { /* LOV EA mds/wire data (little-endian) */ struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */ }; +static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic) +{ + if (lmm_magic == LOV_MAGIC_V3) + return sizeof(struct lov_mds_md_v3) + + stripes * sizeof(struct lov_ost_data_v1); + else + return sizeof(struct lov_mds_md_v1) + + stripes * sizeof(struct lov_ost_data_v1); +} + + #define OBD_MD_FLID (0x00000001ULL) /* object ID */ #define OBD_MD_FLATIME (0x00000002ULL) /* access time */ #define OBD_MD_FLMTIME (0x00000004ULL) /* data modification time */ @@ -2671,6 +2690,10 @@ struct ldlm_res_id { __u64 name[RES_NAME_SIZE]; }; +#define DLDLMRES "["LPX64":"LPX64":"LPX64"]."LPX64i +#define PLDLMRES(res) (res)->lr_name.name[0], (res)->lr_name.name[1], \ + (res)->lr_name.name[2], (res)->lr_name.name[3] + extern void lustre_swab_ldlm_res_id (struct ldlm_res_id *id); static inline int ldlm_res_eq(const struct ldlm_res_id *res0, @@ -2963,6 +2986,7 @@ typedef enum { /* LLOG_JOIN_REC = LLOG_OP_MAGIC | 0x50000, obsolete 1.8.0 */ CHANGELOG_REC = LLOG_OP_MAGIC | 0x60000, CHANGELOG_USER_REC = LLOG_OP_MAGIC | 0x70000, + HSM_AGENT_REC = LLOG_OP_MAGIC | 0x80000, LLOG_HDR_MAGIC = LLOG_OP_MAGIC | 0x45539, LLOG_LOGID_MAGIC = LLOG_OP_MAGIC | 0x4553b, } llog_op_type; @@ -3082,6 +3106,52 @@ struct llog_changelog_user_rec { struct llog_rec_tail cur_tail; } __attribute__((packed)); +enum agent_req_status { + ARS_WAITING, + ARS_STARTED, + ARS_FAILED, + ARS_CANCELED, + ARS_SUCCEED, +}; + +static inline char *agent_req_status2name(enum agent_req_status ars) +{ + switch (ars) { + case ARS_WAITING: + return "WAITING"; + case ARS_STARTED: + return "STARTED"; + case ARS_FAILED: + return "FAILED"; + case ARS_CANCELED: + return "CANCELED"; + case ARS_SUCCEED: + return "SUCCEED"; + default: + return "UNKNOWN"; + } +} + +static inline bool agent_req_in_final_state(enum agent_req_status ars) +{ + return ((ars == ARS_SUCCEED) || (ars == ARS_FAILED) || + (ars == ARS_CANCELED)); +} + +struct llog_agent_req_rec { + struct llog_rec_hdr arr_hdr; /**< record header */ + __u32 arr_status; /**< status of the request */ + /* must match enum + * agent_req_status */ + __u32 arr_archive_id; /**< backend archive number */ + __u64 arr_flags; /**< req flags */ + __u64 arr_compound_id; /**< compound cookie */ + __u64 arr_req_create; /**< req. creation time */ + __u64 arr_req_change; /**< req. status change time */ + struct hsm_action_item arr_hai; /**< req. to the agent */ + struct llog_rec_tail arr_tail; /**< record tail for_sizezof_only */ +} __attribute__((packed)); + /* Old llog gen for compatibility */ struct llog_gen { __u64 mnt_cnt; diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 7e9f57507f0..c7bd4473a1d 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -347,6 +347,16 @@ struct lov_user_md_v3 { /* LOV EA user data (host-endian) */ struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */ } __attribute__((packed)); +static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic) +{ + if (lmm_magic == LOV_USER_MAGIC_V3) + return sizeof(struct lov_user_md_v3) + + stripes * sizeof(struct lov_user_ost_data_v1); + else + return sizeof(struct lov_user_md_v1) + + stripes * sizeof(struct lov_user_ost_data_v1); +} + /* Compile with -D_LARGEFILE64_SOURCE or -D_GNU_SOURCE (or #define) to * use this. It is unsafe to #define those values in this header as it * is possible the application has already #included <sys/stat.h>. */ @@ -462,6 +472,8 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) /* printf display format 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 "["DFID_NOBRACE"]" #define PFID(fid) \ diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index f12429f3821..e14a5f674e8 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -211,13 +211,12 @@ static inline int lustre_cfg_len(__u32 bufcount, __u32 *buflens) { int i; int len; - ENTRY; len = LCFG_HDR_SIZE(bufcount); for (i = 0; i < bufcount; i++) len += cfs_size_round(buflens[i]); - RETURN(cfs_size_round(len)); + return cfs_size_round(len); } @@ -230,12 +229,10 @@ static inline struct lustre_cfg *lustre_cfg_new(int cmd, char *ptr; int i; - ENTRY; - OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); if (!lcfg) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); lcfg->lcfg_version = LUSTRE_CFG_VERSION; lcfg->lcfg_command = cmd; @@ -246,7 +243,7 @@ static inline struct lustre_cfg *lustre_cfg_new(int cmd, lcfg->lcfg_buflens[i] = bufs->lcfg_buflen[i]; LOGL((char *)bufs->lcfg_buf[i], bufs->lcfg_buflen[i], ptr); } - RETURN(lcfg); + return lcfg; } static inline void lustre_cfg_free(struct lustre_cfg *lcfg) @@ -256,44 +253,39 @@ static inline void lustre_cfg_free(struct lustre_cfg *lcfg) len = lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens); OBD_FREE(lcfg, len); - EXIT; return; } static inline int lustre_cfg_sanity_check(void *buf, int len) { struct lustre_cfg *lcfg = (struct lustre_cfg *)buf; - ENTRY; + if (!lcfg) - RETURN(-EINVAL); + return -EINVAL; /* check that the first bits of the struct are valid */ if (len < LCFG_HDR_SIZE(0)) - RETURN(-EINVAL); + return -EINVAL; if (lcfg->lcfg_version != LUSTRE_CFG_VERSION) - RETURN(-EINVAL); + return -EINVAL; if (lcfg->lcfg_bufcount >= LUSTRE_CFG_MAX_BUFCOUNT) - RETURN(-EINVAL); + return -EINVAL; /* check that the buflens are valid */ if (len < LCFG_HDR_SIZE(lcfg->lcfg_bufcount)) - RETURN(-EINVAL); + return -EINVAL; /* make sure all the pointers point inside the data */ if (len < lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)) - RETURN(-EINVAL); + return -EINVAL; - RETURN(0); + return 0; } #include <lustre/lustre_user.h> -#ifndef INVALID_UID -#define INVALID_UID (-1) -#endif - /** @} cfg */ #endif // _LUSTRE_CFG_H diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index 8db6086ea4e..9228b165b25 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -53,20 +53,21 @@ /****************** on-disk files *********************/ -#define MDT_LOGS_DIR "LOGS" /* COMPAT_146 */ -#define MOUNT_CONFIGS_DIR "CONFIGS" -#define CONFIGS_FILE "mountdata" +#define MDT_LOGS_DIR "LOGS" /* COMPAT_146 */ +#define MOUNT_CONFIGS_DIR "CONFIGS" +#define CONFIGS_FILE "mountdata" /** Persistent mount data are stored on the disk in this file. */ -#define MOUNT_DATA_FILE MOUNT_CONFIGS_DIR"/"CONFIGS_FILE -#define LAST_RCVD "last_rcvd" -#define LOV_OBJID "lov_objid" +#define MOUNT_DATA_FILE MOUNT_CONFIGS_DIR"/"CONFIGS_FILE +#define LAST_RCVD "last_rcvd" +#define LOV_OBJID "lov_objid" #define LOV_OBJSEQ "lov_objseq" -#define HEALTH_CHECK "health_check" -#define CAPA_KEYS "capa_keys" -#define CHANGELOG_USERS "changelog_users" -#define MGS_NIDTBL_DIR "NIDTBL_VERSIONS" -#define QMT_DIR "quota_master" -#define QSD_DIR "quota_slave" +#define HEALTH_CHECK "health_check" +#define CAPA_KEYS "capa_keys" +#define CHANGELOG_USERS "changelog_users" +#define MGS_NIDTBL_DIR "NIDTBL_VERSIONS" +#define QMT_DIR "quota_master" +#define QSD_DIR "quota_slave" +#define HSM_ACTIONS "hsm_actions" /****************** persistent mount data *********************/ @@ -226,21 +227,22 @@ struct lustre_mount_data { char *lmd_osd_type; /* OSD type */ }; -#define LMD_FLG_SERVER 0x0001 /* Mounting a server */ -#define LMD_FLG_CLIENT 0x0002 /* Mounting a client */ -#define LMD_FLG_ABORT_RECOV 0x0008 /* Abort recovery */ -#define LMD_FLG_NOSVC 0x0010 /* Only start MGS/MGC for servers, - no other services */ -#define LMD_FLG_NOMGS 0x0020 /* Only start target for servers, reusing - existing MGS services */ -#define LMD_FLG_WRITECONF 0x0040 /* Rewrite config log */ -#define LMD_FLG_NOIR 0x0080 /* NO imperative recovery */ -#define LMD_FLG_NOSCRUB 0x0100 /* Do not trigger scrub automatically */ -#define LMD_FLG_MGS 0x0200 /* Also start MGS along with server */ -#define LMD_FLG_IAM 0x0400 /* IAM dir */ -#define LMD_FLG_NO_PRIMNODE 0x0800 /* all nodes are service nodes */ -#define LMD_FLG_VIRGIN 0x1000 /* the service registers first time */ -#define LMD_FLG_UPDATE 0x2000 /* update parameters */ +#define LMD_FLG_SERVER 0x0001 /* Mounting a server */ +#define LMD_FLG_CLIENT 0x0002 /* Mounting a client */ +#define LMD_FLG_ABORT_RECOV 0x0008 /* Abort recovery */ +#define LMD_FLG_NOSVC 0x0010 /* Only start MGS/MGC for servers, + no other services */ +#define LMD_FLG_NOMGS 0x0020 /* Only start target for servers, reusing + existing MGS services */ +#define LMD_FLG_WRITECONF 0x0040 /* Rewrite config log */ +#define LMD_FLG_NOIR 0x0080 /* NO imperative recovery */ +#define LMD_FLG_NOSCRUB 0x0100 /* Do not trigger scrub automatically */ +#define LMD_FLG_MGS 0x0200 /* Also start MGS along with server */ +#define LMD_FLG_IAM 0x0400 /* IAM dir */ +#define LMD_FLG_NO_PRIMNODE 0x0800 /* all nodes are service nodes */ +#define LMD_FLG_VIRGIN 0x1000 /* the service registers first time */ +#define LMD_FLG_UPDATE 0x2000 /* update parameters */ +#define LMD_FLG_HSM 0x4000 /* Start coordinator */ #define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 317f928fc15..7020d9cd9eb 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -57,6 +57,8 @@ #include <interval_tree.h> /* for interval_node{}, ldlm_extent */ #include <lu_ref.h> +#include "lustre_dlm_flags.h" + struct obd_ops; struct obd_device; @@ -96,161 +98,6 @@ typedef enum { } ldlm_side_t; /** - * Declaration of flags sent through the wire. - **/ -#define LDLM_FL_LOCK_CHANGED 0x000001 /* extent, mode, or resource changed */ - -/** - * If the server returns one of these flags, then the lock was put on that list. - * If the client sends one of these flags (during recovery ONLY!), it wants the - * lock added to the specified list, no questions asked. - */ -#define LDLM_FL_BLOCK_GRANTED 0x000002 -#define LDLM_FL_BLOCK_CONV 0x000004 -#define LDLM_FL_BLOCK_WAIT 0x000008 - -/* Used to be LDLM_FL_CBPENDING 0x000010 moved to non-wire flags */ - -#define LDLM_FL_AST_SENT 0x000020 /* blocking or cancel packet was - * queued for sending. */ -/* Used to be LDLM_FL_WAIT_NOREPROC 0x000040 moved to non-wire flags */ -/* Used to be LDLM_FL_CANCEL 0x000080 moved to non-wire flags */ - -/** - * Lock is being replayed. This could probably be implied by the fact that one - * of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. - */ -#define LDLM_FL_REPLAY 0x000100 - -#define LDLM_FL_INTENT_ONLY 0x000200 /* Don't grant lock, just do intent. */ - -/* Used to be LDLM_FL_LOCAL_ONLY 0x000400 moved to non-wire flags */ -/* Used to be LDLM_FL_FAILED 0x000800 moved to non-wire flags */ - -#define LDLM_FL_HAS_INTENT 0x001000 /* lock request has intent */ - -/* Used to be LDLM_FL_CANCELING 0x002000 moved to non-wire flags */ -/* Used to be LDLM_FL_LOCAL 0x004000 moved to non-wire flags */ - -#define LDLM_FL_DISCARD_DATA 0x010000 /* discard (no writeback) on cancel */ - -#define LDLM_FL_NO_TIMEOUT 0x020000 /* Blocked by group lock - wait - * indefinitely */ - -/** file & record locking */ -#define LDLM_FL_BLOCK_NOWAIT 0x040000 /* Server told not to wait if blocked. - * For AGL, OST will not send glimpse - * callback. */ -#define LDLM_FL_TEST_LOCK 0x080000 // return blocking lock - -/* Used to be LDLM_FL_LVB_READY 0x100000 moved to non-wire flags */ -/* Used to be LDLM_FL_KMS_IGNORE 0x200000 moved to non-wire flags */ -/* Used to be LDLM_FL_NO_LRU 0x400000 moved to non-wire flags */ - -/* Immediatelly cancel such locks when they block some other locks. Send - * cancel notification to original lock holder, but expect no reply. This is - * for clients (like liblustre) that cannot be expected to reliably response - * to blocking AST. */ -#define LDLM_FL_CANCEL_ON_BLOCK 0x800000 - -/* Flags flags inherited from parent lock when doing intents. */ -#define LDLM_INHERIT_FLAGS (LDLM_FL_CANCEL_ON_BLOCK) - -/* Used to be LDLM_FL_CP_REQD 0x1000000 moved to non-wire flags */ -/* Used to be LDLM_FL_CLEANED 0x2000000 moved to non-wire flags */ -/* Used to be LDLM_FL_ATOMIC_CB 0x4000000 moved to non-wire flags */ -/* Used to be LDLM_FL_BL_AST 0x10000000 moved to non-wire flags */ -/* Used to be LDLM_FL_BL_DONE 0x20000000 moved to non-wire flags */ - -/* measure lock contention and return -EUSERS if locking contention is high */ -#define LDLM_FL_DENY_ON_CONTENTION 0x40000000 - -/* These are flags that are mapped into the flags and ASTs of blocking locks */ -#define LDLM_AST_DISCARD_DATA 0x80000000 /* Add FL_DISCARD to blocking ASTs */ - -/* Flags sent in AST lock_flags to be mapped into the receiving lock. */ -#define LDLM_AST_FLAGS (LDLM_FL_DISCARD_DATA) - -/* - * -------------------------------------------------------------------------- - * NOTE! Starting from this point, that is, LDLM_FL_* flags with values above - * 0x80000000 will not be sent over the wire. - * -------------------------------------------------------------------------- - */ - -/** - * Declaration of flags not sent through the wire. - **/ - -/** - * Used for marking lock as a target for -EINTR while cp_ast sleep - * emulation + race with upcoming bl_ast. - */ -#define LDLM_FL_FAIL_LOC 0x100000000ULL - -/** - * Used while processing the unused list to know that we have already - * handled this lock and decided to skip it. - */ -#define LDLM_FL_SKIPPED 0x200000000ULL -/* this lock is being destroyed */ -#define LDLM_FL_CBPENDING 0x400000000ULL -/* not a real flag, not saved in lock */ -#define LDLM_FL_WAIT_NOREPROC 0x800000000ULL -/* cancellation callback already run */ -#define LDLM_FL_CANCEL 0x1000000000ULL -#define LDLM_FL_LOCAL_ONLY 0x2000000000ULL -/* don't run the cancel callback under ldlm_cli_cancel_unused */ -#define LDLM_FL_FAILED 0x4000000000ULL -/* lock cancel has already been sent */ -#define LDLM_FL_CANCELING 0x8000000000ULL -/* local lock (ie, no srv/cli split) */ -#define LDLM_FL_LOCAL 0x10000000000ULL -/* XXX FIXME: This is being added to b_size as a low-risk fix to the fact that - * the LVB filling happens _after_ the lock has been granted, so another thread - * can match it before the LVB has been updated. As a dirty hack, we set - * LDLM_FL_LVB_READY only after we've done the LVB poop. - * this is only needed on LOV/OSC now, where LVB is actually used and callers - * must set it in input flags. - * - * The proper fix is to do the granting inside of the completion AST, which can - * be replaced with a LVB-aware wrapping function for OSC locks. That change is - * pretty high-risk, though, and would need a lot more testing. */ -#define LDLM_FL_LVB_READY 0x20000000000ULL -/* A lock contributes to the known minimum size (KMS) calculation until it has - * finished the part of its cancelation that performs write back on its dirty - * pages. It can remain on the granted list during this whole time. Threads - * racing to update the KMS after performing their writeback need to know to - * exclude each other's locks from the calculation as they walk the granted - * list. */ -#define LDLM_FL_KMS_IGNORE 0x40000000000ULL -/* completion AST to be executed */ -#define LDLM_FL_CP_REQD 0x80000000000ULL -/* cleanup_resource has already handled the lock */ -#define LDLM_FL_CLEANED 0x100000000000ULL -/* optimization hint: LDLM can run blocking callback from current context - * w/o involving separate thread. in order to decrease cs rate */ -#define LDLM_FL_ATOMIC_CB 0x200000000000ULL - -/* It may happen that a client initiates two operations, e.g. unlink and - * mkdir, such that the server sends a blocking AST for conflicting - * locks to this client for the first operation, whereas the second - * operation has canceled this lock and is waiting for rpc_lock which is - * taken by the first operation. LDLM_FL_BL_AST is set by - * ldlm_callback_handler() in the lock to prevent the Early Lock Cancel - * (ELC) code from cancelling it. - * - * LDLM_FL_BL_DONE is to be set by ldlm_cancel_callback() when lock - * cache is dropped to let ldlm_callback_handler() return EINVAL to the - * server. It is used when ELC RPC is already prepared and is waiting - * for rpc_lock, too late to send a separate CANCEL RPC. */ -#define LDLM_FL_BL_AST 0x400000000000ULL -#define LDLM_FL_BL_DONE 0x800000000000ULL -/* Don't put lock into the LRU list, so that it is not canceled due to aging. - * Used by MGC locks, they are cancelled only at unmount or by callback. */ -#define LDLM_FL_NO_LRU 0x1000000000000ULL - -/** * The blocking callback is overloaded to perform two functions. These flags * indicate which operation should be performed. */ @@ -388,7 +235,7 @@ struct ldlm_pool_ops { */ struct ldlm_pool { /** Pool proc directory. */ - proc_dir_entry_t *pl_proc_dir; + struct proc_dir_entry *pl_proc_dir; /** Pool name, must be long enough to hold compound proc entry name. */ char pl_name[100]; /** Lock for protecting SLV/CLV updates. */ @@ -720,8 +567,6 @@ typedef int (*ldlm_completion_callback)(struct ldlm_lock *lock, __u64 flags, void *data); /** Type for glimpse callback function of a lock. */ typedef int (*ldlm_glimpse_callback)(struct ldlm_lock *lock, void *data); -/** Type for weight callback function of a lock. */ -typedef unsigned long (*ldlm_weigh_callback)(struct ldlm_lock *lock); /** Work list for sending GL ASTs to multiple locks. */ struct ldlm_glimpse_work { @@ -890,9 +735,6 @@ struct ldlm_lock { */ ldlm_glimpse_callback l_glimpse_ast; - /** XXX apparently unused "weight" handler. To be removed? */ - ldlm_weigh_callback l_weigh_ast; - /** * Lock export. * This is a pointer to actual client export for locks that were granted @@ -919,11 +761,11 @@ struct ldlm_lock { ldlm_policy_data_t l_policy_data; /** - * Lock state flags. - * Like whenever we receive any blocking requests for this lock, etc. - * Protected by lr_lock. + * Lock state flags. Protected by lr_lock. + * \see lustre_dlm_flags.h where the bits are defined. */ __u64 l_flags; + /** * Lock r/w usage counters. * Protected by lr_lock. @@ -952,34 +794,6 @@ struct ldlm_lock { /** Originally requested extent for the extent lock. */ struct ldlm_extent l_req_extent; - unsigned int l_failed:1, - /** - * Set for locks that were removed from class hash table and will be - * destroyed when last reference to them is released. Set by - * ldlm_lock_destroy_internal(). - * - * Protected by lock and resource locks. - */ - l_destroyed:1, - /* - * it's set in lock_res_and_lock() and unset in unlock_res_and_lock(). - * - * NB: compared with check_res_locked(), checking this bit is cheaper. - * Also, spin_is_locked() is deprecated for kernel code; one reason is - * because it works only for SMP so user needs to add extra macros like - * LASSERT_SPIN_LOCKED for uniprocessor kernels. - */ - l_res_locked:1, - /* - * It's set once we call ldlm_add_waiting_lock_res_locked() - * to start the lock-timeout timer and it will never be reset. - * - * Protected by lock_res_and_lock(). - */ - l_waited:1, - /** Flag whether this is a server namespace lock. */ - l_ns_srv:1; - /* * Client-side-only members. */ @@ -1230,7 +1044,6 @@ struct ldlm_enqueue_info { void *ei_cb_bl; /** blocking lock callback */ void *ei_cb_cp; /** lock completion callback */ void *ei_cb_gl; /** lock glimpse callback */ - void *ei_cb_wg; /** lock weigh callback */ void *ei_cbdata; /** Data to be passed into callbacks. */ }; @@ -1328,7 +1141,6 @@ struct ldlm_callback_suite { ldlm_completion_callback lcs_completion; ldlm_blocking_callback lcs_blocking; ldlm_glimpse_callback lcs_glimpse; - ldlm_weigh_callback lcs_weigh; }; /* ldlm_lockd.c */ @@ -1471,8 +1283,6 @@ void ldlm_namespace_free(struct ldlm_namespace *ns, struct obd_import *imp, int force); 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_move_locked(struct ldlm_namespace *ns, ldlm_side_t client); -struct ldlm_namespace *ldlm_namespace_first_locked(ldlm_side_t client); void ldlm_namespace_get(struct ldlm_namespace *ns); void ldlm_namespace_put(struct ldlm_namespace *ns); int ldlm_proc_setup(void); @@ -1645,7 +1455,7 @@ void unlock_res_and_lock(struct ldlm_lock *lock); * There are not used outside of ldlm. * @{ */ -void ldlm_pools_recalc(ldlm_side_t client); +int ldlm_pools_recalc(ldlm_side_t client); int ldlm_pools_init(void); void ldlm_pools_fini(void); diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h new file mode 100644 index 00000000000..8c34d9d4d25 --- /dev/null +++ b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h @@ -0,0 +1,460 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (lustre_dlm_flags.h) + * + * It has been AutoGen-ed + * From the definitions lustre_dlm_flags.def + * and the template file lustre_dlm_flags.tpl + * + * lustre is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * lustre 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ +/** + * \file lustre_dlm_flags.h + * The flags and collections of flags (masks) for \see struct ldlm_lock. + * This file is derived from flag definitions in lustre_dlm_flags.def. + * The format is defined in the lustre_dlm_flags.tpl template file. + * + * \addtogroup LDLM Lustre Distributed Lock Manager + * @{ + * + * \name flags + * The flags and collections of flags (masks) for \see struct ldlm_lock. + * @{ + */ +#ifndef LDLM_ALL_FLAGS_MASK + +/** l_flags bits marked as "all_flags" bits */ +#define LDLM_FL_ALL_FLAGS_MASK 0x007FFFFFC08F132FULL + +/** l_flags bits marked as "ast" bits */ +#define LDLM_FL_AST_MASK 0x0000000080000000ULL + +/** l_flags bits marked as "blocked" bits */ +#define LDLM_FL_BLOCKED_MASK 0x000000000000000EULL + +/** l_flags bits marked as "gone" bits */ +#define LDLM_FL_GONE_MASK 0x0006004000000000ULL + +/** l_flags bits marked as "hide_lock" bits */ +#define LDLM_FL_HIDE_LOCK_MASK 0x0000206400000000ULL + +/** l_flags bits marked as "inherit" bits */ +#define LDLM_FL_INHERIT_MASK 0x0000000000800000ULL + +/** l_flags bits marked as "local_only" bits */ +#define LDLM_FL_LOCAL_ONLY_MASK 0x007FFFFF00000000ULL + +/** l_flags bits marked as "on_wire" bits */ +#define LDLM_FL_ON_WIRE_MASK 0x00000000C08F132FULL + +/** extent, mode, or resource changed */ +#define LDLM_FL_LOCK_CHANGED 0x0000000000000001ULL // bit 0 +#define ldlm_is_lock_changed(_l) LDLM_TEST_FLAG(( _l), 1ULL << 0) +#define ldlm_set_lock_changed(_l) LDLM_SET_FLAG(( _l), 1ULL << 0) +#define ldlm_clear_lock_changed(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 0) + +/** + * Server placed lock on granted list, or a recovering client wants the + * lock added to the granted list, no questions asked. */ +#define LDLM_FL_BLOCK_GRANTED 0x0000000000000002ULL // bit 1 +#define ldlm_is_block_granted(_l) LDLM_TEST_FLAG(( _l), 1ULL << 1) +#define ldlm_set_block_granted(_l) LDLM_SET_FLAG(( _l), 1ULL << 1) +#define ldlm_clear_block_granted(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 1) + +/** + * Server placed lock on conv list, or a recovering client wants the lock + * added to the conv list, no questions asked. */ +#define LDLM_FL_BLOCK_CONV 0x0000000000000004ULL // bit 2 +#define ldlm_is_block_conv(_l) LDLM_TEST_FLAG(( _l), 1ULL << 2) +#define ldlm_set_block_conv(_l) LDLM_SET_FLAG(( _l), 1ULL << 2) +#define ldlm_clear_block_conv(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 2) + +/** + * Server placed lock on wait list, or a recovering client wants the lock + * added to the wait list, no questions asked. */ +#define LDLM_FL_BLOCK_WAIT 0x0000000000000008ULL // bit 3 +#define ldlm_is_block_wait(_l) LDLM_TEST_FLAG(( _l), 1ULL << 3) +#define ldlm_set_block_wait(_l) LDLM_SET_FLAG(( _l), 1ULL << 3) +#define ldlm_clear_block_wait(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 3) + +/** blocking or cancel packet was queued for sending. */ +#define LDLM_FL_AST_SENT 0x0000000000000020ULL // bit 5 +#define ldlm_is_ast_sent(_l) LDLM_TEST_FLAG(( _l), 1ULL << 5) +#define ldlm_set_ast_sent(_l) LDLM_SET_FLAG(( _l), 1ULL << 5) +#define ldlm_clear_ast_sent(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 5) + +/** + * Lock is being replayed. This could probably be implied by the fact that + * one of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. */ +#define LDLM_FL_REPLAY 0x0000000000000100ULL // bit 8 +#define ldlm_is_replay(_l) LDLM_TEST_FLAG(( _l), 1ULL << 8) +#define ldlm_set_replay(_l) LDLM_SET_FLAG(( _l), 1ULL << 8) +#define ldlm_clear_replay(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 8) + +/** Don't grant lock, just do intent. */ +#define LDLM_FL_INTENT_ONLY 0x0000000000000200ULL // bit 9 +#define ldlm_is_intent_only(_l) LDLM_TEST_FLAG(( _l), 1ULL << 9) +#define ldlm_set_intent_only(_l) LDLM_SET_FLAG(( _l), 1ULL << 9) +#define ldlm_clear_intent_only(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 9) + +/** lock request has intent */ +#define LDLM_FL_HAS_INTENT 0x0000000000001000ULL // bit 12 +#define ldlm_is_has_intent(_l) LDLM_TEST_FLAG(( _l), 1ULL << 12) +#define ldlm_set_has_intent(_l) LDLM_SET_FLAG(( _l), 1ULL << 12) +#define ldlm_clear_has_intent(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 12) + +/** discard (no writeback) on cancel */ +#define LDLM_FL_DISCARD_DATA 0x0000000000010000ULL // bit 16 +#define ldlm_is_discard_data(_l) LDLM_TEST_FLAG(( _l), 1ULL << 16) +#define ldlm_set_discard_data(_l) LDLM_SET_FLAG(( _l), 1ULL << 16) +#define ldlm_clear_discard_data(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 16) + +/** Blocked by group lock - wait indefinitely */ +#define LDLM_FL_NO_TIMEOUT 0x0000000000020000ULL // bit 17 +#define ldlm_is_no_timeout(_l) LDLM_TEST_FLAG(( _l), 1ULL << 17) +#define ldlm_set_no_timeout(_l) LDLM_SET_FLAG(( _l), 1ULL << 17) +#define ldlm_clear_no_timeout(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 17) + +/** + * Server told not to wait if blocked. For AGL, OST will not send glimpse + * callback. */ +#define LDLM_FL_BLOCK_NOWAIT 0x0000000000040000ULL // bit 18 +#define ldlm_is_block_nowait(_l) LDLM_TEST_FLAG(( _l), 1ULL << 18) +#define ldlm_set_block_nowait(_l) LDLM_SET_FLAG(( _l), 1ULL << 18) +#define ldlm_clear_block_nowait(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 18) + +/** return blocking lock */ +#define LDLM_FL_TEST_LOCK 0x0000000000080000ULL // bit 19 +#define ldlm_is_test_lock(_l) LDLM_TEST_FLAG(( _l), 1ULL << 19) +#define ldlm_set_test_lock(_l) LDLM_SET_FLAG(( _l), 1ULL << 19) +#define ldlm_clear_test_lock(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 19) + +/** + * Immediatelly cancel such locks when they block some other locks. Send + * cancel notification to original lock holder, but expect no reply. This + * is for clients (like liblustre) that cannot be expected to reliably + * response to blocking AST. */ +#define LDLM_FL_CANCEL_ON_BLOCK 0x0000000000800000ULL // bit 23 +#define ldlm_is_cancel_on_block(_l) LDLM_TEST_FLAG(( _l), 1ULL << 23) +#define ldlm_set_cancel_on_block(_l) LDLM_SET_FLAG(( _l), 1ULL << 23) +#define ldlm_clear_cancel_on_block(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 23) + +/** + * measure lock contention and return -EUSERS if locking contention is high */ +#define LDLM_FL_DENY_ON_CONTENTION 0x0000000040000000ULL // bit 30 +#define ldlm_is_deny_on_contention(_l) LDLM_TEST_FLAG(( _l), 1ULL << 30) +#define ldlm_set_deny_on_contention(_l) LDLM_SET_FLAG(( _l), 1ULL << 30) +#define ldlm_clear_deny_on_contention(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 30) + +/** + * These are flags that are mapped into the flags and ASTs of blocking + * locks Add FL_DISCARD to blocking ASTs */ +#define LDLM_FL_AST_DISCARD_DATA 0x0000000080000000ULL // bit 31 +#define ldlm_is_ast_discard_data(_l) LDLM_TEST_FLAG(( _l), 1ULL << 31) +#define ldlm_set_ast_discard_data(_l) LDLM_SET_FLAG(( _l), 1ULL << 31) +#define ldlm_clear_ast_discard_data(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 31) + +/** + * Used for marking lock as a target for -EINTR while cp_ast sleep emulation + * + race with upcoming bl_ast. */ +#define LDLM_FL_FAIL_LOC 0x0000000100000000ULL // bit 32 +#define ldlm_is_fail_loc(_l) LDLM_TEST_FLAG(( _l), 1ULL << 32) +#define ldlm_set_fail_loc(_l) LDLM_SET_FLAG(( _l), 1ULL << 32) +#define ldlm_clear_fail_loc(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 32) + +/** + * Used while processing the unused list to know that we have already + * handled this lock and decided to skip it. */ +#define LDLM_FL_SKIPPED 0x0000000200000000ULL // bit 33 +#define ldlm_is_skipped(_l) LDLM_TEST_FLAG(( _l), 1ULL << 33) +#define ldlm_set_skipped(_l) LDLM_SET_FLAG(( _l), 1ULL << 33) +#define ldlm_clear_skipped(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 33) + +/** this lock is being destroyed */ +#define LDLM_FL_CBPENDING 0x0000000400000000ULL // bit 34 +#define ldlm_is_cbpending(_l) LDLM_TEST_FLAG(( _l), 1ULL << 34) +#define ldlm_set_cbpending(_l) LDLM_SET_FLAG(( _l), 1ULL << 34) +#define ldlm_clear_cbpending(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 34) + +/** not a real flag, not saved in lock */ +#define LDLM_FL_WAIT_NOREPROC 0x0000000800000000ULL // bit 35 +#define ldlm_is_wait_noreproc(_l) LDLM_TEST_FLAG(( _l), 1ULL << 35) +#define ldlm_set_wait_noreproc(_l) LDLM_SET_FLAG(( _l), 1ULL << 35) +#define ldlm_clear_wait_noreproc(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 35) + +/** cancellation callback already run */ +#define LDLM_FL_CANCEL 0x0000001000000000ULL // bit 36 +#define ldlm_is_cancel(_l) LDLM_TEST_FLAG(( _l), 1ULL << 36) +#define ldlm_set_cancel(_l) LDLM_SET_FLAG(( _l), 1ULL << 36) +#define ldlm_clear_cancel(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 36) + +/** whatever it might mean */ +#define LDLM_FL_LOCAL_ONLY 0x0000002000000000ULL // bit 37 +#define ldlm_is_local_only(_l) LDLM_TEST_FLAG(( _l), 1ULL << 37) +#define ldlm_set_local_only(_l) LDLM_SET_FLAG(( _l), 1ULL << 37) +#define ldlm_clear_local_only(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 37) + +/** don't run the cancel callback under ldlm_cli_cancel_unused */ +#define LDLM_FL_FAILED 0x0000004000000000ULL // bit 38 +#define ldlm_is_failed(_l) LDLM_TEST_FLAG(( _l), 1ULL << 38) +#define ldlm_set_failed(_l) LDLM_SET_FLAG(( _l), 1ULL << 38) +#define ldlm_clear_failed(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 38) + +/** lock cancel has already been sent */ +#define LDLM_FL_CANCELING 0x0000008000000000ULL // bit 39 +#define ldlm_is_canceling(_l) LDLM_TEST_FLAG(( _l), 1ULL << 39) +#define ldlm_set_canceling(_l) LDLM_SET_FLAG(( _l), 1ULL << 39) +#define ldlm_clear_canceling(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 39) + +/** local lock (ie, no srv/cli split) */ +#define LDLM_FL_LOCAL 0x0000010000000000ULL // bit 40 +#define ldlm_is_local(_l) LDLM_TEST_FLAG(( _l), 1ULL << 40) +#define ldlm_set_local(_l) LDLM_SET_FLAG(( _l), 1ULL << 40) +#define ldlm_clear_local(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 40) + +/** + * XXX FIXME: This is being added to b_size as a low-risk fix to the + * fact that the LVB filling happens _after_ the lock has been granted, + * so another thread can match it before the LVB has been updated. As a + * dirty hack, we set LDLM_FL_LVB_READY only after we've done the LVB poop. + * this is only needed on LOV/OSC now, where LVB is actually used and + * callers must set it in input flags. + * + * The proper fix is to do the granting inside of the completion AST, + * which can be replaced with a LVB-aware wrapping function for OSC locks. + * That change is pretty high-risk, though, and would need a lot more + * testing. */ +#define LDLM_FL_LVB_READY 0x0000020000000000ULL // bit 41 +#define ldlm_is_lvb_ready(_l) LDLM_TEST_FLAG(( _l), 1ULL << 41) +#define ldlm_set_lvb_ready(_l) LDLM_SET_FLAG(( _l), 1ULL << 41) +#define ldlm_clear_lvb_ready(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 41) + +/** + * A lock contributes to the known minimum size (KMS) calculation until it + * has finished the part of its cancelation that performs write back on its + * dirty pages. It can remain on the granted list during this whole time. + * Threads racing to update the KMS after performing their writeback need + * to know to exclude each other's locks from the calculation as they walk + * the granted list. */ +#define LDLM_FL_KMS_IGNORE 0x0000040000000000ULL // bit 42 +#define ldlm_is_kms_ignore(_l) LDLM_TEST_FLAG(( _l), 1ULL << 42) +#define ldlm_set_kms_ignore(_l) LDLM_SET_FLAG(( _l), 1ULL << 42) +#define ldlm_clear_kms_ignore(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 42) + +/** completion AST to be executed */ +#define LDLM_FL_CP_REQD 0x0000080000000000ULL // bit 43 +#define ldlm_is_cp_reqd(_l) LDLM_TEST_FLAG(( _l), 1ULL << 43) +#define ldlm_set_cp_reqd(_l) LDLM_SET_FLAG(( _l), 1ULL << 43) +#define ldlm_clear_cp_reqd(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 43) + +/** cleanup_resource has already handled the lock */ +#define LDLM_FL_CLEANED 0x0000100000000000ULL // bit 44 +#define ldlm_is_cleaned(_l) LDLM_TEST_FLAG(( _l), 1ULL << 44) +#define ldlm_set_cleaned(_l) LDLM_SET_FLAG(( _l), 1ULL << 44) +#define ldlm_clear_cleaned(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 44) + +/** + * optimization hint: LDLM can run blocking callback from current context + * w/o involving separate thread. in order to decrease cs rate */ +#define LDLM_FL_ATOMIC_CB 0x0000200000000000ULL // bit 45 +#define ldlm_is_atomic_cb(_l) LDLM_TEST_FLAG(( _l), 1ULL << 45) +#define ldlm_set_atomic_cb(_l) LDLM_SET_FLAG(( _l), 1ULL << 45) +#define ldlm_clear_atomic_cb(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 45) + +/** + * It may happen that a client initiates two operations, e.g. unlink and + * mkdir, such that the server sends a blocking AST for conflicting locks + * to this client for the first operation, whereas the second operation + * has canceled this lock and is waiting for rpc_lock which is taken by + * the first operation. LDLM_FL_BL_AST is set by ldlm_callback_handler() in + * the lock to prevent the Early Lock Cancel (ELC) code from cancelling it. + * + * LDLM_FL_BL_DONE is to be set by ldlm_cancel_callback() when lock cache is + * dropped to let ldlm_callback_handler() return EINVAL to the server. It + * is used when ELC RPC is already prepared and is waiting for rpc_lock, + * too late to send a separate CANCEL RPC. */ +#define LDLM_FL_BL_AST 0x0000400000000000ULL // bit 46 +#define ldlm_is_bl_ast(_l) LDLM_TEST_FLAG(( _l), 1ULL << 46) +#define ldlm_set_bl_ast(_l) LDLM_SET_FLAG(( _l), 1ULL << 46) +#define ldlm_clear_bl_ast(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 46) + +/** whatever it might mean */ +#define LDLM_FL_BL_DONE 0x0000800000000000ULL // bit 47 +#define ldlm_is_bl_done(_l) LDLM_TEST_FLAG(( _l), 1ULL << 47) +#define ldlm_set_bl_done(_l) LDLM_SET_FLAG(( _l), 1ULL << 47) +#define ldlm_clear_bl_done(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 47) + +/** + * Don't put lock into the LRU list, so that it is not canceled due + * to aging. Used by MGC locks, they are cancelled only at unmount or + * by callback. */ +#define LDLM_FL_NO_LRU 0x0001000000000000ULL // bit 48 +#define ldlm_is_no_lru(_l) LDLM_TEST_FLAG(( _l), 1ULL << 48) +#define ldlm_set_no_lru(_l) LDLM_SET_FLAG(( _l), 1ULL << 48) +#define ldlm_clear_no_lru(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 48) + +/** + * Set for locks that failed and where the server has been notified. + * + * Protected by lock and resource locks. */ +#define LDLM_FL_FAIL_NOTIFIED 0x0002000000000000ULL // bit 49 +#define ldlm_is_fail_notified(_l) LDLM_TEST_FLAG(( _l), 1ULL << 49) +#define ldlm_set_fail_notified(_l) LDLM_SET_FLAG(( _l), 1ULL << 49) +#define ldlm_clear_fail_notified(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 49) + +/** + * Set for locks that were removed from class hash table and will + * be destroyed when last reference to them is released. Set by + * ldlm_lock_destroy_internal(). + * + * Protected by lock and resource locks. */ +#define LDLM_FL_DESTROYED 0x0004000000000000ULL // bit 50 +#define ldlm_is_destroyed(_l) LDLM_TEST_FLAG(( _l), 1ULL << 50) +#define ldlm_set_destroyed(_l) LDLM_SET_FLAG(( _l), 1ULL << 50) +#define ldlm_clear_destroyed(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 50) + +/** flag whether this is a server namespace lock */ +#define LDLM_FL_SERVER_LOCK 0x0008000000000000ULL // bit 51 +#define ldlm_is_server_lock(_l) LDLM_TEST_FLAG(( _l), 1ULL << 51) +#define ldlm_set_server_lock(_l) LDLM_SET_FLAG(( _l), 1ULL << 51) +#define ldlm_clear_server_lock(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 51) + +/** + * It's set in lock_res_and_lock() and unset in unlock_res_and_lock(). + * + * NB: compared with check_res_locked(), checking this bit is cheaper. + * Also, spin_is_locked() is deprecated for kernel code; one reason is + * because it works only for SMP so user needs to add extra macros like + * LASSERT_SPIN_LOCKED for uniprocessor kernels. */ +#define LDLM_FL_RES_LOCKED 0x0010000000000000ULL // bit 52 +#define ldlm_is_res_locked(_l) LDLM_TEST_FLAG(( _l), 1ULL << 52) +#define ldlm_set_res_locked(_l) LDLM_SET_FLAG(( _l), 1ULL << 52) +#define ldlm_clear_res_locked(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 52) + +/** + * It's set once we call ldlm_add_waiting_lock_res_locked() to start the + * lock-timeout timer and it will never be reset. + * + * Protected by lock and resource locks. */ +#define LDLM_FL_WAITED 0x0020000000000000ULL // bit 53 +#define ldlm_is_waited(_l) LDLM_TEST_FLAG(( _l), 1ULL << 53) +#define ldlm_set_waited(_l) LDLM_SET_FLAG(( _l), 1ULL << 53) +#define ldlm_clear_waited(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 53) + +/** Flag whether this is a server namespace lock. */ +#define LDLM_FL_NS_SRV 0x0040000000000000ULL // bit 54 +#define ldlm_is_ns_srv(_l) LDLM_TEST_FLAG(( _l), 1ULL << 54) +#define ldlm_set_ns_srv(_l) LDLM_SET_FLAG(( _l), 1ULL << 54) +#define ldlm_clear_ns_srv(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 54) + +/** test for ldlm_lock flag bit set */ +#define LDLM_TEST_FLAG(_l, _b) (((_l)->l_flags & (_b)) != 0) + +/** set a ldlm_lock flag bit */ +#define LDLM_SET_FLAG(_l, _b) (((_l)->l_flags |= (_b)) + +/** clear a ldlm_lock flag bit */ +#define LDLM_CLEAR_FLAG(_l, _b) (((_l)->l_flags &= ~(_b)) + +/** Mask of flags inherited from parent lock when doing intents. */ +#define LDLM_INHERIT_FLAGS LDLM_FL_INHERIT_MASK + +/** Mask of Flags sent in AST lock_flags to map into the receiving lock. */ +#define LDLM_AST_FLAGS LDLM_FL_AST_MASK + +/** @} subgroup */ +/** @} group */ +#ifdef WIRESHARK_COMPILE +static int hf_lustre_ldlm_fl_lock_changed = -1; +static int hf_lustre_ldlm_fl_block_granted = -1; +static int hf_lustre_ldlm_fl_block_conv = -1; +static int hf_lustre_ldlm_fl_block_wait = -1; +static int hf_lustre_ldlm_fl_ast_sent = -1; +static int hf_lustre_ldlm_fl_replay = -1; +static int hf_lustre_ldlm_fl_intent_only = -1; +static int hf_lustre_ldlm_fl_has_intent = -1; +static int hf_lustre_ldlm_fl_discard_data = -1; +static int hf_lustre_ldlm_fl_no_timeout = -1; +static int hf_lustre_ldlm_fl_block_nowait = -1; +static int hf_lustre_ldlm_fl_test_lock = -1; +static int hf_lustre_ldlm_fl_cancel_on_block = -1; +static int hf_lustre_ldlm_fl_deny_on_contention = -1; +static int hf_lustre_ldlm_fl_ast_discard_data = -1; +static int hf_lustre_ldlm_fl_fail_loc = -1; +static int hf_lustre_ldlm_fl_skipped = -1; +static int hf_lustre_ldlm_fl_cbpending = -1; +static int hf_lustre_ldlm_fl_wait_noreproc = -1; +static int hf_lustre_ldlm_fl_cancel = -1; +static int hf_lustre_ldlm_fl_local_only = -1; +static int hf_lustre_ldlm_fl_failed = -1; +static int hf_lustre_ldlm_fl_canceling = -1; +static int hf_lustre_ldlm_fl_local = -1; +static int hf_lustre_ldlm_fl_lvb_ready = -1; +static int hf_lustre_ldlm_fl_kms_ignore = -1; +static int hf_lustre_ldlm_fl_cp_reqd = -1; +static int hf_lustre_ldlm_fl_cleaned = -1; +static int hf_lustre_ldlm_fl_atomic_cb = -1; +static int hf_lustre_ldlm_fl_bl_ast = -1; +static int hf_lustre_ldlm_fl_bl_done = -1; +static int hf_lustre_ldlm_fl_no_lru = -1; +static int hf_lustre_ldlm_fl_fail_notified = -1; +static int hf_lustre_ldlm_fl_destroyed = -1; +static int hf_lustre_ldlm_fl_server_lock = -1; +static int hf_lustre_ldlm_fl_res_locked = -1; +static int hf_lustre_ldlm_fl_waited = -1; +static int hf_lustre_ldlm_fl_ns_srv = -1; + +const value_string lustre_ldlm_flags_vals[] = { + {LDLM_FL_LOCK_CHANGED, "LDLM_FL_LOCK_CHANGED"}, + {LDLM_FL_BLOCK_GRANTED, "LDLM_FL_BLOCK_GRANTED"}, + {LDLM_FL_BLOCK_CONV, "LDLM_FL_BLOCK_CONV"}, + {LDLM_FL_BLOCK_WAIT, "LDLM_FL_BLOCK_WAIT"}, + {LDLM_FL_AST_SENT, "LDLM_FL_AST_SENT"}, + {LDLM_FL_REPLAY, "LDLM_FL_REPLAY"}, + {LDLM_FL_INTENT_ONLY, "LDLM_FL_INTENT_ONLY"}, + {LDLM_FL_HAS_INTENT, "LDLM_FL_HAS_INTENT"}, + {LDLM_FL_DISCARD_DATA, "LDLM_FL_DISCARD_DATA"}, + {LDLM_FL_NO_TIMEOUT, "LDLM_FL_NO_TIMEOUT"}, + {LDLM_FL_BLOCK_NOWAIT, "LDLM_FL_BLOCK_NOWAIT"}, + {LDLM_FL_TEST_LOCK, "LDLM_FL_TEST_LOCK"}, + {LDLM_FL_CANCEL_ON_BLOCK, "LDLM_FL_CANCEL_ON_BLOCK"}, + {LDLM_FL_DENY_ON_CONTENTION, "LDLM_FL_DENY_ON_CONTENTION"}, + {LDLM_FL_AST_DISCARD_DATA, "LDLM_FL_AST_DISCARD_DATA"}, + {LDLM_FL_FAIL_LOC, "LDLM_FL_FAIL_LOC"}, + {LDLM_FL_SKIPPED, "LDLM_FL_SKIPPED"}, + {LDLM_FL_CBPENDING, "LDLM_FL_CBPENDING"}, + {LDLM_FL_WAIT_NOREPROC, "LDLM_FL_WAIT_NOREPROC"}, + {LDLM_FL_CANCEL, "LDLM_FL_CANCEL"}, + {LDLM_FL_LOCAL_ONLY, "LDLM_FL_LOCAL_ONLY"}, + {LDLM_FL_FAILED, "LDLM_FL_FAILED"}, + {LDLM_FL_CANCELING, "LDLM_FL_CANCELING"}, + {LDLM_FL_LOCAL, "LDLM_FL_LOCAL"}, + {LDLM_FL_LVB_READY, "LDLM_FL_LVB_READY"}, + {LDLM_FL_KMS_IGNORE, "LDLM_FL_KMS_IGNORE"}, + {LDLM_FL_CP_REQD, "LDLM_FL_CP_REQD"}, + {LDLM_FL_CLEANED, "LDLM_FL_CLEANED"}, + {LDLM_FL_ATOMIC_CB, "LDLM_FL_ATOMIC_CB"}, + {LDLM_FL_BL_AST, "LDLM_FL_BL_AST"}, + {LDLM_FL_BL_DONE, "LDLM_FL_BL_DONE"}, + {LDLM_FL_NO_LRU, "LDLM_FL_NO_LRU"}, + {LDLM_FL_FAIL_NOTIFIED, "LDLM_FL_FAIL_NOTIFIED"}, + {LDLM_FL_DESTROYED, "LDLM_FL_DESTROYED"}, + {LDLM_FL_SERVER_LOCK, "LDLM_FL_SERVER_LOCK"}, + {LDLM_FL_RES_LOCKED, "LDLM_FL_RES_LOCKED"}, + {LDLM_FL_WAITED, "LDLM_FL_WAITED"}, + {LDLM_FL_NS_SRV, "LDLM_FL_NS_SRV"}, + { 0, NULL } +}; +#endif /* WIRESHARK_COMPILE */ +#endif /* LDLM_ALL_FLAGS_MASK */ diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index 7d20cba0728..d9d5814e318 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -38,8 +38,8 @@ * Author: Yury Umanets <umka@clusterfs.com> */ -#ifndef __LINUX_FID_H -#define __LINUX_FID_H +#ifndef __LUSTRE_FID_H +#define __LUSTRE_FID_H /** \defgroup fid fid * @@ -154,13 +154,12 @@ #include <linux/libcfs/libcfs.h> #include <lustre/lustre_idl.h> -#include <lustre_req_layout.h> -#include <lustre_mdt.h> -#include <obd.h> - +struct lu_env; struct lu_site; struct lu_context; +struct obd_device; +struct obd_export; /* Whole sequences space range and zero range definitions */ extern const struct lu_seq_range LUSTRE_SEQ_SPACE_RANGE; @@ -320,6 +319,12 @@ static inline void lu_last_id_fid(struct lu_fid *fid, __u64 seq) fid->f_ver = 0; } +/* seq client type */ +enum lu_cli_type { + LUSTRE_SEQ_METADATA = 1, + LUSTRE_SEQ_DATA +}; + enum lu_mgr_type { LUSTRE_SEQ_SERVER, LUSTRE_SEQ_CONTROLLER @@ -341,7 +346,7 @@ struct lu_client_seq { struct lu_seq_range lcs_space; /* Seq related proc */ - proc_dir_entry_t *lcs_proc_dir; + struct proc_dir_entry *lcs_proc_dir; /* This holds last allocated fid in last obtained seq */ struct lu_fid lcs_fid; @@ -388,7 +393,7 @@ struct lu_server_seq { struct dt_object *lss_obj; /* Seq related proc */ - proc_dir_entry_t *lss_proc_dir; + struct proc_dir_entry *lss_proc_dir; /* LUSTRE_SEQ_SERVER or LUSTRE_SEQ_CONTROLLER */ enum lu_mgr_type lss_type; @@ -426,10 +431,14 @@ struct lu_server_seq { struct seq_server_site *lss_site; }; +struct com_thread_info; int seq_query(struct com_thread_info *info); + +struct ptlrpc_request; int seq_handle(struct ptlrpc_request *req); /* Server methods */ + int seq_server_init(struct lu_server_seq *seq, struct dt_device *dev, const char *prefix, @@ -472,6 +481,7 @@ int seq_site_fini(const struct lu_env *env, struct seq_server_site *ss); int fid_is_local(const struct lu_env *env, struct lu_site *site, const struct lu_fid *fid); +enum lu_cli_type; int client_fid_init(struct obd_device *obd, struct obd_export *exp, enum lu_cli_type type); int client_fid_fini(struct obd_device *obd); @@ -488,74 +498,75 @@ struct ldlm_namespace; * renaming name[2,3] fields that need to be used for the quota identifier. */ static inline struct ldlm_res_id * -fid_build_reg_res_name(const struct lu_fid *f, - struct ldlm_res_id *name) +fid_build_reg_res_name(const struct lu_fid *fid, struct ldlm_res_id *res) { - memset(name, 0, sizeof *name); - name->name[LUSTRE_RES_ID_SEQ_OFF] = fid_seq(f); - name->name[LUSTRE_RES_ID_VER_OID_OFF] = fid_ver_oid(f); - return name; + memset(res, 0, sizeof(*res)); + res->name[LUSTRE_RES_ID_SEQ_OFF] = fid_seq(fid); + res->name[LUSTRE_RES_ID_VER_OID_OFF] = fid_ver_oid(fid); + + return res; +} + +/* + * Return true if resource is for object identified by FID. + */ +static inline int fid_res_name_eq(const struct lu_fid *fid, + const struct ldlm_res_id *res) +{ + return res->name[LUSTRE_RES_ID_SEQ_OFF] == fid_seq(fid) && + res->name[LUSTRE_RES_ID_VER_OID_OFF] == fid_ver_oid(fid); +} + +/* + * Extract FID from LDLM resource. Reverse of fid_build_reg_res_name(). + */ +static inline struct lu_fid * +fid_extract_from_res_name(struct lu_fid *fid, const struct ldlm_res_id *res) +{ + fid->f_seq = res->name[LUSTRE_RES_ID_SEQ_OFF]; + fid->f_oid = (__u32)(res->name[LUSTRE_RES_ID_VER_OID_OFF]); + fid->f_ver = (__u32)(res->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32); + LASSERT(fid_res_name_eq(fid, res)); + + return fid; } /* * Build (DLM) resource identifier from global quota FID and quota ID. */ static inline struct ldlm_res_id * -fid_build_quota_resid(const struct lu_fid *glb_fid, union lquota_id *qid, +fid_build_quota_res_name(const struct lu_fid *glb_fid, union lquota_id *qid, struct ldlm_res_id *res) { fid_build_reg_res_name(glb_fid, res); res->name[LUSTRE_RES_ID_QUOTA_SEQ_OFF] = fid_seq(&qid->qid_fid); res->name[LUSTRE_RES_ID_QUOTA_VER_OID_OFF] = fid_ver_oid(&qid->qid_fid); + return res; } /* * Extract global FID and quota ID from resource name */ -static inline void fid_extract_quota_resid(struct ldlm_res_id *res, - struct lu_fid *glb_fid, - union lquota_id *qid) +static inline void fid_extract_from_quota_res(struct lu_fid *glb_fid, + union lquota_id *qid, + const struct ldlm_res_id *res) { - glb_fid->f_seq = res->name[LUSTRE_RES_ID_SEQ_OFF]; - glb_fid->f_oid = (__u32)res->name[LUSTRE_RES_ID_VER_OID_OFF]; - glb_fid->f_ver = (__u32)(res->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32); - + fid_extract_from_res_name(glb_fid, res); qid->qid_fid.f_seq = res->name[LUSTRE_RES_ID_QUOTA_SEQ_OFF]; qid->qid_fid.f_oid = (__u32)res->name[LUSTRE_RES_ID_QUOTA_VER_OID_OFF]; qid->qid_fid.f_ver = (__u32)(res->name[LUSTRE_RES_ID_QUOTA_VER_OID_OFF] >> 32); } -/* - * Return true if resource is for object identified by fid. - */ -static inline int fid_res_name_eq(const struct lu_fid *f, - const struct ldlm_res_id *name) -{ - return name->name[LUSTRE_RES_ID_SEQ_OFF] == fid_seq(f) && - name->name[LUSTRE_RES_ID_VER_OID_OFF] == fid_ver_oid(f); -} - -/* reverse function of fid_build_reg_res_name() */ -static inline void fid_build_from_res_name(struct lu_fid *f, - const struct ldlm_res_id *name) -{ - fid_zero(f); - f->f_seq = name->name[LUSTRE_RES_ID_SEQ_OFF]; - f->f_oid = name->name[LUSTRE_RES_ID_VER_OID_OFF] & 0xffffffff; - f->f_ver = name->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32; - LASSERT(fid_res_name_eq(f, name)); -} - static inline struct ldlm_res_id * -fid_build_pdo_res_name(const struct lu_fid *f, - unsigned int hash, - struct ldlm_res_id *name) +fid_build_pdo_res_name(const struct lu_fid *fid, unsigned int hash, + struct ldlm_res_id *res) { - fid_build_reg_res_name(f, name); - name->name[LUSTRE_RES_ID_HSH_OFF] = hash; - return name; + fid_build_reg_res_name(fid, res); + res->name[LUSTRE_RES_ID_HSH_OFF] = hash; + + return res; } /** @@ -584,7 +595,7 @@ static inline void ostid_build_res_name(struct ost_id *oi, name->name[LUSTRE_RES_ID_SEQ_OFF] = ostid_id(oi); name->name[LUSTRE_RES_ID_VER_OID_OFF] = ostid_seq(oi); } else { - fid_build_reg_res_name((struct lu_fid *)oi, name); + fid_build_reg_res_name(&oi->oi_fid, name); } } @@ -597,7 +608,7 @@ static inline void ostid_res_name_to_id(struct ost_id *oi, ostid_set_id(oi, name->name[LUSTRE_RES_ID_SEQ_OFF]); } else { /* new resid */ - fid_build_from_res_name((struct lu_fid *)oi, name); + fid_extract_from_res_name(&oi->oi_fid, name); } } @@ -644,7 +655,7 @@ static inline void ost_fid_from_resid(struct lu_fid *fid, ostid_to_fid(fid, &oi, 0); } else { /* new resid */ - fid_build_from_res_name(fid, name); + fid_extract_from_res_name(fid, name); } } @@ -666,14 +677,14 @@ static inline __u64 fid_flatten(const struct lu_fid *fid) if (fid_is_igif(fid)) { ino = lu_igif_ino(fid); - RETURN(ino); + return ino; } seq = fid_seq(fid); ino = (seq << 24) + ((seq >> 24) & 0xffffff0000ULL) + fid_oid(fid); - RETURN(ino ? ino : fid_oid(fid)); + return ino ? ino : fid_oid(fid); } static inline __u32 fid_hash(const struct lu_fid *f, int bits) @@ -692,7 +703,7 @@ static inline __u32 fid_flatten32(const struct lu_fid *fid) if (fid_is_igif(fid)) { ino = lu_igif_ino(fid); - RETURN(ino); + return ino; } seq = fid_seq(fid) - FID_SEQ_START; @@ -706,7 +717,7 @@ static inline __u32 fid_flatten32(const struct lu_fid *fid) (seq >> (64 - (40-8)) & 0xffffff00) + (fid_oid(fid) & 0xff000fff) + ((fid_oid(fid) & 0x00fff000) << 8); - RETURN(ino ? ino : fid_oid(fid)); + return ino ? ino : fid_oid(fid); } static inline int lu_fid_diff(struct lu_fid *fid1, struct lu_fid *fid2) @@ -759,4 +770,4 @@ static inline void range_be_to_cpu(struct lu_seq_range *dst, const struct lu_seq /** @} fid */ -#endif /* __LINUX_FID_H */ +#endif /* __LUSTRE_FID_H */ diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index 11e034a65b1..550fff58745 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/drivers/staging/lustre/lustre/include/lustre_fld.h @@ -43,9 +43,6 @@ */ #include <lustre/lustre_idl.h> -#include <lustre_mdt.h> -#include <dt_object.h> - #include <linux/libcfs/libcfs.h> struct lu_client_fld; @@ -75,7 +72,7 @@ struct lu_fld_target { struct lu_server_fld { /** * Fld dir proc entry. */ - proc_dir_entry_t *lsf_proc_dir; + struct proc_dir_entry *lsf_proc_dir; /** * /fld file object device */ @@ -103,7 +100,7 @@ struct lu_server_fld { struct lu_client_fld { /** * Client side proc entry. */ - proc_dir_entry_t *lcf_proc_dir; + struct proc_dir_entry *lcf_proc_dir; /** * List of exports client FLD knows about. */ @@ -129,47 +126,9 @@ struct lu_client_fld { * Client fld proc entry name. */ char lcf_name[80]; - const struct lu_context *lcf_ctx; - int lcf_flags; }; -/** - * number of blocks to reserve for particular operations. Should be function of - * ... something. Stub for now. - */ -enum { - /* one insert operation can involve two delete and one insert */ - FLD_TXN_INDEX_INSERT_CREDITS = 60, - FLD_TXN_INDEX_DELETE_CREDITS = 20, -}; - -int fld_query(struct com_thread_info *info); - -/* Server methods */ -int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld, - struct dt_device *dt, const char *prefix, int mds_node_id, - int type); - -void fld_server_fini(const struct lu_env *env, struct lu_server_fld *fld); - -int fld_declare_server_create(const struct lu_env *env, - struct lu_server_fld *fld, - struct lu_seq_range *new, - struct thandle *th); - -int fld_server_create(const struct lu_env *env, - struct lu_server_fld *fld, - struct lu_seq_range *add_range, - struct thandle *th); - -int fld_insert_entry(const struct lu_env *env, - struct lu_server_fld *fld, - const struct lu_seq_range *range); - -int fld_server_lookup(const struct lu_env *env, struct lu_server_fld *fld, - seqno_t seq, struct lu_seq_range *range); - /* Client methods */ int fld_client_init(struct lu_client_fld *fld, const char *prefix, int hash); diff --git a/drivers/staging/lustre/lustre/include/lustre_idmap.h b/drivers/staging/lustre/lustre/include/lustre_idmap.h index 084bdd6ab4d..2da859691d6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_idmap.h +++ b/drivers/staging/lustre/lustre/include/lustre_idmap.h @@ -80,8 +80,8 @@ struct lustre_idmap_table { struct lu_ucred; -extern void lustre_groups_from_list(group_info_t *ginfo, gid_t *glist); -extern void lustre_groups_sort(group_info_t *group_info); +extern void lustre_groups_from_list(struct group_info *ginfo, gid_t *glist); +extern void lustre_groups_sort(struct group_info *group_info); extern int lustre_in_group_p(struct lu_ucred *mu, gid_t grp); extern int lustre_idmap_add(struct lustre_idmap_table *t, diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index 3a5dd6a94c0..67259eb43cd 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -336,9 +336,11 @@ static inline unsigned int at_timeout2est(unsigned int val) } 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(); + spin_unlock(&at->at_lock); } static inline void at_init(struct adaptive_timeout *at, int val, int flags) { memset(at, 0, sizeof(*at)); diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index bdfc5391c6d..5e11107d4c6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -96,7 +96,7 @@ void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs); /* l_lock.c */ struct lustre_lock { int l_depth; - task_t *l_owner; + struct task_struct *l_owner; struct semaphore l_sem; spinlock_t l_spin; }; @@ -260,10 +260,7 @@ int obd_ioctl_popdata(void *arg, void *data, int len); static inline void obd_ioctl_freedata(char *buf, int len) { - ENTRY; - OBD_FREE_LARGE(buf, len); - EXIT; return; } diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index 714ab378e43..721aa05dff3 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -469,16 +469,14 @@ static inline int llog_destroy(const struct lu_env *env, struct llog_operations *lop; int rc; - ENTRY; - rc = llog_handle2ops(handle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_destroy == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = lop->lop_destroy(env, handle); - RETURN(rc); + return rc; } static inline int llog_next_block(const struct lu_env *env, @@ -489,17 +487,15 @@ static inline int llog_next_block(const struct lu_env *env, struct llog_operations *lop; int rc; - ENTRY; - rc = llog_handle2ops(loghandle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_next_block == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = lop->lop_next_block(env, loghandle, cur_idx, next_idx, cur_offset, buf, len); - RETURN(rc); + return rc; } static inline int llog_prev_block(const struct lu_env *env, @@ -509,16 +505,14 @@ static inline int llog_prev_block(const struct lu_env *env, struct llog_operations *lop; int rc; - ENTRY; - rc = llog_handle2ops(loghandle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_prev_block == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = lop->lop_prev_block(env, loghandle, prev_idx, buf, len); - RETURN(rc); + return rc; } static inline int llog_connect(struct llog_ctxt *ctxt, @@ -528,16 +522,14 @@ static inline int llog_connect(struct llog_ctxt *ctxt, struct llog_operations *lop; int rc; - ENTRY; - rc = llog_obd2ops(ctxt, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_connect == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = lop->lop_connect(ctxt, logid, gen, uuid); - RETURN(rc); + return rc; } /* llog.c */ diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index fb1561a809b..19000259a5e 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -84,9 +84,8 @@ static inline void mdc_init_rpc_lock(struct mdc_rpc_lock *lck) static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck, struct lookup_intent *it) { - ENTRY; - - if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP)) + if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || + it->it_op == IT_LAYOUT)) return; /* This would normally block until the existing request finishes. @@ -123,8 +122,9 @@ static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck, static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck, struct lookup_intent *it) { - if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP)) - goto out; + if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || + it->it_op == IT_LAYOUT)) + return; if (lck->rpcl_it == MDC_FAKE_RPCL_IT) { /* OBD_FAIL_MDC_RPCS_SEM */ mutex_lock(&lck->rpcl_mutex); @@ -141,8 +141,6 @@ static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck, } mutex_unlock(&lck->rpcl_mutex); - out: - EXIT; } static inline void mdc_update_max_ea_from_body(struct obd_export *exp, diff --git a/drivers/staging/lustre/lustre/include/lustre_mdt.h b/drivers/staging/lustre/lustre/include/lustre_mdt.h deleted file mode 100644 index dba26a6cfa3..00000000000 --- a/drivers/staging/lustre/lustre/include/lustre_mdt.h +++ /dev/null @@ -1,84 +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. - */ - -#ifndef __LINUX_MDT_H -#define __LINUX_MDT_H - -/** \defgroup mdt mdt - * - * @{ - */ - -#include <lustre/lustre_idl.h> -#include <lustre_req_layout.h> -#include <md_object.h> -#include <dt_object.h> -#include <linux/libcfs/libcfs.h> - -/* - * Common thread info for mdt, seq and fld - */ -struct com_thread_info { - /* - * for req-layout interface. - */ - struct req_capsule *cti_pill; -}; - -enum { - ESERIOUS = 0x0001000 -}; - -static inline int err_serious(int rc) -{ - LASSERT(rc < 0); - LASSERT(-rc < ESERIOUS); - return -(-rc | ESERIOUS); -} - -static inline int clear_serious(int rc) -{ - if (rc < 0) - rc = -(-rc & ~ESERIOUS); - return rc; -} - -static inline int is_serious(int rc) -{ - return (rc < 0 && -rc & ESERIOUS); -} - -/** @} mdt */ - -#endif diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 293dd90e5b6..e947002fae0 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1136,7 +1136,7 @@ struct ptlrpc_nrs_pol_conf { * different module to the one the NRS framework is held within * (currently ptlrpc), should set this field to THIS_MODULE. */ - module_t *nc_owner; + struct module *nc_owner; /** * Policy registration flags; a bitmast of \e nrs_policy_flags */ @@ -1211,7 +1211,7 @@ struct ptlrpc_nrs_pol_desc { * then unregistration and lprocfs operations will be properly * serialized. */ - module_t *pd_owner; + struct module *pd_owner; /** * Bitmask of \e nrs_policy_flags */ @@ -2322,8 +2322,13 @@ struct ptlrpc_thread { pid_t t_pid; /** * put watchdog in the structure per thread b=14840 + * + * Lustre watchdog is removed for client in the hope + * of a generic watchdog can be merged in kernel. + * When that happens, we should add below back. + * + * struct lc_watchdog *t_watchdog; */ - struct lc_watchdog *t_watchdog; /** * the svc this thread belonged to b=18582 */ @@ -2484,7 +2489,7 @@ struct ptlrpc_service { /** limit of threads number for each partition */ int srv_nthrs_cpt_limit; /** Root of /proc dir tree for this service */ - proc_dir_entry_t *srv_procroot; + struct proc_dir_entry *srv_procroot; /** Pointer to statistic data for this service */ struct lprocfs_stats *srv_stats; /** # hp per lp reqs to handle */ @@ -2631,7 +2636,7 @@ struct ptlrpc_service_part { /** reqs waiting for replies */ struct ptlrpc_at_array scp_at_array; /** early reply timer */ - timer_list_t scp_at_timer; + struct timer_list scp_at_timer; /** debug */ cfs_time_t scp_at_checktime; /** check early replies */ @@ -3161,6 +3166,38 @@ lustre_shrink_reply(struct ptlrpc_request *req, int segment, req->rq_replen = lustre_shrink_msg(req->rq_repmsg, segment, newlen, move_data); } + +#ifdef CONFIG_LUSTRE_TRANSLATE_ERRNOS + +static inline int ptlrpc_status_hton(int h) +{ + /* + * Positive errnos must be network errnos, such as LUSTRE_EDEADLK, + * ELDLM_LOCK_ABORTED, etc. + */ + if (h < 0) + return -lustre_errno_hton(-h); + else + return h; +} + +static inline int ptlrpc_status_ntoh(int n) +{ + /* + * See the comment in ptlrpc_status_hton(). + */ + if (n < 0) + return -lustre_errno_ntoh(-n); + else + return n; +} + +#else + +#define ptlrpc_status_hton(h) (h) +#define ptlrpc_status_ntoh(n) (n) + +#endif /** @} */ /** Change request phase of \a req to \a new_phase */ diff --git a/drivers/staging/lustre/lustre/include/lustre_quota.h b/drivers/staging/lustre/lustre/include/lustre_quota.h index 1c3041f5004..71b5d97e034 100644 --- a/drivers/staging/lustre/lustre/include/lustre_quota.h +++ b/drivers/staging/lustre/lustre/include/lustre_quota.h @@ -168,7 +168,7 @@ struct qsd_instance; * enforcement. Arguments are documented where each function is defined. */ struct qsd_instance *qsd_init(const struct lu_env *, char *, struct dt_device *, - proc_dir_entry_t *); + struct proc_dir_entry *); int qsd_prepare(const struct lu_env *, struct qsd_instance *); int qsd_start(const struct lu_env *, struct qsd_instance *); void qsd_fini(const struct lu_env *, struct qsd_instance *); diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h index 9e0908e1c4d..70b8b133a5c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_sec.h +++ b/drivers/staging/lustre/lustre/include/lustre_sec.h @@ -796,7 +796,7 @@ struct ptlrpc_sec_sops { }; struct ptlrpc_sec_policy { - module_t *sp_owner; + struct module *sp_owner; char *sp_name; __u16 sp_policy; /* policy number */ struct ptlrpc_sec_cops *sp_cops; /* client ops */ diff --git a/drivers/staging/lustre/lustre/include/md_object.h b/drivers/staging/lustre/lustre/include/md_object.h index 92d6420b21d..daf93afe3fe 100644 --- a/drivers/staging/lustre/lustre/include/md_object.h +++ b/drivers/staging/lustre/lustre/include/md_object.h @@ -503,11 +503,6 @@ static inline struct md_device *md_obj2dev(const struct md_object *o) return container_of0(o->mo_lu.lo_dev, struct md_device, md_lu_dev); } -static inline struct seq_server_site *lu_site2seq(const struct lu_site *s) -{ - return s->ld_seq_site; -} - static inline int md_device_init(struct md_device *md, struct lu_device_type *t) { return lu_device_init(&md->md_lu_dev, t); @@ -876,7 +871,7 @@ struct lu_ucred { __u32 uc_suppgids[2]; cfs_cap_t uc_cap; __u32 uc_umask; - group_info_t *uc_ginfo; + struct group_info *uc_ginfo; struct md_identity *uc_identity; }; diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 0a251fdfe16..a6122559d55 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -49,15 +49,14 @@ #define IOC_MDC_MAX_NR 50 #include <lustre/lustre_idl.h> -#include <lu_ref.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 <linux/libcfs/bitmap.h> - - #define MAX_OBD_DEVICES 8192 struct osc_async_rc { @@ -119,6 +118,20 @@ struct lov_stripe_md { #define lsm_stripe_count lsm_wire.lw_stripe_count #define lsm_pool_name lsm_wire.lw_pool_name +static inline bool lsm_is_released(struct lov_stripe_md *lsm) +{ + return !!(lsm->lsm_pattern & LOV_PATTERN_F_RELEASED); +} + +static inline bool lsm_has_objects(struct lov_stripe_md *lsm) +{ + if (lsm == NULL) + return false; + if (lsm_is_released(lsm)) + return false; + return true; +} + struct obd_info; typedef int (*obd_enqueue_update_f)(void *cookie, int rc); @@ -225,7 +238,7 @@ struct obd_type { struct list_head typ_chain; struct obd_ops *typ_dt_ops; struct md_ops *typ_md_ops; - proc_dir_entry_t *typ_procroot; + struct proc_dir_entry *typ_procroot; char *typ_name; int typ_refcnt; struct lu_device_type *typ_lu; @@ -239,30 +252,6 @@ struct brw_page { obd_flag flag; }; -/* Individual type definitions */ - -struct ost_server_data; - -struct osd_properties { - size_t osd_max_ea_size; -}; - -#define OBT_MAGIC 0xBDDECEAE -/* hold common fields for "target" device */ -struct obd_device_target { - __u32 obt_magic; - __u32 obt_instance; - struct super_block *obt_sb; - /** last_rcvd file */ - struct file *obt_rcvd_filp; - __u64 obt_mount_count; - struct rw_semaphore obt_rwsem; - struct vfsmount *obt_vfsmnt; - struct file *obt_health_check_filp; - struct osd_properties obt_osd_properties; - struct obd_job_stats obt_jobstats; -}; - /* llog contexts */ enum llog_ctxt_id { LLOG_CONFIG_ORIG_CTXT = 0, @@ -277,100 +266,13 @@ enum llog_ctxt_id { LLOG_TEST_REPL_CTXT, LLOG_LOVEA_ORIG_CTXT, LLOG_LOVEA_REPL_CTXT, - LLOG_CHANGELOG_ORIG_CTXT, /**< changelog generation on mdd */ - LLOG_CHANGELOG_REPL_CTXT, /**< changelog access on clients */ - LLOG_CHANGELOG_USER_ORIG_CTXT, /**< for multiple changelog consumers */ + LLOG_CHANGELOG_ORIG_CTXT, /**< changelog generation on mdd */ + LLOG_CHANGELOG_REPL_CTXT, /**< changelog access on clients */ + LLOG_CHANGELOG_USER_ORIG_CTXT, /**< for multiple changelog consumers */ + LLOG_AGENT_ORIG_CTXT, /**< agent requests generation on cdt */ LLOG_MAX_CTXTS }; -#define FILTER_SUBDIR_COUNT 32 /* set to zero for no subdirs */ - -struct filter_subdirs { - struct dentry *dentry[FILTER_SUBDIR_COUNT]; -}; - - -struct filter_ext { - __u64 fe_start; - __u64 fe_end; -}; - -struct filter_obd { - /* NB this field MUST be first */ - struct obd_device_target fo_obt; - const char *fo_fstype; - - int fo_group_count; - struct dentry *fo_dentry_O; - struct dentry **fo_dentry_O_groups; - struct filter_subdirs *fo_dentry_O_sub; - struct mutex fo_init_lock; /* group initialization lock*/ - int fo_committed_group; - - spinlock_t fo_objidlock; /* protect fo_lastobjid */ - - unsigned long fo_destroys_in_progress; - struct mutex fo_create_locks[FILTER_SUBDIR_COUNT]; - - struct list_head fo_export_list; - int fo_subdir_count; - - obd_size fo_tot_dirty; /* protected by obd_osfs_lock */ - obd_size fo_tot_granted; /* all values in bytes */ - obd_size fo_tot_pending; - int fo_tot_granted_clients; - - obd_size fo_readcache_max_filesize; - spinlock_t fo_flags_lock; - unsigned int fo_read_cache:1, /**< enable read-only cache */ - fo_writethrough_cache:1,/**< read cache writes */ - fo_mds_ost_sync:1, /**< MDS-OST orphan recovery*/ - fo_raid_degraded:1;/**< RAID device degraded */ - - struct obd_import *fo_mdc_imp; - struct obd_uuid fo_mdc_uuid; - struct lustre_handle fo_mdc_conn; - struct file **fo_last_objid_files; - __u64 *fo_last_objids; /* last created objid for groups, - * protected by fo_objidlock */ - - struct mutex fo_alloc_lock; - - atomic_t fo_r_in_flight; - atomic_t fo_w_in_flight; - - /* - * per-filter pool of kiobuf's allocated by filter_common_setup() and - * torn down by filter_cleanup(). - * - * This pool contains kiobuf used by - * filter_{prep,commit}rw_{read,write}() and is shared by all OST - * threads. - * - * Locking: protected by internal lock of cfs_hash, pool can be - * found from this hash table by t_id of ptlrpc_thread. - */ - struct cfs_hash *fo_iobuf_hash; - - struct brw_stats fo_filter_stats; - - int fo_fmd_max_num; /* per exp filter_mod_data */ - int fo_fmd_max_age; /* jiffies to fmd expiry */ - unsigned long fo_syncjournal:1, /* sync journal on writes */ - fo_sync_lock_cancel:2;/* sync on lock cancel */ - - - /* sptlrpc stuff */ - rwlock_t fo_sptlrpc_lock; - struct sptlrpc_rule_set fo_sptlrpc_rset; - - /* capability related */ - unsigned int fo_fl_oss_capa; - struct list_head fo_capa_keys; - struct hlist_head *fo_capa_hash; - int fo_sec_level; -}; - struct timeout_item { enum timeout_event ti_event; cfs_time_t ti_timeout; @@ -536,25 +438,6 @@ struct obd_id_info { obd_id *data; }; -/* */ - -struct echo_obd { - struct obd_device_target eo_obt; - struct obdo eo_oa; - spinlock_t eo_lock; - __u64 eo_lastino; - struct lustre_handle eo_nl_lock; - atomic_t eo_prep; -}; - -struct ost_obd { - struct ptlrpc_service *ost_service; - struct ptlrpc_service *ost_create_service; - struct ptlrpc_service *ost_io_service; - struct ptlrpc_service *ost_seq_service; - struct mutex ost_health_mutex; -}; - struct echo_client_obd { struct obd_export *ec_exp; /* the local connection to osc/lov */ spinlock_t ec_lock; @@ -654,7 +537,7 @@ struct pool_desc { struct lov_qos_rr pool_rr; /* round robin qos */ struct hlist_node pool_hash; /* access by poolname */ struct list_head pool_list; /* serial access */ - proc_dir_entry_t *pool_proc_entry; /* file in /proc */ + struct proc_dir_entry *pool_proc_entry; /* file in /proc */ struct obd_device *pool_lobd; /* obd of the lov/lod to which * this pool belongs */ }; @@ -675,7 +558,7 @@ struct lov_obd { int lov_pool_count; cfs_hash_t *lov_pools_hash_body; /* used for key access */ struct list_head lov_pool_list; /* used for sequential access */ - proc_dir_entry_t *lov_pool_proc_entry; + struct proc_dir_entry *lov_pool_proc_entry; enum lustre_sec_part lov_sp_me; /* Cached LRU pages from upper layer */ @@ -1017,7 +900,7 @@ struct obd_device { int obd_requests_queued_for_recovery; wait_queue_head_t obd_next_transno_waitq; /* protected by obd_recovery_task_lock */ - timer_list_t obd_recovery_timer; + struct timer_list obd_recovery_timer; time_t obd_recovery_start; /* seconds */ time_t obd_recovery_end; /* seconds, for lprocfs_status */ int obd_recovery_time_hard; @@ -1036,12 +919,8 @@ struct obd_device { int obd_recovery_stage; union { - struct obd_device_target obt; - struct filter_obd filter; struct client_obd cli; - struct ost_obd ost; struct echo_client_obd echo_client; - struct echo_obd echo; struct lov_obd lov; struct lmv_obd lmv; } u; @@ -1052,10 +931,10 @@ struct obd_device { unsigned int md_cntr_base; struct lprocfs_stats *md_stats; - proc_dir_entry_t *obd_proc_entry; + struct proc_dir_entry *obd_proc_entry; void *obd_proc_private; /* type private PDEs */ - proc_dir_entry_t *obd_proc_exports_entry; - proc_dir_entry_t *obd_svc_procroot; + struct proc_dir_entry *obd_proc_exports_entry; + struct proc_dir_entry *obd_svc_procroot; struct lprocfs_stats *obd_svc_stats; atomic_t obd_evict_inprogress; wait_queue_head_t obd_evict_inprogress_waitq; @@ -1218,12 +1097,6 @@ typedef int (* md_enqueue_cb_t)(struct ptlrpc_request *req, struct md_enqueue_info *minfo, int rc); -/* seq client type */ -enum lu_cli_type { - LUSTRE_SEQ_METADATA = 1, - LUSTRE_SEQ_DATA -}; - struct md_enqueue_info { struct md_op_data mi_data; struct lookup_intent mi_it; @@ -1235,7 +1108,7 @@ struct md_enqueue_info { }; struct obd_ops { - module_t *o_owner; + struct module *o_owner; int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg); int (*o_get_info)(const struct lu_env *env, struct obd_export *, diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index de5c5853647..983718fe1e5 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -326,7 +326,7 @@ void obdo_le_to_cpu(struct obdo *dobdo, struct obdo *sobdo); do { \ if (!(obd)) { \ CERROR("NULL device\n"); \ - RETURN(-ENODEV); \ + return -ENODEV; \ } \ } while (0) @@ -337,7 +337,7 @@ do { \ if (!(obd)->obd_set_up || (obd)->obd_stopping) { \ CERROR("Device %d not setup\n", \ (obd)->obd_minor); \ - RETURN(-ENODEV); \ + return -ENODEV; \ } \ } while (0) @@ -424,7 +424,7 @@ do { \ if (err) \ CERROR("md_" #op ": dev %s/%d no operation\n", \ obd->obd_name, obd->obd_minor); \ - RETURN(err); \ + return err; \ } \ } while (0) @@ -432,17 +432,17 @@ do { \ do { \ if ((exp) == NULL) { \ CERROR("obd_" #op ": NULL export\n"); \ - RETURN(-ENODEV); \ + return -ENODEV; \ } \ if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ CERROR("obd_" #op ": cleaned up obd\n"); \ - RETURN(-EOPNOTSUPP); \ + return -EOPNOTSUPP; \ } \ if (!OBT((exp)->exp_obd) || !MDP((exp)->exp_obd, op)) { \ CERROR("obd_" #op ": dev %s/%d no operation\n", \ (exp)->exp_obd->obd_name, \ (exp)->exp_obd->obd_minor); \ - RETURN(-EOPNOTSUPP); \ + return -EOPNOTSUPP; \ } \ } while (0) @@ -453,7 +453,7 @@ do { \ if (err) \ CERROR("obd_" #op ": dev %d no operation\n", \ obd->obd_minor); \ - RETURN(err); \ + return err; \ } \ } while (0) @@ -461,16 +461,16 @@ do { \ do { \ if ((exp) == NULL) { \ CERROR("obd_" #op ": NULL export\n"); \ - RETURN(-ENODEV); \ + return -ENODEV; \ } \ if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ CERROR("obd_" #op ": cleaned up obd\n"); \ - RETURN(-EOPNOTSUPP); \ + return -EOPNOTSUPP; \ } \ if (!OBT((exp)->exp_obd) || !OBP((exp)->exp_obd, op)) { \ CERROR("obd_" #op ": dev %d no operation\n", \ (exp)->exp_obd->obd_minor); \ - RETURN(-EOPNOTSUPP); \ + return -EOPNOTSUPP; \ } \ } while (0) @@ -480,7 +480,7 @@ do { \ if (err) \ CERROR("lop_" #op ": dev %d no operation\n", \ ctxt->loc_obd->obd_minor); \ - RETURN(err); \ + return err; \ } \ } while (0) @@ -495,14 +495,13 @@ static inline int obd_get_info(const struct lu_env *env, struct lov_stripe_md *lsm) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, get_info); EXP_COUNTER_INCREMENT(exp, get_info); rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val, lsm); - RETURN(rc); + return rc; } static inline int obd_set_info_async(const struct lu_env *env, @@ -511,14 +510,13 @@ static inline int obd_set_info_async(const struct lu_env *env, struct ptlrpc_request_set *set) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, set_info_async); EXP_COUNTER_INCREMENT(exp, set_info_async); rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen, val, set); - RETURN(rc); + return rc; } /* @@ -547,7 +545,6 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) { int rc; DECLARE_LU_VARS(ldt, d); - ENTRY; ldt = obd->obd_type->typ_lu; if (ldt != NULL) { @@ -577,7 +574,7 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) OBD_COUNTER_INCREMENT(obd, setup); rc = OBP(obd, setup)(obd, cfg); } - RETURN(rc); + return rc; } static inline int obd_precleanup(struct obd_device *obd, @@ -585,7 +582,6 @@ static inline int obd_precleanup(struct obd_device *obd, { int rc; DECLARE_LU_VARS(ldt, d); - ENTRY; OBD_CHECK_DEV(obd); ldt = obd->obd_type->typ_lu; @@ -605,14 +601,13 @@ static inline int obd_precleanup(struct obd_device *obd, OBD_COUNTER_INCREMENT(obd, precleanup); rc = OBP(obd, precleanup)(obd, cleanup_stage); - RETURN(rc); + return rc; } static inline int obd_cleanup(struct obd_device *obd) { int rc; DECLARE_LU_VARS(ldt, d); - ENTRY; OBD_CHECK_DEV(obd); @@ -632,13 +627,11 @@ static inline int obd_cleanup(struct obd_device *obd) OBD_COUNTER_INCREMENT(obd, cleanup); rc = OBP(obd, cleanup)(obd); - RETURN(rc); + return rc; } static inline void obd_cleanup_client_import(struct obd_device *obd) { - ENTRY; - /* If we set up but never connected, the client import will not have been cleaned. */ down_write(&obd->u.cli.cl_sem); @@ -656,8 +649,6 @@ static inline void obd_cleanup_client_import(struct obd_device *obd) obd->u.cli.cl_import = NULL; } up_write(&obd->u.cli.cl_sem); - - EXIT; } static inline int @@ -665,7 +656,6 @@ obd_process_config(struct obd_device *obd, int datalen, void *data) { int rc; DECLARE_LU_VARS(ldt, d); - ENTRY; OBD_CHECK_DEV(obd); @@ -687,7 +677,7 @@ obd_process_config(struct obd_device *obd, int datalen, void *data) OBD_COUNTER_INCREMENT(obd, process_config); obd->obd_process_conf = 0; - RETURN(rc); + return rc; } /* Pack an in-memory MD struct for storage on disk. @@ -702,13 +692,12 @@ static inline int obd_packmd(struct obd_export *exp, struct lov_stripe_md *mem_src) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, packmd); EXP_COUNTER_INCREMENT(exp, packmd); rc = OBP(exp->exp_obd, packmd)(exp, disk_tgt, mem_src); - RETURN(rc); + return rc; } static inline int obd_size_diskmd(struct obd_export *exp, @@ -757,13 +746,12 @@ static inline int obd_unpackmd(struct obd_export *exp, int disk_len) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, unpackmd); EXP_COUNTER_INCREMENT(exp, unpackmd); rc = OBP(exp->exp_obd, unpackmd)(exp, mem_tgt, disk_src, disk_len); - RETURN(rc); + return rc; } /* helper functions */ @@ -790,13 +778,12 @@ static inline int obd_free_memmd(struct obd_export *exp, static inline int obd_precreate(struct obd_export *exp) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, precreate); OBD_COUNTER_INCREMENT(exp->exp_obd, precreate); rc = OBP(exp->exp_obd, precreate)(exp); - RETURN(rc); + return rc; } static inline int obd_create_async(struct obd_export *exp, @@ -805,13 +792,12 @@ static inline int obd_create_async(struct obd_export *exp, struct obd_trans_info *oti) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, create_async); EXP_COUNTER_INCREMENT(exp, create_async); rc = OBP(exp->exp_obd, create_async)(exp, oinfo, ea, oti); - RETURN(rc); + return rc; } static inline int obd_create(const struct lu_env *env, struct obd_export *exp, @@ -819,13 +805,12 @@ static inline int obd_create(const struct lu_env *env, struct obd_export *exp, struct obd_trans_info *oti) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, create); EXP_COUNTER_INCREMENT(exp, create); rc = OBP(exp->exp_obd, create)(env, exp, obdo, ea, oti); - RETURN(rc); + return rc; } static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, @@ -834,26 +819,24 @@ static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, struct obd_export *md_exp, void *capa) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, destroy); EXP_COUNTER_INCREMENT(exp, destroy); rc = OBP(exp->exp_obd, destroy)(env, exp, obdo, ea, oti, md_exp, capa); - RETURN(rc); + return rc; } static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, struct obd_info *oinfo) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, getattr); EXP_COUNTER_INCREMENT(exp, getattr); rc = OBP(exp->exp_obd, getattr)(env, exp, oinfo); - RETURN(rc); + return rc; } static inline int obd_getattr_async(struct obd_export *exp, @@ -861,13 +844,12 @@ static inline int obd_getattr_async(struct obd_export *exp, struct ptlrpc_request_set *set) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, getattr_async); EXP_COUNTER_INCREMENT(exp, getattr_async); rc = OBP(exp->exp_obd, getattr_async)(exp, oinfo, set); - RETURN(rc); + return rc; } static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, @@ -875,13 +857,12 @@ static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, struct obd_trans_info *oti) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, setattr); EXP_COUNTER_INCREMENT(exp, setattr); rc = OBP(exp->exp_obd, setattr)(env, exp, oinfo, oti); - RETURN(rc); + return rc; } /* This performs all the requests set init/wait/destroy actions. */ @@ -891,20 +872,19 @@ static inline int obd_setattr_rqset(struct obd_export *exp, { struct ptlrpc_request_set *set = NULL; int rc; - ENTRY; EXP_CHECK_DT_OP(exp, setattr_async); EXP_COUNTER_INCREMENT(exp, setattr_async); set = ptlrpc_prep_set(); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set); if (rc == 0) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } /* This adds all the requests into @set if @set != NULL, otherwise @@ -915,13 +895,12 @@ static inline int obd_setattr_async(struct obd_export *exp, struct ptlrpc_request_set *set) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, setattr_async); EXP_COUNTER_INCREMENT(exp, setattr_async); rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set); - RETURN(rc); + return rc; } static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, @@ -929,40 +908,37 @@ static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, { struct obd_device *obd = imp->imp_obd; int rc; - ENTRY; OBD_CHECK_DEV_ACTIVE(obd); OBD_CHECK_DT_OP(obd, add_conn, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, add_conn); rc = OBP(obd, add_conn)(imp, uuid, priority); - RETURN(rc); + return rc; } static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) { struct obd_device *obd = imp->imp_obd; int rc; - ENTRY; OBD_CHECK_DEV_ACTIVE(obd); OBD_CHECK_DT_OP(obd, del_conn, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, del_conn); rc = OBP(obd, del_conn)(imp, uuid); - RETURN(rc); + return rc; } static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) { struct obd_uuid *uuid; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, get_uuid, NULL); EXP_COUNTER_INCREMENT(exp, get_uuid); uuid = OBP(exp->exp_obd, get_uuid)(exp); - RETURN(uuid); + return uuid; } /** Create a new /a exp on device /a obd for the uuid /a cluuid @@ -979,7 +955,6 @@ static inline int obd_connect(const struct lu_env *env, int rc; __u64 ocf = data ? data->ocd_connect_flags : 0; /* for post-condition * check */ - ENTRY; OBD_CHECK_DEV_ACTIVE(obd); OBD_CHECK_DT_OP(obd, connect, -EOPNOTSUPP); @@ -989,7 +964,7 @@ static inline int obd_connect(const struct lu_env *env, /* check that only subset is granted */ LASSERT(ergo(data != NULL, (data->ocd_connect_flags & ocf) == data->ocd_connect_flags)); - RETURN(rc); + return rc; } static inline int obd_reconnect(const struct lu_env *env, @@ -1003,8 +978,6 @@ static inline int obd_reconnect(const struct lu_env *env, __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition * check */ - ENTRY; - OBD_CHECK_DEV_ACTIVE(obd); OBD_CHECK_DT_OP(obd, reconnect, 0); OBD_COUNTER_INCREMENT(obd, reconnect); @@ -1013,44 +986,41 @@ static inline int obd_reconnect(const struct lu_env *env, /* check that only subset is granted */ LASSERT(ergo(d != NULL, (d->ocd_connect_flags & ocf) == d->ocd_connect_flags)); - RETURN(rc); + return rc; } static inline int obd_disconnect(struct obd_export *exp) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, disconnect); EXP_COUNTER_INCREMENT(exp, disconnect); rc = OBP(exp->exp_obd, disconnect)(exp); - RETURN(rc); + return rc; } static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, enum lu_cli_type type) { int rc; - ENTRY; OBD_CHECK_DT_OP(obd, fid_init, 0); OBD_COUNTER_INCREMENT(obd, fid_init); rc = OBP(obd, fid_init)(obd, exp, type); - RETURN(rc); + return rc; } static inline int obd_fid_fini(struct obd_device *obd) { int rc; - ENTRY; OBD_CHECK_DT_OP(obd, fid_fini, 0); OBD_COUNTER_INCREMENT(obd, fid_fini); rc = OBP(obd, fid_fini)(obd); - RETURN(rc); + return rc; } static inline int obd_fid_alloc(struct obd_export *exp, @@ -1058,113 +1028,101 @@ static inline int obd_fid_alloc(struct obd_export *exp, struct md_op_data *op_data) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, fid_alloc); EXP_COUNTER_INCREMENT(exp, fid_alloc); rc = OBP(exp->exp_obd, fid_alloc)(exp, fid, op_data); - RETURN(rc); + return rc; } static inline int obd_ping(const struct lu_env *env, struct obd_export *exp) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, ping, 0); EXP_COUNTER_INCREMENT(exp, ping); rc = OBP(exp->exp_obd, ping)(env, exp); - RETURN(rc); + return rc; } static inline int obd_pool_new(struct obd_device *obd, char *poolname) { int rc; - ENTRY; OBD_CHECK_DT_OP(obd, pool_new, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, pool_new); rc = OBP(obd, pool_new)(obd, poolname); - RETURN(rc); + return rc; } static inline int obd_pool_del(struct obd_device *obd, char *poolname) { int rc; - ENTRY; OBD_CHECK_DT_OP(obd, pool_del, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, pool_del); rc = OBP(obd, pool_del)(obd, poolname); - RETURN(rc); + return rc; } static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ostname) { int rc; - ENTRY; OBD_CHECK_DT_OP(obd, pool_add, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, pool_add); rc = OBP(obd, pool_add)(obd, poolname, ostname); - RETURN(rc); + return rc; } static inline int obd_pool_rem(struct obd_device *obd, char *poolname, char *ostname) { int rc; - ENTRY; OBD_CHECK_DT_OP(obd, pool_rem, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, pool_rem); rc = OBP(obd, pool_rem)(obd, poolname, ostname); - RETURN(rc); + return rc; } static inline void obd_getref(struct obd_device *obd) { - ENTRY; if (OBT(obd) && OBP(obd, getref)) { OBD_COUNTER_INCREMENT(obd, getref); OBP(obd, getref)(obd); } - EXIT; } static inline void obd_putref(struct obd_device *obd) { - ENTRY; if (OBT(obd) && OBP(obd, putref)) { OBD_COUNTER_INCREMENT(obd, putref); OBP(obd, putref)(obd); } - EXIT; } static inline int obd_init_export(struct obd_export *exp) { int rc = 0; - ENTRY; if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && OBP((exp)->exp_obd, init_export)) rc = OBP(exp->exp_obd, init_export)(exp); - RETURN(rc); + return rc; } static inline int obd_destroy_export(struct obd_export *exp) { - ENTRY; if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && OBP((exp)->exp_obd, destroy_export)) OBP(exp->exp_obd, destroy_export)(exp); - RETURN(0); + return 0; } static inline int obd_extent_calc(struct obd_export *exp, @@ -1172,10 +1130,10 @@ static inline int obd_extent_calc(struct obd_export *exp, int cmd, obd_off *offset) { int rc; - ENTRY; + EXP_CHECK_DT_OP(exp, extent_calc); rc = OBP(exp->exp_obd, extent_calc)(exp, md, cmd, offset); - RETURN(rc); + return rc; } static inline struct dentry * @@ -1198,10 +1156,9 @@ static inline int obd_statfs_async(struct obd_export *exp, { int rc = 0; struct obd_device *obd; - ENTRY; if (exp == NULL || exp->exp_obd == NULL) - RETURN(-EINVAL); + return -EINVAL; obd = exp->exp_obd; OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); @@ -1224,7 +1181,7 @@ static inline int obd_statfs_async(struct obd_export *exp, if (oinfo->oi_cb_up) oinfo->oi_cb_up(oinfo, 0); } - RETURN(rc); + return rc; } static inline int obd_statfs_rqset(struct obd_export *exp, @@ -1234,11 +1191,10 @@ static inline int obd_statfs_rqset(struct obd_export *exp, struct ptlrpc_request_set *set = NULL; struct obd_info oinfo = { { { 0 } } }; int rc = 0; - ENTRY; set = ptlrpc_prep_set(); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; oinfo.oi_osfs = osfs; oinfo.oi_flags = flags; @@ -1246,7 +1202,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp, if (rc == 0) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } /* @max_age is the oldest time in jiffies that we accept using a cached data. @@ -1258,10 +1214,9 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, { int rc = 0; struct obd_device *obd = exp->exp_obd; - ENTRY; if (obd == NULL) - RETURN(-EINVAL); + return -EINVAL; OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, statfs); @@ -1286,7 +1241,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, memcpy(osfs, &obd->obd_osfs, sizeof(*osfs)); spin_unlock(&obd->obd_osfs_lock); } - RETURN(rc); + return rc; } static inline int obd_sync_rqset(struct obd_export *exp, struct obd_info *oinfo, @@ -1294,20 +1249,19 @@ static inline int obd_sync_rqset(struct obd_export *exp, struct obd_info *oinfo, { struct ptlrpc_request_set *set = NULL; int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, sync, -EOPNOTSUPP); EXP_COUNTER_INCREMENT(exp, sync); set = ptlrpc_prep_set(); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = OBP(exp->exp_obd, sync)(NULL, exp, oinfo, start, end, set); if (rc == 0) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } static inline int obd_sync(const struct lu_env *env, struct obd_export *exp, @@ -1315,13 +1269,12 @@ static inline int obd_sync(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request_set *set) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, sync, -EOPNOTSUPP); EXP_COUNTER_INCREMENT(exp, sync); rc = OBP(exp->exp_obd, sync)(env, exp, oinfo, start, end, set); - RETURN(rc); + return rc; } static inline int obd_punch_rqset(struct obd_export *exp, @@ -1330,20 +1283,19 @@ static inline int obd_punch_rqset(struct obd_export *exp, { struct ptlrpc_request_set *set = NULL; int rc; - ENTRY; EXP_CHECK_DT_OP(exp, punch); EXP_COUNTER_INCREMENT(exp, punch); set = ptlrpc_prep_set(); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = OBP(exp->exp_obd, punch)(NULL, exp, oinfo, oti, set); if (rc == 0) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } static inline int obd_punch(const struct lu_env *env, struct obd_export *exp, @@ -1351,13 +1303,12 @@ static inline int obd_punch(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request_set *rqset) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, punch); EXP_COUNTER_INCREMENT(exp, punch); rc = OBP(exp->exp_obd, punch)(env, exp, oinfo, oti, rqset); - RETURN(rc); + return rc; } static inline int obd_brw(int cmd, struct obd_export *exp, @@ -1365,7 +1316,6 @@ static inline int obd_brw(int cmd, struct obd_export *exp, struct brw_page *pg, struct obd_trans_info *oti) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, brw); EXP_COUNTER_INCREMENT(exp, brw); @@ -1377,7 +1327,7 @@ static inline int obd_brw(int cmd, struct obd_export *exp, } rc = OBP(exp->exp_obd, brw)(cmd, exp, oinfo, oa_bufs, pg, oti); - RETURN(rc); + return rc; } static inline int obd_preprw(const struct lu_env *env, int cmd, @@ -1389,14 +1339,13 @@ static inline int obd_preprw(const struct lu_env *env, int cmd, struct lustre_capa *capa) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, preprw); EXP_COUNTER_INCREMENT(exp, preprw); rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote, pages, local, oti, capa); - RETURN(rc); + return rc; } static inline int obd_commitrw(const struct lu_env *env, int cmd, @@ -1406,14 +1355,12 @@ static inline int obd_commitrw(const struct lu_env *env, int cmd, struct niobuf_local *local, struct obd_trans_info *oti, int rc) { - ENTRY; - EXP_CHECK_DT_OP(exp, commitrw); EXP_COUNTER_INCREMENT(exp, commitrw); rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj, rnb, pages, local, oti, rc); - RETURN(rc); + return rc; } static inline int obd_merge_lvb(struct obd_export *exp, @@ -1421,13 +1368,12 @@ static inline int obd_merge_lvb(struct obd_export *exp, struct ost_lvb *lvb, int kms_only) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, merge_lvb); EXP_COUNTER_INCREMENT(exp, merge_lvb); rc = OBP(exp->exp_obd, merge_lvb)(exp, lsm, lvb, kms_only); - RETURN(rc); + return rc; } static inline int obd_adjust_kms(struct obd_export *exp, @@ -1435,26 +1381,24 @@ static inline int obd_adjust_kms(struct obd_export *exp, int shrink) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, adjust_kms); EXP_COUNTER_INCREMENT(exp, adjust_kms); rc = OBP(exp->exp_obd, adjust_kms)(exp, lsm, size, shrink); - RETURN(rc); + return rc; } static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, iocontrol); EXP_COUNTER_INCREMENT(exp, iocontrol); rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg); - RETURN(rc); + return rc; } static inline int obd_enqueue_rqset(struct obd_export *exp, @@ -1463,20 +1407,19 @@ static inline int obd_enqueue_rqset(struct obd_export *exp, { struct ptlrpc_request_set *set = NULL; int rc; - ENTRY; EXP_CHECK_DT_OP(exp, enqueue); EXP_COUNTER_INCREMENT(exp, enqueue); set = ptlrpc_prep_set(); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = OBP(exp->exp_obd, enqueue)(exp, oinfo, einfo, set); if (rc == 0) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } static inline int obd_enqueue(struct obd_export *exp, @@ -1485,13 +1428,12 @@ static inline int obd_enqueue(struct obd_export *exp, struct ptlrpc_request_set *set) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, enqueue); EXP_COUNTER_INCREMENT(exp, enqueue); rc = OBP(exp->exp_obd, enqueue)(exp, oinfo, einfo, set); - RETURN(rc); + return rc; } static inline int obd_change_cbdata(struct obd_export *exp, @@ -1499,13 +1441,12 @@ static inline int obd_change_cbdata(struct obd_export *exp, ldlm_iterator_t it, void *data) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, change_cbdata); EXP_COUNTER_INCREMENT(exp, change_cbdata); rc = OBP(exp->exp_obd, change_cbdata)(exp, lsm, it, data); - RETURN(rc); + return rc; } static inline int obd_find_cbdata(struct obd_export *exp, @@ -1513,13 +1454,12 @@ static inline int obd_find_cbdata(struct obd_export *exp, ldlm_iterator_t it, void *data) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, find_cbdata); EXP_COUNTER_INCREMENT(exp, find_cbdata); rc = OBP(exp->exp_obd, find_cbdata)(exp, lsm, it, data); - RETURN(rc); + return rc; } static inline int obd_cancel(struct obd_export *exp, @@ -1527,13 +1467,12 @@ static inline int obd_cancel(struct obd_export *exp, struct lustre_handle *lockh) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, cancel); EXP_COUNTER_INCREMENT(exp, cancel); rc = OBP(exp->exp_obd, cancel)(exp, ea, mode, lockh); - RETURN(rc); + return rc; } static inline int obd_cancel_unused(struct obd_export *exp, @@ -1542,13 +1481,12 @@ static inline int obd_cancel_unused(struct obd_export *exp, void *opaque) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, cancel_unused); EXP_COUNTER_INCREMENT(exp, cancel_unused); rc = OBP(exp->exp_obd, cancel_unused)(exp, ea, flags, opaque); - RETURN(rc); + return rc; } static inline int obd_pin(struct obd_export *exp, const struct lu_fid *fid, @@ -1556,26 +1494,24 @@ static inline int obd_pin(struct obd_export *exp, const struct lu_fid *fid, int flag) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, pin); EXP_COUNTER_INCREMENT(exp, pin); rc = OBP(exp->exp_obd, pin)(exp, fid, oc, handle, flag); - RETURN(rc); + return rc; } static inline int obd_unpin(struct obd_export *exp, struct obd_client_handle *handle, int flag) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, unpin); EXP_COUNTER_INCREMENT(exp, unpin); rc = OBP(exp->exp_obd, unpin)(exp, handle, flag); - RETURN(rc); + return rc; } @@ -1583,30 +1519,26 @@ static inline void obd_import_event(struct obd_device *obd, struct obd_import *imp, enum obd_import_event event) { - ENTRY; if (!obd) { CERROR("NULL device\n"); - EXIT; return; } if (obd->obd_set_up && OBP(obd, import_event)) { OBD_COUNTER_INCREMENT(obd, import_event); OBP(obd, import_event)(obd, imp, event); } - EXIT; } static inline int obd_llog_connect(struct obd_export *exp, struct llogd_conn_body *body) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, llog_connect, 0); EXP_COUNTER_INCREMENT(exp, llog_connect); rc = OBP(exp->exp_obd, llog_connect)(exp, body); - RETURN(rc); + return rc; } @@ -1616,7 +1548,7 @@ static inline int obd_notify(struct obd_device *obd, void *data) { int rc; - ENTRY; + OBD_CHECK_DEV(obd); /* the check for async_recov is a complete hack - I'm hereby @@ -1625,17 +1557,17 @@ static inline int obd_notify(struct obd_device *obd, by this point, and it needs to get them to execute mds_postrecov. */ if (!obd->obd_set_up && !obd->obd_async_recov) { CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name); - RETURN(-EINVAL); + return -EINVAL; } if (!OBP(obd, notify)) { CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name); - RETURN(-ENOSYS); + return -ENOSYS; } OBD_COUNTER_INCREMENT(obd, notify); rc = OBP(obd, notify)(obd, watched, ev, data); - RETURN(rc); + return rc; } static inline int obd_notify_observer(struct obd_device *observer, @@ -1669,26 +1601,24 @@ static inline int obd_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, quotacheck); EXP_COUNTER_INCREMENT(exp, quotacheck); rc = OBP(exp->exp_obd, quotacheck)(exp->exp_obd, exp, oqctl); - RETURN(rc); + return rc; } static inline int obd_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, quotactl); EXP_COUNTER_INCREMENT(exp, quotactl); rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl); - RETURN(rc); + return rc; } static inline int obd_health_check(const struct lu_env *env, @@ -1702,56 +1632,52 @@ static inline int obd_health_check(const struct lu_env *env, * <0 on error */ int rc; - ENTRY; /* don't use EXP_CHECK_DT_OP, because NULL method is normal here */ if (obd == NULL || !OBT(obd)) { CERROR("cleaned up obd\n"); - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; } if (!obd->obd_set_up || obd->obd_stopping) - RETURN(0); + return 0; if (!OBP(obd, health_check)) - RETURN(0); + return 0; rc = OBP(obd, health_check)(env, obd); - RETURN(rc); + return rc; } static inline int obd_register_observer(struct obd_device *obd, struct obd_device *observer) { - ENTRY; OBD_CHECK_DEV(obd); down_write(&obd->obd_observer_link_sem); if (obd->obd_observer && observer) { up_write(&obd->obd_observer_link_sem); - RETURN(-EALREADY); + return -EALREADY; } obd->obd_observer = observer; up_write(&obd->obd_observer_link_sem); - RETURN(0); + return 0; } static inline int obd_pin_observer(struct obd_device *obd, struct obd_device **observer) { - ENTRY; down_read(&obd->obd_observer_link_sem); if (!obd->obd_observer) { *observer = NULL; up_read(&obd->obd_observer_link_sem); - RETURN(-ENOENT); + return -ENOENT; } *observer = obd->obd_observer; - RETURN(0); + return 0; } static inline int obd_unpin_observer(struct obd_device *obd) { - ENTRY; up_read(&obd->obd_observer_link_sem); - RETURN(0); + return 0; } #if 0 @@ -1760,52 +1686,48 @@ static inline int obd_register_page_removal_cb(struct obd_export *exp, obd_pin_extent_cb pin_cb) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, register_page_removal_cb, 0); OBD_COUNTER_INCREMENT(exp->exp_obd, register_page_removal_cb); rc = OBP(exp->exp_obd, register_page_removal_cb)(exp, cb, pin_cb); - RETURN(rc); + return rc; } static inline int obd_unregister_page_removal_cb(struct obd_export *exp, obd_page_removal_cb_t cb) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, unregister_page_removal_cb, 0); OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_page_removal_cb); rc = OBP(exp->exp_obd, unregister_page_removal_cb)(exp, cb); - RETURN(rc); + return rc; } static inline int obd_register_lock_cancel_cb(struct obd_export *exp, obd_lock_cancel_cb cb) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, register_lock_cancel_cb, 0); OBD_COUNTER_INCREMENT(exp->exp_obd, register_lock_cancel_cb); rc = OBP(exp->exp_obd, register_lock_cancel_cb)(exp, cb); - RETURN(rc); + return rc; } static inline int obd_unregister_lock_cancel_cb(struct obd_export *exp, obd_lock_cancel_cb cb) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, unregister_lock_cancel_cb, 0); OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_lock_cancel_cb); rc = OBP(exp->exp_obd, unregister_lock_cancel_cb)(exp, cb); - RETURN(rc); + return rc; } #endif @@ -1814,34 +1736,33 @@ static inline int md_getstatus(struct obd_export *exp, struct lu_fid *fid, struct obd_capa **pc) { int rc; - ENTRY; EXP_CHECK_MD_OP(exp, getstatus); EXP_MD_COUNTER_INCREMENT(exp, getstatus); rc = MDP(exp->exp_obd, getstatus)(exp, fid, pc); - RETURN(rc); + return rc; } static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, getattr); EXP_MD_COUNTER_INCREMENT(exp, getattr); rc = MDP(exp->exp_obd, getattr)(exp, op_data, request); - RETURN(rc); + return rc; } static inline int md_null_inode(struct obd_export *exp, const struct lu_fid *fid) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, null_inode); EXP_MD_COUNTER_INCREMENT(exp, null_inode); rc = MDP(exp->exp_obd, null_inode)(exp, fid); - RETURN(rc); + return rc; } static inline int md_find_cbdata(struct obd_export *exp, @@ -1849,11 +1770,11 @@ static inline int md_find_cbdata(struct obd_export *exp, ldlm_iterator_t it, void *data) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, find_cbdata); EXP_MD_COUNTER_INCREMENT(exp, find_cbdata); rc = MDP(exp->exp_obd, find_cbdata)(exp, fid, it, data); - RETURN(rc); + return rc; } static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, @@ -1861,11 +1782,11 @@ static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, close); EXP_MD_COUNTER_INCREMENT(exp, close); rc = MDP(exp->exp_obd, close)(exp, op_data, mod, request); - RETURN(rc); + return rc; } static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, @@ -1874,12 +1795,12 @@ static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, create); EXP_MD_COUNTER_INCREMENT(exp, create); rc = MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode, uid, gid, cap_effective, rdev, request); - RETURN(rc); + return rc; } static inline int md_done_writing(struct obd_export *exp, @@ -1887,11 +1808,11 @@ static inline int md_done_writing(struct obd_export *exp, struct md_open_data *mod) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, done_writing); EXP_MD_COUNTER_INCREMENT(exp, done_writing); rc = MDP(exp->exp_obd, done_writing)(exp, op_data, mod); - RETURN(rc); + return rc; } static inline int md_enqueue(struct obd_export *exp, @@ -1904,12 +1825,12 @@ static inline int md_enqueue(struct obd_export *exp, int extra_lock_flags) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, enqueue); EXP_MD_COUNTER_INCREMENT(exp, enqueue); rc = MDP(exp->exp_obd, enqueue)(exp, einfo, it, op_data, lockh, lmm, lmmsize, req, extra_lock_flags); - RETURN(rc); + return rc; } static inline int md_getattr_name(struct obd_export *exp, @@ -1917,11 +1838,11 @@ static inline int md_getattr_name(struct obd_export *exp, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, getattr_name); EXP_MD_COUNTER_INCREMENT(exp, getattr_name); rc = MDP(exp->exp_obd, getattr_name)(exp, op_data, request); - RETURN(rc); + return rc; } static inline int md_intent_lock(struct obd_export *exp, @@ -1932,24 +1853,24 @@ static inline int md_intent_lock(struct obd_export *exp, __u64 extra_lock_flags) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, intent_lock); EXP_MD_COUNTER_INCREMENT(exp, intent_lock); rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, lmm, lmmsize, it, lookup_flags, reqp, cb_blocking, extra_lock_flags); - RETURN(rc); + return rc; } static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, link); EXP_MD_COUNTER_INCREMENT(exp, link); rc = MDP(exp->exp_obd, link)(exp, op_data, request); - RETURN(rc); + return rc; } static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, @@ -1957,12 +1878,12 @@ static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, int newlen, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, rename); EXP_MD_COUNTER_INCREMENT(exp, rename); rc = MDP(exp->exp_obd, rename)(exp, op_data, old, oldlen, new, newlen, request); - RETURN(rc); + return rc; } static inline int md_is_subdir(struct obd_export *exp, @@ -1971,11 +1892,11 @@ static inline int md_is_subdir(struct obd_export *exp, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, is_subdir); EXP_MD_COUNTER_INCREMENT(exp, is_subdir); rc = MDP(exp->exp_obd, is_subdir)(exp, pfid, cfid, request); - RETURN(rc); + return rc; } static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, @@ -1984,23 +1905,23 @@ static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, struct md_open_data **mod) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, setattr); EXP_MD_COUNTER_INCREMENT(exp, setattr); rc = MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, ea2, ea2len, request, mod); - RETURN(rc); + return rc; } static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid, struct obd_capa *oc, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, sync); EXP_MD_COUNTER_INCREMENT(exp, sync); rc = MDP(exp->exp_obd, sync)(exp, fid, oc, request); - RETURN(rc); + return rc; } static inline int md_readpage(struct obd_export *exp, struct md_op_data *opdata, @@ -2008,22 +1929,22 @@ static inline int md_readpage(struct obd_export *exp, struct md_op_data *opdata, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, readpage); EXP_MD_COUNTER_INCREMENT(exp, readpage); rc = MDP(exp->exp_obd, readpage)(exp, opdata, pages, request); - RETURN(rc); + return rc; } static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, unlink); EXP_MD_COUNTER_INCREMENT(exp, unlink); rc = MDP(exp->exp_obd, unlink)(exp, op_data, request); - RETURN(rc); + return rc; } static inline int md_get_lustre_md(struct obd_export *exp, @@ -2032,19 +1953,17 @@ static inline int md_get_lustre_md(struct obd_export *exp, struct obd_export *md_exp, struct lustre_md *md) { - ENTRY; EXP_CHECK_MD_OP(exp, get_lustre_md); EXP_MD_COUNTER_INCREMENT(exp, get_lustre_md); - RETURN(MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md)); + return MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md); } static inline int md_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { - ENTRY; EXP_CHECK_MD_OP(exp, free_lustre_md); EXP_MD_COUNTER_INCREMENT(exp, free_lustre_md); - RETURN(MDP(exp->exp_obd, free_lustre_md)(exp, md)); + return MDP(exp->exp_obd, free_lustre_md)(exp, md); } static inline int md_setxattr(struct obd_export *exp, @@ -2054,12 +1973,11 @@ static inline int md_setxattr(struct obd_export *exp, int output_size, int flags, __u32 suppgid, struct ptlrpc_request **request) { - ENTRY; EXP_CHECK_MD_OP(exp, setxattr); EXP_MD_COUNTER_INCREMENT(exp, setxattr); - RETURN(MDP(exp->exp_obd, setxattr)(exp, fid, oc, valid, name, input, + return MDP(exp->exp_obd, setxattr)(exp, fid, oc, valid, name, input, input_size, output_size, flags, - suppgid, request)); + suppgid, request); } static inline int md_getxattr(struct obd_export *exp, @@ -2069,40 +1987,36 @@ static inline int md_getxattr(struct obd_export *exp, int output_size, int flags, struct ptlrpc_request **request) { - ENTRY; EXP_CHECK_MD_OP(exp, getxattr); EXP_MD_COUNTER_INCREMENT(exp, getxattr); - RETURN(MDP(exp->exp_obd, getxattr)(exp, fid, oc, valid, name, input, + return MDP(exp->exp_obd, getxattr)(exp, fid, oc, valid, name, input, input_size, output_size, flags, - request)); + request); } static inline int md_set_open_replay_data(struct obd_export *exp, struct obd_client_handle *och, struct ptlrpc_request *open_req) { - ENTRY; EXP_CHECK_MD_OP(exp, set_open_replay_data); EXP_MD_COUNTER_INCREMENT(exp, set_open_replay_data); - RETURN(MDP(exp->exp_obd, set_open_replay_data)(exp, och, open_req)); + return MDP(exp->exp_obd, set_open_replay_data)(exp, och, open_req); } static inline int md_clear_open_replay_data(struct obd_export *exp, struct obd_client_handle *och) { - ENTRY; EXP_CHECK_MD_OP(exp, clear_open_replay_data); EXP_MD_COUNTER_INCREMENT(exp, clear_open_replay_data); - RETURN(MDP(exp->exp_obd, clear_open_replay_data)(exp, och)); + return MDP(exp->exp_obd, clear_open_replay_data)(exp, och); } static inline int md_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, __u64 *bits) { - ENTRY; EXP_CHECK_MD_OP(exp, set_lock_data); EXP_MD_COUNTER_INCREMENT(exp, set_lock_data); - RETURN(MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits)); + return MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits); } static inline int md_cancel_unused(struct obd_export *exp, @@ -2113,14 +2027,13 @@ static inline int md_cancel_unused(struct obd_export *exp, void *opaque) { int rc; - ENTRY; EXP_CHECK_MD_OP(exp, cancel_unused); EXP_MD_COUNTER_INCREMENT(exp, cancel_unused); rc = MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode, flags, opaque); - RETURN(rc); + return rc; } static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags, @@ -2130,21 +2043,19 @@ static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags, ldlm_mode_t mode, struct lustre_handle *lockh) { - ENTRY; EXP_CHECK_MD_OP(exp, lock_match); EXP_MD_COUNTER_INCREMENT(exp, lock_match); - RETURN(MDP(exp->exp_obd, lock_match)(exp, flags, fid, type, - policy, mode, lockh)); + return MDP(exp->exp_obd, lock_match)(exp, flags, fid, type, + policy, mode, lockh); } static inline int md_init_ea_size(struct obd_export *exp, int easize, int def_asize, int cookiesize) { - ENTRY; EXP_CHECK_MD_OP(exp, init_ea_size); EXP_MD_COUNTER_INCREMENT(exp, init_ea_size); - RETURN(MDP(exp->exp_obd, init_ea_size)(exp, easize, def_asize, - cookiesize)); + return MDP(exp->exp_obd, init_ea_size)(exp, easize, def_asize, + cookiesize); } static inline int md_get_remote_perm(struct obd_export *exp, @@ -2152,22 +2063,21 @@ static inline int md_get_remote_perm(struct obd_export *exp, struct obd_capa *oc, __u32 suppgid, struct ptlrpc_request **request) { - ENTRY; EXP_CHECK_MD_OP(exp, get_remote_perm); EXP_MD_COUNTER_INCREMENT(exp, get_remote_perm); - RETURN(MDP(exp->exp_obd, get_remote_perm)(exp, fid, oc, suppgid, - request)); + return MDP(exp->exp_obd, get_remote_perm)(exp, fid, oc, suppgid, + request); } static inline int md_renew_capa(struct obd_export *exp, struct obd_capa *ocapa, renew_capa_cb_t cb) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, renew_capa); EXP_MD_COUNTER_INCREMENT(exp, renew_capa); rc = MDP(exp->exp_obd, renew_capa)(exp, ocapa, cb); - RETURN(rc); + return rc; } static inline int md_unpack_capa(struct obd_export *exp, @@ -2176,11 +2086,11 @@ static inline int md_unpack_capa(struct obd_export *exp, struct obd_capa **oc) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, unpack_capa); EXP_MD_COUNTER_INCREMENT(exp, unpack_capa); rc = MDP(exp->exp_obd, unpack_capa)(exp, req, field, oc); - RETURN(rc); + return rc; } static inline int md_intent_getattr_async(struct obd_export *exp, @@ -2188,11 +2098,11 @@ static inline int md_intent_getattr_async(struct obd_export *exp, struct ldlm_enqueue_info *einfo) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, intent_getattr_async); EXP_MD_COUNTER_INCREMENT(exp, intent_getattr_async); rc = MDP(exp->exp_obd, intent_getattr_async)(exp, minfo, einfo); - RETURN(rc); + return rc; } static inline int md_revalidate_lock(struct obd_export *exp, @@ -2200,11 +2110,11 @@ static inline int md_revalidate_lock(struct obd_export *exp, struct lu_fid *fid, __u64 *bits) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, revalidate_lock); EXP_MD_COUNTER_INCREMENT(exp, revalidate_lock); rc = MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits); - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/include/obd_lov.h b/drivers/staging/lustre/lustre/include/obd_lov.h index d82f3341d0a..235718b366d 100644 --- a/drivers/staging/lustre/lustre/include/obd_lov.h +++ b/drivers/staging/lustre/lustre/include/obd_lov.h @@ -44,16 +44,6 @@ static inline int lov_stripe_md_size(__u16 stripes) return sizeof(struct lov_stripe_md) + stripes*sizeof(struct lov_oinfo*); } -static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic) -{ - if (lmm_magic == LOV_MAGIC_V3) - return sizeof(struct lov_mds_md_v3) + - stripes * sizeof(struct lov_ost_data_v1); - else - return sizeof(struct lov_mds_md_v1) + - stripes * sizeof(struct lov_ost_data_v1); -} - struct lov_version_size { __u32 lvs_magic; size_t lvs_lmm_size; diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index b5d40afc359..03e6133ef50 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -470,6 +470,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, #define OBD_FAIL_LFSCK_DELAY3 0x1602 #define OBD_FAIL_LFSCK_LINKEA_CRASH 0x1603 #define OBD_FAIL_LFSCK_LINKEA_MORE 0x1604 +#define OBD_FAIL_LFSCK_LINKEA_MORE2 0x1605 #define OBD_FAIL_LFSCK_FATAL1 0x1608 #define OBD_FAIL_LFSCK_FATAL2 0x1609 #define OBD_FAIL_LFSCK_CRASH 0x160a diff --git a/drivers/staging/lustre/lustre/lclient/glimpse.c b/drivers/staging/lustre/lustre/lclient/glimpse.c index 7f3974be1f9..7bbca4bf6b8 100644 --- a/drivers/staging/lustre/lustre/lclient/glimpse.c +++ b/drivers/staging/lustre/lustre/lclient/glimpse.c @@ -93,7 +93,6 @@ int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, struct cl_lock *lock; int result; - ENTRY; result = 0; if (!(lli->lli_flags & LLIF_MDS_SIZE_LOCK)) { CDEBUG(D_DLMTRACE, "Glimpsing inode "DFID"\n", PFID(fid)); @@ -131,10 +130,10 @@ int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, cio->cui_glimpse = 0; if (lock == NULL) - RETURN(0); + return 0; if (IS_ERR(lock)) - RETURN(PTR_ERR(lock)); + return PTR_ERR(lock); LASSERT(agl == 0); result = cl_wait(env, lock); @@ -159,7 +158,7 @@ int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, } } - RETURN(result); + return result; } static int cl_io_get(struct inode *inode, struct lu_env **envout, @@ -203,8 +202,6 @@ int cl_glimpse_size0(struct inode *inode, int agl) int result; int refcheck; - ENTRY; - result = cl_io_get(inode, &env, &io, &refcheck); if (result > 0) { again: @@ -226,7 +223,7 @@ int cl_glimpse_size0(struct inode *inode, int agl) goto again; cl_env_put(env, &refcheck); } - RETURN(result); + return result; } int cl_local_size(struct inode *inode) @@ -240,14 +237,12 @@ int cl_local_size(struct inode *inode) int result; int refcheck; - ENTRY; - if (!cl_i2info(inode)->lli_has_smd) - RETURN(0); + return 0; result = cl_io_get(inode, &env, &io, &refcheck); if (result <= 0) - RETURN(result); + return result; clob = io->ci_obj; result = cl_io_init(env, io, CIT_MISC, clob); @@ -270,5 +265,5 @@ int cl_local_size(struct inode *inode) } cl_io_fini(env, io); cl_env_put(env, &refcheck); - RETURN(result); + return result; } diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 4a0166687f0..8ff38c64b7a 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -169,7 +169,6 @@ int ccc_device_init(const struct lu_env *env, struct lu_device *d, { struct ccc_device *vdv; int rc; - ENTRY; vdv = lu2ccc_dev(d); vdv->cdv_next = lu2cl_dev(next); @@ -182,7 +181,7 @@ int ccc_device_init(const struct lu_env *env, struct lu_device *d, lu_device_get(next); lu_ref_add(&next->ld_reference, "lu-stack", &lu_site_init); } - RETURN(rc); + return rc; } struct lu_device *ccc_device_fini(const struct lu_env *env, @@ -201,11 +200,10 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env, struct lu_device *lud; struct cl_site *site; int rc; - ENTRY; OBD_ALLOC_PTR(vdv); if (vdv == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); lud = &vdv->cdv_cl.cd_lu_dev; cl_device_init(&vdv->cdv_cl, t); @@ -228,7 +226,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env, ccc_device_free(env, lud); lud = ERR_PTR(rc); } - RETURN(lud); + return lud; } struct lu_device *ccc_device_free(const struct lu_env *env, @@ -418,7 +416,6 @@ int ccc_object_glimpse(const struct lu_env *env, { struct inode *inode = ccc_object_inode(obj); - ENTRY; lvb->lvb_mtime = cl_inode_mtime(inode); lvb->lvb_atime = cl_inode_atime(inode); lvb->lvb_ctime = cl_inode_ctime(inode); @@ -429,7 +426,7 @@ int ccc_object_glimpse(const struct lu_env *env, */ if (lvb->lvb_size > 0 && lvb->lvb_blocks == 0) lvb->lvb_blocks = dirty_cnt(inode); - RETURN(0); + return 0; } @@ -479,8 +476,6 @@ int ccc_page_is_under_lock(const struct lu_env *env, int result; - ENTRY; - if (io->ci_type == CIT_READ || io->ci_type == CIT_WRITE || io->ci_type == CIT_FAULT) { if (cio->cui_fd->fd_flags & LL_FILE_GROUP_LOCKED) @@ -495,7 +490,7 @@ int ccc_page_is_under_lock(const struct lu_env *env, } } else result = 0; - RETURN(result); + return result; } int ccc_fail(const struct lu_env *env, const struct cl_page_slice *slice) @@ -559,9 +554,8 @@ int ccc_transient_page_prep(const struct lu_env *env, const struct cl_page_slice *slice, struct cl_io *unused) { - ENTRY; /* transient page should always be sent. */ - RETURN(0); + return 0; } /***************************************************************************** @@ -623,7 +617,6 @@ int ccc_lock_fits_into(const struct lu_env *env, const struct ccc_io *cio = ccc_env_io(env); int result; - ENTRY; /* * Work around DLM peculiarity: it assumes that glimpse * (LDLM_FL_HAS_INTENT) lock is always LCK_PR, and returns reads lock @@ -642,7 +635,7 @@ int ccc_lock_fits_into(const struct lu_env *env, result = lock->cll_state >= CLS_ENQUEUED; else result = 1; - RETURN(result); + return result; } /** @@ -655,7 +648,6 @@ void ccc_lock_state(const struct lu_env *env, enum cl_lock_state state) { struct cl_lock *lock = slice->cls_lock; - ENTRY; /* * Refresh inode attributes when the lock is moving into CLS_HELD @@ -682,7 +674,6 @@ void ccc_lock_state(const struct lu_env *env, lock->cll_descr.cld_end == CL_PAGE_EOF) cl_merge_lvb(env, inode); } - EXIT; } /***************************************************************************** @@ -707,7 +698,6 @@ int ccc_io_one_lock_index(const struct lu_env *env, struct cl_io *io, struct cl_object *obj = io->ci_obj; CLOBINVRNT(env, obj, ccc_object_invariant(obj)); - ENTRY; CDEBUG(D_VFSTRACE, "lock: %d [%lu, %lu]\n", mode, start, end); @@ -725,7 +715,7 @@ int ccc_io_one_lock_index(const struct lu_env *env, struct cl_io *io, descr->cld_enq_flags = enqflags; cl_io_lock_add(env, io, &cio->cui_link); - RETURN(0); + return 0; } void ccc_io_update_iov(const struct lu_env *env, @@ -986,11 +976,9 @@ int cl_setattr_ost(struct inode *inode, const struct iattr *attr, int result; int refcheck; - ENTRY; - env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); io = ccc_env_thread_io(env); io->ci_obj = cl_i2info(inode)->lli_clob; @@ -1019,7 +1007,7 @@ again: if (unlikely(io->ci_need_restart)) goto again; cl_env_put(env, &refcheck); - RETURN(result); + return result; } /***************************************************************************** @@ -1166,7 +1154,7 @@ int cl_file_inode_init(struct inode *inode, struct lustre_md *md) * locked by I_NEW bit. */ lli->lli_clob = clob; - lli->lli_has_smd = md->lsm != NULL; + lli->lli_has_smd = lsm_has_objects(md->lsm); lu_object_ref_add(&clob->co_lu, "inode", inode); } else result = PTR_ERR(clob); @@ -1284,9 +1272,9 @@ __u16 ll_dirent_type_get(struct lu_dirent *ent) __u64 cl_fid_build_ino(const struct lu_fid *fid, int api32) { if (BITS_PER_LONG == 32 || api32) - RETURN(fid_flatten32(fid)); + return fid_flatten32(fid); else - RETURN(fid_flatten(fid)); + return fid_flatten(fid); } /** @@ -1295,15 +1283,14 @@ __u64 cl_fid_build_ino(const struct lu_fid *fid, int api32) __u32 cl_fid_build_gen(const struct lu_fid *fid) { __u32 gen; - ENTRY; if (fid_is_igif(fid)) { gen = lu_igif_gen(fid); - RETURN(gen); + return gen; } gen = (fid_flatten(fid) >> 32); - RETURN(gen); + return gen; } /* lsm is unreliable after hsm implementation as layout can be changed at diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c index 8ecbef92753..2b4dbeebcd5 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c @@ -57,12 +57,11 @@ int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp) int rc, easize, def_easize, cookiesize; struct lov_desc desc; __u16 stripes; - ENTRY; rc = obd_get_info(NULL, dt_exp, sizeof(KEY_LOVDESC), KEY_LOVDESC, &valsize, &desc, NULL); if (rc) - RETURN(rc); + return rc; stripes = min(desc.ld_tgt_count, (__u32)LOV_MAX_STRIPE_COUNT); lsm.lsm_stripe_count = stripes; @@ -77,7 +76,7 @@ int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp) easize, cookiesize); rc = md_init_ea_size(md_exp, easize, def_easize, cookiesize); - RETURN(rc); + return rc; } /** @@ -95,7 +94,6 @@ int cl_ocd_update(struct obd_device *host, __u64 flags; int result; - ENTRY; if (!strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME)) { cli = &watched->u.cli; lco = owner; @@ -116,7 +114,7 @@ int cl_ocd_update(struct obd_device *host, watched->obd_name); result = -EINVAL; } - RETURN(result); + return result; } #define GROUPLOCK_SCOPE "grouplock" diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index ce90c7e3c48..c65b13c800f 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c @@ -133,53 +133,45 @@ for (node = interval_last(root); node != NULL; \ static struct interval_node *interval_first(struct interval_node *node) { - ENTRY; - if (!node) - RETURN(NULL); + return NULL; while (node->in_left) node = node->in_left; - RETURN(node); + return node; } static struct interval_node *interval_last(struct interval_node *node) { - ENTRY; - if (!node) - RETURN(NULL); + return NULL; while (node->in_right) node = node->in_right; - RETURN(node); + return node; } static struct interval_node *interval_next(struct interval_node *node) { - ENTRY; - if (!node) - RETURN(NULL); + return NULL; if (node->in_right) - RETURN(interval_first(node->in_right)); + return interval_first(node->in_right); while (node->in_parent && node_is_right_child(node)) node = node->in_parent; - RETURN(node->in_parent); + return node->in_parent; } static struct interval_node *interval_prev(struct interval_node *node) { - ENTRY; - if (!node) - RETURN(NULL); + return NULL; if (node->in_left) - RETURN(interval_last(node->in_left)); + return interval_last(node->in_left); while (node->in_parent && node_is_left_child(node)) node = node->in_parent; - RETURN(node->in_parent); + return node->in_parent; } enum interval_iter interval_iterate(struct interval_node *root, @@ -188,7 +180,6 @@ enum interval_iter interval_iterate(struct interval_node *root, { struct interval_node *node; enum interval_iter rc = INTERVAL_ITER_CONT; - ENTRY; interval_for_each(node, root) { rc = func(node, data); @@ -196,7 +187,7 @@ enum interval_iter interval_iterate(struct interval_node *root, break; } - RETURN(rc); + return rc; } EXPORT_SYMBOL(interval_iterate); @@ -206,7 +197,6 @@ enum interval_iter interval_iterate_reverse(struct interval_node *root, { struct interval_node *node; enum interval_iter rc = INTERVAL_ITER_CONT; - ENTRY; interval_for_each_reverse(node, root) { rc = func(node, data); @@ -214,7 +204,7 @@ enum interval_iter interval_iterate_reverse(struct interval_node *root, break; } - RETURN(rc); + return rc; } EXPORT_SYMBOL(interval_iterate_reverse); @@ -225,7 +215,6 @@ struct interval_node *interval_find(struct interval_node *root, { struct interval_node *walk = root; int rc; - ENTRY; while (walk) { rc = extent_compare(ex, &walk->in_extent); @@ -237,7 +226,7 @@ struct interval_node *interval_find(struct interval_node *root, walk = walk->in_right; } - RETURN(walk); + return walk; } EXPORT_SYMBOL(interval_find); @@ -326,7 +315,6 @@ static void interval_insert_color(struct interval_node *node, struct interval_node **root) { struct interval_node *parent, *gparent; - ENTRY; while ((parent = node->in_parent) && node_is_red(parent)) { gparent = parent->in_parent; @@ -373,7 +361,6 @@ static void interval_insert_color(struct interval_node *node, } (*root)->in_color = INTERVAL_BLACK; - EXIT; } struct interval_node *interval_insert(struct interval_node *node, @@ -381,14 +368,13 @@ struct interval_node *interval_insert(struct interval_node *node, { struct interval_node **p, *parent = NULL; - ENTRY; LASSERT(!interval_is_intree(node)); p = root; while (*p) { parent = *p; if (node_equal(parent, node)) - RETURN(parent); + return parent; /* max_high field must be updated after each iteration */ if (parent->in_max_high < interval_high(node)) @@ -409,7 +395,7 @@ struct interval_node *interval_insert(struct interval_node *node, interval_insert_color(node, root); node->in_intree = 1; - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(interval_insert); @@ -423,7 +409,6 @@ static void interval_erase_color(struct interval_node *node, struct interval_node **root) { struct interval_node *tmp; - ENTRY; while (node_is_black_or_0(node) && node != *root) { if (parent->in_left == node) { @@ -490,7 +475,6 @@ static void interval_erase_color(struct interval_node *node, } if (node) node->in_color = INTERVAL_BLACK; - EXIT; } /* @@ -501,7 +485,6 @@ static void update_maxhigh(struct interval_node *node, __u64 old_maxhigh) { __u64 left_max, right_max; - ENTRY; while (node) { left_max = node->in_left ? node->in_left->in_max_high : 0; @@ -513,7 +496,6 @@ static void update_maxhigh(struct interval_node *node, break; node = node->in_parent; } - EXIT; } void interval_erase(struct interval_node *node, @@ -521,7 +503,6 @@ void interval_erase(struct interval_node *node, { struct interval_node *child, *parent; int color; - ENTRY; LASSERT(interval_is_intree(node)); node->in_intree = 0; @@ -586,7 +567,6 @@ void interval_erase(struct interval_node *node, color: if (color == INTERVAL_BLACK) interval_erase_color(child, parent, root); - EXIT; } EXPORT_SYMBOL(interval_erase); diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c b/drivers/staging/lustre/lustre/ldlm/l_lock.c index 853409aa945..32f4d52b536 100644 --- a/drivers/staging/lustre/lustre/ldlm/l_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c @@ -51,12 +51,12 @@ struct ldlm_resource *lock_res_and_lock(struct ldlm_lock *lock) { /* on server-side resource of lock doesn't change */ - if (!lock->l_ns_srv) + if ((lock->l_flags & LDLM_FL_NS_SRV) == 0) spin_lock(&lock->l_lock); lock_res(lock->l_resource); - lock->l_res_locked = 1; + lock->l_flags |= LDLM_FL_RES_LOCKED; return lock->l_resource; } EXPORT_SYMBOL(lock_res_and_lock); @@ -67,10 +67,10 @@ EXPORT_SYMBOL(lock_res_and_lock); void unlock_res_and_lock(struct ldlm_lock *lock) { /* on server-side resource of lock doesn't change */ - lock->l_res_locked = 0; + lock->l_flags &= ~LDLM_FL_RES_LOCKED; unlock_res(lock->l_resource); - if (!lock->l_ns_srv) + if ((lock->l_flags & LDLM_FL_NS_SRV) == 0) spin_unlock(&lock->l_lock); } EXPORT_SYMBOL(unlock_res_and_lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index f7432f78e39..7e316637369 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -72,7 +72,6 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms) struct list_head *tmp; struct ldlm_lock *lck; __u64 kms = 0; - ENTRY; /* don't let another thread in ldlm_extent_shift_kms race in * just after we finish and take our lock into account in its @@ -86,7 +85,7 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms) continue; if (lck->l_policy_data.l_extent.end >= old_kms) - RETURN(old_kms); + return old_kms; /* This extent _has_ to be smaller than old_kms (checked above) * so kms can only ever be smaller or the same as old_kms. */ @@ -95,7 +94,7 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms) } LASSERTF(kms <= old_kms, "kms "LPU64" old_kms "LPU64"\n", kms, old_kms); - RETURN(kms); + return kms; } EXPORT_SYMBOL(ldlm_extent_shift_kms); @@ -103,16 +102,15 @@ struct kmem_cache *ldlm_interval_slab; struct ldlm_interval *ldlm_interval_alloc(struct ldlm_lock *lock) { struct ldlm_interval *node; - ENTRY; LASSERT(lock->l_resource->lr_type == LDLM_EXTENT); OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, __GFP_IO); if (node == NULL) - RETURN(NULL); + return NULL; INIT_LIST_HEAD(&node->li_group); ldlm_interval_attach(node, lock); - RETURN(node); + return node; } void ldlm_interval_free(struct ldlm_interval *node) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index f100a84bde7..c68ed276633 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -142,8 +142,6 @@ static inline void ldlm_flock_blocking_unlink(struct ldlm_lock *req) static inline void ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags) { - ENTRY; - LDLM_DEBUG(lock, "ldlm_flock_destroy(mode: %d, flags: 0x%llx)", mode, flags); @@ -162,7 +160,6 @@ ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags) } ldlm_lock_destroy_nolock(lock); - EXIT; } /** @@ -198,6 +195,7 @@ ldlm_flock_deadlock(struct ldlm_lock *req, struct ldlm_lock *bl_lock) if (lock == NULL) break; + LASSERT(req != lock); flock = &lock->l_policy_data.l_flock; LASSERT(flock->owner == bl_owner); bl_owner = flock->blocking_owner; @@ -253,7 +251,6 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, int splitted = 0; const struct ldlm_callback_suite null_cbs = { NULL }; int rc; - ENTRY; CDEBUG(D_DLMTRACE, "flags %#llx owner "LPU64" pid %u mode %u start " LPU64" end "LPU64"\n", *flags, @@ -308,12 +305,12 @@ reprocess: continue; if (!first_enq) - RETURN(LDLM_ITER_CONTINUE); + return LDLM_ITER_CONTINUE; if (*flags & LDLM_FL_BLOCK_NOWAIT) { ldlm_flock_destroy(req, mode, *flags); *err = -EAGAIN; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; } if (*flags & LDLM_FL_TEST_LOCK) { @@ -326,24 +323,27 @@ reprocess: req->l_policy_data.l_flock.end = lock->l_policy_data.l_flock.end; *flags |= LDLM_FL_LOCK_CHANGED; - RETURN(LDLM_ITER_STOP); - } - - if (ldlm_flock_deadlock(req, lock)) { - ldlm_flock_destroy(req, mode, *flags); - *err = -EDEADLK; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; } + /* add lock to blocking list before deadlock + * check to prevent race */ rc = ldlm_flock_blocking_link(req, lock); if (rc) { ldlm_flock_destroy(req, mode, *flags); *err = rc; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; + } + if (ldlm_flock_deadlock(req, lock)) { + ldlm_flock_blocking_unlink(req); + ldlm_flock_destroy(req, mode, *flags); + *err = -EDEADLK; + return LDLM_ITER_STOP; } + ldlm_resource_add_lock(res, &res->lr_waiting, req); *flags |= LDLM_FL_BLOCK_GRANTED; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; } } @@ -351,7 +351,7 @@ reprocess: ldlm_flock_destroy(req, mode, *flags); req->l_req_mode = LCK_NL; *flags |= LDLM_FL_LOCK_CHANGED; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; } /* In case we had slept on this lock request take it off of the @@ -463,7 +463,7 @@ reprocess: ldlm_flock_destroy(req, lock->l_granted_mode, *flags); *err = -ENOLCK; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; } goto reprocess; } @@ -530,7 +530,7 @@ reprocess: ldlm_flock_destroy(req, mode, *flags); ldlm_resource_dump(D_INFO, res); - RETURN(LDLM_ITER_CONTINUE); + return LDLM_ITER_CONTINUE; } struct ldlm_flock_wait_data { @@ -542,7 +542,6 @@ static void ldlm_flock_interrupted_wait(void *data) { struct ldlm_lock *lock; - ENTRY; lock = ((struct ldlm_flock_wait_data *)data)->fwd_lock; @@ -553,8 +552,6 @@ ldlm_flock_interrupted_wait(void *data) /* client side - set flag to prevent lock from being put on LRU list */ lock->l_flags |= LDLM_FL_CBPENDING; unlock_res_and_lock(lock); - - EXIT; } /** @@ -577,7 +574,6 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) struct l_wait_info lwi; ldlm_error_t err; int rc = 0; - ENTRY; CDEBUG(D_DLMTRACE, "flags: 0x%llx data: %p getlk: %p\n", flags, data, getlk); @@ -595,7 +591,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) /* Need to wake up the waiter if we were evicted */ wake_up(&lock->l_waitq); - RETURN(0); + return 0; } LASSERT(flags != LDLM_FL_WAIT_NOREPROC); @@ -607,7 +603,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) goto granted; /* CP AST RPC: lock get granted, wake it up */ wake_up(&lock->l_waitq); - RETURN(0); + return 0; } LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, " @@ -633,26 +629,26 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) if (rc) { LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)", rc); - RETURN(rc); + return rc; } granted: OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CP_CB_WAIT, 10); - if (lock->l_destroyed) { + if (lock->l_flags & LDLM_FL_DESTROYED) { LDLM_DEBUG(lock, "client-side enqueue waking up: destroyed"); - RETURN(0); + return 0; } if (lock->l_flags & LDLM_FL_FAILED) { LDLM_DEBUG(lock, "client-side enqueue waking up: failed"); - RETURN(-EIO); + return -EIO; } if (rc) { LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)", rc); - RETURN(rc); + return rc; } LDLM_DEBUG(lock, "client-side enqueue granted"); @@ -694,15 +690,13 @@ granted: ldlm_process_flock_lock(lock, &noreproc, 1, &err, NULL); } unlock_res_and_lock(lock); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_flock_completion_ast); int ldlm_flock_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, void *data, int flag) { - ENTRY; - LASSERT(lock); LASSERT(flag == LDLM_CB_CANCELING); @@ -710,7 +704,7 @@ int ldlm_flock_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, lock_res_and_lock(lock); ldlm_flock_blocking_unlink(lock); unlock_res_and_lock(lock); - RETURN(0); + return 0; } void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy, @@ -831,19 +825,17 @@ int ldlm_init_flock_export(struct obd_export *exp) &ldlm_export_flock_ops, CFS_HASH_DEFAULT | CFS_HASH_NBLK_CHANGE); if (!exp->exp_flock_hash) - RETURN(-ENOMEM); + return -ENOMEM; - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_init_flock_export); void ldlm_destroy_flock_export(struct obd_export *exp) { - ENTRY; if (exp->exp_flock_hash) { cfs_hash_putref(exp->exp_flock_hash); exp->exp_flock_hash = NULL; } - EXIT; } EXPORT_SYMBOL(ldlm_destroy_flock_export); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 141a957462f..8cd79633dea 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -36,23 +36,46 @@ #define MAX_STRING_SIZE 128 -extern atomic_t ldlm_srv_namespace_nr; -extern atomic_t ldlm_cli_namespace_nr; +extern int ldlm_srv_namespace_nr; +extern int ldlm_cli_namespace_nr; extern struct mutex ldlm_srv_namespace_lock; extern struct list_head ldlm_srv_namespace_list; extern struct mutex ldlm_cli_namespace_lock; -extern struct list_head ldlm_cli_namespace_list; +extern struct list_head ldlm_cli_active_namespace_list; +extern struct list_head ldlm_cli_inactive_namespace_list; -static inline atomic_t *ldlm_namespace_nr(ldlm_side_t client) +static inline int ldlm_namespace_nr_read(ldlm_side_t client) { return client == LDLM_NAMESPACE_SERVER ? - &ldlm_srv_namespace_nr : &ldlm_cli_namespace_nr; + ldlm_srv_namespace_nr : ldlm_cli_namespace_nr; +} + +static inline void ldlm_namespace_nr_inc(ldlm_side_t client) +{ + if (client == LDLM_NAMESPACE_SERVER) + ldlm_srv_namespace_nr++; + else + ldlm_cli_namespace_nr++; +} + +static inline void ldlm_namespace_nr_dec(ldlm_side_t client) +{ + if (client == LDLM_NAMESPACE_SERVER) + ldlm_srv_namespace_nr--; + else + ldlm_cli_namespace_nr--; } static inline struct list_head *ldlm_namespace_list(ldlm_side_t client) { return client == LDLM_NAMESPACE_SERVER ? - &ldlm_srv_namespace_list : &ldlm_cli_namespace_list; + &ldlm_srv_namespace_list : &ldlm_cli_active_namespace_list; +} + +static inline struct list_head *ldlm_namespace_inactive_list(ldlm_side_t client) +{ + return client == LDLM_NAMESPACE_SERVER ? + &ldlm_srv_namespace_list : &ldlm_cli_inactive_namespace_list; } static inline struct mutex *ldlm_namespace_lock(ldlm_side_t client) @@ -61,6 +84,16 @@ static inline struct mutex *ldlm_namespace_lock(ldlm_side_t client) &ldlm_srv_namespace_lock : &ldlm_cli_namespace_lock; } +/* ns_bref is the number of resources in this namespace */ +static inline int ldlm_ns_empty(struct ldlm_namespace *ns) +{ + return atomic_read(&ns->ns_bref) == 0; +} + +void ldlm_namespace_move_to_active_locked(struct ldlm_namespace *, ldlm_side_t); +void ldlm_namespace_move_to_inactive_locked(struct ldlm_namespace *, ldlm_side_t); +struct ldlm_namespace *ldlm_namespace_first_locked(ldlm_side_t); + /* ldlm_request.c */ /* Cancel lru flag, it indicates we cancel aged locks. */ enum { @@ -159,8 +192,8 @@ void ldlm_destroy_flock_export(struct obd_export *exp); void l_check_ns_lock(struct ldlm_namespace *ns); void l_check_no_ns_lock(struct ldlm_namespace *ns); -extern proc_dir_entry_t *ldlm_svc_proc_dir; -extern proc_dir_entry_t *ldlm_type_proc_dir; +extern struct proc_dir_entry *ldlm_svc_proc_dir; +extern struct proc_dir_entry *ldlm_type_proc_dir; struct ldlm_state { struct ptlrpc_service *ldlm_cb_service; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 42df53072dc..1a8c0d7005c 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -60,17 +60,16 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, struct ptlrpc_connection *ptlrpc_conn; struct obd_import_conn *imp_conn = NULL, *item; int rc = 0; - ENTRY; if (!create && !priority) { CDEBUG(D_HA, "Nothing to do\n"); - RETURN(-EINVAL); + return -EINVAL; } ptlrpc_conn = ptlrpc_uuid_to_connection(uuid); if (!ptlrpc_conn) { CDEBUG(D_HA, "can't find connection %s\n", uuid->uuid); - RETURN (-ENOENT); + return -ENOENT; } if (create) { @@ -115,13 +114,13 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, } spin_unlock(&imp->imp_lock); - RETURN(0); + return 0; out_free: if (imp_conn) OBD_FREE(imp_conn, sizeof(*imp_conn)); out_put: ptlrpc_connection_put(ptlrpc_conn); - RETURN(rc); + return rc; } int import_set_conn_priority(struct obd_import *imp, struct obd_uuid *uuid) @@ -141,7 +140,6 @@ int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid) struct obd_import_conn *imp_conn; struct obd_export *dlmexp; int rc = -ENOENT; - ENTRY; spin_lock(&imp->imp_lock); if (list_empty(&imp->imp_conn_list)) { @@ -187,7 +185,7 @@ out: spin_unlock(&imp->imp_lock); if (rc == -ENOENT) CERROR("connection %s not found\n", uuid->uuid); - RETURN(rc); + return rc; } EXPORT_SYMBOL(client_import_del_conn); @@ -200,7 +198,6 @@ int client_import_find_conn(struct obd_import *imp, lnet_nid_t peer, { struct obd_import_conn *conn; int rc = -ENOENT; - ENTRY; spin_lock(&imp->imp_lock); list_for_each_entry(conn, &imp->imp_conn_list, oic_item) { @@ -212,7 +209,7 @@ int client_import_find_conn(struct obd_import *imp, lnet_nid_t peer, } } spin_unlock(&imp->imp_lock); - RETURN(rc); + return rc; } EXPORT_SYMBOL(client_import_find_conn); @@ -267,7 +264,6 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) ldlm_ns_type_t ns_type = LDLM_NS_TYPE_UNKNOWN; int rc; char *cli_name = lustre_cfg_buf(lcfg, 0); - ENTRY; /* In a more perfect world, we would hang a ptlrpc_client off of * obd_type and just use the values from there. */ @@ -305,27 +301,27 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) } else { CERROR("unknown client OBD type \"%s\", can't setup\n", name); - RETURN(-EINVAL); + return -EINVAL; } if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) { CERROR("requires a TARGET UUID\n"); - RETURN(-EINVAL); + return -EINVAL; } if (LUSTRE_CFG_BUFLEN(lcfg, 1) > 37) { CERROR("client UUID must be less than 38 characters\n"); - RETURN(-EINVAL); + return -EINVAL; } if (LUSTRE_CFG_BUFLEN(lcfg, 2) < 1) { CERROR("setup requires a SERVER UUID\n"); - RETURN(-EINVAL); + return -EINVAL; } if (LUSTRE_CFG_BUFLEN(lcfg, 2) > 37) { CERROR("target UUID must be less than 38 characters\n"); - RETURN(-EINVAL); + return -EINVAL; } init_rwsem(&cli->cl_sem); @@ -339,8 +335,8 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) cli->cl_avail_grant = 0; /* FIXME: Should limit this for the sum of all cl_dirty_max. */ cli->cl_dirty_max = OSC_MAX_DIRTY_DEFAULT * 1024 * 1024; - if (cli->cl_dirty_max >> PAGE_CACHE_SHIFT > num_physpages / 8) - cli->cl_dirty_max = num_physpages << (PAGE_CACHE_SHIFT - 3); + if (cli->cl_dirty_max >> PAGE_CACHE_SHIFT > totalram_pages / 8) + cli->cl_dirty_max = totalram_pages << (PAGE_CACHE_SHIFT - 3); INIT_LIST_HEAD(&cli->cl_cache_waiters); INIT_LIST_HEAD(&cli->cl_loi_ready_list); INIT_LIST_HEAD(&cli->cl_loi_hp_ready_list); @@ -388,11 +384,11 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) if (!strcmp(name, LUSTRE_MDC_NAME)) { cli->cl_max_rpcs_in_flight = MDC_MAX_RIF_DEFAULT; - } else if (num_physpages >> (20 - PAGE_CACHE_SHIFT) <= 128 /* MB */) { + } else if (totalram_pages >> (20 - PAGE_CACHE_SHIFT) <= 128 /* MB */) { cli->cl_max_rpcs_in_flight = 2; - } else if (num_physpages >> (20 - PAGE_CACHE_SHIFT) <= 256 /* MB */) { + } else if (totalram_pages >> (20 - PAGE_CACHE_SHIFT) <= 256 /* MB */) { cli->cl_max_rpcs_in_flight = 3; - } else if (num_physpages >> (20 - PAGE_CACHE_SHIFT) <= 512 /* MB */) { + } else if (totalram_pages >> (20 - PAGE_CACHE_SHIFT) <= 512 /* MB */) { cli->cl_max_rpcs_in_flight = 4; } else { if (osc_on_mdt(obddev->obd_name)) @@ -452,29 +448,27 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) cli->cl_qchk_stat = CL_NOT_QUOTACHECKED; - RETURN(rc); + return rc; err_import: class_destroy_import(imp); err_ldlm: ldlm_put_ref(); err: - RETURN(rc); + return rc; } EXPORT_SYMBOL(client_obd_setup); int client_obd_cleanup(struct obd_device *obddev) { - ENTRY; - ldlm_namespace_free_post(obddev->obd_namespace); obddev->obd_namespace = NULL; LASSERT(obddev->u.cli.cl_import == NULL); ldlm_put_ref(); - RETURN(0); + return 0; } EXPORT_SYMBOL(client_obd_cleanup); @@ -489,7 +483,6 @@ int client_connect_import(const struct lu_env *env, struct obd_connect_data *ocd; struct lustre_handle conn = { 0 }; int rc; - ENTRY; *exp = NULL; down_write(&cli->cl_sem); @@ -532,8 +525,6 @@ int client_connect_import(const struct lu_env *env, ptlrpc_pinger_add_import(imp); - EXIT; - if (rc) { out_ldlm: cli->cl_conn_count--; @@ -553,12 +544,11 @@ int client_disconnect_export(struct obd_export *exp) struct client_obd *cli; struct obd_import *imp; int rc = 0, err; - ENTRY; if (!obd) { CERROR("invalid export for disconnect: exp %p cookie "LPX64"\n", exp, exp ? exp->exp_handle.h_cookie : -1); - RETURN(-EINVAL); + return -EINVAL; } cli = &obd->u.cli; @@ -605,8 +595,6 @@ int client_disconnect_export(struct obd_export *exp) ptlrpc_invalidate_import(imp); - EXIT; - out_disconnect: /* Use server style - class_disconnect should be always called for * o_disconnect. */ @@ -616,7 +604,7 @@ out_disconnect: up_write(&cli->cl_sem); - RETURN(rc); + return rc; } EXPORT_SYMBOL(client_disconnect_export); @@ -627,7 +615,6 @@ EXPORT_SYMBOL(client_disconnect_export); int target_pack_pool_reply(struct ptlrpc_request *req) { struct obd_device *obd; - ENTRY; /* Check that we still have all structures alive as this may * be some late RPC at shutdown time. */ @@ -635,7 +622,7 @@ int target_pack_pool_reply(struct ptlrpc_request *req) !exp_connect_lru_resize(req->rq_export))) { lustre_msg_set_slv(req->rq_repmsg, 0); lustre_msg_set_limit(req->rq_repmsg, 0); - RETURN(0); + return 0; } /* OBD is alive here as export is alive, which we checked above. */ @@ -646,7 +633,7 @@ int target_pack_pool_reply(struct ptlrpc_request *req) lustre_msg_set_limit(req->rq_repmsg, obd->obd_pool_limit); read_unlock(&obd->obd_pool_lock); - RETURN(0); + return 0; } EXPORT_SYMBOL(target_pack_pool_reply); @@ -674,10 +661,8 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) int netrc; struct ptlrpc_reply_state *rs; struct obd_export *exp; - ENTRY; if (req->rq_no_reply) { - EXIT; return; } @@ -686,7 +671,6 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) if (rs == NULL || !rs->rs_difficult) { /* no notifiers */ target_send_reply_msg (req, rc, fail_id); - EXIT; return; } @@ -757,19 +741,18 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) } spin_unlock(&rs->rs_lock); spin_unlock(&svcpt->scp_rep_lock); - EXIT; } EXPORT_SYMBOL(target_send_reply); ldlm_mode_t lck_compat_array[] = { - [LCK_EX] LCK_COMPAT_EX, - [LCK_PW] LCK_COMPAT_PW, - [LCK_PR] LCK_COMPAT_PR, - [LCK_CW] LCK_COMPAT_CW, - [LCK_CR] LCK_COMPAT_CR, - [LCK_NL] LCK_COMPAT_NL, - [LCK_GROUP] LCK_COMPAT_GROUP, - [LCK_COS] LCK_COMPAT_COS, + [LCK_EX] = LCK_COMPAT_EX, + [LCK_PW] = LCK_COMPAT_PW, + [LCK_PR] = LCK_COMPAT_PR, + [LCK_CW] = LCK_COMPAT_CW, + [LCK_CR] = LCK_COMPAT_CR, + [LCK_NL] = LCK_COMPAT_NL, + [LCK_GROUP] = LCK_COMPAT_GROUP, + [LCK_COS] = LCK_COMPAT_COS, }; /** diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 33b76a1e5de..6133b3f3471 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -49,45 +49,45 @@ /* lock types */ char *ldlm_lockname[] = { - [0] "--", - [LCK_EX] "EX", - [LCK_PW] "PW", - [LCK_PR] "PR", - [LCK_CW] "CW", - [LCK_CR] "CR", - [LCK_NL] "NL", - [LCK_GROUP] "GROUP", - [LCK_COS] "COS" + [0] = "--", + [LCK_EX] = "EX", + [LCK_PW] = "PW", + [LCK_PR] = "PR", + [LCK_CW] = "CW", + [LCK_CR] = "CR", + [LCK_NL] = "NL", + [LCK_GROUP] = "GROUP", + [LCK_COS] = "COS", }; EXPORT_SYMBOL(ldlm_lockname); char *ldlm_typename[] = { - [LDLM_PLAIN] "PLN", - [LDLM_EXTENT] "EXT", - [LDLM_FLOCK] "FLK", - [LDLM_IBITS] "IBT", + [LDLM_PLAIN] = "PLN", + [LDLM_EXTENT] = "EXT", + [LDLM_FLOCK] = "FLK", + [LDLM_IBITS] = "IBT", }; EXPORT_SYMBOL(ldlm_typename); static ldlm_policy_wire_to_local_t ldlm_policy_wire18_to_local[] = { - [LDLM_PLAIN - LDLM_MIN_TYPE] ldlm_plain_policy_wire_to_local, - [LDLM_EXTENT - LDLM_MIN_TYPE] ldlm_extent_policy_wire_to_local, - [LDLM_FLOCK - LDLM_MIN_TYPE] ldlm_flock_policy_wire18_to_local, - [LDLM_IBITS - LDLM_MIN_TYPE] ldlm_ibits_policy_wire_to_local, + [LDLM_PLAIN - LDLM_MIN_TYPE] = ldlm_plain_policy_wire_to_local, + [LDLM_EXTENT - LDLM_MIN_TYPE] = ldlm_extent_policy_wire_to_local, + [LDLM_FLOCK - LDLM_MIN_TYPE] = ldlm_flock_policy_wire18_to_local, + [LDLM_IBITS - LDLM_MIN_TYPE] = ldlm_ibits_policy_wire_to_local, }; static ldlm_policy_wire_to_local_t ldlm_policy_wire21_to_local[] = { - [LDLM_PLAIN - LDLM_MIN_TYPE] ldlm_plain_policy_wire_to_local, - [LDLM_EXTENT - LDLM_MIN_TYPE] ldlm_extent_policy_wire_to_local, - [LDLM_FLOCK - LDLM_MIN_TYPE] ldlm_flock_policy_wire21_to_local, - [LDLM_IBITS - LDLM_MIN_TYPE] ldlm_ibits_policy_wire_to_local, + [LDLM_PLAIN - LDLM_MIN_TYPE] = ldlm_plain_policy_wire_to_local, + [LDLM_EXTENT - LDLM_MIN_TYPE] = ldlm_extent_policy_wire_to_local, + [LDLM_FLOCK - LDLM_MIN_TYPE] = ldlm_flock_policy_wire21_to_local, + [LDLM_IBITS - LDLM_MIN_TYPE] = ldlm_ibits_policy_wire_to_local, }; static ldlm_policy_local_to_wire_t ldlm_policy_local_to_wire[] = { - [LDLM_PLAIN - LDLM_MIN_TYPE] ldlm_plain_policy_local_to_wire, - [LDLM_EXTENT - LDLM_MIN_TYPE] ldlm_extent_policy_local_to_wire, - [LDLM_FLOCK - LDLM_MIN_TYPE] ldlm_flock_policy_local_to_wire, - [LDLM_IBITS - LDLM_MIN_TYPE] ldlm_ibits_policy_local_to_wire, + [LDLM_PLAIN - LDLM_MIN_TYPE] = ldlm_plain_policy_local_to_wire, + [LDLM_EXTENT - LDLM_MIN_TYPE] = ldlm_extent_policy_local_to_wire, + [LDLM_FLOCK - LDLM_MIN_TYPE] = ldlm_flock_policy_local_to_wire, + [LDLM_IBITS - LDLM_MIN_TYPE] = ldlm_ibits_policy_local_to_wire, }; /** @@ -188,8 +188,6 @@ EXPORT_SYMBOL(ldlm_lock_get); */ void ldlm_lock_put(struct ldlm_lock *lock) { - ENTRY; - LASSERT(lock->l_resource != LP_POISON); LASSERT(atomic_read(&lock->l_refc) > 0); if (atomic_dec_and_test(&lock->l_refc)) { @@ -199,7 +197,7 @@ void ldlm_lock_put(struct ldlm_lock *lock) "final lock_put on destroyed lock, freeing it."); res = lock->l_resource; - LASSERT(lock->l_destroyed); + LASSERT(lock->l_flags & LDLM_FL_DESTROYED); LASSERT(list_empty(&lock->l_res_link)); LASSERT(list_empty(&lock->l_pending_chain)); @@ -220,8 +218,6 @@ void ldlm_lock_put(struct ldlm_lock *lock) lu_ref_fini(&lock->l_reference); OBD_FREE_RCU(lock, sizeof(*lock), &lock->l_handle); } - - EXIT; } EXPORT_SYMBOL(ldlm_lock_put); @@ -253,16 +249,14 @@ int ldlm_lock_remove_from_lru(struct ldlm_lock *lock) struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); int rc; - ENTRY; - if (lock->l_ns_srv) { + if (lock->l_flags & LDLM_FL_NS_SRV) { LASSERT(list_empty(&lock->l_lru)); - RETURN(0); + return 0; } spin_lock(&ns->ns_lock); rc = ldlm_lock_remove_from_lru_nolock(lock); spin_unlock(&ns->ns_lock); - EXIT; return rc; } @@ -289,11 +283,9 @@ void ldlm_lock_add_to_lru(struct ldlm_lock *lock) { struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); - ENTRY; spin_lock(&ns->ns_lock); ldlm_lock_add_to_lru_nolock(lock); spin_unlock(&ns->ns_lock); - EXIT; } /** @@ -304,10 +296,8 @@ void ldlm_lock_touch_in_lru(struct ldlm_lock *lock) { struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); - ENTRY; - if (lock->l_ns_srv) { + if (lock->l_flags & LDLM_FL_NS_SRV) { LASSERT(list_empty(&lock->l_lru)); - EXIT; return; } @@ -317,7 +307,6 @@ void ldlm_lock_touch_in_lru(struct ldlm_lock *lock) ldlm_lock_add_to_lru_nolock(lock); } spin_unlock(&ns->ns_lock); - EXIT; } /** @@ -341,8 +330,6 @@ void ldlm_lock_touch_in_lru(struct ldlm_lock *lock) */ int ldlm_lock_destroy_internal(struct ldlm_lock *lock) { - ENTRY; - if (lock->l_readers || lock->l_writers) { LDLM_ERROR(lock, "lock still has references"); LBUG(); @@ -353,12 +340,11 @@ int ldlm_lock_destroy_internal(struct ldlm_lock *lock) LBUG(); } - if (lock->l_destroyed) { + if (lock->l_flags & LDLM_FL_DESTROYED) { LASSERT(list_empty(&lock->l_lru)); - EXIT; return 0; } - lock->l_destroyed = 1; + lock->l_flags |= LDLM_FL_DESTROYED; if (lock->l_export && lock->l_export->exp_lock_hash) { /* NB: it's safe to call cfs_hash_del() even lock isn't @@ -383,7 +369,6 @@ int ldlm_lock_destroy_internal(struct ldlm_lock *lock) if (lock->l_export && lock->l_completion_ast) lock->l_completion_ast(lock, 0); #endif - EXIT; return 1; } @@ -393,7 +378,7 @@ int ldlm_lock_destroy_internal(struct ldlm_lock *lock) void ldlm_lock_destroy(struct ldlm_lock *lock) { int first; - ENTRY; + lock_res_and_lock(lock); first = ldlm_lock_destroy_internal(lock); unlock_res_and_lock(lock); @@ -403,7 +388,6 @@ void ldlm_lock_destroy(struct ldlm_lock *lock) lu_ref_del(&lock->l_reference, "hash", lock); LDLM_LOCK_RELEASE(lock); } - EXIT; } /** @@ -412,14 +396,13 @@ void ldlm_lock_destroy(struct ldlm_lock *lock) void ldlm_lock_destroy_nolock(struct ldlm_lock *lock) { int first; - ENTRY; + first = ldlm_lock_destroy_internal(lock); /* drop reference from hashtable only for first destroy */ if (first) { lu_ref_del(&lock->l_reference, "hash", lock); LDLM_LOCK_RELEASE(lock); } - EXIT; } /* this is called by portals_handle2object with the handle lock taken */ @@ -450,14 +433,13 @@ struct portals_handle_ops lock_handle_ops = { static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) { struct ldlm_lock *lock; - ENTRY; if (resource == NULL) LBUG(); OBD_SLAB_ALLOC_PTR_GFP(lock, ldlm_lock_slab, __GFP_IO); if (lock == NULL) - RETURN(NULL); + return NULL; spin_lock_init(&lock->l_lock); lock->l_resource = resource; @@ -493,7 +475,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) #endif INIT_LIST_HEAD(&lock->l_exp_list); - RETURN(lock); + return lock; } /** @@ -507,7 +489,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, struct ldlm_resource *oldres = lock->l_resource; struct ldlm_resource *newres; int type; - ENTRY; LASSERT(ns_is_client(ns)); @@ -516,7 +497,7 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, sizeof(lock->l_resource->lr_name)) == 0) { /* Nothing to do */ unlock_res_and_lock(lock); - RETURN(0); + return 0; } LASSERT(new_resid->name[0] != 0); @@ -529,7 +510,7 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, newres = ldlm_resource_get(ns, NULL, new_resid, type, 1); if (newres == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lu_ref_add(&newres->lr_reference, "lock", lock); /* @@ -557,7 +538,7 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, lu_ref_del(&oldres->lr_reference, "lock", lock); ldlm_resource_putref(oldres); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_lock_change_resource); @@ -586,19 +567,18 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, __u64 flags) { struct ldlm_lock *lock; - ENTRY; LASSERT(handle); lock = class_handle2object(handle->cookie); if (lock == NULL) - RETURN(NULL); + return NULL; /* It's unlikely but possible that someone marked the lock as * destroyed after we did handle2object on it */ - if (flags == 0 && !lock->l_destroyed) { + if (flags == 0 && ((lock->l_flags & LDLM_FL_DESTROYED)== 0)) { lu_ref_add(&lock->l_reference, "handle", current); - RETURN(lock); + return lock; } lock_res_and_lock(lock); @@ -606,24 +586,24 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, LASSERT(lock->l_resource != NULL); lu_ref_add_atomic(&lock->l_reference, "handle", current); - if (unlikely(lock->l_destroyed)) { + if (unlikely(lock->l_flags & LDLM_FL_DESTROYED)) { unlock_res_and_lock(lock); CDEBUG(D_INFO, "lock already destroyed: lock %p\n", lock); LDLM_LOCK_PUT(lock); - RETURN(NULL); + return NULL; } if (flags && (lock->l_flags & flags)) { unlock_res_and_lock(lock); LDLM_LOCK_PUT(lock); - RETURN(NULL); + return NULL; } if (flags) lock->l_flags |= flags; unlock_res_and_lock(lock); - RETURN(lock); + return lock; } EXPORT_SYMBOL(__ldlm_handle2lock); /** @} ldlm_handles */ @@ -695,7 +675,7 @@ void ldlm_add_bl_work_item(struct ldlm_lock *lock, struct ldlm_lock *new, lock->l_flags |= LDLM_FL_AST_SENT; /* If the enqueuing client said so, tell the AST recipient to * discard dirty data, rather than writing back. */ - if (new->l_flags & LDLM_AST_DISCARD_DATA) + if (new->l_flags & LDLM_FL_AST_DISCARD_DATA) lock->l_flags |= LDLM_FL_DISCARD_DATA; LASSERT(list_empty(&lock->l_bl_ast)); list_add(&lock->l_bl_ast, work_list); @@ -728,13 +708,11 @@ void ldlm_add_cp_work_item(struct ldlm_lock *lock, struct list_head *work_list) void ldlm_add_ast_work_item(struct ldlm_lock *lock, struct ldlm_lock *new, struct list_head *work_list) { - ENTRY; check_res_locked(lock->l_resource); if (new) ldlm_add_bl_work_item(lock, new, work_list); else ldlm_add_cp_work_item(lock, work_list); - EXIT; } /** @@ -853,7 +831,6 @@ void ldlm_lock_decref_internal_nolock(struct ldlm_lock *lock, __u32 mode) void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) { struct ldlm_namespace *ns; - ENTRY; lock_res_and_lock(lock); @@ -873,7 +850,7 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) (lock->l_flags & LDLM_FL_CBPENDING)) { /* If we received a blocked AST and this was the last reference, * run the callback. */ - if (lock->l_ns_srv && lock->l_export) + if ((lock->l_flags & LDLM_FL_NS_SRV) && lock->l_export) CERROR("FL_CBPENDING set on non-local lock--just a " "warning\n"); @@ -914,8 +891,6 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) LDLM_DEBUG(lock, "do not add lock into lru list"); unlock_res_and_lock(lock); } - - EXIT; } /** @@ -940,7 +915,6 @@ EXPORT_SYMBOL(ldlm_lock_decref); void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, __u32 mode) { struct ldlm_lock *lock = __ldlm_handle2lock(lockh, 0); - ENTRY; LASSERT(lock != NULL); @@ -979,7 +953,6 @@ static void search_granted_lock(struct list_head *queue, { struct list_head *tmp; struct ldlm_lock *lock, *mode_end, *policy_end; - ENTRY; list_for_each(tmp, queue) { lock = list_entry(tmp, struct ldlm_lock, l_res_link); @@ -999,7 +972,6 @@ static void search_granted_lock(struct list_head *queue, prev->res_link = &mode_end->l_res_link; prev->mode_link = &mode_end->l_sl_mode; prev->policy_link = &req->l_sl_policy; - EXIT; return; } else if (lock->l_resource->lr_type == LDLM_IBITS) { for (;;) { @@ -1018,7 +990,6 @@ static void search_granted_lock(struct list_head *queue, &policy_end->l_sl_mode; prev->policy_link = &policy_end->l_sl_policy; - EXIT; return; } @@ -1037,7 +1008,6 @@ static void search_granted_lock(struct list_head *queue, prev->res_link = &mode_end->l_res_link; prev->mode_link = &mode_end->l_sl_mode; prev->policy_link = &req->l_sl_policy; - EXIT; return; } else { LDLM_ERROR(lock,"is not LDLM_PLAIN or LDLM_IBITS lock"); @@ -1050,7 +1020,6 @@ static void search_granted_lock(struct list_head *queue, prev->res_link = queue->prev; prev->mode_link = &req->l_sl_mode; prev->policy_link = &req->l_sl_policy; - EXIT; return; } @@ -1062,14 +1031,13 @@ static void ldlm_granted_list_add_lock(struct ldlm_lock *lock, struct sl_insert_point *prev) { struct ldlm_resource *res = lock->l_resource; - ENTRY; check_res_locked(res); ldlm_resource_dump(D_INFO, res); LDLM_DEBUG(lock, "About to add lock:"); - if (lock->l_destroyed) { + if (lock->l_flags & LDLM_FL_DESTROYED) { CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n"); return; } @@ -1088,8 +1056,6 @@ static void ldlm_granted_list_add_lock(struct ldlm_lock *lock, list_add(&lock->l_sl_mode, prev->mode_link); if (&lock->l_sl_policy != prev->policy_link) list_add(&lock->l_sl_policy, prev->policy_link); - - EXIT; } /** @@ -1099,13 +1065,11 @@ static void ldlm_granted_list_add_lock(struct ldlm_lock *lock, static void ldlm_grant_lock_with_skiplist(struct ldlm_lock *lock) { struct sl_insert_point prev; - ENTRY; LASSERT(lock->l_req_mode == lock->l_granted_mode); search_granted_lock(&lock->l_resource->lr_granted, lock, &prev); ldlm_granted_list_add_lock(lock, &prev); - EXIT; } /** @@ -1122,7 +1086,6 @@ static void ldlm_grant_lock_with_skiplist(struct ldlm_lock *lock) void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list) { struct ldlm_resource *res = lock->l_resource; - ENTRY; check_res_locked(res); @@ -1141,7 +1104,6 @@ void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list) ldlm_add_ast_work_item(lock, NULL, work_list); ldlm_pool_add(&ldlm_res_to_ns(res)->ns_pool, lock); - EXIT; } /** @@ -1203,9 +1165,7 @@ static struct ldlm_lock *search_queue(struct list_head *queue, policy->l_inodebits.bits)) continue; - if (!unref && - (lock->l_destroyed || lock->l_flags & LDLM_FL_FAILED || - lock->l_failed)) + if (!unref && (lock->l_flags & LDLM_FL_GONE_MASK)) continue; if ((flags & LDLM_FL_LOCAL_ONLY) && @@ -1227,8 +1187,8 @@ static struct ldlm_lock *search_queue(struct list_head *queue, void ldlm_lock_fail_match_locked(struct ldlm_lock *lock) { - if (!lock->l_failed) { - lock->l_failed = 1; + if ((lock->l_flags & LDLM_FL_FAIL_NOTIFIED) == 0) { + lock->l_flags |= LDLM_FL_FAIL_NOTIFIED; wake_up_all(&lock->l_waitq); } } @@ -1306,7 +1266,6 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, struct ldlm_resource *res; struct ldlm_lock *lock, *old_lock = NULL; int rc = 0; - ENTRY; if (ns == NULL) { old_lock = ldlm_handle2lock(lockh); @@ -1321,7 +1280,7 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, res = ldlm_resource_get(ns, NULL, res_id, type, 0); if (res == NULL) { LASSERT(old_lock == NULL); - RETURN(0); + return 0; } LDLM_RESOURCE_ADDREF(res); @@ -1342,7 +1301,6 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, if (lock != NULL) GOTO(out, rc = 1); - EXIT; out: unlock_res(res); LDLM_RESOURCE_DELREF(res); @@ -1352,6 +1310,8 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, ldlm_lock2handle(lock, lockh); if ((flags & LDLM_FL_LVB_READY) && (!(lock->l_flags & LDLM_FL_LVB_READY))) { + __u64 wait_flags = LDLM_FL_LVB_READY | + LDLM_FL_DESTROYED | LDLM_FL_FAIL_NOTIFIED; struct l_wait_info lwi; if (lock->l_completion_ast) { int err = lock->l_completion_ast(lock, @@ -1373,8 +1333,7 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, /* XXX FIXME see comment on CAN_MATCH in lustre_dlm.h */ l_wait_event(lock->l_waitq, - lock->l_flags & LDLM_FL_LVB_READY || - lock->l_destroyed || lock->l_failed, + lock->l_flags & wait_flags, &lwi); if (!(lock->l_flags & LDLM_FL_LVB_READY)) { if (flags & LDLM_FL_TEST_LOCK) @@ -1426,13 +1385,11 @@ ldlm_mode_t ldlm_revalidate_lock_handle(struct lustre_handle *lockh, { struct ldlm_lock *lock; ldlm_mode_t mode = 0; - ENTRY; lock = ldlm_handle2lock(lockh); if (lock != NULL) { lock_res_and_lock(lock); - if (lock->l_destroyed || lock->l_flags & LDLM_FL_FAILED || - lock->l_failed) + if (lock->l_flags & LDLM_FL_GONE_MASK) GOTO(out, mode); if (lock->l_flags & LDLM_FL_CBPENDING && @@ -1445,8 +1402,6 @@ ldlm_mode_t ldlm_revalidate_lock_handle(struct lustre_handle *lockh, ldlm_lock_addref_internal_nolock(lock, mode); } - EXIT; - out: if (lock != NULL) { unlock_res_and_lock(lock); @@ -1461,7 +1416,6 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, enum req_location loc, void *data, int size) { void *lvb; - ENTRY; LASSERT(data != NULL); LASSERT(size >= 0); @@ -1479,7 +1433,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lustre_swab_ost_lvb); if (unlikely(lvb == NULL)) { LDLM_ERROR(lock, "no LVB"); - RETURN(-EPROTO); + return -EPROTO; } memcpy(data, lvb, size); @@ -1496,7 +1450,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lustre_swab_ost_lvb_v1); if (unlikely(lvb == NULL)) { LDLM_ERROR(lock, "no LVB"); - RETURN(-EPROTO); + return -EPROTO; } memcpy(data, lvb, size); @@ -1506,7 +1460,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, } else { LDLM_ERROR(lock, "Replied unexpected ost LVB size %d", size); - RETURN(-EINVAL); + return -EINVAL; } break; case LVB_T_LQUOTA: @@ -1521,14 +1475,14 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lustre_swab_lquota_lvb); if (unlikely(lvb == NULL)) { LDLM_ERROR(lock, "no LVB"); - RETURN(-EPROTO); + return -EPROTO; } memcpy(data, lvb, size); } else { LDLM_ERROR(lock, "Replied unexpected lquota LVB size %d", size); - RETURN(-EINVAL); + return -EINVAL; } break; case LVB_T_LAYOUT: @@ -1541,18 +1495,18 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lvb = req_capsule_server_get(pill, &RMF_DLM_LVB); if (unlikely(lvb == NULL)) { LDLM_ERROR(lock, "no LVB"); - RETURN(-EPROTO); + return -EPROTO; } memcpy(data, lvb, size); break; default: LDLM_ERROR(lock, "Unknown LVB type: %d\n", lock->l_lvb_type); - libcfs_debug_dumpstack(NULL); - RETURN(-EINVAL); + dump_stack(); + return -EINVAL; } - RETURN(0); + return 0; } /** @@ -1569,26 +1523,25 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, { struct ldlm_lock *lock; struct ldlm_resource *res; - ENTRY; res = ldlm_resource_get(ns, NULL, res_id, type, 1); if (res == NULL) - RETURN(NULL); + return NULL; lock = ldlm_lock_new(res); if (lock == NULL) - RETURN(NULL); + return NULL; lock->l_req_mode = mode; lock->l_ast_data = data; lock->l_pid = current_pid(); - lock->l_ns_srv = !!ns_is_server(ns); + if (ns_is_server(ns)) + lock->l_flags |= LDLM_FL_NS_SRV; if (cbs) { lock->l_blocking_ast = cbs->lcs_blocking; lock->l_completion_ast = cbs->lcs_completion; lock->l_glimpse_ast = cbs->lcs_glimpse; - lock->l_weigh_ast = cbs->lcs_weigh; } lock->l_tree_node = NULL; @@ -1609,7 +1562,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_NEW_LOCK)) GOTO(out, 0); - RETURN(lock); + return lock; out: ldlm_lock_destroy(lock); @@ -1636,7 +1589,6 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, int local = ns_is_client(ldlm_res_to_ns(res)); ldlm_error_t rc = ELDLM_OK; struct ldlm_interval *node = NULL; - ENTRY; lock->l_last_activity = cfs_time_current_sec(); /* policies are not executed on the client or during replay */ @@ -1654,11 +1606,11 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, LDLM_LOCK_RELEASE(lock); } *flags |= LDLM_FL_LOCK_CHANGED; - RETURN(0); + return 0; } else if (rc != ELDLM_OK || (rc == ELDLM_OK && (*flags & LDLM_FL_INTENT_ONLY))) { ldlm_lock_destroy(lock); - RETURN(rc); + return rc; } } @@ -1693,7 +1645,7 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, /* Some flags from the enqueue want to make it into the AST, via the * lock's l_flags. */ - lock->l_flags |= *flags & LDLM_AST_DISCARD_DATA; + lock->l_flags |= *flags & LDLM_FL_AST_DISCARD_DATA; /* This distinction between local lock trees is very important; a client * namespace only has information about locks taken by that client, and @@ -1738,10 +1690,9 @@ ldlm_work_bl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) struct ldlm_lock_desc d; int rc; struct ldlm_lock *lock; - ENTRY; if (list_empty(arg->list)) - RETURN(-ENOENT); + return -ENOENT; lock = list_entry(arg->list->next, struct ldlm_lock, l_bl_ast); @@ -1762,7 +1713,7 @@ ldlm_work_bl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) lock->l_blocking_lock = NULL; LDLM_LOCK_RELEASE(lock); - RETURN(rc); + return rc; } /** @@ -1775,10 +1726,9 @@ ldlm_work_cp_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) int rc = 0; struct ldlm_lock *lock; ldlm_completion_callback completion_callback; - ENTRY; if (list_empty(arg->list)) - RETURN(-ENOENT); + return -ENOENT; lock = list_entry(arg->list->next, struct ldlm_lock, l_cp_ast); @@ -1807,7 +1757,7 @@ ldlm_work_cp_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) rc = completion_callback(lock, 0, (void *)arg); LDLM_LOCK_RELEASE(lock); - RETURN(rc); + return rc; } /** @@ -1820,10 +1770,9 @@ ldlm_work_revoke_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) struct ldlm_lock_desc desc; int rc; struct ldlm_lock *lock; - ENTRY; if (list_empty(arg->list)) - RETURN(-ENOENT); + return -ENOENT; lock = list_entry(arg->list->next, struct ldlm_lock, l_rk_ast); list_del_init(&lock->l_rk_ast); @@ -1836,7 +1785,7 @@ ldlm_work_revoke_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) rc = lock->l_blocking_ast(lock, &desc, (void*)arg, LDLM_CB_BLOCKING); LDLM_LOCK_RELEASE(lock); - RETURN(rc); + return rc; } /** @@ -1848,10 +1797,9 @@ int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) struct ldlm_glimpse_work *gl_work; struct ldlm_lock *lock; int rc = 0; - ENTRY; if (list_empty(arg->list)) - RETURN(-ENOENT); + return -ENOENT; gl_work = list_entry(arg->list->next, struct ldlm_glimpse_work, gl_list); @@ -1871,7 +1819,7 @@ int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) if ((gl_work->gl_flags & LDLM_GL_WORK_NOFREE) == 0) OBD_FREE_PTR(gl_work); - RETURN(rc); + return rc; } /** @@ -1888,11 +1836,11 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list, int rc; if (list_empty(rpc_list)) - RETURN(0); + return 0; OBD_ALLOC_PTR(arg); if (arg == NULL) - RETURN(-ENOMEM); + return -ENOMEM; atomic_set(&arg->restart, 0); arg->list = rpc_list; @@ -1960,13 +1908,10 @@ static int ldlm_reprocess_res(cfs_hash_t *hs, cfs_hash_bd_t *bd, */ void ldlm_reprocess_all_ns(struct ldlm_namespace *ns) { - ENTRY; - if (ns != NULL) { cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_reprocess_res, NULL); } - EXIT; } EXPORT_SYMBOL(ldlm_reprocess_all_ns); @@ -1982,13 +1927,11 @@ void ldlm_reprocess_all(struct ldlm_resource *res) { LIST_HEAD(rpc_list); - ENTRY; if (!ns_is_client(ldlm_res_to_ns(res))) { CERROR("This is client-side-only module, cannot handle " "LDLM_NAMESPACE_SERVER resource type lock.\n"); LBUG(); } - EXIT; } /** @@ -2032,7 +1975,6 @@ void ldlm_lock_cancel(struct ldlm_lock *lock) { struct ldlm_resource *res; struct ldlm_namespace *ns; - ENTRY; lock_res_and_lock(lock); @@ -2046,15 +1988,15 @@ void ldlm_lock_cancel(struct ldlm_lock *lock) LBUG(); } - if (lock->l_waited) + if (lock->l_flags & LDLM_FL_WAITED) ldlm_del_waiting_lock(lock); /* Releases cancel callback. */ ldlm_cancel_callback(lock); /* Yes, second time, just in case it was added again while we were - running with no res lock in ldlm_cancel_callback */ - if (lock->l_waited) + * running with no res lock in ldlm_cancel_callback */ + if (lock->l_flags & LDLM_FL_WAITED) ldlm_del_waiting_lock(lock); ldlm_resource_unlink_lock(lock); @@ -2067,8 +2009,6 @@ void ldlm_lock_cancel(struct ldlm_lock *lock) * if not to zero out lock->l_granted_mode */ lock->l_granted_mode = LCK_MINMODE; unlock_res_and_lock(lock); - - EXIT; } EXPORT_SYMBOL(ldlm_lock_cancel); @@ -2079,7 +2019,6 @@ int ldlm_lock_set_data(struct lustre_handle *lockh, void *data) { struct ldlm_lock *lock = ldlm_handle2lock(lockh); int rc = -EINVAL; - ENTRY; if (lock) { if (lock->l_ast_data == NULL) @@ -2088,7 +2027,7 @@ int ldlm_lock_set_data(struct lustre_handle *lockh, void *data) rc = 0; LDLM_LOCK_PUT(lock); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_lock_set_data); @@ -2160,8 +2099,6 @@ void ldlm_cancel_locks_for_export(struct obd_export *exp) */ void ldlm_lock_downgrade(struct ldlm_lock *lock, int new_mode) { - ENTRY; - LASSERT(lock->l_granted_mode & (LCK_PW | LCK_EX)); LASSERT(new_mode == LCK_COS); @@ -2177,8 +2114,6 @@ void ldlm_lock_downgrade(struct ldlm_lock *lock, int new_mode) ldlm_grant_lock(lock, NULL); unlock_res_and_lock(lock); ldlm_reprocess_all(lock->l_resource); - - EXIT; } EXPORT_SYMBOL(ldlm_lock_downgrade); @@ -2197,19 +2132,19 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode, struct ldlm_namespace *ns; int granted = 0; struct ldlm_interval *node; - ENTRY; /* Just return if mode is unchanged. */ if (new_mode == lock->l_granted_mode) { *flags |= LDLM_FL_BLOCK_GRANTED; - RETURN(lock->l_resource); + return lock->l_resource; } /* I can't check the type of lock here because the bitlock of lock * is not held here, so do the allocation blindly. -jay */ OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, __GFP_IO); - if (node == NULL) /* Actually, this causes EDEADLOCK to be returned */ - RETURN(NULL); + if (node == NULL) + /* Actually, this causes EDEADLOCK to be returned */ + return NULL; LASSERTF((new_mode == LCK_PW && lock->l_granted_mode == LCK_PR), "new_mode %u, granted %u\n", new_mode, lock->l_granted_mode); @@ -2268,7 +2203,7 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode, ldlm_run_ast_work(ns, &rpc_list, LDLM_WORK_CP_AST); if (node) OBD_SLAB_FREE(node, ldlm_interval_slab, sizeof(*node)); - RETURN(res); + return res; } EXPORT_SYMBOL(ldlm_lock_convert); @@ -2337,91 +2272,90 @@ 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: "LPU64"/"LPU64" 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", - ldlm_lock_to_ns_name(lock), lock, - lock->l_handle.h_cookie, atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - resource->lr_name.name[0], - resource->lr_name.name[1], - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_policy_data.l_extent.start, - lock->l_policy_data.l_extent.end, - lock->l_req_extent.start, lock->l_req_extent.end, - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); + " 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", + ldlm_lock_to_ns_name(lock), lock, + lock->l_handle.h_cookie, atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_policy_data.l_extent.start, + lock->l_policy_data.l_extent.end, + lock->l_req_extent.start, lock->l_req_extent.end, + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); break; case LDLM_FLOCK: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " - "res: "LPU64"/"LPU64" rrc: %d type: %s pid: %d " - "["LPU64"->"LPU64"] flags: "LPX64" nid: %s remote: "LPX64 - " 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, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - resource->lr_name.name[0], - resource->lr_name.name[1], - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_policy_data.l_flock.pid, - lock->l_policy_data.l_flock.start, - lock->l_policy_data.l_flock.end, - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout); + " ns: %s lock: %p/"LPX64" 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", + ldlm_lock_to_ns_name(lock), lock, + lock->l_handle.h_cookie, atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_policy_data.l_flock.pid, + lock->l_policy_data.l_flock.start, + lock->l_policy_data.l_flock.end, + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout); break; case LDLM_IBITS: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " - "res: "LPU64"/"LPU64" bits "LPX64" rrc: %d type: %s " - "flags: "LPX64" nid: %s remote: "LPX64" 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, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - resource->lr_name.name[0], - resource->lr_name.name[1], - lock->l_policy_data.l_inodebits.bits, - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); + " 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 " + "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, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + lock->l_policy_data.l_inodebits.bits, + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); break; default: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " - "res: "LPU64"/"LPU64" rrc: %d type: %s flags: "LPX64" " - "nid: %s remote: "LPX64" 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, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - resource->lr_name.name[0], - resource->lr_name.name[1], - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); + " 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 " + "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, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); break; } va_end(args); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 324d5e4286d..a100a0b9638 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -127,12 +127,12 @@ struct ldlm_bl_work_item { int ldlm_del_waiting_lock(struct ldlm_lock *lock) { - RETURN(0); + return 0; } int ldlm_refresh_waiting_lock(struct ldlm_lock *lock, int timeout) { - RETURN(0); + return 0; } @@ -146,7 +146,6 @@ void ldlm_handle_bl_callback(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, struct ldlm_lock *lock) { int do_ast; - ENTRY; LDLM_DEBUG(lock, "client blocking AST callback handler"); @@ -172,7 +171,6 @@ void ldlm_handle_bl_callback(struct ldlm_namespace *ns, LDLM_DEBUG(lock, "client blocking callback handler END"); LDLM_LOCK_RELEASE(lock); - EXIT; } /** @@ -188,7 +186,6 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, int lvb_len; LIST_HEAD(ast_list); int rc = 0; - ENTRY; LDLM_DEBUG(lock, "client completion callback handler START"); @@ -198,7 +195,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, schedule_timeout_and_set_state( TASK_INTERRUPTIBLE, to); if (lock->l_granted_mode == lock->l_req_mode || - lock->l_destroyed) + lock->l_flags & LDLM_FL_DESTROYED) break; } } @@ -238,7 +235,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, } lock_res_and_lock(lock); - if (lock->l_destroyed || + if ((lock->l_flags & LDLM_FL_DESTROYED) || lock->l_granted_mode == lock->l_req_mode) { /* bug 11300: the lock has already been granted */ unlock_res_and_lock(lock); @@ -332,7 +329,6 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req, struct ldlm_lock *lock) { int rc = -ENOSYS; - ENTRY; LDLM_DEBUG(lock, "client glimpse AST callback handler"); @@ -356,12 +352,10 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req, if (ldlm_bl_to_thread_lock(ns, NULL, lock)) ldlm_handle_bl_callback(ns, NULL, lock); - EXIT; return; } unlock_res_and_lock(lock); LDLM_LOCK_RELEASE(lock); - EXIT; } static int ldlm_callback_reply(struct ptlrpc_request *req, int rc) @@ -382,7 +376,6 @@ static int __ldlm_bl_to_thread(struct ldlm_bl_work_item *blwi, ldlm_cancel_flags_t cancel_flags) { struct ldlm_bl_pool *blp = ldlm_state->ldlm_bl_pool; - ENTRY; spin_lock(&blp->blp_lock); if (blwi->blwi_lock && @@ -402,7 +395,7 @@ static int __ldlm_bl_to_thread(struct ldlm_bl_work_item *blwi, if (!(cancel_flags & LCF_ASYNC)) wait_for_completion(&blwi->blwi_comp); - RETURN(0); + return 0; } static inline void init_blwi(struct ldlm_bl_work_item *blwi, @@ -446,20 +439,18 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns, struct list_head *cancels, int count, ldlm_cancel_flags_t cancel_flags) { - ENTRY; - if (cancels && count == 0) - RETURN(0); + return 0; if (cancel_flags & LCF_ASYNC) { struct ldlm_bl_work_item *blwi; OBD_ALLOC(blwi, sizeof(*blwi)); if (blwi == NULL) - RETURN(-ENOMEM); + return -ENOMEM; init_blwi(blwi, ns, ld, cancels, count, lock, cancel_flags); - RETURN(__ldlm_bl_to_thread(blwi, cancel_flags)); + return __ldlm_bl_to_thread(blwi, cancel_flags); } else { /* if it is synchronous call do minimum mem alloc, as it could * be triggered from kernel shrinker @@ -468,7 +459,7 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns, memset(&blwi, 0, sizeof(blwi)); init_blwi(&blwi, ns, ld, cancels, count, lock, cancel_flags); - RETURN(__ldlm_bl_to_thread(&blwi, cancel_flags)); + return __ldlm_bl_to_thread(&blwi, cancel_flags); } } @@ -494,7 +485,6 @@ static int ldlm_handle_setinfo(struct ptlrpc_request *req) void *val; int keylen, vallen; int rc = -ENOSYS; - ENTRY; DEBUG_REQ(D_HSM, req, "%s: handle setinfo\n", obd->obd_name); @@ -503,14 +493,14 @@ static int ldlm_handle_setinfo(struct ptlrpc_request *req) key = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); if (key == NULL) { DEBUG_REQ(D_IOCTL, req, "no set_info key"); - RETURN(-EFAULT); + return -EFAULT; } keylen = req_capsule_get_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT); val = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL); if (val == NULL) { DEBUG_REQ(D_IOCTL, req, "no set_info val"); - RETURN(-EFAULT); + return -EFAULT; } vallen = req_capsule_get_size(&req->rq_pill, &RMF_SETINFO_VAL, RCL_CLIENT); @@ -552,9 +542,11 @@ static int ldlm_handle_qc_callback(struct ptlrpc_request *req) oqctl = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); if (oqctl == NULL) { CERROR("Can't unpack obd_quotactl\n"); - RETURN(-EPROTO); + return -EPROTO; } + oqctl->qc_stat = ptlrpc_status_ntoh(oqctl->qc_stat); + cli->cl_qchk_stat = oqctl->qc_stat; return 0; } @@ -566,7 +558,6 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) struct ldlm_request *dlm_req; struct ldlm_lock *lock; int rc; - ENTRY; /* Requests arrive in sender's byte order. The ptlrpc service * handler has already checked and, if necessary, byte-swapped the @@ -575,7 +566,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) /* do nothing for sec context finalize */ if (lustre_msg_get_opc(req->rq_reqmsg) == SEC_CTX_FINI) - RETURN(0); + return 0; req_capsule_init(&req->rq_pill, req, RCL_SERVER); @@ -583,7 +574,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) rc = ldlm_callback_reply(req, -ENOTCONN); ldlm_callback_errmsg(req, "Operate on unconnected server", rc, NULL); - RETURN(0); + return 0; } LASSERT(req->rq_export != NULL); @@ -592,71 +583,71 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) switch (lustre_msg_get_opc(req->rq_reqmsg)) { case LDLM_BL_CALLBACK: if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_BL_CALLBACK_NET)) - RETURN(0); + return 0; break; case LDLM_CP_CALLBACK: if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CP_CALLBACK_NET)) - RETURN(0); + return 0; break; case LDLM_GL_CALLBACK: if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_GL_CALLBACK_NET)) - RETURN(0); + return 0; break; case LDLM_SET_INFO: rc = ldlm_handle_setinfo(req); ldlm_callback_reply(req, rc); - RETURN(0); + return 0; case OBD_LOG_CANCEL: /* remove this eventually - for 1.4.0 compat */ CERROR("shouldn't be handling OBD_LOG_CANCEL on DLM thread\n"); req_capsule_set(&req->rq_pill, &RQF_LOG_CANCEL); if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOG_CANCEL_NET)) - RETURN(0); + return 0; rc = llog_origin_handle_cancel(req); if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOG_CANCEL_REP)) - RETURN(0); + return 0; ldlm_callback_reply(req, rc); - RETURN(0); + return 0; case LLOG_ORIGIN_HANDLE_CREATE: req_capsule_set(&req->rq_pill, &RQF_LLOG_ORIGIN_HANDLE_CREATE); if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET)) - RETURN(0); + return 0; rc = llog_origin_handle_open(req); ldlm_callback_reply(req, rc); - RETURN(0); + return 0; case LLOG_ORIGIN_HANDLE_NEXT_BLOCK: req_capsule_set(&req->rq_pill, &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK); if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET)) - RETURN(0); + return 0; rc = llog_origin_handle_next_block(req); ldlm_callback_reply(req, rc); - RETURN(0); + return 0; case LLOG_ORIGIN_HANDLE_READ_HEADER: req_capsule_set(&req->rq_pill, &RQF_LLOG_ORIGIN_HANDLE_READ_HEADER); if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET)) - RETURN(0); + return 0; rc = llog_origin_handle_read_header(req); ldlm_callback_reply(req, rc); - RETURN(0); + return 0; case LLOG_ORIGIN_HANDLE_CLOSE: if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET)) - RETURN(0); + return 0; rc = llog_origin_handle_close(req); ldlm_callback_reply(req, rc); - RETURN(0); + return 0; case OBD_QC_CALLBACK: req_capsule_set(&req->rq_pill, &RQF_QC_CALLBACK); if (OBD_FAIL_CHECK(OBD_FAIL_OBD_QC_CALLBACK_NET)) - RETURN(0); + return 0; rc = ldlm_handle_qc_callback(req); ldlm_callback_reply(req, rc); - RETURN(0); + return 0; default: CERROR("unknown opcode %u\n", lustre_msg_get_opc(req->rq_reqmsg)); ldlm_callback_reply(req, -EPROTO); - RETURN(0); + return 0; } ns = req->rq_export->exp_obd->obd_namespace; @@ -669,7 +660,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) rc = ldlm_callback_reply(req, -EPROTO); ldlm_callback_errmsg(req, "Operate without parameter", rc, NULL); - RETURN(0); + return 0; } /* Force a known safe race, send a cancel to the server for a lock @@ -688,7 +679,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) rc = ldlm_callback_reply(req, -EINVAL); ldlm_callback_errmsg(req, "Operate with invalid parameter", rc, &dlm_req->lock_handle[0]); - RETURN(0); + return 0; } if ((lock->l_flags & LDLM_FL_FAIL_LOC) && @@ -715,7 +706,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) rc = ldlm_callback_reply(req, -EINVAL); ldlm_callback_errmsg(req, "Operate on stale lock", rc, &dlm_req->lock_handle[0]); - RETURN(0); + return 0; } /* BL_AST locks are not needed in LRU. * Let ldlm_cancel_lru() be fast. */ @@ -761,7 +752,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) LBUG(); /* checked above */ } - RETURN(0); + return 0; } @@ -805,13 +796,13 @@ static int ldlm_bl_thread_main(void *arg); static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp) { struct ldlm_bl_thread_data bltd = { .bltd_blp = blp }; - task_t *task; + struct task_struct *task; init_completion(&bltd.bltd_comp); bltd.bltd_num = atomic_read(&blp->blp_num_threads); - snprintf(bltd.bltd_name, sizeof(bltd.bltd_name) - 1, + snprintf(bltd.bltd_name, sizeof(bltd.bltd_name), "ldlm_bl_%02d", bltd.bltd_num); - task = kthread_run(ldlm_bl_thread_main, &bltd, bltd.bltd_name); + task = kthread_run(ldlm_bl_thread_main, &bltd, "%s", bltd.bltd_name); if (IS_ERR(task)) { CERROR("cannot start LDLM thread ldlm_bl_%02d: rc %ld\n", atomic_read(&blp->blp_num_threads), PTR_ERR(task)); @@ -832,7 +823,6 @@ static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp) static int ldlm_bl_thread_main(void *arg) { struct ldlm_bl_pool *blp; - ENTRY; { struct ldlm_bl_thread_data *bltd = arg; @@ -904,7 +894,7 @@ static int ldlm_bl_thread_main(void *arg) atomic_dec(&blp->blp_busy_threads); atomic_dec(&blp->blp_num_threads); complete(&blp->blp_comp); - RETURN(0); + return 0; } @@ -914,7 +904,7 @@ static int ldlm_cleanup(void); int ldlm_get_ref(void) { int rc = 0; - ENTRY; + mutex_lock(&ldlm_ref_mutex); if (++ldlm_refcount == 1) { rc = ldlm_setup(); @@ -923,13 +913,12 @@ int ldlm_get_ref(void) } mutex_unlock(&ldlm_ref_mutex); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_get_ref); void ldlm_put_ref(void) { - ENTRY; mutex_lock(&ldlm_ref_mutex); if (ldlm_refcount == 1) { int rc = ldlm_cleanup(); @@ -941,8 +930,6 @@ void ldlm_put_ref(void) ldlm_refcount--; } mutex_unlock(&ldlm_ref_mutex); - - EXIT; } EXPORT_SYMBOL(ldlm_put_ref); @@ -1016,8 +1003,6 @@ static cfs_hash_ops_t ldlm_export_lock_ops = { int ldlm_init_export(struct obd_export *exp) { - ENTRY; - exp->exp_lock_hash = cfs_hash_create(obd_uuid2str(&exp->exp_client_uuid), HASH_EXP_LOCK_CUR_BITS, @@ -1029,20 +1014,18 @@ int ldlm_init_export(struct obd_export *exp) CFS_HASH_NBLK_CHANGE); if (!exp->exp_lock_hash) - RETURN(-ENOMEM); + return -ENOMEM; - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_init_export); void ldlm_destroy_export(struct obd_export *exp) { - ENTRY; cfs_hash_putref(exp->exp_lock_hash); exp->exp_lock_hash = NULL; ldlm_destroy_flock_export(exp); - EXIT; } EXPORT_SYMBOL(ldlm_destroy_export); @@ -1052,14 +1035,13 @@ static int ldlm_setup(void) struct ldlm_bl_pool *blp = NULL; int rc = 0; int i; - ENTRY; if (ldlm_state != NULL) - RETURN(-EALREADY); + return -EALREADY; OBD_ALLOC(ldlm_state, sizeof(*ldlm_state)); if (ldlm_state == NULL) - RETURN(-ENOMEM); + return -ENOMEM; #ifdef LPROCFS rc = ldlm_proc_setup(); @@ -1139,23 +1121,21 @@ static int ldlm_setup(void) CERROR("Failed to initialize LDLM pools: %d\n", rc); GOTO(out, rc); } - RETURN(0); + return 0; out: ldlm_cleanup(); - RETURN(rc); + return rc; } static int ldlm_cleanup(void) { - ENTRY; - if (!list_empty(ldlm_namespace_list(LDLM_NAMESPACE_SERVER)) || !list_empty(ldlm_namespace_list(LDLM_NAMESPACE_CLIENT))) { CERROR("ldlm still has namespaces; clean these up first.\n"); ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE); ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE); - RETURN(-EBUSY); + return -EBUSY; } ldlm_pools_fini(); @@ -1188,7 +1168,7 @@ static int ldlm_cleanup(void) OBD_FREE(ldlm_state, sizeof(*ldlm_state)); ldlm_state = NULL; - RETURN(0); + return 0; } int ldlm_init(void) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index b3b60288e5f..0025ee6356d 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -142,7 +142,7 @@ */ #define LDLM_POOL_SLV_SHIFT (10) -extern proc_dir_entry_t *ldlm_ns_proc_dir; +extern struct proc_dir_entry *ldlm_ns_proc_dir; static inline __u64 dru(__u64 val, __u32 shift, int round_up) { @@ -335,17 +335,16 @@ static void ldlm_srv_pool_push_slv(struct ldlm_pool *pl) static int ldlm_srv_pool_recalc(struct ldlm_pool *pl) { time_t recalc_interval_sec; - ENTRY; recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) - RETURN(0); + return 0; spin_lock(&pl->pl_lock); recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) { spin_unlock(&pl->pl_lock); - RETURN(0); + return 0; } /* * Recalc SLV after last period. This should be done @@ -367,7 +366,7 @@ static int ldlm_srv_pool_recalc(struct ldlm_pool *pl) lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT, recalc_interval_sec); spin_unlock(&pl->pl_lock); - RETURN(0); + return 0; } /** @@ -394,7 +393,7 @@ static int ldlm_srv_pool_shrink(struct ldlm_pool *pl, * and can't cancel anything. Let's catch this race. */ if (atomic_read(&pl->pl_granted) == 0) - RETURN(0); + return 0; spin_lock(&pl->pl_lock); @@ -473,11 +472,10 @@ static void ldlm_cli_pool_pop_slv(struct ldlm_pool *pl) static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) { time_t recalc_interval_sec; - ENTRY; recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) - RETURN(0); + return 0; spin_lock(&pl->pl_lock); /* @@ -486,7 +484,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) { spin_unlock(&pl->pl_lock); - RETURN(0); + return 0; } /* @@ -503,7 +501,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) * Do not cancel locks in case lru resize is disabled for this ns. */ if (!ns_connect_lru_resize(ldlm_pl2ns(pl))) - RETURN(0); + return 0; /* * In the time of canceling locks on client we do not need to maintain @@ -511,8 +509,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) * It may be called when SLV has changed much, this is why we do not * take into account pl->pl_recalc_time here. */ - RETURN(ldlm_cancel_lru(ldlm_pl2ns(pl), 0, LCF_ASYNC, - LDLM_CANCEL_LRUR)); + return ldlm_cancel_lru(ldlm_pl2ns(pl), 0, LCF_ASYNC, LDLM_CANCEL_LRUR); } /** @@ -524,7 +521,7 @@ static int ldlm_cli_pool_shrink(struct ldlm_pool *pl, int nr, unsigned int gfp_mask) { struct ldlm_namespace *ns; - int canceled = 0, unused; + int unused; ns = ldlm_pl2ns(pl); @@ -532,7 +529,7 @@ static int ldlm_cli_pool_shrink(struct ldlm_pool *pl, * Do not cancel locks in case lru resize is disabled for this ns. */ if (!ns_connect_lru_resize(ns)) - RETURN(0); + return 0; /* * Make sure that pool knows last SLV and Limit from obd. @@ -543,14 +540,10 @@ static int ldlm_cli_pool_shrink(struct ldlm_pool *pl, unused = ns->ns_nr_unused; spin_unlock(&ns->ns_lock); - if (nr) { - canceled = ldlm_cancel_lru(ns, nr, LCF_ASYNC, - LDLM_CANCEL_SHRINK); - } - /* - * Return the number of potentially reclaimable locks. - */ - return ((unused - canceled) / 100) * sysctl_vfs_cache_pressure; + if (nr == 0) + return (unused / 100) * sysctl_vfs_cache_pressure; + else + return ldlm_cancel_lru(ns, nr, LCF_ASYNC, LDLM_CANCEL_SHRINK); } struct ldlm_pool_ops ldlm_srv_pool_ops = { @@ -578,7 +571,6 @@ int ldlm_pool_recalc(struct ldlm_pool *pl) goto recalc; spin_lock(&pl->pl_lock); - recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; if (recalc_interval_sec > 0) { /* * Update pool statistics every 1s. @@ -598,16 +590,17 @@ int ldlm_pool_recalc(struct ldlm_pool *pl) count = pl->pl_ops->po_recalc(pl); lprocfs_counter_add(pl->pl_stats, LDLM_POOL_RECALC_STAT, count); - return count; } + recalc_interval_sec = pl->pl_recalc_time - cfs_time_current_sec() + + pl->pl_recalc_period; - return 0; + return recalc_interval_sec; } -EXPORT_SYMBOL(ldlm_pool_recalc); -/** +/* * Pool shrink wrapper. Will call either client or server pool recalc callback - * depending what pool \a pl is used. + * depending what pool pl is used. When nr == 0, just return the number of + * freeable locks. Otherwise, return the number of canceled locks. */ int ldlm_pool_shrink(struct ldlm_pool *pl, int nr, unsigned int gfp_mask) @@ -734,11 +727,10 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) struct lprocfs_vars pool_vars[2]; char *var_name = NULL; int rc = 0; - ENTRY; OBD_ALLOC(var_name, MAX_STRING_SIZE + 1); if (!var_name) - RETURN(-ENOMEM); + return -ENOMEM; parent_ns_proc = ns->ns_proc_dir_entry; if (parent_ns_proc == NULL) { @@ -751,6 +743,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) if (IS_ERR(pl->pl_proc_dir)) { CERROR("LProcFS failed in ldlm-pool-init\n"); rc = PTR_ERR(pl->pl_proc_dir); + pl->pl_proc_dir = NULL; GOTO(out_free_name, rc); } @@ -813,7 +806,6 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) "recalc_timing", "sec"); rc = lprocfs_register_stats(pl->pl_proc_dir, "stats", pl->pl_stats); - EXIT; out_free_name: OBD_FREE(var_name, MAX_STRING_SIZE + 1); return rc; @@ -835,7 +827,6 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, int idx, ldlm_side_t client) { int rc; - ENTRY; spin_lock_init(&pl->pl_lock); atomic_set(&pl->pl_granted, 0); @@ -863,17 +854,16 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, pl->pl_client_lock_volume = 0; rc = ldlm_pool_proc_init(pl); if (rc) - RETURN(rc); + return rc; CDEBUG(D_DLMTRACE, "Lock pool %s is initialized\n", pl->pl_name); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_pool_init); void ldlm_pool_fini(struct ldlm_pool *pl) { - ENTRY; ldlm_pool_proc_fini(pl); /* @@ -882,7 +872,6 @@ void ldlm_pool_fini(struct ldlm_pool *pl) * any abnormal using cases. */ POISON(pl, 0x5a, sizeof(*pl)); - EXIT; } EXPORT_SYMBOL(ldlm_pool_fini); @@ -1025,37 +1014,32 @@ static int ldlm_pool_granted(struct ldlm_pool *pl) } static struct ptlrpc_thread *ldlm_pools_thread; -static struct shrinker *ldlm_pools_srv_shrinker; -static struct shrinker *ldlm_pools_cli_shrinker; static struct completion ldlm_pools_comp; /* - * Cancel \a nr locks from all namespaces (if possible). Returns number of - * cached locks after shrink is finished. All namespaces are asked to - * cancel approximately equal amount of locks to keep balancing. + * count locks from all namespaces (if possible). Returns number of + * cached locks. */ -static int ldlm_pools_shrink(ldlm_side_t client, int nr, - unsigned int gfp_mask) +static unsigned long ldlm_pools_count(ldlm_side_t client, unsigned int gfp_mask) { - int total = 0, cached = 0, nr_ns; + int total = 0, nr_ns; struct ldlm_namespace *ns; + struct ldlm_namespace *ns_old = NULL; /* loop detection */ void *cookie; - if (client == LDLM_NAMESPACE_CLIENT && nr != 0 && - !(gfp_mask & __GFP_FS)) - return -1; + if (client == LDLM_NAMESPACE_CLIENT && !(gfp_mask & __GFP_FS)) + return 0; - CDEBUG(D_DLMTRACE, "Request to shrink %d %s locks from all pools\n", - nr, client == LDLM_NAMESPACE_CLIENT ? "client" : "server"); + CDEBUG(D_DLMTRACE, "Request to count %s locks from all pools\n", + client == LDLM_NAMESPACE_CLIENT ? "client" : "server"); cookie = cl_env_reenter(); /* * Find out how many resources we may release. */ - for (nr_ns = atomic_read(ldlm_namespace_nr(client)); - nr_ns > 0; nr_ns--) - { + for (nr_ns = ldlm_namespace_nr_read(client); + nr_ns > 0; nr_ns--) { mutex_lock(ldlm_namespace_lock(client)); if (list_empty(ldlm_namespace_list(client))) { mutex_unlock(ldlm_namespace_lock(client)); @@ -1063,24 +1047,49 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr, return 0; } ns = ldlm_namespace_first_locked(client); + + if (ns == ns_old) { + mutex_unlock(ldlm_namespace_lock(client)); + break; + } + + if (ldlm_ns_empty(ns)) { + ldlm_namespace_move_to_inactive_locked(ns, client); + mutex_unlock(ldlm_namespace_lock(client)); + continue; + } + + if (ns_old == NULL) + ns_old = ns; + ldlm_namespace_get(ns); - ldlm_namespace_move_locked(ns, client); + ldlm_namespace_move_to_active_locked(ns, client); mutex_unlock(ldlm_namespace_lock(client)); total += ldlm_pool_shrink(&ns->ns_pool, 0, gfp_mask); ldlm_namespace_put(ns); } - if (nr == 0 || total == 0) { - cl_env_reexit(cookie); - return total; - } + cl_env_reexit(cookie); + return total; +} + +static unsigned long ldlm_pools_scan(ldlm_side_t client, int nr, unsigned int gfp_mask) +{ + unsigned long freed = 0; + int tmp, nr_ns; + struct ldlm_namespace *ns; + void *cookie; + + if (client == LDLM_NAMESPACE_CLIENT && !(gfp_mask & __GFP_FS)) + return -1; + + cookie = cl_env_reenter(); /* - * Shrink at least ldlm_namespace_nr(client) namespaces. + * Shrink at least ldlm_namespace_nr_read(client) namespaces. */ - for (nr_ns = atomic_read(ldlm_namespace_nr(client)); - nr_ns > 0; nr_ns--) - { + for (tmp = nr_ns = ldlm_namespace_nr_read(client); + tmp > 0; tmp--) { int cancel, nr_locks; /* @@ -1089,50 +1098,59 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr, mutex_lock(ldlm_namespace_lock(client)); if (list_empty(ldlm_namespace_list(client))) { mutex_unlock(ldlm_namespace_lock(client)); - /* - * If list is empty, we can't return any @cached > 0, - * that probably would cause needless shrinker - * call. - */ - cached = 0; break; } ns = ldlm_namespace_first_locked(client); ldlm_namespace_get(ns); - ldlm_namespace_move_locked(ns, client); + ldlm_namespace_move_to_active_locked(ns, client); mutex_unlock(ldlm_namespace_lock(client)); nr_locks = ldlm_pool_granted(&ns->ns_pool); - cancel = 1 + nr_locks * nr / total; - ldlm_pool_shrink(&ns->ns_pool, cancel, gfp_mask); - cached += ldlm_pool_granted(&ns->ns_pool); + /* + * We use to shrink propotionally but with new shrinker API, + * we lost the total number of freeable locks. + */ + cancel = 1 + min_t(int, nr_locks, nr / nr_ns); + freed += ldlm_pool_shrink(&ns->ns_pool, cancel, gfp_mask); ldlm_namespace_put(ns); } cl_env_reexit(cookie); - /* we only decrease the SLV in server pools shrinker, return -1 to - * kernel to avoid needless loop. LU-1128 */ - return (client == LDLM_NAMESPACE_SERVER) ? -1 : cached; + /* + * we only decrease the SLV in server pools shrinker, return + * SHRINK_STOP to kernel to avoid needless loop. LU-1128 + */ + return (client == LDLM_NAMESPACE_SERVER) ? SHRINK_STOP : freed; +} + +static unsigned long ldlm_pools_srv_count(struct shrinker *s, struct shrink_control *sc) +{ + return ldlm_pools_count(LDLM_NAMESPACE_SERVER, sc->gfp_mask); +} + +static unsigned long ldlm_pools_srv_scan(struct shrinker *s, struct shrink_control *sc) +{ + return ldlm_pools_scan(LDLM_NAMESPACE_SERVER, sc->nr_to_scan, + sc->gfp_mask); } -static int ldlm_pools_srv_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask)) +static unsigned long ldlm_pools_cli_count(struct shrinker *s, struct shrink_control *sc) { - return ldlm_pools_shrink(LDLM_NAMESPACE_SERVER, - shrink_param(sc, nr_to_scan), - shrink_param(sc, gfp_mask)); + return ldlm_pools_count(LDLM_NAMESPACE_CLIENT, sc->gfp_mask); } -static int ldlm_pools_cli_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask)) +static unsigned long ldlm_pools_cli_scan(struct shrinker *s, struct shrink_control *sc) { - return ldlm_pools_shrink(LDLM_NAMESPACE_CLIENT, - shrink_param(sc, nr_to_scan), - shrink_param(sc, gfp_mask)); + return ldlm_pools_scan(LDLM_NAMESPACE_CLIENT, sc->nr_to_scan, + sc->gfp_mask); } -void ldlm_pools_recalc(ldlm_side_t client) +int ldlm_pools_recalc(ldlm_side_t client) { __u32 nr_l = 0, nr_p = 0, l; struct ldlm_namespace *ns; + struct ldlm_namespace *ns_old = NULL; int nr, equal = 0; + int time = 50; /* seconds of sleep if no active namespaces */ /* * No need to setup pool limit for client pools. @@ -1190,16 +1208,14 @@ void ldlm_pools_recalc(ldlm_side_t client) * for _all_ pools. */ l = LDLM_POOL_HOST_L / - atomic_read( - ldlm_namespace_nr(client)); + ldlm_namespace_nr_read(client); } else { /* * All the rest of greedy pools will have * all locks in equal parts. */ l = (LDLM_POOL_HOST_L - nr_l) / - (atomic_read( - ldlm_namespace_nr(client)) - + (ldlm_namespace_nr_read(client) - nr_p); } ldlm_pool_setup(&ns->ns_pool, l); @@ -1208,9 +1224,9 @@ void ldlm_pools_recalc(ldlm_side_t client) } /* - * Recalc at least ldlm_namespace_nr(client) namespaces. + * Recalc at least ldlm_namespace_nr_read(client) namespaces. */ - for (nr = atomic_read(ldlm_namespace_nr(client)); nr > 0; nr--) { + for (nr = ldlm_namespace_nr_read(client); nr > 0; nr--) { int skip; /* * Lock the list, get first @ns in the list, getref, move it @@ -1226,6 +1242,30 @@ void ldlm_pools_recalc(ldlm_side_t client) } ns = ldlm_namespace_first_locked(client); + if (ns_old == ns) { /* Full pass complete */ + mutex_unlock(ldlm_namespace_lock(client)); + break; + } + + /* We got an empty namespace, need to move it back to inactive + * list. + * The race with parallel resource creation is fine: + * - If they do namespace_get before our check, we fail the + * check and they move this item to the end of the list anyway + * - If we do the check and then they do namespace_get, then + * we move the namespace to inactive and they will move + * it back to active (synchronised by the lock, so no clash + * there). + */ + if (ldlm_ns_empty(ns)) { + ldlm_namespace_move_to_inactive_locked(ns, client); + mutex_unlock(ldlm_namespace_lock(client)); + continue; + } + + if (ns_old == NULL) + ns_old = ns; + spin_lock(&ns->ns_lock); /* * skip ns which is being freed, and we don't want to increase @@ -1239,24 +1279,29 @@ void ldlm_pools_recalc(ldlm_side_t client) } spin_unlock(&ns->ns_lock); - ldlm_namespace_move_locked(ns, client); + ldlm_namespace_move_to_active_locked(ns, client); mutex_unlock(ldlm_namespace_lock(client)); /* * After setup is done - recalc the pool. */ if (!skip) { - ldlm_pool_recalc(&ns->ns_pool); + int ttime = ldlm_pool_recalc(&ns->ns_pool); + + if (ttime < time) + time = ttime; + ldlm_namespace_put(ns); } } + return time; } EXPORT_SYMBOL(ldlm_pools_recalc); static int ldlm_pools_thread_main(void *arg) { struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg; - ENTRY; + int s_time, c_time; thread_set_flags(thread, SVC_RUNNING); wake_up(&thread->t_ctl_waitq); @@ -1270,14 +1315,14 @@ static int ldlm_pools_thread_main(void *arg) /* * Recal all pools on this tick. */ - ldlm_pools_recalc(LDLM_NAMESPACE_SERVER); - ldlm_pools_recalc(LDLM_NAMESPACE_CLIENT); + s_time = ldlm_pools_recalc(LDLM_NAMESPACE_SERVER); + c_time = ldlm_pools_recalc(LDLM_NAMESPACE_CLIENT); /* * Wait until the next check time, or until we're * stopped. */ - lwi = LWI_TIMEOUT(cfs_time_seconds(LDLM_POOLS_THREAD_PERIOD), + lwi = LWI_TIMEOUT(cfs_time_seconds(min(s_time, c_time)), NULL, NULL); l_wait_event(thread->t_ctl_waitq, thread_is_stopping(thread) || @@ -1302,15 +1347,14 @@ static int ldlm_pools_thread_main(void *arg) static int ldlm_pools_thread_start(void) { struct l_wait_info lwi = { 0 }; - task_t *task; - ENTRY; + struct task_struct *task; if (ldlm_pools_thread != NULL) - RETURN(-EALREADY); + return -EALREADY; OBD_ALLOC_PTR(ldlm_pools_thread); if (ldlm_pools_thread == NULL) - RETURN(-ENOMEM); + return -ENOMEM; init_completion(&ldlm_pools_comp); init_waitqueue_head(&ldlm_pools_thread->t_ctl_waitq); @@ -1321,19 +1365,16 @@ static int ldlm_pools_thread_start(void) CERROR("Can't start pool thread, error %ld\n", PTR_ERR(task)); OBD_FREE(ldlm_pools_thread, sizeof(*ldlm_pools_thread)); ldlm_pools_thread = NULL; - RETURN(PTR_ERR(task)); + return PTR_ERR(task); } l_wait_event(ldlm_pools_thread->t_ctl_waitq, thread_is_running(ldlm_pools_thread), &lwi); - RETURN(0); + return 0; } static void ldlm_pools_thread_stop(void) { - ENTRY; - if (ldlm_pools_thread == NULL) { - EXIT; return; } @@ -1348,37 +1389,37 @@ static void ldlm_pools_thread_stop(void) wait_for_completion(&ldlm_pools_comp); OBD_FREE_PTR(ldlm_pools_thread); ldlm_pools_thread = NULL; - EXIT; } +static struct shrinker ldlm_pools_srv_shrinker = { + .count_objects = ldlm_pools_srv_count, + .scan_objects = ldlm_pools_srv_scan, + .seeks = DEFAULT_SEEKS, +}; + +static struct shrinker ldlm_pools_cli_shrinker = { + .count_objects = ldlm_pools_cli_count, + .scan_objects = ldlm_pools_cli_scan, + .seeks = DEFAULT_SEEKS, +}; + int ldlm_pools_init(void) { int rc; - ENTRY; rc = ldlm_pools_thread_start(); if (rc == 0) { - ldlm_pools_srv_shrinker = - set_shrinker(DEFAULT_SEEKS, - ldlm_pools_srv_shrink); - ldlm_pools_cli_shrinker = - set_shrinker(DEFAULT_SEEKS, - ldlm_pools_cli_shrink); + register_shrinker(&ldlm_pools_srv_shrinker); + register_shrinker(&ldlm_pools_cli_shrinker); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_pools_init); void ldlm_pools_fini(void) { - if (ldlm_pools_srv_shrinker != NULL) { - remove_shrinker(ldlm_pools_srv_shrinker); - ldlm_pools_srv_shrinker = NULL; - } - if (ldlm_pools_cli_shrinker != NULL) { - remove_shrinker(ldlm_pools_cli_shrinker); - ldlm_pools_cli_shrinker = NULL; - } + unregister_shrinker(&ldlm_pools_srv_shrinker); + unregister_shrinker(&ldlm_pools_cli_shrinker); ldlm_pools_thread_stop(); } EXPORT_SYMBOL(ldlm_pools_fini); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 1a690edaba0..21cb523ac4a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -94,12 +94,11 @@ int ldlm_expired_completion_wait(void *data) struct obd_import *imp; struct obd_device *obd; - ENTRY; if (lock->l_conn_export == NULL) { static cfs_time_t next_dump = 0, last_dump = 0; if (ptlrpc_check_suspend()) - RETURN(0); + return 0; LCONSOLE_WARN("lock timed out (enqueued at "CFS_TIME_T", " CFS_DURATION_T"s ago)\n", @@ -120,7 +119,7 @@ int ldlm_expired_completion_wait(void *data) if (last_dump == 0) libcfs_debug_dumplog(); } - RETURN(0); + return 0; } obd = lock->l_conn_export->exp_obd; @@ -132,7 +131,7 @@ int ldlm_expired_completion_wait(void *data) cfs_time_sub(cfs_time_current_sec(), lock->l_last_activity), obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_expired_completion_wait); @@ -160,7 +159,7 @@ static int ldlm_completion_tail(struct ldlm_lock *lock) long delay; int result; - if (lock->l_destroyed || lock->l_flags & LDLM_FL_FAILED) { + if (lock->l_flags & (LDLM_FL_DESTROYED | LDLM_FL_FAILED)) { LDLM_DEBUG(lock, "client-side enqueue: destroyed"); result = -EIO; } else { @@ -184,23 +183,21 @@ static int ldlm_completion_tail(struct ldlm_lock *lock) */ int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data) { - ENTRY; - if (flags == LDLM_FL_WAIT_NOREPROC) { LDLM_DEBUG(lock, "client-side enqueue waiting on pending lock"); - RETURN(0); + return 0; } if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED | LDLM_FL_BLOCK_CONV))) { wake_up(&lock->l_waitq); - RETURN(ldlm_completion_tail(lock)); + return ldlm_completion_tail(lock); } LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, " "going forward"); ldlm_reprocess_all(lock->l_resource); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_completion_ast_async); @@ -234,7 +231,6 @@ int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) struct l_wait_info lwi; __u32 timeout; int rc = 0; - ENTRY; if (flags == LDLM_FL_WAIT_NOREPROC) { LDLM_DEBUG(lock, "client-side enqueue waiting on pending lock"); @@ -244,7 +240,7 @@ int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED | LDLM_FL_BLOCK_CONV))) { wake_up(&lock->l_waitq); - RETURN(0); + return 0; } LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, " @@ -295,10 +291,10 @@ noreproc: if (rc) { LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)", rc); - RETURN(rc); + return rc; } - RETURN(ldlm_completion_tail(lock)); + return ldlm_completion_tail(lock); } EXPORT_SYMBOL(ldlm_completion_ast); @@ -316,7 +312,6 @@ EXPORT_SYMBOL(ldlm_completion_ast); int ldlm_blocking_ast_nocheck(struct ldlm_lock *lock) { int do_ast; - ENTRY; lock->l_flags |= LDLM_FL_CBPENDING; do_ast = (!lock->l_readers && !lock->l_writers); @@ -335,7 +330,7 @@ int ldlm_blocking_ast_nocheck(struct ldlm_lock *lock) LDLM_DEBUG(lock, "Lock still has references, will be " "cancelled later"); } - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_blocking_ast_nocheck); @@ -355,11 +350,9 @@ EXPORT_SYMBOL(ldlm_blocking_ast_nocheck); int ldlm_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, void *data, int flag) { - ENTRY; - if (flag == LDLM_CB_CANCELING) { /* Don't need to do anything here. */ - RETURN(0); + return 0; } lock_res_and_lock(lock); @@ -370,9 +363,9 @@ int ldlm_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, * early, if so. */ if (lock->l_blocking_ast != ldlm_blocking_ast) { unlock_res_and_lock(lock); - RETURN(0); + return 0; } - RETURN(ldlm_blocking_ast_nocheck(lock)); + return ldlm_blocking_ast_nocheck(lock); } EXPORT_SYMBOL(ldlm_blocking_ast); @@ -424,7 +417,6 @@ int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, .lcs_blocking = blocking, .lcs_glimpse = glimpse, }; - ENTRY; LASSERT(!(*flags & LDLM_FL_REPLAY)); if (unlikely(ns_is_client(ns))) { @@ -464,7 +456,6 @@ int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, lock->l_completion_ast(lock, *flags, NULL); LDLM_DEBUG(lock, "client-side local enqueue handler, new lock created"); - EXIT; out: LDLM_LOCK_RELEASE(lock); out_nolock: @@ -530,13 +521,12 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, struct ldlm_reply *reply; int cleanup_phase = 1; int size = 0; - ENTRY; lock = ldlm_handle2lock(lockh); /* ldlm_cli_enqueue is holding a reference on this lock. */ if (!lock) { LASSERT(type == LDLM_FLOCK); - RETURN(-ENOLCK); + return -ENOLCK; } LASSERTF(ergo(lvb_len != 0, lvb_len == lock->l_lvb_len), @@ -698,7 +688,6 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, } LDLM_DEBUG(lock, "client-side enqueue END"); - EXIT; cleanup: if (cleanup_phase == 1 && rc) failed_lock_cleanup(ns, lock, mode); @@ -763,7 +752,6 @@ int ldlm_prep_elc_req(struct obd_export *exp, struct ptlrpc_request *req, int flags, avail, to_free, pack = 0; LIST_HEAD(head); int rc; - ENTRY; if (cancels == NULL) cancels = &head; @@ -794,7 +782,7 @@ int ldlm_prep_elc_req(struct obd_export *exp, struct ptlrpc_request *req, rc = ptlrpc_request_pack(req, version, opc); if (rc) { ldlm_lock_list_put(cancels, l_bl_ast, count); - RETURN(rc); + return rc; } if (ns_connect_cancelset(ns)) { @@ -814,7 +802,7 @@ int ldlm_prep_elc_req(struct obd_export *exp, struct ptlrpc_request *req, } else { ldlm_lock_list_put(cancels, l_bl_ast, count); } - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_prep_elc_req); @@ -830,21 +818,20 @@ struct ptlrpc_request *ldlm_enqueue_pack(struct obd_export *exp, int lvb_len) { struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE); if (req == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); rc = ldlm_prep_enqueue_req(exp, req, NULL, 0); if (rc) { ptlrpc_request_free(req); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, lvb_len); ptlrpc_request_set_replen(req); - RETURN(req); + return req; } EXPORT_SYMBOL(ldlm_enqueue_pack); @@ -872,7 +859,6 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, int req_passed_in = 1; int rc, err; struct ptlrpc_request *req; - ENTRY; LASSERT(exp != NULL); @@ -888,15 +874,14 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, } else { const struct ldlm_callback_suite cbs = { .lcs_completion = einfo->ei_cb_cp, - .lcs_blocking = einfo->ei_cb_bl, - .lcs_glimpse = einfo->ei_cb_gl, - .lcs_weigh = einfo->ei_cb_wg + .lcs_blocking = einfo->ei_cb_bl, + .lcs_glimpse = einfo->ei_cb_gl }; lock = ldlm_lock_create(ns, res_id, einfo->ei_type, einfo->ei_mode, &cbs, einfo->ei_cbdata, lvb_len, lvb_type); if (lock == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* for the local lock, add the reference */ ldlm_lock_addref_internal(lock, einfo->ei_mode); ldlm_lock2handle(lock, lockh); @@ -937,7 +922,7 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, if (req == NULL) { failed_lock_cleanup(ns, lock, einfo->ei_mode); LDLM_LOCK_RELEASE(lock); - RETURN(-ENOMEM); + return -ENOMEM; } req_passed_in = 0; if (reqp) @@ -978,7 +963,7 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, if (async) { LASSERT(reqp != NULL); - RETURN(0); + return 0; } LDLM_DEBUG(lock, "sending request"); @@ -1002,7 +987,7 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, *reqp = NULL; } - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_cli_enqueue); @@ -1011,7 +996,7 @@ static int ldlm_cli_convert_local(struct ldlm_lock *lock, int new_mode, { struct ldlm_resource *res; int rc; - ENTRY; + if (ns_is_client(ldlm_lock_to_ns(lock))) { CERROR("Trying to cancel local lock\n"); LBUG(); @@ -1023,11 +1008,11 @@ static int ldlm_cli_convert_local(struct ldlm_lock *lock, int new_mode, ldlm_reprocess_all(res); rc = 0; } else { - rc = EDEADLOCK; + rc = LUSTRE_EDEADLK; } LDLM_DEBUG(lock, "client-side local convert handler END"); LDLM_LOCK_PUT(lock); - RETURN(rc); + return rc; } /* FIXME: one of ldlm_cli_convert or the server side should reject attempted @@ -1042,17 +1027,16 @@ int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags) struct ldlm_resource *res; struct ptlrpc_request *req; int rc; - ENTRY; lock = ldlm_handle2lock(lockh); if (!lock) { LBUG(); - RETURN(-EINVAL); + return -EINVAL; } *flags = 0; if (lock->l_conn_export == NULL) - RETURN(ldlm_cli_convert_local(lock, new_mode, flags)); + return ldlm_cli_convert_local(lock, new_mode, flags); LDLM_DEBUG(lock, "client-side convert"); @@ -1061,7 +1045,7 @@ int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags) LDLM_CONVERT); if (req == NULL) { LDLM_LOCK_PUT(lock); - RETURN(-ENOMEM); + return -ENOMEM; } body = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ); @@ -1095,9 +1079,8 @@ int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags) GOTO(out, rc); } } else { - rc = EDEADLOCK; + rc = LUSTRE_EDEADLK; } - EXIT; out: LDLM_LOCK_PUT(lock); ptlrpc_req_finished(req); @@ -1115,7 +1098,6 @@ EXPORT_SYMBOL(ldlm_cli_convert); static __u64 ldlm_cli_cancel_local(struct ldlm_lock *lock) { __u64 rc = LDLM_FL_LOCAL_ONLY; - ENTRY; if (lock->l_conn_export) { bool local_only; @@ -1147,7 +1129,7 @@ static __u64 ldlm_cli_cancel_local(struct ldlm_lock *lock) ldlm_reprocess_all(lock->l_resource); } - RETURN(rc); + return rc; } /** @@ -1159,7 +1141,6 @@ static void ldlm_cancel_pack(struct ptlrpc_request *req, struct ldlm_request *dlm; struct ldlm_lock *lock; int max, packed = 0; - ENTRY; dlm = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ); LASSERT(dlm != NULL); @@ -1184,7 +1165,6 @@ static void ldlm_cancel_pack(struct ptlrpc_request *req, packed++; } CDEBUG(D_DLMTRACE, "%d locks packed\n", packed); - EXIT; } /** @@ -1197,7 +1177,6 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, struct obd_import *imp; int free, sent = 0; int rc = 0; - ENTRY; LASSERT(exp != NULL); LASSERT(count > 0); @@ -1205,7 +1184,7 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, CFS_FAIL_TIMEOUT(OBD_FAIL_LDLM_PAUSE_CANCEL, cfs_fail_val); if (CFS_FAIL_CHECK(OBD_FAIL_LDLM_CANCEL_RACE)) - RETURN(count); + return count; free = ldlm_format_handles_avail(class_exp2cliimp(exp), &RQF_LDLM_CANCEL, RCL_CLIENT, 0); @@ -1217,7 +1196,7 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, if (imp == NULL || imp->imp_invalid) { CDEBUG(D_DLMTRACE, "skipping cancel on invalid import %p\n", imp); - RETURN(count); + return count; } req = ptlrpc_request_alloc(imp, &RQF_LDLM_CANCEL); @@ -1248,7 +1227,7 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, } else { rc = ptlrpc_queue_wait(req); } - if (rc == ESTALE) { + if (rc == LUSTRE_ESTALE) { CDEBUG(D_DLMTRACE, "client/server (nid %s) " "out of sync -- not fatal\n", libcfs_nid2str(req->rq_import-> @@ -1270,7 +1249,6 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, } ptlrpc_req_finished(req); - EXIT; out: return sent ? sent : rc; } @@ -1290,14 +1268,14 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) struct obd_device *obd; __u64 new_slv; __u32 new_limit; - ENTRY; + if (unlikely(!req->rq_import || !req->rq_import->imp_obd || !imp_connect_lru_resize(req->rq_import))) { /* * Do nothing for corner cases. */ - RETURN(0); + return 0; } /* In some cases RPC may contain SLV and limit zeroed out. This @@ -1311,7 +1289,7 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) "(SLV: "LPU64", Limit: %u)", lustre_msg_get_slv(req->rq_repmsg), lustre_msg_get_limit(req->rq_repmsg)); - RETURN(0); + return 0; } new_limit = lustre_msg_get_limit(req->rq_repmsg); @@ -1328,7 +1306,7 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) obd->obd_pool_limit = new_limit; write_unlock(&obd->obd_pool_lock); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_cli_update_pool); @@ -1346,19 +1324,18 @@ int ldlm_cli_cancel(struct lustre_handle *lockh, struct ldlm_namespace *ns; struct ldlm_lock *lock; LIST_HEAD(cancels); - ENTRY; /* concurrent cancels on the same handle can happen */ lock = ldlm_handle2lock_long(lockh, LDLM_FL_CANCELING); if (lock == NULL) { LDLM_DEBUG_NOLOCK("lock is already being destroyed\n"); - RETURN(0); + return 0; } rc = ldlm_cli_cancel_local(lock); if (rc == LDLM_FL_LOCAL_ONLY) { LDLM_LOCK_RELEASE(lock); - RETURN(0); + return 0; } /* Even if the lock is marked as LDLM_FL_BL_AST, this is a LDLM_CANCEL * RPC which goes to canceld portal, so we can cancel other LRU locks @@ -1380,7 +1357,7 @@ int ldlm_cli_cancel(struct lustre_handle *lockh, LCF_BL_AST, flags); } ldlm_cli_cancel_list(&cancels, count, NULL, cancel_flags); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_cli_cancel); @@ -1430,7 +1407,7 @@ int ldlm_cli_cancel_list_local(struct list_head *cancels, int count, ldlm_cli_cancel_list(&head, bl_ast, NULL, 0); } - RETURN(count); + return count; } EXPORT_SYMBOL(ldlm_cli_cancel_list_local); @@ -1462,7 +1439,7 @@ static ldlm_policy_res_t ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, } unlock_res_and_lock(lock); - RETURN(result); + return result; } /** @@ -1631,7 +1608,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, struct list_head *ca ldlm_cancel_lru_policy_t pf; struct ldlm_lock *lock, *next; int added = 0, unused, remained; - ENTRY; spin_lock(&ns->ns_lock); unused = ns->ns_nr_unused; @@ -1754,7 +1730,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, struct list_head *ca unused--; } spin_unlock(&ns->ns_lock); - RETURN(added); + return added; } int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels, @@ -1782,16 +1758,15 @@ int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, { LIST_HEAD(cancels); int count, rc; - ENTRY; /* Just prepare the list of locks, do not actually cancel them yet. * Locks are cancelled later in a separate thread. */ count = ldlm_prepare_lru_list(ns, &cancels, nr, 0, flags); rc = ldlm_bl_to_thread_list(ns, NULL, &cancels, count, cancel_flags); if (rc == 0) - RETURN(count); + return count; - RETURN(0); + return 0; } /** @@ -1807,7 +1782,6 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res, { struct ldlm_lock *lock; int count = 0; - ENTRY; lock_res(res); list_for_each_entry(lock, &res->lr_granted, l_res_link) { @@ -1848,7 +1822,7 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res, } unlock_res(res); - RETURN(ldlm_cli_cancel_list_local(cancels, count, cancel_flags)); + return ldlm_cli_cancel_list_local(cancels, count, cancel_flags); } EXPORT_SYMBOL(ldlm_cancel_resource_local); @@ -1867,10 +1841,9 @@ int ldlm_cli_cancel_list(struct list_head *cancels, int count, { struct ldlm_lock *lock; int res = 0; - ENTRY; if (list_empty(cancels) || count == 0) - RETURN(0); + return 0; /* XXX: requests (both batched and not) could be sent in parallel. * Usually it is enough to have just 1 RPC, but it is possible that @@ -1906,7 +1879,7 @@ int ldlm_cli_cancel_list(struct list_head *cancels, int count, ldlm_lock_list_put(cancels, l_bl_ast, res); } LASSERT(count == 0); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_cli_cancel_list); @@ -1926,13 +1899,12 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, LIST_HEAD(cancels); int count; int rc; - ENTRY; 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]); - RETURN(0); + return 0; } LDLM_RESOURCE_ADDREF(res); @@ -1944,7 +1916,7 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_cli_cancel_unused_resource); @@ -1986,19 +1958,17 @@ int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, .lc_opaque = opaque, }; - ENTRY; - if (ns == NULL) - RETURN(ELDLM_OK); + return ELDLM_OK; if (res_id != NULL) { - RETURN(ldlm_cli_cancel_unused_resource(ns, res_id, NULL, + return ldlm_cli_cancel_unused_resource(ns, res_id, NULL, LCK_MINMODE, flags, - opaque)); + opaque); } else { cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_cli_hash_cancel_unused, &arg); - RETURN(ELDLM_OK); + return ELDLM_OK; } } EXPORT_SYMBOL(ldlm_cli_cancel_unused); @@ -2012,10 +1982,8 @@ int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter, struct ldlm_lock *lock; int rc = LDLM_ITER_CONTINUE; - ENTRY; - if (!res) - RETURN(LDLM_ITER_CONTINUE); + return LDLM_ITER_CONTINUE; lock_res(res); list_for_each_safe(tmp, next, &res->lr_granted) { @@ -2040,7 +2008,7 @@ int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter, } out: unlock_res(res); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_resource_foreach); @@ -2069,7 +2037,10 @@ void ldlm_namespace_foreach(struct ldlm_namespace *ns, ldlm_iterator_t iter, void *closure) { - struct iter_helper_data helper = { iter: iter, closure: closure }; + struct iter_helper_data helper = { + .iter = iter, + .closure = closure, + }; cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_res_iter_helper, &helper); @@ -2088,7 +2059,6 @@ int ldlm_resource_iterate(struct ldlm_namespace *ns, { struct ldlm_resource *res; int rc; - ENTRY; if (ns == NULL) { CERROR("must pass in namespace\n"); @@ -2097,13 +2067,13 @@ int ldlm_resource_iterate(struct ldlm_namespace *ns, res = ldlm_resource_get(ns, NULL, res_id, 0, 0); if (res == NULL) - RETURN(0); + return 0; LDLM_RESOURCE_ADDREF(res); rc = ldlm_resource_foreach(res, iter, data); LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_resource_iterate); @@ -2137,7 +2107,6 @@ static int replay_lock_interpret(const struct lu_env *env, struct ldlm_reply *reply; struct obd_export *exp; - ENTRY; atomic_dec(&req->rq_import->imp_replay_inflight); if (rc != ELDLM_OK) GOTO(out, rc); @@ -2178,7 +2147,7 @@ out: if (rc != ELDLM_OK) ptlrpc_connect_import(req->rq_import); - RETURN(rc); + return rc; } static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) @@ -2187,13 +2156,11 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) struct ldlm_async_args *aa; struct ldlm_request *body; int flags; - ENTRY; - /* Bug 11974: Do not replay a lock which is actively being canceled */ if (lock->l_flags & LDLM_FL_CANCELING) { LDLM_DEBUG(lock, "Not replaying canceled lock:"); - RETURN(0); + return 0; } /* If this is reply-less callback lock, we cannot replay it, since @@ -2202,7 +2169,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) if (lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK) { LDLM_DEBUG(lock, "Not replaying reply-less lock:"); ldlm_lock_cancel(lock); - RETURN(0); + return 0; } /* @@ -2231,7 +2198,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) req = ptlrpc_request_alloc_pack(imp, &RQF_LDLM_ENQUEUE, LUSTRE_DLM_VERSION, LDLM_ENQUEUE); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* We're part of recovery, so don't wait for it. */ req->rq_send_state = LUSTRE_IMP_REPLAY_LOCKS; @@ -2261,7 +2228,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) req->rq_interpret_reply = (ptlrpc_interpterer_t)replay_lock_interpret; ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1); - RETURN(0); + return 0; } /** @@ -2300,13 +2267,11 @@ int ldlm_replay_locks(struct obd_import *imp) struct ldlm_lock *lock, *next; int rc = 0; - ENTRY; - LASSERT(atomic_read(&imp->imp_replay_inflight) == 0); /* don't replay locks if import failed recovery */ if (imp->imp_vbr_failed) - RETURN(0); + return 0; /* ensure this doesn't fall to 0 before all have been queued */ atomic_inc(&imp->imp_replay_inflight); @@ -2328,6 +2293,6 @@ int ldlm_replay_locks(struct obd_import *imp) atomic_dec(&imp->imp_replay_inflight); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_replay_locks); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 9052dc5e7ad..208751a154b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -48,18 +48,23 @@ struct kmem_cache *ldlm_resource_slab, *ldlm_lock_slab; -atomic_t ldlm_srv_namespace_nr = ATOMIC_INIT(0); -atomic_t ldlm_cli_namespace_nr = ATOMIC_INIT(0); +int ldlm_srv_namespace_nr = 0; +int ldlm_cli_namespace_nr = 0; struct mutex ldlm_srv_namespace_lock; LIST_HEAD(ldlm_srv_namespace_list); struct mutex ldlm_cli_namespace_lock; -LIST_HEAD(ldlm_cli_namespace_list); +/* Client Namespaces that have active resources in them. + * Once all resources go away, ldlm_poold moves such namespaces to the + * inactive list */ +LIST_HEAD(ldlm_cli_active_namespace_list); +/* Client namespaces that don't have any locks in them */ +LIST_HEAD(ldlm_cli_inactive_namespace_list); -proc_dir_entry_t *ldlm_type_proc_dir = NULL; -proc_dir_entry_t *ldlm_ns_proc_dir = NULL; -proc_dir_entry_t *ldlm_svc_proc_dir = NULL; +struct proc_dir_entry *ldlm_type_proc_dir = NULL; +struct proc_dir_entry *ldlm_ns_proc_dir = NULL; +struct proc_dir_entry *ldlm_svc_proc_dir = NULL; extern unsigned int ldlm_cancel_unused_locks_before_replay; @@ -73,7 +78,7 @@ static ssize_t lprocfs_wr_dump_ns(struct file *file, const char *buffer, { ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE); ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE); - RETURN(count); + return count; } LPROC_SEQ_FOPS_WR_ONLY(ldlm, dump_ns); @@ -90,7 +95,6 @@ int ldlm_proc_setup(void) { "cancel_unused_locks_before_replay", &ldlm_rw_uint_fops, &ldlm_cancel_unused_locks_before_replay }, { NULL }}; - ENTRY; LASSERT(ldlm_ns_proc_dir == NULL); ldlm_type_proc_dir = lprocfs_register(OBD_LDLM_DEVICENAME, @@ -122,7 +126,7 @@ int ldlm_proc_setup(void) rc = lprocfs_add_vars(ldlm_type_proc_dir, list, NULL); - RETURN(0); + return 0; err_ns: lprocfs_remove(&ldlm_ns_proc_dir); @@ -132,7 +136,7 @@ err: ldlm_svc_proc_dir = NULL; ldlm_type_proc_dir = NULL; ldlm_ns_proc_dir = NULL; - RETURN(rc); + return rc; } void ldlm_proc_cleanup(void) @@ -325,7 +329,7 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) { struct lprocfs_vars lock_vars[2]; char lock_name[MAX_STRING_SIZE + 1]; - proc_dir_entry_t *ns_pde; + struct proc_dir_entry *ns_pde; LASSERT(ns != NULL); LASSERT(ns->ns_rs_hash != NULL); @@ -563,14 +567,13 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, cfs_hash_bd_t bd; int idx; int rc; - ENTRY; LASSERT(obd != NULL); rc = ldlm_get_ref(); if (rc) { CERROR("ldlm_get_ref failed: %d\n", rc); - RETURN(NULL); + return NULL; } for (idx = 0;;idx++) { @@ -636,7 +639,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, GOTO(out_hash, rc); } - idx = atomic_read(ldlm_namespace_nr(client)); + idx = ldlm_namespace_nr_read(client); rc = ldlm_pool_init(&ns->ns_pool, ns, idx, client); if (rc) { CERROR("Can't initialize lock pool, rc %d\n", rc); @@ -644,7 +647,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, } ldlm_namespace_register(ns, client); - RETURN(ns); + return ns; out_proc: ldlm_namespace_proc_unregister(ns); ldlm_namespace_cleanup(ns, 0); @@ -654,7 +657,7 @@ out_ns: OBD_FREE_PTR(ns); out_ref: ldlm_put_ref(); - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(ldlm_namespace_new); @@ -803,8 +806,6 @@ EXPORT_SYMBOL(ldlm_namespace_cleanup); */ static int __ldlm_namespace_free(struct ldlm_namespace *ns, int force) { - ENTRY; - /* At shutdown time, don't call the cancellation callback */ ldlm_namespace_cleanup(ns, force ? LDLM_FL_LOCAL_ONLY : 0); @@ -836,13 +837,13 @@ force_wait: "with %d resources in use, (rc=%d)\n", ldlm_ns_name(ns), atomic_read(&ns->ns_bref), rc); - RETURN(ELDLM_NAMESPACE_EXISTS); + return ELDLM_NAMESPACE_EXISTS; } CDEBUG(D_DLMTRACE, "dlm namespace %s free done waiting\n", ldlm_ns_name(ns)); } - RETURN(ELDLM_OK); + return ELDLM_OK; } /** @@ -859,9 +860,8 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns, int force) { int rc; - ENTRY; + if (!ns) { - EXIT; return; } @@ -886,7 +886,6 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns, rc = __ldlm_namespace_free(ns, 1); LASSERT(rc == 0); } - EXIT; } /** @@ -896,9 +895,7 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns, */ void ldlm_namespace_free_post(struct ldlm_namespace *ns) { - ENTRY; if (!ns) { - EXIT; return; } @@ -917,7 +914,6 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns) LASSERT(list_empty(&ns->ns_list_chain)); OBD_FREE_PTR(ns); ldlm_put_ref(); - EXIT; } /** @@ -953,6 +949,12 @@ void ldlm_namespace_get(struct ldlm_namespace *ns) } EXPORT_SYMBOL(ldlm_namespace_get); +/* This is only for callers that care about refcount */ +int ldlm_namespace_get_return(struct ldlm_namespace *ns) +{ + return atomic_inc_return(&ns->ns_bref); +} + void ldlm_namespace_put(struct ldlm_namespace *ns) { if (atomic_dec_and_lock(&ns->ns_bref, &ns->ns_lock)) { @@ -967,8 +969,8 @@ void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client) { mutex_lock(ldlm_namespace_lock(client)); LASSERT(list_empty(&ns->ns_list_chain)); - list_add(&ns->ns_list_chain, ldlm_namespace_list(client)); - atomic_inc(ldlm_namespace_nr(client)); + list_add(&ns->ns_list_chain, ldlm_namespace_inactive_list(client)); + ldlm_namespace_nr_inc(client); mutex_unlock(ldlm_namespace_lock(client)); } @@ -981,12 +983,13 @@ void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client) * using list_empty(&ns->ns_list_chain). This is why it is * important to use list_del_init() here. */ list_del_init(&ns->ns_list_chain); - atomic_dec(ldlm_namespace_nr(client)); + ldlm_namespace_nr_dec(client); mutex_unlock(ldlm_namespace_lock(client)); } /** Should be called with ldlm_namespace_lock(client) taken. */ -void ldlm_namespace_move_locked(struct ldlm_namespace *ns, ldlm_side_t client) +void ldlm_namespace_move_to_active_locked(struct ldlm_namespace *ns, + ldlm_side_t client) { LASSERT(!list_empty(&ns->ns_list_chain)); LASSERT(mutex_is_locked(ldlm_namespace_lock(client))); @@ -994,6 +997,16 @@ void ldlm_namespace_move_locked(struct ldlm_namespace *ns, ldlm_side_t client) } /** Should be called with ldlm_namespace_lock(client) taken. */ +void ldlm_namespace_move_to_inactive_locked(struct ldlm_namespace *ns, + ldlm_side_t client) +{ + LASSERT(!list_empty(&ns->ns_list_chain)); + LASSERT(mutex_is_locked(ldlm_namespace_lock(client))); + list_move_tail(&ns->ns_list_chain, + ldlm_namespace_inactive_list(client)); +} + +/** Should be called with ldlm_namespace_lock(client) taken. */ struct ldlm_namespace *ldlm_namespace_first_locked(ldlm_side_t client) { LASSERT(mutex_is_locked(ldlm_namespace_lock(client))); @@ -1049,6 +1062,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, struct ldlm_resource *res; cfs_hash_bd_t bd; __u64 version; + int ns_refcount = 0; LASSERT(ns != NULL); LASSERT(parent == NULL); @@ -1119,7 +1133,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, /* We won! Let's add the resource. */ cfs_hash_bd_add_locked(ns->ns_rs_hash, &bd, &res->lr_hash); if (cfs_hash_bd_count_get(&bd) == 1) - ldlm_namespace_get(ns); + ns_refcount = ldlm_namespace_get_return(ns); cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) { @@ -1128,8 +1142,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("lvbo_init failed for resource " - LPU64": rc %d\n", name->name[0], rc); + CERROR("%s: lvbo_init failed for resource "LPX64":" + LPX64": 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; @@ -1144,6 +1159,16 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, /* We create resource with locked lr_lvb_mutex. */ mutex_unlock(&res->lr_lvb_mutex); + /* Let's see if we happened to be the very first resource in this + * namespace. If so, and this is a client namespace, we need to move + * the namespace into the active namespaces list to be patrolled by + * the ldlm_poold. */ + if (ns_is_client(ns) && ns_refcount == 1) { + mutex_lock(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT)); + ldlm_namespace_move_to_active_locked(ns, LDLM_NAMESPACE_CLIENT); + mutex_unlock(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT)); + } + return res; } EXPORT_SYMBOL(ldlm_resource_get); @@ -1249,7 +1274,7 @@ void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head, LDLM_DEBUG(lock, "About to add this lock:\n"); - if (lock->l_destroyed) { + if (lock->l_flags & LDLM_FL_DESTROYED) { CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n"); return; } @@ -1274,7 +1299,7 @@ void ldlm_resource_insert_lock_after(struct ldlm_lock *original, ldlm_resource_dump(D_INFO, res); LDLM_DEBUG(new, "About to insert this lock after %p:\n", original); - if (new->l_destroyed) { + if (new->l_flags & LDLM_FL_DESTROYED) { CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n"); goto out; } diff --git a/drivers/staging/lustre/lustre/libcfs/Makefile b/drivers/staging/lustre/lustre/libcfs/Makefile index bf5c563dcac..6e489d7aaa8 100644 --- a/drivers/staging/lustre/lustre/libcfs/Makefile +++ b/drivers/staging/lustre/lustre/libcfs/Makefile @@ -11,7 +11,7 @@ libcfs-linux-objs += linux-crypto-adler.o libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs)) libcfs-all-objs := debug.o fail.o nidstrings.o module.o tracefile.o \ - watchdog.o libcfs_string.o hash.o kernel_user_comm.o \ + libcfs_string.o hash.o kernel_user_comm.o \ prng.o workitem.o upcall_cache.o libcfs_cpu.o \ libcfs_mem.o libcfs_lock.o diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index 5a87b083207..9b9c45116ee 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -335,9 +335,10 @@ libcfs_debug_str2mask(int *mask, const char *str, int is_subsys) */ void libcfs_debug_dumplog_internal(void *arg) { - DECL_JOURNAL_DATA; + void *journal_info; - PUSH_JOURNAL; + journal_info = current->journal_info; + current->journal_info = NULL; if (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0) { snprintf(debug_file_name, sizeof(debug_file_name) - 1, @@ -348,7 +349,8 @@ void libcfs_debug_dumplog_internal(void *arg) cfs_tracefile_dump_all_pages(debug_file_name); libcfs_run_debug_log_upcall(debug_file_name); } - POP_JOURNAL; + + current->journal_info = journal_info; } int libcfs_debug_dumplog_thread(void *arg) @@ -361,8 +363,7 @@ int libcfs_debug_dumplog_thread(void *arg) void libcfs_debug_dumplog(void) { wait_queue_t wait; - task_t *dumper; - ENTRY; + struct task_struct *dumper; /* we're being careful to ensure that the kernel thread is * able to set our state to running as it exits before we @@ -459,14 +460,6 @@ void libcfs_debug_set_level(unsigned int debug_level) EXPORT_SYMBOL(libcfs_debug_set_level); -long libcfs_log_return(struct libcfs_debug_msg_data *msgdata, long rc) -{ - libcfs_debug_msg(msgdata, "Process leaving (rc=%lu : %ld : %lx)\n", - rc, rc, rc); - return rc; -} -EXPORT_SYMBOL(libcfs_log_return); - void libcfs_log_goto(struct libcfs_debug_msg_data *msgdata, const char *label, long_ptr_t rc) { diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index 98c76dfac3d..0dd12c8c91b 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -1026,8 +1026,6 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, cfs_hash_t *hs; int len; - ENTRY; - CLASSERT(CFS_HASH_THETA_BITS < 15); LASSERT(name != NULL); @@ -1055,7 +1053,7 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, CFS_HASH_NAME_LEN : CFS_HASH_BIGNAME_LEN; LIBCFS_ALLOC(hs, offsetof(cfs_hash_t, hs_name[len])); if (hs == NULL) - RETURN(NULL); + return NULL; strncpy(hs->hs_name, name, len); hs->hs_name[len - 1] = '\0'; @@ -1087,7 +1085,7 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, return hs; LIBCFS_FREE(hs, offsetof(cfs_hash_t, hs_name[len])); - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(cfs_hash_create); @@ -1101,7 +1099,6 @@ cfs_hash_destroy(cfs_hash_t *hs) struct hlist_node *pos; cfs_hash_bd_t bd; int i; - ENTRY; LASSERT(hs != NULL); LASSERT(!cfs_hash_is_exiting(hs) && @@ -1152,8 +1149,6 @@ cfs_hash_destroy(cfs_hash_t *hs) i = cfs_hash_with_bigname(hs) ? CFS_HASH_BIGNAME_LEN : CFS_HASH_NAME_LEN; LIBCFS_FREE(hs, offsetof(cfs_hash_t, hs_name[i])); - - EXIT; } cfs_hash_t *cfs_hash_getref(cfs_hash_t *hs) @@ -1449,7 +1444,6 @@ cfs_hash_for_each_tight(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, int excl = !!remove_safe; int loop = 0; int i; - ENTRY; cfs_hash_for_each_enter(hs); @@ -1489,7 +1483,7 @@ cfs_hash_for_each_tight(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, cfs_hash_unlock(hs, 0); cfs_hash_for_each_exit(hs); - RETURN(count); + return count; } typedef struct { @@ -1594,7 +1588,6 @@ cfs_hash_for_each_relax(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, void *data) int stop_on_change; int rc; int i; - ENTRY; stop_on_change = cfs_hash_with_rehash_key(hs) || !cfs_hash_with_no_itemref(hs) || @@ -1649,23 +1642,21 @@ int cfs_hash_for_each_nolock(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, void *data) { - ENTRY; - if (cfs_hash_with_no_lock(hs) || cfs_hash_with_rehash_key(hs) || !cfs_hash_with_no_itemref(hs)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (CFS_HOP(hs, get) == NULL || (CFS_HOP(hs, put) == NULL && CFS_HOP(hs, put_locked) == NULL)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; cfs_hash_for_each_enter(hs); cfs_hash_for_each_relax(hs, func, data); cfs_hash_for_each_exit(hs); - RETURN(0); + return 0; } EXPORT_SYMBOL(cfs_hash_for_each_nolock); @@ -1685,7 +1676,6 @@ cfs_hash_for_each_empty(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, void *data) { unsigned i = 0; - ENTRY; if (cfs_hash_with_no_lock(hs)) return -EOPNOTSUPP; @@ -1701,7 +1691,7 @@ cfs_hash_for_each_empty(cfs_hash_t *hs, hs->hs_name, i++); } cfs_hash_for_each_exit(hs); - RETURN(0); + return 0; } EXPORT_SYMBOL(cfs_hash_for_each_empty); diff --git a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c index d6d3b2e0f30..74a0db5c154 100644 --- a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c +++ b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c @@ -246,10 +246,9 @@ EXPORT_SYMBOL(libcfs_kkuc_group_add); int libcfs_kkuc_group_rem(int uid, int group) { struct kkuc_reg *reg, *next; - ENTRY; if (kkuc_groups[group].next == NULL) - RETURN(0); + return 0; if (uid == 0) { /* Broadcast a shutdown message */ @@ -275,7 +274,7 @@ int libcfs_kkuc_group_rem(int uid, int group) } up_write(&kg_sem); - RETURN(0); + return 0; } EXPORT_SYMBOL(libcfs_kkuc_group_rem); @@ -284,7 +283,6 @@ int libcfs_kkuc_group_put(int group, void *payload) struct kkuc_reg *reg; int rc = 0; int one_success = 0; - ENTRY; down_read(&kg_sem); list_for_each_entry(reg, &kkuc_groups[group], kr_chain) { @@ -305,7 +303,7 @@ int libcfs_kkuc_group_put(int group, void *payload) if (one_success) rc = 0; - RETURN(rc); + return rc; } EXPORT_SYMBOL(libcfs_kkuc_group_put); @@ -320,16 +318,15 @@ int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func, { struct kkuc_reg *reg; int rc = 0; - ENTRY; if (group > KUC_GRP_MAX) { CDEBUG(D_WARNING, "Kernelcomm: bad group %d\n", group); - RETURN(-EINVAL); + return -EINVAL; } /* no link for this group */ if (kkuc_groups[group].next == NULL) - RETURN(0); + return 0; down_read(&kg_sem); list_for_each_entry(reg, &kkuc_groups[group], kr_chain) { @@ -339,7 +336,7 @@ int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func, } up_read(&kg_sem); - RETURN(rc); + return rc; } EXPORT_SYMBOL(libcfs_kkuc_group_foreach); diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c index 8e88eb59dd5..1fb37008cda 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c @@ -33,9 +33,6 @@ * Author: liang@whamcloud.com */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_LNET #include <linux/libcfs/libcfs.h> diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c b/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c index 8d6c4adf2ee..a2ce4c0eb3d 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c @@ -30,9 +30,6 @@ * Author: liang@whamcloud.com */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_LNET #include <linux/libcfs/libcfs.h> diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c b/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c index 87913730348..feab537c728 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c @@ -31,9 +31,6 @@ * Author: liang@whamcloud.com */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_LNET #include <linux/libcfs/libcfs.h> diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c index 9edccc99683..922debd0a41 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c @@ -69,7 +69,6 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), const char *debugstr; char op = 0; int newmask = minmask, i, len, found = 0; - ENTRY; /* <str> must be a list of tokens separated by whitespace * and optionally an operator ('+' or '-'). If an operator @@ -132,54 +131,6 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), } EXPORT_SYMBOL(cfs_str2mask); -/* Duplicate a string in a platform-independent way */ -char *cfs_strdup(const char *str, u_int32_t flags) -{ - size_t lenz; /* length of str + zero byte */ - char *dup_str; - - lenz = strlen(str) + 1; - - dup_str = kmalloc(lenz, flags); - if (dup_str == NULL) - return NULL; - - memcpy(dup_str, str, lenz); - - return dup_str; -} -EXPORT_SYMBOL(cfs_strdup); - -/** - * cfs_{v}snprintf() return the actual size that is printed rather than - * the size that would be printed in standard functions. - */ -/* safe vsnprintf */ -int cfs_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) -{ - int i; - - LASSERT(size > 0); - i = vsnprintf(buf, size, fmt, args); - - return (i >= size ? size - 1 : i); -} -EXPORT_SYMBOL(cfs_vsnprintf); - -/* safe snprintf */ -int cfs_snprintf(char *buf, size_t size, const char *fmt, ...) -{ - va_list args; - int i; - - va_start(args, fmt); - i = cfs_vsnprintf(buf, size, fmt, args); - va_end(args); - - return i; -} -EXPORT_SYMBOL(cfs_snprintf); - /* get the first string out of @str */ char *cfs_firststr(char *str, size_t size) { diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c index 95142d19097..00ab8fdc105 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c @@ -76,62 +76,22 @@ struct cfs_cpt_data { static struct cfs_cpt_data cpt_data; -void -cfs_cpu_core_siblings(int cpu, cpumask_t *mask) +static void cfs_cpu_core_siblings(int cpu, cpumask_t *mask) { /* return cpumask of cores in the same socket */ cpumask_copy(mask, topology_core_cpumask(cpu)); } -EXPORT_SYMBOL(cfs_cpu_core_siblings); - -/* return number of cores in the same socket of \a cpu */ -int -cfs_cpu_core_nsiblings(int cpu) -{ - int num; - - down(&cpt_data.cpt_mutex); - - cfs_cpu_core_siblings(cpu, cpt_data.cpt_cpumask); - num = cpus_weight(*cpt_data.cpt_cpumask); - - up(&cpt_data.cpt_mutex); - - return num; -} -EXPORT_SYMBOL(cfs_cpu_core_nsiblings); /* return cpumask of HTs in the same core */ -void -cfs_cpu_ht_siblings(int cpu, cpumask_t *mask) +static void cfs_cpu_ht_siblings(int cpu, cpumask_t *mask) { cpumask_copy(mask, topology_thread_cpumask(cpu)); } -EXPORT_SYMBOL(cfs_cpu_ht_siblings); -/* return number of HTs in the same core of \a cpu */ -int -cfs_cpu_ht_nsiblings(int cpu) -{ - int num; - - down(&cpt_data.cpt_mutex); - - cfs_cpu_ht_siblings(cpu, cpt_data.cpt_cpumask); - num = cpus_weight(*cpt_data.cpt_cpumask); - - up(&cpt_data.cpt_mutex); - - return num; -} -EXPORT_SYMBOL(cfs_cpu_ht_nsiblings); - -void -cfs_node_to_cpumask(int node, cpumask_t *mask) +static void cfs_node_to_cpumask(int node, cpumask_t *mask) { cpumask_copy(mask, cpumask_of_node(node)); } -EXPORT_SYMBOL(cfs_node_to_cpumask); void cfs_cpt_table_free(struct cfs_cpt_table *cptab) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c index 8e35777b4da..b6c79bc177a 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c @@ -274,6 +274,8 @@ static int adler32; int cfs_crypto_register(void) { + request_module("crc32c"); + adler32 = cfs_crypto_adler32_register(); /* check all algorithms and do performance test */ diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index f236510a2f3..ea9e9490031 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -65,20 +65,6 @@ int cfs_curproc_groups_nr(void) return nr; } -void cfs_curproc_groups_dump(gid_t *array, int size) -{ - task_lock(current); - size = min_t(int, size, current_cred()->group_info->ngroups); - memcpy(array, current_cred()->group_info->blocks[0], size * sizeof(__u32)); - task_unlock(current); -} - - -int current_is_in_group(gid_t gid) -{ - return in_group_p(gid); -} - /* Currently all the CFS_CAP_* defines match CAP_* ones. */ #define cfs_cap_pack(cap) (cap) #define cfs_cap_unpack(cap) (cap) @@ -226,16 +212,15 @@ int cfs_get_environ(const char *key, char *value, int *val_len) int key_len = strlen(key); unsigned long addr; int rc; - ENTRY; buffer = kmalloc(buf_len, GFP_USER); if (!buffer) - RETURN(-ENOMEM); + return -ENOMEM; mm = get_task_mm(current); if (!mm) { kfree(buffer); - RETURN(-EINVAL); + return -EINVAL; } /* Avoid deadlocks on mmap_sem if called from sys_mmap_pgoff(), @@ -318,8 +303,6 @@ out: EXPORT_SYMBOL(cfs_get_environ); EXPORT_SYMBOL(cfs_curproc_groups_nr); -EXPORT_SYMBOL(cfs_curproc_groups_dump); -EXPORT_SYMBOL(current_is_in_group); EXPORT_SYMBOL(cfs_cap_raise); EXPORT_SYMBOL(cfs_cap_lower); EXPORT_SYMBOL(cfs_cap_raised); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index e2c195b8dd5..ab1e7316847 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -48,14 +48,10 @@ #include <linux/errno.h> #include <linux/unistd.h> #include <linux/interrupt.h> -#include <asm/uaccess.h> #include <linux/completion.h> - #include <linux/fs.h> -#include <linux/stat.h> #include <asm/uaccess.h> #include <linux/miscdevice.h> -#include <linux/version.h> # define DEBUG_SUBSYSTEM S_LNET @@ -82,7 +78,6 @@ void libcfs_run_debug_log_upcall(char *file) "HOME=/", "PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL}; - ENTRY; argv[0] = lnet_debug_log_upcall; @@ -100,8 +95,6 @@ void libcfs_run_debug_log_upcall(char *file) CDEBUG(D_HA, "Invoked LNET debug log upcall %s %s\n", argv[0], argv[1]); } - - EXIT; } void libcfs_run_upcall(char **argv) @@ -112,7 +105,6 @@ void libcfs_run_upcall(char **argv) "HOME=/", "PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL}; - ENTRY; argv[0] = lnet_upcall; argc = 1; @@ -145,7 +137,6 @@ void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *msgdata) char *argv[6]; char buf[32]; - ENTRY; snprintf (buf, sizeof buf, "%d", msgdata->msg_line); argv[1] = "LBUG"; @@ -168,7 +159,7 @@ void lbug_with_loc(struct libcfs_debug_msg_data *msgdata) /* not reached */ } - libcfs_debug_dumpstack(NULL); + dump_stack(); if (!libcfs_panic_on_lbug) libcfs_debug_dumplog(); libcfs_run_lbug_upcall(msgdata); @@ -179,54 +170,6 @@ void lbug_with_loc(struct libcfs_debug_msg_data *msgdata) schedule(); } - -#include <linux/nmi.h> -#include <asm/stacktrace.h> - - -static int print_trace_stack(void *data, char *name) -{ - printk(" <%s> ", name); - return 0; -} - -# define RELIABLE reliable -# define DUMP_TRACE_CONST const -static void print_trace_address(void *data, unsigned long addr, int reliable) -{ - char fmt[32]; - touch_nmi_watchdog(); - sprintf(fmt, " [<%016lx>] %s%%s\n", addr, RELIABLE ? "": "? "); - __print_symbol(fmt, addr); -} - -static DUMP_TRACE_CONST struct stacktrace_ops print_trace_ops = { - .stack = print_trace_stack, - .address = print_trace_address, - .walk_stack = print_context_stack, -}; - -void libcfs_debug_dumpstack(struct task_struct *tsk) -{ - /* dump_stack() */ - /* show_trace() */ - if (tsk == NULL) - tsk = current; - printk("Pid: %d, comm: %.20s\n", tsk->pid, tsk->comm); - /* show_trace_log_lvl() */ - printk("\nCall Trace:\n"); - dump_trace(tsk, NULL, NULL, - 0, - &print_trace_ops, NULL); - printk("\n"); -} - -task_t *libcfs_current(void) -{ - CWARN("current task struct is %p\n", current); - return current; -} - static int panic_notifier(struct notifier_block *self, unsigned long unused1, void *unused2) { @@ -240,9 +183,9 @@ static int panic_notifier(struct notifier_block *self, unsigned long unused1, } static struct notifier_block libcfs_panic_notifier = { - notifier_call : panic_notifier, - next : NULL, - priority : 10000 + .notifier_call = panic_notifier, + .next = NULL, + .priority = 10000, }; void libcfs_register_panic_notifier(void) @@ -255,10 +198,6 @@ void libcfs_unregister_panic_notifier(void) atomic_notifier_chain_unregister(&panic_notifier_list, &libcfs_panic_notifier); } -EXPORT_SYMBOL(libcfs_debug_dumpstack); -EXPORT_SYMBOL(libcfs_current); - - EXPORT_SYMBOL(libcfs_run_upcall); EXPORT_SYMBOL(libcfs_run_lbug_upcall); EXPORT_SYMBOL(lbug_with_loc); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index 2c7d4a3d660..55296a3591d 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -45,38 +45,37 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg) struct libcfs_ioctl_hdr *hdr; struct libcfs_ioctl_data *data; int err; - ENTRY; hdr = (struct libcfs_ioctl_hdr *)buf; data = (struct libcfs_ioctl_data *)buf; err = copy_from_user(buf, (void *)arg, sizeof(*hdr)); if (err) - RETURN(err); + return err; if (hdr->ioc_version != LIBCFS_IOCTL_VERSION) { CERROR("PORTALS: version mismatch kernel vs application\n"); - RETURN(-EINVAL); + return -EINVAL; } if (hdr->ioc_len + buf >= end) { CERROR("PORTALS: user buffer exceeds kernel buffer\n"); - RETURN(-EINVAL); + return -EINVAL; } if (hdr->ioc_len < sizeof(struct libcfs_ioctl_data)) { CERROR("PORTALS: user buffer too small for ioctl\n"); - RETURN(-EINVAL); + return -EINVAL; } err = copy_from_user(buf, (void *)arg, hdr->ioc_len); if (err) - RETURN(err); + return err; if (libcfs_ioctl_is_invalid(data)) { CERROR("PORTALS: ioctl not correctly formatted\n"); - RETURN(-EINVAL); + return -EINVAL; } if (data->ioc_inllen1) @@ -86,7 +85,7 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg) data->ioc_inlbuf2 = &data->ioc_bulk[0] + cfs_size_round(data->ioc_inllen1); - RETURN(0); + return 0; } int libcfs_ioctl_popdata(void *arg, void *data, int size) @@ -137,7 +136,7 @@ static long libcfs_ioctl(struct file *file, struct cfs_psdev_file pfile; int rc = 0; - if (current_fsuid() != 0) + if (!capable(CAP_SYS_ADMIN)) return -EACCES; if ( _IOC_TYPE(cmd) != IOC_LIBCFS_TYPE || @@ -171,13 +170,13 @@ static long libcfs_ioctl(struct file *file, } static struct file_operations libcfs_fops = { - unlocked_ioctl: libcfs_ioctl, - open : libcfs_psdev_open, - release : libcfs_psdev_release + .unlocked_ioctl = libcfs_ioctl, + .open = libcfs_psdev_open, + .release = libcfs_psdev_release, }; -psdev_t libcfs_dev = { - LNET_MINOR, - "lnet", - &libcfs_fops +struct miscdevice libcfs_dev = { + .minor = LNET_MINOR, + .name = "lnet", + .fops = &libcfs_fops, }; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c index b652a79a481..cc9829ffbdc 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c @@ -81,22 +81,21 @@ add_wait_queue_exclusive_head(wait_queue_head_t *waitq, wait_queue_t *link) EXPORT_SYMBOL(add_wait_queue_exclusive_head); void -waitq_wait(wait_queue_t *link, cfs_task_state_t state) +waitq_wait(wait_queue_t *link, long state) { schedule(); } EXPORT_SYMBOL(waitq_wait); int64_t -waitq_timedwait(wait_queue_t *link, cfs_task_state_t state, - int64_t timeout) +waitq_timedwait(wait_queue_t *link, long state, int64_t timeout) { return schedule_timeout(timeout); } EXPORT_SYMBOL(waitq_timedwait); void -schedule_timeout_and_set_state(cfs_task_state_t state, int64_t timeout) +schedule_timeout_and_set_state(long state, int64_t timeout) { set_current_state(state); schedule_timeout(timeout); @@ -112,13 +111,13 @@ cfs_pause(cfs_duration_t ticks) } EXPORT_SYMBOL(cfs_pause); -void cfs_init_timer(timer_list_t *t) +void cfs_init_timer(struct timer_list *t) { init_timer(t); } EXPORT_SYMBOL(cfs_init_timer); -void cfs_timer_init(timer_list_t *t, cfs_timer_func_t *func, void *arg) +void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg) { init_timer(t); t->function = func; @@ -126,31 +125,31 @@ void cfs_timer_init(timer_list_t *t, cfs_timer_func_t *func, void *arg) } EXPORT_SYMBOL(cfs_timer_init); -void cfs_timer_done(timer_list_t *t) +void cfs_timer_done(struct timer_list *t) { return; } EXPORT_SYMBOL(cfs_timer_done); -void cfs_timer_arm(timer_list_t *t, cfs_time_t deadline) +void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline) { mod_timer(t, deadline); } EXPORT_SYMBOL(cfs_timer_arm); -void cfs_timer_disarm(timer_list_t *t) +void cfs_timer_disarm(struct timer_list *t) { del_timer(t); } EXPORT_SYMBOL(cfs_timer_disarm); -int cfs_timer_is_armed(timer_list_t *t) +int cfs_timer_is_armed(struct timer_list *t) { return timer_pending(t); } EXPORT_SYMBOL(cfs_timer_is_armed); -cfs_time_t cfs_timer_deadline(timer_list_t *t) +cfs_time_t 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 522b28e99e4..fc6c9774948 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c @@ -54,9 +54,7 @@ #include <linux/fs.h> #include <linux/file.h> -#include <linux/stat.h> #include <linux/list.h> -#include <asm/uaccess.h> #include <linux/proc_fs.h> #include <linux/sysctl.h> @@ -564,7 +562,7 @@ int insert_proc(void) { #ifdef CONFIG_SYSCTL if (lnet_table_header == NULL) - lnet_table_header = cfs_register_sysctl_table(top_table, 0); + lnet_table_header = register_sysctl_table(top_table); #endif return 0; } diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c index 855c7e87d96..e6069d78af6 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c @@ -36,7 +36,6 @@ #define DEBUG_SUBSYSTEM S_LNET #include <linux/libcfs/libcfs.h> -#include <linux/libcfs/libcfs.h> #include <linux/if.h> #include <linux/in.h> @@ -641,8 +640,8 @@ libcfs_sock_connect (struct socket **sockp, int *fatal, *fatal = !(rc == -EADDRNOTAVAIL); CDEBUG_LIMIT(*fatal ? D_NETERROR : D_NET, - "Error %d connecting %u.%u.%u.%u/%d -> %u.%u.%u.%u/%d\n", rc, - HIPQUAD(local_ip), local_port, HIPQUAD(peer_ip), peer_port); + "Error %d connecting %pI4h/%d -> %pI4h/%d\n", rc, + &local_ip, local_port, &peer_ip, peer_port); sock_release(*sockp); return rc; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index 6f563436a25..162beee24a7 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -51,7 +51,7 @@ char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX]; struct rw_semaphore cfs_tracefile_sem; -int cfs_tracefile_init_arch() +int cfs_tracefile_init_arch(void) { int i; int j; @@ -96,7 +96,7 @@ out: return -ENOMEM; } -void cfs_tracefile_fini_arch() +void cfs_tracefile_fini_arch(void) { int i; int j; @@ -116,27 +116,27 @@ void cfs_tracefile_fini_arch() fini_rwsem(&cfs_tracefile_sem); } -void cfs_tracefile_read_lock() +void cfs_tracefile_read_lock(void) { down_read(&cfs_tracefile_sem); } -void cfs_tracefile_read_unlock() +void cfs_tracefile_read_unlock(void) { up_read(&cfs_tracefile_sem); } -void cfs_tracefile_write_lock() +void cfs_tracefile_write_lock(void) { down_write(&cfs_tracefile_sem); } -void cfs_tracefile_write_unlock() +void cfs_tracefile_write_unlock(void) { up_write(&cfs_tracefile_sem); } -cfs_trace_buf_type_t cfs_trace_buf_idx_get() +cfs_trace_buf_type_t cfs_trace_buf_idx_get(void) { if (in_irq()) return CFS_TCD_TYPE_IRQ; @@ -269,7 +269,7 @@ void cfs_print_to_console(struct ptldebug_header *hdr, int mask, int cfs_trace_max_debug_mb(void) { - int total_mb = (num_physpages >> (20 - PAGE_SHIFT)); + int total_mb = (totalram_pages >> (20 - PAGE_SHIFT)); return MAX(512, (total_mb * 80)/100); } diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 3372537c6f3..f3108c7f818 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -155,7 +155,6 @@ kportal_memhog_alloc (struct libcfs_device_userstate *ldu, int npages, int flags static int libcfs_psdev_open(unsigned long flags, void *args) { struct libcfs_device_userstate *ldu; - ENTRY; try_module_get(THIS_MODULE); @@ -166,14 +165,13 @@ static int libcfs_psdev_open(unsigned long flags, void *args) } *(struct libcfs_device_userstate **)args = ldu; - RETURN(0); + return 0; } /* called when closing /dev/device */ static int libcfs_psdev_release(unsigned long flags, void *args) { struct libcfs_device_userstate *ldu; - ENTRY; ldu = (struct libcfs_device_userstate *)args; if (ldu != NULL) { @@ -182,7 +180,7 @@ static int libcfs_psdev_release(unsigned long flags, void *args) } module_put(THIS_MODULE); - RETURN(0); + return 0; } static struct rw_semaphore ioctl_list_sem; @@ -222,12 +220,11 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, void *arg, struct libcfs_ioctl_data *data) { int err = -EINVAL; - ENTRY; switch (cmd) { case IOC_LIBCFS_CLEAR_DEBUG: libcfs_debug_clear_buffer(); - RETURN(0); + return 0; /* * case IOC_LIBCFS_PANIC: * Handled in arch/cfs_module.c @@ -235,9 +232,9 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, case IOC_LIBCFS_MARK_DEBUG: if (data->ioc_inlbuf1 == NULL || data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0') - RETURN(-EINVAL); + return -EINVAL; libcfs_debug_mark_buffer(data->ioc_inlbuf1); - RETURN(0); + return 0; #if LWT_SUPPORT case IOC_LIBCFS_LWT_CONTROL: err = lwt_control ((data->ioc_flags & 1) != 0, @@ -301,7 +298,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, ping(data); symbol_put(kping_client); } - RETURN(0); + return 0; } default: { @@ -322,7 +319,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, } } - RETURN(err); + return err; } static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *arg) @@ -330,11 +327,10 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *a char *buf; struct libcfs_ioctl_data *data; int err = 0; - ENTRY; LIBCFS_ALLOC_GFP(buf, 1024, GFP_IOFS); if (buf == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* 'cmd' and permissions get checked in our arch-specific caller */ if (libcfs_ioctl_getdata(buf, buf + 800, (void *)arg)) { @@ -347,7 +343,7 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *a out: LIBCFS_FREE(buf, 1024); - RETURN(err); + return err; } @@ -365,7 +361,7 @@ MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>"); MODULE_DESCRIPTION("Portals v3.1"); MODULE_LICENSE("GPL"); -extern psdev_t libcfs_dev; +extern struct miscdevice libcfs_dev; extern struct rw_semaphore cfs_tracefile_sem; extern struct mutex cfs_trace_thread_mutex; extern struct cfs_wi_sched *cfs_sched_rehash; @@ -495,4 +491,6 @@ static void exit_libcfs_module(void) libcfs_arch_cleanup(); } -cfs_module(libcfs, "1.0.0", init_libcfs_module, exit_libcfs_module); +MODULE_VERSION("1.0.0"); +module_init(init_libcfs_module); +module_exit(exit_libcfs_module); diff --git a/drivers/staging/lustre/lustre/libcfs/nidstrings.c b/drivers/staging/lustre/lustre/libcfs/nidstrings.c index ccfd1078a90..99c9e9d2493 100644 --- a/drivers/staging/lustre/lustre/libcfs/nidstrings.c +++ b/drivers/staging/lustre/lustre/libcfs/nidstrings.c @@ -785,7 +785,6 @@ cfs_parse_nidlist(char *str, int len, struct list_head *nidlist) struct cfs_lstr src; struct cfs_lstr res; int rc; - ENTRY; src.ls_str = str; src.ls_len = len; @@ -794,15 +793,15 @@ cfs_parse_nidlist(char *str, int len, struct list_head *nidlist) rc = cfs_gettok(&src, ' ', &res); if (rc == 0) { cfs_free_nidlist(nidlist); - RETURN(0); + return 0; } rc = parse_nidrange(&res, nidlist); if (rc == 0) { cfs_free_nidlist(nidlist); - RETURN(0); + return 0; } } - RETURN(1); + return 1; } /* @@ -834,7 +833,6 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist) { struct nidrange *nr; struct addrrange *ar; - ENTRY; list_for_each_entry(nr, nidlist, nr_link) { if (nr->nr_netstrfns->nf_type != LNET_NETTYP(LNET_NIDNET(nid))) @@ -842,13 +840,13 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist) if (nr->nr_netnum != LNET_NETNUM(LNET_NIDNET(nid))) continue; if (nr->nr_all) - RETURN(1); + return 1; list_for_each_entry(ar, &nr->nr_addrranges, ar_link) if (nr->nr_netstrfns->nf_match_addr(LNET_NIDADDR(nid), &ar->ar_numaddr_ranges)) - RETURN(1); + return 1; } - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index 439e71dfae3..357f40079ae 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -275,12 +275,9 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, int i; int remain; int mask = msgdata->msg_mask; - char *file = (char *)msgdata->msg_file; + const char *file = kbasename(msgdata->msg_file); cfs_debug_limit_state_t *cdls = msgdata->msg_cdls; - if (strchr(file, '/')) - file = strrchr(file, '/') + 1; - tcd = cfs_trace_get_tcd(); /* cfs_trace_get_tcd() grabs a lock, which disables preemption and @@ -529,7 +526,7 @@ static void collect_pages_on_all_cpus(struct page_collection *pc) int i, cpu; spin_lock(&pc->pc_lock); - cfs_for_each_possible_cpu(cpu) { + for_each_possible_cpu(cpu) { cfs_tcd_for_each_type_lock(tcd, i, cpu) { list_splice_init(&tcd->tcd_pages, &pc->pc_pages); tcd->tcd_cur_pages = 0; @@ -562,7 +559,7 @@ static void put_pages_back_on_all_cpus(struct page_collection *pc) int i, cpu; spin_lock(&pc->pc_lock); - cfs_for_each_possible_cpu(cpu) { + for_each_possible_cpu(cpu) { cfs_tcd_for_each_type_lock(tcd, i, cpu) { cur_head = tcd->tcd_pages.next; @@ -630,7 +627,7 @@ static void put_pages_on_daemon_list(struct page_collection *pc) struct cfs_trace_cpu_data *tcd; int i, cpu; - cfs_for_each_possible_cpu(cpu) { + for_each_possible_cpu(cpu) { cfs_tcd_for_each_type_lock(tcd, i, cpu) put_pages_on_tcd_daemon_list(pc, tcd); } @@ -1159,7 +1156,7 @@ static void trace_cleanup_on_all_cpus(void) struct cfs_trace_page *tmp; int i, cpu; - cfs_for_each_possible_cpu(cpu) { + for_each_possible_cpu(cpu) { cfs_tcd_for_each_type_lock(tcd, i, cpu) { tcd->tcd_shutting_down = 1; diff --git a/drivers/staging/lustre/lustre/libcfs/upcall_cache.c b/drivers/staging/lustre/lustre/libcfs/upcall_cache.c index 18c68c3493b..245b46f0dd9 100644 --- a/drivers/staging/lustre/lustre/libcfs/upcall_cache.c +++ b/drivers/staging/lustre/lustre/libcfs/upcall_cache.c @@ -152,7 +152,6 @@ struct upcall_cache_entry *upcall_cache_get_entry(struct upcall_cache *cache, struct list_head *head; wait_queue_t wait; int rc, found; - ENTRY; LASSERT(cache); @@ -176,7 +175,7 @@ find_again: new = alloc_entry(cache, key, args); if (!new) { CERROR("fail to alloc entry\n"); - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); } goto find_again; } else { @@ -266,17 +265,14 @@ find_again: /* Now we know it's good */ out: spin_unlock(&cache->uc_lock); - RETURN(entry); + return entry; } EXPORT_SYMBOL(upcall_cache_get_entry); void upcall_cache_put_entry(struct upcall_cache *cache, struct upcall_cache_entry *entry) { - ENTRY; - if (!entry) { - EXIT; return; } @@ -284,7 +280,6 @@ void upcall_cache_put_entry(struct upcall_cache *cache, spin_lock(&cache->uc_lock); put_entry(cache, entry); spin_unlock(&cache->uc_lock); - EXIT; } EXPORT_SYMBOL(upcall_cache_put_entry); @@ -294,7 +289,6 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key, struct upcall_cache_entry *entry = NULL; struct list_head *head; int found = 0, rc = 0; - ENTRY; LASSERT(cache); @@ -314,7 +308,7 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key, cache->uc_name, key); /* haven't found, it's possible */ spin_unlock(&cache->uc_lock); - RETURN(-EINVAL); + return -EINVAL; } if (err) { @@ -356,7 +350,7 @@ out: wake_up_all(&entry->ue_waitq); put_entry(cache, entry); - RETURN(rc); + return rc; } EXPORT_SYMBOL(upcall_cache_downcall); @@ -364,7 +358,6 @@ static void cache_flush(struct upcall_cache *cache, int force) { struct upcall_cache_entry *entry, *next; int i; - ENTRY; spin_lock(&cache->uc_lock); for (i = 0; i < UC_CACHE_HASH_SIZE; i++) { @@ -379,7 +372,6 @@ static void cache_flush(struct upcall_cache *cache, int force) } } spin_unlock(&cache->uc_lock); - EXIT; } void upcall_cache_flush_idle(struct upcall_cache *cache) @@ -399,7 +391,6 @@ void upcall_cache_flush_one(struct upcall_cache *cache, __u64 key, void *args) struct list_head *head; struct upcall_cache_entry *entry; int found = 0; - ENTRY; head = &cache->uc_hashtable[UC_CACHE_HASH_INDEX(key)]; @@ -431,11 +422,10 @@ struct upcall_cache *upcall_cache_init(const char *name, const char *upcall, { struct upcall_cache *cache; int i; - ENTRY; LIBCFS_ALLOC(cache, sizeof(*cache)); if (!cache) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); spin_lock_init(&cache->uc_lock); rwlock_init(&cache->uc_upcall_rwlock); @@ -448,7 +438,7 @@ struct upcall_cache *upcall_cache_init(const char *name, const char *upcall, cache->uc_acquire_expire = 30; cache->uc_ops = ops; - RETURN(cache); + return cache; } EXPORT_SYMBOL(upcall_cache_init); diff --git a/drivers/staging/lustre/lustre/libcfs/watchdog.c b/drivers/staging/lustre/lustre/libcfs/watchdog.c deleted file mode 100644 index 7c385ada3e1..00000000000 --- a/drivers/staging/lustre/lustre/libcfs/watchdog.c +++ /dev/null @@ -1,516 +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) 2008, 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. - * - * libcfs/libcfs/watchdog.c - * - * Author: Jacob Berkman <jacob@clusterfs.com> - */ - -#define DEBUG_SUBSYSTEM S_LNET - -#include <linux/libcfs/libcfs.h> -#include "tracefile.h" - -struct lc_watchdog { - spinlock_t lcw_lock; /* check or change lcw_list */ - int lcw_refcount; /* must hold lcw_pending_timers_lock */ - timer_list_t lcw_timer; /* kernel timer */ - struct list_head lcw_list; /* chain on pending list */ - cfs_time_t lcw_last_touched; /* last touched stamp */ - task_t *lcw_task; /* owner task */ - void (*lcw_callback)(pid_t, void *); - void *lcw_data; - - pid_t lcw_pid; - - enum { - LC_WATCHDOG_DISABLED, - LC_WATCHDOG_ENABLED, - LC_WATCHDOG_EXPIRED - } lcw_state; -}; - -#ifdef WITH_WATCHDOG -/* - * The dispatcher will complete lcw_start_completion when it starts, - * and lcw_stop_completion when it exits. - * Wake lcw_event_waitq to signal timer callback dispatches. - */ -static struct completion lcw_start_completion; -static struct completion lcw_stop_completion; -static wait_queue_head_t lcw_event_waitq; - -/* - * Set this and wake lcw_event_waitq to stop the dispatcher. - */ -enum { - LCW_FLAG_STOP = 0 -}; -static unsigned long lcw_flags = 0; - -/* - * Number of outstanding watchdogs. - * When it hits 1, we start the dispatcher. - * When it hits 0, we stop the dispatcher. - */ -static __u32 lcw_refcount = 0; -static DEFINE_MUTEX(lcw_refcount_mutex); - -/* - * List of timers that have fired that need their callbacks run by the - * dispatcher. - */ -/* BH lock! */ -static DEFINE_SPINLOCK(lcw_pending_timers_lock); -static struct list_head lcw_pending_timers = LIST_HEAD_INIT(lcw_pending_timers); - -/* Last time a watchdog expired */ -static cfs_time_t lcw_last_watchdog_time; -static int lcw_recent_watchdog_count; - -static void -lcw_dump(struct lc_watchdog *lcw) -{ - ENTRY; - rcu_read_lock(); - if (lcw->lcw_task == NULL) { - LCONSOLE_WARN("Process " LPPID " was not found in the task " - "list; watchdog callback may be incomplete\n", - (int)lcw->lcw_pid); - } else { - libcfs_debug_dumpstack(lcw->lcw_task); - } - - rcu_read_unlock(); - EXIT; -} - -static void lcw_cb(ulong_ptr_t data) -{ - struct lc_watchdog *lcw = (struct lc_watchdog *)data; - ENTRY; - - if (lcw->lcw_state != LC_WATCHDOG_ENABLED) { - EXIT; - return; - } - - lcw->lcw_state = LC_WATCHDOG_EXPIRED; - - spin_lock_bh(&lcw->lcw_lock); - LASSERT(list_empty(&lcw->lcw_list)); - - spin_lock_bh(&lcw_pending_timers_lock); - lcw->lcw_refcount++; /* +1 for pending list */ - list_add(&lcw->lcw_list, &lcw_pending_timers); - wake_up(&lcw_event_waitq); - - spin_unlock_bh(&lcw_pending_timers_lock); - spin_unlock_bh(&lcw->lcw_lock); - EXIT; -} - -static int is_watchdog_fired(void) -{ - int rc; - - if (test_bit(LCW_FLAG_STOP, &lcw_flags)) - return 1; - - spin_lock_bh(&lcw_pending_timers_lock); - rc = !list_empty(&lcw_pending_timers); - spin_unlock_bh(&lcw_pending_timers_lock); - return rc; -} - -static void lcw_dump_stack(struct lc_watchdog *lcw) -{ - cfs_time_t current_time; - cfs_duration_t delta_time; - struct timeval timediff; - - current_time = cfs_time_current(); - delta_time = cfs_time_sub(current_time, lcw->lcw_last_touched); - cfs_duration_usec(delta_time, &timediff); - - /* - * Check to see if we should throttle the watchdog timer to avoid - * too many dumps going to the console thus triggering an NMI. - */ - delta_time = cfs_duration_sec(cfs_time_sub(current_time, - lcw_last_watchdog_time)); - - if (delta_time < libcfs_watchdog_ratelimit && - lcw_recent_watchdog_count > 3) { - LCONSOLE_WARN("Service thread pid %u was inactive for " - "%lu.%.02lus. Watchdog stack traces are limited " - "to 3 per %d seconds, skipping this one.\n", - (int)lcw->lcw_pid, - timediff.tv_sec, - timediff.tv_usec / 10000, - libcfs_watchdog_ratelimit); - } else { - if (delta_time < libcfs_watchdog_ratelimit) { - lcw_recent_watchdog_count++; - } else { - memcpy(&lcw_last_watchdog_time, ¤t_time, - sizeof(current_time)); - lcw_recent_watchdog_count = 0; - } - - LCONSOLE_WARN("Service thread pid %u was inactive for " - "%lu.%.02lus. The thread might be hung, or it " - "might only be slow and will resume later. " - "Dumping the stack trace for debugging purposes:" - "\n", - (int)lcw->lcw_pid, - timediff.tv_sec, - timediff.tv_usec / 10000); - lcw_dump(lcw); - } -} - -static int lcw_dispatch_main(void *data) -{ - int rc = 0; - struct lc_watchdog *lcw; - LIST_HEAD (zombies); - - ENTRY; - - complete(&lcw_start_completion); - - while (1) { - int dumplog = 1; - - cfs_wait_event_interruptible(lcw_event_waitq, - is_watchdog_fired(), rc); - CDEBUG(D_INFO, "Watchdog got woken up...\n"); - if (test_bit(LCW_FLAG_STOP, &lcw_flags)) { - CDEBUG(D_INFO, "LCW_FLAG_STOP set, shutting down...\n"); - - spin_lock_bh(&lcw_pending_timers_lock); - rc = !list_empty(&lcw_pending_timers); - spin_unlock_bh(&lcw_pending_timers_lock); - if (rc) { - CERROR("pending timers list was not empty at " - "time of watchdog dispatch shutdown\n"); - } - break; - } - - spin_lock_bh(&lcw_pending_timers_lock); - while (!list_empty(&lcw_pending_timers)) { - int is_dumplog; - - lcw = list_entry(lcw_pending_timers.next, - struct lc_watchdog, lcw_list); - /* +1 ref for callback to make sure lwc wouldn't be - * deleted after releasing lcw_pending_timers_lock */ - lcw->lcw_refcount++; - spin_unlock_bh(&lcw_pending_timers_lock); - - /* lock ordering */ - spin_lock_bh(&lcw->lcw_lock); - spin_lock_bh(&lcw_pending_timers_lock); - - if (list_empty(&lcw->lcw_list)) { - /* already removed from pending list */ - lcw->lcw_refcount--; /* -1 ref for callback */ - if (lcw->lcw_refcount == 0) - list_add(&lcw->lcw_list, &zombies); - spin_unlock_bh(&lcw->lcw_lock); - /* still hold lcw_pending_timers_lock */ - continue; - } - - list_del_init(&lcw->lcw_list); - lcw->lcw_refcount--; /* -1 ref for pending list */ - - spin_unlock_bh(&lcw_pending_timers_lock); - spin_unlock_bh(&lcw->lcw_lock); - - CDEBUG(D_INFO, "found lcw for pid " LPPID "\n", - lcw->lcw_pid); - lcw_dump_stack(lcw); - - is_dumplog = lcw->lcw_callback == lc_watchdog_dumplog; - if (lcw->lcw_state != LC_WATCHDOG_DISABLED && - (dumplog || !is_dumplog)) { - lcw->lcw_callback(lcw->lcw_pid, lcw->lcw_data); - if (dumplog && is_dumplog) - dumplog = 0; - } - - spin_lock_bh(&lcw_pending_timers_lock); - lcw->lcw_refcount--; /* -1 ref for callback */ - if (lcw->lcw_refcount == 0) - list_add(&lcw->lcw_list, &zombies); - } - spin_unlock_bh(&lcw_pending_timers_lock); - - while (!list_empty(&zombies)) { - lcw = list_entry(lcw_pending_timers.next, - struct lc_watchdog, lcw_list); - list_del(&lcw->lcw_list); - LIBCFS_FREE(lcw, sizeof(*lcw)); - } - } - - complete(&lcw_stop_completion); - - RETURN(rc); -} - -static void lcw_dispatch_start(void) -{ - task_t *task; - - ENTRY; - LASSERT(lcw_refcount == 1); - - init_completion(&lcw_stop_completion); - init_completion(&lcw_start_completion); - init_waitqueue_head(&lcw_event_waitq); - - CDEBUG(D_INFO, "starting dispatch thread\n"); - task = kthread_run(lcw_dispatch_main, NULL, "lc_watchdogd"); - if (IS_ERR(task)) { - CERROR("error spawning watchdog dispatch thread: %ld\n", - PTR_ERR(task)); - EXIT; - return; - } - wait_for_completion(&lcw_start_completion); - CDEBUG(D_INFO, "watchdog dispatcher initialization complete.\n"); - - EXIT; -} - -static void lcw_dispatch_stop(void) -{ - ENTRY; - LASSERT(lcw_refcount == 0); - - CDEBUG(D_INFO, "trying to stop watchdog dispatcher.\n"); - - set_bit(LCW_FLAG_STOP, &lcw_flags); - wake_up(&lcw_event_waitq); - - wait_for_completion(&lcw_stop_completion); - - CDEBUG(D_INFO, "watchdog dispatcher has shut down.\n"); - - EXIT; -} - -struct lc_watchdog *lc_watchdog_add(int timeout, - void (*callback)(pid_t, void *), - void *data) -{ - struct lc_watchdog *lcw = NULL; - ENTRY; - - LIBCFS_ALLOC(lcw, sizeof(*lcw)); - if (lcw == NULL) { - CDEBUG(D_INFO, "Could not allocate new lc_watchdog\n"); - RETURN(ERR_PTR(-ENOMEM)); - } - - spin_lock_init(&lcw->lcw_lock); - lcw->lcw_refcount = 1; /* refcount for owner */ - lcw->lcw_task = current; - lcw->lcw_pid = current_pid(); - lcw->lcw_callback = (callback != NULL) ? callback : lc_watchdog_dumplog; - lcw->lcw_data = data; - lcw->lcw_state = LC_WATCHDOG_DISABLED; - - INIT_LIST_HEAD(&lcw->lcw_list); - cfs_timer_init(&lcw->lcw_timer, lcw_cb, lcw); - - mutex_lock(&lcw_refcount_mutex); - if (++lcw_refcount == 1) - lcw_dispatch_start(); - mutex_unlock(&lcw_refcount_mutex); - - /* Keep this working in case we enable them by default */ - if (lcw->lcw_state == LC_WATCHDOG_ENABLED) { - lcw->lcw_last_touched = cfs_time_current(); - cfs_timer_arm(&lcw->lcw_timer, cfs_time_seconds(timeout) + - cfs_time_current()); - } - - RETURN(lcw); -} -EXPORT_SYMBOL(lc_watchdog_add); - -static void lcw_update_time(struct lc_watchdog *lcw, const char *message) -{ - cfs_time_t newtime = cfs_time_current();; - - if (lcw->lcw_state == LC_WATCHDOG_EXPIRED) { - struct timeval timediff; - cfs_time_t delta_time = cfs_time_sub(newtime, - lcw->lcw_last_touched); - cfs_duration_usec(delta_time, &timediff); - - LCONSOLE_WARN("Service thread pid %u %s after %lu.%.02lus. " - "This indicates the system was overloaded (too " - "many service threads, or there were not enough " - "hardware resources).\n", - lcw->lcw_pid, - message, - timediff.tv_sec, - timediff.tv_usec / 10000); - } - lcw->lcw_last_touched = newtime; -} - -static void lc_watchdog_del_pending(struct lc_watchdog *lcw) -{ - spin_lock_bh(&lcw->lcw_lock); - if (unlikely(!list_empty(&lcw->lcw_list))) { - spin_lock_bh(&lcw_pending_timers_lock); - list_del_init(&lcw->lcw_list); - lcw->lcw_refcount--; /* -1 ref for pending list */ - spin_unlock_bh(&lcw_pending_timers_lock); - } - - spin_unlock_bh(&lcw->lcw_lock); -} - -void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout) -{ - ENTRY; - LASSERT(lcw != NULL); - - lc_watchdog_del_pending(lcw); - - lcw_update_time(lcw, "resumed"); - lcw->lcw_state = LC_WATCHDOG_ENABLED; - - cfs_timer_arm(&lcw->lcw_timer, cfs_time_current() + - cfs_time_seconds(timeout)); - - EXIT; -} -EXPORT_SYMBOL(lc_watchdog_touch); - -void lc_watchdog_disable(struct lc_watchdog *lcw) -{ - ENTRY; - LASSERT(lcw != NULL); - - lc_watchdog_del_pending(lcw); - - lcw_update_time(lcw, "completed"); - lcw->lcw_state = LC_WATCHDOG_DISABLED; - - EXIT; -} -EXPORT_SYMBOL(lc_watchdog_disable); - -void lc_watchdog_delete(struct lc_watchdog *lcw) -{ - int dead; - - ENTRY; - LASSERT(lcw != NULL); - - cfs_timer_disarm(&lcw->lcw_timer); - - lcw_update_time(lcw, "stopped"); - - spin_lock_bh(&lcw->lcw_lock); - spin_lock_bh(&lcw_pending_timers_lock); - if (unlikely(!list_empty(&lcw->lcw_list))) { - list_del_init(&lcw->lcw_list); - lcw->lcw_refcount--; /* -1 ref for pending list */ - } - - lcw->lcw_refcount--; /* -1 ref for owner */ - dead = lcw->lcw_refcount == 0; - spin_unlock_bh(&lcw_pending_timers_lock); - spin_unlock_bh(&lcw->lcw_lock); - - if (dead) - LIBCFS_FREE(lcw, sizeof(*lcw)); - - mutex_lock(&lcw_refcount_mutex); - if (--lcw_refcount == 0) - lcw_dispatch_stop(); - mutex_unlock(&lcw_refcount_mutex); - - EXIT; -} -EXPORT_SYMBOL(lc_watchdog_delete); - -/* - * Provided watchdog handlers - */ - -void lc_watchdog_dumplog(pid_t pid, void *data) -{ - libcfs_debug_dumplog_internal((void *)((long_ptr_t)pid)); -} -EXPORT_SYMBOL(lc_watchdog_dumplog); - -#else /* !defined(WITH_WATCHDOG) */ - -struct lc_watchdog *lc_watchdog_add(int timeout, - void (*callback)(pid_t pid, void *), - void *data) -{ - static struct lc_watchdog watchdog; - return &watchdog; -} -EXPORT_SYMBOL(lc_watchdog_add); - -void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout) -{ -} -EXPORT_SYMBOL(lc_watchdog_touch); - -void lc_watchdog_disable(struct lc_watchdog *lcw) -{ -} -EXPORT_SYMBOL(lc_watchdog_disable); - -void lc_watchdog_delete(struct lc_watchdog *lcw) -{ -} -EXPORT_SYMBOL(lc_watchdog_delete); - -#endif diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c index b533666c190..1a55c81892e 100644 --- a/drivers/staging/lustre/lustre/libcfs/workitem.c +++ b/drivers/staging/lustre/lustre/libcfs/workitem.c @@ -376,7 +376,8 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab, rc = 0; while (nthrs > 0) { char name[16]; - task_t *task; + struct task_struct *task; + spin_lock(&cfs_wi_data.wi_glock); while (sched->ws_starting > 0) { spin_unlock(&cfs_wi_data.wi_glock); @@ -396,7 +397,7 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab, sched->ws_name, sched->ws_nthreads); } - task = kthread_run(cfs_wi_scheduler, sched, name); + task = kthread_run(cfs_wi_scheduler, sched, "%s", name); if (!IS_ERR(task)) { nthrs--; continue; diff --git a/drivers/staging/lustre/lustre/llite/Makefile b/drivers/staging/lustre/lustre/llite/Makefile index dff0c0486e7..f493e074000 100644 --- a/drivers/staging/lustre/lustre/llite/Makefile +++ b/drivers/staging/lustre/lustre/llite/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_LUSTRE_FS) += lustre.o -obj-$(CONFIG_LUSTRE_FS) += llite_lloop.o +obj-$(CONFIG_LUSTRE_LLITE_LLOOP) += llite_lloop.o lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \ rw.o lproc_llite.o namei.o symlink.o llite_mmap.o \ xattr.o remote_perm.o llite_rmtacl.o llite_capa.o \ diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index ff0d085077c..e7629be3973 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -59,11 +59,11 @@ static void free_dentry_data(struct rcu_head *head) static void ll_release(struct dentry *de) { struct ll_dentry_data *lld; - ENTRY; + LASSERT(de != NULL); lld = ll_d2d(de); if (lld == NULL) /* NFS copies the de->d_op methods (bug 4655) */ - RETURN_EXIT; + return; if (lld->lld_it) { ll_intent_release(lld->lld_it); @@ -73,8 +73,6 @@ static void ll_release(struct dentry *de) LASSERT(lld->lld_mnt_count == 0); de->d_fsdata = NULL; call_rcu(&lld->lld_rcu_head, free_dentry_data); - - EXIT; } /* Compare if two dentries are the same. Don't match if the existing dentry @@ -84,17 +82,14 @@ static void ll_release(struct dentry *de) * an AST before calling d_revalidate_it(). The dentry still exists (marked * INVALID) so d_lookup() matches it, but we have no lock on it (so * lock_match() fails) and we spin around real_lookup(). */ -int ll_dcompare(const struct dentry *parent, const struct inode *pinode, - const struct dentry *dentry, const struct inode *inode, +int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, unsigned int len, const char *str, const struct qstr *name) { - ENTRY; - if (len != name->len) - RETURN(1); + return 1; if (memcmp(str, name->name, len)) - RETURN(1); + return 1; CDEBUG(D_DENTRY, "found name %.*s(%p) flags %#x refc %d\n", name->len, name->name, dentry, dentry->d_flags, @@ -102,12 +97,12 @@ int ll_dcompare(const struct dentry *parent, const struct inode *pinode, /* mountpoint is always valid */ if (d_mountpoint((struct dentry *)dentry)) - RETURN(0); + return 0; if (d_lustre_invalid(dentry)) - RETURN(1); + return 1; - RETURN(0); + return 0; } static inline int return_if_equal(struct ldlm_lock *lock, void *data) @@ -128,22 +123,21 @@ static int find_cbdata(struct inode *inode) struct ll_sb_info *sbi = ll_i2sbi(inode); struct lov_stripe_md *lsm; int rc = 0; - ENTRY; LASSERT(inode); rc = md_find_cbdata(sbi->ll_md_exp, ll_inode2fid(inode), return_if_equal, NULL); if (rc != 0) - RETURN(rc); + return rc; lsm = ccc_inode_lsm_get(inode); if (lsm == NULL) - RETURN(rc); + return rc; rc = obd_find_cbdata(sbi->ll_dt_exp, lsm, return_if_equal, NULL); ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } /** @@ -155,7 +149,6 @@ static int find_cbdata(struct inode *inode) */ static int ll_ddelete(const struct dentry *de) { - ENTRY; LASSERT(de); CDEBUG(D_DENTRY, "%s dentry %.*s (%p, parent %p, inode %p) %s%s\n", @@ -179,13 +172,12 @@ static int ll_ddelete(const struct dentry *de) #endif if (d_lustre_invalid((struct dentry *)de)) - RETURN(1); - RETURN(0); + return 1; + return 0; } static int ll_set_dd(struct dentry *de) { - ENTRY; LASSERT(de != NULL); CDEBUG(D_DENTRY, "ldd on dentry %.*s (%p) parent %p inode %p refc %d\n", @@ -204,11 +196,11 @@ static int ll_set_dd(struct dentry *de) OBD_FREE_PTR(lld); spin_unlock(&de->d_lock); } else { - RETURN(-ENOMEM); + return -ENOMEM; } } - RETURN(0); + return 0; } int ll_dops_init(struct dentry *de, int block, int init_sa) @@ -260,8 +252,6 @@ void ll_intent_drop_lock(struct lookup_intent *it) void ll_intent_release(struct lookup_intent *it) { - ENTRY; - CDEBUG(D_INFO, "intent %p released\n", it); ll_intent_drop_lock(it); /* We are still holding extra reference on a request, need to free it */ @@ -275,14 +265,12 @@ void ll_intent_release(struct lookup_intent *it) it->d.lustre.it_disposition = 0; it->d.lustre.it_data = NULL; - EXIT; } void ll_invalidate_aliases(struct inode *inode) { struct dentry *dentry; struct ll_d_hlist_node *p; - ENTRY; LASSERT(inode != NULL); @@ -296,18 +284,17 @@ void ll_invalidate_aliases(struct inode *inode) dentry->d_name.name, dentry, dentry->d_parent, dentry->d_inode, dentry->d_flags); - if (dentry->d_name.len == 1 && dentry->d_name.name[0] == '/') { - CERROR("called on root (?) dentry=%p, inode=%p " - "ino=%lu\n", dentry, inode, inode->i_ino); + if (unlikely(dentry == dentry->d_sb->s_root)) { + CERROR("%s: called on root dentry=%p, fid="DFID"\n", + ll_get_fsname(dentry->d_sb, NULL, 0), + dentry, PFID(ll_inode2fid(inode))); lustre_dump_dentry(dentry, 1); - libcfs_debug_dumpstack(NULL); + dump_stack(); } d_lustre_invalidate(dentry, 0); } ll_unlock_dcache(inode); - - EXIT; } int ll_revalidate_it_finish(struct ptlrpc_request *request, @@ -315,17 +302,16 @@ int ll_revalidate_it_finish(struct ptlrpc_request *request, struct dentry *de) { int rc = 0; - ENTRY; if (!request) - RETURN(0); + return 0; if (it_disposition(it, DISP_LOOKUP_NEG)) - RETURN(-ENOENT); + return -ENOENT; rc = ll_prep_inode(&de->d_inode, request, NULL, it); - RETURN(rc); + return rc; } void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry) @@ -370,7 +356,6 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, struct inode *parent = de->d_parent->d_inode; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%s,intent=%s\n", de->d_name.name, LL_IT2STR(it)); @@ -383,10 +368,10 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, away this negative dentry and actually do the request to kernel to create whatever needs to be created (if possible)*/ if (it && (it->it_op & IT_CREAT)) - RETURN(0); + return 0; if (d_lustre_invalid(de)) - RETURN(0); + return 0; ibits = MDS_INODELOCK_UPDATE; rc = ll_have_md_lock(parent, &ibits, LCK_MINMODE); @@ -413,7 +398,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, LASSERT(it); if (it->it_op == IT_LOOKUP && !d_lustre_invalid(de)) - RETURN(1); + return 1; if (it->it_op == IT_OPEN) { struct inode *inode = de->d_inode; @@ -460,7 +445,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, if it would be, we'll reopen the open request to MDS later during file open path */ mutex_unlock(&lli->lli_och_mutex); - RETURN(1); + return 1; } else { mutex_unlock(&lli->lli_och_mutex); } @@ -479,7 +464,7 @@ do_lock: de->d_name.name, de->d_name.len, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); if (!IS_POSIXACL(parent) || !exp_connect_umask(exp)) it->it_create_mode &= ~current_umask(); @@ -566,7 +551,7 @@ out: mark: if (it != NULL && it->it_op == IT_GETATTR && rc > 0) ll_statahead_mark(parent, de); - RETURN(rc); + return rc; /* * This part is here to combat evil-evil race in real_lookup on 2.6 @@ -598,7 +583,7 @@ do_lookup: LUSTRE_OPC_CREATE : LUSTRE_OPC_ANY), NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); rc = md_intent_lock(exp, op_data, NULL, 0, it, 0, &req, ll_md_blocking_ast, 0); @@ -639,14 +624,13 @@ int ll_revalidate_nd(struct dentry *dentry, unsigned int flags) struct inode *parent = dentry->d_parent->d_inode; int unplug = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%s,flags=%u\n", dentry->d_name.name, flags); if (!(flags & (LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE)) && ll_need_statahead(parent, dentry) > 0) { if (flags & LOOKUP_RCU) - RETURN(-ECHILD); + return -ECHILD; if (dentry->d_inode == NULL) unplug = 1; @@ -654,7 +638,7 @@ int ll_revalidate_nd(struct dentry *dentry, unsigned int flags) ll_statahead_mark(parent, dentry); } - RETURN(1); + return 1; } diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 23c61fe8196..09844be5eec 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -41,14 +41,13 @@ #include <linux/fs.h> #include <linux/pagemap.h> #include <linux/mm.h> -#include <linux/version.h> #include <asm/uaccess.h> #include <linux/buffer_head.h> // for wait_on_buffer #include <linux/pagevec.h> +#include <linux/prefetch.h> #define DEBUG_SUBSYSTEM S_LLITE -#include <lustre/lustre_idl.h> #include <obd_support.h> #include <obd_class.h> #include <lustre_lib.h> @@ -158,7 +157,6 @@ static int ll_dir_filler(void *_hash, struct page *page0) int npages; int i; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) hash "LPU64"\n", inode->i_ino, inode->i_generation, inode, hash); @@ -239,7 +237,6 @@ static int ll_dir_filler(void *_hash, struct page *page0) if (page_pool != &page0) OBD_FREE(page_pool, sizeof(struct page *) * max_pages); - EXIT; return rc; } @@ -355,15 +352,12 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, rc = md_lock_match(ll_i2sbi(dir)->ll_md_exp, LDLM_FL_BLOCK_GRANTED, ll_inode2fid(dir), LDLM_IBITS, &policy, mode, &lockh); if (!rc) { - struct ldlm_enqueue_info einfo = {.ei_type = LDLM_IBITS, - .ei_mode = mode, - .ei_cb_bl = - ll_md_blocking_ast, - .ei_cb_cp = - ldlm_completion_ast, - .ei_cb_gl = NULL, - .ei_cb_wg = NULL, - .ei_cbdata = NULL}; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_IBITS, + .ei_mode = mode, + .ei_cb_bl = ll_md_blocking_ast, + .ei_cb_cp = ldlm_completion_ast, + }; struct lookup_intent it = { .it_op = IT_READDIR }; struct ptlrpc_request *request; struct md_op_data *op_data; @@ -482,19 +476,17 @@ fail: goto out_unlock; } -int ll_dir_read(struct inode *inode, __u64 *_pos, void *cookie, - filldir_t filldir) +int ll_dir_read(struct inode *inode, struct dir_context *ctx) { struct ll_inode_info *info = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); - __u64 pos = *_pos; + __u64 pos = ctx->pos; int api32 = ll_need_32bit_api(sbi); int hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH; struct page *page; struct ll_dir_chain chain; int done = 0; int rc = 0; - ENTRY; ll_dir_chain_init(&chain); @@ -547,12 +539,14 @@ int ll_dir_read(struct inode *inode, __u64 *_pos, void *cookie, fid_le_to_cpu(&fid, &ent->lde_fid); ino = cl_fid_build_ino(&fid, api32); type = ll_dirent_type_get(ent); + ctx->pos = lhash; /* For 'll_nfs_get_name_filldir()', it will try * to access the 'ent' through its 'lde_name', - * so the parameter 'name' for 'filldir()' must - * be part of the 'ent'. */ - done = filldir(cookie, ent->lde_name, namelen, - lhash, ino, type); + * so the parameter 'name' for 'ctx->actor()' + * must be part of the 'ent'. + */ + done = !dir_emit(ctx, ent->lde_name, + namelen, ino, type); } next = le64_to_cpu(dp->ldp_hash_end); if (!done) { @@ -593,56 +587,49 @@ int ll_dir_read(struct inode *inode, __u64 *_pos, void *cookie, } } - *_pos = pos; + ctx->pos = pos; ll_dir_chain_fini(&chain); - RETURN(rc); + return rc; } -static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir) +static int ll_readdir(struct file *filp, struct dir_context *ctx) { struct inode *inode = filp->f_dentry->d_inode; struct ll_file_data *lfd = LUSTRE_FPRIVATE(filp); struct ll_sb_info *sbi = ll_i2sbi(inode); - __u64 pos = lfd->lfd_pos; int hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH; int api32 = ll_need_32bit_api(sbi); int rc; - struct path path; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %lu/%llu " " 32bit_api %d\n", inode->i_ino, inode->i_generation, - inode, (unsigned long)pos, i_size_read(inode), api32); + inode, (unsigned long)lfd->lfd_pos, i_size_read(inode), api32); - if (pos == MDS_DIR_END_OFF) + if (lfd->lfd_pos == MDS_DIR_END_OFF) /* * end-of-file. */ GOTO(out, rc = 0); - rc = ll_dir_read(inode, &pos, cookie, filldir); - lfd->lfd_pos = pos; - if (pos == MDS_DIR_END_OFF) { + ctx->pos = lfd->lfd_pos; + rc = ll_dir_read(inode, ctx); + lfd->lfd_pos = ctx->pos; + if (ctx->pos == MDS_DIR_END_OFF) { if (api32) - filp->f_pos = LL_DIR_END_OFF_32BIT; + ctx->pos = LL_DIR_END_OFF_32BIT; else - filp->f_pos = LL_DIR_END_OFF; + ctx->pos = LL_DIR_END_OFF; } else { if (api32 && hash64) - filp->f_pos = pos >> 32; - else - filp->f_pos = pos; + ctx->pos >>= 32; } filp->f_version = inode->i_version; - path.mnt = filp->f_path.mnt; - path.dentry = filp->f_dentry; - touch_atime(&path); out: if (!rc) ll_stats_ops_tally(sbi, LPROC_LL_READDIR, 1); - RETURN(rc); + return rc; } int ll_send_mgc_param(struct obd_export *mgc, char *string) @@ -673,8 +660,6 @@ int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump, int mode; int err; - ENTRY; - mode = (0755 & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR; op_data = ll_prep_md_op_data(NULL, dir, NULL, filename, strlen(filename), mode, LUSTRE_OPC_MKDIR, @@ -684,7 +669,8 @@ int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump, op_data->op_cli_flags |= CLI_SET_MEA; err = md_create(sbi->ll_md_exp, op_data, lump, sizeof(*lump), mode, - current_fsuid(), current_fsgid(), + from_kuid(&init_user_ns, current_fsuid()), + from_kgid(&init_user_ns, current_fsgid()), cfs_curproc_cap_pack(), 0, &request); ll_finish_md_op_data(op_data); if (err) @@ -704,7 +690,6 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, struct lustre_sb_info *lsi = s2lsi(inode->i_sb); struct obd_device *mgc = lsi->lsi_mgc; int lum_size; - ENTRY; if (lump != NULL) { /* @@ -731,7 +716,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, " %#08x != %#08x nor %#08x\n", lump->lmm_magic, LOV_USER_MAGIC_V1, LOV_USER_MAGIC_V3); - RETURN(-EINVAL); + return -EINVAL; } } } else { @@ -741,7 +726,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); if (lump != NULL && lump->lmm_magic == cpu_to_le32(LMV_USER_MAGIC)) op_data->op_cli_flags |= CLI_SET_MEA; @@ -797,7 +782,7 @@ end: if (param != NULL) OBD_FREE(param, MGS_PARAM_MAXLEN); } - RETURN(rc); + return rc; } int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, @@ -812,13 +797,13 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, rc = ll_get_max_mdsize(sbi, &lmmsize); if (rc) - RETURN(rc); + return rc; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, lmmsize, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA; rc = md_getattr(sbi->ll_md_exp, op_data, &req); @@ -878,12 +863,11 @@ int ll_get_mdt_idx(struct inode *inode) struct ll_sb_info *sbi = ll_i2sbi(inode); struct md_op_data *op_data; int rc, mdtidx; - ENTRY; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_flags |= MF_GET_MDT_IDX; rc = md_getattr(sbi->ll_md_exp, op_data, NULL); @@ -891,7 +875,7 @@ int ll_get_mdt_idx(struct inode *inode) ll_finish_md_op_data(op_data); if (rc < 0) { CDEBUG(D_INFO, "md_getattr_name: %d\n", rc); - RETURN(rc); + return rc; } return mdtidx; } @@ -912,7 +896,6 @@ static int ll_ioc_copy_start(struct super_block *sb, struct hsm_copy *copy) struct ll_sb_info *sbi = ll_s2sbi(sb); struct hsm_progress_kernel hpk; int rc; - ENTRY; /* Forge a hsm_progress based on data from copy. */ hpk.hpk_fid = copy->hc_hai.hai_fid; @@ -962,7 +945,7 @@ progress: rc = obd_iocontrol(LL_IOC_HSM_PROGRESS, sbi->ll_md_exp, sizeof(hpk), &hpk, NULL); - RETURN(rc); + return rc; } /** @@ -985,7 +968,6 @@ static int ll_ioc_copy_end(struct super_block *sb, struct hsm_copy *copy) struct ll_sb_info *sbi = ll_s2sbi(sb); struct hsm_progress_kernel hpk; int rc; - ENTRY; /* If you modify the logic here, also check llapi_hsm_copy_end(). */ /* Take care: copy->hc_hai.hai_action, len, gid and data are not @@ -1062,7 +1044,7 @@ progress: rc = obd_iocontrol(LL_IOC_HSM_PROGRESS, sbi->ll_md_exp, sizeof(hpk), &hpk, NULL); - RETURN(rc); + return rc; } @@ -1090,7 +1072,6 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) int id = qctl->qc_id; int valid = qctl->qc_valid; int rc = 0; - ENTRY; switch (cmd) { case LUSTRE_Q_INVALIDATE: @@ -1101,32 +1082,34 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) case Q_SETINFO: if (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT) - RETURN(-EPERM); + return -EPERM; break; case Q_GETQUOTA: - if (((type == USRQUOTA && current_euid() != id) || - (type == GRPQUOTA && !in_egroup_p(id))) && + if (((type == USRQUOTA && + uid_eq(current_euid(), make_kuid(&init_user_ns, id))) || + (type == GRPQUOTA && + !in_egroup_p(make_kgid(&init_user_ns, id)))) && (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT)) - RETURN(-EPERM); + return -EPERM; break; case Q_GETINFO: break; default: CERROR("unsupported quotactl op: %#x\n", cmd); - RETURN(-ENOTTY); + return -ENOTTY; } if (valid != QC_GENERAL) { if (sbi->ll_flags & LL_SBI_RMT_CLIENT) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (cmd == Q_GETINFO) qctl->qc_cmd = Q_GETOINFO; else if (cmd == Q_GETQUOTA) qctl->qc_cmd = Q_GETOQUOTA; else - RETURN(-EINVAL); + return -EINVAL; switch (valid) { case QC_MDTIDX: @@ -1151,7 +1134,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) } if (rc) - RETURN(rc); + return rc; qctl->qc_cmd = cmd; } else { @@ -1159,7 +1142,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) OBD_ALLOC_PTR(oqctl); if (oqctl == NULL) - RETURN(-ENOMEM); + return -ENOMEM; QCTL_COPY(oqctl, qctl); rc = obd_quotactl(sbi->ll_md_exp, oqctl); @@ -1169,7 +1152,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) obd_quotactl(sbi->ll_md_exp, oqctl); } OBD_FREE_PTR(oqctl); - RETURN(rc); + return rc; } /* If QIF_SPACE is not set, client should collect the * space usage from OSSs by itself */ @@ -1216,7 +1199,7 @@ out: OBD_FREE_PTR(oqctl); } - RETURN(rc); + return rc; } static char * @@ -1249,7 +1232,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct ll_sb_info *sbi = ll_i2sbi(inode); struct obd_ioctl_data *data; int rc = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), cmd=%#x\n", inode->i_ino, inode->i_generation, inode, cmd); @@ -1262,10 +1244,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) switch(cmd) { case FSFILT_IOC_GETFLAGS: case FSFILT_IOC_SETFLAGS: - RETURN(ll_iocontrol(inode, file, cmd, arg)); + return ll_iocontrol(inode, file, cmd, arg); case FSFILT_IOC_GETVERSION_OLD: case FSFILT_IOC_GETVERSION: - RETURN(put_user(inode->i_generation, (int *)arg)); + return put_user(inode->i_generation, (int *)arg); /* We need to special case any other ioctls we want to handle, * to send them to the MDS/OST as appropriate and to properly * network encode the arg field. @@ -1277,10 +1259,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) mdtidx = ll_get_mdt_idx(inode); if (mdtidx < 0) - RETURN(mdtidx); + return mdtidx; if (put_user((int)mdtidx, (int*)arg)) - RETURN(-EFAULT); + return -EFAULT; return 0; } @@ -1293,7 +1275,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = obd_ioctl_getdata(&buf, &len, (void *)arg); if (rc) - RETURN(rc); + return rc; data = (void *)buf; filename = data->ioc_inlbuf1; @@ -1317,7 +1299,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) GOTO(out_free, rc); } ptlrpc_req_finished(request); - EXIT; out_free: obd_ioctl_freedata(buf, len); return rc; @@ -1333,7 +1314,7 @@ out_free: rc = obd_ioctl_getdata(&buf, &len, (void *)arg); if (rc) - RETURN(rc); + return rc; data = (void *)buf; if (data->ioc_inlbuf1 == NULL || data->ioc_inlbuf2 == NULL || @@ -1364,7 +1345,7 @@ out_free: rc = ll_dir_setdirstripe(inode, lum, filename); lmv_out_free: obd_ioctl_freedata(buf, len); - RETURN(rc); + return rc; } case LL_IOC_LOV_SETSTRIPE: { @@ -1380,11 +1361,11 @@ lmv_out_free: sizeof(lumv3p->lmm_objects[0])); /* first try with v1 which is smaller than v3 */ if (copy_from_user(lumv1, lumv1p, sizeof(*lumv1))) - RETURN(-EFAULT); + return -EFAULT; if ((lumv1->lmm_magic == LOV_USER_MAGIC_V3) ) { if (copy_from_user(&lumv3, lumv3p, sizeof(lumv3))) - RETURN(-EFAULT); + return -EFAULT; } if (inode->i_sb->s_root == file->f_dentry) @@ -1393,7 +1374,7 @@ lmv_out_free: /* in v1 and v3 cases lumv1 points to data */ rc = ll_dir_setstripe(inode, lumv1, set_default); - RETURN(rc); + return rc; } case LL_IOC_LMV_GETSTRIPE: { struct lmv_user_md *lump = (struct lmv_user_md *)arg; @@ -1404,10 +1385,10 @@ lmv_out_free: int mdtindex; if (copy_from_user(&lum, lump, sizeof(struct lmv_user_md))) - RETURN(-EFAULT); + return -EFAULT; if (lum.lum_magic != LMV_MAGIC_V1) - RETURN(-EINVAL); + return -EINVAL; lum_size = lmv_user_md_size(1, LMV_MAGIC_V1); OBD_ALLOC(tmp, lum_size); @@ -1430,7 +1411,7 @@ lmv_out_free: free_lmv: if (tmp) OBD_FREE(tmp, lum_size); - RETURN(rc); + return rc; } case LL_IOC_REMOVE_ENTRY: { char *filename = NULL; @@ -1447,7 +1428,7 @@ free_lmv: filename = ll_getname((const char *)arg); if (IS_ERR(filename)) - RETURN(PTR_ERR(filename)); + return PTR_ERR(filename); namelen = strlen(filename); if (namelen < 1) @@ -1457,12 +1438,12 @@ free_lmv: out_rmdir: if (filename) ll_putname(filename); - RETURN(rc); + return rc; } case LL_IOC_LOV_SWAP_LAYOUTS: - RETURN(-EPERM); + return -EPERM; case LL_IOC_OBD_STATFS: - RETURN(ll_obd_statfs(inode, (void *)arg)); + return ll_obd_statfs(inode, (void *)arg); case LL_IOC_LOV_GETSTRIPE: case LL_IOC_MDC_GETINFO: case IOC_MDC_GETFILEINFO: @@ -1478,7 +1459,7 @@ out_rmdir: cmd == IOC_MDC_GETFILESTRIPE) { filename = ll_getname((const char *)arg); if (IS_ERR(filename)) - RETURN(PTR_ERR(filename)); + return PTR_ERR(filename); rc = ll_lov_getstripe_ea_info(inode, filename, &lmm, &lmmsize, &request); @@ -1539,7 +1520,6 @@ out_rmdir: GOTO(out_req, rc = -EFAULT); } - EXIT; out_req: ptlrpc_req_finished(request); if (filename) @@ -1559,9 +1539,11 @@ out_rmdir: rc = ll_get_max_mdsize(sbi, &lmmsize); if (rc) - RETURN(rc); + return rc; OBD_ALLOC_LARGE(lmm, lmmsize); + if (lmm == NULL) + return -ENOMEM; if (copy_from_user(lmm, lum, lmmsize)) GOTO(free_lmm, rc = -EFAULT); @@ -1602,7 +1584,6 @@ out_rmdir: if (copy_to_user(&lumd->lmd_st, &st, sizeof(st))) GOTO(free_lsm, rc = -EFAULT); - EXIT; free_lsm: obd_free_memmd(sbi->ll_dt_exp, &lsm); free_lmm: @@ -1610,7 +1591,7 @@ out_rmdir: return rc; } case OBD_IOC_LLOG_CATINFO: { - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; } case OBD_IOC_QUOTACHECK: { struct obd_quotactl *oqctl; @@ -1618,11 +1599,11 @@ out_rmdir: if (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT) - RETURN(-EPERM); + return -EPERM; OBD_ALLOC_PTR(oqctl); if (!oqctl) - RETURN(-ENOMEM); + return -ENOMEM; oqctl->qc_type = arg; rc = obd_quotacheck(sbi->ll_md_exp, oqctl); if (rc < 0) { @@ -1642,11 +1623,11 @@ out_rmdir: if (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT) - RETURN(-EPERM); + return -EPERM; OBD_ALLOC_PTR(check); if (!check) - RETURN(-ENOMEM); + return -ENOMEM; rc = obd_iocontrol(cmd, sbi->ll_md_exp, 0, (void *)check, NULL); @@ -1669,7 +1650,7 @@ out_rmdir: } out_poll: OBD_FREE_PTR(check); - RETURN(rc); + return rc; } #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) case LL_IOC_QUOTACTL_18: { @@ -1680,7 +1661,7 @@ out_rmdir: OBD_ALLOC_PTR(qctl_18); if (!qctl_18) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC_PTR(qctl_20); if (!qctl_20) @@ -1720,7 +1701,7 @@ out_rmdir: OBD_FREE_PTR(qctl_20); out_quotactl_18: OBD_FREE_PTR(qctl_18); - RETURN(rc); + return rc; } #else #warning "remove old LL_IOC_QUOTACTL_18 compatibility code" @@ -1730,7 +1711,7 @@ out_rmdir: OBD_ALLOC_PTR(qctl); if (!qctl) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(qctl, (void *)arg, sizeof(*qctl))) GOTO(out_quotactl, rc = -EFAULT); @@ -1742,13 +1723,13 @@ out_rmdir: out_quotactl: OBD_FREE_PTR(qctl); - RETURN(rc); + return rc; } case OBD_IOC_GETDTNAME: case OBD_IOC_GETMDNAME: - RETURN(ll_get_obd_name(inode, cmd, arg)); + return ll_get_obd_name(inode, cmd, arg); case LL_IOC_FLUSHCTX: - RETURN(ll_flush_ctx(inode)); + return ll_flush_ctx(inode); #ifdef CONFIG_FS_POSIX_ACL case LL_IOC_RMTACL: { if (sbi->ll_flags & LL_SBI_RMT_CLIENT && @@ -1759,9 +1740,9 @@ out_rmdir: rc = rct_add(&sbi->ll_rct, current_pid(), arg); if (!rc) fd->fd_flags |= LL_FILE_RMTACL; - RETURN(rc); + return rc; } else - RETURN(0); + return 0; } #endif case LL_IOC_GETOBDCOUNT: { @@ -1769,7 +1750,7 @@ out_rmdir: struct obd_export *exp; if (copy_from_user(&count, (int *)arg, sizeof(int))) - RETURN(-EFAULT); + return -EFAULT; /* get ost count when count is zero, get mdt count otherwise */ exp = count ? sbi->ll_md_exp : sbi->ll_dt_exp; @@ -1778,41 +1759,41 @@ out_rmdir: KEY_TGT_COUNT, &vallen, &count, NULL); if (rc) { CERROR("get target count failed: %d\n", rc); - RETURN(rc); + return rc; } if (copy_to_user((int *)arg, &count, sizeof(int))) - RETURN(-EFAULT); + return -EFAULT; - RETURN(0); + return 0; } case LL_IOC_PATH2FID: if (copy_to_user((void *)arg, ll_inode2fid(inode), sizeof(struct lu_fid))) - RETURN(-EFAULT); - RETURN(0); + 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: rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void *)arg, sizeof(struct ioc_changelog)); - RETURN(rc); + return rc; case OBD_IOC_FID2PATH: - RETURN(ll_fid2path(inode, (void *)arg)); + return ll_fid2path(inode, (void *)arg); case LL_IOC_HSM_REQUEST: { struct hsm_user_request *hur; int totalsize; OBD_ALLOC_PTR(hur); if (hur == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* We don't know the true size yet; copy the fixed-size part */ if (copy_from_user(hur, (void *)arg, sizeof(*hur))) { OBD_FREE_PTR(hur); - RETURN(-EFAULT); + return -EFAULT; } /* Compute the whole struct size */ @@ -1820,12 +1801,12 @@ out_rmdir: OBD_FREE_PTR(hur); OBD_ALLOC_LARGE(hur, totalsize); if (hur == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* Copy the whole struct */ if (copy_from_user(hur, (void *)arg, totalsize)) { OBD_FREE_LARGE(hur, totalsize); - RETURN(-EFAULT); + return -EFAULT; } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), totalsize, @@ -1833,14 +1814,14 @@ out_rmdir: OBD_FREE_LARGE(hur, totalsize); - RETURN(rc); + return rc; } case LL_IOC_HSM_PROGRESS: { struct hsm_progress_kernel hpk; struct hsm_progress hp; if (copy_from_user(&hp, (void *)arg, sizeof(hp))) - RETURN(-EFAULT); + return -EFAULT; hpk.hpk_fid = hp.hp_fid; hpk.hpk_cookie = hp.hp_cookie; @@ -1853,12 +1834,12 @@ out_rmdir: * reported to Lustre root */ rc = obd_iocontrol(cmd, sbi->ll_md_exp, sizeof(hpk), &hpk, NULL); - RETURN(rc); + return rc; } case LL_IOC_HSM_CT_START: rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void *)arg, sizeof(struct lustre_kernelcomm)); - RETURN(rc); + return rc; case LL_IOC_HSM_COPY_START: { struct hsm_copy *copy; @@ -1866,10 +1847,10 @@ out_rmdir: OBD_ALLOC_PTR(copy); if (copy == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { OBD_FREE_PTR(copy); - RETURN(-EFAULT); + return -EFAULT; } rc = ll_ioc_copy_start(inode->i_sb, copy); @@ -1877,7 +1858,7 @@ out_rmdir: rc = -EFAULT; OBD_FREE_PTR(copy); - RETURN(rc); + return rc; } case LL_IOC_HSM_COPY_END: { struct hsm_copy *copy; @@ -1885,10 +1866,10 @@ out_rmdir: OBD_ALLOC_PTR(copy); if (copy == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { OBD_FREE_PTR(copy); - RETURN(-EFAULT); + return -EFAULT; } rc = ll_ioc_copy_end(inode->i_sb, copy); @@ -1896,11 +1877,10 @@ out_rmdir: rc = -EFAULT; OBD_FREE_PTR(copy); - RETURN(rc); + return rc; } default: - RETURN(obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL, - (void *)arg)); + return obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL, (void *)arg); } } @@ -1911,7 +1891,6 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin) struct ll_sb_info *sbi = ll_i2sbi(inode); int api32 = ll_need_32bit_api(sbi); loff_t ret = -EINVAL; - ENTRY; mutex_lock(&inode->i_mutex); switch (origin) { @@ -1957,14 +1936,12 @@ out: int ll_dir_open(struct inode *inode, struct file *file) { - ENTRY; - RETURN(ll_file_open(inode, file)); + return ll_file_open(inode, file); } int ll_dir_release(struct inode *inode, struct file *file) { - ENTRY; - RETURN(ll_file_release(inode, file)); + return ll_file_release(inode, file); } struct file_operations ll_dir_operations = { @@ -1972,7 +1949,7 @@ struct file_operations ll_dir_operations = { .open = ll_dir_open, .release = ll_dir_release, .read = generic_read_dir, - .readdir = ll_readdir, + .iterate = ll_readdir, .unlocked_ioctl = ll_dir_ioctl, .fsync = ll_fsync, }; diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index ed1e3f7b4e5..bc534db1243 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -55,6 +55,8 @@ struct ll_file_data *ll_file_data_get(void) struct ll_file_data *fd; OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, __GFP_IO); + if (fd == NULL) + return NULL; fd->fd_write_failed = false; return fd; } @@ -93,8 +95,6 @@ void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data, struct obd_client_handle *och) { - ENTRY; - op_data->op_attr.ia_valid = ATTR_MODE | ATTR_ATIME | ATTR_ATIME_SET | ATTR_MTIME | ATTR_MTIME_SET | ATTR_CTIME | ATTR_CTIME_SET; @@ -111,7 +111,6 @@ out: ll_pack_inode2opdata(inode, op_data, &och->och_fh); ll_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); - EXIT; } static int ll_close_inode_openhandle(struct obd_export *md_exp, @@ -124,7 +123,6 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, struct obd_device *obd = class_exp2obd(exp); int epoch_close = 1; int rc; - ENTRY; if (obd == NULL) { /* @@ -178,9 +176,7 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, inode->i_ino, rc); } - EXIT; out: - if (exp_connect_som(exp) && !epoch_close && S_ISREG(inode->i_mode) && (och->och_flags & FMODE_WRITE)) { ll_queue_done_writing(inode, LLIF_DONE_WRITING); @@ -202,7 +198,6 @@ int ll_md_real_close(struct inode *inode, int flags) struct obd_client_handle *och; __u64 *och_usecount; int rc = 0; - ENTRY; if (flags & FMODE_WRITE) { och_p = &lli->lli_mds_write_och; @@ -220,7 +215,7 @@ int ll_md_real_close(struct inode *inode, int flags) if (*och_usecount) { /* There are still users of this handle, so skip freeing it. */ mutex_unlock(&lli->lli_och_mutex); - RETURN(0); + return 0; } och=*och_p; *och_p = NULL; @@ -232,7 +227,7 @@ int ll_md_real_close(struct inode *inode, int flags) inode, och); } - RETURN(rc); + return rc; } int ll_md_close(struct obd_export *md_exp, struct inode *inode, @@ -241,7 +236,6 @@ int ll_md_close(struct obd_export *md_exp, struct inode *inode, struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ll_inode_info *lli = ll_i2info(inode); int rc = 0; - ENTRY; /* clear group lock, if present */ if (unlikely(fd->fd_flags & LL_FILE_GROUP_LOCKED)) @@ -287,7 +281,7 @@ int ll_md_close(struct obd_export *md_exp, struct inode *inode, ll_file_data_put(fd); ll_capa_close(inode); - RETURN(rc); + return rc; } /* While this returns an error code, fput() the caller does not, so we need @@ -301,7 +295,6 @@ int ll_file_release(struct inode *inode, struct file *file) struct ll_sb_info *sbi = ll_i2sbi(inode); struct ll_inode_info *lli = ll_i2info(inode); int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -335,7 +328,7 @@ int ll_file_release(struct inode *inode, struct file *file) if (inode->i_sb->s_root == file->f_dentry) { LUSTRE_FPRIVATE(file) = NULL; ll_file_data_put(fd); - RETURN(0); + return 0; } if (!S_ISDIR(inode->i_mode)) { @@ -348,7 +341,7 @@ int ll_file_release(struct inode *inode, struct file *file) if (CFS_FAIL_TIMEOUT_MS(OBD_FAIL_PTLRPC_DUMP_LOG, cfs_fail_val)) libcfs_debug_dumplog(); - RETURN(rc); + return rc; } static int ll_intent_file_open(struct file *file, void *lmm, @@ -362,10 +355,9 @@ static int ll_intent_file_open(struct file *file, void *lmm, struct ptlrpc_request *req; __u32 opc = LUSTRE_OPC_ANY; int rc; - ENTRY; if (!parent) - RETURN(-ENOENT); + return -ENOENT; /* Usually we come here only for NFSD, and we want open lock. But we can also get here with pre 2.6.15 patchless kernels, and in @@ -386,7 +378,7 @@ static int ll_intent_file_open(struct file *file, void *lmm, file->f_dentry->d_inode, name, len, O_RDWR, opc, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); itp->it_flags |= MDS_OPEN_BY_FID; rc = md_intent_lock(sbi->ll_md_exp, op_data, lmm, lmmsize, itp, @@ -422,7 +414,7 @@ out: it_clear_disposition(itp, DISP_ENQ_COMPLETE); ll_intent_drop_lock(itp); - RETURN(rc); + return rc; } /** @@ -464,7 +456,6 @@ int ll_local_open(struct file *file, struct lookup_intent *it, { struct inode *inode = file->f_dentry->d_inode; struct ll_inode_info *lli = ll_i2info(inode); - ENTRY; LASSERT(!LUSTRE_FPRIVATE(file)); @@ -477,7 +468,7 @@ int ll_local_open(struct file *file, struct lookup_intent *it, rc = ll_och_fill(ll_i2sbi(inode)->ll_md_exp, lli, it, och); if (rc) - RETURN(rc); + return rc; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); if ((it->it_flags & FMODE_WRITE) && @@ -489,7 +480,7 @@ int ll_local_open(struct file *file, struct lookup_intent *it, LUSTRE_FPRIVATE(file) = fd; ll_readahead_init(inode, &fd->fd_ras); fd->fd_omode = it->it_flags; - RETURN(0); + return 0; } /* Open a file, and (for the very first open) create objects on the OSTs at @@ -514,7 +505,6 @@ int ll_file_open(struct inode *inode, struct file *file) __u64 *och_usecount = NULL; struct ll_file_data *fd; int rc = 0, opendir_set = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), flags %o\n", inode->i_ino, inode->i_generation, inode, file->f_flags); @@ -524,7 +514,7 @@ int ll_file_open(struct inode *inode, struct file *file) fd = ll_file_data_get(); if (fd == NULL) - GOTO(out_och_free, rc = -ENOMEM); + GOTO(out_openerr, rc = -ENOMEM); fd->fd_file = file; if (S_ISDIR(inode->i_mode)) { @@ -540,7 +530,7 @@ int ll_file_open(struct inode *inode, struct file *file) if (inode->i_sb->s_root == file->f_dentry) { LUSTRE_FPRIVATE(file) = fd; - RETURN(0); + return 0; } if (!it || !it->d.lustre.it_disposition) { @@ -700,8 +690,6 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp, struct obd_info oinfo = { { { 0 } } }; int rc; - ENTRY; - LASSERT(lsm != NULL); oinfo.oi_md = lsm; @@ -736,7 +724,7 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp, OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLSIZE | OBD_MD_FLDATAVERSION); - RETURN(rc); + return rc; } /** @@ -749,7 +737,6 @@ int ll_inode_getattr(struct inode *inode, struct obdo *obdo, struct obd_capa *capa = ll_mdscapa_get(inode); struct lov_stripe_md *lsm; int rc; - ENTRY; lsm = ccc_inode_lsm_get(inode); rc = ll_lsm_getattr(lsm, ll_i2dtexp(inode), @@ -765,7 +752,7 @@ int ll_inode_getattr(struct inode *inode, struct obdo *obdo, (unsigned long)ll_inode_blksize(inode)); } ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } int ll_merge_lvb(const struct lu_env *env, struct inode *inode) @@ -776,8 +763,6 @@ int ll_merge_lvb(const struct lu_env *env, struct inode *inode) struct ost_lvb lvb; int rc = 0; - ENTRY; - ll_inode_size_lock(inode); /* merge timestamps the most recently obtained from mds with timestamps obtained from osts */ @@ -810,7 +795,7 @@ int ll_merge_lvb(const struct lu_env *env, struct inode *inode) } ll_inode_size_unlock(inode); - RETURN(rc); + return rc; } int ll_glimpse_ioctl(struct ll_sb_info *sbi, struct lov_stripe_md *lsm, @@ -860,7 +845,6 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args, struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct cl_io *io; ssize_t result; - ENTRY; restart: io = ccc_env_thread_io(env); @@ -986,15 +970,14 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov, size_t count; ssize_t result; int refcheck; - ENTRY; result = ll_file_get_iov_count(iov, &nr_segs, &count); if (result) - RETURN(result); + return result; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); args = vvp_env_args(env, IO_NORMAL); args->u.normal.via_iov = (struct iovec *)iov; @@ -1004,7 +987,7 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov, result = ll_file_io_generic(env, args, iocb->ki_filp, CIT_READ, &iocb->ki_pos, count); cl_env_put(env, &refcheck); - RETURN(result); + return result; } static ssize_t ll_file_read(struct file *file, char *buf, size_t count, @@ -1015,11 +998,10 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count, struct kiocb *kiocb; ssize_t result; int refcheck; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); local_iov = &vvp_env_info(env)->vti_local_iov; kiocb = &vvp_env_info(env)->vti_kiocb; @@ -1027,13 +1009,13 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count, local_iov->iov_len = count; init_sync_kiocb(kiocb, file); kiocb->ki_pos = *ppos; - kiocb->ki_left = count; + kiocb->ki_nbytes = count; result = ll_file_aio_read(kiocb, local_iov, 1, kiocb->ki_pos); *ppos = kiocb->ki_pos; cl_env_put(env, &refcheck); - RETURN(result); + return result; } /* @@ -1047,15 +1029,14 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov, size_t count; ssize_t result; int refcheck; - ENTRY; result = ll_file_get_iov_count(iov, &nr_segs, &count); if (result) - RETURN(result); + return result; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); args = vvp_env_args(env, IO_NORMAL); args->u.normal.via_iov = (struct iovec *)iov; @@ -1065,7 +1046,7 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov, result = ll_file_io_generic(env, args, iocb->ki_filp, CIT_WRITE, &iocb->ki_pos, count); cl_env_put(env, &refcheck); - RETURN(result); + return result; } static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, @@ -1076,11 +1057,10 @@ static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, struct kiocb *kiocb; ssize_t result; int refcheck; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); local_iov = &vvp_env_info(env)->vti_local_iov; kiocb = &vvp_env_info(env)->vti_kiocb; @@ -1088,13 +1068,13 @@ static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, local_iov->iov_len = count; init_sync_kiocb(kiocb, file); kiocb->ki_pos = *ppos; - kiocb->ki_left = count; + kiocb->ki_nbytes = count; result = ll_file_aio_write(kiocb, local_iov, 1, kiocb->ki_pos); *ppos = kiocb->ki_pos; cl_env_put(env, &refcheck); - RETURN(result); + return result; } @@ -1110,11 +1090,10 @@ static ssize_t ll_file_splice_read(struct file *in_file, loff_t *ppos, struct vvp_io_args *args; ssize_t result; int refcheck; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); args = vvp_env_args(env, IO_SPLICE); args->u.splice.via_pipe = pipe; @@ -1122,7 +1101,7 @@ static ssize_t ll_file_splice_read(struct file *in_file, loff_t *ppos, result = ll_file_io_generic(env, args, in_file, CIT_READ, ppos, count); cl_env_put(env, &refcheck); - RETURN(result); + return result; } static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, @@ -1134,14 +1113,13 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, int lsm_size; int rc = 0; struct lov_stripe_md *lsm = NULL, *lsm2; - ENTRY; OBDO_ALLOC(oa); if (oa == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lsm = ccc_inode_lsm_get(inode); - if (lsm == NULL) + if (!lsm_has_objects(lsm)) GOTO(out, rc = -ENOENT); lsm_size = sizeof(*lsm) + (sizeof(struct lov_oinfo) * @@ -1175,18 +1153,17 @@ static int ll_lov_recreate_obj(struct inode *inode, unsigned long arg) { struct ll_recreate_obj ucreat; struct ost_id oi; - ENTRY; if (!cfs_capable(CFS_CAP_SYS_ADMIN)) - RETURN(-EPERM); + return -EPERM; if (copy_from_user(&ucreat, (struct ll_recreate_obj *)arg, sizeof(ucreat))) - RETURN(-EFAULT); + return -EFAULT; ostid_set_seq_mdt0(&oi); ostid_set_id(&oi, ucreat.lrc_id); - RETURN(ll_lov_recreate(inode, &oi, ucreat.lrc_ost_idx)); + return ll_lov_recreate(inode, &oi, ucreat.lrc_ost_idx); } static int ll_lov_recreate_fid(struct inode *inode, unsigned long arg) @@ -1194,17 +1171,16 @@ static int ll_lov_recreate_fid(struct inode *inode, unsigned long arg) struct lu_fid fid; struct ost_id oi; obd_count ost_idx; - ENTRY; if (!cfs_capable(CFS_CAP_SYS_ADMIN)) - RETURN(-EPERM); + return -EPERM; if (copy_from_user(&fid, (struct lu_fid *)arg, sizeof(fid))) - RETURN(-EFAULT); + return -EFAULT; fid_to_ostid(&fid, &oi); ost_idx = (fid_seq(&fid) >> 16) & 0xffff; - RETURN(ll_lov_recreate(inode, &oi, ost_idx)); + return ll_lov_recreate(inode, &oi, ost_idx); } int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, @@ -1213,14 +1189,13 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, struct lov_stripe_md *lsm = NULL; struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags}; int rc = 0; - ENTRY; lsm = ccc_inode_lsm_get(inode); if (lsm != NULL) { ccc_inode_lsm_put(inode, lsm); CDEBUG(D_IOCTL, "stripe already exists for ino %lu\n", inode->i_ino); - RETURN(-EEXIST); + return -EEXIST; } ll_inode_size_lock(inode); @@ -1237,7 +1212,7 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, ll_inode_size_unlock(inode); ll_intent_release(&oit); ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; out_req_free: ptlrpc_req_finished((struct ptlrpc_request *) oit.d.lustre.it_data); goto out; @@ -1256,13 +1231,13 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, rc = ll_get_max_mdsize(sbi, &lmmsize); if (rc) - RETURN(rc); + return rc; op_data = ll_prep_md_op_data(NULL, inode, NULL, filename, strlen(filename), lmmsize, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA; rc = md_getattr_name(sbi->ll_md_exp, op_data, &req); @@ -1297,6 +1272,12 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, * passing it to userspace. */ if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC)) { + int stripe_count; + + stripe_count = le16_to_cpu(lmm->lmm_stripe_count); + if (le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED) + stripe_count = 0; + /* if function called for directory - we should * avoid swab not existent lsm objects */ if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V1)) { @@ -1304,13 +1285,13 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, if (S_ISREG(body->mode)) lustre_swab_lov_user_md_objects( ((struct lov_user_md_v1 *)lmm)->lmm_objects, - ((struct lov_user_md_v1 *)lmm)->lmm_stripe_count); + stripe_count); } else if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V3)) { lustre_swab_lov_user_md_v3((struct lov_user_md_v3 *)lmm); if (S_ISREG(body->mode)) lustre_swab_lov_user_md_objects( ((struct lov_user_md_v3 *)lmm)->lmm_objects, - ((struct lov_user_md_v3 *)lmm)->lmm_stripe_count); + stripe_count); } } @@ -1329,24 +1310,23 @@ static int ll_lov_setea(struct inode *inode, struct file *file, int lum_size = sizeof(struct lov_user_md) + sizeof(struct lov_user_ost_data); int rc; - ENTRY; if (!cfs_capable(CFS_CAP_SYS_ADMIN)) - RETURN(-EPERM); + return -EPERM; OBD_ALLOC_LARGE(lump, lum_size); if (lump == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(lump, (struct lov_user_md *)arg, lum_size)) { OBD_FREE_LARGE(lump, lum_size); - RETURN(-EFAULT); + return -EFAULT; } rc = ll_lov_setstripe_ea_info(inode, file, flags, lump, lum_size); OBD_FREE_LARGE(lump, lum_size); - RETURN(rc); + return rc; } static int ll_lov_setstripe(struct inode *inode, struct file *file, @@ -1358,17 +1338,16 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file, struct lov_user_md_v3 *lumv3p = (struct lov_user_md_v3 *)arg; int lum_size, rc; int flags = FMODE_WRITE; - ENTRY; /* first try with v1 which is smaller than v3 */ lum_size = sizeof(struct lov_user_md_v1); if (copy_from_user(lumv1, lumv1p, lum_size)) - RETURN(-EFAULT); + return -EFAULT; if (lumv1->lmm_magic == LOV_USER_MAGIC_V3) { lum_size = sizeof(struct lov_user_md_v3); if (copy_from_user(&lumv3, lumv3p, lum_size)) - RETURN(-EFAULT); + return -EFAULT; } rc = ll_lov_setstripe_ea_info(inode, file, flags, lumv1, lum_size); @@ -1384,21 +1363,20 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file, 0, lsm, (void *)arg); ccc_inode_lsm_put(inode, lsm); } - RETURN(rc); + return rc; } static int ll_lov_getstripe(struct inode *inode, unsigned long arg) { struct lov_stripe_md *lsm; int rc = -ENODATA; - ENTRY; lsm = ccc_inode_lsm_get(inode); if (lsm != NULL) rc = obd_iocontrol(LL_IOC_LOV_GETSTRIPE, ll_i2dtexp(inode), 0, lsm, (void *)arg); ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) @@ -1407,17 +1385,16 @@ int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ccc_grouplock grouplock; int rc; - ENTRY; if (ll_file_nolock(file)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; spin_lock(&lli->lli_lock); if (fd->fd_flags & LL_FILE_GROUP_LOCKED) { CWARN("group lock already existed with gid %lu\n", fd->fd_grouplock.cg_gid); spin_unlock(&lli->lli_lock); - RETURN(-EINVAL); + return -EINVAL; } LASSERT(fd->fd_grouplock.cg_lock == NULL); spin_unlock(&lli->lli_lock); @@ -1425,14 +1402,14 @@ int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) rc = cl_get_grouplock(cl_i2info(inode)->lli_clob, arg, (file->f_flags & O_NONBLOCK), &grouplock); if (rc) - RETURN(rc); + return rc; spin_lock(&lli->lli_lock); if (fd->fd_flags & LL_FILE_GROUP_LOCKED) { spin_unlock(&lli->lli_lock); CERROR("another thread just won the race\n"); cl_put_grouplock(&grouplock); - RETURN(-EINVAL); + return -EINVAL; } fd->fd_flags |= LL_FILE_GROUP_LOCKED; @@ -1440,7 +1417,7 @@ int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) spin_unlock(&lli->lli_lock); CDEBUG(D_INFO, "group lock %lu obtained\n", arg); - RETURN(0); + return 0; } int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) @@ -1448,13 +1425,12 @@ int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) struct ll_inode_info *lli = ll_i2info(inode); struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ccc_grouplock grouplock; - ENTRY; spin_lock(&lli->lli_lock); if (!(fd->fd_flags & LL_FILE_GROUP_LOCKED)) { spin_unlock(&lli->lli_lock); CWARN("no group lock held\n"); - RETURN(-EINVAL); + return -EINVAL; } LASSERT(fd->fd_grouplock.cg_lock != NULL); @@ -1462,7 +1438,7 @@ int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) CWARN("group lock %lu doesn't match current id %lu\n", arg, fd->fd_grouplock.cg_gid); spin_unlock(&lli->lli_lock); - RETURN(-EINVAL); + return -EINVAL; } grouplock = fd->fd_grouplock; @@ -1472,7 +1448,7 @@ int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) cl_put_grouplock(&grouplock); CDEBUG(D_INFO, "group lock %lu released\n", arg); - RETURN(0); + return 0; } /** @@ -1489,17 +1465,16 @@ int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it) struct inode *inode = dentry->d_inode; struct obd_client_handle *och; int rc; - ENTRY; LASSERT(inode); /* Root ? Do nothing. */ if (dentry->d_inode->i_sb->s_root == dentry) - RETURN(0); + return 0; /* No open handle to close? Move away */ if (!it_disposition(it, DISP_OPEN_OPEN)) - RETURN(0); + return 0; LASSERT(it_open_error(DISP_OPEN_OPEN, it) == 0); @@ -1518,7 +1493,7 @@ int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it) ptlrpc_req_finished(it->d.lustre.it_data); it_clear_disposition(it, DISP_ENQ_OPEN_REF); } - RETURN(rc); + return rc; } /** @@ -1533,7 +1508,6 @@ int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, struct ll_fiemap_info_key fm_key = { .name = KEY_FIEMAP, }; int vallen = num_bytes; int rc; - ENTRY; /* Checks for fiemap flags */ if (fiemap->fm_flags & ~LUSTRE_FIEMAP_FLAGS_COMPAT) { @@ -1579,7 +1553,7 @@ int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, out: ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } int ll_fid2path(struct inode *inode, void *arg) @@ -1587,26 +1561,25 @@ int ll_fid2path(struct inode *inode, void *arg) struct obd_export *exp = ll_i2mdexp(inode); struct getinfo_fid2path *gfout, *gfin; int outsize, rc; - ENTRY; if (!cfs_capable(CFS_CAP_DAC_READ_SEARCH) && !(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH)) - RETURN(-EPERM); + return -EPERM; /* Need to get the buflen */ OBD_ALLOC_PTR(gfin); if (gfin == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(gfin, arg, sizeof(*gfin))) { OBD_FREE_PTR(gfin); - RETURN(-EFAULT); + return -EFAULT; } outsize = sizeof(*gfout) + gfin->gf_pathlen; OBD_ALLOC(gfout, outsize); if (gfout == NULL) { OBD_FREE_PTR(gfin); - RETURN(-ENOMEM); + return -ENOMEM; } memcpy(gfout, gfin, sizeof(*gfout)); OBD_FREE_PTR(gfin); @@ -1621,7 +1594,7 @@ int ll_fid2path(struct inode *inode, void *arg) gf_free: OBD_FREE(gfout, outsize); - RETURN(rc); + return rc; } static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) @@ -1635,13 +1608,13 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) * required fiemap buffer */ if (get_user(extent_count, &((struct ll_user_fiemap __user *)arg)->fm_extent_count)) - RETURN(-EFAULT); + return -EFAULT; num_bytes = sizeof(*fiemap_s) + (extent_count * sizeof(struct ll_fiemap_extent)); OBD_ALLOC_LARGE(fiemap_s, num_bytes); if (fiemap_s == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* get the fiemap value */ if (copy_from_user(fiemap_s, (struct ll_user_fiemap __user *)arg, @@ -1673,7 +1646,7 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) error: OBD_FREE_LARGE(fiemap_s, num_bytes); - RETURN(rc); + return rc; } /* @@ -1692,24 +1665,21 @@ int ll_data_version(struct inode *inode, __u64 *data_version, struct ll_sb_info *sbi = ll_i2sbi(inode); struct obdo *obdo = NULL; int rc; - ENTRY; /* If no stripe, we consider version is 0. */ lsm = ccc_inode_lsm_get(inode); - if (lsm == NULL) { + if (!lsm_has_objects(lsm)) { *data_version = 0; CDEBUG(D_INODE, "No object for inode\n"); - RETURN(0); + GOTO(out, rc = 0); } OBD_ALLOC_PTR(obdo); - if (obdo == NULL) { - ccc_inode_lsm_put(inode, lsm); - RETURN(-ENOMEM); - } + if (obdo == NULL) + GOTO(out, rc = -ENOMEM); rc = ll_lsm_getattr(lsm, sbi->ll_dt_exp, NULL, obdo, 0, extent_lock); - if (!rc) { + if (rc == 0) { if (!(obdo->o_valid & OBD_MD_FLDATAVERSION)) rc = -EOPNOTSUPP; else @@ -1717,9 +1687,9 @@ int ll_data_version(struct inode *inode, __u64 *data_version, } OBD_FREE_PTR(obdo); +out: ccc_inode_lsm_put(inode, lsm); - - RETURN(rc); + return rc; } struct ll_swap_stack { @@ -1741,7 +1711,7 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, OBD_ALLOC_PTR(llss); if (llss == NULL) - RETURN(-ENOMEM); + return -ENOMEM; llss->inode1 = file1->f_dentry->d_inode; llss->inode2 = file2->f_dentry->d_inode; @@ -1749,8 +1719,8 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, if (!S_ISREG(llss->inode2->i_mode)) GOTO(free, rc = -EINVAL); - if (ll_permission(llss->inode1, MAY_WRITE, NULL) || - ll_permission(llss->inode2, MAY_WRITE, NULL)) + if (inode_permission(llss->inode1, MAY_WRITE) || + inode_permission(llss->inode2, MAY_WRITE)) GOTO(free, rc = -EPERM); if (llss->inode2->i_sb != llss->inode1->i_sb) @@ -1830,12 +1800,12 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, rc = -ENOMEM; op_data = ll_prep_md_op_data(NULL, llss->inode1, llss->inode2, NULL, 0, 0, LUSTRE_OPC_ANY, &msl); - if (op_data != NULL) { - rc = obd_iocontrol(LL_IOC_LOV_SWAP_LAYOUTS, - ll_i2mdexp(llss->inode1), - sizeof(*op_data), op_data, NULL); - ll_finish_md_op_data(op_data); - } + if (IS_ERR(op_data)) + GOTO(free, rc = PTR_ERR(op_data)); + + rc = obd_iocontrol(LL_IOC_LOV_SWAP_LAYOUTS, ll_i2mdexp(llss->inode1), + sizeof(*op_data), op_data, NULL); + ll_finish_md_op_data(op_data); putgl: if (gid != 0) { @@ -1880,7 +1850,7 @@ free: if (llss != NULL) OBD_FREE_PTR(llss); - RETURN(rc); + return rc; } long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) @@ -1888,7 +1858,6 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct inode *inode = file->f_dentry->d_inode; struct ll_file_data *fd = LUSTRE_FPRIVATE(file); int flags, rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),cmd=%x\n", inode->i_ino, inode->i_generation, inode, cmd); @@ -1896,7 +1865,7 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) /* asm-ppc{,64} declares TCGETS, et. al. as type 't' not 'T' */ if (_IOC_TYPE(cmd) == 'T' || _IOC_TYPE(cmd) == 't') /* tty ioctls */ - RETURN(-ENOTTY); + return -ENOTTY; switch(cmd) { case LL_IOC_GETFLAGS: @@ -1909,66 +1878,66 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) * not abused, and to handle any flag side effects. */ if (get_user(flags, (int *) arg)) - RETURN(-EFAULT); + return -EFAULT; if (cmd == LL_IOC_SETFLAGS) { if ((flags & LL_FILE_IGNORE_LOCK) && !(file->f_flags & O_DIRECT)) { CERROR("%s: unable to disable locking on " "non-O_DIRECT file\n", current->comm); - RETURN(-EINVAL); + return -EINVAL; } fd->fd_flags |= flags; } else { fd->fd_flags &= ~flags; } - RETURN(0); + return 0; case LL_IOC_LOV_SETSTRIPE: - RETURN(ll_lov_setstripe(inode, file, arg)); + return ll_lov_setstripe(inode, file, arg); case LL_IOC_LOV_SETEA: - RETURN(ll_lov_setea(inode, file, arg)); + return ll_lov_setea(inode, file, arg); case LL_IOC_LOV_SWAP_LAYOUTS: { struct file *file2; struct lustre_swap_layouts lsl; if (copy_from_user(&lsl, (char *)arg, sizeof(struct lustre_swap_layouts))) - RETURN(-EFAULT); + return -EFAULT; if ((file->f_flags & O_ACCMODE) == 0) /* O_RDONLY */ - RETURN(-EPERM); + return -EPERM; file2 = fget(lsl.sl_fd); if (file2 == NULL) - RETURN(-EBADF); + return -EBADF; rc = -EPERM; if ((file2->f_flags & O_ACCMODE) != 0) /* O_WRONLY or O_RDWR */ rc = ll_swap_layouts(file, file2, &lsl); fput(file2); - RETURN(rc); + return rc; } case LL_IOC_LOV_GETSTRIPE: - RETURN(ll_lov_getstripe(inode, arg)); + return ll_lov_getstripe(inode, arg); case LL_IOC_RECREATE_OBJ: - RETURN(ll_lov_recreate_obj(inode, arg)); + return ll_lov_recreate_obj(inode, arg); case LL_IOC_RECREATE_FID: - RETURN(ll_lov_recreate_fid(inode, arg)); + return ll_lov_recreate_fid(inode, arg); case FSFILT_IOC_FIEMAP: - RETURN(ll_ioctl_fiemap(inode, arg)); + return ll_ioctl_fiemap(inode, arg); case FSFILT_IOC_GETFLAGS: case FSFILT_IOC_SETFLAGS: - RETURN(ll_iocontrol(inode, file, cmd, arg)); + return ll_iocontrol(inode, file, cmd, arg); case FSFILT_IOC_GETVERSION_OLD: case FSFILT_IOC_GETVERSION: - RETURN(put_user(inode->i_generation, (int *)arg)); + return put_user(inode->i_generation, (int *)arg); case LL_IOC_GROUP_LOCK: - RETURN(ll_get_grouplock(inode, file, arg)); + return ll_get_grouplock(inode, file, arg); case LL_IOC_GROUP_UNLOCK: - RETURN(ll_put_grouplock(inode, file, arg)); + return ll_put_grouplock(inode, file, arg); case IOC_OBD_STATFS: - RETURN(ll_obd_statfs(inode, (void *)arg)); + return ll_obd_statfs(inode, (void *)arg); /* We need to special case any other ioctls we want to handle, * to send them to the MDS/OST as appropriate and to properly @@ -1977,30 +1946,30 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case FSFILT_IOC_SETVERSION: */ case LL_IOC_FLUSHCTX: - RETURN(ll_flush_ctx(inode)); + return ll_flush_ctx(inode); case LL_IOC_PATH2FID: { if (copy_to_user((void *)arg, ll_inode2fid(inode), sizeof(struct lu_fid))) - RETURN(-EFAULT); + return -EFAULT; - RETURN(0); + return 0; } case OBD_IOC_FID2PATH: - RETURN(ll_fid2path(inode, (void *)arg)); + return ll_fid2path(inode, (void *)arg); case LL_IOC_DATA_VERSION: { struct ioc_data_version idv; int rc; if (copy_from_user(&idv, (char *)arg, sizeof(idv))) - RETURN(-EFAULT); + return -EFAULT; rc = ll_data_version(inode, &idv.idv_version, !(idv.idv_flags & LL_DV_NOFLUSH)); if (rc == 0 && copy_to_user((char *) arg, &idv, sizeof(idv))) - RETURN(-EFAULT); + return -EFAULT; - RETURN(rc); + return rc; } case LL_IOC_GET_MDTIDX: { @@ -2008,16 +1977,16 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) mdtidx = ll_get_mdt_idx(inode); if (mdtidx < 0) - RETURN(mdtidx); + return mdtidx; if (put_user((int)mdtidx, (int*)arg)) - RETURN(-EFAULT); + return -EFAULT; - RETURN(0); + return 0; } case OBD_IOC_GETDTNAME: case OBD_IOC_GETMDNAME: - RETURN(ll_get_obd_name(inode, cmd, arg)); + return ll_get_obd_name(inode, cmd, arg); case LL_IOC_HSM_STATE_GET: { struct md_op_data *op_data; struct hsm_user_state *hus; @@ -2025,13 +1994,13 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(hus); if (hus == NULL) - RETURN(-ENOMEM); + return -ENOMEM; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hus); - if (op_data == NULL) { + if (IS_ERR(op_data)) { OBD_FREE_PTR(hus); - RETURN(-ENOMEM); + return PTR_ERR(op_data); } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), @@ -2042,7 +2011,7 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ll_finish_md_op_data(op_data); OBD_FREE_PTR(hus); - RETURN(rc); + return rc; } case LL_IOC_HSM_STATE_SET: { struct md_op_data *op_data; @@ -2051,10 +2020,10 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(hss); if (hss == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(hss, (char *)arg, sizeof(*hss))) { OBD_FREE_PTR(hss); - RETURN(-EFAULT); + return -EFAULT; } /* Non-root users are forbidden to set or clear flags which are @@ -2062,14 +2031,14 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (((hss->hss_setmask | hss->hss_clearmask) & ~HSM_USER_MASK) && !cfs_capable(CFS_CAP_SYS_ADMIN)) { OBD_FREE_PTR(hss); - RETURN(-EPERM); + return -EPERM; } op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hss); - if (op_data == NULL) { + if (IS_ERR(op_data)) { OBD_FREE_PTR(hss); - RETURN(-ENOMEM); + return PTR_ERR(op_data); } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), @@ -2078,7 +2047,7 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ll_finish_md_op_data(op_data); OBD_FREE_PTR(hss); - RETURN(rc); + return rc; } case LL_IOC_HSM_ACTION: { struct md_op_data *op_data; @@ -2087,13 +2056,13 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(hca); if (hca == NULL) - RETURN(-ENOMEM); + return -ENOMEM; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hca); - if (op_data == NULL) { + if (IS_ERR(op_data)) { OBD_FREE_PTR(hca); - RETURN(-ENOMEM); + return PTR_ERR(op_data); } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), @@ -2104,17 +2073,17 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ll_finish_md_op_data(op_data); OBD_FREE_PTR(hca); - RETURN(rc); + return rc; } default: { int err; if (LLIOC_STOP == ll_iocontrol_call(inode, file, cmd, arg, &err)) - RETURN(err); + return err; - RETURN(obd_iocontrol(cmd, ll_i2dtexp(inode), 0, NULL, - (void *)arg)); + return obd_iocontrol(cmd, ll_i2dtexp(inode), 0, NULL, + (void *)arg); } } } @@ -2125,7 +2094,6 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin) struct inode *inode = file->f_dentry->d_inode; loff_t retval, eof = 0; - ENTRY; retval = offset + ((origin == SEEK_END) ? i_size_read(inode) : (origin == SEEK_CUR) ? file->f_pos : 0); CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), to=%llu=%#llx(%d)\n", @@ -2136,13 +2104,13 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin) if (origin == SEEK_END || origin == SEEK_HOLE || origin == SEEK_DATA) { retval = ll_glimpse_size(inode); if (retval != 0) - RETURN(retval); + return retval; eof = i_size_read(inode); } - retval = ll_generic_file_llseek_size(file, offset, origin, + retval = generic_file_llseek_size(file, offset, origin, ll_file_maxbytes(inode), eof); - RETURN(retval); + return retval; } int ll_flush(struct file *file, fl_owner_t id) @@ -2184,15 +2152,14 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end, struct obd_capa *capa = NULL; struct cl_fsync_io *fio; int result; - ENTRY; if (mode != CL_FSYNC_NONE && mode != CL_FSYNC_LOCAL && mode != CL_FSYNC_DISCARD && mode != CL_FSYNC_ALL) - RETURN(-EINVAL); + return -EINVAL; env = cl_env_nested_get(&nest); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); capa = ll_osscapa_get(inode, CAPA_OPC_OSS_WRITE); @@ -2220,7 +2187,7 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end, capa_put(capa); - RETURN(result); + return result; } /* @@ -2237,7 +2204,6 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) struct ptlrpc_request *req; struct obd_capa *oc; int rc, err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -2281,23 +2247,24 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) } mutex_unlock(&inode->i_mutex); - RETURN(rc); + return rc; } int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) { struct inode *inode = file->f_dentry->d_inode; struct ll_sb_info *sbi = ll_i2sbi(inode); - struct ldlm_enqueue_info einfo = { .ei_type = LDLM_FLOCK, - .ei_cb_cp =ldlm_flock_completion_ast, - .ei_cbdata = file_lock }; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_FLOCK, + .ei_cb_cp = ldlm_flock_completion_ast, + .ei_cbdata = file_lock, + }; struct md_op_data *op_data; struct lustre_handle lockh = {0}; ldlm_policy_data_t flock = {{0}}; int flags = 0; int rc; int rc2 = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu file_lock=%p\n", inode->i_ino, file_lock); @@ -2315,7 +2282,7 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) flock.l_flock.start = file_lock->fl_start; flock.l_flock.end = file_lock->fl_end; } else { - RETURN(-EINVAL); + return -EINVAL; } flock.l_flock.pid = file_lock->fl_pid; @@ -2350,7 +2317,7 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) default: CDEBUG(D_INFO, "Unknown fcntl lock type: %d\n", file_lock->fl_type); - RETURN (-ENOTSUPP); + return -ENOTSUPP; } switch (cmd) { @@ -2377,13 +2344,13 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) break; default: CERROR("unknown fcntl lock command: %d\n", cmd); - RETURN (-EINVAL); + return -EINVAL; } op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_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, @@ -2409,14 +2376,12 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) ll_finish_md_op_data(op_data); - RETURN(rc); + return rc; } int ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock) { - ENTRY; - - RETURN(-ENOSYS); + return -ENOSYS; } /** @@ -2438,17 +2403,16 @@ int ll_have_md_lock(struct inode *inode, __u64 *bits, ldlm_mode_t l_req_mode) struct lu_fid *fid; __u64 flags; int i; - ENTRY; if (!inode) - RETURN(0); + return 0; fid = &ll_i2info(inode)->lli_fid; CDEBUG(D_INFO, "trying to match res "DFID" mode %s\n", PFID(fid), ldlm_lockname[mode]); flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING | LDLM_FL_TEST_LOCK; - for (i = 0; i < MDS_INODELOCK_MAXSHIFT && *bits != 0; i++) { + for (i = 0; i <= MDS_INODELOCK_MAXSHIFT && *bits != 0; i++) { policy.l_inodebits.bits = *bits & (1 << i); if (policy.l_inodebits.bits == 0) continue; @@ -2467,7 +2431,7 @@ int ll_have_md_lock(struct inode *inode, __u64 *bits, ldlm_mode_t l_req_mode) } } } - RETURN(*bits == 0); + return *bits == 0; } ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, @@ -2476,7 +2440,6 @@ ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, ldlm_policy_data_t policy = { .l_inodebits = {bits}}; struct lu_fid *fid; ldlm_mode_t rc; - ENTRY; fid = &ll_i2info(inode)->lli_fid; CDEBUG(D_INFO, "trying to match res "DFID"\n", PFID(fid)); @@ -2484,7 +2447,7 @@ ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, rc = md_lock_match(ll_i2mdexp(inode), LDLM_FL_BLOCK_GRANTED|flags, fid, LDLM_IBITS, &policy, LCK_CR|LCK_CW|LCK_PR|LCK_PW, lockh); - RETURN(rc); + return rc; } static int ll_inode_revalidate_fini(struct inode *inode, int rc) @@ -2513,7 +2476,6 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, struct ptlrpc_request *req = NULL; struct obd_export *exp; int rc = 0; - ENTRY; LASSERT(inode != NULL); @@ -2537,7 +2499,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, dentry->d_inode, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); oit.it_create_mode |= M_CHECK_STALE; rc = md_intent_lock(exp, op_data, NULL, 0, @@ -2575,7 +2537,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, if (S_ISREG(inode->i_mode)) { rc = ll_get_max_mdsize(sbi, &ealen); if (rc) - RETURN(rc); + return rc; valid |= OBD_MD_FLEASIZE | OBD_MD_FLMODEASIZE; } @@ -2583,7 +2545,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, 0, ealen, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = valid; /* Once OBD_CONNECT_ATTRFID is not supported, we can't find one @@ -2593,7 +2555,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, ll_finish_md_op_data(op_data); if (rc) { rc = ll_inode_revalidate_fini(inode, rc); - RETURN(rc); + return rc; } rc = ll_prep_inode(&inode, req, NULL, NULL); @@ -2608,11 +2570,10 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, { struct inode *inode = dentry->d_inode; int rc; - ENTRY; rc = __ll_inode_revalidate_it(dentry, it, ibits); if (rc != 0) - RETURN(rc); + return rc; /* if object isn't regular file, don't validate size */ if (!S_ISREG(inode->i_mode)) { @@ -2622,7 +2583,7 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, } else { rc = ll_glimpse_size(inode); } - RETURN(rc); + return rc; } int ll_getattr_it(struct vfsmount *mnt, struct dentry *de, @@ -2672,21 +2633,19 @@ struct posix_acl * ll_get_acl(struct inode *inode, int type) { struct ll_inode_info *lli = ll_i2info(inode); struct posix_acl *acl = NULL; - ENTRY; spin_lock(&lli->lli_lock); /* VFS' acl_permission_check->check_acl will release the refcount */ acl = posix_acl_dup(lli->lli_posix_acl); spin_unlock(&lli->lli_lock); - RETURN(acl); + return acl; } int ll_inode_permission(struct inode *inode, int mask) { int rc = 0; - ENTRY; #ifdef MAY_NOT_BLOCK if (mask & MAY_NOT_BLOCK) @@ -2702,7 +2661,7 @@ int ll_inode_permission(struct inode *inode, int mask) rc = __ll_inode_revalidate_it(inode->i_sb->s_root, &it, MDS_INODELOCK_LOOKUP); if (rc) - RETURN(rc); + return rc; } CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), inode mode %x mask %o\n", @@ -2712,9 +2671,9 @@ int ll_inode_permission(struct inode *inode, int mask) return lustre_check_remote_perm(inode, mask); ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1); - rc = ll_generic_permission(inode, mask, flags, ll_check_acl); + rc = generic_permission(inode, mask); - RETURN(rc); + return rc; } #define READ_METHOD aio_read @@ -2806,16 +2765,15 @@ void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd) { unsigned int size; struct llioc_data *in_data = NULL; - ENTRY; if (cb == NULL || cmd == NULL || count > LLIOC_MAX_CMD || count < 0) - RETURN(NULL); + return NULL; size = sizeof(*in_data) + count * sizeof(unsigned int); OBD_ALLOC(in_data, size); if (in_data == NULL) - RETURN(NULL); + return NULL; memset(in_data, 0, sizeof(*in_data)); in_data->iocd_size = size; @@ -2827,7 +2785,7 @@ void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd) list_add_tail(&in_data->iocd_list, &llioc.ioc_head); up_write(&llioc.ioc_sem); - RETURN(in_data); + return in_data; } void ll_iocontrol_unregister(void *magic) @@ -2890,14 +2848,13 @@ int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf) struct cl_env_nest nest; struct lu_env *env; int result; - ENTRY; if (lli->lli_clob == NULL) - RETURN(0); + return 0; env = cl_env_nested_get(&nest); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); result = cl_conf_set(env, lli->lli_clob, conf); cl_env_nested_put(&nest, env); @@ -2915,7 +2872,7 @@ int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf) ldlm_lock_allow_match(lock); } } - RETURN(result); + return result; } /* Fetch layout from MDT with getxattr request, if it's not ready yet */ @@ -2930,10 +2887,13 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) void *lmm; int lmmsize; int rc; - ENTRY; - if (lock->l_lvb_data != NULL) - RETURN(0); + CDEBUG(D_INODE, DFID" LVB_READY=%d l_lvb_data=%p l_lvb_len=%d\n", + PFID(ll_inode2fid(inode)), !!(lock->l_flags & LDLM_FL_LVB_READY), + lock->l_lvb_data, lock->l_lvb_len); + + if ((lock->l_lvb_data != NULL) && (lock->l_flags & LDLM_FL_LVB_READY)) + return 0; /* if layout lock was granted right away, the layout is returned * within DLM_LVB of dlm reply; otherwise if the lock was ever @@ -2948,7 +2908,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) lmmsize, 0, &req); capa_put(oc); if (rc < 0) - RETURN(rc); + return rc; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); if (body == NULL || body->eadatasize > lmmsize) @@ -2968,16 +2928,12 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) memcpy(lvbdata, lmm, lmmsize); lock_res_and_lock(lock); - if (lock->l_lvb_data == NULL) { - lock->l_lvb_data = lvbdata; - lock->l_lvb_len = lmmsize; - lvbdata = NULL; - } - unlock_res_and_lock(lock); + if (lock->l_lvb_data != NULL) + OBD_FREE_LARGE(lock->l_lvb_data, lock->l_lvb_len); - if (lvbdata != NULL) - OBD_FREE_LARGE(lvbdata, lmmsize); - EXIT; + lock->l_lvb_data = lvbdata; + lock->l_lvb_len = lmmsize; + unlock_res_and_lock(lock); out: ptlrpc_req_finished(req); @@ -2999,7 +2955,6 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, int rc = 0; bool lvb_ready; bool wait_layout = false; - ENTRY; LASSERT(lustre_handle_is_used(lockh)); @@ -3008,7 +2963,7 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, LASSERT(ldlm_has_layout(lock)); LDLM_DEBUG(lock, "File %p/"DFID" being reconfigured: %d.\n", - inode, PFID(&lli->lli_fid), reconf); + inode, PFID(&lli->lli_fid), reconf); /* in case this is a caching lock and reinstate with new inode */ md_set_lock_data(sbi->ll_md_exp, &lockh->cookie, inode, NULL); @@ -3068,7 +3023,6 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, /* refresh layout failed, need to wait */ wait_layout = rc == -EBUSY; - EXIT; out: LDLM_LOCK_PUT(lock); @@ -3090,7 +3044,7 @@ out: CDEBUG(D_INODE, "file: "DFID" waiting layout return: %d.\n", PFID(&lli->lli_fid), rc); } - RETURN(rc); + return rc; } /** @@ -3114,17 +3068,17 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) struct lookup_intent it; struct lustre_handle lockh; ldlm_mode_t mode; - struct ldlm_enqueue_info einfo = { .ei_type = LDLM_IBITS, - .ei_mode = LCK_CR, - .ei_cb_bl = ll_md_blocking_ast, - .ei_cb_cp = ldlm_completion_ast, - .ei_cbdata = NULL }; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_IBITS, + .ei_mode = LCK_CR, + .ei_cb_bl = ll_md_blocking_ast, + .ei_cb_cp = ldlm_completion_ast, + }; int rc; - ENTRY; *gen = lli->lli_layout_gen; if (!(sbi->ll_flags & LL_SBI_LAYOUT_LOCK)) - RETURN(0); + return 0; /* sanity checks */ LASSERT(fid_is_sane(ll_inode2fid(inode))); @@ -3136,7 +3090,7 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) if (mode != 0) { /* hit cached lock */ rc = ll_layout_lock_set(&lockh, mode, inode, gen, false); if (rc == 0) - RETURN(0); + return 0; /* better hold lli_layout_mutex to try again otherwise * it will have starvation problem. */ @@ -3154,14 +3108,14 @@ again: goto again; mutex_unlock(&lli->lli_layout_mutex); - RETURN(rc); + return rc; } op_data = ll_prep_md_op_data(NULL, inode, inode, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) { mutex_unlock(&lli->lli_layout_mutex); - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); } /* have to enqueue one */ @@ -3194,5 +3148,5 @@ again: } mutex_unlock(&lli->lli_layout_mutex); - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c index b6fd9593325..edd512b20ee 100644 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ b/drivers/staging/lustre/lustre/llite/llite_capa.c @@ -41,7 +41,6 @@ #define DEBUG_SUBSYSTEM S_LLITE #include <linux/fs.h> -#include <linux/version.h> #include <asm/uaccess.h> #include <linux/file.h> #include <linux/kmod.h> @@ -171,7 +170,6 @@ static int capa_thread_main(void *unused) struct inode *inode = NULL; struct l_wait_info lwi = { 0 }; int rc; - ENTRY; thread_set_flags(&ll_capa_thread, SVC_RUNNING); wake_up(&ll_capa_thread.t_ctl_waitq); @@ -281,7 +279,7 @@ static int capa_thread_main(void *unused) thread_set_flags(&ll_capa_thread, SVC_STOPPED); wake_up(&ll_capa_thread.t_ctl_waitq); - RETURN(0); + return 0; } void ll_capa_timer_callback(unsigned long unused) @@ -291,8 +289,7 @@ void ll_capa_timer_callback(unsigned long unused) int ll_capa_thread_start(void) { - task_t *task; - ENTRY; + struct task_struct *task; init_waitqueue_head(&ll_capa_thread.t_ctl_waitq); @@ -300,12 +297,12 @@ int ll_capa_thread_start(void) if (IS_ERR(task)) { CERROR("cannot start expired capa thread: rc %ld\n", PTR_ERR(task)); - RETURN(PTR_ERR(task)); + return PTR_ERR(task); } wait_event(ll_capa_thread.t_ctl_waitq, thread_is_running(&ll_capa_thread)); - RETURN(0); + return 0; } void ll_capa_thread_stop(void) @@ -322,10 +319,8 @@ struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc) struct obd_capa *ocapa; int found = 0; - ENTRY; - if ((ll_i2sbi(inode)->ll_flags & LL_SBI_OSS_CAPA) == 0) - RETURN(NULL); + return NULL; LASSERT(opc == CAPA_OPC_OSS_WRITE || opc == CAPA_OPC_OSS_RW || opc == CAPA_OPC_OSS_TRUNC); @@ -369,7 +364,7 @@ struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc) } spin_unlock(&capa_lock); - RETURN(ocapa); + return ocapa; } EXPORT_SYMBOL(ll_osscapa_get); @@ -377,12 +372,11 @@ struct obd_capa *ll_mdscapa_get(struct inode *inode) { struct ll_inode_info *lli = ll_i2info(inode); struct obd_capa *ocapa; - ENTRY; LASSERT(inode != NULL); if ((ll_i2sbi(inode)->ll_flags & LL_SBI_MDS_CAPA) == 0) - RETURN(NULL); + return NULL; spin_lock(&capa_lock); ocapa = capa_get(lli->lli_mds_capa); @@ -392,7 +386,7 @@ struct obd_capa *ll_mdscapa_get(struct inode *inode) atomic_set(&ll_capa_debug, 0); } - RETURN(ocapa); + return ocapa; } static struct obd_capa *do_add_mds_capa(struct inode *inode, @@ -525,7 +519,6 @@ int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) { struct inode *inode = ocapa->u.cli.inode; int rc = 0; - ENTRY; LASSERT(ocapa); @@ -561,7 +554,7 @@ int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) capa_put(ocapa); iput(inode); - RETURN(rc); + return rc; } spin_lock(&ocapa->c_lock); @@ -575,7 +568,6 @@ int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) if (capa_for_oss(capa)) inode_add_oss_capa(inode, ocapa); DEBUG_CAPA(D_SEC, capa, "renew"); - EXIT; retry: list_del_init(&ocapa->c_list); sort_add_capa(ocapa, ll_capa_list); diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index 00b2b38d4c9..1f5825c87a7 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -50,14 +50,12 @@ void vvp_write_pending(struct ccc_object *club, struct ccc_page *page) { struct ll_inode_info *lli = ll_i2info(club->cob_inode); - ENTRY; spin_lock(&lli->lli_lock); lli->lli_flags |= LLIF_SOM_DIRTY; if (page != NULL && list_empty(&page->cpg_pending_linkage)) list_add(&page->cpg_pending_linkage, &club->cob_pending_list); spin_unlock(&lli->lli_lock); - EXIT; } /** records that a write has completed */ @@ -66,7 +64,6 @@ void vvp_write_complete(struct ccc_object *club, struct ccc_page *page) struct ll_inode_info *lli = ll_i2info(club->cob_inode); int rc = 0; - ENTRY; spin_lock(&lli->lli_lock); if (page != NULL && !list_empty(&page->cpg_pending_linkage)) { list_del_init(&page->cpg_pending_linkage); @@ -75,7 +72,6 @@ void vvp_write_complete(struct ccc_object *club, struct ccc_page *page) spin_unlock(&lli->lli_lock); if (rc) ll_queue_done_writing(club->cob_inode, 0); - EXIT; } /** Queues DONE_WRITING if @@ -85,7 +81,6 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags) { struct ll_inode_info *lli = ll_i2info(inode); struct ccc_object *club = cl2ccc(ll_i2info(inode)->lli_clob); - ENTRY; spin_lock(&lli->lli_lock); lli->lli_flags |= flags; @@ -119,14 +114,12 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags) spin_unlock(&lcq->lcq_lock); } spin_unlock(&lli->lli_lock); - EXIT; } /** Pack SOM attributes info @opdata for CLOSE, DONE_WRITING rpc. */ void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data) { struct ll_inode_info *lli = ll_i2info(inode); - ENTRY; op_data->op_flags |= MF_SOM_CHANGE; /* Check if Size-on-MDS attributes are valid. */ @@ -140,7 +133,6 @@ void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data) op_data->op_attr.ia_valid |= ATTR_MTIME_SET | ATTR_CTIME_SET | ATTR_ATIME_SET | ATTR_SIZE | ATTR_BLOCKS; } - EXIT; } /** Closes ioepoch and packs Size-on-MDS attribute if needed into @op_data. */ @@ -149,7 +141,6 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, { struct ll_inode_info *lli = ll_i2info(inode); struct ccc_object *club = cl2ccc(ll_i2info(inode)->lli_clob); - ENTRY; spin_lock(&lli->lli_lock); if (!(list_empty(&club->cob_pending_list))) { @@ -209,7 +200,6 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, spin_unlock(&lli->lli_lock); ll_done_writing_attr(inode, op_data); - EXIT; out: return; } @@ -225,7 +215,6 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) __u32 old_flags; struct obdo *oa; int rc; - ENTRY; LASSERT(op_data != NULL); if (lli->lli_flags & LLIF_MDS_SIZE_LOCK) @@ -236,7 +225,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) OBDO_ALLOC(oa); if (!oa) { CERROR("can't allocate memory for Size-on-MDS update.\n"); - RETURN(-ENOMEM); + return -ENOMEM; } old_flags = op_data->op_flags; @@ -266,7 +255,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) ptlrpc_req_finished(request); OBDO_FREE(oa); - RETURN(rc); + return rc; } /** @@ -293,14 +282,12 @@ static void ll_done_writing(struct inode *inode) struct obd_client_handle *och = NULL; struct md_op_data *op_data; int rc; - ENTRY; LASSERT(exp_connect_som(ll_i2mdexp(inode))); OBD_ALLOC_PTR(op_data); if (op_data == NULL) { CERROR("can't allocate op_data\n"); - EXIT; return; } @@ -324,7 +311,6 @@ out: md_clear_open_replay_data(ll_i2sbi(inode)->ll_md_exp, och); OBD_FREE_PTR(och); } - EXIT; } static struct ll_inode_info *ll_close_next_lli(struct ll_close_queue *lcq) @@ -347,7 +333,6 @@ static struct ll_inode_info *ll_close_next_lli(struct ll_close_queue *lcq) static int ll_close_thread(void *arg) { struct ll_close_queue *lcq = arg; - ENTRY; complete(&lcq->lcq_comp); @@ -371,13 +356,13 @@ static int ll_close_thread(void *arg) CDEBUG(D_INFO, "ll_close exiting\n"); complete(&lcq->lcq_comp); - RETURN(0); + return 0; } int ll_close_thread_start(struct ll_close_queue **lcq_ret) { struct ll_close_queue *lcq; - task_t *task; + struct task_struct *task; if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CLOSE_THREAD)) return -EINTR; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 5227c5c4ebe..47e443d90fe 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -90,6 +90,7 @@ extern struct file_operations ll_pgcache_seq_fops; #define REMOTE_PERM_HASHSIZE 16 struct ll_getname_data { + struct dir_context ctx; char *lgd_name; /* points to a buffer with NAME_MAX+1 size */ struct lu_fid lgd_fid; /* target fid we are looking for */ int lgd_found; /* inode matched? */ @@ -438,14 +439,6 @@ struct rmtacl_ctl_table { #define EE_HASHES 32 -struct eacl_entry { - struct list_head ee_list; - pid_t ee_key; /* hash key */ - struct lu_fid ee_fid; - int ee_type; /* ACL type for ACCESS or DEFAULT */ - ext_acl_xattr_header *ee_acl; -}; - struct eacl_table { spinlock_t et_lock; struct list_head et_entries[EE_HASHES]; @@ -512,6 +505,7 @@ struct ll_sb_info { * clustred nfs */ struct rmtacl_ctl_table ll_rct; struct eacl_table ll_et; + __kernel_fsid_t ll_fsid; }; #define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024) @@ -687,8 +681,7 @@ extern struct file_operations ll_dir_operations; extern struct inode_operations ll_dir_inode_operations; struct page *ll_get_dir_page(struct inode *dir, __u64 hash, struct ll_dir_chain *chain); -int ll_dir_read(struct inode *inode, __u64 *_pos, void *cookie, - filldir_t filldir); +int ll_dir_read(struct inode *inode, struct dir_context *ctx); int ll_get_mdt_idx(struct inode *inode); /* llite/namei.c */ @@ -792,8 +785,7 @@ void ll_intent_release(struct lookup_intent *); void ll_invalidate_aliases(struct inode *); void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft); void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry); -int ll_dcompare(const struct dentry *parent, const struct inode *pinode, - const struct dentry *dentry, const struct inode *inode, +int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, unsigned int len, const char *str, const struct qstr *d_name); int ll_revalidate_it_finish(struct ptlrpc_request *request, struct lookup_intent *it, struct dentry *de); @@ -842,6 +834,7 @@ char *ll_get_fsname(struct super_block *sb, char *buf, int buflen); /* llite/llite_nfs.c */ extern struct export_operations lustre_export_operations; __u32 get_uuid2int(const char *name, int len); +void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid); struct inode *search_inode_for_lustre(struct super_block *sb, const struct lu_fid *fid); @@ -1129,7 +1122,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm); int lustre_check_remote_perm(struct inode *inode, int mask); /* llite/llite_capa.c */ -extern timer_list_t ll_capa_timer; +extern struct timer_list ll_capa_timer; int ll_capa_thread_start(void); void ll_capa_thread_stop(void); @@ -1168,6 +1161,14 @@ void ll_ra_stats_inc(struct address_space *mapping, enum ra_stat which); /* llite/llite_rmtacl.c */ #ifdef CONFIG_FS_POSIX_ACL +struct eacl_entry { + struct list_head ee_list; + pid_t ee_key; /* hash key */ + struct lu_fid ee_fid; + int ee_type; /* ACL type for ACCESS or DEFAULT */ + ext_acl_xattr_header *ee_acl; +}; + obd_valid rce_ops2valid(int ops); struct rmtacl_ctl_entry *rct_search(struct rmtacl_ctl_table *rct, pid_t key); int rct_add(struct rmtacl_ctl_table *rct, pid_t key, int ops); @@ -1183,6 +1184,11 @@ struct eacl_entry *et_search_del(struct eacl_table *et, pid_t key, void et_search_free(struct eacl_table *et, pid_t key); void et_init(struct eacl_table *et); void et_fini(struct eacl_table *et); +#else +static inline obd_valid rce_ops2valid(int ops) +{ + return 0; +} #endif /* statahead.c */ diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index afae8010623..b868c2bd58d 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -42,7 +42,6 @@ #include <linux/module.h> #include <linux/types.h> -#include <linux/version.h> #include <linux/mm.h> #include <lustre_lite.h> @@ -79,11 +78,10 @@ static struct ll_sb_info *ll_init_sbi(void) struct sysinfo si; class_uuid_t uuid; int i; - ENTRY; OBD_ALLOC(sbi, sizeof(*sbi)); if (!sbi) - RETURN(NULL); + return NULL; spin_lock_init(&sbi->ll_lock); mutex_init(&sbi->ll_lco.lco_lock); @@ -141,13 +139,12 @@ static struct ll_sb_info *ll_init_sbi(void) atomic_set(&sbi->ll_agl_total, 0); sbi->ll_flags |= LL_SBI_AGL_ENABLED; - RETURN(sbi); + return sbi; } void ll_free_sbi(struct super_block *sb) { struct ll_sb_info *sbi = ll_s2sbi(sb); - ENTRY; if (sbi != NULL) { spin_lock(&ll_sb_lock); @@ -155,7 +152,6 @@ void ll_free_sbi(struct super_block *sb) spin_unlock(&ll_sb_lock); OBD_FREE(sbi, sizeof(*sbi)); } - EXIT; } static struct dentry_operations ll_d_root_ops = { @@ -178,22 +174,21 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, struct lustre_md lmd; obd_valid valid; int size, err, checksum; - ENTRY; obd = class_name2obd(md); if (!obd) { CERROR("MD %s: not setup or attached\n", md); - RETURN(-EINVAL); + return -EINVAL; } OBD_ALLOC_PTR(data); if (data == NULL) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC_PTR(osfs); if (osfs == NULL) { OBD_FREE_PTR(data); - RETURN(-ENOMEM); + return -ENOMEM; } if (proc_lustre_fs_root) { @@ -583,15 +578,17 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, /* s_dev is also used in lt_compare() to compare two fs, but that is * only a node-local comparison. */ uuid = obd_get_uuid(sbi->ll_md_exp); - if (uuid != NULL) + if (uuid != NULL) { sb->s_dev = get_uuid2int(uuid->uuid, strlen(uuid->uuid)); + get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), &sbi->ll_fsid); + } if (data != NULL) OBD_FREE_PTR(data); if (osfs != NULL) OBD_FREE_PTR(osfs); - RETURN(err); + return err; out_root: if (root) iput(root); @@ -627,7 +624,7 @@ int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize) if (rc) CERROR("Get max mdsize error rc %d \n", rc); - RETURN(rc); + return rc; } void ll_dump_inode(struct inode *inode) @@ -676,7 +673,6 @@ void lustre_dump_dentry(struct dentry *dentry, int recur) void client_common_put_super(struct super_block *sb) { struct ll_sb_info *sbi = ll_s2sbi(sb); - ENTRY; #ifdef CONFIG_FS_POSIX_ACL if (sbi->ll_flags & LL_SBI_RMT_CLIENT) { @@ -703,16 +699,12 @@ void client_common_put_super(struct super_block *sb) obd_fid_fini(sbi->ll_md_exp->exp_obd); obd_disconnect(sbi->ll_md_exp); sbi->ll_md_exp = NULL; - - EXIT; } void ll_kill_super(struct super_block *sb) { struct ll_sb_info *sbi; - ENTRY; - /* not init sb ?*/ if (!(sb->s_flags & MS_ACTIVE)) return; @@ -725,31 +717,29 @@ void ll_kill_super(struct super_block *sb) sb->s_dev = sbi->ll_sdev_orig; sbi->ll_umounting = 1; } - EXIT; } char *ll_read_opt(const char *opt, char *data) { char *value; char *retval; - ENTRY; CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data); if (strncmp(opt, data, strlen(opt))) - RETURN(NULL); + return NULL; if ((value = strchr(data, '=')) == NULL) - RETURN(NULL); + return NULL; value++; OBD_ALLOC(retval, strlen(value) + 1); if (!retval) { CERROR("out of memory!\n"); - RETURN(NULL); + return NULL; } memcpy(retval, value, strlen(value)+1); CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval); - RETURN(retval); + return retval; } static inline int ll_set_opt(const char *opt, char *data, int fl) @@ -765,10 +755,9 @@ static int ll_options(char *options, int *flags) { int tmp; char *s1 = options, *s2; - ENTRY; if (!options) - RETURN(0); + return 0; CDEBUG(D_CONFIG, "Parsing opts %s\n", options); @@ -891,7 +880,7 @@ static int ll_options(char *options, int *flags) } LCONSOLE_ERROR_MSG(0x152, "Unknown option '%s', won't mount.\n", s1); - RETURN(-EINVAL); + return -EINVAL; next: /* Find next opt */ @@ -900,7 +889,7 @@ next: break; s1 = s2 + 1; } - RETURN(0); + return 0; } void ll_lli_init(struct ll_inode_info *lli) @@ -977,13 +966,12 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */ const int instlen = sizeof(cfg->cfg_instance) * 2 + 2; int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb); OBD_ALLOC_PTR(cfg); if (cfg == NULL) - RETURN(-ENOMEM); + return -ENOMEM; try_module_get(THIS_MODULE); @@ -992,7 +980,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) if (!sbi) { module_put(THIS_MODULE); OBD_FREE_PTR(cfg); - RETURN(-ENOMEM); + return -ENOMEM; } err = ll_options(lsi->lsi_lmd->lmd_opts, &sbi->ll_flags); @@ -1058,7 +1046,7 @@ out_free: LCONSOLE_WARN("Mounted %s\n", profilenm); OBD_FREE_PTR(cfg); - RETURN(err); + return err; } /* ll_fill_super */ void ll_put_super(struct super_block *sb) @@ -1069,7 +1057,6 @@ void ll_put_super(struct super_block *sb) struct ll_sb_info *sbi = ll_s2sbi(sb); char *profilenm = get_profile_name(sb); int next, force = 1; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op: sb %p - %s\n", sb, profilenm); @@ -1121,8 +1108,6 @@ void ll_put_super(struct super_block *sb) lustre_common_put_super(sb); module_put(THIS_MODULE); - - EXIT; } /* client_put_super */ struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock) @@ -1176,7 +1161,6 @@ void ll_clear_inode(struct inode *inode) { struct ll_inode_info *lli = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -1188,7 +1172,9 @@ void ll_clear_inode(struct inode *inode) LASSERT(lli->lli_opendir_pid == 0); } + spin_lock(&lli->lli_lock); ll_i2info(inode)->lli_flags &= ~LLIF_MDS_SIZE_LOCK; + spin_unlock(&lli->lli_lock); md_null_inode(sbi->ll_md_exp, ll_inode2fid(inode)); LASSERT(!lli->lli_open_fd_write_count); @@ -1235,8 +1221,6 @@ void ll_clear_inode(struct inode *inode) */ cl_inode_fini(inode); lli->lli_has_smd = false; - - EXIT; } int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, @@ -1247,12 +1231,11 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, struct ll_sb_info *sbi = ll_i2sbi(inode); struct ptlrpc_request *request = NULL; int rc, ia_valid; - ENTRY; op_data = ll_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, NULL, 0, &request, mod); @@ -1272,14 +1255,14 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, } else if (rc != -EPERM && rc != -EACCES && rc != -ETXTBSY) { CERROR("md_setattr fails: rc = %d\n", rc); } - RETURN(rc); + return rc; } rc = md_get_lustre_md(sbi->ll_md_exp, request, sbi->ll_dt_exp, sbi->ll_md_exp, &md); if (rc) { ptlrpc_req_finished(request); - RETURN(rc); + return rc; } ia_valid = op_data->op_attr.ia_valid; @@ -1296,7 +1279,7 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, ll_update_inode(inode, &md); ptlrpc_req_finished(request); - RETURN(rc); + return rc; } /* Close IO epoch and send Size-on-MDS attribute update. */ @@ -1306,11 +1289,10 @@ static int ll_setattr_done_writing(struct inode *inode, { struct ll_inode_info *lli = ll_i2info(inode); int rc = 0; - ENTRY; LASSERT(op_data != NULL); if (!S_ISREG(inode->i_mode)) - RETURN(0); + return 0; CDEBUG(D_INODE, "Epoch "LPU64" closed on "DFID" for truncate\n", op_data->op_ioepoch, PFID(&lli->lli_fid)); @@ -1328,7 +1310,7 @@ static int ll_setattr_done_writing(struct inode *inode, CERROR("inode %lu mdc truncate failed: rc = %d\n", inode->i_ino, rc); } - RETURN(rc); + return rc; } static int ll_setattr_ost(struct inode *inode, struct iattr *attr) @@ -1372,7 +1354,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) struct md_op_data *op_data = NULL; struct md_open_data *mod = NULL; int rc = 0, rc1 = 0; - ENTRY; CDEBUG(D_VFSTRACE, "%s: setattr inode %p/fid:"DFID" from %llu to %llu, " "valid %x\n", ll_get_fsname(inode->i_sb, NULL, 0), inode, @@ -1383,7 +1364,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) /* Check new size against VFS/VM file size limit and rlimit */ rc = inode_newsize_ok(inode, attr->ia_size); if (rc) - RETURN(rc); + return rc; /* The maximum Lustre file size is variable, based on the * OST maximum object size and number of stripes. This @@ -1392,7 +1373,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) CDEBUG(D_INODE,"file "DFID" too large %llu > "LPU64"\n", PFID(&lli->lli_fid), attr->ia_size, ll_file_maxbytes(inode)); - RETURN(-EFBIG); + return -EFBIG; } attr->ia_valid |= ATTR_MTIME | ATTR_CTIME; @@ -1400,24 +1381,24 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */ if (attr->ia_valid & TIMES_SET_FLAGS) { - if (current_fsuid() != inode->i_uid && + if ((!uid_eq(current_fsuid(), inode->i_uid)) && !cfs_capable(CFS_CAP_FOWNER)) - RETURN(-EPERM); + return -EPERM; } /* We mark all of the fields "set" so MDS/OST does not re-set them */ if (attr->ia_valid & ATTR_CTIME) { - attr->ia_ctime = CFS_CURRENT_TIME; + attr->ia_ctime = CURRENT_TIME; attr->ia_valid |= ATTR_CTIME_SET; } if (!(attr->ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) { - attr->ia_atime = CFS_CURRENT_TIME; + attr->ia_atime = CURRENT_TIME; attr->ia_valid |= ATTR_ATIME_SET; } if (!(attr->ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) { - attr->ia_mtime = CFS_CURRENT_TIME; + attr->ia_mtime = CURRENT_TIME; attr->ia_valid |= ATTR_MTIME_SET; } @@ -1439,7 +1420,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) OBD_ALLOC_PTR(op_data); if (op_data == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (!S_ISDIR(inode->i_mode)) { if (attr->ia_valid & ATTR_SIZE) @@ -1480,7 +1461,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) * setting times to past, but it is necessary due to possible * time de-synchronization between MDT inode and OST objects */ rc = ll_setattr_ost(inode, attr); - EXIT; out: if (op_data) { if (op_data->op_ioepoch) { @@ -1537,12 +1517,11 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_statfs obd_osfs; int rc; - ENTRY; rc = obd_statfs(NULL, sbi->ll_md_exp, osfs, max_age, flags); if (rc) { CERROR("md_statfs fails: rc = %d\n", rc); - RETURN(rc); + return rc; } osfs->os_type = sb->s_magic; @@ -1556,7 +1535,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, rc = obd_statfs_rqset(sbi->ll_dt_exp, &obd_osfs, max_age, flags); if (rc) { CERROR("obd_statfs fails: rc = %d\n", rc); - RETURN(rc); + return rc; } CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n", @@ -1578,7 +1557,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, osfs->os_ffree = obd_osfs.os_ffree; } - RETURN(rc); + return rc; } int ll_statfs(struct dentry *de, struct kstatfs *sfs) { @@ -1615,7 +1594,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs) sfs->f_blocks = osfs.os_blocks; sfs->f_bfree = osfs.os_bfree; sfs->f_bavail = osfs.os_bavail; - + sfs->f_fsid = ll_s2sbi(sb)->ll_fsid; return 0; } @@ -1707,9 +1686,9 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) inode->i_blkbits = inode->i_sb->s_blocksize_bits; } if (body->valid & OBD_MD_FLUID) - inode->i_uid = body->uid; + inode->i_uid = make_kuid(&init_user_ns, body->uid); if (body->valid & OBD_MD_FLGID) - inode->i_gid = body->gid; + inode->i_gid = make_kgid(&init_user_ns, body->gid); if (body->valid & OBD_MD_FLFLAGS) inode->i_flags = ll_ext_to_inode_flags(body->flags); if (body->valid & OBD_MD_FLNLINK) @@ -1755,7 +1734,9 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) /* Use old size assignment to avoid * deadlock bz14138 & bz14326 */ i_size_write(inode, body->size); + spin_lock(&lli->lli_lock); lli->lli_flags |= LLIF_MDS_SIZE_LOCK; + spin_unlock(&lli->lli_lock); } ldlm_lock_decref(&lockh, mode); } @@ -1786,7 +1767,6 @@ void ll_read_inode2(struct inode *inode, void *opaque) { struct lustre_md *md = opaque; struct ll_inode_info *lli = ll_i2info(inode); - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n", PFID(&lli->lli_fid), inode); @@ -1814,28 +1794,22 @@ void ll_read_inode2(struct inode *inode, void *opaque) inode->i_op = &ll_file_inode_operations; inode->i_fop = sbi->ll_fop; inode->i_mapping->a_ops = (struct address_space_operations *)&ll_aops; - EXIT; } else if (S_ISDIR(inode->i_mode)) { inode->i_op = &ll_dir_inode_operations; inode->i_fop = &ll_dir_operations; - EXIT; } else if (S_ISLNK(inode->i_mode)) { inode->i_op = &ll_fast_symlink_inode_operations; - EXIT; } else { inode->i_op = &ll_special_inode_operations; init_special_inode(inode, inode->i_mode, inode->i_rdev); - - EXIT; } } void ll_delete_inode(struct inode *inode) { struct cl_inode_info *lli = cl_i2info(inode); - ENTRY; if (S_ISREG(inode->i_mode) && lli->lli_clob != NULL) /* discard all dirty pages before truncating them, required by @@ -1859,8 +1833,6 @@ void ll_delete_inode(struct inode *inode) ll_clear_inode(inode); clear_inode(inode); - - EXIT; } int ll_iocontrol(struct inode *inode, struct file *file, @@ -1869,7 +1841,6 @@ int ll_iocontrol(struct inode *inode, struct file *file, struct ll_sb_info *sbi = ll_i2sbi(inode); struct ptlrpc_request *req = NULL; int rc, flags = 0; - ENTRY; switch(cmd) { case FSFILT_IOC_GETFLAGS: { @@ -1880,14 +1851,14 @@ int ll_iocontrol(struct inode *inode, struct file *file, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = OBD_MD_FLFLAGS; rc = md_getattr(sbi->ll_md_exp, op_data, &req); ll_finish_md_op_data(op_data); if (rc) { CERROR("failure %d inode %lu\n", rc, inode->i_ino); - RETURN(-abs(rc)); + return -abs(rc); } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); @@ -1896,7 +1867,7 @@ int ll_iocontrol(struct inode *inode, struct file *file, ptlrpc_req_finished(req); - RETURN(put_user(flags, (int *)arg)); + return put_user(flags, (int *)arg); } case FSFILT_IOC_SETFLAGS: { struct lov_stripe_md *lsm; @@ -1904,12 +1875,12 @@ int ll_iocontrol(struct inode *inode, struct file *file, struct md_op_data *op_data; if (get_user(flags, (int *)arg)) - RETURN(-EFAULT); + return -EFAULT; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); ((struct ll_iattr *)&op_data->op_attr)->ia_attr_flags = flags; op_data->op_attr.ia_valid |= ATTR_ATTR_FLAG; @@ -1918,18 +1889,20 @@ int ll_iocontrol(struct inode *inode, struct file *file, ll_finish_md_op_data(op_data); ptlrpc_req_finished(req); if (rc) - RETURN(rc); + return rc; inode->i_flags = ll_ext_to_inode_flags(flags); lsm = ccc_inode_lsm_get(inode); - if (lsm == NULL) - RETURN(0); + if (!lsm_has_objects(lsm)) { + ccc_inode_lsm_put(inode, lsm); + return 0; + } OBDO_ALLOC(oinfo.oi_oa); if (!oinfo.oi_oa) { ccc_inode_lsm_put(inode, lsm); - RETURN(-ENOMEM); + return -ENOMEM; } oinfo.oi_md = lsm; oinfo.oi_oa->o_oi = lsm->lsm_oi; @@ -1946,20 +1919,21 @@ int ll_iocontrol(struct inode *inode, struct file *file, if (rc && rc != -EPERM && rc != -EACCES) CERROR("osc_setattr_async fails: rc = %d\n", rc); - RETURN(rc); + return rc; } default: - RETURN(-ENOSYS); + return -ENOSYS; } - RETURN(0); + return 0; } int ll_flush_ctx(struct inode *inode) { struct ll_sb_info *sbi = ll_i2sbi(inode); - CDEBUG(D_SEC, "flush context for user %d\n", current_uid()); + CDEBUG(D_SEC, "flush context for user %d\n", + from_kuid(&init_user_ns, current_uid())); obd_set_info_async(NULL, sbi->ll_md_exp, sizeof(KEY_FLUSH_CTX), KEY_FLUSH_CTX, @@ -1976,8 +1950,6 @@ void ll_umount_begin(struct super_block *sb) struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; struct obd_ioctl_data *ioc_data; - ENTRY; - CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb, sb->s_count, atomic_read(&sb->s_active)); @@ -1986,7 +1958,6 @@ void ll_umount_begin(struct super_block *sb) if (obd == NULL) { CERROR("Invalid MDC connection handle "LPX64"\n", sbi->ll_md_exp->exp_handle.h_cookie); - EXIT; return; } obd->obd_force = 1; @@ -1995,7 +1966,6 @@ void ll_umount_begin(struct super_block *sb) if (obd == NULL) { CERROR("Invalid LOV connection handle "LPX64"\n", sbi->ll_dt_exp->exp_handle.h_cookie); - EXIT; return; } obd->obd_force = 1; @@ -2016,8 +1986,6 @@ void ll_umount_begin(struct super_block *sb) * schedule() and sleep one second if needed, and hope. */ schedule(); - - EXIT; } int ll_remount_fs(struct super_block *sb, int *flags, char *data) @@ -2058,14 +2026,13 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, struct ll_sb_info *sbi = NULL; struct lustre_md md; int rc; - ENTRY; LASSERT(*inode || sb); sbi = sb ? ll_s2sbi(sb) : ll_i2sbi(*inode); rc = md_get_lustre_md(sbi->ll_md_exp, req, sbi->ll_dt_exp, sbi->ll_md_exp, &md); if (rc) - RETURN(rc); + return rc; if (*inode) { ll_update_inode(*inode, &md); @@ -2127,7 +2094,7 @@ out: if (md.lsm != NULL) obd_free_memmd(sbi->ll_dt_exp, &md.lsm); md_free_lustre_md(sbi->ll_md_exp, &md); - RETURN(rc); + return rc; } int ll_obd_statfs(struct inode *inode, void *arg) @@ -2238,8 +2205,8 @@ struct md_op_data * ll_prep_md_op_data(struct md_op_data *op_data, op_data->op_namelen = namelen; op_data->op_mode = mode; op_data->op_mod_time = cfs_time_current_sec(); - op_data->op_fsuid = current_fsuid(); - op_data->op_fsgid = current_fsgid(); + op_data->op_fsuid = 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(); op_data->op_bias = 0; op_data->op_cli_flags = 0; @@ -2303,7 +2270,7 @@ int ll_show_options(struct seq_file *seq, struct dentry *dentry) if (sbi->ll_flags & LL_SBI_USER_FID2PATH) seq_puts(seq, ",user_fid2path"); - RETURN(0); + return 0; } /** @@ -2313,23 +2280,22 @@ int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg) { struct ll_sb_info *sbi = ll_i2sbi(inode); struct obd_device *obd; - ENTRY; if (cmd == OBD_IOC_GETDTNAME) obd = class_exp2obd(sbi->ll_dt_exp); else if (cmd == OBD_IOC_GETMDNAME) obd = class_exp2obd(sbi->ll_md_exp); else - RETURN(-EINVAL); + return -EINVAL; if (!obd) - RETURN(-ENOENT); + return -ENOENT; if (copy_to_user((void *)arg, obd->obd_name, strlen(obd->obd_name) + 1)) - RETURN(-EFAULT); + return -EFAULT; - RETURN(0); + return 0; } /** diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index d9590d85634..caed6423e4e 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -40,13 +40,9 @@ #include <linux/stat.h> #include <linux/errno.h> #include <linux/unistd.h> -#include <linux/version.h> #include <asm/uaccess.h> #include <linux/fs.h> -#include <linux/stat.h> -#include <asm/uaccess.h> -#include <linux/mm.h> #include <linux/pagemap.h> #define DEBUG_SUBSYSTEM S_LLITE @@ -74,7 +70,6 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr, size_t count) { struct vm_area_struct *vma, *ret = NULL; - ENTRY; /* mmap_sem must have been held by caller. */ LASSERT(!down_write_trylock(&mm->mmap_sem)); @@ -87,7 +82,7 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr, break; } } - RETURN(ret); + return ret; } /** @@ -107,16 +102,16 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma, struct cl_env_nest *nest, pgoff_t index, unsigned long *ra_flags) { - struct file *file = vma->vm_file; - struct inode *inode = file->f_dentry->d_inode; - struct cl_io *io; - struct cl_fault_io *fio; - struct lu_env *env; - ENTRY; + struct file *file = vma->vm_file; + struct inode *inode = file->f_dentry->d_inode; + struct cl_io *io; + struct cl_fault_io *fio; + struct lu_env *env; + int rc; *env_ret = NULL; if (ll_file_nolock(file)) - RETURN(ERR_PTR(-EOPNOTSUPP)); + return ERR_PTR(-EOPNOTSUPP); /* * page fault can be called when lustre IO is @@ -127,7 +122,7 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma, */ env = cl_env_nested_get(nest); if (IS_ERR(env)) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); *env_ret = env; @@ -152,17 +147,22 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma, CDEBUG(D_MMAP, "vm_flags: %lx (%lu %d)\n", vma->vm_flags, fio->ft_index, fio->ft_executable); - if (cl_io_init(env, io, CIT_FAULT, io->ci_obj) == 0) { + rc = cl_io_init(env, io, CIT_FAULT, io->ci_obj); + if (rc == 0) { struct ccc_io *cio = ccc_env_io(env); struct ll_file_data *fd = LUSTRE_FPRIVATE(file); LASSERT(cio->cui_cl.cis_io == io); - /* mmap lock must be MANDATORY - * it has to cache pages. */ + /* mmap lock must be MANDATORY it has to cache + * pages. */ io->ci_lockreq = CILR_MANDATORY; - - cio->cui_fd = fd; + cio->cui_fd = fd; + } else { + LASSERT(rc < 0); + cl_io_fini(env, io); + cl_env_nested_put(nest, env); + io = ERR_PTR(rc); } return io; @@ -180,7 +180,6 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, sigset_t set; struct inode *inode; struct ll_inode_info *lli; - ENTRY; LASSERT(vmpage != NULL); @@ -190,7 +189,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, result = io->ci_result; if (result < 0) - GOTO(out, result); + GOTO(out_io, result); io->u.ci_fault.ft_mkwrite = 1; io->u.ci_fault.ft_writable = 1; @@ -250,16 +249,15 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, spin_unlock(&lli->lli_lock); } } - EXIT; -out: +out_io: cl_io_fini(env, io); cl_env_nested_put(&nest, env); - +out: CDEBUG(D_MMAP, "%s mkwrite with %d\n", current->comm, result); - LASSERT(ergo(result == 0, PageLocked(vmpage))); - return(result); + + return result; } @@ -304,11 +302,10 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) struct cl_env_nest nest; int result; int fault_ret = 0; - ENTRY; io = ll_fault_io_init(vma, &env, &nest, vmf->pgoff, &ra_flags); if (IS_ERR(io)) - RETURN(to_fault_error(PTR_ERR(io))); + return to_fault_error(PTR_ERR(io)); result = io->ci_result; if (result == 0) { @@ -335,7 +332,7 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) CDEBUG(D_MMAP, "%s fault %d/%d\n", current->comm, fault_ret, result); - RETURN(fault_ret); + return fault_ret; } static int ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf) @@ -431,11 +428,9 @@ static void ll_vm_open(struct vm_area_struct * vma) struct inode *inode = vma->vm_file->f_dentry->d_inode; struct ccc_object *vob = cl_inode2ccc(inode); - ENTRY; LASSERT(vma->vm_file); LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0); atomic_inc(&vob->cob_mmap_cnt); - EXIT; } /** @@ -446,11 +441,9 @@ static void ll_vm_close(struct vm_area_struct *vma) struct inode *inode = vma->vm_file->f_dentry->d_inode; struct ccc_object *vob = cl_inode2ccc(inode); - ENTRY; LASSERT(vma->vm_file); atomic_dec(&vob->cob_mmap_cnt); LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0); - EXIT; } @@ -466,7 +459,6 @@ static inline unsigned long file_to_user(struct vm_area_struct *vma, __u64 byte) int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last) { int rc = -ENOENT; - ENTRY; LASSERTF(last > first, "last "LPU64" first "LPU64"\n", last, first); if (mapping_mapped(mapping)) { @@ -475,7 +467,7 @@ int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last) last - first + 1, 0); } - RETURN(rc); + return rc; } static struct vm_operations_struct ll_file_vm_ops = { @@ -489,10 +481,9 @@ int ll_file_mmap(struct file *file, struct vm_area_struct * vma) { struct inode *inode = file->f_dentry->d_inode; int rc; - ENTRY; if (ll_file_nolock(file)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_MAP, 1); rc = generic_file_mmap(file, vma); @@ -503,5 +494,5 @@ int ll_file_mmap(struct file *file, struct vm_area_struct * vma) rc = ll_glimpse_size(inode); } - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index 28cc41e9058..1767c741fb7 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -58,6 +58,22 @@ __u32 get_uuid2int(const char *name, int len) return (key0 << 1); } +void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid) +{ + __u64 key = 0, key0 = 0x12a3fe2d, key1 = 0x37abe8f9; + + while (len--) { + key = key1 + (key0 ^ (*name++ * 7152373)); + if (key & 0x8000000000000000ULL) + key -= 0x7fffffffffffffffULL; + key1 = key0; + key0 = key; + } + + fsid->val[0] = key; + fsid->val[1] = key >> 32; +} + static int ll_nfs_test_inode(struct inode *inode, void *opaque) { return lu_fid_eq(&ll_i2info(inode)->lli_fid, @@ -75,17 +91,16 @@ struct inode *search_inode_for_lustre(struct super_block *sb, ll_need_32bit_api(sbi)); struct md_op_data *op_data; int rc; - ENTRY; CDEBUG(D_INFO, "searching inode for:(%lu,"DFID")\n", hash, PFID(fid)); inode = ilookup5(sb, hash, ll_nfs_test_inode, (void *)fid); if (inode) - RETURN(inode); + return inode; rc = ll_get_max_mdsize(sbi, &eadatalen); if (rc) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); /* Because inode is NULL, ll_prep_md_op_data can not * be used here. So we allocate op_data ourselves */ @@ -103,14 +118,14 @@ struct inode *search_inode_for_lustre(struct super_block *sb, if (rc) { CERROR("can't get object attrs, fid "DFID", rc %d\n", PFID(fid), rc); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } rc = ll_prep_inode(&inode, req, sb, NULL); ptlrpc_req_finished(req); if (rc) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); - RETURN(inode); + return inode; } struct lustre_nfs_fid { @@ -123,20 +138,19 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren { struct inode *inode; struct dentry *result; - ENTRY; CDEBUG(D_INFO, "Get dentry for fid: "DFID"\n", PFID(fid)); if (!fid_is_sane(fid)) - RETURN(ERR_PTR(-ESTALE)); + return ERR_PTR(-ESTALE); inode = search_inode_for_lustre(sb, fid); if (IS_ERR(inode)) - RETURN(ERR_PTR(PTR_ERR(inode))); + return ERR_CAST(inode); if (is_bad_inode(inode)) { /* we didn't find the right inode.. */ iput(inode); - RETURN(ERR_PTR(-ESTALE)); + return ERR_PTR(-ESTALE); } /** @@ -154,11 +168,11 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren result = d_obtain_alias(inode); if (IS_ERR(result)) - RETURN(result); + return result; ll_dops_init(result, 1, 0); - RETURN(result); + return result; } #define LUSTRE_NFS_FID 0x97 @@ -176,20 +190,19 @@ static int ll_encode_fh(struct inode *inode, __u32 *fh, int *plen, struct inode *parent) { struct lustre_nfs_fid *nfs_fid = (void *)fh; - ENTRY; CDEBUG(D_INFO, "encoding for (%lu,"DFID") maxlen=%d minlen=%d\n", inode->i_ino, PFID(ll_inode2fid(inode)), *plen, (int)sizeof(struct lustre_nfs_fid)); if (*plen < sizeof(struct lustre_nfs_fid) / 4) - RETURN(255); + return 255; nfs_fid->lnf_child = *ll_inode2fid(inode); nfs_fid->lnf_parent = *ll_inode2fid(parent); *plen = sizeof(struct lustre_nfs_fid) / 4; - RETURN(LUSTRE_NFS_FID); + return LUSTRE_NFS_FID; } static int ll_nfs_get_name_filldir(void *cookie, const char *name, int namelen, @@ -214,10 +227,12 @@ static int ll_get_name(struct dentry *dentry, char *name, struct dentry *child) { struct inode *dir = dentry->d_inode; - struct ll_getname_data lgd; - __u64 offset = 0; int rc; - ENTRY; + struct ll_getname_data lgd = { + .lgd_name = name, + .lgd_fid = ll_i2info(child->d_inode)->lli_fid, + .ctx.actor = ll_nfs_get_name_filldir, + }; if (!dir || !S_ISDIR(dir->i_mode)) GOTO(out, rc = -ENOTDIR); @@ -225,17 +240,11 @@ static int ll_get_name(struct dentry *dentry, char *name, if (!dir->i_fop) GOTO(out, rc = -EINVAL); - lgd.lgd_name = name; - lgd.lgd_fid = ll_i2info(child->d_inode)->lli_fid; - lgd.lgd_found = 0; - mutex_lock(&dir->i_mutex); - rc = ll_dir_read(dir, &offset, &lgd, ll_nfs_get_name_filldir); + rc = ll_dir_read(dir, &lgd.ctx); mutex_unlock(&dir->i_mutex); if (!rc && !lgd.lgd_found) rc = -ENOENT; - EXIT; - out: return rc; } @@ -246,9 +255,9 @@ static struct dentry *ll_fh_to_dentry(struct super_block *sb, struct fid *fid, struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid; if (fh_type != LUSTRE_NFS_FID) - RETURN(ERR_PTR(-EPROTO)); + return ERR_PTR(-EPROTO); - RETURN(ll_iget_for_nfs(sb, &nfs_fid->lnf_child, &nfs_fid->lnf_parent)); + return ll_iget_for_nfs(sb, &nfs_fid->lnf_child, &nfs_fid->lnf_parent); } static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid, @@ -257,9 +266,9 @@ static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid, struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid; if (fh_type != LUSTRE_NFS_FID) - RETURN(ERR_PTR(-EPROTO)); + return ERR_PTR(-EPROTO); - RETURN(ll_iget_for_nfs(sb, &nfs_fid->lnf_parent, NULL)); + return ll_iget_for_nfs(sb, &nfs_fid->lnf_parent, NULL); } static struct dentry *ll_get_parent(struct dentry *dchild) @@ -273,7 +282,6 @@ static struct dentry *ll_get_parent(struct dentry *dchild) struct md_op_data *op_data; int rc; int lmmsize; - ENTRY; LASSERT(dir && S_ISDIR(dir->i_mode)); @@ -284,19 +292,19 @@ static struct dentry *ll_get_parent(struct dentry *dchild) rc = ll_get_max_mdsize(sbi, &lmmsize); if (rc != 0) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); op_data = ll_prep_md_op_data(NULL, dir, NULL, dotdot, strlen(dotdot), lmmsize, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN((void *)op_data); + return (void *)op_data; rc = md_getattr_name(sbi->ll_md_exp, op_data, &req); ll_finish_md_op_data(op_data); if (rc) { CERROR("failure %d inode %lu get parent\n", rc, dir->i_ino); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); LASSERT(body->valid & OBD_MD_FLID); @@ -307,7 +315,7 @@ static struct dentry *ll_get_parent(struct dentry *dchild) result = ll_iget_for_nfs(dir->i_sb, &body->fid1, NULL); ptlrpc_req_finished(req); - RETURN(result); + return result; } struct export_operations lustre_export_operations = { diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 9d4c17ea880..2340458b8a0 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -99,7 +99,6 @@ #include <linux/completion.h> #include <linux/highmem.h> #include <linux/gfp.h> -#include <linux/swap.h> #include <linux/pagevec.h> #include <asm/uaccess.h> @@ -574,7 +573,7 @@ static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev, lo->lo_offset = 0; lo->lo_sizelimit = 0; lo->lo_flags = 0; - ll_invalidate_bdev(bdev, 0); + invalidate_bdev(bdev); set_capacity(disks[lo->lo_number], 0); bd_set_size(bdev, 0); mapping_set_gfp_mask(filp->f_mapping, gfp); @@ -618,7 +617,7 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, case LL_IOC_LLOOP_DETACH: { err = loop_clr_fd(lo, bdev, 2); if (err == 0) - ll_blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ + blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ break; } @@ -713,7 +712,7 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file, err = loop_set_fd(lo, NULL, bdev, file); if (err) { fput(file); - ll_blkdev_put(bdev, 0); + blkdev_put(bdev, 0); } break; @@ -737,7 +736,7 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file, bdev = lo->lo_device; err = loop_clr_fd(lo, bdev, 1); if (err == 0) - ll_blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ + blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ break; } @@ -849,10 +848,8 @@ static void lloop_exit(void) blk_cleanup_queue(loop_dev[i].lo_queue); put_disk(disks[i]); } - if (ll_unregister_blkdev(lloop_major, "lloop")) - CWARN("lloop: cannot unregister blkdev\n"); - else - CDEBUG(D_CONFIG, "unregistered lloop major %d\n", lloop_major); + + unregister_blkdev(lloop_major, "lloop"); OBD_FREE(disks, max_loop * sizeof(*disks)); OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev)); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 6a82505c793..d4d3c17547c 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_LLITE -#include <linux/version.h> #include <lustre_lite.h> #include <lprocfs_status.h> #include <linux/seq_file.h> @@ -243,9 +242,9 @@ static ssize_t ll_max_readahead_mb_seq_write(struct file *file, const char *buff if (rc) return rc; - if (pages_number < 0 || pages_number > num_physpages / 2) { + if (pages_number < 0 || pages_number > totalram_pages / 2) { CERROR("can't set file readahead more than %lu MB\n", - num_physpages >> (20 - PAGE_CACHE_SHIFT + 1)); /*1/2 of RAM*/ + totalram_pages >> (20 - PAGE_CACHE_SHIFT + 1)); /*1/2 of RAM*/ return -ERANGE; } @@ -380,23 +379,22 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, const char *buffer, int mult, rc, pages_number; int diff = 0; int nrpages = 0; - ENTRY; mult = 1 << (20 - PAGE_CACHE_SHIFT); buffer = lprocfs_find_named_value(buffer, "max_cached_mb:", &count); rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); if (rc) - RETURN(rc); + return rc; - if (pages_number < 0 || pages_number > num_physpages) { + if (pages_number < 0 || pages_number > totalram_pages) { CERROR("%s: can't set max cache more than %lu MB\n", ll_get_fsname(sb, NULL, 0), - num_physpages >> (20 - PAGE_CACHE_SHIFT)); - RETURN(-ERANGE); + totalram_pages >> (20 - PAGE_CACHE_SHIFT)); + return -ERANGE; } if (sbi->ll_dt_exp == NULL) - RETURN(-ENODEV); + return -ENODEV; spin_lock(&sbi->ll_lock); diff = pages_number - cache->ccc_lru_max; @@ -421,7 +419,7 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, const char *buffer, break; nv = ov > diff ? ov - diff : 0; - rc = cfs_atomic_cmpxchg(&cache->ccc_lru_left, ov, nv); + rc = atomic_cmpxchg(&cache->ccc_lru_left, ov, nv); if (likely(ov == rc)) { diff -= ov - nv; nrpages += ov - nv; @@ -822,7 +820,8 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) sbi->ll_stats_track_id == current->parent->pid) lprocfs_counter_add(sbi->ll_stats, op, count); else if (sbi->ll_stats_track_type == STATS_TRACK_GID && - sbi->ll_stats_track_id == current_gid()) + sbi->ll_stats_track_id == + from_kgid(&init_user_ns, current_gid())) lprocfs_counter_add(sbi->ll_stats, op, count); } EXPORT_SYMBOL(ll_stats_ops_tally); @@ -852,10 +851,9 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; - proc_dir_entry_t *dir; + struct proc_dir_entry *dir; char name[MAX_STRING_SIZE + 1], *ptr; int err, id, len, rc; - ENTRY; memset(lvars, 0, sizeof(lvars)); @@ -880,7 +878,7 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, if (IS_ERR(sbi->ll_proc_root)) { err = PTR_ERR(sbi->ll_proc_root); sbi->ll_proc_root = NULL; - RETURN(err); + return err; } rc = lprocfs_seq_create(sbi->ll_proc_root, "dump_page_cache", 0444, @@ -994,7 +992,7 @@ out: lprocfs_free_stats(&sbi->ll_ra_stats); lprocfs_free_stats(&sbi->ll_stats); } - RETURN(err); + return err; } void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) @@ -1302,8 +1300,9 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) /* We stored the discontiguous offsets here; print them first */ for(i = 0; i < LL_OFFSET_HIST_MAX; i++) { if (offset[i].rw_pid != 0) - seq_printf(seq,"%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", - offset[i].rw_op ? 'W' : 'R', + seq_printf(seq, + "%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", + offset[i].rw_op == READ ? 'R' : 'W', offset[i].rw_pid, offset[i].rw_range_start, offset[i].rw_range_end, @@ -1314,8 +1313,9 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) /* Then print the current offsets for each process */ for(i = 0; i < LL_PROCESS_HIST_MAX; i++) { if (process[i].rw_pid != 0) - seq_printf(seq,"%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", - process[i].rw_op ? 'W' : 'R', + seq_printf(seq, + "%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", + process[i].rw_op == READ ? 'R' : 'W', process[i].rw_pid, process[i].rw_range_start, process[i].rw_last_file_pos, diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index ff8f63de561..34815b550e7 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -77,11 +77,9 @@ static int ll_d_mountpoint(struct dentry *dparent, struct dentry *dchild, int ll_unlock(__u32 mode, struct lustre_handle *lockh) { - ENTRY; - ldlm_lock_decref(lockh, mode); - RETURN(0); + return 0; } @@ -139,7 +137,6 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash, struct lustre_md *md) { struct inode *inode; - ENTRY; LASSERT(hash != 0); inode = iget5_locked(sb, hash, ll_test_inode, ll_set_inode, md); @@ -169,7 +166,7 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash, CDEBUG(D_VFSTRACE, "got inode: %p for "DFID"\n", inode, PFID(&md->body->fid1)); } - RETURN(inode); + return inode; } static void ll_invalidate_negative_children(struct inode *dir) @@ -200,7 +197,6 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, { int rc; struct lustre_handle lockh; - ENTRY; switch (flag) { case LDLM_CB_BLOCKING: @@ -208,7 +204,7 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, rc = ldlm_cli_cancel(&lockh, LCF_ASYNC); if (rc < 0) { CDEBUG(D_INODE, "ldlm_cli_cancel: %d\n", rc); - RETURN(rc); + return rc; } break; case LDLM_CB_CANCELING: { @@ -275,8 +271,11 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, CDEBUG(D_INODE, "invaliding layout %d.\n", rc); } - if (bits & MDS_INODELOCK_UPDATE) + if (bits & MDS_INODELOCK_UPDATE) { + spin_lock(&lli->lli_lock); lli->lli_flags &= ~LLIF_MDS_SIZE_LOCK; + spin_unlock(&lli->lli_lock); + } if (S_ISDIR(inode->i_mode) && (bits & MDS_INODELOCK_UPDATE)) { @@ -297,13 +296,13 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, LBUG(); } - RETURN(0); + return 0; } __u32 ll_i2suppgid(struct inode *i) { - if (current_is_in_group(i->i_gid)) - return (__u32)i->i_gid; + if (in_group_p(i->i_gid)) + return (__u32)from_kgid(&init_user_ns, i->i_gid); else return (__u32)(-1); } @@ -430,7 +429,6 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, struct inode *inode = NULL; __u64 bits = 0; int rc; - ENTRY; /* NB 1 request reference will be taken away by ll_intent_lock() * when I return */ @@ -439,7 +437,7 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, if (!it_disposition(it, DISP_LOOKUP_NEG)) { rc = ll_prep_inode(&inode, request, (*de)->d_sb, it); if (rc) - RETURN(rc); + return rc; ll_set_lock_data(ll_i2sbi(parent)->ll_md_exp, inode, it, &bits); @@ -480,7 +478,7 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, } } - RETURN(0); + return 0; } static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, @@ -493,10 +491,9 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, struct it_cb_data icbd; __u32 opc; int rc; - ENTRY; if (dentry->d_name.len > ll_i2sbi(parent)->ll_namelen) - RETURN(ERR_PTR(-ENAMETOOLONG)); + return ERR_PTR(-ENAMETOOLONG); CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),intent=%s\n", dentry->d_name.len, dentry->d_name.name, parent->i_ino, @@ -514,7 +511,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, rc = ll_inode_revalidate_it(parent->i_sb->s_root, it, MDS_INODELOCK_LOOKUP); if (rc) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } if (it->it_op == IT_GETATTR) { @@ -539,7 +536,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, dentry->d_name.len, lookup_flags, opc, NULL); if (IS_ERR(op_data)) - RETURN((void *)op_data); + return (void *)op_data; /* enforce umask if acl disabled or MDS doesn't support umask */ if (!IS_POSIXACL(parent) || !exp_connect_umask(ll_i2mdexp(parent))) @@ -618,7 +615,6 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, struct dentry *de; long long lookup_flags = LOOKUP_OPEN; int rc = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),file %p," "open_flags %x,mode %x opened %d\n", @@ -627,7 +623,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, OBD_ALLOC(it, sizeof(*it)); if (!it) - RETURN(-ENOMEM); + return -ENOMEM; it->it_op = IT_OPEN; if (mode) { @@ -686,7 +682,7 @@ out_release: ll_intent_release(it); OBD_FREE(it, sizeof(*it)); - RETURN(rc); + return rc; } @@ -700,7 +696,6 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, struct ptlrpc_request *request = NULL; struct ll_sb_info *sbi = ll_i2sbi(dir); int rc; - ENTRY; LASSERT(it && it->d.lustre.it_disposition); @@ -719,7 +714,6 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, CDEBUG(D_DLMTRACE, "setting l_ast_data to inode %p (%lu/%u)\n", inode, inode->i_ino, inode->i_generation); ll_set_lock_data(sbi->ll_md_exp, inode, it, NULL); - EXIT; out: ptlrpc_req_finished(request); return inode; @@ -744,7 +738,6 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode, { struct inode *inode; int rc = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),intent=%s\n", dentry->d_name.len, dentry->d_name.name, dir->i_ino, @@ -752,18 +745,18 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode, rc = it_open_error(DISP_OPEN_CREATE, it); if (rc) - RETURN(rc); + return rc; inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len, NULL, 0, mode, 0, it); if (IS_ERR(inode)) - RETURN(PTR_ERR(inode)); + return PTR_ERR(inode); if (filename_is_volatile(dentry->d_name.name, dentry->d_name.len, NULL)) ll_i2info(inode)->lli_volatile = true; d_instantiate(dentry, inode); - RETURN(0); + return 0; } static void ll_update_times(struct ptlrpc_request *request, @@ -795,7 +788,6 @@ static int ll_new_node(struct inode *dir, struct qstr *name, int tgt_len = 0; int err; - ENTRY; if (unlikely(tgt != NULL)) tgt_len = strlen(tgt) + 1; @@ -805,7 +797,8 @@ static int ll_new_node(struct inode *dir, struct qstr *name, GOTO(err_exit, err = PTR_ERR(op_data)); err = md_create(sbi->ll_md_exp, op_data, tgt, tgt_len, mode, - current_fsuid(), current_fsgid(), + from_kuid(&init_user_ns, current_fsuid()), + from_kgid(&init_user_ns, current_fsgid()), cfs_curproc_cap_pack(), rdev, &request); ll_finish_md_op_data(op_data); if (err) @@ -820,7 +813,6 @@ static int ll_new_node(struct inode *dir, struct qstr *name, d_instantiate(dchild, inode); } - EXIT; err_exit: ptlrpc_req_finished(request); @@ -831,7 +823,6 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode, unsigned rdev, struct dentry *dchild) { int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p) mode %o dev %x\n", name->len, name->name, dir->i_ino, dir->i_generation, dir, @@ -861,7 +852,7 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode, if (!err) ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_MKNOD, 1); - RETURN(err); + return err; } /* @@ -891,7 +882,6 @@ static int ll_symlink_generic(struct inode *dir, struct qstr *name, const char *tgt, struct dentry *dchild) { int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),target=%.*s\n", name->len, name->name, dir->i_ino, dir->i_generation, @@ -903,7 +893,7 @@ static int ll_symlink_generic(struct inode *dir, struct qstr *name, if (!err) ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_SYMLINK, 1); - RETURN(err); + return err; } static int ll_link_generic(struct inode *src, struct inode *dir, @@ -914,7 +904,6 @@ static int ll_link_generic(struct inode *src, struct inode *dir, struct md_op_data *op_data; int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op: inode=%lu/%u(%p), dir=%lu/%u(%p), target=%.*s\n", src->i_ino, src->i_generation, src, dir->i_ino, @@ -923,7 +912,7 @@ static int ll_link_generic(struct inode *src, struct inode *dir, op_data = ll_prep_md_op_data(NULL, src, dir, name->name, name->len, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); err = md_link(sbi->ll_md_exp, op_data, &request); ll_finish_md_op_data(op_data); @@ -932,10 +921,9 @@ static int ll_link_generic(struct inode *src, struct inode *dir, ll_update_times(request, dir); ll_stats_ops_tally(sbi, LPROC_LL_LINK, 1); - EXIT; out: ptlrpc_req_finished(request); - RETURN(err); + return err; } static int ll_mkdir_generic(struct inode *dir, struct qstr *name, @@ -943,7 +931,6 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, { int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", name->len, name->name, dir->i_ino, dir->i_generation, dir); @@ -956,7 +943,7 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, if (!err) ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_MKDIR, 1); - RETURN(err); + return err; } /* Try to find the child dentry by its name. @@ -981,18 +968,17 @@ static int ll_rmdir_generic(struct inode *dir, struct dentry *dparent, struct ptlrpc_request *request = NULL; struct md_op_data *op_data; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", name->len, name->name, dir->i_ino, dir->i_generation, dir); if (unlikely(ll_d_mountpoint(dparent, dchild, name))) - RETURN(-EBUSY); + return -EBUSY; op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, S_IFDIR, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); ll_get_child_fid(dir, name, &op_data->op_fid3); op_data->op_fid2 = op_data->op_fid3; @@ -1004,7 +990,7 @@ static int ll_rmdir_generic(struct inode *dir, struct dentry *dparent, } ptlrpc_req_finished(request); - RETURN(rc); + return rc; } /** @@ -1015,7 +1001,6 @@ int ll_rmdir_entry(struct inode *dir, char *name, int namelen) struct ptlrpc_request *request = NULL; struct md_op_data *op_data; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", namelen, name, dir->i_ino, dir->i_generation, dir); @@ -1023,7 +1008,7 @@ int ll_rmdir_entry(struct inode *dir, char *name, int namelen) op_data = ll_prep_md_op_data(NULL, dir, NULL, name, strlen(name), S_IFDIR, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_cli_flags |= CLI_RM_ENTRY; rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request); ll_finish_md_op_data(op_data); @@ -1033,7 +1018,7 @@ int ll_rmdir_entry(struct inode *dir, char *name, int namelen) } ptlrpc_req_finished(request); - RETURN(rc); + return rc; } int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) @@ -1045,12 +1030,11 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) struct obdo *oa; struct obd_capa *oc = NULL; int rc; - ENTRY; /* req is swabbed so this is safe */ body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); if (!(body->valid & OBD_MD_FLEASIZE)) - RETURN(0); + return 0; if (body->eadatasize == 0) { CERROR("OBD_MD_FLEASIZE set but eadatasize zero\n"); @@ -1122,7 +1106,6 @@ static int ll_unlink_generic(struct inode *dir, struct dentry *dparent, struct ptlrpc_request *request = NULL; struct md_op_data *op_data; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", name->len, name->name, dir->i_ino, dir->i_generation, dir); @@ -1131,12 +1114,12 @@ static int ll_unlink_generic(struct inode *dir, struct dentry *dparent, * just check it as vfs_unlink does. */ if (unlikely(ll_d_mountpoint(dparent, dchild, name))) - RETURN(-EBUSY); + return -EBUSY; op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); ll_get_child_fid(dir, name, &op_data->op_fid3); op_data->op_fid2 = op_data->op_fid3; @@ -1151,7 +1134,7 @@ static int ll_unlink_generic(struct inode *dir, struct dentry *dparent, rc = ll_objects_destroy(request, dir); out: ptlrpc_req_finished(request); - RETURN(rc); + return rc; } static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, @@ -1163,7 +1146,7 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, struct ll_sb_info *sbi = ll_i2sbi(src); struct md_op_data *op_data; int err; - ENTRY; + CDEBUG(D_VFSTRACE,"VFS Op:oldname=%.*s,src_dir=%lu/%u(%p),newname=%.*s," "tgt_dir=%lu/%u(%p)\n", src_name->len, src_name->name, src->i_ino, src->i_generation, src, tgt_name->len, @@ -1171,12 +1154,12 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, if (unlikely(ll_d_mountpoint(src_dparent, src_dchild, src_name) || ll_d_mountpoint(tgt_dparent, tgt_dchild, tgt_name))) - RETURN(-EBUSY); + return -EBUSY; op_data = ll_prep_md_op_data(NULL, src, tgt, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); ll_get_child_fid(src, src_name, &op_data->op_fid3); ll_get_child_fid(tgt, tgt_name, &op_data->op_fid4); @@ -1193,7 +1176,7 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, ptlrpc_req_finished(request); - RETURN(err); + return err; } static int ll_mknod(struct inode *dir, struct dentry *dchild, ll_umode_t mode, diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c index 68b2dc4a7b6..dedd56ae1e6 100644 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ b/drivers/staging/lustre/lustre/llite/remote_perm.c @@ -45,7 +45,6 @@ #include <linux/module.h> #include <linux/types.h> -#include <linux/version.h> #include <lustre_lite.h> #include <lustre_ha.h> @@ -124,22 +123,22 @@ static int do_check_remote_perm(struct ll_inode_info *lli, int mask) struct hlist_head *head; struct ll_remote_perm *lrp; int found = 0, rc; - ENTRY; if (!lli->lli_remote_perms) - RETURN(-ENOENT); + return -ENOENT; - head = lli->lli_remote_perms + remote_perm_hashfunc(current_uid()); + head = lli->lli_remote_perms + + remote_perm_hashfunc(from_kuid(&init_user_ns, current_uid())); spin_lock(&lli->lli_lock); hlist_for_each_entry(lrp, head, lrp_list) { - if (lrp->lrp_uid != current_uid()) + if (lrp->lrp_uid != from_kuid(&init_user_ns, current_uid())) continue; - if (lrp->lrp_gid != current_gid()) + if (lrp->lrp_gid != from_kgid(&init_user_ns, current_gid())) continue; - if (lrp->lrp_fsuid != current_fsuid()) + if (lrp->lrp_fsuid != from_kuid(&init_user_ns, current_fsuid())) continue; - if (lrp->lrp_fsgid != current_fsgid()) + if (lrp->lrp_fsgid != from_kgid(&init_user_ns, current_fsgid())) continue; found = 1; break; @@ -163,7 +162,6 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) struct ll_inode_info *lli = ll_i2info(inode); struct ll_remote_perm *lrp = NULL, *tmp = NULL; struct hlist_head *head, *perm_hash = NULL; - ENTRY; LASSERT(ll_i2sbi(inode)->ll_flags & LL_SBI_RMT_CLIENT); @@ -178,7 +176,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) perm->rp_uid, perm->rp_gid, perm->rp_fsuid, perm->rp_fsgid, current->uid, current->gid, current->fsuid, current->fsgid); - RETURN(-EAGAIN); + return -EAGAIN; } #endif @@ -186,7 +184,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) perm_hash = alloc_rmtperm_hash(); if (perm_hash == NULL) { CERROR("alloc lli_remote_perms failed!\n"); - RETURN(-ENOMEM); + return -ENOMEM; } } @@ -220,7 +218,7 @@ again: lrp = alloc_ll_remote_perm(); if (!lrp) { CERROR("alloc memory for ll_remote_perm failed!\n"); - RETURN(-ENOMEM); + return -ENOMEM; } spin_lock(&lli->lli_lock); goto again; @@ -241,7 +239,7 @@ again: lrp, lrp->lrp_uid, lrp->lrp_gid, lrp->lrp_fsuid, lrp->lrp_fsgid, lrp->lrp_access_perm); - RETURN(0); + return 0; } int lustre_check_remote_perm(struct inode *inode, int mask) @@ -253,7 +251,6 @@ int lustre_check_remote_perm(struct inode *inode, int mask) struct obd_capa *oc; cfs_time_t save; int i = 0, rc; - ENTRY; do { save = lli->lli_rmtperm_time; @@ -304,7 +301,7 @@ int lustre_check_remote_perm(struct inode *inode, int mask) req = NULL; } while (1); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } #if 0 /* NB: remote perms can't be freed in ll_mdc_blocking_ast of UPDATE lock, diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index fac11788901..ae0dc441d1d 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -48,9 +48,6 @@ #include <asm/uaccess.h> #include <linux/fs.h> -#include <linux/stat.h> -#include <asm/uaccess.h> -#include <linux/mm.h> #include <linux/pagemap.h> /* current_is_kswapd() */ #include <linux/swap.h> @@ -110,7 +107,7 @@ static struct ll_cl_context *ll_cl_init(struct file *file, env = cl_env_get(&refcheck); if (IS_ERR(env)) - return ERR_PTR(PTR_ERR(env)); + return ERR_CAST(env); lcc = &vvp_env_info(env)->vti_io_ctx; memset(lcc, 0, sizeof(*lcc)); @@ -132,7 +129,7 @@ static struct ll_cl_context *ll_cl_init(struct file *file, * add dirty pages into cache during truncate */ CERROR("Proc %s is dirting page w/o inode lock, this" "will break truncate.\n", current->comm); - libcfs_debug_dumpstack(NULL); + dump_stack(); LBUG(); return ERR_PTR(-EIO); } @@ -228,7 +225,6 @@ int ll_prepare_write(struct file *file, struct page *vmpage, unsigned from, { struct ll_cl_context *lcc; int result; - ENTRY; lcc = ll_cl_init(file, vmpage, 1); if (!IS_ERR(lcc)) { @@ -256,7 +252,7 @@ int ll_prepare_write(struct file *file, struct page *vmpage, unsigned from, } else { result = PTR_ERR(lcc); } - RETURN(result); + return result; } int ll_commit_write(struct file *file, struct page *vmpage, unsigned from, @@ -267,7 +263,6 @@ int ll_commit_write(struct file *file, struct page *vmpage, unsigned from, struct cl_io *io; struct cl_page *page; int result = 0; - ENTRY; lcc = ll_cl_get(); env = lcc->lcc_env; @@ -287,7 +282,7 @@ int ll_commit_write(struct file *file, struct page *vmpage, unsigned from, lu_ref_del(&page->cp_reference, "prepare_write", current); cl_page_put(env, page); ll_cl_fini(lcc); - RETURN(result); + return result; } struct obd_capa *cl_capa_lookup(struct inode *inode, enum cl_req_type crt) @@ -325,7 +320,6 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, { struct ll_ra_info *ra = &sbi->ll_ra_info; long ret; - ENTRY; /* If read-ahead pages left are less than 1M, do not do read-ahead, * otherwise it will form small read RPC(< 1M), which hurt server @@ -357,7 +351,7 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, } out: - RETURN(ret); + return ret; } void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len) @@ -468,8 +462,6 @@ static int cl_read_ahead_page(const struct lu_env *env, struct cl_io *io, struct ccc_page *cp; int rc; - ENTRY; - rc = 0; cl_page_assume(env, io, page); lu_ref_add(&page->cp_reference, "ra", current); @@ -491,7 +483,7 @@ static int cl_read_ahead_page(const struct lu_env *env, struct cl_io *io, } lu_ref_del(&page->cp_reference, "ra", current); cl_page_put(env, page); - RETURN(rc); + return rc; } /** @@ -516,8 +508,6 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, int rc = 0; const char *msg = NULL; - ENTRY; - gfp_mask = GFP_HIGHUSER & ~__GFP_WAIT; #ifdef __GFP_NOWARN gfp_mask |= __GFP_NOWARN; @@ -554,7 +544,7 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, ll_ra_stats_inc(mapping, which); CDEBUG(D_READA, "%s\n", msg); } - RETURN(rc); + return rc; } #define RIA_DEBUG(ria) \ @@ -722,7 +712,6 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, struct cl_object *clob; int ret = 0; __u64 kms; - ENTRY; inode = mapping->host; lli = ll_i2info(inode); @@ -735,11 +724,11 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, cl_object_attr_unlock(clob); if (ret != 0) - RETURN(ret); + return ret; kms = attr->cat_kms; if (kms == 0) { ll_ra_stats_inc(mapping, RA_STAT_ZERO_LEN); - RETURN(0); + return 0; } spin_lock(&ras->ras_lock); @@ -797,11 +786,11 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, if (end == 0) { ll_ra_stats_inc(mapping, RA_STAT_ZERO_WINDOW); - RETURN(0); + return 0; } len = ria_page_count(ria); if (len == 0) - RETURN(0); + return 0; reserved = ll_ra_count_get(ll_i2sbi(inode), ria, len); if (reserved < len) @@ -840,7 +829,7 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, spin_unlock(&ras->ras_lock); } - RETURN(ret); + return ret; } static void ras_set_start(struct inode *inode, struct ll_readahead_state *ras, @@ -999,7 +988,6 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, { struct ll_ra_info *ra = &sbi->ll_ra_info; int zero = 0, stride_detect = 0, ra_miss = 0; - ENTRY; spin_lock(&ras->ras_lock); @@ -1135,7 +1123,6 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, if ((ras->ras_consecutive_requests > 1 || stride_detect) && !ras->ras_request_index) ras_increase_window(inode, ras, ra); - EXIT; out_unlock: RAS_CDEBUG(ras); ras->ras_request_index++; @@ -1155,7 +1142,6 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) bool redirtied = false; bool unlocked = false; int result; - ENTRY; LASSERT(PageLocked(vmpage)); LASSERT(!PageWriteback(vmpage)); @@ -1247,7 +1233,6 @@ int ll_writepages(struct address_space *mapping, struct writeback_control *wbc) int range_whole = 0; int result; int ignore_layout = 0; - ENTRY; if (wbc->range_cyclic) { start = mapping->writeback_index << PAGE_CACHE_SHIFT; @@ -1281,14 +1266,13 @@ int ll_writepages(struct address_space *mapping, struct writeback_control *wbc) end = i_size_read(inode); mapping->writeback_index = (end >> PAGE_CACHE_SHIFT) + 1; } - RETURN(result); + return result; } int ll_readpage(struct file *file, struct page *vmpage) { struct ll_cl_context *lcc; int result; - ENTRY; lcc = ll_cl_init(file, vmpage, 0); if (!IS_ERR(lcc)) { @@ -1310,5 +1294,5 @@ int ll_readpage(struct file *file, struct page *vmpage) unlock_page(vmpage); result = PTR_ERR(lcc); } - RETURN(result); + return result; } diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 27e4e64bc1e..96c29ad2fc8 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -51,9 +51,6 @@ #include <linux/buffer_head.h> #include <linux/mpage.h> #include <linux/writeback.h> -#include <linux/stat.h> -#include <asm/uaccess.h> -#include <linux/mm.h> #include <linux/pagemap.h> #define DEBUG_SUBSYSTEM S_LLITE @@ -72,7 +69,8 @@ * aligned truncate). Lustre leaves partially truncated page in the cache, * relying on struct inode::i_size to limit further accesses. */ -static void ll_invalidatepage(struct page *vmpage, unsigned long offset) +static void ll_invalidatepage(struct page *vmpage, unsigned int offset, + unsigned int length) { struct inode *inode; struct lu_env *env; @@ -89,7 +87,7 @@ static void ll_invalidatepage(struct page *vmpage, unsigned long offset) * below because they are run with page locked and all our io is * happening with locked page too */ - if (offset == 0) { + if (offset == 0 && length == PAGE_CACHE_SIZE) { env = cl_env_get(&refcheck); if (!IS_ERR(env)) { inode = vmpage->mapping->host; @@ -182,7 +180,7 @@ static int ll_set_page_dirty(struct page *vmpage) */ vvp_write_pending(obj, cpg); #endif - RETURN(__set_page_dirty_nobuffers(vmpage)); + return __set_page_dirty_nobuffers(vmpage); } #define MAX_DIRECTIO_SIZE 2*1024*1024*1024UL @@ -249,7 +247,6 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, long page_size = cl_page_size(obj); bool do_io; int io_pages = 0; - ENTRY; queue = &io->ci_queue; cl_2queue_init(queue); @@ -286,11 +283,11 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, src_page = (rw == WRITE) ? pages[i] : vmpage; dst_page = (rw == WRITE) ? vmpage : pages[i]; - src = ll_kmap_atomic(src_page, KM_USER0); - dst = ll_kmap_atomic(dst_page, KM_USER1); + src = kmap_atomic(src_page); + dst = kmap_atomic(dst_page); memcpy(dst, src, min(page_size, size)); - ll_kunmap_atomic(dst, KM_USER1); - ll_kunmap_atomic(src, KM_USER0); + kunmap_atomic(dst); + kunmap_atomic(src); /* make sure page will be added to the transfer by * cl_io_submit()->...->vvp_page_prep_write(). */ @@ -335,7 +332,7 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, cl_2queue_discard(env, io, queue); cl_2queue_disown(env, io, queue); cl_2queue_fini(env, queue); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ll_direct_rw_pages); @@ -383,14 +380,13 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, unsigned long seg = 0; long size = MAX_DIO_SIZE; int refcheck; - ENTRY; if (!lli->lli_has_smd) - RETURN(-EBADF); + return -EBADF; /* FIXME: io smaller than PAGE_SIZE is broken on ia64 ??? */ if ((file_offset & ~CFS_PAGE_MASK) || (count & ~CFS_PAGE_MASK)) - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), size=%lu (max %lu), " "offset=%lld=%llx, pages %lu (max %lu)\n", @@ -402,7 +398,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, for (seg = 0; seg < nr_segs; seg++) { if (((unsigned long)iov[seg].iov_base & ~CFS_PAGE_MASK) || (iov[seg].iov_len & ~CFS_PAGE_MASK)) - RETURN(-EINVAL); + return -EINVAL; } env = cl_env_get(&refcheck); @@ -495,7 +491,7 @@ out: } cl_env_put(env, &refcheck); - RETURN(tot_bytes ? : result); + return tot_bytes ? : result; } static int ll_write_begin(struct file *file, struct address_space *mapping, @@ -506,11 +502,10 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, struct page *page; int rc; unsigned from = pos & (PAGE_CACHE_SIZE - 1); - ENTRY; page = grab_cache_page_write_begin(mapping, index, flags); if (!page) - RETURN(-ENOMEM); + return -ENOMEM; *pagep = page; @@ -519,7 +514,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, unlock_page(page); page_cache_release(page); } - RETURN(rc); + return rc; } static int ll_write_end(struct file *file, struct address_space *mapping, diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 7747f8f2079..8eaa38e91b9 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -200,12 +200,11 @@ ll_sa_entry_alloc(struct ll_statahead_info *sai, __u64 index, struct ll_sa_entry *entry; int entry_size; char *dname; - ENTRY; entry_size = sizeof(struct ll_sa_entry) + (len & ~3) + 4; OBD_ALLOC(entry, entry_size); if (unlikely(entry == NULL)) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); CDEBUG(D_READA, "alloc sa entry %.*s(%p) index "LPU64"\n", len, name, entry, index); @@ -254,7 +253,7 @@ ll_sa_entry_alloc(struct ll_statahead_info *sai, __u64 index, atomic_inc(&sai->sai_cache_count); - RETURN(entry); + return entry; } /* @@ -465,11 +464,10 @@ static struct ll_statahead_info *ll_sai_alloc(void) { struct ll_statahead_info *sai; int i; - ENTRY; OBD_ALLOC_PTR(sai); if (!sai) - RETURN(NULL); + return NULL; atomic_set(&sai->sai_refcount, 1); @@ -496,7 +494,7 @@ static struct ll_statahead_info *ll_sai_alloc(void) } atomic_set(&sai->sai_cache_count, 0); - RETURN(sai); + return sai; } static inline struct ll_statahead_info * @@ -510,7 +508,6 @@ static void ll_sai_put(struct ll_statahead_info *sai) { struct inode *inode = sai->sai_inode; struct ll_inode_info *lli = ll_i2info(inode); - ENTRY; if (atomic_dec_and_lock(&sai->sai_refcount, &lli->lli_sa_lock)) { struct ll_sa_entry *entry, *next; @@ -519,7 +516,7 @@ static void ll_sai_put(struct ll_statahead_info *sai) /* It is race case, the interpret callback just hold * a reference count */ spin_unlock(&lli->lli_sa_lock); - RETURN_EXIT; + return; } LASSERT(lli->lli_opendir_key == NULL); @@ -550,8 +547,6 @@ static void ll_sai_put(struct ll_statahead_info *sai) iput(inode); OBD_FREE_PTR(sai); } - - EXIT; } /* Do NOT forget to drop inode refcount when into sai_entries_agl. */ @@ -560,7 +555,6 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) struct ll_inode_info *lli = ll_i2info(inode); __u64 index = lli->lli_agl_index; int rc; - ENTRY; LASSERT(list_empty(&lli->lli_agl_list)); @@ -568,7 +562,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) if (is_omitted_entry(sai, index + 1)) { lli->lli_agl_index = 0; iput(inode); - RETURN_EXIT; + return; } /* Someone is in glimpse (sync or async), do nothing. */ @@ -576,7 +570,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) if (rc == 0) { lli->lli_agl_index = 0; iput(inode); - RETURN_EXIT; + return; } /* @@ -597,7 +591,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) up_write(&lli->lli_glimpse_sem); lli->lli_agl_index = 0; iput(inode); - RETURN_EXIT; + return; } CDEBUG(D_READA, "Handling (init) async glimpse: inode = " @@ -613,8 +607,6 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) PFID(&lli->lli_fid), index, rc); iput(inode); - - EXIT; } static void ll_post_statahead(struct ll_statahead_info *sai) @@ -628,12 +620,11 @@ static void ll_post_statahead(struct ll_statahead_info *sai) struct ptlrpc_request *req; struct mdt_body *body; int rc = 0; - ENTRY; spin_lock(&lli->lli_sa_lock); if (unlikely(sa_received_empty(sai))) { spin_unlock(&lli->lli_sa_lock); - RETURN_EXIT; + return; } entry = sa_first_received_entry(sai); atomic_inc(&entry->se_refcount); @@ -690,8 +681,6 @@ static void ll_post_statahead(struct ll_statahead_info *sai) if (agl_should_run(sai, child)) ll_agl_add(sai, child, entry->se_index); - EXIT; - out: /* The "ll_sa_entry_to_stated()" will drop related ldlm ibits lock * reference count by calling "ll_intent_drop_lock()" in spite of the @@ -713,7 +702,6 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, struct ll_statahead_info *sai = NULL; struct ll_sa_entry *entry; int wakeup; - ENTRY; if (it_disposition(it, DISP_LOOKUP_NEG)) rc = -ENOENT; @@ -763,8 +751,6 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, wake_up(&sai->sai_thread.t_ctl_waitq); } - EXIT; - out: if (rc != 0) { ll_intent_release(it); @@ -852,11 +838,10 @@ static int do_sa_lookup(struct inode *dir, struct ll_sa_entry *entry) struct ldlm_enqueue_info *einfo; struct obd_capa *capas[2]; int rc; - ENTRY; rc = sa_args_init(dir, NULL, entry, &minfo, &einfo, capas); if (rc) - RETURN(rc); + return rc; rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo, einfo); if (!rc) { @@ -866,7 +851,7 @@ static int do_sa_lookup(struct inode *dir, struct ll_sa_entry *entry) sa_args_fini(minfo, einfo); } - RETURN(rc); + return rc; } /** @@ -885,30 +870,29 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry, struct ldlm_enqueue_info *einfo; struct obd_capa *capas[2]; int rc; - ENTRY; if (unlikely(inode == NULL)) - RETURN(1); + return 1; if (d_mountpoint(dentry)) - RETURN(1); + return 1; if (unlikely(dentry == dentry->d_sb->s_root)) - RETURN(1); + return 1; entry->se_inode = igrab(inode); rc = md_revalidate_lock(ll_i2mdexp(dir), &it, ll_inode2fid(inode),NULL); if (rc == 1) { entry->se_handle = it.d.lustre.it_lock_handle; ll_intent_release(&it); - RETURN(1); + return 1; } rc = sa_args_init(dir, inode, entry, &minfo, &einfo, capas); if (rc) { entry->se_inode = NULL; iput(inode); - RETURN(rc); + return rc; } rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo, einfo); @@ -921,7 +905,7 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry, sa_args_fini(minfo, einfo); } - RETURN(rc); + return rc; } static void ll_statahead_one(struct dentry *parent, const char* entry_name, @@ -934,12 +918,11 @@ static void ll_statahead_one(struct dentry *parent, const char* entry_name, struct ll_sa_entry *entry; int rc; int rc1; - ENTRY; entry = ll_sa_entry_alloc(sai, sai->sai_index, entry_name, entry_name_len); if (IS_ERR(entry)) - RETURN_EXIT; + return; dentry = d_lookup(parent, &entry->se_qstr); if (!dentry) { @@ -965,8 +948,6 @@ static void ll_statahead_one(struct dentry *parent, const char* entry_name, sai->sai_index++; /* drop one refcount on entry by ll_sa_entry_alloc */ ll_sa_entry_put(sai, entry); - - EXIT; } static int ll_agl_thread(void *arg) @@ -979,7 +960,6 @@ static int ll_agl_thread(void *arg) struct ll_statahead_info *sai = ll_sai_get(plli->lli_sai); struct ptlrpc_thread *thread = &sai->sai_agl_thread; struct l_wait_info lwi = { 0 }; - ENTRY; CDEBUG(D_READA, "agl thread started: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); @@ -1029,7 +1009,7 @@ static int ll_agl_thread(void *arg) ll_sai_put(sai); CDEBUG(D_READA, "agl thread stopped: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); - RETURN(0); + return 0; } static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) @@ -1037,8 +1017,7 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) struct ptlrpc_thread *thread = &sai->sai_agl_thread; struct l_wait_info lwi = { 0 }; struct ll_inode_info *plli; - task_t *task; - ENTRY; + struct task_struct *task; CDEBUG(D_READA, "start agl thread: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); @@ -1049,13 +1028,12 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) if (IS_ERR(task)) { CERROR("can't start ll_agl thread, rc: %ld\n", PTR_ERR(task)); thread_set_flags(thread, SVC_STOPPED); - RETURN_EXIT; + return; } l_wait_event(thread->t_ctl_waitq, thread_is_running(thread) || thread_is_stopped(thread), &lwi); - EXIT; } static int ll_statahead_thread(void *arg) @@ -1074,7 +1052,6 @@ static int ll_statahead_thread(void *arg) int rc = 0; struct ll_dir_chain chain; struct l_wait_info lwi = { 0 }; - ENTRY; CDEBUG(D_READA, "statahead thread started: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); @@ -1257,7 +1234,6 @@ do_it: */ } } - EXIT; out: if (sai->sai_agl_valid) { @@ -1369,7 +1345,6 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry) __u64 pos = 0; int dot_de; int rc = LS_NONE_FIRST_DE; - ENTRY; ll_dir_chain_init(&chain); page = ll_get_dir_page(dir, pos, &chain); @@ -1468,7 +1443,6 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry) ll_release_page(page, 1); } } - EXIT; out: ll_dir_chain_fini(&chain); @@ -1481,7 +1455,6 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry) struct ptlrpc_thread *thread = &sai->sai_thread; struct ll_sb_info *sbi = ll_i2sbi(sai->sai_inode); int hit; - ENTRY; if (entry != NULL && entry->se_stat == SA_ENTRY_SUCC) hit = 1; @@ -1516,8 +1489,6 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry) if (!thread_is_stopped(thread)) wake_up(&thread->t_ctl_waitq); - - EXIT; } /** @@ -1540,7 +1511,6 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, struct l_wait_info lwi = { 0 }; int rc = 0; struct ll_inode_info *plli; - ENTRY; LASSERT(lli->lli_opendir_pid == current_pid()); @@ -1550,7 +1520,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, list_empty(&sai->sai_entries_stated))) { /* to release resource */ ll_stop_statahead(dir, lli->lli_opendir_key); - RETURN(-EAGAIN); + return -EAGAIN; } if ((*dentryp)->d_name.name[0] == '.') { @@ -1576,14 +1546,14 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, * "sai_ls_all" enabled as above. */ sai->sai_miss_hidden++; - RETURN(-EAGAIN); + return -EAGAIN; } } entry = ll_sa_entry_get_byname(sai, &(*dentryp)->d_name); if (entry == NULL || only_unplug) { ll_sai_unplug(sai, entry); - RETURN(entry ? 1 : -EAGAIN); + return entry ? 1 : -EAGAIN; } /* if statahead is busy in readdir, help it do post-work */ @@ -1602,7 +1572,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, &lwi); if (rc < 0) { ll_sai_unplug(sai, entry); - RETURN(-EAGAIN); + return -EAGAIN; } } @@ -1632,7 +1602,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, inode->i_ino, inode->i_generation); ll_sai_unplug(sai, entry); - RETURN(-ESTALE); + return -ESTALE; } else { iput(inode); } @@ -1646,7 +1616,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, } ll_sai_unplug(sai, entry); - RETURN(rc); + return rc; } /* I am the "lli_opendir_pid" owner, only me can set "lli_sai". */ @@ -1698,7 +1668,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, thread_set_flags(&sai->sai_agl_thread, SVC_STOPPED); ll_sai_put(sai); LASSERT(lli->lli_sai == NULL); - RETURN(-EAGAIN); + return -EAGAIN; } l_wait_event(thread->t_ctl_waitq, @@ -1709,7 +1679,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, * We don't stat-ahead for the first dirent since we are already in * lookup. */ - RETURN(-EAGAIN); + return -EAGAIN; out: if (sai != NULL) diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 82c14a993cc..0beaf4e76b4 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -38,7 +38,6 @@ #include <linux/module.h> #include <linux/types.h> -#include <linux/version.h> #include <lustre_lite.h> #include <lustre_ha.h> #include <lustre_dlm.h> @@ -214,7 +213,7 @@ static void __exit exit_lustre_lite(void) ll_remote_perm_cachep = NULL; kmem_cache_destroy(ll_file_data_slab); - if (proc_lustre_fs_root) + if (proc_lustre_fs_root && !IS_ERR(proc_lustre_fs_root)) lprocfs_remove(&proc_lustre_fs_root); } diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index 5260e989a4e..ab06891f7fc 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -37,7 +37,6 @@ #include <linux/fs.h> #include <linux/mm.h> #include <linux/stat.h> -#include <linux/version.h> #define DEBUG_SUBSYSTEM S_LLITE #include <lustre_lite.h> @@ -51,7 +50,6 @@ static int ll_readlink_internal(struct inode *inode, int rc, symlen = i_size_read(inode) + 1; struct mdt_body *body; struct md_op_data *op_data; - ENTRY; *request = NULL; @@ -65,13 +63,13 @@ static int ll_readlink_internal(struct inode *inode, CDEBUG(D_INODE, "using cached symlink %s%.*s, len = %d\n", print_limit < symlen ? "..." : "", print_limit, (*symname) + symlen - print_limit, symlen); - RETURN(0); + return 0; } op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, symlen, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = OBD_MD_LINKNAME; rc = md_getattr(sbi->ll_md_exp, op_data, request); @@ -111,10 +109,10 @@ static int ll_readlink_internal(struct inode *inode, memcpy(lli->lli_symlink_name, *symname, symlen); *symname = lli->lli_symlink_name; } - RETURN(0); + return 0; failed: - RETURN (rc); + return rc; } static int ll_readlink(struct dentry *dentry, char *buffer, int buflen) @@ -123,7 +121,6 @@ static int ll_readlink(struct dentry *dentry, char *buffer, int buflen) struct ptlrpc_request *request; char *symname; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op\n"); @@ -136,7 +133,7 @@ static int ll_readlink(struct dentry *dentry, char *buffer, int buflen) out: ptlrpc_req_finished(request); ll_inode_size_unlock(inode); - RETURN(rc); + return rc; } static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) @@ -145,7 +142,6 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) struct ptlrpc_request *request = NULL; int rc; char *symname; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op\n"); /* Limit the recursive symlink depth to 5 instead of default @@ -170,7 +166,7 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) /* symname may contain a pointer to the request message buffer, * we delay request releasing until ll_put_link then. */ - RETURN(request); + return request; } static void ll_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index 9254b990d31..be125b98b7f 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -213,7 +213,7 @@ int cl_sb_init(struct super_block *sb) cl_env_put(env, &refcheck); } else rc = PTR_ERR(env); - RETURN(rc); + return rc; } int cl_sb_fini(struct super_block *sb) @@ -224,7 +224,6 @@ int cl_sb_fini(struct super_block *sb) int refcheck; int result; - ENTRY; sbi = ll_s2sbi(sb); env = cl_env_get(&refcheck); if (!IS_ERR(env)) { @@ -247,7 +246,7 @@ int cl_sb_fini(struct super_block *sb) * automatically when last device is destroyed). */ lu_types_stop(); - RETURN(result); + return result; } /**************************************************************************** diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index eb964acad45..3ff664ce750 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -176,19 +176,18 @@ static int vvp_mmap_locks(const struct lu_env *env, unsigned long seg; ssize_t count; int result; - ENTRY; LASSERT(io->ci_type == CIT_READ || io->ci_type == CIT_WRITE); if (!cl_is_normalio(env, io)) - RETURN(0); + return 0; if (vio->cui_iov == NULL) /* nfs or loop back device write */ - RETURN(0); + return 0; /* No MM (e.g. NFS)? No vmas too. */ if (mm == NULL) - RETURN(0); + return 0; for (seg = 0; seg < vio->cui_nrsegs; seg++) { const struct iovec *iv = &vio->cui_iov[seg]; @@ -234,7 +233,7 @@ static int vvp_mmap_locks(const struct lu_env *env, descr->cld_end); if (result < 0) - RETURN(result); + return result; if (vma->vm_end - addr >= count) break; @@ -244,7 +243,7 @@ static int vvp_mmap_locks(const struct lu_env *env, } up_read(&mm->mmap_sem); } - RETURN(0); + return 0; } static int vvp_io_rw_lock(const struct lu_env *env, struct cl_io *io, @@ -255,7 +254,6 @@ static int vvp_io_rw_lock(const struct lu_env *env, struct cl_io *io, int ast_flags = 0; LASSERT(io->ci_type == CIT_READ || io->ci_type == CIT_WRITE); - ENTRY; ccc_io_update_iov(env, cio, io); @@ -264,7 +262,7 @@ static int vvp_io_rw_lock(const struct lu_env *env, struct cl_io *io, result = vvp_mmap_locks(env, cio, io); if (result == 0) result = ccc_io_one_lock(env, io, ast_flags, mode, start, end); - RETURN(result); + return result; } static int vvp_io_read_lock(const struct lu_env *env, @@ -274,7 +272,6 @@ static int vvp_io_read_lock(const struct lu_env *env, struct ll_inode_info *lli = ll_i2info(ccc_object_inode(io->ci_obj)); int result; - ENTRY; /* XXX: Layer violation, we shouldn't see lsm at llite level. */ if (lli->lli_has_smd) /* lsm-less file doesn't need to lock */ result = vvp_io_rw_lock(env, io, CLM_READ, @@ -283,7 +280,7 @@ static int vvp_io_read_lock(const struct lu_env *env, io->u.ci_rd.rd.crw_count - 1); else result = 0; - RETURN(result); + return result; } static int vvp_io_fault_lock(const struct lu_env *env, @@ -407,13 +404,15 @@ static int vvp_io_setattr_start(const struct lu_env *env, { struct cl_io *io = ios->cis_io; struct inode *inode = ccc_object_inode(io->ci_obj); + int result = 0; mutex_lock(&inode->i_mutex); if (cl_io_is_trunc(io)) - return vvp_io_setattr_trunc(env, ios, inode, - io->u.ci_setattr.sa_attr.lvb_size); - else - return vvp_io_setattr_time(env, ios); + result = vvp_io_setattr_trunc(env, ios, inode, + io->u.ci_setattr.sa_attr.lvb_size); + if (result == 0) + result = vvp_io_setattr_time(env, ios); + return result; } static void vvp_io_setattr_end(const struct lu_env *env, @@ -525,7 +524,7 @@ out: io->ci_continue = 0; io->ci_nob += result; ll_rw_stats_tally(ll_i2sbi(inode), current->pid, - cio->cui_fd, pos, result, 0); + cio->cui_fd, pos, result, READ); result = 0; } return result; @@ -554,8 +553,6 @@ static int vvp_io_write_start(const struct lu_env *env, loff_t pos = io->u.ci_wr.wr.crw_pos; size_t cnt = io->u.ci_wr.wr.crw_count; - ENTRY; - if (!can_populate_pages(env, io, inode)) return 0; @@ -580,10 +577,10 @@ static int vvp_io_write_start(const struct lu_env *env, io->ci_continue = 0; io->ci_nob += result; ll_rw_stats_tally(ll_i2sbi(inode), current->pid, - cio->cui_fd, pos, result, 0); + cio->cui_fd, pos, result, WRITE); result = 0; } - RETURN(result); + return result; } static int vvp_io_kernel_fault(struct vvp_fault_io *cfio) @@ -767,7 +764,6 @@ static int vvp_io_fault_start(const struct lu_env *env, lu_ref_add(&page->cp_reference, "fault", io); fio->ft_page = page; - EXIT; out: /* return unlocked vmpage to avoid deadlocking */ @@ -805,8 +801,6 @@ static int vvp_io_read_page(const struct lu_env *env, CLOBINVRNT(env, obj, ccc_object_invariant(obj)); LASSERT(slice->cpl_obj == obj); - ENTRY; - if (sbi->ll_ra_info.ra_max_pages_per_file && sbi->ll_ra_info.ra_max_pages) ras_update(sbi, inode, ras, page->cp_index, @@ -819,7 +813,7 @@ static int vvp_io_read_page(const struct lu_env *env, rc == -ENODATA ? "without a lock" : "match failed", rc); if (rc != -ENODATA) - RETURN(rc); + return rc; } if (cp->cpg_defer_uptodate) { @@ -836,7 +830,7 @@ static int vvp_io_read_page(const struct lu_env *env, ll_readahead(env, io, ras, vmpage->mapping, &queue->c2_qin, fd->fd_flags); - RETURN(0); + return 0; } static int vvp_page_sync_io(const struct lu_env *env, struct cl_io *io, @@ -887,10 +881,10 @@ static int vvp_io_prepare_partial(const struct lu_env *env, struct cl_io *io, * purposes here we can treat it like i_size. */ if (attr->cat_kms <= offset) { - char *kaddr = ll_kmap_atomic(cp->cpg_page, KM_USER0); + char *kaddr = kmap_atomic(cp->cpg_page); memset(kaddr, 0, cl_page_size(obj)); - ll_kunmap_atomic(kaddr, KM_USER0); + kunmap_atomic(kaddr); } else if (cp->cpg_defer_uptodate) cp->cpg_ra_used = 1; else @@ -921,8 +915,6 @@ static int vvp_io_prepare_write(const struct lu_env *env, int result; - ENTRY; - LINVRNT(cl_page_is_vmlocked(env, pg)); LASSERT(vmpage->mapping->host == ccc_object_inode(obj)); @@ -942,7 +934,7 @@ static int vvp_io_prepare_write(const struct lu_env *env, pg, cp, from, to); } else CL_PAGE_HEADER(D_PAGE, env, pg, "uptodate\n"); - RETURN(result); + return result; } static int vvp_io_commit_write(const struct lu_env *env, @@ -963,12 +955,10 @@ static int vvp_io_commit_write(const struct lu_env *env, int tallyop; loff_t size; - ENTRY; - LINVRNT(cl_page_is_vmlocked(env, pg)); LASSERT(vmpage->mapping->host == inode); - LU_OBJECT_HEADER(D_INODE, env, &obj->co_lu, "commiting page write\n"); + LU_OBJECT_HEADER(D_INODE, env, &obj->co_lu, "committing page write\n"); CL_PAGE_HEADER(D_PAGE, env, pg, "committing: [%d, %d]\n", from, to); /* @@ -1067,7 +1057,7 @@ static int vvp_io_commit_write(const struct lu_env *env, cl_page_discard(env, io, pg); } ll_inode_size_unlock(inode); - RETURN(result); + return result; } static const struct cl_io_operations vvp_io_ops = { @@ -1120,7 +1110,6 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, int result; CLOBINVRNT(env, obj, ccc_object_invariant(obj)); - ENTRY; CL_IO_SLICE_CLEAN(cio, cui_cl); cl_io_slice_add(io, &cio->cui_cl, obj, &vvp_io_ops); @@ -1174,7 +1163,7 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, PFID(lu_object_fid(&obj->co_lu)), result); } - RETURN(result); + return result; } static struct vvp_io *cl2vvp_io(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/llite/vvp_lock.c b/drivers/staging/lustre/lustre/llite/vvp_lock.c index 9b8712bccd9..e16b31e4ff7 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_lock.c +++ b/drivers/staging/lustre/lustre/llite/vvp_lock.c @@ -63,8 +63,7 @@ static unsigned long vvp_lock_weigh(const struct lu_env *env, { struct ccc_object *cob = cl2ccc(slice->cls_obj); - ENTRY; - RETURN(atomic_read(&cob->cob_mmap_cnt) > 0 ? ~0UL >> 2 : 0); + return atomic_read(&cob->cob_mmap_cnt) > 0 ? ~0UL >> 2 : 0; } static const struct cl_lock_operations vvp_lock_ops = { diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c index 01edc5b63e1..33173fce478 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_object.c +++ b/drivers/staging/lustre/lustre/llite/vvp_object.c @@ -91,8 +91,8 @@ static int vvp_attr_get(const struct lu_env *env, struct cl_object *obj, attr->cat_atime = LTIME_S(inode->i_atime); attr->cat_ctime = LTIME_S(inode->i_ctime); attr->cat_blocks = inode->i_blocks; - attr->cat_uid = inode->i_uid; - attr->cat_gid = inode->i_gid; + attr->cat_uid = from_kuid(&init_user_ns, inode->i_uid); + attr->cat_gid = from_kgid(&init_user_ns, inode->i_gid); /* KMS is not known by this layer */ return 0; /* layers below have to fill in the rest */ } @@ -103,9 +103,9 @@ static int vvp_attr_set(const struct lu_env *env, struct cl_object *obj, struct inode *inode = ccc_object_inode(obj); if (valid & CAT_UID) - inode->i_uid = attr->cat_uid; + inode->i_uid = make_kuid(&init_user_ns, attr->cat_uid); if (valid & CAT_GID) - inode->i_gid = attr->cat_gid; + inode->i_gid = make_kgid(&init_user_ns, attr->cat_gid); if (valid & CAT_ATIME) LTIME_S(inode->i_atime) = attr->cat_atime; if (valid & CAT_MTIME) diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index 4568e69bb9f..1c02c128e0e 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c @@ -218,9 +218,8 @@ static int vvp_page_prep_read(const struct lu_env *env, const struct cl_page_slice *slice, struct cl_io *unused) { - ENTRY; /* Skip the page already marked as PG_uptodate. */ - RETURN(PageUptodate(cl2vm_page(slice)) ? -EALREADY : 0); + return PageUptodate(cl2vm_page(slice)) ? -EALREADY : 0; } static int vvp_page_prep_write(const struct lu_env *env, @@ -274,7 +273,6 @@ static void vvp_page_completion_read(const struct lu_env *env, struct page *vmpage = cp->cpg_page; struct cl_page *page = cl_page_top(slice->cpl_page); struct inode *inode = ccc_object_inode(page->cp_obj); - ENTRY; LASSERT(PageLocked(vmpage)); CL_PAGE_HEADER(D_PAGE, env, page, "completing READ with %d\n", ioret); @@ -290,8 +288,6 @@ static void vvp_page_completion_read(const struct lu_env *env, if (page->cp_sync_io == NULL) unlock_page(vmpage); - - EXIT; } static void vvp_page_completion_write(const struct lu_env *env, @@ -301,7 +297,6 @@ static void vvp_page_completion_write(const struct lu_env *env, struct ccc_page *cp = cl2ccc_page(slice); struct cl_page *pg = slice->cpl_page; struct page *vmpage = cp->cpg_page; - ENTRY; LASSERT(ergo(pg->cp_sync_io != NULL, PageLocked(vmpage))); LASSERT(PageWriteback(vmpage)); @@ -329,7 +324,6 @@ static void vvp_page_completion_write(const struct lu_env *env, vvp_vmpage_error(ccc_object_inode(pg->cp_obj), vmpage, ioret); end_page_writeback(vmpage); - EXIT; } /** @@ -372,7 +366,7 @@ static int vvp_page_make_ready(const struct lu_env *env, LBUG(); } unlock_page(vmpage); - RETURN(result); + return result; } static int vvp_page_print(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 4176264984b..bcf86bac30a 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -112,31 +112,32 @@ int ll_setxattr_common(struct inode *inode, const char *name, struct ptlrpc_request *req; int xattr_type, rc; struct obd_capa *oc; +#ifdef CONFIG_FS_POSIX_ACL posix_acl_xattr_header *new_value = NULL; struct rmtacl_ctl_entry *rce = NULL; ext_acl_xattr_header *acl = NULL; +#endif const char *pv = value; - ENTRY; xattr_type = get_xattr_type(name); rc = xattr_type_filter(sbi, xattr_type); if (rc) - RETURN(rc); + return rc; /* b10667: ignore lustre special xattr for now */ if ((xattr_type == XATTR_TRUSTED_T && strcmp(name, "trusted.lov") == 0) || (xattr_type == XATTR_LUSTRE_T && strcmp(name, "lustre.lov") == 0)) - RETURN(0); + return 0; /* b15587: ignore security.capability xattr for now */ if ((xattr_type == XATTR_SECURITY_T && strcmp(name, "security.capability") == 0)) - RETURN(0); + return 0; /* LU-549: Disable security.selinux when selinux is disabled */ if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() && strcmp(name, "security.selinux") == 0) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; #ifdef CONFIG_FS_POSIX_ACL if (sbi->ll_flags & LL_SBI_RMT_CLIENT && @@ -146,7 +147,7 @@ int ll_setxattr_common(struct inode *inode, const char *name, if (rce == NULL || (rce->rce_ops != RMT_LSETFACL && rce->rce_ops != RMT_RSETFACL)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (rce->rce_ops == RMT_LSETFACL) { struct eacl_entry *ee; @@ -160,7 +161,7 @@ int ll_setxattr_common(struct inode *inode, const char *name, size, ee->ee_acl); if (IS_ERR(acl)) { ee_free(ee); - RETURN(PTR_ERR(acl)); + return PTR_ERR(acl); } size = CFS_ACL_XATTR_SIZE(\ le32_to_cpu(acl->a_count), \ @@ -173,11 +174,11 @@ int ll_setxattr_common(struct inode *inode, const char *name, (posix_acl_xattr_header *)value, size, &new_value); if (unlikely(size < 0)) - RETURN(size); + return size; pv = (const char *)new_value; } else - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; valid |= rce_ops2valid(rce->rce_ops); } @@ -199,11 +200,11 @@ int ll_setxattr_common(struct inode *inode, const char *name, "it is not supported on the server\n"); sbi->ll_flags &= ~LL_SBI_USER_XATTR; } - RETURN(rc); + return rc; } ptlrpc_req_finished(req); - RETURN(0); + return 0; } int ll_setxattr(struct dentry *dentry, const char *name, @@ -285,7 +286,6 @@ int ll_getxattr_common(struct inode *inode, const char *name, void *xdata; struct obd_capa *oc; struct rmtacl_ctl_entry *rce = NULL; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -302,17 +302,17 @@ int ll_getxattr_common(struct inode *inode, const char *name, xattr_type = get_xattr_type(name); rc = xattr_type_filter(sbi, xattr_type); if (rc) - RETURN(rc); + return rc; /* b15587: ignore security.capability xattr for now */ if ((xattr_type == XATTR_SECURITY_T && strcmp(name, "security.capability") == 0)) - RETURN(-ENODATA); + return -ENODATA; /* LU-549: Disable security.selinux when selinux is disabled */ if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() && strcmp(name, "security.selinux") == 0) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; #ifdef CONFIG_FS_POSIX_ACL if (sbi->ll_flags & LL_SBI_RMT_CLIENT && @@ -324,7 +324,7 @@ int ll_getxattr_common(struct inode *inode, const char *name, rce->rce_ops != RMT_LGETFACL && rce->rce_ops != RMT_RSETFACL && rce->rce_ops != RMT_RGETFACL)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; } /* posix acl is under protection of LOOKUP lock. when calling to this, @@ -341,14 +341,14 @@ int ll_getxattr_common(struct inode *inode, const char *name, spin_unlock(&lli->lli_lock); if (!acl) - RETURN(-ENODATA); + return -ENODATA; rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); posix_acl_release(acl); - RETURN(rc); + return rc; } if (xattr_type == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode)) - RETURN(-ENODATA); + return -ENODATA; #endif do_getxattr: @@ -363,7 +363,7 @@ do_getxattr: "it is not supported on the server\n"); sbi->ll_flags &= ~LL_SBI_USER_XATTR; } - RETURN(rc); + return rc; } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); @@ -413,7 +413,6 @@ do_getxattr: memcpy(buffer, xdata, body->eadatasize); rc = body->eadatasize; } - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -562,7 +561,12 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) const size_t name_len = sizeof("lov") - 1; const size_t total_len = prefix_len + name_len + 1; - if (buffer && (rc + total_len) <= size) { + if (((rc + total_len) > size) && (buffer != NULL)) { + ptlrpc_req_finished(request); + return -ERANGE; + } + + if (buffer != NULL) { buffer += rc; memcpy(buffer, XATTR_LUSTRE_PREFIX, prefix_len); memcpy(buffer + prefix_len, "lov", name_len); diff --git a/drivers/staging/lustre/lustre/lmv/lmv_fld.c b/drivers/staging/lustre/lustre/lmv/lmv_fld.c index a4805aefa68..0b2d38d1362 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_fld.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_fld.c @@ -38,7 +38,6 @@ #include <linux/slab.h> #include <linux/module.h> #include <linux/init.h> -#include <linux/slab.h> #include <linux/pagemap.h> #include <asm/div64.h> #include <linux/seq_file.h> @@ -58,8 +57,6 @@ int lmv_fld_lookup(struct lmv_obd *lmv, mdsno_t *mds) { int rc; - ENTRY; - /* FIXME: Currently ZFS still use local seq for ROOT unfortunately, and * this fid_is_local check should be removed once LU-2240 is fixed */ @@ -72,7 +69,7 @@ int lmv_fld_lookup(struct lmv_obd *lmv, if (rc) { CERROR("Error while looking for mds number. Seq "LPX64 ", err = %d\n", fid_seq(fid), rc); - RETURN(rc); + return rc; } CDEBUG(D_INODE, "FLD lookup got mds #%x for fid="DFID"\n", @@ -84,5 +81,5 @@ int lmv_fld_lookup(struct lmv_obd *lmv, PFID(fid)); rc = -EINVAL; } - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index 7eefab5ef5d..511b3b4b699 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -38,7 +38,6 @@ #include <linux/slab.h> #include <linux/module.h> #include <linux/init.h> -#include <linux/slab.h> #include <linux/pagemap.h> #include <asm/div64.h> #include <linux/seq_file.h> @@ -70,11 +69,10 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, struct mdt_body *body; int pmode; int rc = 0; - ENTRY; body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY); if (body == NULL) - RETURN(-EPROTO); + return -EPROTO; LASSERT((body->valid & OBD_MD_MDS)); @@ -142,7 +140,6 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, it->d.lustre.it_lock_handle = plock.cookie; it->d.lustre.it_lock_mode = pmode; - EXIT; out_free_op_data: OBD_FREE_PTR(op_data); out: @@ -169,11 +166,10 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, struct lmv_tgt_desc *tgt; struct mdt_body *body; int rc; - ENTRY; tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); /* If it is ready to open the file by FID, do not need * allocate FID at all, otherwise it will confuse MDT */ @@ -186,7 +182,7 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, op_data->op_fid3 = op_data->op_fid2; rc = lmv_fid_alloc(exp, &op_data->op_fid2, op_data); if (rc != 0) - RETURN(rc); + return rc; } CDEBUG(D_INODE, "OPEN_INTENT with fid1="DFID", fid2="DFID"," @@ -196,7 +192,7 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, rc = md_intent_lock(tgt->ltd_exp, op_data, lmm, lmmsize, it, flags, reqp, cb_blocking, extra_lock_flags); if (rc != 0) - RETURN(rc); + return rc; /* * Nothing is found, do not access body->fid1 as it is zero and thus * pointless. @@ -204,16 +200,16 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, if ((it->d.lustre.it_disposition & DISP_LOOKUP_NEG) && !(it->d.lustre.it_disposition & DISP_OPEN_CREATE) && !(it->d.lustre.it_disposition & DISP_OPEN_OPEN)) - RETURN(rc); + return rc; body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY); if (body == NULL) - RETURN(-EPROTO); + return -EPROTO; /* * Not cross-ref case, just get out of here. */ if (likely(!(body->valid & OBD_MD_MDS))) - RETURN(0); + return 0; /* * Okay, MDS has returned success. Probably name has been resolved in @@ -233,10 +229,10 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, "%*s: %d\n", LL_IT2STR(it), PFID(&op_data->op_fid2), PFID(&op_data->op_fid1), op_data->op_namelen, op_data->op_name, rc); - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } /* @@ -253,11 +249,10 @@ int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data, struct lmv_tgt_desc *tgt = NULL; struct mdt_body *body; int rc = 0; - ENTRY; tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); if (!fid_is_sane(&op_data->op_fid2)) fid_zero(&op_data->op_fid2); @@ -274,7 +269,7 @@ int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data, flags, reqp, cb_blocking, extra_lock_flags); if (rc < 0 || *reqp == NULL) - RETURN(rc); + return rc; /* * MDS has returned success. Probably name has been resolved in @@ -282,15 +277,15 @@ int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data, */ body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY); if (body == NULL) - RETURN(-EPROTO); + return -EPROTO; /* Not cross-ref case, just get out of here. */ if (likely(!(body->valid & OBD_MD_MDS))) - RETURN(0); + return 0; rc = lmv_intent_remote(exp, lmm, lmmsize, it, NULL, flags, reqp, cb_blocking, extra_lock_flags); - RETURN(rc); + return rc; } int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data, @@ -301,7 +296,6 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data, { struct obd_device *obd = exp->exp_obd; int rc; - ENTRY; LASSERT(it != NULL); LASSERT(fid_is_sane(&op_data->op_fid1)); @@ -312,7 +306,7 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; if (it->it_op & (IT_LOOKUP | IT_GETATTR | IT_LAYOUT)) rc = lmv_intent_lookup(exp, op_data, lmm, lmmsize, it, @@ -324,5 +318,5 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data, extra_lock_flags); else LBUG(); - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 1eebfbf3487..c2866046fc3 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -38,12 +38,12 @@ #include <linux/slab.h> #include <linux/module.h> #include <linux/init.h> -#include <linux/slab.h> #include <linux/pagemap.h> #include <linux/mm.h> #include <asm/div64.h> #include <linux/seq_file.h> #include <linux/namei.h> +#include <asm/uaccess.h> #include <lustre/lustre_idl.h> #include <obd_support.h> @@ -80,7 +80,6 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, struct obd_device *obd; int i; int rc = 0; - ENTRY; CDEBUG(D_INFO, "Searching in lmv %p for uuid %s (activate=%d)\n", lmv, uuid->uuid, activate); @@ -119,7 +118,6 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, CDEBUG(D_INFO, "Marking OBD %p %sactive\n", obd, activate ? "" : "in"); lmv_activate_target(lmv, tgt, activate); - EXIT; out_lmv_lock: spin_unlock(&lmv->lmv_lock); @@ -140,13 +138,12 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, struct lmv_obd *lmv = &obd->u.lmv; struct obd_uuid *uuid; int rc = 0; - ENTRY; if (strcmp(watched->obd_type->typ_name, LUSTRE_MDC_NAME)) { CERROR("unexpected notification of %s %s!\n", watched->obd_type->typ_name, watched->obd_name); - RETURN(-EINVAL); + return -EINVAL; } uuid = &watched->u.cli.cl_target_uuid; @@ -161,7 +158,7 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, CERROR("%sactivation of %s failed: %d\n", ev == OBD_NOTIFY_ACTIVE ? "" : "de", uuid->uuid, rc); - RETURN(rc); + return rc; } } else if (ev == OBD_NOTIFY_OCD) { conn_data = &watched->u.cli.cl_import->imp_connect_data; @@ -186,7 +183,7 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, if (obd->obd_observer) rc = obd_notify(obd->obd_observer, watched, ev, data); - RETURN(rc); + return rc; } /** @@ -202,7 +199,6 @@ static int lmv_connect(const struct lu_env *env, struct lmv_obd *lmv = &obd->u.lmv; struct lustre_handle conn = { 0 }; int rc = 0; - ENTRY; /* * We don't want to actually do the underlying connections more than @@ -211,13 +207,13 @@ static int lmv_connect(const struct lu_env *env, lmv->refcount++; if (lmv->refcount > 1) { *exp = NULL; - RETURN(0); + return 0; } rc = class_connect(&conn, obd, cluuid); if (rc) { CERROR("class_connection() returned %d\n", rc); - RETURN(rc); + return rc; } *exp = class_conn2export(&conn); @@ -257,7 +253,7 @@ static int lmv_connect(const struct lu_env *env, obd->obd_proc_private = NULL; } - RETURN(rc); + return rc; } static void lmv_set_timeouts(struct obd_device *obd) @@ -291,7 +287,6 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, int i; int rc = 0; int change = 0; - ENTRY; if (lmv->max_easize < easize) { lmv->max_easize = easize; @@ -306,10 +301,10 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, change = 1; } if (change == 0) - RETURN(0); + return 0; if (lmv->connected == 0) - RETURN(0); + return 0; for (i = 0; i < lmv->desc.ld_tgt_count; i++) { if (lmv->tgts[i] == NULL || @@ -327,7 +322,7 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, break; } } - RETURN(rc); + return rc; } #define MAX_STRING_SIZE 128 @@ -342,13 +337,12 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) struct obd_export *mdc_exp; struct lu_fld_target target; int rc; - ENTRY; mdc_obd = class_find_client_obd(&tgt->ltd_uuid, LUSTRE_MDC_NAME, &obd->obd_uuid); if (!mdc_obd) { CERROR("target %s not attached\n", tgt->ltd_uuid.uuid); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_CONFIG, "connect to %s(%s) - %s, %s FOR %s\n", @@ -358,14 +352,14 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) if (!mdc_obd->obd_set_up) { CERROR("target %s is not set up\n", tgt->ltd_uuid.uuid); - RETURN(-EINVAL); + return -EINVAL; } rc = obd_connect(NULL, &mdc_exp, mdc_obd, &lmv_mdc_uuid, &lmv->conn_data, NULL); if (rc) { CERROR("target %s connect error %d\n", tgt->ltd_uuid.uuid, rc); - RETURN(rc); + return rc; } /* @@ -373,7 +367,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) */ rc = obd_fid_init(mdc_obd, mdc_exp, LUSTRE_SEQ_METADATA); if (rc) - RETURN(rc); + return rc; target.ft_srv = NULL; target.ft_exp = mdc_exp; @@ -386,7 +380,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) obd_disconnect(mdc_exp); CERROR("target %s register_observer error %d\n", tgt->ltd_uuid.uuid, rc); - RETURN(rc); + return rc; } if (obd->obd_observer) { @@ -398,7 +392,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) (void *)(tgt - lmv->tgts[0])); if (rc) { obd_disconnect(mdc_exp); - RETURN(rc); + return rc; } } @@ -433,7 +427,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) obd->obd_proc_private = NULL; } } - RETURN(0); + return 0; } static void lmv_del_target(struct lmv_obd *lmv, int index) @@ -452,7 +446,6 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc = 0; - ENTRY; CDEBUG(D_CONFIG, "Target uuid: %s. index %d\n", uuidp->uuid, index); @@ -467,7 +460,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, lmv_init_unlock(lmv); CERROR("%s: Target %s not attached: rc = %d\n", obd->obd_name, uuidp->uuid, -EINVAL); - RETURN(-EINVAL); + return -EINVAL; } } @@ -477,7 +470,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, " rc = %d\n", obd->obd_name, obd_uuid2str(&tgt->ltd_uuid), index, -EEXIST); lmv_init_unlock(lmv); - RETURN(-EEXIST); + return -EEXIST; } if (index >= lmv->tgts_size) { @@ -491,7 +484,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize); if (newtgts == NULL) { lmv_init_unlock(lmv); - RETURN(-ENOMEM); + return -ENOMEM; } if (lmv->tgts_size) { @@ -514,7 +507,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, OBD_ALLOC_PTR(tgt); if (!tgt) { lmv_init_unlock(lmv); - RETURN(-ENOMEM); + return -ENOMEM; } mutex_init(&tgt->ltd_fid_mutex); @@ -541,7 +534,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, } lmv_init_unlock(lmv); - RETURN(rc); + return rc; } int lmv_check_connect(struct obd_device *obd) @@ -551,21 +544,20 @@ int lmv_check_connect(struct obd_device *obd) int i; int rc; int easize; - ENTRY; if (lmv->connected) - RETURN(0); + return 0; lmv_init_lock(lmv); if (lmv->connected) { lmv_init_unlock(lmv); - RETURN(0); + return 0; } if (lmv->desc.ld_tgt_count == 0) { lmv_init_unlock(lmv); CERROR("%s: no targets configured.\n", obd->obd_name); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_CONFIG, "Time to connect %s to %s\n", @@ -588,7 +580,7 @@ int lmv_check_connect(struct obd_device *obd) easize = lmv_get_easize(lmv); lmv_init_ea_size(obd->obd_self_export, easize, 0, 0); lmv_init_unlock(lmv); - RETURN(0); + return 0; out_disc: while (i-- > 0) { @@ -609,7 +601,7 @@ int lmv_check_connect(struct obd_device *obd) } class_disconnect(lmv->exp); lmv_init_unlock(lmv); - RETURN(rc); + return rc; } static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) @@ -618,7 +610,6 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) struct lmv_obd *lmv = &obd->u.lmv; struct obd_device *mdc_obd; int rc; - ENTRY; LASSERT(tgt != NULL); LASSERT(obd != NULL); @@ -654,7 +645,7 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) lmv_activate_target(lmv, tgt, 0); tgt->ltd_exp = NULL; - RETURN(0); + return 0; } static int lmv_disconnect(struct obd_export *exp) @@ -663,7 +654,6 @@ static int lmv_disconnect(struct obd_export *exp) struct lmv_obd *lmv = &obd->u.lmv; int rc; int i; - ENTRY; if (!lmv->tgts) goto out_local; @@ -683,7 +673,7 @@ static int lmv_disconnect(struct obd_export *exp) } if (obd->obd_proc_private) - lprocfs_remove((proc_dir_entry_t **)&obd->obd_proc_private); + lprocfs_remove((struct proc_dir_entry **)&obd->obd_proc_private); else CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n", obd->obd_type->typ_name, obd->obd_name); @@ -698,7 +688,7 @@ out_local: rc = class_disconnect(exp); if (lmv->refcount == 0) lmv->connected = 0; - RETURN(rc); + return rc; } static int lmv_fid2path(struct obd_export *exp, int len, void *karg, void *uarg) @@ -714,7 +704,7 @@ static int lmv_fid2path(struct obd_export *exp, int len, void *karg, void *uarg) gf = (struct getinfo_fid2path *)karg; tgt = lmv_find_target(lmv, &gf->gf_fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); repeat_fid2path: rc = obd_iocontrol(OBD_IOC_FID2PATH, tgt->ltd_exp, len, gf, uarg); @@ -780,9 +770,126 @@ repeat_fid2path: out_fid2path: if (remote_gf != NULL) OBD_FREE(remote_gf, remote_gf_size); - RETURN(rc); + return rc; +} + +static int lmv_hsm_req_count(struct lmv_obd *lmv, + const struct hsm_user_request *hur, + const struct lmv_tgt_desc *tgt_mds) +{ + int i, nr = 0; + struct lmv_tgt_desc *curr_tgt; + + /* count how many requests must be sent to the given target */ + for (i = 0; i < hur->hur_request.hr_itemcount; i++) { + curr_tgt = lmv_find_target(lmv, &hur->hur_user_item[i].hui_fid); + if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) + nr++; + } + return nr; +} + +static void lmv_hsm_req_build(struct lmv_obd *lmv, + struct hsm_user_request *hur_in, + const struct lmv_tgt_desc *tgt_mds, + struct hsm_user_request *hur_out) +{ + int i, nr_out; + struct lmv_tgt_desc *curr_tgt; + + /* build the hsm_user_request for the given target */ + hur_out->hur_request = hur_in->hur_request; + nr_out = 0; + for (i = 0; i < hur_in->hur_request.hr_itemcount; i++) { + curr_tgt = lmv_find_target(lmv, + &hur_in->hur_user_item[i].hui_fid); + if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) { + hur_out->hur_user_item[nr_out] = + hur_in->hur_user_item[i]; + nr_out++; + } + } + hur_out->hur_request.hr_itemcount = nr_out; + memcpy(hur_data(hur_out), hur_data(hur_in), + hur_in->hur_request.hr_data_len); +} + +static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len, + struct lustre_kernelcomm *lk, void *uarg) +{ + int i, rc = 0; + + /* unregister request (call from llapi_hsm_copytool_fini) */ + for (i = 0; i < lmv->desc.ld_tgt_count; i++) { + /* best effort: try to clean as much as possible + * (continue on error) */ + obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, len, lk, uarg); + } + + /* Whatever the result, remove copytool from kuc groups. + * Unreached coordinators will get EPIPE on next requests + * and will unregister automatically. + */ + rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group); + return rc; } +static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, + struct lustre_kernelcomm *lk, void *uarg) +{ + struct file *filp; + int i, j, err; + int rc = 0; + bool any_set = false; + + /* All or nothing: try to register to all MDS. + * In case of failure, unregister from previous MDS, + * except if it because of inactive target. */ + for (i = 0; i < lmv->desc.ld_tgt_count; i++) { + err = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, + len, lk, uarg); + if (err) { + if (lmv->tgts[i]->ltd_active) { + /* permanent error */ + CERROR("error: iocontrol MDC %s on MDT" + "idx %d cmd %x: err = %d\n", + lmv->tgts[i]->ltd_uuid.uuid, + i, cmd, err); + rc = err; + lk->lk_flags |= LK_FLG_STOP; + /* unregister from previous MDS */ + for (j = 0; j < i; j++) + obd_iocontrol(cmd, + lmv->tgts[j]->ltd_exp, + len, lk, uarg); + return rc; + } + /* else: transient error. + * kuc will register to the missing MDT + * when it is back */ + } else { + any_set = true; + } + } + + if (!any_set) + /* no registration done: return error */ + return -ENOTCONN; + + /* at least one registration done, with no failure */ + filp = fget(lk->lk_wfd); + if (filp == NULL) { + return -EBADF; + } + rc = libcfs_kkuc_group_add(filp, lk->lk_uid, lk->lk_group, lk->lk_data); + if (rc != 0 && filp != NULL) + fput(filp); + return rc; +} + + + + static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) { @@ -792,10 +899,9 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, int rc = 0; int set = 0; int count = lmv->desc.ld_tgt_count; - ENTRY; if (count == 0) - RETURN(-ENOTTY); + return -ENOTTY; switch (cmd) { case IOC_OBD_STATFS: { @@ -806,31 +912,31 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, memcpy(&index, data->ioc_inlbuf2, sizeof(__u32)); if ((index >= count)) - RETURN(-ENODEV); + return -ENODEV; if (lmv->tgts[index] == NULL || lmv->tgts[index]->ltd_active == 0) - RETURN(-ENODATA); + return -ENODATA; mdc_obd = class_exp2obd(lmv->tgts[index]->ltd_exp); if (!mdc_obd) - RETURN(-EINVAL); + return -EINVAL; /* copy UUID */ if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(mdc_obd), min((int) data->ioc_plen2, (int) sizeof(struct obd_uuid)))) - RETURN(-EFAULT); + return -EFAULT; rc = obd_statfs(NULL, lmv->tgts[index]->ltd_exp, &stat_buf, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), 0); if (rc) - RETURN(rc); + return rc; if (copy_to_user(data->ioc_pbuf1, &stat_buf, min((int) data->ioc_plen1, (int) sizeof(stat_buf)))) - RETURN(-EFAULT); + return -EFAULT; break; } case OBD_IOC_QUOTACTL: { @@ -840,11 +946,11 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, if (qctl->qc_valid == QC_MDTIDX) { if (qctl->qc_idx < 0 || count <= qctl->qc_idx) - RETURN(-EINVAL); + return -EINVAL; tgt = lmv->tgts[qctl->qc_idx]; if (tgt == NULL || tgt->ltd_exp == NULL) - RETURN(-EINVAL); + return -EINVAL; } else if (qctl->qc_valid == QC_UUID) { for (i = 0; i < count; i++) { tgt = lmv->tgts[i]; @@ -855,21 +961,21 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, continue; if (tgt->ltd_exp == NULL) - RETURN(-EINVAL); + return -EINVAL; break; } } else { - RETURN(-EINVAL); + return -EINVAL; } if (i >= count) - RETURN(-EAGAIN); + return -EAGAIN; LASSERT(tgt && tgt->ltd_exp); OBD_ALLOC_PTR(oqctl); if (!oqctl) - RETURN(-ENOMEM); + return -ENOMEM; QCTL_COPY(oqctl, qctl); rc = obd_quotactl(tgt->ltd_exp, oqctl); @@ -886,19 +992,19 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, struct ioc_changelog *icc = karg; if (icc->icc_mdtindex >= count) - RETURN(-ENODEV); + return -ENODEV; if (lmv->tgts[icc->icc_mdtindex] == NULL || lmv->tgts[icc->icc_mdtindex]->ltd_exp == NULL || lmv->tgts[icc->icc_mdtindex]->ltd_active == 0) - RETURN(-ENODEV); + return -ENODEV; rc = obd_iocontrol(cmd, lmv->tgts[icc->icc_mdtindex]->ltd_exp, sizeof(*icc), icc, NULL); break; } case LL_IOC_GET_CONNECT_FLAGS: { if (lmv->tgts[0] == NULL) - RETURN(-ENODATA); + return -ENODATA; rc = obd_iocontrol(cmd, lmv->tgts[0]->ltd_exp, len, karg, uarg); break; } @@ -908,29 +1014,107 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, } case LL_IOC_HSM_STATE_GET: case LL_IOC_HSM_STATE_SET: - case LL_IOC_HSM_ACTION: + case LL_IOC_HSM_ACTION: { + struct md_op_data *op_data = karg; + struct lmv_tgt_desc *tgt; + + tgt = lmv_find_target(lmv, &op_data->op_fid1); + if (IS_ERR(tgt)) + return PTR_ERR(tgt); + + if (tgt->ltd_exp == NULL) + return -EINVAL; + + rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg); + break; + } + case LL_IOC_HSM_PROGRESS: { + const struct hsm_progress_kernel *hpk = karg; + struct lmv_tgt_desc *tgt; + + tgt = lmv_find_target(lmv, &hpk->hpk_fid); + if (IS_ERR(tgt)) + return PTR_ERR(tgt); + rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg); + break; + } + case LL_IOC_HSM_REQUEST: { + struct hsm_user_request *hur = karg; + struct lmv_tgt_desc *tgt; + unsigned int reqcount = hur->hur_request.hr_itemcount; + + if (reqcount == 0) + return 0; + + /* if the request is about a single fid + * or if there is a single MDS, no need to split + * the request. */ + if (reqcount == 1 || count == 1) { + tgt = lmv_find_target(lmv, + &hur->hur_user_item[0].hui_fid); + if (IS_ERR(tgt)) + return PTR_ERR(tgt); + rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg); + } else { + /* split fid list to their respective MDS */ + for (i = 0; i < count; i++) { + unsigned int nr, reqlen; + int rc1; + struct hsm_user_request *req; + + nr = lmv_hsm_req_count(lmv, hur, lmv->tgts[i]); + if (nr == 0) /* nothing for this MDS */ + continue; + + /* build a request with fids for this MDS */ + reqlen = offsetof(typeof(*hur), + hur_user_item[nr]) + + hur->hur_request.hr_data_len; + OBD_ALLOC_LARGE(req, reqlen); + if (req == NULL) + return -ENOMEM; + + lmv_hsm_req_build(lmv, hur, lmv->tgts[i], req); + + rc1 = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, + reqlen, req, uarg); + if (rc1 != 0 && rc == 0) + rc = rc1; + OBD_FREE_LARGE(req, reqlen); + } + } + break; + } case LL_IOC_LOV_SWAP_LAYOUTS: { struct md_op_data *op_data = karg; struct lmv_tgt_desc *tgt1, *tgt2; tgt1 = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt1)) - RETURN(PTR_ERR(tgt1)); + return PTR_ERR(tgt1); tgt2 = lmv_find_target(lmv, &op_data->op_fid2); if (IS_ERR(tgt2)) - RETURN(PTR_ERR(tgt2)); + return PTR_ERR(tgt2); if ((tgt1->ltd_exp == NULL) || (tgt2->ltd_exp == NULL)) - RETURN(-EINVAL); + return -EINVAL; /* only files on same MDT can have their layouts swapped */ if (tgt1->ltd_idx != tgt2->ltd_idx) - RETURN(-EPERM); + return -EPERM; rc = obd_iocontrol(cmd, tgt1->ltd_exp, len, karg, uarg); break; } + case LL_IOC_HSM_CT_START: { + struct lustre_kernelcomm *lk = karg; + if (lk->lk_flags & LK_FLG_STOP) + rc = lmv_hsm_ct_unregister(lmv, cmd, len, lk, uarg); + else + rc = lmv_hsm_ct_register(lmv, cmd, len, lk, uarg); + break; + } default: for (i = 0; i < count; i++) { struct obd_device *mdc_obd; @@ -946,7 +1130,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, err = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, len, karg, uarg); if (err == -ENODATA && cmd == OBD_IOC_POLL_QUOTACHECK) { - RETURN(err); + return err; } else if (err) { if (lmv->tgts[i]->ltd_active) { CERROR("error: iocontrol MDC %s on MDT" @@ -962,7 +1146,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, if (!set && !rc) rc = -EIO; } - RETURN(rc); + return rc; } #if 0 @@ -1018,13 +1202,12 @@ static int lmv_placement_policy(struct obd_device *obd, mdsno_t *mds) { struct lmv_obd *lmv = &obd->u.lmv; - ENTRY; LASSERT(mds != NULL); if (lmv->desc.ld_tgt_count == 1) { *mds = 0; - RETURN(0); + return 0; } /** @@ -1042,17 +1225,17 @@ static int lmv_placement_policy(struct obd_device *obd, " rc = %d\n", obd->obd_name, lum->lum_stripe_offset, lmv->desc.ld_tgt_count, -ERANGE); - RETURN(-ERANGE); + return -ERANGE; } *mds = lum->lum_stripe_offset; - RETURN(0); + return 0; } } /* Allocate new fid on target according to operation type and parent * home mds. */ *mds = op_data->op_mds; - RETURN(0); + return 0; } int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid, @@ -1060,11 +1243,10 @@ int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid, { struct lmv_tgt_desc *tgt; int rc; - ENTRY; tgt = lmv_get_target(lmv, mds); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); /* * New seq alloc and FLD setup should be atomic. Otherwise we may find @@ -1084,7 +1266,6 @@ int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid, rc = 0; } - EXIT; out: mutex_unlock(&tgt->ltd_fid_mutex); return rc; @@ -1097,7 +1278,6 @@ int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, struct lmv_obd *lmv = &obd->u.lmv; mdsno_t mds = 0; int rc; - ENTRY; LASSERT(op_data != NULL); LASSERT(fid != NULL); @@ -1106,16 +1286,16 @@ int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, if (rc) { CERROR("Can't get target for allocating fid, " "rc %d\n", rc); - RETURN(rc); + return rc; } rc = __lmv_fid_alloc(lmv, fid, mds); if (rc) { CERROR("Can't alloc new fid, rc %d\n", rc); - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) @@ -1124,23 +1304,22 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) struct lprocfs_static_vars lvars; struct lmv_desc *desc; int rc; - ENTRY; if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) { CERROR("LMV setup requires a descriptor\n"); - RETURN(-EINVAL); + return -EINVAL; } desc = (struct lmv_desc *)lustre_cfg_buf(lcfg, 1); if (sizeof(*desc) > LUSTRE_CFG_BUFLEN(lcfg, 1)) { CERROR("Lmv descriptor size wrong: %d > %d\n", (int)sizeof(*desc), LUSTRE_CFG_BUFLEN(lcfg, 1)); - RETURN(-EINVAL); + return -EINVAL; } OBD_ALLOC(lmv->tgts, sizeof(*lmv->tgts) * 32); if (lmv->tgts == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lmv->tgts_size = 32; obd_str2uuid(&lmv->desc.ld_uuid, desc->ld_uuid.uuid); @@ -1173,7 +1352,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) GOTO(out, rc); } - RETURN(0); + return 0; out: return rc; @@ -1182,7 +1361,6 @@ out: static int lmv_cleanup(struct obd_device *obd) { struct lmv_obd *lmv = &obd->u.lmv; - ENTRY; fld_client_fini(&lmv->lmv_fld); if (lmv->tgts != NULL) { @@ -1195,7 +1373,7 @@ static int lmv_cleanup(struct obd_device *obd) OBD_FREE(lmv->tgts, sizeof(*lmv->tgts) * lmv->tgts_size); lmv->tgts_size = 0; } - RETURN(0); + return 0; } static int lmv_process_config(struct obd_device *obd, obd_count len, void *buf) @@ -1205,7 +1383,6 @@ static int lmv_process_config(struct obd_device *obd, obd_count len, void *buf) int gen; __u32 index; int rc; - ENTRY; switch (lcfg->lcfg_command) { case LCFG_ADD_MDC: @@ -1227,7 +1404,7 @@ static int lmv_process_config(struct obd_device *obd, obd_count len, void *buf) GOTO(out, rc = -EINVAL); } out: - RETURN(rc); + return rc; } static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, @@ -1238,15 +1415,14 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *temp; int rc = 0; int i; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; OBD_ALLOC(temp, sizeof(*temp)); if (temp == NULL) - RETURN(-ENOMEM); + return -ENOMEM; for (i = 0; i < lmv->desc.ld_tgt_count; i++) { if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL) @@ -1279,7 +1455,6 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, } } - EXIT; out_free_temp: OBD_FREE(temp, sizeof(*temp)); return rc; @@ -1292,14 +1467,13 @@ static int lmv_getstatus(struct obd_export *exp, struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; rc = md_getstatus(lmv->tgts[0]->ltd_exp, fid, pc); - RETURN(rc); + return rc; } static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid, @@ -1311,20 +1485,19 @@ static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_getxattr(tgt->ltd_exp, fid, oc, valid, name, input, input_size, output_size, flags, request); - RETURN(rc); + return rc; } static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid, @@ -1337,21 +1510,20 @@ static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_setxattr(tgt->ltd_exp, fid, oc, valid, name, input, input_size, output_size, flags, suppgid, request); - RETURN(rc); + return rc; } static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data, @@ -1361,24 +1533,23 @@ static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); if (op_data->op_flags & MF_GET_MDT_IDX) { op_data->op_mds = tgt->ltd_idx; - RETURN(0); + return 0; } rc = md_getattr(tgt->ltd_exp, op_data, request); - RETURN(rc); + return rc; } static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid) @@ -1387,11 +1558,10 @@ static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid) struct lmv_obd *lmv = &obd->u.lmv; int i; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid)); @@ -1406,7 +1576,7 @@ static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid) md_null_inode(lmv->tgts[i]->ltd_exp, fid); } - RETURN(0); + return 0; } static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid, @@ -1416,11 +1586,10 @@ static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid, struct lmv_obd *lmv = &obd->u.lmv; int i; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid)); @@ -1434,10 +1603,10 @@ static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid, continue; rc = md_find_cbdata(lmv->tgts[i]->ltd_exp, fid, it, data); if (rc) - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } @@ -1448,19 +1617,18 @@ static int lmv_close(struct obd_export *exp, struct md_op_data *op_data, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); CDEBUG(D_INODE, "CLOSE "DFID"\n", PFID(&op_data->op_fid1)); rc = md_close(tgt->ltd_exp, op_data, mod, request); - RETURN(rc); + return rc; } struct lmv_tgt_desc @@ -1487,22 +1655,21 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; if (!lmv->desc.ld_active_tgt_count) - RETURN(-EIO); + return -EIO; tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = lmv_fid_alloc(exp, &op_data->op_fid2, op_data); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INODE, "CREATE '%*s' on "DFID" -> mds #%x\n", op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1), @@ -1514,10 +1681,10 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data, if (rc == 0) { if (*request == NULL) - RETURN(rc); + return rc; CDEBUG(D_INODE, "Created - "DFID"\n", PFID(&op_data->op_fid2)); } - RETURN(rc); + return rc; } static int lmv_done_writing(struct obd_export *exp, @@ -1528,18 +1695,17 @@ static int lmv_done_writing(struct obd_export *exp, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_done_writing(tgt->ltd_exp, op_data, mod); - RETURN(rc); + return rc; } static int @@ -1558,13 +1724,12 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, struct mdt_body *body; int rc = 0; int pmode; - ENTRY; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); LASSERT(body != NULL); if (!(body->valid & OBD_MD_MDS)) - RETURN(0); + return 0; CDEBUG(D_INODE, "REMOTE_ENQUEUE '%s' on "DFID" -> "DFID"\n", LL_IT2STR(it), PFID(&op_data->op_fid1), PFID(&body->fid1)); @@ -1596,7 +1761,6 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh, lmm, lmmsize, NULL, extra_lock_flags); OBD_FREE_PTR(rdata); - EXIT; out: ldlm_lock_decref(&plock, pmode); return rc; @@ -1612,18 +1776,17 @@ lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID"\n", LL_IT2STR(it), PFID(&op_data->op_fid1)); tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID" -> mds #%d\n", LL_IT2STR(it), PFID(&op_data->op_fid1), tgt->ltd_idx); @@ -1635,7 +1798,7 @@ lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, rc = lmv_enqueue_remote(exp, einfo, it, op_data, lockh, lmm, lmmsize, extra_lock_flags); } - RETURN(rc); + return rc; } static int @@ -1648,15 +1811,14 @@ lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data, struct lmv_tgt_desc *tgt; struct mdt_body *body; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); CDEBUG(D_INODE, "GETATTR_NAME for %*s on "DFID" -> mds #%d\n", op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1), @@ -1664,7 +1826,7 @@ lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data, rc = md_getattr_name(tgt->ltd_exp, op_data, request); if (rc != 0) - RETURN(rc); + return rc; body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY); @@ -1678,7 +1840,7 @@ lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data, tgt = lmv_find_target(lmv, &rid); if (IS_ERR(tgt)) { ptlrpc_req_finished(*request); - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); } op_data->op_fid1 = rid; @@ -1690,7 +1852,7 @@ lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data, *request = req; } - RETURN(rc); + return rc; } #define md_op_data_fid(op_data, fl) \ @@ -1709,14 +1871,13 @@ static int lmv_early_cancel(struct obd_export *exp, struct md_op_data *op_data, struct lmv_tgt_desc *tgt; ldlm_policy_data_t policy = {{0}}; int rc = 0; - ENTRY; if (!fid_is_sane(fid)) - RETURN(0); + return 0; tgt = lmv_find_target(lmv, fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); if (tgt->ltd_idx != op_tgt) { CDEBUG(D_INODE, "EARLY_CANCEL on "DFID"\n", PFID(fid)); @@ -1731,7 +1892,7 @@ static int lmv_early_cancel(struct obd_export *exp, struct md_op_data *op_data, rc = 0; } - RETURN(rc); + return rc; } /* @@ -1745,11 +1906,10 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; LASSERT(op_data->op_namelen != 0); @@ -1757,12 +1917,12 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data, PFID(&op_data->op_fid2), op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1)); - op_data->op_fsuid = current_fsuid(); - op_data->op_fsgid = current_fsgid(); + 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(); tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); /* * Cancel UPDATE lock on child (fid1). @@ -1771,11 +1931,11 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_early_cancel(exp, op_data, tgt->ltd_idx, LCK_EX, MDS_INODELOCK_UPDATE, MF_MDC_CANCEL_FID1); if (rc != 0) - RETURN(rc); + return rc; rc = md_link(tgt->ltd_exp, op_data, request); - RETURN(rc); + return rc; } static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, @@ -1787,7 +1947,6 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, struct lmv_tgt_desc *src_tgt; struct lmv_tgt_desc *tgt_tgt; int rc; - ENTRY; LASSERT(oldlen != 0); @@ -1797,18 +1956,18 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; - op_data->op_fsuid = current_fsuid(); - op_data->op_fsgid = current_fsgid(); + 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(); src_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(src_tgt)) - RETURN(PTR_ERR(src_tgt)); + return PTR_ERR(src_tgt); tgt_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2); if (IS_ERR(tgt_tgt)) - RETURN(PTR_ERR(tgt_tgt)); + return PTR_ERR(tgt_tgt); /* * LOOKUP lock on src child (fid3) should also be cancelled for * src_tgt in mdc_rename. @@ -1843,7 +2002,7 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, if (rc == 0) rc = md_rename(src_tgt->ltd_exp, op_data, old, oldlen, new, newlen, request); - RETURN(rc); + return rc; } static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data, @@ -1855,11 +2014,10 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc = 0; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INODE, "SETATTR for "DFID", valid 0x%x\n", PFID(&op_data->op_fid1), op_data->op_attr.ia_valid); @@ -1867,12 +2025,12 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data, op_data->op_flags |= MF_MDC_CANCEL_FID1; tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_setattr(tgt->ltd_exp, op_data, ea, ealen, ea2, ea2len, request, mod); - RETURN(rc); + return rc; } static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid, @@ -1882,18 +2040,17 @@ static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_sync(tgt->ltd_exp, fid, oc, request); - RETURN(rc); + return rc; } /* @@ -1959,7 +2116,7 @@ static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs) __u64 hash_end = dp->ldp_hash_end; __u32 flags = dp->ldp_flags; - for (; nlupgs > 1; nlupgs--) { + while (--nlupgs > 0) { ent = lu_dirent_start(dp); for (end_dirent = ent; ent != NULL; end_dirent = ent, ent = lu_dirent_next(ent)); @@ -1993,6 +2150,7 @@ static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs) kunmap(pages[i]); } + LASSERTF(nlupgs == 0, "left = %d", nlupgs); } #else #define lmv_adjust_dirpages(pages, ncfspgs, nlupgs) do {} while (0) @@ -2008,22 +2166,21 @@ static int lmv_readpage(struct obd_export *exp, struct md_op_data *op_data, int ncfspgs; /* pages read in PAGE_CACHE_SIZE */ int nlupgs; /* pages read in LU_PAGE_SIZE */ struct lmv_tgt_desc *tgt; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INODE, "READPAGE at "LPX64" from "DFID"\n", offset, PFID(&op_data->op_fid1)); tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_readpage(tgt->ltd_exp, op_data, pages, request); if (rc != 0) - RETURN(rc); + return rc; ncfspgs = ((*request)->rq_bulk->bd_nob_transferred + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; @@ -2036,7 +2193,7 @@ static int lmv_readpage(struct obd_export *exp, struct md_op_data *op_data, lmv_adjust_dirpages(pages, ncfspgs, nlupgs); - RETURN(rc); + return rc; } static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data, @@ -2047,11 +2204,10 @@ static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data, struct lmv_tgt_desc *tgt = NULL; struct mdt_body *body; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; retry: /* Send unlink requests to the MDT where the child is located */ if (likely(!fid_is_zero(&op_data->op_fid2))) @@ -2059,10 +2215,10 @@ retry: else tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); - op_data->op_fsuid = current_fsuid(); - op_data->op_fsgid = current_fsgid(); + 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(); /* @@ -2081,22 +2237,22 @@ retry: MDS_INODELOCK_FULL, MF_MDC_CANCEL_FID3); if (rc != 0) - RETURN(rc); + return rc; CDEBUG(D_INODE, "unlink with fid="DFID"/"DFID" -> mds #%d\n", PFID(&op_data->op_fid1), PFID(&op_data->op_fid2), tgt->ltd_idx); rc = md_unlink(tgt->ltd_exp, op_data, request); if (rc != 0 && rc != -EREMOTE) - RETURN(rc); + return rc; body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY); if (body == NULL) - RETURN(-EPROTO); + return -EPROTO; /* Not cross-ref case, just get out of here. */ if (likely(!(body->valid & OBD_MD_MDS))) - RETURN(0); + return 0; CDEBUG(D_INODE, "%s: try unlink to another MDT for "DFID"\n", exp->exp_obd->obd_name, PFID(&body->fid1)); @@ -2144,7 +2300,7 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) default: break; } - RETURN(rc); + return rc; } static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, @@ -2154,13 +2310,12 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd; struct lmv_obd *lmv; int rc = 0; - ENTRY; obd = class_exp2obd(exp); if (obd == NULL) { CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); - RETURN(-EINVAL); + return -EINVAL; } lmv = &obd->u.lmv; @@ -2170,7 +2325,7 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; LASSERT(*vallen == sizeof(__u32)); for (i = 0; i < lmv->desc.ld_tgt_count; i++) { @@ -2183,13 +2338,13 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, if (!obd_get_info(env, tgt->ltd_exp, keylen, key, vallen, val, NULL)) - RETURN(0); + return 0; } - RETURN(-EINVAL); + return -EINVAL; } else if (KEY_IS(KEY_MAX_EASIZE) || KEY_IS(KEY_CONN_DATA)) { rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; /* * Forwarding this request to first MDS, it should know LOV @@ -2199,14 +2354,14 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, vallen, val, NULL); if (!rc && KEY_IS(KEY_CONN_DATA)) exp->exp_connect_data = *(struct obd_connect_data *)val; - RETURN(rc); + return rc; } else if (KEY_IS(KEY_TGT_COUNT)) { *((int *)val) = lmv->desc.ld_tgt_count; - RETURN(0); + return 0; } CDEBUG(D_IOCTL, "Invalid key\n"); - RETURN(-EINVAL); + return -EINVAL; } int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, @@ -2217,13 +2372,12 @@ int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd; struct lmv_obd *lmv; int rc = 0; - ENTRY; obd = class_exp2obd(exp); if (obd == NULL) { CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); - RETURN(-EINVAL); + return -EINVAL; } lmv = &obd->u.lmv; @@ -2242,10 +2396,10 @@ int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, rc = err; } - RETURN(rc); + return rc; } - RETURN(-EINVAL); + return -EINVAL; } int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, @@ -2257,33 +2411,32 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, struct lmv_stripe_md *lsmp; int mea_size; int i; - ENTRY; mea_size = lmv_get_easize(lmv); if (!lmmp) - RETURN(mea_size); + return mea_size; if (*lmmp && !lsm) { OBD_FREE_LARGE(*lmmp, mea_size); *lmmp = NULL; - RETURN(0); + return 0; } if (*lmmp == NULL) { OBD_ALLOC_LARGE(*lmmp, mea_size); if (*lmmp == NULL) - RETURN(-ENOMEM); + return -ENOMEM; } if (!lsm) - RETURN(mea_size); + return mea_size; lsmp = (struct lmv_stripe_md *)lsm; meap = (struct lmv_stripe_md *)*lmmp; if (lsmp->mea_magic != MEA_MAGIC_LAST_CHAR && lsmp->mea_magic != MEA_MAGIC_ALL_CHARS) - RETURN(-EINVAL); + return -EINVAL; meap->mea_magic = cpu_to_le32(lsmp->mea_magic); meap->mea_count = cpu_to_le32(lsmp->mea_count); @@ -2294,7 +2447,7 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, fid_cpu_to_le(&meap->mea_ids[i], &lsmp->mea_ids[i]); } - RETURN(mea_size); + return mea_size; } int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, @@ -2307,7 +2460,6 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, int mea_size; int i; __u32 magic; - ENTRY; mea_size = lmv_get_easize(lmv); if (lsmp == NULL) @@ -2316,17 +2468,17 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, if (*lsmp != NULL && lmm == NULL) { OBD_FREE_LARGE(*tmea, mea_size); *lsmp = NULL; - RETURN(0); + return 0; } LASSERT(mea_size == lmm_size); OBD_ALLOC_LARGE(*tmea, mea_size); if (*tmea == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (!lmm) - RETURN(mea_size); + return mea_size; if (mea->mea_magic == MEA_MAGIC_LAST_CHAR || mea->mea_magic == MEA_MAGIC_ALL_CHARS || @@ -2349,7 +2501,7 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, (*tmea)->mea_ids[i] = mea->mea_ids[i]; fid_le_to_cpu(&(*tmea)->mea_ids[i], &(*tmea)->mea_ids[i]); } - RETURN(mea_size); + return mea_size; } static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, @@ -2361,7 +2513,6 @@ static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, int rc = 0; int err; int i; - ENTRY; LASSERT(fid != NULL); @@ -2375,7 +2526,7 @@ static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, if (!rc) rc = err; } - RETURN(rc); + return rc; } int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, @@ -2383,10 +2534,9 @@ int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, { struct lmv_obd *lmv = &exp->exp_obd->u.lmv; int rc; - ENTRY; rc = md_set_lock_data(lmv->tgts[0]->ltd_exp, lockh, data, bits); - RETURN(rc); + return rc; } ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags, @@ -2398,7 +2548,6 @@ ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags, struct lmv_obd *lmv = &obd->u.lmv; ldlm_mode_t rc; int i; - ENTRY; CDEBUG(D_INODE, "Lock match for "DFID"\n", PFID(fid)); @@ -2417,10 +2566,10 @@ ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags, rc = md_lock_match(lmv->tgts[i]->ltd_exp, flags, fid, type, policy, mode, lockh); if (rc) - RETURN(rc); + return rc; } - RETURN(0); + return 0; } int lmv_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, @@ -2436,11 +2585,10 @@ int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - ENTRY; if (md->mea) obd_free_memmd(exp, (void *)&md->mea); - RETURN(md_free_lustre_md(lmv->tgts[0]->ltd_exp, md)); + return md_free_lustre_md(lmv->tgts[0]->ltd_exp, md); } int lmv_set_open_replay_data(struct obd_export *exp, @@ -2450,13 +2598,12 @@ int lmv_set_open_replay_data(struct obd_export *exp, struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; - ENTRY; tgt = lmv_find_target(lmv, &och->och_fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); - RETURN(md_set_open_replay_data(tgt->ltd_exp, och, open_req)); + return md_set_open_replay_data(tgt->ltd_exp, och, open_req); } int lmv_clear_open_replay_data(struct obd_export *exp, @@ -2465,13 +2612,12 @@ int lmv_clear_open_replay_data(struct obd_export *exp, struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; - ENTRY; tgt = lmv_find_target(lmv, &och->och_fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); - RETURN(md_clear_open_replay_data(tgt->ltd_exp, och)); + return md_clear_open_replay_data(tgt->ltd_exp, och); } static int lmv_get_remote_perm(struct obd_export *exp, @@ -2483,18 +2629,17 @@ static int lmv_get_remote_perm(struct obd_export *exp, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_get_remote_perm(tgt->ltd_exp, fid, oc, suppgid, request); - RETURN(rc); + return rc; } static int lmv_renew_capa(struct obd_export *exp, struct obd_capa *oc, @@ -2504,18 +2649,17 @@ static int lmv_renew_capa(struct obd_export *exp, struct obd_capa *oc, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, &oc->c_capa.lc_fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_renew_capa(tgt->ltd_exp, oc, cb); - RETURN(rc); + return rc; } int lmv_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req, @@ -2535,18 +2679,17 @@ int lmv_intent_getattr_async(struct obd_export *exp, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt = NULL; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_intent_getattr_async(tgt->ltd_exp, minfo, einfo); - RETURN(rc); + return rc; } int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, @@ -2556,18 +2699,17 @@ int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_revalidate_lock(tgt->ltd_exp, it, fid, bits); - RETURN(rc); + return rc; } /** @@ -2583,16 +2725,15 @@ int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, struct lmv_tgt_desc *tgt = lmv->tgts[0]; int rc = 0, i; __u64 curspace, curinodes; - ENTRY; if (!lmv->desc.ld_tgt_count || !tgt->ltd_active) { CERROR("master lmv inactive\n"); - RETURN(-EIO); + return -EIO; } if (oqctl->qc_cmd != Q_GETOQUOTA) { rc = obd_quotactl(tgt->ltd_exp, oqctl); - RETURN(rc); + return rc; } curspace = curinodes = 0; @@ -2620,7 +2761,7 @@ int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, oqctl->qc_dqblk.dqb_curspace = curspace; oqctl->qc_dqblk.dqb_curinodes = curinodes; - RETURN(rc); + return rc; } int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp, @@ -2630,14 +2771,13 @@ int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int i, rc = 0; - ENTRY; for (i = 0; i < lmv->desc.ld_tgt_count; i++) { int err; tgt = lmv->tgts[i]; if (tgt == NULL || tgt->ltd_exp == NULL || !tgt->ltd_active) { CERROR("lmv idx %d inactive\n", i); - RETURN(-EIO); + return -EIO; } err = obd_quotacheck(tgt->ltd_exp, oqctl); @@ -2645,7 +2785,7 @@ int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp, rc = err; } - RETURN(rc); + return rc; } struct obd_ops lmv_obd_ops = { diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index d1c45b583cb..edb5a3a99d5 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -36,7 +36,6 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include <linux/version.h> #include <linux/seq_file.h> #include <asm/statfs.h> #include <lprocfs_status.h> diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h index 28801b8b5fd..33d9ce68fed 100644 --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h @@ -162,10 +162,9 @@ struct lov_device { * Layout type. */ enum lov_layout_type { - /** empty file without body */ - LLT_EMPTY, - /** striped file */ - LLT_RAID0, + LLT_EMPTY, /** empty file without body (mknod + truncate) */ + LLT_RAID0, /** striped file */ + LLT_RELEASED, /** file with no objects (data in HSM) */ LLT_NR }; @@ -255,12 +254,14 @@ struct lov_object { } raid0; struct lov_layout_state_empty { } empty; + struct lov_layout_state_released { + } released; } u; /** * Thread that acquired lov_object::lo_type_guard in an exclusive * mode. */ - task_t *lo_owner; + struct task_struct *lo_owner; }; /** @@ -582,6 +583,8 @@ int lov_io_init_raid0 (const struct lu_env *env, struct cl_object *obj, struct cl_io *io); int lov_io_init_empty (const struct lu_env *env, struct cl_object *obj, struct cl_io *io); +int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, + struct cl_io *io); void lov_lock_unlink (const struct lu_env *env, struct lov_lock_link *link, struct lovsub_lock *sub); diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index f94f8d9d33d..a4006ef46ad 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -122,10 +122,8 @@ static void lov_req_completion(const struct lu_env *env, { struct lov_req *lr; - ENTRY; lr = cl2lov_req(slice); OBD_SLAB_FREE_PTR(lr, lov_req_kmem); - EXIT; } static const struct cl_req_operations lov_req_ops = { @@ -200,7 +198,7 @@ static struct lu_device *lov_device_fini(const struct lu_env *env, LASSERT(ld->ld_lov != NULL); if (ld->ld_target == NULL) - RETURN(NULL); + return NULL; lov_foreach_target(ld, i) { struct lovsub_device *lsd; @@ -211,7 +209,7 @@ static struct lu_device *lov_device_fini(const struct lu_env *env, ld->ld_target[i] = NULL; } } - RETURN(NULL); + return NULL; } static int lov_device_init(const struct lu_env *env, struct lu_device *d, @@ -223,7 +221,7 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d, LASSERT(d->ld_site != NULL); if (ld->ld_target == NULL) - RETURN(rc); + return rc; lov_foreach_target(ld, i) { struct lovsub_device *lsd; @@ -251,7 +249,7 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d, else ld->ld_flags |= LOV_DEV_INITIALIZED; - RETURN(rc); + return rc; } static int lov_req_init(const struct lu_env *env, struct cl_device *dev, @@ -260,14 +258,13 @@ static int lov_req_init(const struct lu_env *env, struct cl_device *dev, struct lov_req *lr; int result; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lr, lov_req_kmem, __GFP_IO); if (lr != NULL) { cl_req_slice_add(req, &lr->lr_cl, dev, &lov_req_ops); result = 0; } else result = -ENOMEM; - RETURN(result); + return result; } static const struct cl_device_operations lov_cl_ops = { @@ -311,13 +308,11 @@ static void lov_cl_del_target(const struct lu_env *env, struct lu_device *dev, __u32 index) { struct lov_device *ld = lu2lov_dev(dev); - ENTRY; if (ld->ld_target[index] != NULL) { cl_stack_fini(env, lovsub2cl_dev(ld->ld_target[index])); ld->ld_target[index] = NULL; } - EXIT; } static struct lov_device_emerg **lov_emerg_alloc(int nr) @@ -360,7 +355,6 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) __u32 tgt_size; __u32 sub_size; - ENTRY; result = 0; tgt_size = dev->ld_lov->lov_tgt_size; sub_size = dev->ld_target_nr; @@ -371,7 +365,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) emerg = lov_emerg_alloc(tgt_size); if (IS_ERR(emerg)) - RETURN(PTR_ERR(emerg)); + return PTR_ERR(emerg); OBD_ALLOC(newd, tgt_size * sz); if (newd != NULL) { @@ -392,7 +386,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) result = -ENOMEM; } } - RETURN(result); + return result; } static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, @@ -404,7 +398,6 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, struct lovsub_device *lsd; struct cl_device *cl; int rc; - ENTRY; obd_getref(obd); @@ -414,7 +407,7 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, if (!tgt->ltd_obd->obd_set_up) { CERROR("Target %s not set up\n", obd_uuid2str(&tgt->ltd_uuid)); - RETURN(-EINVAL); + return -EINVAL; } rc = lov_expand_targets(env, ld); @@ -436,7 +429,7 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, } } obd_putref(obd); - RETURN(rc); + return rc; } static int lov_process_config(const struct lu_env *env, @@ -466,7 +459,7 @@ static int lov_process_config(const struct lu_env *env, } } obd_putref(obd); - RETURN(rc); + return rc; } static const struct lu_device_operations lov_lu_ops = { @@ -485,7 +478,7 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env, OBD_ALLOC_PTR(ld); if (ld == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); cl_device_init(&ld->ld_cl, t); d = lov2lu_dev(ld); @@ -501,11 +494,11 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env, rc = lov_setup(obd, cfg); if (rc) { lov_device_free(env, d); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } ld->ld_lov = &obd->u.lov; - RETURN(d); + return d; } static const struct lu_device_type_operations lov_device_type_ops = { diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 340dbcf829e..e6c60151dc6 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -57,7 +57,7 @@ struct lovea_unpack_args { static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes, __u16 stripe_count) { - if (stripe_count == 0 || stripe_count > LOV_V1_INSANE_STRIPE_COUNT) { + if (stripe_count > LOV_V1_INSANE_STRIPE_COUNT) { CERROR("bad stripe count %d\n", stripe_count); lov_dump_lmm_common(D_WARNING, lmm); return -EINVAL; @@ -69,7 +69,7 @@ static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes, return -EINVAL; } - if (lmm->lmm_pattern != cpu_to_le32(LOV_PATTERN_RAID0)) { + if (lov_pattern(le32_to_cpu(lmm->lmm_pattern)) != LOV_PATTERN_RAID0) { CERROR("bad striping pattern\n"); lov_dump_lmm_common(D_WARNING, lmm); return -EINVAL; @@ -197,6 +197,8 @@ static int lsm_lmm_verify_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes, } *stripe_count = le16_to_cpu(lmm->lmm_stripe_count); + if (le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED) + *stripe_count = 0; if (lmm_bytes < lov_mds_md_size(*stripe_count, LOV_MAGIC_V1)) { CERROR("LOV EA V1 too small: %d, need %d\n", @@ -213,11 +215,14 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, { struct lov_oinfo *loi; int i; + int stripe_count; __u64 stripe_maxbytes = OBD_OBJECT_EOF; lsm_unpackmd_common(lsm, lmm); - for (i = 0; i < lsm->lsm_stripe_count; i++) { + stripe_count = lsm_is_released(lsm) ? 0 : lsm->lsm_stripe_count; + + for (i = 0; i < stripe_count; i++) { /* XXX LOV STACKING call down to osc_unpackmd() */ loi = lsm->lsm_oinfo[i]; ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi); @@ -240,6 +245,8 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, } lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count; + if (lsm->lsm_stripe_count == 0) + lsm->lsm_maxbytes = stripe_maxbytes * lov->desc.ld_tgt_count; return 0; } @@ -267,6 +274,8 @@ static int lsm_lmm_verify_v3(struct lov_mds_md *lmmv1, int lmm_bytes, } *stripe_count = le16_to_cpu(lmm->lmm_stripe_count); + if (le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED) + *stripe_count = 0; if (lmm_bytes < lov_mds_md_size(*stripe_count, LOV_MAGIC_V3)) { CERROR("LOV EA V3 too small: %d, need %d\n", @@ -285,18 +294,22 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm, struct lov_mds_md_v3 *lmm; struct lov_oinfo *loi; int i; + int stripe_count; __u64 stripe_maxbytes = OBD_OBJECT_EOF; int cplen = 0; lmm = (struct lov_mds_md_v3 *)lmmv1; lsm_unpackmd_common(lsm, (struct lov_mds_md_v1 *)lmm); + + stripe_count = lsm_is_released(lsm) ? 0 : lsm->lsm_stripe_count; + cplen = strlcpy(lsm->lsm_pool_name, lmm->lmm_pool_name, sizeof(lsm->lsm_pool_name)); if (cplen >= sizeof(lsm->lsm_pool_name)) return -E2BIG; - for (i = 0; i < lsm->lsm_stripe_count; i++) { + for (i = 0; i < stripe_count; i++) { /* XXX LOV STACKING call down to osc_unpackmd() */ loi = lsm->lsm_oinfo[i]; ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi); @@ -319,6 +332,8 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm, } lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count; + if (lsm->lsm_stripe_count == 0) + lsm->lsm_maxbytes = stripe_maxbytes * lov->desc.ld_tgt_count; return 0; } diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index 1a87abdf095..b611aa4e9dc 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -59,7 +59,6 @@ static inline void lov_sub_exit(struct lov_io_sub *sub) static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio, struct lov_io_sub *sub) { - ENTRY; if (sub->sub_io != NULL) { if (sub->sub_io_initialized) { lov_sub_enter(sub); @@ -79,7 +78,6 @@ static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio, cl_env_put(sub->sub_env, &sub->sub_refcheck); sub->sub_env = NULL; } - EXIT; } static void lov_io_sub_inherit(struct cl_io *io, struct lov_io *lio, @@ -149,7 +147,6 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, LASSERT(sub->sub_io == NULL); LASSERT(sub->sub_env == NULL); LASSERT(sub->sub_stripe < lio->lis_stripe_count); - ENTRY; result = 0; sub->sub_io_initialized = 0; @@ -210,7 +207,7 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, } if (result != 0) lov_io_sub_fini(env, lio, sub); - RETURN(result); + return result; } struct lov_io_sub *lov_sub_get(const struct lu_env *env, @@ -220,7 +217,6 @@ struct lov_io_sub *lov_sub_get(const struct lu_env *env, struct lov_io_sub *sub = &lio->lis_subs[stripe]; LASSERT(stripe < lio->lis_stripe_count); - ENTRY; if (!sub->sub_io_initialized) { sub->sub_stripe = stripe; @@ -231,7 +227,7 @@ struct lov_io_sub *lov_sub_get(const struct lu_env *env, lov_sub_enter(sub); else sub = ERR_PTR(rc); - RETURN(sub); + return sub; } void lov_sub_put(struct lov_io_sub *sub) @@ -249,12 +245,11 @@ static int lov_page_stripe(const struct cl_page *page) { struct lovsub_object *subobj; - ENTRY; subobj = lu2lovsub( lu_object_locate(page->cp_child->cp_obj->co_lu.lo_header, &lovsub_device_type)); LASSERT(subobj != NULL); - RETURN(subobj->lso_index); + return subobj->lso_index; } struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio, @@ -268,10 +263,9 @@ struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio, LASSERT(cl2lov(slice->cpl_obj) == lio->lis_object); LASSERT(lsm != NULL); LASSERT(lio->lis_nr_subios > 0); - ENTRY; stripe = lov_page_stripe(page); - RETURN(lov_sub_get(env, lio, stripe)); + return lov_sub_get(env, lio, stripe); } @@ -282,7 +276,6 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, int result; LASSERT(lio->lis_object != NULL); - ENTRY; /* * Need to be optimized, we can't afford to allocate a piece of memory @@ -297,14 +290,12 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, result = 0; } else result = -ENOMEM; - RETURN(result); + return result; } static void lov_io_slice_init(struct lov_io *lio, struct lov_object *obj, struct cl_io *io) { - ENTRY; - io->ci_result = 0; lio->lis_object = obj; @@ -353,8 +344,6 @@ static void lov_io_slice_init(struct lov_io *lio, default: LBUG(); } - - EXIT; } static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) @@ -363,7 +352,6 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) struct lov_object *lov = cl2lov(ios->cis_obj); int i; - ENTRY; if (lio->lis_subs != NULL) { for (i = 0; i < lio->lis_nr_subios; i++) lov_io_sub_fini(env, lio, &lio->lis_subs[i]); @@ -375,7 +363,6 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) LASSERT(atomic_read(&lov->lo_active_ios) > 0); if (atomic_dec_and_test(&lov->lo_active_ios)) wake_up_all(&lov->lo_waitq); - EXIT; } static obd_off lov_offset_mod(obd_off val, int delta) @@ -397,7 +384,6 @@ static int lov_io_iter_init(const struct lu_env *env, int stripe; int rc = 0; - ENTRY; endpos = lov_offset_mod(lio->lis_endpos, -1); for (stripe = 0; stripe < lio->lis_stripe_count; stripe++) { if (!lov_stripe_intersects(lsm, stripe, lio->lis_pos, @@ -421,7 +407,7 @@ static int lov_io_iter_init(const struct lu_env *env, else break; } - RETURN(rc); + return rc; } static int lov_io_rw_iter_init(const struct lu_env *env, @@ -430,12 +416,11 @@ static int lov_io_rw_iter_init(const struct lu_env *env, struct lov_io *lio = cl2lov_io(env, ios); struct cl_io *io = ios->cis_io; struct lov_stripe_md *lsm = lio->lis_object->lo_lsm; - loff_t start = io->u.ci_rw.crw_pos; + __u64 start = io->u.ci_rw.crw_pos; loff_t next; unsigned long ssize = lsm->lsm_stripe_size; LASSERT(io->ci_type == CIT_READ || io->ci_type == CIT_WRITE); - ENTRY; /* fast path for common case. */ if (lio->lis_nr_subios != 1 && !cl_io_is_append(io)) { @@ -458,7 +443,7 @@ static int lov_io_rw_iter_init(const struct lu_env *env, * XXX The following call should be optimized: we know, that * [lio->lis_pos, lio->lis_endpos) intersects with exactly one stripe. */ - RETURN(lov_io_iter_init(env, ios)); + return lov_io_iter_init(env, ios); } static int lov_io_call(const struct lu_env *env, struct lov_io *lio, @@ -468,7 +453,6 @@ static int lov_io_call(const struct lu_env *env, struct lov_io *lio, struct lov_io_sub *sub; int rc = 0; - ENTRY; list_for_each_entry(sub, &lio->lis_active, sub_linkage) { lov_sub_enter(sub); rc = iofunc(sub->sub_env, sub->sub_io); @@ -479,24 +463,21 @@ static int lov_io_call(const struct lu_env *env, struct lov_io *lio, if (parent->ci_result == 0) parent->ci_result = sub->sub_io->ci_result; } - RETURN(rc); + return rc; } static int lov_io_lock(const struct lu_env *env, const struct cl_io_slice *ios) { - ENTRY; - RETURN(lov_io_call(env, cl2lov_io(env, ios), cl_io_lock)); + return lov_io_call(env, cl2lov_io(env, ios), cl_io_lock); } static int lov_io_start(const struct lu_env *env, const struct cl_io_slice *ios) { - ENTRY; - RETURN(lov_io_call(env, cl2lov_io(env, ios), cl_io_start)); + return lov_io_call(env, cl2lov_io(env, ios), cl_io_start); } static int lov_io_end_wrapper(const struct lu_env *env, struct cl_io *io) { - ENTRY; /* * It's possible that lov_io_start() wasn't called against this * sub-io, either because previous sub-io failed, or upper layer @@ -506,19 +487,19 @@ static int lov_io_end_wrapper(const struct lu_env *env, struct cl_io *io) cl_io_end(env, io); else io->ci_state = CIS_IO_FINISHED; - RETURN(0); + return 0; } static int lov_io_iter_fini_wrapper(const struct lu_env *env, struct cl_io *io) { cl_io_iter_fini(env, io); - RETURN(0); + return 0; } static int lov_io_unlock_wrapper(const struct lu_env *env, struct cl_io *io) { cl_io_unlock(env, io); - RETURN(0); + return 0; } static void lov_io_end(const struct lu_env *env, const struct cl_io_slice *ios) @@ -535,12 +516,10 @@ static void lov_io_iter_fini(const struct lu_env *env, struct lov_io *lio = cl2lov_io(env, ios); int rc; - ENTRY; rc = lov_io_call(env, lio, lov_io_iter_fini_wrapper); LASSERT(rc == 0); while (!list_empty(&lio->lis_active)) list_del_init(lio->lis_active.next); - EXIT; } static void lov_io_unlock(const struct lu_env *env, @@ -548,10 +527,8 @@ static void lov_io_unlock(const struct lu_env *env, { int rc; - ENTRY; rc = lov_io_call(env, cl2lov_io(env, ios), lov_io_unlock_wrapper); LASSERT(rc == 0); - EXIT; } @@ -596,7 +573,7 @@ static int lov_io_submit(const struct lu_env *env, int rc = 0; int alloc = !(current->flags & PF_MEMALLOC); - ENTRY; + if (lio->lis_active_subios == 1) { int idx = lio->lis_single_subio_index; struct lov_io_sub *sub; @@ -608,7 +585,7 @@ static int lov_io_submit(const struct lu_env *env, rc = cl_io_submit_rw(sub->sub_env, sub->sub_io, crt, queue); lov_sub_put(sub); - RETURN(rc); + return rc; } LASSERT(lio->lis_subs != NULL); @@ -616,7 +593,7 @@ static int lov_io_submit(const struct lu_env *env, OBD_ALLOC_LARGE(stripes_qin, sizeof(*stripes_qin) * lio->lis_nr_subios); if (stripes_qin == NULL) - RETURN(-ENOMEM); + return -ENOMEM; for (stripe = 0; stripe < lio->lis_nr_subios; stripe++) cl_page_list_init(&stripes_qin[stripe]); @@ -682,7 +659,7 @@ static int lov_io_submit(const struct lu_env *env, mutex_unlock(&ld->ld_mutex); } - RETURN(rc); + return rc; #undef QIN } @@ -696,7 +673,6 @@ static int lov_io_prepare_write(const struct lu_env *env, struct lov_io_sub *sub; int result; - ENTRY; sub = lov_page_subio(env, lio, slice); if (!IS_ERR(sub)) { result = cl_io_prepare_write(sub->sub_env, sub->sub_io, @@ -704,7 +680,7 @@ static int lov_io_prepare_write(const struct lu_env *env, lov_sub_put(sub); } else result = PTR_ERR(sub); - RETURN(result); + return result; } static int lov_io_commit_write(const struct lu_env *env, @@ -717,7 +693,6 @@ static int lov_io_commit_write(const struct lu_env *env, struct lov_io_sub *sub; int result; - ENTRY; sub = lov_page_subio(env, lio, slice); if (!IS_ERR(sub)) { result = cl_io_commit_write(sub->sub_env, sub->sub_io, @@ -725,7 +700,7 @@ static int lov_io_commit_write(const struct lu_env *env, lov_sub_put(sub); } else result = PTR_ERR(sub); - RETURN(result); + return result; } static int lov_io_fault_start(const struct lu_env *env, @@ -735,13 +710,12 @@ static int lov_io_fault_start(const struct lu_env *env, struct lov_io *lio; struct lov_io_sub *sub; - ENTRY; fio = &ios->cis_io->u.ci_fault; lio = cl2lov_io(env, ios); sub = lov_sub_get(env, lio, lov_page_stripe(fio->ft_page)); sub->sub_io->u.ci_fault.ft_nob = fio->ft_nob; lov_sub_put(sub); - RETURN(lov_io_start(env, ios)); + return lov_io_start(env, ios); } static void lov_io_fsync_end(const struct lu_env *env, @@ -750,7 +724,6 @@ static void lov_io_fsync_end(const struct lu_env *env, struct lov_io *lio = cl2lov_io(env, ios); struct lov_io_sub *sub; unsigned int *written = &ios->cis_io->u.ci_fsync.fi_nr_written; - ENTRY; *written = 0; list_for_each_entry(sub, &lio->lis_active, sub_linkage) { @@ -763,7 +736,6 @@ static void lov_io_fsync_end(const struct lu_env *env, if (subio->ci_result == 0) *written += subio->u.ci_fsync.fi_nr_written; } - RETURN_EXIT; } static const struct cl_io_operations lov_io_ops = { @@ -839,11 +811,9 @@ static void lov_empty_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) { struct lov_object *lov = cl2lov(ios->cis_obj); - ENTRY; if (atomic_dec_and_test(&lov->lo_active_ios)) wake_up_all(&lov->lo_waitq); - EXIT; } static void lov_empty_impossible(const struct lu_env *env, @@ -913,7 +883,6 @@ int lov_io_init_raid0(const struct lu_env *env, struct cl_object *obj, struct lov_io *lio = lov_env_io(env); struct lov_object *lov = cl2lov(obj); - ENTRY; INIT_LIST_HEAD(&lio->lis_active); lov_io_slice_init(lio, lov, io); if (io->ci_result == 0) { @@ -923,7 +892,7 @@ int lov_io_init_raid0(const struct lu_env *env, struct cl_object *obj, atomic_inc(&lov->lo_active_ios); } } - RETURN(io->ci_result); + return io->ci_result; } int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, @@ -932,7 +901,6 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, struct lov_object *lov = cl2lov(obj); struct lov_io *lio = lov_env_io(env); int result; - ENTRY; lio->lis_object = lov; switch (io->ci_type) { @@ -961,7 +929,40 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, } io->ci_result = result < 0 ? result : 0; - RETURN(result != 0); + return result != 0; } +int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, + struct cl_io *io) +{ + struct lov_object *lov = cl2lov(obj); + struct lov_io *lio = lov_env_io(env); + int result; + + LASSERT(lov->lo_lsm != NULL); + lio->lis_object = lov; + + switch (io->ci_type) { + default: + LASSERTF(0, "invalid type %d\n", io->ci_type); + case CIT_MISC: + case CIT_FSYNC: + result = +1; + break; + case CIT_SETATTR: + case CIT_READ: + case CIT_WRITE: + case CIT_FAULT: + /* TODO: need to restore the file. */ + result = -EBADF; + break; + } + if (result == 0) { + cl_io_slice_add(io, &lio->lis_cl, obj, &lov_empty_io_ops); + atomic_inc(&lov->lo_active_ios); + } + + io->ci_result = result < 0 ? result : 0; + return result != 0; +} /** @} lov */ diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index bdf3334e0c9..ec297e87c2a 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -110,7 +110,6 @@ static void lov_sublock_adopt(const struct lu_env *env, struct lov_lock *lck, LASSERT(cl_lock_is_mutexed(parent)); LASSERT(cl_lock_is_mutexed(sublock)); - ENTRY; lsl = cl2sub_lock(sublock); /* @@ -132,7 +131,6 @@ static void lov_sublock_adopt(const struct lu_env *env, struct lov_lock *lck, rc = lov_sublock_modify(env, lck, lsl, &sublock->cll_descr, idx); LASSERT(rc == 0); /* there is no way this can fail, currently */ - EXIT; } static struct cl_lock *lov_sublock_alloc(const struct lu_env *env, @@ -145,7 +143,6 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env, struct lov_lock_link *link; LASSERT(idx < lck->lls_nr); - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(link, lov_lock_link_kmem, __GFP_IO); if (link != NULL) { @@ -179,7 +176,7 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env, OBD_SLAB_FREE_PTR(link, lov_lock_link_kmem); } else sublock = ERR_PTR(-ENOMEM); - RETURN(sublock); + return sublock; } static void lov_sublock_unlock(const struct lu_env *env, @@ -187,11 +184,9 @@ static void lov_sublock_unlock(const struct lu_env *env, struct cl_lock_closure *closure, struct lov_sublock_env *subenv) { - ENTRY; lov_sublock_env_put(subenv); lsl->lss_active = NULL; cl_lock_disclosure(env, closure); - EXIT; } static int lov_sublock_lock(const struct lu_env *env, @@ -203,7 +198,6 @@ static int lov_sublock_lock(const struct lu_env *env, struct lovsub_lock *sublock; struct cl_lock *child; int result = 0; - ENTRY; LASSERT(list_empty(&closure->clc_list)); @@ -243,7 +237,7 @@ static int lov_sublock_lock(const struct lu_env *env, } } } - RETURN(result); + return result; } /** @@ -267,8 +261,6 @@ static int lov_subresult(int result, int rc) int result_rank; int rc_rank; - ENTRY; - LASSERTF(result <= 0 || result == CLO_REPEAT || result == CLO_WAIT, "result = %d", result); LASSERTF(rc <= 0 || rc == CLO_REPEAT || rc == CLO_WAIT, @@ -281,7 +273,7 @@ static int lov_subresult(int result, int rc) if (result_rank < rc_rank) result = rc; - RETURN(result); + return result; } /** @@ -307,8 +299,6 @@ static int lov_lock_sub_init(const struct lu_env *env, struct lov_layout_raid0 *r0 = lov_r0(loo); struct cl_lock *parent = lck->lls_cl.cls_lock; - ENTRY; - lck->lls_orig = parent->cll_descr; file_start = cl_offset(lov2cl(loo), parent->cll_descr.cld_start); file_end = cl_offset(lov2cl(loo), parent->cll_descr.cld_end + 1) - 1; @@ -325,7 +315,7 @@ static int lov_lock_sub_init(const struct lu_env *env, LASSERT(nr > 0); OBD_ALLOC_LARGE(lck->lls_sub, nr * sizeof lck->lls_sub[0]); if (lck->lls_sub == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lck->lls_nr = nr; /* @@ -396,7 +386,7 @@ static int lov_lock_sub_init(const struct lu_env *env, * because enqueue will create them anyway. Main duty of this function * is to fill in sub-lock descriptions in a race free manner. */ - RETURN(result); + return result; } static int lov_sublock_release(const struct lu_env *env, struct lov_lock *lck, @@ -405,7 +395,6 @@ static int lov_sublock_release(const struct lu_env *env, struct lov_lock *lck, struct cl_lock *parent = lck->lls_cl.cls_lock; LASSERT(cl_lock_is_mutexed(parent)); - ENTRY; if (lck->lls_sub[i].sub_flags & LSF_HELD) { struct cl_lock *sublock; @@ -442,7 +431,7 @@ static int lov_sublock_release(const struct lu_env *env, struct lov_lock *lck, * sub-lock is destroyed. */ } - RETURN(rc); + return rc; } static void lov_sublock_hold(const struct lu_env *env, struct lov_lock *lck, @@ -451,7 +440,6 @@ static void lov_sublock_hold(const struct lu_env *env, struct lov_lock *lck, struct cl_lock *parent = lck->lls_cl.cls_lock; LASSERT(cl_lock_is_mutexed(parent)); - ENTRY; if (!(lck->lls_sub[i].sub_flags & LSF_HELD)) { struct cl_lock *sublock; @@ -468,7 +456,6 @@ static void lov_sublock_hold(const struct lu_env *env, struct lov_lock *lck, cl_lock_user_add(env, sublock); cl_lock_put(env, sublock); } - EXIT; } static void lov_lock_fini(const struct lu_env *env, @@ -477,7 +464,6 @@ static void lov_lock_fini(const struct lu_env *env, struct lov_lock *lck; int i; - ENTRY; lck = cl2lov_lock(slice); LASSERT(lck->lls_nr_filled == 0); if (lck->lls_sub != NULL) { @@ -491,7 +477,6 @@ static void lov_lock_fini(const struct lu_env *env, lck->lls_nr * sizeof lck->lls_sub[0]); } OBD_SLAB_FREE_PTR(lck, lov_lock_kmem); - EXIT; } static int lov_lock_enqueue_wait(const struct lu_env *env, @@ -500,14 +485,13 @@ static int lov_lock_enqueue_wait(const struct lu_env *env, { struct cl_lock *lock = lck->lls_cl.cls_lock; int result; - ENTRY; LASSERT(cl_lock_is_mutexed(lock)); cl_lock_mutex_put(env, lock); result = cl_lock_enqueue_wait(env, sublock, 0); cl_lock_mutex_get(env, lock); - RETURN(result ?: CLO_REPEAT); + return result ?: CLO_REPEAT; } /** @@ -522,7 +506,6 @@ static int lov_lock_enqueue_one(const struct lu_env *env, struct lov_lock *lck, struct cl_io *io, __u32 enqflags, int last) { int result; - ENTRY; /* first, try to enqueue a sub-lock ... */ result = cl_enqueue_try(env, sublock, io, enqflags); @@ -541,7 +524,7 @@ static int lov_lock_enqueue_one(const struct lu_env *env, struct lov_lock *lck, if ((result == CLO_WAIT) && (sublock->cll_state <= CLS_HELD) && (enqflags & CEF_ASYNC) && (!last || (enqflags & CEF_AGL))) result = 0; - RETURN(result); + return result; } /** @@ -600,8 +583,6 @@ static int lov_lock_enqueue(const struct lu_env *env, int result; enum cl_lock_state minstate; - ENTRY; - for (result = 0, minstate = CLS_FREEING, i = 0; i < lck->lls_nr; ++i) { int rc; struct lovsub_lock *sub; @@ -680,7 +661,7 @@ static int lov_lock_enqueue(const struct lu_env *env, break; } cl_lock_closure_fini(closure); - RETURN(result ?: minstate >= CLS_ENQUEUED ? 0 : CLO_WAIT); + return result ?: minstate >= CLS_ENQUEUED ? 0 : CLO_WAIT; } static int lov_lock_unuse(const struct lu_env *env, @@ -691,8 +672,6 @@ static int lov_lock_unuse(const struct lu_env *env, int i; int result; - ENTRY; - for (result = 0, i = 0; i < lck->lls_nr; ++i) { int rc; struct lovsub_lock *sub; @@ -728,7 +707,7 @@ static int lov_lock_unuse(const struct lu_env *env, result = -ESTALE; } cl_lock_closure_fini(closure); - RETURN(result); + return result; } @@ -740,8 +719,6 @@ static void lov_lock_cancel(const struct lu_env *env, int i; int result; - ENTRY; - for (result = 0, i = 0; i < lck->lls_nr; ++i) { int rc; struct lovsub_lock *sub; @@ -802,8 +779,6 @@ static int lov_lock_wait(const struct lu_env *env, int result; int i; - ENTRY; - again: for (result = 0, minstate = CLS_FREEING, i = 0, reenqueued = 0; i < lck->lls_nr; ++i) { @@ -839,7 +814,7 @@ again: if (result == 0 && reenqueued != 0) goto again; cl_lock_closure_fini(closure); - RETURN(result ?: minstate >= CLS_HELD ? 0 : CLO_WAIT); + return result ?: minstate >= CLS_HELD ? 0 : CLO_WAIT; } static int lov_lock_use(const struct lu_env *env, @@ -851,7 +826,6 @@ static int lov_lock_use(const struct lu_env *env, int i; LASSERT(slice->cls_lock->cll_state == CLS_INTRANSIT); - ENTRY; for (result = 0, i = 0; i < lck->lls_nr; ++i) { int rc; @@ -908,7 +882,7 @@ static int lov_lock_use(const struct lu_env *env, result = -ESTALE; } cl_lock_closure_fini(closure); - RETURN(result); + return result; } #if 0 @@ -1016,8 +990,6 @@ static int lov_lock_fits_into(const struct lu_env *env, LASSERT(cl_object_same(need->cld_obj, slice->cls_obj)); LASSERT(lov->lls_nr > 0); - ENTRY; - /* for top lock, it's necessary to match enq flags otherwise it will * run into problem if a sublock is missing and reenqueue. */ if (need->cld_enq_flags != lov->lls_orig.cld_enq_flags) @@ -1055,7 +1027,7 @@ static int lov_lock_fits_into(const struct lu_env *env, PDESCR(&lov->lls_orig), PDESCR(&lov->lls_sub[0].sub_got), lov->lls_sub[0].sub_stripe, lov->lls_nr, lov_r0(obj)->lo_nr, result); - RETURN(result); + return result; } void lov_lock_unlink(const struct lu_env *env, @@ -1066,7 +1038,6 @@ void lov_lock_unlink(const struct lu_env *env, LASSERT(cl_lock_is_mutexed(parent)); LASSERT(cl_lock_is_mutexed(sub->lss_cl.cls_lock)); - ENTRY; list_del_init(&link->lll_list); LASSERT(lck->lls_sub[link->lll_idx].sub_lock == sub); @@ -1077,7 +1048,6 @@ void lov_lock_unlink(const struct lu_env *env, lu_ref_del(&parent->cll_reference, "lov-child", sub->lss_cl.cls_lock); cl_lock_put(env, parent); OBD_SLAB_FREE_PTR(link, lov_lock_link_kmem); - EXIT; } struct lov_lock_link *lov_lock_link_find(const struct lu_env *env, @@ -1087,13 +1057,12 @@ struct lov_lock_link *lov_lock_link_find(const struct lu_env *env, struct lov_lock_link *scan; LASSERT(cl_lock_is_mutexed(sub->lss_cl.cls_lock)); - ENTRY; list_for_each_entry(scan, &sub->lss_parents, lll_list) { if (scan->lll_super == lck) - RETURN(scan); + return scan; } - RETURN(NULL); + return NULL; } /** @@ -1120,7 +1089,6 @@ static void lov_lock_delete(const struct lu_env *env, int i; LASSERT(slice->cls_lock->cll_state == CLS_FREEING); - ENTRY; for (i = 0; i < lck->lls_nr; ++i) { struct lov_lock_sub *lls = &lck->lls_sub[i]; @@ -1150,7 +1118,6 @@ static void lov_lock_delete(const struct lu_env *env, } cl_lock_closure_fini(closure); - EXIT; } static int lov_lock_print(const struct lu_env *env, void *cookie, @@ -1192,14 +1159,13 @@ int lov_lock_init_raid0(const struct lu_env *env, struct cl_object *obj, struct lov_lock *lck; int result; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, __GFP_IO); if (lck != NULL) { cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_lock_ops); result = lov_lock_sub_init(env, lck, io); } else result = -ENOMEM; - RETURN(result); + return result; } static void lov_empty_lock_fini(const struct lu_env *env, @@ -1228,14 +1194,13 @@ int lov_lock_init_empty(const struct lu_env *env, struct cl_object *obj, struct lov_lock *lck; int result = -ENOMEM; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, __GFP_IO); if (lck != NULL) { cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_empty_lock_ops); lck->lls_orig = lock->cll_descr; result = 0; } - RETURN(result); + return result; } static struct cl_lock_closure *lov_closure_get(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/lov/lov_log.c b/drivers/staging/lustre/lustre/lov/lov_log.c index 63b7f8d3182..3eedd935d1b 100644 --- a/drivers/staging/lustre/lustre/lov/lov_log.c +++ b/drivers/staging/lustre/lustre/lov/lov_log.c @@ -71,7 +71,6 @@ static int lov_llog_origin_add(const struct lu_env *env, struct obd_device *obd = ctxt->loc_obd; struct lov_obd *lov = &obd->u.lov; int i, rc = 0, cookies = 0; - ENTRY; LASSERTF(logcookies && numcookies >= lsm->lsm_stripe_count, "logcookies %p, numcookies %d lsm->lsm_stripe_count %d \n", @@ -118,7 +117,7 @@ static int lov_llog_origin_add(const struct lu_env *env, /* Note that rc is always 1 if llog_obd_add was successful */ cookies += rc; } - RETURN(cookies); + return cookies; } static int lov_llog_origin_connect(struct llog_ctxt *ctxt, @@ -129,7 +128,6 @@ static int lov_llog_origin_connect(struct llog_ctxt *ctxt, struct obd_device *obd = ctxt->loc_obd; struct lov_obd *lov = &obd->u.lov; int i, rc = 0, err = 0; - ENTRY; obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { @@ -154,7 +152,7 @@ static int lov_llog_origin_connect(struct llog_ctxt *ctxt, } obd_putref(obd); - RETURN(err); + return err; } /* the replicators commit callback */ @@ -167,7 +165,6 @@ static int lov_llog_repl_cancel(const struct lu_env *env, struct lov_obd *lov; struct obd_device *obd = ctxt->loc_obd; int rc = 0, i; - ENTRY; LASSERT(lsm != NULL); LASSERT(count == lsm->lsm_stripe_count); @@ -194,7 +191,7 @@ static int lov_llog_repl_cancel(const struct lu_env *env, } } obd_putref(obd); - RETURN(rc); + return rc; } static struct llog_operations lov_mds_ost_orig_logops = { @@ -212,13 +209,12 @@ int lov_llog_init(struct obd_device *obd, struct obd_llog_group *olg, struct lov_obd *lov = &obd->u.lov; struct obd_device *child; int i, rc = 0; - ENTRY; LASSERT(olg == &obd->obd_olg); rc = llog_setup(NULL, obd, olg, LLOG_MDS_OST_ORIG_CTXT, disk_obd, &lov_mds_ost_orig_logops); if (rc) - RETURN(rc); + return rc; rc = llog_setup(NULL, obd, olg, LLOG_SIZE_REPL_CTXT, disk_obd, &lov_size_repl_logops); @@ -261,8 +257,6 @@ int lov_llog_finish(struct obd_device *obd, int count) { struct llog_ctxt *ctxt; - ENTRY; - /* cleanup our llogs only if the ctxts have been setup * (client lov doesn't setup, mds lov does). */ ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); @@ -274,5 +268,5 @@ int lov_llog_finish(struct obd_device *obd, int count) llog_cleanup(NULL, ctxt); /* lov->tgt llogs are cleaned during osc_cleanup. */ - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c b/drivers/staging/lustre/lustre/lov/lov_merge.c index ddbac122026..d204fedea34 100644 --- a/drivers/staging/lustre/lustre/lov/lov_merge.c +++ b/drivers/staging/lustre/lustre/lov/lov_merge.c @@ -109,7 +109,7 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, lvb->lvb_mtime = current_mtime; lvb->lvb_atime = current_atime; lvb->lvb_ctime = current_ctime; - RETURN(rc); + return rc; } /** Merge the lock value block(&lvb) attributes from each of the stripes in a @@ -127,7 +127,6 @@ int lov_merge_lvb(struct obd_export *exp, int rc; __u64 kms; - ENTRY; lov_stripe_lock(lsm); rc = lov_merge_lvb_kms(lsm, lvb, &kms); lov_stripe_unlock(lsm); @@ -137,7 +136,7 @@ int lov_merge_lvb(struct obd_export *exp, 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); - RETURN(rc); + return rc; } /* Must be called under the lov_stripe_lock() */ @@ -147,7 +146,6 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, struct lov_oinfo *loi; int stripe = 0; __u64 kms; - ENTRY; LASSERT(spin_is_locked(&lsm->lsm_lock)); LASSERT(lsm->lsm_lock_owner == current_pid()); @@ -162,7 +160,7 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, loi->loi_kms, kms); loi_kms_set(loi, loi->loi_lvb.lvb_size = kms); } - RETURN(0); + return 0; } if (size > 0) @@ -175,7 +173,7 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, if (kms > loi->loi_kms) loi_kms_set(loi, kms); - RETURN(0); + return 0; } void lov_merge_attrs(struct obdo *tgt, struct obdo *src, obd_valid valid, diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index ef7ff091f04..0b47aba1332 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -131,19 +131,18 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, struct obd_device *tgt_obd; static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; struct obd_import *imp; - proc_dir_entry_t *lov_proc_dir; + struct proc_dir_entry *lov_proc_dir; int rc; - ENTRY; if (!lov->lov_tgts[index]) - RETURN(-EINVAL); + return -EINVAL; tgt_uuid = &lov->lov_tgts[index]->ltd_uuid; tgt_obd = lov->lov_tgts[index]->ltd_obd; if (!tgt_obd->obd_set_up) { CERROR("Target %s not set up\n", obd_uuid2str(tgt_uuid)); - RETURN(-EINVAL); + return -EINVAL; } /* override the sp_me from lov */ @@ -168,14 +167,14 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, if (rc) { CERROR("Target %s register_observer error %d\n", obd_uuid2str(tgt_uuid), rc); - RETURN(rc); + return rc; } if (imp->imp_invalid) { CDEBUG(D_CONFIG, "not connecting OSC %s; administratively " "disabled\n", obd_uuid2str(tgt_uuid)); - RETURN(0); + return 0; } rc = obd_connect(NULL, &lov->lov_tgts[index]->ltd_exp, tgt_obd, @@ -183,7 +182,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, if (rc || !lov->lov_tgts[index]->ltd_exp) { CERROR("Target %s connect error %d\n", obd_uuid2str(tgt_uuid), rc); - RETURN(-ENODEV); + return -ENODEV; } lov->lov_tgts[index]->ltd_reap = 0; @@ -194,7 +193,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, lov_proc_dir = obd->obd_proc_private; if (lov_proc_dir) { struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd; - proc_dir_entry_t *osc_symlink; + struct proc_dir_entry *osc_symlink; LASSERT(osc_obd != NULL); LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC); @@ -215,7 +214,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, } } - RETURN(0); + return 0; } static int lov_connect(const struct lu_env *env, @@ -227,13 +226,12 @@ static int lov_connect(const struct lu_env *env, struct lov_tgt_desc *tgt; struct lustre_handle conn; int i, rc; - ENTRY; CDEBUG(D_CONFIG, "connect #%d\n", lov->lov_connects); rc = class_connect(&conn, obd, cluuid); if (rc) - RETURN(rc); + return rc; *exp = class_conn2export(&conn); @@ -270,16 +268,15 @@ static int lov_connect(const struct lu_env *env, } obd_putref(obd); - RETURN(0); + return 0; } static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) { - proc_dir_entry_t *lov_proc_dir; + struct proc_dir_entry *lov_proc_dir; struct lov_obd *lov = &obd->u.lov; struct obd_device *osc_obd; int rc; - ENTRY; osc_obd = class_exp2obd(tgt->ltd_exp); CDEBUG(D_CONFIG, "%s: disconnecting target %s\n", @@ -315,7 +312,7 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) } tgt->ltd_exp = NULL; - RETURN(0); + return 0; } static int lov_disconnect(struct obd_export *exp) @@ -323,7 +320,6 @@ static int lov_disconnect(struct obd_export *exp) struct obd_device *obd = class_exp2obd(exp); struct lov_obd *lov = &obd->u.lov; int i, rc; - ENTRY; if (!lov->lov_tgts) goto out; @@ -350,7 +346,7 @@ static int lov_disconnect(struct obd_export *exp) out: rc = class_disconnect(exp); /* bz 9811 */ - RETURN(rc); + return rc; } /* Error codes: @@ -366,7 +362,6 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, struct lov_obd *lov = &obd->u.lov; struct lov_tgt_desc *tgt; int index, activate, active; - ENTRY; CDEBUG(D_INFO, "Searching in lov %p for uuid %s event(%d)\n", lov, uuid->uuid, ev); @@ -438,7 +433,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, out: obd_putref(obd); - RETURN(index); + return index; } static int lov_notify(struct obd_device *obd, struct obd_device *watched, @@ -446,12 +441,11 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, { int rc = 0; struct lov_obd *lov = &obd->u.lov; - ENTRY; down_read(&lov->lov_notify_lock); if (!lov->lov_connects) { up_read(&lov->lov_notify_lock); - RETURN(rc); + return rc; } if (ev == OBD_NOTIFY_ACTIVE || ev == OBD_NOTIFY_INACTIVE || @@ -465,7 +459,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, CERROR("unexpected notification of %s %s!\n", watched->obd_type->typ_name, watched->obd_name); - RETURN(-EINVAL); + return -EINVAL; } uuid = &watched->u.cli.cl_target_uuid; @@ -477,7 +471,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, up_read(&lov->lov_notify_lock); CERROR("event(%d) of %s failed: %d\n", ev, obd_uuid2str(uuid), rc); - RETURN(rc); + return rc; } /* active event should be pass lov target index as data */ data = &rc; @@ -520,7 +514,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, } up_read(&lov->lov_notify_lock); - RETURN(rc); + return rc; } static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, @@ -530,7 +524,6 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, struct lov_tgt_desc *tgt; struct obd_device *tgt_obd; int rc; - ENTRY; CDEBUG(D_CONFIG, "uuid:%s idx:%d gen:%d active:%d\n", uuidp->uuid, index, gen, active); @@ -538,13 +531,13 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, if (gen <= 0) { CERROR("request to add OBD %s with invalid generation: %d\n", uuidp->uuid, gen); - RETURN(-EINVAL); + return -EINVAL; } tgt_obd = class_find_client_obd(uuidp, LUSTRE_OSC_NAME, &obd->obd_uuid); if (tgt_obd == NULL) - RETURN(-EINVAL); + return -EINVAL; mutex_lock(&lov->lov_lock); @@ -553,7 +546,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, CERROR("UUID %s already assigned at LOV target index %d\n", obd_uuid2str(&tgt->ltd_uuid), index); mutex_unlock(&lov->lov_lock); - RETURN(-EEXIST); + return -EEXIST; } if (index >= lov->lov_tgt_size) { @@ -567,7 +560,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize); if (newtgts == NULL) { mutex_unlock(&lov->lov_lock); - RETURN(-ENOMEM); + return -ENOMEM; } if (lov->lov_tgt_size) { @@ -590,14 +583,14 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, OBD_ALLOC_PTR(tgt); if (!tgt) { mutex_unlock(&lov->lov_lock); - RETURN(-ENOMEM); + return -ENOMEM; } rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size); if (rc) { mutex_unlock(&lov->lov_lock); OBD_FREE_PTR(tgt); - RETURN(rc); + return rc; } tgt->ltd_uuid = *uuidp; @@ -621,7 +614,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, /* lov_connect hasn't been called yet. We'll do the lov_connect_obd on this target when that fn first runs, because we don't know the connect flags yet. */ - RETURN(0); + return 0; } obd_getref(obd); @@ -654,7 +647,7 @@ out: lov_del_target(obd, index, 0, 0); } obd_putref(obd); - RETURN(rc); + return rc; } /* Schedule a target for deletion */ @@ -664,12 +657,11 @@ int lov_del_target(struct obd_device *obd, __u32 index, struct lov_obd *lov = &obd->u.lov; int count = lov->desc.ld_tgt_count; int rc = 0; - ENTRY; if (index >= count) { CERROR("LOV target index %d >= number of LOV OBDs %d.\n", index, count); - RETURN(-EINVAL); + return -EINVAL; } /* to make sure there's no ongoing lov_notify() now */ @@ -700,7 +692,7 @@ out: obd_putref(obd); up_write(&lov->lov_notify_lock); - RETURN(rc); + return rc; } static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) @@ -780,11 +772,10 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) struct lov_desc *desc; struct lov_obd *lov = &obd->u.lov; int rc; - ENTRY; if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) { CERROR("LOV setup requires a descriptor\n"); - RETURN(-EINVAL); + return -EINVAL; } desc = (struct lov_desc *)lustre_cfg_buf(lcfg, 1); @@ -792,7 +783,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (sizeof(*desc) > LUSTRE_CFG_BUFLEN(lcfg, 1)) { CERROR("descriptor size wrong: %d > %d\n", (int)sizeof(*desc), LUSTRE_CFG_BUFLEN(lcfg, 1)); - RETURN(-EINVAL); + return -EINVAL; } if (desc->ld_magic != LOV_DESC_MAGIC) { @@ -803,7 +794,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) } else { CERROR("%s: Bad lov desc magic: %#x\n", obd->obd_name, desc->ld_magic); - RETURN(-EINVAL); + return -EINVAL; } } @@ -836,11 +827,11 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lprocfs_obd_setup(obd, lvars.obd_vars); #ifdef LPROCFS { - int rc; + int rc1; - rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd", + rc1 = lprocfs_seq_create(obd->obd_proc_entry, "target_obd", 0444, &lov_proc_target_fops, obd); - if (rc) + if (rc1) CWARN("Error adding the target_obd file\n"); } #endif @@ -848,7 +839,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) obd->obd_proc_entry, NULL, NULL); - RETURN(0); + return 0; out: return rc; @@ -859,8 +850,6 @@ static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) int rc = 0; struct lov_obd *lov = &obd->u.lov; - ENTRY; - switch (stage) { case OBD_CLEANUP_EARLY: { int i; @@ -878,7 +867,7 @@ static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) CERROR("failed to cleanup llogging subsystems\n"); break; } - RETURN(rc); + return rc; } static int lov_cleanup(struct obd_device *obd) @@ -886,7 +875,6 @@ static int lov_cleanup(struct obd_device *obd) struct lov_obd *lov = &obd->u.lov; struct list_head *pos, *tmp; struct pool_desc *pool; - ENTRY; list_for_each_safe(pos, tmp, &lov->lov_pool_list) { pool = list_entry(pos, struct pool_desc, pool_list); @@ -925,7 +913,7 @@ static int lov_cleanup(struct obd_device *obd) lov->lov_tgt_size); lov->lov_tgt_size = 0; } - RETURN(0); + return 0; } int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, @@ -934,7 +922,6 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, struct obd_uuid obd_uuid; int cmd; int rc = 0; - ENTRY; switch(cmd = lcfg->lcfg_command) { case LCFG_LOV_ADD_OBD: @@ -990,7 +977,7 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, } } out: - RETURN(rc); + return rc; } static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, @@ -1000,14 +987,13 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, struct lov_obd *lov = &exp->exp_obd->u.lov; unsigned ost_idx; int rc, i; - ENTRY; LASSERT(src_oa->o_valid & OBD_MD_FLFLAGS && src_oa->o_flags & OBD_FL_RECREATE_OBJS); OBD_ALLOC(obj_mdp, sizeof(*obj_mdp)); if (obj_mdp == NULL) - RETURN(-ENOMEM); + return -ENOMEM; ost_idx = src_oa->o_nlink; lsm = *ea; @@ -1032,7 +1018,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, src_oa, &obj_mdp, oti); out: OBD_FREE(obj_mdp, sizeof(*obj_mdp)); - RETURN(rc); + return rc; } /* the LOV expects oa->o_id to be set to the LOV object id */ @@ -1042,11 +1028,10 @@ static int lov_create(const struct lu_env *env, struct obd_export *exp, { struct lov_obd *lov; int rc = 0; - ENTRY; LASSERT(ea != NULL); if (exp == NULL) - RETURN(-EINVAL); + return -EINVAL; if ((src_oa->o_valid & OBD_MD_FLFLAGS) && src_oa->o_flags == OBD_FL_DELORPHAN) { @@ -1056,7 +1041,7 @@ static int lov_create(const struct lu_env *env, struct obd_export *exp, lov = &exp->exp_obd->u.lov; if (!lov->desc.ld_active_tgt_count) - RETURN(-EIO); + return -EIO; obd_getref(exp->exp_obd); /* Recreate a specific object id at the given OST index */ @@ -1066,7 +1051,7 @@ static int lov_create(const struct lu_env *env, struct obd_export *exp, } obd_putref(exp->exp_obd); - RETURN(rc); + return rc; } #define ASSERT_LSM_MAGIC(lsmp) \ @@ -1088,12 +1073,11 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp, struct list_head *pos; struct lov_obd *lov; int rc = 0, err = 0; - ENTRY; ASSERT_LSM_MAGIC(lsm); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; if (oa->o_valid & OBD_MD_FLCOOKIE) { LASSERT(oti); @@ -1133,7 +1117,7 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp, err = lov_fini_destroy_set(set); out: obd_putref(exp->exp_obd); - RETURN(rc ? rc : err); + return rc ? rc : err; } static int lov_getattr(const struct lu_env *env, struct obd_export *exp, @@ -1144,19 +1128,18 @@ static int lov_getattr(const struct lu_env *env, struct obd_export *exp, struct list_head *pos; struct lov_obd *lov; int err = 0, rc = 0; - ENTRY; LASSERT(oinfo); ASSERT_LSM_MAGIC(oinfo->oi_md); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; rc = lov_prep_getattr_set(exp, oinfo, &set); if (rc) - RETURN(rc); + return rc; list_for_each (pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -1182,7 +1165,7 @@ static int lov_getattr(const struct lu_env *env, struct obd_export *exp, rc = lov_fini_getattr_set(set); if (err) rc = err; - RETURN(rc); + return rc; } static int lov_getattr_interpret(struct ptlrpc_request_set *rqset, @@ -1190,13 +1173,12 @@ static int lov_getattr_interpret(struct ptlrpc_request_set *rqset, { struct lov_request_set *lovset = (struct lov_request_set *)data; int err; - ENTRY; /* don't do attribute merge if this aysnc op failed */ if (rc) atomic_set(&lovset->set_completes, 0); err = lov_fini_getattr_set(lovset); - RETURN(rc ? rc : err); + return rc ? rc : err; } static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, @@ -1207,19 +1189,18 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, struct list_head *pos; struct lov_request *req; int rc = 0, err; - ENTRY; LASSERT(oinfo); ASSERT_LSM_MAGIC(oinfo->oi_md); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; rc = lov_prep_getattr_set(exp, oinfo, &lovset); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INFO, "objid "DOSTID": %ux%u byte stripes\n", POSTID(&oinfo->oi_md->lsm_oi), oinfo->oi_md->lsm_stripe_count, @@ -1249,13 +1230,13 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, LASSERT (rqset->set_interpret == NULL); rqset->set_interpret = lov_getattr_interpret; rqset->set_arg = (void *)lovset; - RETURN(rc); + return rc; } out: if (rc) atomic_set(&lovset->set_completes, 0); err = lov_fini_getattr_set(lovset); - RETURN(rc ? rc : err); + return rc ? rc : err; } static int lov_setattr(const struct lu_env *env, struct obd_export *exp, @@ -1266,13 +1247,12 @@ static int lov_setattr(const struct lu_env *env, struct obd_export *exp, struct list_head *pos; struct lov_request *req; int err = 0, rc = 0; - ENTRY; LASSERT(oinfo); ASSERT_LSM_MAGIC(oinfo->oi_md); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; /* for now, we only expect the following updates here */ LASSERT(!(oinfo->oi_oa->o_valid & ~(OBD_MD_FLID | OBD_MD_FLTYPE | @@ -1285,7 +1265,7 @@ static int lov_setattr(const struct lu_env *env, struct obd_export *exp, lov = &exp->exp_obd->u.lov; rc = lov_prep_setattr_set(exp, oinfo, oti, &set); if (rc) - RETURN(rc); + return rc; list_for_each (pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -1307,7 +1287,7 @@ static int lov_setattr(const struct lu_env *env, struct obd_export *exp, err = lov_fini_setattr_set(set); if (!rc) rc = err; - RETURN(rc); + return rc; } static int lov_setattr_interpret(struct ptlrpc_request_set *rqset, @@ -1315,12 +1295,11 @@ static int lov_setattr_interpret(struct ptlrpc_request_set *rqset, { struct lov_request_set *lovset = (struct lov_request_set *)data; int err; - ENTRY; if (rc) atomic_set(&lovset->set_completes, 0); err = lov_fini_setattr_set(lovset); - RETURN(rc ? rc : err); + return rc ? rc : err; } /* If @oti is given, the request goes from MDS and responses from OSTs are not @@ -1334,7 +1313,6 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, struct list_head *pos; struct lov_obd *lov; int rc = 0; - ENTRY; LASSERT(oinfo); ASSERT_LSM_MAGIC(oinfo->oi_md); @@ -1344,12 +1322,12 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, } if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; rc = lov_prep_setattr_set(exp, oinfo, oti, &set); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INFO, "objid "DOSTID": %ux%u byte stripes\n", POSTID(&oinfo->oi_md->lsm_oi), @@ -1384,14 +1362,14 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, if (rc) atomic_set(&set->set_completes, 0); err = lov_fini_setattr_set(set); - RETURN(rc ? rc : err); + return rc ? rc : err; } LASSERT(rqset->set_interpret == NULL); rqset->set_interpret = lov_setattr_interpret; rqset->set_arg = (void *)set; - RETURN(0); + return 0; } static int lov_punch_interpret(struct ptlrpc_request_set *rqset, @@ -1399,12 +1377,11 @@ static int lov_punch_interpret(struct ptlrpc_request_set *rqset, { struct lov_request_set *lovset = (struct lov_request_set *)data; int err; - ENTRY; if (rc) atomic_set(&lovset->set_completes, 0); err = lov_fini_punch_set(lovset); - RETURN(rc ? rc : err); + return rc ? rc : err; } /* FIXME: maybe we'll just make one node the authoritative attribute node, then @@ -1419,18 +1396,17 @@ static int lov_punch(const struct lu_env *env, struct obd_export *exp, struct list_head *pos; struct lov_request *req; int rc = 0; - ENTRY; LASSERT(oinfo); ASSERT_LSM_MAGIC(oinfo->oi_md); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; rc = lov_prep_punch_set(exp, oinfo, oti, &set); if (rc) - RETURN(rc); + return rc; list_for_each (pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -1450,14 +1426,14 @@ static int lov_punch(const struct lu_env *env, struct obd_export *exp, if (rc || list_empty(&rqset->set_requests)) { int err; err = lov_fini_punch_set(set); - RETURN(rc ? rc : err); + return rc ? rc : err; } LASSERT(rqset->set_interpret == NULL); rqset->set_interpret = lov_punch_interpret; rqset->set_arg = (void *)set; - RETURN(0); + return 0; } static int lov_sync_interpret(struct ptlrpc_request_set *rqset, @@ -1465,12 +1441,11 @@ static int lov_sync_interpret(struct ptlrpc_request_set *rqset, { struct lov_request_set *lovset = data; int err; - ENTRY; if (rc) atomic_set(&lovset->set_completes, 0); err = lov_fini_sync_set(lovset); - RETURN(rc ?: err); + return rc ?: err; } static int lov_sync(const struct lu_env *env, struct obd_export *exp, @@ -1482,18 +1457,17 @@ static int lov_sync(const struct lu_env *env, struct obd_export *exp, struct list_head *pos; struct lov_request *req; int rc = 0; - ENTRY; ASSERT_LSM_MAGIC(oinfo->oi_md); LASSERT(rqset != NULL); if (!exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; rc = lov_prep_sync_set(exp, oinfo, start, end, &set); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INFO, "fsync objid "DOSTID" ["LPX64", "LPX64"]\n", POSTID(&set->set_oi->oi_oa->o_oi), start, end); @@ -1519,14 +1493,14 @@ static int lov_sync(const struct lu_env *env, struct obd_export *exp, if (rc || list_empty(&rqset->set_requests)) { int err = lov_fini_sync_set(set); - RETURN(rc ?: err); + return rc ?: err; } LASSERT(rqset->set_interpret == NULL); rqset->set_interpret = lov_sync_interpret; rqset->set_arg = (void *)set; - RETURN(0); + return 0; } static int lov_brw_check(struct lov_obd *lov, struct obd_info *lov_oinfo, @@ -1571,18 +1545,17 @@ static int lov_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, struct list_head *pos; struct lov_obd *lov = &exp->exp_obd->u.lov; int err, rc = 0; - ENTRY; ASSERT_LSM_MAGIC(oinfo->oi_md); if (cmd == OBD_BRW_CHECK) { rc = lov_brw_check(lov, oinfo, oa_bufs, pga); - RETURN(rc); + return rc; } rc = lov_prep_brw_set(exp, oinfo, oa_bufs, pga, oti, &set); if (rc) - RETURN(rc); + return rc; list_for_each (pos, &set->set_list) { struct obd_export *sub_exp; @@ -1601,16 +1574,16 @@ static int lov_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, err = lov_fini_brw_set(set); if (!rc) rc = err; - RETURN(rc); + return rc; } static int lov_enqueue_interpret(struct ptlrpc_request_set *rqset, void *data, int rc) { struct lov_request_set *lovset = (struct lov_request_set *)data; - ENTRY; + rc = lov_fini_enqueue_set(lovset, lovset->set_ei->ei_mode, rc, rqset); - RETURN(rc); + return rc; } static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo, @@ -1623,7 +1596,6 @@ static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo, struct list_head *pos; struct lov_obd *lov; ldlm_error_t rc; - ENTRY; LASSERT(oinfo); ASSERT_LSM_MAGIC(oinfo->oi_md); @@ -1633,12 +1605,12 @@ static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo, LASSERT((oinfo->oi_flags & LDLM_FL_REPLAY) == 0); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; rc = lov_prep_enqueue_set(exp, oinfo, einfo, &set); if (rc) - RETURN(rc); + return rc; list_for_each (pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -1654,11 +1626,11 @@ static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo, LASSERT(rqset->set_interpret == NULL); rqset->set_interpret = lov_enqueue_interpret; rqset->set_arg = (void *)set; - RETURN(rc); + return rc; } out: rc = lov_fini_enqueue_set(set, mode, rc, rqset); - RETURN(rc); + return rc; } static int lov_change_cbdata(struct obd_export *exp, @@ -1667,12 +1639,11 @@ static int lov_change_cbdata(struct obd_export *exp, { struct lov_obd *lov; int rc = 0, i; - ENTRY; ASSERT_LSM_MAGIC(lsm); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; for (i = 0; i < lsm->lsm_stripe_count; i++) { @@ -1689,7 +1660,7 @@ static int lov_change_cbdata(struct obd_export *exp, rc = obd_change_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp, &submd, it, data); } - RETURN(rc); + return rc; } /* find any ldlm lock of the inode in lov @@ -1702,12 +1673,11 @@ static int lov_find_cbdata(struct obd_export *exp, { struct lov_obd *lov; int rc = 0, i; - ENTRY; ASSERT_LSM_MAGIC(lsm); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; for (i = 0; i < lsm->lsm_stripe_count; i++) { @@ -1723,9 +1693,9 @@ static int lov_find_cbdata(struct obd_export *exp, rc = obd_find_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp, &submd, it, data); if (rc != 0) - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm, @@ -1738,18 +1708,17 @@ static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm, struct lov_obd *lov; struct lustre_handle *lov_lockhp; int err = 0, rc = 0; - ENTRY; ASSERT_LSM_MAGIC(lsm); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; LASSERT(lockh); lov = &exp->exp_obd->u.lov; rc = lov_prep_cancel_set(exp, &oinfo, lsm, mode, lockh, &set); if (rc) - RETURN(rc); + return rc; list_for_each(pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -1769,7 +1738,7 @@ static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm, } lov_fini_cancel_set(set); - RETURN(err); + return err; } static int lov_cancel_unused(struct obd_export *exp, @@ -1778,10 +1747,9 @@ static int lov_cancel_unused(struct obd_export *exp, { struct lov_obd *lov; int rc = 0, i; - ENTRY; if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; if (lsm == NULL) { @@ -1795,7 +1763,7 @@ static int lov_cancel_unused(struct obd_export *exp, if (!rc) rc = err; } - RETURN(rc); + return rc; } ASSERT_LSM_MAGIC(lsm); @@ -1827,20 +1795,19 @@ static int lov_cancel_unused(struct obd_export *exp, rc = err; } } - RETURN(rc); + return rc; } int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc) { struct lov_request_set *lovset = (struct lov_request_set *)data; int err; - ENTRY; if (rc) atomic_set(&lovset->set_completes, 0); err = lov_fini_statfs_set(lovset); - RETURN(rc ? rc : err); + return rc ? rc : err; } static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, @@ -1852,7 +1819,6 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, struct list_head *pos; struct lov_obd *lov; int rc = 0; - ENTRY; LASSERT(oinfo != NULL); LASSERT(oinfo->oi_osfs != NULL); @@ -1860,7 +1826,7 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, lov = &obd->u.lov; rc = lov_prep_statfs_set(obd, oinfo, &set); if (rc) - RETURN(rc); + return rc; list_for_each (pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -1875,13 +1841,13 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, if (rc) atomic_set(&set->set_completes, 0); err = lov_fini_statfs_set(set); - RETURN(rc ? rc : err); + return rc ? rc : err; } LASSERT(rqset->set_interpret == NULL); rqset->set_interpret = lov_statfs_interpret; rqset->set_arg = (void *)set; - RETURN(0); + return 0; } static int lov_statfs(const struct lu_env *env, struct obd_export *exp, @@ -1890,14 +1856,12 @@ static int lov_statfs(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request_set *set = NULL; struct obd_info oinfo = { { { 0 } } }; int rc = 0; - ENTRY; - /* for obdclass we forbid using obd_statfs_rqset, but prefer using async * statfs requests */ set = ptlrpc_prep_set(); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; oinfo.oi_osfs = osfs; oinfo.oi_flags = flags; @@ -1906,7 +1870,7 @@ static int lov_statfs(const struct lu_env *env, struct obd_export *exp, rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, @@ -1916,7 +1880,6 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct lov_obd *lov = &obddev->u.lov; int i = 0, rc = 0, count = lov->desc.ld_tgt_count; struct obd_uuid *uuidp; - ENTRY; switch (cmd) { case IOC_OBD_STATFS: { @@ -1928,23 +1891,23 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, memcpy(&index, data->ioc_inlbuf2, sizeof(__u32)); if ((index >= count)) - RETURN(-ENODEV); + return -ENODEV; if (!lov->lov_tgts[index]) /* Try again with the next index */ - RETURN(-EAGAIN); + return -EAGAIN; if (!lov->lov_tgts[index]->ltd_active) - RETURN(-ENODATA); + return -ENODATA; osc_obd = class_exp2obd(lov->lov_tgts[index]->ltd_exp); if (!osc_obd) - RETURN(-EINVAL); + return -EINVAL; /* copy UUID */ if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(osc_obd), min((int) data->ioc_plen2, (int) sizeof(struct obd_uuid)))) - RETURN(-EFAULT); + return -EFAULT; flags = uarg ? *(__u32*)uarg : 0; /* got statfs data */ @@ -1952,11 +1915,11 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), flags); if (rc) - RETURN(rc); + return rc; if (copy_to_user(data->ioc_pbuf1, &stat_buf, min((int) data->ioc_plen1, (int) sizeof(stat_buf)))) - RETURN(-EFAULT); + return -EFAULT; break; } case OBD_IOC_LOV_GET_CONFIG: { @@ -1967,23 +1930,23 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, len = 0; if (obd_ioctl_getdata(&buf, &len, (void *)uarg)) - RETURN(-EINVAL); + return -EINVAL; data = (struct obd_ioctl_data *)buf; if (sizeof(*desc) > data->ioc_inllen1) { obd_ioctl_freedata(buf, len); - RETURN(-EINVAL); + return -EINVAL; } if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) { obd_ioctl_freedata(buf, len); - RETURN(-EINVAL); + return -EINVAL; } if (sizeof(__u32) * count > data->ioc_inllen3) { obd_ioctl_freedata(buf, len); - RETURN(-EINVAL); + return -EINVAL; } desc = (struct lov_desc *)data->ioc_inlbuf1; @@ -2020,11 +1983,11 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (qctl->qc_valid == QC_OSTIDX) { if (qctl->qc_idx < 0 || count <= qctl->qc_idx) - RETURN(-EINVAL); + return -EINVAL; tgt = lov->lov_tgts[qctl->qc_idx]; if (!tgt || !tgt->ltd_exp) - RETURN(-EINVAL); + return -EINVAL; } else if (qctl->qc_valid == QC_UUID) { for (i = 0; i < count; i++) { tgt = lov->lov_tgts[i]; @@ -2034,21 +1997,21 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, continue; if (tgt->ltd_exp == NULL) - RETURN(-EINVAL); + return -EINVAL; break; } } else { - RETURN(-EINVAL); + return -EINVAL; } if (i >= count) - RETURN(-EAGAIN); + return -EAGAIN; LASSERT(tgt && tgt->ltd_exp); OBD_ALLOC_PTR(oqctl); if (!oqctl) - RETURN(-ENOMEM); + return -ENOMEM; QCTL_COPY(oqctl, qctl); rc = obd_quotactl(tgt->ltd_exp, oqctl); @@ -2064,7 +2027,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, int set = 0; if (count == 0) - RETURN(-ENOTTY); + return -ENOTTY; for (i = 0; i < count; i++) { int err; @@ -2081,7 +2044,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, err = obd_iocontrol(cmd, lov->lov_tgts[i]->ltd_exp, len, karg, uarg); if (err == -ENODATA && cmd == OBD_IOC_POLL_QUOTACHECK) { - RETURN(err); + return err; } else if (err) { if (lov->lov_tgts[i]->ltd_active) { CDEBUG(err == -ENOTTY ? @@ -2102,7 +2065,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, } } - RETURN(rc); + return rc; } #define FIEMAP_BUFFER_SIZE 4096 @@ -2259,7 +2222,7 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, int cur_stripe = 0, cur_stripe_wrap = 0, stripe_count; unsigned int buffer_size = FIEMAP_BUFFER_SIZE; - if (lsm == NULL) + if (!lsm_has_objects(lsm)) GOTO(out, rc = 0); if (fiemap_count_to_size(fm_key->fiemap.fm_extent_count) < buffer_size) @@ -2469,10 +2432,9 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp, struct obd_device *obddev = class_exp2obd(exp); struct lov_obd *lov = &obddev->u.lov; int i, rc; - ENTRY; if (!vallen || !val) - RETURN(-EFAULT); + return -EFAULT; obd_getref(obddev); @@ -2553,7 +2515,7 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp, out: obd_putref(obddev); - RETURN(rc); + return rc; } static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, @@ -2568,14 +2530,13 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, unsigned incr, check_uuid, do_inactive, no_set; unsigned next_id = 0, mds_con = 0, capa = 0; - ENTRY; incr = check_uuid = do_inactive = no_set = 0; if (set == NULL) { no_set = 1; set = ptlrpc_prep_set(); if (!set) - RETURN(-ENOMEM); + return -ENOMEM; } obd_getref(obddev); @@ -2667,7 +2628,7 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, rc = err; ptlrpc_set_destroy(set); } - RETURN(rc); + return rc; } static int lov_extent_calc(struct obd_export *exp, struct lov_stripe_md *lsm, @@ -2691,7 +2652,7 @@ static int lov_extent_calc(struct obd_export *exp, struct lov_stripe_md *lsm, LBUG(); } - RETURN(0); + return 0; } void lov_stripe_lock(struct lov_stripe_md *md) @@ -2719,7 +2680,6 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, __u64 curspace = 0; __u64 bhardlimit = 0; int i, rc = 0; - ENTRY; if (oqctl->qc_cmd != LUSTRE_Q_QUOTAON && oqctl->qc_cmd != LUSTRE_Q_QUOTAOFF && @@ -2728,7 +2688,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, oqctl->qc_cmd != LUSTRE_Q_SETQUOTA && oqctl->qc_cmd != Q_FINVALIDATE) { CERROR("bad quota opc %x for lov obd", oqctl->qc_cmd); - RETURN(-EFAULT); + return -EFAULT; } /* for lov tgt */ @@ -2770,7 +2730,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, oqctl->qc_dqblk.dqb_curspace = curspace; oqctl->qc_dqblk.dqb_bhardlimit = bhardlimit; } - RETURN(rc); + return rc; } static int lov_quotacheck(struct obd_device *obd, struct obd_export *exp, @@ -2778,7 +2738,6 @@ static int lov_quotacheck(struct obd_device *obd, struct obd_export *exp, { struct lov_obd *lov = &obd->u.lov; int i, rc = 0; - ENTRY; obd_getref(obd); @@ -2814,7 +2773,7 @@ static int lov_quotacheck(struct obd_device *obd, struct obd_export *exp, out: obd_putref(obd); - RETURN(rc); + return rc; } struct obd_ops lov_obd_ops = { @@ -2870,7 +2829,6 @@ int __init lov_init(void) { struct lprocfs_static_vars lvars = { 0 }; int rc; - ENTRY; /* print an address of _any_ initialized kernel symbol from this * module, to allow debugging with gdb that doesn't support data @@ -2898,7 +2856,7 @@ int __init lov_init(void) lu_kmem_fini(lov_caches); } - RETURN(rc); + return rc; } static void /*__exit*/ lov_exit(void) @@ -2912,5 +2870,7 @@ static void /*__exit*/ lov_exit(void) MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); MODULE_DESCRIPTION("Lustre Logical Object Volume OBD driver"); MODULE_LICENSE("GPL"); +MODULE_VERSION(LUSTRE_VERSION_STRING); -cfs_module(lov, LUSTRE_VERSION_STRING, lov_init, lov_exit); +module_init(lov_init); +module_exit(lov_exit); diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index aa8ae80e812..84e55ce3ccd 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -116,10 +116,9 @@ static struct cl_object *lov_sub_find(const struct lu_env *env, { struct lu_object *o; - ENTRY; o = lu_object_find_at(env, cl2lu_dev(dev), fid, &conf->coc_lu); LASSERT(ergo(!IS_ERR(o), o->lo_dev->ld_type == &lovsub_device_type)); - RETURN(lu2cl(o)); + return lu2cl(o); } static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, @@ -204,8 +203,6 @@ static int lov_init_raid0(const struct lu_env *env, struct lu_fid *ofid = <i->lti_fid; struct lov_layout_raid0 *r0 = &state->raid0; - ENTRY; - if (lsm->lsm_magic != LOV_MAGIC_V1 && lsm->lsm_magic != LOV_MAGIC_V3) { dump_lsm(D_ERROR, lsm); LASSERTF(0, "magic mismatch, expected %d/%d, actual %d.\n", @@ -255,13 +252,28 @@ static int lov_init_raid0(const struct lu_env *env, } else result = -ENOMEM; out: - RETURN(result); + return result; +} + +static int lov_init_released(const struct lu_env *env, + struct lov_device *dev, struct lov_object *lov, + const struct cl_object_conf *conf, + union lov_layout_state *state) +{ + struct lov_stripe_md *lsm = conf->u.coc_md->lsm; + + LASSERT(lsm != NULL); + LASSERT(lsm_is_released(lsm)); + LASSERT(lov->lo_lsm == NULL); + + lov->lo_lsm = lsm_addref(lsm); + return 0; } static int lov_delete_empty(const struct lu_env *env, struct lov_object *lov, union lov_layout_state *state) { - LASSERT(lov->lo_type == LLT_EMPTY); + LASSERT(lov->lo_type == LLT_EMPTY || lov->lo_type == LLT_RELEASED); lov_layout_wait(env, lov); @@ -323,8 +335,6 @@ static int lov_delete_raid0(const struct lu_env *env, struct lov_object *lov, struct lov_stripe_md *lsm = lov->lo_lsm; int i; - ENTRY; - dump_lsm(D_INODE, lsm); lov_layout_wait(env, lov); @@ -343,20 +353,19 @@ static int lov_delete_raid0(const struct lu_env *env, struct lov_object *lov, } } cl_object_prune(env, &lov->lo_cl); - RETURN(0); + return 0; } static void lov_fini_empty(const struct lu_env *env, struct lov_object *lov, union lov_layout_state *state) { - LASSERT(lov->lo_type == LLT_EMPTY); + LASSERT(lov->lo_type == LLT_EMPTY || lov->lo_type == LLT_RELEASED); } static void lov_fini_raid0(const struct lu_env *env, struct lov_object *lov, union lov_layout_state *state) { struct lov_layout_raid0 *r0 = &state->raid0; - ENTRY; if (r0->lo_sub != NULL) { OBD_FREE_LARGE(r0->lo_sub, r0->lo_nr * sizeof r0->lo_sub[0]); @@ -365,8 +374,13 @@ static void lov_fini_raid0(const struct lu_env *env, struct lov_object *lov, dump_lsm(D_INODE, lov->lo_lsm); lov_free_memmd(&lov->lo_lsm); +} - EXIT; +static void lov_fini_released(const struct lu_env *env, struct lov_object *lov, + union lov_layout_state *state) +{ + dump_lsm(D_INODE, lov->lo_lsm); + lov_free_memmd(&lov->lo_lsm); } static int lov_print_empty(const struct lu_env *env, void *cookie, @@ -400,6 +414,13 @@ static int lov_print_raid0(const struct lu_env *env, void *cookie, return 0; } +static int lov_print_released(const struct lu_env *env, void *cookie, + lu_printer_t p, const struct lu_object *o) +{ + (*p)(env, cookie, "released\n"); + return 0; +} + /** * Implements cl_object_operations::coo_attr_get() method for an object * without stripes (LLT_EMPTY layout type). @@ -422,8 +443,6 @@ static int lov_attr_get_raid0(const struct lu_env *env, struct cl_object *obj, struct cl_attr *lov_attr = &r0->lo_attr; int result = 0; - ENTRY; - /* this is called w/o holding type guard mutex, so it must be inside * an on going IO otherwise lsm may be replaced. * LU-2117: it turns out there exists one exception. For mmaped files, @@ -478,7 +497,7 @@ static int lov_attr_get_raid0(const struct lu_env *env, struct cl_object *obj, if (attr->cat_mtime < lov_attr->cat_mtime) attr->cat_mtime = lov_attr->cat_mtime; } - RETURN(result); + return result; } const static struct lov_layout_operations lov_dispatch[] = { @@ -503,10 +522,20 @@ const static struct lov_layout_operations lov_dispatch[] = { .llo_lock_init = lov_lock_init_raid0, .llo_io_init = lov_io_init_raid0, .llo_getattr = lov_attr_get_raid0 + }, + [LLT_RELEASED] = { + .llo_init = lov_init_released, + .llo_delete = lov_delete_empty, + .llo_fini = lov_fini_released, + .llo_install = lov_install_empty, + .llo_print = lov_print_released, + .llo_page_init = lov_page_init_empty, + .llo_lock_init = lov_lock_init_empty, + .llo_io_init = lov_io_init_released, + .llo_getattr = lov_attr_get_empty } }; - /** * Performs a double-dispatch based on the layout type of an object. */ @@ -520,6 +549,18 @@ const static struct lov_layout_operations lov_dispatch[] = { lov_dispatch[__llt].op(__VA_ARGS__); \ }) +/** + * Return lov_layout_type associated with a given lsm + */ +enum lov_layout_type lov_type(struct lov_stripe_md *lsm) +{ + if (lsm == NULL) + return LLT_EMPTY; + if (lsm_is_released(lsm)) + return LLT_RELEASED; + return LLT_RAID0; +} + static inline void lov_conf_freeze(struct lov_object *lov) { if (lov->lo_owner != current) @@ -581,7 +622,6 @@ static void lov_conf_unlock(struct lov_object *lov) static int lov_layout_wait(const struct lu_env *env, struct lov_object *lov) { struct l_wait_info lwi = { 0 }; - ENTRY; while (atomic_read(&lov->lo_active_ios) > 0) { CDEBUG(D_INODE, "file:"DFID" wait for active IO, now: %d.\n", @@ -591,7 +631,7 @@ static int lov_layout_wait(const struct lu_env *env, struct lov_object *lov) l_wait_event(lov->lo_waitq, atomic_read(&lov->lo_active_ios) == 0, &lwi); } - RETURN(0); + return 0; } static int lov_layout_change(const struct lu_env *unused, @@ -608,19 +648,18 @@ static int lov_layout_change(const struct lu_env *unused, void *cookie; struct lu_env *env; int refcheck; - ENTRY; LASSERT(0 <= lov->lo_type && lov->lo_type < ARRAY_SIZE(lov_dispatch)); - if (conf->u.coc_md != NULL && conf->u.coc_md->lsm != NULL) - llt = LLT_RAID0; /* only raid0 is supported. */ + if (conf->u.coc_md != NULL) + llt = lov_type(conf->u.coc_md->lsm); LASSERT(0 <= llt && llt < ARRAY_SIZE(lov_dispatch)); cookie = cl_env_reenter(); env = cl_env_get(&refcheck); if (IS_ERR(env)) { cl_env_reexit(cookie); - RETURN(PTR_ERR(env)); + return PTR_ERR(env); } old_ops = &lov_dispatch[lov->lo_type]; @@ -650,7 +689,7 @@ static int lov_layout_change(const struct lu_env *unused, cl_env_put(env, &refcheck); cl_env_reexit(cookie); - RETURN(result); + return result; } /***************************************************************************** @@ -658,7 +697,6 @@ static int lov_layout_change(const struct lu_env *unused, * Lov object operations. * */ - int lov_object_init(const struct lu_env *env, struct lu_object *obj, const struct lu_object_conf *conf) { @@ -669,7 +707,6 @@ int lov_object_init(const struct lu_env *env, struct lu_object *obj, const struct lov_layout_operations *ops; int result; - ENTRY; init_rwsem(&lov->lo_type_guard); atomic_set(&lov->lo_active_ios, 0); init_waitqueue_head(&lov->lo_waitq); @@ -677,21 +714,20 @@ int lov_object_init(const struct lu_env *env, struct lu_object *obj, cl_object_page_init(lu2cl(obj), sizeof(struct lov_page)); /* no locking is necessary, as object is being created */ - lov->lo_type = cconf->u.coc_md->lsm != NULL ? LLT_RAID0 : LLT_EMPTY; + lov->lo_type = lov_type(cconf->u.coc_md->lsm); ops = &lov_dispatch[lov->lo_type]; result = ops->llo_init(env, dev, lov, cconf, set); if (result == 0) ops->llo_install(env, lov, set); - RETURN(result); + return result; } static int lov_conf_set(const struct lu_env *env, struct cl_object *obj, const struct cl_object_conf *conf) { - struct lov_stripe_md *lsm = NULL; - struct lov_object *lov = cl2lov(obj); - int result = 0; - ENTRY; + struct lov_stripe_md *lsm = NULL; + struct lov_object *lov = cl2lov(obj); + int result = 0; lov_conf_lock(lov); if (conf->coc_opc == OBJECT_CONF_INVALIDATE) { @@ -728,31 +764,26 @@ static int lov_conf_set(const struct lu_env *env, struct cl_object *obj, } lov->lo_layout_invalid = lov_layout_change(env, lov, conf); - EXIT; out: lov_conf_unlock(lov); - RETURN(result); + return result; } static void lov_object_delete(const struct lu_env *env, struct lu_object *obj) { struct lov_object *lov = lu2lov(obj); - ENTRY; LOV_2DISPATCH_VOID(lov, llo_delete, env, lov, &lov->u); - EXIT; } static void lov_object_free(const struct lu_env *env, struct lu_object *obj) { struct lov_object *lov = lu2lov(obj); - ENTRY; LOV_2DISPATCH_VOID(lov, llo_fini, env, lov, &lov->u); lu_object_fini(obj); OBD_SLAB_FREE_PTR(lov, lov_object_kmem); - EXIT; } static int lov_object_print(const struct lu_env *env, void *cookie, @@ -835,7 +866,6 @@ struct lu_object *lov_object_alloc(const struct lu_env *env, struct lov_object *lov; struct lu_object *obj; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lov, lov_object_kmem, __GFP_IO); if (lov != NULL) { obj = lov2lu(lov); @@ -850,7 +880,7 @@ struct lu_object *lov_object_alloc(const struct lu_env *env, obj->lo_ops = &lov_lu_obj_ops; } else obj = NULL; - RETURN(obj); + return obj; } struct lov_stripe_md *lov_lsm_addref(struct lov_object *lov) @@ -906,7 +936,6 @@ int lov_read_and_clear_async_rc(struct cl_object *clob) { struct lu_object *luobj; int rc = 0; - ENTRY; luobj = lu_object_locate(&cl_object_header(clob)->coh_lu, &lov_device_type); @@ -928,6 +957,7 @@ int lov_read_and_clear_async_rc(struct cl_object *clob) loi->loi_ar.ar_rc = 0; } } + case LLT_RELEASED: case LLT_EMPTY: break; default: @@ -935,7 +965,7 @@ int lov_read_and_clear_async_rc(struct cl_object *clob) } lov_conf_thaw(lov); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(lov_read_and_clear_async_rc); diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c index f62b7e53b66..04863a7c5e0 100644 --- a/drivers/staging/lustre/lustre/lov/lov_offset.c +++ b/drivers/staging/lustre/lustre/lov/lov_offset.c @@ -52,10 +52,9 @@ obd_size lov_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size, obd_off swidth; obd_size lov_size; int magic = lsm->lsm_magic; - ENTRY; if (ost_size == 0) - RETURN(0); + return 0; LASSERT(lsm_op_find(magic) != NULL); lsm_op_find(magic)->lsm_stripe_by_index(lsm, &stripeno, NULL, &swidth); @@ -67,7 +66,7 @@ obd_size lov_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size, else lov_size = (ost_size - 1) * swidth + (stripeno + 1) * ssize; - RETURN(lov_size); + return lov_size; } /* we have an offset in file backed by an lov and want to find out where diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 492948aad68..55ec26778f8 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -143,7 +143,6 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, int lmm_size, lmm_magic; int i; int cplen = 0; - ENTRY; if (lsm) { lmm_magic = lsm->lsm_magic; @@ -159,7 +158,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, (lmm_magic != LOV_MAGIC_V3)) { CERROR("bad mem LOV MAGIC: 0x%08X != 0x%08X nor 0x%08X\n", lmm_magic, LOV_MAGIC_V1, LOV_MAGIC_V3); - RETURN(-EINVAL); + return -EINVAL; } @@ -168,10 +167,12 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, * to the actual number of OSTs in this filesystem. */ if (!lmmp) { stripe_count = lov_get_stripecnt(lov, lmm_magic, - lsm->lsm_stripe_count); + lsm->lsm_stripe_count); lsm->lsm_stripe_count = stripe_count; - } else { + } else if (!lsm_is_released(lsm)) { stripe_count = lsm->lsm_stripe_count; + } else { + stripe_count = 0; } } else { /* No need to allocate more than maximum supported stripes. @@ -188,20 +189,20 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, lmm_size = lov_mds_md_size(stripe_count, lmm_magic); if (!lmmp) - RETURN(lmm_size); + return lmm_size; if (*lmmp && !lsm) { stripe_count = le16_to_cpu((*lmmp)->lmm_stripe_count); lmm_size = lov_mds_md_size(stripe_count, lmm_magic); OBD_FREE_LARGE(*lmmp, lmm_size); *lmmp = NULL; - RETURN(0); + return 0; } if (!*lmmp) { OBD_ALLOC_LARGE(*lmmp, lmm_size); if (!*lmmp) - RETURN(-ENOMEM); + return -ENOMEM; } CDEBUG(D_INFO, "lov_packmd: LOV_MAGIC 0x%08X, lmm_size = %d \n", @@ -215,7 +216,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, lmmv1->lmm_magic = cpu_to_le32(LOV_MAGIC_V1); if (!lsm) - RETURN(lmm_size); + return lmm_size; /* lmmv1 and lmmv3 point to the same struct and have the * same first fields @@ -229,7 +230,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, cplen = strlcpy(lmmv3->lmm_pool_name, lsm->lsm_pool_name, sizeof(lmmv3->lmm_pool_name)); if (cplen >= sizeof(lmmv3->lmm_pool_name)) - RETURN(-E2BIG); + return -E2BIG; lmm_objects = lmmv3->lmm_objects; } else { lmm_objects = lmmv1->lmm_objects; @@ -246,7 +247,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, lmm_objects[i].l_ost_idx = cpu_to_le32(loi->loi_ost_idx); } - RETURN(lmm_size); + return lmm_size; } /* Find the max stripecount we should use */ @@ -307,14 +308,13 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, __u16 stripe_count, int pattern, int magic) { int i, lsm_size; - ENTRY; CDEBUG(D_INFO, "alloc lsm, stripe_count %d\n", stripe_count); *lsmp = lsm_alloc_plain(stripe_count, &lsm_size); if (!*lsmp) { CERROR("can't allocate lsmp stripe_count %d\n", stripe_count); - RETURN(-ENOMEM); + return -ENOMEM; } atomic_set(&(*lsmp)->lsm_refc, 1); @@ -325,12 +325,13 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, __u16 stripe_count, (*lsmp)->lsm_pattern = pattern; (*lsmp)->lsm_pool_name[0] = '\0'; (*lsmp)->lsm_layout_gen = 0; - (*lsmp)->lsm_oinfo[0]->loi_ost_idx = ~0; + if (stripe_count > 0) + (*lsmp)->lsm_oinfo[0]->loi_ost_idx = ~0; for (i = 0; i < stripe_count; i++) loi_init((*lsmp)->lsm_oinfo[i]); - RETURN(lsm_size); + return lsm_size; } int lov_free_memmd(struct lov_stripe_md **lsmp) @@ -359,13 +360,13 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, int rc = 0, lsm_size; __u16 stripe_count; __u32 magic; - ENTRY; + __u32 pattern; /* If passed an MDS struct use values from there, otherwise defaults */ if (lmm) { rc = lov_verify_lmm(lmm, lmm_bytes, &stripe_count); if (rc) - RETURN(rc); + return rc; magic = le32_to_cpu(lmm->lmm_magic); } else { magic = LOV_MAGIC; @@ -376,31 +377,31 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, if (!lsmp) { /* XXX LOV STACKING call into osc for sizes */ LBUG(); - RETURN(lov_stripe_md_size(stripe_count)); + return lov_stripe_md_size(stripe_count); } /* If we are passed an allocated struct but nothing to unpack, free */ if (*lsmp && !lmm) { lov_free_memmd(lsmp); - RETURN(0); + return 0; } - lsm_size = lov_alloc_memmd(lsmp, stripe_count, LOV_PATTERN_RAID0, - magic); + pattern = le32_to_cpu(lmm->lmm_pattern); + lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic); if (lsm_size < 0) - RETURN(lsm_size); + return lsm_size; /* If we are passed a pointer but nothing to unpack, we only alloc */ if (!lmm) - RETURN(lsm_size); + return lsm_size; LASSERT(lsm_op_find(magic) != NULL); rc = lsm_op_find(magic)->lsm_unpackmd(lov, *lsmp, lmm); if (rc) { lov_free_memmd(lsmp); - RETURN(rc); + return rc; } - RETURN(lsm_size); + return lsm_size; } static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, @@ -416,11 +417,10 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, __u16 stripe_count; int rc; int cplen = 0; - ENTRY; rc = lov_lum_swab_if_needed(lumv3, &lmm_magic, lump); if (rc) - RETURN(rc); + return rc; /* in the rest of the tests, as *lumv1 and lumv3 have the same * fields, we use lumv1 to avoid code duplication */ @@ -430,10 +430,10 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, lov->desc.ld_pattern : LOV_PATTERN_RAID0; } - if (lumv1->lmm_pattern != LOV_PATTERN_RAID0) { + if (lov_pattern(lumv1->lmm_pattern) != LOV_PATTERN_RAID0) { CDEBUG(D_IOCTL, "bad userland stripe pattern: %#x\n", lumv1->lmm_pattern); - RETURN(-EINVAL); + return -EINVAL; } /* 64kB is the largest common page size we see (ia64), and matches the @@ -449,7 +449,7 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, (typeof(lumv1->lmm_stripe_offset))(-1))) { CDEBUG(D_IOCTL, "stripe offset %u > number of OSTs %u\n", lumv1->lmm_stripe_offset, lov->desc.ld_tgt_count); - RETURN(-EINVAL); + return -EINVAL; } stripe_count = lov_get_stripecnt(lov, lmm_magic, lumv1->lmm_stripe_count); @@ -479,7 +479,7 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, lumv3->lmm_stripe_offset, pool); if (rc < 0) { lov_pool_putref(pool); - RETURN(-EINVAL); + return -EINVAL; } } @@ -490,6 +490,9 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, } } + if (lumv1->lmm_pattern & LOV_PATTERN_F_RELEASED) + stripe_count = 0; + rc = lov_alloc_memmd(lsmp, stripe_count, lumv1->lmm_pattern, lmm_magic); if (rc >= 0) { @@ -505,7 +508,7 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, rc = 0; } - RETURN(rc); + return rc; } /* Configure object striping information on a new file. @@ -526,7 +529,7 @@ int lov_setstripe(struct obd_export *exp, int max_lmm_size, rc = __lov_setstripe(exp, max_lmm_size, lsmp, lump); set_fs(seg); - RETURN(rc); + return rc; } int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp, @@ -539,8 +542,6 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp, obd_id last_id = 0; struct lov_user_ost_data_v1 *lmm_objects; - ENTRY; - if (lump->lmm_magic == LOV_USER_MAGIC_V3) lmm_objects = ((struct lov_user_md_v3 *)lump)->lmm_objects; else @@ -552,26 +553,26 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp, rc = obd_get_info(NULL, oexp, sizeof(KEY_LAST_ID), KEY_LAST_ID, &len, &last_id, NULL); if (rc) - RETURN(rc); + 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", lmm_objects[i].l_ost_idx, POSTID(&lmm_objects[i].l_ost_oi), last_id); - RETURN(-EINVAL); + return -EINVAL; } } rc = lov_setstripe(exp, 0, lsmp, lump); if (rc) - RETURN(rc); + return rc; for (i = 0; i < lump->lmm_stripe_count; i++) { (*lsmp)->lsm_oinfo[i]->loi_ost_idx = lmm_objects[i].l_ost_idx; (*lsmp)->lsm_oinfo[i]->loi_oi = lmm_objects[i].l_ost_oi; } - RETURN(0); + return 0; } @@ -593,10 +594,9 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm, int rc, lmm_size; int lum_size; mm_segment_t seg; - ENTRY; if (!lsm) - RETURN(-ENODATA); + return -ENODATA; /* * "Switch to kernel segment" to allow copying from kernel space by @@ -674,5 +674,5 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm, obd_free_diskmd(exp, &lmmk); out_set: set_fs(seg); - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c index 65790d68472..674e61781c2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_page.c +++ b/drivers/staging/lustre/lustre/lov/lov_page.c @@ -69,7 +69,6 @@ static void lov_page_fini(const struct lu_env *env, struct cl_page *sub = lov_sub_page(slice); LINVRNT(lov_page_invariant(slice)); - ENTRY; if (sub != NULL) { LASSERT(sub->cp_state == CPS_FREEING); @@ -78,7 +77,6 @@ static void lov_page_fini(const struct lu_env *env, slice->cpl_page->cp_child = NULL; cl_page_put(env, sub); } - EXIT; } static int lov_page_own(const struct lu_env *env, @@ -90,7 +88,6 @@ static int lov_page_own(const struct lu_env *env, LINVRNT(lov_page_invariant(slice)); LINVRNT(!cl2lov_page(slice)->lps_invalid); - ENTRY; sub = lov_page_subio(env, lio, slice); if (!IS_ERR(sub)) { @@ -98,7 +95,7 @@ static int lov_page_own(const struct lu_env *env, lov_sub_put(sub); } else LBUG(); /* Arrgh */ - RETURN(0); + return 0; } static void lov_page_assume(const struct lu_env *env, @@ -117,7 +114,6 @@ static int lov_page_cache_add(const struct lu_env *env, LINVRNT(lov_page_invariant(slice)); LINVRNT(!cl2lov_page(slice)->lps_invalid); - ENTRY; sub = lov_page_subio(env, lio, slice); if (!IS_ERR(sub)) { @@ -128,7 +124,7 @@ static int lov_page_cache_add(const struct lu_env *env, rc = PTR_ERR(sub); CL_PAGE_DEBUG(D_ERROR, env, slice->cpl_page, "rc = %d\n", rc); } - RETURN(rc); + return rc; } static int lov_page_print(const struct lu_env *env, @@ -172,7 +168,6 @@ int lov_page_init_raid0(const struct lu_env *env, struct cl_object *obj, obd_off suboff; int stripe; int rc; - ENTRY; offset = cl_offset(obj, page->cp_index); stripe = lov_stripe_number(loo->lo_lsm, offset); @@ -205,7 +200,6 @@ int lov_page_init_raid0(const struct lu_env *env, struct cl_object *obj, LASSERT(0); } - EXIT; out: return rc; } @@ -221,14 +215,13 @@ int lov_page_init_empty(const struct lu_env *env, struct cl_object *obj, { struct lov_page *lpg = cl_object_page_slice(obj, page); void *addr; - ENTRY; cl_page_slice_add(page, &lpg->lps_cl, obj, &lov_empty_page_ops); addr = kmap(vmpage); memset(addr, 0, cl_page_size(obj)); kunmap(vmpage); cl_page_export(env, page, 1); - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index a96f90880c6..dd3c07d5c4d 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -68,7 +68,6 @@ void lov_pool_putref(struct pool_desc *pool) lov_ost_pool_free(&(pool->pool_rr.lqr_pool)); lov_ost_pool_free(&(pool->pool_obds)); OBD_FREE_PTR(pool); - EXIT; } } @@ -322,8 +321,6 @@ void lov_dump_pool(int level, struct pool_desc *pool) #define LOV_POOL_INIT_COUNT 2 int lov_ost_pool_init(struct ost_pool *op, unsigned int count) { - ENTRY; - if (count == 0) count = LOV_POOL_INIT_COUNT; op->op_array = NULL; @@ -333,9 +330,8 @@ int lov_ost_pool_init(struct ost_pool *op, unsigned int count) OBD_ALLOC(op->op_array, op->op_size * sizeof(op->op_array[0])); if (op->op_array == NULL) { op->op_size = 0; - RETURN(-ENOMEM); + return -ENOMEM; } - EXIT; return 0; } @@ -366,7 +362,6 @@ int lov_ost_pool_extend(struct ost_pool *op, unsigned int min_count) int lov_ost_pool_add(struct ost_pool *op, __u32 idx, unsigned int min_count) { int rc = 0, i; - ENTRY; down_write(&op->op_rw_sem); @@ -382,7 +377,6 @@ int lov_ost_pool_add(struct ost_pool *op, __u32 idx, unsigned int min_count) /* ost not found we add it */ op->op_array[op->op_count] = idx; op->op_count++; - EXIT; out: up_write(&op->op_rw_sem); return rc; @@ -391,7 +385,6 @@ out: int lov_ost_pool_remove(struct ost_pool *op, __u32 idx) { int i; - ENTRY; down_write(&op->op_rw_sem); @@ -401,21 +394,18 @@ int lov_ost_pool_remove(struct ost_pool *op, __u32 idx) (op->op_count - i - 1) * sizeof(op->op_array[0])); op->op_count--; up_write(&op->op_rw_sem); - EXIT; return 0; } } up_write(&op->op_rw_sem); - RETURN(-EINVAL); + return -EINVAL; } int lov_ost_pool_free(struct ost_pool *op) { - ENTRY; - if (op->op_size == 0) - RETURN(0); + return 0; down_write(&op->op_rw_sem); @@ -425,7 +415,7 @@ int lov_ost_pool_free(struct ost_pool *op) op->op_size = 0; up_write(&op->op_rw_sem); - RETURN(0); + return 0; } @@ -434,16 +424,15 @@ int lov_pool_new(struct obd_device *obd, char *poolname) struct lov_obd *lov; struct pool_desc *new_pool; int rc; - ENTRY; lov = &(obd->u.lov); if (strlen(poolname) > LOV_MAXPOOLNAME) - RETURN(-ENAMETOOLONG); + return -ENAMETOOLONG; OBD_ALLOC_PTR(new_pool); if (new_pool == NULL) - RETURN(-ENOMEM); + return -ENOMEM; strncpy(new_pool->pool_name, poolname, LOV_MAXPOOLNAME); new_pool->pool_name[LOV_MAXPOOLNAME] = '\0'; @@ -492,7 +481,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname) CDEBUG(D_CONFIG, LOV_POOLNAMEF" is pool #%d\n", poolname, lov->lov_pool_count); - RETURN(0); + return 0; out_err: spin_lock(&obd->obd_dev_lock); @@ -513,14 +502,13 @@ int lov_pool_del(struct obd_device *obd, char *poolname) { struct lov_obd *lov; struct pool_desc *pool; - ENTRY; lov = &(obd->u.lov); /* lookup and kill hash reference */ pool = cfs_hash_del_key(lov->lov_pools_hash_body, poolname); if (pool == NULL) - RETURN(-ENOENT); + return -ENOENT; if (pool->pool_proc_entry != NULL) { CDEBUG(D_INFO, "proc entry %p\n", pool->pool_proc_entry); @@ -536,7 +524,7 @@ int lov_pool_del(struct obd_device *obd, char *poolname) /* release last reference */ lov_pool_putref(pool); - RETURN(0); + return 0; } @@ -547,13 +535,12 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname) struct pool_desc *pool; unsigned int lov_idx; int rc; - ENTRY; lov = &(obd->u.lov); pool = cfs_hash_lookup(lov->lov_pools_hash_body, poolname); if (pool == NULL) - RETURN(-ENOENT); + return -ENOENT; obd_str2uuid(&ost_uuid, ostname); @@ -580,7 +567,6 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname) CDEBUG(D_CONFIG, "Added %s to "LOV_POOLNAMEF" as member %d\n", ostname, poolname, pool_tgt_count(pool)); - EXIT; out: obd_putref(obd); lov_pool_putref(pool); @@ -594,13 +580,12 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) struct pool_desc *pool; unsigned int lov_idx; int rc = 0; - ENTRY; lov = &(obd->u.lov); pool = cfs_hash_lookup(lov->lov_pools_hash_body, poolname); if (pool == NULL) - RETURN(-ENOENT); + return -ENOENT; obd_str2uuid(&ost_uuid, ostname); @@ -626,7 +611,6 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) CDEBUG(D_CONFIG, "%s removed from "LOV_POOLNAMEF"\n", ostname, poolname); - EXIT; out: obd_putref(obd); lov_pool_putref(pool); @@ -636,7 +620,6 @@ out: int lov_check_index_in_pool(__u32 idx, struct pool_desc *pool) { int i, rc; - ENTRY; /* caller may no have a ref on pool if it got the pool * without calling lov_find_pool() (e.g. go through the lov pool @@ -651,7 +634,6 @@ int lov_check_index_in_pool(__u32 idx, struct pool_desc *pool) GOTO(out, rc = 0); } rc = -ENOENT; - EXIT; out: up_read(&pool_tgt_rw_sem(pool)); diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 13f1637bc70..61e6d0b46c9 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -60,7 +60,6 @@ static void lov_init_set(struct lov_request_set *set) void lov_finish_set(struct lov_request_set *set) { struct list_head *pos, *n; - ENTRY; LASSERT(set); list_for_each_safe(pos, n, &set->set_list) { @@ -87,7 +86,6 @@ void lov_finish_set(struct lov_request_set *set) lov_llh_put(set->set_lockh); OBD_FREE(set, sizeof(*set)); - EXIT; } int lov_set_finished(struct lov_request_set *set, int idempotent) @@ -122,7 +120,6 @@ int lov_update_common_set(struct lov_request_set *set, struct lov_request *req, int rc) { struct lov_obd *lov = &set->set_exp->exp_obd->u.lov; - ENTRY; lov_update_set(set, req, rc); @@ -132,7 +129,7 @@ int lov_update_common_set(struct lov_request_set *set, rc = 0; /* FIXME in raid1 regime, should return 0 */ - RETURN(rc); + return rc; } void lov_set_add_req(struct lov_request *req, struct lov_request_set *set) @@ -232,7 +229,6 @@ int lov_update_enqueue_set(struct lov_request *req, __u32 mode, int rc) struct lustre_handle *lov_lockhp; struct obd_info *oi = set->set_oi; struct lov_oinfo *loi; - ENTRY; LASSERT(oi != NULL); @@ -254,7 +250,7 @@ int lov_update_enqueue_set(struct lov_request *req, __u32 mode, int rc) req->rq_idx, &oi->oi_md->lsm_oi, rc); lov_stripe_unlock(oi->oi_md); lov_update_set(set, req, rc); - RETURN(rc); + return rc; } /* The callback for osc_enqueue that updates lov info for every OSC request. */ @@ -275,11 +271,10 @@ static int enqueue_done(struct lov_request_set *set, __u32 mode) struct lov_obd *lov = &set->set_exp->exp_obd->u.lov; int completes = atomic_read(&set->set_completes); int rc = 0; - ENTRY; /* enqueue/match success, just return */ if (completes && completes == atomic_read(&set->set_success)) - RETURN(0); + return 0; /* cancel enqueued/matched locks */ list_for_each_entry(req, &set->set_list, rq_link) { @@ -305,17 +300,16 @@ static int enqueue_done(struct lov_request_set *set, __u32 mode) } if (set->set_lockh) lov_llh_put(set->set_lockh); - RETURN(rc); + return rc; } int lov_fini_enqueue_set(struct lov_request_set *set, __u32 mode, int rc, struct ptlrpc_request_set *rqset) { int ret = 0; - ENTRY; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); /* Do enqueue_done only for sync requests and if any request * succeeded. */ @@ -328,7 +322,7 @@ int lov_fini_enqueue_set(struct lov_request_set *set, __u32 mode, int rc, lov_put_reqset(set); - RETURN(rc ? rc : ret); + return rc ? rc : ret; } static void lov_llh_addref(void *llhp) @@ -369,11 +363,10 @@ int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_obd *lov = &exp->exp_obd->u.lov; struct lov_request_set *set; int i, rc = 0; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -445,19 +438,18 @@ int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(0); + return 0; out_set: lov_fini_enqueue_set(set, einfo->ei_mode, rc, NULL); - RETURN(rc); + return rc; } int lov_fini_match_set(struct lov_request_set *set, __u32 mode, int flags) { int rc = 0; - ENTRY; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); rc = enqueue_done(set, mode); if ((set->set_count == atomic_read(&set->set_success)) && @@ -466,7 +458,7 @@ int lov_fini_match_set(struct lov_request_set *set, __u32 mode, int flags) lov_put_reqset(set); - RETURN(rc); + return rc; } int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo, @@ -477,11 +469,10 @@ int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_obd *lov = &exp->exp_obd->u.lov; struct lov_request_set *set; int i, rc = 0; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -535,19 +526,18 @@ int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_match_set(set, mode, 0); - RETURN(rc); + return rc; } int lov_fini_cancel_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (set->set_lockh) @@ -555,7 +545,7 @@ int lov_fini_cancel_set(struct lov_request_set *set) lov_put_reqset(set); - RETURN(rc); + return rc; } int lov_prep_cancel_set(struct obd_export *exp, struct obd_info *oinfo, @@ -565,11 +555,10 @@ int lov_prep_cancel_set(struct obd_export *exp, struct obd_info *oinfo, { struct lov_request_set *set; int i, rc = 0; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -617,10 +606,10 @@ int lov_prep_cancel_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_cancel_set(set); - RETURN(rc); + return rc; } static int common_attr_done(struct lov_request_set *set) { @@ -628,15 +617,14 @@ static int common_attr_done(struct lov_request_set *set) struct lov_request *req; struct obdo *tmp_oa; int rc = 0, attrset = 0; - ENTRY; LASSERT(set->set_oi != NULL); if (set->set_oi->oi_oa == NULL) - RETURN(0); + return 0; if (!atomic_read(&set->set_success)) - RETURN(-EIO); + return -EIO; OBDO_ALLOC(tmp_oa); if (tmp_oa == NULL) @@ -670,7 +658,7 @@ static int common_attr_done(struct lov_request_set *set) out: if (tmp_oa) OBDO_FREE(tmp_oa); - RETURN(rc); + return rc; } @@ -680,7 +668,6 @@ static int brw_done(struct lov_request_set *set) struct lov_oinfo *loi = NULL; struct list_head *pos; struct lov_request *req; - ENTRY; list_for_each (pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -694,16 +681,15 @@ static int brw_done(struct lov_request_set *set) loi->loi_lvb.lvb_blocks = req->rq_oi.oi_oa->o_blocks; } - RETURN(0); + return 0; } int lov_fini_brw_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) { rc = brw_done(set); @@ -711,7 +697,7 @@ int lov_fini_brw_set(struct lov_request_set *set) } lov_put_reqset(set); - RETURN(rc); + return rc; } int lov_prep_brw_set(struct obd_export *exp, struct obd_info *oinfo, @@ -727,11 +713,10 @@ int lov_prep_brw_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i, shift; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -832,23 +817,22 @@ out: else lov_fini_brw_set(set); - RETURN(rc); + return rc; } int lov_fini_getattr_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) rc = common_attr_done(set); lov_put_reqset(set); - RETURN(rc); + return rc; } /* The callback for osc_getattr_async that finilizes a request info when a @@ -867,11 +851,10 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -913,18 +896,16 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_getattr_set(set); - RETURN(rc); + return rc; } int lov_fini_destroy_set(struct lov_request_set *set) { - ENTRY; - if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) { /* FIXME update qos data here */ @@ -932,7 +913,7 @@ int lov_fini_destroy_set(struct lov_request_set *set) lov_put_reqset(set); - RETURN(0); + return 0; } int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, @@ -943,11 +924,10 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -987,19 +967,18 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_destroy_set(set); - RETURN(rc); + return rc; } int lov_fini_setattr_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) { rc = common_attr_done(set); @@ -1007,7 +986,7 @@ int lov_fini_setattr_set(struct lov_request_set *set) } lov_put_reqset(set); - RETURN(rc); + return rc; } int lov_update_setattr_set(struct lov_request_set *set, @@ -1015,7 +994,6 @@ int lov_update_setattr_set(struct lov_request_set *set, { struct lov_obd *lov = &req->rq_rqset->set_exp->exp_obd->u.lov; struct lov_stripe_md *lsm = req->rq_rqset->set_oi->oi_md; - ENTRY; lov_update_set(set, req, rc); @@ -1036,7 +1014,7 @@ int lov_update_setattr_set(struct lov_request_set *set, req->rq_oi.oi_oa->o_atime; } - RETURN(rc); + return rc; } /* The callback for osc_setattr_async that finilizes a request info when a @@ -1056,11 +1034,10 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -1113,19 +1090,18 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_setattr_set(set); - RETURN(rc); + return rc; } int lov_fini_punch_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) { rc = -EIO; @@ -1136,7 +1112,7 @@ int lov_fini_punch_set(struct lov_request_set *set) lov_put_reqset(set); - RETURN(rc); + return rc; } int lov_update_punch_set(struct lov_request_set *set, @@ -1144,7 +1120,6 @@ int lov_update_punch_set(struct lov_request_set *set, { struct lov_obd *lov = &req->rq_rqset->set_exp->exp_obd->u.lov; struct lov_stripe_md *lsm = req->rq_rqset->set_oi->oi_md; - ENTRY; lov_update_set(set, req, rc); @@ -1162,7 +1137,7 @@ int lov_update_punch_set(struct lov_request_set *set, lov_stripe_unlock(lsm); } - RETURN(rc); + return rc; } /* The callback for osc_punch that finilizes a request info when a response @@ -1182,11 +1157,10 @@ int lov_prep_punch_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_oi = oinfo; @@ -1238,19 +1212,18 @@ int lov_prep_punch_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_punch_set(set); - RETURN(rc); + return rc; } int lov_fini_sync_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) { if (!atomic_read(&set->set_success)) @@ -1260,7 +1233,7 @@ int lov_fini_sync_set(struct lov_request_set *set) lov_put_reqset(set); - RETURN(rc); + return rc; } /* The callback for osc_sync that finilizes a request info when a @@ -1281,11 +1254,10 @@ int lov_prep_sync_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - ENTRY; OBD_ALLOC_PTR(set); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -1330,10 +1302,10 @@ int lov_prep_sync_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_sync_set(set); - RETURN(rc); + return rc; } #define LOV_U64_MAX ((__u64)~0ULL) @@ -1347,8 +1319,6 @@ out_set: int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,int success) { - ENTRY; - if (success) { __u32 expected_stripes = lov_get_stripecnt(&obd->u.lov, LOV_MAGIC, 0); @@ -1361,26 +1331,25 @@ int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,int success) memcpy(&obd->obd_osfs, osfs, sizeof(*osfs)); obd->obd_osfs_age = cfs_time_current_64(); spin_unlock(&obd->obd_osfs_lock); - RETURN(0); + return 0; } - RETURN(-EIO); + return -EIO; } int lov_fini_statfs_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) - RETURN(0); + return 0; if (atomic_read(&set->set_completes)) { rc = lov_fini_statfs(set->set_obd, set->set_oi->oi_osfs, atomic_read(&set->set_success)); } lov_put_reqset(set); - RETURN(rc); + return rc; } void lov_update_statfs(struct obd_statfs *osfs, struct obd_statfs *lov_sfs, @@ -1450,7 +1419,6 @@ static int cb_statfs_update(void *cookie, int rc) struct lov_tgt_desc *tgt; struct obd_device *lovobd, *tgtobd; int success; - ENTRY; lovreq = container_of(oinfo, struct lov_request, rq_oi); set = lovreq->rq_rqset; @@ -1488,7 +1456,7 @@ out: atomic_read(&set->set_success)); } - RETURN(0); + return 0; } int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, @@ -1497,11 +1465,10 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &obd->u.lov; int rc = 0, i; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_obd = obd; @@ -1544,8 +1511,8 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_statfs_set(set); - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 204ecd0b863..998ea1cbc7b 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -55,10 +55,8 @@ static void lovsub_req_completion(const struct lu_env *env, { struct lovsub_req *lsr; - ENTRY; lsr = cl2lovsub_req(slice); OBD_SLAB_FREE_PTR(lsr, lovsub_req_kmem); - EXIT; } /** @@ -73,14 +71,12 @@ static void lovsub_req_attr_set(const struct lu_env *env, { struct lovsub_object *subobj; - ENTRY; subobj = cl2lovsub(obj); /* * There is no OBD_MD_* flag for obdo::o_stripe_idx, so set it * unconditionally. It never changes anyway. */ attr->cra_oa->o_stripe_idx = subobj->lso_index; - EXIT; } static const struct cl_req_operations lovsub_req_ops = { @@ -101,20 +97,19 @@ static int lovsub_device_init(const struct lu_env *env, struct lu_device *d, struct lu_device_type *ldt; int rc; - ENTRY; next->ld_site = d->ld_site; ldt = next->ld_type; LASSERT(ldt != NULL); rc = ldt->ldt_ops->ldto_device_init(env, next, ldt->ldt_name, NULL); if (rc) { next->ld_site = NULL; - RETURN(rc); + return rc; } lu_device_get(next); lu_ref_add(&next->ld_reference, "lu-stack", &lu_site_init); lsd->acid_next = lu2cl_dev(next); - RETURN(rc); + return rc; } static struct lu_device *lovsub_device_fini(const struct lu_env *env, @@ -123,12 +118,11 @@ static struct lu_device *lovsub_device_fini(const struct lu_env *env, struct lu_device *next; struct lovsub_device *lsd; - ENTRY; lsd = lu2lovsub_dev(d); next = cl2lu_dev(lsd->acid_next); lsd->acid_super = NULL; lsd->acid_next = NULL; - RETURN(next); + return next; } static struct lu_device *lovsub_device_free(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/drivers/staging/lustre/lustre/lov/lovsub_lock.c index 03bab17ccc6..80305aa6171 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_lock.c @@ -57,35 +57,29 @@ static void lovsub_lock_fini(const struct lu_env *env, { struct lovsub_lock *lsl; - ENTRY; lsl = cl2lovsub_lock(slice); LASSERT(list_empty(&lsl->lss_parents)); OBD_SLAB_FREE_PTR(lsl, lovsub_lock_kmem); - EXIT; } static void lovsub_parent_lock(const struct lu_env *env, struct lov_lock *lov) { struct cl_lock *parent; - ENTRY; parent = lov->lls_cl.cls_lock; cl_lock_get(parent); lu_ref_add(&parent->cll_reference, "lovsub-parent", current); cl_lock_mutex_get(env, parent); - EXIT; } static void lovsub_parent_unlock(const struct lu_env *env, struct lov_lock *lov) { struct cl_lock *parent; - ENTRY; parent = lov->lls_cl.cls_lock; cl_lock_mutex_put(env, lov->lls_cl.cls_lock); lu_ref_del(&parent->cll_reference, "lovsub-parent", current); cl_lock_put(env, parent); - EXIT; } /** @@ -101,7 +95,6 @@ static void lovsub_lock_state(const struct lu_env *env, struct lov_lock_link *scan; LASSERT(cl_lock_is_mutexed(slice->cls_lock)); - ENTRY; list_for_each_entry(scan, &sub->lss_parents, lll_list) { struct lov_lock *lov = scan->lll_super; @@ -113,7 +106,6 @@ static void lovsub_lock_state(const struct lu_env *env, lovsub_parent_unlock(env, lov); } } - EXIT; } /** @@ -127,8 +119,6 @@ static unsigned long lovsub_lock_weigh(const struct lu_env *env, struct lov_lock *lov; unsigned long dumbbell; - ENTRY; - LASSERT(cl_lock_is_mutexed(slice->cls_lock)); if (!list_empty(&lock->lss_parents)) { @@ -146,7 +136,7 @@ static unsigned long lovsub_lock_weigh(const struct lu_env *env, } else dumbbell = 0; - RETURN(dumbbell); + return dumbbell; } /** @@ -162,7 +152,6 @@ static void lovsub_lock_descr_map(const struct cl_lock_descr *in, pgoff_t start; pgoff_t end; - ENTRY; start = in->cld_start; end = in->cld_end; @@ -184,7 +173,6 @@ static void lovsub_lock_descr_map(const struct cl_lock_descr *in, } out->cld_start = start; out->cld_end = end; - EXIT; } /** @@ -241,8 +229,6 @@ static int lovsub_lock_modify(const struct lu_env *env, struct lov_lock *lov; int result = 0; - ENTRY; - LASSERT(cl_lock_mode_match(d->cld_mode, s->cls_lock->cll_descr.cld_mode)); list_for_each_entry(scan, &lock->lss_parents, lll_list) { @@ -254,7 +240,7 @@ static int lovsub_lock_modify(const struct lu_env *env, lovsub_parent_unlock(env, lov); result = result ?: rc; } - RETURN(result); + return result; } static int lovsub_lock_closure(const struct lu_env *env, @@ -267,7 +253,6 @@ static int lovsub_lock_closure(const struct lu_env *env, int result; LASSERT(cl_lock_is_mutexed(slice->cls_lock)); - ENTRY; sub = cl2lovsub_lock(slice); result = 0; @@ -278,7 +263,7 @@ static int lovsub_lock_closure(const struct lu_env *env, if (result != 0) break; } - RETURN(result); + return result; } /** @@ -290,11 +275,10 @@ static int lovsub_lock_delete_one(const struct lu_env *env, { struct cl_lock *parent; int result; - ENTRY; parent = lov->lls_cl.cls_lock; if (parent->cll_error) - RETURN(0); + return 0; result = 0; switch (parent->cll_state) { @@ -386,7 +370,7 @@ static int lovsub_lock_delete_one(const struct lu_env *env, break; } - RETURN(result); + return result; } /** @@ -403,7 +387,6 @@ static void lovsub_lock_delete(const struct lu_env *env, LASSERT(cl_lock_is_mutexed(child)); - ENTRY; /* * Destruction of a sub-lock might take multiple iterations, because * when the last sub-lock of a given top-lock is deleted, top-lock is @@ -434,7 +417,6 @@ static void lovsub_lock_delete(const struct lu_env *env, } } } while (restart); - EXIT; } static int lovsub_lock_print(const struct lu_env *env, void *cookie, @@ -471,7 +453,6 @@ int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj, struct lovsub_lock *lsk; int result; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lsk, lovsub_lock_kmem, __GFP_IO); if (lsk != NULL) { INIT_LIST_HEAD(&lsk->lss_parents); @@ -479,7 +460,7 @@ int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj, result = 0; } else result = -ENOMEM; - RETURN(result); + return result; } /** @} lov */ diff --git a/drivers/staging/lustre/lustre/lov/lovsub_object.c b/drivers/staging/lustre/lustre/lov/lovsub_object.c index 1b83d9081c4..89760b3bf3f 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_object.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_object.c @@ -61,7 +61,6 @@ int lovsub_object_init(const struct lu_env *env, struct lu_object *obj, int result; - ENTRY; under = &dev->acid_next->cd_lu_dev; below = under->ld_ops->ldo_object_alloc(env, obj->lo_header, under); if (below != NULL) { @@ -70,7 +69,7 @@ int lovsub_object_init(const struct lu_env *env, struct lu_object *obj, result = 0; } else result = -ENOMEM; - RETURN(result); + return result; } @@ -78,7 +77,6 @@ static void lovsub_object_free(const struct lu_env *env, struct lu_object *obj) { struct lovsub_object *los = lu2lovsub(obj); struct lov_object *lov = los->lso_super; - ENTRY; /* We can't assume lov was assigned here, because of the shadow * object handling in lu_object_find. @@ -94,7 +92,6 @@ static void lovsub_object_free(const struct lu_env *env, struct lu_object *obj) lu_object_fini(obj); lu_object_header_fini(&los->lso_header.coh_lu); OBD_SLAB_FREE_PTR(los, lovsub_object_kmem); - EXIT; } static int lovsub_object_print(const struct lu_env *env, void *cookie, @@ -110,9 +107,8 @@ static int lovsub_attr_set(const struct lu_env *env, struct cl_object *obj, { struct lov_object *lov = cl2lovsub(obj)->lso_super; - ENTRY; lov_r0(lov)->lo_attr_valid = 0; - RETURN(0); + return 0; } static int lovsub_object_glimpse(const struct lu_env *env, @@ -121,8 +117,7 @@ static int lovsub_object_glimpse(const struct lu_env *env, { struct lovsub_object *los = cl2lovsub(obj); - ENTRY; - RETURN(cl_object_glimpse(env, &los->lso_super->lo_cl, lvb)); + return cl_object_glimpse(env, &los->lso_super->lo_cl, lvb); } @@ -150,7 +145,6 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env, struct lovsub_object *los; struct lu_object *obj; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(los, lovsub_object_kmem, __GFP_IO); if (los != NULL) { struct cl_object_header *hdr; @@ -164,7 +158,7 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env, obj->lo_ops = &lovsub_lu_obj_ops; } else obj = NULL; - RETURN(obj); + return obj; } /** @} lov */ diff --git a/drivers/staging/lustre/lustre/lov/lovsub_page.c b/drivers/staging/lustre/lustre/lov/lovsub_page.c index bc9e683968d..3f00ce9677b 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_page.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_page.c @@ -63,10 +63,9 @@ int lovsub_page_init(const struct lu_env *env, struct cl_object *obj, struct cl_page *page, struct page *unused) { struct lovsub_page *lsb = cl_object_page_slice(obj, page); - ENTRY; cl_page_slice_add(page, &lsb->lsb_cl, obj, &lovsub_page_ops); - RETURN(0); + return 0; } /** @} lov */ diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 5b2c0d88add..15744e13a3f 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#include <linux/version.h> #include <asm/statfs.h> #include <lprocfs_status.h> #include <obd_class.h> diff --git a/drivers/staging/lustre/lustre/lvfs/fsfilt.c b/drivers/staging/lustre/lustre/lvfs/fsfilt.c index 064445cbdb5..e86df7356cb 100644 --- a/drivers/staging/lustre/lustre/lvfs/fsfilt.c +++ b/drivers/staging/lustre/lustre/lvfs/fsfilt.c @@ -35,7 +35,6 @@ #define DEBUG_SUBSYSTEM S_FILTER #include <linux/fs.h> -#include <linux/jbd.h> #include <linux/module.h> #include <linux/kmod.h> #include <linux/slab.h> @@ -68,7 +67,7 @@ int fsfilt_register_ops(struct fsfilt_operations *fs_ops) CERROR("different operations for type %s\n", fs_ops->fs_type); /* unlock fsfilt_types list */ - RETURN(-EEXIST); + return -EEXIST; } } else { try_module_get(THIS_MODULE); @@ -120,7 +119,7 @@ struct fsfilt_operations *fsfilt_get_ops(const char *type) if (rc) { CERROR("Can't find %s interface\n", name); - RETURN(ERR_PTR(rc < 0 ? rc : -rc)); + return ERR_PTR(rc < 0 ? rc : -rc); /* unlock fsfilt_types list */ } } diff --git a/drivers/staging/lustre/lustre/lvfs/fsfilt_ext3.c b/drivers/staging/lustre/lustre/lvfs/fsfilt_ext3.c index c1e99b37572..ee75994003e 100644 --- a/drivers/staging/lustre/lustre/lvfs/fsfilt_ext3.c +++ b/drivers/staging/lustre/lustre/lvfs/fsfilt_ext3.c @@ -48,7 +48,6 @@ #include <ldiskfs/ldiskfs_config.h> #include <ext4/ext4.h> #include <ext4/ext4_jbd2.h> -#include <linux/version.h> #include <linux/bitops.h> #include <linux/quota.h> diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c index e70d8fe9988..18e1b47a1d6 100644 --- a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c +++ b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c @@ -40,16 +40,12 @@ #define DEBUG_SUBSYSTEM S_FILTER -#include <linux/version.h> #include <linux/fs.h> #include <asm/unistd.h> #include <linux/slab.h> #include <linux/pagemap.h> #include <linux/quotaops.h> -#include <linux/version.h> #include <linux/libcfs/libcfs.h> -#include <lustre_fsfilt.h> -#include <obd.h> #include <linux/module.h> #include <linux/init.h> #include <linux/lustre_compat25.h> @@ -207,7 +203,6 @@ int lustre_rename(struct dentry *dir, struct vfsmount *mnt, { struct dentry *dchild_old, *dchild_new; int err = 0; - ENTRY; ASSERT_KERNEL_CTXT("kernel doing rename outside kernel context\n"); CDEBUG(D_INODE, "renaming file %.*s to %.*s\n", @@ -215,7 +210,7 @@ int lustre_rename(struct dentry *dir, struct vfsmount *mnt, dchild_old = ll_lookup_one_len(oldname, dir, strlen(oldname)); if (IS_ERR(dchild_old)) - RETURN(PTR_ERR(dchild_old)); + return PTR_ERR(dchild_old); if (!dchild_old->d_inode) GOTO(put_old, err = -ENOENT); @@ -230,7 +225,7 @@ int lustre_rename(struct dentry *dir, struct vfsmount *mnt, dput(dchild_new); put_old: dput(dchild_old); - RETURN(err); + return err; } EXPORT_SYMBOL(lustre_rename); @@ -242,7 +237,7 @@ struct l_file *l_dentry_open(struct lvfs_run_ctxt *ctxt, struct l_dentry *de, .dentry = de, .mnt = ctxt->pwdmnt, }; - return ll_dentry_open(&path, flags, current_cred()); + return dentry_open(&path, flags, current_cred()); } EXPORT_SYMBOL(l_dentry_open); @@ -255,7 +250,7 @@ __s64 lprocfs_read_helper(struct lprocfs_counter *lc, __s64 ret = 0; if (lc == NULL || header == NULL) - RETURN(0); + return 0; switch (field) { case LPROCFS_FIELDS_FLAGS_CONFIG: @@ -285,7 +280,7 @@ __s64 lprocfs_read_helper(struct lprocfs_counter *lc, break; }; - RETURN(ret); + return ret; } EXPORT_SYMBOL(lprocfs_read_helper); #endif /* LPROCFS */ diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 6592478e9b6..e0b8f186625 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#include <linux/version.h> #include <linux/vfs.h> #include <obd_class.h> #include <lprocfs_status.h> @@ -93,14 +92,13 @@ static ssize_t mdc_kuc_write(struct file *file, const char *buffer, struct hsm_action_item *hai; int len; int fd, rc; - ENTRY; rc = lprocfs_write_helper(buffer, count, &fd); if (rc) - RETURN(rc); + return rc; if (fd < 0) - RETURN(-ERANGE); + return -ERANGE; CWARN("message to fd %d\n", fd); len = sizeof(*lh) + sizeof(*hal) + MTI_NAME_MAXLEN + @@ -141,8 +139,8 @@ static ssize_t mdc_kuc_write(struct file *file, const char *buffer, } OBD_FREE(lh, len); if (rc < 0) - RETURN(rc); - RETURN(count); + return rc; + return count; } struct file_operations mdc_kuc_fops = { diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index e789aed98de..b2de4780367 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -45,10 +45,10 @@ static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid) LASSERT (b != NULL); b->suppgid = suppgid; - b->uid = current_uid(); - b->gid = current_gid(); - b->fsuid = current_fsuid(); - b->fsgid = current_fsgid(); + b->uid = from_kuid(&init_user_ns, current_uid()); + b->gid = from_kgid(&init_user_ns, current_gid()); + b->fsuid = from_kuid(&init_user_ns, current_fsuid()); + b->fsgid = from_kgid(&init_user_ns, current_fsgid()); b->capability = cfs_curproc_cap_pack(); } @@ -219,8 +219,8 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data, /* XXX do something about time, uid, gid */ rec->cr_opcode = REINT_OPEN; - rec->cr_fsuid = current_fsuid(); - rec->cr_fsgid = current_fsgid(); + rec->cr_fsuid = from_kuid(&init_user_ns, current_fsuid()); + rec->cr_fsgid = from_kgid(&init_user_ns, current_fsgid()); rec->cr_cap = cfs_curproc_cap_pack(); if (op_data != NULL) { rec->cr_fid1 = op_data->op_fid1; @@ -299,16 +299,16 @@ static void mdc_setattr_pack_rec(struct mdt_rec_setattr *rec, struct md_op_data *op_data) { rec->sa_opcode = REINT_SETATTR; - rec->sa_fsuid = current_fsuid(); - rec->sa_fsgid = current_fsgid(); + rec->sa_fsuid = from_kuid(&init_user_ns, current_fsuid()); + rec->sa_fsgid = from_kgid(&init_user_ns, current_fsgid()); rec->sa_cap = cfs_curproc_cap_pack(); rec->sa_suppgid = -1; rec->sa_fid = op_data->op_fid1; rec->sa_valid = attr_pack(op_data->op_attr.ia_valid); rec->sa_mode = op_data->op_attr.ia_mode; - rec->sa_uid = op_data->op_attr.ia_uid; - rec->sa_gid = op_data->op_attr.ia_gid; + rec->sa_uid = from_kuid(&init_user_ns, op_data->op_attr.ia_uid); + rec->sa_gid = from_kgid(&init_user_ns, op_data->op_attr.ia_gid); rec->sa_size = op_data->op_attr.ia_size; rec->sa_blocks = op_data->op_attr_blocks; rec->sa_atime = LTIME_S(op_data->op_attr.ia_atime); @@ -316,8 +316,9 @@ static void mdc_setattr_pack_rec(struct mdt_rec_setattr *rec, rec->sa_ctime = LTIME_S(op_data->op_attr.ia_ctime); rec->sa_attr_flags = ((struct ll_iattr *)&op_data->op_attr)->ia_attr_flags; if ((op_data->op_attr.ia_valid & ATTR_GID) && - current_is_in_group(op_data->op_attr.ia_gid)) - rec->sa_suppgid = op_data->op_attr.ia_gid; + in_group_p(op_data->op_attr.ia_gid)) + rec->sa_suppgid = + from_kgid(&init_user_ns, op_data->op_attr.ia_gid); else rec->sa_suppgid = op_data->op_suppgids[0]; @@ -504,11 +505,11 @@ void mdc_close_pack(struct ptlrpc_request *req, struct md_op_data *op_data) static int mdc_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw) { int rc; - ENTRY; + client_obd_list_lock(&cli->cl_loi_list_lock); rc = list_empty(&mcw->mcw_entry); client_obd_list_unlock(&cli->cl_loi_list_lock); - RETURN(rc); + return rc; }; /* We record requests in flight in cli->cl_r_in_flight here. diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 1cc90b635fb..fb5a9959bf7 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -115,13 +115,12 @@ int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, { struct ldlm_lock *lock; struct inode *new_inode = data; - ENTRY; if(bits) *bits = 0; if (!*lockh) - RETURN(0); + return 0; lock = ldlm_handle2lock((struct lustre_handle *)lockh); @@ -144,7 +143,7 @@ int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, unlock_res_and_lock(lock); LDLM_LOCK_PUT(lock); - RETURN(0); + return 0; } ldlm_mode_t mdc_lock_match(struct obd_export *exp, __u64 flags, @@ -154,12 +153,11 @@ ldlm_mode_t mdc_lock_match(struct obd_export *exp, __u64 flags, { struct ldlm_res_id res_id; ldlm_mode_t rc; - ENTRY; fid_build_reg_res_name(fid, &res_id); rc = ldlm_lock_match(class_exp2obd(exp)->obd_namespace, flags, &res_id, type, policy, mode, lockh, 0); - RETURN(rc); + return rc; } int mdc_cancel_unused(struct obd_export *exp, @@ -173,12 +171,10 @@ int mdc_cancel_unused(struct obd_export *exp, struct obd_device *obd = class_exp2obd(exp); int rc; - ENTRY; - fid_build_reg_res_name(fid, &res_id); rc = ldlm_cli_cancel_unused_resource(obd->obd_namespace, &res_id, policy, mode, flags, opaque); - RETURN(rc); + return rc; } int mdc_null_inode(struct obd_export *exp, @@ -187,7 +183,6 @@ int mdc_null_inode(struct obd_export *exp, struct ldlm_res_id res_id; struct ldlm_resource *res; struct ldlm_namespace *ns = class_exp2obd(exp)->obd_namespace; - ENTRY; LASSERTF(ns != NULL, "no namespace passed\n"); @@ -195,14 +190,14 @@ int mdc_null_inode(struct obd_export *exp, res = ldlm_resource_get(ns, NULL, &res_id, 0, 0); if(res == NULL) - RETURN(0); + return 0; lock_res(res); res->lr_lvb_inode = NULL; unlock_res(res); ldlm_resource_putref(res); - RETURN(0); + return 0; } /* find any ldlm lock of the inode in mdc @@ -215,16 +210,15 @@ int mdc_find_cbdata(struct obd_export *exp, { struct ldlm_res_id res_id; int rc = 0; - ENTRY; fid_build_reg_res_name((struct lu_fid*)fid, &res_id); rc = ldlm_resource_iterate(class_exp2obd(exp)->obd_namespace, &res_id, it, data); if (rc == LDLM_ITER_STOP) - RETURN(1); + return 1; else if (rc == LDLM_ITER_CONTINUE) - RETURN(0); - RETURN(rc); + return 0; + return rc; } static inline void mdc_clear_replay_flag(struct ptlrpc_request *req, int rc) @@ -281,7 +275,6 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp, int count = 0; int mode; int rc; - ENTRY; it->it_create_mode = (it->it_create_mode & ~S_IFMT) | S_IFREG; @@ -314,7 +307,7 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp, &RQF_LDLM_INTENT_OPEN); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); } /* parent capability */ @@ -362,12 +355,11 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp, struct obd_device *obddev = class_exp2obd(exp); struct ldlm_intent *lit; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_UNLINK); if (req == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -376,7 +368,7 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp, rc = ldlm_prep_enqueue_req(exp, req, NULL, 0); if (rc) { ptlrpc_request_free(req); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } /* pack the intent */ @@ -391,7 +383,7 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp, req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, obddev->u.cli.cl_max_mds_cookiesize); ptlrpc_request_set_replen(req); - RETURN(req); + return req; } static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, @@ -407,12 +399,11 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, OBD_MD_FLRMTPERM : OBD_MD_FLACL); struct ldlm_intent *lit; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_GETATTR); if (req == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -421,7 +412,7 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, rc = ldlm_prep_enqueue_req(exp, req, NULL, 0); if (rc) { ptlrpc_request_free(req); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } /* pack the intent */ @@ -438,7 +429,7 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, sizeof(struct mdt_remote_perm)); ptlrpc_request_set_replen(req); - RETURN(req); + return req; } static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp, @@ -450,18 +441,17 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp, struct ldlm_intent *lit; struct layout_intent *layout; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_LAYOUT); if (req == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT, 0); rc = ldlm_prep_enqueue_req(exp, req, NULL, 0); if (rc) { ptlrpc_request_free(req); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } /* pack the intent */ @@ -477,7 +467,7 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp, req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, obd->u.cli.cl_max_mds_easize); ptlrpc_request_set_replen(req); - RETURN(req); + return req; } static struct ptlrpc_request * @@ -485,21 +475,20 @@ mdc_enqueue_pack(struct obd_export *exp, int lvb_len) { struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE); if (req == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); rc = ldlm_prep_enqueue_req(exp, req, NULL, 0); if (rc) { ptlrpc_request_free(req); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, lvb_len); ptlrpc_request_set_replen(req); - RETURN(req); + return req; } static int mdc_finish_enqueue(struct obd_export *exp, @@ -516,7 +505,6 @@ static int mdc_finish_enqueue(struct obd_export *exp, struct ldlm_lock *lock; void *lvb_data = NULL; int lvb_len = 0; - ENTRY; LASSERT(rc >= 0); /* Similarly, if we're going to replay this request, we don't want to @@ -579,7 +567,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, body = req_capsule_server_get(pill, &RMF_MDT_BODY); if (body == NULL) { CERROR ("Can't swab mdt_body\n"); - RETURN (-EPROTO); + return -EPROTO; } if (it_disposition(it, DISP_OPEN_OPEN) && @@ -605,7 +593,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, eadata = req_capsule_server_sized_get(pill, &RMF_MDT_MD, body->eadatasize); if (eadata == NULL) - RETURN(-EPROTO); + return -EPROTO; /* save lvb data and length in case this is for layout * lock */ @@ -649,14 +637,14 @@ static int mdc_finish_enqueue(struct obd_export *exp, perm = req_capsule_server_swab_get(pill, &RMF_ACL, lustre_swab_mdt_remote_perm); if (perm == NULL) - RETURN(-EPROTO); + return -EPROTO; } if (body->valid & OBD_MD_FLMDSCAPA) { struct lustre_capa *capa, *p; capa = req_capsule_server_get(pill, &RMF_CAPA1); if (capa == NULL) - RETURN(-EPROTO); + return -EPROTO; if (it->it_op & IT_OPEN) { /* client fid capa will be checked in replay */ @@ -670,7 +658,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, capa = req_capsule_server_get(pill, &RMF_CAPA2); if (capa == NULL) - RETURN(-EPROTO); + return -EPROTO; } } else if (it->it_op & IT_LAYOUT) { /* maybe the lock was granted right away and layout @@ -680,7 +668,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, lvb_data = req_capsule_server_sized_get(pill, &RMF_DLM_LVB, lvb_len); if (lvb_data == NULL) - RETURN(-EPROTO); + return -EPROTO; } } @@ -695,7 +683,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, OBD_ALLOC_LARGE(lmm, lvb_len); if (lmm == NULL) { LDLM_LOCK_PUT(lock); - RETURN(-ENOMEM); + return -ENOMEM; } memcpy(lmm, lvb_data, lvb_len); @@ -713,7 +701,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, if (lock != NULL) LDLM_LOCK_PUT(lock); - RETURN(rc); + return rc; } /* We always reserve enough space in the reply packet for a stripe MD, because @@ -738,7 +726,6 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, int generation, resends = 0; struct ldlm_reply *lockrep; enum lvb_type lvb_type = 0; - ENTRY; LASSERTF(!it || einfo->ei_type == LDLM_IBITS, "lock type %d\n", einfo->ei_type); @@ -780,17 +767,17 @@ resend: req = mdc_enqueue_pack(exp, 0); } else if (it->it_op & IT_LAYOUT) { if (!imp_connect_lvb_type(class_exp2cliimp(exp))) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; req = mdc_intent_layout_pack(exp, it, op_data); lvb_type = LVB_T_LAYOUT; } else { LBUG(); - RETURN(-EINVAL); + return -EINVAL; } if (IS_ERR(req)) - RETURN(PTR_ERR(req)); + return PTR_ERR(req); if (req != NULL && it && it->it_op & IT_CREAT) /* ask ptlrpc not to resend on EINPROGRESS since we have our own @@ -813,7 +800,7 @@ resend: mdc_put_rpc_lock(obddev->u.cli.cl_rpc_lock, it); mdc_clear_replay_flag(req, 0); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } } @@ -823,8 +810,14 @@ resend: /* For flock requests we immediatelly return without further delay and let caller deal with the rest, since rest of this function metadata processing makes no sense for flock - requests anyway */ - RETURN(rc); + requests anyway. But in case of problem during comms with + Server (ETIMEDOUT) or any signal/kill attempt (EINTR), we + can not rely on caller and this mainly for F_UNLCKs + (explicits or automatically generated by Kernel to clean + current FLocks upon exit) that can't be trashed */ + if ((rc == -EINTR) || (rc == -ETIMEDOUT)) + goto resend; + return rc; } mdc_exit_request(&obddev->u.cli); @@ -834,12 +827,15 @@ resend: CERROR("ldlm_cli_enqueue: %d\n", rc); mdc_clear_replay_flag(req, rc); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } lockrep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); LASSERT(lockrep != NULL); + lockrep->lock_policy_res2 = + ptlrpc_status_ntoh(lockrep->lock_policy_res2); + /* Retry the create infinitely when we get -EINPROGRESS from * server. This is required by the new quota design. */ if (it && it->it_op & IT_CREAT && @@ -856,7 +852,7 @@ resend: goto resend; } else { CDEBUG(D_HA, "resend cross eviction\n"); - RETURN(-EIO); + return -EIO; } } @@ -868,7 +864,7 @@ resend: } ptlrpc_req_finished(req); } - RETURN(rc); + return rc; } static int mdc_finish_intent_lock(struct obd_export *exp, @@ -882,7 +878,6 @@ static int mdc_finish_intent_lock(struct obd_export *exp, struct ldlm_lock *lock; int rc; - LASSERT(request != NULL); LASSERT(request != LP_POISON); LASSERT(request->rq_repmsg != LP_POISON); @@ -891,11 +886,11 @@ static int mdc_finish_intent_lock(struct obd_export *exp, /* The server failed before it even started executing the * intent, i.e. because it couldn't unpack the request. */ LASSERT(it->d.lustre.it_status != 0); - RETURN(it->d.lustre.it_status); + return it->d.lustre.it_status; } rc = it_open_error(DISP_IT_EXECD, it); if (rc) - RETURN(rc); + return rc; mdt_body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); LASSERT(mdt_body != NULL); /* mdc_enqueue checked */ @@ -917,13 +912,13 @@ static int mdc_finish_intent_lock(struct obd_export *exp, CDEBUG(D_DENTRY, "Found stale data "DFID"("DFID")/"DFID "\n", PFID(&op_data->op_fid2), PFID(&op_data->op_fid2), PFID(&mdt_body->fid1)); - RETURN(-ESTALE); + return -ESTALE; } } rc = it_open_error(DISP_LOOKUP_EXECD, it); if (rc) - RETURN(rc); + return rc; /* keep requests around for the multiple phases of the call * this shows the DISP_XX must guarantee we make it into the call @@ -984,7 +979,7 @@ static int mdc_finish_intent_lock(struct obd_export *exp, CDEBUG(D_DENTRY,"D_IT dentry %.*s intent: %s status %d disp %x rc %d\n", op_data->op_namelen, op_data->op_name, ldlm_it2str(it->it_op), it->d.lustre.it_status, it->d.lustre.it_disposition, rc); - RETURN(rc); + return rc; } int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, @@ -997,7 +992,6 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, struct lustre_handle lockh; ldlm_policy_data_t policy; ldlm_mode_t mode; - ENTRY; if (it->d.lustre.it_lock_handle) { lockh.cookie = it->d.lustre.it_lock_handle; @@ -1029,7 +1023,7 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, it->d.lustre.it_lock_mode = 0; } - RETURN(!!mode); + return !!mode; } /* @@ -1067,7 +1061,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, { struct lustre_handle lockh; int rc = 0; - ENTRY; + LASSERT(it); CDEBUG(D_DLMTRACE, "(name: %.*s,"DFID") in obj "DFID @@ -1087,7 +1081,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, /* Only return failure if it was not GETATTR by cfid (from inode_revalidate) */ if (rc || op_data->op_namelen != 0) - RETURN(rc); + return rc; } /* lookup_it may be called only after revalidate_it has run, because @@ -1099,22 +1093,25 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, * this and use the request from revalidate. In this case, revalidate * never dropped its reference, so the refcounts are all OK */ if (!it_disposition(it, DISP_ENQ_COMPLETE)) { - struct ldlm_enqueue_info einfo = - { LDLM_IBITS, it_to_lock_mode(it), cb_blocking, - ldlm_completion_ast, NULL, NULL, NULL }; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_IBITS, + .ei_mode = it_to_lock_mode(it), + .ei_cb_bl = cb_blocking, + .ei_cb_cp = ldlm_completion_ast, + }; /* For case if upper layer did not alloc fid, do it now. */ if (!fid_is_sane(&op_data->op_fid2) && it->it_op & IT_CREAT) { rc = mdc_fid_alloc(exp, &op_data->op_fid2, op_data); if (rc < 0) { CERROR("Can't alloc new fid, rc %d\n", rc); - RETURN(rc); + return rc; } } rc = mdc_enqueue(exp, &einfo, it, op_data, &lockh, lmm, lmmsize, NULL, extra_lock_flags); if (rc < 0) - RETURN(rc); + return rc; } else if (!fid_is_sane(&op_data->op_fid2) || !(it->it_create_mode & M_CHECK_STALE)) { /* DISP_ENQ_COMPLETE set means there is extra reference on @@ -1125,7 +1122,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, } *reqp = it->d.lustre.it_data; rc = mdc_finish_intent_lock(exp, *reqp, op_data, it, &lockh); - RETURN(rc); + return rc; } static int mdc_intent_getattr_async_interpret(const struct lu_env *env, @@ -1139,8 +1136,8 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env, struct lookup_intent *it; struct lustre_handle *lockh; struct obd_device *obddev; + struct ldlm_reply *lockrep; __u64 flags = LDLM_FL_HAS_INTENT; - ENTRY; it = &minfo->mi_it; lockh = &minfo->mi_lockh; @@ -1159,12 +1156,17 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env, GOTO(out, rc); } + lockrep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); + LASSERT(lockrep != NULL); + + lockrep->lock_policy_res2 = + ptlrpc_status_ntoh(lockrep->lock_policy_res2); + rc = mdc_finish_enqueue(exp, req, einfo, it, lockh, rc); if (rc) GOTO(out, rc); rc = mdc_finish_intent_lock(exp, req, &minfo->mi_data, it, lockh); - EXIT; out: OBD_FREE_PTR(einfo); @@ -1191,7 +1193,6 @@ int mdc_intent_getattr_async(struct obd_export *exp, }; int rc = 0; __u64 flags = LDLM_FL_HAS_INTENT; - ENTRY; CDEBUG(D_DLMTRACE,"name: %.*s in inode "DFID", intent: %s flags %#o\n", op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1), @@ -1200,12 +1201,12 @@ int mdc_intent_getattr_async(struct obd_export *exp, fid_build_reg_res_name(&op_data->op_fid1, &res_id); req = mdc_intent_getattr_pack(exp, it, op_data); if (!req) - RETURN(-ENOMEM); + return -ENOMEM; rc = mdc_enter_request(&obddev->u.cli); if (rc != 0) { ptlrpc_req_finished(req); - RETURN(rc); + return rc; } rc = ldlm_cli_enqueue(exp, &req, einfo, &res_id, &policy, &flags, NULL, @@ -1213,7 +1214,7 @@ int mdc_intent_getattr_async(struct obd_export *exp, if (rc < 0) { mdc_exit_request(&obddev->u.cli); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } CLASSERT(sizeof(*ga) <= sizeof(req->rq_async_args)); @@ -1225,5 +1226,5 @@ int mdc_intent_getattr_async(struct obd_export *exp, req->rq_interpret_reply = mdc_intent_getattr_async_interpret; ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1); - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index 5e25a07c52b..9f3a345f34e 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -75,7 +75,6 @@ int mdc_resource_get_unused(struct obd_export *exp, struct lu_fid *fid, struct ldlm_res_id res_id; struct ldlm_resource *res; int count; - ENTRY; /* Return, i.e. cancel nothing, only if ELC is supported (flag in * export) but disabled through procfs (flag in NS). @@ -84,13 +83,13 @@ int mdc_resource_get_unused(struct obd_export *exp, struct lu_fid *fid, * when we still want to cancel locks in advance and just cancel them * locally, without sending any RPC. */ if (exp_connect_cancelset(exp) && !ns_connect_cancelset(ns)) - RETURN(0); + return 0; fid_build_reg_res_name(fid, &res_id); res = ldlm_resource_get(exp->exp_obd->obd_namespace, NULL, &res_id, 0, 0); if (res == NULL) - RETURN(0); + return 0; LDLM_RESOURCE_ADDREF(res); /* Initialize ibits lock policy. */ policy.l_inodebits.bits = bits; @@ -98,7 +97,7 @@ int mdc_resource_get_unused(struct obd_export *exp, struct lu_fid *fid, mode, 0, 0, NULL); LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); - RETURN(count); + return count; } int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, @@ -111,7 +110,6 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = exp->exp_obd; int count = 0, rc; __u64 bits; - ENTRY; LASSERT(op_data != NULL); @@ -127,7 +125,7 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, &RQF_MDS_REINT_SETATTR); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); if ((op_data->op_flags & (MF_SOM_CHANGE | MF_EPOCH_OPEN)) == 0) @@ -140,7 +138,7 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } rpc_lock = obd->u.cli.cl_rpc_lock; @@ -203,7 +201,7 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, obd_mod_put(*mod); req->rq_commit_cb(req); } - RETURN(rc); + return rc; } int mdc_create(struct obd_export *exp, struct md_op_data *op_data, @@ -217,7 +215,6 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, struct obd_import *import = exp->exp_obd->u.cli.cl_import; int generation = import->imp_generation; LIST_HEAD(cancels); - ENTRY; /* For case if upper layer did not alloc fid, do it now. */ if (!fid_is_sane(&op_data->op_fid2)) { @@ -228,7 +225,7 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_fid_alloc(exp, &op_data->op_fid2, op_data); if (rc < 0) { CERROR("Can't alloc new fid, rc %d\n", rc); - RETURN(rc); + return rc; } } @@ -244,7 +241,7 @@ rebuild: &RQF_MDS_REINT_CREATE_RMT_ACL); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -255,7 +252,7 @@ rebuild: rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } /* @@ -298,7 +295,7 @@ rebuild: goto rebuild; } else { CDEBUG(D_HA, "resend cross eviction\n"); - RETURN(-EIO); + return -EIO; } } else if (rc == 0) { struct mdt_body *body; @@ -315,7 +312,7 @@ rebuild: } *request = req; - RETURN(rc); + return rc; } int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, @@ -325,7 +322,6 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req = *request; int count = 0, rc; - ENTRY; LASSERT(req == NULL); @@ -345,7 +341,7 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, &RQF_MDS_REINT_UNLINK); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -354,7 +350,7 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_unlink_pack(req, op_data); @@ -370,7 +366,7 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_reint(req, obd->u.cli.cl_rpc_lock, LUSTRE_IMP_FULL); if (rc == -ERESTARTSYS) rc = 0; - RETURN(rc); + return rc; } int mdc_link(struct obd_export *exp, struct md_op_data *op_data, @@ -380,7 +376,6 @@ int mdc_link(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = exp->exp_obd; struct ptlrpc_request *req; int count = 0, rc; - ENTRY; if ((op_data->op_flags & MF_MDC_CANCEL_FID2) && (fid_is_sane(&op_data->op_fid2))) @@ -396,7 +391,7 @@ int mdc_link(struct obd_export *exp, struct md_op_data *op_data, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_REINT_LINK); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); mdc_set_capa_size(req, &RMF_CAPA2, op_data->op_capa2); @@ -406,7 +401,7 @@ int mdc_link(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_link_pack(req, op_data); @@ -417,7 +412,7 @@ int mdc_link(struct obd_export *exp, struct md_op_data *op_data, if (rc == -ERESTARTSYS) rc = 0; - RETURN(rc); + return rc; } int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, @@ -428,7 +423,6 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = exp->exp_obd; struct ptlrpc_request *req; int count = 0, rc; - ENTRY; if ((op_data->op_flags & MF_MDC_CANCEL_FID1) && (fid_is_sane(&op_data->op_fid1))) @@ -455,7 +449,7 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, &RQF_MDS_REINT_RENAME); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); @@ -466,7 +460,7 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } if (exp_connect_cancelset(exp) && req) @@ -485,5 +479,5 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, if (rc == -ERESTARTSYS) rc = 0; - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 3cf9d8d3f2e..ed3a7a05557 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -65,21 +65,20 @@ int mdc_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req, { struct lustre_capa *capa; struct obd_capa *c; - ENTRY; /* swabbed already in mdc_enqueue */ capa = req_capsule_server_get(&req->rq_pill, field); if (capa == NULL) - RETURN(-EPROTO); + return -EPROTO; c = alloc_capa(CAPA_SITE_CLIENT); if (IS_ERR(c)) { CDEBUG(D_INFO, "alloc capa failed!\n"); - RETURN(PTR_ERR(c)); + return PTR_ERR(c); } else { c->c_capa = *capa; *oc = c; - RETURN(0); + return 0; } } @@ -109,12 +108,11 @@ static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid, struct ptlrpc_request *req; struct mdt_body *body; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_GETSTATUS, LUSTRE_MDS_VERSION, MDS_GETSTATUS); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_pack_body(req, NULL, NULL, 0, 0, -1, 0); lustre_msg_add_flags(req->rq_reqmsg, msg_flags); @@ -141,7 +139,6 @@ static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid, "root fid="DFID", last_committed="LPU64"\n", PFID(rootfid), lustre_msg_get_last_committed(req->rq_repmsg)); - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -172,17 +169,16 @@ static int mdc_getattr_common(struct obd_export *exp, struct mdt_body *body; void *eadata; int rc; - ENTRY; /* Request message already built. */ rc = ptlrpc_queue_wait(req); if (rc != 0) - RETURN(rc); + return rc; /* sanity check for the reply */ body = req_capsule_server_get(pill, &RMF_MDT_BODY); if (body == NULL) - RETURN(-EPROTO); + return -EPROTO; CDEBUG(D_NET, "mode: %o\n", body->mode); @@ -192,7 +188,7 @@ static int mdc_getattr_common(struct obd_export *exp, eadata = req_capsule_server_sized_get(pill, &RMF_MDT_MD, body->eadatasize); if (eadata == NULL) - RETURN(-EPROTO); + return -EPROTO; } if (body->valid & OBD_MD_FLRMTPERM) { @@ -202,17 +198,17 @@ static int mdc_getattr_common(struct obd_export *exp, perm = req_capsule_server_swab_get(pill, &RMF_ACL, lustre_swab_mdt_remote_perm); if (perm == NULL) - RETURN(-EPROTO); + return -EPROTO; } if (body->valid & OBD_MD_FLMDSCAPA) { struct lustre_capa *capa; capa = req_capsule_server_get(pill, &RMF_CAPA1); if (capa == NULL) - RETURN(-EPROTO); + return -EPROTO; } - RETURN(0); + return 0; } int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data, @@ -220,24 +216,23 @@ int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data, { struct ptlrpc_request *req; int rc; - ENTRY; /* Single MDS without an LMV case */ if (op_data->op_flags & MF_GET_MDT_IDX) { op_data->op_mds = 0; - RETURN(0); + return 0; } *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1, @@ -257,7 +252,7 @@ int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data, ptlrpc_req_finished(req); else *request = req; - RETURN(rc); + return rc; } int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data, @@ -265,13 +260,12 @@ int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data, { struct ptlrpc_request *req; int rc; - ENTRY; *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR_NAME); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -280,7 +274,7 @@ int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data, rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR_NAME); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1, @@ -303,7 +297,7 @@ int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data, ptlrpc_req_finished(req); else *request = req; - RETURN(rc); + return rc; } static int mdc_is_subdir(struct obd_export *exp, @@ -314,14 +308,12 @@ static int mdc_is_subdir(struct obd_export *exp, struct ptlrpc_request *req; int rc; - ENTRY; - *request = NULL; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_IS_SUBDIR, LUSTRE_MDS_VERSION, MDS_IS_SUBDIR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_is_subdir_pack(req, pfid, cfid, 0); ptlrpc_request_set_replen(req); @@ -331,7 +323,7 @@ static int mdc_is_subdir(struct obd_export *exp, ptlrpc_req_finished(req); else *request = req; - RETURN(rc); + return rc; } static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, @@ -345,12 +337,11 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, int xattr_namelen = 0; char *tmp; int rc; - ENTRY; *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), fmt); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, oc); if (xattr_name) { @@ -367,7 +358,7 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, opcode); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } if (opcode == MDS_REINT) { @@ -377,12 +368,8 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); rec->sx_opcode = REINT_SETXATTR; - /* TODO: - * cfs_curproc_fs{u,g}id() should replace - * current->fs{u,g}id for portability. - */ - rec->sx_fsuid = current_fsuid(); - rec->sx_fsgid = current_fsgid(); + rec->sx_fsuid = from_kuid(&init_user_ns, current_fsuid()); + rec->sx_fsgid = from_kgid(&init_user_ns, current_fsgid()); rec->sx_cap = cfs_curproc_cap_pack(); rec->sx_suppgid1 = suppgid; rec->sx_suppgid2 = -1; @@ -424,7 +411,7 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, ptlrpc_req_finished(req); else *request = req; - RETURN(rc); + return rc; } int mdc_setxattr(struct obd_export *exp, const struct lu_fid *fid, @@ -457,32 +444,31 @@ static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md) struct posix_acl *acl; void *buf; int rc; - ENTRY; if (!body->aclsize) - RETURN(0); + return 0; buf = req_capsule_server_sized_get(pill, &RMF_ACL, body->aclsize); if (!buf) - RETURN(-EPROTO); + return -EPROTO; acl = posix_acl_from_xattr(&init_user_ns, buf, body->aclsize); if (IS_ERR(acl)) { rc = PTR_ERR(acl); CERROR("convert xattr to acl: %d\n", rc); - RETURN(rc); + return rc; } rc = posix_acl_valid(acl); if (rc) { CERROR("validate acl: %d\n", rc); posix_acl_release(acl); - RETURN(rc); + return rc; } md->posix_acl = acl; - RETURN(0); + return 0; } #else #define mdc_unpack_acl(req, md) 0 @@ -494,7 +480,6 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, { struct req_capsule *pill = &req->rq_pill; int rc; - ENTRY; LASSERT(md); memset(md, 0, sizeof(*md)); @@ -546,7 +531,7 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, if (md->body->eadatasize == 0) { CDEBUG(D_INFO, "OBD_MD_FLDIREA is set, " "but eadatasize 0\n"); - RETURN(-EPROTO); + return -EPROTO; } if (md->body->valid & OBD_MD_MEA) { lmvsize = md->body->eadatasize; @@ -611,7 +596,6 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, md->oss_capa = oc; } - EXIT; out: if (rc) { if (md->oss_capa) { @@ -633,8 +617,7 @@ out: int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { - ENTRY; - RETURN(0); + return 0; } /** @@ -648,12 +631,10 @@ void mdc_replay_open(struct ptlrpc_request *req) struct obd_client_handle *och; struct lustre_handle old; struct mdt_body *body; - ENTRY; if (mod == NULL) { DEBUG_REQ(D_ERROR, req, "Can't properly replay without open data."); - EXIT; return; } @@ -687,7 +668,6 @@ void mdc_replay_open(struct ptlrpc_request *req) DEBUG_REQ(D_HA, close_req, "updating close body with new fh"); epoch->handle = body->handle; } - EXIT; } void mdc_commit_open(struct ptlrpc_request *req) @@ -726,10 +706,9 @@ int mdc_set_open_replay_data(struct obd_export *exp, struct mdt_rec_create *rec; struct mdt_body *body; struct obd_import *imp = open_req->rq_import; - ENTRY; if (!open_req->rq_replay) - RETURN(0); + return 0; rec = req_capsule_client_get(&open_req->rq_pill, &RMF_REC_REINT); body = req_capsule_server_get(&open_req->rq_pill, &RMF_MDT_BODY); @@ -744,7 +723,7 @@ int mdc_set_open_replay_data(struct obd_export *exp, if (mod == NULL) { DEBUG_REQ(D_ERROR, open_req, "Can't allocate md_open_data"); - RETURN(0); + return 0; } /** @@ -776,21 +755,20 @@ int mdc_set_open_replay_data(struct obd_export *exp, } DEBUG_REQ(D_RPCTRACE, open_req, "Set up open replay data"); - RETURN(0); + return 0; } int mdc_clear_open_replay_data(struct obd_export *exp, struct obd_client_handle *och) { struct md_open_data *mod = och->och_mod; - ENTRY; /** * It is possible to not have \var mod in a case of eviction between * lookup and ll_file_open(). **/ if (mod == NULL) - RETURN(0); + return 0; LASSERT(mod != LP_POISON); @@ -798,7 +776,7 @@ int mdc_clear_open_replay_data(struct obd_export *exp, och->och_mod = NULL; obd_mod_put(mod); - RETURN(0); + return 0; } /* Prepares the request for the replay by the given reply */ @@ -823,19 +801,18 @@ int mdc_close(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req; int rc; - ENTRY; *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_CLOSE); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_CLOSE); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } /* To avoid a livelock (bug 7034), we need to send CLOSE RPCs to a @@ -916,7 +893,7 @@ int mdc_close(struct obd_export *exp, struct md_op_data *op_data, } *request = req; mdc_close_handle_reply(req, op_data, rc); - RETURN(rc); + return rc; } int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, @@ -925,18 +902,17 @@ int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_DONE_WRITING); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_DONE_WRITING); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } if (mod != NULL) { @@ -983,7 +959,7 @@ int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, mdc_close_handle_reply(req, op_data, rc); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } @@ -997,7 +973,6 @@ int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data, int resends = 0; struct l_wait_info lwi; int rc; - ENTRY; *request = NULL; init_waitqueue_head(&waitq); @@ -1005,14 +980,14 @@ int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data, restart_bulk: req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_READPAGE); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_READPAGE); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req->rq_request_portal = MDS_READPAGE_PORTAL; @@ -1022,7 +997,7 @@ restart_bulk: MDS_BULK_PORTAL); if (desc == NULL) { ptlrpc_request_free(req); - RETURN(-ENOMEM); + return -ENOMEM; } /* NB req now owns desc and will free it when it gets freed */ @@ -1038,12 +1013,12 @@ restart_bulk: if (rc) { ptlrpc_req_finished(req); if (rc != -ETIMEDOUT) - RETURN(rc); + return rc; resends++; if (!client_should_resend(resends, &exp->exp_obd->u.cli)) { CERROR("too many resend retries, returning error\n"); - RETURN(-EIO); + return -EIO; } lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(resends), NULL, NULL, NULL); l_wait_event(waitq, 0, &lwi); @@ -1055,7 +1030,7 @@ restart_bulk: req->rq_bulk->bd_nob_transferred); if (rc < 0) { ptlrpc_req_finished(req); - RETURN(rc); + return rc; } if (req->rq_bulk->bd_nob_transferred & ~LU_PAGE_MASK) { @@ -1063,11 +1038,11 @@ restart_bulk: req->rq_bulk->bd_nob_transferred, PAGE_CACHE_SIZE * op_data->op_npages); ptlrpc_req_finished(req); - RETURN(-EPROTO); + return -EPROTO; } *request = req; - RETURN(0); + return 0; } static int mdc_statfs(const struct lu_env *env, @@ -1079,7 +1054,6 @@ static int mdc_statfs(const struct lu_env *env, struct obd_statfs *msfs; struct obd_import *imp = NULL; int rc; - ENTRY; /* * Since the request might also come from lprocfs, so we need @@ -1090,7 +1064,7 @@ static int mdc_statfs(const struct lu_env *env, imp = class_import_get(obd->u.cli.cl_import); up_read(&obd->u.cli.cl_sem); if (!imp) - RETURN(-ENODEV); + return -ENODEV; req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_STATFS, LUSTRE_MDS_VERSION, MDS_STATFS); @@ -1118,7 +1092,6 @@ static int mdc_statfs(const struct lu_env *env, GOTO(out, rc = -EPROTO); *osfs = *msfs; - EXIT; out: ptlrpc_req_finished(req); output: @@ -1133,15 +1106,15 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) int rc; if (gf->gf_pathlen > PATH_MAX) - RETURN(-ENAMETOOLONG); + return -ENAMETOOLONG; if (gf->gf_pathlen < 2) - RETURN(-EOVERFLOW); + return -EOVERFLOW; /* Key is KEY_FID2PATH + getinfo_fid2path description */ keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf); OBD_ALLOC(key, keylen); if (key == NULL) - RETURN(-ENOMEM); + return -ENOMEM; memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH)); memcpy(key + cfs_size_round(sizeof(KEY_FID2PATH)), gf, sizeof(*gf)); @@ -1178,7 +1151,6 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp, struct hsm_progress_kernel *req_hpk; struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_PROGRESS, LUSTRE_MDS_VERSION, MDS_HSM_PROGRESS); @@ -1193,6 +1165,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp, GOTO(out, rc = -EPROTO); *req_hpk = *hpk; + req_hpk->hpk_errval = lustre_errno_hton(hpk->hpk_errval); ptlrpc_request_set_replen(req); @@ -1208,7 +1181,6 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives) __u32 *archive_mask; struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_CT_REGISTER, LUSTRE_MDS_VERSION, @@ -1242,19 +1214,18 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp, struct hsm_current_action *req_hca; struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_HSM_ACTION); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_ACTION); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1, @@ -1273,7 +1244,6 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp, *hca = *req_hca; - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -1283,7 +1253,6 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp) { struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_CT_UNREGISTER, LUSTRE_MDS_VERSION, @@ -1309,19 +1278,18 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp, struct hsm_user_state *req_hus; struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_HSM_STATE_GET); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_STATE_GET); if (rc != 0) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1, @@ -1339,7 +1307,6 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp, *hus = *req_hus; - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -1352,19 +1319,18 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp, struct hsm_state_set *req_hss; struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_HSM_STATE_SET); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_STATE_SET); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1, @@ -1381,7 +1347,6 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp, rc = mdc_queue_wait(req); GOTO(out, rc); - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -1396,7 +1361,6 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, struct hsm_user_item *req_hui; char *req_opaque; int rc; - ENTRY; req = ptlrpc_request_alloc(imp, &RQF_MDS_HSM_REQUEST); if (req == NULL) @@ -1411,7 +1375,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_REQUEST); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, NULL, NULL, OBD_MD_FLRMTPERM, 0, 0, 0); @@ -1476,21 +1440,20 @@ static int changelog_kkuc_cb(const struct lu_env *env, struct llog_handle *llh, struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr; struct kuc_hdr *lh; int len, rc; - ENTRY; if (rec->cr_hdr.lrh_type != CHANGELOG_REC) { rc = -EINVAL; CERROR("%s: not a changelog rec %x/%d: rc = %d\n", cs->cs_obd->obd_name, rec->cr_hdr.lrh_type, rec->cr.cr_type, rc); - RETURN(rc); + return rc; } 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", rec->cr.cr_index, cs->cs_startrec); - RETURN(0); + return 0; } CDEBUG(D_CHANGELOG, LPU64" %02d%-5s "LPU64" 0x%x t="DFID" p="DFID @@ -1509,7 +1472,7 @@ static int changelog_kkuc_cb(const struct lu_env *env, struct llog_handle *llh, rc = libcfs_kkuc_msg_put(cs->cs_fp, lh); CDEBUG(D_CHANGELOG, "kucmsg fp %p len %d rc %d\n", cs->cs_fp, len,rc); - RETURN(rc); + return rc; } static int mdc_changelog_send_thread(void *csdata) @@ -1608,13 +1571,12 @@ static int mdc_quotacheck(struct obd_device *unused, struct obd_export *exp, struct ptlrpc_request *req; struct obd_quotactl *body; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_QUOTACHECK, LUSTRE_MDS_VERSION, MDS_QUOTACHECK); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; body = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); *body = *oqctl; @@ -1628,7 +1590,7 @@ static int mdc_quotacheck(struct obd_device *unused, struct obd_export *exp, if (rc) cli->cl_qchk_stat = rc; ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int mdc_quota_poll_check(struct obd_export *exp, @@ -1636,7 +1598,6 @@ static int mdc_quota_poll_check(struct obd_export *exp, { struct client_obd *cli = &exp->exp_obd->u.cli; int rc; - ENTRY; qchk->obd_uuid = cli->cl_target_uuid; memcpy(qchk->obd_type, LUSTRE_MDS_NAME, strlen(LUSTRE_MDS_NAME)); @@ -1645,7 +1606,7 @@ static int mdc_quota_poll_check(struct obd_export *exp, /* the client is not the previous one */ if (rc == CL_NOT_QUOTACHECKED) rc = -EINTR; - RETURN(rc); + return rc; } static int mdc_quotactl(struct obd_device *unused, struct obd_export *exp, @@ -1654,13 +1615,12 @@ static int mdc_quotactl(struct obd_device *unused, struct obd_export *exp, struct ptlrpc_request *req; struct obd_quotactl *oqc; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_QUOTACTL, LUSTRE_MDS_VERSION, MDS_QUOTACTL); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; oqc = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); *oqc = *oqctl; @@ -1682,7 +1642,7 @@ static int mdc_quotactl(struct obd_device *unused, struct obd_export *exp, } ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int mdc_ioc_swap_layouts(struct obd_export *exp, @@ -1692,7 +1652,6 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, struct ptlrpc_request *req; int rc, count; struct mdc_swap_layouts *msl, *payload; - ENTRY; msl = op_data->op_data; @@ -1711,7 +1670,7 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, &RQF_MDS_SWAP_LAYOUTS); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); @@ -1720,7 +1679,7 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, rc = mdc_prep_elc_req(exp, req, MDS_SWAP_LAYOUTS, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_swap_layouts_pack(req, op_data); @@ -1735,7 +1694,6 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, rc = ptlrpc_queue_wait(req); if (rc) GOTO(out, rc); - EXIT; out: ptlrpc_req_finished(req); @@ -1750,7 +1708,6 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct obd_import *imp = obd->u.cli.cl_import; struct llog_ctxt *ctxt; int rc; - ENTRY; if (!try_module_get(THIS_MODULE)) { CERROR("Can't get module. Is it alive?"); @@ -1774,6 +1731,9 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO(out, rc); case LL_IOC_HSM_CT_START: rc = mdc_ioc_hsm_ct_start(exp, karg); + /* ignore if it was already registered on this MDS. */ + if (rc == -EEXIST) + rc = 0; GOTO(out, rc); case LL_IOC_HSM_PROGRESS: rc = mdc_ioc_hsm_progress(exp, karg); @@ -1855,7 +1815,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, OBD_ALLOC_PTR(oqctl); if (!oqctl) - RETURN(-ENOMEM); + return -ENOMEM; QCTL_COPY(oqctl, qctl); rc = obd_quotactl(exp, oqctl); @@ -1897,11 +1857,10 @@ int mdc_get_info_rpc(struct obd_export *exp, struct ptlrpc_request *req; char *tmp; int rc = -EINVAL; - ENTRY; req = ptlrpc_request_alloc(imp, &RQF_MDS_GET_INFO); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_KEY, RCL_CLIENT, keylen); @@ -1911,7 +1870,7 @@ int mdc_get_info_rpc(struct obd_export *exp, rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GET_INFO); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } tmp = req_capsule_client_get(&req->rq_pill, &RMF_GETINFO_KEY); @@ -1936,7 +1895,7 @@ int mdc_get_info_rpc(struct obd_export *exp, } ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static void lustre_swab_hai(struct hsm_action_item *h) @@ -1991,19 +1950,10 @@ static int mdc_ioc_hsm_ct_start(struct obd_export *exp, lk->lk_uid, lk->lk_group, lk->lk_flags); if (lk->lk_flags & LK_FLG_STOP) { - rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group); /* Unregister with the coordinator */ - if (rc == 0) - rc = mdc_ioc_hsm_ct_unregister(imp); + rc = mdc_ioc_hsm_ct_unregister(imp); } else { - struct file *fp = fget(lk->lk_wfd); - - rc = libcfs_kkuc_group_add(fp, lk->lk_uid, lk->lk_group, - lk->lk_data); - if (rc && fp) - fput(fp); - if (rc == 0) - rc = mdc_ioc_hsm_ct_register(imp, archive); + rc = mdc_ioc_hsm_ct_register(imp, archive); } return rc; @@ -2019,19 +1969,18 @@ static int mdc_hsm_copytool_send(int len, void *val) struct kuc_hdr *lh = (struct kuc_hdr *)val; struct hsm_action_list *hal = (struct hsm_action_list *)(lh + 1); int rc; - ENTRY; if (len < sizeof(*lh) + sizeof(*hal)) { CERROR("Short HSM message %d < %d\n", len, (int) (sizeof(*lh) + sizeof(*hal))); - RETURN(-EPROTO); + return -EPROTO; } if (lh->kuc_magic == __swab16(KUC_MAGIC)) { lustre_swab_kuch(lh); lustre_swab_hal(hal); } else if (lh->kuc_magic != KUC_MAGIC) { CERROR("Bad magic %x!=%x\n", lh->kuc_magic, KUC_MAGIC); - RETURN(-EPROTO); + return -EPROTO; } CDEBUG(D_HSM, " Received message mg=%x t=%d m=%d l=%d actions=%d " @@ -2042,7 +1991,7 @@ static int mdc_hsm_copytool_send(int len, void *val) /* Broadcast to HSM listeners */ rc = libcfs_kkuc_group_put(KUC_GRP_HSM, lh); - RETURN(rc); + return rc; } /** @@ -2084,11 +2033,10 @@ int mdc_set_info_async(const struct lu_env *env, { struct obd_import *imp = class_exp2cliimp(exp); int rc; - ENTRY; if (KEY_IS(KEY_READ_ONLY)) { if (vallen != sizeof(int)) - RETURN(-EINVAL); + return -EINVAL; spin_lock(&imp->imp_lock); if (*((int *)val)) { @@ -2104,15 +2052,15 @@ int mdc_set_info_async(const struct lu_env *env, rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION, keylen, key, vallen, val, set); - RETURN(rc); + return rc; } if (KEY_IS(KEY_SPTLRPC_CONF)) { sptlrpc_conf_client_adapt(exp->exp_obd); - RETURN(0); + return 0; } if (KEY_IS(KEY_FLUSH_CTX)) { sptlrpc_import_flush_my_ctx(imp); - RETURN(0); + return 0; } if (KEY_IS(KEY_MDS_CONN)) { /* mds-mds import */ @@ -2121,20 +2069,20 @@ int mdc_set_info_async(const struct lu_env *env, spin_unlock(&imp->imp_lock); imp->imp_client->cli_request_portal = MDS_MDS_PORTAL; CDEBUG(D_OTHER, "%s: timeout / 2\n", exp->exp_obd->obd_name); - RETURN(0); + return 0; } if (KEY_IS(KEY_CHANGELOG_CLEAR)) { rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION, keylen, key, vallen, val, set); - RETURN(rc); + return rc; } if (KEY_IS(KEY_HSM_COPYTOOL_SEND)) { rc = mdc_hsm_copytool_send(vallen, val); - RETURN(rc); + return rc; } CERROR("Unknown key %s\n", (char *)key); - RETURN(-EINVAL); + return -EINVAL; } int mdc_get_info(const struct lu_env *env, struct obd_export *exp, @@ -2147,30 +2095,30 @@ int mdc_get_info(const struct lu_env *env, struct obd_export *exp, int mdsize, *max_easize; if (*vallen != sizeof(int)) - RETURN(-EINVAL); + return -EINVAL; mdsize = *(int*)val; if (mdsize > exp->exp_obd->u.cli.cl_max_mds_easize) exp->exp_obd->u.cli.cl_max_mds_easize = mdsize; max_easize = val; *max_easize = exp->exp_obd->u.cli.cl_max_mds_easize; - RETURN(0); + return 0; } else if (KEY_IS(KEY_CONN_DATA)) { struct obd_import *imp = class_exp2cliimp(exp); struct obd_connect_data *data = val; if (*vallen != sizeof(*data)) - RETURN(-EINVAL); + return -EINVAL; *data = imp->imp_connect_data; - RETURN(0); + return 0; } else if (KEY_IS(KEY_TGT_COUNT)) { *((int *)val) = 1; - RETURN(0); + return 0; } rc = mdc_get_info_rpc(exp, keylen, key, *vallen, val); - RETURN(rc); + return rc; } static int mdc_pin(struct obd_export *exp, const struct lu_fid *fid, @@ -2180,18 +2128,17 @@ static int mdc_pin(struct obd_export *exp, const struct lu_fid *fid, struct ptlrpc_request *req; struct mdt_body *body; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_PIN); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, oc); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_PIN); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, fid, oc, 0, 0, -1, flags); @@ -2220,11 +2167,11 @@ static int mdc_pin(struct obd_export *exp, const struct lu_fid *fid, } handle->och_mod->mod_open_req = req; /* will be dropped by unpin */ - RETURN(0); + return 0; err_out: ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int mdc_unpin(struct obd_export *exp, struct obd_client_handle *handle, @@ -2233,12 +2180,11 @@ static int mdc_unpin(struct obd_export *exp, struct obd_client_handle *handle, struct ptlrpc_request *req; struct mdt_body *body; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_UNPIN, LUSTRE_MDS_VERSION, MDS_UNPIN); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; body = req_capsule_client_get(&req->rq_pill, &RMF_MDT_BODY); body->handle = handle->och_fh; @@ -2257,7 +2203,7 @@ static int mdc_unpin(struct obd_export *exp, struct obd_client_handle *handle, ptlrpc_req_finished(handle->och_mod->mod_open_req); obd_mod_put(handle->och_mod); - RETURN(rc); + return rc; } int mdc_sync(struct obd_export *exp, const struct lu_fid *fid, @@ -2265,19 +2211,18 @@ int mdc_sync(struct obd_export *exp, const struct lu_fid *fid, { struct ptlrpc_request *req; int rc; - ENTRY; *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_SYNC); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, oc); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_SYNC); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, fid, oc, 0, 0, -1, 0); @@ -2289,7 +2234,7 @@ int mdc_sync(struct obd_export *exp, const struct lu_fid *fid, ptlrpc_req_finished(req); else *request = req; - RETURN(rc); + return rc; } static int mdc_import_event(struct obd_device *obd, struct obd_import *imp, @@ -2328,7 +2273,7 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp, } case IMP_EVENT_ACTIVE: rc = obd_notify_observer(obd, obd, OBD_NOTIFY_ACTIVE, NULL); - /* restore re-establish kuc registration after reconnecting */ + /* redo the kuc registration after reconnecting */ if (rc == 0) rc = mdc_kuc_reregister(imp); break; @@ -2342,7 +2287,7 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp, CERROR("Unknown import event %x\n", event); LBUG(); } - RETURN(rc); + return rc; } int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid, @@ -2350,8 +2295,8 @@ int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid, { struct client_obd *cli = &exp->exp_obd->u.cli; struct lu_client_seq *seq = cli->cl_seq; - ENTRY; - RETURN(seq_client_alloc_fid(NULL, seq, fid)); + + return seq_client_alloc_fid(NULL, seq, fid); } struct obd_uuid *mdc_get_uuid(struct obd_export *exp) { @@ -2367,15 +2312,15 @@ struct obd_uuid *mdc_get_uuid(struct obd_export *exp) { static int mdc_cancel_for_recovery(struct ldlm_lock *lock) { if (lock->l_resource->lr_type != LDLM_IBITS) - RETURN(0); + return 0; /* FIXME: if we ever get into a situation where there are too many * opened files with open locks on a single node, then we really * should replay these open locks to reget it */ if (lock->l_policy_data.l_inodebits.bits & MDS_INODELOCK_OPEN) - RETURN(0); + return 0; - RETURN(1); + return 1; } static int mdc_resource_inode_free(struct ldlm_resource *res) @@ -2387,7 +2332,7 @@ static int mdc_resource_inode_free(struct ldlm_resource *res) } struct ldlm_valblock_ops inode_lvbo = { - lvbo_free: mdc_resource_inode_free + .lvbo_free = mdc_resource_inode_free, }; static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) @@ -2395,11 +2340,10 @@ 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 }; int rc; - ENTRY; OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock)); if (!cli->cl_rpc_lock) - RETURN(-ENOMEM); + return -ENOMEM; mdc_init_rpc_lock(cli->cl_rpc_lock); ptlrpcd_addref(); @@ -2427,14 +2371,14 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) CERROR("failed to setup llogging subsystems\n"); } - RETURN(rc); + return rc; err_close_lock: OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock)); err_rpc_lock: OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock)); ptlrpcd_decref(); - RETURN(rc); + return rc; } /* Initialize the default and maximum LOV EA and cookie sizes. This allows @@ -2446,7 +2390,6 @@ static int mdc_init_ea_size(struct obd_export *exp, int easize, { struct obd_device *obd = exp->exp_obd; struct client_obd *cli = &obd->u.cli; - ENTRY; if (cli->cl_max_mds_easize < easize) cli->cl_max_mds_easize = easize; @@ -2457,13 +2400,12 @@ static int mdc_init_ea_size(struct obd_export *exp, int easize, if (cli->cl_max_mds_cookiesize < cookiesize) cli->cl_max_mds_cookiesize = cookiesize; - RETURN(0); + return 0; } static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { int rc = 0; - ENTRY; switch (stage) { case OBD_CLEANUP_EARLY: @@ -2482,7 +2424,7 @@ static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) CERROR("failed to cleanup llogging subsystems\n"); break; } - RETURN(rc); + return rc; } static int mdc_cleanup(struct obd_device *obd) @@ -2504,33 +2446,29 @@ static int mdc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, struct llog_ctxt *ctxt; int rc; - ENTRY; - LASSERT(olg == &obd->obd_olg); rc = llog_setup(NULL, obd, olg, LLOG_CHANGELOG_REPL_CTXT, tgt, &llog_client_ops); if (rc) - RETURN(rc); + return rc; ctxt = llog_group_get_ctxt(olg, LLOG_CHANGELOG_REPL_CTXT); llog_initiator_connect(ctxt); llog_ctxt_put(ctxt); - RETURN(0); + return 0; } static int mdc_llog_finish(struct obd_device *obd, int count) { struct llog_ctxt *ctxt; - ENTRY; - ctxt = llog_get_context(obd, LLOG_CHANGELOG_REPL_CTXT); if (ctxt) llog_cleanup(NULL, ctxt); - RETURN(0); + return 0; } static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf) @@ -2559,21 +2497,20 @@ int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid, { struct ptlrpc_request *req; int rc; - ENTRY; LASSERT(client_is_remote(exp)); *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, oc); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, fid, oc, OBD_MD_FLRMTPERM, 0, suppgid, 0); @@ -2588,7 +2525,7 @@ int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid, ptlrpc_req_finished(req); else *request = req; - RETURN(rc); + return rc; } static int mdc_interpret_renew_capa(const struct lu_env *env, @@ -2598,7 +2535,6 @@ static int mdc_interpret_renew_capa(const struct lu_env *env, struct mdc_renew_capa_args *ra = args; struct mdt_body *body = NULL; struct lustre_capa *capa; - ENTRY; if (status) GOTO(out, capa = ERR_PTR(status)); @@ -2613,7 +2549,6 @@ static int mdc_interpret_renew_capa(const struct lu_env *env, capa = req_capsule_server_get(&req->rq_pill, &RMF_CAPA2); if (!capa) GOTO(out, capa = ERR_PTR(-EFAULT)); - EXIT; out: ra->ra_cb(ra->ra_oc, capa); return 0; @@ -2624,12 +2559,11 @@ static int mdc_renew_capa(struct obd_export *exp, struct obd_capa *oc, { struct ptlrpc_request *req; struct mdc_renew_capa_args *ra; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_GETATTR, LUSTRE_MDS_VERSION, MDS_GETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* NB, OBD_MD_FLOSSCAPA is set here, but it doesn't necessarily mean the * capa to renew is oss capa. @@ -2643,7 +2577,7 @@ static int mdc_renew_capa(struct obd_export *exp, struct obd_capa *oc, ra->ra_cb = cb; req->rq_interpret_reply = mdc_interpret_renew_capa; ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1); - RETURN(0); + return 0; } static int mdc_connect(const struct lu_env *env, @@ -2737,7 +2671,7 @@ int __init mdc_init(void) rc = class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars, LUSTRE_MDC_NAME, NULL); - RETURN(rc); + return rc; } static void /*__exit*/ mdc_exit(void) diff --git a/drivers/staging/lustre/lustre/mgc/libmgc.c b/drivers/staging/lustre/lustre/mgc/libmgc.c index 442146cc7e6..7b4947cec3a 100644 --- a/drivers/staging/lustre/lustre/mgc/libmgc.c +++ b/drivers/staging/lustre/lustre/mgc/libmgc.c @@ -56,7 +56,6 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { int rc; - ENTRY; ptlrpcd_addref(); @@ -73,19 +72,18 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) GOTO(err_cleanup, rc); } - RETURN(rc); + return rc; err_cleanup: client_obd_cleanup(obd); err_decref: ptlrpcd_decref(); - RETURN(rc); + return rc; } static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { int rc = 0; - ENTRY; switch (stage) { case OBD_CLEANUP_EARLY: @@ -96,21 +94,20 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) CERROR("failed to cleanup llogging subsystems\n"); break; } - RETURN(rc); + return rc; } static int mgc_cleanup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; int rc; - ENTRY; LASSERT(cli->cl_mgc_vfsmnt == NULL); ptlrpcd_decref(); rc = client_obd_cleanup(obd); - RETURN(rc); + return rc; } static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, @@ -118,32 +115,30 @@ static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, { struct llog_ctxt *ctxt; int rc; - ENTRY; LASSERT(olg == &obd->obd_olg); rc = llog_setup(NULL, obd, olg, LLOG_CONFIG_REPL_CTXT, tgt, &llog_client_ops); if (rc < 0) - RETURN(rc); + return rc; ctxt = llog_group_get_ctxt(olg, LLOG_CONFIG_REPL_CTXT); llog_initiator_connect(ctxt); llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } static int mgc_llog_finish(struct obd_device *obd, int count) { struct llog_ctxt *ctxt; - ENTRY; ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT); if (ctxt) llog_cleanup(NULL, ctxt); - RETURN(0); + return 0; } struct obd_ops mgc_obd_ops = { diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index 1105eaa2431..ebecec2b007 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#include <linux/version.h> #include <linux/vfs.h> #include <obd_class.h> #include <lprocfs_status.h> diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index c6c84d97ce4..12a9ede21a8 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -118,19 +118,16 @@ static DEFINE_SPINLOCK(config_list_lock); /* Take a reference to a config log */ static int config_log_get(struct config_llog_data *cld) { - ENTRY; atomic_inc(&cld->cld_refcount); CDEBUG(D_INFO, "log %s refs %d\n", cld->cld_logname, atomic_read(&cld->cld_refcount)); - RETURN(0); + return 0; } /* Drop a reference to a config log. When no longer referenced, we can free the config log data */ static void config_log_put(struct config_llog_data *cld) { - ENTRY; - CDEBUG(D_INFO, "log %s refs %d\n", cld->cld_logname, atomic_read(&cld->cld_refcount)); LASSERT(atomic_read(&cld->cld_refcount) > 0); @@ -152,8 +149,6 @@ static void config_log_put(struct config_llog_data *cld) class_export_put(cld->cld_mgcexp); OBD_FREE(cld, sizeof(*cld) + strlen(cld->cld_logname) + 1); } - - EXIT; } /* Find a config log by name */ @@ -164,7 +159,6 @@ struct config_llog_data *config_log_find(char *logname, struct config_llog_data *cld; struct config_llog_data *found = NULL; void * instance; - ENTRY; LASSERT(logname != NULL); @@ -186,7 +180,7 @@ struct config_llog_data *config_log_find(char *logname, LASSERT(found->cld_stopping == 0 || cld_is_sptlrpc(found) == 0); } spin_unlock(&config_list_lock); - RETURN(found); + return found; } static @@ -198,14 +192,13 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, { struct config_llog_data *cld; int rc; - ENTRY; CDEBUG(D_MGC, "do adding config log %s:%p\n", logname, cfg ? cfg->cfg_instance : 0); OBD_ALLOC(cld, sizeof(*cld) + strlen(logname) + 1); if (!cld) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); strcpy(cld->cld_logname, logname); if (cfg) @@ -235,7 +228,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, if (rc) { config_log_put(cld); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } if (cld_is_sptlrpc(cld)) { @@ -244,7 +237,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, CERROR("failed processing sptlrpc log: %d\n", rc); } - RETURN(cld); + return cld; } static struct config_llog_data *config_recover_log_add(struct obd_device *obd, @@ -296,7 +289,6 @@ static int config_log_add(struct obd_device *obd, char *logname, struct config_llog_data *sptlrpc_cld; char seclogname[32]; char *ptr; - ENTRY; CDEBUG(D_MGC, "adding config log %s:%p\n", logname, cfg->cfg_instance); @@ -307,7 +299,7 @@ static int config_log_add(struct obd_device *obd, char *logname, ptr = strrchr(logname, '-'); if (ptr == NULL || ptr - logname > 8) { CERROR("logname %s is too long\n", logname); - RETURN(-EINVAL); + return -EINVAL; } memcpy(seclogname, logname, ptr - logname); @@ -319,7 +311,7 @@ static int config_log_add(struct obd_device *obd, char *logname, CONFIG_T_SPTLRPC, NULL, NULL); if (IS_ERR(sptlrpc_cld)) { CERROR("can't create sptlrpc log: %s\n", seclogname); - RETURN(PTR_ERR(sptlrpc_cld)); + return PTR_ERR(sptlrpc_cld); } } @@ -327,7 +319,7 @@ static int config_log_add(struct obd_device *obd, char *logname, if (IS_ERR(cld)) { CERROR("can't create log: %s\n", logname); config_log_put(sptlrpc_cld); - RETURN(PTR_ERR(cld)); + return PTR_ERR(cld); } cld->cld_sptlrpc = sptlrpc_cld; @@ -339,12 +331,12 @@ static int config_log_add(struct obd_device *obd, char *logname, recover_cld = config_recover_log_add(obd, seclogname, cfg, sb); if (IS_ERR(recover_cld)) { config_log_put(cld); - RETURN(PTR_ERR(recover_cld)); + return PTR_ERR(recover_cld); } cld->cld_recover = recover_cld; } - RETURN(0); + return 0; } DEFINE_MUTEX(llog_process_lock); @@ -357,11 +349,10 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) struct config_llog_data *cld_sptlrpc = NULL; struct config_llog_data *cld_recover = NULL; int rc = 0; - ENTRY; cld = config_log_find(logname, cfg); if (cld == NULL) - RETURN(-ENOENT); + return -ENOENT; mutex_lock(&cld->cld_lock); /* @@ -375,7 +366,7 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) mutex_unlock(&cld->cld_lock); /* drop the ref from the find */ config_log_put(cld); - RETURN(rc); + return rc; } cld->cld_stopping = 1; @@ -406,7 +397,7 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) CDEBUG(D_MGC, "end config log %s (%d)\n", logname ? logname : "client", rc); - RETURN(rc); + return rc; } int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) @@ -415,7 +406,6 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) struct obd_import *imp = obd->u.cli.cl_import; struct obd_connect_data *ocd = &imp->imp_connect_data; struct config_llog_data *cld; - ENTRY; seq_printf(m, "imperative_recovery: %s\n", OCD_HAS_FLAG(ocd, IMP_RECOV) ? "ENABLED" : "DISABLED"); @@ -431,7 +421,7 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) } spin_unlock(&config_list_lock); - RETURN(0); + return 0; } /* reenqueue any lost locks */ @@ -445,7 +435,6 @@ static DECLARE_COMPLETION(rq_exit); static void do_requeue(struct config_llog_data *cld) { - ENTRY; LASSERT(atomic_read(&cld->cld_refcount) > 0); /* Do not run mgc_process_log on a disconnected export or an @@ -460,8 +449,6 @@ static void do_requeue(struct config_llog_data *cld) cld->cld_logname); } up_read(&cld->cld_mgcexp->exp_obd->u.cli.cl_sem); - - EXIT; } /* this timeout represents how many seconds MGC should wait before @@ -474,7 +461,6 @@ static void do_requeue(struct config_llog_data *cld) static int mgc_requeue_thread(void *data) { int rc = 0; - ENTRY; CDEBUG(D_MGC, "Starting requeue thread\n"); @@ -556,15 +542,13 @@ static int mgc_requeue_thread(void *data) complete(&rq_exit); CDEBUG(D_MGC, "Ending requeue thread\n"); - RETURN(rc); + return rc; } /* Add a cld to the list to requeue. Start the requeue thread if needed. We are responsible for dropping the config log reference from here on out. */ static void mgc_requeue_add(struct config_llog_data *cld) { - ENTRY; - CDEBUG(D_INFO, "log %s: requeue (r=%d sp=%d st=%x)\n", cld->cld_logname, atomic_read(&cld->cld_refcount), cld->cld_stopping, rq_state); @@ -573,7 +557,7 @@ static void mgc_requeue_add(struct config_llog_data *cld) mutex_lock(&cld->cld_lock); if (cld->cld_stopping || cld->cld_lostlock) { mutex_unlock(&cld->cld_lock); - RETURN_EXIT; + return; } /* this refcount will be released in mgc_requeue_thread. */ config_log_get(cld); @@ -591,7 +575,6 @@ static void mgc_requeue_add(struct config_llog_data *cld) spin_unlock(&config_list_lock); wake_up(&rq_waitq); } - EXIT; } /********************** class fns **********************/ @@ -605,7 +588,6 @@ static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb, struct dentry *dentry; char *label; int err = 0; - ENTRY; LASSERT(lsi); LASSERT(lsi->lsi_srv_mnt == mnt); @@ -620,7 +602,7 @@ static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb, up(&cli->cl_mgc_sem); CERROR("%s: No fstype %s: rc = %ld\n", lsi->lsi_fstype, obd->obd_name, PTR_ERR(obd->obd_fsops)); - RETURN(PTR_ERR(obd->obd_fsops)); + return PTR_ERR(obd->obd_fsops); } cli->cl_mgc_vfsmnt = mnt; @@ -654,21 +636,20 @@ static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb, CDEBUG(D_MGC, "MGC using disk labelled=%s\n", label); /* We keep the cl_mgc_sem until mgc_fs_cleanup */ - RETURN(0); + return 0; err_ops: fsfilt_put_ops(obd->obd_fsops); obd->obd_fsops = NULL; cli->cl_mgc_vfsmnt = NULL; up(&cli->cl_mgc_sem); - RETURN(err); + return err; } static int mgc_fs_cleanup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; int rc = 0; - ENTRY; LASSERT(cli->cl_mgc_vfsmnt != NULL); @@ -687,14 +668,13 @@ static int mgc_fs_cleanup(struct obd_device *obd) up(&cli->cl_mgc_sem); - RETURN(rc); + return rc; } static atomic_t mgc_count = ATOMIC_INIT(0); static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { int rc = 0; - ENTRY; switch (stage) { case OBD_CLEANUP_EARLY: @@ -719,14 +699,13 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) CERROR("failed to cleanup llogging subsystems\n"); break; } - RETURN(rc); + return rc; } static int mgc_cleanup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; int rc; - ENTRY; LASSERT(cli->cl_mgc_vfsmnt == NULL); @@ -740,14 +719,13 @@ static int mgc_cleanup(struct obd_device *obd) ptlrpcd_decref(); rc = client_obd_cleanup(obd); - RETURN(rc); + return rc; } static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { struct lprocfs_static_vars lvars; int rc; - ENTRY; ptlrpcd_addref(); @@ -782,13 +760,13 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) rc = 0; } - RETURN(rc); + return rc; err_cleanup: client_obd_cleanup(obd); err_decref: ptlrpcd_decref(); - RETURN(rc); + return rc; } /* based on ll_mdc_blocking_ast */ @@ -798,7 +776,6 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, struct lustre_handle lockh; struct config_llog_data *cld = (struct config_llog_data *)data; int rc = 0; - ENTRY; switch (flag) { case LDLM_CB_BLOCKING: @@ -847,7 +824,7 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, LBUG(); } - RETURN(rc); + return rc; } /* Not sure where this should go... */ @@ -862,18 +839,17 @@ static int mgc_set_mgs_param(struct obd_export *exp, struct ptlrpc_request *req; struct mgs_send_param *req_msp, *rep_msp; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MGS_SET_INFO, LUSTRE_MGS_VERSION, MGS_SET_INFO); if (!req) - RETURN(-ENOMEM); + return -ENOMEM; req_msp = req_capsule_client_get(&req->rq_pill, &RMF_MGS_SEND_PARAM); if (!req_msp) { ptlrpc_req_finished(req); - RETURN(-ENOMEM); + return -ENOMEM; } memcpy(req_msp, msp, sizeof(*req_msp)); @@ -889,7 +865,7 @@ static int mgc_set_mgs_param(struct obd_export *exp, ptlrpc_req_finished(req); - RETURN(rc); + return rc; } /* Take a config lock so we can get cancel notifications */ @@ -900,12 +876,15 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm, struct lustre_handle *lockh) { struct config_llog_data *cld = (struct config_llog_data *)data; - struct ldlm_enqueue_info einfo = { type, mode, mgc_blocking_ast, - ldlm_completion_ast, NULL, NULL, NULL }; + struct ldlm_enqueue_info einfo = { + .ei_type = type, + .ei_mode = mode, + .ei_cb_bl = mgc_blocking_ast, + .ei_cb_cp = ldlm_completion_ast, + }; struct ptlrpc_request *req; int short_limit = cld_is_sptlrpc(cld); int rc; - ENTRY; CDEBUG(D_MGC, "Enqueue for %s (res "LPX64")\n", cld->cld_logname, cld->cld_resid.name[0]); @@ -916,7 +895,7 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm, &RQF_LDLM_ENQUEUE, LUSTRE_DLM_VERSION, LDLM_ENQUEUE); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, 0); ptlrpc_request_set_replen(req); @@ -934,17 +913,15 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm, /* A failed enqueue should still call the mgc_blocking_ast, where it will be requeued if needed ("grant failed"). */ ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int mgc_cancel(struct obd_export *exp, struct lov_stripe_md *md, __u32 mode, struct lustre_handle *lockh) { - ENTRY; - ldlm_lock_decref(lockh, mode); - RETURN(0); + return 0; } static void mgc_notify_active(struct obd_device *unused) @@ -965,18 +942,17 @@ static int mgc_target_register(struct obd_export *exp, struct ptlrpc_request *req; struct mgs_target_info *req_mti, *rep_mti; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MGS_TARGET_REG, LUSTRE_MGS_VERSION, MGS_TARGET_REG); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_mti = req_capsule_client_get(&req->rq_pill, &RMF_MGS_TARGET_INFO); if (!req_mti) { ptlrpc_req_finished(req); - RETURN(-ENOMEM); + return -ENOMEM; } memcpy(req_mti, mti, sizeof(*req_mti)); @@ -995,7 +971,7 @@ static int mgc_target_register(struct obd_export *exp, } ptlrpc_req_finished(req); - RETURN(rc); + return rc; } int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, @@ -1003,14 +979,13 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, void *val, struct ptlrpc_request_set *set) { int rc = -EINVAL; - ENTRY; /* Turn off initial_recov after we try all backup servers once */ if (KEY_IS(KEY_INIT_RECOV_BACKUP)) { struct obd_import *imp = class_exp2cliimp(exp); int value; if (vallen != sizeof(int)) - RETURN(-EINVAL); + return -EINVAL; value = *(int *)val; CDEBUG(D_MGC, "InitRecov %s %d/d%d:i%d:r%d:or%d:%s\n", imp->imp_obd->obd_name, value, @@ -1021,46 +996,46 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, if ((imp->imp_state != LUSTRE_IMP_FULL && imp->imp_state != LUSTRE_IMP_NEW) || value > 1) ptlrpc_reconnect_import(imp); - RETURN(0); + return 0; } /* FIXME move this to mgc_process_config */ if (KEY_IS(KEY_REGISTER_TARGET)) { struct mgs_target_info *mti; if (vallen != sizeof(struct mgs_target_info)) - RETURN(-EINVAL); + return -EINVAL; mti = (struct mgs_target_info *)val; CDEBUG(D_MGC, "register_target %s %#x\n", mti->mti_svname, mti->mti_flags); rc = mgc_target_register(exp, mti); - RETURN(rc); + return rc; } if (KEY_IS(KEY_SET_FS)) { struct super_block *sb = (struct super_block *)val; struct lustre_sb_info *lsi; if (vallen != sizeof(struct super_block)) - RETURN(-EINVAL); + return -EINVAL; lsi = s2lsi(sb); rc = mgc_fs_setup(exp->exp_obd, sb, lsi->lsi_srv_mnt); if (rc) { CERROR("set_fs got %d\n", rc); } - RETURN(rc); + return rc; } if (KEY_IS(KEY_CLEAR_FS)) { if (vallen != 0) - RETURN(-EINVAL); + return -EINVAL; rc = mgc_fs_cleanup(exp->exp_obd); if (rc) { CERROR("clear_fs got %d\n", rc); } - RETURN(rc); + return rc; } if (KEY_IS(KEY_SET_INFO)) { struct mgs_send_param *msp; msp = (struct mgs_send_param *)val; rc = mgc_set_mgs_param(exp, msp); - RETURN(rc); + return rc; } if (KEY_IS(KEY_MGSSEC)) { struct client_obd *cli = &exp->exp_obd->u.cli; @@ -1075,7 +1050,7 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, */ if (vallen == 0) { if (cli->cl_flvr_mgc.sf_rpc != SPTLRPC_FLVR_INVALID) - RETURN(0); + return 0; val = "null"; vallen = 4; } @@ -1084,7 +1059,7 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, if (rc) { CERROR("invalid sptlrpc flavor %s to MGS\n", (char *) val); - RETURN(rc); + return rc; } /* @@ -1103,10 +1078,10 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, (char *) val, str); rc = -EPERM; } - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } static int mgc_get_info(const struct lu_env *env, struct obd_export *exp, @@ -1167,7 +1142,7 @@ static int mgc_import_event(struct obd_device *obd, CERROR("Unknown import event %#x\n", event); LBUG(); } - RETURN(rc); + return rc; } static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, @@ -1175,7 +1150,6 @@ static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, { struct llog_ctxt *ctxt; int rc; - ENTRY; LASSERT(olg == &obd->obd_olg); @@ -1192,20 +1166,18 @@ static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, llog_initiator_connect(ctxt); llog_ctxt_put(ctxt); - RETURN(0); + return 0; out: ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt) llog_cleanup(NULL, ctxt); - RETURN(rc); + return rc; } static int mgc_llog_finish(struct obd_device *obd, int count) { struct llog_ctxt *ctxt; - ENTRY; - ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT); if (ctxt) llog_cleanup(NULL, ctxt); @@ -1213,7 +1185,7 @@ static int mgc_llog_finish(struct obd_device *obd, int count) ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt) llog_cleanup(NULL, ctxt); - RETURN(0); + return 0; } enum { @@ -1238,14 +1210,13 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, int pos; int rc = 0; int off = 0; - ENTRY; LASSERT(cfg->cfg_instance != NULL); LASSERT(cfg->cfg_sb == cfg->cfg_instance); OBD_ALLOC(inst, PAGE_CACHE_SIZE); if (inst == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (!IS_SERVER(lsi)) { pos = snprintf(inst, PAGE_CACHE_SIZE, "%p", cfg->cfg_instance); @@ -1259,7 +1230,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, PAGE_CACHE_SIZE); if (rc) { OBD_FREE(inst, PAGE_CACHE_SIZE); - RETURN(-EINVAL); + return -EINVAL; } pos = strlen(inst); } @@ -1417,7 +1388,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, } OBD_FREE(inst, PAGE_CACHE_SIZE); - RETURN(rc); + return rc; } /** @@ -1439,7 +1410,6 @@ static int mgc_process_recover_log(struct obd_device *obd, int i; int ealen; int rc; - ENTRY; /* allocate buffer for bulk transfer. * if this is the first time for this mgs to read logs, @@ -1582,8 +1552,6 @@ static int mgc_process_cfg_log(struct obd_device *mgc, int rc = 0, must_pop = 0; bool sptlrpc_started = false; - ENTRY; - LASSERT(cld); LASSERT(mutex_is_locked(&cld->cld_lock)); @@ -1592,7 +1560,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc, * read it up here. */ if (cld_is_sptlrpc(cld) && local_only) - RETURN(0); + return 0; if (cld->cld_cfg.cfg_sb) lsi = s2lsi(cld->cld_cfg.cfg_sb); @@ -1600,12 +1568,12 @@ static int mgc_process_cfg_log(struct obd_device *mgc, ctxt = llog_get_context(mgc, LLOG_CONFIG_REPL_CTXT); if (!ctxt) { CERROR("missing llog context\n"); - RETURN(-EINVAL); + return -EINVAL; } OBD_ALLOC_PTR(saved_ctxt); if (saved_ctxt == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lctxt = llog_get_context(mgc, LLOG_CONFIG_ORIG_CTXT); @@ -1623,7 +1591,6 @@ static int mgc_process_cfg_log(struct obd_device *mgc, be updated here. */ rc = class_config_parse_llog(NULL, ctxt, cld->cld_logname, &cld->cld_cfg); - EXIT; out_pop: llog_ctxt_put(ctxt); @@ -1647,7 +1614,7 @@ out_pop: strlen("-sptlrpc")); } - RETURN(rc); + return rc; } /** Get a config log from the MGS and process it. @@ -1659,7 +1626,6 @@ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld) struct lustre_handle lockh = { 0 }; __u64 flags = LDLM_FL_NO_LRU; int rc = 0, rcl; - ENTRY; LASSERT(cld); @@ -1670,7 +1636,7 @@ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld) mutex_lock(&cld->cld_lock); if (cld->cld_stopping) { mutex_unlock(&cld->cld_lock); - RETURN(0); + return 0; } OBD_FAIL_TIMEOUT(OBD_FAIL_MGC_PAUSE_PROCESS_LOG, 20); @@ -1719,7 +1685,7 @@ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld) CERROR("Can't drop cfg lock: %d\n", rcl); } - RETURN(rc); + return rc; } @@ -1733,7 +1699,6 @@ static int mgc_process_config(struct obd_device *obd, obd_count len, void *buf) struct config_llog_instance *cfg = NULL; char *logname; int rc = 0; - ENTRY; switch(lcfg->lcfg_command) { case LCFG_LOV_ADD_OBD: { @@ -1818,7 +1783,7 @@ static int mgc_process_config(struct obd_device *obd, obd_count len, void *buf) } } out: - RETURN(rc); + return rc; } struct obd_ops mgc_obd_ops = { diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index b80c13c6f5d..8a0e08ced45 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -3,7 +3,7 @@ obj-$(CONFIG_LUSTRE_FS) += obdclass.o llog_test.o obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \ llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \ genops.o uuid.o llog_ioctl.o lprocfs_status.o \ - lprocfs_jobstats.o lustre_handles.o lustre_peer.o llog_osd.o \ + lustre_handles.o lustre_peer.o llog_osd.o \ local_storage.o statfs_pack.o obdo.o obd_config.o obd_mount.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 \ diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index c2a6702c9f2..f0bb632a70a 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/drivers/staging/lustre/lustre/obdclass/acl.c @@ -144,10 +144,9 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size) { int count, i, esize; ext_acl_xattr_header *new; - ENTRY; if (unlikely(size < 0)) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); else if (!size) count = 0; else @@ -155,7 +154,7 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size) esize = CFS_ACL_XATTR_SIZE(count, ext_acl_xattr); OBD_ALLOC(new, esize); if (unlikely(new == NULL)) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); new->a_count = cpu_to_le32(count); for (i = 0; i < count; i++) { @@ -165,7 +164,7 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size) new->a_entries[i].e_stat = cpu_to_le32(ES_UNK); } - RETURN(new); + return new; } EXPORT_SYMBOL(lustre_posix_acl_xattr_2ext); @@ -178,16 +177,15 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size, int count, i, j, rc = 0; __u32 id; posix_acl_xattr_header *new; - ENTRY; if (unlikely(size < 0)) - RETURN(-EINVAL); + return -EINVAL; else if (!size) - RETURN(0); + return 0; OBD_ALLOC(new, size); if (unlikely(new == NULL)) - RETURN(-ENOMEM); + return -ENOMEM; new->a_version = cpu_to_le32(CFS_ACL_XATTR_VERSION); count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr); @@ -228,7 +226,6 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size, *out = new; rc = 0; } - EXIT; _out: if (rc) { @@ -302,7 +299,6 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, posix_acl_xattr_entry pe = {ACL_MASK, 0, ACL_UNDEFINED_ID}; posix_acl_xattr_header *new; ext_acl_xattr_entry *ee, ae; - ENTRY; lustre_posix_acl_cpu_to_le(&pe, &pe); ee = lustre_ext_acl_xattr_search(ext_header, &pe, &pos); @@ -312,7 +308,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, posix_size = CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr); OBD_ALLOC(new, posix_size); if (unlikely(new == NULL)) - RETURN(-ENOMEM); + return -ENOMEM; new->a_version = cpu_to_le32(CFS_ACL_XATTR_VERSION); for (i = 0, j = 0; i < ext_count; i++) { @@ -349,7 +345,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, int ori_posix_count; if (unlikely(size < 0)) - RETURN(-EINVAL); + return -EINVAL; else if (!size) ori_posix_count = 0; else @@ -360,7 +356,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr); OBD_ALLOC(new, posix_size); if (unlikely(new == NULL)) - RETURN(-ENOMEM); + return -ENOMEM; new->a_version = cpu_to_le32(CFS_ACL_XATTR_VERSION); /* 1. process the unchanged ACL entries @@ -397,7 +393,6 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, *out = new; rc = 0; } - EXIT; _out: if (rc) { @@ -420,10 +415,9 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, posix_acl_xattr_entry pae; ext_acl_xattr_header *new; ext_acl_xattr_entry *ee, eae; - ENTRY; if (unlikely(size < 0)) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); else if (!size) posix_count = 0; else @@ -434,7 +428,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, OBD_ALLOC(new, ext_size); if (unlikely(new == NULL)) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); for (i = 0, j = 0; i < posix_count; i++) { lustre_posix_acl_le_to_cpu(&pae, &posix_header->a_entries[i]); @@ -532,7 +526,6 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, new->a_count = cpu_to_le32(j); /* free unused space. */ rc = lustre_ext_acl_xattr_reduce_space(&new, ext_count); - EXIT; out: if (rc) { diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c index 3e532f5106e..68d797ba8ae 100644 --- a/drivers/staging/lustre/lustre/obdclass/capa.c +++ b/drivers/staging/lustre/lustre/obdclass/capa.c @@ -42,12 +42,12 @@ #define DEBUG_SUBSYSTEM S_SEC -#include <linux/version.h> #include <linux/fs.h> #include <asm/unistd.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/init.h> +#include <linux/crypto.h> #include <obd_class.h> #include <lustre_debug.h> @@ -77,6 +77,12 @@ EXPORT_SYMBOL(capa_list); EXPORT_SYMBOL(capa_lock); EXPORT_SYMBOL(capa_count); +static inline +unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm) +{ + return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.min_keysize; +} + struct hlist_head *init_capa_hash(void) { struct hlist_head *hash; @@ -235,9 +241,26 @@ struct obd_capa *capa_lookup(struct hlist_head *hash, struct lustre_capa *capa, } EXPORT_SYMBOL(capa_lookup); +static inline int ll_crypto_hmac(struct crypto_hash *tfm, + u8 *key, unsigned int *keylen, + struct scatterlist *sg, + unsigned int size, u8 *result) +{ + struct hash_desc desc; + int rv; + desc.tfm = tfm; + desc.flags = 0; + rv = crypto_hash_setkey(desc.tfm, key, *keylen); + if (rv) { + CERROR("failed to hash setkey: %d\n", rv); + return rv; + } + return crypto_hash_digest(&desc, sg, size, result); +} + int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key) { - struct ll_crypto_hash *tfm; + struct crypto_hash *tfm; struct capa_hmac_alg *alg; int keylen; struct scatterlist sl; @@ -249,7 +272,7 @@ int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key) alg = &capa_hmac_algs[capa_alg(capa)]; - tfm = ll_crypto_alloc_hash(alg->ha_name, 0, 0); + tfm = crypto_alloc_hash(alg->ha_name, 0, 0); if (!tfm) { CERROR("crypto_alloc_tfm failed, check whether your kernel" "has crypto support!\n"); @@ -262,7 +285,7 @@ int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key) (unsigned long)(capa) % PAGE_CACHE_SIZE); ll_crypto_hmac(tfm, key, &keylen, &sl, sl.length, hmac); - ll_crypto_free_hash(tfm); + crypto_free_hash(tfm); return 0; } @@ -270,21 +293,20 @@ EXPORT_SYMBOL(capa_hmac); int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) { - struct ll_crypto_cipher *tfm; + struct crypto_blkcipher *tfm; struct scatterlist sd; struct scatterlist ss; struct blkcipher_desc desc; unsigned int min; int rc; char alg[CRYPTO_MAX_ALG_NAME+1] = "aes"; - ENTRY; /* passing "aes" in a variable instead of a constant string keeps gcc * 4.3.2 happy */ - tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 ); + tfm = crypto_alloc_blkcipher(alg, 0, 0 ); if (IS_ERR(tfm)) { CERROR("failed to load transform for aes\n"); - RETURN(PTR_ERR(tfm)); + return PTR_ERR(tfm); } min = ll_crypto_tfm_alg_min_keysize(tfm); @@ -293,7 +315,7 @@ int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) GOTO(out, rc = -EINVAL); } - rc = ll_crypto_blkcipher_setkey(tfm, key, min); + rc = crypto_blkcipher_setkey(tfm, key, min); if (rc) { CERROR("failed to setting key for aes\n"); GOTO(out, rc); @@ -307,37 +329,34 @@ int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) desc.tfm = tfm; desc.info = NULL; desc.flags = 0; - rc = ll_crypto_blkcipher_encrypt(&desc, &sd, &ss, 16); + rc = crypto_blkcipher_encrypt(&desc, &sd, &ss, 16); if (rc) { CERROR("failed to encrypt for aes\n"); GOTO(out, rc); } - EXIT; - out: - ll_crypto_free_blkcipher(tfm); + crypto_free_blkcipher(tfm); return rc; } EXPORT_SYMBOL(capa_encrypt_id); int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) { - struct ll_crypto_cipher *tfm; + struct crypto_blkcipher *tfm; struct scatterlist sd; struct scatterlist ss; struct blkcipher_desc desc; unsigned int min; int rc; char alg[CRYPTO_MAX_ALG_NAME+1] = "aes"; - ENTRY; /* passing "aes" in a variable instead of a constant string keeps gcc * 4.3.2 happy */ - tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 ); + tfm = crypto_alloc_blkcipher(alg, 0, 0 ); if (IS_ERR(tfm)) { CERROR("failed to load transform for aes\n"); - RETURN(PTR_ERR(tfm)); + return PTR_ERR(tfm); } min = ll_crypto_tfm_alg_min_keysize(tfm); @@ -346,7 +365,7 @@ int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) GOTO(out, rc = -EINVAL); } - rc = ll_crypto_blkcipher_setkey(tfm, key, min); + rc = crypto_blkcipher_setkey(tfm, key, min); if (rc) { CERROR("failed to setting key for aes\n"); GOTO(out, rc); @@ -361,16 +380,14 @@ int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) desc.tfm = tfm; desc.info = NULL; desc.flags = 0; - rc = ll_crypto_blkcipher_decrypt(&desc, &sd, &ss, 16); + rc = crypto_blkcipher_decrypt(&desc, &sd, &ss, 16); if (rc) { CERROR("failed to decrypt for aes\n"); GOTO(out, rc); } - EXIT; - out: - ll_crypto_free_blkcipher(tfm); + crypto_free_blkcipher(tfm); return rc; } EXPORT_SYMBOL(capa_decrypt_id); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 75c9be8875e..42697934155 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -106,7 +106,6 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) LINVRNT(cl_io_type_is_valid(io->ci_type)); LINVRNT(cl_io_invariant(io)); - ENTRY; while (!list_empty(&io->ci_layers)) { slice = container_of(io->ci_layers.prev, struct cl_io_slice, @@ -144,7 +143,6 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) default: LBUG(); } - EXIT; } EXPORT_SYMBOL(cl_io_fini); @@ -157,7 +155,6 @@ static int cl_io_init0(const struct lu_env *env, struct cl_io *io, LINVRNT(io->ci_state == CIS_ZERO || io->ci_state == CIS_FINI); LINVRNT(cl_io_type_is_valid(iot)); LINVRNT(cl_io_invariant(io)); - ENTRY; io->ci_type = iot; INIT_LIST_HEAD(&io->ci_lockset.cls_todo); @@ -175,7 +172,7 @@ static int cl_io_init0(const struct lu_env *env, struct cl_io *io, } if (result == 0) io->ci_state = CIS_INIT; - RETURN(result); + return result; } /** @@ -228,7 +225,6 @@ int cl_io_rw_init(const struct lu_env *env, struct cl_io *io, { LINVRNT(iot == CIT_READ || iot == CIT_WRITE); LINVRNT(io->ci_obj != NULL); - ENTRY; LU_OBJECT_HEADER(D_VFSTRACE, env, &io->ci_obj->co_lu, "io range: %u ["LPU64", "LPU64") %u %u\n", @@ -236,7 +232,7 @@ int cl_io_rw_init(const struct lu_env *env, struct cl_io *io, io->u.ci_rw.crw_nonblock, io->u.ci_wr.wr_append); io->u.ci_rw.crw_pos = pos; io->u.ci_rw.crw_count = count; - RETURN(cl_io_init(env, io, iot, io->ci_obj)); + return cl_io_init(env, io, iot, io->ci_obj); } EXPORT_SYMBOL(cl_io_rw_init); @@ -288,7 +284,6 @@ static void cl_io_locks_sort(struct cl_io *io) { int done = 0; - ENTRY; /* hidden treasure: bubble sort for now. */ do { struct cl_io_lock_link *curr; @@ -325,7 +320,6 @@ static void cl_io_locks_sort(struct cl_io *io) prev = curr; } } while (!done); - EXIT; } /** @@ -339,12 +333,11 @@ int cl_queue_match(const struct list_head *queue, { struct cl_io_lock_link *scan; - ENTRY; list_for_each_entry(scan, queue, cill_linkage) { if (cl_lock_descr_match(&scan->cill_descr, need)) - RETURN(+1); + return +1; } - RETURN(0); + return 0; } EXPORT_SYMBOL(cl_queue_match); @@ -353,7 +346,6 @@ static int cl_queue_merge(const struct list_head *queue, { struct cl_io_lock_link *scan; - ENTRY; list_for_each_entry(scan, queue, cill_linkage) { if (cl_lock_descr_cmp(&scan->cill_descr, need)) continue; @@ -361,9 +353,9 @@ static int cl_queue_merge(const struct list_head *queue, CDEBUG(D_VFSTRACE, "lock: %d: [%lu, %lu]\n", scan->cill_descr.cld_mode, scan->cill_descr.cld_start, scan->cill_descr.cld_end); - RETURN(+1); + return +1; } - RETURN(0); + return 0; } @@ -388,8 +380,6 @@ static int cl_lockset_lock_one(const struct lu_env *env, struct cl_lock *lock; int result; - ENTRY; - lock = cl_lock_request(env, io, &link->cill_descr, "io", io); if (!IS_ERR(lock)) { @@ -404,7 +394,7 @@ static int cl_lockset_lock_one(const struct lu_env *env, result = 0; } else result = PTR_ERR(lock); - RETURN(result); + return result; } static void cl_lock_link_fini(const struct lu_env *env, struct cl_io *io, @@ -412,7 +402,6 @@ static void cl_lock_link_fini(const struct lu_env *env, struct cl_io *io, { struct cl_lock *lock = link->cill_lock; - ENTRY; list_del_init(&link->cill_linkage); if (lock != NULL) { cl_lock_release(env, lock, "io", io); @@ -420,7 +409,6 @@ static void cl_lock_link_fini(const struct lu_env *env, struct cl_io *io, } if (link->cill_fini != NULL) link->cill_fini(env, link); - EXIT; } static int cl_lockset_lock(const struct lu_env *env, struct cl_io *io, @@ -431,7 +419,6 @@ static int cl_lockset_lock(const struct lu_env *env, struct cl_io *io, struct cl_lock *lock; int result; - ENTRY; result = 0; list_for_each_entry_safe(link, temp, &set->cls_todo, cill_linkage) { if (!cl_lockset_match(set, &link->cill_descr)) { @@ -455,7 +442,7 @@ static int cl_lockset_lock(const struct lu_env *env, struct cl_io *io, break; } } - RETURN(result); + return result; } /** @@ -474,7 +461,6 @@ int cl_io_lock(const struct lu_env *env, struct cl_io *io) LINVRNT(io->ci_state == CIS_IT_STARTED); LINVRNT(cl_io_invariant(io)); - ENTRY; cl_io_for_each(scan, io) { if (scan->cis_iop->op[io->ci_type].cio_lock == NULL) continue; @@ -490,7 +476,7 @@ int cl_io_lock(const struct lu_env *env, struct cl_io *io) cl_io_unlock(env, io); else io->ci_state = CIS_LOCKED; - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_lock); @@ -508,7 +494,6 @@ void cl_io_unlock(const struct lu_env *env, struct cl_io *io) LASSERT(CIS_IT_STARTED <= io->ci_state && io->ci_state < CIS_UNLOCKED); LINVRNT(cl_io_invariant(io)); - ENTRY; set = &io->ci_lockset; list_for_each_entry_safe(link, temp, &set->cls_todo, cill_linkage) @@ -527,7 +512,6 @@ void cl_io_unlock(const struct lu_env *env, struct cl_io *io) } io->ci_state = CIS_UNLOCKED; LASSERT(!cl_env_info(env)->clt_counters[CNL_TOP].ctc_nr_locks_acquired); - EXIT; } EXPORT_SYMBOL(cl_io_unlock); @@ -547,7 +531,6 @@ int cl_io_iter_init(const struct lu_env *env, struct cl_io *io) LINVRNT(io->ci_state == CIS_INIT || io->ci_state == CIS_IT_ENDED); LINVRNT(cl_io_invariant(io)); - ENTRY; result = 0; cl_io_for_each(scan, io) { if (scan->cis_iop->op[io->ci_type].cio_iter_init == NULL) @@ -559,7 +542,7 @@ int cl_io_iter_init(const struct lu_env *env, struct cl_io *io) } if (result == 0) io->ci_state = CIS_IT_STARTED; - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_iter_init); @@ -576,13 +559,11 @@ void cl_io_iter_fini(const struct lu_env *env, struct cl_io *io) LINVRNT(io->ci_state == CIS_UNLOCKED); LINVRNT(cl_io_invariant(io)); - ENTRY; cl_io_for_each_reverse(scan, io) { if (scan->cis_iop->op[io->ci_type].cio_iter_fini != NULL) scan->cis_iop->op[io->ci_type].cio_iter_fini(env, scan); } io->ci_state = CIS_IT_ENDED; - EXIT; } EXPORT_SYMBOL(cl_io_iter_fini); @@ -598,8 +579,6 @@ void cl_io_rw_advance(const struct lu_env *env, struct cl_io *io, size_t nob) LINVRNT(cl_io_is_loopable(io)); LINVRNT(cl_io_invariant(io)); - ENTRY; - io->u.ci_rw.crw_pos += nob; io->u.ci_rw.crw_count -= nob; @@ -609,7 +588,6 @@ void cl_io_rw_advance(const struct lu_env *env, struct cl_io *io, size_t nob) scan->cis_iop->op[io->ci_type].cio_advance(env, scan, nob); } - EXIT; } EXPORT_SYMBOL(cl_io_rw_advance); @@ -621,14 +599,13 @@ int cl_io_lock_add(const struct lu_env *env, struct cl_io *io, { int result; - ENTRY; if (cl_lockset_merge(&io->ci_lockset, &link->cill_descr)) result = +1; else { list_add(&link->cill_linkage, &io->ci_lockset.cls_todo); result = 0; } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_lock_add); @@ -647,7 +624,6 @@ int cl_io_lock_alloc_add(const struct lu_env *env, struct cl_io *io, struct cl_io_lock_link *link; int result; - ENTRY; OBD_ALLOC_PTR(link); if (link != NULL) { link->cill_descr = *descr; @@ -658,7 +634,7 @@ int cl_io_lock_alloc_add(const struct lu_env *env, struct cl_io *io, } else result = -ENOMEM; - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_lock_alloc_add); @@ -673,7 +649,6 @@ int cl_io_start(const struct lu_env *env, struct cl_io *io) LINVRNT(cl_io_is_loopable(io)); LINVRNT(io->ci_state == CIS_LOCKED); LINVRNT(cl_io_invariant(io)); - ENTRY; io->ci_state = CIS_IO_GOING; cl_io_for_each(scan, io) { @@ -685,7 +660,7 @@ int cl_io_start(const struct lu_env *env, struct cl_io *io) } if (result >= 0) result = 0; - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_start); @@ -700,7 +675,6 @@ void cl_io_end(const struct lu_env *env, struct cl_io *io) LINVRNT(cl_io_is_loopable(io)); LINVRNT(io->ci_state == CIS_IO_GOING); LINVRNT(cl_io_invariant(io)); - ENTRY; cl_io_for_each_reverse(scan, io) { if (scan->cis_iop->op[io->ci_type].cio_end != NULL) @@ -708,7 +682,6 @@ void cl_io_end(const struct lu_env *env, struct cl_io *io) /* TODO: error handling. */ } io->ci_state = CIS_IO_FINISHED; - EXIT; } EXPORT_SYMBOL(cl_io_end); @@ -774,7 +747,6 @@ int cl_io_read_page(const struct lu_env *env, struct cl_io *io, LINVRNT(io->ci_state == CIS_IO_GOING || io->ci_state == CIS_LOCKED); LINVRNT(cl_page_in_io(page, io)); LINVRNT(cl_io_invariant(io)); - ENTRY; queue = &io->ci_queue; @@ -807,7 +779,7 @@ int cl_io_read_page(const struct lu_env *env, struct cl_io *io, */ cl_page_list_disown(env, io, &queue->c2_qin); cl_2queue_fini(env, queue); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_read_page); @@ -827,7 +799,6 @@ int cl_io_prepare_write(const struct lu_env *env, struct cl_io *io, LINVRNT(io->ci_state == CIS_IO_GOING || io->ci_state == CIS_LOCKED); LINVRNT(cl_io_invariant(io)); LASSERT(cl_page_in_io(page, io)); - ENTRY; cl_io_for_each_reverse(scan, io) { if (scan->cis_iop->cio_prepare_write != NULL) { @@ -841,7 +812,7 @@ int cl_io_prepare_write(const struct lu_env *env, struct cl_io *io, break; } } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_prepare_write); @@ -867,7 +838,6 @@ int cl_io_commit_write(const struct lu_env *env, struct cl_io *io, */ LASSERT(cl_page_is_owned(page, io) || page->cp_parent != NULL); LASSERT(cl_page_in_io(page, io)); - ENTRY; cl_io_for_each(scan, io) { if (scan->cis_iop->cio_commit_write != NULL) { @@ -882,7 +852,7 @@ int cl_io_commit_write(const struct lu_env *env, struct cl_io *io, } } LINVRNT(result <= 0); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_commit_write); @@ -903,7 +873,6 @@ int cl_io_submit_rw(const struct lu_env *env, struct cl_io *io, int result = 0; LINVRNT(crt < ARRAY_SIZE(scan->cis_iop->req_op)); - ENTRY; cl_io_for_each(scan, io) { if (scan->cis_iop->req_op[crt].cio_submit == NULL) @@ -917,7 +886,7 @@ int cl_io_submit_rw(const struct lu_env *env, struct cl_io *io, * If ->cio_submit() failed, no pages were sent. */ LASSERT(ergo(result != 0, list_empty(&queue->c2_qout.pl_pages))); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_submit_rw); @@ -1009,7 +978,6 @@ int cl_io_loop(const struct lu_env *env, struct cl_io *io) int result = 0; LINVRNT(cl_io_is_loopable(io)); - ENTRY; do { size_t nob; @@ -1043,7 +1011,7 @@ int cl_io_loop(const struct lu_env *env, struct cl_io *io) } while (result == 0 && io->ci_continue); if (result == 0) result = io->ci_result; - RETURN(result < 0 ? result : 0); + return result < 0 ? result : 0; } EXPORT_SYMBOL(cl_io_loop); @@ -1064,13 +1032,11 @@ void cl_io_slice_add(struct cl_io *io, struct cl_io_slice *slice, LASSERT((linkage->prev == NULL && linkage->next == NULL) || list_empty(linkage)); - ENTRY; list_add_tail(linkage, &io->ci_layers); slice->cis_io = io; slice->cis_obj = obj; slice->cis_iop = ops; - EXIT; } EXPORT_SYMBOL(cl_io_slice_add); @@ -1080,11 +1046,9 @@ EXPORT_SYMBOL(cl_io_slice_add); */ void cl_page_list_init(struct cl_page_list *plist) { - ENTRY; plist->pl_nr = 0; INIT_LIST_HEAD(&plist->pl_pages); plist->pl_owner = current; - EXIT; } EXPORT_SYMBOL(cl_page_list_init); @@ -1093,7 +1057,6 @@ EXPORT_SYMBOL(cl_page_list_init); */ void cl_page_list_add(struct cl_page_list *plist, struct cl_page *page) { - ENTRY; /* it would be better to check that page is owned by "current" io, but * it is not passed here. */ LASSERT(page->cp_owner != NULL); @@ -1105,9 +1068,8 @@ void cl_page_list_add(struct cl_page_list *plist, struct cl_page *page) LASSERT(list_empty(&page->cp_batch)); list_add_tail(&page->cp_batch, &plist->pl_pages); ++plist->pl_nr; - page->cp_queue_ref = lu_ref_add(&page->cp_reference, "queue", plist); + lu_ref_add_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist); cl_page_get(page); - EXIT; } EXPORT_SYMBOL(cl_page_list_add); @@ -1120,15 +1082,13 @@ void cl_page_list_del(const struct lu_env *env, LASSERT(plist->pl_nr > 0); LINVRNT(plist->pl_owner == current); - ENTRY; list_del_init(&page->cp_batch); lockdep_off(); mutex_unlock(&page->cp_mutex); lockdep_on(); --plist->pl_nr; - lu_ref_del_at(&page->cp_reference, page->cp_queue_ref, "queue", plist); + lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist); cl_page_put(env, page); - EXIT; } EXPORT_SYMBOL(cl_page_list_del); @@ -1142,13 +1102,11 @@ void cl_page_list_move(struct cl_page_list *dst, struct cl_page_list *src, LINVRNT(dst->pl_owner == current); LINVRNT(src->pl_owner == current); - ENTRY; list_move_tail(&page->cp_batch, &dst->pl_pages); --src->pl_nr; ++dst->pl_nr; - lu_ref_set_at(&page->cp_reference, - page->cp_queue_ref, "queue", src, dst); - EXIT; + lu_ref_set_at(&page->cp_reference, &page->cp_queue_ref, "queue", + src, dst); } EXPORT_SYMBOL(cl_page_list_move); @@ -1163,10 +1121,8 @@ void cl_page_list_splice(struct cl_page_list *list, struct cl_page_list *head) LINVRNT(list->pl_owner == current); LINVRNT(head->pl_owner == current); - ENTRY; cl_page_list_for_each_safe(page, tmp, list) cl_page_list_move(head, list, page); - EXIT; } EXPORT_SYMBOL(cl_page_list_splice); @@ -1184,7 +1140,6 @@ void cl_page_list_disown(const struct lu_env *env, LINVRNT(plist->pl_owner == current); - ENTRY; cl_page_list_for_each_safe(page, temp, plist) { LASSERT(plist->pl_nr > 0); @@ -1202,10 +1157,10 @@ void cl_page_list_disown(const struct lu_env *env, * XXX cl_page_disown0() will fail if page is not locked. */ cl_page_disown0(env, io, page); - lu_ref_del(&page->cp_reference, "queue", plist); + lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", + plist); cl_page_put(env, page); } - EXIT; } EXPORT_SYMBOL(cl_page_list_disown); @@ -1219,11 +1174,9 @@ void cl_page_list_fini(const struct lu_env *env, struct cl_page_list *plist) LINVRNT(plist->pl_owner == current); - ENTRY; cl_page_list_for_each_safe(page, temp, plist) cl_page_list_del(env, plist, page); LASSERT(plist->pl_nr == 0); - EXIT; } EXPORT_SYMBOL(cl_page_list_fini); @@ -1240,7 +1193,6 @@ int cl_page_list_own(const struct lu_env *env, LINVRNT(plist->pl_owner == current); - ENTRY; result = 0; cl_page_list_for_each_safe(page, temp, plist) { LASSERT(index <= page->cp_index); @@ -1250,7 +1202,7 @@ int cl_page_list_own(const struct lu_env *env, else cl_page_list_del(env, plist, page); } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_page_list_own); @@ -1278,10 +1230,8 @@ void cl_page_list_discard(const struct lu_env *env, struct cl_io *io, struct cl_page *page; LINVRNT(plist->pl_owner == current); - ENTRY; cl_page_list_for_each(page, plist) cl_page_discard(env, io, page); - EXIT; } EXPORT_SYMBOL(cl_page_list_discard); @@ -1295,14 +1245,13 @@ int cl_page_list_unmap(const struct lu_env *env, struct cl_io *io, int result; LINVRNT(plist->pl_owner == current); - ENTRY; result = 0; cl_page_list_for_each(page, plist) { result = cl_page_unmap(env, io, page); if (result != 0) break; } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_page_list_unmap); @@ -1311,10 +1260,8 @@ EXPORT_SYMBOL(cl_page_list_unmap); */ void cl_2queue_init(struct cl_2queue *queue) { - ENTRY; cl_page_list_init(&queue->c2_qin); cl_page_list_init(&queue->c2_qout); - EXIT; } EXPORT_SYMBOL(cl_2queue_init); @@ -1323,9 +1270,7 @@ EXPORT_SYMBOL(cl_2queue_init); */ void cl_2queue_add(struct cl_2queue *queue, struct cl_page *page) { - ENTRY; cl_page_list_add(&queue->c2_qin, page); - EXIT; } EXPORT_SYMBOL(cl_2queue_add); @@ -1335,10 +1280,8 @@ EXPORT_SYMBOL(cl_2queue_add); void cl_2queue_disown(const struct lu_env *env, struct cl_io *io, struct cl_2queue *queue) { - ENTRY; cl_page_list_disown(env, io, &queue->c2_qin); cl_page_list_disown(env, io, &queue->c2_qout); - EXIT; } EXPORT_SYMBOL(cl_2queue_disown); @@ -1348,10 +1291,8 @@ EXPORT_SYMBOL(cl_2queue_disown); void cl_2queue_discard(const struct lu_env *env, struct cl_io *io, struct cl_2queue *queue) { - ENTRY; cl_page_list_discard(env, io, &queue->c2_qin); cl_page_list_discard(env, io, &queue->c2_qout); - EXIT; } EXPORT_SYMBOL(cl_2queue_discard); @@ -1371,10 +1312,8 @@ EXPORT_SYMBOL(cl_2queue_assume); */ void cl_2queue_fini(const struct lu_env *env, struct cl_2queue *queue) { - ENTRY; cl_page_list_fini(env, &queue->c2_qout); cl_page_list_fini(env, &queue->c2_qin); - EXIT; } EXPORT_SYMBOL(cl_2queue_fini); @@ -1383,10 +1322,8 @@ EXPORT_SYMBOL(cl_2queue_fini); */ void cl_2queue_init_page(struct cl_2queue *queue, struct cl_page *page) { - ENTRY; cl_2queue_init(queue); cl_2queue_add(queue, page); - EXIT; } EXPORT_SYMBOL(cl_2queue_init_page); @@ -1397,10 +1334,9 @@ EXPORT_SYMBOL(cl_2queue_init_page); */ struct cl_io *cl_io_top(struct cl_io *io) { - ENTRY; while (io->ci_parent != NULL) io = io->ci_parent; - RETURN(io); + return io; } EXPORT_SYMBOL(cl_io_top); @@ -1425,12 +1361,10 @@ void cl_req_slice_add(struct cl_req *req, struct cl_req_slice *slice, struct cl_device *dev, const struct cl_req_operations *ops) { - ENTRY; list_add_tail(&slice->crs_linkage, &req->crq_layers); slice->crs_dev = dev; slice->crs_ops = ops; slice->crs_req = req; - EXIT; } EXPORT_SYMBOL(cl_req_slice_add); @@ -1442,14 +1376,13 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req) LASSERT(req->crq_nrpages == 0); LINVRNT(list_empty(&req->crq_layers)); LINVRNT(equi(req->crq_nrobjs > 0, req->crq_o != NULL)); - ENTRY; if (req->crq_o != NULL) { for (i = 0; i < req->crq_nrobjs; ++i) { struct cl_object *obj = req->crq_o[i].ro_obj; if (obj != NULL) { lu_object_ref_del_at(&obj->co_lu, - req->crq_o[i].ro_obj_ref, + &req->crq_o[i].ro_obj_ref, "cl_req", req); cl_object_put(env, obj); } @@ -1457,7 +1390,6 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req) OBD_FREE(req->crq_o, req->crq_nrobjs * sizeof req->crq_o[0]); } OBD_FREE_PTR(req); - EXIT; } static int cl_req_init(const struct lu_env *env, struct cl_req *req, @@ -1467,7 +1399,6 @@ static int cl_req_init(const struct lu_env *env, struct cl_req *req, struct cl_page_slice *slice; int result; - ENTRY; result = 0; page = cl_page_top(page); do { @@ -1482,7 +1413,7 @@ static int cl_req_init(const struct lu_env *env, struct cl_req *req, } page = page->cp_child; } while (page != NULL && result == 0); - RETURN(result); + return result; } /** @@ -1493,7 +1424,6 @@ void cl_req_completion(const struct lu_env *env, struct cl_req *req, int rc) { struct cl_req_slice *slice; - ENTRY; /* * for the lack of list_for_each_entry_reverse_safe()... */ @@ -1505,7 +1435,6 @@ void cl_req_completion(const struct lu_env *env, struct cl_req *req, int rc) slice->crs_ops->cro_completion(env, slice, rc); } cl_req_free(env, req); - EXIT; } EXPORT_SYMBOL(cl_req_completion); @@ -1518,7 +1447,6 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, struct cl_req *req; LINVRNT(nr_objects > 0); - ENTRY; OBD_ALLOC_PTR(req); if (req != NULL) { @@ -1539,7 +1467,7 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, } } else req = ERR_PTR(-ENOMEM); - RETURN(req); + return req; } EXPORT_SYMBOL(cl_req_alloc); @@ -1553,7 +1481,6 @@ void cl_req_page_add(const struct lu_env *env, struct cl_req_obj *rqo; int i; - ENTRY; page = cl_page_top(page); LASSERT(list_empty(&page->cp_flight)); @@ -1570,13 +1497,12 @@ void cl_req_page_add(const struct lu_env *env, if (rqo->ro_obj == NULL) { rqo->ro_obj = obj; cl_object_get(obj); - rqo->ro_obj_ref = lu_object_ref_add(&obj->co_lu, - "cl_req", req); + lu_object_ref_add_at(&obj->co_lu, &rqo->ro_obj_ref, + "cl_req", req); break; } } LASSERT(i < req->crq_nrobjs); - EXIT; } EXPORT_SYMBOL(cl_req_page_add); @@ -1587,7 +1513,6 @@ void cl_req_page_done(const struct lu_env *env, struct cl_page *page) { struct cl_req *req = page->cp_req; - ENTRY; page = cl_page_top(page); LASSERT(!list_empty(&page->cp_flight)); @@ -1596,7 +1521,6 @@ void cl_req_page_done(const struct lu_env *env, struct cl_page *page) list_del_init(&page->cp_flight); --req->crq_nrpages; page->cp_req = NULL; - EXIT; } EXPORT_SYMBOL(cl_req_page_done); @@ -1610,7 +1534,6 @@ int cl_req_prep(const struct lu_env *env, struct cl_req *req) int result; const struct cl_req_slice *slice; - ENTRY; /* * Check that the caller of cl_req_alloc() didn't lie about the number * of objects. @@ -1626,7 +1549,7 @@ int cl_req_prep(const struct lu_env *env, struct cl_req *req) break; } } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_req_prep); @@ -1643,7 +1566,6 @@ void cl_req_attr_set(const struct lu_env *env, struct cl_req *req, int i; LASSERT(!list_empty(&req->crq_pages)); - ENTRY; /* Take any page to use as a model. */ page = list_entry(req->crq_pages.next, struct cl_page, cp_flight); @@ -1662,7 +1584,6 @@ void cl_req_attr_set(const struct lu_env *env, struct cl_req *req, attr + i, flags); } } - EXIT; } EXPORT_SYMBOL(cl_req_attr_set); @@ -1675,12 +1596,10 @@ EXPORT_SYMBOL(cl_req_attr_set); */ void cl_sync_io_init(struct cl_sync_io *anchor, int nrpages) { - ENTRY; init_waitqueue_head(&anchor->csi_waitq); atomic_set(&anchor->csi_sync_nr, nrpages); atomic_set(&anchor->csi_barrier, nrpages > 0); anchor->csi_sync_rc = 0; - EXIT; } EXPORT_SYMBOL(cl_sync_io_init); @@ -1695,7 +1614,6 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_io *io, struct l_wait_info lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(timeout), NULL, NULL, NULL); int rc; - ENTRY; LASSERT(timeout >= 0); @@ -1725,7 +1643,7 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_io *io, } POISON(anchor, 0x5a, sizeof *anchor); - RETURN(rc); + return rc; } EXPORT_SYMBOL(cl_sync_io_wait); @@ -1734,7 +1652,6 @@ EXPORT_SYMBOL(cl_sync_io_wait); */ void cl_sync_io_note(struct cl_sync_io *anchor, int ioret) { - ENTRY; if (anchor->csi_sync_rc == 0 && ioret < 0) anchor->csi_sync_rc = ioret; /* @@ -1748,6 +1665,5 @@ void cl_sync_io_note(struct cl_sync_io *anchor, int ioret) /* it's safe to nuke or reuse anchor now */ atomic_set(&anchor->csi_barrier, 0); } - EXIT; } EXPORT_SYMBOL(cl_sync_io_note); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index d34e044fc85..749eb082f97 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -191,12 +191,10 @@ void cl_lock_slice_add(struct cl_lock *lock, struct cl_lock_slice *slice, struct cl_object *obj, const struct cl_lock_operations *ops) { - ENTRY; slice->cls_lock = lock; list_add_tail(&slice->cls_linkage, &lock->cll_layers); slice->cls_obj = obj; slice->cls_ops = ops; - EXIT; } EXPORT_SYMBOL(cl_lock_slice_add); @@ -254,7 +252,6 @@ static void cl_lock_free(const struct lu_env *env, struct cl_lock *lock) LINVRNT(!cl_lock_is_mutexed(lock)); - ENTRY; cl_lock_trace(D_DLMTRACE, env, "free lock", lock); might_sleep(); while (!list_empty(&lock->cll_layers)) { @@ -267,13 +264,12 @@ static void cl_lock_free(const struct lu_env *env, struct cl_lock *lock) } CS_LOCK_DEC(obj, total); CS_LOCKSTATE_DEC(obj, lock->cll_state); - lu_object_ref_del_at(&obj->co_lu, lock->cll_obj_ref, "cl_lock", lock); + lu_object_ref_del_at(&obj->co_lu, &lock->cll_obj_ref, "cl_lock", lock); cl_object_put(env, obj); lu_ref_fini(&lock->cll_reference); lu_ref_fini(&lock->cll_holders); mutex_destroy(&lock->cll_guard); OBD_SLAB_FREE_PTR(lock, cl_lock_kmem); - EXIT; } /** @@ -290,7 +286,6 @@ void cl_lock_put(const struct lu_env *env, struct cl_lock *lock) struct cl_object *obj; LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; obj = lock->cll_descr.cld_obj; LINVRNT(obj != NULL); @@ -304,7 +299,6 @@ void cl_lock_put(const struct lu_env *env, struct cl_lock *lock) } CS_LOCK_DEC(obj, busy); } - EXIT; } EXPORT_SYMBOL(cl_lock_put); @@ -366,15 +360,14 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env, struct cl_lock *lock; struct lu_object_header *head; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lock, cl_lock_kmem, __GFP_IO); if (lock != NULL) { atomic_set(&lock->cll_ref, 1); lock->cll_descr = *descr; lock->cll_state = CLS_NEW; cl_object_get(obj); - lock->cll_obj_ref = lu_object_ref_add(&obj->co_lu, - "cl_lock", lock); + lu_object_ref_add_at(&obj->co_lu, &lock->cll_obj_ref, "cl_lock", + lock); INIT_LIST_HEAD(&lock->cll_layers); INIT_LIST_HEAD(&lock->cll_linkage); INIT_LIST_HEAD(&lock->cll_inclosure); @@ -401,7 +394,7 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env, } } else lock = ERR_PTR(-ENOMEM); - RETURN(lock); + return lock; } /** @@ -468,13 +461,12 @@ static int cl_lock_fits_into(const struct lu_env *env, const struct cl_lock_slice *slice; LINVRNT(cl_lock_invariant_trusted(env, lock)); - ENTRY; list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { if (slice->cls_ops->clo_fits_into != NULL && !slice->cls_ops->clo_fits_into(env, slice, need, io)) - RETURN(0); + return 0; } - RETURN(1); + return 1; } static struct cl_lock *cl_lock_lookup(const struct lu_env *env, @@ -485,8 +477,6 @@ static struct cl_lock *cl_lock_lookup(const struct lu_env *env, struct cl_lock *lock; struct cl_object_header *head; - ENTRY; - head = cl_object_header(obj); LINVRNT(spin_is_locked(&head->coh_lock_guard)); CS_LOCK_INC(obj, lookup); @@ -504,10 +494,10 @@ static struct cl_lock *cl_lock_lookup(const struct lu_env *env, if (matched) { cl_lock_get_trust(lock); CS_LOCK_INC(obj, hit); - RETURN(lock); + return lock; } } - RETURN(NULL); + return NULL; } /** @@ -528,8 +518,6 @@ static struct cl_lock *cl_lock_find(const struct lu_env *env, struct cl_object *obj; struct cl_lock *lock; - ENTRY; - obj = need->cld_obj; head = cl_object_header(obj); @@ -561,7 +549,7 @@ static struct cl_lock *cl_lock_find(const struct lu_env *env, } } } - RETURN(lock); + return lock; } /** @@ -630,13 +618,12 @@ const struct cl_lock_slice *cl_lock_at(const struct cl_lock *lock, const struct cl_lock_slice *slice; LINVRNT(cl_lock_invariant_trusted(NULL, lock)); - ENTRY; list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { if (slice->cls_obj->co_lu.lo_dev->ld_type == dtype) - RETURN(slice); + return slice; } - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(cl_lock_at); @@ -705,7 +692,6 @@ int cl_lock_mutex_try(const struct lu_env *env, struct cl_lock *lock) int result; LINVRNT(cl_lock_invariant_trusted(env, lock)); - ENTRY; result = 0; if (lock->cll_guarder == current) { @@ -717,7 +703,7 @@ int cl_lock_mutex_try(const struct lu_env *env, struct cl_lock *lock) cl_lock_mutex_tail(env, lock); } else result = -EBUSY; - RETURN(result); + return result; } EXPORT_SYMBOL(cl_lock_mutex_try); @@ -784,7 +770,6 @@ static void cl_lock_cancel0(const struct lu_env *env, struct cl_lock *lock) { LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; if (!(lock->cll_flags & CLF_CANCELLED)) { const struct cl_lock_slice *slice; @@ -795,7 +780,6 @@ static void cl_lock_cancel0(const struct lu_env *env, struct cl_lock *lock) slice->cls_ops->clo_cancel(env, slice); } } - EXIT; } static void cl_lock_delete0(const struct lu_env *env, struct cl_lock *lock) @@ -806,7 +790,6 @@ static void cl_lock_delete0(const struct lu_env *env, struct cl_lock *lock) LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; if (lock->cll_state < CLS_FREEING) { LASSERT(lock->cll_state != CLS_INTRANSIT); cl_lock_state_set(env, lock, CLS_FREEING); @@ -836,7 +819,6 @@ static void cl_lock_delete0(const struct lu_env *env, struct cl_lock *lock) * existing references goes away. */ } - EXIT; } /** @@ -886,7 +868,6 @@ void cl_lock_hold_release(const struct lu_env *env, struct cl_lock *lock, LINVRNT(cl_lock_invariant(env, lock)); LASSERT(lock->cll_holds > 0); - ENTRY; cl_lock_trace(D_DLMTRACE, env, "hold release lock", lock); lu_ref_del(&lock->cll_holders, scope, source); cl_lock_hold_mod(env, lock, -1); @@ -910,7 +891,6 @@ void cl_lock_hold_release(const struct lu_env *env, struct cl_lock *lock, cl_lock_delete0(env, lock); } } - EXIT; } EXPORT_SYMBOL(cl_lock_hold_release); @@ -939,7 +919,6 @@ int cl_lock_state_wait(const struct lu_env *env, struct cl_lock *lock) sigset_t blocked; int result; - ENTRY; LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); LASSERT(lock->cll_depth == 1); @@ -976,7 +955,7 @@ int cl_lock_state_wait(const struct lu_env *env, struct cl_lock *lock) /* Restore old blocked signals */ cfs_restore_sigs(blocked); } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_lock_state_wait); @@ -985,7 +964,6 @@ static void cl_lock_state_signal(const struct lu_env *env, struct cl_lock *lock, { const struct cl_lock_slice *slice; - ENTRY; LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); @@ -993,7 +971,6 @@ static void cl_lock_state_signal(const struct lu_env *env, struct cl_lock *lock, if (slice->cls_ops->clo_state != NULL) slice->cls_ops->clo_state(env, slice, state); wake_up_all(&lock->cll_wq); - EXIT; } /** @@ -1005,10 +982,8 @@ static void cl_lock_state_signal(const struct lu_env *env, struct cl_lock *lock, */ void cl_lock_signal(const struct lu_env *env, struct cl_lock *lock) { - ENTRY; cl_lock_trace(D_DLMTRACE, env, "state signal lock", lock); cl_lock_state_signal(env, lock, lock->cll_state); - EXIT; } EXPORT_SYMBOL(cl_lock_signal); @@ -1025,7 +1000,6 @@ EXPORT_SYMBOL(cl_lock_signal); void cl_lock_state_set(const struct lu_env *env, struct cl_lock *lock, enum cl_lock_state state) { - ENTRY; LASSERT(lock->cll_state <= state || (lock->cll_state == CLS_CACHED && (state == CLS_HELD || /* lock found in cache */ @@ -1041,7 +1015,6 @@ void cl_lock_state_set(const struct lu_env *env, struct cl_lock *lock, cl_lock_state_signal(env, lock, state); lock->cll_state = state; } - EXIT; } EXPORT_SYMBOL(cl_lock_state_set); @@ -1084,12 +1057,11 @@ int cl_use_try(const struct lu_env *env, struct cl_lock *lock, int atomic) int result; enum cl_lock_state state; - ENTRY; cl_lock_trace(D_DLMTRACE, env, "use lock", lock); LASSERT(lock->cll_state == CLS_CACHED); if (lock->cll_error) - RETURN(lock->cll_error); + return lock->cll_error; result = -ENOSYS; state = cl_lock_intransit(env, lock); @@ -1129,7 +1101,7 @@ int cl_use_try(const struct lu_env *env, struct cl_lock *lock, int atomic) } cl_lock_extransit(env, lock, state); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_use_try); @@ -1144,7 +1116,6 @@ static int cl_enqueue_kick(const struct lu_env *env, int result; const struct cl_lock_slice *slice; - ENTRY; result = -ENOSYS; list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { if (slice->cls_ops->clo_enqueue != NULL) { @@ -1155,7 +1126,7 @@ static int cl_enqueue_kick(const struct lu_env *env, } } LASSERT(result != -ENOSYS); - RETURN(result); + return result; } /** @@ -1176,7 +1147,6 @@ int cl_enqueue_try(const struct lu_env *env, struct cl_lock *lock, { int result; - ENTRY; cl_lock_trace(D_DLMTRACE, env, "enqueue lock", lock); do { LINVRNT(cl_lock_is_mutexed(lock)); @@ -1219,7 +1189,7 @@ int cl_enqueue_try(const struct lu_env *env, struct cl_lock *lock, LBUG(); } } while (result == CLO_REPEAT); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_enqueue_try); @@ -1235,7 +1205,6 @@ int cl_lock_enqueue_wait(const struct lu_env *env, { struct cl_lock *conflict; int rc = 0; - ENTRY; LASSERT(cl_lock_is_mutexed(lock)); LASSERT(lock->cll_state == CLS_QUEUING); @@ -1265,7 +1234,7 @@ int cl_lock_enqueue_wait(const struct lu_env *env, cl_lock_mutex_get(env, lock); LASSERT(rc <= 0); - RETURN(rc); + return rc; } EXPORT_SYMBOL(cl_lock_enqueue_wait); @@ -1274,8 +1243,6 @@ static int cl_enqueue_locked(const struct lu_env *env, struct cl_lock *lock, { int result; - ENTRY; - LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); LASSERT(lock->cll_holds > 0); @@ -1298,7 +1265,7 @@ static int cl_enqueue_locked(const struct lu_env *env, struct cl_lock *lock, LASSERT(ergo(result == 0 && !(enqflags & CEF_AGL), lock->cll_state == CLS_ENQUEUED || lock->cll_state == CLS_HELD)); - RETURN(result); + return result; } /** @@ -1315,8 +1282,6 @@ int cl_enqueue(const struct lu_env *env, struct cl_lock *lock, { int result; - ENTRY; - cl_lock_lockdep_acquire(env, lock, enqflags); cl_lock_mutex_get(env, lock); result = cl_enqueue_locked(env, lock, io, enqflags); @@ -1325,7 +1290,7 @@ int cl_enqueue(const struct lu_env *env, struct cl_lock *lock, cl_lock_lockdep_release(env, lock); LASSERT(ergo(result == 0, lock->cll_state == CLS_ENQUEUED || lock->cll_state == CLS_HELD)); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_enqueue); @@ -1346,19 +1311,18 @@ int cl_unuse_try(const struct lu_env *env, struct cl_lock *lock) int result; enum cl_lock_state state = CLS_NEW; - ENTRY; cl_lock_trace(D_DLMTRACE, env, "unuse lock", lock); if (lock->cll_users > 1) { cl_lock_user_del(env, lock); - RETURN(0); + return 0; } /* Only if the lock is in CLS_HELD or CLS_ENQUEUED state, it can hold * underlying resources. */ if (!(lock->cll_state == CLS_HELD || lock->cll_state == CLS_ENQUEUED)) { cl_lock_user_del(env, lock); - RETURN(0); + return 0; } /* @@ -1404,20 +1368,17 @@ int cl_unuse_try(const struct lu_env *env, struct cl_lock *lock) state = CLS_NEW; cl_lock_extransit(env, lock, state); } - RETURN(result ?: lock->cll_error); + return result ?: lock->cll_error; } EXPORT_SYMBOL(cl_unuse_try); static void cl_unuse_locked(const struct lu_env *env, struct cl_lock *lock) { int result; - ENTRY; result = cl_unuse_try(env, lock); if (result) CL_LOCK_DEBUG(D_ERROR, env, lock, "unuse return %d\n", result); - - EXIT; } /** @@ -1425,12 +1386,10 @@ static void cl_unuse_locked(const struct lu_env *env, struct cl_lock *lock) */ void cl_unuse(const struct lu_env *env, struct cl_lock *lock) { - ENTRY; cl_lock_mutex_get(env, lock); cl_unuse_locked(env, lock); cl_lock_mutex_put(env, lock); cl_lock_lockdep_release(env, lock); - EXIT; } EXPORT_SYMBOL(cl_unuse); @@ -1449,7 +1408,6 @@ int cl_wait_try(const struct lu_env *env, struct cl_lock *lock) const struct cl_lock_slice *slice; int result; - ENTRY; cl_lock_trace(D_DLMTRACE, env, "wait lock try", lock); do { LINVRNT(cl_lock_is_mutexed(lock)); @@ -1489,7 +1447,7 @@ int cl_wait_try(const struct lu_env *env, struct cl_lock *lock) cl_lock_state_set(env, lock, CLS_HELD); } } while (result == CLO_REPEAT); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_wait_try); @@ -1506,7 +1464,6 @@ int cl_wait(const struct lu_env *env, struct cl_lock *lock) { int result; - ENTRY; cl_lock_mutex_get(env, lock); LINVRNT(cl_lock_invariant(env, lock)); @@ -1530,7 +1487,7 @@ int cl_wait(const struct lu_env *env, struct cl_lock *lock) cl_lock_trace(D_DLMTRACE, env, "wait lock", lock); cl_lock_mutex_put(env, lock); LASSERT(ergo(result == 0, lock->cll_state == CLS_HELD)); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_wait); @@ -1544,7 +1501,6 @@ unsigned long cl_lock_weigh(const struct lu_env *env, struct cl_lock *lock) unsigned long pound; unsigned long ounce; - ENTRY; LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); @@ -1557,7 +1513,7 @@ unsigned long cl_lock_weigh(const struct lu_env *env, struct cl_lock *lock) pound = ~0UL; } } - RETURN(pound); + return pound; } EXPORT_SYMBOL(cl_lock_weigh); @@ -1579,7 +1535,6 @@ int cl_lock_modify(const struct lu_env *env, struct cl_lock *lock, struct cl_object_header *hdr = cl_object_header(obj); int result; - ENTRY; cl_lock_trace(D_DLMTRACE, env, "modify lock", lock); /* don't allow object to change */ LASSERT(obj == desc->cld_obj); @@ -1590,7 +1545,7 @@ int cl_lock_modify(const struct lu_env *env, struct cl_lock *lock, if (slice->cls_ops->clo_modify != NULL) { result = slice->cls_ops->clo_modify(env, slice, desc); if (result != 0) - RETURN(result); + return result; } } CL_LOCK_DEBUG(D_DLMTRACE, env, lock, " -> "DDESCR"@"DFID"\n", @@ -1603,7 +1558,7 @@ int cl_lock_modify(const struct lu_env *env, struct cl_lock *lock, spin_lock(&hdr->coh_lock_guard); lock->cll_descr = *desc; spin_unlock(&hdr->coh_lock_guard); - RETURN(0); + return 0; } EXPORT_SYMBOL(cl_lock_modify); @@ -1642,7 +1597,6 @@ int cl_lock_closure_build(const struct lu_env *env, struct cl_lock *lock, const struct cl_lock_slice *slice; int result; - ENTRY; LINVRNT(cl_lock_is_mutexed(closure->clc_origin)); LINVRNT(cl_lock_invariant(env, closure->clc_origin)); @@ -1659,7 +1613,7 @@ int cl_lock_closure_build(const struct lu_env *env, struct cl_lock *lock, } if (result != 0) cl_lock_disclosure(env, closure); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_lock_closure_build); @@ -1674,7 +1628,7 @@ int cl_lock_enclosure(const struct lu_env *env, struct cl_lock *lock, struct cl_lock_closure *closure) { int result = 0; - ENTRY; + cl_lock_trace(D_DLMTRACE, env, "enclosure lock", lock); if (!cl_lock_mutex_try(env, lock)) { /* @@ -1706,7 +1660,7 @@ int cl_lock_enclosure(const struct lu_env *env, struct cl_lock *lock, } result = CLO_REPEAT; } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_lock_enclosure); @@ -1766,13 +1720,11 @@ void cl_lock_delete(const struct lu_env *env, struct cl_lock *lock) LASSERT(ergo(cl_lock_nesting(lock) == CNL_TOP, cl_lock_nr_mutexed(env) == 1)); - ENTRY; cl_lock_trace(D_DLMTRACE, env, "delete lock", lock); if (lock->cll_holds == 0) cl_lock_delete0(env, lock); else lock->cll_flags |= CLF_DOOMED; - EXIT; } EXPORT_SYMBOL(cl_lock_delete); @@ -1791,7 +1743,6 @@ void cl_lock_error(const struct lu_env *env, struct cl_lock *lock, int error) LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; if (lock->cll_error == 0 && error != 0) { cl_lock_trace(D_DLMTRACE, env, "set lock error", lock); lock->cll_error = error; @@ -1799,7 +1750,6 @@ void cl_lock_error(const struct lu_env *env, struct cl_lock *lock, int error) cl_lock_cancel(env, lock); cl_lock_delete(env, lock); } - EXIT; } EXPORT_SYMBOL(cl_lock_error); @@ -1819,13 +1769,11 @@ void cl_lock_cancel(const struct lu_env *env, struct cl_lock *lock) LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; cl_lock_trace(D_DLMTRACE, env, "cancel lock", lock); if (lock->cll_holds == 0) cl_lock_cancel0(env, lock); else lock->cll_flags |= CLF_CANCELPEND; - EXIT; } EXPORT_SYMBOL(cl_lock_cancel); @@ -1843,8 +1791,6 @@ struct cl_lock *cl_lock_at_pgoff(const struct lu_env *env, struct cl_lock *lock; struct cl_lock_descr *need; - ENTRY; - head = cl_object_header(obj); need = &cl_env_info(env)->clt_descr; lock = NULL; @@ -1878,7 +1824,7 @@ struct cl_lock *cl_lock_at_pgoff(const struct lu_env *env, } } spin_unlock(&head->coh_lock_guard); - RETURN(lock); + return lock; } EXPORT_SYMBOL(cl_lock_at_pgoff); @@ -1979,7 +1925,6 @@ int cl_lock_discard_pages(const struct lu_env *env, struct cl_lock *lock) int result; LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; io->ci_obj = cl_object_top(descr->cld_obj); io->ci_ignore_layout = 1; @@ -2001,7 +1946,7 @@ int cl_lock_discard_pages(const struct lu_env *env, struct cl_lock *lock) } while (res != CLP_GANG_OKAY); out: cl_io_fini(env, io); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_lock_discard_pages); @@ -2018,7 +1963,6 @@ void cl_locks_prune(const struct lu_env *env, struct cl_object *obj, int cancel) struct cl_object_header *head; struct cl_lock *lock; - ENTRY; head = cl_object_header(obj); /* * If locks are destroyed without cancellation, all pages must be @@ -2059,7 +2003,6 @@ again: spin_lock(&head->coh_lock_guard); } spin_unlock(&head->coh_lock_guard); - EXIT; } EXPORT_SYMBOL(cl_locks_prune); @@ -2070,8 +2013,6 @@ static struct cl_lock *cl_lock_hold_mutex(const struct lu_env *env, { struct cl_lock *lock; - ENTRY; - while (1) { lock = cl_lock_find(env, io, need); if (IS_ERR(lock)) @@ -2087,7 +2028,7 @@ static struct cl_lock *cl_lock_hold_mutex(const struct lu_env *env, cl_lock_mutex_put(env, lock); cl_lock_put(env, lock); } - RETURN(lock); + return lock; } /** @@ -2103,12 +2044,10 @@ struct cl_lock *cl_lock_hold(const struct lu_env *env, const struct cl_io *io, { struct cl_lock *lock; - ENTRY; - lock = cl_lock_hold_mutex(env, io, need, scope, source); if (!IS_ERR(lock)) cl_lock_mutex_put(env, lock); - RETURN(lock); + return lock; } EXPORT_SYMBOL(cl_lock_hold); @@ -2124,7 +2063,6 @@ struct cl_lock *cl_lock_request(const struct lu_env *env, struct cl_io *io, int rc; __u32 enqflags = need->cld_enq_flags; - ENTRY; do { lock = cl_lock_hold_mutex(env, io, need, scope, source); if (IS_ERR(lock)) @@ -2156,7 +2094,7 @@ struct cl_lock *cl_lock_request(const struct lu_env *env, struct cl_io *io, lock = ERR_PTR(rc); } } while (rc == 0); - RETURN(lock); + return lock; } EXPORT_SYMBOL(cl_lock_request); @@ -2170,12 +2108,10 @@ void cl_lock_hold_add(const struct lu_env *env, struct cl_lock *lock, LINVRNT(cl_lock_invariant(env, lock)); LASSERT(lock->cll_state != CLS_FREEING); - ENTRY; cl_lock_hold_mod(env, lock, +1); cl_lock_get(lock); lu_ref_add(&lock->cll_holders, scope, source); lu_ref_add(&lock->cll_reference, scope, source); - EXIT; } EXPORT_SYMBOL(cl_lock_hold_add); @@ -2187,11 +2123,9 @@ void cl_lock_unhold(const struct lu_env *env, struct cl_lock *lock, const char *scope, const void *source) { LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; cl_lock_hold_release(env, lock, scope, source); lu_ref_del(&lock->cll_reference, scope, source); cl_lock_put(env, lock); - EXIT; } EXPORT_SYMBOL(cl_lock_unhold); @@ -2202,14 +2136,12 @@ void cl_lock_release(const struct lu_env *env, struct cl_lock *lock, const char *scope, const void *source) { LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; cl_lock_trace(D_DLMTRACE, env, "release lock", lock); cl_lock_mutex_get(env, lock); cl_lock_hold_release(env, lock, scope, source); cl_lock_mutex_put(env, lock); lu_ref_del(&lock->cll_reference, scope, source); cl_lock_put(env, lock); - EXIT; } EXPORT_SYMBOL(cl_lock_release); @@ -2218,9 +2150,7 @@ void cl_lock_user_add(const struct lu_env *env, struct cl_lock *lock) LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; cl_lock_used_mod(env, lock, +1); - EXIT; } EXPORT_SYMBOL(cl_lock_user_add); @@ -2230,11 +2160,9 @@ void cl_lock_user_del(const struct lu_env *env, struct cl_lock *lock) LINVRNT(cl_lock_invariant(env, lock)); LASSERT(lock->cll_users > 0); - ENTRY; cl_lock_used_mod(env, lock, -1); if (lock->cll_users == 0) wake_up_all(&lock->cll_wq); - EXIT; } EXPORT_SYMBOL(cl_lock_user_del); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index cdb5fba0459..7b0e9d26b6c 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -79,7 +79,6 @@ int cl_object_header_init(struct cl_object_header *h) { int result; - ENTRY; result = lu_object_header_init(&h->coh_lu); if (result == 0) { spin_lock_init(&h->coh_page_guard); @@ -94,7 +93,7 @@ int cl_object_header_init(struct cl_object_header *h) INIT_LIST_HEAD(&h->coh_locks); h->coh_page_bufsize = ALIGN(sizeof(struct cl_page), 8); } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_object_header_init); @@ -222,7 +221,6 @@ int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, int result; LASSERT(spin_is_locked(cl_object_attr_guard(obj))); - ENTRY; top = obj->co_lu.lo_header; result = 0; @@ -236,7 +234,7 @@ int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, } } } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_object_attr_get); @@ -254,7 +252,6 @@ int cl_object_attr_set(const struct lu_env *env, struct cl_object *obj, int result; LASSERT(spin_is_locked(cl_object_attr_guard(obj))); - ENTRY; top = obj->co_lu.lo_header; result = 0; @@ -269,7 +266,7 @@ int cl_object_attr_set(const struct lu_env *env, struct cl_object *obj, } } } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_object_attr_set); @@ -287,7 +284,6 @@ int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, struct lu_object_header *top; int result; - ENTRY; top = obj->co_lu.lo_header; result = 0; list_for_each_entry_reverse(obj, &top->loh_layers, @@ -303,7 +299,7 @@ int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, "ctime: "LPU64" blocks: "LPU64"\n", lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_object_glimpse); @@ -316,7 +312,6 @@ int cl_conf_set(const struct lu_env *env, struct cl_object *obj, struct lu_object_header *top; int result; - ENTRY; top = obj->co_lu.lo_header; result = 0; list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { @@ -326,7 +321,7 @@ int cl_conf_set(const struct lu_env *env, struct cl_object *obj, break; } } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_conf_set); @@ -362,10 +357,8 @@ EXPORT_SYMBOL(cl_object_kill); */ void cl_object_prune(const struct lu_env *env, struct cl_object *obj) { - ENTRY; cl_pages_prune(env, obj); cl_locks_prune(env, obj, 1); - EXIT; } EXPORT_SYMBOL(cl_object_prune); @@ -941,13 +934,11 @@ EXPORT_SYMBOL(cl_env_nested_put); */ void cl_attr2lvb(struct ost_lvb *lvb, const struct cl_attr *attr) { - ENTRY; lvb->lvb_size = attr->cat_size; lvb->lvb_mtime = attr->cat_mtime; lvb->lvb_atime = attr->cat_atime; lvb->lvb_ctime = attr->cat_ctime; lvb->lvb_blocks = attr->cat_blocks; - EXIT; } EXPORT_SYMBOL(cl_attr2lvb); @@ -958,13 +949,11 @@ EXPORT_SYMBOL(cl_attr2lvb); */ void cl_lvb2attr(struct cl_attr *attr, const struct ost_lvb *lvb) { - ENTRY; attr->cat_size = lvb->lvb_size; attr->cat_mtime = lvb->lvb_mtime; attr->cat_atime = lvb->lvb_atime; attr->cat_ctime = lvb->lvb_ctime; attr->cat_blocks = lvb->lvb_blocks; - EXIT; } EXPORT_SYMBOL(cl_lvb2attr); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index bb9335911c3..2a5ce376e57 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -108,17 +108,16 @@ cl_page_at_trusted(const struct cl_page *page, const struct lu_device_type *dtype) { const struct cl_page_slice *slice; - ENTRY; page = cl_page_top_trusted((struct cl_page *)page); do { list_for_each_entry(slice, &page->cp_layers, cpl_linkage) { if (slice->cpl_obj->co_lu.lo_dev->ld_type == dtype) - RETURN(slice); + return slice; } page = page->cp_child; } while (page != NULL); - RETURN(NULL); + return NULL; } /** @@ -167,7 +166,6 @@ int cl_page_gang_lookup(const struct lu_env *env, struct cl_object *obj, unsigned int j; int res = CLP_GANG_OKAY; int tree_lock = 1; - ENTRY; idx = start; hdr = cl_object_header(obj); @@ -243,7 +241,7 @@ int cl_page_gang_lookup(const struct lu_env *env, struct cl_object *obj, } if (tree_lock) spin_unlock(&hdr->coh_page_guard); - RETURN(res); + return res; } EXPORT_SYMBOL(cl_page_gang_lookup); @@ -258,7 +256,6 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page) PASSERT(env, page, page->cp_parent == NULL); PASSERT(env, page, page->cp_state == CPS_FREEING); - ENTRY; might_sleep(); while (!list_empty(&page->cp_layers)) { struct cl_page_slice *slice; @@ -270,11 +267,10 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page) } CS_PAGE_DEC(obj, total); CS_PAGESTATE_DEC(obj, page->cp_state); - lu_object_ref_del_at(&obj->co_lu, page->cp_obj_ref, "cl_page", page); + lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page); cl_object_put(env, obj); lu_ref_fini(&page->cp_reference); OBD_FREE(page, pagesize); - EXIT; } /** @@ -295,7 +291,6 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env, struct cl_page *page; struct lu_object_header *head; - ENTRY; OBD_ALLOC_GFP(page, cl_object_header(o)->coh_page_bufsize, __GFP_IO); if (page != NULL) { @@ -305,7 +300,8 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env, atomic_inc(&page->cp_ref); page->cp_obj = o; cl_object_get(o); - page->cp_obj_ref = lu_object_ref_add(&o->co_lu, "cl_page",page); + lu_object_ref_add_at(&o->co_lu, &page->cp_obj_ref, "cl_page", + page); page->cp_index = ind; cl_page_state_set_trust(page, CPS_CACHED); page->cp_type = type; @@ -336,7 +332,7 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env, } else { page = ERR_PTR(-ENOMEM); } - RETURN(page); + return page; } /** @@ -364,8 +360,6 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, LASSERT(type == CPT_CACHEABLE || type == CPT_TRANSIENT); might_sleep(); - ENTRY; - hdr = cl_object_header(o); CS_PAGE_INC(o, lookup); @@ -395,13 +389,13 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, if (page != NULL) { CS_PAGE_INC(o, hit); - RETURN(page); + return page; } /* allocate and initialize cl_page */ page = cl_page_alloc(env, o, idx, vmpage, type); if (IS_ERR(page)) - RETURN(page); + return page; if (type == CPT_TRANSIENT) { if (parent) { @@ -409,7 +403,7 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, page->cp_parent = parent; parent->cp_child = page; } - RETURN(page); + return page; } /* @@ -450,7 +444,7 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, cl_page_delete0(env, ghost, 0); cl_page_free(env, ghost); } - RETURN(page); + return page; } struct cl_page *cl_page_find(const struct lu_env *env, struct cl_object *o, @@ -553,7 +547,6 @@ static void cl_page_state_set0(const struct lu_env *env, } }; - ENTRY; old = page->cp_state; PASSERT(env, page, allowed_transitions[old][state]); CL_PAGE_HEADER(D_TRACE, env, page, "%d -> %d\n", old, state); @@ -566,7 +559,6 @@ static void cl_page_state_set0(const struct lu_env *env, CS_PAGESTATE_INC(page->cp_obj, state); cl_page_state_set_trust(page, state); } - EXIT; } static void cl_page_state_set(const struct lu_env *env, @@ -585,9 +577,7 @@ static void cl_page_state_set(const struct lu_env *env, */ void cl_page_get(struct cl_page *page) { - ENTRY; cl_page_get_trust(page); - EXIT; } EXPORT_SYMBOL(cl_page_get); @@ -604,7 +594,6 @@ void cl_page_put(const struct lu_env *env, struct cl_page *page) { PASSERT(env, page, atomic_read(&page->cp_ref) > !!page->cp_parent); - ENTRY; CL_PAGE_HEADER(D_TRACE, env, page, "%d\n", atomic_read(&page->cp_ref)); @@ -620,8 +609,6 @@ void cl_page_put(const struct lu_env *env, struct cl_page *page) */ cl_page_free(env, page); } - - EXIT; } EXPORT_SYMBOL(cl_page_put); @@ -640,7 +627,7 @@ struct page *cl_page_vmpage(const struct lu_env *env, struct cl_page *page) do { list_for_each_entry(slice, &page->cp_layers, cpl_linkage) { if (slice->cpl_ops->cpo_vmpage != NULL) - RETURN(slice->cpl_ops->cpo_vmpage(env, slice)); + return slice->cpl_ops->cpo_vmpage(env, slice); } page = page->cp_child; } while (page != NULL); @@ -656,7 +643,6 @@ struct cl_page *cl_vmpage_page(struct page *vmpage, struct cl_object *obj) struct cl_page *top; struct cl_page *page; - ENTRY; KLASSERT(PageLocked(vmpage)); /* @@ -671,7 +657,7 @@ struct cl_page *cl_vmpage_page(struct page *vmpage, struct cl_object *obj) */ top = (struct cl_page *)vmpage->private; if (top == NULL) - RETURN(NULL); + return NULL; for (page = top; page != NULL; page = page->cp_child) { if (cl_object_same(page->cp_obj, obj)) { @@ -680,7 +666,7 @@ struct cl_page *cl_vmpage_page(struct page *vmpage, struct cl_object *obj) } } LASSERT(ergo(page, page->cp_type == CPT_CACHEABLE)); - RETURN(page); + return page; } EXPORT_SYMBOL(cl_vmpage_page); @@ -785,11 +771,10 @@ static int cl_page_invoke(const struct lu_env *env, { PINVRNT(env, page, cl_object_same(page->cp_obj, io->ci_obj)); - ENTRY; - RETURN(CL_PAGE_INVOKE(env, page, op, + return CL_PAGE_INVOKE(env, page, op, (const struct lu_env *, const struct cl_page_slice *, struct cl_io *), - io)); + io); } static void cl_page_invoid(const struct lu_env *env, @@ -797,16 +782,13 @@ static void cl_page_invoid(const struct lu_env *env, { PINVRNT(env, page, cl_object_same(page->cp_obj, io->ci_obj)); - ENTRY; CL_PAGE_INVOID(env, page, op, (const struct lu_env *, const struct cl_page_slice *, struct cl_io *), io); - EXIT; } static void cl_page_owner_clear(struct cl_page *page) { - ENTRY; for (page = cl_page_top(page); page != NULL; page = page->cp_child) { if (page->cp_owner != NULL) { LASSERT(page->cp_owner->ci_owned_nr > 0); @@ -815,17 +797,14 @@ static void cl_page_owner_clear(struct cl_page *page) page->cp_task = NULL; } } - EXIT; } static void cl_page_owner_set(struct cl_page *page) { - ENTRY; for (page = cl_page_top(page); page != NULL; page = page->cp_child) { LASSERT(page->cp_owner != NULL); page->cp_owner->ci_owned_nr++; } - EXIT; } void cl_page_disown0(const struct lu_env *env, @@ -833,7 +812,6 @@ void cl_page_disown0(const struct lu_env *env, { enum cl_page_state state; - ENTRY; state = pg->cp_state; PINVRNT(env, pg, state == CPS_OWNED || state == CPS_FREEING); PINVRNT(env, pg, cl_page_invariant(pg)); @@ -850,7 +828,6 @@ void cl_page_disown0(const struct lu_env *env, (const struct lu_env *, const struct cl_page_slice *, struct cl_io *), io); - EXIT; } /** @@ -859,8 +836,7 @@ void cl_page_disown0(const struct lu_env *env, int cl_page_is_owned(const struct cl_page *pg, const struct cl_io *io) { LINVRNT(cl_object_same(pg->cp_obj, io->ci_obj)); - ENTRY; - RETURN(pg->cp_state == CPS_OWNED && pg->cp_owner == io); + return pg->cp_state == CPS_OWNED && pg->cp_owner == io; } EXPORT_SYMBOL(cl_page_is_owned); @@ -891,7 +867,6 @@ static int cl_page_own0(const struct lu_env *env, struct cl_io *io, PINVRNT(env, pg, !cl_page_is_owned(pg, io)); - ENTRY; pg = cl_page_top(pg); io = cl_io_top(io); @@ -918,7 +893,7 @@ static int cl_page_own0(const struct lu_env *env, struct cl_io *io, } } PINVRNT(env, pg, ergo(result == 0, cl_page_invariant(pg))); - RETURN(result); + return result; } /** @@ -960,7 +935,6 @@ void cl_page_assume(const struct lu_env *env, { PINVRNT(env, pg, cl_object_same(pg->cp_obj, io->ci_obj)); - ENTRY; pg = cl_page_top(pg); io = cl_io_top(io); @@ -970,7 +944,6 @@ void cl_page_assume(const struct lu_env *env, pg->cp_task = current; cl_page_owner_set(pg); cl_page_state_set(env, pg, CPS_OWNED); - EXIT; } EXPORT_SYMBOL(cl_page_assume); @@ -991,7 +964,6 @@ void cl_page_unassume(const struct lu_env *env, PINVRNT(env, pg, cl_page_is_owned(pg, io)); PINVRNT(env, pg, cl_page_invariant(pg)); - ENTRY; pg = cl_page_top(pg); io = cl_io_top(io); cl_page_owner_clear(pg); @@ -1000,7 +972,6 @@ void cl_page_unassume(const struct lu_env *env, (const struct lu_env *, const struct cl_page_slice *, struct cl_io *), io); - EXIT; } EXPORT_SYMBOL(cl_page_unassume); @@ -1020,11 +991,9 @@ void cl_page_disown(const struct lu_env *env, { PINVRNT(env, pg, cl_page_is_owned(pg, io)); - ENTRY; pg = cl_page_top(pg); io = cl_io_top(io); cl_page_disown0(env, io, pg); - EXIT; } EXPORT_SYMBOL(cl_page_disown); @@ -1057,7 +1026,6 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg, int radix) { struct cl_page *tmp = pg; - ENTRY; PASSERT(env, pg, pg == cl_page_top(pg)); PASSERT(env, pg, pg->cp_state != CPS_FREEING); @@ -1102,8 +1070,6 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg, cl_page_put(env, tmp); } } - - EXIT; } /** @@ -1134,9 +1100,7 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg, void cl_page_delete(const struct lu_env *env, struct cl_page *pg) { PINVRNT(env, pg, cl_page_invariant(pg)); - ENTRY; cl_page_delete0(env, pg, 1); - EXIT; } EXPORT_SYMBOL(cl_page_delete); @@ -1186,7 +1150,6 @@ int cl_page_is_vmlocked(const struct lu_env *env, const struct cl_page *pg) int result; const struct cl_page_slice *slice; - ENTRY; pg = cl_page_top_trusted((struct cl_page *)pg); slice = container_of(pg->cp_layers.next, const struct cl_page_slice, cpl_linkage); @@ -1198,14 +1161,13 @@ int cl_page_is_vmlocked(const struct lu_env *env, const struct cl_page *pg) */ result = slice->cpl_ops->cpo_is_vmlocked(env, slice); PASSERT(env, pg, result == -EBUSY || result == -ENODATA); - RETURN(result == -EBUSY); + return result == -EBUSY; } EXPORT_SYMBOL(cl_page_is_vmlocked); static enum cl_page_state cl_req_type_state(enum cl_req_type crt) { - ENTRY; - RETURN(crt == CRT_WRITE ? CPS_PAGEOUT : CPS_PAGEIN); + return crt == CRT_WRITE ? CPS_PAGEOUT : CPS_PAGEIN; } static void cl_page_io_start(const struct lu_env *env, @@ -1214,10 +1176,8 @@ static void cl_page_io_start(const struct lu_env *env, /* * Page is queued for IO, change its state. */ - ENTRY; cl_page_owner_clear(pg); cl_page_state_set(env, pg, cl_req_type_state(crt)); - EXIT; } /** @@ -1280,7 +1240,6 @@ void cl_page_completion(const struct lu_env *env, PASSERT(env, pg, pg->cp_req == NULL); PASSERT(env, pg, pg->cp_state == cl_req_type_state(crt)); - ENTRY; CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, ioret); if (crt == CRT_READ && ioret == 0) { PASSERT(env, pg, !(pg->cp_flags & CPF_READ_COMPLETED)); @@ -1307,8 +1266,6 @@ void cl_page_completion(const struct lu_env *env, if (anchor) cl_sync_io_note(anchor, ioret); - - EXIT; } EXPORT_SYMBOL(cl_page_completion); @@ -1328,9 +1285,8 @@ int cl_page_make_ready(const struct lu_env *env, struct cl_page *pg, PINVRNT(env, pg, crt < CRT_NR); - ENTRY; if (crt >= CRT_NR) - RETURN(-EINVAL); + return -EINVAL; result = CL_PAGE_INVOKE(env, pg, CL_PAGE_OP(io[crt].cpo_make_ready), (const struct lu_env *, const struct cl_page_slice *)); @@ -1339,7 +1295,7 @@ int cl_page_make_ready(const struct lu_env *env, struct cl_page *pg, cl_page_io_start(env, pg, crt); } CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_page_make_ready); @@ -1365,10 +1321,8 @@ int cl_page_cache_add(const struct lu_env *env, struct cl_io *io, PINVRNT(env, pg, cl_page_is_owned(pg, io)); PINVRNT(env, pg, cl_page_invariant(pg)); - ENTRY; - if (crt >= CRT_NR) - RETURN(-EINVAL); + return -EINVAL; list_for_each_entry(scan, &pg->cp_layers, cpl_linkage) { if (scan->cpl_ops->io[crt].cpo_cache_add == NULL) @@ -1379,7 +1333,7 @@ int cl_page_cache_add(const struct lu_env *env, struct cl_io *io, break; } CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_page_cache_add); @@ -1399,12 +1353,10 @@ int cl_page_flush(const struct lu_env *env, struct cl_io *io, PINVRNT(env, pg, cl_page_is_owned(pg, io)); PINVRNT(env, pg, cl_page_invariant(pg)); - ENTRY; - result = cl_page_invoke(env, io, pg, CL_PAGE_OP(cpo_flush)); CL_PAGE_HEADER(D_TRACE, env, pg, "%d\n", result); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_page_flush); @@ -1422,13 +1374,12 @@ int cl_page_is_under_lock(const struct lu_env *env, struct cl_io *io, PINVRNT(env, page, cl_page_invariant(page)); - ENTRY; rc = CL_PAGE_INVOKE(env, page, CL_PAGE_OP(cpo_is_under_lock), (const struct lu_env *, const struct cl_page_slice *, struct cl_io *), io); PASSERT(env, page, rc != 0); - RETURN(rc); + return rc; } EXPORT_SYMBOL(cl_page_is_under_lock); @@ -1452,7 +1403,6 @@ int cl_pages_prune(const struct lu_env *env, struct cl_object *clobj) struct cl_io *io; int result; - ENTRY; info = cl_env_info(env); io = &info->clt_io; @@ -1465,7 +1415,7 @@ int cl_pages_prune(const struct lu_env *env, struct cl_object *clobj) result = cl_io_init(env, io, CIT_MISC, obj); if (result != 0) { cl_io_fini(env, io); - RETURN(io->ci_result); + return io->ci_result; } do { @@ -1476,7 +1426,7 @@ int cl_pages_prune(const struct lu_env *env, struct cl_object *clobj) } while (result != CLP_GANG_OKAY); cl_io_fini(env, io); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_pages_prune); @@ -1586,12 +1536,10 @@ void cl_page_slice_add(struct cl_page *page, struct cl_page_slice *slice, struct cl_object *obj, const struct cl_page_operations *ops) { - ENTRY; list_add_tail(&slice->cpl_linkage, &page->cp_layers); slice->cpl_obj = obj; slice->cpl_ops = ops; slice->cpl_page = page; - EXIT; } EXPORT_SYMBOL(cl_page_slice_add); diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index af1c2d09c47..b1024a6d37d 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -112,18 +112,18 @@ int lustre_get_jobid(char *jobid) { int jobid_len = JOBSTATS_JOBID_SIZE; int rc = 0; - ENTRY; memset(jobid, 0, JOBSTATS_JOBID_SIZE); /* Jobstats isn't enabled */ if (strcmp(obd_jobid_var, JOBSTATS_DISABLE) == 0) - RETURN(0); + return 0; /* Use process name + fsuid as jobid */ if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) { snprintf(jobid, JOBSTATS_JOBID_SIZE, "%s.%u", - current_comm(), current_fsuid()); - RETURN(0); + current_comm(), + from_kuid(&init_user_ns, current_fsuid())); + return 0; } rc = cfs_get_environ(obd_jobid_var, jobid, &jobid_len); @@ -150,7 +150,7 @@ int lustre_get_jobid(char *jobid) obd_jobid_var, rc); } } - RETURN(rc); + return rc; } EXPORT_SYMBOL(lustre_get_jobid); @@ -193,7 +193,6 @@ int class_resolve_dev_name(__u32 len, const char *name) int rc; int dev; - ENTRY; if (!len || !name) { CERROR("No name passed,!\n"); GOTO(out, rc = -EINVAL); @@ -214,7 +213,7 @@ int class_resolve_dev_name(__u32 len, const char *name) rc = dev; out: - RETURN(rc); + return rc; } int class_handle_ioctl(unsigned int cmd, unsigned long arg) @@ -224,7 +223,6 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) struct libcfs_debug_ioctl_data *debug_data; struct obd_device *obd = NULL; int err = 0, len = 0; - ENTRY; /* only for debugging */ if (cmd == LIBCFS_IOC_DEBUG_MASK) { @@ -237,7 +235,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) CDEBUG(D_IOCTL, "cmd = %x\n", cmd); if (obd_ioctl_getdata(&buf, &len, (void *)arg)) { CERROR("OBD ioctl: data error\n"); - RETURN(-EINVAL); + return -EINVAL; } data = (struct obd_ioctl_data *)buf; @@ -428,10 +426,10 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) out: if (buf) obd_ioctl_freedata(buf, len); - RETURN(err); + return err; } /* class_handle_ioctl */ -extern psdev_t obd_psdev; +extern struct miscdevice obd_psdev; #define OBD_INIT_CHECK int obd_init_checks(void) @@ -524,7 +522,7 @@ static int __init init_obdclass(void) LPROCFS_STATS_FLAG_IRQ_SAFE); if (obd_memory == NULL) { CERROR("kmalloc of 'obd_memory' failed\n"); - RETURN(-ENOMEM); + return -ENOMEM; } lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT, @@ -558,10 +556,10 @@ static int __init init_obdclass(void) /* Default the dirty page cache cap to 1/2 of system memory. * For clients with less memory, a larger fraction is needed * for other purposes (mostly for BGL). */ - if (num_physpages <= 512 << (20 - PAGE_CACHE_SHIFT)) - obd_max_dirty_pages = num_physpages / 4; + if (totalram_pages <= 512 << (20 - PAGE_CACHE_SHIFT)) + obd_max_dirty_pages = totalram_pages / 4; else - obd_max_dirty_pages = num_physpages / 2; + obd_max_dirty_pages = totalram_pages / 2; err = obd_init_caches(); if (err) @@ -638,7 +636,6 @@ static void cleanup_obdclass(void) int lustre_unregister_fs(void); __u64 memory_leaked, pages_leaked; __u64 memory_max, pages_max; - ENTRY; lustre_unregister_fs(); @@ -678,12 +675,12 @@ static void cleanup_obdclass(void) CDEBUG((pages_leaked) ? D_ERROR : D_INFO, "obd_memory_pages max: "LPU64", leaked: "LPU64"\n", pages_max, pages_leaked); - - EXIT; } MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); MODULE_DESCRIPTION("Lustre Class Driver Build Version: " BUILD_VERSION); MODULE_LICENSE("GPL"); +MODULE_VERSION(LUSTRE_VERSION_STRING); -cfs_module(obdclass, LUSTRE_VERSION_STRING, init_obdclass, cleanup_obdclass); +module_init(init_obdclass); +module_exit(cleanup_obdclass); diff --git a/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c index 1c962dd3bd2..1b164c7027b 100644 --- a/drivers/staging/lustre/lustre/obdclass/dt_object.c +++ b/drivers/staging/lustre/lustre/obdclass/dt_object.c @@ -219,7 +219,6 @@ struct dt_object *dt_locate_at(const struct lu_env *env, struct lu_device *top_dev) { struct lu_object *lo, *n; - ENTRY; lo = lu_object_find_at(env, top_dev, fid, NULL); if (IS_ERR(lo)) @@ -376,15 +375,13 @@ struct dt_object *dt_find_or_create(const struct lu_env *env, struct thandle *th; int rc; - ENTRY; - dto = dt_locate(env, dt, fid); if (IS_ERR(dto)) - RETURN(dto); + return dto; LASSERT(dto != NULL); if (dt_object_exists(dto)) - RETURN(dto); + return dto; th = dt_trans_create(env, dt); if (IS_ERR(th)) @@ -415,9 +412,9 @@ trans_stop: out: if (rc) { lu_object_put(env, &dto->do_lu); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } - RETURN(dto); + return dto; } EXPORT_SYMBOL(dt_find_or_create); @@ -659,7 +656,6 @@ static int dt_index_page_build(const struct lu_env *env, union lu_page *lp, struct lu_idxpage *lip = &lp->lp_idx; char *entry; int rc, size; - ENTRY; /* no support for variable key & record size for now */ LASSERT((ii->ii_flags & II_FL_VARKEY) == 0); @@ -763,21 +759,20 @@ int dt_index_walk(const struct lu_env *env, struct dt_object *obj, const struct dt_it_ops *iops; unsigned int pageidx, nob, nlupgs = 0; int rc; - ENTRY; LASSERT(rdpg->rp_pages != NULL); LASSERT(obj->do_index_ops != NULL); nob = rdpg->rp_count; if (nob <= 0) - RETURN(-EFAULT); + return -EFAULT; /* Iterate through index and fill containers from @rdpg */ iops = &obj->do_index_ops->dio_it; LASSERT(iops != NULL); it = iops->init(env, obj, rdpg->rp_attrs, BYPASS_CAPA); if (IS_ERR(it)) - RETURN(PTR_ERR(it)); + return PTR_ERR(it); rc = iops->load(env, it, rdpg->rp_hash); if (rc == 0) { @@ -831,7 +826,7 @@ int dt_index_walk(const struct lu_env *env, struct dt_object *obj, if (rc >= 0) rc = min_t(unsigned int, nlupgs * LU_PAGE_SIZE, rdpg->rp_count); - RETURN(rc); + return rc; } EXPORT_SYMBOL(dt_index_walk); @@ -855,26 +850,25 @@ int dt_index_read(const struct lu_env *env, struct dt_device *dev, const struct dt_index_features *feat; struct dt_object *obj; int rc; - ENTRY; /* rp_count shouldn't be null and should be a multiple of the container * size */ if (rdpg->rp_count <= 0 && (rdpg->rp_count & (LU_PAGE_SIZE - 1)) != 0) - RETURN(-EFAULT); + return -EFAULT; if (fid_seq(&ii->ii_fid) >= FID_SEQ_NORMAL) /* we don't support directory transfer via OBD_IDX_READ for the * time being */ - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (!fid_is_quota(&ii->ii_fid)) /* block access to all local files except quota files */ - RETURN(-EPERM); + return -EPERM; /* lookup index object subject to the transfer */ obj = dt_locate(env, dev, &ii->ii_fid); if (IS_ERR(obj)) - RETURN(PTR_ERR(obj)); + return PTR_ERR(obj); if (dt_object_exists(obj) == 0) GOTO(out, rc = -ENOENT); diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index d96876e0bc6..68fe71c8a2a 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -163,20 +163,19 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, { struct obd_type *type; int rc = 0; - ENTRY; /* sanity check */ LASSERT(strnlen(name, CLASS_MAX_NAME) < CLASS_MAX_NAME); if (class_search_type(name)) { CDEBUG(D_IOCTL, "Type %s already registered\n", name); - RETURN(-EEXIST); + return -EEXIST; } rc = -ENOMEM; OBD_ALLOC(type, sizeof(*type)); if (type == NULL) - RETURN(rc); + return rc; OBD_ALLOC_PTR(type->typ_dt_ops); OBD_ALLOC_PTR(type->typ_md_ops); @@ -214,7 +213,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, list_add(&type->typ_chain, &obd_types); spin_unlock(&obd_types_lock); - RETURN (0); + return 0; failed: if (type->typ_name != NULL) @@ -224,18 +223,17 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, if (type->typ_dt_ops != NULL) OBD_FREE_PTR(type->typ_dt_ops); OBD_FREE(type, sizeof(*type)); - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_register_type); int class_unregister_type(const char *name) { struct obd_type *type = class_search_type(name); - ENTRY; if (!type) { CERROR("unknown obd type\n"); - RETURN(-EINVAL); + return -EINVAL; } if (type->typ_refcnt) { @@ -244,7 +242,7 @@ int class_unregister_type(const char *name) /* Remove ops, but leave the name for debugging */ OBD_FREE_PTR(type->typ_dt_ops); OBD_FREE_PTR(type->typ_md_ops); - RETURN(-EBUSY); + return -EBUSY; } if (type->typ_procroot) { @@ -263,7 +261,7 @@ int class_unregister_type(const char *name) if (type->typ_md_ops != NULL) OBD_FREE_PTR(type->typ_md_ops); OBD_FREE(type, sizeof(*type)); - RETURN(0); + return 0; } /* class_unregister_type */ EXPORT_SYMBOL(class_unregister_type); @@ -285,17 +283,16 @@ struct obd_device *class_newdev(const char *type_name, const char *name) struct obd_type *type = NULL; int i; int new_obd_minor = 0; - ENTRY; if (strlen(name) >= MAX_OBD_NAME) { CERROR("name/uuid must be < %u bytes long\n", MAX_OBD_NAME); - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); } type = class_get_type(type_name); if (type == NULL){ CERROR("OBD: unknown type: %s\n", type_name); - RETURN(ERR_PTR(-ENODEV)); + return ERR_PTR(-ENODEV); } newdev = obd_device_alloc(); @@ -349,7 +346,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name) CDEBUG(D_IOCTL, "Adding new device %s (%p)\n", result->obd_name, result); - RETURN(result); + return result; out: obd_device_free(newdev); out_type: @@ -635,7 +632,6 @@ EXPORT_SYMBOL(class_notify_sptlrpc_conf); void obd_cleanup_caches(void) { - ENTRY; if (obd_device_cachep) { kmem_cache_destroy(obd_device_cachep); obd_device_cachep = NULL; @@ -652,13 +648,10 @@ void obd_cleanup_caches(void) kmem_cache_destroy(capa_cachep); capa_cachep = NULL; } - EXIT; } int obd_init_caches(void) { - ENTRY; - LASSERT(obd_device_cachep == NULL); obd_device_cachep = kmem_cache_create("ll_obd_dev_cache", sizeof(struct obd_device), @@ -685,10 +678,10 @@ int obd_init_caches(void) if (!capa_cachep) GOTO(out, -ENOMEM); - RETURN(0); + return 0; out: obd_cleanup_caches(); - RETURN(-ENOMEM); + return -ENOMEM; } @@ -696,21 +689,20 @@ int obd_init_caches(void) struct obd_export *class_conn2export(struct lustre_handle *conn) { struct obd_export *export; - ENTRY; if (!conn) { CDEBUG(D_CACHE, "looking for null handle\n"); - RETURN(NULL); + return NULL; } if (conn->cookie == -1) { /* this means assign a new connection */ CDEBUG(D_CACHE, "want a new connection\n"); - RETURN(NULL); + return NULL; } CDEBUG(D_INFO, "looking for export cookie "LPX64"\n", conn->cookie); export = class_handle2object(conn->cookie); - RETURN(export); + return export; } EXPORT_SYMBOL(class_conn2export); @@ -757,7 +749,6 @@ EXPORT_SYMBOL(class_conn2cliimp); static void class_export_destroy(struct obd_export *exp) { struct obd_device *obd = exp->exp_obd; - ENTRY; LASSERT_ATOMIC_ZERO(&exp->exp_refcount); LASSERT(obd != NULL); @@ -777,7 +768,6 @@ static void class_export_destroy(struct obd_export *exp) class_decref(obd, "export", exp); OBD_FREE_RCU(exp, sizeof(*exp), &exp->exp_handle); - EXIT; } static void export_handle_addref(void *export) @@ -828,7 +818,6 @@ struct obd_export *class_new_export(struct obd_device *obd, struct obd_export *export; cfs_hash_t *hash = NULL; int rc = 0; - ENTRY; OBD_ALLOC_PTR(export); if (!export) @@ -899,7 +888,7 @@ struct obd_export *class_new_export(struct obd_device *obd, export->exp_obd->obd_num_exports++; spin_unlock(&obd->obd_dev_lock); cfs_hash_putref(hash); - RETURN(export); + return export; exit_unlock: spin_unlock(&obd->obd_dev_lock); @@ -936,8 +925,6 @@ EXPORT_SYMBOL(class_unlink_export); /* Import management functions */ void class_import_destroy(struct obd_import *imp) { - ENTRY; - CDEBUG(D_IOCTL, "destroying import %p for %s\n", imp, imp->imp_obd->obd_name); @@ -958,7 +945,6 @@ void class_import_destroy(struct obd_import *imp) LASSERT(imp->imp_sec == NULL); class_decref(imp->imp_obd, "import", imp); OBD_FREE_RCU(imp, sizeof(*imp), &imp->imp_handle); - EXIT; } static void import_handle_addref(void *import) @@ -983,8 +969,6 @@ EXPORT_SYMBOL(class_import_get); void class_import_put(struct obd_import *imp) { - ENTRY; - LASSERT(list_empty(&imp->imp_zombie_chain)); LASSERT_ATOMIC_GT_LT(&imp->imp_refcount, 0, LI_POISON); @@ -999,7 +983,6 @@ void class_import_put(struct obd_import *imp) /* catch possible import put race */ LASSERT_ATOMIC_GE_LT(&imp->imp_refcount, 0, LI_POISON); - EXIT; } EXPORT_SYMBOL(class_import_put); @@ -1121,18 +1104,17 @@ int class_connect(struct lustre_handle *conn, struct obd_device *obd, LASSERT(conn != NULL); LASSERT(obd != NULL); LASSERT(cluuid != NULL); - ENTRY; export = class_new_export(obd, cluuid); if (IS_ERR(export)) - RETURN(PTR_ERR(export)); + return PTR_ERR(export); conn->cookie = export->exp_handle.h_cookie; class_export_put(export); CDEBUG(D_IOCTL, "connect: client %s, cookie "LPX64"\n", cluuid->uuid, conn->cookie); - RETURN(0); + return 0; } EXPORT_SYMBOL(class_connect); @@ -1188,11 +1170,10 @@ void class_export_recovery_cleanup(struct obd_export *exp) int class_disconnect(struct obd_export *export) { int already_disconnected; - ENTRY; if (export == NULL) { CWARN("attempting to free NULL export %p\n", export); - RETURN(-EINVAL); + return -EINVAL; } spin_lock(&export->exp_lock); @@ -1220,7 +1201,7 @@ int class_disconnect(struct obd_export *export) class_unlink_export(export); no_disconn: class_export_put(export); - RETURN(0); + return 0; } EXPORT_SYMBOL(class_disconnect); @@ -1243,7 +1224,6 @@ static void class_disconnect_export_list(struct list_head *list, { int rc; struct obd_export *exp; - ENTRY; /* It's possible that an export may disconnect itself, but * nothing else will be added to this list. */ @@ -1281,13 +1261,11 @@ static void class_disconnect_export_list(struct list_head *list, obd_export_nid2str(exp), exp, rc); class_export_put(exp); } - EXIT; } void class_disconnect_exports(struct obd_device *obd) { struct list_head work_list; - ENTRY; /* Move all of the exports from obd_exports to a work list, en masse. */ INIT_LIST_HEAD(&work_list); @@ -1304,7 +1282,6 @@ void class_disconnect_exports(struct obd_device *obd) } else CDEBUG(D_HA, "OBD device %d (%p) has no exports\n", obd->obd_minor, obd); - EXIT; } EXPORT_SYMBOL(class_disconnect_exports); @@ -1316,7 +1293,6 @@ void class_disconnect_stale_exports(struct obd_device *obd, struct list_head work_list; struct obd_export *exp, *n; int evicted = 0; - ENTRY; INIT_LIST_HEAD(&work_list); spin_lock(&obd->obd_dev_lock); @@ -1356,7 +1332,6 @@ void class_disconnect_stale_exports(struct obd_device *obd, class_disconnect_export_list(&work_list, exp_flags_from_obd(obd) | OBD_OPT_ABORT_RECOV); - EXIT; } EXPORT_SYMBOL(class_disconnect_stale_exports); @@ -1484,7 +1459,7 @@ int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid) CERROR("%s: can't disconnect %s: no exports found\n", obd->obd_name, uuid); } else { - CWARN("%s: evicting %s at adminstrative request\n", + CWARN("%s: evicting %s at administrative request\n", obd->obd_name, doomed_exp->exp_client_uuid.uuid); class_fail_export(doomed_exp); class_export_put(doomed_exp); @@ -1585,7 +1560,6 @@ void obd_zombie_impexp_cull(void) { struct obd_import *import; struct obd_export *export; - ENTRY; do { spin_lock(&obd_zombie_impexp_lock); @@ -1624,7 +1598,6 @@ void obd_zombie_impexp_cull(void) cond_resched(); } while (import != NULL || export != NULL); - EXIT; } static struct completion obd_zombie_start; @@ -1649,7 +1622,7 @@ static int obd_zombie_impexp_check(void *arg) !test_bit(OBD_ZOMBIE_STOP, &obd_zombie_flags); spin_unlock(&obd_zombie_impexp_lock); - RETURN(rc); + return rc; } /** @@ -1751,7 +1724,7 @@ static int obd_zombie_impexp_thread(void *unused) complete(&obd_zombie_stop); - RETURN(0); + return 0; } @@ -1760,7 +1733,7 @@ static int obd_zombie_impexp_thread(void *unused) */ int obd_zombie_impexp_init(void) { - task_t *task; + struct task_struct *task; INIT_LIST_HEAD(&obd_zombie_imports); INIT_LIST_HEAD(&obd_zombie_exports); @@ -1772,10 +1745,10 @@ int obd_zombie_impexp_init(void) task = kthread_run(obd_zombie_impexp_thread, NULL, "obd_zombid"); if (IS_ERR(task)) - RETURN(PTR_ERR(task)); + return PTR_ERR(task); wait_for_completion(&obd_zombie_start); - RETURN(0); + return 0; } /** * stop destroy zombie import/export thread diff --git a/drivers/staging/lustre/lustre/obdclass/idmap.c b/drivers/staging/lustre/lustre/obdclass/idmap.c index 622f8d16527..ec2590f5cfe 100644 --- a/drivers/staging/lustre/lustre/obdclass/idmap.c +++ b/drivers/staging/lustre/lustre/obdclass/idmap.c @@ -59,8 +59,7 @@ * groups_search() is copied from linux kernel! * A simple bsearch. */ -static int lustre_groups_search(group_info_t *group_info, - gid_t grp) +static int lustre_groups_search(const struct group_info *group_info, gid_t grp) { int left, right; @@ -71,7 +70,8 @@ static int lustre_groups_search(group_info_t *group_info, right = group_info->ngroups; while (left < right) { int mid = (left + right) / 2; - int cmp = grp - CFS_GROUP_AT(group_info, mid); + int cmp = grp - + from_kgid(&init_user_ns, CFS_GROUP_AT(group_info, mid)); if (cmp > 0) left = mid + 1; @@ -83,7 +83,7 @@ static int lustre_groups_search(group_info_t *group_info, return 0; } -void lustre_groups_from_list(group_info_t *ginfo, gid_t *glist) +void lustre_groups_from_list(struct group_info *ginfo, gid_t *glist) { int i; int count = ginfo->ngroups; @@ -102,7 +102,7 @@ EXPORT_SYMBOL(lustre_groups_from_list); /* groups_sort() is copied from linux kernel! */ /* a simple shell-metzner sort */ -void lustre_groups_sort(group_info_t *group_info) +void lustre_groups_sort(struct group_info *group_info) { int base, max, stride; int gidsetsize = group_info->ngroups; @@ -116,16 +116,19 @@ void lustre_groups_sort(group_info_t *group_info) for (base = 0; base < max; base++) { int left = base; int right = left + stride; - gid_t tmp = CFS_GROUP_AT(group_info, right); + gid_t tmp = from_kgid(&init_user_ns, + CFS_GROUP_AT(group_info, right)); while (left >= 0 && - CFS_GROUP_AT(group_info, left) > tmp) { + tmp < from_kgid(&init_user_ns, + CFS_GROUP_AT(group_info, left))) { CFS_GROUP_AT(group_info, right) = CFS_GROUP_AT(group_info, left); right = left; left -= stride; } - CFS_GROUP_AT(group_info, right) = tmp; + CFS_GROUP_AT(group_info, right) = + make_kgid(&init_user_ns, tmp); } stride /= 3; } @@ -137,7 +140,7 @@ int lustre_in_group_p(struct lu_ucred *mu, gid_t grp) int rc = 1; if (grp != mu->uc_fsgid) { - group_info_t *group_info = NULL; + struct group_info *group_info = NULL; if (mu->uc_ginfo || !mu->uc_identity || mu->uc_valid == UCRED_OLD) diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index d2c3072541d..d1a57ebfda9 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -83,27 +83,26 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) struct obd_ioctl_data *data; int err; int offset = 0; - ENTRY; err = copy_from_user(&hdr, (void *)arg, sizeof(hdr)); if ( err ) - RETURN(err); + return err; if (hdr.ioc_version != OBD_IOCTL_VERSION) { CERROR("Version mismatch kernel (%x) vs application (%x)\n", OBD_IOCTL_VERSION, hdr.ioc_version); - RETURN(-EINVAL); + return -EINVAL; } if (hdr.ioc_len > OBD_MAX_IOCTL_BUFFER) { CERROR("User buffer len %d exceeds %d max buffer\n", hdr.ioc_len, OBD_MAX_IOCTL_BUFFER); - RETURN(-EINVAL); + return -EINVAL; } if (hdr.ioc_len < sizeof(struct obd_ioctl_data)) { CERROR("User buffer too small for ioctl (%d)\n", hdr.ioc_len); - RETURN(-EINVAL); + return -EINVAL; } /* When there are lots of processes calling vmalloc on multi-core @@ -114,7 +113,7 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) if (*buf == NULL) { CERROR("Cannot allocate control buffer of len %d\n", hdr.ioc_len); - RETURN(-EINVAL); + return -EINVAL; } *len = hdr.ioc_len; data = (struct obd_ioctl_data *)*buf; @@ -122,13 +121,13 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) err = copy_from_user(*buf, (void *)arg, hdr.ioc_len); if ( err ) { OBD_FREE_LARGE(*buf, hdr.ioc_len); - RETURN(err); + return err; } if (obd_ioctl_is_invalid(data)) { CERROR("ioctl not correctly formatted\n"); OBD_FREE_LARGE(*buf, hdr.ioc_len); - RETURN(-EINVAL); + return -EINVAL; } if (data->ioc_inllen1) { @@ -150,7 +149,6 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset; } - EXIT; return 0; } EXPORT_SYMBOL(obd_ioctl_getdata); @@ -169,19 +167,15 @@ EXPORT_SYMBOL(obd_ioctl_popdata); /* opening /dev/obd */ static int obd_class_open(struct inode * inode, struct file * file) { - ENTRY; - try_module_get(THIS_MODULE); - RETURN(0); + return 0; } /* closing /dev/obd */ static int obd_class_release(struct inode * inode, struct file * file) { - ENTRY; - module_put(THIS_MODULE); - RETURN(0); + return 0; } /* to control /dev/obd */ @@ -189,17 +183,16 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { int err = 0; - ENTRY; /* Allow non-root access for OBD_IOC_PING_TARGET - used by lfs check */ if (!cfs_capable(CFS_CAP_SYS_ADMIN) && (cmd != OBD_IOC_PING_TARGET)) - RETURN(err = -EACCES); + return err = -EACCES; if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */ - RETURN(err = -ENOTTY); + return err = -ENOTTY; err = class_handle_ioctl(cmd, (unsigned long)arg); - RETURN(err); + return err; } /* declare character device */ @@ -211,7 +204,7 @@ static struct file_operations obd_psdev_fops = { }; /* modules setup */ -psdev_t obd_psdev = { +struct miscdevice obd_psdev = { .minor = OBD_DEV_MINOR, .name = OBD_DEV_NAME, .fops = &obd_psdev_fops, @@ -385,24 +378,29 @@ struct file_operations obd_device_list_fops = { int class_procfs_init(void) { - int rc; - ENTRY; + int rc = 0; obd_sysctl_init(); proc_lustre_root = lprocfs_register("fs/lustre", NULL, lprocfs_base, NULL); + if (IS_ERR(proc_lustre_root)) { + rc = PTR_ERR(proc_lustre_root); + proc_lustre_root = NULL; + goto out; + } + rc = lprocfs_seq_create(proc_lustre_root, "devices", 0444, &obd_device_list_fops, NULL); +out: if (rc) CERROR("error adding /proc/fs/lustre/devices file\n"); - RETURN(0); + return 0; } int class_procfs_clean(void) { - ENTRY; if (proc_lustre_root) { lprocfs_remove(&proc_lustre_root); } - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c index 6ee347153a1..d3bb5ffc564 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c @@ -213,9 +213,9 @@ void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid) if (valid & OBD_MD_FLMODE) dst->i_mode = (dst->i_mode & S_IFMT) | (src->o_mode & ~S_IFMT); if (valid & OBD_MD_FLUID) - dst->i_uid = src->o_uid; + dst->i_uid = make_kuid(&init_user_ns, src->o_uid); if (valid & OBD_MD_FLGID) - dst->i_gid = src->o_gid; + dst->i_gid = make_kgid(&init_user_ns, src->o_gid); if (valid & OBD_MD_FLFLAGS) dst->i_flags = src->o_flags; } diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index 46aad6813ca..acd2619227d 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -38,8 +38,6 @@ #include <linux/sysctl.h> #include <linux/sched.h> #include <linux/mm.h> -#include <linux/sysctl.h> -#include <linux/version.h> #include <linux/proc_fs.h> #include <linux/slab.h> #include <linux/stat.h> @@ -202,12 +200,12 @@ int LL_PROC_PROTO(proc_max_dirty_pages_in_mb) 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. */ - if (obd_max_dirty_pages > ((num_physpages / 10) * 9)) { + if (obd_max_dirty_pages > ((totalram_pages / 10) * 9)) { CERROR("Refusing to set max dirty pages to %u, which " "is more than 90%% of available RAM; setting " "to %lu\n", obd_max_dirty_pages, - ((num_physpages / 10) * 9)); - obd_max_dirty_pages = ((num_physpages / 10) * 9); + ((totalram_pages / 10) * 9)); + obd_max_dirty_pages = ((totalram_pages / 10) * 9); } else if (obd_max_dirty_pages < 4 << (20 - PAGE_CACHE_SHIFT)) { obd_max_dirty_pages = 4 << (20 - PAGE_CACHE_SHIFT); } @@ -431,7 +429,7 @@ void obd_sysctl_init (void) { #ifdef CONFIG_SYSCTL if ( !obd_table_header ) - obd_table_header = cfs_register_sysctl_table(parent_table, 0); + obd_table_header = register_sysctl_table(parent_table); #endif } diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index b1d215e5699..0cb44287502 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -111,21 +111,20 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, { struct llog_log_hdr *llh = loghandle->lgh_hdr; int rc = 0; - ENTRY; CDEBUG(D_RPCTRACE, "Canceling %d in log "DOSTID"\n", index, POSTID(&loghandle->lgh_id.lgl_oi)); if (index == 0) { CERROR("Can't cancel index 0 which is header\n"); - RETURN(-EINVAL); + return -EINVAL; } spin_lock(&loghandle->lgh_hdr_lock); if (!ext2_clear_bit(index, llh->llh_bitmap)) { spin_unlock(&loghandle->lgh_hdr_lock); CDEBUG(D_RPCTRACE, "Catalog index %u already clear?\n", index); - RETURN(-ENOENT); + return -ENOENT; } llh->llh_count--; @@ -143,7 +142,7 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, loghandle->lgh_id.lgl_ogen, rc); GOTO(out_err, rc); } - RETURN(1); + return 1; } spin_unlock(&loghandle->lgh_hdr_lock); @@ -156,7 +155,7 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, loghandle->lgh_id.lgl_ogen, rc); GOTO(out_err, rc); } - RETURN(0); + return 0; out_err: spin_lock(&loghandle->lgh_hdr_lock); ext2_set_bit(index, llh->llh_bitmap); @@ -175,10 +174,10 @@ static int llog_read_header(const struct lu_env *env, rc = llog_handle2ops(handle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_read_header == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = lop->lop_read_header(env, handle); if (rc == LLOG_EEMPTY) { @@ -206,12 +205,11 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, struct llog_log_hdr *llh; int rc; - ENTRY; LASSERT(handle->lgh_hdr == NULL); OBD_ALLOC_PTR(llh); if (llh == NULL) - RETURN(-ENOMEM); + return -ENOMEM; handle->lgh_hdr = llh; /* first assign flags to use llog_client_ops */ llh->llh_flags = flags; @@ -263,7 +261,7 @@ out: OBD_FREE_PTR(llh); handle->lgh_hdr = NULL; } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_init_handle); @@ -277,7 +275,6 @@ int llog_copy_handler(const struct lu_env *env, char *cfg_buf = (char*) (rec + 1); struct lustre_cfg *lcfg; int rc = 0; - ENTRY; /* Append all records */ local_rec.lrh_len -= sizeof(*rec) + sizeof(struct llog_rec_tail); @@ -289,7 +286,7 @@ int llog_copy_handler(const struct lu_env *env, rec->lrh_index, rc, rec->lrh_len, lcfg->lcfg_command, lustre_cfg_string(lcfg, 0), lustre_cfg_string(lcfg, 1)); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_copy_handler); @@ -306,14 +303,12 @@ static int llog_process_thread(void *arg) int saved_index = 0; int last_called_index = 0; - ENTRY; - LASSERT(llh); OBD_ALLOC(buf, LLOG_CHUNK_SIZE); if (!buf) { lpi->lpi_rc = -ENOMEM; - RETURN(0); + return 0; } if (cd != NULL) { @@ -457,12 +452,10 @@ int llog_process_or_fork(const struct lu_env *env, struct llog_process_info *lpi; int rc; - ENTRY; - OBD_ALLOC_PTR(lpi); if (lpi == NULL) { CERROR("cannot alloc pointer\n"); - RETURN(-ENOMEM); + return -ENOMEM; } lpi->lpi_loghandle = loghandle; lpi->lpi_cb = cb; @@ -480,7 +473,7 @@ int llog_process_or_fork(const struct lu_env *env, CERROR("%s: cannot start thread: rc = %d\n", loghandle->lgh_ctxt->loc_obd->obd_name, rc); OBD_FREE_PTR(lpi); - RETURN(rc); + return rc; } wait_for_completion(&lpi->lpi_completion); } else { @@ -489,7 +482,7 @@ int llog_process_or_fork(const struct lu_env *env, } rc = lpi->lpi_rc; OBD_FREE_PTR(lpi); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_process_or_fork); @@ -516,11 +509,10 @@ int llog_reverse_process(const struct lu_env *env, struct llog_process_cat_data *cd = catdata; void *buf; int rc = 0, first_index = 1, index, idx; - ENTRY; OBD_ALLOC(buf, LLOG_CHUNK_SIZE); if (!buf) - RETURN(-ENOMEM); + return -ENOMEM; if (cd != NULL) first_index = cd->lpcd_first_idx + 1; @@ -594,7 +586,7 @@ int llog_reverse_process(const struct lu_env *env, out: if (buf) OBD_FREE(buf, LLOG_CHUNK_SIZE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_reverse_process); @@ -617,16 +609,14 @@ int llog_exist(struct llog_handle *loghandle) struct llog_operations *lop; int rc; - ENTRY; - rc = llog_handle2ops(loghandle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_exist == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = lop->lop_exist(loghandle); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_exist); @@ -636,13 +626,11 @@ int llog_declare_create(const struct lu_env *env, struct llog_operations *lop; int raised, rc; - ENTRY; - rc = llog_handle2ops(loghandle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_declare_create == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); if (!raised) @@ -650,7 +638,7 @@ int llog_declare_create(const struct lu_env *env, rc = lop->lop_declare_create(env, loghandle, th); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_declare_create); @@ -660,13 +648,11 @@ int llog_create(const struct lu_env *env, struct llog_handle *handle, struct llog_operations *lop; int raised, rc; - ENTRY; - rc = llog_handle2ops(handle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_create == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); if (!raised) @@ -674,7 +660,7 @@ int llog_create(const struct lu_env *env, struct llog_handle *handle, rc = lop->lop_create(env, handle, th); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_create); @@ -686,14 +672,12 @@ int llog_declare_write_rec(const struct lu_env *env, struct llog_operations *lop; int raised, rc; - ENTRY; - rc = llog_handle2ops(handle, &lop); if (rc) - RETURN(rc); + return rc; LASSERT(lop); if (lop->lop_declare_write_rec == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); if (!raised) @@ -701,7 +685,7 @@ int llog_declare_write_rec(const struct lu_env *env, rc = lop->lop_declare_write_rec(env, handle, rec, idx, th); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_declare_write_rec); @@ -712,15 +696,13 @@ int llog_write_rec(const struct lu_env *env, struct llog_handle *handle, struct llog_operations *lop; int raised, rc, buflen; - ENTRY; - rc = llog_handle2ops(handle, &lop); if (rc) - RETURN(rc); + return rc; LASSERT(lop); if (lop->lop_write_rec == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (buf) buflen = rec->lrh_len + sizeof(struct llog_rec_hdr) + @@ -736,7 +718,7 @@ int llog_write_rec(const struct lu_env *env, struct llog_handle *handle, buf, idx, th); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_write_rec); @@ -746,10 +728,8 @@ int llog_add(const struct lu_env *env, struct llog_handle *lgh, { int raised, rc; - ENTRY; - if (lgh->lgh_logops->lop_add == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); if (!raised) @@ -757,7 +737,7 @@ int llog_add(const struct lu_env *env, struct llog_handle *lgh, rc = lgh->lgh_logops->lop_add(env, lgh, rec, logcookies, buf, th); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_add); @@ -766,10 +746,8 @@ int llog_declare_add(const struct lu_env *env, struct llog_handle *lgh, { int raised, rc; - ENTRY; - if (lgh->lgh_logops->lop_declare_add == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); if (!raised) @@ -777,7 +755,7 @@ int llog_declare_add(const struct lu_env *env, struct llog_handle *lgh, rc = lgh->lgh_logops->lop_declare_add(env, lgh, rec, th); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_declare_add); @@ -792,14 +770,12 @@ int llog_open_create(const struct lu_env *env, struct llog_ctxt *ctxt, struct thandle *th; int rc; - ENTRY; - rc = llog_open(env, ctxt, res, logid, name, LLOG_OPEN_NEW); if (rc) - RETURN(rc); + return rc; if (llog_exist(*res)) - RETURN(0); + return 0; if ((*res)->lgh_obj != NULL) { struct dt_device *d; @@ -825,7 +801,7 @@ int llog_open_create(const struct lu_env *env, struct llog_ctxt *ctxt, out: if (rc) llog_close(env, *res); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_open_create); @@ -838,15 +814,13 @@ int llog_erase(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_handle *handle; int rc = 0, rc2; - ENTRY; - /* nothing to erase */ if (name == NULL && logid == NULL) - RETURN(0); + return 0; rc = llog_open(env, ctxt, &handle, logid, name, LLOG_OPEN_EXISTS); if (rc < 0) - RETURN(rc); + return rc; rc = llog_init_handle(env, handle, LLOG_F_IS_PLAIN, NULL); if (rc == 0) @@ -855,7 +829,7 @@ int llog_erase(const struct lu_env *env, struct llog_ctxt *ctxt, rc2 = llog_close(env, handle); if (rc == 0) rc = rc2; - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_erase); @@ -870,8 +844,6 @@ int llog_write(const struct lu_env *env, struct llog_handle *loghandle, { int rc; - ENTRY; - LASSERT(loghandle); LASSERT(loghandle->lgh_ctxt); @@ -883,7 +855,7 @@ int llog_write(const struct lu_env *env, struct llog_handle *loghandle, th = dt_trans_create(env, dt); if (IS_ERR(th)) - RETURN(PTR_ERR(th)); + return PTR_ERR(th); rc = llog_declare_write_rec(env, loghandle, rec, idx, th); if (rc) @@ -905,7 +877,7 @@ out_trans: cookiecount, buf, idx, NULL); up_write(&loghandle->lgh_lock); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_write); @@ -916,19 +888,17 @@ int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt, int raised; int rc; - ENTRY; - LASSERT(ctxt); LASSERT(ctxt->loc_logops); if (ctxt->loc_logops->lop_open == NULL) { *lgh = NULL; - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; } *lgh = llog_alloc_handle(); if (*lgh == NULL) - RETURN(-ENOMEM); + return -ENOMEM; (*lgh)->lgh_ctxt = ctxt; (*lgh)->lgh_logops = ctxt->loc_logops; @@ -942,7 +912,7 @@ int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt, llog_free_handle(*lgh); *lgh = NULL; } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_open); @@ -951,8 +921,6 @@ int llog_close(const struct lu_env *env, struct llog_handle *loghandle) struct llog_operations *lop; int rc; - ENTRY; - rc = llog_handle2ops(loghandle, &lop); if (rc) GOTO(out, rc); @@ -961,6 +929,6 @@ int llog_close(const struct lu_env *env, struct llog_handle *loghandle) rc = lop->lop_close(env, loghandle); out: llog_handle_put(loghandle); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_close); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index cf00b2f550a..c0f3af72574 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -67,7 +67,6 @@ static int llog_cat_new_log(const struct lu_env *env, struct llog_log_hdr *llh; struct llog_logid_rec rec = { { 0 }, }; int rc, index, bitmap_size; - ENTRY; llh = cathandle->lgh_hdr; bitmap_size = LLOG_BITMAP_SIZE(llh); @@ -77,20 +76,20 @@ static int llog_cat_new_log(const struct lu_env *env, /* maximum number of available slots in catlog is bitmap_size - 2 */ if (llh->llh_cat_idx == index) { CERROR("no free catalog slots for log...\n"); - RETURN(-ENOSPC); + return -ENOSPC; } if (OBD_FAIL_CHECK(OBD_FAIL_MDS_LLOG_CREATE_FAILED)) - RETURN(-ENOSPC); + return -ENOSPC; rc = llog_create(env, loghandle, th); /* if llog is already created, no need to initialize it */ if (rc == -EEXIST) { - RETURN(0); + return 0; } else if (rc != 0) { CERROR("%s: can't create new plain llog in catalog: rc = %d\n", loghandle->lgh_ctxt->loc_obd->obd_name, rc); - RETURN(rc); + return rc; } rc = llog_init_handle(env, loghandle, @@ -134,10 +133,10 @@ static int llog_cat_new_log(const struct lu_env *env, GOTO(out_destroy, rc); loghandle->lgh_hdr->llh_cat_idx = index; - RETURN(0); + return 0; out_destroy: llog_destroy(env, loghandle); - RETURN(rc); + return rc; } /* Open an existent log handle and add it to the open list. @@ -155,10 +154,8 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle, struct llog_handle *loghandle; int rc = 0; - ENTRY; - if (cathandle == NULL) - RETURN(-EBADF); + return -EBADF; down_write(&cathandle->lgh_lock); list_for_each_entry(loghandle, &cathandle->u.chd.chd_head, @@ -187,14 +184,14 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle, CERROR("%s: error opening log id "DOSTID":%x: rc = %d\n", cathandle->lgh_ctxt->loc_obd->obd_name, POSTID(&logid->lgl_oi), logid->lgl_ogen, rc); - RETURN(rc); + return rc; } rc = llog_init_handle(env, loghandle, LLOG_F_IS_PLAIN, NULL); if (rc < 0) { llog_close(env, loghandle); loghandle = NULL; - RETURN(rc); + return rc; } down_write(&cathandle->lgh_lock); @@ -205,7 +202,6 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle, loghandle->u.phd.phd_cookie.lgc_lgl = cathandle->lgh_id; loghandle->u.phd.phd_cookie.lgc_index = loghandle->lgh_hdr->llh_cat_idx; - EXIT; out: llog_handle_get(loghandle); *res = loghandle; @@ -217,8 +213,6 @@ int llog_cat_close(const struct lu_env *env, struct llog_handle *cathandle) struct llog_handle *loghandle, *n; int rc; - ENTRY; - list_for_each_entry_safe(loghandle, n, &cathandle->u.chd.chd_head, u.phd.phd_entry) { struct llog_log_hdr *llh = loghandle->lgh_hdr; @@ -246,7 +240,7 @@ int llog_cat_close(const struct lu_env *env, struct llog_handle *cathandle) if (cathandle->lgh_ctxt->loc_handle == cathandle) cathandle->lgh_ctxt->loc_handle = NULL; rc = llog_close(env, cathandle); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_close); @@ -272,7 +266,6 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, struct thandle *th) { struct llog_handle *loghandle = NULL; - ENTRY; down_read_nested(&cathandle->lgh_lock, LLOGH_CAT); loghandle = cathandle->u.chd.chd_current_log; @@ -284,7 +277,7 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, if (llh == NULL || loghandle->lgh_last_idx < LLOG_BITMAP_SIZE(llh) - 1) { up_read(&cathandle->lgh_lock); - RETURN(loghandle); + return loghandle; } else { up_write(&loghandle->lgh_lock); } @@ -304,7 +297,7 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, LASSERT(llh); if (loghandle->lgh_last_idx < LLOG_BITMAP_SIZE(llh) - 1) { up_write(&cathandle->lgh_lock); - RETURN(loghandle); + return loghandle; } else { up_write(&loghandle->lgh_lock); } @@ -318,7 +311,7 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, down_write_nested(&loghandle->lgh_lock, LLOGH_LOG); up_write(&cathandle->lgh_lock); LASSERT(loghandle); - RETURN(loghandle); + return loghandle; } /* Add a single record to the recovery log(s) using a catalog @@ -332,7 +325,6 @@ int llog_cat_add_rec(const struct lu_env *env, struct llog_handle *cathandle, { struct llog_handle *loghandle; int rc; - ENTRY; LASSERT(rec->lrh_len <= LLOG_CHUNK_SIZE); loghandle = llog_cat_current_log(cathandle, th); @@ -343,7 +335,7 @@ int llog_cat_add_rec(const struct lu_env *env, struct llog_handle *cathandle, rc = llog_cat_new_log(env, cathandle, loghandle, th); if (rc < 0) { up_write(&loghandle->lgh_lock); - RETURN(rc); + return rc; } } /* now let's try to add the record */ @@ -361,7 +353,7 @@ int llog_cat_add_rec(const struct lu_env *env, struct llog_handle *cathandle, rc = llog_cat_new_log(env, cathandle, loghandle, th); if (rc < 0) { up_write(&loghandle->lgh_lock); - RETURN(rc); + return rc; } } /* now let's try to add the record */ @@ -372,7 +364,7 @@ int llog_cat_add_rec(const struct lu_env *env, struct llog_handle *cathandle, up_write(&loghandle->lgh_lock); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_add_rec); @@ -383,8 +375,6 @@ int llog_cat_declare_add_rec(const struct lu_env *env, struct llog_handle *loghandle, *next; int rc = 0; - ENTRY; - if (cathandle->u.chd.chd_current_log == NULL) { /* declare new plain llog */ down_write(&cathandle->lgh_lock); @@ -437,7 +427,7 @@ int llog_cat_declare_add_rec(const struct lu_env *env, llog_declare_write_rec(env, next, rec, -1, th); } out: - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_declare_add_rec); @@ -460,7 +450,7 @@ int llog_cat_add(const struct lu_env *env, struct llog_handle *cathandle, th = dt_trans_create(env, dt); if (IS_ERR(th)) - RETURN(PTR_ERR(th)); + return PTR_ERR(th); rc = llog_cat_declare_add_rec(env, cathandle, rec, th); if (rc) @@ -479,7 +469,7 @@ out_trans: rc = llog_cat_add_rec(env, cathandle, rec, reccookie, buf, th); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_add); @@ -498,8 +488,6 @@ int llog_cat_cancel_records(const struct lu_env *env, { int i, index, rc = 0, failed = 0; - ENTRY; - for (i = 0; i < count; i++, cookies++) { struct llog_handle *loghandle; struct llog_logid *lgl = &cookies->lgc_lgl; @@ -533,7 +521,7 @@ int llog_cat_cancel_records(const struct lu_env *env, cathandle->lgh_ctxt->loc_obd->obd_name, failed, count, rc); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_cancel_records); @@ -545,10 +533,9 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh, struct llog_handle *llh; int rc; - ENTRY; if (rec->lrh_type != LLOG_LOGID_MAGIC) { CERROR("invalid record in catalog\n"); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_HA, "processing log "DOSTID":%x at index %u of catalog " DOSTID"\n", POSTID(&lir->lid_id.lgl_oi), lir->lid_id.lgl_ogen, @@ -559,12 +546,12 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh, CERROR("%s: cannot find handle for llog "DOSTID": %d\n", cat_llh->lgh_ctxt->loc_obd->obd_name, POSTID(&lir->lid_id.lgl_oi), rc); - RETURN(rc); + return rc; } if (rec->lrh_index < d->lpd_startcat) /* Skip processing of the logs until startcat */ - RETURN(0); + return 0; if (d->lpd_startidx > 0) { struct llog_process_cat_data cd; @@ -581,7 +568,7 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh, } llog_handle_put(llh); - RETURN(rc); + return rc; } int llog_cat_process_or_fork(const struct lu_env *env, @@ -592,7 +579,6 @@ int llog_cat_process_or_fork(const struct lu_env *env, struct llog_process_data d; struct llog_log_hdr *llh = cat_llh->lgh_hdr; int rc; - ENTRY; LASSERT(llh->llh_flags & LLOG_F_IS_CAT); d.lpd_data = data; @@ -611,7 +597,7 @@ int llog_cat_process_or_fork(const struct lu_env *env, rc = llog_process_or_fork(env, cat_llh, llog_cat_process_cb, &d, &cd, fork); if (rc != 0) - RETURN(rc); + return rc; cd.lpcd_first_idx = 0; cd.lpcd_last_idx = cat_llh->lgh_last_idx; @@ -622,7 +608,7 @@ int llog_cat_process_or_fork(const struct lu_env *env, &d, NULL, fork); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_process_or_fork); @@ -645,7 +631,7 @@ static int llog_cat_reverse_process_cb(const struct lu_env *env, if (le32_to_cpu(rec->lrh_type) != LLOG_LOGID_MAGIC) { CERROR("invalid record in catalog\n"); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_HA, "processing log "DOSTID":%x at index %u of catalog " DOSTID"\n", POSTID(&lir->lid_id.lgl_oi), lir->lid_id.lgl_ogen, @@ -656,12 +642,12 @@ static int llog_cat_reverse_process_cb(const struct lu_env *env, CERROR("%s: cannot find handle for llog "DOSTID": %d\n", cat_llh->lgh_ctxt->loc_obd->obd_name, POSTID(&lir->lid_id.lgl_oi), rc); - RETURN(rc); + return rc; } rc = llog_reverse_process(env, llh, d->lpd_cb, d->lpd_data, NULL); llog_handle_put(llh); - RETURN(rc); + return rc; } int llog_cat_reverse_process(const struct lu_env *env, @@ -672,7 +658,6 @@ int llog_cat_reverse_process(const struct lu_env *env, struct llog_process_cat_data cd; struct llog_log_hdr *llh = cat_llh->lgh_hdr; int rc; - ENTRY; LASSERT(llh->llh_flags & LLOG_F_IS_CAT); d.lpd_data = data; @@ -688,7 +673,7 @@ int llog_cat_reverse_process(const struct lu_env *env, llog_cat_reverse_process_cb, &d, &cd); if (rc != 0) - RETURN(rc); + return rc; cd.lpcd_first_idx = le32_to_cpu(llh->llh_cat_idx); cd.lpcd_last_idx = 0; @@ -701,7 +686,7 @@ int llog_cat_reverse_process(const struct lu_env *env, &d, NULL); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_reverse_process); @@ -709,7 +694,6 @@ int llog_cat_set_first_idx(struct llog_handle *cathandle, int index) { struct llog_log_hdr *llh = cathandle->lgh_hdr; int i, bitmap_size, idx; - ENTRY; bitmap_size = LLOG_BITMAP_SIZE(llh); if (llh->llh_cat_idx == (index - 1)) { @@ -734,7 +718,7 @@ out: POSTID(&cathandle->lgh_id.lgl_oi), llh->llh_cat_idx); } - RETURN(0); + return 0; } /* Cleanup deleted plain llog traces from catalog */ @@ -774,11 +758,9 @@ int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle, struct llog_log_hdr *llh; int rc; - ENTRY; - if (rec->lrh_type != LLOG_LOGID_MAGIC) { CERROR("invalid record in catalog\n"); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_HA, "processing log "DOSTID":%x at index %u of catalog " @@ -794,7 +776,7 @@ int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle, /* remove index from catalog */ llog_cat_cleanup(env, cathandle, NULL, rec->lrh_index); } - RETURN(rc); + return rc; } llh = loghandle->lgh_hdr; @@ -810,7 +792,7 @@ int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle, } llog_handle_put(loghandle); - RETURN(rc); + return rc; } EXPORT_SYMBOL(cat_cancel_cb); @@ -822,12 +804,12 @@ int llog_cat_init_and_process(const struct lu_env *env, rc = llog_init_handle(env, llh, LLOG_F_IS_CAT, NULL); if (rc) - RETURN(rc); + return rc; rc = llog_process_or_fork(env, llh, cat_cancel_cb, NULL, NULL, false); if (rc) CERROR("%s: llog_process() with cat_cancel_cb failed: rc = " "%d\n", llh->lgh_ctxt->loc_obd->obd_name, rc); - RETURN(0); + return 0; } EXPORT_SYMBOL(llog_cat_init_and_process); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c b/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c index 0732874e26c..da558a5dc92 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c @@ -45,46 +45,45 @@ static int str2logid(struct llog_logid *logid, char *str, int len) char *start, *end, *endp; __u64 id, seq; - ENTRY; start = str; if (*start != '#') - RETURN(-EINVAL); + return -EINVAL; start++; if (start - str >= len - 1) - RETURN(-EINVAL); + return -EINVAL; end = strchr(start, '#'); if (end == NULL || end == start) - RETURN(-EINVAL); + return -EINVAL; *end = '\0'; id = simple_strtoull(start, &endp, 0); if (endp != end) - RETURN(-EINVAL); + return -EINVAL; start = ++end; if (start - str >= len - 1) - RETURN(-EINVAL); + return -EINVAL; end = strchr(start, '#'); if (end == NULL || end == start) - RETURN(-EINVAL); + return -EINVAL; *end = '\0'; seq = simple_strtoull(start, &endp, 0); if (endp != end) - RETURN(-EINVAL); + return -EINVAL; ostid_set_seq(&logid->lgl_oi, seq); ostid_set_id(&logid->lgl_oi, id); start = ++end; if (start - str >= len - 1) - RETURN(-EINVAL); + return -EINVAL; logid->lgl_ogen = simple_strtoul(start, &endp, 16); if (*endp != '\0') - RETURN(-EINVAL); + return -EINVAL; - RETURN(0); + return 0; } static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, @@ -96,8 +95,6 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, char *endp; int cur_index, rc = 0; - ENTRY; - if (ioc_data && ioc_data->ioc_inllen1 > 0) { l = 0; remains = ioc_data->ioc_inllen4 + @@ -106,19 +103,19 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, cfs_size_round(ioc_data->ioc_inllen3); from = simple_strtol(ioc_data->ioc_inlbuf2, &endp, 0); if (*endp != '\0') - RETURN(-EINVAL); + return -EINVAL; to = simple_strtol(ioc_data->ioc_inlbuf3, &endp, 0); if (*endp != '\0') - RETURN(-EINVAL); + return -EINVAL; ioc_data->ioc_inllen1 = 0; out = ioc_data->ioc_bulk; } cur_index = rec->lrh_index; if (cur_index < from) - RETURN(0); + return 0; if (to > 0 && cur_index > to) - RETURN(-LLOG_EEMPTY); + return -LLOG_EEMPTY; if (handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) { struct llog_logid_rec *lir = (struct llog_logid_rec *)rec; @@ -131,13 +128,13 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, rec->lrh_len); } if (handle->lgh_ctxt == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = llog_cat_id2handle(env, handle, &loghandle, &lir->lid_id); if (rc) { CDEBUG(D_IOCTL, "cannot find log #"DOSTID"#%08x\n", POSTID(&lir->lid_id.lgl_oi), lir->lid_id.lgl_ogen); - RETURN(rc); + return rc; } rc = llog_process(env, loghandle, llog_check_cb, NULL, NULL); llog_handle_put(loghandle); @@ -167,10 +164,10 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, if (remains <= 0) { CERROR("%s: no space to print log records\n", handle->lgh_ctxt->loc_obd->obd_name); - RETURN(-LLOG_EEMPTY); + return -LLOG_EEMPTY; } } - RETURN(rc); + return rc; } static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, @@ -182,7 +179,6 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, char *endp; int cur_index; - ENTRY; if (ioc_data != NULL && ioc_data->ioc_inllen1 > 0) { l = 0; remains = ioc_data->ioc_inllen4 + @@ -191,26 +187,26 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, cfs_size_round(ioc_data->ioc_inllen3); from = simple_strtol(ioc_data->ioc_inlbuf2, &endp, 0); if (*endp != '\0') - RETURN(-EINVAL); + return -EINVAL; to = simple_strtol(ioc_data->ioc_inlbuf3, &endp, 0); if (*endp != '\0') - RETURN(-EINVAL); + return -EINVAL; out = ioc_data->ioc_bulk; ioc_data->ioc_inllen1 = 0; } cur_index = rec->lrh_index; if (cur_index < from) - RETURN(0); + return 0; if (to > 0 && cur_index > to) - RETURN(-LLOG_EEMPTY); + return -LLOG_EEMPTY; if (handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) { struct llog_logid_rec *lir = (struct llog_logid_rec *)rec; if (rec->lrh_type != LLOG_LOGID_MAGIC) { CERROR("invalid record in catalog\n"); - RETURN(-EINVAL); + return -EINVAL; } l = snprintf(out, remains, @@ -222,7 +218,7 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, rc = class_config_parse_rec(rec, out, remains); if (rc < 0) - RETURN(rc); + return rc; l = rc; } else { l = snprintf(out, remains, @@ -233,10 +229,10 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, remains -= l; if (remains <= 0) { CERROR("not enough space for print log records\n"); - RETURN(-LLOG_EEMPTY); + return -LLOG_EEMPTY; } - RETURN(0); + return 0; } static int llog_remove_log(const struct lu_env *env, struct llog_handle *cat, struct llog_logid *logid) @@ -244,13 +240,11 @@ static int llog_remove_log(const struct lu_env *env, struct llog_handle *cat, struct llog_handle *log; int rc; - ENTRY; - rc = llog_cat_id2handle(env, cat, &log, logid); if (rc) { CDEBUG(D_IOCTL, "cannot find log #"DOSTID"#%08x\n", POSTID(&logid->lgl_oi), logid->lgl_ogen); - RETURN(-ENOENT); + return -ENOENT; } rc = llog_destroy(env, log); @@ -261,7 +255,7 @@ static int llog_remove_log(const struct lu_env *env, struct llog_handle *cat, llog_cat_cleanup(env, cat, log, log->u.phd.phd_cookie.lgc_index); out: llog_handle_put(log); - RETURN(rc); + return rc; } @@ -271,12 +265,11 @@ static int llog_delete_cb(const struct lu_env *env, struct llog_handle *handle, struct llog_logid_rec *lir = (struct llog_logid_rec *)rec; int rc; - ENTRY; if (rec->lrh_type != LLOG_LOGID_MAGIC) - RETURN(-EINVAL); + return -EINVAL; rc = llog_remove_log(env, handle, &lir->lid_id); - RETURN(rc); + return rc; } @@ -287,25 +280,23 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd, int rc = 0; struct llog_handle *handle = NULL; - ENTRY; - if (*data->ioc_inlbuf1 == '#') { rc = str2logid(&logid, data->ioc_inlbuf1, data->ioc_inllen1); if (rc) - RETURN(rc); + return rc; rc = llog_open(env, ctxt, &handle, &logid, NULL, LLOG_OPEN_EXISTS); if (rc) - RETURN(rc); + return rc; } else if (*data->ioc_inlbuf1 == '$') { char *name = data->ioc_inlbuf1 + 1; rc = llog_open(env, ctxt, &handle, NULL, name, LLOG_OPEN_EXISTS); if (rc) - RETURN(rc); + return rc; } else { - RETURN(-EINVAL); + return -EINVAL; } rc = llog_init_handle(env, handle, 0, NULL); @@ -422,6 +413,6 @@ out_close: llog_cat_close(env, handle); else llog_close(env, handle); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_ioctl); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c b/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c index 7e12dc62141..5385d8e658c 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c @@ -64,7 +64,6 @@ static int llog_lvfs_pad(struct obd_device *obd, struct l_file *file, struct llog_rec_hdr rec = { 0 }; struct llog_rec_tail tail; int rc; - ENTRY; LASSERT(len >= LLOG_MIN_REC_SIZE && (len & 0x7) == 0); @@ -86,7 +85,7 @@ static int llog_lvfs_pad(struct obd_device *obd, struct l_file *file, } out: - RETURN(rc); + return rc; } static int llog_lvfs_write_blob(struct obd_device *obd, struct l_file *file, @@ -97,8 +96,6 @@ static int llog_lvfs_write_blob(struct obd_device *obd, struct l_file *file, loff_t saved_off = file->f_pos; int buflen = rec->lrh_len; - ENTRY; - file->f_pos = off; if (buflen == 0) @@ -140,7 +137,7 @@ static int llog_lvfs_write_blob(struct obd_device *obd, struct l_file *file, if (saved_off > file->f_pos) file->f_pos = saved_off; LASSERT(rc <= 0); - RETURN(rc); + return rc; } static int llog_lvfs_read_blob(struct obd_device *obd, struct l_file *file, @@ -148,14 +145,13 @@ static int llog_lvfs_read_blob(struct obd_device *obd, struct l_file *file, { loff_t offset = off; int rc; - ENTRY; rc = fsfilt_read_record(obd, file, buf, size, &offset); if (rc) { CERROR("error reading log record: rc %d\n", rc); - RETURN(rc); + return rc; } - RETURN(0); + return 0; } static int llog_lvfs_read_header(const struct lu_env *env, @@ -163,7 +159,6 @@ static int llog_lvfs_read_header(const struct lu_env *env, { struct obd_device *obd; int rc; - ENTRY; LASSERT(sizeof(*handle->lgh_hdr) == LLOG_CHUNK_SIZE); @@ -171,7 +166,7 @@ static int llog_lvfs_read_header(const struct lu_env *env, if (i_size_read(handle->lgh_file->f_dentry->d_inode) == 0) { CDEBUG(D_HA, "not reading header from 0-byte log\n"); - RETURN(LLOG_EEMPTY); + return LLOG_EEMPTY; } rc = llog_lvfs_read_blob(obd, handle->lgh_file, handle->lgh_hdr, @@ -206,7 +201,7 @@ static int llog_lvfs_read_header(const struct lu_env *env, handle->lgh_last_idx = handle->lgh_hdr->llh_tail.lrt_index; handle->lgh_file->f_pos = i_size_read(handle->lgh_file->f_dentry->d_inode); - RETURN(rc); + return rc; } /* returns negative in on error; 0 if success && reccookie == 0; 1 otherwise */ @@ -223,7 +218,6 @@ static int llog_lvfs_write_rec(const struct lu_env *env, struct obd_device *obd; struct file *file; size_t left; - ENTRY; llh = loghandle->lgh_hdr; file = loghandle->lgh_file; @@ -236,7 +230,7 @@ static int llog_lvfs_write_rec(const struct lu_env *env, else rc = (reclen > LLOG_CHUNK_SIZE) ? -E2BIG : 0; if (rc) - RETURN(rc); + return rc; if (buf) /* write_blob adds header and tail to lrh_len. */ @@ -253,7 +247,7 @@ static int llog_lvfs_write_rec(const struct lu_env *env, } if (idx && llh->llh_size && llh->llh_size != rec->lrh_len) - RETURN(-EINVAL); + return -EINVAL; if (!ext2_test_bit(idx, llh->llh_bitmap)) CERROR("Modify unset record %u\n", idx); @@ -263,7 +257,7 @@ static int llog_lvfs_write_rec(const struct lu_env *env, rc = llog_lvfs_write_blob(obd, file, &llh->llh_hdr, NULL, 0); /* we are done if we only write the header or on error */ if (rc || idx == 0) - RETURN(rc); + return rc; if (buf) { /* We assume that caller has set lgh_cur_* */ @@ -277,7 +271,7 @@ static int llog_lvfs_write_rec(const struct lu_env *env, if (rec->lrh_index != loghandle->lgh_cur_idx) { CERROR("modify idx mismatch %u/%d\n", idx, loghandle->lgh_cur_idx); - RETURN(-EFAULT); + return -EFAULT; } } else { /* Assumes constant lrh_len */ @@ -290,7 +284,7 @@ static int llog_lvfs_write_rec(const struct lu_env *env, reccookie->lgc_index = idx; rc = 1; } - RETURN(rc); + return rc; } /* Make sure that records don't cross a chunk boundary, so we can @@ -308,12 +302,12 @@ static int llog_lvfs_write_rec(const struct lu_env *env, index = loghandle->lgh_last_idx + 1; rc = llog_lvfs_pad(obd, file, left, index); if (rc) - RETURN(rc); + return rc; loghandle->lgh_last_idx++; /*for pad rec*/ } /* if it's the last idx in log file, then return -ENOSPC */ if (loghandle->lgh_last_idx >= LLOG_BITMAP_SIZE(llh) - 1) - RETURN(-ENOSPC); + return -ENOSPC; loghandle->lgh_last_idx++; index = loghandle->lgh_last_idx; LASSERT(index < LLOG_BITMAP_SIZE(llh)); @@ -339,11 +333,11 @@ static int llog_lvfs_write_rec(const struct lu_env *env, rc = llog_lvfs_write_blob(obd, file, &llh->llh_hdr, NULL, 0); if (rc) - RETURN(rc); + return rc; rc = llog_lvfs_write_blob(obd, file, rec, buf, file->f_pos); if (rc) - RETURN(rc); + return rc; CDEBUG(D_RPCTRACE, "added record "DOSTID": idx: %u, %u \n", POSTID(&loghandle->lgh_id.lgl_oi), index, rec->lrh_len); @@ -362,7 +356,7 @@ static int llog_lvfs_write_rec(const struct lu_env *env, if (rc == 0 && rec->lrh_type == LLOG_GEN_REC) rc = 1; - RETURN(rc); + return rc; } /* We can skip reading at least as many log blocks as the number of @@ -391,10 +385,9 @@ static int llog_lvfs_next_block(const struct lu_env *env, int len) { int rc; - ENTRY; if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off "LPU64")\n", next_idx, *cur_idx, *cur_offset); @@ -419,7 +412,7 @@ static int llog_lvfs_next_block(const struct lu_env *env, POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, *cur_offset); - RETURN(rc); + return rc; } /* put number of bytes read into rc to make code simpler */ @@ -430,13 +423,13 @@ static int llog_lvfs_next_block(const struct lu_env *env, } if (rc == 0) /* end of file, nothing to do */ - RETURN(0); + return 0; if (rc < sizeof(*tail)) { CERROR("Invalid llog block at log id "DOSTID"/%u offset" LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, *cur_offset); - RETURN(-EINVAL); + return -EINVAL; } rec = buf; @@ -461,7 +454,7 @@ static int llog_lvfs_next_block(const struct lu_env *env, CERROR("Invalid llog tail at log id "DOSTID"/%u offset " LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, *cur_offset); - RETURN(-EINVAL); + return -EINVAL; } if (tail->lrt_index < next_idx) continue; @@ -471,11 +464,11 @@ static int llog_lvfs_next_block(const struct lu_env *env, if (rec->lrh_index > next_idx) { CERROR("missed desired record? %u > %u\n", rec->lrh_index, next_idx); - RETURN(-ENOENT); + return -ENOENT; } - RETURN(0); + return 0; } - RETURN(-EIO); + return -EIO; } static int llog_lvfs_prev_block(const struct lu_env *env, @@ -484,10 +477,9 @@ static int llog_lvfs_prev_block(const struct lu_env *env, { __u64 cur_offset; int rc; - ENTRY; if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_OTHER, "looking for log index %u\n", prev_idx); @@ -508,20 +500,20 @@ static int llog_lvfs_prev_block(const struct lu_env *env, POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, cur_offset); - RETURN(rc); + return rc; } /* put number of bytes read into rc to make code simpler */ rc = cur_offset - ppos; if (rc == 0) /* end of file, nothing to do */ - RETURN(0); + return 0; if (rc < sizeof(*tail)) { CERROR("Invalid llog block at log id "DOSTID"/%u offset" LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, cur_offset); - RETURN(-EINVAL); + return -EINVAL; } rec = buf; @@ -544,7 +536,7 @@ static int llog_lvfs_prev_block(const struct lu_env *env, CERROR("Invalid llog tail at log id "DOSTID"/%u offset" LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, cur_offset); - RETURN(-EINVAL); + return -EINVAL; } if (tail->lrt_index < prev_idx) continue; @@ -554,11 +546,11 @@ static int llog_lvfs_prev_block(const struct lu_env *env, if (rec->lrh_index > prev_idx) { CERROR("missed desired record? %u > %u\n", rec->lrh_index, prev_idx); - RETURN(-ENOENT); + return -ENOENT; } - RETURN(0); + return 0; } - RETURN(-EIO); + return -EIO; } static struct file *llog_filp_open(char *dir, char *name, int flags, int mode) @@ -593,8 +585,6 @@ static int llog_lvfs_open(const struct lu_env *env, struct llog_handle *handle, struct obd_device *obd; int rc = 0; - ENTRY; - LASSERT(ctxt); LASSERT(ctxt->loc_exp); LASSERT(ctxt->loc_exp->exp_obd); @@ -661,12 +651,12 @@ static int llog_lvfs_open(const struct lu_env *env, struct llog_handle *handle, if (open_param != LLOG_OPEN_NEW && handle->lgh_file == NULL) GOTO(out_name, rc = -ENOENT); - RETURN(0); + return 0; out_name: if (handle->lgh_name != NULL) OBD_FREE(handle->lgh_name, strlen(name) + 1); out: - RETURN(rc); + return rc; } static int llog_lvfs_exist(struct llog_handle *handle) @@ -688,8 +678,6 @@ static int llog_lvfs_create(const struct lu_env *env, int rc = 0; int open_flags = O_RDWR | O_CREAT | O_LARGEFILE; - ENTRY; - LASSERT(ctxt); LASSERT(ctxt->loc_exp); obd = ctxt->loc_exp->exp_obd; @@ -699,7 +687,7 @@ static int llog_lvfs_create(const struct lu_env *env, file = llog_filp_open(MOUNT_CONFIGS_DIR, handle->lgh_name, open_flags, 0644); if (IS_ERR(file)) - RETURN(PTR_ERR(file)); + return PTR_ERR(file); lustre_build_llog_lvfs_oid(&handle->lgh_id, file->f_dentry->d_inode->i_ino, @@ -708,7 +696,7 @@ static int llog_lvfs_create(const struct lu_env *env, } else { OBDO_ALLOC(oa); if (oa == NULL) - RETURN(-ENOMEM); + return -ENOMEM; ostid_set_seq_llog(&oa->o_oi); oa->o_valid = OBD_MD_FLGENER | OBD_MD_FLGROUP; @@ -736,7 +724,7 @@ static int llog_lvfs_create(const struct lu_env *env, out: OBDO_FREE(oa); } - RETURN(rc); + return rc; } static int llog_lvfs_close(const struct lu_env *env, @@ -744,10 +732,8 @@ static int llog_lvfs_close(const struct lu_env *env, { int rc; - ENTRY; - if (handle->lgh_file == NULL) - RETURN(0); + return 0; rc = filp_close(handle->lgh_file, 0); if (rc) CERROR("%s: error closing llog #"DOSTID"#%08x: " @@ -759,7 +745,7 @@ static int llog_lvfs_close(const struct lu_env *env, OBD_FREE(handle->lgh_name, strlen(handle->lgh_name) + 1); handle->lgh_name = NULL; } - RETURN(rc); + return rc; } static int llog_lvfs_destroy(const struct lu_env *env, @@ -772,7 +758,6 @@ static int llog_lvfs_destroy(const struct lu_env *env, void *th; struct inode *inode; int rc, rc1; - ENTRY; dir = MOUNT_CONFIGS_DIR; @@ -795,12 +780,12 @@ static int llog_lvfs_destroy(const struct lu_env *env, dput(fdentry); pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - RETURN(rc); + return rc; } OBDO_ALLOC(oa); if (oa == NULL) - RETURN(-ENOMEM); + return -ENOMEM; oa->o_oi = handle->lgh_id.lgl_oi; oa->o_generation = handle->lgh_id.lgl_ogen; @@ -825,7 +810,7 @@ static int llog_lvfs_destroy(const struct lu_env *env, rc = rc1; out: OBDO_FREE(oa); - RETURN(rc); + return rc; } static int llog_lvfs_declare_create(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 7e229079631..71817af7539 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -110,7 +110,6 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); struct obd_llog_group *olg; int rc, idx; - ENTRY; LASSERT(ctxt != NULL); LASSERT(ctxt != LP_POISON); @@ -139,7 +138,7 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) l_wait_event(olg->olg_waitq, llog_group_ctxt_null(olg, idx), &lwi); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cleanup); @@ -149,16 +148,15 @@ int llog_setup(const struct lu_env *env, struct obd_device *obd, { struct llog_ctxt *ctxt; int rc = 0; - ENTRY; if (index < 0 || index >= LLOG_MAX_CTXTS) - RETURN(-EINVAL); + return -EINVAL; LASSERT(olg != NULL); ctxt = llog_new_ctxt(obd); if (!ctxt) - RETURN(-ENOMEM); + return -ENOMEM; ctxt->loc_obd = obd; ctxt->loc_olg = olg; @@ -189,7 +187,7 @@ int llog_setup(const struct lu_env *env, struct obd_device *obd, } rc = 0; } - RETURN(rc); + return rc; } if (op->lop_setup) { @@ -210,22 +208,21 @@ int llog_setup(const struct lu_env *env, struct obd_device *obd, ctxt->loc_flags &= ~LLOG_CTXT_FLAG_UNINITIALIZED; } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_setup); int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags) { int rc = 0; - ENTRY; if (!ctxt) - RETURN(0); + return 0; if (CTXTP(ctxt, sync)) rc = CTXTP(ctxt, sync)(ctxt, exp, flags); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_sync); @@ -234,15 +231,14 @@ int llog_obd_add(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_cookie *logcookies, int numcookies) { int raised, rc; - ENTRY; if (!ctxt) { CERROR("No ctxt\n"); - RETURN(-ENODEV); + return -ENODEV; } if (ctxt->loc_flags & LLOG_CTXT_FLAG_UNINITIALIZED) - RETURN(-ENXIO); + return -ENXIO; CTXT_CHECK_OP(ctxt, obd_add, -EOPNOTSUPP); raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); @@ -252,7 +248,7 @@ int llog_obd_add(const struct lu_env *env, struct llog_ctxt *ctxt, numcookies); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_obd_add); @@ -261,16 +257,15 @@ int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_cookie *cookies, int flags) { int rc; - ENTRY; if (!ctxt) { CERROR("No ctxt\n"); - RETURN(-ENODEV); + return -ENODEV; } CTXT_CHECK_OP(ctxt, cancel, -EOPNOTSUPP); rc = CTXTP(ctxt, cancel)(env, ctxt, lsm, count, cookies, flags); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cancel); @@ -278,24 +273,24 @@ int obd_llog_init(struct obd_device *obd, struct obd_llog_group *olg, struct obd_device *disk_obd, int *index) { int rc; - ENTRY; + OBD_CHECK_DT_OP(obd, llog_init, 0); OBD_COUNTER_INCREMENT(obd, llog_init); rc = OBP(obd, llog_init)(obd, olg, disk_obd, index); - RETURN(rc); + return rc; } EXPORT_SYMBOL(obd_llog_init); int obd_llog_finish(struct obd_device *obd, int count) { int rc; - ENTRY; + OBD_CHECK_DT_OP(obd, llog_finish, 0); OBD_COUNTER_INCREMENT(obd, llog_finish); rc = OBP(obd, llog_finish)(obd, count); - RETURN(rc); + return rc; } EXPORT_SYMBOL(obd_llog_finish); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_osd.c b/drivers/staging/lustre/lustre/obdclass/llog_osd.c index 6dbd21a863c..654c8e18965 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_osd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_osd.c @@ -41,10 +41,6 @@ #define DEBUG_SUBSYSTEM S_LOG -#ifndef EXPORT_SYMTAB -#define EXPORT_SYMTAB -#endif - #include <obd.h> #include <obd_class.h> #include <lustre_fid.h> @@ -97,8 +93,6 @@ static int llog_osd_pad(const struct lu_env *env, struct dt_object *o, struct llog_thread_info *lgi = llog_info(env); int rc; - ENTRY; - LASSERT(th); LASSERT(off); LASSERT(len >= LLOG_MIN_REC_SIZE && (len & 0x7) == 0); @@ -126,7 +120,7 @@ static int llog_osd_pad(const struct lu_env *env, struct dt_object *o, o->do_lu.lo_dev->ld_obd->obd_name, rc); out: dt_write_unlock(env, o); - RETURN(rc); + return rc; } static int llog_osd_write_blob(const struct lu_env *env, struct dt_object *o, @@ -137,8 +131,6 @@ static int llog_osd_write_blob(const struct lu_env *env, struct dt_object *o, int buflen = rec->lrh_len; int rc; - ENTRY; - LASSERT(env); LASSERT(o); @@ -203,7 +195,7 @@ out: dt_attr_set(env, o, &lgi->lgi_attr, th, BYPASS_CAPA); } - RETURN(rc); + return rc; } static int llog_osd_read_header(const struct lu_env *env, @@ -214,8 +206,6 @@ static int llog_osd_read_header(const struct lu_env *env, struct llog_thread_info *lgi; int rc; - ENTRY; - LASSERT(sizeof(*handle->lgh_hdr) == LLOG_CHUNK_SIZE); o = handle->lgh_obj; @@ -225,13 +215,13 @@ static int llog_osd_read_header(const struct lu_env *env, rc = dt_attr_get(env, o, &lgi->lgi_attr, NULL); if (rc) - RETURN(rc); + return rc; LASSERT(lgi->lgi_attr.la_valid & LA_SIZE); if (lgi->lgi_attr.la_size == 0) { CDEBUG(D_HA, "not reading header from 0-byte log\n"); - RETURN(LLOG_EEMPTY); + return LLOG_EEMPTY; } lgi->lgi_off = 0; @@ -243,7 +233,7 @@ static int llog_osd_read_header(const struct lu_env *env, CERROR("%s: error reading log header from "DFID": rc = %d\n", o->do_lu.lo_dev->ld_obd->obd_name, PFID(lu_object_fid(&o->do_lu)), rc); - RETURN(rc); + return rc; } llh_hdr = &handle->lgh_hdr->llh_hdr; @@ -256,7 +246,7 @@ static int llog_osd_read_header(const struct lu_env *env, handle->lgh_name ? handle->lgh_name : "", PFID(lu_object_fid(&o->do_lu)), llh_hdr->lrh_type, LLOG_HDR_MAGIC); - RETURN(-EIO); + return -EIO; } else if (llh_hdr->lrh_len != LLOG_CHUNK_SIZE) { CERROR("%s: incorrectly sized log %s "DFID" header: " "%#x (expected %#x)\n" @@ -265,12 +255,12 @@ static int llog_osd_read_header(const struct lu_env *env, handle->lgh_name ? handle->lgh_name : "", PFID(lu_object_fid(&o->do_lu)), llh_hdr->lrh_len, LLOG_CHUNK_SIZE); - RETURN(-EIO); + return -EIO; } handle->lgh_last_idx = handle->lgh_hdr->llh_tail.lrt_index; - RETURN(0); + return 0; } static int llog_osd_declare_write_rec(const struct lu_env *env, @@ -282,8 +272,6 @@ static int llog_osd_declare_write_rec(const struct lu_env *env, struct dt_object *o; int rc; - ENTRY; - LASSERT(env); LASSERT(th); LASSERT(loghandle); @@ -295,18 +283,18 @@ static int llog_osd_declare_write_rec(const struct lu_env *env, rc = dt_declare_record_write(env, o, sizeof(struct llog_log_hdr), 0, th); if (rc || idx == 0) /* if error or just header */ - RETURN(rc); + return rc; if (dt_object_exists(o)) { rc = dt_attr_get(env, o, &lgi->lgi_attr, BYPASS_CAPA); lgi->lgi_off = lgi->lgi_attr.la_size; LASSERT(ergo(rc == 0, lgi->lgi_attr.la_valid & LA_SIZE)); if (rc) - RETURN(rc); + return rc; rc = dt_declare_punch(env, o, lgi->lgi_off, OBD_OBJECT_EOF, th); if (rc) - RETURN(rc); + return rc; } else { lgi->lgi_off = 0; } @@ -314,7 +302,7 @@ static int llog_osd_declare_write_rec(const struct lu_env *env, /* XXX: implement declared window or multi-chunks approach */ rc = dt_declare_record_write(env, o, 32 * 1024, lgi->lgi_off, th); - RETURN(rc); + return rc; } /* returns negative in on error; 0 if success && reccookie == 0; 1 otherwise */ @@ -333,8 +321,6 @@ static int llog_osd_write_rec(const struct lu_env *env, struct dt_object *o; size_t left; - ENTRY; - LASSERT(env); llh = loghandle->lgh_hdr; LASSERT(llh); @@ -352,11 +338,11 @@ static int llog_osd_write_rec(const struct lu_env *env, else rc = (reclen > LLOG_CHUNK_SIZE) ? -E2BIG : 0; if (rc) - RETURN(rc); + return rc; rc = dt_attr_get(env, o, &lgi->lgi_attr, NULL); if (rc) - RETURN(rc); + return rc; if (buf) /* write_blob adds header and tail to lrh_len. */ @@ -369,7 +355,7 @@ static int llog_osd_write_rec(const struct lu_env *env, LBUG(); if (idx && llh->llh_size && llh->llh_size != rec->lrh_len) - RETURN(-EINVAL); + return -EINVAL; if (!ext2_test_bit(idx, llh->llh_bitmap)) CERROR("%s: modify unset record %u\n", @@ -384,7 +370,7 @@ static int llog_osd_write_rec(const struct lu_env *env, &lgi->lgi_off, th); /* we are done if we only write the header or on error */ if (rc || idx == 0) - RETURN(rc); + return rc; if (buf) { /* We assume that caller has set lgh_cur_* */ @@ -400,7 +386,7 @@ static int llog_osd_write_rec(const struct lu_env *env, CERROR("%s: modify idx mismatch %u/%d\n", o->do_lu.lo_dev->ld_obd->obd_name, idx, loghandle->lgh_cur_idx); - RETURN(-EFAULT); + return -EFAULT; } } else { /* Assumes constant lrh_len */ @@ -413,7 +399,7 @@ static int llog_osd_write_rec(const struct lu_env *env, reccookie->lgc_index = idx; rc = 1; } - RETURN(rc); + return rc; } /* Make sure that records don't cross a chunk boundary, so we can @@ -432,12 +418,12 @@ static int llog_osd_write_rec(const struct lu_env *env, index = loghandle->lgh_last_idx + 1; rc = llog_osd_pad(env, o, &lgi->lgi_off, left, index, th); if (rc) - RETURN(rc); + return rc; loghandle->lgh_last_idx++; /*for pad rec*/ } /* if it's the last idx in log file, then return -ENOSPC */ if (loghandle->lgh_last_idx >= LLOG_BITMAP_SIZE(llh) - 1) - RETURN(-ENOSPC); + return -ENOSPC; loghandle->lgh_last_idx++; index = loghandle->lgh_last_idx; @@ -509,7 +495,7 @@ out: reccookie->lgc_subsys = -1; rc = 1; } - RETURN(rc); + return rc; } /* We can skip reading at least as many log blocks as the number of @@ -541,13 +527,11 @@ static int llog_osd_next_block(const struct lu_env *env, struct dt_device *dt; int rc; - ENTRY; - LASSERT(env); LASSERT(lgi); if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off "LPU64")\n", next_idx, *cur_idx, *cur_offset); @@ -668,10 +652,8 @@ static int llog_osd_prev_block(const struct lu_env *env, loff_t cur_offset; int rc; - ENTRY; - if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_OTHER, "looking for log index %u\n", prev_idx); @@ -798,8 +780,6 @@ static int llog_osd_open(const struct lu_env *env, struct llog_handle *handle, struct local_oid_storage *los; int rc = 0; - ENTRY; - LASSERT(env); LASSERT(ctxt); LASSERT(ctxt->loc_exp); @@ -809,7 +789,7 @@ static int llog_osd_open(const struct lu_env *env, struct llog_handle *handle, ls = ls_device_get(dt); if (IS_ERR(ls)) - RETURN(PTR_ERR(ls)); + return PTR_ERR(ls); mutex_lock(&ls->ls_los_mutex); los = dt_los_find(ls, name != NULL ? FID_SEQ_LLOG_NAME : FID_SEQ_LLOG); @@ -864,7 +844,7 @@ static int llog_osd_open(const struct lu_env *env, struct llog_handle *handle, handle->private_data = los; LASSERT(handle->lgh_ctxt); - RETURN(rc); + return rc; out_put: lu_object_put(env, &o->do_lu); @@ -873,7 +853,7 @@ out_name: OBD_FREE(handle->lgh_name, strlen(name) + 1); out: dt_los_put(los); - RETURN(rc); + return rc; } static int llog_osd_exist(struct llog_handle *handle) @@ -891,33 +871,31 @@ static int llog_osd_declare_create(const struct lu_env *env, struct dt_object *o; int rc; - ENTRY; - LASSERT(res->lgh_obj); LASSERT(th); /* object can be created by another thread */ o = res->lgh_obj; if (dt_object_exists(o)) - RETURN(0); + return 0; los = res->private_data; LASSERT(los); rc = llog_osd_declare_new_object(env, los, o, th); if (rc) - RETURN(rc); + return rc; rc = dt_declare_record_write(env, o, LLOG_CHUNK_SIZE, 0, th); if (rc) - RETURN(rc); + return rc; if (res->lgh_name) { struct dt_object *llog_dir; llog_dir = llog_osd_dir_get(env, res->lgh_ctxt); if (IS_ERR(llog_dir)) - RETURN(PTR_ERR(llog_dir)); + return PTR_ERR(llog_dir); logid_to_fid(&res->lgh_id, &lgi->lgi_fid); rc = dt_declare_insert(env, llog_dir, (struct dt_rec *)&lgi->lgi_fid, @@ -928,7 +906,7 @@ static int llog_osd_declare_create(const struct lu_env *env, o->do_lu.lo_dev->ld_obd->obd_name, res->lgh_name, rc); } - RETURN(rc); + return rc; } /* This is a callback from the llog_* functions. @@ -941,15 +919,13 @@ static int llog_osd_create(const struct lu_env *env, struct llog_handle *res, struct dt_object *o; int rc = 0; - ENTRY; - LASSERT(env); o = res->lgh_obj; LASSERT(o); /* llog can be already created */ if (dt_object_exists(o)) - RETURN(-EEXIST); + return -EEXIST; los = res->private_data; LASSERT(los); @@ -962,14 +938,14 @@ static int llog_osd_create(const struct lu_env *env, struct llog_handle *res, dt_write_unlock(env, o); if (rc) - RETURN(rc); + return rc; if (res->lgh_name) { struct dt_object *llog_dir; llog_dir = llog_osd_dir_get(env, res->lgh_ctxt); if (IS_ERR(llog_dir)) - RETURN(PTR_ERR(llog_dir)); + return PTR_ERR(llog_dir); logid_to_fid(&res->lgh_id, &lgi->lgi_fid); dt_read_lock(env, llog_dir, 0); @@ -984,7 +960,7 @@ static int llog_osd_create(const struct lu_env *env, struct llog_handle *res, o->do_lu.lo_dev->ld_obd->obd_name, res->lgh_name, rc); } - RETURN(rc); + return rc; } static int llog_osd_close(const struct lu_env *env, struct llog_handle *handle) @@ -992,8 +968,6 @@ static int llog_osd_close(const struct lu_env *env, struct llog_handle *handle) struct local_oid_storage *los; int rc = 0; - ENTRY; - LASSERT(handle->lgh_obj); lu_object_put(env, &handle->lgh_obj->do_lu); @@ -1005,7 +979,7 @@ static int llog_osd_close(const struct lu_env *env, struct llog_handle *handle) if (handle->lgh_name) OBD_FREE(handle->lgh_name, strlen(handle->lgh_name) + 1); - RETURN(rc); + return rc; } static int llog_osd_destroy(const struct lu_env *env, @@ -1018,8 +992,6 @@ static int llog_osd_destroy(const struct lu_env *env, char *name = NULL; int rc; - ENTRY; - ctxt = loghandle->lgh_ctxt; LASSERT(ctxt); @@ -1032,7 +1004,7 @@ static int llog_osd_destroy(const struct lu_env *env, th = dt_trans_create(env, d); if (IS_ERR(th)) - RETURN(PTR_ERR(th)); + return PTR_ERR(th); if (loghandle->lgh_name) { llog_dir = llog_osd_dir_get(env, ctxt); @@ -1082,7 +1054,7 @@ out_trans: dt_trans_stop(env, d, th); if (llog_dir != NULL) lu_object_put(env, &llog_dir->do_lu); - RETURN(rc); + return rc; } static int llog_osd_setup(const struct lu_env *env, struct obd_device *obd, @@ -1094,8 +1066,6 @@ static int llog_osd_setup(const struct lu_env *env, struct obd_device *obd, struct llog_ctxt *ctxt; int rc = 0; - ENTRY; - LASSERT(obd); LASSERT(olg->olg_ctxts[ctxt_idx]); @@ -1131,7 +1101,7 @@ static int llog_osd_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) dt = ctxt->loc_exp->exp_obd->obd_lvfs_ctxt.dt; ls = ls_device_get(dt); if (IS_ERR(ls)) - RETURN(PTR_ERR(ls)); + return PTR_ERR(ls); mutex_lock(&ls->ls_los_mutex); los = dt_los_find(ls, FID_SEQ_LLOG); @@ -1175,8 +1145,6 @@ int llog_osd_get_cat_list(const struct lu_env *env, struct dt_device *d, struct thandle *th; int rc, size; - ENTRY; - LASSERT(d); size = sizeof(*idarray) * count; @@ -1186,7 +1154,7 @@ int llog_osd_get_cat_list(const struct lu_env *env, struct dt_device *d, o = dt_locate(env, d, &lgi->lgi_fid); if (IS_ERR(o)) - RETURN(PTR_ERR(o)); + return PTR_ERR(o); if (!dt_object_exists(o)) { th = dt_trans_create(env, d); @@ -1253,10 +1221,9 @@ out_trans: GOTO(out, rc); } - EXIT; out: lu_object_put(env, &o->do_lu); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_osd_get_cat_list); @@ -1270,7 +1237,7 @@ int llog_osd_put_cat_list(const struct lu_env *env, struct dt_device *d, int rc, size; if (!count) - RETURN(0); + return 0; LASSERT(d); @@ -1281,7 +1248,7 @@ int llog_osd_put_cat_list(const struct lu_env *env, struct dt_device *d, o = dt_locate(env, d, &lgi->lgi_fid); if (IS_ERR(o)) - RETURN(PTR_ERR(o)); + return PTR_ERR(o); if (!dt_object_exists(o)) GOTO(out, rc = -ENOENT); @@ -1318,6 +1285,6 @@ out_trans: dt_trans_stop(env, d, th); out: lu_object_put(env, &o->do_lu); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_osd_put_cat_list); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index dedfecff95b..24ca099b01d 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -88,7 +88,6 @@ EXPORT_SYMBOL(lustre_swab_llog_id); void lustre_swab_llogd_body (struct llogd_body *d) { - ENTRY; print_llogd_body(d); lustre_swab_llog_id(&d->lgd_logid); __swab32s (&d->lgd_ctxt_idx); @@ -98,7 +97,6 @@ void lustre_swab_llogd_body (struct llogd_body *d) __swab32s (&d->lgd_len); __swab64s (&d->lgd_cur_offset); print_llogd_body(d); - EXIT; } EXPORT_SYMBOL(lustre_swab_llogd_body); @@ -203,6 +201,23 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec) break; } + case HSM_AGENT_REC: { + struct llog_agent_req_rec *arr = + (struct llog_agent_req_rec *)rec; + + __swab32s(&arr->arr_hai.hai_len); + __swab32s(&arr->arr_hai.hai_action); + lustre_swab_lu_fid(&arr->arr_hai.hai_fid); + lustre_swab_lu_fid(&arr->arr_hai.hai_dfid); + __swab64s(&arr->arr_hai.hai_cookie); + __swab64s(&arr->arr_hai.hai_extent.offset); + __swab64s(&arr->arr_hai.hai_extent.length); + __swab64s(&arr->arr_hai.hai_gid); + /* no swabing for opaque data */ + /* hai_data[0]; */ + break; + } + case MDS_SETATTR64_REC: { struct llog_setattr64_rec *lsr = @@ -281,20 +296,17 @@ static void print_llog_hdr(struct llog_log_hdr *h) void lustre_swab_llog_hdr (struct llog_log_hdr *h) { - ENTRY; print_llog_hdr(h); lustre_swab_llog_rec(&h->llh_hdr); print_llog_hdr(h); - EXIT; } EXPORT_SYMBOL(lustre_swab_llog_hdr); static void print_lustre_cfg(struct lustre_cfg *lcfg) { int i; - ENTRY; if (!(libcfs_debug & D_OTHER)) /* don't loop on nothing */ return; @@ -311,20 +323,17 @@ static void print_lustre_cfg(struct lustre_cfg *lcfg) for (i = 0; i < lcfg->lcfg_bufcount; i++) CDEBUG(D_OTHER, "\tlcfg->lcfg_buflens[%d]: %d\n", i, lcfg->lcfg_buflens[i]); - EXIT; } void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg) { int i; - ENTRY; __swab32s(&lcfg->lcfg_version); if (lcfg->lcfg_version != LUSTRE_CFG_VERSION) { CERROR("not swabbing lustre_cfg version %#x (expecting %#x)\n", lcfg->lcfg_version, LUSTRE_CFG_VERSION); - EXIT; return; } @@ -337,7 +346,6 @@ void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg) __swab32s(&lcfg->lcfg_buflens[i]); print_lustre_cfg(lcfg); - EXIT; return; } EXPORT_SYMBOL(lustre_swab_lustre_cfg); @@ -360,7 +368,6 @@ struct cfg_marker32 { void lustre_swab_cfg_marker(struct cfg_marker *marker, int swab, int size) { struct cfg_marker32 *cm32 = (struct cfg_marker32*)marker; - ENTRY; if (swab) { __swab32s(&marker->cm_step); @@ -401,7 +408,6 @@ void lustre_swab_cfg_marker(struct cfg_marker *marker, int swab, int size) __swab64s(&marker->cm_canceltime); } - EXIT; return; } EXPORT_SYMBOL(lustre_swab_cfg_marker); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_test.c b/drivers/staging/lustre/lustre/obdclass/llog_test.c index d397f781ec4..d9e6d12215f 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_test.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_test.c @@ -78,22 +78,22 @@ static int verify_handle(char *test, struct llog_handle *llh, int num_recs) if (active_recs != num_recs) { CERROR("%s: expected %d active recs after write, found %d\n", test, num_recs, active_recs); - RETURN(-ERANGE); + return -ERANGE; } if (llh->lgh_hdr->llh_count != num_recs) { CERROR("%s: handle->count is %d, expected %d after write\n", test, llh->lgh_hdr->llh_count, num_recs); - RETURN(-ERANGE); + return -ERANGE; } if (llh->lgh_last_idx < last_idx) { CERROR("%s: handle->last_idx is %d, expected %d after write\n", test, llh->lgh_last_idx, last_idx); - RETURN(-ERANGE); + return -ERANGE; } - RETURN(0); + return 0; } /* Test named-log create/open, close */ @@ -105,8 +105,6 @@ static int llog_test_1(const struct lu_env *env, int rc; int rc2; - ENTRY; - CWARN("1a: create a log with name: %s\n", name); ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); LASSERT(ctxt); @@ -134,7 +132,7 @@ out_close: } out: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } /* Test named-log reopen; returns opened log on success */ @@ -146,8 +144,6 @@ static int llog_test_2(const struct lu_env *env, struct obd_device *obd, struct llog_logid logid; int rc; - ENTRY; - CWARN("2a: re-open a log with name: %s\n", name); ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); LASSERT(ctxt); @@ -213,7 +209,7 @@ out_close_llh: out_put: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } /* Test record writing, single and in bulk */ @@ -224,8 +220,6 @@ static int llog_test_3(const struct lu_env *env, struct obd_device *obd, int rc, i; int num_recs = 1; /* 1 for the header */ - ENTRY; - lgr.lgr_hdr.lrh_len = lgr.lgr_tail.lrt_len = sizeof(lgr); lgr.lgr_hdr.lrh_type = LLOG_GEN_REC; @@ -234,12 +228,12 @@ static int llog_test_3(const struct lu_env *env, struct obd_device *obd, num_recs++; if (rc < 0) { CERROR("3a: write one log record failed: %d\n", rc); - RETURN(rc); + return rc; } rc = verify_handle("3a", llh, num_recs); if (rc) - RETURN(rc); + return rc; CWARN("3b: write 10 cfg log records with 8 bytes bufs\n"); for (i = 0; i < 10; i++) { @@ -253,14 +247,14 @@ static int llog_test_3(const struct lu_env *env, struct obd_device *obd, if (rc < 0) { CERROR("3b: write 10 records failed at #%d: %d\n", i + 1, rc); - RETURN(rc); + return rc; } num_recs++; } rc = verify_handle("3b", llh, num_recs); if (rc) - RETURN(rc); + return rc; CWARN("3c: write 1000 more log records\n"); for (i = 0; i < 1000; i++) { @@ -268,14 +262,14 @@ static int llog_test_3(const struct lu_env *env, struct obd_device *obd, if (rc < 0) { CERROR("3c: write 1000 records failed at #%d: %d\n", i + 1, rc); - RETURN(rc); + return rc; } num_recs++; } rc = verify_handle("3c", llh, num_recs); if (rc) - RETURN(rc); + return rc; CWARN("3d: write log more than BITMAP_SIZE, return -ENOSPC\n"); for (i = 0; i < LLOG_BITMAP_SIZE(llh->lgh_hdr) + 1; i++) { @@ -299,20 +293,20 @@ static int llog_test_3(const struct lu_env *env, struct obd_device *obd, } else if (rc < 0) { CERROR("3d: write recs failed at #%d: %d\n", i + 1, rc); - RETURN(rc); + return rc; } num_recs++; } if (rc != -ENOSPC) { CWARN("3d: write record more than BITMAP size!\n"); - RETURN(-EINVAL); + return -EINVAL; } CWARN("3d: wrote %d more records before end of llog is reached\n", num_recs); rc = verify_handle("3d", llh, num_recs); - RETURN(rc); + return rc; } /* Test catalogue additions */ @@ -328,8 +322,6 @@ static int llog_test_4(const struct lu_env *env, struct obd_device *obd) char *buf; struct llog_rec_hdr rec; - ENTRY; - ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); LASSERT(ctxt); @@ -424,7 +416,7 @@ out: } ctxt_release: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } static int cat_counter; @@ -437,7 +429,7 @@ static int cat_print_cb(const struct lu_env *env, struct llog_handle *llh, if (rec->lrh_type != LLOG_LOGID_MAGIC) { CERROR("invalid record in catalog\n"); - RETURN(-EINVAL); + return -EINVAL; } logid_to_fid(&lir->lid_id, &fid); @@ -448,7 +440,7 @@ static int cat_print_cb(const struct lu_env *env, struct llog_handle *llh, cat_counter++; - RETURN(0); + return 0; } static int plain_counter; @@ -460,7 +452,7 @@ static int plain_print_cb(const struct lu_env *env, struct llog_handle *llh, if (!(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN)) { CERROR("log is not plain\n"); - RETURN(-EINVAL); + return -EINVAL; } logid_to_fid(&llh->lgh_id, &fid); @@ -470,7 +462,7 @@ static int plain_print_cb(const struct lu_env *env, struct llog_handle *llh, plain_counter++; - RETURN(0); + return 0; } static int cancel_count; @@ -483,7 +475,7 @@ static int llog_cancel_rec_cb(const struct lu_env *env, if (!(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN)) { CERROR("log is not plain\n"); - RETURN(-EINVAL); + return -EINVAL; } cookie.lgc_lgl = llh->lgh_id; @@ -492,8 +484,8 @@ static int llog_cancel_rec_cb(const struct lu_env *env, llog_cat_cancel_records(env, llh->u.phd.phd_cat_handle, 1, &cookie); cancel_count++; if (cancel_count == LLOG_TEST_RECNUM) - RETURN(-LLOG_EEMPTY); - RETURN(0); + return -LLOG_EEMPTY; + return 0; } /* Test log and catalogue processing */ @@ -505,8 +497,6 @@ static int llog_test_5(const struct lu_env *env, struct obd_device *obd) struct llog_mini_rec lmr; struct llog_ctxt *ctxt; - ENTRY; - ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); LASSERT(ctxt); @@ -602,7 +592,7 @@ out: out_put: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } /* Test client api; open log by name and process */ @@ -686,7 +676,7 @@ nctxt_put: llog_ctxt_put(nctxt); ctxt_release: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } static union { @@ -728,12 +718,10 @@ static int llog_test_7_sub(const struct lu_env *env, struct llog_ctxt *ctxt) int rc = 0, i, process_count; int num_recs = 0; - ENTRY; - rc = llog_open_create(env, ctxt, &llh, NULL, NULL); if (rc) { CERROR("7_sub: create log failed\n"); - RETURN(rc); + return rc; } rc = llog_init_handle(env, llh, @@ -804,7 +792,7 @@ out_close: if (rc) llog_destroy(env, llh); llog_close(env, llh); - RETURN(rc); + return rc; } /* Test all llog records writing and processing */ @@ -813,8 +801,6 @@ static int llog_test_7(const struct lu_env *env, struct obd_device *obd) struct llog_ctxt *ctxt; int rc; - ENTRY; - ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); CWARN("7a: test llog_logid_rec\n"); @@ -895,7 +881,7 @@ static int llog_test_7(const struct lu_env *env, struct obd_device *obd) } out: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } /* ------------------------------------------------------------------------- @@ -908,7 +894,6 @@ static int llog_run_tests(const struct lu_env *env, struct obd_device *obd) int rc, err; char name[10]; - ENTRY; ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); LASSERT(ctxt); @@ -970,18 +955,16 @@ static int llog_test_cleanup(struct obd_device *obd) struct lu_env env; int rc; - ENTRY; - rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD); if (rc) - RETURN(rc); + return rc; tgt = obd->obd_lvfs_ctxt.dt->dd_lu_dev.ld_obd; rc = llog_cleanup(&env, llog_get_context(tgt, LLOG_TEST_ORIG_CTXT)); if (rc) CERROR("failed to llog_test_llog_finish: %d\n", rc); lu_env_fini(&env); - RETURN(rc); + return rc; } static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) @@ -993,16 +976,14 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) struct lu_context test_session; int rc; - ENTRY; - if (lcfg->lcfg_bufcount < 2) { CERROR("requires a TARGET OBD name\n"); - RETURN(-EINVAL); + return -EINVAL; } if (lcfg->lcfg_buflens[1] < 1) { CERROR("requires a TARGET OBD name\n"); - RETURN(-EINVAL); + return -EINVAL; } /* disk obd */ @@ -1010,12 +991,12 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (!tgt || !tgt->obd_attached || !tgt->obd_set_up) { CERROR("target device not attached or not set up (%s)\n", lustre_cfg_string(lcfg, 1)); - RETURN(-EINVAL); + return -EINVAL; } rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD); if (rc) - RETURN(rc); + return rc; rc = lu_context_init(&test_session, LCT_SESSION); if (rc) @@ -1056,7 +1037,7 @@ cleanup_session: lu_context_fini(&test_session); cleanup_env: lu_env_fini(&env); - RETURN(rc); + return rc; } static struct obd_ops llog_obd_ops = { diff --git a/drivers/staging/lustre/lustre/obdclass/local_storage.c b/drivers/staging/lustre/lustre/obdclass/local_storage.c index 3be35a83a49..cc19fbab020 100644 --- a/drivers/staging/lustre/lustre/obdclass/local_storage.c +++ b/drivers/staging/lustre/lustre/obdclass/local_storage.c @@ -45,17 +45,15 @@ static int ls_object_init(const struct lu_env *env, struct lu_object *o, struct lu_object *below; struct lu_device *under; - ENTRY; - ls = container_of0(o->lo_dev, struct ls_device, ls_top_dev.dd_lu_dev); under = &ls->ls_osd->dd_lu_dev; below = under->ld_ops->ldo_object_alloc(env, o->lo_header, under); if (below == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lu_object_add(o, below); - RETURN(0); + return 0; } static void ls_object_free(const struct lu_env *env, struct lu_object *o) @@ -143,8 +141,6 @@ struct ls_device *ls_device_get(struct dt_device *dev) { struct ls_device *ls; - ENTRY; - mutex_lock(&ls_list_mutex); ls = __ls_find_dev(dev); if (ls) @@ -170,7 +166,7 @@ struct ls_device *ls_device_get(struct dt_device *dev) list_add(&ls->ls_linkage, &ls_list_head); out_ls: mutex_unlock(&ls_list_mutex); - RETURN(ls); + return ls; } void ls_device_put(const struct lu_env *env, struct ls_device *ls) @@ -224,26 +220,24 @@ int local_object_declare_create(const struct lu_env *env, struct dt_thread_info *dti = dt_info(env); int rc; - ENTRY; - /* update fid generation file */ if (los != NULL) { LASSERT(dt_object_exists(los->los_obj)); rc = dt_declare_record_write(env, los->los_obj, sizeof(struct los_ondisk), 0, th); if (rc) - RETURN(rc); + return rc; } rc = dt_declare_create(env, o, attr, NULL, dof, th); if (rc) - RETURN(rc); + return rc; dti->dti_lb.lb_buf = NULL; dti->dti_lb.lb_len = sizeof(dti->dti_lma); rc = dt_declare_xattr_set(env, o, &dti->dti_lb, XATTR_NAME_LMA, 0, th); - RETURN(rc); + return rc; } int local_object_create(const struct lu_env *env, @@ -255,14 +249,12 @@ int local_object_create(const struct lu_env *env, obd_id lastid; int rc; - ENTRY; - rc = dt_create(env, o, attr, NULL, dof, th); if (rc) - RETURN(rc); + return rc; if (los == NULL) - RETURN(rc); + return rc; LASSERT(los->los_obj); LASSERT(dt_object_exists(los->los_obj)); @@ -283,7 +275,7 @@ int local_object_create(const struct lu_env *env, th); mutex_unlock(&los->los_id_lock); - RETURN(rc); + return rc; } /* @@ -304,7 +296,7 @@ struct dt_object *__local_file_create(const struct lu_env *env, dto = ls_locate(env, ls, fid); if (unlikely(IS_ERR(dto))) - RETURN(dto); + return dto; LASSERT(dto != NULL); if (dt_object_exists(dto)) @@ -377,7 +369,7 @@ out: lu_object_put_nocache(env, &dto->do_lu); dto = ERR_PTR(rc); } - RETURN(dto); + return dto; } /* @@ -443,7 +435,7 @@ struct dt_object *local_file_find_or_create_with_fid(const struct lu_env *env, ls = ls_device_get(dt); if (IS_ERR(ls)) { - dto = ERR_PTR(PTR_ERR(ls)); + dto = ERR_CAST(ls); } else { /* create the object */ dti->dti_attr.la_valid = LA_MODE; @@ -537,7 +529,7 @@ local_index_find_or_create_with_fid(const struct lu_env *env, ls = ls_device_get(dt); if (IS_ERR(ls)) { - dto = ERR_PTR(PTR_ERR(ls)); + dto = ERR_CAST(ls); } else { /* create the object */ dti->dti_attr.la_valid = LA_MODE; @@ -588,17 +580,15 @@ int local_object_unlink(const struct lu_env *env, struct dt_device *dt, struct thandle *th; int rc; - ENTRY; - rc = dt_lookup_dir(env, parent, name, &dti->dti_fid); if (rc == -ENOENT) - RETURN(0); + return 0; else if (rc < 0) - RETURN(rc); + return rc; dto = dt_locate(env, dt, &dti->dti_fid); if (unlikely(IS_ERR(dto))) - RETURN(PTR_ERR(dto)); + return PTR_ERR(dto); th = dt_trans_create(env, dt); if (IS_ERR(th)) @@ -761,11 +751,9 @@ int local_oid_storage_init(const struct lu_env *env, struct dt_device *dev, __u32 first_oid = fid_oid(first_fid); int rc = 0; - ENTRY; - ls = ls_device_get(dev); if (IS_ERR(ls)) - RETURN(PTR_ERR(ls)); + return PTR_ERR(ls); mutex_lock(&ls->ls_los_mutex); *los = dt_los_find(ls, fid_seq(first_fid)); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c deleted file mode 100644 index e2d57fef0da..00000000000 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c +++ /dev/null @@ -1,562 +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 - * - * GPL HEADER END - */ -/* - * Copyright (c) 2011, 2012, Intel Corporation. - * Use is subject to license terms. - * - * Author: Niu Yawei <niu@whamcloud.com> - */ -/* - * lustre/obdclass/lprocfs_jobstats.c - */ - -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif -#define DEBUG_SUBSYSTEM S_CLASS - - -#include <obd_class.h> -#include <lprocfs_status.h> -#include <lustre/lustre_idl.h> - -#if defined(LPROCFS) - -/* - * JobID formats & JobID environment variable names for supported - * job schedulers: - * - * SLURM: - * JobID format: 32 bit integer. - * JobID env var: SLURM_JOB_ID. - * SGE: - * JobID format: Decimal integer range to 99999. - * JobID env var: JOB_ID. - * LSF: - * JobID format: 6 digit integer by default (up to 999999), can be - * increased to 10 digit (up to 2147483646). - * JobID env var: LSB_JOBID. - * Loadleveler: - * JobID format: String of machine_name.cluster_id.process_id, for - * example: fr2n02.32.0 - * JobID env var: LOADL_STEP_ID. - * PBS: - * JobID format: String of sequence_number[.server_name][@server]. - * JobID env var: PBS_JOBID. - * Maui/MOAB: - * JobID format: Same as PBS. - * JobID env var: Same as PBS. - */ - -struct job_stat { - struct hlist_node js_hash; - struct list_head js_list; - atomic_t js_refcount; - char js_jobid[JOBSTATS_JOBID_SIZE]; - time_t js_timestamp; /* seconds */ - struct lprocfs_stats *js_stats; - struct obd_job_stats *js_jobstats; -}; - -static unsigned job_stat_hash(cfs_hash_t *hs, const void *key, unsigned mask) -{ - return cfs_hash_djb2_hash(key, strlen(key), mask); -} - -static void *job_stat_key(struct hlist_node *hnode) -{ - struct job_stat *job; - job = hlist_entry(hnode, struct job_stat, js_hash); - return job->js_jobid; -} - -static int job_stat_keycmp(const void *key, struct hlist_node *hnode) -{ - struct job_stat *job; - job = hlist_entry(hnode, struct job_stat, js_hash); - return (strlen(job->js_jobid) == strlen(key)) && - !strncmp(job->js_jobid, key, strlen(key)); -} - -static void *job_stat_object(struct hlist_node *hnode) -{ - return hlist_entry(hnode, struct job_stat, js_hash); -} - -static void job_stat_get(cfs_hash_t *hs, struct hlist_node *hnode) -{ - struct job_stat *job; - job = hlist_entry(hnode, struct job_stat, js_hash); - atomic_inc(&job->js_refcount); -} - -static void job_free(struct job_stat *job) -{ - LASSERT(atomic_read(&job->js_refcount) == 0); - LASSERT(job->js_jobstats); - - write_lock(&job->js_jobstats->ojs_lock); - list_del_init(&job->js_list); - write_unlock(&job->js_jobstats->ojs_lock); - - lprocfs_free_stats(&job->js_stats); - OBD_FREE_PTR(job); -} - -static void job_putref(struct job_stat *job) -{ - LASSERT(atomic_read(&job->js_refcount) > 0); - if (atomic_dec_and_test(&job->js_refcount)) - job_free(job); -} - -static void job_stat_put_locked(cfs_hash_t *hs, struct hlist_node *hnode) -{ - struct job_stat *job; - job = hlist_entry(hnode, struct job_stat, js_hash); - job_putref(job); -} - -static void job_stat_exit(cfs_hash_t *hs, struct hlist_node *hnode) -{ - CERROR("Should not have any items!"); -} - -static cfs_hash_ops_t job_stats_hash_ops = { - .hs_hash = job_stat_hash, - .hs_key = job_stat_key, - .hs_keycmp = job_stat_keycmp, - .hs_object = job_stat_object, - .hs_get = job_stat_get, - .hs_put_locked = job_stat_put_locked, - .hs_exit = job_stat_exit, -}; - -static int job_iter_callback(cfs_hash_t *hs, cfs_hash_bd_t *bd, - struct hlist_node *hnode, void *data) -{ - time_t oldest = *((time_t *)data); - struct job_stat *job; - - job = hlist_entry(hnode, struct job_stat, js_hash); - if (!oldest || job->js_timestamp < oldest) - cfs_hash_bd_del_locked(hs, bd, hnode); - - return 0; -} - -static void lprocfs_job_cleanup(struct obd_job_stats *stats, bool force) -{ - time_t oldest, now; - - if (stats->ojs_cleanup_interval == 0) - return; - - now = cfs_time_current_sec(); - if (!force && now < stats->ojs_last_cleanup + - stats->ojs_cleanup_interval) - return; - - oldest = now - stats->ojs_cleanup_interval; - cfs_hash_for_each_safe(stats->ojs_hash, job_iter_callback, - &oldest); - stats->ojs_last_cleanup = cfs_time_current_sec(); -} - -static struct job_stat *job_alloc(char *jobid, struct obd_job_stats *jobs) -{ - struct job_stat *job; - - LASSERT(jobs->ojs_cntr_num && jobs->ojs_cntr_init_fn); - - OBD_ALLOC_PTR(job); - if (job == NULL) - return NULL; - - job->js_stats = lprocfs_alloc_stats(jobs->ojs_cntr_num, 0); - if (job->js_stats == NULL) { - OBD_FREE_PTR(job); - return NULL; - } - - jobs->ojs_cntr_init_fn(job->js_stats); - - memcpy(job->js_jobid, jobid, JOBSTATS_JOBID_SIZE); - job->js_timestamp = cfs_time_current_sec(); - job->js_jobstats = jobs; - INIT_HLIST_NODE(&job->js_hash); - INIT_LIST_HEAD(&job->js_list); - atomic_set(&job->js_refcount, 1); - - return job; -} - -int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, - int event, long amount) -{ - struct obd_job_stats *stats = &obd->u.obt.obt_jobstats; - struct job_stat *job, *job2; - ENTRY; - - LASSERT(stats && stats->ojs_hash); - - lprocfs_job_cleanup(stats, false); - - if (!jobid || !strlen(jobid)) - RETURN(-EINVAL); - - if (strlen(jobid) >= JOBSTATS_JOBID_SIZE) { - CERROR("Invalid jobid size (%lu), expect(%d)\n", - (unsigned long)strlen(jobid) + 1, JOBSTATS_JOBID_SIZE); - RETURN(-EINVAL); - } - - job = cfs_hash_lookup(stats->ojs_hash, jobid); - if (job) - goto found; - - job = job_alloc(jobid, stats); - if (job == NULL) - RETURN(-ENOMEM); - - job2 = cfs_hash_findadd_unique(stats->ojs_hash, job->js_jobid, - &job->js_hash); - if (job2 != job) { - job_putref(job); - job = job2; - /* We cannot LASSERT(!list_empty(&job->js_list)) here, - * since we just lost the race for inserting "job" into the - * ojs_list, and some other thread is doing it _right_now_. - * Instead, be content the other thread is doing this, since - * "job2" was initialized in job_alloc() already. LU-2163 */ - } else { - LASSERT(list_empty(&job->js_list)); - write_lock(&stats->ojs_lock); - list_add_tail(&job->js_list, &stats->ojs_list); - write_unlock(&stats->ojs_lock); - } - -found: - LASSERT(stats == job->js_jobstats); - LASSERT(stats->ojs_cntr_num > event); - job->js_timestamp = cfs_time_current_sec(); - lprocfs_counter_add(job->js_stats, event, amount); - - job_putref(job); - RETURN(0); -} -EXPORT_SYMBOL(lprocfs_job_stats_log); - -void lprocfs_job_stats_fini(struct obd_device *obd) -{ - struct obd_job_stats *stats = &obd->u.obt.obt_jobstats; - time_t oldest = 0; - - if (stats->ojs_hash == NULL) - return; - cfs_hash_for_each_safe(stats->ojs_hash, job_iter_callback, &oldest); - cfs_hash_putref(stats->ojs_hash); - stats->ojs_hash = NULL; - LASSERT(list_empty(&stats->ojs_list)); -} -EXPORT_SYMBOL(lprocfs_job_stats_fini); - -static void *lprocfs_jobstats_seq_start(struct seq_file *p, loff_t *pos) -{ - struct obd_job_stats *stats = p->private; - loff_t off = *pos; - struct job_stat *job; - - read_lock(&stats->ojs_lock); - if (off == 0) - return SEQ_START_TOKEN; - off--; - list_for_each_entry(job, &stats->ojs_list, js_list) { - if (!off--) - return job; - } - return NULL; -} - -static void lprocfs_jobstats_seq_stop(struct seq_file *p, void *v) -{ - struct obd_job_stats *stats = p->private; - - read_unlock(&stats->ojs_lock); -} - -static void *lprocfs_jobstats_seq_next(struct seq_file *p, void *v, loff_t *pos) -{ - struct obd_job_stats *stats = p->private; - struct job_stat *job; - struct list_head *next; - - ++*pos; - if (v == SEQ_START_TOKEN) { - next = stats->ojs_list.next; - } else { - job = (struct job_stat *)v; - next = job->js_list.next; - } - - return next == &stats->ojs_list ? NULL : - list_entry(next, struct job_stat, js_list); -} - -/* - * Example of output on MDT: - * - * job_stats: - * - job_id: test_id.222.25844 - * snapshot_time: 1322494486 - * open: { samples: 3, unit: reqs } - * close: { samples: 3, unit: reqs } - * mknod: { samples: 0, unit: reqs } - * link: { samples: 0, unit: reqs } - * unlink: { samples: 0, unit: reqs } - * mkdir: { samples: 0, unit: reqs } - * rmdir: { samples: 0, unit: reqs } - * rename: { samples: 1, unit: reqs } - * getattr: { samples: 7, unit: reqs } - * setattr: { samples: 0, unit: reqs } - * getxattr: { samples: 0, unit: reqs } - * setxattr: { samples: 0, unit: reqs } - * statfs: { samples: 0, unit: reqs } - * sync: { samples: 0, unit: reqs } - * - * Example of output on OST: - * - * job_stats: - * - job_id 4854 - * snapshot_time: 1322494602 - * read: { samples: 0, unit: bytes, min: 0, max: 0, sum: 0 } - * write: { samples: 1, unit: bytes, min: 10, max: 10, sum: 10 } - * setattr: { samples: 0, unit: reqs } - * punch: { samples: 0, unit: reqs } - * sync: { samples: 0, unit: reqs } - */ - -static const char spaces[] = " "; - -static int inline width(const char *str, int len) -{ - return len - min((int)strlen(str), 15); -} - -static int lprocfs_jobstats_seq_show(struct seq_file *p, void *v) -{ - struct job_stat *job = v; - struct lprocfs_stats *s; - struct lprocfs_counter ret; - struct lprocfs_counter *cntr; - struct lprocfs_counter_header *cntr_header; - int i; - - if (v == SEQ_START_TOKEN) { - seq_printf(p, "job_stats:\n"); - return 0; - } - - seq_printf(p, "- %-16s %s\n", "job_id:", job->js_jobid); - seq_printf(p, " %-16s %ld\n", "snapshot_time:", job->js_timestamp); - - s = job->js_stats; - for (i = 0; i < s->ls_num; i++) { - cntr = lprocfs_stats_counter_get(s, 0, i); - cntr_header = &s->ls_cnt_header[i]; - lprocfs_stats_collect(s, i, &ret); - - seq_printf(p, " %s:%.*s { samples: %11"LPF64"u", - cntr_header->lc_name, - width(cntr_header->lc_name, 15), spaces, - ret.lc_count); - if (cntr_header->lc_units[0] != '\0') - seq_printf(p, ", unit: %5s", cntr_header->lc_units); - - if (cntr_header->lc_config & LPROCFS_CNTR_AVGMINMAX) { - seq_printf(p, ", min:%8"LPF64"u, max:%8"LPF64"u," - " sum:%16"LPF64"u", - ret.lc_count ? ret.lc_min : 0, - ret.lc_count ? ret.lc_max : 0, - ret.lc_count ? ret.lc_sum : 0); - } - if (cntr_header->lc_config & LPROCFS_CNTR_STDDEV) { - seq_printf(p, ", sumsq: %18"LPF64"u", - ret.lc_count ? ret.lc_sumsquare : 0); - } - - seq_printf(p, " }\n"); - - } - return 0; -} - -struct seq_operations lprocfs_jobstats_seq_sops = { - start: lprocfs_jobstats_seq_start, - stop: lprocfs_jobstats_seq_stop, - next: lprocfs_jobstats_seq_next, - show: lprocfs_jobstats_seq_show, -}; - -static int lprocfs_jobstats_seq_open(struct inode *inode, struct file *file) -{ - struct seq_file *seq; - int rc; - - rc = seq_open(file, &lprocfs_jobstats_seq_sops); - if (rc) - return rc; - seq = file->private_data; - seq->private = PDE_DATA(inode); - return 0; -} - -static ssize_t lprocfs_jobstats_seq_write(struct file *file, const char *buf, - size_t len, loff_t *off) -{ - struct seq_file *seq = file->private_data; - struct obd_job_stats *stats = seq->private; - char jobid[JOBSTATS_JOBID_SIZE]; - int all = 0; - struct job_stat *job; - - if (!memcmp(buf, "clear", strlen("clear"))) { - all = 1; - } else if (len < JOBSTATS_JOBID_SIZE) { - memset(jobid, 0, JOBSTATS_JOBID_SIZE); - /* Trim '\n' if any */ - if (buf[len - 1] == '\n') - memcpy(jobid, buf, len - 1); - else - memcpy(jobid, buf, len); - } else { - return -EINVAL; - } - - LASSERT(stats->ojs_hash); - if (all) { - time_t oldest = 0; - cfs_hash_for_each_safe(stats->ojs_hash, job_iter_callback, - &oldest); - return len; - } - - if (!strlen(jobid)) - return -EINVAL; - - job = cfs_hash_lookup(stats->ojs_hash, jobid); - if (!job) - return -EINVAL; - - cfs_hash_del_key(stats->ojs_hash, jobid); - - job_putref(job); - return len; -} - -struct file_operations lprocfs_jobstats_seq_fops = { - .owner = THIS_MODULE, - .open = lprocfs_jobstats_seq_open, - .read = seq_read, - .write = lprocfs_jobstats_seq_write, - .llseek = seq_lseek, - .release = lprocfs_seq_release, -}; - -int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num, - cntr_init_callback init_fn) -{ - struct proc_dir_entry *entry; - struct obd_job_stats *stats; - ENTRY; - - LASSERT(obd->obd_proc_entry != NULL); - LASSERT(obd->obd_type->typ_name); - - if (strcmp(obd->obd_type->typ_name, LUSTRE_MDT_NAME) && - strcmp(obd->obd_type->typ_name, LUSTRE_OST_NAME)) { - CERROR("Invalid obd device type.\n"); - RETURN(-EINVAL); - } - stats = &obd->u.obt.obt_jobstats; - - LASSERT(stats->ojs_hash == NULL); - stats->ojs_hash = cfs_hash_create("JOB_STATS", - HASH_JOB_STATS_CUR_BITS, - HASH_JOB_STATS_MAX_BITS, - HASH_JOB_STATS_BKT_BITS, 0, - CFS_HASH_MIN_THETA, - CFS_HASH_MAX_THETA, - &job_stats_hash_ops, - CFS_HASH_DEFAULT); - if (stats->ojs_hash == NULL) - RETURN(-ENOMEM); - - INIT_LIST_HEAD(&stats->ojs_list); - rwlock_init(&stats->ojs_lock); - stats->ojs_cntr_num = cntr_num; - stats->ojs_cntr_init_fn = init_fn; - stats->ojs_cleanup_interval = 600; /* 10 mins by default */ - stats->ojs_last_cleanup = cfs_time_current_sec(); - - entry = proc_create_data("job_stats", 0644, obd->obd_proc_entry, - &lprocfs_jobstats_seq_fops, stats); - if (entry) - RETURN(0); - else - RETURN(-ENOMEM); -} -EXPORT_SYMBOL(lprocfs_job_stats_init); - -int lprocfs_rd_job_interval(struct seq_file *m, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - struct obd_job_stats *stats; - - LASSERT(obd != NULL); - stats = &obd->u.obt.obt_jobstats; - return seq_printf(m, "%d\n", stats->ojs_cleanup_interval); -} -EXPORT_SYMBOL(lprocfs_rd_job_interval); - -int lprocfs_wr_job_interval(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - struct obd_job_stats *stats; - int val, rc; - - LASSERT(obd != NULL); - stats = &obd->u.obt.obt_jobstats; - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - - stats->ojs_cleanup_interval = val; - lprocfs_job_cleanup(stats, true); - - return count; - -} -EXPORT_SYMBOL(lprocfs_wr_job_interval); - -#endif /* LPROCFS*/ diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index f7af3d6a4ef..a95f60a4f90 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -68,11 +68,11 @@ EXPORT_SYMBOL(lprocfs_seq_release); /* lprocfs API calls */ -proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root, +struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, char *name, void *data, struct file_operations *fops) { - proc_dir_entry_t *proc; + struct proc_dir_entry *proc; umode_t mode = 0; if (root == NULL || name == NULL || fops == NULL) @@ -179,17 +179,21 @@ struct proc_dir_entry *lprocfs_register(const char *name, struct proc_dir_entry *parent, struct lprocfs_vars *list, void *data) { - struct proc_dir_entry *newchild; + struct proc_dir_entry *entry; + + entry = proc_mkdir(name, parent); + if (entry == NULL) + GOTO(out, entry = ERR_PTR(-ENOMEM)); - newchild = proc_mkdir(name, parent); - if (newchild != NULL && list != NULL) { - int rc = lprocfs_add_vars(newchild, list, data); - if (rc) { - lprocfs_remove(&newchild); - return ERR_PTR(rc); + if (list != NULL) { + int rc = lprocfs_add_vars(entry, list, data); + if (rc != 0) { + lprocfs_remove(&entry); + entry = ERR_PTR(rc); } } - return newchild; +out: + return entry; } EXPORT_SYMBOL(lprocfs_register); @@ -896,7 +900,6 @@ void lprocfs_free_per_client_stats(struct obd_device *obd) { cfs_hash_t *hash = obd->obd_nid_stats_hash; struct nid_stat *stat; - ENTRY; /* we need extra list - because hash_exit called to early */ /* not need locking because all clients is died */ @@ -907,7 +910,6 @@ void lprocfs_free_per_client_stats(struct obd_device *obd) cfs_hash_del(hash, &stat->nid, &stat->nid_hash); lprocfs_free_client_stats(stat); } - EXIT; } EXPORT_SYMBOL(lprocfs_free_per_client_stats); @@ -1494,7 +1496,6 @@ EXPORT_SYMBOL(lprocfs_nid_stats_clear_read); static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data) { struct nid_stat *stat = obj; - ENTRY; CDEBUG(D_INFO,"refcnt %d\n", atomic_read(&stat->nid_exp_ref_count)); if (atomic_read(&stat->nid_exp_ref_count) == 1) { @@ -1502,13 +1503,13 @@ static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data) spin_lock(&stat->nid_obd->obd_nid_lock); list_move(&stat->nid_list, data); spin_unlock(&stat->nid_obd->obd_nid_lock); - RETURN(1); + return 1; } /* we has reference to object - only clear data*/ if (stat->nid_stats) lprocfs_clear_stats(stat->nid_stats); - RETURN(0); + return 0; } int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, @@ -1536,22 +1537,21 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) { struct nid_stat *new_stat, *old_stat; struct obd_device *obd = NULL; - proc_dir_entry_t *entry; + struct proc_dir_entry *entry; char *buffer = NULL; int rc = 0; - ENTRY; *newnid = 0; if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry || !exp->exp_obd->obd_nid_stats_hash) - RETURN(-EINVAL); + return -EINVAL; /* not test against zero because eric say: * You may only test nid against another nid, or LNET_NID_ANY. * Anything else is nonsense.*/ if (!nid || *nid == LNET_NID_ANY) - RETURN(0); + return 0; obd = exp->exp_obd; @@ -1559,7 +1559,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) OBD_ALLOC_PTR(new_stat); if (new_stat == NULL) - RETURN(-ENOMEM); + return -ENOMEM; new_stat->nid = *nid; new_stat->nid_obd = exp->exp_obd; @@ -1596,10 +1596,12 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) NULL, NULL); OBD_FREE(buffer, LNET_NIDSTR_SIZE); - if (new_stat->nid_proc == NULL) { + if (IS_ERR(new_stat->nid_proc)) { CERROR("Error making export directory for nid %s\n", libcfs_nid2str(*nid)); - GOTO(destroy_new_ns, rc = -ENOMEM); + rc = PTR_ERR(new_stat->nid_proc); + new_stat->nid_proc = NULL; + GOTO(destroy_new_ns, rc); } entry = lprocfs_add_simple(new_stat->nid_proc, "uuid", @@ -1625,7 +1627,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) list_add(&new_stat->nid_list, &obd->obd_nid_stats); spin_unlock(&obd->obd_nid_lock); - RETURN(rc); + return rc; destroy_new_ns: if (new_stat->nid_proc != NULL) @@ -1635,7 +1637,7 @@ destroy_new_ns: destroy_new: nidstat_putref(new_stat); OBD_FREE_PTR(new_stat); - RETURN(rc); + return rc; } EXPORT_SYMBOL(lprocfs_exp_setup); @@ -1644,7 +1646,7 @@ int lprocfs_exp_cleanup(struct obd_export *exp) struct nid_stat *stat = exp->exp_nid_stats; if(!stat || !exp->exp_obd) - RETURN(0); + return 0; nidstat_putref(exp->exp_nid_stats); exp->exp_nid_stats = NULL; @@ -1873,7 +1875,7 @@ static char *lprocfs_strnstr(const char *s1, const char *s2, size_t len) * If \a name is not found the original \a buffer is returned. */ char *lprocfs_find_named_value(const char *buffer, const char *name, - unsigned long *count) + size_t *count) { char *val; size_t buflen = *count; @@ -1897,23 +1899,22 @@ char *lprocfs_find_named_value(const char *buffer, const char *name, } EXPORT_SYMBOL(lprocfs_find_named_value); -int lprocfs_seq_create(proc_dir_entry_t *parent, +int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name, umode_t mode, const struct file_operations *seq_fops, void *data) { struct proc_dir_entry *entry; - ENTRY; /* Disallow secretly (un)writable entries. */ LASSERT((seq_fops->write == NULL) == ((mode & 0222) == 0)); entry = proc_create_data(name, mode, parent, seq_fops, data); if (entry == NULL) - RETURN(-ENOMEM); + return -ENOMEM; - RETURN(0); + return 0; } EXPORT_SYMBOL(lprocfs_seq_create); diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index fdf0ed36769..3a3d5bc5a62 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -202,7 +202,6 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env, struct list_head *layers; int clean; int result; - ENTRY; /* * Create top-level object slice. This will also create @@ -210,9 +209,9 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env, */ top = dev->ld_ops->ldo_object_alloc(env, NULL, dev); if (top == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); if (IS_ERR(top)) - RETURN(top); + return top; /* * This is the only place where object fid is assigned. It's constant * after this point. @@ -233,7 +232,7 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env, result = scan->lo_ops->loo_object_init(env, scan, conf); if (result != 0) { lu_object_free(env, top); - RETURN(ERR_PTR(result)); + return ERR_PTR(result); } scan->lo_flags |= LU_OBJECT_ALLOCATED; } @@ -244,13 +243,13 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env, result = scan->lo_ops->loo_object_start(env, scan); if (result != 0) { lu_object_free(env, top); - RETURN(ERR_PTR(result)); + return ERR_PTR(result); } } } lprocfs_counter_incr(dev->ld_site->ls_stats, LU_SS_CREATED); - RETURN(top); + return top; } /** @@ -317,7 +316,7 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr) int i; if (OBD_FAIL_CHECK(OBD_FAIL_OBD_NO_LRU)) - RETURN(0); + return 0; INIT_LIST_HEAD(&dispose); /* @@ -538,7 +537,7 @@ static struct lu_object *htable_lookup(struct lu_site *s, __u64 ver = cfs_hash_bd_version_get(bd); if (*version == ver) - return NULL; + return ERR_PTR(-ENOENT); *version = ver; bkt = cfs_hash_bd_extra_get(s->ls_obj_hash, bd); @@ -547,7 +546,7 @@ static struct lu_object *htable_lookup(struct lu_site *s, hnode = cfs_hash_bd_peek_locked(s->ls_obj_hash, bd, (void *)f); if (hnode == NULL) { lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_MISS); - return NULL; + return ERR_PTR(-ENOENT); } h = container_of0(hnode, struct lu_object_header, loh_hash); @@ -651,7 +650,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env, cfs_hash_bd_get_and_lock(hs, (void *)f, &bd, 1); o = htable_lookup(s, &bd, f, waiter, &version); cfs_hash_bd_unlock(hs, &bd, 1); - if (o != NULL) + if (!IS_ERR(o) || PTR_ERR(o) != -ENOENT) return o; /* @@ -667,7 +666,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env, cfs_hash_bd_lock(hs, &bd, 1); shadow = htable_lookup(s, &bd, f, waiter, &version); - if (likely(shadow == NULL)) { + if (likely(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT)) { struct lu_site_bkt_data *bkt; bkt = cfs_hash_bd_extra_get(hs, &bd); @@ -849,7 +848,7 @@ static int lu_htable_order(void) * * Size of lu_object is (arbitrary) taken as 1K (together with inode). */ - cache_size = num_physpages; + cache_size = totalram_pages; #if BITS_PER_LONG == 32 /* limit hashtable size for lowmem systems to low RAM */ @@ -980,7 +979,6 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) char name[16]; int bits; int i; - ENTRY; memset(s, 0, sizeof *s); bits = lu_htable_order(); @@ -1041,7 +1039,7 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) lu_dev_add_linkage(s, top); - RETURN(0); + return 0; } EXPORT_SYMBOL(lu_site_init); @@ -1147,15 +1145,16 @@ EXPORT_SYMBOL(lu_device_fini); * Initialize object \a o that is part of compound object \a h and was created * by device \a d. */ -int lu_object_init(struct lu_object *o, - struct lu_object_header *h, struct lu_device *d) +int lu_object_init(struct lu_object *o, struct lu_object_header *h, + struct lu_device *d) { - memset(o, 0, sizeof *o); + memset(o, 0, sizeof(*o)); o->lo_header = h; - o->lo_dev = d; + o->lo_dev = d; lu_device_get(d); - o->lo_dev_ref = lu_ref_add(&d->ld_reference, "lu_object", o); + lu_ref_add_at(&d->ld_reference, &o->lo_dev_ref, "lu_object", o); INIT_LIST_HEAD(&o->lo_linkage); + return 0; } EXPORT_SYMBOL(lu_object_init); @@ -1170,8 +1169,8 @@ void lu_object_fini(struct lu_object *o) LASSERT(list_empty(&o->lo_linkage)); if (dev != NULL) { - lu_ref_del_at(&dev->ld_reference, - o->lo_dev_ref , "lu_object", o); + lu_ref_del_at(&dev->ld_reference, &o->lo_dev_ref, + "lu_object", o); lu_device_put(dev); o->lo_dev = NULL; } @@ -1315,7 +1314,6 @@ int lu_context_key_register(struct lu_context_key *key) LASSERT(key->lct_init != NULL); LASSERT(key->lct_fini != NULL); LASSERT(key->lct_tags != 0); - LASSERT(key->lct_owner != NULL); result = -ENFILE; spin_lock(&lu_keys_guard); @@ -1349,7 +1347,6 @@ static void key_fini(struct lu_context *ctx, int index) lu_ref_del(&key->lct_reference, "ctx", ctx); atomic_dec(&key->lct_used); - LASSERT(key->lct_owner != NULL); if ((ctx->lc_tags & LCT_NOREF) == 0) { #ifdef CONFIG_MODULE_UNLOAD LINVRNT(module_refcount(key->lct_owner) > 0); @@ -1557,7 +1554,6 @@ static int keys_fill(struct lu_context *ctx) if (unlikely(IS_ERR(value))) return PTR_ERR(value); - LASSERT(key->lct_owner != NULL); if (!(ctx->lc_tags & LCT_NOREF)) try_module_get(key->lct_owner); lu_ref_add_atomic(&key->lct_reference, "ctx", ctx); @@ -1783,7 +1779,6 @@ int lu_env_refill_by_tags(struct lu_env *env, __u32 ctags, } EXPORT_SYMBOL(lu_env_refill_by_tags); -static struct shrinker *lu_site_shrinker = NULL; typedef struct lu_site_stats{ unsigned lss_populated; @@ -1839,61 +1834,68 @@ static void lu_site_stats_get(cfs_hash_t *hs, * objects without taking the lu_sites_guard lock, but this is not * possible in the current implementation. */ -static int lu_cache_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask)) +static unsigned long lu_cache_shrink_count(struct shrinker *sk, + struct shrink_control *sc) { lu_site_stats_t stats; struct lu_site *s; struct lu_site *tmp; - int cached = 0; - int remain = shrink_param(sc, nr_to_scan); - LIST_HEAD(splice); - - if (!(shrink_param(sc, gfp_mask) & __GFP_FS)) { - if (remain != 0) - return -1; - else - /* We must not take the lu_sites_guard lock when - * __GFP_FS is *not* set because of the deadlock - * possibility detailed above. Additionally, - * since we cannot determine the number of - * objects in the cache without taking this - * lock, we're in a particularly tough spot. As - * a result, we'll just lie and say our cache is - * empty. This _should_ be ok, as we can't - * reclaim objects when __GFP_FS is *not* set - * anyways. - */ - return 0; - } + unsigned long cached = 0; - CDEBUG(D_INODE, "Shrink %d objects\n", remain); + if (!(sc->gfp_mask & __GFP_FS)) + return 0; mutex_lock(&lu_sites_guard); list_for_each_entry_safe(s, tmp, &lu_sites, ls_linkage) { - if (shrink_param(sc, nr_to_scan) != 0) { - remain = lu_site_purge(&lu_shrink_env, s, remain); - /* - * Move just shrunk site to the tail of site list to - * assure shrinking fairness. - */ - list_move_tail(&s->ls_linkage, &splice); - } - memset(&stats, 0, sizeof(stats)); lu_site_stats_get(s->ls_obj_hash, &stats, 0); cached += stats.lss_total - stats.lss_busy; - if (shrink_param(sc, nr_to_scan) && remain <= 0) - break; } - list_splice(&splice, lu_sites.prev); mutex_unlock(&lu_sites_guard); cached = (cached / 100) * sysctl_vfs_cache_pressure; - if (shrink_param(sc, nr_to_scan) == 0) - CDEBUG(D_INODE, "%d objects cached\n", cached); + CDEBUG(D_INODE, "%ld objects cached\n", cached); return cached; } +static unsigned long lu_cache_shrink_scan(struct shrinker *sk, + struct shrink_control *sc) +{ + struct lu_site *s; + struct lu_site *tmp; + unsigned long remain = sc->nr_to_scan, freed = 0; + LIST_HEAD(splice); + + if (!(sc->gfp_mask & __GFP_FS)) + /* We must not take the lu_sites_guard lock when + * __GFP_FS is *not* set because of the deadlock + * possibility detailed above. Additionally, + * since we cannot determine the number of + * objects in the cache without taking this + * lock, we're in a particularly tough spot. As + * a result, we'll just lie and say our cache is + * empty. This _should_ be ok, as we can't + * reclaim objects when __GFP_FS is *not* set + * anyways. + */ + return SHRINK_STOP; + + mutex_lock(&lu_sites_guard); + list_for_each_entry_safe(s, tmp, &lu_sites, ls_linkage) { + freed = lu_site_purge(&lu_shrink_env, s, remain); + remain -= freed; + /* + * Move just shrunk site to the tail of site list to + * assure shrinking fairness. + */ + list_move_tail(&s->ls_linkage, &splice); + } + list_splice(&splice, lu_sites.prev); + mutex_unlock(&lu_sites_guard); + + return sc->nr_to_scan - remain; +} + /* * Debugging stuff. */ @@ -1917,6 +1919,12 @@ int lu_printk_printer(const struct lu_env *env, return 0; } +static struct shrinker lu_site_shrinker = { + .count_objects = lu_cache_shrink_count, + .scan_objects = lu_cache_shrink_scan, + .seeks = DEFAULT_SEEKS, +}; + /** * Initialization of global lu_* data. */ @@ -1951,9 +1959,7 @@ int lu_global_init(void) * inode, one for ea. Unfortunately setting this high value results in * lu_object/inode cache consuming all the memory. */ - lu_site_shrinker = set_shrinker(DEFAULT_SEEKS, lu_cache_shrink); - if (lu_site_shrinker == NULL) - return -ENOMEM; + register_shrinker(&lu_site_shrinker); return result; } @@ -1963,11 +1969,7 @@ int lu_global_init(void) */ void lu_global_fini(void) { - if (lu_site_shrinker != NULL) { - remove_shrinker(lu_site_shrinker); - lu_site_shrinker = NULL; - } - + unregister_shrinker(&lu_site_shrinker); lu_context_key_degister(&lu_global_key); /* @@ -2079,7 +2081,7 @@ void lu_object_assign_fid(const struct lu_env *env, struct lu_object *o, cfs_hash_bd_get_and_lock(hs, (void *)fid, &bd, 1); shadow = htable_lookup(s, &bd, fid, &waiter, &version); /* supposed to be unique */ - LASSERT(shadow == NULL); + LASSERT(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT); *old = *fid; bkt = cfs_hash_bd_extra_get(hs, &bd); cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash); diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ucred.c b/drivers/staging/lustre/lustre/obdclass/lu_ucred.c index 229db6c39b7..e23e545b0d6 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_ucred.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_ucred.c @@ -33,13 +33,13 @@ * This file is part of Lustre, http://www.lustre.org/ * Lustre is a trademark of Sun Microsystems, Inc. * - * lustre/obdclass/lu_object.c + * lustre/obdclass/lu_ucred.c * - * Lustre Object. - * These are the only exported functions, they provide some generic - * infrastructure for managing object devices + * Lustre user credentials context infrastructure. * * Author: Nikita Danilov <nikita.danilov@sun.com> + * Author: Fan Yong <fan.yong@intel.com> + * Author: Vitaly Fertman <vitaly_fertman@xyratex.com> */ #define DEBUG_SUBSYSTEM S_CLASS diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 69d6499ef73..be31d32b82c 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -65,7 +65,6 @@ void class_handle_hash(struct portals_handle *h, struct portals_handle_ops *ops) { struct handle_bucket *bucket; - ENTRY; LASSERT(h != NULL); LASSERT(list_empty(&h->h_link)); @@ -100,7 +99,6 @@ void class_handle_hash(struct portals_handle *h, CDEBUG(D_INFO, "added object %p with handle "LPX64" to hash\n", h, h->h_cookie); - EXIT; } EXPORT_SYMBOL(class_handle_hash); @@ -139,7 +137,6 @@ EXPORT_SYMBOL(class_handle_unhash); void class_handle_hash_back(struct portals_handle *h) { struct handle_bucket *bucket; - ENTRY; bucket = handle_hash + (h->h_cookie & HANDLE_HASH_MASK); @@ -147,8 +144,6 @@ void class_handle_hash_back(struct portals_handle *h) list_add_rcu(&h->h_link, &bucket->head); h->h_in = 1; spin_unlock(&bucket->lock); - - EXIT; } EXPORT_SYMBOL(class_handle_hash_back); @@ -157,7 +152,6 @@ void *class_handle2object(__u64 cookie) struct handle_bucket *bucket; struct portals_handle *h; void *retval = NULL; - ENTRY; LASSERT(handle_hash != NULL); @@ -180,7 +174,7 @@ void *class_handle2object(__u64 cookie) } rcu_read_unlock(); - RETURN(retval); + return retval; } EXPORT_SYMBOL(class_handle2object); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c index 2fa2589dc8e..df4936ad237 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c @@ -191,7 +191,6 @@ int class_check_uuid(struct obd_uuid *uuid, __u64 nid) { struct uuid_nid_data *entry; int found = 0; - ENTRY; CDEBUG(D_INFO, "check if uuid %s has %s.\n", obd_uuid2str(uuid), libcfs_nid2str(nid)); @@ -213,6 +212,6 @@ int class_check_uuid(struct obd_uuid *uuid, __u64 nid) break; } spin_unlock(&g_uuid_lock); - RETURN(found); + return found; } EXPORT_SYMBOL(class_check_uuid); diff --git a/drivers/staging/lustre/lustre/obdclass/md_attrs.c b/drivers/staging/lustre/lustre/obdclass/md_attrs.c index b71344a04c7..f7187829e27 100644 --- a/drivers/staging/lustre/lustre/obdclass/md_attrs.c +++ b/drivers/staging/lustre/lustre/obdclass/md_attrs.c @@ -99,19 +99,18 @@ EXPORT_SYMBOL(lustre_som_swab); int lustre_buf2som(void *buf, int rc, struct md_som_data *msd) { struct som_attrs *attrs = (struct som_attrs *)buf; - ENTRY; if (rc == 0 || rc == -ENODATA) /* no SOM attributes */ - RETURN(-ENODATA); + return -ENODATA; if (rc < 0) /* error hit while fetching xattr */ - RETURN(rc); + return rc; /* check SOM compatibility */ if (attrs->som_incompat & ~cpu_to_le32(SOM_INCOMPAT_SUPP)) - RETURN(-ENODATA); + return -ENODATA; /* unpack SOM attributes */ lustre_som_swab(attrs); @@ -124,7 +123,7 @@ int lustre_buf2som(void *buf, int rc, struct md_som_data *msd) msd->msd_blocks = attrs->som_blocks; msd->msd_mountid = attrs->som_mountid; - RETURN(0); + return 0; } EXPORT_SYMBOL(lustre_buf2som); @@ -156,15 +155,14 @@ EXPORT_SYMBOL(lustre_hsm_swab); int lustre_buf2hsm(void *buf, int rc, struct md_hsm *mh) { struct hsm_attrs *attrs = (struct hsm_attrs *)buf; - ENTRY; if (rc == 0 || rc == -ENODATA) /* no HSM attributes */ - RETURN(-ENODATA); + return -ENODATA; if (rc < 0) /* error hit while fetching xattr */ - RETURN(rc); + return rc; /* unpack HSM attributes */ lustre_hsm_swab(attrs); @@ -175,7 +173,7 @@ int lustre_buf2hsm(void *buf, int rc, struct md_hsm *mh) mh->mh_arch_id = attrs->hsm_arch_id; mh->mh_arch_ver = attrs->hsm_arch_ver; - RETURN(0); + return 0; } EXPORT_SYMBOL(lustre_buf2hsm); @@ -188,7 +186,6 @@ EXPORT_SYMBOL(lustre_buf2hsm); void lustre_hsm2buf(void *buf, struct md_hsm *mh) { struct hsm_attrs *attrs = (struct hsm_attrs *)buf; - ENTRY; /* copy HSM attributes */ attrs->hsm_compat = mh->mh_compat; diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index bbf06d009fd..d0a64ff5358 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -93,7 +93,7 @@ struct cfg_interop_param *class_find_old_param(const char *param, int name_len = 0; if (param == NULL || ptr == NULL) - RETURN(NULL); + return NULL; value = strchr(param, '='); if (value == NULL) @@ -104,11 +104,11 @@ struct cfg_interop_param *class_find_old_param(const char *param, while (ptr->old_param != NULL) { if (strncmp(param, ptr->old_param, name_len) == 0 && name_len == strlen(ptr->old_param)) - RETURN(ptr); + return ptr; ptr++; } - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(class_find_old_param); @@ -335,23 +335,22 @@ int class_attach(struct lustre_cfg *lcfg) struct obd_device *obd = NULL; char *typename, *name, *uuid; int rc, len; - ENTRY; if (!LUSTRE_CFG_BUFLEN(lcfg, 1)) { CERROR("No type passed!\n"); - RETURN(-EINVAL); + return -EINVAL; } typename = lustre_cfg_string(lcfg, 1); if (!LUSTRE_CFG_BUFLEN(lcfg, 0)) { CERROR("No name passed!\n"); - RETURN(-EINVAL); + return -EINVAL; } name = lustre_cfg_string(lcfg, 0); if (!LUSTRE_CFG_BUFLEN(lcfg, 2)) { CERROR("No UUID passed!\n"); - RETURN(-EINVAL); + return -EINVAL; } uuid = lustre_cfg_string(lcfg, 2); @@ -433,7 +432,7 @@ int class_attach(struct lustre_cfg *lcfg) obd->obd_attached = 1; CDEBUG(D_IOCTL, "OBD: dev %d attached type %s with refcount %d\n", obd->obd_minor, typename, atomic_read(&obd->obd_refcount)); - RETURN(0); + return 0; out: if (obd != NULL) { class_release_dev(obd); @@ -449,7 +448,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { int err = 0; struct obd_export *exp; - ENTRY; LASSERT(obd != NULL); LASSERTF(obd == class_num2obd(obd->obd_minor), @@ -462,13 +460,13 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) /* have we attached a type to this device? */ if (!obd->obd_attached) { CERROR("Device %d not attached\n", obd->obd_minor); - RETURN(-ENODEV); + return -ENODEV; } if (obd->obd_set_up) { CERROR("Device %d already setup (type %s)\n", obd->obd_minor, obd->obd_type->typ_name); - RETURN(-EEXIST); + return -EEXIST; } /* is someone else setting us up right now? (attach inits spinlock) */ @@ -477,7 +475,7 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) spin_unlock(&obd->obd_dev_lock); CERROR("Device %d setup in progress (type %s)\n", obd->obd_minor, obd->obd_type->typ_name); - RETURN(-EEXIST); + return -EEXIST; } /* just leave this on forever. I can't use obd_set_up here because other fns check that status, and we're not actually set up yet. */ @@ -542,7 +540,7 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) CDEBUG(D_IOCTL, "finished setup of obd %s (uuid %s)\n", obd->obd_name, obd->obd_uuid.uuid); - RETURN(0); + return 0; err_exp: if (obd->obd_self_export) { class_unlink_export(obd->obd_self_export); @@ -572,18 +570,16 @@ EXPORT_SYMBOL(class_setup); */ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg) { - ENTRY; - if (obd->obd_set_up) { CERROR("OBD device %d still set up\n", obd->obd_minor); - RETURN(-EBUSY); + return -EBUSY; } spin_lock(&obd->obd_dev_lock); if (!obd->obd_attached) { spin_unlock(&obd->obd_dev_lock); CERROR("OBD device %d not attached\n", obd->obd_minor); - RETURN(-ENODEV); + return -ENODEV; } obd->obd_attached = 0; spin_unlock(&obd->obd_dev_lock); @@ -592,7 +588,7 @@ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg) obd->obd_name, obd->obd_uuid.uuid); class_decref(obd, "attach", obd); - RETURN(0); + return 0; } EXPORT_SYMBOL(class_detach); @@ -604,20 +600,19 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) { int err = 0; char *flag; - ENTRY; OBD_RACE(OBD_FAIL_LDLM_RECOV_CLIENTS); if (!obd->obd_set_up) { CERROR("Device %d not setup\n", obd->obd_minor); - RETURN(-ENODEV); + return -ENODEV; } spin_lock(&obd->obd_dev_lock); if (obd->obd_stopping) { spin_unlock(&obd->obd_dev_lock); CERROR("OBD %d already stopping\n", obd->obd_minor); - RETURN(-ENODEV); + return -ENODEV; } /* Leave this on forever */ obd->obd_stopping = 1; @@ -696,7 +691,7 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) class_decref(obd, "setup", obd); obd->obd_set_up = 0; - RETURN(0); + return 0; } EXPORT_SYMBOL(class_cleanup); @@ -767,12 +762,11 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg) struct obd_import *imp; struct obd_uuid uuid; int rc; - ENTRY; if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1 || LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(struct obd_uuid)) { CERROR("invalid conn_uuid\n"); - RETURN(-EINVAL); + return -EINVAL; } if (strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) && strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) && @@ -780,19 +774,19 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg) strcmp(obd->obd_type->typ_name, LUSTRE_LWP_NAME) && strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME)) { CERROR("can't add connection on non-client dev\n"); - RETURN(-EINVAL); + return -EINVAL; } imp = obd->u.cli.cl_import; if (!imp) { CERROR("try to add conn on immature client dev\n"); - RETURN(-EINVAL); + return -EINVAL; } obd_str2uuid(&uuid, lustre_cfg_string(lcfg, 1)); rc = obd_add_conn(imp, &uuid, lcfg->lcfg_num); - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_add_conn); @@ -803,29 +797,28 @@ int class_del_conn(struct obd_device *obd, struct lustre_cfg *lcfg) struct obd_import *imp; struct obd_uuid uuid; int rc; - ENTRY; if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1 || LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(struct obd_uuid)) { CERROR("invalid conn_uuid\n"); - RETURN(-EINVAL); + return -EINVAL; } if (strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) && strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME)) { CERROR("can't del connection on non-client dev\n"); - RETURN(-EINVAL); + return -EINVAL; } imp = obd->u.cli.cl_import; if (!imp) { CERROR("try to del conn on immature client dev\n"); - RETURN(-EINVAL); + return -EINVAL; } obd_str2uuid(&uuid, lustre_cfg_string(lcfg, 1)); rc = obd_del_conn(imp, &uuid); - RETURN(rc); + return rc; } LIST_HEAD(lustre_profile_list); @@ -834,13 +827,12 @@ struct lustre_profile *class_get_profile(const char * prof) { struct lustre_profile *lprof; - ENTRY; list_for_each_entry(lprof, &lustre_profile_list, lp_list) { if (!strcmp(lprof->lp_profile, prof)) { - RETURN(lprof); + return lprof; } } - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(class_get_profile); @@ -853,13 +845,12 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, { struct lustre_profile *lprof; int err = 0; - ENTRY; CDEBUG(D_CONFIG, "Add profile %s\n", prof); OBD_ALLOC(lprof, sizeof(*lprof)); if (lprof == NULL) - RETURN(-ENOMEM); + return -ENOMEM; INIT_LIST_HEAD(&lprof->lp_list); LASSERT(proflen == (strlen(prof) + 1)); @@ -883,7 +874,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, } list_add(&lprof->lp_list, &lustre_profile_list); - RETURN(err); + return err; out: if (lprof->lp_md) @@ -893,13 +884,12 @@ out: if (lprof->lp_profile) OBD_FREE(lprof->lp_profile, proflen); OBD_FREE(lprof, sizeof(*lprof)); - RETURN(err); + return err; } void class_del_profile(const char *prof) { struct lustre_profile *lprof; - ENTRY; CDEBUG(D_CONFIG, "Del profile %s\n", prof); @@ -912,7 +902,6 @@ void class_del_profile(const char *prof) OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1); OBD_FREE(lprof, sizeof *lprof); } - EXIT; } EXPORT_SYMBOL(class_del_profile); @@ -920,7 +909,6 @@ EXPORT_SYMBOL(class_del_profile); void class_del_profiles(void) { struct lustre_profile *lprof, *n; - ENTRY; list_for_each_entry_safe(lprof, n, &lustre_profile_list, lp_list) { list_del(&lprof->lp_list); @@ -930,13 +918,11 @@ void class_del_profiles(void) OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1); OBD_FREE(lprof, sizeof *lprof); } - EXIT; } EXPORT_SYMBOL(class_del_profiles); static int class_set_global(char *ptr, int val, struct lustre_cfg *lcfg) { - ENTRY; if (class_match_param(ptr, PARAM_AT_MIN, NULL) == 0) at_min = val; else if (class_match_param(ptr, PARAM_AT_MAX, NULL) == 0) @@ -951,10 +937,10 @@ static int class_set_global(char *ptr, int val, struct lustre_cfg *lcfg) strlcpy(obd_jobid_var, lustre_cfg_string(lcfg, 2), JOBSTATS_JOBID_VAR_MAX_LEN + 1); else - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_IOCTL, "global %s = %d\n", ptr, val); - RETURN(0); + return 0; } @@ -991,14 +977,13 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, char *value = NULL; int name_len = 0; int new_len = 0; - ENTRY; if (cfg == NULL || new_name == NULL) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); param = lustre_cfg_string(cfg, 1); if (param == NULL) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); value = strchr(param, '='); if (value == NULL) @@ -1010,7 +995,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, OBD_ALLOC(new_param, new_len); if (new_param == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); strcpy(new_param, new_name); if (value != NULL) @@ -1019,7 +1004,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, OBD_ALLOC_PTR(bufs); if (bufs == NULL) { OBD_FREE(new_param, new_len); - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); } lustre_cfg_bufs_reset(bufs, NULL); @@ -1031,14 +1016,14 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, OBD_FREE(new_param, new_len); OBD_FREE_PTR(bufs); if (new_cfg == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); new_cfg->lcfg_num = cfg->lcfg_num; new_cfg->lcfg_flags = cfg->lcfg_flags; new_cfg->lcfg_nid = cfg->lcfg_nid; new_cfg->lcfg_nal = cfg->lcfg_nal; - RETURN(new_cfg); + return new_cfg; } EXPORT_SYMBOL(lustre_cfg_rename); @@ -1244,11 +1229,10 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, int matched = 0, j = 0; int rc = 0; int skip = 0; - ENTRY; if (lcfg->lcfg_command != LCFG_PARAM) { CERROR("Unknown command: %d\n", lcfg->lcfg_command); - RETURN(-EINVAL); + return -EINVAL; } /* fake a seq file so that var->fops->write can work... */ @@ -1295,7 +1279,7 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, /* If the prefix doesn't match, return error so we can pass it down the stack */ if (strnchr(key, keylen, '.')) - RETURN(-ENOSYS); + return -ENOSYS; CERROR("%s: unknown param %s\n", (char *)lustre_cfg_string(lcfg, 0), key); /* rc = -EINVAL; continue parsing other params */ @@ -1316,7 +1300,7 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, rc = 0; if (!rc && skip) rc = skip; - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_process_proc_param); @@ -1335,7 +1319,6 @@ int class_config_llog_handler(const struct lu_env *env, int cfg_len = rec->lrh_len; char *cfg_buf = (char*) (rec + 1); int rc = 0; - ENTRY; //class_config_dump_handler(handle, rec, data); @@ -1426,10 +1409,13 @@ int class_config_llog_handler(const struct lu_env *env, } - if ((clli->cfg_flags & CFG_F_EXCLUDE) && - (lcfg->lcfg_command == LCFG_LOV_ADD_OBD)) - /* Add inactive instead */ - lcfg->lcfg_command = LCFG_LOV_ADD_INA; + if (clli->cfg_flags & CFG_F_EXCLUDE) { + CDEBUG(D_CONFIG, "cmd: %x marked EXCLUDED\n", + lcfg->lcfg_command); + if (lcfg->lcfg_command == LCFG_LOV_ADD_OBD) + /* Add inactive instead */ + lcfg->lcfg_command = LCFG_LOV_ADD_INA; + } lustre_cfg_bufs_init(&bufs, lcfg); @@ -1513,7 +1499,7 @@ out: handle->lgh_ctxt->loc_obd->obd_name, rc); class_config_dump_handler(NULL, handle, rec, data); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_config_llog_handler); @@ -1524,12 +1510,11 @@ int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_handle *llh; llog_cb_t callback; int rc; - ENTRY; CDEBUG(D_INFO, "looking up llog %s\n", name); rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS); if (rc) - RETURN(rc); + return rc; rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL); if (rc) @@ -1555,7 +1540,7 @@ int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, parse_out: llog_close(env, llh); - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_config_parse_llog); @@ -1571,12 +1556,10 @@ int class_config_parse_rec(struct llog_rec_hdr *rec, char *buf, int size) char *end = buf + size; int rc = 0; - ENTRY; - LASSERT(rec->lrh_type == OBD_CFG_REC); rc = lustre_cfg_sanity_check(lcfg, rec->lrh_len); if (rc < 0) - RETURN(rc); + return rc; ptr += snprintf(ptr, end-ptr, "cmd=%05x ", lcfg->lcfg_command); if (lcfg->lcfg_flags) @@ -1607,7 +1590,7 @@ int class_config_parse_rec(struct llog_rec_hdr *rec, char *buf, int size) } /* return consumed bytes */ rc = ptr - buf; - RETURN(rc); + return rc; } int class_config_dump_handler(const struct lu_env *env, @@ -1617,11 +1600,9 @@ int class_config_dump_handler(const struct lu_env *env, char *outstr; int rc = 0; - ENTRY; - OBD_ALLOC(outstr, 256); if (outstr == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (rec->lrh_type == OBD_CFG_REC) { class_config_parse_rec(rec, outstr, 256); @@ -1632,7 +1613,7 @@ int class_config_dump_handler(const struct lu_env *env, } OBD_FREE(outstr, 256); - RETURN(rc); + return rc; } int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt, @@ -1641,13 +1622,11 @@ int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_handle *llh; int rc; - ENTRY; - LCONSOLE_INFO("Dumping config log %s\n", name); rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS); if (rc) - RETURN(rc); + return rc; rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL); if (rc) @@ -1658,7 +1637,7 @@ parse_out: llog_close(env, llh); LCONSOLE_INFO("End config log %s\n", name); - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_config_dump_llog); @@ -1671,11 +1650,10 @@ int class_manual_cleanup(struct obd_device *obd) struct lustre_cfg *lcfg; struct lustre_cfg_bufs bufs; int rc; - ENTRY; if (!obd) { CERROR("empty cleanup\n"); - RETURN(-EALREADY); + return -EALREADY; } if (obd->obd_force) @@ -1690,7 +1668,7 @@ int class_manual_cleanup(struct obd_device *obd) lustre_cfg_bufs_set_string(&bufs, 1, flags); lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); if (!lcfg) - RETURN(-ENOMEM); + return -ENOMEM; rc = class_process_config(lcfg); if (rc) { @@ -1705,7 +1683,7 @@ int class_manual_cleanup(struct obd_device *obd) CERROR("detach failed %d: %s\n", rc, obd->obd_name); out: lustre_cfg_free(lcfg); - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_manual_cleanup); @@ -1797,7 +1775,7 @@ nid_key(struct hlist_node *hnode) exp = hlist_entry(hnode, struct obd_export, exp_nid_hash); - RETURN(&exp->exp_connection->c_peer.nid); + return &exp->exp_connection->c_peer.nid; } /* @@ -1812,8 +1790,8 @@ nid_kepcmp(const void *key, struct hlist_node *hnode) LASSERT(key); exp = hlist_entry(hnode, struct obd_export, exp_nid_hash); - RETURN(exp->exp_connection->c_peer.nid == *(lnet_nid_t *)key && - !exp->exp_failed); + return exp->exp_connection->c_peer.nid == *(lnet_nid_t *)key && + !exp->exp_failed; } static void * diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 99adad9793c..68a4d6a0eb0 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -47,10 +47,8 @@ #include <obd.h> #include <lvfs.h> -#include <lustre_fsfilt.h> #include <obd_class.h> #include <lustre/lustre_user.h> -#include <linux/version.h> #include <lustre_log.h> #include <lustre_disk.h> #include <lustre_param.h> @@ -82,14 +80,13 @@ int lustre_process_log(struct super_block *sb, char *logname, struct lustre_sb_info *lsi = s2lsi(sb); struct obd_device *mgc = lsi->lsi_mgc; int rc; - ENTRY; LASSERT(mgc); LASSERT(cfg); OBD_ALLOC_PTR(bufs); if (bufs == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* mgc_process_config */ lustre_cfg_bufs_reset(bufs, mgc->obd_name); @@ -119,7 +116,7 @@ int lustre_process_log(struct super_block *sb, char *logname, rc); /* class_obd_list(); */ - RETURN(rc); + return rc; } EXPORT_SYMBOL(lustre_process_log); @@ -132,10 +129,9 @@ int lustre_end_log(struct super_block *sb, char *logname, struct lustre_sb_info *lsi = s2lsi(sb); struct obd_device *mgc = lsi->lsi_mgc; int rc; - ENTRY; if (!mgc) - RETURN(-ENOENT); + return -ENOENT; /* mgc_process_config */ lustre_cfg_bufs_reset(&bufs, mgc->obd_name); @@ -145,7 +141,7 @@ int lustre_end_log(struct super_block *sb, char *logname, lcfg = lustre_cfg_new(LCFG_LOG_END, &bufs); rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); lustre_cfg_free(lcfg); - RETURN(rc); + return rc; } EXPORT_SYMBOL(lustre_end_log); @@ -225,7 +221,6 @@ int lustre_start_mgc(struct super_block *sb) char *ptr; int recov_bk; int rc = 0, i = 0, j, len; - ENTRY; LASSERT(lsi->lsi_lmd); @@ -254,7 +249,7 @@ int lustre_start_mgc(struct super_block *sb) } if (i == 0) { CERROR("No valid MGS nids found.\n"); - RETURN(-EINVAL); + return -EINVAL; } mutex_lock(&mgc_start_lock); @@ -478,7 +473,7 @@ out_free: OBD_FREE(mgcname, len); if (niduuid) OBD_FREE(niduuid, len + 2); - RETURN(rc); + return rc; } static int lustre_stop_mgc(struct super_block *sb) @@ -487,13 +482,12 @@ static int lustre_stop_mgc(struct super_block *sb) struct obd_device *obd; char *niduuid = 0, *ptr = 0; int i, rc = 0, len = 0; - ENTRY; if (!lsi) - RETURN(-ENOENT); + return -ENOENT; obd = lsi->lsi_mgc; if (!obd) - RETURN(-ENOENT); + return -ENOENT; lsi->lsi_mgc = NULL; mutex_lock(&mgc_start_lock); @@ -549,7 +543,7 @@ out: /* class_import_put will get rid of the additional connections */ mutex_unlock(&mgc_start_lock); - RETURN(rc); + return rc; } /***************** lustre superblock **************/ @@ -557,15 +551,14 @@ out: struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) { struct lustre_sb_info *lsi; - ENTRY; OBD_ALLOC_PTR(lsi); if (!lsi) - RETURN(NULL); + return NULL; OBD_ALLOC_PTR(lsi->lsi_lmd); if (!lsi->lsi_lmd) { OBD_FREE_PTR(lsi); - RETURN(NULL); + return NULL; } lsi->lsi_lmd->lmd_exclude_count = 0; @@ -578,13 +571,12 @@ struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) /* Default umount style */ lsi->lsi_flags = LSI_UMOUNT_FAILOVER; - RETURN(lsi); + return lsi; } static int lustre_free_lsi(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); - ENTRY; LASSERT(lsi != NULL); CDEBUG(D_MOUNT, "Freeing lsi %p\n", lsi); @@ -625,7 +617,7 @@ static int lustre_free_lsi(struct super_block *sb) OBD_FREE(lsi, sizeof(*lsi)); s2lsi_nocast(sb) = NULL; - RETURN(0); + return 0; } /* The lsi has one reference for every server that is using the disk - @@ -633,7 +625,6 @@ static int lustre_free_lsi(struct super_block *sb) int lustre_put_lsi(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); - ENTRY; LASSERT(lsi != NULL); @@ -645,11 +636,20 @@ int lustre_put_lsi(struct super_block *sb) obd_zombie_barrier(); } lustre_free_lsi(sb); - RETURN(1); + return 1; } - RETURN(0); + return 0; } +/*** SERVER NAME *** + * <FSNAME><SEPERATOR><TYPE><INDEX> + * FSNAME is between 1 and 8 characters (inclusive). + * Excluded characters are '/' and ':' + * SEPERATOR is either ':' or '-' + * TYPE: "OST", "MDT", etc. + * INDEX: Hex representation of the index + */ + /** Get the fsname ("lustre") from the server name ("lustre-OST003F"). * @param [in] svname server name including type and index * @param [out] fsname Buffer to copy filesystem name prefix into. @@ -659,22 +659,13 @@ int lustre_put_lsi(struct super_block *sb) */ int server_name2fsname(const char *svname, char *fsname, const char **endptr) { - const char *dash = strrchr(svname, '-'); - if (!dash) { - dash = strrchr(svname, ':'); - if (!dash) - return -EINVAL; - } + const char *dash; - /* interpret <fsname>-MDTXXXXX-mdc as mdt, the better way is to pass - * in the fsname, then determine the server index */ - if (!strcmp(LUSTRE_MDC_NAME, dash + 1)) { - dash--; - for (; dash > svname && *dash != '-' && *dash != ':'; dash--) - ; - if (dash == svname) - return -EINVAL; - } + dash = svname + strnlen(svname, 8); /* max fsname length is 8 */ + for (; dash > svname && *dash != '-' && *dash != ':'; dash--) + ; + if (dash == svname) + return -EINVAL; if (fsname != NULL) { strncpy(fsname, svname, dash - svname); @@ -697,15 +688,15 @@ int server_name2svname(const char *label, char *svname, const char **endptr, size_t svsize) { int rc; - const const char *dash; + const char *dash; /* We use server_name2fsname() just for parsing */ rc = server_name2fsname(label, NULL, &dash); if (rc != 0) return rc; - if (*dash != '-') - return -1; + if (endptr != NULL) + *endptr = dash; if (strlcpy(svname, dash + 1, svsize) >= svsize) return -E2BIG; @@ -730,9 +721,6 @@ int server_name2index(const char *svname, __u32 *idx, const char **endptr) if (rc != 0) return rc; - if (*dash != '-') - return -EINVAL; - dash++; if (strncmp(dash, "MDT", 3) == 0) @@ -744,11 +732,20 @@ int server_name2index(const char *svname, __u32 *idx, const char **endptr) dash += 3; - if (strcmp(dash, "all") == 0) + if (strncmp(dash, "all", 3) == 0) { + if (endptr != NULL) + *endptr = dash + 3; return rc | LDD_F_SV_ALL; + } index = simple_strtoul(dash, (char **)endptr, 16); - *idx = index; + if (idx != NULL) + *idx = index; + + /* Account for -mdc after index that is possible when specifying mdt */ + if (endptr != NULL && strncmp(LUSTRE_MDC_NAME, *endptr + 1, + sizeof(LUSTRE_MDC_NAME)-1) == 0) + *endptr += sizeof(LUSTRE_MDC_NAME); return rc; } @@ -760,7 +757,6 @@ EXPORT_SYMBOL(server_name2index); int lustre_common_put_super(struct super_block *sb) { int rc; - ENTRY; CDEBUG(D_MOUNT, "dropping sb %p\n", sb); @@ -769,7 +765,7 @@ int lustre_common_put_super(struct super_block *sb) if (rc && (rc != -ENOENT)) { if (rc != -EBUSY) { CERROR("Can't stop MGC: %d\n", rc); - RETURN(rc); + return rc; } /* BUSY just means that there's some other obd that needs the mgc. Let him clean it up. */ @@ -778,7 +774,7 @@ int lustre_common_put_super(struct super_block *sb) /* Drop a ref to the mounted disk */ lustre_put_lsi(sb); lu_types_stop(); - RETURN(rc); + return rc; } EXPORT_SYMBOL(lustre_common_put_super); @@ -816,12 +812,11 @@ int lustre_check_exclusion(struct super_block *sb, char *svname) struct lustre_mount_data *lmd = lsi->lsi_lmd; __u32 index; int i, rc; - ENTRY; rc = server_name2index(svname, &index, NULL); if (rc != LDD_F_SV_TYPE_OST) /* Only exclude OSTs */ - RETURN(0); + return 0; CDEBUG(D_MOUNT, "Check exclusion %s (%d) in %d of %s\n", svname, index, lmd->lmd_exclude_count, lmd->lmd_dev); @@ -829,10 +824,10 @@ int lustre_check_exclusion(struct super_block *sb, char *svname) for(i = 0; i < lmd->lmd_exclude_count; i++) { if (index == lmd->lmd_exclude[i]) { CWARN("Excluding %s (on exclusion list)\n", svname); - RETURN(1); + return 1; } } - RETURN(0); + return 0; } /* mount -v -o exclude=lustre-OST0001:lustre-OST0002 -t lustre ... */ @@ -841,7 +836,6 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) const char *s1 = ptr, *s2; __u32 index, *exclude_list; int rc = 0, devmax; - ENTRY; /* The shortest an ost name can be is 8 chars: -OST0000. We don't actually know the fsname at this time, so in fact @@ -851,20 +845,22 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) /* temp storage until we figure out how many we have */ OBD_ALLOC(exclude_list, sizeof(index) * devmax); if (!exclude_list) - RETURN(-ENOMEM); + return -ENOMEM; /* we enter this fn pointing at the '=' */ while (*s1 && *s1 != ' ' && *s1 != ',') { s1++; rc = server_name2index(s1, &index, &s2); if (rc < 0) { - CERROR("Can't parse server name '%s'\n", s1); + CERROR("Can't parse server name '%s': rc = %d\n", + s1, rc); break; } if (rc == LDD_F_SV_TYPE_OST) exclude_list[lmd->lmd_exclude_count++] = index; else - CDEBUG(D_MOUNT, "ignoring exclude %.7s\n", s1); + CDEBUG(D_MOUNT, "ignoring exclude %.*s: type = %#x\n", + (uint)(s2-s1), s1, rc); s1 = s2; /* now we are pointing at ':' (next exclude) or ',' (end of excludes) */ @@ -887,7 +883,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) } } OBD_FREE(exclude_list, sizeof(index) * devmax); - RETURN(rc); + return rc; } static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr) @@ -991,13 +987,12 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) char *s1, *s2, *devname = NULL; struct lustre_mount_data *raw = (struct lustre_mount_data *)options; int rc = 0; - ENTRY; LASSERT(lmd); if (!options) { LCONSOLE_ERROR_MSG(0x162, "Missing mount data: check that " "/sbin/mount.lustre is installed.\n"); - RETURN(-EINVAL); + return -EINVAL; } /* Options should be a string - try to detect old lmd data */ @@ -1005,13 +1000,13 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) LCONSOLE_ERROR_MSG(0x163, "You're using an old version of " "/sbin/mount.lustre. Please install " "version %s\n", LUSTRE_VERSION_STRING); - RETURN(-EINVAL); + return -EINVAL; } lmd->lmd_magic = LMD_MAGIC; OBD_ALLOC(lmd->lmd_params, 4096); if (lmd->lmd_params == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lmd->lmd_params[0] = '\0'; /* Set default flags here */ @@ -1150,14 +1145,14 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) /* Freed in lustre_free_lsi */ OBD_ALLOC(lmd->lmd_profile, strlen(s1) + 8); if (!lmd->lmd_profile) - RETURN(-ENOMEM); + return -ENOMEM; sprintf(lmd->lmd_profile, "%s-client", s1); } /* Freed in lustre_free_lsi */ OBD_ALLOC(lmd->lmd_dev, strlen(devname) + 1); if (!lmd->lmd_dev) - RETURN(-ENOMEM); + return -ENOMEM; strcpy(lmd->lmd_dev, devname); /* Save mount options */ @@ -1168,18 +1163,18 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) /* Freed in lustre_free_lsi */ OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1); if (!lmd->lmd_opts) - RETURN(-ENOMEM); + return -ENOMEM; strcpy(lmd->lmd_opts, options); } lmd_print(lmd); lmd->lmd_magic = LMD_MAGIC; - RETURN(rc); + return rc; invalid: CERROR("Bad mount options %s\n", options); - RETURN(-EINVAL); + return -EINVAL; } struct lustre_mount_data2 { @@ -1198,13 +1193,12 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) struct lustre_mount_data2 *lmd2 = data; struct lustre_sb_info *lsi; int rc; - ENTRY; CDEBUG(D_MOUNT|D_VFSTRACE, "VFS Op: sb %p\n", sb); lsi = lustre_init_lsi(sb); if (!lsi) - RETURN(-ENOMEM); + return -ENOMEM; lmd = lsi->lsi_lmd; /* diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index 01a0e1f83a6..70997648a4f 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/obdo.c @@ -100,11 +100,11 @@ void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid) newvalid |= OBD_MD_FLMODE; } if (valid & OBD_MD_FLUID) { - dst->o_uid = src->i_uid; + dst->o_uid = from_kuid(&init_user_ns, src->i_uid); newvalid |= OBD_MD_FLUID; } if (valid & OBD_MD_FLGID) { - dst->o_gid = src->i_gid; + dst->o_gid = from_kgid(&init_user_ns, src->i_gid); newvalid |= OBD_MD_FLGID; } if (valid & OBD_MD_FLFLAGS) { @@ -232,16 +232,16 @@ void obdo_from_iattr(struct obdo *oa, struct iattr *attr, unsigned int ia_valid) if (ia_valid & ATTR_MODE) { oa->o_mode = attr->ia_mode; oa->o_valid |= OBD_MD_FLTYPE | OBD_MD_FLMODE; - if (!current_is_in_group(oa->o_gid) && + if (!in_group_p(make_kgid(&init_user_ns, oa->o_gid)) && !cfs_capable(CFS_CAP_FSETID)) oa->o_mode &= ~S_ISGID; } if (ia_valid & ATTR_UID) { - oa->o_uid = attr->ia_uid; + oa->o_uid = from_kuid(&init_user_ns, attr->ia_uid); oa->o_valid |= OBD_MD_FLUID; } if (ia_valid & ATTR_GID) { - oa->o_gid = attr->ia_gid; + oa->o_gid = from_kgid(&init_user_ns, attr->ia_gid); oa->o_valid |= OBD_MD_FLGID; } } @@ -281,16 +281,16 @@ void iattr_from_obdo(struct iattr *attr, struct obdo *oa, obd_flag valid) if (valid & OBD_MD_FLMODE) { attr->ia_mode = (attr->ia_mode & S_IFMT)|(oa->o_mode & ~S_IFMT); attr->ia_valid |= ATTR_MODE; - if (!current_is_in_group(oa->o_gid) && + if (!in_group_p(make_kgid(&init_user_ns, oa->o_gid)) && !cfs_capable(CFS_CAP_FSETID)) attr->ia_mode &= ~S_ISGID; } if (valid & OBD_MD_FLUID) { - attr->ia_uid = oa->o_uid; + attr->ia_uid = make_kuid(&init_user_ns, oa->o_uid); attr->ia_valid |= ATTR_UID; } if (valid & OBD_MD_FLGID) { - attr->ia_gid = oa->o_gid; + attr->ia_gid = make_kgid(&init_user_ns, oa->o_gid); attr->ia_valid |= ATTR_GID; } } diff --git a/drivers/staging/lustre/lustre/obdecho/echo.c b/drivers/staging/lustre/lustre/obdecho/echo.c index 9e64939af9d..debb9cec490 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo.c +++ b/drivers/staging/lustre/lustre/obdecho/echo.c @@ -96,12 +96,10 @@ static int echo_init_export(struct obd_export *exp) static int echo_destroy_export(struct obd_export *exp) { - ENTRY; - target_destroy_export(exp); ldlm_destroy_export(exp); - RETURN(0); + return 0; } static __u64 echo_next_id(struct obd_device *obddev) @@ -151,25 +149,24 @@ static int echo_destroy(const struct lu_env *env, struct obd_export *exp, { struct obd_device *obd = class_exp2obd(exp); - ENTRY; if (!obd) { CERROR("invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); - RETURN(-EINVAL); + return -EINVAL; } if (!(oa->o_valid & OBD_MD_FLID)) { CERROR("obdo missing FLID valid flag: "LPX64"\n", oa->o_valid); - RETURN(-EINVAL); + return -EINVAL; } if (ostid_id(&oa->o_oi) > obd->u.echo.eo_lastino || ostid_id(&oa->o_oi) < ECHO_INIT_OID) { CERROR("bad destroy objid: "DOSTID"\n", POSTID(&oa->o_oi)); - RETURN(-EINVAL); + return -EINVAL; } - RETURN(0); + return 0; } static int echo_getattr(const struct lu_env *env, struct obd_export *exp, @@ -178,24 +175,23 @@ static int echo_getattr(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd = class_exp2obd(exp); obd_id id = ostid_id(&oinfo->oi_oa->o_oi); - ENTRY; if (!obd) { CERROR("invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); - RETURN(-EINVAL); + return -EINVAL; } if (!(oinfo->oi_oa->o_valid & OBD_MD_FLID)) { CERROR("obdo missing FLID valid flag: "LPX64"\n", oinfo->oi_oa->o_valid); - RETURN(-EINVAL); + return -EINVAL; } obdo_cpy_md(oinfo->oi_oa, &obd->u.echo.eo_oa, oinfo->oi_oa->o_valid); ostid_set_seq_echo(&oinfo->oi_oa->o_oi); ostid_set_id(&oinfo->oi_oa->o_oi, id); - RETURN(0); + return 0; } static int echo_setattr(const struct lu_env *env, struct obd_export *exp, @@ -203,17 +199,16 @@ static int echo_setattr(const struct lu_env *env, struct obd_export *exp, { struct obd_device *obd = class_exp2obd(exp); - ENTRY; if (!obd) { CERROR("invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); - RETURN(-EINVAL); + return -EINVAL; } if (!(oinfo->oi_oa->o_valid & OBD_MD_FLID)) { CERROR("obdo missing FLID valid flag: "LPX64"\n", oinfo->oi_oa->o_valid); - RETURN(-EINVAL); + return -EINVAL; } memcpy(&obd->u.echo.eo_oa, oinfo->oi_oa, sizeof(*oinfo->oi_oa)); @@ -225,7 +220,7 @@ static int echo_setattr(const struct lu_env *env, struct obd_export *exp, oti->oti_ack_locks[0].lock = obd->u.echo.eo_nl_lock; } - RETURN(0); + return 0; } static void @@ -410,11 +405,10 @@ static int echo_preprw(const struct lu_env *env, int cmd, int tot_bytes = 0; int rc = 0; int i, left; - ENTRY; obd = export->exp_obd; if (obd == NULL) - RETURN(-EINVAL); + return -EINVAL; /* Temp fix to stop falling foul of osc_announce_cached() */ oa->o_valid &= ~(OBD_MD_FLBLOCKS | OBD_MD_FLGRANT); @@ -456,7 +450,7 @@ static int echo_preprw(const struct lu_env *env, int cmd, CDEBUG(D_PAGE, "%d pages allocated after prep\n", atomic_read(&obd->u.echo.eo_prep)); - RETURN(0); + return 0; preprw_cleanup: /* It is possible that we would rather handle errors by allow @@ -487,11 +481,10 @@ static int echo_commitrw(const struct lu_env *env, int cmd, struct obd_device *obd; int pgs = 0; int i; - ENTRY; obd = export->exp_obd; if (obd == NULL) - RETURN(-EINVAL); + return -EINVAL; if (rc) GOTO(commitrw_cleanup, rc); @@ -506,7 +499,7 @@ static int echo_commitrw(const struct lu_env *env, int cmd, if (niocount && res == NULL) { CERROR("NULL res niobuf with niocount %d\n", niocount); - RETURN(-EINVAL); + return -EINVAL; } LASSERT(oti == NULL || oti->oti_handle == (void *)DESC_PRIV); @@ -537,7 +530,7 @@ static int echo_commitrw(const struct lu_env *env, int cmd, CDEBUG(D_PAGE, "%d pages remain after commit\n", atomic_read(&obd->u.echo.eo_prep)); - RETURN(rc); + return rc; commitrw_cleanup: atomic_sub(pgs, &obd->u.echo.eo_prep); @@ -565,7 +558,6 @@ static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg) __u64 lock_flags = 0; struct ldlm_res_id res_id = {.name = {1}}; char ns_name[48]; - ENTRY; obd->u.echo.eo_obt.obt_magic = OBT_MAGIC; spin_lock_init(&obd->u.echo.eo_lock); @@ -578,7 +570,7 @@ static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg) LDLM_NS_TYPE_OST); if (obd->obd_namespace == NULL) { LBUG(); - RETURN(-ENOMEM); + return -ENOMEM; } rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, LDLM_PLAIN, @@ -600,13 +592,12 @@ static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg) ptlrpc_init_client (LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL, "echo_ldlm_cb_client", &obd->obd_ldlm_client); - RETURN(0); + return 0; } static int echo_cleanup(struct obd_device *obd) { int leaked; - ENTRY; lprocfs_obd_cleanup(obd); lprocfs_free_obd_stats(obd); @@ -624,7 +615,7 @@ static int echo_cleanup(struct obd_device *obd) if (leaked != 0) CERROR("%d prep/commitrw pages leaked\n", leaked); - RETURN(0); + return 0; } struct obd_ops echo_obd_ops = { diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 184195fde62..c8b43442dc7 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -43,6 +43,7 @@ #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> @@ -312,11 +313,9 @@ static void echo_page_fini(const struct lu_env *env, struct echo_page *ep = cl2echo_page(slice); struct echo_object *eco = cl2echo_obj(slice->cpl_obj); struct page *vmpage = ep->ep_vmpage; - ENTRY; atomic_dec(&eco->eo_npages); page_cache_release(vmpage); - EXIT; } static int echo_page_prep(const struct lu_env *env, @@ -408,14 +407,13 @@ static int echo_page_init(const struct lu_env *env, struct cl_object *obj, { struct echo_page *ep = cl_object_page_slice(obj, page); struct echo_object *eco = cl2echo_obj(obj); - ENTRY; ep->ep_vmpage = vmpage; page_cache_get(vmpage); mutex_init(&ep->ep_lock); cl_page_slice_add(page, &ep->ep_cl, obj, &echo_page_ops); atomic_inc(&eco->eo_npages); - RETURN(0); + return 0; } static int echo_io_init(const struct lu_env *env, struct cl_object *obj, @@ -429,7 +427,6 @@ static int echo_lock_init(const struct lu_env *env, const struct cl_io *unused) { struct echo_lock *el; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(el, echo_lock_kmem, __GFP_IO); if (el != NULL) { @@ -438,7 +435,7 @@ static int echo_lock_init(const struct lu_env *env, INIT_LIST_HEAD(&el->el_chain); atomic_set(&el->el_refcount, 0); } - RETURN(el == NULL ? -ENOMEM : 0); + return el == NULL ? -ENOMEM : 0; } static int echo_conf_set(const struct lu_env *env, struct cl_object *obj, @@ -467,7 +464,6 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, struct echo_device *ed = cl2echo_dev(lu2cl_dev(obj->lo_dev)); struct echo_client_obd *ec = ed->ed_ec; struct echo_object *eco = cl2echo_obj(lu2cl(obj)); - ENTRY; if (ed->ed_next) { struct lu_object *below; @@ -477,7 +473,7 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, below = under->ld_ops->ldo_object_alloc(env, obj->lo_header, under); if (below == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lu_object_add(obj, below); } @@ -501,7 +497,7 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, list_add_tail(&eco->eo_obj_chain, &ec->ec_objects); spin_unlock(&ec->ec_lock); - RETURN(0); + return 0; } /* taken from osc_unpackmd() */ @@ -510,8 +506,6 @@ static int echo_alloc_memmd(struct echo_device *ed, { int lsm_size; - ENTRY; - /* If export is lov/osc then use their obd method */ if (ed->ed_next != NULL) return obd_alloc_memmd(ed->ed_ec->ec_exp, lsmp); @@ -521,27 +515,25 @@ static int echo_alloc_memmd(struct echo_device *ed, LASSERT(*lsmp == NULL); OBD_ALLOC(*lsmp, lsm_size); if (*lsmp == NULL) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); if ((*lsmp)->lsm_oinfo[0] == NULL) { OBD_FREE(*lsmp, lsm_size); - RETURN(-ENOMEM); + return -ENOMEM; } loi_init((*lsmp)->lsm_oinfo[0]); (*lsmp)->lsm_maxbytes = LUSTRE_STRIPE_MAXBYTES; ostid_set_seq_echo(&(*lsmp)->lsm_oi); - RETURN(lsm_size); + return lsm_size; } static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp) { int lsm_size; - ENTRY; - /* If export is lov/osc then use their obd method */ if (ed->ed_next != NULL) return obd_free_memmd(ed->ed_ec->ec_exp, lsmp); @@ -552,14 +544,13 @@ static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp) OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); OBD_FREE(*lsmp, lsm_size); *lsmp = NULL; - RETURN(0); + return 0; } static void echo_object_free(const struct lu_env *env, struct lu_object *obj) { struct echo_object *eco = cl2echo_obj(lu2cl(obj)); struct echo_client_obd *ec = eco->eo_dev->ed_ec; - ENTRY; LASSERT(atomic_read(&eco->eo_npages) == 0); @@ -573,7 +564,6 @@ static void echo_object_free(const struct lu_env *env, struct lu_object *obj) if (eco->eo_lsm) echo_free_memmd(eco->eo_dev, &eco->eo_lsm); OBD_SLAB_FREE_PTR(eco, echo_object_kmem); - EXIT; } static int echo_object_print(const struct lu_env *env, void *cookie, @@ -606,7 +596,6 @@ static struct lu_object *echo_object_alloc(const struct lu_env *env, { struct echo_object *eco; struct lu_object *obj = NULL; - ENTRY; /* we're the top dev. */ LASSERT(hdr == NULL); @@ -622,7 +611,7 @@ static struct lu_object *echo_object_alloc(const struct lu_env *env, eco->eo_cl.co_ops = &echo_cl_obj_ops; obj->lo_ops = &echo_lu_obj_ops; } - RETURN(obj); + return obj; } static struct lu_device_operations echo_device_lu_ops = { @@ -648,7 +637,7 @@ static int echo_site_init(const struct lu_env *env, struct echo_device *ed) /* initialize site */ rc = cl_site_init(site, &ed->ed_cl); if (rc) { - CERROR("Cannot initilize site for echo client(%d)\n", rc); + CERROR("Cannot initialize site for echo client(%d)\n", rc); return rc; } @@ -737,11 +726,10 @@ static int echo_fid_init(struct echo_device *ed, char *obd_name, { char *prefix; int rc; - ENTRY; OBD_ALLOC_PTR(ed->ed_cl_seq); if (ed->ed_cl_seq == NULL) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC(prefix, MAX_OBD_NAME + 5); if (prefix == NULL) @@ -758,18 +746,17 @@ static int echo_fid_init(struct echo_device *ed, char *obd_name, if (rc) GOTO(out_free_seq, rc); - RETURN(0); + return 0; out_free_seq: OBD_FREE_PTR(ed->ed_cl_seq); ed->ed_cl_seq = NULL; - RETURN(rc); + return rc; } static int echo_fid_fini(struct obd_device *obddev) { struct echo_device *ed = obd2echo_dev(obddev); - ENTRY; if (ed->ed_cl_seq != NULL) { seq_client_fini(ed->ed_cl_seq); @@ -777,7 +764,7 @@ static int echo_fid_fini(struct obd_device *obddev) ed->ed_cl_seq = NULL; } - RETURN(0); + return 0; } static struct lu_device *echo_device_alloc(const struct lu_env *env, @@ -792,7 +779,6 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, const char *tgt_type_name; int rc; int cleanup = 0; - ENTRY; OBD_ALLOC_PTR(ed); if (ed == NULL) @@ -916,7 +902,7 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, } ed->ed_next = next; - RETURN(&cd->cd_lu_dev); + return &cd->cd_lu_dev; out: switch(cleanup) { case 4: { @@ -1076,7 +1062,6 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, struct lu_fid *fid; int refcheck; int rc; - ENTRY; LASSERT(lsmp); lsm = *lsmp; @@ -1087,11 +1072,11 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, /* Never return an object if the obd is to be freed. */ if (echo_dev2cl(d)->cd_lu_dev.ld_obd->obd_stopping) - RETURN(ERR_PTR(-ENODEV)); + return ERR_PTR(-ENODEV); env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN((void *)env); + return (void *)env; info = echo_env_info(env); conf = &info->eti_conf; @@ -1131,7 +1116,7 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, out: cl_env_put(env, &refcheck); - RETURN(eco); + return eco; } static int cl_echo_object_put(struct echo_object *eco) @@ -1139,11 +1124,10 @@ static int cl_echo_object_put(struct echo_object *eco) struct lu_env *env; struct cl_object *obj = echo_obj2cl(eco); int refcheck; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); /* an external function to kill an object? */ if (eco->eo_deleted) { @@ -1154,7 +1138,7 @@ static int cl_echo_object_put(struct echo_object *eco) cl_object_put(env, obj); cl_env_put(env, &refcheck); - RETURN(0); + return 0; } static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco, @@ -1167,7 +1151,6 @@ static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco, struct cl_lock_descr *descr; struct echo_thread_info *info; int rc = -ENOMEM; - ENTRY; info = echo_env_info(env); io = &info->eti_io; @@ -1201,7 +1184,7 @@ static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco, cl_lock_release(env, lck, "ec enqueue", current); } } - RETURN(rc); + return rc; } static int cl_echo_enqueue(struct echo_object *eco, obd_off start, obd_off end, @@ -1212,11 +1195,10 @@ static int cl_echo_enqueue(struct echo_object *eco, obd_off start, obd_off end, struct cl_io *io; int refcheck; int result; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); info = echo_env_info(env); io = &info->eti_io; @@ -1230,7 +1212,6 @@ static int cl_echo_enqueue(struct echo_object *eco, obd_off start, obd_off end, result = cl_echo_enqueue0(env, eco, start, end, mode, cookie, 0); cl_io_fini(env, io); - EXIT; out: cl_env_put(env, &refcheck); return result; @@ -1243,7 +1224,6 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed, struct echo_lock *ecl = NULL; struct list_head *el; int found = 0, still_used = 0; - ENTRY; LASSERT(ec != NULL); spin_lock(&ec->ec_lock); @@ -1262,10 +1242,10 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed, spin_unlock(&ec->ec_lock); if (!found) - RETURN(-ENOENT); + return -ENOENT; echo_lock_release(env, ecl, still_used); - RETURN(0); + return 0; } static int cl_echo_cancel(struct echo_device *ed, __u64 cookie) @@ -1273,16 +1253,15 @@ static int cl_echo_cancel(struct echo_device *ed, __u64 cookie) struct lu_env *env; int refcheck; int rc; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); rc = cl_echo_cancel0(env, ed, cookie); cl_env_put(env, &refcheck); - RETURN(rc); + return rc; } static int cl_echo_async_brw(const struct lu_env *env, struct cl_io *io, @@ -1291,7 +1270,6 @@ static int cl_echo_async_brw(const struct lu_env *env, struct cl_io *io, struct cl_page *clp; struct cl_page *temp; int result = 0; - ENTRY; cl_page_list_for_each_safe(clp, temp, &queue->c2_qin) { int rc; @@ -1300,7 +1278,7 @@ static int cl_echo_async_brw(const struct lu_env *env, struct cl_io *io, continue; result = result ?: rc; } - RETURN(result); + return result; } static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset, @@ -1318,13 +1296,12 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset, int refcheck; int rc; int i; - ENTRY; LASSERT((offset & ~CFS_PAGE_MASK) == 0); LASSERT(ed->ed_next != NULL); env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); info = echo_env_info(env); io = &info->eti_io; @@ -1386,7 +1363,6 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset, } cl_echo_cancel0(env, ed, lh.cookie); - EXIT; error_lock: cl_2queue_discard(env, io, queue); cl_2queue_disown(env, io, queue); @@ -1411,7 +1387,7 @@ echo_copyout_lsm (struct lov_stripe_md *lsm, void *_ulsm, int ulsm_nob) if (nob > ulsm_nob) return (-EINVAL); - if (copy_to_user (ulsm, lsm, sizeof(ulsm))) + if (copy_to_user (ulsm, lsm, sizeof(*ulsm))) return (-EFAULT); for (i = 0; i < lsm->lsm_stripe_count; i++) { @@ -1467,13 +1443,11 @@ static int echo_big_lmm_get(const struct lu_env *env, struct md_object *o, struct echo_thread_info *info = echo_env_info(env); int rc; - ENTRY; - LASSERT(ma->ma_lmm_size > 0); rc = mo_xattr_get(env, o, &LU_BUF_NULL, XATTR_NAME_LOV); if (rc < 0) - RETURN(rc); + return rc; /* big_lmm may need to be grown */ if (info->eti_big_lmmsize < rc) { @@ -1490,7 +1464,7 @@ static int echo_big_lmm_get(const struct lu_env *env, struct md_object *o, OBD_ALLOC_LARGE(info->eti_big_lmm, size); if (info->eti_big_lmm == NULL) - RETURN(-ENOMEM); + return -ENOMEM; info->eti_big_lmmsize = size; } LASSERT(info->eti_big_lmmsize >= rc); @@ -1499,13 +1473,13 @@ static int echo_big_lmm_get(const struct lu_env *env, struct md_object *o, info->eti_buf.lb_len = info->eti_big_lmmsize; rc = mo_xattr_get(env, o, &info->eti_buf, XATTR_NAME_LOV); if (rc < 0) - RETURN(rc); + return rc; ma->ma_valid |= MA_LOV; ma->ma_lmm = info->eti_big_lmm; ma->ma_lmm_size = rc; - RETURN(0); + return 0; } int echo_attr_get_complex(const struct lu_env *env, struct md_object *next, @@ -1517,8 +1491,6 @@ int echo_attr_get_complex(const struct lu_env *env, struct md_object *next, int need = ma->ma_need; int rc = 0, rc2; - ENTRY; - ma->ma_valid = 0; if (need & MA_INODE) { @@ -1571,7 +1543,7 @@ out: ma->ma_need = need; CDEBUG(D_INODE, "after getattr rc = %d, ma_valid = "LPX64" ma_lmm=%p\n", rc, ma->ma_valid, ma->ma_lmm); - RETURN(rc); + return rc; } static int @@ -1587,8 +1559,6 @@ echo_md_create_internal(const struct lu_env *env, struct echo_device *ed, struct lu_object_conf conf = { .loc_flags = LOC_F_NEW }; int rc; - ENTRY; - rc = mdo_lookup(env, parent, lname, fid2, spec); if (rc == 0) return -EEXIST; @@ -1600,7 +1570,7 @@ echo_md_create_internal(const struct lu_env *env, struct echo_device *ed, if (IS_ERR(ec_child)) { CERROR("Can not find the child "DFID": rc = %ld\n", PFID(fid), PTR_ERR(ec_child)); - RETURN(PTR_ERR(ec_child)); + return PTR_ERR(ec_child); } child = lu_object_locate(ec_child->lo_header, ld->ld_type); @@ -1623,7 +1593,6 @@ echo_md_create_internal(const struct lu_env *env, struct echo_device *ed, } CDEBUG(D_RPCTRACE, "End creating object "DFID" %s %p rc = %d\n", PFID(lu_object_fid(&parent->mo_lu)), lname->ln_name, parent, rc); - EXIT; out_put: lu_object_put(env, ec_child); return rc; @@ -1663,13 +1632,11 @@ static int echo_create_md_object(const struct lu_env *env, int rc = 0; int i; - ENTRY; - if (ec_parent == NULL) return -1; parent = lu_object_locate(ec_parent->lo_header, ld->ld_type); if (parent == NULL) - RETURN(-ENXIO); + return -ENXIO; memset(ma, 0, sizeof(*ma)); memset(spec, 0, sizeof(*spec)); @@ -1699,7 +1666,7 @@ static int echo_create_md_object(const struct lu_env *env, /* If name is specified, only create one object by name */ rc = echo_md_create_internal(env, ed, lu2md(parent), fid, lname, spec, ma); - RETURN(rc); + return rc; } /* Create multiple object sequenced by id */ @@ -1719,7 +1686,7 @@ static int echo_create_md_object(const struct lu_env *env, fid->f_oid++; } - RETURN(rc); + return rc; } static struct lu_object *echo_md_lookup(const struct lu_env *env, @@ -1731,14 +1698,13 @@ static struct lu_object *echo_md_lookup(const struct lu_env *env, struct lu_fid *fid = &info->eti_fid; struct lu_object *child; int rc; - ENTRY; CDEBUG(D_INFO, "lookup %s in parent "DFID" %p\n", lname->ln_name, PFID(fid), parent); rc = mdo_lookup(env, parent, lname, fid, NULL); if (rc) { CERROR("lookup %s: rc = %d\n", lname->ln_name, rc); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } /* In the function below, .hs_keycmp resolves to @@ -1746,7 +1712,7 @@ static struct lu_object *echo_md_lookup(const struct lu_env *env, /* coverity[overrun-buffer-val] */ child = lu_object_find_at(env, &ed->ed_cl.cd_lu_dev, fid, NULL); - RETURN(child); + return child; } static int echo_setattr_object(const struct lu_env *env, @@ -1763,13 +1729,11 @@ static int echo_setattr_object(const struct lu_env *env, int rc = 0; int i; - ENTRY; - if (ec_parent == NULL) return -1; parent = lu_object_locate(ec_parent->lo_header, ld->ld_type); if (parent == NULL) - RETURN(-ENXIO); + return -ENXIO; for (i = 0; i < count; i++) { struct lu_object *ec_child, *child; @@ -1780,7 +1744,7 @@ static int echo_setattr_object(const struct lu_env *env, if (IS_ERR(ec_child)) { CERROR("Can't find child %s: rc = %ld\n", lname->ln_name, PTR_ERR(ec_child)); - RETURN(PTR_ERR(ec_child)); + return PTR_ERR(ec_child); } child = lu_object_locate(ec_child->lo_header, ld->ld_type); @@ -1811,7 +1775,7 @@ static int echo_setattr_object(const struct lu_env *env, id++; lu_object_put(env, ec_child); } - RETURN(rc); + return rc; } static int echo_getattr_object(const struct lu_env *env, @@ -1828,13 +1792,11 @@ static int echo_getattr_object(const struct lu_env *env, int rc = 0; int i; - ENTRY; - if (ec_parent == NULL) return -1; parent = lu_object_locate(ec_parent->lo_header, ld->ld_type); if (parent == NULL) - RETURN(-ENXIO); + return -ENXIO; memset(ma, 0, sizeof(*ma)); ma->ma_need |= MA_INODE | MA_LOV | MA_PFID | MA_HSM | MA_ACL_DEF; @@ -1852,14 +1814,14 @@ static int echo_getattr_object(const struct lu_env *env, if (IS_ERR(ec_child)) { CERROR("Can't find child %s: rc = %ld\n", lname->ln_name, PTR_ERR(ec_child)); - RETURN(PTR_ERR(ec_child)); + return PTR_ERR(ec_child); } child = lu_object_locate(ec_child->lo_header, ld->ld_type); if (child == NULL) { CERROR("Can not locate the child %s\n", lname->ln_name); lu_object_put(env, ec_child); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_RPCTRACE, "Start getattr object "DFID"\n", @@ -1877,7 +1839,7 @@ static int echo_getattr_object(const struct lu_env *env, lu_object_put(env, ec_child); } - RETURN(rc); + return rc; } static int echo_lookup_object(const struct lu_env *env, @@ -1931,13 +1893,11 @@ static int echo_md_destroy_internal(const struct lu_env *env, struct lu_object *child; int rc; - ENTRY; - ec_child = echo_md_lookup(env, ed, parent, lname); if (IS_ERR(ec_child)) { CERROR("Can't find child %s: rc = %ld\n", lname->ln_name, PTR_ERR(ec_child)); - RETURN(PTR_ERR(ec_child)); + return PTR_ERR(ec_child); } child = lu_object_locate(ec_child->lo_header, ld->ld_type); @@ -1976,11 +1936,10 @@ static int echo_destroy_object(const struct lu_env *env, struct lu_object *parent; int rc = 0; int i; - ENTRY; parent = lu_object_locate(ec_parent->lo_header, ld->ld_type); if (parent == NULL) - RETURN(-EINVAL); + return -EINVAL; memset(ma, 0, sizeof(*ma)); ma->ma_attr.la_mode = mode; @@ -1994,7 +1953,7 @@ static int echo_destroy_object(const struct lu_env *env, lname->ln_namelen = namelen; rc = echo_md_destroy_internal(env, ed, lu2md(parent), lname, ma); - RETURN(rc); + return rc; } /*prepare the requests*/ @@ -2013,7 +1972,7 @@ static int echo_destroy_object(const struct lu_env *env, id++; } - RETURN(rc); + return rc; } static struct lu_object *echo_resolve_path(const struct lu_env *env, @@ -2028,13 +1987,12 @@ static struct lu_object *echo_resolve_path(const struct lu_env *env, struct lu_object *parent = NULL; struct lu_object *child = NULL; int rc = 0; - ENTRY; /*Only support MDD layer right now*/ rc = md->md_ops->mdo_root_get(env, md, fid); if (rc) { CERROR("get root error: rc = %d\n", rc); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } /* In the function below, .hs_keycmp resolves to @@ -2044,7 +2002,7 @@ static struct lu_object *echo_resolve_path(const struct lu_env *env, if (IS_ERR(parent)) { CERROR("Can not find the parent "DFID": rc = %ld\n", PFID(fid), PTR_ERR(parent)); - RETURN(parent); + return parent; } while (1) { @@ -2083,9 +2041,9 @@ static struct lu_object *echo_resolve_path(const struct lu_env *env, parent = child; } if (rc) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); - RETURN(parent); + return parent; } static void echo_ucred_init(struct lu_env *env) @@ -2097,10 +2055,14 @@ static void echo_ucred_init(struct lu_env *env) ucred->uc_suppgids[0] = -1; ucred->uc_suppgids[1] = -1; - ucred->uc_uid = ucred->uc_o_uid = current_uid(); - ucred->uc_gid = ucred->uc_o_gid = current_gid(); - ucred->uc_fsuid = ucred->uc_o_fsuid = current_fsuid(); - ucred->uc_fsgid = ucred->uc_o_fsgid = current_fsgid(); + ucred->uc_uid = ucred->uc_o_uid = + from_kuid(&init_user_ns, current_uid()); + ucred->uc_gid = ucred->uc_o_gid = + from_kgid(&init_user_ns, current_gid()); + ucred->uc_fsuid = ucred->uc_o_fsuid = + from_kuid(&init_user_ns, current_fsuid()); + ucred->uc_fsgid = ucred->uc_o_fsgid = + from_kgid(&init_user_ns, current_fsgid()); ucred->uc_cap = cfs_curproc_cap_pack(); /* remove fs privilege for non-root user. */ @@ -2129,21 +2091,20 @@ static int echo_md_handler(struct echo_device *ed, int command, char *name = NULL; int namelen = data->ioc_plen2; int rc = 0; - ENTRY; if (ld == NULL) { CERROR("MD echo client is not being initialized properly\n"); - RETURN(-EINVAL); + return -EINVAL; } if (strcmp(ld->ld_type->ldt_name, LUSTRE_MDD_NAME)) { CERROR("Only support MDD layer right now!\n"); - RETURN(-EINVAL); + return -EINVAL; } env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); rc = lu_env_refill_by_tags(env, ECHO_MD_CTX_TAG, ECHO_MD_SES_TAG); if (rc != 0) @@ -2243,13 +2204,12 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, struct lov_stripe_md *lsm = NULL; int rc; int created = 0; - ENTRY; if ((oa->o_valid & OBD_MD_FLID) == 0 && /* no obj id */ (on_target || /* set_stripe */ ec->ec_nstripes != 0)) { /* LOV */ CERROR ("No valid oid\n"); - RETURN(-EINVAL); + return -EINVAL; } rc = echo_alloc_memmd(ed, &lsm); @@ -2315,7 +2275,6 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, cl_echo_object_put(eco); CDEBUG(D_INFO, "oa oid "DOSTID"\n", POSTID(&oa->o_oi)); - EXIT; failed: if (created && rc) @@ -2333,17 +2292,16 @@ static int echo_get_object(struct echo_object **ecop, struct echo_device *ed, struct lov_stripe_md *lsm = NULL; struct echo_object *eco; int rc; - ENTRY; if ((oa->o_valid & OBD_MD_FLID) == 0 || ostid_id(&oa->o_oi) == 0) { /* disallow use of object id 0 */ CERROR ("No valid oid\n"); - RETURN(-EINVAL); + return -EINVAL; } rc = echo_alloc_memmd(ed, &lsm); if (rc < 0) - RETURN(rc); + return rc; lsm->lsm_oi = oa->o_oi; if (!(oa->o_valid & OBD_MD_FLGROUP)) @@ -2357,7 +2315,7 @@ static int echo_get_object(struct echo_object **ecop, struct echo_device *ed, rc = PTR_ERR(eco); if (lsm) echo_free_memmd(ed, &lsm); - RETURN(rc); + return rc; } static void echo_put_object(struct echo_object *eco) @@ -2476,7 +2434,6 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, int verify; int gfp_mask; int brw_flags = 0; - ENTRY; verify = (ostid_id(&oa->o_oi) != ECHO_PERSISTENT_OBJID && (oa->o_valid & OBD_MD_FLFLAGS) != 0 && @@ -2490,7 +2447,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, if (count <= 0 || (count & (~CFS_PAGE_MASK)) != 0) - RETURN(-EINVAL); + return -EINVAL; /* XXX think again with misaligned I/O */ npages = count >> PAGE_CACHE_SHIFT; @@ -2500,12 +2457,12 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, OBD_ALLOC(pga, npages * sizeof(*pga)); if (pga == NULL) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC(pages, npages * sizeof(*pages)); if (pages == NULL) { OBD_FREE(pga, npages * sizeof(*pga)); - RETURN(-ENOMEM); + return -ENOMEM; } for (i = 0, pgp = pga, off = offset; @@ -2554,7 +2511,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, } OBD_FREE(pga, npages * sizeof(*pga)); OBD_FREE(pages, npages * sizeof(*pages)); - RETURN(rc); + return rc; } static int echo_client_prep_commit(const struct lu_env *env, @@ -2572,11 +2529,9 @@ static int echo_client_prep_commit(const struct lu_env *env, obd_size npages, tot_pages; int i, ret = 0, brw_flags = 0; - ENTRY; - if (count <= 0 || (count & (~CFS_PAGE_MASK)) != 0 || (lsm != NULL && ostid_id(&lsm->lsm_oi) != ostid_id(&oa->o_oi))) - RETURN(-EINVAL); + return -EINVAL; npages = batch >> PAGE_CACHE_SHIFT; tot_pages = count >> PAGE_CACHE_SHIFT; @@ -2661,7 +2616,7 @@ out: OBD_FREE(lnb, npages * sizeof(struct niobuf_local)); if (rnb) OBD_FREE(rnb, npages * sizeof(struct niobuf_remote)); - RETURN(ret); + return ret; } static int echo_client_brw_ioctl(const struct lu_env *env, int rw, @@ -2677,13 +2632,12 @@ static int echo_client_brw_ioctl(const struct lu_env *env, int rw, int rc; int async = 1; long test_mode; - ENTRY; LASSERT(oa->o_valid & OBD_MD_FLGROUP); rc = echo_get_object(&eco, ed, oa); if (rc) - RETURN(rc); + return rc; oa->o_valid &= ~OBD_MD_FLHANDLE; @@ -2719,7 +2673,7 @@ static int echo_client_brw_ioctl(const struct lu_env *env, int rw, rc = -EINVAL; } echo_put_object(eco); - RETURN(rc); + return rc; } static int @@ -2731,21 +2685,20 @@ echo_client_enqueue(struct obd_export *exp, struct obdo *oa, struct echo_object *eco; obd_off end; int rc; - ENTRY; if (ed->ed_next == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (!(mode == LCK_PR || mode == LCK_PW)) - RETURN(-EINVAL); + return -EINVAL; if ((offset & (~CFS_PAGE_MASK)) != 0 || (nob & (~CFS_PAGE_MASK)) != 0) - RETURN(-EINVAL); + return -EINVAL; rc = echo_get_object (&eco, ed, oa); if (rc != 0) - RETURN(rc); + return rc; end = (nob == 0) ? ((obd_off) -1) : (offset + nob - 1); rc = cl_echo_enqueue(eco, offset, end, mode, &ulh->cookie); @@ -2754,7 +2707,7 @@ echo_client_enqueue(struct obd_export *exp, struct obdo *oa, CDEBUG(D_INFO, "Cookie is "LPX64"\n", ulh->cookie); } echo_put_object(eco); - RETURN(rc); + return rc; } static int @@ -2787,7 +2740,6 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, int rw = OBD_BRW_READ; int rc = 0; int i; - ENTRY; memset(&dummy_oti, 0, sizeof(dummy_oti)); @@ -2800,11 +2752,11 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, /* This FID is unpacked just for validation at this point */ rc = ostid_to_fid(&fid, &oa->o_oi, 0); if (rc < 0) - RETURN(rc); + return rc; OBD_ALLOC_PTR(env); if (env == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = lu_env_init(env, LCT_DT_THREAD); if (rc) @@ -2980,7 +2932,6 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO (out, rc = -ENOTTY); } - EXIT; out: lu_env_fini(env); OBD_FREE_PTR(env); @@ -3004,18 +2955,17 @@ static int echo_client_setup(const struct lu_env *env, struct obd_uuid echo_uuid = { "ECHO_UUID" }; struct obd_connect_data *ocd = NULL; int rc; - ENTRY; if (lcfg->lcfg_bufcount < 2 || LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) { CERROR("requires a TARGET OBD name\n"); - RETURN(-EINVAL); + return -EINVAL; } tgt = class_name2obd(lustre_cfg_string(lcfg, 1)); if (!tgt || !tgt->obd_attached || !tgt->obd_set_up) { CERROR("device not attached or not set up (%s)\n", lustre_cfg_string(lcfg, 1)); - RETURN(-EINVAL); + return -EINVAL; } spin_lock_init(&ec->ec_lock); @@ -3027,7 +2977,7 @@ static int echo_client_setup(const struct lu_env *env, if (!strcmp(tgt->obd_type->typ_name, LUSTRE_MDT_NAME)) { lu_context_tags_update(ECHO_MD_CTX_TAG); lu_session_tags_update(ECHO_MD_SES_TAG); - RETURN(0); + return 0; } OBD_ALLOC(ocd, sizeof(*ocd)); @@ -3062,7 +3012,7 @@ static int echo_client_setup(const struct lu_env *env, return (rc); } - RETURN(rc); + return rc; } static int echo_client_cleanup(struct obd_device *obddev) @@ -3070,21 +3020,20 @@ static int echo_client_cleanup(struct obd_device *obddev) struct echo_device *ed = obd2echo_dev(obddev); struct echo_client_obd *ec = &obddev->u.echo_client; int rc; - ENTRY; /*Do nothing for Metadata echo client*/ if (ed == NULL ) - RETURN(0); + return 0; if (ed->ed_next_ismd) { lu_context_tags_clear(ECHO_MD_CTX_TAG); lu_session_tags_clear(ECHO_MD_SES_TAG); - RETURN(0); + return 0; } if (!list_empty(&obddev->obd_exports)) { CERROR("still has clients!\n"); - RETURN(-EBUSY); + return -EBUSY; } LASSERT(atomic_read(&ec->ec_exp->exp_refcount) > 0); @@ -3092,7 +3041,7 @@ static int echo_client_cleanup(struct obd_device *obddev) if (rc != 0) CERROR("fail to disconnect device: %d\n", rc); - RETURN(rc); + return rc; } static int echo_client_connect(const struct lu_env *env, @@ -3103,13 +3052,12 @@ static int echo_client_connect(const struct lu_env *env, int rc; struct lustre_handle conn = { 0 }; - ENTRY; rc = class_connect(&conn, src, cluuid); if (rc == 0) { *exp = class_conn2export(&conn); } - RETURN (rc); + return rc; } static int echo_client_disconnect(struct obd_export *exp) @@ -3120,7 +3068,6 @@ static int echo_client_disconnect(struct obd_export *exp) struct ec_lock *ecl; #endif int rc; - ENTRY; if (exp == NULL) GOTO(out, rc = -EINVAL); @@ -3195,7 +3142,6 @@ static int __init obdecho_init(void) struct lprocfs_static_vars lvars; int rc; - ENTRY; LCONSOLE_INFO("Echo OBD driver; http://www.lustre.org/\n"); LASSERT(PAGE_CACHE_SIZE % OBD_ECHO_BLOCK_SIZE == 0); @@ -3205,7 +3151,7 @@ static int __init obdecho_init(void) rc = echo_client_init(); - RETURN(rc); + return rc; } static void /*__exit*/ obdecho_exit(void) @@ -3217,7 +3163,9 @@ static void /*__exit*/ obdecho_exit(void) MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); MODULE_DESCRIPTION("Lustre Testing Echo OBD driver"); MODULE_LICENSE("GPL"); +MODULE_VERSION(LUSTRE_VERSION_STRING); -cfs_module(obdecho, LUSTRE_VERSION_STRING, obdecho_init, obdecho_exit); +module_init(obdecho_init); +module_exit(obdecho_exit); /** @} echo_client */ diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 198cf3ba137..90d24d8dea2 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#include <linux/version.h> #include <asm/statfs.h> #include <obd_cksum.h> #include <obd_class.h> @@ -146,7 +145,7 @@ static ssize_t osc_max_dirty_mb_seq_write(struct file *file, const char *buffer, if (pages_number <= 0 || pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_CACHE_SHIFT) || - pages_number > num_physpages / 4) /* 1/4 of RAM */ + pages_number > totalram_pages / 4) /* 1/4 of RAM */ return -ERANGE; client_obd_list_lock(&cli->cl_loi_list_lock); diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 0a0ec6f7d2d..00295da4ab3 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -540,7 +540,6 @@ int osc_extent_release(const struct lu_env *env, struct osc_extent *ext) { struct osc_object *obj = ext->oe_obj; int rc = 0; - ENTRY; LASSERT(atomic_read(&ext->oe_users) > 0); LASSERT(sanity_check(ext) == 0); @@ -572,7 +571,7 @@ int osc_extent_release(const struct lu_env *env, struct osc_extent *ext) osc_io_unplug_async(env, osc_cli(obj), obj); } osc_extent_put(env, ext); - RETURN(rc); + return rc; } static inline int overlapped(struct osc_extent *ex1, struct osc_extent *ex2) @@ -602,11 +601,10 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, int ppc_bits; /* pages per chunk bits */ int chunk_mask; int rc; - ENTRY; cur = osc_extent_alloc(obj); if (cur == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); lock = cl_lock_at_pgoff(env, osc2cl(obj), index, NULL, 1, 0); LASSERT(lock != NULL); @@ -783,7 +781,6 @@ restart: goto restart; } - EXIT; out: osc_extent_put(env, cur); @@ -805,7 +802,6 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, int blocksize = cli->cl_import->imp_obd->obd_osfs.os_bsize ? : 4096; __u64 last_off = 0; int last_count = -1; - ENTRY; OSC_EXTENT_DUMP(D_CACHE, ext, "extent finished.\n"); @@ -846,7 +842,7 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, osc_extent_remove(ext); /* put the refcount for RPC */ osc_extent_put(env, ext); - RETURN(0); + return 0; } static int extent_wait_cb(struct osc_extent *ext, int state) @@ -870,7 +866,6 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, struct l_wait_info lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(600), NULL, LWI_ON_SIGNAL_NOOP, NULL); int rc = 0; - ENTRY; osc_object_lock(obj); LASSERT(sanity_check_nolock(ext) == 0); @@ -902,7 +897,7 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, } if (rc == 0 && ext->oe_rc < 0) rc = ext->oe_rc; - RETURN(rc); + return rc; } /** @@ -925,7 +920,6 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, int grants = 0; int nr_pages = 0; int rc = 0; - ENTRY; LASSERT(sanity_check(ext) == 0); LASSERT(ext->oe_state == OES_TRUNC); @@ -1021,7 +1015,7 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, out: cl_io_fini(env, io); cl_env_nested_put(&nest, env); - RETURN(rc); + return rc; } /** @@ -1036,7 +1030,6 @@ static int osc_extent_make_ready(const struct lu_env *env, struct osc_object *obj = ext->oe_obj; int page_count = 0; int rc; - ENTRY; /* we're going to grab page lock, so object lock must not be taken. */ LASSERT(sanity_check(ext) == 0); @@ -1096,7 +1089,7 @@ static int osc_extent_make_ready(const struct lu_env *env, /* get a refcount for RPC. */ osc_extent_get(ext); - RETURN(0); + return 0; } /** @@ -1115,7 +1108,6 @@ static int osc_extent_expand(struct osc_extent *ext, pgoff_t index, int *grants) pgoff_t end_index; int chunksize = 1 << cli->cl_chunkbits; int rc = 0; - ENTRY; LASSERT(ext->oe_max_end >= index && ext->oe_start <= index); osc_object_lock(obj); @@ -1143,11 +1135,10 @@ static int osc_extent_expand(struct osc_extent *ext, pgoff_t index, int *grants) LASSERT(*grants >= 0); EASSERTF(osc_extent_is_overlapped(obj, ext) == 0, ext, "overlapped after expanding for %lu.\n", index); - EXIT; out: osc_object_unlock(obj); - RETURN(rc); + return rc; } static void osc_extent_tree_dump0(int level, struct osc_object *obj, @@ -1207,11 +1198,10 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap, LASSERT(cmd == OBD_BRW_WRITE); /* no cached reads */ - ENTRY; result = cl_page_make_ready(env, page, CRT_WRITE); if (result == 0) opg->ops_submit_time = cfs_time_current(); - RETURN(result); + return result; } static int osc_refresh_count(const struct lu_env *env, @@ -1255,8 +1245,6 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, enum cl_req_type crt; int srvlock; - ENTRY; - cmd &= ~OBD_BRW_NOQUOTA; LASSERT(equi(page->cp_state == CPS_PAGEIN, cmd == OBD_BRW_READ)); LASSERT(equi(page->cp_state == CPS_PAGEOUT, cmd == OBD_BRW_WRITE)); @@ -1305,7 +1293,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, cl_page_completion(env, page, crt, rc); - RETURN(0); + return 0; } #define OSC_DUMP_GRANT(cli, fmt, args...) do { \ @@ -1338,11 +1326,8 @@ static void osc_consume_write_grant(struct client_obd *cli, static void osc_release_write_grant(struct client_obd *cli, struct brw_page *pga) { - ENTRY; - LASSERT(spin_is_locked(&cli->cl_loi_list_lock.lock)); if (!(pga->flag & OBD_BRW_FROM_GRANT)) { - EXIT; return; } @@ -1354,7 +1339,6 @@ static void osc_release_write_grant(struct client_obd *cli, atomic_dec(&obd_dirty_transit_pages); cli->cl_dirty_transit -= PAGE_CACHE_SIZE; } - EXIT; } /** @@ -1503,7 +1487,6 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, struct osc_cache_waiter ocw; struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); int rc = -EDQUOT; - ENTRY; OSC_DUMP_GRANT(cli, "need:%d.\n", bytes); @@ -1557,11 +1540,10 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, if (osc_enter_cache_try(cli, oap, bytes, 0)) GOTO(out, rc = 0); } - EXIT; out: client_obd_list_unlock(&cli->cl_loi_list_lock); OSC_DUMP_GRANT(cli, "returned %d.\n", rc); - RETURN(rc); + return rc; } /* caller must hold loi_list_lock */ @@ -1570,7 +1552,6 @@ void osc_wake_cache_waiters(struct client_obd *cli) struct list_head *l, *tmp; struct osc_cache_waiter *ocw; - ENTRY; list_for_each_safe(l, tmp, &cli->cl_cache_waiters) { ocw = list_entry(l, struct osc_cache_waiter, ocw_entry); list_del_init(&ocw->ocw_entry); @@ -1596,8 +1577,6 @@ wakeup: wake_up(&ocw->ocw_waitq); } - - EXIT; } static int osc_max_rpc_in_flight(struct client_obd *cli, struct osc_object *osc) @@ -1613,7 +1592,6 @@ static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, int cmd) { int invalid_import = 0; - ENTRY; /* if we have an invalid import we want to drain the queued pages * by forcing them through rpcs that immediately fail and complete @@ -1624,42 +1602,42 @@ static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, if (cmd & OBD_BRW_WRITE) { if (atomic_read(&osc->oo_nr_writes) == 0) - RETURN(0); + return 0; if (invalid_import) { CDEBUG(D_CACHE, "invalid import forcing RPC\n"); - RETURN(1); + return 1; } if (!list_empty(&osc->oo_hp_exts)) { CDEBUG(D_CACHE, "high prio request forcing RPC\n"); - RETURN(1); + return 1; } if (!list_empty(&osc->oo_urgent_exts)) { CDEBUG(D_CACHE, "urgent request forcing RPC\n"); - RETURN(1); + return 1; } /* trigger a write rpc stream as long as there are dirtiers * waiting for space. as they're waiting, they're not going to * create more pages to coalesce with what's waiting.. */ if (!list_empty(&cli->cl_cache_waiters)) { CDEBUG(D_CACHE, "cache waiters forcing RPC\n"); - RETURN(1); + return 1; } if (atomic_read(&osc->oo_nr_writes) >= cli->cl_max_pages_per_rpc) - RETURN(1); + return 1; } else { if (atomic_read(&osc->oo_nr_reads) == 0) - RETURN(0); + return 0; if (invalid_import) { CDEBUG(D_CACHE, "invalid import forcing RPC\n"); - RETURN(1); + return 1; } /* all read are urgent. */ if (!list_empty(&osc->oo_reading_exts)) - RETURN(1); + return 1; } - RETURN(0); + return 0; } static void osc_update_pending(struct osc_object *obj, int cmd, int delta) @@ -1757,7 +1735,6 @@ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli, struct lov_oinfo *loi = osc->oo_oinfo; __u64 xid = 0; - ENTRY; if (oap->oap_request != NULL) { xid = ptlrpc_req_xid(oap->oap_request); ptlrpc_req_finished(oap->oap_request); @@ -1781,8 +1758,6 @@ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli, if (rc) CERROR("completion on oap %p obj %p returns %d.\n", oap, osc, rc); - - EXIT; } /** @@ -1795,14 +1770,13 @@ static int try_to_add_extent_for_io(struct client_obd *cli, int *pc, unsigned int *max_pages) { struct osc_extent *tmp; - ENTRY; EASSERT((ext->oe_state == OES_CACHE || ext->oe_state == OES_LOCK_DONE), ext); *max_pages = max(ext->oe_mppr, *max_pages); if (*pc + ext->oe_nr_pages > *max_pages) - RETURN(0); + return 0; list_for_each_entry(tmp, rpclist, oe_link) { EASSERT(tmp->oe_owner == current, tmp); @@ -1815,7 +1789,7 @@ static int try_to_add_extent_for_io(struct client_obd *cli, if (tmp->oe_srvlock != ext->oe_srvlock || !tmp->oe_grants != !ext->oe_grants) - RETURN(0); + return 0; /* remove break for strict check */ break; @@ -1824,7 +1798,7 @@ static int try_to_add_extent_for_io(struct client_obd *cli, *pc += ext->oe_nr_pages; list_move_tail(&ext->oe_link, rpclist); ext->oe_owner = current; - RETURN(1); + return 1; } /** @@ -1913,7 +1887,6 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, obd_count page_count = 0; int srvlock = 0; int rc = 0; - ENTRY; LASSERT(osc_object_is_locked(osc)); @@ -1921,7 +1894,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, LASSERT(equi(page_count == 0, list_empty(&rpclist))); if (list_empty(&rpclist)) - RETURN(0); + return 0; osc_update_pending(osc, OBD_BRW_WRITE, -page_count); @@ -1962,7 +1935,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, } osc_object_lock(osc); - RETURN(rc); + return rc; } /** @@ -1985,7 +1958,6 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, int page_count = 0; unsigned int max_pages = cli->cl_max_pages_per_rpc; int rc = 0; - ENTRY; LASSERT(osc_object_is_locked(osc)); list_for_each_entry_safe(ext, next, @@ -2010,7 +1982,7 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, osc_object_lock(osc); } - RETURN(rc); + return rc; } #define list_to_obj(list, item) ({ \ @@ -2023,15 +1995,13 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, * we could be sending. These lists are maintained by osc_makes_rpc(). */ static struct osc_object *osc_next_obj(struct client_obd *cli) { - ENTRY; - /* First return objects that have blocked locks so that they * will be flushed quickly and other clients can get the lock, * then objects which have pages ready to be stuffed into RPCs */ if (!list_empty(&cli->cl_loi_hp_ready_list)) - RETURN(list_to_obj(&cli->cl_loi_hp_ready_list, hp_ready_item)); + return list_to_obj(&cli->cl_loi_hp_ready_list, hp_ready_item); if (!list_empty(&cli->cl_loi_ready_list)) - RETURN(list_to_obj(&cli->cl_loi_ready_list, ready_item)); + return list_to_obj(&cli->cl_loi_ready_list, ready_item); /* then if we have cache waiters, return all objects with queued * writes. This is especially important when many small files @@ -2039,19 +2009,17 @@ static struct osc_object *osc_next_obj(struct client_obd *cli) * they don't pass the nr_pending/object threshhold */ if (!list_empty(&cli->cl_cache_waiters) && !list_empty(&cli->cl_loi_write_list)) - RETURN(list_to_obj(&cli->cl_loi_write_list, write_item)); + return list_to_obj(&cli->cl_loi_write_list, write_item); /* then return all queued objects when we have an invalid import * so that they get flushed */ if (cli->cl_import == NULL || cli->cl_import->imp_invalid) { if (!list_empty(&cli->cl_loi_write_list)) - RETURN(list_to_obj(&cli->cl_loi_write_list, - write_item)); + return list_to_obj(&cli->cl_loi_write_list, write_item); if (!list_empty(&cli->cl_loi_read_list)) - RETURN(list_to_obj(&cli->cl_loi_read_list, - read_item)); + return list_to_obj(&cli->cl_loi_read_list, read_item); } - RETURN(NULL); + return NULL; } /* called with the loi list lock held */ @@ -2060,11 +2028,10 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli, { struct osc_object *osc; int rc = 0; - ENTRY; while ((osc = osc_next_obj(cli)) != NULL) { struct cl_object *obj = osc2cl(osc); - struct lu_ref_link *link; + struct lu_ref_link link; OSC_IO_DEBUG(osc, "%lu in flight\n", rpcs_in_flight(cli)); @@ -2075,7 +2042,8 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli, cl_object_get(obj); client_obd_list_unlock(&cli->cl_loi_list_lock); - link = lu_object_ref_add(&obj->co_lu, "check", current); + lu_object_ref_add_at(&obj->co_lu, &link, "check", + current); /* attempt some read/write balancing by alternating between * reads and writes in an object. The makes_rpc checks here @@ -2116,7 +2084,8 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli, osc_object_unlock(osc); osc_list_maint(cli, osc); - lu_object_ref_del_at(&obj->co_lu, link, "check", current); + lu_object_ref_del_at(&obj->co_lu, &link, "check", + current); cl_object_put(env, obj); client_obd_list_lock(&cli->cl_loi_list_lock); @@ -2165,7 +2134,6 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, { struct obd_export *exp = osc_export(osc); struct osc_async_page *oap = &ops->ops_oap; - ENTRY; if (!page) return cfs_size_round(sizeof(*oap)); @@ -2187,7 +2155,7 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, spin_lock_init(&oap->oap_lock); CDEBUG(D_INFO, "oap %p page %p obj off "LPU64"\n", oap, page, oap->oap_obj_off); - RETURN(0); + return 0; } int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, @@ -2204,17 +2172,16 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, int cmd = OBD_BRW_WRITE; int need_release = 0; int rc = 0; - ENTRY; if (oap->oap_magic != OAP_MAGIC) - RETURN(-EINVAL); + return -EINVAL; if (cli->cl_import == NULL || cli->cl_import->imp_invalid) - RETURN(-EIO); + return -EIO; if (!list_empty(&oap->oap_pending_item) || !list_empty(&oap->oap_rpc_item)) - RETURN(-EBUSY); + return -EBUSY; /* Set the OBD_BRW_SRVLOCK before the page is queued. */ brw_flags |= ops->ops_srvlock ? OBD_BRW_SRVLOCK : 0; @@ -2242,7 +2209,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, if (rc == 0 && osc_quota_chkdq(cli, qid) == NO_QUOTA) rc = -EDQUOT; if (rc) - RETURN(rc); + return rc; } oap->oap_cmd = cmd; @@ -2350,7 +2317,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, list_add_tail(&oap->oap_pending_item, &ext->oe_pages); osc_object_unlock(osc); } - RETURN(rc); + return rc; } int osc_teardown_async_page(const struct lu_env *env, @@ -2359,7 +2326,6 @@ int osc_teardown_async_page(const struct lu_env *env, struct osc_async_page *oap = &ops->ops_oap; struct osc_extent *ext = NULL; int rc = 0; - ENTRY; LASSERT(oap->oap_magic == OAP_MAGIC); @@ -2384,7 +2350,7 @@ int osc_teardown_async_page(const struct lu_env *env, osc_object_unlock(obj); if (ext != NULL) osc_extent_put(env, ext); - RETURN(rc); + return rc; } /** @@ -2404,7 +2370,6 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, struct osc_async_page *oap = &ops->ops_oap; bool unplug = false; int rc = 0; - ENTRY; osc_object_lock(obj); ext = osc_extent_lookup(obj, index); @@ -2454,7 +2419,6 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, unplug = true; } rc = 0; - EXIT; out: osc_object_unlock(obj); @@ -2482,7 +2446,6 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) pgoff_t index = oap2cl_page(oap)->cp_index; int rc = -EBUSY; int cmd; - ENTRY; LASSERT(!oap->oap_interrupted); oap->oap_interrupted = 1; @@ -2526,7 +2489,7 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) } osc_list_maint(cli, obj); - RETURN(rc); + return rc; } int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, @@ -2539,7 +2502,6 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, int mppr = cli->cl_max_pages_per_rpc; pgoff_t start = CL_PAGE_EOF; pgoff_t end = 0; - ENTRY; list_for_each_entry(oap, list, oap_pending_item) { struct cl_page *cp = oap2cl_page(oap); @@ -2557,7 +2519,7 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, list_del_init(&oap->oap_pending_item); osc_ap_completion(env, cli, oap, 0, -ENOMEM); } - RETURN(-ENOMEM); + return -ENOMEM; } ext->oe_rw = !!(cmd & OBD_BRW_READ); @@ -2583,7 +2545,7 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, osc_object_unlock(obj); osc_io_unplug(env, cli, obj, PDL_POLICY_ROUND); - RETURN(0); + return 0; } /** @@ -2599,7 +2561,6 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, LIST_HEAD(list); int result = 0; bool partial; - ENTRY; /* pages with index greater or equal to index will be truncated. */ index = cl_index(osc2cl(obj), size); @@ -2705,7 +2666,7 @@ again: waiting = NULL; goto again; } - RETURN(result); + return result; } /** @@ -2756,7 +2717,6 @@ int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj, struct osc_extent *ext; pgoff_t index = start; int result = 0; - ENTRY; again: osc_object_lock(obj); @@ -2794,7 +2754,7 @@ again: osc_object_unlock(obj); OSC_IO_DEBUG(obj, "sync file range.\n"); - RETURN(result); + return result; } /** @@ -2813,7 +2773,6 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, LIST_HEAD(discard_list); bool unplug = false; int result = 0; - ENTRY; osc_object_lock(obj); ext = osc_extent_search(obj, start); @@ -2910,7 +2869,7 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, } OSC_IO_DEBUG(obj, "cache page out.\n"); - RETURN(result); + return result; } /** @} osc */ diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index 158e8fff838..a3aa9b6596e 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -374,7 +374,7 @@ struct osc_page { /** * Thread that submitted this page for transfer. For debugging. */ - task_t *ops_submitter; + struct task_struct *ops_submitter; /** * Submit time - the time when the page is starting RPC. For debugging. */ @@ -660,7 +660,7 @@ struct osc_extent { /** lock covering this extent */ struct cl_lock *oe_osclock; /** terminator of this extent. Must be true if this extent is in IO. */ - task_t *oe_owner; + struct task_struct *oe_owner; /** return value of writeback. If somebody is waiting for this extent, * this value can be known by outside world. */ int oe_rc; diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index 4208ddfd73b..35f25786763 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -171,8 +171,7 @@ LU_TYPE_INIT_FINI(osc, &osc_key, &osc_session_key); static int osc_cl_process_config(const struct lu_env *env, struct lu_device *d, struct lustre_cfg *cfg) { - ENTRY; - RETURN(osc_process_config_base(d->ld_obd, cfg)); + return osc_process_config_base(d->ld_obd, cfg); } static const struct lu_device_operations osc_lu_ops = { @@ -188,7 +187,7 @@ static const struct cl_device_operations osc_cl_ops = { static int osc_device_init(const struct lu_env *env, struct lu_device *d, const char *name, struct lu_device *next) { - RETURN(0); + return 0; } static struct lu_device *osc_device_fini(const struct lu_env *env, @@ -218,7 +217,7 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env, OBD_ALLOC_PTR(od); if (od == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); cl_device_init(&od->od_cl, t); d = osc2lu_dev(od); @@ -231,10 +230,10 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env, rc = osc_setup(obd, cfg); if (rc) { osc_device_free(env, d); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } od->od_exp = obd->obd_self_export; - RETURN(d); + return d; } static const struct lu_device_type_operations osc_device_type_ops = { diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 1b277045b3e..3aeaf845cf2 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -261,7 +261,6 @@ static int osc_io_prepare_write(const struct lu_env *env, struct obd_import *imp = class_exp2cliimp(dev->od_exp); struct osc_io *oio = cl2osc_io(env, ios); int result = 0; - ENTRY; /* * This implements OBD_BRW_CHECK logic from old client. @@ -276,7 +275,7 @@ static int osc_io_prepare_write(const struct lu_env *env, * [from, to) bytes of this page to OST. -jay */ cl_page_export(env, slice->cpl_page, 1); - RETURN(result); + return result; } static int osc_io_commit_write(const struct lu_env *env, @@ -288,7 +287,6 @@ static int osc_io_commit_write(const struct lu_env *env, struct osc_page *opg = cl2osc_page(slice); struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); struct osc_async_page *oap = &opg->ops_oap; - ENTRY; LASSERT(to > 0); /* @@ -306,7 +304,7 @@ static int osc_io_commit_write(const struct lu_env *env, /* see osc_io_prepare_write() for lockless io handling. */ cl_page_clip(env, slice->cpl_page, from, to); - RETURN(0); + return 0; } static int osc_io_fault_start(const struct lu_env *env, @@ -315,8 +313,6 @@ static int osc_io_fault_start(const struct lu_env *env, struct cl_io *io; struct cl_fault_io *fio; - ENTRY; - io = ios->cis_io; fio = &io->u.ci_fault; CDEBUG(D_INFO, "%lu %d %d\n", @@ -329,7 +325,7 @@ static int osc_io_fault_start(const struct lu_env *env, if (fio->ft_writable) osc_page_touch_at(env, ios->cis_obj, fio->ft_index, fio->ft_nob); - RETURN(0); + return 0; } static int osc_async_upcall(void *a, int rc) @@ -517,19 +513,18 @@ static int osc_io_read_start(const struct lu_env *env, struct cl_object *obj = slice->cis_obj; struct cl_attr *attr = &osc_env_info(env)->oti_attr; int result = 0; - ENTRY; if (oio->oi_lockless == 0) { cl_object_attr_lock(obj); result = cl_object_attr_get(env, obj, attr); if (result == 0) { - attr->cat_atime = LTIME_S(CFS_CURRENT_TIME); + attr->cat_atime = LTIME_S(CURRENT_TIME); result = cl_object_attr_set(env, obj, attr, CAT_ATIME); } cl_object_attr_unlock(obj); } - RETURN(result); + return result; } static int osc_io_write_start(const struct lu_env *env, @@ -539,7 +534,6 @@ static int osc_io_write_start(const struct lu_env *env, struct cl_object *obj = slice->cis_obj; struct cl_attr *attr = &osc_env_info(env)->oti_attr; int result = 0; - ENTRY; if (oio->oi_lockless == 0) { OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1); @@ -547,13 +541,13 @@ static int osc_io_write_start(const struct lu_env *env, result = cl_object_attr_get(env, obj, attr); if (result == 0) { attr->cat_mtime = attr->cat_ctime = - LTIME_S(CFS_CURRENT_TIME); + LTIME_S(CURRENT_TIME); result = cl_object_attr_set(env, obj, attr, CAT_MTIME | CAT_CTIME); } cl_object_attr_unlock(obj); } - RETURN(result); + return result; } static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, @@ -565,7 +559,6 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, struct lov_oinfo *loi = obj->oo_oinfo; struct osc_async_cbargs *cbargs = &oio->oi_cbarg; int rc = 0; - ENTRY; memset(oa, 0, sizeof(*oa)); oa->o_oi = loi->loi_oi; @@ -585,7 +578,7 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, rc = osc_sync_base(osc_export(obj), oinfo, osc_async_upcall, cbargs, PTLRPCD_SET); - RETURN(rc); + return rc; } static int osc_io_fsync_start(const struct lu_env *env, @@ -598,7 +591,6 @@ static int osc_io_fsync_start(const struct lu_env *env, pgoff_t start = cl_index(obj, fio->fi_start); pgoff_t end = cl_index(obj, fio->fi_end); int result = 0; - ENTRY; if (fio->fi_end == OBD_OBJECT_EOF) end = CL_PAGE_EOF; @@ -625,7 +617,7 @@ static int osc_io_fsync_start(const struct lu_env *env, result = rc; } - RETURN(result); + return result; } static void osc_io_fsync_end(const struct lu_env *env, @@ -785,7 +777,7 @@ static void osc_req_attr_set(const struct lu_env *env, "no cover page!\n"); CL_PAGE_DEBUG(D_ERROR, env, apage, "dump uncover page!\n"); - libcfs_debug_dumpstack(NULL); + dump_stack(); LBUG(); } diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 640bc3d3470..5d7bdbfc871 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -89,35 +89,49 @@ static struct ldlm_lock *osc_handle_ptr(struct lustre_handle *handle) */ static int osc_lock_invariant(struct osc_lock *ols) { - struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle); - struct ldlm_lock *olock = ols->ols_lock; - int handle_used = lustre_handle_is_used(&ols->ols_handle); - - return - ergo(osc_lock_is_lockless(ols), - ols->ols_locklessable && ols->ols_lock == NULL) || - (ergo(olock != NULL, handle_used) && - ergo(olock != NULL, - olock->l_handle.h_cookie == ols->ols_handle.cookie) && - /* - * Check that ->ols_handle and ->ols_lock are consistent, but - * take into account that they are set at the different time. - */ - ergo(handle_used, - ergo(lock != NULL && olock != NULL, lock == olock) && - ergo(lock == NULL, olock == NULL)) && - ergo(ols->ols_state == OLS_CANCELLED, - olock == NULL && !handle_used) && - /* - * DLM lock is destroyed only after we have seen cancellation - * ast. - */ - ergo(olock != NULL && ols->ols_state < OLS_CANCELLED, - !olock->l_destroyed) && - ergo(ols->ols_state == OLS_GRANTED, - olock != NULL && - olock->l_req_mode == olock->l_granted_mode && - ols->ols_hold)); + struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle); + struct ldlm_lock *olock = ols->ols_lock; + int handle_used = lustre_handle_is_used(&ols->ols_handle); + + if (ergo(osc_lock_is_lockless(ols), + ols->ols_locklessable && ols->ols_lock == NULL)) + return 1; + + /* + * If all the following "ergo"s are true, return 1, otherwise 0 + */ + if (! ergo(olock != NULL, handle_used)) + return 0; + + if (! ergo(olock != NULL, + olock->l_handle.h_cookie == ols->ols_handle.cookie)) + return 0; + + if (! ergo(handle_used, + ergo(lock != NULL && olock != NULL, lock == olock) && + ergo(lock == NULL, olock == NULL))) + return 0; + /* + * Check that ->ols_handle and ->ols_lock are consistent, but + * take into account that they are set at the different time. + */ + if (! ergo(ols->ols_state == OLS_CANCELLED, + olock == NULL && !handle_used)) + return 0; + /* + * DLM lock is destroyed only after we have seen cancellation + * ast. + */ + if (! ergo(olock != NULL && ols->ols_state < OLS_CANCELLED, + ((olock->l_flags & LDLM_FL_DESTROYED) == 0))) + return 0; + + if (! ergo(ols->ols_state == OLS_GRANTED, + olock != NULL && + olock->l_req_mode == olock->l_granted_mode && + ols->ols_hold)) + return 0; + return 1; } /***************************************************************************** @@ -261,7 +275,7 @@ static __u64 osc_enq2ldlm_flags(__u32 enqflags) if (enqflags & CEF_ASYNC) result |= LDLM_FL_HAS_INTENT; if (enqflags & CEF_DISCARD_DATA) - result |= LDLM_AST_DISCARD_DATA; + result |= LDLM_FL_AST_DISCARD_DATA; return result; } @@ -329,10 +343,8 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, struct cl_attr *attr; unsigned valid; - ENTRY; - if (!(olck->ols_flags & LDLM_FL_LVB_READY)) - RETURN_EXIT; + return; lvb = &olck->ols_lvb; obj = olck->ols_cl.cls_obj; @@ -378,8 +390,6 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, cl_object_attr_set(env, obj, attr, valid); cl_object_attr_unlock(obj); - - EXIT; } /** @@ -398,7 +408,6 @@ static void osc_lock_granted(const struct lu_env *env, struct osc_lock *olck, LASSERT(dlmlock->l_granted_mode == dlmlock->l_req_mode); - ENTRY; if (olck->ols_state < OLS_GRANTED) { lock = olck->ols_cl.cls_lock; ext = &dlmlock->l_policy_data.l_extent; @@ -428,7 +437,6 @@ static void osc_lock_granted(const struct lu_env *env, struct osc_lock *olck, LINVRNT(osc_lock_invariant(olck)); lock_res_and_lock(dlmlock); } - EXIT; } static void osc_lock_upcall0(const struct lu_env *env, struct osc_lock *olck) @@ -436,8 +444,6 @@ static void osc_lock_upcall0(const struct lu_env *env, struct osc_lock *olck) { struct ldlm_lock *dlmlock; - ENTRY; - dlmlock = ldlm_handle2lock_long(&olck->ols_handle, 0); LASSERT(dlmlock != NULL); @@ -483,7 +489,6 @@ static int osc_lock_upcall(void *cookie, int errcode) struct lu_env *env; struct cl_env_nest nest; - ENTRY; env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { int rc; @@ -575,7 +580,7 @@ static int osc_lock_upcall(void *cookie, int errcode) /* should never happen, similar to osc_ldlm_blocking_ast(). */ LBUG(); } - RETURN(errcode); + return errcode; } /** @@ -896,55 +901,6 @@ static unsigned long osc_lock_weigh(const struct lu_env *env, return cl_object_header(slice->cls_obj)->coh_pages; } -/** - * Get the weight of dlm lock for early cancellation. - * - * XXX: it should return the pages covered by this \a dlmlock. - */ -static unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock) -{ - struct cl_env_nest nest; - struct lu_env *env; - struct osc_lock *lock; - struct cl_lock *cll; - unsigned long weight; - ENTRY; - - might_sleep(); - /* - * osc_ldlm_weigh_ast has a complex context since it might be called - * because of lock canceling, or from user's input. We have to make - * a new environment for it. Probably it is implementation safe to use - * the upper context because cl_lock_put don't modify environment - * variables. But in case of .. - */ - env = cl_env_nested_get(&nest); - if (IS_ERR(env)) - /* Mostly because lack of memory, tend to eliminate this lock*/ - RETURN(0); - - LASSERT(dlmlock->l_resource->lr_type == LDLM_EXTENT); - lock = osc_ast_data_get(dlmlock); - if (lock == NULL) { - /* cl_lock was destroyed because of memory pressure. - * It is much reasonable to assign this type of lock - * a lower cost. - */ - GOTO(out, weight = 0); - } - - cll = lock->ols_cl.cls_lock; - cl_lock_mutex_get(env, cll); - weight = cl_lock_weigh(env, cll); - cl_lock_mutex_put(env, cll); - osc_ast_data_put(env, lock); - EXIT; - -out: - cl_env_nested_put(&nest, env); - return weight; -} - static void osc_lock_build_einfo(const struct lu_env *env, const struct cl_lock *clock, struct osc_lock *lock, @@ -966,7 +922,6 @@ static void osc_lock_build_einfo(const struct lu_env *env, einfo->ei_cb_bl = osc_ldlm_blocking_ast; einfo->ei_cb_cp = osc_ldlm_completion_ast; einfo->ei_cb_gl = osc_ldlm_glimpse_ast; - einfo->ei_cb_wg = osc_ldlm_weigh_ast; einfo->ei_cbdata = lock; /* value to be put into ->l_ast_data */ } @@ -1059,7 +1014,6 @@ static int osc_lock_enqueue_wait(const struct lu_env *env, struct cl_lock *conflict= NULL; int lockless = osc_lock_is_lockless(olck); int rc = 0; - ENTRY; LASSERT(cl_lock_is_mutexed(lock)); @@ -1130,7 +1084,7 @@ static int osc_lock_enqueue_wait(const struct lu_env *env, rc = CLO_WAIT; } } - RETURN(rc); + return rc; } /** @@ -1154,7 +1108,6 @@ static int osc_lock_enqueue(const struct lu_env *env, struct osc_lock *ols = cl2osc_lock(slice); struct cl_lock *lock = ols->ols_cl.cls_lock; int result; - ENTRY; LASSERT(cl_lock_is_mutexed(lock)); LASSERTF(ols->ols_state == OLS_NEW, @@ -1207,7 +1160,7 @@ static int osc_lock_enqueue(const struct lu_env *env, } } LASSERT(ergo(ols->ols_glimpse, !osc_lock_is_lockless(ols))); - RETURN(result); + return result; } static int osc_lock_wait(const struct lu_env *env, @@ -1298,7 +1251,6 @@ static int osc_lock_flush(struct osc_lock *ols, int discard) struct cl_env_nest nest; struct lu_env *env; int result = 0; - ENTRY; env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { @@ -1328,7 +1280,7 @@ static int osc_lock_flush(struct osc_lock *ols, int discard) ols->ols_flush = 1; LINVRNT(!osc_lock_has_pages(ols)); } - RETURN(result); + return result; } /** diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index ca94e633138..9d34de873fa 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -191,10 +191,9 @@ static int osc_object_glimpse(const struct lu_env *env, { struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo; - ENTRY; lvb->lvb_size = oinfo->loi_kms; lvb->lvb_blocks = oinfo->loi_lvb.lvb_blocks; - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index baba959a745..d272322b29b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -219,7 +219,6 @@ static int osc_page_cache_add(const struct lu_env *env, struct osc_io *oio = osc_env_io(env); struct osc_page *opg = cl2osc_page(slice); int result; - ENTRY; LINVRNT(osc_page_protected(env, opg, CLM_WRITE, 0)); @@ -240,7 +239,7 @@ static int osc_page_cache_add(const struct lu_env *env, } } - RETURN(result); + return result; } void osc_index2policy(ldlm_policy_data_t *policy, const struct cl_object *obj, @@ -294,7 +293,6 @@ static int osc_page_is_under_lock(const struct lu_env *env, struct cl_lock *lock; int result = -ENODATA; - ENTRY; lock = cl_lock_at_page(env, slice->cpl_obj, slice->cpl_page, NULL, 1, 0); if (lock != NULL) { @@ -302,7 +300,7 @@ static int osc_page_is_under_lock(const struct lu_env *env, result = -EBUSY; cl_lock_put(env, lock); } - RETURN(result); + return result; } static void osc_page_disown(const struct lu_env *env, @@ -421,7 +419,6 @@ static void osc_page_delete(const struct lu_env *env, LINVRNT(opg->ops_temp || osc_page_protected(env, opg, CLM_READ, 1)); - ENTRY; CDEBUG(D_TRACE, "%p\n", opg); osc_page_transfer_put(env, opg); rc = osc_teardown_async_page(env, obj, opg); @@ -440,7 +437,6 @@ static void osc_page_delete(const struct lu_env *env, spin_unlock(&obj->oo_seatbelt); osc_lru_del(osc_cli(obj), opg, true); - EXIT; } void osc_page_clip(const struct lu_env *env, const struct cl_page_slice *slice, @@ -481,9 +477,9 @@ static int osc_page_flush(const struct lu_env *env, { struct osc_page *opg = cl2osc_page(slice); int rc = 0; - ENTRY; + rc = osc_flush_async_page(env, io, opg); - RETURN(rc); + return rc; } static const struct cl_page_operations osc_page_ops = { @@ -586,7 +582,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, * at any time. */ -static CFS_DECL_WAITQ(osc_lru_waitq); +static DECLARE_WAIT_QUEUE_HEAD(osc_lru_waitq); static atomic_t osc_lru_waiters = ATOMIC_INIT(0); /* LRU pages are freed in batch mode. OSC should at least free this * number of pages to avoid running out of LRU budget, and.. */ @@ -666,15 +662,14 @@ int osc_lru_shrink(struct client_obd *cli, int target) int count = 0; int index = 0; int rc = 0; - ENTRY; LASSERT(atomic_read(&cli->cl_lru_in_list) >= 0); if (atomic_read(&cli->cl_lru_in_list) == 0 || target <= 0) - RETURN(0); + return 0; env = cl_env_nested_get(&nest); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); pvec = osc_env_info(env)->oti_pvec; io = &osc_env_info(env)->oti_io; @@ -757,7 +752,7 @@ int osc_lru_shrink(struct client_obd *cli, int target) cl_env_nested_put(&nest, env); atomic_dec(&cli->cl_lru_shrinkers); - RETURN(count > 0 ? count : rc); + return count > 0 ? count : rc; } static void osc_lru_add(struct client_obd *cli, struct osc_page *opg) @@ -881,13 +876,12 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); struct client_obd *cli = osc_cli(obj); int rc = 0; - ENTRY; if (cli->cl_cache == NULL) /* shall not be in LRU */ - RETURN(0); + return 0; LASSERT(atomic_read(cli->cl_lru_left) >= 0); - while (!cfs_atomic_add_unless(cli->cl_lru_left, -1, 0)) { + while (!atomic_add_unless(cli->cl_lru_left, -1, 0)) { int gen; /* run out of LRU spaces, try to drop some by itself */ @@ -921,7 +915,7 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, rc = 0; } - RETURN(rc); + return rc; } /** @} osc */ diff --git a/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c index 69caab76ced..9720c0e865c 100644 --- a/drivers/staging/lustre/lustre/osc/osc_quota.c +++ b/drivers/staging/lustre/lustre/osc/osc_quota.c @@ -45,7 +45,6 @@ static inline struct osc_quota_info *osc_oqi_alloc(obd_uid id) int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[]) { int type; - ENTRY; for (type = 0; type < MAXQUOTAS; type++) { struct osc_quota_info *oqi; @@ -62,11 +61,11 @@ int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[]) * quota space on this OST */ CDEBUG(D_QUOTA, "chkdq found noquota for %s %d\n", type == USRQUOTA ? "user" : "grout", qid[type]); - RETURN(NO_QUOTA); + return NO_QUOTA; } } - RETURN(QUOTA_OK); + return QUOTA_OK; } #define MD_QUOTA_FLAG(type) ((type == USRQUOTA) ? OBD_MD_FLUSRQUOTA \ @@ -79,10 +78,9 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], { int type; int rc = 0; - ENTRY; if ((valid & (OBD_MD_FLUSRQUOTA | OBD_MD_FLGRPQUOTA)) == 0) - RETURN(0); + return 0; for (type = 0; type < MAXQUOTAS; type++) { struct osc_quota_info *oqi; @@ -134,7 +132,7 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], } } - RETURN(rc); + return rc; } /* @@ -211,7 +209,6 @@ int osc_quota_setup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; int i, type; - ENTRY; for (type = 0; type < MAXQUOTAS; type++) { cli->cl_quota_hash[type] = cfs_hash_create("QUOTA_HASH", @@ -228,24 +225,23 @@ int osc_quota_setup(struct obd_device *obd) } if (type == MAXQUOTAS) - RETURN(0); + return 0; for (i = 0; i < type; i++) cfs_hash_putref(cli->cl_quota_hash[i]); - RETURN(-ENOMEM); + return -ENOMEM; } int osc_quota_cleanup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; int type; - ENTRY; for (type = 0; type < MAXQUOTAS; type++) cfs_hash_putref(cli->cl_quota_hash[type]); - RETURN(0); + return 0; } int osc_quotactl(struct obd_device *unused, struct obd_export *exp, @@ -254,13 +250,12 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp, struct ptlrpc_request *req; struct obd_quotactl *oqc; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_OST_QUOTACTL, LUSTRE_OST_VERSION, OST_QUOTACTL); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; oqc = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); *oqc = *oqctl; @@ -282,7 +277,7 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp, } ptlrpc_req_finished(req); - RETURN(rc); + return rc; } int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, @@ -292,13 +287,12 @@ int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, struct ptlrpc_request *req; struct obd_quotactl *body; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_OST_QUOTACHECK, LUSTRE_OST_VERSION, OST_QUOTACHECK); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; body = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); *body = *oqctl; @@ -312,14 +306,13 @@ int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, if (rc) cli->cl_qchk_stat = rc; ptlrpc_req_finished(req); - RETURN(rc); + return rc; } int osc_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk) { struct client_obd *cli = &exp->exp_obd->u.cli; int rc; - ENTRY; qchk->obd_uuid = cli->cl_target_uuid; memcpy(qchk->obd_type, LUSTRE_OST_NAME, strlen(LUSTRE_OST_NAME)); @@ -328,5 +321,5 @@ int osc_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk) /* the client is not the previous one */ if (rc == CL_NOT_QUOTACHECKED) rc = -EINTR; - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 53d6a35c80b..ee6707a5ea9 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -69,30 +69,29 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, struct lov_stripe_md *lsm) { int lmm_size; - ENTRY; lmm_size = sizeof(**lmmp); if (lmmp == NULL) - RETURN(lmm_size); + return lmm_size; if (*lmmp != NULL && lsm == NULL) { OBD_FREE(*lmmp, lmm_size); *lmmp = NULL; - RETURN(0); + return 0; } else if (unlikely(lsm != NULL && ostid_id(&lsm->lsm_oi) == 0)) { - RETURN(-EBADF); + return -EBADF; } if (*lmmp == NULL) { OBD_ALLOC(*lmmp, lmm_size); if (*lmmp == NULL) - RETURN(-ENOMEM); + return -ENOMEM; } if (lsm) ostid_cpu_to_le(&lsm->lsm_oi, &(*lmmp)->lmm_oi); - RETURN(lmm_size); + return lmm_size; } /* Unpack OSC object metadata from disk storage (LE byte order). */ @@ -101,47 +100,46 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, { int lsm_size; struct obd_import *imp = class_exp2cliimp(exp); - ENTRY; if (lmm != NULL) { if (lmm_bytes < sizeof(*lmm)) { CERROR("%s: lov_mds_md too small: %d, need %d\n", exp->exp_obd->obd_name, lmm_bytes, (int)sizeof(*lmm)); - RETURN(-EINVAL); + return -EINVAL; } /* XXX LOV_MAGIC etc check? */ if (unlikely(ostid_id(&lmm->lmm_oi) == 0)) { CERROR("%s: zero lmm_object_id: rc = %d\n", exp->exp_obd->obd_name, -EINVAL); - RETURN(-EINVAL); + return -EINVAL; } } lsm_size = lov_stripe_md_size(1); if (lsmp == NULL) - RETURN(lsm_size); + return lsm_size; if (*lsmp != NULL && lmm == NULL) { OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); OBD_FREE(*lsmp, lsm_size); *lsmp = NULL; - RETURN(0); + return 0; } if (*lsmp == NULL) { OBD_ALLOC(*lsmp, lsm_size); if (unlikely(*lsmp == NULL)) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); if (unlikely((*lsmp)->lsm_oinfo[0] == NULL)) { OBD_FREE(*lsmp, lsm_size); - RETURN(-ENOMEM); + return -ENOMEM; } loi_init((*lsmp)->lsm_oinfo[0]); } else if (unlikely(ostid_id(&(*lsmp)->lsm_oi) == 0)) { - RETURN(-EBADF); + return -EBADF; } if (lmm != NULL) @@ -154,7 +152,7 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, else (*lsmp)->lsm_maxbytes = LUSTRE_STRIPE_MAXBYTES; - RETURN(lsm_size); + return lsm_size; } static inline void osc_pack_capa(struct ptlrpc_request *req, @@ -202,7 +200,6 @@ static int osc_getattr_interpret(const struct lu_env *env, struct osc_async_args *aa, int rc) { struct ost_body *body; - ENTRY; if (rc != 0) GOTO(out, rc); @@ -223,7 +220,7 @@ static int osc_getattr_interpret(const struct lu_env *env, } out: rc = aa->aa_oi->oi_cb_up(aa->aa_oi, rc); - RETURN(rc); + return rc; } static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, @@ -232,17 +229,16 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, struct ptlrpc_request *req; struct osc_async_args *aa; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } osc_pack_req_body(req, oinfo); @@ -255,7 +251,7 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, aa->aa_oi = oinfo; ptlrpc_set_add_req(set, req); - RETURN(0); + return 0; } static int osc_getattr(const struct lu_env *env, struct obd_export *exp, @@ -264,17 +260,16 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request *req; struct ost_body *body; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } osc_pack_req_body(req, oinfo); @@ -296,7 +291,6 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, oinfo->oi_oa->o_blksize = cli_brw_size(exp->exp_obd); oinfo->oi_oa->o_valid |= OBD_MD_FLBLKSZ; - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -308,19 +302,18 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request *req; struct ost_body *body; int rc; - ENTRY; LASSERT(oinfo->oi_oa->o_valid & OBD_MD_FLGROUP); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } osc_pack_req_body(req, oinfo); @@ -338,10 +331,9 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, lustre_get_wire_obdo(&req->rq_import->imp_connect_data, oinfo->oi_oa, &body->oa); - EXIT; out: ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int osc_setattr_interpret(const struct lu_env *env, @@ -349,7 +341,6 @@ static int osc_setattr_interpret(const struct lu_env *env, struct osc_setattr_args *sa, int rc) { struct ost_body *body; - ENTRY; if (rc != 0) GOTO(out, rc); @@ -362,7 +353,7 @@ static int osc_setattr_interpret(const struct lu_env *env, &body->oa); out: rc = sa->sa_upcall(sa->sa_cookie, rc); - RETURN(rc); + return rc; } int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, @@ -373,17 +364,16 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, struct ptlrpc_request *req; struct osc_setattr_args *sa; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } if (oti && oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE) @@ -413,7 +403,7 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, ptlrpc_set_add_req(rqset, req); } - RETURN(0); + return 0; } static int osc_setattr_async(struct obd_export *exp, struct obd_info *oinfo, @@ -431,7 +421,6 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, struct ost_body *body; struct lov_stripe_md *lsm; int rc; - ENTRY; LASSERT(oa); LASSERT(ea); @@ -440,7 +429,7 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, if (!lsm) { rc = obd_alloc_memmd(exp, &lsm); if (rc < 0) - RETURN(rc); + return rc; } req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_CREATE); @@ -506,7 +495,7 @@ out_req: out: if (rc && !*ea) obd_free_memmd(exp, &lsm); - RETURN(rc); + return rc; } int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, @@ -517,17 +506,16 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, struct osc_setattr_args *sa; struct ost_body *body; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_PUNCH); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_PUNCH); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */ ptlrpc_at_set_req_timeout(req); @@ -551,7 +539,7 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, else ptlrpc_set_add_req(rqset, req); - RETURN(0); + return 0; } static int osc_punch(const struct lu_env *env, struct obd_export *exp, @@ -571,7 +559,6 @@ static int osc_sync_interpret(const struct lu_env *env, { struct osc_fsync_args *fa = arg; struct ost_body *body; - ENTRY; if (rc) GOTO(out, rc); @@ -585,7 +572,7 @@ static int osc_sync_interpret(const struct lu_env *env, *fa->fa_oi->oi_oa = body->oa; out: rc = fa->fa_upcall(fa->fa_cookie, rc); - RETURN(rc); + return rc; } int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, @@ -596,17 +583,16 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, struct ost_body *body; struct osc_fsync_args *fa; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SYNC); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SYNC); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } /* overload the size and blocks fields in the oa with start/end */ @@ -630,25 +616,23 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, else ptlrpc_set_add_req(rqset, req); - RETURN (0); + return 0; } static int osc_sync(const struct lu_env *env, struct obd_export *exp, struct obd_info *oinfo, obd_size start, obd_size end, struct ptlrpc_request_set *set) { - ENTRY; - if (!oinfo->oi_oa) { CDEBUG(D_INFO, "oa NULL\n"); - RETURN(-EINVAL); + return -EINVAL; } oinfo->oi_oa->o_size = start; oinfo->oi_oa->o_blocks = end; oinfo->oi_oa->o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS); - RETURN(osc_sync_base(exp, oinfo, oinfo->oi_cb_up, oinfo, set)); + return osc_sync_base(exp, oinfo, oinfo->oi_cb_up, oinfo, set); } /* Find and cancel locally locks matched by @mode in the resource found by @@ -662,7 +646,6 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa, struct ldlm_res_id res_id; struct ldlm_resource *res; int count; - ENTRY; /* Return, i.e. cancel nothing, only if ELC is supported (flag in * export) but disabled through procfs (flag in NS). @@ -671,19 +654,19 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa, * when we still want to cancel locks in advance and just cancel them * locally, without sending any RPC. */ if (exp_connect_cancelset(exp) && !ns_connect_cancelset(ns)) - RETURN(0); + return 0; ostid_build_res_name(&oa->o_oi, &res_id); res = ldlm_resource_get(ns, NULL, &res_id, 0, 0); if (res == NULL) - RETURN(0); + return 0; LDLM_RESOURCE_ADDREF(res); count = ldlm_cancel_resource_local(res, cancels, NULL, mode, lock_flags, 0, NULL); LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); - RETURN(count); + return count; } static int osc_destroy_interpret(const struct lu_env *env, @@ -720,7 +703,6 @@ int osc_create(const struct lu_env *env, struct obd_export *exp, struct obd_trans_info *oti) { int rc = 0; - ENTRY; LASSERT(oa); LASSERT(ea); @@ -728,16 +710,16 @@ int osc_create(const struct lu_env *env, struct obd_export *exp, if ((oa->o_valid & OBD_MD_FLFLAGS) && oa->o_flags == OBD_FL_RECREATE_OBJS) { - RETURN(osc_real_create(exp, oa, ea, oti)); + return osc_real_create(exp, oa, ea, oti); } if (!fid_seq_is_mdt(ostid_seq(&oa->o_oi))) - RETURN(osc_real_create(exp, oa, ea, oti)); + return osc_real_create(exp, oa, ea, oti); /* we should not get here anymore */ LBUG(); - RETURN(rc); + return rc; } /* Destroy requests can be async always on the client, and we don't even really @@ -760,11 +742,10 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, struct ost_body *body; LIST_HEAD(cancels); int rc, count; - ENTRY; if (!oa) { CDEBUG(D_INFO, "oa NULL\n"); - RETURN(-EINVAL); + return -EINVAL; } count = osc_resource_get_unused(exp, oa, &cancels, LCK_PW, @@ -773,7 +754,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_DESTROY); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } osc_set_capa_size(req, &RMF_CAPA1, (struct obd_capa *)capa); @@ -781,7 +762,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, 0, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */ @@ -817,7 +798,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, /* Do not wait for response */ ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); - RETURN(0); + return 0; } static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, @@ -948,7 +929,6 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) { int rc = 0; struct ost_body *body; - ENTRY; client_obd_list_lock(&cli->cl_loi_list_lock); /* Don't shrink if we are already above or below the desired limit @@ -959,13 +939,13 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) if (target_bytes >= cli->cl_avail_grant) { client_obd_list_unlock(&cli->cl_loi_list_lock); - RETURN(0); + return 0; } client_obd_list_unlock(&cli->cl_loi_list_lock); OBD_ALLOC_PTR(body); if (!body) - RETURN(-ENOMEM); + return -ENOMEM; osc_announce_cached(cli, &body->oa, 0); @@ -986,7 +966,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) if (rc != 0) __osc_update_grant(cli, body->oa.o_grant); OBD_FREE_PTR(body); - RETURN(rc); + return rc; } static int osc_should_shrink_grant(struct client_obd *client) @@ -1256,11 +1236,10 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, struct req_capsule *pill; struct brw_page *pg_prev; - ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_BRW_PREP_REQ)) - RETURN(-ENOMEM); /* Recoverable */ + return -ENOMEM; /* Recoverable */ if (OBD_FAIL_CHECK(OBD_FAIL_OSC_BRW_PREP_REQ2)) - RETURN(-EINVAL); /* Fatal */ + return -EINVAL; /* Fatal */ if ((cmd & OBD_BRW_WRITE) != 0) { opc = OST_WRITE; @@ -1272,7 +1251,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, req = ptlrpc_request_alloc(cli->cl_import, &RQF_OST_BRW_READ); } if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; for (niocount = i = 1; i < page_count; i++) { if (!can_merge_pages(pga[i - 1], pga[i])) @@ -1289,7 +1268,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, opc); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */ ptlrpc_at_set_req_timeout(req); @@ -1435,11 +1414,11 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, aa->aa_ocapa = capa_get(ocapa); *reqp = req; - RETURN(0); + return 0; out: ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer, @@ -1496,18 +1475,17 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) struct client_obd *cli = aa->aa_cli; struct ost_body *body; __u32 client_cksum = 0; - ENTRY; if (rc < 0 && rc != -EDQUOT) { DEBUG_REQ(D_INFO, req, "Failed request with rc = %d\n", rc); - RETURN(rc); + return rc; } LASSERTF(req->rq_repmsg != NULL, "rc = %d\n", rc); body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); if (body == NULL) { DEBUG_REQ(D_INFO, req, "Can't unpack body\n"); - RETURN(-EPROTO); + return -EPROTO; } /* set/clear over quota flag for a uid/gid */ @@ -1524,7 +1502,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) osc_update_grant(cli, body); if (rc < 0) - RETURN(rc); + return rc; if (aa->aa_oa->o_valid & OBD_MD_FLCKSUM) client_cksum = aa->aa_oa->o_cksum; /* save for later */ @@ -1532,19 +1510,19 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE) { if (rc > 0) { CERROR("Unexpected +ve rc %d\n", rc); - RETURN(-EPROTO); + return -EPROTO; } LASSERT(req->rq_bulk->bd_nob == aa->aa_requested_nob); if (sptlrpc_cli_unwrap_bulk_write(req, req->rq_bulk)) - RETURN(-EAGAIN); + return -EAGAIN; if ((aa->aa_oa->o_valid & OBD_MD_FLCKSUM) && client_cksum && check_write_checksum(&body->oa, peer, client_cksum, body->oa.o_cksum, aa->aa_requested_nob, aa->aa_page_count, aa->aa_ppga, cksum_type_unpack(aa->aa_oa->o_flags))) - RETURN(-EAGAIN); + return -EAGAIN; rc = check_write_rcs(req, aa->aa_requested_nob,aa->aa_nio_count, aa->aa_page_count, aa->aa_ppga); @@ -1561,7 +1539,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if (rc > aa->aa_requested_nob) { CERROR("Unexpected rc %d (%d requested)\n", rc, aa->aa_requested_nob); - RETURN(-EPROTO); + return -EPROTO; } if (rc != req->rq_bulk->bd_nob_transferred) { @@ -1641,7 +1619,7 @@ out: lustre_get_wire_obdo(&req->rq_import->imp_connect_data, aa->aa_oa, &body->oa); - RETURN(rc); + return rc; } static int osc_brw_internal(int cmd, struct obd_export *exp, struct obdo *oa, @@ -1655,8 +1633,6 @@ static int osc_brw_internal(int cmd, struct obd_export *exp, struct obdo *oa, int generation, resends = 0; struct l_wait_info lwi; - ENTRY; - init_waitqueue_head(&waitq); generation = exp->exp_obd->u.cli.cl_import->imp_generation; @@ -1711,7 +1687,7 @@ restart_bulk: out: if (rc == -EAGAIN || rc == -EINPROGRESS) rc = -EIO; - RETURN (rc); + return rc; } static int osc_brw_redo_request(struct ptlrpc_request *request, @@ -1720,7 +1696,6 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, struct ptlrpc_request *new_req; struct osc_brw_async_args *new_aa; struct osc_async_page *oap; - ENTRY; DEBUG_REQ(rc == -EINPROGRESS ? D_RPCTRACE : D_ERROR, request, "redo for recoverable error %d", rc); @@ -1732,7 +1707,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, aa->aa_page_count, aa->aa_ppga, &new_req, aa->aa_ocapa, 0, 1); if (rc) - RETURN(rc); + return rc; list_for_each_entry(oap, &aa->aa_oaps, oap_rpc_item) { if (oap->oap_request != NULL) { @@ -1741,7 +1716,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, request, oap->oap_request); if (oap->oap_interrupted) { ptlrpc_req_finished(new_req); - RETURN(-EINTR); + return -EINTR; } } } @@ -1784,7 +1759,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, ptlrpcd_add_req(new_req, PDL_POLICY_SAME, -1); DEBUG_REQ(D_INFO, new_req, "new request"); - RETURN(0); + return 0; } /* @@ -1873,7 +1848,6 @@ static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, struct obd_import *imp = class_exp2cliimp(exp); struct client_obd *cli; int rc, page_count_orig; - ENTRY; LASSERT((imp != NULL) && (imp->imp_obd != NULL)); cli = &imp->imp_obd->u.cli; @@ -1883,8 +1857,8 @@ static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, * I/O can succeed */ if (imp->imp_invalid) - RETURN(-EIO); - RETURN(0); + return -EIO; + return 0; } /* test_brw with a failed create can trip this, maybe others. */ @@ -1894,7 +1868,7 @@ static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, orig = ppga = osc_build_ppga(pga, page_count); if (ppga == NULL) - RETURN(-ENOMEM); + return -ENOMEM; page_count_orig = page_count; sort_brw_pages(ppga, page_count); @@ -1935,7 +1909,7 @@ out: if (saved_oa != NULL) OBDO_FREE(saved_oa); - RETURN(rc); + return rc; } static int brw_interpret(const struct lu_env *env, @@ -1946,7 +1920,6 @@ static int brw_interpret(const struct lu_env *env, struct osc_extent *tmp; struct cl_object *obj = NULL; struct client_obd *cli = aa->aa_cli; - ENTRY; rc = osc_brw_fini_request(req, rc); CDEBUG(D_INODE, "request %p aa %p rc %d\n", req, aa, rc); @@ -1970,7 +1943,7 @@ static int brw_interpret(const struct lu_env *env, } if (rc == 0) - RETURN(0); + return 0; else if (rc == -EAGAIN || rc == -EINPROGRESS) rc = -EIO; } @@ -2040,7 +2013,7 @@ static int brw_interpret(const struct lu_env *env, client_obd_list_unlock(&cli->cl_loi_list_lock); osc_io_unplug(env, cli, NULL, PDL_POLICY_SAME); - RETURN(rc); + return rc; } /** @@ -2072,7 +2045,6 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, int rc; LIST_HEAD(rpc_list); - ENTRY; LASSERT(!list_empty(ext_list)); /* add pages into rpc_list to build BRW rpc */ @@ -2228,7 +2200,6 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, */ ptlrpcd_add_req(req, pol, -1); rc = 0; - EXIT; out: if (mem_tight != 0) @@ -2257,7 +2228,7 @@ out: if (clerq && !IS_ERR(clerq)) cl_req_completion(env, clerq, rc); } - RETURN(rc); + return rc; } static int osc_set_lock_data_with_check(struct ldlm_lock *lock, @@ -2337,7 +2308,6 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, __u64 *flags, int agl, int rc) { int intent = *flags & LDLM_FL_HAS_INTENT; - ENTRY; if (intent) { /* The request was created before ldlm_cli_enqueue call. */ @@ -2347,6 +2317,8 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, &RMF_DLM_REP); LASSERT(rep != NULL); + rep->lock_policy_res1 = + ptlrpc_status_ntoh(rep->lock_policy_res1); if (rep->lock_policy_res1) rc = rep->lock_policy_res1; } @@ -2361,7 +2333,7 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, /* Call the update callback. */ rc = (*upcall)(cookie, rc); - RETURN(rc); + return rc; } static int osc_enqueue_interpret(const struct lu_env *env, @@ -2494,7 +2466,6 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, int match_lvb = (agl != 0 ? 0 : LDLM_FL_LVB_READY); ldlm_mode_t mode; int rc; - ENTRY; /* Filesystem lock extents are extended to page boundaries so that * dealing with the page cache is a little smoother. */ @@ -2536,7 +2507,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, * Return -ECANCELED to tell the caller. */ ldlm_lock_decref(lockh, mode); LDLM_LOCK_PUT(matched); - RETURN(-ECANCELED); + return -ECANCELED; } else if (osc_set_lock_data_with_check(matched, einfo)) { *flags |= LDLM_FL_LVB_READY; /* addref the lock only if not async requests and PW @@ -2561,7 +2532,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, /* For async requests, decref the lock. */ ldlm_lock_decref(lockh, einfo->ei_mode); LDLM_LOCK_PUT(matched); - RETURN(ELDLM_OK); + return ELDLM_OK; } else { ldlm_lock_decref(lockh, mode); LDLM_LOCK_PUT(matched); @@ -2574,12 +2545,12 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE_LVB); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = ldlm_prep_enqueue_req(exp, req, &cancels, 0); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, @@ -2615,14 +2586,14 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, } else if (intent) { ptlrpc_req_finished(req); } - RETURN(rc); + return rc; } rc = osc_enqueue_fini(req, lvb, upcall, cookie, flags, agl, rc); if (intent) ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, @@ -2631,7 +2602,6 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, { struct ldlm_res_id res_id; int rc; - ENTRY; ostid_build_res_name(&oinfo->oi_md->lsm_oi, &res_id); rc = osc_enqueue_base(exp, &res_id, &oinfo->oi_flags, &oinfo->oi_policy, @@ -2639,7 +2609,7 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, oinfo->oi_md->lsm_oinfo[0]->loi_kms_valid, oinfo->oi_cb_up, oinfo, einfo, oinfo->oi_lockh, rqset, rqset != NULL, 0); - RETURN(rc); + return rc; } int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, @@ -2650,10 +2620,9 @@ int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, struct obd_device *obd = exp->exp_obd; int lflags = *flags; ldlm_mode_t rc; - ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_MATCH)) - RETURN(-EIO); + return -EIO; /* Filesystem lock extents are extended to page boundaries so that * dealing with the page cache is a little smoother */ @@ -2674,35 +2643,32 @@ int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, if (!osc_set_data_with_check(lockh, data)) { if (!(lflags & LDLM_FL_TEST_LOCK)) ldlm_lock_decref(lockh, rc); - RETURN(0); + return 0; } } if (!(lflags & LDLM_FL_TEST_LOCK) && mode != rc) { ldlm_lock_addref(lockh, LCK_PR); ldlm_lock_decref(lockh, LCK_PW); } - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } int osc_cancel_base(struct lustre_handle *lockh, __u32 mode) { - ENTRY; - if (unlikely(mode == LCK_GROUP)) ldlm_lock_decref_and_cancel(lockh, mode); else ldlm_lock_decref(lockh, mode); - RETURN(0); + return 0; } static int osc_cancel(struct obd_export *exp, struct lov_stripe_md *md, __u32 mode, struct lustre_handle *lockh) { - ENTRY; - RETURN(osc_cancel_base(lockh, mode)); + return osc_cancel_base(lockh, mode); } static int osc_cancel_unused(struct obd_export *exp, @@ -2726,7 +2692,6 @@ static int osc_statfs_interpret(const struct lu_env *env, struct osc_async_args *aa, int rc) { struct obd_statfs *msfs; - ENTRY; if (rc == -EBADR) /* The request has in fact never been sent @@ -2734,7 +2699,7 @@ static int osc_statfs_interpret(const struct lu_env *env, * Exit immediately since the caller is * aware of the problem and takes care * of the clean up */ - RETURN(rc); + return rc; if ((rc == -ENOTCONN || rc == -EAGAIN) && (aa->aa_oi->oi_flags & OBD_STATFS_NODELAY)) @@ -2751,7 +2716,7 @@ static int osc_statfs_interpret(const struct lu_env *env, *aa->aa_oi->oi_osfs = *msfs; out: rc = aa->aa_oi->oi_cb_up(aa->aa_oi, rc); - RETURN(rc); + return rc; } static int osc_statfs_async(struct obd_export *exp, @@ -2762,7 +2727,6 @@ static int osc_statfs_async(struct obd_export *exp, struct ptlrpc_request *req; struct osc_async_args *aa; int rc; - ENTRY; /* We could possibly pass max_age in the request (as an absolute * timestamp or a "seconds.usec ago") so the target can avoid doing @@ -2772,12 +2736,12 @@ static int osc_statfs_async(struct obd_export *exp, * timestamps are not ideal because they need time synchronization. */ req = ptlrpc_request_alloc(obd->u.cli.cl_import, &RQF_OST_STATFS); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_STATFS); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } ptlrpc_request_set_replen(req); req->rq_request_portal = OST_CREATE_PORTAL; @@ -2795,7 +2759,7 @@ static int osc_statfs_async(struct obd_export *exp, aa->aa_oi = oinfo; ptlrpc_set_add_req(rqset, req); - RETURN(0); + return 0; } static int osc_statfs(const struct lu_env *env, struct obd_export *exp, @@ -2806,7 +2770,6 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request *req; struct obd_import *imp = NULL; int rc; - ENTRY; /*Since the request might also come from lprocfs, so we need *sync this with client_disconnect_export Bug15684*/ @@ -2815,7 +2778,7 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, imp = class_import_get(obd->u.cli.cl_import); up_read(&obd->u.cli.cl_sem); if (!imp) - RETURN(-ENODEV); + return -ENODEV; /* We could possibly pass max_age in the request (as an absolute * timestamp or a "seconds.usec ago") so the target can avoid doing @@ -2828,12 +2791,12 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, class_import_put(imp); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_STATFS); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } ptlrpc_request_set_replen(req); req->rq_request_portal = OST_CREATE_PORTAL; @@ -2856,7 +2819,6 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, *osfs = *msfs; - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -2874,20 +2836,19 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) struct lov_user_md_v3 lum, *lumk; struct lov_user_ost_data_v1 *lmm_objects; int rc = 0, lum_size; - ENTRY; if (!lsm) - RETURN(-ENODATA); + return -ENODATA; /* we only need the header part from user space to get lmm_magic and * lmm_stripe_count, (the header part is common to v1 and v3) */ lum_size = sizeof(struct lov_user_md_v1); if (copy_from_user(&lum, lump, lum_size)) - RETURN(-EFAULT); + return -EFAULT; if ((lum.lmm_magic != LOV_USER_MAGIC_V1) && (lum.lmm_magic != LOV_USER_MAGIC_V3)) - RETURN(-EINVAL); + return -EINVAL; /* lov_user_md_vX and lov_mds_md_vX must have the same size */ LASSERT(sizeof(struct lov_user_md_v1) == sizeof(struct lov_mds_md_v1)); @@ -2900,7 +2861,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) lum_size = lov_mds_md_size(lum.lmm_stripe_count, lum.lmm_magic); OBD_ALLOC(lumk, lum_size); if (!lumk) - RETURN(-ENOMEM); + return -ENOMEM; if (lum.lmm_magic == LOV_USER_MAGIC_V1) lmm_objects = @@ -2922,7 +2883,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) if (lumk != &lum) OBD_FREE(lumk, lum_size); - RETURN(rc); + return rc; } @@ -2932,7 +2893,6 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct obd_device *obd = exp->exp_obd; struct obd_ioctl_data *data = karg; int err = 0; - ENTRY; if (!try_module_get(THIS_MODULE)) { CERROR("Can't get module. Is it alive?"); @@ -3016,15 +2976,14 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, obd_count keylen, void *key, __u32 *vallen, void *val, struct lov_stripe_md *lsm) { - ENTRY; if (!vallen || !val) - RETURN(-EFAULT); + return -EFAULT; if (KEY_IS(KEY_LOCK_TO_STRIPE)) { __u32 *stripe = val; *vallen = sizeof(*stripe); *stripe = 0; - RETURN(0); + return 0; } else if (KEY_IS(KEY_LAST_ID)) { struct ptlrpc_request *req; obd_id *reply; @@ -3034,14 +2993,14 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GET_INFO_LAST_ID); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT, keylen); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GET_INFO); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); @@ -3060,7 +3019,7 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, *((obd_id *)val) = *reply; out: ptlrpc_req_finished(req); - RETURN(rc); + return rc; } else if (KEY_IS(KEY_FIEMAP)) { struct ll_fiemap_info_key *fm_key = (struct ll_fiemap_info_key *)key; @@ -3142,10 +3101,10 @@ fini_req: drop_lock: if (mode) ldlm_lock_decref(&lockh, LCK_PR); - RETURN(rc); + return rc; } - RETURN(-EINVAL); + return -EINVAL; } static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, @@ -3157,25 +3116,24 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, struct obd_import *imp = class_exp2cliimp(exp); char *tmp; int rc; - ENTRY; OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_SHUTDOWN, 10); if (KEY_IS(KEY_CHECKSUM)) { if (vallen != sizeof(int)) - RETURN(-EINVAL); + return -EINVAL; exp->exp_obd->u.cli.cl_checksum = (*(int *)val) ? 1 : 0; - RETURN(0); + return 0; } if (KEY_IS(KEY_SPTLRPC_CONF)) { sptlrpc_conf_client_adapt(obd); - RETURN(0); + return 0; } if (KEY_IS(KEY_FLUSH_CTX)) { sptlrpc_import_flush_my_ctx(imp); - RETURN(0); + return 0; } if (KEY_IS(KEY_CACHE_SET)) { @@ -3192,7 +3150,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, list_add(&cli->cl_lru_osc, &cli->cl_cache->ccc_lru); spin_unlock(&cli->cl_cache->ccc_lru_lock); - RETURN(0); + return 0; } if (KEY_IS(KEY_CACHE_LRU_SHRINK)) { @@ -3202,11 +3160,11 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, nr = osc_lru_shrink(cli, min(nr, target)); *(int *)val -= nr; - RETURN(0); + return 0; } if (!set && !KEY_IS(KEY_GRANT_SHRINK)) - RETURN(-EINVAL); + return -EINVAL; /* We pass all other commands directly to OST. Since nobody calls osc methods directly and everybody is supposed to go through LOV, we @@ -3219,7 +3177,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, &RQF_OST_SET_GRANT_INFO : &RQF_OBD_SET_INFO); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT, keylen); @@ -3229,7 +3187,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SET_INFO); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); @@ -3248,7 +3206,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, OBDO_ALLOC(oa); if (!oa) { ptlrpc_req_finished(req); - RETURN(-ENOMEM); + return -ENOMEM; } *oa = ((struct ost_body *)val)->oa; aa->aa_oa = oa; @@ -3263,7 +3221,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, } else ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); - RETURN(0); + return 0; } @@ -3280,8 +3238,6 @@ static int osc_llog_finish(struct obd_device *obd, int count) { struct llog_ctxt *ctxt; - ENTRY; - ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); if (ctxt) { llog_cat_close(NULL, ctxt->loc_handle); @@ -3291,7 +3247,7 @@ static int osc_llog_finish(struct obd_device *obd, int count) ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); if (ctxt) llog_cleanup(NULL, ctxt); - RETURN(0); + return 0; } static int osc_reconnect(const struct lu_env *env, @@ -3317,7 +3273,7 @@ static int osc_reconnect(const struct lu_env *env, data->ocd_version, data->ocd_grant, lost_grant); } - RETURN(0); + return 0; } static int osc_disconnect(struct obd_export *exp) @@ -3369,7 +3325,6 @@ static int osc_import_event(struct obd_device *obd, struct client_obd *cli; int rc = 0; - ENTRY; LASSERT(imp->imp_obd == obd); switch (event) { @@ -3433,7 +3388,7 @@ static int osc_import_event(struct obd_device *obd, CERROR("Unknown import event %d\n", event); LBUG(); } - RETURN(rc); + return rc; } /** @@ -3457,9 +3412,9 @@ static int osc_cancel_for_recovery(struct ldlm_lock *lock) (lock->l_granted_mode == LCK_PR || lock->l_granted_mode == LCK_CR) && (osc_dlm_lock_pageref(lock) == 0)) - RETURN(1); + return 1; - RETURN(0); + return 0; } static int brw_queue_work(const struct lu_env *env, void *data) @@ -3469,7 +3424,7 @@ static int brw_queue_work(const struct lu_env *env, void *data) CDEBUG(D_CACHE, "Run writeback work for client obd %p.\n", cli); osc_io_unplug(env, cli, NULL, PDL_POLICY_SAME); - RETURN(0); + return 0; } int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) @@ -3478,11 +3433,10 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) struct client_obd *cli = &obd->u.cli; void *handler; int rc; - ENTRY; rc = ptlrpcd_addref(); if (rc) - RETURN(rc); + return rc; rc = client_obd_setup(obd, lcfg); if (rc) @@ -3517,7 +3471,7 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) INIT_LIST_HEAD(&cli->cl_grant_shrink_list); ns_register_cancel(obd->obd_namespace, osc_cancel_for_recovery); - RETURN(rc); + return rc; out_ptlrpcd_work: ptlrpcd_destroy_work(handler); @@ -3525,13 +3479,12 @@ out_client_setup: client_obd_cleanup(obd); out_ptlrpcd: ptlrpcd_decref(); - RETURN(rc); + return rc; } static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { int rc = 0; - ENTRY; switch (stage) { case OBD_CLEANUP_EARLY: { @@ -3570,7 +3523,7 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) break; } } - RETURN(rc); + return rc; } int osc_cleanup(struct obd_device *obd) @@ -3578,8 +3531,6 @@ int osc_cleanup(struct obd_device *obd) struct client_obd *cli = &obd->u.cli; int rc; - ENTRY; - /* lru cleanup */ if (cli->cl_cache != NULL) { LASSERT(atomic_read(&cli->cl_cache->ccc_users) > 0); @@ -3597,7 +3548,7 @@ int osc_cleanup(struct obd_device *obd) rc = client_obd_cleanup(obd); ptlrpcd_decref(); - RETURN(rc); + return rc; } int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg) @@ -3671,7 +3622,6 @@ int __init osc_init(void) { struct lprocfs_static_vars lvars = { 0 }; int rc; - ENTRY; /* print an address of _any_ initialized kernel symbol from this * module, to allow debugging with gdb that doesn't support data @@ -3679,6 +3629,8 @@ int __init osc_init(void) CDEBUG(D_INFO, "Lustre OSC module (%p).\n", &osc_caches); rc = lu_kmem_init(osc_caches); + if (rc) + return rc; lprocfs_osc_init_vars(&lvars); @@ -3686,13 +3638,13 @@ int __init osc_init(void) LUSTRE_OSC_NAME, &osc_device_type); if (rc) { lu_kmem_fini(osc_caches); - RETURN(rc); + return rc; } spin_lock_init(&osc_ast_guard); lockdep_set_class(&osc_ast_guard, &osc_ast_guard_class); - RETURN(rc); + return rc; } static void /*__exit*/ osc_exit(void) @@ -3704,5 +3656,7 @@ static void /*__exit*/ osc_exit(void) MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); MODULE_DESCRIPTION("Lustre Object Storage Client (OSC)"); MODULE_LICENSE("GPL"); +MODULE_VERSION(LUSTRE_VERSION_STRING); -cfs_module(osc, LUSTRE_VERSION_STRING, osc_init, osc_exit); +module_init(osc_init); +module_exit(osc_exit); diff --git a/drivers/staging/lustre/lustre/ptlrpc/Makefile b/drivers/staging/lustre/lustre/ptlrpc/Makefile index 983eb66a554..6d78b80487f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/Makefile +++ b/drivers/staging/lustre/lustre/ptlrpc/Makefile @@ -16,6 +16,7 @@ ptlrpc_objs += sec.o sec_bulk.o sec_gc.o sec_config.o sec_lproc.o ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs) +ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.o obj-$(CONFIG_PTLRPC_GSS) += gss/ diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 22f7e654c9d..810a458caed 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -137,11 +137,10 @@ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req, struct obd_import *imp = req->rq_import; struct ptlrpc_bulk_desc *desc; - ENTRY; LASSERT(type == BULK_PUT_SINK || type == BULK_GET_SOURCE); desc = ptlrpc_new_bulk(npages, max_brw, type, portal); if (desc == NULL) - RETURN(NULL); + return NULL; desc->bd_import_generation = req->rq_import_generation; desc->bd_import = class_import_get(imp); @@ -187,7 +186,6 @@ EXPORT_SYMBOL(__ptlrpc_prep_bulk_page); void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin) { int i; - ENTRY; LASSERT(desc != NULL); LASSERT(desc->bd_iov_count != LI_POISON); /* not freed already */ @@ -208,7 +206,6 @@ void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin) OBD_FREE(desc, offsetof(struct ptlrpc_bulk_desc, bd_iov[desc->bd_max_iov])); - EXIT; } EXPORT_SYMBOL(__ptlrpc_free_bulk); @@ -336,7 +333,6 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) struct ptlrpc_request *early_req; time_t olddl; int rc; - ENTRY; req->rq_early = 0; spin_unlock(&req->rq_lock); @@ -344,7 +340,7 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) rc = sptlrpc_cli_unwrap_early_reply(req, &early_req); if (rc) { spin_lock(&req->rq_lock); - RETURN(rc); + return rc; } rc = unpack_reply(early_req); @@ -360,7 +356,7 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) if (rc != 0) { spin_lock(&req->rq_lock); - RETURN(rc); + return rc; } /* Adjust the local timeout for this req */ @@ -379,7 +375,7 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) cfs_time_sub(req->rq_deadline, cfs_time_current_sec()), cfs_time_sub(req->rq_deadline, olddl)); - RETURN(rc); + return rc; } /** @@ -547,7 +543,6 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, { struct obd_import *imp = request->rq_import; int rc; - ENTRY; if (unlikely(ctx)) request->rq_cli_ctx = sptlrpc_cli_ctx_get(ctx); @@ -601,7 +596,7 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, lustre_msg_set_opc(request->rq_reqmsg, opcode); - RETURN(0); + return 0; out_ctx: sptlrpc_cli_ctx_put(request->rq_cli_ctx, 1); out_free: @@ -822,10 +817,9 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void) { struct ptlrpc_request_set *set; - ENTRY; OBD_ALLOC(set, sizeof *set); if (!set) - RETURN(NULL); + return NULL; atomic_set(&set->set_refcount, 1); INIT_LIST_HEAD(&set->set_requests); init_waitqueue_head(&set->set_waitq); @@ -839,7 +833,7 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void) set->set_producer_arg = NULL; set->set_rc = 0; - RETURN(set); + return set; } EXPORT_SYMBOL(ptlrpc_prep_set); @@ -859,13 +853,13 @@ struct ptlrpc_request_set *ptlrpc_prep_fcset(int max, set_producer_func func, set = ptlrpc_prep_set(); if (!set) - RETURN(NULL); + return NULL; set->set_max_inflight = max; set->set_producer = func; set->set_producer_arg = arg; - RETURN(set); + return set; } EXPORT_SYMBOL(ptlrpc_prep_fcset); @@ -883,7 +877,6 @@ void ptlrpc_set_destroy(struct ptlrpc_request_set *set) struct list_head *next; int expected_phase; int n = 0; - ENTRY; /* Requests on the set should either all be completed, or all be new */ expected_phase = (atomic_read(&set->set_remaining) == 0) ? @@ -925,7 +918,6 @@ void ptlrpc_set_destroy(struct ptlrpc_request_set *set) LASSERT(atomic_read(&set->set_remaining) == 0); ptlrpc_reqset_put(set); - EXIT; } EXPORT_SYMBOL(ptlrpc_set_destroy); @@ -941,13 +933,13 @@ int ptlrpc_set_add_cb(struct ptlrpc_request_set *set, OBD_ALLOC_PTR(cbdata); if (cbdata == NULL) - RETURN(-ENOMEM); + return -ENOMEM; cbdata->psc_interpret = fn; cbdata->psc_data = data; list_add_tail(&cbdata->psc_item, &set->set_cblist); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_set_add_cb); @@ -1027,7 +1019,6 @@ static int ptlrpc_import_delay_req(struct obd_import *imp, struct ptlrpc_request *req, int *status) { int delay = 0; - ENTRY; LASSERT (status != NULL); *status = 0; @@ -1078,7 +1069,7 @@ static int ptlrpc_import_delay_req(struct obd_import *imp, } } - RETURN(delay); + return delay; } /** @@ -1120,7 +1111,6 @@ static int ptlrpc_console_allow(struct ptlrpc_request *req) static int ptlrpc_check_status(struct ptlrpc_request *req) { int err; - ENTRY; err = lustre_msg_get_status(req->rq_repmsg); if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) { @@ -1133,7 +1123,7 @@ static int ptlrpc_check_status(struct ptlrpc_request *req) libcfs_nid2str( imp->imp_connection->c_peer.nid), ll_opcode2str(opc), err); - RETURN(err < 0 ? err : -EINVAL); + return err < 0 ? err : -EINVAL; } if (err < 0) { @@ -1143,7 +1133,7 @@ static int ptlrpc_check_status(struct ptlrpc_request *req) DEBUG_REQ(D_INFO, req, "status is %d", err); } - RETURN(err); + return err; } /** @@ -1156,7 +1146,6 @@ static void ptlrpc_save_versions(struct ptlrpc_request *req) struct lustre_msg *repmsg = req->rq_repmsg; struct lustre_msg *reqmsg = req->rq_reqmsg; __u64 *versions = lustre_msg_get_versions(repmsg); - ENTRY; if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) return; @@ -1165,8 +1154,6 @@ static void ptlrpc_save_versions(struct ptlrpc_request *req) lustre_msg_set_versions(reqmsg, versions); CDEBUG(D_INFO, "Client save versions ["LPX64"/"LPX64"]\n", versions[0], versions[1]); - - EXIT; } /** @@ -1183,7 +1170,6 @@ static int after_reply(struct ptlrpc_request *req) int rc; struct timeval work_start; long timediff; - ENTRY; LASSERT(obd != NULL); /* repbuf must be unlinked */ @@ -1194,7 +1180,7 @@ static int after_reply(struct ptlrpc_request *req) DEBUG_REQ(D_ERROR, req, "reply buffer overflow," " expected: %d, actual size: %d", req->rq_nob_received, req->rq_repbuf_len); - RETURN(-EOVERFLOW); + return -EOVERFLOW; } sptlrpc_cli_free_repbuf(req); @@ -1205,7 +1191,7 @@ static int after_reply(struct ptlrpc_request *req) req->rq_replen = req->rq_nob_received; req->rq_nob_received = 0; req->rq_resend = 1; - RETURN(0); + return 0; } /* @@ -1215,18 +1201,18 @@ static int after_reply(struct ptlrpc_request *req) rc = sptlrpc_cli_unwrap_reply(req); if (rc) { DEBUG_REQ(D_ERROR, req, "unwrap reply failed (%d):", rc); - RETURN(rc); + return rc; } /* * Security layer unwrap might ask resend this request. */ if (req->rq_resend) - RETURN(0); + return 0; rc = unpack_reply(req); if (rc) - RETURN(rc); + return rc; /* retry indefinitely on EINPROGRESS */ if (lustre_msg_get_status(req->rq_repmsg) == -EINPROGRESS && @@ -1257,7 +1243,7 @@ static int after_reply(struct ptlrpc_request *req) else req->rq_sent = now + req->rq_nr_resend; - RETURN(0); + return 0; } do_gettimeofday(&work_start); @@ -1272,7 +1258,7 @@ static int after_reply(struct ptlrpc_request *req) lustre_msg_get_type(req->rq_repmsg) != PTL_RPC_MSG_ERR) { DEBUG_REQ(D_ERROR, req, "invalid packet received (type=%u)", lustre_msg_get_type(req->rq_repmsg)); - RETURN(-EPROTO); + return -EPROTO; } if (lustre_msg_get_opc(req->rq_reqmsg) != OBD_PING) @@ -1293,10 +1279,10 @@ static int after_reply(struct ptlrpc_request *req) if (ll_rpc_recoverable_error(rc)) { if (req->rq_send_state != LUSTRE_IMP_FULL || imp->imp_obd->obd_no_recov || imp->imp_dlm_fake) { - RETURN(rc); + return rc; } ptlrpc_request_handle_notconn(req); - RETURN(rc); + return rc; } } else { /* @@ -1360,7 +1346,7 @@ static int after_reply(struct ptlrpc_request *req) spin_unlock(&imp->imp_lock); } - RETURN(rc); + return rc; } /** @@ -1372,13 +1358,12 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) { struct obd_import *imp = req->rq_import; int rc; - ENTRY; LASSERT(req->rq_phase == RQ_PHASE_NEW); if (req->rq_sent && (req->rq_sent > cfs_time_current_sec()) && (!req->rq_generation_set || req->rq_import_generation == imp->imp_generation)) - RETURN (0); + return 0; ptlrpc_rqphase_move(req, RQ_PHASE_RPC); @@ -1400,14 +1385,14 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) list_add_tail(&req->rq_list, &imp->imp_delayed_list); atomic_inc(&req->rq_import->imp_inflight); spin_unlock(&imp->imp_lock); - RETURN(0); + return 0; } if (rc != 0) { spin_unlock(&imp->imp_lock); req->rq_status = rc; ptlrpc_rqphase_move(req, RQ_PHASE_INTERPRET); - RETURN(rc); + return rc; } LASSERT(list_empty(&req->rq_list)); @@ -1421,10 +1406,10 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) if (rc) { if (req->rq_err) { req->rq_status = rc; - RETURN(1); + return 1; } else { req->rq_wait_ctx = 1; - RETURN(0); + return 0; } } @@ -1439,15 +1424,14 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) if (rc) { DEBUG_REQ(D_HA, req, "send failed (%d); expect timeout", rc); req->rq_net_err = 1; - RETURN(rc); + return rc; } - RETURN(0); + return 0; } static inline int ptlrpc_set_producer(struct ptlrpc_request_set *set) { int remaining, rc; - ENTRY; LASSERT(set->set_producer != NULL); @@ -1461,11 +1445,11 @@ static inline int ptlrpc_set_producer(struct ptlrpc_request_set *set) /* no more RPC to produce */ set->set_producer = NULL; set->set_producer_arg = NULL; - RETURN(0); + return 0; } } - RETURN((atomic_read(&set->set_remaining) - remaining)); + return (atomic_read(&set->set_remaining) - remaining); } /** @@ -1478,10 +1462,9 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) { struct list_head *tmp, *next; int force_timer_recalc = 0; - ENTRY; if (atomic_read(&set->set_remaining) == 0) - RETURN(1); + return 1; list_for_each_safe(tmp, next, &set->set_requests) { struct ptlrpc_request *req = @@ -1834,7 +1817,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) } /* If we hit an error, we want to recover promptly. */ - RETURN(atomic_read(&set->set_remaining) == 0 || force_timer_recalc); + return atomic_read(&set->set_remaining) == 0 || force_timer_recalc; } EXPORT_SYMBOL(ptlrpc_check_set); @@ -1847,7 +1830,6 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) { struct obd_import *imp = req->rq_import; int rc = 0; - ENTRY; spin_lock(&req->rq_lock); req->rq_timedout = 1; @@ -1873,14 +1855,14 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) if (imp == NULL) { DEBUG_REQ(D_HA, req, "NULL import: already cleaned up?"); - RETURN(1); + return 1; } atomic_inc(&imp->imp_timeouts); /* The DLM server doesn't want recovery run on its imports. */ if (imp->imp_dlm_fake) - RETURN(1); + return 1; /* If this request is for recovery or other primordial tasks, * then error it out here. */ @@ -1894,7 +1876,7 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) req->rq_status = -ETIMEDOUT; req->rq_err = 1; spin_unlock(&req->rq_lock); - RETURN(1); + return 1; } /* if a request can't be resent we can't wait for an answer after @@ -1906,7 +1888,7 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) ptlrpc_fail_import(imp, lustre_msg_get_conn_cnt(req->rq_reqmsg)); - RETURN(rc); + return rc; } /** @@ -1919,7 +1901,6 @@ int ptlrpc_expired_set(void *data) struct ptlrpc_request_set *set = data; struct list_head *tmp; time_t now = cfs_time_current_sec(); - ENTRY; LASSERT(set != NULL); @@ -1955,7 +1936,7 @@ int ptlrpc_expired_set(void *data) * sleep so we can recalculate the timeout, or enable interrupts * if everyone's timed out. */ - RETURN(1); + return 1; } EXPORT_SYMBOL(ptlrpc_expired_set); @@ -2006,7 +1987,6 @@ int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) int timeout = 0; struct ptlrpc_request *req; int deadline; - ENTRY; SIGNAL_MASK_ASSERT(); /* XXX BUG 1511 */ @@ -2045,7 +2025,7 @@ int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) else if (timeout == 0 || timeout > deadline - now) timeout = deadline - now; } - RETURN(timeout); + return timeout; } EXPORT_SYMBOL(ptlrpc_set_next_timeout); @@ -2061,7 +2041,6 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) struct ptlrpc_request *req; struct l_wait_info lwi; int rc, timeout; - ENTRY; if (set->set_producer) (void)ptlrpc_set_producer(set); @@ -2074,7 +2053,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) } if (list_empty(&set->set_requests)) - RETURN(0); + return 0; do { timeout = ptlrpc_set_next_timeout(set); @@ -2171,7 +2150,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) } } - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_set_wait); @@ -2185,9 +2164,7 @@ EXPORT_SYMBOL(ptlrpc_set_wait); */ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) { - ENTRY; if (request == NULL) { - EXIT; return; } @@ -2240,7 +2217,6 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) __ptlrpc_free_req_to_pool(request); else OBD_FREE(request, sizeof(*request)); - EXIT; } static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked); @@ -2263,15 +2239,14 @@ EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock); */ static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked) { - ENTRY; if (request == NULL) - RETURN(1); + return 1; if (request == LP_POISON || request->rq_reqmsg == LP_POISON) { CERROR("dereferencing freed request (bug 575)\n"); LBUG(); - RETURN(1); + return 1; } DEBUG_REQ(D_INFO, request, "refcount now %u", @@ -2279,10 +2254,10 @@ static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked) if (atomic_dec_and_test(&request->rq_refcount)) { __ptlrpc_free_req(request, locked); - RETURN(1); + return 1; } - RETURN(0); + return 0; } /** @@ -2332,7 +2307,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) * Nothing left to do. */ if (!ptlrpc_client_recv_or_unlink(request)) - RETURN(1); + return 1; LNetMDUnlink(request->rq_reply_md_h); @@ -2340,7 +2315,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) * Let's check it once again. */ if (!ptlrpc_client_recv_or_unlink(request)) - RETURN(1); + return 1; /* * Move to "Unregistering" phase as reply was not unlinked yet. @@ -2351,7 +2326,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) * Do not wait for unlink to finish. */ if (async) - RETURN(0); + return 0; /* * We have to l_wait_event() whatever the result, to give liblustre @@ -2372,7 +2347,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) &lwi); if (rc == 0) { ptlrpc_rqphase_move(request, request->rq_next_phase); - RETURN(1); + return 1; } LASSERT(rc == -ETIMEDOUT); @@ -2380,7 +2355,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) "rvcng=%d unlnk=%d", request->rq_receiving_reply, request->rq_must_unlink); } - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_unregister_reply); @@ -2397,7 +2372,6 @@ void ptlrpc_free_committed(struct obd_import *imp) struct list_head *tmp, *saved; struct ptlrpc_request *req; struct ptlrpc_request *last_req = NULL; /* temporary fire escape */ - ENTRY; LASSERT(imp != NULL); @@ -2408,7 +2382,6 @@ void ptlrpc_free_committed(struct obd_import *imp) imp->imp_generation == imp->imp_last_generation_checked) { CDEBUG(D_INFO, "%s: skip recheck: last_committed "LPU64"\n", imp->imp_obd->obd_name, imp->imp_peer_committed_transno); - EXIT; return; } CDEBUG(D_RPCTRACE, "%s: committing for last_committed "LPU64" gen %d\n", @@ -2456,16 +2429,10 @@ free_req: list_del_init(&req->rq_replay_list); __ptlrpc_req_finished(req, 1); } - - EXIT; - return; } void ptlrpc_cleanup_client(struct obd_import *imp) { - ENTRY; - EXIT; - return; } EXPORT_SYMBOL(ptlrpc_cleanup_client); @@ -2517,9 +2484,8 @@ EXPORT_SYMBOL(ptlrpc_restart_req); */ struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req) { - ENTRY; atomic_inc(&req->rq_refcount); - RETURN(req); + return req; } EXPORT_SYMBOL(ptlrpc_request_addref); @@ -2588,7 +2554,6 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req) { struct ptlrpc_request_set *set; int rc; - ENTRY; LASSERT(req->rq_set == NULL); LASSERT(!req->rq_receiving_reply); @@ -2596,7 +2561,7 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req) set = ptlrpc_prep_set(); if (set == NULL) { CERROR("Unable to allocate ptlrpc set."); - RETURN(-ENOMEM); + return -ENOMEM; } /* for distributed debugging */ @@ -2608,7 +2573,7 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_queue_wait); @@ -2629,7 +2594,6 @@ static int ptlrpc_replay_interpret(const struct lu_env *env, struct ptlrpc_replay_async_args *aa = data; struct obd_import *imp = req->rq_import; - ENTRY; atomic_dec(&imp->imp_replay_inflight); if (!ptlrpc_client_replied(req)) { @@ -2710,7 +2674,7 @@ static int ptlrpc_replay_interpret(const struct lu_env *env, /* this replay failed, so restart recovery */ ptlrpc_connect_import(imp); - RETURN(rc); + return rc; } /** @@ -2721,7 +2685,6 @@ static int ptlrpc_replay_interpret(const struct lu_env *env, int ptlrpc_replay_req(struct ptlrpc_request *req) { struct ptlrpc_replay_async_args *aa; - ENTRY; LASSERT(req->rq_import->imp_state == LUSTRE_IMP_REPLAY); @@ -2751,7 +2714,7 @@ int ptlrpc_replay_req(struct ptlrpc_request *req) ptlrpc_request_addref(req); /* ptlrpcd needs a ref */ ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_replay_req); @@ -2761,7 +2724,6 @@ EXPORT_SYMBOL(ptlrpc_replay_req); void ptlrpc_abort_inflight(struct obd_import *imp) { struct list_head *tmp, *n; - ENTRY; /* Make sure that no new requests get processed for this import. * ptlrpc_{queue,set}_wait must (and does) hold imp_lock while testing @@ -2809,8 +2771,6 @@ void ptlrpc_abort_inflight(struct obd_import *imp) ptlrpc_free_committed(imp); spin_unlock(&imp->imp_lock); - - EXIT; } EXPORT_SYMBOL(ptlrpc_abort_inflight); @@ -2969,18 +2929,17 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, { struct ptlrpc_request *req = NULL; struct ptlrpc_work_async_args *args; - ENTRY; might_sleep(); if (cb == NULL) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); /* copy some code from deprecated fakereq. */ OBD_ALLOC_PTR(req); if (req == NULL) { CERROR("ptlrpc: run out of memory!\n"); - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); } req->rq_send_state = LUSTRE_IMP_FULL; @@ -3009,7 +2968,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, args->cb = cb; args->cbdata = cbdata; - RETURN(req); + return req; } EXPORT_SYMBOL(ptlrpcd_alloc_work); diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index a0757f372be..17ca8420887 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -49,7 +49,6 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, struct obd_uuid *uuid) { struct ptlrpc_connection *conn, *conn2; - ENTRY; conn = cfs_hash_lookup(conn_hash, &peer); if (conn) @@ -57,7 +56,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, OBD_ALLOC_PTR(conn); if (!conn) - RETURN(NULL); + return NULL; conn->c_peer = peer; conn->c_self = self; @@ -80,7 +79,6 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, OBD_FREE_PTR(conn); conn = conn2; } - EXIT; out: CDEBUG(D_INFO, "conn=%p refcount %d to %s\n", conn, atomic_read(&conn->c_refcount), @@ -92,10 +90,9 @@ EXPORT_SYMBOL(ptlrpc_connection_get); int ptlrpc_connection_put(struct ptlrpc_connection *conn) { int rc = 0; - ENTRY; if (!conn) - RETURN(rc); + return rc; LASSERT(atomic_read(&conn->c_refcount) > 1); @@ -122,28 +119,24 @@ int ptlrpc_connection_put(struct ptlrpc_connection *conn) conn, atomic_read(&conn->c_refcount), libcfs_nid2str(conn->c_peer.nid)); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_connection_put); struct ptlrpc_connection * ptlrpc_connection_addref(struct ptlrpc_connection *conn) { - ENTRY; - atomic_inc(&conn->c_refcount); CDEBUG(D_INFO, "conn=%p refcount %d to %s\n", conn, atomic_read(&conn->c_refcount), libcfs_nid2str(conn->c_peer.nid)); - RETURN(conn); + return conn; } EXPORT_SYMBOL(ptlrpc_connection_addref); int ptlrpc_connection_init(void) { - ENTRY; - conn_hash = cfs_hash_create("CONN_HASH", HASH_CONN_CUR_BITS, HASH_CONN_MAX_BITS, @@ -152,16 +145,15 @@ int ptlrpc_connection_init(void) CFS_HASH_MAX_THETA, &conn_hash_ops, CFS_HASH_DEFAULT); if (!conn_hash) - RETURN(-ENOMEM); + return -ENOMEM; - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_connection_init); -void ptlrpc_connection_fini(void) { - ENTRY; +void ptlrpc_connection_fini(void) +{ cfs_hash_putref(conn_hash); - EXIT; } EXPORT_SYMBOL(ptlrpc_connection_fini); diff --git a/drivers/staging/lustre/lustre/ptlrpc/errno.c b/drivers/staging/lustre/lustre/ptlrpc/errno.c new file mode 100644 index 00000000000..1c100633396 --- /dev/null +++ b/drivers/staging/lustre/lustre/ptlrpc/errno.c @@ -0,0 +1,380 @@ +/* + * 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/gpl-2.0.txt + * + * GPL HEADER END + */ +/* + * Copyright (C) 2011 FUJITSU LIMITED. All rights reserved. + * + * Copyright (c) 2013, Intel Corporation. + */ + +#include <linux/libcfs/libcfs.h> +#include <lustre/lustre_errno.h> + +/* + * The two translation tables below must define a one-to-one mapping between + * host and network errnos. + * + * EWOULDBLOCK is equal to EAGAIN on all architectures except for parisc, which + * appears irrelevant. Thus, existing references to EWOULDBLOCK are fine. + * + * EDEADLOCK is equal to EDEADLK on x86 but not on sparc, at least. A sparc + * host has no context-free way to determine if a LUSTRE_EDEADLK represents an + * EDEADLK or an EDEADLOCK. Therefore, all existing references to EDEADLOCK + * that need to be transferred on wire have been replaced with EDEADLK. + */ +static int lustre_errno_hton_mapping[] = { + [EPERM] = LUSTRE_EPERM, + [ENOENT] = LUSTRE_ENOENT, + [ESRCH] = LUSTRE_ESRCH, + [EINTR] = LUSTRE_EINTR, + [EIO] = LUSTRE_EIO, + [ENXIO] = LUSTRE_ENXIO, + [E2BIG] = LUSTRE_E2BIG, + [ENOEXEC] = LUSTRE_ENOEXEC, + [EBADF] = LUSTRE_EBADF, + [ECHILD] = LUSTRE_ECHILD, + [EAGAIN] = LUSTRE_EAGAIN, + [ENOMEM] = LUSTRE_ENOMEM, + [EACCES] = LUSTRE_EACCES, + [EFAULT] = LUSTRE_EFAULT, + [ENOTBLK] = LUSTRE_ENOTBLK, + [EBUSY] = LUSTRE_EBUSY, + [EEXIST] = LUSTRE_EEXIST, + [EXDEV] = LUSTRE_EXDEV, + [ENODEV] = LUSTRE_ENODEV, + [ENOTDIR] = LUSTRE_ENOTDIR, + [EISDIR] = LUSTRE_EISDIR, + [EINVAL] = LUSTRE_EINVAL, + [ENFILE] = LUSTRE_ENFILE, + [EMFILE] = LUSTRE_EMFILE, + [ENOTTY] = LUSTRE_ENOTTY, + [ETXTBSY] = LUSTRE_ETXTBSY, + [EFBIG] = LUSTRE_EFBIG, + [ENOSPC] = LUSTRE_ENOSPC, + [ESPIPE] = LUSTRE_ESPIPE, + [EROFS] = LUSTRE_EROFS, + [EMLINK] = LUSTRE_EMLINK, + [EPIPE] = LUSTRE_EPIPE, + [EDOM] = LUSTRE_EDOM, + [ERANGE] = LUSTRE_ERANGE, + [EDEADLK] = LUSTRE_EDEADLK, + [ENAMETOOLONG] = LUSTRE_ENAMETOOLONG, + [ENOLCK] = LUSTRE_ENOLCK, + [ENOSYS] = LUSTRE_ENOSYS, + [ENOTEMPTY] = LUSTRE_ENOTEMPTY, + [ELOOP] = LUSTRE_ELOOP, + [ENOMSG] = LUSTRE_ENOMSG, + [EIDRM] = LUSTRE_EIDRM, + [ECHRNG] = LUSTRE_ECHRNG, + [EL2NSYNC] = LUSTRE_EL2NSYNC, + [EL3HLT] = LUSTRE_EL3HLT, + [EL3RST] = LUSTRE_EL3RST, + [ELNRNG] = LUSTRE_ELNRNG, + [EUNATCH] = LUSTRE_EUNATCH, + [ENOCSI] = LUSTRE_ENOCSI, + [EL2HLT] = LUSTRE_EL2HLT, + [EBADE] = LUSTRE_EBADE, + [EBADR] = LUSTRE_EBADR, + [EXFULL] = LUSTRE_EXFULL, + [ENOANO] = LUSTRE_ENOANO, + [EBADRQC] = LUSTRE_EBADRQC, + [EBADSLT] = LUSTRE_EBADSLT, + [EBFONT] = LUSTRE_EBFONT, + [ENOSTR] = LUSTRE_ENOSTR, + [ENODATA] = LUSTRE_ENODATA, + [ETIME] = LUSTRE_ETIME, + [ENOSR] = LUSTRE_ENOSR, + [ENONET] = LUSTRE_ENONET, + [ENOPKG] = LUSTRE_ENOPKG, + [EREMOTE] = LUSTRE_EREMOTE, + [ENOLINK] = LUSTRE_ENOLINK, + [EADV] = LUSTRE_EADV, + [ESRMNT] = LUSTRE_ESRMNT, + [ECOMM] = LUSTRE_ECOMM, + [EPROTO] = LUSTRE_EPROTO, + [EMULTIHOP] = LUSTRE_EMULTIHOP, + [EDOTDOT] = LUSTRE_EDOTDOT, + [EBADMSG] = LUSTRE_EBADMSG, + [EOVERFLOW] = LUSTRE_EOVERFLOW, + [ENOTUNIQ] = LUSTRE_ENOTUNIQ, + [EBADFD] = LUSTRE_EBADFD, + [EREMCHG] = LUSTRE_EREMCHG, + [ELIBACC] = LUSTRE_ELIBACC, + [ELIBBAD] = LUSTRE_ELIBBAD, + [ELIBSCN] = LUSTRE_ELIBSCN, + [ELIBMAX] = LUSTRE_ELIBMAX, + [ELIBEXEC] = LUSTRE_ELIBEXEC, + [EILSEQ] = LUSTRE_EILSEQ, + [ERESTART] = LUSTRE_ERESTART, + [ESTRPIPE] = LUSTRE_ESTRPIPE, + [EUSERS] = LUSTRE_EUSERS, + [ENOTSOCK] = LUSTRE_ENOTSOCK, + [EDESTADDRREQ] = LUSTRE_EDESTADDRREQ, + [EMSGSIZE] = LUSTRE_EMSGSIZE, + [EPROTOTYPE] = LUSTRE_EPROTOTYPE, + [ENOPROTOOPT] = LUSTRE_ENOPROTOOPT, + [EPROTONOSUPPORT] = LUSTRE_EPROTONOSUPPORT, + [ESOCKTNOSUPPORT] = LUSTRE_ESOCKTNOSUPPORT, + [EOPNOTSUPP] = LUSTRE_EOPNOTSUPP, + [EPFNOSUPPORT] = LUSTRE_EPFNOSUPPORT, + [EAFNOSUPPORT] = LUSTRE_EAFNOSUPPORT, + [EADDRINUSE] = LUSTRE_EADDRINUSE, + [EADDRNOTAVAIL] = LUSTRE_EADDRNOTAVAIL, + [ENETDOWN] = LUSTRE_ENETDOWN, + [ENETUNREACH] = LUSTRE_ENETUNREACH, + [ENETRESET] = LUSTRE_ENETRESET, + [ECONNABORTED] = LUSTRE_ECONNABORTED, + [ECONNRESET] = LUSTRE_ECONNRESET, + [ENOBUFS] = LUSTRE_ENOBUFS, + [EISCONN] = LUSTRE_EISCONN, + [ENOTCONN] = LUSTRE_ENOTCONN, + [ESHUTDOWN] = LUSTRE_ESHUTDOWN, + [ETOOMANYREFS] = LUSTRE_ETOOMANYREFS, + [ETIMEDOUT] = LUSTRE_ETIMEDOUT, + [ECONNREFUSED] = LUSTRE_ECONNREFUSED, + [EHOSTDOWN] = LUSTRE_EHOSTDOWN, + [EHOSTUNREACH] = LUSTRE_EHOSTUNREACH, + [EALREADY] = LUSTRE_EALREADY, + [EINPROGRESS] = LUSTRE_EINPROGRESS, + [ESTALE] = LUSTRE_ESTALE, + [EUCLEAN] = LUSTRE_EUCLEAN, + [ENOTNAM] = LUSTRE_ENOTNAM, + [ENAVAIL] = LUSTRE_ENAVAIL, + [EISNAM] = LUSTRE_EISNAM, + [EREMOTEIO] = LUSTRE_EREMOTEIO, + [EDQUOT] = LUSTRE_EDQUOT, + [ENOMEDIUM] = LUSTRE_ENOMEDIUM, + [EMEDIUMTYPE] = LUSTRE_EMEDIUMTYPE, + [ECANCELED] = LUSTRE_ECANCELED, + [ENOKEY] = LUSTRE_ENOKEY, + [EKEYEXPIRED] = LUSTRE_EKEYEXPIRED, + [EKEYREVOKED] = LUSTRE_EKEYREVOKED, + [EKEYREJECTED] = LUSTRE_EKEYREJECTED, + [EOWNERDEAD] = LUSTRE_EOWNERDEAD, + [ENOTRECOVERABLE] = LUSTRE_ENOTRECOVERABLE, + [ERESTARTSYS] = LUSTRE_ERESTARTSYS, + [ERESTARTNOINTR] = LUSTRE_ERESTARTNOINTR, + [ERESTARTNOHAND] = LUSTRE_ERESTARTNOHAND, + [ENOIOCTLCMD] = LUSTRE_ENOIOCTLCMD, + [ERESTART_RESTARTBLOCK] = LUSTRE_ERESTART_RESTARTBLOCK, + [EBADHANDLE] = LUSTRE_EBADHANDLE, + [ENOTSYNC] = LUSTRE_ENOTSYNC, + [EBADCOOKIE] = LUSTRE_EBADCOOKIE, + [ENOTSUPP] = LUSTRE_ENOTSUPP, + [ETOOSMALL] = LUSTRE_ETOOSMALL, + [ESERVERFAULT] = LUSTRE_ESERVERFAULT, + [EBADTYPE] = LUSTRE_EBADTYPE, + [EJUKEBOX] = LUSTRE_EJUKEBOX, + [EIOCBQUEUED] = LUSTRE_EIOCBQUEUED, +}; + +static int lustre_errno_ntoh_mapping[] = { + [LUSTRE_EPERM] = EPERM, + [LUSTRE_ENOENT] = ENOENT, + [LUSTRE_ESRCH] = ESRCH, + [LUSTRE_EINTR] = EINTR, + [LUSTRE_EIO] = EIO, + [LUSTRE_ENXIO] = ENXIO, + [LUSTRE_E2BIG] = E2BIG, + [LUSTRE_ENOEXEC] = ENOEXEC, + [LUSTRE_EBADF] = EBADF, + [LUSTRE_ECHILD] = ECHILD, + [LUSTRE_EAGAIN] = EAGAIN, + [LUSTRE_ENOMEM] = ENOMEM, + [LUSTRE_EACCES] = EACCES, + [LUSTRE_EFAULT] = EFAULT, + [LUSTRE_ENOTBLK] = ENOTBLK, + [LUSTRE_EBUSY] = EBUSY, + [LUSTRE_EEXIST] = EEXIST, + [LUSTRE_EXDEV] = EXDEV, + [LUSTRE_ENODEV] = ENODEV, + [LUSTRE_ENOTDIR] = ENOTDIR, + [LUSTRE_EISDIR] = EISDIR, + [LUSTRE_EINVAL] = EINVAL, + [LUSTRE_ENFILE] = ENFILE, + [LUSTRE_EMFILE] = EMFILE, + [LUSTRE_ENOTTY] = ENOTTY, + [LUSTRE_ETXTBSY] = ETXTBSY, + [LUSTRE_EFBIG] = EFBIG, + [LUSTRE_ENOSPC] = ENOSPC, + [LUSTRE_ESPIPE] = ESPIPE, + [LUSTRE_EROFS] = EROFS, + [LUSTRE_EMLINK] = EMLINK, + [LUSTRE_EPIPE] = EPIPE, + [LUSTRE_EDOM] = EDOM, + [LUSTRE_ERANGE] = ERANGE, + [LUSTRE_EDEADLK] = EDEADLK, + [LUSTRE_ENAMETOOLONG] = ENAMETOOLONG, + [LUSTRE_ENOLCK] = ENOLCK, + [LUSTRE_ENOSYS] = ENOSYS, + [LUSTRE_ENOTEMPTY] = ENOTEMPTY, + [LUSTRE_ELOOP] = ELOOP, + [LUSTRE_ENOMSG] = ENOMSG, + [LUSTRE_EIDRM] = EIDRM, + [LUSTRE_ECHRNG] = ECHRNG, + [LUSTRE_EL2NSYNC] = EL2NSYNC, + [LUSTRE_EL3HLT] = EL3HLT, + [LUSTRE_EL3RST] = EL3RST, + [LUSTRE_ELNRNG] = ELNRNG, + [LUSTRE_EUNATCH] = EUNATCH, + [LUSTRE_ENOCSI] = ENOCSI, + [LUSTRE_EL2HLT] = EL2HLT, + [LUSTRE_EBADE] = EBADE, + [LUSTRE_EBADR] = EBADR, + [LUSTRE_EXFULL] = EXFULL, + [LUSTRE_ENOANO] = ENOANO, + [LUSTRE_EBADRQC] = EBADRQC, + [LUSTRE_EBADSLT] = EBADSLT, + [LUSTRE_EBFONT] = EBFONT, + [LUSTRE_ENOSTR] = ENOSTR, + [LUSTRE_ENODATA] = ENODATA, + [LUSTRE_ETIME] = ETIME, + [LUSTRE_ENOSR] = ENOSR, + [LUSTRE_ENONET] = ENONET, + [LUSTRE_ENOPKG] = ENOPKG, + [LUSTRE_EREMOTE] = EREMOTE, + [LUSTRE_ENOLINK] = ENOLINK, + [LUSTRE_EADV] = EADV, + [LUSTRE_ESRMNT] = ESRMNT, + [LUSTRE_ECOMM] = ECOMM, + [LUSTRE_EPROTO] = EPROTO, + [LUSTRE_EMULTIHOP] = EMULTIHOP, + [LUSTRE_EDOTDOT] = EDOTDOT, + [LUSTRE_EBADMSG] = EBADMSG, + [LUSTRE_EOVERFLOW] = EOVERFLOW, + [LUSTRE_ENOTUNIQ] = ENOTUNIQ, + [LUSTRE_EBADFD] = EBADFD, + [LUSTRE_EREMCHG] = EREMCHG, + [LUSTRE_ELIBACC] = ELIBACC, + [LUSTRE_ELIBBAD] = ELIBBAD, + [LUSTRE_ELIBSCN] = ELIBSCN, + [LUSTRE_ELIBMAX] = ELIBMAX, + [LUSTRE_ELIBEXEC] = ELIBEXEC, + [LUSTRE_EILSEQ] = EILSEQ, + [LUSTRE_ERESTART] = ERESTART, + [LUSTRE_ESTRPIPE] = ESTRPIPE, + [LUSTRE_EUSERS] = EUSERS, + [LUSTRE_ENOTSOCK] = ENOTSOCK, + [LUSTRE_EDESTADDRREQ] = EDESTADDRREQ, + [LUSTRE_EMSGSIZE] = EMSGSIZE, + [LUSTRE_EPROTOTYPE] = EPROTOTYPE, + [LUSTRE_ENOPROTOOPT] = ENOPROTOOPT, + [LUSTRE_EPROTONOSUPPORT] = EPROTONOSUPPORT, + [LUSTRE_ESOCKTNOSUPPORT] = ESOCKTNOSUPPORT, + [LUSTRE_EOPNOTSUPP] = EOPNOTSUPP, + [LUSTRE_EPFNOSUPPORT] = EPFNOSUPPORT, + [LUSTRE_EAFNOSUPPORT] = EAFNOSUPPORT, + [LUSTRE_EADDRINUSE] = EADDRINUSE, + [LUSTRE_EADDRNOTAVAIL] = EADDRNOTAVAIL, + [LUSTRE_ENETDOWN] = ENETDOWN, + [LUSTRE_ENETUNREACH] = ENETUNREACH, + [LUSTRE_ENETRESET] = ENETRESET, + [LUSTRE_ECONNABORTED] = ECONNABORTED, + [LUSTRE_ECONNRESET] = ECONNRESET, + [LUSTRE_ENOBUFS] = ENOBUFS, + [LUSTRE_EISCONN] = EISCONN, + [LUSTRE_ENOTCONN] = ENOTCONN, + [LUSTRE_ESHUTDOWN] = ESHUTDOWN, + [LUSTRE_ETOOMANYREFS] = ETOOMANYREFS, + [LUSTRE_ETIMEDOUT] = ETIMEDOUT, + [LUSTRE_ECONNREFUSED] = ECONNREFUSED, + [LUSTRE_EHOSTDOWN] = EHOSTDOWN, + [LUSTRE_EHOSTUNREACH] = EHOSTUNREACH, + [LUSTRE_EALREADY] = EALREADY, + [LUSTRE_EINPROGRESS] = EINPROGRESS, + [LUSTRE_ESTALE] = ESTALE, + [LUSTRE_EUCLEAN] = EUCLEAN, + [LUSTRE_ENOTNAM] = ENOTNAM, + [LUSTRE_ENAVAIL] = ENAVAIL, + [LUSTRE_EISNAM] = EISNAM, + [LUSTRE_EREMOTEIO] = EREMOTEIO, + [LUSTRE_EDQUOT] = EDQUOT, + [LUSTRE_ENOMEDIUM] = ENOMEDIUM, + [LUSTRE_EMEDIUMTYPE] = EMEDIUMTYPE, + [LUSTRE_ECANCELED] = ECANCELED, + [LUSTRE_ENOKEY] = ENOKEY, + [LUSTRE_EKEYEXPIRED] = EKEYEXPIRED, + [LUSTRE_EKEYREVOKED] = EKEYREVOKED, + [LUSTRE_EKEYREJECTED] = EKEYREJECTED, + [LUSTRE_EOWNERDEAD] = EOWNERDEAD, + [LUSTRE_ENOTRECOVERABLE] = ENOTRECOVERABLE, + [LUSTRE_ERESTARTSYS] = ERESTARTSYS, + [LUSTRE_ERESTARTNOINTR] = ERESTARTNOINTR, + [LUSTRE_ERESTARTNOHAND] = ERESTARTNOHAND, + [LUSTRE_ENOIOCTLCMD] = ENOIOCTLCMD, + [LUSTRE_ERESTART_RESTARTBLOCK] = ERESTART_RESTARTBLOCK, + [LUSTRE_EBADHANDLE] = EBADHANDLE, + [LUSTRE_ENOTSYNC] = ENOTSYNC, + [LUSTRE_EBADCOOKIE] = EBADCOOKIE, + [LUSTRE_ENOTSUPP] = ENOTSUPP, + [LUSTRE_ETOOSMALL] = ETOOSMALL, + [LUSTRE_ESERVERFAULT] = ESERVERFAULT, + [LUSTRE_EBADTYPE] = EBADTYPE, + [LUSTRE_EJUKEBOX] = EJUKEBOX, + [LUSTRE_EIOCBQUEUED] = EIOCBQUEUED, +}; + +unsigned int lustre_errno_hton(unsigned int h) +{ + unsigned int n; + + if (h == 0) { + n = 0; + } else if (h < ARRAY_SIZE(lustre_errno_hton_mapping)) { + n = lustre_errno_hton_mapping[h]; + if (n == 0) + goto generic; + } else { +generic: + /* + * A generic errno is better than the unknown one that could + * mean anything to a different host. + */ + n = LUSTRE_EIO; + } + + return n; +} +EXPORT_SYMBOL(lustre_errno_hton); + +unsigned int lustre_errno_ntoh(unsigned int n) +{ + unsigned int h; + + if (n == 0) { + h = 0; + } else if (n < ARRAY_SIZE(lustre_errno_ntoh_mapping)) { + h = lustre_errno_ntoh_mapping[n]; + if (h == 0) + goto generic; + } else { +generic: + /* + * Similar to the situation in lustre_errno_hton(), an unknown + * network errno could coincide with anything. Hence, it is + * better to return a generic errno. + */ + h = EIO; + } + + return h; +} +EXPORT_SYMBOL(lustre_errno_ntoh); diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index 0264c102cb3..58d089c3fef 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -55,7 +55,6 @@ void request_out_callback(lnet_event_t *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; - ENTRY; LASSERT (ev->type == LNET_EVENT_SEND || ev->type == LNET_EVENT_UNLINK); @@ -79,8 +78,6 @@ void request_out_callback(lnet_event_t *ev) } ptlrpc_req_finished(req); - - EXIT; } /* @@ -90,7 +87,6 @@ void reply_in_callback(lnet_event_t *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; - ENTRY; DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status); @@ -166,7 +162,6 @@ out_wake: * since we don't have our own ref */ ptlrpc_client_wake_req(req); spin_unlock(&req->rq_lock); - EXIT; } /* @@ -177,7 +172,6 @@ void client_bulk_callback (lnet_event_t *ev) struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_bulk_desc *desc = cbid->cbid_arg; struct ptlrpc_request *req; - ENTRY; LASSERT ((desc->bd_type == BULK_PUT_SINK && ev->type == LNET_EVENT_PUT) || @@ -220,7 +214,6 @@ void client_bulk_callback (lnet_event_t *ev) ptlrpc_client_wake_req(desc->bd_req); spin_unlock(&desc->bd_lock); - EXIT; } /* @@ -289,7 +282,6 @@ void request_in_callback(lnet_event_t *ev) struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt; struct ptlrpc_service *service = svcpt->scp_service; struct ptlrpc_request *req; - ENTRY; LASSERT (ev->type == LNET_EVENT_PUT || ev->type == LNET_EVENT_UNLINK); @@ -378,7 +370,6 @@ void request_in_callback(lnet_event_t *ev) wake_up(&svcpt->scp_waitq); spin_unlock(&svcpt->scp_lock); - EXIT; } /* @@ -389,7 +380,6 @@ void reply_out_callback(lnet_event_t *ev) struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_reply_state *rs = cbid->cbid_arg; struct ptlrpc_service_part *svcpt = rs->rs_svcpt; - ENTRY; LASSERT (ev->type == LNET_EVENT_SEND || ev->type == LNET_EVENT_ACK || @@ -400,7 +390,6 @@ void reply_out_callback(lnet_event_t *ev) * net's ref on 'rs' */ LASSERT (ev->unlinked); ptlrpc_rs_decref(rs); - EXIT; return; } @@ -421,7 +410,6 @@ void reply_out_callback(lnet_event_t *ev) spin_unlock(&rs->rs_lock); spin_unlock(&svcpt->scp_rep_lock); } - EXIT; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_api.h b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_api.h index feac60482c9..0e9f6c472a3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_api.h +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_api.h @@ -100,7 +100,7 @@ struct subflavor_desc { /* Each mechanism is described by the following struct: */ struct gss_api_mech { struct list_head gm_list; - module_t *gm_owner; + struct module *gm_owner; char *gm_name; rawobj_t gm_oid; atomic_t gm_count; diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c index ed95bbba95c..b518d8a0aab 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c @@ -68,7 +68,6 @@ int gss_cli_ctx_wrap_bulk(struct ptlrpc_cli_ctx *ctx, __u32 maj; int offset; int rc; - ENTRY; LASSERT(req->rq_pack_bulk); LASSERT(req->rq_bulk_read || req->rq_bulk_write); @@ -104,7 +103,7 @@ int gss_cli_ctx_wrap_bulk(struct ptlrpc_cli_ctx *ctx, bsd->bsd_svc = SPTLRPC_FLVR_BULK_SVC(req->rq_flvr.sf_rpc); if (bsd->bsd_svc == SPTLRPC_BULK_SVC_NULL) - RETURN(0); + return 0; LASSERT(bsd->bsd_svc == SPTLRPC_BULK_SVC_INTG || bsd->bsd_svc == SPTLRPC_BULK_SVC_PRIV); @@ -132,18 +131,18 @@ int gss_cli_ctx_wrap_bulk(struct ptlrpc_cli_ctx *ctx, &token); if (maj != GSS_S_COMPLETE) { CWARN("failed to sign bulk data: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } } else { /* privacy mode */ if (desc->bd_iov_count == 0) - RETURN(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); + return rc; } token.data = bsd->bsd_data; @@ -153,12 +152,12 @@ int gss_cli_ctx_wrap_bulk(struct ptlrpc_cli_ctx *ctx, 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 -EACCES; } } } - RETURN(0); + return 0; } int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, @@ -171,7 +170,6 @@ int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, rawobj_t token; __u32 maj; int roff, voff; - ENTRY; LASSERT(req->rq_pack_bulk); LASSERT(req->rq_bulk_read || req->rq_bulk_write); @@ -220,7 +218,7 @@ int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, "(%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); + return -EPROTO; } LASSERT(bsdv->bsd_svc == SPTLRPC_BULK_SVC_NULL || @@ -235,7 +233,7 @@ int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, if (req->rq_bulk_write) { if (bsdv->bsd_flags & BSD_FL_ERR) { CERROR("server reported bulk i/o failure\n"); - RETURN(-EIO); + return -EIO; } if (bsdv->bsd_svc == SPTLRPC_BULK_SVC_PRIV) @@ -270,12 +268,12 @@ int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, &token); if (maj != GSS_S_COMPLETE) { CERROR("failed to verify bulk read: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } } else if (bsdv->bsd_svc == SPTLRPC_BULK_SVC_PRIV) { desc->bd_nob = bsdv->bsd_nob; if (desc->bd_nob == 0) - RETURN(0); + return 0; token.data = bsdv->bsd_data; token.len = lustre_msg_buflen(vmsg, voff) - @@ -286,14 +284,14 @@ int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, if (maj != GSS_S_COMPLETE) { CERROR("failed to decrypt bulk read: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } desc->bd_nob_transferred = desc->bd_nob; } } - RETURN(0); + return 0; } static int gss_prep_bulk(struct ptlrpc_bulk_desc *desc, @@ -318,21 +316,20 @@ int gss_cli_prep_bulk(struct ptlrpc_request *req, struct ptlrpc_bulk_desc *desc) { int rc; - ENTRY; 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); + 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); + return rc; } int gss_svc_prep_bulk(struct ptlrpc_request *req, @@ -341,7 +338,6 @@ int gss_svc_prep_bulk(struct ptlrpc_request *req, struct gss_svc_reqctx *grctx; struct ptlrpc_bulk_sec_desc *bsd; int rc; - ENTRY; LASSERT(req->rq_svc_ctx); LASSERT(req->rq_pack_bulk); @@ -355,14 +351,14 @@ int gss_svc_prep_bulk(struct ptlrpc_request *req, bsd = grctx->src_reqbsd; if (bsd->bsd_svc != SPTLRPC_BULK_SVC_PRIV) - RETURN(0); + 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); + return rc; } int gss_svc_unwrap_bulk(struct ptlrpc_request *req, @@ -372,7 +368,6 @@ int gss_svc_unwrap_bulk(struct ptlrpc_request *req, struct ptlrpc_bulk_sec_desc *bsdr, *bsdv; rawobj_t token; __u32 maj; - ENTRY; LASSERT(req->rq_svc_ctx); LASSERT(req->rq_pack_bulk); @@ -404,7 +399,7 @@ int gss_svc_unwrap_bulk(struct ptlrpc_request *req, if (maj != GSS_S_COMPLETE) { bsdv->bsd_flags |= BSD_FL_ERR; CERROR("failed to verify bulk signature: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } break; case SPTLRPC_BULK_SVC_PRIV: @@ -412,7 +407,7 @@ int gss_svc_unwrap_bulk(struct ptlrpc_request *req, 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); + return -EPROTO; } if (desc->bd_iov_count == 0) { @@ -428,12 +423,12 @@ int gss_svc_unwrap_bulk(struct ptlrpc_request *req, if (maj != GSS_S_COMPLETE) { bsdv->bsd_flags |= BSD_FL_ERR; CERROR("failed decrypt bulk data: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } break; } - RETURN(0); + return 0; } int gss_svc_wrap_bulk(struct ptlrpc_request *req, @@ -444,7 +439,6 @@ int gss_svc_wrap_bulk(struct ptlrpc_request *req, rawobj_t token; __u32 maj; int rc; - ENTRY; LASSERT(req->rq_svc_ctx); LASSERT(req->rq_pack_bulk); @@ -476,7 +470,7 @@ int gss_svc_wrap_bulk(struct ptlrpc_request *req, if (maj != GSS_S_COMPLETE) { bsdv->bsd_flags |= BSD_FL_ERR; CERROR("failed to sign bulk data: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } break; case SPTLRPC_BULK_SVC_PRIV: @@ -492,7 +486,7 @@ int gss_svc_wrap_bulk(struct ptlrpc_request *req, bsdv->bsd_flags |= BSD_FL_ERR; CERROR("bulk read: failed to allocate encryption " "pages: %d\n", rc); - RETURN(rc); + return rc; } token.data = bsdv->bsd_data; @@ -503,10 +497,10 @@ int gss_svc_wrap_bulk(struct ptlrpc_request *req, if (maj != GSS_S_COMPLETE) { bsdv->bsd_flags |= BSD_FL_ERR; CERROR("failed to encrypt bulk data: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } break; } - RETURN(0); + 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 index 142c789b1bc..55247af3910 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c @@ -243,41 +243,41 @@ int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) if (count != sizeof(param)) { CERROR("ioctl size %lu, expect %lu, please check lgss_keyring " "version\n", count, (unsigned long) sizeof(param)); - RETURN(-EINVAL); + return -EINVAL; } if (copy_from_user(¶m, buffer, sizeof(param))) { CERROR("failed copy data from lgssd\n"); - RETURN(-EFAULT); + return -EFAULT; } if (param.version != GSSD_INTERFACE_VERSION) { CERROR("gssd interface version %d (expect %d)\n", param.version, GSSD_INTERFACE_VERSION); - RETURN(-EINVAL); + return -EINVAL; } /* take name */ if (strncpy_from_user(obdname, param.uuid, sizeof(obdname)) <= 0) { CERROR("Invalid obdname pointer\n"); - RETURN(-EFAULT); + return -EFAULT; } obd = class_name2obd(obdname); if (!obd) { CERROR("no such obd %s\n", obdname); - RETURN(-EINVAL); + return -EINVAL; } if (unlikely(!obd->obd_set_up)) { CERROR("obd %s not setup\n", obdname); - RETURN(-EINVAL); + 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); + return -EINVAL; } if (strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) && @@ -285,7 +285,7 @@ int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) 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); + return -EINVAL; } spin_unlock(&obd->obd_dev_lock); @@ -293,7 +293,7 @@ int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) 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); + return -EINVAL; } imp = class_import_get(obd->u.cli.cl_import); up_read(&obd->u.cli.cl_sem); @@ -301,7 +301,7 @@ int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) if (imp->imp_deactive) { CERROR("import has been deactivated\n"); class_import_put(imp); - RETURN(-EINVAL); + return -EINVAL; } req = ptlrpc_request_alloc_pack(imp, &RQF_SEC_CTX, LUSTRE_OBD_VERSION, @@ -368,7 +368,7 @@ out_copy: class_import_put(imp); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } int gss_do_ctx_fini_rpc(struct gss_cli_ctx *gctx) @@ -378,7 +378,6 @@ int gss_do_ctx_fini_rpc(struct gss_cli_ctx *gctx) struct ptlrpc_request *req; struct ptlrpc_user_desc *pud; int rc; - ENTRY; LASSERT(atomic_read(&ctx->cc_refcount) > 0); @@ -386,7 +385,7 @@ int gss_do_ctx_fini_rpc(struct gss_cli_ctx *gctx) 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); + return 0; } might_sleep(); @@ -434,7 +433,7 @@ int gss_do_ctx_fini_rpc(struct gss_cli_ctx *gctx) out_ref: ptlrpc_req_finished(req); out: - RETURN(rc); + return rc; } int __init gss_init_cli_upcall(void) diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c index bb571ae5105..188dbbfbd2f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c @@ -524,7 +524,6 @@ void rvs_sec_install_root_ctx_kr(struct ptlrpc_sec *sec, struct gss_sec_keyring *gsec_kr = sec2gsec_keyring(sec); struct ptlrpc_cli_ctx *ctx; cfs_time_t now; - ENTRY; LASSERT(sec_is_reverse(sec)); @@ -569,11 +568,10 @@ struct ptlrpc_sec * gss_sec_create_kr(struct obd_import *imp, struct sptlrpc_flavor *sf) { struct gss_sec_keyring *gsec_kr; - ENTRY; OBD_ALLOC(gsec_kr, sizeof(*gsec_kr)); if (gsec_kr == NULL) - RETURN(NULL); + return NULL; INIT_HLIST_HEAD(&gsec_kr->gsk_clist); gsec_kr->gsk_root_ctx = NULL; @@ -592,11 +590,11 @@ struct ptlrpc_sec * gss_sec_create_kr(struct obd_import *imp, goto err_free; } - RETURN(&gsec_kr->gsk_base.gs_base); + return &gsec_kr->gsk_base.gs_base; err_free: OBD_FREE(gsec_kr, sizeof(*gsec_kr)); - RETURN(NULL); + return NULL; } static @@ -683,7 +681,6 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_kr(struct ptlrpc_sec *sec, char *coinfo; int coinfo_size; char *co_flags = ""; - ENTRY; LASSERT(imp != NULL); @@ -697,7 +694,7 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_kr(struct ptlrpc_sec *sec, * always succeed. */ if (ctx || sec_is_reverse(sec)) - RETURN(ctx); + return ctx; } LASSERT(create != 0); @@ -821,7 +818,7 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_kr(struct ptlrpc_sec *sec, out: if (is_root) mutex_unlock(&gsec_kr->gsk_root_uc_lock); - RETURN(ctx); + return ctx; } static @@ -891,7 +888,6 @@ void flush_spec_ctx_cache_kr(struct ptlrpc_sec *sec, struct hlist_head freelist = HLIST_HEAD_INIT; struct hlist_node *next; struct ptlrpc_cli_ctx *ctx; - ENTRY; gsec_kr = sec2gsec_keyring(sec); @@ -930,15 +926,12 @@ void flush_spec_ctx_cache_kr(struct ptlrpc_sec *sec, spin_unlock(&sec->ps_lock); dispose_ctx_list_kr(&freelist); - EXIT; } static int gss_sec_flush_ctx_cache_kr(struct ptlrpc_sec *sec, uid_t uid, int grace, int force) { - ENTRY; - 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), @@ -949,7 +942,7 @@ int gss_sec_flush_ctx_cache_kr(struct ptlrpc_sec *sec, else flush_spec_ctx_cache_kr(sec, uid, grace, force); - RETURN(0); + return 0; } static @@ -959,7 +952,6 @@ void gss_sec_gc_ctx_kr(struct ptlrpc_sec *sec) struct hlist_head freelist = HLIST_HEAD_INIT; struct hlist_node *next; struct ptlrpc_cli_ctx *ctx; - ENTRY; CWARN("running gc\n"); @@ -981,8 +973,6 @@ void gss_sec_gc_ctx_kr(struct ptlrpc_sec *sec) spin_unlock(&sec->ps_lock); dispose_ctx_list_kr(&freelist); - EXIT; - return; } static @@ -993,7 +983,6 @@ int gss_sec_display_kr(struct ptlrpc_sec *sec, struct seq_file *seq) struct ptlrpc_cli_ctx *ctx; struct gss_cli_ctx *gctx; time_t now = cfs_time_current_sec(); - ENTRY; spin_lock(&sec->ps_lock); hlist_for_each_entry_safe(ctx, next, @@ -1032,7 +1021,7 @@ int gss_sec_display_kr(struct ptlrpc_sec *sec, struct seq_file *seq) } spin_unlock(&sec->ps_lock); - RETURN(0); + return 0; } /**************************************** @@ -1148,16 +1137,15 @@ static int gss_kt_instantiate(struct key *key, const void *data, size_t datalen) { int rc; - ENTRY; if (data != NULL || datalen != 0) { CERROR("invalid: data %p, len %lu\n", data, (long)datalen); - RETURN(-EINVAL); + return -EINVAL; } if (key->payload.data != 0) { CERROR("key already have payload\n"); - RETURN(-EINVAL); + return -EINVAL; } /* link the key to session keyring, so following context negotiation @@ -1179,11 +1167,11 @@ int gss_kt_instantiate(struct key *key, const void *data, size_t datalen) CERROR("failed to link key %08x to keyring %08x: %d\n", key->serial, key_tgcred(current)->session_keyring->serial, rc); - RETURN(rc); + return rc; } CDEBUG(D_SEC, "key %p instantiated, ctx %p\n", key, key->payload.data); - RETURN(0); + return 0; } /* @@ -1198,11 +1186,10 @@ int gss_kt_update(struct key *key, const void *data, size_t datalen) rawobj_t tmpobj = RAWOBJ_EMPTY; __u32 datalen32 = (__u32) datalen; int rc; - ENTRY; if (data == NULL || datalen == 0) { CWARN("invalid: data %p, len %lu\n", data, (long)datalen); - RETURN(-EINVAL); + return -EINVAL; } /* if upcall finished negotiation too fast (mostly likely because @@ -1216,9 +1203,9 @@ int gss_kt_update(struct key *key, const void *data, size_t datalen) rc = key_validate(key); if (rc == 0) - RETURN(-EAGAIN); + return -EAGAIN; else - RETURN(rc); + return rc; } LASSERT(atomic_read(&ctx->cc_refcount) > 0); @@ -1229,7 +1216,7 @@ int gss_kt_update(struct key *key, const void *data, size_t datalen) /* don't proceed if already refreshed */ if (cli_ctx_is_refreshed(ctx)) { CWARN("ctx already done refresh\n"); - RETURN(0); + return 0; } sptlrpc_cli_ctx_get(ctx); @@ -1304,7 +1291,7 @@ out: /* let user space think it's a success */ sptlrpc_cli_ctx_put(ctx, 1); - RETURN(0); + return 0; } static @@ -1316,10 +1303,8 @@ int gss_kt_match(const struct key *key, const void *desc) static void gss_kt_destroy(struct key *key) { - ENTRY; LASSERT(key->payload.data == NULL); CDEBUG(D_SEC, "destroy key %p\n", key); - EXIT; } static diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c index 4b28931bbc9..c106a9e049a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c @@ -54,6 +54,7 @@ #include <linux/slab.h> #include <linux/crypto.h> #include <linux/mutex.h> +#include <linux/crypto.h> #include <obd.h> #include <obd_class.h> @@ -147,14 +148,14 @@ static const char * enctype2str(__u32 enctype) static int keyblock_init(struct krb5_keyblock *kb, char *alg_name, int alg_mode) { - kb->kb_tfm = ll_crypto_alloc_blkcipher(alg_name, alg_mode, 0); + 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 (ll_crypto_blkcipher_setkey(kb->kb_tfm, kb->kb_key.data, kb->kb_key.len)) { + 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; @@ -197,7 +198,7 @@ void keyblock_free(struct krb5_keyblock *kb) { rawobj_free(&kb->kb_key); if (kb->kb_tfm) - ll_crypto_free_blkcipher(kb->kb_tfm); + crypto_free_blkcipher(kb->kb_tfm); } static @@ -341,7 +342,7 @@ __u32 import_context_rfc1964(struct krb5_ctx *kctx, char *p, char *end) if (p != end) goto out_err; - CDEBUG(D_SEC, "succesfully imported rfc1964 context\n"); + CDEBUG(D_SEC, "successfully imported rfc1964 context\n"); return 0; out_err: return GSS_S_FAILURE; @@ -403,7 +404,7 @@ __u32 import_context_rfc4121(struct krb5_ctx *kctx, char *p, char *end) if (get_keyblock(&p, end, &kctx->kc_keyc, keysize)) goto out_err; - CDEBUG(D_SEC, "succesfully imported v2 context\n"); + CDEBUG(D_SEC, "successfully imported v2 context\n"); return 0; out_err: return GSS_S_FAILURE; @@ -494,7 +495,7 @@ __u32 gss_copy_reverse_context_kerberos(struct gss_ctx *gctx, goto out_err; gctx_new->internal_ctx_id = knew; - CDEBUG(D_SEC, "succesfully copied reverse context\n"); + CDEBUG(D_SEC, "successfully copied reverse context\n"); return GSS_S_COMPLETE; out_err: @@ -529,7 +530,7 @@ void buf_to_sg(struct scatterlist *sg, void *ptr, int len) } static -__u32 krb5_encrypt(struct ll_crypto_cipher *tfm, +__u32 krb5_encrypt(struct crypto_blkcipher *tfm, int decrypt, void * iv, void * in, @@ -546,27 +547,27 @@ __u32 krb5_encrypt(struct ll_crypto_cipher *tfm, desc.info = local_iv; desc.flags= 0; - if (length % ll_crypto_blkcipher_blocksize(tfm) != 0) { + if (length % crypto_blkcipher_blocksize(tfm) != 0) { CERROR("output length %d mismatch blocksize %d\n", - length, ll_crypto_blkcipher_blocksize(tfm)); + length, crypto_blkcipher_blocksize(tfm)); goto out; } - if (ll_crypto_blkcipher_ivsize(tfm) > 16) { - CERROR("iv size too large %d\n", ll_crypto_blkcipher_ivsize(tfm)); + 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, ll_crypto_blkcipher_ivsize(tfm)); + memcpy(local_iv, iv, crypto_blkcipher_ivsize(tfm)); memcpy(out, in, length); buf_to_sg(&sg, out, length); if (decrypt) - ret = ll_crypto_blkcipher_decrypt_iv(&desc, &sg, &sg, length); + ret = crypto_blkcipher_decrypt_iv(&desc, &sg, &sg, length); else - ret = ll_crypto_blkcipher_encrypt_iv(&desc, &sg, &sg, length); + ret = crypto_blkcipher_encrypt_iv(&desc, &sg, &sg, length); out: return(ret); @@ -574,7 +575,7 @@ out: static inline -int krb5_digest_hmac(struct ll_crypto_hash *tfm, +int krb5_digest_hmac(struct crypto_hash *tfm, rawobj_t *key, struct krb5_header *khdr, int msgcnt, rawobj_t *msgs, @@ -585,17 +586,17 @@ int krb5_digest_hmac(struct ll_crypto_hash *tfm, struct scatterlist sg[1]; int i; - ll_crypto_hash_setkey(tfm, key->data, key->len); + crypto_hash_setkey(tfm, key->data, key->len); desc.tfm = tfm; desc.flags= 0; - ll_crypto_hash_init(&desc); + 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); - ll_crypto_hash_update(&desc, sg, msgs[i].len); + crypto_hash_update(&desc, sg, msgs[i].len); } for (i = 0; i < iovcnt; i++) { @@ -604,20 +605,20 @@ int krb5_digest_hmac(struct ll_crypto_hash *tfm, sg_set_page(&sg[0], iovs[i].kiov_page, iovs[i].kiov_len, iovs[i].kiov_offset); - ll_crypto_hash_update(&desc, sg, iovs[i].kiov_len); + crypto_hash_update(&desc, sg, iovs[i].kiov_len); } if (khdr) { buf_to_sg(sg, (char *) khdr, sizeof(*khdr)); - ll_crypto_hash_update(&desc, sg, sizeof(*khdr)); + crypto_hash_update(&desc, sg, sizeof(*khdr)); } - return ll_crypto_hash_final(&desc, cksum->data); + return crypto_hash_final(&desc, cksum->data); } static inline -int krb5_digest_norm(struct ll_crypto_hash *tfm, +int krb5_digest_norm(struct crypto_hash *tfm, struct krb5_keyblock *kb, struct krb5_header *khdr, int msgcnt, rawobj_t *msgs, @@ -632,13 +633,13 @@ int krb5_digest_norm(struct ll_crypto_hash *tfm, desc.tfm = tfm; desc.flags= 0; - ll_crypto_hash_init(&desc); + 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); - ll_crypto_hash_update(&desc, sg, msgs[i].len); + crypto_hash_update(&desc, sg, msgs[i].len); } for (i = 0; i < iovcnt; i++) { @@ -647,15 +648,15 @@ int krb5_digest_norm(struct ll_crypto_hash *tfm, sg_set_page(&sg[0], iovs[i].kiov_page, iovs[i].kiov_len, iovs[i].kiov_offset); - ll_crypto_hash_update(&desc, sg, iovs[i].kiov_len); + crypto_hash_update(&desc, sg, iovs[i].kiov_len); } if (khdr) { buf_to_sg(sg, (char *) khdr, sizeof(*khdr)); - ll_crypto_hash_update(&desc, sg, sizeof(*khdr)); + crypto_hash_update(&desc, sg, sizeof(*khdr)); } - ll_crypto_hash_final(&desc, cksum->data); + crypto_hash_final(&desc, cksum->data); return krb5_encrypt(kb->kb_tfm, 0, NULL, cksum->data, cksum->data, cksum->len); @@ -674,7 +675,7 @@ __s32 krb5_make_checksum(__u32 enctype, rawobj_t *cksum) { struct krb5_enctype *ke = &enctypes[enctype]; - struct ll_crypto_hash *tfm; + struct crypto_hash *tfm; __u32 code = GSS_S_FAILURE; int rc; @@ -683,7 +684,7 @@ __s32 krb5_make_checksum(__u32 enctype, return GSS_S_FAILURE; } - cksum->len = ll_crypto_hash_digestsize(tfm); + cksum->len = crypto_hash_digestsize(tfm); OBD_ALLOC_LARGE(cksum->data, cksum->len); if (!cksum->data) { cksum->len = 0; @@ -700,7 +701,7 @@ __s32 krb5_make_checksum(__u32 enctype, if (rc == 0) code = GSS_S_COMPLETE; out_tfm: - ll_crypto_free_hash(tfm); + crypto_free_hash(tfm); return code; } @@ -878,7 +879,7 @@ int add_padding(rawobj_t *msg, int msg_buflen, int blocksize) } static -int krb5_encrypt_rawobjs(struct ll_crypto_cipher *tfm, +int krb5_encrypt_rawobjs(struct crypto_blkcipher *tfm, int mode_ecb, int inobj_cnt, rawobj_t *inobjs, @@ -890,7 +891,6 @@ int krb5_encrypt_rawobjs(struct ll_crypto_cipher *tfm, __u8 local_iv[16] = {0}, *buf; __u32 datalen = 0; int i, rc; - ENTRY; buf = outobj->data; desc.tfm = tfm; @@ -905,23 +905,23 @@ int krb5_encrypt_rawobjs(struct ll_crypto_cipher *tfm, if (mode_ecb) { if (enc) - rc = ll_crypto_blkcipher_encrypt( + rc = crypto_blkcipher_encrypt( &desc, &dst, &src, src.length); else - rc = ll_crypto_blkcipher_decrypt( + rc = crypto_blkcipher_decrypt( &desc, &dst, &src, src.length); } else { if (enc) - rc = ll_crypto_blkcipher_encrypt_iv( + rc = crypto_blkcipher_encrypt_iv( &desc, &dst, &src, src.length); else - rc = ll_crypto_blkcipher_decrypt_iv( + rc = crypto_blkcipher_decrypt_iv( &desc, &dst, &src, src.length); } if (rc) { CERROR("encrypt error %d\n", rc); - RETURN(rc); + return rc; } datalen += inobjs[i].len; @@ -929,14 +929,14 @@ int krb5_encrypt_rawobjs(struct ll_crypto_cipher *tfm, } outobj->len = datalen; - RETURN(0); + return 0; } /* * if adj_nob != 0, we adjust desc->bd_nob to the actual cipher text size. */ static -int krb5_encrypt_bulk(struct ll_crypto_cipher *tfm, +int krb5_encrypt_bulk(struct crypto_blkcipher *tfm, struct krb5_header *khdr, char *confounder, struct ptlrpc_bulk_desc *desc, @@ -951,7 +951,7 @@ int krb5_encrypt_bulk(struct ll_crypto_cipher *tfm, LASSERT(desc->bd_iov_count); LASSERT(desc->bd_enc_iov); - blocksize = ll_crypto_blkcipher_blocksize(tfm); + blocksize = crypto_blkcipher_blocksize(tfm); LASSERT(blocksize > 1); LASSERT(cipher->len == blocksize + sizeof(*khdr)); @@ -963,7 +963,7 @@ int krb5_encrypt_bulk(struct ll_crypto_cipher *tfm, buf_to_sg(&src, confounder, blocksize); buf_to_sg(&dst, cipher->data, blocksize); - rc = ll_crypto_blkcipher_encrypt_iv(&ciph_desc, &dst, &src, blocksize); + rc = crypto_blkcipher_encrypt_iv(&ciph_desc, &dst, &src, blocksize); if (rc) { CERROR("error to encrypt confounder: %d\n", rc); return rc; @@ -983,7 +983,7 @@ int krb5_encrypt_bulk(struct ll_crypto_cipher *tfm, desc->bd_enc_iov[i].kiov_offset = dst.offset; desc->bd_enc_iov[i].kiov_len = dst.length; - rc = ll_crypto_blkcipher_encrypt_iv(&ciph_desc, &dst, &src, + rc = crypto_blkcipher_encrypt_iv(&ciph_desc, &dst, &src, src.length); if (rc) { CERROR("error to encrypt page: %d\n", rc); @@ -995,7 +995,7 @@ int krb5_encrypt_bulk(struct ll_crypto_cipher *tfm, buf_to_sg(&src, khdr, sizeof(*khdr)); buf_to_sg(&dst, cipher->data + blocksize, sizeof(*khdr)); - rc = ll_crypto_blkcipher_encrypt_iv(&ciph_desc, + rc = crypto_blkcipher_encrypt_iv(&ciph_desc, &dst, &src, sizeof(*khdr)); if (rc) { CERROR("error to encrypt krb5 header: %d\n", rc); @@ -1025,7 +1025,7 @@ int krb5_encrypt_bulk(struct ll_crypto_cipher *tfm, * should have been done by prep_bulk(). */ static -int krb5_decrypt_bulk(struct ll_crypto_cipher *tfm, +int krb5_decrypt_bulk(struct crypto_blkcipher *tfm, struct krb5_header *khdr, struct ptlrpc_bulk_desc *desc, rawobj_t *cipher, @@ -1042,7 +1042,7 @@ int krb5_decrypt_bulk(struct ll_crypto_cipher *tfm, LASSERT(desc->bd_enc_iov); LASSERT(desc->bd_nob_transferred); - blocksize = ll_crypto_blkcipher_blocksize(tfm); + blocksize = crypto_blkcipher_blocksize(tfm); LASSERT(blocksize > 1); LASSERT(cipher->len == blocksize + sizeof(*khdr)); @@ -1059,7 +1059,7 @@ int krb5_decrypt_bulk(struct ll_crypto_cipher *tfm, buf_to_sg(&src, cipher->data, blocksize); buf_to_sg(&dst, plain->data, blocksize); - rc = ll_crypto_blkcipher_decrypt_iv(&ciph_desc, &dst, &src, blocksize); + rc = crypto_blkcipher_decrypt_iv(&ciph_desc, &dst, &src, blocksize); if (rc) { CERROR("error to decrypt confounder: %d\n", rc); return rc; @@ -1102,7 +1102,7 @@ int krb5_decrypt_bulk(struct ll_crypto_cipher *tfm, if (desc->bd_iov[i].kiov_len % blocksize == 0) sg_assign_page(&dst, desc->bd_iov[i].kiov_page); - rc = ll_crypto_blkcipher_decrypt_iv(&ciph_desc, &dst, &src, + rc = crypto_blkcipher_decrypt_iv(&ciph_desc, &dst, &src, src.length); if (rc) { CERROR("error to decrypt page: %d\n", rc); @@ -1142,7 +1142,7 @@ int krb5_decrypt_bulk(struct ll_crypto_cipher *tfm, buf_to_sg(&src, cipher->data + blocksize, sizeof(*khdr)); buf_to_sg(&dst, cipher->data + blocksize, sizeof(*khdr)); - rc = ll_crypto_blkcipher_decrypt_iv(&ciph_desc, + rc = crypto_blkcipher_decrypt_iv(&ciph_desc, &dst, &src, sizeof(*khdr)); if (rc) { CERROR("error to decrypt tail: %d\n", rc); @@ -1177,7 +1177,7 @@ __u32 gss_wrap_kerberos(struct gss_ctx *gctx, LASSERT(ke->ke_conf_size <= GSS_MAX_CIPHER_BLOCK); LASSERT(kctx->kc_keye.kb_tfm == NULL || ke->ke_conf_size >= - ll_crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm)); + crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm)); /* * final token format: @@ -1201,7 +1201,7 @@ __u32 gss_wrap_kerberos(struct gss_ctx *gctx, blocksize = 1; } else { LASSERT(kctx->kc_keye.kb_tfm); - blocksize = ll_crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); + blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); } LASSERT(blocksize <= ke->ke_conf_size); @@ -1248,7 +1248,7 @@ __u32 gss_wrap_kerberos(struct gss_ctx *gctx, if (kctx->kc_enctype == ENCTYPE_ARCFOUR_HMAC) { rawobj_t arc4_keye; - struct ll_crypto_cipher *arc4_tfm; + struct crypto_blkcipher *arc4_tfm; if (krb5_make_checksum(ENCTYPE_ARCFOUR_HMAC, &kctx->kc_keyi, NULL, 1, &cksum, 0, NULL, &arc4_keye)) { @@ -1256,13 +1256,13 @@ __u32 gss_wrap_kerberos(struct gss_ctx *gctx, GOTO(arc4_out, rc = -EACCES); } - arc4_tfm = ll_crypto_alloc_blkcipher("ecb(arc4)", 0, 0); + 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 (ll_crypto_blkcipher_setkey(arc4_tfm, arc4_keye.data, + if (crypto_blkcipher_setkey(arc4_tfm, arc4_keye.data, arc4_keye.len)) { CERROR("failed to set arc4 key, len %d\n", arc4_keye.len); @@ -1272,7 +1272,7 @@ __u32 gss_wrap_kerberos(struct gss_ctx *gctx, rc = krb5_encrypt_rawobjs(arc4_tfm, 1, 3, data_desc, &cipher, 1); arc4_out_tfm: - ll_crypto_free_blkcipher(arc4_tfm); + crypto_free_blkcipher(arc4_tfm); arc4_out_key: rawobj_free(&arc4_keye); arc4_out: @@ -1310,7 +1310,7 @@ __u32 gss_prep_bulk_kerberos(struct gss_ctx *gctx, LASSERT(desc->bd_enc_iov); LASSERT(kctx->kc_keye.kb_tfm); - blocksize = ll_crypto_blkcipher_blocksize(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); @@ -1371,7 +1371,7 @@ __u32 gss_wrap_bulk_kerberos(struct gss_ctx *gctx, blocksize = 1; } else { LASSERT(kctx->kc_keye.kb_tfm); - blocksize = ll_crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); + blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); } /* @@ -1481,7 +1481,7 @@ __u32 gss_unwrap_kerberos(struct gss_ctx *gctx, blocksize = 1; } else { LASSERT(kctx->kc_keye.kb_tfm); - blocksize = ll_crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); + blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); } /* expected token layout: @@ -1521,7 +1521,7 @@ __u32 gss_unwrap_kerberos(struct gss_ctx *gctx, if (kctx->kc_enctype == ENCTYPE_ARCFOUR_HMAC) { rawobj_t arc4_keye; - struct ll_crypto_cipher *arc4_tfm; + struct crypto_blkcipher *arc4_tfm; cksum.data = token->data + token->len - ke->ke_hash_size; cksum.len = ke->ke_hash_size; @@ -1532,13 +1532,13 @@ __u32 gss_unwrap_kerberos(struct gss_ctx *gctx, GOTO(arc4_out, rc = -EACCES); } - arc4_tfm = ll_crypto_alloc_blkcipher("ecb(arc4)", 0, 0); + 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 (ll_crypto_blkcipher_setkey(arc4_tfm, + if (crypto_blkcipher_setkey(arc4_tfm, arc4_keye.data, arc4_keye.len)) { CERROR("failed to set arc4 key, len %d\n", arc4_keye.len); @@ -1548,7 +1548,7 @@ __u32 gss_unwrap_kerberos(struct gss_ctx *gctx, rc = krb5_encrypt_rawobjs(arc4_tfm, 1, 1, &cipher_in, &plain_out, 0); arc4_out_tfm: - ll_crypto_free_blkcipher(arc4_tfm); + crypto_free_blkcipher(arc4_tfm); arc4_out_key: rawobj_free(&arc4_keye); arc4_out: @@ -1647,7 +1647,7 @@ __u32 gss_unwrap_bulk_kerberos(struct gss_ctx *gctx, LBUG(); } else { LASSERT(kctx->kc_keye.kb_tfm); - blocksize = ll_crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); + blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); } LASSERT(sizeof(*khdr) >= blocksize && sizeof(*khdr) % blocksize == 0); diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c index 3df7257b7fa..c624518c181 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c @@ -262,7 +262,6 @@ void gss_sec_ctx_replace_pf(struct gss_sec *gsec, struct hlist_node *next; HLIST_HEAD(freelist); unsigned int hash; - ENTRY; gsec_pf = container_of(gsec, struct gss_sec_pipefs, gsp_base); @@ -287,7 +286,6 @@ void gss_sec_ctx_replace_pf(struct gss_sec *gsec, spin_unlock(&gsec->gs_base.ps_lock); ctx_list_destroy_pf(&freelist); - EXIT; } static @@ -297,23 +295,22 @@ int gss_install_rvs_cli_ctx_pf(struct gss_sec *gsec, struct vfs_cred vcred; struct ptlrpc_cli_ctx *cli_ctx; int rc; - ENTRY; vcred.vc_uid = 0; vcred.vc_gid = 0; cli_ctx = ctx_create_pf(&gsec->gs_base, &vcred); if (!cli_ctx) - RETURN(-ENOMEM); + 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); + return rc; } gss_sec_ctx_replace_pf(gsec, cli_ctx); - RETURN(0); + return 0; } static @@ -324,7 +321,6 @@ void gss_ctx_cache_gc_pf(struct gss_sec_pipefs *gsec_pf, struct ptlrpc_cli_ctx *ctx; struct hlist_node *next; int i; - ENTRY; sec = &gsec_pf->gsp_base.gs_base; @@ -337,7 +333,6 @@ void gss_ctx_cache_gc_pf(struct gss_sec_pipefs *gsec_pf, } sec->ps_gc_next = cfs_time_current_sec() + sec->ps_gc_interval; - EXIT; } static @@ -347,7 +342,6 @@ struct ptlrpc_sec* gss_sec_create_pf(struct obd_import *imp, { struct gss_sec_pipefs *gsec_pf; int alloc_size, hash_size, i; - ENTRY; #define GSS_SEC_PIPEFS_CTX_HASH_SIZE (32) @@ -362,7 +356,7 @@ struct ptlrpc_sec* gss_sec_create_pf(struct obd_import *imp, OBD_ALLOC(gsec_pf, alloc_size); if (!gsec_pf) - RETURN(NULL); + return NULL; gsec_pf->gsp_chash_size = hash_size; for (i = 0; i < hash_size; i++) @@ -380,13 +374,13 @@ struct ptlrpc_sec* gss_sec_create_pf(struct obd_import *imp, goto err_destroy; } - RETURN(&gsec_pf->gsp_base.gs_base); + 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); + return NULL; } static @@ -423,7 +417,6 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_pf(struct ptlrpc_sec *sec, struct hlist_node *next; HLIST_HEAD(freelist); unsigned int hash, gc = 0, found = 0; - ENTRY; might_sleep(); @@ -473,7 +466,7 @@ retry: /* don't allocate for reverse sec */ if (sec_is_reverse(sec)) { spin_unlock(&sec->ps_lock); - RETURN(NULL); + return NULL; } if (new) { @@ -504,7 +497,7 @@ retry: } ctx_list_destroy_pf(&freelist); - RETURN(ctx); + return ctx; } static @@ -545,7 +538,6 @@ int gss_sec_flush_ctx_cache_pf(struct ptlrpc_sec *sec, struct hlist_node *next; HLIST_HEAD(freelist); int i, busy = 0; - ENTRY; might_sleep_if(grace); @@ -584,7 +576,7 @@ int gss_sec_flush_ctx_cache_pf(struct ptlrpc_sec *sec, spin_unlock(&sec->ps_lock); ctx_list_destroy_pf(&freelist); - RETURN(busy); + return busy; } /**************************************** @@ -704,11 +696,9 @@ void upcall_msg_delist(struct gss_upcall_msg *msg) static void gss_release_msg(struct gss_upcall_msg *gmsg) { - ENTRY; LASSERT(atomic_read(&gmsg->gum_refcount) > 0); if (!atomic_dec_and_test(&gmsg->gum_refcount)) { - EXIT; return; } @@ -721,7 +711,6 @@ void gss_release_msg(struct gss_upcall_msg *gmsg) LASSERT(list_empty(&gmsg->gum_list)); LASSERT(list_empty(&gmsg->gum_base.list)); OBD_FREE_PTR(gmsg); - EXIT; } static @@ -809,19 +798,18 @@ ssize_t gss_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, char *data = (char *)msg->data + msg->copied; ssize_t mlen = msg->len; ssize_t left; - ENTRY; if (mlen > buflen) mlen = buflen; left = copy_to_user(dst, data, mlen); if (left < 0) { msg->errno = left; - RETURN(left); + return left; } mlen -= left; msg->copied += mlen; msg->errno = 0; - RETURN(mlen); + return mlen; } static @@ -835,14 +823,13 @@ ssize_t gss_pipe_downcall(struct file *filp, const char *src, size_t mlen) int datalen; int timeout, rc; __u32 mechidx, seq, gss_err; - ENTRY; mechidx = (__u32) (long) rpci->private; LASSERT(mechidx < MECH_MAX); OBD_ALLOC(buf, mlen); if (!buf) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(buf, src, mlen)) { CERROR("failed copy user space data\n"); @@ -940,7 +927,7 @@ out_free: * hack pipefs: always return asked length unless all following * downcalls might be messed up. */ rc = mlen; - RETURN(rc); + return rc; } static @@ -949,13 +936,11 @@ 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; - ENTRY; LASSERT(list_empty(&msg->list)); /* normally errno is >= 0 */ if (msg->errno >= 0) { - EXIT; return; } @@ -980,7 +965,6 @@ void gss_pipe_destroy_msg(struct rpc_pipe_msg *msg) } gss_msg_fail_ctx(gmsg); gss_release_msg(gmsg); - EXIT; } static @@ -988,7 +972,6 @@ void gss_pipe_release(struct inode *inode) { struct rpc_inode *rpci = RPC_I(inode); __u32 idx; - ENTRY; idx = (__u32) (long) rpci->private; LASSERT(idx < MECH_MAX); @@ -1020,7 +1003,6 @@ void gss_pipe_release(struct inode *inode) upcall_list_lock(idx); } upcall_list_unlock(idx); - EXIT; } static struct rpc_pipe_ops gss_upcall_ops = { @@ -1041,7 +1023,6 @@ int gss_ctx_refresh_pf(struct ptlrpc_cli_ctx *ctx) struct gss_sec *gsec; struct gss_upcall_msg *gmsg; int rc = 0; - ENTRY; might_sleep(); @@ -1052,14 +1033,14 @@ int gss_ctx_refresh_pf(struct ptlrpc_cli_ctx *ctx) imp = ctx->cc_sec->ps_import; if (!imp->imp_connection) { CERROR("import has no connection set\n"); - RETURN(-EINVAL); + return -EINVAL; } gsec = container_of(ctx->cc_sec, struct gss_sec, gs_base); OBD_ALLOC_PTR(gmsg); if (!gmsg) - RETURN(-ENOMEM); + return -ENOMEM; /* initialize pipefs base msg */ INIT_LIST_HEAD(&gmsg->gum_base.list); @@ -1107,10 +1088,10 @@ int gss_ctx_refresh_pf(struct ptlrpc_cli_ctx *ctx) goto err_free; } - RETURN(0); + return 0; err_free: OBD_FREE_PTR(gmsg); - RETURN(rc); + return rc; } static diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_rawobj.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_rawobj.c index 474ecf80530..fb298aef66e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_rawobj.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_rawobj.c @@ -65,7 +65,7 @@ int rawobj_alloc(rawobj_t *obj, char *buf, int len) OBD_ALLOC_LARGE(obj->data, len); if (!obj->data) { obj->len = 0; - RETURN(-ENOMEM); + return -ENOMEM; } memcpy(obj->data, buf, len); } else diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c index 31b50ea19c2..5b5365b4629 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c @@ -259,8 +259,6 @@ static int rsi_parse(struct cache_detail *cd, char *mesg, int mlen) struct rsi rsii, *rsip = NULL; time_t expiry; int status = -EINVAL; - ENTRY; - memset(&rsii, 0, sizeof(rsii)); @@ -341,7 +339,7 @@ out: if (status) CERROR("rsi parse error %d\n", status); - RETURN(status); + return status; } static struct cache_detail rsi_cache = { @@ -662,7 +660,6 @@ static void rsc_flush(rsc_entry_match *match, long data) struct cache_head **ch; struct rsc *rscp; int n; - ENTRY; write_lock(&rsc_cache.hash_lock); for (n = 0; n < RSC_HASHMAX; n++) { @@ -684,7 +681,6 @@ static void rsc_flush(rsc_entry_match *match, long data) } } write_unlock(&rsc_cache.hash_lock); - EXIT; } static int match_uid(struct rsc *rscp, long uid) @@ -744,7 +740,6 @@ int gss_svc_upcall_install_rvs_ctx(struct obd_import *imp, unsigned long ctx_expiry; __u32 major; int rc; - ENTRY; memset(&rsci, 0, sizeof(rsci)); @@ -792,7 +787,7 @@ out: if (rc) CERROR("create reverse svc ctx: idx "LPX64", rc %d\n", gsec->gs_rvs_hdl, rc); - RETURN(rc); + return rc; } int gss_svc_upcall_expire_rvs_ctx(rawobj_t *handle) @@ -855,7 +850,6 @@ int gss_svc_upcall_handle_init(struct ptlrpc_request *req, struct gss_rep_header *rephdr; int first_check = 1; int rc = SECSVC_DROP; - ENTRY; memset(&rsikey, 0, sizeof(rsikey)); rsikey.lustre_svc = lustre_svc; @@ -1016,7 +1010,7 @@ out: COMPAT_RSC_PUT(&rsci->h, &rsc_cache); } - RETURN(rc); + return rc; } struct gss_svc_ctx *gss_svc_upcall_get_ctx(struct ptlrpc_request *req, diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/lproc_gss.c b/drivers/staging/lustre/lustre/ptlrpc/gss/lproc_gss.c index 340400089a5..de100a14ab5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/lproc_gss.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/lproc_gss.c @@ -199,15 +199,17 @@ int gss_init_lproc(void) 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 = PTR_ERR(gss_proc_root)); + 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 = PTR_ERR(gss_proc_root)); + GOTO(err_out, rc); } return 0; diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c index ebca858ca18..b42ddda9ee2 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c @@ -280,11 +280,10 @@ __u32 gss_unseal_msg(struct gss_ctx *mechctx, __u8 *clear_buf; int clear_buflen; __u32 major; - ENTRY; if (msgbuf->lm_bufcount != 2) { CERROR("invalid bufcount %d\n", msgbuf->lm_bufcount); - RETURN(GSS_S_FAILURE); + return GSS_S_FAILURE; } /* allocate a temporary clear text buffer, same sized as token, @@ -292,7 +291,7 @@ __u32 gss_unseal_msg(struct gss_ctx *mechctx, clear_buflen = lustre_msg_buflen(msgbuf, 1); OBD_ALLOC_LARGE(clear_buf, clear_buflen); if (!clear_buf) - RETURN(GSS_S_FAILURE); + return GSS_S_FAILURE; /* buffer objects */ hdrobj.len = lustre_msg_buflen(msgbuf, 0); @@ -317,7 +316,7 @@ __u32 gss_unseal_msg(struct gss_ctx *mechctx, major = GSS_S_COMPLETE; out_free: OBD_FREE_LARGE(clear_buf, clear_buflen); - RETURN(major); + return major; } /******************************************** @@ -646,7 +645,6 @@ int gss_cli_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct gss_cli_ctx *gctx = ctx2gctx(ctx); __u32 flags = 0, seq, svc; int rc; - ENTRY; LASSERT(req->rq_reqbuf); LASSERT(req->rq_reqbuf->lm_bufcount >= 2); @@ -654,7 +652,7 @@ int gss_cli_ctx_sign(struct ptlrpc_cli_ctx *ctx, /* nothing to do for context negotiation RPCs */ if (req->rq_ctx_init) - RETURN(0); + return 0; svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc); if (req->rq_pack_bulk) @@ -670,7 +668,7 @@ redo: flags, gctx->gc_proc, seq, svc, &gctx->gc_handle); if (rc < 0) - RETURN(rc); + 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 @@ -689,7 +687,7 @@ redo: } req->rq_reqdata_len = rc; - RETURN(0); + return 0; } static @@ -765,7 +763,6 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct lustre_msg *msg = req->rq_repdata; __u32 major; int pack_bulk, swabbed, rc = 0; - ENTRY; LASSERT(req->rq_cli_ctx == ctx); LASSERT(msg); @@ -777,12 +774,12 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, 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); + return 0; } if (msg->lm_bufcount < 2 || msg->lm_bufcount > 4) { CERROR("unexpected bufcount %u\n", msg->lm_bufcount); - RETURN(-EPROTO); + return -EPROTO; } swabbed = ptlrpc_rep_need_swab(req); @@ -790,7 +787,7 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, ghdr = gss_swab_header(msg, 0, swabbed); if (ghdr == NULL) { CERROR("can't decode gss header\n"); - RETURN(-EPROTO); + return -EPROTO; } /* sanity checks */ @@ -800,7 +797,7 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, if (ghdr->gh_version != reqhdr->gh_version) { CERROR("gss version %u mismatch, expect %u\n", ghdr->gh_version, reqhdr->gh_version); - RETURN(-EPROTO); + return -EPROTO; } switch (ghdr->gh_proc) { @@ -810,19 +807,19 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, 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); + return -EPROTO; } if (ghdr->gh_seq != reqhdr->gh_seq) { CERROR("seqnum %u mismatch, expect %u\n", ghdr->gh_seq, reqhdr->gh_seq); - RETURN(-EPROTO); + return -EPROTO; } if (ghdr->gh_svc != reqhdr->gh_svc) { CERROR("svc %u mismatch, expect %u\n", ghdr->gh_svc, reqhdr->gh_svc); - RETURN(-EPROTO); + return -EPROTO; } if (swabbed) @@ -831,7 +828,7 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, 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); + return -EPERM; } if (req->rq_early && reqhdr->gh_svc == SPTLRPC_SVC_NULL) { @@ -843,7 +840,7 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, if (cksum != msg->lm_cksum) { CWARN("early reply checksum mismatch: " "%08x != %08x\n", cksum, msg->lm_cksum); - RETURN(-EPROTO); + return -EPROTO; } } @@ -852,13 +849,13 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, if (msg->lm_bufcount < 3) { CERROR("Invalid reply bufcount %u\n", msg->lm_bufcount); - RETURN(-EPROTO); + return -EPROTO; } rc = bulk_sec_desc_unpack(msg, 2, swabbed); if (rc) { CERROR("unpack bulk desc: %d\n", rc); - RETURN(rc); + return rc; } } @@ -878,7 +875,7 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, rc = -EPROTO; } - RETURN(rc); + return rc; } int gss_cli_ctx_seal(struct ptlrpc_cli_ctx *ctx, @@ -889,7 +886,6 @@ int gss_cli_ctx_seal(struct ptlrpc_cli_ctx *ctx, struct gss_header *ghdr; __u32 buflens[2], major; int wiresize, rc; - ENTRY; LASSERT(req->rq_clrbuf); LASSERT(req->rq_cli_ctx == ctx); @@ -915,7 +911,7 @@ int gss_cli_ctx_seal(struct ptlrpc_cli_ctx *ctx, } else { OBD_ALLOC_LARGE(req->rq_reqbuf, wiresize); if (!req->rq_reqbuf) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_reqbuf_len = wiresize; } @@ -969,7 +965,7 @@ redo: /* now set the final wire data length */ req->rq_reqdata_len = lustre_shrink_msg(req->rq_reqbuf, 1, token.len,0); - RETURN(0); + return 0; err_free: if (!req->rq_pool) { @@ -977,7 +973,7 @@ err_free: req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } - RETURN(rc); + return rc; } int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, @@ -988,7 +984,6 @@ int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, struct lustre_msg *msg = req->rq_repdata; int msglen, pack_bulk, swabbed, rc; __u32 major; - ENTRY; LASSERT(req->rq_cli_ctx == ctx); LASSERT(req->rq_ctx_init == 0); @@ -1000,14 +995,14 @@ int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, ghdr = gss_swab_header(msg, 0, swabbed); if (ghdr == NULL) { CERROR("can't decode gss header\n"); - RETURN(-EPROTO); + 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); + return -EPROTO; } switch (ghdr->gh_proc) { @@ -1017,7 +1012,7 @@ int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, 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); + return -EPROTO; } if (swabbed) @@ -1038,25 +1033,25 @@ int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, swabbed = __lustre_unpack_msg(msg, msglen); if (swabbed < 0) { CERROR("Failed to unpack after decryption\n"); - RETURN(-EPROTO); + return -EPROTO; } if (msg->lm_bufcount < 1) { CERROR("Invalid reply buffer: empty\n"); - RETURN(-EPROTO); + return -EPROTO; } if (pack_bulk) { if (msg->lm_bufcount < 2) { CERROR("bufcount %u: missing bulk sec desc\n", msg->lm_bufcount); - RETURN(-EPROTO); + return -EPROTO; } /* bulk checksum is the last segment */ if (bulk_sec_desc_unpack(msg, msg->lm_bufcount - 1, swabbed)) - RETURN(-EPROTO); + return -EPROTO; } req->rq_repmsg = lustre_msg_buf(msg, 0, 0); @@ -1077,7 +1072,7 @@ int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, rc = -EPERM; } - RETURN(rc); + return rc; } /********************************************* @@ -1148,7 +1143,6 @@ int gss_sec_create_common(struct gss_sec *gsec, void gss_sec_destroy_common(struct gss_sec *gsec) { struct ptlrpc_sec *sec = &gsec->gs_base; - ENTRY; LASSERT(sec->ps_import); LASSERT(atomic_read(&sec->ps_refcount) == 0); @@ -1163,8 +1157,6 @@ void gss_sec_destroy_common(struct gss_sec *gsec) if (SPTLRPC_FLVR_BULK_SVC(sec->ps_flvr.sf_rpc) == SPTLRPC_BULK_SVC_PRIV) sptlrpc_enc_pool_del_user(); - - EXIT; } void gss_sec_kill(struct ptlrpc_sec *sec) @@ -1260,7 +1252,6 @@ int gss_alloc_reqbuf_intg(struct ptlrpc_sec *sec, int bufsize, txtsize; int bufcnt = 2; __u32 buflens[5]; - ENTRY; /* * on-wire data layout: @@ -1312,7 +1303,7 @@ int gss_alloc_reqbuf_intg(struct ptlrpc_sec *sec, OBD_ALLOC_LARGE(req->rq_reqbuf, bufsize); if (!req->rq_reqbuf) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_reqbuf_len = bufsize; } else { @@ -1331,7 +1322,7 @@ int gss_alloc_reqbuf_intg(struct ptlrpc_sec *sec, if (req->rq_pack_udesc) sptlrpc_pack_user_desc(req->rq_reqbuf, 2); - RETURN(0); + return 0; } static @@ -1342,7 +1333,6 @@ int gss_alloc_reqbuf_priv(struct ptlrpc_sec *sec, __u32 ibuflens[3], wbuflens[2]; int ibufcnt; int clearsize, wiresize; - ENTRY; LASSERT(req->rq_clrbuf == NULL); LASSERT(req->rq_clrbuf_len == 0); @@ -1399,7 +1389,7 @@ int gss_alloc_reqbuf_priv(struct ptlrpc_sec *sec, OBD_ALLOC_LARGE(req->rq_clrbuf, clearsize); if (!req->rq_clrbuf) - RETURN(-ENOMEM); + return -ENOMEM; } req->rq_clrbuf_len = clearsize; @@ -1409,7 +1399,7 @@ int gss_alloc_reqbuf_priv(struct ptlrpc_sec *sec, if (req->rq_pack_udesc) sptlrpc_pack_user_desc(req->rq_clrbuf, 1); - RETURN(0); + return 0; } /* @@ -1442,7 +1432,6 @@ void gss_free_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req) { int privacy; - ENTRY; LASSERT(!req->rq_pool || req->rq_reqbuf); privacy = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc) == SPTLRPC_SVC_PRIV; @@ -1471,8 +1460,6 @@ release_reqbuf: req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } - - EXIT; } static int do_alloc_repbuf(struct ptlrpc_request *req, int bufsize) @@ -1578,7 +1565,6 @@ int gss_alloc_repbuf(struct ptlrpc_sec *sec, int msgsize) { int svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc); - ENTRY; LASSERT(!req->rq_pack_bulk || (req->rq_bulk_read || req->rq_bulk_write)); @@ -1697,7 +1683,7 @@ int gss_enlarge_reqbuf_intg(struct ptlrpc_sec *sec, OBD_ALLOC_LARGE(newbuf, newbuf_size); if (newbuf == NULL) - RETURN(-ENOMEM); + return -ENOMEM; memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len); @@ -1717,7 +1703,7 @@ int gss_enlarge_reqbuf_intg(struct ptlrpc_sec *sec, _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize); req->rq_reqlen = newmsg_size; - RETURN(0); + return 0; } static @@ -1786,7 +1772,7 @@ int gss_enlarge_reqbuf_priv(struct ptlrpc_sec *sec, OBD_ALLOC_LARGE(newclrbuf, newclrbuf_size); if (newclrbuf == NULL) - RETURN(-ENOMEM); + return -ENOMEM; memcpy(newclrbuf, req->rq_clrbuf, req->rq_clrbuf_len); @@ -1806,7 +1792,7 @@ int gss_enlarge_reqbuf_priv(struct ptlrpc_sec *sec, _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize); req->rq_reqlen = newmsg_size; - RETURN(0); + return 0; } int gss_enlarge_reqbuf(struct ptlrpc_sec *sec, @@ -1891,7 +1877,6 @@ int gss_svc_sign(struct ptlrpc_request *req, { __u32 flags = 0; int rc; - ENTRY; LASSERT(rs->rs_msg == lustre_msg_buf(rs->rs_repbuf, 1, 0)); @@ -1906,7 +1891,7 @@ int gss_svc_sign(struct ptlrpc_request *req, LUSTRE_SP_ANY, flags, PTLRPC_GSS_PROC_DATA, grctx->src_wirectx.gw_seq, svc, NULL); if (rc < 0) - RETURN(rc); + return rc; rs->rs_repdata_len = rc; @@ -1923,7 +1908,7 @@ int gss_svc_sign(struct ptlrpc_request *req, req->rq_reply_off = 0; } - RETURN(0); + return 0; } int gss_pack_err_notify(struct ptlrpc_request *req, __u32 major, __u32 minor) @@ -1933,10 +1918,9 @@ int gss_pack_err_notify(struct ptlrpc_request *req, __u32 major, __u32 minor) struct gss_err_header *ghdr; int replen = sizeof(struct ptlrpc_body); int rc; - ENTRY; //if (OBD_FAIL_CHECK_ORSET(OBD_FAIL_SVCGSS_ERR_NOTIFY, OBD_FAIL_ONCE)) - // RETURN(-EINVAL); + // return -EINVAL; grctx->src_err_notify = 1; grctx->src_reserve_len = 0; @@ -1944,7 +1928,7 @@ int gss_pack_err_notify(struct ptlrpc_request *req, __u32 major, __u32 minor) rc = lustre_pack_reply_v2(req, 1, &replen, NULL, 0); if (rc) { CERROR("could not pack reply, err %d\n", rc); - RETURN(rc); + return rc; } /* gss hdr */ @@ -1963,7 +1947,7 @@ int gss_pack_err_notify(struct ptlrpc_request *req, __u32 major, __u32 minor) CDEBUG(D_SEC, "prepare gss error notify(0x%x/0x%x) to %s\n", major, minor, libcfs_nid2str(req->rq_peer.nid)); - RETURN(0); + return 0; } static @@ -1978,7 +1962,6 @@ int gss_svc_handle_init(struct ptlrpc_request *req, __u32 lustre_svc; __u32 *secdata, seclen; int swabbed, rc; - ENTRY; CDEBUG(D_SEC, "processing gss init(%d) request from %s\n", gw->gw_proc, libcfs_nid2str(req->rq_peer.nid)); @@ -1987,18 +1970,18 @@ int gss_svc_handle_init(struct ptlrpc_request *req, if (gw->gw_flags & LUSTRE_GSS_PACK_BULK) { CERROR("unexpected bulk flag\n"); - RETURN(SECSVC_DROP); + 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); + return SECSVC_DROP; } if (reqbuf->lm_bufcount < 3 || reqbuf->lm_bufcount > 4){ CERROR("Invalid bufcount %d\n", reqbuf->lm_bufcount); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } swabbed = ptlrpc_req_need_swab(req); @@ -2009,7 +1992,7 @@ int gss_svc_handle_init(struct ptlrpc_request *req, if (seclen < 4 + 4) { CERROR("sec size %d too small\n", seclen); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } /* lustre svc type */ @@ -2020,7 +2003,7 @@ int gss_svc_handle_init(struct ptlrpc_request *req, * because touched internal structure of obd_uuid */ if (rawobj_extract(&uuid_obj, &secdata, &seclen)) { CERROR("failed to extract target uuid\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } uuid_obj.data[uuid_obj.len - 1] = '\0'; @@ -2030,25 +2013,25 @@ int gss_svc_handle_init(struct ptlrpc_request *req, 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); + return SECSVC_DROP; } /* extract reverse handle */ if (rawobj_extract(&rvs_hdl, &secdata, &seclen)) { CERROR("failed extract reverse handle\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } /* extract token */ if (rawobj_extract(&in_token, &secdata, &seclen)) { CERROR("can't extract token\n"); - RETURN(SECSVC_DROP); + 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); + return rc; if (grctx->src_ctx->gsc_usr_mds || grctx->src_ctx->gsc_usr_oss || grctx->src_ctx->gsc_usr_root) @@ -2064,11 +2047,11 @@ int gss_svc_handle_init(struct ptlrpc_request *req, if (gw->gw_flags & LUSTRE_GSS_PACK_USER) { if (reqbuf->lm_bufcount < 4) { CERROR("missing user descriptor\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } if (sptlrpc_unpack_user_desc(reqbuf, 2, swabbed)) { CERROR("Mal-formed user descriptor\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } req->rq_pack_udesc = 1; @@ -2078,7 +2061,7 @@ int gss_svc_handle_init(struct ptlrpc_request *req, req->rq_reqmsg = lustre_msg_buf(reqbuf, 1, 0); req->rq_reqlen = lustre_msg_buflen(reqbuf, 1); - RETURN(rc); + return rc; } /* @@ -2094,13 +2077,12 @@ int gss_svc_verify_request(struct ptlrpc_request *req, struct lustre_msg *msg = req->rq_reqbuf; int offset = 2; int swabbed; - ENTRY; *major = GSS_S_COMPLETE; if (msg->lm_bufcount < 2) { CERROR("Too few segments (%u) in request\n", msg->lm_bufcount); - RETURN(-EINVAL); + return -EINVAL; } if (gw->gw_svc == SPTLRPC_SVC_NULL) @@ -2109,20 +2091,20 @@ int gss_svc_verify_request(struct ptlrpc_request *req, 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); + 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); + 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); + return -EACCES; } verified: @@ -2132,12 +2114,12 @@ verified: if (gw->gw_flags & LUSTRE_GSS_PACK_USER) { if (msg->lm_bufcount < (offset + 1)) { CERROR("no user desc included\n"); - RETURN(-EINVAL); + return -EINVAL; } if (sptlrpc_unpack_user_desc(msg, offset, swabbed)) { CERROR("Mal-formed user descriptor\n"); - RETURN(-EINVAL); + return -EINVAL; } req->rq_pack_udesc = 1; @@ -2149,11 +2131,11 @@ verified: if (gw->gw_flags & LUSTRE_GSS_PACK_BULK) { if (msg->lm_bufcount < (offset + 1)) { CERROR("missing bulk sec descriptor\n"); - RETURN(-EINVAL); + return -EINVAL; } if (bulk_sec_desc_unpack(msg, offset, swabbed)) - RETURN(-EINVAL); + return -EINVAL; req->rq_pack_bulk = 1; grctx->src_reqbsd = lustre_msg_buf(msg, offset, 0); @@ -2162,7 +2144,7 @@ verified: req->rq_reqmsg = lustre_msg_buf(msg, 1, 0); req->rq_reqlen = msg->lm_buflens[1]; - RETURN(0); + return 0; } static @@ -2174,48 +2156,47 @@ int gss_svc_unseal_request(struct ptlrpc_request *req, struct gss_svc_ctx *gctx = grctx->src_ctx; struct lustre_msg *msg = req->rq_reqbuf; int swabbed, msglen, offset = 1; - ENTRY; 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); + 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); + 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); + return -EACCES; } swabbed = __lustre_unpack_msg(msg, msglen); if (swabbed < 0) { CERROR("Failed to unpack after decryption\n"); - RETURN(-EINVAL); + return -EINVAL; } req->rq_reqdata_len = msglen; if (msg->lm_bufcount < 1) { CERROR("Invalid buffer: is empty\n"); - RETURN(-EINVAL); + return -EINVAL; } if (gw->gw_flags & LUSTRE_GSS_PACK_USER) { if (msg->lm_bufcount < offset + 1) { CERROR("no user descriptor included\n"); - RETURN(-EINVAL); + return -EINVAL; } if (sptlrpc_unpack_user_desc(msg, offset, swabbed)) { CERROR("Mal-formed user descriptor\n"); - RETURN(-EINVAL); + return -EINVAL; } req->rq_pack_udesc = 1; @@ -2226,11 +2207,11 @@ int gss_svc_unseal_request(struct ptlrpc_request *req, if (gw->gw_flags & LUSTRE_GSS_PACK_BULK) { if (msg->lm_bufcount < offset + 1) { CERROR("no bulk checksum included\n"); - RETURN(-EINVAL); + return -EINVAL; } if (bulk_sec_desc_unpack(msg, offset, swabbed)) - RETURN(-EINVAL); + return -EINVAL; req->rq_pack_bulk = 1; grctx->src_reqbsd = lustre_msg_buf(msg, offset, 0); @@ -2239,7 +2220,7 @@ int gss_svc_unseal_request(struct ptlrpc_request *req, req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, 0, 0); req->rq_reqlen = req->rq_reqbuf->lm_buflens[0]; - RETURN(0); + return 0; } static @@ -2249,7 +2230,6 @@ int gss_svc_handle_data(struct ptlrpc_request *req, struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); __u32 major = 0; int rc = 0; - ENTRY; grctx->src_ctx = gss_svc_upcall_get_ctx(req, gw); if (!grctx->src_ctx) { @@ -2272,7 +2252,7 @@ int gss_svc_handle_data(struct ptlrpc_request *req, } if (rc == 0) - RETURN(SECSVC_OK); + 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, @@ -2283,9 +2263,9 @@ error: * 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_COMPLETE; - RETURN(SECSVC_DROP); + return SECSVC_DROP; } static @@ -2294,7 +2274,6 @@ int gss_svc_handle_destroy(struct ptlrpc_request *req, { struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); __u32 major; - ENTRY; req->rq_ctx_fini = 1; req->rq_no_reply = 1; @@ -2302,16 +2281,16 @@ int gss_svc_handle_destroy(struct ptlrpc_request *req, 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); + 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); + return SECSVC_DROP; } if (gss_svc_verify_request(req, grctx, gw, &major)) - RETURN(SECSVC_DROP); + return SECSVC_DROP; CWARN("destroy svc ctx %p idx "LPX64" (%u->%s)\n", grctx->src_ctx, gss_handle_to_u64(&gw->gw_handle), @@ -2322,19 +2301,19 @@ int gss_svc_handle_destroy(struct ptlrpc_request *req, 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); + 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); + return SECSVC_OK; } req->rq_pack_udesc = 1; req->rq_user_desc = lustre_msg_buf(req->rq_reqbuf, 2, 0); } - RETURN(SECSVC_OK); + return SECSVC_OK; } int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) @@ -2343,14 +2322,13 @@ int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) struct gss_svc_reqctx *grctx; struct gss_wire_ctx *gw; int swabbed, rc; - ENTRY; 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); + return SECSVC_DROP; } swabbed = ptlrpc_req_need_swab(req); @@ -2358,14 +2336,14 @@ int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) ghdr = gss_swab_header(req->rq_reqbuf, 0, swabbed); if (ghdr == NULL) { CERROR("can't decode gss header\n"); - RETURN(SECSVC_DROP); + 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); + return SECSVC_DROP; } req->rq_sp_from = ghdr->gh_sp; @@ -2373,7 +2351,7 @@ int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) /* alloc grctx data */ OBD_ALLOC_PTR(grctx); if (!grctx) - RETURN(SECSVC_DROP); + return SECSVC_DROP; grctx->src_base.sc_policy = sptlrpc_policy_get(policy); atomic_set(&grctx->src_base.sc_refcount, 1); @@ -2428,16 +2406,14 @@ int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) break; } - RETURN(rc); + return rc; } void gss_svc_invalidate_ctx(struct ptlrpc_svc_ctx *svc_ctx) { struct gss_svc_reqctx *grctx; - ENTRY; if (svc_ctx == NULL) { - EXIT; return; } @@ -2446,8 +2422,6 @@ void gss_svc_invalidate_ctx(struct ptlrpc_svc_ctx *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); - - EXIT; } static inline @@ -2496,13 +2470,12 @@ int gss_svc_alloc_rs(struct ptlrpc_request *req, int msglen) __u32 ibuflens[2], buflens[4]; int ibufcnt = 0, bufcnt; int txtsize, wmsg_size, rs_size; - ENTRY; 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); + return -EPROTO; } svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc); @@ -2575,7 +2548,7 @@ int gss_svc_alloc_rs(struct ptlrpc_request *req, int msglen) } else { OBD_ALLOC_LARGE(rs, rs_size); if (rs == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rs->rs_size = rs_size; } @@ -2605,7 +2578,7 @@ int gss_svc_alloc_rs(struct ptlrpc_request *req, int msglen) LASSERT(rs->rs_msg); req->rq_reply_state = rs; - RETURN(0); + return 0; } static int gss_svc_seal(struct ptlrpc_request *req, @@ -2619,7 +2592,6 @@ static int gss_svc_seal(struct ptlrpc_request *req, int token_buflen; __u32 buflens[2], major; int msglen, rc; - ENTRY; /* get clear data length. note embedded lustre_msg might * have been shrinked */ @@ -2647,7 +2619,7 @@ static int gss_svc_seal(struct ptlrpc_request *req, token_buflen = gss_mech_payload(gctx->gsc_mechctx, msglen, 1); OBD_ALLOC_LARGE(token_buf, token_buflen); if (token_buf == NULL) - RETURN(-ENOMEM); + return -ENOMEM; hdrobj.len = PTLRPC_GSS_HEADER_SIZE; hdrobj.data = (__u8 *) ghdr; @@ -2703,7 +2675,7 @@ static int gss_svc_seal(struct ptlrpc_request *req, rc = 0; out_free: OBD_FREE_LARGE(token_buf, token_buflen); - RETURN(rc); + return rc; } int gss_svc_authorize(struct ptlrpc_request *req) @@ -2712,7 +2684,6 @@ int gss_svc_authorize(struct ptlrpc_request *req) struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); struct gss_wire_ctx *gw = &grctx->src_wirectx; int early, rc; - ENTRY; early = (req->rq_packed_final == 0); @@ -2720,7 +2691,7 @@ int gss_svc_authorize(struct ptlrpc_request *req) LASSERT(rs->rs_repdata_len != 0); req->rq_reply_off = gss_at_reply_off_integ; - RETURN(0); + return 0; } /* early reply could happen in many cases */ @@ -2728,7 +2699,7 @@ int gss_svc_authorize(struct ptlrpc_request *req) 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); + return -EINVAL; } LASSERT(grctx->src_ctx); @@ -2749,7 +2720,7 @@ int gss_svc_authorize(struct ptlrpc_request *req) rc = 0; out: - RETURN(rc); + return rc; } void gss_svc_free_rs(struct ptlrpc_reply_state *rs) diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 47a3c051273..5ca69aec72e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -195,7 +195,6 @@ int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt) /* Must be called with imp_lock held! */ static void ptlrpc_deactivate_and_unlock_import(struct obd_import *imp) { - ENTRY; LASSERT(spin_is_locked(&imp->imp_lock)); CDEBUG(D_HA, "setting import %s INVALID\n", obd2cli_tgt(imp->imp_obd)); @@ -205,8 +204,6 @@ static void ptlrpc_deactivate_and_unlock_import(struct obd_import *imp) ptlrpc_abort_inflight(imp); obd_import_event(imp->imp_obd, imp, IMP_EVENT_INACTIVE); - - EXIT; } /* @@ -394,8 +391,6 @@ EXPORT_SYMBOL(ptlrpc_activate_import); void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt) { - ENTRY; - LASSERT(!imp->imp_dlm_fake); if (ptlrpc_set_import_discon(imp, conn_cnt)) { @@ -417,7 +412,6 @@ void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt) ptlrpc_pinger_wake_up(); } - EXIT; } EXPORT_SYMBOL(ptlrpc_fail_import); @@ -461,7 +455,6 @@ static int import_select_connection(struct obd_import *imp) struct obd_export *dlmexp; char *target_start; int target_len, tried_all = 1; - ENTRY; spin_lock(&imp->imp_lock); @@ -469,7 +462,7 @@ static int import_select_connection(struct obd_import *imp) CERROR("%s: no connections available\n", imp->imp_obd->obd_name); spin_unlock(&imp->imp_lock); - RETURN(-EINVAL); + return -EINVAL; } list_for_each_entry(conn, &imp->imp_conn_list, oic_item) { @@ -558,7 +551,7 @@ static int import_select_connection(struct obd_import *imp) spin_unlock(&imp->imp_lock); - RETURN(0); + return 0; } /* @@ -602,21 +595,20 @@ int ptlrpc_connect_import(struct obd_import *imp) (char *)&imp->imp_connect_data }; struct ptlrpc_connect_async_args *aa; int rc; - ENTRY; spin_lock(&imp->imp_lock); if (imp->imp_state == LUSTRE_IMP_CLOSED) { spin_unlock(&imp->imp_lock); CERROR("can't connect to a closed import\n"); - RETURN(-EINVAL); + return -EINVAL; } else if (imp->imp_state == LUSTRE_IMP_FULL) { spin_unlock(&imp->imp_lock); CERROR("already connected\n"); - RETURN(0); + return 0; } else if (imp->imp_state == LUSTRE_IMP_CONNECTING) { spin_unlock(&imp->imp_lock); CERROR("already connecting\n"); - RETURN(-EALREADY); + return -EALREADY; } IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CONNECTING); @@ -716,7 +708,7 @@ out: IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_connect_import); @@ -756,13 +748,12 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, struct obd_connect_data *ocd; struct obd_export *exp; int ret; - ENTRY; spin_lock(&imp->imp_lock); if (imp->imp_state == LUSTRE_IMP_CLOSED) { imp->imp_connect_tried = 1; spin_unlock(&imp->imp_lock); - RETURN(0); + return 0; } if (rc) { @@ -984,7 +975,7 @@ finish: imp->imp_connection->c_remote_uuid.uuid); ptlrpc_connect_import(imp); imp->imp_connect_tried = 1; - RETURN(0); + return 0; } } else { @@ -1137,7 +1128,7 @@ out: /* reply message might not be ready */ if (request->rq_repmsg == NULL) - RETURN(-EPROTO); + return -EPROTO; ocd = req_capsule_server_get(&request->rq_pill, &RMF_CONNECT_DATA); @@ -1161,7 +1152,7 @@ out: ptlrpc_deactivate_import(imp); IMPORT_SET_STATE(imp, LUSTRE_IMP_CLOSED); } - RETURN(-EPROTO); + return -EPROTO; } ptlrpc_maybe_ping_import_soon(imp); @@ -1172,7 +1163,7 @@ out: } wake_up_all(&imp->imp_recovery_waitq); - RETURN(rc); + return rc; } /** @@ -1183,7 +1174,6 @@ static int completed_replay_interpret(const struct lu_env *env, struct ptlrpc_request *req, void * data, int rc) { - ENTRY; atomic_dec(&req->rq_import->imp_replay_inflight); if (req->rq_status == 0 && !req->rq_import->imp_vbr_failed) { @@ -1202,7 +1192,7 @@ static int completed_replay_interpret(const struct lu_env *env, ptlrpc_connect_import(req->rq_import); } - RETURN(0); + return 0; } /** @@ -1212,10 +1202,9 @@ static int completed_replay_interpret(const struct lu_env *env, static int signal_completed_replay(struct obd_import *imp) { struct ptlrpc_request *req; - ENTRY; if (unlikely(OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_FINISH_REPLAY))) - RETURN(0); + return 0; LASSERT(atomic_read(&imp->imp_replay_inflight) == 0); atomic_inc(&imp->imp_replay_inflight); @@ -1224,7 +1213,7 @@ static int signal_completed_replay(struct obd_import *imp) OBD_PING); if (req == NULL) { atomic_dec(&imp->imp_replay_inflight); - RETURN(-ENOMEM); + return -ENOMEM; } ptlrpc_request_set_replen(req); @@ -1236,7 +1225,7 @@ static int signal_completed_replay(struct obd_import *imp) req->rq_interpret_reply = completed_replay_interpret; ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); - RETURN(0); + return 0; } /** @@ -1248,8 +1237,6 @@ static int ptlrpc_invalidate_import_thread(void *data) { struct obd_import *imp = data; - ENTRY; - unshare_fs_struct(); CDEBUG(D_HA, "thread invalidate import %s to %s@%s\n", @@ -1267,7 +1254,7 @@ static int ptlrpc_invalidate_import_thread(void *data) ptlrpc_import_recovery_state_machine(imp); class_import_put(imp); - RETURN(0); + return 0; } /** @@ -1297,7 +1284,6 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) char *target_start; int target_len; - ENTRY; if (imp->imp_state == LUSTRE_IMP_EVICTED) { deuuidify(obd2cli_tgt(imp->imp_obd), NULL, &target_start, &target_len); @@ -1319,7 +1305,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) spin_unlock(&imp->imp_lock); { - task_t *task; + struct task_struct *task; /* bug 17802: XXX client_disconnect_export vs connect request * race. if client will evicted at this time, we start * invalidate thread without reference to import and import can @@ -1334,7 +1320,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) } else { rc = 0; } - RETURN(rc); + return rc; } } @@ -1393,7 +1379,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) } out: - RETURN(rc); + return rc; } int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) @@ -1401,7 +1387,6 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) struct ptlrpc_request *req; int rq_opc, rc = 0; int nowait = imp->imp_obd->obd_force; - ENTRY; if (nowait) GOTO(set_state, rc); @@ -1413,7 +1398,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) default: CERROR("don't know how to disconnect from %s (connect_op %d)\n", obd2cli_tgt(imp->imp_obd), imp->imp_connect_op); - RETURN(-EINVAL); + return -EINVAL; } if (ptlrpc_import_in_recovery(imp)) { @@ -1476,21 +1461,17 @@ out: memset(&imp->imp_remote_handle, 0, sizeof(imp->imp_remote_handle)); spin_unlock(&imp->imp_lock); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_disconnect_import); void ptlrpc_cleanup_imp(struct obd_import *imp) { - ENTRY; - spin_lock(&imp->imp_lock); IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CLOSED); imp->imp_generation++; spin_unlock(&imp->imp_lock); ptlrpc_abort_inflight(imp); - - EXIT; } EXPORT_SYMBOL(ptlrpc_cleanup_imp); diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index 367ca8ef7d6..379e59477ea 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -85,7 +85,6 @@ static int llog_client_open(const struct lu_env *env, struct llog_ctxt *ctxt = lgh->lgh_ctxt; struct ptlrpc_request *req = NULL; int rc; - ENTRY; LLOG_CLIENT_ENTRY(ctxt, imp); @@ -133,7 +132,6 @@ static int llog_client_open(const struct lu_env *env, lgh->lgh_id = body->lgd_logid; lgh->lgh_ctxt = ctxt; - EXIT; out: LLOG_CLIENT_EXIT(ctxt, imp); ptlrpc_req_finished(req); @@ -147,7 +145,6 @@ static int llog_client_destroy(const struct lu_env *env, struct ptlrpc_request *req = NULL; struct llogd_body *body; int rc; - ENTRY; LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_DESTROY, @@ -170,7 +167,7 @@ static int llog_client_destroy(const struct lu_env *env, ptlrpc_req_finished(req); err_exit: LLOG_CLIENT_EXIT(loghandle->lgh_ctxt, imp); - RETURN(rc); + return rc; } @@ -184,7 +181,6 @@ static int llog_client_next_block(const struct lu_env *env, struct llogd_body *body; void *ptr; int rc; - ENTRY; LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK, @@ -221,7 +217,6 @@ static int llog_client_next_block(const struct lu_env *env, *cur_offset = body->lgd_cur_offset; memcpy(buf, ptr, len); - EXIT; out: ptlrpc_req_finished(req); err_exit: @@ -238,7 +233,6 @@ static int llog_client_prev_block(const struct lu_env *env, struct llogd_body *body; void *ptr; int rc; - ENTRY; LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK, @@ -270,7 +264,6 @@ static int llog_client_prev_block(const struct lu_env *env, GOTO(out, rc =-EFAULT); memcpy(buf, ptr, len); - EXIT; out: ptlrpc_req_finished(req); err_exit: @@ -287,7 +280,6 @@ static int llog_client_read_header(const struct lu_env *env, struct llog_log_hdr *hdr; struct llog_rec_hdr *llh_hdr; int rc; - ENTRY; LLOG_CLIENT_ENTRY(handle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp,&RQF_LLOG_ORIGIN_HANDLE_READ_HEADER, @@ -326,7 +318,6 @@ static int llog_client_read_header(const struct lu_env *env, CERROR("you may need to re-run lconf --write_conf.\n"); rc = -EIO; } - EXIT; out: ptlrpc_req_finished(req); err_exit: diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c index a81f557d779..17c06a32df6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c @@ -57,7 +57,6 @@ int llog_initiator_connect(struct llog_ctxt *ctxt) { struct obd_import *new_imp; - ENTRY; LASSERT(ctxt); new_imp = ctxt->loc_obd->u.cli.cl_import; @@ -70,6 +69,6 @@ int llog_initiator_connect(struct llog_ctxt *ctxt) ctxt->loc_imp = class_import_get(new_imp); } mutex_unlock(&ctxt->loc_mutex); - RETURN(0); + return 0; } EXPORT_SYMBOL(llog_initiator_connect); diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_server.c b/drivers/staging/lustre/lustre/ptlrpc/llog_server.c index bc1fcd8c7e7..af9d2ac391e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_server.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_server.c @@ -71,11 +71,9 @@ int llog_origin_handle_open(struct ptlrpc_request *req) char *name = NULL; int rc; - ENTRY; - body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) - RETURN(-EFAULT); + return -EFAULT; if (ostid_id(&body->lgd_logid.lgl_oi) > 0) logid = &body->lgd_logid; @@ -83,7 +81,7 @@ int llog_origin_handle_open(struct ptlrpc_request *req) if (req_capsule_field_present(&req->rq_pill, &RMF_NAME, RCL_CLIENT)) { name = req_capsule_client_get(&req->rq_pill, &RMF_NAME); if (name == NULL) - RETURN(-EFAULT); + return -EFAULT; CDEBUG(D_INFO, "%s: opening log %s\n", obd->obd_name, name); } @@ -91,7 +89,7 @@ int llog_origin_handle_open(struct ptlrpc_request *req) if (ctxt == NULL) { CDEBUG(D_WARNING, "%s: no ctxt. group=%p idx=%d name=%s\n", obd->obd_name, &obd->obd_olg, body->lgd_ctxt_idx, name); - RETURN(-ENODEV); + return -ENODEV; } disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); @@ -108,7 +106,6 @@ int llog_origin_handle_open(struct ptlrpc_request *req) body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY); body->lgd_logid = loghandle->lgh_id; - EXIT; out_close: llog_origin_close(req->rq_svc_thread->t_env, loghandle); out_pop: @@ -127,11 +124,9 @@ int llog_origin_handle_destroy(struct ptlrpc_request *req) struct llog_ctxt *ctxt; int rc; - ENTRY; - body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) - RETURN(-EFAULT); + return -EFAULT; if (ostid_id(&body->lgd_logid.lgl_oi) > 0) logid = &body->lgd_logid; @@ -142,7 +137,7 @@ int llog_origin_handle_destroy(struct ptlrpc_request *req) ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx); if (ctxt == NULL) - RETURN(-ENODEV); + return -ENODEV; disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); @@ -153,7 +148,7 @@ int llog_origin_handle_destroy(struct ptlrpc_request *req) rc = llog_erase(req->rq_svc_thread->t_env, ctxt, logid, NULL); pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_origin_handle_destroy); @@ -169,15 +164,13 @@ int llog_origin_handle_next_block(struct ptlrpc_request *req) void *ptr; int rc; - ENTRY; - body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) - RETURN(-EFAULT); + return -EFAULT; ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx); if (ctxt == NULL) - RETURN(-ENODEV); + return -ENODEV; disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); @@ -208,7 +201,6 @@ int llog_origin_handle_next_block(struct ptlrpc_request *req) &repbody->lgd_cur_offset, ptr, LLOG_CHUNK_SIZE); if (rc) GOTO(out_close, rc); - EXIT; out_close: llog_origin_close(req->rq_svc_thread->t_env, loghandle); out_pop: @@ -230,15 +222,13 @@ int llog_origin_handle_prev_block(struct ptlrpc_request *req) void *ptr; int rc; - ENTRY; - body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) - RETURN(-EFAULT); + return -EFAULT; ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx); if (ctxt == NULL) - RETURN(-ENODEV); + return -ENODEV; disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); @@ -269,7 +259,6 @@ int llog_origin_handle_prev_block(struct ptlrpc_request *req) if (rc) GOTO(out_close, rc); - EXIT; out_close: llog_origin_close(req->rq_svc_thread->t_env, loghandle); out_pop: @@ -290,15 +279,13 @@ int llog_origin_handle_read_header(struct ptlrpc_request *req) __u32 flags; int rc; - ENTRY; - body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) - RETURN(-EFAULT); + return -EFAULT; ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx); if (ctxt == NULL) - RETURN(-ENODEV); + return -ENODEV; disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); @@ -324,7 +311,6 @@ int llog_origin_handle_read_header(struct ptlrpc_request *req) hdr = req_capsule_server_get(&req->rq_pill, &RMF_LLOG_LOG_HDR); *hdr = *loghandle->lgh_hdr; - EXIT; out_close: llog_origin_close(req->rq_svc_thread->t_env, loghandle); out_pop: @@ -336,9 +322,8 @@ EXPORT_SYMBOL(llog_origin_handle_read_header); int llog_origin_handle_close(struct ptlrpc_request *req) { - ENTRY; /* Nothing to do */ - RETURN(0); + return 0; } EXPORT_SYMBOL(llog_origin_handle_close); @@ -352,20 +337,19 @@ int llog_origin_handle_cancel(struct ptlrpc_request *req) struct llog_handle *cathandle; struct inode *inode; void *handle; - ENTRY; logcookies = req_capsule_client_get(&req->rq_pill, &RMF_LOGCOOKIES); num_cookies = req_capsule_get_size(&req->rq_pill, &RMF_LOGCOOKIES, RCL_CLIENT) / sizeof(*logcookies); if (logcookies == NULL || num_cookies == 0) { DEBUG_REQ(D_HA, req, "No llog cookies sent"); - RETURN(-EFAULT); + return -EFAULT; } ctxt = llog_get_context(req->rq_export->exp_obd, logcookies->lgc_subsys); if (ctxt == NULL) - RETURN(-ENODEV); + return -ENODEV; disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 3e7325499d0..bea44a3d4a2 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -302,7 +302,7 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, const char *buffer, * hose a kernel by allowing the request history to grow too * far. */ bufpages = (svc->srv_buf_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; - if (val > num_physpages/(2 * bufpages)) + if (val > totalram_pages / (2 * bufpages)) return -ERANGE; spin_lock(&svc->srv_lock); @@ -480,7 +480,6 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) bool hp = false; int i; int rc = 0; - ENTRY; /** * Serialize NRS core lprocfs operations with policy registration/ @@ -613,7 +612,7 @@ out: mutex_unlock(&nrs_core.nrs_mutex); - RETURN(rc); + return rc; } /** @@ -638,7 +637,6 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, const char *buffe char *cmd_copy = NULL; char *token; int rc = 0; - ENTRY; if (count >= LPROCFS_NRS_WR_MAX_CMD) GOTO(out, rc = -EINVAL); @@ -698,7 +696,7 @@ out: if (cmd_copy) OBD_FREE(cmd_copy, LPROCFS_NRS_WR_MAX_CMD); - RETURN(rc < 0 ? rc : count); + return rc < 0 ? rc : count; } LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs); @@ -1217,13 +1215,12 @@ int lprocfs_wr_ping(struct file *file, const char *buffer, struct obd_device *obd = ((struct seq_file *)file->private_data)->private; struct ptlrpc_request *req; int rc; - ENTRY; LPROCFS_CLIMP_CHECK(obd); req = ptlrpc_prep_ping(obd->u.cli.cl_import); LPROCFS_CLIMP_EXIT(obd); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_send_state = LUSTRE_IMP_FULL; @@ -1231,8 +1228,8 @@ int lprocfs_wr_ping(struct file *file, const char *buffer, ptlrpc_req_finished(req); if (rc >= 0) - RETURN(count); - RETURN(rc); + return count; + return rc; } EXPORT_SYMBOL(lprocfs_wr_ping); diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index de3f0db0ba4..a0e009717a5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -54,7 +54,6 @@ static int ptl_send_buf (lnet_handle_md_t *mdh, void *base, int len, { int rc; lnet_md_t md; - ENTRY; LASSERT (portal != 0); LASSERT (conn != NULL); @@ -76,7 +75,7 @@ static int ptl_send_buf (lnet_handle_md_t *mdh, void *base, int len, if (unlikely(rc != 0)) { CERROR ("LNetMDBind failed: %d\n", rc); LASSERT (rc == -ENOMEM); - RETURN (-ENOMEM); + return -ENOMEM; } CDEBUG(D_NET, "Sending %d bytes to portal %d, xid "LPD64", offset %u\n", @@ -95,7 +94,7 @@ static int ptl_send_buf (lnet_handle_md_t *mdh, void *base, int len, LASSERTF(rc2 == 0, "rc2 = %d\n", rc2); } - RETURN (0); + return 0; } static void mdunlink_iterate_helper(lnet_handle_md_t *bd_mds, int count) @@ -122,10 +121,9 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) __u64 xid; lnet_handle_me_t me_h; lnet_md_t md; - ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_BULK_GET_NET)) - RETURN(0); + return 0; /* NB no locking required until desc is on the network */ LASSERT(desc->bd_nob > 0); @@ -207,7 +205,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) LASSERT(desc->bd_md_count >= 0); mdunlink_iterate_helper(desc->bd_mds, desc->bd_md_max_brw); req->rq_status = -ENOMEM; - RETURN(-ENOMEM); + return -ENOMEM; } /* Set rq_xid to matchbits of the final bulk so that server can @@ -231,7 +229,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) desc->bd_iov_count, desc->bd_nob, desc->bd_last_xid, req->rq_xid, desc->bd_portal); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_register_bulk); @@ -247,7 +245,6 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) wait_queue_head_t *wq; struct l_wait_info lwi; int rc; - ENTRY; LASSERT(!in_interrupt()); /* might sleep */ @@ -257,7 +254,7 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) req->rq_bulk_deadline = cfs_time_current_sec() + LONG_UNLINK; if (ptlrpc_client_bulk_active(req) == 0) /* completed or */ - RETURN(1); /* never registered */ + return 1; /* never registered */ LASSERT(desc->bd_req == req); /* bd_req NULL until registered */ @@ -268,14 +265,14 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) mdunlink_iterate_helper(desc->bd_mds, desc->bd_md_max_brw); if (ptlrpc_client_bulk_active(req) == 0) /* completed or */ - RETURN(1); /* never registered */ + return 1; /* never registered */ /* Move to "Unregistering" phase as bulk was not unlinked yet. */ ptlrpc_rqphase_move(req, RQ_PHASE_UNREGISTERING); /* Do not wait for unlink to finish. */ if (async) - RETURN(0); + return 0; if (req->rq_set != NULL) wq = &req->rq_set->set_waitq; @@ -290,14 +287,14 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) rc = l_wait_event(*wq, !ptlrpc_client_bulk_active(req), &lwi); if (rc == 0) { ptlrpc_rqphase_move(req, req->rq_next_phase); - RETURN(1); + return 1; } LASSERT(rc == -ETIMEDOUT); DEBUG_REQ(D_WARNING, req, "Unexpectedly long timeout: desc %p", desc); } - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_unregister_bulk); @@ -400,7 +397,8 @@ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags) req->rq_type = PTL_RPC_MSG_REPLY; lustre_msg_set_type(req->rq_repmsg, req->rq_type); - lustre_msg_set_status(req->rq_repmsg, req->rq_status); + lustre_msg_set_status(req->rq_repmsg, + ptlrpc_status_hton(req->rq_status)); lustre_msg_set_opc(req->rq_repmsg, req->rq_reqmsg ? lustre_msg_get_opc(req->rq_reqmsg) : 0); @@ -455,15 +453,14 @@ EXPORT_SYMBOL(ptlrpc_reply); int ptlrpc_send_error(struct ptlrpc_request *req, int may_be_difficult) { int rc; - ENTRY; if (req->rq_no_reply) - RETURN(0); + return 0; if (!req->rq_repmsg) { rc = lustre_pack_reply(req, 1, NULL, NULL); if (rc) - RETURN(rc); + return rc; } if (req->rq_status != -ENOSPC && req->rq_status != -EACCES && @@ -472,7 +469,7 @@ int ptlrpc_send_error(struct ptlrpc_request *req, int may_be_difficult) req->rq_type = PTL_RPC_MSG_ERR; rc = ptlrpc_send_reply(req, may_be_difficult); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_send_error); @@ -497,10 +494,9 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) lnet_handle_me_t reply_me_h; lnet_md_t reply_md; struct obd_device *obd = request->rq_import->imp_obd; - ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_DROP_RPC)) - RETURN(0); + return 0; LASSERT(request->rq_type == PTL_RPC_MSG_REQUEST); LASSERT(request->rq_wait_ctx == 0); @@ -516,7 +512,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) /* this prevents us from waiting in ptlrpc_queue_wait */ request->rq_err = 1; request->rq_status = -ENODEV; - RETURN(-ENODEV); + return -ENODEV; } connection = request->rq_import->imp_connection; diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 1996431e35f..0abcd6d8227 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -81,17 +81,16 @@ static int nrs_policy_ctl_locked(struct ptlrpc_nrs_policy *policy, * policy->pol_private will be NULL in such a case. */ if (policy->pol_state == NRS_POL_STATE_STOPPED) - RETURN(-ENODEV); + return -ENODEV; - RETURN(policy->pol_desc->pd_ops->op_policy_ctl != NULL ? + return policy->pol_desc->pd_ops->op_policy_ctl != NULL ? policy->pol_desc->pd_ops->op_policy_ctl(policy, opc, arg) : - -ENOSYS); + -ENOSYS; } static void nrs_policy_stop0(struct ptlrpc_nrs_policy *policy) { struct ptlrpc_nrs *nrs = policy->pol_nrs; - ENTRY; if (policy->pol_desc->pd_ops->op_policy_stop != NULL) { spin_unlock(&nrs->nrs_lock); @@ -111,24 +110,21 @@ static void nrs_policy_stop0(struct ptlrpc_nrs_policy *policy) if (atomic_dec_and_test(&policy->pol_desc->pd_refs)) module_put(policy->pol_desc->pd_owner); - - EXIT; } static int nrs_policy_stop_locked(struct ptlrpc_nrs_policy *policy) { struct ptlrpc_nrs *nrs = policy->pol_nrs; - ENTRY; if (nrs->nrs_policy_fallback == policy && !nrs->nrs_stopping) - RETURN(-EPERM); + return -EPERM; if (policy->pol_state == NRS_POL_STATE_STARTING) - RETURN(-EAGAIN); + return -EAGAIN; /* In progress or already stopped */ if (policy->pol_state != NRS_POL_STATE_STARTED) - RETURN(0); + return 0; policy->pol_state = NRS_POL_STATE_STOPPING; @@ -145,7 +141,7 @@ static int nrs_policy_stop_locked(struct ptlrpc_nrs_policy *policy) if (policy->pol_ref == 1) nrs_policy_stop0(policy); - RETURN(0); + return 0; } /** @@ -158,15 +154,8 @@ static int nrs_policy_stop_locked(struct ptlrpc_nrs_policy *policy) static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs) { struct ptlrpc_nrs_policy *tmp = nrs->nrs_policy_primary; - ENTRY; if (tmp == NULL) { - /** - * XXX: This should really be RETURN_EXIT, but the latter does - * not currently print anything out, and possibly should be - * fixed to do so. - */ - EXIT; return; } @@ -177,7 +166,6 @@ static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs) if (tmp->pol_ref == 0) nrs_policy_stop0(tmp); - EXIT; } /** @@ -203,19 +191,18 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) { struct ptlrpc_nrs *nrs = policy->pol_nrs; int rc = 0; - ENTRY; /** * Don't allow multiple starting which is too complex, and has no real * benefit. */ if (nrs->nrs_policy_starting) - RETURN(-EAGAIN); + return -EAGAIN; LASSERT(policy->pol_state != NRS_POL_STATE_STARTING); if (policy->pol_state == NRS_POL_STATE_STOPPING) - RETURN(-EAGAIN); + return -EAGAIN; if (policy->pol_flags & PTLRPC_NRS_FL_FALLBACK) { /** @@ -226,7 +213,7 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) */ if (policy == nrs->nrs_policy_fallback) { nrs_policy_stop_primary(nrs); - RETURN(0); + return 0; } /** @@ -241,10 +228,10 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) * Shouldn't start primary policy if w/o fallback policy. */ if (nrs->nrs_policy_fallback == NULL) - RETURN(-EPERM); + return -EPERM; if (policy->pol_state == NRS_POL_STATE_STARTED) - RETURN(0); + return 0; } /** @@ -256,7 +243,7 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) atomic_dec(&policy->pol_desc->pd_refs); CERROR("NRS: cannot get module for policy %s; is it alive?\n", policy->pol_desc->pd_name); - RETURN(-ENODEV); + return -ENODEV; } /** @@ -303,7 +290,7 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) out: nrs->nrs_policy_starting = 0; - RETURN(rc); + return rc; } /** @@ -644,7 +631,6 @@ static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name, { struct ptlrpc_nrs_policy *policy; int rc = 0; - ENTRY; spin_lock(&nrs->nrs_lock); @@ -674,7 +660,7 @@ out: spin_unlock(&nrs->nrs_lock); - RETURN(rc); + return rc; } /** @@ -690,7 +676,6 @@ out: static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) { struct ptlrpc_nrs_policy *policy = NULL; - ENTRY; spin_lock(&nrs->nrs_lock); @@ -699,7 +684,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) spin_unlock(&nrs->nrs_lock); CERROR("Can't find NRS policy %s\n", name); - RETURN(-ENOENT); + return -ENOENT; } if (policy->pol_ref > 1) { @@ -708,7 +693,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) nrs_policy_put_locked(policy); spin_unlock(&nrs->nrs_lock); - RETURN(-EBUSY); + return -EBUSY; } LASSERT(policy->pol_req_queued == 0); @@ -731,7 +716,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) LASSERT(policy->pol_private == NULL); OBD_FREE_PTR(policy); - RETURN(0); + return 0; } /** @@ -751,7 +736,6 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, struct ptlrpc_nrs_policy *tmp; struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; int rc; - ENTRY; LASSERT(svcpt != NULL); LASSERT(desc->pd_ops != NULL); @@ -764,7 +748,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, OBD_CPT_ALLOC_GFP(policy, svcpt->scp_service->srv_cptable, svcpt->scp_cpt, sizeof(*policy), __GFP_IO); if (policy == NULL) - RETURN(-ENOMEM); + return -ENOMEM; policy->pol_nrs = nrs; policy->pol_desc = desc; @@ -777,7 +761,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, rc = nrs_policy_init(policy); if (rc != 0) { OBD_FREE_PTR(policy); - RETURN(rc); + return rc; } spin_lock(&nrs->nrs_lock); @@ -793,7 +777,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, nrs_policy_fini(policy); OBD_FREE_PTR(policy); - RETURN(-EEXIST); + return -EEXIST; } list_add_tail(&policy->pol_list, &nrs->nrs_policy_list); @@ -807,7 +791,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, if (rc != 0) (void) nrs_policy_unregister(nrs, policy->pol_desc->pd_name); - RETURN(rc); + return rc; } /** @@ -844,7 +828,6 @@ static void ptlrpc_nrs_req_add_nolock(struct ptlrpc_request *req) static void ptlrpc_nrs_hpreq_add_nolock(struct ptlrpc_request *req) { int opc = lustre_msg_get_opc(req->rq_reqmsg); - ENTRY; spin_lock(&req->rq_lock); req->rq_hp = 1; @@ -852,7 +835,6 @@ static void ptlrpc_nrs_hpreq_add_nolock(struct ptlrpc_request *req) if (opc != OBD_PING) DEBUG_REQ(D_NET, req, "high priority req"); spin_unlock(&req->rq_lock); - EXIT; } /** @@ -891,7 +873,6 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs) struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; struct ptlrpc_service *svc = svcpt->scp_service; int rc = -EINVAL; - ENTRY; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -912,7 +893,7 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs) } } - RETURN(rc); + return rc; } /** @@ -950,7 +931,7 @@ static int nrs_svcpt_setup_locked0(struct ptlrpc_nrs *nrs, rc = nrs_register_policies_locked(nrs); - RETURN(rc); + return rc; } /** @@ -966,7 +947,6 @@ static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt) { struct ptlrpc_nrs *nrs; int rc; - ENTRY; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -994,7 +974,7 @@ static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt) rc = nrs_svcpt_setup_locked0(nrs, svcpt); out: - RETURN(rc); + return rc; } /** @@ -1012,7 +992,6 @@ static void nrs_svcpt_cleanup_locked(struct ptlrpc_service_part *svcpt) struct ptlrpc_nrs_policy *tmp; int rc; bool hp = false; - ENTRY; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -1036,8 +1015,6 @@ again: if (hp) OBD_FREE_PTR(nrs); - - EXIT; } /** @@ -1051,13 +1028,12 @@ again: static struct ptlrpc_nrs_pol_desc *nrs_policy_find_desc_locked(const char *name) { struct ptlrpc_nrs_pol_desc *tmp; - ENTRY; list_for_each_entry(tmp, &nrs_core.nrs_policies, pd_list) { if (strncmp(tmp->pd_name, name, NRS_POL_NAME_MAX) == 0) - RETURN(tmp); + return tmp; } - RETURN(NULL); + return NULL; } /** @@ -1079,7 +1055,6 @@ static int nrs_policy_unregister_locked(struct ptlrpc_nrs_pol_desc *desc) struct ptlrpc_service_part *svcpt; int i; int rc = 0; - ENTRY; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); LASSERT(mutex_is_locked(&ptlrpc_all_services_mutex)); @@ -1107,7 +1082,7 @@ again: "partition %d of service %s: %d\n", desc->pd_name, svcpt->scp_cpt, svcpt->scp_service->srv_name, rc); - RETURN(rc); + return rc; } if (!hp && nrs_svc_has_hp(svc)) { @@ -1120,7 +1095,7 @@ again: desc->pd_ops->op_lprocfs_fini(svc); } - RETURN(rc); + return rc; } /** @@ -1143,7 +1118,6 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) struct ptlrpc_service *svc; struct ptlrpc_nrs_pol_desc *desc; int rc = 0; - ENTRY; LASSERT(conf != NULL); LASSERT(conf->nc_ops != NULL); @@ -1171,7 +1145,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) "policy flags; external policies cannot act as fallback " "policies, or be started immediately upon registration " "without interaction with lprocfs\n", conf->nc_name); - RETURN(-EINVAL); + return -EINVAL; } mutex_lock(&nrs_core.nrs_mutex); @@ -1274,7 +1248,7 @@ internal: fail: mutex_unlock(&nrs_core.nrs_mutex); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_nrs_policy_register); @@ -1296,14 +1270,13 @@ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf) { struct ptlrpc_nrs_pol_desc *desc; int rc; - ENTRY; LASSERT(conf != NULL); if (conf->nc_flags & PTLRPC_NRS_FL_FALLBACK) { CERROR("Unable to unregister a fallback policy, unless the " "PTLRPC service is stopping.\n"); - RETURN(-EPERM); + return -EPERM; } conf->nc_name[NRS_POL_NAME_MAX - 1] = '\0'; @@ -1341,7 +1314,7 @@ fail: not_exist: mutex_unlock(&nrs_core.nrs_mutex); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_nrs_policy_unregister); @@ -1396,7 +1369,7 @@ failed: mutex_unlock(&nrs_core.nrs_mutex); - RETURN(rc); + return rc; } /** @@ -1630,7 +1603,6 @@ void ptlrpc_nrs_req_hp_move(struct ptlrpc_request *req) struct ptlrpc_nrs_request *nrq = &req->rq_nrq; struct ptlrpc_nrs_resource *res1[NRS_RES_MAX]; struct ptlrpc_nrs_resource *res2[NRS_RES_MAX]; - ENTRY; /** * Obtain the high-priority NRS head resources. @@ -1660,7 +1632,6 @@ out: * returned false. */ nrs_resource_put_safe(res1); - EXIT; } /** @@ -1696,7 +1667,6 @@ int ptlrpc_nrs_policy_control(const struct ptlrpc_service *svc, struct ptlrpc_service_part *svcpt; int i; int rc = 0; - ENTRY; LASSERT(opc != PTLRPC_NRS_CTL_INVALID); @@ -1728,7 +1698,7 @@ int ptlrpc_nrs_policy_control(const struct ptlrpc_service *svc, } } out: - RETURN(rc); + return rc; } @@ -1745,7 +1715,6 @@ extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; int ptlrpc_nrs_init(void) { int rc; - ENTRY; mutex_init(&nrs_core.nrs_mutex); INIT_LIST_HEAD(&nrs_core.nrs_policies); @@ -1755,7 +1724,7 @@ int ptlrpc_nrs_init(void) GOTO(fail, rc); - RETURN(rc); + return rc; fail: /** * Since no PTLRPC services have been started at this point, all we need @@ -1763,7 +1732,7 @@ fail: */ ptlrpc_nrs_fini(); - RETURN(rc); + return rc; } /** diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 1437636dfe2..cd2611a3b53 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -115,7 +115,7 @@ int lustre_msg_check_version(struct lustre_msg *msg, __u32 version) EXPORT_SYMBOL(lustre_msg_check_version); /* early reply size */ -int lustre_msg_early_size() +int lustre_msg_early_size(void) { static int size = 0; if (!size) { @@ -329,7 +329,6 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count, { struct ptlrpc_reply_state *rs; int msg_len, rc; - ENTRY; LASSERT(req->rq_reply_state == NULL); @@ -342,7 +341,7 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count, msg_len = lustre_msg_size_v2(count, lens); rc = sptlrpc_svc_alloc_rs(req, msg_len); if (rc) - RETURN(rc); + return rc; rs = req->rq_reply_state; atomic_set(&rs->rs_refcount, 1); /* 1 ref for rq_reply_state */ @@ -363,7 +362,7 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count, PTLRPC_RS_DEBUG_LRU_ADD(rs); - RETURN(0); + return 0; } EXPORT_SYMBOL(lustre_pack_reply_v2); @@ -574,7 +573,6 @@ static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len) int __lustre_unpack_msg(struct lustre_msg *m, int len) { int required_len, rc; - ENTRY; /* We can provide a slightly better error log, if we check the * message magic and version first. In the future, struct @@ -588,12 +586,12 @@ int __lustre_unpack_msg(struct lustre_msg *m, int len) /* can't even look inside the message */ CERROR("message length %d too small for magic/version check\n", len); - RETURN(-EINVAL); + return -EINVAL; } rc = lustre_unpack_msg_v2(m, len); - RETURN(rc); + return rc; } EXPORT_SYMBOL(__lustre_unpack_msg); @@ -642,6 +640,9 @@ static inline int lustre_unpack_ptlrpc_body_v2(struct ptlrpc_request *req, return -EINVAL; } + if (!inout) + pb->pb_status = ptlrpc_status_ntoh(pb->pb_status); + return 0; } @@ -1613,11 +1614,10 @@ int do_set_info_async(struct obd_import *imp, struct ptlrpc_request *req; char *tmp; int rc; - ENTRY; req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT, keylen); @@ -1626,7 +1626,7 @@ int do_set_info_async(struct obd_import *imp, rc = ptlrpc_request_pack(req, version, opcode); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); @@ -1644,7 +1644,7 @@ int do_set_info_async(struct obd_import *imp, ptlrpc_req_finished(req); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(do_set_info_async); @@ -2163,7 +2163,6 @@ static void lustre_swab_lmm_oi(struct ost_id *oi) static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum) { - ENTRY; __swab32s(&lum->lmm_magic); __swab32s(&lum->lmm_pattern); lustre_swab_lmm_oi(&lum->lmm_oi); @@ -2171,31 +2170,25 @@ static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum) __swab16s(&lum->lmm_stripe_count); __swab16s(&lum->lmm_stripe_offset); print_lum(lum); - EXIT; } void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum) { - ENTRY; CDEBUG(D_IOCTL, "swabbing lov_user_md v1\n"); lustre_swab_lov_user_md_common(lum); - EXIT; } EXPORT_SYMBOL(lustre_swab_lov_user_md_v1); void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum) { - ENTRY; CDEBUG(D_IOCTL, "swabbing lov_user_md v3\n"); lustre_swab_lov_user_md_common((struct lov_user_md_v1 *)lum); /* lmm_pool_name nothing to do with char */ - EXIT; } EXPORT_SYMBOL(lustre_swab_lov_user_md_v3); void lustre_swab_lov_mds_md(struct lov_mds_md *lmm) { - ENTRY; CDEBUG(D_IOCTL, "swabbing lov_mds_md\n"); __swab32s(&lmm->lmm_magic); __swab32s(&lmm->lmm_pattern); @@ -2203,7 +2196,6 @@ void lustre_swab_lov_mds_md(struct lov_mds_md *lmm) __swab32s(&lmm->lmm_stripe_size); __swab16s(&lmm->lmm_stripe_count); __swab16s(&lmm->lmm_layout_gen); - EXIT; } EXPORT_SYMBOL(lustre_swab_lov_mds_md); @@ -2211,13 +2203,12 @@ void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod, int stripe_count) { int i; - ENTRY; + for (i = 0; i < stripe_count; i++) { lustre_swab_ost_id(&(lod[i].l_ost_oi)); __swab32s(&(lod[i].l_ost_gen)); __swab32s(&(lod[i].l_ost_idx)); } - EXIT; } EXPORT_SYMBOL(lustre_swab_lov_user_md_objects); @@ -2459,6 +2450,7 @@ void _debug_req(struct ptlrpc_request *req, rep_ok ? lustre_msg_get_flags(req->rq_repmsg) : -1, req->rq_status, rep_ok ? lustre_msg_get_status(req->rq_repmsg) : -1); + va_end(args); } EXPORT_SYMBOL(_debug_req); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index ef5269aee0d..5dec771d70e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -51,7 +51,7 @@ struct mutex pinger_mutex; static LIST_HEAD(pinger_imports); static struct list_head timeout_list = LIST_HEAD_INIT(timeout_list); -int ptlrpc_pinger_suppress_pings() +int ptlrpc_pinger_suppress_pings(void) { return suppress_pings; } @@ -75,11 +75,10 @@ int ptlrpc_obd_ping(struct obd_device *obd) { int rc; struct ptlrpc_request *req; - ENTRY; req = ptlrpc_prep_ping(obd->u.cli.cl_import); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_send_state = LUSTRE_IMP_FULL; @@ -87,28 +86,27 @@ int ptlrpc_obd_ping(struct obd_device *obd) ptlrpc_req_finished(req); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_obd_ping); int ptlrpc_ping(struct obd_import *imp) { struct ptlrpc_request *req; - ENTRY; req = ptlrpc_prep_ping(imp); if (req == NULL) { CERROR("OOM trying to ping %s->%s\n", imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd)); - RETURN(-ENOMEM); + return -ENOMEM; } DEBUG_REQ(D_INFO, req, "pinging %s->%s", imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd)); ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); - RETURN(0); + return 0; } void ptlrpc_update_next_ping(struct obd_import *imp, int soon) @@ -297,7 +295,6 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp, static int ptlrpc_pinger_main(void *arg) { struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg; - ENTRY; /* Record that the thread is running */ thread_set_flags(thread, SVC_RUNNING); @@ -353,7 +350,6 @@ static int ptlrpc_pinger_main(void *arg) thread_is_event(thread), &lwi); if (thread_test_and_clear_flags(thread, SVC_STOPPING)) { - EXIT; break; } else { /* woken after adding import to reset timer */ @@ -369,37 +365,32 @@ static int ptlrpc_pinger_main(void *arg) return 0; } -static struct ptlrpc_thread *pinger_thread = NULL; +static struct ptlrpc_thread pinger_thread; int ptlrpc_start_pinger(void) { struct l_wait_info lwi = { 0 }; int rc; - ENTRY; - if (pinger_thread != NULL) - RETURN(-EALREADY); + if (!thread_is_init(&pinger_thread) && + !thread_is_stopped(&pinger_thread)) + return -EALREADY; - OBD_ALLOC_PTR(pinger_thread); - if (pinger_thread == NULL) - RETURN(-ENOMEM); - init_waitqueue_head(&pinger_thread->t_ctl_waitq); + init_waitqueue_head(&pinger_thread.t_ctl_waitq); init_waitqueue_head(&suspend_timeouts_waitq); - strcpy(pinger_thread->t_name, "ll_ping"); + strcpy(pinger_thread.t_name, "ll_ping"); /* CLONE_VM and CLONE_FILES just avoid a needless copy, because we * just drop the VM and FILES in cfs_daemonize_ctxt() right away. */ - rc = PTR_ERR(kthread_run(ptlrpc_pinger_main, - pinger_thread, pinger_thread->t_name)); + rc = PTR_ERR(kthread_run(ptlrpc_pinger_main, &pinger_thread, + "%s", pinger_thread.t_name)); if (IS_ERR_VALUE(rc)) { CERROR("cannot start thread: %d\n", rc); - OBD_FREE(pinger_thread, sizeof(*pinger_thread)); - pinger_thread = NULL; - RETURN(rc); + return rc; } - l_wait_event(pinger_thread->t_ctl_waitq, - thread_is_running(pinger_thread), &lwi); + l_wait_event(pinger_thread.t_ctl_waitq, + thread_is_running(&pinger_thread), &lwi); if (suppress_pings) CWARN("Pings will be suppressed at the request of the " @@ -408,7 +399,7 @@ int ptlrpc_start_pinger(void) "(Search for the \"suppress_pings\" kernel module " "parameter.)\n"); - RETURN(0); + return 0; } int ptlrpc_pinger_remove_timeouts(void); @@ -417,23 +408,19 @@ int ptlrpc_stop_pinger(void) { struct l_wait_info lwi = { 0 }; int rc = 0; - ENTRY; - if (pinger_thread == NULL) - RETURN(-EALREADY); + if (!thread_is_init(&pinger_thread) && + !thread_is_stopped(&pinger_thread)) + return -EALREADY; ptlrpc_pinger_remove_timeouts(); - mutex_lock(&pinger_mutex); - thread_set_flags(pinger_thread, SVC_STOPPING); - wake_up(&pinger_thread->t_ctl_waitq); - mutex_unlock(&pinger_mutex); + thread_set_flags(&pinger_thread, SVC_STOPPING); + wake_up(&pinger_thread.t_ctl_waitq); - l_wait_event(pinger_thread->t_ctl_waitq, - thread_is_stopped(pinger_thread), &lwi); + l_wait_event(pinger_thread.t_ctl_waitq, + thread_is_stopped(&pinger_thread), &lwi); - OBD_FREE_PTR(pinger_thread); - pinger_thread = NULL; - RETURN(rc); + return rc; } void ptlrpc_pinger_sending_on_import(struct obd_import *imp) @@ -459,9 +446,8 @@ void ptlrpc_pinger_commit_expected(struct obd_import *imp) int ptlrpc_pinger_add_import(struct obd_import *imp) { - ENTRY; if (!list_empty(&imp->imp_pinger_chain)) - RETURN(-EALREADY); + return -EALREADY; mutex_lock(&pinger_mutex); CDEBUG(D_HA, "adding pingable import %s->%s\n", @@ -476,15 +462,14 @@ int ptlrpc_pinger_add_import(struct obd_import *imp) ptlrpc_pinger_wake_up(); mutex_unlock(&pinger_mutex); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_pinger_add_import); int ptlrpc_pinger_del_import(struct obd_import *imp) { - ENTRY; if (list_empty(&imp->imp_pinger_chain)) - RETURN(-ENOENT); + return -ENOENT; mutex_lock(&pinger_mutex); list_del_init(&imp->imp_pinger_chain); @@ -494,7 +479,7 @@ int ptlrpc_pinger_del_import(struct obd_import *imp) imp->imp_obd->obd_no_recov = 1; class_import_put(imp); mutex_unlock(&pinger_mutex); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_pinger_del_import); @@ -615,10 +600,10 @@ int ptlrpc_pinger_remove_timeouts(void) return 0; } -void ptlrpc_pinger_wake_up() +void ptlrpc_pinger_wake_up(void) { - thread_add_flags(pinger_thread, SVC_EVENT); - wake_up(&pinger_thread->t_ctl_waitq); + thread_add_flags(&pinger_thread, SVC_EVENT); + wake_up(&pinger_thread.t_ctl_waitq); } /* Ping evictor thread */ @@ -659,7 +644,6 @@ static int ping_evictor_main(void *arg) struct obd_export *exp; struct l_wait_info lwi = { 0 }; time_t expire_time; - ENTRY; unshare_fs_struct(); @@ -731,12 +715,12 @@ static int ping_evictor_main(void *arg) } CDEBUG(D_HA, "Exiting Ping Evictor\n"); - RETURN(0); + return 0; } void ping_evictor_start(void) { - task_t *task; + struct task_struct *task; if (++pet_refcount > 1) return; diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c index f6ea80f0b10..419e634854d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c @@ -54,7 +54,6 @@ extern struct mutex ptlrpcd_mutex; __init int ptlrpc_init(void) { int rc, cleanup_phase = 0; - ENTRY; lustre_assert_wire_constants(); #if RS_DEBUG @@ -67,11 +66,11 @@ __init int ptlrpc_init(void) rc = req_layout_init(); if (rc) - RETURN(rc); + return rc; rc = ptlrpc_hr_init(); if (rc) - RETURN(rc); + return rc; cleanup_phase = 1; @@ -110,7 +109,7 @@ __init int ptlrpc_init(void) rc = tgt_mod_init(); if (rc) GOTO(cleanup, rc); - RETURN(0); + return 0; cleanup: switch(cleanup_phase) { @@ -150,5 +149,7 @@ static void __exit ptlrpc_exit(void) MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); MODULE_DESCRIPTION("Lustre Request Processor and Lock Management"); MODULE_LICENSE("GPL"); +MODULE_VERSION("1.0.0"); -cfs_module(ptlrpc, "1.0.0", ptlrpc_init, ptlrpc_exit); +module_init(ptlrpc_init); +module_exit(ptlrpc_exit); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 5a66a1be422..89c9be96f45 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -268,7 +268,6 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) struct ptlrpc_request_set *set = pc->pc_set; int rc = 0; int rc2; - ENTRY; if (atomic_read(&set->set_new_count)) { spin_lock(&set->set_new_req_lock); @@ -302,7 +301,7 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) * new modules are loaded, i.e., early during boot up. */ CERROR("Failure to refill session: %d\n", rc2); - RETURN(rc); + return rc; } if (atomic_read(&set->set_remaining)) @@ -368,7 +367,7 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) } } - RETURN(rc); + return rc; } /** @@ -383,7 +382,6 @@ static int ptlrpcd(void *arg) struct ptlrpc_request_set *set = pc->pc_set; struct lu_env env = { .le_ses = NULL }; int rc, exit = 0; - ENTRY; unshare_fs_struct(); #if defined(CONFIG_SMP) @@ -410,7 +408,7 @@ static int ptlrpcd(void *arg) complete(&pc->pc_starting); if (rc != 0) - RETURN(rc); + return rc; /* * This mainloop strongly resembles ptlrpc_set_wait() except that our @@ -501,7 +499,6 @@ static int ptlrpcd_bind(int index, int max) #if defined(CONFIG_NUMA) cpumask_t mask; #endif - ENTRY; LASSERT(index <= max - 1); pc = &ptlrpcds->pd_threads[index]; @@ -596,7 +593,7 @@ static int ptlrpcd_bind(int index, int max) } } - RETURN(rc); + return rc; } @@ -604,7 +601,6 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) { int rc; int env = 0; - ENTRY; /* * Do not allow start second thread for one pc. @@ -612,14 +608,14 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) if (test_and_set_bit(LIOD_START, &pc->pc_flags)) { CWARN("Starting second thread (%s) for same pc %p\n", name, pc); - RETURN(0); + return 0; } pc->pc_index = index; init_completion(&pc->pc_starting); init_completion(&pc->pc_finishing); spin_lock_init(&pc->pc_lock); - strncpy(pc->pc_name, name, sizeof(pc->pc_name) - 1); + strlcpy(pc->pc_name, name, sizeof(pc->pc_name)); pc->pc_set = ptlrpc_prep_set(); if (pc->pc_set == NULL) GOTO(out, rc = -ENOMEM); @@ -634,14 +630,15 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) env = 1; { - task_t *task; + struct task_struct *task; + if (index >= 0) { rc = ptlrpcd_bind(index, max); if (rc < 0) GOTO(out, rc); } - task = kthread_run(ptlrpcd, pc, pc->pc_name); + task = kthread_run(ptlrpcd, pc, "%s", pc->pc_name); if (IS_ERR(task)) GOTO(out, rc = PTR_ERR(task)); @@ -663,31 +660,25 @@ out: clear_bit(LIOD_BIND, &pc->pc_flags); clear_bit(LIOD_START, &pc->pc_flags); } - RETURN(rc); + return rc; } void ptlrpcd_stop(struct ptlrpcd_ctl *pc, int force) { - ENTRY; - if (!test_bit(LIOD_START, &pc->pc_flags)) { CWARN("Thread for pc %p was not started\n", pc); - goto out; + return; } set_bit(LIOD_STOP, &pc->pc_flags); if (force) set_bit(LIOD_FORCE, &pc->pc_flags); wake_up(&pc->pc_set->set_waitq); - -out: - EXIT; } void ptlrpcd_free(struct ptlrpcd_ctl *pc) { struct ptlrpc_request_set *set = pc->pc_set; - ENTRY; if (!test_bit(LIOD_START, &pc->pc_flags)) { CWARN("Thread for pc %p was not started\n", pc); @@ -716,13 +707,11 @@ out: pc->pc_partners = NULL; } pc->pc_npartners = 0; - EXIT; } static void ptlrpcd_fini(void) { int i; - ENTRY; if (ptlrpcds != NULL) { for (i = 0; i < ptlrpcds->pd_nthreads; i++) @@ -734,8 +723,6 @@ static void ptlrpcd_fini(void) OBD_FREE(ptlrpcds, ptlrpcds->pd_size); ptlrpcds = NULL; } - - EXIT; } static int ptlrpcd_init(void) @@ -743,7 +730,6 @@ static int ptlrpcd_init(void) int nthreads = num_online_cpus(); char name[16]; int size, i = -1, j, rc = 0; - ENTRY; if (max_ptlrpcds > 0 && max_ptlrpcds < nthreads) nthreads = max_ptlrpcds; @@ -759,7 +745,7 @@ static int ptlrpcd_init(void) if (ptlrpcds == NULL) GOTO(out, rc = -ENOMEM); - snprintf(name, 15, "ptlrpcd_rcv"); + snprintf(name, sizeof(name), "ptlrpcd_rcv"); set_bit(LIOD_RECOVERY, &ptlrpcds->pd_thread_rcv.pc_flags); rc = ptlrpcd_start(-1, nthreads, name, &ptlrpcds->pd_thread_rcv); if (rc < 0) @@ -778,7 +764,7 @@ static int ptlrpcd_init(void) * unnecessary dependency. But how to distribute async RPCs load * among all the ptlrpc daemons becomes another trouble. */ for (i = 0; i < nthreads; i++) { - snprintf(name, 15, "ptlrpcd_%d", i); + snprintf(name, sizeof(name), "ptlrpcd_%d", i); rc = ptlrpcd_start(i, nthreads, name, &ptlrpcds->pd_threads[i]); if (rc < 0) GOTO(out, rc); @@ -800,19 +786,18 @@ out: ptlrpcds = NULL; } - RETURN(0); + return 0; } int ptlrpcd_addref(void) { int rc = 0; - ENTRY; mutex_lock(&ptlrpcd_mutex); if (++ptlrpcd_users == 1) rc = ptlrpcd_init(); mutex_unlock(&ptlrpcd_mutex); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpcd_addref); diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index 2960889834a..84c39e083ea 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -60,12 +60,8 @@ */ void ptlrpc_initiate_recovery(struct obd_import *imp) { - ENTRY; - CDEBUG(D_HA, "%s: starting recovery\n", obd2cli_tgt(imp->imp_obd)); ptlrpc_connect_import(imp); - - EXIT; } /** @@ -78,7 +74,6 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) struct list_head *tmp, *pos; struct ptlrpc_request *req = NULL; __u64 last_transno; - ENTRY; *inflight = 0; @@ -137,11 +132,11 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) if (rc) { CERROR("recovery replay error %d for req " LPU64"\n", rc, req->rq_xid); - RETURN(rc); + return rc; } *inflight = 1; } - RETURN(rc); + return rc; } /** @@ -152,8 +147,6 @@ int ptlrpc_resend(struct obd_import *imp) { struct ptlrpc_request *req, *next; - ENTRY; - /* As long as we're in recovery, nothing should be added to the sending * list, so we don't need to hold the lock during this iteration and * resend process. @@ -163,7 +156,7 @@ int ptlrpc_resend(struct obd_import *imp) spin_lock(&imp->imp_lock); if (imp->imp_state != LUSTRE_IMP_RECOVER) { spin_unlock(&imp->imp_lock); - RETURN(-1); + return -1; } list_for_each_entry_safe(req, next, &imp->imp_sending_list, @@ -176,7 +169,7 @@ int ptlrpc_resend(struct obd_import *imp) } spin_unlock(&imp->imp_lock); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_resend); @@ -203,7 +196,6 @@ EXPORT_SYMBOL(ptlrpc_wake_delayed); void ptlrpc_request_handle_notconn(struct ptlrpc_request *failed_req) { struct obd_import *imp = failed_req->rq_import; - ENTRY; CDEBUG(D_HA, "import %s of %s@%s abruptly disconnected: reconnecting\n", imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd), @@ -230,8 +222,6 @@ void ptlrpc_request_handle_notconn(struct ptlrpc_request *failed_req) if (!failed_req->rq_no_resend) failed_req->rq_resend = 1; spin_unlock(&failed_req->rq_lock); - - EXIT; } /** @@ -246,7 +236,6 @@ int ptlrpc_set_import_active(struct obd_import *imp, int active) struct obd_device *obd = imp->imp_obd; int rc = 0; - ENTRY; LASSERT(obd); /* When deactivating, mark import invalid, and abort in-flight @@ -279,7 +268,7 @@ int ptlrpc_set_import_active(struct obd_import *imp, int active) rc = ptlrpc_recover_import(imp, NULL, 0); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_set_import_active); @@ -287,7 +276,6 @@ EXPORT_SYMBOL(ptlrpc_set_import_active); int ptlrpc_recover_import(struct obd_import *imp, char *new_uuid, int async) { int rc = 0; - ENTRY; spin_lock(&imp->imp_lock); if (imp->imp_state == LUSTRE_IMP_NEW || imp->imp_deactive || @@ -337,7 +325,6 @@ int ptlrpc_recover_import(struct obd_import *imp, char *new_uuid, int async) CDEBUG(D_HA, "%s: recovery finished\n", obd2cli_tgt(imp->imp_obd)); } - EXIT; out: return rc; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 36e8bed5458..962b31d163d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -269,8 +269,8 @@ struct ptlrpc_cli_ctx *get_my_ctx(struct ptlrpc_sec *sec) remove_dead = 0; } } else { - vcred.vc_uid = current_uid(); - vcred.vc_gid = current_gid(); + vcred.vc_uid = from_kuid(&init_user_ns, current_uid()); + vcred.vc_gid = from_kgid(&init_user_ns, current_gid()); } return sec->ps_policy->sp_cops->lookup_ctx(sec, &vcred, @@ -396,14 +396,13 @@ int sptlrpc_req_get_ctx(struct ptlrpc_request *req) struct obd_import *imp = req->rq_import; struct ptlrpc_sec *sec; int rc; - ENTRY; LASSERT(!req->rq_cli_ctx); LASSERT(imp); rc = import_sec_validate_get(imp, &sec); if (rc) - RETURN(rc); + return rc; req->rq_cli_ctx = get_my_ctx(sec); @@ -411,10 +410,10 @@ int sptlrpc_req_get_ctx(struct ptlrpc_request *req) if (!req->rq_cli_ctx) { CERROR("req %p: fail to get context\n", req); - RETURN(-ENOMEM); + return -ENOMEM; } - RETURN(0); + return 0; } /** @@ -428,8 +427,6 @@ int sptlrpc_req_get_ctx(struct ptlrpc_request *req) */ void sptlrpc_req_put_ctx(struct ptlrpc_request *req, int sync) { - ENTRY; - LASSERT(req); LASSERT(req->rq_cli_ctx); @@ -444,7 +441,6 @@ void sptlrpc_req_put_ctx(struct ptlrpc_request *req, int sync) sptlrpc_cli_ctx_put(req->rq_cli_ctx, sync); req->rq_cli_ctx = NULL; - EXIT; } static @@ -520,7 +516,6 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req) struct ptlrpc_cli_ctx *oldctx = req->rq_cli_ctx; struct ptlrpc_cli_ctx *newctx; int rc; - ENTRY; LASSERT(oldctx); @@ -533,7 +528,7 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req) /* restore old ctx */ req->rq_cli_ctx = oldctx; - RETURN(rc); + return rc; } newctx = req->rq_cli_ctx; @@ -560,14 +555,14 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req) /* restore old ctx */ sptlrpc_req_put_ctx(req, 0); req->rq_cli_ctx = oldctx; - RETURN(rc); + return rc; } LASSERT(req->rq_cli_ctx == newctx); } sptlrpc_cli_ctx_put(oldctx, 1); - RETURN(0); + return 0; } EXPORT_SYMBOL(sptlrpc_req_replace_dead_ctx); @@ -639,12 +634,11 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) struct ptlrpc_sec *sec; struct l_wait_info lwi; int rc; - ENTRY; LASSERT(ctx); if (req->rq_ctx_init || req->rq_ctx_fini) - RETURN(0); + return 0; /* * during the process a request's context might change type even @@ -654,7 +648,7 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) again: rc = import_sec_validate_get(req->rq_import, &sec); if (rc) - RETURN(rc); + return rc; if (sec->ps_flvr.sf_rpc != req->rq_flvr.sf_rpc) { CDEBUG(D_SEC, "req %p: flavor has changed %x -> %x\n", @@ -666,7 +660,7 @@ again: sptlrpc_sec_put(sec); if (cli_ctx_is_eternal(ctx)) - RETURN(0); + return 0; if (unlikely(test_bit(PTLRPC_CTX_NEW_BIT, &ctx->cc_flags))) { LASSERT(ctx->cc_ops->refresh); @@ -677,7 +671,7 @@ again: LASSERT(ctx->cc_ops->validate); if (ctx->cc_ops->validate(ctx) == 0) { req_off_ctx_list(req, ctx); - RETURN(0); + return 0; } if (unlikely(test_bit(PTLRPC_CTX_ERROR_BIT, &ctx->cc_flags))) { @@ -685,7 +679,7 @@ again: req->rq_err = 1; spin_unlock(&req->rq_lock); req_off_ctx_list(req, ctx); - RETURN(-EPERM); + return -EPERM; } /* @@ -719,7 +713,7 @@ again: unlikely(req->rq_reqmsg) && lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT) { req_off_ctx_list(req, ctx); - RETURN(0); + return 0; } if (unlikely(test_bit(PTLRPC_CTX_DEAD_BIT, &ctx->cc_flags))) { @@ -731,7 +725,7 @@ again: spin_lock(&req->rq_lock); req->rq_err = 1; spin_unlock(&req->rq_lock); - RETURN(-EINTR); + return -EINTR; } rc = sptlrpc_req_replace_dead_ctx(req); @@ -742,7 +736,7 @@ again: spin_lock(&req->rq_lock); req->rq_err = 1; spin_unlock(&req->rq_lock); - RETURN(rc); + return rc; } ctx = req->rq_cli_ctx; @@ -759,7 +753,7 @@ again: spin_unlock(&ctx->cc_lock); if (timeout < 0) - RETURN(-EWOULDBLOCK); + return -EWOULDBLOCK; /* Clear any flags that may be present from previous sends */ LASSERT(req->rq_receiving_reply == 0); @@ -789,7 +783,7 @@ again: req_off_ctx_list(req, ctx); LASSERT(rc != 0); - RETURN(rc); + return rc; } goto again; @@ -889,7 +883,6 @@ int sptlrpc_import_check_ctx(struct obd_import *imp) struct ptlrpc_cli_ctx *ctx; struct ptlrpc_request *req = NULL; int rc; - ENTRY; might_sleep(); @@ -898,22 +891,22 @@ int sptlrpc_import_check_ctx(struct obd_import *imp) sptlrpc_sec_put(sec); if (!ctx) - RETURN(-ENOMEM); + return -ENOMEM; if (cli_ctx_is_eternal(ctx) || ctx->cc_ops->validate(ctx) == 0) { sptlrpc_cli_ctx_put(ctx, 1); - RETURN(0); + return 0; } if (cli_ctx_is_error(ctx)) { sptlrpc_cli_ctx_put(ctx, 1); - RETURN(-EACCES); + return -EACCES; } OBD_ALLOC_PTR(req); if (!req) - RETURN(-ENOMEM); + return -ENOMEM; spin_lock_init(&req->rq_lock); atomic_set(&req->rq_refcount, 10000); @@ -929,7 +922,7 @@ int sptlrpc_import_check_ctx(struct obd_import *imp) sptlrpc_cli_ctx_put(req->rq_cli_ctx, 1); OBD_FREE_PTR(req); - RETURN(rc); + return rc; } /** @@ -941,7 +934,6 @@ int sptlrpc_cli_wrap_request(struct ptlrpc_request *req) { struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; int rc = 0; - ENTRY; LASSERT(ctx); LASSERT(ctx->cc_sec); @@ -953,7 +945,7 @@ int sptlrpc_cli_wrap_request(struct ptlrpc_request *req) if (req->rq_bulk) { rc = sptlrpc_cli_wrap_bulk(req, req->rq_bulk); if (rc) - RETURN(rc); + return rc; } switch (SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc)) { @@ -977,14 +969,13 @@ int sptlrpc_cli_wrap_request(struct ptlrpc_request *req) LASSERT(req->rq_reqdata_len <= req->rq_reqbuf_len); } - RETURN(rc); + return rc; } static int do_cli_unwrap_reply(struct ptlrpc_request *req) { struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; int rc; - ENTRY; LASSERT(ctx); LASSERT(ctx->cc_sec); @@ -1002,13 +993,13 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) break; default: CERROR("failed unpack reply: x"LPU64"\n", req->rq_xid); - RETURN(-EPROTO); + return -EPROTO; } if (req->rq_repdata_len < sizeof(struct lustre_msg)) { CERROR("replied data length %d too small\n", req->rq_repdata_len); - RETURN(-EPROTO); + return -EPROTO; } if (SPTLRPC_FLVR_POLICY(req->rq_repdata->lm_secflvr) != @@ -1016,7 +1007,7 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) CERROR("reply policy %u doesn't match request policy %u\n", SPTLRPC_FLVR_POLICY(req->rq_repdata->lm_secflvr), SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc)); - RETURN(-EPROTO); + return -EPROTO; } switch (SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc)) { @@ -1038,7 +1029,7 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) if (SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc) != SPTLRPC_POLICY_NULL && !req->rq_ctx_init) req->rq_rep_swab_mask = 0; - RETURN(rc); + return rc; } /** @@ -1096,11 +1087,10 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, char *early_buf; int early_bufsz, early_size; int rc; - ENTRY; OBD_ALLOC_PTR(early_req); if (early_req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; early_size = req->rq_nob_received; early_bufsz = size_roundup_power2(early_size); @@ -1163,7 +1153,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, LASSERT(early_req->rq_repmsg); *req_ret = early_req; - RETURN(0); + return 0; err_ctx: sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1); @@ -1171,7 +1161,7 @@ err_buf: OBD_FREE_LARGE(early_buf, early_bufsz); err_req: OBD_FREE_PTR(early_req); - RETURN(rc); + return rc; } /** @@ -1285,7 +1275,6 @@ struct ptlrpc_sec * sptlrpc_sec_create(struct obd_import *imp, struct ptlrpc_sec_policy *policy; struct ptlrpc_sec *sec; char str[32]; - ENTRY; if (svc_ctx) { LASSERT(imp->imp_dlm_fake == 1); @@ -1308,7 +1297,7 @@ struct ptlrpc_sec * sptlrpc_sec_create(struct obd_import *imp, policy = sptlrpc_wireflavor2policy(sf->sf_rpc); if (!policy) { CERROR("invalid flavor 0x%x\n", sf->sf_rpc); - RETURN(NULL); + return NULL; } } @@ -1324,7 +1313,7 @@ struct ptlrpc_sec * sptlrpc_sec_create(struct obd_import *imp, sptlrpc_policy_put(policy); } - RETURN(sec); + return sec; } struct ptlrpc_sec *sptlrpc_import_sec_ref(struct obd_import *imp) @@ -1406,12 +1395,11 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp, enum lustre_sec_part sp; char str[24]; int rc = 0; - ENTRY; might_sleep(); if (imp == NULL) - RETURN(0); + return 0; conn = imp->imp_connection; @@ -1485,7 +1473,7 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp, mutex_unlock(&imp->imp_sec_mutex); out: sptlrpc_sec_put(sec); - RETURN(rc); + return rc; } void sptlrpc_import_sec_put(struct obd_import *imp) @@ -1523,7 +1511,8 @@ void sptlrpc_import_flush_root_ctx(struct obd_import *imp) void sptlrpc_import_flush_my_ctx(struct obd_import *imp) { - import_flush_ctx_common(imp, current_uid(), 1, 1); + import_flush_ctx_common(imp, from_kuid(&init_user_ns, current_uid()), + 1, 1); } EXPORT_SYMBOL(sptlrpc_import_flush_my_ctx); @@ -1668,17 +1657,16 @@ int sptlrpc_cli_alloc_repbuf(struct ptlrpc_request *req, int msgsize) { struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; struct ptlrpc_sec_policy *policy; - ENTRY; LASSERT(ctx); LASSERT(ctx->cc_sec); LASSERT(ctx->cc_sec->ps_policy); if (req->rq_repbuf) - RETURN(0); + return 0; policy = ctx->cc_sec->ps_policy; - RETURN(policy->sp_cops->alloc_repbuf(ctx->cc_sec, req, msgsize)); + return policy->sp_cops->alloc_repbuf(ctx->cc_sec, req, msgsize); } /** @@ -1689,7 +1677,6 @@ void sptlrpc_cli_free_repbuf(struct ptlrpc_request *req) { struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; struct ptlrpc_sec_policy *policy; - ENTRY; LASSERT(ctx); LASSERT(ctx->cc_sec); @@ -1703,7 +1690,6 @@ void sptlrpc_cli_free_repbuf(struct ptlrpc_request *req) policy = ctx->cc_sec->ps_policy; policy->sp_cops->free_repbuf(ctx->cc_sec, req); req->rq_repmsg = NULL; - EXIT; } int sptlrpc_cli_install_rvs_ctx(struct obd_import *imp, @@ -2032,7 +2018,6 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) struct ptlrpc_sec_policy *policy; struct lustre_msg *msg = req->rq_reqbuf; int rc; - ENTRY; LASSERT(msg); LASSERT(req->rq_reqmsg == NULL); @@ -2050,18 +2035,18 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) default: CERROR("error unpacking request from %s x"LPU64"\n", libcfs_id2str(req->rq_peer), req->rq_xid); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } req->rq_flvr.sf_rpc = WIRE_FLVR(msg->lm_secflvr); req->rq_sp_from = LUSTRE_SP_ANY; - req->rq_auth_uid = INVALID_UID; - req->rq_auth_mapped_uid = INVALID_UID; + req->rq_auth_uid = -1; + req->rq_auth_mapped_uid = -1; policy = sptlrpc_wireflavor2policy(req->rq_flvr.sf_rpc); if (!policy) { CERROR("unsupported rpc flavor %x\n", req->rq_flvr.sf_rpc); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } LASSERT(policy->sp_sops->accept); @@ -2079,7 +2064,7 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) /* sanity check for the request source */ rc = sptlrpc_svc_check_from(req, rc); - RETURN(rc); + return rc; } /** @@ -2092,7 +2077,6 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen) struct ptlrpc_sec_policy *policy; struct ptlrpc_reply_state *rs; int rc; - ENTRY; LASSERT(req->rq_svc_ctx); LASSERT(req->rq_svc_ctx->sc_policy); @@ -2105,7 +2089,7 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen) /* failed alloc, try emergency pool */ rs = lustre_get_emerg_rs(req->rq_rqbd->rqbd_svcpt); if (rs == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_reply_state = rs; rc = policy->sp_sops->alloc_rs(req, msglen); @@ -2118,7 +2102,7 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen) LASSERT(rc != 0 || (req->rq_reply_state && req->rq_reply_state->rs_msg)); - RETURN(rc); + return rc; } /** @@ -2131,7 +2115,6 @@ int sptlrpc_svc_wrap_reply(struct ptlrpc_request *req) { struct ptlrpc_sec_policy *policy; int rc; - ENTRY; LASSERT(req->rq_svc_ctx); LASSERT(req->rq_svc_ctx->sc_policy); @@ -2142,7 +2125,7 @@ int sptlrpc_svc_wrap_reply(struct ptlrpc_request *req) rc = policy->sp_sops->authorize(req); LASSERT(rc || req->rq_reply_state->rs_repdata_len); - RETURN(rc); + return rc; } /** @@ -2152,7 +2135,6 @@ void sptlrpc_svc_free_rs(struct ptlrpc_reply_state *rs) { struct ptlrpc_sec_policy *policy; unsigned int prealloc; - ENTRY; LASSERT(rs->rs_svc_ctx); LASSERT(rs->rs_svc_ctx->sc_policy); @@ -2165,7 +2147,6 @@ void sptlrpc_svc_free_rs(struct ptlrpc_reply_state *rs) if (prealloc) lustre_put_emerg_rs(rs); - EXIT; } void sptlrpc_svc_ctx_addref(struct ptlrpc_request *req) @@ -2314,10 +2295,10 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int offset) pud = lustre_msg_buf(msg, offset, 0); - pud->pud_uid = current_uid(); - pud->pud_gid = current_gid(); - pud->pud_fsuid = current_fsuid(); - pud->pud_fsgid = current_fsgid(); + pud->pud_uid = from_kuid(&init_user_ns, current_uid()); + pud->pud_gid = from_kgid(&init_user_ns, current_gid()); + pud->pud_fsuid = from_kuid(&init_user_ns, current_fsuid()); + pud->pud_fsgid = from_kgid(&init_user_ns, current_fsgid()); pud->pud_cap = cfs_curproc_cap_pack(); pud->pud_ngroups = (msg->lm_buflens[offset] - sizeof(*pud)) / 4; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index bf53f1bc174..6547f46a772 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -59,8 +59,8 @@ ****************************************/ -#define PTRS_PER_PAGE (PAGE_CACHE_SIZE / sizeof(void *)) -#define PAGES_PER_POOL (PTRS_PER_PAGE) +#define POINTERS_PER_PAGE (PAGE_CACHE_SIZE / sizeof(void *)) +#define PAGES_PER_POOL (POINTERS_PER_PAGE) #define IDLE_IDX_MAX (100) #define IDLE_IDX_WEIGHT (3) @@ -121,13 +121,6 @@ static struct ptlrpc_enc_page_pool { } page_pools; /* - * memory shrinker - */ -const int pools_shrinker_seeks = DEFAULT_SEEKS; -static struct shrinker *pools_shrinker = NULL; - - -/* * /proc/fs/lustre/sptlrpc/encrypt_page_pools */ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v) @@ -156,7 +149,7 @@ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v) "max waitqueue depth: %u\n" "max wait time: "CFS_TIME_T"/%u\n" , - num_physpages, + totalram_pages, PAGES_PER_POOL, page_pools.epp_max_pages, page_pools.epp_max_pools, @@ -226,30 +219,46 @@ static void enc_pools_release_free_pages(long npages) } /* - * could be called frequently for query (@nr_to_scan == 0). * we try to keep at least PTLRPC_MAX_BRW_PAGES pages in the pool. */ -static int enc_pools_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask)) +static unsigned long enc_pools_shrink_count(struct shrinker *s, + struct shrink_control *sc) { - if (unlikely(shrink_param(sc, nr_to_scan) != 0)) { + /* + * 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 > + CACHE_QUIESCENT_PERIOD)) { spin_lock(&page_pools.epp_lock); - shrink_param(sc, nr_to_scan) = min_t(unsigned long, - shrink_param(sc, nr_to_scan), - page_pools.epp_free_pages - - PTLRPC_MAX_BRW_PAGES); - if (shrink_param(sc, nr_to_scan) > 0) { - enc_pools_release_free_pages(shrink_param(sc, - nr_to_scan)); - CDEBUG(D_SEC, "released %ld pages, %ld left\n", - (long)shrink_param(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_idle_idx = IDLE_IDX_MAX; spin_unlock(&page_pools.epp_lock); } + LASSERT(page_pools.epp_idle_idx <= IDLE_IDX_MAX); + return max((int)page_pools.epp_free_pages - PTLRPC_MAX_BRW_PAGES, 0) * + (IDLE_IDX_MAX - page_pools.epp_idle_idx) / IDLE_IDX_MAX; +} + +/* + * we try to keep at least PTLRPC_MAX_BRW_PAGES pages in the pool. + */ +static unsigned long enc_pools_shrink_scan(struct shrinker *s, + struct shrink_control *sc) +{ + spin_lock(&page_pools.epp_lock); + sc->nr_to_scan = min_t(unsigned long, sc->nr_to_scan, + page_pools.epp_free_pages - PTLRPC_MAX_BRW_PAGES); + if (sc->nr_to_scan > 0) { + enc_pools_release_free_pages(sc->nr_to_scan); + CDEBUG(D_SEC, "released %ld pages, %ld left\n", + (long)sc->nr_to_scan, page_pools.epp_free_pages); + + page_pools.epp_st_shrinks++; + page_pools.epp_last_shrink = cfs_time_current_sec(); + } + spin_unlock(&page_pools.epp_lock); + /* * if no pool access for a long time, we consider it's fully idle. * a little race here is fine. @@ -262,8 +271,7 @@ static int enc_pools_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask)) } LASSERT(page_pools.epp_idle_idx <= IDLE_IDX_MAX); - return max((int)page_pools.epp_free_pages - PTLRPC_MAX_BRW_PAGES, 0) * - (IDLE_IDX_MAX - page_pools.epp_idle_idx) / IDLE_IDX_MAX; + return sc->nr_to_scan; } static inline @@ -699,13 +707,19 @@ static inline void enc_pools_free(void) sizeof(*page_pools.epp_pools)); } +static struct shrinker pools_shrinker = { + .count_objects = enc_pools_shrink_count, + .scan_objects = enc_pools_shrink_scan, + .seeks = DEFAULT_SEEKS, +}; + int sptlrpc_enc_pool_init(void) { /* * maximum capacity is 1/8 of total physical memory. * is the 1/8 a good number? */ - page_pools.epp_max_pages = num_physpages / 8; + page_pools.epp_max_pages = totalram_pages / 8; page_pools.epp_max_pools = npages_to_npools(page_pools.epp_max_pages); init_waitqueue_head(&page_pools.epp_waitq); @@ -736,12 +750,7 @@ int sptlrpc_enc_pool_init(void) if (page_pools.epp_pools == NULL) return -ENOMEM; - pools_shrinker = set_shrinker(pools_shrinker_seeks, - enc_pools_shrink); - if (pools_shrinker == NULL) { - enc_pools_free(); - return -ENOMEM; - } + register_shrinker(&pools_shrinker); return 0; } @@ -750,11 +759,10 @@ void sptlrpc_enc_pool_fini(void) { unsigned long cleaned, npools; - LASSERT(pools_shrinker); LASSERT(page_pools.epp_pools); LASSERT(page_pools.epp_total_pages == page_pools.epp_free_pages); - remove_shrinker(pools_shrinker); + unregister_shrinker(&pools_shrinker); npools = npages_to_npools(page_pools.epp_total_pages); cleaned = enc_pools_cleanup(page_pools.epp_pools, npools); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index a45a3929b59..6cc3f23c27c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -195,7 +195,7 @@ int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) flavor = strchr(param, '='); if (flavor == NULL) { CERROR("invalid param, no '='\n"); - RETURN(-EINVAL); + return -EINVAL; } *flavor++ = '\0'; @@ -208,7 +208,7 @@ int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) rule->sr_netid = libcfs_str2net(param); if (rule->sr_netid == LNET_NIDNET(LNET_NID_ANY)) { CERROR("invalid network name: %s\n", param); - RETURN(-EINVAL); + return -EINVAL; } } @@ -228,16 +228,16 @@ int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) rule->sr_to = LUSTRE_SP_MDT; } else { CERROR("invalid rule dir segment: %s\n", dir); - RETURN(-EINVAL); + return -EINVAL; } } /* 2.1 flavor */ rc = sptlrpc_parse_flavor(flavor, &rule->sr_flvr); if (rc) - RETURN(-EINVAL); + return -EINVAL; - RETURN(0); + return 0; } EXPORT_SYMBOL(sptlrpc_parse_rule); @@ -661,18 +661,17 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, char fsname[MTI_NAME_MAXLEN]; struct sptlrpc_rule rule; int rc; - ENTRY; target = lustre_cfg_string(lcfg, 1); if (target == NULL) { CERROR("missing target name\n"); - RETURN(-EINVAL); + return -EINVAL; } param = lustre_cfg_string(lcfg, 2); if (param == NULL) { CERROR("missing parameter\n"); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_SEC, "processing rule: %s.%s\n", target, param); @@ -680,13 +679,13 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, /* parse rule to make sure the format is correct */ if (strncmp(param, PARAM_SRPC_FLVR, sizeof(PARAM_SRPC_FLVR) - 1) != 0) { CERROR("Invalid sptlrpc parameter: %s\n", param); - RETURN(-EINVAL); + return -EINVAL; } param += sizeof(PARAM_SRPC_FLVR) - 1; rc = sptlrpc_parse_rule(param, &rule); if (rc) - RETURN(-EINVAL); + return -EINVAL; if (conf == NULL) { target2fsname(target, fsname, sizeof(fsname)); @@ -708,7 +707,7 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, if (rc == 0) conf->sc_modified++; - RETURN(rc); + return rc; } int sptlrpc_process_config(struct lustre_cfg *lcfg) @@ -905,7 +904,6 @@ EXPORT_SYMBOL(sptlrpc_target_choose_flavor); void sptlrpc_conf_client_adapt(struct obd_device *obd) { struct obd_import *imp; - ENTRY; LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 || strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) ==0); @@ -924,7 +922,6 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd) } up_read(&obd->u.cli.cl_sem); - EXIT; } EXPORT_SYMBOL(sptlrpc_conf_client_adapt); @@ -1011,11 +1008,10 @@ int sptlrpc_target_local_copy_conf(struct obd_device *obd, struct lvfs_run_ctxt saved; struct dentry *dentry; int rc; - ENTRY; ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt == NULL) - RETURN(-EINVAL); + return -EINVAL; push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); @@ -1058,7 +1054,7 @@ out_ctx: llog_ctxt_put(ctxt); CDEBUG(D_SEC, "target %s: write local sptlrpc conf: rc = %d\n", obd->obd_name, rc); - RETURN(rc); + return rc; } static int local_read_handler(const struct lu_env *env, @@ -1068,11 +1064,10 @@ static int local_read_handler(const struct lu_env *env, struct sptlrpc_conf *conf = (struct sptlrpc_conf *) data; struct lustre_cfg *lcfg = (struct lustre_cfg *)(rec + 1); int cfg_len, rc; - ENTRY; if (rec->lrh_type != OBD_CFG_REC) { CERROR("unhandled lrh_type: %#x\n", rec->lrh_type); - RETURN(-EINVAL); + return -EINVAL; } cfg_len = rec->lrh_len - sizeof(struct llog_rec_hdr) - @@ -1081,15 +1076,15 @@ static int local_read_handler(const struct lu_env *env, rc = lustre_cfg_sanity_check(lcfg, cfg_len); if (rc) { CERROR("Insane cfg\n"); - RETURN(rc); + return rc; } if (lcfg->lcfg_command != LCFG_SPTLRPC_CONF) { CERROR("invalid command (%x)\n", lcfg->lcfg_command); - RETURN(-EINVAL); + return -EINVAL; } - RETURN(__sptlrpc_process_config(lcfg, conf)); + return __sptlrpc_process_config(lcfg, conf); } static @@ -1100,14 +1095,13 @@ int sptlrpc_target_local_read_conf(struct obd_device *obd, struct llog_ctxt *ctxt; struct lvfs_run_ctxt saved; int rc; - ENTRY; LASSERT(conf->sc_updated == 0 && conf->sc_local == 0); ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt == NULL) { CERROR("missing llog context\n"); - RETURN(-EINVAL); + return -EINVAL; } push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); @@ -1143,7 +1137,7 @@ out_pop: llog_ctxt_put(ctxt); CDEBUG(D_SEC, "target %s: read local sptlrpc conf: rc = %d\n", obd->obd_name, rc); - RETURN(rc); + return rc; } @@ -1160,7 +1154,6 @@ int sptlrpc_conf_target_get_rules(struct obd_device *obd, enum lustre_sec_part sp_dst; char fsname[MTI_NAME_MAXLEN]; int rc = 0; - ENTRY; if (strcmp(obd->obd_type->typ_name, LUSTRE_MDT_NAME) == 0) { sp_dst = LUSTRE_SP_MDT; @@ -1168,7 +1161,7 @@ int sptlrpc_conf_target_get_rules(struct obd_device *obd, sp_dst = LUSTRE_SP_OST; } else { CERROR("unexpected obd type %s\n", obd->obd_type->typ_name); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_SEC, "get rules for target %s\n", obd->obd_uuid.uuid); @@ -1210,7 +1203,7 @@ int sptlrpc_conf_target_get_rules(struct obd_device *obd, LUSTRE_SP_ANY, sp_dst, rset); out: mutex_unlock(&sptlrpc_conf_lock); - RETURN(rc); + return rc; } EXPORT_SYMBOL(sptlrpc_conf_target_get_rules); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index 4c96a14a1bb..d2eb20eb56d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c @@ -217,7 +217,7 @@ again: int sptlrpc_gc_init(void) { struct l_wait_info lwi = { 0 }; - task_t *task; + struct task_struct *task; mutex_init(&sec_gc_mutex); spin_lock_init(&sec_gc_list_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index f552d2f182b..416401be6d4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -192,7 +192,6 @@ int plain_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) { struct lustre_msg *msg = req->rq_reqbuf; struct plain_header *phdr; - ENTRY; msg->lm_secflvr = req->rq_flvr.sf_rpc; @@ -209,7 +208,7 @@ int plain_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) req->rq_reqdata_len = lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens); - RETURN(0); + return 0; } static @@ -219,11 +218,10 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) struct plain_header *phdr; __u32 cksum; int swabbed; - ENTRY; if (msg->lm_bufcount != PLAIN_PACK_SEGMENTS) { CERROR("unexpected reply buf count %u\n", msg->lm_bufcount); - RETURN(-EPROTO); + return -EPROTO; } swabbed = ptlrpc_rep_need_swab(req); @@ -231,24 +229,24 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) phdr = lustre_msg_buf(msg, PLAIN_PACK_HDR_OFF, sizeof(*phdr)); if (phdr == NULL) { CERROR("missing plain header\n"); - RETURN(-EPROTO); + return -EPROTO; } if (phdr->ph_ver != 0) { CERROR("Invalid header version\n"); - RETURN(-EPROTO); + return -EPROTO; } /* expect no user desc in reply */ if (phdr->ph_flags & PLAIN_FL_USER) { CERROR("Unexpected udesc flag in reply\n"); - RETURN(-EPROTO); + return -EPROTO; } if (phdr->ph_bulk_hash_alg != req->rq_flvr.u_bulk.hash.hash_alg) { CERROR("reply bulk flavor %u != %u\n", phdr->ph_bulk_hash_alg, req->rq_flvr.u_bulk.hash.hash_alg); - RETURN(-EPROTO); + return -EPROTO; } if (unlikely(req->rq_early)) { @@ -262,7 +260,7 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) CDEBUG(D_SEC, "early reply checksum mismatch: %08x != %08x\n", cpu_to_le32(cksum), msg->lm_cksum); - RETURN(-EINVAL); + return -EINVAL; } } else { /* whether we sent with bulk or not, we expect the same @@ -272,18 +270,18 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) phdr->ph_flags & PLAIN_FL_BULK)) { CERROR("%s bulk checksum in reply\n", req->rq_pack_bulk ? "Missing" : "Unexpected"); - RETURN(-EPROTO); + return -EPROTO; } if (phdr->ph_flags & PLAIN_FL_BULK) { if (plain_unpack_bsd(msg, swabbed)) - RETURN(-EPROTO); + return -EPROTO; } } req->rq_repmsg = lustre_msg_buf(msg, PLAIN_PACK_MSG_OFF, 0); req->rq_replen = lustre_msg_buflen(msg, PLAIN_PACK_MSG_OFF); - RETURN(0); + return 0; } static @@ -307,10 +305,10 @@ int plain_cli_wrap_bulk(struct ptlrpc_cli_ctx *ctx, bsd->bsd_svc = SPTLRPC_FLVR_BULK_SVC(req->rq_flvr.sf_rpc); if (bsd->bsd_svc == SPTLRPC_BULK_SVC_NULL) - RETURN(0); + return 0; if (req->rq_bulk_read) - RETURN(0); + return 0; rc = plain_generate_bulk_csum(desc, req->rq_flvr.u_bulk.hash.hash_alg, token); @@ -417,7 +415,6 @@ static void plain_destroy_sec(struct ptlrpc_sec *sec) { struct plain_sec *plsec = sec2plsec(sec); - ENTRY; LASSERT(sec->ps_policy == &plain_policy); LASSERT(sec->ps_import); @@ -428,7 +425,6 @@ void plain_destroy_sec(struct ptlrpc_sec *sec) class_import_put(sec->ps_import); OBD_FREE_PTR(plsec); - EXIT; } static @@ -445,13 +441,12 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, struct plain_sec *plsec; struct ptlrpc_sec *sec; struct ptlrpc_cli_ctx *ctx; - ENTRY; LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN); OBD_ALLOC_PTR(plsec); if (plsec == NULL) - RETURN(NULL); + return NULL; /* * initialize plain_sec @@ -476,12 +471,12 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, ctx = plain_sec_install_ctx(plsec); if (ctx == NULL) { plain_destroy_sec(sec); - RETURN(NULL); + return NULL; } sptlrpc_cli_ctx_put(ctx, 1); } - RETURN(sec); + return sec; } static @@ -491,7 +486,6 @@ struct ptlrpc_cli_ctx *plain_lookup_ctx(struct ptlrpc_sec *sec, { struct plain_sec *plsec = sec2plsec(sec); struct ptlrpc_cli_ctx *ctx; - ENTRY; read_lock(&plsec->pls_lock); ctx = plsec->pls_ctx; @@ -502,7 +496,7 @@ struct ptlrpc_cli_ctx *plain_lookup_ctx(struct ptlrpc_sec *sec, if (unlikely(ctx == NULL)) ctx = plain_sec_install_ctx(plsec); - RETURN(ctx); + return ctx; } static @@ -526,11 +520,10 @@ int plain_flush_ctx_cache(struct ptlrpc_sec *sec, { struct plain_sec *plsec = sec2plsec(sec); struct ptlrpc_cli_ctx *ctx; - ENTRY; /* do nothing unless caller want to flush for 'all' */ if (uid != -1) - RETURN(0); + return 0; write_lock(&plsec->pls_lock); ctx = plsec->pls_ctx; @@ -539,7 +532,7 @@ int plain_flush_ctx_cache(struct ptlrpc_sec *sec, if (ctx) sptlrpc_cli_ctx_put(ctx, 1); - RETURN(0); + return 0; } static @@ -549,7 +542,6 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec, { __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, }; int alloc_len; - ENTRY; buflens[PLAIN_PACK_HDR_OFF] = sizeof(struct plain_header); buflens[PLAIN_PACK_MSG_OFF] = msgsize; @@ -570,7 +562,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec, alloc_len = size_roundup_power2(alloc_len); OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_len); if (!req->rq_reqbuf) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_reqbuf_len = alloc_len; } else { @@ -585,20 +577,18 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec, if (req->rq_pack_udesc) sptlrpc_pack_user_desc(req->rq_reqbuf, PLAIN_PACK_USER_OFF); - RETURN(0); + return 0; } static void plain_free_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req) { - ENTRY; if (!req->rq_pool) { OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } - EXIT; } static @@ -608,7 +598,6 @@ int plain_alloc_repbuf(struct ptlrpc_sec *sec, { __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, }; int alloc_len; - ENTRY; buflens[PLAIN_PACK_HDR_OFF] = sizeof(struct plain_header); buflens[PLAIN_PACK_MSG_OFF] = msgsize; @@ -627,21 +616,19 @@ int plain_alloc_repbuf(struct ptlrpc_sec *sec, OBD_ALLOC_LARGE(req->rq_repbuf, alloc_len); if (!req->rq_repbuf) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_repbuf_len = alloc_len; - RETURN(0); + return 0; } static void plain_free_repbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req) { - ENTRY; OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len); req->rq_repbuf = NULL; req->rq_repbuf_len = 0; - EXIT; } static @@ -652,7 +639,6 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, struct lustre_msg *newbuf; int oldsize; int newmsg_size, newbuf_size; - ENTRY; LASSERT(req->rq_reqbuf); LASSERT(req->rq_reqbuf_len >= req->rq_reqlen); @@ -681,7 +667,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, OBD_ALLOC_LARGE(newbuf, newbuf_size); if (newbuf == NULL) - RETURN(-ENOMEM); + return -ENOMEM; memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len); @@ -697,7 +683,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize); req->rq_reqlen = newmsg_size; - RETURN(0); + return 0; } /**************************************** @@ -715,7 +701,6 @@ int plain_accept(struct ptlrpc_request *req) struct lustre_msg *msg = req->rq_reqbuf; struct plain_header *phdr; int swabbed; - ENTRY; LASSERT(SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc) == SPTLRPC_POLICY_PLAIN); @@ -725,12 +710,12 @@ int plain_accept(struct ptlrpc_request *req) SPTLRPC_FLVR_BULK_TYPE(req->rq_flvr.sf_rpc) != SPTLRPC_FLVR_BULK_TYPE(SPTLRPC_FLVR_PLAIN)) { CERROR("Invalid rpc flavor %x\n", req->rq_flvr.sf_rpc); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } if (msg->lm_bufcount < PLAIN_PACK_SEGMENTS) { CERROR("unexpected request buf count %u\n", msg->lm_bufcount); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } swabbed = ptlrpc_req_need_swab(req); @@ -738,17 +723,17 @@ int plain_accept(struct ptlrpc_request *req) phdr = lustre_msg_buf(msg, PLAIN_PACK_HDR_OFF, sizeof(*phdr)); if (phdr == NULL) { CERROR("missing plain header\n"); - RETURN(-EPROTO); + return -EPROTO; } if (phdr->ph_ver != 0) { CERROR("Invalid header version\n"); - RETURN(-EPROTO); + return -EPROTO; } if (phdr->ph_bulk_hash_alg >= BULK_HASH_ALG_MAX) { CERROR("invalid hash algorithm: %u\n", phdr->ph_bulk_hash_alg); - RETURN(-EPROTO); + return -EPROTO; } req->rq_sp_from = phdr->ph_sp; @@ -758,7 +743,7 @@ int plain_accept(struct ptlrpc_request *req) if (sptlrpc_unpack_user_desc(msg, PLAIN_PACK_USER_OFF, swabbed)) { CERROR("Mal-formed user descriptor\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } req->rq_pack_udesc = 1; @@ -767,7 +752,7 @@ int plain_accept(struct ptlrpc_request *req) if (phdr->ph_flags & PLAIN_FL_BULK) { if (plain_unpack_bsd(msg, swabbed)) - RETURN(SECSVC_DROP); + return SECSVC_DROP; req->rq_pack_bulk = 1; } @@ -778,7 +763,7 @@ int plain_accept(struct ptlrpc_request *req) req->rq_svc_ctx = &plain_svc_ctx; atomic_inc(&req->rq_svc_ctx->sc_refcount); - RETURN(SECSVC_OK); + return SECSVC_OK; } static @@ -787,7 +772,6 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) struct ptlrpc_reply_state *rs; __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, }; int rs_size = sizeof(*rs); - ENTRY; LASSERT(msgsize % 8 == 0); @@ -807,7 +791,7 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) } else { OBD_ALLOC_LARGE(rs, rs_size); if (rs == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rs->rs_size = rs_size; } @@ -821,20 +805,17 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) rs->rs_msg = lustre_msg_buf_v2(rs->rs_repbuf, PLAIN_PACK_MSG_OFF, 0); req->rq_reply_state = rs; - RETURN(0); + return 0; } static void plain_free_rs(struct ptlrpc_reply_state *rs) { - ENTRY; - LASSERT(atomic_read(&rs->rs_svc_ctx->sc_refcount) > 1); atomic_dec(&rs->rs_svc_ctx->sc_refcount); if (!rs->rs_prealloc) OBD_FREE_LARGE(rs, rs->rs_size); - EXIT; } static @@ -844,7 +825,6 @@ int plain_authorize(struct ptlrpc_request *req) struct lustre_msg_v2 *msg = rs->rs_repbuf; struct plain_header *phdr; int len; - ENTRY; LASSERT(rs); LASSERT(msg); @@ -882,7 +862,7 @@ int plain_authorize(struct ptlrpc_request *req) req->rq_reply_off = 0; } - RETURN(0); + return 0; } static diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 1667b8e8601..acf75f3873d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -369,7 +369,6 @@ static void rs_batch_fini(struct rs_batch *b) void ptlrpc_dispatch_difficult_reply(struct ptlrpc_reply_state *rs) { struct ptlrpc_hr_thread *hrt; - ENTRY; LASSERT(list_empty(&rs->rs_list)); @@ -380,28 +379,23 @@ void ptlrpc_dispatch_difficult_reply(struct ptlrpc_reply_state *rs) spin_unlock(&hrt->hrt_lock); wake_up(&hrt->hrt_waitq); - EXIT; } void ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs) { - ENTRY; - LASSERT(spin_is_locked(&rs->rs_svcpt->scp_rep_lock)); LASSERT(spin_is_locked(&rs->rs_lock)); LASSERT (rs->rs_difficult); rs->rs_scheduled_ever = 1; /* flag any notification attempt */ if (rs->rs_scheduled) { /* being set up or already notified */ - EXIT; return; } rs->rs_scheduled = 1; list_del_init(&rs->rs_list); ptlrpc_dispatch_difficult_reply(rs); - EXIT; } EXPORT_SYMBOL(ptlrpc_schedule_difficult_reply); @@ -409,7 +403,6 @@ void ptlrpc_commit_replies(struct obd_export *exp) { struct ptlrpc_reply_state *rs, *nxt; DECLARE_RS_BATCH(batch); - ENTRY; rs_batch_init(&batch); /* Find any replies that have been committed and get their service @@ -429,7 +422,6 @@ void ptlrpc_commit_replies(struct obd_export *exp) } spin_unlock(&exp->exp_uncommitted_replies_lock); rs_batch_fini(&batch); - EXIT; } EXPORT_SYMBOL(ptlrpc_commit_replies); @@ -551,6 +543,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, if (tc->tc_thr_factor != 0) { int factor = tc->tc_thr_factor; const int fade = 4; + cpumask_t mask; /* * User wants to increase number of threads with for @@ -564,7 +557,8 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, * have too many threads no matter how many cores/HTs * there are. */ - if (cfs_cpu_ht_nsiblings(0) > 1) { /* weight is # of HTs */ + cpumask_copy(&mask, topology_thread_cpumask(0)); + if (cpus_weight(mask) > 1) { /* weight is # of HTs */ /* depress thread factor for hyper-thread */ factor = factor - (factor >> 1) + (factor >> 3); } @@ -689,7 +683,7 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, */ struct ptlrpc_service * ptlrpc_register_service(struct ptlrpc_service_conf *conf, - proc_dir_entry_t *proc_entry) + struct proc_dir_entry *proc_entry) { struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt; struct ptlrpc_service *service; @@ -700,7 +694,6 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, int cpt; int rc; int i; - ENTRY; LASSERT(conf->psc_buf.bc_nbufs > 0); LASSERT(conf->psc_buf.bc_buf_size >= @@ -724,7 +717,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, if (rc != 0) { CERROR("%s: invalid CPT pattern string: %s", conf->psc_name, cconf->cc_pattern); - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); } rc = cfs_expr_list_values(el, ncpts, &cpts); @@ -734,7 +727,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, conf->psc_name, cconf->cc_pattern, rc); if (cpts != NULL) OBD_FREE(cpts, sizeof(*cpts) * ncpts); - RETURN(ERR_PTR(rc < 0 ? rc : -EINVAL)); + return ERR_PTR(rc < 0 ? rc : -EINVAL); } ncpts = rc; } @@ -744,7 +737,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, if (service == NULL) { if (cpts != NULL) OBD_FREE(cpts, sizeof(*cpts) * ncpts); - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); } service->srv_cptable = cptable; @@ -823,10 +816,10 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, GOTO(failed, rc); } - RETURN(service); + return service; failed: ptlrpc_unregister_service(service); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } EXPORT_SYMBOL(ptlrpc_register_service); @@ -1035,8 +1028,6 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) struct obd_export *oldest_exp; time_t oldest_time, new_time; - ENTRY; - LASSERT(exp); /* Compensate for slow machines, etc, by faking our request time @@ -1048,7 +1039,7 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) /* Do not pay attention on 1sec or smaller renewals. */ new_time = cfs_time_current_sec() + extra_delay; if (exp->exp_last_request_time + 1 /*second */ >= new_time) - RETURN_EXIT; + return; exp->exp_last_request_time = new_time; CDEBUG(D_HA, "updating export %s at "CFS_TIME_T" exp %p\n", @@ -1063,7 +1054,7 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) if (list_empty(&exp->exp_obd_chain_timed)) { /* this one is not timed */ spin_unlock(&exp->exp_obd->obd_dev_lock); - RETURN_EXIT; + return; } list_move_tail(&exp->exp_obd_chain_timed, @@ -1076,7 +1067,6 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) if (exp->exp_obd->obd_recovering) { /* be nice to everyone during recovery */ - EXIT; return; } @@ -1105,8 +1095,6 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) exp->exp_obd->obd_eviction_timer = 0; } } - - EXIT; } /** @@ -1259,7 +1247,6 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) cfs_duration_t olddl = req->rq_deadline - cfs_time_current_sec(); time_t newdl; int rc; - ENTRY; /* deadline is when the client expects us to reply, margin is the difference between clients' and servers' expectations */ @@ -1270,7 +1257,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) at_get(&svcpt->scp_at_estimate), at_extra); if (AT_OFF) - RETURN(0); + return 0; if (olddl < 0) { DEBUG_REQ(D_WARNING, req, "Already past deadline (%+lds), " @@ -1278,13 +1265,13 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) "at_early_margin (%d)?", olddl, at_early_margin); /* Return an error so we're not re-added to the timed list. */ - RETURN(-ETIMEDOUT); + return -ETIMEDOUT; } if ((lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT) == 0){ DEBUG_REQ(D_INFO, req, "Wanted to ask client for more time, " "but no AT support"); - RETURN(-ENOSYS); + return -ENOSYS; } if (req->rq_export && @@ -1314,18 +1301,18 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) olddl, req->rq_arrival_time.tv_sec + at_get(&svcpt->scp_at_estimate) - cfs_time_current_sec()); - RETURN(-ETIMEDOUT); + return -ETIMEDOUT; } } newdl = cfs_time_current_sec() + at_get(&svcpt->scp_at_estimate); OBD_ALLOC(reqcopy, sizeof *reqcopy); if (reqcopy == NULL) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC_LARGE(reqmsg, req->rq_reqlen); if (!reqmsg) { OBD_FREE(reqcopy, sizeof *reqcopy); - RETURN(-ENOMEM); + return -ENOMEM; } *reqcopy = *req; @@ -1384,7 +1371,7 @@ out: sptlrpc_svc_ctx_decref(reqcopy); OBD_FREE_LARGE(reqmsg, req->rq_reqlen); OBD_FREE(reqcopy, sizeof *reqcopy); - RETURN(rc); + return rc; } /* Send early replies to everybody expiring within at_early_margin @@ -1399,19 +1386,18 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) time_t now = cfs_time_current_sec(); cfs_duration_t delay; int first, counter = 0; - ENTRY; spin_lock(&svcpt->scp_at_lock); if (svcpt->scp_at_check == 0) { spin_unlock(&svcpt->scp_at_lock); - RETURN(0); + return 0; } delay = cfs_time_sub(cfs_time_current(), svcpt->scp_at_checktime); svcpt->scp_at_check = 0; if (array->paa_count == 0) { spin_unlock(&svcpt->scp_at_lock); - RETURN(0); + return 0; } /* The timer went off, but maybe the nearest rpc already completed. */ @@ -1420,7 +1406,7 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) /* We've still got plenty of time. Reset the timer. */ ptlrpc_at_set_timer(svcpt); spin_unlock(&svcpt->scp_at_lock); - RETURN(0); + return 0; } /* We're close to a timeout, and we don't know how much longer the @@ -1490,7 +1476,7 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) ptlrpc_server_drop_request(rq); } - RETURN(1); /* return "did_something" for liblustre */ + return 1; /* return "did_something" for liblustre */ } /** @@ -1501,12 +1487,11 @@ static int ptlrpc_server_hpreq_init(struct ptlrpc_service_part *svcpt, struct ptlrpc_request *req) { int rc = 0; - ENTRY; if (svcpt->scp_service->srv_ops.so_hpreq_handler) { rc = svcpt->scp_service->srv_ops.so_hpreq_handler(req); if (rc < 0) - RETURN(rc); + return rc; LASSERT(rc == 0); } if (req->rq_export && req->rq_ops) { @@ -1527,7 +1512,7 @@ static int ptlrpc_server_hpreq_init(struct ptlrpc_service_part *svcpt, * ost_brw_write(). */ if (rc < 0) - RETURN(rc); + return rc; LASSERT(rc == 0 || rc == 1); } @@ -1539,13 +1524,12 @@ static int ptlrpc_server_hpreq_init(struct ptlrpc_service_part *svcpt, ptlrpc_nrs_req_initialize(svcpt, req, rc); - RETURN(rc); + return rc; } /** Remove the request from the export list. */ static void ptlrpc_server_hpreq_fini(struct ptlrpc_request *req) { - ENTRY; if (req->rq_export && req->rq_ops) { /* refresh lock timeout again so that client has more * room to send lock cancel RPC. */ @@ -1556,7 +1540,6 @@ static void ptlrpc_server_hpreq_fini(struct ptlrpc_request *req) list_del_init(&req->rq_exp_list); spin_unlock_bh(&req->rq_export->exp_rpc_lock); } - EXIT; } static int ptlrpc_hpreq_check(struct ptlrpc_request *req) @@ -1587,15 +1570,14 @@ static int ptlrpc_server_request_add(struct ptlrpc_service_part *svcpt, struct ptlrpc_request *req) { int rc; - ENTRY; rc = ptlrpc_server_hpreq_init(svcpt, req); if (rc < 0) - RETURN(rc); + return rc; ptlrpc_nrs_req_add(svcpt, req, !!rc); - RETURN(0); + return 0; } /** @@ -1701,7 +1683,6 @@ static struct ptlrpc_request * ptlrpc_server_request_get(struct ptlrpc_service_part *svcpt, bool force) { struct ptlrpc_request *req = NULL; - ENTRY; spin_lock(&svcpt->scp_req_lock); @@ -1722,7 +1703,7 @@ ptlrpc_server_request_get(struct ptlrpc_service_part *svcpt, bool force) } spin_unlock(&svcpt->scp_req_lock); - RETURN(NULL); + return NULL; got_request: svcpt->scp_nreqs_active++; @@ -1734,7 +1715,7 @@ got_request: if (likely(req->rq_export)) class_export_rpc_inc(req->rq_export); - RETURN(req); + return req; } /** @@ -1751,12 +1732,11 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, struct ptlrpc_request *req; __u32 deadline; int rc; - ENTRY; spin_lock(&svcpt->scp_lock); if (list_empty(&svcpt->scp_req_incoming)) { spin_unlock(&svcpt->scp_lock); - RETURN(0); + return 0; } req = list_entry(svcpt->scp_req_incoming.next, @@ -1875,12 +1855,12 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, GOTO(err_req, rc); wake_up(&svcpt->scp_waitq); - RETURN(1); + return 1; err_req: ptlrpc_server_finish_request(svcpt, req); - RETURN(1); + return 1; } /** @@ -1898,11 +1878,10 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, long timediff; int rc; int fail_opc = 0; - ENTRY; request = ptlrpc_server_request_get(svcpt, false); if (request == NULL) - RETURN(0); + return 0; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT)) fail_opc = OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT; @@ -2041,7 +2020,7 @@ put_conn: out_req: ptlrpc_server_finish_active_request(svcpt, request); - RETURN(1); + return 1; } /** @@ -2055,7 +2034,6 @@ ptlrpc_handle_rs(struct ptlrpc_reply_state *rs) struct obd_export *exp; int nlocks; int been_handled; - ENTRY; exp = rs->rs_export; @@ -2141,12 +2119,12 @@ ptlrpc_handle_rs(struct ptlrpc_reply_state *rs) if (atomic_dec_and_test(&svcpt->scp_nreps_difficult) && svc->srv_is_stopping) wake_up_all(&svcpt->scp_waitq); - RETURN(1); + return 1; } /* still on the net; callback will schedule */ spin_unlock(&rs->rs_lock); - RETURN(1); + return 1; } @@ -2252,7 +2230,9 @@ ptlrpc_wait_event(struct ptlrpc_service_part *svcpt, struct l_wait_info lwi = LWI_TIMEOUT(svcpt->scp_rqbd_timeout, ptlrpc_retry_rqbds, svcpt); + /* XXX: Add this back when libcfs watchdog is merged upstream lc_watchdog_disable(thread->t_watchdog); + */ cond_resched(); @@ -2266,8 +2246,10 @@ ptlrpc_wait_event(struct ptlrpc_service_part *svcpt, if (ptlrpc_thread_stopping(thread)) return -EINTR; + /* lc_watchdog_touch(thread->t_watchdog, ptlrpc_server_get_timeout(svcpt)); + */ return 0; } @@ -2284,11 +2266,10 @@ static int ptlrpc_main(void *arg) struct ptlrpc_service *svc = svcpt->scp_service; struct ptlrpc_reply_state *rs; #ifdef WITH_GROUP_INFO - group_info_t *ginfo = NULL; + struct group_info *ginfo = NULL; #endif struct lu_env *env; int counter = 0, rc = 0; - ENTRY; thread->t_pid = current_pid(); unshare_fs_struct(); @@ -2370,8 +2351,10 @@ static int ptlrpc_main(void *arg) /* wake up our creator in case he's still waiting. */ wake_up(&thread->t_ctl_waitq); + /* thread->t_watchdog = lc_watchdog_add(ptlrpc_server_get_timeout(svcpt), NULL, NULL); + */ spin_lock(&svcpt->scp_rep_lock); list_add(&rs->rs_list, &svcpt->scp_rep_idle); @@ -2426,8 +2409,10 @@ static int ptlrpc_main(void *arg) } } + /* lc_watchdog_delete(thread->t_watchdog); thread->t_watchdog = NULL; + */ out_srv_fini: /* @@ -2550,7 +2535,6 @@ static int ptlrpc_start_hr_threads(void) struct ptlrpc_hr_partition *hrp; int i; int j; - ENTRY; cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { int rc = 0; @@ -2573,9 +2557,9 @@ static int ptlrpc_start_hr_threads(void) CERROR("Reply handling thread %d:%d Failed on starting: " "rc = %d\n", i, j, rc); ptlrpc_stop_hr_threads(); - RETURN(rc); + return rc; } - RETURN(0); + return 0; } static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) @@ -2584,8 +2568,6 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) struct ptlrpc_thread *thread; LIST_HEAD (zombie); - ENTRY; - CDEBUG(D_INFO, "Stopping threads for service %s\n", svcpt->scp_service->srv_name); @@ -2625,7 +2607,6 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) list_del(&thread->t_link); OBD_FREE_PTR(thread); } - EXIT; } /** @@ -2635,14 +2616,11 @@ void ptlrpc_stop_all_threads(struct ptlrpc_service *svc) { struct ptlrpc_service_part *svcpt; int i; - ENTRY; ptlrpc_service_for_each_part(svcpt, i, svc) { if (svcpt->scp_service != NULL) ptlrpc_svcpt_stop_threads(svcpt); } - - EXIT; } EXPORT_SYMBOL(ptlrpc_stop_all_threads); @@ -2651,7 +2629,6 @@ int ptlrpc_start_threads(struct ptlrpc_service *svc) int rc = 0; int i; int j; - ENTRY; /* We require 2 threads min, see note in ptlrpc_server_handle_request */ LASSERT(svc->srv_nthrs_cpt_init >= PTLRPC_NTHRS_INIT); @@ -2669,12 +2646,12 @@ int ptlrpc_start_threads(struct ptlrpc_service *svc) } } - RETURN(0); + return 0; failed: CERROR("cannot start %s thread #%d_%d: rc %d\n", svc->srv_thread_name, i, j, rc); ptlrpc_stop_all_threads(svc); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_start_threads); @@ -2684,7 +2661,6 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) struct ptlrpc_thread *thread; struct ptlrpc_service *svc; int rc; - ENTRY; LASSERT(svcpt != NULL); @@ -2696,23 +2672,23 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) again: if (unlikely(svc->srv_is_stopping)) - RETURN(-ESRCH); + return -ESRCH; if (!ptlrpc_threads_increasable(svcpt) || (OBD_FAIL_CHECK(OBD_FAIL_TGT_TOOMANY_THREADS) && svcpt->scp_nthrs_running == svc->srv_nthrs_cpt_init - 1)) - RETURN(-EMFILE); + return -EMFILE; OBD_CPT_ALLOC_PTR(thread, svc->srv_cptable, svcpt->scp_cpt); if (thread == NULL) - RETURN(-ENOMEM); + return -ENOMEM; init_waitqueue_head(&thread->t_ctl_waitq); spin_lock(&svcpt->scp_lock); if (!ptlrpc_threads_increasable(svcpt)) { spin_unlock(&svcpt->scp_lock); OBD_FREE_PTR(thread); - RETURN(-EMFILE); + return -EMFILE; } if (svcpt->scp_nthrs_starting != 0) { @@ -2730,7 +2706,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) CDEBUG(D_INFO, "Creating thread %s #%d race, retry later\n", svc->srv_thread_name, svcpt->scp_thr_nextid); - RETURN(-EAGAIN); + return -EAGAIN; } svcpt->scp_nthrs_starting++; @@ -2742,46 +2718,55 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) spin_unlock(&svcpt->scp_lock); if (svcpt->scp_cpt >= 0) { - snprintf(thread->t_name, PTLRPC_THR_NAME_LEN, "%s%02d_%03d", + snprintf(thread->t_name, sizeof(thread->t_name), "%s%02d_%03d", svc->srv_thread_name, svcpt->scp_cpt, thread->t_id); } else { - snprintf(thread->t_name, PTLRPC_THR_NAME_LEN, "%s_%04d", + snprintf(thread->t_name, sizeof(thread->t_name), "%s_%04d", svc->srv_thread_name, thread->t_id); } CDEBUG(D_RPCTRACE, "starting thread '%s'\n", thread->t_name); - rc = PTR_ERR(kthread_run(ptlrpc_main, thread, thread->t_name)); + rc = PTR_ERR(kthread_run(ptlrpc_main, thread, "%s", thread->t_name)); if (IS_ERR_VALUE(rc)) { CERROR("cannot start thread '%s': rc %d\n", thread->t_name, rc); spin_lock(&svcpt->scp_lock); - list_del(&thread->t_link); --svcpt->scp_nthrs_starting; - spin_unlock(&svcpt->scp_lock); - - OBD_FREE(thread, sizeof(*thread)); - RETURN(rc); + if (thread_is_stopping(thread)) { + /* this ptlrpc_thread is being hanled + * by ptlrpc_svcpt_stop_threads now + */ + thread_add_flags(thread, SVC_STOPPED); + wake_up(&thread->t_ctl_waitq); + spin_unlock(&svcpt->scp_lock); + } else { + list_del(&thread->t_link); + spin_unlock(&svcpt->scp_lock); + OBD_FREE_PTR(thread); + } + return rc; } if (!wait) - RETURN(0); + return 0; l_wait_event(thread->t_ctl_waitq, thread_is_running(thread) || thread_is_stopped(thread), &lwi); rc = thread_is_stopped(thread) ? thread->t_id : 0; - RETURN(rc); + return rc; } int ptlrpc_hr_init(void) { + cpumask_t mask; struct ptlrpc_hr_partition *hrp; struct ptlrpc_hr_thread *hrt; int rc; int i; int j; - ENTRY; + int weight; memset(&ptlrpc_hr, 0, sizeof(ptlrpc_hr)); ptlrpc_hr.hr_cpt_table = cfs_cpt_table; @@ -2789,10 +2774,13 @@ int ptlrpc_hr_init(void) ptlrpc_hr.hr_partitions = cfs_percpt_alloc(ptlrpc_hr.hr_cpt_table, sizeof(*hrp)); if (ptlrpc_hr.hr_partitions == NULL) - RETURN(-ENOMEM); + return -ENOMEM; init_waitqueue_head(&ptlrpc_hr.hr_waitq); + cpumask_copy(&mask, topology_thread_cpumask(0)); + weight = cpus_weight(mask); + cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { hrp->hrp_cpt = i; @@ -2800,7 +2788,7 @@ int ptlrpc_hr_init(void) atomic_set(&hrp->hrp_nstopped, 0); hrp->hrp_nthrs = cfs_cpt_weight(ptlrpc_hr.hr_cpt_table, i); - hrp->hrp_nthrs /= cfs_cpu_ht_nsiblings(0); + hrp->hrp_nthrs /= weight; LASSERT(hrp->hrp_nthrs > 0); OBD_CPT_ALLOC(hrp->hrp_thrs, ptlrpc_hr.hr_cpt_table, i, @@ -2823,7 +2811,7 @@ int ptlrpc_hr_init(void) out: if (rc != 0) ptlrpc_hr_fini(); - RETURN(rc); + return rc; } void ptlrpc_hr_fini(void) @@ -3045,8 +3033,6 @@ ptlrpc_service_free(struct ptlrpc_service *svc) int ptlrpc_unregister_service(struct ptlrpc_service *service) { - ENTRY; - CDEBUG(D_NET, "%s: tearing down\n", service->srv_name); service->srv_is_stopping = 1; @@ -3066,7 +3052,7 @@ int ptlrpc_unregister_service(struct ptlrpc_service *service) ptlrpc_service_free(service); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_unregister_service); |