Skip to contentSkip to conversation

More accurate statfs

PATCH Superseded Douglas Fuller 3 participants 4 messages Aug 15, 2017 – Aug 16, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover 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.

Douglas Fuller (1):
fs/ceph: More accurate statfs

 fs/ceph/super.c                 | 9 ++++++++-
 include/linux/ceph/ceph_fs.h    | 2 ++
 include/linux/ceph/mon_client.h | 2 +-
 net/ceph/mon_client.c           | 6 +++++-
 4 files changed, 16 insertions(+), 3 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/1 fs/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.

---
 fs/ceph/super.c                 | 9 ++++++++-
 include/linux/ceph/ceph_fs.h    | 2 ++
 include/linux/ceph/mon_client.h | 2 +-
 net/ceph/mon_client.c           | 6 +++++-
 4 files changed, 16 insertions(+), 3 deletions(-)
fs/ceph/super.c +8 -1
index 1deb8810d7c7..75facee8b6d1 100644
@@ -49,9 +49,16 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
 	struct ceph_statfs st;
 	u64 fsid;
 	int err;
+	__le64 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");
-	err = ceph_monc_do_statfs(&fsc->client->monc, &st);
+	err = ceph_monc_do_statfs(&fsc->client->monc, data_pool, &st);
 	if (err < 0)
 		return err;
 
