From 2d784025da2dd1c979ff2269d91340a8e0729309 Mon Sep 17 00:00:00 2001 From: Liang Zhen Date: Wed, 4 Jul 2012 13:50:30 +0800 Subject: [PATCH] LU-1598 osd: bypass OI lookup for creation It's unnecessary to call osd_oi_lookup() in osd_fid_lookup if it's a file creation because FID shouldn't never be re-used so we expect it to be not existed, which means we can bypass overhead of OI lookup at here, if it's really a duplicate FID from unexpected reasons, we should detect it later while calling do_create->osd_oi_insert(). Signed-off-by: Liang Zhen Change-Id: I87227a4e7d008c06876b1366734832886868de3b Reviewed-on: http://review.whamcloud.com/3269 Reviewed-by: Fan Yong Tested-by: Hudson Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger --- lustre/osd-ldiskfs/osd_handler.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index a1243c9..0dcc349 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -387,7 +387,7 @@ static int osd_fid_lookup(const struct lu_env *env, struct osd_object *obj, struct inode *inode; struct osd_scrub *scrub; struct scrub_file *sf; - int result; + int result; int verify = 0; ENTRY; @@ -422,22 +422,19 @@ static int osd_fid_lookup(const struct lu_env *env, struct osd_object *obj, } fid_zero(&oic->oic_fid); - /* Search order: 3. OI files. */ - result = osd_oi_lookup(info, dev, fid, id); - if (result != 0 && result != -ENOENT) - GOTO(out, result); - /* If fid wasn't found in oi, inode-less object is created, - * for which lu_object_exists() returns false. This is used - * in a (frequent) case when objects are created as locking - * anchors or place holders for objects yet to be created. */ - if (conf != NULL && conf->loc_flags & LOC_F_NEW) { - if (unlikely(result == 0)) - GOTO(out, result = -EEXIST); - else - GOTO(out, result = 0); - } + /* + * Objects are created as locking anchors or place holders for objects + * yet to be created. No need to osd_oi_lookup() at here because FID + * shouldn't never be re-used, if it's really a duplicate FID from + * unexpected reason, we should be able to detect it later by calling + * do_create->osd_oi_insert() + */ + if (conf != NULL && (conf->loc_flags & LOC_F_NEW) != 0) + GOTO(out, result = 0); + /* Search order: 3. OI files. */ + result = osd_oi_lookup(info, dev, fid, id); if (result == -ENOENT) { if (!fid_is_norm(fid) || !ldiskfs_test_bit(osd_oi_fid2idx(dev,fid), @@ -447,6 +444,9 @@ static int osd_fid_lookup(const struct lu_env *env, struct osd_object *obj, goto trigger; } + if (result != 0) + GOTO(out, result); + iget: if (verify == 0) inode = osd_iget(info, dev, id); -- 1.8.3.1