From patchwork Tue Aug 15 18:54:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Fuller X-Patchwork-Id: 9902381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 11EEA60244 for ; Tue, 15 Aug 2017 18:55:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01B06288D3 for ; Tue, 15 Aug 2017 18:55:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9879288DA; Tue, 15 Aug 2017 18:55:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25324288D3 for ; Tue, 15 Aug 2017 18:55:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751855AbdHOSzM (ORCPT ); Tue, 15 Aug 2017 14:55:12 -0400 Received: from mail-qk0-f177.google.com ([209.85.220.177]:38780 "EHLO mail-qk0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751129AbdHOSzL (ORCPT ); Tue, 15 Aug 2017 14:55:11 -0400 Received: by mail-qk0-f177.google.com with SMTP id x191so8928868qka.5 for ; Tue, 15 Aug 2017 11:55:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=8cxSr1mJmAlE7Urbh78bKxpZuzo2Hnr2rBhLVU+zl1E=; b=GmMCsRP962GPI4W3P5tBrTSaSXDqXskHlm6e2IXrYh7nRdEzf+nGhYNS9PXZ3ZCY8y pTWwZDG/W/iUJDda5j/nGzoftwEBYchw7CEugtrxBGXcRllMEqOIFrQF0FbjMJKtnwl5 1C0eiwMCcFXKtgPeK92ab1eNUToS6ef2sCRLNnSrEECf9pmKCpEEf0Ug76zngqUHGhMX jMcU6vT7X+GSnLwV66UjaHWlhyc+J+2+KMD5heDN0KyM12HxSZ7+o11fZLuv3a+RPZ96 yFJyiqbDROocFLYS724RgUnlZr1Ra0bCzgdTvFrnyYRYcxjGkn4KuZorRzvOwVYNpVAR Z39w== X-Gm-Message-State: AHYfb5h0Kyrr72E2VsMjvt/9Vp5rwExk+4/IcfrQJhOcfLVe4pmy3d3J a/n7M0vExcGeL4+hjEVWlg== X-Received: by 10.55.87.7 with SMTP id l7mr35251941qkb.251.1502823310370; Tue, 15 Aug 2017 11:55:10 -0700 (PDT) Received: from localhost.localdomain (96-38-113-238.dhcp.jcsn.tn.charter.com. [96.38.113.238]) by smtp.gmail.com with ESMTPSA id q127sm6640631qkf.9.2017.08.15.11.55.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 15 Aug 2017 11:55:09 -0700 (PDT) From: Douglas Fuller To: ceph-devel@vger.kernel.org Subject: [PATCH 1/1] fs/ceph: More accurate statfs Date: Tue, 15 Aug 2017 14:54:51 -0400 Message-Id: <04d1b74e1f90539a5bea9d737710ab71039e5eab.1502823001.git.dfuller@redhat.com> X-Mailer: git-send-email 2.11.0 (Apple Git-81) In-Reply-To: References: In-Reply-To: References: Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: "Yan, Zheng" --- 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(-) diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 1deb8810d7c7..75facee8b6d1 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -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; diff --git a/include/linux/ceph/ceph_fs.h b/include/linux/ceph/ceph_fs.h index d1642a4b4c5e..b422170b791a 100644 --- a/include/linux/ceph/ceph_fs.h +++ b/include/linux/ceph/ceph_fs.h @@ -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 { diff --git a/include/linux/ceph/mon_client.h b/include/linux/ceph/mon_client.h index d5a3ecea578d..bd4650ab1248 100644 --- a/include/linux/ceph/mon_client.h +++ b/include/linux/ceph/mon_client.h @@ -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, diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c index 875675765531..5ef21986074e 100644 --- a/net/ceph/mon_client.c +++ b/net/ceph/mon_client.c @@ -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);