}
}
- CDEBUG(D_INFO, "client at index %d with UUID '%s' added\n",
+ CDEBUG(D_INFO, "client at idx %d with UUID '%s' added\n",
cl_idx, med->med_mcd->mcd_uuid);
med->med_idx = cl_idx;
if (!strcmp(med->med_mcd->mcd_uuid, obd->obd_uuid.uuid))
GOTO(free_and_out, 0);
- CDEBUG(D_INFO, "freeing client at index %u (%lld)with UUID '%s'\n",
+ CDEBUG(D_INFO, "freeing client at idx %u (%lld)with UUID '%s'\n",
med->med_idx, med->med_off, med->med_mcd->mcd_uuid);
- if (!test_and_clear_bit(med->med_idx, bitmap)) {
+ /* Clear the bit _after_ zeroing out the client so we don't
+ race with mds_client_add and zero out new clients.*/
+ if (!test_bit(med->med_idx, bitmap)) {
CERROR("MDS client %u: bit already clear in bitmap!!\n",
med->med_idx);
LBUG();
pop_ctxt(&saved, &obd->obd_ctxt, NULL);
CDEBUG(rc == 0 ? D_INFO : D_ERROR,
- "zeroing out client %s off %u in %s rc %d\n",
+ "zeroing out client %s idx %u in %s rc %d\n",
med->med_mcd->mcd_uuid, med->med_idx, LAST_RCVD, rc);
}
+ if (!test_and_clear_bit(med->med_idx, bitmap)) {
+ CERROR("MDS client %u: bit already clear in bitmap!!\n",
+ med->med_idx);
+ LBUG();
+ }
+
free_and_out:
OBD_FREE(med->med_mcd, sizeof(*med->med_mcd));
struct mds_client_data *mcd = NULL;
loff_t off = 0;
unsigned long last_rcvd_size = file->f_dentry->d_inode->i_size;
- __u64 last_transno = 0;
__u64 mount_count;
int cl_idx, rc = 0;
ENTRY;
- LASSERT(sizeof(struct mds_client_data) == MDS_LR_CLIENT_SIZE);
- LASSERT(sizeof(struct mds_server_data) <= MDS_LR_SERVER_SIZE);
+ /* ensure padding in the struct is the correct size */
+ LASSERT (offsetof(struct mds_server_data, msd_padding) +
+ sizeof(msd->msd_padding) == MDS_LR_SERVER_SIZE);
+ LASSERT (offsetof(struct mds_client_data, mcd_padding) +
+ sizeof(mcd->mcd_padding) == MDS_LR_CLIENT_SIZE);
OBD_ALLOC_WAIT(msd, sizeof(*msd));
if (!msd)
if (last_rcvd_size == 0) {
CWARN("%s: initializing new %s\n", obd->obd_name, LAST_RCVD);
+
memcpy(msd->msd_uuid, obd->obd_uuid.uuid,sizeof(msd->msd_uuid));
+ msd->msd_last_transno = 0;
+ mount_count = msd->msd_mount_count = 0;
msd->msd_server_size = cpu_to_le32(MDS_LR_SERVER_SIZE);
msd->msd_client_start = cpu_to_le32(MDS_LR_CLIENT_START);
msd->msd_client_size = cpu_to_le16(MDS_LR_CLIENT_SIZE);
msd->msd_feature_rocompat = cpu_to_le32(MDS_ROCOMPAT_LOVOBJID);
- rc = fsfilt_write_record(obd, file, msd, sizeof(*msd), &off, 1);
-
- if (rc == 0)
- RETURN(0);
-
- CERROR("%s: error writing new MSD: %d\n", obd->obd_name, rc);
- GOTO(err_msd, rc);
- }
-
- rc = fsfilt_read_record(obd, file, msd, sizeof(*msd), &off);
- if (rc) {
- CERROR("error reading MDS %s: rc = %d\n", LAST_RCVD, rc);
- GOTO(err_msd, rc);
+ } else {
+ rc = fsfilt_read_record(obd, file, msd, sizeof(*msd), &off);
+ if (rc) {
+ CERROR("error reading MDS %s: rc = %d\n", LAST_RCVD, rc);
+ GOTO(err_msd, rc);
+ }
+ if (strcmp(msd->msd_uuid, obd->obd_uuid.uuid) != 0) {
+ CERROR("OBD UUID %s does not match last_rcvd UUID %s\n",
+ obd->obd_uuid.uuid, msd->msd_uuid);
+ GOTO(err_msd, rc = -EINVAL);
+ }
+ mount_count = le64_to_cpu(msd->msd_mount_count);
}
- if (!msd->msd_server_size)
- msd->msd_server_size = cpu_to_le32(MDS_LR_SERVER_SIZE);
- if (!msd->msd_client_start)
- msd->msd_client_start = cpu_to_le32(MDS_LR_CLIENT_START);
- if (!msd->msd_client_size)
- msd->msd_client_size = cpu_to_le16(MDS_LR_CLIENT_SIZE);
-
if (msd->msd_feature_incompat & ~cpu_to_le32(MDS_INCOMPAT_SUPP)) {
CERROR("unsupported incompat feature %x\n",
le32_to_cpu(msd->msd_feature_incompat) &
GOTO(err_msd, rc = -EINVAL);
}
- last_transno = le64_to_cpu(msd->msd_last_transno);
- mds->mds_last_transno = last_transno;
-
- mount_count = le64_to_cpu(msd->msd_mount_count);
- mds->mds_mount_count = mount_count;
+ mds->mds_last_transno = le64_to_cpu(msd->msd_last_transno);
CDEBUG(D_INODE, "%s: server last_transno: "LPU64"\n",
- obd->obd_name, last_transno);
+ obd->obd_name, mds->mds_last_transno);
CDEBUG(D_INODE, "%s: server mount_count: "LPU64"\n",
- obd->obd_name, mount_count);
+ obd->obd_name, mount_count + 1);
CDEBUG(D_INODE, "%s: server data size: %u\n",
obd->obd_name, le32_to_cpu(msd->msd_server_size));
CDEBUG(D_INODE, "%s: per-client data start: %u\n",
for (cl_idx = 0, off = le32_to_cpu(msd->msd_client_start);
off < last_rcvd_size; cl_idx++) {
__u64 last_transno;
- int mount_age;
+ struct obd_export *exp;
+ struct mds_export_data *med;
if (!mcd) {
OBD_ALLOC_WAIT(mcd, sizeof(*mcd));
/* These exports are cleaned up by mds_disconnect(), so they
* need to be set up like real exports as mds_connect() does.
*/
- mount_age = mount_count - le64_to_cpu(mcd->mcd_mount_count);
- if (mount_age < MDS_MOUNT_RECOV) {
- struct obd_export *exp = class_new_export(obd);
- struct mds_export_data *med;
- CDEBUG(D_HA, "RCVRNG CLIENT uuid: %s idx: %d lr: "LPU64
- " srv lr: "LPU64" mnt: "LPU64" last mount: "
- LPU64"\n", mcd->mcd_uuid, cl_idx,
- last_transno, le64_to_cpu(msd->msd_last_transno),
- le64_to_cpu(mcd->mcd_mount_count), mount_count);
- if (exp == NULL)
- GOTO(err_client, rc = -ENOMEM);
-
- memcpy(&exp->exp_client_uuid.uuid, mcd->mcd_uuid,
- sizeof exp->exp_client_uuid.uuid);
- med = &exp->exp_mds_data;
- med->med_mcd = mcd;
- mds_client_add(obd, mds, med, cl_idx);
- /* create helper if export init gets more complex */
- INIT_LIST_HEAD(&med->med_open_head);
- spin_lock_init(&med->med_open_lock);
-
- mcd = NULL;
- obd->obd_recoverable_clients++;
- obd->obd_max_recoverable_clients++;
- class_export_put(exp);
- } else {
- CDEBUG(D_INFO, "discarded client %d, UUID '%s', count "
- LPU64"\n", cl_idx, mcd->mcd_uuid,
- le64_to_cpu(mcd->mcd_mount_count));
- }
+ CDEBUG(D_HA, "RCVRNG CLIENT uuid: %s idx: %d lr: "LPU64
+ " srv lr: "LPU64"\n", mcd->mcd_uuid, cl_idx,
+ last_transno, le64_to_cpu(msd->msd_last_transno));
+
+ exp = class_new_export(obd);
+ if (exp == NULL)
+ GOTO(err_client, rc = -ENOMEM);
+
+ memcpy(&exp->exp_client_uuid.uuid, mcd->mcd_uuid,
+ sizeof exp->exp_client_uuid.uuid);
+ med = &exp->exp_mds_data;
+ med->med_mcd = mcd;
+ mds_client_add(obd, mds, med, cl_idx);
+ /* create helper if export init gets more complex */
+ INIT_LIST_HEAD(&med->med_open_head);
+ spin_lock_init(&med->med_open_lock);
+
+ mcd = NULL;
+ obd->obd_recoverable_clients++;
+ 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);
if (last_transno > mds->mds_last_transno)
- mds->mds_last_transno = last_transno;
+ mds->mds_last_transno = last_transno;
}
obd->obd_last_committed = mds->mds_last_transno;
if (obd->obd_recoverable_clients) {
- CWARN("RECOVERY: %d recoverable clients, last_transno "
- LPU64"\n", obd->obd_recoverable_clients,
- mds->mds_last_transno);
+ CWARN("RECOVERY: service %s, %d recoverable clients, "
+ "last_transno "LPU64"\n", obd->obd_name,
+ obd->obd_recoverable_clients, mds->mds_last_transno);
obd->obd_next_recovery_transno = obd->obd_last_committed + 1;
obd->obd_recovering = 1;
}
if (mcd)
OBD_FREE(mcd, sizeof(*mcd));
+
+ mds->mds_mount_count = mount_count + 1;
+ msd->msd_mount_count = cpu_to_le64(mds->mds_mount_count);
- return 0;
+ /* save it, so mount count and last_transno is current */
+ rc = mds_update_server_data(obd, 1);
+
+ RETURN(rc);
err_client:
class_disconnect_exports(obd, 0);
err_msd:
mds_server_free_data(mds);
- return rc;
+ RETURN(rc);
}
int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)