From patchwork Wed Oct 11 02:37:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Wareing X-Patchwork-Id: 9998483 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 B81F560216 for ; Wed, 11 Oct 2017 02:38:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7C8128806 for ; Wed, 11 Oct 2017 02:38:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CE2128829; Wed, 11 Oct 2017 02:38:29 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 1C75828806 for ; Wed, 11 Oct 2017 02:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932471AbdJKCi2 (ORCPT ); Tue, 10 Oct 2017 22:38:28 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:34558 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932406AbdJKCi2 (ORCPT ); Tue, 10 Oct 2017 22:38:28 -0400 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9B2axYk013470 for ; Tue, 10 Oct 2017 19:38:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=oqojQGZw9BnE2BFMQn79PRcwW9C0EWjNfc+K2yU0Q/s=; b=ireuHsBnp9L91ByuclXuCKtVf2LNRkIsRRHpk5yCuOmMOfOccEF9avfBm5BWxi0LZbeX EBB681eCc5PaHYtZQeyA4GlEoaEH/0w3qF9e0esML0Lr9hZglgKJi2g6WbGXQgkVw9MS cN+Dotwb7cCLTC4pC2zMz0DurpH22otE1t8= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 2dh271tntp-4 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 10 Oct 2017 19:38:27 -0700 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB11.TheFacebook.com (192.168.16.21) with Microsoft SMTP Server id 14.3.319.2; Tue, 10 Oct 2017 19:38:26 -0700 Received: from devbig279.prn1.facebook.com (localhost [127.0.0.1]) by devbig279.prn1.facebook.com (Postfix) with ESMTP id B044F3620C1D; Tue, 10 Oct 2017 19:37:53 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Richard Wareing Smtp-Origin-Hostname: devbig279.prn1.facebook.com To: CC: , , Smtp-Origin-Cluster: prn1c29 Subject: [PATCH v6 1/3] xfs: Show realtime device stats on statfs calls if inherit flag set Date: Tue, 10 Oct 2017 19:37:50 -0700 Message-ID: <20171011023752.1373259-2-rwareing@fb.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171011023752.1373259-1-rwareing@fb.com> References: <20171011023752.1373259-1-rwareing@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-10_08:, , signatures=0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP - Reports realtime device free blocks in statfs calls if inheritance bit is set on the inode of directory. This is a bit more intuitive, especially for use-cases which are using a much larger device for the realtime device. - Add XFS_IS_REALTIME_MOUNT option to gate based on the existence of a realtime device on the mount, similar to the XFS_IS_REALTIME_INODE option. Reviewed-by: Christoph Hellwig Reviewed-by: Dave Chinner Signed-off-by: Richard Wareing --- Changes since v5: * None Changes since v4: * None Changes since v3: * Fixed accounting bug, we are not required to substract m_alloc_set_aside as this is a data device only requirement. * Added XFS_IS_REALTIME_MOUNT macro based on learnings from CVE-2017-14340, now provides similar gating on the mount as XFS_IS_REALTIME_INODE does for the inode. Changes since v2: * Style updated per Christoph Hellwig's comment * Fixed bug: statp->f_bavail = statp->f_bfree fs/xfs/xfs_linux.h | 2 ++ fs/xfs/xfs_super.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h index 044fb0e..fe46e71 100644 --- a/fs/xfs/xfs_linux.h +++ b/fs/xfs/xfs_linux.h @@ -280,8 +280,10 @@ static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y) #ifdef CONFIG_XFS_RT #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) +#define XFS_IS_REALTIME_MOUNT(mp) ((mp)->m_rtdev_targp ? 1 : 0) #else #define XFS_IS_REALTIME_INODE(ip) (0) +#define XFS_IS_REALTIME_MOUNT(mp) (0) #endif #endif /* __XFS_LINUX__ */ diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 455a575..6d33a5e 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1136,6 +1136,14 @@ xfs_fs_statfs( ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) == (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD)) xfs_qm_statvfs(ip, statp); + + if (XFS_IS_REALTIME_MOUNT(mp) && + (ip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)) { + statp->f_blocks = sbp->sb_rblocks; + statp->f_bavail = statp->f_bfree = + sbp->sb_frextents * sbp->sb_rextsize; + } + return 0; }