Whamcloud - gitweb
LU-1598 osd: bypass OI lookup for creation
authorLiang Zhen <liang@whamcloud.com>
Wed, 4 Jul 2012 05:50:30 +0000 (13:50 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 10 Jul 2012 04:37:31 +0000 (00:37 -0400)
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 <liang@whamcloud.com>
Change-Id: I87227a4e7d008c06876b1366734832886868de3b
Reviewed-on: http://review.whamcloud.com/3269
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/osd-ldiskfs/osd_handler.c

index a1243c9..0dcc349 100644 (file)
@@ -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);