Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mon, client: Filter statfs for file systems with a single data pool #16378

Merged
merged 8 commits into from
Aug 8, 2017

Conversation

fullerdj
Copy link
Contributor

No description provided.

Copy link
Contributor

@jcsp jcsp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Let's add an entry to PendingReleaseNotes to publicise it.

@fullerdj
Copy link
Contributor Author

@batrick @jcsp Can we merge this?

@batrick
Copy link
Member

batrick commented Jul 26, 2017

@fullerdj sorry I msised this because of no cephfs label. I'll take a look now.

@batrick batrick added the cephfs Ceph File System label Jul 26, 2017
@fullerdj
Copy link
Contributor Author

looks like it needs a rebase while I'm at it.

Copy link
Member

@batrick batrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall to me but should have a trivial test confirming it works. An extra pool using a few megabytes which is shown not to be included in the statfs on the data pool should suffice?

}

void encode_payload(uint64_t features) override {
paxos_encode();
::encode(fsid, payload);
::encode(data_pool, payload);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this always encoded as an int?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's encoded as a boost::optional. There's a defined encoding for that:

https://github.com/ceph/ceph/blob/master/src/include/encoding.h#L289

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, cool.

@@ -290,11 +291,11 @@ bool MgrStatMonitor::preprocess_getpoolstats(MonOpRequestRef op)
return true;
}

