* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2015, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
RETURN(PTR_ERR(th));
tti_buf_lcd(tti);
- mutex_lock(&ted->ted_lcd_lock);
rc = dt_declare_record_write(env, tgt->lut_last_rcvd,
&tti->tti_buf,
ted->ted_lr_off, th);
rc = dt_trans_start_local(env, tgt->lut_bottom, th);
if (rc)
GOTO(out, rc);
+
+ mutex_lock(&ted->ted_lcd_lock);
+
/*
* Until this operations will be committed the sync is needed
* for this export. This should be done _after_ starting the
tti->tti_off = ted->ted_lr_off;
rc = tgt_client_data_write(env, tgt, ted->ted_lcd, &tti->tti_off, th);
+
+ mutex_unlock(&ted->ted_lcd_lock);
+
EXIT;
out:
- mutex_unlock(&ted->ted_lcd_lock);
dt_trans_stop(env, tgt->lut_bottom, th);
CDEBUG(D_INFO, "%s: update last_rcvd client data for UUID = %s, "
"last_transno = %llu: rc = %d\n", tgt->lut_obd->obd_name,
} else {
spin_unlock(&ccb->llcc_tgt->lut_translock);
}
+
+ CDEBUG(D_HA, "%s: transno %lld is committed\n",
+ ccb->llcc_tgt->lut_obd->obd_name, ccb->llcc_transno);
+
out:
class_export_cb_put(ccb->llcc_exp);
- if (ccb->llcc_transno)
- CDEBUG(D_HA, "%s: transno %lld is committed\n",
- ccb->llcc_tgt->lut_obd->obd_name, ccb->llcc_transno);
OBD_FREE_PTR(ccb);
}
+/**
+ * Add commit callback function, it returns a non-zero value to inform
+ * caller to use sync transaction if necessary.
+ */
int tgt_last_commit_cb_add(struct thandle *th, struct lu_target *tgt,
struct obd_export *exp, __u64 transno)
{
/* report failure to force synchronous operation */
return -EPERM;
- return rc;
+ /* if exp_need_sync is set, return non-zero value to force
+ * a sync transaction. */
+ return rc ? rc : exp->exp_need_sync;
}
struct tgt_new_client_callback {
if (exp->exp_flags & OBD_OPT_FAILOVER)
RETURN(0);
+ if (OBD_FAIL_CHECK(OBD_FAIL_TGT_CLIENT_DEL))
+ RETURN(0);
+
/* Make sure the server's last_transno is up to date.
* This should be done before zeroing client slot so last_transno will
* be in server data or in client data in case of failure */
if (!lw_client) {
tti->tti_off = ted->ted_lr_off;
- rc = tgt_client_data_write(env, tgt, ted->ted_lcd, &tti->tti_off, th);
+ if (CFS_FAIL_CHECK(OBD_FAIL_TGT_RCVD_EIO))
+ rc = -EIO;
+ else
+ rc = tgt_client_data_write(env, tgt, ted->ted_lcd,
+ &tti->tti_off, th);
if (rc < 0) {
mutex_unlock(&ted->ted_lcd_lock);
RETURN(rc);
* because a replay slot has not been assigned. This should be
* replaced by dmu_tx_hold_append() when available.
*/
- tti->tti_off = atomic_read(&tgt->lut_num_clients) * 8 *
- sizeof(struct lsd_reply_data);
tti->tti_buf.lb_buf = NULL;
tti->tti_buf.lb_len = sizeof(struct lsd_reply_data);
dto = dt_object_locate(tgt->lut_reply_data, th->th_dev);
- rc = dt_declare_record_write(env, dto, &tti->tti_buf,
- tti->tti_off, th);
+ rc = dt_declare_record_write(env, dto, &tti->tti_buf, -1, th);
if (rc)
return rc;
} else {