Whamcloud - gitweb
LU-9972 osd: cache OI mapping in dt_declare_ref_add 11/31211/4
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 23 Oct 2017 16:32:15 +0000 (19:32 +0300)
committerJohn L. Hammond <john.hammond@intel.com>
Thu, 1 Mar 2018 19:59:02 +0000 (19:59 +0000)
so that subsequent calls to manipulate /PENDING don't need to
consult with OI.
use OIC in osd_index_ea_delete() to optimize FLDB lookups.

Lustre-change: https://review.whamcloud.com/29709
Lustre-commit: b6e718def348c53759a12afee9450207fc7ab56f

Change-Id: I779bbddb429b577aecf1ad092d74d0802e43d567
Signed-off-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Minh Diep <minh.diep@intel.com>
Reviewed-on: https://review.whamcloud.com/31211
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-zfs/osd_object.c

index e8568dd..a35f498 100644 (file)
@@ -1844,9 +1844,6 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt,
 
        oh = container_of0(th, struct osd_thandle, ot_super);
 
-       /* reset OI cache for safety */
-       oti->oti_ins_cache_used = 0;
-
        remove_agents = oh->ot_remove_agents;
 
        qtrans = oh->ot_quota_trans;
@@ -1909,6 +1906,9 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt,
        if (unlikely(remove_agents != 0))
                osd_process_scheduled_agent_removals(env, osd);
 
+       /* reset OI cache for safety */
+       oti->oti_ins_cache_used = 0;
+
        sb_end_write(osd_sb(osd));
 
        RETURN(rc);
@@ -3658,6 +3658,8 @@ static int osd_declare_ref_add(const struct lu_env *env, struct dt_object *dt,
        osd_trans_declare_op(env, oh, OSD_OT_REF_ADD,
                             osd_dto_credits_noquota[DTO_ATTR_SET_BASE]);
 
+       osd_idc_find_and_init(env, osd_dev(dt->do_lu.lo_dev), osd_dt_obj(dt));
+
        return 0;
 }
 
@@ -4554,6 +4556,34 @@ static int osd_remote_fid(const struct lu_env *env, struct osd_device *osd,
        RETURN(1);
 }
 
+static void osd_take_care_of_agent(const struct lu_env *env,
+                                  struct osd_device *osd,
+                                  struct osd_thandle *oh,
+                                  struct ldiskfs_dir_entry_2 *de)
+{
+       struct lu_fid *fid = &osd_oti_get(env)->oti_fid;
+       struct osd_idmap_cache *idc;
+       int rc, schedule = 0;
+
+       LASSERT(de != NULL);
+
+       rc = osd_get_fid_from_dentry(de, (struct dt_rec *)fid);
+       if (likely(rc == 0)) {
+               idc = osd_idc_find_or_init(env, osd, fid);
+               if (IS_ERR(idc) || idc->oic_remote)
+                       schedule = 1;
+       } else if (rc == -ENODATA) {
+               /* can't get FID, postpone to the end of the
+                * transaction when iget() is safe */
+               schedule = 1;
+       } else {
+               CERROR("%s: can't get FID: rc = %d\n", osd_name(osd), rc);
+       }
+       if (schedule)
+               osd_schedule_agent_inode_removal(env, oh,
+                                                le32_to_cpu(de->inode));
+}
+
 /**
  * Index delete function for interoperability mode (b11826).
  * It will remove the directory entry added by osd_index_ea_insert().
@@ -4620,20 +4650,8 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt,
                 * reverse would need filesystem abort in case of error deleting
                 * the entry after the agent had been removed, or leave a
                 * dangling entry pointing at a random inode. */
-               if (strcmp((char *)key, dotdot) != 0) {
-                       LASSERT(de != NULL);
-                       rc = osd_get_fid_from_dentry(de, (struct dt_rec *)fid);
-                       if (rc == -ENODATA) {
-                               /* can't get FID, postpone to the end of the
-                                * transaction when iget() is safe */
-                               osd_schedule_agent_inode_removal(env, oh,
-                                               le32_to_cpu(de->inode));
-                       } else if (rc == 0 &&
-                                  unlikely(osd_remote_fid(env, osd, fid))) {
-                               osd_schedule_agent_inode_removal(env, oh,
-                                               le32_to_cpu(de->inode));
-                       }
-               }
+               if (strcmp((char *)key, dotdot) != 0)
+                       osd_take_care_of_agent(env, osd, oh, de);
                rc = ldiskfs_delete_entry(oh->ot_handle, dir, de, bh);
                brelse(bh);
        } else {
index 0c7beca..7ccc58f 100644 (file)
@@ -1759,6 +1759,7 @@ out:
 static int osd_declare_ref_add(const struct lu_env *env, struct dt_object *dt,
                               struct thandle *th)
 {
+       osd_idc_find_and_init(env, osd_dev(dt->do_lu.lo_dev), osd_dt_obj(dt));
        return osd_declare_attr_set(env, dt, NULL, th);
 }
 
@@ -1799,6 +1800,7 @@ out:
 static int osd_declare_ref_del(const struct lu_env *env, struct dt_object *dt,
                               struct thandle *handle)
 {
+       osd_idc_find_and_init(env, osd_dev(dt->do_lu.lo_dev), osd_dt_obj(dt));
        return osd_declare_attr_set(env, dt, NULL, handle);
 }