diff options
author | Jiri Kosina <jkosina@suse.cz> | 2013-12-19 15:08:03 +0100 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-12-19 15:08:32 +0100 |
commit | e23c34bb41da65f354fb7eee04300c56ee48f60c (patch) | |
tree | 549fbe449d55273b81ef104a9755109bf4ae7817 /drivers/staging/lustre/lustre | |
parent | b481c2cb3534c85dca625973b33eba15f9af3e4c (diff) | |
parent | 319e2e3f63c348a9b66db4667efa73178e18b17d (diff) |
Merge branch 'master' into for-next
Sync with Linus' tree to be able to apply fixes on top of newer things
in tree (efi-stub).
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/staging/lustre/lustre')
80 files changed, 668 insertions, 635 deletions
diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig index 4e898e491860..93d59b6a60da 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 INET && m + depends on INET && m && !MIPS && !XTENSA && !SUPERH select LNET select CRYPTO select CRYPTO_CRC32 @@ -16,7 +16,7 @@ config LUSTRE_FS this file system support as a module, choose M here: the module will be called lustre. - To mount Lustre file systems , you also need to install the user space + To mount Lustre file systems, you also need to install the user space mount.lustre and other user space commands which can be found in the lustre-client package, available from http://downloads.whamcloud.com/public/lustre/ @@ -52,7 +52,7 @@ config LUSTRE_DEBUG_EXPENSIVE_CHECK config LUSTRE_TRANSLATE_ERRNOS bool depends on LUSTRE_FS && !X86 - default true + default y config LUSTRE_LLITE_LLOOP bool "Lustre virtual block device" diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 66007b57018b..79fc2fe131a2 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -548,9 +548,7 @@ 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; + return PTR_ERR_OR_ZERO(seq_type_proc_dir); } static void __exit fid_mod_exit(void) diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index 25099cbe37eb..45315101848c 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -267,7 +267,7 @@ void fld_cache_punch_hole(struct fld_cache *cache, const seqno_t new_end = range->lsr_end; struct fld_cache_entry *fldt; - OBD_ALLOC_GFP(fldt, sizeof *fldt, GFP_ATOMIC); + OBD_ALLOC_GFP(fldt, sizeof(*fldt), GFP_ATOMIC); if (!fldt) { OBD_FREE_PTR(f_new); /* overlap is not allowed, so dont mess up list. */ diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 078e98bda684..e47fd50b2a2e 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -59,8 +59,6 @@ #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) @@ -509,14 +507,11 @@ static int __init fld_mod_init(void) 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; diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index edb40afe66f1..c485206fc6c2 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -3096,13 +3096,13 @@ struct cl_io *cl_io_top(struct cl_io *io); void cl_io_print(const struct lu_env *env, void *cookie, lu_printer_t printer, const struct cl_io *io); -#define CL_IO_SLICE_CLEAN(foo_io, base) \ -do { \ - typeof(foo_io) __foo_io = (foo_io); \ +#define CL_IO_SLICE_CLEAN(foo_io, base) \ +do { \ + typeof(foo_io) __foo_io = (foo_io); \ \ - CLASSERT(offsetof(typeof(*__foo_io), base) == 0); \ - memset(&__foo_io->base + 1, 0, \ - (sizeof *__foo_io) - sizeof __foo_io->base); \ + CLASSERT(offsetof(typeof(*__foo_io), base) == 0); \ + memset(&__foo_io->base + 1, 0, \ + sizeof(*__foo_io) - sizeof(__foo_io->base)); \ } while (0) /** @} cl_io */ diff --git a/drivers/staging/lustre/lustre/include/lclient.h b/drivers/staging/lustre/lustre/include/lclient.h index 9d4011f2908b..27316f7b7a70 100644 --- a/drivers/staging/lustre/lustre/include/lclient.h +++ b/drivers/staging/lustre/lustre/include/lclient.h @@ -388,8 +388,8 @@ __u16 ll_dirent_type_get(struct lu_dirent *ent); __u64 cl_fid_build_ino(const struct lu_fid *fid, int api32); __u32 cl_fid_build_gen(const struct lu_fid *fid); -# define CLOBINVRNT(env, clob, expr) \ - ((void)sizeof(env), (void)sizeof(clob), (void)sizeof !!(expr)) +# define CLOBINVRNT(env, clob, expr) \ + ((void)sizeof(env), (void)sizeof(clob), (void)sizeof(!!(expr))) int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp); int cl_ocd_update(struct obd_device *host, diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 9243dfab43d3..eefdb8d061b1 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -105,8 +105,8 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define ll_vfs_unlink(inode,entry,mnt) vfs_unlink(inode,entry) #define ll_vfs_mknod(dir,entry,mnt,mode,dev) vfs_mknod(dir,entry,mode,dev) #define ll_security_inode_unlink(dir,entry,mnt) security_inode_unlink(dir,entry) -#define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \ - vfs_rename(old,old_dir,new,new_dir) +#define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1,delegated_inode) \ + vfs_rename(old,old_dir,new,new_dir,delegated_inode) #define cfs_bio_io_error(a,b) bio_io_error((a)) #define cfs_bio_endio(a,b,c) bio_endio((a),(c)) @@ -232,9 +232,6 @@ static inline int ll_namei_to_lookup_intent_flag(int flag) return flag; } -# define ll_mrf_ret void -# define LL_MRF_RETURN(rc) - #include <linux/fs.h> # define ll_umode_t umode_t diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index fa31be886ef8..d5b8225ef1a7 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -622,7 +622,7 @@ struct lu_site { /** * objects hash table */ - cfs_hash_t *ls_obj_hash; + struct cfs_hash *ls_obj_hash; /** * index of bucket on hash table while purging */ @@ -659,7 +659,7 @@ struct lu_site { static inline struct lu_site_bkt_data * lu_site_bkt_from_fid(struct lu_site *site, struct lu_fid *fid) { - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; cfs_hash_bd_get(site->ls_obj_hash, fid, &bd); return cfs_hash_bd_extra_get(site->ls_obj_hash, &bd); diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h b/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h index 2870487dd286..35aefa2cdad1 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h @@ -165,7 +165,7 @@ #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_ESTALE 116 /* Stale 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 */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 984235ccd3a5..5ca18d016014 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -831,9 +831,10 @@ static inline void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen) static inline void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src) { /* check that all fields are converted */ - CLASSERT(sizeof *src == - sizeof fid_seq(src) + - sizeof fid_oid(src) + sizeof fid_ver(src)); + CLASSERT(sizeof(*src) == + sizeof(fid_seq(src)) + + sizeof(fid_oid(src)) + + sizeof(fid_ver(src))); dst->f_seq = cpu_to_le64(fid_seq(src)); dst->f_oid = cpu_to_le32(fid_oid(src)); dst->f_ver = cpu_to_le32(fid_ver(src)); @@ -842,9 +843,10 @@ static inline void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src) static inline void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src) { /* check that all fields are converted */ - CLASSERT(sizeof *src == - sizeof fid_seq(src) + - sizeof fid_oid(src) + sizeof fid_ver(src)); + CLASSERT(sizeof(*src) == + sizeof(fid_seq(src)) + + sizeof(fid_oid(src)) + + sizeof(fid_ver(src))); dst->f_seq = le64_to_cpu(fid_seq(src)); dst->f_oid = le32_to_cpu(fid_oid(src)); dst->f_ver = le32_to_cpu(fid_ver(src)); @@ -853,9 +855,10 @@ static inline void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src) static inline void fid_cpu_to_be(struct lu_fid *dst, const struct lu_fid *src) { /* check that all fields are converted */ - CLASSERT(sizeof *src == - sizeof fid_seq(src) + - sizeof fid_oid(src) + sizeof fid_ver(src)); + CLASSERT(sizeof(*src) == + sizeof(fid_seq(src)) + + sizeof(fid_oid(src)) + + sizeof(fid_ver(src))); dst->f_seq = cpu_to_be64(fid_seq(src)); dst->f_oid = cpu_to_be32(fid_oid(src)); dst->f_ver = cpu_to_be32(fid_ver(src)); @@ -864,9 +867,10 @@ static inline void fid_cpu_to_be(struct lu_fid *dst, const struct lu_fid *src) static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src) { /* check that all fields are converted */ - CLASSERT(sizeof *src == - sizeof fid_seq(src) + - sizeof fid_oid(src) + sizeof fid_ver(src)); + CLASSERT(sizeof(*src) == + sizeof(fid_seq(src)) + + sizeof(fid_oid(src)) + + sizeof(fid_ver(src))); dst->f_seq = be64_to_cpu(fid_seq(src)); dst->f_oid = be32_to_cpu(fid_oid(src)); dst->f_ver = be32_to_cpu(fid_ver(src)); @@ -891,9 +895,11 @@ extern void lustre_swab_lu_seq_range(struct lu_seq_range *range); static inline int lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1) { /* Check that there is no alignment padding. */ - CLASSERT(sizeof *f0 == - sizeof f0->f_seq + sizeof f0->f_oid + sizeof f0->f_ver); - return memcmp(f0, f1, sizeof *f0) == 0; + CLASSERT(sizeof(*f0) == + sizeof(f0->f_seq) + + sizeof(f0->f_oid) + + sizeof(f0->f_ver)); + return memcmp(f0, f1, sizeof(*f0)) == 0; } #define __diff_normalize(val0, val1) \ @@ -1638,8 +1644,10 @@ static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi, /* extern void lustre_swab_lov_mds_md(struct lov_mds_md *llm); */ -#define MAX_MD_SIZE (sizeof(struct lov_mds_md) + 4 * sizeof(struct lov_ost_data)) -#define MIN_MD_SIZE (sizeof(struct lov_mds_md) + 1 * sizeof(struct lov_ost_data)) +#define MAX_MD_SIZE \ + (sizeof(struct lov_mds_md) + 4 * sizeof(struct lov_ost_data)) +#define MIN_MD_SIZE \ + (sizeof(struct lov_mds_md) + 1 * sizeof(struct lov_ost_data)) #define XATTR_NAME_ACL_ACCESS "system.posix_acl_access" #define XATTR_NAME_ACL_DEFAULT "system.posix_acl_default" diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 7020d9cd9eb2..bc2b82ffae92 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -375,7 +375,7 @@ struct ldlm_namespace { ldlm_side_t ns_client; /** Resource hash table for namespace. */ - cfs_hash_t *ns_rs_hash; + struct cfs_hash *ns_rs_hash; /** serialize */ spinlock_t ns_lock; @@ -1083,7 +1083,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, * Rate-limited version of lock printing function. */ #define LDLM_DEBUG_LIMIT(mask, lock, fmt, a...) do { \ - static cfs_debug_limit_state_t _ldlm_cdls; \ + static struct cfs_debug_limit_state _ldlm_cdls; \ LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, mask, &_ldlm_cdls); \ ldlm_lock_debug(&msgdata, mask, &_ldlm_cdls, lock, "### " fmt , ##a);\ } while (0) diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index d61c020a4643..2feb38b51af2 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -197,12 +197,12 @@ struct obd_export { /** Connection count value from last succesful reconnect rpc */ __u32 exp_conn_cnt; /** Hash list of all ldlm locks granted on this export */ - cfs_hash_t *exp_lock_hash; + struct cfs_hash *exp_lock_hash; /** * Hash list for Posix lock deadlock detection, added with * ldlm_lock::l_exp_flock_hash. */ - cfs_hash_t *exp_flock_hash; + struct cfs_hash *exp_flock_hash; struct list_head exp_outstanding_replies; struct list_head exp_uncommitted_replies; spinlock_t exp_uncommitted_replies_lock; diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index d9d5814e318d..ff119532dafb 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -590,7 +590,7 @@ fid_build_pdo_res_name(const struct lu_fid *fid, unsigned int hash, static inline void ostid_build_res_name(struct ost_id *oi, struct ldlm_res_id *name) { - memset(name, 0, sizeof *name); + memset(name, 0, sizeof(*name)); if (fid_seq_is_mdt0(ostid_seq(oi))) { name->name[LUSTRE_RES_ID_SEQ_OFF] = ostid_id(oi); name->name[LUSTRE_RES_ID_VER_OID_OFF] = ostid_seq(oi); diff --git a/drivers/staging/lustre/lustre/include/lustre_lite.h b/drivers/staging/lustre/lustre/include/lustre_lite.h index 25f8bfaccef3..beccb5e4065f 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lite.h +++ b/drivers/staging/lustre/lustre/include/lustre_lite.h @@ -139,7 +139,11 @@ static inline unsigned long hash_x_index(__u64 hash, int hash64) { if (BITS_PER_LONG == 32 && hash64) hash >>= 32; - return ~0UL - hash; + /* save hash 0 as index 0 because otherwise we'll save it at + * page index end (~0UL) and it causes truncate_inode_pages_range() + * to loop forever. + */ + return ~0UL - (hash + !hash); } /** @} lite */ diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index e947002fae04..72edf01b58a2 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1427,7 +1427,7 @@ struct nrs_fifo_req { struct nrs_crrn_net { struct ptlrpc_nrs_resource cn_res; cfs_binheap_t *cn_binheap; - cfs_hash_t *cn_cli_hash; + struct cfs_hash *cn_cli_hash; /** * Used when a new scheduling round commences, in order to synchronize * all clients with the new round number. @@ -1568,7 +1568,7 @@ struct nrs_orr_key { struct nrs_orr_data { struct ptlrpc_nrs_resource od_res; cfs_binheap_t *od_binheap; - cfs_hash_t *od_obj_hash; + struct cfs_hash *od_obj_hash; struct kmem_cache *od_cache; /** * Used when a new scheduling round commences, in order to synchronize @@ -2206,7 +2206,7 @@ do { \ #define DEBUG_REQ(level, req, fmt, args...) \ do { \ if ((level) & (D_ERROR | D_WARNING)) { \ - static cfs_debug_limit_state_t cdls; \ + static struct cfs_debug_limit_state cdls; \ LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, level, &cdls); \ debug_req(&msgdata, level, &cdls, req, "@@@ "fmt" ", ## args);\ } else { \ diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index a6122559d55d..d0aea15b7c39 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -177,7 +177,7 @@ static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1, * ->lsm_wire contains padding, but it should be zeroed out during * allocation. */ - return memcmp(&m1->lsm_wire, &m2->lsm_wire, sizeof m1->lsm_wire); + return memcmp(&m1->lsm_wire, &m2->lsm_wire, sizeof(m1->lsm_wire)); } static inline int lov_lum_lsm_cmp(struct lov_user_md *lum, @@ -429,7 +429,7 @@ struct client_obd { /* ptlrpc work for writeback in ptlrpcd context */ void *cl_writeback_work; /* hash tables for osc_quota_info */ - cfs_hash_t *cl_quota_hash[MAXQUOTAS]; + struct cfs_hash *cl_quota_hash[MAXQUOTAS]; }; #define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid) @@ -556,7 +556,7 @@ struct lov_obd { __u32 lov_tgt_size; /* size of tgts array */ int lov_connects; int lov_pool_count; - cfs_hash_t *lov_pools_hash_body; /* used for key access */ + struct cfs_hash *lov_pools_hash_body; /* used for key access */ struct list_head lov_pool_list; /* used for sequential access */ struct proc_dir_entry *lov_pool_proc_entry; enum lustre_sec_part lov_sp_me; @@ -855,11 +855,11 @@ struct obd_device { * protection of other bits using _bh lock */ unsigned long obd_recovery_expired:1; /* uuid-export hash body */ - cfs_hash_t *obd_uuid_hash; + struct cfs_hash *obd_uuid_hash; /* nid-export hash body */ - cfs_hash_t *obd_nid_hash; + struct cfs_hash *obd_nid_hash; /* nid stats body */ - cfs_hash_t *obd_nid_stats_hash; + struct cfs_hash *obd_nid_stats_hash; struct list_head obd_nid_stats; atomic_t obd_refcount; wait_queue_head_t obd_refcount_waitq; diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index 03e6133ef50f..9697e7faff2f 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -633,8 +633,8 @@ do { \ #define OBD_ALLOC(ptr, size) OBD_ALLOC_GFP(ptr, size, __GFP_IO) #define OBD_ALLOC_WAIT(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_IOFS) -#define OBD_ALLOC_PTR(ptr) OBD_ALLOC(ptr, sizeof *(ptr)) -#define OBD_ALLOC_PTR_WAIT(ptr) OBD_ALLOC_WAIT(ptr, sizeof *(ptr)) +#define OBD_ALLOC_PTR(ptr) OBD_ALLOC(ptr, sizeof(*(ptr))) +#define OBD_ALLOC_PTR_WAIT(ptr) OBD_ALLOC_WAIT(ptr, sizeof(*(ptr))) #define OBD_CPT_ALLOC_GFP(ptr, cptab, cpt, size, gfp_mask) \ __OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, gfp_mask) @@ -643,7 +643,7 @@ do { \ OBD_CPT_ALLOC_GFP(ptr, cptab, cpt, size, __GFP_IO) #define OBD_CPT_ALLOC_PTR(ptr, cptab, cpt) \ - OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof *(ptr)) + OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof(*(ptr))) # define __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size) \ do { \ @@ -773,7 +773,7 @@ do { \ #define OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, size, flags) \ __OBD_SLAB_ALLOC_VERBOSE(ptr, slab, cptab, cpt, size, flags) -#define OBD_FREE_PTR(ptr) OBD_FREE(ptr, sizeof *(ptr)) +#define OBD_FREE_PTR(ptr) OBD_FREE(ptr, sizeof(*(ptr))) #define OBD_SLAB_FREE(ptr, slab, size) \ do { \ @@ -789,19 +789,19 @@ do { \ OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, size, __GFP_IO) #define OBD_SLAB_ALLOC_PTR(ptr, slab) \ - OBD_SLAB_ALLOC(ptr, slab, sizeof *(ptr)) + OBD_SLAB_ALLOC(ptr, slab, sizeof(*(ptr))) #define OBD_SLAB_CPT_ALLOC_PTR(ptr, slab, cptab, cpt) \ - OBD_SLAB_CPT_ALLOC(ptr, slab, cptab, cpt, sizeof *(ptr)) + OBD_SLAB_CPT_ALLOC(ptr, slab, cptab, cpt, sizeof(*(ptr))) #define OBD_SLAB_ALLOC_PTR_GFP(ptr, slab, flags) \ - OBD_SLAB_ALLOC_GFP(ptr, slab, sizeof *(ptr), flags) + OBD_SLAB_ALLOC_GFP(ptr, slab, sizeof(*(ptr)), flags) #define OBD_SLAB_CPT_ALLOC_PTR_GFP(ptr, slab, cptab, cpt, flags) \ - OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, sizeof *(ptr), flags) + OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, sizeof(*(ptr)), flags) #define OBD_SLAB_FREE_PTR(ptr, slab) \ - OBD_SLAB_FREE((ptr), (slab), sizeof *(ptr)) + OBD_SLAB_FREE((ptr), (slab), sizeof(*(ptr))) #define KEY_IS(str) \ (keylen >= (sizeof(str)-1) && memcmp(key, str, (sizeof(str)-1)) == 0) diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 8ff38c64b7a1..e60c04d5393a 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -701,7 +701,7 @@ int ccc_io_one_lock_index(const struct lu_env *env, struct cl_io *io, CDEBUG(D_VFSTRACE, "lock: %d [%lu, %lu]\n", mode, start, end); - memset(&cio->cui_link, 0, sizeof cio->cui_link); + memset(&cio->cui_link, 0, sizeof(cio->cui_link)); if (cio->cui_fd && (cio->cui_fd->fd_flags & LL_FILE_GROUP_LOCKED)) { descr->cld_mode = CLM_GROUP; diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index c65b13c800f9..1de1d8eb9b41 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c @@ -125,11 +125,11 @@ static inline __u64 min_u64(__u64 x, __u64 y) #define interval_for_each(node, root) \ for (node = interval_first(root); node != NULL; \ - node = interval_next(node)) + node = interval_next(node)) #define interval_for_each_reverse(node, root) \ for (node = interval_last(root); node != NULL; \ - node = interval_prev(node)) + node = interval_prev(node)) static struct interval_node *interval_first(struct interval_node *node) { @@ -239,7 +239,7 @@ static void __rotate_change_maxhigh(struct interval_node *node, left_max = node->in_left ? node->in_left->in_max_high : 0; right_max = node->in_right ? node->in_right->in_max_high : 0; node->in_max_high = max_u64(interval_high(node), - max_u64(left_max,right_max)); + max_u64(left_max, right_max)); } /* The left rotation "pivots" around the link from node to node->right, and @@ -427,8 +427,9 @@ static void interval_erase_color(struct interval_node *node, } else { if (node_is_black_or_0(tmp->in_right)) { struct interval_node *o_left; - if ((o_left = tmp->in_left)) - o_left->in_color = INTERVAL_BLACK; + o_left = tmp->in_left; + if (o_left) + o_left->in_color = INTERVAL_BLACK; tmp->in_color = INTERVAL_RED; __rotate_right(tmp, root); tmp = parent->in_right; @@ -436,7 +437,7 @@ static void interval_erase_color(struct interval_node *node, tmp->in_color = parent->in_color; parent->in_color = INTERVAL_BLACK; if (tmp->in_right) - tmp->in_right->in_color = INTERVAL_BLACK; + tmp->in_right->in_color = INTERVAL_BLACK; __rotate_left(parent, root); node = *root; break; @@ -457,8 +458,9 @@ static void interval_erase_color(struct interval_node *node, } else { if (node_is_black_or_0(tmp->in_left)) { struct interval_node *o_right; - if ((o_right = tmp->in_right)) - o_right->in_color = INTERVAL_BLACK; + o_right = tmp->in_right; + if (o_right) + o_right->in_color = INTERVAL_BLACK; tmp->in_color = INTERVAL_RED; __rotate_left(tmp, root); tmp = parent->in_left; @@ -545,7 +547,7 @@ void interval_erase(struct interval_node *node, update_maxhigh(child ? : parent, node->in_max_high); update_maxhigh(node, old->in_max_high); if (parent == old) - parent = node; + parent = node; goto color; } parent = node->in_parent; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index 7e316637369b..ac5d66aa7f02 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -144,7 +144,7 @@ struct ldlm_interval *ldlm_interval_detach(struct ldlm_lock *l) l->l_tree_node = NULL; list_del_init(&l->l_sl_policy); - return (list_empty(&n->li_group) ? n : NULL); + return list_empty(&n->li_group) ? n : NULL; } static inline int lock_mode_to_index(ldlm_mode_t mode) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index c68ed2766333..39fcdacc51ed 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -745,7 +745,7 @@ void ldlm_flock_policy_local_to_wire(const ldlm_policy_data_t *lpolicy, * Export handle<->flock hash operations. */ static unsigned -ldlm_export_flock_hash(cfs_hash_t *hs, const void *key, unsigned mask) +ldlm_export_flock_hash(struct cfs_hash *hs, const void *key, unsigned mask) { return cfs_hash_u64_hash(*(__u64 *)key, mask); } @@ -772,7 +772,7 @@ ldlm_export_flock_object(struct hlist_node *hnode) } static void -ldlm_export_flock_get(cfs_hash_t *hs, struct hlist_node *hnode) +ldlm_export_flock_get(struct cfs_hash *hs, struct hlist_node *hnode) { struct ldlm_lock *lock; struct ldlm_flock *flock; @@ -787,7 +787,7 @@ ldlm_export_flock_get(cfs_hash_t *hs, struct hlist_node *hnode) } static void -ldlm_export_flock_put(cfs_hash_t *hs, struct hlist_node *hnode) +ldlm_export_flock_put(struct cfs_hash *hs, struct hlist_node *hnode) { struct ldlm_lock *lock; struct ldlm_flock *flock; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 6133b3f34718..3900a69742fc 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -529,7 +529,7 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, lock_res_nested(oldres, LRT_NEW); } LASSERT(memcmp(new_resid, &oldres->lr_name, - sizeof oldres->lr_name) != 0); + sizeof(oldres->lr_name)) != 0); lock->l_resource = newres; unlock_res(oldres); unlock_res_and_lock(lock); @@ -1891,7 +1891,7 @@ static int reprocess_one_queue(struct ldlm_resource *res, void *closure) return LDLM_ITER_CONTINUE; } -static int ldlm_reprocess_res(cfs_hash_t *hs, cfs_hash_bd_t *bd, +static int ldlm_reprocess_res(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *arg) { struct ldlm_resource *res = cfs_hash_object(hs, hnode); @@ -2040,7 +2040,7 @@ struct export_cl_data { * Iterator function for ldlm_cancel_locks_for_export. * Cancels passed locks. */ -int ldlm_cancel_locks_for_export_cb(cfs_hash_t *hs, cfs_hash_bd_t *bd, +int ldlm_cancel_locks_for_export_cb(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *data) { diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 3916bda3004c..fde9bcd1d48d 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -800,9 +800,9 @@ static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp) 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)); @@ -937,7 +937,7 @@ EXPORT_SYMBOL(ldlm_put_ref); * Export handle<->lock hash operations. */ static unsigned -ldlm_export_lock_hash(cfs_hash_t *hs, const void *key, unsigned mask) +ldlm_export_lock_hash(struct cfs_hash *hs, const void *key, unsigned mask) { return cfs_hash_u64_hash(((struct lustre_handle *)key)->cookie, mask); } @@ -973,7 +973,7 @@ ldlm_export_lock_object(struct hlist_node *hnode) } static void -ldlm_export_lock_get(cfs_hash_t *hs, struct hlist_node *hnode) +ldlm_export_lock_get(struct cfs_hash *hs, struct hlist_node *hnode) { struct ldlm_lock *lock; @@ -982,7 +982,7 @@ ldlm_export_lock_get(cfs_hash_t *hs, struct hlist_node *hnode) } static void -ldlm_export_lock_put(cfs_hash_t *hs, struct hlist_node *hnode) +ldlm_export_lock_put(struct cfs_hash *hs, struct hlist_node *hnode) { struct ldlm_lock *lock; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 454027d68d54..0025ee6356da 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -521,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); @@ -540,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 = { @@ -601,9 +597,10 @@ int ldlm_pool_recalc(struct ldlm_pool *pl) return recalc_interval_sec; } -/** +/* * 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) @@ -1017,29 +1014,24 @@ 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(); @@ -1047,8 +1039,7 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr, * Find out how many resources we may release. */ for (nr_ns = ldlm_namespace_nr_read(client); - nr_ns > 0; nr_ns--) - { + nr_ns > 0; nr_ns--) { mutex_lock(ldlm_namespace_lock(client)); if (list_empty(ldlm_namespace_list(client))) { mutex_unlock(ldlm_namespace_lock(client)); @@ -1078,17 +1069,27 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr, 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 = ldlm_namespace_nr_read(client) - nr_ns; - nr_ns > 0; nr_ns--) - { + for (tmp = nr_ns = ldlm_namespace_nr_read(client); + tmp > 0; tmp--) { int cancel, nr_locks; /* @@ -1097,12 +1098,6 @@ 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); @@ -1111,29 +1106,42 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr, 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 int ldlm_pools_srv_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask)) +static unsigned long ldlm_pools_srv_scan(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_scan(LDLM_NAMESPACE_SERVER, sc->nr_to_scan, + sc->gfp_mask); } -static int ldlm_pools_cli_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_CLIENT, - shrink_param(sc, nr_to_scan), - shrink_param(sc, gfp_mask)); + return ldlm_pools_count(LDLM_NAMESPACE_CLIENT, sc->gfp_mask); +} + +static unsigned long ldlm_pools_cli_scan(struct shrinker *s, struct shrink_control *sc) +{ + return ldlm_pools_scan(LDLM_NAMESPACE_CLIENT, sc->nr_to_scan, + sc->gfp_mask); } int ldlm_pools_recalc(ldlm_side_t client) @@ -1216,7 +1224,7 @@ int 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 = ldlm_namespace_nr_read(client); nr > 0; nr--) { int skip; @@ -1383,18 +1391,26 @@ static void ldlm_pools_thread_stop(void) ldlm_pools_thread = NULL; } +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; 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; } @@ -1402,14 +1418,8 @@ 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 21cb523ac4af..dcc278403136 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -1652,7 +1652,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, struct list_head *ca LDLM_LOCK_GET(lock); spin_unlock(&ns->ns_lock); - lu_ref_add(&lock->l_reference, __FUNCTION__, current); + lu_ref_add(&lock->l_reference, __func__, current); /* Pass the lock through the policy filter and see if it * should stay in LRU. @@ -1670,7 +1670,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, struct list_head *ca result = pf(ns, lock, unused, added, count); if (result == LDLM_POLICY_KEEP_LOCK) { lu_ref_del(&lock->l_reference, - __FUNCTION__, current); + __func__, current); LDLM_LOCK_RELEASE(lock); spin_lock(&ns->ns_lock); break; @@ -1693,7 +1693,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, struct list_head *ca * by itself, or the lock is no longer unused. */ unlock_res_and_lock(lock); lu_ref_del(&lock->l_reference, - __FUNCTION__, current); + __func__, current); LDLM_LOCK_RELEASE(lock); spin_lock(&ns->ns_lock); continue; @@ -1724,7 +1724,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, struct list_head *ca LASSERT(list_empty(&lock->l_bl_ast)); list_add(&lock->l_bl_ast, cancels); unlock_res_and_lock(lock); - lu_ref_del(&lock->l_reference, __FUNCTION__, current); + lu_ref_del(&lock->l_reference, __func__, current); spin_lock(&ns->ns_lock); added++; unused--; @@ -1925,7 +1925,7 @@ struct ldlm_cli_cancel_arg { void *lc_opaque; }; -static int ldlm_cli_hash_cancel_unused(cfs_hash_t *hs, cfs_hash_bd_t *bd, +static int ldlm_cli_hash_cancel_unused(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *arg) { struct ldlm_resource *res = cfs_hash_object(hs, hnode); @@ -2023,7 +2023,7 @@ static int ldlm_iter_helper(struct ldlm_lock *lock, void *closure) return helper->iter(lock, helper->closure); } -static int ldlm_res_iter_helper(cfs_hash_t *hs, cfs_hash_bd_t *bd, +static int ldlm_res_iter_helper(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *arg) { diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 208751a154b3..77e022bf8bcc 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -159,7 +159,7 @@ static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v) { struct ldlm_namespace *ns = m->private; __u64 res = 0; - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; int i; /* result is not strictly consistant */ @@ -389,7 +389,7 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) #endif /* LPROCFS */ -static unsigned ldlm_res_hop_hash(cfs_hash_t *hs, +static unsigned ldlm_res_hop_hash(struct cfs_hash *hs, const void *key, unsigned mask) { const struct ldlm_res_id *id = key; @@ -401,7 +401,7 @@ static unsigned ldlm_res_hop_hash(cfs_hash_t *hs, return val & mask; } -static unsigned ldlm_res_hop_fid_hash(cfs_hash_t *hs, +static unsigned ldlm_res_hop_fid_hash(struct cfs_hash *hs, const void *key, unsigned mask) { const struct ldlm_res_id *id = key; @@ -453,7 +453,7 @@ static void *ldlm_res_hop_object(struct hlist_node *hnode) return hlist_entry(hnode, struct ldlm_resource, lr_hash); } -static void ldlm_res_hop_get_locked(cfs_hash_t *hs, struct hlist_node *hnode) +static void ldlm_res_hop_get_locked(struct cfs_hash *hs, struct hlist_node *hnode) { struct ldlm_resource *res; @@ -461,7 +461,7 @@ static void ldlm_res_hop_get_locked(cfs_hash_t *hs, struct hlist_node *hnode) ldlm_resource_getref(res); } -static void ldlm_res_hop_put_locked(cfs_hash_t *hs, struct hlist_node *hnode) +static void ldlm_res_hop_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) { struct ldlm_resource *res; @@ -470,7 +470,7 @@ static void ldlm_res_hop_put_locked(cfs_hash_t *hs, struct hlist_node *hnode) ldlm_resource_putref_locked(res); } -static void ldlm_res_hop_put(cfs_hash_t *hs, struct hlist_node *hnode) +static void ldlm_res_hop_put(struct cfs_hash *hs, struct hlist_node *hnode) { struct ldlm_resource *res; @@ -564,7 +564,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, struct ldlm_namespace *ns = NULL; struct ldlm_ns_bucket *nsb; ldlm_ns_hash_def_t *nsd; - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; int idx; int rc; @@ -743,7 +743,7 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q, } while (1); } -static int ldlm_resource_clean(cfs_hash_t *hs, cfs_hash_bd_t *bd, +static int ldlm_resource_clean(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *arg) { struct ldlm_resource *res = cfs_hash_object(hs, hnode); @@ -756,7 +756,7 @@ static int ldlm_resource_clean(cfs_hash_t *hs, cfs_hash_bd_t *bd, return 0; } -static int ldlm_resource_complain(cfs_hash_t *hs, cfs_hash_bd_t *bd, +static int ldlm_resource_complain(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *arg) { struct ldlm_resource *res = cfs_hash_object(hs, hnode); @@ -1060,7 +1060,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, { struct hlist_node *hnode; struct ldlm_resource *res; - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; __u64 version; int ns_refcount = 0; @@ -1115,7 +1115,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, lu_ref_fini(&res->lr_reference); /* We have taken lr_lvb_mutex. Drop it. */ mutex_unlock(&res->lr_lvb_mutex); - OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res); + OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof(*res)); res = hlist_entry(hnode, struct ldlm_resource, lr_hash); /* Synchronize with regard to resource creation. */ @@ -1183,7 +1183,7 @@ struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res) return res; } -static void __ldlm_resource_putref_final(cfs_hash_bd_t *bd, +static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd, struct ldlm_resource *res) { struct ldlm_ns_bucket *nsb = res->lr_ns_bucket; @@ -1214,7 +1214,7 @@ static void __ldlm_resource_putref_final(cfs_hash_bd_t *bd, int ldlm_resource_putref(struct ldlm_resource *res) { struct ldlm_namespace *ns = ldlm_res_to_ns(res); - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; LASSERT_ATOMIC_GT_LT(&res->lr_refcount, 0, LI_POISON); CDEBUG(D_INFO, "putref res: %p count: %d\n", @@ -1226,7 +1226,7 @@ int ldlm_resource_putref(struct ldlm_resource *res) cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free) ns->ns_lvbo->lvbo_free(res); - OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res); + OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof(*res)); return 1; } return 0; @@ -1243,7 +1243,7 @@ int ldlm_resource_putref_locked(struct ldlm_resource *res) res, atomic_read(&res->lr_refcount) - 1); if (atomic_dec_and_test(&res->lr_refcount)) { - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; cfs_hash_bd_get(ldlm_res_to_ns(res)->ns_rs_hash, &res->lr_name, &bd); @@ -1256,7 +1256,7 @@ int ldlm_resource_putref_locked(struct ldlm_resource *res) */ if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free) ns->ns_lvbo->lvbo_free(res); - OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res); + OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof(*res)); cfs_hash_bd_lock(ns->ns_rs_hash, &bd, 1); return 1; @@ -1352,7 +1352,7 @@ void ldlm_dump_all_namespaces(ldlm_side_t client, int level) } EXPORT_SYMBOL(ldlm_dump_all_namespaces); -static int ldlm_res_hash_dump(cfs_hash_t *hs, cfs_hash_bd_t *bd, +static int ldlm_res_hash_dump(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *arg) { struct ldlm_resource *res = cfs_hash_object(hs, hnode); diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index 0dd12c8c91b6..e3e0578b27f9 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -119,25 +119,25 @@ CFS_MODULE_PARM(warn_on_depth, "i", uint, 0644, struct cfs_wi_sched *cfs_sched_rehash; static inline void -cfs_hash_nl_lock(cfs_hash_lock_t *lock, int exclusive) {} +cfs_hash_nl_lock(union cfs_hash_lock *lock, int exclusive) {} static inline void -cfs_hash_nl_unlock(cfs_hash_lock_t *lock, int exclusive) {} +cfs_hash_nl_unlock(union cfs_hash_lock *lock, int exclusive) {} static inline void -cfs_hash_spin_lock(cfs_hash_lock_t *lock, int exclusive) +cfs_hash_spin_lock(union cfs_hash_lock *lock, int exclusive) { spin_lock(&lock->spin); } static inline void -cfs_hash_spin_unlock(cfs_hash_lock_t *lock, int exclusive) +cfs_hash_spin_unlock(union cfs_hash_lock *lock, int exclusive) { spin_unlock(&lock->spin); } static inline void -cfs_hash_rw_lock(cfs_hash_lock_t *lock, int exclusive) +cfs_hash_rw_lock(union cfs_hash_lock *lock, int exclusive) { if (!exclusive) read_lock(&lock->rw); @@ -146,7 +146,7 @@ cfs_hash_rw_lock(cfs_hash_lock_t *lock, int exclusive) } static inline void -cfs_hash_rw_unlock(cfs_hash_lock_t *lock, int exclusive) +cfs_hash_rw_unlock(union cfs_hash_lock *lock, int exclusive) { if (!exclusive) read_unlock(&lock->rw); @@ -209,7 +209,7 @@ static cfs_hash_lock_ops_t cfs_hash_nr_bkt_rw_lops = }; static void -cfs_hash_lock_setup(cfs_hash_t *hs) +cfs_hash_lock_setup(struct cfs_hash *hs) { if (cfs_hash_with_no_lock(hs)) { hs->hs_lops = &cfs_hash_nl_lops; @@ -246,13 +246,13 @@ typedef struct { } cfs_hash_head_t; static int -cfs_hash_hh_hhead_size(cfs_hash_t *hs) +cfs_hash_hh_hhead_size(struct cfs_hash *hs) { return sizeof(cfs_hash_head_t); } static struct hlist_head * -cfs_hash_hh_hhead(cfs_hash_t *hs, cfs_hash_bd_t *bd) +cfs_hash_hh_hhead(struct cfs_hash *hs, struct cfs_hash_bd *bd) { cfs_hash_head_t *head = (cfs_hash_head_t *)&bd->bd_bucket->hsb_head[0]; @@ -260,7 +260,7 @@ cfs_hash_hh_hhead(cfs_hash_t *hs, cfs_hash_bd_t *bd) } static int -cfs_hash_hh_hnode_add(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_hh_hnode_add(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode) { hlist_add_head(hnode, cfs_hash_hh_hhead(hs, bd)); @@ -268,7 +268,7 @@ cfs_hash_hh_hnode_add(cfs_hash_t *hs, cfs_hash_bd_t *bd, } static int -cfs_hash_hh_hnode_del(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_hh_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode) { hlist_del_init(hnode); @@ -285,13 +285,13 @@ typedef struct { } cfs_hash_head_dep_t; static int -cfs_hash_hd_hhead_size(cfs_hash_t *hs) +cfs_hash_hd_hhead_size(struct cfs_hash *hs) { return sizeof(cfs_hash_head_dep_t); } static struct hlist_head * -cfs_hash_hd_hhead(cfs_hash_t *hs, cfs_hash_bd_t *bd) +cfs_hash_hd_hhead(struct cfs_hash *hs, struct cfs_hash_bd *bd) { cfs_hash_head_dep_t *head; @@ -300,7 +300,7 @@ cfs_hash_hd_hhead(cfs_hash_t *hs, cfs_hash_bd_t *bd) } static int -cfs_hash_hd_hnode_add(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_hd_hnode_add(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode) { cfs_hash_head_dep_t *hh = container_of(cfs_hash_hd_hhead(hs, bd), @@ -310,7 +310,7 @@ cfs_hash_hd_hnode_add(cfs_hash_t *hs, cfs_hash_bd_t *bd, } static int -cfs_hash_hd_hnode_del(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_hd_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode) { cfs_hash_head_dep_t *hh = container_of(cfs_hash_hd_hhead(hs, bd), @@ -329,13 +329,13 @@ typedef struct { } cfs_hash_dhead_t; static int -cfs_hash_dh_hhead_size(cfs_hash_t *hs) +cfs_hash_dh_hhead_size(struct cfs_hash *hs) { return sizeof(cfs_hash_dhead_t); } static struct hlist_head * -cfs_hash_dh_hhead(cfs_hash_t *hs, cfs_hash_bd_t *bd) +cfs_hash_dh_hhead(struct cfs_hash *hs, struct cfs_hash_bd *bd) { cfs_hash_dhead_t *head; @@ -344,7 +344,7 @@ cfs_hash_dh_hhead(cfs_hash_t *hs, cfs_hash_bd_t *bd) } static int -cfs_hash_dh_hnode_add(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_dh_hnode_add(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode) { cfs_hash_dhead_t *dh = container_of(cfs_hash_dh_hhead(hs, bd), @@ -359,7 +359,7 @@ cfs_hash_dh_hnode_add(cfs_hash_t *hs, cfs_hash_bd_t *bd, } static int -cfs_hash_dh_hnode_del(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_dh_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnd) { cfs_hash_dhead_t *dh = container_of(cfs_hash_dh_hhead(hs, bd), @@ -384,13 +384,13 @@ typedef struct { } cfs_hash_dhead_dep_t; static int -cfs_hash_dd_hhead_size(cfs_hash_t *hs) +cfs_hash_dd_hhead_size(struct cfs_hash *hs) { return sizeof(cfs_hash_dhead_dep_t); } static struct hlist_head * -cfs_hash_dd_hhead(cfs_hash_t *hs, cfs_hash_bd_t *bd) +cfs_hash_dd_hhead(struct cfs_hash *hs, struct cfs_hash_bd *bd) { cfs_hash_dhead_dep_t *head; @@ -399,7 +399,7 @@ cfs_hash_dd_hhead(cfs_hash_t *hs, cfs_hash_bd_t *bd) } static int -cfs_hash_dd_hnode_add(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_dd_hnode_add(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode) { cfs_hash_dhead_dep_t *dh = container_of(cfs_hash_dd_hhead(hs, bd), @@ -414,7 +414,7 @@ cfs_hash_dd_hnode_add(cfs_hash_t *hs, cfs_hash_bd_t *bd, } static int -cfs_hash_dd_hnode_del(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_dd_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnd) { cfs_hash_dhead_dep_t *dh = container_of(cfs_hash_dd_hhead(hs, bd), @@ -457,7 +457,7 @@ static cfs_hash_hlist_ops_t cfs_hash_dd_hops = { }; static void -cfs_hash_hlist_setup(cfs_hash_t *hs) +cfs_hash_hlist_setup(struct cfs_hash *hs) { if (cfs_hash_with_add_tail(hs)) { hs->hs_hops = cfs_hash_with_depth(hs) ? @@ -469,8 +469,8 @@ cfs_hash_hlist_setup(cfs_hash_t *hs) } static void -cfs_hash_bd_from_key(cfs_hash_t *hs, cfs_hash_bucket_t **bkts, - unsigned int bits, const void *key, cfs_hash_bd_t *bd) +cfs_hash_bd_from_key(struct cfs_hash *hs, struct cfs_hash_bucket **bkts, + unsigned int bits, const void *key, struct cfs_hash_bd *bd) { unsigned int index = cfs_hash_id(hs, key, (1U << bits) - 1); @@ -481,7 +481,7 @@ cfs_hash_bd_from_key(cfs_hash_t *hs, cfs_hash_bucket_t **bkts, } void -cfs_hash_bd_get(cfs_hash_t *hs, const void *key, cfs_hash_bd_t *bd) +cfs_hash_bd_get(struct cfs_hash *hs, const void *key, struct cfs_hash_bd *bd) { /* NB: caller should hold hs->hs_rwlock if REHASH is set */ if (likely(hs->hs_rehash_buckets == NULL)) { @@ -496,7 +496,7 @@ cfs_hash_bd_get(cfs_hash_t *hs, const void *key, cfs_hash_bd_t *bd) EXPORT_SYMBOL(cfs_hash_bd_get); static inline void -cfs_hash_bd_dep_record(cfs_hash_t *hs, cfs_hash_bd_t *bd, int dep_cur) +cfs_hash_bd_dep_record(struct cfs_hash *hs, struct cfs_hash_bd *bd, int dep_cur) { if (likely(dep_cur <= bd->bd_bucket->hsb_depmax)) return; @@ -519,7 +519,7 @@ cfs_hash_bd_dep_record(cfs_hash_t *hs, cfs_hash_bd_t *bd, int dep_cur) } void -cfs_hash_bd_add_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_bd_add_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode) { int rc; @@ -539,7 +539,7 @@ cfs_hash_bd_add_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, EXPORT_SYMBOL(cfs_hash_bd_add_locked); void -cfs_hash_bd_del_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_bd_del_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode) { hs->hs_hops->hop_hnode_del(hs, bd, hnode); @@ -560,11 +560,11 @@ cfs_hash_bd_del_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, EXPORT_SYMBOL(cfs_hash_bd_del_locked); void -cfs_hash_bd_move_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd_old, - cfs_hash_bd_t *bd_new, struct hlist_node *hnode) +cfs_hash_bd_move_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd_old, + struct cfs_hash_bd *bd_new, struct hlist_node *hnode) { - cfs_hash_bucket_t *obkt = bd_old->bd_bucket; - cfs_hash_bucket_t *nbkt = bd_new->bd_bucket; + struct cfs_hash_bucket *obkt = bd_old->bd_bucket; + struct cfs_hash_bucket *nbkt = bd_new->bd_bucket; int rc; if (cfs_hash_bd_compare(bd_old, bd_new) == 0) @@ -617,7 +617,7 @@ typedef enum cfs_hash_lookup_intent { } cfs_hash_lookup_intent_t; static struct hlist_node * -cfs_hash_bd_lookup_intent(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_bd_lookup_intent(struct cfs_hash *hs, struct cfs_hash_bd *bd, const void *key, struct hlist_node *hnode, cfs_hash_lookup_intent_t intent) @@ -658,7 +658,7 @@ cfs_hash_bd_lookup_intent(cfs_hash_t *hs, cfs_hash_bd_t *bd, } struct hlist_node * -cfs_hash_bd_lookup_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, const void *key) +cfs_hash_bd_lookup_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd, const void *key) { return cfs_hash_bd_lookup_intent(hs, bd, key, NULL, CFS_HS_LOOKUP_IT_FIND); @@ -666,7 +666,7 @@ cfs_hash_bd_lookup_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, const void *key) EXPORT_SYMBOL(cfs_hash_bd_lookup_locked); struct hlist_node * -cfs_hash_bd_peek_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, const void *key) +cfs_hash_bd_peek_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd, const void *key) { return cfs_hash_bd_lookup_intent(hs, bd, key, NULL, CFS_HS_LOOKUP_IT_PEEK); @@ -674,7 +674,7 @@ cfs_hash_bd_peek_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, const void *key) EXPORT_SYMBOL(cfs_hash_bd_peek_locked); struct hlist_node * -cfs_hash_bd_findadd_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_bd_findadd_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd, const void *key, struct hlist_node *hnode, int noref) { @@ -685,7 +685,7 @@ cfs_hash_bd_findadd_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, EXPORT_SYMBOL(cfs_hash_bd_findadd_locked); struct hlist_node * -cfs_hash_bd_finddel_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_bd_finddel_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd, const void *key, struct hlist_node *hnode) { /* hnode can be NULL, we find the first item with @key */ @@ -695,10 +695,10 @@ cfs_hash_bd_finddel_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, EXPORT_SYMBOL(cfs_hash_bd_finddel_locked); static void -cfs_hash_multi_bd_lock(cfs_hash_t *hs, cfs_hash_bd_t *bds, +cfs_hash_multi_bd_lock(struct cfs_hash *hs, struct cfs_hash_bd *bds, unsigned n, int excl) { - cfs_hash_bucket_t *prev = NULL; + struct cfs_hash_bucket *prev = NULL; int i; /** @@ -718,10 +718,10 @@ cfs_hash_multi_bd_lock(cfs_hash_t *hs, cfs_hash_bd_t *bds, } static void -cfs_hash_multi_bd_unlock(cfs_hash_t *hs, cfs_hash_bd_t *bds, +cfs_hash_multi_bd_unlock(struct cfs_hash *hs, struct cfs_hash_bd *bds, unsigned n, int excl) { - cfs_hash_bucket_t *prev = NULL; + struct cfs_hash_bucket *prev = NULL; int i; cfs_hash_for_each_bd(bds, n, i) { @@ -733,7 +733,7 @@ cfs_hash_multi_bd_unlock(cfs_hash_t *hs, cfs_hash_bd_t *bds, } static struct hlist_node * -cfs_hash_multi_bd_lookup_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds, +cfs_hash_multi_bd_lookup_locked(struct cfs_hash *hs, struct cfs_hash_bd *bds, unsigned n, const void *key) { struct hlist_node *ehnode; @@ -749,8 +749,8 @@ cfs_hash_multi_bd_lookup_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds, } static struct hlist_node * -cfs_hash_multi_bd_findadd_locked(cfs_hash_t *hs, - cfs_hash_bd_t *bds, unsigned n, const void *key, +cfs_hash_multi_bd_findadd_locked(struct cfs_hash *hs, + struct cfs_hash_bd *bds, unsigned n, const void *key, struct hlist_node *hnode, int noref) { struct hlist_node *ehnode; @@ -770,7 +770,7 @@ cfs_hash_multi_bd_findadd_locked(cfs_hash_t *hs, if (i == 1) { /* only one bucket */ cfs_hash_bd_add_locked(hs, &bds[0], hnode); } else { - cfs_hash_bd_t mybd; + struct cfs_hash_bd mybd; cfs_hash_bd_get(hs, key, &mybd); cfs_hash_bd_add_locked(hs, &mybd, hnode); @@ -780,7 +780,7 @@ cfs_hash_multi_bd_findadd_locked(cfs_hash_t *hs, } static struct hlist_node * -cfs_hash_multi_bd_finddel_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds, +cfs_hash_multi_bd_finddel_locked(struct cfs_hash *hs, struct cfs_hash_bd *bds, unsigned n, const void *key, struct hlist_node *hnode) { @@ -797,7 +797,7 @@ cfs_hash_multi_bd_finddel_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds, } static void -cfs_hash_bd_order(cfs_hash_bd_t *bd1, cfs_hash_bd_t *bd2) +cfs_hash_bd_order(struct cfs_hash_bd *bd1, struct cfs_hash_bd *bd2) { int rc; @@ -815,7 +815,7 @@ cfs_hash_bd_order(cfs_hash_bd_t *bd1, cfs_hash_bd_t *bd2) bd2->bd_bucket = NULL; } else if (rc > 0) { /* swab bd1 and bd2 */ - cfs_hash_bd_t tmp; + struct cfs_hash_bd tmp; tmp = *bd2; *bd2 = *bd1; @@ -824,7 +824,7 @@ cfs_hash_bd_order(cfs_hash_bd_t *bd1, cfs_hash_bd_t *bd2) } void -cfs_hash_dual_bd_get(cfs_hash_t *hs, const void *key, cfs_hash_bd_t *bds) +cfs_hash_dual_bd_get(struct cfs_hash *hs, const void *key, struct cfs_hash_bd *bds) { /* NB: caller should hold hs_lock.rw if REHASH is set */ cfs_hash_bd_from_key(hs, hs->hs_buckets, @@ -844,21 +844,21 @@ cfs_hash_dual_bd_get(cfs_hash_t *hs, const void *key, cfs_hash_bd_t *bds) EXPORT_SYMBOL(cfs_hash_dual_bd_get); void -cfs_hash_dual_bd_lock(cfs_hash_t *hs, cfs_hash_bd_t *bds, int excl) +cfs_hash_dual_bd_lock(struct cfs_hash *hs, struct cfs_hash_bd *bds, int excl) { cfs_hash_multi_bd_lock(hs, bds, 2, excl); } EXPORT_SYMBOL(cfs_hash_dual_bd_lock); void -cfs_hash_dual_bd_unlock(cfs_hash_t *hs, cfs_hash_bd_t *bds, int excl) +cfs_hash_dual_bd_unlock(struct cfs_hash *hs, struct cfs_hash_bd *bds, int excl) { cfs_hash_multi_bd_unlock(hs, bds, 2, excl); } EXPORT_SYMBOL(cfs_hash_dual_bd_unlock); struct hlist_node * -cfs_hash_dual_bd_lookup_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds, +cfs_hash_dual_bd_lookup_locked(struct cfs_hash *hs, struct cfs_hash_bd *bds, const void *key) { return cfs_hash_multi_bd_lookup_locked(hs, bds, 2, key); @@ -866,7 +866,7 @@ cfs_hash_dual_bd_lookup_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds, EXPORT_SYMBOL(cfs_hash_dual_bd_lookup_locked); struct hlist_node * -cfs_hash_dual_bd_findadd_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds, +cfs_hash_dual_bd_findadd_locked(struct cfs_hash *hs, struct cfs_hash_bd *bds, const void *key, struct hlist_node *hnode, int noref) { @@ -876,7 +876,7 @@ cfs_hash_dual_bd_findadd_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds, EXPORT_SYMBOL(cfs_hash_dual_bd_findadd_locked); struct hlist_node * -cfs_hash_dual_bd_finddel_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds, +cfs_hash_dual_bd_finddel_locked(struct cfs_hash *hs, struct cfs_hash_bd *bds, const void *key, struct hlist_node *hnode) { return cfs_hash_multi_bd_finddel_locked(hs, bds, 2, key, hnode); @@ -884,7 +884,7 @@ cfs_hash_dual_bd_finddel_locked(cfs_hash_t *hs, cfs_hash_bd_t *bds, EXPORT_SYMBOL(cfs_hash_dual_bd_finddel_locked); static void -cfs_hash_buckets_free(cfs_hash_bucket_t **buckets, +cfs_hash_buckets_free(struct cfs_hash_bucket **buckets, int bkt_size, int prev_size, int size) { int i; @@ -902,11 +902,11 @@ cfs_hash_buckets_free(cfs_hash_bucket_t **buckets, * needed, the newly allocated buckets if allocation was needed and * successful, and NULL on error. */ -static cfs_hash_bucket_t ** -cfs_hash_buckets_realloc(cfs_hash_t *hs, cfs_hash_bucket_t **old_bkts, +static struct cfs_hash_bucket ** +cfs_hash_buckets_realloc(struct cfs_hash *hs, struct cfs_hash_bucket **old_bkts, unsigned int old_size, unsigned int new_size) { - cfs_hash_bucket_t **new_bkts; + struct cfs_hash_bucket **new_bkts; int i; LASSERT(old_size == 0 || old_bkts != NULL); @@ -925,7 +925,7 @@ cfs_hash_buckets_realloc(cfs_hash_t *hs, cfs_hash_bucket_t **old_bkts, for (i = old_size; i < new_size; i++) { struct hlist_head *hhead; - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; LIBCFS_ALLOC(new_bkts[i], cfs_hash_bkt_size(hs)); if (new_bkts[i] == NULL) { @@ -969,7 +969,7 @@ static int cfs_hash_rehash_worker(cfs_workitem_t *wi); #if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1 static int cfs_hash_dep_print(cfs_workitem_t *wi) { - cfs_hash_t *hs = container_of(wi, cfs_hash_t, hs_dep_wi); + struct cfs_hash *hs = container_of(wi, struct cfs_hash, hs_dep_wi); int dep; int bkt; int off; @@ -990,13 +990,13 @@ static int cfs_hash_dep_print(cfs_workitem_t *wi) return 0; } -static void cfs_hash_depth_wi_init(cfs_hash_t *hs) +static void cfs_hash_depth_wi_init(struct cfs_hash *hs) { spin_lock_init(&hs->hs_dep_lock); cfs_wi_init(&hs->hs_dep_wi, hs, cfs_hash_dep_print); } -static void cfs_hash_depth_wi_cancel(cfs_hash_t *hs) +static void cfs_hash_depth_wi_cancel(struct cfs_hash *hs) { if (cfs_wi_deschedule(cfs_sched_rehash, &hs->hs_dep_wi)) return; @@ -1012,18 +1012,18 @@ static void cfs_hash_depth_wi_cancel(cfs_hash_t *hs) #else /* CFS_HASH_DEBUG_LEVEL < CFS_HASH_DEBUG_1 */ -static inline void cfs_hash_depth_wi_init(cfs_hash_t *hs) {} -static inline void cfs_hash_depth_wi_cancel(cfs_hash_t *hs) {} +static inline void cfs_hash_depth_wi_init(struct cfs_hash *hs) {} +static inline void cfs_hash_depth_wi_cancel(struct cfs_hash *hs) {} #endif /* CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1 */ -cfs_hash_t * +struct cfs_hash * cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, unsigned bkt_bits, unsigned extra_bytes, unsigned min_theta, unsigned max_theta, cfs_hash_ops_t *ops, unsigned flags) { - cfs_hash_t *hs; + struct cfs_hash *hs; int len; CLASSERT(CFS_HASH_THETA_BITS < 15); @@ -1051,7 +1051,7 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, len = (flags & CFS_HASH_BIGNAME) == 0 ? CFS_HASH_NAME_LEN : CFS_HASH_BIGNAME_LEN; - LIBCFS_ALLOC(hs, offsetof(cfs_hash_t, hs_name[len])); + LIBCFS_ALLOC(hs, offsetof(struct cfs_hash, hs_name[len])); if (hs == NULL) return NULL; @@ -1084,7 +1084,7 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, if (hs->hs_buckets != NULL) return hs; - LIBCFS_FREE(hs, offsetof(cfs_hash_t, hs_name[len])); + LIBCFS_FREE(hs, offsetof(struct cfs_hash, hs_name[len])); return NULL; } EXPORT_SYMBOL(cfs_hash_create); @@ -1093,11 +1093,11 @@ EXPORT_SYMBOL(cfs_hash_create); * Cleanup libcfs hash @hs. */ static void -cfs_hash_destroy(cfs_hash_t *hs) +cfs_hash_destroy(struct cfs_hash *hs) { struct hlist_node *hnode; struct hlist_node *pos; - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; int i; LASSERT(hs != NULL); @@ -1148,10 +1148,10 @@ cfs_hash_destroy(cfs_hash_t *hs) 0, CFS_HASH_NBKT(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])); + LIBCFS_FREE(hs, offsetof(struct cfs_hash, hs_name[i])); } -cfs_hash_t *cfs_hash_getref(cfs_hash_t *hs) +struct cfs_hash *cfs_hash_getref(struct cfs_hash *hs) { if (atomic_inc_not_zero(&hs->hs_refcount)) return hs; @@ -1159,7 +1159,7 @@ cfs_hash_t *cfs_hash_getref(cfs_hash_t *hs) } EXPORT_SYMBOL(cfs_hash_getref); -void cfs_hash_putref(cfs_hash_t *hs) +void cfs_hash_putref(struct cfs_hash *hs) { if (atomic_dec_and_test(&hs->hs_refcount)) cfs_hash_destroy(hs); @@ -1167,7 +1167,7 @@ void cfs_hash_putref(cfs_hash_t *hs) EXPORT_SYMBOL(cfs_hash_putref); static inline int -cfs_hash_rehash_bits(cfs_hash_t *hs) +cfs_hash_rehash_bits(struct cfs_hash *hs) { if (cfs_hash_with_no_lock(hs) || !cfs_hash_with_rehash(hs)) @@ -1204,7 +1204,7 @@ cfs_hash_rehash_bits(cfs_hash_t *hs) * - too many elements */ static inline int -cfs_hash_rehash_inline(cfs_hash_t *hs) +cfs_hash_rehash_inline(struct cfs_hash *hs) { return !cfs_hash_with_nblk_change(hs) && atomic_read(&hs->hs_count) < CFS_HASH_LOOP_HOG; @@ -1215,9 +1215,9 @@ cfs_hash_rehash_inline(cfs_hash_t *hs) * ops->hs_get function will be called when the item is added. */ void -cfs_hash_add(cfs_hash_t *hs, const void *key, struct hlist_node *hnode) +cfs_hash_add(struct cfs_hash *hs, const void *key, struct hlist_node *hnode) { - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; int bits; LASSERT(hlist_unhashed(hnode)); @@ -1238,11 +1238,11 @@ cfs_hash_add(cfs_hash_t *hs, const void *key, struct hlist_node *hnode) EXPORT_SYMBOL(cfs_hash_add); static struct hlist_node * -cfs_hash_find_or_add(cfs_hash_t *hs, const void *key, +cfs_hash_find_or_add(struct cfs_hash *hs, const void *key, struct hlist_node *hnode, int noref) { struct hlist_node *ehnode; - cfs_hash_bd_t bds[2]; + struct cfs_hash_bd bds[2]; int bits = 0; LASSERT(hlist_unhashed(hnode)); @@ -1270,7 +1270,7 @@ cfs_hash_find_or_add(cfs_hash_t *hs, const void *key, * Returns 0 on success or -EALREADY on key collisions. */ int -cfs_hash_add_unique(cfs_hash_t *hs, const void *key, struct hlist_node *hnode) +cfs_hash_add_unique(struct cfs_hash *hs, const void *key, struct hlist_node *hnode) { return cfs_hash_find_or_add(hs, key, hnode, 1) != hnode ? -EALREADY : 0; @@ -1284,7 +1284,7 @@ EXPORT_SYMBOL(cfs_hash_add_unique); * Otherwise ops->hs_get is called on the item which was added. */ void * -cfs_hash_findadd_unique(cfs_hash_t *hs, const void *key, +cfs_hash_findadd_unique(struct cfs_hash *hs, const void *key, struct hlist_node *hnode) { hnode = cfs_hash_find_or_add(hs, key, hnode, 0); @@ -1301,11 +1301,11 @@ EXPORT_SYMBOL(cfs_hash_findadd_unique); * on the removed object. */ void * -cfs_hash_del(cfs_hash_t *hs, const void *key, struct hlist_node *hnode) +cfs_hash_del(struct cfs_hash *hs, const void *key, struct hlist_node *hnode) { void *obj = NULL; int bits = 0; - cfs_hash_bd_t bds[2]; + struct cfs_hash_bd bds[2]; cfs_hash_lock(hs, 0); cfs_hash_dual_bd_get_and_lock(hs, key, bds, 1); @@ -1341,7 +1341,7 @@ EXPORT_SYMBOL(cfs_hash_del); * will be returned and ops->hs_put is called on the removed object. */ void * -cfs_hash_del_key(cfs_hash_t *hs, const void *key) +cfs_hash_del_key(struct cfs_hash *hs, const void *key) { return cfs_hash_del(hs, key, NULL); } @@ -1356,11 +1356,11 @@ EXPORT_SYMBOL(cfs_hash_del_key); * in the hash @hs NULL is returned. */ void * -cfs_hash_lookup(cfs_hash_t *hs, const void *key) +cfs_hash_lookup(struct cfs_hash *hs, const void *key) { void *obj = NULL; struct hlist_node *hnode; - cfs_hash_bd_t bds[2]; + struct cfs_hash_bd bds[2]; cfs_hash_lock(hs, 0); cfs_hash_dual_bd_get_and_lock(hs, key, bds, 0); @@ -1377,7 +1377,7 @@ cfs_hash_lookup(cfs_hash_t *hs, const void *key) EXPORT_SYMBOL(cfs_hash_lookup); static void -cfs_hash_for_each_enter(cfs_hash_t *hs) +cfs_hash_for_each_enter(struct cfs_hash *hs) { LASSERT(!cfs_hash_is_exiting(hs)); @@ -1403,7 +1403,7 @@ cfs_hash_for_each_enter(cfs_hash_t *hs) } static void -cfs_hash_for_each_exit(cfs_hash_t *hs) +cfs_hash_for_each_exit(struct cfs_hash *hs) { int remained; int bits; @@ -1434,12 +1434,12 @@ cfs_hash_for_each_exit(cfs_hash_t *hs) * cfs_hash_bd_del_locked */ static __u64 -cfs_hash_for_each_tight(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, +cfs_hash_for_each_tight(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, void *data, int remove_safe) { struct hlist_node *hnode; struct hlist_node *pos; - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; __u64 count = 0; int excl = !!remove_safe; int loop = 0; @@ -1492,7 +1492,7 @@ typedef struct { } cfs_hash_cond_arg_t; static int -cfs_hash_cond_del_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_cond_del_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *data) { cfs_hash_cond_arg_t *cond = data; @@ -1508,7 +1508,7 @@ cfs_hash_cond_del_locked(cfs_hash_t *hs, cfs_hash_bd_t *bd, * any object be reference. */ void -cfs_hash_cond_del(cfs_hash_t *hs, cfs_hash_cond_opt_cb_t func, void *data) +cfs_hash_cond_del(struct cfs_hash *hs, cfs_hash_cond_opt_cb_t func, void *data) { cfs_hash_cond_arg_t arg = { .func = func, @@ -1520,7 +1520,7 @@ cfs_hash_cond_del(cfs_hash_t *hs, cfs_hash_cond_opt_cb_t func, void *data) EXPORT_SYMBOL(cfs_hash_cond_del); void -cfs_hash_for_each(cfs_hash_t *hs, +cfs_hash_for_each(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, void *data) { cfs_hash_for_each_tight(hs, func, data, 0); @@ -1528,7 +1528,7 @@ cfs_hash_for_each(cfs_hash_t *hs, EXPORT_SYMBOL(cfs_hash_for_each); void -cfs_hash_for_each_safe(cfs_hash_t *hs, +cfs_hash_for_each_safe(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, void *data) { cfs_hash_for_each_tight(hs, func, data, 1); @@ -1536,7 +1536,7 @@ cfs_hash_for_each_safe(cfs_hash_t *hs, EXPORT_SYMBOL(cfs_hash_for_each_safe); static int -cfs_hash_peek(cfs_hash_t *hs, cfs_hash_bd_t *bd, +cfs_hash_peek(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *data) { *(int *)data = 0; @@ -1544,7 +1544,7 @@ cfs_hash_peek(cfs_hash_t *hs, cfs_hash_bd_t *bd, } int -cfs_hash_is_empty(cfs_hash_t *hs) +cfs_hash_is_empty(struct cfs_hash *hs) { int empty = 1; @@ -1554,7 +1554,7 @@ cfs_hash_is_empty(cfs_hash_t *hs) EXPORT_SYMBOL(cfs_hash_is_empty); __u64 -cfs_hash_size_get(cfs_hash_t *hs) +cfs_hash_size_get(struct cfs_hash *hs) { return cfs_hash_with_counter(hs) ? atomic_read(&hs->hs_count) : @@ -1578,11 +1578,11 @@ EXPORT_SYMBOL(cfs_hash_size_get); * two cases, so iteration has to be stopped on change. */ static int -cfs_hash_for_each_relax(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, void *data) +cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, void *data) { struct hlist_node *hnode; struct hlist_node *tmp; - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; __u32 version; int count = 0; int stop_on_change; @@ -1639,7 +1639,7 @@ cfs_hash_for_each_relax(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, void *data) } int -cfs_hash_for_each_nolock(cfs_hash_t *hs, +cfs_hash_for_each_nolock(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, void *data) { if (cfs_hash_with_no_lock(hs) || @@ -1672,7 +1672,7 @@ EXPORT_SYMBOL(cfs_hash_for_each_nolock); * the required locking is in place to prevent concurrent insertions. */ int -cfs_hash_for_each_empty(cfs_hash_t *hs, +cfs_hash_for_each_empty(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, void *data) { unsigned i = 0; @@ -1696,12 +1696,12 @@ cfs_hash_for_each_empty(cfs_hash_t *hs, EXPORT_SYMBOL(cfs_hash_for_each_empty); void -cfs_hash_hlist_for_each(cfs_hash_t *hs, unsigned hindex, +cfs_hash_hlist_for_each(struct cfs_hash *hs, unsigned hindex, cfs_hash_for_each_cb_t func, void *data) { struct hlist_head *hhead; struct hlist_node *hnode; - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; cfs_hash_for_each_enter(hs); cfs_hash_lock(hs, 0); @@ -1731,11 +1731,11 @@ EXPORT_SYMBOL(cfs_hash_hlist_for_each); * is held so the callback must never sleep. */ void -cfs_hash_for_each_key(cfs_hash_t *hs, const void *key, +cfs_hash_for_each_key(struct cfs_hash *hs, const void *key, cfs_hash_for_each_cb_t func, void *data) { struct hlist_node *hnode; - cfs_hash_bd_t bds[2]; + struct cfs_hash_bd bds[2]; unsigned i; cfs_hash_lock(hs, 0); @@ -1772,7 +1772,7 @@ EXPORT_SYMBOL(cfs_hash_for_each_key); * theta thresholds for @hs are tunable via cfs_hash_set_theta(). */ void -cfs_hash_rehash_cancel_locked(cfs_hash_t *hs) +cfs_hash_rehash_cancel_locked(struct cfs_hash *hs) { int i; @@ -1801,7 +1801,7 @@ cfs_hash_rehash_cancel_locked(cfs_hash_t *hs) EXPORT_SYMBOL(cfs_hash_rehash_cancel_locked); void -cfs_hash_rehash_cancel(cfs_hash_t *hs) +cfs_hash_rehash_cancel(struct cfs_hash *hs) { cfs_hash_lock(hs, 1); cfs_hash_rehash_cancel_locked(hs); @@ -1810,7 +1810,7 @@ cfs_hash_rehash_cancel(cfs_hash_t *hs) EXPORT_SYMBOL(cfs_hash_rehash_cancel); int -cfs_hash_rehash(cfs_hash_t *hs, int do_rehash) +cfs_hash_rehash(struct cfs_hash *hs, int do_rehash) { int rc; @@ -1840,9 +1840,9 @@ cfs_hash_rehash(cfs_hash_t *hs, int do_rehash) EXPORT_SYMBOL(cfs_hash_rehash); static int -cfs_hash_rehash_bd(cfs_hash_t *hs, cfs_hash_bd_t *old) +cfs_hash_rehash_bd(struct cfs_hash *hs, struct cfs_hash_bd *old) { - cfs_hash_bd_t new; + struct cfs_hash_bd new; struct hlist_head *hhead; struct hlist_node *hnode; struct hlist_node *pos; @@ -1873,9 +1873,9 @@ cfs_hash_rehash_bd(cfs_hash_t *hs, cfs_hash_bd_t *old) static int cfs_hash_rehash_worker(cfs_workitem_t *wi) { - cfs_hash_t *hs = container_of(wi, cfs_hash_t, hs_rehash_wi); - cfs_hash_bucket_t **bkts; - cfs_hash_bd_t bd; + struct cfs_hash *hs = container_of(wi, struct cfs_hash, hs_rehash_wi); + struct cfs_hash_bucket **bkts; + struct cfs_hash_bd bd; unsigned int old_size; unsigned int new_size; int bsize; @@ -1965,7 +1965,7 @@ cfs_hash_rehash_worker(cfs_workitem_t *wi) if (bkts != NULL) cfs_hash_buckets_free(bkts, bsize, new_size, old_size); if (rc != 0) - CDEBUG(D_INFO, "early quit of of rehashing: %d\n", rc); + CDEBUG(D_INFO, "early quit of rehashing: %d\n", rc); /* return 1 only if cfs_wi_exit is called */ return rc == -ESRCH; } @@ -1980,12 +1980,12 @@ cfs_hash_rehash_worker(cfs_workitem_t *wi) * the registered cfs_hash_get() and cfs_hash_put() functions will * not be called. */ -void cfs_hash_rehash_key(cfs_hash_t *hs, const void *old_key, +void cfs_hash_rehash_key(struct cfs_hash *hs, const void *old_key, void *new_key, struct hlist_node *hnode) { - cfs_hash_bd_t bds[3]; - cfs_hash_bd_t old_bds[2]; - cfs_hash_bd_t new_bd; + struct cfs_hash_bd bds[3]; + struct cfs_hash_bd old_bds[2]; + struct cfs_hash_bd new_bd; LASSERT(!hlist_unhashed(hnode)); @@ -2028,8 +2028,8 @@ int cfs_hash_debug_header(struct seq_file *m) } EXPORT_SYMBOL(cfs_hash_debug_header); -static cfs_hash_bucket_t ** -cfs_hash_full_bkts(cfs_hash_t *hs) +static struct cfs_hash_bucket ** +cfs_hash_full_bkts(struct cfs_hash *hs) { /* NB: caller should hold hs->hs_rwlock if REHASH is set */ if (hs->hs_rehash_buckets == NULL) @@ -2041,7 +2041,7 @@ cfs_hash_full_bkts(cfs_hash_t *hs) } static unsigned int -cfs_hash_full_nbkt(cfs_hash_t *hs) +cfs_hash_full_nbkt(struct cfs_hash *hs) { /* NB: caller should hold hs->hs_rwlock if REHASH is set */ if (hs->hs_rehash_buckets == NULL) @@ -2052,7 +2052,7 @@ cfs_hash_full_nbkt(cfs_hash_t *hs) CFS_HASH_RH_NBKT(hs) : CFS_HASH_NBKT(hs); } -int cfs_hash_debug_str(cfs_hash_t *hs, struct seq_file *m) +int cfs_hash_debug_str(struct cfs_hash *hs, struct seq_file *m) { int dist[8] = { 0, }; int maxdep = -1; @@ -2089,7 +2089,7 @@ int cfs_hash_debug_str(cfs_hash_t *hs, struct seq_file *m) * Non-Uniform hash distribution: 128/125/0/0/0/0/2/1 */ for (i = 0; i < cfs_hash_full_nbkt(hs); i++) { - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; bd.bd_bucket = cfs_hash_full_bkts(hs)[i]; cfs_hash_bd_lock(hs, &bd, 0); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index ea9e9490031f..0bf8e5d87f1a 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -167,7 +167,7 @@ static int cfs_access_process_vm(struct task_struct *tsk, unsigned long addr, return 0; down_read(&mm->mmap_sem); - /* ignore errors, just check how much was sucessfully transfered */ + /* ignore errors, just check how much was successfully transferred */ while (len) { int bytes, rc, offset; void *maddr; @@ -227,8 +227,10 @@ int cfs_get_environ(const char *key, char *value, int *val_len) * which is already holding mmap_sem for writes. If some other * thread gets the write lock in the meantime, this thread will * block, but at least it won't deadlock on itself. LU-1735 */ - if (down_read_trylock(&mm->mmap_sem) == 0) + if (down_read_trylock(&mm->mmap_sem) == 0) { + kfree(buffer); return -EDEADLK; + } up_read(&mm->mmap_sem); addr = mm->env_start; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index ab1e73168472..cc565b1fb994 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -137,7 +137,7 @@ void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *msgdata) char *argv[6]; char buf[32]; - snprintf (buf, sizeof buf, "%d", msgdata->msg_line); + snprintf(buf, sizeof(buf), "%d", msgdata->msg_line); argv[1] = "LBUG"; argv[2] = (char *)msgdata->msg_file; diff --git a/drivers/staging/lustre/lustre/libcfs/prng.c b/drivers/staging/lustre/lustre/libcfs/prng.c index 69224d84bc4b..f87e9e516546 100644 --- a/drivers/staging/lustre/lustre/libcfs/prng.c +++ b/drivers/staging/lustre/lustre/libcfs/prng.c @@ -70,7 +70,7 @@ static unsigned int seed_y = 362436069; * cfs_rand - creates new seeds * * First it creates new seeds from the previous seeds. Then it generates a - * new psuedo random number for use. + * new pseudo random number for use. * * Returns a pseudo-random 32-bit integer */ @@ -84,7 +84,7 @@ unsigned int cfs_rand(void) EXPORT_SYMBOL(cfs_rand); /** - * cfs_srand - sets the inital seed + * cfs_srand - sets the initial seed * @seed1 : (seed_x) should have the most entropy in the low bits of the word * @seed2 : (seed_y) should have the most entropy in the high bits of the word * diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index 357f40079ae0..f71a3cc63ad8 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -276,7 +276,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, int remain; int mask = msgdata->msg_mask; const char *file = kbasename(msgdata->msg_file); - cfs_debug_limit_state_t *cdls = msgdata->msg_cdls; + struct cfs_debug_limit_state *cdls = msgdata->msg_cdls; tcd = cfs_trace_get_tcd(); diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c index 462172d1a756..1a55c81892e0 100644 --- a/drivers/staging/lustre/lustre/libcfs/workitem.c +++ b/drivers/staging/lustre/lustre/libcfs/workitem.c @@ -397,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/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 09844be5eec4..1f079034bd8f 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -743,7 +743,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, /* In the following we use the fact that LOV_USER_MAGIC_V1 and LOV_USER_MAGIC_V3 have the same initial fields so we do not - need the make the distiction between the 2 versions */ + need to make the distinction between the 2 versions */ if (set_default && mgc->u.cli.cl_mgc_mgsexp) { char *param = NULL; char *buf; diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 253f02688f4f..fb85a58db058 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -364,7 +364,7 @@ static int ll_intent_file_open(struct file *file, void *lmm, that case that lock is also ok */ /* We can also get here if there was cached open handle in revalidate_it * but it disappeared while we were getting from there to ll_file_open. - * But this means this file was closed and immediatelly opened which + * But this means this file was closed and immediately opened which * makes a good candidate for using OPEN lock */ /* If lmmsize & lmm are not 0, we are just setting stripe info * parameters. No need for the open lock */ @@ -1009,7 +1009,7 @@ 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; @@ -1068,7 +1068,7 @@ 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; @@ -2456,8 +2456,8 @@ static int ll_inode_revalidate_fini(struct inode *inode, int rc) if (rc == -ENOENT) { clear_nlink(inode); /* This path cannot be hit for regular files unless in - * case of obscure races, so no need to to validate - * size. */ + * case of obscure races, so no need to validate size. + */ if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) return 0; } else if (rc != 0) { @@ -3011,7 +3011,7 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, /* set layout to file. Unlikely this will fail as old layout was * surely eliminated */ - memset(&conf, 0, sizeof conf); + memset(&conf, 0, sizeof(conf)); conf.coc_opc = OBJECT_CONF_SET; conf.coc_inode = inode; conf.coc_lock = lock; @@ -3034,7 +3034,7 @@ out: ll_get_fsname(inode->i_sb, NULL, 0), inode, PFID(&lli->lli_fid)); - memset(&conf, 0, sizeof conf); + memset(&conf, 0, sizeof(conf)); conf.coc_opc = OBJECT_CONF_WAIT; conf.coc_inode = inode; rc = ll_layout_conf(inode, &conf); diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index 1f5825c87a79..e2996c46b2c0 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -159,7 +159,7 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, } if (flags & LLIF_DONE_WRITING) { /* Some pages are still dirty, it is early to send - * DONE_WRITE. Wait untill all pages will be flushed + * DONE_WRITE. Wait until all pages will be flushed * and try DONE_WRITE again later. */ LASSERT(!(lli->lli_flags & LLIF_DONE_WRITING)); lli->lli_flags |= LLIF_DONE_WRITING; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index b868c2bd58d2..fd584ff7e2df 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1973,10 +1973,10 @@ void ll_umount_begin(struct super_block *sb) OBD_ALLOC_PTR(ioc_data); if (ioc_data) { obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp, - sizeof *ioc_data, ioc_data, NULL); + sizeof(*ioc_data), ioc_data, NULL); obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp, - sizeof *ioc_data, ioc_data, NULL); + sizeof(*ioc_data), ioc_data, NULL); OBD_FREE_PTR(ioc_data); } diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 2340458b8a04..e2421ea61352 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -337,8 +337,7 @@ static unsigned int loop_get_bio(struct lloop_device *lo, struct bio **req) return count; } -static ll_mrf_ret -loop_make_request(struct request_queue *q, struct bio *old_bio) +static void loop_make_request(struct request_queue *q, struct bio *old_bio) { struct lloop_device *lo = q->queuedata; int rw = bio_rw(old_bio); @@ -366,10 +365,9 @@ loop_make_request(struct request_queue *q, struct bio *old_bio) goto err; } loop_add_bio(lo, old_bio); - LL_MRF_RETURN(0); + return; err: cfs_bio_io_error(old_bio, old_bio->bi_size); - LL_MRF_RETURN(0); } diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index d4d3c17547ca..4bf09c4a0c9d 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1063,7 +1063,7 @@ static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v) return 0; } seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", - now.tv_sec, now.tv_usec); + now.tv_sec, (unsigned long)now.tv_usec); seq_printf(seq, "%15s %19s | %20s\n", " ", "read", "write"); seq_printf(seq, "%13s %14s %4s %4s | %14s %4s %4s\n", "extents", "calls", "%", "cum%", @@ -1127,7 +1127,7 @@ static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v) return 0; } seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", - now.tv_sec, now.tv_usec); + now.tv_sec, (unsigned long)now.tv_usec); seq_printf(seq, "%15s %19s | %20s\n", " ", "read", "write"); seq_printf(seq, "%13s %14s %4s %4s | %14s %4s %4s\n", @@ -1293,7 +1293,7 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) spin_lock(&sbi->ll_process_lock); seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", - now.tv_sec, now.tv_usec); + now.tv_sec, (unsigned long)now.tv_usec); seq_printf(seq, "%3s %10s %14s %14s %17s %17s %14s\n", "R/W", "PID", "RANGE START", "RANGE END", "SMALLEST EXTENT", "LARGEST EXTENT", "OFFSET"); diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 34815b550e71..90bbdae824ac 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -83,7 +83,7 @@ int ll_unlock(__u32 mode, struct lustre_handle *lockh) } -/* called from iget5_locked->find_inode() under inode_lock spinlock */ +/* called from iget5_locked->find_inode() under inode_hash_lock spinlock */ static int ll_test_inode(struct inode *inode, void *opaque) { struct ll_inode_info *lli = ll_i2info(inode); diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index ae0dc441d1d9..e9ba38a553cf 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -717,7 +717,7 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, lli = ll_i2info(inode); clob = lli->lli_clob; - memset(ria, 0, sizeof *ria); + memset(ria, 0, sizeof(*ria)); cl_object_attr_lock(clob); ret = cl_object_attr_get(env, clob, attr); diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 96c29ad2fc8c..7e3e0967993b 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -202,11 +202,8 @@ static inline int ll_get_user_pages(int rw, unsigned long user_addr, OBD_ALLOC_LARGE(*pages, *max_pages * sizeof(**pages)); if (*pages) { - down_read(¤t->mm->mmap_sem); - result = get_user_pages(current, current->mm, user_addr, - *max_pages, (rw == READ), 0, *pages, - NULL); - up_read(¤t->mm->mmap_sem); + result = get_user_pages_fast(user_addr, *max_pages, + (rw == READ), *pages); if (unlikely(result <= 0)) OBD_FREE_LARGE(*pages, *max_pages * sizeof(**pages)); } diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 8eaa38e91b99..f6b5f4b95f37 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -647,7 +647,7 @@ static void ll_post_statahead(struct ll_statahead_info *sai) */ LASSERT(fid_is_zero(&minfo->mi_data.op_fid2)); - /* XXX: No fid in reply, this is probaly cross-ref case. + /* XXX: No fid in reply, this is probably cross-ref case. * SA can't handle it yet. */ if (body->valid & OBD_MD_MDS) GOTO(out, rc = -EAGAIN); diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index be125b98b7f0..c4d1580b7be5 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -297,7 +297,7 @@ static loff_t vvp_pgcache_id_pack(struct vvp_pgcache_id *id) ((__u64)id->vpi_bucket << PGC_OBJ_SHIFT); } -static int vvp_pgcache_obj_get(cfs_hash_t *hs, cfs_hash_bd_t *bd, +static int vvp_pgcache_obj_get(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *data) { struct vvp_pgcache_id *id = data; diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h index 33d9ce68fedd..4276124d92e9 100644 --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h @@ -564,50 +564,50 @@ extern struct kmem_cache *lovsub_req_kmem; extern struct kmem_cache *lov_lock_link_kmem; -int lov_object_init (const struct lu_env *env, struct lu_object *obj, +int lov_object_init(const struct lu_env *env, struct lu_object *obj, const struct lu_object_conf *conf); -int lovsub_object_init (const struct lu_env *env, struct lu_object *obj, +int lovsub_object_init(const struct lu_env *env, struct lu_object *obj, const struct lu_object_conf *conf); -int lov_lock_init (const struct lu_env *env, struct cl_object *obj, +int lov_lock_init(const struct lu_env *env, struct cl_object *obj, struct cl_lock *lock, const struct cl_io *io); -int lov_io_init (const struct lu_env *env, struct cl_object *obj, +int lov_io_init(const struct lu_env *env, struct cl_object *obj, struct cl_io *io); -int lovsub_lock_init (const struct lu_env *env, struct cl_object *obj, +int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj, struct cl_lock *lock, const struct cl_io *io); -int lov_lock_init_raid0 (const struct lu_env *env, struct cl_object *obj, +int lov_lock_init_raid0(const struct lu_env *env, struct cl_object *obj, struct cl_lock *lock, const struct cl_io *io); -int lov_lock_init_empty (const struct lu_env *env, struct cl_object *obj, +int lov_lock_init_empty(const struct lu_env *env, struct cl_object *obj, struct cl_lock *lock, const struct cl_io *io); -int lov_io_init_raid0 (const struct lu_env *env, struct cl_object *obj, +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, +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, +void lov_lock_unlink(const struct lu_env *env, struct lov_lock_link *link, struct lovsub_lock *sub); struct lov_io_sub *lov_sub_get(const struct lu_env *env, struct lov_io *lio, int stripe); -void lov_sub_put (struct lov_io_sub *sub); -int lov_sublock_modify (const struct lu_env *env, struct lov_lock *lov, +void lov_sub_put(struct lov_io_sub *sub); +int lov_sublock_modify(const struct lu_env *env, struct lov_lock *lov, struct lovsub_lock *sublock, const struct cl_lock_descr *d, int idx); -int lov_page_init (const struct lu_env *env, struct cl_object *ob, +int lov_page_init(const struct lu_env *env, struct cl_object *ob, struct cl_page *page, struct page *vmpage); -int lovsub_page_init (const struct lu_env *env, struct cl_object *ob, +int lovsub_page_init(const struct lu_env *env, struct cl_object *ob, struct cl_page *page, struct page *vmpage); -int lov_page_init_empty (const struct lu_env *env, +int lov_page_init_empty(const struct lu_env *env, struct cl_object *obj, struct cl_page *page, struct page *vmpage); -int lov_page_init_raid0 (const struct lu_env *env, +int lov_page_init_raid0(const struct lu_env *env, struct cl_object *obj, struct cl_page *page, struct page *vmpage); -struct lu_object *lov_object_alloc (const struct lu_env *env, +struct lu_object *lov_object_alloc(const struct lu_env *env, const struct lu_object_header *hdr, struct lu_device *dev); struct lu_object *lovsub_object_alloc(const struct lu_env *env, @@ -617,7 +617,7 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env, struct lov_lock_link *lov_lock_link_find(const struct lu_env *env, struct lov_lock *lck, struct lovsub_lock *sub); -struct lov_io_sub *lov_page_subio (const struct lu_env *env, +struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio, const struct cl_page_slice *slice); diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index a4006ef46ad2..1f33b04b0c38 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -44,6 +44,8 @@ #include <obd_class.h> #include "lov_cl_internal.h" +#include "lov_internal.h" + struct kmem_cache *lov_lock_kmem; struct kmem_cache *lov_object_kmem; @@ -64,47 +66,47 @@ struct lu_kmem_descr lov_caches[] = { { .ckd_cache = &lov_lock_kmem, .ckd_name = "lov_lock_kmem", - .ckd_size = sizeof (struct lov_lock) + .ckd_size = sizeof(struct lov_lock) }, { .ckd_cache = &lov_object_kmem, .ckd_name = "lov_object_kmem", - .ckd_size = sizeof (struct lov_object) + .ckd_size = sizeof(struct lov_object) }, { .ckd_cache = &lov_thread_kmem, .ckd_name = "lov_thread_kmem", - .ckd_size = sizeof (struct lov_thread_info) + .ckd_size = sizeof(struct lov_thread_info) }, { .ckd_cache = &lov_session_kmem, .ckd_name = "lov_session_kmem", - .ckd_size = sizeof (struct lov_session) + .ckd_size = sizeof(struct lov_session) }, { .ckd_cache = &lov_req_kmem, .ckd_name = "lov_req_kmem", - .ckd_size = sizeof (struct lov_req) + .ckd_size = sizeof(struct lov_req) }, { .ckd_cache = &lovsub_lock_kmem, .ckd_name = "lovsub_lock_kmem", - .ckd_size = sizeof (struct lovsub_lock) + .ckd_size = sizeof(struct lovsub_lock) }, { .ckd_cache = &lovsub_object_kmem, .ckd_name = "lovsub_object_kmem", - .ckd_size = sizeof (struct lovsub_object) + .ckd_size = sizeof(struct lovsub_object) }, { .ckd_cache = &lovsub_req_kmem, .ckd_name = "lovsub_req_kmem", - .ckd_size = sizeof (struct lovsub_req) + .ckd_size = sizeof(struct lovsub_req) }, { .ckd_cache = &lov_lock_link_kmem, .ckd_name = "lov_lock_link_kmem", - .ckd_size = sizeof (struct lov_lock_link) + .ckd_size = sizeof(struct lov_lock_link) }, { .ckd_cache = NULL @@ -286,7 +288,7 @@ static void lov_emerg_free(struct lov_device_emerg **emrg, int nr) OBD_FREE_PTR(em); } } - OBD_FREE(emrg, nr * sizeof emrg[0]); + OBD_FREE(emrg, nr * sizeof(emrg[0])); } static struct lu_device *lov_device_free(const struct lu_env *env, @@ -297,7 +299,7 @@ static struct lu_device *lov_device_free(const struct lu_env *env, cl_device_fini(lu2cl_dev(d)); if (ld->ld_target != NULL) - OBD_FREE(ld->ld_target, nr * sizeof ld->ld_target[0]); + OBD_FREE(ld->ld_target, nr * sizeof(ld->ld_target[0])); if (ld->ld_emrg != NULL) lov_emerg_free(ld->ld_emrg, nr); OBD_FREE_PTR(ld); @@ -321,7 +323,7 @@ static struct lov_device_emerg **lov_emerg_alloc(int nr) int i; int result; - OBD_ALLOC(emerg, nr * sizeof emerg[0]); + OBD_ALLOC(emerg, nr * sizeof(emerg[0])); if (emerg == NULL) return ERR_PTR(-ENOMEM); for (result = i = 0; i < nr && result == 0; i++) { @@ -361,7 +363,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) if (sub_size < tgt_size) { struct lovsub_device **newd; struct lov_device_emerg **emerg; - const size_t sz = sizeof newd[0]; + const size_t sz = sizeof(newd[0]); emerg = lov_emerg_alloc(tgt_size); if (IS_ERR(emerg)) @@ -446,7 +448,7 @@ static int lov_process_config(const struct lu_env *env, cmd = cfg->lcfg_command; rc = lov_process_config_base(d->ld_obd, cfg, &index, &gen); if (rc == 0) { - switch(cmd) { + switch (cmd) { case LCFG_LOV_ADD_OBD: case LCFG_LOV_ADD_INA: rc = lov_cl_add_target(env, d, index); diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index 16770d14ee04..796da8930876 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -89,6 +89,8 @@ struct lov_request_set { extern struct kmem_cache *lov_oinfo_slab; +extern struct lu_kmem_descr lov_caches[]; + void lov_finish_set(struct lov_request_set *set); static inline void lov_get_reqset(struct lov_request_set *set) @@ -124,7 +126,7 @@ static inline void lov_llh_put(struct lov_lock_handles *llh) if (atomic_read(&llh->llh_refcount)) return; - OBD_FREE_RCU(llh, sizeof *llh + + OBD_FREE_RCU(llh, sizeof(*llh) + sizeof(*llh->llh_handles) * llh->llh_stripe_count, &llh->llh_handle); } diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index b611aa4e9dcb..2792fa5c4be2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -86,7 +86,7 @@ static void lov_io_sub_inherit(struct cl_io *io, struct lov_io *lio, struct lov_stripe_md *lsm = lio->lis_object->lo_lsm; struct cl_io *parent = lio->lis_cl.cis_io; - switch(io->ci_type) { + switch (io->ci_type) { case CIT_SETATTR: { io->u.ci_setattr.sa_attr = parent->u.ci_setattr.sa_attr; io->u.ci_setattr.sa_valid = parent->u.ci_setattr.sa_valid; @@ -282,7 +282,7 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, * when writing a page. -jay */ OBD_ALLOC_LARGE(lio->lis_subs, - lsm->lsm_stripe_count * sizeof lio->lis_subs[0]); + lsm->lsm_stripe_count * sizeof(lio->lis_subs[0])); if (lio->lis_subs != NULL) { lio->lis_nr_subios = lio->lis_stripe_count; lio->lis_single_subio_index = -1; @@ -356,7 +356,7 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) for (i = 0; i < lio->lis_nr_subios; i++) lov_io_sub_fini(env, lio, &lio->lis_subs[i]); OBD_FREE_LARGE(lio->lis_subs, - lio->lis_nr_subios * sizeof lio->lis_subs[0]); + lio->lis_nr_subios * sizeof(lio->lis_subs[0])); lio->lis_nr_subios = 0; } diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index ec297e87c2a2..26bc719b6dc8 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -88,7 +88,7 @@ static struct lov_sublock_env *lov_sublock_env_get(const struct lu_env *env, subenv->lse_io = sub->sub_io; subenv->lse_sub = sub; } else { - subenv = (void*)sub; + subenv = (void *)sub; } } return subenv; @@ -167,7 +167,7 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env, lov_sublock_env_put(subenv); } else { /* error occurs. */ - sublock = (void*)subenv; + sublock = (void *)subenv; } if (!IS_ERR(sublock)) @@ -313,7 +313,7 @@ static int lov_lock_sub_init(const struct lu_env *env, nr++; } LASSERT(nr > 0); - OBD_ALLOC_LARGE(lck->lls_sub, nr * sizeof lck->lls_sub[0]); + OBD_ALLOC_LARGE(lck->lls_sub, nr * sizeof(lck->lls_sub[0])); if (lck->lls_sub == NULL) return -ENOMEM; @@ -474,7 +474,7 @@ static void lov_lock_fini(const struct lu_env *env, */ LASSERT(lck->lls_sub[i].sub_lock == NULL); OBD_FREE_LARGE(lck->lls_sub, - lck->lls_nr * sizeof lck->lls_sub[0]); + lck->lls_nr * sizeof(lck->lls_sub[0])); } OBD_SLAB_FREE_PTR(lck, lov_lock_kmem); } @@ -742,7 +742,7 @@ static void lov_lock_cancel(const struct lu_env *env, continue; } - switch(sublock->cll_state) { + switch (sublock->cll_state) { case CLS_HELD: rc = cl_unuse_try(subenv->lse_env, sublock); lov_sublock_release(env, lck, i, 0, 0); diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 0b47aba1332a..4783450774cd 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -554,7 +554,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, struct lov_tgt_desc **newtgts, **old = NULL; __u32 newsize, oldsize = 0; - newsize = max(lov->lov_tgt_size, (__u32)2); + newsize = max_t(__u32, lov->lov_tgt_size, 2); while (newsize < index + 1) newsize = newsize << 1; OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize); @@ -923,7 +923,7 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, int cmd; int rc = 0; - switch(cmd = lcfg->lcfg_command) { + switch (cmd = lcfg->lcfg_command) { case LCFG_LOV_ADD_OBD: case LCFG_LOV_ADD_INA: case LCFG_LOV_DEL_OBD: { @@ -1090,7 +1090,7 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp, if (rc) GOTO(out, rc); - list_for_each (pos, &set->set_list) { + list_for_each(pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); if (oa->o_valid & OBD_MD_FLCOOKIE) @@ -1141,7 +1141,7 @@ static int lov_getattr(const struct lu_env *env, struct obd_export *exp, if (rc) return rc; - list_for_each (pos, &set->set_list) { + list_for_each(pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); CDEBUG(D_INFO, "objid "DOSTID"[%d] has subobj "DOSTID" at idx" @@ -1227,7 +1227,7 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, if (!list_empty(&rqset->set_requests)) { LASSERT(rc == 0); - LASSERT (rqset->set_interpret == NULL); + LASSERT(rqset->set_interpret == NULL); rqset->set_interpret = lov_getattr_interpret; rqset->set_arg = (void *)lovset; return rc; @@ -1267,7 +1267,7 @@ static int lov_setattr(const struct lu_env *env, struct obd_export *exp, if (rc) return rc; - list_for_each (pos, &set->set_list) { + list_for_each(pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); rc = obd_setattr(env, lov->lov_tgts[req->rq_idx]->ltd_exp, @@ -1408,7 +1408,7 @@ static int lov_punch(const struct lu_env *env, struct obd_export *exp, if (rc) return rc; - list_for_each (pos, &set->set_list) { + list_for_each(pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); rc = obd_punch(env, lov->lov_tgts[req->rq_idx]->ltd_exp, @@ -1472,7 +1472,7 @@ static int lov_sync(const struct lu_env *env, struct obd_export *exp, CDEBUG(D_INFO, "fsync objid "DOSTID" ["LPX64", "LPX64"]\n", POSTID(&set->set_oi->oi_oa->o_oi), start, end); - list_for_each (pos, &set->set_list) { + list_for_each(pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); rc = obd_sync(env, lov->lov_tgts[req->rq_idx]->ltd_exp, @@ -1557,7 +1557,7 @@ static int lov_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, if (rc) return rc; - list_for_each (pos, &set->set_list) { + list_for_each(pos, &set->set_list) { struct obd_export *sub_exp; struct brw_page *sub_pga; req = list_entry(pos, struct lov_request, rq_link); @@ -1612,7 +1612,7 @@ static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo, if (rc) return rc; - list_for_each (pos, &set->set_list) { + list_for_each(pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); rc = obd_enqueue(lov->lov_tgts[req->rq_idx]->ltd_exp, @@ -1828,7 +1828,7 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, if (rc) return rc; - list_for_each (pos, &set->set_list) { + list_for_each(pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); rc = obd_statfs_async(lov->lov_tgts[req->rq_idx]->ltd_exp, &req->rq_oi, max_age, rqset); @@ -1909,7 +1909,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, (int) sizeof(struct obd_uuid)))) return -EFAULT; - flags = uarg ? *(__u32*)uarg : 0; + flags = uarg ? *(__u32 *)uarg : 0; /* got statfs data */ rc = obd_statfs(NULL, lov->lov_tgts[index]->ltd_exp, &stat_buf, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), @@ -2495,7 +2495,7 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp, GOTO(out, rc); } else if (KEY_IS(KEY_CONNECT_FLAG)) { struct lov_tgt_desc *tgt; - __u64 ost_idx = *((__u64*)val); + __u64 ost_idx = *((__u64 *)val); LASSERT(*vallen == sizeof(__u64)); LASSERT(ost_idx < lov->desc.ld_tgt_count); @@ -2564,7 +2564,7 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, for (i = 0; i < count; i++, val = (char *)val + incr) { if (next_id) { - tgt = lov->lov_tgts[((struct obd_id_info*)val)->idx]; + tgt = lov->lov_tgts[((struct obd_id_info *)val)->idx]; } else { tgt = lov->lov_tgts[i]; } @@ -2593,9 +2593,9 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, } else if (next_id) { err = obd_set_info_async(env, tgt->ltd_exp, keylen, key, vallen, - ((struct obd_id_info*)val)->data, set); + ((struct obd_id_info *)val)->data, set); } else if (capa) { - struct mds_capa_info *info = (struct mds_capa_info*)val; + struct mds_capa_info *info = (struct mds_capa_info *)val; LASSERT(vallen == sizeof(*info)); @@ -2781,7 +2781,7 @@ struct obd_ops lov_obd_ops = { .o_setup = lov_setup, .o_precleanup = lov_precleanup, .o_cleanup = lov_cleanup, - //.o_process_config = lov_process_config, + /*.o_process_config = lov_process_config,*/ .o_connect = lov_connect, .o_disconnect = lov_disconnect, .o_statfs = lov_statfs, @@ -2823,8 +2823,6 @@ struct obd_ops lov_obd_ops = { struct kmem_cache *lov_oinfo_slab; -extern struct lu_kmem_descr lov_caches[]; - int __init lov_init(void) { struct lprocfs_static_vars lvars = { 0 }; diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 84e55ce3ccd2..cf2fa8abfb1d 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -214,7 +214,7 @@ static int lov_init_raid0(const struct lu_env *env, r0->lo_nr = lsm->lsm_stripe_count; LASSERT(r0->lo_nr <= lov_targets_nr(dev)); - OBD_ALLOC_LARGE(r0->lo_sub, r0->lo_nr * sizeof r0->lo_sub[0]); + OBD_ALLOC_LARGE(r0->lo_sub, r0->lo_nr * sizeof(r0->lo_sub[0])); if (r0->lo_sub != NULL) { result = 0; subconf->coc_inode = conf->coc_inode; @@ -368,7 +368,7 @@ static void lov_fini_raid0(const struct lu_env *env, struct lov_object *lov, struct lov_layout_raid0 *r0 = &state->raid0; if (r0->lo_sub != NULL) { - OBD_FREE_LARGE(r0->lo_sub, r0->lo_nr * sizeof r0->lo_sub[0]); + OBD_FREE_LARGE(r0->lo_sub, r0->lo_nr * sizeof(r0->lo_sub[0])); r0->lo_sub = NULL; } diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 55ec26778f80..ec6f6e0572ae 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -121,7 +121,7 @@ void lov_dump_lmm(int level, void *lmm) do { \ if (!(test)) lov_dump_lmm(D_ERROR, lmm); \ LASSERT(test); /* so we know what assertion failed */ \ -} while(0) +} while (0) /* Pack LOV object metadata for disk storage. It is packed in LE byte * order and is opaque to the networking layer. @@ -630,22 +630,22 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm, /* FIXME: Bug 1185 - copy fields properly when structs change */ /* struct lov_user_md_v3 and struct lov_mds_md_v3 must be the same */ CLASSERT(sizeof(lum) == sizeof(struct lov_mds_md_v3)); - CLASSERT(sizeof lum.lmm_objects[0] == sizeof lmmk->lmm_objects[0]); + CLASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lmmk->lmm_objects[0])); if ((cpu_to_le32(LOV_MAGIC) != LOV_MAGIC) && ((lmmk->lmm_magic == cpu_to_le32(LOV_MAGIC_V1)) || (lmmk->lmm_magic == cpu_to_le32(LOV_MAGIC_V3)))) { lustre_swab_lov_mds_md(lmmk); lustre_swab_lov_user_md_objects( - (struct lov_user_ost_data*)lmmk->lmm_objects, + (struct lov_user_ost_data *)lmmk->lmm_objects, lmmk->lmm_stripe_count); } if (lum.lmm_magic == LOV_USER_MAGIC) { /* User request for v1, we need skip lmm_pool_name */ if (lmmk->lmm_magic == LOV_MAGIC_V3) { - memmove((char*)(&lmmk->lmm_stripe_count) + + memmove((char *)(&lmmk->lmm_stripe_count) + sizeof(lmmk->lmm_stripe_count), - ((struct lov_mds_md_v3*)lmmk)->lmm_objects, + ((struct lov_mds_md_v3 *)lmmk)->lmm_objects, lmmk->lmm_stripe_count * sizeof(struct lov_ost_data_v1)); lmm_size -= LOV_MAXPOOLNAME; diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index dd3c07d5c4de..a1701dfe4083 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -86,7 +86,7 @@ void lov_pool_putref_locked(struct pool_desc *pool) * Chapter 6.4. * Addison Wesley, 1973 */ -static __u32 pool_hashfn(cfs_hash_t *hash_body, const void *key, unsigned mask) +static __u32 pool_hashfn(struct cfs_hash *hash_body, const void *key, unsigned mask) { int i; __u32 result; @@ -125,7 +125,7 @@ static void *pool_hashobject(struct hlist_node *hnode) return hlist_entry(hnode, struct pool_desc, pool_hash); } -static void pool_hashrefcount_get(cfs_hash_t *hs, struct hlist_node *hnode) +static void pool_hashrefcount_get(struct cfs_hash *hs, struct hlist_node *hnode) { struct pool_desc *pool; @@ -133,7 +133,7 @@ static void pool_hashrefcount_get(cfs_hash_t *hs, struct hlist_node *hnode) lov_pool_getref(pool); } -static void pool_hashrefcount_put_locked(cfs_hash_t *hs, +static void pool_hashrefcount_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) { struct pool_desc *pool; diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 61e6d0b46c98..bf324ae2946f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -245,7 +245,7 @@ int lov_update_enqueue_set(struct lov_request *req, __u32 mode, int rc) osc_update_enqueue(lov_lockhp, loi, oi->oi_flags, &req->rq_oi.oi_md->lsm_oinfo[0]->loi_lvb, mode, rc); if (rc == ELDLM_LOCK_ABORTED && (oi->oi_flags & LDLM_FL_HAS_INTENT)) - memset(lov_lockhp, 0, sizeof *lov_lockhp); + memset(lov_lockhp, 0, sizeof(*lov_lockhp)); rc = lov_update_enqueue_lov(set->set_exp, lov_lockhp, loi, oi->oi_flags, req->rq_idx, &oi->oi_md->lsm_oi, rc); lov_stripe_unlock(oi->oi_md); @@ -343,7 +343,7 @@ static struct lov_lock_handles *lov_llh_new(struct lov_stripe_md *lsm) { struct lov_lock_handles *llh; - OBD_ALLOC(llh, sizeof *llh + + OBD_ALLOC(llh, sizeof(*llh) + sizeof(*llh->llh_handles) * lsm->lsm_stripe_count); if (llh == NULL) return NULL; @@ -630,7 +630,7 @@ static int common_attr_done(struct lov_request_set *set) if (tmp_oa == NULL) GOTO(out, rc = -ENOMEM); - list_for_each (pos, &set->set_list) { + list_for_each(pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); if (!req->rq_complete || req->rq_rc) @@ -669,7 +669,7 @@ static int brw_done(struct lov_request_set *set) struct list_head *pos; struct lov_request *req; - list_for_each (pos, &set->set_list) { + list_for_each(pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); if (!req->rq_complete || req->rq_rc) @@ -1315,7 +1315,7 @@ out_set: (tot) = LOV_U64_MAX; \ else \ (tot) += (add); \ - } while(0) + } while (0) int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,int success) { diff --git a/drivers/staging/lustre/lustre/lvfs/fsfilt.c b/drivers/staging/lustre/lustre/lvfs/fsfilt.c index e86df7356cb1..0d6ed69ddb22 100644 --- a/drivers/staging/lustre/lustre/lvfs/fsfilt.c +++ b/drivers/staging/lustre/lustre/lvfs/fsfilt.c @@ -50,9 +50,8 @@ static struct fsfilt_operations *fsfilt_search_type(const char *type) list_for_each(p, &fsfilt_types) { found = list_entry(p, struct fsfilt_operations, fs_list); - if (!strcmp(found->fs_type, type)) { + if (!strcmp(found->fs_type, type)) return found; - } } return NULL; } @@ -62,7 +61,8 @@ int fsfilt_register_ops(struct fsfilt_operations *fs_ops) struct fsfilt_operations *found; /* lock fsfilt_types list */ - if ((found = fsfilt_search_type(fs_ops->fs_type))) { + found = fsfilt_search_type(fs_ops->fs_type); + if (found) { if (found != fs_ops) { CERROR("different operations for type %s\n", fs_ops->fs_type); @@ -103,14 +103,16 @@ struct fsfilt_operations *fsfilt_get_ops(const char *type) struct fsfilt_operations *fs_ops; /* lock fsfilt_types list */ - if (!(fs_ops = fsfilt_search_type(type))) { + fs_ops = fsfilt_search_type(type); + if (!fs_ops) { char name[32]; int rc; snprintf(name, sizeof(name) - 1, "fsfilt_%s", type); name[sizeof(name) - 1] = '\0'; - if (!(rc = request_module("%s", name))) { + rc = request_module("%s", name); + if (!rc) { fs_ops = fsfilt_search_type(type); CDEBUG(D_INFO, "Loaded module '%s'\n", name); if (!fs_ops) diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_lib.c b/drivers/staging/lustre/lustre/lvfs/lvfs_lib.c index 97a8be2300dd..b21e40cdacab 100644 --- a/drivers/staging/lustre/lustre/lvfs/lvfs_lib.c +++ b/drivers/staging/lustre/lustre/lvfs/lvfs_lib.c @@ -154,11 +154,10 @@ int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid) spin_lock(&stats->ls_lock); if (stats->ls_biggest_alloc_num <= cpuid) stats->ls_biggest_alloc_num = cpuid + 1; - if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) { + if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) spin_unlock_irqrestore(&stats->ls_lock, flags); - } else { + else spin_unlock(&stats->ls_lock); - } } /* initialize the ls_percpu[cpuid] non-zero counter */ for (i = 0; i < stats->ls_num; ++i) { diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c index 18e1b47a1d65..09474e7553dd 100644 --- a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c +++ b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c @@ -65,9 +65,9 @@ EXPORT_SYMBOL(obd_memory); msg) # define ASSERT_KERNEL_CTXT(msg) LASSERTF(segment_eq(get_fs(), get_ds()), msg) #else -# define ASSERT_CTXT_MAGIC(magic) do {} while(0) -# define ASSERT_NOT_KERNEL_CTXT(msg) do {} while(0) -# define ASSERT_KERNEL_CTXT(msg) do {} while(0) +# define ASSERT_CTXT_MAGIC(magic) do {} while (0) +# define ASSERT_NOT_KERNEL_CTXT(msg) do {} while (0) +# define ASSERT_KERNEL_CTXT(msg) do {} while (0) #endif static void push_group_info(struct lvfs_run_ctxt *save, @@ -80,7 +80,8 @@ static void push_group_info(struct lvfs_run_ctxt *save, struct cred *cred; task_lock(current); save->group_info = current_cred()->group_info; - if ((cred = prepare_creds())) { + cred = prepare_creds(); + if (cred) { cred->group_info = ginfo; commit_creds(cred); } @@ -96,7 +97,8 @@ static void pop_group_info(struct lvfs_run_ctxt *save, } else { struct cred *cred; task_lock(current); - if ((cred = prepare_creds())) { + cred = prepare_creds(); + if (cred) { cred->group_info = save->group_info; commit_creds(cred); } @@ -112,7 +114,7 @@ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx, if (new_ctx->dt != NULL) return; - //ASSERT_NOT_KERNEL_CTXT("already in kernel context!\n"); + /* ASSERT_NOT_KERNEL_CTXT("already in kernel context!\n"); */ ASSERT_CTXT_MAGIC(new_ctx->magic); OBD_SET_CTXT_MAGIC(save); @@ -137,7 +139,8 @@ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx, save->luc.luc_fsgid = current_fsgid(); save->luc.luc_cap = current_cap(); - if ((cred = prepare_creds())) { + cred = prepare_creds(); + if (cred) { cred->uid = uc->luc_uid; cred->gid = uc->luc_gid; cred->fsuid = uc->luc_fsuid; @@ -180,7 +183,8 @@ void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx, current->fs->umask = saved->luc.luc_umask; if (uc) { struct cred *cred; - if ((cred = prepare_creds())) { + cred = prepare_creds(); + if (cred) { cred->uid = saved->luc.luc_uid; cred->gid = saved->luc.luc_gid; cred->fsuid = saved->luc.luc_fsuid; @@ -220,7 +224,7 @@ int lustre_rename(struct dentry *dir, struct vfsmount *mnt, GOTO(put_old, err = PTR_ERR(dchild_new)); err = ll_vfs_rename(dir->d_inode, dchild_old, mnt, - dir->d_inode, dchild_new, mnt); + dir->d_inode, dchild_new, mnt, NULL); dput(dchild_new); put_old: @@ -253,32 +257,32 @@ __s64 lprocfs_read_helper(struct lprocfs_counter *lc, return 0; switch (field) { - case LPROCFS_FIELDS_FLAGS_CONFIG: - ret = header->lc_config; - break; - case LPROCFS_FIELDS_FLAGS_SUM: - ret = lc->lc_sum; - if ((flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0) - ret += lc->lc_sum_irq; - break; - case LPROCFS_FIELDS_FLAGS_MIN: - ret = lc->lc_min; - break; - case LPROCFS_FIELDS_FLAGS_MAX: - ret = lc->lc_max; - break; - case LPROCFS_FIELDS_FLAGS_AVG: - ret = (lc->lc_max - lc->lc_min) / 2; - break; - case LPROCFS_FIELDS_FLAGS_SUMSQUARE: - ret = lc->lc_sumsquare; - break; - case LPROCFS_FIELDS_FLAGS_COUNT: - ret = lc->lc_count; - break; - default: - break; - }; + case LPROCFS_FIELDS_FLAGS_CONFIG: + ret = header->lc_config; + break; + case LPROCFS_FIELDS_FLAGS_SUM: + ret = lc->lc_sum; + if ((flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0) + ret += lc->lc_sum_irq; + break; + case LPROCFS_FIELDS_FLAGS_MIN: + ret = lc->lc_min; + break; + case LPROCFS_FIELDS_FLAGS_MAX: + ret = lc->lc_max; + break; + case LPROCFS_FIELDS_FLAGS_AVG: + ret = (lc->lc_max - lc->lc_min) / 2; + break; + case LPROCFS_FIELDS_FLAGS_SUMSQUARE: + ret = lc->lc_sumsquare; + break; + case LPROCFS_FIELDS_FLAGS_COUNT: + ret = lc->lc_count; + break; + default: + break; + } return ret; } diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 426979341554..e048500edd60 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -1387,7 +1387,7 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req) cl_object_put(env, obj); } } - OBD_FREE(req->crq_o, req->crq_nrobjs * sizeof req->crq_o[0]); + OBD_FREE(req->crq_o, req->crq_nrobjs * sizeof(req->crq_o[0])); } OBD_FREE_PTR(req); } @@ -1452,7 +1452,7 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, if (req != NULL) { int result; - OBD_ALLOC(req->crq_o, nr_objects * sizeof req->crq_o[0]); + OBD_ALLOC(req->crq_o, nr_objects * sizeof(req->crq_o[0])); if (req->crq_o != NULL) { req->crq_nrobjs = nr_objects; req->crq_type = crt; @@ -1642,7 +1642,7 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_io *io, cpu_relax(); } - POISON(anchor, 0x5a, sizeof *anchor); + POISON(anchor, 0x5a, sizeof(*anchor)); return rc; } EXPORT_SYMBOL(cl_sync_io_wait); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index 7b0e9d26b6c1..1a926036724b 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -577,9 +577,9 @@ static void cl_env_init0(struct cl_env *cle, void *debug) * The implementation of using hash table to connect cl_env and thread */ -static cfs_hash_t *cl_env_hash; +static struct cfs_hash *cl_env_hash; -static unsigned cl_env_hops_hash(cfs_hash_t *lh, +static unsigned cl_env_hops_hash(struct cfs_hash *lh, const void *key, unsigned mask) { #if BITS_PER_LONG == 64 @@ -604,7 +604,7 @@ static int cl_env_hops_keycmp(const void *key, struct hlist_node *hn) return (key == cle->ce_owner); } -static void cl_env_hops_noop(cfs_hash_t *hs, struct hlist_node *hn) +static void cl_env_hops_noop(struct cfs_hash *hs, struct hlist_node *hn) { struct cl_env *cle = hlist_entry(hn, struct cl_env, ce_node); LASSERT(cle->ce_magic == &cl_env_init0); diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index b1024a6d37dd..4afd962cdb64 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -178,7 +178,7 @@ EXPORT_SYMBOL(obd_alloc_fail); static inline void obd_data2conn(struct lustre_handle *conn, struct obd_ioctl_data *data) { - memset(conn, 0, sizeof *conn); + memset(conn, 0, sizeof(*conn)); conn->cookie = data->ioc_cookie; } diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 68fe71c8a2a9..f6fae16fc7f7 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -816,7 +816,7 @@ struct obd_export *class_new_export(struct obd_device *obd, struct obd_uuid *cluuid) { struct obd_export *export; - cfs_hash_t *hash = NULL; + struct cfs_hash *hash = NULL; int rc = 0; OBD_ALLOC_PTR(export); @@ -1384,7 +1384,7 @@ EXPORT_SYMBOL(obd_export_nid2str); int obd_export_evict_by_nid(struct obd_device *obd, const char *nid) { - cfs_hash_t *nid_hash; + struct cfs_hash *nid_hash; struct obd_export *doomed_exp = NULL; int exports_evicted = 0; @@ -1432,7 +1432,7 @@ EXPORT_SYMBOL(obd_export_evict_by_nid); int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid) { - cfs_hash_t *uuid_hash; + struct cfs_hash *uuid_hash; struct obd_export *doomed_exp = NULL; struct obd_uuid doomed_uuid; int exports_evicted = 0; diff --git a/drivers/staging/lustre/lustre/obdclass/llog_test.c b/drivers/staging/lustre/lustre/obdclass/llog_test.c index d9e6d12215f9..178f89eccab1 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_test.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_test.c @@ -242,7 +242,7 @@ static int llog_test_3(const struct lu_env *env, struct obd_device *obd, hdr.lrh_len = 8; hdr.lrh_type = OBD_CFG_REC; - memset(buf, 0, sizeof buf); + memset(buf, 0, sizeof(buf)); rc = llog_write(env, llh, &hdr, NULL, 0, buf, -1); if (rc < 0) { CERROR("3b: write 10 records failed at #%d: %d\n", @@ -277,8 +277,8 @@ static int llog_test_3(const struct lu_env *env, struct obd_device *obd, char buf_even[24]; char buf_odd[32]; - memset(buf_odd, 0, sizeof buf_odd); - memset(buf_even, 0, sizeof buf_even); + memset(buf_odd, 0, sizeof(buf_odd)); + memset(buf_even, 0, sizeof(buf_even)); if ((i % 2) == 0) { hdr.lrh_len = 24; hdr.lrh_type = OBD_CFG_REC; diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index a95f60a4f90e..02d76f8dbcb9 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -898,7 +898,7 @@ static void lprocfs_free_client_stats(struct nid_stat *client_stat) void lprocfs_free_per_client_stats(struct obd_device *obd) { - cfs_hash_t *hash = obd->obd_nid_stats_hash; + struct cfs_hash *hash = obd->obd_nid_stats_hash; struct nid_stat *stat; /* we need extra list - because hash_exit called to early */ @@ -1069,7 +1069,7 @@ static int lprocfs_stats_seq_show(struct seq_file *p, void *v) struct timeval now; do_gettimeofday(&now); rc = seq_printf(p, "%-25s %lu.%lu secs.usecs\n", - "snapshot_time", now.tv_sec, now.tv_usec); + "snapshot_time", now.tv_sec, (unsigned long)now.tv_usec); if (rc < 0) return rc; } @@ -1422,7 +1422,7 @@ void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) } EXPORT_SYMBOL(lprocfs_init_ldlm_stats); -int lprocfs_exp_print_uuid(cfs_hash_t *hs, cfs_hash_bd_t *bd, +int lprocfs_exp_print_uuid(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *data) { @@ -1453,7 +1453,7 @@ struct exp_hash_cb_data { bool first; }; -int lprocfs_exp_print_hash(cfs_hash_t *hs, cfs_hash_bd_t *bd, +int lprocfs_exp_print_hash(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *cb_data) { diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index c29ac1c2defd..212823ab937b 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -71,7 +71,7 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o) struct lu_object_header *top; struct lu_site *site; struct lu_object *orig; - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; const struct lu_fid *fid; top = o->lo_header; @@ -175,8 +175,8 @@ void lu_object_unhash(const struct lu_env *env, struct lu_object *o) top = o->lo_header; set_bit(LU_OBJECT_HEARD_BANSHEE, &top->loh_flags); if (!test_and_set_bit(LU_OBJECT_UNHASHED, &top->loh_flags)) { - cfs_hash_t *obj_hash = o->lo_dev->ld_site->ls_obj_hash; - cfs_hash_bd_t bd; + struct cfs_hash *obj_hash = o->lo_dev->ld_site->ls_obj_hash; + struct cfs_hash_bd bd; cfs_hash_bd_get_and_lock(obj_hash, &top->loh_fid, &bd, 1); list_del_init(&top->loh_lru); @@ -306,8 +306,8 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr) struct lu_object_header *h; struct lu_object_header *temp; struct lu_site_bkt_data *bkt; - cfs_hash_bd_t bd; - cfs_hash_bd_t bd2; + struct cfs_hash_bd bd; + struct cfs_hash_bd bd2; struct list_head dispose; int did_sth; int start; @@ -526,7 +526,7 @@ int lu_object_invariant(const struct lu_object *o) EXPORT_SYMBOL(lu_object_invariant); static struct lu_object *htable_lookup(struct lu_site *s, - cfs_hash_bd_t *bd, + struct cfs_hash_bd *bd, const struct lu_fid *f, wait_queue_t *waiter, __u64 *version) @@ -589,8 +589,8 @@ static struct lu_object *lu_object_new(const struct lu_env *env, const struct lu_object_conf *conf) { struct lu_object *o; - cfs_hash_t *hs; - cfs_hash_bd_t bd; + struct cfs_hash *hs; + struct cfs_hash_bd bd; struct lu_site_bkt_data *bkt; o = lu_object_alloc(env, dev, f, conf); @@ -618,8 +618,8 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env, struct lu_object *o; struct lu_object *shadow; struct lu_site *s; - cfs_hash_t *hs; - cfs_hash_bd_t bd; + struct cfs_hash *hs; + struct cfs_hash_bd bd; __u64 version = 0; /* @@ -788,7 +788,7 @@ struct lu_site_print_arg { }; static int -lu_site_obj_print(cfs_hash_t *hs, cfs_hash_bd_t *bd, +lu_site_obj_print(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *data) { struct lu_site_print_arg *arg = (struct lu_site_print_arg *)data; @@ -874,7 +874,7 @@ static int lu_htable_order(void) return bits; } -static unsigned lu_obj_hop_hash(cfs_hash_t *hs, +static unsigned lu_obj_hop_hash(struct cfs_hash *hs, const void *key, unsigned mask) { struct lu_fid *fid = (struct lu_fid *)key; @@ -914,14 +914,14 @@ static int lu_obj_hop_keycmp(const void *key, struct hlist_node *hnode) return lu_fid_eq(&h->loh_fid, (struct lu_fid *)key); } -static void lu_obj_hop_get(cfs_hash_t *hs, struct hlist_node *hnode) +static void lu_obj_hop_get(struct cfs_hash *hs, struct hlist_node *hnode) { struct lu_object_header *h; h = hlist_entry(hnode, struct lu_object_header, loh_hash); if (atomic_add_return(1, &h->loh_ref) == 1) { struct lu_site_bkt_data *bkt; - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; cfs_hash_bd_get(hs, &h->loh_fid, &bd); bkt = cfs_hash_bd_extra_get(hs, &bd); @@ -929,7 +929,7 @@ static void lu_obj_hop_get(cfs_hash_t *hs, struct hlist_node *hnode) } } -static void lu_obj_hop_put_locked(cfs_hash_t *hs, struct hlist_node *hnode) +static void lu_obj_hop_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) { LBUG(); /* we should never called it */ } @@ -975,12 +975,12 @@ EXPORT_SYMBOL(lu_dev_del_linkage); int lu_site_init(struct lu_site *s, struct lu_device *top) { struct lu_site_bkt_data *bkt; - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; char name[16]; int bits; int i; - memset(s, 0, sizeof *s); + memset(s, 0, sizeof(*s)); bits = lu_htable_order(); snprintf(name, 16, "lu_site_%s", top->ld_type->ldt_name); for (bits = min(max(LU_SITE_BITS_MIN, bits), LU_SITE_BITS_MAX); @@ -1110,7 +1110,7 @@ int lu_device_init(struct lu_device *d, struct lu_device_type *t) { if (t->ldt_device_nr++ == 0 && t->ldt_ops->ldto_start != NULL) t->ldt_ops->ldto_start(t); - memset(d, 0, sizeof *d); + memset(d, 0, sizeof(*d)); atomic_set(&d->ld_ref, 0); d->ld_type = t; lu_ref_init(&d->ld_reference); @@ -1206,7 +1206,7 @@ EXPORT_SYMBOL(lu_object_add); */ int lu_object_header_init(struct lu_object_header *h) { - memset(h, 0, sizeof *h); + memset(h, 0, sizeof(*h)); atomic_set(&h->loh_ref, 1); INIT_HLIST_NODE(&h->loh_hash); INIT_LIST_HEAD(&h->loh_lru); @@ -1525,7 +1525,7 @@ static void keys_fini(struct lu_context *ctx) for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) key_fini(ctx, i); - OBD_FREE(ctx->lc_value, ARRAY_SIZE(lu_keys) * sizeof ctx->lc_value[0]); + OBD_FREE(ctx->lc_value, ARRAY_SIZE(lu_keys) * sizeof(ctx->lc_value[0])); ctx->lc_value = NULL; } @@ -1574,7 +1574,8 @@ static int keys_fill(struct lu_context *ctx) static int keys_init(struct lu_context *ctx) { - OBD_ALLOC(ctx->lc_value, ARRAY_SIZE(lu_keys) * sizeof ctx->lc_value[0]); + OBD_ALLOC(ctx->lc_value, + ARRAY_SIZE(lu_keys) * sizeof(ctx->lc_value[0])); if (likely(ctx->lc_value != NULL)) return keys_fill(ctx); @@ -1588,7 +1589,7 @@ int lu_context_init(struct lu_context *ctx, __u32 tags) { int rc; - memset(ctx, 0, sizeof *ctx); + memset(ctx, 0, sizeof(*ctx)); ctx->lc_state = LCS_INITIALIZED; ctx->lc_tags = tags; if (tags & LCT_REMEMBER) { @@ -1779,7 +1780,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; @@ -1788,10 +1788,10 @@ typedef struct lu_site_stats{ unsigned lss_busy; } lu_site_stats_t; -static void lu_site_stats_get(cfs_hash_t *hs, +static void lu_site_stats_get(struct cfs_hash *hs, lu_site_stats_t *stats, int populated) { - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; int i; cfs_hash_for_each_bucket(hs, &bd, i) { @@ -1835,61 +1835,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. */ @@ -1913,6 +1920,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. */ @@ -1947,9 +1960,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; } @@ -1959,11 +1970,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); /* @@ -2065,8 +2072,8 @@ void lu_object_assign_fid(const struct lu_env *env, struct lu_object *o, struct lu_site_bkt_data *bkt; struct lu_object *shadow; wait_queue_t waiter; - cfs_hash_t *hs; - cfs_hash_bd_t bd; + struct cfs_hash *hs; + struct cfs_hash_bd bd; __u64 version = 0; LASSERT(fid_is_zero(old)); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index d0a64ff53581..362ae541b209 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -417,7 +417,7 @@ int class_attach(struct lustre_cfg *lcfg) /* do the attach */ if (OBP(obd, attach)) { - rc = OBP(obd,attach)(obd, sizeof *lcfg, lcfg); + rc = OBP(obd, attach)(obd, sizeof(*lcfg), lcfg); if (rc) GOTO(out, rc = -EINVAL); } @@ -900,7 +900,7 @@ void class_del_profile(const char *prof) OBD_FREE(lprof->lp_dt, strlen(lprof->lp_dt) + 1); if (lprof->lp_md) OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1); - OBD_FREE(lprof, sizeof *lprof); + OBD_FREE(lprof, sizeof(*lprof)); } } EXPORT_SYMBOL(class_del_profile); @@ -916,7 +916,7 @@ void class_del_profiles(void) OBD_FREE(lprof->lp_dt, strlen(lprof->lp_dt) + 1); if (lprof->lp_md) OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1); - OBD_FREE(lprof, sizeof *lprof); + OBD_FREE(lprof, sizeof(*lprof)); } } EXPORT_SYMBOL(class_del_profiles); @@ -1692,7 +1692,7 @@ EXPORT_SYMBOL(class_manual_cleanup); */ static unsigned -uuid_hash(cfs_hash_t *hs, const void *key, unsigned mask) +uuid_hash(struct cfs_hash *hs, const void *key, unsigned mask) { return cfs_hash_djb2_hash(((struct obd_uuid *)key)->uuid, sizeof(((struct obd_uuid *)key)->uuid), mask); @@ -1731,7 +1731,7 @@ uuid_export_object(struct hlist_node *hnode) } static void -uuid_export_get(cfs_hash_t *hs, struct hlist_node *hnode) +uuid_export_get(struct cfs_hash *hs, struct hlist_node *hnode) { struct obd_export *exp; @@ -1740,7 +1740,7 @@ uuid_export_get(cfs_hash_t *hs, struct hlist_node *hnode) } static void -uuid_export_put_locked(cfs_hash_t *hs, struct hlist_node *hnode) +uuid_export_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) { struct obd_export *exp; @@ -1763,7 +1763,7 @@ static cfs_hash_ops_t uuid_hash_ops = { */ static unsigned -nid_hash(cfs_hash_t *hs, const void *key, unsigned mask) +nid_hash(struct cfs_hash *hs, const void *key, unsigned mask) { return cfs_hash_djb2_hash(key, sizeof(lnet_nid_t), mask); } @@ -1801,7 +1801,7 @@ nid_export_object(struct hlist_node *hnode) } static void -nid_export_get(cfs_hash_t *hs, struct hlist_node *hnode) +nid_export_get(struct cfs_hash *hs, struct hlist_node *hnode) { struct obd_export *exp; @@ -1810,7 +1810,7 @@ nid_export_get(cfs_hash_t *hs, struct hlist_node *hnode) } static void -nid_export_put_locked(cfs_hash_t *hs, struct hlist_node *hnode) +nid_export_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) { struct obd_export *exp; @@ -1855,7 +1855,7 @@ nidstats_object(struct hlist_node *hnode) } static void -nidstats_get(cfs_hash_t *hs, struct hlist_node *hnode) +nidstats_get(struct cfs_hash *hs, struct hlist_node *hnode) { struct nid_stat *ns; @@ -1864,7 +1864,7 @@ nidstats_get(cfs_hash_t *hs, struct hlist_node *hnode) } static void -nidstats_put_locked(cfs_hash_t *hs, struct hlist_node *hnode) +nidstats_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) { struct nid_stat *ns; diff --git a/drivers/staging/lustre/lustre/obdclass/uuid.c b/drivers/staging/lustre/lustre/obdclass/uuid.c index af5f27f82bc5..e87a19900770 100644 --- a/drivers/staging/lustre/lustre/obdclass/uuid.c +++ b/drivers/staging/lustre/lustre/obdclass/uuid.c @@ -48,7 +48,7 @@ static inline __u32 consume(int nob, __u8 **ptr) { __u32 value; - LASSERT(nob <= sizeof value); + LASSERT(nob <= sizeof(value)); for (value = 0; nob > 0; --nob) value = (value << 8) | *((*ptr)++); @@ -61,7 +61,7 @@ static void uuid_unpack(class_uuid_t in, __u16 *uu, int nr) { __u8 *ptr = in; - LASSERT(nr * sizeof *uu == sizeof(class_uuid_t)); + LASSERT(nr * sizeof(*uu) == sizeof(class_uuid_t)); while (nr-- > 0) CONSUME(uu[nr], &ptr); diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 2644edf438c1..1fb0ac4e920d 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -1089,7 +1089,7 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, } else { struct lustre_md *md; md = &info->eti_md; - memset(md, 0, sizeof *md); + memset(md, 0, sizeof(*md)); md->lsm = lsm; conf->eoc_cl.u.coc_md = md; } @@ -1387,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++) { diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 90d24d8dea21..ef10e2af787f 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -571,7 +571,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) client_obd_list_lock(&cli->cl_loi_list_lock); seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", - now.tv_sec, now.tv_usec); + now.tv_sec, (unsigned long)now.tv_usec); seq_printf(seq, "read RPCs in flight: %d\n", cli->cl_r_in_flight); seq_printf(seq, "write RPCs in flight: %d\n", @@ -683,7 +683,7 @@ static int osc_stats_seq_show(struct seq_file *seq, void *v) do_gettimeofday(&now); seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", - now.tv_sec, now.tv_usec); + now.tv_sec, (unsigned long)now.tv_usec); seq_printf(seq, "lockless_write_bytes\t\t"LPU64"\n", stats->os_lockless_writes); seq_printf(seq, "lockless_read_bytes\t\t"LPU64"\n", diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 3aeaf845cf27..681d60a7d5ef 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -105,7 +105,7 @@ static int osc_io_submit(const struct lu_env *env, struct osc_object *osc = NULL; /* to keep gcc happy */ struct osc_page *opg; struct cl_io *io; - LIST_HEAD (list); + LIST_HEAD(list); struct cl_page_list *qin = &queue->c2_qin; struct cl_page_list *qout = &queue->c2_qout; diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 5d7bdbfc871a..c90abfbb1d7a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -862,7 +862,7 @@ static int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data) cap = &req->rq_pill; req_capsule_extend(cap, &RQF_LDLM_GL_CALLBACK); req_capsule_set_size(cap, &RMF_DLM_LVB, RCL_SERVER, - sizeof *lvb); + sizeof(*lvb)); result = req_capsule_server_pack(cap); if (result == 0) { lvb = req_capsule_server_get(cap, &RMF_DLM_LVB); diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index d272322b29b6..6c20b8ecfb82 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -245,7 +245,7 @@ static int osc_page_cache_add(const struct lu_env *env, void osc_index2policy(ldlm_policy_data_t *policy, const struct cl_object *obj, pgoff_t start, pgoff_t end) { - memset(policy, 0, sizeof *policy); + memset(policy, 0, sizeof(*policy)); policy->l_extent.start = cl_offset(obj, start); policy->l_extent.end = cl_offset(obj, end + 1) - 1; } diff --git a/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c index 9720c0e865c8..6045a78a2baa 100644 --- a/drivers/staging/lustre/lustre/osc/osc_quota.c +++ b/drivers/staging/lustre/lustre/osc/osc_quota.c @@ -139,7 +139,7 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], * Hash operations for uid/gid <-> osc_quota_info */ static unsigned -oqi_hashfn(cfs_hash_t *hs, const void *key, unsigned mask) +oqi_hashfn(struct cfs_hash *hs, const void *key, unsigned mask) { return cfs_hash_u32_hash(*((__u32*)key), mask); } @@ -172,17 +172,17 @@ oqi_object(struct hlist_node *hnode) } static void -oqi_get(cfs_hash_t *hs, struct hlist_node *hnode) +oqi_get(struct cfs_hash *hs, struct hlist_node *hnode) { } static void -oqi_put_locked(cfs_hash_t *hs, struct hlist_node *hnode) +oqi_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) { } static void -oqi_exit(cfs_hash_t *hs, struct hlist_node *hnode) +oqi_exit(struct cfs_hash *hs, struct hlist_node *hnode) { struct osc_quota_info *oqi; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index ee6707a5ea9d..cb197782d9a3 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2554,7 +2554,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, } req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, - sizeof *lvb); + sizeof(*lvb)); ptlrpc_request_set_replen(req); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 810a458caed7..c2ab0c8c4d42 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -817,7 +817,7 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void) { struct ptlrpc_request_set *set; - OBD_ALLOC(set, sizeof *set); + OBD_ALLOC(set, sizeof(*set)); if (!set) return NULL; atomic_set(&set->set_refcount, 1); @@ -2690,7 +2690,7 @@ int ptlrpc_replay_req(struct ptlrpc_request *req) LASSERT (sizeof (*aa) <= sizeof (req->rq_async_args)); aa = ptlrpc_req_async_args(req); - memset(aa, 0, sizeof *aa); + memset(aa, 0, sizeof(*aa)); /* Prepare request to be resent with ptlrpcd */ aa->praa_old_state = req->rq_send_state; diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index 17ca84208873..6756356faac1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -41,7 +41,7 @@ #include "ptlrpc_internal.h" -static cfs_hash_t *conn_hash = NULL; +static struct cfs_hash *conn_hash = NULL; static cfs_hash_ops_t conn_hash_ops; struct ptlrpc_connection * @@ -161,7 +161,7 @@ EXPORT_SYMBOL(ptlrpc_connection_fini); * Hash operations for net_peer<->connection */ static unsigned -conn_hashfn(cfs_hash_t *hs, const void *key, unsigned mask) +conn_hashfn(struct cfs_hash *hs, const void *key, unsigned mask) { return cfs_hash_djb2_hash(key, sizeof(lnet_process_id_t), mask); } @@ -195,7 +195,7 @@ conn_object(struct hlist_node *hnode) } static void -conn_get(cfs_hash_t *hs, struct hlist_node *hnode) +conn_get(struct cfs_hash *hs, struct hlist_node *hnode) { struct ptlrpc_connection *conn; @@ -204,7 +204,7 @@ conn_get(cfs_hash_t *hs, struct hlist_node *hnode) } static void -conn_put_locked(cfs_hash_t *hs, struct hlist_node *hnode) +conn_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) { struct ptlrpc_connection *conn; @@ -213,7 +213,7 @@ conn_put_locked(cfs_hash_t *hs, struct hlist_node *hnode) } static void -conn_exit(cfs_hash_t *hs, struct hlist_node *hnode) +conn_exit(struct cfs_hash *hs, struct hlist_node *hnode) { struct ptlrpc_connection *conn; diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 5ca69aec72e1..7b96a0e88cdb 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -682,7 +682,7 @@ int ptlrpc_connect_import(struct obd_import *imp) CLASSERT(sizeof (*aa) <= sizeof (request->rq_async_args)); aa = ptlrpc_req_async_args(request); - memset(aa, 0, sizeof *aa); + memset(aa, 0, sizeof(*aa)); aa->pcaa_peer_committed = committed_before_reconnect; aa->pcaa_initial_connect = initial_connect; diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index 2f55ce26ccba..d0a6e5689227 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -1669,7 +1669,7 @@ void req_capsule_init(struct req_capsule *pill, if (req != NULL && pill == &req->rq_pill && req->rq_pill_init) return; - memset(pill, 0, sizeof *pill); + memset(pill, 0, sizeof(*pill)); pill->rc_req = req; pill->rc_loc = location; req_capsule_init_area(pill); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 227a0ae9593b..4d340f4a2198 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -383,8 +383,8 @@ int ptlrpc_start_pinger(void) /* 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); return rc; @@ -409,8 +409,8 @@ int ptlrpc_stop_pinger(void) struct l_wait_info lwi = { 0 }; int rc = 0; - if (!thread_is_init(&pinger_thread) && - !thread_is_stopped(&pinger_thread)) + if (thread_is_init(&pinger_thread) || + thread_is_stopped(&pinger_thread)) return -EALREADY; ptlrpc_pinger_remove_timeouts(); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index fbdeff65d059..89c9be96f454 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -615,7 +615,7 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) 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); @@ -638,7 +638,7 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) 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)); @@ -745,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) @@ -764,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); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 9013745ab105..316103ab7c3c 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) @@ -214,7 +207,7 @@ static void enc_pools_release_free_pages(long npages) p_idx++; g_idx = 0; } - }; + } /* free unused pools */ while (p_idx_max1 < p_idx_max2) { @@ -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,6 +707,12 @@ 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) { /* @@ -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/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index ac8b5fd2300b..21de868da522 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -263,7 +263,7 @@ static struct ptlrpc_hr_service ptlrpc_hr; */ static void rs_batch_init(struct rs_batch *b) { - memset(b, 0, sizeof *b); + memset(b, 0, sizeof(*b)); INIT_LIST_HEAD(&b->rsb_replies); } @@ -1306,12 +1306,12 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) } newdl = cfs_time_current_sec() + at_get(&svcpt->scp_at_estimate); - OBD_ALLOC(reqcopy, sizeof *reqcopy); + OBD_ALLOC(reqcopy, sizeof(*reqcopy)); if (reqcopy == NULL) return -ENOMEM; OBD_ALLOC_LARGE(reqmsg, req->rq_reqlen); if (!reqmsg) { - OBD_FREE(reqcopy, sizeof *reqcopy); + OBD_FREE(reqcopy, sizeof(*reqcopy)); return -ENOMEM; } @@ -1370,7 +1370,7 @@ out_put: out: sptlrpc_svc_ctx_decref(reqcopy); OBD_FREE_LARGE(reqmsg, req->rq_reqlen); - OBD_FREE(reqcopy, sizeof *reqcopy); + OBD_FREE(reqcopy, sizeof(*reqcopy)); return rc; } @@ -2718,15 +2718,15 @@ 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); |