]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os: further simplify store_statfs_t
authorSage Weil <sage@redhat.com>
Wed, 15 Jun 2016 20:14:41 +0000 (16:14 -0400)
committerSage Weil <sage@redhat.com>
Wed, 15 Jun 2016 20:14:41 +0000 (16:14 -0400)
- drop bsize (nobody needs it)
- all fields in units of bytes (replace blocks with total (bytes))

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/FuseStore.cc
src/os/bluestore/BlueStore.cc
src/os/filestore/FileStore.cc
src/os/memstore/MemStore.cc
src/osd/OSD.cc
src/osd/osd_types.cc
src/osd/osd_types.h
src/test/objectstore/store_test.cc

index a98d9e4eedc89d873392dbf015a0901ddced47d1..e9c29d130f6e3c9fcd244f55e7673a7ebf48ab69 100644 (file)
@@ -982,9 +982,9 @@ static int os_statfs(const char *path, struct statvfs *stbuf)
   int r = fs->store->statfs(&s);
   if (r < 0)
     return r;
-  stbuf->f_bsize = s.bsize;
-  stbuf->f_blocks = s.blocks;
-  stbuf->f_bavail = stbuf->f_bfree = s.available / s.bsize;
+  stbuf->f_bsize = 4096;   // LIES!
+  stbuf->f_blocks = s.total / 4096;
+  stbuf->f_bavail = s.available / 4096;
 
   return 0;
 }
index 88c3966070a24ddc1cb12a93bbe42468c9bda36f..3960dd5edff0e67957ffe6c9aa27d7f6451eea59 100644 (file)
@@ -2551,6 +2551,12 @@ int BlueStore::fsck()
       errors += r;
   }
 
+  // get expected statfs; fill unaffected fields to be able to compare
+  // structs
+  statfs(&actual_statfs);
+  expected_statfs.total = actual_statfs.total;
+  expected_statfs.available = actual_statfs.available;
+
   // walk collections, objects
   for (ceph::unordered_map<coll_t, CollectionRef>::iterator p = coll_map.begin();
        p != coll_map.end();
@@ -2751,11 +2757,6 @@ int BlueStore::fsck()
     hash_shared.clear();
     bnode.reset();
   }
-  statfs(&actual_statfs);
-  //fill unaffected fields to be able to compare structs
-  expected_statfs.blocks = actual_statfs.blocks;
-  expected_statfs.bsize = actual_statfs.bsize;
-  expected_statfs.available = actual_statfs.available;
   if (!(actual_statfs == expected_statfs)) {
     dout(30) << __func__ << "  actual statfs differs from the expected one:"
              << actual_statfs << " vs. "
@@ -2955,9 +2956,7 @@ int BlueStore::statfs(struct store_statfs_t *buf)
     bluefs_len += p.get_len();
 
   buf->reset();
-
-  buf->blocks = bdev->get_size() / block_size;
-  buf->bsize = block_size;
+  buf->total = bdev->get_size();
   buf->available = (alloc->get_free() - bluefs_len);
 
   bufferlist bl;
index 6ccbf9002174722d8bac0cca7b1d5e6707e1b08c..730cee9b62a0e9f682d439374475cc0b5bdc7b4e 100644 (file)
@@ -711,8 +711,7 @@ int FileStore::statfs(struct store_statfs_t *buf0)
     assert(r != -ENOENT);
     return r;
   }
-  buf0->blocks = buf.f_blocks;
-  buf0->bsize = buf.f_bsize;
+  buf0->total = buf.f_blocks * buf.f_bsize;
   buf0->available = buf.f_bavail * buf.f_bsize;
   return 0;
 }
index f96d472392854a0c1b66d1df92a3152e2f4cd907..aa0aba8b79592071216e4cece15046865dc5c778 100644 (file)
@@ -224,14 +224,10 @@ int MemStore::statfs(struct store_statfs_t *st)
 {
    dout(10) << __func__ << dendl;
   st->reset();
-  st->bsize = 4096;
-
-   // Device size is a configured constant
-  st->blocks = g_conf->memstore_device_bytes / st->bsize;
-
-  dout(10) << __func__ << ": used_bytes: " << used_bytes << "/" << g_conf->memstore_device_bytes << dendl;
-  st->available = MAX((int64_t(st->blocks * st->bsize) - int64_t(used_bytes)), 0);
-
+  st->total = g_conf->memstore_device_bytes;
+  st->available = MAX(int64_t(st->total) - int64_t(used_bytes), 0ll);
+  dout(10) << __func__ << ": used_bytes: " << used_bytes
+          << "/" << g_conf->memstore_device_bytes << dendl;
   return 0;
 }
 
