From patchwork Fri Oct 23 06:32:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852309 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B46A14B2 for ; Fri, 23 Oct 2020 06:35:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E13DC2223F for ; Fri, 23 Oct 2020 06:35:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="qojxtR3i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372832AbgJWGfT (ORCPT ); Fri, 23 Oct 2020 02:35:19 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45140 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372843AbgJWGfT (ORCPT ); Fri, 23 Oct 2020 02:35:19 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6OHDv025403 for ; Fri, 23 Oct 2020 06:35:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=QolY6rM5KBfj6BujmkLxmJjCLlNsu7GImlyQ2DbLdnA=; b=qojxtR3i5Hu2gHGzTjUNmwua/h+m3nqh4hTdCORHWVgtB1lXtdYfAQesOYzdyRe/WFV7 I0BFoqRg4egQBr4NhN0skPhnoyWHjpfRUnGJ1Uzl0ovdRffshk6ifXf2RxBRZy0EJ8nu I/6v+rOHPU2DLAbPBal29g0OKGiLOWS88iEGoC6gpsbgrba7wpqP7Yi6xBSEf2Tf4EJ5 hmH81DUUrdQOSfv4qhINAVRGi7ktOl6J4RzNWARj+5BD5EYeopRm49eVUSzj5fcOL4RJ BUYTaptqfskwfJWZJglpAGjfFZsED+kBYVZZ3vDkg0KcgIBSEKAGWG3IlJII79l8lK+6 Kg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 34ak16snpp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:35:17 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6P558178184 for ; Fri, 23 Oct 2020 06:33:17 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 348aj0n96u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:17 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 09N6XGQg009332 for ; Fri, 23 Oct 2020 06:33:17 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:16 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 01/14] xfs: store inode btree block counts in AGI header Date: Thu, 22 Oct 2020 23:32:53 -0700 Message-Id: <20201023063306.7441-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 suspectscore=4 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 mlxlogscore=999 suspectscore=4 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" Source kernel commit: 2a39946c984464e4aac82c556ba9915589be7323 Add a btree block usage counters for both inode btrees to the AGI header so that we don't have to walk the entire finobt at mount time to create the per-AG reservations. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Signed-off-by: Allison Henderson --- libxfs/xfs_ag.c | 5 +++++ libxfs/xfs_format.h | 18 +++++++++++++++++- libxfs/xfs_ialloc.c | 1 + libxfs/xfs_ialloc_btree.c | 21 +++++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index ceaa7e5..af8a0af 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -333,6 +333,11 @@ xfs_agiblock_init( } for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO); + if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) { + agi->agi_iblocks = cpu_to_be32(1); + if (xfs_sb_version_hasfinobt(&mp->m_sb)) + agi->agi_fblocks = cpu_to_be32(1); + } } typedef void (*aghdr_init_work_f)(struct xfs_mount *mp, struct xfs_buf *bp, diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index f0ecd06..01544f9 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -449,6 +449,7 @@ xfs_sb_has_compat_feature( #define XFS_SB_FEAT_RO_COMPAT_FINOBT (1 << 0) /* free inode btree */ #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ #define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflinked files */ +#define XFS_SB_FEAT_RO_COMPAT_INOBTCNT (1 << 3) /* inobt block counts */ #define XFS_SB_FEAT_RO_COMPAT_ALL \ (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ @@ -564,6 +565,17 @@ static inline bool xfs_sb_version_hasreflink(struct xfs_sb *sbp) } /* + * Inode btree block counter. We record the number of inobt and finobt blocks + * in the AGI header so that we can skip the finobt walk at mount time when + * setting up per-AG reservations. + */ +static inline bool xfs_sb_version_hasinobtcounts(struct xfs_sb *sbp) +{ + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && + (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_INOBTCNT); +} + +/* * end of superblock version macros */ @@ -765,6 +777,9 @@ typedef struct xfs_agi { __be32 agi_free_root; /* root of the free inode btree */ __be32 agi_free_level;/* levels in free inode btree */ + __be32 agi_iblocks; /* inobt blocks used */ + __be32 agi_fblocks; /* finobt blocks used */ + /* structure must be padded to 64 bit alignment */ } xfs_agi_t; @@ -785,7 +800,8 @@ typedef struct xfs_agi { #define XFS_AGI_ALL_BITS_R1 ((1 << XFS_AGI_NUM_BITS_R1) - 1) #define XFS_AGI_FREE_ROOT (1 << 11) #define XFS_AGI_FREE_LEVEL (1 << 12) -#define XFS_AGI_NUM_BITS_R2 13 +#define XFS_AGI_IBLOCKS (1 << 13) /* both inobt/finobt block counters */ +#define XFS_AGI_NUM_BITS_R2 14 /* disk block (xfs_daddr_t) in the AG */ #define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index ce73fee..8adeb10 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -2468,6 +2468,7 @@ xfs_ialloc_log_agi( offsetof(xfs_agi_t, agi_unlinked), offsetof(xfs_agi_t, agi_free_root), offsetof(xfs_agi_t, agi_free_level), + offsetof(xfs_agi_t, agi_iblocks), sizeof(xfs_agi_t) }; #ifdef DEBUG diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c index 41c308c..3ed87d1 100644 --- a/libxfs/xfs_ialloc_btree.c +++ b/libxfs/xfs_ialloc_btree.c @@ -66,6 +66,25 @@ xfs_finobt_set_root( XFS_AGI_FREE_ROOT | XFS_AGI_FREE_LEVEL); } +/* Update the inode btree block counter for this btree. */ +static inline void +xfs_inobt_mod_blockcount( + struct xfs_btree_cur *cur, + int howmuch) +{ + struct xfs_buf *agbp = cur->bc_ag.agbp; + struct xfs_agi *agi = agbp->b_addr; + + if (!xfs_sb_version_hasinobtcounts(&cur->bc_mp->m_sb)) + return; + + if (cur->bc_btnum == XFS_BTNUM_FINO) + be32_add_cpu(&agi->agi_fblocks, howmuch); + else if (cur->bc_btnum == XFS_BTNUM_INO) + be32_add_cpu(&agi->agi_iblocks, howmuch); + xfs_ialloc_log_agi(cur->bc_tp, agbp, XFS_AGI_IBLOCKS); +} + STATIC int __xfs_inobt_alloc_block( struct xfs_btree_cur *cur, @@ -101,6 +120,7 @@ __xfs_inobt_alloc_block( new->s = cpu_to_be32(XFS_FSB_TO_AGBNO(args.mp, args.fsbno)); *stat = 1; + xfs_inobt_mod_blockcount(cur, 1); return 0; } @@ -133,6 +153,7 @@ __xfs_inobt_free_block( struct xfs_buf *bp, enum xfs_ag_resv_type resv) { + xfs_inobt_mod_blockcount(cur, -1); return xfs_free_extent(cur->bc_tp, XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(bp)), 1, &XFS_RMAP_OINFO_INOBT, resv); From patchwork Fri Oct 23 06:32:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852271 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC5B014B2 for ; Fri, 23 Oct 2020 06:33:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8870C223C7 for ; Fri, 23 Oct 2020 06:33:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="K3qOD4ae" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372791AbgJWGdU (ORCPT ); Fri, 23 Oct 2020 02:33:20 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:37750 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372782AbgJWGdT (ORCPT ); Fri, 23 Oct 2020 02:33:19 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6PUsd007889 for ; Fri, 23 Oct 2020 06:33:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=8CJ5kGNCMANpHWsmquFL+rKZ+Rc6jTVGIkJCvsRYPso=; b=K3qOD4aePxsuMe3HlLkyRHeYKWi3yrnxSRXQgPDH3bFrhiNMbBKLxBiz5PrXHHIjq+M7 pKCpzBbr4haO7ocA6LRm2nF6uyopyoaWgE80BTbnXTka54iFnLSQx08RvfQNsbl7ClXu LY16AoSvGh43rOr5bST8UD4ekUzaoazHtDmIZVk5utwccC4HXVGVn3MAZQZ4iylD6WbS 5NUDu6Z3X8MMtFgucjbfNbJ3KWFD2sU1yNPZW44kpkNEGKtiTQ9bjfgUgda3bwiCViMe MtFBXL77qO+QY2yYMSAfMSBU02pCVvaVE4UBrf8tqWA3G/OoQUcPhnQV5OW/3fi6RTQh Fg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 347p4b9du6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:33:18 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6QAoO100472 for ; Fri, 23 Oct 2020 06:33:18 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 348a6re9jw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:18 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 09N6XHCF009339 for ; Fri, 23 Oct 2020 06:33:17 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:16 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 02/14] xfs: enable new inode btree counters feature Date: Thu, 22 Oct 2020 23:32:54 -0700 Message-Id: <20201023063306.7441-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 suspectscore=1 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" Source kernel commit: b896a39faa5a2f97dadfb347928466afb12cc63a Enable the new inode btree counters feature. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Signed-off-by: Allison Henderson --- libxfs/xfs_format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 01544f9..5a183b6 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -453,7 +453,8 @@ xfs_sb_has_compat_feature( #define XFS_SB_FEAT_RO_COMPAT_ALL \ (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ - XFS_SB_FEAT_RO_COMPAT_REFLINK) + XFS_SB_FEAT_RO_COMPAT_REFLINK| \ + XFS_SB_FEAT_RO_COMPAT_INOBTCNT) #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL static inline bool xfs_sb_has_ro_compat_feature( From patchwork Fri Oct 23 06:32:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852311 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01DF361C for ; Fri, 23 Oct 2020 06:35:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D047D22253 for ; Fri, 23 Oct 2020 06:35:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ahWiS0EV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372843AbgJWGfU (ORCPT ); Fri, 23 Oct 2020 02:35:20 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45154 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372848AbgJWGfU (ORCPT ); Fri, 23 Oct 2020 02:35:20 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6OKOd025425 for ; Fri, 23 Oct 2020 06:35:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=pyB9iK+MRlpaMj2mfDK3+42kjtMHTbOUh58jymyV/EY=; b=ahWiS0EVXnysC9l4RQX+zUJZoM+iAAxp4NsFXkChpK2s5f2h66m7WxWBD8GQOBQ3MLE4 r7DrTa52P5zjD/yDscFJLZpxf9D3lchlI5X4mmpVujLjib0RidHqxeiAql57cKw6X/me lM62xAv/L+gjIaxVdklJ8uowXkbnJ5sb6vrqcg/H/CVd5GvEOcUCClZnRUhby6vmx1K+ Ok8xcL740pp/ea2cy1YC4A5j5eYofYcKiQWdzFQwahGr1ZqSWIDYmiQBAhsjunMWu6R9 y269RJ4W4VR4kWaroCDtRwGlp8tnvfcj81TDlHK4OxWGfkaQyml87WjNxN2lNQC3MF5j kg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 34ak16snps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:35:18 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6P6RB178387 for ; Fri, 23 Oct 2020 06:33:18 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 348aj0n970-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:18 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 09N6XHV6008350 for ; Fri, 23 Oct 2020 06:33:17 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:17 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 03/14] xfsprogs: Add helper xfs_attr_node_remove_step Date: Thu, 22 Oct 2020 23:32:55 -0700 Message-Id: <20201023063306.7441-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 mlxlogscore=999 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Collins Source kernel commit: 5e2aff99f8f0b7ff511b7bbd1213743f59806878 This patch adds a new helper function xfs_attr_node_remove_step. This will help simplify and modularize the calling function xfs_attr_node_remove. Signed-off-by: Allison Henderson --- libxfs/xfs_attr.c | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 1c1092f..1bf71dc 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1220,19 +1220,14 @@ xfs_attr_node_remove_rmt( * the root node (a special case of an intermediate node). */ STATIC int -xfs_attr_node_removename( - struct xfs_da_args *args) +xfs_attr_node_remove_step( + struct xfs_da_args *args, + struct xfs_da_state *state) { - struct xfs_da_state *state; struct xfs_da_state_blk *blk; int retval, error; struct xfs_inode *dp = args->dp; - trace_xfs_attr_node_removename(args); - - error = xfs_attr_node_removename_setup(args, &state); - if (error) - goto out; /* * If there is an out-of-line value, de-allocate the blocks. @@ -1242,7 +1237,7 @@ xfs_attr_node_removename( if (args->rmtblkno > 0) { error = xfs_attr_node_remove_rmt(args, state); if (error) - goto out; + return error; } /* @@ -1259,18 +1254,45 @@ xfs_attr_node_removename( if (retval && (state->path.active > 1)) { error = xfs_da3_join(state); if (error) - goto out; + return error; error = xfs_defer_finish(&args->trans); if (error) - goto out; + return error; /* * Commit the Btree join operation and start a new trans. */ error = xfs_trans_roll_inode(&args->trans, dp); if (error) - goto out; + return error; } + return error; +} + +/* + * Remove a name from a B-tree attribute list. + * + * This routine will find the blocks of the name to remove, remove them and + * shirnk the tree if needed. + */ +STATIC int +xfs_attr_node_removename( + struct xfs_da_args *args) +{ + struct xfs_da_state *state; + int error; + struct xfs_inode *dp = args->dp; + + trace_xfs_attr_node_removename(args); + + error = xfs_attr_node_removename_setup(args, &state); + if (error) + goto out; + + error = xfs_attr_node_remove_step(args, state); + if (error) + goto out; + /* * If the result is small enough, push it all into the inode. */ From patchwork Fri Oct 23 06:32:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852281 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3ED6361C for ; Fri, 23 Oct 2020 06:33:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12BD622254 for ; Fri, 23 Oct 2020 06:33:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="VyJOZesd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372792AbgJWGdX (ORCPT ); Fri, 23 Oct 2020 02:33:23 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:41416 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372779AbgJWGdX (ORCPT ); Fri, 23 Oct 2020 02:33:23 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6OlKR106649 for ; Fri, 23 Oct 2020 06:33:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=kmAyZ2nYBn1N9tGf5y85LN0qaLX5abKtm39h33EPHJU=; b=VyJOZesdrGWjnXwOGS6Tv+YhS24JjVG8lLjPUvLtFmRkR6S/kn0CgZQQCb4QF3mUgw56 YwXLkZM0X9dWRXF7HvS0nIulmEGkG4av1hQQ0MI/p9BcqlAzH0gw2qKswYZa4WgbCd6t Po7LMEOmdMFbWF7tQSHrdW/oFL2mlOLyNOlQQfT3jhrfW+9TYbSybwsO/mEwy2HyTf11 uq8VH3UluDpOqHDU6aswbUM8siqQGg8aPkm/3NAl9rHxtELgbZkyjiZHM7IbHHPCtrW8 A5mR7Up2jkuClxBZ7ZnLeAaRD3CkY18KyKIHpubjmW3XigL3jLrIY8J9gCTiy7Lghj+0 Uw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 349jrq1eq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:33:19 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6P6G9178415 for ; Fri, 23 Oct 2020 06:33:18 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 348aj0n97a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:18 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 09N6XHUq009348 for ; Fri, 23 Oct 2020 06:33:17 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:17 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 04/14] xfsprogs: Add delay ready attr remove routines Date: Thu, 22 Oct 2020 23:32:56 -0700 Message-Id: <20201023063306.7441-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 suspectscore=4 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=4 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch modifies the attr remove routines to be delay ready. This means they no longer roll or commit transactions, but instead return -EAGAIN to have the calling routine roll and refresh the transaction. In this series, xfs_attr_remove_args has become xfs_attr_remove_iter, which uses a sort of state machine like switch to keep track of where it was when EAGAIN was returned. xfs_attr_node_removename has also been modified to use the switch, and a new version of xfs_attr_remove_args consists of a simple loop to refresh the transaction until the operation is completed. A new XFS_DAC_DEFER_FINISH flag is used to finish the transaction where ever the existing code used to. Calls to xfs_attr_rmtval_remove are replaced with the delay ready version __xfs_attr_rmtval_remove. We will rename __xfs_attr_rmtval_remove back to xfs_attr_rmtval_remove when we are done. xfs_attr_rmtval_remove itself is still in use by the set routines (used during a rename). For reasons of preserving existing function, we modify xfs_attr_rmtval_remove to call xfs_defer_finish when the flag is set. Similar to how xfs_attr_remove_args does here. Once we transition the set routines to be delay ready, xfs_attr_rmtval_remove is no longer used and will be removed. This patch also adds a new struct xfs_delattr_context, which we will use to keep track of the current state of an attribute operation. The new xfs_delattr_state enum is used to track various operations that are in progress so that we know not to repeat them, and resume where we left off before EAGAIN was returned to cycle out the transaction. Other members take the place of local variables that need to retain their values across multiple function recalls. See xfs_attr.h for a more detailed diagram of the states. Signed-off-by: Allison Henderson --- include/libxfs.h | 1 + libxfs/xfs_attr.c | 200 ++++++++++++++++++++++++++++++++++------------- libxfs/xfs_attr.h | 72 +++++++++++++++++ libxfs/xfs_attr_leaf.c | 2 +- libxfs/xfs_attr_remote.c | 36 ++++----- libxfs/xfs_attr_remote.h | 2 +- 6 files changed, 239 insertions(+), 74 deletions(-) diff --git a/include/libxfs.h b/include/libxfs.h index b937013..e962416 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -170,6 +170,7 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; #include "xfs_ialloc.h" #include "xfs_attr_leaf.h" +#include "xfs_attr.h" #include "xfs_attr_remote.h" #include "xfs_trans_space.h" diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 1bf71dc..3dc0780 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -53,7 +53,7 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC int xfs_attr_node_addname(xfs_da_args_t *args); -STATIC int xfs_attr_node_removename(xfs_da_args_t *args); +STATIC int xfs_attr_node_removename_iter(struct xfs_delattr_context *dac); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); @@ -264,6 +264,33 @@ xfs_attr_set_shortform( } /* + * Checks to see if a delayed attribute transaction should be rolled. If so, + * also checks for a defer finish. Transaction is finished and rolled as + * needed, and returns true of false if the delayed operation should continue. + */ +int +xfs_attr_trans_roll( + struct xfs_delattr_context *dac) +{ + struct xfs_da_args *args = dac->da_args; + int error = 0; + + if (dac->flags & XFS_DAC_DEFER_FINISH) { + /* + * The caller wants us to finish all the deferred ops so that we + * avoid pinning the log tail with a large number of deferred + * ops. + */ + dac->flags &= ~XFS_DAC_DEFER_FINISH; + error = xfs_defer_finish(&args->trans); + if (error) + return error; + } + + return xfs_trans_roll_inode(&args->trans, args->dp); +} + +/* * Set the attribute specified in @args. */ int @@ -364,23 +391,54 @@ xfs_has_attr( */ int xfs_attr_remove_args( - struct xfs_da_args *args) + struct xfs_da_args *args) { - struct xfs_inode *dp = args->dp; - int error; + int error = 0; + struct xfs_delattr_context dac = { + .da_args = args, + }; + + do { + error = xfs_attr_remove_iter(&dac); + if (error != -EAGAIN) + break; + + error = xfs_attr_trans_roll(&dac); + if (error) + return error; + + } while (true); + + return error; +} + +/* + * Remove the attribute specified in @args. + * + * This function may return -EAGAIN to signal that the transaction needs to be + * rolled. Callers should continue calling this function until they receive a + * return value other than -EAGAIN. + */ +int +xfs_attr_remove_iter( + struct xfs_delattr_context *dac) +{ + struct xfs_da_args *args = dac->da_args; + struct xfs_inode *dp = args->dp; + + if (dac->dela_state == XFS_DAS_RM_SHRINK) + goto node; if (!xfs_inode_hasattr(dp)) { - error = -ENOATTR; + return -ENOATTR; } else if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) { ASSERT(dp->i_afp->if_flags & XFS_IFINLINE); - error = xfs_attr_shortform_remove(args); + return xfs_attr_shortform_remove(args); } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_removename(args); - } else { - error = xfs_attr_node_removename(args); + return xfs_attr_leaf_removename(args); } - - return error; +node: + return xfs_attr_node_removename_iter(dac); } /* @@ -1170,10 +1228,11 @@ xfs_attr_leaf_mark_incomplete( */ STATIC int xfs_attr_node_removename_setup( - struct xfs_da_args *args, - struct xfs_da_state **state) + struct xfs_delattr_context *dac, + struct xfs_da_state **state) { - int error; + struct xfs_da_args *args = dac->da_args; + int error; error = xfs_attr_node_hasname(args, state); if (error != -EEXIST) @@ -1183,6 +1242,12 @@ int xfs_attr_node_removename_setup( ASSERT((*state)->path.blk[(*state)->path.active - 1].magic == XFS_ATTR_LEAF_MAGIC); + /* + * Store state in the context incase we need to cycle out the + * transaction + */ + dac->da_state = *state; + if (args->rmtblkno > 0) { error = xfs_attr_leaf_mark_incomplete(args, *state); if (error) @@ -1195,13 +1260,16 @@ int xfs_attr_node_removename_setup( } STATIC int -xfs_attr_node_remove_rmt( - struct xfs_da_args *args, - struct xfs_da_state *state) +xfs_attr_node_remove_rmt ( + struct xfs_delattr_context *dac, + struct xfs_da_state *state) { - int error = 0; + int error = 0; - error = xfs_attr_rmtval_remove(args); + /* + * May return -EAGAIN to request that the caller recall this function + */ + error = __xfs_attr_rmtval_remove(dac); if (error) return error; @@ -1213,21 +1281,27 @@ xfs_attr_node_remove_rmt( } /* - * Remove a name from a B-tree attribute list. + * Step through removeing a name from a B-tree attribute list. * * This will involve walking down the Btree, and may involve joining * leaf nodes and even joining intermediate nodes up to and including * the root node (a special case of an intermediate node). + * + * This routine is meant to function as either an inline or delayed operation, + * and may return -EAGAIN when the transaction needs to be rolled. Calling + * functions will need to handle this, and recall the function until a + * successful error code is returned. */ STATIC int xfs_attr_node_remove_step( - struct xfs_da_args *args, - struct xfs_da_state *state) + struct xfs_delattr_context *dac) { - struct xfs_da_state_blk *blk; - int retval, error; - struct xfs_inode *dp = args->dp; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state *state; + struct xfs_da_state_blk *blk; + int retval, error = 0; + state = dac->da_state; /* * If there is an out-of-line value, de-allocate the blocks. @@ -1235,7 +1309,10 @@ xfs_attr_node_remove_step( * overflow the maximum size of a transaction and/or hit a deadlock. */ if (args->rmtblkno > 0) { - error = xfs_attr_node_remove_rmt(args, state); + /* + * May return -EAGAIN. Remove blocks until args->rmtblkno == 0 + */ + error = xfs_attr_node_remove_rmt(dac, state); if (error) return error; } @@ -1249,21 +1326,16 @@ xfs_attr_node_remove_step( xfs_da3_fixhashpath(state, &state->path); /* - * Check to see if the tree needs to be collapsed. + * Check to see if the tree needs to be collapsed. Set the flag to + * indicate that the calling function needs to move the to shrink + * operation */ if (retval && (state->path.active > 1)) { error = xfs_da3_join(state); if (error) - return error; - error = xfs_defer_finish(&args->trans); - if (error) - return error; - /* - * Commit the Btree join operation and start a new trans. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; + dac->flags |= XFS_DAC_DEFER_FINISH; + dac->dela_state = XFS_DAS_RM_SHRINK; + return -EAGAIN; } return error; @@ -1274,31 +1346,53 @@ xfs_attr_node_remove_step( * * This routine will find the blocks of the name to remove, remove them and * shirnk the tree if needed. + * + * This routine is meant to function as either an inline or delayed operation, + * and may return -EAGAIN when the transaction needs to be rolled. Calling + * functions will need to handle this, and recall the function until a + * successful error code is returned. */ STATIC int -xfs_attr_node_removename( - struct xfs_da_args *args) +xfs_attr_node_removename_iter( + struct xfs_delattr_context *dac) { - struct xfs_da_state *state; - int error; - struct xfs_inode *dp = args->dp; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state *state; + int error; + struct xfs_inode *dp = args->dp; trace_xfs_attr_node_removename(args); + state = dac->da_state; - error = xfs_attr_node_removename_setup(args, &state); - if (error) - goto out; + if ((dac->flags & XFS_DAC_NODE_RMVNAME_INIT) == 0) { + dac->flags |= XFS_DAC_NODE_RMVNAME_INIT; + error = xfs_attr_node_removename_setup(dac, &state); + if (error) + goto out; + } - error = xfs_attr_node_remove_step(args, state); - if (error) - goto out; + switch (dac->dela_state) { + case XFS_DAS_UNINIT: + error = xfs_attr_node_remove_step(dac); + if (error) + break; - /* - * If the result is small enough, push it all into the inode. - */ - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) - error = xfs_attr_node_shrink(args, state); + /* do not break, proceed to shrink if needed */ + case XFS_DAS_RM_SHRINK: + /* + * If the result is small enough, push it all into the inode. + */ + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) + error = xfs_attr_node_shrink(args, state); + break; + default: + ASSERT(0); + return -EINVAL; + } + + if (error == -EAGAIN) + return error; out: if (state) xfs_da_state_free(state); diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 3e97a93..64dcf0f 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -74,6 +74,74 @@ struct xfs_attr_list_context { }; +/* + * ======================================================================== + * Structure used to pass context around among the delayed routines. + * ======================================================================== + */ + +/* + * Below is a state machine diagram for attr remove operations. The XFS_DAS_* + * states indicate places where the function would return -EAGAIN, and then + * immediately resume from after being recalled by the calling function. States + * marked as a "subroutine state" indicate that they belong to a subroutine, and + * so the calling function needs to pass them back to that subroutine to allow + * it to finish where it left off. But they otherwise do not have a role in the + * calling function other than just passing through. + * + * xfs_attr_remove_iter() + * XFS_DAS_RM_SHRINK ─┐ + * (subroutine state) │ + * └─>xfs_attr_node_removename() + * │ + * v + * need to + * shrink tree? ─n─┐ + * │ │ + * y │ + * │ │ + * v │ + * XFS_DAS_RM_SHRINK │ + * │ │ + * v │ + * done <─────┘ + * + */ + +/* + * Enum values for xfs_delattr_context.da_state + * + * These values are used by delayed attribute operations to keep track of where + * they were before they returned -EAGAIN. A return code of -EAGAIN signals the + * calling function to roll the transaction, and then recall the subroutine to + * finish the operation. The enum is then used by the subroutine to jump back + * to where it was and resume executing where it left off. + */ +enum xfs_delattr_state { + XFS_DAS_UNINIT = 0, /* No state has been set yet */ + XFS_DAS_RM_SHRINK, /* We are shrinking the tree */ +}; + +/* + * Defines for xfs_delattr_context.flags + */ +#define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ +#define XFS_DAC_NODE_RMVNAME_INIT 0x02 /* xfs_attr_node_removename init */ + +/* + * Context used for keeping track of delayed attribute operations + */ +struct xfs_delattr_context { + struct xfs_da_args *da_args; + + /* Used in xfs_attr_node_removename to roll through removing blocks */ + struct xfs_da_state *da_state; + + /* Used to keep track of current state of delayed operation */ + unsigned int flags; + enum xfs_delattr_state dela_state; +}; + /*======================================================================== * Function prototypes for the kernel. *========================================================================*/ @@ -91,6 +159,10 @@ int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_args(struct xfs_da_args *args); int xfs_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); +int xfs_attr_remove_iter(struct xfs_delattr_context *dac); +int xfs_attr_trans_roll(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); +void xfs_delattr_context_init(struct xfs_delattr_context *dac, + struct xfs_da_args *args); #endif /* __XFS_ATTR_H__ */ diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 269efb7..f869727 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -19,8 +19,8 @@ #include "xfs_bmap_btree.h" #include "xfs_bmap.h" #include "xfs_attr_sf.h" -#include "xfs_attr_remote.h" #include "xfs_attr.h" +#include "xfs_attr_remote.h" #include "xfs_attr_leaf.h" #include "xfs_trace.h" #include "xfs_dir2.h" diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index f09ea29..ff53d09 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -675,10 +675,12 @@ xfs_attr_rmtval_invalidate( */ int xfs_attr_rmtval_remove( - struct xfs_da_args *args) + struct xfs_da_args *args) { - int error; - int retval; + int error; + struct xfs_delattr_context dac = { + .da_args = args, + }; trace_xfs_attr_rmtval_remove(args); @@ -686,19 +688,16 @@ xfs_attr_rmtval_remove( * Keep de-allocating extents until the remote-value region is gone. */ do { - retval = __xfs_attr_rmtval_remove(args); - if (retval && retval != -EAGAIN) - return retval; + error = __xfs_attr_rmtval_remove(&dac); + if (error != -EAGAIN) + break; - /* - * Close out trans and start the next one in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); + error = xfs_attr_trans_roll(&dac); if (error) return error; - } while (retval == -EAGAIN); + } while (true); - return 0; + return error; } /* @@ -708,9 +707,10 @@ xfs_attr_rmtval_remove( */ int __xfs_attr_rmtval_remove( - struct xfs_da_args *args) + struct xfs_delattr_context *dac) { - int error, done; + struct xfs_da_args *args = dac->da_args; + int error, done; /* * Unmap value blocks for this attr. @@ -720,12 +720,10 @@ __xfs_attr_rmtval_remove( if (error) return error; - error = xfs_defer_finish(&args->trans); - if (error) - return error; - - if (!done) + if (!done) { + dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; + } return error; } diff --git a/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index 9eee615..002fd30 100644 --- a/libxfs/xfs_attr_remote.h +++ b/libxfs/xfs_attr_remote.h @@ -14,5 +14,5 @@ int xfs_attr_rmtval_remove(struct xfs_da_args *args); int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map, xfs_buf_flags_t incore_flags); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); -int __xfs_attr_rmtval_remove(struct xfs_da_args *args); +int __xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); #endif /* __XFS_ATTR_REMOTE_H__ */ From patchwork Fri Oct 23 06:32:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852289 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC8AF61C for ; Fri, 23 Oct 2020 06:33:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A284A22254 for ; Fri, 23 Oct 2020 06:33:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="jCgSNz0G" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372799AbgJWGd0 (ORCPT ); Fri, 23 Oct 2020 02:33:26 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:37770 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372782AbgJWGdZ (ORCPT ); Fri, 23 Oct 2020 02:33:25 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6PxDO008259 for ; Fri, 23 Oct 2020 06:33:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=HJkHup6zYs0SjkwgCrCgCKFx4m28tV9PxJDtpsILqpM=; b=jCgSNz0Gi6rzUwWbjQZgpo/V7nHNbSVwXmZbC6G5k9er5dl3y17nBA7FN+8VcbLrks6D SPXqL0e7EBfeLj6nsVKv1r21ZictBw3z0CHjSE64mfk+YHBILaUQsP1y/LmZZUODkeNG 5Du8bRteakWNKRIiINDQqMBn83Yk67r899usv3EH+aZFU+Mv/lnFWG1kXklMb+BjVgB1 DS7PrxLdNwzl7HsTaLvm0qH/UZCL7dRU99nLVhQToiROYMLjCgElOn0QmFEqz6w6FYW2 NvVDGMgoVxx4QhVQy5NUUlLDxa2vQJY7HE4e8epkIxLtYdlFCiYJwPo9fLDxqUJhjJtA pQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 347p4b9du9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:33:19 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6QAHX100424 for ; Fri, 23 Oct 2020 06:33:19 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 348a6re9k7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:19 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 09N6XIAx009355 for ; Fri, 23 Oct 2020 06:33:18 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:17 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 05/14] xfsprogs: Add delay ready attr set routines Date: Thu, 22 Oct 2020 23:32:57 -0700 Message-Id: <20201023063306.7441-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 suspectscore=3 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch modifies the attr set routines to be delay ready. This means they no longer roll or commit transactions, but instead return -EAGAIN to have the calling routine roll and refresh the transaction. In this series, xfs_attr_set_args has become xfs_attr_set_iter, which uses a state machine like switch to keep track of where it was when EAGAIN was returned. See xfs_attr.h for a more detailed diagram of the states. Two new helper functions have been added: xfs_attr_rmtval_set_init and xfs_attr_rmtval_set_blk. They provide a subset of logic similar to xfs_attr_rmtval_set, but they store the current block in the delay attr context to allow the caller to roll the transaction between allocations. This helps to simplify and consolidate code used by xfs_attr_leaf_addname and xfs_attr_node_addname. xfs_attr_set_args has now become a simple loop to refresh the transaction until the operation is completed. Lastly, xfs_attr_rmtval_remove is no longer used, and is removed. Signed-off-by: Allison Henderson --- libxfs/xfs_attr.c | 370 +++++++++++++++++++++++++++++++---------------- libxfs/xfs_attr.h | 126 +++++++++++++++- libxfs/xfs_attr_remote.c | 98 ++++++++----- libxfs/xfs_attr_remote.h | 4 + 4 files changed, 439 insertions(+), 159 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 3dc0780..1cd3ae3 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -44,7 +44,7 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args); * Internal routines when attribute list is one block. */ STATIC int xfs_attr_leaf_get(xfs_da_args_t *args); -STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args); +STATIC int xfs_attr_leaf_addname(struct xfs_delattr_context *dac); STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); @@ -52,12 +52,15 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); * Internal routines when attribute list is more than one block. */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); -STATIC int xfs_attr_node_addname(xfs_da_args_t *args); +STATIC int xfs_attr_node_addname(struct xfs_delattr_context *dac); STATIC int xfs_attr_node_removename_iter(struct xfs_delattr_context *dac); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); +STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); +STATIC int xfs_attr_set_iter(struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp); int xfs_inode_hasattr( @@ -218,8 +221,11 @@ xfs_attr_is_shortform( /* * Attempts to set an attr in shortform, or converts short form to leaf form if - * there is not enough room. If the attr is set, the transaction is committed - * and set to NULL. + * there is not enough room. This function is meant to operate as a helper + * routine to the delayed attribute functions. It returns -EAGAIN to indicate + * that the calling function should roll the transaction, and then proceed to + * add the attr in leaf form. This subroutine does not expect to be recalled + * again like the other delayed attr routines do. */ STATIC int xfs_attr_set_shortform( @@ -227,16 +233,16 @@ xfs_attr_set_shortform( struct xfs_buf **leaf_bp) { struct xfs_inode *dp = args->dp; - int error, error2 = 0; + int error = 0; /* * Try to add the attr to the attribute list in the inode. */ error = xfs_attr_try_sf_addname(dp, args); + + /* Should only be 0, -EEXIST or ENOSPC */ if (error != -ENOSPC) { - error2 = xfs_trans_commit(args->trans); - args->trans = NULL; - return error ? error : error2; + return error; } /* * It won't fit in the shortform, transform to a leaf block. GROT: @@ -249,18 +255,10 @@ xfs_attr_set_shortform( /* * Prevent the leaf buffer from being unlocked so that a concurrent AIL * push cannot grab the half-baked leaf buffer and run into problems - * with the write verifier. Once we're done rolling the transaction we - * can release the hold and add the attr to the leaf. + * with the write verifier. */ xfs_trans_bhold(args->trans, *leaf_bp); - error = xfs_defer_finish(&args->trans); - xfs_trans_bhold_release(args->trans, *leaf_bp); - if (error) { - xfs_trans_brelse(args->trans, *leaf_bp); - return error; - } - - return 0; + return -EAGAIN; } /* @@ -268,7 +266,7 @@ xfs_attr_set_shortform( * also checks for a defer finish. Transaction is finished and rolled as * needed, and returns true of false if the delayed operation should continue. */ -int +STATIC int xfs_attr_trans_roll( struct xfs_delattr_context *dac) { @@ -297,61 +295,130 @@ int xfs_attr_set_args( struct xfs_da_args *args) { - struct xfs_inode *dp = args->dp; - struct xfs_buf *leaf_bp = NULL; - int error = 0; + struct xfs_buf *leaf_bp = NULL; + int error = 0; + struct xfs_delattr_context dac = { + .da_args = args, + }; + + do { + error = xfs_attr_set_iter(&dac, &leaf_bp); + if (error != -EAGAIN) + break; + + error = xfs_attr_trans_roll(&dac); + if (error) + return error; + + if (leaf_bp) { + xfs_trans_bjoin(args->trans, leaf_bp); + xfs_trans_bhold(args->trans, leaf_bp); + } + + } while (true); + + return error; +} + +/* + * Set the attribute specified in @args. + * This routine is meant to function as a delayed operation, and may return + * -EAGAIN when the transaction needs to be rolled. Calling functions will need + * to handle this, and recall the function until a successful error code is + * returned. + */ +STATIC int +xfs_attr_set_iter( + struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp) +{ + struct xfs_da_args *args = dac->da_args; + struct xfs_inode *dp = args->dp; + int error = 0; + + /* State machine switch */ + switch (dac->dela_state) { + case XFS_DAS_FLIP_LFLAG: + case XFS_DAS_FOUND_LBLK: + goto das_leaf; + case XFS_DAS_FOUND_NBLK: + case XFS_DAS_FLIP_NFLAG: + case XFS_DAS_ALLOC_NODE: + goto das_node; + default: + break; + } /* * If the attribute list is already in leaf format, jump straight to * leaf handling. Otherwise, try to add the attribute to the shortform * list; if there's no room then convert the list to leaf format and try - * again. + * again. No need to set state as we will be in leaf form when we come + * back */ if (xfs_attr_is_shortform(dp)) { /* - * If the attr was successfully set in shortform, the - * transaction is committed and set to NULL. Otherwise, is it - * converted from shortform to leaf, and the transaction is - * retained. + * If the attr was successfully set in shortform, no need to + * continue. Otherwise, is it converted from shortform to leaf + * and -EAGAIN is returned. */ - error = xfs_attr_set_shortform(args, &leaf_bp); - if (error || !args->trans) - return error; + error = xfs_attr_set_shortform(args, leaf_bp); + if (error == -EAGAIN) + dac->flags |= XFS_DAC_DEFER_FINISH; + + return error; } - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_addname(args); - if (error != -ENOSPC) - return error; + /* + * After a shortform to leaf conversion, we need to hold the leaf and + * cycle out the transaction. When we get back, we need to release + * the leaf. + */ + if (*leaf_bp != NULL) { + xfs_trans_bhold_release(args->trans, *leaf_bp); + *leaf_bp = NULL; + } - /* - * Promote the attribute list to the Btree format. - */ - error = xfs_attr3_leaf_to_node(args); - if (error) - return error; + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { + error = xfs_attr_leaf_try_add(args, *leaf_bp); + switch (error) { + case -ENOSPC: + /* + * Promote the attribute list to the Btree format. + */ + error = xfs_attr3_leaf_to_node(args); + if (error) + return error; - /* - * Finish any deferred work items and roll the transaction once - * more. The goal here is to call node_addname with the inode - * and transaction in the same state (inode locked and joined, - * transaction clean) no matter how we got to this step. - */ - error = xfs_defer_finish(&args->trans); - if (error) + /* + * Finish any deferred work items and roll the + * transaction once more. The goal here is to call + * node_addname with the inode and transaction in the + * same state (inode locked and joined, transaction + * clean) no matter how we got to this step. + */ + dac->flags |= XFS_DAC_DEFER_FINISH; + return -EAGAIN; + case 0: + dac->dela_state = XFS_DAS_FOUND_LBLK; + return -EAGAIN; + default: return error; + } +das_leaf: + error = xfs_attr_leaf_addname(dac); + if (error == -ENOSPC) + /* + * No need to set state. We will be in node form when + * we are recalled + */ + return -EAGAIN; - /* - * Commit the current trans (including the inode) and - * start a new one. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; + return error; } - - error = xfs_attr_node_addname(args); +das_node: + error = xfs_attr_node_addname(dac); return error; } @@ -715,28 +782,30 @@ out_brelse: * * This leaf block cannot have a "remote" value, we only call this routine * if bmap_one_block() says there is only one block (ie: no remote blks). + * + * This routine is meant to function as a delayed operation, and may return + * -EAGAIN when the transaction needs to be rolled. Calling functions will need + * to handle this, and recall the function until a successful error code is + * returned. */ STATIC int xfs_attr_leaf_addname( - struct xfs_da_args *args) + struct xfs_delattr_context *dac) { - int error, forkoff; - struct xfs_buf *bp = NULL; - struct xfs_inode *dp = args->dp; - - trace_xfs_attr_leaf_addname(args); - - error = xfs_attr_leaf_try_add(args, bp); - if (error) - return error; + struct xfs_da_args *args = dac->da_args; + struct xfs_buf *bp = NULL; + int error, forkoff; + struct xfs_inode *dp = args->dp; - /* - * Commit the transaction that added the attr name so that - * later routines can manage their own transactions. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; + /* State machine switch */ + switch (dac->dela_state) { + case XFS_DAS_FLIP_LFLAG: + goto das_flip_flag; + case XFS_DAS_RM_LBLK: + goto das_rm_lblk; + default: + break; + } /* * If there was an out-of-line value, allocate the blocks we @@ -744,12 +813,34 @@ xfs_attr_leaf_addname( * after we create the attribute so that we don't overflow the * maximum size of a transaction and/or hit a deadlock. */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); + + /* Open coded xfs_attr_rmtval_set without trans handling */ + if ((dac->flags & XFS_DAC_LEAF_ADDNAME_INIT) == 0) { + dac->flags |= XFS_DAC_LEAF_ADDNAME_INIT; + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_find_space(dac); + if (error) + return error; + } + } + + /* + * Roll through the "value", allocating blocks on disk as + * required. + */ + if (dac->blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(dac); if (error) return error; + + dac->flags |= XFS_DAC_DEFER_FINISH; + return -EAGAIN; } + error = xfs_attr_rmtval_set_value(args); + if (error) + return error; + if (!(args->op_flags & XFS_DA_OP_RENAME)) { /* * Added a "remote" value, just clear the incomplete flag. @@ -769,29 +860,29 @@ xfs_attr_leaf_addname( * In a separate transaction, set the incomplete flag on the "old" attr * and clear the incomplete flag on the "new" attr. */ - error = xfs_attr3_leaf_flipflags(args); if (error) return error; /* * Commit the flag value change and start the next trans in series. */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - return error; - + dac->dela_state = XFS_DAS_FLIP_LFLAG; + return -EAGAIN; +das_flip_flag: /* * Dismantle the "old" attribute/value pair by removing a "remote" value * (if it exists). */ xfs_attr_restore_rmt_blk(args); + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; +das_rm_lblk: if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; - - error = xfs_attr_rmtval_remove(args); + error = __xfs_attr_rmtval_remove(dac); + if (error == -EAGAIN) + dac->dela_state = XFS_DAS_RM_LBLK; if (error) return error; } @@ -957,23 +1048,38 @@ xfs_attr_node_hasname( * * "Remote" attribute values confuse the issue and atomic rename operations * add a whole extra layer of confusion on top of that. + * + * This routine is meant to function as a delayed operation, and may return + * -EAGAIN when the transaction needs to be rolled. Calling functions will need + * to handle this, and recall the function until a successful error code is + *returned. */ STATIC int xfs_attr_node_addname( - struct xfs_da_args *args) + struct xfs_delattr_context *dac) { - struct xfs_da_state *state; - struct xfs_da_state_blk *blk; - struct xfs_inode *dp; - int retval, error; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state *state = NULL; + struct xfs_da_state_blk *blk; + int retval = 0; + int error = 0; trace_xfs_attr_node_addname(args); - /* - * Fill in bucket of arguments/results/context to carry around. - */ - dp = args->dp; -restart: + /* State machine switch */ + switch (dac->dela_state) { + case XFS_DAS_FLIP_NFLAG: + goto das_flip_flag; + case XFS_DAS_FOUND_NBLK: + goto das_found_nblk; + case XFS_DAS_ALLOC_NODE: + goto das_alloc_node; + case XFS_DAS_RM_NBLK: + goto das_rm_nblk; + default: + break; + } + /* * Search to see if name already exists, and get back a pointer * to where it should go. @@ -1019,19 +1125,13 @@ restart: error = xfs_attr3_leaf_to_node(args); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; /* - * Commit the node conversion and start the next - * trans in the chain. + * Restart routine from the top. No need to set the + * state */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - - goto restart; + dac->flags |= XFS_DAC_DEFER_FINISH; + return -EAGAIN; } /* @@ -1043,9 +1143,7 @@ restart: error = xfs_da3_split(state); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; + dac->flags |= XFS_DAC_DEFER_FINISH; } else { /* * Addition succeeded, update Btree hashvals. @@ -1060,13 +1158,9 @@ restart: xfs_da_state_free(state); state = NULL; - /* - * Commit the leaf addition or btree split and start the next - * trans in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; + dac->dela_state = XFS_DAS_FOUND_NBLK; + return -EAGAIN; +das_found_nblk: /* * If there was an out-of-line value, allocate the blocks we @@ -1075,7 +1169,27 @@ restart: * maximum size of a transaction and/or hit a deadlock. */ if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); + /* Open coded xfs_attr_rmtval_set without trans handling */ + error = xfs_attr_rmtval_find_space(dac); + if (error) + return error; + + /* + * Roll through the "value", allocating blocks on disk as + * required. + */ +das_alloc_node: + if (dac->blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(dac); + if (error) + return error; + + dac->flags |= XFS_DAC_DEFER_FINISH; + dac->dela_state = XFS_DAS_ALLOC_NODE; + return -EAGAIN; + } + + error = xfs_attr_rmtval_set_value(args); if (error) return error; } @@ -1105,22 +1219,28 @@ restart: /* * Commit the flag value change and start the next trans in series */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - goto out; - + dac->dela_state = XFS_DAS_FLIP_NFLAG; + return -EAGAIN; +das_flip_flag: /* * Dismantle the "old" attribute/value pair by removing a "remote" value * (if it exists). */ xfs_attr_restore_rmt_blk(args); + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + +das_rm_nblk: if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; + error = __xfs_attr_rmtval_remove(dac); + + if (error == -EAGAIN) { + dac->dela_state = XFS_DAS_RM_NBLK; + return -EAGAIN; + } - error = xfs_attr_rmtval_remove(args); if (error) return error; } diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 64dcf0f..501f9df 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -106,6 +106,118 @@ struct xfs_attr_list_context { * v │ * done <─────┘ * + * + * Below is a state machine diagram for attr set operations. + * + * xfs_attr_set_iter() + * │ + * v + * ┌───n── fork has + * │ only 1 blk? + * │ │ + * │ y + * │ │ + * │ v + * │ xfs_attr_leaf_try_add() + * │ │ + * │ v + * │ had enough + * ├───n────space? + * │ │ + * │ y + * │ │ + * │ v + * │ XFS_DAS_FOUND_LBLK ──┐ + * │ │ + * │ XFS_DAS_FLIP_LFLAG ──┤ + * │ (subroutine state) │ + * │ │ + * │ └─>xfs_attr_leaf_addname() + * │ │ + * │ v + * │ was this + * │ a rename? ──n─┐ + * │ │ │ + * │ y │ + * │ │ │ + * │ v │ + * │ flip incomplete │ + * │ flag │ + * │ │ │ + * │ v │ + * │ XFS_DAS_FLIP_LFLAG │ + * │ │ │ + * │ v │ + * │ remove │ + * │ XFS_DAS_RM_LBLK ─> old name │ + * │ ^ │ │ + * │ │ v │ + * │ └──────y── more to │ + * │ remove │ + * │ │ │ + * │ n │ + * │ │ │ + * │ v │ + * │ done <──────┘ + * └──> XFS_DAS_FOUND_NBLK ──┐ + * (subroutine state) │ + * │ + * XFS_DAS_ALLOC_NODE ──┤ + * (subroutine state) │ + * │ + * XFS_DAS_FLIP_NFLAG ──┤ + * (subroutine state) │ + * │ + * └─>xfs_attr_node_addname() + * │ + * v + * find space to store + * attr. Split if needed + * │ + * v + * XFS_DAS_FOUND_NBLK + * │ + * v + * ┌─────n── need to + * │ alloc blks? + * │ │ + * │ y + * │ │ + * │ v + * │ ┌─>XFS_DAS_ALLOC_NODE + * │ │ │ + * │ │ v + * │ └──y── need to alloc + * │ more blocks? + * │ │ + * │ n + * │ │ + * │ v + * │ was this + * └────────> a rename? ──n─┐ + * │ │ + * y │ + * │ │ + * v │ + * flip incomplete │ + * flag │ + * │ │ + * v │ + * XFS_DAS_FLIP_NFLAG │ + * │ │ + * v │ + * remove │ + * XFS_DAS_RM_NBLK ─> old name │ + * ^ │ │ + * │ v │ + * └──────y── more to │ + * remove │ + * │ │ + * n │ + * │ │ + * v │ + * done <──────┘ + * */ /* @@ -120,6 +232,13 @@ struct xfs_attr_list_context { enum xfs_delattr_state { XFS_DAS_UNINIT = 0, /* No state has been set yet */ XFS_DAS_RM_SHRINK, /* We are shrinking the tree */ + XFS_DAS_FOUND_LBLK, /* We found leaf blk for attr */ + XFS_DAS_FOUND_NBLK, /* We found node blk for attr */ + XFS_DAS_FLIP_LFLAG, /* Flipped leaf INCOMPLETE attr flag */ + XFS_DAS_RM_LBLK, /* A rename is removing leaf blocks */ + XFS_DAS_ALLOC_NODE, /* We are allocating node blocks */ + XFS_DAS_FLIP_NFLAG, /* Flipped node INCOMPLETE attr flag */ + XFS_DAS_RM_NBLK, /* A rename is removing node blocks */ }; /* @@ -127,6 +246,7 @@ enum xfs_delattr_state { */ #define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ #define XFS_DAC_NODE_RMVNAME_INIT 0x02 /* xfs_attr_node_removename init */ +#define XFS_DAC_LEAF_ADDNAME_INIT 0x04 /* xfs_attr_leaf_addname init*/ /* * Context used for keeping track of delayed attribute operations @@ -134,6 +254,11 @@ enum xfs_delattr_state { struct xfs_delattr_context { struct xfs_da_args *da_args; + /* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ + struct xfs_bmbt_irec map; + xfs_dablk_t lblkno; + int blkcnt; + /* Used in xfs_attr_node_removename to roll through removing blocks */ struct xfs_da_state *da_state; @@ -160,7 +285,6 @@ int xfs_attr_set_args(struct xfs_da_args *args); int xfs_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_remove_iter(struct xfs_delattr_context *dac); -int xfs_attr_trans_roll(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac, struct xfs_da_args *args); diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index ff53d09..e8221d9 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -442,7 +442,7 @@ xfs_attr_rmtval_get( * Find a "hole" in the attribute address space large enough for us to drop the * new attribute's value into */ -STATIC int +int xfs_attr_rmt_find_hole( struct xfs_da_args *args) { @@ -469,7 +469,7 @@ xfs_attr_rmt_find_hole( return 0; } -STATIC int +int xfs_attr_rmtval_set_value( struct xfs_da_args *args) { @@ -629,6 +629,69 @@ xfs_attr_rmtval_set( } /* + * Find a hole for the attr and store it in the delayed attr context. This + * initializes the context to roll through allocating an attr extent for a + * delayed attr operation + */ +int +xfs_attr_rmtval_find_space( + struct xfs_delattr_context *dac) +{ + struct xfs_da_args *args = dac->da_args; + struct xfs_bmbt_irec *map = &dac->map; + int error; + + dac->lblkno = 0; + dac->blkcnt = 0; + args->rmtblkcnt = 0; + args->rmtblkno = 0; + memset(map, 0, sizeof(struct xfs_bmbt_irec)); + + error = xfs_attr_rmt_find_hole(args); + if (error) + return error; + + dac->blkcnt = args->rmtblkcnt; + dac->lblkno = args->rmtblkno; + + return 0; +} + +/* + * Write one block of the value associated with an attribute into the + * out-of-line buffer that we have defined for it. This is similar to a subset + * of xfs_attr_rmtval_set, but records the current block to the delayed attr + * context, and leaves transaction handling to the caller. + */ +int +xfs_attr_rmtval_set_blk( + struct xfs_delattr_context *dac) +{ + struct xfs_da_args *args = dac->da_args; + struct xfs_inode *dp = args->dp; + struct xfs_bmbt_irec *map = &dac->map; + int nmap; + int error; + + nmap = 1; + error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)dac->lblkno, + dac->blkcnt, XFS_BMAPI_ATTRFORK, args->total, + map, &nmap); + if (error) + return error; + + ASSERT(nmap == 1); + ASSERT((map->br_startblock != DELAYSTARTBLOCK) && + (map->br_startblock != HOLESTARTBLOCK)); + + /* roll attribute extent map forwards */ + dac->lblkno += map->br_blockcount; + dac->blkcnt -= map->br_blockcount; + + return 0; +} + +/* * Remove the value associated with an attribute by deleting the * out-of-line buffer that it is stored on. */ @@ -670,37 +733,6 @@ xfs_attr_rmtval_invalidate( } /* - * Remove the value associated with an attribute by deleting the - * out-of-line buffer that it is stored on. - */ -int -xfs_attr_rmtval_remove( - struct xfs_da_args *args) -{ - int error; - struct xfs_delattr_context dac = { - .da_args = args, - }; - - trace_xfs_attr_rmtval_remove(args); - - /* - * Keep de-allocating extents until the remote-value region is gone. - */ - do { - error = __xfs_attr_rmtval_remove(&dac); - if (error != -EAGAIN) - break; - - error = xfs_attr_trans_roll(&dac); - if (error) - return error; - } while (true); - - return error; -} - -/* * Remove the value associated with an attribute by deleting the out-of-line * buffer that it is stored on. Returns EAGAIN for the caller to refresh the * transaction and re-call the function diff --git a/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index 002fd30..84e2700 100644 --- a/libxfs/xfs_attr_remote.h +++ b/libxfs/xfs_attr_remote.h @@ -15,4 +15,8 @@ int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map, xfs_buf_flags_t incore_flags); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); int __xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); +int xfs_attr_rmt_find_hole(struct xfs_da_args *args); +int xfs_attr_rmtval_set_value(struct xfs_da_args *args); +int xfs_attr_rmtval_set_blk(struct xfs_delattr_context *dac); +int xfs_attr_rmtval_find_space(struct xfs_delattr_context *dac); #endif /* __XFS_ATTR_REMOTE_H__ */ From patchwork Fri Oct 23 06:32:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852275 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1790414B7 for ; Fri, 23 Oct 2020 06:33:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E19ED22253 for ; Fri, 23 Oct 2020 06:33:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="GBvbn7lw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372801AbgJWGdV (ORCPT ); Fri, 23 Oct 2020 02:33:21 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:37772 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372794AbgJWGdV (ORCPT ); Fri, 23 Oct 2020 02:33:21 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6PgUB007908 for ; Fri, 23 Oct 2020 06:33:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=ewEZH27/H6DlCNeF1T35uLCSvIUuybdgdhBiWv9YSpU=; b=GBvbn7lwcZ5s9O6pPpJkYMXPmVandn2jr0Eag+sHL+sPdnZXgLP5kHr/1vua2aWr35eN 2hTp3+Pjl3PKoaEEDLqjkw9oeWj4ypJ10/zqR/m+eYM36czQeGsM60l2NjRbNmPSuDwu L8iuZmwJD1ZiVdyoNPIm/C7q+Bl2cQezlT6TYBtqVyDOB9mK7pcE/BKya1shpDaMsBLp +Sp5WiWIIldMJUQsPIXOUwo+PBNBqXHZtu7TbKexGS/7buwEzAN1jbCjFy6Xult9u5uS 2OuPQs2ebSeciE0KCbOxgcoAdpMtUUY8GY7qmGgCdU0KrtACjitLvnNc5YDQMbg9hAcw Kw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 347p4b9du7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:33:20 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6P6G0178426 for ; Fri, 23 Oct 2020 06:33:19 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 348aj0n97e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:19 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 09N6XIMJ008354 for ; Fri, 23 Oct 2020 06:33:18 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:18 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 06/14] xfsprogs: Rename __xfs_attr_rmtval_remove Date: Thu, 22 Oct 2020 23:32:58 -0700 Message-Id: <20201023063306.7441-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Collins Now that xfs_attr_rmtval_remove is gone, rename __xfs_attr_rmtval_remove to xfs_attr_rmtval_remove Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- libxfs/xfs_attr.c | 7 +++---- libxfs/xfs_attr_remote.c | 2 +- libxfs/xfs_attr_remote.h | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 1cd3ae3..0cee4b17 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -880,7 +880,7 @@ das_flip_flag: return error; das_rm_lblk: if (args->rmtblkno) { - error = __xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(dac); if (error == -EAGAIN) dac->dela_state = XFS_DAS_RM_LBLK; if (error) @@ -1234,8 +1234,7 @@ das_flip_flag: das_rm_nblk: if (args->rmtblkno) { - error = __xfs_attr_rmtval_remove(dac); - + error = xfs_attr_rmtval_remove(dac); if (error == -EAGAIN) { dac->dela_state = XFS_DAS_RM_NBLK; return -EAGAIN; @@ -1389,7 +1388,7 @@ xfs_attr_node_remove_rmt ( /* * May return -EAGAIN to request that the caller recall this function */ - error = __xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(dac); if (error) return error; diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index e8221d9..aa4aed8a 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -738,7 +738,7 @@ xfs_attr_rmtval_invalidate( * transaction and re-call the function */ int -__xfs_attr_rmtval_remove( +xfs_attr_rmtval_remove( struct xfs_delattr_context *dac) { struct xfs_da_args *args = dac->da_args; diff --git a/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index 84e2700..6ae91af 100644 --- a/libxfs/xfs_attr_remote.h +++ b/libxfs/xfs_attr_remote.h @@ -10,11 +10,10 @@ int xfs_attr3_rmt_blocks(struct xfs_mount *mp, int attrlen); int xfs_attr_rmtval_get(struct xfs_da_args *args); int xfs_attr_rmtval_set(struct xfs_da_args *args); -int xfs_attr_rmtval_remove(struct xfs_da_args *args); int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map, xfs_buf_flags_t incore_flags); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); -int __xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); +int xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); int xfs_attr_rmt_find_hole(struct xfs_da_args *args); int xfs_attr_rmtval_set_value(struct xfs_da_args *args); int xfs_attr_rmtval_set_blk(struct xfs_delattr_context *dac); From patchwork Fri Oct 23 06:32:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852285 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38D0061C for ; Fri, 23 Oct 2020 06:33:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 083E422460 for ; Fri, 23 Oct 2020 06:33:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="TkUkNNKf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372802AbgJWGdY (ORCPT ); Fri, 23 Oct 2020 02:33:24 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:37774 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372798AbgJWGdX (ORCPT ); Fri, 23 Oct 2020 02:33:23 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6PkDt007918 for ; Fri, 23 Oct 2020 06:33:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=UDtl0ParNPWzPnR894DAyF+vkDldffMz9fEDk1KZo1Y=; b=TkUkNNKfK+euAeAb1GYP2oEzgBPpda74idQS8dkKIutCax5jogQWrp4tntlum4BRNI/9 imItb96hDjY1pEiKWrtEoIZXD0ZiekE6BVs+Gg2fdvI7si1UygaSSOwTCJY8iO7pfyIv RgOAuMEKQQUuMbNJljL9TvrB5jwaKU4l1YBlXiSAjUwlrTr3qwv0bJ5Pb7RVyjPICpbH DBmXuQpQobw30kwZ71PUuPfCFtSmPmvnrlqHLQaygqwr72vCdUieCyiwTfyc+9um+QBs dypZhp86oSK9xKfszyrr5gxhe9lzlBikDBGV+R+kPFcuoxOb/SAyX3Ol3lQ7TVwvhhYu 8w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 347p4b9du8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:33:20 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6Q1hK123276 for ; Fri, 23 Oct 2020 06:33:19 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 34ak1aqy8w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:19 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 09N6XI0s009371 for ; Fri, 23 Oct 2020 06:33:18 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:18 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 07/14] xfsprogs: Set up infastructure for deferred attribute operations Date: Thu, 22 Oct 2020 23:32:59 -0700 Message-Id: <20201023063306.7441-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Collins Currently attributes are modified directly across one or more transactions. But they are not logged or replayed in the event of an error. The goal of delayed attributes is to enable logging and replaying of attribute operations using the existing delayed operations infrastructure. This will later enable the attributes to become part of larger multi part operations that also must first be recorded to the log. This is mostly of interest in the scheme of parent pointers which would need to maintain an attribute containing parent inode information any time an inode is moved, created, or removed. Parent pointers would then be of interest to any feature that would need to quickly derive an inode path from the mount point. Online scrub, nfs lookups and fs grow or shrink operations are all features that could take advantage of this. This patch adds two new log item types for setting or removing attributes as deferred operations. The xfs_attri_log_item logs an intent to set or remove an attribute. The corresponding xfs_attrd_log_item holds a reference to the xfs_attri_log_item and is freed once the transaction is done. Both log items use a generic xfs_attr_log_format structure that contains the attribute name, value, flags, inode, and an op_flag that indicates if the operations is a set or remove. Signed-off-by: Allison Henderson --- libxfs/defer_item.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/libxfs_priv.h | 1 + libxfs/xfs_attr.c | 7 ++- libxfs/xfs_attr.h | 19 +++++++ libxfs/xfs_defer.c | 1 + libxfs/xfs_defer.h | 2 + libxfs/xfs_format.h | 5 ++ libxfs/xfs_log_format.h | 43 +++++++++++++++- libxfs/xfs_types.h | 1 + 9 files changed, 205 insertions(+), 6 deletions(-) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index b18182e..ab21173 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -16,10 +16,14 @@ #include "xfs_trans.h" #include "xfs_bmap.h" #include "xfs_alloc.h" +#include "xfs_attr_item.h" #include "xfs_rmap.h" #include "xfs_refcount.h" #include "xfs_bmap.h" #include "xfs_inode.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_attr.h" /* Dummy defer item ops, since we don't do logging. */ @@ -112,6 +116,134 @@ const struct xfs_defer_op_type xfs_extent_free_defer_type = { .cancel_item = xfs_extent_free_cancel_item, }; +static inline struct xfs_attrd_log_item *ATTRD_ITEM(struct xfs_log_item *lip) +{ + return container_of(lip, struct xfs_attrd_log_item, attrd_item); +} + +/* + * Log an ATTRI it to the ATTRD when the attr op is done. An attr operation + * may be a set or a remove. Note that the transaction is marked dirty + * regardless of whether the operation succeeds or fails to support the + * ATTRI/ATTRD lifecycle rules. + */ +int +xfs_trans_attr( + struct xfs_delattr_context *dac, + struct xfs_attrd_log_item *attrdp, + struct xfs_buf **leaf_bp, + uint32_t op_flags) +{ + struct xfs_da_args *args = dac->da_args; + int error; + + error = xfs_qm_dqattach_locked(args->dp, 0); + if (error) + return error; + + switch (op_flags) { + case XFS_ATTR_OP_FLAGS_SET: + args->op_flags |= XFS_DA_OP_ADDNAME; + error = xfs_attr_set_iter(dac, leaf_bp); + break; + case XFS_ATTR_OP_FLAGS_REMOVE: + ASSERT(XFS_IFORK_Q((args->dp))); + error = xfs_attr_remove_iter(dac); + break; + default: + error = -EFSCORRUPTED; + break; + } + + /* + * Mark the transaction dirty, even on error. This ensures the + * transaction is aborted, which: + * + * 1.) releases the ATTRI and frees the ATTRD + * 2.) shuts down the filesystem + */ + args->trans->t_flags |= XFS_TRANS_DIRTY; + + return error; +} + +/* Get an ATTRI. */ +static struct xfs_log_item * +xfs_attr_create_intent( + struct xfs_trans *tp, + struct list_head *items, + unsigned int count, + bool sort) +{ + return NULL; +} + +/* Abort all pending ATTRs. */ +STATIC void +xfs_attr_abort_intent( + struct xfs_log_item *intent) +{ +} + +/* Get an ATTRD so we can process all the attrs. */ +static struct xfs_log_item * +xfs_attr_create_done( + struct xfs_trans *tp, + struct xfs_log_item *intent, + unsigned int count) +{ + return NULL; +} + +/* Process an attr. */ +STATIC int +xfs_attr_finish_item( + struct xfs_trans *tp, + struct xfs_log_item *done, + struct list_head *item, + struct xfs_btree_cur **state) +{ + struct xfs_attr_item *attr; + int error; + struct xfs_delattr_context *dac; + + attr = container_of(item, struct xfs_attr_item, xattri_list); + dac = &attr->xattri_dac; + + /* + * Always reset trans after EAGAIN cycle + * since the transaction is new + */ + dac->da_args->trans = tp; + + error = xfs_trans_attr(dac, ATTRD_ITEM(done), &dac->leaf_bp, + attr->xattri_op_flags); + if (error != -EAGAIN) + kmem_free(attr); + + return error; +} + +/* Cancel an attr */ +STATIC void +xfs_attr_cancel_item( + struct list_head *item) +{ + struct xfs_attr_item *attr; + + attr = container_of(item, struct xfs_attr_item, xattri_list); + kmem_free(attr); +} + +const struct xfs_defer_op_type xfs_attr_defer_type = { + .max_items = 1, + .create_intent = xfs_attr_create_intent, + .abort_intent = xfs_attr_abort_intent, + .create_done = xfs_attr_create_done, + .finish_item = xfs_attr_finish_item, + .cancel_item = xfs_attr_cancel_item, +}; + /* * AGFL blocks are accounted differently in the reserve pools and are not * inserted into the busy extent list. diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index bd724c3..130cef4 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -499,6 +499,7 @@ void __xfs_buf_mark_corrupt(struct xfs_buf *bp, xfs_failaddr_t fa); #define xfs_trans_reserve_quota_nblks(t,i,b,n,f) (0) #define xfs_trans_unreserve_quota_nblks(t,i,b,n,f) ((void) 0) #define xfs_qm_dqattach(i) (0) +#define xfs_qm_dqattach_locked(i,b) (0) #define uuid_copy(s,d) platform_uuid_copy((s),(d)) #define uuid_equal(s,d) (platform_uuid_compare((s),(d)) == 0) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 0cee4b17..ea054be 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -24,6 +24,7 @@ #include "xfs_quota_defs.h" #include "xfs_trans_space.h" #include "xfs_trace.h" +#include "xfs_attr_item.h" /* * xfs_attr.c @@ -59,8 +60,6 @@ STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); -STATIC int xfs_attr_set_iter(struct xfs_delattr_context *dac, - struct xfs_buf **leaf_bp); int xfs_inode_hasattr( @@ -142,7 +141,7 @@ xfs_attr_get( /* * Calculate how many blocks we need for the new attribute, */ -STATIC int +int xfs_attr_calc_size( struct xfs_da_args *args, int *local) @@ -327,7 +326,7 @@ xfs_attr_set_args( * to handle this, and recall the function until a successful error code is * returned. */ -STATIC int +int xfs_attr_set_iter( struct xfs_delattr_context *dac, struct xfs_buf **leaf_bp) diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 501f9df..5b4a1ca 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -247,6 +247,7 @@ enum xfs_delattr_state { #define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ #define XFS_DAC_NODE_RMVNAME_INIT 0x02 /* xfs_attr_node_removename init */ #define XFS_DAC_LEAF_ADDNAME_INIT 0x04 /* xfs_attr_leaf_addname init*/ +#define XFS_DAC_DELAYED_OP_INIT 0x08 /* delayed operations init*/ /* * Context used for keeping track of delayed attribute operations @@ -254,6 +255,9 @@ enum xfs_delattr_state { struct xfs_delattr_context { struct xfs_da_args *da_args; + /* Used by delayed attributes to hold leaf across transactions */ + struct xfs_buf *leaf_bp; + /* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ struct xfs_bmbt_irec map; xfs_dablk_t lblkno; @@ -267,6 +271,18 @@ struct xfs_delattr_context { enum xfs_delattr_state dela_state; }; +/* + * List of attrs to commit later. + */ +struct xfs_attr_item { + struct xfs_delattr_context xattri_dac; + uint32_t xattri_op_flags;/* attr op set or rm */ + + /* used to log this item to an intent */ + struct list_head xattri_list; +}; + + /*======================================================================== * Function prototypes for the kernel. *========================================================================*/ @@ -282,11 +298,14 @@ int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_args(struct xfs_da_args *args); +int xfs_attr_set_iter(struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp); int xfs_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_remove_iter(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac, struct xfs_da_args *args); +int xfs_attr_calc_size(struct xfs_da_args *args, int *local); #endif /* __XFS_ATTR_H__ */ diff --git a/libxfs/xfs_defer.c b/libxfs/xfs_defer.c index 34c1019..c6e45e2 100644 --- a/libxfs/xfs_defer.c +++ b/libxfs/xfs_defer.c @@ -174,6 +174,7 @@ static const struct xfs_defer_op_type *defer_op_types[] = { [XFS_DEFER_OPS_TYPE_RMAP] = &xfs_rmap_update_defer_type, [XFS_DEFER_OPS_TYPE_FREE] = &xfs_extent_free_defer_type, [XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type, + [XFS_DEFER_OPS_TYPE_ATTR] = &xfs_attr_defer_type, }; static void diff --git a/libxfs/xfs_defer.h b/libxfs/xfs_defer.h index 6b2ca58..ed65927 100644 --- a/libxfs/xfs_defer.h +++ b/libxfs/xfs_defer.h @@ -18,6 +18,7 @@ enum xfs_defer_ops_type { XFS_DEFER_OPS_TYPE_RMAP, XFS_DEFER_OPS_TYPE_FREE, XFS_DEFER_OPS_TYPE_AGFL_FREE, + XFS_DEFER_OPS_TYPE_ATTR, XFS_DEFER_OPS_TYPE_MAX, }; @@ -62,5 +63,6 @@ extern const struct xfs_defer_op_type xfs_refcount_update_defer_type; extern const struct xfs_defer_op_type xfs_rmap_update_defer_type; extern const struct xfs_defer_op_type xfs_extent_free_defer_type; extern const struct xfs_defer_op_type xfs_agfl_free_defer_type; +extern const struct xfs_defer_op_type xfs_attr_defer_type; #endif /* __XFS_DEFER_H__ */ diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 5a183b6..11e9fc5 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -565,6 +565,11 @@ 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_hasdelattr(struct xfs_sb *sbp) +{ + return false; +} + /* * Inode btree block counter. We record the number of inobt and finobt blocks * in the AGI header so that we can skip the finobt walk at mount time when diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index e3400c9..6c5bf51 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -117,7 +117,11 @@ struct xfs_unmount_log_format { #define XLOG_REG_TYPE_CUD_FORMAT 24 #define XLOG_REG_TYPE_BUI_FORMAT 25 #define XLOG_REG_TYPE_BUD_FORMAT 26 -#define XLOG_REG_TYPE_MAX 26 +#define XLOG_REG_TYPE_ATTRI_FORMAT 27 +#define XLOG_REG_TYPE_ATTRD_FORMAT 28 +#define XLOG_REG_TYPE_ATTR_NAME 29 +#define XLOG_REG_TYPE_ATTR_VALUE 30 +#define XLOG_REG_TYPE_MAX 30 /* * Flags to log operation header @@ -240,6 +244,8 @@ typedef struct xfs_trans_header { #define XFS_LI_CUD 0x1243 #define XFS_LI_BUI 0x1244 /* bmbt update intent */ #define XFS_LI_BUD 0x1245 +#define XFS_LI_ATTRI 0x1246 /* attr set/remove intent*/ +#define XFS_LI_ATTRD 0x1247 /* attr set/remove done */ #define XFS_LI_TYPE_DESC \ { XFS_LI_EFI, "XFS_LI_EFI" }, \ @@ -255,7 +261,9 @@ typedef struct xfs_trans_header { { XFS_LI_CUI, "XFS_LI_CUI" }, \ { XFS_LI_CUD, "XFS_LI_CUD" }, \ { XFS_LI_BUI, "XFS_LI_BUI" }, \ - { XFS_LI_BUD, "XFS_LI_BUD" } + { XFS_LI_BUD, "XFS_LI_BUD" }, \ + { XFS_LI_ATTRI, "XFS_LI_ATTRI" }, \ + { XFS_LI_ATTRD, "XFS_LI_ATTRD" } /* * Inode Log Item Format definitions. @@ -860,4 +868,35 @@ struct xfs_icreate_log { __be32 icl_gen; /* inode generation number to use */ }; +/* + * Flags for deferred attribute operations. + * Upper bits are flags, lower byte is type code + */ +#define XFS_ATTR_OP_FLAGS_SET 1 /* Set the attribute */ +#define XFS_ATTR_OP_FLAGS_REMOVE 2 /* Remove the attribute */ +#define XFS_ATTR_OP_FLAGS_TYPE_MASK 0x0FF /* Flags type mask */ + +/* + * This is the structure used to lay out an attr log item in the + * log. + */ +struct xfs_attri_log_format { + uint16_t alfi_type; /* attri log item type */ + uint16_t alfi_size; /* size of this item */ + uint32_t __pad; /* pad to 64 bit aligned */ + uint64_t alfi_id; /* attri identifier */ + xfs_ino_t alfi_ino; /* the inode for this attr operation */ + uint32_t alfi_op_flags; /* marks the op as a set or remove */ + uint32_t alfi_name_len; /* attr name length */ + uint32_t alfi_value_len; /* attr value length */ + uint32_t alfi_attr_flags;/* attr flags */ +}; + +struct xfs_attrd_log_format { + uint16_t alfd_type; /* attrd log item type */ + uint16_t alfd_size; /* size of this item */ + uint32_t __pad; /* pad to 64 bit aligned */ + uint64_t alfd_alf_id; /* id of corresponding attrd */ +}; + #endif /* __XFS_LOG_FORMAT_H__ */ diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index 397d947..860cdd2 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -11,6 +11,7 @@ typedef uint32_t prid_t; /* project ID */ typedef uint32_t xfs_agblock_t; /* blockno in alloc. group */ typedef uint32_t xfs_agino_t; /* inode # within allocation grp */ typedef uint32_t xfs_extlen_t; /* extent length in blocks */ +typedef uint32_t xfs_attrlen_t; /* attr length */ typedef uint32_t xfs_agnumber_t; /* allocation group number */ typedef int32_t xfs_extnum_t; /* # of extents in a file */ typedef int16_t xfs_aextnum_t; /* # extents in an attribute fork */ From patchwork Fri Oct 23 06:33:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852279 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E82A14B7 for ; Fri, 23 Oct 2020 06:33:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A2D422254 for ; Fri, 23 Oct 2020 06:33:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="RvTKvjKh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372805AbgJWGdW (ORCPT ); Fri, 23 Oct 2020 02:33:22 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:43582 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372792AbgJWGdW (ORCPT ); Fri, 23 Oct 2020 02:33:22 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6P5jv025591 for ; Fri, 23 Oct 2020 06:33:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=0ebdhy2MjzR3u6cGrinf/oeA8AjqZkawilBvvJR0iYs=; b=RvTKvjKhQapz/izr0E5Cb4GuT0imdsoYAqESOS+MlxM0qd9de1wNuNAK6jnjZ9wLMjL5 3KEAFJfXHX6SnFclTEzon28d8dWYs2TZF3E2XoI7nZZQOKrY7EHqRc90Agqidj6c9ThT IDaX4KMWWgSyyj+CS6Fs54k6Z2UD4KMlJrlFLeoAWbrZ6JuTPJnreKDmnj6eTNB8z2lR RIUbBIyzJLcqiNPd3sqyqECbt1Pyq5YFnj/6q/MQnbRvrpT6kM+a7vBcII3sc+FleCm/ 6h/TzncmwaQBHHhjKfdyrKUijs0gVNdXu7HxOPbTbOwH9HbzYBWUhmdY0pE9EEKb4wQQ Ow== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 34ak16sngk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:33:20 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6QD9r100632 for ; Fri, 23 Oct 2020 06:33:20 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 348a6re9kr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:20 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 09N6XInV012222 for ; Fri, 23 Oct 2020 06:33:19 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:18 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 08/14] xfsprogs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Date: Thu, 22 Oct 2020 23:33:00 -0700 Message-Id: <20201023063306.7441-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 suspectscore=1 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 mlxlogscore=999 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Collins These routines to set up and start a new deferred attribute operations. These functions are meant to be called by any routine needing to initiate a deferred attribute operation as opposed to the existing inline operations. New helper function xfs_attr_item_init also added. Signed-off-by: Allison Henderson --- libxfs/xfs_attr.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/xfs_attr.h | 2 ++ 2 files changed, 55 insertions(+) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index ea054be..775f16e 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -643,6 +643,59 @@ out_trans_cancel: goto out_unlock; } +STATIC int +xfs_attr_item_init( + struct xfs_da_args *args, + unsigned int op_flags, /* op flag (set or remove) */ + struct xfs_attr_item **attr) /* new xfs_attr_item */ +{ + + struct xfs_attr_item *new; + + new = kmem_alloc_large(sizeof(struct xfs_attr_item), KM_NOFS); + memset(new, 0, sizeof(struct xfs_attr_item)); + new->xattri_op_flags = op_flags; + new->xattri_dac.da_args = args; + + *attr = new; + return 0; +} + +/* Sets an attribute for an inode as a deferred operation */ +int +xfs_attr_set_deferred( + struct xfs_da_args *args) +{ + struct xfs_attr_item *new; + int error = 0; + + error = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_SET, &new); + if (error) + return error; + + xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + +/* Removes an attribute for an inode as a deferred operation */ +int +xfs_attr_remove_deferred( + struct xfs_da_args *args) +{ + + struct xfs_attr_item *new; + int error; + + error = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_REMOVE, &new); + if (error) + return error; + + xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + /*======================================================================== * External routines when attribute list is inside the inode *========================================================================*/ diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 5b4a1ca..8a08411 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -307,5 +307,7 @@ bool xfs_attr_namecheck(const void *name, size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac, struct xfs_da_args *args); int xfs_attr_calc_size(struct xfs_da_args *args, int *local); +int xfs_attr_set_deferred(struct xfs_da_args *args); +int xfs_attr_remove_deferred(struct xfs_da_args *args); #endif /* __XFS_ATTR_H__ */ From patchwork Fri Oct 23 06:33:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852273 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8303D61C for ; Fri, 23 Oct 2020 06:33:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5829622253 for ; Fri, 23 Oct 2020 06:33:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="dL9hvPnk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372800AbgJWGdU (ORCPT ); Fri, 23 Oct 2020 02:33:20 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:37768 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372792AbgJWGdU (ORCPT ); Fri, 23 Oct 2020 02:33:20 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6P087007778 for ; Fri, 23 Oct 2020 06:33:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=Jbyq1PwcSN1lNmFKszXwqvgdYN3W8hSXzyb5AafwRDA=; b=dL9hvPnkXPxHFzRxfEZ1hCxehjUbe10poqGymTCcPBNQsNOxZYqKbwOrUE/DLR1gTDSs tDepTxoU4EHCir3G3XMcO3ZZrTFJznGa0hL/s24+AOSWyV/1seACYYUkr+VlVHMYaLEg E1HPrEagjb0rJZEBI1kxz/DxIbiMJMB5hfcKRL0CDUSiYB05hrm/hFDa+6zGcm0SLuq8 6XPF1AEAbby0q2MqPqII3780/MLTit5PwZTAmD3qp/wiMT6hAXZmdlLVJx+qB8sl28Bm FCYzpDDOiYjJpC9XWlLhOMu89JKxG5tpsI4bW0OliT31zg0XGZ6IBLmown9rM9txGvbw zw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 347p4b9dua-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:33:19 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6QAaA100450 for ; Fri, 23 Oct 2020 06:33:19 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 348a6re9kn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:19 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 09N6XJ0O027437 for ; Fri, 23 Oct 2020 06:33:19 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:18 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 09/14] xfsprogs: Add feature bit XFS_SB_FEAT_INCOMPAT_LOG_DELATTR Date: Thu, 22 Oct 2020 23:33:01 -0700 Message-Id: <20201023063306.7441-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 suspectscore=1 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds a new feature bit XFS_SB_FEAT_INCOMPAT_LOG_DELATTR which can be used to control turning on/off delayed attributes Signed-off-by: Allison Henderson --- libxfs/xfs_format.h | 8 ++++++-- libxfs/xfs_fs.h | 1 + libxfs/xfs_sb.c | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 11e9fc5..93f1a82 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -481,7 +481,9 @@ xfs_sb_has_incompat_feature( return (sbp->sb_features_incompat & feature) != 0; } -#define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0 +#define XFS_SB_FEAT_INCOMPAT_LOG_DELATTR (1 << 0) /* Delayed Attributes */ +#define XFS_SB_FEAT_INCOMPAT_LOG_ALL \ + (XFS_SB_FEAT_INCOMPAT_LOG_DELATTR) #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL static inline bool xfs_sb_has_incompat_log_feature( @@ -567,7 +569,9 @@ static inline bool xfs_sb_version_hasreflink(struct xfs_sb *sbp) static inline bool xfs_sb_version_hasdelattr(struct xfs_sb *sbp) { - return false; + return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && + (sbp->sb_features_log_incompat & + XFS_SB_FEAT_INCOMPAT_LOG_DELATTR)); } /* diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index 84bcffa..78e8740 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -249,6 +249,7 @@ typedef struct xfs_fsop_resblks { #define XFS_FSOP_GEOM_FLAGS_SPINODES (1 << 18) /* sparse inode chunks */ #define XFS_FSOP_GEOM_FLAGS_RMAPBT (1 << 19) /* reverse mapping btree */ #define XFS_FSOP_GEOM_FLAGS_REFLINK (1 << 20) /* files can share blocks */ +#define XFS_FSOP_GEOM_FLAGS_DELATTR (1 << 22) /* delayed attributes */ /* * Minimum and maximum sizes need for growth checks. diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 302eea1..f9409b5 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -1143,6 +1143,8 @@ xfs_fs_geometry( geo->flags |= XFS_FSOP_GEOM_FLAGS_RMAPBT; if (xfs_sb_version_hasreflink(sbp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_REFLINK; + if (xfs_sb_version_hasdelattr(sbp)) + geo->flags |= XFS_FSOP_GEOM_FLAGS_DELATTR; if (xfs_sb_version_hassector(sbp)) geo->logsectsize = sbp->sb_logsectsize; else From patchwork Fri Oct 23 06:33:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852277 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA0C814B2 for ; Fri, 23 Oct 2020 06:33:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88538223C7 for ; Fri, 23 Oct 2020 06:33:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="vHmhY/7M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372794AbgJWGdW (ORCPT ); Fri, 23 Oct 2020 02:33:22 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:43578 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372799AbgJWGdV (ORCPT ); Fri, 23 Oct 2020 02:33:21 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6OrNf025553 for ; Fri, 23 Oct 2020 06:33:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=oBx1M40JwgsZ9yNKcP4j3Ra5FqC14HT/RNoivCaIink=; b=vHmhY/7Mvz23IC1/RJo9pwo+mTh1ur92ec317kTT4iwKMNldZGTLyZks+N+6RDMhk/u9 DR5wo0JYWwmGNmSN6NVXgCaoqDL4LoCmyR6rwo69gWhERLV1Hjm/nf4vXmitiNc+A0tW yIcDl7rCabfYTgLeO8wlmM7H04ZdQdOoXj+WLAJ7XODqzxK0wtuc8/oX1PR7w0Em37mr 4yWjt/ZNWER9lKONWHQsFEZm/zZy6d4M7jHw96BVuCnBBTEO58rJEV4bL5+E7QM7zWNf aI46bTg56Lp9ex5EGfFcoEIva1Y5suEEjQkJIYVwHCt+R8cq/LkS1RqjdQNonKT3PaZr Kg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 34ak16sngh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:33:20 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6Q1hL123276 for ; Fri, 23 Oct 2020 06:33:20 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 34ak1aqy99-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:20 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 09N6XJi2009395 for ; Fri, 23 Oct 2020 06:33:19 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:19 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 10/14] xfsprogs: Enable delayed attributes Date: Thu, 22 Oct 2020 23:33:02 -0700 Message-Id: <20201023063306.7441-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 mlxlogscore=999 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Collins Finally enable delayed attributes in xfs_attr_set and xfs_attr_remove. Signed-off-by: Allison Henderson --- libxfs/xfs_attr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 775f16e..6267669 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -602,9 +602,10 @@ xfs_attr_set( if (error != -ENOATTR && error != -EEXIST) goto out_trans_cancel; - error = xfs_attr_set_args(args); + error = xfs_attr_set_deferred(args); if (error) goto out_trans_cancel; + /* shortform attribute has already been committed */ if (!args->trans) goto out_unlock; @@ -613,7 +614,7 @@ xfs_attr_set( if (error != -EEXIST) goto out_trans_cancel; - error = xfs_attr_remove_args(args); + error = xfs_attr_remove_deferred(args); if (error) goto out_trans_cancel; } From patchwork Fri Oct 23 06:33:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852313 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9605861C for ; Fri, 23 Oct 2020 06:35:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 724EA22253 for ; Fri, 23 Oct 2020 06:35:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="UIjHK3Nn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S375338AbgJWGfW (ORCPT ); Fri, 23 Oct 2020 02:35:22 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45180 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372848AbgJWGfV (ORCPT ); Fri, 23 Oct 2020 02:35:21 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6PHhY025926 for ; Fri, 23 Oct 2020 06:35:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=pG5l8DUz+HYlN1k7Goytm+5fB8gz5YLjZYwBvC94SoE=; b=UIjHK3Nny9F5P3TzrlkyiM7ysKpOgt+So+ou+a6Rw4qmdb//kPa5n0PCoPODJccYVple gaqxvPUfFrMk5AKQQ90FC3Yf/Cyph2orQ+rfGAM35MrFnxhVhENk3lvCcg4MLt/LfuGj CFSMukU3Dzo494sazwSReRqpb2hSUEHONJyfTw/5bdTUDQfmWuKMo4KEReW+wXEWhbVA 3cEAIsOi8t+H8dO6rcS6A6LzdcSEP673FuFf3qmejGvAi4uw3PhhAf20TjbPrxPXWH45 X9EnkzYtskQlwpgeVczc9Y4FF1PHEWYkedpT7bG1ooZNtWTLDMRmggk9yWZ/83m/RnOA xg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 34ak16snpy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:35:20 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6Q16L123287 for ; Fri, 23 Oct 2020 06:33:20 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 34ak1aqy9c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:20 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 09N6XJ3f012225 for ; Fri, 23 Oct 2020 06:33:19 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:19 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 11/14] xfsprogs: Remove unused xfs_attr_*_args Date: Thu, 22 Oct 2020 23:33:03 -0700 Message-Id: <20201023063306.7441-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 mlxlogscore=999 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Remove xfs_attr_set_args, xfs_attr_remove_args, and xfs_attr_trans_roll. These high level loops are now driven by the delayed operations code, and can be removed. Signed-off-by: Allison Henderson --- libxfs/xfs_attr.c | 97 +------------------------------------------------------ libxfs/xfs_attr.h | 2 -- 2 files changed, 1 insertion(+), 98 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 6267669..248e89e 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -261,65 +261,6 @@ xfs_attr_set_shortform( } /* - * Checks to see if a delayed attribute transaction should be rolled. If so, - * also checks for a defer finish. Transaction is finished and rolled as - * needed, and returns true of false if the delayed operation should continue. - */ -STATIC int -xfs_attr_trans_roll( - struct xfs_delattr_context *dac) -{ - struct xfs_da_args *args = dac->da_args; - int error = 0; - - if (dac->flags & XFS_DAC_DEFER_FINISH) { - /* - * The caller wants us to finish all the deferred ops so that we - * avoid pinning the log tail with a large number of deferred - * ops. - */ - dac->flags &= ~XFS_DAC_DEFER_FINISH; - error = xfs_defer_finish(&args->trans); - if (error) - return error; - } - - return xfs_trans_roll_inode(&args->trans, args->dp); -} - -/* - * Set the attribute specified in @args. - */ -int -xfs_attr_set_args( - struct xfs_da_args *args) -{ - struct xfs_buf *leaf_bp = NULL; - int error = 0; - struct xfs_delattr_context dac = { - .da_args = args, - }; - - do { - error = xfs_attr_set_iter(&dac, &leaf_bp); - if (error != -EAGAIN) - break; - - error = xfs_attr_trans_roll(&dac); - if (error) - return error; - - if (leaf_bp) { - xfs_trans_bjoin(args->trans, leaf_bp); - xfs_trans_bhold(args->trans, leaf_bp); - } - - } while (true); - - return error; -} - -/* * Set the attribute specified in @args. * This routine is meant to function as a delayed operation, and may return * -EAGAIN when the transaction needs to be rolled. Calling functions will need @@ -362,11 +303,7 @@ xfs_attr_set_iter( * continue. Otherwise, is it converted from shortform to leaf * and -EAGAIN is returned. */ - error = xfs_attr_set_shortform(args, leaf_bp); - if (error == -EAGAIN) - dac->flags |= XFS_DAC_DEFER_FINISH; - - return error; + return xfs_attr_set_shortform(args, leaf_bp); } /* @@ -397,7 +334,6 @@ xfs_attr_set_iter( * same state (inode locked and joined, transaction * clean) no matter how we got to this step. */ - dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; case 0: dac->dela_state = XFS_DAS_FOUND_LBLK; @@ -454,32 +390,6 @@ xfs_has_attr( /* * Remove the attribute specified in @args. - */ -int -xfs_attr_remove_args( - struct xfs_da_args *args) -{ - int error = 0; - struct xfs_delattr_context dac = { - .da_args = args, - }; - - do { - error = xfs_attr_remove_iter(&dac); - if (error != -EAGAIN) - break; - - error = xfs_attr_trans_roll(&dac); - if (error) - return error; - - } while (true); - - return error; -} - -/* - * Remove the attribute specified in @args. * * This function may return -EAGAIN to signal that the transaction needs to be * rolled. Callers should continue calling this function until they receive a @@ -886,7 +796,6 @@ xfs_attr_leaf_addname( if (error) return error; - dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; } @@ -1183,7 +1092,6 @@ xfs_attr_node_addname( * Restart routine from the top. No need to set the * state */ - dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; } @@ -1196,7 +1104,6 @@ xfs_attr_node_addname( error = xfs_da3_split(state); if (error) goto out; - dac->flags |= XFS_DAC_DEFER_FINISH; } else { /* * Addition succeeded, update Btree hashvals. @@ -1237,7 +1144,6 @@ das_alloc_node: if (error) return error; - dac->flags |= XFS_DAC_DEFER_FINISH; dac->dela_state = XFS_DAS_ALLOC_NODE; return -EAGAIN; } @@ -1505,7 +1411,6 @@ xfs_attr_node_remove_step( if (retval && (state->path.active > 1)) { error = xfs_da3_join(state); if (error) - dac->flags |= XFS_DAC_DEFER_FINISH; dac->dela_state = XFS_DAS_RM_SHRINK; return -EAGAIN; } diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 8a08411..58f9660 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -297,11 +297,9 @@ int xfs_inode_hasattr(struct xfs_inode *ip); int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); -int xfs_attr_set_args(struct xfs_da_args *args); int xfs_attr_set_iter(struct xfs_delattr_context *dac, struct xfs_buf **leaf_bp); int xfs_has_attr(struct xfs_da_args *args); -int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_remove_iter(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac, From patchwork Fri Oct 23 06:33:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852315 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F08961C for ; Fri, 23 Oct 2020 06:35:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C9CB22253 for ; Fri, 23 Oct 2020 06:35:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="WKQdOfPj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372848AbgJWGfW (ORCPT ); Fri, 23 Oct 2020 02:35:22 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43132 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372883AbgJWGfW (ORCPT ); Fri, 23 Oct 2020 02:35:22 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6OxKu106679 for ; Fri, 23 Oct 2020 06:35:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=Dg2xhcSa8tPr7z9EVSEGJFj6h0oRIxwpJP9tJIRcO0o=; b=WKQdOfPjnzbe1XptFRbizfk0jaRzl2ExH9vnREQlsP/ss2YVKLvomq+rRTmVUJYoSR6r RdT/Jv0tVnfCa1bTTEtylPs7VXJs5cqDY/PumYq12BXj3ju6d7RbFMz1PMJ4/Be1uUkC 2Uc4lDltC9Kx5ymT2rN6b1GR+EeXcto2huW3Bha2t7fcsvSLy3oeUek/2Ci6mhaVoLEN 6vjNXcBH7w2Ic2F7dNLsZm5Vvr0Z1xMzcrH6h9cGYTG3KJ6biDvmEPdXJxyPHEzql5SV NaECbiX2gIHrCZvxrfFSbDsFr3HBAk8qwLwCIq2BgJjZ5IPnROWJ8HR4DoYur+OTDm+8 cA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 349jrq1ew4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:35:21 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6Pjbe112532 for ; Fri, 23 Oct 2020 06:33:21 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 348ah1p30s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:21 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 09N6XJCe012228 for ; Fri, 23 Oct 2020 06:33:20 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:19 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 12/14] xfs_io: Add delayed attributes error tag Date: Thu, 22 Oct 2020 23:33:04 -0700 Message-Id: <20201023063306.7441-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Collins This patch adds an error tag that we can use to test delayed attribute recovery and replay Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong --- io/inject.c | 1 + libxfs/xfs_errortag.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/io/inject.c b/io/inject.c index 352d27c..9124c41 100644 --- a/io/inject.c +++ b/io/inject.c @@ -55,6 +55,7 @@ error_tag(char *name) { XFS_ERRTAG_FORCE_SUMMARY_RECALC, "bad_summary" }, { XFS_ERRTAG_IUNLINK_FALLBACK, "iunlink_fallback" }, { XFS_ERRTAG_BUF_IOERROR, "buf_ioerror" }, + { XFS_ERRTAG_DELAYED_ATTR, "delayed_attr" }, { XFS_ERRTAG_MAX, NULL } }; int count; diff --git a/libxfs/xfs_errortag.h b/libxfs/xfs_errortag.h index 53b305d..cb38cbf 100644 --- a/libxfs/xfs_errortag.h +++ b/libxfs/xfs_errortag.h @@ -56,7 +56,8 @@ #define XFS_ERRTAG_FORCE_SUMMARY_RECALC 33 #define XFS_ERRTAG_IUNLINK_FALLBACK 34 #define XFS_ERRTAG_BUF_IOERROR 35 -#define XFS_ERRTAG_MAX 36 +#define XFS_ERRTAG_DELAYED_ATTR 36 +#define XFS_ERRTAG_MAX 37 /* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. @@ -97,5 +98,6 @@ #define XFS_RANDOM_FORCE_SUMMARY_RECALC 1 #define XFS_RANDOM_IUNLINK_FALLBACK (XFS_RANDOM_DEFAULT/10) #define XFS_RANDOM_BUF_IOERROR XFS_RANDOM_DEFAULT +#define XFS_RANDOM_DELAYED_ATTR 1 #endif /* __XFS_ERRORTAG_H_ */ From patchwork Fri Oct 23 06:33:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852287 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B1D514B2 for ; Fri, 23 Oct 2020 06:33:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D73E22460 for ; Fri, 23 Oct 2020 06:33:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="hckSVRKy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372798AbgJWGdY (ORCPT ); Fri, 23 Oct 2020 02:33:24 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:41452 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372799AbgJWGdX (ORCPT ); Fri, 23 Oct 2020 02:33:23 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6OlBx106652 for ; Fri, 23 Oct 2020 06:33:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=631qSXA5EEvPVYC09X3zaehxcuP5wu493Ba2AIamE4w=; b=hckSVRKyloty2nXPnCMWvKXzTIb4a59iYijfjnOCOIqLY3IVZqumbLP5YCwDEscbZYaE wGeGKZyUVagt6yaB8maLhnoP/hq3pCzaUpH5Qvg5ABlatXsd6/TGBNoClqSCm/B4icoB SxnRzI59TtuE1MwtjhLerBxCp3hR29twdyFVYHucCquS76ug9L/worV9/fV7WCJqkUnH CS66PIw7CdF3Cn+OcbEE9B/EM1rT0XoZmCLQDljtPXrnLJGf9AWayPBxU0oyxBgf/IfP ErhzojJg6Nox9RiPVbninculpwUu4N4zt5ICZoiwaOc2v1cv0GwZ4qHvfYM065uDIrbm bw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 349jrq1eq8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:33:21 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6PllG112757 for ; Fri, 23 Oct 2020 06:33:21 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 348ah1p30t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:21 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 09N6XKrl009398 for ; Fri, 23 Oct 2020 06:33:20 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:20 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 13/14] [RFC] xfsprogs: Add log item printing for ATTRI and ATTRD Date: Thu, 22 Oct 2020 23:33:05 -0700 Message-Id: <20201023063306.7441-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=3 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=3 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch implements a new set of log printing functions to print the ATTRI and ATTRD items and vectors in the log. These will be used during log dump and log recover operations. RFC: Though most attributes are strings, the attribute operations accept any binary payload, so we cannot assume them printable. This was done intentionally in preparation for parent pointers. And until parent pointers get here, attributes have no discernible format. So the print routines are just a simple hex dump for now. It's not pretty, but works for now. Signed-off-by: Allison Henderson --- logprint/log_misc.c | 31 +++++++- logprint/log_print_all.c | 12 +++ logprint/log_redo.c | 197 +++++++++++++++++++++++++++++++++++++++++++++++ logprint/logprint.h | 10 +++ 4 files changed, 249 insertions(+), 1 deletion(-) diff --git a/logprint/log_misc.c b/logprint/log_misc.c index af927cb..900a75d 100644 --- a/logprint/log_misc.c +++ b/logprint/log_misc.c @@ -54,11 +54,29 @@ print_stars(void) "***********************************\n"); } /* print_stars */ +void +print_hex_dump(char *ptr, int len) { + int i = 0; + + for (i = 0; i < len; i++) { + if (i % 16 == 0) + printf("%08x ", i); + + printf("%02x", ptr[i]); + + if ((i+1)%16 == 0) + printf("\n"); + else if ((i+1)%2 == 0) + printf(" "); + } + printf("\n"); +} + /* * Given a pointer to a data segment, print out the data as if it were * a log operation header. */ -static void +void xlog_print_op_header(xlog_op_header_t *op_head, int i, char **ptr) @@ -949,6 +967,17 @@ xlog_print_record( be32_to_cpu(op_head->oh_len)); break; } + case XFS_LI_ATTRI: { + skip = xlog_print_trans_attri(&ptr, + be32_to_cpu(op_head->oh_len), + &i); + break; + } + case XFS_LI_ATTRD: { + skip = xlog_print_trans_attrd(&ptr, + be32_to_cpu(op_head->oh_len)); + break; + } case XFS_LI_RUI: { skip = xlog_print_trans_rui(&ptr, be32_to_cpu(op_head->oh_len), diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c index 1924a0a..2b3f035 100644 --- a/logprint/log_print_all.c +++ b/logprint/log_print_all.c @@ -402,6 +402,12 @@ xlog_recover_print_logitem( case XFS_LI_EFI: xlog_recover_print_efi(item); break; + case XFS_LI_ATTRD: + xlog_recover_print_attrd(item); + break; + case XFS_LI_ATTRI: + xlog_recover_print_attri(item); + break; case XFS_LI_RUD: xlog_recover_print_rud(item); break; @@ -454,6 +460,12 @@ xlog_recover_print_item( case XFS_LI_EFI: printf("EFI"); break; + case XFS_LI_ATTRD: + printf("ATTRD"); + break; + case XFS_LI_ATTRI: + printf("ATTRI"); + break; case XFS_LI_RUD: printf("RUD"); break; diff --git a/logprint/log_redo.c b/logprint/log_redo.c index 297e203..3e790e2 100644 --- a/logprint/log_redo.c +++ b/logprint/log_redo.c @@ -8,6 +8,7 @@ #include "libxlog.h" #include "logprint.h" +#include "xfs_attr_item.h" /* Extent Free Items */ @@ -653,3 +654,199 @@ xlog_recover_print_bud( f = item->ri_buf[0].i_addr; xlog_print_trans_bud(&f, sizeof(struct xfs_bud_log_format)); } + +/* Attr Items */ + +static int +xfs_attri_copy_log_format( + char *buf, + uint len, + struct xfs_attri_log_format *dst_attri_fmt) +{ + uint dst_len = sizeof(struct xfs_attri_log_format); + + if (len == dst_len) { + memcpy((char *)dst_attri_fmt, buf, len); + return 0; + } + + fprintf(stderr, _("%s: bad size of attri format: %u; expected %u\n"), + progname, len, dst_len); + return 1; +} + +int +xlog_print_trans_attri( + char **ptr, + uint src_len, + int *i) +{ + struct xfs_attri_log_format *src_f = NULL; + xlog_op_header_t *head = NULL; + uint dst_len; + int error = 0; + + dst_len = sizeof(struct xfs_attri_log_format); + if (src_len != dst_len) { + fprintf(stderr, _("%s: bad size of attri format: %u; expected %u\n"), + progname, src_len, dst_len); + return 1; + } + + /* + * memmove to ensure 8-byte alignment for the long longs in + * xfs_attri_log_format_t structure + */ + if ((src_f = (struct xfs_attri_log_format *)malloc(src_len)) == NULL) { + fprintf(stderr, _("%s: xlog_print_trans_attri: malloc failed\n"), + progname); + exit(1); + } + memmove((char*)src_f, *ptr, src_len); + *ptr += src_len; + + printf(_("ATTRI: #regs: %d name_len: %d, value_len: %d id: 0x%llx\n"), + src_f->alfi_size, src_f->alfi_name_len, src_f->alfi_value_len, + (unsigned long long)src_f->alfi_id); + + if (src_f->alfi_name_len > 0) { + printf(_("\n")); + (*i)++; + head = (xlog_op_header_t *)*ptr; + xlog_print_op_header(head, *i, ptr); + error = xlog_print_trans_attri_name(ptr, be32_to_cpu(head->oh_len)); + if (error) + goto error; + } + + if (src_f->alfi_value_len > 0) { + printf(_("\n")); + (*i)++; + head = (xlog_op_header_t *)*ptr; + xlog_print_op_header(head, *i, ptr); + error = xlog_print_trans_attri_value(ptr, be32_to_cpu(head->oh_len), + src_f->alfi_value_len); + } +error: + free(src_f); + + return error; +} /* xlog_print_trans_attri */ + +int +xlog_print_trans_attri_name( + char **ptr, + uint src_len) +{ + printf(_("ATTRI: name len:%u\n"), src_len); + print_hex_dump(*ptr, src_len); + + *ptr += src_len; + + return 0; +} /* xlog_print_trans_attri */ + +int +xlog_print_trans_attri_value( + char **ptr, + uint src_len, + int value_len) +{ + int len = value_len; + + if (len > MAX_ATTR_VAL_PRINT) + len = MAX_ATTR_VAL_PRINT; + + printf(_("ATTRI: value len:%u\n"), value_len); + print_hex_dump(*ptr, len); + + *ptr += src_len; + + return 0; +} /* xlog_print_trans_attri_value */ + +void +xlog_recover_print_attri( + struct xlog_recover_item *item) +{ + struct xfs_attri_log_format *f, *src_f = NULL; + uint src_len, dst_len; + + int region = 0; + + src_f = (struct xfs_attri_log_format *)item->ri_buf[0].i_addr; + src_len = item->ri_buf[region].i_len; + + /* + * An xfs_attri_log_format structure contains a attribute name and + * variable length value as the last field. + */ + dst_len = sizeof(struct xfs_attri_log_format); + + if ((f = ((struct xfs_attri_log_format *)malloc(dst_len))) == NULL) { + fprintf(stderr, _("%s: xlog_recover_print_attri: malloc failed\n"), + progname); + exit(1); + } + if (xfs_attri_copy_log_format((char*)src_f, src_len, f)) + goto out; + + printf(_("ATTRI: #regs: %d name_len: %d, value_len: %d id: 0x%llx\n"), + f->alfi_size, f->alfi_name_len, f->alfi_value_len, (unsigned long long)f->alfi_id); + + if (f->alfi_name_len > 0) { + region++; + printf(_("ATTRI: name len:%u\n"), f->alfi_name_len); + print_hex_dump((char *)item->ri_buf[region].i_addr, + f->alfi_name_len); + } + + if (f->alfi_value_len > 0) { + int len = f->alfi_value_len; + + if (len > MAX_ATTR_VAL_PRINT) + len = MAX_ATTR_VAL_PRINT; + + region++; + printf(_("ATTRI: value len:%u\n"), f->alfi_value_len); + print_hex_dump((char *)item->ri_buf[region].i_addr, len); + } + +out: + free(f); + +} + +int +xlog_print_trans_attrd(char **ptr, uint len) +{ + struct xfs_attrd_log_format *f; + struct xfs_attrd_log_format lbuf; + uint core_size = sizeof(struct xfs_attrd_log_format); + + memcpy(&lbuf, *ptr, MIN(core_size, len)); + f = &lbuf; + *ptr += len; + if (len >= core_size) { + printf(_("ATTRD: #regs: %d id: 0x%llx\n"), + f->alfd_size, + (unsigned long long)f->alfd_alf_id); + return 0; + } else { + printf(_("ATTRD: Not enough data to decode further\n")); + return 1; + } +} /* xlog_print_trans_attrd */ + +void +xlog_recover_print_attrd( + struct xlog_recover_item *item) +{ + struct xfs_attrd_log_format *f; + + f = (struct xfs_attrd_log_format *)item->ri_buf[0].i_addr; + + printf(_(" ATTRD: #regs: %d id: 0x%llx\n"), + f->alfd_size, + (unsigned long long)f->alfd_alf_id); +} diff --git a/logprint/logprint.h b/logprint/logprint.h index ee85bfe..2e256bd 100644 --- a/logprint/logprint.h +++ b/logprint/logprint.h @@ -28,6 +28,7 @@ extern void xfs_log_print_trans(struct xlog *, int); extern void print_xlog_record_line(void); extern void print_xlog_op_line(void); extern void print_stars(void); +extern void print_hex_dump(char* ptr, int len); extern struct xfs_inode_log_format * xfs_inode_item_format_convert(char *, uint, struct xfs_inode_log_format *); @@ -52,4 +53,13 @@ extern void xlog_recover_print_bui(struct xlog_recover_item *item); extern int xlog_print_trans_bud(char **ptr, uint len); extern void xlog_recover_print_bud(struct xlog_recover_item *item); +#define MAX_ATTR_VAL_PRINT 128 + +extern int xlog_print_trans_attri(char **ptr, uint src_len, int *i); +extern int xlog_print_trans_attri_name(char **ptr, uint src_len); +extern int xlog_print_trans_attri_value(char **ptr, uint src_len, int value_len); +extern void xlog_recover_print_attri(struct xlog_recover_item *item); +extern int xlog_print_trans_attrd(char **ptr, uint len); +extern void xlog_recover_print_attrd(struct xlog_recover_item *item); +extern void xlog_print_op_header(xlog_op_header_t *op_head, int i, char **ptr); #endif /* LOGPRINT_H */ From patchwork Fri Oct 23 06:33:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11852283 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A289E14B7 for ; Fri, 23 Oct 2020 06:33:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FF38241A3 for ; Fri, 23 Oct 2020 06:33:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="WSn9OtfQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S372779AbgJWGdX (ORCPT ); Fri, 23 Oct 2020 02:33:23 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:41458 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372802AbgJWGdX (ORCPT ); Fri, 23 Oct 2020 02:33:23 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6PbTW106826 for ; Fri, 23 Oct 2020 06:33:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=Uu5eVIFCmeVkuq3Tto5FmNjKv+c7wREVyGK1cXIojv8=; b=WSn9OtfQHlosLx9heWjisLHGIubageOjM1ioUyviquFqEAx4uBg0E5TbmzLhmTLhcPKT auxE+JiInF8FMtlTEBOWeo7Wm459qKUajchAZIMeU/PPs1NF7CHuudj81zDlJ1QaAq8T ALLCRiEz6HG8tYC8A0PYmsyuvF+IP8sVCgs6rK2HCSUlnbYfe314ZubgBR30ByVZJRaP /sIqOu0HbBdNjhT3ld9w7FNg7V1F886dVR8j7YWfj41cme8GYv0sRgHVQqlJwhm8jREC ECn/+jCyrhLCHCG9CAQ5wqxhJg0/o/0BpTjnvGGmo7o3GI5GWnmZ8bUUIpyJzO/W1pII LA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 349jrq1eq7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Oct 2020 06:33:21 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09N6Q2UI123374 for ; Fri, 23 Oct 2020 06:33:21 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 34ak1aqy9g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Oct 2020 06:33:21 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 09N6XKuE012231 for ; Fri, 23 Oct 2020 06:33:20 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Oct 2020 23:33:20 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v13 14/14] xfsprogs: Add delayed attribute flag to cmd Date: Thu, 22 Oct 2020 23:33:06 -0700 Message-Id: <20201023063306.7441-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023063306.7441-1-allison.henderson@oracle.com> References: <20201023063306.7441-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9782 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230045 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Collins mkfs: enable feature bit in mkfs via the '-n delattr' parameter. Signed-off-by: Allison Collins Signed-off-by: Allison Henderson --- mkfs/xfs_mkfs.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 8fe149d..e18fb3a 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -94,6 +94,7 @@ enum { N_SIZE = 0, N_VERSION, N_FTYPE, + N_DELATTR, N_MAX_OPTS, }; @@ -547,6 +548,7 @@ static struct opt_params nopts = { [N_SIZE] = "size", [N_VERSION] = "version", [N_FTYPE] = "ftype", + [N_DELATTR] = "delattr", }, .subopt_params = { { .index = N_SIZE, @@ -569,6 +571,12 @@ static struct opt_params nopts = { .maxval = 1, .defaultval = 1, }, + { .index = N_DELATTR, + .conflicts = { { NULL, LAST_CONFLICT } }, + .minval = 0, + .maxval = 1, + .defaultval = 1, + }, }, }; @@ -742,6 +750,7 @@ struct sb_feat_args { bool reflink; /* XFS_SB_FEAT_RO_COMPAT_REFLINK */ bool nodalign; bool nortalign; + bool delattr; /* XFS_SB_FEAT_INCOMPAT_LOG_DELATTR */ }; struct cli_params { @@ -873,7 +882,7 @@ usage( void ) /* log subvol */ [-l agnum=n,internal,size=num,logdev=xxx,version=n\n\ sunit=value|su=num,sectsize=num,lazy-count=0|1]\n\ /* label */ [-L label (maximum 12 characters)]\n\ -/* naming */ [-n size=num,version=2|ci,ftype=0|1]\n\ +/* naming */ [-n size=num,version=2|ci,ftype=0|1,delattr=0|1]\n\ /* no-op info only */ [-N]\n\ /* prototype file */ [-p fname]\n\ /* quiet */ [-q]\n\ @@ -1592,6 +1601,9 @@ naming_opts_parser( case N_FTYPE: cli->sb_feat.dirftype = getnum(value, opts, subopt); break; + case N_DELATTR: + cli->sb_feat.delattr = getnum(value, &nopts, N_DELATTR); + break; default: return -EINVAL; } @@ -1988,6 +2000,14 @@ _("reflink not supported without CRC support\n")); cli->sb_feat.reflink = false; } + if ((cli->sb_feat.delattr) && + cli->sb_feat.dir_version == 4) { + fprintf(stderr, +_("delayed attributes not supported on v4 filesystems\n")); + usage(); + cli->sb_feat.delattr = false; + } + if ((cli->fsx.fsx_xflags & FS_XFLAG_COWEXTSIZE) && !cli->sb_feat.reflink) { fprintf(stderr, @@ -2953,6 +2973,8 @@ sb_set_features( sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_RMAPBT; if (fp->reflink) sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_REFLINK; + if (fp->delattr) + sbp->sb_features_log_incompat |= XFS_SB_FEAT_INCOMPAT_LOG_DELATTR; /* * Sparse inode chunk support has two main inode alignment requirements.