X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosd-zfs%2Fosd_object.c;h=332909324d852f1aee2a0cf94569e31c9f427ebe;hb=d022319528b84dea545920647edc599b2318557b;hp=02983acb7d64b1fcef07fb53410d9449fc0d219c;hpb=2291c21d174ac0a88f2c3b0551362079c963df16;p=fs%2Flustre-release.git 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); }