Whamcloud - gitweb
LU-4712 llite: lock the inode to be migrated
[fs/lustre-release.git] / lustre / llite / file.c
index 6bd91ed..0ee0dde 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -194,15 +194,6 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp,
                spin_unlock(&lli->lli_lock);
        }
 
-        if (rc == 0) {
-                rc = ll_objects_destroy(req, inode);
-                if (rc)
-                       CERROR("%s: inode "DFID
-                              " ll_objects destroy: rc = %d\n",
-                              ll_i2mdexp(inode)->exp_obd->obd_name,
-                              PFID(ll_inode2fid(inode)), rc);
-        }
-
        if (rc == 0 && op_data->op_bias & MDS_HSM_RELEASE) {
                struct mdt_body *body;
                body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
@@ -1018,51 +1009,57 @@ int ll_inode_getattr(struct inode *inode, struct obdo *obdo,
        RETURN(rc);
 }
 
-int ll_merge_lvb(const struct lu_env *env, struct inode *inode)
+int ll_merge_attr(const struct lu_env *env, struct inode *inode)
 {
        struct ll_inode_info *lli = ll_i2info(inode);
        struct cl_object *obj = lli->lli_clob;
        struct cl_attr *attr = ccc_env_thread_attr(env);
-       struct ost_lvb lvb;
+       s64 atime;
+       s64 mtime;
+       s64 ctime;
        int rc = 0;
 
        ENTRY;
 
        ll_inode_size_lock(inode);
+
        /* merge timestamps the most recently obtained from mds with
           timestamps obtained from osts */
-       LTIME_S(inode->i_atime) = lli->lli_lvb.lvb_atime;
-       LTIME_S(inode->i_mtime) = lli->lli_lvb.lvb_mtime;
-       LTIME_S(inode->i_ctime) = lli->lli_lvb.lvb_ctime;
+       LTIME_S(inode->i_atime) = lli->lli_atime;
+       LTIME_S(inode->i_mtime) = lli->lli_mtime;
+       LTIME_S(inode->i_ctime) = lli->lli_ctime;
 
-       lvb.lvb_size = i_size_read(inode);
-       lvb.lvb_blocks = inode->i_blocks;
-       lvb.lvb_mtime = LTIME_S(inode->i_mtime);
-       lvb.lvb_atime = LTIME_S(inode->i_atime);
-       lvb.lvb_ctime = LTIME_S(inode->i_ctime);
+       atime = LTIME_S(inode->i_atime);
+       mtime = LTIME_S(inode->i_mtime);
+       ctime = LTIME_S(inode->i_ctime);
 
        cl_object_attr_lock(obj);
        rc = cl_object_attr_get(env, obj, attr);
        cl_object_attr_unlock(obj);
 
-       if (rc == 0) {
-               if (lvb.lvb_atime < attr->cat_atime)
-                       lvb.lvb_atime = attr->cat_atime;
-               if (lvb.lvb_ctime < attr->cat_ctime)
-                       lvb.lvb_ctime = attr->cat_ctime;
-               if (lvb.lvb_mtime < attr->cat_mtime)
-                       lvb.lvb_mtime = attr->cat_mtime;
-
-               CDEBUG(D_VFSTRACE, DFID" updating i_size "LPU64"\n",
-                               PFID(&lli->lli_fid), attr->cat_size);
-               cl_isize_write_nolock(inode, attr->cat_size);
-
-               inode->i_blocks = attr->cat_blocks;
-
-               LTIME_S(inode->i_mtime) = lvb.lvb_mtime;
-               LTIME_S(inode->i_atime) = lvb.lvb_atime;
-               LTIME_S(inode->i_ctime) = lvb.lvb_ctime;
-       }
+       if (rc != 0)
+               GOTO(out_size_unlock, rc);
+
+       if (atime < attr->cat_atime)
+               atime = attr->cat_atime;
+
+       if (ctime < attr->cat_ctime)
+               ctime = attr->cat_ctime;
+
+       if (mtime < attr->cat_mtime)
+               mtime = attr->cat_mtime;
+
+       CDEBUG(D_VFSTRACE, DFID" updating i_size "LPU64"\n",
+              PFID(&lli->lli_fid), attr->cat_size);
+
+       i_size_write(inode, attr->cat_size);
+       inode->i_blocks = attr->cat_blocks;
+
+       LTIME_S(inode->i_atime) = atime;
+       LTIME_S(inode->i_mtime) = mtime;
+       LTIME_S(inode->i_ctime) = ctime;
+
+out_size_unlock:
        ll_inode_size_unlock(inode);
 
        RETURN(rc);
@@ -1147,7 +1144,7 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args,
        struct range_lock     range;
        ENTRY;
 
-       CDEBUG(D_VFSTRACE, "file: %s, type: %d ppos: "LPU64", count: %zd\n",
+       CDEBUG(D_VFSTRACE, "file: %s, type: %d ppos: "LPU64", count: %zu\n",
                file->f_dentry->d_name.name, iot, *ppos, count);
 
 restart:
@@ -1156,24 +1153,24 @@ restart:
 
         if (cl_io_rw_init(env, io, iot, *ppos, count) == 0) {
                struct vvp_io *vio = vvp_env_io(env);
-               struct ccc_io *cio = ccc_env_io(env);
                bool range_locked = false;
 
                if (file->f_flags & O_APPEND)
                        range_lock_init(&range, 0, LUSTRE_EOF);
                else
                        range_lock_init(&range, *ppos, *ppos + count - 1);
-               cio->cui_fd  = LUSTRE_FPRIVATE(file);
-               vio->cui_io_subtype = args->via_io_subtype;
-
-                switch (vio->cui_io_subtype) {
-                case IO_NORMAL:
-                        cio->cui_iov = args->u.normal.via_iov;
-                        cio->cui_nrsegs = args->u.normal.via_nrsegs;
-                        cio->cui_tot_nrsegs = cio->cui_nrsegs;
-                        cio->cui_iocb = args->u.normal.via_iocb;
-                        if ((iot == CIT_WRITE) &&
-                            !(cio->cui_fd->fd_flags & LL_FILE_GROUP_LOCKED)) {
+
+               vio->vui_fd  = LUSTRE_FPRIVATE(file);
+               vio->vui_io_subtype = args->via_io_subtype;
+
+               switch (vio->vui_io_subtype) {
+               case IO_NORMAL:
+                       vio->vui_iov = args->u.normal.via_iov;
+                       vio->vui_nrsegs = args->u.normal.via_nrsegs;
+                       vio->vui_tot_nrsegs = vio->vui_nrsegs;
+                       vio->vui_iocb = args->u.normal.via_iocb;
+                       if ((iot == CIT_WRITE) &&
+                           !(vio->vui_fd->fd_flags & LL_FILE_GROUP_LOCKED)) {
                                CDEBUG(D_VFSTRACE, "Range lock "RL_FMT"\n",
                                       RL_PARA(&range));
                                result = range_lock(&lli->lli_write_tree,
@@ -1184,15 +1181,15 @@ restart:
                                range_locked = true;
                        }
                        down_read(&lli->lli_trunc_sem);
-                        break;
-                case IO_SPLICE:
-                        vio->u.splice.cui_pipe = args->u.splice.via_pipe;
-                        vio->u.splice.cui_flags = args->u.splice.via_flags;
-                        break;
-                default:
-                        CERROR("Unknow IO type - %u\n", vio->cui_io_subtype);
-                        LBUG();
-                }
+                       break;
+               case IO_SPLICE:
+                       vio->u.splice.vui_pipe = args->u.splice.via_pipe;
+                       vio->u.splice.vui_flags = args->u.splice.via_flags;
+                       break;
+               default:
+                       CERROR("unknown IO subtype %u\n", vio->vui_io_subtype);
+                       LBUG();
+               }
 
                ll_cl_add(file, env, io);
                 result = cl_io_loop(env, io);
@@ -1220,7 +1217,7 @@ out:
        /* If any bit been read/written (result != 0), we just return
         * short read/write instead of restart io. */
        if ((result == 0 || result == -ENODATA) && io->ci_need_restart) {
-               CDEBUG(D_VFSTRACE, "Restart %s on %s from %lld, count:%zd\n",
+               CDEBUG(D_VFSTRACE, "Restart %s on %s from %lld, count:%zu\n",
                       iot == CIT_READ ? "read" : "write",
                       file->f_dentry->d_name.name, *ppos, count);
                LASSERTF(io->ci_nob == 0, "%zd\n", io->ci_nob);
@@ -1431,95 +1428,16 @@ static ssize_t ll_file_splice_read(struct file *in_file, loff_t *ppos,
         RETURN(result);
 }
 
-static int ll_lov_recreate(struct inode *inode, struct ost_id *oi,
-                           obd_count ost_idx)
-{
-       struct obd_export *exp = ll_i2dtexp(inode);
-       struct obd_trans_info oti = { 0 };
-       struct obdo *oa = NULL;
-       int lsm_size;
-       int rc = 0;
-       struct lov_stripe_md *lsm = NULL, *lsm2;
-       ENTRY;
-
-       OBDO_ALLOC(oa);
-       if (oa == NULL)
-               RETURN(-ENOMEM);
-
-       lsm = ccc_inode_lsm_get(inode);
-       if (!lsm_has_objects(lsm))
-                GOTO(out, rc = -ENOENT);
-
-        lsm_size = sizeof(*lsm) + (sizeof(struct lov_oinfo) *
-                   (lsm->lsm_stripe_count));
-
-        OBD_ALLOC_LARGE(lsm2, lsm_size);
-        if (lsm2 == NULL)
-                GOTO(out, rc = -ENOMEM);
-
-       oa->o_oi = *oi;
-        oa->o_nlink = ost_idx;
-        oa->o_flags |= OBD_FL_RECREATE_OBJS;
-        oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
-        obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
-                                   OBD_MD_FLMTIME | OBD_MD_FLCTIME);
-        obdo_set_parent_fid(oa, &ll_i2info(inode)->lli_fid);
-        memcpy(lsm2, lsm, lsm_size);
-       ll_inode_size_lock(inode);
-       rc = obd_create(NULL, exp, oa, &lsm2, &oti);
-       ll_inode_size_unlock(inode);
-
-       OBD_FREE_LARGE(lsm2, lsm_size);
-       GOTO(out, rc);
-out:
-       ccc_inode_lsm_put(inode, lsm);
-       OBDO_FREE(oa);
-       return rc;
-}
-
-static int ll_lov_recreate_obj(struct inode *inode, unsigned long arg)
-{
-       struct ll_recreate_obj ucreat;
-       struct ost_id           oi;
-       ENTRY;
-
-       if (!cfs_capable(CFS_CAP_SYS_ADMIN))
-               RETURN(-EPERM);
-
-       if (copy_from_user(&ucreat, (struct ll_recreate_obj __user *)arg,
-                          sizeof(ucreat)))
-               RETURN(-EFAULT);
-
-       ostid_set_seq_mdt0(&oi);
-       ostid_set_id(&oi, ucreat.lrc_id);
-       RETURN(ll_lov_recreate(inode, &oi, ucreat.lrc_ost_idx));
-}
-
-static int ll_lov_recreate_fid(struct inode *inode, unsigned long arg)
-{
-       struct lu_fid   fid;
-       struct ost_id   oi;
-       obd_count       ost_idx;
-        ENTRY;
-
-       if (!cfs_capable(CFS_CAP_SYS_ADMIN))
-               RETURN(-EPERM);
-
-       if (copy_from_user(&fid, (struct lu_fid __user *)arg, sizeof(fid)))
-               RETURN(-EFAULT);
-
-       fid_to_ostid(&fid, &oi);
-       ost_idx = (fid_seq(&fid) >> 16) & 0xffff;
-       RETURN(ll_lov_recreate(inode, &oi, ost_idx));
-}
-
 int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
                              __u64  flags, struct lov_user_md *lum,
                             int lum_size)
 {
        struct lov_stripe_md *lsm = NULL;
-       struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags};
-       int rc = 0;
+       struct lookup_intent oit = {
+               .it_op = IT_OPEN,
+               .it_flags = flags | MDS_OPEN_BY_FID,
+       };
+       int rc;
        ENTRY;
 
        lsm = ccc_inode_lsm_get(inode);
@@ -1531,13 +1449,13 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
        }
 
        ll_inode_size_lock(inode);
-       oit.it_flags |= MDS_OPEN_BY_FID;
        rc = ll_intent_file_open(file, lum, lum_size, &oit);
-       if (rc)
+       if (rc < 0)
                GOTO(out_unlock, rc);
+
        rc = oit.d.lustre.it_status;
        if (rc < 0)
-               GOTO(out_req_free, rc);
+               GOTO(out_unlock, rc);
 
        ll_release_openhandle(file->f_dentry, &oit);
 
@@ -1547,10 +1465,8 @@ out_unlock:
        ccc_inode_lsm_put(inode, lsm);
 out:
        cl_lov_delay_create_clear(&file->f_flags);
+
        RETURN(rc);
-out_req_free:
-       ptlrpc_req_finished((struct ptlrpc_request *) oit.d.lustre.it_data);
-       goto out;
 }
 
 int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
@@ -1666,6 +1582,23 @@ static int ll_lov_setea(struct inode *inode, struct file *file,
        RETURN(rc);
 }
 
+static int ll_file_getstripe(struct inode *inode,
+                            struct lov_user_md __user *lum)
+{
+       struct lu_env   *env;
+       int             refcheck;
+       int             rc;
+       ENTRY;
+
+       env = cl_env_get(&refcheck);
+       if (IS_ERR(env))
+               RETURN(PTR_ERR(env));
+
+       rc = cl_object_getstripe(env, ll_i2info(inode)->lli_clob, lum);
+       cl_env_put(env, &refcheck);
+       RETURN(rc);
+}
+
 static int ll_lov_setstripe(struct inode *inode, struct file *file,
                            unsigned long arg)
 {
@@ -1682,36 +1615,18 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file,
        lum_size = rc;
        rc = ll_lov_setstripe_ea_info(inode, file, flags, klum, lum_size);
        if (rc == 0) {
-               struct lov_stripe_md *lsm;
                __u32 gen;
 
                put_user(0, &lum->lmm_stripe_count);
 
                ll_layout_refresh(inode, &gen);
-               lsm = ccc_inode_lsm_get(inode);
-               rc = obd_iocontrol(LL_IOC_LOV_GETSTRIPE, ll_i2dtexp(inode),
-                                  0, lsm, lum);
-               ccc_inode_lsm_put(inode, lsm);
+               rc = ll_file_getstripe(inode, (struct lov_user_md __user *)arg);
        }
 
        OBD_FREE(klum, lum_size);
        RETURN(rc);
 }
 
-static int ll_lov_getstripe(struct inode *inode, unsigned long arg)
-{
-       struct lov_stripe_md *lsm;
-       int rc = -ENODATA;
-       ENTRY;
-
-       lsm = ccc_inode_lsm_get(inode);
-       if (lsm != NULL)
-               rc = obd_iocontrol(LL_IOC_LOV_GETSTRIPE, ll_i2dtexp(inode), 0,
-                                  lsm, (void __user *)arg);
-       ccc_inode_lsm_put(inode, lsm);
-       RETURN(rc);
-}
-
 static int
 ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg)
 {
@@ -1721,6 +1636,11 @@ ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg)
         int                     rc;
         ENTRY;
 
+       if (arg == 0) {
+               CWARN("group id for group lock must not be 0\n");
+               RETURN(-EINVAL);
+       }
+
         if (ll_file_nolock(file))
                 RETURN(-EOPNOTSUPP);
 
@@ -1734,7 +1654,7 @@ ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg)
        LASSERT(fd->fd_grouplock.cg_lock == NULL);
        spin_unlock(&lli->lli_lock);
 
-       rc = cl_get_grouplock(cl_i2info(inode)->lli_clob,
+       rc = cl_get_grouplock(ll_i2info(inode)->lli_clob,
                              arg, (file->f_flags & O_NONBLOCK), &grouplock);
        if (rc)
                RETURN(rc);
@@ -1755,7 +1675,8 @@ ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg)
        RETURN(0);
 }
 
-int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg)
+static int ll_put_grouplock(struct inode *inode, struct file *file,
+                           unsigned long arg)
 {
        struct ll_inode_info   *lli = ll_i2info(inode);
        struct ll_file_data    *fd = LUSTRE_FPRIVATE(file);
@@ -1873,6 +1794,12 @@ static int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap,
        fm_key.oa.o_oi = lsm->lsm_oi;
         fm_key.oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
 
+       if (i_size_read(inode) == 0) {
+               rc = ll_glimpse_size(inode);
+               if (rc)
+                       GOTO(out, rc);
+       }
+
         obdo_from_inode(&fm_key.oa, inode, OBD_MD_FLSIZE);
         obdo_set_parent_fid(&fm_key.oa, &ll_i2info(inode)->lli_fid);
         /* If filesize is 0, then there would be no objects for mapping */
@@ -2067,7 +1994,7 @@ int ll_hsm_release(struct inode *inode)
        if (IS_ERR(env))
                GOTO(out, rc = PTR_ERR(env));
 
-       ll_merge_lvb(env, inode);
+       ll_merge_attr(env, inode);
        cl_env_nested_put(&nest, env);
 
        /* Release the file.
@@ -2403,12 +2330,9 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                fput(file2);
                RETURN(rc);
        }
-        case LL_IOC_LOV_GETSTRIPE:
-                RETURN(ll_lov_getstripe(inode, arg));
-        case LL_IOC_RECREATE_OBJ:
-                RETURN(ll_lov_recreate_obj(inode, arg));
-        case LL_IOC_RECREATE_FID:
-                RETURN(ll_lov_recreate_fid(inode, arg));
+       case LL_IOC_LOV_GETSTRIPE:
+               RETURN(ll_file_getstripe(inode,
+                                        (struct lov_user_md __user *)arg));
         case FSFILT_IOC_FIEMAP:
                 RETURN(ll_ioctl_fiemap(inode, arg));
         case FSFILT_IOC_GETFLAGS:
@@ -2440,7 +2364,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                RETURN(0);
        }
        case LL_IOC_GETPARENT:
-               RETURN(ll_getparent(file, (void __user *)arg));
+               RETURN(ll_getparent(file, (struct getparent __user *)arg));
 
        case OBD_IOC_FID2PATH:
                RETURN(ll_fid2path(inode, (void __user *)arg));
@@ -2808,7 +2732,7 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,
        capa = ll_osscapa_get(inode, CAPA_OPC_OSS_WRITE);
 
        io = ccc_env_thread_io(env);
-       io->ci_obj = cl_i2info(inode)->lli_clob;
+       io->ci_obj = ll_i2info(inode)->lli_clob;
        io->ci_ignore_layout = ignore_layout;
 
        /* initialize parameters for sync */
@@ -3106,11 +3030,14 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
        qstr.name = name;
        qstr.len = namelen;
        dchild = d_lookup(file->f_dentry, &qstr);
-       if (dchild != NULL && dchild->d_inode != NULL) {
-               op_data->op_fid3 = *ll_inode2fid(dchild->d_inode);
+       if (dchild != NULL) {
                if (dchild->d_inode != NULL) {
                        child_inode = igrab(dchild->d_inode);
-                       ll_invalidate_aliases(child_inode);
+                       if (child_inode != NULL) {
+                               mutex_lock(&child_inode->i_mutex);
+                               op_data->op_fid3 = *ll_inode2fid(child_inode);
+                               ll_invalidate_aliases(child_inode);
+                       }
                }
                dput(dchild);
        } else {
@@ -3151,6 +3078,7 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
 out_free:
        if (child_inode != NULL) {
                clear_nlink(child_inode);
+               mutex_unlock(&child_inode->i_mutex);
                iput(child_inode);
        }
 
@@ -3310,10 +3238,10 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
 
                 ll_lookup_finish_locks(&oit, dentry);
         } else if (!ll_have_md_lock(dentry->d_inode, &ibits, LCK_MINMODE)) {
-                struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode);
-                obd_valid valid = OBD_MD_FLGETATTR;
-                struct md_op_data *op_data;
-                int ealen = 0;
+               struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode);
+               u64 valid = OBD_MD_FLGETATTR;
+               struct md_op_data *op_data;
+               int ealen = 0;
 
                if (S_ISREG(inode->i_mode)) {
                        rc = ll_get_default_mdsize(sbi, &ealen);
@@ -3353,16 +3281,17 @@ static int ll_merge_md_attr(struct inode *inode)
 
        LASSERT(ll_i2info(inode)->lli_lsm_md != NULL);
        rc = md_merge_attr(ll_i2mdexp(inode), ll_i2info(inode)->lli_lsm_md,
-                          &attr);
+                          &attr, ll_md_blocking_ast);
        if (rc != 0)
                RETURN(rc);
 
-       ll_i2info(inode)->lli_stripe_dir_size = attr.cat_size;
-       ll_i2info(inode)->lli_stripe_dir_nlink = attr.cat_nlink;
+       set_nlink(inode, attr.cat_nlink);
+       inode->i_blocks = attr.cat_blocks;
+       i_size_write(inode, attr.cat_size);
 
-       ll_i2info(inode)->lli_lvb.lvb_atime = attr.cat_atime;
-       ll_i2info(inode)->lli_lvb.lvb_mtime = attr.cat_mtime;
-       ll_i2info(inode)->lli_lvb.lvb_ctime = attr.cat_ctime;
+       ll_i2info(inode)->lli_atime = attr.cat_atime;
+       ll_i2info(inode)->lli_mtime = attr.cat_mtime;
+       ll_i2info(inode)->lli_ctime = attr.cat_ctime;
 
        RETURN(0);
 }
