From: shadow Date: Fri, 9 May 2008 12:22:47 +0000 (+0000) Subject: Obsolete CURRENT_SECONDS and use cfs_time_current_sec() instead. X-Git-Tag: v1_9_50~521 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=b61d3781d58689a994f4687d9396db17386926bd Obsolete CURRENT_SECONDS and use cfs_time_current_sec() instead. b=14929 i=zam --- diff --git a/lustre/ChangeLog b/lustre/ChangeLog index c16f5ac..600acb0 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -13,6 +13,10 @@ tbd Sun Microsystems, Inc. removed cwd "./" (refer to Bugzilla 14399). Severity : minor +Bugzilla : 14929 +Description: Obsolete CURRENT_SECONDS and use cfs_time_current_sec() instead. + +Severity : minor Bugzilla : 14645 Frequency : rare, on shutdown ost Description: don't hit live lock with umount ost. diff --git a/lustre/include/darwin/lustre_compat.h b/lustre/include/darwin/lustre_compat.h index d11c8d6..ec7e6c3 100644 --- a/lustre/include/darwin/lustre_compat.h +++ b/lustre/include/darwin/lustre_compat.h @@ -15,7 +15,6 @@ /* XXX */ #define LOOKUP_COBD 4096 -#define CURRENT_SECONDS cfs_unix_seconds() #endif diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h index c562e75..b64ae31 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -83,9 +83,6 @@ typedef unsigned short umode_t; #endif -#ifndef CURRENT_SECONDS -# define CURRENT_SECONDS time(0) -#endif #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) ((sizeof (a))/(sizeof ((a)[0]))) diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 1dcc960..ba1b24f 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -763,7 +763,7 @@ int target_handle_connect(struct ptlrpc_request *req) if (req->rq_export == NULL && initial_conn) export->exp_last_request_time = max(export->exp_last_request_time, - (time_t)CURRENT_SECONDS); + (time_t)cfs_time_current_sec()); } /* We want to handle EALREADY but *not* -EALREADY from @@ -779,7 +779,7 @@ int target_handle_connect(struct ptlrpc_request *req) CWARN("%s: connection from %s@%s %st"LPU64" exp %p cur %ld last %ld\n", target->obd_name, cluuid.uuid, libcfs_nid2str(req->rq_peer.nid), target->obd_recovering ? "recovering/" : "", data->ocd_transno, - export, (long)CURRENT_SECONDS, + export, (long)cfs_time_current_sec(), export ? (long)export->exp_last_request_time : 0); @@ -1102,7 +1102,7 @@ static void target_finish_recovery(struct obd_device *obd) rc < 0 ? "failed" : "complete", rc); } - obd->obd_recovery_end = CURRENT_SECONDS; + obd->obd_recovery_end = cfs_time_current_sec(); EXIT; } @@ -1215,7 +1215,7 @@ static void reset_recovery_timer(struct obd_device *obd) CDEBUG(D_HA, "%s: timer will expire in %u seconds\n", obd->obd_name, (unsigned int)timeout_shift); /* Only used for lprocfs_status */ - obd->obd_recovery_end = CURRENT_SECONDS + timeout_shift; + obd->obd_recovery_end = cfs_time_current_sec() + timeout_shift; } @@ -1645,7 +1645,7 @@ void target_recovery_init(struct obd_device *obd, svc_handler_t handler) obd->obd_max_recoverable_clients, obd->obd_last_committed); obd->obd_next_recovery_transno = obd->obd_last_committed + 1; target_start_recovery_thread(obd, handler); - obd->obd_recovery_start = CURRENT_SECONDS; + obd->obd_recovery_start = cfs_time_current_sec(); /* Only used for lprocfs_status */ obd->obd_recovery_end = obd->obd_recovery_start + OBD_RECOVERY_TIMEOUT; /* bz13079: this should be set to desired value for ost but not for mds */ diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 6c305f4..5d0c289 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -64,7 +64,7 @@ int ldlm_expired_completion_wait(void *data) LDLM_ERROR(lock, "lock timed out (enqueued at %lu, %lus ago); " "not entering recovery in server code, just going " "back to sleep", lock->l_enqueued_time.tv_sec, - CURRENT_SECONDS - lock->l_enqueued_time.tv_sec); + cfs_time_current_sec() - lock->l_enqueued_time.tv_sec); if (cfs_time_after(cfs_time_current(), next_dump)) { last_dump = next_dump; next_dump = cfs_time_shift(300); @@ -81,7 +81,7 @@ int ldlm_expired_completion_wait(void *data) ptlrpc_fail_import(imp, lwd->lwd_conn_cnt); LDLM_ERROR(lock, "lock timed out (enqueued at %lu, %lus ago), entering " "recovery for %s@%s", lock->l_enqueued_time.tv_sec, - CURRENT_SECONDS - lock->l_enqueued_time.tv_sec, + cfs_time_current_sec() - lock->l_enqueued_time.tv_sec, obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid); RETURN(0); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 7b63ce3..7c6fd9d 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1403,7 +1403,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME)) CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n", LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime), - CURRENT_SECONDS); + cfs_time_current_sec()); /* NB: ATTR_SIZE will only be set after this point if the size * resides on the MDS, ie, this file has no objects. */ @@ -2242,7 +2242,7 @@ struct md_op_data * ll_prep_md_op_data(struct md_op_data *op_data, op_data->op_name = name; op_data->op_namelen = namelen; op_data->op_mode = mode; - op_data->op_mod_time = CURRENT_SECONDS; + op_data->op_mod_time = cfs_time_current_sec(); op_data->op_fsuid = current->fsuid; op_data->op_fsgid = current->fsgid; op_data->op_cap = current->cap_effective; diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c index ba6f612..e65ce42 100644 --- a/lustre/lvfs/fsfilt_ext3.c +++ b/lustre/lvfs/fsfilt_ext3.c @@ -1772,7 +1772,7 @@ static int commit_chkquot(struct super_block *sb, struct qchk_ctxt *qctxt, if (!oqc) RETURN(-ENOMEM); - now = CURRENT_SECONDS; + now = cfs_time_current_sec(); if (cdqb->dqb_bsoftlimit && toqb(cdqb->dqb_curspace) >= cdqb->dqb_bsoftlimit && diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 2cc5974..38a1ceb 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -902,7 +902,7 @@ static int mdd_xattr_set(const struct lu_env *env, struct md_object *obj, rc = mdd_xattr_set_txn(env, md2mdd_obj(obj), buf, name, fl, handle); if (rc == 0) { - la_copy->la_ctime = CURRENT_SECONDS; + la_copy->la_ctime = cfs_time_current_sec(); la_copy->la_valid = LA_CTIME; rc = mdd_attr_set_internal_locked(env, mdd_obj, la_copy, handle, 0); @@ -936,7 +936,7 @@ int mdd_xattr_del(const struct lu_env *env, struct md_object *obj, mdd_object_capa(env, mdd_obj)); mdd_write_unlock(env, mdd_obj); if (rc == 0) { - la_copy->la_ctime = CURRENT_SECONDS; + la_copy->la_ctime = cfs_time_current_sec(); la_copy->la_valid = LA_CTIME; rc = mdd_attr_set_internal_locked(env, mdd_obj, la_copy, handle, 0); diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index 54c577e..5ecaf5a 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -446,7 +446,7 @@ static int mds_init_server_data(struct obd_device *obd, struct file *file) obd->obd_max_recoverable_clients, mds->mds_last_transno); obd->obd_next_recovery_transno = obd->obd_last_committed + 1; obd->obd_recovering = 1; - obd->obd_recovery_start = CURRENT_SECONDS; + obd->obd_recovery_start = cfs_time_current_sec(); /* Only used for lprocfs_status */ obd->obd_recovery_end = obd->obd_recovery_start + OBD_RECOVERY_TIMEOUT; diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index 9ff31cb..bf8b8e5 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -241,7 +241,7 @@ commit: */ int mds_fix_attr(struct inode *inode, struct mds_update_record *rec) { - time_t now = CURRENT_SECONDS; + time_t now = cfs_time_current_sec(); struct iattr *attr = &rec->ur_iattr; unsigned int ia_valid = attr->ia_valid; int error; @@ -1330,7 +1330,7 @@ cleanup: #define INODE_CTIME_AGE (10) #define INODE_CTIME_OLD(inode) (LTIME_S(inode->i_ctime) + \ - INODE_CTIME_AGE < CURRENT_SECONDS) + INODE_CTIME_AGE < cfs_time_current_sec()) int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds, struct ll_fid *fid, diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 4e49f34..93a11de 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -708,7 +708,7 @@ struct obd_export *class_new_export(struct obd_device *obd, CFS_INIT_LIST_HEAD(&export->exp_handle.h_link); class_handle_hash(&export->exp_handle, export_handle_addref); - export->exp_last_request_time = CURRENT_SECONDS; + export->exp_last_request_time = cfs_time_current_sec(); spin_lock_init(&export->exp_lock); INIT_HLIST_NODE(&export->exp_uuid_hash); INIT_HLIST_NODE(&export->exp_nid_hash); diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index 4718009..0cc9e0e 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -161,7 +161,7 @@ int llog_init_handle(struct llog_handle *handle, int flags, llh->llh_hdr.lrh_type = LLOG_HDR_MAGIC; llh->llh_hdr.lrh_len = llh->llh_tail.lrt_len = LLOG_CHUNK_SIZE; llh->llh_hdr.lrh_index = llh->llh_tail.lrt_index = 0; - llh->llh_timestamp = CURRENT_SECONDS; + llh->llh_timestamp = cfs_time_current_sec(); if (uuid) memcpy(&llh->llh_tgtuuid, uuid, sizeof(llh->llh_tgtuuid)); llh->llh_bitmap_offset = offsetof(typeof(*llh),llh_bitmap); diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index a8b4a18..9afb4dd 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -1681,8 +1681,8 @@ int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off, goto out; if (lprocfs_obd_snprintf(&page, size, &len, "time remaining: %lu\n", - CURRENT_SECONDS >= obd->obd_recovery_end ? 0 : - obd->obd_recovery_end - CURRENT_SECONDS) <= 0) + cfs_time_current_sec() >= obd->obd_recovery_end ? 0 : + obd->obd_recovery_end - cfs_time_current_sec()) <= 0) goto out; if(lprocfs_obd_snprintf(&page, size, &len, "connected_clients: %d/%d\n", diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 2bad71a..3a8b7ab 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -1488,7 +1488,7 @@ int osc_brw_redo_request(struct ptlrpc_request *request, aa->aa_resends++; new_req->rq_interpret_reply = request->rq_interpret_reply; new_req->rq_async_args = request->rq_async_args; - new_req->rq_sent = CURRENT_SECONDS + aa->aa_resends; + new_req->rq_sent = cfs_time_current_sec() + aa->aa_resends; new_aa = (struct osc_brw_async_args *)&new_req->rq_async_args; diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index 68f2e3e..25df3a4 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -1487,7 +1487,7 @@ static struct obd_capa *osd_capa_get(const struct lu_env *env, spin_unlock(&capa_lock); capa->lc_keyid = key->lk_keyid; - capa->lc_expiry = CURRENT_SECONDS + dev->od_capa_timeout; + capa->lc_expiry = cfs_time_current_sec() + dev->od_capa_timeout; rc = capa_hmac(capa->lc_hmac, capa, key->lk_key); if (rc) { diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index f4b6a80..5124f28 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -873,7 +873,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) ENTRY; LASSERT(req->rq_phase == RQ_PHASE_NEW); - if (req->rq_sent && (req->rq_sent > CURRENT_SECONDS)) + if (req->rq_sent && (req->rq_sent > cfs_time_current_sec())) RETURN (0); req->rq_phase = RQ_PHASE_RPC; @@ -921,7 +921,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) RETURN(1); } else { /* here begins timeout counting */ - req->rq_sent = CURRENT_SECONDS; + req->rq_sent = cfs_time_current_sec(); req->rq_wait_ctx = 1; RETURN(0); } @@ -1081,7 +1081,7 @@ check_ctx: } if (!req->rq_wait_ctx) { /* begins timeout counting */ - req->rq_sent = CURRENT_SECONDS; + req->rq_sent = cfs_time_current_sec(); req->rq_wait_ctx = 1; } continue; @@ -1193,7 +1193,7 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req) DEBUG_REQ(D_ERROR|D_NETERROR, req, "%s (sent at %lu, %lus ago)", req->rq_net_err ? "network error" : "timeout", - (long)req->rq_sent, CURRENT_SECONDS - req->rq_sent); + (long)req->rq_sent, cfs_time_current_sec() - req->rq_sent); if (imp != NULL && obd_debug_peer_on_timeout) LNetCtl(IOC_LIBCFS_DEBUG_PEER, &imp->imp_connection->c_peer); @@ -1247,7 +1247,7 @@ int ptlrpc_expired_set(void *data) { struct ptlrpc_request_set *set = data; struct list_head *tmp; - time_t now = CURRENT_SECONDS; + time_t now = cfs_time_current_sec(); ENTRY; LASSERT(set != NULL); @@ -1307,7 +1307,7 @@ void ptlrpc_interrupted_set(void *data) int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) { struct list_head *tmp; - time_t now = CURRENT_SECONDS; + time_t now = cfs_time_current_sec(); time_t deadline; int timeout = 0; struct ptlrpc_request *req; diff --git a/lustre/ptlrpc/niobuf.c b/lustre/ptlrpc/niobuf.c index d4c8fe0..cb92a0a 100644 --- a/lustre/ptlrpc/niobuf.c +++ b/lustre/ptlrpc/niobuf.c @@ -513,7 +513,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) OBD_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_SEND, request->rq_timeout + 5); - request->rq_sent = CURRENT_SECONDS; + request->rq_sent = cfs_time_current_sec(); do_gettimeofday(&request->rq_arrival_time); ptlrpc_pinger_sending_on_import(request->rq_import); rc = ptl_send_buf(&request->rq_req_md_h, diff --git a/lustre/ptlrpc/pinger.c b/lustre/ptlrpc/pinger.c index ab5647f..819cad6 100644 --- a/lustre/ptlrpc/pinger.c +++ b/lustre/ptlrpc/pinger.c @@ -433,7 +433,7 @@ static int ping_evictor_main(void *arg) obd = pet_exp->exp_obd; spin_unlock(&pet_lock); - expire_time = CURRENT_SECONDS - (3 * obd_timeout / 2); + expire_time = cfs_time_current_sec() - (3 * obd_timeout / 2); CDEBUG(D_HA, "evicting all exports of obd %s older than %ld\n", obd->obd_name, expire_time); @@ -457,9 +457,9 @@ static int ping_evictor_main(void *arg) obd->obd_name, obd_uuid2str(&exp->exp_client_uuid), obd_export_nid2str(exp), - (long)(CURRENT_SECONDS - + (long)(cfs_time_current_sec() - exp->exp_last_request_time), - exp, (long)CURRENT_SECONDS, + exp, (long)cfs_time_current_sec(), (long)expire_time, (long)exp->exp_last_request_time); CDEBUG(D_HA, "Last request was at %ld\n", diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index 5949cc4..cca0fd0 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -465,7 +465,7 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) at the exact right moment. Eventually, all silent exports will make it to the top of the list. */ exp->exp_last_request_time = max(exp->exp_last_request_time, - (time_t)CURRENT_SECONDS + extra_delay); + cfs_time_current_sec() + extra_delay); CDEBUG(D_HA, "updating export %s at %ld exp %p\n", exp->exp_client_uuid.uuid, @@ -500,20 +500,20 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) /* Note - racing to start/reset the obd_eviction timer is safe */ if (exp->exp_obd->obd_eviction_timer == 0) { /* Check if the oldest entry is expired. */ - if (CURRENT_SECONDS > (oldest_time + + if (cfs_time_current_sec() > (oldest_time + (3 * obd_timeout / 2) + extra_delay)) { /* We need a second timer, in case the net was down and * it just came back. Since the pinger may skip every * other PING_INTERVAL (see note in ptlrpc_pinger_main), * we better wait for 3. */ - exp->exp_obd->obd_eviction_timer = CURRENT_SECONDS + + exp->exp_obd->obd_eviction_timer = cfs_time_current_sec() + 3 * PING_INTERVAL; CDEBUG(D_HA, "%s: Think about evicting %s from %ld\n", exp->exp_obd->obd_name, obd_export_nid2str(exp), oldest_time); } } else { - if (CURRENT_SECONDS > (exp->exp_obd->obd_eviction_timer + + if (cfs_time_current_sec() > (exp->exp_obd->obd_eviction_timer + extra_delay)) { /* The evictor won't evict anyone who we've heard from * recently, so we don't have to check before we start