]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/FuseStore: hide bitwise_hash_end if bits unknown; add bitwise_hash_bits
authorSage Weil <sage@redhat.com>
Thu, 7 Jan 2016 13:56:42 +0000 (08:56 -0500)
committerSage Weil <sage@redhat.com>
Wed, 27 Jan 2016 19:06:13 +0000 (14:06 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/FuseStore.cc

index 5772ddbedcc2c70f1581aebacd9fc780a78153c6..0c9e0edb15dd2b2b665bab7621fdcd74ab344f45 100644 (file)
@@ -45,6 +45,7 @@ FuseStore::~FuseStore()
  * $cid/
  * $cid/bitwise_hash_start = lowest hash value
  * $cid/bitwise_hash_end = highest hash value
+ * $cid/bitwise_hash_bits - how many bits are significant
  * $cid/pgmeta/ - pgmeta object
  * $cid/all/ - all objects
  * $cid/all/$obj/
@@ -59,6 +60,7 @@ enum {
   FN_COLLECTION,
   FN_HASH_START,
   FN_HASH_END,
+  FN_HASH_BITS,
   FN_OBJECT,
   FN_OBJECT_HASH,
   FN_OBJECT_DATA,
@@ -103,6 +105,8 @@ static int parse_fn(const char *path, coll_t *cid, ghobject_t *oid, string *key,
     return FN_HASH_START;
   if (v.front() == "bitwise_hash_end")
     return FN_HASH_END;
+  if (v.front() == "bitwise_hash_bits")
+    return FN_HASH_BITS;
   if (v.front() == "pgmeta") {
     spg_t pgid;
     if (cid->is_pg(&pgid)) {
@@ -218,12 +222,26 @@ static int os_getattr(const char *path, struct stat *stbuf)
     stbuf->st_mode = S_IFDIR | 0700;
     return 0;
 
-  case FN_HASH_START:
   case FN_HASH_END:
+    if (fs->store->collection_bits(cid) < 0)
+      return -ENOENT;
+    // fall-thru
+  case FN_HASH_START:
   case FN_OBJECT_HASH:
     stbuf->st_size = 9;
     return 0;
 
+  case FN_HASH_BITS:
+    {
+      int bits = fs->store->collection_bits(cid);
+      if (bits < 0)
+       return -ENOENT;
+      char buf[8];
+      snprintf(buf, sizeof(buf), "%d\n", bits);
+      stbuf->st_size = strlen(buf);
+    }
+    return 0;
+
   case FN_OBJECT_DATA:
     {
       int r = fs->store->stat(cid, oid, stbuf);
@@ -305,7 +323,10 @@ static int os_readdir(const char *path,
   case FN_COLLECTION:
     {
       filler(buf, "bitwise_hash_start", NULL, 0);
-      filler(buf, "bitwise_hash_end", NULL, 0);
+      if (fs->store->collection_bits(cid) >= 0) {
+       filler(buf, "bitwise_hash_end", NULL, 0);
+       filler(buf, "bitwise_hash_bits", NULL, 0);
+      }
       filler(buf, "all", NULL, 0);
       filler(buf, "by_bitwise_hash", NULL, 0);
       spg_t pgid;
@@ -441,7 +462,7 @@ static int os_open(const char *path, struct fuse_file_info *fi)
          uint64_t rev_end = (rev_start | (0xffffffff >> hash_bits));
          h = rev_end;
        } else {
-         h = 0xffffffff;
+         return -ENOENT;
        }
       } else {
        h = 0xffffffff;
@@ -452,6 +473,15 @@ static int os_open(const char *path, struct fuse_file_info *fi)
     }
     break;
 
+  case FN_HASH_BITS:
+    {
+      char buf[8];
+      snprintf(buf, sizeof(buf), "%d\n", fs->store->collection_bits(cid));
+      pbl = new bufferlist;
+      pbl->append(buf);
+    }
+    break;
+
   case FN_OBJECT_HASH:
     {
       pbl = new bufferlist;