- struct inode *root = 0;
- struct obd_device *obd;
- struct ll_sb_info *sbi;
- char *osc = NULL;
- char *mdc = NULL;
- int err;
- struct ll_fid rootfid;
- struct obd_statfs osfs;
- struct ptlrpc_request *request = NULL;
- struct ptlrpc_connection *mdc_conn;
- struct ll_read_inode2_cookie lic;
- class_uuid_t uuid;
-
- ENTRY;
- MOD_INC_USE_COUNT;
-
- OBD_ALLOC(sbi, sizeof(*sbi));
- if (!sbi) {
- MOD_DEC_USE_COUNT;
- RETURN(-ENOMEM);
- }
-
- INIT_LIST_HEAD(&sbi->ll_conn_chain);
- generate_random_uuid(uuid);
- class_uuid_unparse(uuid, sbi->ll_sb_uuid);
-
- sb->s_fs_info = sbi;
-
- ll_options(data, &osc, &mdc, &sbi->ll_flags);
-
- if (!osc) {
- CERROR("no osc\n");
- GOTO(out_free, sb = NULL);
- }
-
- if (!mdc) {
- CERROR("no mdc\n");
- GOTO(out_free, sb = NULL);
- }
-
- obd = class_uuid2obd(mdc);
- if (!obd) {
- CERROR("MDC %s: not setup or attached\n", mdc);
- GOTO(out_free, sb = NULL);
- }
-
- err = obd_connect(&sbi->ll_mdc_conn, obd, sbi->ll_sb_uuid,
- ptlrpc_recovd, ll_recover);
- if (err) {
- CERROR("cannot connect to %s: rc = %d\n", mdc, err);
- GOTO(out_free, sb = NULL);
- }
-
-#warning Peter: is this the right place to raise the connection level?
- mdc_conn = sbi2mdc(sbi)->cl_import.imp_connection;
- mdc_conn->c_level = LUSTRE_CONN_FULL;
- list_add(&mdc_conn->c_sb_chain, &sbi->ll_conn_chain);
-
- obd = class_uuid2obd(osc);
- if (!obd) {
- CERROR("OSC %s: not setup or attached\n", osc);
- GOTO(out_mdc, sb = NULL);
- }
-
- err = obd_connect(&sbi->ll_osc_conn, obd, sbi->ll_sb_uuid,
- ptlrpc_recovd, ll_recover);
- if (err) {
- CERROR("cannot connect to %s: rc = %d\n", osc, err);
- GOTO(out_mdc, sb = NULL);
- }
-
- err = mdc_getstatus(&sbi->ll_mdc_conn, &rootfid);
- if (err) {
- CERROR("cannot mds_connect: rc = %d\n", err);
- GOTO(out_mdc, sb = NULL);
- }
- CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id);
- sbi->ll_rootino = rootfid.id;
-
- memset(&osfs, 0, sizeof(osfs));
- err = mdc_statfs(&sbi->ll_mdc_conn, &osfs);
- sb->s_blocksize = osfs.os_bsize;
- sb->s_blocksize_bits = log2(osfs.os_bsize);
- sb->s_magic = LL_SUPER_MAGIC;
- sb->s_maxbytes = (1ULL << (32 + 9)) - osfs.os_bsize;
-
- sb->s_op = &ll_super_operations;
-
- /* make root inode */
- err = mdc_getattr(&sbi->ll_mdc_conn, sbi->ll_rootino, S_IFDIR,
- OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, 0, &request);
- if (err) {
- CERROR("mdc_getattr failed for root: rc = %d\n", err);
- GOTO(out_request, sb = NULL);
- }
-
- /* initialize committed transaction callback daemon */
- spin_lock_init(&sbi->ll_commitcbd_lock);
- init_waitqueue_head(&sbi->ll_commitcbd_waitq);
- init_waitqueue_head(&sbi->ll_commitcbd_ctl_waitq);
- sbi->ll_commitcbd_flags = 0;
- err = ll_commitcbd_setup(sbi);
- if (err) {
- CERROR("failed to start commit callback daemon: rc = %d\n",err);
- GOTO(out_request, sb = NULL);
- }
-
- lic.lic_body = lustre_msg_buf(request->rq_repmsg, 0);
- lic.lic_lmm = NULL;
- root = iget5_locked(sb, sbi->ll_rootino, NULL,
- ll_read_inode2, &lic);
-
- if (root) {
- sb->s_root = d_alloc_root(root);
- } else {
- CERROR("lustre_lite: bad iget4 for root\n");
- GOTO(out_cdb, sb = NULL);
- }