Whamcloud - gitweb
ORNL-24 skip unnecessary client obj hash lookup
[fs/lustre-release.git] / lustre / lclient / lcommon_cl.c
index 9f7d9a3..f1fe4dd 100644 (file)
@@ -30,6 +30,9 @@
  * Use is subject to license terms.
  */
 /*
+ * Copyright (c) 2011 Whamcloud, Inc.
+ */
+/*
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  *
@@ -1033,7 +1036,7 @@ int cl_setattr_ost(struct inode *inode, const struct iattr *attr,
         if (IS_ERR(env))
                 RETURN(PTR_ERR(env));
 
-        io = &ccc_env_info(env)->cti_io;
+        io = ccc_env_thread_io(env);
         io->ci_obj = cl_i2info(inode)->lli_clob;
 
         io->u.ci_setattr.sa_attr.lvb_atime = LTIME_S(attr->ia_atime);
@@ -1158,7 +1161,7 @@ int cl_inode_init(struct inode *inode, struct lustre_md *md)
         struct cl_object     *clob;
         struct lu_site       *site;
         struct lu_fid        *fid;
-        const struct cl_object_conf conf = {
+        struct cl_object_conf conf = {
                 .coc_inode = inode,
                 .u = {
                         .coc_md    = md
@@ -1167,7 +1170,6 @@ int cl_inode_init(struct inode *inode, struct lustre_md *md)
         int result = 0;
         int refcheck;
 
-        /* LASSERT(inode->i_state & I_NEW); */
         LASSERT(md->body->valid & OBD_MD_FLID);
 
         if (!S_ISREG(cl_inode_mode(inode)))
@@ -1183,6 +1185,14 @@ int cl_inode_init(struct inode *inode, struct lustre_md *md)
         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. */
+#ifdef __KERNEL__
+                LASSERT(inode->i_state & I_NEW);
+#endif
+                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)) {
@@ -1218,14 +1228,16 @@ int cl_inode_init(struct inode *inode, struct lustre_md *md)
 static void cl_object_put_last(struct lu_env *env, struct cl_object *obj)
 {
         struct lu_object_header *header = obj->co_lu.lo_header;
-        struct lu_site          *site;
         cfs_waitlink_t           waiter;
 
         if (unlikely(cfs_atomic_read(&header->loh_ref) != 1)) {
-                site = obj->co_lu.lo_dev->ld_site;
+                struct lu_site *site = obj->co_lu.lo_dev->ld_site;
+                struct lu_site_bkt_data *bkt;
+
+                bkt = lu_site_bkt_from_fid(site, &header->loh_fid);
 
                 cfs_waitlink_init(&waiter);
-                cfs_waitq_add(&site->ls_marche_funebre, &waiter);
+                cfs_waitq_add(&bkt->lsb_marche_funebre, &waiter);
 
                 while (1) {
                         cfs_set_current_state(CFS_TASK_UNINT);
@@ -1235,7 +1247,7 @@ static void cl_object_put_last(struct lu_env *env, struct cl_object *obj)
                 }
 
                 cfs_set_current_state(CFS_TASK_RUNNING);
-                cfs_waitq_del(&site->ls_marche_funebre, &waiter);
+                cfs_waitq_del(&bkt->lsb_marche_funebre, &waiter);
         }
 
         cl_object_put(env, obj);
@@ -1302,22 +1314,13 @@ __u16 ll_dirent_type_get(struct lu_dirent *ent)
 }
 
 /**
- * for 32 bit inode numbers directly map seq+oid to 32bit number.
- */
-__u32 cl_fid_build_ino32(const struct lu_fid *fid)
-{
-        RETURN(fid_flatten32(fid));
-}
-
-/**
  * build inode number from passed @fid */
-__u64 cl_fid_build_ino(const struct lu_fid *fid)
+__u64 cl_fid_build_ino(const struct lu_fid *fid, int api32)
 {
-#if BITS_PER_LONG == 32
-        RETURN(fid_flatten32(fid));
-#else
-        RETURN(fid_flatten(fid));
-#endif
+        if (BITS_PER_LONG == 32 || api32)
+                RETURN(fid_flatten32(fid));
+        else
+                RETURN(fid_flatten(fid));
 }
 
 /**