Whamcloud - gitweb
LU-11579 llite: remove cl_file_inode_init() LASSERT
[fs/lustre-release.git] / lustre / llite / lcommon_cl.c
index 597c130..c4b6cc9 100644 (file)
@@ -68,7 +68,7 @@ __u16 cl_inode_fini_refcheck;
 static DEFINE_MUTEX(cl_inode_fini_guard);
 
 int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr,
-                  unsigned int attr_flags)
+                  enum op_xvalid xvalid, unsigned int attr_flags)
 {
         struct lu_env *env;
         struct cl_io  *io;
@@ -90,7 +90,8 @@ int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr,
        io->u.ci_setattr.sa_attr.lvb_ctime = LTIME_S(attr->ia_ctime);
        io->u.ci_setattr.sa_attr.lvb_size = attr->ia_size;
        io->u.ci_setattr.sa_attr_flags = attr_flags;
-       io->u.ci_setattr.sa_valid = attr->ia_valid;
+       io->u.ci_setattr.sa_avalid = attr->ia_valid;
+       io->u.ci_setattr.sa_xvalid = xvalid;
        io->u.ci_setattr.sa_parent_fid = lu_object_fid(&obj->co_lu);
 
 again:
@@ -151,27 +152,36 @@ int cl_file_inode_init(struct inode *inode, struct lustre_md *md)
 
        site = ll_i2sbi(inode)->ll_site;
        lli  = ll_i2info(inode);
-        fid  = &lli->lli_fid;
-        LASSERT(fid_is_sane(fid));
-
-        if (lli->lli_clob == NULL) {
-                /* clob is slave of inode, empty lli_clob means for new inode,
-                 * there is no clob in cache with the given fid, so it is
-                 * unnecessary to perform lookup-alloc-lookup-insert, just
-                 * alloc and insert directly. */
-                LASSERT(inode->i_state & I_NEW);
-                conf.coc_lu.loc_flags = LOC_F_NEW;
-                clob = cl_object_find(env, lu2cl_dev(site->ls_top_dev),
-                                      fid, &conf);
-                if (!IS_ERR(clob)) {
-                        /*
-                         * No locking is necessary, as new inode is
-                         * locked by I_NEW bit.
-                         */
-                        lli->lli_clob = clob;
-                        lu_object_ref_add(&clob->co_lu, "inode", inode);
-                } else
-                        result = PTR_ERR(clob);
+       fid  = &lli->lli_fid;
+       LASSERT(fid_is_sane(fid));
+
+       if (lli->lli_clob == NULL) {
+               /* clob is slave of inode, empty lli_clob means for new inode,
+                * there is no clob in cache with the given fid, so it is
+                * unnecessary to perform lookup-alloc-lookup-insert, just
+                * alloc and insert directly.
+                */
+               if (!(inode->i_state & I_NEW)) {
+                       result = -EIO;
+                       CERROR("%s: unexpected not-NEW inode "DFID": rc = %d\n",
+                              ll_get_fsname(inode->i_sb, NULL, 0), PFID(fid),
+                              result);
+                       goto out;
+               }
+
+               conf.coc_lu.loc_flags = LOC_F_NEW;
+               clob = cl_object_find(env, lu2cl_dev(site->ls_top_dev),
+                                     fid, &conf);
+               if (!IS_ERR(clob)) {
+                       /*
+                        * No locking is necessary, as new inode is
+                        * locked by I_NEW bit.
+                        */
+                       lli->lli_clob = clob;
+                       lu_object_ref_add(&clob->co_lu, "inode", inode);
+               } else {
+                       result = PTR_ERR(clob);
+               }
        } else {
                result = cl_conf_set(env, lli->lli_clob, &conf);
                if (result == -EBUSY) {
@@ -180,12 +190,14 @@ int cl_file_inode_init(struct inode *inode, struct lustre_md *md)
                }
        }
 
-        cl_env_put(env, &refcheck);
+       if (result != 0)
+               CERROR("%s: failed to initialize cl_object "DFID": rc = %d\n",
+                       ll_get_fsname(inode->i_sb, NULL, 0), PFID(fid), result);
+
+out:
+       cl_env_put(env, &refcheck);
 
-        if (result != 0)
-                CERROR("Failure to initialize cl object "DFID": %d\n",
-                       PFID(fid), result);
-        return result;
+       return result;
 }
 
 /**