Skip to content

Commit

Permalink
osd: fine-grained statistics of logical object space usage
Browse files Browse the repository at this point in the history
To test this change, we create an image of 5GB and do rbd bench write of 1GB:
./bin/rbd create bar -s 5120 && ./bin/rbd bench --io-type write --io-size 32K --io-total 100M --io-pattern rand  rbd/bar

Below is the test result.

Was:

GLOBAL:
    SIZE       AVAIL      RAW USED     %RAW USED
    30911M     27052M        3859M         12.49
POOLS:
    NAME                  ID     USED      %USED     MAX AVAIL     OBJECTS
    rbd                   0      3191M     26.36         8914M        1174
    cephfs_data_a         1          0         0         8914M           0
    cephfs_metadata_a     2       2246         0         8914M          21

Now:

GLOBAL:
    SIZE       AVAIL      RAW USED     %RAW USED
    30911M     27050M        3861M         12.49
POOLS:
    NAME                  ID     USED        %USED     MAX AVAIL     OBJECTS
    rbd                   0      101216k      1.10         8913M        1178
    cephfs_data_a         1            0         0         8913M           0
    cephfs_metadata_a     2          892         0         8913M          21

E.g., this change can make "osd pool set-quota max_bytes" work nicely.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
  • Loading branch information
xiexingguo committed May 22, 2017
1 parent e3319da commit 580be10
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/osd/PrimaryLogPG.cc
Expand Up @@ -6893,10 +6893,15 @@ void PrimaryLogPG::write_update_size_and_usage(object_stat_sum_t& delta_stats, o
modified.union_of(ch);
if (write_full || offset + length > oi.size) {
uint64_t new_size = offset + length;
delta_stats.num_bytes -= oi.size;
delta_stats.num_bytes += new_size;
oi.size = new_size;
}
{ // count newly write bytes, exclude overwrites
interval_set<uint64_t> overlap;
overlap.intersection_of(ch, oi.extents);
ch.subtract(overlap);
oi.extents.union_of(ch);
delta_stats.num_bytes += ch.size();
}
delta_stats.num_wr++;
delta_stats.num_wr_kb += SHIFT_ROUND_UP(length, 10);
}
Expand Down
8 changes: 6 additions & 2 deletions src/osd/osd_types.cc
Expand Up @@ -4967,7 +4967,7 @@ void object_info_t::encode(bufferlist& bl, uint64_t features) const
++i) {
old_watchers.insert(make_pair(i->first.second, i->second));
}
ENCODE_START(16, 8, bl);
ENCODE_START(17, 8, bl);
::encode(soid, bl);
::encode(myoloc, bl); //Retained for compatibility
::encode((__u32)0, bl); // was category, no longer used
Expand Down Expand Up @@ -4998,13 +4998,14 @@ void object_info_t::encode(bufferlist& bl, uint64_t features) const
::encode(expected_object_size, bl);
::encode(expected_write_size, bl);
::encode(alloc_hint_flags, bl);
::encode(extents, bl);
ENCODE_FINISH(bl);
}

void object_info_t::decode(bufferlist::iterator& bl)
{
object_locator_t myoloc;
DECODE_START_LEGACY_COMPAT_LEN(16, 8, 8, bl);
DECODE_START_LEGACY_COMPAT_LEN(17, 8, 8, bl);
map<entity_name_t, watch_info_t> old_watchers;
::decode(soid, bl);
::decode(myoloc, bl);
Expand Down Expand Up @@ -5086,6 +5087,9 @@ void object_info_t::decode(bufferlist::iterator& bl)
expected_write_size = 0;
alloc_hint_flags = 0;
}
if (struct_v >= 17) {
::decode(extents, bl);
}
DECODE_FINISH(bl);
}

Expand Down
1 change: 1 addition & 0 deletions src/osd/osd_types.h
Expand Up @@ -4479,6 +4479,7 @@ struct object_info_t {
// alloc hint attribute
uint64_t expected_object_size, expected_write_size;
uint32_t alloc_hint_flags;
interval_set<uint64_t> extents; // deduplicated logic extent map

void copy_user_bits(const object_info_t& other);

Expand Down

0 comments on commit 580be10

Please sign in to comment.