From: Liang Zhen Date: Mon, 27 Dec 2010 05:35:20 +0000 (+0800) Subject: LU-32 osd: keep root node BH ref of IAM container X-Git-Tag: 2.1.54~34 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=4ad943d14235ce8e8599477b340dbd75c076581e;hp=39308b9999b42bf91aff860a71669ca13686c475 LU-32 osd: keep root node BH ref of IAM container 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 Change-Id: I954f26932462169c9bfc6bbfe1a57b5348624179 Reviewed-on: http://review.whamcloud.com/1826 Tested-by: Hudson Reviewed-by: Bobi Jam Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 788eb31..c461662 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -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; } diff --git a/lustre/osd-ldiskfs/osd_iam.c b/lustre/osd-ldiskfs/osd_iam.c index d949fa5..98cde18 100644 --- a/lustre/osd-ldiskfs/osd_iam.c +++ b/lustre/osd-ldiskfs/osd_iam.c @@ -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; diff --git a/lustre/osd-ldiskfs/osd_iam.h b/lustre/osd-ldiskfs/osd_iam.h index e6c550c..ffb458c 100644 --- a/lustre/osd-ldiskfs/osd_iam.h +++ b/lustre/osd-ldiskfs/osd_iam.h @@ -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; }; /*