bool MgrStatMonitor::preprocess_statfs(MonOpRequestRef op)
{
bool MgrStatMonitor::preprocess_statfs(MonOpRequestRef op) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary code churn (and conflicts with style of the file).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More likely unnecessary press of the shift key whilst scrolling.

src/mon/PGMap.h Outdated
*/
int64_t get_pool_free_space(const OSDMap &osd_map, int poolid) const;

float pool_raw_used_rate(const OSDMap &osd_map, int poolid) const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not put this as a static function in PGMap.cc?

Copy link
Contributor Author

@fullerdj fullerdj Jul 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the other stats gathering functions are exported. Some of these stats gathering functions are rather new; we seem to be interested in exposing more statistics that rely on telling the user how many more bytes they're allowed to store.

These are certainly only used in PGMap.cc for now, though, so I can move it there if you prefer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just keep it in PGMap.cc for now.

@fullerdj fullerdj force-pushed the wip-djf-19109 branch 2 times, most recently from 087ad1b to da8f820 Compare July 26, 2017 17:35
@fullerdj
Copy link
Contributor Author

For a test, we can just see if the report accounts for replication/ec overhead. I'll come up with something.

Copy link
Member

@liewegas liewegas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few comments, but otherwise this is awesome!

I wonder if it is possible to do this based on the current directory? Linux maps that back to a superblock so no, but the glibc call takes a path name, which means in theory we could look at that directory's layout (vs the whole fs).

MStatfs() : PaxosServiceMessage(CEPH_MSG_STATFS, 0) {}
MStatfs(const uuid_d& f, ceph_tid_t t, version_t v) :
PaxosServiceMessage(CEPH_MSG_STATFS, v), fsid(f) {
MStatfs() : PaxosServiceMessage(CEPH_MSG_STATFS, 0, 2) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use the const definitions at the top of the class like other messages... see e.g.
https://github.com/ceph/ceph/blob/master/src/messages/MOSDOp.h#L36

@@ -22,10 +22,12 @@
class MStatfs : public PaxosServiceMessage {
public:
uuid_d fsid;
boost::optional<int> data_pool;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be int64_t instead of int

ceph_statfs get_statfs() const override {
return digest.get_statfs();
ceph_statfs get_statfs(OSDMap& osdmap,
boost::optional<int> data_pool) const override {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/int/int64_t/

src/mon/PGMap.cc Outdated
@@ -614,6 +614,21 @@ void PGMapDigest::pool_cache_io_rate_summary(Formatter *f, ostream *out,
cache_io_rate_summary(f, out, p->second.first, ts->second);
}

int64_t PGMapDigest::get_pool_free_space(const OSDMap &osd_map,
int poolid) const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int64_t

src/mon/PGMap.h Outdated
statfs.num_objects = pg_sum.stats.sum.num_objects;

if (data_pool) {
const pool_stat_t &stat = pg_pool_sum.at(*data_pool);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably fall back if the pool doesn't exist (e.g., if a client statfs request races with a pool deletion)

@fullerdj fullerdj force-pushed the wip-djf-19109 branch 2 times, most recently from 8a21c5c to 90edb88 Compare July 26, 2017 19:45
@batrick
Copy link
Member

batrick commented Jul 26, 2017

Tracker ticket: http://tracker.ceph.com/issues/19109

@batrick
Copy link
Member

batrick commented Jul 28, 2017

@fullerdj your rebase got screwed up somehow.

@fullerdj
Copy link
Contributor Author

It seems so. I'm writing up a test, so at least this will make sure this PR doesn't get merged beforehand.

@fullerdj
Copy link
Contributor Author

Ok, I've added a test. This should be ready to go.

fs_avail = float(fs_avail) * 1024

ratio = (raw_avail / pool_size) / fs_avail
assert ratio > 0.9 and ratio < 1.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, could just put

assert 0.9 < ratio < 1.1

@fullerdj
Copy link
Contributor Author

fullerdj commented Aug 3, 2017

I'm checking if there's an easy fix for that but maybe you will find it first @fullerdj.

The test is racy. Even though it does conv=fdatasync, that is a nop on fuse. This probably used to work because of the previous dd; although it looks for data_bin_mb + other_bin_mb bytes, but df would have reported data_bin_mb * pool_size bytes used. I'll fix the test.

Bump encoding version accordingly.

Signed-off-by: Douglas Fuller <dfuller@redhat.com>
@fullerdj fullerdj force-pushed the wip-djf-19109 branch 2 times, most recently from 35a640d to ac1c0a3 Compare August 3, 2017 14:21
Douglas Fuller added 5 commits August 3, 2017 14:11
MStatfs now includes an optional data pool element for filesystems
with a single data pool, support this element and return data for
a single data pool if requested.

Signed-off-by: Douglas Fuller <dfuller@redhat.com>
Extend the Objecter's StatfsOp to support MStatfs::data_pool. This
requests statistics for a single data pool in the case of a filesystem
that has exactly one.

Signed-off-by: Douglas Fuller <dfuller@redhat.com>
When statfs() is called for a filesystem with a single data pool,
add that as an argument to receive statistics for that pool only.

Signed-off-by: Douglas Fuller <dfuller@redhat.com>
Signed-off-by: Douglas Fuller <dfuller@redhat.com>
Add a test for filtered df for file systems with single data pools.

Signed-off-by: Douglas Fuller <dfuller@redhat.com>
Signed-off-by: Douglas Fuller <dfuller@redhat.com>
@liewegas
Copy link
Member

liewegas commented Aug 5, 2017

Presumably this was caused by a bad rebase.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
@batrick batrick merged commit 41849fd into ceph:master Aug 8, 2017
batrick added a commit that referenced this pull request Aug 8, 2017
* refs/remotes/upstream/pull/16378/head:
	doc: remove accidental additions to release notes
	qa/cephfs: Fix race in test_volume_client
	qa/cephfs: Test filtered df
	PendingReleaseNotes: add note about df filtering
	client: Support new, filtered MStatfs
	objecter: Support new, filtered MStatfs
	mon/PGMap stats: Support new, filtered MStatfs
	messages: Add optional data pool to MStatfs

Reviewed-by: John Spray <john.spray@redhat.com>
Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
Reviewed-by: Sage Weil <sage@redhat.com>
batrick added a commit that referenced this pull request Aug 8, 2017
* refs/remotes/upstream/pull/16378/head:
	doc: remove accidental additions to release notes
	qa/cephfs: Fix race in test_volume_client
	qa/cephfs: Test filtered df
	PendingReleaseNotes: add note about df filtering
	client: Support new, filtered MStatfs
	objecter: Support new, filtered MStatfs
	mon/PGMap stats: Support new, filtered MStatfs
	messages: Add optional data pool to MStatfs

Reviewed-by: John Spray <john.spray@redhat.com>
Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
Reviewed-by: Sage Weil <sage@redhat.com>
@fullerdj fullerdj deleted the wip-djf-19109 branch August 8, 2017 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants