Whamcloud - gitweb
b=20094
[fs/lustre-release.git] / lustre / obdclass / lu_object.c
index 42798fb..0c07d53 100644 (file)
@@ -845,8 +845,6 @@ void lu_device_fini(struct lu_device *d)
 
         t = d->ld_type;
         if (d->ld_obd != NULL) {
-                /* finish lprocfs */
-                lprocfs_obd_cleanup(d->ld_obd);
                 d->ld_obd->obd_lu_dev = NULL;
                 d->ld_obd = NULL;
         }
@@ -1094,13 +1092,16 @@ void lu_context_key_degister(struct lu_context_key *key)
         lu_context_key_quiesce(key);
 
         ++key_set_version;
-        key_fini(&lu_shrink_env.le_ctx, key->lct_index);
-
-        if (atomic_read(&key->lct_used) > 1)
-                CERROR("key has instances.\n");
         spin_lock(&lu_keys_guard);
-        lu_keys[key->lct_index] = NULL;
+        key_fini(&lu_shrink_env.le_ctx, key->lct_index);
+        if (lu_keys[key->lct_index]) {
+                lu_keys[key->lct_index] = NULL;
+                lu_ref_fini(&key->lct_reference);
+        }
         spin_unlock(&lu_keys_guard);
+
+        LASSERTF(atomic_read(&key->lct_used) == 1, "key has instances: %d\n",
+                 atomic_read(&key->lct_used));
 }
 EXPORT_SYMBOL(lu_context_key_degister);
 
@@ -1193,6 +1194,7 @@ void *lu_context_key_get(const struct lu_context *ctx,
 {
         LINVRNT(ctx->lc_state == LCS_ENTERED);
         LINVRNT(0 <= key->lct_index && key->lct_index < ARRAY_SIZE(lu_keys));
+        LASSERT(lu_keys[key->lct_index] == key);
         return ctx->lc_value[key->lct_index];
 }
 EXPORT_SYMBOL(lu_context_key_get);
@@ -1241,6 +1243,7 @@ static void keys_fini(struct lu_context *ctx)
 {
         int i;
 
+        spin_lock(&lu_keys_guard);
         if (ctx->lc_value != NULL) {
                 for (i = 0; i < ARRAY_SIZE(lu_keys); ++i)
                         key_fini(ctx, i);
@@ -1248,6 +1251,7 @@ static void keys_fini(struct lu_context *ctx)
                          ARRAY_SIZE(lu_keys) * sizeof ctx->lc_value[0]);
                 ctx->lc_value = NULL;
         }
+        spin_unlock(&lu_keys_guard);
 }
 
 static int keys_fill(struct lu_context *ctx)
@@ -1428,8 +1432,11 @@ static int lu_cache_shrink(int nr, unsigned int gfp_mask)
         int remain = nr;
         CFS_LIST_HEAD(splice);
 
-        if (nr != 0 && !(gfp_mask & __GFP_FS))
-                return -1;
+        if (nr != 0) {
+                if (!(gfp_mask & __GFP_FS))
+                        return -1;
+                CDEBUG(D_INODE, "Shrink %d objects\n", nr);
+        }
 
         down(&lu_sites_guard);
         list_for_each_entry_safe(s, tmp, &lu_sites, ls_linkage) {
@@ -1444,11 +1451,15 @@ static int lu_cache_shrink(int nr, unsigned int gfp_mask)
                 read_lock(&s->ls_guard);
                 cached += s->ls_total - s->ls_busy;
                 read_unlock(&s->ls_guard);
-                if (remain <= 0)
+                if (nr && remain <= 0)
                         break;
         }
         list_splice(&splice, lu_sites.prev);
         up(&lu_sites_guard);
+
+        cached = (cached / 100) * sysctl_vfs_cache_pressure;
+        if (nr == 0)
+                CDEBUG(D_INODE, "%d objects cached\n", cached);
         return cached;
 }
 
@@ -1465,7 +1476,7 @@ struct lu_env lu_debugging_env;
  * Debugging printer function using printk().
  */
 int lu_printk_printer(const struct lu_env *env,
-                      void *_, const char *format, ...)
+                      void *unused, const char *format, ...)
 {
         va_list args;
 
@@ -1512,6 +1523,12 @@ void cl_global_fini(void);
 int  lu_ref_global_init(void);
 void lu_ref_global_fini(void);
 
+int dt_global_init(void);
+void dt_global_fini(void);
+
+int llo_global_init(void);
+void llo_global_fini(void);
+
 /**
  * Initialization of global lu_* data.
  */
@@ -1521,6 +1538,10 @@ int lu_global_init(void)
 
         CDEBUG(D_CONSOLE, "Lustre LU module (%p).\n", &lu_keys);
 
+        result = lu_ref_global_init();
+        if (result != 0)
+                return result;
+
         LU_CONTEXT_KEY_INIT(&lu_global_key);
         result = lu_context_key_register(&lu_global_key);
         if (result != 0)
@@ -1536,9 +1557,6 @@ int lu_global_init(void)
         if (result != 0)
                 return result;
 
-        result = lu_ref_global_init();
-        if (result != 0)
-                return result;
         /*
          * seeks estimation: 3 seeks to read a record from oi, one to read
          * inode, one for ea. Unfortunately setting this high value results in
@@ -1549,10 +1567,22 @@ int lu_global_init(void)
                 return -ENOMEM;
 
         result = lu_time_global_init();
-        if (result != 0)
-                return result;
+        if (result)
+                GOTO(out, result);
+
+#ifdef __KERNEL__
+        result = dt_global_init();
+        if (result)
+                GOTO(out, result);
+
+        result = llo_global_init();
+        if (result)
+                GOTO(out, result);
+#endif
+        result = cl_global_init();
+out:
 
-        return cl_global_init();
+        return result;
 }
 
 /**
@@ -1561,6 +1591,10 @@ int lu_global_init(void)
 void lu_global_fini(void)
 {
         cl_global_fini();
+#ifdef __KERNEL__
+        llo_global_fini();
+        dt_global_fini();
+#endif
         lu_time_global_fini();
         if (lu_site_shrinker != NULL) {
                 remove_shrinker(lu_site_shrinker);
@@ -1643,13 +1677,23 @@ void fid_pack(struct lu_fid_pack *pack, const struct lu_fid *fid,
          */
         CLASSERT(LUSTRE_SEQ_MAX_WIDTH < 0xffffull);
 
-        if (fid_is_igif(fid) ||
-            seq > 0xffffffull || oid > 0xffff || fid_ver(fid) != 0) {
+        /* fid can be packed in six bytes (first byte as length of packed fid,
+         * three bytes of seq and two bytes of oid).
+         * this reduces IO overhead specially for OSD Object Index. */
+
+        if (seq < FID_SEQ_START ||
+            seq > (0xffffffull + FID_SEQ_START) ||
+            oid > 0xffff || fid_ver(fid) != 0) {
                 fid_cpu_to_be(befider, fid);
                 recsize = sizeof *befider;
         } else {
                 unsigned char *small_befider;
 
+                /* as lower 24 bits of FID_SEQ_START are zero, no need to
+                 * subtract its value from seq */
+
+                CLASSERT((FID_SEQ_START & 0xffffff) == 0);
+
                 small_befider = (unsigned char *)befider;
 
                 small_befider[0] = seq >> 16;
@@ -1681,6 +1725,7 @@ int fid_unpack(const struct lu_fid_pack *pack, struct lu_fid *fid)
 
                 area = (unsigned char *)pack->fp_area;
                 fid->f_seq = (area[0] << 16) | (area[1] << 8) | area[2];
+                fid->f_seq +=  FID_SEQ_START;
                 fid->f_oid = (area[3] << 8) | area[4];
                 fid->f_ver = 0;
                 break;
@@ -1739,4 +1784,3 @@ void lu_kmem_fini(struct lu_kmem_descr *caches)
         }
 }
 EXPORT_SYMBOL(lu_kmem_fini);
-