📄 mds_fs.c
字号:
if (!lsd) RETURN(-ENOMEM); OBD_ALLOC_WAIT(mds->mds_client_bitmap, LR_MAX_CLIENTS / 8); if (!mds->mds_client_bitmap) { OBD_FREE(lsd, sizeof(*lsd)); RETURN(-ENOMEM); } mds->mds_server_data = lsd; 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; mount_count = lsd->lsd_mount_count = 0; lsd->lsd_server_size = cpu_to_le32(LR_SERVER_SIZE); lsd->lsd_client_start = cpu_to_le32(LR_CLIENT_START); lsd->lsd_client_size = cpu_to_le16(LR_CLIENT_SIZE); lsd->lsd_feature_rocompat = cpu_to_le32(OBD_ROCOMPAT_LOVOBJID); lsd->lsd_feature_incompat = cpu_to_le32(OBD_INCOMPAT_MDT); } else { rc = fsfilt_read_record(obd, file, lsd, sizeof(*lsd), &off); if (rc) { CERROR("error reading MDS %s: rc %d\n", LAST_RCVD, rc); GOTO(err_msd, 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(err_msd, rc = -EINVAL); } /* COMPAT_146 */ /* Assume old last_rcvd format unless I_C_LR is set */ if (!(lsd->lsd_feature_incompat & cpu_to_le32(OBD_INCOMPAT_COMMON_LR))) lsd->lsd_mount_count = lsd->lsd_compat14; /* end COMPAT_146 */ mount_count = le64_to_cpu(lsd->lsd_mount_count); } if (lsd->lsd_feature_incompat & ~cpu_to_le32(MDT_INCOMPAT_SUPP)) { CERROR("%s: unsupported incompat filesystem feature(s) %x\n", obd->obd_name, le32_to_cpu(lsd->lsd_feature_incompat) & ~MDT_INCOMPAT_SUPP); GOTO(err_msd, rc = -EINVAL); } if (lsd->lsd_feature_rocompat & ~cpu_to_le32(MDT_ROCOMPAT_SUPP)) { CERROR("%s: unsupported read-only filesystem feature(s) %x\n", obd->obd_name, le32_to_cpu(lsd->lsd_feature_rocompat) & ~MDT_ROCOMPAT_SUPP); /* Do something like remount filesystem read-only */ GOTO(err_msd, rc = -EINVAL); } lsd->lsd_feature_compat = cpu_to_le32(OBD_COMPAT_MDT); mds->mds_last_transno = le64_to_cpu(lsd->lsd_last_transno); CDEBUG(D_INODE, "%s: server last_transno: "LPU64"\n", obd->obd_name, mds->mds_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, le32_to_cpu(lsd->lsd_server_size)); CDEBUG(D_INODE, "%s: per-client data start: %u\n", obd->obd_name, le32_to_cpu(lsd->lsd_client_start)); CDEBUG(D_INODE, "%s: per-client data size: %u\n", obd->obd_name, le32_to_cpu(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 <= le32_to_cpu(lsd->lsd_client_start) ? 0 : (last_rcvd_size - le32_to_cpu(lsd->lsd_client_start)) / le16_to_cpu(lsd->lsd_client_size)); if (!lsd->lsd_server_size || !lsd->lsd_client_start || !lsd->lsd_client_size) { CERROR("Bad last_rcvd contents!\n"); GOTO(err_msd, rc = -EINVAL); } /* 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. */ for (cl_idx = 0, off = le32_to_cpu(lsd->lsd_client_start); off < last_rcvd_size; cl_idx++) { __u64 last_transno; struct obd_export *exp; struct mds_export_data *med; if (!mcd) { OBD_ALLOC_WAIT(mcd, sizeof(*mcd)); if (!mcd) GOTO(err_client, rc = -ENOMEM); } /* Don't assume off is incremented properly by * fsfilt_read_record(), in case sizeof(*mcd) * isn't the same as lsd->lsd_client_size. */ off = le32_to_cpu(lsd->lsd_client_start) + cl_idx * le16_to_cpu(lsd->lsd_client_size); rc = fsfilt_read_record(obd, file, mcd, sizeof(*mcd), &off); if (rc) { CERROR("error reading MDS %s idx %d, off %llu: rc %d\n", LAST_RCVD, cl_idx, off, rc); break; /* read error shouldn't cause startup to fail */ } if (mcd->mcd_uuid[0] == '\0') { CDEBUG(D_INFO, "skipping zeroed client at offset %d\n", cl_idx); continue; } last_transno = le64_to_cpu(mcd->mcd_last_transno) > le64_to_cpu(mcd->mcd_last_close_transno) ? le64_to_cpu(mcd->mcd_last_transno) : le64_to_cpu(mcd->mcd_last_close_transno); /* These exports are cleaned up by mds_disconnect(), so they * need to be set up like real exports as mds_connect() does. */ CDEBUG(D_HA, "RCVRNG CLIENT uuid: %s idx: %d lr: "LPU64 " srv lr: "LPU64" lx: "LPU64"\n", mcd->mcd_uuid, cl_idx, last_transno, le64_to_cpu(lsd->lsd_last_transno), le64_to_cpu(mcd->mcd_last_xid)); exp = class_new_export(obd, (struct obd_uuid *)mcd->mcd_uuid); if (IS_ERR(exp)) { if (PTR_ERR(exp) == -EALREADY) { /* export already exists, zero out this one */ mcd->mcd_uuid[0] = '\0'; } else { GOTO(err_client, rc = PTR_ERR(exp)); } } else { med = &exp->exp_mds_data; med->med_mcd = mcd; rc = mds_client_add(obd, exp, cl_idx, 0); /* can't fail for existing client */ LASSERTF(rc == 0, "rc = %d\n", rc); mcd = NULL; spin_lock(&exp->exp_lock); exp->exp_replay_needed = 1; exp->exp_connecting = 0; spin_unlock(&exp->exp_lock); obd->obd_recoverable_clients++; 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_transno = "LPU64"\n", cl_idx, last_transno); if (last_transno > mds->mds_last_transno) mds->mds_last_transno = last_transno; } if (mcd) OBD_FREE(mcd, sizeof(*mcd)); obd->obd_last_committed = mds->mds_last_transno; if (obd->obd_recoverable_clients) { 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; obd->obd_recovery_start = 0; obd->obd_recovery_end = 0; obd->obd_recovery_timeout = OBD_RECOVERY_FACTOR * obd_timeout;#ifdef CRAY_XT3 /* bz13079: this won't be changed for mds */ obd->obd_recovery_max_time = OBD_RECOVERY_MAX_TIME;#endif } mds->mds_mount_count = mount_count + 1; lsd->lsd_mount_count = lsd->lsd_compat14 = cpu_to_le64(mds->mds_mount_count); /* save it, so mount count and last_transno is current */ rc = mds_update_server_data(obd, 1); if (rc) GOTO(err_client, rc); RETURN(0);err_client: class_disconnect_exports(obd);err_msd: mds_server_free_data(mds); RETURN(rc);}int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt){ struct mds_obd *mds = &obd->u.mds; struct lvfs_run_ctxt saved; struct dentry *dentry; struct file *file; int rc; ENTRY; OBD_FAIL_RETURN(OBD_FAIL_MDS_FS_SETUP, -ENOENT); rc = cleanup_group_info(); if (rc) RETURN(rc); mds->mds_vfsmnt = mnt; /* why not mnt->mnt_sb instead of mnt->mnt_root->d_inode->i_sb? */ obd->u.obt.obt_sb = mnt->mnt_root->d_inode->i_sb; rc = fsfilt_setup(obd, obd->u.obt.obt_sb); if (rc) RETURN(rc); OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt); obd->obd_lvfs_ctxt.pwdmnt = mnt; obd->obd_lvfs_ctxt.pwd = mnt->mnt_root; obd->obd_lvfs_ctxt.fs = get_ds(); obd->obd_lvfs_ctxt.cb_ops = mds_lvfs_ops; /* setup the directory tree */ push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); dentry = simple_mkdir(current->fs->pwd, "ROOT", 0755, 0); if (IS_ERR(dentry)) { rc = PTR_ERR(dentry); CERROR("cannot create ROOT directory: rc = %d\n", rc); GOTO(err_pop, rc); } mds->mds_rootfid.id = dentry->d_inode->i_ino; mds->mds_rootfid.generation = dentry->d_inode->i_generation; mds->mds_rootfid.f_type = S_IFDIR; dput(dentry); dentry = lookup_one_len("__iopen__", current->fs->pwd, strlen("__iopen__")); if (IS_ERR(dentry)) { rc = PTR_ERR(dentry); CERROR("cannot lookup __iopen__ directory: rc = %d\n", rc); GOTO(err_pop, rc); } mds->mds_fid_de = dentry; if (!dentry->d_inode || is_bad_inode(dentry->d_inode)) { rc = -ENOENT; CERROR("__iopen__ directory has no inode? rc = %d\n", rc); GOTO(err_fid, rc); } dentry = simple_mkdir(current->fs->pwd, "PENDING", 0777, 1); if (IS_ERR(dentry)) { rc = PTR_ERR(dentry); CERROR("cannot create PENDING directory: rc = %d\n", rc); GOTO(err_fid, rc); } mds->mds_pending_dir = dentry; /* COMPAT_146 */ dentry = simple_mkdir(current->fs->pwd, MDT_LOGS_DIR, 0777, 1); if (IS_ERR(dentry)) { rc = PTR_ERR(dentry); CERROR("cannot create %s directory: rc = %d\n", MDT_LOGS_DIR, rc); GOTO(err_pending, rc); } mds->mds_logs_dir = dentry; /* end COMPAT_146 */ dentry = simple_mkdir(current->fs->pwd, "OBJECTS", 0777, 1); if (IS_ERR(dentry)) { rc = PTR_ERR(dentry);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -