Whamcloud - gitweb
b=22615 fixes for regressions caused by 11063
[fs/lustre-release.git] / lustre / liblustre / super.c
index ff23356..7be70b9 100644 (file)
@@ -65,8 +65,6 @@
 #include <file.h>
 #endif
 
-#undef LIST_HEAD
-
 #include "llite_lib.h"
 
 #ifndef MAY_EXEC
@@ -84,7 +82,7 @@ static int ll_permission(struct inode *inode, int mask)
 
         if (current->fsuid == st->st_uid)
                 mode >>= 6;
-        else if (in_group_p(st->st_gid))
+        else if (cfs_curproc_is_in_groups(st->st_gid))
                 mode >>= 3;
 
         if ((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask)
@@ -111,7 +109,7 @@ static void llu_fsop_gone(struct filesys *fs)
         int next = 0;
         ENTRY;
 
-        list_del(&sbi->ll_conn_chain);
+        cfs_list_del(&sbi->ll_conn_chain);
         cl_sb_fini(sbi);
         obd_disconnect(sbi->ll_dt_exp);
         obd_disconnect(sbi->ll_md_exp);
@@ -175,24 +173,22 @@ void llu_update_inode(struct inode *inode, struct lustre_md *md)
                 }
         }
 
-        if (body->valid & OBD_MD_FLMTIME &&
-            body->mtime > LTIME_S(st->st_mtime))
-                LTIME_S(st->st_mtime) = body->mtime;
-        if (body->valid & OBD_MD_FLATIME &&
-            body->atime > LTIME_S(st->st_atime))
-                LTIME_S(st->st_atime) = body->atime;
-
-        /* mtime is always updated with ctime, but can be set in past.
-           As write and utime(2) may happen within 1 second, and utime's
-           mtime has a priority over write's one, so take mtime from mds
-           for the same ctimes. */
-        if (body->valid & OBD_MD_FLCTIME &&
-            body->ctime >= LTIME_S(st->st_ctime)) {
-                LTIME_S(st->st_ctime) = body->ctime;
-                if (body->valid & OBD_MD_FLMTIME)
+        if (body->valid & OBD_MD_FLATIME) {
+                if (body->atime > LTIME_S(st->st_atime))
+                        LTIME_S(st->st_atime) = body->atime;
+                lli->lli_lvb.lvb_atime = body->atime;
+        }
+        if (body->valid & OBD_MD_FLMTIME) {
+                if (body->mtime > LTIME_S(st->st_mtime))
                         LTIME_S(st->st_mtime) = body->mtime;
+                lli->lli_lvb.lvb_mtime = body->mtime;
+        }
+        if (body->valid & OBD_MD_FLCTIME) {
+                if (body->ctime > LTIME_S(st->st_ctime))
+                        LTIME_S(st->st_ctime) = body->ctime;
+                lli->lli_lvb.lvb_ctime = body->ctime;
         }
-       if (S_ISREG(st->st_mode))
+        if (S_ISREG(st->st_mode))
                 st->st_blksize = min(2UL * PTLRPC_MAX_BRW_SIZE, LL_MAX_BLKSIZE);
         else
                 st->st_blksize = 4096;
@@ -340,10 +336,12 @@ void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid)
         dst->o_valid |= newvalid;
 }
 
-/*
- * really does the getattr on the inode and updates its fields
+/**
+ * Performs the getattr on the inode and updates its fields.
+ * If @sync != 0, perform the getattr under the server-side lock.
  */
