Skip to content

Commit 06d7437

Browse files
Douglas Fulleridryomov
authored andcommitted
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: Douglas Fuller <[email protected]> Reviewed-by: Yan, Zheng <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 92776fd commit 06d7437

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

fs/ceph/super.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,16 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
4949
struct ceph_statfs st;
5050
u64 fsid;
5151
int err;
52+
u64 data_pool;
53+
54+
if (fsc->mdsc->mdsmap->m_num_data_pg_pools == 1) {
55+
data_pool = fsc->mdsc->mdsmap->m_data_pg_pools[0];
56+
} else {
57+
data_pool = CEPH_NOPOOL;
58+
}
5259

5360
dout("statfs\n");
54-
err = ceph_monc_do_statfs(&fsc->client->monc, &st);
61+
err = ceph_monc_do_statfs(&fsc->client->monc, data_pool, &st);
5562
if (err < 0)
5663
return err;
5764

include/linux/ceph/ceph_fs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ struct ceph_mon_request_header {
167167
struct ceph_mon_statfs {
168168
struct ceph_mon_request_header monhdr;
169169
struct ceph_fsid fsid;
170+
__u8 contains_data_pool;
171+
__le64 data_pool;
170172
} __attribute__ ((packed));
171173

172174
struct ceph_statfs {

include/linux/ceph/mon_client.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ void ceph_monc_renew_subs(struct ceph_mon_client *monc);
133133
extern int ceph_monc_wait_osdmap(struct ceph_mon_client *monc, u32 epoch,
134134
unsigned long timeout);
135135

136-
extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
137-
struct ceph_statfs *buf);
136+
int ceph_monc_do_statfs(struct ceph_mon_client *monc, u64 data_pool,
137+
struct ceph_statfs *buf);
138138

139139
int ceph_monc_get_version(struct ceph_mon_client *monc, const char *what,
140140
u64 *newest);

net/ceph/mon_client.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,8 @@ static void handle_statfs_reply(struct ceph_mon_client *monc,
676676
/*
677677
* Do a synchronous statfs().
678678
*/
679-
int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
679+
int ceph_monc_do_statfs(struct ceph_mon_client *monc, u64 data_pool,
680+
struct ceph_statfs *buf)
680681
{
681682
struct ceph_mon_generic_request *req;
682683
struct ceph_mon_statfs *h;
@@ -696,6 +697,7 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
696697
goto out;
697698

698699
req->u.st = buf;
700+
req->request->hdr.version = cpu_to_le16(2);
699701

700702
mutex_lock(&monc->mutex);
701703
register_generic_request(req);
@@ -705,6 +707,8 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
705707
h->monhdr.session_mon = cpu_to_le16(-1);
706708
h->monhdr.session_mon_tid = 0;
707709
h->fsid = monc->monmap->fsid;
710+
h->contains_data_pool = (data_pool != CEPH_NOPOOL);
711+
h->data_pool = cpu_to_le64(data_pool);
708712
send_generic_request(monc, req);
709713
mutex_unlock(&monc->mutex);
710714

0 commit comments

Comments
 (0)