From patchwork Mon Apr 1 17:10:15 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: 10880457 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 AE45D922 for ; Mon, 1 Apr 2019 18:08:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94709286A0 for ; Mon, 1 Apr 2019 18:08:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8900D28764; Mon, 1 Apr 2019 18:08:26 +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 61697286A0 for ; Mon, 1 Apr 2019 18:08:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728992AbfDASIY (ORCPT ); Mon, 1 Apr 2019 14:08:24 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:59712 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729924AbfDARKV (ORCPT ); Mon, 1 Apr 2019 13:10:21 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x31H9GZl131412 for ; Mon, 1 Apr 2019 17:10:19 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=zTWGs//CcjbitG1e8Bg5QK1wb3QshaBEE6LryCtZkLI=; b=5IElK6ewg+xv5ixKtOn4waxKpbEG4dfqnzcMe4rVPU3FhuT0YwhQyiWsoF1yAw6YCdQW 1kZxuZdQE+eXXw7uYkEKXHcGKRWchQShjoId39NAuHZinIgxyLtISKEb0iQPsKBpCd4c YZrdtAtCa/qDEw5b2PTmgCwFJIvElhwz5eG1zn7XPvKApNT1O/B8vIAWItwDwcSfqrYf p4Wor8E/3gJTC6yDJq2otXF5vQOEw1AmTQ7pDdQQMfuihn9DobJd/OR5s6cupAoLW+9Q QlyOjZw0nBm6b+AtefW7w4IBXXDnF9TE5irQmeKAdXI7F2DsaF+l6YBEIb/ENu5h2qHE ig== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2rhyvt0cs0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 01 Apr 2019 17:10:18 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x31HAHP3011207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 1 Apr 2019 17:10:17 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x31HAGvL017472 for ; Mon, 1 Apr 2019 17:10:17 GMT Received: from localhost (/10.159.239.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Apr 2019 10:10:16 -0700 Subject: [PATCH 01/10] xfs: track metadata health levels From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 01 Apr 2019 10:10:15 -0700 Message-ID: <155413861577.4966.12311071928325570886.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 Add the necessary in-core metadata fields to keep track of which parts of the filesystem have been observed to be unhealthy, and print a warning at unmount time if we have unfixed problems. Signed-off-by: Darrick J. Wong --- fs/xfs/Makefile | 1 fs/xfs/libxfs/xfs_health.h | 201 ++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_health.c | 192 ++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_inode.h | 7 ++ fs/xfs/xfs_mount.c | 1 fs/xfs/xfs_mount.h | 23 +++++ fs/xfs/xfs_trace.h | 73 ++++++++++++++++ 7 files changed, 498 insertions(+) create mode 100644 fs/xfs/libxfs/xfs_health.h create mode 100644 fs/xfs/xfs_health.c diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 7f96bdadc372..786379c143f4 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -73,6 +73,7 @@ xfs-y += xfs_aops.o \ xfs_fsmap.o \ xfs_fsops.o \ xfs_globals.o \ + xfs_health.o \ xfs_icache.o \ xfs_ioctl.o \ xfs_iomap.o \ diff --git a/fs/xfs/libxfs/xfs_health.h b/fs/xfs/libxfs/xfs_health.h new file mode 100644 index 000000000000..0d51bd2689ea --- /dev/null +++ b/fs/xfs/libxfs/xfs_health.h @@ -0,0 +1,201 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#ifndef __XFS_HEALTH_H__ +#define __XFS_HEALTH_H__ + +/* + * In-Core Filesystem Health Assessments + * ===================================== + * + * We'd like to be able to summarize the current health status of the + * filesystem so that the administrator knows when it's necessary to schedule + * some downtime for repairs. Until then, we would also like to avoid abrupt + * shutdowns due to corrupt metadata. + * + * The online scrub feature evaluates the health of all filesystem metadata. + * When scrub detects corruption in a piece of metadata it will set the + * corresponding sickness flag, and repair will clear it if successful. + * + * If problems remain at unmount time, we can also request manual intervention + * by logging a notice to run xfs_repair. + * + * Evidence of health problems can be sorted into three basic categories: + * + * a) Primary evidence, which signals that something is defective within the + * general grouping of metadata. + * + * b) Secondary evidence, which are side effects of primary problem but are + * not themselves problems. These can be forgotten when the primary + * health problems are addressed. + * + * c) Indirect evidence, which points to something being wrong in another + * group, but we had to release resources and this is all that's left of + * that state. + */ + +struct xfs_mount; +struct xfs_perag; +struct xfs_inode; + +/* Observable health issues for metadata spanning the entire filesystem. */ +#define XFS_HEALTH_FS_COUNTERS (1 << 0) /* summary counters */ +#define XFS_HEALTH_FS_UQUOTA (1 << 1) /* user quota */ +#define XFS_HEALTH_FS_GQUOTA (1 << 2) /* group quota */ +#define XFS_HEALTH_FS_PQUOTA (1 << 3) /* project quota */ + +/* Observable health issues for realtime volume metadata. */ +#define XFS_HEALTH_RT_BITMAP (1 << 0) /* realtime bitmap */ +#define XFS_HEALTH_RT_SUMMARY (1 << 1) /* realtime summary */ + +/* Observable health issues for AG metadata. */ +#define XFS_HEALTH_AG_SB (1 << 0) /* superblock */ +#define XFS_HEALTH_AG_AGF (1 << 1) /* AGF header */ +#define XFS_HEALTH_AG_AGFL (1 << 2) /* AGFL header */ +#define XFS_HEALTH_AG_AGI (1 << 3) /* AGI header */ +#define XFS_HEALTH_AG_BNOBT (1 << 4) /* free space by block */ +#define XFS_HEALTH_AG_CNTBT (1 << 5) /* free space by length */ +#define XFS_HEALTH_AG_INOBT (1 << 6) /* inode index */ +#define XFS_HEALTH_AG_FINOBT (1 << 7) /* free inode index */ +#define XFS_HEALTH_AG_RMAPBT (1 << 8) /* reverse mappings */ +#define XFS_HEALTH_AG_REFCNTBT (1 << 9) /* reference counts */ + +/* Observable health issues for inode metadata. */ +#define XFS_HEALTH_INO_CORE (1 << 0) /* inode core */ +#define XFS_HEALTH_INO_BMBTD (1 << 1) /* data fork */ +#define XFS_HEALTH_INO_BMBTA (1 << 2) /* attr fork */ +#define XFS_HEALTH_INO_BMBTC (1 << 3) /* cow fork */ +#define XFS_HEALTH_INO_DIR (1 << 4) /* directory */ +#define XFS_HEALTH_INO_XATTR (1 << 5) /* extended attributes */ +#define XFS_HEALTH_INO_SYMLINK (1 << 6) /* symbolic link remote target */ +#define XFS_HEALTH_INO_PARENT (1 << 7) /* parent pointers */ + +/* Primary evidence of health problems in a given group. */ +#define XFS_HEALTH_FS_PRIMARY (XFS_HEALTH_FS_COUNTERS | \ + XFS_HEALTH_FS_UQUOTA | \ + XFS_HEALTH_FS_GQUOTA | \ + XFS_HEALTH_FS_PQUOTA) + +#define XFS_HEALTH_RT_PRIMARY (XFS_HEALTH_RT_BITMAP | \ + XFS_HEALTH_RT_SUMMARY) + +#define XFS_HEALTH_AG_PRIMARY (XFS_HEALTH_AG_SB | \ + XFS_HEALTH_AG_AGF | \ + XFS_HEALTH_AG_AGFL | \ + XFS_HEALTH_AG_AGI | \ + XFS_HEALTH_AG_BNOBT | \ + XFS_HEALTH_AG_CNTBT | \ + XFS_HEALTH_AG_INOBT | \ + XFS_HEALTH_AG_FINOBT | \ + XFS_HEALTH_AG_RMAPBT | \ + XFS_HEALTH_AG_REFCNTBT) + +#define XFS_HEALTH_INO_PRIMARY (XFS_HEALTH_INO_CORE | \ + XFS_HEALTH_INO_BMBTD | \ + XFS_HEALTH_INO_BMBTA | \ + XFS_HEALTH_INO_BMBTC | \ + XFS_HEALTH_INO_DIR | \ + XFS_HEALTH_INO_XATTR | \ + XFS_HEALTH_INO_SYMLINK | \ + XFS_HEALTH_INO_PARENT) + +/* Secondary state related to (but not primary evidence of) health problems. */ +#define XFS_HEALTH_FS_SECONDARY (0) +#define XFS_HEALTH_RT_SECONDARY (0) +#define XFS_HEALTH_AG_SECONDARY (0) +#define XFS_HEALTH_INO_SECONDARY (0) + +/* Evidence of health problems elsewhere. */ +#define XFS_HEALTH_FS_INDIRECT (0) +#define XFS_HEALTH_RT_INDIRECT (0) +#define XFS_HEALTH_AG_INDIRECT (0) +#define XFS_HEALTH_INO_INDIRECT (0) + +/* All health masks. */ +#define XFS_HEALTH_FS_ALL (XFS_HEALTH_FS_PRIMARY | \ + XFS_HEALTH_FS_SECONDARY | \ + XFS_HEALTH_FS_INDIRECT) + +#define XFS_HEALTH_RT_ALL (XFS_HEALTH_RT_PRIMARY | \ + XFS_HEALTH_RT_SECONDARY | \ + XFS_HEALTH_RT_INDIRECT) + +#define XFS_HEALTH_AG_ALL (XFS_HEALTH_AG_PRIMARY | \ + XFS_HEALTH_AG_SECONDARY | \ + XFS_HEALTH_AG_INDIRECT) + +#define XFS_HEALTH_INO_ALL (XFS_HEALTH_INO_PRIMARY | \ + XFS_HEALTH_INO_SECONDARY | \ + XFS_HEALTH_INO_INDIRECT) + +/* These functions must be provided by the xfs implementation. */ + +void xfs_fs_mark_sick(struct xfs_mount *mp, unsigned int mask); +void xfs_fs_mark_healthy(struct xfs_mount *mp, unsigned int mask); +unsigned int xfs_fs_measure_sickness(struct xfs_mount *mp); + +void xfs_rt_mark_sick(struct xfs_mount *mp, unsigned int mask); +void xfs_rt_mark_healthy(struct xfs_mount *mp, unsigned int mask); +unsigned int xfs_rt_measure_sickness(struct xfs_mount *mp); + +void xfs_ag_mark_sick(struct xfs_perag *pag, unsigned int mask); +void xfs_ag_mark_healthy(struct xfs_perag *pag, unsigned int mask); +unsigned int xfs_ag_measure_sickness(struct xfs_perag *pag); + +void xfs_inode_mark_sick(struct xfs_inode *ip, unsigned int mask); +void xfs_inode_mark_healthy(struct xfs_inode *ip, unsigned int mask); +unsigned int xfs_inode_measure_sickness(struct xfs_inode *ip); + +/* Now some helpers. */ + +static inline bool +xfs_fs_is_sick(struct xfs_mount *mp, unsigned int mask) +{ + return (xfs_fs_measure_sickness(mp) & mask) != 0; +} + +static inline bool +xfs_rt_is_sick(struct xfs_mount *mp, unsigned int mask) +{ + return (xfs_rt_measure_sickness(mp) & mask) != 0; +} + +static inline bool +xfs_ag_is_sick(struct xfs_perag *pag, unsigned int mask) +{ + return (xfs_ag_measure_sickness(pag) & mask) != 0; +} + +static inline bool +xfs_inode_is_sick(struct xfs_inode *ip, unsigned int mask) +{ + return (xfs_inode_measure_sickness(ip) & mask) != 0; +} + +static inline bool +xfs_fs_healthy(struct xfs_mount *mp) +{ + return xfs_fs_measure_sickness(mp) == 0; +} + +static inline bool +xfs_rt_healthy(struct xfs_mount *mp) +{ + return xfs_rt_measure_sickness(mp) == 0; +} + +static inline bool +xfs_ag_healthy(struct xfs_perag *pag) +{ + return xfs_ag_measure_sickness(pag) == 0; +} + +static inline bool +xfs_inode_healthy(struct xfs_inode *ip) +{ + return xfs_inode_measure_sickness(ip) == 0; +} + +#endif /* __XFS_HEALTH_H__ */ diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c new file mode 100644 index 000000000000..e9d6859f7501 --- /dev/null +++ b/fs/xfs/xfs_health.c @@ -0,0 +1,192 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_shared.h" +#include "xfs_format.h" +#include "xfs_log_format.h" +#include "xfs_trans_resv.h" +#include "xfs_bit.h" +#include "xfs_sb.h" +#include "xfs_mount.h" +#include "xfs_defer.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_inode.h" +#include "xfs_trace.h" +#include "xfs_health.h" + +/* Mark unhealthy per-fs metadata. */ +void +xfs_fs_mark_sick( + struct xfs_mount *mp, + unsigned int mask) +{ + ASSERT(!(mask & ~XFS_HEALTH_FS_ALL)); + trace_xfs_fs_mark_sick(mp, mask); + + spin_lock(&mp->m_sb_lock); + mp->m_sick |= mask; + spin_unlock(&mp->m_sb_lock); +} + +/* Mark a per-fs metadata healed. */ +void +xfs_fs_mark_healthy( + struct xfs_mount *mp, + unsigned int mask) +{ + ASSERT(!(mask & ~XFS_HEALTH_FS_ALL)); + trace_xfs_fs_mark_healthy(mp, mask); + + spin_lock(&mp->m_sb_lock); + mp->m_sick &= ~mask; + if (!(mp->m_sick & XFS_HEALTH_FS_PRIMARY)) + mp->m_sick &= ~XFS_HEALTH_FS_SECONDARY; + spin_unlock(&mp->m_sb_lock); +} + +/* Sample which per-fs metadata are unhealthy. */ +unsigned int +xfs_fs_measure_sickness( + struct xfs_mount *mp) +{ + unsigned int ret; + + spin_lock(&mp->m_sb_lock); + ret = mp->m_sick; + spin_unlock(&mp->m_sb_lock); + return ret; +} + +/* Mark unhealthy realtime metadata. */ +void +xfs_rt_mark_sick( + struct xfs_mount *mp, + unsigned int mask) +{ + ASSERT(!(mask & ~XFS_HEALTH_RT_ALL)); + trace_xfs_rt_mark_sick(mp, mask); + + spin_lock(&mp->m_sb_lock); + mp->m_rt_sick |= mask; + spin_unlock(&mp->m_sb_lock); +} + +/* Mark a realtime metadata healed. */ +void +xfs_rt_mark_healthy( + struct xfs_mount *mp, + unsigned int mask) +{ + ASSERT(!(mask & ~XFS_HEALTH_RT_ALL)); + trace_xfs_rt_mark_healthy(mp, mask); + + spin_lock(&mp->m_sb_lock); + mp->m_rt_sick &= ~mask; + if (!(mp->m_rt_sick & XFS_HEALTH_RT_PRIMARY)) + mp->m_rt_sick &= ~XFS_HEALTH_RT_SECONDARY; + spin_unlock(&mp->m_sb_lock); +} + +/* Sample which realtime metadata are unhealthy. */ +unsigned int +xfs_rt_measure_sickness( + struct xfs_mount *mp) +{ + unsigned int ret; + + spin_lock(&mp->m_sb_lock); + ret = mp->m_rt_sick; + spin_unlock(&mp->m_sb_lock); + return ret; +} + +/* Mark unhealthy per-ag metadata. */ +void +xfs_ag_mark_sick( + struct xfs_perag *pag, + unsigned int mask) +{ + ASSERT(!(mask & ~XFS_HEALTH_AG_ALL)); + trace_xfs_ag_mark_sick(pag->pag_mount, pag->pag_agno, mask); + + spin_lock(&pag->pag_state_lock); + pag->pag_sick |= mask; + spin_unlock(&pag->pag_state_lock); +} + +/* Mark per-ag metadata ok. */ +void +xfs_ag_mark_healthy( + struct xfs_perag *pag, + unsigned int mask) +{ + ASSERT(!(mask & ~XFS_HEALTH_AG_ALL)); + trace_xfs_ag_mark_healthy(pag->pag_mount, pag->pag_agno, mask); + + spin_lock(&pag->pag_state_lock); + pag->pag_sick &= ~mask; + if (!(pag->pag_sick & XFS_HEALTH_AG_PRIMARY)) + pag->pag_sick &= ~XFS_HEALTH_AG_SECONDARY; + spin_unlock(&pag->pag_state_lock); +} + +/* Sample which per-ag metadata are unhealthy. */ +unsigned int +xfs_ag_measure_sickness( + struct xfs_perag *pag) +{ + unsigned int ret; + + spin_lock(&pag->pag_state_lock); + ret = pag->pag_sick; + spin_unlock(&pag->pag_state_lock); + return ret; +} + +/* Mark the unhealthy parts of an inode. */ +void +xfs_inode_mark_sick( + struct xfs_inode *ip, + unsigned int mask) +{ + ASSERT(!(mask & ~XFS_HEALTH_INO_ALL)); + trace_xfs_inode_mark_sick(ip, mask); + + spin_lock(&ip->i_flags_lock); + ip->i_sick |= mask; + spin_unlock(&ip->i_flags_lock); +} + +/* Mark parts of an inode healed. */ +void +xfs_inode_mark_healthy( + struct xfs_inode *ip, + unsigned int mask) +{ + ASSERT(!(mask & ~XFS_HEALTH_INO_ALL)); + trace_xfs_inode_mark_healthy(ip, mask); + + spin_lock(&ip->i_flags_lock); + ip->i_sick &= ~mask; + if (!(ip->i_sick & XFS_HEALTH_INO_PRIMARY)) + ip->i_sick &= ~XFS_HEALTH_INO_SECONDARY; + spin_unlock(&ip->i_flags_lock); +} + +/* Sample which parts of an inode are unhealthy. */ +unsigned int +xfs_inode_measure_sickness( + struct xfs_inode *ip) +{ + unsigned int ret; + + spin_lock(&ip->i_flags_lock); + ret = ip->i_sick; + spin_unlock(&ip->i_flags_lock); + return ret; +} diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 88239c2dd824..877acdd5f026 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -45,6 +45,13 @@ typedef struct xfs_inode { mrlock_t i_lock; /* inode lock */ mrlock_t i_mmaplock; /* inode mmap IO lock */ atomic_t i_pincount; /* inode pin count */ + + /* + * Bitset noting which parts of an inode are not healthy. + * Callers must hold i_flags_lock before accessing this field. + */ + unsigned int i_sick; + spinlock_t i_flags_lock; /* inode i_flags lock */ /* Miscellaneous state. */ unsigned long i_flags; /* see defined flags below */ diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 950752e5ec2c..fc1f24dd0386 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -231,6 +231,7 @@ xfs_initialize_perag( error = xfs_iunlink_init(pag); if (error) goto out_hash_destroy; + spin_lock_init(&pag->pag_state_lock); } index = xfs_set_inode_alloc(mp, agcount); diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 15dc02964113..63bbafb01eb5 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -60,6 +60,13 @@ struct xfs_error_cfg { typedef struct xfs_mount { struct super_block *m_super; xfs_tid_t m_tid; /* next unused tid for fs */ + + /* + * Bitset of unhealthy per-fs metadata. + * Callers must hold m_sb_lock to access this field. + */ + unsigned int m_sick; + struct xfs_ail *m_ail; /* fs active log item list */ struct xfs_sb m_sb; /* copy of fs superblock */ @@ -71,6 +78,11 @@ typedef struct xfs_mount { struct xfs_buf *m_sb_bp; /* buffer for superblock */ char *m_fsname; /* filesystem name */ int m_fsname_len; /* strlen of fs name */ + /* + * Bitset of unhealthy rt volume metadata. + * Callers must hold m_sb_lock to access this field. + */ + unsigned int m_rt_sick; char *m_rtname; /* realtime device name */ char *m_logname; /* external log device name */ int m_bsize; /* fs logical block size */ @@ -389,6 +401,17 @@ typedef struct xfs_perag { * or have some other means to control concurrency. */ struct rhashtable pagi_unlinked_hash; + + /* Spinlock to protect in-core per-ag state */ + spinlock_t pag_state_lock; + + /* + * Bitset of unhealthy AG metadata. + * + * Callers should hold pag_state_lock and the relevant AG header buffer + * lock before accessing this field. + */ + unsigned int pag_sick; } xfs_perag_t; static inline struct xfs_ag_resv * diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 47fb07d86efd..f079841c7af6 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -3440,6 +3440,79 @@ DEFINE_AGINODE_EVENT(xfs_iunlink); DEFINE_AGINODE_EVENT(xfs_iunlink_remove); DEFINE_AG_EVENT(xfs_iunlink_map_prev_fallback); +DECLARE_EVENT_CLASS(xfs_fs_corrupt_class, + TP_PROTO(struct xfs_mount *mp, unsigned int flags), + TP_ARGS(mp, flags), + TP_STRUCT__entry( + __field(dev_t, dev) + __field(unsigned int, flags) + ), + TP_fast_assign( + __entry->dev = mp->m_super->s_dev; + __entry->flags = flags; + ), + TP_printk("dev %d:%d flags 0x%x", + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->flags) +); +#define DEFINE_FS_CORRUPT_EVENT(name) \ +DEFINE_EVENT(xfs_fs_corrupt_class, name, \ + TP_PROTO(struct xfs_mount *mp, unsigned int flags), \ + TP_ARGS(mp, flags)) +DEFINE_FS_CORRUPT_EVENT(xfs_fs_mark_sick); +DEFINE_FS_CORRUPT_EVENT(xfs_fs_mark_healthy); +DEFINE_FS_CORRUPT_EVENT(xfs_rt_mark_sick); +DEFINE_FS_CORRUPT_EVENT(xfs_rt_mark_healthy); + +DECLARE_EVENT_CLASS(xfs_ag_corrupt_class, + TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, unsigned int flags), + TP_ARGS(mp, agno, flags), + TP_STRUCT__entry( + __field(dev_t, dev) + __field(xfs_agnumber_t, agno) + __field(unsigned int, flags) + ), + TP_fast_assign( + __entry->dev = mp->m_super->s_dev; + __entry->agno = agno; + __entry->flags = flags; + ), + TP_printk("dev %d:%d agno %u flags 0x%x", + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->agno, __entry->flags) +); +#define DEFINE_AG_CORRUPT_EVENT(name) \ +DEFINE_EVENT(xfs_ag_corrupt_class, name, \ + TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \ + unsigned int flags), \ + TP_ARGS(mp, agno, flags)) +DEFINE_AG_CORRUPT_EVENT(xfs_ag_mark_sick); +DEFINE_AG_CORRUPT_EVENT(xfs_ag_mark_healthy); + +DECLARE_EVENT_CLASS(xfs_inode_corrupt_class, + TP_PROTO(struct xfs_inode *ip, unsigned int flags), + TP_ARGS(ip, flags), + TP_STRUCT__entry( + __field(dev_t, dev) + __field(xfs_ino_t, ino) + __field(unsigned int, flags) + ), + TP_fast_assign( + __entry->dev = ip->i_mount->m_super->s_dev; + __entry->ino = ip->i_ino; + __entry->flags = flags; + ), + TP_printk("dev %d:%d ino 0x%llx flags 0x%x", + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->ino, __entry->flags) +); +#define DEFINE_INODE_CORRUPT_EVENT(name) \ +DEFINE_EVENT(xfs_inode_corrupt_class, name, \ + TP_PROTO(struct xfs_inode *ip, unsigned int flags), \ + TP_ARGS(ip, flags)) +DEFINE_INODE_CORRUPT_EVENT(xfs_inode_mark_sick); +DEFINE_INODE_CORRUPT_EVENT(xfs_inode_mark_healthy); + #endif /* _TRACE_XFS_H */ #undef TRACE_INCLUDE_PATH From patchwork Mon Apr 1 17:10:21 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: 10880357 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 744D617E1 for ; Mon, 1 Apr 2019 17:10:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D569287B1 for ; Mon, 1 Apr 2019 17:10:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B19428796; Mon, 1 Apr 2019 17:10:28 +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 CD959287B8 for ; Mon, 1 Apr 2019 17:10:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729642AbfDARK0 (ORCPT ); Mon, 1 Apr 2019 13:10:26 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:45848 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729415AbfDARKY (ORCPT ); Mon, 1 Apr 2019 13:10:24 -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 x31H9JWD134175 for ; Mon, 1 Apr 2019 17:10:23 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=p/oMjki7jE/jcL5UvRhh3xV0w+zL2riDRUOQUoxSPes=; b=RklXcJT/vkhgpybtBS2QBj6n6mfrSU0FmUg8wWF2TPWzu+7N38A1gIwcCGYqA5GFaipd eN9DgXsavbjhxjKpl53nZiAgksoxyYir+pnwe83v/QSGlO4TemHEwVF+yZ/a557gFmsZ JW4+DTYOcjjJ1XsRNwgzTKBJ09Z2nGqT6vQ0p7t/uyR3qK3ScOLyvDUDZNWmsShS+jgr 6r8pkooU3ZTYAf+j3SHa8UnBJbJAHQdUnb4rs49BTkGYPdCmvdwKEZQsK656gaV96OMJ sjooLmyUHAe7Bldn5Mrc3Pt5tK/L9OAcGLRX3aFBVryrhd18z1wnLZDpPC0kGZW9AV8g nw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2rhwyd0ghs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 01 Apr 2019 17:10:23 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x31HANZa011932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 1 Apr 2019 17:10:23 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x31HANDj011499 for ; Mon, 1 Apr 2019 17:10:23 GMT Received: from localhost (/10.159.239.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Apr 2019 10:10:22 -0700 Subject: [PATCH 02/10] xfs: replace the BAD_SUMMARY mount flag with the equivalent health code From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 01 Apr 2019 10:10:21 -0700 Message-ID: <155413862191.4966.10871732453060652442.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=1 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 Replace the BAD_SUMMARY mount flag with calls to the equivalent health tracking code. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_sb.c | 5 +++-- fs/xfs/xfs_log.c | 3 ++- fs/xfs/xfs_mount.c | 9 ++++----- fs/xfs/xfs_mount.h | 1 - 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index f96b1997938e..f0309b74e377 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -30,6 +30,7 @@ #include "xfs_refcount_btree.h" #include "xfs_da_format.h" #include "xfs_da_btree.h" +#include "xfs_health.h" /* * Physical superblock buffer manipulations. Shared with libxfs in userspace. @@ -907,7 +908,7 @@ xfs_initialize_perag_data( /* * If the new summary counts are obviously incorrect, fail the * mount operation because that implies the AGFs are also corrupt. - * Clear BAD_SUMMARY so that we don't unmount with a dirty log, which + * Clear FS_COUNTERS so that we don't unmount with a dirty log, which * will prevent xfs_repair from fixing anything. */ if (fdblocks > sbp->sb_dblocks || ifree > ialloc) { @@ -925,7 +926,7 @@ xfs_initialize_perag_data( xfs_reinit_percpu_counters(mp); out: - mp->m_flags &= ~XFS_MOUNT_BAD_SUMMARY; + xfs_fs_mark_healthy(mp, XFS_HEALTH_FS_COUNTERS); return error; } diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index c3b610b687d1..0f418842a035 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -23,6 +23,7 @@ #include "xfs_cksum.h" #include "xfs_sysfs.h" #include "xfs_sb.h" +#include "xfs_health.h" kmem_zone_t *xfs_log_ticket_zone; @@ -861,7 +862,7 @@ xfs_log_write_unmount_record( * recalculated during log recovery at next mount. Refer to * xlog_check_unmount_rec for more details. */ - if (XFS_TEST_ERROR((mp->m_flags & XFS_MOUNT_BAD_SUMMARY), mp, + if (XFS_TEST_ERROR(xfs_fs_is_sick(mp, XFS_HEALTH_FS_COUNTERS), mp, XFS_ERRTAG_FORCE_SUMMARY_RECALC)) { xfs_alert(mp, "%s: will fix summary counters at next mount", __func__); diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index fc1f24dd0386..a43ca655a431 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -34,6 +34,7 @@ #include "xfs_refcount_btree.h" #include "xfs_reflink.h" #include "xfs_extent_busy.h" +#include "xfs_health.h" static DEFINE_MUTEX(xfs_uuid_table_mutex); @@ -647,7 +648,7 @@ xfs_check_summary_counts( (mp->m_sb.sb_fdblocks > mp->m_sb.sb_dblocks || !xfs_verify_icount(mp, mp->m_sb.sb_icount) || mp->m_sb.sb_ifree > mp->m_sb.sb_icount)) - mp->m_flags |= XFS_MOUNT_BAD_SUMMARY; + xfs_fs_mark_sick(mp, XFS_HEALTH_FS_COUNTERS); /* * We can safely re-initialise incore superblock counters from the @@ -662,7 +663,7 @@ xfs_check_summary_counts( */ if ((!xfs_sb_version_haslazysbcount(&mp->m_sb) || XFS_LAST_UNMOUNT_WAS_CLEAN(mp)) && - !(mp->m_flags & XFS_MOUNT_BAD_SUMMARY)) + !xfs_fs_is_sick(mp, XFS_HEALTH_FS_COUNTERS)) return 0; return xfs_initialize_perag_data(mp, mp->m_sb.sb_agcount); @@ -1451,7 +1452,5 @@ xfs_force_summary_recalc( if (!xfs_sb_version_haslazysbcount(&mp->m_sb)) return; - spin_lock(&mp->m_sb_lock); - mp->m_flags |= XFS_MOUNT_BAD_SUMMARY; - spin_unlock(&mp->m_sb_lock); + xfs_fs_mark_sick(mp, XFS_HEALTH_FS_COUNTERS); } diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 63bbafb01eb5..6e7728340ca7 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -211,7 +211,6 @@ typedef struct xfs_mount { must be synchronous except for space allocations */ #define XFS_MOUNT_UNMOUNTING (1ULL << 1) /* filesystem is unmounting */ -#define XFS_MOUNT_BAD_SUMMARY (1ULL << 2) /* summary counters are bad */ #define XFS_MOUNT_WAS_CLEAN (1ULL << 3) #define XFS_MOUNT_FS_SHUTDOWN (1ULL << 4) /* atomic stop of all filesystem operations, typically for From patchwork Mon Apr 1 17:10:28 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: 10880455 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 AA8E814DE for ; Mon, 1 Apr 2019 18:08:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93F15286A0 for ; Mon, 1 Apr 2019 18:08:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 885A328764; Mon, 1 Apr 2019 18:08:16 +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 0BD87286A0 for ; Mon, 1 Apr 2019 18:08:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728739AbfDASIO (ORCPT ); Mon, 1 Apr 2019 14:08:14 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:59902 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729427AbfDARKc (ORCPT ); Mon, 1 Apr 2019 13:10:32 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x31H9LUd131494 for ; Mon, 1 Apr 2019 17:10:31 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=xvQwGcZ43cJrPjUb1/8R8y+2MGrVcuknikLC6gh7vNk=; b=zt5FXT02KREJ87cpqbHCAzqShVQe+SK1kVre9BVxAP/hRFNz6CqPaonIr6NtiSKONh4l BXFgE9nOLNWIonEESTEbeqPoT6QbGuR6z7kJmZdofLji1PdeC5fJn5GoGpv5+aLpibnV fWDbCw5AX6a3AHLwaycuQc/C9/bJ7w1geYPu71zVDXq5+i5gJqS+ENnbKrRflUzu7xyw Y3ESFdmuVcMTA37p0gbmGdwjU51MUbj651ntA7NjEPtmqG+m4wHCj7Te0xFwnjMfbq17 QWObnZzzf9Q1Gs+q+n/TN//AY0ZiS+Yq/y8yYX7X95wzY0kd4hoazVeecUmOfTXAnaZO 6w== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2rhyvt0csw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 01 Apr 2019 17:10:30 +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 x31HAT9b013106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 1 Apr 2019 17:10:29 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x31HATro016789 for ; Mon, 1 Apr 2019 17:10:29 GMT Received: from localhost (/10.159.239.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Apr 2019 10:10:28 -0700 Subject: [PATCH 03/10] xfs: clear BAD_SUMMARY if unmounting an unhealthy filesystem From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 01 Apr 2019 10:10:28 -0700 Message-ID: <155413862812.4966.6543791189302248422.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=1 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 If we know the filesystem metadata isn't healthy during unmount, we want to encourage the administrator to run xfs_repair right away. We can't do this if BAD_SUMMARY will cause an unclean log unmount to force summary recalculation, so turn it off if the fs is bad. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_health.h | 2 + fs/xfs/xfs_health.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_mount.c | 2 + fs/xfs/xfs_trace.h | 3 ++ 4 files changed, 66 insertions(+) diff --git a/fs/xfs/libxfs/xfs_health.h b/fs/xfs/libxfs/xfs_health.h index 0d51bd2689ea..269b124dc1d7 100644 --- a/fs/xfs/libxfs/xfs_health.h +++ b/fs/xfs/libxfs/xfs_health.h @@ -148,6 +148,8 @@ void xfs_inode_mark_sick(struct xfs_inode *ip, unsigned int mask); void xfs_inode_mark_healthy(struct xfs_inode *ip, unsigned int mask); unsigned int xfs_inode_measure_sickness(struct xfs_inode *ip); +void xfs_health_unmount(struct xfs_mount *mp); + /* Now some helpers. */ static inline bool diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c index e9d6859f7501..6e2da858c356 100644 --- a/fs/xfs/xfs_health.c +++ b/fs/xfs/xfs_health.c @@ -19,6 +19,65 @@ #include "xfs_trace.h" #include "xfs_health.h" +/* + * Warn about metadata corruption that we detected but haven't fixed, and + * make sure we're not sitting on anything that would get in the way of + * recovery. + */ +void +xfs_health_unmount( + struct xfs_mount *mp) +{ + struct xfs_perag *pag; + xfs_agnumber_t agno; + unsigned int sick; + bool warn = false; + + if (XFS_FORCED_SHUTDOWN(mp)) + return; + + /* Measure AG corruption levels. */ + for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { + pag = xfs_perag_get(mp, agno); + spin_lock(&pag->pag_state_lock); + if (pag->pag_sick) { + trace_xfs_ag_unfixed_corruption(mp, agno, sick); + warn = true; + } + spin_unlock(&pag->pag_state_lock); + xfs_perag_put(pag); + } + + /* Measure realtime volume corruption levels. */ + sick = xfs_rt_measure_sickness(mp); + if (sick) { + trace_xfs_rt_unfixed_corruption(mp, sick); + warn = true; + } + + /* Measure fs corruption and keep the sample around for the warning. */ + sick = xfs_fs_measure_sickness(mp); + if (sick) { + trace_xfs_fs_unfixed_corruption(mp, sick); + warn = true; + } + + if (warn) { + xfs_warn(mp, +"Uncorrected metadata errors detected; please run xfs_repair."); + + /* + * If we have unhealthy metadata, we want the admin to run + * xfs_repair after unmounting. They can't do that if the log + * is written out without a clean unmount record (such as when + * the summary counters are marked unhealthy to force + * recalculation of the summary counters) so clear it. + */ + if (sick & XFS_HEALTH_FS_COUNTERS) + xfs_fs_mark_healthy(mp, XFS_HEALTH_FS_COUNTERS); + } +} + /* Mark unhealthy per-fs metadata. */ void xfs_fs_mark_sick( diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index a43ca655a431..f0f73d598a0c 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -1075,6 +1075,7 @@ xfs_mountfs( */ cancel_delayed_work_sync(&mp->m_reclaim_work); xfs_reclaim_inodes(mp, SYNC_WAIT); + xfs_health_unmount(mp); out_log_dealloc: mp->m_flags |= XFS_MOUNT_UNMOUNTING; xfs_log_mount_cancel(mp); @@ -1157,6 +1158,7 @@ xfs_unmountfs( */ cancel_delayed_work_sync(&mp->m_reclaim_work); xfs_reclaim_inodes(mp, SYNC_WAIT); + xfs_health_unmount(mp); xfs_qm_unmount(mp); diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index f079841c7af6..2464ea351f83 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -3461,8 +3461,10 @@ DEFINE_EVENT(xfs_fs_corrupt_class, name, \ TP_ARGS(mp, flags)) DEFINE_FS_CORRUPT_EVENT(xfs_fs_mark_sick); DEFINE_FS_CORRUPT_EVENT(xfs_fs_mark_healthy); +DEFINE_FS_CORRUPT_EVENT(xfs_fs_unfixed_corruption); DEFINE_FS_CORRUPT_EVENT(xfs_rt_mark_sick); DEFINE_FS_CORRUPT_EVENT(xfs_rt_mark_healthy); +DEFINE_FS_CORRUPT_EVENT(xfs_rt_unfixed_corruption); DECLARE_EVENT_CLASS(xfs_ag_corrupt_class, TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, unsigned int flags), @@ -3488,6 +3490,7 @@ DEFINE_EVENT(xfs_ag_corrupt_class, name, \ TP_ARGS(mp, agno, flags)) DEFINE_AG_CORRUPT_EVENT(xfs_ag_mark_sick); DEFINE_AG_CORRUPT_EVENT(xfs_ag_mark_healthy); +DEFINE_AG_CORRUPT_EVENT(xfs_ag_unfixed_corruption); DECLARE_EVENT_CLASS(xfs_inode_corrupt_class, TP_PROTO(struct xfs_inode *ip, unsigned int flags), From patchwork Mon Apr 1 17:10:34 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: 10880453 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 96EBD14DE for ; Mon, 1 Apr 2019 18:08:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DC77286A0 for ; Mon, 1 Apr 2019 18:08:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7154828764; Mon, 1 Apr 2019 18:08:08 +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 DE1A1286A0 for ; Mon, 1 Apr 2019 18:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730024AbfDARKr (ORCPT ); Mon, 1 Apr 2019 13:10:47 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60190 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730016AbfDARKn (ORCPT ); Mon, 1 Apr 2019 13:10:43 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x31H9GxF131404 for ; Mon, 1 Apr 2019 17:10:42 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=VjBIDEkS9cHBtutbP1w/+wSMMJ1SHPOWr1k9yGMzaCk=; b=0MZorrXTWNPkCsh9loyuoys/VgnIxqe1FBDojvH0Ig8OUTxUNUEeZJXEiAhcDv3RXhUY Q0BSveFDy0rcITktohX12RVLpaFff0JHUtGVkT0O+GTsCccjDY/JoP5SjQp6Xh+rS/jj RVmu/40ZY+kZmCcvpF6NPoqNn7X50YdKBYvDg1pVLEqRMVfdkEXd6g5LW/1xLVOTS8kv 80YZvQp7q2ALjzGtE3BralmuqOHvsl2N2Wa8B3w44qzzGQpWiyk9g0t7TX3qq1uAifk7 nz/fTPzQVysnnN8GIPqqwQ9L4j7UntL/ZfbOK4M5QYzptWpjE/bSWZNO5AQsK/SDQ+om qw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2rhyvt0cu0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 01 Apr 2019 17:10:41 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x31HAZXc012092 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 1 Apr 2019 17:10:36 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x31HAZfW017582 for ; Mon, 1 Apr 2019 17:10:35 GMT Received: from localhost (/10.159.239.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Apr 2019 10:10:35 -0700 Subject: [PATCH 04/10] xfs: expand xfs_fsop_geom From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 01 Apr 2019 10:10:34 -0700 Message-ID: <155413863414.4966.13609556795695536711.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=1 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 Rename the current (v2-v4) geometry ioctl XFS_IOC_FSGEOMETRY_V2 and expand the existing xfs_fsop_geom to reserve empty space for more fields. This means that newly built binaries will pick up the new format and existing programs will simply end up in the V2 handler. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_fs.h | 32 +++++++++++++++++++++++++++++++- fs/xfs/libxfs/xfs_sb.c | 5 +++++ fs/xfs/xfs_ioctl.c | 22 ++++++++++++++++++++-- fs/xfs/xfs_ioctl32.c | 1 + 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index f3aa59302fef..1dba751cde60 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -148,7 +148,34 @@ typedef struct xfs_fsop_geom_v1 { } xfs_fsop_geom_v1_t; /* - * Output for XFS_IOC_FSGEOMETRY + * Output for XFS_IOC_FSGEOMETRY_V2 + */ +typedef struct xfs_fsop_geom_v2 { + __u32 blocksize; /* filesystem (data) block size */ + __u32 rtextsize; /* realtime extent size */ + __u32 agblocks; /* fsblocks in an AG */ + __u32 agcount; /* number of allocation groups */ + __u32 logblocks; /* fsblocks in the log */ + __u32 sectsize; /* (data) sector size, bytes */ + __u32 inodesize; /* inode size in bytes */ + __u32 imaxpct; /* max allowed inode space(%) */ + __u64 datablocks; /* fsblocks in data subvolume */ + __u64 rtblocks; /* fsblocks in realtime subvol */ + __u64 rtextents; /* rt extents in realtime subvol*/ + __u64 logstart; /* starting fsblock of the log */ + unsigned char uuid[16]; /* unique id of the filesystem */ + __u32 sunit; /* stripe unit, fsblocks */ + __u32 swidth; /* stripe width, fsblocks */ + __s32 version; /* structure version */ + __u32 flags; /* superblock version flags */ + __u32 logsectsize; /* log sector size, bytes */ + __u32 rtsectsize; /* realtime sector size, bytes */ + __u32 dirblocksize; /* directory block size, bytes */ + __u32 logsunit; /* log stripe unit, bytes */ +} xfs_fsop_geom_v2_t; + +/* + * Output for XFS_IOC_FSGEOMETRY (v5) */ typedef struct xfs_fsop_geom { __u32 blocksize; /* filesystem (data) block size */ @@ -172,6 +199,7 @@ 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 */ } xfs_fsop_geom_t; /* Output for XFS_FS_COUNTS */ @@ -189,6 +217,7 @@ typedef struct xfs_fsop_resblks { } xfs_fsop_resblks_t; #define XFS_FSOP_GEOM_VERSION 0 +#define XFS_FSOP_GEOM_V5 5 #define XFS_FSOP_GEOM_FLAGS_ATTR 0x0001 /* attributes in use */ #define XFS_FSOP_GEOM_FLAGS_NLINK 0x0002 /* 32-bit nlink values */ @@ -620,6 +649,7 @@ struct xfs_scrub_metadata { #define XFS_IOC_FSSETDM_BY_HANDLE _IOW ('X', 121, struct xfs_fsop_setdm_handlereq) #define XFS_IOC_ATTRLIST_BY_HANDLE _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq) #define XFS_IOC_ATTRMULTI_BY_HANDLE _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq) +#define XFS_IOC_FSGEOMETRY_V2 _IOR ('X', 124, struct xfs_fsop_geom_v2) #define XFS_IOC_FSGEOMETRY _IOR ('X', 124, struct xfs_fsop_geom) #define XFS_IOC_GOINGDOWN _IOR ('X', 125, uint32_t) /* XFS_IOC_GETFSUUID ---------- deprecated 140 */ diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index f0309b74e377..c2ca3a816c41 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -1168,6 +1168,11 @@ xfs_fs_geometry( geo->logsunit = sbp->sb_logsunit; + if (struct_version < 5) + return 0; + + geo->version = XFS_FSOP_GEOM_V5; + return 0; } diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 6ecdbb3af7de..7fd8815633dc 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -801,7 +801,7 @@ xfs_ioc_fsgeometry_v1( } STATIC int -xfs_ioc_fsgeometry( +xfs_ioc_fsgeometry_v2( xfs_mount_t *mp, void __user *arg) { @@ -812,6 +812,23 @@ xfs_ioc_fsgeometry( if (error) return error; + if (copy_to_user(arg, &fsgeo, sizeof(struct xfs_fsop_geom_v2))) + return -EFAULT; + return 0; +} + +STATIC int +xfs_ioc_fsgeometry( + struct xfs_mount *mp, + void __user *arg) +{ + struct xfs_fsop_geom fsgeo; + int error; + + error = xfs_fs_geometry(&mp->m_sb, &fsgeo, 5); + if (error) + return error; + if (copy_to_user(arg, &fsgeo, sizeof(fsgeo))) return -EFAULT; return 0; @@ -1938,7 +1955,8 @@ xfs_file_ioctl( case XFS_IOC_FSGEOMETRY_V1: return xfs_ioc_fsgeometry_v1(mp, arg); - + case XFS_IOC_FSGEOMETRY_V2: + return xfs_ioc_fsgeometry_v2(mp, arg); case XFS_IOC_FSGEOMETRY: return xfs_ioc_fsgeometry(mp, arg); diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 5001dca361e9..323cfd4b15dc 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -561,6 +561,7 @@ xfs_file_compat_ioctl( switch (cmd) { /* No size or alignment issues on any arch */ case XFS_IOC_DIOINFO: + case XFS_IOC_FSGEOMETRY_V2: case XFS_IOC_FSGEOMETRY: case XFS_IOC_FSGETXATTR: case XFS_IOC_FSSETXATTR: From patchwork Mon Apr 1 17:10:40 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: 10880359 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 A1FD11800 for ; Mon, 1 Apr 2019 17:10:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BE6720502 for ; Mon, 1 Apr 2019 17:10:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FF13287B5; Mon, 1 Apr 2019 17:10:47 +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 C55D628797 for ; Mon, 1 Apr 2019 17:10:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729455AbfDARKp (ORCPT ); Mon, 1 Apr 2019 13:10:45 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:46218 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729683AbfDARKo (ORCPT ); Mon, 1 Apr 2019 13:10:44 -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 x31H9HuK134141 for ; Mon, 1 Apr 2019 17:10:43 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=/S/9i6OQpHcc9I244VmMlA9rJTq74UBJrkfD0UdKgd4=; b=5VeLQicHs9EOsXUT/NLjPZxM99FwNNYfTCc8fRjb1uSI9ybbHn5YQezdv1y1n2idw+Au VVYDjwqKkLgRzQWmShnXKqQVEQVTtA774T5UMYYXHj5ygtJjavWaDwRDKZkXeAaP/jhB gpSrSP5MsTq5d5bP5nd4SD7jqYMW5FTR8HG1t3lTN1RK2Na4lg/vUDcT5T+Mp8DIGtYW JSCpEP/U/0Ttvtx+v0vYj4FHBu/0D3iQ9/lP0knzmWnCzGKvZVpIDUT7cF3y4LOFIcww 9N6A5OlWBPMa3hQJ5bGL81P1owUingVXfG0noTRdXJjKo/m9uiUrIOJUmYwjmtu+qZNM Rw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2rhwyd0gkc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 01 Apr 2019 17:10:42 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x31HAfaV004879 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 1 Apr 2019 17:10:41 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x31HAfaE017713 for ; Mon, 1 Apr 2019 17:10:41 GMT Received: from localhost (/10.159.239.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Apr 2019 10:10:41 -0700 Subject: [PATCH 05/10] xfs: add a new ioctl to describe allocation group geometry From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 01 Apr 2019 10:10:40 -0700 Message-ID: <155413864032.4966.11238815153270272807.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 Add a new ioctl to describe an allocation group's geometry. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_ag.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_ag.h | 2 ++ fs/xfs/libxfs/xfs_fs.h | 14 ++++++++++++++ fs/xfs/xfs_ioctl.c | 24 ++++++++++++++++++++++++ fs/xfs/xfs_ioctl32.c | 1 + 5 files changed, 89 insertions(+) diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c index 1ef8acf35e7d..1679e37fe28d 100644 --- a/fs/xfs/libxfs/xfs_ag.c +++ b/fs/xfs/libxfs/xfs_ag.c @@ -19,6 +19,7 @@ #include "xfs_ialloc.h" #include "xfs_rmap.h" #include "xfs_ag.h" +#include "xfs_ag_resv.h" static struct xfs_buf * xfs_get_aghdr_buf( @@ -461,3 +462,50 @@ xfs_ag_extend_space( len, &XFS_RMAP_OINFO_SKIP_UPDATE, XFS_AG_RESV_NONE); } + +/* Retrieve AG geometry. */ +int +xfs_ag_get_geometry( + struct xfs_mount *mp, + xfs_agnumber_t agno, + struct xfs_ag_geometry *ageo) +{ + struct xfs_buf *bp; + struct xfs_agi *agi; + struct xfs_agf *agf; + struct xfs_perag *pag; + unsigned int freeblks; + int error; + + memset(ageo, 0, sizeof(*ageo)); + + if (agno >= mp->m_sb.sb_agcount) + return -EINVAL; + + error = xfs_ialloc_read_agi(mp, NULL, agno, &bp); + if (error) + return error; + + agi = XFS_BUF_TO_AGI(bp); + ageo->ag_icount = be32_to_cpu(agi->agi_count); + ageo->ag_ifree = be32_to_cpu(agi->agi_freecount); + xfs_buf_relse(bp); + + error = xfs_alloc_read_agf(mp, NULL, agno, 0, &bp); + if (error) + return error; + + agf = XFS_BUF_TO_AGF(bp); + pag = xfs_perag_get(mp, agno); + ageo->ag_length = be32_to_cpu(agf->agf_length); + freeblks = pag->pagf_freeblks + + pag->pagf_flcount + + pag->pagf_btreeblks - + xfs_ag_resv_needed(pag, XFS_AG_RESV_NONE); + ageo->ag_freeblks = freeblks; + xfs_perag_put(pag); + xfs_buf_relse(bp); + + ageo->ag_number = agno; + return 0; +} diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h index 412702e23f61..5166322807e7 100644 --- a/fs/xfs/libxfs/xfs_ag.h +++ b/fs/xfs/libxfs/xfs_ag.h @@ -26,5 +26,7 @@ struct aghdr_init_data { int xfs_ag_init_headers(struct xfs_mount *mp, struct aghdr_init_data *id); int xfs_ag_extend_space(struct xfs_mount *mp, struct xfs_trans *tp, struct aghdr_init_data *id, xfs_extlen_t len); +int xfs_ag_get_geometry(struct xfs_mount *mp, xfs_agnumber_t agno, + struct xfs_ag_geometry *ageo); #endif /* __LIBXFS_AG_H */ diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 1dba751cde60..87226e00e7bd 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -266,6 +266,19 @@ typedef struct xfs_fsop_resblks { #define XFS_MIN_DBLOCKS(s) ((xfs_rfsblock_t)((s)->sb_agcount - 1) * \ (s)->sb_agblocks + XFS_MIN_AG_BLOCKS) +/* + * Output for XFS_IOC_AG_GEOMETRY + */ +struct xfs_ag_geometry { + __u32 ag_number; /* i/o: AG number */ + __u32 ag_length; /* o: length in blocks */ + __u32 ag_freeblks; /* o: free space */ + __u32 ag_icount; /* o: inodes allocated */ + __u32 ag_ifree; /* o: inodes free */ + __u32 ag_reserved32; /* o: zero */ + __u64 ag_reserved[5]; /* o: zero */ +}; + /* * Structures for XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG & XFS_IOC_FSGROWFSRT */ @@ -619,6 +632,7 @@ struct xfs_scrub_metadata { #define XFS_IOC_FREE_EOFBLOCKS _IOR ('X', 58, struct xfs_fs_eofblocks) /* XFS_IOC_GETFSMAP ------ hoisted 59 */ #define XFS_IOC_SCRUB_METADATA _IOWR('X', 60, struct xfs_scrub_metadata) +#define XFS_IOC_AG_GEOMETRY _IOWR('X', 61, struct xfs_ag_geometry) /* * ioctl commands that replace IRIX syssgi()'s diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 7fd8815633dc..b5918ce656bd 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -33,6 +33,7 @@ #include "xfs_fsmap.h" #include "scrub/xfs_scrub.h" #include "xfs_sb.h" +#include "xfs_ag.h" #include #include @@ -834,6 +835,26 @@ xfs_ioc_fsgeometry( return 0; } +STATIC int +xfs_ioc_ag_geometry( + struct xfs_mount *mp, + void __user *arg) +{ + struct xfs_ag_geometry ageo; + int error; + + if (copy_from_user(&ageo, arg, sizeof(ageo))) + return -EFAULT; + + error = xfs_ag_get_geometry(mp, ageo.ag_number, &ageo); + if (error) + return error; + + if (copy_to_user(arg, &ageo, sizeof(ageo))) + return -EFAULT; + return 0; +} + /* * Linux extended inode flags interface. */ @@ -1960,6 +1981,9 @@ xfs_file_ioctl( case XFS_IOC_FSGEOMETRY: return xfs_ioc_fsgeometry(mp, arg); + case XFS_IOC_AG_GEOMETRY: + return xfs_ioc_ag_geometry(mp, arg); + case XFS_IOC_GETVERSION: return put_user(inode->i_generation, (int __user *)arg); diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 323cfd4b15dc..28d2110dd871 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -563,6 +563,7 @@ xfs_file_compat_ioctl( case XFS_IOC_DIOINFO: case XFS_IOC_FSGEOMETRY_V2: case XFS_IOC_FSGEOMETRY: + case XFS_IOC_AG_GEOMETRY: case XFS_IOC_FSGETXATTR: case XFS_IOC_FSSETXATTR: case XFS_IOC_FSGETXATTRA: 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; From patchwork Mon Apr 1 17:10:52 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: 10880361 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 9E6371800 for ; Mon, 1 Apr 2019 17:11:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A440287E0 for ; Mon, 1 Apr 2019 17:11:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78BF3287FE; Mon, 1 Apr 2019 17:11:08 +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 08DFD287E0 for ; Mon, 1 Apr 2019 17:11:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730100AbfDARLC (ORCPT ); Mon, 1 Apr 2019 13:11:02 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60476 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730088AbfDARLA (ORCPT ); Mon, 1 Apr 2019 13:11:00 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x31H9HBe131425 for ; Mon, 1 Apr 2019 17:10:59 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=4bvR5br32hDUNz52m7zxDI4EVyE/GujD/3eqjCBkTTk=; b=LUzXAd+v3/jbB4FJXRPUdAYnWgsU2E2YfoH/We/ZT2euLk01MOb6NXVXxMjGqSX8sJYq vtupyIbTNBn+qleHkl2u/T/zUqDt5WBnDZyernSUR844mjmvPYwkndW426fqcjpW+Rf3 UfqJ3TM+RcDs8wPPHbO2yJ/3KcRDSr8HmhTMLKLYB9Z6FYci2ZTWDmeROivbzxs/2swM yv4qhsJS0mw0m32NzsnmTi5OTvboaW292uQYMV7duiOU6ieJXDJUc5tStF+qV/xipJL1 j+K5c++Vz7lxWgLjF/cc0b8nFNYMk5rJMVEB6S1L7hXBt6eLTQuAiD2tITO+Y+Kz2Ua3 cA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2rhyvt0cvu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 01 Apr 2019 17:10:59 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x31HAv3M014292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 1 Apr 2019 17:10:58 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x31HAvgq017187 for ; Mon, 1 Apr 2019 17:10:57 GMT Received: from localhost (/10.159.239.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Apr 2019 10:10:57 -0700 Subject: [PATCH 07/10] xfs: report AG health via AG geometry ioctl From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 01 Apr 2019 10:10:52 -0700 Message-ID: <155413865266.4966.1015973371094452528.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 the AG geometry info ioctl to report health status too. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_fs.h | 12 +++++++++++- fs/xfs/libxfs/xfs_health.h | 2 ++ fs/xfs/xfs_health.c | 40 ++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_ioctl.c | 2 ++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index ddbfde7ff79d..dc2c538e6b92 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -284,9 +284,19 @@ struct xfs_ag_geometry { __u32 ag_freeblks; /* o: free space */ __u32 ag_icount; /* o: inodes allocated */ __u32 ag_ifree; /* o: inodes free */ - __u32 ag_reserved32; /* o: zero */ + __u32 ag_health; /* o: sick things in ag */ __u64 ag_reserved[5]; /* o: zero */ }; +#define XFS_AG_GEOM_HEALTH_AG_SB (1 << 0) /* superblock */ +#define XFS_AG_GEOM_HEALTH_AG_AGF (1 << 1) /* AGF header */ +#define XFS_AG_GEOM_HEALTH_AG_AGFL (1 << 2) /* AGFL header */ +#define XFS_AG_GEOM_HEALTH_AG_AGI (1 << 3) /* AGI header */ +#define XFS_AG_GEOM_HEALTH_AG_BNOBT (1 << 4) /* free space by block */ +#define XFS_AG_GEOM_HEALTH_AG_CNTBT (1 << 5) /* free space by length */ +#define XFS_AG_GEOM_HEALTH_AG_INOBT (1 << 6) /* inode index */ +#define XFS_AG_GEOM_HEALTH_AG_FINOBT (1 << 7) /* free inode index */ +#define XFS_AG_GEOM_HEALTH_AG_RMAPBT (1 << 8) /* reverse mappings */ +#define XFS_AG_GEOM_HEALTH_AG_REFCNTBT (1 << 9) /* reference counts */ /* * Structures for XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG & XFS_IOC_FSGROWFSRT diff --git a/fs/xfs/libxfs/xfs_health.h b/fs/xfs/libxfs/xfs_health.h index 36736d54a3e3..2d3b879da9b5 100644 --- a/fs/xfs/libxfs/xfs_health.h +++ b/fs/xfs/libxfs/xfs_health.h @@ -202,5 +202,7 @@ xfs_inode_healthy(struct xfs_inode *ip) } void xfs_fsop_geom_health(struct xfs_mount *mp, struct xfs_fsop_geom *geo); +void xfs_ag_geom_health(struct xfs_mount *mp, xfs_agnumber_t agno, + struct xfs_ag_geometry *ageo); #endif /* __XFS_HEALTH_H__ */ diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c index 151c98693bef..5ca471bd41ad 100644 --- a/fs/xfs/xfs_health.c +++ b/fs/xfs/xfs_health.c @@ -276,3 +276,43 @@ xfs_fsop_geom_health( if (sick & XFS_HEALTH_RT_SUMMARY) geo->health |= XFS_FSOP_GEOM_HEALTH_RT_SUMMARY; } + +/* Fill out ag geometry health info. */ +void +xfs_ag_geom_health( + struct xfs_mount *mp, + xfs_agnumber_t agno, + struct xfs_ag_geometry *ageo) +{ + struct xfs_perag *pag; + unsigned int sick; + + if (agno >= mp->m_sb.sb_agcount) + return; + + ageo->ag_health = 0; + + pag = xfs_perag_get(mp, agno); + sick = xfs_ag_measure_sickness(pag); + if (sick & XFS_HEALTH_AG_SB) + ageo->ag_health |= XFS_AG_GEOM_HEALTH_AG_SB; + if (sick & XFS_HEALTH_AG_AGF) + ageo->ag_health |= XFS_AG_GEOM_HEALTH_AG_AGF; + if (sick & XFS_HEALTH_AG_AGFL) + ageo->ag_health |= XFS_AG_GEOM_HEALTH_AG_AGFL; + if (sick & XFS_HEALTH_AG_AGI) + ageo->ag_health |= XFS_AG_GEOM_HEALTH_AG_AGI; + if (sick & XFS_HEALTH_AG_BNOBT) + ageo->ag_health |= XFS_AG_GEOM_HEALTH_AG_BNOBT; + if (sick & XFS_HEALTH_AG_CNTBT) + ageo->ag_health |= XFS_AG_GEOM_HEALTH_AG_CNTBT; + if (sick & XFS_HEALTH_AG_INOBT) + ageo->ag_health |= XFS_AG_GEOM_HEALTH_AG_INOBT; + if (sick & XFS_HEALTH_AG_FINOBT) + ageo->ag_health |= XFS_AG_GEOM_HEALTH_AG_FINOBT; + if (sick & XFS_HEALTH_AG_RMAPBT) + ageo->ag_health |= XFS_AG_GEOM_HEALTH_AG_RMAPBT; + if (sick & XFS_HEALTH_AG_REFCNTBT) + ageo->ag_health |= XFS_AG_GEOM_HEALTH_AG_REFCNTBT; + xfs_perag_put(pag); +} diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index f9bf11b6a055..f1fc5e53cfc1 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -853,6 +853,8 @@ xfs_ioc_ag_geometry( if (error) return error; + xfs_ag_geom_health(mp, ageo.ag_number, &ageo); + if (copy_to_user(arg, &ageo, sizeof(ageo))) return -EFAULT; return 0; From patchwork Mon Apr 1 17:11:02 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: 10880363 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 B631817E1 for ; Mon, 1 Apr 2019 17:11:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F3162223E for ; Mon, 1 Apr 2019 17:11:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D010287FB; Mon, 1 Apr 2019 17:11:13 +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 0ED25287DA for ; Mon, 1 Apr 2019 17:11:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729085AbfDARLM (ORCPT ); Mon, 1 Apr 2019 13:11:12 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:46712 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730089AbfDARLK (ORCPT ); Mon, 1 Apr 2019 13:11:10 -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 x31H9Hjm134155 for ; Mon, 1 Apr 2019 17:11:09 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=NZEleTwnsOG0eaTFq+4cV0qPXR99Ph7wQYmQrGVsbYI=; b=lOcyfsjg0TzmWWfzPeLM8x1B13Fw5Oy0loPsa59S9PDEMUR/CAHQWVUrutvG6tmXlJqp gcezz2N4FQXN7AkIx89GUDIv3el0JN1peVw2hqpntoF+D9RiinxF8lQKMXCYXcs2fmmQ 0qLczL1WJgjROfUwbBEez6tJ0dO3bT5jlnuM/qzZjqMvliNnap7Q3CZSNzNETzzLXpnW N2jPDVPaSS5bZH7qUbyzBM36eiJDMHidel1nDshHauW8q9wm90qlR7lUK19VInIk55YF wSlQKWvtBv7bfxX0Dz/zTNs9NecHLkVZfEkLnhLI6wl2bmNYGVFCLHWvXEFxALpyS8Sn 8Q== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2rhwyd0gnv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 01 Apr 2019 17:11:08 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x31HB7Ep017868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 1 Apr 2019 17:11:07 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x31HB75q012215 for ; Mon, 1 Apr 2019 17:11:07 GMT Received: from localhost (/10.159.239.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Apr 2019 10:11:07 -0700 Subject: [PATCH 08/10] xfs: report inode health via bulkstat From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 01 Apr 2019 10:11:02 -0700 Message-ID: <155413866259.4966.15271041361179138786.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=1 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 space in the bulkstat ioctl structure to report any problems observed with the inode. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_fs.h | 13 ++++++++++++- fs/xfs/libxfs/xfs_health.h | 1 + fs/xfs/xfs_health.c | 27 +++++++++++++++++++++++++++ fs/xfs/xfs_itable.c | 2 ++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index dc2c538e6b92..fffaead718a5 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -346,13 +346,24 @@ typedef struct xfs_bstat { #define bs_projid bs_projid_lo /* (previously just bs_projid) */ __u16 bs_forkoff; /* inode fork offset in bytes */ __u16 bs_projid_hi; /* higher part of project id */ - unsigned char bs_pad[6]; /* pad space, unused */ + uint16_t bs_health; /* sick inode metadata */ + unsigned char bs_pad[4]; /* pad space, unused */ __u32 bs_cowextsize; /* cow extent size */ __u32 bs_dmevmask; /* DMIG event mask */ __u16 bs_dmstate; /* DMIG state info */ __u16 bs_aextents; /* attribute number of extents */ } xfs_bstat_t; +/* bs_health flags */ +#define XFS_BS_HEALTH_INODE (1 << 0) /* inode core */ +#define XFS_BS_HEALTH_BMBTD (1 << 1) /* data fork */ +#define XFS_BS_HEALTH_BMBTA (1 << 2) /* attr fork */ +#define XFS_BS_HEALTH_BMBTC (1 << 3) /* cow fork */ +#define XFS_BS_HEALTH_DIR (1 << 4) /* directory */ +#define XFS_BS_HEALTH_XATTR (1 << 5) /* extended attributes */ +#define XFS_BS_HEALTH_SYMLINK (1 << 6) /* symbolic link remote target */ +#define XFS_BS_HEALTH_PARENT (1 << 7) /* parent pointers */ + /* * Project quota id helpers (previously projid was 16bit only * and using two 16bit values to hold new 32bit projid was choosen diff --git a/fs/xfs/libxfs/xfs_health.h b/fs/xfs/libxfs/xfs_health.h index 2d3b879da9b5..a6446d1dd8a7 100644 --- a/fs/xfs/libxfs/xfs_health.h +++ b/fs/xfs/libxfs/xfs_health.h @@ -204,5 +204,6 @@ xfs_inode_healthy(struct xfs_inode *ip) void xfs_fsop_geom_health(struct xfs_mount *mp, struct xfs_fsop_geom *geo); void xfs_ag_geom_health(struct xfs_mount *mp, xfs_agnumber_t agno, struct xfs_ag_geometry *ageo); +void xfs_bulkstat_health(struct xfs_inode *ip, struct xfs_bstat *bs); #endif /* __XFS_HEALTH_H__ */ diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c index 5ca471bd41ad..1c9b71949410 100644 --- a/fs/xfs/xfs_health.c +++ b/fs/xfs/xfs_health.c @@ -316,3 +316,30 @@ xfs_ag_geom_health( ageo->ag_health |= XFS_AG_GEOM_HEALTH_AG_REFCNTBT; xfs_perag_put(pag); } + +/* Fill out bulkstat health info. */ +void +xfs_bulkstat_health( + struct xfs_inode *ip, + struct xfs_bstat *bs) +{ + unsigned int sick = xfs_inode_measure_sickness(ip); + + bs->bs_health = 0; + if (sick & XFS_HEALTH_INO_CORE) + bs->bs_health |= XFS_BS_HEALTH_INODE; + if (sick & XFS_HEALTH_INO_BMBTD) + bs->bs_health |= XFS_BS_HEALTH_BMBTD; + if (sick & XFS_HEALTH_INO_BMBTA) + bs->bs_health |= XFS_BS_HEALTH_BMBTA; + if (sick & XFS_HEALTH_INO_BMBTC) + bs->bs_health |= XFS_BS_HEALTH_BMBTC; + if (sick & XFS_HEALTH_INO_DIR) + bs->bs_health |= XFS_BS_HEALTH_DIR; + if (sick & XFS_HEALTH_INO_XATTR) + bs->bs_health |= XFS_BS_HEALTH_XATTR; + if (sick & XFS_HEALTH_INO_SYMLINK) + bs->bs_health |= XFS_BS_HEALTH_SYMLINK; + if (sick & XFS_HEALTH_INO_PARENT) + bs->bs_health |= XFS_BS_HEALTH_PARENT; +} diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 1861289bf823..cff28ee73deb 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c @@ -18,6 +18,7 @@ #include "xfs_error.h" #include "xfs_trace.h" #include "xfs_icache.h" +#include "xfs_health.h" /* * Return stat information for one inode. @@ -84,6 +85,7 @@ xfs_bulkstat_one_int( buf->bs_extsize = dic->di_extsize << mp->m_sb.sb_blocklog; buf->bs_extents = dic->di_nextents; memset(buf->bs_pad, 0, sizeof(buf->bs_pad)); + xfs_bulkstat_health(ip, buf); buf->bs_dmevmask = dic->di_dmevmask; buf->bs_dmstate = dic->di_dmstate; buf->bs_aextents = dic->di_anextents; From patchwork Mon Apr 1 17:11:12 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: 10880449 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 CBEDA184E for ; Mon, 1 Apr 2019 18:07:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4336286A2 for ; Mon, 1 Apr 2019 18:07:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7F3B28803; Mon, 1 Apr 2019 18:07:25 +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 EDC3728764 for ; Mon, 1 Apr 2019 18:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729569AbfDARLV (ORCPT ); Mon, 1 Apr 2019 13:11:21 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:46822 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729539AbfDARLP (ORCPT ); Mon, 1 Apr 2019 13:11:15 -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 x31H9px6134674 for ; Mon, 1 Apr 2019 17:11:14 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=32FxUx8gObyPgt6DojZia4vsDdpFYeZUiQXkItzhS80=; b=nbgLqy2GH1+YDe0y9XUG/3L24ok/y3H3P9Bj6LSzQaASjQEp9DG3spBRt/zmzUa9sF/f fK/wRE0QtUE8ozA13i3jCaSthNv1xXBqDw1Lt/+CQJcfCbHLunF3lihntEtJIq8x3+0k afQsw3lV6CUdjL8693I5De3tkxVR5mFZTA4g3ZWmAbVPFSkwX5kuOLpQEMkaqcU5ULhn Vy4ywLmTN312QZc8SjjQxXNr8VFcK9b8k9fWjPbqpa5ZFv3CNcanQBOO3ttQUAdwJU3C xF6lqMJrCDbzdHilFKhxo9bGb3cNc+lIQ/XAPiQvGLtSA7f/wdEiycbQbtyTk2heGaic iA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2rhwyd0gp6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 01 Apr 2019 17:11:14 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x31HBD5b015363 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 1 Apr 2019 17:11:13 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x31HBDl9007662 for ; Mon, 1 Apr 2019 17:11:13 GMT Received: from localhost (/10.159.239.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Apr 2019 10:11:13 -0700 Subject: [PATCH 09/10] xfs: scrub/repair should update filesystem metadata health From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 01 Apr 2019 10:11:12 -0700 Message-ID: <155413867262.4966.18080677522827911800.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=1 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 Now that we have the ability to track sick metadata in-core, make scrub and repair update those health assessments after doing work. Signed-off-by: Darrick J. Wong --- fs/xfs/Makefile | 1 fs/xfs/scrub/health.c | 180 +++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/scrub/health.h | 12 +++ fs/xfs/scrub/scrub.c | 8 ++ fs/xfs/scrub/scrub.h | 11 +++ 5 files changed, 212 insertions(+) create mode 100644 fs/xfs/scrub/health.c create mode 100644 fs/xfs/scrub/health.h diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 786379c143f4..b20964e26a22 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -143,6 +143,7 @@ xfs-y += $(addprefix scrub/, \ common.o \ dabtree.o \ dir.o \ + health.o \ ialloc.o \ inode.o \ parent.o \ diff --git a/fs/xfs/scrub/health.c b/fs/xfs/scrub/health.c new file mode 100644 index 000000000000..dd9986500801 --- /dev/null +++ b/fs/xfs/scrub/health.c @@ -0,0 +1,180 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_shared.h" +#include "xfs_format.h" +#include "xfs_trans_resv.h" +#include "xfs_mount.h" +#include "xfs_defer.h" +#include "xfs_btree.h" +#include "xfs_bit.h" +#include "xfs_log_format.h" +#include "xfs_trans.h" +#include "xfs_sb.h" +#include "xfs_inode.h" +#include "xfs_health.h" +#include "scrub/scrub.h" +#include "scrub/health.h" + +static const unsigned int xchk_type_to_health_flag[XFS_SCRUB_TYPE_NR] = { + [XFS_SCRUB_TYPE_SB] = XFS_HEALTH_AG_SB, + [XFS_SCRUB_TYPE_AGF] = XFS_HEALTH_AG_AGF, + [XFS_SCRUB_TYPE_AGFL] = XFS_HEALTH_AG_AGFL, + [XFS_SCRUB_TYPE_AGI] = XFS_HEALTH_AG_AGI, + [XFS_SCRUB_TYPE_BNOBT] = XFS_HEALTH_AG_BNOBT, + [XFS_SCRUB_TYPE_CNTBT] = XFS_HEALTH_AG_CNTBT, + [XFS_SCRUB_TYPE_INOBT] = XFS_HEALTH_AG_INOBT, + [XFS_SCRUB_TYPE_FINOBT] = XFS_HEALTH_AG_FINOBT, + [XFS_SCRUB_TYPE_RMAPBT] = XFS_HEALTH_AG_RMAPBT, + [XFS_SCRUB_TYPE_REFCNTBT] = XFS_HEALTH_AG_REFCNTBT, + [XFS_SCRUB_TYPE_INODE] = XFS_HEALTH_INO_CORE, + [XFS_SCRUB_TYPE_BMBTD] = XFS_HEALTH_INO_BMBTD, + [XFS_SCRUB_TYPE_BMBTA] = XFS_HEALTH_INO_BMBTA, + [XFS_SCRUB_TYPE_BMBTC] = XFS_HEALTH_INO_BMBTC, + [XFS_SCRUB_TYPE_DIR] = XFS_HEALTH_INO_DIR, + [XFS_SCRUB_TYPE_XATTR] = XFS_HEALTH_INO_XATTR, + [XFS_SCRUB_TYPE_SYMLINK] = XFS_HEALTH_INO_SYMLINK, + [XFS_SCRUB_TYPE_PARENT] = XFS_HEALTH_INO_PARENT, + [XFS_SCRUB_TYPE_RTBITMAP] = XFS_HEALTH_RT_BITMAP, + [XFS_SCRUB_TYPE_RTSUM] = XFS_HEALTH_RT_SUMMARY, + [XFS_SCRUB_TYPE_UQUOTA] = XFS_HEALTH_FS_UQUOTA, + [XFS_SCRUB_TYPE_GQUOTA] = XFS_HEALTH_FS_GQUOTA, + [XFS_SCRUB_TYPE_PQUOTA] = XFS_HEALTH_FS_PQUOTA, +}; + +/* Return the health status mask for this scrub type. */ +unsigned int +xchk_health_mask_for_scrub_type( + __u32 scrub_type) +{ + return xchk_type_to_health_flag[scrub_type]; +} + +/* Mark metadata unhealthy. */ +static void +xchk_mark_sick( + struct xfs_scrub *sc, + unsigned int mask) +{ + struct xfs_perag *pag; + + if (!mask) + return; + + switch (sc->sm->sm_type) { + case XFS_SCRUB_TYPE_SB: + case XFS_SCRUB_TYPE_AGF: + case XFS_SCRUB_TYPE_AGFL: + case XFS_SCRUB_TYPE_AGI: + case XFS_SCRUB_TYPE_BNOBT: + case XFS_SCRUB_TYPE_CNTBT: + case XFS_SCRUB_TYPE_INOBT: + case XFS_SCRUB_TYPE_FINOBT: + case XFS_SCRUB_TYPE_RMAPBT: + case XFS_SCRUB_TYPE_REFCNTBT: + pag = xfs_perag_get(sc->mp, sc->sm->sm_agno); + xfs_ag_mark_sick(pag, mask); + xfs_perag_put(pag); + break; + case XFS_SCRUB_TYPE_INODE: + case XFS_SCRUB_TYPE_BMBTD: + case XFS_SCRUB_TYPE_BMBTA: + case XFS_SCRUB_TYPE_BMBTC: + case XFS_SCRUB_TYPE_DIR: + case XFS_SCRUB_TYPE_XATTR: + case XFS_SCRUB_TYPE_SYMLINK: + case XFS_SCRUB_TYPE_PARENT: + xfs_inode_mark_sick(sc->ip, mask); + break; + case XFS_SCRUB_TYPE_UQUOTA: + case XFS_SCRUB_TYPE_GQUOTA: + case XFS_SCRUB_TYPE_PQUOTA: + xfs_fs_mark_sick(sc->mp, mask); + break; + case XFS_SCRUB_TYPE_RTBITMAP: + case XFS_SCRUB_TYPE_RTSUM: + xfs_rt_mark_sick(sc->mp, mask); + break; + default: + break; + } +} + +/* Mark metadata healed after a repair or healthy after a clean scan. */ +static void +xchk_mark_healthy( + struct xfs_scrub *sc, + unsigned int mask) +{ + struct xfs_perag *pag; + + if (!mask) + return; + + switch (sc->sm->sm_type) { + case XFS_SCRUB_TYPE_SB: + case XFS_SCRUB_TYPE_AGF: + case XFS_SCRUB_TYPE_AGFL: + case XFS_SCRUB_TYPE_AGI: + case XFS_SCRUB_TYPE_BNOBT: + case XFS_SCRUB_TYPE_CNTBT: + case XFS_SCRUB_TYPE_INOBT: + case XFS_SCRUB_TYPE_FINOBT: + case XFS_SCRUB_TYPE_RMAPBT: + case XFS_SCRUB_TYPE_REFCNTBT: + pag = xfs_perag_get(sc->mp, sc->sm->sm_agno); + xfs_ag_mark_healthy(pag, mask); + xfs_perag_put(pag); + break; + case XFS_SCRUB_TYPE_INODE: + case XFS_SCRUB_TYPE_BMBTD: + case XFS_SCRUB_TYPE_BMBTA: + case XFS_SCRUB_TYPE_BMBTC: + case XFS_SCRUB_TYPE_DIR: + case XFS_SCRUB_TYPE_XATTR: + case XFS_SCRUB_TYPE_SYMLINK: + case XFS_SCRUB_TYPE_PARENT: + xfs_inode_mark_healthy(sc->ip, mask); + break; + case XFS_SCRUB_TYPE_UQUOTA: + case XFS_SCRUB_TYPE_GQUOTA: + case XFS_SCRUB_TYPE_PQUOTA: + xfs_fs_mark_healthy(sc->mp, mask); + break; + case XFS_SCRUB_TYPE_RTBITMAP: + case XFS_SCRUB_TYPE_RTSUM: + xfs_rt_mark_healthy(sc->mp, mask); + break; + default: + break; + } +} + +/* Update filesystem health assessments based on what we found and did. */ +void +xchk_update_health( + struct xfs_scrub *sc, + bool already_fixed) +{ + /* + * If the scrubber finds errors, we mark sick whatever's mentioned in + * sick_mask, no matter whether this is a first scan or an evaluation + * of repair effectiveness. + * + * If there is no direct corruption and we're called after a repair, + * clear whatever's in heal_mask because that's what we fixed. + * + * Otherwise, there's no direct corruption and we didn't repair + * anything, so mark whatever's in sick_mask as healthy. + */ + if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) + xchk_mark_sick(sc, sc->sick_mask); + else if (already_fixed) + xchk_mark_healthy(sc, sc->heal_mask); + else + xchk_mark_healthy(sc, sc->sick_mask); +} diff --git a/fs/xfs/scrub/health.h b/fs/xfs/scrub/health.h new file mode 100644 index 000000000000..e795f4c9a23c --- /dev/null +++ b/fs/xfs/scrub/health.h @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#ifndef __XFS_SCRUB_HEALTH_H__ +#define __XFS_SCRUB_HEALTH_H__ + +unsigned int xchk_health_mask_for_scrub_type(__u32 scrub_type); +void xchk_update_health(struct xfs_scrub *sc, bool already_fixed); + +#endif /* __XFS_SCRUB_HEALTH_H__ */ diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c index 1b2344d00525..b1519dfc5811 100644 --- a/fs/xfs/scrub/scrub.c +++ b/fs/xfs/scrub/scrub.c @@ -40,6 +40,7 @@ #include "scrub/trace.h" #include "scrub/btree.h" #include "scrub/repair.h" +#include "scrub/health.h" /* * Online Scrub and Repair @@ -468,6 +469,7 @@ xfs_scrub_metadata( { struct xfs_scrub sc; struct xfs_mount *mp = ip->i_mount; + unsigned int heal_mask; bool try_harder = false; bool already_fixed = false; int error = 0; @@ -488,6 +490,7 @@ xfs_scrub_metadata( error = xchk_validate_inputs(mp, sm); if (error) goto out; + heal_mask = xchk_health_mask_for_scrub_type(sm->sm_type); xchk_experimental_warning(mp); @@ -499,6 +502,8 @@ xfs_scrub_metadata( sc.ops = &meta_scrub_ops[sm->sm_type]; sc.try_harder = try_harder; sc.sa.agno = NULLAGNUMBER; + sc.heal_mask = heal_mask; + sc.sick_mask = xchk_health_mask_for_scrub_type(sm->sm_type); error = sc.ops->setup(&sc, ip); if (error) goto out_teardown; @@ -519,6 +524,8 @@ xfs_scrub_metadata( } else if (error) goto out_teardown; + xchk_update_health(&sc, already_fixed); + if ((sc.sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) && !already_fixed) { bool needs_fix; @@ -551,6 +558,7 @@ xfs_scrub_metadata( xrep_failure(mp); goto out; } + heal_mask = sc.heal_mask; goto retry_op; } } diff --git a/fs/xfs/scrub/scrub.h b/fs/xfs/scrub/scrub.h index 22f754fba8e5..05f1ad242a35 100644 --- a/fs/xfs/scrub/scrub.h +++ b/fs/xfs/scrub/scrub.h @@ -62,6 +62,17 @@ struct xfs_scrub { struct xfs_inode *ip; void *buf; uint ilock_flags; + + /* Metadata to be marked sick if scrub finds errors. */ + unsigned int sick_mask; + + /* + * Metadata to be marked healthy if repair fixes errors. Some repair + * functions can fix multiple data structures at once, so we have to + * treat sick and heal masks separately. + */ + unsigned int heal_mask; + bool try_harder; bool has_quotaofflock; From patchwork Mon Apr 1 17:11:18 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: 10880447 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 6E2C4922 for ; Mon, 1 Apr 2019 18:07:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55A83286A2 for ; Mon, 1 Apr 2019 18:07:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 499B22880F; Mon, 1 Apr 2019 18:07:25 +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 A631A286A2 for ; Mon, 1 Apr 2019 18:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729169AbfDASHX (ORCPT ); Mon, 1 Apr 2019 14:07:23 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60916 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729526AbfDARLW (ORCPT ); Mon, 1 Apr 2019 13:11:22 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x31H9Lkx131470 for ; Mon, 1 Apr 2019 17:11:20 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=iltskkaghrB61B7lqqR9Dm3LuVUPRX0dR092QLZq+GI=; b=aVYI5rwdzj83LVfYNiSHLCOEMVQ72EJkQcq8LKQIh0DdliymL3CQDGp1tWy9L1AFDsu1 s4O7FZB7e9W/zo0Ralnor/V56OKXXZNlJ8S0jpBoxHrhm5Tk/fqPQOXWmIaPMBdXagvJ 718DkdBPBmTN77QbWKtbp/ILiEGy4hAhBwkWlEpHeIQyCXF/mnBS6VcHZJYnYqUVqXZ7 DEQDWUCYtCiYrp3RbhLjm+SjWjSOYv1H0vckBuzWrh2dhQYj1RKAh5OPuWtxinTty8jw TJ7cEUwHQSFO7e8hkQajtgLkK8a43obf8VJc5iIq72d5usz6dy/BOpxVO/ruoKtJc3RO kw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2rhyvt0cxy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 01 Apr 2019 17:11:20 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x31HBJ3n015532 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 1 Apr 2019 17:11:19 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x31HBJiw007802 for ; Mon, 1 Apr 2019 17:11:19 GMT Received: from localhost (/10.159.239.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Apr 2019 10:11:19 -0700 Subject: [PATCH 10/10] xfs: update health status if we get a clean bill of health From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 01 Apr 2019 10:11:18 -0700 Message-ID: <155413867884.4966.3786317285199498710.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=1 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 If scrub finds that everything is ok with the filesystem, we need a way to tell the health tracking that it can let go of indirect health flags, since indirect flags only mean that at some point in the past we lost some context. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_fs.h | 3 ++ fs/xfs/scrub/common.c | 12 ++++++++++ fs/xfs/scrub/common.h | 1 + fs/xfs/scrub/health.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/scrub/health.h | 1 + fs/xfs/scrub/repair.c | 1 + fs/xfs/scrub/scrub.c | 6 +++++ fs/xfs/scrub/trace.h | 4 ++- 8 files changed, 84 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index fffaead718a5..320274d3809a 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -574,9 +574,10 @@ struct xfs_scrub_metadata { #define XFS_SCRUB_TYPE_UQUOTA 21 /* user quotas */ #define XFS_SCRUB_TYPE_GQUOTA 22 /* group quotas */ #define XFS_SCRUB_TYPE_PQUOTA 23 /* project quotas */ +#define XFS_SCRUB_TYPE_HEALTHY 24 /* everything checked out ok */ /* Number of scrub subcommands. */ -#define XFS_SCRUB_TYPE_NR 24 +#define XFS_SCRUB_TYPE_NR 25 /* i: Repair this metadata. */ #define XFS_SCRUB_IFLAG_REPAIR (1 << 0) diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index 0c54ff55b901..9064ed567e37 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -208,6 +208,18 @@ xchk_ino_set_preen( trace_xchk_ino_preen(sc, ino, __return_address); } +/* Record non-specific corruption. */ +void +xchk_set_corrupt( + struct xfs_scrub *sc) +{ + sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; + xfs_scrub_whine(sc->mp, "type %d ret_ip %pS", + sc->sm->sm_type, + __return_address); + trace_xchk_fs_error(sc, 0, __return_address); +} + /* Record a corrupt block. */ void xchk_block_set_corrupt( diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h index e26a430bd466..1b7b8c555f2e 100644 --- a/fs/xfs/scrub/common.h +++ b/fs/xfs/scrub/common.h @@ -39,6 +39,7 @@ void xchk_block_set_preen(struct xfs_scrub *sc, struct xfs_buf *bp); void xchk_ino_set_preen(struct xfs_scrub *sc, xfs_ino_t ino); +void xchk_set_corrupt(struct xfs_scrub *sc); void xchk_block_set_corrupt(struct xfs_scrub *sc, struct xfs_buf *bp); void xchk_ino_set_corrupt(struct xfs_scrub *sc, xfs_ino_t ino); diff --git a/fs/xfs/scrub/health.c b/fs/xfs/scrub/health.c index dd9986500801..049e802b9418 100644 --- a/fs/xfs/scrub/health.c +++ b/fs/xfs/scrub/health.c @@ -19,6 +19,7 @@ #include "xfs_health.h" #include "scrub/scrub.h" #include "scrub/health.h" +#include "scrub/common.h" static const unsigned int xchk_type_to_health_flag[XFS_SCRUB_TYPE_NR] = { [XFS_SCRUB_TYPE_SB] = XFS_HEALTH_AG_SB, @@ -54,6 +55,60 @@ xchk_health_mask_for_scrub_type( return xchk_type_to_health_flag[scrub_type]; } +/* + * Quick scan to double-check that there isn't any evidence of lingering + * primary health problems. If we're still clear, then the health update will + * take care of clearing the indirect evidence. + */ +int +xchk_health_record( + struct xfs_scrub *sc) +{ + struct xfs_mount *mp = sc->mp; + struct xfs_perag *pag; + xfs_agnumber_t agno; + unsigned int sick; + + sick = xfs_fs_measure_sickness(mp); + if (sick & XFS_HEALTH_FS_PRIMARY) + xchk_set_corrupt(sc); + + sick = xfs_rt_measure_sickness(mp); + if (sick & XFS_HEALTH_RT_PRIMARY) + xchk_set_corrupt(sc); + + for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { + pag = xfs_perag_get(mp, agno); + sick = xfs_ag_measure_sickness(pag); + if (sick & XFS_HEALTH_AG_PRIMARY) + xchk_set_corrupt(sc); + xfs_perag_put(pag); + } + + return 0; +} + +/* + * Scrub gave the filesystem a clean bill of health, so clear all the indirect + * markers of past problems (at least for the fs and ags) so that we can be + * healthy again. + */ +STATIC void +xchk_mark_all_healthy( + struct xfs_mount *mp) +{ + struct xfs_perag *pag; + xfs_agnumber_t agno; + int error = 0; + + xfs_fs_mark_healthy(mp, XFS_HEALTH_FS_INDIRECT); + xfs_rt_mark_healthy(mp, XFS_HEALTH_RT_INDIRECT); + for (agno = 0; error == 0 && agno < mp->m_sb.sb_agcount; agno++) { + pag = xfs_perag_get(mp, agno); + xfs_ag_mark_healthy(pag, XFS_HEALTH_AG_INDIRECT); + xfs_perag_put(pag); + } +} /* Mark metadata unhealthy. */ static void xchk_mark_sick( @@ -149,6 +204,9 @@ xchk_mark_healthy( case XFS_SCRUB_TYPE_RTSUM: xfs_rt_mark_healthy(sc->mp, mask); break; + case XFS_SCRUB_TYPE_HEALTHY: + xchk_mark_all_healthy(sc->mp); + break; default: break; } diff --git a/fs/xfs/scrub/health.h b/fs/xfs/scrub/health.h index e795f4c9a23c..001e5a93273d 100644 --- a/fs/xfs/scrub/health.h +++ b/fs/xfs/scrub/health.h @@ -8,5 +8,6 @@ unsigned int xchk_health_mask_for_scrub_type(__u32 scrub_type); void xchk_update_health(struct xfs_scrub *sc, bool already_fixed); +int xchk_health_record(struct xfs_scrub *sc); #endif /* __XFS_SCRUB_HEALTH_H__ */ diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c index f28f4bad317b..5df67fe5d8ac 100644 --- a/fs/xfs/scrub/repair.c +++ b/fs/xfs/scrub/repair.c @@ -31,6 +31,7 @@ #include "xfs_quota.h" #include "xfs_attr.h" #include "xfs_reflink.h" +#include "xfs_health.h" #include "scrub/xfs_scrub.h" #include "scrub/scrub.h" #include "scrub/common.h" diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c index b1519dfc5811..f446ab57d7b0 100644 --- a/fs/xfs/scrub/scrub.c +++ b/fs/xfs/scrub/scrub.c @@ -348,6 +348,12 @@ static const struct xchk_meta_ops meta_scrub_ops[] = { .scrub = xchk_quota, .repair = xrep_notsupported, }, + [XFS_SCRUB_TYPE_HEALTHY] = { /* fs healthy; clean all reminders */ + .type = ST_FS, + .setup = xchk_setup_fs, + .scrub = xchk_health_record, + .repair = xrep_notsupported, + }, }; /* This isn't a stable feature, warn once per day. */ diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index 3c83e8b3b39c..7c25a38c6f81 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -75,7 +75,8 @@ TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PQUOTA); { XFS_SCRUB_TYPE_RTSUM, "rtsummary" }, \ { XFS_SCRUB_TYPE_UQUOTA, "usrquota" }, \ { XFS_SCRUB_TYPE_GQUOTA, "grpquota" }, \ - { XFS_SCRUB_TYPE_PQUOTA, "prjquota" } + { XFS_SCRUB_TYPE_PQUOTA, "prjquota" }, \ + { XFS_SCRUB_TYPE_HEALTHY, "healthy" } DECLARE_EVENT_CLASS(xchk_class, TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm, @@ -223,6 +224,7 @@ DEFINE_EVENT(xchk_block_error_class, name, \ void *ret_ip), \ TP_ARGS(sc, daddr, ret_ip)) +DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_fs_error); DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_block_error); DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_block_preen);