Whamcloud - gitweb
LU-4423 lustre: don't declare extern variables in C files.
[fs/lustre-release.git] / lustre / osd-zfs / osd_object.c
index 6d582ea..ca0db0f 100644 (file)
@@ -66,11 +66,8 @@ static int osd_object_sync_delay_us = -1;
 
 static struct dt_object_operations osd_obj_ops;
 static struct lu_object_operations osd_lu_obj_ops;
-extern struct dt_body_operations osd_body_ops;
 static struct dt_object_operations osd_obj_otable_it_ops;
 
-extern struct kmem_cache *osd_object_kmem;
-
 static void
 osd_object_sa_fini(struct osd_object *obj)
 {
@@ -291,6 +288,7 @@ int __osd_obj2dnode(objset_t *os, uint64_t oid, dnode_t **dnp)
        dbi = (dmu_buf_impl_t *)db;
        DB_DNODE_ENTER(dbi);
        *dnp = DB_DNODE(dbi);
+       DB_DNODE_EXIT(dbi);
        LASSERT(*dnp != NULL);
 
        return 0;
@@ -1485,6 +1483,7 @@ static int osd_declare_create(const struct lu_env *env, struct dt_object *dt,
        switch (dof->dof_type) {
                case DFT_DIR:
                        dt->do_index_ops = &osd_dir_ops;
+                       /* fallthrough */
                case DFT_INDEX:
                        /* for zap create */
                        dmu_tx_hold_zap(oh->ot_tx, DMU_NEW_OBJECT, FALSE, NULL);
@@ -1649,6 +1648,7 @@ int osd_find_new_dnode(const struct lu_env *env, dmu_tx_t *tx,
                        atomic_inc_32(&dn->dn_dbufs_count);
                }
                *dnp = dn;
+               DB_DNODE_EXIT(db);
                dbuf_read(db, NULL, DB_RF_MUST_SUCCEED | DB_RF_NOPREFETCH);
                break;
        }
@@ -2103,15 +2103,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);
        }