Whamcloud - gitweb
LU-1866 osd: ancillary work for initial OI scrub
[fs/lustre-release.git] / lustre / obdclass / mea.c
index ac85dad..2a1ee39 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.
@@ -71,29 +69,39 @@ static int mea_all_chars_hash(int count, char *name, int namelen)
 
 int raw_name2idx(int hashtype, int count, const char *name, int namelen)
 {
-        unsigned int c = 0;
+       unsigned int    c = 0;
+       int             idx;
 
-        LASSERT(namelen > 0);
-        if (count <= 1)
-                return 0;
+       LASSERT(namelen > 0);
 
-        switch (hashtype) {
-                case MEA_MAGIC_LAST_CHAR:
-                        c = mea_last_char_hash(count, (char *)name, namelen);
-                        break;
-                case MEA_MAGIC_ALL_CHARS:
-                        c = mea_all_chars_hash(count, (char *)name, namelen);
-                        break;
-                case MEA_MAGIC_HASH_SEGMENT:
-                        CERROR("Unsupported hash type MEA_MAGIC_HASH_SEGMENT\n");
-                        break;
-                default:
-                        CERROR("Unknown hash type 0x%x\n", hashtype);
-        }
+       if (filename_is_volatile(name, namelen, &idx)) {
+               if ((idx >= 0) && (idx < count))
+                       return idx;
+               goto hashchoice;
+       }
 
-        LASSERT(c < count);
-        return c;
+       if (count <= 1)
+               return 0;
+
+hashchoice:
+       switch (hashtype) {
+       case MEA_MAGIC_LAST_CHAR:
+               c = mea_last_char_hash(count, (char *)name, namelen);
+               break;
+       case MEA_MAGIC_ALL_CHARS:
+               c = mea_all_chars_hash(count, (char *)name, namelen);
+               break;
+       case MEA_MAGIC_HASH_SEGMENT:
+               CERROR("Unsupported hash type MEA_MAGIC_HASH_SEGMENT\n");
+               break;
+       default:
+               CERROR("Unknown hash type 0x%x\n", hashtype);
+       }
+
+       LASSERT(c < count);
+       return c;
 }
+EXPORT_SYMBOL(raw_name2idx);
 
 int mea_name2idx(struct lmv_stripe_md *mea, const char *name, int namelen)
 {
@@ -106,3 +114,4 @@ int mea_name2idx(struct lmv_stripe_md *mea, const char *name, int namelen)
         LASSERT(c < mea->mea_count);
         return c;
 }
+EXPORT_SYMBOL(mea_name2idx);