From f217946f21d3c70ada558c27ad5de60fff40295c Mon Sep 17 00:00:00 2001 From: bobijam Date: Wed, 6 Aug 2008 03:12:37 +0000 Subject: [PATCH] Branch b1_6 b=16317 o=Herb Wartens(hwartens@llnl.gov) i=wangdi, johann Description: exports in /proc are broken Details : recreate /proc entries for clients when they reconnect. --- lustre/ChangeLog | 5 ++ lustre/include/lprocfs_status.h | 37 ++++++----- lustre/include/lustre_export.h | 11 +++- lustre/include/obd.h | 15 +++-- lustre/include/obd_class.h | 17 ++--- lustre/ldlm/ldlm_lib.c | 42 ++++++------ lustre/ldlm/ldlm_lockd.c | 44 ++++++++----- lustre/mds/handler.c | 49 +++++++------- lustre/mds/mds_fs.c | 30 +++++++-- lustre/mds/mds_internal.h | 9 ++- lustre/mgs/mgs_fs.c | 38 ++++++++--- lustre/mgs/mgs_handler.c | 52 +++++++-------- lustre/mgs/mgs_internal.h | 8 ++- lustre/obdclass/lprocfs_status.c | 139 +++++++++++++++++++++++++++++++-------- lustre/obdfilter/filter.c | 50 +++++++++----- lustre/osc/osc_request.c | 43 ++++++------ lustre/ptlrpc/import.c | 85 ++++++++++++------------ 17 files changed, 429 insertions(+), 245 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 440c945..5ef978d 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -39,6 +39,11 @@ tbd Sun Microsystems, Inc. old (verbose) output can be obtained by using -v option. Severity : normal +Bugzilla : 16317 +Description: exports in /proc are broken +Details : recreate /proc entries for clients when they reconnect. + +Severity : normal Bugzilla : 16080 Description: don't fail open with -ERANGE Details : if client connected until mds will be know about real ost count diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index bcef57c..4ac84b1 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -339,11 +339,11 @@ extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx, #define lprocfs_counter_decr(stats, idx) \ lprocfs_counter_sub(stats, idx, 1) -extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc, +extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc, enum lprocfs_fields_flags field); -static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, - int idx, +static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, + int idx, enum lprocfs_fields_flags field) { __u64 ret = 0; @@ -356,12 +356,13 @@ static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, return ret; } -extern struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num, +extern struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags); extern void lprocfs_clear_stats(struct lprocfs_stats *stats); extern void lprocfs_free_stats(struct lprocfs_stats **stats); -extern void lprocfs_init_ops_stats(int num_private_stats, +extern void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats); +extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats); extern int lprocfs_alloc_obd_stats(struct obd_device *obddev, unsigned int num_private_stats); extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index, @@ -410,7 +411,7 @@ extern int lprocfs_nid_stats_clear_read(char *page, char **start, off_t off, extern struct file_operations lprocfs_evict_client_fops; -extern int lprocfs_seq_create(cfs_proc_dir_entry_t *parent, char *name, +extern int lprocfs_seq_create(cfs_proc_dir_entry_t *parent, char *name, mode_t mode, struct file_operations *seq_fops, void *data); extern int lprocfs_obd_seq_create(struct obd_device *dev, char *name, @@ -446,7 +447,7 @@ extern int lprocfs_rd_num_exports(char *page, char **start, off_t off, extern int lprocfs_rd_numrefs(char *page, char **start, off_t off, int count, int *eof, void *data); struct adaptive_timeout; -extern int lprocfs_at_hist_helper(char *page, int count, int rc, +extern int lprocfs_at_hist_helper(char *page, int count, int rc, struct adaptive_timeout *at); extern int lprocfs_rd_timeouts(char *page, char **start, off_t off, int count, int *eof, void *data); @@ -477,7 +478,7 @@ extern int lprocfs_write_helper(const char *buffer, unsigned long count, int *val); extern int lprocfs_write_frac_helper(const char *buffer, unsigned long count, int *val, int mult); -extern int lprocfs_read_frac_helper(char *buffer, unsigned long count, +extern int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, int mult); extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count, __u64 *val); @@ -517,7 +518,7 @@ extern struct rw_semaphore _lprocfs_lock; } \ } while(0) -/* You must use these macros when you want to refer to +/* You must use these macros when you want to refer to * the import in a client obd_device for a lprocfs entry */ #define LPROCFS_CLIMP_CHECK(obd) do { \ typecheck(struct obd_device *, obd); \ @@ -531,8 +532,8 @@ extern struct rw_semaphore _lprocfs_lock; up_read(&(obd)->u.cli.cl_sem); -/* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only - proc entries; otherwise, you will define name##_seq_write function also for +/* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only + proc entries; otherwise, you will define name##_seq_write function also for a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally, call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */ #define __LPROC_SEQ_FOPS(name, custom_seq_write) \ @@ -632,8 +633,8 @@ static inline void lprocfs_counter_init(struct lprocfs_stats *stats, const char *name, const char *units) { return; } -static inline __u64 lc_read_helper(struct lprocfs_counter *lc, - enum lprocfs_fields_flags field) +static inline __u64 lc_read_helper(struct lprocfs_counter *lc, + enum lprocfs_fields_flags field) { return 0; } static inline struct lprocfs_stats* lprocfs_alloc_stats(unsigned int num, @@ -647,9 +648,11 @@ static inline int lprocfs_register_stats(cfs_proc_dir_entry_t *root, const char *name, struct lprocfs_stats *stats) { return 0; } -static inline void lprocfs_init_ops_stats(int num_private_stats, +static inline void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats) { return; } +static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) +{ return; } static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev, unsigned int num_private_stats) { return 0; } @@ -660,7 +663,7 @@ struct obd_export; static inline int lprocfs_add_clear_entry(struct obd_export *exp) { return 0; } static inline int lprocfs_exp_setup(struct obd_export *exp, - lnet_nid_t *peer_nid, int *newnid) + lnet_nid_t *peer_nid, int *newnid) { return 0; } static inline int lprocfs_exp_cleanup(struct obd_export *exp) { return 0; } @@ -717,7 +720,7 @@ static inline int lprocfs_rd_numrefs(char *page, char **start, off_t off, int count, int *eof, void *data) { return 0; } struct adaptive_timeout; -static inline int lprocfs_at_hist_helper(char *page, int count, int rc, +static inline int lprocfs_at_hist_helper(char *page, int count, int rc, struct adaptive_timeout *at) { return 0; } static inline int lprocfs_rd_timeouts(char *page, char **start, off_t off, @@ -772,7 +775,7 @@ int lprocfs_counter_write(struct file *file, const char *buffer, unsigned long count, void *data) { return 0; } static inline -__u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx, +__u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx, enum lprocfs_fields_flags field) { return (__u64)0; } diff --git a/lustre/include/lustre_export.h b/lustre/include/lustre_export.h index 035b16c..5210627 100644 --- a/lustre/include/lustre_export.h +++ b/lustre/include/lustre_export.h @@ -87,22 +87,30 @@ struct filter_export_data { struct brw_stats fed_brw_stats; }; +typedef struct nid_stat_uuid { + struct list_head ns_uuid_list; + struct obd_uuid ns_uuid; +} nid_stat_uuid_t; + typedef struct nid_stat { lnet_nid_t nid; struct hlist_node nid_hash; struct list_head nid_list; + struct list_head nid_uuid_list; struct obd_device *nid_obd; struct proc_dir_entry *nid_proc; struct lprocfs_stats *nid_stats; struct brw_stats *nid_brw_stats; + struct lprocfs_stats *nid_ldlm_stats; int nid_exp_ref_count; -}nid_stat_t; +} nid_stat_t; struct obd_export { struct portals_handle exp_handle; atomic_t exp_refcount; atomic_t exp_rpc_count; struct obd_uuid exp_client_uuid; + lnet_nid_t exp_client_nid; struct list_head exp_obd_chain; struct hlist_node exp_uuid_hash; /* uuid-export hash*/ struct hlist_node exp_nid_hash; /* nid-export hash */ @@ -111,7 +119,6 @@ struct obd_export { struct obd_device *exp_obd; struct obd_import *exp_imp_reverse; /* to make RPCs backwards */ struct nid_stat *exp_nid_stats; - struct lprocfs_stats *exp_ldlm_stats; struct lprocfs_stats *exp_ops_stats; struct ptlrpc_connection *exp_connection; __u32 exp_conn_cnt; diff --git a/lustre/include/obd.h b/lustre/include/obd.h index a21c90e..f4d198a 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -448,7 +448,7 @@ struct client_obd { __u32 cl_supp_cksum_types; /* checksum algorithm to be used */ cksum_type_t cl_cksum_type; - + /* also protected by the poorly named _loi_list_lock lock above */ struct osc_async_rc cl_ar; @@ -805,7 +805,7 @@ struct obd_device { unsigned long obd_attached:1, /* finished attach */ obd_set_up:1, /* finished setup */ obd_recovering:1, /* there are recoverable clients */ - obd_abort_recovery:1,/* somebody ioctl'ed us to abort */ + obd_abort_recovery:1,/* somebody ioctl'ed us to abort */ obd_replayable:1, /* recovery is enabled; inform clients */ obd_no_transno:1, /* no committed-transno notification */ obd_no_recov:1, /* fail instead of retry messages */ @@ -839,7 +839,7 @@ struct obd_device { struct fsfilt_operations *obd_fsops; spinlock_t obd_osfs_lock; struct obd_statfs obd_osfs; /* locked by obd_osfs_lock */ - __u64 obd_osfs_age; + __u64 obd_osfs_age; struct lvfs_run_ctxt obd_lvfs_ctxt; struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS]; struct obd_device *obd_observer; @@ -971,7 +971,8 @@ struct obd_ops { void *localdata); int (*o_reconnect)(struct obd_export *exp, struct obd_device *src, struct obd_uuid *cluuid, - struct obd_connect_data *ocd); + struct obd_connect_data *ocd, + void *localdata); int (*o_disconnect)(struct obd_export *exp); int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs, @@ -1010,7 +1011,7 @@ struct obd_ops { int (*o_prep_async_page)(struct obd_export *exp, struct lov_stripe_md *lsm, struct lov_oinfo *loi, - cfs_page_t *page, obd_off offset, + cfs_page_t *page, obd_off offset, struct obd_async_page_ops *ops, void *data, void **res, int nocache, struct lustre_handle *lockh); @@ -1091,7 +1092,7 @@ struct obd_ops { /* llog related obd_methods */ int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd, - int count, struct llog_catid *logid, + int count, struct llog_catid *logid, struct obd_uuid *uuid); int (*o_llog_finish)(struct obd_device *obd, int count); @@ -1127,7 +1128,7 @@ struct obd_ops { obd_lock_cancel_cb cb); int (*o_unregister_lock_cancel_cb)(struct obd_export *exp, obd_lock_cancel_cb cb); - + /* * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c. diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index e0812fd..c1e7a5c 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -104,7 +104,7 @@ void obd_zombie_impexp_cull(void); /* obd_config.c */ int class_process_config(struct lustre_cfg *lcfg); -int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, +int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, struct lustre_cfg *lcfg, void *data); int class_attach(struct lustre_cfg *lcfg); int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg); @@ -135,7 +135,7 @@ struct config_llog_instance { struct super_block *cfg_sb; struct obd_uuid cfg_uuid; int cfg_last_idx; /* for partial llog processing */ - int cfg_flags; + int cfg_flags; }; int class_config_parse_llog(struct llog_ctxt *ctxt, char *name, struct config_llog_instance *cfg); @@ -353,7 +353,7 @@ static inline int obd_set_info_async(struct obd_export *exp, obd_count keylen, EXP_CHECK_OP(exp, set_info_async); EXP_COUNTER_INCREMENT(exp, set_info_async); - rc = OBP(exp->exp_obd, set_info_async)(exp, keylen, key, vallen, val, + rc = OBP(exp->exp_obd, set_info_async)(exp, keylen, key, vallen, val, set); RETURN(rc); } @@ -370,7 +370,7 @@ static inline int obd_setup(struct obd_device *obd, int datalen, void *data) RETURN(rc); } -static inline int obd_precleanup(struct obd_device *obd, +static inline int obd_precleanup(struct obd_device *obd, enum obd_cleanup_stage cleanup_stage) { int rc; @@ -678,7 +678,8 @@ static inline int obd_connect(struct lustre_handle *conn,struct obd_device *obd, static inline int obd_reconnect(struct obd_export *exp, struct obd_device *obd, struct obd_uuid *cluuid, - struct obd_connect_data *d) + struct obd_connect_data *d, + void *localdata) { int rc; __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition check */ @@ -688,7 +689,7 @@ static inline int obd_reconnect(struct obd_export *exp, OBD_CHECK_OP(obd, reconnect, 0); OBD_COUNTER_INCREMENT(obd, reconnect); - rc = OBP(obd, reconnect)(exp, obd, cluuid, d); + rc = OBP(obd, reconnect)(exp, obd, cluuid, d, localdata); /* check that only subset is granted */ LASSERT(ergo(d != NULL, (d->ocd_connect_flags & ocf) == d->ocd_connect_flags)); @@ -1344,13 +1345,13 @@ static inline int obd_notify(struct obd_device *obd, /* the check for async_recov is a complete hack - I'm hereby overloading the meaning to also mean "this was called from mds_postsetup". I know that my mds is able to handle notifies - by this point, and it needs to get them to execute mds_postrecov. */ + by this point, and it needs to get them to execute mds_postrecov. */ if (!obd->obd_set_up && !obd->obd_async_recov) { CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name); RETURN(-EINVAL); } - if (!OBP(obd, notify)) + if (!OBP(obd, notify)) RETURN(-ENOSYS); OBD_COUNTER_INCREMENT(obd, notify); diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index a63bc36..6657654 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -492,7 +492,7 @@ int client_disconnect_export(struct obd_export *exp) ldlm_cli_cancel_unused(obd->obd_namespace, NULL, obd->obd_force ? LDLM_FL_LOCAL_ONLY:0, NULL); - ldlm_namespace_free_prior(obd->obd_namespace, imp, + ldlm_namespace_free_prior(obd->obd_namespace, imp, obd->obd_force); to_be_freed = obd->obd_namespace; } @@ -575,7 +575,7 @@ void target_client_add_cb(struct obd_device *obd, __u64 transno, void *cb_data, } EXPORT_SYMBOL(target_client_add_cb); -static void +static void target_start_and_reset_recovery_timer(struct obd_device *obd, svc_handler_t handler, struct ptlrpc_request *req, @@ -630,13 +630,13 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler) if (target->obd_no_conn) { LCONSOLE_WARN("%s: temporarily refusing client connection " - "from %s\n", target->obd_name, + "from %s\n", target->obd_name, libcfs_nid2str(req->rq_peer.nid)); GOTO(out, rc = -EAGAIN); } - /* Make sure the target isn't cleaned up while we're here. Yes, - there's still a race between the above check and our incref here. + /* Make sure the target isn't cleaned up while we're here. Yes, + there's still a race between the above check and our incref here. Really, class_uuid2obd should take the ref. */ targref = class_incref(target); @@ -824,7 +824,7 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler) client_nid); } } else { - rc = obd_reconnect(export, target, &cluuid, data); + rc = obd_reconnect(export, target, &cluuid, data, client_nid); } if (rc) @@ -1196,15 +1196,15 @@ static void reset_recovery_timer(struct obd_device *obd, int duration, /* Track the client's largest expected replay time */ obd->obd_recovery_timeout = duration; #ifdef CRAY_XT3 - /* - * If total recovery time already exceed the - * obd_recovery_max_time, then CRAY XT3 will + /* + * If total recovery time already exceed the + * obd_recovery_max_time, then CRAY XT3 will * abort the recovery */ if(obd->obd_recovery_timeout > obd->obd_recovery_max_time) obd->obd_recovery_timeout = obd->obd_recovery_max_time; #endif - obd->obd_recovery_end = obd->obd_recovery_start + + obd->obd_recovery_end = obd->obd_recovery_start + obd->obd_recovery_timeout; if (cfs_time_before(now, obd->obd_recovery_end)) { left = cfs_time_sub(obd->obd_recovery_end, now); @@ -1219,7 +1219,7 @@ static void check_and_start_recovery_timer(struct obd_device *obd, svc_handler_t handler) { spin_lock_bh(&obd->obd_processing_task_lock); - if (obd->obd_recovery_handler) { + if (obd->obd_recovery_handler) { spin_unlock_bh(&obd->obd_processing_task_lock); return; } @@ -1236,12 +1236,12 @@ static void check_and_start_recovery_timer(struct obd_device *obd, /* Reset the timer with each new client connection */ /* - * This timer is actually reconnect_timer, which is for making sure - * the total recovery window is at least as big as my reconnect + * This timer is actually reconnect_timer, which is for making sure + * the total recovery window is at least as big as my reconnect * attempt timing. So the initial recovery time_out will be set to * OBD_RECOVERY_FACTOR * obd_timeout. If the timeout coming * from client is bigger than this, then the recovery time_out will - * be extend to make sure the client could be reconnected, in the + * be extend to make sure the client could be reconnected, in the * process, the timeout from the new client should be ignored. */ @@ -1251,7 +1251,7 @@ target_start_and_reset_recovery_timer(struct obd_device *obd, struct ptlrpc_request *req, int new_client) { - int req_timeout = OBD_RECOVERY_FACTOR * + int req_timeout = OBD_RECOVERY_FACTOR * lustre_msg_get_timeout(req->rq_reqmsg); check_and_start_recovery_timer(obd, handler); @@ -1539,7 +1539,7 @@ int target_queue_last_replay_reply(struct ptlrpc_request *req, int rc) export */ if (req->rq_export->exp_replay_needed) { --obd->obd_recoverable_clients; - + spin_lock(&req->rq_export->exp_lock); req->rq_export->exp_replay_needed = 0; spin_unlock(&req->rq_export->exp_lock); @@ -1576,9 +1576,9 @@ int target_pack_pool_reply(struct ptlrpc_request *req) { struct obd_device *obd; ENTRY; - - /* - * Check that we still have all structures alive as this may + + /* + * Check that we still have all structures alive as this may * be some late rpc in shutdown time. */ if (unlikely(!req->rq_export || !req->rq_export->exp_obd || @@ -1588,8 +1588,8 @@ int target_pack_pool_reply(struct ptlrpc_request *req) RETURN(0); } - /* - * OBD is alive here as export is alive, which we checked above. + /* + * OBD is alive here as export is alive, which we checked above. */ obd = req->rq_export->exp_obd; diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 8fb4f95..d6b92b5 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -316,7 +316,7 @@ static int __ldlm_add_waiting_lock(struct ldlm_lock *lock) timeout_rounded = round_timeout(lock->l_callback_timeout); - if (cfs_time_before(timeout_rounded, + if (cfs_time_before(timeout_rounded, cfs_timer_deadline(&waiting_locks_timer)) || !cfs_timer_is_armed(&waiting_locks_timer)) { cfs_timer_arm(&waiting_locks_timer, timeout_rounded); @@ -657,9 +657,11 @@ int ldlm_server_blocking_ast(struct ldlm_lock *lock, if (AT_OFF) req->rq_timeout = ldlm_get_rq_timeout(); - if (lock->l_export && lock->l_export->exp_ldlm_stats) - lprocfs_counter_incr(lock->l_export->exp_ldlm_stats, + if (lock->l_export && lock->l_export->exp_nid_stats && + lock->l_export->exp_nid_stats->nid_ldlm_stats) { + lprocfs_counter_incr(lock->l_export->exp_nid_stats->nid_ldlm_stats, LDLM_BL_CALLBACK - LDLM_FIRST_OPC); + } rc = ldlm_bl_and_cp_ast_fini(req, arg, lock, instant_cancel); @@ -762,9 +764,11 @@ int ldlm_server_completion_ast(struct ldlm_lock *lock, int flags, void *data) } unlock_res_and_lock(lock); - if (lock->l_export && lock->l_export->exp_ldlm_stats) - lprocfs_counter_incr(lock->l_export->exp_ldlm_stats, + if (lock->l_export && lock->l_export->exp_nid_stats && + lock->l_export->exp_nid_stats->nid_ldlm_stats) { + lprocfs_counter_incr(lock->l_export->exp_nid_stats->nid_ldlm_stats, LDLM_CP_CALLBACK - LDLM_FIRST_OPC); + } rc = ldlm_bl_and_cp_ast_fini(req, arg, lock, instant_cancel); @@ -804,9 +808,11 @@ int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data) if (AT_OFF) req->rq_timeout = ldlm_get_rq_timeout(); - if (lock->l_export && lock->l_export->exp_ldlm_stats) - lprocfs_counter_incr(lock->l_export->exp_ldlm_stats, + if (lock->l_export && lock->l_export->exp_nid_stats && + lock->l_export->exp_nid_stats->nid_ldlm_stats) { + lprocfs_counter_incr(lock->l_export->exp_nid_stats->nid_ldlm_stats, LDLM_GL_CALLBACK - LDLM_FIRST_OPC); + } rc = ptlrpc_queue_wait(req); if (rc == -ELDLM_NO_LOCK_DATA) @@ -915,9 +921,11 @@ int ldlm_handle_enqueue(struct ptlrpc_request *req, ldlm_svc_get_eopc(dlm_req, req->rq_rqbd->rqbd_service->srv_stats); - if (req->rq_export->exp_ldlm_stats) - lprocfs_counter_incr(req->rq_export->exp_ldlm_stats, + if (req->rq_export && req->rq_export->exp_nid_stats && + req->rq_export->exp_nid_stats->nid_ldlm_stats) { + lprocfs_counter_incr(req->rq_export->exp_nid_stats->nid_ldlm_stats, LDLM_ENQUEUE - LDLM_FIRST_OPC); + } if (dlm_req->lock_desc.l_resource.lr_type < LDLM_MIN_TYPE || dlm_req->lock_desc.l_resource.lr_type >= LDLM_MAX_TYPE) { @@ -1164,9 +1172,11 @@ int ldlm_handle_convert(struct ptlrpc_request *req) RETURN (-EFAULT); } - if (req->rq_export && req->rq_export->exp_ldlm_stats) - lprocfs_counter_incr(req->rq_export->exp_ldlm_stats, + if (req->rq_export && req->rq_export->exp_nid_stats && + req->rq_export->exp_nid_stats->nid_ldlm_stats) { + lprocfs_counter_incr(req->rq_export->exp_nid_stats->nid_ldlm_stats, LDLM_CONVERT - LDLM_FIRST_OPC); + } rc = lustre_pack_reply(req, 2, size, NULL); if (rc) @@ -1273,9 +1283,11 @@ int ldlm_handle_cancel(struct ptlrpc_request *req) RETURN(-EFAULT); } - if (req->rq_export && req->rq_export->exp_ldlm_stats) - lprocfs_counter_incr(req->rq_export->exp_ldlm_stats, + if (req->rq_export && req->rq_export->exp_nid_stats && + req->rq_export->exp_nid_stats->nid_ldlm_stats) { + lprocfs_counter_incr(req->rq_export->exp_nid_stats->nid_ldlm_stats, LDLM_CANCEL - LDLM_FIRST_OPC); + } rc = lustre_pack_reply(req, 1, NULL, NULL); if (rc) @@ -1371,7 +1383,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, &lock->l_resource->lr_name, sizeof(lock->l_resource->lr_name)) != 0) { unlock_res_and_lock(lock); - if (ldlm_lock_change_resource(ns, lock, + if (ldlm_lock_change_resource(ns, lock, dlm_req->lock_desc.l_resource.lr_name)) { LDLM_ERROR(lock, "Failed to allocate resource"); LDLM_LOCK_PUT(lock); @@ -1440,7 +1452,7 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req, if (lock->l_granted_mode == LCK_PW && !lock->l_readers && !lock->l_writers && cfs_time_after(cfs_time_current(), - cfs_time_add(lock->l_last_used, + cfs_time_add(lock->l_last_used, cfs_time_seconds(10)))) { unlock_res_and_lock(lock); if (ldlm_bl_to_thread_lock(ns, NULL, lock)) @@ -2057,7 +2069,7 @@ static int ldlm_cleanup(void) #endif ENTRY; - if (!list_empty(ldlm_namespace_list(LDLM_NAMESPACE_SERVER)) || + if (!list_empty(ldlm_namespace_list(LDLM_NAMESPACE_SERVER)) || !list_empty(ldlm_namespace_list(LDLM_NAMESPACE_CLIENT))) { CERROR("ldlm still has namespaces; clean these up first.\n"); ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE); diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index fa6b08c..d5e58f0 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -192,7 +192,7 @@ struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid, struct dentry *de = mds_fid2dentry(mds, fid, mnt), *retval = de; struct ldlm_res_id res_id = { .name = {0} }; int flags = LDLM_FL_ATOMIC_CB, rc; - ldlm_policy_data_t policy = { .l_inodebits = { lockpart} }; + ldlm_policy_data_t policy = { .l_inodebits = { lockpart} }; ENTRY; if (IS_ERR(de)) @@ -200,8 +200,8 @@ struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid, res_id.name[0] = de->d_inode->i_ino; res_id.name[1] = de->d_inode->i_generation; - rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, - LDLM_IBITS, &policy, lock_mode, &flags, + rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, + LDLM_IBITS, &policy, lock_mode, &flags, ldlm_blocking_ast, ldlm_completion_ast, NULL, NULL, 0, NULL, lockh); if (rc != ELDLM_OK) { @@ -277,7 +277,7 @@ struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, RETURN(result); } -static int mds_connect_internal(struct obd_export *exp, +static int mds_connect_internal(struct obd_export *exp, struct obd_connect_data *data) { struct obd_device *obd = exp->exp_obd; @@ -314,7 +314,8 @@ static int mds_connect_internal(struct obd_export *exp, static int mds_reconnect(struct obd_export *exp, struct obd_device *obd, struct obd_uuid *cluuid, - struct obd_connect_data *data) + struct obd_connect_data *data, + void *localdata) { int rc; ENTRY; @@ -323,6 +324,8 @@ static int mds_reconnect(struct obd_export *exp, struct obd_device *obd, RETURN(-EINVAL); rc = mds_connect_internal(exp, data); + if (rc == 0) + mds_export_stats_init(obd, exp, localdata); RETURN(rc); } @@ -404,7 +407,7 @@ int mds_init_export(struct obd_export *exp) INIT_LIST_HEAD(&med->med_open_head); spin_lock_init(&med->med_open_lock); - + spin_lock(&exp->exp_lock); exp->exp_connecting = 1; spin_unlock(&exp->exp_lock); @@ -569,7 +572,7 @@ static int mds_getstatus(struct ptlrpc_request *req) /* get the LOV EA from @inode and store it into @md. It can be at most * @size bytes, and @size is updated with the actual EA size. - * The EA size is also returned on success, and -ve errno on failure. + * The EA size is also returned on success, and -ve errno on failure. * If there is no EA then 0 is returned. */ int mds_get_md(struct obd_device *obd, struct inode *inode, void *md, int *size, int lock, int flags) @@ -966,7 +969,7 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, } #endif - /* child_lockh() is only set in fixup_handle_for_resent_req() + /* child_lockh() is only set in fixup_handle_for_resent_req() * if MSG_RESENT is set */ if (lustre_handle_is_used(child_lockh)) { LASSERT(lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT); @@ -976,9 +979,9 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, if (resent_req == 0) { if (name) { OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_RESEND, obd_timeout*2); - rc = mds_get_parent_child_locked(obd, &obd->u.mds, + rc = mds_get_parent_child_locked(obd, &obd->u.mds, &body->fid1, - &parent_lockh, + &parent_lockh, &dparent, LCK_CR, MDS_INODELOCK_UPDATE, name, namesize, @@ -992,7 +995,7 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, LASSERT(dchild); if (IS_ERR(dchild)) rc = PTR_ERR(dchild); - } + } if (rc) GOTO(cleanup, rc); } else { @@ -1001,7 +1004,7 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, struct ldlm_resource *res; DEBUG_REQ(D_DLMTRACE, req, "resent, not enqueuing new locks"); granted_lock = ldlm_handle2lock(child_lockh); - /* lock was granted in fixup_handle_for_resent_req() if + /* lock was granted in fixup_handle_for_resent_req() if * MSG_RESENT is set */ LASSERTF(granted_lock != NULL, LPU64"/%u lockh "LPX64"\n", body->fid1.id, body->fid1.generation, @@ -1145,7 +1148,7 @@ static int mds_statfs(struct ptlrpc_request *req) /* This will trigger a watchdog timeout */ OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_STATFS_LCW_SLEEP, - (MDS_SERVICE_WATCHDOG_FACTOR * + (MDS_SERVICE_WATCHDOG_FACTOR * at_get(&svc->srv_at_estimate) / 1000) + 1); OBD_COUNTER_INCREMENT(obd, statfs); @@ -2177,10 +2180,10 @@ static int mds_postsetup(struct obd_device *obd) if (mds->mds_profile) { struct lustre_profile *lprof; - /* The profile defines which osc and mdc to connect to, for a + /* The profile defines which osc and mdc to connect to, for a client. We reuse that here to figure out the name of the lov to use (and ignore lprof->lp_mdc). - The profile was set in the config log with + The profile was set in the config log with LCFG_MOUNTOPT profilenm oscnm mdcnm */ lprof = class_get_profile(mds->mds_profile); if (lprof == NULL) { @@ -2211,7 +2214,7 @@ int mds_postrecov(struct obd_device *obd) RETURN(0); LASSERT(!obd->obd_recovering); - ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); + ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); LASSERT(ctxt != NULL); llog_ctxt_put(ctxt); @@ -2224,7 +2227,7 @@ int mds_postrecov(struct obd_device *obd) /* Notify the LOV, which will in turn call mds_notify for each tgt */ /* This means that we have to hack obd_notify to think we're obd_set_up during mds_lov_connect. */ - obd_notify(obd->u.mds.mds_osc_obd, NULL, + obd_notify(obd->u.mds.mds_osc_obd, NULL, obd->obd_async_recov ? OBD_NOTIFY_SYNC_NONBLOCK : OBD_NOTIFY_SYNC, NULL); @@ -2471,7 +2474,7 @@ static int mds_intent_policy(struct ldlm_namespace *ns, !intent_disposition(rep, DISP_OPEN_LOCK)) { /* If it is the disconnect error (ENODEV & ENOCONN) * ptlrpc layer should know this imediately, it should - * be replied by rq_stats, otherwise, return it by + * be replied by rq_stats, otherwise, return it by * intent here */ if (IS_CLIENT_DISCONNECT_ERROR(rep->lock_policy_res2)) @@ -2603,12 +2606,12 @@ static int mdt_setup(struct obd_device *obd, obd_count len, void *buf) mds_max_threads = mds_min_threads = mds_num_threads; } else { /* Base min threads on memory and cpus */ - mds_min_threads = num_possible_cpus() * num_physpages >> + mds_min_threads = num_possible_cpus() * num_physpages >> (27 - CFS_PAGE_SHIFT); if (mds_min_threads < MDS_THREADS_MIN) mds_min_threads = MDS_THREADS_MIN; /* Largest auto threads start value */ - if (mds_min_threads > 32) + if (mds_min_threads > 32) mds_min_threads = 32; mds_max_threads = min(MDS_THREADS_MAX, mds_min_threads * 4); } @@ -2761,9 +2764,9 @@ static int mds_process_config(struct obd_device *obd, obd_count len, void *buf) int rc; lprocfs_mds_init_vars(&lvars); - + rc = class_process_proc_param(PARAM_MDT, lvars.obd_vars, lcfg, obd); - + return(rc); } @@ -2818,7 +2821,7 @@ static int __init mds_init(void) return rc; } init_obd_quota_ops(mds_quota_interface_ref, &mds_obd_ops); - + lprocfs_mds_init_vars(&lvars); class_register_type(&mds_obd_ops, lvars.module_vars, LUSTRE_MDS_NAME); lprocfs_mdt_init_vars(&lvars); diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index d0689d6..d52ca47 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -64,15 +64,21 @@ #include "mds_internal.h" -static int mds_export_stats_init(struct obd_device *obd, +int mds_export_stats_init(struct obd_device *obd, struct obd_export *exp, - void *client_nid) - { + void *localdata) +{ + lnet_nid_t *client_nid = localdata; int rc, num_stats, newnid = 0; rc = lprocfs_exp_setup(exp, client_nid, &newnid); - if (rc) + if (rc) { + /* Mask error for already created + * /proc entries */ + if (rc == -EALREADY) + rc = 0; return rc; + } if (newnid) { struct nid_stat *tmp = exp->exp_nid_stats; @@ -92,6 +98,20 @@ static int mds_export_stats_init(struct obd_device *obd, return rc; mds_stats_counter_init(tmp->nid_stats); + + /* Always add in ldlm_stats */ + tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - + LDLM_FIRST_OPC, + 0); + if (tmp->nid_ldlm_stats == NULL) + return -ENOMEM; + + lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats); + + rc = lprocfs_register_stats(tmp->nid_proc, "ldlm_stats", + tmp->nid_ldlm_stats); + if (rc) + return rc; } return 0; @@ -770,7 +790,7 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa, lock_kernel(); rc = ll_vfs_rename(mds->mds_objects_dir->d_inode, filp->f_dentry, - filp->f_vfsmnt, mds->mds_objects_dir->d_inode, + filp->f_vfsmnt, mds->mds_objects_dir->d_inode, new_child, filp->f_vfsmnt); unlock_kernel(); if (rc) diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h index c57ea74..ac2f1e3 100644 --- a/lustre/mds/mds_internal.h +++ b/lustre/mds/mds_internal.h @@ -155,7 +155,7 @@ int enqueue_ordered_locks(struct obd_device *obd, struct ldlm_res_id *p1_res_id, ldlm_policy_data_t *p2_policy); void mds_commit_cb(struct obd_device *, __u64 last_rcvd, void *data, int error); int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle, - struct ptlrpc_request *req, int rc, __u32 op_data, + struct ptlrpc_request *req, int rc, __u32 op_data, int force_sync); void mds_reconstruct_generic(struct ptlrpc_request *req); void mds_req_from_lcd(struct ptlrpc_request *req, struct lsd_client_data *cd); @@ -227,7 +227,7 @@ int mds_lov_prepare_objids(struct obd_device *obd, struct lov_mds_md *lmm); void mds_lov_update_objids(struct obd_device *obd, struct lov_mds_md *lmm); int mds_lov_clear_orphans(struct mds_obd *mds, struct obd_uuid *ost_uuid); -int mds_lov_start_synchronize(struct obd_device *obd, +int mds_lov_start_synchronize(struct obd_device *obd, struct obd_device *watched, void *data, int nonblock); int mds_post_mds_lovconf(struct obd_device *obd); @@ -254,10 +254,13 @@ int mds_close(struct ptlrpc_request *req, int offset); int mds_done_writing(struct ptlrpc_request *req, int offset); /*mds/mds_join.c*/ -int mds_join_file(struct mds_update_record *rec, struct ptlrpc_request *req, +int mds_join_file(struct mds_update_record *rec, struct ptlrpc_request *req, struct dentry *dchild, struct lustre_handle *lockh); /* mds/mds_fs.c */ +int mds_export_stats_init(struct obd_device *obd, + struct obd_export *exp, + void *client_nid); int mds_client_add(struct obd_device *obd, struct obd_export *exp, int cl_off, void *localdata); int mds_client_free(struct obd_export *exp); diff --git a/lustre/mgs/mgs_fs.c b/lustre/mgs/mgs_fs.c index 735a3d5..5dff42f 100644 --- a/lustre/mgs/mgs_fs.c +++ b/lustre/mgs/mgs_fs.c @@ -61,13 +61,21 @@ #include "mgs_internal.h" -static int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp) +static int mgs_export_stats_init(struct obd_device *obd, + struct obd_export *exp, + void *localdata) { + lnet_nid_t *client_nid = localdata; int rc, num_stats, newnid = 0; - rc = lprocfs_exp_setup(exp, NULL, &newnid); - if (rc) + rc = lprocfs_exp_setup(exp, client_nid, &newnid); + if (rc) { + /* Mask error for already created + * /proc entries */ + if (rc == -EALREADY) + rc = 0; return rc; + } if (newnid) { num_stats = (sizeof(*obd->obd_type->typ_ops) / sizeof(void *)) + @@ -79,7 +87,19 @@ static int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp) lprocfs_init_ops_stats(LPROC_MGS_LAST, exp->exp_ops_stats); mgs_stats_counter_init(exp->exp_ops_stats); lprocfs_register_stats(exp->exp_nid_stats->nid_proc, "stats", exp->exp_ops_stats); + + /* Always add in ldlm_stats */ + exp->exp_nid_stats->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - + LDLM_FIRST_OPC, 0); + if (exp->exp_nid_stats->nid_ldlm_stats == NULL) + return -ENOMEM; + + lprocfs_init_ldlm_stats(exp->exp_nid_stats->nid_ldlm_stats); + + rc = lprocfs_register_stats(exp->exp_nid_stats->nid_proc, "ldlm_stats", + exp->exp_nid_stats->nid_ldlm_stats); } + return 0; } @@ -87,9 +107,11 @@ static int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp) * disk in the last_rcvd file or anywhere else. In the event of a MGS * crash all connections are treated as new connections. */ -int mgs_client_add(struct obd_device *obd, struct obd_export *exp) +int mgs_client_add(struct obd_device *obd, + struct obd_export *exp, + void *localdata) { - return mgs_export_stats_init(obd, exp); + return mgs_export_stats_init(obd, exp, localdata); } /* Remove client export data from the MGS */ @@ -115,9 +137,9 @@ static struct dentry *mgs_fid2dentry(struct mgs_obd *mgs, struct ll_fid *fid) if (ino == 0) RETURN(ERR_PTR(-ESTALE)); - + snprintf(fid_name, sizeof(fid_name), "0x%lx", ino); - + /* under ext3 this is neither supposed to return bad inodes nor NULL inodes. */ result = ll_lookup_one_len(fid_name, mgs->mgs_fid_de, strlen(fid_name)); @@ -198,7 +220,7 @@ int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt) dentry = simple_mkdir(current->fs->pwd, mnt, MOUNT_CONFIGS_DIR, 0777, 1); if (IS_ERR(dentry)) { rc = PTR_ERR(dentry); - CERROR("cannot create %s directory: rc = %d\n", + CERROR("cannot create %s directory: rc = %d\n", MOUNT_CONFIGS_DIR, rc); GOTO(err_pop, rc); } diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 7477625..7ab1244 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -88,7 +88,7 @@ static int mgs_connect(struct lustre_handle *conn, struct obd_device *obd, data->ocd_version = LUSTRE_VERSION_CODE; } - rc = mgs_client_add(obd, exp); + rc = mgs_client_add(obd, exp, localdata); if (rc) { class_disconnect(exp); @@ -150,7 +150,7 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf) /* Find our disk */ lmi = server_get_mount(obd->obd_name); - if (!lmi) + if (!lmi) RETURN(rc = -EINVAL); mnt = lmi->lmi_mnt; @@ -160,7 +160,7 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf) GOTO(err_put, rc = PTR_ERR(obd->obd_fsops)); /* namespace for mgs llog */ - obd->obd_namespace = ldlm_namespace_new(obd, "MGS", LDLM_NAMESPACE_SERVER, + obd->obd_namespace = ldlm_namespace_new(obd, "MGS", LDLM_NAMESPACE_SERVER, LDLM_NAMESPACE_MODEST); if (obd->obd_namespace == NULL) GOTO(err_ops, rc = -ENOMEM); @@ -263,7 +263,7 @@ static int mgs_cleanup(struct obd_device *obd) if (mgs->mgs_sb == NULL) RETURN(0); - + ping_evictor_stop(); ptlrpc_unregister_service(mgs->mgs_service); @@ -292,15 +292,15 @@ static int mgs_get_cfg_lock(struct obd_device *obd, char *fsname, ENTRY; rc = mgc_fsname2resid(fsname, &res_id); - if (!rc) + if (!rc) rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, LDLM_PLAIN, NULL, LCK_EX, &flags, ldlm_blocking_ast, ldlm_completion_ast, NULL, fsname, 0, NULL, lockh); - if (rc) + if (rc) CERROR("can't take cfg lock for %s (%d)\n", fsname, rc); - + RETURN(rc); } @@ -335,7 +335,7 @@ static int mgs_check_target(struct obd_device *obd, struct mgs_target_info *mti) } else { /* Index is correctly marked as used */ - /* If the logs don't contain the mti_nids then add + /* If the logs don't contain the mti_nids then add them as failover nids */ rc = mgs_check_failnid(obd, mti); } @@ -345,7 +345,7 @@ static int mgs_check_target(struct obd_device *obd, struct mgs_target_info *mti) /* Called whenever a target starts up. Flags indicate first connect, etc. */ static int mgs_handle_target_reg(struct ptlrpc_request *req) -{ +{ struct obd_device *obd = req->rq_export->exp_obd; struct lustre_handle lockh; struct mgs_target_info *mti, *rep_mti; @@ -357,7 +357,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) mti = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*mti), lustre_swab_mgs_target_info); - + if (!(mti->mti_flags & (LDD_F_WRITECONF | LDD_F_UPGRADE14 | LDD_F_UPDATE))) { /* We're just here as a startup ping. */ @@ -365,14 +365,14 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) mti->mti_svname, obd_export_nid2str(req->rq_export)); rc = mgs_check_target(obd, mti); /* above will set appropriate mti flags */ - if (rc <= 0) + if (rc <= 0) /* Nothing wrong, or fatal error */ GOTO(out_nolock, rc); } /* Revoke the config lock to make sure nobody is reading. */ /* Although actually I think it should be alright if - someone was reading while we were updating the logs - if we + someone was reading while we were updating the logs - if we revoke at the end they will just update from where they left off. */ lockrc = mgs_get_cfg_lock(obd, mti->mti_fsname, &lockh); if (lockrc != ELDLM_OK) { @@ -403,7 +403,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) } mti->mti_flags |= LDD_F_UPDATE; /* Erased logs means start from scratch. */ - mti->mti_flags &= ~LDD_F_UPGRADE14; + mti->mti_flags &= ~LDD_F_UPGRADE14; } /* COMPAT_146 */ @@ -413,26 +413,26 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) CERROR("Can't upgrade from 1.4 (%d)\n", rc); GOTO(out, rc); } - + /* We're good to go */ mti->mti_flags |= LDD_F_UPDATE; } /* end COMPAT_146 */ if (mti->mti_flags & LDD_F_UPDATE) { - CDEBUG(D_MGS, "updating %s, index=%d\n", mti->mti_svname, + CDEBUG(D_MGS, "updating %s, index=%d\n", mti->mti_svname, mti->mti_stripe_index); - - /* create or update the target log + + /* create or update the target log and update the client/mdt logs */ rc = mgs_write_log_target(obd, mti); if (rc) { - CERROR("Failed to write %s log (%d)\n", + CERROR("Failed to write %s log (%d)\n", mti->mti_svname, rc); GOTO(out, rc); } - mti->mti_flags &= ~(LDD_F_VIRGIN | LDD_F_UPDATE | + mti->mti_flags &= ~(LDD_F_VIRGIN | LDD_F_UPDATE | LDD_F_NEED_INDEX | LDD_F_WRITECONF | LDD_F_UPGRADE14); mti->mti_flags |= LDD_F_REWRITE_LDD; @@ -443,9 +443,9 @@ out: if (lockrc == ELDLM_OK) mgs_put_cfg_lock(&lockh); out_nolock: - CDEBUG(D_MGS, "replying with %s, index=%d, rc=%d\n", mti->mti_svname, + CDEBUG(D_MGS, "replying with %s, index=%d, rc=%d\n", mti->mti_svname, mti->mti_stripe_index, rc); - lustre_pack_reply(req, 2, rep_size, NULL); + lustre_pack_reply(req, 2, rep_size, NULL); /* send back the whole mti in the reply */ rep_mti = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*rep_mti)); @@ -620,8 +620,8 @@ int mgs_handle(struct ptlrpc_request *req) } LASSERT(current->journal_info == NULL); - - if (rc) + + if (rc) CERROR("MGS handle cmd=%d rc=%d\n", opc, rc); out: @@ -673,7 +673,7 @@ int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (lcfg == NULL) RETURN(-ENOMEM); rc = copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1); - if (rc) + if (rc) GOTO(out_free, rc); if (lcfg->lcfg_bufcount < 1) @@ -691,8 +691,8 @@ int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len, writing (above). */ if (fsname[0]) { lockrc = mgs_get_cfg_lock(obd, fsname, &lockh); - if (lockrc != ELDLM_OK) - CERROR("lock error %d for fs %s\n", lockrc, + if (lockrc != ELDLM_OK) + CERROR("lock error %d for fs %s\n", lockrc, fsname); else mgs_put_cfg_lock(&lockh); diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h index 8ed4114..6a81fde 100644 --- a/lustre/mgs/mgs_internal.h +++ b/lustre/mgs/mgs_internal.h @@ -50,7 +50,7 @@ /* mgs_llog.c */ int class_dentry_readdir(struct obd_device *obd, struct dentry *dir, - struct vfsmount *inmnt, + struct vfsmount *inmnt, struct list_head *dentry_list); #define INDEX_MAP_SIZE 8192 /* covers indicies to FFFF */ @@ -83,7 +83,9 @@ int mgs_erase_logs(struct obd_device *obd, char *fsname); int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname); /* mgs_fs.c */ -int mgs_client_add(struct obd_device *obd, struct obd_export *exp); +int mgs_client_add(struct obd_device *obd, + struct obd_export *exp, + void *localdata); int mgs_client_free(struct obd_export *exp); int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt); int mgs_fs_cleanup(struct obd_device *obddev); @@ -97,7 +99,7 @@ int lproc_mgs_add_live(struct obd_device *obd, struct fs_db *fsdb); int lproc_mgs_del_live(struct obd_device *obd, struct fs_db *fsdb); void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars); #else -static inline int lproc_mgs_setup(struct obd_device *dev) +static inline int lproc_mgs_setup(struct obd_device *dev) {return 0;} static inline int lproc_mgs_cleanup(struct obd_device *obd) {return 0;} diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 5522d9d..c1dd431 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -117,7 +117,7 @@ int lprocfs_add_simple(struct proc_dir_entry *root, char *name, { struct proc_dir_entry *proc; mode_t mode = 0; - + if (root == NULL || name == NULL) return -EINVAL; if (read_proc) @@ -152,7 +152,7 @@ static ssize_t lprocfs_fops_read(struct file *f, char __user *buf, size_t size, LPROCFS_ENTRY(); OBD_FAIL_TIMEOUT(OBD_FAIL_LPROC_REMOVE, 10); if (!dp->deleted && dp->read_proc) - rc = dp->read_proc(page, &start, *ppos, PAGE_SIZE, + rc = dp->read_proc(page, &start, *ppos, PAGE_SIZE, &eof, dp->data); LPROCFS_EXIT(); if (rc <= 0) @@ -328,7 +328,7 @@ void lprocfs_remove(struct proc_dir_entry **rooth) "0x%p %s/%s len %d\n", rm_entry, temp->name, rm_entry->name, (int)strlen(rm_entry->name)); - /* Now, the rm_entry->deleted flags is protected + /* Now, the rm_entry->deleted flags is protected * by _lprocfs_lock. */ rm_entry->data = NULL; remove_proc_entry(rm_entry->name, temp); @@ -414,14 +414,14 @@ int lprocfs_wr_atomic(struct file *file, const char *buffer, atomic_t *atm = data; int val = 0; int rc; - + rc = lprocfs_write_helper(buffer, count, &val); if (rc < 0) return rc; if (val <= 0) return -ERANGE; - + atomic_set(atm, val); return count; } @@ -583,7 +583,7 @@ int lprocfs_rd_conn_uuid(char *page, char **start, off_t off, int count, struct ptlrpc_connection *conn; int rc = 0; - LASSERT(obd != NULL); + LASSERT(obd != NULL); LPROCFS_CLIMP_CHECK(obd); conn = obd->u.cli.cl_import->imp_connection; LASSERT(conn != NULL); @@ -594,12 +594,12 @@ int lprocfs_rd_conn_uuid(char *page, char **start, off_t off, int count, return rc; } -int lprocfs_at_hist_helper(char *page, int count, int rc, +int lprocfs_at_hist_helper(char *page, int count, int rc, struct adaptive_timeout *at) { int i; for (i = 0; i < AT_BINS; i++) - rc += snprintf(page + rc, count - rc, "%3u ", at->at_hist[i]); + rc += snprintf(page + rc, count - rc, "%3u ", at->at_hist[i]); rc += snprintf(page + rc, count - rc, "\n"); return rc; } @@ -624,7 +624,7 @@ int lprocfs_rd_timeouts(char *page, char **start, off_t off, int count, /* Some network health info for kicks */ s2dhms(&ts, now - imp->imp_last_reply_time); - rc += snprintf(page + rc, count - rc, + rc += snprintf(page + rc, count - rc, "%-10s : %ld, "DHMS_FMT" ago\n", "last reply", imp->imp_last_reply_time, DHMS_VARS(&ts)); @@ -633,11 +633,11 @@ int lprocfs_rd_timeouts(char *page, char **start, off_t off, int count, worst = imp->imp_at.iat_net_latency.at_worst_ever; worstt = imp->imp_at.iat_net_latency.at_worst_time; s2dhms(&ts, now - worstt); - rc += snprintf(page + rc, count - rc, + rc += snprintf(page + rc, count - rc, "%-10s : cur %3u worst %3u (at %ld, "DHMS_FMT" ago) ", - "network", cur, worst, worstt, DHMS_VARS(&ts)); + "network", cur, worst, worstt, DHMS_VARS(&ts)); rc = lprocfs_at_hist_helper(page, count, rc, - &imp->imp_at.iat_net_latency); + &imp->imp_at.iat_net_latency); for(i = 0; i < IMP_AT_MAX_PORTALS; i++) { if (imp->imp_at.iat_portal[i] == 0) @@ -648,7 +648,7 @@ int lprocfs_rd_timeouts(char *page, char **start, off_t off, int count, s2dhms(&ts, now - worstt); rc += snprintf(page + rc, count - rc, "portal %-2d : cur %3u worst %3u (at %ld, " - DHMS_FMT" ago) ", imp->imp_at.iat_portal[i], + DHMS_FMT" ago) ", imp->imp_at.iat_portal[i], cur, worst, worstt, DHMS_VARS(&ts)); rc = lprocfs_at_hist_helper(page, count, rc, &imp->imp_at.iat_service_estimate[i]); @@ -758,7 +758,7 @@ int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list) int lprocfs_obd_cleanup(struct obd_device *obd) { - if (!obd) + if (!obd) return -EINVAL; if (obd->obd_proc_exports_entry) { /* Should be no exports left */ @@ -789,6 +789,9 @@ static void lprocfs_free_client_stats(struct nid_stat *client_stat) if (client_stat->nid_brw_stats) OBD_FREE(client_stat->nid_brw_stats, sizeof(struct brw_stats)); + if (client_stat->nid_ldlm_stats) + lprocfs_free_stats(&client_stat->nid_ldlm_stats); + OBD_FREE(client_stat, sizeof(*client_stat)); return; @@ -869,7 +872,7 @@ void lprocfs_free_stats(struct lprocfs_stats **statsh) unsigned int num_cpu; unsigned int percpusize; unsigned int i; - + if (!stats || (stats->ls_num == 0)) return; *statsh = NULL; @@ -1167,6 +1170,29 @@ void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats) LPROCFS_OBD_OP_INIT(num_private_stats, stats,unregister_lock_cancel_cb); } +void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) +{ + lprocfs_counter_init(ldlm_stats, + LDLM_ENQUEUE - LDLM_FIRST_OPC, + 0, "ldlm_enqueue", "reqs"); + lprocfs_counter_init(ldlm_stats, + LDLM_CONVERT - LDLM_FIRST_OPC, + 0, "ldlm_convert", "reqs"); + lprocfs_counter_init(ldlm_stats, + LDLM_CANCEL - LDLM_FIRST_OPC, + 0, "ldlm_cancel", "reqs"); + lprocfs_counter_init(ldlm_stats, + LDLM_BL_CALLBACK - LDLM_FIRST_OPC, + 0, "ldlm_bl_callback", "reqs"); + lprocfs_counter_init(ldlm_stats, + LDLM_CP_CALLBACK - LDLM_FIRST_OPC, + 0, "ldlm_cp_callback", "reqs"); + lprocfs_counter_init(ldlm_stats, + LDLM_GL_CALLBACK - LDLM_FIRST_OPC, + 0, "ldlm_gl_callback", "reqs"); +} + + int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats) { struct lprocfs_stats *stats; @@ -1207,7 +1233,7 @@ int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats) void lprocfs_free_obd_stats(struct obd_device *obd) { - if (obd->obd_stats) + if (obd->obd_stats) lprocfs_free_stats(&obd->obd_stats); } @@ -1324,8 +1350,9 @@ EXPORT_SYMBOL(lprocfs_nid_stats_clear_write); int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) { int rc = 0; - struct nid_stat *tmp = NULL, *tmp1; - struct obd_device *obd = NULL; + struct nid_stat *tmp, *tmp1; + struct nid_stat_uuid *cursor, *tmp_ns_uuid; + struct obd_device *obd; ENTRY; *newnid = 0; @@ -1348,6 +1375,16 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) if (tmp == NULL) RETURN(-ENOMEM); + OBD_ALLOC(tmp_ns_uuid, sizeof(struct nid_stat_uuid)); + if (tmp_ns_uuid == NULL) { + OBD_FREE(tmp, sizeof(struct nid_stat)); + RETURN(-ENOMEM); + } + CFS_INIT_LIST_HEAD(&tmp_ns_uuid->ns_uuid_list); + strncpy(tmp_ns_uuid->ns_uuid.uuid, exp->exp_client_uuid.uuid, + sizeof(struct obd_uuid)); + + CFS_INIT_LIST_HEAD(&tmp->nid_uuid_list); tmp->nid = *nid; tmp->nid_obd = exp->exp_obd; tmp->nid_exp_ref_count = 1; /* need live in hash after destroy export */ @@ -1357,14 +1394,38 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) list_add(&tmp->nid_list, &obd->obd_nid_stats); spin_unlock(&obd->obd_nid_lock); - tmp1= lustre_hash_findadd_unique(obd->obd_nid_stats_hash_body, nid, - &tmp->nid_hash); + tmp1 = lustre_hash_findadd_unique(obd->obd_nid_stats_hash_body, nid, + &tmp->nid_hash); CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n", tmp1, libcfs_nid2str(*nid), tmp->nid_exp_ref_count); + /* Return -EALREADY here so that we know that the /proc + * entry already has been created */ if (tmp1 != tmp) { + int found = 0; + exp->exp_nid_stats = tmp1; - GOTO(destroy_new, rc = 0); + + /* We need to decrement the refcount if the uuid was + * already in our list */ + spin_lock(&obd->obd_nid_lock); + list_for_each_entry(cursor, + &tmp1->nid_uuid_list, + ns_uuid_list) { + if (cursor && obd_uuid_equals(&cursor->ns_uuid, + &exp->exp_client_uuid)) { + found = 1; + --tmp1->nid_exp_ref_count; + break; + } + } + + if (!found) + list_add(&tmp_ns_uuid->ns_uuid_list, + &tmp1->nid_uuid_list); + spin_unlock(&obd->obd_nid_lock); + + GOTO(destroy_new, rc = -EALREADY); } /* not found - create */ tmp->nid_proc = proc_mkdir(libcfs_nid2str(*nid), @@ -1377,6 +1438,11 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) GOTO(destroy_new, rc = -ENOMEM); } + /* Add in uuid to our nid_stats list */ + spin_lock(&obd->obd_nid_lock); + list_add(&tmp_ns_uuid->ns_uuid_list, &tmp->nid_uuid_list); + spin_unlock(&obd->obd_nid_lock); + rc = lprocfs_add_simple(tmp->nid_proc, "uuid", lprocfs_exp_rd_uuid, NULL, tmp); if (rc) @@ -1397,15 +1463,33 @@ destroy_new: int lprocfs_exp_cleanup(struct obd_export *exp) { struct nid_stat *stat = exp->exp_nid_stats; + struct nid_stat_uuid *cursor, *tmp; + int found = 0; - if(!stat) + if(!stat || !exp->exp_obd) RETURN(0); + spin_lock(&exp->exp_obd->obd_nid_lock); + list_for_each_entry_safe(cursor, tmp, + &stat->nid_uuid_list, + ns_uuid_list) { + if (cursor && obd_uuid_equals(&cursor->ns_uuid, + &exp->exp_client_uuid)) { + found = 1; + list_del(&cursor->ns_uuid_list); + OBD_FREE(cursor, sizeof(struct nid_stat_uuid)); + break; + } + } + spin_unlock(&exp->exp_obd->obd_nid_lock); + if (!found) + CERROR("obd_export's client uuid %s are not found in its " + "nid_stats list\n", exp->exp_client_uuid.uuid); + stat->nid_exp_ref_count--; CDEBUG(D_INFO, "Put stat %p - %d\n", stat, stat->nid_exp_ref_count); exp->exp_nid_stats = NULL; - lprocfs_free_stats(&exp->exp_ldlm_stats); lprocfs_free_stats(&exp->exp_ops_stats); return 0; @@ -1488,7 +1572,7 @@ int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, int mu 2. #echo x.0x > /proc/xxx output result : x.0x 3. #echo x.x0 > /proc/xxx output result : x.x 4. #echo x.xx > /proc/xxx output result : x.xx - Only reserved 2bits fraction. + Only reserved 2bits fraction. */ for (i = 0; i < (5 - prtn); i++) temp_mult *= 10; @@ -1576,7 +1660,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count, return 0; } -int lprocfs_seq_create(cfs_proc_dir_entry_t *parent, +int lprocfs_seq_create(cfs_proc_dir_entry_t *parent, char *name, mode_t mode, struct file_operations *seq_fops, void *data) { @@ -1598,7 +1682,7 @@ __inline__ int lprocfs_obd_seq_create(struct obd_device *dev, char *name, struct file_operations *seq_fops, void *data) { - return (lprocfs_seq_create(dev->obd_proc_entry, name, + return (lprocfs_seq_create(dev->obd_proc_entry, name, mode, seq_fops, data)); } EXPORT_SYMBOL(lprocfs_obd_seq_create); @@ -1751,7 +1835,7 @@ int lprocfs_obd_rd_recovery_maxtime(char *page, char **start, off_t off, struct obd_device *obd = (struct obd_device *)data; LASSERT(obd != NULL); - return snprintf(page, count, "%lu\n", + return snprintf(page, count, "%lu\n", obd->obd_recovery_max_time); } EXPORT_SYMBOL(lprocfs_obd_rd_recovery_maxtime); @@ -1786,6 +1870,7 @@ EXPORT_SYMBOL(lprocfs_free_stats); EXPORT_SYMBOL(lprocfs_clear_stats); EXPORT_SYMBOL(lprocfs_register_stats); EXPORT_SYMBOL(lprocfs_init_ops_stats); +EXPORT_SYMBOL(lprocfs_init_ldlm_stats); EXPORT_SYMBOL(lprocfs_alloc_obd_stats); EXPORT_SYMBOL(lprocfs_free_obd_stats); EXPORT_SYMBOL(lprocfs_exp_setup); diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 8c2c734..9674e8b 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -134,7 +134,7 @@ int filter_finish_transno(struct obd_export *exp, struct obd_trans_info *oti, err = -EINVAL; } else { if (!force_sync) - force_sync = fsfilt_add_journal_cb(exp->exp_obd, + force_sync = fsfilt_add_journal_cb(exp->exp_obd, last_rcvd, oti->oti_handle, filter_commit_cb, @@ -211,9 +211,15 @@ static int filter_export_stats_init(struct obd_device *obd, if (obd_uuid_equals(&exp->exp_client_uuid, &obd->obd_uuid)) /* Self-export gets no proc entry */ RETURN(0); - rc = lprocfs_exp_setup(exp, client_nid, &newnid); - if (rc) + rc = lprocfs_exp_setup(exp, (lnet_nid_t *)client_nid, &newnid); + if (rc) { + /* Mask error for already created + * /proc entries */ + if (rc == -EALREADY) + rc = 0; + RETURN(rc); + } if (newnid) { struct nid_stat *tmp = exp->exp_nid_stats; @@ -241,6 +247,17 @@ static int filter_export_stats_init(struct obd_device *obd, tmp->nid_stats); if (rc) RETURN(rc); + + /* Always add in ldlm_stats */ + tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - + LDLM_FIRST_OPC, 0); + if (tmp->nid_ldlm_stats == NULL) + return -ENOMEM; + + lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats); + + rc = lprocfs_register_stats(tmp->nid_proc, "ldlm_stats", + tmp->nid_ldlm_stats); } RETURN(0); @@ -594,7 +611,7 @@ static int filter_init_export(struct obd_export *exp) { spin_lock_init(&exp->exp_filter_data.fed_lock); INIT_LIST_HEAD(&exp->exp_filter_data.fed_mod_list); - + spin_lock(&exp->exp_lock); exp->exp_connecting = 1; spin_unlock(&exp->exp_lock); @@ -937,7 +954,7 @@ static int filter_prep_groups(struct obd_device *obd) int i, rc = 0, cleanup_phase = 0; ENTRY; - O_dentry = simple_mkdir(current->fs->pwd, filter->fo_vfsmnt, + O_dentry = simple_mkdir(current->fs->pwd, filter->fo_vfsmnt, "O", 0700, 1); CDEBUG(D_INODE, "got/created O: %p\n", O_dentry); if (IS_ERR(O_dentry)) { @@ -965,7 +982,7 @@ static int filter_prep_groups(struct obd_device *obd) loff_t off = 0; sprintf(name, "%d", i); - dentry = simple_mkdir(O_dentry, filter->fo_vfsmnt, + dentry = simple_mkdir(O_dentry, filter->fo_vfsmnt, name, 0700, 1); CDEBUG(D_INODE, "got/created O/%s: %p\n", name, dentry); if (IS_ERR(dentry)) { @@ -1472,7 +1489,7 @@ static int filter_intent_policy(struct ldlm_namespace *ns, /* If we grant any lock at all, it will be a whole-file read lock. * Call the extent policy function to see if our request can be - * granted, or is blocked. + * granted, or is blocked. * If the OST lock has LDLM_FL_HAS_INTENT set, it means a glimpse lock */ lock->l_policy_data.l_extent.start = 0; @@ -1537,7 +1554,7 @@ static int filter_intent_policy(struct ldlm_namespace *ns, if (tree->lit_mode == LCK_PR) continue; - interval_iterate_reverse(tree->lit_root, + interval_iterate_reverse(tree->lit_root, filter_intent_cb, &arg); } unlock_res(res); @@ -1988,7 +2005,7 @@ static int filter_llog_finish(struct obd_device *obd, int count) if (obd->u.filter.fo_lcm) { llog_cleanup_commit_master((struct llog_commit_master *) obd->u.filter.fo_lcm, 1); - OBD_FREE(obd->u.filter.fo_lcm, + OBD_FREE(obd->u.filter.fo_lcm, sizeof(struct llog_commit_master)); obd->u.filter.fo_lcm = NULL; } @@ -2174,7 +2191,8 @@ static int filter_connect_internal(struct obd_export *exp, static int filter_reconnect(struct obd_export *exp, struct obd_device *obd, struct obd_uuid *cluuid, - struct obd_connect_data *data) + struct obd_connect_data *data, + void *localdata) { int rc; ENTRY; @@ -2183,6 +2201,8 @@ static int filter_reconnect(struct obd_export *exp, struct obd_device *obd, RETURN(-EINVAL); rc = filter_connect_internal(exp, data); + if (rc == 0) + filter_export_stats_init(obd, exp, localdata); RETURN(rc); } @@ -3293,7 +3313,7 @@ int filter_destroy(struct obd_export *exp, struct obdo *oa, } GOTO(cleanup, rc = -ENOENT); } - + filter_prepare_destroy(obd, oa->o_id); /* Our MDC connection is established by the MDS to us */ @@ -3364,13 +3384,13 @@ cleanup: filter_cancel_cookies_cb, fcc); /* If add_journal_cb failed, then filter_finish_transno - * will commit the handle and we will do a sync - * on commit. then we call callback directly to free - * the fcc. + * will commit the handle and we will do a sync + * on commit. then we call callback directly to free + * the fcc. */ rc = filter_finish_transno(exp, oti, rc, sync); if (sync) { - filter_cancel_cookies_cb(obd, 0, fcc, rc); + filter_cancel_cookies_cb(obd, 0, fcc, rc); fcc = NULL; } rc2 = fsfilt_commit(obd, dparent->d_inode, handle, 0); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 35e3169..d04b1bf 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -75,7 +75,7 @@ static quota_interface_t *quota_interface; extern quota_interface_t osc_quota_interface; /* by default 10s */ -atomic_t osc_resend_time; +atomic_t osc_resend_time; /* Pack OSC object metadata for disk storage (LE byte order). */ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, @@ -844,7 +844,7 @@ static void handle_short_read(int nob_read, obd_count page_count, if (pga[i]->count > nob_read) { /* EOF inside this page */ - ptr = cfs_kmap(pga[i]->pg) + + ptr = cfs_kmap(pga[i]->pg) + (pga[i]->off & ~CFS_PAGE_MASK); memset(ptr + nob_read, 0, pga[i]->count - nob_read); cfs_kunmap(pga[i]->pg); @@ -1057,8 +1057,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, LASSERTF((void *)(niobuf - niocount) == lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2, niocount * sizeof(*niobuf)), - "want %p - real %p\n", lustre_msg_buf(req->rq_reqmsg, - REQ_REC_OFF + 2, niocount * sizeof(*niobuf)), + "want %p - real %p\n", lustre_msg_buf(req->rq_reqmsg, + REQ_REC_OFF + 2, niocount * sizeof(*niobuf)), (void *)(niobuf - niocount)); osc_announce_cached(cli, &body->oa, opc == OST_WRITE ? requested_nob:0); @@ -1161,7 +1161,7 @@ static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer, "["LPU64"-"LPU64"]\n", msg, libcfs_nid2str(peer->nid), oa->o_valid & OBD_MD_FLFID ? oa->o_fid : (__u64)0, - oa->o_valid & OBD_MD_FLFID ? oa->o_generation : + oa->o_valid & OBD_MD_FLFID ? oa->o_generation : (__u64)0, oa->o_id, oa->o_valid & OBD_MD_FLGROUP ? oa->o_gr : (__u64)0, @@ -1423,9 +1423,9 @@ int osc_brw_redo_request(struct ptlrpc_request *request, } } - /* use ptlrpc_set_add_req is safe because interpret functions work - * in check_set context. only one way exist with access to request - * from different thread got -EINTR - this way protected with + /* use ptlrpc_set_add_req is safe because interpret functions work + * in check_set context. only one way exist with access to request + * from different thread got -EINTR - this way protected with * cl_loi_list_lock */ ptlrpc_set_add_req(set, new_req); @@ -2532,7 +2532,7 @@ int osc_prep_async_page(struct obd_export *exp, struct lov_stripe_md *lsm, spin_lock_init(&oap->oap_lock); - /* If the page was marked as notcacheable - don't add to any locks */ + /* If the page was marked as notcacheable - don't add to any locks */ if (!nocache) { oid.name[0] = loi->loi_id; /* This is the only place where we can call cache_add_extent @@ -2842,12 +2842,12 @@ int osc_extent_blocking_cb(struct ldlm_lock *lock, { struct lustre_handle lockh = { 0 }; int rc; - ENTRY; - + ENTRY; + if ((unsigned long)data > 0 && (unsigned long)data < 0x1000) { LDLM_ERROR(lock, "cancelling lock with bad data %p", data); - LBUG(); - } + LBUG(); + } switch (flag) { case LDLM_CB_BLOCKING: @@ -3073,7 +3073,7 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, RETURN(-ENOMEM); size[DLM_LOCKREPLY_OFF] = sizeof(*rep); - size[DLM_REPLY_REC_OFF] = + size[DLM_REPLY_REC_OFF] = sizeof(oinfo->oi_md->lsm_oinfo[0]->loi_lvb); ptlrpc_req_set_repsize(req, 3, size); } @@ -3250,7 +3250,7 @@ static int osc_statfs(struct obd_device *obd, struct obd_statfs *osfs, int rc; ENTRY; - /*Since the request might also come from lprocfs, so we need + /*Since the request might also come from lprocfs, so we need *sync this with client_disconnect_export Bug15684*/ down_read(&obd->u.cli.cl_sem); if (obd->u.cli.cl_import) @@ -3258,7 +3258,7 @@ static int osc_statfs(struct obd_device *obd, struct obd_statfs *osfs, up_read(&obd->u.cli.cl_sem); if (!imp) RETURN(-ENODEV); - + /* We could possibly pass max_age in the request (as an absolute * timestamp or a "seconds.usec ago") so the target can avoid doing * extra calls into the filesystem if that isn't necessary (e.g. @@ -3610,7 +3610,7 @@ static struct llog_operations osc_size_repl_logops = { static struct llog_operations osc_mds_ost_orig_logops; static int osc_llog_init(struct obd_device *obd, struct obd_device *tgt, - int count, struct llog_catid *catid, + int count, struct llog_catid *catid, struct obd_uuid *uuid) { int rc; @@ -3635,11 +3635,11 @@ static int osc_llog_init(struct obd_device *obd, struct obd_device *tgt, rc = llog_setup(obd, LLOG_SIZE_REPL_CTXT, tgt, count, NULL, &osc_size_repl_logops); - if (rc) + if (rc) CERROR("failed LLOG_SIZE_REPL_CTXT\n"); out: if (rc) { - CERROR("osc '%s' tgt '%s' cnt %d catid %p rc=%d\n", + CERROR("osc '%s' tgt '%s' cnt %d catid %p rc=%d\n", obd->obd_name, tgt->obd_name, count, catid, rc); CERROR("logid "LPX64":0x%x\n", catid->lci_logid.lgl_oid, catid->lci_logid.lgl_ogen); @@ -3668,7 +3668,8 @@ static int osc_llog_finish(struct obd_device *obd, int count) static int osc_reconnect(struct obd_export *exp, struct obd_device *obd, struct obd_uuid *cluuid, - struct obd_connect_data *data) + struct obd_connect_data *data, + void *localdata) { struct client_obd *cli = &obd->u.cli; @@ -3702,7 +3703,7 @@ static int osc_disconnect(struct obd_export *exp) if (obd->u.cli.cl_conn_count == 1) /* flush any remaining cancel messages out to the target */ llog_sync(ctxt, exp); - + llog_ctxt_put(ctxt); rc = client_disconnect_export(exp); diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index a09fbbb..985757f 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -150,12 +150,12 @@ int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt) LCONSOLE_ERROR_MSG(0x166, "%s: Connection to service " "%.*s via nid %s was lost; in progress " "operations using this service will fail.\n", - imp->imp_obd->obd_name, target_len, target_start, + imp->imp_obd->obd_name, target_len, target_start, libcfs_nid2str(imp->imp_connection->c_peer.nid)); } IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_DISCON); spin_unlock(&imp->imp_lock); - + if (obd_dump_on_timeout) libcfs_debug_dumplog(); @@ -214,7 +214,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp) atomic_inc(&imp->imp_inval_count); - /* + /* * If this is an invalid MGC connection, then don't bother * waiting for imp_inflight to drop to 0. */ @@ -254,7 +254,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp) out: obd_import_event(imp->imp_obd, imp, IMP_EVENT_INVALIDATE); - + atomic_dec(&imp->imp_inval_count); cfs_waitq_signal(&imp->imp_recovery_waitq); } @@ -301,8 +301,7 @@ void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt) int ptlrpc_reconnect_import(struct obd_import *imp) { - - ptlrpc_set_import_discon(imp, 0); + ptlrpc_set_import_discon(imp, 0); /* Force a new connect attempt */ ptlrpc_invalidate_import(imp); /* Do a fresh connect next time by zeroing the handle */ @@ -315,16 +314,16 @@ int ptlrpc_reconnect_import(struct obd_import *imp) (atomic_read(&imp->imp_inval_count) == 0), &lwi); if (rc) - CERROR("Interrupted, inval=%d\n", + CERROR("Interrupted, inval=%d\n", atomic_read(&imp->imp_inval_count)); } - /* + /* * Allow reconnect attempts. Note: Currently, the function is * only called by MGC. So assume this is a recoverable import, - * and force import to be recoverable. fix this if you need to + * and force import to be recoverable. fix this if you need to */ - + imp->imp_obd->obd_no_recov = 0; /* Remove 'invalid' flag */ ptlrpc_activate_import(imp); @@ -356,10 +355,10 @@ static int import_select_connection(struct obd_import *imp) imp->imp_obd->obd_name, libcfs_nid2str(conn->oic_conn->c_peer.nid), conn->oic_last_attempt); - + /* Don't thrash connections */ if (cfs_time_before_64(cfs_time_current_64(), - conn->oic_last_attempt + + conn->oic_last_attempt + cfs_time_seconds(CONNECTION_SWITCH_MIN))) { continue; } @@ -530,7 +529,7 @@ int ptlrpc_connect_import(struct obd_import *imp, char *new_uuid) imp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT; rc = obd_reconnect(imp->imp_obd->obd_self_export, obd, - &obd->obd_uuid, &imp->imp_connect_data); + &obd->obd_uuid, &imp->imp_connect_data, NULL); if (rc) GOTO(out, rc); @@ -570,7 +569,7 @@ int ptlrpc_connect_import(struct obd_import *imp, char *new_uuid) } DEBUG_REQ(D_RPCTRACE, request, "%sconnect request %d", - aa->pcaa_initial_connect ? "initial " : "re", + aa->pcaa_initial_connect ? "initial " : "re", imp->imp_conn_cnt); ptlrpcd_add_req(request); rc = 0; @@ -602,10 +601,10 @@ static void ptlrpc_maybe_ping_import_soon(struct obd_import *imp) oic_item); /* XXX: When the failover node is the primary node, it is possible - * to have two identical connections in imp_conn_list. We must + * to have two identical connections in imp_conn_list. We must * compare not conn's pointers but NIDs, otherwise we can defeat * connection throttling. (See bug 14774.) */ - if (imp->imp_conn_current->oic_conn->c_self != + if (imp->imp_conn_current->oic_conn->c_self != imp_conn->oic_conn->c_self) { ptlrpc_ping_import_soon(imp); wake_pinger = 1; @@ -614,7 +613,7 @@ static void ptlrpc_maybe_ping_import_soon(struct obd_import *imp) #else /* liblustre has no pinger thead, so we wakup pinger anyway */ wake_pinger = 1; -#endif +#endif unlock: spin_unlock(&imp->imp_lock); @@ -814,9 +813,9 @@ finish: imp->imp_connect_flags_orig, ocd->ocd_connect_flags); if (!exp) { - /* This could happen if export is cleaned during the + /* This could happen if export is cleaned during the connect attempt */ - CERROR("Missing export for %s\n", + CERROR("Missing export for %s\n", imp->imp_obd->obd_name); GOTO(out, rc = -ENODEV); } @@ -891,24 +890,24 @@ finish: } if (ocd->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) { - cli->cl_max_pages_per_rpc = + cli->cl_max_pages_per_rpc = ocd->ocd_brw_size >> CFS_PAGE_SHIFT; } - imp->imp_obd->obd_namespace->ns_connect_flags = + imp->imp_obd->obd_namespace->ns_connect_flags = ocd->ocd_connect_flags; - imp->imp_obd->obd_namespace->ns_orig_connect_flags = + imp->imp_obd->obd_namespace->ns_orig_connect_flags = ocd->ocd_connect_flags; if ((ocd->ocd_connect_flags & OBD_CONNECT_AT) && (imp->imp_msg_magic == LUSTRE_MSG_MAGIC_V2)) - /* We need a per-message support flag, because + /* We need a per-message support flag, because a. we don't know if the incoming connect reply supports AT or not (in reply_in_callback) until we unpack it. b. failovered server means export and flags are gone (in ptlrpc_send_reply). - Can only be set when we know AT is supported at + Can only be set when we know AT is supported at both ends */ imp->imp_msghdr_flags |= MSGHDR_AT_SUPPORT; else @@ -968,7 +967,7 @@ finish: obd2cli_tgt(imp->imp_obd), (char *)imp->imp_connection->c_remote_uuid.uuid, rc); } - + spin_lock(&imp->imp_lock); imp->imp_last_recon = 0; spin_unlock(&imp->imp_lock); @@ -1026,7 +1025,7 @@ static int ptlrpc_invalidate_import_thread(void *data) ENTRY; ptlrpc_daemonize("ll_imp_inval"); - + CDEBUG(D_HA, "thread invalidate import %s to %s@%s\n", imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd), imp->imp_connection->c_remote_uuid.uuid); @@ -1173,12 +1172,12 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) if (AT_OFF) { timeout = cfs_time_seconds(obd_timeout); } else { - int idx = import_at_get_index(imp, + int idx = import_at_get_index(imp, imp->imp_client->cli_request_portal); timeout = cfs_time_seconds( at_get(&imp->imp_at.iat_service_estimate[idx])); } - lwi = LWI_TIMEOUT_INTR(cfs_timeout_cap(timeout), + lwi = LWI_TIMEOUT_INTR(cfs_timeout_cap(timeout), back_to_sleep, LWI_ON_SIGNAL_NOOP, NULL); rc = l_wait_event(imp->imp_recovery_waitq, !ptlrpc_import_in_recovery(imp), &lwi); @@ -1196,14 +1195,14 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) * it fails. We can get through the above with a down server * if the client doesn't know the server is gone yet. */ req->rq_no_resend = 1; - + #ifndef CRAY_XT3 - /* We want client umounts to happen quickly, no matter the + /* We want client umounts to happen quickly, no matter the server state... */ req->rq_timeout = min_t(int, req->rq_timeout, INITIAL_CONNECT_TIMEOUT); #else - /* ... but we always want liblustre clients to nicely + /* ... but we always want liblustre clients to nicely disconnect, so only use the adaptive value. */ if (AT_OFF) req->rq_timeout = obd_timeout / 3; @@ -1219,12 +1218,12 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) set_state: spin_lock(&imp->imp_lock); out: - if (noclose) + if (noclose) IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_DISCON); else IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CLOSED); memset(&imp->imp_remote_handle, 0, sizeof(imp->imp_remote_handle)); - /* Try all connections in the future - bz 12758 */ + /* Try all connections in the future - bz 12758 */ imp->imp_last_recon = 0; spin_unlock(&imp->imp_lock); @@ -1247,7 +1246,7 @@ extern unsigned int at_min, at_max, at_history; This gives us a max of the last binlimit*AT_BINS secs without the storage, but still smoothing out a return to normalcy from a slow response. (E.g. remember the maximum latency in each minute of the last 4 minutes.) */ -int at_add(struct adaptive_timeout *at, unsigned int val) +int at_add(struct adaptive_timeout *at, unsigned int val) { unsigned int old = at->at_current; time_t now = cfs_time_current_sec(); @@ -1255,12 +1254,12 @@ int at_add(struct adaptive_timeout *at, unsigned int val) LASSERT(at); #if 0 - CDEBUG(D_INFO, "add %u to %p time=%lu v=%u (%u %u %u %u)\n", + CDEBUG(D_INFO, "add %u to %p time=%lu v=%u (%u %u %u %u)\n", val, at, now - at->at_binstart, at->at_current, at->at_hist[0], at->at_hist[1], at->at_hist[2], at->at_hist[3]); #endif - if (val == 0) - /* 0's don't count, because we never want our timeout to + if (val == 0) + /* 0's don't count, because we never want our timeout to drop to 0, and because 0 could mean an error */ return 0; @@ -1318,22 +1317,22 @@ int at_add(struct adaptive_timeout *at, unsigned int val) at->at_hist[0], at->at_hist[1], at->at_hist[2], at->at_hist[3]); #endif - + /* if we changed, report the old value */ old = (at->at_current != old) ? old : 0; - + spin_unlock(&at->at_lock); return old; } /* Find the imp_at index for a given portal; assign if space available */ -int import_at_get_index(struct obd_import *imp, int portal) +int import_at_get_index(struct obd_import *imp, int portal) { struct imp_at *at = &imp->imp_at; int i; for (i = 0; i < IMP_AT_MAX_PORTALS; i++) { - if (at->iat_portal[i] == portal) + if (at->iat_portal[i] == portal) return i; if (at->iat_portal[i] == 0) /* unused */ @@ -1345,13 +1344,13 @@ int import_at_get_index(struct obd_import *imp, int portal) /* Check unused under lock */ for (; i < IMP_AT_MAX_PORTALS; i++) { - if (at->iat_portal[i] == portal) + if (at->iat_portal[i] == portal) goto out; if (at->iat_portal[i] == 0) /* unused */ break; } - + /* Not enough portals? */ LASSERT(i < IMP_AT_MAX_PORTALS); -- 1.8.3.1