Whamcloud - gitweb
LU-2237 tests: new test for re-recreating last_rcvd
[fs/lustre-release.git] / lustre / osc / osc_object.c
index 28be07e..bd2e6f4 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,6 +26,8 @@
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -78,24 +78,52 @@ static int osc_object_init(const struct lu_env *env, struct lu_object *obj,
 
         osc->oo_oinfo = cconf->u.coc_oinfo;
 #ifdef INVARIANT_CHECK
-        cfs_mutex_init(&osc->oo_debug_mutex);
+       mutex_init(&osc->oo_debug_mutex);
 #endif
-        cfs_spin_lock_init(&osc->oo_seatbelt);
+       spin_lock_init(&osc->oo_seatbelt);
         for (i = 0; i < CRT_NR; ++i)
                 CFS_INIT_LIST_HEAD(&osc->oo_inflight[i]);
-        return 0;
+
+       CFS_INIT_LIST_HEAD(&osc->oo_ready_item);
+       CFS_INIT_LIST_HEAD(&osc->oo_hp_ready_item);
+       CFS_INIT_LIST_HEAD(&osc->oo_write_item);
+       CFS_INIT_LIST_HEAD(&osc->oo_read_item);
+
+       osc->oo_root.rb_node = NULL;
+       CFS_INIT_LIST_HEAD(&osc->oo_hp_exts);
+       CFS_INIT_LIST_HEAD(&osc->oo_urgent_exts);
+       CFS_INIT_LIST_HEAD(&osc->oo_rpc_exts);
+       CFS_INIT_LIST_HEAD(&osc->oo_reading_exts);
+       cfs_atomic_set(&osc->oo_nr_reads, 0);
+       cfs_atomic_set(&osc->oo_nr_writes, 0);
+       spin_lock_init(&osc->oo_lock);
+
+       return 0;
 }
 
 static void osc_object_free(const struct lu_env *env, struct lu_object *obj)
 {
-        struct osc_object *osc = lu2osc(obj);
-        int i;
-
-        for (i = 0; i < CRT_NR; ++i)
-                LASSERT(cfs_list_empty(&osc->oo_inflight[i]));
-
-        lu_object_fini(obj);
-        OBD_SLAB_FREE_PTR(osc, osc_object_kmem);
+       struct osc_object *osc = lu2osc(obj);
+       int i;
+
+       for (i = 0; i < CRT_NR; ++i)
+               LASSERT(cfs_list_empty(&osc->oo_inflight[i]));
+
+       LASSERT(cfs_list_empty(&osc->oo_ready_item));
+       LASSERT(cfs_list_empty(&osc->oo_hp_ready_item));
+       LASSERT(cfs_list_empty(&osc->oo_write_item));
+       LASSERT(cfs_list_empty(&osc->oo_read_item));
+
+       LASSERT(osc->oo_root.rb_node == NULL);
+       LASSERT(cfs_list_empty(&osc->oo_hp_exts));
+       LASSERT(cfs_list_empty(&osc->oo_urgent_exts));
+       LASSERT(cfs_list_empty(&osc->oo_rpc_exts));
+       LASSERT(cfs_list_empty(&osc->oo_reading_exts));
+       LASSERT(cfs_atomic_read(&osc->oo_nr_reads) == 0);
+       LASSERT(cfs_atomic_read(&osc->oo_nr_writes) == 0);
+
+       lu_object_fini(obj);
+       OBD_SLAB_FREE_PTR(osc, osc_object_kmem);
 }
 
 int osc_lvb_print(const struct lu_env *env, void *cookie,
@@ -151,8 +179,11 @@ int osc_attr_set(const struct lu_env *env, struct cl_object *obj,
                 lvb->lvb_ctime = attr->cat_ctime;
         if (valid & CAT_BLOCKS)
                 lvb->lvb_blocks = attr->cat_blocks;
-        if (valid & CAT_KMS)
+        if (valid & CAT_KMS) {
+                CDEBUG(D_CACHE, "set kms from "LPU64"to "LPU64"\n",
+                       oinfo->loi_kms, (__u64)attr->cat_kms);
                 loi_kms_set(oinfo, attr->cat_kms);
+        }
         return 0;
 }