diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-07-07 12:35:33 +0100 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-07-07 12:35:33 +0100 |
commit | 06be5eefe1192eb8ce8d07497f67595b6bfe9741 (patch) | |
tree | 80f1987d4970f8079681f8be0c135cafc8d6329a /drivers/staging/lustre/lustre | |
parent | ARM: fix lockdep unannotated irqs-off warning (diff) | |
parent | ARM: avoid unwanted GCC memset()/memcpy() optimisations for IO variants (diff) | |
download | linux-dev-06be5eefe1192eb8ce8d07497f67595b6bfe9741.tar.xz linux-dev-06be5eefe1192eb8ce8d07497f67595b6bfe9741.zip |
Merge branches 'fixes' and 'ioremap' into for-linus
Diffstat (limited to 'drivers/staging/lustre/lustre')
151 files changed, 3705 insertions, 5556 deletions
diff --git a/drivers/staging/lustre/lustre/fid/Makefile b/drivers/staging/lustre/lustre/fid/Makefile index 5513ce416a35..b7ef314b4b84 100644 --- a/drivers/staging/lustre/lustre/fid/Makefile +++ b/drivers/staging/lustre/lustre/fid/Makefile @@ -1,3 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += fid.o -fid-y := fid_request.o fid_lib.o -fid-$(CONFIG_PROC_FS) += lproc_fid.o +fid-y := fid_request.o fid_lib.o lproc_fid.o diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h b/drivers/staging/lustre/lustre/fid/fid_internal.h index b5e8da8956f2..84daee1154dc 100644 --- a/drivers/staging/lustre/lustre/fid/fid_internal.h +++ b/drivers/staging/lustre/lustre/fid/fid_internal.h @@ -47,10 +47,6 @@ int seq_client_alloc_super(struct lu_client_seq *seq, const struct lu_env *env); -#if defined(CONFIG_PROC_FS) -extern struct lprocfs_vars seq_client_proc_list[]; -#endif - -extern struct proc_dir_entry *seq_type_proc_dir; +extern struct lprocfs_vars seq_client_debugfs_list[]; #endif /* __FID_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 063441abfcfc..1362783b7eab 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -53,6 +53,8 @@ #include "../include/lustre_mdc.h" #include "fid_internal.h" +static struct dentry *seq_debugfs_dir; + static int seq_client_rpc(struct lu_client_seq *seq, struct lu_seq_range *output, __u32 opc, const char *opcname) @@ -201,10 +203,9 @@ static int seq_client_alloc_seq(const struct lu_env *env, CERROR("%s: Can't allocate new meta-sequence, rc %d\n", seq->lcs_name, rc); return rc; - } else { - CDEBUG(D_INFO, "%s: New range - "DRANGE"\n", - seq->lcs_name, PRANGE(&seq->lcs_space)); } + CDEBUG(D_INFO, "%s: New range - "DRANGE"\n", + seq->lcs_name, PRANGE(&seq->lcs_space)); } else { rc = 0; } @@ -400,37 +401,32 @@ void seq_client_flush(struct lu_client_seq *seq) } EXPORT_SYMBOL(seq_client_flush); -static void seq_client_proc_fini(struct lu_client_seq *seq) +static void seq_client_debugfs_fini(struct lu_client_seq *seq) { -#if defined(CONFIG_PROC_FS) - if (seq->lcs_proc_dir) { - if (!IS_ERR(seq->lcs_proc_dir)) - lprocfs_remove(&seq->lcs_proc_dir); - seq->lcs_proc_dir = NULL; - } -#endif /* CONFIG_PROC_FS */ + if (!IS_ERR_OR_NULL(seq->lcs_debugfs_entry)) + ldebugfs_remove(&seq->lcs_debugfs_entry); } -static int seq_client_proc_init(struct lu_client_seq *seq) +static int seq_client_debugfs_init(struct lu_client_seq *seq) { -#if defined(CONFIG_PROC_FS) int rc; - seq->lcs_proc_dir = lprocfs_register(seq->lcs_name, - seq_type_proc_dir, - NULL, NULL); + seq->lcs_debugfs_entry = ldebugfs_register(seq->lcs_name, + seq_debugfs_dir, + NULL, NULL); - if (IS_ERR(seq->lcs_proc_dir)) { - CERROR("%s: LProcFS failed in seq-init\n", - seq->lcs_name); - rc = PTR_ERR(seq->lcs_proc_dir); + if (IS_ERR_OR_NULL(seq->lcs_debugfs_entry)) { + CERROR("%s: LdebugFS failed in seq-init\n", seq->lcs_name); + rc = seq->lcs_debugfs_entry ? PTR_ERR(seq->lcs_debugfs_entry) + : -ENOMEM; + seq->lcs_debugfs_entry = NULL; return rc; } - rc = lprocfs_add_vars(seq->lcs_proc_dir, - seq_client_proc_list, seq); + rc = ldebugfs_add_vars(seq->lcs_debugfs_entry, + seq_client_debugfs_list, seq); if (rc) { - CERROR("%s: Can't init sequence manager proc, rc %d\n", + CERROR("%s: Can't init sequence manager debugfs, rc %d\n", seq->lcs_name, rc); goto out_cleanup; } @@ -438,12 +434,8 @@ static int seq_client_proc_init(struct lu_client_seq *seq) return 0; out_cleanup: - seq_client_proc_fini(seq); + seq_client_debugfs_fini(seq); return rc; - -#else /* CONFIG_PROC_FS */ - return 0; -#endif } int seq_client_init(struct lu_client_seq *seq, @@ -478,7 +470,7 @@ int seq_client_init(struct lu_client_seq *seq, snprintf(seq->lcs_name, sizeof(seq->lcs_name), "cli-%s", prefix); - rc = seq_client_proc_init(seq); + rc = seq_client_debugfs_init(seq); if (rc) seq_client_fini(seq); return rc; @@ -487,7 +479,7 @@ EXPORT_SYMBOL(seq_client_init); void seq_client_fini(struct lu_client_seq *seq) { - seq_client_proc_fini(seq); + seq_client_debugfs_fini(seq); if (seq->lcs_exp != NULL) { class_export_put(seq->lcs_exp); @@ -505,11 +497,11 @@ int client_fid_init(struct obd_device *obd, char *prefix; int rc; - OBD_ALLOC_PTR(cli->cl_seq); + cli->cl_seq = kzalloc(sizeof(*cli->cl_seq), GFP_NOFS); if (cli->cl_seq == NULL) return -ENOMEM; - OBD_ALLOC(prefix, MAX_OBD_NAME + 5); + prefix = kzalloc(MAX_OBD_NAME + 5, GFP_NOFS); if (prefix == NULL) { rc = -ENOMEM; goto out_free_seq; @@ -519,13 +511,13 @@ int client_fid_init(struct obd_device *obd, /* Init client side sequence-manager */ rc = seq_client_init(cli->cl_seq, exp, type, prefix, NULL); - OBD_FREE(prefix, MAX_OBD_NAME + 5); + kfree(prefix); if (rc) goto out_free_seq; return rc; out_free_seq: - OBD_FREE_PTR(cli->cl_seq); + kfree(cli->cl_seq); cli->cl_seq = NULL; return rc; } @@ -537,7 +529,7 @@ int client_fid_fini(struct obd_device *obd) if (cli->cl_seq != NULL) { seq_client_fini(cli->cl_seq); - OBD_FREE_PTR(cli->cl_seq); + kfree(cli->cl_seq); cli->cl_seq = NULL; } @@ -545,22 +537,18 @@ int client_fid_fini(struct obd_device *obd) } EXPORT_SYMBOL(client_fid_fini); -struct proc_dir_entry *seq_type_proc_dir; - static int __init fid_mod_init(void) { - seq_type_proc_dir = lprocfs_register(LUSTRE_SEQ_NAME, - proc_lustre_root, - NULL, NULL); - return PTR_ERR_OR_ZERO(seq_type_proc_dir); + seq_debugfs_dir = ldebugfs_register(LUSTRE_SEQ_NAME, + debugfs_lustre_root, + NULL, NULL); + return PTR_ERR_OR_ZERO(seq_debugfs_dir); } static void __exit fid_mod_exit(void) { - if (seq_type_proc_dir != NULL && !IS_ERR(seq_type_proc_dir)) { - lprocfs_remove(&seq_type_proc_dir); - seq_type_proc_dir = NULL; - } + if (!IS_ERR_OR_NULL(seq_debugfs_dir)) + ldebugfs_remove(&seq_debugfs_dir); } MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index 783939dbd4db..cc2201c25339 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -59,8 +59,9 @@ * Note: this function is only used for testing, it is no safe for production * use. */ -static int lprocfs_fid_write_common(const char __user *buffer, size_t count, - struct lu_seq_range *range) +static int +ldebugfs_fid_write_common(const char __user *buffer, size_t count, + struct lu_seq_range *range) { struct lu_seq_range tmp; int rc; @@ -92,10 +93,11 @@ static int lprocfs_fid_write_common(const char __user *buffer, size_t count, return count; } -/* Client side procfs stuff */ -static ssize_t lprocfs_fid_space_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +/* Client side debugfs stuff */ +static ssize_t +ldebugfs_fid_space_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct lu_client_seq *seq; int rc; @@ -104,7 +106,7 @@ static ssize_t lprocfs_fid_space_seq_write(struct file *file, LASSERT(seq != NULL); mutex_lock(&seq->lcs_mutex); - rc = lprocfs_fid_write_common(buffer, count, &seq->lcs_space); + rc = ldebugfs_fid_write_common(buffer, count, &seq->lcs_space); if (rc == 0) { CDEBUG(D_INFO, "%s: Space: "DRANGE"\n", @@ -117,7 +119,7 @@ static ssize_t lprocfs_fid_space_seq_write(struct file *file, } static int -lprocfs_fid_space_seq_show(struct seq_file *m, void *unused) +ldebugfs_fid_space_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; @@ -130,9 +132,10 @@ lprocfs_fid_space_seq_show(struct seq_file *m, void *unused) return 0; } -static ssize_t lprocfs_fid_width_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t +ldebugfs_fid_width_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct lu_client_seq *seq; __u64 max; @@ -154,10 +157,8 @@ static ssize_t lprocfs_fid_width_seq_write(struct file *file, if (val <= max && val > 0) { seq->lcs_width = val; - if (rc == 0) { - CDEBUG(D_INFO, "%s: Sequence size: %llu\n", - seq->lcs_name, seq->lcs_width); - } + CDEBUG(D_INFO, "%s: Sequence size: %llu\n", seq->lcs_name, + seq->lcs_width); } mutex_unlock(&seq->lcs_mutex); @@ -166,7 +167,7 @@ static ssize_t lprocfs_fid_width_seq_write(struct file *file, } static int -lprocfs_fid_width_seq_show(struct seq_file *m, void *unused) +ldebugfs_fid_width_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; @@ -180,7 +181,7 @@ lprocfs_fid_width_seq_show(struct seq_file *m, void *unused) } static int -lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused) +ldebugfs_fid_fid_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; @@ -194,7 +195,7 @@ lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused) } static int -lprocfs_fid_server_seq_show(struct seq_file *m, void *unused) +ldebugfs_fid_server_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; struct client_obd *cli; @@ -211,15 +212,15 @@ lprocfs_fid_server_seq_show(struct seq_file *m, void *unused) return 0; } -LPROC_SEQ_FOPS(lprocfs_fid_space); -LPROC_SEQ_FOPS(lprocfs_fid_width); -LPROC_SEQ_FOPS_RO(lprocfs_fid_server); -LPROC_SEQ_FOPS_RO(lprocfs_fid_fid); +LPROC_SEQ_FOPS(ldebugfs_fid_space); +LPROC_SEQ_FOPS(ldebugfs_fid_width); +LPROC_SEQ_FOPS_RO(ldebugfs_fid_server); +LPROC_SEQ_FOPS_RO(ldebugfs_fid_fid); -struct lprocfs_vars seq_client_proc_list[] = { - { "space", &lprocfs_fid_space_fops }, - { "width", &lprocfs_fid_width_fops }, - { "server", &lprocfs_fid_server_fops }, - { "fid", &lprocfs_fid_fid_fops }, +struct lprocfs_vars seq_client_debugfs_list[] = { + { "space", &ldebugfs_fid_space_fops }, + { "width", &ldebugfs_fid_width_fops }, + { "server", &ldebugfs_fid_server_fops }, + { "fid", &ldebugfs_fid_fid_fops }, { NULL } }; diff --git a/drivers/staging/lustre/lustre/fld/Makefile b/drivers/staging/lustre/lustre/fld/Makefile index 2bbf08433dca..646e315d1aa8 100644 --- a/drivers/staging/lustre/lustre/fld/Makefile +++ b/drivers/staging/lustre/lustre/fld/Makefile @@ -1,3 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += fld.o -fld-y := fld_request.o fld_cache.o -fld-$(CONFIG_PROC_FS) += lproc_fld.o +fld-y := fld_request.o fld_cache.o lproc_fld.o diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index 0d0a73745065..ec2fc4339a2e 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -69,7 +69,7 @@ struct fld_cache *fld_cache_init(const char *name, LASSERT(name != NULL); LASSERT(cache_threshold < cache_size); - OBD_ALLOC_PTR(cache); + cache = kzalloc(sizeof(*cache), GFP_NOFS); if (cache == NULL) return ERR_PTR(-ENOMEM); @@ -116,7 +116,7 @@ void fld_cache_fini(struct fld_cache *cache) CDEBUG(D_INFO, " Cache reqs: %llu\n", cache->fci_stat.fst_cache); CDEBUG(D_INFO, " Cache hits: %llu%%\n", pct); - OBD_FREE_PTR(cache); + kfree(cache); } /** @@ -128,7 +128,7 @@ void fld_cache_entry_delete(struct fld_cache *cache, list_del(&node->fce_list); list_del(&node->fce_lru); cache->fci_cache_count--; - OBD_FREE_PTR(node); + kfree(node); } /** @@ -268,7 +268,7 @@ static void fld_cache_punch_hole(struct fld_cache *cache, OBD_ALLOC_GFP(fldt, sizeof(*fldt), GFP_ATOMIC); if (!fldt) { - OBD_FREE_PTR(f_new); + kfree(f_new); /* overlap is not allowed, so dont mess up list. */ return; } @@ -315,7 +315,7 @@ static void fld_cache_overlap_handle(struct fld_cache *cache, f_curr->fce_range.lsr_end = max(f_curr->fce_range.lsr_end, new_end); - OBD_FREE_PTR(f_new); + kfree(f_new); fld_fix_new_list(cache); } else if (new_start <= f_curr->fce_range.lsr_start && @@ -324,7 +324,7 @@ static void fld_cache_overlap_handle(struct fld_cache *cache, * e.g. whole range migrated. update fld cache entry */ f_curr->fce_range = *range; - OBD_FREE_PTR(f_new); + kfree(f_new); fld_fix_new_list(cache); } else if (f_curr->fce_range.lsr_start < new_start && @@ -364,7 +364,7 @@ struct fld_cache_entry LASSERT(range_is_sane(range)); - OBD_ALLOC_PTR(f_new); + f_new = kzalloc(sizeof(*f_new), GFP_NOFS); if (!f_new) return ERR_PTR(-ENOMEM); @@ -440,7 +440,7 @@ int fld_cache_insert(struct fld_cache *cache, rc = fld_cache_insert_nolock(cache, flde); write_unlock(&cache->fci_lock); if (rc) - OBD_FREE_PTR(flde); + kfree(flde); return rc; } diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h index 68bec7658463..844576b9bc6f 100644 --- a/drivers/staging/lustre/lustre/fld/fld_internal.h +++ b/drivers/staging/lustre/lustre/fld/fld_internal.h @@ -142,10 +142,7 @@ extern struct lu_fld_hash fld_hash[]; int fld_client_rpc(struct obd_export *exp, struct lu_seq_range *range, __u32 fld_op); -#if defined(CONFIG_PROC_FS) -extern struct lprocfs_vars fld_client_proc_list[]; -#endif - +extern struct lprocfs_vars fld_client_debugfs_list[]; struct fld_cache *fld_cache_init(const char *name, int cache_size, int cache_threshold); diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 6ac225e90ee0..c3b47f2346df 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -221,7 +221,7 @@ int fld_client_add_target(struct lu_client_fld *fld, CDEBUG(D_INFO, "%s: Adding target %s (idx %llu)\n", fld->lcf_name, name, tar->ft_idx); - OBD_ALLOC_PTR(target); + target = kzalloc(sizeof(*target), GFP_NOFS); if (target == NULL) return -ENOMEM; @@ -229,7 +229,7 @@ int fld_client_add_target(struct lu_client_fld *fld, list_for_each_entry(tmp, &fld->lcf_targets, ft_chain) { if (tmp->ft_idx == tar->ft_idx) { spin_unlock(&fld->lcf_lock); - OBD_FREE_PTR(target); + kfree(target); CERROR("Target %s exists in FLD and known as %s:#%llu\n", name, fld_target_name(tmp), tmp->ft_idx); return -EEXIST; @@ -268,7 +268,7 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) if (target->ft_exp != NULL) class_export_put(target->ft_exp); - OBD_FREE_PTR(target); + kfree(target); return 0; } } @@ -277,58 +277,44 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) } EXPORT_SYMBOL(fld_client_del_target); -static struct proc_dir_entry *fld_type_proc_dir; +static struct dentry *fld_debugfs_dir; -#if defined(CONFIG_PROC_FS) -static int fld_client_proc_init(struct lu_client_fld *fld) +static int fld_client_debugfs_init(struct lu_client_fld *fld) { int rc; - fld->lcf_proc_dir = lprocfs_register(fld->lcf_name, - fld_type_proc_dir, - NULL, NULL); + fld->lcf_debugfs_entry = ldebugfs_register(fld->lcf_name, + fld_debugfs_dir, + NULL, NULL); - if (IS_ERR(fld->lcf_proc_dir)) { - CERROR("%s: LProcFS failed in fld-init\n", - fld->lcf_name); - rc = PTR_ERR(fld->lcf_proc_dir); + if (IS_ERR_OR_NULL(fld->lcf_debugfs_entry)) { + CERROR("%s: LdebugFS failed in fld-init\n", fld->lcf_name); + rc = fld->lcf_debugfs_entry ? PTR_ERR(fld->lcf_debugfs_entry) + : -ENOMEM; + fld->lcf_debugfs_entry = NULL; return rc; } - rc = lprocfs_add_vars(fld->lcf_proc_dir, - fld_client_proc_list, fld); + rc = ldebugfs_add_vars(fld->lcf_debugfs_entry, + fld_client_debugfs_list, fld); if (rc) { - CERROR("%s: Can't init FLD proc, rc %d\n", - fld->lcf_name, rc); + CERROR("%s: Can't init FLD debufs, rc %d\n", fld->lcf_name, rc); goto out_cleanup; } return 0; out_cleanup: - fld_client_proc_fini(fld); + fld_client_debugfs_fini(fld); return rc; } -void fld_client_proc_fini(struct lu_client_fld *fld) +void fld_client_debugfs_fini(struct lu_client_fld *fld) { - if (fld->lcf_proc_dir) { - if (!IS_ERR(fld->lcf_proc_dir)) - lprocfs_remove(&fld->lcf_proc_dir); - fld->lcf_proc_dir = NULL; - } -} -#else -static int fld_client_proc_init(struct lu_client_fld *fld) -{ - return 0; + if (!IS_ERR_OR_NULL(fld->lcf_debugfs_entry)) + ldebugfs_remove(&fld->lcf_debugfs_entry); } - -void fld_client_proc_fini(struct lu_client_fld *fld) -{ -} -#endif -EXPORT_SYMBOL(fld_client_proc_fini); +EXPORT_SYMBOL(fld_client_debugfs_fini); static inline int hash_is_sane(int hash) { @@ -372,7 +358,7 @@ int fld_client_init(struct lu_client_fld *fld, goto out; } - rc = fld_client_proc_init(fld); + rc = fld_client_debugfs_init(fld); if (rc) goto out; out: @@ -396,7 +382,7 @@ void fld_client_fini(struct lu_client_fld *fld) list_del(&target->ft_chain); if (target->ft_exp != NULL) class_export_put(target->ft_exp); - OBD_FREE_PTR(target); + kfree(target); } spin_unlock(&fld->lcf_lock); @@ -504,18 +490,16 @@ EXPORT_SYMBOL(fld_client_flush); static int __init fld_mod_init(void) { - fld_type_proc_dir = lprocfs_register(LUSTRE_FLD_NAME, - proc_lustre_root, - NULL, NULL); - return PTR_ERR_OR_ZERO(fld_type_proc_dir); + fld_debugfs_dir = ldebugfs_register(LUSTRE_FLD_NAME, + debugfs_lustre_root, + NULL, NULL); + return PTR_ERR_OR_ZERO(fld_debugfs_dir); } static void __exit fld_mod_exit(void) { - if (fld_type_proc_dir != NULL && !IS_ERR(fld_type_proc_dir)) { - lprocfs_remove(&fld_type_proc_dir); - fld_type_proc_dir = NULL; - } + if (!IS_ERR_OR_NULL(fld_debugfs_dir)) + ldebugfs_remove(&fld_debugfs_dir); } MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index f53fdcfae34e..da822101e005 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -56,7 +56,7 @@ #include "fld_internal.h" static int -fld_proc_targets_seq_show(struct seq_file *m, void *unused) +fld_debugfs_targets_seq_show(struct seq_file *m, void *unused) { struct lu_client_fld *fld = (struct lu_client_fld *)m->private; struct lu_fld_target *target; @@ -73,7 +73,7 @@ fld_proc_targets_seq_show(struct seq_file *m, void *unused) } static int -fld_proc_hash_seq_show(struct seq_file *m, void *unused) +fld_debugfs_hash_seq_show(struct seq_file *m, void *unused) { struct lu_client_fld *fld = (struct lu_client_fld *)m->private; @@ -87,9 +87,9 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused) } static ssize_t -fld_proc_hash_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +fld_debugfs_hash_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct lu_client_fld *fld; struct lu_fld_hash *hash = NULL; @@ -128,8 +128,8 @@ fld_proc_hash_seq_write(struct file *file, } static ssize_t -fld_proc_cache_flush_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) +fld_debugfs_cache_flush_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { struct lu_client_fld *fld = file->private_data; @@ -142,31 +142,26 @@ fld_proc_cache_flush_write(struct file *file, const char __user *buffer, return count; } -static int fld_proc_cache_flush_open(struct inode *inode, struct file *file) -{ - file->private_data = PDE_DATA(inode); - return 0; -} - -static int fld_proc_cache_flush_release(struct inode *inode, struct file *file) +static int +fld_debugfs_cache_flush_release(struct inode *inode, struct file *file) { file->private_data = NULL; return 0; } -static struct file_operations fld_proc_cache_flush_fops = { +static struct file_operations fld_debugfs_cache_flush_fops = { .owner = THIS_MODULE, - .open = fld_proc_cache_flush_open, - .write = fld_proc_cache_flush_write, - .release = fld_proc_cache_flush_release, + .open = simple_open, + .write = fld_debugfs_cache_flush_write, + .release = fld_debugfs_cache_flush_release, }; -LPROC_SEQ_FOPS_RO(fld_proc_targets); -LPROC_SEQ_FOPS(fld_proc_hash); +LPROC_SEQ_FOPS_RO(fld_debugfs_targets); +LPROC_SEQ_FOPS(fld_debugfs_hash); -struct lprocfs_vars fld_client_proc_list[] = { - { "targets", &fld_proc_targets_fops }, - { "hash", &fld_proc_hash_fops }, - { "cache_flush", &fld_proc_cache_flush_fops }, +struct lprocfs_vars fld_client_debugfs_list[] = { + { "targets", &fld_debugfs_targets_fops }, + { "hash", &fld_debugfs_hash_fops }, + { "cache_flush", &fld_debugfs_cache_flush_fops }, { NULL } }; diff --git a/drivers/staging/lustre/lustre/include/dt_object.h b/drivers/staging/lustre/lustre/include/dt_object.h index be4c7d95e788..abae31b41e74 100644 --- a/drivers/staging/lustre/lustre/include/dt_object.h +++ b/drivers/staging/lustre/lustre/include/dt_object.h @@ -58,7 +58,6 @@ #include "../../include/linux/libcfs/libcfs.h" struct seq_file; -struct proc_dir_entry; struct lustre_cfg; struct thandle; @@ -1481,7 +1480,6 @@ static inline struct dt_thread_info *dt_info(const struct lu_env *env) int dt_global_init(void); void dt_global_fini(void); -#if defined (CONFIG_PROC_FS) int lprocfs_dt_rd_blksize(char *page, char **start, off_t off, int count, int *eof, void *data); int lprocfs_dt_rd_kbytestotal(char *page, char **start, off_t off, @@ -1494,6 +1492,5 @@ int lprocfs_dt_rd_filestotal(char *page, char **start, off_t off, int count, int *eof, void *data); int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off, int count, int *eof, void *data); -#endif /* CONFIG_PROC_FS */ #endif /* __LUSTRE_DT_OBJECT_H */ diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 3925db160650..513c81f43d6e 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -189,22 +189,7 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount) #endif - -/* - * After 3.1, kernel's nameidata.intent.open.flags is different - * with lustre's lookup_intent.it_flags, as lustre's it_flags' - * lower bits equal to FMODE_xxx while kernel doesn't transliterate - * lower bits of nameidata.intent.open.flags to FMODE_xxx. - * */ #include <linux/version.h> -static inline int ll_namei_to_lookup_intent_flag(int flag) -{ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) - flag = (flag & ~O_ACCMODE) | OPEN_FMODE(flag); -#endif - return flag; -} - #include <linux/fs.h> # define ll_umode_t umode_t diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h index a7658a99a08d..45651caf42cc 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h @@ -44,7 +44,6 @@ #include <linux/fs.h> #include <linux/dcache.h> -#include <linux/proc_fs.h> #include "../obd_class.h" #include "../lustre_net.h" diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h index d72605864b0a..14562788e4e0 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h @@ -55,9 +55,7 @@ truncate_complete_page(struct address_space *mapping, struct page *page) if (PagePrivate(page)) page->mapping->a_ops->invalidatepage(page, 0, PAGE_CACHE_SIZE); - if (TestClearPageDirty(page)) - account_page_cleaned(page, mapping); - + cancel_dirty_page(page); ClearPageMappedToDisk(page); ll_delete_from_page_cache(page); } diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h index 9cd8683573ce..2817e88e014a 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd.h +++ b/drivers/staging/lustre/lustre/include/linux/obd.h @@ -43,11 +43,11 @@ #include "../obd_support.h" -# include <linux/fs.h> -# include <linux/list.h> -# include <linux/sched.h> /* for struct task_struct, for current.h */ -# include <linux/proc_fs.h> -# include <linux/mount.h> +#include <linux/fs.h> +#include <linux/list.h> +#include <linux/sched.h> /* for struct task_struct, for current.h */ +#include <linux/mount.h> + #include "../lustre_intent.h" struct ll_iattr { diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index d030847e51ba..8ede2a00ca4f 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -42,7 +42,7 @@ #ifndef _LPROCFS_SNMP_H #define _LPROCFS_SNMP_H -#include <linux/proc_fs.h> +#include <linux/debugfs.h> #include <linux/seq_file.h> #include <linux/spinlock.h> #include <linux/types.h> @@ -60,8 +60,8 @@ struct lprocfs_vars { }; struct lprocfs_static_vars { - struct lprocfs_vars *module_vars; struct lprocfs_vars *obd_vars; + struct attribute_group *sysfs_vars; }; /* if we find more consumers this could be generalized */ @@ -348,7 +348,8 @@ enum { #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE /* class_obd.c */ -extern struct proc_dir_entry *proc_lustre_root; +extern struct dentry *debugfs_lustre_root; +extern struct kobject *lustre_kobj; struct obd_device; struct obd_histogram; @@ -378,8 +379,6 @@ extern int lprocfs_write_frac_helper(const char __user *buffer, unsigned long count, int *val, int mult); extern int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, int mult); -#if defined (CONFIG_PROC_FS) - extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid); /* @@ -422,9 +421,8 @@ static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int opc, else spin_lock(&stats->ls_lock); return 1; - } else { - return stats->ls_biggest_alloc_num; } + return stats->ls_biggest_alloc_num; } } @@ -556,53 +554,45 @@ extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index, extern void lprocfs_free_obd_stats(struct obd_device *obddev); extern void lprocfs_free_md_stats(struct obd_device *obddev); struct obd_export; -struct nid_stat; -extern int lprocfs_add_clear_entry(struct obd_device *obd, - struct proc_dir_entry *entry); -extern int lprocfs_exp_setup(struct obd_export *exp, - lnet_nid_t *peer_nid, int *newnid); extern int lprocfs_exp_cleanup(struct obd_export *exp); -extern struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, - char *name, - void *data, - struct file_operations *fops); -extern struct proc_dir_entry * -lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent, +extern struct dentry *ldebugfs_add_simple(struct dentry *root, + char *name, + void *data, + struct file_operations *fops); +extern struct dentry * +ldebugfs_add_symlink(const char *name, struct dentry *parent, const char *format, ...); -extern void lprocfs_free_per_client_stats(struct obd_device *obd); -extern int -lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, - unsigned long count, void *data); -extern int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data); -extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, - struct lprocfs_stats *stats); +extern int ldebugfs_register_stats(struct dentry *parent, + const char *name, + struct lprocfs_stats *stats); /* lprocfs_status.c */ -extern int lprocfs_add_vars(struct proc_dir_entry *root, - struct lprocfs_vars *var, - void *data); +extern int ldebugfs_add_vars(struct dentry *parent, + struct lprocfs_vars *var, + void *data); -extern struct proc_dir_entry *lprocfs_register(const char *name, - struct proc_dir_entry *parent, - struct lprocfs_vars *list, - void *data); +extern struct dentry *ldebugfs_register(const char *name, + struct dentry *parent, + struct lprocfs_vars *list, + void *data); -extern void lprocfs_remove(struct proc_dir_entry **root); -extern void lprocfs_remove_proc_entry(const char *name, - struct proc_dir_entry *parent); +extern void ldebugfs_remove(struct dentry **entryp); -extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list); +extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, + struct attribute_group *attrs); extern int lprocfs_obd_cleanup(struct obd_device *obd); -extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name, - umode_t mode, - const struct file_operations *seq_fops, - void *data); -extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name, - umode_t mode, - const struct file_operations *seq_fops, - void *data); +extern int ldebugfs_seq_create(struct dentry *parent, + const char *name, + umode_t mode, + const struct file_operations *seq_fops, + void *data); +extern int ldebugfs_obd_seq_create(struct obd_device *dev, + const char *name, + umode_t mode, + const struct file_operations *seq_fops, + void *data); /* Generic callbacks */ @@ -613,15 +603,12 @@ extern int lprocfs_wr_atomic(struct file *file, const char __user *buffer, extern int lprocfs_rd_uint(struct seq_file *m, void *data); extern int lprocfs_wr_uint(struct file *file, const char __user *buffer, unsigned long count, void *data); -extern int lprocfs_rd_uuid(struct seq_file *m, void *data); extern int lprocfs_rd_name(struct seq_file *m, void *data); extern int lprocfs_rd_server_uuid(struct seq_file *m, void *data); extern int lprocfs_rd_conn_uuid(struct seq_file *m, void *data); extern int lprocfs_rd_import(struct seq_file *m, void *data); extern int lprocfs_rd_state(struct seq_file *m, void *data); extern int lprocfs_rd_connect_flags(struct seq_file *m, void *data); -extern int lprocfs_rd_num_exports(struct seq_file *m, void *data); -extern int lprocfs_rd_numrefs(struct seq_file *m, void *data); struct adaptive_timeout; extern int lprocfs_at_hist_helper(struct seq_file *m, @@ -640,12 +627,6 @@ extern int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, size_t count, loff_t *off); /* Statfs helpers */ -extern int lprocfs_rd_blksize(struct seq_file *m, void *data); -extern int lprocfs_rd_kbytestotal(struct seq_file *m, void *data); -extern int lprocfs_rd_kbytesfree(struct seq_file *m, void *data); -extern int lprocfs_rd_kbytesavail(struct seq_file *m, void *data); -extern int lprocfs_rd_filestotal(struct seq_file *m, void *data); -extern int lprocfs_rd_filesfree(struct seq_file *m, void *data); extern int lprocfs_write_helper(const char __user *buffer, unsigned long count, int *val); @@ -685,11 +666,11 @@ extern int lprocfs_seq_release(struct inode *, struct file *); /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only proc entries; otherwise, you will define name##_seq_write function also for a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally, - call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */ + call ldebugfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */ #define __LPROC_SEQ_FOPS(name, custom_seq_write) \ static int name##_single_open(struct inode *inode, struct file *file) \ { \ - return single_open(file, name##_seq_show, PDE_DATA(inode)); \ + return single_open(file, name##_seq_show, inode->i_private); \ } \ static struct file_operations name##_fops = { \ .owner = THIS_MODULE, \ @@ -734,7 +715,7 @@ static struct file_operations name##_fops = { \ } \ static int name##_##type##_open(struct inode *inode, struct file *file) \ { \ - return single_open(file, NULL, PDE_DATA(inode)); \ + return single_open(file, NULL, inode->i_private); \ } \ static struct file_operations name##_##type##_fops = { \ .open = name##_##type##_open, \ @@ -742,6 +723,27 @@ static struct file_operations name##_fops = { \ .release = lprocfs_single_release, \ } +struct lustre_attr { + struct attribute attr; + ssize_t (*show)(struct kobject *kobj, struct attribute *attr, + char *buf); + ssize_t (*store)(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t len); +}; + +#define LUSTRE_ATTR(name, mode, show, store) \ +static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store) + +#define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL) +#define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store) + +ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr, + char *buf); +ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t len); + +extern const struct sysfs_ops lustre_sysfs_ops; + /* lproc_ptlrpc.c */ struct ptlrpc_request; extern void target_print_req(void *seq_file, struct ptlrpc_request *req); @@ -810,206 +812,4 @@ extern int lprocfs_quota_rd_qs_factor(char *page, char **start, loff_t off, extern int lprocfs_quota_wr_qs_factor(struct file *file, const char *buffer, unsigned long count, void *data); -#else -/* CONFIG_PROC_FS is not defined */ - -#define proc_lustre_root NULL - -static inline void lprocfs_counter_add(struct lprocfs_stats *stats, - int index, long amount) -{ return; } -static inline void lprocfs_counter_incr(struct lprocfs_stats *stats, - int index) -{ return; } -static inline void lprocfs_counter_sub(struct lprocfs_stats *stats, - int index, long amount) -{ return; } -static inline void lprocfs_counter_decr(struct lprocfs_stats *stats, - int index) -{ return; } -static inline void lprocfs_counter_init(struct lprocfs_stats *stats, - int index, unsigned conf, - const char *name, const char *units) -{ return; } - -static inline __u64 lc_read_helper(struct lprocfs_counter *lc, - enum lprocfs_fields_flags field) -{ return 0; } - -/* NB: we return !NULL to satisfy error checker */ -static inline struct lprocfs_stats * -lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags) -{ return (struct lprocfs_stats *)1; } -static inline void lprocfs_clear_stats(struct lprocfs_stats *stats) -{ return; } -static inline void lprocfs_free_stats(struct lprocfs_stats **stats) -{ return; } -static inline int lprocfs_register_stats(struct proc_dir_entry *root, - const char *name, - struct lprocfs_stats *stats) -{ return 0; } -static inline void lprocfs_init_ops_stats(int num_private_stats, - struct lprocfs_stats *stats) -{ return; } -static inline void lprocfs_init_mps_stats(int num_private_stats, - struct lprocfs_stats *stats) -{ return; } -static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) -{ return; } -static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev, - unsigned int num_private_stats) -{ return 0; } -static inline int lprocfs_alloc_md_stats(struct obd_device *obddev, - unsigned int num_private_stats) -{ return 0; } -static inline void lprocfs_free_obd_stats(struct obd_device *obddev) -{ return; } -static inline void lprocfs_free_md_stats(struct obd_device *obddev) -{ return; } - -struct obd_export; -static inline int lprocfs_add_clear_entry(struct obd_export *exp) -{ return 0; } -static inline int lprocfs_exp_setup(struct obd_export *exp, - lnet_nid_t *peer_nid, - int *newnid) -{ return 0; } -static inline int lprocfs_exp_cleanup(struct obd_export *exp) -{ return 0; } -static inline struct proc_dir_entry * -lprocfs_add_simple(struct proc_dir_entry *root, char *name, - void *data, struct file_operations *fops) -{return 0; } -static inline struct proc_dir_entry * -lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent, - const char *format, ...) -{return NULL; } -static inline void lprocfs_free_per_client_stats(struct obd_device *obd) -{ return; } -static inline -int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, - unsigned long count, void *data) -{return count;} -static inline -int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data) -{ return 0; } - -static inline struct proc_dir_entry * -lprocfs_register(const char *name, struct proc_dir_entry *parent, - struct lprocfs_vars *list, void *data) -{ return NULL; } -static inline int lprocfs_add_vars(struct proc_dir_entry *root, - struct lprocfs_vars *var, - void *data) -{ return 0; } -static inline void lprocfs_remove(struct proc_dir_entry **root) -{ return; } -static inline void lprocfs_remove_proc_entry(const char *name, - struct proc_dir_entry *parent) -{ return; } -static inline int lprocfs_obd_setup(struct obd_device *dev, - struct lprocfs_vars *list) -{ return 0; } -static inline int lprocfs_obd_cleanup(struct obd_device *dev) -{ return 0; } -static inline int lprocfs_rd_u64(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_uuid(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_name(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_server_uuid(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_conn_uuid(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_import(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_pinger_recov(struct seq_file *m, void *n) -{ return 0; } -static inline int lprocfs_rd_state(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_connect_flags(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_rd_num_exports(struct seq_file *m, void *data) -{ return 0; } -extern inline int lprocfs_rd_numrefs(struct seq_file *m, void *data) -{ return 0; } -struct adaptive_timeout; -static inline int lprocfs_at_hist_helper(struct seq_file *m, - struct adaptive_timeout *at) -{ return 0; } -static inline int lprocfs_rd_timeouts(struct seq_file *m, void *data) -{ return 0; } -static inline int lprocfs_wr_timeouts(struct file *file, - const char __user *buffer, - unsigned long count, void *data) -{ return 0; } -static inline int lprocfs_wr_evict_client(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) -{ return 0; } -static inline int lprocfs_wr_ping(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) -{ return 0; } -static inline int lprocfs_wr_import(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) -{ return 0; } -static inline int lprocfs_wr_pinger_recov(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) -{ return 0; } - -/* Statfs helpers */ -static inline -int lprocfs_rd_blksize(struct seq_file *m, void *data) -{ return 0; } -static inline -int lprocfs_rd_kbytestotal(struct seq_file *m, void *data) -{ return 0; } -static inline -int lprocfs_rd_kbytesfree(struct seq_file *m, void *data) -{ return 0; } -static inline -int lprocfs_rd_kbytesavail(struct seq_file *m, void *data) -{ return 0; } -static inline -int lprocfs_rd_filestotal(struct seq_file *m, void *data) -{ return 0; } -static inline -int lprocfs_rd_filesfree(struct seq_file *m, void *data) -{ return 0; } -static inline -void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value) -{ return; } -static inline -void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value) -{ return; } -static inline -void lprocfs_oh_clear(struct obd_histogram *oh) -{ return; } -static inline -unsigned long lprocfs_oh_sum(struct obd_histogram *oh) -{ return 0; } -static inline -void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, - struct lprocfs_counter *cnt) -{ return; } -static inline -__u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx, - enum lprocfs_fields_flags field) -{ return (__u64)0; } - -#define LPROC_SEQ_FOPS_RO(name) -#define LPROC_SEQ_FOPS(name) -#define LPROC_SEQ_FOPS_RO_TYPE(name, type) -#define LPROC_SEQ_FOPS_RW_TYPE(name, type) -#define LPROC_SEQ_FOPS_WR_ONLY(name, type) - -/* lproc_ptlrpc.c */ -#define target_print_req NULL - -#endif /* CONFIG_PROC_FS */ - #endif /* LPROCFS_SNMP_H */ diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index c8cc48f00026..e1d72a7a5c2d 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -43,7 +43,6 @@ #include "lu_ref.h" struct seq_file; -struct proc_dir_entry; struct lustre_cfg; struct lprocfs_stats; @@ -277,7 +276,6 @@ struct lu_device { * Stack this device belongs to. */ struct lu_site *ld_site; - struct proc_dir_entry *ld_proc_entry; /** \todo XXX: temporary back pointer into obd. */ struct obd_device *ld_obd; diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 305ecbee9b78..4d72d6ed26b0 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -92,6 +92,7 @@ #define _LUSTRE_IDL_H_ #include "../../../include/linux/libcfs/libcfs.h" +#include "../../../include/linux/lnet/types.h" /* Defn's shared with user-space. */ #include "lustre_user.h" diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 89794fdfec9d..e095ada40ed2 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -243,7 +243,6 @@ struct ost_id { #define LL_IOC_LMV_SETSTRIPE _IOWR('f', 240, struct lmv_user_md) #define LL_IOC_LMV_GETSTRIPE _IOWR('f', 241, struct lmv_user_md) -#define LL_IOC_REMOVE_ENTRY _IOWR('f', 242, __u64) #define LL_IOC_SET_LEASE _IOWR('f', 243, long) #define LL_IOC_GET_LEASE _IO('f', 244) #define LL_IOC_HSM_IMPORT _IOWR('f', 245, struct hsm_user_import) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index bac9902b56bb..f6f4c037fb30 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -60,11 +60,13 @@ struct obd_ops; struct obd_device; +extern struct kset *ldlm_ns_kset; +extern struct kset *ldlm_svc_kset; + #define OBD_LDLM_DEVICENAME "ldlm" #define LDLM_DEFAULT_LRU_SIZE (100 * num_online_cpus()) #define LDLM_DEFAULT_MAX_ALIVE (cfs_time_seconds(36000)) -#define LDLM_CTIME_AGE_LIMIT (10) #define LDLM_DEFAULT_PARALLEL_AST_LIMIT 1024 /** @@ -232,8 +234,8 @@ struct ldlm_pool_ops { * This feature is commonly referred to as lru_resize. */ struct ldlm_pool { - /** Pool proc directory. */ - struct proc_dir_entry *pl_proc_dir; + /** Pool debugfs directory. */ + struct dentry *pl_debugfs_entry; /** Pool name, must be long enough to hold compound proc entry name. */ char pl_name[100]; /** Lock for protecting SLV/CLV updates. */ @@ -263,6 +265,10 @@ struct ldlm_pool { int pl_grant_plan; /** Pool statistics. */ struct lprocfs_stats *pl_stats; + + /* sysfs object */ + struct kobject pl_kobj; + struct completion pl_kobj_unregister; }; typedef int (*ldlm_res_policy)(struct ldlm_namespace *, struct ldlm_lock **, @@ -302,14 +308,6 @@ typedef enum { LDLM_NAMESPACE_MODEST = 1 << 1 } ldlm_appetite_t; -/** - * Default values for the "max_nolock_size", "contention_time" and - * "contended_locks" namespace tunables. - */ -#define NS_DEFAULT_MAX_NOLOCK_BYTES 0 -#define NS_DEFAULT_CONTENTION_SECONDS 2 -#define NS_DEFAULT_CONTENDED_LOCKS 32 - struct ldlm_ns_bucket { /** back pointer to namespace */ struct ldlm_namespace *nsb_namespace; @@ -390,8 +388,8 @@ struct ldlm_namespace { /** Client side original connect flags supported by server. */ __u64 ns_orig_connect_flags; - /* namespace proc dir entry */ - struct proc_dir_entry *ns_proc_dir_entry; + /* namespace debugfs dir entry */ + struct dentry *ns_debugfs_entry; /** * Position in global namespace list linking all namespaces on @@ -421,18 +419,6 @@ struct ldlm_namespace { unsigned int ns_max_unused; /** Maximum allowed age (last used time) for locks in the LRU */ unsigned int ns_max_age; - /** - * Server only: number of times we evicted clients due to lack of reply - * to ASTs. - */ - unsigned int ns_timeouts; - /** - * Number of seconds since the file change time after which the - * MDT will return an UPDATE lock along with a LOOKUP lock. - * This allows the client to start caching negative dentries - * for a directory and may save an RPC for a later stat. - */ - unsigned int ns_ctime_age_limit; /** * Used to rate-limit ldlm_namespace_dump calls. @@ -466,27 +452,6 @@ struct ldlm_namespace { /** Definition of how eagerly unused locks will be released from LRU */ ldlm_appetite_t ns_appetite; - /** - * If more than \a ns_contended_locks are found, the resource is - * considered to be contended. Lock enqueues might specify that no - * contended locks should be granted - */ - unsigned ns_contended_locks; - - /** - * The resources in this namespace remember contended state during - * \a ns_contention_time, in seconds. - */ - unsigned ns_contention_time; - - /** - * Limit size of contended extent locks, in bytes. - * If extended lock is requested for more then this many bytes and - * caller instructs us not to grant contended locks, we would disregard - * such a request. - */ - unsigned ns_max_nolock_size; - /** Limit of parallel AST RPC count. */ unsigned ns_max_parallel_ast; @@ -501,6 +466,9 @@ struct ldlm_namespace { * recalculation of LDLM pool statistics should be skipped. */ unsigned ns_stopping:1; + + struct kobject ns_kobj; /* sysfs object */ + struct completion ns_kobj_unregister; }; /** @@ -1283,13 +1251,8 @@ void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client); void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client); void ldlm_namespace_get(struct ldlm_namespace *ns); void ldlm_namespace_put(struct ldlm_namespace *ns); -#if defined (CONFIG_PROC_FS) -int ldlm_proc_setup(void); -void ldlm_proc_cleanup(void); -#else -static inline int ldlm_proc_setup(void) { return 0; } -static inline void ldlm_proc_cleanup(void) {} -#endif +int ldlm_debugfs_setup(void); +void ldlm_debugfs_cleanup(void); /* resource.c - internal */ struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns, diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h index 16dcdbfae689..d4cc09635271 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h @@ -1,17 +1,10 @@ /* -*- buffer-read-only: t -*- vi: set ro: * - * DO NOT EDIT THIS FILE (lustre_dlm_flags.h) + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. * - * It has been AutoGen-ed - * From the definitions lustre_dlm_flags.def - * and the template file lustre_dlm_flags.tpl - * - * lustre is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * lustre is distributed in the hope that it will be useful, but + * Lustre is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. @@ -22,8 +15,6 @@ /** * \file lustre_dlm_flags.h * The flags and collections of flags (masks) for \see struct ldlm_lock. - * This file is derived from flag definitions in lustre_dlm_flags.def. - * The format is defined in the lustre_dlm_flags.tpl template file. * * \addtogroup LDLM Lustre Distributed Lock Manager * @{ diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index 9c06a49f12a4..3b992b42fd91 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -106,34 +106,6 @@ struct mgs_export_data { spinlock_t med_lock; /* protect med_clients */ }; -/** - * per-NID statistics structure. - * It tracks access patterns to this export on a per-client-NID basis - */ -struct nid_stat { - lnet_nid_t nid; - struct hlist_node nid_hash; - struct list_head nid_list; - struct obd_device *nid_obd; - struct proc_dir_entry *nid_proc; - struct lprocfs_stats *nid_stats; - struct lprocfs_stats *nid_ldlm_stats; - atomic_t nid_exp_ref_count; /* for obd_nid_stats_hash - exp_nid_stats */ -}; - -#define nidstat_getref(nidstat) \ -do { \ - atomic_inc(&(nidstat)->nid_exp_ref_count); \ -} while (0) - -#define nidstat_putref(nidstat) \ -do { \ - atomic_dec(&(nidstat)->nid_exp_ref_count); \ - LASSERTF(atomic_read(&(nidstat)->nid_exp_ref_count) >= 0, \ - "stat %p nid_exp_ref_count < 0\n", nidstat); \ -} while (0) - enum obd_option { OBD_OPT_FORCE = 0x0001, OBD_OPT_FAILOVER = 0x0002, @@ -190,7 +162,6 @@ struct obd_export { * exp_lock protect its change */ struct obd_import *exp_imp_reverse; - struct nid_stat *exp_nid_stats; struct lprocfs_stats *exp_md_stats; /** Active connection */ struct ptlrpc_connection *exp_connection; diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index 0a0929fd9023..c7c8fe4cdbcc 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -346,7 +346,7 @@ struct lu_client_seq { struct lu_seq_range lcs_space; /* Seq related proc */ - struct proc_dir_entry *lcs_proc_dir; + struct dentry *lcs_debugfs_entry; /* This holds last allocated fid in last obtained seq */ struct lu_fid lcs_fid; @@ -392,9 +392,6 @@ struct lu_server_seq { /* /seq file object device */ struct dt_object *lss_obj; - /* Seq related proc */ - struct proc_dir_entry *lss_proc_dir; - /* LUSTRE_SEQ_SERVER or LUSTRE_SEQ_CONTROLLER */ enum lu_mgr_type lss_type; diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index 5ee4b1ed0995..c1f08dee3bd6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/drivers/staging/lustre/lustre/include/lustre_fld.h @@ -71,10 +71,6 @@ struct lu_fld_target { struct lu_server_fld { /** - * Fld dir proc entry. */ - struct proc_dir_entry *lsf_proc_dir; - - /** * /fld file object device */ struct dt_object *lsf_obj; @@ -99,8 +95,8 @@ struct lu_server_fld { struct lu_client_fld { /** - * Client side proc entry. */ - struct proc_dir_entry *lcf_proc_dir; + * Client side debugfs entry. */ + struct dentry *lcf_debugfs_entry; /** * List of exports client FLD knows about. */ @@ -123,10 +119,10 @@ struct lu_client_fld { struct fld_cache *lcf_cache; /** - * Client fld proc entry name. */ - char lcf_name[LUSTRE_MDT_MAXNAMELEN]; + * Client fld debugfs entry name. */ + char lcf_name[LUSTRE_MDT_MAXNAMELEN]; - int lcf_flags; + int lcf_flags; }; /* Client methods */ @@ -153,7 +149,7 @@ int fld_client_add_target(struct lu_client_fld *fld, int fld_client_del_target(struct lu_client_fld *fld, __u64 idx); -void fld_client_proc_fini(struct lu_client_fld *fld); +void fld_client_debugfs_fini(struct lu_client_fld *fld); /** @} fld */ diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index bf135630c39a..43ee9f0eb4d4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -549,19 +549,13 @@ do { \ __blocked = cfs_block_sigsinv(0); \ \ for (;;) { \ - unsigned __wstate; \ - \ - __wstate = info->lwi_on_signal != NULL && \ - (__timeout == 0 || __allow_intr) ? \ - TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE; \ - \ - set_current_state(TASK_INTERRUPTIBLE); \ - \ if (condition) \ break; \ \ + set_current_state(TASK_INTERRUPTIBLE); \ + \ if (__timeout == 0) { \ - schedule(); \ + schedule(); \ } else { \ long interval = info->lwi_interval? \ min_t(long, \ @@ -582,6 +576,8 @@ do { \ } \ } \ \ + set_current_state(TASK_RUNNING); \ + \ if (condition) \ break; \ if (cfs_signal_pending()) { \ @@ -605,7 +601,6 @@ do { \ \ cfs_restore_sigs(__blocked); \ \ - set_current_state(TASK_RUNNING); \ remove_wait_queue(&wq, &__wait); \ } while (0) diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index e2805bd1acf1..77a7de98fc8e 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -56,8 +56,8 @@ */ #include "../../include/linux/libcfs/libcfs.h" -// #include <obd.h> -#include "../../include/linux/lnet/lnet.h" +#include "../../include/linux/lnet/nidstr.h" +#include "../../include/linux/lnet/api.h" #include "lustre/lustre_idl.h" #include "lustre_ha.h" #include "lustre_sec.h" @@ -1978,8 +1978,8 @@ struct ptlrpc_service { int srv_nthrs_cpt_init; /** limit of threads number for each partition */ int srv_nthrs_cpt_limit; - /** Root of /proc dir tree for this service */ - struct proc_dir_entry *srv_procroot; + /** Root of debugfs dir tree for this service */ + struct dentry *srv_debugfs_entry; /** Pointer to statistic data for this service */ struct lprocfs_stats *srv_stats; /** # hp per lp reqs to handle */ @@ -2016,6 +2016,10 @@ struct ptlrpc_service { int srv_cpt_bits; /** CPT table this service is running over */ struct cfs_cpt_table *srv_cptable; + + /* sysfs object */ + struct kobject srv_kobj; + struct completion srv_kobj_unregister; /** * partition data for ptlrpc service */ @@ -2525,7 +2529,8 @@ void ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs); int ptlrpc_hpreq_handler(struct ptlrpc_request *req); struct ptlrpc_service *ptlrpc_register_service( struct ptlrpc_service_conf *conf, - struct proc_dir_entry *proc_entry); + struct kset *parent, + struct dentry *debugfs_entry); void ptlrpc_stop_all_threads(struct ptlrpc_service *svc); int ptlrpc_start_threads(struct ptlrpc_service *svc); @@ -2947,15 +2952,9 @@ void ptlrpcd_decref(void); * @{ */ const char *ll_opcode2str(__u32 opcode); -#if defined (CONFIG_PROC_FS) void ptlrpc_lprocfs_register_obd(struct obd_device *obd); void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd); void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes); -#else -static inline void ptlrpc_lprocfs_register_obd(struct obd_device *obd) {} -static inline void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd) {} -static inline void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes) {} -#endif /** @} */ /* ptlrpc/llog_client.c */ diff --git a/drivers/staging/lustre/lustre/include/lustre_quota.h b/drivers/staging/lustre/lustre/include/lustre_quota.h deleted file mode 100644 index 2643f28070a2..000000000000 --- a/drivers/staging/lustre/lustre/include/lustre_quota.h +++ /dev/null @@ -1,241 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA - * - * GPL HEADER END - */ -/* - * Copyright (c) 2011, 2012, Intel Corporation. - * Use is subject to license terms. - */ - -#ifndef _LUSTRE_QUOTA_H -#define _LUSTRE_QUOTA_H - -/** \defgroup quota quota - * - */ - -#include <linux/fs.h> -#include <linux/quota.h> -#include <linux/quotaops.h> - -#include "dt_object.h" -#include "lustre_fid.h" -#include "lustre_dlm.h" - -#ifndef MAX_IQ_TIME -#define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */ -#endif - -#ifndef MAX_DQ_TIME -#define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */ -#endif - -struct lquota_id_info; -struct lquota_trans; - -/* Gather all quota record type in an union that can be used to read any records - * from disk. All fields of these records must be 64-bit aligned, otherwise the - * OSD layer may swab them incorrectly. */ -union lquota_rec { - struct lquota_glb_rec lqr_glb_rec; - struct lquota_slv_rec lqr_slv_rec; - struct lquota_acct_rec lqr_acct_rec; -}; - -/* Index features supported by the global index objects - * Only used for migration purpose and should be removed once on-disk migration - * is no longer needed */ -extern struct dt_index_features dt_quota_iusr_features; -extern struct dt_index_features dt_quota_busr_features; -extern struct dt_index_features dt_quota_igrp_features; -extern struct dt_index_features dt_quota_bgrp_features; - -/* Name used in the configuration logs to identify the default metadata pool - * (composed of all the MDTs, with pool ID 0) and the default data pool (all - * the OSTs, with pool ID 0 too). */ -#define QUOTA_METAPOOL_NAME "mdt=" -#define QUOTA_DATAPOOL_NAME "ost=" - -/* - * Quota Master Target support - */ - -/* Request handlers for quota master operations. - * This is used by the MDT to pass quota/lock requests to the quota master - * target. This won't be needed any more once the QMT is a real target and - * does not rely any more on the MDT service threads and namespace. */ -struct qmt_handlers { - /* Handle quotactl request from client. */ - int (*qmth_quotactl)(const struct lu_env *, struct lu_device *, - struct obd_quotactl *); - - /* Handle dqacq/dqrel request from slave. */ - int (*qmth_dqacq)(const struct lu_env *, struct lu_device *, - struct ptlrpc_request *); - - /* LDLM intent policy associated with quota locks */ - int (*qmth_intent_policy)(const struct lu_env *, struct lu_device *, - struct ptlrpc_request *, struct ldlm_lock **, - int); - - /* Initialize LVB of ldlm resource associated with quota objects */ - int (*qmth_lvbo_init)(struct lu_device *, struct ldlm_resource *); - - /* Update LVB of ldlm resource associated with quota objects */ - int (*qmth_lvbo_update)(struct lu_device *, struct ldlm_resource *, - struct ptlrpc_request *, int); - - /* Return size of LVB to be packed in ldlm message */ - int (*qmth_lvbo_size)(struct lu_device *, struct ldlm_lock *); - - /* Fill request buffer with lvb */ - int (*qmth_lvbo_fill)(struct lu_device *, struct ldlm_lock *, void *, - int); - - /* Free lvb associated with ldlm resource */ - int (*qmth_lvbo_free)(struct lu_device *, struct ldlm_resource *); -}; - -/* actual handlers are defined in lustre/quota/qmt_handler.c */ -extern struct qmt_handlers qmt_hdls; - -/* - * Quota enforcement support on slaves - */ - -struct qsd_instance; - -/* The quota slave feature is implemented under the form of a library. - * The API is the following: - * - * - qsd_init(): the user (mostly the OSD layer) should first allocate a qsd - * instance via qsd_init(). This creates all required structures - * to manage quota enforcement for this target and performs all - * low-level initialization which does not involve any lustre - * object. qsd_init() should typically be called when the OSD - * is being set up. - * - * - qsd_prepare(): This sets up on-disk objects associated with the quota slave - * feature and initiates the quota reintegration procedure if - * needed. qsd_prepare() should typically be called when - * ->ldo_prepare is invoked. - * - * - qsd_start(): a qsd instance should be started once recovery is completed - * (i.e. when ->ldo_recovery_complete is called). This is used - * to notify the qsd layer that quota should now be enforced - * again via the qsd_op_begin/end functions. The last step of the - * reintegration procedure (namely usage reconciliation) will be - * completed during start. - * - * - qsd_fini(): is used to release a qsd_instance structure allocated with - * qsd_init(). This releases all quota slave objects and frees the - * structures associated with the qsd_instance. - * - * - qsd_op_begin(): is used to enforce quota, it must be called in the - * declaration of each operation. qsd_op_end() should then be - * invoked later once all operations have been completed in - * order to release/adjust the quota space. - * Running qsd_op_begin() before qsd_start() isn't fatal and - * will return success. - * Once qsd_start() has been run, qsd_op_begin() will block - * until the reintegration procedure is completed. - * - * - qsd_op_end(): performs the post operation quota processing. This must be - * called after the operation transaction stopped. - * While qsd_op_begin() must be invoked each time a new - * operation is declared, qsd_op_end() should be called only - * once for the whole transaction. - * - * - qsd_op_adjust(): triggers pre-acquire/release if necessary. - * - * Below are the function prototypes to be used by OSD layer to manage quota - * enforcement. Arguments are documented where each function is defined. */ - -struct qsd_instance *qsd_init(const struct lu_env *, char *, struct dt_device *, - struct proc_dir_entry *); -int qsd_prepare(const struct lu_env *, struct qsd_instance *); -int qsd_start(const struct lu_env *, struct qsd_instance *); -void qsd_fini(const struct lu_env *, struct qsd_instance *); -int qsd_op_begin(const struct lu_env *, struct qsd_instance *, - struct lquota_trans *, struct lquota_id_info *, int *); -void qsd_op_end(const struct lu_env *, struct qsd_instance *, - struct lquota_trans *); -void qsd_op_adjust(const struct lu_env *, struct qsd_instance *, - union lquota_id *, int); -/* This is exported for the ldiskfs quota migration only, - * see convert_quota_file() */ -int lquota_disk_write_glb(const struct lu_env *, struct dt_object *, - __u64, struct lquota_glb_rec *); - -/* - * Quota information attached to a transaction - */ - -struct lquota_entry; - -struct lquota_id_info { - /* quota identifier */ - union lquota_id lqi_id; - - /* USRQUOTA or GRPQUOTA for now, could be expanded for - * directory quota or other types later. */ - int lqi_type; - - /* inodes or kbytes to be consumed or released, it could - * be negative when releasing space. */ - long long lqi_space; - - /* quota slave entry structure associated with this ID */ - struct lquota_entry *lqi_qentry; - - /* whether we are reporting blocks or inodes */ - bool lqi_is_blk; -}; - -/* Since we enforce only inode quota in meta pool (MDTs), and block quota in - * data pool (OSTs), there are at most 4 quota ids being enforced in a single - * transaction, which is chown transaction: - * original uid and gid, new uid and gid. - * - * This value might need to be revised when directory quota is added. */ -#define QUOTA_MAX_TRANSIDS 4 - -/* all qids involved in a single transaction */ -struct lquota_trans { - unsigned short lqt_id_cnt; - struct lquota_id_info lqt_ids[QUOTA_MAX_TRANSIDS]; -}; - -/* flags for quota local enforcement */ -#define QUOTA_FL_OVER_USRQUOTA 0x01 -#define QUOTA_FL_OVER_GRPQUOTA 0x02 -#define QUOTA_FL_SYNC 0x04 - -#define IS_LQUOTA_RES(res) \ - (res->lr_name.name[LUSTRE_RES_ID_SEQ_OFF] == FID_SEQ_QUOTA || \ - res->lr_name.name[LUSTRE_RES_ID_SEQ_OFF] == FID_SEQ_QUOTA_GLB) - -/* helper function used by MDT & OFD to retrieve quota accounting information - * on slave */ -int lquotactl_slv(const struct lu_env *, struct dt_device *, - struct obd_quotactl *); -/** @} quota */ -#endif /* _LUSTRE_QUOTA_H */ diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h index dff70a5b9bc4..707ff69717c6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_sec.h +++ b/drivers/staging/lustre/lustre/include/lustre_sec.h @@ -1061,15 +1061,7 @@ const char *sec2target_str(struct ptlrpc_sec *sec); /* * lprocfs */ -#if defined (CONFIG_PROC_FS) -struct proc_dir_entry; -extern struct proc_dir_entry *sptlrpc_proc_root; int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev); -#else -#define sptlrpc_proc_root NULL -static inline int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev) -{ return 0; } -#endif /* * server side diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 2a88b806fca5..55452e562bd4 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -244,11 +244,12 @@ struct obd_type { struct list_head typ_chain; struct obd_ops *typ_dt_ops; struct md_ops *typ_md_ops; - struct proc_dir_entry *typ_procroot; + struct dentry *typ_debugfs_entry; char *typ_name; int typ_refcnt; struct lu_device_type *typ_lu; spinlock_t obd_type_lock; + struct kobject *typ_kobj; }; struct brw_page { @@ -544,7 +545,7 @@ struct pool_desc { struct lov_qos_rr pool_rr; /* round robin qos */ struct hlist_node pool_hash; /* access by poolname */ struct list_head pool_list; /* serial access */ - struct proc_dir_entry *pool_proc_entry; /* file in /proc */ + struct dentry *pool_debugfs_entry; /* file in /proc */ struct obd_device *pool_lobd; /* obd of the lov/lod to which * this pool belongs */ }; @@ -565,13 +566,15 @@ struct lov_obd { int lov_pool_count; 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; + struct dentry *lov_pool_debugfs_entry; enum lustre_sec_part lov_sp_me; /* Cached LRU pages from upper layer */ void *lov_cache; struct rw_semaphore lov_notify_lock; + + struct kobject *lov_tgts_kobj; }; struct lmv_tgt_desc { @@ -610,6 +613,7 @@ struct lmv_obd { struct lmv_tgt_desc **tgts; struct obd_connect_data conn_data; + struct kobject *lmv_tgts_kobj; }; struct niobuf_local { @@ -841,9 +845,6 @@ struct obd_device { struct cfs_hash *obd_uuid_hash; /* nid-export hash body */ struct cfs_hash *obd_nid_hash; - /* nid stats body */ - struct cfs_hash *obd_nid_stats_hash; - struct list_head obd_nid_stats; atomic_t obd_refcount; wait_queue_head_t obd_refcount_waitq; struct list_head obd_exports; @@ -913,10 +914,8 @@ struct obd_device { unsigned int md_cntr_base; struct lprocfs_stats *md_stats; - struct proc_dir_entry *obd_proc_entry; - void *obd_proc_private; /* type private PDEs */ - struct proc_dir_entry *obd_proc_exports_entry; - struct proc_dir_entry *obd_svc_procroot; + struct dentry *obd_debugfs_entry; + struct dentry *obd_svc_debugfs_entry; struct lprocfs_stats *obd_svc_stats; atomic_t obd_evict_inprogress; wait_queue_head_t obd_evict_inprogress_waitq; @@ -936,6 +935,9 @@ struct obd_device { struct lu_ref obd_reference; int obd_conn_inprogress; + + struct kobject obd_kobj; /* sysfs object */ + struct completion obd_kobj_unregister; }; #define OBD_LLOG_FL_SENDNOW 0x0001 diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 34b5fa3f081c..36ed78127830 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -75,8 +75,7 @@ struct lu_device_type; extern struct list_head obd_types; struct obd_export *class_conn2export(struct lustre_handle *); int class_register_type(struct obd_ops *, struct md_ops *, - struct lprocfs_vars *, const char *nm, - struct lu_device_type *ldt); + const char *nm, struct lu_device_type *ldt); int class_unregister_type(const char *nm); struct obd_device *class_newdev(const char *type_name, const char *name); @@ -140,14 +139,7 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg); int class_add_uuid(const char *uuid, __u64 nid); /*obdecho*/ -#if defined (CONFIG_PROC_FS) extern void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars); -#else -static inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -#endif #define CFG_F_START 0x01 /* Set when we start updating from a log */ #define CFG_F_MARKER 0x02 /* We are within a maker */ @@ -357,7 +349,6 @@ static inline int obd_check_dev_active(struct obd_device *obd) return rc; } -#if defined (CONFIG_PROC_FS) #define OBD_COUNTER_OFFSET(op) \ ((offsetof(struct obd_ops, o_ ## op) - \ offsetof(struct obd_ops, o_iocontrol)) \ @@ -379,10 +370,6 @@ static inline int obd_check_dev_active(struct obd_device *obd) OBD_COUNTER_OFFSET(op); \ LASSERT(coffset < (export)->exp_obd->obd_stats->ls_num); \ lprocfs_counter_incr((export)->exp_obd->obd_stats, coffset); \ - if ((export)->exp_nid_stats != NULL && \ - (export)->exp_nid_stats->nid_stats != NULL) \ - lprocfs_counter_incr( \ - (export)->exp_nid_stats->nid_stats, coffset);\ } #define MD_COUNTER_OFFSET(op) \ @@ -411,27 +398,6 @@ static inline int obd_check_dev_active(struct obd_device *obd) (export)->exp_md_stats, coffset); \ } -#else -#define OBD_COUNTER_OFFSET(op) -#define OBD_COUNTER_INCREMENT(obd, op) -#define EXP_COUNTER_INCREMENT(exp, op) -#define MD_COUNTER_INCREMENT(obd, op) -#define EXP_MD_COUNTER_INCREMENT(exp, op) -#endif - -static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat *tmp) -{ - /* Always add in ldlm_stats */ - tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC - ,LPROCFS_STATS_FLAG_NOPERCPU); - if (tmp->nid_ldlm_stats == NULL) - return -ENOMEM; - - lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats); - - return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats", - tmp->nid_ldlm_stats); -} #define OBD_CHECK_MD_OP(obd, op, err) \ do { \ diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index 2991d2ee780b..73e2d4880b9b 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -509,7 +509,6 @@ extern atomic_t libcfs_kmemory; extern void obd_update_maxusage(void); -#if defined (CONFIG_PROC_FS) #define obd_memory_add(size) \ lprocfs_counter_add(obd_memory, OBD_MEMORY_STAT, (long)(size)) #define obd_memory_sub(size) \ @@ -530,46 +529,6 @@ extern void obd_update_maxusage(void); extern __u64 obd_memory_max(void); extern __u64 obd_pages_max(void); -#else - -extern __u64 obd_alloc; -extern __u64 obd_pages; - -extern __u64 obd_max_alloc; -extern __u64 obd_max_pages; - -static inline void obd_memory_add(long size) -{ - obd_alloc += size; - if (obd_alloc > obd_max_alloc) - obd_max_alloc = obd_alloc; -} - -static inline void obd_memory_sub(long size) -{ - obd_alloc -= size; -} - -static inline void obd_pages_add(int order) -{ - obd_pages += 1<< order; - if (obd_pages > obd_max_pages) - obd_max_pages = obd_pages; -} - -static inline void obd_pages_sub(int order) -{ - obd_pages -= 1<< order; -} - -#define obd_memory_sum() (obd_alloc) -#define obd_pages_sum() (obd_pages) - -#define obd_memory_max() (obd_max_alloc) -#define obd_pages_max() (obd_max_pages) - -#endif - #define OBD_DEBUG_MEMUSAGE (1) #if OBD_DEBUG_MEMUSAGE @@ -676,37 +635,20 @@ do { \ __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size) -/* Allocations above this size are considered too big and could not be done - * atomically. - * - * Be very careful when changing this value, especially when decreasing it, - * since vmalloc in Linux doesn't perform well on multi-cores system, calling - * vmalloc in critical path would hurt performance badly. See LU-66. - */ -#define OBD_ALLOC_BIG (4 * PAGE_CACHE_SIZE) - #define OBD_ALLOC_LARGE(ptr, size) \ do { \ - if (size > OBD_ALLOC_BIG) \ - OBD_VMALLOC(ptr, size); \ - else \ - OBD_ALLOC(ptr, size); \ + ptr = libcfs_kvzalloc(size, GFP_NOFS); \ } while (0) #define OBD_CPT_ALLOC_LARGE(ptr, cptab, cpt, size) \ do { \ - if (size > OBD_ALLOC_BIG) \ - OBD_CPT_VMALLOC(ptr, cptab, cpt, size); \ - else \ - OBD_CPT_ALLOC(ptr, cptab, cpt, size); \ + ptr = libcfs_kvzalloc_cpt(cptab, cpt, size, GFP_NOFS); \ } while (0) #define OBD_FREE_LARGE(ptr, size) \ do { \ - if (size > OBD_ALLOC_BIG) \ - OBD_VFREE(ptr, size); \ - else \ - OBD_FREE(ptr, size); \ + (void)(size); \ + kvfree(ptr); \ } while (0) diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index ab6cb419302f..e0c1ccafbd63 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -202,7 +202,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env, struct cl_site *site; int rc; - OBD_ALLOC_PTR(vdv); + vdv = kzalloc(sizeof(*vdv), GFP_NOFS); if (vdv == NULL) return ERR_PTR(-ENOMEM); @@ -211,7 +211,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env, ccc2lu_dev(vdv)->ld_ops = luops; vdv->cdv_cl.cd_ops = clops; - OBD_ALLOC_PTR(site); + site = kzalloc(sizeof(*site), GFP_NOFS); if (site != NULL) { rc = cl_site_init(site, &vdv->cdv_cl); if (rc == 0) @@ -219,7 +219,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env, else { LASSERT(lud->ld_site == NULL); CERROR("Cannot init lu_site, rc %d.\n", rc); - OBD_FREE_PTR(site); + kfree(site); } } else rc = -ENOMEM; @@ -239,10 +239,10 @@ struct lu_device *ccc_device_free(const struct lu_env *env, if (d->ld_site != NULL) { cl_site_fini(site); - OBD_FREE_PTR(site); + kfree(site); } cl_device_fini(lu2cl_dev(d)); - OBD_FREE_PTR(vdv); + kfree(vdv); return next; } @@ -836,25 +836,24 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj, *exceed = 1; } return result; - } else { - /* - * region is within kms and, hence, within real file - * size (A). We need to increase i_size to cover the - * read region so that generic_file_read() will do its - * job, but that doesn't mean the kms size is - * _correct_, it is only the _minimum_ size. If - * someone does a stat they will get the correct size - * which will always be >= the kms value here. - * b=11081 - */ - if (cl_isize_read(inode) < kms) { - cl_isize_write_nolock(inode, kms); - CDEBUG(D_VFSTRACE, - DFID" updating i_size %llu\n", - PFID(lu_object_fid(&obj->co_lu)), - (__u64)cl_isize_read(inode)); + } + /* + * region is within kms and, hence, within real file + * size (A). We need to increase i_size to cover the + * read region so that generic_file_read() will do its + * job, but that doesn't mean the kms size is + * _correct_, it is only the _minimum_ size. If + * someone does a stat they will get the correct size + * which will always be >= the kms value here. + * b=11081 + */ + if (cl_isize_read(inode) < kms) { + cl_isize_write_nolock(inode, kms); + CDEBUG(D_VFSTRACE, + DFID" updating i_size %llu\n", + PFID(lu_object_fid(&obj->co_lu)), + (__u64)cl_isize_read(inode)); - } } } ccc_object_size_unlock(obj); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 70b909f55861..6601e6b12c32 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -197,8 +197,7 @@ void ldlm_destroy_flock_export(struct obd_export *exp); void l_check_ns_lock(struct ldlm_namespace *ns); void l_check_no_ns_lock(struct ldlm_namespace *ns); -extern struct proc_dir_entry *ldlm_svc_proc_dir; -extern struct proc_dir_entry *ldlm_type_proc_dir; +extern struct dentry *ldlm_svc_debugfs_dir; struct ldlm_state { struct ptlrpc_service *ldlm_cb_service; @@ -238,40 +237,85 @@ enum ldlm_policy_res { typedef enum ldlm_policy_res ldlm_policy_res_t; -#define LDLM_POOL_PROC_READER_SEQ_SHOW(var, type) \ - static int lprocfs_##var##_seq_show(struct seq_file *m, void *v) \ +#define LDLM_POOL_SYSFS_PRINT_int(v) sprintf(buf, "%d\n", v) +#define LDLM_POOL_SYSFS_SET_int(a, b) { a = b; } +#define LDLM_POOL_SYSFS_PRINT_u64(v) sprintf(buf, "%lld\n", v) +#define LDLM_POOL_SYSFS_SET_u64(a, b) { a = b; } +#define LDLM_POOL_SYSFS_PRINT_atomic(v) sprintf(buf, "%d\n", atomic_read(&v)) +#define LDLM_POOL_SYSFS_SET_atomic(a, b) atomic_set(&a, b) + +#define LDLM_POOL_SYSFS_READER_SHOW(var, type) \ + static ssize_t var##_show(struct kobject *kobj, \ + struct attribute *attr, \ + char *buf) \ { \ - struct ldlm_pool *pl = m->private; \ + struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \ + pl_kobj); \ type tmp; \ \ spin_lock(&pl->pl_lock); \ tmp = pl->pl_##var; \ spin_unlock(&pl->pl_lock); \ \ - return lprocfs_rd_uint(m, &tmp); \ + return LDLM_POOL_SYSFS_PRINT_##type(tmp); \ } \ struct __##var##__dummy_read {; } /* semicolon catcher */ -#define LDLM_POOL_PROC_WRITER(var, type) \ - static int lprocfs_wr_##var(struct file *file, \ - const char __user *buffer, \ - unsigned long count, void *data) \ +#define LDLM_POOL_SYSFS_WRITER_STORE(var, type) \ + static ssize_t var##_store(struct kobject *kobj, \ + struct attribute *attr, \ + const char *buffer, \ + size_t count) \ { \ - struct ldlm_pool *pl = data; \ - type tmp; \ + struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \ + pl_kobj); \ + unsigned long tmp; \ int rc; \ \ - rc = lprocfs_wr_uint(file, buffer, count, &tmp); \ + rc = kstrtoul(buffer, 10, &tmp); \ if (rc < 0) { \ - CERROR("Can't parse user input, rc = %d\n", rc); \ return rc; \ } \ \ spin_lock(&pl->pl_lock); \ - pl->pl_##var = tmp; \ + LDLM_POOL_SYSFS_SET_##type(pl->pl_##var, tmp); \ spin_unlock(&pl->pl_lock); \ \ - return rc; \ + return count; \ + } \ + struct __##var##__dummy_write {; } /* semicolon catcher */ + +#define LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(var, type) \ + static ssize_t var##_show(struct kobject *kobj, \ + struct attribute *attr, \ + char *buf) \ + { \ + struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \ + pl_kobj); \ + \ + return LDLM_POOL_SYSFS_PRINT_##type(pl->pl_##var); \ + } \ + struct __##var##__dummy_read {; } /* semicolon catcher */ + +#define LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(var, type) \ + static ssize_t var##_store(struct kobject *kobj, \ + struct attribute *attr, \ + const char *buffer, \ + size_t count) \ + { \ + struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \ + pl_kobj); \ + unsigned long tmp; \ + int rc; \ + \ + rc = kstrtoul(buffer, 10, &tmp); \ + if (rc < 0) { \ + return rc; \ + } \ + \ + LDLM_POOL_SYSFS_SET_##type(pl->pl_##var, tmp); \ + \ + return count; \ } \ struct __##var##__dummy_write {; } /* semicolon catcher */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index c5c86e73ca52..764f98684d74 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -73,7 +73,7 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, } if (create) { - OBD_ALLOC(imp_conn, sizeof(*imp_conn)); + imp_conn = kzalloc(sizeof(*imp_conn), GFP_NOFS); if (!imp_conn) { rc = -ENOMEM; goto out_put; @@ -119,8 +119,7 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, spin_unlock(&imp->imp_lock); return 0; out_free: - if (imp_conn) - OBD_FREE(imp_conn, sizeof(*imp_conn)); + kfree(imp_conn); out_put: ptlrpc_connection_put(ptlrpc_conn); return rc; @@ -179,7 +178,7 @@ int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid) list_del(&imp_conn->oic_item); ptlrpc_connection_put(imp_conn->oic_conn); - OBD_FREE(imp_conn, sizeof(*imp_conn)); + kfree(imp_conn); CDEBUG(D_HA, "imp %p@%s: remove connection %s\n", imp, imp->imp_obd->obd_name, uuid->uuid); rc = 0; @@ -668,10 +667,9 @@ int target_send_reply_msg(struct ptlrpc_request *req, int rc, int fail_id) DEBUG_REQ(D_NET, req, "processing error (%d)", rc); req->rq_status = rc; return ptlrpc_send_error(req, 1); - } else { - DEBUG_REQ(D_NET, req, "sending reply"); } + DEBUG_REQ(D_NET, req, "sending reply"); return ptlrpc_send_reply(req, PTLRPC_REPLY_MAYBE_DIFFICULT); } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 84b111eb48fa..bb2246d3b22b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -208,8 +208,7 @@ void ldlm_lock_put(struct ldlm_lock *lock) lock->l_export = NULL; } - if (lock->l_lvb_data != NULL) - OBD_FREE(lock->l_lvb_data, lock->l_lvb_len); + kfree(lock->l_lvb_data); ldlm_interval_free(ldlm_interval_detach(lock)); lu_ref_fini(&lock->l_reference); @@ -932,7 +931,9 @@ static void search_granted_lock(struct list_head *queue, prev->mode_link = &mode_end->l_sl_mode; prev->policy_link = &req->l_sl_policy; return; - } else if (lock->l_resource->lr_type == LDLM_IBITS) { + } + + if (lock->l_resource->lr_type == LDLM_IBITS) { for (;;) { policy_end = list_entry(lock->l_sl_policy.prev, @@ -968,11 +969,10 @@ static void search_granted_lock(struct list_head *queue, prev->mode_link = &mode_end->l_sl_mode; prev->policy_link = &req->l_sl_policy; return; - } else { - LDLM_ERROR(lock, - "is not LDLM_PLAIN or LDLM_IBITS lock"); - LBUG(); } + + LDLM_ERROR(lock, "is not LDLM_PLAIN or LDLM_IBITS lock"); + LBUG(); } /* insert point is last lock on the queue, @@ -1527,7 +1527,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, if (lvb_len) { lock->l_lvb_len = lvb_len; - OBD_ALLOC(lock->l_lvb_data, lvb_len); + lock->l_lvb_data = kzalloc(lvb_len, GFP_NOFS); if (lock->l_lvb_data == NULL) goto out; } @@ -1791,7 +1791,7 @@ int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) LDLM_LOCK_RELEASE(lock); if ((gl_work->gl_flags & LDLM_GL_WORK_NOFREE) == 0) - OBD_FREE_PTR(gl_work); + kfree(gl_work); return rc; } @@ -1812,7 +1812,7 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list, if (list_empty(rpc_list)) return 0; - OBD_ALLOC_PTR(arg); + arg = kzalloc(sizeof(*arg), GFP_NOFS); if (arg == NULL) return -ENOMEM; @@ -1857,7 +1857,7 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list, rc = atomic_read(&arg->restart) ? -ERESTART : 0; goto out; out: - OBD_FREE_PTR(arg); + kfree(arg); return rc; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 08a91f5d91b1..b7b6ca1196b7 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -58,6 +58,10 @@ MODULE_PARM_DESC(ldlm_cpts, "CPU partitions ldlm threads should run on"); static struct mutex ldlm_ref_mutex; static int ldlm_refcount; +struct kobject *ldlm_kobj; +struct kset *ldlm_ns_kset; +struct kset *ldlm_svc_kset; + struct ldlm_cb_async_args { struct ldlm_cb_set_arg *ca_set_arg; struct ldlm_lock *ca_lock; @@ -220,7 +224,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, * variable length */ void *lvb_data; - OBD_ALLOC(lvb_data, lvb_len); + lvb_data = kzalloc(lvb_len, GFP_NOFS); if (lvb_data == NULL) { LDLM_ERROR(lock, "No memory: %d.\n", lvb_len); rc = -ENOMEM; @@ -448,7 +452,7 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns, if (cancel_flags & LCF_ASYNC) { struct ldlm_bl_work_item *blwi; - OBD_ALLOC(blwi, sizeof(*blwi)); + blwi = kzalloc(sizeof(*blwi), GFP_NOFS); if (blwi == NULL) return -ENOMEM; init_blwi(blwi, ns, ld, cancels, count, lock, cancel_flags); @@ -849,7 +853,7 @@ static int ldlm_bl_thread_main(void *arg) memory_pressure_clr(); if (blwi->blwi_flags & LCF_ASYNC) - OBD_FREE(blwi, sizeof(*blwi)); + kfree(blwi); else complete(&blwi->blwi_comp); } @@ -1002,6 +1006,42 @@ void ldlm_destroy_export(struct obd_export *exp) } EXPORT_SYMBOL(ldlm_destroy_export); +extern unsigned int ldlm_cancel_unused_locks_before_replay; + +static ssize_t cancel_unused_locks_before_replay_show(struct kobject *kobj, + struct attribute *attr, + char *buf) +{ + return sprintf(buf, "%d\n", ldlm_cancel_unused_locks_before_replay); +} +static ssize_t cancel_unused_locks_before_replay_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) +{ + int rc; + unsigned long val; + + rc = kstrtoul(buffer, 10, &val); + if (rc) + return rc; + + ldlm_cancel_unused_locks_before_replay = val; + + return count; +} +LUSTRE_RW_ATTR(cancel_unused_locks_before_replay); + +/* These are for root of /sys/fs/lustre/ldlm */ +static struct attribute *ldlm_attrs[] = { + &lustre_attr_cancel_unused_locks_before_replay.attr, + NULL, +}; + +static struct attribute_group ldlm_attr_group = { + .attrs = ldlm_attrs, +}; + static int ldlm_setup(void) { static struct ptlrpc_service_conf conf; @@ -1012,11 +1052,33 @@ static int ldlm_setup(void) if (ldlm_state != NULL) return -EALREADY; - OBD_ALLOC(ldlm_state, sizeof(*ldlm_state)); + ldlm_state = kzalloc(sizeof(*ldlm_state), GFP_NOFS); if (ldlm_state == NULL) return -ENOMEM; - rc = ldlm_proc_setup(); + ldlm_kobj = kobject_create_and_add("ldlm", lustre_kobj); + if (!ldlm_kobj) { + rc = -ENOMEM; + goto out; + } + + rc = sysfs_create_group(ldlm_kobj, &ldlm_attr_group); + if (rc) + goto out; + + ldlm_ns_kset = kset_create_and_add("namespaces", NULL, ldlm_kobj); + if (!ldlm_ns_kset) { + rc = -ENOMEM; + goto out; + } + + ldlm_svc_kset = kset_create_and_add("services", NULL, ldlm_kobj); + if (!ldlm_svc_kset) { + rc = -ENOMEM; + goto out; + } + + rc = ldlm_debugfs_setup(); if (rc != 0) goto out; @@ -1050,7 +1112,8 @@ static int ldlm_setup(void) }, }; ldlm_state->ldlm_cb_service = - ptlrpc_register_service(&conf, ldlm_svc_proc_dir); + ptlrpc_register_service(&conf, ldlm_svc_kset, + ldlm_svc_debugfs_dir); if (IS_ERR(ldlm_state->ldlm_cb_service)) { CERROR("failed to start service\n"); rc = PTR_ERR(ldlm_state->ldlm_cb_service); @@ -1059,7 +1122,7 @@ static int ldlm_setup(void) } - OBD_ALLOC(blp, sizeof(*blp)); + blp = kzalloc(sizeof(*blp), GFP_NOFS); if (blp == NULL) { rc = -ENOMEM; goto out; @@ -1088,7 +1151,6 @@ static int ldlm_setup(void) goto out; } - rc = ldlm_pools_init(); if (rc) { CERROR("Failed to initialize LDLM pools: %d\n", rc); @@ -1129,16 +1191,22 @@ static int ldlm_cleanup(void) wait_for_completion(&blp->blp_comp); } - OBD_FREE(blp, sizeof(*blp)); + kfree(blp); } if (ldlm_state->ldlm_cb_service != NULL) ptlrpc_unregister_service(ldlm_state->ldlm_cb_service); - ldlm_proc_cleanup(); + if (ldlm_ns_kset) + kset_unregister(ldlm_ns_kset); + if (ldlm_svc_kset) + kset_unregister(ldlm_svc_kset); + if (ldlm_kobj) + kobject_put(ldlm_kobj); + ldlm_debugfs_cleanup(); - OBD_FREE(ldlm_state, sizeof(*ldlm_state)); + kfree(ldlm_state); ldlm_state = NULL; return 0; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index a9f4833e03e5..1605b9c69271 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -90,10 +90,10 @@ * pl_server_lock_volume - Current server lock volume (calculated); * * As it may be seen from list above, we have few possible tunables which may - * affect behavior much. They all may be modified via proc. However, they also + * affect behavior much. They all may be modified via sysfs. However, they also * give a possibility for constructing few pre-defined behavior policies. If * none of predefines is suitable for a working pattern being used, new one may - * be "constructed" via proc tunables. + * be "constructed" via sysfs tunables. */ #define DEBUG_SUBSYSTEM S_LDLM @@ -654,7 +654,6 @@ int ldlm_pool_setup(struct ldlm_pool *pl, int limit) } EXPORT_SYMBOL(ldlm_pool_setup); -#if defined(CONFIG_PROC_FS) static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused) { int granted, grant_rate, cancel_rate, grant_step; @@ -696,9 +695,12 @@ static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused) } LPROC_SEQ_FOPS_RO(lprocfs_pool_state); -static int lprocfs_grant_speed_seq_show(struct seq_file *m, void *unused) +static ssize_t grant_speed_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ldlm_pool *pl = m->private; + struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, + pl_kobj); + int grant_speed; spin_lock(&pl->pl_lock); @@ -706,63 +708,109 @@ static int lprocfs_grant_speed_seq_show(struct seq_file *m, void *unused) grant_speed = atomic_read(&pl->pl_grant_rate) - atomic_read(&pl->pl_cancel_rate); spin_unlock(&pl->pl_lock); - return lprocfs_rd_uint(m, &grant_speed); + return sprintf(buf, "%d\n", grant_speed); } +LUSTRE_RO_ATTR(grant_speed); -LDLM_POOL_PROC_READER_SEQ_SHOW(grant_plan, int); -LPROC_SEQ_FOPS_RO(lprocfs_grant_plan); +LDLM_POOL_SYSFS_READER_SHOW(grant_plan, int); +LUSTRE_RO_ATTR(grant_plan); -LDLM_POOL_PROC_READER_SEQ_SHOW(recalc_period, int); -LDLM_POOL_PROC_WRITER(recalc_period, int); -static ssize_t lprocfs_recalc_period_seq_write(struct file *file, - const char __user *buf, - size_t len, loff_t *off) -{ - struct seq_file *seq = file->private_data; +LDLM_POOL_SYSFS_READER_SHOW(recalc_period, int); +LDLM_POOL_SYSFS_WRITER_STORE(recalc_period, int); +LUSTRE_RW_ATTR(recalc_period); - return lprocfs_wr_recalc_period(file, buf, len, seq->private); -} -LPROC_SEQ_FOPS(lprocfs_recalc_period); +LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(server_lock_volume, u64); +LUSTRE_RO_ATTR(server_lock_volume); -LPROC_SEQ_FOPS_RO_TYPE(ldlm_pool, u64); -LPROC_SEQ_FOPS_RO_TYPE(ldlm_pool, atomic); -LPROC_SEQ_FOPS_RW_TYPE(ldlm_pool_rw, atomic); +LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(limit, atomic); +LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(limit, atomic); +LUSTRE_RW_ATTR(limit); -LPROC_SEQ_FOPS_RO(lprocfs_grant_speed); +LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(granted, atomic); +LUSTRE_RO_ATTR(granted); + +LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(cancel_rate, atomic); +LUSTRE_RO_ATTR(cancel_rate); + +LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(grant_rate, atomic); +LUSTRE_RO_ATTR(grant_rate); + +LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(lock_volume_factor, atomic); +LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(lock_volume_factor, atomic); +LUSTRE_RW_ATTR(lock_volume_factor); #define LDLM_POOL_ADD_VAR(name, var, ops) \ do { \ snprintf(var_name, MAX_STRING_SIZE, #name); \ pool_vars[0].data = var; \ pool_vars[0].fops = ops; \ - lprocfs_add_vars(pl->pl_proc_dir, pool_vars, NULL);\ + ldebugfs_add_vars(pl->pl_debugfs_entry, pool_vars, NULL);\ } while (0) -static int ldlm_pool_proc_init(struct ldlm_pool *pl) +/* These are for pools in /sys/fs/lustre/ldlm/namespaces/.../pool */ +static struct attribute *ldlm_pl_attrs[] = { + &lustre_attr_grant_speed.attr, + &lustre_attr_grant_plan.attr, + &lustre_attr_recalc_period.attr, + &lustre_attr_server_lock_volume.attr, + &lustre_attr_limit.attr, + &lustre_attr_granted.attr, + &lustre_attr_cancel_rate.attr, + &lustre_attr_grant_rate.attr, + &lustre_attr_lock_volume_factor.attr, + NULL, +}; + +static void ldlm_pl_release(struct kobject *kobj) +{ + struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, + pl_kobj); + complete(&pl->pl_kobj_unregister); +} + +static struct kobj_type ldlm_pl_ktype = { + .default_attrs = ldlm_pl_attrs, + .sysfs_ops = &lustre_sysfs_ops, + .release = ldlm_pl_release, +}; + +static int ldlm_pool_sysfs_init(struct ldlm_pool *pl) +{ + struct ldlm_namespace *ns = ldlm_pl2ns(pl); + int err; + + init_completion(&pl->pl_kobj_unregister); + err = kobject_init_and_add(&pl->pl_kobj, &ldlm_pl_ktype, &ns->ns_kobj, + "pool"); + + return err; +} + +static int ldlm_pool_debugfs_init(struct ldlm_pool *pl) { struct ldlm_namespace *ns = ldlm_pl2ns(pl); - struct proc_dir_entry *parent_ns_proc; + struct dentry *debugfs_ns_parent; struct lprocfs_vars pool_vars[2]; char *var_name = NULL; int rc = 0; - OBD_ALLOC(var_name, MAX_STRING_SIZE + 1); + var_name = kzalloc(MAX_STRING_SIZE + 1, GFP_NOFS); if (!var_name) return -ENOMEM; - parent_ns_proc = ns->ns_proc_dir_entry; - if (parent_ns_proc == NULL) { - CERROR("%s: proc entry is not initialized\n", + debugfs_ns_parent = ns->ns_debugfs_entry; + if (IS_ERR_OR_NULL(debugfs_ns_parent)) { + CERROR("%s: debugfs entry is not initialized\n", ldlm_ns_name(ns)); rc = -EINVAL; goto out_free_name; } - pl->pl_proc_dir = lprocfs_register("pool", parent_ns_proc, - NULL, NULL); - if (IS_ERR(pl->pl_proc_dir)) { - CERROR("LProcFS failed in ldlm-pool-init\n"); - rc = PTR_ERR(pl->pl_proc_dir); - pl->pl_proc_dir = NULL; + pl->pl_debugfs_entry = ldebugfs_register("pool", debugfs_ns_parent, + NULL, NULL); + if (IS_ERR(pl->pl_debugfs_entry)) { + CERROR("LdebugFS failed in ldlm-pool-init\n"); + rc = PTR_ERR(pl->pl_debugfs_entry); + pl->pl_debugfs_entry = NULL; goto out_free_name; } @@ -770,20 +818,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) memset(pool_vars, 0, sizeof(pool_vars)); pool_vars[0].name = var_name; - LDLM_POOL_ADD_VAR("server_lock_volume", &pl->pl_server_lock_volume, - &ldlm_pool_u64_fops); - LDLM_POOL_ADD_VAR("limit", &pl->pl_limit, &ldlm_pool_rw_atomic_fops); - LDLM_POOL_ADD_VAR("granted", &pl->pl_granted, &ldlm_pool_atomic_fops); - LDLM_POOL_ADD_VAR("grant_speed", pl, &lprocfs_grant_speed_fops); - LDLM_POOL_ADD_VAR("cancel_rate", &pl->pl_cancel_rate, - &ldlm_pool_atomic_fops); - LDLM_POOL_ADD_VAR("grant_rate", &pl->pl_grant_rate, - &ldlm_pool_atomic_fops); - LDLM_POOL_ADD_VAR("grant_plan", pl, &lprocfs_grant_plan_fops); - LDLM_POOL_ADD_VAR("recalc_period", pl, &lprocfs_recalc_period_fops); - LDLM_POOL_ADD_VAR("lock_volume_factor", &pl->pl_lock_volume_factor, - &ldlm_pool_rw_atomic_fops); - LDLM_POOL_ADD_VAR("state", pl, &lprocfs_pool_state_fops); + LDLM_POOL_ADD_VAR(state, pl, &lprocfs_pool_state_fops); pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT - LDLM_POOL_FIRST_STAT, 0); @@ -825,32 +860,31 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) lprocfs_counter_init(pl->pl_stats, LDLM_POOL_TIMING_STAT, LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV, "recalc_timing", "sec"); - rc = lprocfs_register_stats(pl->pl_proc_dir, "stats", pl->pl_stats); + rc = ldebugfs_register_stats(pl->pl_debugfs_entry, "stats", + pl->pl_stats); out_free_name: - OBD_FREE(var_name, MAX_STRING_SIZE + 1); + kfree(var_name); return rc; } -static void ldlm_pool_proc_fini(struct ldlm_pool *pl) +static void ldlm_pool_sysfs_fini(struct ldlm_pool *pl) +{ + kobject_put(&pl->pl_kobj); + wait_for_completion(&pl->pl_kobj_unregister); +} + +static void ldlm_pool_debugfs_fini(struct ldlm_pool *pl) { if (pl->pl_stats != NULL) { lprocfs_free_stats(&pl->pl_stats); pl->pl_stats = NULL; } - if (pl->pl_proc_dir != NULL) { - lprocfs_remove(&pl->pl_proc_dir); - pl->pl_proc_dir = NULL; + if (pl->pl_debugfs_entry != NULL) { + ldebugfs_remove(&pl->pl_debugfs_entry); + pl->pl_debugfs_entry = NULL; } } -#else /* !CONFIG_PROC_FS */ -static int ldlm_pool_proc_init(struct ldlm_pool *pl) -{ - return 0; -} - -static void ldlm_pool_proc_fini(struct ldlm_pool *pl) {} -#endif /* CONFIG_PROC_FS */ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, int idx, ldlm_side_t client) @@ -881,7 +915,11 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, pl->pl_recalc_period = LDLM_POOL_CLI_DEF_RECALC_PERIOD; } pl->pl_client_lock_volume = 0; - rc = ldlm_pool_proc_init(pl); + rc = ldlm_pool_debugfs_init(pl); + if (rc) + return rc; + + rc = ldlm_pool_sysfs_init(pl); if (rc) return rc; @@ -893,7 +931,8 @@ EXPORT_SYMBOL(ldlm_pool_init); void ldlm_pool_fini(struct ldlm_pool *pl) { - ldlm_pool_proc_fini(pl); + ldlm_pool_sysfs_fini(pl); + ldlm_pool_debugfs_fini(pl); /* * Pool should not be used after this point. We can't free it here as @@ -1362,8 +1401,7 @@ static int ldlm_pools_thread_main(void *arg) if (thread_test_and_clear_flags(thread, SVC_STOPPING)) break; - else - thread_test_and_clear_flags(thread, SVC_EVENT); + thread_test_and_clear_flags(thread, SVC_EVENT); } thread_set_flags(thread, SVC_STOPPED); @@ -1383,7 +1421,7 @@ static int ldlm_pools_thread_start(void) if (ldlm_pools_thread != NULL) return -EALREADY; - OBD_ALLOC_PTR(ldlm_pools_thread); + ldlm_pools_thread = kzalloc(sizeof(*ldlm_pools_thread), GFP_NOFS); if (ldlm_pools_thread == NULL) return -ENOMEM; @@ -1394,7 +1432,7 @@ static int ldlm_pools_thread_start(void) "ldlm_poold"); if (IS_ERR(task)) { CERROR("Can't start pool thread, error %ld\n", PTR_ERR(task)); - OBD_FREE(ldlm_pools_thread, sizeof(*ldlm_pools_thread)); + kfree(ldlm_pools_thread); ldlm_pools_thread = NULL; return PTR_ERR(task); } @@ -1417,7 +1455,7 @@ static void ldlm_pools_thread_stop(void) * in pools thread. */ wait_for_completion(&ldlm_pools_comp); - OBD_FREE_PTR(ldlm_pools_thread); + kfree(ldlm_pools_thread); ldlm_pools_thread = NULL; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 4f713183145b..6245a2c36a0f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -1462,7 +1462,7 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns, lock->l_last_used)); lv = lvf * la * unused; - /* Inform pool about current CLV to see it via proc. */ + /* Inform pool about current CLV to see it via debugfs. */ ldlm_pool_set_clv(pl, lv); /* Stop when SLV is not yet come from server or lv is smaller than @@ -1472,7 +1472,7 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns, } /** - * Callback function for proc used policy. Makes decision whether to keep + * Callback function for debugfs used policy. Makes decision whether to keep * \a lock in LRU for current \a LRU size \a unused, added in current scan \a * added and number of locks to be preferably canceled \a count. * diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index f750d42a7ad5..cdb63665a113 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -61,19 +61,17 @@ LIST_HEAD(ldlm_cli_active_namespace_list); /* Client namespaces that don't have any locks in them */ LIST_HEAD(ldlm_cli_inactive_namespace_list); -struct proc_dir_entry *ldlm_type_proc_dir = NULL; -static struct proc_dir_entry *ldlm_ns_proc_dir = NULL; -struct proc_dir_entry *ldlm_svc_proc_dir = NULL; - -extern unsigned int ldlm_cancel_unused_locks_before_replay; +static struct dentry *ldlm_debugfs_dir; +static struct dentry *ldlm_ns_debugfs_dir; +struct dentry *ldlm_svc_debugfs_dir; /* during debug dump certain amount of granted locks for one resource to avoid * DDOS. */ unsigned int ldlm_dump_granted_max = 256; -#if defined(CONFIG_PROC_FS) -static ssize_t lprocfs_wr_dump_ns(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +static ssize_t +lprocfs_wr_dump_ns(struct file *file, const char __user *buffer, + size_t count, loff_t *off) { ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE); ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE); @@ -82,81 +80,82 @@ static ssize_t lprocfs_wr_dump_ns(struct file *file, const char __user *buffer, LPROC_SEQ_FOPS_WR_ONLY(ldlm, dump_ns); LPROC_SEQ_FOPS_RW_TYPE(ldlm_rw, uint); -LPROC_SEQ_FOPS_RO_TYPE(ldlm, uint); -int ldlm_proc_setup(void) +static struct lprocfs_vars ldlm_debugfs_list[] = { + { "dump_namespaces", &ldlm_dump_ns_fops, NULL, 0222 }, + { "dump_granted_max", &ldlm_rw_uint_fops, &ldlm_dump_granted_max }, + { NULL } +}; + +int ldlm_debugfs_setup(void) { int rc; - struct lprocfs_vars list[] = { - { "dump_namespaces", &ldlm_dump_ns_fops, NULL, 0222 }, - { "dump_granted_max", &ldlm_rw_uint_fops, - &ldlm_dump_granted_max }, - { "cancel_unused_locks_before_replay", &ldlm_rw_uint_fops, - &ldlm_cancel_unused_locks_before_replay }, - { NULL } }; - LASSERT(ldlm_ns_proc_dir == NULL); - - ldlm_type_proc_dir = lprocfs_register(OBD_LDLM_DEVICENAME, - proc_lustre_root, - NULL, NULL); - if (IS_ERR(ldlm_type_proc_dir)) { + + ldlm_debugfs_dir = ldebugfs_register(OBD_LDLM_DEVICENAME, + debugfs_lustre_root, + NULL, NULL); + if (IS_ERR_OR_NULL(ldlm_debugfs_dir)) { CERROR("LProcFS failed in ldlm-init\n"); - rc = PTR_ERR(ldlm_type_proc_dir); + rc = ldlm_debugfs_dir ? PTR_ERR(ldlm_debugfs_dir) : -ENOMEM; goto err; } - ldlm_ns_proc_dir = lprocfs_register("namespaces", - ldlm_type_proc_dir, - NULL, NULL); - if (IS_ERR(ldlm_ns_proc_dir)) { + ldlm_ns_debugfs_dir = ldebugfs_register("namespaces", + ldlm_debugfs_dir, + NULL, NULL); + if (IS_ERR_OR_NULL(ldlm_ns_debugfs_dir)) { CERROR("LProcFS failed in ldlm-init\n"); - rc = PTR_ERR(ldlm_ns_proc_dir); + rc = ldlm_ns_debugfs_dir ? PTR_ERR(ldlm_ns_debugfs_dir) + : -ENOMEM; goto err_type; } - ldlm_svc_proc_dir = lprocfs_register("services", - ldlm_type_proc_dir, - NULL, NULL); - if (IS_ERR(ldlm_svc_proc_dir)) { + ldlm_svc_debugfs_dir = ldebugfs_register("services", + ldlm_debugfs_dir, + NULL, NULL); + if (IS_ERR_OR_NULL(ldlm_svc_debugfs_dir)) { CERROR("LProcFS failed in ldlm-init\n"); - rc = PTR_ERR(ldlm_svc_proc_dir); + rc = ldlm_svc_debugfs_dir ? PTR_ERR(ldlm_svc_debugfs_dir) + : -ENOMEM; goto err_ns; } - rc = lprocfs_add_vars(ldlm_type_proc_dir, list, NULL); + rc = ldebugfs_add_vars(ldlm_debugfs_dir, ldlm_debugfs_list, NULL); return 0; err_ns: - lprocfs_remove(&ldlm_ns_proc_dir); + ldebugfs_remove(&ldlm_ns_debugfs_dir); err_type: - lprocfs_remove(&ldlm_type_proc_dir); + ldebugfs_remove(&ldlm_debugfs_dir); err: - ldlm_svc_proc_dir = NULL; - ldlm_type_proc_dir = NULL; - ldlm_ns_proc_dir = NULL; + ldlm_svc_debugfs_dir = NULL; + ldlm_ns_debugfs_dir = NULL; + ldlm_debugfs_dir = NULL; return rc; } -void ldlm_proc_cleanup(void) +void ldlm_debugfs_cleanup(void) { - if (ldlm_svc_proc_dir) - lprocfs_remove(&ldlm_svc_proc_dir); + if (!IS_ERR_OR_NULL(ldlm_svc_debugfs_dir)) + ldebugfs_remove(&ldlm_svc_debugfs_dir); - if (ldlm_ns_proc_dir) - lprocfs_remove(&ldlm_ns_proc_dir); + if (!IS_ERR_OR_NULL(ldlm_ns_debugfs_dir)) + ldebugfs_remove(&ldlm_ns_debugfs_dir); - if (ldlm_type_proc_dir) - lprocfs_remove(&ldlm_type_proc_dir); + if (!IS_ERR_OR_NULL(ldlm_debugfs_dir)) + ldebugfs_remove(&ldlm_debugfs_dir); - ldlm_svc_proc_dir = NULL; - ldlm_type_proc_dir = NULL; - ldlm_ns_proc_dir = NULL; + ldlm_svc_debugfs_dir = NULL; + ldlm_ns_debugfs_dir = NULL; + ldlm_debugfs_dir = NULL; } -static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v) +static ssize_t resource_count_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ldlm_namespace *ns = m->private; + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); __u64 res = 0; struct cfs_hash_bd bd; int i; @@ -164,46 +163,56 @@ static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v) /* result is not strictly consistent */ cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, i) res += cfs_hash_bd_count_get(&bd); - return lprocfs_rd_u64(m, &res); + return sprintf(buf, "%lld\n", res); } -LPROC_SEQ_FOPS_RO(lprocfs_ns_resources); +LUSTRE_RO_ATTR(resource_count); -static int lprocfs_ns_locks_seq_show(struct seq_file *m, void *v) +static ssize_t lock_count_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ldlm_namespace *ns = m->private; + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); __u64 locks; locks = lprocfs_stats_collector(ns->ns_stats, LDLM_NSS_LOCKS, LPROCFS_FIELDS_FLAGS_SUM); - return lprocfs_rd_u64(m, &locks); + return sprintf(buf, "%lld\n", locks); +} +LUSTRE_RO_ATTR(lock_count); + +static ssize_t lock_unused_count_show(struct kobject *kobj, + struct attribute *attr, + char *buf) +{ + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); + + return sprintf(buf, "%d\n", ns->ns_nr_unused); } -LPROC_SEQ_FOPS_RO(lprocfs_ns_locks); +LUSTRE_RO_ATTR(lock_unused_count); -static int lprocfs_lru_size_seq_show(struct seq_file *m, void *v) +static ssize_t lru_size_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ldlm_namespace *ns = m->private; + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); __u32 *nr = &ns->ns_max_unused; if (ns_connect_lru_resize(ns)) nr = &ns->ns_nr_unused; - return lprocfs_rd_uint(m, nr); + return sprintf(buf, "%u", *nr); } -static ssize_t lprocfs_lru_size_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t lru_size_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private; - char dummy[MAX_STRING_SIZE + 1]; + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); unsigned long tmp; int lru_resize; int err; - dummy[MAX_STRING_SIZE] = '\0'; - if (copy_from_user(dummy, buffer, MAX_STRING_SIZE)) - return -EFAULT; - - if (strncmp(dummy, "clear", 5) == 0) { + if (strncmp(buffer, "clear", 5) == 0) { CDEBUG(D_DLMTRACE, "dropping all unused locks from namespace %s\n", ldlm_ns_name(ns)); @@ -229,9 +238,9 @@ static ssize_t lprocfs_lru_size_seq_write(struct file *file, return count; } - err = kstrtoul(dummy, 10, &tmp); + err = kstrtoul(buffer, 10, &tmp); if (err != 0) { - CERROR("invalid value written\n"); + CERROR("lru_size: invalid value written\n"); return -EINVAL; } lru_resize = (tmp == 0); @@ -277,25 +286,56 @@ static ssize_t lprocfs_lru_size_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(lprocfs_lru_size); +LUSTRE_RW_ATTR(lru_size); -static int lprocfs_elc_seq_show(struct seq_file *m, void *v) +static ssize_t lru_max_age_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ldlm_namespace *ns = m->private; - unsigned int supp = ns_connect_cancelset(ns); + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); - return lprocfs_rd_uint(m, &supp); + return sprintf(buf, "%u", ns->ns_max_age); } -static ssize_t lprocfs_elc_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t lru_max_age_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private; - unsigned int supp = -1; + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); + unsigned long tmp; + int err; + + err = kstrtoul(buffer, 10, &tmp); + if (err != 0) + return -EINVAL; + + ns->ns_max_age = tmp; + + return count; +} +LUSTRE_RW_ATTR(lru_max_age); + +static ssize_t early_lock_cancel_show(struct kobject *kobj, + struct attribute *attr, + char *buf) +{ + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); + + return sprintf(buf, "%d\n", ns_connect_cancelset(ns)); +} + +static ssize_t early_lock_cancel_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) +{ + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); + unsigned long supp = -1; int rc; - rc = lprocfs_wr_uint(file, buffer, count, &supp); + rc = kstrtoul(buffer, 10, &supp); if (rc < 0) return rc; @@ -305,91 +345,88 @@ static ssize_t lprocfs_elc_seq_write(struct file *file, ns->ns_connect_flags |= OBD_CONNECT_CANCELSET; return count; } -LPROC_SEQ_FOPS(lprocfs_elc); +LUSTRE_RW_ATTR(early_lock_cancel); + +/* These are for namespaces in /sys/fs/lustre/ldlm/namespaces/ */ +static struct attribute *ldlm_ns_attrs[] = { + &lustre_attr_resource_count.attr, + &lustre_attr_lock_count.attr, + &lustre_attr_lock_unused_count.attr, + &lustre_attr_lru_size.attr, + &lustre_attr_lru_max_age.attr, + &lustre_attr_early_lock_cancel.attr, + NULL, +}; + +static void ldlm_ns_release(struct kobject *kobj) +{ + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); + complete(&ns->ns_kobj_unregister); +} -void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns) +static struct kobj_type ldlm_ns_ktype = { + .default_attrs = ldlm_ns_attrs, + .sysfs_ops = &lustre_sysfs_ops, + .release = ldlm_ns_release, +}; + +static void ldlm_namespace_debugfs_unregister(struct ldlm_namespace *ns) { - if (ns->ns_proc_dir_entry == NULL) + if (IS_ERR_OR_NULL(ns->ns_debugfs_entry)) CERROR("dlm namespace %s has no procfs dir?\n", ldlm_ns_name(ns)); else - lprocfs_remove(&ns->ns_proc_dir_entry); + ldebugfs_remove(&ns->ns_debugfs_entry); if (ns->ns_stats != NULL) lprocfs_free_stats(&ns->ns_stats); } -#define LDLM_NS_ADD_VAR(name, var, ops) \ - do { \ - snprintf(lock_name, MAX_STRING_SIZE, name); \ - lock_vars[0].data = var; \ - lock_vars[0].fops = ops; \ - lprocfs_add_vars(ns_pde, lock_vars, NULL); \ - } while (0) - -int ldlm_namespace_proc_register(struct ldlm_namespace *ns) +void ldlm_namespace_sysfs_unregister(struct ldlm_namespace *ns) { - struct lprocfs_vars lock_vars[2]; - char lock_name[MAX_STRING_SIZE + 1]; - struct proc_dir_entry *ns_pde; + kobject_put(&ns->ns_kobj); + wait_for_completion(&ns->ns_kobj_unregister); +} - LASSERT(ns != NULL); - LASSERT(ns->ns_rs_hash != NULL); +int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns) +{ + int err; - if (ns->ns_proc_dir_entry != NULL) { - ns_pde = ns->ns_proc_dir_entry; - } else { - ns_pde = proc_mkdir(ldlm_ns_name(ns), ldlm_ns_proc_dir); - if (ns_pde == NULL) - return -ENOMEM; - ns->ns_proc_dir_entry = ns_pde; - } + ns->ns_kobj.kset = ldlm_ns_kset; + init_completion(&ns->ns_kobj_unregister); + err = kobject_init_and_add(&ns->ns_kobj, &ldlm_ns_ktype, NULL, + "%s", ldlm_ns_name(ns)); ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0); - if (ns->ns_stats == NULL) + if (ns->ns_stats == NULL) { + kobject_put(&ns->ns_kobj); return -ENOMEM; + } lprocfs_counter_init(ns->ns_stats, LDLM_NSS_LOCKS, LPROCFS_CNTR_AVGMINMAX, "locks", "locks"); - lock_name[MAX_STRING_SIZE] = '\0'; - - memset(lock_vars, 0, sizeof(lock_vars)); - lock_vars[0].name = lock_name; + return err; +} - LDLM_NS_ADD_VAR("resource_count", ns, &lprocfs_ns_resources_fops); - LDLM_NS_ADD_VAR("lock_count", ns, &lprocfs_ns_locks_fops); +static int ldlm_namespace_debugfs_register(struct ldlm_namespace *ns) +{ + struct dentry *ns_entry; - if (ns_is_client(ns)) { - LDLM_NS_ADD_VAR("lock_unused_count", &ns->ns_nr_unused, - &ldlm_uint_fops); - LDLM_NS_ADD_VAR("lru_size", ns, &lprocfs_lru_size_fops); - LDLM_NS_ADD_VAR("lru_max_age", &ns->ns_max_age, - &ldlm_rw_uint_fops); - LDLM_NS_ADD_VAR("early_lock_cancel", ns, &lprocfs_elc_fops); + if (!IS_ERR_OR_NULL(ns->ns_debugfs_entry)) { + ns_entry = ns->ns_debugfs_entry; } else { - LDLM_NS_ADD_VAR("ctime_age_limit", &ns->ns_ctime_age_limit, - &ldlm_rw_uint_fops); - LDLM_NS_ADD_VAR("lock_timeouts", &ns->ns_timeouts, - &ldlm_uint_fops); - LDLM_NS_ADD_VAR("max_nolock_bytes", &ns->ns_max_nolock_size, - &ldlm_rw_uint_fops); - LDLM_NS_ADD_VAR("contention_seconds", &ns->ns_contention_time, - &ldlm_rw_uint_fops); - LDLM_NS_ADD_VAR("contended_locks", &ns->ns_contended_locks, - &ldlm_rw_uint_fops); - LDLM_NS_ADD_VAR("max_parallel_ast", &ns->ns_max_parallel_ast, - &ldlm_rw_uint_fops); + ns_entry = debugfs_create_dir(ldlm_ns_name(ns), + ldlm_ns_debugfs_dir); + if (ns_entry == NULL) + return -ENOMEM; + ns->ns_debugfs_entry = ns_entry; } + return 0; } #undef MAX_STRING_SIZE -#else /* CONFIG_PROC_FS */ - -#define ldlm_namespace_proc_unregister(ns) ({; }) -#define ldlm_namespace_proc_register(ns) ({0; }) - -#endif /* CONFIG_PROC_FS */ static unsigned ldlm_res_hop_hash(struct cfs_hash *hs, const void *key, unsigned mask) @@ -590,7 +627,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, break; } - OBD_ALLOC_PTR(ns); + ns = kzalloc(sizeof(*ns), GFP_NOFS); if (!ns) goto out_ref; @@ -623,25 +660,26 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, atomic_set(&ns->ns_bref, 0); init_waitqueue_head(&ns->ns_waitq); - ns->ns_max_nolock_size = NS_DEFAULT_MAX_NOLOCK_BYTES; - ns->ns_contention_time = NS_DEFAULT_CONTENTION_SECONDS; - ns->ns_contended_locks = NS_DEFAULT_CONTENDED_LOCKS; - ns->ns_max_parallel_ast = LDLM_DEFAULT_PARALLEL_AST_LIMIT; ns->ns_nr_unused = 0; ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE; ns->ns_max_age = LDLM_DEFAULT_MAX_ALIVE; - ns->ns_ctime_age_limit = LDLM_CTIME_AGE_LIMIT; - ns->ns_timeouts = 0; ns->ns_orig_connect_flags = 0; ns->ns_connect_flags = 0; ns->ns_stopping = 0; - rc = ldlm_namespace_proc_register(ns); + + rc = ldlm_namespace_sysfs_register(ns); if (rc != 0) { - CERROR("Can't initialize ns proc, rc %d\n", rc); + CERROR("Can't initialize ns sysfs, rc %d\n", rc); goto out_hash; } + rc = ldlm_namespace_debugfs_register(ns); + if (rc != 0) { + CERROR("Can't initialize ns proc, rc %d\n", rc); + goto out_sysfs; + } + idx = ldlm_namespace_nr_read(client); rc = ldlm_pool_init(&ns->ns_pool, ns, idx, client); if (rc) { @@ -652,12 +690,14 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, ldlm_namespace_register(ns, client); return ns; out_proc: - ldlm_namespace_proc_unregister(ns); + ldlm_namespace_debugfs_unregister(ns); +out_sysfs: + ldlm_namespace_sysfs_unregister(ns); ldlm_namespace_cleanup(ns, 0); out_hash: cfs_hash_putref(ns->ns_rs_hash); out_ns: - OBD_FREE_PTR(ns); + kfree(ns); out_ref: ldlm_put_ref(); return NULL; @@ -898,13 +938,13 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns) * Removing it after @dir may cause oops. */ ldlm_pool_fini(&ns->ns_pool); - ldlm_namespace_proc_unregister(ns); + ldlm_namespace_debugfs_unregister(ns); cfs_hash_putref(ns->ns_rs_hash); /* Namespace \a ns should be not on list at this time, otherwise * this will cause issues related to using freed \a ns in poold * thread. */ LASSERT(list_empty(&ns->ns_list_chain)); - OBD_FREE_PTR(ns); + kfree(ns); ldlm_put_ref(); } @@ -915,7 +955,7 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns) * proc1: destroy import * class_disconnect_export(grab cl_sem) -> * -> ldlm_namespace_free -> - * -> lprocfs_remove(grab _lprocfs_lock). + * -> ldebugfs_remove(grab _lprocfs_lock). * proc2: read proc info * lprocfs_fops_read(grab _lprocfs_lock) -> * -> osc_rd_active, etc(grab cl_sem). @@ -1137,10 +1177,8 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, CERROR("%s: lvbo_init failed for resource %#llx:%#llx: rc = %d\n", ns->ns_obd->obd_name, name->name[0], name->name[1], rc); - if (res->lr_lvb_data) { - OBD_FREE(res->lr_lvb_data, res->lr_lvb_len); - res->lr_lvb_data = NULL; - } + kfree(res->lr_lvb_data); + res->lr_lvb_data = NULL; res->lr_lvb_len = rc; mutex_unlock(&res->lr_lvb_mutex); ldlm_resource_putref(res); diff --git a/drivers/staging/lustre/lustre/libcfs/Makefile b/drivers/staging/lustre/lustre/libcfs/Makefile index 2996a48a31fb..ec98f44a10dd 100644 --- a/drivers/staging/lustre/lustre/libcfs/Makefile +++ b/drivers/staging/lustre/lustre/libcfs/Makefile @@ -2,11 +2,11 @@ obj-$(CONFIG_LUSTRE_FS) += libcfs.o libcfs-linux-objs := linux-tracefile.o linux-debug.o libcfs-linux-objs += linux-prim.o linux-cpu.o -libcfs-linux-objs += linux-tcpip.o libcfs-linux-objs += linux-curproc.o libcfs-linux-objs += linux-module.o libcfs-linux-objs += linux-crypto.o libcfs-linux-objs += linux-crypto-adler.o +libcfs-linux-objs += linux-mem.o libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs)) diff --git a/drivers/staging/lustre/lustre/libcfs/fail.c b/drivers/staging/lustre/lustre/libcfs/fail.c index 92444b0fe2a3..7b7fc215e633 100644 --- a/drivers/staging/lustre/lustre/libcfs/fail.c +++ b/drivers/staging/lustre/lustre/libcfs/fail.c @@ -41,7 +41,7 @@ EXPORT_SYMBOL(cfs_fail_loc); unsigned int cfs_fail_val = 0; EXPORT_SYMBOL(cfs_fail_val); -wait_queue_head_t cfs_race_waitq; +DECLARE_WAIT_QUEUE_HEAD(cfs_race_waitq); EXPORT_SYMBOL(cfs_race_waitq); int cfs_race_state; diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index a55567e0de9e..0ed063145230 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -427,31 +427,31 @@ cfs_hash_dd_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd, } static cfs_hash_hlist_ops_t cfs_hash_hh_hops = { - .hop_hhead = cfs_hash_hh_hhead, - .hop_hhead_size = cfs_hash_hh_hhead_size, - .hop_hnode_add = cfs_hash_hh_hnode_add, - .hop_hnode_del = cfs_hash_hh_hnode_del, + .hop_hhead = cfs_hash_hh_hhead, + .hop_hhead_size = cfs_hash_hh_hhead_size, + .hop_hnode_add = cfs_hash_hh_hnode_add, + .hop_hnode_del = cfs_hash_hh_hnode_del, }; static cfs_hash_hlist_ops_t cfs_hash_hd_hops = { - .hop_hhead = cfs_hash_hd_hhead, - .hop_hhead_size = cfs_hash_hd_hhead_size, - .hop_hnode_add = cfs_hash_hd_hnode_add, - .hop_hnode_del = cfs_hash_hd_hnode_del, + .hop_hhead = cfs_hash_hd_hhead, + .hop_hhead_size = cfs_hash_hd_hhead_size, + .hop_hnode_add = cfs_hash_hd_hnode_add, + .hop_hnode_del = cfs_hash_hd_hnode_del, }; static cfs_hash_hlist_ops_t cfs_hash_dh_hops = { - .hop_hhead = cfs_hash_dh_hhead, - .hop_hhead_size = cfs_hash_dh_hhead_size, - .hop_hnode_add = cfs_hash_dh_hnode_add, - .hop_hnode_del = cfs_hash_dh_hnode_del, + .hop_hhead = cfs_hash_dh_hhead, + .hop_hhead_size = cfs_hash_dh_hhead_size, + .hop_hnode_add = cfs_hash_dh_hnode_add, + .hop_hnode_del = cfs_hash_dh_hnode_del, }; static cfs_hash_hlist_ops_t cfs_hash_dd_hops = { - .hop_hhead = cfs_hash_dd_hhead, - .hop_hhead_size = cfs_hash_dd_hhead_size, - .hop_hnode_add = cfs_hash_dd_hnode_add, - .hop_hnode_del = cfs_hash_dd_hnode_del, + .hop_hhead = cfs_hash_dd_hhead, + .hop_hhead_size = cfs_hash_dd_hhead_size, + .hop_hnode_add = cfs_hash_dd_hnode_add, + .hop_hnode_del = cfs_hash_dd_hnode_del, }; static void diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c index cc3ab351943e..f9262243f935 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c @@ -87,7 +87,7 @@ static void cfs_cpu_core_siblings(int cpu, cpumask_t *mask) /* return cpumask of HTs in the same core */ static void cfs_cpu_ht_siblings(int cpu, cpumask_t *mask) { - cpumask_copy(mask, topology_thread_cpumask(cpu)); + cpumask_copy(mask, topology_sibling_cpumask(cpu)); } static void cfs_node_to_cpumask(int node, cpumask_t *mask) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c new file mode 100644 index 000000000000..025e2f0028ab --- /dev/null +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c @@ -0,0 +1,59 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * + */ +/* + * This file creates a memory allocation primitive for Lustre, that + * allows to fallback to vmalloc allocations should regular kernel allocations + * fail due to size or system memory fragmentation. + * + * Author: Oleg Drokin <green@linuxhacker.ru> + * + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Seagate Technology. + */ +#include <linux/slab.h> +#include <linux/vmalloc.h> + +#include "../../../include/linux/libcfs/libcfs.h" + +void *libcfs_kvzalloc(size_t size, gfp_t flags) +{ + void *ret; + + ret = kzalloc(size, flags | __GFP_NOWARN); + if (!ret) + ret = __vmalloc(size, flags | __GFP_ZERO, PAGE_KERNEL); + return ret; +} +EXPORT_SYMBOL(libcfs_kvzalloc); + +void *libcfs_kvzalloc_cpt(struct cfs_cpt_table *cptab, int cpt, size_t size, + gfp_t flags) +{ + void *ret; + + ret = kzalloc_node(size, flags | __GFP_NOWARN, + cfs_cpt_spread_node(cptab, cpt)); + if (!ret) { + WARN_ON(!(flags & (__GFP_FS|__GFP_HIGH))); + ret = vmalloc_node(size, cfs_cpt_spread_node(cptab, cpt)); + } + + return ret; +} +EXPORT_SYMBOL(libcfs_kvzalloc_cpt); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c deleted file mode 100644 index f2462e7f04bc..000000000000 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ /dev/null @@ -1,623 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ -#define DEBUG_SUBSYSTEM S_LNET - -#include "../../../include/linux/libcfs/libcfs.h" - -#include <linux/if.h> -#include <linux/in.h> -#include <linux/file.h> -/* For sys_open & sys_close */ -#include <linux/syscalls.h> - -static int -libcfs_sock_ioctl(int cmd, unsigned long arg) -{ - mm_segment_t oldmm = get_fs(); - struct socket *sock; - int rc; - struct file *sock_filp; - - rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock); - if (rc != 0) { - CERROR ("Can't create socket: %d\n", rc); - return rc; - } - - sock_filp = sock_alloc_file(sock, 0, NULL); - if (IS_ERR(sock_filp)) { - sock_release(sock); - rc = PTR_ERR(sock_filp); - goto out; - } - - set_fs(KERNEL_DS); - if (sock_filp->f_op->unlocked_ioctl) - rc = sock_filp->f_op->unlocked_ioctl(sock_filp, cmd, arg); - set_fs(oldmm); - - fput(sock_filp); -out: - return rc; -} - -int -libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) -{ - struct ifreq ifr; - int nob; - int rc; - __u32 val; - - nob = strnlen(name, IFNAMSIZ); - if (nob == IFNAMSIZ) { - CERROR("Interface name %s too long\n", name); - return -EINVAL; - } - - CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ); - - strcpy(ifr.ifr_name, name); - rc = libcfs_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr); - - if (rc != 0) { - CERROR("Can't get flags for interface %s\n", name); - return rc; - } - - if ((ifr.ifr_flags & IFF_UP) == 0) { - CDEBUG(D_NET, "Interface %s down\n", name); - *up = 0; - *ip = *mask = 0; - return 0; - } - - *up = 1; - - strcpy(ifr.ifr_name, name); - ifr.ifr_addr.sa_family = AF_INET; - rc = libcfs_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr); - - if (rc != 0) { - CERROR("Can't get IP address for interface %s\n", name); - return rc; - } - - val = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr; - *ip = ntohl(val); - - strcpy(ifr.ifr_name, name); - ifr.ifr_addr.sa_family = AF_INET; - rc = libcfs_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr); - - if (rc != 0) { - CERROR("Can't get netmask for interface %s\n", name); - return rc; - } - - val = ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr; - *mask = ntohl(val); - - return 0; -} - -EXPORT_SYMBOL(libcfs_ipif_query); - -int -libcfs_ipif_enumerate (char ***namesp) -{ - /* Allocate and fill in 'names', returning # interfaces/error */ - char **names; - int toobig; - int nalloc; - int nfound; - struct ifreq *ifr; - struct ifconf ifc; - int rc; - int nob; - int i; - - - nalloc = 16; /* first guess at max interfaces */ - toobig = 0; - for (;;) { - if (nalloc * sizeof(*ifr) > PAGE_CACHE_SIZE) { - toobig = 1; - nalloc = PAGE_CACHE_SIZE/sizeof(*ifr); - CWARN("Too many interfaces: only enumerating first %d\n", - nalloc); - } - - LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr)); - if (ifr == NULL) { - CERROR ("ENOMEM enumerating up to %d interfaces\n", nalloc); - rc = -ENOMEM; - goto out0; - } - - ifc.ifc_buf = (char *)ifr; - ifc.ifc_len = nalloc * sizeof(*ifr); - - rc = libcfs_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc); - - if (rc < 0) { - CERROR ("Error %d enumerating interfaces\n", rc); - goto out1; - } - - LASSERT (rc == 0); - - nfound = ifc.ifc_len/sizeof(*ifr); - LASSERT (nfound <= nalloc); - - if (nfound < nalloc || toobig) - break; - - LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); - nalloc *= 2; - } - - if (nfound == 0) - goto out1; - - LIBCFS_ALLOC(names, nfound * sizeof(*names)); - if (names == NULL) { - rc = -ENOMEM; - goto out1; - } - - for (i = 0; i < nfound; i++) { - - nob = strnlen (ifr[i].ifr_name, IFNAMSIZ); - if (nob == IFNAMSIZ) { - /* no space for terminating NULL */ - CERROR("interface name %.*s too long (%d max)\n", - nob, ifr[i].ifr_name, IFNAMSIZ); - rc = -ENAMETOOLONG; - goto out2; - } - - LIBCFS_ALLOC(names[i], IFNAMSIZ); - if (names[i] == NULL) { - rc = -ENOMEM; - goto out2; - } - - memcpy(names[i], ifr[i].ifr_name, nob); - names[i][nob] = 0; - } - - *namesp = names; - rc = nfound; - - out2: - if (rc < 0) - libcfs_ipif_free_enumeration(names, nfound); - out1: - LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); - out0: - return rc; -} - -EXPORT_SYMBOL(libcfs_ipif_enumerate); - -void -libcfs_ipif_free_enumeration (char **names, int n) -{ - int i; - - LASSERT (n > 0); - - for (i = 0; i < n && names[i] != NULL; i++) - LIBCFS_FREE(names[i], IFNAMSIZ); - - LIBCFS_FREE(names, n * sizeof(*names)); -} - -EXPORT_SYMBOL(libcfs_ipif_free_enumeration); - -int -libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout) -{ - int rc; - long ticks = timeout * HZ; - unsigned long then; - struct timeval tv; - - LASSERT (nob > 0); - /* Caller may pass a zero timeout if she thinks the socket buffer is - * empty enough to take the whole message immediately */ - - for (;;) { - struct kvec iov = { - .iov_base = buffer, - .iov_len = nob - }; - struct msghdr msg = { - .msg_flags = (timeout == 0) ? MSG_DONTWAIT : 0 - }; - - if (timeout != 0) { - /* Set send timeout to remaining time */ - tv = (struct timeval) { - .tv_sec = ticks / HZ, - .tv_usec = ((ticks % HZ) * 1000000) / HZ - }; - rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, - (char *)&tv, sizeof(tv)); - if (rc != 0) { - CERROR("Can't set socket send timeout %ld.%06d: %d\n", - (long)tv.tv_sec, (int)tv.tv_usec, rc); - return rc; - } - } - - then = jiffies; - rc = kernel_sendmsg(sock, &msg, &iov, 1, nob); - ticks -= jiffies - then; - - if (rc == nob) - return 0; - - if (rc < 0) - return rc; - - if (rc == 0) { - CERROR ("Unexpected zero rc\n"); - return -ECONNABORTED; - } - - if (ticks <= 0) - return -EAGAIN; - - buffer = ((char *)buffer) + rc; - nob -= rc; - } - - return 0; -} -EXPORT_SYMBOL(libcfs_sock_write); - -int -libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout) -{ - int rc; - long ticks = timeout * HZ; - unsigned long then; - struct timeval tv; - - LASSERT (nob > 0); - LASSERT (ticks > 0); - - for (;;) { - struct kvec iov = { - .iov_base = buffer, - .iov_len = nob - }; - struct msghdr msg = { - .msg_flags = 0 - }; - - /* Set receive timeout to remaining time */ - tv = (struct timeval) { - .tv_sec = ticks / HZ, - .tv_usec = ((ticks % HZ) * 1000000) / HZ - }; - rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, - (char *)&tv, sizeof(tv)); - if (rc != 0) { - CERROR("Can't set socket recv timeout %ld.%06d: %d\n", - (long)tv.tv_sec, (int)tv.tv_usec, rc); - return rc; - } - - then = jiffies; - rc = kernel_recvmsg(sock, &msg, &iov, 1, nob, 0); - ticks -= jiffies - then; - - if (rc < 0) - return rc; - - if (rc == 0) - return -ECONNRESET; - - buffer = ((char *)buffer) + rc; - nob -= rc; - - if (nob == 0) - return 0; - - if (ticks <= 0) - return -ETIMEDOUT; - } -} - -EXPORT_SYMBOL(libcfs_sock_read); - -static int -libcfs_sock_create (struct socket **sockp, int *fatal, - __u32 local_ip, int local_port) -{ - struct sockaddr_in locaddr; - struct socket *sock; - int rc; - int option; - - /* All errors are fatal except bind failure if the port is in use */ - *fatal = 1; - - rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock); - *sockp = sock; - if (rc != 0) { - CERROR ("Can't create socket: %d\n", rc); - return rc; - } - - option = 1; - rc = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (char *)&option, sizeof (option)); - if (rc != 0) { - CERROR("Can't set SO_REUSEADDR for socket: %d\n", rc); - goto failed; - } - - if (local_ip != 0 || local_port != 0) { - memset(&locaddr, 0, sizeof(locaddr)); - locaddr.sin_family = AF_INET; - locaddr.sin_port = htons(local_port); - locaddr.sin_addr.s_addr = (local_ip == 0) ? - INADDR_ANY : htonl(local_ip); - - rc = sock->ops->bind(sock, (struct sockaddr *)&locaddr, - sizeof(locaddr)); - if (rc == -EADDRINUSE) { - CDEBUG(D_NET, "Port %d already in use\n", local_port); - *fatal = 0; - goto failed; - } - if (rc != 0) { - CERROR("Error trying to bind to port %d: %d\n", - local_port, rc); - goto failed; - } - } - - return 0; - - failed: - sock_release(sock); - return rc; -} - -int -libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize) -{ - int option; - int rc; - - if (txbufsize != 0) { - option = txbufsize; - rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDBUF, - (char *)&option, sizeof (option)); - if (rc != 0) { - CERROR ("Can't set send buffer %d: %d\n", - option, rc); - return rc; - } - } - - if (rxbufsize != 0) { - option = rxbufsize; - rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUF, - (char *)&option, sizeof (option)); - if (rc != 0) { - CERROR ("Can't set receive buffer %d: %d\n", - option, rc); - return rc; - } - } - - return 0; -} - -EXPORT_SYMBOL(libcfs_sock_setbuf); - -int -libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port) -{ - struct sockaddr_in sin; - int len = sizeof (sin); - int rc; - - rc = sock->ops->getname (sock, (struct sockaddr *)&sin, &len, - remote ? 2 : 0); - if (rc != 0) { - CERROR ("Error %d getting sock %s IP/port\n", - rc, remote ? "peer" : "local"); - return rc; - } - - if (ip != NULL) - *ip = ntohl (sin.sin_addr.s_addr); - - if (port != NULL) - *port = ntohs (sin.sin_port); - - return 0; -} - -EXPORT_SYMBOL(libcfs_sock_getaddr); - -int -libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize) -{ - - if (txbufsize != NULL) { - *txbufsize = sock->sk->sk_sndbuf; - } - - if (rxbufsize != NULL) { - *rxbufsize = sock->sk->sk_rcvbuf; - } - - return 0; -} - -EXPORT_SYMBOL(libcfs_sock_getbuf); - -int -libcfs_sock_listen (struct socket **sockp, - __u32 local_ip, int local_port, int backlog) -{ - int fatal; - int rc; - - rc = libcfs_sock_create(sockp, &fatal, local_ip, local_port); - if (rc != 0) { - if (!fatal) - CERROR("Can't create socket: port %d already in use\n", - local_port); - return rc; - } - - rc = (*sockp)->ops->listen(*sockp, backlog); - if (rc == 0) - return 0; - - CERROR("Can't set listen backlog %d: %d\n", backlog, rc); - sock_release(*sockp); - return rc; -} - -EXPORT_SYMBOL(libcfs_sock_listen); - -int -libcfs_sock_accept (struct socket **newsockp, struct socket *sock) -{ - wait_queue_t wait; - struct socket *newsock; - int rc; - - init_waitqueue_entry(&wait, current); - - /* XXX this should add a ref to sock->ops->owner, if - * TCP could be a module */ - rc = sock_create_lite(PF_PACKET, sock->type, IPPROTO_TCP, &newsock); - if (rc) { - CERROR("Can't allocate socket\n"); - return rc; - } - - newsock->ops = sock->ops; - - rc = sock->ops->accept(sock, newsock, O_NONBLOCK); - if (rc == -EAGAIN) { - /* Nothing ready, so wait for activity */ - set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(sk_sleep(sock->sk), &wait); - schedule(); - remove_wait_queue(sk_sleep(sock->sk), &wait); - set_current_state(TASK_RUNNING); - rc = sock->ops->accept(sock, newsock, O_NONBLOCK); - } - - if (rc != 0) - goto failed; - - *newsockp = newsock; - return 0; - - failed: - sock_release(newsock); - return rc; -} - -EXPORT_SYMBOL(libcfs_sock_accept); - -void -libcfs_sock_abort_accept (struct socket *sock) -{ - wake_up_all(sk_sleep(sock->sk)); -} - -EXPORT_SYMBOL(libcfs_sock_abort_accept); - -int -libcfs_sock_connect (struct socket **sockp, int *fatal, - __u32 local_ip, int local_port, - __u32 peer_ip, int peer_port) -{ - struct sockaddr_in srvaddr; - int rc; - - rc = libcfs_sock_create(sockp, fatal, local_ip, local_port); - if (rc != 0) - return rc; - - memset (&srvaddr, 0, sizeof (srvaddr)); - srvaddr.sin_family = AF_INET; - srvaddr.sin_port = htons(peer_port); - srvaddr.sin_addr.s_addr = htonl(peer_ip); - - rc = (*sockp)->ops->connect(*sockp, - (struct sockaddr *)&srvaddr, sizeof(srvaddr), - 0); - if (rc == 0) - return 0; - - /* EADDRNOTAVAIL probably means we're already connected to the same - * peer/port on the same local port on a differently typed - * connection. Let our caller retry with a different local - * port... */ - *fatal = !(rc == -EADDRNOTAVAIL); - - CDEBUG_LIMIT(*fatal ? D_NETERROR : D_NET, - "Error %d connecting %pI4h/%d -> %pI4h/%d\n", rc, - &local_ip, local_port, &peer_ip, peer_port); - - sock_release(*sockp); - return rc; -} - -EXPORT_SYMBOL(libcfs_sock_connect); - -void -libcfs_sock_release (struct socket *sock) -{ - sock_release(sock); -} - -EXPORT_SYMBOL(libcfs_sock_release); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index c8e293002e07..eb10e3b478aa 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -49,7 +49,7 @@ static unsigned int pages_factor[CFS_TCD_TYPE_MAX] = { char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX]; -struct rw_semaphore cfs_tracefile_sem; +static DECLARE_RWSEM(cfs_tracefile_sem); int cfs_tracefile_init_arch(void) { @@ -57,8 +57,6 @@ int cfs_tracefile_init_arch(void) int j; struct cfs_trace_cpu_data *tcd; - init_rwsem(&cfs_tracefile_sem); - /* initialize trace_data */ memset(cfs_trace_data, 0, sizeof(cfs_trace_data)); for (i = 0; i < CFS_TCD_TYPE_MAX; i++) { @@ -102,11 +100,10 @@ void cfs_tracefile_fini_arch(void) int j; for (i = 0; i < num_possible_cpus(); i++) - for (j = 0; j < 3; j++) - if (cfs_trace_console_buffers[i][j] != NULL) { - kfree(cfs_trace_console_buffers[i][j]); - cfs_trace_console_buffers[i][j] = NULL; - } + for (j = 0; j < 3; j++) { + kfree(cfs_trace_console_buffers[i][j]); + cfs_trace_console_buffers[i][j] = NULL; + } for (i = 0; cfs_trace_data[i] != NULL; i++) { kfree(cfs_trace_data[i]); diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index f0ee76abfd5a..e60b2e9b9194 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -49,7 +49,6 @@ #include <linux/file.h> #include <linux/list.h> -#include <linux/proc_fs.h> #include <linux/sysctl.h> # define DEBUG_SUBSYSTEM S_LNET @@ -67,8 +66,6 @@ MODULE_DESCRIPTION("Portals v3.1"); MODULE_LICENSE("GPL"); extern struct miscdevice libcfs_dev; -extern struct rw_semaphore cfs_tracefile_sem; -extern struct mutex cfs_trace_thread_mutex; extern struct cfs_wi_sched *cfs_sched_rehash; extern void libcfs_init_nidstrings(void); @@ -249,8 +246,8 @@ static int libcfs_psdev_release(unsigned long flags, void *args) return 0; } -static struct rw_semaphore ioctl_list_sem; -static struct list_head ioctl_list; +static DECLARE_RWSEM(ioctl_list_sem); +static LIST_HEAD(ioctl_list); int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand) { @@ -393,11 +390,6 @@ static int init_libcfs_module(void) libcfs_arch_init(); libcfs_init_nidstrings(); - init_rwsem(&cfs_tracefile_sem); - mutex_init(&cfs_trace_thread_mutex); - init_rwsem(&ioctl_list_sem); - INIT_LIST_HEAD(&ioctl_list); - init_waitqueue_head(&cfs_race_waitq); rc = libcfs_debug_init(5 * 1024 * 1024); if (rc < 0) { diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index c86394f7f4d9..6ee2adcf8890 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -52,7 +52,7 @@ union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS] __cacheline char cfs_tracefile[TRACEFILE_NAME_SIZE]; long long cfs_tracefile_size = CFS_TRACEFILE_SIZE; static struct tracefiled_ctl trace_tctl; -struct mutex cfs_trace_thread_mutex; +static DEFINE_MUTEX(cfs_trace_thread_mutex); static int thread_running; static atomic_t cfs_tage_allocated = ATOMIC_INIT(0); diff --git a/drivers/staging/lustre/lustre/llite/Makefile b/drivers/staging/lustre/lustre/llite/Makefile index 7d70115d5bc7..2cbc46838fdd 100644 --- a/drivers/staging/lustre/lustre/llite/Makefile +++ b/drivers/staging/lustre/lustre/llite/Makefile @@ -5,7 +5,6 @@ lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \ xattr.o xattr_cache.o remote_perm.o llite_rmtacl.o llite_capa.o \ rw26.o super25.o statahead.o \ ../lclient/glimpse.o ../lclient/lcommon_cl.o ../lclient/lcommon_misc.o \ - vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o + vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o lproc_llite.o -lustre-$(CONFIG_PROC_FS) += lproc_llite.o llite_lloop-y := lloop.o diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 5af01351306d..7b008a64707d 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -52,7 +52,7 @@ static void free_dentry_data(struct rcu_head *head) struct ll_dentry_data *lld; lld = container_of(head, struct ll_dentry_data, lld_rcu_head); - OBD_FREE_PTR(lld); + kfree(lld); } /* should NOT be called with the dcache lock, see fs/dcache.c */ @@ -67,7 +67,7 @@ static void ll_release(struct dentry *de) if (lld->lld_it) { ll_intent_release(lld->lld_it); - OBD_FREE(lld->lld_it, sizeof(*lld->lld_it)); + kfree(lld->lld_it); } de->d_fsdata = NULL; @@ -194,7 +194,7 @@ int ll_d_init(struct dentry *de) de->d_fsdata = lld; __d_lustre_invalidate(de); } else { - OBD_FREE_PTR(lld); + kfree(lld); } spin_unlock(&de->d_lock); } else { diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index a5bc694dcb64..3d746a94f92e 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -239,7 +239,7 @@ static int ll_dir_filler(void *_hash, struct page *page0) ll_pagevec_lru_add_file(&lru_pvec); if (page_pool != &page0) - OBD_FREE(page_pool, sizeof(struct page *) * max_pages); + kfree(page_pool); return rc; } @@ -650,7 +650,7 @@ static int ll_send_mgc_param(struct obd_export *mgc, char *string) sizeof(struct mgs_send_param), msp, NULL); if (rc) CERROR("Failed to set parameter: %d\n", rc); - OBD_FREE_PTR(msp); + kfree(msp); return rc; } @@ -754,10 +754,8 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, char *buf; param = kzalloc(MGS_PARAM_MAXLEN, GFP_NOFS); - if (!param) { - rc = -ENOMEM; - goto end; - } + if (!param) + return -ENOMEM; buf = param; /* Get fsname and assume devname to be -MDT0000. */ @@ -786,8 +784,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param); end: - if (param != NULL) - OBD_FREE(param, MGS_PARAM_MAXLEN); + kfree(param); } return rc; } @@ -1072,7 +1069,7 @@ static int copy_and_ioctl(int cmd, struct obd_export *exp, rc = obd_iocontrol(cmd, exp, size, copy, NULL); out: - OBD_FREE(copy, size); + kfree(copy); return rc; } @@ -1163,7 +1160,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) oqctl->qc_cmd = Q_QUOTAOFF; obd_quotactl(sbi->ll_md_exp, oqctl); } - OBD_FREE_PTR(oqctl); + kfree(oqctl); return rc; } /* If QIF_SPACE is not set, client should collect the @@ -1206,39 +1203,44 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) oqctl->qc_dqblk.dqb_valid &= ~QIF_SPACE; } - OBD_FREE_PTR(oqctl_tmp); + kfree(oqctl_tmp); } out: QCTL_COPY(qctl, oqctl); - OBD_FREE_PTR(oqctl); + kfree(oqctl); } return rc; } -static char * -ll_getname(const char __user *filename) +/* This function tries to get a single name component, + * to send to the server. No actual path traversal involved, + * so we limit to NAME_MAX */ +static char *ll_getname(const char __user *filename) { int ret = 0, len; - char *tmp = __getname(); + char *tmp; + tmp = kzalloc(NAME_MAX + 1, GFP_KERNEL); if (!tmp) return ERR_PTR(-ENOMEM); - len = strncpy_from_user(tmp, filename, PATH_MAX); - if (len == 0) + len = strncpy_from_user(tmp, filename, NAME_MAX + 1); + if (len < 0) + ret = len; + else if (len == 0) ret = -ENOENT; - else if (len > PATH_MAX) + else if (len > NAME_MAX && tmp[NAME_MAX] != 0) ret = -ENAMETOOLONG; if (ret) { - __putname(tmp); + kfree(tmp); tmp = ERR_PTR(ret); } return tmp; } -#define ll_putname(filename) __putname(filename) +#define ll_putname(filename) kfree(filename) static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -1436,37 +1438,7 @@ lmv_out_free: goto free_lmv; } free_lmv: - if (tmp) - OBD_FREE(tmp, lum_size); - return rc; - } - case LL_IOC_REMOVE_ENTRY: { - char *filename = NULL; - int namelen = 0; - int rc; - - /* Here is a little hack to avoid sending REINT_RMENTRY to - * unsupported server, which might crash the server(LU-2730), - * Because both LVB_TYPE and REINT_RMENTRY will be supported - * on 2.4, we use OBD_CONNECT_LVB_TYPE to detect whether the - * server will support REINT_RMENTRY XXX*/ - if (!(exp_connect_flags(sbi->ll_md_exp) & OBD_CONNECT_LVB_TYPE)) - return -ENOTSUPP; - - filename = ll_getname((const char *)arg); - if (IS_ERR(filename)) - return PTR_ERR(filename); - - namelen = strlen(filename); - if (namelen < 1) { - rc = -EINVAL; - goto out_rmdir; - } - - rc = ll_rmdir_entry(inode, filename, namelen); -out_rmdir: - if (filename) - ll_putname(filename); + kfree(tmp); return rc; } case LL_IOC_LOV_SWAP_LAYOUTS: @@ -1576,7 +1548,7 @@ out_req: if (rc) return rc; - OBD_ALLOC_LARGE(lmm, lmmsize); + lmm = libcfs_kvzalloc(lmmsize, GFP_NOFS); if (lmm == NULL) return -ENOMEM; if (copy_from_user(lmm, lum, lmmsize)) { @@ -1629,7 +1601,7 @@ out_req: free_lsm: obd_free_memmd(sbi->ll_dt_exp, &lsm); free_lmm: - OBD_FREE_LARGE(lmm, lmmsize); + kvfree(lmm); return rc; } case OBD_IOC_LLOG_CATINFO: { @@ -1657,7 +1629,7 @@ free_lmm: if (rc < 0) CDEBUG(D_INFO, "obd_quotacheck failed: rc %d\n", rc); - OBD_FREE_PTR(oqctl); + kfree(oqctl); return error ?: rc; } case OBD_IOC_POLL_QUOTACHECK: { @@ -1691,7 +1663,7 @@ free_lmm: goto out_poll; } out_poll: - OBD_FREE_PTR(check); + kfree(check); return rc; } case LL_IOC_QUOTACTL: { @@ -1712,7 +1684,7 @@ out_poll: rc = -EFAULT; out_quotactl: - OBD_FREE_PTR(qctl); + kfree(qctl); return rc; } case OBD_IOC_GETDTNAME: @@ -1775,19 +1747,13 @@ out_quotactl: struct hsm_user_request *hur; ssize_t totalsize; - hur = kzalloc(sizeof(*hur), GFP_NOFS); - if (!hur) - return -ENOMEM; - - /* We don't know the true size yet; copy the fixed-size part */ - if (copy_from_user(hur, (void *)arg, sizeof(*hur))) { - OBD_FREE_PTR(hur); - return -EFAULT; - } + hur = memdup_user((void *)arg, sizeof(*hur)); + if (IS_ERR(hur)) + return PTR_ERR(hur); /* Compute the whole struct size */ totalsize = hur_len(hur); - OBD_FREE_PTR(hur); + kfree(hur); if (totalsize < 0) return -E2BIG; @@ -1795,13 +1761,13 @@ out_quotactl: if (totalsize >= MDS_MAXREQSIZE / 3) return -E2BIG; - OBD_ALLOC_LARGE(hur, totalsize); + hur = libcfs_kvzalloc(totalsize, GFP_NOFS); if (hur == NULL) return -ENOMEM; /* Copy the whole struct */ if (copy_from_user(hur, (void *)arg, totalsize)) { - OBD_FREE_LARGE(hur, totalsize); + kvfree(hur); return -EFAULT; } @@ -1828,7 +1794,7 @@ out_quotactl: hur, NULL); } - OBD_FREE_LARGE(hur, totalsize); + kvfree(hur); return rc; } @@ -1861,38 +1827,30 @@ out_quotactl: struct hsm_copy *copy; int rc; - copy = kzalloc(sizeof(*copy), GFP_NOFS); - if (!copy) - return -ENOMEM; - if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { - OBD_FREE_PTR(copy); - return -EFAULT; - } + copy = memdup_user((char *)arg, sizeof(*copy)); + if (IS_ERR(copy)) + return PTR_ERR(copy); rc = ll_ioc_copy_start(inode->i_sb, copy); if (copy_to_user((char *)arg, copy, sizeof(*copy))) rc = -EFAULT; - OBD_FREE_PTR(copy); + kfree(copy); return rc; } case LL_IOC_HSM_COPY_END: { struct hsm_copy *copy; int rc; - copy = kzalloc(sizeof(*copy), GFP_NOFS); - if (!copy) - return -ENOMEM; - if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { - OBD_FREE_PTR(copy); - return -EFAULT; - } + copy = memdup_user((char *)arg, sizeof(*copy)); + if (IS_ERR(copy)) + return PTR_ERR(copy); rc = ll_ioc_copy_end(inode->i_sb, copy); if (copy_to_user((char *)arg, copy, sizeof(*copy))) rc = -EFAULT; - OBD_FREE_PTR(copy); + kfree(copy); return rc; } default: diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 4b44c634fcc3..3075db211106 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -213,7 +213,7 @@ out: md_clear_open_replay_data(md_exp, och); /* Free @och if it is not waiting for DONE_WRITING. */ och->och_fh.cookie = DEAD_HANDLE_MAGIC; - OBD_FREE_PTR(och); + kfree(och); } if (req) /* This is close request */ ptlrpc_req_finished(req); @@ -693,7 +693,7 @@ restart: out_och_free: if (rc) { if (och_p && *och_p) { - OBD_FREE(*och_p, sizeof(struct obd_client_handle)); + kfree(*och_p); *och_p = NULL; /* OBD_FREE writes some magic there */ (*och_usecount)--; } @@ -875,7 +875,7 @@ out_close: out_release_it: ll_intent_release(&it); out: - OBD_FREE_PTR(och); + kfree(och); return ERR_PTR(rc); } @@ -1282,7 +1282,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx) lsm_size = sizeof(*lsm) + (sizeof(struct lov_oinfo) * (lsm->lsm_stripe_count)); - OBD_ALLOC_LARGE(lsm2, lsm_size); + lsm2 = libcfs_kvzalloc(lsm_size, GFP_NOFS); if (lsm2 == NULL) { rc = -ENOMEM; goto out; @@ -1300,7 +1300,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx) rc = obd_create(NULL, exp, oa, &lsm2, &oti); ll_inode_size_unlock(inode); - OBD_FREE_LARGE(lsm2, lsm_size); + kvfree(lsm2); goto out; out: ccc_inode_lsm_put(inode, lsm); @@ -1477,12 +1477,12 @@ static int ll_lov_setea(struct inode *inode, struct file *file, if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; - OBD_ALLOC_LARGE(lump, lum_size); + lump = libcfs_kvzalloc(lum_size, GFP_NOFS); if (lump == NULL) return -ENOMEM; if (copy_from_user(lump, (struct lov_user_md *)arg, lum_size)) { - OBD_FREE_LARGE(lump, lum_size); + kvfree(lump); return -EFAULT; } @@ -1490,7 +1490,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file, lum_size); cl_lov_delay_create_clear(&file->f_flags); - OBD_FREE_LARGE(lump, lum_size); + kvfree(lump); return rc; } @@ -1779,7 +1779,7 @@ int ll_fid2path(struct inode *inode, void __user *arg) rc = -EFAULT; gf_free: - OBD_FREE(gfout, outsize); + kfree(gfout); return rc; } @@ -1802,7 +1802,7 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) num_bytes = sizeof(*fiemap_s) + (extent_count * sizeof(struct ll_fiemap_extent)); - OBD_ALLOC_LARGE(fiemap_s, num_bytes); + fiemap_s = libcfs_kvzalloc(num_bytes, GFP_NOFS); if (fiemap_s == NULL) return -ENOMEM; @@ -1839,7 +1839,7 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) rc = -EFAULT; error: - OBD_FREE_LARGE(fiemap_s, num_bytes); + kvfree(fiemap_s); return rc; } @@ -1883,7 +1883,7 @@ int ll_data_version(struct inode *inode, __u64 *data_version, *data_version = obdo->o_data_version; } - OBD_FREE_PTR(obdo); + kfree(obdo); out: ccc_inode_lsm_put(inode, lsm); return rc; @@ -2109,8 +2109,7 @@ putgl: } free: - if (llss != NULL) - OBD_FREE_PTR(llss); + kfree(llss); return rc; } @@ -2152,22 +2151,20 @@ static int ll_hsm_import(struct inode *inode, struct file *file, /* set HSM flags */ hss = kzalloc(sizeof(*hss), GFP_NOFS); - if (!hss) { - rc = -ENOMEM; - goto out; - } + if (!hss) + return -ENOMEM; hss->hss_valid = HSS_SETMASK | HSS_ARCHIVE_ID; hss->hss_archive_id = hui->hui_archive_id; hss->hss_setmask = HS_ARCHIVED | HS_EXISTS | HS_RELEASED; rc = ll_hsm_state_set(inode, hss); if (rc != 0) - goto out; + goto free_hss; attr = kzalloc(sizeof(*attr), GFP_NOFS); if (!attr) { rc = -ENOMEM; - goto out; + goto free_hss; } attr->ia_mode = hui->hui_mode & (S_IRWXU | S_IRWXG | S_IRWXO); @@ -2193,13 +2190,9 @@ static int ll_hsm_import(struct inode *inode, struct file *file, mutex_unlock(&inode->i_mutex); -out: - if (hss != NULL) - OBD_FREE_PTR(hss); - - if (attr != NULL) - OBD_FREE_PTR(attr); - + kfree(attr); +free_hss: + kfree(hss); return rc; } @@ -2350,7 +2343,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hus); if (IS_ERR(op_data)) { - OBD_FREE_PTR(hus); + kfree(hus); return PTR_ERR(op_data); } @@ -2361,25 +2354,20 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = -EFAULT; ll_finish_md_op_data(op_data); - OBD_FREE_PTR(hus); + kfree(hus); return rc; } case LL_IOC_HSM_STATE_SET: { struct hsm_state_set *hss; int rc; - hss = kzalloc(sizeof(*hss), GFP_NOFS); - if (!hss) - return -ENOMEM; - - if (copy_from_user(hss, (char *)arg, sizeof(*hss))) { - OBD_FREE_PTR(hss); - return -EFAULT; - } + hss = memdup_user((char *)arg, sizeof(*hss)); + if (IS_ERR(hss)) + return PTR_ERR(hss); rc = ll_hsm_state_set(inode, hss); - OBD_FREE_PTR(hss); + kfree(hss); return rc; } case LL_IOC_HSM_ACTION: { @@ -2394,7 +2382,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hca); if (IS_ERR(op_data)) { - OBD_FREE_PTR(hca); + kfree(hca); return PTR_ERR(op_data); } @@ -2405,7 +2393,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = -EFAULT; ll_finish_md_op_data(op_data); - OBD_FREE_PTR(hca); + kfree(hca); return rc; } case LL_IOC_SET_LEASE: { @@ -2495,18 +2483,13 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case LL_IOC_HSM_IMPORT: { struct hsm_user_import *hui; - hui = kzalloc(sizeof(*hui), GFP_NOFS); - if (!hui) - return -ENOMEM; - - if (copy_from_user(hui, (void *)arg, sizeof(*hui))) { - OBD_FREE_PTR(hui); - return -EFAULT; - } + hui = memdup_user((void *)arg, sizeof(*hui)); + if (IS_ERR(hui)) + return PTR_ERR(hui); rc = ll_hsm_import(inode, file, hui); - OBD_FREE_PTR(hui); + kfree(hui); return rc; } default: { @@ -3062,7 +3045,7 @@ static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, num_bytes = sizeof(*fiemap) + (extent_count * sizeof(struct ll_fiemap_extent)); - OBD_ALLOC_LARGE(fiemap, num_bytes); + fiemap = libcfs_kvzalloc(num_bytes, GFP_NOFS); if (fiemap == NULL) return -ENOMEM; @@ -3084,7 +3067,7 @@ static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, fiemap->fm_mapped_extents * sizeof(struct ll_fiemap_extent)); - OBD_FREE_LARGE(fiemap, num_bytes); + kvfree(fiemap); return rc; } @@ -3246,12 +3229,10 @@ void ll_iocontrol_unregister(void *magic) down_write(&llioc.ioc_sem); list_for_each_entry(tmp, &llioc.ioc_head, iocd_list) { if (tmp == magic) { - unsigned int size = tmp->iocd_size; - list_del(&tmp->iocd_list); up_write(&llioc.ioc_sem); - OBD_FREE(tmp, size); + kfree(tmp); return; } } @@ -3375,7 +3356,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) goto out; } - OBD_ALLOC_LARGE(lvbdata, lmmsize); + lvbdata = libcfs_kvzalloc(lmmsize, GFP_NOFS); if (lvbdata == NULL) { rc = -ENOMEM; goto out; @@ -3384,7 +3365,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) memcpy(lvbdata, lmm, lmmsize); lock_res_and_lock(lock); if (lock->l_lvb_data != NULL) - OBD_FREE_LARGE(lock->l_lvb_data, lock->l_lvb_len); + kvfree(lock->l_lvb_data); lock->l_lvb_data = lvbdata; lock->l_lvb_len = lmmsize; @@ -3619,6 +3600,6 @@ int ll_layout_restore(struct inode *inode) hur->hur_request.hr_itemcount = 1; rc = obd_iocontrol(LL_IOC_HSM_REQUEST, cl_i2sbi(inode)->ll_md_exp, len, hur, NULL); - OBD_FREE(hur, len); + kfree(hur); return rc; } diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c index aec9a44120c0..a6268718b76e 100644 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ b/drivers/staging/lustre/lustre/llite/llite_capa.c @@ -140,6 +140,7 @@ static void sort_add_capa(struct obd_capa *ocapa, struct list_head *head) static inline int obd_capa_open_count(struct obd_capa *oc) { struct ll_inode_info *lli = ll_i2info(oc->u.cli.inode); + return atomic_read(&lli->lli_open_count); } diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index a94ba02ccf02..7bdae723fedd 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -305,7 +305,7 @@ out: ll_finish_md_op_data(op_data); if (och) { md_clear_open_replay_data(ll_i2sbi(inode)->ll_md_exp, och); - OBD_FREE_PTR(och); + kfree(och); } } @@ -374,7 +374,7 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret) task = kthread_run(ll_close_thread, lcq, "ll_close"); if (IS_ERR(task)) { - OBD_FREE(lcq, sizeof(*lcq)); + kfree(lcq); return PTR_ERR(task); } @@ -389,5 +389,5 @@ void ll_close_thread_shutdown(struct ll_close_queue *lcq) atomic_inc(&lcq->lcq_stop); wake_up(&lcq->lcq_waitq); wait_for_completion(&lcq->lcq_comp); - OBD_FREE(lcq, sizeof(*lcq)); + kfree(lcq); } diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 5f918e3c4683..f097d4d167d5 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -57,12 +57,6 @@ #define VM_FAULT_RETRY 0 #endif -/* Kernel 3.1 kills LOOKUP_CONTINUE, LOOKUP_PARENT is equivalent to it. - * seem kernel commit 49084c3bb2055c401f3493c13edae14d49128ca0 */ -#ifndef LOOKUP_CONTINUE -#define LOOKUP_CONTINUE LOOKUP_PARENT -#endif - /** Only used on client-side for indicating the tail of dir hash/offset. */ #define LL_DIR_END_OFF 0x7fffffffffffffffULL #define LL_DIR_END_OFF_32BIT 0x7fffffffUL @@ -471,7 +465,7 @@ struct ll_sb_info { struct obd_uuid ll_sb_uuid; struct obd_export *ll_md_exp; struct obd_export *ll_dt_exp; - struct proc_dir_entry* ll_proc_root; + struct dentry *ll_debugfs_entry; struct lu_fid ll_root_fid; /* root object fid */ int ll_flags; @@ -493,9 +487,6 @@ struct ll_sb_info { unsigned int ll_namelen; struct file_operations *ll_fop; - /* =0 - hold lock over whole read/write - * >0 - max. chunk to be read/written w/o lock re-acquiring */ - unsigned long ll_max_rw_chunk; unsigned int ll_md_brw_size; /* used by readdir */ struct lu_site *ll_site; @@ -524,10 +515,11 @@ struct ll_sb_info { struct rmtacl_ctl_table ll_rct; struct eacl_table ll_et; __kernel_fsid_t ll_fsid; + struct kobject ll_kobj; /* sysfs object */ + struct super_block *ll_sb; /* struct super_block (for sysfs code)*/ + struct completion ll_kobj_unregister; }; -#define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024) - struct ll_ra_read { pgoff_t lrr_start; pgoff_t lrr_count; @@ -644,7 +636,8 @@ struct lov_stripe_md; extern spinlock_t inode_lock; -extern struct proc_dir_entry *proc_lustre_fs_root; +extern struct dentry *llite_root; +extern struct kset *llite_kset; static inline struct inode *ll_info2i(struct ll_inode_info *lli) { @@ -670,30 +663,14 @@ void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar); struct ll_ra_read *ll_ra_read_get(struct file *f); /* llite/lproc_llite.c */ -#if defined (CONFIG_PROC_FS) -int lprocfs_register_mountpoint(struct proc_dir_entry *parent, - struct super_block *sb, char *osc, char *mdc); -void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi); +int ldebugfs_register_mountpoint(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc); +void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct ll_file_data *file, loff_t pos, size_t count, int rw); -#else -static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent, - struct super_block *sb, char *osc, char *mdc){return 0;} -static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {} -static inline -void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {} -static inline void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -static inline void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, - struct ll_file_data *file, loff_t pos, - size_t count, int rw) {} -#endif - /* llite/dir.c */ void ll_release_page(struct page *page, int remove); @@ -727,11 +704,7 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, struct ll_readahead_state *ras, struct address_space *mapping, struct cl_page_list *queue, int flags); -#ifndef MS_HAS_NEW_AOPS extern const struct address_space_operations ll_aops; -#else -extern const struct address_space_operations_ext ll_aops; -#endif /* llite/file.c */ extern struct file_operations ll_file_operations; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index a27af7882170..25139885b5a7 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -57,7 +57,8 @@ #include "llite_internal.h" struct kmem_cache *ll_file_data_slab; -struct proc_dir_entry *proc_lustre_fs_root; +struct dentry *llite_root; +struct kset *llite_kset; static LIST_HEAD(ll_super_blocks); static DEFINE_SPINLOCK(ll_sb_lock); @@ -66,7 +67,7 @@ static DEFINE_SPINLOCK(ll_sb_lock); #define log2(n) ffz(~(n)) #endif -static struct ll_sb_info *ll_init_sbi(void) +static struct ll_sb_info *ll_init_sbi(struct super_block *sb) { struct ll_sb_info *sbi = NULL; unsigned long pages; @@ -134,6 +135,8 @@ static struct ll_sb_info *ll_init_sbi(void) atomic_set(&sbi->ll_agl_total, 0); sbi->ll_flags |= LL_SBI_AGL_ENABLED; + sbi->ll_sb = sb; + return sbi; } @@ -145,7 +148,7 @@ static void ll_free_sbi(struct super_block *sb) spin_lock(&ll_sb_lock); list_del(&sbi->ll_list); spin_unlock(&ll_sb_lock); - OBD_FREE(sbi, sizeof(*sbi)); + kfree(sbi); } } @@ -177,15 +180,14 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, osfs = kzalloc(sizeof(*osfs), GFP_NOFS); if (!osfs) { - OBD_FREE_PTR(data); + kfree(data); return -ENOMEM; } - if (proc_lustre_fs_root) { - err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb, - dt, md); + if (llite_root != NULL) { + err = ldebugfs_register_mountpoint(llite_root, sb, dt, md); if (err < 0) - CERROR("could not register mount in /proc/fs/lustre\n"); + CERROR("could not register mount in <debugfs>/lustre/llite\n"); } /* indicate the features supported by this client */ @@ -227,14 +229,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (sbi->ll_flags & LL_SBI_USER_XATTR) data->ocd_connect_flags |= OBD_CONNECT_XATTR; -#ifdef HAVE_MS_FLOCK_LOCK - /* force vfs to use lustre handler for flock() calls - bug 10743 */ - sb->s_flags |= MS_FLOCK_LOCK; -#endif -#ifdef MS_HAS_NEW_AOPS - sb->s_flags |= MS_HAS_NEW_AOPS; -#endif - if (sbi->ll_flags & LL_SBI_FLOCK) sbi->ll_fop = &ll_file_operations_flock; else if (sbi->ll_flags & LL_SBI_LOCALFLOCK) @@ -292,11 +286,15 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, char *buf; buf = kzalloc(PAGE_CACHE_SIZE, GFP_KERNEL); + if (!buf) { + err = -ENOMEM; + goto out_md_fid; + } obd_connect_flags2str(buf, PAGE_CACHE_SIZE, valid ^ CLIENT_CONNECT_MDT_REQD, ","); LCONSOLE_ERROR_MSG(0x170, "Server %s does not support feature(s) needed for correct operation of this client (%s). Please upgrade server or downgrade client.\n", sbi->ll_md_exp->exp_obd->obd_name, buf); - OBD_FREE(buf, PAGE_CACHE_SIZE); + kfree(buf); err = -EPROTO; goto out_md_fid; } @@ -316,7 +314,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, sb->s_magic = LL_SUPER_MAGIC; sb->s_maxbytes = MAX_LFS_FILESIZE; sbi->ll_namelen = osfs->os_namelen; - sbi->ll_max_rw_chunk = LL_DEFAULT_MAX_RW_CHUNK; if ((sbi->ll_flags & LL_SBI_USER_XATTR) && !(data->ocd_connect_flags & OBD_CONNECT_XATTR)) { @@ -408,7 +405,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (!OBD_FAIL_CHECK(OBD_FAIL_OSC_CONNECT_CKSUM)) { /* OBD_CONNECT_CKSUM should always be set, even if checksums are * disabled by default, because it can still be enabled on the - * fly via /proc. As a consequence, we still need to come to an + * fly via /sys. As a consequence, we still need to come to an * agreement on the supported algorithms at connect time */ data->ocd_connect_flags |= OBD_CONNECT_CKSUM; @@ -501,7 +498,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, err = md_getattr(sbi->ll_md_exp, op_data, &request); if (oc) capa_put(oc); - OBD_FREE_PTR(op_data); + kfree(op_data); if (err) { CERROR("%s: md_getattr failed for root: rc = %d\n", sbi->ll_md_exp->exp_obd->obd_name, err); @@ -582,10 +579,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), &sbi->ll_fsid); } - if (data != NULL) - OBD_FREE_PTR(data); - if (osfs != NULL) - OBD_FREE_PTR(osfs); + kfree(data); + kfree(osfs); return err; out_root: @@ -603,11 +598,9 @@ out_md: obd_disconnect(sbi->ll_md_exp); sbi->ll_md_exp = NULL; out: - if (data != NULL) - OBD_FREE_PTR(data); - if (osfs != NULL) - OBD_FREE_PTR(osfs); - lprocfs_unregister_mountpoint(sbi); + kfree(data); + kfree(osfs); + ldebugfs_unregister_mountpoint(sbi); return err; } @@ -688,7 +681,7 @@ static void client_common_put_super(struct super_block *sb) * see LU-2543. */ obd_zombie_barrier(); - lprocfs_unregister_mountpoint(sbi); + ldebugfs_unregister_mountpoint(sbi); obd_fid_fini(sbi->ll_md_exp->exp_obd); obd_disconnect(sbi->ll_md_exp); @@ -916,8 +909,6 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) char *dt = NULL, *md = NULL; char *profilenm = get_profile_name(sb); struct config_llog_instance *cfg; - /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */ - const int instlen = sizeof(cfg->cfg_instance) * 2 + 2; int err; CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb); @@ -929,10 +920,10 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) try_module_get(THIS_MODULE); /* client additional sb info */ - lsi->lsi_llsbi = sbi = ll_init_sbi(); + lsi->lsi_llsbi = sbi = ll_init_sbi(sb); if (!sbi) { module_put(THIS_MODULE); - OBD_FREE_PTR(cfg); + kfree(cfg); return -ENOMEM; } @@ -993,16 +984,14 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) err = client_common_fill_super(sb, md, dt, mnt); out_free: - if (md) - OBD_FREE(md, strlen(lprof->lp_md) + instlen + 2); - if (dt) - OBD_FREE(dt, strlen(lprof->lp_dt) + instlen + 2); + kfree(md); + kfree(dt); if (err) ll_put_super(sb); else if (sbi->ll_flags & LL_SBI_VERBOSE) LCONSOLE_WARN("Mounted %s\n", profilenm); - OBD_FREE_PTR(cfg); + kfree(cfg); return err; } /* ll_fill_super */ @@ -1126,8 +1115,7 @@ void ll_clear_inode(struct inode *inode) ll_md_real_close(inode, FMODE_READ); if (S_ISLNK(inode->i_mode) && lli->lli_symlink_name) { - OBD_FREE(lli->lli_symlink_name, - strlen(lli->lli_symlink_name) + 1); + kfree(lli->lli_symlink_name); lli->lli_symlink_name = NULL; } @@ -1957,7 +1945,7 @@ void ll_umount_begin(struct super_block *sb) obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp, sizeof(*ioc_data), ioc_data, NULL); - OBD_FREE_PTR(ioc_data); + kfree(ioc_data); } /* Really, we'd like to wait until there are no requests outstanding, @@ -2236,7 +2224,7 @@ void ll_finish_md_op_data(struct md_op_data *op_data) { capa_put(op_data->op_capa1); capa_put(op_data->op_capa2); - OBD_FREE_PTR(op_data); + kfree(op_data); } int ll_show_options(struct seq_file *seq, struct dentry *dentry) diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index db43b81386f7..8d1c253d4669 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -116,7 +116,7 @@ struct inode *search_inode_for_lustre(struct super_block *sb, /* mds_fid2dentry ignores f_type */ rc = md_getattr(sbi->ll_md_exp, op_data, &req); - OBD_FREE_PTR(op_data); + kfree(op_data); if (rc) { CERROR("can't get object attrs, fid "DFID", rc %d\n", PFID(fid), rc); diff --git a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c index f4da156f3874..c8a450b5cb18 100644 --- a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c +++ b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c @@ -94,7 +94,7 @@ static void rce_free(struct rmtacl_ctl_entry *rce) if (!list_empty(&rce->rce_list)) list_del(&rce->rce_list); - OBD_FREE_PTR(rce); + kfree(rce); } static struct rmtacl_ctl_entry *__rct_search(struct rmtacl_ctl_table *rct, @@ -205,7 +205,7 @@ void ee_free(struct eacl_entry *ee) if (ee->ee_acl) lustre_ext_acl_xattr_free(ee->ee_acl); - OBD_FREE_PTR(ee); + kfree(ee); } static struct eacl_entry *__et_search_del(struct eacl_table *et, pid_t key, diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 413a8408e3f5..cc00fd10fbcf 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -840,9 +840,9 @@ out_mem4: out_mem3: while (i--) put_disk(disks[i]); - OBD_FREE(disks, max_loop * sizeof(*disks)); + kfree(disks); out_mem2: - OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev)); + kfree(loop_dev); out_mem1: unregister_blkdev(lloop_major, "lloop"); ll_iocontrol_unregister(ll_iocontrol_magic); @@ -863,8 +863,8 @@ static void lloop_exit(void) unregister_blkdev(lloop_major, "lloop"); - OBD_FREE(disks, max_loop * sizeof(*disks)); - OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev)); + kfree(disks); + kfree(loop_dev); } module_init(lloop_init); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 83a9b85474e1..486dca6077de 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -48,31 +48,33 @@ static struct file_operations ll_rw_extents_stats_fops; static struct file_operations ll_rw_extents_stats_pp_fops; static struct file_operations ll_rw_offset_stats_fops; -static int ll_blksize_seq_show(struct seq_file *m, void *v) +static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); struct obd_statfs osfs; int rc; - LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(sbi->ll_sb, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - seq_printf(m, "%u\n", osfs.os_bsize); + return sprintf(buf, "%u\n", osfs.os_bsize); return rc; } -LPROC_SEQ_FOPS_RO(ll_blksize); +LUSTRE_RO_ATTR(blocksize); -static int ll_kbytestotal_seq_show(struct seq_file *m, void *v) +static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); struct obd_statfs osfs; int rc; - LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(sbi->ll_sb, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { @@ -82,21 +84,22 @@ static int ll_kbytestotal_seq_show(struct seq_file *m, void *v) while (blk_size >>= 1) result <<= 1; - seq_printf(m, "%llu\n", result); + rc = sprintf(buf, "%llu\n", result); } return rc; } -LPROC_SEQ_FOPS_RO(ll_kbytestotal); +LUSTRE_RO_ATTR(kbytestotal); -static int ll_kbytesfree_seq_show(struct seq_file *m, void *v) +static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); struct obd_statfs osfs; int rc; - LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(sbi->ll_sb, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { @@ -106,21 +109,22 @@ static int ll_kbytesfree_seq_show(struct seq_file *m, void *v) while (blk_size >>= 1) result <<= 1; - seq_printf(m, "%llu\n", result); + rc = sprintf(buf, "%llu\n", result); } return rc; } -LPROC_SEQ_FOPS_RO(ll_kbytesfree); +LUSTRE_RO_ATTR(kbytesfree); -static int ll_kbytesavail_seq_show(struct seq_file *m, void *v) +static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); struct obd_statfs osfs; int rc; - LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(sbi->ll_sb, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) { @@ -130,81 +134,79 @@ static int ll_kbytesavail_seq_show(struct seq_file *m, void *v) while (blk_size >>= 1) result <<= 1; - seq_printf(m, "%llu\n", result); + rc = sprintf(buf, "%llu\n", result); } return rc; } -LPROC_SEQ_FOPS_RO(ll_kbytesavail); +LUSTRE_RO_ATTR(kbytesavail); -static int ll_filestotal_seq_show(struct seq_file *m, void *v) +static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); struct obd_statfs osfs; int rc; - LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(sbi->ll_sb, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - seq_printf(m, "%llu\n", osfs.os_files); + return sprintf(buf, "%llu\n", osfs.os_files); return rc; } -LPROC_SEQ_FOPS_RO(ll_filestotal); +LUSTRE_RO_ATTR(filestotal); -static int ll_filesfree_seq_show(struct seq_file *m, void *v) +static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); struct obd_statfs osfs; int rc; - LASSERT(sb != NULL); - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(sbi->ll_sb, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - seq_printf(m, "%llu\n", osfs.os_ffree); + return sprintf(buf, "%llu\n", osfs.os_ffree); return rc; } -LPROC_SEQ_FOPS_RO(ll_filesfree); +LUSTRE_RO_ATTR(filesfree); -static int ll_client_type_seq_show(struct seq_file *m, void *v) +static ssize_t client_type_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)m->private); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - LASSERT(sbi != NULL); - - if (sbi->ll_flags & LL_SBI_RMT_CLIENT) - seq_puts(m, "remote client\n"); - else - seq_puts(m, "local client\n"); - - return 0; + return sprintf(buf, "%s client\n", + sbi->ll_flags & LL_SBI_RMT_CLIENT ? "remote" : "local"); } -LPROC_SEQ_FOPS_RO(ll_client_type); +LUSTRE_RO_ATTR(client_type); -static int ll_fstype_seq_show(struct seq_file *m, void *v) +static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - LASSERT(sb != NULL); - seq_printf(m, "%s\n", sb->s_type->name); - return 0; + return sprintf(buf, "%s\n", sbi->ll_sb->s_type->name); } -LPROC_SEQ_FOPS_RO(ll_fstype); +LUSTRE_RO_ATTR(fstype); -static int ll_sb_uuid_seq_show(struct seq_file *m, void *v) +static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = (struct super_block *)m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - LASSERT(sb != NULL); - seq_printf(m, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid); - return 0; + return sprintf(buf, "%s\n", sbi->ll_sb_uuid.uuid); } -LPROC_SEQ_FOPS_RO(ll_sb_uuid); +LUSTRE_RO_ATTR(uuid); static int ll_site_stats_seq_show(struct seq_file *m, void *v) { @@ -218,10 +220,11 @@ static int ll_site_stats_seq_show(struct seq_file *m, void *v) } LPROC_SEQ_FOPS_RO(ll_site_stats); -static int ll_max_readahead_mb_seq_show(struct seq_file *m, void *v) +static ssize_t max_read_ahead_mb_show(struct kobject *kobj, + struct attribute *attr, char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); long pages_number; int mult; @@ -230,23 +233,27 @@ static int ll_max_readahead_mb_seq_show(struct seq_file *m, void *v) spin_unlock(&sbi->ll_lock); mult = 1 << (20 - PAGE_CACHE_SHIFT); - return lprocfs_seq_read_frac_helper(m, pages_number, mult); + return lprocfs_read_frac_helper(buf, PAGE_SIZE, pages_number, mult); } -static ssize_t ll_max_readahead_mb_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_read_ahead_mb_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int mult, rc, pages_number; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long pages_number; - mult = 1 << (20 - PAGE_CACHE_SHIFT); - rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); + rc = kstrtoul(buffer, 10, &pages_number); if (rc) return rc; - if (pages_number < 0 || pages_number > totalram_pages / 2) { + pages_number *= 1 << (20 - PAGE_CACHE_SHIFT); /* MB -> pages */ + + if (pages_number > totalram_pages / 2) { + CERROR("can't set file readahead more than %lu MB\n", totalram_pages >> (20 - PAGE_CACHE_SHIFT + 1)); /*1/2 of RAM*/ return -ERANGE; @@ -258,12 +265,14 @@ static ssize_t ll_max_readahead_mb_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_max_readahead_mb); +LUSTRE_RW_ATTR(max_read_ahead_mb); -static int ll_max_readahead_per_file_mb_seq_show(struct seq_file *m, void *v) +static ssize_t max_read_ahead_per_file_mb_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); long pages_number; int mult; @@ -272,24 +281,24 @@ static int ll_max_readahead_per_file_mb_seq_show(struct seq_file *m, void *v) spin_unlock(&sbi->ll_lock); mult = 1 << (20 - PAGE_CACHE_SHIFT); - return lprocfs_seq_read_frac_helper(m, pages_number, mult); + return lprocfs_read_frac_helper(buf, PAGE_SIZE, pages_number, mult); } -static ssize_t ll_max_readahead_per_file_mb_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_read_ahead_per_file_mb_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int mult, rc, pages_number; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long pages_number; - mult = 1 << (20 - PAGE_CACHE_SHIFT); - rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); + rc = kstrtoul(buffer, 10, &pages_number); if (rc) return rc; - if (pages_number < 0 || - pages_number > sbi->ll_ra_info.ra_max_pages) { + if (pages_number > sbi->ll_ra_info.ra_max_pages) { CERROR("can't set file readahead more than max_read_ahead_mb %lu MB\n", sbi->ll_ra_info.ra_max_pages); return -ERANGE; @@ -301,12 +310,14 @@ static ssize_t ll_max_readahead_per_file_mb_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_max_readahead_per_file_mb); +LUSTRE_RW_ATTR(max_read_ahead_per_file_mb); -static int ll_max_read_ahead_whole_mb_seq_show(struct seq_file *m, void *unused) +static ssize_t max_read_ahead_whole_mb_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); long pages_number; int mult; @@ -315,26 +326,26 @@ static int ll_max_read_ahead_whole_mb_seq_show(struct seq_file *m, void *unused) spin_unlock(&sbi->ll_lock); mult = 1 << (20 - PAGE_CACHE_SHIFT); - return lprocfs_seq_read_frac_helper(m, pages_number, mult); + return lprocfs_read_frac_helper(buf, PAGE_SIZE, pages_number, mult); } -static ssize_t ll_max_read_ahead_whole_mb_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_read_ahead_whole_mb_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int mult, rc, pages_number; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long pages_number; - mult = 1 << (20 - PAGE_CACHE_SHIFT); - rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); + rc = kstrtoul(buffer, 10, &pages_number); if (rc) return rc; /* Cap this at the current max readahead window size, the readahead * algorithm does this anyway so it's pointless to set it larger. */ - if (pages_number < 0 || - pages_number > sbi->ll_ra_info.ra_max_pages_per_file) { + if (pages_number > sbi->ll_ra_info.ra_max_pages_per_file) { CERROR("can't set max_read_ahead_whole_mb more than max_read_ahead_per_file_mb: %lu\n", sbi->ll_ra_info.ra_max_pages_per_file >> (20 - PAGE_CACHE_SHIFT)); return -ERANGE; @@ -346,7 +357,7 @@ static ssize_t ll_max_read_ahead_whole_mb_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_max_read_ahead_whole_mb); +LUSTRE_RW_ATTR(max_read_ahead_whole_mb); static int ll_max_cached_mb_seq_show(struct seq_file *m, void *v) { @@ -469,28 +480,30 @@ out: } LPROC_SEQ_FOPS(ll_max_cached_mb); -static int ll_checksum_seq_show(struct seq_file *m, void *v) +static ssize_t checksum_pages_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - seq_printf(m, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0); - return 0; + return sprintf(buf, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0); } -static ssize_t ll_checksum_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t checksum_pages_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int val, rc; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long val; if (!sbi->ll_dt_exp) /* Not set up yet */ return -EAGAIN; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; if (val) @@ -505,154 +518,146 @@ static ssize_t ll_checksum_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_checksum); - -static int ll_max_rw_chunk_seq_show(struct seq_file *m, void *v) -{ - struct super_block *sb = m->private; - - seq_printf(m, "%lu\n", ll_s2sbi(sb)->ll_max_rw_chunk); - return 0; -} - -static ssize_t ll_max_rw_chunk_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) -{ - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - int rc, val; - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - ll_s2sbi(sb)->ll_max_rw_chunk = val; - return count; -} -LPROC_SEQ_FOPS(ll_max_rw_chunk); +LUSTRE_RW_ATTR(checksum_pages); -static int ll_rd_track_id(struct seq_file *m, enum stats_track_type type) +static ssize_t ll_rd_track_id(struct kobject *kobj, char *buf, + enum stats_track_type type) { - struct super_block *sb = m->private; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - if (ll_s2sbi(sb)->ll_stats_track_type == type) - seq_printf(m, "%d\n", ll_s2sbi(sb)->ll_stats_track_id); - else if (ll_s2sbi(sb)->ll_stats_track_type == STATS_TRACK_ALL) - seq_puts(m, "0 (all)\n"); + if (sbi->ll_stats_track_type == type) + return sprintf(buf, "%d\n", sbi->ll_stats_track_id); + else if (sbi->ll_stats_track_type == STATS_TRACK_ALL) + return sprintf(buf, "0 (all)\n"); else - seq_puts(m, "untracked\n"); - - return 0; + return sprintf(buf, "untracked\n"); } -static int ll_wr_track_id(const char __user *buffer, unsigned long count, - void *data, enum stats_track_type type) +static ssize_t ll_wr_track_id(struct kobject *kobj, const char *buffer, + size_t count, + enum stats_track_type type) { - struct super_block *sb = data; - int rc, pid; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long pid; - rc = lprocfs_write_helper(buffer, count, &pid); + rc = kstrtoul(buffer, 10, &pid); if (rc) return rc; - ll_s2sbi(sb)->ll_stats_track_id = pid; + sbi->ll_stats_track_id = pid; if (pid == 0) - ll_s2sbi(sb)->ll_stats_track_type = STATS_TRACK_ALL; + sbi->ll_stats_track_type = STATS_TRACK_ALL; else - ll_s2sbi(sb)->ll_stats_track_type = type; - lprocfs_clear_stats(ll_s2sbi(sb)->ll_stats); + sbi->ll_stats_track_type = type; + lprocfs_clear_stats(sbi->ll_stats); return count; } -static int ll_track_pid_seq_show(struct seq_file *m, void *v) +static ssize_t stats_track_pid_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - return ll_rd_track_id(m, STATS_TRACK_PID); + return ll_rd_track_id(kobj, buf, STATS_TRACK_PID); } -static ssize_t ll_track_pid_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stats_track_pid_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct seq_file *seq = file->private_data; - return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_PID); + return ll_wr_track_id(kobj, buffer, count, STATS_TRACK_PID); } -LPROC_SEQ_FOPS(ll_track_pid); +LUSTRE_RW_ATTR(stats_track_pid); -static int ll_track_ppid_seq_show(struct seq_file *m, void *v) +static ssize_t stats_track_ppid_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - return ll_rd_track_id(m, STATS_TRACK_PPID); + return ll_rd_track_id(kobj, buf, STATS_TRACK_PPID); } -static ssize_t ll_track_ppid_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stats_track_ppid_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct seq_file *seq = file->private_data; - return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_PPID); + return ll_wr_track_id(kobj, buffer, count, STATS_TRACK_PPID); } -LPROC_SEQ_FOPS(ll_track_ppid); +LUSTRE_RW_ATTR(stats_track_ppid); -static int ll_track_gid_seq_show(struct seq_file *m, void *v) +static ssize_t stats_track_gid_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - return ll_rd_track_id(m, STATS_TRACK_GID); + return ll_rd_track_id(kobj, buf, STATS_TRACK_GID); } -static ssize_t ll_track_gid_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stats_track_gid_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct seq_file *seq = file->private_data; - return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_GID); + return ll_wr_track_id(kobj, buffer, count, STATS_TRACK_GID); } -LPROC_SEQ_FOPS(ll_track_gid); +LUSTRE_RW_ATTR(stats_track_gid); -static int ll_statahead_max_seq_show(struct seq_file *m, void *v) +static ssize_t statahead_max_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - seq_printf(m, "%u\n", sbi->ll_sa_max); - return 0; + return sprintf(buf, "%u\n", sbi->ll_sa_max); } -static ssize_t ll_statahead_max_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t statahead_max_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int val, rc; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; - if (val >= 0 && val <= LL_SA_RPC_MAX) + if (val <= LL_SA_RPC_MAX) sbi->ll_sa_max = val; else - CERROR("Bad statahead_max value %d. Valid values are in the range [0, %d]\n", + CERROR("Bad statahead_max value %lu. Valid values are in the range [0, %d]\n", val, LL_SA_RPC_MAX); return count; } -LPROC_SEQ_FOPS(ll_statahead_max); +LUSTRE_RW_ATTR(statahead_max); -static int ll_statahead_agl_seq_show(struct seq_file *m, void *v) +static ssize_t statahead_agl_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - seq_printf(m, "%u\n", sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0); - return 0; + return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0); } -static ssize_t ll_statahead_agl_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t statahead_agl_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int val, rc; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -663,7 +668,7 @@ static ssize_t ll_statahead_agl_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_statahead_agl); +LUSTRE_RW_ATTR(statahead_agl); static int ll_statahead_stats_seq_show(struct seq_file *m, void *v) { @@ -681,24 +686,27 @@ static int ll_statahead_stats_seq_show(struct seq_file *m, void *v) } LPROC_SEQ_FOPS_RO(ll_statahead_stats); -static int ll_lazystatfs_seq_show(struct seq_file *m, void *v) +static ssize_t lazystatfs_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - seq_printf(m, "%u\n", sbi->ll_flags & LL_SBI_LAZYSTATFS ? 1 : 0); - return 0; + return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_LAZYSTATFS ? 1 : 0); } -static ssize_t ll_lazystatfs_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t lazystatfs_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct super_block *sb = ((struct seq_file *)file->private_data)->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int val, rc; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -709,12 +717,14 @@ static ssize_t ll_lazystatfs_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_lazystatfs); +LUSTRE_RW_ATTR(lazystatfs); -static int ll_max_easize_seq_show(struct seq_file *m, void *v) +static ssize_t max_easize_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); unsigned int ealen; int rc; @@ -722,15 +732,16 @@ static int ll_max_easize_seq_show(struct seq_file *m, void *v) if (rc) return rc; - seq_printf(m, "%u\n", ealen); - return 0; + return sprintf(buf, "%u\n", ealen); } -LPROC_SEQ_FOPS_RO(ll_max_easize); +LUSTRE_RO_ATTR(max_easize); -static int ll_default_easize_seq_show(struct seq_file *m, void *v) +static ssize_t default_easize_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); unsigned int ealen; int rc; @@ -738,42 +749,9 @@ static int ll_default_easize_seq_show(struct seq_file *m, void *v) if (rc) return rc; - seq_printf(m, "%u\n", ealen); - return 0; -} -LPROC_SEQ_FOPS_RO(ll_default_easize); - -static int ll_max_cookiesize_seq_show(struct seq_file *m, void *v) -{ - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - unsigned int cookielen; - int rc; - - rc = ll_get_max_cookiesize(sbi, &cookielen); - if (rc) - return rc; - - seq_printf(m, "%u\n", cookielen); - return 0; -} -LPROC_SEQ_FOPS_RO(ll_max_cookiesize); - -static int ll_default_cookiesize_seq_show(struct seq_file *m, void *v) -{ - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - unsigned int cookielen; - int rc; - - rc = ll_get_default_cookiesize(sbi, &cookielen); - if (rc) - return rc; - - seq_printf(m, "%u\n", cookielen); - return 0; + return sprintf(buf, "%u\n", ealen); } -LPROC_SEQ_FOPS_RO(ll_default_cookiesize); +LUSTRE_RO_ATTR(default_easize); static int ll_sbi_flags_seq_show(struct seq_file *m, void *v) { @@ -799,26 +777,27 @@ static int ll_sbi_flags_seq_show(struct seq_file *m, void *v) } LPROC_SEQ_FOPS_RO(ll_sbi_flags); -static int ll_xattr_cache_seq_show(struct seq_file *m, void *v) +static ssize_t xattr_cache_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct super_block *sb = m->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); - seq_printf(m, "%u\n", sbi->ll_xattr_cache_enabled); - - return 0; + return sprintf(buf, "%u\n", sbi->ll_xattr_cache_enabled); } -static ssize_t ll_xattr_cache_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t xattr_cache_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct seq_file *seq = file->private_data; - struct super_block *sb = seq->private; - struct ll_sb_info *sbi = ll_s2sbi(sb); - int val, rc; + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -832,46 +811,59 @@ static ssize_t ll_xattr_cache_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ll_xattr_cache); +LUSTRE_RW_ATTR(xattr_cache); static struct lprocfs_vars lprocfs_llite_obd_vars[] = { - { "uuid", &ll_sb_uuid_fops, NULL, 0 }, /* { "mntpt_path", ll_rd_path, 0, 0 }, */ - { "fstype", &ll_fstype_fops, NULL, 0 }, { "site", &ll_site_stats_fops, NULL, 0 }, - { "blocksize", &ll_blksize_fops, NULL, 0 }, - { "kbytestotal", &ll_kbytestotal_fops, NULL, 0 }, - { "kbytesfree", &ll_kbytesfree_fops, NULL, 0 }, - { "kbytesavail", &ll_kbytesavail_fops, NULL, 0 }, - { "filestotal", &ll_filestotal_fops, NULL, 0 }, - { "filesfree", &ll_filesfree_fops, NULL, 0 }, - { "client_type", &ll_client_type_fops, NULL, 0 }, /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ - { "max_read_ahead_mb", &ll_max_readahead_mb_fops, NULL }, - { "max_read_ahead_per_file_mb", &ll_max_readahead_per_file_mb_fops, - NULL }, - { "max_read_ahead_whole_mb", &ll_max_read_ahead_whole_mb_fops, NULL }, { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, - { "checksum_pages", &ll_checksum_fops, NULL }, - { "max_rw_chunk", &ll_max_rw_chunk_fops, NULL }, - { "stats_track_pid", &ll_track_pid_fops, NULL }, - { "stats_track_ppid", &ll_track_ppid_fops, NULL }, - { "stats_track_gid", &ll_track_gid_fops, NULL }, - { "statahead_max", &ll_statahead_max_fops, NULL }, - { "statahead_agl", &ll_statahead_agl_fops, NULL }, { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, - { "lazystatfs", &ll_lazystatfs_fops, NULL }, - { "max_easize", &ll_max_easize_fops, NULL, 0 }, - { "default_easize", &ll_default_easize_fops, NULL, 0 }, - { "max_cookiesize", &ll_max_cookiesize_fops, NULL, 0 }, - { "default_cookiesize", &ll_default_cookiesize_fops, NULL, 0 }, { "sbi_flags", &ll_sbi_flags_fops, NULL, 0 }, - { "xattr_cache", &ll_xattr_cache_fops, NULL, 0 }, { NULL } }; #define MAX_STRING_SIZE 128 +static struct attribute *llite_attrs[] = { + &lustre_attr_blocksize.attr, + &lustre_attr_kbytestotal.attr, + &lustre_attr_kbytesfree.attr, + &lustre_attr_kbytesavail.attr, + &lustre_attr_filestotal.attr, + &lustre_attr_filesfree.attr, + &lustre_attr_client_type.attr, + &lustre_attr_fstype.attr, + &lustre_attr_uuid.attr, + &lustre_attr_max_read_ahead_mb.attr, + &lustre_attr_max_read_ahead_per_file_mb.attr, + &lustre_attr_max_read_ahead_whole_mb.attr, + &lustre_attr_checksum_pages.attr, + &lustre_attr_stats_track_pid.attr, + &lustre_attr_stats_track_ppid.attr, + &lustre_attr_stats_track_gid.attr, + &lustre_attr_statahead_max.attr, + &lustre_attr_statahead_agl.attr, + &lustre_attr_lazystatfs.attr, + &lustre_attr_max_easize.attr, + &lustre_attr_default_easize.attr, + &lustre_attr_xattr_cache.attr, + NULL, +}; + +static void llite_sb_release(struct kobject *kobj) +{ + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kobj); + complete(&sbi->ll_kobj_unregister); +} + +static struct kobj_type llite_ktype = { + .default_attrs = llite_attrs, + .sysfs_ops = &lustre_sysfs_ops, + .release = llite_sb_release, +}; + static const struct llite_file_opcode { __u32 opcode; __u32 type; @@ -958,24 +950,18 @@ static const char *ra_stat_string[] = { [RA_STAT_WRONG_GRAB_PAGE] = "wrong page from grab_cache_page", }; -LPROC_SEQ_FOPS_RO_TYPE(llite, name); -LPROC_SEQ_FOPS_RO_TYPE(llite, uuid); - -int lprocfs_register_mountpoint(struct proc_dir_entry *parent, - struct super_block *sb, char *osc, char *mdc) +int ldebugfs_register_mountpoint(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc) { - struct lprocfs_vars lvars[2]; struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; - struct proc_dir_entry *dir; + struct dentry *dir; char name[MAX_STRING_SIZE + 1], *ptr; int err, id, len, rc; - memset(lvars, 0, sizeof(lvars)); name[MAX_STRING_SIZE] = '\0'; - lvars[0].name = name; LASSERT(sbi != NULL); LASSERT(mdc != NULL); @@ -991,30 +977,32 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len, lsi->lsi_lmd->lmd_profile, sb); - sbi->ll_proc_root = lprocfs_register(name, parent, NULL, NULL); - if (IS_ERR(sbi->ll_proc_root)) { - err = PTR_ERR(sbi->ll_proc_root); - sbi->ll_proc_root = NULL; + dir = ldebugfs_register(name, parent, NULL, NULL); + if (IS_ERR_OR_NULL(dir)) { + err = dir ? PTR_ERR(dir) : -ENOMEM; + sbi->ll_debugfs_entry = NULL; return err; } + sbi->ll_debugfs_entry = dir; - rc = lprocfs_seq_create(sbi->ll_proc_root, "dump_page_cache", 0444, - &vvp_dump_pgcache_file_ops, sbi); + rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "dump_page_cache", 0444, + &vvp_dump_pgcache_file_ops, sbi); if (rc) CWARN("Error adding the dump_page_cache file\n"); - rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats", 0644, - &ll_rw_extents_stats_fops, sbi); + rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "extents_stats", 0644, + &ll_rw_extents_stats_fops, sbi); if (rc) CWARN("Error adding the extent_stats file\n"); - rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats_per_process", - 0644, &ll_rw_extents_stats_pp_fops, sbi); + rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, + "extents_stats_per_process", + 0644, &ll_rw_extents_stats_pp_fops, sbi); if (rc) CWARN("Error adding the extents_stats_per_process file\n"); - rc = lprocfs_seq_create(sbi->ll_proc_root, "offset_stats", 0644, - &ll_rw_offset_stats_fops, sbi); + rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "offset_stats", 0644, + &ll_rw_offset_stats_fops, sbi); if (rc) CWARN("Error adding the offset_stats file\n"); @@ -1040,7 +1028,8 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, (type & LPROCFS_CNTR_AVGMINMAX), llite_opcode_table[id].opname, ptr); } - err = lprocfs_register_stats(sbi->ll_proc_root, "stats", sbi->ll_stats); + err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "stats", + sbi->ll_stats); if (err) goto out; @@ -1054,76 +1043,53 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, for (id = 0; id < ARRAY_SIZE(ra_stat_string); id++) lprocfs_counter_init(sbi->ll_ra_stats, id, 0, ra_stat_string[id], "pages"); - err = lprocfs_register_stats(sbi->ll_proc_root, "read_ahead_stats", + + err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "read_ahead_stats", sbi->ll_ra_stats); if (err) goto out; - err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_llite_obd_vars, sb); + err = ldebugfs_add_vars(sbi->ll_debugfs_entry, + lprocfs_llite_obd_vars, sb); if (err) goto out; - /* MDC info */ - obd = class_name2obd(mdc); - - LASSERT(obd != NULL); - LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); - LASSERT(obd->obd_type->typ_name != NULL); - - dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root); - if (dir == NULL) { - err = -ENOMEM; - goto out; - } - - snprintf(name, MAX_STRING_SIZE, "common_name"); - lvars[0].fops = &llite_name_fops; - err = lprocfs_add_vars(dir, lvars, obd); + sbi->ll_kobj.kset = llite_kset; + init_completion(&sbi->ll_kobj_unregister); + err = kobject_init_and_add(&sbi->ll_kobj, &llite_ktype, NULL, + "%s", name); if (err) goto out; - snprintf(name, MAX_STRING_SIZE, "uuid"); - lvars[0].fops = &llite_uuid_fops; - err = lprocfs_add_vars(dir, lvars, obd); + /* MDC info */ + obd = class_name2obd(mdc); + + err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj, + obd->obd_type->typ_name); if (err) goto out; /* OSC */ obd = class_name2obd(osc); - LASSERT(obd != NULL); - LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); - LASSERT(obd->obd_type->typ_name != NULL); - - dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root); - if (dir == NULL) { - err = -ENOMEM; - goto out; - } - - snprintf(name, MAX_STRING_SIZE, "common_name"); - lvars[0].fops = &llite_name_fops; - err = lprocfs_add_vars(dir, lvars, obd); - if (err) - goto out; - - snprintf(name, MAX_STRING_SIZE, "uuid"); - lvars[0].fops = &llite_uuid_fops; - err = lprocfs_add_vars(dir, lvars, obd); + err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj, + obd->obd_type->typ_name); out: if (err) { - lprocfs_remove(&sbi->ll_proc_root); + ldebugfs_remove(&sbi->ll_debugfs_entry); lprocfs_free_stats(&sbi->ll_ra_stats); lprocfs_free_stats(&sbi->ll_stats); } return err; } -void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) +void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi) { - if (sbi->ll_proc_root) { - lprocfs_remove(&sbi->ll_proc_root); + if (sbi->ll_debugfs_entry) { + ldebugfs_remove(&sbi->ll_debugfs_entry); + kobject_put(&sbi->ll_kobj); + wait_for_completion(&sbi->ll_kobj_unregister); lprocfs_free_stats(&sbi->ll_ra_stats); lprocfs_free_stats(&sbi->ll_stats); } @@ -1531,6 +1497,5 @@ LPROC_SEQ_FOPS(ll_rw_offset_stats); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = NULL; lvars->obd_vars = lprocfs_llite_obd_vars; } diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 5a25dcd10126..72ce6e72845f 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -665,7 +665,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, out_release: ll_intent_release(it); - OBD_FREE(it, sizeof(*it)); + kfree(it); return rc; } diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index c6c824356464..b17b7cea582c 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -200,12 +200,12 @@ static inline int ll_get_user_pages(int rw, unsigned long user_addr, *max_pages = (user_addr + size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; *max_pages -= user_addr >> PAGE_CACHE_SHIFT; - OBD_ALLOC_LARGE(*pages, *max_pages * sizeof(**pages)); + *pages = libcfs_kvzalloc(*max_pages * sizeof(**pages), GFP_NOFS); if (*pages) { result = get_user_pages_fast(user_addr, *max_pages, (rw == READ), *pages); if (unlikely(result <= 0)) - OBD_FREE_LARGE(*pages, *max_pages * sizeof(**pages)); + kvfree(*pages); } return result; @@ -517,7 +517,6 @@ static int ll_migratepage(struct address_space *mapping, } #endif -#ifndef MS_HAS_NEW_AOPS const struct address_space_operations ll_aops = { .readpage = ll_readpage, .direct_IO = ll_direct_IO_26, @@ -532,22 +531,3 @@ const struct address_space_operations ll_aops = { .migratepage = ll_migratepage, #endif }; -#else -const struct address_space_operations_ext ll_aops = { - .orig_aops.readpage = ll_readpage, -/* .orig_aops.readpages = ll_readpages, */ - .orig_aops.direct_IO = ll_direct_IO_26, - .orig_aops.writepage = ll_writepage, - .orig_aops.writepages = ll_writepages, - .orig_aops.set_page_dirty = ll_set_page_dirty, - .orig_aops.prepare_write = ll_prepare_write, - .orig_aops.commit_write = ll_commit_write, - .orig_aops.invalidatepage = ll_invalidatepage, - .orig_aops.releasepage = ll_releasepage, -#ifdef CONFIG_MIGRATION - .orig_aops.migratepage = ll_migratepage, -#endif - .write_begin = ll_write_begin, - .write_end = ll_write_end -}; -#endif diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 7f8071242f23..f97371dd8539 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -312,7 +312,7 @@ static void ll_sa_entry_cleanup(struct ll_statahead_info *sai, entry->se_minfo = NULL; ll_intent_release(&minfo->mi_it); iput(minfo->mi_dir); - OBD_FREE_PTR(minfo); + kfree(minfo); } if (req) { @@ -336,7 +336,7 @@ static void ll_sa_entry_put(struct ll_statahead_info *sai, ll_sa_entry_cleanup(sai, entry); iput(entry->se_inode); - OBD_FREE(entry, entry->se_size); + kfree(entry); atomic_dec(&sai->sai_cache_count); } } @@ -544,7 +544,7 @@ static void ll_sai_put(struct ll_statahead_info *sai) LASSERT(agl_list_empty(sai)); iput(inode); - OBD_FREE_PTR(sai); + kfree(sai); } } @@ -772,7 +772,7 @@ out: if (rc != 0) { ll_intent_release(it); iput(dir); - OBD_FREE_PTR(minfo); + kfree(minfo); } if (sai != NULL) ll_sai_put(sai); @@ -786,8 +786,8 @@ static void sa_args_fini(struct md_enqueue_info *minfo, iput(minfo->mi_dir); capa_put(minfo->mi_data.op_capa1); capa_put(minfo->mi_data.op_capa2); - OBD_FREE_PTR(minfo); - OBD_FREE_PTR(einfo); + kfree(minfo); + kfree(einfo); } /** @@ -816,15 +816,15 @@ static int sa_args_init(struct inode *dir, struct inode *child, minfo = kzalloc(sizeof(*minfo), GFP_NOFS); if (!minfo) { - OBD_FREE_PTR(einfo); + kfree(einfo); return -ENOMEM; } op_data = ll_prep_md_op_data(&minfo->mi_data, dir, child, qstr->name, qstr->len, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) { - OBD_FREE_PTR(einfo); - OBD_FREE_PTR(minfo); + kfree(einfo); + kfree(minfo); return PTR_ERR(op_data); } @@ -1719,8 +1719,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, return -EAGAIN; out: - if (sai != NULL) - OBD_FREE_PTR(sai); + kfree(sai); spin_lock(&lli->lli_sa_lock); lli->lli_opendir_key = NULL; lli->lli_opendir_pid = 0; diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index a494f6271fa0..e4020ce8cb7b 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -89,7 +89,6 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)); static int __init init_lustre_lite(void) { - struct proc_dir_entry *entry; lnet_process_id_t lnet_id; struct timeval tv; int i, rc, seed[2]; @@ -128,15 +127,18 @@ static int __init init_lustre_lite(void) if (ll_rmtperm_hash_cachep == NULL) goto out_cache; - entry = lprocfs_register("llite", proc_lustre_root, NULL, NULL); - if (IS_ERR(entry)) { - rc = PTR_ERR(entry); - CERROR("cannot register '/proc/fs/lustre/llite': rc = %d\n", - rc); + llite_root = debugfs_create_dir("llite", debugfs_lustre_root); + if (IS_ERR_OR_NULL(llite_root)) { + rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; + llite_root = NULL; goto out_cache; } - proc_lustre_fs_root = entry; + llite_kset = kset_create_and_add("llite", NULL, lustre_kobj); + if (!llite_kset) { + rc = -ENOMEM; + goto out_debugfs; + } cfs_get_random_bytes(seed, sizeof(seed)); @@ -155,7 +157,7 @@ static int __init init_lustre_lite(void) setup_timer(&ll_capa_timer, ll_capa_timer_callback, 0); rc = ll_capa_thread_start(); if (rc != 0) - goto out_proc; + goto out_sysfs; rc = vvp_global_init(); if (rc != 0) @@ -176,8 +178,10 @@ out_vvp: out_capa: del_timer(&ll_capa_timer); ll_capa_thread_stop(); -out_proc: - lprocfs_remove(&proc_lustre_fs_root); +out_sysfs: + kset_unregister(llite_kset); +out_debugfs: + debugfs_remove(llite_root); out_cache: if (ll_inode_cachep != NULL) kmem_cache_destroy(ll_inode_cachep); @@ -200,7 +204,8 @@ static void __exit exit_lustre_lite(void) lustre_register_kill_super_cb(NULL); lustre_register_client_process_config(NULL); - lprocfs_remove(&proc_lustre_fs_root); + debugfs_remove(llite_root); + kset_unregister(llite_kset); ll_xattr_fini(); vvp_global_fini(); diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index 3711e671a4df..69b203651905 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -118,7 +118,7 @@ failed: return rc; } -static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) +static const char *ll_follow_link(struct dentry *dentry, void **cookie) { struct inode *inode = d_inode(dentry); struct ptlrpc_request *request = NULL; @@ -126,32 +126,22 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) char *symname = NULL; CDEBUG(D_VFSTRACE, "VFS Op\n"); - /* Limit the recursive symlink depth to 5 instead of default - * 8 links when kernel has 4k stack to prevent stack overflow. - * For 8k stacks we need to limit it to 7 for local servers. */ - if (THREAD_SIZE < 8192 && current->link_count >= 6) { - rc = -ELOOP; - } else if (THREAD_SIZE == 8192 && current->link_count >= 8) { - rc = -ELOOP; - } else { - ll_inode_size_lock(inode); - rc = ll_readlink_internal(inode, &request, &symname); - ll_inode_size_unlock(inode); - } + ll_inode_size_lock(inode); + rc = ll_readlink_internal(inode, &request, &symname); + ll_inode_size_unlock(inode); if (rc) { ptlrpc_req_finished(request); - request = NULL; - symname = ERR_PTR(rc); + return ERR_PTR(rc); } - nd_set_link(nd, symname); /* symname may contain a pointer to the request message buffer, * we delay request releasing until ll_put_link then. */ - return request; + *cookie = request; + return symname; } -static void ll_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) +static void ll_put_link(struct inode *unused, void *cookie) { ptlrpc_req_finished(cookie); } diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index fde41d7c5e3d..b8f6a8779fd3 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -253,7 +253,7 @@ int cl_sb_fini(struct super_block *sb) /**************************************************************************** * - * /proc/fs/lustre/llite/$MNT/dump_page_cache + * debugfs/lustre/llite/$MNT/dump_page_cache * ****************************************************************************/ @@ -517,7 +517,7 @@ static void vvp_pgcache_stop(struct seq_file *f, void *v) /* Nothing to do */ } -static struct seq_operations vvp_pgcache_ops = { +static const struct seq_operations vvp_pgcache_ops = { .start = vvp_pgcache_start, .next = vvp_pgcache_next, .stop = vvp_pgcache_stop, @@ -526,16 +526,17 @@ static struct seq_operations vvp_pgcache_ops = { static int vvp_dump_pgcache_seq_open(struct inode *inode, struct file *filp) { - struct ll_sb_info *sbi = PDE_DATA(inode); - struct seq_file *seq; - int result; + struct seq_file *seq; + int rc; - result = seq_open(filp, &vvp_pgcache_ops); - if (result == 0) { - seq = filp->private_data; - seq->private = sbi; - } - return result; + rc = seq_open(filp, &vvp_pgcache_ops); + if (rc) + return rc; + + seq = filp->private_data; + seq->private = inode->i_private; + + return 0; } const struct file_operations vvp_dump_pgcache_file_ops = { diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index e0fcbe1395fd..362a87d0d0d3 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -188,11 +188,11 @@ int ll_setxattr_common(struct inode *inode, const char *name, valid |= rce_ops2valid(rce->rce_ops); } #endif - oc = ll_mdscapa_get(inode); - rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc, - valid, name, pv, size, 0, flags, - ll_i2suppgid(inode), &req); - capa_put(oc); + oc = ll_mdscapa_get(inode); + rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc, + valid, name, pv, size, 0, flags, + ll_i2suppgid(inode), &req); + capa_put(oc); #ifdef CONFIG_FS_POSIX_ACL if (new_value != NULL) lustre_posix_acl_xattr_free(new_value, size); diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index 69ea92adf4f1..6956dec53fcc 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -144,7 +144,7 @@ static int ll_xattr_cache_add(struct list_head *cache, return 0; err_value: - OBD_FREE(xattr->xe_name, xattr->xe_namelen); + kfree(xattr->xe_name); err_name: OBD_SLAB_FREE_PTR(xattr, xattr_kmem); @@ -170,8 +170,8 @@ static int ll_xattr_cache_del(struct list_head *cache, if (ll_xattr_cache_find(cache, xattr_name, &xattr) == 0) { list_del(&xattr->xe_list); - OBD_FREE(xattr->xe_name, xattr->xe_namelen); - OBD_FREE(xattr->xe_value, xattr->xe_vallen); + kfree(xattr->xe_name); + kfree(xattr->xe_value); OBD_SLAB_FREE_PTR(xattr, xattr_kmem); return 0; diff --git a/drivers/staging/lustre/lustre/lmv/Makefile b/drivers/staging/lustre/lustre/lmv/Makefile index a7a15369af15..1a24299791d7 100644 --- a/drivers/staging/lustre/lustre/lmv/Makefile +++ b/drivers/staging/lustre/lustre/lmv/Makefile @@ -1,3 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += lmv.o -lmv-y := lmv_obd.o lmv_intent.o lmv_fld.o -lmv-$(CONFIG_PROC_FS) += lproc_lmv.o +lmv-y := lmv_obd.o lmv_intent.o lmv_fld.o lproc_lmv.o diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index d22d57b4ff38..cb35f6341fb2 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -99,7 +99,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, goto out; } - OBD_ALLOC_PTR(op_data); + op_data = kzalloc(sizeof(*op_data), GFP_NOFS); if (op_data == NULL) { rc = -ENOMEM; goto out; @@ -142,7 +142,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, it->d.lustre.it_lock_mode = pmode; out_free_op_data: - OBD_FREE_PTR(op_data); + kfree(op_data); out: if (rc && pmode) ldlm_lock_decref(&plock, pmode); diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index 852d78721ca9..b808728daee7 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -144,14 +144,8 @@ struct lmv_tgt_desc *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data, struct lu_fid *fid); /* lproc_lmv.c */ -#if defined(CONFIG_PROC_FS) void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars); -#else -static inline void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -#endif + extern struct file_operations lmv_proc_target_fops; #endif diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index b9459faf8645..ac5053cd5da5 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -199,7 +199,6 @@ static int lmv_connect(const struct lu_env *env, struct obd_uuid *cluuid, struct obd_connect_data *data, void *localdata) { - struct proc_dir_entry *lmv_proc_dir; struct lmv_obd *lmv = &obd->u.lmv; struct lustre_handle conn = { 0 }; int rc = 0; @@ -230,19 +229,8 @@ static int lmv_connect(const struct lu_env *env, if (data) lmv->conn_data = *data; - if (obd->obd_proc_private != NULL) { - lmv_proc_dir = obd->obd_proc_private; - } else { - lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry, - NULL, NULL); - if (IS_ERR(lmv_proc_dir)) { - CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.", - obd->obd_type->typ_name, obd->obd_name); - lmv_proc_dir = NULL; - } - obd->obd_proc_private = lmv_proc_dir; - } - + lmv->lmv_tgts_kobj = kobject_create_and_add("target_obds", + &obd->obd_kobj); /* * All real clients should perform actual connection right away, because * it is possible, that LMV will not have opportunity to connect targets @@ -252,10 +240,8 @@ static int lmv_connect(const struct lu_env *env, if (data->ocd_connect_flags & OBD_CONNECT_REAL) rc = lmv_check_connect(obd); - if (rc && lmv_proc_dir) { - lprocfs_remove(&lmv_proc_dir); - obd->obd_proc_private = NULL; - } + if (rc && lmv->lmv_tgts_kobj) + kobject_put(lmv->lmv_tgts_kobj); return rc; } @@ -337,7 +323,6 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) { - struct proc_dir_entry *lmv_proc_dir; struct lmv_obd *lmv = &obd->u.lmv; struct obd_uuid *cluuid = &lmv->cluuid; struct obd_uuid lmv_mdc_uuid = { "LMV_MDC_UUID" }; @@ -415,25 +400,10 @@ static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) mdc_obd->obd_name, mdc_obd->obd_uuid.uuid, atomic_read(&obd->obd_refcount)); - lmv_proc_dir = obd->obd_proc_private; - if (lmv_proc_dir) { - struct proc_dir_entry *mdc_symlink; - - LASSERT(mdc_obd->obd_type != NULL); - LASSERT(mdc_obd->obd_type->typ_name != NULL); - mdc_symlink = lprocfs_add_symlink(mdc_obd->obd_name, - lmv_proc_dir, - "../../../%s/%s", - mdc_obd->obd_type->typ_name, - mdc_obd->obd_name); - if (mdc_symlink == NULL) { - CERROR("Could not register LMV target /proc/fs/lustre/%s/%s/target_obds/%s.", - obd->obd_type->typ_name, obd->obd_name, - mdc_obd->obd_name); - lprocfs_remove(&lmv_proc_dir); - obd->obd_proc_private = NULL; - } - } + if (lmv->lmv_tgts_kobj) + /* Even if we failed to create the link, that's fine */ + rc = sysfs_create_link(lmv->lmv_tgts_kobj, &mdc_obd->obd_kobj, + mdc_obd->obd_name); return 0; } @@ -442,7 +412,7 @@ static void lmv_del_target(struct lmv_obd *lmv, int index) if (lmv->tgts[index] == NULL) return; - OBD_FREE_PTR(lmv->tgts[index]); + kfree(lmv->tgts[index]); lmv->tgts[index] = NULL; return; } @@ -488,7 +458,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, while (newsize < index + 1) newsize <<= 1; - OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize); + newtgts = kcalloc(newsize, sizeof(*newtgts), GFP_NOFS); if (newtgts == NULL) { lmv_init_unlock(lmv); return -ENOMEM; @@ -504,14 +474,13 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, lmv->tgts = newtgts; lmv->tgts_size = newsize; smp_rmb(); - if (old) - OBD_FREE(old, sizeof(*old) * oldsize); + kfree(old); CDEBUG(D_CONFIG, "tgts: %p size: %d\n", lmv->tgts, lmv->tgts_size); } - OBD_ALLOC_PTR(tgt); + tgt = kzalloc(sizeof(*tgt), GFP_NOFS); if (!tgt) { lmv_init_unlock(lmv); return -ENOMEM; @@ -611,7 +580,6 @@ int lmv_check_connect(struct obd_device *obd) static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) { - struct proc_dir_entry *lmv_proc_dir; struct lmv_obd *lmv = &obd->u.lmv; struct obd_device *mdc_obd; int rc; @@ -627,9 +595,9 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) mdc_obd->obd_no_recov = obd->obd_no_recov; } - lmv_proc_dir = obd->obd_proc_private; - if (lmv_proc_dir) - lprocfs_remove_proc_entry(mdc_obd->obd_name, lmv_proc_dir); + if (lmv->lmv_tgts_kobj) + sysfs_remove_link(lmv->lmv_tgts_kobj, + mdc_obd->obd_name); rc = obd_fid_fini(tgt->ltd_exp->exp_obd); if (rc) @@ -677,11 +645,8 @@ static int lmv_disconnect(struct obd_export *exp) lmv_disconnect_mdc(obd, lmv->tgts[i]); } - if (obd->obd_proc_private) - lprocfs_remove((struct proc_dir_entry **)&obd->obd_proc_private); - else - CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n", - obd->obd_type->typ_name, obd->obd_name); + if (lmv->lmv_tgts_kobj) + kobject_put(lmv->lmv_tgts_kobj); out_local: /* @@ -750,7 +715,7 @@ repeat_fid2path: /* sigh, has to go to another MDT to do path building further */ if (remote_gf == NULL) { remote_gf_size = sizeof(*remote_gf) + PATH_MAX; - OBD_ALLOC(remote_gf, remote_gf_size); + remote_gf = kzalloc(remote_gf_size, GFP_NOFS); if (remote_gf == NULL) { rc = -ENOMEM; goto out_fid2path; @@ -780,8 +745,7 @@ repeat_fid2path: goto repeat_fid2path; out_fid2path: - if (remote_gf != NULL) - OBD_FREE(remote_gf, remote_gf_size); + kfree(remote_gf); return rc; } @@ -984,7 +948,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, return -EAGAIN; LASSERT(tgt && tgt->ltd_exp); - OBD_ALLOC_PTR(oqctl); + oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS); if (!oqctl) return -ENOMEM; @@ -995,7 +959,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, qctl->qc_valid = QC_MDTIDX; qctl->obd_uuid = tgt->ltd_uuid; } - OBD_FREE_PTR(oqctl); + kfree(oqctl); break; } case OBD_IOC_CHANGELOG_SEND: @@ -1081,7 +1045,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, reqlen = offsetof(typeof(*hur), hur_user_item[nr]) + hur->hur_request.hr_data_len; - OBD_ALLOC_LARGE(req, reqlen); + req = libcfs_kvzalloc(reqlen, GFP_NOFS); if (req == NULL) return -ENOMEM; @@ -1091,7 +1055,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, reqlen, req, uarg); if (rc1 != 0 && rc == 0) rc = rc1; - OBD_FREE_LARGE(req, reqlen); + kvfree(req); } } break; @@ -1311,7 +1275,7 @@ int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { struct lmv_obd *lmv = &obd->u.lmv; - struct lprocfs_static_vars lvars; + struct lprocfs_static_vars lvars = { NULL }; struct lmv_desc *desc; int rc; @@ -1327,7 +1291,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) return -EINVAL; } - OBD_ALLOC(lmv->tgts, sizeof(*lmv->tgts) * 32); + lmv->tgts = kcalloc(32, sizeof(*lmv->tgts), GFP_NOFS); if (lmv->tgts == NULL) return -ENOMEM; lmv->tgts_size = 32; @@ -1345,16 +1309,12 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lprocfs_lmv_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars); -#if defined (CONFIG_PROC_FS) - { - rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd", - 0444, &lmv_proc_target_fops, obd); - if (rc) - CWARN("%s: error adding LMV target_obd file: rc = %d\n", - obd->obd_name, rc); - } -#endif + lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); + rc = ldebugfs_seq_create(obd->obd_debugfs_entry, "target_obd", + 0444, &lmv_proc_target_fops, obd); + if (rc) + CWARN("%s: error adding LMV target_obd file: rc = %d\n", + obd->obd_name, rc); rc = fld_client_init(&lmv->lmv_fld, obd->obd_name, LUSTRE_CLI_FLD_HASH_DHT); if (rc) { @@ -1380,7 +1340,7 @@ static int lmv_cleanup(struct obd_device *obd) continue; lmv_del_target(lmv, i); } - OBD_FREE(lmv->tgts, sizeof(*lmv->tgts) * lmv->tgts_size); + kfree(lmv->tgts); lmv->tgts_size = 0; } return 0; @@ -1437,7 +1397,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, if (rc) return rc; - OBD_ALLOC(temp, sizeof(*temp)); + temp = kzalloc(sizeof(*temp), GFP_NOFS); if (temp == NULL) return -ENOMEM; @@ -1473,7 +1433,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, } out_free_temp: - OBD_FREE(temp, sizeof(*temp)); + kfree(temp); return rc; } @@ -1769,7 +1729,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, goto out; } - OBD_ALLOC_PTR(rdata); + rdata = kzalloc(sizeof(*rdata), GFP_NOFS); if (rdata == NULL) { rc = -ENOMEM; goto out; @@ -1780,7 +1740,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh, lmm, lmmsize, NULL, extra_lock_flags); - OBD_FREE_PTR(rdata); + kfree(rdata); out: ldlm_lock_decref(&plock, pmode); return rc; @@ -2313,7 +2273,7 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) * stack. */ break; case OBD_CLEANUP_EXPORTS: - fld_client_proc_fini(&lmv->lmv_fld); + fld_client_debugfs_fini(&lmv->lmv_fld); lprocfs_obd_cleanup(obd); break; default: @@ -2440,13 +2400,13 @@ static int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, return mea_size; if (*lmmp && !lsm) { - OBD_FREE_LARGE(*lmmp, mea_size); + kvfree(*lmmp); *lmmp = NULL; return 0; } if (*lmmp == NULL) { - OBD_ALLOC_LARGE(*lmmp, mea_size); + *lmmp = libcfs_kvzalloc(mea_size, GFP_NOFS); if (*lmmp == NULL) return -ENOMEM; } @@ -2489,14 +2449,14 @@ static int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, return mea_size; if (*lsmp != NULL && lmm == NULL) { - OBD_FREE_LARGE(*tmea, mea_size); + kvfree(*tmea); *lsmp = NULL; return 0; } LASSERT(mea_size == lmm_size); - OBD_ALLOC_LARGE(*tmea, mea_size); + *tmea = libcfs_kvzalloc(mea_size, GFP_NOFS); if (*tmea == NULL) return -ENOMEM; @@ -2875,7 +2835,7 @@ static int __init lmv_init(void) lprocfs_lmv_init_vars(&lvars); rc = class_register_type(&lmv_obd_ops, &lmv_md_ops, - lvars.module_vars, LUSTRE_LMV_NAME, NULL); + LUSTRE_LMV_NAME, NULL); return rc; } diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 22e5c315faa4..311fc1b70c4d 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -42,17 +42,17 @@ #include "../include/obd_class.h" #include "lmv_internal.h" -static int lmv_numobd_seq_show(struct seq_file *m, void *v) +static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lmv_desc *desc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + struct lmv_desc *desc; - LASSERT(dev != NULL); desc = &dev->u.lmv.desc; - seq_printf(m, "%u\n", desc->ld_tgt_count); - return 0; + return sprintf(buf, "%u\n", desc->ld_tgt_count); } -LPROC_SEQ_FOPS_RO(lmv_numobd); +LUSTRE_RO_ATTR(numobd); static const char *placement_name[] = { [PLACEMENT_CHAR_POLICY] = "CHAR", @@ -77,66 +77,61 @@ static const char *placement_policy2name(enum placement_policy placement) return placement_name[placement]; } -static int lmv_placement_seq_show(struct seq_file *m, void *v) +static ssize_t placement_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lmv_obd *lmv; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + struct lmv_obd *lmv; - LASSERT(dev != NULL); lmv = &dev->u.lmv; - seq_printf(m, "%s\n", placement_policy2name(lmv->lmv_placement)); - return 0; + return sprintf(buf, "%s\n", placement_policy2name(lmv->lmv_placement)); } #define MAX_POLICY_STRING_SIZE 64 -static ssize_t lmv_placement_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t placement_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - char dummy[MAX_POLICY_STRING_SIZE + 1]; - int len = count; - enum placement_policy policy; - struct lmv_obd *lmv; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + char dummy[MAX_POLICY_STRING_SIZE + 1]; + enum placement_policy policy; + struct lmv_obd *lmv = &dev->u.lmv; - if (copy_from_user(dummy, buffer, MAX_POLICY_STRING_SIZE)) - return -EFAULT; + memcpy(dummy, buffer, MAX_POLICY_STRING_SIZE); - LASSERT(dev != NULL); - lmv = &dev->u.lmv; + if (count > MAX_POLICY_STRING_SIZE) + count = MAX_POLICY_STRING_SIZE; - if (len > MAX_POLICY_STRING_SIZE) - len = MAX_POLICY_STRING_SIZE; + if (dummy[count - 1] == '\n') + count--; + dummy[count] = '\0'; - if (dummy[len - 1] == '\n') - len--; - dummy[len] = '\0'; - - policy = placement_name2policy(dummy, len); + policy = placement_name2policy(dummy, count); if (policy != PLACEMENT_INVAL_POLICY) { spin_lock(&lmv->lmv_lock); lmv->lmv_placement = policy; spin_unlock(&lmv->lmv_lock); } else { - CERROR("Invalid placement policy \"%s\"!\n", dummy); return -EINVAL; } return count; } -LPROC_SEQ_FOPS(lmv_placement); +LUSTRE_RW_ATTR(placement); -static int lmv_activeobd_seq_show(struct seq_file *m, void *v) +static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lmv_desc *desc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + struct lmv_desc *desc; - LASSERT(dev != NULL); desc = &dev->u.lmv.desc; - seq_printf(m, "%u\n", desc->ld_active_tgt_count); - return 0; + return sprintf(buf, "%u\n", desc->ld_active_tgt_count); } -LPROC_SEQ_FOPS_RO(lmv_activeobd); +LUSTRE_RO_ATTR(activeobd); static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v) { @@ -182,7 +177,7 @@ static int lmv_tgt_seq_show(struct seq_file *p, void *v) return 0; } -static struct seq_operations lmv_tgt_sops = { +static const struct seq_operations lmv_tgt_sops = { .start = lmv_tgt_seq_start, .stop = lmv_tgt_seq_stop, .next = lmv_tgt_seq_next, @@ -199,29 +194,16 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) return rc; seq = file->private_data; - seq->private = PDE_DATA(inode); + seq->private = inode->i_private; return 0; } -LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid); - static struct lprocfs_vars lprocfs_lmv_obd_vars[] = { - { "numobd", &lmv_numobd_fops, NULL, 0 }, - { "placement", &lmv_placement_fops, NULL, 0 }, - { "activeobd", &lmv_activeobd_fops, NULL, 0 }, - { "uuid", &lmv_uuid_fops, NULL, 0 }, { "desc_uuid", &lmv_desc_uuid_fops, NULL, 0 }, { NULL } }; -LPROC_SEQ_FOPS_RO_TYPE(lmv, numrefs); - -static struct lprocfs_vars lprocfs_lmv_module_vars[] = { - { "num_refs", &lmv_numrefs_fops, NULL, 0 }, - { NULL } -}; - struct file_operations lmv_proc_target_fops = { .owner = THIS_MODULE, .open = lmv_target_seq_open, @@ -230,8 +212,19 @@ struct file_operations lmv_proc_target_fops = { .release = seq_release, }; +static struct attribute *lmv_attrs[] = { + &lustre_attr_activeobd.attr, + &lustre_attr_numobd.attr, + &lustre_attr_placement.attr, + NULL, +}; + +static struct attribute_group lmv_attr_group = { + .attrs = lmv_attrs, +}; + void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_lmv_module_vars; + lvars->sysfs_vars = &lmv_attr_group; lvars->obd_vars = lprocfs_lmv_obd_vars; } diff --git a/drivers/staging/lustre/lustre/lov/Makefile b/drivers/staging/lustre/lustre/lov/Makefile index 6fe56a24b165..e4cc0db21014 100644 --- a/drivers/staging/lustre/lustre/lov/Makefile +++ b/drivers/staging/lustre/lustre/lov/Makefile @@ -2,5 +2,4 @@ obj-$(CONFIG_LUSTRE_FS) += lov.o lov-y := lov_obd.o lov_pack.o lov_offset.o lov_merge.o \ lov_request.o lov_ea.o lov_dev.o lov_object.o lov_page.o \ lov_lock.o lov_io.o lovsub_dev.o lovsub_object.o lovsub_page.o \ - lovsub_lock.o lovsub_io.o lov_pool.o -lov-$(CONFIG_PROC_FS) += lproc_lov.o + lovsub_lock.o lovsub_io.o lov_pool.o lproc_lov.o diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index 711b837ddba2..504b24a468fc 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -285,10 +285,10 @@ static void lov_emerg_free(struct lov_device_emerg **emrg, int nr) LASSERT(em->emrg_page_list.pl_nr == 0); if (em->emrg_env != NULL) cl_env_put(em->emrg_env, &em->emrg_refcheck); - OBD_FREE_PTR(em); + kfree(em); } } - OBD_FREE(emrg, nr * sizeof(emrg[0])); + kfree(emrg); } static struct lu_device *lov_device_free(const struct lu_env *env, @@ -298,11 +298,10 @@ static struct lu_device *lov_device_free(const struct lu_env *env, const int nr = ld->ld_target_nr; cl_device_fini(lu2cl_dev(d)); - if (ld->ld_target != NULL) - OBD_FREE(ld->ld_target, nr * sizeof(ld->ld_target[0])); + kfree(ld->ld_target); if (ld->ld_emrg != NULL) lov_emerg_free(ld->ld_emrg, nr); - OBD_FREE_PTR(ld); + kfree(ld); return NULL; } @@ -323,13 +322,13 @@ static struct lov_device_emerg **lov_emerg_alloc(int nr) int i; int result; - OBD_ALLOC(emerg, nr * sizeof(emerg[0])); + emerg = kcalloc(nr, sizeof(emerg[0]), GFP_NOFS); if (emerg == NULL) return ERR_PTR(-ENOMEM); for (result = i = 0; i < nr && result == 0; i++) { struct lov_device_emerg *em; - OBD_ALLOC_PTR(em); + em = kzalloc(sizeof(*em), GFP_NOFS); if (em != NULL) { emerg[i] = em; cl_page_list_init(&em->emrg_page_list); @@ -369,12 +368,12 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) if (IS_ERR(emerg)) return PTR_ERR(emerg); - OBD_ALLOC(newd, tgt_size * sz); + newd = kcalloc(tgt_size, sz, GFP_NOFS); if (newd != NULL) { mutex_lock(&dev->ld_mutex); if (sub_size > 0) { memcpy(newd, dev->ld_target, sub_size * sz); - OBD_FREE(dev->ld_target, sub_size * sz); + kfree(dev->ld_target); } dev->ld_target = newd; dev->ld_target_nr = tgt_size; @@ -478,7 +477,7 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env, struct obd_device *obd; int rc; - OBD_ALLOC_PTR(ld); + ld = kzalloc(sizeof(*ld), GFP_NOFS); if (ld == NULL) return ERR_PTR(-ENOMEM); diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 2bcfaeaff6fa..3f51b573e1fb 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -95,7 +95,7 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size) oinfo_ptrs_size = sizeof(struct lov_oinfo *) * stripe_count; *size = sizeof(struct lov_stripe_md) + oinfo_ptrs_size; - OBD_ALLOC_LARGE(lsm, *size); + lsm = libcfs_kvzalloc(*size, GFP_NOFS); if (!lsm) return NULL; @@ -111,7 +111,7 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size) err: while (--i >= 0) OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab, sizeof(*loi)); - OBD_FREE_LARGE(lsm, *size); + kvfree(lsm); return NULL; } @@ -123,8 +123,7 @@ void lsm_free_plain(struct lov_stripe_md *lsm) for (i = 0; i < stripe_count; i++) OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab, sizeof(struct lov_oinfo)); - OBD_FREE_LARGE(lsm, sizeof(struct lov_stripe_md) + - stripe_count * sizeof(struct lov_oinfo *)); + kvfree(lsm); } static void lsm_unpackmd_common(struct lov_stripe_md *lsm, diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index b644acc9b034..dde9656d4dd6 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -71,13 +71,6 @@ }) #endif -struct lov_lock_handles { - struct portals_handle llh_handle; - atomic_t llh_refcount; - int llh_stripe_count; - struct lustre_handle llh_handles[0]; -}; - struct lov_request { struct obd_info rq_oi; struct lov_request_set *rq_rqset; @@ -88,7 +81,6 @@ struct lov_request { int rq_stripe; /* stripe number */ int rq_complete; int rq_rc; - int rq_buflen; /* length of sub_md */ u32 rq_oabufs; u32 rq_pgaidx; @@ -109,9 +101,6 @@ struct lov_request_set { struct llog_cookie *set_cookies; int set_cookie_sent; struct obd_trans_info *set_oti; - u32 set_oabufs; - struct brw_page *set_pga; - struct lov_lock_handles *set_lockh; struct list_head set_list; wait_queue_head_t set_waitq; spinlock_t set_lock; @@ -136,32 +125,6 @@ static inline void lov_put_reqset(struct lov_request_set *set) lov_finish_set(set); } -static inline struct lov_lock_handles * -lov_handle2llh(struct lustre_handle *handle) -{ - LASSERT(handle != NULL); - return class_handle2object(handle->cookie); -} - -static inline void lov_llh_put(struct lov_lock_handles *llh) -{ - CDEBUG(D_INFO, "PUTting llh %p : new refcount %d\n", llh, - atomic_read(&llh->llh_refcount) - 1); - LASSERT(atomic_read(&llh->llh_refcount) > 0 && - atomic_read(&llh->llh_refcount) < 0x5a5a); - if (atomic_dec_and_test(&llh->llh_refcount)) { - class_handle_unhash(&llh->llh_handle); - /* The structure may be held by other threads because RCU. - * -jxiong */ - if (atomic_read(&llh->llh_refcount)) - return; - - OBD_FREE_RCU(llh, sizeof(*llh) + - sizeof(*llh->llh_handles) * llh->llh_stripe_count, - &llh->llh_handle); - } -} - #define lov_uuid2str(lv, index) \ (char *)((lv)->lov_tgts[index]->ltd_uuid.uuid) @@ -265,15 +228,8 @@ void lsm_free_plain(struct lov_stripe_md *lsm); void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm); /* lproc_lov.c */ -#if defined (CONFIG_PROC_FS) extern const struct file_operations lov_proc_target_fops; void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars); -#else -static inline void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -#endif /* lov_cl.c */ extern struct lu_device_type lov_device_type; diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index cf96e0d01e22..11c1081b1d3d 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -70,7 +70,7 @@ static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio, if (sub->sub_stripe == lio->lis_single_subio_index) lio->lis_single_subio_index = -1; else if (!sub->sub_borrowed) - OBD_FREE_PTR(sub->sub_io); + kfree(sub->sub_io); sub->sub_io = NULL; } if (sub->sub_env != NULL && !IS_ERR(sub->sub_env)) { @@ -179,7 +179,8 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, sub->sub_io = &lio->lis_single_subio; lio->lis_single_subio_index = stripe; } else { - OBD_ALLOC_PTR(sub->sub_io); + sub->sub_io = kzalloc(sizeof(*sub->sub_io), + GFP_NOFS); if (sub->sub_io == NULL) result = -ENOMEM; } @@ -285,8 +286,10 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, * Need to be optimized, we can't afford to allocate a piece of memory * when writing a page. -jay */ - OBD_ALLOC_LARGE(lio->lis_subs, - lsm->lsm_stripe_count * sizeof(lio->lis_subs[0])); + lio->lis_subs = + libcfs_kvzalloc(lsm->lsm_stripe_count * + sizeof(lio->lis_subs[0]), + GFP_NOFS); if (lio->lis_subs != NULL) { lio->lis_nr_subios = lio->lis_stripe_count; lio->lis_single_subio_index = -1; @@ -359,8 +362,7 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) if (lio->lis_subs != NULL) { 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])); + kvfree(lio->lis_subs); lio->lis_nr_subios = 0; } @@ -603,8 +605,10 @@ static int lov_io_submit(const struct lu_env *env, LASSERT(lio->lis_subs != NULL); if (alloc) { - OBD_ALLOC_LARGE(stripes_qin, - sizeof(*stripes_qin) * lio->lis_nr_subios); + stripes_qin = + libcfs_kvzalloc(sizeof(*stripes_qin) * + lio->lis_nr_subios, + GFP_NOFS); if (stripes_qin == NULL) return -ENOMEM; @@ -657,8 +661,7 @@ static int lov_io_submit(const struct lu_env *env, } if (alloc) { - OBD_FREE_LARGE(stripes_qin, - sizeof(*stripes_qin) * lio->lis_nr_subios); + kvfree(stripes_qin); } else { int i; diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index f2eca565bdda..a6938085ff24 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -314,7 +314,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])); + lck->lls_sub = libcfs_kvzalloc(nr * sizeof(lck->lls_sub[0]), GFP_NOFS); if (lck->lls_sub == NULL) return -ENOMEM; @@ -441,8 +441,7 @@ static void lov_lock_fini(const struct lu_env *env, * a reference on its parent. */ LASSERT(lck->lls_sub[i].sub_lock == NULL); - OBD_FREE_LARGE(lck->lls_sub, - lck->lls_nr * sizeof(lck->lls_sub[0])); + kvfree(lck->lls_sub); } OBD_SLAB_FREE_PTR(lck, lov_lock_kmem); } diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 02781576637e..96c55acd52ae 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -127,7 +127,6 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, struct obd_device *tgt_obd; static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; struct obd_import *imp; - struct proc_dir_entry *lov_proc_dir; int rc; if (!lov->lov_tgts[index]) @@ -186,28 +185,10 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index, obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in"); - lov_proc_dir = obd->obd_proc_private; - if (lov_proc_dir) { - struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd; - struct proc_dir_entry *osc_symlink; - - LASSERT(osc_obd != NULL); - LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC); - LASSERT(osc_obd->obd_type->typ_name != NULL); - - osc_symlink = lprocfs_add_symlink(osc_obd->obd_name, - lov_proc_dir, - "../../../%s/%s", - osc_obd->obd_type->typ_name, - osc_obd->obd_name); - if (osc_symlink == NULL) { - CERROR("could not register LOV target /proc/fs/lustre/%s/%s/target_obds/%s.", - obd->obd_type->typ_name, obd->obd_name, - osc_obd->obd_name); - lprocfs_remove(&lov_proc_dir); - obd->obd_proc_private = NULL; - } - } + if (lov->lov_tgts_kobj) + /* Even if we failed, that's ok */ + rc = sysfs_create_link(lov->lov_tgts_kobj, &tgt_obd->obd_kobj, + tgt_obd->obd_name); return 0; } @@ -239,6 +220,10 @@ static int lov_connect(const struct lu_env *env, lov->lov_ocd = *data; obd_getref(obd); + + lov->lov_tgts_kobj = kobject_create_and_add("target_obds", + &obd->obd_kobj); + for (i = 0; i < lov->desc.ld_tgt_count; i++) { tgt = lov->lov_tgts[i]; if (!tgt || obd_uuid_empty(&tgt->ltd_uuid)) @@ -268,7 +253,6 @@ static int lov_connect(const struct lu_env *env, static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) { - struct proc_dir_entry *lov_proc_dir; struct lov_obd *lov = &obd->u.lov; struct obd_device *osc_obd; int rc; @@ -284,10 +268,10 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) } if (osc_obd) { - lov_proc_dir = obd->obd_proc_private; - if (lov_proc_dir) { - lprocfs_remove_proc_entry(osc_obd->obd_name, lov_proc_dir); - } + if (lov->lov_tgts_kobj) + sysfs_remove_link(lov->lov_tgts_kobj, + osc_obd->obd_name); + /* Pass it on to our clients. * XXX This should be an argument to disconnect, * XXX not a back-door flag on the OBD. Ah well. @@ -337,6 +321,10 @@ static int lov_disconnect(struct obd_export *exp) lov_del_target(obd, i, NULL, lov->lov_tgts[i]->ltd_gen); } } + + if (lov->lov_tgts_kobj) + kobject_put(lov->lov_tgts_kobj); + obd_putref(obd); out: @@ -554,7 +542,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, newsize = max_t(__u32, lov->lov_tgt_size, 2); while (newsize < index + 1) newsize <<= 1; - OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize); + newtgts = kcalloc(newsize, sizeof(*newtgts), GFP_NOFS); if (newtgts == NULL) { mutex_unlock(&lov->lov_lock); return -ENOMEM; @@ -570,14 +558,13 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, lov->lov_tgts = newtgts; lov->lov_tgt_size = newsize; smp_rmb(); - if (old) - OBD_FREE(old, sizeof(*old) * oldsize); + kfree(old); CDEBUG(D_CONFIG, "tgts: %p size: %d\n", lov->lov_tgts, lov->lov_tgt_size); } - OBD_ALLOC_PTR(tgt); + tgt = kzalloc(sizeof(*tgt), GFP_NOFS); if (!tgt) { mutex_unlock(&lov->lov_lock); return -ENOMEM; @@ -586,7 +573,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size); if (rc) { mutex_unlock(&lov->lov_lock); - OBD_FREE_PTR(tgt); + kfree(tgt); return rc; } @@ -712,7 +699,7 @@ static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) if (tgt->ltd_exp) lov_disconnect_obd(obd, tgt); - OBD_FREE_PTR(tgt); + kfree(tgt); /* Manual cleanup - no cleanup logs to clean up the osc's. We must do it ourselves. And we can't do it from lov_cleanup, @@ -822,21 +809,16 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto out; lprocfs_lov_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars); -#if defined (CONFIG_PROC_FS) - { - int rc1; + lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); - rc1 = lprocfs_seq_create(obd->obd_proc_entry, "target_obd", - 0444, &lov_proc_target_fops, obd); - if (rc1) - CWARN("Error adding the target_obd file\n"); - } -#endif - lov->lov_pool_proc_entry = lprocfs_register("pools", - obd->obd_proc_entry, - NULL, NULL); + rc = ldebugfs_seq_create(obd->obd_debugfs_entry, "target_obd", + 0444, &lov_proc_target_fops, obd); + if (rc) + CWARN("Error adding the target_obd file\n"); + lov->lov_pool_debugfs_entry = ldebugfs_register("pools", + obd->obd_debugfs_entry, + NULL, NULL); return 0; out: @@ -903,8 +885,7 @@ static int lov_cleanup(struct obd_device *obd) lov_del_target(obd, i, NULL, 0); } obd_putref(obd); - OBD_FREE(lov->lov_tgts, sizeof(*lov->lov_tgts) * - lov->lov_tgt_size); + kfree(lov->lov_tgts); lov->lov_tgt_size = 0; } return 0; @@ -994,7 +975,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, LASSERT(src_oa->o_valid & OBD_MD_FLFLAGS && src_oa->o_flags & OBD_FL_RECREATE_OBJS); - OBD_ALLOC(obj_mdp, sizeof(*obj_mdp)); + obj_mdp = kzalloc(sizeof(*obj_mdp), GFP_NOFS); if (obj_mdp == NULL) return -ENOMEM; @@ -1032,7 +1013,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, rc = obd_create(NULL, lov->lov_tgts[ost_idx]->ltd_exp, src_oa, &obj_mdp, oti); out: - OBD_FREE(obj_mdp, sizeof(*obj_mdp)); + kfree(obj_mdp); return rc; } @@ -1419,7 +1400,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, __u32 flags; memcpy(&index, data->ioc_inlbuf2, sizeof(__u32)); - if ((index >= count)) + if (index >= count) return -ENODEV; if (!lov->lov_tgts[index]) @@ -1532,7 +1513,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, return -EAGAIN; LASSERT(tgt && tgt->ltd_exp); - OBD_ALLOC_PTR(oqctl); + oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS); if (!oqctl) return -ENOMEM; @@ -1543,7 +1524,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, qctl->qc_valid = QC_OSTIDX; qctl->obd_uuid = tgt->ltd_uuid; } - OBD_FREE_PTR(oqctl); + kfree(oqctl); break; } default: { @@ -1756,7 +1737,7 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, if (fiemap_count_to_size(fm_key->fiemap.fm_extent_count) < buffer_size) buffer_size = fiemap_count_to_size(fm_key->fiemap.fm_extent_count); - OBD_ALLOC_LARGE(fm_local, buffer_size); + fm_local = libcfs_kvzalloc(buffer_size, GFP_NOFS); if (fm_local == NULL) { rc = -ENOMEM; goto out; @@ -1962,7 +1943,7 @@ skip_last_device_calc: fiemap->fm_mapped_extents = current_extent; out: - OBD_FREE_LARGE(fm_local, buffer_size); + kvfree(fm_local); return rc; } @@ -2367,7 +2348,7 @@ static int __init lov_init(void) } lprocfs_lov_init_vars(&lvars); - rc = class_register_type(&lov_obd_ops, NULL, lvars.module_vars, + rc = class_register_type(&lov_obd_ops, NULL, LUSTRE_LOV_NAME, &lov_device_type); if (rc) { diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index a22342fa792d..4d7cd924a27e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -218,7 +218,8 @@ 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])); + r0->lo_sub = libcfs_kvzalloc(r0->lo_nr * sizeof(r0->lo_sub[0]), + GFP_NOFS); if (r0->lo_sub != NULL) { result = 0; subconf->coc_inode = conf->coc_inode; @@ -375,7 +376,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])); + kvfree(r0->lo_sub); 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 5356d5324176..6b1c135c9ab0 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -192,13 +192,13 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, if (*lmmp && !lsm) { stripe_count = le16_to_cpu((*lmmp)->lmm_stripe_count); lmm_size = lov_mds_md_size(stripe_count, lmm_magic); - OBD_FREE_LARGE(*lmmp, lmm_size); + kvfree(*lmmp); *lmmp = NULL; return 0; } if (!*lmmp) { - OBD_ALLOC_LARGE(*lmmp, lmm_size); + *lmmp = libcfs_kvzalloc(lmm_size, GFP_NOFS); if (!*lmmp) return -ENOMEM; } @@ -285,7 +285,7 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count) CERROR("bad disk LOV MAGIC: 0x%08X; dumping LMM (size=%d):\n", le32_to_cpu(*(__u32 *)lmm), lmm_bytes); sz = lmm_bytes * 2 + 1; - OBD_ALLOC_LARGE(buffer, sz); + buffer = libcfs_kvzalloc(sz, GFP_NOFS); if (buffer != NULL) { int i; @@ -293,7 +293,7 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count) sprintf(buffer+2*i, "%.2X", ((char *)lmm)[i]); buffer[sz - 1] = '\0'; CERROR("%s\n", buffer); - OBD_FREE_LARGE(buffer, sz); + kvfree(buffer); } return -EINVAL; } @@ -367,9 +367,11 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, if (rc) return rc; magic = le32_to_cpu(lmm->lmm_magic); + pattern = le32_to_cpu(lmm->lmm_pattern); } else { magic = LOV_MAGIC; stripe_count = lov_get_stripecnt(lov, magic, 0); + pattern = LOV_PATTERN_RAID0; } /* If we aren't passed an lsmp struct, we just want the size */ @@ -384,7 +386,6 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, return 0; } - pattern = le32_to_cpu(lmm->lmm_pattern); lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic); if (lsm_size < 0) return lsm_size; diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index d96163de773f..1e4d3fbee323 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -64,10 +64,10 @@ void lov_pool_putref(struct pool_desc *pool) if (atomic_dec_and_test(&pool->pool_refcount)) { LASSERT(hlist_unhashed(&pool->pool_hash)); LASSERT(list_empty(&pool->pool_list)); - LASSERT(pool->pool_proc_entry == NULL); + LASSERT(pool->pool_debugfs_entry == NULL); lov_ost_pool_free(&(pool->pool_rr.lqr_pool)); lov_ost_pool_free(&(pool->pool_obds)); - OBD_FREE_PTR(pool); + kfree(pool); } } @@ -152,7 +152,6 @@ cfs_hash_ops_t pool_hash_operations = { }; -#if defined (CONFIG_PROC_FS) /* ifdef needed for liblustre support */ /* * pool /proc seq_file methods @@ -210,7 +209,7 @@ static void *pool_proc_start(struct seq_file *s, loff_t *pos) return NULL; } - OBD_ALLOC_PTR(iter); + iter = kzalloc(sizeof(*iter), GFP_NOFS); if (!iter) return ERR_PTR(-ENOMEM); iter->magic = POOL_IT_MAGIC; @@ -246,7 +245,7 @@ static void pool_proc_stop(struct seq_file *s, void *v) * will work */ s->private = iter->pool; lov_pool_putref(iter->pool); - OBD_FREE_PTR(iter); + kfree(iter); } return; } @@ -269,7 +268,7 @@ static int pool_proc_show(struct seq_file *s, void *v) return 0; } -static struct seq_operations pool_proc_ops = { +static const struct seq_operations pool_proc_ops = { .start = pool_proc_start, .next = pool_proc_next, .stop = pool_proc_stop, @@ -283,7 +282,7 @@ static int pool_proc_open(struct inode *inode, struct file *file) rc = seq_open(file, &pool_proc_ops); if (!rc) { struct seq_file *s = file->private_data; - s->private = PDE_DATA(inode); + s->private = inode->i_private; } return rc; } @@ -294,7 +293,6 @@ static struct file_operations pool_proc_operations = { .llseek = seq_lseek, .release = seq_release, }; -#endif /* CONFIG_PROC_FS */ void lov_dump_pool(int level, struct pool_desc *pool) { @@ -327,7 +325,7 @@ int lov_ost_pool_init(struct ost_pool *op, unsigned int count) op->op_count = 0; init_rwsem(&op->op_rw_sem); op->op_size = count; - OBD_ALLOC(op->op_array, op->op_size * sizeof(op->op_array[0])); + op->op_array = kcalloc(op->op_size, sizeof(op->op_array[0]), GFP_NOFS); if (op->op_array == NULL) { op->op_size = 0; return -ENOMEM; @@ -347,13 +345,13 @@ int lov_ost_pool_extend(struct ost_pool *op, unsigned int min_count) return 0; new_size = max(min_count, 2 * op->op_size); - OBD_ALLOC(new, new_size * sizeof(op->op_array[0])); + new = kcalloc(new_size, sizeof(op->op_array[0]), GFP_NOFS); if (new == NULL) return -ENOMEM; /* copy old array to new one */ memcpy(new, op->op_array, op->op_size * sizeof(op->op_array[0])); - OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0])); + kfree(op->op_array); op->op_array = new; op->op_size = new_size; return 0; @@ -411,7 +409,7 @@ int lov_ost_pool_free(struct ost_pool *op) down_write(&op->op_rw_sem); - OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0])); + kfree(op->op_array); op->op_array = NULL; op->op_count = 0; op->op_size = 0; @@ -432,7 +430,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname) if (strlen(poolname) > LOV_MAXPOOLNAME) return -ENAMETOOLONG; - OBD_ALLOC_PTR(new_pool); + new_pool = kzalloc(sizeof(*new_pool), GFP_NOFS); if (new_pool == NULL) return -ENOMEM; @@ -454,20 +452,21 @@ int lov_pool_new(struct obd_device *obd, char *poolname) INIT_HLIST_NODE(&new_pool->pool_hash); -#if defined (CONFIG_PROC_FS) /* we need this assert seq_file is not implemented for liblustre */ /* get ref for /proc file */ lov_pool_getref(new_pool); - new_pool->pool_proc_entry = lprocfs_add_simple(lov->lov_pool_proc_entry, - poolname, new_pool, - &pool_proc_operations); - if (IS_ERR(new_pool->pool_proc_entry)) { - CWARN("Cannot add proc pool entry "LOV_POOLNAMEF"\n", poolname); - new_pool->pool_proc_entry = NULL; + new_pool->pool_debugfs_entry = ldebugfs_add_simple( + lov->lov_pool_debugfs_entry, + poolname, new_pool, + &pool_proc_operations); + if (IS_ERR_OR_NULL(new_pool->pool_debugfs_entry)) { + CWARN("Cannot add debugfs pool entry "LOV_POOLNAMEF"\n", + poolname); + new_pool->pool_debugfs_entry = NULL; lov_pool_putref(new_pool); } - CDEBUG(D_INFO, "pool %p - proc %p\n", new_pool, new_pool->pool_proc_entry); -#endif + CDEBUG(D_INFO, "pool %p - proc %p\n", + new_pool, new_pool->pool_debugfs_entry); spin_lock(&obd->obd_dev_lock); list_add_tail(&new_pool->pool_list, &lov->lov_pool_list); @@ -493,12 +492,12 @@ out_err: lov->lov_pool_count--; spin_unlock(&obd->obd_dev_lock); - lprocfs_remove(&new_pool->pool_proc_entry); + ldebugfs_remove(&new_pool->pool_debugfs_entry); lov_ost_pool_free(&new_pool->pool_rr.lqr_pool); out_free_pool_obds: lov_ost_pool_free(&new_pool->pool_obds); - OBD_FREE_PTR(new_pool); + kfree(new_pool); return rc; } @@ -514,9 +513,9 @@ int lov_pool_del(struct obd_device *obd, char *poolname) if (pool == NULL) return -ENOENT; - if (pool->pool_proc_entry != NULL) { - CDEBUG(D_INFO, "proc entry %p\n", pool->pool_proc_entry); - lprocfs_remove(&pool->pool_proc_entry); + if (!IS_ERR_OR_NULL(pool->pool_debugfs_entry)) { + CDEBUG(D_INFO, "proc entry %p\n", pool->pool_debugfs_entry); + ldebugfs_remove(&pool->pool_debugfs_entry); lov_pool_putref(pool); } diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 933e2d1f8127..f4de8b84c5c2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -68,22 +68,10 @@ void lov_finish_set(struct lov_request_set *set) if (req->rq_oi.oi_oa) OBDO_FREE(req->rq_oi.oi_oa); - if (req->rq_oi.oi_md) - OBD_FREE_LARGE(req->rq_oi.oi_md, req->rq_buflen); - if (req->rq_oi.oi_osfs) - OBD_FREE(req->rq_oi.oi_osfs, - sizeof(*req->rq_oi.oi_osfs)); - OBD_FREE(req, sizeof(*req)); + kfree(req->rq_oi.oi_osfs); + kfree(req); } - - if (set->set_pga) { - int len = set->set_oabufs * sizeof(*set->set_pga); - OBD_FREE_LARGE(set->set_pga, len); - } - if (set->set_lockh) - lov_llh_put(set->set_lockh); - - OBD_FREE(set, sizeof(*set)); + kfree(set); } int lov_set_finished(struct lov_request_set *set, int idempotent) @@ -286,7 +274,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - OBD_ALLOC(set, sizeof(*set)); + set = kzalloc(sizeof(*set), GFP_NOFS); if (set == NULL) return -ENOMEM; lov_init_set(set); @@ -312,7 +300,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, continue; } - OBD_ALLOC(req, sizeof(*req)); + req = kzalloc(sizeof(*req), GFP_NOFS); if (req == NULL) { rc = -ENOMEM; goto out_set; @@ -323,7 +311,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, OBDO_ALLOC(req->rq_oi.oi_oa); if (req->rq_oi.oi_oa == NULL) { - OBD_FREE(req, sizeof(*req)); + kfree(req); rc = -ENOMEM; goto out_set; } @@ -369,7 +357,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - OBD_ALLOC(set, sizeof(*set)); + set = kzalloc(sizeof(*set), GFP_NOFS); if (set == NULL) return -ENOMEM; lov_init_set(set); @@ -395,7 +383,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, continue; } - OBD_ALLOC(req, sizeof(*req)); + req = kzalloc(sizeof(*req), GFP_NOFS); if (req == NULL) { rc = -ENOMEM; goto out_set; @@ -406,7 +394,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, OBDO_ALLOC(req->rq_oi.oi_oa); if (req->rq_oi.oi_oa == NULL) { - OBD_FREE(req, sizeof(*req)); + kfree(req); rc = -ENOMEM; goto out_set; } @@ -488,7 +476,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - OBD_ALLOC(set, sizeof(*set)); + set = kzalloc(sizeof(*set), GFP_NOFS); if (set == NULL) return -ENOMEM; lov_init_set(set); @@ -511,7 +499,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, continue; } - OBD_ALLOC(req, sizeof(*req)); + req = kzalloc(sizeof(*req), GFP_NOFS); if (req == NULL) { rc = -ENOMEM; goto out_set; @@ -521,7 +509,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, OBDO_ALLOC(req->rq_oi.oi_oa); if (req->rq_oi.oi_oa == NULL) { - OBD_FREE(req, sizeof(*req)); + kfree(req); rc = -ENOMEM; goto out_set; } @@ -619,8 +607,7 @@ void lov_update_statfs(struct obd_statfs *osfs, struct obd_statfs *lov_sfs, if (tmp & 1) { if (quit) break; - else - quit = 1; + quit = 1; shift = 0; } tmp >>= 1; @@ -716,7 +703,7 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, struct lov_obd *lov = &obd->u.lov; int rc = 0, i; - OBD_ALLOC(set, sizeof(*set)); + set = kzalloc(sizeof(*set), GFP_NOFS); if (set == NULL) return -ENOMEM; lov_init_set(set); @@ -742,15 +729,16 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, continue; } - OBD_ALLOC(req, sizeof(*req)); + req = kzalloc(sizeof(*req), GFP_NOFS); if (req == NULL) { rc = -ENOMEM; goto out_set; } - OBD_ALLOC(req->rq_oi.oi_osfs, sizeof(*req->rq_oi.oi_osfs)); + req->rq_oi.oi_osfs = kzalloc(sizeof(*req->rq_oi.oi_osfs), + GFP_NOFS); if (req->rq_oi.oi_osfs == NULL) { - OBD_FREE(req, sizeof(*req)); + kfree(req); rc = -ENOMEM; goto out_set; } diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 42336f13a76f..90d9ec386a1a 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -136,7 +136,7 @@ static struct lu_device *lovsub_device_free(const struct lu_env *env, lu_site_print(env, d->ld_site, &msgdata, lu_cdebug_printer); } cl_device_fini(lu2cl_dev(d)); - OBD_FREE_PTR(lsd); + kfree(lsd); return next; } @@ -172,7 +172,7 @@ static struct lu_device *lovsub_device_alloc(const struct lu_env *env, struct lu_device *d; struct lovsub_device *lsd; - OBD_ALLOC_PTR(lsd); + lsd = kzalloc(sizeof(*lsd), GFP_NOFS); if (lsd != NULL) { int result; diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 174cbf5c138f..380b8271bf24 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -166,29 +166,29 @@ static ssize_t lov_stripecount_seq_write(struct file *file, } LPROC_SEQ_FOPS(lov_stripecount); -static int lov_numobd_seq_show(struct seq_file *m, void *v) +static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct lov_desc *desc; - LASSERT(dev != NULL); desc = &dev->u.lov.desc; - seq_printf(m, "%u\n", desc->ld_tgt_count); - return 0; + return sprintf(buf, "%u\n", desc->ld_tgt_count); } -LPROC_SEQ_FOPS_RO(lov_numobd); +LUSTRE_RO_ATTR(numobd); -static int lov_activeobd_seq_show(struct seq_file *m, void *v) +static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct lov_desc *desc; - LASSERT(dev != NULL); desc = &dev->u.lov.desc; - seq_printf(m, "%u\n", desc->ld_active_tgt_count); - return 0; + return sprintf(buf, "%u\n", desc->ld_active_tgt_count); } -LPROC_SEQ_FOPS_RO(lov_activeobd); +LUSTRE_RO_ATTR(activeobd); static int lov_desc_uuid_seq_show(struct seq_file *m, void *v) { @@ -258,48 +258,34 @@ static int lov_target_seq_open(struct inode *inode, struct file *file) return rc; seq = file->private_data; - seq->private = PDE_DATA(inode); + seq->private = inode->i_private; return 0; } -LPROC_SEQ_FOPS_RO_TYPE(lov, uuid); -LPROC_SEQ_FOPS_RO_TYPE(lov, filestotal); -LPROC_SEQ_FOPS_RO_TYPE(lov, filesfree); -LPROC_SEQ_FOPS_RO_TYPE(lov, blksize); -LPROC_SEQ_FOPS_RO_TYPE(lov, kbytestotal); -LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesfree); -LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesavail); - static struct lprocfs_vars lprocfs_lov_obd_vars[] = { - { "uuid", &lov_uuid_fops, NULL, 0 }, { "stripesize", &lov_stripesize_fops, NULL }, { "stripeoffset", &lov_stripeoffset_fops, NULL }, { "stripecount", &lov_stripecount_fops, NULL }, { "stripetype", &lov_stripetype_fops, NULL }, - { "numobd", &lov_numobd_fops, NULL, 0 }, - { "activeobd", &lov_activeobd_fops, NULL, 0 }, - { "filestotal", &lov_filestotal_fops, NULL, 0 }, - { "filesfree", &lov_filesfree_fops, NULL, 0 }, /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ - { "blocksize", &lov_blksize_fops, NULL, 0 }, - { "kbytestotal", &lov_kbytestotal_fops, NULL, 0 }, - { "kbytesfree", &lov_kbytesfree_fops, NULL, 0 }, - { "kbytesavail", &lov_kbytesavail_fops, NULL, 0 }, { "desc_uuid", &lov_desc_uuid_fops, NULL, 0 }, { NULL } }; -LPROC_SEQ_FOPS_RO_TYPE(lov, numrefs); +static struct attribute *lov_attrs[] = { + &lustre_attr_activeobd.attr, + &lustre_attr_numobd.attr, + NULL, +}; -static struct lprocfs_vars lprocfs_lov_module_vars[] = { - { "num_refs", &lov_numrefs_fops, NULL, 0 }, - { NULL } +static struct attribute_group lov_attr_group = { + .attrs = lov_attrs, }; void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_lov_module_vars; - lvars->obd_vars = lprocfs_lov_obd_vars; + lvars->sysfs_vars = &lov_attr_group; + lvars->obd_vars = lprocfs_lov_obd_vars; } const struct file_operations lov_proc_target_fops = { diff --git a/drivers/staging/lustre/lustre/mdc/Makefile b/drivers/staging/lustre/lustre/mdc/Makefile index 2516551a6dc3..99ba9ff0d83a 100644 --- a/drivers/staging/lustre/lustre/mdc/Makefile +++ b/drivers/staging/lustre/lustre/mdc/Makefile @@ -1,3 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += mdc.o -mdc-y := mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o -mdc-$(CONFIG_PROC_FS) += lproc_mdc.o +mdc-y := mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o lproc_mdc.o diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index acfe08e459c0..1c95f87a0e2a 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -40,29 +40,34 @@ #include "../include/lprocfs_status.h" #include "mdc_internal.h" -static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v) +static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + int len; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight); + len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return len; } -static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file, - const char __user *buffer, - size_t count, - loff_t *off) +static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = - ((struct seq_file *)file->private_data)->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; - int val, rc; + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -75,11 +80,11 @@ static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(mdc_max_rpcs_in_flight); +LUSTRE_RW_ATTR(max_rpcs_in_flight); static int mdc_kuc_open(struct inode *inode, struct file *file) { - return single_open(file, NULL, PDE_DATA(inode)); + return single_open(file, NULL, inode->i_private); } /* temporary for testing */ @@ -106,7 +111,7 @@ static ssize_t mdc_kuc_write(struct file *file, len = sizeof(*lh) + sizeof(*hal) + MTI_NAME_MAXLEN + /* for mockup below */ 2 * cfs_size_round(sizeof(*hai)); - OBD_ALLOC(lh, len); + lh = kzalloc(len, GFP_NOFS); if (!lh) return -ENOMEM; @@ -141,13 +146,13 @@ static ssize_t mdc_kuc_write(struct file *file, rc = libcfs_kkuc_msg_put(fp, lh); fput(fp); } - OBD_FREE(lh, len); + kfree(lh); if (rc < 0) return rc; return count; } -struct file_operations mdc_kuc_fops = { +static struct file_operations mdc_kuc_fops = { .open = mdc_kuc_open, .write = mdc_kuc_write, .release = single_release, @@ -155,49 +160,39 @@ struct file_operations mdc_kuc_fops = { LPROC_SEQ_FOPS_WR_ONLY(mdc, ping); -LPROC_SEQ_FOPS_RO_TYPE(mdc, uuid); LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags); -LPROC_SEQ_FOPS_RO_TYPE(mdc, blksize); -LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytestotal); -LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesfree); -LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesavail); -LPROC_SEQ_FOPS_RO_TYPE(mdc, filestotal); -LPROC_SEQ_FOPS_RO_TYPE(mdc, filesfree); LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid); LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid); LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts); LPROC_SEQ_FOPS_RO_TYPE(mdc, state); -static int mdc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v) +/* + * Note: below sysfs entry is provided, but not currently in use, instead + * sbi->sb_md_brw_size is used, the per obd variable should be used + * when DNE is enabled, and dir pages are managed in MDC layer. + * Don't forget to enable sysfs store function then. + */ +static ssize_t max_pages_per_rpc_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - return lprocfs_obd_rd_max_pages_per_rpc(m, m->private); + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + struct client_obd *cli = &dev->u.cli; + + return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc); } -LPROC_SEQ_FOPS_RO(mdc_obd_max_pages_per_rpc); +LUSTRE_RO_ATTR(max_pages_per_rpc); LPROC_SEQ_FOPS_RW_TYPE(mdc, import); LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov); static struct lprocfs_vars lprocfs_mdc_obd_vars[] = { - { "uuid", &mdc_uuid_fops, NULL, 0 }, { "ping", &mdc_ping_fops, NULL, 0222 }, { "connect_flags", &mdc_connect_flags_fops, NULL, 0 }, - { "blocksize", &mdc_blksize_fops, NULL, 0 }, - { "kbytestotal", &mdc_kbytestotal_fops, NULL, 0 }, - { "kbytesfree", &mdc_kbytesfree_fops, NULL, 0 }, - { "kbytesavail", &mdc_kbytesavail_fops, NULL, 0 }, - { "filestotal", &mdc_filestotal_fops, NULL, 0 }, - { "filesfree", &mdc_filesfree_fops, NULL, 0 }, /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ { "mds_server_uuid", &mdc_server_uuid_fops, NULL, 0 }, { "mds_conn_uuid", &mdc_conn_uuid_fops, NULL, 0 }, - /* - * FIXME: below proc entry is provided, but not in used, instead - * sbi->sb_md_brw_size is used, the per obd variable should be used - * when CMD is enabled, and dir pages are managed in MDC layer. - * Remember to enable proc write function. - */ - { "max_pages_per_rpc", &mdc_obd_max_pages_per_rpc_fops, NULL, 0 }, - { "max_rpcs_in_flight", &mdc_max_rpcs_in_flight_fops, NULL, 0 }, { "timeouts", &mdc_timeouts_fops, NULL, 0 }, { "import", &mdc_import_fops, NULL, 0 }, { "state", &mdc_state_fops, NULL, 0 }, @@ -206,15 +201,18 @@ static struct lprocfs_vars lprocfs_mdc_obd_vars[] = { { NULL } }; -LPROC_SEQ_FOPS_RO_TYPE(mdc, numrefs); +static struct attribute *mdc_attrs[] = { + &lustre_attr_max_rpcs_in_flight.attr, + &lustre_attr_max_pages_per_rpc.attr, + NULL, +}; -static struct lprocfs_vars lprocfs_mdc_module_vars[] = { - { "num_refs", &mdc_numrefs_fops, NULL, 0 }, - { NULL } +static struct attribute_group mdc_attr_group = { + .attrs = mdc_attrs, }; void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_mdc_module_vars; + lvars->sysfs_vars = &mdc_attr_group; lvars->obd_vars = lprocfs_mdc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index 81780c943a08..4d149435e949 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -40,14 +40,7 @@ #include "../include/lustre_mdc.h" #include "../include/lustre_mds.h" -#if defined CONFIG_PROC_FS void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars); -#else -static inline void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -#endif void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid, struct obd_capa *oc, __u64 valid, int ea_size, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index d1c224ecd2b7..bcb6c00c49ff 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -746,7 +746,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, LDLM_DEBUG(lock, "layout lock returned by: %s, lvb_len: %d\n", ldlm_it2str(it->it_op), lvb_len); - OBD_ALLOC_LARGE(lmm, lvb_len); + lmm = libcfs_kvzalloc(lvb_len, GFP_NOFS); if (lmm == NULL) { LDLM_LOCK_PUT(lock); return -ENOMEM; @@ -763,7 +763,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, } unlock_res_and_lock(lock); if (lmm != NULL) - OBD_FREE_LARGE(lmm, lvb_len); + kvfree(lmm); } if (lock != NULL) LDLM_LOCK_PUT(lock); @@ -1251,7 +1251,7 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env, rc = mdc_finish_intent_lock(exp, req, &minfo->mi_data, it, lockh); out: - OBD_FREE_PTR(einfo); + kfree(einfo); minfo->mi_cb(req, minfo, rc); return 0; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index f8ef5fe5e771..7f208a6621e6 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -75,11 +75,11 @@ static int mdc_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req, if (IS_ERR(c)) { CDEBUG(D_INFO, "alloc capa failed!\n"); return PTR_ERR(c); - } else { - c->c_capa = *capa; - *oc = c; - return 0; } + + c->c_capa = *capa; + *oc = c; + return 0; } static inline int mdc_queue_wait(struct ptlrpc_request *req) @@ -1201,7 +1201,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) /* Key is KEY_FID2PATH + getinfo_fid2path description */ keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf); - OBD_ALLOC(key, keylen); + key = kzalloc(keylen, GFP_NOFS); if (key == NULL) return -ENOMEM; memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH)); @@ -1234,7 +1234,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path); out: - OBD_FREE(key, keylen); + kfree(key); return rc; } @@ -1604,7 +1604,7 @@ static int mdc_changelog_send_thread(void *csdata) CDEBUG(D_CHANGELOG, "changelog to fp=%p start %llu\n", cs->cs_fp, cs->cs_startrec); - OBD_ALLOC(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE); + cs->cs_buf = kzalloc(KUC_CHANGELOG_MSG_MAXSIZE, GFP_NOFS); if (cs->cs_buf == NULL) { rc = -ENOMEM; goto out; @@ -1644,9 +1644,8 @@ out: llog_cat_close(NULL, llh); if (ctxt) llog_ctxt_put(ctxt); - if (cs->cs_buf) - OBD_FREE(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE); - OBD_FREE_PTR(cs); + kfree(cs->cs_buf); + kfree(cs); return rc; } @@ -1657,7 +1656,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd, int rc; /* Freed in mdc_changelog_send_thread */ - OBD_ALLOC_PTR(cs); + cs = kzalloc(sizeof(*cs), GFP_NOFS); if (!cs) return -ENOMEM; @@ -1679,7 +1678,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd, } CERROR("Failed to start changelog thread: %d\n", rc); - OBD_FREE_PTR(cs); + kfree(cs); return rc; } @@ -1819,10 +1818,7 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); - if (rc) - goto out; -out: ptlrpc_req_finished(req); return rc; } @@ -1937,7 +1933,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct if_quotactl *qctl = karg; struct obd_quotactl *oqctl; - OBD_ALLOC_PTR(oqctl); + oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS); if (oqctl == NULL) { rc = -ENOMEM; goto out; @@ -1951,7 +1947,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, qctl->obd_uuid = obd->u.cli.cl_target_uuid; } - OBD_FREE_PTR(oqctl); + kfree(oqctl); goto out; } case LL_IOC_GET_CONNECT_FLAGS: @@ -2094,7 +2090,6 @@ static int mdc_hsm_copytool_send(int len, void *val) { struct kuc_hdr *lh = (struct kuc_hdr *)val; struct hsm_action_list *hal = (struct hsm_action_list *)(lh + 1); - int rc; if (len < sizeof(*lh) + sizeof(*hal)) { CERROR("Short HSM message %d < %d\n", len, @@ -2115,9 +2110,7 @@ static int mdc_hsm_copytool_send(int len, void *val) lh->kuc_msglen, hal->hal_count, hal->hal_fsname); /* Broadcast to HSM listeners */ - rc = libcfs_kkuc_group_put(KUC_GRP_HSM, lh); - - return rc; + return libcfs_kkuc_group_put(KUC_GRP_HSM, lh); } /** @@ -2430,14 +2423,14 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) struct lprocfs_static_vars lvars = { NULL }; int rc; - OBD_ALLOC(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock)); + cli->cl_rpc_lock = kzalloc(sizeof(*cli->cl_rpc_lock), GFP_NOFS); if (!cli->cl_rpc_lock) return -ENOMEM; mdc_init_rpc_lock(cli->cl_rpc_lock); ptlrpcd_addref(); - OBD_ALLOC(cli->cl_close_lock, sizeof(*cli->cl_close_lock)); + cli->cl_close_lock = kzalloc(sizeof(*cli->cl_close_lock), GFP_NOFS); if (!cli->cl_close_lock) { rc = -ENOMEM; goto err_rpc_lock; @@ -2448,7 +2441,7 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) if (rc) goto err_close_lock; lprocfs_mdc_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars); + lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); @@ -2465,9 +2458,9 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) return rc; err_close_lock: - OBD_FREE(cli->cl_close_lock, sizeof(*cli->cl_close_lock)); + kfree(cli->cl_close_lock); err_rpc_lock: - OBD_FREE(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock)); + kfree(cli->cl_rpc_lock); ptlrpcd_decref(); return rc; } @@ -2525,8 +2518,8 @@ static int mdc_cleanup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; - OBD_FREE(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock)); - OBD_FREE(cli->cl_close_lock, sizeof(*cli->cl_close_lock)); + kfree(cli->cl_rpc_lock); + kfree(cli->cl_close_lock); ptlrpcd_decref(); @@ -2714,7 +2707,7 @@ static int __init mdc_init(void) lprocfs_mdc_init_vars(&lvars); - return class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars, + return class_register_type(&mdc_obd_ops, &mdc_md_ops, LUSTRE_MDC_NAME, NULL); } diff --git a/drivers/staging/lustre/lustre/mgc/Makefile b/drivers/staging/lustre/lustre/mgc/Makefile index cc6e9f51a8e8..8ea29a89cf50 100644 --- a/drivers/staging/lustre/lustre/mgc/Makefile +++ b/drivers/staging/lustre/lustre/mgc/Makefile @@ -1,3 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += mgc.o -mgc-y := mgc_request.o -mgc-$(CONFIG_PROC_FS) += lproc_mgc.o +mgc-y := mgc_request.o lproc_mgc.o diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index c4ea38e5f077..34a9317d6d63 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -40,7 +40,6 @@ #include "../include/lprocfs_status.h" #include "mgc_internal.h" -LPROC_SEQ_FOPS_RO_TYPE(mgc, uuid); LPROC_SEQ_FOPS_RO_TYPE(mgc, connect_flags); LPROC_SEQ_FOPS_RO_TYPE(mgc, server_uuid); LPROC_SEQ_FOPS_RO_TYPE(mgc, conn_uuid); @@ -56,7 +55,6 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v) LPROC_SEQ_FOPS_RO(mgc_ir_state); static struct lprocfs_vars lprocfs_mgc_obd_vars[] = { - { "uuid", &mgc_uuid_fops, NULL, 0 }, { "ping", &mgc_ping_fops, NULL, 0222 }, { "connect_flags", &mgc_connect_flags_fops, NULL, 0 }, { "mgs_server_uuid", &mgc_server_uuid_fops, NULL, 0 }, @@ -67,14 +65,7 @@ static struct lprocfs_vars lprocfs_mgc_obd_vars[] = { { NULL } }; -LPROC_SEQ_FOPS_RO_TYPE(mgc, numrefs); -static struct lprocfs_vars lprocfs_mgc_module_vars[] = { - { "num_refs", &mgc_numrefs_fops, NULL, 0 }, - { NULL } -}; - void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_mgc_module_vars; lvars->obd_vars = lprocfs_mgc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h index a6f8b3ced2e7..82fb8f46e037 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h +++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h @@ -44,19 +44,8 @@ #include "../include/lustre_log.h" #include "../include/lustre_export.h" -#if defined (CONFIG_PROC_FS) void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars); int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data); -#else -static inline void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -static inline int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) -{ - return 0; -} -#endif /* CONFIG_PROC_FS */ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 7947aec5c847..174dfc32876b 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -149,7 +149,7 @@ static void config_log_put(struct config_llog_data *cld) sptlrpc_conf_log_stop(cld->cld_logname); class_export_put(cld->cld_mgcexp); - OBD_FREE(cld, sizeof(*cld) + strlen(cld->cld_logname) + 1); + kfree(cld); } } @@ -198,7 +198,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, CDEBUG(D_MGC, "do adding config log %s:%p\n", logname, cfg ? cfg->cfg_instance : NULL); - OBD_ALLOC(cld, sizeof(*cld) + strlen(logname) + 1); + cld = kzalloc(sizeof(*cld) + strlen(logname) + 1, GFP_NOFS); if (!cld) return ERR_PTR(-ENOMEM); @@ -448,7 +448,6 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) return rc; } -#if defined (CONFIG_PROC_FS) int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) { struct obd_device *obd = data; @@ -477,7 +476,6 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) LPROCFS_CLIMP_EXIT(obd); return 0; } -#endif /* reenqueue any lost locks */ #define RQ_RUNNING 0x1 @@ -722,7 +720,7 @@ static int mgc_cleanup(struct obd_device *obd) static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { - struct lprocfs_static_vars lvars; + struct lprocfs_static_vars lvars = { NULL }; int rc; ptlrpcd_addref(); @@ -738,7 +736,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) } lprocfs_mgc_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars); + lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); sptlrpc_lprocfs_cliobd_attach(obd); if (atomic_inc_return(&mgc_count) == 1) { @@ -1129,14 +1127,14 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, LASSERT(cfg->cfg_instance != NULL); LASSERT(cfg->cfg_sb == cfg->cfg_instance); - OBD_ALLOC(inst, PAGE_CACHE_SIZE); + inst = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); if (inst == NULL) return -ENOMEM; if (!IS_SERVER(lsi)) { pos = snprintf(inst, PAGE_CACHE_SIZE, "%p", cfg->cfg_instance); if (pos >= PAGE_CACHE_SIZE) { - OBD_FREE(inst, PAGE_CACHE_SIZE); + kfree(inst); return -E2BIG; } } else { @@ -1144,7 +1142,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, rc = server_name2svname(lsi->lsi_svname, inst, NULL, PAGE_CACHE_SIZE); if (rc) { - OBD_FREE(inst, PAGE_CACHE_SIZE); + kfree(inst); return -EINVAL; } pos = strlen(inst); @@ -1302,7 +1300,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, /* continue, even one with error */ } - OBD_FREE(inst, PAGE_CACHE_SIZE); + kfree(inst); return rc; } @@ -1336,7 +1334,7 @@ static int mgc_process_recover_log(struct obd_device *obd, if (cfg->cfg_last_idx == 0) /* the first time */ nrpages = CONFIG_READ_NRPAGES_INIT; - OBD_ALLOC(pages, sizeof(*pages) * nrpages); + pages = kcalloc(nrpages, sizeof(*pages), GFP_NOFS); if (pages == NULL) { rc = -ENOMEM; goto out; @@ -1466,7 +1464,7 @@ out: break; __free_page(pages[i]); } - OBD_FREE(pages, sizeof(*pages) * nrpages); + kfree(pages); } return rc; } @@ -1494,7 +1492,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc, if (cld->cld_cfg.cfg_sb) lsi = s2lsi(cld->cld_cfg.cfg_sb); - OBD_ALLOC_PTR(env); + env = kzalloc(sizeof(*env), GFP_NOFS); if (env == NULL) return -ENOMEM; @@ -1540,7 +1538,7 @@ out_pop: lu_env_fini(env); out_free: - OBD_FREE_PTR(env); + kfree(env); return rc; } @@ -1745,7 +1743,7 @@ struct obd_ops mgc_obd_ops = { static int __init mgc_init(void) { - return class_register_type(&mgc_obd_ops, NULL, NULL, + return class_register_type(&mgc_obd_ops, NULL, LUSTRE_MGC_NAME, NULL); } diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index e894681797c2..d0f70b41acf6 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -6,6 +6,4 @@ obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \ lustre_handles.o lustre_peer.o \ statfs_pack.o obdo.o obd_config.o obd_mount.o \ lu_object.o dt_object.o capa.o cl_object.o \ - cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o - -obdclass-$(CONFIG_PROC_FS) += lprocfs_counters.o + cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o lprocfs_counters.o diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index 9a69f6b35a0e..bc3fc4780cb9 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/drivers/staging/lustre/lustre/obdclass/acl.c @@ -104,12 +104,12 @@ static int lustre_posix_acl_xattr_reduce_space(posix_acl_xattr_header **header, if (unlikely(old_count <= new_count)) return old_size; - OBD_ALLOC(new, new_size); + new = kzalloc(new_size, GFP_NOFS); if (unlikely(new == NULL)) return -ENOMEM; memcpy(new, *header, new_size); - OBD_FREE(*header, old_size); + kfree(*header); *header = new; return new_size; } @@ -120,18 +120,17 @@ static int lustre_ext_acl_xattr_reduce_space(ext_acl_xattr_header **header, { int ext_count = le32_to_cpu((*header)->a_count); int ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr); - int old_size = CFS_ACL_XATTR_SIZE(old_count, ext_acl_xattr); ext_acl_xattr_header *new; if (unlikely(old_count <= ext_count)) return 0; - OBD_ALLOC(new, ext_size); + new = kzalloc(ext_size, GFP_NOFS); if (unlikely(new == NULL)) return -ENOMEM; memcpy(new, *header, ext_size); - OBD_FREE(*header, old_size); + kfree(*header); *header = new; return 0; } @@ -152,7 +151,7 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size) else count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr); esize = CFS_ACL_XATTR_SIZE(count, ext_acl_xattr); - OBD_ALLOC(new, esize); + new = kzalloc(esize, GFP_NOFS); if (unlikely(new == NULL)) return ERR_PTR(-ENOMEM); @@ -183,7 +182,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size, if (size < sizeof(*new)) return -EINVAL; - OBD_ALLOC(new, size); + new = kzalloc(size, GFP_NOFS); if (unlikely(new == NULL)) return -ENOMEM; @@ -232,7 +231,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size, _out: if (rc) { - OBD_FREE(new, size); + kfree(new); size = rc; } return size; @@ -244,7 +243,7 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_filter); */ void lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size) { - OBD_FREE(header, size); + kfree(header); } EXPORT_SYMBOL(lustre_posix_acl_xattr_free); @@ -253,8 +252,7 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_free); */ void lustre_ext_acl_xattr_free(ext_acl_xattr_header *header) { - OBD_FREE(header, CFS_ACL_XATTR_SIZE(le32_to_cpu(header->a_count), \ - ext_acl_xattr)); + kfree(header); } EXPORT_SYMBOL(lustre_ext_acl_xattr_free); @@ -309,7 +307,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, /* there are only base ACL entries at most. */ posix_count = 3; posix_size = CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr); - OBD_ALLOC(new, posix_size); + new = kzalloc(posix_size, GFP_NOFS); if (unlikely(new == NULL)) return -ENOMEM; @@ -360,7 +358,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, posix_count = ori_posix_count + ext_count; posix_size = CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr); - OBD_ALLOC(new, posix_size); + new = kzalloc(posix_size, GFP_NOFS); if (unlikely(new == NULL)) return -ENOMEM; @@ -402,7 +400,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, _out: if (rc) { - OBD_FREE(new, posix_size); + kfree(new); posix_size = rc; } return posix_size; @@ -432,7 +430,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, ext_count = posix_count + ori_ext_count; ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr); - OBD_ALLOC(new, ext_size); + new = kzalloc(ext_size, GFP_NOFS); if (unlikely(new == NULL)) return ERR_PTR(-ENOMEM); @@ -538,7 +536,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, out: if (rc) { - OBD_FREE(new, ext_size); + kfree(new); new = ERR_PTR(rc); } return new; diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c index d206b1046a18..d8d1a66ad68e 100644 --- a/drivers/staging/lustre/lustre/obdclass/capa.c +++ b/drivers/staging/lustre/lustre/obdclass/capa.c @@ -87,7 +87,7 @@ struct hlist_head *init_capa_hash(void) struct hlist_head *hash; int nr_hash, i; - OBD_ALLOC(hash, PAGE_CACHE_SIZE); + hash = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); if (!hash) return NULL; @@ -129,7 +129,7 @@ void cleanup_capa_hash(struct hlist_head *hash) } spin_unlock(&capa_lock); - OBD_FREE(hash, PAGE_CACHE_SIZE); + kfree(hash); } EXPORT_SYMBOL(cleanup_capa_hash); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 3141b6043708..fd1a4c5421e8 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -612,7 +612,7 @@ EXPORT_SYMBOL(cl_io_lock_add); static void cl_free_io_lock_link(const struct lu_env *env, struct cl_io_lock_link *link) { - OBD_FREE_PTR(link); + kfree(link); } /** @@ -624,7 +624,7 @@ int cl_io_lock_alloc_add(const struct lu_env *env, struct cl_io *io, struct cl_io_lock_link *link; int result; - OBD_ALLOC_PTR(link); + link = kzalloc(sizeof(*link), GFP_NOFS); if (link != NULL) { link->cill_descr = *descr; link->cill_fini = cl_free_io_lock_link; @@ -1387,9 +1387,9 @@ 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])); + kfree(req->crq_o); } - OBD_FREE_PTR(req); + kfree(req); } static int cl_req_init(const struct lu_env *env, struct cl_req *req, @@ -1448,7 +1448,7 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, LINVRNT(nr_objects > 0); - OBD_ALLOC_PTR(req); + req = kzalloc(sizeof(*req), GFP_NOFS); if (req != NULL) { int result; @@ -1456,7 +1456,8 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, INIT_LIST_HEAD(&req->crq_pages); INIT_LIST_HEAD(&req->crq_layers); - OBD_ALLOC(req->crq_o, nr_objects * sizeof(req->crq_o[0])); + req->crq_o = kcalloc(nr_objects, sizeof(req->crq_o[0]), + GFP_NOFS); if (req->crq_o != NULL) { req->crq_nrobjs = nr_objects; result = cl_req_init(env, req, page); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index f13d1fbffd9d..163fe0cd7f9a 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -906,10 +906,8 @@ struct lu_env *cl_env_nested_get(struct cl_env_nest *nest) if (env != NULL) { if (!cl_io_is_going(env)) return env; - else { - cl_env_put(env, &nest->cen_refcheck); - nest->cen_cookie = cl_env_reenter(); - } + cl_env_put(env, &nest->cen_refcheck); + nest->cen_cookie = cl_env_reenter(); } env = cl_env_get(&nest->cen_refcheck); if (IS_ERR(env)) { diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index b7dd04808060..a7f3032f34dd 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -62,12 +62,6 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg, # define PINVRNT(env, page, exp) \ ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp)) -/* Disable page statistic by default due to huge performance penalty. */ -#define CS_PAGE_INC(o, item) -#define CS_PAGE_DEC(o, item) -#define CS_PAGESTATE_INC(o, state) -#define CS_PAGESTATE_DEC(o, state) - /** * Internal version of cl_page_top, it should be called if the page is * known to be not freed, says with page referenced, or radix tree lock held, @@ -248,7 +242,6 @@ EXPORT_SYMBOL(cl_page_gang_lookup); static void cl_page_free(const struct lu_env *env, struct cl_page *page) { struct cl_object *obj = page->cp_obj; - int pagesize = cl_object_header(obj)->coh_page_bufsize; PASSERT(env, page, list_empty(&page->cp_batch)); PASSERT(env, page, page->cp_owner == NULL); @@ -265,12 +258,10 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page) list_del_init(page->cp_layers.next); slice->cpl_ops->cpo_fini(env, slice); } - CS_PAGE_DEC(obj, total); - CS_PAGESTATE_DEC(obj, page->cp_state); lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page); cl_object_put(env, obj); lu_ref_fini(&page->cp_reference); - OBD_FREE(page, pagesize); + kfree(page); } /** @@ -324,11 +315,6 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env, } } } - if (result == 0) { - CS_PAGE_INC(o, total); - CS_PAGE_INC(o, create); - CS_PAGESTATE_DEC(o, CPS_CACHED); - } } else { page = ERR_PTR(-ENOMEM); } @@ -361,7 +347,6 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, might_sleep(); hdr = cl_object_header(o); - CS_PAGE_INC(o, lookup); CDEBUG(D_PAGE, "%lu@"DFID" %p %lx %d\n", idx, PFID(&hdr->coh_lu.loh_fid), vmpage, vmpage->private, type); @@ -388,7 +373,6 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, } if (page != NULL) { - CS_PAGE_INC(o, hit); return page; } @@ -555,8 +539,6 @@ static void cl_page_state_set0(const struct lu_env *env, PASSERT(env, page, equi(state == CPS_OWNED, page->cp_owner != NULL)); - CS_PAGESTATE_DEC(page->cp_obj, page->cp_state); - CS_PAGESTATE_INC(page->cp_obj, state); cl_page_state_set_trust(page, state); } } diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index d4b74b670c43..1bc37566b3a5 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -231,7 +231,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) err = -EINVAL; goto out; } - OBD_ALLOC(lcfg, data->ioc_plen1); + lcfg = kzalloc(data->ioc_plen1, GFP_NOFS); if (lcfg == NULL) { err = -ENOMEM; goto out; @@ -243,7 +243,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) if (!err) err = class_process_config(lcfg); - OBD_FREE(lcfg, data->ioc_plen1); + kfree(lcfg); goto out; } @@ -506,15 +506,8 @@ int obd_init_checks(void) return ret; } -#if defined (CONFIG_PROC_FS) extern int class_procfs_init(void); extern int class_procfs_clean(void); -#else -static inline int class_procfs_init(void) -{ return 0; } -static inline int class_procfs_clean(void) -{ return 0; } -#endif static int __init init_obdclass(void) { @@ -529,24 +522,22 @@ static int __init init_obdclass(void) spin_lock_init(&obd_types_lock); obd_zombie_impexp_init(); - if (IS_ENABLED(CONFIG_PROC_FS)) { - obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM, - LPROCFS_STATS_FLAG_NONE | - LPROCFS_STATS_FLAG_IRQ_SAFE); + obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM, + LPROCFS_STATS_FLAG_NONE | + LPROCFS_STATS_FLAG_IRQ_SAFE); - if (obd_memory == NULL) { - CERROR("kmalloc of 'obd_memory' failed\n"); - return -ENOMEM; - } - - lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT, - LPROCFS_CNTR_AVGMINMAX, - "memused", "bytes"); - lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT, - LPROCFS_CNTR_AVGMINMAX, - "pagesused", "pages"); + if (obd_memory == NULL) { + CERROR("kmalloc of 'obd_memory' failed\n"); + return -ENOMEM; } + lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT, + LPROCFS_CNTR_AVGMINMAX, + "memused", "bytes"); + lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT, + LPROCFS_CNTR_AVGMINMAX, + "pagesused", "pages"); + err = obd_init_checks(); if (err == -EOVERFLOW) return err; @@ -620,7 +611,6 @@ void obd_update_maxusage(void) } EXPORT_SYMBOL(obd_update_maxusage); -#if defined (CONFIG_PROC_FS) __u64 obd_memory_max(void) { __u64 ret; @@ -644,7 +634,6 @@ __u64 obd_pages_max(void) return ret; } EXPORT_SYMBOL(obd_pages_max); -#endif /* liblustre doesn't call cleanup_obdclass, apparently. we carry on in this * ifdef to the end of the file to cover module and versioning goo.*/ diff --git a/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c index b1eee0a6dc9a..b67b0feb03e0 100644 --- a/drivers/staging/lustre/lustre/obdclass/dt_object.c +++ b/drivers/staging/lustre/lustre/obdclass/dt_object.c @@ -49,8 +49,6 @@ /* fid_be_to_cpu() */ #include "../include/lustre_fid.h" -#include "../include/lustre_quota.h" - /* context key constructor/destructor: dt_global_key_init, dt_global_key_fini */ LU_KEY_INIT(dt_global, struct dt_thread_info); LU_KEY_FINI(dt_global, struct dt_thread_info); @@ -237,7 +235,8 @@ EXPORT_SYMBOL(dt_locate_at); /** * find a object named \a entry in given \a dfh->dfh_o directory. */ -static int dt_find_entry(const struct lu_env *env, const char *entry, void *data) +static int dt_find_entry(const struct lu_env *env, + const char *entry, void *data) { struct dt_find_hint *dfh = data; struct dt_device *dt = dfh->dfh_dt; @@ -330,9 +329,9 @@ static struct dt_object *dt_reg_open(const struct lu_env *env, int result; result = dt_lookup_dir(env, p, name, fid); - if (result == 0){ + if (result == 0) o = dt_locate(env, dt, fid); - } else + else o = ERR_PTR(result); return o; @@ -923,7 +922,7 @@ int dt_index_read(const struct lu_env *env, struct dt_device *dev, ii->ii_version = dt_version_get(env, obj); /* walk the index and fill lu_idxpages with key/record pairs */ - rc = dt_index_walk(env, obj, rdpg, dt_index_page_build ,ii); + rc = dt_index_walk(env, obj, rdpg, dt_index_page_build, ii); dt_read_unlock(env, obj); if (rc == 0) { @@ -939,8 +938,6 @@ out: } EXPORT_SYMBOL(dt_index_read); -#if defined (CONFIG_PROC_FS) - int lprocfs_dt_rd_blksize(char *page, char **start, off_t off, int count, int *eof, void *data) { @@ -1055,5 +1052,3 @@ int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off, return rc; } EXPORT_SYMBOL(lprocfs_dt_rd_filesfree); - -#endif /* CONFIG_PROC_FS */ diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 66b56784f674..978c3c5c460a 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -156,7 +156,7 @@ EXPORT_SYMBOL(class_put_type); #define CLASS_MAX_NAME 1024 int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, - struct lprocfs_vars *vars, const char *name, + const char *name, struct lu_device_type *ldt) { struct obd_type *type; @@ -171,13 +171,13 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, } rc = -ENOMEM; - OBD_ALLOC(type, sizeof(*type)); + type = kzalloc(sizeof(*type), GFP_NOFS); if (type == NULL) return rc; - OBD_ALLOC_PTR(type->typ_dt_ops); - OBD_ALLOC_PTR(type->typ_md_ops); - OBD_ALLOC(type->typ_name, strlen(name) + 1); + type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); + type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS); + type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS); if (type->typ_dt_ops == NULL || type->typ_md_ops == NULL || @@ -191,11 +191,19 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, strcpy(type->typ_name, name); spin_lock_init(&type->obd_type_lock); - type->typ_procroot = lprocfs_register(type->typ_name, proc_lustre_root, - vars, type); - if (IS_ERR(type->typ_procroot)) { - rc = PTR_ERR(type->typ_procroot); - type->typ_procroot = NULL; + type->typ_debugfs_entry = ldebugfs_register(type->typ_name, + debugfs_lustre_root, + NULL, type); + if (IS_ERR_OR_NULL(type->typ_debugfs_entry)) { + rc = type->typ_debugfs_entry ? PTR_ERR(type->typ_debugfs_entry) + : -ENOMEM; + type->typ_debugfs_entry = NULL; + goto failed; + } + + type->typ_kobj = kobject_create_and_add(type->typ_name, lustre_kobj); + if (!type->typ_kobj) { + rc = -ENOMEM; goto failed; } @@ -213,13 +221,12 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, return 0; failed: - if (type->typ_name != NULL) - OBD_FREE(type->typ_name, strlen(name) + 1); - if (type->typ_md_ops != NULL) - OBD_FREE_PTR(type->typ_md_ops); - if (type->typ_dt_ops != NULL) - OBD_FREE_PTR(type->typ_dt_ops); - OBD_FREE(type, sizeof(*type)); + if (type->typ_kobj) + kobject_put(type->typ_kobj); + kfree(type->typ_name); + kfree(type->typ_md_ops); + kfree(type->typ_dt_ops); + kfree(type); return rc; } EXPORT_SYMBOL(class_register_type); @@ -237,14 +244,16 @@ int class_unregister_type(const char *name) CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt); /* This is a bad situation, let's make the best of it */ /* Remove ops, but leave the name for debugging */ - OBD_FREE_PTR(type->typ_dt_ops); - OBD_FREE_PTR(type->typ_md_ops); + kfree(type->typ_dt_ops); + kfree(type->typ_md_ops); return -EBUSY; } - if (type->typ_procroot) { - lprocfs_remove(&type->typ_procroot); - } + if (type->typ_kobj) + kobject_put(type->typ_kobj); + + if (!IS_ERR_OR_NULL(type->typ_debugfs_entry)) + ldebugfs_remove(&type->typ_debugfs_entry); if (type->typ_lu) lu_device_type_fini(type->typ_lu); @@ -252,12 +261,10 @@ int class_unregister_type(const char *name) spin_lock(&obd_types_lock); list_del(&type->typ_chain); spin_unlock(&obd_types_lock); - OBD_FREE(type->typ_name, strlen(name) + 1); - if (type->typ_dt_ops != NULL) - OBD_FREE_PTR(type->typ_dt_ops); - if (type->typ_md_ops != NULL) - OBD_FREE_PTR(type->typ_md_ops); - OBD_FREE(type, sizeof(*type)); + kfree(type->typ_name); + kfree(type->typ_dt_ops); + kfree(type->typ_md_ops); + kfree(type); return 0; } /* class_unregister_type */ EXPORT_SYMBOL(class_unregister_type); @@ -819,7 +826,7 @@ struct obd_export *class_new_export(struct obd_device *obd, struct cfs_hash *hash = NULL; int rc = 0; - OBD_ALLOC_PTR(export); + export = kzalloc(sizeof(*export), GFP_NOFS); if (!export) return ERR_PTR(-ENOMEM); @@ -904,7 +911,7 @@ exit_err: class_handle_unhash(&export->exp_handle); LASSERT(hlist_unhashed(&export->exp_uuid_hash)); obd_destroy_export(export); - OBD_FREE_PTR(export); + kfree(export); return ERR_PTR(rc); } EXPORT_SYMBOL(class_new_export); @@ -945,7 +952,7 @@ static void class_import_destroy(struct obd_import *imp) struct obd_import_conn, oic_item); list_del_init(&imp_conn->oic_item); ptlrpc_put_connection_superhack(imp_conn->oic_conn); - OBD_FREE(imp_conn, sizeof(*imp_conn)); + kfree(imp_conn); } LASSERT(imp->imp_sec == NULL); @@ -1008,7 +1015,7 @@ struct obd_import *class_new_import(struct obd_device *obd) { struct obd_import *imp; - OBD_ALLOC(imp, sizeof(*imp)); + imp = kzalloc(sizeof(*imp), GFP_NOFS); if (imp == NULL) return NULL; @@ -1811,7 +1818,7 @@ void *kuc_alloc(int payload_len, int transport, int type) struct kuc_hdr *lh; int len = kuc_len(payload_len); - OBD_ALLOC(lh, len); + lh = kzalloc(len, GFP_NOFS); if (lh == NULL) return ERR_PTR(-ENOMEM); @@ -1828,6 +1835,6 @@ EXPORT_SYMBOL(kuc_alloc); inline void kuc_free(void *p, int payload_len) { struct kuc_hdr *lh = kuc_ptr(p); - OBD_FREE(lh, kuc_len(payload_len)); + kfree(lh); } EXPORT_SYMBOL(kuc_free); diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 06944b863d16..84f75dce0d4c 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -53,7 +53,6 @@ #include <linux/fcntl.h> #include <linux/delay.h> #include <linux/skbuff.h> -#include <linux/proc_fs.h> #include <linux/fs.h> #include <linux/poll.h> #include <linux/list.h> @@ -64,6 +63,7 @@ #include <linux/uaccess.h> #include <linux/miscdevice.h> #include <linux/seq_file.h> +#include <linux/kobject.h> #include "../../../include/linux/libcfs/libcfs.h" #include "../../../include/linux/lnet/lnetctl.h" @@ -107,7 +107,7 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) * system, the high lock contention will hurt performance badly, * obdfilter-survey is an example, which relies on ioctl. So we'd * better avoid vmalloc on ioctl path. LU-66 */ - OBD_ALLOC_LARGE(*buf, hdr.ioc_len); + *buf = libcfs_kvzalloc(hdr.ioc_len, GFP_NOFS); if (*buf == NULL) { CERROR("Cannot allocate control buffer of len %d\n", hdr.ioc_len); @@ -153,7 +153,7 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) return 0; free_buf: - OBD_FREE_LARGE(*buf, hdr.ioc_len); + kvfree(*buf); return err; } EXPORT_SYMBOL(obd_ioctl_getdata); @@ -216,29 +216,27 @@ struct miscdevice obd_psdev = { }; -#if defined (CONFIG_PROC_FS) -static int obd_proc_version_seq_show(struct seq_file *m, void *v) +static ssize_t version_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - seq_printf(m, "lustre: %s\nkernel: %s\nbuild: %s\n", - LUSTRE_VERSION_STRING, "patchless_client", BUILD_VERSION); - return 0; + return sprintf(buf, "%s\n", LUSTRE_VERSION_STRING); } -LPROC_SEQ_FOPS_RO(obd_proc_version); -int obd_proc_pinger_seq_show(struct seq_file *m, void *v) +static ssize_t pinger_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - seq_printf(m, "%s\n", "on"); - return 0; + return sprintf(buf, "%s\n", "on"); } -LPROC_SEQ_FOPS_RO(obd_proc_pinger); -static int obd_proc_health_seq_show(struct seq_file *m, void *v) +static ssize_t health_show(struct kobject *kobj, struct attribute *attr, + char *buf) { bool healthy = true; int i; + size_t len = 0; if (libcfs_catastrophe) - seq_printf(m, "LBUG\n"); + return sprintf(buf, "LBUG\n"); read_lock(&obd_dev_lock); for (i = 0; i < class_devno_max(); i++) { @@ -256,8 +254,6 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v) read_unlock(&obd_dev_lock); if (obd_health_check(NULL, obd)) { - seq_printf(m, "device %s reported unhealthy\n", - obd->obd_name); healthy = false; } class_decref(obd, __func__, current); @@ -266,32 +262,29 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v) read_unlock(&obd_dev_lock); if (healthy) - seq_puts(m, "healthy\n"); + len = sprintf(buf, "healthy\n"); else - seq_puts(m, "NOT HEALTHY\n"); + len = sprintf(buf, "NOT HEALTHY\n"); - return 0; + return len; } -LPROC_SEQ_FOPS_RO(obd_proc_health); -static int obd_proc_jobid_var_seq_show(struct seq_file *m, void *v) +static ssize_t jobid_var_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - seq_printf(m, "%s\n", obd_jobid_var); - return 0; + return snprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_var); } -static ssize_t obd_proc_jobid_var_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, + size_t count) { if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN) return -EINVAL; memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1); - /* This might leave the var invalid on error, which is probably fine.*/ - if (copy_from_user(obd_jobid_var, buffer, count)) - return -EFAULT; + memcpy(obd_jobid_var, buffer, count); /* Trim the trailing '\n' if any */ if (obd_jobid_var[count - 1] == '\n') @@ -299,23 +292,21 @@ static ssize_t obd_proc_jobid_var_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(obd_proc_jobid_var); -static int obd_proc_jobid_name_seq_show(struct seq_file *m, void *v) +static ssize_t jobid_name_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - seq_printf(m, "%s\n", obd_jobid_var); - return 0; + return snprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_node); } -static ssize_t obd_proc_jobid_name_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, + size_t count) { if (!count || count > JOBSTATS_JOBID_SIZE) return -EINVAL; - if (copy_from_user(obd_jobid_node, buffer, count)) - return -EFAULT; + memcpy(obd_jobid_node, buffer, count); obd_jobid_node[count] = 0; @@ -325,20 +316,24 @@ static ssize_t obd_proc_jobid_name_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(obd_proc_jobid_name); - -/* Root for /proc/fs/lustre */ -struct proc_dir_entry *proc_lustre_root = NULL; -EXPORT_SYMBOL(proc_lustre_root); - -struct lprocfs_vars lprocfs_base[] = { - { "version", &obd_proc_version_fops }, - { "pinger", &obd_proc_pinger_fops }, - { "health_check", &obd_proc_health_fops }, - { "jobid_var", &obd_proc_jobid_var_fops }, - { .name = "jobid_name", - .fops = &obd_proc_jobid_name_fops}, - { NULL } + +/* Root for /sys/kernel/debug/lustre */ +struct dentry *debugfs_lustre_root; +EXPORT_SYMBOL_GPL(debugfs_lustre_root); + +LUSTRE_RO_ATTR(version); +LUSTRE_RO_ATTR(pinger); +LUSTRE_RO_ATTR(health); +LUSTRE_RW_ATTR(jobid_var); +LUSTRE_RW_ATTR(jobid_name); + +static struct attribute *lustre_attrs[] = { + &lustre_attr_version.attr, + &lustre_attr_pinger.attr, + &lustre_attr_health.attr, + &lustre_attr_jobid_name.attr, + &lustre_attr_jobid_var.attr, + NULL, }; static void *obd_device_list_seq_start(struct seq_file *p, loff_t *pos) @@ -406,7 +401,7 @@ static int obd_device_list_open(struct inode *inode, struct file *file) return rc; seq = file->private_data; - seq->private = PDE_DATA(inode); + seq->private = inode->i_private; return 0; } @@ -419,31 +414,57 @@ struct file_operations obd_device_list_fops = { .release = seq_release, }; +struct kobject *lustre_kobj; +EXPORT_SYMBOL_GPL(lustre_kobj); + +static struct attribute_group lustre_attr_group = { + .attrs = lustre_attrs, +}; + int class_procfs_init(void) { int rc = 0; + struct dentry *file; + + lustre_kobj = kobject_create_and_add("lustre", fs_kobj); + if (lustre_kobj == NULL) + goto out; + + /* Create the files associated with this kobject */ + rc = sysfs_create_group(lustre_kobj, &lustre_attr_group); + if (rc) { + kobject_put(lustre_kobj); + goto out; + } - proc_lustre_root = lprocfs_register("fs/lustre", NULL, - lprocfs_base, NULL); - if (IS_ERR(proc_lustre_root)) { - rc = PTR_ERR(proc_lustre_root); - proc_lustre_root = NULL; + debugfs_lustre_root = debugfs_create_dir("lustre", NULL); + if (IS_ERR_OR_NULL(debugfs_lustre_root)) { + rc = debugfs_lustre_root ? PTR_ERR(debugfs_lustre_root) + : -ENOMEM; + debugfs_lustre_root = NULL; + kobject_put(lustre_kobj); goto out; } - rc = lprocfs_seq_create(proc_lustre_root, "devices", 0444, - &obd_device_list_fops, NULL); + file = debugfs_create_file("devices", 0444, debugfs_lustre_root, NULL, + &obd_device_list_fops); + if (IS_ERR_OR_NULL(file)) { + rc = file ? PTR_ERR(file) : -ENOMEM; + kobject_put(lustre_kobj); + goto out; + } out: - if (rc) - CERROR("error adding /proc/fs/lustre/devices file\n"); - return 0; + return rc; } int class_procfs_clean(void) { - if (proc_lustre_root) { - lprocfs_remove(&proc_lustre_root); - } + if (debugfs_lustre_root != NULL) + debugfs_remove_recursive(debugfs_lustre_root); + + debugfs_lustre_root = NULL; + + kobject_put(lustre_kobj); + return 0; } -#endif /* CONFIG_PROC_FS */ diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index 4b62d25764ad..54f0a81f7b51 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -38,7 +38,6 @@ #include <linux/sysctl.h> #include <linux/sched.h> #include <linux/mm.h> -#include <linux/proc_fs.h> #include <linux/slab.h> #include <linux/stat.h> #include <linux/ctype.h> @@ -55,30 +54,6 @@ static struct ctl_table_header *obd_table_header; #endif - -#define OBD_SYSCTL 300 - -enum { - OBD_TIMEOUT = 3, /* RPC timeout before recovery/intr */ - OBD_DUMP_ON_TIMEOUT, /* dump kernel debug log upon eviction */ - OBD_MEMUSED, /* bytes currently OBD_ALLOCated */ - OBD_PAGESUSED, /* pages currently OBD_PAGE_ALLOCated */ - OBD_MAXMEMUSED, /* maximum bytes OBD_ALLOCated concurrently */ - OBD_MAXPAGESUSED, /* maximum pages OBD_PAGE_ALLOCated concurrently */ - OBD_SYNCFILTER, /* XXX temporary, as we play with sync osts.. */ - OBD_LDLM_TIMEOUT, /* LDLM timeout for ASTs before client eviction */ - OBD_DUMP_ON_EVICTION, /* dump kernel debug log upon eviction */ - OBD_DEBUG_PEER_ON_TIMEOUT, /* dump peer debug when RPC times out */ - OBD_ALLOC_FAIL_RATE, /* memory allocation random failure rate */ - OBD_MAX_DIRTY_PAGES, /* maximum dirty pages */ - OBD_AT_MIN, /* Adaptive timeouts params */ - OBD_AT_MAX, - OBD_AT_EXTRA, - OBD_AT_EARLY_MARGIN, - OBD_AT_HISTORY, -}; - - #ifdef CONFIG_SYSCTL static int proc_set_timeout(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 114be4a78ccf..4fa52d1b79d1 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -60,7 +60,7 @@ static struct llog_handle *llog_alloc_handle(void) { struct llog_handle *loghandle; - OBD_ALLOC_PTR(loghandle); + loghandle = kzalloc(sizeof(*loghandle), GFP_NOFS); if (loghandle == NULL) return NULL; @@ -88,9 +88,9 @@ static void llog_free_handle(struct llog_handle *loghandle) else if (loghandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) LASSERT(list_empty(&loghandle->u.chd.chd_head)); LASSERT(sizeof(*(loghandle->lgh_hdr)) == LLOG_CHUNK_SIZE); - OBD_FREE(loghandle->lgh_hdr, LLOG_CHUNK_SIZE); + kfree(loghandle->lgh_hdr); out: - OBD_FREE_PTR(loghandle); + kfree(loghandle); } void llog_handle_get(struct llog_handle *loghandle) @@ -207,7 +207,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, LASSERT(handle->lgh_hdr == NULL); - OBD_ALLOC_PTR(llh); + llh = kzalloc(sizeof(*llh), GFP_NOFS); if (llh == NULL) return -ENOMEM; handle->lgh_hdr = llh; @@ -261,7 +261,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, } out: if (rc) { - OBD_FREE_PTR(llh); + kfree(llh); handle->lgh_hdr = NULL; } return rc; @@ -283,7 +283,7 @@ static int llog_process_thread(void *arg) LASSERT(llh); - OBD_ALLOC(buf, LLOG_CHUNK_SIZE); + buf = kzalloc(LLOG_CHUNK_SIZE, GFP_NOFS); if (!buf) { lpi->lpi_rc = -ENOMEM; return 0; @@ -400,7 +400,7 @@ out: if (cd != NULL) cd->lpcd_last_idx = last_called_index; - OBD_FREE(buf, LLOG_CHUNK_SIZE); + kfree(buf); lpi->lpi_rc = rc; return 0; } @@ -434,7 +434,7 @@ int llog_process_or_fork(const struct lu_env *env, struct llog_process_info *lpi; int rc; - OBD_ALLOC_PTR(lpi); + lpi = kzalloc(sizeof(*lpi), GFP_NOFS); if (lpi == NULL) { CERROR("cannot alloc pointer\n"); return -ENOMEM; @@ -454,7 +454,7 @@ int llog_process_or_fork(const struct lu_env *env, if (IS_ERR_VALUE(rc)) { CERROR("%s: cannot start thread: rc = %d\n", loghandle->lgh_ctxt->loc_obd->obd_name, rc); - OBD_FREE_PTR(lpi); + kfree(lpi); return rc; } wait_for_completion(&lpi->lpi_completion); @@ -463,7 +463,7 @@ int llog_process_or_fork(const struct lu_env *env, llog_process_thread(lpi); } rc = lpi->lpi_rc; - OBD_FREE_PTR(lpi); + kfree(lpi); return rc; } EXPORT_SYMBOL(llog_process_or_fork); @@ -484,7 +484,7 @@ int llog_reverse_process(const struct lu_env *env, void *buf; int rc = 0, first_index = 1, index, idx; - OBD_ALLOC(buf, LLOG_CHUNK_SIZE); + buf = kzalloc(LLOG_CHUNK_SIZE, GFP_NOFS); if (!buf) return -ENOMEM; @@ -563,8 +563,7 @@ int llog_reverse_process(const struct lu_env *env, } out: - if (buf) - OBD_FREE(buf, LLOG_CHUNK_SIZE); + kfree(buf); return rc; } EXPORT_SYMBOL(llog_reverse_process); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index c8f6ab006124..48dbbcf97702 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -279,9 +279,8 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, loghandle->lgh_last_idx < LLOG_BITMAP_SIZE(llh) - 1) { up_read(&cathandle->lgh_lock); return loghandle; - } else { - up_write(&loghandle->lgh_lock); } + up_write(&loghandle->lgh_lock); } up_read(&cathandle->lgh_lock); @@ -299,9 +298,8 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, if (loghandle->lgh_last_idx < LLOG_BITMAP_SIZE(llh) - 1) { up_write(&cathandle->lgh_lock); return loghandle; - } else { - up_write(&loghandle->lgh_lock); } + up_write(&loghandle->lgh_lock); } CDEBUG(D_INODE, "use next log\n"); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 978d886a1103..81ab27e7376f 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -46,7 +46,7 @@ static struct llog_ctxt *llog_new_ctxt(struct obd_device *obd) { struct llog_ctxt *ctxt; - OBD_ALLOC_PTR(ctxt); + ctxt = kzalloc(sizeof(*ctxt), GFP_NOFS); if (!ctxt) return NULL; @@ -66,7 +66,7 @@ static void llog_ctxt_destroy(struct llog_ctxt *ctxt) class_import_put(ctxt->loc_imp); ctxt->loc_imp = NULL; } - OBD_FREE_PTR(ctxt); + kfree(ctxt); } int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt) diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index c171c6c6c457..17e7c1807863 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -221,8 +221,6 @@ int lprocfs_write_frac_helper(const char __user *buffer, unsigned long count, } EXPORT_SYMBOL(lprocfs_write_frac_helper); -#if defined (CONFIG_PROC_FS) - static int lprocfs_no_percpu_stats; module_param(lprocfs_no_percpu_stats, int, 0644); MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs stats"); @@ -243,11 +241,11 @@ EXPORT_SYMBOL(lprocfs_seq_release); /* lprocfs API calls */ -struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, - char *name, void *data, - struct file_operations *fops) +struct dentry *ldebugfs_add_simple(struct dentry *root, + char *name, void *data, + struct file_operations *fops) { - struct proc_dir_entry *proc; + struct dentry *entry; umode_t mode = 0; if (root == NULL || name == NULL || fops == NULL) @@ -257,26 +255,26 @@ struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, mode = 0444; if (fops->write) mode |= 0200; - proc = proc_create_data(name, mode, root, fops, data); - if (!proc) { - CERROR("LprocFS: No memory to create /proc entry %s", name); - return ERR_PTR(-ENOMEM); + entry = debugfs_create_file(name, mode, root, data, fops); + if (IS_ERR_OR_NULL(entry)) { + CERROR("LprocFS: No memory to create <debugfs> entry %s", name); + return entry ?: ERR_PTR(-ENOMEM); } - return proc; + return entry; } -EXPORT_SYMBOL(lprocfs_add_simple); +EXPORT_SYMBOL(ldebugfs_add_simple); -struct proc_dir_entry *lprocfs_add_symlink(const char *name, - struct proc_dir_entry *parent, const char *format, ...) +struct dentry *ldebugfs_add_symlink(const char *name, struct dentry *parent, + const char *format, ...) { - struct proc_dir_entry *entry; + struct dentry *entry; char *dest; va_list ap; if (parent == NULL || format == NULL) return NULL; - OBD_ALLOC_WAIT(dest, MAX_STRING_SIZE + 1); + dest = kzalloc(MAX_STRING_SIZE + 1, GFP_KERNEL); if (dest == NULL) return NULL; @@ -284,37 +282,29 @@ struct proc_dir_entry *lprocfs_add_symlink(const char *name, vsnprintf(dest, MAX_STRING_SIZE, format, ap); va_end(ap); - entry = proc_symlink(name, parent, dest); - if (entry == NULL) - CERROR("LprocFS: Could not create symbolic link from %s to %s", + entry = debugfs_create_symlink(name, parent, dest); + if (IS_ERR_OR_NULL(entry)) { + CERROR("LdebugFS: Could not create symbolic link from %s to %s", name, dest); + entry = NULL; + } - OBD_FREE(dest, MAX_STRING_SIZE + 1); + kfree(dest); return entry; } -EXPORT_SYMBOL(lprocfs_add_symlink); +EXPORT_SYMBOL(ldebugfs_add_symlink); static struct file_operations lprocfs_generic_fops = { }; -/** - * Add /proc entries. - * - * \param root [in] The parent proc entry on which new entry will be added. - * \param list [in] Array of proc entries to be added. - * \param data [in] The argument to be passed when entries read/write routines - * are called through /proc file. - * - * \retval 0 on success - * < 0 on error - */ -int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list, - void *data) +int ldebugfs_add_vars(struct dentry *parent, + struct lprocfs_vars *list, + void *data) { - if (root == NULL || list == NULL) + if (IS_ERR_OR_NULL(parent) || IS_ERR_OR_NULL(list)) return -EINVAL; while (list->name != NULL) { - struct proc_dir_entry *proc; + struct dentry *entry; umode_t mode = 0; if (list->proc_mode != 0000) { @@ -325,54 +315,50 @@ int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list, if (list->fops->write) mode |= 0200; } - proc = proc_create_data(list->name, mode, root, - list->fops ?: &lprocfs_generic_fops, - list->data ?: data); - if (proc == NULL) - return -ENOMEM; + entry = debugfs_create_file(list->name, mode, parent, + list->data ?: data, + list->fops ?: &lprocfs_generic_fops + ); + if (IS_ERR_OR_NULL(entry)) + return entry ? PTR_ERR(entry) : -ENOMEM; list++; } return 0; } -EXPORT_SYMBOL(lprocfs_add_vars); - -void lprocfs_remove(struct proc_dir_entry **rooth) -{ - proc_remove(*rooth); - *rooth = NULL; -} -EXPORT_SYMBOL(lprocfs_remove); +EXPORT_SYMBOL(ldebugfs_add_vars); -void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent) +void ldebugfs_remove(struct dentry **entryp) { - LASSERT(parent != NULL); - remove_proc_entry(name, parent); + debugfs_remove(*entryp); + *entryp = NULL; } -EXPORT_SYMBOL(lprocfs_remove_proc_entry); +EXPORT_SYMBOL(ldebugfs_remove); -struct proc_dir_entry *lprocfs_register(const char *name, - struct proc_dir_entry *parent, - struct lprocfs_vars *list, void *data) +struct dentry *ldebugfs_register(const char *name, + struct dentry *parent, + struct lprocfs_vars *list, void *data) { - struct proc_dir_entry *entry; + struct dentry *entry; - entry = proc_mkdir(name, parent); - if (entry == NULL) { - entry = ERR_PTR(-ENOMEM); + entry = debugfs_create_dir(name, parent); + if (IS_ERR_OR_NULL(entry)) { + entry = entry ?: ERR_PTR(-ENOMEM); goto out; } - if (list != NULL) { - int rc = lprocfs_add_vars(entry, list, data); + if (!IS_ERR_OR_NULL(list)) { + int rc; + + rc = ldebugfs_add_vars(entry, list, data); if (rc != 0) { - lprocfs_remove(&entry); + debugfs_remove(entry); entry = ERR_PTR(rc); } } out: return entry; } -EXPORT_SYMBOL(lprocfs_register); +EXPORT_SYMBOL(ldebugfs_register); /* Generic callbacks */ int lprocfs_rd_uint(struct seq_file *m, void *data) @@ -437,15 +423,15 @@ int lprocfs_wr_atomic(struct file *file, const char __user *buffer, } EXPORT_SYMBOL(lprocfs_wr_atomic); -int lprocfs_rd_uuid(struct seq_file *m, void *data) +static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - LASSERT(obd != NULL); - seq_printf(m, "%s\n", obd->obd_uuid.uuid); - return 0; + return sprintf(buf, "%s\n", obd->obd_uuid.uuid); } -EXPORT_SYMBOL(lprocfs_rd_uuid); +LUSTRE_RO_ATTR(uuid); int lprocfs_rd_name(struct seq_file *m, void *data) { @@ -457,23 +443,27 @@ int lprocfs_rd_name(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_rd_name); -int lprocfs_rd_blksize(struct seq_file *m, void *data) +static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - seq_printf(m, "%u\n", osfs.os_bsize); + return sprintf(buf, "%u\n", osfs.os_bsize); return rc; } -EXPORT_SYMBOL(lprocfs_rd_blksize); +LUSTRE_RO_ATTR(blocksize); -int lprocfs_rd_kbytestotal(struct seq_file *m, void *data) +static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), @@ -485,16 +475,18 @@ int lprocfs_rd_kbytestotal(struct seq_file *m, void *data) while (blk_size >>= 1) result <<= 1; - seq_printf(m, "%llu\n", result); + return sprintf(buf, "%llu\n", result); } return rc; } -EXPORT_SYMBOL(lprocfs_rd_kbytestotal); +LUSTRE_RO_ATTR(kbytestotal); -int lprocfs_rd_kbytesfree(struct seq_file *m, void *data) +static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), @@ -506,16 +498,18 @@ int lprocfs_rd_kbytesfree(struct seq_file *m, void *data) while (blk_size >>= 1) result <<= 1; - seq_printf(m, "%llu\n", result); + return sprintf(buf, "%llu\n", result); } return rc; } -EXPORT_SYMBOL(lprocfs_rd_kbytesfree); +LUSTRE_RO_ATTR(kbytesfree); -int lprocfs_rd_kbytesavail(struct seq_file *m, void *data) +static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), @@ -527,40 +521,44 @@ int lprocfs_rd_kbytesavail(struct seq_file *m, void *data) while (blk_size >>= 1) result <<= 1; - seq_printf(m, "%llu\n", result); + return sprintf(buf, "%llu\n", result); } return rc; } -EXPORT_SYMBOL(lprocfs_rd_kbytesavail); +LUSTRE_RO_ATTR(kbytesavail); -int lprocfs_rd_filestotal(struct seq_file *m, void *data) +static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - seq_printf(m, "%llu\n", osfs.os_files); + return sprintf(buf, "%llu\n", osfs.os_files); return rc; } -EXPORT_SYMBOL(lprocfs_rd_filestotal); +LUSTRE_RO_ATTR(filestotal); -int lprocfs_rd_filesfree(struct seq_file *m, void *data) +static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_NODELAY); if (!rc) - seq_printf(m, "%llu\n", osfs.os_ffree); + return sprintf(buf, "%llu\n", osfs.os_ffree); return rc; } -EXPORT_SYMBOL(lprocfs_rd_filesfree); +LUSTRE_RO_ATTR(filesfree); int lprocfs_rd_server_uuid(struct seq_file *m, void *data) { @@ -930,43 +928,62 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_rd_connect_flags); -int lprocfs_rd_num_exports(struct seq_file *m, void *data) -{ - struct obd_device *obd = data; - - LASSERT(obd != NULL); - seq_printf(m, "%u\n", obd->obd_num_exports); - return 0; -} -EXPORT_SYMBOL(lprocfs_rd_num_exports); +static struct attribute *obd_def_attrs[] = { + &lustre_attr_blocksize.attr, + &lustre_attr_kbytestotal.attr, + &lustre_attr_kbytesfree.attr, + &lustre_attr_kbytesavail.attr, + &lustre_attr_filestotal.attr, + &lustre_attr_filesfree.attr, + &lustre_attr_uuid.attr, + NULL, +}; -int lprocfs_rd_numrefs(struct seq_file *m, void *data) +static void obd_sysfs_release(struct kobject *kobj) { - struct obd_type *class = (struct obd_type *) data; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - LASSERT(class != NULL); - seq_printf(m, "%d\n", class->typ_refcnt); - return 0; + complete(&obd->obd_kobj_unregister); } -EXPORT_SYMBOL(lprocfs_rd_numrefs); -int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list) +static struct kobj_type obd_ktype = { + .default_attrs = obd_def_attrs, + .sysfs_ops = &lustre_sysfs_ops, + .release = obd_sysfs_release, +}; + +int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, + struct attribute_group *attrs) { int rc = 0; - LASSERT(obd != NULL); - LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); - LASSERT(obd->obd_type->typ_procroot != NULL); - - obd->obd_proc_entry = lprocfs_register(obd->obd_name, - obd->obd_type->typ_procroot, - list, obd); - if (IS_ERR(obd->obd_proc_entry)) { - rc = PTR_ERR(obd->obd_proc_entry); + init_completion(&obd->obd_kobj_unregister); + rc = kobject_init_and_add(&obd->obd_kobj, &obd_ktype, + obd->obd_type->typ_kobj, + "%s", obd->obd_name); + if (rc) + return rc; + + if (attrs) { + rc = sysfs_create_group(&obd->obd_kobj, attrs); + if (rc) { + kobject_put(&obd->obd_kobj); + return rc; + } + } + + obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name, + obd->obd_type->typ_debugfs_entry, + list, obd); + if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) { + rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry) + : -ENOMEM; CERROR("error %d setting up lprocfs for %s\n", rc, obd->obd_name); - obd->obd_proc_entry = NULL; + obd->obd_debugfs_entry = NULL; } + return rc; } EXPORT_SYMBOL(lprocfs_obd_setup); @@ -975,58 +992,16 @@ int lprocfs_obd_cleanup(struct obd_device *obd) { if (!obd) return -EINVAL; - if (obd->obd_proc_exports_entry) { - /* Should be no exports left */ - lprocfs_remove(&obd->obd_proc_exports_entry); - obd->obd_proc_exports_entry = NULL; - } - if (obd->obd_proc_entry) { - lprocfs_remove(&obd->obd_proc_entry); - obd->obd_proc_entry = NULL; - } - return 0; -} -EXPORT_SYMBOL(lprocfs_obd_cleanup); - -static void lprocfs_free_client_stats(struct nid_stat *client_stat) -{ - CDEBUG(D_CONFIG, "stat %p - data %p/%p\n", client_stat, - client_stat->nid_proc, client_stat->nid_stats); - - LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0, - "nid %s:count %d\n", libcfs_nid2str(client_stat->nid), - atomic_read(&client_stat->nid_exp_ref_count)); - - if (client_stat->nid_proc) - lprocfs_remove(&client_stat->nid_proc); - if (client_stat->nid_stats) - lprocfs_free_stats(&client_stat->nid_stats); + if (!IS_ERR_OR_NULL(obd->obd_debugfs_entry)) + ldebugfs_remove(&obd->obd_debugfs_entry); - if (client_stat->nid_ldlm_stats) - lprocfs_free_stats(&client_stat->nid_ldlm_stats); + kobject_put(&obd->obd_kobj); + wait_for_completion(&obd->obd_kobj_unregister); - OBD_FREE_PTR(client_stat); - return; - -} - -void lprocfs_free_per_client_stats(struct obd_device *obd) -{ - struct cfs_hash *hash = obd->obd_nid_stats_hash; - struct nid_stat *stat; - - /* we need extra list - because hash_exit called to early */ - /* not need locking because all clients is died */ - while (!list_empty(&obd->obd_nid_stats)) { - stat = list_entry(obd->obd_nid_stats.next, - struct nid_stat, nid_list); - list_del_init(&stat->nid_list); - cfs_hash_del(hash, &stat->nid, &stat->nid_hash); - lprocfs_free_client_stats(stat); - } + return 0; } -EXPORT_SYMBOL(lprocfs_free_per_client_stats); +EXPORT_SYMBOL(lprocfs_obd_cleanup); int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid) { @@ -1257,8 +1232,10 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file) rc = seq_open(file, &lprocfs_stats_seq_sops); if (rc) return rc; + seq = file->private_data; - seq->private = PDE_DATA(inode); + seq->private = inode->i_private; + return 0; } @@ -1271,20 +1248,21 @@ struct file_operations lprocfs_stats_seq_fops = { .release = lprocfs_seq_release, }; -int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, +int ldebugfs_register_stats(struct dentry *parent, const char *name, struct lprocfs_stats *stats) { - struct proc_dir_entry *entry; - LASSERT(root != NULL); + struct dentry *entry; - entry = proc_create_data(name, 0644, root, - &lprocfs_stats_seq_fops, stats); - if (entry == NULL) - return -ENOMEM; + LASSERT(!IS_ERR_OR_NULL(parent)); + + entry = debugfs_create_file(name, 0644, parent, stats, + &lprocfs_stats_seq_fops); + if (IS_ERR_OR_NULL(entry)) + return entry ? PTR_ERR(entry) : -ENOMEM; return 0; } -EXPORT_SYMBOL(lprocfs_register_stats); +EXPORT_SYMBOL(ldebugfs_register_stats); void lprocfs_counter_init(struct lprocfs_stats *stats, int index, unsigned conf, const char *name, const char *units) @@ -1388,7 +1366,7 @@ int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats) int rc, i; LASSERT(obd->obd_stats == NULL); - LASSERT(obd->obd_proc_entry != NULL); + LASSERT(obd->obd_debugfs_entry != NULL); LASSERT(obd->obd_cntr_base == 0); num_stats = ((int)sizeof(*obd->obd_type->typ_dt_ops) / sizeof(void *)) + @@ -1409,7 +1387,7 @@ int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats) "Missing obd_stat initializer obd_op operation at offset %d.\n", i - num_private_stats); } - rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats); + rc = ldebugfs_register_stats(obd->obd_debugfs_entry, "stats", stats); if (rc < 0) { lprocfs_free_stats(&stats); } else { @@ -1479,7 +1457,7 @@ int lprocfs_alloc_md_stats(struct obd_device *obd, int rc, i; LASSERT(obd->md_stats == NULL); - LASSERT(obd->obd_proc_entry != NULL); + LASSERT(obd->obd_debugfs_entry != NULL); LASSERT(obd->md_cntr_base == 0); num_stats = 1 + MD_COUNTER_OFFSET(revalidate_lock) + @@ -1497,7 +1475,7 @@ int lprocfs_alloc_md_stats(struct obd_device *obd, LBUG(); } } - rc = lprocfs_register_stats(obd->obd_proc_entry, "md_stats", stats); + rc = ldebugfs_register_stats(obd->obd_debugfs_entry, "md_stats", stats); if (rc < 0) { lprocfs_free_stats(&stats); } else { @@ -1543,241 +1521,8 @@ void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) } EXPORT_SYMBOL(lprocfs_init_ldlm_stats); -int lprocfs_exp_print_uuid(struct cfs_hash *hs, struct cfs_hash_bd *bd, - struct hlist_node *hnode, void *data) - -{ - struct obd_export *exp = cfs_hash_object(hs, hnode); - struct seq_file *m = (struct seq_file *)data; - - if (exp->exp_nid_stats) - seq_printf(m, "%s\n", obd_uuid2str(&exp->exp_client_uuid)); - - return 0; -} - -static int -lproc_exp_uuid_seq_show(struct seq_file *m, void *unused) -{ - struct nid_stat *stats = (struct nid_stat *)m->private; - struct obd_device *obd = stats->nid_obd; - - cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid, - lprocfs_exp_print_uuid, m); - return 0; -} - -LPROC_SEQ_FOPS_RO(lproc_exp_uuid); - -struct exp_hash_cb_data { - struct seq_file *m; - bool first; -}; - -int lprocfs_exp_print_hash(struct cfs_hash *hs, struct cfs_hash_bd *bd, - struct hlist_node *hnode, void *cb_data) - -{ - struct exp_hash_cb_data *data = (struct exp_hash_cb_data *)cb_data; - struct obd_export *exp = cfs_hash_object(hs, hnode); - - if (exp->exp_lock_hash != NULL) { - if (data->first) { - cfs_hash_debug_header(data->m); - data->first = false; - } - cfs_hash_debug_str(hs, data->m); - } - - return 0; -} - -static int -lproc_exp_hash_seq_show(struct seq_file *m, void *unused) -{ - struct nid_stat *stats = (struct nid_stat *)m->private; - struct obd_device *obd = stats->nid_obd; - struct exp_hash_cb_data cb_data = { - .m = m, - .first = true - }; - - cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid, - lprocfs_exp_print_hash, &cb_data); - return 0; -} - -LPROC_SEQ_FOPS_RO(lproc_exp_hash); - -int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data) -{ - seq_printf(m, "%s\n", - "Write into this file to clear all nid stats and stale nid entries"); - return 0; -} -EXPORT_SYMBOL(lprocfs_nid_stats_clear_read); - -static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data) -{ - struct nid_stat *stat = obj; - - CDEBUG(D_INFO, "refcnt %d\n", atomic_read(&stat->nid_exp_ref_count)); - if (atomic_read(&stat->nid_exp_ref_count) == 1) { - /* object has only hash references. */ - spin_lock(&stat->nid_obd->obd_nid_lock); - list_move(&stat->nid_list, data); - spin_unlock(&stat->nid_obd->obd_nid_lock); - return 1; - } - /* we has reference to object - only clear data*/ - if (stat->nid_stats) - lprocfs_clear_stats(stat->nid_stats); - - return 0; -} - -int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - struct nid_stat *client_stat; - LIST_HEAD(free_list); - - cfs_hash_cond_del(obd->obd_nid_stats_hash, - lprocfs_nid_stats_clear_write_cb, &free_list); - - while (!list_empty(&free_list)) { - client_stat = list_entry(free_list.next, struct nid_stat, - nid_list); - list_del_init(&client_stat->nid_list); - lprocfs_free_client_stats(client_stat); - } - - return count; -} -EXPORT_SYMBOL(lprocfs_nid_stats_clear_write); - -int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) -{ - struct nid_stat *new_stat, *old_stat; - struct obd_device *obd = NULL; - struct proc_dir_entry *entry; - char *buffer = NULL; - int rc = 0; - - *newnid = 0; - - if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry || - !exp->exp_obd->obd_nid_stats_hash) - return -EINVAL; - - /* not test against zero because eric say: - * You may only test nid against another nid, or LNET_NID_ANY. - * Anything else is nonsense.*/ - if (!nid || *nid == LNET_NID_ANY) - return 0; - - obd = exp->exp_obd; - - CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash); - - OBD_ALLOC_PTR(new_stat); - if (new_stat == NULL) - return -ENOMEM; - - new_stat->nid = *nid; - new_stat->nid_obd = exp->exp_obd; - /* we need set default refcount to 1 to balance obd_disconnect */ - atomic_set(&new_stat->nid_exp_ref_count, 1); - - old_stat = cfs_hash_findadd_unique(obd->obd_nid_stats_hash, - nid, &new_stat->nid_hash); - CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n", - old_stat, libcfs_nid2str(*nid), - atomic_read(&new_stat->nid_exp_ref_count)); - - /* We need to release old stats because lprocfs_exp_cleanup() hasn't - * been and will never be called. */ - if (exp->exp_nid_stats) { - nidstat_putref(exp->exp_nid_stats); - exp->exp_nid_stats = NULL; - } - - /* Return -EALREADY here so that we know that the /proc - * entry already has been created */ - if (old_stat != new_stat) { - exp->exp_nid_stats = old_stat; - rc = -EALREADY; - goto destroy_new; - } - /* not found - create */ - OBD_ALLOC(buffer, LNET_NIDSTR_SIZE); - if (buffer == NULL) { - rc = -ENOMEM; - goto destroy_new; - } - - memcpy(buffer, libcfs_nid2str(*nid), LNET_NIDSTR_SIZE); - new_stat->nid_proc = lprocfs_register(buffer, - obd->obd_proc_exports_entry, - NULL, NULL); - OBD_FREE(buffer, LNET_NIDSTR_SIZE); - - if (IS_ERR(new_stat->nid_proc)) { - CERROR("Error making export directory for nid %s\n", - libcfs_nid2str(*nid)); - rc = PTR_ERR(new_stat->nid_proc); - new_stat->nid_proc = NULL; - goto destroy_new_ns; - } - - entry = lprocfs_add_simple(new_stat->nid_proc, "uuid", - new_stat, &lproc_exp_uuid_fops); - if (IS_ERR(entry)) { - CWARN("Error adding the NID stats file\n"); - rc = PTR_ERR(entry); - goto destroy_new_ns; - } - - entry = lprocfs_add_simple(new_stat->nid_proc, "hash", - new_stat, &lproc_exp_hash_fops); - if (IS_ERR(entry)) { - CWARN("Error adding the hash file\n"); - rc = PTR_ERR(entry); - goto destroy_new_ns; - } - - exp->exp_nid_stats = new_stat; - *newnid = 1; - /* protect competitive add to list, not need locking on destroy */ - spin_lock(&obd->obd_nid_lock); - list_add(&new_stat->nid_list, &obd->obd_nid_stats); - spin_unlock(&obd->obd_nid_lock); - - return rc; - -destroy_new_ns: - if (new_stat->nid_proc != NULL) - lprocfs_remove(&new_stat->nid_proc); - cfs_hash_del(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash); - -destroy_new: - nidstat_putref(new_stat); - OBD_FREE_PTR(new_stat); - return rc; -} -EXPORT_SYMBOL(lprocfs_exp_setup); - int lprocfs_exp_cleanup(struct obd_export *exp) { - struct nid_stat *stat = exp->exp_nid_stats; - - if (!stat || !exp->exp_obd) - return 0; - - nidstat_putref(exp->exp_nid_stats); - exp->exp_nid_stats = NULL; - return 0; } EXPORT_SYMBOL(lprocfs_exp_cleanup); @@ -1972,35 +1717,35 @@ char *lprocfs_find_named_value(const char *buffer, const char *name, } EXPORT_SYMBOL(lprocfs_find_named_value); -int lprocfs_seq_create(struct proc_dir_entry *parent, +int ldebugfs_seq_create(struct dentry *parent, const char *name, umode_t mode, const struct file_operations *seq_fops, void *data) { - struct proc_dir_entry *entry; + struct dentry *entry; /* Disallow secretly (un)writable entries. */ LASSERT((seq_fops->write == NULL) == ((mode & 0222) == 0)); - entry = proc_create_data(name, mode, parent, seq_fops, data); - if (entry == NULL) - return -ENOMEM; + entry = debugfs_create_file(name, mode, parent, data, seq_fops); + if (IS_ERR_OR_NULL(entry)) + return entry ? PTR_ERR(entry) : -ENOMEM; return 0; } -EXPORT_SYMBOL(lprocfs_seq_create); +EXPORT_SYMBOL(ldebugfs_seq_create); -int lprocfs_obd_seq_create(struct obd_device *dev, - const char *name, - umode_t mode, - const struct file_operations *seq_fops, - void *data) +int ldebugfs_obd_seq_create(struct obd_device *dev, + const char *name, + umode_t mode, + const struct file_operations *seq_fops, + void *data) { - return lprocfs_seq_create(dev->obd_proc_entry, name, - mode, seq_fops, data); + return ldebugfs_seq_create(dev->obd_debugfs_entry, name, + mode, seq_fops, data); } -EXPORT_SYMBOL(lprocfs_obd_seq_create); +EXPORT_SYMBOL(ldebugfs_obd_seq_create); void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value) { @@ -2056,4 +1801,26 @@ int lprocfs_obd_rd_max_pages_per_rpc(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_obd_rd_max_pages_per_rpc); -#endif +ssize_t lustre_attr_show(struct kobject *kobj, + struct attribute *attr, char *buf) +{ + struct lustre_attr *a = container_of(attr, struct lustre_attr, attr); + + return a->show ? a->show(kobj, attr, buf) : 0; +} +EXPORT_SYMBOL_GPL(lustre_attr_show); + +ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t len) +{ + struct lustre_attr *a = container_of(attr, struct lustre_attr, attr); + + return a->store ? a->store(kobj, attr, buf, len) : len; +} +EXPORT_SYMBOL_GPL(lustre_attr_store); + +const struct sysfs_ops lustre_sysfs_ops = { + .show = lustre_attr_show, + .store = lustre_attr_store, +}; +EXPORT_SYMBOL_GPL(lustre_sysfs_ops); diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 20c0779951fd..4d9b6333eeae 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -1532,7 +1532,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])); + kfree(ctx->lc_value); ctx->lc_value = NULL; } @@ -1581,8 +1581,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])); + ctx->lc_value = kcalloc(ARRAY_SIZE(lu_keys), sizeof(ctx->lc_value[0]), + GFP_NOFS); if (likely(ctx->lc_value != NULL)) return keys_fill(ctx); @@ -1989,14 +1989,10 @@ void lu_global_fini(void) static __u32 ls_stats_read(struct lprocfs_stats *stats, int idx) { -#if defined (CONFIG_PROC_FS) struct lprocfs_counter ret; lprocfs_stats_collect(stats, idx, &ret); return (__u32)ret.lc_count; -#else - return 0; -#endif } /** @@ -2125,7 +2121,7 @@ void lu_buf_free(struct lu_buf *buf) LASSERT(buf); if (buf->lb_buf) { LASSERT(buf->lb_len > 0); - OBD_FREE_LARGE(buf->lb_buf, buf->lb_len); + kvfree(buf->lb_buf); buf->lb_buf = NULL; buf->lb_len = 0; } @@ -2137,7 +2133,7 @@ void lu_buf_alloc(struct lu_buf *buf, int size) LASSERT(buf); LASSERT(buf->lb_buf == NULL); LASSERT(buf->lb_len == 0); - OBD_ALLOC_LARGE(buf->lb_buf, size); + buf->lb_buf = libcfs_kvzalloc(size, GFP_NOFS); if (likely(buf->lb_buf)) buf->lb_len = size; } @@ -2175,14 +2171,14 @@ int lu_buf_check_and_grow(struct lu_buf *buf, int len) if (len <= buf->lb_len) return 0; - OBD_ALLOC_LARGE(ptr, len); + ptr = libcfs_kvzalloc(len, GFP_NOFS); if (ptr == NULL) return -ENOMEM; /* Free the old buf */ if (buf->lb_buf != NULL) { memcpy(ptr, buf->lb_buf, buf->lb_len); - OBD_FREE_LARGE(buf->lb_buf, buf->lb_len); + kvfree(buf->lb_buf); } buf->lb_buf = ptr; diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index f720e3183295..35a94a8f4fd3 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -186,7 +186,7 @@ void class_handle_free_cb(struct rcu_head *rcu) if (h->h_ops->hop_free != NULL) h->h_ops->hop_free(ptr, h->h_size); else - OBD_FREE(ptr, h->h_size); + kfree(ptr); } EXPORT_SYMBOL(class_handle_free_cb); @@ -198,7 +198,8 @@ int class_handle_init(void) LASSERT(handle_hash == NULL); - OBD_ALLOC_LARGE(handle_hash, sizeof(*bucket) * HANDLE_HASH_SIZE); + handle_hash = libcfs_kvzalloc(sizeof(*bucket) * HANDLE_HASH_SIZE, + GFP_NOFS); if (handle_hash == NULL) return -ENOMEM; @@ -249,7 +250,7 @@ void class_handle_cleanup(void) count = cleanup_all_handles(); - OBD_FREE_LARGE(handle_hash, sizeof(*handle_hash) * HANDLE_HASH_SIZE); + kvfree(handle_hash); handle_hash = NULL; if (count != 0) diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c index 64b2f35e224f..5cc6435cc47a 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c @@ -104,7 +104,7 @@ int class_add_uuid(const char *uuid, __u64 nid) if (strlen(uuid) > UUID_MAX - 1) return -EOVERFLOW; - OBD_ALLOC_PTR(data); + data = kzalloc(sizeof(*data), GFP_NOFS); if (data == NULL) return -ENOMEM; @@ -136,7 +136,7 @@ int class_add_uuid(const char *uuid, __u64 nid) if (found) { CDEBUG(D_INFO, "found uuid %s %s cnt=%d\n", uuid, libcfs_nid2str(nid), entry->un_nid_count); - OBD_FREE(data, sizeof(*data)); + kfree(data); } else { CDEBUG(D_INFO, "add uuid %s %s\n", uuid, libcfs_nid2str(nid)); } @@ -180,7 +180,7 @@ int class_del_uuid(const char *uuid) libcfs_nid2str(data->un_nids[0]), data->un_nid_count); - OBD_FREE(data, sizeof(*data)); + kfree(data); } return 0; diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 6ce9adc2f11c..fbdb748a36b9 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -49,7 +49,6 @@ static cfs_hash_ops_t uuid_hash_ops; static cfs_hash_ops_t nid_hash_ops; -static cfs_hash_ops_t nid_stat_hash_ops; /*********** string parsing utils *********/ @@ -383,7 +382,6 @@ int class_attach(struct lustre_cfg *lcfg) INIT_LIST_HEAD(&obd->obd_unlinked_exports); INIT_LIST_HEAD(&obd->obd_delayed_exports); INIT_LIST_HEAD(&obd->obd_exports_timed); - INIT_LIST_HEAD(&obd->obd_nid_stats); spin_lock_init(&obd->obd_nid_lock); spin_lock_init(&obd->obd_dev_lock); mutex_init(&obd->obd_dev_mutex); @@ -486,7 +484,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) obd->obd_starting = 1; obd->obd_uuid_hash = NULL; obd->obd_nid_hash = NULL; - obd->obd_nid_stats_hash = NULL; spin_unlock(&obd->obd_dev_lock); /* create an uuid-export lustre hash */ @@ -515,19 +512,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto err_hash; } - /* create a nid-stats lustre hash */ - obd->obd_nid_stats_hash = cfs_hash_create("NID_STATS", - HASH_NID_STATS_CUR_BITS, - HASH_NID_STATS_MAX_BITS, - HASH_NID_STATS_BKT_BITS, 0, - CFS_HASH_MIN_THETA, - CFS_HASH_MAX_THETA, - &nid_stat_hash_ops, CFS_HASH_DEFAULT); - if (!obd->obd_nid_stats_hash) { - err = -ENOMEM; - goto err_hash; - } - exp = class_new_export(obd, &obd->obd_uuid); if (IS_ERR(exp)) { err = PTR_ERR(exp); @@ -567,10 +551,6 @@ err_hash: cfs_hash_putref(obd->obd_nid_hash); obd->obd_nid_hash = NULL; } - if (obd->obd_nid_stats_hash) { - cfs_hash_putref(obd->obd_nid_stats_hash); - obd->obd_nid_stats_hash = NULL; - } obd->obd_starting = 0; CERROR("setup %s failed (%d)\n", obd->obd_name, err); return err; @@ -694,12 +674,6 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) obd->obd_nid_hash = NULL; } - /* destroy a nid-stats hash body */ - if (obd->obd_nid_stats_hash) { - cfs_hash_putref(obd->obd_nid_stats_hash); - obd->obd_nid_stats_hash = NULL; - } - class_decref(obd, "setup", obd); obd->obd_set_up = 0; @@ -860,48 +834,43 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, CDEBUG(D_CONFIG, "Add profile %s\n", prof); - OBD_ALLOC(lprof, sizeof(*lprof)); + lprof = kzalloc(sizeof(*lprof), GFP_NOFS); if (lprof == NULL) return -ENOMEM; INIT_LIST_HEAD(&lprof->lp_list); LASSERT(proflen == (strlen(prof) + 1)); - OBD_ALLOC(lprof->lp_profile, proflen); + lprof->lp_profile = kmemdup(prof, proflen, GFP_NOFS); if (lprof->lp_profile == NULL) { err = -ENOMEM; - goto out; + goto free_lprof; } - memcpy(lprof->lp_profile, prof, proflen); LASSERT(osclen == (strlen(osc) + 1)); - OBD_ALLOC(lprof->lp_dt, osclen); + lprof->lp_dt = kmemdup(osc, osclen, GFP_NOFS); if (lprof->lp_dt == NULL) { err = -ENOMEM; - goto out; + goto free_lp_profile; } - memcpy(lprof->lp_dt, osc, osclen); if (mdclen > 0) { LASSERT(mdclen == (strlen(mdc) + 1)); - OBD_ALLOC(lprof->lp_md, mdclen); + lprof->lp_md = kmemdup(mdc, mdclen, GFP_NOFS); if (lprof->lp_md == NULL) { err = -ENOMEM; - goto out; + goto free_lp_dt; } - memcpy(lprof->lp_md, mdc, mdclen); } list_add(&lprof->lp_list, &lustre_profile_list); return err; -out: - if (lprof->lp_md) - OBD_FREE(lprof->lp_md, mdclen); - if (lprof->lp_dt) - OBD_FREE(lprof->lp_dt, osclen); - if (lprof->lp_profile) - OBD_FREE(lprof->lp_profile, proflen); - OBD_FREE(lprof, sizeof(*lprof)); +free_lp_dt: + kfree(lprof->lp_dt); +free_lp_profile: + kfree(lprof->lp_profile); +free_lprof: + kfree(lprof); return err; } @@ -914,11 +883,10 @@ void class_del_profile(const char *prof) lprof = class_get_profile(prof); if (lprof) { list_del(&lprof->lp_list); - OBD_FREE(lprof->lp_profile, strlen(lprof->lp_profile) + 1); - 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)); + kfree(lprof->lp_profile); + kfree(lprof->lp_dt); + kfree(lprof->lp_md); + kfree(lprof); } } EXPORT_SYMBOL(class_del_profile); @@ -930,11 +898,10 @@ void class_del_profiles(void) list_for_each_entry_safe(lprof, n, &lustre_profile_list, lp_list) { list_del(&lprof->lp_list); - OBD_FREE(lprof->lp_profile, strlen(lprof->lp_profile) + 1); - 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)); + kfree(lprof->lp_profile); + kfree(lprof->lp_dt); + kfree(lprof->lp_md); + kfree(lprof); } } EXPORT_SYMBOL(class_del_profiles); @@ -1011,7 +978,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, new_len = LUSTRE_CFG_BUFLEN(cfg, 1) + strlen(new_name) - name_len; - OBD_ALLOC(new_param, new_len); + new_param = kzalloc(new_len, GFP_NOFS); if (new_param == NULL) return ERR_PTR(-ENOMEM); @@ -1019,9 +986,9 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, if (value != NULL) strcat(new_param, value); - OBD_ALLOC_PTR(bufs); + bufs = kzalloc(sizeof(*bufs), GFP_NOFS); if (bufs == NULL) { - OBD_FREE(new_param, new_len); + kfree(new_param); return ERR_PTR(-ENOMEM); } @@ -1031,8 +998,8 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, new_cfg = lustre_cfg_new(cfg->lcfg_command, bufs); - OBD_FREE(new_param, new_len); - OBD_FREE_PTR(bufs); + kfree(new_param); + kfree(bufs); if (new_cfg == NULL) return ERR_PTR(-ENOMEM); @@ -1493,7 +1460,7 @@ int class_config_llog_handler(const struct lu_env *env, inst = 1; inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) + sizeof(clli->cfg_instance) * 2 + 4; - OBD_ALLOC(inst_name, inst_len); + inst_name = kzalloc(inst_len, GFP_NOFS); if (inst_name == NULL) { rc = -ENOMEM; goto out; @@ -1556,7 +1523,7 @@ int class_config_llog_handler(const struct lu_env *env, lustre_cfg_free(lcfg_new); if (inst) - OBD_FREE(inst_name, inst_len); + kfree(inst_name); break; } default: @@ -1671,7 +1638,7 @@ int class_config_dump_handler(const struct lu_env *env, char *outstr; int rc = 0; - OBD_ALLOC(outstr, 256); + outstr = kzalloc(256, GFP_NOFS); if (outstr == NULL) return -ENOMEM; @@ -1683,7 +1650,7 @@ int class_config_dump_handler(const struct lu_env *env, rc = -EINVAL; } - OBD_FREE(outstr, 256); + kfree(outstr); return rc; } @@ -1897,57 +1864,3 @@ static cfs_hash_ops_t nid_hash_ops = { .hs_get = nid_export_get, .hs_put_locked = nid_export_put_locked, }; - - -/* - * nid<->nidstats hash operations - */ - -static void * -nidstats_key(struct hlist_node *hnode) -{ - struct nid_stat *ns; - - ns = hlist_entry(hnode, struct nid_stat, nid_hash); - - return &ns->nid; -} - -static int -nidstats_keycmp(const void *key, struct hlist_node *hnode) -{ - return *(lnet_nid_t *)nidstats_key(hnode) == *(lnet_nid_t *)key; -} - -static void * -nidstats_object(struct hlist_node *hnode) -{ - return hlist_entry(hnode, struct nid_stat, nid_hash); -} - -static void -nidstats_get(struct cfs_hash *hs, struct hlist_node *hnode) -{ - struct nid_stat *ns; - - ns = hlist_entry(hnode, struct nid_stat, nid_hash); - nidstat_getref(ns); -} - -static void -nidstats_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) -{ - struct nid_stat *ns; - - ns = hlist_entry(hnode, struct nid_stat, nid_hash); - nidstat_putref(ns); -} - -static cfs_hash_ops_t nid_stat_hash_ops = { - .hs_hash = nid_hash, - .hs_key = nidstats_key, - .hs_keycmp = nidstats_keycmp, - .hs_object = nidstats_object, - .hs_get = nidstats_get, - .hs_put_locked = nidstats_put_locked, -}; diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 3437b2ecfc02..ce4a71f7171a 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -84,7 +84,7 @@ int lustre_process_log(struct super_block *sb, char *logname, LASSERT(mgc); LASSERT(cfg); - OBD_ALLOC_PTR(bufs); + bufs = kzalloc(sizeof(*bufs), GFP_NOFS); if (bufs == NULL) return -ENOMEM; @@ -97,7 +97,7 @@ int lustre_process_log(struct super_block *sb, char *logname, rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); lustre_cfg_free(lcfg); - OBD_FREE_PTR(bufs); + kfree(bufs); if (rc == -EINVAL) LCONSOLE_ERROR_MSG(0x15b, "%s: The configuration from log '%s' failed from the MGS (%d). Make sure this client and the MGS are running compatible versions of Lustre.\n", @@ -147,7 +147,7 @@ int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, char *s1, char *s2, char *s3, char *s4) { struct lustre_cfg_bufs bufs; - struct lustre_cfg * lcfg = NULL; + struct lustre_cfg *lcfg = NULL; int rc; CDEBUG(D_TRACE, "lcfg %s %#x %s %s %s %s\n", cfgname, @@ -247,8 +247,8 @@ int lustre_start_mgc(struct super_block *sb) mutex_lock(&mgc_start_lock); len = strlen(LUSTRE_MGC_OBDNAME) + strlen(libcfs_nid2str(nid)) + 1; - OBD_ALLOC(mgcname, len); - OBD_ALLOC(niduuid, len + 2); + mgcname = kzalloc(len, GFP_NOFS); + niduuid = kzalloc(len + 2, GFP_NOFS); if (!mgcname || !niduuid) { rc = -ENOMEM; goto out_free; @@ -257,7 +257,7 @@ int lustre_start_mgc(struct super_block *sb) mgssec = lsi->lsi_lmd->lmd_mgssec ? lsi->lsi_lmd->lmd_mgssec : ""; - OBD_ALLOC_PTR(data); + data = kzalloc(sizeof(*data), GFP_NOFS); if (data == NULL) { rc = -ENOMEM; goto out_free; @@ -375,7 +375,7 @@ int lustre_start_mgc(struct super_block *sb) lsi->lsi_lmd->lmd_mgs_failnodes = 1; /* Random uuid for MGC allows easier reconnects */ - OBD_ALLOC_PTR(uuid); + uuid = kzalloc(sizeof(*uuid), GFP_NOFS); if (!uuid) { rc = -ENOMEM; goto out_free; @@ -388,7 +388,7 @@ int lustre_start_mgc(struct super_block *sb) rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME, (char *)uuid->uuid, LUSTRE_MGS_OBDNAME, niduuid, NULL, NULL); - OBD_FREE_PTR(uuid); + kfree(uuid); if (rc) goto out_free; @@ -464,12 +464,9 @@ out: out_free: mutex_unlock(&mgc_start_lock); - if (data) - OBD_FREE_PTR(data); - if (mgcname) - OBD_FREE(mgcname, len); - if (niduuid) - OBD_FREE(niduuid, len + 2); + kfree(data); + kfree(mgcname); + kfree(niduuid); return rc; } @@ -513,7 +510,7 @@ static int lustre_stop_mgc(struct super_block *sb) /* Save the obdname for cleaning the nid uuids, which are obdname_XX */ len = strlen(obd->obd_name) + 6; - OBD_ALLOC(niduuid, len); + niduuid = kzalloc(len, GFP_NOFS); if (niduuid) { strcpy(niduuid, obd->obd_name); ptr = niduuid + strlen(niduuid); @@ -538,8 +535,7 @@ static int lustre_stop_mgc(struct super_block *sb) niduuid, rc); } out: - if (niduuid) - OBD_FREE(niduuid, len); + kfree(niduuid); /* class_import_put will get rid of the additional connections */ mutex_unlock(&mgc_start_lock); @@ -552,12 +548,12 @@ struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) { struct lustre_sb_info *lsi; - OBD_ALLOC_PTR(lsi); + lsi = kzalloc(sizeof(*lsi), GFP_NOFS); if (!lsi) return NULL; - OBD_ALLOC_PTR(lsi->lsi_lmd); + lsi->lsi_lmd = kzalloc(sizeof(*lsi->lsi_lmd), GFP_NOFS); if (!lsi->lsi_lmd) { - OBD_FREE_PTR(lsi); + kfree(lsi); return NULL; } @@ -585,36 +581,21 @@ static int lustre_free_lsi(struct super_block *sb) LASSERT(atomic_read(&lsi->lsi_mounts) == 0); if (lsi->lsi_lmd != NULL) { - if (lsi->lsi_lmd->lmd_dev != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_dev, - strlen(lsi->lsi_lmd->lmd_dev) + 1); - if (lsi->lsi_lmd->lmd_profile != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_profile, - strlen(lsi->lsi_lmd->lmd_profile) + 1); - if (lsi->lsi_lmd->lmd_mgssec != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_mgssec, - strlen(lsi->lsi_lmd->lmd_mgssec) + 1); - if (lsi->lsi_lmd->lmd_opts != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_opts, - strlen(lsi->lsi_lmd->lmd_opts) + 1); + kfree(lsi->lsi_lmd->lmd_dev); + kfree(lsi->lsi_lmd->lmd_profile); + kfree(lsi->lsi_lmd->lmd_mgssec); + kfree(lsi->lsi_lmd->lmd_opts); if (lsi->lsi_lmd->lmd_exclude_count) - OBD_FREE(lsi->lsi_lmd->lmd_exclude, - sizeof(lsi->lsi_lmd->lmd_exclude[0]) * - lsi->lsi_lmd->lmd_exclude_count); - if (lsi->lsi_lmd->lmd_mgs != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_mgs, - strlen(lsi->lsi_lmd->lmd_mgs) + 1); - if (lsi->lsi_lmd->lmd_osd_type != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_osd_type, - strlen(lsi->lsi_lmd->lmd_osd_type) + 1); - if (lsi->lsi_lmd->lmd_params != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_params, 4096); - - OBD_FREE(lsi->lsi_lmd, sizeof(*lsi->lsi_lmd)); + kfree(lsi->lsi_lmd->lmd_exclude); + kfree(lsi->lsi_lmd->lmd_mgs); + kfree(lsi->lsi_lmd->lmd_osd_type); + kfree(lsi->lsi_lmd->lmd_params); + + kfree(lsi->lsi_lmd); } LASSERT(lsi->lsi_llsbi == NULL); - OBD_FREE(lsi, sizeof(*lsi)); + kfree(lsi); s2lsi_nocast(sb) = NULL; return 0; @@ -846,7 +827,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) devmax = strlen(ptr) / 8 + 1; /* temp storage until we figure out how many we have */ - OBD_ALLOC(exclude_list, sizeof(index) * devmax); + exclude_list = kcalloc(devmax, sizeof(index), GFP_NOFS); if (!exclude_list) return -ENOMEM; @@ -875,8 +856,8 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) if (lmd->lmd_exclude_count) { /* permanent, freed in lustre_free_lsi */ - OBD_ALLOC(lmd->lmd_exclude, sizeof(index) * - lmd->lmd_exclude_count); + lmd->lmd_exclude = kcalloc(lmd->lmd_exclude_count, + sizeof(index), GFP_NOFS); if (lmd->lmd_exclude) { memcpy(lmd->lmd_exclude, exclude_list, sizeof(index) * lmd->lmd_exclude_count); @@ -885,7 +866,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) lmd->lmd_exclude_count = 0; } } - OBD_FREE(exclude_list, sizeof(index) * devmax); + kfree(exclude_list); return rc; } @@ -894,10 +875,8 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr) char *tail; int length; - if (lmd->lmd_mgssec != NULL) { - OBD_FREE(lmd->lmd_mgssec, strlen(lmd->lmd_mgssec) + 1); - lmd->lmd_mgssec = NULL; - } + kfree(lmd->lmd_mgssec); + lmd->lmd_mgssec = NULL; tail = strchr(ptr, ','); if (tail == NULL) @@ -905,7 +884,7 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr) else length = tail - ptr; - OBD_ALLOC(lmd->lmd_mgssec, length + 1); + lmd->lmd_mgssec = kzalloc(length + 1, GFP_NOFS); if (lmd->lmd_mgssec == NULL) return -ENOMEM; @@ -922,10 +901,8 @@ static int lmd_parse_string(char **handle, char *ptr) if ((handle == NULL) || (ptr == NULL)) return -EINVAL; - if (*handle != NULL) { - OBD_FREE(*handle, strlen(*handle) + 1); - *handle = NULL; - } + kfree(*handle); + *handle = NULL; tail = strchr(ptr, ','); if (tail == NULL) @@ -933,7 +910,7 @@ static int lmd_parse_string(char **handle, char *ptr) else length = tail - ptr; - OBD_ALLOC(*handle, length + 1); + *handle = kzalloc(length + 1, GFP_NOFS); if (*handle == NULL) return -ENOMEM; @@ -963,7 +940,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr) if (lmd->lmd_mgs != NULL) oldlen = strlen(lmd->lmd_mgs) + 1; - OBD_ALLOC(mgsnid, oldlen + length + 1); + mgsnid = kzalloc(oldlen + length + 1, GFP_NOFS); if (mgsnid == NULL) return -ENOMEM; @@ -971,7 +948,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr) /* Multiple mgsnid= are taken to mean failover locations */ memcpy(mgsnid, lmd->lmd_mgs, oldlen); mgsnid[oldlen - 1] = ':'; - OBD_FREE(lmd->lmd_mgs, oldlen); + kfree(lmd->lmd_mgs); } memcpy(mgsnid + oldlen, *ptr, length); mgsnid[oldlen + length] = '\0'; @@ -1005,7 +982,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) } lmd->lmd_magic = LMD_MAGIC; - OBD_ALLOC(lmd->lmd_params, 4096); + lmd->lmd_params = kzalloc(4096, GFP_NOFS); if (lmd->lmd_params == NULL) return -ENOMEM; lmd->lmd_params[0] = '\0'; @@ -1143,14 +1120,14 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) /* Remove leading /s from fsname */ while (*++s1 == '/') ; /* Freed in lustre_free_lsi */ - OBD_ALLOC(lmd->lmd_profile, strlen(s1) + 8); + lmd->lmd_profile = kzalloc(strlen(s1) + 8, GFP_NOFS); if (!lmd->lmd_profile) return -ENOMEM; sprintf(lmd->lmd_profile, "%s-client", s1); } /* Freed in lustre_free_lsi */ - OBD_ALLOC(lmd->lmd_dev, strlen(devname) + 1); + lmd->lmd_dev = kzalloc(strlen(devname) + 1, GFP_NOFS); if (!lmd->lmd_dev) return -ENOMEM; strcpy(lmd->lmd_dev, devname); @@ -1161,7 +1138,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) *s1-- = 0; if (*options != 0) { /* Freed in lustre_free_lsi */ - OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1); + lmd->lmd_opts = kzalloc(strlen(options) + 1, GFP_NOFS); if (!lmd->lmd_opts) return -ENOMEM; strcpy(lmd->lmd_opts, options); diff --git a/drivers/staging/lustre/lustre/obdecho/Makefile b/drivers/staging/lustre/lustre/obdecho/Makefile index 672028fc7f6e..a659a37a7e93 100644 --- a/drivers/staging/lustre/lustre/obdecho/Makefile +++ b/drivers/staging/lustre/lustre/obdecho/Makefile @@ -1,2 +1,2 @@ obj-$(CONFIG_LUSTRE_FS) += obdecho.o -obdecho-y := echo_client.o lproc_echo.o +obdecho-y := echo_client.o diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index d542e06d6cd3..0222fd2e4757 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -479,13 +479,13 @@ static int echo_alloc_memmd(struct echo_device *ed, lsm_size = lov_stripe_md_size(1); LASSERT(*lsmp == NULL); - OBD_ALLOC(*lsmp, lsm_size); + *lsmp = kzalloc(lsm_size, GFP_NOFS); if (*lsmp == NULL) return -ENOMEM; - OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); + (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), GFP_NOFS); if ((*lsmp)->lsm_oinfo[0] == NULL) { - OBD_FREE(*lsmp, lsm_size); + kfree(*lsmp); return -ENOMEM; } @@ -507,8 +507,8 @@ static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp) lsm_size = lov_stripe_md_size(1); LASSERT(*lsmp != NULL); - OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); - OBD_FREE(*lsmp, lsm_size); + kfree((*lsmp)->lsm_oinfo[0]); + kfree(*lsmp); *lsmp = NULL; return 0; } @@ -700,7 +700,7 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, int rc; int cleanup = 0; - OBD_ALLOC_PTR(ed); + ed = kzalloc(sizeof(*ed), GFP_NOFS); if (ed == NULL) { rc = -ENOMEM; goto out; @@ -798,7 +798,7 @@ out: case 2: cl_device_fini(&ed->ed_cl); case 1: - OBD_FREE_PTR(ed); + kfree(ed); case 0: default: break; @@ -895,7 +895,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env, LASSERT(ed->ed_site == lu2cl_site(d->ld_site)); echo_site_fini(env, ed); cl_device_fini(&ed->ed_cl); - OBD_FREE_PTR(ed); + kfree(ed); return NULL; } @@ -1577,13 +1577,13 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, if (rw == OBD_BRW_WRITE) brw_flags = OBD_BRW_ASYNC; - OBD_ALLOC(pga, npages * sizeof(*pga)); + pga = kcalloc(npages, sizeof(*pga), GFP_NOFS); if (pga == NULL) return -ENOMEM; - OBD_ALLOC(pages, npages * sizeof(*pages)); + pages = kcalloc(npages, sizeof(*pages), GFP_NOFS); if (pages == NULL) { - OBD_FREE(pga, npages * sizeof(*pga)); + kfree(pga); return -ENOMEM; } @@ -1632,8 +1632,8 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, } OBD_PAGE_FREE(pgp->pg); } - OBD_FREE(pga, npages * sizeof(*pga)); - OBD_FREE(pages, npages * sizeof(*pages)); + kfree(pga); + kfree(pages); return rc; } @@ -1659,8 +1659,8 @@ static int echo_client_prep_commit(const struct lu_env *env, npages = batch >> PAGE_CACHE_SHIFT; tot_pages = count >> PAGE_CACHE_SHIFT; - OBD_ALLOC(lnb, npages * sizeof(struct niobuf_local)); - OBD_ALLOC(rnb, npages * sizeof(struct niobuf_remote)); + lnb = kcalloc(npages, sizeof(struct niobuf_local), GFP_NOFS); + rnb = kcalloc(npages, sizeof(struct niobuf_remote), GFP_NOFS); if (lnb == NULL || rnb == NULL) { ret = -ENOMEM; @@ -1737,10 +1737,8 @@ static int echo_client_prep_commit(const struct lu_env *env, } out: - if (lnb) - OBD_FREE(lnb, npages * sizeof(struct niobuf_local)); - if (rnb) - OBD_FREE(rnb, npages * sizeof(struct niobuf_remote)); + kfree(lnb); + kfree(rnb); return ret; } @@ -1879,7 +1877,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (rc < 0) return rc; - OBD_ALLOC_PTR(env); + env = kzalloc(sizeof(*env), GFP_NOFS); if (env == NULL) return -ENOMEM; @@ -2010,7 +2008,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, out: lu_env_fini(env); - OBD_FREE_PTR(env); + kfree(env); /* XXX this should be in a helper also called by target_send_reply */ for (ack_lock = dummy_oti.oti_ack_locks, i = 0; i < 4; @@ -2050,7 +2048,7 @@ static int echo_client_setup(const struct lu_env *env, ec->ec_unique = 0; ec->ec_nstripes = 0; - OBD_ALLOC(ocd, sizeof(*ocd)); + ocd = kzalloc(sizeof(*ocd), GFP_NOFS); if (ocd == NULL) { CERROR("Can't alloc ocd connecting to %s\n", lustre_cfg_string(lcfg, 1)); @@ -2074,7 +2072,7 @@ static int echo_client_setup(const struct lu_env *env, spin_unlock(&tgt->obd_dev_lock); } - OBD_FREE(ocd, sizeof(*ocd)); + kfree(ocd); if (rc != 0) { CERROR("fail to connect to device %s\n", @@ -2143,15 +2141,11 @@ static struct obd_ops echo_client_obd_ops = { int echo_client_init(void) { - struct lprocfs_static_vars lvars = { NULL }; int rc; - lprocfs_echo_init_vars(&lvars); - rc = lu_kmem_init(echo_caches); if (rc == 0) { rc = class_register_type(&echo_client_obd_ops, NULL, - lvars.module_vars, LUSTRE_ECHO_CLIENT_NAME, &echo_device_type); if (rc) @@ -2168,15 +2162,10 @@ void echo_client_exit(void) static int __init obdecho_init(void) { - struct lprocfs_static_vars lvars; - LCONSOLE_INFO("Echo OBD driver; http://www.lustre.org/\n"); LASSERT(PAGE_CACHE_SIZE % OBD_ECHO_BLOCK_SIZE == 0); - lprocfs_echo_init_vars(&lvars); - - return echo_client_init(); } diff --git a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c b/drivers/staging/lustre/lustre/obdecho/lproc_echo.c deleted file mode 100644 index 0beb97db7c7d..000000000000 --- a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ -#define DEBUG_SUBSYSTEM S_ECHO - -#include "../include/lprocfs_status.h" -#include "../include/obd_class.h" - -#if defined(CONFIG_PROC_FS) -LPROC_SEQ_FOPS_RO_TYPE(echo, uuid); -static struct lprocfs_vars lprocfs_echo_obd_vars[] = { - { "uuid", &echo_uuid_fops, NULL, 0 }, - { NULL } -}; - -LPROC_SEQ_FOPS_RO_TYPE(echo, numrefs); -static struct lprocfs_vars lprocfs_echo_module_vars[] = { - { "num_refs", &echo_numrefs_fops, NULL, 0 }, - { NULL } -}; - -void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars) -{ - lvars->module_vars = lprocfs_echo_module_vars; - lvars->obd_vars = lprocfs_echo_obd_vars; -} -#endif /* CONFIG_PROC_FS */ diff --git a/drivers/staging/lustre/lustre/osc/Makefile b/drivers/staging/lustre/lustre/osc/Makefile index 54927fba4eb4..37cdeea9ac49 100644 --- a/drivers/staging/lustre/lustre/osc/Makefile +++ b/drivers/staging/lustre/lustre/osc/Makefile @@ -1,4 +1,3 @@ obj-$(CONFIG_LUSTRE_FS) += osc.o osc-y := osc_request.o osc_dev.o osc_object.o \ - osc_page.o osc_lock.o osc_io.o osc_quota.o osc_cache.o -osc-$(CONFIG_PROC_FS) += lproc_osc.o + osc_page.o osc_lock.o osc_io.o osc_quota.o osc_cache.o lproc_osc.o diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 15a66209831c..ff6d2e2ffdab 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -42,25 +42,25 @@ #include <linux/seq_file.h> #include "osc_internal.h" -static int osc_active_seq_show(struct seq_file *m, void *v) +static ssize_t active_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; - - LPROCFS_CLIMP_CHECK(dev); - seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive); - LPROCFS_CLIMP_EXIT(dev); + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); - return 0; + return sprintf(buf, "%d\n", !dev->u.cli.cl_import->imp_deactive); } -static ssize_t osc_active_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t active_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - int val, rc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; if (val < 0 || val > 1) @@ -70,41 +70,43 @@ static ssize_t osc_active_seq_write(struct file *file, if (dev->u.cli.cl_import->imp_deactive == val) rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val); else - CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n", val); + CDEBUG(D_CONFIG, "activate %ld: ignoring repeat request\n", + val); return count; } -LPROC_SEQ_FOPS(osc_active); +LUSTRE_RW_ATTR(active); -static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v) +static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; - client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight); - client_obd_list_unlock(&cli->cl_loi_list_lock); - - return 0; + return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); } -static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; struct ptlrpc_request_pool *pool = cli->cl_import->imp_rq_pool; - int val, rc; + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; if (val < 1 || val > OSC_MAX_RIF_MAX) return -ERANGE; - LPROCFS_CLIMP_CHECK(dev); if (pool && val > cli->cl_max_rpcs_in_flight) pool->prp_populate(pool, val-cli->cl_max_rpcs_in_flight); @@ -112,14 +114,16 @@ static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file, cli->cl_max_rpcs_in_flight = val; client_obd_list_unlock(&cli->cl_loi_list_lock); - LPROCFS_CLIMP_EXIT(dev); return count; } -LPROC_SEQ_FOPS(osc_max_rpcs_in_flight); +LUSTRE_RW_ATTR(max_rpcs_in_flight); -static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v) +static ssize_t max_dirty_mb_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; long val; int mult; @@ -129,22 +133,26 @@ static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v) client_obd_list_unlock(&cli->cl_loi_list_lock); mult = 1 << 20; - return lprocfs_seq_read_frac_helper(m, val, mult); + return lprocfs_read_frac_helper(buf, PAGE_SIZE, val, mult); } -static ssize_t osc_max_dirty_mb_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_dirty_mb_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; - int pages_number, mult, rc; + int rc; + unsigned long pages_number; - mult = 1 << (20 - PAGE_CACHE_SHIFT); - rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); + rc = kstrtoul(buffer, 10, &pages_number); if (rc) return rc; + pages_number *= 1 << (20 - PAGE_CACHE_SHIFT); /* MB -> pages */ + if (pages_number <= 0 || pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_CACHE_SHIFT) || pages_number > totalram_pages / 4) /* 1/4 of RAM */ @@ -157,7 +165,7 @@ static ssize_t osc_max_dirty_mb_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(osc_max_dirty_mb); +LUSTRE_RW_ATTR(max_dirty_mb); static int osc_cached_mb_seq_show(struct seq_file *m, void *v) { @@ -210,44 +218,51 @@ static ssize_t osc_cached_mb_seq_write(struct file *file, } LPROC_SEQ_FOPS(osc_cached_mb); -static int osc_cur_dirty_bytes_seq_show(struct seq_file *m, void *v) +static ssize_t cur_dirty_bytes_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; + int len; client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%lu\n", cli->cl_dirty); + len = sprintf(buf, "%lu\n", cli->cl_dirty); client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return len; } -LPROC_SEQ_FOPS_RO(osc_cur_dirty_bytes); +LUSTRE_RO_ATTR(cur_dirty_bytes); -static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v) +static ssize_t cur_grant_bytes_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; + int len; client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%lu\n", cli->cl_avail_grant); + len = sprintf(buf, "%lu\n", cli->cl_avail_grant); client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return len; } -static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t cur_grant_bytes_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &obd->u.cli; - int rc; - __u64 val; - - if (obd == NULL) - return 0; + int rc; + unsigned long long val; - rc = lprocfs_write_u64_helper(buffer, count, &val); + rc = kstrtoull(buffer, 10, &val); if (rc) return rc; @@ -255,54 +270,56 @@ static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, client_obd_list_lock(&cli->cl_loi_list_lock); if (val >= cli->cl_avail_grant) { client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return -EINVAL; } client_obd_list_unlock(&cli->cl_loi_list_lock); - LPROCFS_CLIMP_CHECK(obd); if (cli->cl_import->imp_state == LUSTRE_IMP_FULL) rc = osc_shrink_grant_to_target(cli, val); - LPROCFS_CLIMP_EXIT(obd); if (rc) return rc; return count; } -LPROC_SEQ_FOPS(osc_cur_grant_bytes); +LUSTRE_RW_ATTR(cur_grant_bytes); -static int osc_cur_lost_grant_bytes_seq_show(struct seq_file *m, void *v) +static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; + int len; client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%lu\n", cli->cl_lost_grant); + len = sprintf(buf, "%lu\n", cli->cl_lost_grant); client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return len; } -LPROC_SEQ_FOPS_RO(osc_cur_lost_grant_bytes); +LUSTRE_RO_ATTR(cur_lost_grant_bytes); -static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v) +static ssize_t grant_shrink_interval_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - if (obd == NULL) - return 0; - seq_printf(m, "%d\n", obd->u.cli.cl_grant_shrink_interval); - return 0; + return sprintf(buf, "%d\n", obd->u.cli.cl_grant_shrink_interval); } -static ssize_t osc_grant_shrink_interval_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t grant_shrink_interval_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - int val, rc; - - if (obd == NULL) - return 0; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -313,30 +330,29 @@ static ssize_t osc_grant_shrink_interval_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(osc_grant_shrink_interval); +LUSTRE_RW_ATTR(grant_shrink_interval); -static int osc_checksum_seq_show(struct seq_file *m, void *v) +static ssize_t checksums_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; - - if (obd == NULL) - return 0; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - seq_printf(m, "%d\n", obd->u.cli.cl_checksum ? 1 : 0); - return 0; + return sprintf(buf, "%d\n", obd->u.cli.cl_checksum ? 1 : 0); } -static ssize_t osc_checksum_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t checksums_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - int val, rc; - - if (obd == NULL) - return 0; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -344,7 +360,7 @@ static ssize_t osc_checksum_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(osc_checksum); +LUSTRE_RW_ATTR(checksums); static int osc_checksum_type_seq_show(struct seq_file *m, void *v) { @@ -400,22 +416,27 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, } LPROC_SEQ_FOPS(osc_checksum_type); -static int osc_resend_count_seq_show(struct seq_file *m, void *v) +static ssize_t resend_count_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends)); - return 0; + return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_resends)); } -static ssize_t osc_resend_count_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t resend_count_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - int val, rc; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -426,75 +447,94 @@ static ssize_t osc_resend_count_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(osc_resend_count); +LUSTRE_RW_ATTR(resend_count); -static int osc_contention_seconds_seq_show(struct seq_file *m, void *v) +static ssize_t contention_seconds_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct osc_device *od = obd2osc_dev(obd); - seq_printf(m, "%u\n", od->od_contention_time); - return 0; + return sprintf(buf, "%u\n", od->od_contention_time); } -static ssize_t osc_contention_seconds_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t contention_seconds_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct osc_device *od = obd2osc_dev(obd); return lprocfs_write_helper(buffer, count, &od->od_contention_time) ?: count; } -LPROC_SEQ_FOPS(osc_contention_seconds); +LUSTRE_RW_ATTR(contention_seconds); -static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v) +static ssize_t lockless_truncate_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct osc_device *od = obd2osc_dev(obd); - seq_printf(m, "%u\n", od->od_lockless_truncate); - return 0; + return sprintf(buf, "%u\n", od->od_lockless_truncate); } -static ssize_t osc_lockless_truncate_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t lockless_truncate_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct osc_device *od = obd2osc_dev(obd); return lprocfs_write_helper(buffer, count, &od->od_lockless_truncate) ?: count; } -LPROC_SEQ_FOPS(osc_lockless_truncate); +LUSTRE_RW_ATTR(lockless_truncate); -static int osc_destroys_in_flight_seq_show(struct seq_file *m, void *v) +static ssize_t destroys_in_flight_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_destroy_in_flight)); - return 0; + return sprintf(buf, "%u\n", + atomic_read(&obd->u.cli.cl_destroy_in_flight)); } -LPROC_SEQ_FOPS_RO(osc_destroys_in_flight); +LUSTRE_RO_ATTR(destroys_in_flight); -static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v) +static ssize_t max_pages_per_rpc_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - return lprocfs_obd_rd_max_pages_per_rpc(m, m->private); + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + struct client_obd *cli = &dev->u.cli; + + return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc); } -static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_pages_per_rpc_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data; int chunk_mask, rc; - __u64 val; + unsigned long long val; - rc = lprocfs_write_u64_helper(buffer, count, &val); + rc = kstrtoull(buffer, 10, &val); if (rc) return rc; @@ -502,32 +542,21 @@ static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file, if (val >= ONE_MB_BRW_SIZE) val >>= PAGE_CACHE_SHIFT; - LPROCFS_CLIMP_CHECK(dev); - chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_CACHE_SHIFT)) - 1); /* max_pages_per_rpc must be chunk aligned */ val = (val + ~chunk_mask) & chunk_mask; if (val == 0 || val > ocd->ocd_brw_size >> PAGE_CACHE_SHIFT) { - LPROCFS_CLIMP_EXIT(dev); return -ERANGE; } client_obd_list_lock(&cli->cl_loi_list_lock); cli->cl_max_pages_per_rpc = val; client_obd_list_unlock(&cli->cl_loi_list_lock); - LPROCFS_CLIMP_EXIT(dev); return count; } -LPROC_SEQ_FOPS(osc_obd_max_pages_per_rpc); +LUSTRE_RW_ATTR(max_pages_per_rpc); -LPROC_SEQ_FOPS_RO_TYPE(osc, uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags); -LPROC_SEQ_FOPS_RO_TYPE(osc, blksize); -LPROC_SEQ_FOPS_RO_TYPE(osc, kbytestotal); -LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesfree); -LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesavail); -LPROC_SEQ_FOPS_RO_TYPE(osc, filestotal); -LPROC_SEQ_FOPS_RO_TYPE(osc, filesfree); LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts); @@ -539,46 +568,20 @@ LPROC_SEQ_FOPS_RW_TYPE(osc, import); LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov); static struct lprocfs_vars lprocfs_osc_obd_vars[] = { - { "uuid", &osc_uuid_fops, NULL, 0 }, { "ping", &osc_ping_fops, NULL, 0222 }, { "connect_flags", &osc_connect_flags_fops, NULL, 0 }, - { "blocksize", &osc_blksize_fops, NULL, 0 }, - { "kbytestotal", &osc_kbytestotal_fops, NULL, 0 }, - { "kbytesfree", &osc_kbytesfree_fops, NULL, 0 }, - { "kbytesavail", &osc_kbytesavail_fops, NULL, 0 }, - { "filestotal", &osc_filestotal_fops, NULL, 0 }, - { "filesfree", &osc_filesfree_fops, NULL, 0 }, /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ { "ost_server_uuid", &osc_server_uuid_fops, NULL, 0 }, { "ost_conn_uuid", &osc_conn_uuid_fops, NULL, 0 }, - { "active", &osc_active_fops, NULL }, - { "max_pages_per_rpc", &osc_obd_max_pages_per_rpc_fops, NULL }, - { "max_rpcs_in_flight", &osc_max_rpcs_in_flight_fops, NULL }, - { "destroys_in_flight", &osc_destroys_in_flight_fops, NULL, 0 }, - { "max_dirty_mb", &osc_max_dirty_mb_fops, NULL }, { "osc_cached_mb", &osc_cached_mb_fops, NULL }, - { "cur_dirty_bytes", &osc_cur_dirty_bytes_fops, NULL, 0 }, - { "cur_grant_bytes", &osc_cur_grant_bytes_fops, NULL }, - { "cur_lost_grant_bytes", &osc_cur_lost_grant_bytes_fops, NULL, 0}, - { "grant_shrink_interval", &osc_grant_shrink_interval_fops, NULL }, - { "checksums", &osc_checksum_fops, NULL }, { "checksum_type", &osc_checksum_type_fops, NULL }, - { "resend_count", &osc_resend_count_fops, NULL}, { "timeouts", &osc_timeouts_fops, NULL, 0 }, - { "contention_seconds", &osc_contention_seconds_fops, NULL }, - { "lockless_truncate", &osc_lockless_truncate_fops, NULL }, { "import", &osc_import_fops, NULL }, { "state", &osc_state_fops, NULL, 0 }, { "pinger_recov", &osc_pinger_recov_fops, NULL }, { NULL } }; -LPROC_SEQ_FOPS_RO_TYPE(osc, numrefs); -static struct lprocfs_vars lprocfs_osc_module_vars[] = { - { "num_refs", &osc_numrefs_fops, NULL, 0 }, - { NULL } -}; - #define pct(a, b) (b ? a * 100 / b : 0) static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) @@ -679,8 +682,8 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) #undef pct static ssize_t osc_rpc_stats_seq_write(struct file *file, - const char __user *buf, - size_t len, loff_t *off) + const char __user *buf, + size_t len, loff_t *off) { struct seq_file *seq = file->private_data; struct obd_device *dev = seq->private; @@ -718,8 +721,8 @@ static int osc_stats_seq_show(struct seq_file *seq, void *v) } static ssize_t osc_stats_seq_write(struct file *file, - const char __user *buf, - size_t len, loff_t *off) + const char __user *buf, + size_t len, loff_t *off) { struct seq_file *seq = file->private_data; struct obd_device *dev = seq->private; @@ -735,17 +738,38 @@ int lproc_osc_attach_seqstat(struct obd_device *dev) { int rc; - rc = lprocfs_seq_create(dev->obd_proc_entry, "osc_stats", 0644, - &osc_stats_fops, dev); + rc = ldebugfs_seq_create(dev->obd_debugfs_entry, "osc_stats", 0644, + &osc_stats_fops, dev); if (rc == 0) - rc = lprocfs_obd_seq_create(dev, "rpc_stats", 0644, - &osc_rpc_stats_fops, dev); + rc = ldebugfs_obd_seq_create(dev, "rpc_stats", 0644, + &osc_rpc_stats_fops, dev); return rc; } +static struct attribute *osc_attrs[] = { + &lustre_attr_active.attr, + &lustre_attr_checksums.attr, + &lustre_attr_contention_seconds.attr, + &lustre_attr_cur_dirty_bytes.attr, + &lustre_attr_cur_grant_bytes.attr, + &lustre_attr_cur_lost_grant_bytes.attr, + &lustre_attr_destroys_in_flight.attr, + &lustre_attr_grant_shrink_interval.attr, + &lustre_attr_lockless_truncate.attr, + &lustre_attr_max_dirty_mb.attr, + &lustre_attr_max_pages_per_rpc.attr, + &lustre_attr_max_rpcs_in_flight.attr, + &lustre_attr_resend_count.attr, + NULL, +}; + +static struct attribute_group osc_attr_group = { + .attrs = osc_attrs, +}; + void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_osc_module_vars; + lvars->sysfs_vars = &osc_attr_group; lvars->obd_vars = lprocfs_osc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index d44b3d4ffe4d..5592d32a1a95 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -112,8 +112,8 @@ static const char *oes_strings[] = { /* ----- extent part 0 ----- */ \ __ext, EXTPARA(__ext), \ /* ----- part 1 ----- */ \ - atomic_read(&__ext->oe_refc), \ - atomic_read(&__ext->oe_users), \ + atomic_read(&__ext->oe_refc), \ + atomic_read(&__ext->oe_users), \ list_empty_marker(&__ext->oe_link), \ oes_strings[__ext->oe_state], ext_flags(__ext, __buf), \ __ext->oe_obj, \ @@ -297,12 +297,12 @@ out: #define sanity_check_nolock(ext) \ osc_extent_sanity_check0(ext, __func__, __LINE__) -#define sanity_check(ext) ({ \ - int __res; \ +#define sanity_check(ext) ({ \ + int __res; \ osc_object_lock((ext)->oe_obj); \ - __res = sanity_check_nolock(ext); \ - osc_object_unlock((ext)->oe_obj); \ - __res; \ + __res = sanity_check_nolock(ext); \ + osc_object_unlock((ext)->oe_obj); \ + __res; \ }) @@ -411,7 +411,7 @@ static void osc_extent_put_trust(struct osc_extent *ext) static struct osc_extent *osc_extent_search(struct osc_object *obj, pgoff_t index) { - struct rb_node *n = obj->oo_root.rb_node; + struct rb_node *n = obj->oo_root.rb_node; struct osc_extent *tmp, *p = NULL; LASSERT(osc_object_is_locked(obj)); @@ -447,8 +447,8 @@ static struct osc_extent *osc_extent_lookup(struct osc_object *obj, /* caller must have held object lock. */ static void osc_extent_insert(struct osc_object *obj, struct osc_extent *ext) { - struct rb_node **n = &obj->oo_root.rb_node; - struct rb_node *parent = NULL; + struct rb_node **n = &obj->oo_root.rb_node; + struct rb_node *parent = NULL; struct osc_extent *tmp; LASSERT(ext->oe_intree == 0); @@ -544,19 +544,19 @@ static int osc_extent_merge(const struct lu_env *env, struct osc_extent *cur, LASSERT(cur->oe_osclock == victim->oe_osclock); ppc_bits = osc_cli(obj)->cl_chunkbits - PAGE_CACHE_SHIFT; chunk_start = cur->oe_start >> ppc_bits; - chunk_end = cur->oe_end >> ppc_bits; - if (chunk_start != (victim->oe_end >> ppc_bits) + 1 && + chunk_end = cur->oe_end >> ppc_bits; + if (chunk_start != (victim->oe_end >> ppc_bits) + 1 && chunk_end + 1 != victim->oe_start >> ppc_bits) return -ERANGE; OSC_EXTENT_DUMP(D_CACHE, victim, "will be merged by %p.\n", cur); - cur->oe_start = min(cur->oe_start, victim->oe_start); - cur->oe_end = max(cur->oe_end, victim->oe_end); - cur->oe_grants += victim->oe_grants; + cur->oe_start = min(cur->oe_start, victim->oe_start); + cur->oe_end = max(cur->oe_end, victim->oe_end); + cur->oe_grants += victim->oe_grants; cur->oe_nr_pages += victim->oe_nr_pages; /* only the following bits are needed to merge */ - cur->oe_urgent |= victim->oe_urgent; + cur->oe_urgent |= victim->oe_urgent; cur->oe_memalloc |= victim->oe_memalloc; list_splice_init(&victim->oe_pages, &cur->oe_pages); list_del_init(&victim->oe_link); @@ -624,18 +624,18 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, { struct client_obd *cli = osc_cli(obj); - struct cl_lock *lock; + struct cl_lock *lock; struct osc_extent *cur; struct osc_extent *ext; struct osc_extent *conflict = NULL; struct osc_extent *found = NULL; - pgoff_t chunk; - pgoff_t max_end; - int max_pages; /* max_pages_per_rpc */ - int chunksize; - int ppc_bits; /* pages per chunk bits */ - int chunk_mask; - int rc; + pgoff_t chunk; + pgoff_t max_end; + int max_pages; /* max_pages_per_rpc */ + int chunksize; + int ppc_bits; /* pages per chunk bits */ + int chunk_mask; + int rc; cur = osc_extent_alloc(obj); if (cur == NULL) @@ -646,10 +646,10 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, LASSERT(lock->cll_descr.cld_mode >= CLM_WRITE); LASSERT(cli->cl_chunkbits >= PAGE_CACHE_SHIFT); - ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; + ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; chunk_mask = ~((1 << ppc_bits) - 1); - chunksize = 1 << cli->cl_chunkbits; - chunk = index >> ppc_bits; + chunksize = 1 << cli->cl_chunkbits; + chunk = index >> ppc_bits; /* align end to rpc edge, rpc size may not be a power 2 integer. */ max_pages = cli->cl_max_pages_per_rpc; @@ -659,15 +659,15 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, /* initialize new extent by parameters so far */ cur->oe_max_end = max_end; - cur->oe_start = index & chunk_mask; - cur->oe_end = ((index + ~chunk_mask + 1) & chunk_mask) - 1; + cur->oe_start = index & chunk_mask; + cur->oe_end = ((index + ~chunk_mask + 1) & chunk_mask) - 1; if (cur->oe_start < lock->cll_descr.cld_start) cur->oe_start = lock->cll_descr.cld_start; if (cur->oe_end > max_end) cur->oe_end = max_end; cur->oe_osclock = lock; - cur->oe_grants = 0; - cur->oe_mppr = max_pages; + cur->oe_grants = 0; + cur->oe_mppr = max_pages; /* grants has been allocated by caller */ LASSERTF(*grants >= chunksize + cli->cl_extent_tax, @@ -681,7 +681,7 @@ restart: ext = first_extent(obj); while (ext != NULL) { loff_t ext_chk_start = ext->oe_start >> ppc_bits; - loff_t ext_chk_end = ext->oe_end >> ppc_bits; + loff_t ext_chk_end = ext->oe_end >> ppc_bits; LASSERT(sanity_check_nolock(ext) == 0); if (chunk > ext_chk_end + 1) @@ -755,14 +755,14 @@ restart: EASSERT((ext->oe_start & ~chunk_mask) == 0, ext); /* pull ext's start back to cover cur */ - ext->oe_start = cur->oe_start; + ext->oe_start = cur->oe_start; ext->oe_grants += chunksize; *grants -= chunksize; found = osc_extent_hold(ext); } else if (chunk == ext_chk_end + 1) { /* rear merge */ - ext->oe_end = cur->oe_end; + ext->oe_end = cur->oe_end; ext->oe_grants += chunksize; *grants -= chunksize; @@ -943,21 +943,21 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, * @size, then partial truncate happens. */ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, - bool partial) + bool partial) { - struct cl_env_nest nest; - struct lu_env *env; - struct cl_io *io; - struct osc_object *obj = ext->oe_obj; - struct client_obd *cli = osc_cli(obj); + struct cl_env_nest nest; + struct lu_env *env; + struct cl_io *io; + struct osc_object *obj = ext->oe_obj; + struct client_obd *cli = osc_cli(obj); struct osc_async_page *oap; struct osc_async_page *tmp; - int pages_in_chunk = 0; - int ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; - __u64 trunc_chunk = trunc_index >> ppc_bits; - int grants = 0; - int nr_pages = 0; - int rc = 0; + int pages_in_chunk = 0; + int ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; + __u64 trunc_chunk = trunc_index >> ppc_bits; + int grants = 0; + int nr_pages = 0; + int rc = 0; LASSERT(sanity_check(ext) == 0); EASSERT(ext->oe_state == OES_TRUNC, ext); @@ -976,8 +976,8 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, /* discard all pages with index greater then trunc_index */ list_for_each_entry_safe(oap, tmp, &ext->oe_pages, oap_pending_item) { - struct cl_page *sub = oap2cl_page(oap); - struct cl_page *page = cl_page_top(sub); + struct cl_page *sub = oap2cl_page(oap); + struct cl_page *page = cl_page_top(sub); LASSERT(list_empty(&oap->oap_rpc_item)); @@ -1022,7 +1022,7 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, grants = ext->oe_grants; ext->oe_grants = 0; } else { /* calculate how many grants we can free */ - int chunks = (ext->oe_end >> ppc_bits) - trunc_chunk; + int chunks = (ext->oe_end >> ppc_bits) - trunc_chunk; pgoff_t last_index; @@ -1038,10 +1038,10 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, } /* this is what we can free from this extent */ - grants = chunks << cli->cl_chunkbits; + grants = chunks << cli->cl_chunkbits; ext->oe_grants -= grants; - last_index = ((trunc_chunk + 1) << ppc_bits) - 1; - ext->oe_end = min(last_index, ext->oe_max_end); + last_index = ((trunc_chunk + 1) << ppc_bits) - 1; + ext->oe_end = min(last_index, ext->oe_max_end); LASSERT(ext->oe_end >= ext->oe_start); LASSERT(ext->oe_grants > 0); } @@ -1236,8 +1236,8 @@ static inline int osc_is_ready(struct osc_object *osc) static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap, int cmd) { - struct osc_page *opg = oap2osc_page(oap); - struct cl_page *page = cl_page_top(oap2cl_page(oap)); + struct osc_page *opg = oap2osc_page(oap); + struct cl_page *page = cl_page_top(oap2cl_page(oap)); int result; LASSERT(cmd == OBD_BRW_WRITE); /* no cached reads */ @@ -1251,10 +1251,10 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap, static int osc_refresh_count(const struct lu_env *env, struct osc_async_page *oap, int cmd) { - struct osc_page *opg = oap2osc_page(oap); - struct cl_page *page = oap2cl_page(oap); + struct osc_page *opg = oap2osc_page(oap); + struct cl_page *page = oap2cl_page(oap); struct cl_object *obj; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; int result; loff_t kms; @@ -1283,10 +1283,10 @@ static int osc_refresh_count(const struct lu_env *env, static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, int cmd, int rc) { - struct osc_page *opg = oap2osc_page(oap); - struct cl_page *page = cl_page_top(oap2cl_page(oap)); - struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); - enum cl_req_type crt; + struct osc_page *opg = oap2osc_page(oap); + struct cl_page *page = cl_page_top(oap2cl_page(oap)); + struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); + enum cl_req_type crt; int srvlock; cmd &= ~OBD_BRW_NOQUOTA; @@ -1318,7 +1318,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, /* statistic */ if (rc == 0 && srvlock) { - struct lu_device *ld = opg->ops_cl.cpl_obj->co_lu.lo_dev; + struct lu_device *ld = opg->ops_cl.cpl_obj->co_lu.lo_dev; struct osc_stats *stats = &lu2osc_dev(ld)->od_stats; int bytes = oap->oap_count; @@ -1396,7 +1396,7 @@ static int osc_reserve_grant(struct client_obd *cli, unsigned int bytes) int rc = -EDQUOT; if (cli->cl_avail_grant >= bytes) { - cli->cl_avail_grant -= bytes; + cli->cl_avail_grant -= bytes; cli->cl_reserved_grant += bytes; rc = 0; } @@ -1527,7 +1527,7 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, struct osc_async_page *oap, int bytes) { struct osc_object *osc = oap->oap_obj; - struct lov_oinfo *loi = osc->oo_oinfo; + struct lov_oinfo *loi = osc->oo_oinfo; struct osc_cache_waiter ocw; struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); int rc = -EDQUOT; @@ -1782,7 +1782,7 @@ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli, struct osc_async_page *oap, int sent, int rc) { struct osc_object *osc = oap->oap_obj; - struct lov_oinfo *loi = osc->oo_oinfo; + struct lov_oinfo *loi = osc->oo_oinfo; __u64 xid = 0; if (oap->oap_request != NULL) { @@ -2049,7 +2049,7 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, #define list_to_obj(list, item) ({ \ struct list_head *__tmp = (list)->next; \ - list_del_init(__tmp); \ + list_del_init(__tmp); \ list_entry(__tmp, struct osc_object, oo_##item); \ }) @@ -2179,7 +2179,7 @@ static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli, } static int osc_io_unplug_async(const struct lu_env *env, - struct client_obd *cli, struct osc_object *osc) + struct client_obd *cli, struct osc_object *osc) { /* XXX: policy is no use actually. */ return osc_io_unplug0(env, cli, osc, PDL_POLICY_ROUND, 1); @@ -2194,7 +2194,7 @@ void osc_io_unplug(const struct lu_env *env, struct client_obd *cli, int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, struct page *page, loff_t offset) { - struct obd_export *exp = osc_export(osc); + struct obd_export *exp = osc_export(osc); struct osc_async_page *oap = &ops->ops_oap; if (!page) @@ -2224,16 +2224,16 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, struct osc_page *ops) { struct osc_io *oio = osc_env_io(env); - struct osc_extent *ext = NULL; + struct osc_extent *ext = NULL; struct osc_async_page *oap = &ops->ops_oap; - struct client_obd *cli = oap->oap_cli; - struct osc_object *osc = oap->oap_obj; + struct client_obd *cli = oap->oap_cli; + struct osc_object *osc = oap->oap_obj; pgoff_t index; - int grants = 0; - int brw_flags = OBD_BRW_ASYNC; - int cmd = OBD_BRW_WRITE; - int need_release = 0; - int rc = 0; + int grants = 0; + int brw_flags = OBD_BRW_ASYNC; + int cmd = OBD_BRW_WRITE; + int need_release = 0; + int rc = 0; if (oap->oap_magic != OAP_MAGIC) return -EINVAL; @@ -2256,7 +2256,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, /* check if the file's owner/group is over quota */ if (!(cmd & OBD_BRW_NOQUOTA)) { struct cl_object *obj; - struct cl_attr *attr; + struct cl_attr *attr; unsigned int qid[MAXQUOTAS]; obj = cl_object_top(&osc->oo_cl); @@ -2386,7 +2386,7 @@ int osc_teardown_async_page(const struct lu_env *env, struct osc_object *obj, struct osc_page *ops) { struct osc_async_page *oap = &ops->ops_oap; - struct osc_extent *ext = NULL; + struct osc_extent *ext = NULL; int rc = 0; LASSERT(oap->oap_magic == OAP_MAGIC); @@ -2425,10 +2425,10 @@ int osc_teardown_async_page(const struct lu_env *env, int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, struct osc_page *ops) { - struct osc_extent *ext = NULL; - struct osc_object *obj = cl2osc(ops->ops_cl.cpl_obj); - struct cl_page *cp = ops->ops_cl.cpl_page; - pgoff_t index = cp->cp_index; + struct osc_extent *ext = NULL; + struct osc_object *obj = cl2osc(ops->ops_cl.cpl_obj); + struct cl_page *cp = ops->ops_cl.cpl_page; + pgoff_t index = cp->cp_index; struct osc_async_page *oap = &ops->ops_oap; bool unplug = false; int rc = 0; @@ -2507,14 +2507,14 @@ out: int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) { struct osc_async_page *oap = &ops->ops_oap; - struct osc_object *obj = oap->oap_obj; - struct client_obd *cli = osc_cli(obj); - struct osc_extent *ext; - struct osc_extent *found = NULL; - struct list_head *plist; + struct osc_object *obj = oap->oap_obj; + struct client_obd *cli = osc_cli(obj); + struct osc_extent *ext; + struct osc_extent *found = NULL; + struct list_head *plist; pgoff_t index = oap2cl_page(oap)->cp_index; - int rc = -EBUSY; - int cmd; + int rc = -EBUSY; + int cmd; LASSERT(!oap->oap_interrupted); oap->oap_interrupted = 1; @@ -2523,10 +2523,10 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) osc_object_lock(obj); if (oap->oap_cmd & OBD_BRW_WRITE) { plist = &obj->oo_urgent_exts; - cmd = OBD_BRW_WRITE; + cmd = OBD_BRW_WRITE; } else { plist = &obj->oo_reading_exts; - cmd = OBD_BRW_READ; + cmd = OBD_BRW_READ; } list_for_each_entry(ext, plist, oe_link) { if (ext->oe_start <= index && ext->oe_end >= index) { @@ -2564,13 +2564,13 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, struct list_head *list, int cmd, int brw_flags) { - struct client_obd *cli = osc_cli(obj); - struct osc_extent *ext; + struct client_obd *cli = osc_cli(obj); + struct osc_extent *ext; struct osc_async_page *oap, *tmp; - int page_count = 0; - int mppr = cli->cl_max_pages_per_rpc; - pgoff_t start = CL_PAGE_EOF; - pgoff_t end = 0; + int page_count = 0; + int mppr = cli->cl_max_pages_per_rpc; + pgoff_t start = CL_PAGE_EOF; + pgoff_t end = 0; list_for_each_entry(oap, list, oap_pending_item) { struct cl_page *cp = oap2cl_page(oap); @@ -2785,7 +2785,7 @@ int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj, { struct osc_extent *ext; pgoff_t index = start; - int result = 0; + int result = 0; again: osc_object_lock(obj); diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index 4935fc7c0706..9222c9f4faae 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -118,7 +118,7 @@ static struct lu_device *osc2lu_dev(struct osc_device *osc) */ static void *osc_key_init(const struct lu_context *ctx, - struct lu_context_key *key) + struct lu_context_key *key) { struct osc_thread_info *info; @@ -204,7 +204,7 @@ static struct lu_device *osc_device_free(const struct lu_env *env, struct osc_device *od = lu2osc_dev(d); cl_device_fini(lu2cl_dev(d)); - OBD_FREE_PTR(od); + kfree(od); return NULL; } @@ -217,7 +217,7 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env, struct obd_device *obd; int rc; - OBD_ALLOC_PTR(od); + od = kzalloc(sizeof(*od), GFP_NOFS); if (od == NULL) return ERR_PTR(-ENOMEM); @@ -248,14 +248,14 @@ static const struct lu_device_type_operations osc_device_type_ops = { .ldto_device_alloc = osc_device_alloc, .ldto_device_free = osc_device_free, - .ldto_device_init = osc_device_init, - .ldto_device_fini = osc_device_fini + .ldto_device_init = osc_device_init, + .ldto_device_fini = osc_device_fini }; struct lu_device_type osc_device_type = { - .ldt_tags = LU_DEVICE_CL, - .ldt_name = LUSTRE_OSC_NAME, - .ldt_ops = &osc_device_type_ops, + .ldt_tags = LU_DEVICE_CL, + .ldt_name = LUSTRE_OSC_NAME, + .ldt_ops = &osc_device_type_ops, .ldt_ctx_tags = LCT_CL_THREAD }; diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index af96c7bc7764..470698b0dd75 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -136,16 +136,8 @@ extern spinlock_t osc_ast_guard; int osc_cleanup(struct obd_device *obd); int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg); -#if defined (CONFIG_PROC_FS) int lproc_osc_attach_seqstat(struct obd_device *dev); void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars); -#else -static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;} -static inline void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -#endif extern struct lu_device_type osc_device_type; diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 3c7300b0651d..fa24e9ed1831 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -100,16 +100,16 @@ static int osc_io_submit(const struct lu_env *env, const struct cl_io_slice *ios, enum cl_req_type crt, struct cl_2queue *queue) { - struct cl_page *page; - struct cl_page *tmp; - struct client_obd *cli = NULL; - struct osc_object *osc = NULL; /* to keep gcc happy */ - struct osc_page *opg; - struct cl_io *io; + struct cl_page *page; + struct cl_page *tmp; + struct client_obd *cli = NULL; + struct osc_object *osc = NULL; /* to keep gcc happy */ + struct osc_page *opg; + struct cl_io *io; LIST_HEAD(list); - struct cl_page_list *qin = &queue->c2_qin; - struct cl_page_list *qout = &queue->c2_qout; + struct cl_page_list *qin = &queue->c2_qin; + struct cl_page_list *qout = &queue->c2_qout; int queued = 0; int result = 0; int cmd; @@ -189,8 +189,8 @@ static int osc_io_submit(const struct lu_env *env, static void osc_page_touch_at(const struct lu_env *env, struct cl_object *obj, pgoff_t idx, unsigned to) { - struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; int valid; __u64 kms; @@ -233,8 +233,8 @@ static void osc_page_touch_at(const struct lu_env *env, static void osc_page_touch(const struct lu_env *env, struct osc_page *opage, unsigned to) { - struct cl_page *page = opage->ops_cl.cpl_page; - struct cl_object *obj = opage->ops_cl.cpl_obj; + struct cl_page *page = opage->ops_cl.cpl_page; + struct cl_object *obj = opage->ops_cl.cpl_obj; osc_page_touch_at(env, obj, page->cp_index, to); } @@ -260,7 +260,7 @@ static int osc_io_prepare_write(const struct lu_env *env, { struct osc_device *dev = lu2osc_dev(slice->cpl_obj->co_lu.lo_dev); struct obd_import *imp = class_exp2cliimp(dev->od_exp); - struct osc_io *oio = cl2osc_io(env, ios); + struct osc_io *oio = cl2osc_io(env, ios); int result = 0; /* @@ -284,9 +284,9 @@ static int osc_io_commit_write(const struct lu_env *env, const struct cl_page_slice *slice, unsigned from, unsigned to) { - struct osc_io *oio = cl2osc_io(env, ios); - struct osc_page *opg = cl2osc_page(slice); - struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); + struct osc_io *oio = cl2osc_io(env, ios); + struct osc_page *opg = cl2osc_page(slice); + struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); struct osc_async_page *oap = &opg->ops_oap; LASSERT(to > 0); @@ -311,10 +311,10 @@ static int osc_io_commit_write(const struct lu_env *env, static int osc_io_fault_start(const struct lu_env *env, const struct cl_io_slice *ios) { - struct cl_io *io; + struct cl_io *io; struct cl_fault_io *fio; - io = ios->cis_io; + io = ios->cis_io; fio = &io->u.ci_fault; CDEBUG(D_INFO, "%lu %d %d\n", fio->ft_index, fio->ft_writable, fio->ft_nob); @@ -375,11 +375,11 @@ static void osc_trunc_check(const struct lu_env *env, struct cl_io *io, struct osc_io *oio, __u64 size) { struct cl_object *clob; - int partial; + int partial; pgoff_t start; - clob = oio->oi_cl.cis_obj; - start = cl_index(clob, size); + clob = oio->oi_cl.cis_obj; + start = cl_index(clob, size); partial = cl_offset(clob, start) < size; /* @@ -392,17 +392,17 @@ static void osc_trunc_check(const struct lu_env *env, struct cl_io *io, static int osc_io_setattr_start(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_io *io = slice->cis_io; - struct osc_io *oio = cl2osc_io(env, slice); - struct cl_object *obj = slice->cis_obj; - struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; - struct obdo *oa = &oio->oi_oa; + struct cl_io *io = slice->cis_io; + struct osc_io *oio = cl2osc_io(env, slice); + struct cl_object *obj = slice->cis_obj; + struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct obdo *oa = &oio->oi_oa; struct osc_async_cbargs *cbargs = &oio->oi_cbarg; - __u64 size = io->u.ci_setattr.sa_attr.lvb_size; - unsigned int ia_valid = io->u.ci_setattr.sa_valid; - int result = 0; - struct obd_info oinfo = { { { 0 } } }; + __u64 size = io->u.ci_setattr.sa_attr.lvb_size; + unsigned int ia_valid = io->u.ci_setattr.sa_valid; + int result = 0; + struct obd_info oinfo = { { { 0 } } }; /* truncate cache dirty pages first */ if (cl_io_is_trunc(io)) @@ -477,8 +477,8 @@ static int osc_io_setattr_start(const struct lu_env *env, static void osc_io_setattr_end(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_io *io = slice->cis_io; - struct osc_io *oio = cl2osc_io(env, slice); + struct cl_io *io = slice->cis_io; + struct osc_io *oio = cl2osc_io(env, slice); struct cl_object *obj = slice->cis_obj; struct osc_async_cbargs *cbargs = &oio->oi_cbarg; int result = 0; @@ -512,8 +512,8 @@ static void osc_io_setattr_end(const struct lu_env *env, static int osc_io_read_start(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_object *obj = slice->cis_obj; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_object *obj = slice->cis_obj; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; int rc = 0; if (!slice->cis_io->ci_noatime) { @@ -528,8 +528,8 @@ static int osc_io_read_start(const struct lu_env *env, static int osc_io_write_start(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_object *obj = slice->cis_obj; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_object *obj = slice->cis_obj; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; int rc = 0; OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1); @@ -544,10 +544,10 @@ static int osc_io_write_start(const struct lu_env *env, static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, struct cl_fsync_io *fio) { - struct osc_io *oio = osc_env_io(env); - struct obdo *oa = &oio->oi_oa; - struct obd_info *oinfo = &oio->oi_info; - struct lov_oinfo *loi = obj->oo_oinfo; + struct osc_io *oio = osc_env_io(env); + struct obdo *oa = &oio->oi_oa; + struct obd_info *oinfo = &oio->oi_info; + struct lov_oinfo *loi = obj->oo_oinfo; struct osc_async_cbargs *cbargs = &oio->oi_cbarg; int rc = 0; @@ -575,13 +575,13 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, static int osc_io_fsync_start(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_io *io = slice->cis_io; + struct cl_io *io = slice->cis_io; struct cl_fsync_io *fio = &io->u.ci_fsync; - struct cl_object *obj = slice->cis_obj; - struct osc_object *osc = cl2osc(obj); - pgoff_t start = cl_index(obj, fio->fi_start); - pgoff_t end = cl_index(obj, fio->fi_end); - int result = 0; + struct cl_object *obj = slice->cis_obj; + struct osc_object *osc = cl2osc(obj); + pgoff_t start = cl_index(obj, fio->fi_start); + pgoff_t end = cl_index(obj, fio->fi_end); + int result = 0; if (fio->fi_end == OBD_OBJECT_EOF) end = CL_PAGE_EOF; @@ -615,15 +615,15 @@ static void osc_io_fsync_end(const struct lu_env *env, const struct cl_io_slice *slice) { struct cl_fsync_io *fio = &slice->cis_io->u.ci_fsync; - struct cl_object *obj = slice->cis_obj; + struct cl_object *obj = slice->cis_obj; pgoff_t start = cl_index(obj, fio->fi_start); - pgoff_t end = cl_index(obj, fio->fi_end); + pgoff_t end = cl_index(obj, fio->fi_end); int result = 0; if (fio->fi_mode == CL_FSYNC_LOCAL) { result = osc_cache_wait_range(env, cl2osc(obj), start, end); } else if (fio->fi_mode == CL_FSYNC_ALL) { - struct osc_io *oio = cl2osc_io(env, slice); + struct osc_io *oio = cl2osc_io(env, slice); struct osc_async_cbargs *cbargs = &oio->oi_cbarg; wait_for_completion(&cbargs->opc_sync); @@ -717,17 +717,17 @@ static void osc_req_attr_set(const struct lu_env *env, struct cl_req_attr *attr, u64 flags) { struct lov_oinfo *oinfo; - struct cl_req *clerq; - struct cl_page *apage; /* _some_ page in @clerq */ - struct cl_lock *lock; /* _some_ lock protecting @apage */ - struct osc_lock *olck; - struct osc_page *opg; - struct obdo *oa; - struct ost_lvb *lvb; - - oinfo = cl2osc(obj)->oo_oinfo; - lvb = &oinfo->loi_lvb; - oa = attr->cra_oa; + struct cl_req *clerq; + struct cl_page *apage; /* _some_ page in @clerq */ + struct cl_lock *lock; /* _some_ lock protecting @apage */ + struct osc_lock *olck; + struct osc_page *opg; + struct obdo *oa; + struct ost_lvb *lvb; + + oinfo = cl2osc(obj)->oo_oinfo; + lvb = &oinfo->loi_lvb; + oa = attr->cra_oa; if ((flags & OBD_MD_FLMTIME) != 0) { oa->o_mtime = lvb->lvb_mtime; @@ -759,7 +759,7 @@ static void osc_req_attr_set(const struct lu_env *env, lock = cl_lock_at_page(env, apage->cp_obj, apage, NULL, 1, 1); if (lock == NULL) { struct cl_object_header *head; - struct cl_lock *scan; + struct cl_lock *scan; head = cl_object_header(apage->cp_obj); list_for_each_entry(scan, &head->coh_locks, diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 350ad49550ab..70b1b43f692b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -89,9 +89,9 @@ static struct ldlm_lock *osc_handle_ptr(struct lustre_handle *handle) */ static int osc_lock_invariant(struct osc_lock *ols) { - struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle); - struct ldlm_lock *olock = ols->ols_lock; - int handle_used = lustre_handle_is_used(&ols->ols_handle); + struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle); + struct ldlm_lock *olock = ols->ols_lock; + int handle_used = lustre_handle_is_used(&ols->ols_handle); if (ergo(osc_lock_is_lockless(ols), ols->ols_locklessable && ols->ols_lock == NULL)) @@ -164,7 +164,7 @@ static void osc_lock_detach(const struct lu_env *env, struct osc_lock *olck) lock_res_and_lock(dlmlock); if (dlmlock->l_granted_mode == dlmlock->l_req_mode) { struct cl_object *obj = olck->ols_cl.cls_obj; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; __u64 old_kms; cl_object_attr_lock(obj); @@ -237,7 +237,7 @@ static int osc_lock_unuse(const struct lu_env *env, static void osc_lock_fini(const struct lu_env *env, struct cl_lock_slice *slice) { - struct osc_lock *ols = cl2osc_lock(slice); + struct osc_lock *ols = cl2osc_lock(slice); LINVRNT(osc_lock_invariant(ols)); /* @@ -337,25 +337,25 @@ static void osc_ast_data_put(const struct lu_env *env, struct osc_lock *olck) static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, int rc) { - struct ost_lvb *lvb; - struct cl_object *obj; - struct lov_oinfo *oinfo; - struct cl_attr *attr; - unsigned valid; + struct ost_lvb *lvb; + struct cl_object *obj; + struct lov_oinfo *oinfo; + struct cl_attr *attr; + unsigned valid; if (!(olck->ols_flags & LDLM_FL_LVB_READY)) return; - lvb = &olck->ols_lvb; - obj = olck->ols_cl.cls_obj; + lvb = &olck->ols_lvb; + obj = olck->ols_cl.cls_obj; oinfo = cl2osc(obj)->oo_oinfo; - attr = &osc_env_info(env)->oti_attr; + attr = &osc_env_info(env)->oti_attr; valid = CAT_BLOCKS | CAT_ATIME | CAT_CTIME | CAT_MTIME | CAT_SIZE; cl_lvb2attr(attr, lvb); cl_object_attr_lock(obj); if (rc == 0) { - struct ldlm_lock *dlmlock; + struct ldlm_lock *dlmlock; __u64 size; dlmlock = olck->ols_lock; @@ -401,23 +401,23 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, static void osc_lock_granted(const struct lu_env *env, struct osc_lock *olck, struct ldlm_lock *dlmlock, int rc) { - struct ldlm_extent *ext; - struct cl_lock *lock; + struct ldlm_extent *ext; + struct cl_lock *lock; struct cl_lock_descr *descr; LASSERT(dlmlock->l_granted_mode == dlmlock->l_req_mode); if (olck->ols_state < OLS_GRANTED) { - lock = olck->ols_cl.cls_lock; - ext = &dlmlock->l_policy_data.l_extent; + lock = olck->ols_cl.cls_lock; + ext = &dlmlock->l_policy_data.l_extent; descr = &osc_env_info(env)->oti_descr; descr->cld_obj = lock->cll_descr.cld_obj; /* XXX check that ->l_granted_mode is valid. */ - descr->cld_mode = osc_ldlm2cl_lock(dlmlock->l_granted_mode); + descr->cld_mode = osc_ldlm2cl_lock(dlmlock->l_granted_mode); descr->cld_start = cl_index(descr->cld_obj, ext->start); - descr->cld_end = cl_index(descr->cld_obj, ext->end); - descr->cld_gid = ext->gid; + descr->cld_end = cl_index(descr->cld_obj, ext->end); + descr->cld_gid = ext->gid; /* * tell upper layers the extent of the lock that was actually * granted @@ -482,11 +482,11 @@ static void osc_lock_upcall0(const struct lu_env *env, struct osc_lock *olck) */ static int osc_lock_upcall(void *cookie, int errcode) { - struct osc_lock *olck = cookie; - struct cl_lock_slice *slice = &olck->ols_cl; - struct cl_lock *lock = slice->cls_lock; - struct lu_env *env; - struct cl_env_nest nest; + struct osc_lock *olck = cookie; + struct cl_lock_slice *slice = &olck->ols_cl; + struct cl_lock *lock = slice->cls_lock; + struct lu_env *env; + struct cl_env_nest nest; env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { @@ -626,7 +626,7 @@ static int osc_dlm_blocking_ast0(const struct lu_env *env, void *data, int flag) { struct osc_lock *olck; - struct cl_lock *lock; + struct cl_lock *lock; int result; int cancel; @@ -733,9 +733,9 @@ static int osc_ldlm_blocking_ast(struct ldlm_lock *dlmlock, struct ldlm_lock_desc *new, void *data, int flag) { - struct lu_env *env; + struct lu_env *env; struct cl_env_nest nest; - int result; + int result; /* * This can be called in the context of outer IO, e.g., @@ -774,9 +774,9 @@ static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock, __u64 flags, void *data) { struct cl_env_nest nest; - struct lu_env *env; - struct osc_lock *olck; - struct cl_lock *lock; + struct lu_env *env; + struct osc_lock *olck; + struct cl_lock *lock; int result; int dlmrc; @@ -830,15 +830,15 @@ static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock, static int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data) { - struct ptlrpc_request *req = data; + struct ptlrpc_request *req = data; struct osc_lock *olck; - struct cl_lock *lock; - struct cl_object *obj; - struct cl_env_nest nest; - struct lu_env *env; - struct ost_lvb *lvb; - struct req_capsule *cap; - int result; + struct cl_lock *lock; + struct cl_object *obj; + struct cl_env_nest nest; + struct lu_env *env; + struct ost_lvb *lvb; + struct req_capsule *cap; + int result; LASSERT(lustre_msg_get_opc(req->rq_reqmsg) == LDLM_GL_CALLBACK); @@ -916,11 +916,11 @@ static void osc_lock_build_einfo(const struct lu_env *env, */ mode = CLM_READ; - einfo->ei_type = LDLM_EXTENT; - einfo->ei_mode = osc_cl_lock2ldlm(mode); - einfo->ei_cb_bl = osc_ldlm_blocking_ast; - einfo->ei_cb_cp = osc_ldlm_completion_ast; - einfo->ei_cb_gl = osc_ldlm_glimpse_ast; + einfo->ei_type = LDLM_EXTENT; + einfo->ei_mode = osc_cl_lock2ldlm(mode); + einfo->ei_cb_bl = osc_ldlm_blocking_ast; + einfo->ei_cb_cp = osc_ldlm_completion_ast; + einfo->ei_cb_gl = osc_ldlm_glimpse_ast; einfo->ei_cbdata = lock; /* value to be put into ->l_ast_data */ } @@ -948,9 +948,9 @@ static void osc_lock_to_lockless(const struct lu_env *env, ols->ols_locklessable = 1; slice->cls_ops = &osc_lock_lockless_ops; } else { - struct osc_io *oio = osc_env_io(env); - struct cl_io *io = oio->oi_cl.cis_io; - struct cl_object *obj = slice->cls_obj; + struct osc_io *oio = osc_env_io(env); + struct cl_io *io = oio->oi_cl.cis_io; + struct cl_object *obj = slice->cls_obj; struct osc_object *oob = cl2osc(obj); const struct osc_device *osd = lu2osc_dev(obj->co_lu.lo_dev); struct obd_connect_data *ocd; @@ -1006,13 +1006,13 @@ static int osc_lock_compatible(const struct osc_lock *qing, static int osc_lock_enqueue_wait(const struct lu_env *env, const struct osc_lock *olck) { - struct cl_lock *lock = olck->ols_cl.cls_lock; - struct cl_lock_descr *descr = &lock->cll_descr; - struct cl_object_header *hdr = cl_object_header(descr->cld_obj); - struct cl_lock *scan; - struct cl_lock *conflict = NULL; - int lockless = osc_lock_is_lockless(olck); - int rc = 0; + struct cl_lock *lock = olck->ols_cl.cls_lock; + struct cl_lock_descr *descr = &lock->cll_descr; + struct cl_object_header *hdr = cl_object_header(descr->cld_obj); + struct cl_lock *scan; + struct cl_lock *conflict = NULL; + int lockless = osc_lock_is_lockless(olck); + int rc = 0; LASSERT(cl_lock_is_mutexed(lock)); @@ -1102,8 +1102,8 @@ static int osc_lock_enqueue(const struct lu_env *env, const struct cl_lock_slice *slice, struct cl_io *unused, __u32 enqflags) { - struct osc_lock *ols = cl2osc_lock(slice); - struct cl_lock *lock = ols->ols_cl.cls_lock; + struct osc_lock *ols = cl2osc_lock(slice); + struct cl_lock *lock = ols->ols_cl.cls_lock; int result; LASSERT(cl_lock_is_mutexed(lock)); @@ -1116,10 +1116,10 @@ static int osc_lock_enqueue(const struct lu_env *env, result = osc_lock_enqueue_wait(env, ols); if (result == 0) { if (!osc_lock_is_lockless(ols)) { - struct osc_object *obj = cl2osc(slice->cls_obj); - struct osc_thread_info *info = osc_env_info(env); - struct ldlm_res_id *resname = &info->oti_resname; - ldlm_policy_data_t *policy = &info->oti_policy; + struct osc_object *obj = cl2osc(slice->cls_obj); + struct osc_thread_info *info = osc_env_info(env); + struct ldlm_res_id *resname = &info->oti_resname; + ldlm_policy_data_t *policy = &info->oti_policy; struct ldlm_enqueue_info *einfo = &ols->ols_einfo; /* lock will be passed as upcall cookie, @@ -1164,7 +1164,7 @@ static int osc_lock_wait(const struct lu_env *env, const struct cl_lock_slice *slice) { struct osc_lock *olck = cl2osc_lock(slice); - struct cl_lock *lock = olck->ols_cl.cls_lock; + struct cl_lock *lock = olck->ols_cl.cls_lock; LINVRNT(osc_lock_invariant(olck)); @@ -1176,8 +1176,7 @@ static int osc_lock_wait(const struct lu_env *env, /* It is from enqueue RPC reply upcall for * updating state. Do not re-enqueue. */ return -ENAVAIL; - else - olck->ols_state = OLS_NEW; + olck->ols_state = OLS_NEW; } else { LASSERT(lock->cll_error); return lock->cll_error; @@ -1245,14 +1244,14 @@ static int osc_lock_use(const struct lu_env *env, static int osc_lock_flush(struct osc_lock *ols, int discard) { - struct cl_lock *lock = ols->ols_cl.cls_lock; - struct cl_env_nest nest; - struct lu_env *env; + struct cl_lock *lock = ols->ols_cl.cls_lock; + struct cl_env_nest nest; + struct lu_env *env; int result = 0; env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { - struct osc_object *obj = cl2osc(ols->ols_cl.cls_obj); + struct osc_object *obj = cl2osc(ols->ols_cl.cls_obj); struct cl_lock_descr *descr = &lock->cll_descr; int rc = 0; @@ -1298,11 +1297,11 @@ static int osc_lock_flush(struct osc_lock *ols, int discard) static void osc_lock_cancel(const struct lu_env *env, const struct cl_lock_slice *slice) { - struct cl_lock *lock = slice->cls_lock; - struct osc_lock *olck = cl2osc_lock(slice); + struct cl_lock *lock = slice->cls_lock; + struct osc_lock *olck = cl2osc_lock(slice); struct ldlm_lock *dlmlock = olck->ols_lock; - int result = 0; - int discard; + int result = 0; + int discard; LASSERT(cl_lock_is_mutexed(lock)); LINVRNT(osc_lock_invariant(olck)); @@ -1482,7 +1481,7 @@ static int osc_lock_lockless_unuse(const struct lu_env *env, static void osc_lock_lockless_cancel(const struct lu_env *env, const struct cl_lock_slice *slice) { - struct osc_lock *ols = cl2osc_lock(slice); + struct osc_lock *ols = cl2osc_lock(slice); int result; result = osc_lock_flush(ols, 0); @@ -1496,7 +1495,7 @@ static int osc_lock_lockless_wait(const struct lu_env *env, const struct cl_lock_slice *slice) { struct osc_lock *olck = cl2osc_lock(slice); - struct cl_lock *lock = olck->ols_cl.cls_lock; + struct cl_lock *lock = olck->ols_cl.cls_lock; LINVRNT(osc_lock_invariant(olck)); LASSERT(olck->ols_state >= OLS_UPCALL_RECEIVED); @@ -1512,7 +1511,7 @@ static void osc_lock_lockless_state(const struct lu_env *env, LINVRNT(osc_lock_invariant(lock)); if (state == CLS_HELD) { - struct osc_io *oio = osc_env_io(env); + struct osc_io *oio = osc_env_io(env); LASSERT(ergo(lock->ols_owner, lock->ols_owner == oio)); lock->ols_owner = oio; @@ -1591,7 +1590,7 @@ int osc_lock_init(const struct lu_env *env, int osc_dlm_lock_pageref(struct ldlm_lock *dlm) { struct osc_lock *olock; - int rc = 0; + int rc = 0; spin_lock(&osc_ast_guard); olock = dlm->l_ast_data; diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index 92c202f70395..c628a250ebd6 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -72,7 +72,7 @@ static struct osc_object *lu2osc(const struct lu_object *obj) static int osc_object_init(const struct lu_env *env, struct lu_object *obj, const struct lu_object_conf *conf) { - struct osc_object *osc = lu2osc(obj); + struct osc_object *osc = lu2osc(obj); const struct cl_object_conf *cconf = lu2cl_conf(conf); int i; @@ -136,9 +136,9 @@ int osc_lvb_print(const struct lu_env *env, void *cookie, static int osc_object_print(const struct lu_env *env, void *cookie, lu_printer_t p, const struct lu_object *obj) { - struct osc_object *osc = lu2osc(obj); - struct lov_oinfo *oinfo = osc->oo_oinfo; - struct osc_async_rc *ar = &oinfo->loi_ar; + struct osc_object *osc = lu2osc(obj); + struct lov_oinfo *oinfo = osc->oo_oinfo; + struct osc_async_rc *ar = &oinfo->loi_ar; (*p)(env, cookie, "id: " DOSTID " idx: %d gen: %d kms_valid: %u kms %llu rc: %d force_sync: %d min_xid: %llu ", POSTID(&oinfo->loi_oi), oinfo->loi_ost_idx, @@ -163,7 +163,7 @@ int osc_attr_set(const struct lu_env *env, struct cl_object *obj, const struct cl_attr *attr, unsigned valid) { struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo; - struct ost_lvb *lvb = &oinfo->loi_lvb; + struct ost_lvb *lvb = &oinfo->loi_lvb; if (valid & CAT_SIZE) lvb->lvb_size = attr->cat_size; @@ -188,7 +188,7 @@ static int osc_object_glimpse(const struct lu_env *env, { struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo; - lvb->lvb_size = oinfo->loi_kms; + lvb->lvb_size = oinfo->loi_kms; lvb->lvb_blocks = oinfo->loi_lvb.lvb_blocks; return 0; } @@ -208,9 +208,9 @@ void osc_object_clear_contended(struct osc_object *obj) int osc_object_is_contended(struct osc_object *obj) { - struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev); + struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev); int osc_contention_time = dev->od_contention_time; - unsigned long cur_time = cfs_time_current(); + unsigned long cur_time = cfs_time_current(); unsigned long retry_time; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION)) @@ -255,7 +255,7 @@ struct lu_object *osc_object_alloc(const struct lu_env *env, struct lu_device *dev) { struct osc_object *osc; - struct lu_object *obj; + struct lu_object *obj; OBD_SLAB_ALLOC_PTR_GFP(osc, osc_object_kmem, GFP_NOFS); if (osc != NULL) { diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 76ba58b09c5d..43dfa73dd3a6 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -216,7 +216,7 @@ static int osc_page_cache_add(const struct lu_env *env, const struct cl_page_slice *slice, struct cl_io *io) { - struct osc_io *oio = osc_env_io(env); + struct osc_io *oio = osc_env_io(env); struct osc_page *opg = cl2osc_page(slice); int result; @@ -247,7 +247,7 @@ void osc_index2policy(ldlm_policy_data_t *policy, const struct cl_object *obj, { memset(policy, 0, sizeof(*policy)); policy->l_extent.start = cl_offset(obj, start); - policy->l_extent.end = cl_offset(obj, end + 1) - 1; + policy->l_extent.end = cl_offset(obj, end + 1) - 1; } static int osc_page_addref_lock(const struct lu_env *env, @@ -255,7 +255,7 @@ static int osc_page_addref_lock(const struct lu_env *env, struct cl_lock *lock) { struct osc_lock *olock; - int rc; + int rc; LASSERT(opg->ops_lock == NULL); @@ -274,7 +274,7 @@ static int osc_page_addref_lock(const struct lu_env *env, static void osc_page_putref_lock(const struct lu_env *env, struct osc_page *opg) { - struct cl_lock *lock = opg->ops_lock; + struct cl_lock *lock = opg->ops_lock; struct osc_lock *olock; LASSERT(lock != NULL); @@ -291,7 +291,7 @@ static int osc_page_is_under_lock(const struct lu_env *env, struct cl_io *unused) { struct cl_lock *lock; - int result = -ENODATA; + int result = -ENODATA; lock = cl_lock_at_page(env, slice->cpl_obj, slice->cpl_page, NULL, 1, 0); @@ -317,7 +317,7 @@ static void osc_page_completion_read(const struct lu_env *env, const struct cl_page_slice *slice, int ioret) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); if (likely(opg->ops_lock)) @@ -329,7 +329,7 @@ static void osc_page_completion_write(const struct lu_env *env, const struct cl_page_slice *slice, int ioret) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_object *obj = cl2osc(slice->cpl_obj); osc_lru_add(osc_cli(obj), opg); @@ -364,10 +364,10 @@ static int osc_page_print(const struct lu_env *env, const struct cl_page_slice *slice, void *cookie, lu_printer_t printer) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_async_page *oap = &opg->ops_oap; - struct osc_object *obj = cl2osc(slice->cpl_obj); - struct client_obd *cli = &osc_export(obj)->exp_obd->u.cli; + struct osc_object *obj = cl2osc(slice->cpl_obj); + struct client_obd *cli = &osc_export(obj)->exp_obd->u.cli; return (*printer)(env, cookie, LUSTRE_OSC_NAME "-page@%p: 1< %#x %d %u %s %s > 2< %llu %u %u %#x %#x | %p %p %p > 3< %s %p %d %lu %d > 4< %d %d %d %lu %s | %s %s %s %s > 5< %s %s %s %s | %d %s | %d %s %s>\n", opg, @@ -408,7 +408,7 @@ static int osc_page_print(const struct lu_env *env, static void osc_page_delete(const struct lu_env *env, const struct cl_page_slice *slice) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); int rc; @@ -437,13 +437,13 @@ static void osc_page_delete(const struct lu_env *env, void osc_page_clip(const struct lu_env *env, const struct cl_page_slice *slice, int from, int to) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_async_page *oap = &opg->ops_oap; LINVRNT(osc_page_protected(env, opg, CLM_READ, 0)); opg->ops_from = from; - opg->ops_to = to; + opg->ops_to = to; spin_lock(&oap->oap_lock); oap->oap_async_flags |= ASYNC_COUNT_STABLE; spin_unlock(&oap->oap_lock); @@ -502,11 +502,11 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj, struct cl_page *page, struct page *vmpage) { struct osc_object *osc = cl2osc(obj); - struct osc_page *opg = cl_object_page_slice(obj, page); + struct osc_page *opg = cl_object_page_slice(obj, page); int result; opg->ops_from = 0; - opg->ops_to = PAGE_CACHE_SIZE; + opg->ops_to = PAGE_CACHE_SIZE; result = osc_prep_async_page(osc, opg, vmpage, cl_offset(obj, page->cp_index)); @@ -540,7 +540,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, enum cl_req_type crt, int brw_flags) { struct osc_async_page *oap = &opg->ops_oap; - struct osc_object *obj = oap->oap_obj; + struct osc_object *obj = oap->oap_obj; LINVRNT(osc_page_protected(env, opg, crt == CRT_WRITE ? CLM_WRITE : CLM_READ, 1)); @@ -550,9 +550,9 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, LASSERT(oap->oap_async_flags & ASYNC_READY); LASSERT(oap->oap_async_flags & ASYNC_COUNT_STABLE); - oap->oap_cmd = crt == CRT_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ; - oap->oap_page_off = opg->ops_from; - oap->oap_count = opg->ops_to - opg->ops_from; + oap->oap_cmd = crt == CRT_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ; + oap->oap_page_off = opg->ops_from; + oap->oap_count = opg->ops_to - opg->ops_from; oap->oap_brw_flags = OBD_BRW_SYNC | brw_flags; if (!client_is_remote(osc_export(obj)) && diff --git a/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c index 6690f149a04c..2ff253f458f8 100644 --- a/drivers/staging/lustre/lustre/osc/osc_quota.c +++ b/drivers/staging/lustre/lustre/osc/osc_quota.c @@ -232,7 +232,7 @@ int osc_quota_setup(struct obd_device *obd) int osc_quota_cleanup(struct obd_device *obd) { - struct client_obd *cli = &obd->u.cli; + struct client_obd *cli = &obd->u.cli; int type; for (type = 0; type < MAXQUOTAS; type++) @@ -245,8 +245,8 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp, struct obd_quotactl *oqctl) { struct ptlrpc_request *req; - struct obd_quotactl *oqc; - int rc; + struct obd_quotactl *oqc; + int rc; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_OST_QUOTACTL, LUSTRE_OST_VERSION, @@ -285,10 +285,10 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp, int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, struct obd_quotactl *oqctl) { - struct client_obd *cli = &exp->exp_obd->u.cli; - struct ptlrpc_request *req; - struct obd_quotactl *body; - int rc; + struct client_obd *cli = &exp->exp_obd->u.cli; + struct ptlrpc_request *req; + struct obd_quotactl *body; + int rc; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_OST_QUOTACHECK, LUSTRE_OST_VERSION, diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index d7a9b650df09..f84b4c78a8a0 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -110,7 +110,7 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, return lmm_size; if (*lmmp != NULL && lsm == NULL) { - OBD_FREE(*lmmp, lmm_size); + kfree(*lmmp); *lmmp = NULL; return 0; } else if (unlikely(lsm != NULL && ostid_id(&lsm->lsm_oi) == 0)) { @@ -118,7 +118,7 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, } if (*lmmp == NULL) { - OBD_ALLOC(*lmmp, lmm_size); + *lmmp = kzalloc(lmm_size, GFP_NOFS); if (*lmmp == NULL) return -ENOMEM; } @@ -157,19 +157,20 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, return lsm_size; if (*lsmp != NULL && lmm == NULL) { - OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); - OBD_FREE(*lsmp, lsm_size); + kfree((*lsmp)->lsm_oinfo[0]); + kfree(*lsmp); *lsmp = NULL; return 0; } if (*lsmp == NULL) { - OBD_ALLOC(*lsmp, lsm_size); + *lsmp = kzalloc(lsm_size, GFP_NOFS); if (unlikely(*lsmp == NULL)) return -ENOMEM; - OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); + (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), + GFP_NOFS); if (unlikely((*lsmp)->lsm_oinfo[0] == NULL)) { - OBD_FREE(*lsmp, lsm_size); + kfree(*lsmp); return -ENOMEM; } loi_init((*lsmp)->lsm_oinfo[0]); @@ -263,7 +264,7 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, { struct ptlrpc_request *req; struct osc_async_args *aa; - int rc; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) @@ -293,8 +294,8 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, struct obd_info *oinfo) { struct ptlrpc_request *req; - struct ost_body *body; - int rc; + struct ost_body *body; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) @@ -337,8 +338,8 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, struct obd_info *oinfo, struct obd_trans_info *oti) { struct ptlrpc_request *req; - struct ost_body *body; - int rc; + struct ost_body *body; + int rc; LASSERT(oinfo->oi_oa->o_valid & OBD_MD_FLGROUP); @@ -402,9 +403,9 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, obd_enqueue_update_f upcall, void *cookie, struct ptlrpc_request_set *rqset) { - struct ptlrpc_request *req; + struct ptlrpc_request *req; struct osc_setattr_args *sa; - int rc; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR); if (req == NULL) @@ -459,9 +460,9 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md **ea, struct obd_trans_info *oti) { struct ptlrpc_request *req; - struct ost_body *body; - struct lov_stripe_md *lsm; - int rc; + struct ost_body *body; + struct lov_stripe_md *lsm; + int rc; LASSERT(oa); LASSERT(ea); @@ -547,10 +548,10 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, obd_enqueue_update_f upcall, void *cookie, struct ptlrpc_request_set *rqset) { - struct ptlrpc_request *req; + struct ptlrpc_request *req; struct osc_setattr_args *sa; - struct ost_body *body; - int rc; + struct ost_body *body; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_PUNCH); if (req == NULL) @@ -576,7 +577,7 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret; CLASSERT (sizeof(*sa) <= sizeof(req->rq_async_args)); sa = ptlrpc_req_async_args(req); - sa->sa_oa = oinfo->oi_oa; + sa->sa_oa = oinfo->oi_oa; sa->sa_upcall = upcall; sa->sa_cookie = cookie; if (rqset == PTLRPCD_SET) @@ -615,9 +616,9 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, struct ptlrpc_request_set *rqset) { struct ptlrpc_request *req; - struct ost_body *body; + struct ost_body *body; struct osc_fsync_args *fa; - int rc; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SYNC); if (req == NULL) @@ -756,9 +757,9 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, struct obd_trans_info *oti, struct obd_export *md_export, void *capa) { - struct client_obd *cli = &exp->exp_obd->u.cli; + struct client_obd *cli = &exp->exp_obd->u.cli; struct ptlrpc_request *req; - struct ost_body *body; + struct ost_body *body; LIST_HEAD(cancels); int rc, count; @@ -946,7 +947,7 @@ static int osc_shrink_grant(struct client_obd *cli) int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) { - int rc = 0; + int rc = 0; struct ost_body *body; client_obd_list_lock(&cli->cl_loi_list_lock); @@ -962,7 +963,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) } client_obd_list_unlock(&cli->cl_loi_list_lock); - OBD_ALLOC_PTR(body); + body = kzalloc(sizeof(*body), GFP_NOFS); if (!body) return -ENOMEM; @@ -984,7 +985,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) sizeof(*body), body, NULL); if (rc != 0) __osc_update_grant(cli, body->oa.o_grant); - OBD_FREE_PTR(body); + kfree(body); return rc; } @@ -1006,8 +1007,8 @@ static int osc_should_shrink_grant(struct client_obd *client) if (client->cl_import->imp_state == LUSTRE_IMP_FULL && client->cl_avail_grant > brw_size) return 1; - else - osc_update_next_shrink(client); + + osc_update_next_shrink(client); } return 0; } @@ -1130,8 +1131,8 @@ static int check_write_rcs(struct ptlrpc_request *req, int requested_nob, int niocount, u32 page_count, struct brw_page **pga) { - int i; - __u32 *remote_rcs; + int i; + __u32 *remote_rcs; remote_rcs = req_capsule_server_sized_get(&req->rq_pill, &RMF_RCS, sizeof(*remote_rcs) * @@ -1181,15 +1182,15 @@ static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2) } static u32 osc_checksum_bulk(int nob, u32 pg_count, - struct brw_page **pga, int opc, - cksum_type_t cksum_type) + struct brw_page **pga, int opc, + cksum_type_t cksum_type) { - __u32 cksum; - int i = 0; - struct cfs_crypto_hash_desc *hdesc; - unsigned int bufsize; - int err; - unsigned char cfs_alg = cksum_obd2cfs(cksum_type); + __u32 cksum; + int i = 0; + struct cfs_crypto_hash_desc *hdesc; + unsigned int bufsize; + int err; + unsigned char cfs_alg = cksum_obd2cfs(cksum_type); LASSERT(pg_count > 0); @@ -1249,14 +1250,14 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, struct obd_capa *ocapa, int reserve, int resend) { - struct ptlrpc_request *req; + struct ptlrpc_request *req; struct ptlrpc_bulk_desc *desc; - struct ost_body *body; - struct obd_ioobj *ioobj; - struct niobuf_remote *niobuf; + struct ost_body *body; + struct obd_ioobj *ioobj; + struct niobuf_remote *niobuf; int niocount, i, requested_nob, opc, rc; struct osc_brw_async_args *aa; - struct req_capsule *pill; + struct req_capsule *pill; struct brw_page *pg_prev; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_BRW_PREP_REQ)) @@ -1358,8 +1359,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, niobuf->len += pg->count; } else { niobuf->offset = pg->off; - niobuf->len = pg->count; - niobuf->flags = pg->flag; + niobuf->len = pg->count; + niobuf->flags = pg->flag; } pg_prev = pg; } @@ -1580,9 +1581,9 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if (body->oa.o_valid & OBD_MD_FLCKSUM) { static int cksum_counter; - __u32 server_cksum = body->oa.o_cksum; - char *via; - char *router; + __u32 server_cksum = body->oa.o_cksum; + char *via; + char *router; cksum_type_t cksum_type; cksum_type = cksum_type_unpack(body->oa.o_valid &OBD_MD_FLFLAGS? @@ -1748,7 +1749,7 @@ static void sort_brw_pages(struct brw_page **array, int num) static void osc_release_ppga(struct brw_page **ppga, u32 count) { LASSERT(ppga != NULL); - OBD_FREE(ppga, sizeof(*ppga) * count); + kfree(ppga); } static int brw_interpret(const struct lu_env *env, @@ -1757,7 +1758,7 @@ static int brw_interpret(const struct lu_env *env, struct osc_brw_async_args *aa = data; struct osc_extent *ext; struct osc_extent *tmp; - struct cl_object *obj = NULL; + struct cl_object *obj = NULL; struct client_obd *cli = aa->aa_cli; rc = osc_brw_fini_request(req, rc); @@ -1861,26 +1862,25 @@ static int brw_interpret(const struct lu_env *env, int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, struct list_head *ext_list, int cmd, pdl_policy_t pol) { - struct ptlrpc_request *req = NULL; - struct osc_extent *ext; - struct brw_page **pga = NULL; - struct osc_brw_async_args *aa = NULL; - struct obdo *oa = NULL; - struct osc_async_page *oap; - struct osc_async_page *tmp; - struct cl_req *clerq = NULL; - enum cl_req_type crt = (cmd & OBD_BRW_WRITE) ? CRT_WRITE : - CRT_READ; - struct ldlm_lock *lock = NULL; - struct cl_req_attr *crattr = NULL; - u64 starting_offset = OBD_OBJECT_EOF; - u64 ending_offset = 0; - int mpflag = 0; - int mem_tight = 0; - int page_count = 0; - int i; - int rc; - struct ost_body *body; + struct ptlrpc_request *req = NULL; + struct osc_extent *ext; + struct brw_page **pga = NULL; + struct osc_brw_async_args *aa = NULL; + struct obdo *oa = NULL; + struct osc_async_page *oap; + struct osc_async_page *tmp; + struct cl_req *clerq = NULL; + enum cl_req_type crt = (cmd & OBD_BRW_WRITE) ? CRT_WRITE : CRT_READ; + struct ldlm_lock *lock = NULL; + struct cl_req_attr *crattr = NULL; + u64 starting_offset = OBD_OBJECT_EOF; + u64 ending_offset = 0; + int mpflag = 0; + int mem_tight = 0; + int page_count = 0; + int i; + int rc; + struct ost_body *body; LIST_HEAD(rpc_list); LASSERT(!list_empty(ext_list)); @@ -1908,13 +1908,13 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, if (mem_tight) mpflag = cfs_memory_pressure_get_and_set(); - OBD_ALLOC(crattr, sizeof(*crattr)); + crattr = kzalloc(sizeof(*crattr), GFP_NOFS); if (crattr == NULL) { rc = -ENOMEM; goto out; } - OBD_ALLOC(pga, sizeof(*pga) * page_count); + pga = kcalloc(page_count, sizeof(*pga), GFP_NOFS); if (pga == NULL) { rc = -ENOMEM; goto out; @@ -2055,7 +2055,7 @@ out: if (crattr != NULL) { capa_put(crattr->cra_capa); - OBD_FREE(crattr, sizeof(*crattr)); + kfree(crattr); } if (rc != 0) { @@ -2063,8 +2063,7 @@ out: if (oa) OBDO_FREE(oa); - if (pga) - OBD_FREE(pga, sizeof(*pga) * page_count); + kfree(pga); /* this should happen rarely and is pretty bad, it makes the * pending list not follow the dirty order */ while (!list_empty(ext_list)) { @@ -2300,7 +2299,9 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, ldlm_lock_decref(lockh, mode); LDLM_LOCK_PUT(matched); return -ECANCELED; - } else if (osc_set_lock_data_with_check(matched, einfo)) { + } + + if (osc_set_lock_data_with_check(matched, einfo)) { *flags |= LDLM_FL_LVB_READY; /* addref the lock only if not async requests and PW * lock is matched whereas we asked for PR. */ @@ -2325,10 +2326,10 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, ldlm_lock_decref(lockh, einfo->ei_mode); LDLM_LOCK_PUT(matched); return ELDLM_OK; - } else { - ldlm_lock_decref(lockh, mode); - LDLM_LOCK_PUT(matched); } + + ldlm_lock_decref(lockh, mode); + LDLM_LOCK_PUT(matched); } no_match: @@ -2480,10 +2481,10 @@ static int osc_statfs_async(struct obd_export *exp, struct obd_info *oinfo, __u64 max_age, struct ptlrpc_request_set *rqset) { - struct obd_device *obd = class_exp2obd(exp); + struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req; struct osc_async_args *aa; - int rc; + int rc; /* We could possibly pass max_age in the request (as an absolute * timestamp or a "seconds.usec ago") so the target can avoid doing @@ -2522,10 +2523,10 @@ static int osc_statfs_async(struct obd_export *exp, static int osc_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *osfs, __u64 max_age, __u32 flags) { - struct obd_device *obd = class_exp2obd(exp); - struct obd_statfs *msfs; + struct obd_device *obd = class_exp2obd(exp); + struct obd_statfs *msfs; struct ptlrpc_request *req; - struct obd_import *imp = NULL; + struct obd_import *imp = NULL; int rc; /*Since the request might also come from lprocfs, so we need @@ -2617,7 +2618,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) * because lov_user_md_vX and lov_mds_md_vX have the same size */ if (lum.lmm_stripe_count > 0) { lum_size = lov_mds_md_size(lum.lmm_stripe_count, lum.lmm_magic); - OBD_ALLOC(lumk, lum_size); + lumk = kzalloc(lum_size, GFP_NOFS); if (!lumk) return -ENOMEM; @@ -2639,7 +2640,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) rc = -EFAULT; if (lumk != &lum) - OBD_FREE(lumk, lum_size); + kfree(lumk); return rc; } @@ -2749,9 +2750,9 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, return 0; } else if (KEY_IS(KEY_LAST_ID)) { struct ptlrpc_request *req; - u64 *reply; - char *tmp; - int rc; + u64 *reply; + char *tmp; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GET_INFO_LAST_ID); @@ -2788,14 +2789,14 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, } else if (KEY_IS(KEY_FIEMAP)) { struct ll_fiemap_info_key *fm_key = (struct ll_fiemap_info_key *)key; - struct ldlm_res_id res_id; - ldlm_policy_data_t policy; - struct lustre_handle lockh; - ldlm_mode_t mode = 0; - struct ptlrpc_request *req; - struct ll_user_fiemap *reply; - char *tmp; - int rc; + struct ldlm_res_id res_id; + ldlm_policy_data_t policy; + struct lustre_handle lockh; + ldlm_mode_t mode = 0; + struct ptlrpc_request *req; + struct ll_user_fiemap *reply; + char *tmp; + int rc; if (!(fm_key->fiemap.fm_flags & FIEMAP_FLAG_SYNC)) goto skip_locking; @@ -2881,10 +2882,10 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, void *val, struct ptlrpc_request_set *set) { struct ptlrpc_request *req; - struct obd_device *obd = exp->exp_obd; - struct obd_import *imp = class_exp2cliimp(exp); - char *tmp; - int rc; + struct obd_device *obd = exp->exp_obd; + struct obd_import *imp = class_exp2cliimp(exp); + char *tmp; + int rc; OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_SHUTDOWN, 10); @@ -3071,8 +3072,8 @@ static int osc_import_event(struct obd_device *obd, } case IMP_EVENT_INVALIDATE: { struct ldlm_namespace *ns = obd->obd_namespace; - struct lu_env *env; - int refcheck; + struct lu_env *env; + int refcheck; env = cl_env_get(&refcheck); if (!IS_ERR(env)) { @@ -3159,9 +3160,9 @@ static int brw_queue_work(const struct lu_env *env, void *data) int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { struct lprocfs_static_vars lvars = { NULL }; - struct client_obd *cli = &obd->u.cli; - void *handler; - int rc; + struct client_obd *cli = &obd->u.cli; + void *handler; + int rc; rc = ptlrpcd_addref(); if (rc) @@ -3184,7 +3185,7 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL; lprocfs_osc_init_vars(&lvars); - if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0) { + if (lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars) == 0) { lproc_osc_attach_seqstat(obd); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); @@ -3351,7 +3352,7 @@ static int __init osc_init(void) lprocfs_osc_init_vars(&lvars); - rc = class_register_type(&osc_obd_ops, NULL, lvars.module_vars, + rc = class_register_type(&osc_obd_ops, NULL, LUSTRE_OSC_NAME, &osc_device_type); if (rc) { lu_kmem_fini(osc_caches); diff --git a/drivers/staging/lustre/lustre/ptlrpc/Makefile b/drivers/staging/lustre/lustre/ptlrpc/Makefile index fb50cd4c65b6..24bbac19ddd1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/Makefile +++ b/drivers/staging/lustre/lustre/ptlrpc/Makefile @@ -15,6 +15,5 @@ ptlrpc_objs += pers.o lproc_ptlrpc.o wiretest.o layout.o ptlrpc_objs += sec.o sec_bulk.o sec_gc.o sec_config.o ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o -ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs) -ptlrpc-$(CONFIG_PROC_FS) += sec_lproc.o +ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs) sec_lproc.o ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.o diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 0357f1d4532f..a12cd66b2365 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -57,8 +57,8 @@ void ptlrpc_init_client(int req_portal, int rep_portal, char *name, struct ptlrpc_client *cl) { cl->cli_request_portal = req_portal; - cl->cli_reply_portal = rep_portal; - cl->cli_name = name; + cl->cli_reply_portal = rep_portal; + cl->cli_name = name; } EXPORT_SYMBOL(ptlrpc_init_client); @@ -68,9 +68,9 @@ EXPORT_SYMBOL(ptlrpc_init_client); struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid) { struct ptlrpc_connection *c; - lnet_nid_t self; - lnet_process_id_t peer; - int err; + lnet_nid_t self; + lnet_process_id_t peer; + int err; /* ptlrpc_uuid_to_peer() initializes its 2nd parameter * before accessing its values. */ @@ -103,7 +103,8 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned npages, unsigned max_brw, struct ptlrpc_bulk_desc *desc; int i; - OBD_ALLOC(desc, offsetof(struct ptlrpc_bulk_desc, bd_iov[npages])); + desc = kzalloc(offsetof(struct ptlrpc_bulk_desc, bd_iov[npages]), + GFP_NOFS); if (!desc) return NULL; @@ -147,7 +148,7 @@ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req, desc->bd_import = class_import_get(imp); desc->bd_req = req; - desc->bd_cbid.cbid_fn = client_bulk_callback; + desc->bd_cbid.cbid_fn = client_bulk_callback; desc->bd_cbid.cbid_arg = desc; /* This makes req own desc, and free it when she frees herself */ @@ -205,8 +206,7 @@ void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin) page_cache_release(desc->bd_iov[i].kiov_page); } - OBD_FREE(desc, offsetof(struct ptlrpc_bulk_desc, - bd_iov[desc->bd_max_iov])); + kfree(desc); } EXPORT_SYMBOL(__ptlrpc_free_bulk); @@ -343,8 +343,8 @@ static int unpack_reply(struct ptlrpc_request *req) static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) { struct ptlrpc_request *early_req; - time_t olddl; - int rc; + time_t olddl; + int rc; req->rq_early = 0; spin_unlock(&req->rq_lock); @@ -390,7 +390,7 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) return rc; } -struct kmem_cache *request_cache; +static struct kmem_cache *request_cache; int ptlrpc_request_cache_init(void) { @@ -435,11 +435,11 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool) list_del(&req->rq_list); LASSERT(req->rq_reqbuf); LASSERT(req->rq_reqbuf_len == pool->prp_rq_size); - OBD_FREE_LARGE(req->rq_reqbuf, pool->prp_rq_size); + kvfree(req->rq_reqbuf); ptlrpc_request_cache_free(req); } spin_unlock(&pool->prp_lock); - OBD_FREE(pool, sizeof(*pool)); + kfree(pool); } EXPORT_SYMBOL(ptlrpc_free_rq_pool); @@ -469,7 +469,7 @@ void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq) req = ptlrpc_request_cache_alloc(GFP_NOFS); if (!req) return; - OBD_ALLOC_LARGE(msg, size); + msg = libcfs_kvzalloc(size, GFP_NOFS); if (!msg) { ptlrpc_request_cache_free(req); return; @@ -498,7 +498,7 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize, { struct ptlrpc_request_pool *pool; - OBD_ALLOC(pool, sizeof(struct ptlrpc_request_pool)); + pool = kzalloc(sizeof(struct ptlrpc_request_pool), GFP_NOFS); if (!pool) return NULL; @@ -514,7 +514,7 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize, if (list_empty(&pool->prp_req_list)) { /* have not allocated a single request for the pool */ - OBD_FREE(pool, sizeof(struct ptlrpc_request_pool)); + kfree(pool); pool = NULL; } return pool; @@ -580,8 +580,8 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, int count, __u32 *lengths, char **bufs, struct ptlrpc_cli_ctx *ctx) { - struct obd_import *imp = request->rq_import; - int rc; + struct obd_import *imp = request->rq_import; + int rc; if (unlikely(ctx)) request->rq_cli_ctx = sptlrpc_cli_ctx_get(ctx); @@ -605,10 +605,10 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, request->rq_type = PTL_RPC_MSG_REQUEST; request->rq_export = NULL; - request->rq_req_cbid.cbid_fn = request_out_callback; + request->rq_req_cbid.cbid_fn = request_out_callback; request->rq_req_cbid.cbid_arg = request; - request->rq_reply_cbid.cbid_fn = reply_in_callback; + request->rq_reply_cbid.cbid_fn = reply_in_callback; request->rq_reply_cbid.cbid_arg = request; request->rq_reply_deadline = 0; @@ -761,8 +761,8 @@ EXPORT_SYMBOL(ptlrpc_request_alloc); * initialize its buffer structure according to capsule template \a format. */ struct ptlrpc_request *ptlrpc_request_alloc_pool(struct obd_import *imp, - struct ptlrpc_request_pool *pool, - const struct req_format *format) + struct ptlrpc_request_pool *pool, + const struct req_format *format) { return ptlrpc_request_alloc_internal(imp, pool, format); } @@ -789,11 +789,11 @@ EXPORT_SYMBOL(ptlrpc_request_free); * Returns allocated request or NULL on error. */ struct ptlrpc_request *ptlrpc_request_alloc_pack(struct obd_import *imp, - const struct req_format *format, - __u32 version, int opcode) + const struct req_format *format, + __u32 version, int opcode) { struct ptlrpc_request *req = ptlrpc_request_alloc(imp, format); - int rc; + int rc; if (req) { rc = ptlrpc_request_pack(req, version, opcode); @@ -820,7 +820,7 @@ ptlrpc_prep_req_pool(struct obd_import *imp, struct ptlrpc_request_pool *pool) { struct ptlrpc_request *request; - int rc; + int rc; request = __ptlrpc_request_alloc(imp, pool); if (!request) @@ -856,7 +856,7 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void) { struct ptlrpc_request_set *set; - OBD_ALLOC(set, sizeof(*set)); + set = kzalloc(sizeof(*set), GFP_NOFS); if (!set) return NULL; atomic_set(&set->set_refcount, 1); @@ -868,9 +868,9 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void) INIT_LIST_HEAD(&set->set_new_requests); INIT_LIST_HEAD(&set->set_cblist); set->set_max_inflight = UINT_MAX; - set->set_producer = NULL; + set->set_producer = NULL; set->set_producer_arg = NULL; - set->set_rc = 0; + set->set_rc = 0; return set; } @@ -894,9 +894,9 @@ struct ptlrpc_request_set *ptlrpc_prep_fcset(int max, set_producer_func func, if (!set) return NULL; - set->set_max_inflight = max; - set->set_producer = func; - set->set_producer_arg = arg; + set->set_max_inflight = max; + set->set_producer = func; + set->set_producer_arg = arg; return set; } @@ -912,10 +912,10 @@ EXPORT_SYMBOL(ptlrpc_prep_fcset); */ void ptlrpc_set_destroy(struct ptlrpc_request_set *set) { - struct list_head *tmp; - struct list_head *next; - int expected_phase; - int n = 0; + struct list_head *tmp; + struct list_head *next; + int expected_phase; + int n = 0; /* Requests on the set should either all be completed, or all be new */ expected_phase = (atomic_read(&set->set_remaining) == 0) ? @@ -970,7 +970,7 @@ int ptlrpc_set_add_cb(struct ptlrpc_request_set *set, { struct ptlrpc_set_cbdata *cbdata; - OBD_ALLOC_PTR(cbdata); + cbdata = kzalloc(sizeof(*cbdata), GFP_NOFS); if (cbdata == NULL) return -ENOMEM; @@ -1013,7 +1013,7 @@ EXPORT_SYMBOL(ptlrpc_set_add_req); * Currently only used for ptlrpcd. */ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc, - struct ptlrpc_request *req) + struct ptlrpc_request *req) { struct ptlrpc_request_set *set = pc->pc_set; int count, i; @@ -1400,7 +1400,7 @@ static int after_reply(struct ptlrpc_request *req) */ static int ptlrpc_send_new_req(struct ptlrpc_request *req) { - struct obd_import *imp = req->rq_import; + struct obd_import *imp = req->rq_import; int rc; LASSERT(req->rq_phase == RQ_PHASE_NEW); @@ -1669,7 +1669,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) continue; } - if (status != 0) { + if (status != 0) { req->rq_status = status; ptlrpc_rqphase_move(req, RQ_PHASE_INTERPRET); @@ -1969,8 +1969,8 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) int ptlrpc_expired_set(void *data) { struct ptlrpc_request_set *set = data; - struct list_head *tmp; - time_t now = get_seconds(); + struct list_head *tmp; + time_t now = get_seconds(); LASSERT(set != NULL); @@ -2052,11 +2052,11 @@ EXPORT_SYMBOL(ptlrpc_interrupted_set); */ int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) { - struct list_head *tmp; - time_t now = get_seconds(); - int timeout = 0; + struct list_head *tmp; + time_t now = get_seconds(); + int timeout = 0; struct ptlrpc_request *req; - int deadline; + int deadline; list_for_each(tmp, &set->set_requests) { req = list_entry(tmp, struct ptlrpc_request, rq_set_chain); @@ -2105,10 +2105,10 @@ EXPORT_SYMBOL(ptlrpc_set_next_timeout); */ int ptlrpc_set_wait(struct ptlrpc_request_set *set) { - struct list_head *tmp; + struct list_head *tmp; struct ptlrpc_request *req; - struct l_wait_info lwi; - int rc, timeout; + struct l_wait_info lwi; + int rc, timeout; if (set->set_producer) (void)ptlrpc_set_producer(set); @@ -2214,7 +2214,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) err = cbdata->psc_interpret(set, cbdata->psc_data, rc); if (err && !rc) rc = err; - OBD_FREE_PTR(cbdata); + kfree(cbdata); } } @@ -2353,8 +2353,8 @@ EXPORT_SYMBOL(ptlrpc_req_xid); */ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) { - int rc; - wait_queue_head_t *wq; + int rc; + wait_queue_head_t *wq; struct l_wait_info lwi; /* @@ -2471,7 +2471,7 @@ void ptlrpc_free_committed(struct obd_import *imp) { struct ptlrpc_request *req, *saved; struct ptlrpc_request *last_req = NULL; /* temporary fire escape */ - bool skip_committed_list = true; + bool skip_committed_list = true; LASSERT(imp != NULL); assert_spin_locked(&imp->imp_lock); @@ -3023,8 +3023,8 @@ EXPORT_SYMBOL(ptlrpc_sample_next_xid); * have delay before it really runs by ptlrpcd thread. */ struct ptlrpc_work_async_args { - int (*cb)(const struct lu_env *, void *); - void *cbdata; + int (*cb)(const struct lu_env *, void *); + void *cbdata; }; static void ptlrpcd_add_work_req(struct ptlrpc_request *req) @@ -3113,7 +3113,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, CLASSERT(sizeof(*args) <= sizeof(req->rq_async_args)); args = ptlrpc_req_async_args(req); - args->cb = cb; + args->cb = cb; args->cbdata = cbdata; return req; diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index 7e27397ce384..ffe36e22245f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -54,7 +54,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, if (conn) goto out; - OBD_ALLOC_PTR(conn); + conn = kzalloc(sizeof(*conn), GFP_NOFS); if (!conn) return NULL; @@ -76,7 +76,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, /* coverity[overrun-buffer-val] */ conn2 = cfs_hash_findadd_unique(conn_hash, &peer, &conn->c_hash); if (conn != conn2) { - OBD_FREE_PTR(conn); + kfree(conn); conn = conn2; } out: @@ -227,7 +227,7 @@ conn_exit(struct cfs_hash *hs, struct hlist_node *hnode) LASSERTF(atomic_read(&conn->c_refcount) == 0, "Busy connection with %d refs\n", atomic_read(&conn->c_refcount)); - OBD_FREE_PTR(conn); + kfree(conn); } static cfs_hash_ops_t conn_hash_ops = { diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index 7f8644e01112..8cb1929fd31d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -53,7 +53,7 @@ lnet_handle_eq_t ptlrpc_eq_h; */ void request_out_callback(lnet_event_t *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; LASSERT(ev->type == LNET_EVENT_SEND || @@ -86,7 +86,7 @@ void request_out_callback(lnet_event_t *ev) */ void reply_in_callback(lnet_event_t *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status); @@ -172,9 +172,9 @@ out_wake: */ void client_bulk_callback(lnet_event_t *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_bulk_desc *desc = cbid->cbid_arg; - struct ptlrpc_request *req; + struct ptlrpc_request *req; LASSERT((desc->bd_type == BULK_PUT_SINK && ev->type == LNET_EVENT_PUT) || @@ -245,9 +245,9 @@ void client_bulk_callback(lnet_event_t *ev) static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, struct ptlrpc_request *req) { - __u64 sec = req->rq_arrival_time.tv_sec; - __u32 usec = req->rq_arrival_time.tv_usec >> 4; /* usec / 16 */ - __u64 new_seq; + __u64 sec = req->rq_arrival_time.tv_sec; + __u32 usec = req->rq_arrival_time.tv_usec >> 4; /* usec / 16 */ + __u64 new_seq; /* set sequence ID for request and add it to history list, * it must be called with hold svcpt::scp_lock */ @@ -281,11 +281,11 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, */ void request_in_callback(lnet_event_t *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request_buffer_desc *rqbd = cbid->cbid_arg; - struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt; - struct ptlrpc_service *service = svcpt->scp_service; - struct ptlrpc_request *req; + struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt; + struct ptlrpc_service *service = svcpt->scp_service; + struct ptlrpc_request *req; LASSERT(ev->type == LNET_EVENT_PUT || ev->type == LNET_EVENT_UNLINK); @@ -380,7 +380,7 @@ void request_in_callback(lnet_event_t *ev) */ void reply_out_callback(lnet_event_t *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_reply_state *rs = cbid->cbid_arg; struct ptlrpc_service_part *svcpt = rs->rs_svcpt; @@ -433,17 +433,17 @@ static void ptlrpc_master_callback(lnet_event_t *ev) } int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, - lnet_process_id_t *peer, lnet_nid_t *self) + lnet_process_id_t *peer, lnet_nid_t *self) { - int best_dist = 0; - __u32 best_order = 0; - int count = 0; - int rc = -ENOENT; - int portals_compatibility; - int dist; - __u32 order; - lnet_nid_t dst_nid; - lnet_nid_t src_nid; + int best_dist = 0; + __u32 best_order = 0; + int count = 0; + int rc = -ENOENT; + int portals_compatibility; + int dist; + __u32 order; + lnet_nid_t dst_nid; + lnet_nid_t src_nid; portals_compatibility = LNetCtl(IOC_LIBCFS_PORTALS_COMPATIBILITY, NULL); @@ -487,10 +487,10 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, void ptlrpc_ni_fini(void) { - wait_queue_head_t waitq; - struct l_wait_info lwi; - int rc; - int retries; + wait_queue_head_t waitq; + struct l_wait_info lwi; + int rc; + int retries; /* Wait for the event queue to become idle since there may still be * messages in flight with pending events (i.e. the fire-and-forget @@ -523,7 +523,7 @@ void ptlrpc_ni_fini(void) lnet_pid_t ptl_get_pid(void) { - lnet_pid_t pid; + lnet_pid_t pid; pid = LUSTRE_SRV_LNET_PID; return pid; @@ -531,8 +531,8 @@ lnet_pid_t ptl_get_pid(void) int ptlrpc_ni_init(void) { - int rc; - lnet_pid_t pid; + int rc; + lnet_pid_t pid; pid = ptl_get_pid(); CDEBUG(D_NET, "My pid is: %x\n", pid); @@ -563,7 +563,7 @@ int ptlrpc_ni_init(void) int ptlrpc_init_portals(void) { - int rc = ptlrpc_ni_init(); + int rc = ptlrpc_ni_init(); if (rc != 0) { CERROR("network initialisation failed\n"); diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index d5fc689c008b..c9b8481dd384 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -119,7 +119,7 @@ int ptlrpc_init_import(struct obd_import *imp) spin_lock(&imp->imp_lock); imp->imp_generation++; - imp->imp_state = LUSTRE_IMP_NEW; + imp->imp_state = LUSTRE_IMP_NEW; spin_unlock(&imp->imp_lock); @@ -369,7 +369,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp) imp_unregistering)); } spin_unlock(&imp->imp_lock); - } + } } while (rc != 0); /* @@ -559,7 +559,7 @@ static int import_select_connection(struct obd_import *imp) ptlrpc_connection_put(imp->imp_connection); imp->imp_connection = ptlrpc_connection_addref(imp_conn->oic_conn); - dlmexp = class_conn2export(&imp->imp_dlm_handle); + dlmexp = class_conn2export(&imp->imp_dlm_handle); LASSERT(dlmexp != NULL); if (dlmexp->exp_connection) ptlrpc_connection_put(dlmexp->exp_connection); @@ -1490,7 +1490,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) INITIAL_CONNECT_TIMEOUT); IMPORT_SET_STATE(imp, LUSTRE_IMP_CONNECTING); - req->rq_send_state = LUSTRE_IMP_CONNECTING; + req->rq_send_state = LUSTRE_IMP_CONNECTING; ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); ptlrpc_req_finished(req); diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index a42335e26de9..d14c20008850 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -807,11 +807,11 @@ struct req_capsule; /* * Request fields. */ -#define DEFINE_MSGF(name, flags, size, swabber, dumper) { \ - .rmf_name = (name), \ - .rmf_flags = (flags), \ - .rmf_size = (size), \ - .rmf_swabber = (void (*)(void *))(swabber), \ +#define DEFINE_MSGF(name, flags, size, swabber, dumper) { \ + .rmf_name = (name), \ + .rmf_flags = (flags), \ + .rmf_size = (size), \ + .rmf_swabber = (void (*)(void *))(swabber), \ .rmf_dumper = (void (*)(void *))(dumper) \ } @@ -1164,25 +1164,25 @@ EXPORT_SYMBOL(RMF_SWAP_LAYOUTS); struct req_format { const char *rf_name; - int rf_idx; + int rf_idx; struct { - int nr; + int nr; const struct req_msg_field **d; } rf_fields[RCL_NR]; }; -#define DEFINE_REQ_FMT(name, client, client_nr, server, server_nr) { \ - .rf_name = name, \ - .rf_fields = { \ +#define DEFINE_REQ_FMT(name, client, client_nr, server, server_nr) { \ + .rf_name = name, \ + .rf_fields = { \ [RCL_CLIENT] = { \ .nr = client_nr, \ - .d = client \ - }, \ + .d = client \ + }, \ [RCL_SERVER] = { \ .nr = server_nr, \ - .d = server \ - } \ - } \ + .d = server \ + } \ + } \ } #define DEFINE_REQ_FMT0(name, client, server) \ @@ -1769,10 +1769,10 @@ EXPORT_SYMBOL(req_capsule_set); * field of a \a pill's \a rc_fmt's RMF's. */ int req_capsule_filled_sizes(struct req_capsule *pill, - enum req_location loc) + enum req_location loc) { const struct req_format *fmt = pill->rc_fmt; - int i; + int i; LASSERT(fmt != NULL); @@ -1806,8 +1806,8 @@ EXPORT_SYMBOL(req_capsule_filled_sizes); int req_capsule_server_pack(struct req_capsule *pill) { const struct req_format *fmt; - int count; - int rc; + int count; + int rc; LASSERT(pill->rc_loc == RCL_SERVER); fmt = pill->rc_fmt; @@ -1857,11 +1857,11 @@ swabber_dumper_helper(struct req_capsule *pill, int offset, void *value, int len, int dump, void (*swabber)(void *)) { - void *p; - int i; - int n; - int do_swab; - int inout = loc == RCL_CLIENT; + void *p; + int i; + int n; + int do_swab; + int inout = loc == RCL_CLIENT; swabber = swabber ?: field->rmf_swabber; @@ -1936,10 +1936,10 @@ static void *__req_capsule_get(struct req_capsule *pill, int dump) { const struct req_format *fmt; - struct lustre_msg *msg; - void *value; - int len; - int offset; + struct lustre_msg *msg; + void *value; + int len; + int offset; void *(*getter)(struct lustre_msg *m, int n, int minlen); @@ -2000,10 +2000,10 @@ static void *__req_capsule_get(struct req_capsule *pill, */ static void __req_capsule_dump(struct req_capsule *pill, enum req_location loc) { - const struct req_format *fmt; - const struct req_msg_field *field; - int len; - int i; + const struct req_format *fmt; + const struct req_msg_field *field; + int len; + int i; fmt = pill->rc_fmt; @@ -2350,9 +2350,9 @@ void req_capsule_shrink(struct req_capsule *pill, enum req_location loc) { const struct req_format *fmt; - struct lustre_msg *msg; - int len; - int offset; + struct lustre_msg *msg; + int len; + int offset; fmt = pill->rc_fmt; LASSERT(fmt != NULL); diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index e9baf5bbee3a..1c701e0a0bc7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -49,29 +49,29 @@ #include "../include/lustre_net.h" #include <linux/list.h> -#define LLOG_CLIENT_ENTRY(ctxt, imp) do { \ - mutex_lock(&ctxt->loc_mutex); \ - if (ctxt->loc_imp) { \ - imp = class_import_get(ctxt->loc_imp); \ - } else { \ - CERROR("ctxt->loc_imp == NULL for context idx %d." \ - "Unable to complete MDS/OSS recovery," \ - "but I'll try again next time. Not fatal.\n", \ - ctxt->loc_idx); \ - imp = NULL; \ - mutex_unlock(&ctxt->loc_mutex); \ - return (-EINVAL); \ - } \ - mutex_unlock(&ctxt->loc_mutex); \ +#define LLOG_CLIENT_ENTRY(ctxt, imp) do { \ + mutex_lock(&ctxt->loc_mutex); \ + if (ctxt->loc_imp) { \ + imp = class_import_get(ctxt->loc_imp); \ + } else { \ + CERROR("ctxt->loc_imp == NULL for context idx %d." \ + "Unable to complete MDS/OSS recovery," \ + "but I'll try again next time. Not fatal.\n", \ + ctxt->loc_idx); \ + imp = NULL; \ + mutex_unlock(&ctxt->loc_mutex); \ + return (-EINVAL); \ + } \ + mutex_unlock(&ctxt->loc_mutex); \ } while (0) -#define LLOG_CLIENT_EXIT(ctxt, imp) do { \ - mutex_lock(&ctxt->loc_mutex); \ - if (ctxt->loc_imp != imp) \ - CWARN("loc_imp has changed from %p to %p\n", \ - ctxt->loc_imp, imp); \ - class_import_put(imp); \ - mutex_unlock(&ctxt->loc_mutex); \ +#define LLOG_CLIENT_EXIT(ctxt, imp) do { \ + mutex_lock(&ctxt->loc_mutex); \ + if (ctxt->loc_imp != imp) \ + CWARN("loc_imp has changed from %p to %p\n", \ + ctxt->loc_imp, imp); \ + class_import_put(imp); \ + mutex_unlock(&ctxt->loc_mutex); \ } while (0) /* This is a callback from the llog_* functions. @@ -80,11 +80,11 @@ static int llog_client_open(const struct lu_env *env, struct llog_handle *lgh, struct llog_logid *logid, char *name, enum llog_open_param open_param) { - struct obd_import *imp; - struct llogd_body *body; - struct llog_ctxt *ctxt = lgh->lgh_ctxt; + struct obd_import *imp; + struct llogd_body *body; + struct llog_ctxt *ctxt = lgh->lgh_ctxt; struct ptlrpc_request *req = NULL; - int rc; + int rc; LLOG_CLIENT_ENTRY(ctxt, imp); @@ -145,10 +145,10 @@ out: static int llog_client_destroy(const struct lu_env *env, struct llog_handle *loghandle) { - struct obd_import *imp; + struct obd_import *imp; struct ptlrpc_request *req = NULL; - struct llogd_body *body; - int rc; + struct llogd_body *body; + int rc; LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_DESTROY, @@ -182,11 +182,11 @@ static int llog_client_next_block(const struct lu_env *env, int *cur_idx, int next_idx, __u64 *cur_offset, void *buf, int len) { - struct obd_import *imp; + struct obd_import *imp; struct ptlrpc_request *req = NULL; - struct llogd_body *body; - void *ptr; - int rc; + struct llogd_body *body; + void *ptr; + int rc; LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK, @@ -240,11 +240,11 @@ static int llog_client_prev_block(const struct lu_env *env, struct llog_handle *loghandle, int prev_idx, void *buf, int len) { - struct obd_import *imp; + struct obd_import *imp; struct ptlrpc_request *req = NULL; - struct llogd_body *body; - void *ptr; - int rc; + struct llogd_body *body; + void *ptr; + int rc; LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK, @@ -292,12 +292,12 @@ err_exit: static int llog_client_read_header(const struct lu_env *env, struct llog_handle *handle) { - struct obd_import *imp; + struct obd_import *imp; struct ptlrpc_request *req = NULL; - struct llogd_body *body; - struct llog_log_hdr *hdr; - struct llog_rec_hdr *llh_hdr; - int rc; + struct llogd_body *body; + struct llog_log_hdr *hdr; + struct llog_rec_hdr *llh_hdr; + int rc; LLOG_CLIENT_ENTRY(handle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_READ_HEADER, diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 9533ab976a33..aaaabbf5f1b9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -181,19 +181,19 @@ static const char *ll_eopcode2str(__u32 opcode) return ll_eopcode_table[opcode].opname; } -#if defined(CONFIG_PROC_FS) -static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir, - char *name, - struct proc_dir_entry **procroot_ret, - struct lprocfs_stats **stats_ret) +static void +ptlrpc_ldebugfs_register(struct dentry *root, char *dir, + char *name, + struct dentry **debugfs_root_ret, + struct lprocfs_stats **stats_ret) { - struct proc_dir_entry *svc_procroot; + struct dentry *svc_debugfs_entry; struct lprocfs_stats *svc_stats; int i, rc; unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV; - LASSERT(*procroot_ret == NULL); + LASSERT(*debugfs_root_ret == NULL); LASSERT(*stats_ret == NULL); svc_stats = lprocfs_alloc_stats(EXTRA_MAX_OPCODES+LUSTRE_MAX_OPCODES, @@ -201,14 +201,14 @@ static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir, if (svc_stats == NULL) return; - if (dir) { - svc_procroot = lprocfs_register(dir, root, NULL, NULL); - if (IS_ERR(svc_procroot)) { + if (dir != NULL) { + svc_debugfs_entry = ldebugfs_register(dir, root, NULL, NULL); + if (IS_ERR(svc_debugfs_entry)) { lprocfs_free_stats(&svc_stats); return; } } else { - svc_procroot = root; + svc_debugfs_entry = root; } lprocfs_counter_init(svc_stats, PTLRPC_REQWAIT_CNTR, @@ -244,14 +244,14 @@ static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir, ll_opcode2str(opcode), "usec"); } - rc = lprocfs_register_stats(svc_procroot, name, svc_stats); + rc = ldebugfs_register_stats(svc_debugfs_entry, name, svc_stats); if (rc < 0) { - if (dir) - lprocfs_remove(&svc_procroot); + if (dir != NULL) + ldebugfs_remove(&svc_debugfs_entry); lprocfs_free_stats(&svc_stats); } else { - if (dir) - *procroot_ret = svc_procroot; + if (dir != NULL) + *debugfs_root_ret = svc_debugfs_entry; *stats_ret = svc_stats; } } @@ -261,8 +261,8 @@ ptlrpc_lprocfs_req_history_len_seq_show(struct seq_file *m, void *v) { struct ptlrpc_service *svc = m->private; struct ptlrpc_service_part *svcpt; - int total = 0; - int i; + int total = 0; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) total += svcpt->scp_hist_nrqbds; @@ -277,8 +277,8 @@ ptlrpc_lprocfs_req_history_max_seq_show(struct seq_file *m, void *n) { struct ptlrpc_service *svc = m->private; struct ptlrpc_service_part *svcpt; - int total = 0; - int i; + int total = 0; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) total += svc->srv_hist_nrqbds_cpt_max; @@ -289,13 +289,13 @@ ptlrpc_lprocfs_req_history_max_seq_show(struct seq_file *m, void *n) static ssize_t ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) + const char __user *buffer, + size_t count, loff_t *off) { struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; - int bufpages; - int val; - int rc; + int bufpages; + int val; + int rc; rc = lprocfs_write_helper(buffer, count, &val); if (rc < 0) @@ -324,23 +324,23 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, } LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_history_max); -static int -ptlrpc_lprocfs_threads_min_seq_show(struct seq_file *m, void *n) + +static ssize_t threads_min_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ptlrpc_service *svc = m->private; + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); - seq_printf(m, "%d\n", svc->srv_nthrs_cpt_init * svc->srv_ncpts); - return 0; + return sprintf(buf, "%d\n", svc->srv_nthrs_cpt_init * svc->srv_ncpts); } -static ssize_t -ptlrpc_lprocfs_threads_min_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t threads_min_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; - int val; - int rc = lprocfs_write_helper(buffer, count, &val); + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + unsigned long val; + int rc = kstrtoul(buffer, 10, &val); if (rc < 0) return rc; @@ -360,41 +360,41 @@ ptlrpc_lprocfs_threads_min_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ptlrpc_lprocfs_threads_min); +LUSTRE_RW_ATTR(threads_min); -static int -ptlrpc_lprocfs_threads_started_seq_show(struct seq_file *m, void *n) +static ssize_t threads_started_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct ptlrpc_service *svc = m->private; + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); struct ptlrpc_service_part *svcpt; - int total = 0; - int i; + int total = 0; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) total += svcpt->scp_nthrs_running; - seq_printf(m, "%d\n", total); - return 0; + return sprintf(buf, "%d\n", total); } -LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_threads_started); +LUSTRE_RO_ATTR(threads_started); -static int -ptlrpc_lprocfs_threads_max_seq_show(struct seq_file *m, void *n) +static ssize_t threads_max_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ptlrpc_service *svc = m->private; + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); - seq_printf(m, "%d\n", svc->srv_nthrs_cpt_limit * svc->srv_ncpts); - return 0; + return sprintf(buf, "%d\n", svc->srv_nthrs_cpt_limit * svc->srv_ncpts); } -static ssize_t -ptlrpc_lprocfs_threads_max_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t threads_max_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; - int val; - int rc = lprocfs_write_helper(buffer, count, &val); + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + unsigned long val; + int rc = kstrtoul(buffer, 10, &val); if (rc < 0) return rc; @@ -414,7 +414,7 @@ ptlrpc_lprocfs_threads_max_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ptlrpc_lprocfs_threads_max); +LUSTRE_RW_ATTR(threads_max); /** * \addtogoup nrs @@ -478,17 +478,17 @@ void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy, */ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) { - struct ptlrpc_service *svc = m->private; - struct ptlrpc_service_part *svcpt; - struct ptlrpc_nrs *nrs; - struct ptlrpc_nrs_policy *policy; - struct ptlrpc_nrs_pol_info *infos; - struct ptlrpc_nrs_pol_info tmp; - unsigned num_pols; - unsigned pol_idx = 0; - bool hp = false; - int i; - int rc = 0; + struct ptlrpc_service *svc = m->private; + struct ptlrpc_service_part *svcpt; + struct ptlrpc_nrs *nrs; + struct ptlrpc_nrs_policy *policy; + struct ptlrpc_nrs_pol_info *infos; + struct ptlrpc_nrs_pol_info tmp; + unsigned num_pols; + unsigned pol_idx = 0; + bool hp = false; + int i; + int rc = 0; /** * Serialize NRS core lprocfs operations with policy registration/ @@ -507,10 +507,10 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) num_pols = svc->srv_parts[0]->scp_nrs_reg.nrs_num_pols; spin_unlock(&nrs->nrs_lock); - OBD_ALLOC(infos, num_pols * sizeof(*infos)); + infos = kcalloc(num_pols, sizeof(*infos), GFP_NOFS); if (infos == NULL) { rc = -ENOMEM; - goto out; + goto unlock; } again: @@ -617,10 +617,8 @@ again: goto again; } -out: - if (infos) - OBD_FREE(infos, num_pols * sizeof(*infos)); - + kfree(infos); +unlock: mutex_unlock(&nrs_core.nrs_mutex); return rc; @@ -640,26 +638,22 @@ out: * regular and high-priority (if the service has one) NRS head. */ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) + const char __user *buffer, + size_t count, loff_t *off) { struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; - enum ptlrpc_nrs_queue_type queue = PTLRPC_NRS_QUEUE_BOTH; - char *cmd; - char *cmd_copy = NULL; - char *token; - int rc = 0; + enum ptlrpc_nrs_queue_type queue = PTLRPC_NRS_QUEUE_BOTH; + char *cmd; + char *cmd_copy = NULL; + char *token; + int rc = 0; - if (count >= LPROCFS_NRS_WR_MAX_CMD) { - rc = -EINVAL; - goto out; - } + if (count >= LPROCFS_NRS_WR_MAX_CMD) + return -EINVAL; - OBD_ALLOC(cmd, LPROCFS_NRS_WR_MAX_CMD); - if (cmd == NULL) { - rc = -ENOMEM; - goto out; - } + cmd = kzalloc(LPROCFS_NRS_WR_MAX_CMD, GFP_NOFS); + if (cmd == NULL) + return -ENOMEM; /** * strsep() modifies its argument, so keep a copy */ @@ -716,8 +710,7 @@ default_queue: mutex_unlock(&nrs_core.nrs_mutex); out: - if (cmd_copy) - OBD_FREE(cmd_copy, LPROCFS_NRS_WR_MAX_CMD); + kfree(cmd_copy); return rc < 0 ? rc : count; } @@ -736,8 +729,8 @@ ptlrpc_lprocfs_svc_req_history_seek(struct ptlrpc_service_part *svcpt, struct ptlrpc_srh_iterator *srhi, __u64 seq) { - struct list_head *e; - struct ptlrpc_request *req; + struct list_head *e; + struct ptlrpc_request *req; if (srhi->srhi_req != NULL && srhi->srhi_seq > svcpt->scp_hist_seq_culled && @@ -825,7 +818,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos) return NULL; } - OBD_ALLOC(srhi, sizeof(*srhi)); + srhi = kzalloc(sizeof(*srhi), GFP_NOFS); if (srhi == NULL) return NULL; @@ -851,7 +844,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos) } } - OBD_FREE(srhi, sizeof(*srhi)); + kfree(srhi); return NULL; } @@ -860,20 +853,19 @@ ptlrpc_lprocfs_svc_req_history_stop(struct seq_file *s, void *iter) { struct ptlrpc_srh_iterator *srhi = iter; - if (srhi != NULL) - OBD_FREE(srhi, sizeof(*srhi)); + kfree(srhi); } static void * ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s, void *iter, loff_t *pos) { - struct ptlrpc_service *svc = s->private; - struct ptlrpc_srh_iterator *srhi = iter; - struct ptlrpc_service_part *svcpt; - __u64 seq; - int rc; - int i; + struct ptlrpc_service *svc = s->private; + struct ptlrpc_srh_iterator *srhi = iter; + struct ptlrpc_service_part *svcpt; + __u64 seq; + int rc; + int i; for (i = srhi->srhi_idx; i < svc->srv_ncpts; i++) { svcpt = svc->srv_parts[i]; @@ -895,7 +887,7 @@ ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s, } } - OBD_FREE(srhi, sizeof(*srhi)); + kfree(srhi); return NULL; } @@ -931,11 +923,11 @@ EXPORT_SYMBOL(target_print_req); static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter) { - struct ptlrpc_service *svc = s->private; - struct ptlrpc_srh_iterator *srhi = iter; - struct ptlrpc_service_part *svcpt; - struct ptlrpc_request *req; - int rc; + struct ptlrpc_service *svc = s->private; + struct ptlrpc_srh_iterator *srhi = iter; + struct ptlrpc_service_part *svcpt; + struct ptlrpc_request *req; + int rc; LASSERT(srhi->srhi_idx < svc->srv_ncpts); @@ -980,28 +972,28 @@ ptlrpc_lprocfs_svc_req_history_open(struct inode *inode, struct file *file) .next = ptlrpc_lprocfs_svc_req_history_next, .show = ptlrpc_lprocfs_svc_req_history_show, }; - struct seq_file *seqf; - int rc; + struct seq_file *seqf; + int rc; rc = seq_open(file, &sops); if (rc) return rc; seqf = file->private_data; - seqf->private = PDE_DATA(inode); + seqf->private = inode->i_private; return 0; } /* See also lprocfs_rd_timeouts */ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) { - struct ptlrpc_service *svc = m->private; - struct ptlrpc_service_part *svcpt; - struct dhms ts; - time_t worstt; - unsigned int cur; - unsigned int worst; - int i; + struct ptlrpc_service *svc = m->private; + struct ptlrpc_service_part *svcpt; + struct dhms ts; + time_t worstt; + unsigned int cur; + unsigned int worst; + int i; if (AT_OFF) { seq_printf(m, "adaptive timeouts off, using obd_timeout %u\n", @@ -1026,23 +1018,26 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) } LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_timeouts); -static int ptlrpc_lprocfs_hp_ratio_seq_show(struct seq_file *m, void *v) +static ssize_t high_priority_ratio_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct ptlrpc_service *svc = m->private; - seq_printf(m, "%d", svc->srv_hpreq_ratio); - return 0; + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + return sprintf(buf, "%d\n", svc->srv_hpreq_ratio); } -static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file, - const char __user *buffer, - size_t count, - loff_t *off) +static ssize_t high_priority_ratio_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; - int rc; - int val; + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + int rc; + int val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoint(buffer, 10, &val); if (rc < 0) return rc; @@ -1055,30 +1050,62 @@ static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ptlrpc_lprocfs_hp_ratio); +LUSTRE_RW_ATTR(high_priority_ratio); + +static struct attribute *ptlrpc_svc_attrs[] = { + &lustre_attr_threads_min.attr, + &lustre_attr_threads_started.attr, + &lustre_attr_threads_max.attr, + &lustre_attr_high_priority_ratio.attr, + NULL, +}; + +static void ptlrpc_sysfs_svc_release(struct kobject *kobj) +{ + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + + complete(&svc->srv_kobj_unregister); +} + +static struct kobj_type ptlrpc_svc_ktype = { + .default_attrs = ptlrpc_svc_attrs, + .sysfs_ops = &lustre_sysfs_ops, + .release = ptlrpc_sysfs_svc_release, +}; + +void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc) +{ + /* Let's see if we had a chance at initialization first */ + if (svc->srv_kobj.kset) { + kobject_put(&svc->srv_kobj); + wait_for_completion(&svc->srv_kobj_unregister); + } +} + +int ptlrpc_sysfs_register_service(struct kset *parent, + struct ptlrpc_service *svc) +{ + int rc; + + svc->srv_kobj.kset = parent; + init_completion(&svc->srv_kobj_unregister); + rc = kobject_init_and_add(&svc->srv_kobj, &ptlrpc_svc_ktype, NULL, + "%s", svc->srv_name); + + return rc; +} -void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry, - struct ptlrpc_service *svc) +void ptlrpc_ldebugfs_register_service(struct dentry *entry, + struct ptlrpc_service *svc) { struct lprocfs_vars lproc_vars[] = { - {.name = "high_priority_ratio", - .fops = &ptlrpc_lprocfs_hp_ratio_fops, - .data = svc}, {.name = "req_buffer_history_len", .fops = &ptlrpc_lprocfs_req_history_len_fops, .data = svc}, {.name = "req_buffer_history_max", .fops = &ptlrpc_lprocfs_req_history_max_fops, .data = svc}, - {.name = "threads_min", - .fops = &ptlrpc_lprocfs_threads_min_fops, - .data = svc}, - {.name = "threads_max", - .fops = &ptlrpc_lprocfs_threads_max_fops, - .data = svc}, - {.name = "threads_started", - .fops = &ptlrpc_lprocfs_threads_started_fops, - .data = svc}, {.name = "timeouts", .fops = &ptlrpc_lprocfs_timeouts_fops, .data = svc}, @@ -1097,26 +1124,26 @@ void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry, int rc; - ptlrpc_lprocfs_register(entry, svc->srv_name, - "stats", &svc->srv_procroot, - &svc->srv_stats); + ptlrpc_ldebugfs_register(entry, svc->srv_name, + "stats", &svc->srv_debugfs_entry, + &svc->srv_stats); - if (svc->srv_procroot == NULL) + if (svc->srv_debugfs_entry == NULL) return; - lprocfs_add_vars(svc->srv_procroot, lproc_vars, NULL); + ldebugfs_add_vars(svc->srv_debugfs_entry, lproc_vars, NULL); - rc = lprocfs_seq_create(svc->srv_procroot, "req_history", - 0400, &req_history_fops, svc); + rc = ldebugfs_seq_create(svc->srv_debugfs_entry, "req_history", + 0400, &req_history_fops, svc); if (rc) CWARN("Error adding the req_history file\n"); } void ptlrpc_lprocfs_register_obd(struct obd_device *obddev) { - ptlrpc_lprocfs_register(obddev->obd_proc_entry, NULL, "stats", - &obddev->obd_svc_procroot, - &obddev->obd_svc_stats); + ptlrpc_ldebugfs_register(obddev->obd_debugfs_entry, NULL, "stats", + &obddev->obd_svc_debugfs_entry, + &obddev->obd_svc_stats); } EXPORT_SYMBOL(ptlrpc_lprocfs_register_obd); @@ -1164,8 +1191,8 @@ EXPORT_SYMBOL(ptlrpc_lprocfs_brw); void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc) { - if (svc->srv_procroot != NULL) - lprocfs_remove(&svc->srv_procroot); + if (svc->srv_debugfs_entry != NULL) + ldebugfs_remove(&svc->srv_debugfs_entry); if (svc->srv_stats) lprocfs_free_stats(&svc->srv_stats); @@ -1173,8 +1200,8 @@ void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc) void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd) { - if (obd->obd_svc_procroot) - lprocfs_remove(&obd->obd_svc_procroot); + if (!IS_ERR_OR_NULL(obd->obd_svc_debugfs_entry)) + ldebugfs_remove(&obd->obd_svc_debugfs_entry); if (obd->obd_svc_stats) lprocfs_free_stats(&obd->obd_svc_stats); @@ -1188,10 +1215,10 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - char *kbuf; - char *tmpbuf; + char *kbuf; + char *tmpbuf; - OBD_ALLOC(kbuf, BUFLEN); + kbuf = kzalloc(BUFLEN, GFP_NOFS); if (kbuf == NULL) return -ENOMEM; @@ -1209,7 +1236,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer, /* Kludge code(deadlock situation): the lprocfs lock has been held * since the client is evicted by writing client's * uuid/nid to procfs "evict_client" entry. However, - * obd_export_evict_by_uuid() will call lprocfs_remove() to destroy + * obd_export_evict_by_uuid() will call ldebugfs_remove() to destroy * the proc entries under the being destroyed export{}, so I have * to drop the lock at first here. * - jay, jxiong@clusterfs.com */ @@ -1225,7 +1252,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer, class_decref(obd, __func__, current); out: - OBD_FREE(kbuf, BUFLEN); + kfree(kbuf); return count; } EXPORT_SYMBOL(lprocfs_wr_evict_client); @@ -1237,7 +1264,7 @@ int lprocfs_wr_ping(struct file *file, const char __user *buffer, { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; struct ptlrpc_request *req; - int rc; + int rc; LPROCFS_CLIMP_CHECK(obd); req = ptlrpc_prep_ping(obd->u.cli.cl_import); @@ -1275,7 +1302,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer, if (count > PAGE_CACHE_SIZE - 1 || count <= prefix_len) return -EINVAL; - OBD_ALLOC(kbuf, count + 1); + kbuf = kzalloc(count + 1, GFP_NOFS); if (kbuf == NULL) return -ENOMEM; @@ -1319,7 +1346,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer, ptlrpc_recover_import(imp, uuid, 1); out: - OBD_FREE(kbuf, count + 1); + kfree(kbuf); return count; } EXPORT_SYMBOL(lprocfs_wr_import); @@ -1362,5 +1389,3 @@ int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, } EXPORT_SYMBOL(lprocfs_wr_pinger_recov); - -#endif /* CONFIG_PROC_FS */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index 2fa2585584a3..92c746b44462 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -52,17 +52,17 @@ static int ptl_send_buf(lnet_handle_md_t *mdh, void *base, int len, struct ptlrpc_connection *conn, int portal, __u64 xid, unsigned int offset) { - int rc; - lnet_md_t md; + int rc; + lnet_md_t md; LASSERT(portal != 0); LASSERT(conn != NULL); CDEBUG(D_INFO, "conn=%p id %s\n", conn, libcfs_id2str(conn->c_peer)); - md.start = base; - md.length = len; + md.start = base; + md.length = len; md.threshold = (ack == LNET_ACK_REQ) ? 2 : 1; - md.options = PTLRPC_MD_OPTIONS; - md.user_ptr = cbid; + md.options = PTLRPC_MD_OPTIONS; + md.user_ptr = cbid; md.eq_handle = ptlrpc_eq_h; if (unlikely(ack == LNET_ACK_REQ && @@ -120,8 +120,8 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) int posted_md; int total_md; __u64 xid; - lnet_handle_me_t me_h; - lnet_md_t md; + lnet_handle_me_t me_h; + lnet_md_t md; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_BULK_GET_NET)) return 0; @@ -243,9 +243,9 @@ EXPORT_SYMBOL(ptlrpc_register_bulk); int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) { struct ptlrpc_bulk_desc *desc = req->rq_bulk; - wait_queue_head_t *wq; - struct l_wait_info lwi; - int rc; + wait_queue_head_t *wq; + struct l_wait_info lwi; + int rc; LASSERT(!in_interrupt()); /* might sleep */ @@ -301,8 +301,8 @@ EXPORT_SYMBOL(ptlrpc_unregister_bulk); static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags) { - struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; - struct ptlrpc_service *svc = svcpt->scp_service; + struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; + struct ptlrpc_service *svc = svcpt->scp_service; int service_time = max_t(int, get_seconds() - req->rq_arrival_time.tv_sec, 1); @@ -353,8 +353,8 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags) int ptlrpc_send_reply(struct ptlrpc_request *req, int flags) { struct ptlrpc_reply_state *rs = req->rq_reply_state; - struct ptlrpc_connection *conn; - int rc; + struct ptlrpc_connection *conn; + int rc; /* We must already have a reply buffer (only ptlrpc_error() may be * called without one). The reply generated by sptlrpc layer (e.g. @@ -491,8 +491,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) int rc2; int mpflag = 0; struct ptlrpc_connection *connection; - lnet_handle_me_t reply_me_h; - lnet_md_t reply_md; + lnet_handle_me_t reply_me_h; + lnet_md_t reply_md; struct obd_device *obd = request->rq_import->imp_obd; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_DROP_RPC)) @@ -594,15 +594,15 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) spin_unlock(&request->rq_lock); if (!noreply) { - reply_md.start = request->rq_repbuf; - reply_md.length = request->rq_repbuf_len; + reply_md.start = request->rq_repbuf; + reply_md.length = request->rq_repbuf_len; /* Allow multiple early replies */ reply_md.threshold = LNET_MD_THRESH_INF; /* Manage remote for early replies */ - reply_md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | + reply_md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | LNET_MD_MANAGE_REMOTE | LNET_MD_TRUNCATE; /* allow to make EOVERFLOW error */; - reply_md.user_ptr = &request->rq_reply_cbid; + reply_md.user_ptr = &request->rq_reply_cbid; reply_md.eq_handle = ptlrpc_eq_h; /* We must see the unlink callback to unset rq_reply_unlink, @@ -682,11 +682,11 @@ EXPORT_SYMBOL(ptl_send_rpc); */ int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd) { - struct ptlrpc_service *service = rqbd->rqbd_svcpt->scp_service; - static lnet_process_id_t match_id = {LNET_NID_ANY, LNET_PID_ANY}; - int rc; - lnet_md_t md; - lnet_handle_me_t me_h; + struct ptlrpc_service *service = rqbd->rqbd_svcpt->scp_service; + static lnet_process_id_t match_id = {LNET_NID_ANY, LNET_PID_ANY}; + int rc; + lnet_md_t md; + lnet_handle_me_t me_h; CDEBUG(D_NET, "LNetMEAttach: portal %d\n", service->srv_req_portal); @@ -709,12 +709,12 @@ int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd) LASSERT(rqbd->rqbd_refcount == 0); rqbd->rqbd_refcount = 1; - md.start = rqbd->rqbd_buffer; - md.length = service->srv_buf_size; - md.max_size = service->srv_max_req_size; + md.start = rqbd->rqbd_buffer; + md.length = service->srv_buf_size; + md.max_size = service->srv_max_req_size; md.threshold = LNET_MD_THRESH_INF; - md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | LNET_MD_MAX_SIZE; - md.user_ptr = &rqbd->rqbd_cbid; + md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | LNET_MD_MAX_SIZE; + md.user_ptr = &rqbd->rqbd_cbid; md.eq_handle = ptlrpc_eq_h; rc = LNetMDAttach(me_h, md, LNET_UNLINK, &rqbd->rqbd_md_h); diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 81ad7473242e..9516acadb7a1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -188,8 +188,8 @@ static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs) */ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) { - struct ptlrpc_nrs *nrs = policy->pol_nrs; - int rc = 0; + struct ptlrpc_nrs *nrs = policy->pol_nrs; + int rc = 0; /** * Don't allow multiple starting which is too complex, and has no real @@ -377,15 +377,15 @@ static void nrs_resource_put(struct ptlrpc_nrs_resource *res) */ static struct ptlrpc_nrs_resource *nrs_resource_get(struct ptlrpc_nrs_policy *policy, - struct ptlrpc_nrs_request *nrq, - bool moving_req) + struct ptlrpc_nrs_request *nrq, + bool moving_req) { /** * Set to NULL to traverse the resource hierarchy from the top. */ struct ptlrpc_nrs_resource *res = NULL; struct ptlrpc_nrs_resource *tmp = NULL; - int rc; + int rc; while (1) { rc = policy->pol_desc->pd_ops->op_res_get(policy, nrq, res, @@ -432,8 +432,8 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, struct ptlrpc_nrs_resource **resp, bool moving_req) { - struct ptlrpc_nrs_policy *primary = NULL; - struct ptlrpc_nrs_policy *fallback = NULL; + struct ptlrpc_nrs_policy *primary = NULL; + struct ptlrpc_nrs_policy *fallback = NULL; memset(resp, 0, sizeof(resp[0]) * NRS_RES_MAX); @@ -478,14 +478,14 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, * * \param resp the resource hierarchy that is being released * - * \see ptlrpcnrs_req_hp_move() + * \see ptlrpc_nrs_req_hp_move() * \see ptlrpc_nrs_req_finalize() */ static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp) { struct ptlrpc_nrs_policy *pols[NRS_RES_MAX]; - struct ptlrpc_nrs *nrs = NULL; - int i; + struct ptlrpc_nrs *nrs = NULL; + int i; for (i = 0; i < NRS_RES_MAX; i++) { if (resp[i] != NULL) { @@ -530,7 +530,7 @@ static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp) */ static inline struct ptlrpc_nrs_request *nrs_request_get(struct ptlrpc_nrs_policy *policy, - bool peek, bool force) + bool peek, bool force) { struct ptlrpc_nrs_request *nrq; @@ -556,8 +556,8 @@ struct ptlrpc_nrs_request *nrs_request_get(struct ptlrpc_nrs_policy *policy, static inline void nrs_request_enqueue(struct ptlrpc_nrs_request *nrq) { struct ptlrpc_nrs_policy *policy; - int rc; - int i; + int rc; + int i; /** * Try in descending order, because the primary policy (if any) is @@ -628,8 +628,8 @@ static inline void nrs_request_stop(struct ptlrpc_nrs_request *nrq) static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name, enum ptlrpc_nrs_ctl opc, void *arg) { - struct ptlrpc_nrs_policy *policy; - int rc = 0; + struct ptlrpc_nrs_policy *policy; + int rc = 0; spin_lock(&nrs->nrs_lock); @@ -715,7 +715,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) nrs_policy_fini(policy); LASSERT(policy->pol_private == NULL); - OBD_FREE_PTR(policy); + kfree(policy); return 0; } @@ -733,10 +733,10 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) static int nrs_policy_register(struct ptlrpc_nrs *nrs, struct ptlrpc_nrs_pol_desc *desc) { - struct ptlrpc_nrs_policy *policy; - struct ptlrpc_nrs_policy *tmp; - struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; - int rc; + struct ptlrpc_nrs_policy *policy; + struct ptlrpc_nrs_policy *tmp; + struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; + int rc; LASSERT(svcpt != NULL); LASSERT(desc->pd_ops != NULL); @@ -746,22 +746,23 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, LASSERT(desc->pd_ops->op_req_dequeue != NULL); LASSERT(desc->pd_compat != NULL); - OBD_CPT_ALLOC_GFP(policy, svcpt->scp_service->srv_cptable, - svcpt->scp_cpt, sizeof(*policy), GFP_NOFS); + policy = kzalloc_node(sizeof(*policy), GFP_NOFS, + cfs_cpt_spread_node(svcpt->scp_service->srv_cptable, + svcpt->scp_cpt)); if (policy == NULL) return -ENOMEM; - policy->pol_nrs = nrs; - policy->pol_desc = desc; - policy->pol_state = NRS_POL_STATE_STOPPED; - policy->pol_flags = desc->pd_flags; + policy->pol_nrs = nrs; + policy->pol_desc = desc; + policy->pol_state = NRS_POL_STATE_STOPPED; + policy->pol_flags = desc->pd_flags; INIT_LIST_HEAD(&policy->pol_list); INIT_LIST_HEAD(&policy->pol_list_queued); rc = nrs_policy_init(policy); if (rc != 0) { - OBD_FREE_PTR(policy); + kfree(policy); return rc; } @@ -776,7 +777,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, spin_unlock(&nrs->nrs_lock); nrs_policy_fini(policy); - OBD_FREE_PTR(policy); + kfree(policy); return -EEXIST; } @@ -803,7 +804,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, */ static void ptlrpc_nrs_req_add_nolock(struct ptlrpc_request *req) { - struct ptlrpc_nrs_policy *policy; + struct ptlrpc_nrs_policy *policy; LASSERT(req->rq_nrq.nr_initialized); LASSERT(!req->rq_nrq.nr_enqueued); @@ -828,7 +829,7 @@ static void ptlrpc_nrs_req_add_nolock(struct ptlrpc_request *req) */ static void ptlrpc_nrs_hpreq_add_nolock(struct ptlrpc_request *req) { - int opc = lustre_msg_get_opc(req->rq_reqmsg); + int opc = lustre_msg_get_opc(req->rq_reqmsg); spin_lock(&req->rq_lock); req->rq_hp = 1; @@ -871,9 +872,9 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs) { struct ptlrpc_nrs_pol_desc *desc; /* for convenience */ - struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; - struct ptlrpc_service *svc = svcpt->scp_service; - int rc = -EINVAL; + struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; + struct ptlrpc_service *svc = svcpt->scp_service; + int rc = -EINVAL; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -911,7 +912,7 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs) static int nrs_svcpt_setup_locked0(struct ptlrpc_nrs *nrs, struct ptlrpc_service_part *svcpt) { - enum ptlrpc_nrs_queue_type queue; + enum ptlrpc_nrs_queue_type queue; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -942,8 +943,8 @@ static int nrs_svcpt_setup_locked0(struct ptlrpc_nrs *nrs, */ static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt) { - struct ptlrpc_nrs *nrs; - int rc; + struct ptlrpc_nrs *nrs; + int rc; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -961,9 +962,10 @@ static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt) if (svcpt->scp_service->srv_ops.so_hpreq_handler == NULL) goto out; - OBD_CPT_ALLOC_PTR(svcpt->scp_nrs_hp, - svcpt->scp_service->srv_cptable, - svcpt->scp_cpt); + svcpt->scp_nrs_hp = + kzalloc_node(sizeof(*svcpt->scp_nrs_hp), GFP_NOFS, + cfs_cpt_spread_node(svcpt->scp_service->srv_cptable, + svcpt->scp_cpt)); if (svcpt->scp_nrs_hp == NULL) { rc = -ENOMEM; goto out; @@ -986,11 +988,11 @@ out: */ static void nrs_svcpt_cleanup_locked(struct ptlrpc_service_part *svcpt) { - struct ptlrpc_nrs *nrs; - struct ptlrpc_nrs_policy *policy; - struct ptlrpc_nrs_policy *tmp; - int rc; - bool hp = false; + struct ptlrpc_nrs *nrs; + struct ptlrpc_nrs_policy *policy; + struct ptlrpc_nrs_policy *tmp; + int rc; + bool hp = false; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -1013,7 +1015,7 @@ again: } if (hp) - OBD_FREE_PTR(nrs); + kfree(nrs); } /** @@ -1026,7 +1028,7 @@ again: */ static struct ptlrpc_nrs_pol_desc *nrs_policy_find_desc_locked(const char *name) { - struct ptlrpc_nrs_pol_desc *tmp; + struct ptlrpc_nrs_pol_desc *tmp; list_for_each_entry(tmp, &nrs_core.nrs_policies, pd_list) { if (strncmp(tmp->pd_name, name, NRS_POL_NAME_MAX) == 0) @@ -1049,11 +1051,11 @@ static struct ptlrpc_nrs_pol_desc *nrs_policy_find_desc_locked(const char *name) */ static int nrs_policy_unregister_locked(struct ptlrpc_nrs_pol_desc *desc) { - struct ptlrpc_nrs *nrs; - struct ptlrpc_service *svc; - struct ptlrpc_service_part *svcpt; - int i; - int rc = 0; + struct ptlrpc_nrs *nrs; + struct ptlrpc_service *svc; + struct ptlrpc_service_part *svcpt; + int i; + int rc = 0; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); LASSERT(mutex_is_locked(&ptlrpc_all_services_mutex)); @@ -1113,9 +1115,9 @@ again: */ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) { - struct ptlrpc_service *svc; - struct ptlrpc_nrs_pol_desc *desc; - int rc = 0; + struct ptlrpc_service *svc; + struct ptlrpc_nrs_pol_desc *desc; + int rc = 0; LASSERT(conf != NULL); LASSERT(conf->nc_ops != NULL); @@ -1153,19 +1155,19 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) goto fail; } - OBD_ALLOC_PTR(desc); + desc = kzalloc(sizeof(*desc), GFP_NOFS); if (desc == NULL) { rc = -ENOMEM; goto fail; } strncpy(desc->pd_name, conf->nc_name, NRS_POL_NAME_MAX); - desc->pd_ops = conf->nc_ops; - desc->pd_compat = conf->nc_compat; + desc->pd_ops = conf->nc_ops; + desc->pd_compat = conf->nc_compat; desc->pd_compat_svc_name = conf->nc_compat_svc_name; if ((conf->nc_flags & PTLRPC_NRS_FL_REG_EXTERN) != 0) - desc->pd_owner = conf->nc_owner; - desc->pd_flags = conf->nc_flags; + desc->pd_owner = conf->nc_owner; + desc->pd_flags = conf->nc_flags; atomic_set(&desc->pd_refs, 0); /** @@ -1185,17 +1187,17 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) mutex_lock(&ptlrpc_all_services_mutex); list_for_each_entry(svc, &ptlrpc_all_services, srv_list) { - struct ptlrpc_service_part *svcpt; - int i; - int rc2; + struct ptlrpc_service_part *svcpt; + int i; + int rc2; if (!nrs_policy_compatible(svc, desc) || unlikely(svc->srv_is_stopping)) continue; ptlrpc_service_for_each_part(svcpt, i, svc) { - struct ptlrpc_nrs *nrs; - bool hp = false; + struct ptlrpc_nrs *nrs; + bool hp = false; again: nrs = nrs_svcpt2nrs(svcpt, hp); rc = nrs_policy_register(nrs, desc); @@ -1210,7 +1212,7 @@ again: */ LASSERT(rc2 == 0); mutex_unlock(&ptlrpc_all_services_mutex); - OBD_FREE_PTR(desc); + kfree(desc); goto fail; } @@ -1233,7 +1235,7 @@ again: */ LASSERT(rc2 == 0); mutex_unlock(&ptlrpc_all_services_mutex); - OBD_FREE_PTR(desc); + kfree(desc); goto fail; } } @@ -1265,8 +1267,8 @@ EXPORT_SYMBOL(ptlrpc_nrs_policy_register); */ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf) { - struct ptlrpc_nrs_pol_desc *desc; - int rc; + struct ptlrpc_nrs_pol_desc *desc; + int rc; LASSERT(conf != NULL); @@ -1301,7 +1303,7 @@ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf) conf->nc_name); list_del(&desc->pd_list); - OBD_FREE_PTR(desc); + kfree(desc); fail: mutex_unlock(&ptlrpc_all_services_mutex); @@ -1329,10 +1331,10 @@ EXPORT_SYMBOL(ptlrpc_nrs_policy_unregister); */ int ptlrpc_service_nrs_setup(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; - const struct ptlrpc_nrs_pol_desc *desc; - int i; - int rc = 0; + struct ptlrpc_service_part *svcpt; + const struct ptlrpc_nrs_pol_desc *desc; + int i; + int rc = 0; mutex_lock(&nrs_core.nrs_mutex); @@ -1374,9 +1376,9 @@ failed: */ void ptlrpc_service_nrs_cleanup(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; - const struct ptlrpc_nrs_pol_desc *desc; - int i; + struct ptlrpc_service_part *svcpt; + const struct ptlrpc_nrs_pol_desc *desc; + int i; mutex_lock(&nrs_core.nrs_mutex); @@ -1415,7 +1417,7 @@ void ptlrpc_service_nrs_cleanup(struct ptlrpc_service *svc) void ptlrpc_nrs_req_initialize(struct ptlrpc_service_part *svcpt, struct ptlrpc_request *req, bool hp) { - struct ptlrpc_nrs *nrs = nrs_svcpt2nrs(svcpt, hp); + struct ptlrpc_nrs *nrs = nrs_svcpt2nrs(svcpt, hp); memset(&req->rq_nrq, 0, sizeof(req->rq_nrq)); nrs_resource_get_safe(nrs, &req->rq_nrq, req->rq_nrq.nr_res_ptrs, @@ -1523,8 +1525,8 @@ struct ptlrpc_request * ptlrpc_nrs_req_get_nolock0(struct ptlrpc_service_part *svcpt, bool hp, bool peek, bool force) { - struct ptlrpc_nrs *nrs = nrs_svcpt2nrs(svcpt, hp); - struct ptlrpc_nrs_policy *policy; + struct ptlrpc_nrs *nrs = nrs_svcpt2nrs(svcpt, hp); + struct ptlrpc_nrs_policy *policy; struct ptlrpc_nrs_request *nrq; /** @@ -1594,10 +1596,10 @@ bool ptlrpc_nrs_req_pending_nolock(struct ptlrpc_service_part *svcpt, bool hp) */ void ptlrpc_nrs_req_hp_move(struct ptlrpc_request *req) { - struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; - struct ptlrpc_nrs_request *nrq = &req->rq_nrq; - struct ptlrpc_nrs_resource *res1[NRS_RES_MAX]; - struct ptlrpc_nrs_resource *res2[NRS_RES_MAX]; + struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; + struct ptlrpc_nrs_request *nrq = &req->rq_nrq; + struct ptlrpc_nrs_resource *res1[NRS_RES_MAX]; + struct ptlrpc_nrs_resource *res2[NRS_RES_MAX]; /** * Obtain the high-priority NRS head resources. @@ -1659,9 +1661,9 @@ int ptlrpc_nrs_policy_control(const struct ptlrpc_service *svc, enum ptlrpc_nrs_queue_type queue, char *name, enum ptlrpc_nrs_ctl opc, bool single, void *arg) { - struct ptlrpc_service_part *svcpt; - int i; - int rc = 0; + struct ptlrpc_service_part *svcpt; + int i; + int rc = 0; LASSERT(opc != PTLRPC_NRS_CTL_INVALID); @@ -1709,7 +1711,7 @@ extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; */ int ptlrpc_nrs_init(void) { - int rc; + int rc; mutex_init(&nrs_core.nrs_mutex); INIT_LIST_HEAD(&nrs_core.nrs_policies); @@ -1747,7 +1749,7 @@ void ptlrpc_nrs_fini(void) list_for_each_entry_safe(desc, tmp, &nrs_core.nrs_policies, pd_list) { list_del_init(&desc->pd_list); - OBD_FREE_PTR(desc); + kfree(desc); } } diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c index eb40c01db612..8e21f0cdc8f8 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c @@ -80,7 +80,9 @@ static int nrs_fifo_start(struct ptlrpc_nrs_policy *policy) { struct nrs_fifo_head *head; - OBD_CPT_ALLOC_PTR(head, nrs_pol2cptab(policy), nrs_pol2cptid(policy)); + head = kzalloc_node(sizeof(*head), GFP_NOFS, + cfs_cpt_spread_node(nrs_pol2cptab(policy), + nrs_pol2cptid(policy))); if (head == NULL) return -ENOMEM; @@ -105,7 +107,7 @@ static void nrs_fifo_stop(struct ptlrpc_nrs_policy *policy) LASSERT(head != NULL); LASSERT(list_empty(&head->fh_list)); - OBD_FREE_PTR(head); + kfree(head); } /** @@ -158,9 +160,9 @@ static int nrs_fifo_res_get(struct ptlrpc_nrs_policy *policy, */ static struct ptlrpc_nrs_request *nrs_fifo_req_get(struct ptlrpc_nrs_policy *policy, - bool peek, bool force) + bool peek, bool force) { - struct nrs_fifo_head *head = policy->pol_private; + struct nrs_fifo_head *head = policy->pol_private; struct ptlrpc_nrs_request *nrq; nrq = unlikely(list_empty(&head->fh_list)) ? NULL : diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index b51af9bf37b7..2787bfd67165 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -279,8 +279,8 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt) /* See if we have anything in a pool, and wait if nothing */ while (list_empty(&svcpt->scp_rep_idle)) { - struct l_wait_info lwi; - int rc; + struct l_wait_info lwi; + int rc; spin_unlock(&svcpt->scp_rep_lock); /* If we cannot get anything for some long time, we better @@ -321,7 +321,7 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count, __u32 *lens, char **bufs, int flags) { struct ptlrpc_reply_state *rs; - int msg_len, rc; + int msg_len, rc; LASSERT(req->rq_reply_state == NULL); @@ -440,8 +440,8 @@ EXPORT_SYMBOL(lustre_msg_buf); int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, int segment, unsigned int newlen, int move_data) { - char *tail = NULL, *newpos; - int tail_len = 0, n; + char *tail = NULL, *newpos; + int tail_len = 0, n; LASSERT(msg); LASSERT(msg->lm_bufcount > segment); @@ -1577,8 +1577,8 @@ int do_set_info_async(struct obd_import *imp, struct ptlrpc_request_set *set) { struct ptlrpc_request *req; - char *tmp; - int rc; + char *tmp; + int rc; req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO); if (req == NULL) @@ -1688,7 +1688,7 @@ void lustre_swab_connect(struct obd_connect_data *ocd) CLASSERT(offsetof(typeof(*ocd), paddingF) != 0); } -void lustre_swab_obdo(struct obdo *o) +void lustre_swab_obdo(struct obdo *o) { __swab64s(&o->o_valid); lustre_swab_ost_id(&o->o_oi); @@ -2179,7 +2179,7 @@ EXPORT_SYMBOL(lustre_swab_lov_user_md_objects); void lustre_swab_ldlm_res_id(struct ldlm_res_id *id) { - int i; + int i; for (i = 0; i < RES_NAME_SIZE; i++) __swab64s(&id->name[i]); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 9dbda9332dd8..d05c37c1fd30 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -91,7 +91,7 @@ int ptlrpc_obd_ping(struct obd_device *obd) } EXPORT_SYMBOL(ptlrpc_obd_ping); -int ptlrpc_ping(struct obd_import *imp) +static int ptlrpc_ping(struct obd_import *imp) { struct ptlrpc_request *req; @@ -110,7 +110,7 @@ int ptlrpc_ping(struct obd_import *imp) return 0; } -void ptlrpc_update_next_ping(struct obd_import *imp, int soon) +static void ptlrpc_update_next_ping(struct obd_import *imp, int soon) { int time = soon ? PING_INTERVAL_SHORT : PING_INTERVAL; if (imp->imp_state == LUSTRE_IMP_DISCON) { @@ -141,7 +141,7 @@ static inline int ptlrpc_next_reconnect(struct obd_import *imp) return cfs_time_shift(obd_timeout); } -long pinger_check_timeout(unsigned long time) +static long pinger_check_timeout(unsigned long time) { struct timeout_item *item; unsigned long timeout = PING_INTERVAL; @@ -289,12 +289,10 @@ static int ptlrpc_pinger_main(void *arg) thread_is_stopping(thread) || thread_is_event(thread), &lwi); - if (thread_test_and_clear_flags(thread, SVC_STOPPING)) { + if (thread_test_and_clear_flags(thread, SVC_STOPPING)) break; - } else { - /* woken after adding import to reset timer */ - thread_test_and_clear_flags(thread, SVC_EVENT); - } + /* woken after adding import to reset timer */ + thread_test_and_clear_flags(thread, SVC_EVENT); } } @@ -422,12 +420,12 @@ EXPORT_SYMBOL(ptlrpc_pinger_del_import); * Register a timeout callback to the pinger list, and the callback will * be called when timeout happens. */ -struct timeout_item *ptlrpc_new_timeout(int time, enum timeout_event event, - timeout_cb_t cb, void *data) +static struct timeout_item *ptlrpc_new_timeout(int time, + enum timeout_event event, timeout_cb_t cb, void *data) { struct timeout_item *ti; - OBD_ALLOC_PTR(ti); + ti = kzalloc(sizeof(*ti), GFP_NOFS); if (!ti) return NULL; @@ -514,7 +512,7 @@ int ptlrpc_del_timeout_client(struct list_head *obd_list, LASSERTF(ti != NULL, "ti is NULL !\n"); if (list_empty(&ti->ti_obd_list)) { list_del(&ti->ti_chain); - OBD_FREE_PTR(ti); + kfree(ti); } mutex_unlock(&pinger_mutex); return 0; @@ -529,7 +527,7 @@ int ptlrpc_pinger_remove_timeouts(void) list_for_each_entry_safe(item, tmp, &timeout_list, ti_chain) { LASSERT(list_empty(&item->ti_obd_list)); list_del(&item->ti_chain); - OBD_FREE_PTR(item); + kfree(item); } mutex_unlock(&pinger_mutex); return 0; @@ -546,9 +544,9 @@ void ptlrpc_pinger_wake_up(void) #define PET_TERMINATE 2 static int pet_refcount; -static int pet_state; -static wait_queue_head_t pet_waitq; -LIST_HEAD(pet_list); +static int pet_state; +static wait_queue_head_t pet_waitq; +static LIST_HEAD(pet_list); static DEFINE_SPINLOCK(pet_lock); int ping_evictor_wake(struct obd_export *exp) diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index a66dc3c6da41..6dc3998dcd24 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -76,19 +76,16 @@ void ptlrpc_initiate_recovery(struct obd_import *imp); int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset); int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset); -#if defined(CONFIG_PROC_FS) -void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry, - struct ptlrpc_service *svc); +int ptlrpc_sysfs_register_service(struct kset *parent, + struct ptlrpc_service *svc); +void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc); + +void ptlrpc_ldebugfs_register_service(struct dentry *debugfs_entry, + struct ptlrpc_service *svc); void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc); void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req, long amount); void ptlrpc_lprocfs_do_request_stat(struct ptlrpc_request *req, long q_usec, long work_usec); -#else -#define ptlrpc_lprocfs_register_service(params...) do {} while (0) -#define ptlrpc_lprocfs_unregister_service(params...) do {} while (0) -#define ptlrpc_lprocfs_rpc_sent(params...) do {} while (0) -#define ptlrpc_lprocfs_do_request_stat(params...) do {} while (0) -#endif /* CONFIG_PROC_FS */ /* NRS */ @@ -263,14 +260,8 @@ void sptlrpc_enc_pool_fini(void); int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v); /* sec_lproc.c */ -#if defined(CONFIG_PROC_FS) int sptlrpc_lproc_init(void); void sptlrpc_lproc_fini(void); -#else -static inline int sptlrpc_lproc_init(void) -{ return 0; } -static inline void sptlrpc_lproc_fini(void) {} -#endif /* sec_gc.c */ int sptlrpc_gc_init(void); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 0c178ec0e487..e591cff323ec 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -68,9 +68,9 @@ #include "ptlrpc_internal.h" struct ptlrpcd { - int pd_size; - int pd_index; - int pd_nthreads; + int pd_size; + int pd_index; + int pd_nthreads; struct ptlrpcd_ctl pd_thread_rcv; struct ptlrpcd_ctl pd_threads[0]; }; @@ -528,8 +528,9 @@ static int ptlrpcd_bind(int index, int max) } if (rc == 0 && pc->pc_npartners > 0) { - OBD_ALLOC(pc->pc_partners, - sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners); + pc->pc_partners = kcalloc(pc->pc_npartners, + sizeof(struct ptlrpcd_ctl *), + GFP_NOFS); if (pc->pc_partners == NULL) { pc->pc_npartners = 0; rc = -ENOMEM; @@ -699,8 +700,7 @@ out: if (pc->pc_npartners > 0) { LASSERT(pc->pc_partners != NULL); - OBD_FREE(pc->pc_partners, - sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners); + kfree(pc->pc_partners); pc->pc_partners = NULL; } pc->pc_npartners = 0; @@ -717,7 +717,7 @@ static void ptlrpcd_fini(void) ptlrpcd_free(&ptlrpcds->pd_threads[i]); ptlrpcd_stop(&ptlrpcds->pd_thread_rcv, 0); ptlrpcd_free(&ptlrpcds->pd_thread_rcv); - OBD_FREE(ptlrpcds, ptlrpcds->pd_size); + kfree(ptlrpcds); ptlrpcds = NULL; } } @@ -738,7 +738,7 @@ static int ptlrpcd_init(void) nthreads &= ~1; /* make sure it is even */ size = offsetof(struct ptlrpcd, pd_threads[nthreads]); - OBD_ALLOC(ptlrpcds, size); + ptlrpcds = kzalloc(size, GFP_NOFS); if (ptlrpcds == NULL) { rc = -ENOMEM; goto out; @@ -781,7 +781,7 @@ out: ptlrpcd_free(&ptlrpcds->pd_threads[j]); ptlrpcd_stop(&ptlrpcds->pd_thread_rcv, 0); ptlrpcd_free(&ptlrpcds->pd_thread_rcv); - OBD_FREE(ptlrpcds, size); + kfree(ptlrpcds); ptlrpcds = NULL; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 21e9dc9d5580..b9821db22904 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -113,10 +113,10 @@ static struct ptlrpc_sec_policy *sptlrpc_wireflavor2policy(__u32 flavor) { static DEFINE_MUTEX(load_mutex); - static atomic_t loaded = ATOMIC_INIT(0); + static atomic_t loaded = ATOMIC_INIT(0); struct ptlrpc_sec_policy *policy; - __u16 number = SPTLRPC_FLVR_POLICY(flavor); - __u16 flag = 0; + __u16 number = SPTLRPC_FLVR_POLICY(flavor); + __u16 flag = 0; if (number >= SPTLRPC_POLICY_MAX) return NULL; @@ -339,7 +339,7 @@ int sptlrpc_cli_ctx_display(struct ptlrpc_cli_ctx *ctx, char *buf, int bufsize) static int import_sec_check_expire(struct obd_import *imp) { - int adapt = 0; + int adapt = 0; spin_lock(&imp->imp_lock); if (imp->imp_sec_expire && @@ -359,7 +359,7 @@ static int import_sec_check_expire(struct obd_import *imp) static int import_sec_validate_get(struct obd_import *imp, struct ptlrpc_sec **sec) { - int rc; + int rc; if (unlikely(imp->imp_sec_expire)) { rc = import_sec_check_expire(imp); @@ -447,10 +447,10 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req, struct ptlrpc_cli_ctx *oldctx, struct ptlrpc_cli_ctx *newctx) { - struct sptlrpc_flavor old_flvr; - char *reqmsg = NULL; /* to workaround old gcc */ - int reqmsg_size; - int rc = 0; + struct sptlrpc_flavor old_flvr; + char *reqmsg = NULL; /* to workaround old gcc */ + int reqmsg_size; + int rc = 0; LASSERT(req->rq_reqmsg); LASSERT(req->rq_reqlen); @@ -469,7 +469,7 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req, /* save request message */ reqmsg_size = req->rq_reqlen; if (reqmsg_size != 0) { - OBD_ALLOC_LARGE(reqmsg, reqmsg_size); + reqmsg = libcfs_kvzalloc(reqmsg_size, GFP_NOFS); if (reqmsg == NULL) return -ENOMEM; memcpy(reqmsg, req->rq_reqmsg, reqmsg_size); @@ -497,7 +497,7 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req, req->rq_flvr = old_flvr; } - OBD_FREE_LARGE(reqmsg, reqmsg_size); + kvfree(reqmsg); } return rc; } @@ -514,7 +514,7 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req) { struct ptlrpc_cli_ctx *oldctx = req->rq_cli_ctx; struct ptlrpc_cli_ctx *newctx; - int rc; + int rc; LASSERT(oldctx); @@ -629,10 +629,10 @@ void req_off_ctx_list(struct ptlrpc_request *req, struct ptlrpc_cli_ctx *ctx) */ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) { - struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; - struct ptlrpc_sec *sec; - struct l_wait_info lwi; - int rc; + struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; + struct ptlrpc_sec *sec; + struct l_wait_info lwi; + int rc; LASSERT(ctx); @@ -866,7 +866,7 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req) if (req->rq_pool || !req->rq_reqbuf) return; - OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len); + kfree(req->rq_reqbuf); req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } @@ -878,7 +878,7 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req) */ int sptlrpc_import_check_ctx(struct obd_import *imp) { - struct ptlrpc_sec *sec; + struct ptlrpc_sec *sec; struct ptlrpc_cli_ctx *ctx; struct ptlrpc_request *req = NULL; int rc; @@ -974,7 +974,7 @@ int sptlrpc_cli_wrap_request(struct ptlrpc_request *req) static int do_cli_unwrap_reply(struct ptlrpc_request *req) { struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; - int rc; + int rc; LASSERT(ctx); LASSERT(ctx->cc_sec); @@ -1082,10 +1082,10 @@ int sptlrpc_cli_unwrap_reply(struct ptlrpc_request *req) int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, struct ptlrpc_request **req_ret) { - struct ptlrpc_request *early_req; - char *early_buf; - int early_bufsz, early_size; - int rc; + struct ptlrpc_request *early_req; + char *early_buf; + int early_bufsz, early_size; + int rc; early_req = ptlrpc_request_cache_alloc(GFP_NOFS); if (early_req == NULL) @@ -1093,7 +1093,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, early_size = req->rq_nob_received; early_bufsz = size_roundup_power2(early_size); - OBD_ALLOC_LARGE(early_buf, early_bufsz); + early_buf = libcfs_kvzalloc(early_bufsz, GFP_NOFS); if (early_buf == NULL) { rc = -ENOMEM; goto err_req; @@ -1163,7 +1163,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, err_ctx: sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1); err_buf: - OBD_FREE_LARGE(early_buf, early_bufsz); + kvfree(early_buf); err_req: ptlrpc_request_cache_free(early_req); return rc; @@ -1181,7 +1181,7 @@ void sptlrpc_cli_finish_early_reply(struct ptlrpc_request *early_req) LASSERT(early_req->rq_repmsg); sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1); - OBD_FREE_LARGE(early_req->rq_repbuf, early_req->rq_repbuf_len); + kvfree(early_req->rq_repbuf); ptlrpc_request_cache_free(early_req); } @@ -1273,13 +1273,13 @@ EXPORT_SYMBOL(sptlrpc_sec_put); */ static struct ptlrpc_sec *sptlrpc_sec_create(struct obd_import *imp, - struct ptlrpc_svc_ctx *svc_ctx, - struct sptlrpc_flavor *sf, - enum lustre_sec_part sp) + struct ptlrpc_svc_ctx *svc_ctx, + struct sptlrpc_flavor *sf, + enum lustre_sec_part sp) { struct ptlrpc_sec_policy *policy; - struct ptlrpc_sec *sec; - char str[32]; + struct ptlrpc_sec *sec; + char str[32]; if (svc_ctx) { LASSERT(imp->imp_dlm_fake == 1); @@ -1369,7 +1369,7 @@ static void sptlrpc_import_sec_adapt_inplace(struct obd_import *imp, struct ptlrpc_sec *sec, struct sptlrpc_flavor *sf) { - char str1[32], str2[32]; + char str1[32], str2[32]; if (sec->ps_flvr.sf_flags != sf->sf_flags) CDEBUG(D_SEC, "changing sec flags: %s -> %s\n", @@ -1394,12 +1394,12 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp, struct ptlrpc_svc_ctx *svc_ctx, struct sptlrpc_flavor *flvr) { - struct ptlrpc_connection *conn; - struct sptlrpc_flavor sf; - struct ptlrpc_sec *sec, *newsec; - enum lustre_sec_part sp; - char str[24]; - int rc = 0; + struct ptlrpc_connection *conn; + struct sptlrpc_flavor sf; + struct ptlrpc_sec *sec, *newsec; + enum lustre_sec_part sp; + char str[24]; + int rc = 0; might_sleep(); @@ -1436,7 +1436,7 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp, sec = sptlrpc_import_sec_ref(imp); if (sec) { - char str2[24]; + char str2[24]; if (flavor_equal(&sf, &sec->ps_flvr)) goto out; @@ -1585,8 +1585,8 @@ void sptlrpc_cli_free_reqbuf(struct ptlrpc_request *req) void _sptlrpc_enlarge_msg_inplace(struct lustre_msg *msg, int segment, int newsize) { - void *src, *dst; - int oldsize, oldmsg_size, movesize; + void *src, *dst; + int oldsize, oldmsg_size, movesize; LASSERT(segment < msg->lm_bufcount); LASSERT(msg->lm_buflens[segment] <= newsize); @@ -1635,9 +1635,9 @@ EXPORT_SYMBOL(_sptlrpc_enlarge_msg_inplace); int sptlrpc_cli_enlarge_reqbuf(struct ptlrpc_request *req, int segment, int newsize) { - struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; - struct ptlrpc_sec_cops *cops; - struct lustre_msg *msg = req->rq_reqmsg; + struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; + struct ptlrpc_sec_cops *cops; + struct lustre_msg *msg = req->rq_reqmsg; LASSERT(ctx); LASSERT(msg); @@ -1748,7 +1748,7 @@ static int flavor_allowed(struct sptlrpc_flavor *exp, int sptlrpc_target_export_check(struct obd_export *exp, struct ptlrpc_request *req) { - struct sptlrpc_flavor flavor; + struct sptlrpc_flavor flavor; if (exp == NULL) return 0; @@ -1926,8 +1926,8 @@ EXPORT_SYMBOL(sptlrpc_target_export_check); void sptlrpc_target_update_exp_flavor(struct obd_device *obd, struct sptlrpc_rule_set *rset) { - struct obd_export *exp; - struct sptlrpc_flavor new_flvr; + struct obd_export *exp; + struct sptlrpc_flavor new_flvr; LASSERT(obd); @@ -2019,8 +2019,8 @@ static int sptlrpc_svc_check_from(struct ptlrpc_request *req, int svc_rc) int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) { struct ptlrpc_sec_policy *policy; - struct lustre_msg *msg = req->rq_reqbuf; - int rc; + struct lustre_msg *msg = req->rq_reqbuf; + int rc; LASSERT(msg); LASSERT(req->rq_reqmsg == NULL); @@ -2231,8 +2231,8 @@ int sptlrpc_cli_unwrap_bulk_read(struct ptlrpc_request *req, struct ptlrpc_bulk_desc *desc, int nob) { - struct ptlrpc_cli_ctx *ctx; - int rc; + struct ptlrpc_cli_ctx *ctx; + int rc; LASSERT(req->rq_bulk_read && !req->rq_bulk_write); @@ -2256,8 +2256,8 @@ EXPORT_SYMBOL(sptlrpc_cli_unwrap_bulk_read); int sptlrpc_cli_unwrap_bulk_write(struct ptlrpc_request *req, struct ptlrpc_bulk_desc *desc) { - struct ptlrpc_cli_ctx *ctx; - int rc; + struct ptlrpc_cli_ctx *ctx; + int rc; LASSERT(!req->rq_bulk_read && req->rq_bulk_write); @@ -2329,7 +2329,7 @@ EXPORT_SYMBOL(sptlrpc_pack_user_desc); int sptlrpc_unpack_user_desc(struct lustre_msg *msg, int offset, int swabbed) { struct ptlrpc_user_desc *pud; - int i; + int i; pud = lustre_msg_buf(msg, offset, sizeof(*pud)); if (!pud) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index c05a8554d737..69d73c430696 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -62,7 +62,7 @@ #define POINTERS_PER_PAGE (PAGE_CACHE_SIZE / sizeof(void *)) #define PAGES_PER_POOL (POINTERS_PER_PAGE) -#define IDLE_IDX_MAX (100) +#define IDLE_IDX_MAX (100) #define IDLE_IDX_WEIGHT (3) #define CACHE_QUIESCENT_PERIOD (20) @@ -173,8 +173,8 @@ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v) static void enc_pools_release_free_pages(long npages) { - int p_idx, g_idx; - int p_idx_max1, p_idx_max2; + int p_idx, g_idx; + int p_idx_max1, p_idx_max2; LASSERT(npages > 0); LASSERT(npages <= page_pools.epp_free_pages); @@ -210,7 +210,7 @@ static void enc_pools_release_free_pages(long npages) /* free unused pools */ while (p_idx_max1 < p_idx_max2) { LASSERT(page_pools.epp_pools[p_idx_max2]); - OBD_FREE(page_pools.epp_pools[p_idx_max2], PAGE_CACHE_SIZE); + kfree(page_pools.epp_pools[p_idx_max2]); page_pools.epp_pools[p_idx_max2] = NULL; p_idx_max2--; } @@ -284,7 +284,7 @@ int npages_to_npools(unsigned long npages) static unsigned long enc_pools_cleanup(struct page ***pools, int npools) { unsigned long cleaned = 0; - int i, j; + int i, j; for (i = 0; i < npools; i++) { if (pools[i]) { @@ -294,7 +294,7 @@ static unsigned long enc_pools_cleanup(struct page ***pools, int npools) cleaned++; } } - OBD_FREE(pools[i], PAGE_CACHE_SIZE); + kfree(pools[i]); pools[i] = NULL; } } @@ -311,9 +311,9 @@ static unsigned long enc_pools_cleanup(struct page ***pools, int npools) */ static void enc_pools_insert(struct page ***pools, int npools, int npages) { - int freeslot; - int op_idx, np_idx, og_idx, ng_idx; - int cur_npools, end_npools; + int freeslot; + int op_idx, np_idx, og_idx, ng_idx; + int cur_npools, end_npools; LASSERT(npages > 0); LASSERT(page_pools.epp_total_pages+npages <= page_pools.epp_max_pages); @@ -393,9 +393,9 @@ static void enc_pools_insert(struct page ***pools, int npools, int npages) static int enc_pools_add_pages(int npages) { static DEFINE_MUTEX(add_pages_mutex); - struct page ***pools; - int npools, alloced = 0; - int i, j, rc = -ENOMEM; + struct page ***pools; + int npools, alloced = 0; + int i, j, rc = -ENOMEM; if (npages < PTLRPC_MAX_BRW_PAGES) npages = PTLRPC_MAX_BRW_PAGES; @@ -409,12 +409,12 @@ static int enc_pools_add_pages(int npages) page_pools.epp_st_grows++; npools = npages_to_npools(npages); - OBD_ALLOC(pools, npools * sizeof(*pools)); + pools = kcalloc(npools, sizeof(*pools), GFP_NOFS); if (pools == NULL) goto out; for (i = 0; i < npools; i++) { - OBD_ALLOC(pools[i], PAGE_CACHE_SIZE); + pools[i] = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); if (pools[i] == NULL) goto out_pools; @@ -435,7 +435,7 @@ static int enc_pools_add_pages(int npages) out_pools: enc_pools_cleanup(pools, npools); - OBD_FREE(pools, npools * sizeof(*pools)); + kfree(pools); out: if (rc) { page_pools.epp_st_grow_fails++; @@ -494,12 +494,12 @@ static int enc_pools_should_grow(int page_needed, long now) */ int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc) { - wait_queue_t waitlink; - unsigned long this_idle = -1; - unsigned long tick = 0; - long now; - int p_idx, g_idx; - int i; + wait_queue_t waitlink; + unsigned long this_idle = -1; + unsigned long tick = 0; + long now; + int p_idx, g_idx; + int i; LASSERT(desc->bd_iov_count > 0); LASSERT(desc->bd_iov_count <= page_pools.epp_max_pages); @@ -508,8 +508,8 @@ int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc) if (desc->bd_enc_iov != NULL) return 0; - OBD_ALLOC(desc->bd_enc_iov, - desc->bd_iov_count * sizeof(*desc->bd_enc_iov)); + desc->bd_enc_iov = kcalloc(desc->bd_iov_count, + sizeof(*desc->bd_enc_iov), GFP_NOFS); if (desc->bd_enc_iov == NULL) return -ENOMEM; @@ -609,8 +609,8 @@ EXPORT_SYMBOL(sptlrpc_enc_pool_get_pages); void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc) { - int p_idx, g_idx; - int i; + int p_idx, g_idx; + int i; if (desc->bd_enc_iov == NULL) return; @@ -646,8 +646,7 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc) spin_unlock(&page_pools.epp_lock); - OBD_FREE(desc->bd_enc_iov, - desc->bd_iov_count * sizeof(*desc->bd_enc_iov)); + kfree(desc->bd_enc_iov); desc->bd_enc_iov = NULL; } EXPORT_SYMBOL(sptlrpc_enc_pool_put_pages); @@ -659,7 +658,7 @@ EXPORT_SYMBOL(sptlrpc_enc_pool_put_pages); */ int sptlrpc_enc_pool_add_user(void) { - int need_grow = 0; + int need_grow = 0; spin_lock(&page_pools.epp_lock); if (page_pools.epp_growing == 0 && page_pools.epp_total_pages == 0) { @@ -690,9 +689,10 @@ EXPORT_SYMBOL(sptlrpc_enc_pool_del_user); static inline void enc_pools_alloc(void) { LASSERT(page_pools.epp_max_pools); - OBD_ALLOC_LARGE(page_pools.epp_pools, - page_pools.epp_max_pools * - sizeof(*page_pools.epp_pools)); + page_pools.epp_pools = + libcfs_kvzalloc(page_pools.epp_max_pools * + sizeof(*page_pools.epp_pools), + GFP_NOFS); } static inline void enc_pools_free(void) @@ -700,9 +700,7 @@ static inline void enc_pools_free(void) LASSERT(page_pools.epp_max_pools); LASSERT(page_pools.epp_pools); - OBD_FREE_LARGE(page_pools.epp_pools, - page_pools.epp_max_pools * - sizeof(*page_pools.epp_pools)); + kvfree(page_pools.epp_pools); } static struct shrinker pools_shrinker = { @@ -843,11 +841,11 @@ EXPORT_SYMBOL(bulk_sec_desc_unpack); int sptlrpc_get_bulk_checksum(struct ptlrpc_bulk_desc *desc, __u8 alg, void *buf, int buflen) { - struct cfs_crypto_hash_desc *hdesc; - int hashsize; - char hashbuf[64]; - unsigned int bufsize; - int i, err; + struct cfs_crypto_hash_desc *hdesc; + int hashsize; + char hashbuf[64]; + unsigned int bufsize; + int i, err; LASSERT(alg > BULK_HASH_ALG_NULL && alg < BULK_HASH_ALG_MAX); LASSERT(buflen >= 4); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index 56ba9e4e5297..31da43e8b3c6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -94,8 +94,8 @@ EXPORT_SYMBOL(sptlrpc_target_sec_part); */ int sptlrpc_parse_flavor(const char *str, struct sptlrpc_flavor *flvr) { - char buf[32]; - char *bulk, *alg; + char buf[32]; + char *bulk, *alg; memset(flvr, 0, sizeof(*flvr)); @@ -182,8 +182,8 @@ static void sptlrpc_rule_init(struct sptlrpc_rule *rule) */ int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) { - char *flavor, *dir; - int rc; + char *flavor, *dir; + int rc; sptlrpc_rule_init(rule); @@ -242,8 +242,7 @@ void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset) (rset->srs_nrule == 0 && rset->srs_rules == NULL)); if (rset->srs_nslot) { - OBD_FREE(rset->srs_rules, - rset->srs_nslot * sizeof(*rset->srs_rules)); + kfree(rset->srs_rules); sptlrpc_rule_set_init(rset); } } @@ -265,7 +264,7 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset) nslot = rset->srs_nslot + 8; /* better use realloc() if available */ - OBD_ALLOC(rules, nslot * sizeof(*rset->srs_rules)); + rules = kcalloc(nslot, sizeof(*rset->srs_rules), GFP_NOFS); if (rules == NULL) return -ENOMEM; @@ -274,8 +273,7 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset) memcpy(rules, rset->srs_rules, rset->srs_nrule * sizeof(*rset->srs_rules)); - OBD_FREE(rset->srs_rules, - rset->srs_nslot * sizeof(*rset->srs_rules)); + kfree(rset->srs_rules); } rset->srs_rules = rules; @@ -311,9 +309,9 @@ static inline int rule_match_net(struct sptlrpc_rule *r1, int sptlrpc_rule_set_merge(struct sptlrpc_rule_set *rset, struct sptlrpc_rule *rule) { - struct sptlrpc_rule *p = rset->srs_rules; - int spec_dir, spec_net; - int rc, n, match = 0; + struct sptlrpc_rule *p = rset->srs_rules; + int spec_dir, spec_net; + int rc, n, match = 0; might_sleep(); @@ -405,8 +403,8 @@ int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset, lnet_nid_t nid, struct sptlrpc_flavor *sf) { - struct sptlrpc_rule *r; - int n; + struct sptlrpc_rule *r; + int n; for (n = 0; n < rset->srs_nrule; n++) { r = &rset->srs_rules[n]; @@ -435,7 +433,7 @@ EXPORT_SYMBOL(sptlrpc_rule_set_choose); void sptlrpc_rule_set_dump(struct sptlrpc_rule_set *rset) { struct sptlrpc_rule *r; - int n; + int n; for (n = 0; n < rset->srs_nrule; n++) { r = &rset->srs_rules[n]; @@ -476,8 +474,8 @@ static inline int is_hex(char c) static void target2fsname(const char *tgt, char *fsname, int buflen) { - const char *ptr; - int len; + const char *ptr; + int len; ptr = strrchr(tgt, '-'); if (ptr) { @@ -509,7 +507,7 @@ static void sptlrpc_conf_free_rsets(struct sptlrpc_conf *conf) &conf->sc_tgts, sct_list) { sptlrpc_rule_set_free(&conf_tgt->sct_rset); list_del(&conf_tgt->sct_list); - OBD_FREE_PTR(conf_tgt); + kfree(conf_tgt); } LASSERT(list_empty(&conf->sc_tgts)); @@ -523,7 +521,7 @@ static void sptlrpc_conf_free(struct sptlrpc_conf *conf) sptlrpc_conf_free_rsets(conf); list_del(&conf->sc_list); - OBD_FREE_PTR(conf); + kfree(conf); } static @@ -541,7 +539,7 @@ struct sptlrpc_conf_tgt *sptlrpc_conf_get_tgt(struct sptlrpc_conf *conf, if (!create) return NULL; - OBD_ALLOC_PTR(conf_tgt); + conf_tgt = kzalloc(sizeof(*conf_tgt), GFP_NOFS); if (conf_tgt) { strlcpy(conf_tgt->sct_name, name, sizeof(conf_tgt->sct_name)); sptlrpc_rule_set_init(&conf_tgt->sct_rset); @@ -565,7 +563,7 @@ struct sptlrpc_conf *sptlrpc_conf_get(const char *fsname, if (!create) return NULL; - OBD_ALLOC_PTR(conf); + conf = kzalloc(sizeof(*conf), GFP_NOFS); if (conf == NULL) return NULL; @@ -585,8 +583,8 @@ static int sptlrpc_conf_merge_rule(struct sptlrpc_conf *conf, const char *target, struct sptlrpc_rule *rule) { - struct sptlrpc_conf_tgt *conf_tgt; - struct sptlrpc_rule_set *rule_set; + struct sptlrpc_conf_tgt *conf_tgt; + struct sptlrpc_rule_set *rule_set; /* fsname == target means general rules for the whole fs */ if (strcmp(conf->sc_fsname, target) == 0) { @@ -612,10 +610,10 @@ static int sptlrpc_conf_merge_rule(struct sptlrpc_conf *conf, static int __sptlrpc_process_config(struct lustre_cfg *lcfg, struct sptlrpc_conf *conf) { - char *target, *param; - char fsname[MTI_NAME_MAXLEN]; - struct sptlrpc_rule rule; - int rc; + char *target, *param; + char fsname[MTI_NAME_MAXLEN]; + struct sptlrpc_rule rule; + int rc; target = lustre_cfg_string(lcfg, 1); if (target == NULL) { @@ -673,8 +671,8 @@ EXPORT_SYMBOL(sptlrpc_process_config); static int logname2fsname(const char *logname, char *buf, int buflen) { - char *ptr; - int len; + char *ptr; + int len; ptr = strrchr(logname, '-'); if (ptr == NULL || strcmp(ptr, "-sptlrpc")) { @@ -692,7 +690,7 @@ static int logname2fsname(const char *logname, char *buf, int buflen) void sptlrpc_conf_log_update_begin(const char *logname) { struct sptlrpc_conf *conf; - char fsname[16]; + char fsname[16]; if (logname2fsname(logname, fsname, sizeof(fsname))) return; @@ -718,7 +716,7 @@ EXPORT_SYMBOL(sptlrpc_conf_log_update_begin); void sptlrpc_conf_log_update_end(const char *logname) { struct sptlrpc_conf *conf; - char fsname[16]; + char fsname[16]; if (logname2fsname(logname, fsname, sizeof(fsname))) return; @@ -743,7 +741,7 @@ EXPORT_SYMBOL(sptlrpc_conf_log_update_end); void sptlrpc_conf_log_start(const char *logname) { - char fsname[16]; + char fsname[16]; if (logname2fsname(logname, fsname, sizeof(fsname))) return; @@ -757,7 +755,7 @@ EXPORT_SYMBOL(sptlrpc_conf_log_start); void sptlrpc_conf_log_stop(const char *logname) { struct sptlrpc_conf *conf; - char fsname[16]; + char fsname[16]; if (logname2fsname(logname, fsname, sizeof(fsname))) return; @@ -801,10 +799,10 @@ void sptlrpc_conf_choose_flavor(enum lustre_sec_part from, lnet_nid_t nid, struct sptlrpc_flavor *sf) { - struct sptlrpc_conf *conf; + struct sptlrpc_conf *conf; struct sptlrpc_conf_tgt *conf_tgt; - char name[MTI_NAME_MAXLEN]; - int len, rc = 0; + char name[MTI_NAME_MAXLEN]; + int len, rc = 0; target2fsname(target->uuid, name, sizeof(name)); @@ -860,7 +858,7 @@ EXPORT_SYMBOL(sptlrpc_target_choose_flavor); */ void sptlrpc_conf_client_adapt(struct obd_device *obd) { - struct obd_import *imp; + struct obd_import *imp; LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 || strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) == 0); @@ -882,7 +880,7 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd) } EXPORT_SYMBOL(sptlrpc_conf_client_adapt); -int sptlrpc_conf_init(void) +int sptlrpc_conf_init(void) { mutex_init(&sptlrpc_conf_lock); return 0; @@ -890,7 +888,7 @@ int sptlrpc_conf_init(void) void sptlrpc_conf_fini(void) { - struct sptlrpc_conf *conf, *conf_next; + struct sptlrpc_conf *conf, *conf_next; mutex_lock(&sptlrpc_conf_lock); list_for_each_entry_safe(conf, conf_next, &sptlrpc_confs, sc_list) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index 81de68edb04e..cdad608bdb8d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c @@ -164,7 +164,7 @@ static void sec_do_gc(struct ptlrpc_sec *sec) static int sec_gc_main(void *arg) { struct ptlrpc_thread *thread = (struct ptlrpc_thread *) arg; - struct l_wait_info lwi; + struct l_wait_info lwi; unshare_fs_struct(); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c index 0d08145a6c7e..68fcac14b3ee 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c @@ -51,10 +51,6 @@ #include "ptlrpc_internal.h" - -struct proc_dir_entry *sptlrpc_proc_root = NULL; -EXPORT_SYMBOL(sptlrpc_proc_root); - static char *sec_flags2str(unsigned long flags, char *buf, int bufsize) { buf[0] = '\0'; @@ -78,7 +74,7 @@ static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v) struct obd_device *dev = seq->private; struct client_obd *cli = &dev->u.cli; struct ptlrpc_sec *sec = NULL; - char str[32]; + char str[32]; LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 || strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 || @@ -138,7 +134,7 @@ LPROC_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs); int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev) { - int rc; + int rc; if (strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) != 0 && strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) != 0 && @@ -148,16 +144,16 @@ int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev) return -EINVAL; } - rc = lprocfs_obd_seq_create(dev, "srpc_info", 0444, - &sptlrpc_info_lprocfs_fops, dev); + rc = ldebugfs_obd_seq_create(dev, "srpc_info", 0444, + &sptlrpc_info_lprocfs_fops, dev); if (rc) { CERROR("create proc entry srpc_info for %s: %d\n", dev->obd_name, rc); return rc; } - rc = lprocfs_obd_seq_create(dev, "srpc_contexts", 0444, - &sptlrpc_ctxs_lprocfs_fops, dev); + rc = ldebugfs_obd_seq_create(dev, "srpc_contexts", 0444, + &sptlrpc_ctxs_lprocfs_fops, dev); if (rc) { CERROR("create proc entry srpc_contexts for %s: %d\n", dev->obd_name, rc); @@ -174,17 +170,20 @@ static struct lprocfs_vars sptlrpc_lprocfs_vars[] = { { NULL } }; +static struct dentry *sptlrpc_debugfs_dir; + int sptlrpc_lproc_init(void) { - int rc; + int rc; - LASSERT(sptlrpc_proc_root == NULL); + LASSERT(sptlrpc_debugfs_dir == NULL); - sptlrpc_proc_root = lprocfs_register("sptlrpc", proc_lustre_root, - sptlrpc_lprocfs_vars, NULL); - if (IS_ERR(sptlrpc_proc_root)) { - rc = PTR_ERR(sptlrpc_proc_root); - sptlrpc_proc_root = NULL; + sptlrpc_debugfs_dir = ldebugfs_register("sptlrpc", debugfs_lustre_root, + sptlrpc_lprocfs_vars, NULL); + if (IS_ERR_OR_NULL(sptlrpc_debugfs_dir)) { + rc = sptlrpc_debugfs_dir ? PTR_ERR(sptlrpc_debugfs_dir) + : -ENOMEM; + sptlrpc_debugfs_dir = NULL; return rc; } return 0; @@ -192,8 +191,6 @@ int sptlrpc_lproc_init(void) void sptlrpc_lproc_fini(void) { - if (sptlrpc_proc_root) { - lprocfs_remove(&sptlrpc_proc_root); - sptlrpc_proc_root = NULL; - } + if (!IS_ERR_OR_NULL(sptlrpc_debugfs_dir)) + ldebugfs_remove(&sptlrpc_debugfs_dir); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index 4e132435b450..ce1c563d0175 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c @@ -92,7 +92,7 @@ int null_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) static int null_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) { - __u32 cksums, cksumc; + __u32 cksums, cksumc; LASSERT(req->rq_repdata); @@ -159,7 +159,7 @@ int null_alloc_reqbuf(struct ptlrpc_sec *sec, int alloc_size = size_roundup_power2(msgsize); LASSERT(!req->rq_pool); - OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_size); + req->rq_reqbuf = libcfs_kvzalloc(alloc_size, GFP_NOFS); if (!req->rq_reqbuf) return -ENOMEM; @@ -186,7 +186,7 @@ void null_free_reqbuf(struct ptlrpc_sec *sec, "req %p: reqlen %d should smaller than buflen %d\n", req, req->rq_reqlen, req->rq_reqbuf_len); - OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); + kvfree(req->rq_reqbuf); req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } @@ -202,7 +202,7 @@ int null_alloc_repbuf(struct ptlrpc_sec *sec, msgsize = size_roundup_power2(msgsize); - OBD_ALLOC_LARGE(req->rq_repbuf, msgsize); + req->rq_repbuf = libcfs_kvzalloc(msgsize, GFP_NOFS); if (!req->rq_repbuf) return -ENOMEM; @@ -216,7 +216,7 @@ void null_free_repbuf(struct ptlrpc_sec *sec, { LASSERT(req->rq_repbuf); - OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len); + kvfree(req->rq_repbuf); req->rq_repbuf = NULL; req->rq_repbuf_len = 0; } @@ -226,9 +226,9 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req, int segment, int newsize) { - struct lustre_msg *newbuf; - struct lustre_msg *oldbuf = req->rq_reqmsg; - int oldsize, newmsg_size, alloc_size; + struct lustre_msg *newbuf; + struct lustre_msg *oldbuf = req->rq_reqmsg; + int oldsize, newmsg_size, alloc_size; LASSERT(req->rq_reqbuf); LASSERT(req->rq_reqbuf == req->rq_reqmsg); @@ -247,7 +247,7 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, if (req->rq_reqbuf_len < newmsg_size) { alloc_size = size_roundup_power2(newmsg_size); - OBD_ALLOC_LARGE(newbuf, alloc_size); + newbuf = libcfs_kvzalloc(alloc_size, GFP_NOFS); if (newbuf == NULL) return -ENOMEM; @@ -261,7 +261,7 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, spin_lock(&req->rq_import->imp_lock); memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen); - OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); + kvfree(req->rq_reqbuf); req->rq_reqbuf = req->rq_reqmsg = newbuf; req->rq_reqbuf_len = alloc_size; @@ -316,7 +316,7 @@ int null_alloc_rs(struct ptlrpc_request *req, int msgsize) /* pre-allocated */ LASSERT(rs->rs_size >= rs_size); } else { - OBD_ALLOC_LARGE(rs, rs_size); + rs = libcfs_kvzalloc(rs_size, GFP_NOFS); if (rs == NULL) return -ENOMEM; @@ -341,7 +341,7 @@ void null_free_rs(struct ptlrpc_reply_state *rs) atomic_dec(&rs->rs_svc_ctx->sc_refcount); if (!rs->rs_prealloc) - OBD_FREE_LARGE(rs, rs->rs_size); + kvfree(rs); } static diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index a79cd53010a4..53ce0d14bd46 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -136,7 +136,7 @@ static int plain_verify_bulk_csum(struct ptlrpc_bulk_desc *desc, struct plain_bulk_token *tokenr) { struct plain_bulk_token tokenv; - int rc; + int rc; if (hash_alg == BULK_HASH_ALG_NULL) return 0; @@ -154,8 +154,8 @@ static int plain_verify_bulk_csum(struct ptlrpc_bulk_desc *desc, static void corrupt_bulk_data(struct ptlrpc_bulk_desc *desc) { - char *ptr; - unsigned int off, i; + char *ptr; + unsigned int off, i; for (i = 0; i < desc->bd_iov_count; i++) { if (desc->bd_iov[i].kiov_len == 0) @@ -190,7 +190,7 @@ int plain_ctx_validate(struct ptlrpc_cli_ctx *ctx) static int plain_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) { - struct lustre_msg *msg = req->rq_reqbuf; + struct lustre_msg *msg = req->rq_reqbuf; struct plain_header *phdr; msg->lm_secflvr = req->rq_flvr.sf_rpc; @@ -214,10 +214,10 @@ int plain_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) static int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) { - struct lustre_msg *msg = req->rq_repdata; + struct lustre_msg *msg = req->rq_repdata; struct plain_header *phdr; - __u32 cksum; - int swabbed; + __u32 cksum; + int swabbed; if (msg->lm_bufcount != PLAIN_PACK_SEGMENTS) { CERROR("unexpected reply buf count %u\n", msg->lm_bufcount); @@ -290,8 +290,8 @@ int plain_cli_wrap_bulk(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_bulk_desc *desc) { struct ptlrpc_bulk_sec_desc *bsd; - struct plain_bulk_token *token; - int rc; + struct plain_bulk_token *token; + int rc; LASSERT(req->rq_pack_bulk); LASSERT(req->rq_reqbuf->lm_bufcount == PLAIN_PACK_SEGMENTS); @@ -333,9 +333,9 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_bulk_desc *desc) { struct ptlrpc_bulk_sec_desc *bsdv; - struct plain_bulk_token *tokenv; - int rc; - int i, nob; + struct plain_bulk_token *tokenv; + int rc; + int i, nob; LASSERT(req->rq_pack_bulk); LASSERT(req->rq_reqbuf->lm_bufcount == PLAIN_PACK_SEGMENTS); @@ -374,9 +374,9 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, static struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec) { - struct ptlrpc_cli_ctx *ctx, *ctx_new; + struct ptlrpc_cli_ctx *ctx, *ctx_new; - OBD_ALLOC_PTR(ctx_new); + ctx_new = kzalloc(sizeof(*ctx_new), GFP_NOFS); write_lock(&plsec->pls_lock); @@ -384,8 +384,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec) if (ctx) { atomic_inc(&ctx->cc_refcount); - if (ctx_new) - OBD_FREE_PTR(ctx_new); + kfree(ctx_new); } else if (ctx_new) { ctx = ctx_new; @@ -414,7 +413,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec) static void plain_destroy_sec(struct ptlrpc_sec *sec) { - struct plain_sec *plsec = sec2plsec(sec); + struct plain_sec *plsec = sec2plsec(sec); LASSERT(sec->ps_policy == &plain_policy); LASSERT(sec->ps_import); @@ -424,7 +423,7 @@ void plain_destroy_sec(struct ptlrpc_sec *sec) class_import_put(sec->ps_import); - OBD_FREE_PTR(plsec); + kfree(plsec); } static @@ -438,13 +437,13 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, struct ptlrpc_svc_ctx *svc_ctx, struct sptlrpc_flavor *sf) { - struct plain_sec *plsec; - struct ptlrpc_sec *sec; - struct ptlrpc_cli_ctx *ctx; + struct plain_sec *plsec; + struct ptlrpc_sec *sec; + struct ptlrpc_cli_ctx *ctx; LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN); - OBD_ALLOC_PTR(plsec); + plsec = kzalloc(sizeof(*plsec), GFP_NOFS); if (plsec == NULL) return NULL; @@ -484,8 +483,8 @@ struct ptlrpc_cli_ctx *plain_lookup_ctx(struct ptlrpc_sec *sec, struct vfs_cred *vcred, int create, int remove_dead) { - struct plain_sec *plsec = sec2plsec(sec); - struct ptlrpc_cli_ctx *ctx; + struct plain_sec *plsec = sec2plsec(sec); + struct ptlrpc_cli_ctx *ctx; read_lock(&plsec->pls_lock); ctx = plsec->pls_ctx; @@ -508,7 +507,7 @@ void plain_release_ctx(struct ptlrpc_sec *sec, LASSERT(atomic_read(&ctx->cc_refcount) == 0); LASSERT(ctx->cc_sec == sec); - OBD_FREE_PTR(ctx); + kfree(ctx); atomic_dec(&sec->ps_nctx); sptlrpc_sec_put(sec); @@ -518,8 +517,8 @@ static int plain_flush_ctx_cache(struct ptlrpc_sec *sec, uid_t uid, int grace, int force) { - struct plain_sec *plsec = sec2plsec(sec); - struct ptlrpc_cli_ctx *ctx; + struct plain_sec *plsec = sec2plsec(sec); + struct ptlrpc_cli_ctx *ctx; /* do nothing unless caller want to flush for 'all' */ if (uid != -1) @@ -541,7 +540,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec, int msgsize) { __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, }; - int alloc_len; + int alloc_len; buflens[PLAIN_PACK_HDR_OFF] = sizeof(struct plain_header); buflens[PLAIN_PACK_MSG_OFF] = msgsize; @@ -560,7 +559,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec, LASSERT(!req->rq_pool); alloc_len = size_roundup_power2(alloc_len); - OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_len); + req->rq_reqbuf = libcfs_kvzalloc(alloc_len, GFP_NOFS); if (!req->rq_reqbuf) return -ENOMEM; @@ -585,7 +584,7 @@ void plain_free_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req) { if (!req->rq_pool) { - OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); + kvfree(req->rq_reqbuf); req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } @@ -614,7 +613,7 @@ int plain_alloc_repbuf(struct ptlrpc_sec *sec, alloc_len = size_roundup_power2(alloc_len); - OBD_ALLOC_LARGE(req->rq_repbuf, alloc_len); + req->rq_repbuf = libcfs_kvzalloc(alloc_len, GFP_NOFS); if (!req->rq_repbuf) return -ENOMEM; @@ -626,7 +625,7 @@ static void plain_free_repbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req) { - OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len); + kvfree(req->rq_repbuf); req->rq_repbuf = NULL; req->rq_repbuf_len = 0; } @@ -636,9 +635,9 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req, int segment, int newsize) { - struct lustre_msg *newbuf; - int oldsize; - int newmsg_size, newbuf_size; + struct lustre_msg *newbuf; + int oldsize; + int newmsg_size, newbuf_size; LASSERT(req->rq_reqbuf); LASSERT(req->rq_reqbuf_len >= req->rq_reqlen); @@ -665,7 +664,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, if (req->rq_reqbuf_len < newbuf_size) { newbuf_size = size_roundup_power2(newbuf_size); - OBD_ALLOC_LARGE(newbuf, newbuf_size); + newbuf = libcfs_kvzalloc(newbuf_size, GFP_NOFS); if (newbuf == NULL) return -ENOMEM; @@ -680,7 +679,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len); - OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); + kvfree(req->rq_reqbuf); req->rq_reqbuf = newbuf; req->rq_reqbuf_len = newbuf_size; req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, @@ -710,9 +709,9 @@ static struct ptlrpc_svc_ctx plain_svc_ctx = { static int plain_accept(struct ptlrpc_request *req) { - struct lustre_msg *msg = req->rq_reqbuf; + struct lustre_msg *msg = req->rq_reqbuf; struct plain_header *phdr; - int swabbed; + int swabbed; LASSERT(SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc) == SPTLRPC_POLICY_PLAIN); @@ -781,9 +780,9 @@ int plain_accept(struct ptlrpc_request *req) static int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) { - struct ptlrpc_reply_state *rs; - __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, }; - int rs_size = sizeof(*rs); + struct ptlrpc_reply_state *rs; + __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, }; + int rs_size = sizeof(*rs); LASSERT(msgsize % 8 == 0); @@ -801,7 +800,7 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) /* pre-allocated */ LASSERT(rs->rs_size >= rs_size); } else { - OBD_ALLOC_LARGE(rs, rs_size); + rs = libcfs_kvzalloc(rs_size, GFP_NOFS); if (rs == NULL) return -ENOMEM; @@ -827,16 +826,16 @@ void plain_free_rs(struct ptlrpc_reply_state *rs) atomic_dec(&rs->rs_svc_ctx->sc_refcount); if (!rs->rs_prealloc) - OBD_FREE_LARGE(rs, rs->rs_size); + kvfree(rs); } static int plain_authorize(struct ptlrpc_request *req) { struct ptlrpc_reply_state *rs = req->rq_reply_state; - struct lustre_msg_v2 *msg = rs->rs_repbuf; - struct plain_header *phdr; - int len; + struct lustre_msg_v2 *msg = rs->rs_repbuf; + struct plain_header *phdr; + int len; LASSERT(rs); LASSERT(msg); @@ -871,7 +870,7 @@ int plain_authorize(struct ptlrpc_request *req) lustre_msg_buf(msg, PLAIN_PACK_MSG_OFF, 0), lustre_msg_buflen(msg, PLAIN_PACK_MSG_OFF), NULL, 0, (unsigned char *)&msg->lm_cksum, &hsize); - req->rq_reply_off = 0; + req->rq_reply_off = 0; } return 0; @@ -881,10 +880,10 @@ static int plain_svc_unwrap_bulk(struct ptlrpc_request *req, struct ptlrpc_bulk_desc *desc) { - struct ptlrpc_reply_state *rs = req->rq_reply_state; + struct ptlrpc_reply_state *rs = req->rq_reply_state; struct ptlrpc_bulk_sec_desc *bsdr, *bsdv; - struct plain_bulk_token *tokenr; - int rc; + struct plain_bulk_token *tokenr; + int rc; LASSERT(req->rq_bulk_write); LASSERT(req->rq_pack_bulk); @@ -915,10 +914,10 @@ static int plain_svc_wrap_bulk(struct ptlrpc_request *req, struct ptlrpc_bulk_desc *desc) { - struct ptlrpc_reply_state *rs = req->rq_reply_state; + struct ptlrpc_reply_state *rs = req->rq_reply_state; struct ptlrpc_bulk_sec_desc *bsdr, *bsdv; - struct plain_bulk_token *tokenv; - int rc; + struct plain_bulk_token *tokenv; + int rc; LASSERT(req->rq_bulk_read); LASSERT(req->rq_pack_bulk); diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 8e61421515cb..9117f1c15a8e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -72,10 +72,12 @@ struct mutex ptlrpc_all_services_mutex; struct ptlrpc_request_buffer_desc * ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt) { - struct ptlrpc_service *svc = svcpt->scp_service; + struct ptlrpc_service *svc = svcpt->scp_service; struct ptlrpc_request_buffer_desc *rqbd; - OBD_CPT_ALLOC_PTR(rqbd, svc->srv_cptable, svcpt->scp_cpt); + rqbd = kzalloc_node(sizeof(*rqbd), GFP_NOFS, + cfs_cpt_spread_node(svc->srv_cptable, + svcpt->scp_cpt)); if (rqbd == NULL) return NULL; @@ -87,7 +89,7 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt) OBD_CPT_ALLOC_LARGE(rqbd->rqbd_buffer, svc->srv_cptable, svcpt->scp_cpt, svc->srv_buf_size); if (rqbd->rqbd_buffer == NULL) { - OBD_FREE_PTR(rqbd); + kfree(rqbd); return NULL; } @@ -112,17 +114,17 @@ ptlrpc_free_rqbd(struct ptlrpc_request_buffer_desc *rqbd) svcpt->scp_nrqbds_total--; spin_unlock(&svcpt->scp_lock); - OBD_FREE_LARGE(rqbd->rqbd_buffer, svcpt->scp_service->srv_buf_size); - OBD_FREE_PTR(rqbd); + kvfree(rqbd->rqbd_buffer); + kfree(rqbd); } int ptlrpc_grow_req_bufs(struct ptlrpc_service_part *svcpt, int post) { - struct ptlrpc_service *svc = svcpt->scp_service; + struct ptlrpc_service *svc = svcpt->scp_service; struct ptlrpc_request_buffer_desc *rqbd; - int rc = 0; - int i; + int rc = 0; + int i; if (svcpt->scp_rqbd_allocating) goto try_post; @@ -184,7 +186,7 @@ ptlrpc_save_lock(struct ptlrpc_request *req, struct lustre_handle *lock, int mode, int no_ack) { struct ptlrpc_reply_state *rs = req->rq_reply_state; - int idx; + int idx; LASSERT(rs != NULL); LASSERT(rs->rs_nlocks < RS_MAX_LOCKS); @@ -273,8 +275,8 @@ static void rs_batch_init(struct rs_batch *b) static struct ptlrpc_hr_thread * ptlrpc_hr_select(struct ptlrpc_service_part *svcpt) { - struct ptlrpc_hr_partition *hrp; - unsigned int rotor; + struct ptlrpc_hr_partition *hrp; + unsigned int rotor; if (svcpt->scp_cpt >= 0 && svcpt->scp_service->srv_cptable == ptlrpc_hr.hr_cpt_table) { @@ -429,8 +431,8 @@ static int ptlrpc_server_post_idle_rqbds(struct ptlrpc_service_part *svcpt) { struct ptlrpc_request_buffer_desc *rqbd; - int rc; - int posted = 0; + int rc; + int posted = 0; for (;;) { spin_lock(&svcpt->scp_lock); @@ -487,11 +489,11 @@ static void ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, struct ptlrpc_service_conf *conf) { - struct ptlrpc_service_thr_conf *tc = &conf->psc_thr; - unsigned init; - unsigned total; - unsigned nthrs; - int weight; + struct ptlrpc_service_thr_conf *tc = &conf->psc_thr; + unsigned init; + unsigned total; + unsigned nthrs; + int weight; /* * Common code for estimating & validating threads number. @@ -515,7 +517,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, * be up to 8 * nthrs_max */ total = min(tc->tc_nthrs_max * 8, tc->tc_nthrs_user); nthrs = total / svc->srv_ncpts; - init = max(init, nthrs); + init = max(init, nthrs); goto out; } @@ -529,7 +531,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, nthrs = tc->tc_nthrs_base; if (svc->srv_ncpts == 1) { - int i; + int i; /* NB: Increase the base number if it's single partition * and total number of cores/HTs is larger or equal to 4. @@ -541,7 +543,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, } if (tc->tc_thr_factor != 0) { - int factor = tc->tc_thr_factor; + int factor = tc->tc_thr_factor; const int fade = 4; /* @@ -557,7 +559,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, * there are. */ /* weight is # of HTs */ - if (cpumask_weight(topology_thread_cpumask(0)) > 1) { + if (cpumask_weight(topology_sibling_cpumask(0)) > 1) { /* depress thread factor for hyper-thread */ factor = factor - (factor >> 1) + (factor >> 3); } @@ -593,9 +595,9 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, struct ptlrpc_service_part *svcpt, int cpt) { struct ptlrpc_at_array *array; - int size; - int index; - int rc; + int size; + int index; + int rc; svcpt->scp_cpt = cpt; INIT_LIST_HEAD(&svcpt->scp_threads); @@ -625,23 +627,25 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, array = &svcpt->scp_at_array; size = at_est2timeout(at_max); - array->paa_size = size; - array->paa_count = 0; + array->paa_size = size; + array->paa_count = 0; array->paa_deadline = -1; /* allocate memory for scp_at_array (ptlrpc_at_array) */ - OBD_CPT_ALLOC(array->paa_reqs_array, - svc->srv_cptable, cpt, sizeof(struct list_head) * size); + array->paa_reqs_array = + kzalloc_node(sizeof(struct list_head) * size, GFP_NOFS, + cfs_cpt_spread_node(svc->srv_cptable, cpt)); if (array->paa_reqs_array == NULL) return -ENOMEM; for (index = 0; index < size; index++) INIT_LIST_HEAD(&array->paa_reqs_array[index]); - OBD_CPT_ALLOC(array->paa_reqs_count, - svc->srv_cptable, cpt, sizeof(__u32) * size); + array->paa_reqs_count = + kzalloc_node(sizeof(__u32) * size, GFP_NOFS, + cfs_cpt_spread_node(svc->srv_cptable, cpt)); if (array->paa_reqs_count == NULL) - goto failed; + goto free_reqs_array; cfs_timer_init(&svcpt->scp_at_timer, ptlrpc_at_timer, svcpt); /* At SOW, service time should be quick; 10s seems generous. If client @@ -655,21 +659,16 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, /* We shouldn't be under memory pressure at startup, so * fail if we can't allocate all our buffers at this time. */ if (rc != 0) - goto failed; + goto free_reqs_count; return 0; - failed: - if (array->paa_reqs_count != NULL) { - OBD_FREE(array->paa_reqs_count, sizeof(__u32) * size); - array->paa_reqs_count = NULL; - } - - if (array->paa_reqs_array != NULL) { - OBD_FREE(array->paa_reqs_array, - sizeof(struct list_head) * array->paa_size); - array->paa_reqs_array = NULL; - } +free_reqs_count: + kfree(array->paa_reqs_count); + array->paa_reqs_count = NULL; +free_reqs_array: + kfree(array->paa_reqs_array); + array->paa_reqs_array = NULL; return -ENOMEM; } @@ -681,17 +680,18 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, */ struct ptlrpc_service * ptlrpc_register_service(struct ptlrpc_service_conf *conf, - struct proc_dir_entry *proc_entry) -{ - struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt; - struct ptlrpc_service *service; - struct ptlrpc_service_part *svcpt; - struct cfs_cpt_table *cptable; - __u32 *cpts = NULL; - int ncpts; - int cpt; - int rc; - int i; + struct kset *parent, + struct dentry *debugfs_entry) +{ + struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt; + struct ptlrpc_service *service; + struct ptlrpc_service_part *svcpt; + struct cfs_cpt_table *cptable; + __u32 *cpts = NULL; + int ncpts; + int cpt; + int rc; + int i; LASSERT(conf->psc_buf.bc_nbufs > 0); LASSERT(conf->psc_buf.bc_buf_size >= @@ -707,7 +707,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, } else { ncpts = cfs_cpt_number(cptable); if (cconf->cc_pattern != NULL) { - struct cfs_expr_list *el; + struct cfs_expr_list *el; rc = cfs_expr_list_parse(cconf->cc_pattern, strlen(cconf->cc_pattern), @@ -723,24 +723,23 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, if (rc <= 0) { CERROR("%s: failed to parse CPT array %s: %d\n", conf->psc_name, cconf->cc_pattern, rc); - if (cpts != NULL) - OBD_FREE(cpts, sizeof(*cpts) * ncpts); + kfree(cpts); return ERR_PTR(rc < 0 ? rc : -EINVAL); } ncpts = rc; } } - OBD_ALLOC(service, offsetof(struct ptlrpc_service, srv_parts[ncpts])); + service = kzalloc(offsetof(struct ptlrpc_service, srv_parts[ncpts]), + GFP_NOFS); if (service == NULL) { - if (cpts != NULL) - OBD_FREE(cpts, sizeof(*cpts) * ncpts); + kfree(cpts); return ERR_PTR(-ENOMEM); } - service->srv_cptable = cptable; - service->srv_cpts = cpts; - service->srv_ncpts = ncpts; + service->srv_cptable = cptable; + service->srv_cpts = cpts; + service->srv_ncpts = ncpts; service->srv_cpt_bits = 0; /* it's zero already, easy to read... */ while ((1 << service->srv_cpt_bits) < cfs_cpt_number(cptable)) @@ -748,18 +747,18 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, /* public members */ spin_lock_init(&service->srv_lock); - service->srv_name = conf->psc_name; - service->srv_watchdog_factor = conf->psc_watchdog_factor; + service->srv_name = conf->psc_name; + service->srv_watchdog_factor = conf->psc_watchdog_factor; INIT_LIST_HEAD(&service->srv_list); /* for safety of cleanup */ /* buffer configuration */ - service->srv_nbuf_per_group = test_req_buffer_pressure ? + service->srv_nbuf_per_group = test_req_buffer_pressure ? 1 : conf->psc_buf.bc_nbufs; - service->srv_max_req_size = conf->psc_buf.bc_req_max_size + + service->srv_max_req_size = conf->psc_buf.bc_req_max_size + SPTLRPC_MAX_PAYLOAD; - service->srv_buf_size = conf->psc_buf.bc_buf_size; - service->srv_rep_portal = conf->psc_buf.bc_rep_portal; - service->srv_req_portal = conf->psc_buf.bc_req_portal; + service->srv_buf_size = conf->psc_buf.bc_buf_size; + service->srv_rep_portal = conf->psc_buf.bc_rep_portal; + service->srv_req_portal = conf->psc_buf.bc_req_portal; /* Increase max reply size to next power of two */ service->srv_max_reply_size = 1; @@ -767,10 +766,10 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, conf->psc_buf.bc_rep_max_size + SPTLRPC_MAX_PAYLOAD) service->srv_max_reply_size <<= 1; - service->srv_thread_name = conf->psc_thr.tc_thr_name; - service->srv_ctx_tags = conf->psc_thr.tc_ctx_tags; - service->srv_hpreq_ratio = PTLRPC_SVC_HP_RATIO; - service->srv_ops = conf->psc_ops; + service->srv_thread_name = conf->psc_thr.tc_thr_name; + service->srv_ctx_tags = conf->psc_thr.tc_ctx_tags; + service->srv_hpreq_ratio = PTLRPC_SVC_HP_RATIO; + service->srv_ops = conf->psc_ops; for (i = 0; i < ncpts; i++) { if (!conf->psc_thr.tc_cpu_affinity) @@ -778,7 +777,8 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, else cpt = cpts != NULL ? cpts[i] : i; - OBD_CPT_ALLOC(svcpt, cptable, cpt, sizeof(*svcpt)); + svcpt = kzalloc_node(sizeof(*svcpt), GFP_NOFS, + cfs_cpt_spread_node(cptable, cpt)); if (svcpt == NULL) { rc = -ENOMEM; goto failed; @@ -799,8 +799,14 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, list_add(&service->srv_list, &ptlrpc_all_services); mutex_unlock(&ptlrpc_all_services_mutex); - if (proc_entry != NULL) - ptlrpc_lprocfs_register_service(proc_entry, service); + if (parent) { + rc = ptlrpc_sysfs_register_service(parent, service); + if (rc) + goto failed; + } + + if (!IS_ERR_OR_NULL(debugfs_entry)) + ptlrpc_ldebugfs_register_service(debugfs_entry, service); rc = ptlrpc_service_nrs_setup(service); if (rc != 0) @@ -853,11 +859,11 @@ static void ptlrpc_server_free_request(struct ptlrpc_request *req) void ptlrpc_server_drop_request(struct ptlrpc_request *req) { struct ptlrpc_request_buffer_desc *rqbd = req->rq_rqbd; - struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt; - struct ptlrpc_service *svc = svcpt->scp_service; - int refcount; - struct list_head *tmp; - struct list_head *nxt; + struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt; + struct ptlrpc_service *svc = svcpt->scp_service; + int refcount; + struct list_head *tmp; + struct list_head *nxt; if (!atomic_dec_and_test(&req->rq_refcount)) return; @@ -1304,7 +1310,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) reqcopy = ptlrpc_request_cache_alloc(GFP_NOFS); if (reqcopy == NULL) return -ENOMEM; - OBD_ALLOC_LARGE(reqmsg, req->rq_reqlen); + reqmsg = libcfs_kvzalloc(req->rq_reqlen, GFP_NOFS); if (!reqmsg) { rc = -ENOMEM; goto out_free; @@ -1368,7 +1374,7 @@ out_put: class_export_put(reqcopy->rq_export); out: sptlrpc_svc_ctx_decref(reqcopy); - OBD_FREE_LARGE(reqmsg, req->rq_reqlen); + kvfree(reqmsg); out_free: ptlrpc_request_cache_free(reqcopy); return rc; @@ -1381,7 +1387,7 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) struct ptlrpc_at_array *array = &svcpt->scp_at_array; struct ptlrpc_request *rq, *n; struct list_head work_list; - __u32 index, count; + __u32 index, count; time_t deadline; time_t now = get_seconds(); long delay; @@ -1726,10 +1732,10 @@ static int ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, struct ptlrpc_thread *thread) { - struct ptlrpc_service *svc = svcpt->scp_service; - struct ptlrpc_request *req; - __u32 deadline; - int rc; + struct ptlrpc_service *svc = svcpt->scp_service; + struct ptlrpc_request *req; + __u32 deadline; + int rc; spin_lock(&svcpt->scp_lock); if (list_empty(&svcpt->scp_req_incoming)) { @@ -1870,11 +1876,11 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, { struct ptlrpc_service *svc = svcpt->scp_service; struct ptlrpc_request *request; - struct timeval work_start; - struct timeval work_end; - long timediff; - int rc; - int fail_opc = 0; + struct timeval work_start; + struct timeval work_end; + long timediff; + int rc; + int fail_opc = 0; request = ptlrpc_server_request_get(svcpt, false); if (request == NULL) @@ -2026,10 +2032,10 @@ static int ptlrpc_handle_rs(struct ptlrpc_reply_state *rs) { struct ptlrpc_service_part *svcpt = rs->rs_svcpt; - struct ptlrpc_service *svc = svcpt->scp_service; - struct obd_export *exp; - int nlocks; - int been_handled; + struct ptlrpc_service *svc = svcpt->scp_service; + struct obd_export *exp; + int nlocks; + int been_handled; exp = rs->rs_export; @@ -2256,10 +2262,10 @@ ptlrpc_wait_event(struct ptlrpc_service_part *svcpt, */ static int ptlrpc_main(void *arg) { - struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg; - struct ptlrpc_service_part *svcpt = thread->t_svcpt; - struct ptlrpc_service *svc = svcpt->scp_service; - struct ptlrpc_reply_state *rs; + struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg; + struct ptlrpc_service_part *svcpt = thread->t_svcpt; + struct ptlrpc_service *svc = svcpt->scp_service; + struct ptlrpc_reply_state *rs; struct group_info *ginfo = NULL; struct lu_env *env; int counter = 0, rc = 0; @@ -2291,7 +2297,7 @@ static int ptlrpc_main(void *arg) goto out; } - OBD_ALLOC_PTR(env); + env = kzalloc(sizeof(*env), GFP_NOFS); if (env == NULL) { rc = -ENOMEM; goto out_srv_fini; @@ -2317,7 +2323,7 @@ static int ptlrpc_main(void *arg) } /* Alloc reply state structure for this one */ - OBD_ALLOC_LARGE(rs, svc->srv_max_reply_size); + rs = libcfs_kvzalloc(svc->srv_max_reply_size, GFP_NOFS); if (!rs) { rc = -ENOMEM; goto out_srv_fini; @@ -2414,7 +2420,7 @@ out_srv_fini: if (env != NULL) { lu_context_fini(&env->le_ctx); - OBD_FREE_PTR(env); + kfree(env); } out: CDEBUG(D_RPCTRACE, "service thread [ %p : %u ] %d exiting: rc %d\n", @@ -2458,11 +2464,11 @@ static int hrt_dont_sleep(struct ptlrpc_hr_thread *hrt, */ static int ptlrpc_hr_main(void *arg) { - struct ptlrpc_hr_thread *hrt = (struct ptlrpc_hr_thread *)arg; - struct ptlrpc_hr_partition *hrp = hrt->hrt_partition; - LIST_HEAD (replies); - char threadname[20]; - int rc; + struct ptlrpc_hr_thread *hrt = (struct ptlrpc_hr_thread *)arg; + struct ptlrpc_hr_partition *hrp = hrt->hrt_partition; + LIST_HEAD (replies); + char threadname[20]; + int rc; snprintf(threadname, sizeof(threadname), "ptlrpc_hr%02d_%03d", hrp->hrp_cpt, hrt->hrt_id); @@ -2499,9 +2505,9 @@ static int ptlrpc_hr_main(void *arg) static void ptlrpc_stop_hr_threads(void) { - struct ptlrpc_hr_partition *hrp; - int i; - int j; + struct ptlrpc_hr_partition *hrp; + int i; + int j; ptlrpc_hr.hr_stopping = 1; @@ -2523,12 +2529,12 @@ static void ptlrpc_stop_hr_threads(void) static int ptlrpc_start_hr_threads(void) { - struct ptlrpc_hr_partition *hrp; - int i; - int j; + struct ptlrpc_hr_partition *hrp; + int i; + int j; cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { - int rc = 0; + int rc = 0; for (j = 0; j < hrp->hrp_nthrs; j++) { struct ptlrpc_hr_thread *hrt = &hrp->hrp_thrs[j]; @@ -2555,9 +2561,9 @@ static int ptlrpc_start_hr_threads(void) static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) { - struct l_wait_info lwi = { 0 }; - struct ptlrpc_thread *thread; - LIST_HEAD (zombie); + struct l_wait_info lwi = { 0 }; + struct ptlrpc_thread *thread; + LIST_HEAD (zombie); CDEBUG(D_INFO, "Stopping threads for service %s\n", svcpt->scp_service->srv_name); @@ -2596,7 +2602,7 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) thread = list_entry(zombie.next, struct ptlrpc_thread, t_link); list_del(&thread->t_link); - OBD_FREE_PTR(thread); + kfree(thread); } } @@ -2606,7 +2612,7 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) void ptlrpc_stop_all_threads(struct ptlrpc_service *svc) { struct ptlrpc_service_part *svcpt; - int i; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) { if (svcpt->scp_service != NULL) @@ -2617,9 +2623,9 @@ EXPORT_SYMBOL(ptlrpc_stop_all_threads); int ptlrpc_start_threads(struct ptlrpc_service *svc) { - int rc = 0; - int i; - int j; + int rc = 0; + int i; + int j; /* We require 2 threads min, see note in ptlrpc_server_handle_request */ LASSERT(svc->srv_nthrs_cpt_init >= PTLRPC_NTHRS_INIT); @@ -2648,10 +2654,10 @@ EXPORT_SYMBOL(ptlrpc_start_threads); int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) { - struct l_wait_info lwi = { 0 }; - struct ptlrpc_thread *thread; - struct ptlrpc_service *svc; - int rc; + struct l_wait_info lwi = { 0 }; + struct ptlrpc_thread *thread; + struct ptlrpc_service *svc; + int rc; LASSERT(svcpt != NULL); @@ -2670,7 +2676,9 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) svcpt->scp_nthrs_running == svc->srv_nthrs_cpt_init - 1)) return -EMFILE; - OBD_CPT_ALLOC_PTR(thread, svc->srv_cptable, svcpt->scp_cpt); + thread = kzalloc_node(sizeof(*thread), GFP_NOFS, + cfs_cpt_spread_node(svc->srv_cptable, + svcpt->scp_cpt)); if (thread == NULL) return -ENOMEM; init_waitqueue_head(&thread->t_ctl_waitq); @@ -2678,7 +2686,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) spin_lock(&svcpt->scp_lock); if (!ptlrpc_threads_increasable(svcpt)) { spin_unlock(&svcpt->scp_lock); - OBD_FREE_PTR(thread); + kfree(thread); return -EMFILE; } @@ -2687,7 +2695,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) * might require unique and contiguous t_id */ LASSERT(svcpt->scp_nthrs_starting == 1); spin_unlock(&svcpt->scp_lock); - OBD_FREE_PTR(thread); + kfree(thread); if (wait) { CDEBUG(D_INFO, "Waiting for creating thread %s #%d\n", svc->srv_thread_name, svcpt->scp_thr_nextid); @@ -2733,7 +2741,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) } else { list_del(&thread->t_link); spin_unlock(&svcpt->scp_lock); - OBD_FREE_PTR(thread); + kfree(thread); } return rc; } @@ -2751,12 +2759,12 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) int ptlrpc_hr_init(void) { - struct ptlrpc_hr_partition *hrp; - struct ptlrpc_hr_thread *hrt; - int rc; - int i; - int j; - int weight; + struct ptlrpc_hr_partition *hrp; + struct ptlrpc_hr_thread *hrt; + int rc; + int i; + int j; + int weight; memset(&ptlrpc_hr, 0, sizeof(ptlrpc_hr)); ptlrpc_hr.hr_cpt_table = cfs_cpt_table; @@ -2768,7 +2776,7 @@ int ptlrpc_hr_init(void) init_waitqueue_head(&ptlrpc_hr.hr_waitq); - weight = cpumask_weight(topology_thread_cpumask(0)); + weight = cpumask_weight(topology_sibling_cpumask(0)); cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { hrp->hrp_cpt = i; @@ -2780,8 +2788,10 @@ int ptlrpc_hr_init(void) hrp->hrp_nthrs /= weight; LASSERT(hrp->hrp_nthrs > 0); - OBD_CPT_ALLOC(hrp->hrp_thrs, ptlrpc_hr.hr_cpt_table, i, - hrp->hrp_nthrs * sizeof(*hrt)); + hrp->hrp_thrs = + kzalloc_node(hrp->hrp_nthrs * sizeof(*hrt), GFP_NOFS, + cfs_cpt_spread_node(ptlrpc_hr.hr_cpt_table, + i)); if (hrp->hrp_thrs == NULL) { rc = -ENOMEM; goto out; @@ -2807,8 +2817,8 @@ out: void ptlrpc_hr_fini(void) { - struct ptlrpc_hr_partition *hrp; - int i; + struct ptlrpc_hr_partition *hrp; + int i; if (ptlrpc_hr.hr_partitions == NULL) return; @@ -2817,8 +2827,7 @@ void ptlrpc_hr_fini(void) cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { if (hrp->hrp_thrs != NULL) { - OBD_FREE(hrp->hrp_thrs, - hrp->hrp_nthrs * sizeof(hrp->hrp_thrs[0])); + kfree(hrp->hrp_thrs); } } @@ -2849,8 +2858,8 @@ static void ptlrpc_wait_replies(struct ptlrpc_service_part *svcpt) static void ptlrpc_service_del_atimer(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; - int i; + struct ptlrpc_service_part *svcpt; + int i; /* early disarm AT timer... */ ptlrpc_service_for_each_part(svcpt, i, svc) { @@ -2862,11 +2871,11 @@ ptlrpc_service_del_atimer(struct ptlrpc_service *svc) static void ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; + struct ptlrpc_service_part *svcpt; struct ptlrpc_request_buffer_desc *rqbd; - struct l_wait_info lwi; - int rc; - int i; + struct l_wait_info lwi; + int rc; + int i; /* All history will be culled when the next request buffer is * freed in ptlrpc_service_purge_all() */ @@ -2918,11 +2927,11 @@ ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc) static void ptlrpc_service_purge_all(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; - struct ptlrpc_request_buffer_desc *rqbd; - struct ptlrpc_request *req; - struct ptlrpc_reply_state *rs; - int i; + struct ptlrpc_service_part *svcpt; + struct ptlrpc_request_buffer_desc *rqbd; + struct ptlrpc_request *req; + struct ptlrpc_reply_state *rs; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) { if (svcpt->scp_service == NULL) @@ -2978,7 +2987,7 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) struct ptlrpc_reply_state, rs_list); list_del(&rs->rs_list); - OBD_FREE_LARGE(rs, svc->srv_max_reply_size); + kvfree(rs); } } } @@ -2986,9 +2995,9 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) static void ptlrpc_service_free(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; - struct ptlrpc_at_array *array; - int i; + struct ptlrpc_service_part *svcpt; + struct ptlrpc_at_array *array; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) { if (svcpt->scp_service == NULL) @@ -2998,27 +3007,19 @@ ptlrpc_service_free(struct ptlrpc_service *svc) cfs_timer_disarm(&svcpt->scp_at_timer); array = &svcpt->scp_at_array; - if (array->paa_reqs_array != NULL) { - OBD_FREE(array->paa_reqs_array, - sizeof(struct list_head) * array->paa_size); - array->paa_reqs_array = NULL; - } - - if (array->paa_reqs_count != NULL) { - OBD_FREE(array->paa_reqs_count, - sizeof(__u32) * array->paa_size); - array->paa_reqs_count = NULL; - } + kfree(array->paa_reqs_array); + array->paa_reqs_array = NULL; + kfree(array->paa_reqs_count); + array->paa_reqs_count = NULL; } ptlrpc_service_for_each_part(svcpt, i, svc) - OBD_FREE_PTR(svcpt); + kfree(svcpt); if (svc->srv_cpts != NULL) cfs_expr_list_values_free(svc->srv_cpts, svc->srv_ncpts); - OBD_FREE(svc, offsetof(struct ptlrpc_service, - srv_parts[svc->srv_ncpts])); + kfree(svc); } int ptlrpc_unregister_service(struct ptlrpc_service *service) @@ -3039,6 +3040,7 @@ int ptlrpc_unregister_service(struct ptlrpc_service *service) ptlrpc_service_nrs_cleanup(service); ptlrpc_lprocfs_unregister_service(service); + ptlrpc_sysfs_unregister_service(service); ptlrpc_service_free(service); @@ -3054,9 +3056,9 @@ EXPORT_SYMBOL(ptlrpc_unregister_service); * to be shot, so it's intentionally non-aggressive. */ int ptlrpc_svcpt_health_check(struct ptlrpc_service_part *svcpt) { - struct ptlrpc_request *request = NULL; - struct timeval right_now; - long timediff; + struct ptlrpc_request *request = NULL; + struct timeval right_now; + long timediff; do_gettimeofday(&right_now); @@ -3088,8 +3090,8 @@ int ptlrpc_svcpt_health_check(struct ptlrpc_service_part *svcpt) int ptlrpc_service_health_check(struct ptlrpc_service *svc) { - struct ptlrpc_service_part *svcpt; - int i; + struct ptlrpc_service_part *svcpt; + int i; if (svc == NULL) return 0; |