Commit 06d74376 authored by Douglas Fuller's avatar Douglas Fuller Committed by Ilya Dryomov

ceph: more accurate statfs

Improve accuracy of statfs reporting for Ceph filesystems comprising
exactly one data pool. In this case, the Ceph monitor can now report
the space usage for the single data pool instead of the global data
for the entire Ceph cluster. Include support for this message in
mon_client and leverage it in ceph/super.
Signed-off-by: default avatarDouglas Fuller <dfuller@redhat.com>
Reviewed-by: default avatarYan, Zheng <zyan@redhat.com>
Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 92776fd2
...@@ -49,9 +49,16 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -49,9 +49,16 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
struct ceph_statfs st; struct ceph_statfs st;
u64 fsid; u64 fsid;
int err; int err;
u64 data_pool;
if (fsc->mdsc->mdsmap->m_num_data_pg_pools == 1) {
data_pool = fsc->mdsc->mdsmap->m_data_pg_pools[0];
} else {
data_pool = CEPH_NOPOOL;
}
dout("statfs\n"); dout("statfs\n");
err = ceph_monc_do_statfs(&fsc->client->monc, &st); err = ceph_monc_do_statfs(&fsc->client->monc, data_pool, &st);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -167,6 +167,8 @@ struct ceph_mon_request_header { ...@@ -167,6 +167,8 @@ struct ceph_mon_request_header {
struct ceph_mon_statfs { struct ceph_mon_statfs {
struct ceph_mon_request_header monhdr; struct ceph_mon_request_header monhdr;
struct ceph_fsid fsid; struct ceph_fsid fsid;
__u8 contains_data_pool;
__le64 data_pool;
} __attribute__ ((packed)); } __attribute__ ((packed));
struct ceph_statfs { struct ceph_statfs {
......
...@@ -133,7 +133,7 @@ void ceph_monc_renew_subs(struct ceph_mon_client *monc); ...@@ -133,7 +133,7 @@ void ceph_monc_renew_subs(struct ceph_mon_client *monc);
extern int ceph_monc_wait_osdmap(struct ceph_mon_client *monc, u32 epoch, extern int ceph_monc_wait_osdmap(struct ceph_mon_client *monc, u32 epoch,
unsigned long timeout); unsigned long timeout);
extern int ceph_monc_do_statfs(struct ceph_mon_client *monc, int ceph_monc_do_statfs(struct ceph_mon_client *monc, u64 data_pool,
struct ceph_statfs *buf); struct ceph_statfs *buf);
int ceph_monc_get_version(struct ceph_mon_client *monc, const char *what, int ceph_monc_get_version(struct ceph_mon_client *monc, const char *what,
......
...@@ -676,7 +676,8 @@ static void handle_statfs_reply(struct ceph_mon_client *monc, ...@@ -676,7 +676,8 @@ static void handle_statfs_reply(struct ceph_mon_client *monc,
/* /*
* Do a synchronous statfs(). * Do a synchronous statfs().
*/ */
int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf) int ceph_monc_do_statfs(struct ceph_mon_client *monc, u64 data_pool,
struct ceph_statfs *buf)
{ {
struct ceph_mon_generic_request *req; struct ceph_mon_generic_request *req;
struct ceph_mon_statfs *h; struct ceph_mon_statfs *h;
...@@ -696,6 +697,7 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf) ...@@ -696,6 +697,7 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
goto out; goto out;
req->u.st = buf; req->u.st = buf;
req->request->hdr.version = cpu_to_le16(2);
mutex_lock(&monc->mutex); mutex_lock(&monc->mutex);
register_generic_request(req); register_generic_request(req);
...@@ -705,6 +707,8 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf) ...@@ -705,6 +707,8 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
h->monhdr.session_mon = cpu_to_le16(-1); h->monhdr.session_mon = cpu_to_le16(-1);
h->monhdr.session_mon_tid = 0; h->monhdr.session_mon_tid = 0;
h->fsid = monc->monmap->fsid; h->fsid = monc->monmap->fsid;
h->contains_data_pool = (data_pool != CEPH_NOPOOL);
h->data_pool = cpu_to_le64(data_pool);
send_generic_request(monc, req); send_generic_request(monc, req);
mutex_unlock(&monc->mutex); mutex_unlock(&monc->mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment