Whamcloud - gitweb
LU-13309 ofd: optimize the brw codepath 95/37795/3
authorAndrew Perepechko <c17827@cray.com>
Fri, 13 Mar 2020 09:44:24 +0000 (12:44 +0300)
committerOleg Drokin <green@whamcloud.com>
Tue, 31 Mar 2020 07:01:07 +0000 (07:01 +0000)
1) currently, ofd_commitrw() calls lvbo_update()
from the read path with req == NULL.

The only effect of this call is lvb update from
disk. However, the read request does not update
inode info such as atime/mtime/ctime/i_size, so
there's no need for lvb update.

The comment above the removed code claims that
ofd_preprw_read() updated ondisk atime. In fact,
there's no code in the read path which updates
atime. Atime update was implemented by
obdo_to_inode() before we moved to osd.

We don't seem to suffer from this loss, so
attr_get and lvb update, which currently do nothing,
can be simply dropped.

2) ofd_commitrw_*() calls ofd_object_find()
whereas the corresponding preprw call has not
only received the pointer to the object, but
also keeps a reference on it when exits so
ofd_commitrw_*() has to put it twice.

We don't really need to look up the needed
object twice, just record it in the ofd info
and then take it from there.

Change-Id: If9692906e6c8c4e1254d166620d1ea7e68a933b6
Signed-off-by: Andrew Perepechko <c17827@cray.com>
Cray-bug-id: LUS-8127
Reviewed-on: https://review.whamcloud.com/37795
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alexander Boyko <c17825@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ofd/ofd_io.c

index 3049225..d86bb5c 100644 (file)
@@ -515,6 +515,8 @@ static int ofd_preprw_read(const struct lu_env *env, struct obd_export *exp,
                RETURN(PTR_ERR(fo));
        LASSERT(fo != NULL);
 
+       ofd_info(env)->fti_obj = fo;
+
        ofd_read_lock(env, fo);
        if (!ofd_object_exists(fo))
                GOTO(unlock, rc = -ENOENT);
@@ -547,10 +549,6 @@ static int ofd_preprw_read(const struct lu_env *env, struct obd_export *exp,
        }
 
        LASSERT(*nr_local > 0 && *nr_local <= PTLRPC_MAX_BRW_PAGES);
-       rc = dt_attr_get(env, ofd_object_child(fo), la);
-       if (unlikely(rc))
-               GOTO(buf_put, rc);
-
        rc = dt_read_prep(env, ofd_object_child(fo), lnb, *nr_local);
        if (unlikely(rc))
                GOTO(buf_put, rc);
@@ -672,6 +670,8 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp,
                GOTO(out, rc = PTR_ERR(fo));
        LASSERT(fo != NULL);
 
+       ofd_info(env)->fti_obj = fo;
+
        ofd_read_lock(env, fo);
        if (!ofd_object_exists(fo)) {
                CERROR("%s: BRW to missing obj "DOSTID"\n",
@@ -830,7 +830,6 @@ int ofd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp,
                rc = ofd_preprw_read(env, exp, ofd, fid, &info->fti_attr, oa,
                                     obj->ioo_bufcnt, rnb, nr_local, lnb,
                                     jobid);
-               obdo_from_la(oa, &info->fti_attr, LA_ATIME);
        } else {
                CERROR("%s: wrong cmd %d received!\n",
                       exp->exp_obd->obd_name, cmd);
@@ -865,17 +864,13 @@ ofd_commitrw_read(const struct lu_env *env, struct ofd_device *ofd,
 
        LASSERT(niocount > 0);
 
-       fo = ofd_object_find(env, ofd, fid);
-       if (IS_ERR(fo))
-               RETURN(PTR_ERR(fo));
+       fo = ofd_info(env)->fti_obj;
        LASSERT(fo != NULL);
        LASSERT(ofd_object_exists(fo));
        dt_bufs_put(env, ofd_object_child(fo), lnb, niocount);
 
        ofd_read_unlock(env, fo);
        ofd_object_put(env, fo);
-       /* second put is pair to object_get in ofd_preprw_read */
-       ofd_object_put(env, fo);
 
        RETURN(0);
 }
@@ -1120,7 +1115,7 @@ ofd_commitrw_write(const struct lu_env *env, struct obd_export *exp,
 
        LASSERT(objcount == 1);
 
-       fo = ofd_object_find(env, ofd, fid);
+       fo = ofd_info(env)->fti_obj;
        LASSERT(fo != NULL);
 
        o = ofd_object_child(fo);
@@ -1261,8 +1256,6 @@ out_stop:
 out:
        dt_bufs_put(env, o, lnb, niocount);
        ofd_object_put(env, fo);
-       /* second put is pair to object_get in ofd_preprw_write */
-       ofd_object_put(env, fo);
        if (granted > 0)
                tgt_grant_commit(exp, granted, old_rc);
        RETURN(rc);
@@ -1382,19 +1375,6 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp,
                        nodemap_putref(nodemap);
                }
        } else if (cmd == OBD_BRW_READ) {
-
-               /* If oa != NULL then ofd_preprw_read updated the inode
-                * atime and we should update the lvb so that other glimpses
-                * will also get the updated value. bug 5972 */
-               if (oa && ns && ns->ns_lvbo && ns->ns_lvbo->lvbo_update) {
-                       ost_fid_build_resid(fid, &info->fti_resid);
-                       rs = ldlm_resource_get(ns, NULL, &info->fti_resid,
-                                              LDLM_EXTENT, 0);
-                       if (!IS_ERR(rs)) {
-                               ldlm_res_lvbo_update(rs, NULL, 1);
-                               ldlm_resource_putref(rs);
-                       }
-               }
                rc = ofd_commitrw_read(env, ofd, fid, objcount,
                                       npages, lnb);
                if (old_rc)