index 968356dfb7f9bc8c891496df566943e710770200..333a23144f4c1a1683ad2c3636e65b09000ba08b 100644 (file)
@@ -774,7 +774,7 @@ void OSDService::update_osd_stat(vector<int>& hb_peers)
     return;
   }
 
-  uint64_t bytes = stbuf.blocks * stbuf.bsize;
+  uint64_t bytes = stbuf.total;
   uint64_t used = bytes - stbuf.available;
   uint64_t avail = stbuf.available;
 
@@ -2799,7 +2799,7 @@ int OSD::update_crush_location()
     }
     snprintf(weight, sizeof(weight), "%.4lf",
             MAX((double).00001,
-                (double)(st.blocks * st.bsize) /
+                (double)(st.total) /
                 (double)(1ull << 40 /* TB */)));
   }
 
index 173fe56dd03311509b06ded5445740d58750289e..cde4e7b7575ae63d45784cabc5ff994858281a1c 100644 (file)
@@ -5571,8 +5571,7 @@ void OSDOp::merge_osd_op_vector_out_data(vector<OSDOp>& ops, bufferlist& out)
 
 bool store_statfs_t::operator==(const store_statfs_t& other) const
 {
-  return blocks == other.blocks
-    && bsize == other.bsize
+  return total == other.total
     && available == other.available
     && allocated == other.allocated
     && stored == other.stored
@@ -5583,11 +5582,8 @@ bool store_statfs_t::operator==(const store_statfs_t& other) const
 
 void store_statfs_t::dump(Formatter *f) const
 {
+  f->dump_int("total", total);
   f->dump_int("available", available);
-
-  f->dump_int("blocks", blocks);
-  f->dump_int("bsize", bsize);
-
   f->dump_int("allocated", allocated);
   f->dump_int("stored", stored);
   f->dump_int("compressed", compressed);
@@ -5598,9 +5594,8 @@ void store_statfs_t::dump(Formatter *f) const
 ostream& operator<<(ostream& out, const store_statfs_t &s)
 {
   out << std::hex
-      << " store_statfs(0x" << s.blocks
-      << "*0x"  << s.bsize
-      << "/0x"  << s.available
+      << " store_statfs(0x" << s.available
+      << "/0x"  << s.total
       << ", stored 0x" << s.stored
       << "/0x"  << s.allocated
       << ", compress 0x" << s.compressed
index 553ee0600c0a9042d469558f2face0d1fb850fcf..37e5557be09485bd08b124d375f8fa8d1b3a4b42 100644 (file)
@@ -4314,9 +4314,7 @@ struct PromoteCounter {
 +*/
 struct store_statfs_t
 {
-
-  uint64_t blocks = 0;                 // Total data blocks
-  uint32_t bsize = 0;                  // Optimal transfer block size
+  uint64_t total = 0;                  // Total bytes
   uint64_t available = 0;              // Free bytes available
 
   int64_t allocated = 0;               // Bytes allocated by the store
index 0d8b70248ffab2e11f2e63ee1b1d0e7868f6e3ac..1fca627a2a9b67cb1f2fe3f34d4451658648dc52 100644 (file)
@@ -1138,8 +1138,7 @@ TEST_P(StoreTest, BluestoreStatFSTest) {
     ASSERT_EQ(r, 0);
     ASSERT_EQ( 0u, statfs.allocated);
     ASSERT_EQ( 0u, statfs.stored);
-    ASSERT_EQ(0x1000u, statfs.bsize);
-    ASSERT_EQ(g_conf->bluestore_block_size / 0x1000, statfs.blocks);
+    ASSERT_EQ(g_conf->bluestore_block_size, statfs.total);
     ASSERT_TRUE(statfs.available > 0u && statfs.available < g_conf->bluestore_block_size);
     //force fsck
     EXPECT_EQ(store->umount(), 0);
@@ -1356,10 +1355,9 @@ TEST_P(StoreTest, BluestoreFragmentedBlobTest) {
     struct store_statfs_t statfs;
     int r = store->statfs(&statfs);
     ASSERT_EQ(r, 0);
-    ASSERT_EQ( 0u, statfs.allocated);
-    ASSERT_EQ( 0u, statfs.stored);
-    ASSERT_EQ(0x1000u, statfs.bsize);
-    ASSERT_EQ(g_conf->bluestore_block_size / 0x1000, statfs.blocks);
+    ASSERT_EQ(g_conf->bluestore_block_size, statfs.total);
+    ASSERT_EQ(0u, statfs.allocated);
+    ASSERT_EQ(0u, statfs.stored);
     ASSERT_TRUE(statfs.available > 0u && statfs.available < g_conf->bluestore_block_size);
   }
   std::string data;