-static inline int mdt_trans_credit_get(const struct lu_env *env,
- struct mdt_device *mdt,
- enum mdt_txn_op op)
-{
- struct dt_device *dev = mdt->mdt_bottom;
- int cr;
- switch (op) {
- case MDT_TXN_CAPA_KEYS_WRITE_OP:
- case MDT_TXN_LAST_RCVD_WRITE_OP:
- cr = dev->dd_ops->dt_credit_get(env,
- dev,
- DTO_WRITE_BLOCK);
- break;
- default:
- LBUG();
- }
- return cr;
-}
-
-void mdt_trans_credit_init(const struct lu_env *env,
- struct mdt_device *mdt,
- enum mdt_txn_op op)
-{
- struct mdt_thread_info *mti;
- struct txn_param *p;
- int cr;
-
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- p = &mti->mti_txn_param;
-
- cr = mdt_trans_credit_get(env, mdt, op);
- txn_param_init(p, cr);
-}
-
-struct thandle* mdt_trans_start(const struct lu_env *env,
- struct mdt_device *mdt)
-{
- struct mdt_thread_info *mti;
- struct txn_param *p;
-
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- p = &mti->mti_txn_param;
-
- /* export can require sync operations */
- if (mti->mti_exp != NULL)
- p->tp_sync = mti->mti_exp->exp_need_sync;
-
- return mdt->mdt_bottom->dd_ops->dt_trans_start(env, mdt->mdt_bottom, p);
-}
-
-void mdt_trans_stop(const struct lu_env *env,
- struct mdt_device *mdt, struct thandle *th)
-{
- mdt->mdt_bottom->dd_ops->dt_trans_stop(env, th);
-}
-
-static inline int mdt_last_rcvd_header_read(const struct lu_env *env,
- struct mdt_device *mdt)
-{
- struct mdt_thread_info *mti;
- int rc;
-
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
-
- mti->mti_off = 0;
- rc = dt_record_read(env, mdt->mdt_last_rcvd,
- mdt_buf(env, &mti->mti_lsd, sizeof(mti->mti_lsd)),
- &mti->mti_off);
- if (rc == 0)
- lsd_le_to_cpu(&mti->mti_lsd, &mdt->mdt_lsd);
-
- CDEBUG(D_INFO, "read last_rcvd header rc = %d, uuid = %s, "
- "last_transno = "LPU64"\n", rc, mdt->mdt_lsd.lsd_uuid,
- mdt->mdt_lsd.lsd_last_transno);
- return rc;
-}
-
-static int mdt_last_rcvd_header_write(const struct lu_env *env,
- struct mdt_device *mdt,
- struct thandle *th)
-{
- struct mdt_thread_info *mti;
- int rc;
- ENTRY;
-
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
-
- mti->mti_off = 0;
- lsd_cpu_to_le(&mdt->mdt_lsd, &mti->mti_lsd);
-
- rc = dt_record_write(env, mdt->mdt_last_rcvd,
- mdt_buf_const(env, &mti->mti_lsd,
- sizeof(mti->mti_lsd)),
- &mti->mti_off, th);
-
- CDEBUG(D_INFO, "write last_rcvd header rc = %d, uuid = %s, "
- "last_transno = "LPU64"\n", rc, mdt->mdt_lsd.lsd_uuid,
- mdt->mdt_lsd.lsd_last_transno);
-
- RETURN(rc);
-}
-
-static int mdt_last_rcvd_read(const struct lu_env *env,
- struct mdt_device *mdt,
- struct lsd_client_data *lcd, loff_t *off)
-{
- struct mdt_thread_info *mti;
- struct lsd_client_data *tmp;
- int rc;
-
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- tmp = &mti->mti_lcd;
- rc = dt_record_read(env, mdt->mdt_last_rcvd,
- mdt_buf(env, tmp, sizeof(*tmp)), off);
- if (rc == 0)
- lcd_le_to_cpu(tmp, lcd);
-
- CDEBUG(D_INFO, "read lcd @%d rc = %d, uuid = %s, last_transno = "LPU64
- ", last_xid = "LPU64", last_result = %u, last_data = %u, "
- "last_close_transno = "LPU64", last_close_xid = "LPU64", "
- "last_close_result = %u\n", (int)(*off - sizeof(*tmp)),
- rc, lcd->lcd_uuid, lcd->lcd_last_transno, lcd->lcd_last_xid,
- lcd->lcd_last_result, lcd->lcd_last_data,
- lcd->lcd_last_close_transno, lcd->lcd_last_close_xid,
- lcd->lcd_last_close_result);
- return rc;
-}
-
-static int mdt_last_rcvd_write(const struct lu_env *env,
- struct mdt_device *mdt,
- struct lsd_client_data *lcd,
- loff_t *off, struct thandle *th)
-{
- struct mdt_thread_info *mti;
- struct lsd_client_data *tmp;
- int rc;
-
- LASSERT(th != NULL);
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- tmp = &mti->mti_lcd;
-
- lcd_cpu_to_le(lcd, tmp);
-
- rc = dt_record_write(env, mdt->mdt_last_rcvd,
- mdt_buf_const(env, tmp, sizeof(*tmp)), off, th);
-
- CDEBUG(D_INFO, "write lcd @%d rc = %d, uuid = %s, last_transno = "LPU64
- ", last_xid = "LPU64", last_result = %u, last_data = %u, "
- "last_close_transno = "LPU64", last_close_xid = "LPU64" ,"
- "last_close_result = %u\n", (int)(*off - sizeof(*tmp)),
- rc, lcd->lcd_uuid, lcd->lcd_last_transno, lcd->lcd_last_xid,
- lcd->lcd_last_result, lcd->lcd_last_data,
- lcd->lcd_last_close_transno, lcd->lcd_last_close_xid,
- lcd->lcd_last_close_result);
- return rc;
-}
-
-static int mdt_clients_data_init(const struct lu_env *env,
- struct mdt_device *mdt,
- unsigned long last_size)
-{
- struct lr_server_data *lsd = &mdt->mdt_lsd;
- struct lsd_client_data *lcd = NULL;
- struct obd_device *obd = mdt2obd_dev(mdt);
- loff_t off;
- int cl_idx;
- int rc = 0;
- ENTRY;
-
- /* When we do a clean MDS shutdown, we save the last_transno into
- * the header. If we find clients with higher last_transno values
- * then those clients may need recovery done. */
- LASSERT(atomic_read(&obd->obd_req_replay_clients) == 0);
- for (cl_idx = 0, off = lsd->lsd_client_start;
- off < last_size; cl_idx++) {
- __u64 last_transno;
- struct obd_export *exp;
-
- if (!lcd) {
- OBD_ALLOC_PTR(lcd);
- if (!lcd)
- RETURN(-ENOMEM);
- }
-
- off = lsd->lsd_client_start +
- cl_idx * lsd->lsd_client_size;
-
- rc = mdt_last_rcvd_read(env, mdt, lcd, &off);
- if (rc) {
- CERROR("error reading MDS %s idx %d, off %llu: rc %d\n",
- LAST_RCVD, cl_idx, off, rc);
- rc = 0;
- break; /* read error shouldn't cause startup to fail */
- }
-
- if (lcd->lcd_uuid[0] == '\0') {
- CDEBUG(D_INFO, "skipping zeroed client at offset %d\n",
- cl_idx);
- continue;
- }
-
- last_transno = lcd_last_transno(lcd);
-
- /* These exports are cleaned up by mdt_obd_disconnect(), so
- * they need to be set up like real exports as
- * mdt_obd_connect() does.
- */
- CDEBUG(D_HA, "RCVRNG CLIENT uuid: %s idx: %d lr: "LPU64
- " srv lr: "LPU64" lx: "LPU64"\n", lcd->lcd_uuid, cl_idx,
- last_transno, lsd->lsd_last_transno,
- lcd_last_xid(lcd));
-
- exp = class_new_export(obd, (struct obd_uuid *)lcd->lcd_uuid);
- if (IS_ERR(exp)) {
- if (PTR_ERR(exp) == -EALREADY) {
- /* export already exists, zero out this one */
- lcd->lcd_uuid[0] = '\0';
- } else {
- GOTO(err_client, rc = PTR_ERR(exp));
- }
- } else {
- struct mdt_thread_info *mti;
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- LASSERT(mti != NULL);
- mti->mti_exp = exp;
- exp->exp_mdt_data.med_lcd = lcd;
- rc = mdt_client_add(env, mdt, cl_idx);
- /* can't fail existing */
- LASSERTF(rc == 0, "rc = %d\n", rc);
- /* VBR: set export last committed version */
- exp->exp_last_committed = last_transno;
- lcd = NULL;
- spin_lock(&exp->exp_lock);
- exp->exp_connecting = 0;
- exp->exp_in_recovery = 0;
- spin_unlock(&exp->exp_lock);
- obd->obd_max_recoverable_clients++;
- class_export_put(exp);
- }
-
- CDEBUG(D_OTHER, "client at idx %d has last_transno="LPU64"\n",
- cl_idx, last_transno);
- /* protect __u64 value update */
- spin_lock(&mdt->mdt_transno_lock);
- mdt->mdt_last_transno = max(last_transno,
- mdt->mdt_last_transno);
- spin_unlock(&mdt->mdt_transno_lock);
- }
-
-err_client:
- if (lcd)
- OBD_FREE_PTR(lcd);
- RETURN(rc);
-}
-
-static int mdt_server_data_init(const struct lu_env *env,
- struct mdt_device *mdt,
- struct lustre_sb_info *lsi)
-{
- struct lr_server_data *lsd = &mdt->mdt_lsd;
- struct lsd_client_data *lcd = NULL;
- struct obd_device *obd = mdt2obd_dev(mdt);
- struct mdt_thread_info *mti;
- struct dt_object *obj;
- struct lu_attr *la;
- struct lustre_disk_data *ldd;
- unsigned long last_rcvd_size;
- __u64 mount_count;
- int rc;
- ENTRY;
-
- /* ensure padding in the struct is the correct size */
- CLASSERT(offsetof(struct lr_server_data, lsd_padding) +
- sizeof(lsd->lsd_padding) == LR_SERVER_SIZE);
- CLASSERT(offsetof(struct lsd_client_data, lcd_padding) +
- sizeof(lcd->lcd_padding) == LR_CLIENT_SIZE);
-
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- LASSERT(mti != NULL);
- la = &mti->mti_attr.ma_attr;
-
- obj = mdt->mdt_last_rcvd;
- rc = obj->do_ops->do_attr_get(env, mdt->mdt_last_rcvd, la, BYPASS_CAPA);
- if (rc)
- RETURN(rc);
-
- last_rcvd_size = (unsigned long)la->la_size;
-
- if (last_rcvd_size == 0) {
- LCONSOLE_WARN("%s: new disk, initializing\n", obd->obd_name);
-
- memcpy(lsd->lsd_uuid, obd->obd_uuid.uuid,
- sizeof(lsd->lsd_uuid));
- lsd->lsd_last_transno = 0;
- lsd->lsd_mount_count = 0;
- lsd->lsd_server_size = LR_SERVER_SIZE;
- lsd->lsd_client_start = LR_CLIENT_START;
- lsd->lsd_client_size = LR_CLIENT_SIZE;
- lsd->lsd_feature_compat = OBD_COMPAT_MDT;
- lsd->lsd_feature_rocompat = OBD_ROCOMPAT_LOVOBJID;
- lsd->lsd_feature_incompat = OBD_INCOMPAT_MDT |
- OBD_INCOMPAT_COMMON_LR;
- } else {
- LCONSOLE_WARN("%s: used disk, loading\n", obd->obd_name);
- rc = mdt_last_rcvd_header_read(env, mdt);
- if (rc) {
- CERROR("error reading MDS %s: rc %d\n", LAST_RCVD, rc);
- GOTO(out, rc);
- }
- if (strcmp(lsd->lsd_uuid, obd->obd_uuid.uuid) != 0) {
- LCONSOLE_ERROR_MSG(0x157, "Trying to start OBD %s using"
- "the wrong disk %s. Were the /dev/ "
- "assignments rearranged?\n",
- obd->obd_uuid.uuid, lsd->lsd_uuid);
- GOTO(out, rc = -EINVAL);
- }
- lsd->lsd_feature_compat |= OBD_COMPAT_MDT;
- lsd->lsd_feature_incompat |= OBD_INCOMPAT_MDT |
- OBD_INCOMPAT_COMMON_LR;
- }
- mount_count = lsd->lsd_mount_count;
-
- ldd = lsi->lsi_ldd;
-
- if (lsd->lsd_feature_incompat & ~MDT_INCOMPAT_SUPP) {
- CERROR("%s: unsupported incompat filesystem feature(s) %x\n",
- obd->obd_name,
- lsd->lsd_feature_incompat & ~MDT_INCOMPAT_SUPP);
- GOTO(out, rc = -EINVAL);
- }
- if (lsd->lsd_feature_rocompat & ~MDT_ROCOMPAT_SUPP) {
- CERROR("%s: unsupported read-only filesystem feature(s) %x\n",
- obd->obd_name,
- lsd->lsd_feature_rocompat & ~MDT_ROCOMPAT_SUPP);
- /* XXX: Do something like remount filesystem read-only */
- GOTO(out, rc = -EINVAL);
- }
- /** Interop: evict all clients at first boot with 1.8 last_rcvd */
- if (!(lsd->lsd_feature_compat & OBD_COMPAT_20)) {
- LCONSOLE_WARN("Mounting %s at first time on 1.8 FS, remove all"
- " clients for interop needs\n", obd->obd_name);
- simple_truncate(lsi->lsi_srv_mnt->mnt_sb->s_root,
- lsi->lsi_srv_mnt, LAST_RCVD,
- lsd->lsd_client_start);
- last_rcvd_size = lsd->lsd_client_start;
- /** set 2.0 flag to upgrade/downgrade between 1.8 and 2.0 */
- lsd->lsd_feature_compat |= OBD_COMPAT_20;
- }
-
- if (ldd->ldd_flags & LDD_F_IAM_DIR)
- lsd->lsd_feature_incompat |= OBD_INCOMPAT_IAM_DIR;
-
- lsd->lsd_feature_incompat |= OBD_INCOMPAT_FID;
-
- spin_lock(&mdt->mdt_transno_lock);
- mdt->mdt_last_transno = lsd->lsd_last_transno;
- spin_unlock(&mdt->mdt_transno_lock);
-
- CDEBUG(D_INODE, "========BEGIN DUMPING LAST_RCVD========\n");
- CDEBUG(D_INODE, "%s: server last_transno: "LPU64"\n",
- obd->obd_name, mdt->mdt_last_transno);
- CDEBUG(D_INODE, "%s: server mount_count: "LPU64"\n",
- obd->obd_name, mount_count + 1);
- CDEBUG(D_INODE, "%s: server data size: %u\n",
- obd->obd_name, lsd->lsd_server_size);
- CDEBUG(D_INODE, "%s: per-client data start: %u\n",
- obd->obd_name, lsd->lsd_client_start);
- CDEBUG(D_INODE, "%s: per-client data size: %u\n",
- obd->obd_name, lsd->lsd_client_size);
- CDEBUG(D_INODE, "%s: last_rcvd size: %lu\n",
- obd->obd_name, last_rcvd_size);
- CDEBUG(D_INODE, "%s: last_rcvd clients: %lu\n", obd->obd_name,
- last_rcvd_size <= lsd->lsd_client_start ? 0 :
- (last_rcvd_size - lsd->lsd_client_start) /
- lsd->lsd_client_size);
- CDEBUG(D_INODE, "========END DUMPING LAST_RCVD========\n");
-
- if (!lsd->lsd_server_size || !lsd->lsd_client_start ||
- !lsd->lsd_client_size) {
- CERROR("Bad last_rcvd contents!\n");
- GOTO(out, rc = -EINVAL);
- }
-
- rc = mdt_clients_data_init(env, mdt, last_rcvd_size);
- if (rc)
- GOTO(err_client, rc);
-
- spin_lock(&mdt->mdt_transno_lock);
- /* obd_last_committed is used for compatibility
- * with other lustre recovery code */
- obd->obd_last_committed = mdt->mdt_last_transno;
- spin_unlock(&mdt->mdt_transno_lock);
-
- mdt->mdt_mount_count = mount_count + 1;
- lsd->lsd_mount_count = mdt->mdt_mount_count;
-
- /* save it, so mount count and last_transno is current */
- rc = mdt_server_data_update(env, mdt);
- if (rc)
- GOTO(err_client, rc);
-
- RETURN(0);
-
-err_client:
- class_disconnect_exports(obd);
-out:
- return rc;
-}
-
-static int mdt_server_data_update(const struct lu_env *env,
- struct mdt_device *mdt)
-{
- struct mdt_thread_info *mti;
- struct thandle *th;
- int rc;
-
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
-
- mdt_trans_credit_init(env, mdt, MDT_TXN_LAST_RCVD_WRITE_OP);
- th = mdt_trans_start(env, mdt);
- if (IS_ERR(th))
- RETURN(PTR_ERR(th));
-
- CDEBUG(D_SUPER, "MDS mount_count is "LPU64", last_transno is "LPU64"\n",
- mdt->mdt_mount_count, mdt->mdt_last_transno);
-
- spin_lock(&mdt->mdt_transno_lock);
- mdt->mdt_lsd.lsd_last_transno = mdt->mdt_last_transno;
- spin_unlock(&mdt->mdt_transno_lock);
-
- rc = mdt_last_rcvd_header_write(env, mdt, th);
- mdt_trans_stop(env, mdt, th);
- return rc;
-}
-
-
-int mdt_client_new(const struct lu_env *env, struct mdt_device *mdt)
-{
- unsigned long *bitmap = mdt->mdt_client_bitmap;
- struct mdt_thread_info *mti;
- struct mdt_export_data *med;
- struct lsd_client_data *lcd;
- struct lr_server_data *lsd = &mdt->mdt_lsd;
- struct obd_device *obd = mdt2obd_dev(mdt);
- struct thandle *th;
- loff_t off;
- int rc;
- int cl_idx;
- ENTRY;
-
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- LASSERT(mti != NULL);
-
- med = &mti->mti_exp->exp_mdt_data;
- lcd = med->med_lcd;
-
- LASSERT(bitmap != NULL);
- if (!strcmp(med->med_lcd->lcd_uuid, obd->obd_uuid.uuid))
- RETURN(0);
-
- /* the bitmap operations can handle cl_idx > sizeof(long) * 8, so
- * there's no need for extra complication here
- */
- spin_lock(&mdt->mdt_client_bitmap_lock);
- cl_idx = find_first_zero_bit(bitmap, LR_MAX_CLIENTS);
- if (cl_idx >= LR_MAX_CLIENTS ||
- OBD_FAIL_CHECK(OBD_FAIL_MDS_CLIENT_ADD)) {
- CERROR("no room for %u clients - fix LR_MAX_CLIENTS\n",
- cl_idx);
- spin_unlock(&mdt->mdt_client_bitmap_lock);
- RETURN(-EOVERFLOW);
- }
- set_bit(cl_idx, bitmap);
- spin_unlock(&mdt->mdt_client_bitmap_lock);
-
- CDEBUG(D_INFO, "client at idx %d with UUID '%s' added\n",
- cl_idx, med->med_lcd->lcd_uuid);
-
- med->med_lr_idx = cl_idx;
- med->med_lr_off = lsd->lsd_client_start +
- (cl_idx * lsd->lsd_client_size);
- init_mutex(&med->med_lcd_lock);
-
- LASSERTF(med->med_lr_off > 0, "med_lr_off = %llu\n", med->med_lr_off);
-
- /* Write new client data. */
- off = med->med_lr_off;
- mdt_trans_credit_init(env, mdt, MDT_TXN_LAST_RCVD_WRITE_OP);
-
- th = mdt_trans_start(env, mdt);
- if (IS_ERR(th))
- RETURN(PTR_ERR(th));
-
- /*
- * Until this operations will be committed the sync is needed
- * for this export. This should be done _after_ starting the
- * transaction so that many connecting clients will not bring
- * server down with lots of sync writes.
- */
- mdt_trans_add_cb(th, lut_cb_client, class_export_cb_get(mti->mti_exp));
- spin_lock(&mti->mti_exp->exp_lock);
- mti->mti_exp->exp_need_sync = 1;
- spin_unlock(&mti->mti_exp->exp_lock);
-
- rc = mdt_last_rcvd_write(env, mdt, lcd, &off, th);
- CDEBUG(D_INFO, "wrote client lcd at idx %u off %llu (len %u)\n",
- cl_idx, med->med_lr_off, (int)sizeof(*lcd));
- mdt_trans_stop(env, mdt, th);
-
- RETURN(rc);
-}
-
-/* Add client data to the MDS. We use a bitmap to locate a free space
- * in the last_rcvd file if cl_off is -1 (i.e. a new client).
- * Otherwise, we just have to read the data from the last_rcvd file and
- * we know its offset.
- *
- * It should not be possible to fail adding an existing client - otherwise
- * mdt_init_server_data() callsite needs to be fixed.
- */
-int mdt_client_add(const struct lu_env *env,
- struct mdt_device *mdt, int cl_idx)
-{
- struct mdt_thread_info *mti;
- struct mdt_export_data *med;
- unsigned long *bitmap = mdt->mdt_client_bitmap;
- struct obd_device *obd = mdt2obd_dev(mdt);
- struct lr_server_data *lsd = &mdt->mdt_lsd;
- int rc = 0;
- ENTRY;
-
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- LASSERT(mti != NULL);
-
- med = &mti->mti_exp->exp_mdt_data;
-
- LASSERT(bitmap != NULL);
- LASSERTF(cl_idx >= 0, "%d\n", cl_idx);
-
- if (!strcmp(med->med_lcd->lcd_uuid, obd->obd_uuid.uuid))
- RETURN(0);
-
- spin_lock(&mdt->mdt_client_bitmap_lock);
- if (test_and_set_bit(cl_idx, bitmap)) {
- CERROR("MDS client %d: bit already set in bitmap!!\n",
- cl_idx);
- LBUG();
- }
- spin_unlock(&mdt->mdt_client_bitmap_lock);
-
- CDEBUG(D_INFO, "client at idx %d with UUID '%s' added\n",
- cl_idx, med->med_lcd->lcd_uuid);
-
- med->med_lr_idx = cl_idx;
- med->med_lr_off = lsd->lsd_client_start +
- (cl_idx * lsd->lsd_client_size);
- init_mutex(&med->med_lcd_lock);
-
- LASSERTF(med->med_lr_off > 0, "med_lr_off = %llu\n", med->med_lr_off);
-
- RETURN(rc);
-}
-
-int mdt_client_del(const struct lu_env *env, struct mdt_device *mdt)
-{
- struct mdt_thread_info *mti;
- struct mdt_export_data *med;
- struct lsd_client_data *lcd;
- struct obd_device *obd = mdt2obd_dev(mdt);
- struct obd_export *exp;
- struct thandle *th;
- loff_t off;
- int rc = 0;
- ENTRY;
-
- mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- LASSERT(mti != NULL);
-
- exp = mti->mti_exp;
- med = &exp->exp_mdt_data;
- lcd = med->med_lcd;
- if (!lcd)
- RETURN(0);
-
- /* XXX: If lcd_uuid were a real obd_uuid, I could use obd_uuid_equals */
- if (!strcmp(lcd->lcd_uuid, obd->obd_uuid.uuid))
- GOTO(free, 0);
-
- CDEBUG(D_INFO, "freeing client at idx %u, offset %lld\n",
- med->med_lr_idx, med->med_lr_off);
-
- off = med->med_lr_off;
-
- /*
- * Don't clear med_lr_idx here as it is likely also unset. At worst we
- * leak a client slot that will be cleaned on the next recovery.
- */
- if (off <= 0) {
- CERROR("client idx %d has offset %lld\n",
- med->med_lr_idx, off);
- GOTO(free, rc = -EINVAL);
- }
-
- /*
- * Clear the bit _after_ zeroing out the client so we don't race with
- * mdt_client_add and zero out new clients.
- */
- if (!test_bit(med->med_lr_idx, mdt->mdt_client_bitmap)) {
- CERROR("MDT client %u: bit already clear in bitmap!!\n",
- med->med_lr_idx);
- LBUG();
- }
-
- /* 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 */
- mdt_server_data_update(env, mdt);
-
- mdt_trans_credit_init(env, mdt, MDT_TXN_LAST_RCVD_WRITE_OP);
- th = mdt_trans_start(env, mdt);
- if (IS_ERR(th))
- GOTO(free, rc = PTR_ERR(th));
-
- mutex_down(&med->med_lcd_lock);
- memset(lcd, 0, sizeof *lcd);
- rc = mdt_last_rcvd_write(env, mdt, lcd, &off, th);
- mutex_up(&med->med_lcd_lock);
- mdt_trans_stop(env, mdt, th);
-
- spin_lock(&mdt->mdt_client_bitmap_lock);
- clear_bit(med->med_lr_idx, mdt->mdt_client_bitmap);
- spin_unlock(&mdt->mdt_client_bitmap_lock);
-
- CDEBUG(rc == 0 ? D_INFO : D_ERROR, "Zeroing out client idx %u in "
- "%s, rc %d\n", med->med_lr_idx, LAST_RCVD, rc);
- EXIT;
-free:
- OBD_FREE_PTR(lcd);
- med->med_lcd = NULL;
- return 0;
-}
-