-int llu_inode_getattr(struct inode *inode, struct obdo *obdo)
+int llu_inode_getattr(struct inode *inode, struct obdo *obdo,
+                      __u64 ioepoch, int sync)
 {
         struct llu_inode_info *lli = llu_i2info(inode);
         struct ptlrpc_request_set *set;
@@ -359,10 +357,16 @@ int llu_inode_getattr(struct inode *inode, struct obdo *obdo)
         oinfo.oi_oa->o_id = lsm->lsm_object_id;
         oinfo.oi_oa->o_gr = lsm->lsm_object_gr;
         oinfo.oi_oa->o_mode = S_IFREG;
+        oinfo.oi_oa->o_ioepoch = ioepoch;
         oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE |
                                OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
                                OBD_MD_FLBLKSZ | OBD_MD_FLMTIME |
-                               OBD_MD_FLCTIME | OBD_MD_FLGROUP;
+                               OBD_MD_FLCTIME | OBD_MD_FLGROUP |
+                               OBD_MD_FLATIME | OBD_MD_FLEPOCH;
+        if (sync) {
+                oinfo.oi_oa->o_valid |= OBD_MD_FLFLAGS;
+                oinfo.oi_oa->o_flags |= OBD_FL_SRVLOCK;
+        }
 
         set = ptlrpc_prep_set();
         if (set == NULL) {
@@ -460,7 +464,8 @@ static int llu_have_md_lock(struct inode *inode, __u64 lockpart)
 
 static int llu_inode_revalidate(struct inode *inode)
 {
-        struct lov_stripe_md *lsm = NULL;
+        struct llu_inode_info *lli = llu_i2info(inode);
+        struct intnl_stat *st = llu_i2stat(inode);
         ENTRY;
 
         if (!inode) {
@@ -472,20 +477,25 @@ static int llu_inode_revalidate(struct inode *inode)
                 struct lustre_md md;
                 struct ptlrpc_request *req = NULL;
                 struct llu_sb_info *sbi = llu_i2sbi(inode);
+                struct md_op_data op_data = { { 0 } };
                 unsigned long valid = OBD_MD_FLGETATTR;
                 int rc, ealen = 0;
 
                 /* Why don't we update all valid MDS fields here, if we're
                  * doing an RPC anyways?  -phil */
-                if (S_ISREG(llu_i2stat(inode)->st_mode)) {
+                if (S_ISREG(st->st_mode)) {
                         ealen = obd_size_diskmd(sbi->ll_dt_exp, NULL);
                         valid |= OBD_MD_FLEASIZE;
                 }
-                rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode),
-                                NULL, valid, ealen, &req);
+
+                llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, ealen,
+                                    LUSTRE_OPC_ANY);
+                op_data.op_valid = valid;
+
+                rc = md_getattr(sbi->ll_md_exp, &op_data, &req);
                 if (rc) {
                         CERROR("failure %d inode %llu\n", rc,
-                               (long long)llu_i2stat(inode)->st_ino);
+                               (long long)st->st_ino);
                         RETURN(-abs(rc));
                 }
                 rc = md_get_lustre_md(sbi->ll_md_exp, req,
@@ -507,14 +517,18 @@ static int llu_inode_revalidate(struct inode *inode)
 
 
                 llu_update_inode(inode, &md);
-                if (md.lsm != NULL && llu_i2info(inode)->lli_smd != md.lsm)
+                if (md.lsm != NULL && lli->lli_smd != md.lsm)
                         obd_free_memmd(sbi->ll_dt_exp, &md.lsm);
                 ptlrpc_req_finished(req);
         }
 
-        lsm = llu_i2info(inode)->lli_smd;
-        if (!lsm)       /* object not yet allocated, don't validate size */
+        if (!lli->lli_smd) {
+                /* object not yet allocated, don't validate size */
+                st->st_atime = lli->lli_lvb.lvb_atime;
+                st->st_mtime = lli->lli_lvb.lvb_mtime;
+                st->st_ctime = lli->lli_lvb.lvb_ctime;
                 RETURN(0);
+        }
 
         /* ll_glimpse_size will prefer locally cached writes if they extend
          * the file */
@@ -640,7 +654,8 @@ static int inode_setattr(struct inode * inode, struct iattr * attr)
                 st->st_ctime = attr->ia_ctime;
         if (ia_valid & ATTR_MODE) {
                 st->st_mode = attr->ia_mode;
-                if (!in_group_p(st->st_gid) && !cfs_capable(CFS_CAP_FSETID))
+                if (!cfs_curproc_is_in_groups(st->st_gid) &&
+                    !cfs_capable(CFS_CAP_FSETID))
                         st->st_mode &= ~S_ISGID;
         }
         /* mark_inode_dirty(inode); */
@@ -704,13 +719,15 @@ static int llu_setattr_done_writing(struct inode *inode,
         CDEBUG(D_INODE, "Epoch "LPU64" closed on "DFID" for truncate\n",
                op_data->op_ioepoch, PFID(&lli->lli_fid));
 
-        op_data->op_flags = MF_EPOCH_CLOSE | MF_SOM_CHANGE;
+        op_data->op_flags = MF_EPOCH_CLOSE;
+        llu_done_writing_attr(inode, op_data);
+        llu_pack_inode2opdata(inode, op_data, NULL);
+
         rc = md_done_writing(llu_i2sbi(inode)->ll_md_exp, op_data, mod);
         if (rc == -EAGAIN) {
                 /* MDS has instructed us to obtain Size-on-MDS attribute
                  * from OSTs and send setattr to back to MDS. */
-                rc = llu_sizeonmds_update(inode, mod, &op_data->op_handle,
-                                          op_data->op_ioepoch);
+                rc = llu_som_update(inode, op_data);
         } else if (rc) {
                 CERROR("inode %llu mdc truncate failed: rc = %d\n",
                        (unsigned long long)st->st_ino, rc);
@@ -756,33 +773,23 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
 
         /* We mark all of the fields "set" so MDS/OST does not re-set them */
         if (attr->ia_valid & ATTR_CTIME) {
-                attr->ia_ctime = CURRENT_TIME;
+                attr->ia_ctime = CFS_CURRENT_TIME;
                 attr->ia_valid |= ATTR_CTIME_SET;
         }
         if (!(ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) {
-                attr->ia_atime = CURRENT_TIME;
+                attr->ia_atime = CFS_CURRENT_TIME;
                 attr->ia_valid |= ATTR_ATIME_SET;
         }
         if (!(ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) {
-                attr->ia_mtime = CURRENT_TIME;
+                attr->ia_mtime = CFS_CURRENT_TIME;
                 attr->ia_valid |= ATTR_MTIME_SET;
         }
-        if ((attr->ia_valid & ATTR_CTIME) && !(attr->ia_valid & ATTR_MTIME)) {
-                /* To avoid stale mtime on mds, obtain it from ost and send
-                   to mds. */
-                rc = cl_glimpse_size(inode);
-                if (rc)
-                        RETURN(rc);
-
-                attr->ia_valid |= ATTR_MTIME_SET | ATTR_MTIME;
-                attr->ia_mtime = inode->i_stbuf.st_mtime;
-        }
 
         if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
                 CDEBUG(D_INODE, "setting mtime "CFS_TIME_T", ctime "CFS_TIME_T
                       ", now = "CFS_TIME_T"\n",
                        LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
-                       LTIME_S(CURRENT_TIME));
+                       LTIME_S(CFS_CURRENT_TIME));
 
         /* NB: ATTR_SIZE will only be set after this point if the size
          * resides on the MDS, ie, this file has no objects. */
@@ -796,17 +803,14 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
                 memcpy(&op_data.op_attr, attr, sizeof(*attr));
 
                 /* Open epoch for truncate. */
-                if (ia_valid & ATTR_SIZE)
+                if (exp_connect_som(llu_i2mdexp(inode)) &&
+                    (ia_valid & ATTR_SIZE))
                         op_data.op_flags = MF_EPOCH_OPEN;
                 rc = llu_md_setattr(inode, &op_data, &mod);
                 if (rc)
                         RETURN(rc);
 
-                if (op_data.op_ioepoch)
-                        CDEBUG(D_INODE, "Epoch "LPU64" opened on "DFID" for "
-                               "truncate\n", op_data.op_ioepoch,
-                               PFID(&llu_i2info(inode)->lli_fid));
-
+                llu_ioepoch_open(llu_i2info(inode), op_data.op_ioepoch);
                 if (!lsm || !S_ISREG(st->st_mode)) {
                         CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n");
                         GOTO(out, rc);
@@ -836,13 +840,16 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
                 inode_setattr(inode, attr);
         }
 
-        if (ia_valid & ATTR_SIZE) {
-                rc = cl_setattr_do_truncate(inode, attr->ia_size, NULL);
-        } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
-                CDEBUG(D_INODE, "set mtime on OST inode %llu to %lu\n",
-                       (long long unsigned)st->st_ino, LTIME_S(attr->ia_mtime));
-                rc = cl_setattr_ost(inode, NULL);
-        }
+        if (ia_valid & ATTR_SIZE)
+                attr->ia_valid |= ATTR_SIZE;
+        if ((ia_valid & ATTR_SIZE) | 
+            ((ia_valid | ATTR_ATIME | ATTR_ATIME_SET) &&
+             LTIME_S(attr->ia_atime) < LTIME_S(attr->ia_ctime)) ||
+            ((ia_valid | ATTR_MTIME | ATTR_MTIME_SET) &&
+             LTIME_S(attr->ia_mtime) < LTIME_S(attr->ia_ctime)))
+                /* perform truncate and setting mtime/atime to past under PW
+                 * 0:EOF extent lock (new_size:EOF for truncate) */
+                rc = cl_setattr_ost(inode, attr, NULL);
         EXIT;
 out:
         if (op_data.op_ioepoch)
@@ -895,7 +902,7 @@ static int llu_iop_setattr(struct pnode *pno,
         }
 
         iattr.ia_valid |= ATTR_RAW | ATTR_CTIME;
-        iattr.ia_ctime = CURRENT_TIME;
+        iattr.ia_ctime = CFS_CURRENT_TIME;
 
         rc = llu_setattr_raw(ino, &iattr);
         liblustre_wait_idle();
@@ -939,6 +946,7 @@ static int llu_readlink_internal(struct inode *inode,
         struct llu_sb_info *sbi = llu_i2sbi(inode);
         struct mdt_body *body;
         struct intnl_stat *st = llu_i2stat(inode);
+        struct md_op_data op_data = {{ 0 }};
         int rc, symlen = st->st_size + 1;
         ENTRY;
 
@@ -951,8 +959,11 @@ static int llu_readlink_internal(struct inode *inode,
                 RETURN(0);
         }
 
-        rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), NULL,
-                        OBD_MD_LINKNAME, symlen, request);
+        llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, symlen,
+                            LUSTRE_OPC_ANY);
+        op_data.op_valid = OBD_MD_LINKNAME;
+
+        rc = md_getattr(sbi->ll_md_exp, &op_data, request);
         if (rc) {
                 CERROR("inode %llu: rc = %d\n", (long long)st->st_ino, rc);
                 RETURN(rc);
@@ -1204,7 +1215,7 @@ static int llu_statfs(struct llu_sb_info *sbi, struct statfs *sfs)
         /* For now we will always get up-to-date statfs values, but in the
          * future we may allow some amount of caching on the client (e.g.
          * from QOS or lprocfs updates). */
-        rc = llu_statfs_internal(sbi, &osfs, cfs_time_current_64() - HZ);
+        rc = llu_statfs_internal(sbi, &osfs, cfs_time_current_64() - CFS_HZ);
         if (rc)
                 return rc;
 
@@ -1413,7 +1424,7 @@ static int llu_file_flock(struct inode *ino,
 
                 if (lmv->tgts[0].ltd_exp != NULL)
                         rc = ldlm_cli_enqueue(lmv->tgts[0].ltd_exp, NULL, &einfo, &res_id,
-                                              &flock, &flags, NULL, 0, NULL, &lockh, 0);
+                                              &flock, &flags, NULL, 0, &lockh, 0);
                 else
                         rc = -ENODEV;
         }
@@ -1602,56 +1613,51 @@ static int llu_get_grouplock(struct inode *inode, unsigned long arg)
 {
         struct llu_inode_info *lli = llu_i2info(inode);
         struct ll_file_data *fd = lli->lli_file_data;
-        ldlm_policy_data_t policy = { .l_extent = { .start = 0,
-                                                    .end = OBD_OBJECT_EOF}};
-        struct lustre_handle lockh = { 0 };
-        struct lov_stripe_md *lsm = lli->lli_smd;
-        ldlm_error_t err;
-        int flags = 0;
+        int rc;
+        struct ccc_grouplock grouplock;
         ENTRY;
 
+        if (fd->fd_flags & LL_FILE_IGNORE_LOCK) {
+                RETURN(-ENOTSUPP);
+        }
         if (fd->fd_flags & LL_FILE_GROUP_LOCKED) {
                 RETURN(-EINVAL);
         }
+        LASSERT(fd->fd_grouplock.cg_lock == NULL);
 
-        policy.l_extent.gid = arg;
-        if (lli->lli_open_flags & O_NONBLOCK)
-                flags = LDLM_FL_BLOCK_NOWAIT;
+        rc = cl_get_grouplock(cl_i2info(inode)->lli_clob,
+                              arg, (lli->lli_open_flags & O_NONBLOCK),
+                              &grouplock);
 
-        err = llu_extent_lock(fd, inode, lsm, LCK_GROUP, &policy, &lockh,
-                              flags);
-        if (err)
-                RETURN(err);
+        if (rc)
+                RETURN(rc);
 
-        fd->fd_flags |= LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK;
-        fd->fd_gid = arg;
-        memcpy(&fd->fd_cwlockh, &lockh, sizeof(lockh));
+        fd->fd_flags |= LL_FILE_GROUP_LOCKED;
+        fd->fd_grouplock = grouplock;
 
         RETURN(0);
 }
 
-static int llu_put_grouplock(struct inode *inode, unsigned long arg)
+int llu_put_grouplock(struct inode *inode, unsigned long arg)
 {
         struct llu_inode_info *lli = llu_i2info(inode);
         struct ll_file_data *fd = lli->lli_file_data;
-        struct lov_stripe_md *lsm = lli->lli_smd;
-        ldlm_error_t err;
+        struct ccc_grouplock grouplock;
         ENTRY;
 
         if (!(fd->fd_flags & LL_FILE_GROUP_LOCKED))
                 RETURN(-EINVAL);
 
-        if (fd->fd_gid != arg)
-                RETURN(-EINVAL);
+        LASSERT(fd->fd_grouplock.cg_lock != NULL);
 
-        fd->fd_flags &= ~(LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK);
+        if (fd->fd_grouplock.cg_gid != arg)
+                RETURN(-EINVAL);
 
-        err = llu_extent_unlock(fd, inode, lsm, LCK_GROUP, &fd->fd_cwlockh);
-        if (err)
-                RETURN(err);
+        grouplock = fd->fd_grouplock;
+        memset(&fd->fd_grouplock, 0, sizeof(fd->fd_grouplock));
+        fd->fd_flags &= ~LL_FILE_GROUP_LOCKED;
 
-        fd->fd_gid = 0;
-        memset(&fd->fd_cwlockh, 0, sizeof(fd->fd_cwlockh));
+        cl_put_grouplock(&grouplock);
 
         RETURN(0);
 }
@@ -1670,7 +1676,7 @@ static int llu_lov_dir_setstripe(struct inode *ino, unsigned long arg)
         LASSERT(sizeof(lum) == sizeof(*lump));
         LASSERT(sizeof(lum.lmm_objects[0]) ==
                 sizeof(lump->lmm_objects[0]));
-        if (copy_from_user(&lum, lump, sizeof(lum)))
+        if (cfs_copy_from_user(&lum, lump, sizeof(lum)))
                 return(-EFAULT);
 
         switch (lum.lmm_magic) {
@@ -1712,12 +1718,9 @@ static int llu_lov_setstripe_ea_info(struct inode *ino, int flags,
 {
         struct llu_sb_info *sbi = llu_i2sbi(ino);
         struct llu_inode_info *lli = llu_i2info(ino);
-        struct llu_inode_info *lli2 = NULL;
-        struct lov_stripe_md *lsm;
         struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags};
         struct ldlm_enqueue_info einfo = { LDLM_IBITS, LCK_CR,
                 llu_md_blocking_ast, ldlm_completion_ast, NULL, NULL, NULL };
-
         struct ptlrpc_request *req = NULL;
         struct lustre_md md;
         struct md_op_data data = {{ 0 }};
@@ -1725,28 +1728,14 @@ static int llu_lov_setstripe_ea_info(struct inode *ino, int flags,
         int rc = 0;
         ENTRY;
 
-        lsm = lli->lli_smd;
-        if (lsm) {
+        if (lli->lli_smd) {
                 CDEBUG(D_IOCTL, "stripe already exists for ino "DFID"\n",
                        PFID(&lli->lli_fid));
                 return -EEXIST;
         }
 
-        OBD_ALLOC(lli2, sizeof(struct llu_inode_info));
-        if (!lli2)
-                return -ENOMEM;
-
-        memcpy(lli2, lli, sizeof(struct llu_inode_info));
-        lli2->lli_open_count = 0;
-        lli2->lli_it = NULL;
-        lli2->lli_file_data = NULL;
-        lli2->lli_smd = NULL;
-        lli2->lli_symlink_name = NULL;
-        ino->i_private = lli2;
-
         llu_prep_md_op_data(&data, NULL, ino, NULL, 0, O_RDWR,
                             LUSTRE_OPC_ANY);
-
         rc = md_enqueue(sbi->ll_md_exp, &einfo, &oit, &data,
                         &lockh, lum, lum_size, NULL, LDLM_FL_INTENT_ONLY);
         if (rc)
@@ -1770,28 +1759,20 @@ static int llu_lov_setstripe_ea_info(struct inode *ino, int flags,
         if (rc)
                 GOTO(out, rc);
 
-        lli->lli_smd = lli2->lli_smd;
-        lli2->lli_smd = NULL;
-
-        llu_local_open(lli2, &oit);
-
+        llu_update_inode(ino, &md);
+        llu_local_open(lli, &oit);
         /* release intent */
         if (lustre_handle_is_used(&lockh))
                 ldlm_lock_decref(&lockh, LCK_CR);
-
         ptlrpc_req_finished(req);
         req = NULL;
-
         rc = llu_file_release(ino);
- out:
-        ino->i_private = lli;
-        if (!rc)
-                llu_update_inode(ino, &md);
-        if (lli2)
-                OBD_FREE(lli2, sizeof(struct llu_inode_info));
+        EXIT;
+
+out:
         if (req != NULL)
                 ptlrpc_req_finished(req);
-        RETURN(rc);
+        return rc;
 }
 
 static int llu_lov_file_setstripe(struct inode *ino, unsigned long arg)
@@ -1803,7 +1784,7 @@ static int llu_lov_file_setstripe(struct inode *ino, unsigned long arg)
 
         LASSERT(sizeof(lum) == sizeof(*lump));
         LASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lump->lmm_objects[0]));
-        if (copy_from_user(&lum, lump, sizeof(lum)))
+        if (cfs_copy_from_user(&lum, lump, sizeof(lum)))
                 RETURN(-EFAULT);
 
         rc = llu_lov_setstripe_ea_info(ino, flags, &lum, sizeof(lum));
@@ -1923,39 +1904,6 @@ struct inode *llu_iget(struct filesys *fs, struct lustre_md *md)
 }
 
 static int
-llu_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp)
-{
-        /* even if default lov is LOV_MAGIC_V1 we use LOV_MAGIC_V3
-         * to be sure buffer are large enough */
-        struct lov_stripe_md lsm = { .lsm_magic = LOV_MAGIC_V3 };
-        __u32 valsize = sizeof(struct lov_desc);
-        int rc, easize, def_easize, cookiesize;
-        struct lov_desc desc;
-        __u32 stripes;
-        ENTRY;
-
-        rc = obd_get_info(dt_exp, sizeof(KEY_LOVDESC), KEY_LOVDESC,
-                          &valsize, &desc, NULL);
-        if (rc)
-                RETURN(rc);
-
-        stripes = min(desc.ld_tgt_count, (__u32)LOV_MAX_STRIPE_COUNT);
-        lsm.lsm_stripe_count = stripes;
-        easize = obd_size_diskmd(dt_exp, &lsm);
-
-        lsm.lsm_stripe_count = desc.ld_default_stripe_count;
-        def_easize = obd_size_diskmd(dt_exp, &lsm);
-
-        cookiesize = stripes * sizeof(struct llog_cookie);
-
-        CDEBUG(D_HA, "updating max_mdsize/max_cookiesize: %d/%d\n",
-               easize, cookiesize);
-
-        rc = md_init_ea_size(md_exp, easize, def_easize, cookiesize);
-        RETURN(rc);
-}
-
-static int
 llu_fsswop_mount(const char *source,
                  unsigned flags,
                  const void *data __IS_UNUSED,
@@ -1970,8 +1918,6 @@ llu_fsswop_mount(const char *source,
         struct obd_statfs osfs;
         static struct qstr noname = { NULL, 0, 0 };
         struct ptlrpc_request *request = NULL;
-        struct lustre_handle md_conn = {0, };
-        struct lustre_handle dt_conn = {0, };
         struct lustre_md md;
         class_uuid_t uuid;
         struct config_llog_instance cfg = {0, };
@@ -1981,6 +1927,7 @@ llu_fsswop_mount(const char *source,
         char *osc = NULL, *mdc = NULL;
         int async = 1, err = -EINVAL;
         struct obd_connect_data ocd = {0,};
+        struct md_op_data op_data = {{0}};
 
         ENTRY;
 
@@ -2051,7 +1998,8 @@ llu_fsswop_mount(const char *source,
                            sizeof(async), &async, NULL);
 
         ocd.ocd_connect_flags = OBD_CONNECT_IBITS | OBD_CONNECT_VERSION |
-                                OBD_CONNECT_FID | OBD_CONNECT_AT;
+                                OBD_CONNECT_FID | OBD_CONNECT_AT |
+                                OBD_CONNECT_VBR | OBD_CONNECT_SOM;
 #ifdef LIBLUSTRE_POSIX_ACL
         ocd.ocd_connect_flags |= OBD_CONNECT_ACL;
 #endif
@@ -2059,12 +2007,11 @@ llu_fsswop_mount(const char *source,
         ocd.ocd_version = LUSTRE_VERSION_CODE;
 
         /* setup mdc */
-        err = obd_connect(NULL, &md_conn, obd, &sbi->ll_sb_uuid, &ocd, NULL);
+        err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, &ocd, NULL);
         if (err) {
                 CERROR("cannot connect to %s: rc = %d\n", mdc, err);
                 GOTO(out_free, err);
         }
-        sbi->ll_md_exp = class_conn2export(&md_conn);
 
         err = obd_statfs(obd, &osfs, 100000000, 0);
         if (err)
@@ -2084,26 +2031,22 @@ llu_fsswop_mount(const char *source,
                            sizeof(async), &async, NULL);
 
         obd->obd_upcall.onu_owner = &sbi->ll_lco;
-        obd->obd_upcall.onu_upcall = ll_ocd_update;
+        obd->obd_upcall.onu_upcall = cl_ocd_update;
 
         ocd.ocd_connect_flags = OBD_CONNECT_SRVLOCK | OBD_CONNECT_REQPORTAL |
                                 OBD_CONNECT_VERSION | OBD_CONNECT_TRUNCLOCK |
-                                OBD_CONNECT_FID | OBD_CONNECT_AT;
+                                OBD_CONNECT_FID | OBD_CONNECT_AT |
+                                OBD_CONNECT_SOM;
+
         ocd.ocd_version = LUSTRE_VERSION_CODE;
-        err = obd_connect(NULL, &dt_conn, obd, &sbi->ll_sb_uuid, &ocd, NULL);
+        err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, &ocd, NULL);
         if (err) {
                 CERROR("cannot connect to %s: rc = %d\n", osc, err);
                 GOTO(out_md, err);
         }
-        sbi->ll_dt_exp = class_conn2export(&dt_conn);
         sbi->ll_lco.lco_flags = ocd.ocd_connect_flags;
-
-        if (err) {
-                CERROR("cannot register lock cancel callback: rc = %d\n", err);
-                GOTO(out_dt, err);
-        }
-
-        llu_init_ea_size(sbi->ll_md_exp, sbi->ll_dt_exp);
+        sbi->ll_lco.lco_md_exp = sbi->ll_md_exp;
+        sbi->ll_lco.lco_dt_exp = sbi->ll_dt_exp;
 
         fid_zero(&sbi->ll_root_fid);
         err = md_getstatus(sbi->ll_md_exp, &sbi->ll_root_fid, NULL);
@@ -2117,9 +2060,10 @@ llu_fsswop_mount(const char *source,
         }
         CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&sbi->ll_root_fid));
 
+        op_data.op_fid1 = sbi->ll_root_fid;
+        op_data.op_valid = OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS;
         /* fetch attr of root inode */
-        err = md_getattr(sbi->ll_md_exp, &sbi->ll_root_fid, NULL,
-                         OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS, 0, &request);
+        err = md_getattr(sbi->ll_md_exp, &op_data, &request);
         if (err) {
                 CERROR("md_getattr failed for root: rc = %d\n", err);
                 GOTO(out_lock_cn_cb, err);
@@ -2169,7 +2113,6 @@ out_inode:
 out_request:
         ptlrpc_req_finished(request);
 out_lock_cn_cb:
-out_dt:
         obd_disconnect(sbi->ll_dt_exp);
 out_md:
         obd_disconnect(sbi->ll_md_exp);