@@ -3387,9 +3316,9 @@ ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
                                RETURN(rc);
                }
 
-               LTIME_S(inode->i_atime) = ll_i2info(inode)->lli_lvb.lvb_atime;
-               LTIME_S(inode->i_mtime) = ll_i2info(inode)->lli_lvb.lvb_mtime;
-               LTIME_S(inode->i_ctime) = ll_i2info(inode)->lli_lvb.lvb_ctime;
+               LTIME_S(inode->i_atime) = ll_i2info(inode)->lli_atime;
+               LTIME_S(inode->i_mtime) = ll_i2info(inode)->lli_mtime;
+               LTIME_S(inode->i_ctime) = ll_i2info(inode)->lli_ctime;
        } else {
                /* In case of restore, the MDT has the right size and has
                 * already send it back without granting the layout lock,
@@ -3431,16 +3360,10 @@ int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat)
        stat->mtime = inode->i_mtime;
        stat->ctime = inode->i_ctime;
        stat->blksize = 1 << inode->i_blkbits;
-       stat->blocks = inode->i_blocks;
 
-       if (S_ISDIR(inode->i_mode) &&
-               ll_i2info(inode)->lli_lsm_md != NULL) {
-               stat->nlink = lli->lli_stripe_dir_nlink;
-               stat->size = lli->lli_stripe_dir_size;
-       } else {
-               stat->nlink = inode->i_nlink;
-               stat->size = i_size_read(inode);
-       }
+       stat->nlink = inode->i_nlink;
+       stat->size = i_size_read(inode);
+       stat->blocks = inode->i_blocks;
 
         return 0;
 }
@@ -4120,9 +4043,8 @@ int ll_layout_restore(struct inode *inode, loff_t offset, __u64 length)
        hur->hur_user_item[0].hui_extent.offset = offset;
        hur->hur_user_item[0].hui_extent.length = length;
        hur->hur_request.hr_itemcount = 1;
-       rc = obd_iocontrol(LL_IOC_HSM_REQUEST, cl_i2sbi(inode)->ll_md_exp,
+       rc = obd_iocontrol(LL_IOC_HSM_REQUEST, ll_i2sbi(inode)->ll_md_exp,
                           len, hur, NULL);
        OBD_FREE(hur, len);
        RETURN(rc);
 }
-