diff options
Diffstat (limited to 'drivers/staging/lustre/lustre')
60 files changed, 627 insertions, 752 deletions
diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h b/drivers/staging/lustre/lustre/fid/fid_internal.h index eb607c52ef3b..b5e8da8956f2 100644 --- a/drivers/staging/lustre/lustre/fid/fid_internal.h +++ b/drivers/staging/lustre/lustre/fid/fid_internal.h @@ -47,7 +47,7 @@ int seq_client_alloc_super(struct lu_client_seq *seq, const struct lu_env *env); -#if defined (CONFIG_PROC_FS) +#if defined(CONFIG_PROC_FS) extern struct lprocfs_vars seq_client_proc_list[]; #endif diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 64b1d80c64b0..063441abfcfc 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -402,7 +402,7 @@ EXPORT_SYMBOL(seq_client_flush); static void seq_client_proc_fini(struct lu_client_seq *seq) { -#if defined (CONFIG_PROC_FS) +#if defined(CONFIG_PROC_FS) if (seq->lcs_proc_dir) { if (!IS_ERR(seq->lcs_proc_dir)) lprocfs_remove(&seq->lcs_proc_dir); @@ -413,7 +413,7 @@ static void seq_client_proc_fini(struct lu_client_seq *seq) static int seq_client_proc_init(struct lu_client_seq *seq) { -#if defined (CONFIG_PROC_FS) +#if defined(CONFIG_PROC_FS) int rc; seq->lcs_proc_dir = lprocfs_register(seq->lcs_name, diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index 5d95d0b358b8..0d0a73745065 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -257,9 +257,9 @@ void fld_cache_flush(struct fld_cache *cache) * entry accordingly. */ -void fld_cache_punch_hole(struct fld_cache *cache, - struct fld_cache_entry *f_curr, - struct fld_cache_entry *f_new) +static void fld_cache_punch_hole(struct fld_cache *cache, + struct fld_cache_entry *f_curr, + struct fld_cache_entry *f_new) { const struct lu_seq_range *range = &f_new->fce_range; const u64 new_start = range->lsr_start; diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h index 8806b6096953..6125bbe822b5 100644 --- a/drivers/staging/lustre/lustre/fld/fld_internal.h +++ b/drivers/staging/lustre/lustre/fld/fld_internal.h @@ -111,7 +111,7 @@ struct fld_cache { /** * Cache name used for debug and messages. */ - char fci_name[80]; + char fci_name[LUSTRE_MDT_MAXNAMELEN]; unsigned int fci_no_shrink:1; }; diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 0d361ff43212..b8d17e109a96 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -131,11 +131,20 @@ fld_rrb_scan(struct lu_client_fld *fld, u64 seq) else hash = 0; +again: list_for_each_entry(target, &fld->lcf_targets, ft_chain) { if (target->ft_idx == hash) return target; } + if (hash != 0) { + /* It is possible the remote target(MDT) are not connected to + * with client yet, so we will refer this to MDT0, which should + * be connected during mount */ + hash = 0; + goto again; + } + CERROR("%s: Can't find target by hash %d (seq %#llx). Targets (%d):\n", fld->lcf_name, hash, seq, fld->lcf_count); @@ -269,7 +278,7 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) } EXPORT_SYMBOL(fld_client_del_target); -struct proc_dir_entry *fld_type_proc_dir = NULL; +static struct proc_dir_entry *fld_type_proc_dir; #if defined (CONFIG_PROC_FS) static int fld_client_proc_init(struct lu_client_fld *fld) diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index 95e7de18d2f1..8c5a65704a37 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -87,13 +87,21 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused) } static ssize_t -fld_proc_hash_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +fld_proc_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; + char fh_name[8]; int i; + if (count > sizeof(fh_name)) + return -ENAMETOOLONG; + + if (copy_from_user(fh_name, buffer, count) != 0) + return -EFAULT; + fld = ((struct seq_file *)file->private_data)->private; LASSERT(fld != NULL); @@ -101,7 +109,7 @@ fld_proc_hash_seq_write(struct file *file, const char *buffer, if (count != strlen(fld_hash[i].fh_name)) continue; - if (!strncmp(fld_hash[i].fh_name, buffer, count)) { + if (!strncmp(fld_hash[i].fh_name, fh_name, count)) { hash = &fld_hash[i]; break; } @@ -146,7 +154,7 @@ static int fld_proc_cache_flush_release(struct inode *inode, struct file *file) return 0; } -struct file_operations fld_proc_cache_flush_fops = { +static struct file_operations fld_proc_cache_flush_fops = { .owner = THIS_MODULE, .open = fld_proc_cache_flush_open, .write = fld_proc_cache_flush_write, diff --git a/drivers/staging/lustre/lustre/include/lclient.h b/drivers/staging/lustre/lustre/include/lclient.h index b3b841f4d6e6..c5c3a8d9eaa4 100644 --- a/drivers/staging/lustre/lustre/include/lclient.h +++ b/drivers/staging/lustre/lustre/include/lclient.h @@ -135,6 +135,7 @@ static inline struct ccc_thread_info *ccc_env_info(const struct lu_env *env) static inline struct cl_attr *ccc_env_thread_attr(const struct lu_env *env) { struct cl_attr *attr = &ccc_env_info(env)->cti_attr; + memset(attr, 0, sizeof(*attr)); return attr; } @@ -142,6 +143,7 @@ static inline struct cl_attr *ccc_env_thread_attr(const struct lu_env *env) static inline struct cl_io *ccc_env_thread_io(const struct lu_env *env) { struct cl_io *io = &ccc_env_info(env)->cti_io; + memset(io, 0, sizeof(*io)); return io; } @@ -323,6 +325,7 @@ void ccc_lock_fini(const struct lu_env *env, struct cl_lock_slice *slice); int ccc_lock_enqueue(const struct lu_env *env, const struct cl_lock_slice *slice, struct cl_io *io, __u32 enqflags); +int ccc_lock_use(const struct lu_env *env, const struct cl_lock_slice *slice); int ccc_lock_unuse(const struct lu_env *env, const struct cl_lock_slice *slice); int ccc_lock_wait(const struct lu_env *env, const struct cl_lock_slice *slice); int ccc_lock_fits_into(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index cfe503b7df62..8a25cf6f6825 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -627,16 +627,16 @@ struct adaptive_timeout; extern int lprocfs_at_hist_helper(struct seq_file *m, struct adaptive_timeout *at); extern int lprocfs_rd_timeouts(struct seq_file *m, void *data); -extern int lprocfs_wr_timeouts(struct file *file, const char *buffer, +extern int lprocfs_wr_timeouts(struct file *file, const char __user *buffer, unsigned long count, void *data); -extern int lprocfs_wr_evict_client(struct file *file, const char *buffer, +extern int lprocfs_wr_evict_client(struct file *file, const char __user *buffer, size_t count, loff_t *off); -extern int lprocfs_wr_ping(struct file *file, const char *buffer, +extern int lprocfs_wr_ping(struct file *file, const char __user *buffer, size_t count, loff_t *off); -extern int lprocfs_wr_import(struct file *file, const char *buffer, +extern int lprocfs_wr_import(struct file *file, const char __user *buffer, size_t count, loff_t *off); extern int lprocfs_rd_pinger_recov(struct seq_file *m, void *n); -extern int lprocfs_wr_pinger_recov(struct file *file, const char *buffer, +extern int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, size_t count, loff_t *off); /* Statfs helpers */ @@ -650,8 +650,8 @@ 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); extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult); -extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count, - __u64 *val); +extern int lprocfs_write_u64_helper(const char __user *buffer, + unsigned long count, __u64 *val); extern int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count, __u64 *val, int mult); @@ -716,7 +716,8 @@ static struct file_operations name##_fops = { \ return lprocfs_rd_##type(m, m->private); \ } \ static ssize_t name##_##type##_seq_write(struct file *file, \ - const char *buffer, size_t count, loff_t *off) \ + const char __user *buffer, size_t count, \ + loff_t *off) \ { \ struct seq_file *seq = file->private_data; \ return lprocfs_wr_##type(file, buffer, \ @@ -726,7 +727,8 @@ static struct file_operations name##_fops = { \ #define LPROC_SEQ_FOPS_WR_ONLY(name, type) \ static ssize_t name##_##type##_write(struct file *file, \ - const char *buffer, size_t count, loff_t *off) \ + const char __user *buffer, size_t count, \ + loff_t *off) \ { \ return lprocfs_wr_##type(file, buffer, count, off); \ } \ @@ -939,20 +941,24 @@ static inline int lprocfs_at_hist_helper(struct seq_file *m, 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 *buffer, - unsigned long count, void *data) + const char __user *buffer, + unsigned long count, void *data) { return 0; } -static inline int lprocfs_wr_evict_client(struct file *file, const char *buffer, - size_t count, loff_t *off) +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 *buffer, - size_t count, loff_t *off) +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 *buffer, - size_t count, loff_t *off) +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 *buffer, - size_t count, loff_t *off) +static inline int lprocfs_wr_pinger_recov(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { return 0; } /* Statfs helpers */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 7b7457cf70e3..305ecbee9b78 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -105,6 +105,11 @@ * FOO_BULK_PORTAL is for incoming bulk on the FOO */ +/* Lustre service names are following the format + * service name + MDT + seq name + */ +#define LUSTRE_MDT_MAXNAMELEN 80 + #define CONNMGR_REQUEST_PORTAL 1 #define CONNMGR_REPLY_PORTAL 2 //#define OSC_REQUEST_PORTAL 3 diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index 2d6fbb4b1b39..0a0929fd9023 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -358,7 +358,7 @@ struct lu_client_seq { * Service uuid, passed from MDT + seq name to form unique seq name to * use it with procfs. */ - char lcs_name[80]; + char lcs_name[LUSTRE_MDT_MAXNAMELEN]; /* * Sequence width, that is how many objects may be allocated in one @@ -408,7 +408,7 @@ struct lu_server_seq { * Service uuid, passed from MDT + seq name to form unique seq name to * use it with procfs. */ - char lss_name[80]; + char lss_name[LUSTRE_MDT_MAXNAMELEN]; /* * Allocation chunks for super and meta sequences. Default values are diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index 64c504849a22..5ee4b1ed0995 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/drivers/staging/lustre/lustre/include/lustre_fld.h @@ -93,7 +93,7 @@ struct lu_server_fld { /** * Fld service name in form "fld-srv-lustre-MDTXXX" */ - char lsf_name[80]; + char lsf_name[LUSTRE_MDT_MAXNAMELEN]; }; @@ -124,7 +124,7 @@ struct lu_client_fld { /** * Client fld proc entry name. */ - char lcf_name[80]; + char lcf_name[LUSTRE_MDT_MAXNAMELEN]; int lcf_flags; }; diff --git a/drivers/staging/lustre/lustre/include/lustre_update.h b/drivers/staging/lustre/lustre/include/lustre_update.h deleted file mode 100644 index 84defce0f623..000000000000 --- a/drivers/staging/lustre/lustre/include/lustre_update.h +++ /dev/null @@ -1,189 +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.gnu.org/licenses/gpl-2.0.htm - * - * GPL HEADER END - */ -/* - * Copyright (c) 2013, Intel Corporation. - */ -/* - * lustre/include/lustre_update.h - * - * Author: Di Wang <di.wang@intel.com> - */ - -#ifndef _LUSTRE_UPDATE_H -#define _LUSTRE_UPDATE_H - -#define UPDATE_BUFFER_SIZE 8192 -struct update_request { - struct dt_device *ur_dt; - struct list_head ur_list; /* attached itself to thandle */ - int ur_flags; - int ur_rc; /* request result */ - int ur_batchid; /* Current batch(trans) id */ - struct update_buf *ur_buf; /* Holding the update req */ -}; - -static inline unsigned long update_size(struct update *update) -{ - unsigned long size; - int i; - - size = cfs_size_round(offsetof(struct update, u_bufs[0])); - for (i = 0; i < UPDATE_BUF_COUNT; i++) - size += cfs_size_round(update->u_lens[i]); - - return size; -} - -static inline void *update_param_buf(struct update *update, int index, - int *size) -{ - int i; - void *ptr; - - if (index >= UPDATE_BUF_COUNT) - return NULL; - - ptr = (char *)update + cfs_size_round(offsetof(struct update, - u_bufs[0])); - for (i = 0; i < index; i++) { - LASSERT(update->u_lens[i] > 0); - ptr += cfs_size_round(update->u_lens[i]); - } - - if (size != NULL) - *size = update->u_lens[index]; - - return ptr; -} - -static inline unsigned long update_buf_size(struct update_buf *buf) -{ - unsigned long size; - int i = 0; - - size = cfs_size_round(offsetof(struct update_buf, ub_bufs[0])); - for (i = 0; i < buf->ub_count; i++) { - struct update *update; - - update = (struct update *)((char *)buf + size); - size += update_size(update); - } - LASSERT(size <= UPDATE_BUFFER_SIZE); - return size; -} - -static inline void *update_buf_get(struct update_buf *buf, int index, int *size) -{ - int count = buf->ub_count; - void *ptr; - int i = 0; - - if (index >= count) - return NULL; - - ptr = (char *)buf + cfs_size_round(offsetof(struct update_buf, - ub_bufs[0])); - for (i = 0; i < index; i++) - ptr += update_size((struct update *)ptr); - - if (size != NULL) - *size = update_size((struct update *)ptr); - - return ptr; -} - -static inline void update_init_reply_buf(struct update_reply *reply, int count) -{ - reply->ur_version = UPDATE_REPLY_V1; - reply->ur_count = count; -} - -static inline void *update_get_buf_internal(struct update_reply *reply, - int index, int *size) -{ - char *ptr; - int count = reply->ur_count; - int i; - - if (index >= count) - return NULL; - - ptr = (char *)reply + cfs_size_round(offsetof(struct update_reply, - ur_lens[count])); - for (i = 0; i < index; i++) { - LASSERT(reply->ur_lens[i] > 0); - ptr += cfs_size_round(reply->ur_lens[i]); - } - - if (size != NULL) - *size = reply->ur_lens[index]; - - return ptr; -} - -static inline void update_insert_reply(struct update_reply *reply, void *data, - int data_len, int index, int rc) -{ - char *ptr; - - ptr = update_get_buf_internal(reply, index, NULL); - LASSERT(ptr != NULL); - - *(int *)ptr = cpu_to_le32(rc); - ptr += sizeof(int); - if (data_len > 0) { - LASSERT(data != NULL); - memcpy(ptr, data, data_len); - } - reply->ur_lens[index] = data_len + sizeof(int); -} - -static inline int update_get_reply_buf(struct update_reply *reply, void **buf, - int index) -{ - char *ptr; - int size = 0; - int result; - - ptr = update_get_buf_internal(reply, index, &size); - result = *(int *)ptr; - - if (result < 0) - return result; - - LASSERT((ptr != NULL && size >= sizeof(int))); - *buf = ptr + sizeof(int); - return size - sizeof(int); -} - -static inline int update_get_reply_result(struct update_reply *reply, - void **buf, int index) -{ - void *ptr; - int size; - - ptr = update_get_buf_internal(reply, index, &size); - LASSERT(ptr != NULL && size > sizeof(int)); - return *(int *)ptr; -} - -#endif diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 24d26ab35346..23095bb75226 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -586,6 +586,12 @@ int ccc_lock_enqueue(const struct lu_env *env, return 0; } +int ccc_lock_use(const struct lu_env *env, const struct cl_lock_slice *slice) +{ + CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj)); + return 0; +} + int ccc_lock_unuse(const struct lu_env *env, const struct cl_lock_slice *slice) { CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj)); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 6c6c57ca91de..20e64cddb1f4 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -249,8 +249,9 @@ typedef enum ldlm_policy_res ldlm_policy_res_t; struct __##var##__dummy_read {; } /* semicolon catcher */ #define LDLM_POOL_PROC_WRITER(var, type) \ - static int lprocfs_wr_##var(struct file *file, const char *buffer, \ - unsigned long count, void *data) \ + static int lprocfs_wr_##var(struct file *file, \ + const char __user *buffer, \ + unsigned long count, void *data) \ { \ struct ldlm_pool *pl = data; \ type tmp; \ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 4c838f615a64..d20d277dc2f7 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -470,6 +470,7 @@ static void ldlm_cli_pool_pop_slv(struct ldlm_pool *pl) static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) { time_t recalc_interval_sec; + int ret; recalc_interval_sec = get_seconds() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) @@ -490,16 +491,15 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) */ ldlm_cli_pool_pop_slv(pl); - pl->pl_recalc_time = get_seconds(); - lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT, - recalc_interval_sec); spin_unlock(&pl->pl_lock); /* * Do not cancel locks in case lru resize is disabled for this ns. */ - if (!ns_connect_lru_resize(ldlm_pl2ns(pl))) - return 0; + if (!ns_connect_lru_resize(ldlm_pl2ns(pl))) { + ret = 0; + goto out; + } /* * In the time of canceling locks on client we do not need to maintain @@ -507,7 +507,19 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) * It may be called when SLV has changed much, this is why we do not * take into account pl->pl_recalc_time here. */ - return ldlm_cancel_lru(ldlm_pl2ns(pl), 0, LCF_ASYNC, LDLM_CANCEL_LRUR); + ret = ldlm_cancel_lru(ldlm_pl2ns(pl), 0, LCF_ASYNC, LDLM_CANCEL_LRUR); + +out: + spin_lock(&pl->pl_lock); + /* + * Time of LRU resizing might be longer than period, + * so update after LRU resizing rather than before it. + */ + pl->pl_recalc_time = get_seconds(); + lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT, + recalc_interval_sec); + spin_unlock(&pl->pl_lock); + return ret; } /** @@ -591,6 +603,14 @@ int ldlm_pool_recalc(struct ldlm_pool *pl) } recalc_interval_sec = pl->pl_recalc_time - get_seconds() + pl->pl_recalc_period; + if (recalc_interval_sec <= 0) { + /* Prevent too frequent recalculation. */ + CDEBUG(D_DLMTRACE, "Negative interval(%ld), " + "too short period(%ld)", + recalc_interval_sec, + pl->pl_recalc_period); + recalc_interval_sec = 1; + } return recalc_interval_sec; } @@ -697,8 +717,8 @@ LPROC_SEQ_FOPS_RO(lprocfs_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 *buf, size_t len, - loff_t *off) + const char __user *buf, + size_t len, loff_t *off) { struct seq_file *seq = file->private_data; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 1f150e46f50e..c6f62a91b233 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -72,7 +72,7 @@ extern unsigned int ldlm_cancel_unused_locks_before_replay; unsigned int ldlm_dump_granted_max = 256; #if defined(CONFIG_PROC_FS) -static ssize_t lprocfs_wr_dump_ns(struct file *file, const char *buffer, +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); @@ -287,8 +287,9 @@ static int lprocfs_elc_seq_show(struct seq_file *m, void *v) return lprocfs_rd_uint(m, &supp); } -static ssize_t lprocfs_elc_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t lprocfs_elc_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private; unsigned int supp = -1; diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index a7a7ac626aaf..76c62e87a415 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -57,7 +57,7 @@ module_param(libcfs_debug, int, 0644); MODULE_PARM_DESC(libcfs_debug, "Lustre kernel debug mask"); EXPORT_SYMBOL(libcfs_debug); -unsigned int libcfs_debug_mb = 0; +static unsigned int libcfs_debug_mb; module_param(libcfs_debug_mb, uint, 0644); MODULE_PARM_DESC(libcfs_debug_mb, "Total debug buffer size."); EXPORT_SYMBOL(libcfs_debug_mb); @@ -93,7 +93,7 @@ EXPORT_SYMBOL(libcfs_debug_binary); unsigned int libcfs_stack = 3 * THREAD_SIZE / 4; EXPORT_SYMBOL(libcfs_stack); -unsigned int portal_enter_debugger; +static unsigned int portal_enter_debugger; EXPORT_SYMBOL(portal_enter_debugger); unsigned int libcfs_catastrophe; @@ -115,7 +115,7 @@ static wait_queue_head_t debug_ctlwq; char libcfs_debug_file_path_arr[PATH_MAX] = LIBCFS_DEBUG_FILE_PATH_DEFAULT; /* We need to pass a pointer here, but elsewhere this must be a const */ -char *libcfs_debug_file_path; +static char *libcfs_debug_file_path; module_param(libcfs_debug_file_path, charp, 0644); MODULE_PARM_DESC(libcfs_debug_file_path, "Path for dumping debug logs, set 'NONE' to prevent log dumping"); @@ -124,7 +124,7 @@ int libcfs_panic_in_progress; /* libcfs_debug_token2mask() expects the returned * string in lower-case */ -const char * +static const char * libcfs_debug_subsys2str(int subsys) { switch (1 << subsys) { @@ -185,7 +185,7 @@ libcfs_debug_subsys2str(int subsys) /* libcfs_debug_token2mask() expects the returned * string in lower-case */ -const char * +static const char * libcfs_debug_dbg2str(int debug) { switch (1 << debug) { @@ -350,7 +350,7 @@ void libcfs_debug_dumplog_internal(void *arg) current->journal_info = journal_info; } -int libcfs_debug_dumplog_thread(void *arg) +static int libcfs_debug_dumplog_thread(void *arg) { libcfs_debug_dumplog_internal(arg); wake_up(&debug_ctlwq); diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index 2d1e6729e996..ec3a2a8b8b2c 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -126,18 +126,21 @@ cfs_hash_nl_unlock(union cfs_hash_lock *lock, int exclusive) {} static inline void cfs_hash_spin_lock(union cfs_hash_lock *lock, int exclusive) + __acquires(&lock->spin) { spin_lock(&lock->spin); } static inline void cfs_hash_spin_unlock(union cfs_hash_lock *lock, int exclusive) + __releases(&lock->spin) { spin_unlock(&lock->spin); } static inline void cfs_hash_rw_lock(union cfs_hash_lock *lock, int exclusive) + __acquires(&lock->rw) { if (!exclusive) read_lock(&lock->rw); @@ -147,6 +150,7 @@ cfs_hash_rw_lock(union cfs_hash_lock *lock, int exclusive) static inline void cfs_hash_rw_unlock(union cfs_hash_lock *lock, int exclusive) + __releases(&lock->rw) { if (!exclusive) read_unlock(&lock->rw); @@ -1580,7 +1584,7 @@ cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, stop_on_change = cfs_hash_with_rehash_key(hs) || !cfs_hash_with_no_itemref(hs) || - CFS_HOP(hs, put_locked) == NULL; + hs->hs_ops->hs_put_locked == NULL; cfs_hash_lock(hs, 0); LASSERT(!cfs_hash_is_rehashing(hs)); @@ -1635,9 +1639,9 @@ cfs_hash_for_each_nolock(struct cfs_hash *hs, !cfs_hash_with_no_itemref(hs)) return -EOPNOTSUPP; - if (CFS_HOP(hs, get) == NULL || - (CFS_HOP(hs, put) == NULL && - CFS_HOP(hs, put_locked) == NULL)) + if (hs->hs_ops->hs_get == NULL || + (hs->hs_ops->hs_put == NULL && + hs->hs_ops->hs_put_locked == NULL)) return -EOPNOTSUPP; cfs_hash_for_each_enter(hs); @@ -1667,9 +1671,9 @@ cfs_hash_for_each_empty(struct cfs_hash *hs, if (cfs_hash_with_no_lock(hs)) return -EOPNOTSUPP; - if (CFS_HOP(hs, get) == NULL || - (CFS_HOP(hs, put) == NULL && - CFS_HOP(hs, put_locked) == NULL)) + if (hs->hs_ops->hs_get == NULL || + (hs->hs_ops->hs_put == NULL && + hs->hs_ops->hs_put_locked == NULL)) return -EOPNOTSUPP; cfs_hash_for_each_enter(hs); diff --git a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c index e2aa637abcf9..d9b7c6b69db4 100644 --- a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c +++ b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c @@ -228,12 +228,12 @@ int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func, if (kkuc_groups[group].next == NULL) return 0; - down_read(&kg_sem); + down_write(&kg_sem); list_for_each_entry(reg, &kkuc_groups[group], kr_chain) { if (reg->kr_fp != NULL) rc = cb_func(reg->kr_data, cb_arg); } - up_read(&kg_sem); + up_write(&kg_sem); return rc; } diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c index fb88733607a9..76d4392bd282 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c @@ -47,7 +47,7 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), int *oldmask, int minmask, int allmask) { const char *debugstr; - char op = 0; + char op = '\0'; int newmask = minmask, i, len, found = 0; /* <str> must be a list of tokens separated by whitespace @@ -55,10 +55,10 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), * appears first in <str>, '*oldmask' is used as the starting point * (relative), otherwise minmask is used (absolute). An operator * applies to all following tokens up to the next operator. */ - while (*str != 0) { + while (*str != '\0') { while (isspace(*str)) str++; - if (*str == 0) + if (*str == '\0') break; if (*str == '+' || *str == '-') { op = *str++; @@ -67,13 +67,15 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), newmask = *oldmask; while (isspace(*str)) str++; - if (*str == 0) /* trailing op */ + if (*str == '\0') /* trailing op */ return -EINVAL; } /* find token length */ - for (len = 0; str[len] != 0 && !isspace(str[len]) && - str[len] != '+' && str[len] != '-'; len++); + len = 0; + while (str[len] != '\0' && !isspace(str[len]) && + str[len] != '+' && str[len] != '-') + len++; /* match token */ found = 0; @@ -132,7 +134,7 @@ char *cfs_firststr(char *str, size_t size) ++end; } - *end= '\0'; + *end = '\0'; out: return str; } diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index d71ad5ed1f6d..277f6b890e09 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -82,17 +82,12 @@ int cfs_cap_raised(cfs_cap_t cap) return cap_raised(current_cap(), cap); } -void cfs_kernel_cap_pack(kernel_cap_t kcap, cfs_cap_t *cap) +static void cfs_kernel_cap_pack(kernel_cap_t kcap, cfs_cap_t *cap) { /* XXX lost high byte */ *cap = kcap.cap[0]; } -void cfs_kernel_cap_unpack(kernel_cap_t *kcap, cfs_cap_t cap) -{ - kcap->cap[0] = cap; -} - cfs_cap_t cfs_curproc_cap_pack(void) { cfs_cap_t cap; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c index 83d3f08a37b2..c539e3741583 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c @@ -232,8 +232,9 @@ static int proc_debug_mb(struct ctl_table *table, int write, __proc_debug_mb); } -int proc_console_max_delay_cs(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) +static int proc_console_max_delay_cs(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, + loff_t *ppos) { int rc, max_delay_cs; struct ctl_table dummy = *table; @@ -264,8 +265,9 @@ int proc_console_max_delay_cs(struct ctl_table *table, int write, return rc; } -int proc_console_min_delay_cs(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) +static int proc_console_min_delay_cs(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, + loff_t *ppos) { int rc, min_delay_cs; struct ctl_table dummy = *table; @@ -296,8 +298,8 @@ int proc_console_min_delay_cs(struct ctl_table *table, int write, return rc; } -int proc_console_backoff(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) +static int proc_console_backoff(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int rc, backoff; struct ctl_table dummy = *table; @@ -324,16 +326,18 @@ int proc_console_backoff(struct ctl_table *table, int write, return rc; } -int libcfs_force_lbug(struct ctl_table *table, int write, void __user *buffer, - size_t *lenp, loff_t *ppos) +static int libcfs_force_lbug(struct ctl_table *table, int write, + void __user *buffer, + size_t *lenp, loff_t *ppos) { if (write) LBUG(); return 0; } -int proc_fail_loc(struct ctl_table *table, int write, void __user *buffer, - size_t *lenp, loff_t *ppos) +static int proc_fail_loc(struct ctl_table *table, int write, + void __user *buffer, + size_t *lenp, loff_t *ppos) { int rc; long old_fail_loc = cfs_fail_loc; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c index b91a1f95bbd0..cd2fc01dea4c 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c @@ -43,7 +43,7 @@ /* For sys_open & sys_close */ #include <linux/syscalls.h> -int +static int libcfs_sock_ioctl(int cmd, unsigned long arg) { mm_segment_t oldmm = get_fs(); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index 976c61ed49f4..c8e293002e07 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -151,6 +151,7 @@ cfs_trace_buf_type_t cfs_trace_buf_idx_get(void) * for details. */ int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking) + __acquires(&tcd->tc_lock) { __LASSERT(tcd->tcd_type < CFS_TCD_TYPE_MAX); if (tcd->tcd_type == CFS_TCD_TYPE_IRQ) @@ -165,6 +166,7 @@ int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking) } void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking) + __releases(&tcd->tcd_lock) { __LASSERT(tcd->tcd_type < CFS_TCD_TYPE_MAX); if (tcd->tcd_type == CFS_TCD_TYPE_IRQ) @@ -269,5 +271,5 @@ int cfs_trace_max_debug_mb(void) { int total_mb = (totalram_pages >> (20 - PAGE_SHIFT)); - return MAX(512, (total_mb * 80)/100); + return max(512, (total_mb * 80)/100); } diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 2c4fc74505bc..7dc77dd402b8 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -42,8 +42,7 @@ #include "../../include/linux/lnet/lnet.h" #include "tracefile.h" -void -kportal_memhog_free (struct libcfs_device_userstate *ldu) +static void kportal_memhog_free (struct libcfs_device_userstate *ldu) { struct page **level0p = &ldu->ldu_memhog_root_page; struct page **level1p; @@ -86,8 +85,7 @@ kportal_memhog_free (struct libcfs_device_userstate *ldu) LASSERT (ldu->ldu_memhog_pages == 0); } -int -kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages, +static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages, gfp_t flags) { struct page **level0p; @@ -334,8 +332,6 @@ extern struct mutex cfs_trace_thread_mutex; extern struct cfs_wi_sched *cfs_sched_rehash; extern void libcfs_init_nidstrings(void); -extern int libcfs_arch_init(void); -extern void libcfs_arch_cleanup(void); static int init_libcfs_module(void) { diff --git a/drivers/staging/lustre/lustre/libcfs/nidstrings.c b/drivers/staging/lustre/lustre/libcfs/nidstrings.c index 47c239f22ba8..087449f4e6c1 100644 --- a/drivers/staging/lustre/lustre/libcfs/nidstrings.c +++ b/drivers/staging/lustre/lustre/libcfs/nidstrings.c @@ -81,14 +81,105 @@ libcfs_next_nidstring(void) return str; } -static int libcfs_lo_str2addr(const char *str, int nob, __u32 *addr); -static void libcfs_ip_addr2str(__u32 addr, char *str); -static int libcfs_ip_str2addr(const char *str, int nob, __u32 *addr); -static void libcfs_decnum_addr2str(__u32 addr, char *str); -static void libcfs_hexnum_addr2str(__u32 addr, char *str); -static int libcfs_num_str2addr(const char *str, int nob, __u32 *addr); -static int libcfs_num_parse(char *str, int len, struct list_head *list); -static int libcfs_num_match(__u32 addr, struct list_head *list); +static int libcfs_lo_str2addr(const char *str, int nob, __u32 *addr) +{ + *addr = 0; + return 1; +} + +static void libcfs_ip_addr2str(__u32 addr, char *str) +{ + snprintf(str, LNET_NIDSTR_SIZE, "%u.%u.%u.%u", + (addr >> 24) & 0xff, (addr >> 16) & 0xff, + (addr >> 8) & 0xff, addr & 0xff); +} + +static int libcfs_ip_str2addr(const char *str, int nob, __u32 *addr) +{ + unsigned int a; + unsigned int b; + unsigned int c; + unsigned int d; + int n = nob; /* XscanfX */ + + /* numeric IP? */ + if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 && + n == nob && + (a & ~0xff) == 0 && (b & ~0xff) == 0 && + (c & ~0xff) == 0 && (d & ~0xff) == 0) { + *addr = ((a<<24)|(b<<16)|(c<<8)|d); + return 1; + } + + return 0; +} + +static void libcfs_decnum_addr2str(__u32 addr, char *str) +{ + snprintf(str, LNET_NIDSTR_SIZE, "%u", addr); +} + +static void libcfs_hexnum_addr2str(__u32 addr, char *str) +{ + snprintf(str, LNET_NIDSTR_SIZE, "0x%x", addr); +} + +static int libcfs_num_str2addr(const char *str, int nob, __u32 *addr) +{ + int n; + + n = nob; + if (sscanf(str, "0x%x%n", addr, &n) >= 1 && n == nob) + return 1; + + n = nob; + if (sscanf(str, "0X%x%n", addr, &n) >= 1 && n == nob) + return 1; + + n = nob; + if (sscanf(str, "%u%n", addr, &n) >= 1 && n == nob) + return 1; + + return 0; +} + +/** + * Nf_parse_addrlist method for networks using numeric addresses. + * + * Examples of such networks are gm and elan. + * + * \retval 0 if \a str parsed to numeric address + * \retval errno otherwise + */ +static int +libcfs_num_parse(char *str, int len, struct list_head *list) +{ + struct cfs_expr_list *el; + int rc; + + rc = cfs_expr_list_parse(str, len, 0, MAX_NUMERIC_VALUE, &el); + if (rc == 0) + list_add_tail(&el->el_link, list); + + return rc; +} + +/* + * Nf_match_addr method for networks using numeric addresses + * + * \retval 1 on match + * \retval 0 otherwise + */ +static int +libcfs_num_match(__u32 addr, struct list_head *numaddr) +{ + struct cfs_expr_list *el; + + LASSERT(!list_empty(numaddr)); + el = list_entry(numaddr->next, struct cfs_expr_list, el_link); + + return cfs_expr_list_match(addr, el); +} struct netstrfns { int nf_type; @@ -197,24 +288,7 @@ static struct netstrfns libcfs_netstrfns[] = { {/* .nf_type */ -1}, }; -const int libcfs_nnetstrfns = ARRAY_SIZE(libcfs_netstrfns); - -int -libcfs_lo_str2addr(const char *str, int nob, __u32 *addr) -{ - *addr = 0; - return 1; -} - -void -libcfs_ip_addr2str(__u32 addr, char *str) -{ -#if 0 /* never lookup */ -#endif - snprintf(str, LNET_NIDSTR_SIZE, "%u.%u.%u.%u", - (addr >> 24) & 0xff, (addr >> 16) & 0xff, - (addr >> 8) & 0xff, addr & 0xff); -} +static const int libcfs_nnetstrfns = ARRAY_SIZE(libcfs_netstrfns); /* CAVEAT EMPTOR XscanfX * I use "%n" at the end of a sscanf format to detect trailing junk. However @@ -223,60 +297,7 @@ libcfs_ip_addr2str(__u32 addr, char *str) * fine, if it doesn't, then the scan ended at the end of the string, which is * fine too :) */ -int -libcfs_ip_str2addr(const char *str, int nob, __u32 *addr) -{ - unsigned int a; - unsigned int b; - unsigned int c; - unsigned int d; - int n = nob; /* XscanfX */ - - /* numeric IP? */ - if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 && - n == nob && - (a & ~0xff) == 0 && (b & ~0xff) == 0 && - (c & ~0xff) == 0 && (d & ~0xff) == 0) { - *addr = ((a<<24)|(b<<16)|(c<<8)|d); - return 1; - } - - return 0; -} - -void -libcfs_decnum_addr2str(__u32 addr, char *str) -{ - snprintf(str, LNET_NIDSTR_SIZE, "%u", addr); -} - -void -libcfs_hexnum_addr2str(__u32 addr, char *str) -{ - snprintf(str, LNET_NIDSTR_SIZE, "0x%x", addr); -} - -int -libcfs_num_str2addr(const char *str, int nob, __u32 *addr) -{ - int n; - - n = nob; - if (sscanf(str, "0x%x%n", addr, &n) >= 1 && n == nob) - return 1; - - n = nob; - if (sscanf(str, "0X%x%n", addr, &n) >= 1 && n == nob) - return 1; - - n = nob; - if (sscanf(str, "%u%n", addr, &n) >= 1 && n == nob) - return 1; - - return 0; -} - -struct netstrfns * +static struct netstrfns * libcfs_lnd2netstrfns(int lnd) { int i; @@ -289,7 +310,7 @@ libcfs_lnd2netstrfns(int lnd) return NULL; } -struct netstrfns * +static struct netstrfns * libcfs_namenum2netstrfns(const char *name) { struct netstrfns *nf; @@ -304,7 +325,7 @@ libcfs_namenum2netstrfns(const char *name) return NULL; } -struct netstrfns * +static struct netstrfns * libcfs_name2netstrfns(const char *name) { int i; @@ -343,7 +364,7 @@ libcfs_lnd2str(int lnd) return nf->nf_name; str = libcfs_next_nidstring(); - snprintf(str, LNET_NIDSTR_SIZE, "?%u?", lnd); + snprintf(str, LNET_NIDSTR_SIZE, "?%d?", lnd); return str; } EXPORT_SYMBOL(libcfs_lnd2str); @@ -369,11 +390,11 @@ libcfs_net2str(__u32 net) char *str = libcfs_next_nidstring(); if (nf == NULL) - snprintf(str, LNET_NIDSTR_SIZE, "<%u:%u>", lnd, num); + snprintf(str, LNET_NIDSTR_SIZE, "<%d:%d>", lnd, num); else if (num == 0) snprintf(str, LNET_NIDSTR_SIZE, "%s", nf->nf_name); else - snprintf(str, LNET_NIDSTR_SIZE, "%s%u", nf->nf_name, num); + snprintf(str, LNET_NIDSTR_SIZE, "%s%d", nf->nf_name, num); return str; } @@ -397,7 +418,7 @@ libcfs_nid2str(lnet_nid_t nid) str = libcfs_next_nidstring(); if (nf == NULL) - snprintf(str, LNET_NIDSTR_SIZE, "%x@<%u:%u>", addr, lnd, nnum); + snprintf(str, LNET_NIDSTR_SIZE, "%x@<%d:%d>", addr, lnd, nnum); else { nf->nf_addr2str(addr, str); nob = strlen(str); @@ -405,7 +426,7 @@ libcfs_nid2str(lnet_nid_t nid) snprintf(str + nob, LNET_NIDSTR_SIZE - nob, "@%s", nf->nf_name); else - snprintf(str + nob, LNET_NIDSTR_SIZE - nob, "@%s%u", + snprintf(str + nob, LNET_NIDSTR_SIZE - nob, "@%s%d", nf->nf_name, nnum); } @@ -586,27 +607,6 @@ struct addrrange { }; /** - * Nf_parse_addrlist method for networks using numeric addresses. - * - * Examples of such networks are gm and elan. - * - * \retval 0 if \a str parsed to numeric address - * \retval errno otherwise - */ -static int -libcfs_num_parse(char *str, int len, struct list_head *list) -{ - struct cfs_expr_list *el; - int rc; - - rc = cfs_expr_list_parse(str, len, 0, MAX_NUMERIC_VALUE, &el); - if (rc == 0) - list_add_tail(&el->el_link, list); - - return rc; -} - -/** * Parses \<addrrange\> token on the syntax. * * Allocates struct addrrange and links to \a nidrange via @@ -812,23 +812,6 @@ cfs_parse_nidlist(char *str, int len, struct list_head *nidlist) } EXPORT_SYMBOL(cfs_parse_nidlist); -/* - * Nf_match_addr method for networks using numeric addresses - * - * \retval 1 on match - * \retval 0 otherwise - */ -static int -libcfs_num_match(__u32 addr, struct list_head *numaddr) -{ - struct cfs_expr_list *el; - - LASSERT(!list_empty(numaddr)); - el = list_entry(numaddr->next, struct cfs_expr_list, el_link); - - return cfs_expr_list_match(addr, el); -} - /** * Matches a nid (\a nid) against the compiled list of nidranges (\a nidlist). * diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index 5917c31c7ed6..eb65b50f832d 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -55,7 +55,7 @@ static struct tracefiled_ctl trace_tctl; struct mutex cfs_trace_thread_mutex; static int thread_running = 0; -atomic_t cfs_tage_allocated = ATOMIC_INIT(0); +static atomic_t cfs_tage_allocated = ATOMIC_INIT(0); static void put_pages_on_tcd_daemon_list(struct page_collection *pc, struct cfs_trace_cpu_data *tcd); @@ -1037,6 +1037,7 @@ static int tracefiled(void *arg) tage->used, rc); put_pages_back(&pc); __LASSERT(list_empty(&pc.pc_pages)); + break; } } MMSPACE_CLOSE; diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 5bb9c85cec81..88614b71cf6d 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -263,14 +263,6 @@ void ll_invalidate_aliases(struct inode *inode) dentry, dentry, dentry->d_parent, dentry->d_inode, dentry->d_flags); - if (unlikely(dentry == dentry->d_sb->s_root)) { - CERROR("%s: called on root dentry=%p, fid="DFID"\n", - ll_get_fsname(dentry->d_sb, NULL, 0), - dentry, PFID(ll_inode2fid(inode))); - lustre_dump_dentry(dentry, 1); - dump_stack(); - } - d_lustre_invalidate(dentry, 0); } ll_unlock_dcache(inode); diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 1ac7a702ce26..a18201913273 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -183,7 +183,10 @@ static int ll_dir_filler(void *_hash, struct page *page0) op_data->op_offset = hash; rc = md_readpage(exp, op_data, page_pool, &request); ll_finish_md_op_data(op_data); - if (rc == 0) { + if (rc < 0) { + /* page0 is special, which was added into page cache early */ + delete_from_page_cache(page0); + } else if (rc == 0) { body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); /* Checked by mdc_readpage() */ LASSERT(body != NULL); @@ -278,7 +281,7 @@ static struct page *ll_dir_page_locate(struct inode *dir, __u64 *hash, spin_lock_irq(&mapping->tree_lock); found = radix_tree_gang_lookup(&mapping->page_tree, (void **)&page, offset, 1); - if (found > 0) { + if (found > 0 && !radix_tree_exceptional_entry(page)) { struct lu_dirpage *dp; page_cache_get(page); @@ -652,8 +655,8 @@ static int ll_send_mgc_param(struct obd_export *mgc, char *string) return rc; } -int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump, - char *filename) +static int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump, + char *filename) { struct ptlrpc_request *request = NULL; struct md_op_data *op_data; diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 35a2df01528c..7c7ef7ec908e 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1553,6 +1553,11 @@ ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) struct ccc_grouplock grouplock; int rc; + if (arg == 0) { + CWARN("group id for group lock must not be 0\n"); + return -EINVAL; + } + if (ll_file_nolock(file)) return -EOPNOTSUPP; @@ -1587,7 +1592,8 @@ ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) return 0; } -int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) +static int ll_put_grouplock(struct inode *inode, struct file *file, + unsigned long arg) { struct ll_inode_info *lli = ll_i2info(inode); struct ll_file_data *fd = LUSTRE_FPRIVATE(file); diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 37306e0c7aad..d032c2b086cc 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -816,7 +816,6 @@ int ll_show_options(struct seq_file *seq, struct dentry *dentry); void ll_dirty_page_discard_warn(struct page *page, int ioret); int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, struct super_block *, struct lookup_intent *); -void lustre_dump_dentry(struct dentry *, int recur); int ll_obd_statfs(struct inode *inode, void *arg); int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize); int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index a3367bfb1456..0c1b583a4ea1 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -665,48 +665,6 @@ int ll_get_default_cookiesize(struct ll_sb_info *sbi, int *lmmsize) return rc; } -static void ll_dump_inode(struct inode *inode) -{ - struct ll_d_hlist_node *tmp; - int dentry_count = 0; - - LASSERT(inode != NULL); - - ll_d_hlist_for_each(tmp, &inode->i_dentry) - dentry_count++; - - CERROR("inode %p dump: dev=%s ino=%lu mode=%o count=%u, %d dentries\n", - inode, ll_i2mdexp(inode)->exp_obd->obd_name, inode->i_ino, - inode->i_mode, atomic_read(&inode->i_count), dentry_count); -} - -void lustre_dump_dentry(struct dentry *dentry, int recur) -{ - struct list_head *tmp; - int subdirs = 0; - - LASSERT(dentry != NULL); - - list_for_each(tmp, &dentry->d_subdirs) - subdirs++; - - CERROR("dentry %p dump: name=%pd parent=%pd (%p), inode=%p, count=%u, flags=0x%x, fsdata=%p, %d subdirs\n", - dentry, dentry, dentry->d_parent, dentry->d_parent, - dentry->d_inode, d_count(dentry), - dentry->d_flags, dentry->d_fsdata, subdirs); - if (dentry->d_inode != NULL) - ll_dump_inode(dentry->d_inode); - - if (recur == 0) - return; - - list_for_each(tmp, &dentry->d_subdirs) { - struct dentry *d = list_entry(tmp, struct dentry, d_child); - - lustre_dump_dentry(d, recur - 1); - } -} - static void client_common_put_super(struct super_block *sb) { struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -987,7 +945,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) if (err) goto out_free; lsi->lsi_flags |= LSI_BDI_INITIALIZED; - lsi->lsi_bdi.capabilities = BDI_CAP_MAP_COPY; + lsi->lsi_bdi.capabilities = 0; err = ll_bdi_register(&lsi->lsi_bdi); if (err) goto out_free; @@ -1812,10 +1770,6 @@ void ll_read_inode2(struct inode *inode, void *opaque) /* OIDEBUG(inode); */ - /* initializing backing dev info. */ - inode->i_mapping->backing_dev_info = &s2lsi(inode->i_sb)->lsi_bdi; - - if (S_ISREG(inode->i_mode)) { struct ll_sb_info *sbi = ll_i2sbi(inode); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index e6a909e6faf0..aaa13bd3e8de 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -399,9 +399,6 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, return -ERANGE; } - if (sbi->ll_dt_exp == NULL) - return -ENODEV; - spin_lock(&sbi->ll_lock); diff = pages_number - cache->ccc_lru_max; spin_unlock(&sbi->ll_lock); @@ -437,6 +434,11 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, if (diff <= 0) break; + if (sbi->ll_dt_exp == NULL) { /* being initialized */ + rc = -ENODEV; + break; + } + /* difficult - have to ask OSCs to drop LRU slots. */ tmp = diff << 1; rc = obd_set_info_async(NULL, sbi->ll_dt_exp, diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 6aff155651cc..7c1e02a031ba 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -72,21 +72,6 @@ static void ll_destroy_inode(struct inode *inode) call_rcu(&inode->i_rcu, ll_inode_destroy_callback); } -static int ll_init_inodecache(void) -{ - ll_inode_cachep = kmem_cache_create("lustre_inode_cache", - sizeof(struct ll_inode_info), - 0, SLAB_HWCACHE_ALIGN, NULL); - if (ll_inode_cachep == NULL) - return -ENOMEM; - return 0; -} - -static void ll_destroy_inodecache(void) -{ - kmem_cache_destroy(ll_inode_cachep); -} - /* exported operations */ struct super_operations lustre_super_operations = { .alloc_inode = ll_alloc_inode, @@ -104,9 +89,10 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)); static int __init init_lustre_lite(void) { - int i, rc, seed[2]; - struct timeval tv; + struct proc_dir_entry *entry; lnet_process_id_t lnet_id; + struct timeval tv; + int i, rc, seed[2]; CLASSERT(sizeof(LUSTRE_VOLATILE_HDR) == LUSTRE_VOLATILE_HDR_LEN + 1); @@ -116,59 +102,52 @@ static int __init init_lustre_lite(void) CDEBUG(D_INFO, "Lustre client module (%p).\n", &lustre_super_operations); - rc = ll_init_inodecache(); - if (rc) - return -ENOMEM; + rc = -ENOMEM; + ll_inode_cachep = kmem_cache_create("lustre_inode_cache", + sizeof(struct ll_inode_info), + 0, SLAB_HWCACHE_ALIGN, NULL); + if (ll_inode_cachep == NULL) + goto out_cache; + ll_file_data_slab = kmem_cache_create("ll_file_data", sizeof(struct ll_file_data), 0, SLAB_HWCACHE_ALIGN, NULL); - if (ll_file_data_slab == NULL) { - ll_destroy_inodecache(); - return -ENOMEM; - } + if (ll_file_data_slab == NULL) + goto out_cache; ll_remote_perm_cachep = kmem_cache_create("ll_remote_perm_cache", sizeof(struct ll_remote_perm), 0, 0, NULL); - if (ll_remote_perm_cachep == NULL) { - kmem_cache_destroy(ll_file_data_slab); - ll_file_data_slab = NULL; - ll_destroy_inodecache(); - return -ENOMEM; - } + if (ll_remote_perm_cachep == NULL) + goto out_cache; ll_rmtperm_hash_cachep = kmem_cache_create("ll_rmtperm_hash_cache", REMOTE_PERM_HASHSIZE * sizeof(struct list_head), 0, 0, NULL); - if (ll_rmtperm_hash_cachep == NULL) { - kmem_cache_destroy(ll_remote_perm_cachep); - ll_remote_perm_cachep = NULL; - kmem_cache_destroy(ll_file_data_slab); - ll_file_data_slab = NULL; - ll_destroy_inodecache(); - return -ENOMEM; + 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); + goto out_cache; } - proc_lustre_fs_root = proc_lustre_root ? - lprocfs_register("llite", proc_lustre_root, NULL, NULL) : NULL; - - lustre_register_client_fill_super(ll_fill_super); - lustre_register_kill_super_cb(ll_kill_super); - - lustre_register_client_process_config(ll_process_config); + proc_lustre_fs_root = entry; cfs_get_random_bytes(seed, sizeof(seed)); - /* Nodes with small feet have little entropy - * the NID for this node gives the most entropy in the low bits */ - for (i = 0; ; i++) { - if (LNetGetId(i, &lnet_id) == -ENOENT) { + /* Nodes with small feet have little entropy. The NID for this + * node gives the most entropy in the low bits */ + for (i = 0;; i++) { + if (LNetGetId(i, &lnet_id) == -ENOENT) break; - } - if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND) { + + if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND) seed[0] ^= LNET_NIDADDR(lnet_id.nid); - } } do_gettimeofday(&tv); @@ -177,20 +156,54 @@ static int __init init_lustre_lite(void) init_timer(&ll_capa_timer); ll_capa_timer.function = ll_capa_timer_callback; rc = ll_capa_thread_start(); - /* - * XXX normal cleanup is needed here. - */ - if (rc == 0) - rc = vvp_global_init(); + if (rc != 0) + goto out_proc; - if (rc == 0) - rc = ll_xattr_init(); + rc = vvp_global_init(); + if (rc != 0) + goto out_capa; + + rc = ll_xattr_init(); + if (rc != 0) + goto out_vvp; + + lustre_register_client_fill_super(ll_fill_super); + lustre_register_kill_super_cb(ll_kill_super); + lustre_register_client_process_config(ll_process_config); + + return 0; + +out_vvp: + vvp_global_fini(); +out_capa: + del_timer(&ll_capa_timer); + ll_capa_thread_stop(); +out_proc: + lprocfs_remove(&proc_lustre_fs_root); +out_cache: + if (ll_inode_cachep != NULL) + kmem_cache_destroy(ll_inode_cachep); + + if (ll_file_data_slab != NULL) + kmem_cache_destroy(ll_file_data_slab); + + if (ll_remote_perm_cachep != NULL) + kmem_cache_destroy(ll_remote_perm_cachep); + + if (ll_rmtperm_hash_cachep != NULL) + kmem_cache_destroy(ll_rmtperm_hash_cachep); return rc; } static void __exit exit_lustre_lite(void) { + lustre_register_client_fill_super(NULL); + lustre_register_kill_super_cb(NULL); + lustre_register_client_process_config(NULL); + + lprocfs_remove(&proc_lustre_fs_root); + ll_xattr_fini(); vvp_global_fini(); del_timer(&ll_capa_timer); @@ -199,22 +212,12 @@ static void __exit exit_lustre_lite(void) "client remaining capa count %d\n", capa_count[CAPA_SITE_CLIENT]); - lustre_register_client_fill_super(NULL); - lustre_register_kill_super_cb(NULL); - - lustre_register_client_process_config(NULL); - - ll_destroy_inodecache(); - + kmem_cache_destroy(ll_inode_cachep); kmem_cache_destroy(ll_rmtperm_hash_cachep); - ll_rmtperm_hash_cachep = NULL; kmem_cache_destroy(ll_remote_perm_cachep); - ll_remote_perm_cachep = NULL; kmem_cache_destroy(ll_file_data_slab); - if (proc_lustre_fs_root && !IS_ERR(proc_lustre_fs_root)) - lprocfs_remove(&proc_lustre_fs_root); } MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 65d610abe06e..91bba79678cf 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -307,18 +307,13 @@ static int vvp_io_rw_lock(const struct lu_env *env, struct cl_io *io, static int vvp_io_read_lock(const struct lu_env *env, const struct cl_io_slice *ios) { - struct cl_io *io = ios->cis_io; - struct ll_inode_info *lli = ll_i2info(ccc_object_inode(io->ci_obj)); + struct cl_io *io = ios->cis_io; + struct cl_io_rw_common *rd = &io->u.ci_rd.rd; int result; - /* XXX: Layer violation, we shouldn't see lsm at llite level. */ - if (lli->lli_has_smd) /* lsm-less file doesn't need to lock */ - result = vvp_io_rw_lock(env, io, CLM_READ, - io->u.ci_rd.rd.crw_pos, - io->u.ci_rd.rd.crw_pos + - io->u.ci_rd.rd.crw_count - 1); - else - result = 0; + result = vvp_io_rw_lock(env, io, CLM_READ, rd->crw_pos, + rd->crw_pos + rd->crw_count - 1); + return result; } diff --git a/drivers/staging/lustre/lustre/llite/vvp_lock.c b/drivers/staging/lustre/lustre/llite/vvp_lock.c index 372633e164b9..f354e82d4ae7 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_lock.c +++ b/drivers/staging/lustre/lustre/llite/vvp_lock.c @@ -71,6 +71,7 @@ static const struct cl_lock_operations vvp_lock_ops = { .clo_fini = ccc_lock_fini, .clo_enqueue = ccc_lock_enqueue, .clo_wait = ccc_lock_wait, + .clo_use = ccc_lock_use, .clo_unuse = ccc_lock_unuse, .clo_fits_into = ccc_lock_fits_into, .clo_state = ccc_lock_state, diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 9f3837412cdf..b779f47384c5 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -128,7 +128,7 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, return rc; } -struct obd_uuid *lmv_get_uuid(struct obd_export *exp) +static struct obd_uuid *lmv_get_uuid(struct obd_export *exp) { struct lmv_obd *lmv = &exp->exp_obd->u.lmv; @@ -335,7 +335,7 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, #define MAX_STRING_SIZE 128 -int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) +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; @@ -1663,10 +1663,10 @@ struct lmv_tgt_desc return tgt; } -int lmv_create(struct obd_export *exp, struct md_op_data *op_data, - const void *data, int datalen, int mode, __u32 uid, - __u32 gid, cfs_cap_t cap_effective, __u64 rdev, - struct ptlrpc_request **request) +static int lmv_create(struct obd_export *exp, struct md_op_data *op_data, + const void *data, int datalen, int mode, __u32 uid, + __u32 gid, cfs_cap_t cap_effective, __u64 rdev, + struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -2387,9 +2387,9 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, return -EINVAL; } -int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, - u32 keylen, void *key, u32 vallen, - void *val, struct ptlrpc_request_set *set) +static int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, + u32 keylen, void *key, u32 vallen, + void *val, struct ptlrpc_request_set *set) { struct lmv_tgt_desc *tgt; struct obd_device *obd; @@ -2425,8 +2425,8 @@ int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, return -EINVAL; } -int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, - struct lov_stripe_md *lsm) +static int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, + struct lov_stripe_md *lsm) { struct obd_device *obd = class_exp2obd(exp); struct lmv_obd *lmv = &obd->u.lmv; @@ -2473,8 +2473,8 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, return mea_size; } -int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, - struct lov_mds_md *lmm, int lmm_size) +static int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, + struct lov_mds_md *lmm, int lmm_size) { struct obd_device *obd = class_exp2obd(exp); struct lmv_stripe_md **tmea = (struct lmv_stripe_md **)lsmp; @@ -2551,8 +2551,8 @@ static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, return rc; } -int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, - __u64 *bits) +static int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, + __u64 *bits) { struct lmv_obd *lmv = &exp->exp_obd->u.lmv; int rc; @@ -2561,10 +2561,10 @@ int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, return rc; } -ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags, - const struct lu_fid *fid, ldlm_type_t type, - ldlm_policy_data_t *policy, ldlm_mode_t mode, - struct lustre_handle *lockh) +static ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags, + const struct lu_fid *fid, ldlm_type_t type, + ldlm_policy_data_t *policy, ldlm_mode_t mode, + struct lustre_handle *lockh) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -2594,16 +2594,18 @@ ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags, return 0; } -int lmv_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, - struct obd_export *dt_exp, struct obd_export *md_exp, - struct lustre_md *md) +static int lmv_get_lustre_md(struct obd_export *exp, + struct ptlrpc_request *req, + struct obd_export *dt_exp, + struct obd_export *md_exp, + struct lustre_md *md) { struct lmv_obd *lmv = &exp->exp_obd->u.lmv; return md_get_lustre_md(lmv->tgts[0]->ltd_exp, req, dt_exp, md_exp, md); } -int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md) +static int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -2613,9 +2615,9 @@ int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md) return md_free_lustre_md(lmv->tgts[0]->ltd_exp, md); } -int lmv_set_open_replay_data(struct obd_export *exp, - struct obd_client_handle *och, - struct lookup_intent *it) +static int lmv_set_open_replay_data(struct obd_export *exp, + struct obd_client_handle *och, + struct lookup_intent *it) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -2628,8 +2630,8 @@ int lmv_set_open_replay_data(struct obd_export *exp, return md_set_open_replay_data(tgt->ltd_exp, och, it); } -int lmv_clear_open_replay_data(struct obd_export *exp, - struct obd_client_handle *och) +static int lmv_clear_open_replay_data(struct obd_export *exp, + struct obd_client_handle *och) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -2684,17 +2686,18 @@ static int lmv_renew_capa(struct obd_export *exp, struct obd_capa *oc, return rc; } -int lmv_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req, - const struct req_msg_field *field, struct obd_capa **oc) +static int lmv_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req, + const struct req_msg_field *field, + struct obd_capa **oc) { struct lmv_obd *lmv = &exp->exp_obd->u.lmv; return md_unpack_capa(lmv->tgts[0]->ltd_exp, req, field, oc); } -int lmv_intent_getattr_async(struct obd_export *exp, - struct md_enqueue_info *minfo, - struct ldlm_enqueue_info *einfo) +static int lmv_intent_getattr_async(struct obd_export *exp, + struct md_enqueue_info *minfo, + struct ldlm_enqueue_info *einfo) { struct md_op_data *op_data = &minfo->mi_data; struct obd_device *obd = exp->exp_obd; @@ -2714,8 +2717,8 @@ int lmv_intent_getattr_async(struct obd_export *exp, return rc; } -int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, - struct lu_fid *fid, __u64 *bits) +static int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, + struct lu_fid *fid, __u64 *bits) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -2739,8 +2742,8 @@ int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, * process with other slave MDTs. The only exception is Q_GETOQUOTA for which * we directly fetch data from the slave MDTs. */ -int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, - struct obd_quotactl *oqctl) +static int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, + struct obd_quotactl *oqctl) { struct obd_device *obd = class_exp2obd(exp); struct lmv_obd *lmv = &obd->u.lmv; @@ -2786,8 +2789,8 @@ int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, return rc; } -int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp, - struct obd_quotactl *oqctl) +static int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp, + struct obd_quotactl *oqctl) { struct obd_device *obd = class_exp2obd(exp); struct lmv_obd *lmv = &obd->u.lmv; @@ -2810,7 +2813,7 @@ int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp, return rc; } -struct obd_ops lmv_obd_ops = { +static struct obd_ops lmv_obd_ops = { .o_owner = THIS_MODULE, .o_setup = lmv_setup, .o_cleanup = lmv_cleanup, @@ -2830,7 +2833,7 @@ struct obd_ops lmv_obd_ops = { .o_quotactl = lmv_quotactl }; -struct md_ops lmv_md_ops = { +static struct md_ops lmv_md_ops = { .m_getstatus = lmv_getstatus, .m_null_inode = lmv_null_inode, .m_find_cbdata = lmv_find_cbdata, @@ -2864,7 +2867,7 @@ struct md_ops lmv_md_ops = { .m_revalidate_lock = lmv_revalidate_lock }; -int __init lmv_init(void) +static int __init lmv_init(void) { struct lprocfs_static_vars lvars; int rc; diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 117002097b28..5be4176829d3 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -175,7 +175,7 @@ static int lmv_tgt_seq_show(struct seq_file *p, void *v) tgt->ltd_uuid.uuid, tgt->ltd_active ? "" : "IN"); } -struct seq_operations lmv_tgt_sops = { +static struct seq_operations lmv_tgt_sops = { .start = lmv_tgt_seq_start, .stop = lmv_tgt_seq_stop, .next = lmv_tgt_seq_next, @@ -199,7 +199,7 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid); -struct lprocfs_vars lprocfs_lmv_obd_vars[] = { +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 }, diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index c993f25fb303..c99f2f44ec62 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -51,8 +51,9 @@ static int lov_stripesize_seq_show(struct seq_file *m, void *v) return seq_printf(m, "%llu\n", desc->ld_default_stripe_size); } -static ssize_t lov_stripesize_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t lov_stripesize_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *dev = ((struct seq_file *)file->private_data)->private; struct lov_desc *desc; @@ -81,8 +82,9 @@ static int lov_stripeoffset_seq_show(struct seq_file *m, void *v) return seq_printf(m, "%llu\n", desc->ld_default_stripe_offset); } -static ssize_t lov_stripeoffset_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t lov_stripeoffset_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *dev = ((struct seq_file *)file->private_data)->private; struct lov_desc *desc; @@ -110,8 +112,9 @@ static int lov_stripetype_seq_show(struct seq_file *m, void *v) return seq_printf(m, "%u\n", desc->ld_pattern); } -static ssize_t lov_stripetype_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t lov_stripetype_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *dev = ((struct seq_file *)file->private_data)->private; struct lov_desc *desc; @@ -140,8 +143,9 @@ static int lov_stripecount_seq_show(struct seq_file *m, void *v) (__s16)(desc->ld_default_stripe_count + 1) - 1); } -static ssize_t lov_stripecount_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t lov_stripecount_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *dev = ((struct seq_file *)file->private_data)->private; struct lov_desc *desc; diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 16341c818358..c791941bd810 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -52,7 +52,7 @@ static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v) } static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file, - const char *buffer, + const char __user *buffer, size_t count, loff_t *off) { @@ -82,8 +82,9 @@ static int mdc_kuc_open(struct inode *inode, struct file *file) } /* temporary for testing */ -static ssize_t mdc_kuc_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t mdc_kuc_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; @@ -105,6 +106,8 @@ static ssize_t mdc_kuc_write(struct file *file, const char *buffer, /* for mockup below */ 2 * cfs_size_round(sizeof(*hai)); OBD_ALLOC(lh, len); + if (!lh) + return -ENOMEM; lh->kuc_magic = KUC_MAGIC; lh->kuc_transport = KUC_TRANSPORT_HSM; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index 4e59995e0042..d3234cb1ea22 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -222,10 +222,9 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data, rec->cr_fsuid = from_kuid(&init_user_ns, current_fsuid()); rec->cr_fsgid = from_kgid(&init_user_ns, current_fsgid()); rec->cr_cap = cfs_curproc_cap_pack(); - if (op_data != NULL) { - rec->cr_fid1 = op_data->op_fid1; - rec->cr_fid2 = op_data->op_fid2; - } + rec->cr_fid1 = op_data->op_fid1; + rec->cr_fid2 = op_data->op_fid2; + rec->cr_mode = mode; cr_flags = mds_pack_open_flags(flags, mode); rec->cr_rdev = rdev; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 8c9b4f5494e9..d1c224ecd2b7 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -828,6 +828,7 @@ resend: einfo->ei_type); policy = (ldlm_policy_data_t *)lmm; res_id.name[3] = LDLM_FLOCK; + req = NULL; } else if (it->it_op & IT_OPEN) { req = mdc_intent_open_pack(exp, it, op_data, lmm, lmmsize, einfo->ei_cbdata); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 3b0f245a8780..ef2744700d8b 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -855,8 +855,8 @@ static void mdc_close_handle_reply(struct ptlrpc_request *req, } } -int mdc_close(struct obd_export *exp, struct md_op_data *op_data, - struct md_open_data *mod, struct ptlrpc_request **request) +static int mdc_close(struct obd_export *exp, struct md_op_data *op_data, + struct md_open_data *mod, struct ptlrpc_request **request) { struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req; @@ -974,8 +974,8 @@ int mdc_close(struct obd_export *exp, struct md_op_data *op_data, return rc < 0 ? rc : saved_rc; } -int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, - struct md_open_data *mod) +static int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, + struct md_open_data *mod) { struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req; @@ -1044,8 +1044,8 @@ int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, } -int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data, - struct page **pages, struct ptlrpc_request **request) +static int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data, + struct page **pages, struct ptlrpc_request **request) { struct ptlrpc_request *req; struct ptlrpc_bulk_desc *desc; @@ -1908,8 +1908,8 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, /* copy UUID */ if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(obd), - min((int) data->ioc_plen2, - (int) sizeof(struct obd_uuid)))) { + min_t(size_t, data->ioc_plen2, + sizeof(struct obd_uuid)))) { rc = -EFAULT; goto out; } @@ -1921,8 +1921,8 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, goto out; if (copy_to_user(data->ioc_pbuf1, &stat_buf, - min((int) data->ioc_plen1, - (int) sizeof(stat_buf)))) { + min_t(size_t, data->ioc_plen1, + sizeof(stat_buf)))) { rc = -EFAULT; goto out; } @@ -1974,9 +1974,9 @@ out: return rc; } -int mdc_get_info_rpc(struct obd_export *exp, - u32 keylen, void *key, - int vallen, void *val) +static int mdc_get_info_rpc(struct obd_export *exp, + u32 keylen, void *key, + int vallen, void *val) { struct obd_import *imp = class_exp2cliimp(exp); struct ptlrpc_request *req; @@ -2148,11 +2148,11 @@ static int mdc_kuc_reregister(struct obd_import *imp) (void *)imp); } -int mdc_set_info_async(const struct lu_env *env, - struct obd_export *exp, - u32 keylen, void *key, - u32 vallen, void *val, - struct ptlrpc_request_set *set) +static int mdc_set_info_async(const struct lu_env *env, + struct obd_export *exp, + u32 keylen, void *key, + u32 vallen, void *val, + struct ptlrpc_request_set *set) { struct obd_import *imp = class_exp2cliimp(exp); int rc; @@ -2199,9 +2199,9 @@ int mdc_set_info_async(const struct lu_env *env, return -EINVAL; } -int mdc_get_info(const struct lu_env *env, struct obd_export *exp, - __u32 keylen, void *key, __u32 *vallen, void *val, - struct lov_stripe_md *lsm) +static int mdc_get_info(const struct lu_env *env, struct obd_export *exp, + __u32 keylen, void *key, __u32 *vallen, void *val, + struct lov_stripe_md *lsm) { int rc = -EINVAL; @@ -2263,8 +2263,8 @@ int mdc_get_info(const struct lu_env *env, struct obd_export *exp, return rc; } -int mdc_sync(struct obd_export *exp, const struct lu_fid *fid, - struct obd_capa *oc, struct ptlrpc_request **request) +static int mdc_sync(struct obd_export *exp, const struct lu_fid *fid, + struct obd_capa *oc, struct ptlrpc_request **request) { struct ptlrpc_request *req; int rc; @@ -2356,7 +2356,7 @@ int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid, return seq_client_alloc_fid(NULL, seq, fid); } -struct obd_uuid *mdc_get_uuid(struct obd_export *exp) +static struct obd_uuid *mdc_get_uuid(struct obd_export *exp) { struct client_obd *cli = &exp->exp_obd->u.cli; @@ -2390,7 +2390,7 @@ static int mdc_resource_inode_free(struct ldlm_resource *res) return 0; } -struct ldlm_valblock_ops inode_lvbo = { +static struct ldlm_valblock_ops inode_lvbo = { .lvbo_free = mdc_resource_inode_free, }; @@ -2550,9 +2550,9 @@ static int mdc_process_config(struct obd_device *obd, u32 len, void *buf) /* get remote permission for current user on fid */ -int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid, - struct obd_capa *oc, __u32 suppgid, - struct ptlrpc_request **request) +static int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid, + struct obd_capa *oc, __u32 suppgid, + struct ptlrpc_request **request) { struct ptlrpc_request *req; int rc; @@ -2647,7 +2647,7 @@ static int mdc_renew_capa(struct obd_export *exp, struct obd_capa *oc, return 0; } -struct obd_ops mdc_obd_ops = { +static struct obd_ops mdc_obd_ops = { .o_owner = THIS_MODULE, .o_setup = mdc_setup, .o_precleanup = mdc_precleanup, @@ -2670,7 +2670,7 @@ struct obd_ops mdc_obd_ops = { .o_quotacheck = mdc_quotacheck }; -struct md_ops mdc_md_ops = { +static struct md_ops mdc_md_ops = { .m_getstatus = mdc_getstatus, .m_null_inode = mdc_null_inode, .m_find_cbdata = mdc_find_cbdata, @@ -2705,7 +2705,7 @@ struct md_ops mdc_md_ops = { .m_revalidate_lock = mdc_revalidate_lock }; -int __init mdc_init(void) +static int __init mdc_init(void) { int rc; struct lprocfs_static_vars lvars = { NULL }; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index ce96bd279111..f13d1fbffd9d 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -193,6 +193,7 @@ static spinlock_t *cl_object_attr_guard(struct cl_object *o) * cl_object_attr_get(), cl_object_attr_set(). */ void cl_object_attr_lock(struct cl_object *o) + __acquires(cl_object_attr_guard(o)) { spin_lock(cl_object_attr_guard(o)); } @@ -202,6 +203,7 @@ EXPORT_SYMBOL(cl_object_attr_lock); * Releases data-attributes lock, acquired by cl_object_attr_lock(). */ void cl_object_attr_unlock(struct cl_object *o) + __releases(cl_object_attr_guard(o)) { spin_unlock(cl_object_attr_guard(o)); } @@ -662,7 +664,8 @@ static int cl_env_store_init(void) { return cl_env_hash != NULL ? 0 :-ENOMEM; } -static void cl_env_store_fini(void) { +static void cl_env_store_fini(void) +{ cfs_hash_putref(cl_env_hash); } diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 89a3fb2e56b2..29456e1ad225 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -61,7 +61,7 @@ __u64 obd_alloc; EXPORT_SYMBOL(obd_alloc); __u64 obd_pages; EXPORT_SYMBOL(obd_pages); -DEFINE_SPINLOCK(obd_updatemax_lock); +static DEFINE_SPINLOCK(obd_updatemax_lock); /* The following are visible and mutable through /proc/sys/lustre/. */ unsigned int obd_alloc_fail_rate = 0; diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 736ca410aca3..82508210465e 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -1151,22 +1151,24 @@ void class_export_recovery_cleanup(struct obd_export *exp) exp->exp_obd->obd_stale_clients++; } spin_unlock(&obd->obd_recovery_task_lock); + + spin_lock(&exp->exp_lock); /** Cleanup req replay fields */ if (exp->exp_req_replay_needed) { - spin_lock(&exp->exp_lock); exp->exp_req_replay_needed = 0; - spin_unlock(&exp->exp_lock); + LASSERT(atomic_read(&obd->obd_req_replay_clients)); atomic_dec(&obd->obd_req_replay_clients); } + /** Cleanup lock replay data */ if (exp->exp_lock_replay_needed) { - spin_lock(&exp->exp_lock); exp->exp_lock_replay_needed = 0; - spin_unlock(&exp->exp_lock); + LASSERT(atomic_read(&obd->obd_lock_replay_clients)); atomic_dec(&obd->obd_lock_replay_clients); } + spin_unlock(&exp->exp_lock); } /* This function removes 1-3 references from the export: diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 66ceab20c743..b94aeac18a37 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -83,9 +83,8 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) int err; int offset = 0; - err = copy_from_user(&hdr, (void *)arg, sizeof(hdr)); - if (err) - return err; + if (copy_from_user(&hdr, (void *)arg, sizeof(hdr))) + return -EFAULT; if (hdr.ioc_version != OBD_IOCTL_VERSION) { CERROR("Version mismatch kernel (%x) vs application (%x)\n", @@ -117,18 +116,19 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) *len = hdr.ioc_len; data = (struct obd_ioctl_data *)*buf; - err = copy_from_user(*buf, (void *)arg, hdr.ioc_len); - if (err) { - OBD_FREE_LARGE(*buf, hdr.ioc_len); - return err; + if (copy_from_user(*buf, (void *)arg, hdr.ioc_len)) { + err = -EFAULT; + goto free_buf; + } + if (hdr.ioc_len != data->ioc_len) { + err = -EINVAL; + goto free_buf; } - if (hdr.ioc_len != data->ioc_len) - return -EINVAL; if (obd_ioctl_is_invalid(data)) { CERROR("ioctl not correctly formatted\n"); - OBD_FREE_LARGE(*buf, hdr.ioc_len); - return -EINVAL; + err = -EINVAL; + goto free_buf; } if (data->ioc_inllen1) { @@ -151,6 +151,10 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) } return 0; + +free_buf: + OBD_FREE_LARGE(*buf, hdr.ioc_len); + return err; } EXPORT_SYMBOL(obd_ioctl_getdata); @@ -272,8 +276,9 @@ static int obd_proc_jobid_var_seq_show(struct seq_file *m, void *v) return seq_printf(m, "%s\n", obd_jobid_var); } -static ssize_t obd_proc_jobid_var_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t obd_proc_jobid_var_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN) return -EINVAL; diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index d3ec90e85eb9..a2d5aa105d6b 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -168,7 +168,8 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec) } case CHANGELOG_REC: { - struct llog_changelog_rec *cr = (struct llog_changelog_rec *)rec; + struct llog_changelog_rec *cr = + (struct llog_changelog_rec *)rec; __swab16s(&cr->cr.cr_namelen); __swab16s(&cr->cr.cr_flags); @@ -188,6 +189,8 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec) } else { tail = &cr->cr_tail; } + tail = (struct llog_rec_tail *)((char *)tail + + cr->cr.cr_namelen); break; } case CHANGELOG_USER_REC: diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 3b7dfc367722..ddab94d7ee82 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -45,6 +45,7 @@ #include "../include/lprocfs_status.h" #include "../include/lustre/lustre_idl.h" #include <linux/seq_file.h> +#include <linux/ctype.h> static const char * const obd_connect_names[] = { "read_only", @@ -1849,7 +1850,7 @@ int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult) } EXPORT_SYMBOL(lprocfs_seq_read_frac_helper); -int lprocfs_write_u64_helper(const char *buffer, unsigned long count, +int lprocfs_write_u64_helper(const char __user *buffer, unsigned long count, __u64 *val) { return lprocfs_write_frac_u64_helper(buffer, count, val, 1); @@ -1862,6 +1863,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count, char kernbuf[22], *end, *pbuf; __u64 whole, frac = 0, units; unsigned frac_d = 1; + int sign = 1; if (count > (sizeof(kernbuf) - 1)) return -EINVAL; @@ -1872,7 +1874,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count, kernbuf[count] = '\0'; pbuf = kernbuf; if (*pbuf == '-') { - mult = -mult; + sign = -1; pbuf++; } @@ -1880,7 +1882,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count, if (pbuf == end) return -EINVAL; - if (end != NULL && *end == '.') { + if (*end == '.') { int i; pbuf = end + 1; @@ -1895,25 +1897,25 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count, } units = 1; - switch (*end) { - case 'p': case 'P': + switch (tolower(*end)) { + case 'p': units <<= 10; - case 't': case 'T': + case 't': units <<= 10; - case 'g': case 'G': + case 'g': units <<= 10; - case 'm': case 'M': + case 'm': units <<= 10; - case 'k': case 'K': + case 'k': units <<= 10; } /* Specified units override the multiplier */ - if (units) - mult = mult < 0 ? -units : units; + if (units > 1) + mult = units; frac *= mult; do_div(frac, frac_d); - *val = whole * mult + frac; + *val = sign * (whole * mult + frac); return 0; } EXPORT_SYMBOL(lprocfs_write_frac_u64_helper); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 4f39cdee1b5c..3c0c9109cefd 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -376,6 +376,11 @@ int lustre_start_mgc(struct super_block *sb) /* Random uuid for MGC allows easier reconnects */ OBD_ALLOC_PTR(uuid); + if (!uuid) { + rc = -ENOMEM; + goto out_free; + } + ll_generate_random_uuid(uuidc); class_uuid_unparse(uuidc, uuid); diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 9f719bcecab3..1795d3a7a029 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -53,8 +53,9 @@ static int osc_active_seq_show(struct seq_file *m, void *v) return rc; } -static ssize_t osc_active_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t osc_active_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *dev = ((struct seq_file *)file->private_data)->private; int val, rc; @@ -88,7 +89,8 @@ static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v) } static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file, - const char *buffer, size_t count, loff_t *off) + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *dev = ((struct seq_file *)file->private_data)->private; struct client_obd *cli = &dev->u.cli; @@ -130,8 +132,9 @@ static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v) return lprocfs_seq_read_frac_helper(m, val, mult); } -static ssize_t osc_max_dirty_mb_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t osc_max_dirty_mb_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *dev = ((struct seq_file *)file->private_data)->private; struct client_obd *cli = &dev->u.cli; @@ -233,8 +236,9 @@ static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v) return rc; } -static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; struct client_obd *cli = &obd->u.cli; @@ -290,7 +294,8 @@ static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v) } static ssize_t osc_grant_shrink_interval_seq_write(struct file *file, - const char *buffer, size_t count, loff_t *off) + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; int val, rc; @@ -322,8 +327,9 @@ static int osc_checksum_seq_show(struct seq_file *m, void *v) obd->u.cli.cl_checksum ? 1 : 0); } -static ssize_t osc_checksum_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t osc_checksum_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; int val, rc; @@ -358,11 +364,12 @@ static int osc_checksum_type_seq_show(struct seq_file *m, void *v) else seq_printf(m, "%s ", cksum_name[i]); } - seq_printf(m, "\n"); + seq_putc(m, '\n'); return 0; } -static ssize_t osc_checksum_type_seq_write(struct file *file, const char *buffer, +static ssize_t osc_checksum_type_seq_write(struct file *file, + const char __user *buffer, size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; @@ -401,8 +408,9 @@ static int osc_resend_count_seq_show(struct seq_file *m, void *v) return seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends)); } -static ssize_t osc_resend_count_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t osc_resend_count_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; int val, rc; @@ -428,8 +436,9 @@ static int osc_contention_seconds_seq_show(struct seq_file *m, void *v) return seq_printf(m, "%u\n", od->od_contention_time); } -static ssize_t osc_contention_seconds_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t osc_contention_seconds_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; struct osc_device *od = obd2osc_dev(obd); @@ -447,8 +456,9 @@ static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v) return seq_printf(m, "%u\n", od->od_lockless_truncate); } -static ssize_t osc_lockless_truncate_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t osc_lockless_truncate_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; struct osc_device *od = obd2osc_dev(obd); @@ -472,7 +482,8 @@ static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v) } static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file, - const char *buffer, size_t count, loff_t *off) + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *dev = ((struct seq_file *)file->private_data)->private; struct client_obd *cli = &dev->u.cli; @@ -590,9 +601,9 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) seq_printf(seq, "pending read pages: %d\n", atomic_read(&cli->cl_pending_r_pages)); - seq_printf(seq, "\n\t\t\tread\t\t\twrite\n"); - seq_printf(seq, "pages per rpc rpcs %% cum %% |"); - seq_printf(seq, " rpcs %% cum %%\n"); + seq_puts(seq, "\n\t\t\tread\t\t\twrite\n"); + seq_puts(seq, "pages per rpc rpcs % cum % |"); + seq_puts(seq, " rpcs % cum %\n"); read_tot = lprocfs_oh_sum(&cli->cl_read_page_hist); write_tot = lprocfs_oh_sum(&cli->cl_write_page_hist); @@ -613,9 +624,9 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) break; } - seq_printf(seq, "\n\t\t\tread\t\t\twrite\n"); - seq_printf(seq, "rpcs in flight rpcs %% cum %% |"); - seq_printf(seq, " rpcs %% cum %%\n"); + seq_puts(seq, "\n\t\t\tread\t\t\twrite\n"); + seq_puts(seq, "rpcs in flight rpcs % cum % |"); + seq_puts(seq, " rpcs % cum %\n"); read_tot = lprocfs_oh_sum(&cli->cl_read_rpc_hist); write_tot = lprocfs_oh_sum(&cli->cl_write_rpc_hist); @@ -636,9 +647,9 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) break; } - seq_printf(seq, "\n\t\t\tread\t\t\twrite\n"); - seq_printf(seq, "offset rpcs %% cum %% |"); - seq_printf(seq, " rpcs %% cum %%\n"); + seq_puts(seq, "\n\t\t\tread\t\t\twrite\n"); + seq_puts(seq, "offset rpcs % cum % |"); + seq_puts(seq, " rpcs % cum %\n"); read_tot = lprocfs_oh_sum(&cli->cl_read_offset_hist); write_tot = lprocfs_oh_sum(&cli->cl_write_offset_hist); @@ -664,8 +675,9 @@ 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 *buf, - size_t len, loff_t *off) +static ssize_t osc_rpc_stats_seq_write(struct file *file, + const char __user *buf, + size_t len, loff_t *off) { struct seq_file *seq = file->private_data; struct obd_device *dev = seq->private; @@ -702,8 +714,9 @@ static int osc_stats_seq_show(struct seq_file *seq, void *v) return 0; } -static ssize_t osc_stats_seq_write(struct file *file, const char *buf, - size_t len, loff_t *off) +static ssize_t osc_stats_seq_write(struct file *file, + const char __user *buf, + size_t len, loff_t *off) { struct seq_file *seq = file->private_data; struct obd_device *dev = seq->private; diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 370e6d4896c6..7022ed42d2d1 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1820,6 +1820,9 @@ static int try_to_add_extent_for_io(struct client_obd *cli, int *pc, unsigned int *max_pages) { struct osc_extent *tmp; + struct osc_async_page *oap = list_first_entry(&ext->oe_pages, + struct osc_async_page, + oap_pending_item); EASSERT((ext->oe_state == OES_CACHE || ext->oe_state == OES_LOCK_DONE), ext); @@ -1829,6 +1832,10 @@ static int try_to_add_extent_for_io(struct client_obd *cli, return 0; list_for_each_entry(tmp, rpclist, oe_link) { + struct osc_async_page *oap2; + + oap2 = list_first_entry(&tmp->oe_pages, struct osc_async_page, + oap_pending_item); EASSERT(tmp->oe_owner == current, tmp); #if 0 if (overlapped(tmp, ext)) { @@ -1836,6 +1843,11 @@ static int try_to_add_extent_for_io(struct client_obd *cli, EASSERT(0, ext); } #endif + if (oap2cl_page(oap)->cp_type != oap2cl_page(oap2)->cp_type) { + CDEBUG(D_CACHE, "Do not permit different type of IO" + " for a same RPC\n"); + return 0; + } if (tmp->oe_srvlock != ext->oe_srvlock || !tmp->oe_grants != !ext->oe_grants) diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index d788dac93cd0..af96c7bc7764 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -160,11 +160,6 @@ static inline unsigned long rpcs_in_flight(struct client_obd *cli) return cli->cl_r_in_flight + cli->cl_w_in_flight; } -#ifndef min_t -#define min_t(type, x, y) \ - ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) -#endif - struct osc_device { struct cl_device od_cl; struct obd_export *od_exp; diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index a7f08bc48166..445655724904 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -100,14 +100,14 @@ static int osc_lock_invariant(struct osc_lock *ols) /* * If all the following "ergo"s are true, return 1, otherwise 0 */ - if (! ergo(olock != NULL, handle_used)) + if (!ergo(olock != NULL, handle_used)) return 0; - if (! ergo(olock != NULL, + if (!ergo(olock != NULL, olock->l_handle.h_cookie == ols->ols_handle.cookie)) return 0; - if (! ergo(handle_used, + if (!ergo(handle_used, ergo(lock != NULL && olock != NULL, lock == olock) && ergo(lock == NULL, olock == NULL))) return 0; @@ -115,18 +115,18 @@ static int osc_lock_invariant(struct osc_lock *ols) * Check that ->ols_handle and ->ols_lock are consistent, but * take into account that they are set at the different time. */ - if (! ergo(ols->ols_state == OLS_CANCELLED, + if (!ergo(ols->ols_state == OLS_CANCELLED, olock == NULL && !handle_used)) return 0; /* * DLM lock is destroyed only after we have seen cancellation * ast. */ - if (! ergo(olock != NULL && ols->ols_state < OLS_CANCELLED, + if (!ergo(olock != NULL && ols->ols_state < OLS_CANCELLED, ((olock->l_flags & LDLM_FL_DESTROYED) == 0))) return 0; - if (! ergo(ols->ols_state == OLS_GRANTED, + if (!ergo(ols->ols_state == OLS_GRANTED, olock != NULL && olock->l_req_mode == olock->l_granted_mode && ols->ols_hold)) diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index b9450b95f1c5..0adfa707a763 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -3332,7 +3332,7 @@ extern struct lu_kmem_descr osc_caches[]; extern spinlock_t osc_ast_guard; extern struct lock_class_key osc_ast_guard_class; -int __init osc_init(void) +static int __init osc_init(void) { struct lprocfs_static_vars lvars = { NULL }; int rc; diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index dc9e406f3212..4882dd0a4483 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -1247,7 +1247,9 @@ static int after_reply(struct ptlrpc_request *req) time_t now = get_seconds(); DEBUG_REQ(D_RPCTRACE, req, "Resending request on EINPROGRESS"); + spin_lock(&req->rq_lock); req->rq_resend = 1; + spin_unlock(&req->rq_lock); req->rq_nr_resend++; /* allocate new xid to avoid reply reconstruction */ @@ -1497,11 +1499,13 @@ static inline int ptlrpc_set_producer(struct ptlrpc_request_set *set) int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) { struct list_head *tmp, *next; + struct list_head comp_reqs; int force_timer_recalc = 0; if (atomic_read(&set->set_remaining) == 0) return 1; + INIT_LIST_HEAD(&comp_reqs); list_for_each_safe(tmp, next, &set->set_requests) { struct ptlrpc_request *req = list_entry(tmp, struct ptlrpc_request, @@ -1576,8 +1580,10 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) ptlrpc_rqphase_move(req, req->rq_next_phase); } - if (req->rq_phase == RQ_PHASE_COMPLETE) + if (req->rq_phase == RQ_PHASE_COMPLETE) { + list_move_tail(&req->rq_set_chain, &comp_reqs); continue; + } if (req->rq_phase == RQ_PHASE_INTERPRET) goto interpret; @@ -1860,9 +1866,15 @@ interpret: if (req->rq_status != 0) set->set_rc = req->rq_status; ptlrpc_req_finished(req); + } else { + list_move_tail(&req->rq_set_chain, &comp_reqs); } } + /* move completed request at the head of list so it's easier for + * caller to find them */ + list_splice(&comp_reqs, &set->set_requests); + /* If we hit an error, we want to recover promptly. */ return atomic_read(&set->set_remaining) == 0 || force_timer_recalc; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index dc5ceb55d001..bbef666b1d16 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -65,7 +65,6 @@ #endif /* struct ptlrpc_request, lustre_msg* */ #include "../include/lustre_req_layout.h" -#include "../include/lustre_update.h" #include "../include/lustre_acl.h" #include "../include/lustre_debug.h" diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 4011e0050fcb..0e2071b8a36e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -45,7 +45,7 @@ #include "ptlrpc_internal.h" -struct ll_rpc_opcode { +static struct ll_rpc_opcode { __u32 opcode; const char *opname; } ll_rpc_opcode_table[LUSTRE_MAX_OPCODES] = { @@ -136,7 +136,7 @@ struct ll_rpc_opcode { { UPDATE_OBJ, "update_obj" }, }; -struct ll_eopcode { +static struct ll_eopcode { __u32 opcode; const char *opname; } ll_eopcode_table[EXTRA_LAST_OPC] = { @@ -175,15 +175,17 @@ const char *ll_opcode2str(__u32 opcode) return ll_rpc_opcode_table[offset].opname; } -const char *ll_eopcode2str(__u32 opcode) +static const char *ll_eopcode2str(__u32 opcode) { LASSERT(ll_eopcode_table[opcode].opcode == opcode); return ll_eopcode_table[opcode].opname; } + #if defined (CONFIG_PROC_FS) -void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir, - char *name, struct proc_dir_entry **procroot_ret, - struct lprocfs_stats **stats_ret) +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) { struct proc_dir_entry *svc_procroot; struct lprocfs_stats *svc_stats; @@ -284,8 +286,9 @@ 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 *buffer, - size_t count, loff_t *off) +ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; int bufpages; @@ -329,8 +332,9 @@ ptlrpc_lprocfs_threads_min_seq_show(struct seq_file *m, void *n) } static ssize_t -ptlrpc_lprocfs_threads_min_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +ptlrpc_lprocfs_threads_min_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; int val; @@ -381,8 +385,9 @@ ptlrpc_lprocfs_threads_max_seq_show(struct seq_file *m, void *n) } static ssize_t -ptlrpc_lprocfs_threads_max_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +ptlrpc_lprocfs_threads_max_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; int val; @@ -723,7 +728,7 @@ struct ptlrpc_srh_iterator { struct ptlrpc_request *srhi_req; }; -int +static int ptlrpc_lprocfs_svc_req_history_seek(struct ptlrpc_service_part *svcpt, struct ptlrpc_srh_iterator *srhi, __u64 seq) @@ -1025,7 +1030,7 @@ static int ptlrpc_lprocfs_hp_ratio_seq_show(struct seq_file *m, void *v) } static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file, - const char *buffer, + const char __user *buffer, size_t count, loff_t *off) { @@ -1175,7 +1180,7 @@ EXPORT_SYMBOL(ptlrpc_lprocfs_unregister_obd); #define BUFLEN (UUID_MAX + 5) -int lprocfs_wr_evict_client(struct file *file, const char *buffer, +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; @@ -1223,7 +1228,7 @@ EXPORT_SYMBOL(lprocfs_wr_evict_client); #undef BUFLEN -int lprocfs_wr_ping(struct file *file, const char *buffer, +int lprocfs_wr_ping(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; @@ -1251,7 +1256,7 @@ EXPORT_SYMBOL(lprocfs_wr_ping); * The connection UUID is a node's primary NID. For example, * "echo connection=192.168.0.1@tcp0::instance > .../import". */ -int lprocfs_wr_import(struct file *file, const char *buffer, +int lprocfs_wr_import(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; @@ -1329,7 +1334,7 @@ int lprocfs_rd_pinger_recov(struct seq_file *m, void *n) } EXPORT_SYMBOL(lprocfs_rd_pinger_recov); -int lprocfs_wr_pinger_recov(struct file *file, const char *buffer, +int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index cbcc541cac43..4621b71fe0b6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -306,21 +306,16 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) if (atomic_read(&set->set_remaining)) rc |= ptlrpc_check_set(env, set); - if (!list_empty(&set->set_requests)) { - /* - * XXX: our set never completes, so we prune the completed - * reqs after each iteration. boy could this be smarter. - */ - list_for_each_safe(pos, tmp, &set->set_requests) { - req = list_entry(pos, struct ptlrpc_request, - rq_set_chain); - if (req->rq_phase != RQ_PHASE_COMPLETE) - continue; + /* NB: ptlrpc_check_set has already moved completed request at the + * head of seq::set_requests */ + list_for_each_safe(pos, tmp, &set->set_requests) { + req = list_entry(pos, struct ptlrpc_request, rq_set_chain); + if (req->rq_phase != RQ_PHASE_COMPLETE) + break; - list_del_init(&req->rq_set_chain); - req->rq_set = NULL; - ptlrpc_req_finished(req); - } + list_del_init(&req->rq_set_chain); + req->rq_set = NULL; + ptlrpc_req_finished(req); } if (rc == 0) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index c500aff66193..81de68edb04e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c @@ -47,6 +47,8 @@ #include "../include/lustre_net.h" #include "../include/lustre_sec.h" +#include "ptlrpc_internal.h" + #define SEC_GC_INTERVAL (30 * 60) |