void capa_dup(void *dst, struct obd_capa *ocapa);
void capa_dup2(void *dst, struct lustre_capa *capa);
int capa_expired(struct lustre_capa *capa);
-int __capa_is_to_expire(struct obd_capa *ocapa);
+int __capa_is_to_expire(struct obd_capa *ocapa, struct timeval *tv);
int capa_is_to_expire(struct obd_capa *ocapa);
#define CAPA_EXPIRY_SHIFT 10 /* 1024 sec */
struct lustre_capa *capa;
int expired = 0;
unsigned long expiry;
+ struct timeval tv;
+
ENTRY;
+ do_gettimeofday(&tv);
spin_lock(&capa_lock);
if (!list_empty(ll_capa_list)) {
ocapa = list_entry(ll_capa_list->next, struct obd_capa, c_list);
- expired = __capa_is_to_expire(ocapa);
+ expired = __capa_is_to_expire(ocapa, &tv);
if (!expired) {
capa = &ocapa->c_capa;
expiry = expiry_to_jiffies(capa->lc_expiry -
struct obd_capa *ocapa, tcapa, *tmp, *next = NULL;
unsigned long expiry, sleep = CAPA_PRE_EXPIRY;
struct inode *inode;
+ struct timeval tv;
l_wait_event(capa_thread.t_ctl_waitq,
(have_expired_capa() || ll_capa_check_stop()),
if (ll_capa_check_stop())
break;
+ do_gettimeofday(&tv);
spin_lock(&capa_lock);
list_for_each_entry_safe(ocapa, tmp, ll_capa_list, c_list) {
if (ocapa->c_capa.lc_flags & CAPA_FL_SHORT)
if (ocapa->c_capa.lc_op == CAPA_TRUNC)
continue;
- if (__capa_is_to_expire(ocapa)) {
+ if (__capa_is_to_expire(ocapa, &tv)) {
inode = igrab(ocapa->c_inode);
if (inode == NULL)
continue;
list_add(&ocapa->c_lli_list, &lli->lli_capas);
spin_unlock(&lli->lli_lock);
+ capa_put(ocapa);
+
expiry = expiry_to_jiffies(capa->lc_expiry - capa_pre_expiry(capa));
spin_lock(&capa_lock);
ocapa = capa_renew(capa, MDS_CAPA);
if (!ocapa)
rc = -ENOMEM;
+ capa_put(ocapa);
out:
if (rc == 0)
body->valid |= OBD_MD_CAPA;
hlist_add_head(&ocapa->c_hash, head);
if (type == CLIENT_CAPA)
INIT_LIST_HEAD(&ocapa->c_lli_list);
+ __capa_get(ocapa);
capa_count[type]++;
return ((unsigned long )capa->lc_expiry <= tv.tv_sec) ? 1 : 0;
}
-int __capa_is_to_expire(struct obd_capa *ocapa)
+int __capa_is_to_expire(struct obd_capa *ocapa, struct timeval *tv)
{
- struct timeval tv;
int pre_expiry = capa_pre_expiry(&ocapa->c_capa);
- do_gettimeofday(&tv);
- /* XXX: in case the lock is inaccurate, minus one more
+ /* XXX: in case the clock is inaccurate, minus one more
* pre_expiry to make sure the expiry won't miss */
return ((unsigned long)ocapa->c_capa.lc_expiry -
- 2 * pre_expiry <= tv.tv_sec)? 1 : 0;
+ 2 * pre_expiry <= tv->tv_sec)? 1 : 0;
}
int capa_is_to_expire(struct obd_capa *ocapa)
{
+ struct timeval tv;
int rc;
+ do_gettimeofday(&tv);
spin_lock(&capa_lock);
- rc = __capa_is_to_expire(ocapa);
+ rc = __capa_is_to_expire(ocapa, &tv);
spin_unlock(&capa_lock);
return rc;
capa->lc_ino, capa->lc_igen, FILTER_CAPA);
verify:
if (ocapa) {
+ struct timeval tv;
+
/* fo_capa_lock protects capa too */
+ do_gettimeofday(&tv);
spin_lock(&filter->fo_capa_lock);
if (capa->lc_keyid == ocapa->c_capa.lc_keyid) {
rc = memcmp(capa, &ocapa->c_capa, sizeof(*capa));
goto new_capa;
}
- if (rc && __capa_is_to_expire(ocapa)) {
+ if (rc && __capa_is_to_expire(ocapa, &tv)) {
/* client should use new expiry now */
ocapa->c_bvalid = 0;
goto new_capa;