- if (rc) {
- CERROR("%s: Can't init seq exp, rc %d\n", ofd_name(ofd), rc);
- return rc;
- }
-
- rwlock_init(&ofd->ofd_seq_list_lock);
- CFS_INIT_LIST_HEAD(&ofd->ofd_seq_list);
- ofd->ofd_seq_count = 0;
- return rc;
-}
-
-int ofd_clients_data_init(const struct lu_env *env, struct ofd_device *ofd,
- unsigned long fsize)
-{
- struct obd_device *obd = ofd_obd(ofd);
- struct lr_server_data *lsd = &ofd->ofd_lut.lut_lsd;
- struct lsd_client_data *lcd = NULL;
- struct filter_export_data *fed;
- int cl_idx;
- int rc = 0;
- loff_t off = lsd->lsd_client_start;
-
- CLASSERT(offsetof(struct lsd_client_data, lcd_padding) +
- sizeof(lcd->lcd_padding) == LR_CLIENT_SIZE);
-
- OBD_ALLOC_PTR(lcd);
- if (lcd == NULL)
- RETURN(-ENOMEM);
-
- for (cl_idx = 0; off < fsize; cl_idx++) {
- struct obd_export *exp;
- __u64 last_rcvd;
-
- /* Don't assume off is incremented properly by
- * fsfilt_read_record(), in case sizeof(*lcd)
- * isn't the same as fsd->lsd_client_size. */
- off = lsd->lsd_client_start + cl_idx * lsd->lsd_client_size;
- rc = tgt_client_data_read(env, &ofd->ofd_lut, lcd, &off, cl_idx);
- if (rc) {
- CERROR("%s: error reading FILT %s idx %d off %llu: "
- "rc = %d\n", ofd_name(ofd), 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_rcvd = lcd->lcd_last_transno;
-
- /* These exports are cleaned up by ofd_disconnect(), so they
- * need to be set up like real exports as ofd_connect() does.
- */
- exp = class_new_export(obd, (struct obd_uuid *)lcd->lcd_uuid);
-
- CDEBUG(D_HA, "RCVRNG CLIENT uuid: %s idx: %d lr: "LPU64
- " srv lr: "LPU64"\n", lcd->lcd_uuid, cl_idx,
- last_rcvd, lsd->lsd_last_transno);
-
- if (IS_ERR(exp)) {
- if (PTR_ERR(exp) == -EALREADY) {
- /* export already exists, zero out this one */
- CERROR("%s: Duplicate export %s!\n",
- ofd_name(ofd), lcd->lcd_uuid);
- continue;
- }
- GOTO(err_out, rc = PTR_ERR(exp));
- }
-
- fed = &exp->exp_filter_data;
- *fed->fed_ted.ted_lcd = *lcd;
-
- rc = tgt_client_add(env, exp, cl_idx);
- LASSERTF(rc == 0, "rc = %d\n", rc); /* can't fail existing */
- /* VBR: set export last committed version */
- exp->exp_last_committed = last_rcvd;
- 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);
-
- /* Need to check last_rcvd even for duplicated exports. */
- CDEBUG(D_OTHER, "client at idx %d has last_rcvd = "LPU64"\n",
- cl_idx, last_rcvd);
-
- spin_lock(&ofd->ofd_lut.lut_translock);
- if (last_rcvd > lsd->lsd_last_transno)
- lsd->lsd_last_transno = last_rcvd;
- spin_unlock(&ofd->ofd_lut.lut_translock);
- }
-
-err_out:
- OBD_FREE_PTR(lcd);
- RETURN(rc);
-}
-
-int ofd_server_data_init(const struct lu_env *env, struct ofd_device *ofd)
-{
- struct ofd_thread_info *info = ofd_info(env);
- struct lr_server_data *lsd = &ofd->ofd_lut.lut_lsd;
- struct obd_device *obd = ofd_obd(ofd);
- unsigned long last_rcvd_size;
- __u32 index;
- int rc;
-
- rc = dt_attr_get(env, ofd->ofd_lut.lut_last_rcvd, &info->fti_attr,
- BYPASS_CAPA);
- if (rc)
- RETURN(rc);
-
- last_rcvd_size = (unsigned long)info->fti_attr.la_size;
-
- /* ensure padding in the struct is the correct size */
- CLASSERT (offsetof(struct lr_server_data, lsd_padding) +
- sizeof(lsd->lsd_padding) == LR_SERVER_SIZE);
-
- rc = server_name2index(obd->obd_name, &index, NULL);