Whamcloud - gitweb
LU-3382 build: clean unused link dependencies
[fs/lustre-release.git] / lustre / liblustre / super.c
index 916e4c8..9980b95 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,6 +26,8 @@
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <time.h>
-#include <sys/types.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
 #include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/queue.h>
-#ifndef __CYGWIN__
-# include <sys/statvfs.h>
-#else
-# include <sys/statfs.h>
-#endif
-
+#include <sys/types.h>
+#include <libcfs/libcfs.h>
+#include <lustre/lustre_idl.h>
+#include <liblustre.h>
+#include <lclient.h>
+#include <lustre_dlm.h>
+#include <lustre_export.h>
+#include <lustre_lite.h>
+#include <lustre_mdc.h>
+#include <lustre_net.h>
+#include <lustre_req_layout.h>
+#include <lustre_ver.h>
+#include <obd.h>
+#include <obd_class.h>
+#include <obd_support.h>
 #include "llite_lib.h"
 
 #ifndef MAY_EXEC
@@ -69,10 +83,10 @@ static int ll_permission(struct inode *inode, int mask)
         struct intnl_stat *st = llu_i2stat(inode);
         mode_t mode = st->st_mode;
 
-        if (current->fsuid == st->st_uid)
-                mode >>= 6;
-        else if (cfs_curproc_is_in_groups(st->st_gid))
-                mode >>= 3;
+       if (current->fsuid == st->st_uid)
+               mode >>= 6;
+       else if (in_group_p(st->st_gid))
+               mode >>= 3;
 
         if ((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask)
                 return 0;
@@ -120,7 +134,7 @@ static ldlm_mode_t llu_take_md_lock(struct inode *inode, __u64 bits,
         ldlm_policy_data_t policy = { .l_inodebits = {bits}};
         struct lu_fid *fid;
         ldlm_mode_t rc;
-        int flags;
+       __u64 flags;
         ENTRY;
 
         fid = &llu_i2info(inode)->lli_fid;
@@ -147,19 +161,15 @@ void llu_update_inode(struct inode *inode, struct lustre_md *md)
                 st->st_mode = (st->st_mode & ~S_IFMT)|(body->mode & S_IFMT);
 
         if (lsm != NULL) {
-                if (lli->lli_smd == NULL) {
-                        cl_inode_init(inode, md);
-                        lli->lli_smd = lsm;
-                        lli->lli_maxbytes = lsm->lsm_maxbytes;
-                        if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
-                                lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
-                } else {
-                        if (lov_stripe_md_cmp(lli->lli_smd, lsm)) {
-                                CERROR("lsm mismatch for inode %lld\n",
-                                       (long long)st->st_ino);
-                                LBUG();
-                        }
-                }
+               if (!lli->lli_has_smd) {
+                       cl_file_inode_init(inode, md);
+                       lli->lli_has_smd = true;
+                       lli->lli_maxbytes = lsm->lsm_maxbytes;
+                       if (lli->lli_maxbytes > MAX_LFS_FILESIZE)
+                               lli->lli_maxbytes = MAX_LFS_FILESIZE;
+               }
+               if (md->lsm != NULL)
+                       obd_free_memmd(llu_i2obdexp(inode), &md->lsm);
         }
 
         if (body->valid & OBD_MD_FLATIME) {
@@ -193,7 +203,7 @@ void llu_update_inode(struct inode *inode, struct lustre_md *md)
                 lli->lli_st_flags = body->flags;
         if (body->valid & OBD_MD_FLSIZE) {
                 if ((llu_i2sbi(inode)->ll_lco.lco_flags & OBD_CONNECT_SOM) &&
-                    S_ISREG(st->st_mode) && lli->lli_smd) {
+                   S_ISREG(st->st_mode) && lli->lli_has_smd) {
                         struct lustre_handle lockh;
                         ldlm_mode_t mode;
 
@@ -217,49 +227,6 @@ void llu_update_inode(struct inode *inode, struct lustre_md *md)
         }
 }
 
-void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid)
-{
-        struct llu_inode_info *lli = llu_i2info(dst);
-        struct intnl_stat *st = llu_i2stat(dst);
-
-        valid &= src->o_valid;
-
-        LASSERTF(!(valid & (OBD_MD_FLTYPE | OBD_MD_FLGENER | OBD_MD_FLFID |
-                            OBD_MD_FLID | OBD_MD_FLGROUP)),
-                 "object "LPU64"/"LPU64", valid %x\n",
-                 src->o_id, src->o_seq, valid);
-
-        if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
-                CDEBUG(D_INODE,"valid "LPX64", cur time "CFS_TIME_T"/"CFS_TIME_T
-                       ", new %lu/%lu\n",
-                       src->o_valid,
-                       LTIME_S(st->st_mtime), LTIME_S(st->st_ctime),
-                       (long)src->o_mtime, (long)src->o_ctime);
-
-        if (valid & OBD_MD_FLATIME)
-                LTIME_S(st->st_atime) = src->o_atime;
-        if (valid & OBD_MD_FLMTIME)
-                LTIME_S(st->st_mtime) = src->o_mtime;
-        if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(st->st_ctime))
-                LTIME_S(st->st_ctime) = src->o_ctime;
-        if (valid & OBD_MD_FLSIZE)
-                st->st_size = src->o_size;
-        if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
-                st->st_blocks = src->o_blocks;
-        if (valid & OBD_MD_FLBLKSZ)
-                st->st_blksize = src->o_blksize;
-        if (valid & OBD_MD_FLTYPE)
-                st->st_mode = (st->st_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
-        if (valid & OBD_MD_FLMODE)
-                st->st_mode = (st->st_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
-        if (valid & OBD_MD_FLUID)
-                st->st_uid = src->o_uid;
-        if (valid & OBD_MD_FLGID)
-                st->st_gid = src->o_gid;
-        if (valid & OBD_MD_FLFLAGS)
-                lli->lli_st_flags = src->o_flags;
-}
-
 /**
  * Performs the getattr on the inode and updates its fields.
  * If @sync != 0, perform the getattr under the server-side lock.
@@ -267,19 +234,18 @@ void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid)
 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;
-        struct lov_stripe_md *lsm = lli->lli_smd;
-        struct obd_info oinfo = { { { 0 } } };
-        int rc;
-        ENTRY;
+       struct ptlrpc_request_set *set;
+       struct lov_stripe_md *lsm = NULL;
+       struct obd_info oinfo = { { { 0 } } };
+       int rc;
+       ENTRY;
 
+       lsm = ccc_inode_lsm_get(inode);
         LASSERT(lsm);
 
         oinfo.oi_md = lsm;
         oinfo.oi_oa = obdo;
-        oinfo.oi_oa->o_id = lsm->lsm_object_id;
-        oinfo.oi_oa->o_seq = lsm->lsm_object_seq;
+       oinfo.oi_oa->o_oi = lsm->lsm_oi;
         oinfo.oi_oa->o_mode = S_IFREG;
         oinfo.oi_oa->o_ioepoch = ioepoch;
         oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE |
@@ -287,7 +253,7 @@ int llu_inode_getattr(struct inode *inode, struct obdo *obdo,
                                OBD_MD_FLBLKSZ | OBD_MD_FLMTIME |
                                OBD_MD_FLCTIME | OBD_MD_FLGROUP |
                                OBD_MD_FLATIME | OBD_MD_FLEPOCH;
-        obdo_from_inode(oinfo.oi_oa, NULL, &llu_i2info(inode)->lli_fid, 0);
+        obdo_set_parent_fid(oinfo.oi_oa, &llu_i2info(inode)->lli_fid);
         if (sync) {
                 oinfo.oi_oa->o_valid |= OBD_MD_FLFLAGS;
                 oinfo.oi_oa->o_flags |= OBD_FL_SRVLOCK;
@@ -303,6 +269,7 @@ int llu_inode_getattr(struct inode *inode, struct obdo *obdo,
                         rc = ptlrpc_set_wait(set);
                 ptlrpc_set_destroy(set);
         }
+       ccc_inode_lsm_put(inode, lsm);
         if (rc)
                 RETURN(rc);
 
@@ -310,13 +277,13 @@ int llu_inode_getattr(struct inode *inode, struct obdo *obdo,
                                OBD_MD_FLMTIME | OBD_MD_FLCTIME |
                                OBD_MD_FLSIZE;
 
-        obdo_refresh_inode(inode, oinfo.oi_oa, oinfo.oi_oa->o_valid);
-        CDEBUG(D_INODE, "objid "LPX64" size %Lu, blocks %Lu, "
-               "blksize %Lu\n", lli->lli_smd->lsm_object_id,
-               (long long unsigned)llu_i2stat(inode)->st_size,
-               (long long unsigned)llu_i2stat(inode)->st_blocks,
-               (long long unsigned)llu_i2stat(inode)->st_blksize);
-        RETURN(0);
+       obdo_refresh_inode(inode, oinfo.oi_oa, oinfo.oi_oa->o_valid);
+       CDEBUG(D_INODE, "objid "DOSTID" size %llu, blocks %llu, "
+              "blksize %llu\n", POSTID(&oinfo.oi_oa->o_oi),
+              (long long unsigned)llu_i2stat(inode)->st_size,
+              (long long unsigned)llu_i2stat(inode)->st_blocks,
+              (long long unsigned)llu_i2stat(inode)->st_blksize);
+       RETURN(0);
 }
 
 static struct inode* llu_new_inode(struct filesys *fs,
@@ -346,7 +313,7 @@ static struct inode* llu_new_inode(struct filesys *fs,
 
         /* initialize lli here */
         lli->lli_sbi = llu_fs2sbi(fs);
-        lli->lli_smd = NULL;
+       lli->lli_has_smd = false;
         lli->lli_symlink_name = NULL;
         lli->lli_flags = 0;
         lli->lli_maxbytes = (__u64)(~0UL);
@@ -371,7 +338,7 @@ static int llu_have_md_lock(struct inode *inode, __u64 lockpart)
         struct lustre_handle lockh;
         ldlm_policy_data_t policy = { .l_inodebits = { lockpart } };
         struct lu_fid *fid;
-        int flags;
+       __u64 flags;
         ENTRY;
 
         LASSERT(inode);
@@ -393,11 +360,6 @@ static int llu_inode_revalidate(struct inode *inode)
         struct intnl_stat *st = llu_i2stat(inode);
         ENTRY;
 
-        if (!inode) {
-                CERROR("REPORT THIS LINE TO PETER\n");
-                RETURN(0);
-        }
-
         if (!llu_have_md_lock(inode, MDS_INODELOCK_UPDATE)) {
                 struct lustre_md md;
                 struct ptlrpc_request *req = NULL;
@@ -442,12 +404,12 @@ static int llu_inode_revalidate(struct inode *inode)
 
 
                 llu_update_inode(inode, &md);
-                if (md.lsm != NULL && lli->lli_smd != md.lsm)
-                        obd_free_memmd(sbi->ll_dt_exp, &md.lsm);
-                ptlrpc_req_finished(req);
-        }
+               if (md.lsm != NULL)
+                       obd_free_memmd(sbi->ll_dt_exp, &md.lsm);
+               ptlrpc_req_finished(req);
+       }
 
-        if (!lli->lli_smd) {
+       if (!lli->lli_has_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;
@@ -507,10 +469,11 @@ static int null_if_equal(struct ldlm_lock *lock, void *data)
         return LDLM_ITER_CONTINUE;
 }
 
-void llu_clear_inode(struct inode *inode)
+static void llu_clear_inode(struct inode *inode)
 {
-        struct llu_inode_info *lli = llu_i2info(inode);
-        struct llu_sb_info *sbi = llu_i2sbi(inode);
+       struct llu_inode_info *lli = llu_i2info(inode);
+       struct llu_sb_info *sbi = llu_i2sbi(inode);
+       struct lov_stripe_md *lsm;
         ENTRY;
 
         CDEBUG(D_VFSTRACE, "VFS Op:inode=%llu/%lu(%p)\n",
@@ -518,19 +481,15 @@ void llu_clear_inode(struct inode *inode)
                inode);
 
         lli->lli_flags &= ~LLIF_MDS_SIZE_LOCK;
-        md_change_cbdata(sbi->ll_md_exp, ll_inode2fid(inode),
-                         null_if_equal, inode);
+       md_null_inode(sbi->ll_md_exp, ll_inode2fid(inode));
 
-        if (lli->lli_smd)
-                obd_change_cbdata(sbi->ll_dt_exp, lli->lli_smd,
-                                  null_if_equal, inode);
+       lsm = ccc_inode_lsm_get(inode);
+       if (lsm != NULL)
+               obd_change_cbdata(sbi->ll_dt_exp, lsm, null_if_equal, inode);
+       ccc_inode_lsm_put(inode, lsm);
 
-        cl_inode_fini(inode);
-
-        if (lli->lli_smd) {
-                obd_free_memmd(sbi->ll_dt_exp, &lli->lli_smd);
-                lli->lli_smd = NULL;
-        }
+       cl_inode_fini(inode);
+       lli->lli_has_smd = false;
 
         if (lli->lli_symlink_name) {
                 OBD_FREE(lli->lli_symlink_name,
@@ -541,7 +500,7 @@ void llu_clear_inode(struct inode *inode)
         EXIT;
 }
 
-void llu_iop_gone(struct inode *inode)
+static void llu_iop_gone(struct inode *inode)
 {
         struct llu_inode_info *lli = llu_i2info(inode);
         ENTRY;
@@ -563,7 +522,7 @@ static int inode_setattr(struct inode * inode, struct iattr * attr)
          * inode_setattr() is only ever invoked with ATTR_SIZE (by
          * llu_setattr_raw()) when file has no bodies. Check this.
          */
-        LASSERT(ergo(ia_valid & ATTR_SIZE, llu_i2info(inode)->lli_smd == NULL));
+       LASSERT(ergo(ia_valid & ATTR_SIZE, !llu_i2info(inode)->lli_has_smd));
 
         if (ia_valid & ATTR_SIZE)
                 st->st_size = attr->ia_size;
@@ -577,12 +536,12 @@ static int inode_setattr(struct inode * inode, struct iattr * attr)
                 st->st_mtime = attr->ia_mtime;
         if (ia_valid & ATTR_CTIME)
                 st->st_ctime = attr->ia_ctime;
-        if (ia_valid & ATTR_MODE) {
-                st->st_mode = attr->ia_mode;
-                if (!cfs_curproc_is_in_groups(st->st_gid) &&
-                    !cfs_capable(CFS_CAP_FSETID))
-                        st->st_mode &= ~S_ISGID;
-        }
+       if (ia_valid & ATTR_MODE) {
+               st->st_mode = attr->ia_mode;
+               if (!in_group_p(st->st_gid) &&
+                   !cfs_capable(CFS_CAP_FSETID))
+                       st->st_mode &= ~S_ISGID;
+       }
         /* mark_inode_dirty(inode); */
         return error;
 }
@@ -675,7 +634,7 @@ static int llu_setattr_done_writing(struct inode *inode,
  */
 int llu_setattr_raw(struct inode *inode, struct iattr *attr)
 {
-        struct lov_stripe_md *lsm = llu_i2info(inode)->lli_smd;
+       int has_lsm = llu_i2info(inode)->lli_has_smd;
         struct intnl_stat *st = llu_i2stat(inode);
         int ia_valid = attr->ia_valid;
         struct md_op_data op_data = { { 0 } };
@@ -713,18 +672,18 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
         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(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. */
-        if (lsm)
-                attr->ia_valid &= ~ATTR_SIZE;
-
-        /* If only OST attributes being set on objects, don't do MDS RPC.
-         * In that case, we need to check permissions and update the local
-         * inode ourselves so we can call obdo_from_inode() always. */
-        if (ia_valid & (lsm ? ~(ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
+                      LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
+                      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. */
+       if (has_lsm)
+               attr->ia_valid &= ~ATTR_SIZE;
+
+       /* If only OST attributes being set on objects, don't do MDS RPC.
+        * In that case, we need to check permissions and update the local
+        * inode ourselves so we can call obdo_from_inode() always. */
+       if (ia_valid & (has_lsm ? ~(ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
                 memcpy(&op_data.op_attr, attr, sizeof(*attr));
 
                 /* Open epoch for truncate. */
@@ -736,7 +695,7 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
                         RETURN(rc);
 
                 llu_ioepoch_open(llu_i2info(inode), op_data.op_ioepoch);
-                if (!lsm || !S_ISREG(st->st_mode)) {
+               if (!has_lsm || !S_ISREG(st->st_mode)) {
                         CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n");
                         GOTO(out, rc);
                 }
@@ -767,9 +726,9 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
 
         if (ia_valid & ATTR_SIZE)
                 attr->ia_valid |= ATTR_SIZE;
-        if ((ia_valid & ATTR_SIZE) ||
-            (ia_valid | ATTR_ATIME | ATTR_ATIME_SET) ||
-            (ia_valid | ATTR_MTIME | ATTR_MTIME_SET))
+        if (ia_valid & (ATTR_SIZE |
+                        ATTR_ATIME | ATTR_ATIME_SET |
+                        ATTR_MTIME | ATTR_MTIME_SET))
                 /* on truncate and utimes send attributes to osts, setting
                  * mtime/atime to past will be performed under PW 0:EOF extent
                  * lock (new_size:EOF for truncate)
@@ -1095,7 +1054,7 @@ static int llu_statfs_internal(struct llu_sb_info *sbi,
         int rc;
         ENTRY;
 
-        rc = obd_statfs(class_exp2obd(sbi->ll_md_exp), osfs, max_age, 0);
+        rc = obd_statfs(NULL, sbi->ll_md_exp, osfs, max_age, 0);
         if (rc) {
                 CERROR("md_statfs fails: rc = %d\n", rc);
                 RETURN(rc);
@@ -1268,20 +1227,23 @@ static int llu_file_flock(struct inode *ino,
                           int cmd,
                           struct file_lock *file_lock)
 {
-        struct llu_inode_info *lli = llu_i2info(ino);
-        struct intnl_stat *st = llu_i2stat(ino);
-        struct ldlm_res_id res_id =
-                { .name = {fid_seq(&lli->lli_fid),
-                           fid_oid(&lli->lli_fid),
-                           fid_ver(&lli->lli_fid),
-                           LDLM_FLOCK} };
-        struct ldlm_enqueue_info einfo = { LDLM_FLOCK, 0, NULL,
-                ldlm_flock_completion_ast, NULL, NULL, file_lock };
-
-        struct lustre_handle lockh = {0};
-        ldlm_policy_data_t flock;
-        int flags = 0;
-        int rc;
+       struct llu_inode_info *lli = llu_i2info(ino);
+       struct ldlm_res_id res_id =
+               { .name = {fid_seq(&lli->lli_fid),
+                          fid_oid(&lli->lli_fid),
+                          fid_ver(&lli->lli_fid),
+                          LDLM_FLOCK} };
+       struct ldlm_enqueue_info einfo = {
+               .ei_type        = LDLM_FLOCK,
+               .ei_mode        = 0,
+               .ei_cb_cp       = ldlm_flock_completion_ast,
+               .ei_cbdata      = file_lock,
+       };
+       struct intnl_stat     *st  = llu_i2stat(ino);
+       struct lustre_handle lockh = {0};
+       ldlm_policy_data_t flock;
+       __u64 flags = 0;
+       int rc;
 
         CDEBUG(D_VFSTRACE, "VFS Op:inode=%llu file_lock=%p\n",
                (unsigned long long)st->st_ino, file_lock);
@@ -1336,11 +1298,11 @@ static int llu_file_flock(struct inode *ino,
                 LBUG();
         }
 
-        CDEBUG(D_DLMTRACE, "inode=%llu, pid=%u, cmd=%d, flags=%#x, mode=%u, "
-               "start="LPX64", end="LPX64"\n", (unsigned long long)st->st_ino,
-               flock.l_flock.pid, cmd, flags, einfo.ei_mode, flock.l_flock.start,
-               flock.l_flock.end);
-
+       CDEBUG(D_DLMTRACE, "inode=%llu, pid=%u, cmd=%d, flags="LPX64", "
+              "mode=%u, start="LPX64", end="LPX64"\n",
+              (unsigned long long)st->st_ino,
+              flock.l_flock.pid, cmd, flags, einfo.ei_mode,
+              flock.l_flock.start, flock.l_flock.end);
         {
                 struct lmv_obd *lmv;
                 struct obd_device *lmv_obd;
@@ -1350,11 +1312,12 @@ static int llu_file_flock(struct inode *ino,
                 if (lmv->desc.ld_tgt_count < 1)
                         RETURN(rc = -ENODEV);
 
-                if (lmv->tgts[0].ltd_exp != NULL)
-                        rc = ldlm_cli_enqueue(lmv->tgts[0].ltd_exp, NULL, &einfo, &res_id,
-                                              &flock, &flags, NULL, 0, &lockh, 0);
-                else
-                        rc = -ENODEV;
+               if (lmv->tgts[0] != NULL && lmv->tgts[0]->ltd_exp != NULL)
+                       rc = ldlm_cli_enqueue(lmv->tgts[0]->ltd_exp, NULL,
+                                             &einfo, &res_id, &flock, &flags,
+                                             NULL, 0, LVB_T_NONE, &lockh, 0);
+               else
+                       rc = -ENODEV;
         }
         RETURN(rc);
 }
@@ -1604,7 +1567,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 (cfs_copy_from_user(&lum, lump, sizeof(lum)))
+       if (copy_from_user(&lum, lump, sizeof(lum)))
                 return(-EFAULT);
 
         switch (lum.lmm_magic) {
@@ -1642,30 +1605,34 @@ static int llu_lov_dir_setstripe(struct inode *ino, unsigned long arg)
 }
 
 static int llu_lov_setstripe_ea_info(struct inode *ino, int flags,
-                                     struct lov_user_md *lum, int lum_size)
+                                    struct lov_user_md *lum, int lum_size)
 {
-        struct llu_sb_info *sbi = llu_i2sbi(ino);
-        struct llu_inode_info *lli = llu_i2info(ino);
-        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 }};
-        struct lustre_handle lockh;
-        int rc = 0;
-        ENTRY;
-
-        if (lli->lli_smd) {
-                CDEBUG(D_IOCTL, "stripe already exists for ino "DFID"\n",
-                       PFID(&lli->lli_fid));
-                return -EEXIST;
-        }
+       struct llu_sb_info *sbi = llu_i2sbi(ino);
+       struct llu_inode_info *lli = llu_i2info(ino);
+       struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags};
+       struct ldlm_enqueue_info einfo = {
+               .ei_type        = LDLM_IBITS,
+               .ei_mode        = LCK_CR,
+               .ei_cb_bl       = llu_md_blocking_ast,
+               .ei_cb_cp       = ldlm_completion_ast,
+       };
+       struct ptlrpc_request *req = NULL;
+       struct lustre_md md;
+       struct md_op_data data = {{ 0 }};
+       struct lustre_handle lockh;
+       int rc = 0;
+       ENTRY;
+
+       if (lli->lli_has_smd) {
+               CDEBUG(D_IOCTL, "stripe already exists for ino "DFID"\n",
+                      PFID(&lli->lli_fid));
+               return -EEXIST;
+       }
 
         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);
+       rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL, &oit, &data, &lockh,
+                       LDLM_FL_INTENT_ONLY);
         if (rc)
                 GOTO(out, rc);
 
@@ -1712,7 +1679,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 (cfs_copy_from_user(&lum, lump, sizeof(lum)))
+       if (copy_from_user(&lum, lump, sizeof(lum)))
                 RETURN(-EFAULT);
 
         rc = llu_lov_setstripe_ea_info(ino, flags, &lum, sizeof(lum));
@@ -1732,13 +1699,15 @@ static int llu_lov_setstripe(struct inode *ino, unsigned long arg)
 
 static int llu_lov_getstripe(struct inode *ino, unsigned long arg)
 {
-        struct lov_stripe_md *lsm = llu_i2info(ino)->lli_smd;
-
-        if (!lsm)
-                RETURN(-ENODATA);
-
-        return obd_iocontrol(LL_IOC_LOV_GETSTRIPE, llu_i2obdexp(ino), 0, lsm,
-                            (void *)arg);
+       struct lov_stripe_md *lsm = NULL;
+       int rc = -ENODATA;
+
+       lsm = ccc_inode_lsm_get(ino);
+       if (lsm != NULL)
+               rc = obd_iocontrol(LL_IOC_LOV_GETSTRIPE, llu_i2obdexp(ino), 0, lsm,
+                                  (void *)arg);
+       ccc_inode_lsm_put(ino, lsm);
+       return rc;
 }
 
 static int llu_iop_ioctl(struct inode *ino, unsigned long int request,
@@ -1791,9 +1760,8 @@ static int llu_iop_datasync(struct inode *inode)
         return 0;
 }
 
-struct filesys_ops llu_filesys_ops =
-{
-        fsop_gone: llu_fsop_gone,
+static struct filesys_ops llu_filesys_ops = {
+       .fsop_gone      = llu_fsop_gone,
 };
 
 struct inode *llu_iget(struct filesys *fs, struct lustre_md *md)
@@ -1849,13 +1817,14 @@ llu_fsswop_mount(const char *source,
         struct lustre_md md;
         class_uuid_t uuid;
         struct config_llog_instance cfg = {0, };
-        char ll_instance[sizeof(sbi) * 2 + 3];
         struct lustre_profile *lprof;
         char *zconf_mgsnid, *zconf_profile;
         char *osc = NULL, *mdc = NULL;
         int async = 1, err = -EINVAL;
         struct obd_connect_data ocd = {0,};
         struct md_op_data op_data = {{0}};
+        /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */
+        const int instlen = sizeof(cfg.cfg_instance) * 2 + 2;
 
         ENTRY;
 
@@ -1880,10 +1849,9 @@ llu_fsswop_mount(const char *source,
 
         /* generate a string unique to this super, let's try
          the address of the super itself.*/
-        snprintf(ll_instance, sizeof(ll_instance), "%p", sbi);
+        cfg.cfg_instance = sbi;
 
         /* retrive & parse config log */
-        cfg.cfg_instance = ll_instance;
         cfg.cfg_uuid = sbi->ll_sb_uuid;
         err = liblustre_process_log(&cfg, zconf_mgsnid, zconf_profile, 1);
         if (err < 0) {
@@ -1896,11 +1864,11 @@ llu_fsswop_mount(const char *source,
                 CERROR("No profile found: %s\n", zconf_profile);
                 GOTO(out_free, err = -EINVAL);
         }
-        OBD_ALLOC(osc, strlen(lprof->lp_dt) + strlen(ll_instance) + 2);
-        sprintf(osc, "%s-%s", lprof->lp_dt, ll_instance);
+        OBD_ALLOC(osc, strlen(lprof->lp_dt) + instlen + 2);
+        sprintf(osc, "%s-%p", lprof->lp_dt, cfg.cfg_instance);
 
-        OBD_ALLOC(mdc, strlen(lprof->lp_md) + strlen(ll_instance) + 2);
-        sprintf(mdc, "%s-%s", lprof->lp_md, ll_instance);
+        OBD_ALLOC(mdc, strlen(lprof->lp_md) + instlen + 2);
+        sprintf(mdc, "%s-%p", lprof->lp_md, cfg.cfg_instance);
 
         if (!osc) {
                 CERROR("no osc\n");
@@ -1922,12 +1890,13 @@ llu_fsswop_mount(const char *source,
                 CERROR("MDC %s: not setup or attached\n", mdc);
                 GOTO(out_free, err = -EINVAL);
         }
-        obd_set_info_async(obd->obd_self_export, sizeof(KEY_ASYNC), KEY_ASYNC,
-                           sizeof(async), &async, NULL);
+        obd_set_info_async(NULL, obd->obd_self_export, sizeof(KEY_ASYNC),
+                           KEY_ASYNC, sizeof(async), &async, NULL);
 
         ocd.ocd_connect_flags = OBD_CONNECT_IBITS | OBD_CONNECT_VERSION |
                                 OBD_CONNECT_FID | OBD_CONNECT_AT |
-                                OBD_CONNECT_VBR | OBD_CONNECT_FULL20;
+                               OBD_CONNECT_VBR | OBD_CONNECT_FULL20 |
+                               OBD_CONNECT_LVB_TYPE;
 
 #ifdef LIBLUSTRE_POSIX_ACL
         ocd.ocd_connect_flags |= OBD_CONNECT_ACL;
@@ -1942,7 +1911,7 @@ llu_fsswop_mount(const char *source,
                 GOTO(out_free, err);
         }
 
-        err = obd_statfs(obd, &osfs, 100000000, 0);
+        err = obd_statfs(NULL, sbi->ll_md_exp, &osfs, 100000000, 0);
         if (err)
                 GOTO(out_md, err);
 
@@ -1956,8 +1925,8 @@ llu_fsswop_mount(const char *source,
                 CERROR("OSC %s: not setup or attached\n", osc);
                 GOTO(out_md, err = -EINVAL);
         }
-        obd_set_info_async(obd->obd_self_export, sizeof(KEY_ASYNC), KEY_ASYNC,
-                           sizeof(async), &async, NULL);
+        obd_set_info_async(NULL, obd->obd_self_export, sizeof(KEY_ASYNC),
+                           KEY_ASYNC, sizeof(async), &async, NULL);
 
         obd->obd_upcall.onu_owner = &sbi->ll_lco;
         obd->obd_upcall.onu_upcall = cl_ocd_update;
@@ -1965,7 +1934,8 @@ llu_fsswop_mount(const char *source,
         ocd.ocd_connect_flags = OBD_CONNECT_SRVLOCK | OBD_CONNECT_REQPORTAL |
                                 OBD_CONNECT_VERSION | OBD_CONNECT_TRUNCLOCK |
                                 OBD_CONNECT_FID | OBD_CONNECT_AT |
-                                OBD_CONNECT_FULL20;
+                               OBD_CONNECT_FULL20 | OBD_CONNECT_EINPROGRESS |
+                               OBD_CONNECT_LVB_TYPE;
 
         ocd.ocd_version = LUSTRE_VERSION_CODE;
         err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, &ocd, NULL);
@@ -2033,9 +2003,8 @@ llu_fsswop_mount(const char *source,
         ptlrpc_req_finished(request);
 
         CDEBUG(D_SUPER, "LibLustre: %s mounted successfully!\n", source);
-        liblustre_wait_idle();
-
-        return 0;
+        err = 0;
+        goto out_free;
 
 out_inode:
         _sysio_i_gone(root);
@@ -2047,43 +2016,44 @@ out_md:
         obd_disconnect(sbi->ll_md_exp);
 out_free:
         if (osc)
-                OBD_FREE(osc, strlen(osc) + 1);
+                OBD_FREE(osc, strlen(lprof->lp_dt) + instlen + 2);
         if (mdc)
-                OBD_FREE(mdc, strlen(mdc) + 1);
-        OBD_FREE(sbi, sizeof(*sbi));
+                OBD_FREE(mdc, strlen(lprof->lp_md) + instlen + 2);
+        if (err != 0)
+                OBD_FREE(sbi, sizeof(*sbi));
         liblustre_wait_idle();
         return err;
 }
 
 struct fssw_ops llu_fssw_ops = {
-        llu_fsswop_mount
+       .fsswop_mount           = llu_fsswop_mount,
 };
 
 static struct inode_ops llu_inode_ops = {
-        inop_lookup:    llu_iop_lookup,
-        inop_getattr:   llu_iop_getattr,
-        inop_setattr:   llu_iop_setattr,
-        inop_filldirentries:     llu_iop_filldirentries,
-        inop_mkdir:     llu_iop_mkdir_raw,
-        inop_rmdir:     llu_iop_rmdir_raw,
-        inop_symlink:   llu_iop_symlink_raw,
-        inop_readlink:  llu_iop_readlink,
-        inop_open:      llu_iop_open,
-        inop_close:     llu_iop_close,
-        inop_link:      llu_iop_link_raw,
-        inop_unlink:    llu_iop_unlink_raw,
-        inop_rename:    llu_iop_rename_raw,
-        inop_pos:       llu_iop_pos,
-        inop_read:      llu_iop_read,
-        inop_write:     llu_iop_write,
-        inop_iodone:    llu_iop_iodone,
-        inop_fcntl:     llu_iop_fcntl,
-        inop_sync:      llu_iop_sync,
-        inop_datasync:  llu_iop_datasync,
-        inop_ioctl:     llu_iop_ioctl,
-        inop_mknod:     llu_iop_mknod_raw,
+       .inop_lookup            = llu_iop_lookup,
+       .inop_getattr           = llu_iop_getattr,
+       .inop_setattr           = llu_iop_setattr,
+       .inop_filldirentries    = llu_iop_filldirentries,
+       .inop_mkdir             = llu_iop_mkdir_raw,
+       .inop_rmdir             = llu_iop_rmdir_raw,
+       .inop_symlink           = llu_iop_symlink_raw,
+       .inop_readlink          = llu_iop_readlink,
+       .inop_open              = llu_iop_open,
+       .inop_close             = llu_iop_close,
+       .inop_link              = llu_iop_link_raw,
+       .inop_unlink            = llu_iop_unlink_raw,
+       .inop_rename            = llu_iop_rename_raw,
+       .inop_pos               = llu_iop_pos,
+       .inop_read              = llu_iop_read,
+       .inop_write             = llu_iop_write,
+       .inop_iodone            = llu_iop_iodone,
+       .inop_fcntl             = llu_iop_fcntl,
+       .inop_sync              = llu_iop_sync,
+       .inop_datasync          = llu_iop_datasync,
+       .inop_ioctl             = llu_iop_ioctl,
+       .inop_mknod             = llu_iop_mknod_raw,
 #ifdef _HAVE_STATVFS
-        inop_statvfs:   llu_iop_statvfs,
+       .inop_statvfs           = llu_iop_statvfs,
 #endif
-        inop_gone:      llu_iop_gone,
+       .inop_gone              = llu_iop_gone,
 };