include/linux/ceph/ceph_fs.h +2 -0
index d1642a4b4c5e..b422170b791a 100644
@@ -167,6 +167,8 @@ struct ceph_mon_request_header {
 struct ceph_mon_statfs {
 	struct ceph_mon_request_header monhdr;
 	struct ceph_fsid fsid;
+	__u8 contains_data_pool;
+	__le64 data_pool;
 } __attribute__ ((packed));
 
 struct ceph_statfs {
include/linux/ceph/mon_client.h +1 -1
index d5a3ecea578d..bd4650ab1248 100644
@@ -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,
 				 unsigned long timeout);
 
-extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
+extern int ceph_monc_do_statfs(struct ceph_mon_client *monc, __le64 data_pool,
 			       struct ceph_statfs *buf);
 
 int ceph_monc_get_version(struct ceph_mon_client *monc, const char *what,
net/ceph/mon_client.c +5 -1
index 875675765531..5ef21986074e 100644
@@ -676,7 +676,8 @@ static void handle_statfs_reply(struct ceph_mon_client *monc,
 /*
  * 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, __le64 data_pool,
+			struct ceph_statfs *buf)
 {
 	struct ceph_mon_generic_request *req;
 	struct ceph_mon_statfs *h;
@@ -696,6 +697,7 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
 		goto out;
 
 	req->u.st = buf;
+	req->request->hdr.version = 2;
 
 	mutex_lock(&monc->mutex);
 	register_generic_request(req);
@@ -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_tid = 0;
 	h->fsid = monc->monmap->fsid;
+	h->contains_data_pool = (data_pool != CEPH_NOPOOL);
+	h->data_pool = data_pool;
 	send_generic_request(monc, req);
 	mutex_unlock(&monc->mutex);
 
Signature · 1 line
2.11.0 (Apple Git-81)
Reviewed-by on v1 1/1
#2 lore raw

Re: [PATCH 1/1] fs/ceph: More accurate statfs

Quoted 85 lines · Douglas Fuller

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.

---
 fs/ceph/super.c                 | 9 ++++++++-
 include/linux/ceph/ceph_fs.h    | 2 ++
 include/linux/ceph/mon_client.h | 2 +-
 net/ceph/mon_client.c           | 6 +++++-
 4 files changed, 16 insertions(+), 3 deletions(-)
fs/ceph/super.c +8 -1
index 1deb8810d7c7..75facee8b6d1 100644
@@ -49,9 +49,16 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
        struct ceph_statfs st;
        u64 fsid;
        int err;
+       __le64 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");
-       err = ceph_monc_do_statfs(&fsc->client->monc, &st);
+       err = ceph_monc_do_statfs(&fsc->client->monc, data_pool, &st);
        if (err < 0)
                return err;
 
include/linux/ceph/ceph_fs.h +2 -0
index d1642a4b4c5e..b422170b791a 100644
@@ -167,6 +167,8 @@ struct ceph_mon_request_header {
 struct ceph_mon_statfs {
        struct ceph_mon_request_header monhdr;
        struct ceph_fsid fsid;
+       __u8 contains_data_pool;
+       __le64 data_pool;
 } __attribute__ ((packed));
 
 struct ceph_statfs {
include/linux/ceph/mon_client.h +1 -1
index d5a3ecea578d..bd4650ab1248 100644
@@ -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,
                                 unsigned long timeout);
 
-extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
+extern int ceph_monc_do_statfs(struct ceph_mon_client *monc, __le64 data_pool,
                               struct ceph_statfs *buf);
 
 int ceph_monc_get_version(struct ceph_mon_client *monc, const char *what,
net/ceph/mon_client.c +3 -1
index 875675765531..5ef21986074e 100644
@@ -676,7 +676,8 @@ static void handle_statfs_reply(struct ceph_mon_client *monc,
 /*
  * 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, __le64 data_pool,
+                       struct ceph_statfs *buf)
 {
        struct ceph_mon_generic_request *req;
        struct ceph_mon_statfs *h;
@@ -696,6 +697,7 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
                goto out;
 
        req->u.st = buf;
+       req->request->hdr.version = 2;
 
        mutex_lock(&monc->mutex);
        register_generic_request(req);

net/ceph/mon_client.c int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)

Quoted 9 lines
net/ceph/mon_client.c +2 -1
@@ -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_tid = 0;
        h->fsid = monc->monmap->fsid;
+       h->contains_data_pool = (data_pool != CEPH_NOPOOL);
+       h->data_pool = data_pool;
        send_generic_request(monc, req);
        mutex_unlock(&monc->mutex);
 
--
Quoted 6 lines

2.11.0 (Apple Git-81)

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#3 lore raw

Re: [PATCH 1/1] fs/ceph: More accurate statfs

In reply to Douglas Fuller
Quoted 19 lines · Douglas Fuller

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.

---
 fs/ceph/super.c                 | 9 ++++++++-
 include/linux/ceph/ceph_fs.h    | 2 ++
 include/linux/ceph/mon_client.h | 2 +-
 net/ceph/mon_client.c           | 6 +++++-
 4 files changed, 16 insertions(+), 3 deletions(-)
fs/ceph/super.c +0 -0
index 1deb8810d7c7..75facee8b6d1 100644

fs/ceph/super.c static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf) · line 58

Quoted 10 lines
fs/ceph/super.c +7 -0
@@ -49,9 +49,16 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
        struct ceph_statfs st;
        u64 fsid;
        int err;
+       __le64 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;
+       }

Missing cpu_to_le64() here -- data_pool is __le64, while CEPH_NOPOOL and m_data_pg_pools are in CPU order.

Quoted 48 lines
fs/ceph/super.c +1 -1
        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)
                return err;
 
include/linux/ceph/ceph_fs.h +2 -0
index d1642a4b4c5e..b422170b791a 100644
@@ -167,6 +167,8 @@ struct ceph_mon_request_header {
 struct ceph_mon_statfs {
        struct ceph_mon_request_header monhdr;
        struct ceph_fsid fsid;
+       __u8 contains_data_pool;
+       __le64 data_pool;
 } __attribute__ ((packed));
 
 struct ceph_statfs {
include/linux/ceph/mon_client.h +1 -1
index d5a3ecea578d..bd4650ab1248 100644
@@ -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,
                                 unsigned long timeout);
 
-extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
+extern int ceph_monc_do_statfs(struct ceph_mon_client *monc, __le64 data_pool,
                               struct ceph_statfs *buf);
 
 int ceph_monc_get_version(struct ceph_mon_client *monc, const char *what,
net/ceph/mon_client.c +2 -1
index 875675765531..5ef21986074e 100644
@@ -676,7 +676,8 @@ static void handle_statfs_reply(struct ceph_mon_client *monc,
 /*
  * 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, __le64 data_pool,
+                       struct ceph_statfs *buf)
 {
        struct ceph_mon_generic_request *req;
        struct ceph_mon_statfs *h;

net/ceph/mon_client.c int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf) · line 700

Quoted 4 lines
net/ceph/mon_client.c +1 -0
@@ -696,6 +697,7 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
                goto out;
 
        req->u.st = buf;
+       req->request->hdr.version = 2;

cpu_to_le16(2)

net/ceph/mon_client.c int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf) · line 710

Quoted 8 lines
net/ceph/mon_client.c +1 -0
        mutex_lock(&monc->mutex);
        register_generic_request(req);
@@ -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_tid = 0;
        h->fsid = monc->monmap->fsid;
+       h->contains_data_pool = (data_pool != CEPH_NOPOOL);

... and again here, but the other way around.

net/ceph/mon_client.c int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf) · line 711

Quoted 1 line
net/ceph/mon_client.c +1 -0
+       h->data_pool = data_pool;

I'd make ceph_monc_do_statfs() take u64 and do cpu_to_le64() here, in one place.

Thanks,

Ilya