Whamcloud - gitweb
LU-11838 lustre: discard LTIME_S macro
[fs/lustre-release.git] / lustre / llite / lcommon_cl.c
index 1249be0..21a10ec 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;
@@ -85,12 +85,13 @@ int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr,
        io->ci_obj = obj;
        io->ci_verify_layout = 1;
 
-       io->u.ci_setattr.sa_attr.lvb_atime = LTIME_S(attr->ia_atime);
-       io->u.ci_setattr.sa_attr.lvb_mtime = LTIME_S(attr->ia_mtime);
-       io->u.ci_setattr.sa_attr.lvb_ctime = LTIME_S(attr->ia_ctime);
+       io->u.ci_setattr.sa_attr.lvb_atime = attr->ia_atime.tv_sec;
+       io->u.ci_setattr.sa_attr.lvb_mtime = attr->ia_mtime.tv_sec;
+       io->u.ci_setattr.sa_attr.lvb_ctime = attr->ia_ctime.tv_sec;
        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;
 }
 
 /**
@@ -204,12 +216,12 @@ static void cl_object_put_last(struct lu_env *env, struct cl_object *obj)
 
        if (unlikely(atomic_read(&header->loh_ref) != 1)) {
                struct lu_site *site = obj->co_lu.lo_dev->ld_site;
-               struct lu_site_bkt_data *bkt;
+               wait_queue_head_t *wq;
 
-               bkt = lu_site_bkt_from_fid(site, &header->loh_fid);
+               wq = lu_site_wq_from_fid(site, &header->loh_fid);
 
                init_waitqueue_entry(&waiter, current);
-               add_wait_queue(&bkt->lsb_marche_funebre, &waiter);
+               add_wait_queue(wq, &waiter);
 
                while (1) {
                        set_current_state(TASK_UNINTERRUPTIBLE);
@@ -219,7 +231,7 @@ static void cl_object_put_last(struct lu_env *env, struct cl_object *obj)
                }
 
                set_current_state(TASK_RUNNING);
-               remove_wait_queue(&bkt->lsb_marche_funebre, &waiter);
+               remove_wait_queue(wq, &waiter);
        }
 
        cl_object_put(env, obj);