Whamcloud - gitweb
LU-11462 osd-zfs: skip sync if object is not dirty 76/33276/7
authorAlex Zhuravlev <bzzz@whamcloud.com>
Wed, 3 Oct 2018 09:39:34 +0000 (12:39 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 9 Aug 2019 04:39:57 +0000 (04:39 +0000)
there is no need to flush whole filesystem if the object is not
dirty or being synced.

in SLOW=yes FSTYPE=zfs sh sanity-benchmark.sh ~24% sync reqs
can be skipped.

Change-Id: I13b15ed646a4603858002e8be25ef5f5f8cd2b9b
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/33276
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Nathaniel Clark <nclark@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osd-zfs/osd_object.c

index 02983ac..3329093 100644 (file)
@@ -2105,15 +2105,22 @@ static int osd_object_sync(const struct lu_env *env, struct dt_object *dt,
                           __u64 start, __u64 end)
 {
        struct osd_device *osd = osd_obj2dev(osd_dt_obj(dt));
+       struct dmu_buf_impl *db = osd_dt_obj(dt)->oo_dn->dn_dbuf;
+       uint64_t txg = 0;
        ENTRY;
 
-       /* XXX: no other option than syncing the whole filesystem until we
-        * support ZIL.  If the object tracked the txg that it was last
-        * modified in, it could pass that txg here instead of "0".  Maybe
-        * the changes are already committed, so no wait is needed at all? */
-       if (!osd->od_dt_dev.dd_rdonly) {
+       if (osd->od_dt_dev.dd_rdonly)
+               RETURN(0);
+
+       mutex_enter(&db->db_mtx);
+       if (db->db_last_dirty)
+               txg = db->db_last_dirty->dr_txg;
+       mutex_exit(&db->db_mtx);
+
+       if (txg) {
+               /* the object is dirty or being synced */
                if (osd_object_sync_delay_us < 0)
-                       txg_wait_synced(dmu_objset_pool(osd->od_os), 0ULL);
+                       txg_wait_synced(dmu_objset_pool(osd->od_os), txg);
                else
                        udelay(osd_object_sync_delay_us);
        }