From patchwork Tue Jan 1 02:22:32 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: 10745717 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 B90226C5 for ; Tue, 1 Jan 2019 02:22:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAFA228C9F for ; Tue, 1 Jan 2019 02:22:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F19A28CA3; Tue, 1 Jan 2019 02:22:40 +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 8E91F28C9F for ; Tue, 1 Jan 2019 02:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728344AbfAACWj (ORCPT ); Mon, 31 Dec 2018 21:22:39 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:56298 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728193AbfAACWj (ORCPT ); Mon, 31 Dec 2018 21:22:39 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012F86w169028 for ; Tue, 1 Jan 2019 02:22:35 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=dtAivQPh/QJURYcar3iocrn/YryAIIKL+2+8IzQrsMs=; b=JWv4v7+qD/Jnn6HTxjAyW9QBkMPAaKQ1J9ADyCSUs5s4cjPzPrcPlwpy4spZqze5M8I7 6t3eREcGeA7dZRe1n05PlnU6hMXSuDf4RlWv5nPDlKmN1+/A5NKQmg/LE6DJfZ8iscdY JA0soUM0eBrn0uzKceVa7skVu50f8bDLnyvsMRitzJqYutQHEk1qsrsEHYyJFSiM+Vi8 tRJ0xtHH8YFNTcgLkYNAHVYgqzvyrdRV3ZTAuFxGs5Vn088AtzMsFLIZDLLHrew7MGBv wxTuKh/2aEx6FPDLrYFEanNnlJHzhIB2e6M37NqWiPqICEZVvOv1T9rNnFZ6Wn5zKNvF 4w== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2pnxedxauk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:22:35 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x012MYwG012801 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:22:34 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x012MYpB028718 for ; Tue, 1 Jan 2019 02:22:34 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:22:34 -0800 Subject: [PATCH 01/13] xfs: create imeta abstractions to get and set metadata inodes From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:22:32 -0800 Message-ID: <154630935225.21716.14557647854216921704.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 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 Create some helper routines to get and set metadata inode numbers instead of open-coding them throughout xfs. Signed-off-by: Darrick J. Wong --- fs/xfs/Makefile | 1 fs/xfs/libxfs/xfs_imeta.c | 381 +++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_imeta.h | 43 +++++ fs/xfs/libxfs/xfs_types.c | 5 - fs/xfs/xfs_mount.c | 21 ++ fs/xfs/xfs_trace.h | 29 +++ 6 files changed, 477 insertions(+), 3 deletions(-) create mode 100644 fs/xfs/libxfs/xfs_imeta.c create mode 100644 fs/xfs/libxfs/xfs_imeta.h diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index ab373aeb0c37..57651a47b5e9 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -46,6 +46,7 @@ xfs-y += $(addprefix libxfs/, \ xfs_ialloc.o \ xfs_ialloc_btree.o \ xfs_iext_tree.o \ + xfs_imeta.o \ xfs_inode_fork.o \ xfs_inode_buf.o \ xfs_inode_util.o \ diff --git a/fs/xfs/libxfs/xfs_imeta.c b/fs/xfs/libxfs/xfs_imeta.c new file mode 100644 index 000000000000..2599b236f6de --- /dev/null +++ b/fs/xfs/libxfs/xfs_imeta.c @@ -0,0 +1,381 @@ +// 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_trans.h" +#include "xfs_imeta.h" +#include "xfs_trace.h" +#include "xfs_inode.h" + +/* + * Metadata Inode Number Management + * ================================ + * + * These functions provide an abstraction layer for looking up, creating, and + * deleting metadata inodes. These pointers live in the in-core superblock, + * so the functions moderate access to those fields and take care of logging. + * + * For the five existing metadata inodes (real time bitmap & summary; and the + * user, group, and quotas) we'll continue to maintain the in-core superblock + * inodes for reads and only require xfs_imeta_create and xfs_imeta_unlink to + * persist changes. New metadata inode types must only use the xfs_imeta_* + * functions. + * + * Callers wishing to create or unlink a metadata inode must pass in a + * xfs_imeta_end structure. After committing or cancelling the transaction, + * this structure must be passed to xfs_imeta_end_update to free resources that + * cannot be freed during the transaction. + * + * Right now we only support callers passing in the predefined metadata inode + * paths; the goal is that callers will some day locate metadata inodes based + * on a metadata inode directory structure. + */ + +/* Static metadata inode paths */ + +const struct xfs_imeta_path XFS_IMETA_RTBITMAP = { + .bogus = 0, +}; + +const struct xfs_imeta_path XFS_IMETA_RTSUMMARY = { + .bogus = 1, +}; + +const struct xfs_imeta_path XFS_IMETA_USRQUOTA = { + .bogus = 2, +}; + +const struct xfs_imeta_path XFS_IMETA_GRPQUOTA = { + .bogus = 3, +}; + +const struct xfs_imeta_path XFS_IMETA_PRJQUOTA = { + .bogus = 4, +}; + +/* Are these two paths equal? */ +STATIC bool +xfs_imeta_path_compare( + const struct xfs_imeta_path *a, + const struct xfs_imeta_path *b) +{ + return a == b; +} + +/* Is this path ok? */ +static inline bool +xfs_imeta_path_check( + const struct xfs_imeta_path *path) +{ + return true; +} + +/* Functions for storing and retrieving superblock inode values. */ + +/* Mapping of metadata inode paths to in-core superblock values. */ +static const struct xfs_imeta_sbmap { + const struct xfs_imeta_path *path; + unsigned int offset; +} xfs_imeta_sbmaps[] = { + { + .path = &XFS_IMETA_RTBITMAP, + .offset = offsetof(struct xfs_sb, sb_rbmino), + }, + { + .path = &XFS_IMETA_RTSUMMARY, + .offset = offsetof(struct xfs_sb, sb_rsumino), + }, + { + .path = &XFS_IMETA_USRQUOTA, + .offset = offsetof(struct xfs_sb, sb_uquotino), + }, + { + .path = &XFS_IMETA_GRPQUOTA, + .offset = offsetof(struct xfs_sb, sb_gquotino), + }, + { + .path = &XFS_IMETA_PRJQUOTA, + .offset = offsetof(struct xfs_sb, sb_pquotino), + }, + { NULL, 0 }, +}; + +/* Return a pointer to the in-core superblock inode value. */ +static inline xfs_ino_t * +xfs_imeta_sbmap_to_inop( + struct xfs_mount *mp, + const struct xfs_imeta_sbmap *map) +{ + return (xfs_ino_t *)(((char *)&mp->m_sb) + map->offset); +} + +/* Compute location of metadata inode pointer in the in-core superblock */ +static inline xfs_ino_t * +xfs_imeta_path_to_sb_inop( + struct xfs_mount *mp, + const struct xfs_imeta_path *path) +{ + const struct xfs_imeta_sbmap *p; + + for (p = xfs_imeta_sbmaps; p->path; p++) + if (xfs_imeta_path_compare(p->path, path)) + return xfs_imeta_sbmap_to_inop(mp, p); + + return NULL; +} + +/* Look up a superblock metadata inode by its path. */ +STATIC int +xfs_imeta_sb_lookup( + struct xfs_mount *mp, + const struct xfs_imeta_path *path, + xfs_ino_t *inop) +{ + xfs_ino_t *sb_inop; + + sb_inop = xfs_imeta_path_to_sb_inop(mp, path); + if (!sb_inop) + return -EINVAL; + + trace_xfs_imeta_sb_lookup(mp, sb_inop); + *inop = *sb_inop; + return 0; +} + +/* + * Create a new metadata inode and set a superblock pointer to this new inode. + * The superblock field must not already be pointing to an inode. + */ +STATIC int +xfs_imeta_sb_create( + struct xfs_trans **tpp, + const struct xfs_imeta_path *path, + umode_t mode, + struct xfs_inode **ipp) +{ + struct xfs_ialloc_args args = { + .ops = &xfs_default_ialloc_ops, + .nlink = S_ISDIR(mode) ? 2 : 1, + .mode = mode, + }; + struct xfs_mount *mp = (*tpp)->t_mountp; + xfs_ino_t *sb_inop; + int error; + + /* Reject if the sb already points to some inode. */ + sb_inop = xfs_imeta_path_to_sb_inop(mp, path); + if (!sb_inop) + return -EINVAL; + + if (*sb_inop != NULLFSINO) + return -EEXIST; + + /* Otherwise, create the inode and set the sb pointer. */ + error = xfs_dir_ialloc(tpp, &args, ipp); + if (error) + return error; + + + *sb_inop = (*ipp)->i_ino; + trace_xfs_imeta_sb_create(mp, sb_inop); + xfs_log_sb(*tpp); + return 0; +} + +/* + * Clear the given inode pointer from the superblock and drop the link count + * of the metadata inode. + */ +STATIC int +xfs_imeta_sb_unlink( + struct xfs_trans **tpp, + const struct xfs_imeta_path *path, + struct xfs_inode *ip) +{ + struct xfs_mount *mp = (*tpp)->t_mountp; + xfs_ino_t *sb_inop; + + sb_inop = xfs_imeta_path_to_sb_inop(mp, path); + if (!sb_inop) + return -EINVAL; + + /* Reject if the sb doesn't point to the inode that was passed in. */ + if (*sb_inop != ip->i_ino) + return -ENOENT; + + *sb_inop = NULLFSINO; + trace_xfs_imeta_sb_unlink(mp, sb_inop); + xfs_log_sb(*tpp); + return xfs_droplink(*tpp, ip); +} + +/* Set the given inode pointer to NULL in the superblock. */ +STATIC int +xfs_imeta_sb_zap( + struct xfs_trans **tpp, + const struct xfs_imeta_path *path) +{ + struct xfs_mount *mp = (*tpp)->t_mountp; + xfs_ino_t *sb_inop; + + sb_inop = xfs_imeta_path_to_sb_inop(mp, path); + if (!sb_inop) + return -EINVAL; + + *sb_inop = NULLFSINO; + trace_xfs_imeta_sb_zap(mp, sb_inop); + xfs_log_sb(*tpp); + return 0; +} + +/* General functions for managing metadata inode pointers */ + +/* + * Is this metadata inode pointer ok? We allow the fields to be set to + * NULLFSINO if the metadata structure isn't present, and we don't allow + * obviously incorrect inode pointers. + */ +static inline bool +xfs_imeta_verify( + struct xfs_mount *mp, + xfs_ino_t ino) +{ + if (ino == NULLFSINO) + return true; + return xfs_verify_ino(mp, ino); +} + +/* Look up a metadata inode by its path. */ +int +xfs_imeta_lookup( + struct xfs_mount *mp, + const struct xfs_imeta_path *path, + xfs_ino_t *inop) +{ + xfs_ino_t ino; + int error; + + ASSERT(xfs_imeta_path_check(path)); + + error = xfs_imeta_sb_lookup(mp, path, &ino); + if (error) + return error; + + if (!xfs_imeta_verify(mp, ino)) + return -EFSCORRUPTED; + + *inop = ino; + return 0; +} + +/* + * Create a metadata inode with the given @mode, and insert it into the + * metadata directory tree at the given @path. The path (up to the final + * component) must already exist. The new metadata inode @ipp will be ijoined + * and logged to @tpp, with the ILOCK held until the next transaction commit. + * The caller must provide a @cleanup structure. + * + * NOTE: This function may pass a child inode @ipp back to the caller along + * with an error status code. The caller must always check for a non-null + * child inode and release it. + */ +int +xfs_imeta_create( + struct xfs_trans **tpp, + const struct xfs_imeta_path *path, + umode_t mode, + struct xfs_inode **ipp, + struct xfs_imeta_end *cleanup) +{ + ASSERT(xfs_imeta_path_check(path)); + *ipp = NULL; + + return xfs_imeta_sb_create(tpp, path, mode, ipp); +} + +/* + * Unlink a metadata inode @ip from the metadata directory given by @path. The + * metadata inode must not be ILOCKed. Upon return, the inode will be ijoined + * and logged to @tpp, and returned with reduced link count, ready to be + * released. The caller must provide a @cleanup structure. + */ +int +xfs_imeta_unlink( + struct xfs_trans **tpp, + const struct xfs_imeta_path *path, + struct xfs_inode *ip, + struct xfs_imeta_end *cleanup) +{ + ASSERT(xfs_imeta_path_check(path)); + ASSERT(xfs_imeta_verify((*tpp)->t_mountp, ip->i_ino)); + + return xfs_imeta_sb_unlink(tpp, path, ip); +} + +/* + * Forcibly clear the metadata pointer noted by @path so that a subsequent + * lookup will return NULLFSINO. If the pointer was not already NULLFSINO, the + * caller is responsible for cleaning up those resources; in other words, this + * function is only to be used when blowing out a totally destroyed metadata + * inode. The caller must provide a @cleanup structure. + */ +int +xfs_imeta_zap( + struct xfs_trans **tpp, + const struct xfs_imeta_path *path, + struct xfs_imeta_end *cleanup) +{ + ASSERT(xfs_imeta_path_check(path)); + + return xfs_imeta_sb_zap(tpp, path); +} + +/* + * Clean up after committing (or cancelling) a metadata inode creation or + * removal. + */ +void +xfs_imeta_end_update( + struct xfs_mount *mp, + struct xfs_imeta_end *cleanup, + int error) +{ + trace_xfs_imeta_end_update(mp, 0, error, _RET_IP_); +} + +/* Does this inode number refer to a static metadata inode? */ +bool +xfs_is_static_meta_ino( + struct xfs_mount *mp, + xfs_ino_t ino) +{ + const struct xfs_imeta_sbmap *p; + + if (ino == NULLFSINO) + return false; + + for (p = xfs_imeta_sbmaps; p->path; p++) + if (ino == *xfs_imeta_sbmap_to_inop(mp, p)) + return true; + + return false; +} + +/* Ensure that the in-core superblock has all the values that it should. */ +int +xfs_imeta_mount( + struct xfs_mount *mp) +{ + return 0; +} diff --git a/fs/xfs/libxfs/xfs_imeta.h b/fs/xfs/libxfs/xfs_imeta.h new file mode 100644 index 000000000000..373d40703dec --- /dev/null +++ b/fs/xfs/libxfs/xfs_imeta.h @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#ifndef __XFS_IMETA_H__ +#define __XFS_IMETA_H__ + +/* Key for looking up metadata inodes. */ +struct xfs_imeta_path { + /* Temporary: integer to keep the static imeta definitions unique */ + int bogus; +}; + +/* Cleanup widget for metadata inode creation and deletion. */ +struct xfs_imeta_end { + /* empty for now */ +}; + +/* Lookup keys for static metadata inodes. */ +extern const struct xfs_imeta_path XFS_IMETA_RTBITMAP; +extern const struct xfs_imeta_path XFS_IMETA_RTSUMMARY; +extern const struct xfs_imeta_path XFS_IMETA_USRQUOTA; +extern const struct xfs_imeta_path XFS_IMETA_GRPQUOTA; +extern const struct xfs_imeta_path XFS_IMETA_PRJQUOTA; + +int xfs_imeta_lookup(struct xfs_mount *mp, const struct xfs_imeta_path *path, + xfs_ino_t *ino); + +int xfs_imeta_create(struct xfs_trans **tpp, const struct xfs_imeta_path *path, + umode_t mode, struct xfs_inode **ipp, + struct xfs_imeta_end *cleanup); +int xfs_imeta_unlink(struct xfs_trans **tpp, const struct xfs_imeta_path *path, + struct xfs_inode *ip, struct xfs_imeta_end *cleanup); +int xfs_imeta_zap(struct xfs_trans **tpp, const struct xfs_imeta_path *path, + struct xfs_imeta_end *cleanup); +void xfs_imeta_end_update(struct xfs_mount *mp, struct xfs_imeta_end *cleanup, + int error); + +bool xfs_is_static_meta_ino(struct xfs_mount *mp, xfs_ino_t ino); +int xfs_imeta_mount(struct xfs_mount *mp); + +#endif /* __XFS_IMETA_H__ */ diff --git a/fs/xfs/libxfs/xfs_types.c b/fs/xfs/libxfs/xfs_types.c index 24715ed086e3..d05ccfabbc9c 100644 --- a/fs/xfs/libxfs/xfs_types.c +++ b/fs/xfs/libxfs/xfs_types.c @@ -20,6 +20,7 @@ #include "xfs_alloc_btree.h" #include "xfs_alloc.h" #include "xfs_ialloc.h" +#include "xfs_imeta.h" /* Find the size of the AG, in blocks. */ xfs_agblock_t @@ -140,9 +141,7 @@ xfs_internal_inum( struct xfs_mount *mp, xfs_ino_t ino) { - return ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || - (xfs_sb_version_hasquota(&mp->m_sb) && - xfs_is_quota_inode(&mp->m_sb, ino)); + return xfs_is_static_meta_ino(mp, ino); } /* diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 0bcab017b12b..b895368c64fb 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_imeta.h" static DEFINE_MUTEX(xfs_uuid_table_mutex); @@ -665,6 +666,22 @@ xfs_check_summary_counts( return xfs_initialize_perag_data(mp, mp->m_sb.sb_agcount); } +STATIC int +xfs_mountfs_imeta( + struct xfs_mount *mp) +{ + int error; + + error = xfs_imeta_mount(mp); + if (error) { + xfs_warn(mp, "Failed to load metadata inode info, error %d", + error); + return error; + } + + return 0; +} + /* * This function does the following on an initial mount of a file system: * - reads the superblock from disk and init the mount struct @@ -902,6 +919,10 @@ xfs_mountfs( if (error) goto out_log_dealloc; + error = xfs_mountfs_imeta(mp); + if (error) + goto out_log_dealloc; + /* * Get and sanity-check the root inode. * Save the pointer to it in the mount structure. diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 02683ec06164..5392cc85e951 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -3381,6 +3381,35 @@ DEFINE_TRANS_EVENT(xfs_trans_roll); DEFINE_TRANS_EVENT(xfs_trans_add_item); DEFINE_TRANS_EVENT(xfs_trans_free_items); +DECLARE_EVENT_CLASS(xfs_imeta_sb_class, + TP_PROTO(struct xfs_mount *mp, xfs_ino_t *sb_inop), + TP_ARGS(mp, sb_inop), + TP_STRUCT__entry( + __field(dev_t, dev) + __field(unsigned int, sb_offset) + __field(xfs_ino_t, ino) + ), + TP_fast_assign( + __entry->dev = mp->m_super->s_dev; + __entry->sb_offset = (char *)sb_inop - (char *)&mp->m_sb; + __entry->ino = *sb_inop; + ), + TP_printk("dev %d:%d sb_offset 0x%x ino 0x%llx", + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->sb_offset, + __entry->ino) +) + +#define DEFINE_IMETA_SB_EVENT(name) \ +DEFINE_EVENT(xfs_imeta_sb_class, name, \ + TP_PROTO(struct xfs_mount *mp, xfs_ino_t *sb_inop), \ + TP_ARGS(mp, sb_inop)) +DEFINE_IMETA_SB_EVENT(xfs_imeta_sb_lookup); +DEFINE_IMETA_SB_EVENT(xfs_imeta_sb_create); +DEFINE_IMETA_SB_EVENT(xfs_imeta_sb_unlink); +DEFINE_IMETA_SB_EVENT(xfs_imeta_sb_zap); +DEFINE_AG_ERROR_EVENT(xfs_imeta_end_update); + #endif /* _TRACE_XFS_H */ #undef TRACE_INCLUDE_PATH From patchwork Tue Jan 1 02:22:39 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: 10745719 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 B643113AD for ; Tue, 1 Jan 2019 02:22:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9F4428C9F for ; Tue, 1 Jan 2019 02:22:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EB4C28CA3; Tue, 1 Jan 2019 02:22:44 +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 2C38A28C9F for ; Tue, 1 Jan 2019 02:22:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728355AbfAACWn (ORCPT ); Mon, 31 Dec 2018 21:22:43 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:56382 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728193AbfAACWn (ORCPT ); Mon, 31 Dec 2018 21:22:43 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012E2G9168464 for ; Tue, 1 Jan 2019 02:22: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=0Hewb78q2xYh8EL0nc4xNaPziImd34SmUJh/mI547PM=; b=ShjKsdwEd40ofWxtgLqiwaXsHMqWvJNkLQJoEn4J3zCyAXlkokSzrxwEArkC1b9uMhxl NnJfaHBkRXK+X4h6BujvfCs+S3bqLZj9lWG5TEez0JzDIGfyj3mrOjTfZTSXvzZzhXep /fMQKxUXZVC8HBsyL/Z9YprbIfeOqYLQ1d9ZRIj8K2pia835CWvL6w5JWyC+5JrKy3JJ 7DVxqP82xIGp8GYY5I2Z+gvX39uoUraNOsd2fLJGzilAAPEDsx1Seejl8/rYHPqa9dG6 PXorfAqevCSVrTSKJBI5IqVrpXa7JoxVA77UY2Ub8w3s9h8weY+zuQoXfPbg1N4gzG0Q YQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2pnxedxaun-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:22:42 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x012MeNq030052 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:22:41 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 x012MeBW027271 for ; Tue, 1 Jan 2019 02:22:40 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:22:40 -0800 Subject: [PATCH 02/13] xfs: create transaction reservations for metadata inode operations From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:22:39 -0800 Message-ID: <154630935956.21716.7954680040325712549.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 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 Create transaction reservation types and block reservation helpers to help us calculate transaction requirements. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_imeta.c | 20 +++++++++++++ fs/xfs/libxfs/xfs_imeta.h | 3 ++ fs/xfs/libxfs/xfs_trans_resv.c | 61 ++++++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_trans_resv.h | 2 + 4 files changed, 86 insertions(+) diff --git a/fs/xfs/libxfs/xfs_imeta.c b/fs/xfs/libxfs/xfs_imeta.c index 2599b236f6de..86b05992599a 100644 --- a/fs/xfs/libxfs/xfs_imeta.c +++ b/fs/xfs/libxfs/xfs_imeta.c @@ -17,6 +17,10 @@ #include "xfs_imeta.h" #include "xfs_trace.h" #include "xfs_inode.h" +#include "xfs_bmap_btree.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_trans_space.h" /* * Metadata Inode Number Management @@ -379,3 +383,19 @@ xfs_imeta_mount( { return 0; } + +/* Calculate the log block reservation to create a metadata inode. */ +unsigned int +xfs_imeta_create_space_res( + struct xfs_mount *mp) +{ + return XFS_IALLOC_SPACE_RES(mp); +} + +/* Calculate the log block reservation to unlink a metadata inode. */ +unsigned int +xfs_imeta_unlink_space_res( + struct xfs_mount *mp) +{ + return XFS_REMOVE_SPACE_RES(mp); +} diff --git a/fs/xfs/libxfs/xfs_imeta.h b/fs/xfs/libxfs/xfs_imeta.h index 373d40703dec..7740e7bd03e5 100644 --- a/fs/xfs/libxfs/xfs_imeta.h +++ b/fs/xfs/libxfs/xfs_imeta.h @@ -40,4 +40,7 @@ void xfs_imeta_end_update(struct xfs_mount *mp, struct xfs_imeta_end *cleanup, bool xfs_is_static_meta_ino(struct xfs_mount *mp, xfs_ino_t ino); int xfs_imeta_mount(struct xfs_mount *mp); +unsigned int xfs_imeta_create_space_res(struct xfs_mount *mp); +unsigned int xfs_imeta_unlink_space_res(struct xfs_mount *mp); + #endif /* __XFS_IMETA_H__ */ diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index bf9815743114..dd3bf0c63410 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c @@ -778,6 +778,56 @@ xfs_calc_sb_reservation( return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize); } +/* + * Metadata inode creation needs enough space to create or mkdir a directory, + * plus logging the superblock. + */ +static unsigned int +xfs_calc_imeta_create_resv( + struct xfs_mount *mp, + struct xfs_trans_resv *resp) +{ + unsigned int ret; + + ret = xfs_calc_buf_res(1, mp->m_sb.sb_sectsize); + ret += resp->tr_create.tr_logres; + return ret; +} + +/* Metadata inode creation needs enough rounds to create or mkdir a directory */ +static int +xfs_calc_imeta_create_count( + struct xfs_mount *mp, + struct xfs_trans_resv *resp) +{ + return resp->tr_create.tr_logcount; +} + +/* + * Metadata inode unlink needs enough space to remove a file plus logging the + * superblock. + */ +static unsigned int +xfs_calc_imeta_unlink_resv( + struct xfs_mount *mp, + struct xfs_trans_resv *resp) +{ + unsigned int ret; + + ret = xfs_calc_buf_res(1, mp->m_sb.sb_sectsize); + ret += resp->tr_remove.tr_logres; + return ret; +} + +/* Metadata inode creation needs enough rounds to remove a file. */ +static int +xfs_calc_imeta_unlink_count( + struct xfs_mount *mp, + struct xfs_trans_resv *resp) +{ + return resp->tr_remove.tr_logcount; +} + void xfs_trans_resv_calc( struct xfs_mount *mp, @@ -888,4 +938,15 @@ xfs_trans_resv_calc( resp->tr_clearagi.tr_logres = xfs_calc_clear_agi_bucket_reservation(mp); resp->tr_growrtzero.tr_logres = xfs_calc_growrtzero_reservation(mp); resp->tr_growrtfree.tr_logres = xfs_calc_growrtfree_reservation(mp); + + /* metadata inode creation and unlink */ + resp->tr_imeta_create.tr_logres = xfs_calc_imeta_create_resv(mp, resp); + resp->tr_imeta_create.tr_logcount = + xfs_calc_imeta_create_count(mp, resp); + resp->tr_imeta_create.tr_logflags |= XFS_TRANS_PERM_LOG_RES; + + resp->tr_imeta_unlink.tr_logres = xfs_calc_imeta_unlink_resv(mp, resp); + resp->tr_imeta_unlink.tr_logcount = + xfs_calc_imeta_unlink_count(mp, resp); + resp->tr_imeta_unlink.tr_logflags |= XFS_TRANS_PERM_LOG_RES; } diff --git a/fs/xfs/libxfs/xfs_trans_resv.h b/fs/xfs/libxfs/xfs_trans_resv.h index 7241ab28cf84..7f7d86671319 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.h +++ b/fs/xfs/libxfs/xfs_trans_resv.h @@ -50,6 +50,8 @@ struct xfs_trans_resv { struct xfs_trans_res tr_qm_equotaoff;/* end of turn quota off */ struct xfs_trans_res tr_sb; /* modify superblock */ struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */ + struct xfs_trans_res tr_imeta_create; /* create metadata inode */ + struct xfs_trans_res tr_imeta_unlink; /* unlink metadata inode */ }; /* shorthand way of accessing reservation structure */ From patchwork Tue Jan 1 02:22:45 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: 10745721 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 378D313AD for ; Tue, 1 Jan 2019 02:22:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 274BD28C9F for ; Tue, 1 Jan 2019 02:22:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 187C728CA3; Tue, 1 Jan 2019 02:22:50 +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 A8C3F28C9F for ; Tue, 1 Jan 2019 02:22:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728382AbfAACWt (ORCPT ); Mon, 31 Dec 2018 21:22:49 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:39408 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728193AbfAACWt (ORCPT ); Mon, 31 Dec 2018 21:22:49 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012FDLA174239 for ; Tue, 1 Jan 2019 02:22:47 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=Zyo8CP3lxkdO7CzWcpAaY1tshrKFHg3P5c9+vhsLXYE=; b=RFrpnHQt1BwFzpXc8gD40wnXTy68vAlju7z1LFvGMg3W3nLfcd4fZuPrHhbXEABdFF1O MqAB8yJS1ekqkLTxJ/8D4Rmwa1ArnOEWqrzhpVWA0lUAtU5LMf85JDnByBEK765lawqg zQU5eEsTTwIw4OX6W9t8x3zp9WQoqD8BnN2T4+XADDzajnxu2yMWo/pNjvp6M13VKLqd R2qdixue3fHc5FDDOkbkEgUN1L9NTA+/MwFOTgNoPMj4m0nNm175kreVH5JCorkTbaGB SkW4ZzlzlOIo/vP04HSRZfAXx11SDMCsS6bDDXdy9MGFlxPWzmnyRQY/6lzmoqNpbT9P oQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2pp1jqx454-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:22:47 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x012Mkf9015675 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:22:46 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x012Mkkq027294 for ; Tue, 1 Jan 2019 02:22:46 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:22:46 -0800 Subject: [PATCH 03/13] xfs: refactor the v4 group/project inode pointer switch From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:22:45 -0800 Message-ID: <154630936571.21716.17710862173783712576.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 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 Refactor the group and project quota inode pointer switcheroo that happens only on v4 filesystems into a separate function prior to enhancing the xfs_qm_qino_alloc function. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_qm.c | 79 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 58be2ef90351..b5f2853a5009 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -742,6 +742,53 @@ xfs_qm_destroy_quotainfo( mp->m_quotainfo = NULL; } +/* + * Switch the group and project quota in-core inode pointers if needed. + * + * On v4 superblocks that don't have separate pquotino, we share an inode + * between gquota and pquota. If the on-disk superblock has GQUOTA and the + * filesystem is now mounted with PQUOTA, just use sb_gquotino for sb_pquotino + * and vice-versa. + */ +STATIC int +xfs_qm_qino_switch( + struct xfs_mount *mp, + struct xfs_inode **ip, + unsigned int flags, + bool *need_alloc) +{ + xfs_ino_t ino = NULLFSINO; + int error; + + if (xfs_sb_version_has_pquotino(&mp->m_sb) || + !(flags & (XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA))) + return 0; + + if ((flags & XFS_QMOPT_PQUOTA) && + (mp->m_sb.sb_gquotino != NULLFSINO)) { + ino = mp->m_sb.sb_gquotino; + if (mp->m_sb.sb_pquotino != NULLFSINO) + return -EFSCORRUPTED; + } else if ((flags & XFS_QMOPT_GQUOTA) && + (mp->m_sb.sb_pquotino != NULLFSINO)) { + ino = mp->m_sb.sb_pquotino; + if (mp->m_sb.sb_gquotino != NULLFSINO) + return -EFSCORRUPTED; + } + + if (ino == NULLFSINO) + return 0; + + error = xfs_iget(mp, NULL, ino, 0, 0, ip); + if (error) + return error; + + mp->m_sb.sb_gquotino = NULLFSINO; + mp->m_sb.sb_pquotino = NULLFSINO; + *need_alloc = false; + return 0; +} + /* * Create an inode and return with a reference already taken, but unlocked * This is how we create quota inodes @@ -762,35 +809,9 @@ xfs_qm_qino_alloc( bool need_alloc = true; *ip = NULL; - /* - * With superblock that doesn't have separate pquotino, we - * share an inode between gquota and pquota. If the on-disk - * superblock has GQUOTA and the filesystem is now mounted - * with PQUOTA, just use sb_gquotino for sb_pquotino and - * vice-versa. - */ - if (!xfs_sb_version_has_pquotino(&mp->m_sb) && - (flags & (XFS_QMOPT_PQUOTA|XFS_QMOPT_GQUOTA))) { - xfs_ino_t ino = NULLFSINO; - - if ((flags & XFS_QMOPT_PQUOTA) && - (mp->m_sb.sb_gquotino != NULLFSINO)) { - ino = mp->m_sb.sb_gquotino; - ASSERT(mp->m_sb.sb_pquotino == NULLFSINO); - } else if ((flags & XFS_QMOPT_GQUOTA) && - (mp->m_sb.sb_pquotino != NULLFSINO)) { - ino = mp->m_sb.sb_pquotino; - ASSERT(mp->m_sb.sb_gquotino == NULLFSINO); - } - if (ino != NULLFSINO) { - error = xfs_iget(mp, NULL, ino, 0, 0, ip); - if (error) - return error; - mp->m_sb.sb_gquotino = NULLFSINO; - mp->m_sb.sb_pquotino = NULLFSINO; - need_alloc = false; - } - } + error = xfs_qm_qino_switch(mp, ip, flags, &need_alloc); + if (error) + return error; error = xfs_trans_alloc(mp, &M_RES(mp)->tr_create, XFS_QM_QINOCREATE_SPACE_RES(mp), 0, 0, &tp); From patchwork Tue Jan 1 02:22:51 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: 10745723 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 93F966C5 for ; Tue, 1 Jan 2019 02:23:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 871CC28C9F for ; Tue, 1 Jan 2019 02:23:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B52C28CA3; Tue, 1 Jan 2019 02:23:01 +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 0B5CF28C9F for ; Tue, 1 Jan 2019 02:23:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728383AbfAACXA (ORCPT ); Mon, 31 Dec 2018 21:23:00 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:56538 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728193AbfAACXA (ORCPT ); Mon, 31 Dec 2018 21:23:00 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012F3BA169015 for ; Tue, 1 Jan 2019 02:22: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=mPOniM5OawwVjgZJ4rRfSXVujcmBrJrLtDiXlgY6qlI=; b=XOChYRNxeU4Ztu5FYg90JU2Xo4IDUOGD5exxytivByfgNv9gGjcAS/kxSDIFtmoWXR4Y Vv1JUPQc+z3nzHdTYFuBXSRJsJFRFi1B90AOyCV5zOB/9+2Fl+w6hJY5Tj603nEac9VS 0s1tMO3iMc+NLkHu/c0ak6I3Pm/zc3M9RW+uPmKEunE/jz7I0y52n7ahsvnq/vP1rZXH gg0SAoI9lPjMsTi/pQMiQ3ntV8QPSTgoMrAMAg68Ws95fzl7cJ0uhaAaZ4+brSIseIFM we6/wOvWzE3ciMU0tchEFk2Q593W1Wy1PPyfN32GukoQSg0HwHovgCQZSxt4g7VUAHxA sA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2pnxedxaut-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:22:58 +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 x012Mrmm015790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:22:53 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x012MqoB008360 for ; Tue, 1 Jan 2019 02:22:53 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:22:52 -0800 Subject: [PATCH 04/13] xfs: convert all users to xfs_imeta_log From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:22:51 -0800 Message-ID: <154630937173.21716.11939017688750544410.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 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 Convert all open-coded sb metadata inode pointer logging to use xfs_imeta_log. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_qm.c | 78 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index b5f2853a5009..4b8a48fb5780 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -26,6 +26,7 @@ #include "xfs_trace.h" #include "xfs_icache.h" #include "xfs_cksum.h" +#include "xfs_imeta.h" /* * The global quota manager. There is only one of these for the entire @@ -742,6 +743,18 @@ xfs_qm_destroy_quotainfo( mp->m_quotainfo = NULL; } +static inline const struct xfs_imeta_path * +xfs_qflags_to_imeta( + unsigned int qflags) +{ + if (qflags & XFS_QMOPT_UQUOTA) + return &XFS_IMETA_USRQUOTA; + else if (qflags & XFS_QMOPT_GQUOTA) + return &XFS_IMETA_GRPQUOTA; + else + return &XFS_IMETA_PRJQUOTA; +} + /* * Switch the group and project quota in-core inode pointers if needed. * @@ -749,6 +762,12 @@ xfs_qm_destroy_quotainfo( * between gquota and pquota. If the on-disk superblock has GQUOTA and the * filesystem is now mounted with PQUOTA, just use sb_gquotino for sb_pquotino * and vice-versa. + * + * We tolerate the direct manipulation of the in-core sb quota inode pointers + * here because calling xfs_imeta_log is only really required for filesystems + * with the metadata directory feature. That feature requires a v5 superblock, + * which always supports simultaneous group and project quotas, so we'll never + * get here. */ STATIC int xfs_qm_qino_switch( @@ -783,8 +802,13 @@ xfs_qm_qino_switch( if (error) return error; - mp->m_sb.sb_gquotino = NULLFSINO; - mp->m_sb.sb_pquotino = NULLFSINO; + if (flags & XFS_QMOPT_PQUOTA) { + mp->m_sb.sb_gquotino = NULLFSINO; + mp->m_sb.sb_pquotino = ino; + } else if (flags & XFS_QMOPT_GQUOTA) { + mp->m_sb.sb_gquotino = ino; + mp->m_sb.sb_pquotino = NULLFSINO; + } *need_alloc = false; return 0; } @@ -795,37 +819,26 @@ xfs_qm_qino_switch( */ STATIC int xfs_qm_qino_alloc( - xfs_mount_t *mp, - xfs_inode_t **ip, - uint flags) + struct xfs_mount *mp, + struct xfs_inode **ip, + uint flags) { - struct xfs_ialloc_args args = { - .ops = &xfs_default_ialloc_ops, - .nlink = 1, - .mode = S_IFREG, - }; - xfs_trans_t *tp; - int error; - bool need_alloc = true; + struct xfs_imeta_end ic; + struct xfs_trans *tp; + const struct xfs_imeta_path *path = xfs_qflags_to_imeta(flags); + int error; + bool need_alloc = true; *ip = NULL; error = xfs_qm_qino_switch(mp, ip, flags, &need_alloc); if (error) return error; - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_create, - XFS_QM_QINOCREATE_SPACE_RES(mp), 0, 0, &tp); + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_imeta_create, + xfs_imeta_create_space_res(mp), 0, 0, &tp); if (error) return error; - if (need_alloc) { - error = xfs_dir_ialloc(&tp, &args, ip); - if (error) { - xfs_trans_cancel(tp); - return error; - } - } - /* * Make the changes in the superblock, and log those too. * sbfields arg may contain fields other than *QUOTINO; @@ -843,22 +856,27 @@ xfs_qm_qino_alloc( /* qflags will get updated fully _after_ quotacheck */ mp->m_sb.sb_qflags = mp->m_qflags & XFS_ALL_QUOTA_ACCT; } - if (flags & XFS_QMOPT_UQUOTA) - mp->m_sb.sb_uquotino = (*ip)->i_ino; - else if (flags & XFS_QMOPT_GQUOTA) - mp->m_sb.sb_gquotino = (*ip)->i_ino; - else - mp->m_sb.sb_pquotino = (*ip)->i_ino; spin_unlock(&mp->m_sb_lock); xfs_log_sb(tp); + if (need_alloc) { + error = xfs_imeta_create(&tp, path, S_IFREG, ip, &ic); + if (error) { + xfs_trans_cancel(tp); + xfs_imeta_end_update(mp, &ic, error); + return error; + } + } + error = xfs_trans_commit(tp); if (error) { ASSERT(XFS_FORCED_SHUTDOWN(mp)); xfs_alert(mp, "%s failed (error %d)!", __func__, error); } - if (need_alloc) + if (need_alloc) { + xfs_imeta_end_update(mp, &ic, error); xfs_finish_inode_setup(*ip); + } return error; } From patchwork Tue Jan 1 02:22:57 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: 10745725 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 536B46C5 for ; Tue, 1 Jan 2019 02:23:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4710D28C9F for ; Tue, 1 Jan 2019 02:23:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B97B28CA3; Tue, 1 Jan 2019 02:23:03 +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 93C6628C9F for ; Tue, 1 Jan 2019 02:23:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728385AbfAACXC (ORCPT ); Mon, 31 Dec 2018 21:23:02 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:39532 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728193AbfAACXC (ORCPT ); Mon, 31 Dec 2018 21:23:02 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012EFNB173632 for ; Tue, 1 Jan 2019 02:23:00 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=Zt+nXOjRtstKa5Al2W+s8DqIUamK7PgS/1qeAFC2uAs=; b=SYeF9cM7dQeFV1Q3V0EoCr4au6wpYZUTER+MTdg7iIZymEU/3Qy9KDEn9yDU0lI5KtZN Aa0YCeptNry37LMyjN9l91scKY4NpxFRScUes6KW0K45H4i0IU+6UAS96LtDqCCJQGX+ OAmbrHMureY1r7yVkOCwEE4uL1cIxzWTDOJcSP8zdiypzxc069fzSChMUG2ED4mhsmTI vx3PH3YEAmdex5eUUrei1Skw/7xFZW/QCrRzkiqgkev9fywpPL8U7WITw6oJwXyNTw/g X6EbGXR/EnKmIH6rffreumzQlToh/5klN8TpE8JrFUGLP2gMBMD45uS1Cwdr/eqdVmNw JQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2pp1jqx45d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:23:00 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x012MxwN013443 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:22:59 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x012MxAj004382 for ; Tue, 1 Jan 2019 02:22:59 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:22:58 -0800 Subject: [PATCH 05/13] xfs: iget for metadata inodes From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:22:57 -0800 Message-ID: <154630937786.21716.1154582079168264872.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 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 Create a xfs_iget_meta function for metadata inodes to ensure that we always check that the inobt thinks a metadata inode is in use. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_imeta.h | 5 +++++ fs/xfs/xfs_icache.c | 27 +++++++++++++++++++++++++++ fs/xfs/xfs_inode.c | 7 +++++++ fs/xfs/xfs_qm.c | 33 +++++++++++++++++---------------- fs/xfs/xfs_qm_syscalls.c | 4 +++- fs/xfs/xfs_rtalloc.c | 15 +++++++++------ 6 files changed, 68 insertions(+), 23 deletions(-) diff --git a/fs/xfs/libxfs/xfs_imeta.h b/fs/xfs/libxfs/xfs_imeta.h index 7740e7bd03e5..5321dba38bbe 100644 --- a/fs/xfs/libxfs/xfs_imeta.h +++ b/fs/xfs/libxfs/xfs_imeta.h @@ -43,4 +43,9 @@ int xfs_imeta_mount(struct xfs_mount *mp); unsigned int xfs_imeta_create_space_res(struct xfs_mount *mp); unsigned int xfs_imeta_unlink_space_res(struct xfs_mount *mp); +/* Must be implemented by the libxfs client */ +int xfs_imeta_iget(struct xfs_mount *mp, xfs_ino_t ino, unsigned char ftype, + struct xfs_inode **ipp); +void xfs_imeta_irele(struct xfs_inode *ip); + #endif /* __XFS_IMETA_H__ */ diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index f00c6f4bc515..7c459e37396d 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -22,6 +22,8 @@ #include "xfs_dquot_item.h" #include "xfs_dquot.h" #include "xfs_reflink.h" +#include "xfs_da_format.h" +#include "xfs_dir2.h" #include #include @@ -910,6 +912,31 @@ xfs_icache_inode_is_allocated( return 0; } +/* Get a metadata inode. The ftype must match exactly. */ +int +xfs_imeta_iget( + struct xfs_mount *mp, + xfs_ino_t ino, + unsigned char ftype, + struct xfs_inode **ipp) +{ + struct xfs_inode *ip; + int error; + + error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED, 0, &ip); + if (error) + return error; + + if (ftype == XFS_DIR3_FT_UNKNOWN || + xfs_mode_to_ftype(VFS_I(ip)->i_mode) != ftype) { + xfs_irele(ip); + return -EFSCORRUPTED; + } + + *ipp = ip; + return 0; +} + /* * The inode lookup is done in batches to keep the amount of lock traffic and * radix tree lookups to a minimum. The batch size is a trade off between diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index f177e0ded21c..d2de7cd87b07 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2654,6 +2654,13 @@ xfs_irele( iput(VFS_I(ip)); } +void +xfs_imeta_irele( + struct xfs_inode *ip) +{ + xfs_irele(ip); +} + /* * Decide if this inode have post-EOF blocks. The caller is responsible * for knowing / caring about the PREALLOC/APPEND flags. diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 4b8a48fb5780..c6ab9fe531d5 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -27,6 +27,7 @@ #include "xfs_icache.h" #include "xfs_cksum.h" #include "xfs_imeta.h" +#include "xfs_da_format.h" /* * The global quota manager. There is only one of these for the entire @@ -232,15 +233,15 @@ xfs_qm_unmount_quotas( */ if (mp->m_quotainfo) { if (mp->m_quotainfo->qi_uquotaip) { - xfs_irele(mp->m_quotainfo->qi_uquotaip); + xfs_imeta_irele(mp->m_quotainfo->qi_uquotaip); mp->m_quotainfo->qi_uquotaip = NULL; } if (mp->m_quotainfo->qi_gquotaip) { - xfs_irele(mp->m_quotainfo->qi_gquotaip); + xfs_imeta_irele(mp->m_quotainfo->qi_gquotaip); mp->m_quotainfo->qi_gquotaip = NULL; } if (mp->m_quotainfo->qi_pquotaip) { - xfs_irele(mp->m_quotainfo->qi_pquotaip); + xfs_imeta_irele(mp->m_quotainfo->qi_pquotaip); mp->m_quotainfo->qi_pquotaip = NULL; } } @@ -798,7 +799,7 @@ xfs_qm_qino_switch( if (ino == NULLFSINO) return 0; - error = xfs_iget(mp, NULL, ino, 0, 0, ip); + error = xfs_imeta_iget(mp, ino, XFS_DIR3_FT_REG_FILE, ip); if (error) return error; @@ -1570,24 +1571,24 @@ xfs_qm_init_quotainos( if (XFS_IS_UQUOTA_ON(mp) && mp->m_sb.sb_uquotino != NULLFSINO) { ASSERT(mp->m_sb.sb_uquotino > 0); - error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, - 0, 0, &uip); + error = xfs_imeta_iget(mp, mp->m_sb.sb_uquotino, + XFS_DIR3_FT_REG_FILE, &uip); if (error) return error; } if (XFS_IS_GQUOTA_ON(mp) && mp->m_sb.sb_gquotino != NULLFSINO) { ASSERT(mp->m_sb.sb_gquotino > 0); - error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, - 0, 0, &gip); + error = xfs_imeta_iget(mp, mp->m_sb.sb_gquotino, + XFS_DIR3_FT_REG_FILE, &gip); if (error) goto error_rele; } if (XFS_IS_PQUOTA_ON(mp) && mp->m_sb.sb_pquotino != NULLFSINO) { ASSERT(mp->m_sb.sb_pquotino > 0); - error = xfs_iget(mp, NULL, mp->m_sb.sb_pquotino, - 0, 0, &pip); + error = xfs_imeta_iget(mp, mp->m_sb.sb_pquotino, + XFS_DIR3_FT_REG_FILE, &pip); if (error) goto error_rele; } @@ -1632,11 +1633,11 @@ xfs_qm_init_quotainos( error_rele: if (uip) - xfs_irele(uip); + xfs_imeta_irele(uip); if (gip) - xfs_irele(gip); + xfs_imeta_irele(gip); if (pip) - xfs_irele(pip); + xfs_imeta_irele(pip); return error; } @@ -1645,15 +1646,15 @@ xfs_qm_destroy_quotainos( xfs_quotainfo_t *qi) { if (qi->qi_uquotaip) { - xfs_irele(qi->qi_uquotaip); + xfs_imeta_irele(qi->qi_uquotaip); qi->qi_uquotaip = NULL; /* paranoia */ } if (qi->qi_gquotaip) { - xfs_irele(qi->qi_gquotaip); + xfs_imeta_irele(qi->qi_gquotaip); qi->qi_gquotaip = NULL; } if (qi->qi_pquotaip) { - xfs_irele(qi->qi_pquotaip); + xfs_imeta_irele(qi->qi_pquotaip); qi->qi_pquotaip = NULL; } } diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c index d96f146e3fe6..71c910ea9e6c 100644 --- a/fs/xfs/xfs_qm_syscalls.c +++ b/fs/xfs/xfs_qm_syscalls.c @@ -23,6 +23,8 @@ #include "xfs_trace.h" #include "xfs_icache.h" #include "xfs_defer.h" +#include "xfs_imeta.h" +#include "xfs_da_format.h" STATIC int xfs_qm_log_quotaoff(xfs_mount_t *, xfs_qoff_logitem_t **, uint); STATIC int xfs_qm_log_quotaoff_end(xfs_mount_t *, xfs_qoff_logitem_t *, @@ -225,7 +227,7 @@ xfs_qm_scall_trunc_qfile( if (ino == NULLFSINO) return 0; - error = xfs_iget(mp, NULL, ino, 0, 0, &ip); + error = xfs_imeta_iget(mp, ino, XFS_DIR3_FT_REG_FILE, &ip); if (error) return error; diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index afe4d29f7ab4..cedaf2f94362 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -24,7 +24,8 @@ #include "xfs_buf.h" #include "xfs_icache.h" #include "xfs_rtalloc.h" - +#include "xfs_da_format.h" +#include "xfs_imeta.h" /* * Read and return the summary information for a given extent size, @@ -1206,14 +1207,16 @@ xfs_rtmount_inodes( xfs_sb_t *sbp; sbp = &mp->m_sb; - error = xfs_iget(mp, NULL, sbp->sb_rbmino, 0, 0, &mp->m_rbmip); + error = xfs_imeta_iget(mp, mp->m_sb.sb_rbmino, XFS_DIR3_FT_REG_FILE, + &mp->m_rbmip); if (error) return error; ASSERT(mp->m_rbmip != NULL); - error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip); + error = xfs_imeta_iget(mp, mp->m_sb.sb_rsumino, XFS_DIR3_FT_REG_FILE, + &mp->m_rsumip); if (error) { - xfs_irele(mp->m_rbmip); + xfs_imeta_irele(mp->m_rbmip); return error; } ASSERT(mp->m_rsumip != NULL); @@ -1234,9 +1237,9 @@ xfs_rtunmount_inodes( { kmem_free(mp->m_rsum_cache); if (mp->m_rbmip) - xfs_irele(mp->m_rbmip); + xfs_imeta_irele(mp->m_rbmip); if (mp->m_rsumip) - xfs_irele(mp->m_rsumip); + xfs_imeta_irele(mp->m_rsumip); } /* From patchwork Tue Jan 1 02:23:04 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: 10745727 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 C419113AD for ; Tue, 1 Jan 2019 02:23:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6A3828C9F for ; Tue, 1 Jan 2019 02:23:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB2D128CA3; Tue, 1 Jan 2019 02:23: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 4080028C9F for ; Tue, 1 Jan 2019 02:23:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728412AbfAACXH (ORCPT ); Mon, 31 Dec 2018 21:23:07 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:44928 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728193AbfAACXH (ORCPT ); Mon, 31 Dec 2018 21:23:07 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012DnDJ018621 for ; Tue, 1 Jan 2019 02:23:06 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=pkU42iX9QiuzcdRf60Vl1YnoEO+bwKlnZ6yA4BmTEQo=; b=2bn3qnqgxPs9ZGH5z5ZJYGeL5wQMkrmHGQ7nNxz49gN4kG8O2FQ8Q1S8EN7SJgtbuEqj Wd42t+fp4NCvtLm0xw9R0YcJ36kl7VFhEqaKLfdpf6EdK5S0b8QUGrnO4PL4SRyvuZYl iYRvVrZO/hOuqj2tWMB5pac3cEwfUViLsNq4GgkWWv9wNdA9etJjvmmMFQ7do4fc8PvI G9dtKARS9Hi0OIk5iHTN6LaZnTqs23GslKhVQVv1tH10Dlq0wjraBbOSe3NnBkH/mAWa sQ77q8WQOr174/Qh6w6RpRFNoUGMfSMhBhviPtoMRRZwEqJk2xidxz+5lkCpP4UgOC8O Aw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2pp0btp7bb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:23:06 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x012N5uQ013678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:23:05 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x012N53P028919 for ; Tue, 1 Jan 2019 02:23:05 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:23:04 -0800 Subject: [PATCH 06/13] xfs: define the on-disk format for the metadir feature From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:23:04 -0800 Message-ID: <154630938409.21716.18345212801449500981.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 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 Define the on-disk layout and feature flags for the metadata inode directory feature. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_format.h | 30 ++++++++++++++++++++++++++++-- fs/xfs/xfs_inode.h | 5 +++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 3d9f5d8e4e25..c85a2f2e4c83 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -175,6 +175,14 @@ typedef struct xfs_sb { xfs_lsn_t sb_lsn; /* last write sequence */ uuid_t sb_meta_uuid; /* metadata file system unique id */ + /* + * Metadata Directory Inode. On disk this lives in the sb_rbmino slot, + * but we continue to use the in-core superblock to cache the classic + * inodes (rt bitmap; rt summary; user, group, and project quotas) so + * we cache the metadir inode value here too. + */ + xfs_ino_t sb_metadirino; + /* must be padded to 64 bit alignment */ } xfs_sb_t; @@ -193,7 +201,14 @@ typedef struct xfs_dsb { uuid_t sb_uuid; /* user-visible file system unique id */ __be64 sb_logstart; /* starting block of log if internal */ __be64 sb_rootino; /* root inode number */ - __be64 sb_rbmino; /* bitmap inode for realtime extents */ + /* + * bitmap inode for realtime extents. + * + * The metadata inode directory feature uses the sb_rbmino field to + * point to the root of the metadata directory tree. All other sb + * inode pointers are cancelled. + */ + __be64 sb_rbmino; __be64 sb_rsumino; /* summary inode for rt bitmap */ __be32 sb_rextsize; /* realtime extent size, blocks */ __be32 sb_agblocks; /* size of an allocation group */ @@ -465,6 +480,7 @@ xfs_sb_has_ro_compat_feature( #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ #define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */ #define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */ +#define XFS_SB_FEAT_INCOMPAT_METADIR (1 << 3) /* metadata ino dir */ #define XFS_SB_FEAT_INCOMPAT_ALL \ (XFS_SB_FEAT_INCOMPAT_FTYPE| \ XFS_SB_FEAT_INCOMPAT_SPINODES| \ @@ -546,6 +562,12 @@ static inline bool xfs_sb_version_hasreflink(struct xfs_sb *sbp) (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_REFLINK); } +static inline bool xfs_sb_version_hasmetadir(struct xfs_sb *sbp) +{ + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && + (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR); +} + /* * end of superblock version macros */ @@ -1055,12 +1077,16 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #define XFS_DIFLAG2_DAX_BIT 0 /* use DAX for this inode */ #define XFS_DIFLAG2_REFLINK_BIT 1 /* file's blocks may be shared */ #define XFS_DIFLAG2_COWEXTSIZE_BIT 2 /* copy on write extent size hint */ +#define XFS_DIFLAG2_METADATA_BIT 3 /* filesystem metadata */ + #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) #define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT) #define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT) +#define XFS_DIFLAG2_METADATA (1 << XFS_DIFLAG2_METADATA_BIT) #define XFS_DIFLAG2_ANY \ - (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE) + (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ + XFS_DIFLAG2_METADATA) /* * Inode number format: diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 211b7d85bf62..5f8375424f62 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -170,6 +170,11 @@ static inline bool xfs_is_reflink_inode(struct xfs_inode *ip) return ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK; } +static inline bool xfs_is_metadata_inode(struct xfs_inode *ip) +{ + return ip->i_d.di_flags2 & XFS_DIFLAG2_METADATA; +} + /* * Check if an inode has any data in the COW fork. This might be often false * even for inodes with the reflink flag when there is no pending COW operation. From patchwork Tue Jan 1 02:23:10 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: 10745729 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 1573113AD for ; Tue, 1 Jan 2019 02:23:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08CB928C9F for ; Tue, 1 Jan 2019 02:23:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F13AE28CA3; Tue, 1 Jan 2019 02:23:14 +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 79B1E28C9F for ; Tue, 1 Jan 2019 02:23:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728413AbfAACXO (ORCPT ); Mon, 31 Dec 2018 21:23:14 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:39644 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728193AbfAACXN (ORCPT ); Mon, 31 Dec 2018 21:23:13 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012E408173564 for ; Tue, 1 Jan 2019 02:23:12 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=0vqOGDE0KjlxddXXzCTkC8mziHhWeRD8IT+Dnvb3icI=; b=kYax2gY81RtzvLqmmhMPZJzR4mup2HZ/UNuUY2YYwxp0DefU3yMc47M1Kmqu1mUu1j3y sMYrlBVHB6Q/yNKAC9Psrb7ktV7P95coQ5OuKfwgAatJnUbDpxGTAVEbm6RO/v+IW6RW JBHuUSmtBISQoa0aXVkdaqOyyzyx4uvzfy8y3sGlOGG2Jcmt+OJD6+ihf6cq7MufbJeG pFoLGtLs3JQ/QRCmGZvdNCh5gjqdXvWy3203hhms4FLoAXGA7km2Aplxd6TZXTX2Sp2t 7PYzZvj0d4PAg6tEHLIzRAj9HD/3TB/paeTP+Hq5pI6ZJg0YJ+aBGFQo661ggsCYt9B8 qg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2pp1jqx45k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:23:12 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x012NBRJ030731 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:23:11 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x012NBBZ027491 for ; Tue, 1 Jan 2019 02:23:11 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:23:11 -0800 Subject: [PATCH 07/13] xfs: load metadata inode directory at mount time From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:23:10 -0800 Message-ID: <154630939020.21716.3079946986143648994.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 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 Load the metadata directory inode into memory at mount time and release it at unmount time. We also make sure that the obsolete inode pointers in the superblock are not logged or read from the superblock. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_sb.c | 31 +++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_types.c | 2 +- fs/xfs/xfs_mount.c | 20 ++++++++++++++++++-- fs/xfs/xfs_mount.h | 1 + 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 8ffb5c1b2843..86ba6a2cb3bb 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -524,6 +524,25 @@ __xfs_sb_from_disk( /* Convert on-disk flags to in-memory flags? */ if (convert_xquota) xfs_sb_quota_from_disk(to); + + if (xfs_sb_version_hasmetadir(to)) { + /* + * Set metadirino here and null out the in-core fields for + * the other inodes because metadir initialization will load + * them later. + */ + to->sb_metadirino = be64_to_cpu(from->sb_rbmino); + to->sb_rbmino = NULLFSINO; + to->sb_rsumino = NULLFSINO; + + /* + * We don't have to worry about quota inode conversion here + * because metadir requires a v5 filesystem. + */ + to->sb_uquotino = NULLFSINO; + to->sb_gquotino = NULLFSINO; + to->sb_pquotino = NULLFSINO; + } } void @@ -665,6 +684,18 @@ xfs_sb_to_disk( if (xfs_sb_version_hasmetauuid(from)) uuid_copy(&to->sb_meta_uuid, &from->sb_meta_uuid); } + + if (xfs_sb_version_hasmetadir(from)) { + /* + * Save metadirino here and null out the on-disk fields for + * the other inodes, at least until we reuse the fields. + */ + to->sb_rbmino = cpu_to_be64(from->sb_metadirino); + to->sb_rsumino = cpu_to_be64(NULLFSINO); + to->sb_uquotino = cpu_to_be64(NULLFSINO); + to->sb_gquotino = cpu_to_be64(NULLFSINO); + to->sb_pquotino = cpu_to_be64(NULLFSINO); + } } /* diff --git a/fs/xfs/libxfs/xfs_types.c b/fs/xfs/libxfs/xfs_types.c index d05ccfabbc9c..089c5d865746 100644 --- a/fs/xfs/libxfs/xfs_types.c +++ b/fs/xfs/libxfs/xfs_types.c @@ -153,7 +153,7 @@ xfs_verify_dir_ino( struct xfs_mount *mp, xfs_ino_t ino) { - if (xfs_internal_inum(mp, ino)) + if (!xfs_sb_version_hasmetadir(&mp->m_sb) && xfs_internal_inum(mp, ino)) return false; return xfs_verify_ino(mp, ino); } diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index b895368c64fb..68b9ba7245e8 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -672,6 +672,16 @@ xfs_mountfs_imeta( { int error; + /* Load the metadata directory inode into memory. */ + if (xfs_sb_version_hasmetadir(&mp->m_sb)) { + error = xfs_imeta_iget(mp, mp->m_sb.sb_metadirino, + XFS_DIR3_FT_DIR, &mp->m_metadirip); + if (error) { + xfs_warn(mp, "Failed metadir ino init: %d", error); + return error; + } + } + error = xfs_imeta_mount(mp); if (error) { xfs_warn(mp, "Failed to load metadata inode info, error %d", @@ -921,7 +931,7 @@ xfs_mountfs( error = xfs_mountfs_imeta(mp); if (error) - goto out_log_dealloc; + goto out_free_metadir; /* * Get and sanity-check the root inode. @@ -933,7 +943,7 @@ xfs_mountfs( xfs_warn(mp, "Failed to read root inode 0x%llx, error %d", sbp->sb_rootino, -error); - goto out_log_dealloc; + goto out_free_metadir; } ASSERT(rip != NULL); @@ -1079,6 +1089,9 @@ xfs_mountfs( xfs_irele(rip); /* Clean out dquots that might be in memory after quotacheck. */ xfs_qm_unmount(mp); + out_free_metadir: + if (mp->m_metadirip) + xfs_imeta_irele(mp->m_metadirip); /* * Cancel all delayed reclaim work and reclaim the inodes directly. * We have to do this /after/ rtunmount and qm_unmount because those @@ -1143,6 +1156,9 @@ xfs_unmountfs( xfs_rtunmount_inodes(mp); xfs_irele(mp->m_rootip); + if (mp->m_metadirip) + xfs_imeta_irele(mp->m_metadirip); + /* * We can potentially deadlock here if we have an inode cluster * that has been freed has its buffer still pinned in memory because diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 34f2cf96ec27..2845a51f1a36 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -103,6 +103,7 @@ typedef struct xfs_mount { struct xfs_inode *m_rbmip; /* pointer to bitmap inode */ struct xfs_inode *m_rsumip; /* pointer to summary inode */ struct xfs_inode *m_rootip; /* pointer to root directory */ + struct xfs_inode *m_metadirip; /* metadata inode directory */ struct xfs_quotainfo *m_quotainfo; /* disk quota information */ xfs_buftarg_t *m_ddev_targp; /* saves taking the address */ xfs_buftarg_t *m_logdev_targp;/* ptr to log device */ From patchwork Tue Jan 1 02:23:16 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: 10745731 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 E03F813AD for ; Tue, 1 Jan 2019 02:23:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3EB928C9F for ; Tue, 1 Jan 2019 02:23:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C840F28CA3; Tue, 1 Jan 2019 02:23:24 +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 686DE28C9F for ; Tue, 1 Jan 2019 02:23:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728193AbfAACXY (ORCPT ); Mon, 31 Dec 2018 21:23:24 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45112 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728414AbfAACXX (ORCPT ); Mon, 31 Dec 2018 21:23:23 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012FYGM019623 for ; Tue, 1 Jan 2019 02:23: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=2ir1ySzKwwfd7cM9b+5a6vSSTGHCgyfqQKQJiNzSWR8=; b=nqxM/jN1jouSGo563OLQqHe8pRcVPUTAC4Dn26NAom00J6eATQpa+olUCLc0zch9OJ4h sE8x8O6Xbk5Zsd5HhkMSPj0pjVeqUmdgYnrkNjG2oiHI2A2ntvQxS0YjcDuJYv7ARVHr U+Pwe8plCN+vlFdMM4KK2n2F608O0Jq92oJw/+8BkodNUQyRc88deOeV3YQQP3Gu1cTo QyRqi3X4jNNzlNdsvDHNTTsq7G6pZEzja3Izb85qJM4yMi7c2LD5s+/ckm9nL1BFakKH 5W6RSkke3Nf/B0IO+/pt9cFBqGT0kALUxF0IqcIZoI1+UXbSwovxCWj3r0iUCrUEuyGm Xg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2pp0btp7bm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:23:23 +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 x012NHIO030892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:23:17 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x012NHSO004481 for ; Tue, 1 Jan 2019 02:23:17 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:23:17 -0800 Subject: [PATCH 08/13] xfs: convert metadata inode lookup keys to use paths From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:23:16 -0800 Message-ID: <154630939636.21716.9376021504995036779.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=841 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 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 Convert the magic metadata inode lookup keys to use actual strings for paths. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_imeta.c | 48 ++++++++++++++++++++++++--------------------- fs/xfs/libxfs/xfs_imeta.h | 17 ++++++++++++++-- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/fs/xfs/libxfs/xfs_imeta.c b/fs/xfs/libxfs/xfs_imeta.c index 86b05992599a..3249f66d680f 100644 --- a/fs/xfs/libxfs/xfs_imeta.c +++ b/fs/xfs/libxfs/xfs_imeta.c @@ -47,26 +47,17 @@ */ /* Static metadata inode paths */ - -const struct xfs_imeta_path XFS_IMETA_RTBITMAP = { - .bogus = 0, -}; - -const struct xfs_imeta_path XFS_IMETA_RTSUMMARY = { - .bogus = 1, -}; - -const struct xfs_imeta_path XFS_IMETA_USRQUOTA = { - .bogus = 2, -}; - -const struct xfs_imeta_path XFS_IMETA_GRPQUOTA = { - .bogus = 3, -}; - -const struct xfs_imeta_path XFS_IMETA_PRJQUOTA = { - .bogus = 4, -}; +static const char *rtbitmap_path[] = {"realtime", "0.bitmap"}; +static const char *rtsummary_path[] = {"realtime", "0.summary"}; +static const char *usrquota_path[] = {"quota", "user"}; +static const char *grpquota_path[] = {"quota", "group"}; +static const char *prjquota_path[] = {"quota", "project"}; + +XFS_IMETA_DEFINE_PATH(XFS_IMETA_RTBITMAP, rtbitmap_path); +XFS_IMETA_DEFINE_PATH(XFS_IMETA_RTSUMMARY, rtsummary_path); +XFS_IMETA_DEFINE_PATH(XFS_IMETA_USRQUOTA, usrquota_path); +XFS_IMETA_DEFINE_PATH(XFS_IMETA_GRPQUOTA, grpquota_path); +XFS_IMETA_DEFINE_PATH(XFS_IMETA_PRJQUOTA, prjquota_path); /* Are these two paths equal? */ STATIC bool @@ -74,7 +65,20 @@ xfs_imeta_path_compare( const struct xfs_imeta_path *a, const struct xfs_imeta_path *b) { - return a == b; + unsigned int i; + + if (a == b) + return true; + + if (a->im_depth != b->im_depth) + return false; + + for (i = 0; i < a->im_depth; i++) + if (a->im_path[i] != b->im_path[i] && + strcmp(a->im_path[i], b->im_path[i])) + return false; + + return true; } /* Is this path ok? */ @@ -82,7 +86,7 @@ static inline bool xfs_imeta_path_check( const struct xfs_imeta_path *path) { - return true; + return path->im_depth <= XFS_IMETA_MAX_DEPTH; } /* Functions for storing and retrieving superblock inode values. */ diff --git a/fs/xfs/libxfs/xfs_imeta.h b/fs/xfs/libxfs/xfs_imeta.h index 5321dba38bbe..6caf5b16f8d7 100644 --- a/fs/xfs/libxfs/xfs_imeta.h +++ b/fs/xfs/libxfs/xfs_imeta.h @@ -6,10 +6,23 @@ #ifndef __XFS_IMETA_H__ #define __XFS_IMETA_H__ +/* How deep can we nest metadata dirs? */ +#define XFS_IMETA_MAX_DEPTH 64 + +/* Form an imeta path from a simple array of strings. */ +#define XFS_IMETA_DEFINE_PATH(name, path) \ +const struct xfs_imeta_path name = { \ + .im_path = (path), \ + .im_depth = ARRAY_SIZE(path), \ +} + /* Key for looking up metadata inodes. */ struct xfs_imeta_path { - /* Temporary: integer to keep the static imeta definitions unique */ - int bogus; + /* Array of string pointers. */ + const char **im_path; + + /* Number of strings in path. */ + unsigned int im_depth; }; /* Cleanup widget for metadata inode creation and deletion. */ From patchwork Tue Jan 1 02:23:22 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: 10745733 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 4FE9D13AD for ; Tue, 1 Jan 2019 02:23:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 432B528C9F for ; Tue, 1 Jan 2019 02:23:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3777C28CA3; Tue, 1 Jan 2019 02:23: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 23AD228C9F for ; Tue, 1 Jan 2019 02:23:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728475AbfAACX0 (ORCPT ); Mon, 31 Dec 2018 21:23:26 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:56754 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728414AbfAACX0 (ORCPT ); Mon, 31 Dec 2018 21:23:26 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012GKRn169434 for ; Tue, 1 Jan 2019 02:23:24 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=UtnXuGN3tuV+L+c5a4m/9NJ3tCa8rAj28gKyusYTZWs=; b=ZfQYhigKZQDi1RI23ZSKMdaZxZOZmmClWH0lZcOCEhSb8j2oHWHte+5MUAJp7EKEo1tt LRpuPv64Qh+e2Q6vYL3N6Xqbi1PZ9cJxeGrLHcXfQMZ5u0HBtVsj+zJMoArZr0BljPum S7AuTz9wPJWKhDB7SIqqCd9QQDkEyvYj+1K57U/xrvoFZSodcDFoDOB5UUXEFU5VgCWf cfv4fxuMUC3R0I78mVwpvqSG1vYp5UhmWnzqZUh1SMw8V8S0hQ0FoC/SUEXF6ZTAcR+w q2b3PN0CZ7abBhzpKR3+8ha2OFbg84bttbRHggN2+ha7PwcH6qFapdMVlfyytEB2xs1y JA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2pnxedxav4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:23:24 +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 x012NNwd031011 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:23:23 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x012NNNv004502 for ; Tue, 1 Jan 2019 02:23:23 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:23:23 -0800 Subject: [PATCH 09/13] xfs: enforce metadata inode flag From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:23:22 -0800 Message-ID: <154630940242.21716.6515771914516209462.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=829 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 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 checks for the metadata inode flag so that we don't ever leak metadata inodes out to userspace, and we don't ever try to read a regular inode as metadata. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_inode_buf.c | 5 +++++ fs/xfs/scrub/common.c | 3 ++- fs/xfs/scrub/inode_repair.c | 3 +++ fs/xfs/scrub/scrub.c | 1 + fs/xfs/xfs_icache.c | 4 +++- fs/xfs/xfs_inode.c | 8 ++++++++ fs/xfs/xfs_itable.c | 6 ++++++ 7 files changed, 28 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 8fa1050c1ae2..debacf69f126 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -557,6 +557,11 @@ xfs_dinode_verify( flags2 = be64_to_cpu(dip->di_flags2); + /* don't allow the metadata iflag if we don't have metadir */ + if ((flags2 & XFS_DIFLAG2_METADATA) && + !xfs_sb_version_hasmetadir(&mp->m_sb)) + return __this_address; + /* don't allow reflink/cowextsize if we don't have reflink */ if ((flags2 & (XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE)) && !xfs_sb_version_hasreflink(&mp->m_sb)) diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index c881b18dd799..c5cbe245082c 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -722,7 +722,8 @@ xchk_get_inode( error, __return_address); return error; } - if (VFS_I(ip)->i_generation != sc->sm->sm_gen) { + if (VFS_I(ip)->i_generation != sc->sm->sm_gen || + xfs_is_metadata_inode(ip)) { xfs_irele(ip); return -ENOENT; } diff --git a/fs/xfs/scrub/inode_repair.c b/fs/xfs/scrub/inode_repair.c index 3c9ac9e046fd..c036481a2407 100644 --- a/fs/xfs/scrub/inode_repair.c +++ b/fs/xfs/scrub/inode_repair.c @@ -168,6 +168,9 @@ xrep_dinode_flags( flags2 &= ~XFS_DIFLAG2_REFLINK; if (flags2 & XFS_DIFLAG2_REFLINK) flags2 &= ~XFS_DIFLAG2_DAX; + if (!xfs_sb_version_hasmetadir(&mp->m_sb) && + (flags2 & XFS_DIFLAG2_METADATA)) + flags2 &= ~XFS_DIFLAG2_METADATA; dip->di_flags = cpu_to_be16(flags); dip->di_flags2 = cpu_to_be64(flags2); } diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c index 943dbec82d60..5f176575dad7 100644 --- a/fs/xfs/scrub/scrub.c +++ b/fs/xfs/scrub/scrub.c @@ -184,6 +184,7 @@ xchk_teardown( if (sc->ilock_flags) xfs_iunlock(sc->ip, sc->ilock_flags); if (sc->ip != ip_in && + !xfs_is_metadata_inode(sc->ip) && !xfs_internal_inum(sc->mp, sc->ip->i_ino)) xfs_irele(sc->ip); sc->ip = NULL; diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 7c459e37396d..2881716e1c9e 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -927,7 +927,9 @@ xfs_imeta_iget( if (error) return error; - if (ftype == XFS_DIR3_FT_UNKNOWN || + if ((xfs_sb_version_hasmetadir(&mp->m_sb) && + !xfs_is_metadata_inode(ip)) || + ftype == XFS_DIR3_FT_UNKNOWN || xfs_mode_to_ftype(VFS_I(ip)->i_mode) != ftype) { xfs_irele(ip); return -EFSCORRUPTED; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index d2de7cd87b07..6a3a8137af4d 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -609,8 +609,13 @@ xfs_lookup( if (error) goto out_free_name; + if (xfs_is_metadata_inode(*ipp)) + goto out_irele; + return 0; +out_irele: + xfs_irele(*ipp); out_free_name: if (ci_name) kmem_free(ci_name->name); @@ -2658,6 +2663,9 @@ void xfs_imeta_irele( struct xfs_inode *ip) { + ASSERT(!xfs_sb_version_hasmetadir(&ip->i_mount->m_sb) || + xfs_is_metadata_inode(ip)); + xfs_irele(ip); } diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 8c6ca9d364ec..c8aa7c6295c2 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c @@ -54,6 +54,12 @@ xfs_bulkstat_one_int( if (error) goto out_free; + if (xfs_is_metadata_inode(ip)) { + xfs_iunlock(ip, XFS_ILOCK_SHARED); + xfs_irele(ip); + goto out_free; + } + ASSERT(ip != NULL); ASSERT(ip->i_imap.im_blkno != 0); inode = VFS_I(ip); From patchwork Tue Jan 1 02:23: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: 10745735 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 97F436C5 for ; Tue, 1 Jan 2019 02:23:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 878D728C9F for ; Tue, 1 Jan 2019 02:23:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A4BD28CA3; Tue, 1 Jan 2019 02:23:37 +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 31A7228C9F for ; Tue, 1 Jan 2019 02:23:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728477AbfAACXf (ORCPT ); Mon, 31 Dec 2018 21:23:35 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:56816 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728414AbfAACXf (ORCPT ); Mon, 31 Dec 2018 21:23:35 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012DxnY168362 for ; Tue, 1 Jan 2019 02:23: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=2Pd2+8Hy20lTcMD+k3//9PRmMqtZy0Hhi+29cldWgj0=; b=PBsNzOZ2jj788dXTFzcFwYVX9UZoTLIoXkGC3tkILSefj2DkJMslM+JThGEJzk/Dq0Af pXFHwsN/Eo/qr4nguBajQPeGkuo9PGBEnzgei2ttb+Ger9cn8ZtURdK69byApdktum27 RiDjrBtMWkhyc95ihFtOCvD8xmuvBpeRue6bGhD7JIv8KCumVvrjK2qL5xzD5W0DTpuA U128yJ2J2Jx7Tj1BggsaOV1Hs3+DeqsR2NyHkjgcf3vYxv5bdjgvlLsZrbtNcI55jedn 9NKaP0NPRTc6G1SYuZiQpgU0JgaNT9UzLI2ljqAJkzzLVU42AdgiDds9sO4CREsVGPmr Jw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2pnxedxav7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:23:31 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x012NU2b031358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:23:30 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x012NTun029099 for ; Tue, 1 Jan 2019 02:23:29 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:23:29 -0800 Subject: [PATCH 10/13] xfs: read and write metadata inode directory From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:23:28 -0800 Message-ID: <154630940854.21716.15648156322989767213.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 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 Plumb in the bits we need to look up metadata inode numbers from the metadata inode directory and save them back. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_imeta.c | 517 ++++++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_imeta.h | 4 fs/xfs/libxfs/xfs_inode_util.c | 2 fs/xfs/libxfs/xfs_trans_resv.c | 8 + fs/xfs/xfs_trace.h | 5 5 files changed, 530 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_imeta.c b/fs/xfs/libxfs/xfs_imeta.c index 3249f66d680f..0095b86646b9 100644 --- a/fs/xfs/libxfs/xfs_imeta.c +++ b/fs/xfs/libxfs/xfs_imeta.c @@ -21,6 +21,7 @@ #include "xfs_da_format.h" #include "xfs_da_btree.h" #include "xfs_trans_space.h" +#include "xfs_dir2.h" /* * Metadata Inode Number Management @@ -41,9 +42,16 @@ * this structure must be passed to xfs_imeta_end_update to free resources that * cannot be freed during the transaction. * - * Right now we only support callers passing in the predefined metadata inode - * paths; the goal is that callers will some day locate metadata inodes based - * on a metadata inode directory structure. + * When the metadata inode directory (metadir) feature is enabled, we can + * create a complex directory tree in which to store metadata inodes. Inodes + * within the metadata directory tree should have the "metadata" inode flag set + * to prevent them from being exposed to the outside world. + * + * Within the metadata directory tree, we avoid taking the directory IOLOCK + * (like the VFS does for user directories) because we assume that the higher + * level XFS code already controls against concurrent updates of the + * corresponding part of the directory tree. We do take metadata inodes' ILOCK + * during updates due to the locking requirements of the bmap code. */ /* Static metadata inode paths */ @@ -59,6 +67,10 @@ XFS_IMETA_DEFINE_PATH(XFS_IMETA_USRQUOTA, usrquota_path); XFS_IMETA_DEFINE_PATH(XFS_IMETA_GRPQUOTA, grpquota_path); XFS_IMETA_DEFINE_PATH(XFS_IMETA_PRJQUOTA, prjquota_path); +const struct xfs_imeta_path XFS_IMETA_METADIR = { + .im_depth = 0, +}; + /* Are these two paths equal? */ STATIC bool xfs_imeta_path_compare( @@ -116,6 +128,10 @@ static const struct xfs_imeta_sbmap { .path = &XFS_IMETA_PRJQUOTA, .offset = offsetof(struct xfs_sb, sb_pquotino), }, + { + .path = &XFS_IMETA_METADIR, + .offset = offsetof(struct xfs_sb, sb_metadirino), + }, { NULL, 0 }, }; @@ -247,6 +263,460 @@ xfs_imeta_sb_zap( return 0; } +/* Functions for storing and retrieving metadata directory inode values. */ + +/* + * Given a parent directory @dp, a metadata inode @path and component + * @path_idx, and the expected file type @ftype of the path component, fill out + * the @xname and look up the inode number in the directory, returning it in + * @ino. + */ +static inline int +xfs_imeta_dir_lookup_component( + struct xfs_inode *dp, + const struct xfs_imeta_path *path, + unsigned int path_idx, + unsigned char ftype, + struct xfs_name *xname, + xfs_ino_t *ino) +{ + int error; + + xname->name = (const unsigned char *)path->im_path[path_idx]; + xname->len = strlen(path->im_path[path_idx]); + xname->type = ftype; + + trace_xfs_imeta_dir_lookup_component(dp, xname); + + error = xfs_dir_lookup(NULL, dp, xname, ino, NULL); + if (error) + return error; + if (!xfs_verify_ino(dp->i_mount, *ino)) + return -EFSCORRUPTED; + return 0; +} + +/* + * Traverse a metadata directory tree path, returning the inode corresponding + * to the parent of the last path component. If any of the path components do + * not exist, return -ENOENT. + */ +STATIC int +xfs_imeta_dir_parent( + struct xfs_mount *mp, + const struct xfs_imeta_path *path, + struct xfs_inode **dpp) +{ + struct xfs_name xname; + struct xfs_inode *dp; + xfs_ino_t ino; + unsigned int i; + int error; + + if (mp->m_metadirip == NULL) + return -ENOENT; + + /* Grab the metadir root. */ + error = xfs_imeta_iget(mp, mp->m_metadirip->i_ino, XFS_DIR3_FT_DIR, + &dp); + if (error) + return error; + + /* Caller wanted the root, we're done! */ + if (path->im_depth == 0) { + *dpp = dp; + return 0; + } + + for (i = 0; i < path->im_depth - 1; i++) { + /* Look up the name in the current directory. */ + error = xfs_imeta_dir_lookup_component(dp, path, i, + XFS_DIR3_FT_DIR, &xname, &ino); + if (error) + goto out_rele; + + /* Drop the existing dp and pick up the new one. */ + xfs_imeta_irele(dp); + error = xfs_imeta_iget(mp, ino, XFS_DIR3_FT_DIR, &dp); + if (error) + goto out_rele; + } + + *dpp = dp; + return 0; + +out_rele: + xfs_imeta_irele(dp); + return error; +} + +/* + * Look up a metadata inode from the metadata inode directory. If the last + * path component doesn't exist, return NULLFSINO. If any other part of the + * path does not exist, return -ENOENT so we can distinguish the two. + */ +STATIC int +xfs_imeta_dir_lookup_int( + struct xfs_mount *mp, + const struct xfs_imeta_path *path, + xfs_ino_t *inop) +{ + struct xfs_name xname; + struct xfs_inode *dp = NULL; + xfs_ino_t ino; + int error; + + /* metadir ino is recorded in superblock */ + if (xfs_imeta_path_compare(path, &XFS_IMETA_METADIR)) + return xfs_imeta_sb_lookup(mp, path, inop); + + ASSERT(path->im_depth > 0); + + /* Find the parent of the last path component. */ + error = xfs_imeta_dir_parent(mp, path, &dp); + if (error) + return error; + + /* Look up the name in the current directory. */ + error = xfs_imeta_dir_lookup_component(dp, path, path->im_depth - 1, + XFS_DIR3_FT_UNKNOWN, &xname, &ino); + switch (error) { + case 0: + *inop = ino; + break; + case -ENOENT: + *inop = NULLFSINO; + error = 0; + break; + } + + xfs_imeta_irele(dp); + return error; +} + +/* + * Look up a metadata inode from the metadata inode directory. If any of the + * middle path components do not exist, we consider this corruption because + * only the last component is allowed to not exist. + */ +STATIC int +xfs_imeta_dir_lookup( + struct xfs_mount *mp, + const struct xfs_imeta_path *path, + xfs_ino_t *inop) +{ + int error; + + error = xfs_imeta_dir_lookup_int(mp, path, inop); + if (error == -ENOENT) + return -EFSCORRUPTED; + return error; +} + +/* + * Load all the metadata inode pointers that are cached in the in-core + * superblock but live somewhere in the metadata directory tree. + */ +STATIC int +xfs_imeta_dir_mount( + struct xfs_mount *mp) +{ + const struct xfs_imeta_sbmap *p; + xfs_ino_t *sb_inop; + int err2; + int error = 0; + + for (p = xfs_imeta_sbmaps; p->path && p->path->im_depth > 0; p++) { + if (p->path == &XFS_IMETA_METADIR) + continue; + sb_inop = xfs_imeta_sbmap_to_inop(mp, p); + err2 = xfs_imeta_dir_lookup_int(mp, p->path, sb_inop); + if (err2 == -ENOENT) { + *sb_inop = NULLFSINO; + continue; + } + if (!error && err2) + error = err2; + } + + return error; +} + +/* + * Create a new metadata inode and a metadata directory entry to this new + * inode. There must not already be a directory entry. + */ +STATIC int +xfs_imeta_dir_create( + struct xfs_trans **tpp, + const struct xfs_imeta_path *path, + umode_t mode, + struct xfs_inode **ipp, + struct xfs_imeta_end *cleanup) +{ + struct xfs_ialloc_args args = { + .ops = &xfs_default_ialloc_ops, + .nlink = S_ISDIR(mode) ? 2 : 1, + .mode = mode, + }; + struct xfs_name xname; + struct xfs_mount *mp = (*tpp)->t_mountp; + struct xfs_inode *dp = NULL; + xfs_ino_t *sb_inop; + xfs_ino_t ino; + unsigned int resblks; + int error; + + /* metadir ino is recorded in superblock */ + if (xfs_imeta_path_compare(path, &XFS_IMETA_METADIR)) { + error = xfs_imeta_sb_create(tpp, path, mode, ipp); + if (error) + return error; + + /* Set the metadata iflag, initialize directory. */ + (*ipp)->i_d.di_flags2 |= XFS_DIFLAG2_METADATA; + return xfs_dir_init(*tpp, *ipp, *ipp); + } + + ASSERT(path->im_depth > 0); + + /* + * Find the parent of the last path component. If the parent path does + * not exist, we consider this corruption because paths are supposed + * to exist. + */ + error = xfs_imeta_dir_parent(mp, path, &dp); + if (error == -ENOENT) + return -EFSCORRUPTED; + if (error) + return error; + + /* Check that the name does not already exist in the directory. */ + error = xfs_imeta_dir_lookup_component(dp, path, path->im_depth - 1, + XFS_DIR3_FT_UNKNOWN, &xname, &ino); + switch (error) { + case 0: + error = -EEXIST; + break; + case -ENOENT: + error = 0; + break; + } + if (error) + goto out_rele; + + xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT); + + /* + * A newly created regular or special file just has one directory + * entry pointing to them, but a directory also the "." entry + * pointing to itself. + */ + args.pip = dp; + error = xfs_dir_ialloc(tpp, &args, ipp); + if (error) + goto out_ilock; + + /* Set the metadata iflag */ + (*ipp)->i_d.di_flags2 |= XFS_DIFLAG2_METADATA; + xfs_trans_log_inode(*tpp, *ipp, XFS_ILOG_CORE); + + /* + * Once we join the parent directory to the transaction we can't + * release it until after the transaction commits or cancels, so we + * must defer releasing it to end_update. This is different from + * regular file creation, where the vfs holds the parent dir reference + * and will free it. The caller is always responsible for releasing + * ipp, even if we failed. + */ + xfs_trans_ijoin(*tpp, dp, XFS_ILOCK_EXCL); + cleanup->dp = dp; + + /* Create the entry. */ + if (S_ISDIR(args.mode)) + resblks = XFS_MKDIR_SPACE_RES(mp, xname.len); + else + resblks = XFS_CREATE_SPACE_RES(mp, xname.len); + xname.type = xfs_mode_to_ftype(args.mode); + trace_xfs_imeta_dir_try_create(dp, &xname); + error = xfs_dir_create_new_child(*tpp, resblks, dp, &xname, *ipp); + if (error) + return error; + trace_xfs_imeta_dir_created(*ipp, &xname); + + /* Update the in-core superblock value if there is one. */ + sb_inop = xfs_imeta_path_to_sb_inop(mp, path); + if (sb_inop) + *sb_inop = (*ipp)->i_ino; + return 0; + +out_ilock: + xfs_iunlock(dp, XFS_ILOCK_EXCL); +out_rele: + xfs_imeta_irele(dp); + return error; +} + +/* + * Remove the given entry from the metadata directory and drop the link count + * of the metadata inode. + */ +STATIC int +xfs_imeta_dir_unlink( + struct xfs_trans **tpp, + const struct xfs_imeta_path *path, + struct xfs_inode *ip, + struct xfs_imeta_end *cleanup) +{ + struct xfs_name xname; + struct xfs_mount *mp = (*tpp)->t_mountp; + struct xfs_inode *dp = NULL; + xfs_ino_t *sb_inop; + xfs_ino_t ino; + unsigned int resblks; + int error; + + /* metadir ino is recorded in superblock */ + if (xfs_imeta_path_compare(path, &XFS_IMETA_METADIR)) + return xfs_imeta_sb_unlink(tpp, path, ip); + + ASSERT(path->im_depth > 0); + + /* + * Find the parent of the last path component. If the parent path does + * not exist, we consider this corruption because paths are supposed + * to exist. + */ + error = xfs_imeta_dir_parent(mp, path, &dp); + if (error == -ENOENT) + return -EFSCORRUPTED; + if (error) + return error; + + /* Look up the name in the current directory. */ + error = xfs_imeta_dir_lookup_component(dp, path, path->im_depth - 1, + xfs_mode_to_ftype(VFS_I(ip)->i_mode), &xname, &ino); + switch (error) { + case 0: + if (ino != ip->i_ino) + error = -ENOENT; + break; + case -ENOENT: + error = -EFSCORRUPTED; + break; + } + if (error) + goto out_rele; + + xfs_lock_two_inodes(dp, XFS_ILOCK_EXCL, ip, XFS_ILOCK_EXCL); + + /* + * Once we join the parent directory to the transaction we can't + * release it until after the transaction commits or cancels, so we + * must defer releasing it to end_update. This is different from + * regular file removal, where the vfs holds the parent dir reference + * and will free it. The unlink caller is always responsible for + * releasing ip, so we don't need to take care of that. + */ + xfs_trans_ijoin(*tpp, dp, XFS_ILOCK_EXCL); + xfs_trans_ijoin(*tpp, ip, XFS_ILOCK_EXCL); + cleanup->dp = dp; + + resblks = XFS_REMOVE_SPACE_RES(mp); + error = xfs_dir_remove_child(*tpp, resblks, dp, &xname, ip); + if (error) + return error; + trace_xfs_imeta_dir_unlinked(dp, &xname); + + /* Update the in-core superblock value if there is one. */ + sb_inop = xfs_imeta_path_to_sb_inop(mp, path); + if (sb_inop) + *sb_inop = NULLFSINO; + return 0; + +out_rele: + xfs_imeta_irele(dp); + return error; +} + +/* + * Remove the given entry from the metadata directory, which effectively sets + * it to NULL. + */ +STATIC int +xfs_imeta_dir_zap( + struct xfs_trans **tpp, + const struct xfs_imeta_path *path, + struct xfs_imeta_end *cleanup) +{ + struct xfs_name xname; + struct xfs_mount *mp = (*tpp)->t_mountp; + struct xfs_inode *dp = NULL; + xfs_ino_t *sb_inop; + xfs_ino_t ino; + unsigned int resblks; + int error; + + /* metadir ino is recorded in superblock */ + if (xfs_imeta_path_compare(path, &XFS_IMETA_METADIR)) + return xfs_imeta_sb_zap(tpp, path); + + ASSERT(path->im_depth > 0); + + /* + * Find the parent of the last path component. If the parent path does + * not exist, we consider this corruption because paths are supposed + * to exist. + */ + error = xfs_imeta_dir_parent(mp, path, &dp); + if (error == -ENOENT) + return -EFSCORRUPTED; + if (error) + return error; + + /* Look up the name in the current directory. */ + error = xfs_imeta_dir_lookup_component(dp, path, path->im_depth - 1, + XFS_DIR3_FT_UNKNOWN, &xname, &ino); + switch (error) { + case 0: + break; + case -ENOENT: + error = 0; + /* fall through */ + default: + goto out_rele; + } + + xfs_ilock(dp, XFS_ILOCK_EXCL); + + /* + * Once we join the parent directory to the transaction we can't + * release it until after the transaction commits or cancels, so we + * must defer releasing it to end_update. This is different from + * regular file removal, where the vfs holds the parent dir reference + * and will free it. The unlink caller is always responsible for + * releasing ip, so we don't need to take care of that. + */ + xfs_trans_ijoin(*tpp, dp, XFS_ILOCK_EXCL); + cleanup->dp = dp; + + resblks = XFS_REMOVE_SPACE_RES(mp); + error = xfs_dir_removename(*tpp, dp, &xname, ino, resblks); + if (error) + return error; + trace_xfs_imeta_dir_zap(dp, &xname); + + /* Update the in-core superblock value if there is one. */ + sb_inop = xfs_imeta_path_to_sb_inop(mp, path); + if (sb_inop) + *sb_inop = NULLFSINO; + return 0; + +out_rele: + xfs_imeta_irele(dp); + return error; +} + /* General functions for managing metadata inode pointers */ /* @@ -276,7 +746,10 @@ xfs_imeta_lookup( ASSERT(xfs_imeta_path_check(path)); - error = xfs_imeta_sb_lookup(mp, path, &ino); + if (xfs_sb_version_hasmetadir(&mp->m_sb)) + error = xfs_imeta_dir_lookup(mp, path, &ino); + else + error = xfs_imeta_sb_lookup(mp, path, &ino); if (error) return error; @@ -306,9 +779,14 @@ xfs_imeta_create( struct xfs_inode **ipp, struct xfs_imeta_end *cleanup) { + struct xfs_mount *mp = (*tpp)->t_mountp; + ASSERT(xfs_imeta_path_check(path)); *ipp = NULL; + cleanup->dp = NULL; + if (xfs_sb_version_hasmetadir(&mp->m_sb)) + return xfs_imeta_dir_create(tpp, path, mode, ipp, cleanup); return xfs_imeta_sb_create(tpp, path, mode, ipp); } @@ -325,9 +803,14 @@ xfs_imeta_unlink( struct xfs_inode *ip, struct xfs_imeta_end *cleanup) { + struct xfs_mount *mp = (*tpp)->t_mountp; + cleanup->dp = NULL; + ASSERT(xfs_imeta_path_check(path)); ASSERT(xfs_imeta_verify((*tpp)->t_mountp, ip->i_ino)); + if (xfs_sb_version_hasmetadir(&mp->m_sb)) + return xfs_imeta_dir_unlink(tpp, path, ip, cleanup); return xfs_imeta_sb_unlink(tpp, path, ip); } @@ -344,8 +827,13 @@ xfs_imeta_zap( const struct xfs_imeta_path *path, struct xfs_imeta_end *cleanup) { + struct xfs_mount *mp = (*tpp)->t_mountp; + cleanup->dp = NULL; + ASSERT(xfs_imeta_path_check(path)); + if (xfs_sb_version_hasmetadir(&mp->m_sb)) + return xfs_imeta_dir_zap(tpp, path, cleanup); return xfs_imeta_sb_zap(tpp, path); } @@ -360,6 +848,10 @@ xfs_imeta_end_update( int error) { trace_xfs_imeta_end_update(mp, 0, error, _RET_IP_); + + if (cleanup->dp) + xfs_imeta_irele(cleanup->dp); + cleanup->dp = NULL; } /* Does this inode number refer to a static metadata inode? */ @@ -385,6 +877,9 @@ int xfs_imeta_mount( struct xfs_mount *mp) { + if (xfs_sb_version_hasmetadir(&mp->m_sb)) + return xfs_imeta_dir_mount(mp); + return 0; } @@ -393,6 +888,9 @@ unsigned int xfs_imeta_create_space_res( struct xfs_mount *mp) { + if (xfs_sb_version_hasmetadir(&mp->m_sb)) + return max(XFS_MKDIR_SPACE_RES(mp, NAME_MAX), + XFS_CREATE_SPACE_RES(mp, NAME_MAX)); return XFS_IALLOC_SPACE_RES(mp); } @@ -403,3 +901,14 @@ xfs_imeta_unlink_space_res( { return XFS_REMOVE_SPACE_RES(mp); } + +/* Clear the metadata iflag if we're unlinking this inode. */ +void +xfs_imeta_droplink( + struct xfs_inode *ip) +{ + if (VFS_I(ip)->i_nlink == 0 && + xfs_sb_version_hasmetadir(&ip->i_mount->m_sb) && + xfs_is_metadata_inode(ip)) + ip->i_d.di_flags2 &= ~XFS_DIFLAG2_METADATA; +} diff --git a/fs/xfs/libxfs/xfs_imeta.h b/fs/xfs/libxfs/xfs_imeta.h index 6caf5b16f8d7..ecd2db0a4c92 100644 --- a/fs/xfs/libxfs/xfs_imeta.h +++ b/fs/xfs/libxfs/xfs_imeta.h @@ -27,7 +27,7 @@ struct xfs_imeta_path { /* Cleanup widget for metadata inode creation and deletion. */ struct xfs_imeta_end { - /* empty for now */ + struct xfs_inode *dp; }; /* Lookup keys for static metadata inodes. */ @@ -36,6 +36,7 @@ extern const struct xfs_imeta_path XFS_IMETA_RTSUMMARY; extern const struct xfs_imeta_path XFS_IMETA_USRQUOTA; extern const struct xfs_imeta_path XFS_IMETA_GRPQUOTA; extern const struct xfs_imeta_path XFS_IMETA_PRJQUOTA; +extern const struct xfs_imeta_path XFS_IMETA_METADIR; int xfs_imeta_lookup(struct xfs_mount *mp, const struct xfs_imeta_path *path, xfs_ino_t *ino); @@ -52,6 +53,7 @@ void xfs_imeta_end_update(struct xfs_mount *mp, struct xfs_imeta_end *cleanup, bool xfs_is_static_meta_ino(struct xfs_mount *mp, xfs_ino_t ino); int xfs_imeta_mount(struct xfs_mount *mp); +void xfs_imeta_droplink(struct xfs_inode *ip); unsigned int xfs_imeta_create_space_res(struct xfs_mount *mp); unsigned int xfs_imeta_unlink_space_res(struct xfs_mount *mp); diff --git a/fs/xfs/libxfs/xfs_inode_util.c b/fs/xfs/libxfs/xfs_inode_util.c index 00cda9046c8e..815efd73efa7 100644 --- a/fs/xfs/libxfs/xfs_inode_util.c +++ b/fs/xfs/libxfs/xfs_inode_util.c @@ -18,6 +18,7 @@ #include "xfs_ialloc.h" #include "xfs_error.h" #include "xfs_inode_item.h" +#include "xfs_imeta.h" /* * helper function to extract extent size hint from inode @@ -825,6 +826,7 @@ xfs_droplink( xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); drop_nlink(VFS_I(ip)); + xfs_imeta_droplink(ip); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); if (VFS_I(ip)->i_nlink) diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index dd3bf0c63410..33cc35159088 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c @@ -790,7 +790,10 @@ xfs_calc_imeta_create_resv( unsigned int ret; ret = xfs_calc_buf_res(1, mp->m_sb.sb_sectsize); - ret += resp->tr_create.tr_logres; + if (xfs_sb_version_hasmetadir(&mp->m_sb)) + ret += max(resp->tr_create.tr_logres, resp->tr_mkdir.tr_logres); + else + ret += resp->tr_create.tr_logres; return ret; } @@ -800,6 +803,9 @@ xfs_calc_imeta_create_count( struct xfs_mount *mp, struct xfs_trans_resv *resp) { + if (xfs_sb_version_hasmetadir(&mp->m_sb)) + return max(resp->tr_create.tr_logcount, + resp->tr_mkdir.tr_logcount); return resp->tr_create.tr_logcount; } diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 5392cc85e951..21dc5846dc2f 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -3409,6 +3409,11 @@ DEFINE_IMETA_SB_EVENT(xfs_imeta_sb_create); DEFINE_IMETA_SB_EVENT(xfs_imeta_sb_unlink); DEFINE_IMETA_SB_EVENT(xfs_imeta_sb_zap); DEFINE_AG_ERROR_EVENT(xfs_imeta_end_update); +DEFINE_NAMESPACE_EVENT(xfs_imeta_dir_lookup_component); +DEFINE_NAMESPACE_EVENT(xfs_imeta_dir_try_create); +DEFINE_NAMESPACE_EVENT(xfs_imeta_dir_created); +DEFINE_NAMESPACE_EVENT(xfs_imeta_dir_unlinked); +DEFINE_NAMESPACE_EVENT(xfs_imeta_dir_zap); #endif /* _TRACE_XFS_H */ From patchwork Tue Jan 1 02:23:35 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: 10745737 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 87BA76C5 for ; Tue, 1 Jan 2019 02:23:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B17F28C9F for ; Tue, 1 Jan 2019 02:23:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F67D28CA3; Tue, 1 Jan 2019 02:23:39 +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 ED5FD28C9F for ; Tue, 1 Jan 2019 02:23:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728604AbfAACXi (ORCPT ); Mon, 31 Dec 2018 21:23:38 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45306 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728414AbfAACXi (ORCPT ); Mon, 31 Dec 2018 21:23:38 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012Ehmu019070 for ; Tue, 1 Jan 2019 02:23:37 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=FNpuBrgO4gdpy8lnq1UaS/wNmJeR+d034vP1ZDcsVDo=; b=nni6+nAhA+bi74pkKmEcGerFANpa1xvTT+dpiKLYvJ3ZCFUIR6sopLQgdp1EoNnnPK5W t5MjEChAE/1JYqH8ovBROPLBZ7SyMCz9mVuvuX1lGvAKoTQABGedfj4d6lGaXuDOIvPf F4ilmFUNfhRD0SuZgWUEeoB3IdeSevkj2J617T/6ksaZECrp1cQZU6E+cAOKRpwqXLVl LBygD7icjrX/NQ558lznV1yBM3y0voQ8pFVPMA9A+YaytrZjHJlAfF0ikv/d58Rf/++p Y4rSu8Q6ZDtmXQU6IXS/we+MIzRTiJHceq2SZwBcix+hkFAxxuWEy2sLsxb9LuxAZMUI Zg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2pp0btp7bs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:23:36 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x012NaBN031226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:23:36 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x012NaQd027728 for ; Tue, 1 Jan 2019 02:23:36 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:23:35 -0800 Subject: [PATCH 11/13] xfs: ensure metadata directory paths exist before creating files From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:23:35 -0800 Message-ID: <154630941488.21716.5321601013179303914.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=100 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=100 mlxscore=100 mlxlogscore=-1000 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 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 Since xfs_imeta_create can create new metadata files arbitrarily deep in the metadata directory tree, we must supply a function that can ensure that all directories in a path exist, and call it before the quota functions create the quota inodes. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_imeta.h | 2 + fs/xfs/xfs_inode.c | 102 +++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_qm.c | 13 ++++++ 3 files changed, 117 insertions(+) diff --git a/fs/xfs/libxfs/xfs_imeta.h b/fs/xfs/libxfs/xfs_imeta.h index ecd2db0a4c92..33024889fc71 100644 --- a/fs/xfs/libxfs/xfs_imeta.h +++ b/fs/xfs/libxfs/xfs_imeta.h @@ -62,5 +62,7 @@ unsigned int xfs_imeta_unlink_space_res(struct xfs_mount *mp); int xfs_imeta_iget(struct xfs_mount *mp, xfs_ino_t ino, unsigned char ftype, struct xfs_inode **ipp); void xfs_imeta_irele(struct xfs_inode *ip); +int xfs_imeta_ensure_dirpath(struct xfs_mount *mp, + const struct xfs_imeta_path *path); #endif /* __XFS_IMETA_H__ */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 6a3a8137af4d..abd332a13d95 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -43,6 +43,7 @@ #include "xfs_dir2_priv.h" #include "xfs_dquot_item.h" #include "xfs_dquot.h" +#include "xfs_imeta.h" kmem_zone_t *xfs_inode_zone; @@ -927,6 +928,107 @@ xfs_create_tmpfile( return error; } +/* Create a metadata for the last component of the path. */ +STATIC int +xfs_imeta_mkdir( + struct xfs_mount *mp, + const struct xfs_imeta_path *path) +{ + struct xfs_imeta_end ic; + struct xfs_inode *ip = NULL; + struct xfs_trans *tp = NULL; + struct xfs_dquot *udqp = NULL; + struct xfs_dquot *gdqp = NULL; + struct xfs_dquot *pdqp = NULL; + uint resblks; + int error; + + if (XFS_FORCED_SHUTDOWN(mp)) + return -EIO; + + /* Grab the dquots from the metadata directory root. */ + error = xfs_qm_vop_dqalloc(mp->m_metadirip, 0, 0, 0, + XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, + &udqp, &gdqp, &pdqp); + if (error) + return error; + + /* Allocate a transaction to create the last directory. */ + resblks = xfs_imeta_create_space_res(mp); + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_imeta_create, resblks, + 0, 0, &tp); + if (error) + goto out_dqrele; + + /* Reserve quota for the new directory. */ + error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, pdqp, + resblks, 1, 0); + if (error) { + xfs_trans_cancel(tp); + goto out_dqrele; + } + + /* Create the subdirectory. */ + error = xfs_imeta_create(&tp, path, S_IFDIR, &ip, &ic); + if (error) { + xfs_trans_cancel(tp); + xfs_imeta_end_update(mp, &ic, error); + goto out_irele; + } + + /* + * Attach the dquot(s) to the inodes and modify them incore. + * These ids of the inode couldn't have changed since the new + * inode has been locked ever since it was created. + */ + xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp); + + error = xfs_trans_commit(tp); + xfs_imeta_end_update(mp, &ic, error); + +out_irele: + /* Have to finish setting up the inode to ensure it's deleted. */ + if (ip) { + xfs_finish_inode_setup(ip); + xfs_irele(ip); + } + +out_dqrele: + xfs_qm_dqrele(udqp); + xfs_qm_dqrele(gdqp); + xfs_qm_dqrele(pdqp); + return error; +} + +/* + * Make sure that every metadata directory path component exists and is a + * directory. + */ +int +xfs_imeta_ensure_dirpath( + struct xfs_mount *mp, + const struct xfs_imeta_path *path) +{ + struct xfs_imeta_path temp_path = { + .im_path = path->im_path, + .im_depth = 1, + }; + unsigned int i; + int error = 0; + + if (!xfs_sb_version_hasmetadir(&mp->m_sb)) + return 0; + + for (i = 0; i < path->im_depth - 1; i++) { + temp_path.im_depth = i + 1; + error = xfs_imeta_mkdir(mp, &temp_path); + if (error && error != -EEXIST) + break; + } + + return error == -EEXIST ? 0 : error; +} + int xfs_link( xfs_inode_t *tdp, diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index c6ab9fe531d5..00d39e98af3f 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -827,6 +827,7 @@ xfs_qm_qino_alloc( struct xfs_imeta_end ic; struct xfs_trans *tp; const struct xfs_imeta_path *path = xfs_qflags_to_imeta(flags); + uint old_qflags; int error; bool need_alloc = true; @@ -835,6 +836,18 @@ xfs_qm_qino_alloc( if (error) return error; + /* + * Ensure the quota directory exists, being careful to disable quotas + * while we do this. We'll have to quotacheck anyway, so the loss + * of one inode shouldn't affect the quota count. + */ + old_qflags = mp->m_qflags & XFS_ALL_QUOTA_ACCT; + mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT; + error = xfs_imeta_ensure_dirpath(mp, xfs_qflags_to_imeta(flags)); + mp->m_qflags |= old_qflags; + if (error) + return error; + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_imeta_create, xfs_imeta_create_space_res(mp), 0, 0, &tp); if (error) From patchwork Tue Jan 1 02:23:41 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: 10745739 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 ECCBF13AD for ; Tue, 1 Jan 2019 02:23:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC82228C33 for ; Tue, 1 Jan 2019 02:23:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC2FE2785D; Tue, 1 Jan 2019 02:23:46 +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 4763E2785D for ; Tue, 1 Jan 2019 02:23:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728622AbfAACXp (ORCPT ); Mon, 31 Dec 2018 21:23:45 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:56970 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728414AbfAACXp (ORCPT ); Mon, 31 Dec 2018 21:23:45 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012NihA173680 for ; Tue, 1 Jan 2019 02:23:44 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=whj+eaKj812q7tou50RuZKPBEZjlqebAAJi/EzzcOCs=; b=A77jE9M+amM16hHYMMSVP+dqqI4qDTcpcSj3UheFsVu/tMwPlAWW3myJiPaB7jrd/ZsQ YrMLbmk8poktCSvrSu72qicuOS926n2AGB/NYUAwze3wBX0T6GMNcd6YzwMSNn0l5p/b bkLvRYIIYuDPEeRnbcax3l/ZnGiVT7QmttvxR1Hm+MBpfI7WxUzx/SkTDxnGi1f+gNGw PW4k1dcAglm/imhN8AUWD9NuSmX/xMuT9OHrWjp2Z1MxiN3mEq7Sld6j0vcD7puGtLoU JAhH9G6X83AUW4vEALPK5zHgXNgLVLCWxiFDt8I/wSD6rbosl4oMr6213syNtlmGGBKt BQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2pnxedxave-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:23:43 +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 x012NghK014675 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:23:43 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x012Ngeh008895 for ; Tue, 1 Jan 2019 02:23:42 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:23:42 -0800 Subject: [PATCH 12/13] xfs: disable the agi rotor for metadata inodes From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:23:41 -0800 Message-ID: <154630942114.21716.1893263236839727703.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=945 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010020 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 Ideally, we'd put all the metadata inodes in one place if we could, so that the metadata all stay reasonably close together instead of spreading out over the disk. Furthermore, if the log is internal we'd probably prefer to keep the metadata near the log. Therefore, disable AGI rotoring for metadata inode allocations. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_ialloc.c | 48 ++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_ialloc.h | 10 ++++---- fs/xfs/libxfs/xfs_inode_util.c | 3 +-- 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index f32be0c85f93..9f926fbb37f8 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c @@ -937,20 +937,21 @@ xfs_ialloc_next_ag( */ STATIC xfs_agnumber_t xfs_ialloc_ag_select( - xfs_trans_t *tp, /* transaction pointer */ - xfs_ino_t parent, /* parent directory inode number */ - umode_t mode) /* bits set to indicate file type */ + struct xfs_trans *tp, + struct xfs_inode *pip, + umode_t mode) { - xfs_agnumber_t agcount; /* number of ag's in the filesystem */ - xfs_agnumber_t agno; /* current ag number */ - int flags; /* alloc buffer locking flags */ - xfs_extlen_t ineed; /* blocks needed for inode allocation */ - xfs_extlen_t longest = 0; /* longest extent available */ - xfs_mount_t *mp; /* mount point structure */ - int needspace; /* file mode implies space allocated */ - xfs_perag_t *pag; /* per allocation group data */ - xfs_agnumber_t pagno; /* parent (starting) ag number */ - int error; + struct xfs_mount *mp; + struct xfs_perag *pag; + xfs_ino_t parent = pip ? pip->i_ino : 0; + xfs_agnumber_t agcount; + xfs_agnumber_t agno; + xfs_agnumber_t pagno; + xfs_extlen_t ineed; + xfs_extlen_t longest = 0; /* longest extent available */ + int needspace; /* file mode implies space allocated */ + int flags; + int error; /* * Files of these types need at least one block if length > 0 @@ -959,9 +960,21 @@ xfs_ialloc_ag_select( needspace = S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode); mp = tp->t_mountp; agcount = mp->m_maxagi; - if (S_ISDIR(mode)) + if (pip && xfs_is_metadata_inode(pip)) { + /* + * Try to squash all the metadata inodes into the parent's + * AG, or the one with the log if the log is internal, or + * AG 0 if all else fails. + */ + if (xfs_verify_ino(mp, parent)) + pagno = XFS_INO_TO_AGNO(mp, parent); + else if (mp->m_sb.sb_logstart != 0) + pagno = XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart); + else + pagno = 0; + } else if (S_ISDIR(mode)) { pagno = xfs_ialloc_next_ag(mp); - else { + } else { pagno = XFS_INO_TO_AGNO(mp, parent); if (pagno >= agcount) pagno = 0; @@ -1693,13 +1706,14 @@ xfs_dialloc_ag( int xfs_dialloc( struct xfs_trans *tp, - xfs_ino_t parent, + struct xfs_inode *pip, umode_t mode, struct xfs_buf **IO_agbp, xfs_ino_t *inop) { struct xfs_mount *mp = tp->t_mountp; struct xfs_buf *agbp; + xfs_ino_t parent = pip ? pip->i_ino : 0; xfs_agnumber_t agno; int error; int ialloced; @@ -1723,7 +1737,7 @@ xfs_dialloc( * We do not have an agbp, so select an initial allocation * group for inode allocation. */ - start_agno = xfs_ialloc_ag_select(tp, parent, mode); + start_agno = xfs_ialloc_ag_select(tp, pip, mode); if (start_agno == NULLAGNUMBER) { *inop = NULLFSINO; return 0; diff --git a/fs/xfs/libxfs/xfs_ialloc.h b/fs/xfs/libxfs/xfs_ialloc.h index b74fa2addd51..23a03168c240 100644 --- a/fs/xfs/libxfs/xfs_ialloc.h +++ b/fs/xfs/libxfs/xfs_ialloc.h @@ -66,11 +66,11 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o) */ int /* error */ xfs_dialloc( - struct xfs_trans *tp, /* transaction pointer */ - xfs_ino_t parent, /* parent inode (directory) */ - umode_t mode, /* mode bits for new inode */ - struct xfs_buf **agbp, /* buf for a.g. inode header */ - xfs_ino_t *inop); /* inode number allocated */ + struct xfs_trans *tp, /* transaction pointer */ + struct xfs_inode *pip, /* parent inode (directory) */ + umode_t mode, /* mode bits for new inode */ + struct xfs_buf **agbp, /* buf for a.g. inode header */ + xfs_ino_t *inop); /* inode number allocated */ /* * Free disk inode. Carefully avoids touching the incore inode, all diff --git a/fs/xfs/libxfs/xfs_inode_util.c b/fs/xfs/libxfs/xfs_inode_util.c index 815efd73efa7..7d29b995f2dc 100644 --- a/fs/xfs/libxfs/xfs_inode_util.c +++ b/fs/xfs/libxfs/xfs_inode_util.c @@ -380,8 +380,7 @@ xfs_ialloc( * Call the space management code to pick * the on-disk inode to be allocated. */ - error = xfs_dialloc(tp, pip ? pip->i_ino : 0, args->mode, - ialloc_context, &ino); + error = xfs_dialloc(tp, pip, args->mode, ialloc_context, &ino); if (error) return error; if (*ialloc_context || ino == NULLFSINO) { From patchwork Tue Jan 1 02:23:47 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: 10745741 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 8641E14DE for ; Tue, 1 Jan 2019 02:23:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A1512785D for ; Tue, 1 Jan 2019 02:23:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E35728C37; Tue, 1 Jan 2019 02:23:51 +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 25B952785D for ; Tue, 1 Jan 2019 02:23:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728623AbfAACXu (ORCPT ); Mon, 31 Dec 2018 21:23:50 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45476 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728414AbfAACXu (ORCPT ); Mon, 31 Dec 2018 21:23:50 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012NnPY024034 for ; Tue, 1 Jan 2019 02:23:49 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=jfZm9MNrgl+OuuzxLpPeByjAFsgP8Q6Qa8fCLyBYAv8=; b=ETzHQt5oVm0zVioDeZn90d28MLwRzHMsd7sg2fCFtxoQdTqA6T/FILnUt/zd4DK6efee HXDne8rvhLhGv1ces5yRUDNPcfTMvR33TMoB4d1o/bJlWTZq3ILZVo8X9EW1SFhqEIYW eG/6i2ROH2pE+dsZD4CHbGfmrb8yK/597JR0dxUxsS4roUuHXwvil0hqSYrdvOq0FW0B gy5tCeVBnAPmPtOyoUzrHLyZvvSKq6aKJloJG2SJZHoQz/2OlQn9Yi4rXe+sdR83SNZU iIT983HPT2RlIEx/65u17sUuHBH+Y+jmU+hv9GmhAq9+EliIh5KV3c7LDDkWdA1NL/fZ KA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2pp0btp7c9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:23:49 +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 x012Nmdc017306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:23:48 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x012NmQk029295 for ; Tue, 1 Jan 2019 02:23:48 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:23:48 -0800 Subject: [PATCH 13/13] xfs: enable metadata inode directory feature From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:23:47 -0800 Message-ID: <154630942740.21716.4618386068238400104.stgit@magnolia> In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia> References: <154630934595.21716.17416691804044507782.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=801 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010020 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 Enable the metadata inode directory feature. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index c85a2f2e4c83..ab7db41b2163 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -484,7 +484,8 @@ xfs_sb_has_ro_compat_feature( #define XFS_SB_FEAT_INCOMPAT_ALL \ (XFS_SB_FEAT_INCOMPAT_FTYPE| \ XFS_SB_FEAT_INCOMPAT_SPINODES| \ - XFS_SB_FEAT_INCOMPAT_META_UUID) + XFS_SB_FEAT_INCOMPAT_META_UUID| \ + XFS_SB_FEAT_INCOMPAT_METADIR) #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL static inline bool