Whamcloud - gitweb
LU-32 osd: keep root node BH ref of IAM container
authorLiang Zhen <liang@whamcloud.com>
Mon, 27 Dec 2010 05:35:20 +0000 (13:35 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 4 Jan 2012 15:47:18 +0000 (10:47 -0500)
IAM in ldiskfs-osd will always consume some slots in bh_lru (see:
fs/buffer.c), if we keep buffer_head reference on root node,
we can save one slot in bh_lru and could be somehow helpful for
overall performance, I did some tests, LRU hits rate increased
5%-10% while creating files if we always keep this reference.

Signed-off-by: Liang Zhen <liang@whamcloud.com>
Change-Id: I954f26932462169c9bfc6bbfe1a57b5348624179
Reviewed-on: http://review.whamcloud.com/1826
Tested-by: Hudson
Reviewed-by: Bobi Jam <bobijam@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_iam.c
lustre/osd-ldiskfs/osd_iam.h

index 788eb31..c461662 100644 (file)
@@ -2372,18 +2372,30 @@ static int osd_iam_container_init(const struct lu_env *env,
                                   struct osd_object *obj,
                                   struct osd_directory *dir)
 {
+        struct iam_container *bag = &dir->od_container;
         int result;
-        struct iam_container *bag;
 
-        bag    = &dir->od_container;
         result = iam_container_init(bag, &dir->od_descr, obj->oo_inode);
-        if (result == 0) {
-                result = iam_container_setup(bag);
-                if (result == 0)
-                        obj->oo_dt.do_index_ops = &osd_index_iam_ops;
-                else
-                        iam_container_fini(bag);
+        if (result != 0)
+                return result;
+
+        result = iam_container_setup(bag);
+        if (result != 0)
+                goto out;
+
+        if (osd_obj2dev(obj)->od_iop_mode) {
+                u32 ptr = bag->ic_descr->id_ops->id_root_ptr(bag);
+
+                bag->ic_root_bh = ldiskfs_bread(NULL, obj->oo_inode,
+                                                ptr, 0, &result);
         }
+
+ out:
+        if (result == 0)
+                obj->oo_dt.do_index_ops = &osd_index_iam_ops;
+        else
+                iam_container_fini(bag);
+
         return result;
 }
 
index d949fa5..98cde18 100644 (file)
@@ -190,6 +190,8 @@ EXPORT_SYMBOL(iam_container_setup);
  */
 void iam_container_fini(struct iam_container *c)
 {
+        brelse(c->ic_root_bh);
+        c->ic_root_bh = NULL;
 }
 EXPORT_SYMBOL(iam_container_fini);
 
@@ -268,6 +270,18 @@ int iam_node_read(struct iam_container *c, iam_ptr_t ptr,
 {
         int result = 0;
 
+        /* NB: it can be called by iam_lfix_guess() which is still at
+         * very early stage, c->ic_root_bh and c->ic_descr->id_ops
+         * haven't been intialized yet.
+         * Also, we don't have this for IAM dir.
+         */
+        if (c->ic_root_bh != NULL &&
+            c->ic_descr->id_ops->id_root_ptr(c) == ptr) {
+                get_bh(c->ic_root_bh);
+                *bh = c->ic_root_bh;
+                return 0;
+        }
+
         *bh = ldiskfs_bread(h, c->ic_object, (int)ptr, 0, &result);
         if (*bh == NULL)
                 result = -EIO;
index e6c550c..ffb458c 100644 (file)
@@ -447,15 +447,19 @@ struct iam_container {
          * Underlying flat file. IO against this object is issued to
          * read/write nodes.
          */
-        struct inode      *ic_object;
+        struct inode        *ic_object;
+        /*
+         * BH of root block
+         */
+        struct buffer_head  *ic_root_bh;
         /*
          * container flavor.
          */
-        struct iam_descr  *ic_descr;
+        struct iam_descr    *ic_descr;
         /*
          * read-write lock protecting index consistency.
          */
-        cfs_rw_semaphore_t ic_sem;
+        cfs_rw_semaphore_t   ic_sem;
 };
 
 /*