From d022319528b84dea545920647edc599b2318557b Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Wed, 3 Oct 2018 12:39:34 +0300 Subject: [PATCH] LU-11462 osd-zfs: skip sync if object is not dirty 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 Reviewed-on: https://review.whamcloud.com/33276 Reviewed-by: Andreas Dilger Reviewed-by: Brian Behlendorf Reviewed-by: Nathaniel Clark Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/osd-zfs/osd_object.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c index 02983ac..3329093 100644 --- a/lustre/osd-zfs/osd_object.c +++ b/lustre/osd-zfs/osd_object.c @@ -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); } -- 1.8.3.1