From patchwork Mon Apr 1 17:10:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10880451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABA8F922 for ; Mon, 1 Apr 2019 18:07:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94B9A286A0 for ; Mon, 1 Apr 2019 18:07:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88BEF28764; Mon, 1 Apr 2019 18:07:59 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 1D97B286A0 for ; Mon, 1 Apr 2019 18:07:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729661AbfDASHx (ORCPT ); Mon, 1 Apr 2019 14:07:53 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:46416 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730065AbfDARKz (ORCPT ); Mon, 1 Apr 2019 13:10:55 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x31H9HC9134152 for ; Mon, 1 Apr 2019 17:10:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=IFC6EtDlLGHwmCLYyQIA5Fg1PQWddVshgoPjjE3wPjU=; b=GbHQaa59Guemte1vLbEN0tAOXcMoI6KojaBqObRqjaAZDkAzS4oxJ3fescE3byhRZsPJ T/vY97l948xkAHudE+4nc30w8L1BbAPmhWLgiMMnl/OTNJiRcsCal0ZZr77QLcDXe1wi mBnniPSloII7FW9VqLbK/ytTr31hNiFPtPHSUbFafonsPRBu6JXOX3B9xSJcGrp1m+Gn w7fRYPpA88F72vU+04Sv+iHTnViXuf/5MjMZ7fFPouDsixfjZq/4OouqudyaY8cc4C2P ny4WuVtiMpvl0LhpFlf4w/n2pdoWd2Dv9cRaZJZcODwBy76fyAcMsbSeOhooEmJ6xRlG kg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2rhwyd0gm5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 01 Apr 2019 17:10:53 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x31HAlSe015315 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 1 Apr 2019 17:10:48 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x31HAlFE016998 for ; Mon, 1 Apr 2019 17:10:47 GMT Received: from localhost (/10.159.239.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Apr 2019 10:10:47 -0700 Subject: [PATCH 06/10] xfs: report fs and rt health via geometry structure From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 01 Apr 2019 10:10:46 -0700 Message-ID: <155413864658.4966.5585966135005160342.stgit@magnolia> In-Reply-To: <155413860964.4966.6087725033542837255.stgit@magnolia> References: <155413860964.4966.6087725033542837255.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9214 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904010112 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 From: Darrick J. Wong Use our newly expanded geometry structure to report the overall fs and realtime health status. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_fs.h | 11 ++++++++++- fs/xfs/libxfs/xfs_health.h | 3 +++ fs/xfs/xfs_health.c | 27 +++++++++++++++++++++++++++ fs/xfs/xfs_ioctl.c | 3 +++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 87226e00e7bd..ddbfde7ff79d 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -199,9 +199,18 @@ typedef struct xfs_fsop_geom { __u32 rtsectsize; /* realtime sector size, bytes */ __u32 dirblocksize; /* directory block size, bytes */ __u32 logsunit; /* log stripe unit, bytes */ - __u64 reserved[18]; /* reserved space */ + __u32 health; /* o: unhealthy fs & rt metadata */ + __u32 reserved32; /* reserved space */ + __u64 reserved[17]; /* reserved space */ } xfs_fsop_geom_t; +#define XFS_FSOP_GEOM_HEALTH_FS_COUNTERS (1 << 0) /* summary counters */ +#define XFS_FSOP_GEOM_HEALTH_FS_UQUOTA (1 << 1) /* user quota */ +#define XFS_FSOP_GEOM_HEALTH_FS_GQUOTA (1 << 2) /* group quota */ +#define XFS_FSOP_GEOM_HEALTH_FS_PQUOTA (1 << 3) /* project quota */ +#define XFS_FSOP_GEOM_HEALTH_RT_BITMAP (1 << 4) /* realtime bitmap */ +#define XFS_FSOP_GEOM_HEALTH_RT_SUMMARY (1 << 5) /* realtime summary */ + /* Output for XFS_FS_COUNTS */ typedef struct xfs_fsop_counts { __u64 freedata; /* free data section blocks */ diff --git a/fs/xfs/libxfs/xfs_health.h b/fs/xfs/libxfs/xfs_health.h index 269b124dc1d7..36736d54a3e3 100644 --- a/fs/xfs/libxfs/xfs_health.h +++ b/fs/xfs/libxfs/xfs_health.h @@ -39,6 +39,7 @@ struct xfs_mount; struct xfs_perag; struct xfs_inode; +struct xfs_fsop_geom; /* Observable health issues for metadata spanning the entire filesystem. */ #define XFS_HEALTH_FS_COUNTERS (1 << 0) /* summary counters */ @@ -200,4 +201,6 @@ xfs_inode_healthy(struct xfs_inode *ip) return xfs_inode_measure_sickness(ip) == 0; } +void xfs_fsop_geom_health(struct xfs_mount *mp, struct xfs_fsop_geom *geo); + #endif /* __XFS_HEALTH_H__ */ diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c index 6e2da858c356..151c98693bef 100644 --- a/fs/xfs/xfs_health.c +++ b/fs/xfs/xfs_health.c @@ -249,3 +249,30 @@ xfs_inode_measure_sickness( spin_unlock(&ip->i_flags_lock); return ret; } + +/* Fill out fs geometry health info. */ +void +xfs_fsop_geom_health( + struct xfs_mount *mp, + struct xfs_fsop_geom *geo) +{ + unsigned int sick; + + geo->health = 0; + + sick = xfs_fs_measure_sickness(mp); + if (sick & XFS_HEALTH_FS_COUNTERS) + geo->health |= XFS_FSOP_GEOM_HEALTH_FS_COUNTERS; + if (sick & XFS_HEALTH_FS_UQUOTA) + geo->health |= XFS_FSOP_GEOM_HEALTH_FS_UQUOTA; + if (sick & XFS_HEALTH_FS_GQUOTA) + geo->health |= XFS_FSOP_GEOM_HEALTH_FS_GQUOTA; + if (sick & XFS_HEALTH_FS_PQUOTA) + geo->health |= XFS_FSOP_GEOM_HEALTH_FS_PQUOTA; + + sick = xfs_rt_measure_sickness(mp); + if (sick & XFS_HEALTH_RT_BITMAP) + geo->health |= XFS_FSOP_GEOM_HEALTH_RT_BITMAP; + if (sick & XFS_HEALTH_RT_SUMMARY) + geo->health |= XFS_FSOP_GEOM_HEALTH_RT_SUMMARY; +} diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index b5918ce656bd..f9bf11b6a055 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -34,6 +34,7 @@ #include "scrub/xfs_scrub.h" #include "xfs_sb.h" #include "xfs_ag.h" +#include "xfs_health.h" #include #include @@ -830,6 +831,8 @@ xfs_ioc_fsgeometry( if (error) return error; + xfs_fsop_geom_health(mp, &fsgeo); + if (copy_to_user(arg, &fsgeo, sizeof(fsgeo))) return -EFAULT; return 0;