From patchwork Thu Aug 27 00:28:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739711 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 C946814E5 for ; Thu, 27 Aug 2020 00:29:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7644208E4 for ; Thu, 27 Aug 2020 00:29:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="e19f9fsB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726753AbgH0A3L (ORCPT ); Wed, 26 Aug 2020 20:29:11 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37612 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbgH0A3K (ORCPT ); Wed, 26 Aug 2020 20:29:10 -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 07R0FITn144836 for ; Thu, 27 Aug 2020 00:29:08 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=WeNx+V3R6/0XvlRj4TowXMUOsVW8jKj03A5+dErMBJY=; b=e19f9fsB12z8bbCYiMm2DatXuMlsoL/8uRNZ/OYUFUUxTGAErpp/bibPOrRDvalHQkir 0nq/IWPE8v97MyGEu94rOt0UJzJvC8yX/eAXQ2ks9YDumOmkJAoFo0EPY8vg6ZgwVCqc 8/FlBs4gFmxNU9+yU6PNIXuDH1hqH7Hu1iXLubvK6yY2fiQz2ljI/dOz0BM0LaysvA7f 119s1r7elb2uATIPnpNnGsGsP2z5LGuue3Vceqhu/hSqEqmt1SdE/0DQC9O8/JjMIAxo 7XforiaGm+Z8f3SBqwL/XMhlAKtkGW3U1Xmv4nqxCDZbHVHIuoVp8p6feByvR1k2TsS+ cA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 333w6u1yvm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:08 +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 07R0BNt4038219 for ; Thu, 27 Aug 2020 00:29:08 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 333r9mk51d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:08 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0T7Bi016838 for ; Thu, 27 Aug 2020 00:29:07 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:07 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 01/32] xfsprogs: Add xfs_has_attr and subroutines Date: Wed, 26 Aug 2020 17:28:25 -0700 Message-Id: <20200827002856.1131-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=4 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=4 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds a new functions to check for the existence of an attribute. Subroutines are also added to handle the cases of leaf blocks, nodes or shortform. Common code that appears in existing attr add and remove functions have been factored out to help reduce the appearance of duplicated code. We will need these routines later for delayed attributes since delayed operations cannot return error codes. Signed-off-by: Allison Collins Reviewed-by: Chandan Rajendra Reviewed-by: Brian Foster --- libxfs/xfs_attr.c | 182 ++++++++++++++++++++++++++++++++----------------- libxfs/xfs_attr.h | 1 + libxfs/xfs_attr_leaf.c | 97 ++++++++++++++++++-------- libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 191 insertions(+), 92 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index a276a57..056caa1 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -46,6 +46,7 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args); 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_removename(xfs_da_args_t *args); +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. @@ -53,6 +54,8 @@ STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); 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_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); @@ -261,6 +264,37 @@ xfs_attr_set_args( } /* + * Return EEXIST if attr is found, or ENOATTR if not + */ +int +xfs_has_attr( + struct xfs_da_args *args) +{ + struct xfs_inode *dp = args->dp; + struct xfs_buf *bp = NULL; + int error; + + if (!xfs_inode_hasattr(dp)) + return -ENOATTR; + + if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) { + ASSERT(dp->i_afp->if_flags & XFS_IFINLINE); + return xfs_attr_sf_findname(args, NULL, NULL); + } + + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { + error = xfs_attr_leaf_hasname(args, &bp); + + if (bp) + xfs_trans_brelse(args->trans, bp); + + return error; + } + + return xfs_attr_node_hasname(args, NULL); +} + +/* * Remove the attribute specified in @args. */ int @@ -469,26 +503,19 @@ STATIC int xfs_attr_leaf_addname( struct xfs_da_args *args) { - struct xfs_inode *dp; struct xfs_buf *bp; int retval, error, forkoff; + struct xfs_inode *dp = args->dp; trace_xfs_attr_leaf_addname(args); /* - * Read the (only) block in the attribute list in. - */ - dp = args->dp; - args->blkno = 0; - error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, &bp); - if (error) - return error; - - /* * Look up the given attribute in the leaf block. Figure out if * the given flags produce an error or call for an atomic rename. */ - retval = xfs_attr3_leaf_lookup_int(bp, args); + retval = xfs_attr_leaf_hasname(args, &bp); + if (retval != -ENOATTR && retval != -EEXIST) + return retval; if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE)) goto out_brelse; if (retval == -EEXIST) { @@ -640,6 +667,27 @@ out_brelse: } /* + * Return EEXIST if attr is found, or ENOATTR if not + */ +STATIC int +xfs_attr_leaf_hasname( + struct xfs_da_args *args, + struct xfs_buf **bp) +{ + int error = 0; + + error = xfs_attr3_leaf_read(args->trans, args->dp, 0, bp); + if (error) + return error; + + error = xfs_attr3_leaf_lookup_int(*bp, args); + if (error != -ENOATTR && error != -EEXIST) + xfs_trans_brelse(args->trans, *bp); + + return error; +} + +/* * Remove a name from the leaf attribute list structure * * This leaf block cannot have a "remote" value, we only call this routine @@ -659,16 +707,14 @@ xfs_attr_leaf_removename( * Remove the attribute. */ dp = args->dp; - args->blkno = 0; - error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, &bp); - if (error) - return error; - error = xfs_attr3_leaf_lookup_int(bp, args); + error = xfs_attr_leaf_hasname(args, &bp); + if (error == -ENOATTR) { xfs_trans_brelse(args->trans, bp); return error; - } + } else if (error != -EEXIST) + return error; xfs_attr3_leaf_remove(bp, args); @@ -703,21 +749,56 @@ xfs_attr_leaf_get(xfs_da_args_t *args) trace_xfs_attr_leaf_get(args); - args->blkno = 0; - error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, &bp); - if (error) - return error; + error = xfs_attr_leaf_hasname(args, &bp); - error = xfs_attr3_leaf_lookup_int(bp, args); - if (error != -EEXIST) { + if (error == -ENOATTR) { xfs_trans_brelse(args->trans, bp); return error; - } + } else if (error != -EEXIST) + return error; + + error = xfs_attr3_leaf_getvalue(bp, args); xfs_trans_brelse(args->trans, bp); return error; } +/* + * Return EEXIST if attr is found, or ENOATTR if not + * statep: If not null is set to point at the found state. Caller will + * be responsible for freeing the state in this case. + */ +STATIC int +xfs_attr_node_hasname( + struct xfs_da_args *args, + struct xfs_da_state **statep) +{ + struct xfs_da_state *state; + int retval, error; + + state = xfs_da_state_alloc(); + state->args = args; + state->mp = args->dp->i_mount; + + if (statep != NULL) + *statep = NULL; + + /* + * Search to see if name exists, and get back a pointer to it. + */ + error = xfs_da3_node_lookup_int(state, &retval); + if (error) { + xfs_da_state_free(state); + return error; + } + + if (statep != NULL) + *statep = state; + else + xfs_da_state_free(state); + return retval; +} + /*======================================================================== * External routines when attribute list size > geo->blksize *========================================================================*/ @@ -750,17 +831,14 @@ xfs_attr_node_addname( dp = args->dp; mp = dp->i_mount; restart: - state = xfs_da_state_alloc(); - state->args = args; - state->mp = mp; - /* * Search to see if name already exists, and get back a pointer * to where it should go. */ - error = xfs_da3_node_lookup_int(state, &retval); - if (error) + retval = xfs_attr_node_hasname(args, &state); + if (retval != -ENOATTR && retval != -EEXIST) goto out; + blk = &state->path.blk[ state->path.active-1 ]; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE)) @@ -965,29 +1043,15 @@ xfs_attr_node_removename( { struct xfs_da_state *state; struct xfs_da_state_blk *blk; - struct xfs_inode *dp; struct xfs_buf *bp; int retval, error, forkoff; + struct xfs_inode *dp = args->dp; trace_xfs_attr_node_removename(args); - /* - * Tie a string around our finger to remind us where we are. - */ - dp = args->dp; - state = xfs_da_state_alloc(); - state->args = args; - state->mp = dp->i_mount; - - /* - * Search to see if name exists, and get back a pointer to it. - */ - error = xfs_da3_node_lookup_int(state, &retval); - if (error || (retval != -EEXIST)) { - if (error == 0) - error = retval; + error = xfs_attr_node_hasname(args, &state); + if (error != -EEXIST) goto out; - } /* * If there is an out-of-line value, de-allocate the blocks. @@ -1082,7 +1146,8 @@ xfs_attr_node_removename( error = 0; out: - xfs_da_state_free(state); + if (state) + xfs_da_state_free(state); return error; } @@ -1202,31 +1267,23 @@ xfs_attr_node_get(xfs_da_args_t *args) { xfs_da_state_t *state; xfs_da_state_blk_t *blk; - int error, retval; + int error; int i; trace_xfs_attr_node_get(args); - state = xfs_da_state_alloc(); - state->args = args; - state->mp = args->dp->i_mount; - /* * Search to see if name exists, and get back a pointer to it. */ - error = xfs_da3_node_lookup_int(state, &retval); - if (error) { - retval = error; - goto out_release; - } - if (retval != -EEXIST) + error = xfs_attr_node_hasname(args, &state); + if (error != -EEXIST) goto out_release; /* * Get the value, local or "remote" */ blk = &state->path.blk[state->path.active - 1]; - retval = xfs_attr3_leaf_getvalue(blk->bp, args); + error = xfs_attr3_leaf_getvalue(blk->bp, args); /* * If not in a transaction, we have to release all the buffers. @@ -1237,8 +1294,9 @@ out_release: state->path.blk[i].bp = NULL; } - xfs_da_state_free(state); - return retval; + if (state) + xfs_da_state_free(state); + return error; } /* Returns true if the attribute entry name is valid. */ diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index db47176..3e97a93 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -89,6 +89,7 @@ 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_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); bool xfs_attr_namecheck(const void *name, size_t length); diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 7267e6a..b9d633f 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -657,18 +657,63 @@ xfs_attr_shortform_create( } /* + * Return -EEXIST if attr is found, or -ENOATTR if not + * args: args containing attribute name and namelen + * sfep: If not null, pointer will be set to the last attr entry found on + -EEXIST. On -ENOATTR pointer is left at the last entry in the list + * basep: If not null, pointer is set to the byte offset of the entry in the + * list on -EEXIST. On -ENOATTR, pointer is left at the byte offset of + * the last entry in the list + */ +int +xfs_attr_sf_findname( + struct xfs_da_args *args, + struct xfs_attr_sf_entry **sfep, + unsigned int *basep) +{ + struct xfs_attr_shortform *sf; + struct xfs_attr_sf_entry *sfe; + unsigned int base = sizeof(struct xfs_attr_sf_hdr); + int size = 0; + int end; + int i; + + sf = (struct xfs_attr_shortform *)args->dp->i_afp->if_u1.if_data; + sfe = &sf->list[0]; + end = sf->hdr.count; + for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), + base += size, i++) { + size = XFS_ATTR_SF_ENTSIZE(sfe); + if (!xfs_attr_match(args, sfe->namelen, sfe->nameval, + sfe->flags)) + continue; + break; + } + + if (sfep != NULL) + *sfep = sfe; + + if (basep != NULL) + *basep = base; + + if (i == end) + return -ENOATTR; + return -EEXIST; +} + +/* * Add a name/value pair to the shortform attribute list. * Overflow from the inode has already been checked for. */ void -xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) +xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff) { - xfs_attr_shortform_t *sf; - xfs_attr_sf_entry_t *sfe; - int i, offset, size; - xfs_mount_t *mp; - xfs_inode_t *dp; - struct xfs_ifork *ifp; + struct xfs_attr_shortform *sf; + struct xfs_attr_sf_entry *sfe; + int offset, size, error; + struct xfs_mount *mp; + struct xfs_inode *dp; + struct xfs_ifork *ifp; trace_xfs_attr_sf_add(args); @@ -679,11 +724,8 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) ifp = dp->i_afp; ASSERT(ifp->if_flags & XFS_IFINLINE); sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; - sfe = &sf->list[0]; - for (i = 0; i < sf->hdr.count; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { - ASSERT(!xfs_attr_match(args, sfe->namelen, sfe->nameval, - sfe->flags)); - } + error = xfs_attr_sf_findname(args, &sfe, NULL); + ASSERT(error != -EEXIST); offset = (char *)sfe - (char *)sf; size = XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); @@ -725,31 +767,26 @@ xfs_attr_fork_remove( * Remove an attribute from the shortform attribute list structure. */ int -xfs_attr_shortform_remove(xfs_da_args_t *args) +xfs_attr_shortform_remove(struct xfs_da_args *args) { - xfs_attr_shortform_t *sf; - xfs_attr_sf_entry_t *sfe; - int base, size=0, end, totsize, i; - xfs_mount_t *mp; - xfs_inode_t *dp; + struct xfs_attr_shortform *sf; + struct xfs_attr_sf_entry *sfe; + int size = 0, end, totsize; + unsigned int base; + struct xfs_mount *mp; + struct xfs_inode *dp; + int error; trace_xfs_attr_sf_remove(args); dp = args->dp; mp = dp->i_mount; - base = sizeof(xfs_attr_sf_hdr_t); sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; - sfe = &sf->list[0]; - end = sf->hdr.count; - for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), - base += size, i++) { - size = XFS_ATTR_SF_ENTSIZE(sfe); - if (xfs_attr_match(args, sfe->namelen, sfe->nameval, - sfe->flags)) - break; - } - if (i == end) - return -ENOATTR; + + error = xfs_attr_sf_findname(args, &sfe, &base); + if (error != -EEXIST) + return error; + size = XFS_ATTR_SF_ENTSIZE(sfe); /* * Fix up the attribute fork data, covering the hole diff --git a/libxfs/xfs_attr_leaf.h b/libxfs/xfs_attr_leaf.h index 5be6be3..9b1c59f 100644 --- a/libxfs/xfs_attr_leaf.h +++ b/libxfs/xfs_attr_leaf.h @@ -52,6 +52,9 @@ int xfs_attr_shortform_getvalue(struct xfs_da_args *args); int xfs_attr_shortform_to_leaf(struct xfs_da_args *args, struct xfs_buf **leaf_bp); int xfs_attr_shortform_remove(struct xfs_da_args *args); +int xfs_attr_sf_findname(struct xfs_da_args *args, + struct xfs_attr_sf_entry **sfep, + unsigned int *basep); int xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp); int xfs_attr_shortform_bytesfit(struct xfs_inode *dp, int bytes); xfs_failaddr_t xfs_attr_shortform_verify(struct xfs_inode *ip); From patchwork Thu Aug 27 00:28:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739713 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 E73AC1751 for ; Thu, 27 Aug 2020 00:29:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE70C2087C for ; Thu, 27 Aug 2020 00:29:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Akr3rD8Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbgH0A3L (ORCPT ); Wed, 26 Aug 2020 20:29:11 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37640 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbgH0A3K (ORCPT ); Wed, 26 Aug 2020 20:29:10 -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 07R0Fmnm144966 for ; Thu, 27 Aug 2020 00:29:09 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=DPwWtPRw65CbMoFiBNruIGBDecWUzX6hlFBSzqV8Hv0=; b=Akr3rD8Zl0AxGaSblJMaHEw0OANvt4mZwh8gIIQ9Ml/NxS6pA4g3xnjk3IzwcUn+CJoo QPOipVUz9bTBJS/JMSRdPrKhQKT6MXR/mJyeo1ejOEtD9UY2L1tsALLFbzbuUhySHZuM odp5pIi6istJQssC1s92wA1ycJ6hcv2H59wGbZn4JbiMfhMnzLBnpUi0KMcy0J+1MmnH o2J/qsmG9vltiuq1djAoU7zJYU8Taqnkh5gYHXSFQRurTOv09PV4IZs5D6V66k0XcMTX geBjaxGfjmWVYkvCl51MCQLOdrQK7qd5De59+VmCS66MaQhRWC8iScs90JUJUaWiofdi bA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 333w6u1yvr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:09 +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 07R0AH3V121713 for ; Thu, 27 Aug 2020 00:29:09 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 333rubkfyq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:08 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0T7A3024784 for ; Thu, 27 Aug 2020 00:29:07 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:07 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 02/32] xfsprogs: Check for -ENOATTR or -EEXIST Date: Wed, 26 Aug 2020 17:28:26 -0700 Message-Id: <20200827002856.1131-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=1 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Delayed operations cannot return error codes. So we must check for these conditions first before starting set or remove operations Signed-off-by: Allison Collins Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- libxfs/xfs_attr.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 056caa1..e519ecc 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -404,6 +404,15 @@ xfs_attr_set( args->total, 0, quota_flags); if (error) goto out_trans_cancel; + + error = xfs_has_attr(args); + if (error == -EEXIST && (args->attr_flags & XATTR_CREATE)) + goto out_trans_cancel; + if (error == -ENOATTR && (args->attr_flags & XATTR_REPLACE)) + goto out_trans_cancel; + if (error != -ENOATTR && error != -EEXIST) + goto out_trans_cancel; + error = xfs_attr_set_args(args); if (error) goto out_trans_cancel; @@ -411,6 +420,10 @@ xfs_attr_set( if (!args->trans) goto out_unlock; } else { + error = xfs_has_attr(args); + if (error != -EEXIST) + goto out_trans_cancel; + error = xfs_attr_remove_args(args); if (error) goto out_trans_cancel; From patchwork Thu Aug 27 00:28:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739715 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 1A20B722 for ; Thu, 27 Aug 2020 00:29:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECA612087C for ; Thu, 27 Aug 2020 00:29:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="C1EF5Noi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726148AbgH0A3L (ORCPT ); Wed, 26 Aug 2020 20:29:11 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:54580 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbgH0A3K (ORCPT ); Wed, 26 Aug 2020 20:29:10 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07R0SwnK022029 for ; Thu, 27 Aug 2020 00:29:09 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=+mNLHtPhQDaL8z3IC2A1ufREkBufQZ2Pv9i9ntSbsog=; b=C1EF5NoiL8JesmK0eiPPU/TePVTdjGbR2fsIWYuj9rlEtCh8wHFhv2xDZlEzKmC4Vfng nkVyX3VxVmolHVhcXECcpLFXrT3KIyAAq4qUH/zbknHVLQb21tQa0EP9NcbuJrjW21uR YLyRbYIeaHj3hPqszxb97zaW5FvO4tpAR3ihHzqLXJOmDD1QSYLv00xrPJk/oWhYXKfy qeHzeroQpvTh/NltynEQQ1ibYgyvNml5zrTasXiZ5Pyw1I9pgTuTAj4e5gGvntKQSKQ1 Ca0klZmeZGXSQapJtfsf/ybL5+yYIw150NAzZk0BQeVHzgBYgM1WfFwumFRuDUIK3k17 0Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 335gw859dc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:09 +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 07R0BMT7038030 for ; Thu, 27 Aug 2020 00:29:08 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 333r9mk51p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:08 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0T83e024787 for ; Thu, 27 Aug 2020 00:29:08 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:07 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 03/32] xfsprogs: Factor out new helper functions xfs_attr_rmtval_set Date: Wed, 26 Aug 2020 17:28:27 -0700 Message-Id: <20200827002856.1131-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=1 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Break xfs_attr_rmtval_set into two helper functions xfs_attr_rmt_find_hole and xfs_attr_rmtval_set_value. xfs_attr_rmtval_set rolls the transaction between the helpers, but delayed operations cannot. We will use the helpers later when constructing new delayed attribute routines. Signed-off-by: Allison Collins Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Rajendra --- libxfs/xfs_attr_remote.c | 149 +++++++++++++++++++++++++++++------------------ 1 file changed, 92 insertions(+), 57 deletions(-) diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index a9a48b30..6267cd6 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -439,32 +439,23 @@ xfs_attr_rmtval_get( } /* - * Write the value associated with an attribute into the out-of-line buffer - * that we have defined for it. + * Find a "hole" in the attribute address space large enough for us to drop the + * new attribute's value into */ -int -xfs_attr_rmtval_set( +STATIC int +xfs_attr_rmt_find_hole( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; struct xfs_mount *mp = dp->i_mount; - struct xfs_bmbt_irec map; - xfs_dablk_t lblkno; - xfs_fileoff_t lfileoff = 0; - uint8_t *src = args->value; - int blkcnt; - int valuelen; - int nmap; int error; - int offset = 0; - - trace_xfs_attr_rmtval_set(args); + int blkcnt; + xfs_fileoff_t lfileoff = 0; /* - * Find a "hole" in the attribute address space large enough for - * us to drop the new attribute's value into. Because CRC enable - * attributes have headers, we can't just do a straight byte to FSB - * conversion and have to take the header space into account. + * Because CRC enable attributes have headers, we can't just do a + * straight byte to FSB conversion and have to take the header space + * into account. */ blkcnt = xfs_attr3_rmt_blocks(mp, args->rmtvaluelen); error = xfs_bmap_first_unused(args->trans, args->dp, blkcnt, &lfileoff, @@ -472,48 +463,26 @@ xfs_attr_rmtval_set( if (error) return error; - args->rmtblkno = lblkno = (xfs_dablk_t)lfileoff; + args->rmtblkno = (xfs_dablk_t)lfileoff; args->rmtblkcnt = blkcnt; - /* - * Roll through the "value", allocating blocks on disk as required. - */ - while (blkcnt > 0) { - /* - * Allocate a single extent, up to the size of the value. - * - * Note that we have to consider this a data allocation as we - * write the remote attribute without logging the contents. - * Hence we must ensure that we aren't using blocks that are on - * the busy list so that we don't overwrite blocks which have - * recently been freed but their transactions are not yet - * committed to disk. If we overwrite the contents of a busy - * extent and then crash then the block may not contain the - * correct metadata after log recovery occurs. - */ - nmap = 1; - error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno, - blkcnt, XFS_BMAPI_ATTRFORK, args->total, &map, - &nmap); - if (error) - return error; - error = xfs_defer_finish(&args->trans); - if (error) - return error; - - ASSERT(nmap == 1); - ASSERT((map.br_startblock != DELAYSTARTBLOCK) && - (map.br_startblock != HOLESTARTBLOCK)); - lblkno += map.br_blockcount; - blkcnt -= map.br_blockcount; + return 0; +} - /* - * Start the next trans in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; - } +STATIC int +xfs_attr_rmtval_set_value( + struct xfs_da_args *args) +{ + struct xfs_inode *dp = args->dp; + struct xfs_mount *mp = dp->i_mount; + struct xfs_bmbt_irec map; + xfs_dablk_t lblkno; + uint8_t *src = args->value; + int blkcnt; + int valuelen; + int nmap; + int error; + int offset = 0; /* * Roll through the "value", copying the attribute value to the @@ -594,6 +563,72 @@ xfs_attr_rmtval_stale( } /* + * Write the value associated with an attribute into the out-of-line buffer + * that we have defined for it. + */ +int +xfs_attr_rmtval_set( + struct xfs_da_args *args) +{ + struct xfs_inode *dp = args->dp; + struct xfs_bmbt_irec map; + xfs_dablk_t lblkno; + int blkcnt; + int nmap; + int error; + + trace_xfs_attr_rmtval_set(args); + + error = xfs_attr_rmt_find_hole(args); + if (error) + return error; + + blkcnt = args->rmtblkcnt; + lblkno = (xfs_dablk_t)args->rmtblkno; + /* + * Roll through the "value", allocating blocks on disk as required. + */ + while (blkcnt > 0) { + /* + * Allocate a single extent, up to the size of the value. + * + * Note that we have to consider this a data allocation as we + * write the remote attribute without logging the contents. + * Hence we must ensure that we aren't using blocks that are on + * the busy list so that we don't overwrite blocks which have + * recently been freed but their transactions are not yet + * committed to disk. If we overwrite the contents of a busy + * extent and then crash then the block may not contain the + * correct metadata after log recovery occurs. + */ + nmap = 1; + error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno, + blkcnt, XFS_BMAPI_ATTRFORK, args->total, &map, + &nmap); + if (error) + return error; + error = xfs_defer_finish(&args->trans); + if (error) + return error; + + ASSERT(nmap == 1); + ASSERT((map.br_startblock != DELAYSTARTBLOCK) && + (map.br_startblock != HOLESTARTBLOCK)); + lblkno += map.br_blockcount; + blkcnt -= map.br_blockcount; + + /* + * Start the next trans in the chain. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + return error; + } + + return xfs_attr_rmtval_set_value(args); +} + +/* * Remove the value associated with an attribute by deleting the * out-of-line buffer that it is stored on. */ From patchwork Thu Aug 27 00:28:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739717 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 9F69D722 for ; Thu, 27 Aug 2020 00:29:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8531C2087C for ; Thu, 27 Aug 2020 00:29:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="sL48Rt8k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbgH0A3O (ORCPT ); Wed, 26 Aug 2020 20:29:14 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:54614 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726794AbgH0A3N (ORCPT ); Wed, 26 Aug 2020 20:29:13 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07R0T0BG022056 for ; Thu, 27 Aug 2020 00:29:12 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=UaKS47l9ur1Ge0fXn+DCpx5LAYw6pVxec7m/574XwJY=; b=sL48Rt8kew7V4qGUXhrHKEE7nIFB4BelllVw9u3tS5ULCiiS9+YpetVKuCI+wRT4sti+ VhiOlFozKWSwtiszaIIOQsj9Lz99DWCe/qMcGSTnePDK+ofo0mdA9gjubbFK42EWx4Nc FmQ8du8pFa6tXFl+KPGF24fckB/OLA1oedox0Yv1JqXqAd29lAH0OS/rooJaxuDS0qV+ mFg2MayrFSMRvQtQ5cP8LSui6Z/d4+emDWMaNlaMOn8D8YdPdr7/d/7BX7yKq+qutTgj 6EpXhIRfuYbzJLuDUvzrbiVZ5LY9WQrUQhyJJwEZLNHBs+bg2rITKzDybWBILdsgD4vR 2Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 335gw859dg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:11 +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 07R0AHkX121689 for ; Thu, 27 Aug 2020 00:29:11 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 333rubkg1y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:11 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07R0T9OX019220 for ; Thu, 27 Aug 2020 00:29:09 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:08 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 04/32] xfsprogs: Pull up trans handling in xfs_attr3_leaf_flipflags Date: Wed, 26 Aug 2020 17:28:28 -0700 Message-Id: <20200827002856.1131-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=1 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Since delayed operations cannot roll transactions, pull up the transaction handling into the calling function Signed-off-by: Allison Collins Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Rajendra --- libxfs/xfs_attr.c | 14 ++++++++++++++ libxfs/xfs_attr_leaf.c | 7 +------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index e519ecc..1b65ad3 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -622,6 +622,13 @@ xfs_attr_leaf_addname( 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; /* * Dismantle the "old" attribute/value pair by removing @@ -968,6 +975,13 @@ restart: error = xfs_attr3_leaf_flipflags(args); if (error) goto out; + /* + * 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; /* * Dismantle the "old" attribute/value pair by removing diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index b9d633f..2d4c91b 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2945,10 +2945,5 @@ xfs_attr3_leaf_flipflags( XFS_DA_LOGRANGE(leaf2, name_rmt, sizeof(*name_rmt))); } - /* - * Commit the flag value change and start the next trans in series. - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - - return error; + return 0; } From patchwork Thu Aug 27 00:28:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739719 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 BDE7B1751 for ; Thu, 27 Aug 2020 00:29:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A51142087C for ; Thu, 27 Aug 2020 00:29:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="SxMKa3qn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726794AbgH0A3O (ORCPT ); Wed, 26 Aug 2020 20:29:14 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37656 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbgH0A3N (ORCPT ); Wed, 26 Aug 2020 20:29:13 -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 07R0FgBd144946 for ; Thu, 27 Aug 2020 00:29:11 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=/jamhobgKOZi/JwzvHuUc0/M1nZmo6I0Yweljtr20uY=; b=SxMKa3qnaclOQICeATKM5JoAWU7ZpprkYv35az/8Vx6AaSKAntimHCxoMcrk5DF62GDS ACnSxR8cCx2lNzaGxnxIHPASD0HkMF/uXT96XizByw9nQhP1rU41dGjKJwuELXWCu0Vv HFFSSjDu1quoWE7KPgkOml8i2XMGVYRq+OSi44HrYcnlAETTt4ttGCI/2qzT0VoVDq5e usoD4+c9ALX07rHajpAB/hDApldyY04CfYjUt1rYPSAWZVNLW4K2AzCcJTumpDtC/PD7 Vj/LE3mWPG0AsP3/L7Wc+RlMm9sQxKKmkIMSd3Y3if0ZetJWgnuq+Aeyq+EQJOoWVfZP qg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 333w6u1yvt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:11 +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 07R0BMmQ038067 for ; Thu, 27 Aug 2020 00:29:11 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 333r9mk52d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:11 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TAIn016879 for ; Thu, 27 Aug 2020 00:29:10 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:09 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 05/32] xfsprogs: Split apart xfs_attr_leaf_addname Date: Wed, 26 Aug 2020 17:28:29 -0700 Message-Id: <20200827002856.1131-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=1 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Split out new helper function xfs_attr_leaf_try_add from xfs_attr_leaf_addname. Because new delayed attribute routines cannot roll transactions, we split off the parts of xfs_attr_leaf_addname that we can use, and move the commit into the calling function. Signed-off-by: Allison Collins Reviewed-by: Brian Foster Reviewed-by: Chandan Rajendra --- libxfs/xfs_attr.c | 95 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 34 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 1b65ad3..4f362b4 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -256,10 +256,31 @@ xfs_attr_set_args( } } - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { error = xfs_attr_leaf_addname(args); - else - error = xfs_attr_node_addname(args); + if (error != -ENOSPC) + 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) + return error; + + /* + * Commit the current trans (including the inode) and + * start a new one. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + return error; + } + + error = xfs_attr_node_addname(args); return error; } @@ -507,20 +528,21 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) *========================================================================*/ /* - * Add a name to the leaf attribute list structure + * Tries to add an attribute to an inode in leaf form * - * 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 function is meant to execute as part of a delayed operation and leaves + * the transaction handling to the caller. On success the attribute is added + * and the inode and transaction are left dirty. If there is not enough space, + * the attr data is converted to node format and -ENOSPC is returned. Caller is + * responsible for handling the dirty inode and transaction or adding the attr + * in node format. */ STATIC int -xfs_attr_leaf_addname( - struct xfs_da_args *args) +xfs_attr_leaf_try_add( + struct xfs_da_args *args, + struct xfs_buf *bp) { - struct xfs_buf *bp; - int retval, error, forkoff; - struct xfs_inode *dp = args->dp; - - trace_xfs_attr_leaf_addname(args); + int retval, error; /* * Look up the given attribute in the leaf block. Figure out if @@ -562,31 +584,39 @@ xfs_attr_leaf_addname( retval = xfs_attr3_leaf_add(bp, args); if (retval == -ENOSPC) { /* - * Promote the attribute list to the Btree format, then - * Commit that transaction so that the node_addname() call - * can manage its own transactions. + * Promote the attribute list to the Btree format. Unless an + * error occurs, retain the -ENOSPC retval */ error = xfs_attr3_leaf_to_node(args); if (error) return error; - error = xfs_defer_finish(&args->trans); - if (error) - return error; + } + return retval; +out_brelse: + xfs_trans_brelse(args->trans, bp); + return retval; +} - /* - * Commit the current trans (including the inode) and start - * a new one. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; - /* - * Fob the whole rest of the problem off on the Btree code. - */ - error = xfs_attr_node_addname(args); +/* + * Add a name to the leaf attribute list structure + * + * 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). + */ +STATIC int +xfs_attr_leaf_addname( + struct xfs_da_args *args) +{ + 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; - } /* * Commit the transaction that added the attr name so that @@ -681,9 +711,6 @@ xfs_attr_leaf_addname( error = xfs_attr3_leaf_clearflag(args); } return error; -out_brelse: - xfs_trans_brelse(args->trans, bp); - return retval; } /* From patchwork Thu Aug 27 00:28:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739721 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 0805A14E5 for ; Thu, 27 Aug 2020 00:29:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DADC42087D for ; Thu, 27 Aug 2020 00:29:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="rOgfFIMu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbgH0A3O (ORCPT ); Wed, 26 Aug 2020 20:29:14 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37664 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726798AbgH0A3N (ORCPT ); Wed, 26 Aug 2020 20:29:13 -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 07R0FPg5144892 for ; Thu, 27 Aug 2020 00:29:12 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=Nmh7OxivzMQSFfIi6PSSyuenP5SNxZryD/sgKtZiYW0=; b=rOgfFIMuFoy6f/PVhITepk03HnwOmyp7ENTYIvABkfGrt5z25o+RRqoTkbTEnhS5+vIy YaVDRxP2M/gwhVXa7Aw+t046V0BEiUBcraC9R1DOj75DPnvPoqJmG89YDsN2TSueDyEa sd7yg+6QR391C4U/AADhbJS/xvriz8CGlRBUMbANRTPFhlbkAqurlAHAOMiEdp4hvlpM rIaqR7Hz7V54Ui8udzucixA87XzKQMXk792pForSZOyg/n76y0cPm0mvrNu9DG6IZgoA OQ52w9ues/XzXse6qt4wXf8ZIDLJyF69j59s/ztogKHwxng0q7ASFcO6jm0zpVRpzJyt CA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 333w6u1yvu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:12 +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 07R0AfdT127388 for ; Thu, 27 Aug 2020 00:29:11 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 333ru0t3aj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:11 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TA7L016882 for ; Thu, 27 Aug 2020 00:29:10 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:10 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 06/32] xfsprogs: Refactor xfs_attr_try_sf_addname Date: Wed, 26 Aug 2020 17:28:30 -0700 Message-Id: <20200827002856.1131-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org To help pre-simplify xfs_attr_set_args, we need to hoist transaction handling up, while modularizing the adjacent code down into helpers. In this patch, hoist the commit in xfs_attr_try_sf_addname up into the calling function, and also pull the attr list creation down. Signed-off-by: Allison Collins Reviewed-by: Darrick J. Wong Reviewed-by: Amir Goldstein Reviewed-by: Brian Foster Reviewed-by: Chandan Rajendra --- libxfs/xfs_attr.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 4f362b4..8180134 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -178,8 +178,13 @@ xfs_attr_try_sf_addname( struct xfs_da_args *args) { - struct xfs_mount *mp = dp->i_mount; - int error, error2; + int error; + + /* + * Build initial attribute list (if required). + */ + if (dp->i_afp->if_format == XFS_DINODE_FMT_EXTENTS) + xfs_attr_shortform_create(args); error = xfs_attr_shortform_addname(args); if (error == -ENOSPC) @@ -192,12 +197,10 @@ xfs_attr_try_sf_addname( if (!error && !(args->op_flags & XFS_DA_OP_NOTIME)) xfs_trans_ichgtime(args->trans, dp, XFS_ICHGTIME_CHG); - if (mp->m_flags & XFS_MOUNT_WSYNC) + if (dp->i_mount->m_flags & XFS_MOUNT_WSYNC) xfs_trans_set_sync(args->trans); - error2 = xfs_trans_commit(args->trans); - args->trans = NULL; - return error ? error : error2; + return error; } /* @@ -209,7 +212,7 @@ xfs_attr_set_args( { struct xfs_inode *dp = args->dp; struct xfs_buf *leaf_bp = NULL; - int error; + int error, error2 = 0; /* * If the attribute list is non-existent or a shortform list, @@ -220,17 +223,14 @@ xfs_attr_set_args( dp->i_afp->if_nextents == 0)) { /* - * Build initial attribute list (if required). - */ - if (dp->i_afp->if_format == XFS_DINODE_FMT_EXTENTS) - xfs_attr_shortform_create(args); - - /* * Try to add the attr to the attribute list in the inode. */ error = xfs_attr_try_sf_addname(dp, args); - if (error != -ENOSPC) - return error; + if (error != -ENOSPC) { + error2 = xfs_trans_commit(args->trans); + args->trans = NULL; + return error ? error : error2; + } /* * It won't fit in the shortform, transform to a leaf block. From patchwork Thu Aug 27 00:28:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739759 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 D03E4722 for ; Thu, 27 Aug 2020 00:31:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8602207CD for ; Thu, 27 Aug 2020 00:31:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="uY+8QvR6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726995AbgH0AbN (ORCPT ); Wed, 26 Aug 2020 20:31:13 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:55400 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbgH0AbN (ORCPT ); Wed, 26 Aug 2020 20:31:13 -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 07R0U0bW068451 for ; Thu, 27 Aug 2020 00:31:12 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=r0x2BSIyXCpHXjC2q6KFBDhAj4t029959eTU6EvbFFI=; b=uY+8QvR6GUaP5BRhLW8jozn4ifSwjI1axPZb0Mgr5laHgQ5ph2U3sxpRauhhZHHp4ulF IfIuwph/fpEizyoCbZrKXJKu+JnoeQoSduIH7qLjBrp2Ghi2vgARI7zjhTZQtRVT/E57 gic1CYS5h+i7CS7ItCJYQXbNN735IQmwewVg5YE9QEdD2uaqDb134uOkMaRfFIar/SIE boVu+PogpDcgqFTMb8MfigivdtQ2s1NmF2eW2rBGdovdTYT5n6z91fNwRu+hhoVmEOBU TSP48+DNQ1iYR9FYmlieGGbd0yQ4SNfSDRBzzFf/e4mYIs2bvmzL0BGwKCx3j9Kig+1S lQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 333dbs3e2s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:31:12 +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 07R0Aqw3025926 for ; Thu, 27 Aug 2020 00:29:11 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 333r9mswt9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:11 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TBmK016885 for ; Thu, 27 Aug 2020 00:29:11 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:11 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 07/32] xfsprogs: Pull up trans roll from xfs_attr3_leaf_setflag Date: Wed, 26 Aug 2020 17:28:31 -0700 Message-Id: <20200827002856.1131-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org New delayed allocation routines cannot be handling transactions so pull them up into the calling functions Signed-off-by: Allison Collins Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster Reviewed-by: Chandan Rajendra --- libxfs/xfs_attr.c | 5 +++++ libxfs/xfs_attr_leaf.c | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 8180134..5cdaac1 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1132,6 +1132,11 @@ xfs_attr_node_removename( error = xfs_attr3_leaf_setflag(args); if (error) goto out; + + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + goto out; + error = xfs_attr_rmtval_remove(args); if (error) goto out; diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 2d4c91b..d34ead2 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2827,10 +2827,7 @@ xfs_attr3_leaf_setflag( XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); } - /* - * Commit the flag value change and start the next trans in series. - */ - return xfs_trans_roll_inode(&args->trans, args->dp); + return 0; } /* From patchwork Thu Aug 27 00:28:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739745 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 A978C722 for ; Thu, 27 Aug 2020 00:29:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 912ED208E4 for ; Thu, 27 Aug 2020 00:29:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ToUU2XmY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726894AbgH0A3V (ORCPT ); Wed, 26 Aug 2020 20:29:21 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37762 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726856AbgH0A3U (ORCPT ); Wed, 26 Aug 2020 20:29: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 07R0TJdb165407 for ; Thu, 27 Aug 2020 00:29: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; s=corp-2020-01-29; bh=MXUK95i7spFuvbxFem/28TAu6rcdZwzT/HjBX7ghP7E=; b=ToUU2XmYlivf9EnCkXLn5NBY/2902uBOL2OYDzRsSKVkFcJrvg8++S5ZxNIwLWIUay4E 1Ye4SLKFdXRHXdoWRXmY1R90aWtHujWJ3MMN5IJaj+OthuI9XT3P9sL/G6g4WynzTryT Loxwy3PviX8OohZ1jTa0DE6eiK2K1MNoOc9Gmzm5TEWItzvxCoUFM+RHnaTZFpauaWf9 P2EC8JTfFGebvf2ROqxlYA58Jgj1tDGXIMN2OTwRu7e5FhFZdPQCVZ1kBOcl7BAwlDDH 9Ip8mjep1HzdD92s3hS5FMjSVRJgBSWjkQncSOzWj5bVH/tq7xqCVN/N0tBxVWPHsXNv Iw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 333w6u1yvw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29: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 07R0ArGB025945 for ; Thu, 27 Aug 2020 00:29:12 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 333r9mswta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:12 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TBO3016888 for ; Thu, 27 Aug 2020 00:29:11 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:11 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 08/32] xfsprogs: Factor out xfs_attr_rmtval_invalidate Date: Wed, 26 Aug 2020 17:28:32 -0700 Message-Id: <20200827002856.1131-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Because new delayed attribute routines cannot roll transactions, we carve off the parts of xfs_attr_rmtval_remove that we can use. This will help to reduce repetitive code later when we introduce delayed attributes. Signed-off-by: Allison Collins Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Rajendra --- libxfs/xfs_attr_remote.c | 26 +++++++++++++++++++++----- libxfs/xfs_attr_remote.h | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 6267cd6..e09c1b6 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -633,15 +633,12 @@ xfs_attr_rmtval_set( * out-of-line buffer that it is stored on. */ int -xfs_attr_rmtval_remove( +xfs_attr_rmtval_invalidate( struct xfs_da_args *args) { xfs_dablk_t lblkno; int blkcnt; int error; - int done; - - trace_xfs_attr_rmtval_remove(args); /* * Roll through the "value", invalidating the attribute value's blocks. @@ -669,13 +666,32 @@ xfs_attr_rmtval_remove( lblkno += map.br_blockcount; 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. + */ +int +xfs_attr_rmtval_remove( + struct xfs_da_args *args) +{ + xfs_dablk_t lblkno; + int blkcnt; + int error = 0; + int done = 0; + + trace_xfs_attr_rmtval_remove(args); + + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; /* * Keep de-allocating extents until the remote-value region is gone. */ lblkno = args->rmtblkno; blkcnt = args->rmtblkcnt; - done = 0; while (!done) { error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, XFS_BMAPI_ATTRFORK, 1, &done); diff --git a/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index e1144f2..3616e88 100644 --- a/libxfs/xfs_attr_remote.h +++ b/libxfs/xfs_attr_remote.h @@ -13,5 +13,5 @@ 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); #endif /* __XFS_ATTR_REMOTE_H__ */ From patchwork Thu Aug 27 00:28:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739723 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 E222214E5 for ; Thu, 27 Aug 2020 00:29:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC289208E4 for ; Thu, 27 Aug 2020 00:29:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="C05E0MJ4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726798AbgH0A3P (ORCPT ); Wed, 26 Aug 2020 20:29:15 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54098 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbgH0A3O (ORCPT ); Wed, 26 Aug 2020 20:29:14 -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 07R0Dw0v045222 for ; Thu, 27 Aug 2020 00:29:13 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=FoC1IZQUFho7fKcdfZKEwfxWABpMQQd9Gd3dqzvH82s=; b=C05E0MJ4jCTG5z+sRwzO2GUCc/VFA/nUyUTZ2C7IbFZ9dh9jy5fOhKMCICwG4zmOxjG0 FjHcKK+K/2kYyJab0XxG4L0IKv8/3bMyq94R14DIAupwQZ4Evt76S8F7UqKdAoaIcGWn mOnCjWDEeljowZhO41sn00mbb3bnWBUvZstJDFIGvqzWuX5qUWqsNmQ745uOH2I+kDdh jp/7aX/a579Y3SgubgVVMgDTwldYBasxOiut+7VA/fo3ndKYiW3V7PqdUr1TAAQTY2Ou zVna+I3PIaZc0k41ui6SzRs9uSnGkAbCy4MlL1SMracub9mcPTHxmTzA8ExjMjDXdRHK Sw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 333dbs3dx5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:13 +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 07R0AgVX127541 for ; Thu, 27 Aug 2020 00:29:12 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 333ru0t3b3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:12 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TCRd024796 for ; Thu, 27 Aug 2020 00:29:12 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:11 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 09/32] xfsprogs: Pull up trans roll in xfs_attr3_leaf_clearflag Date: Wed, 26 Aug 2020 17:28:33 -0700 Message-Id: <20200827002856.1131-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org New delayed allocation routines cannot be handling transactions so pull them out into the calling functions Signed-off-by: Allison Collins Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Rajendra --- libxfs/xfs_attr.c | 16 ++++++++++++++++ libxfs/xfs_attr_leaf.c | 5 +---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 5cdaac1..b472c95 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -709,6 +709,14 @@ xfs_attr_leaf_addname( * Added a "remote" value, just clear the incomplete flag. */ error = xfs_attr3_leaf_clearflag(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); } return error; } @@ -1073,6 +1081,14 @@ restart: error = xfs_attr3_leaf_clearflag(args); if (error) goto out; + + /* + * 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; } retval = error = 0; diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index d34ead2..4fd50ed 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2776,10 +2776,7 @@ xfs_attr3_leaf_clearflag( XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); } - /* - * Commit the flag value change and start the next trans in series. - */ - return xfs_trans_roll_inode(&args->trans, args->dp); + return 0; } /* From patchwork Thu Aug 27 00:28:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739725 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 18963722 for ; Thu, 27 Aug 2020 00:29:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 002CA2087D for ; Thu, 27 Aug 2020 00:29:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Elk9ov9C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726802AbgH0A3P (ORCPT ); Wed, 26 Aug 2020 20:29:15 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54102 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbgH0A3P (ORCPT ); Wed, 26 Aug 2020 20:29:15 -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 07R0E0wx045250 for ; Thu, 27 Aug 2020 00:29:14 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=kNp8Gm9A4HzP4lVYd6QQfLUB+O8Xi52GRMSYZW8BRK4=; b=Elk9ov9CvmgelXjQ8XYT32p8k9QsnMu80q6311xc9a+5OZ66/ClXtZno/HswQfWwp4SJ i9OCSjYQOFwrbYHcUXCry0/2Sj05Elkt5ugZSWxhfVc7BzDUPr7+n7pZbMNceNycfp8V PJtzQTLicrFjMjIVFGoX22rrjFRKN+apDKbEU2mI1tODauT+xElL0sShGNsw2fsReOUT yy3Z/1DOIXi/SbbshKf6xZELgb1hgHlcG2ra0oUPQhrS/l0SHR5diMyUjvWNw1iV7ThS r8g/UhfppgfFV+g7ISCFZc0wlWLxBOLtwo4kcKJE1L7H9zurYAQDFjWHtbhc/wPJHvTk Ag== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 333dbs3dx6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:14 +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 07R0AqW9025878 for ; Thu, 27 Aug 2020 00:29:13 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 333r9mswtn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:13 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TCns024799 for ; Thu, 27 Aug 2020 00:29:12 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:12 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 10/32] xfsprogs: Refactor xfs_attr_rmtval_remove Date: Wed, 26 Aug 2020 17:28:34 -0700 Message-Id: <20200827002856.1131-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Refactor xfs_attr_rmtval_remove to add helper function __xfs_attr_rmtval_remove. We will use this later when we introduce delayed attributes. This function will eventually replace xfs_attr_rmtval_remove Signed-off-by: Allison Collins Reviewed-by: Chandan Rajendra Reviewed-by: Brian Foster --- libxfs/xfs_attr_remote.c | 46 ++++++++++++++++++++++++++++++++++++---------- libxfs/xfs_attr_remote.h | 1 + 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index e09c1b6..52e5574 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -680,7 +680,7 @@ xfs_attr_rmtval_remove( xfs_dablk_t lblkno; int blkcnt; int error = 0; - int done = 0; + int retval = 0; trace_xfs_attr_rmtval_remove(args); @@ -692,14 +692,10 @@ xfs_attr_rmtval_remove( */ lblkno = args->rmtblkno; blkcnt = args->rmtblkcnt; - while (!done) { - error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, - XFS_BMAPI_ATTRFORK, 1, &done); - if (error) - return error; - error = xfs_defer_finish(&args->trans); - if (error) - return error; + do { + retval = __xfs_attr_rmtval_remove(args); + if (retval && retval != EAGAIN) + return retval; /* * Close out trans and start the next one in the chain. @@ -707,6 +703,36 @@ xfs_attr_rmtval_remove( error = xfs_trans_roll_inode(&args->trans, args->dp); if (error) return error; - } + } while (retval == -EAGAIN); + return 0; } + +/* + * 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 + */ +int +__xfs_attr_rmtval_remove( + struct xfs_da_args *args) +{ + int error, done; + + /* + * Unmap value blocks for this attr. + */ + error = xfs_bunmapi(args->trans, args->dp, args->rmtblkno, + args->rmtblkcnt, XFS_BMAPI_ATTRFORK, 1, &done); + if (error) + return error; + + error = xfs_defer_finish(&args->trans); + if (error) + return error; + + if (!done) + return -EAGAIN; + + return error; +} diff --git a/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index 3616e88..9eee615 100644 --- a/libxfs/xfs_attr_remote.h +++ b/libxfs/xfs_attr_remote.h @@ -14,4 +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); #endif /* __XFS_ATTR_REMOTE_H__ */ From patchwork Thu Aug 27 00:28:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739729 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 56E91722 for ; Thu, 27 Aug 2020 00:29:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F3AE2087D for ; Thu, 27 Aug 2020 00:29:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="S842yLTf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726838AbgH0A3Q (ORCPT ); Wed, 26 Aug 2020 20:29:16 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:54630 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgH0A3Q (ORCPT ); Wed, 26 Aug 2020 20:29:16 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07R0T1MC022065 for ; Thu, 27 Aug 2020 00:29:15 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=OLteAmIH0pa7vtnc7iU/vhqCxyprbIox1L6/aLKxvX8=; b=S842yLTfkIu5ELJPXBKJ3WYbZBRP6rK/PtoGzJAq4RzhTCkv9btjPvE+RTZcQr/c4S4u 4eT9j0dKU5v1mY7HGeVCFTXGEM6SnVk2mSjS/qhzjpZI6IVU9ytfjGrlVY1DjlmpBWc0 RgbNG5YcAD5BUPiNyWhC1+BkDhrrwZ60PAP6QQTNIYNUvjE6Sn7NSC9LiLAwu3YPFK/s L6HbUzHmvUilFnr3e3ST31gniJQ0SUow0ObQO930QbYZFyv4Y2nXOD8+Z3ijiSPqLfGA 7nJfJ8X5Mz8yDdpF4q7PIt6TORkYPIUx2O4bCpsQkaI+O6H/KbPS9KNm7T0K7D2ZW1Bv Cg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 335gw859dm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:14 +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 07R0AqWA025878 for ; Thu, 27 Aug 2020 00:29:14 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 333r9mswts-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:14 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07R0TCp7019244 for ; Thu, 27 Aug 2020 00:29:13 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:12 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 11/32] xfsprogs: Pull up xfs_attr_rmtval_invalidate Date: Wed, 26 Aug 2020 17:28:35 -0700 Message-Id: <20200827002856.1131-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch pulls xfs_attr_rmtval_invalidate out of xfs_attr_rmtval_remove and into the calling functions. Eventually __xfs_attr_rmtval_remove will replace xfs_attr_rmtval_remove when we introduce delayed attributes. These functions are exepcted to return -EAGAIN when they need a new transaction. Because the invalidate does not need a new transaction, we need to separate it from the rest of the function that does. This will enable __xfs_attr_rmtval_remove to smoothly replace xfs_attr_rmtval_remove later. Signed-off-by: Allison Collins Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong --- libxfs/xfs_attr.c | 12 ++++++++++++ libxfs/xfs_attr_remote.c | 3 --- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index b472c95..310b925 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -670,6 +670,10 @@ xfs_attr_leaf_addname( args->rmtblkcnt = args->rmtblkcnt2; args->rmtvaluelen = args->rmtvaluelen2; if (args->rmtblkno) { + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + error = xfs_attr_rmtval_remove(args); if (error) return error; @@ -1028,6 +1032,10 @@ restart: args->rmtblkcnt = args->rmtblkcnt2; args->rmtvaluelen = args->rmtvaluelen2; if (args->rmtblkno) { + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + error = xfs_attr_rmtval_remove(args); if (error) return error; @@ -1153,6 +1161,10 @@ xfs_attr_node_removename( if (error) goto out; + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + error = xfs_attr_rmtval_remove(args); if (error) goto out; diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 52e5574..07b7193 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -684,9 +684,6 @@ xfs_attr_rmtval_remove( trace_xfs_attr_rmtval_remove(args); - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; /* * Keep de-allocating extents until the remote-value region is gone. */ From patchwork Thu Aug 27 00:28:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739741 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 EA99E722 for ; Thu, 27 Aug 2020 00:29:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D11A82087D for ; Thu, 27 Aug 2020 00:29:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="pCq8v2EL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726882AbgH0A3V (ORCPT ); Wed, 26 Aug 2020 20:29:21 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37736 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgH0A3T (ORCPT ); Wed, 26 Aug 2020 20:29: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 07R0TIDs165395 for ; Thu, 27 Aug 2020 00:29: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=yoAkyTnt2lENWm854HDxxaVxNZsPcpWwzPUNl6Z3pWo=; b=pCq8v2ELjqlMAkxcyyOibZTaQn/sUcHrUrnzNXF0CVdkaplGhUsZGvrLXM0izTSL3uZ9 N5TVu7qmbLnpI13jcyvpmOfyRpIMba4CLx9G+iOuPLOVNSog0tvgX1kQ4lqjEbWnebFx cH/c+ky/PN1LfqBgZI8+ckHCLHmB2NTVLN8XufgzeyZ8wklVhCbUiVRQCExFQ4uONaZq 0ETIIKpTp/q/zq7kXqwc7aYh/vuvwx91Izi/TeDesWqFioLlMhr/1bOSbLuIRQHfwiJv jIr4F6AZfGO8zrytf+rQpd1chi/vWW5iJ/Bw2Sfj5GnOvo/LlNoLucD1HHHmumoWKPx/ JQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 333w6u1yvy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29: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 07R0BM5L038033 for ; Thu, 27 Aug 2020 00:29:14 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 333r9mk52x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:13 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TDpI024802 for ; Thu, 27 Aug 2020 00:29:13 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:13 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 12/32] xfsprogs: Add helper function xfs_attr_node_shrink Date: Wed, 26 Aug 2020 17:28:36 -0700 Message-Id: <20200827002856.1131-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=1 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds a new helper function xfs_attr_node_shrink used to shrink an attr name into an inode if it is small enough. This helps to modularize the greater calling function xfs_attr_node_removename. Signed-off-by: Allison Collins Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- libxfs/xfs_attr.c | 68 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 310b925..bd96bc4 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1109,6 +1109,45 @@ out: } /* + * Shrink an attribute from leaf to shortform + */ +STATIC int +xfs_attr_node_shrink( + struct xfs_da_args *args, + struct xfs_da_state *state) +{ + struct xfs_inode *dp = args->dp; + int error, forkoff; + struct xfs_buf *bp; + + /* + * Have to get rid of the copy of this dabuf in the state. + */ + ASSERT(state->path.active == 1); + ASSERT(state->path.blk[0].bp); + state->path.blk[0].bp = NULL; + + error = xfs_attr3_leaf_read(args->trans, args->dp, 0, &bp); + if (error) + return error; + + forkoff = xfs_attr_shortform_allfit(bp, dp); + if (forkoff) { + error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); + /* bp is gone due to xfs_da_shrink_inode */ + if (error) + return error; + + error = xfs_defer_finish(&args->trans); + if (error) + return error; + } else + xfs_trans_brelse(args->trans, bp); + + return 0; +} + +/* * Remove a name from a B-tree attribute list. * * This will involve walking down the Btree, and may involve joining @@ -1121,8 +1160,7 @@ xfs_attr_node_removename( { struct xfs_da_state *state; struct xfs_da_state_blk *blk; - struct xfs_buf *bp; - int retval, error, forkoff; + int retval, error; struct xfs_inode *dp = args->dp; trace_xfs_attr_node_removename(args); @@ -1207,30 +1245,8 @@ xfs_attr_node_removename( /* * If the result is small enough, push it all into the inode. */ - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - /* - * Have to get rid of the copy of this dabuf in the state. - */ - ASSERT(state->path.active == 1); - ASSERT(state->path.blk[0].bp); - state->path.blk[0].bp = NULL; - - error = xfs_attr3_leaf_read(args->trans, args->dp, 0, &bp); - if (error) - goto out; - - if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { - error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); - /* bp is gone due to xfs_da_shrink_inode */ - if (error) - goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; - } else - xfs_trans_brelse(args->trans, bp); - } - error = 0; + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) + error = xfs_attr_node_shrink(args, state); out: if (state) From patchwork Thu Aug 27 00:28:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739727 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 004C414E5 for ; Thu, 27 Aug 2020 00:29:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB2EB2087D for ; Thu, 27 Aug 2020 00:29:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="cOScAtzg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbgH0A3Q (ORCPT ); Wed, 26 Aug 2020 20:29:16 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:54632 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726838AbgH0A3Q (ORCPT ); Wed, 26 Aug 2020 20:29:16 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07R0SwaT022042 for ; Thu, 27 Aug 2020 00:29:15 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=+lABhNFxL2DSeDCO96nC5CV4Gijn9hrJV8omwq+iXgI=; b=cOScAtzgMblH/MFwbS2Z9HNCfl6uLBZThdD0Xu3+iHL8s7QXZqJ75v1KOdNeQt+3HBSt b2dc1qM3U0mtAbBqe9IGsRkQplf4mpOJB6k0RgsT/qJiLqAbPIntRhieaSASeiMgMBGl kuB3v2gPtcPZKWbdu7InbjK1w/YL4uwnyDFsaFTMpYrzuCkwaID/EB3+/6GEMJulEr9+ 5M1XMMuzTUuAe8SpydLwlWXQFrD8MSIeESOKHoPKszGU1JxEeeFrl8EKrZsPQmUEaPUQ d1YbnP775QMJqVa9LcUMCtrQ46rCdwa9fFvm6ZUMa2864HNBnuCDVCsGzWOgOBiL5eAj 9g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 335gw859dn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:14 +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 07R0AHkY121689 for ; Thu, 27 Aug 2020 00:29:14 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 333rubkg51-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:14 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TDV8016894 for ; Thu, 27 Aug 2020 00:29:13 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:13 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 13/32] xfsprogs: Remove unneeded xfs_trans_roll_inode calls Date: Wed, 26 Aug 2020 17:28:37 -0700 Message-Id: <20200827002856.1131-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=1 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Some calls to xfs_trans_roll_inode and xfs_defer_finish routines are not needed. If they are the last operations executed in these functions, and no further changes are made, then higher level routines will roll or commit the transactions. Signed-off-by: Allison Collins Reviewed-by: Brian Foster --- libxfs/xfs_attr.c | 61 +++++++------------------------------------------------ 1 file changed, 7 insertions(+), 54 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index bd96bc4..808c4c3 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -693,34 +693,15 @@ xfs_attr_leaf_addname( /* * If the result is small enough, shrink it all into the inode. */ - if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { + forkoff = xfs_attr_shortform_allfit(bp, dp); + if (forkoff) error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ - if (error) - return error; - error = xfs_defer_finish(&args->trans); - if (error) - return error; - } - - /* - * Commit the remove and start the next trans in series. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - } else if (args->rmtblkno > 0) { /* * Added a "remote" value, just clear the incomplete flag. */ error = xfs_attr3_leaf_clearflag(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); } return error; } @@ -780,15 +761,11 @@ xfs_attr_leaf_removename( /* * If the result is small enough, shrink it all into the inode. */ - if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { - error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); + forkoff = xfs_attr_shortform_allfit(bp, dp); + if (forkoff) + return xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ - if (error) - return error; - error = xfs_defer_finish(&args->trans); - if (error) - return error; - } + return 0; } @@ -1070,18 +1047,8 @@ restart: error = xfs_da3_join(state); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; } - /* - * Commit and start the next trans in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - } else if (args->rmtblkno > 0) { /* * Added a "remote" value, just clear the incomplete flag. @@ -1089,14 +1056,6 @@ restart: error = xfs_attr3_leaf_clearflag(args); if (error) goto out; - - /* - * 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; } retval = error = 0; @@ -1135,16 +1094,10 @@ xfs_attr_node_shrink( if (forkoff) { error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ - if (error) - return error; - - error = xfs_defer_finish(&args->trans); - if (error) - return error; } else xfs_trans_brelse(args->trans, bp); - return 0; + return error; } /* From patchwork Thu Aug 27 00:28:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739761 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 515EC913 for ; Thu, 27 Aug 2020 00:31:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39AC0207CD for ; Thu, 27 Aug 2020 00:31:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="o447VpyT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727001AbgH0AbQ (ORCPT ); Wed, 26 Aug 2020 20:31:16 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:55408 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbgH0AbQ (ORCPT ); Wed, 26 Aug 2020 20:31:16 -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 07R0U9gr068755 for ; Thu, 27 Aug 2020 00:31:15 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=d5cZTCslKLc621hhs0W+Z55MQQ0pKkkxDakAKaeREbE=; b=o447VpyTiZjEjjGebLwmBrkfprKj7SrpXntizgTHCF21c/npWlEhF803eSEfYw/29cYn a/i95qwXquZof6XklNlAvjbUgpv1bJ6zKEMFzt7JIfQs+ATU2pnZSeQsTFeQEO+IxH8D FhKQm0ifF7kwpTfPoKdkBaFLc6e2L4ByfNuZuwKbIeAPz6l7DdOwZIkvYsgnduH9u8wU vJDwhj8GYcvW5c74ARaBX5O8xTPRuEJMl1WvUfOMW4xs4DNLdNd/HyQFOoXsKALFkWxU avCLsQmpLZKvAQMw0j6Bd3//iUliLPkLkAiGYcqeevgqoRzDwMhGtTYV9tcJEfLkqQYV bA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 333dbs3e2v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:31:15 +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 07R0AfEv127392 for ; Thu, 27 Aug 2020 00:29:14 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 333ru0t3bx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:14 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07R0TEUT019293 for ; Thu, 27 Aug 2020 00:29:14 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:13 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 14/32] xfsprogs: Remove xfs_trans_roll in xfs_attr_node_removename Date: Wed, 26 Aug 2020 17:28:38 -0700 Message-Id: <20200827002856.1131-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org A transaction roll is not necessary immediately after setting the INCOMPLETE flag when removing a node xattr entry with remote value blocks. The remote block invalidation that immediately follows setting the flag is an in-core only change. The next step after that is to start unmapping the remote blocks from the attr fork, but the xattr remove transaction reservation includes reservation for full tree splits of the dabtree and bmap tree. The remote block unmap code will roll the transaction as extents are unmapped and freed. Signed-off-by: Allison Collins Reviewed-by: Brian Foster --- libxfs/xfs_attr.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 808c4c3..8bfd580 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1148,10 +1148,6 @@ xfs_attr_node_removename( if (error) goto out; - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - goto out; - error = xfs_attr_rmtval_invalidate(args); if (error) return error; From patchwork Thu Aug 27 00:28:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739765 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 746921751 for ; Thu, 27 Aug 2020 00:31:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B4A0207CD for ; Thu, 27 Aug 2020 00:31:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="KAMCixCJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726998AbgH0AbT (ORCPT ); Wed, 26 Aug 2020 20:31:19 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38848 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727000AbgH0AbR (ORCPT ); Wed, 26 Aug 2020 20:31:17 -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 07R0TTkt165479 for ; Thu, 27 Aug 2020 00:31:16 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=DkIlMXMvYx/qqxyaTbrFH6BPXK6JVxlAQCJqZ735LE4=; b=KAMCixCJfZWi1Ppv5Cic5fZmi+9KLygiWyAAxinKO9gPRIfZ0wpHTgwtNEPcMPlEFqtv K0r8ROWoa8yhsH3Po49q1hLTkiWJDxm2R9P26qKtDwWBgM+uF47EyaT+YvNnrKWLtxM7 +6hk43Gdt5OMGTO/6ORTB9yiAUfYVxaQsTl5PcdkZk8W0GlvG6o+vVeNQNI2MnvuAjUR Gjsv5hmx95NoJZNIbZPmM4LelOv2S38fl1Qa6oJ9w6vA/Cax4lopY6NZseC25qxWtGep 5BiOkvMthuily9Ip8Z9+KnbClY32xCRb5FjrjtHcIO3GApB88c1YXMaUQDU5SFd+FPgm ig== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 333w6u201q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:31:16 +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 07R0AHIW121671 for ; Thu, 27 Aug 2020 00:29:15 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 333rubkg67-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:15 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07R0TEPI019298 for ; Thu, 27 Aug 2020 00:29:14 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:14 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 15/32] xfsprogs: Add helpers xfs_attr_is_shortform and xfs_attr_set_shortform Date: Wed, 26 Aug 2020 17:28:39 -0700 Message-Id: <20200827002856.1131-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=1 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org In this patch, we hoist code from xfs_attr_set_args into two new helpers xfs_attr_is_shortform and xfs_attr_set_shortform. These two will help to simplify xfs_attr_set_args when we get into delayed attrs later. Signed-off-by: Allison Collins Reviewed-by: Brian Foster Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong --- libxfs/xfs_attr.c | 107 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 35 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 8bfd580..07c0614 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -204,6 +204,66 @@ xfs_attr_try_sf_addname( } /* + * Check to see if the attr should be upgraded from non-existent or shortform to + * single-leaf-block attribute list. + */ +static inline bool +xfs_attr_is_shortform( + struct xfs_inode *ip) +{ + return ip->i_afp->if_format == XFS_DINODE_FMT_LOCAL || + (ip->i_afp->if_format == XFS_DINODE_FMT_EXTENTS && + ip->i_afp->if_nextents == 0); +} + +/* + * 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. + */ +STATIC int +xfs_attr_set_shortform( + struct xfs_da_args *args, + struct xfs_buf **leaf_bp) +{ + struct xfs_inode *dp = args->dp; + int error, error2 = 0; + + /* + * Try to add the attr to the attribute list in the inode. + */ + error = xfs_attr_try_sf_addname(dp, args); + if (error != -ENOSPC) { + error2 = xfs_trans_commit(args->trans); + args->trans = NULL; + return error ? error : error2; + } + /* + * It won't fit in the shortform, transform to a leaf block. GROT: + * another possible req'mt for a double-split btree op. + */ + error = xfs_attr_shortform_to_leaf(args, leaf_bp); + if (error) + return error; + + /* + * 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. + */ + 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; +} + +/* * Set the attribute specified in @args. */ int @@ -212,48 +272,25 @@ xfs_attr_set_args( { struct xfs_inode *dp = args->dp; struct xfs_buf *leaf_bp = NULL; - int error, error2 = 0; + int error = 0; /* - * If the attribute list is non-existent or a shortform list, - * upgrade it to a single-leaf-block attribute list. + * 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. */ - if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL || - (dp->i_afp->if_format == XFS_DINODE_FMT_EXTENTS && - dp->i_afp->if_nextents == 0)) { + if (xfs_attr_is_shortform(dp)) { /* - * Try to add the attr to the attribute list in the inode. + * 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. */ - error = xfs_attr_try_sf_addname(dp, args); - if (error != -ENOSPC) { - error2 = xfs_trans_commit(args->trans); - args->trans = NULL; - return error ? error : error2; - } - - /* - * It won't fit in the shortform, transform to a leaf block. - * GROT: another possible req'mt for a double-split btree op. - */ - error = xfs_attr_shortform_to_leaf(args, &leaf_bp); - if (error) - return error; - - /* - * 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. - */ - 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); + error = xfs_attr_set_shortform(args, &leaf_bp); + if (error || !args->trans) return error; - } } if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { From patchwork Thu Aug 27 00:28:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739763 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 43D5F722 for ; Thu, 27 Aug 2020 00:31:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27EB220786 for ; Thu, 27 Aug 2020 00:31:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="NOBetaAT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726444AbgH0AbR (ORCPT ); Wed, 26 Aug 2020 20:31:17 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38846 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726998AbgH0AbR (ORCPT ); Wed, 26 Aug 2020 20:31:17 -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 07R0U0Ws165561 for ; Thu, 27 Aug 2020 00:31:16 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=S6aNBUz3Fszfbtv01QuNGGU1bzWYIPWn4oHQPYwBAc4=; b=NOBetaATOrfRkDZ+X4b8OMWwptpZJNCjOx3jh+CGL1tSeBL1fXuxODi5nk7CJTbwik9G cOYi1K+B8QDyTKEz9qIBlKLko9LwCJLiimAN4xQvb+9TEfTg3ydHQrng5lzt9TiprjFN pZhXBZJXMVj7z9KQts6eg4Bb/8IJeaSfsbUdECvCybqNrTi44dyll8EtDlmk7BKUTn3e njzk/hsBIhh394Dk6Uj18ti9L7EJ2TlVILYdrEzMVJJu464MUeazPKlHlKvOuguw1FOT Xqe9EkXcRkm8ih7Itl2l8Q08FiHDd1pWR9XGlo1jOfACmiNNERb5MGeI9MqYpq6bWPHD FQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 333w6u201r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:31:16 +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 07R0BNVP038170 for ; Thu, 27 Aug 2020 00:29:15 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 333r9mk53c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:15 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07R0TExJ019005 for ; Thu, 27 Aug 2020 00:29:14 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:14 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 16/32] xfsprogs: Add helper function xfs_attr_leaf_mark_incomplete Date: Wed, 26 Aug 2020 17:28:40 -0700 Message-Id: <20200827002856.1131-17-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=1 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch helps to simplify xfs_attr_node_removename by modularizing the code around the transactions into helper functions. This will make the function easier to follow when we introduce delayed attributes. Signed-off-by: Allison Collins Reviewed-by: Amir Goldstein Reviewed-by: Chandan Rajendra Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong --- libxfs/xfs_attr.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 07c0614..11fc469 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1138,6 +1138,32 @@ xfs_attr_node_shrink( } /* + * Mark an attribute entry INCOMPLETE and save pointers to the relevant buffers + * for later deletion of the entry. + */ +STATIC int +xfs_attr_leaf_mark_incomplete( + struct xfs_da_args *args, + struct xfs_da_state *state) +{ + int error; + + /* + * Fill in disk block numbers in the state structure + * so that we can get the buffers back after we commit + * several transactions in the following calls. + */ + error = xfs_attr_fillstate(state); + if (error) + return error; + + /* + * Mark the attribute as INCOMPLETE + */ + return xfs_attr3_leaf_setflag(args); +} + +/* * Remove a name from a B-tree attribute list. * * This will involve walking down the Btree, and may involve joining @@ -1168,20 +1194,7 @@ xfs_attr_node_removename( ASSERT(blk->bp != NULL); ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); if (args->rmtblkno > 0) { - /* - * Fill in disk block numbers in the state structure - * so that we can get the buffers back after we commit - * several transactions in the following calls. - */ - error = xfs_attr_fillstate(state); - if (error) - goto out; - - /* - * Mark the attribute as INCOMPLETE, then bunmapi() the - * remote value. - */ - error = xfs_attr3_leaf_setflag(args); + error = xfs_attr_leaf_mark_incomplete(args, state); if (error) goto out; From patchwork Thu Aug 27 00:28:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739737 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 09914722 for ; Thu, 27 Aug 2020 00:29:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E44FE20B1F for ; Thu, 27 Aug 2020 00:29:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="FEI0XfYZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726903AbgH0A3U (ORCPT ); Wed, 26 Aug 2020 20:29:20 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37740 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726880AbgH0A3U (ORCPT ); Wed, 26 Aug 2020 20:29: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 07R0TIgV165398 for ; Thu, 27 Aug 2020 00:29: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=voPYxhxdm1WNeMd9tSikSTqQ0t+Fj2LTASAcXXVeiGQ=; b=FEI0XfYZGfiqZm/cIaAx+6iFzR41XHpiwXxoSYzecLaeJ/S8jT687C0s0gv0Dm/4xHol 1730V+MWCZRzMYv4zVIS+tiXRB07PJwNWJ5EUenTk50/zp7l/P3GStQVoBOgPR7+cpYd j3Q3PMKGaQ/eKqfswqlMWTXXcHvSZ/QCmB8/b+9ibQhIF9H7n/IBF9k+P3a6p5is2k+Z thEpG8eO3Vur6znO6vZJaQKEDGGWdirqwKhpueYYDiA17L7gGObnJJ6U5W1GbopeSrMc to7cdkygES1ezk4xLRoIsjCYRIpQ61guyfsDKRepa9YSxc4Alox1jkZaNRfVWP7RT7H6 pA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 333w6u1yw4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:18 +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 07R0AfVb127471 for ; Thu, 27 Aug 2020 00:29:16 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 333ru0t3c9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:16 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TFiO016897 for ; Thu, 27 Aug 2020 00:29:15 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:15 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 17/32] xfsprogs: Add remote block helper functions Date: Wed, 26 Aug 2020 17:28:41 -0700 Message-Id: <20200827002856.1131-18-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds two new helper functions xfs_attr_store_rmt_blk and xfs_attr_restore_rmt_blk. These two helpers assist to remove redundant code associated with storing and retrieving remote blocks during the attr set operations. Signed-off-by: Allison Collins Reviewed-by: Chandan Rajendra Reviewed-by: Amir Goldstein Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong --- libxfs/xfs_attr.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 11fc469..6f9fa9e 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -564,6 +564,30 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) * External routines when attribute list is one block *========================================================================*/ +/* Store info about a remote block */ +STATIC void +xfs_attr_save_rmt_blk( + struct xfs_da_args *args) +{ + args->blkno2 = args->blkno; + args->index2 = args->index; + args->rmtblkno2 = args->rmtblkno; + args->rmtblkcnt2 = args->rmtblkcnt; + args->rmtvaluelen2 = args->rmtvaluelen; +} + +/* Set stored info about a remote block */ +STATIC void +xfs_attr_restore_rmt_blk( + struct xfs_da_args *args) +{ + args->blkno = args->blkno2; + args->index = args->index2; + args->rmtblkno = args->rmtblkno2; + args->rmtblkcnt = args->rmtblkcnt2; + args->rmtvaluelen = args->rmtvaluelen2; +} + /* * Tries to add an attribute to an inode in leaf form * @@ -598,11 +622,7 @@ xfs_attr_leaf_try_add( /* save the attribute state for later removal*/ args->op_flags |= XFS_DA_OP_RENAME; /* an atomic rename */ - args->blkno2 = args->blkno; /* set 2nd entry info*/ - args->index2 = args->index; - args->rmtblkno2 = args->rmtblkno; - args->rmtblkcnt2 = args->rmtblkcnt; - args->rmtvaluelen2 = args->rmtvaluelen; + xfs_attr_save_rmt_blk(args); /* * clear the remote attr state now that it is saved so that the @@ -701,11 +721,8 @@ xfs_attr_leaf_addname( * Dismantle the "old" attribute/value pair by removing * a "remote" value (if it exists). */ - args->index = args->index2; - args->blkno = args->blkno2; - args->rmtblkno = args->rmtblkno2; - args->rmtblkcnt = args->rmtblkcnt2; - args->rmtvaluelen = args->rmtvaluelen2; + xfs_attr_restore_rmt_blk(args); + if (args->rmtblkno) { error = xfs_attr_rmtval_invalidate(args); if (error) @@ -924,11 +941,7 @@ restart: /* save the attribute state for later removal*/ args->op_flags |= XFS_DA_OP_RENAME; /* atomic rename op */ - args->blkno2 = args->blkno; /* set 2nd entry info*/ - args->index2 = args->index; - args->rmtblkno2 = args->rmtblkno; - args->rmtblkcnt2 = args->rmtblkcnt; - args->rmtvaluelen2 = args->rmtvaluelen; + xfs_attr_save_rmt_blk(args); /* * clear the remote attr state now that it is saved so that the @@ -1040,11 +1053,8 @@ restart: * Dismantle the "old" attribute/value pair by removing * a "remote" value (if it exists). */ - args->index = args->index2; - args->blkno = args->blkno2; - args->rmtblkno = args->rmtblkno2; - args->rmtblkcnt = args->rmtblkcnt2; - args->rmtvaluelen = args->rmtvaluelen2; + xfs_attr_restore_rmt_blk(args); + if (args->rmtblkno) { error = xfs_attr_rmtval_invalidate(args); if (error) From patchwork Thu Aug 27 00:28:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739731 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 261DD14E5 for ; Thu, 27 Aug 2020 00:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1049D208E4 for ; Thu, 27 Aug 2020 00:29:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="i4hqsC1w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbgH0A3S (ORCPT ); Wed, 26 Aug 2020 20:29:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:54648 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726851AbgH0A3S (ORCPT ); Wed, 26 Aug 2020 20:29:18 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07R0SaNS021960 for ; Thu, 27 Aug 2020 00:29:17 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=uXbfJmUnN44Ai1eQhOeLwRwjnjMKRcvCpZPnwnwFrsY=; b=i4hqsC1wqLHn4dprs58Iep9MZhMwvna911alGzwixvMUn9U2tx6O4YZ0Wt8X83qm+3aO YrvU7mEwjFX/r/G7EdAPpM2XimgYOloI+2sM1V5CgdniAzz3u+p+t6MizHkb3cf2ICxK E7PoEunxao3T3JzzbmBFcfUtBOuLzCjOOiRDHY+mG+dj+DYkw84H8FaeFdKFyYQACrbG NiCDwXDe4008CrwAXehX4iJbgNvU53ASTzT5zQrD1Qa0ysF3sjqKVwJi1lIPI/jSGI3V 5i+H0Mvlp9C58wAROJ7nC+nFfNdszKA9aQJXJFN8d1TsXVKMEa7D7QaW0+ztg3XUpRFs fA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 335gw859dt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:16 +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 07R0BMfj038046 for ; Thu, 27 Aug 2020 00:29:16 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 333r9mk53h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:16 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07R0TFsu019010 for ; Thu, 27 Aug 2020 00:29:15 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:15 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 18/32] xfsprogs: Add helper function xfs_attr_node_removename_setup Date: Wed, 26 Aug 2020 17:28:42 -0700 Message-Id: <20200827002856.1131-19-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=1 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds a new helper function xfs_attr_node_removename_setup. This will help modularize xfs_attr_node_removename when we add delay ready attributes later. Signed-off-by: Allison Collins Reviewed-by: Brian Foster Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong --- libxfs/xfs_attr.c | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 6f9fa9e..4d1ab1e 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1174,6 +1174,38 @@ xfs_attr_leaf_mark_incomplete( } /* + * Initial setup for xfs_attr_node_removename. Make sure the attr is there and + * the blocks are valid. Attr keys with remote blocks will be marked + * incomplete. + */ +STATIC +int xfs_attr_node_removename_setup( + struct xfs_da_args *args, + struct xfs_da_state **state) +{ + int error; + struct xfs_da_state_blk *blk; + + error = xfs_attr_node_hasname(args, state); + if (error != -EEXIST) + return error; + + blk = &(*state)->path.blk[(*state)->path.active - 1]; + ASSERT(blk->bp != NULL); + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + + if (args->rmtblkno > 0) { + error = xfs_attr_leaf_mark_incomplete(args, *state); + if (error) + return error; + + return xfs_attr_rmtval_invalidate(args); + } + + return 0; +} + +/* * Remove a name from a B-tree attribute list. * * This will involve walking down the Btree, and may involve joining @@ -1191,8 +1223,8 @@ xfs_attr_node_removename( trace_xfs_attr_node_removename(args); - error = xfs_attr_node_hasname(args, &state); - if (error != -EEXIST) + error = xfs_attr_node_removename_setup(args, &state); + if (error) goto out; /* @@ -1200,18 +1232,7 @@ xfs_attr_node_removename( * This is done before we remove the attribute so that we don't * overflow the maximum size of a transaction and/or hit a deadlock. */ - blk = &state->path.blk[ state->path.active-1 ]; - ASSERT(blk->bp != NULL); - ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); if (args->rmtblkno > 0) { - error = xfs_attr_leaf_mark_incomplete(args, state); - if (error) - goto out; - - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; - error = xfs_attr_rmtval_remove(args); if (error) goto out; From patchwork Thu Aug 27 00:28:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739735 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 B6434722 for ; Thu, 27 Aug 2020 00:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DCD22087D for ; Thu, 27 Aug 2020 00:29:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="WncOtXUW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726876AbgH0A3T (ORCPT ); Wed, 26 Aug 2020 20:29:19 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:54652 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726856AbgH0A3S (ORCPT ); Wed, 26 Aug 2020 20:29:18 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07R0T0BH022056 for ; Thu, 27 Aug 2020 00:29:17 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=H+m+HE4aUYwyCvKHp3qvsJ+m7cE6Xx34My48qCvqsso=; b=WncOtXUWvUY04+qA6iXAIKObIfe3LqU2Rli4PM9+x0Hvf3YycIVcQAUvqWOjVv73gWRr gQ0VRaILSGXmLmG0UQxMQA2psMx56QlOpV9oMjE4U/+Wic6Q+7Eb+EuriAkRV3W5gN0f C1nS0+L0g3eKwQvbvURd6p0ESEleS7epxoFyQO0gOSOi6RlVqJWX2cxbbuepMCxlABnj tLez42lZCJ1wjK44BzIeIHHr/vwuafjf1Am5vtVLNPTEEBu2b0QODJFuLw4t/4dQNBFq 9mlicEfEbZZwvzUL2Pm7fgc2l8W5SZxtU2DKn/4E1RaktWfiNODqhuztrB9QwDYndYtM ZA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 335gw859ds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:17 +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 07R0AIFk121927 for ; Thu, 27 Aug 2020 00:29:16 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 333rubkg7j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:16 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TFmH016900 for ; Thu, 27 Aug 2020 00:29:15 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:15 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 19/32] xfsprogs: Add helper function xfs_attr_node_removename_rmt Date: Wed, 26 Aug 2020 17:28:43 -0700 Message-Id: <20200827002856.1131-20-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=1 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds another new helper function xfs_attr_node_removename_rmt. This will also help modularize xfs_attr_node_removename when we add delay ready attributes later. Signed-off-by: Allison Collins Reviewed-by: Brian Foster Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong --- libxfs/xfs_attr.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 4d1ab1e..8ce1ec0 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1205,6 +1205,24 @@ int xfs_attr_node_removename_setup( return 0; } +STATIC int +xfs_attr_node_remove_rmt( + struct xfs_da_args *args, + struct xfs_da_state *state) +{ + int error = 0; + + error = xfs_attr_rmtval_remove(args); + if (error) + return error; + + /* + * Refill the state structure with buffers, the prior calls released our + * buffers. + */ + return xfs_attr_refillstate(state); +} + /* * Remove a name from a B-tree attribute list. * @@ -1233,15 +1251,7 @@ xfs_attr_node_removename( * overflow the maximum size of a transaction and/or hit a deadlock. */ if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_remove(args); - if (error) - goto out; - - /* - * Refill the state structure with buffers, the prior calls - * released our buffers. - */ - error = xfs_attr_refillstate(state); + error = xfs_attr_node_remove_rmt(args, state); if (error) goto out; } From patchwork Thu Aug 27 00:28:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739733 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 5E4751751 for ; Thu, 27 Aug 2020 00:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46624208E4 for ; Thu, 27 Aug 2020 00:29:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="QwcTwz8I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbgH0A3S (ORCPT ); Wed, 26 Aug 2020 20:29:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:54658 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgH0A3S (ORCPT ); Wed, 26 Aug 2020 20:29:18 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07R0SwnL022029 for ; Thu, 27 Aug 2020 00:29:17 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=zMCwaqgvfzLkg/XYl3Nuw768dA6Dc7QLx7PK4Ip8+rg=; b=QwcTwz8IRb83vTMOomfz+40vb1byyDBuKn3ke3r/FEF1MRF8ZgIESIxUah4tOtKnYqz1 Pkv21P1bUpqXyHpmf4bLdvtyXT1KUqF/e6oN003tV9De4rXzAWsUPIfj2yAfXkWdxaZg ph8SAcyv6Zq3/qFk1wG2XyOU6pIfxtD9E2SgvM91vXKQUm52uTRx/iz17OnlzMNzsHqT gTQg9DTReo2C6D3Q1e5iytcz53x9ZzyGX22cJN86PoUbTH8hMv5JosCL3DylI2KktKr7 IpKwbH11UBYHmoLMjRr31aJH+O0noqqBQ1p6oVJA4VSVsD8hFbEDqEhUnaaYk3K0ABLd Uw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 335gw859dv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:17 +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 07R0AHFD121641 for ; Thu, 27 Aug 2020 00:29:16 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 333rubkg7v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:16 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07R0TGXx019038 for ; Thu, 27 Aug 2020 00:29:16 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:16 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 20/32] xfsprogs: Simplify xfs_attr_leaf_addname Date: Wed, 26 Aug 2020 17:28:44 -0700 Message-Id: <20200827002856.1131-21-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=1 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Invert the rename logic in xfs_attr_leaf_addname to simplify the delayed attr logic later. Signed-off-by: Allison Collins Reviewed-by: Brian Foster --- libxfs/xfs_attr.c | 107 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 8ce1ec0..b4ad0eb 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -695,68 +695,71 @@ xfs_attr_leaf_addname( return error; } - /* - * If this is an atomic rename operation, we must "flip" the - * incomplete flags on the "new" and "old" attribute/value pairs - * so that one disappears and one appears atomically. Then we - * must remove the "old" attribute/value pair. - */ - if (args->op_flags & XFS_DA_OP_RENAME) { + if (!(args->op_flags & XFS_DA_OP_RENAME)) { /* - * 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. + * Added a "remote" value, just clear the incomplete flag. */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - return error; + if (args->rmtblkno > 0) + error = xfs_attr3_leaf_clearflag(args); - /* - * Dismantle the "old" attribute/value pair by removing - * a "remote" value (if it exists). - */ - xfs_attr_restore_rmt_blk(args); + return error; + } - if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; + /* + * If this is an atomic rename operation, we must "flip" the incomplete + * flags on the "new" and "old" attribute/value pairs so that one + * disappears and one appears atomically. Then we must remove the "old" + * attribute/value pair. + * + * In a separate transaction, set the incomplete flag on the "old" attr + * and clear the incomplete flag on the "new" attr. + */ - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - } + 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; - /* - * Read in the block containing the "old" attr, then - * remove the "old" attr from that block (neat, huh!) - */ - error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, - &bp); + /* + * Dismantle the "old" attribute/value pair by removing a "remote" value + * (if it exists). + */ + xfs_attr_restore_rmt_blk(args); + + if (args->rmtblkno) { + error = xfs_attr_rmtval_invalidate(args); if (error) return error; - xfs_attr3_leaf_remove(bp, args); - - /* - * If the result is small enough, shrink it all into the inode. - */ - forkoff = xfs_attr_shortform_allfit(bp, dp); - if (forkoff) - error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); - /* bp is gone due to xfs_da_shrink_inode */ - } else if (args->rmtblkno > 0) { - /* - * Added a "remote" value, just clear the incomplete flag. - */ - error = xfs_attr3_leaf_clearflag(args); + error = xfs_attr_rmtval_remove(args); + if (error) + return error; } + + /* + * Read in the block containing the "old" attr, then remove the "old" + * attr from that block (neat, huh!) + */ + error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, + &bp); + if (error) + return error; + + xfs_attr3_leaf_remove(bp, args); + + /* + * If the result is small enough, shrink it all into the inode. + */ + forkoff = xfs_attr_shortform_allfit(bp, dp); + if (forkoff) + error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); + /* bp is gone due to xfs_da_shrink_inode */ + return error; } From patchwork Thu Aug 27 00:28:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739739 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 95FB81751 for ; Thu, 27 Aug 2020 00:29:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AEC0208E4 for ; Thu, 27 Aug 2020 00:29:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="AIwTldU7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726880AbgH0A3U (ORCPT ); Wed, 26 Aug 2020 20:29:20 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54138 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726882AbgH0A3U (ORCPT ); Wed, 26 Aug 2020 20:29:20 -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 07R0Do21045155 for ; Thu, 27 Aug 2020 00:29: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; s=corp-2020-01-29; bh=y9gjkHS94Nt+KjIt7iPHyi0y3Rc7KRSa23fgK7rQ0Cw=; b=AIwTldU7uFbSXa/eQJUBw5dvKgsLatqe4ziqsdlNDBuw3jn0nWRQtL1Diy23DJZvcgFI 3mIs+bQuad8mINSfIHHK5hi6jH6uk0uOJj2Gk9Zbn4wODC1GgS9GKuqH0dnYSKzRVmjP vE8VVj1YSi9Q6Tz2RpKHx0HKlKbXGGSj09w8U2XwNJAcazm37CmY+MCvv3svYNBo5tI+ doS1pa9D/T3ZNMsZJE4ZcmrL9HKj01t5uc3QMCRciUlyDMTRY0hyZDqK4iaNj09N/6uw A6dWj1ujTI7+3AkqQsgeF045WAvwrvuuWx5iFupdkwkyStRguZEZIQJ+J9h6pOaq0VzE bw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 333dbs3dx7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29: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 07R0AqMH025881 for ; Thu, 27 Aug 2020 00:29:18 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 333r9mswvg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:18 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07R0TGeM019331 for ; Thu, 27 Aug 2020 00:29:17 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:16 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 21/32] xfsprogs: Simplify xfs_attr_node_addname Date: Wed, 26 Aug 2020 17:28:45 -0700 Message-Id: <20200827002856.1131-22-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Invert the rename logic in xfs_attr_node_addname to simplify the delayed attr logic later. Signed-off-by: Allison Collins Reviewed-by: Brian Foster --- libxfs/xfs_attr.c | 125 ++++++++++++++++++++++++++---------------------------- 1 file changed, 61 insertions(+), 64 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index b4ad0eb..592ba30 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1030,80 +1030,77 @@ restart: return error; } - /* - * If this is an atomic rename operation, we must "flip" the - * incomplete flags on the "new" and "old" attribute/value pairs - * so that one disappears and one appears atomically. Then we - * must remove the "old" attribute/value pair. - */ - if (args->op_flags & XFS_DA_OP_RENAME) { - /* - * 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) - goto out; + if (!(args->op_flags & XFS_DA_OP_RENAME)) { /* - * Commit the flag value change and start the next trans in - * series + * Added a "remote" value, just clear the incomplete flag. */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - goto out; + if (args->rmtblkno > 0) + error = xfs_attr3_leaf_clearflag(args); + retval = error; + goto out; + } - /* - * Dismantle the "old" attribute/value pair by removing - * a "remote" value (if it exists). - */ - xfs_attr_restore_rmt_blk(args); + /* + * If this is an atomic rename operation, we must "flip" the incomplete + * flags on the "new" and "old" attribute/value pairs so that one + * disappears and one appears atomically. Then we must remove the "old" + * attribute/value pair. + * + * 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) + goto out; + /* + * 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; - if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; + /* + * Dismantle the "old" attribute/value pair by removing a "remote" value + * (if it exists). + */ + xfs_attr_restore_rmt_blk(args); - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - } + if (args->rmtblkno) { + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; - /* - * Re-find the "old" attribute entry after any split ops. - * The INCOMPLETE flag means that we will find the "old" - * attr, not the "new" one. - */ - args->attr_filter |= XFS_ATTR_INCOMPLETE; - state = xfs_da_state_alloc(); - state->args = args; - state->mp = mp; - state->inleaf = 0; - error = xfs_da3_node_lookup_int(state, &retval); + error = xfs_attr_rmtval_remove(args); if (error) - goto out; + return error; + } - /* - * Remove the name and update the hashvals in the tree. - */ - blk = &state->path.blk[ state->path.active-1 ]; - ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); - error = xfs_attr3_leaf_remove(blk->bp, args); - xfs_da3_fixhashpath(state, &state->path); + /* + * Re-find the "old" attribute entry after any split ops. The INCOMPLETE + * flag means that we will find the "old" attr, not the "new" one. + */ + args->attr_filter |= XFS_ATTR_INCOMPLETE; + state = xfs_da_state_alloc(); + state->args = args; + state->mp = mp; + state->inleaf = 0; + error = xfs_da3_node_lookup_int(state, &retval); + if (error) + goto out; - /* - * Check to see if the tree needs to be collapsed. - */ - if (retval && (state->path.active > 1)) { - error = xfs_da3_join(state); - if (error) - goto out; - } + /* + * Remove the name and update the hashvals in the tree. + */ + blk = &state->path.blk[state->path.active-1]; + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + error = xfs_attr3_leaf_remove(blk->bp, args); + xfs_da3_fixhashpath(state, &state->path); - } else if (args->rmtblkno > 0) { - /* - * Added a "remote" value, just clear the incomplete flag. - */ - error = xfs_attr3_leaf_clearflag(args); + /* + * Check to see if the tree needs to be collapsed. + */ + if (retval && (state->path.active > 1)) { + error = xfs_da3_join(state); if (error) goto out; } From patchwork Thu Aug 27 00:28:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739743 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 3DF2717C7 for ; Thu, 27 Aug 2020 00:29:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 226702087D for ; Thu, 27 Aug 2020 00:29:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ykJI9a7t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726839AbgH0A3V (ORCPT ); Wed, 26 Aug 2020 20:29:21 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:54674 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726894AbgH0A3U (ORCPT ); Wed, 26 Aug 2020 20:29:20 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07R0TBg6022162 for ; Thu, 27 Aug 2020 00:29: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; s=corp-2020-01-29; bh=RNmmb6gqrXCYQyr/3829f9Hf8G7fCZTqs454omFtZwo=; b=ykJI9a7tL0l21Vg3tM3ZQkNKLz5TvTcrWUX0XD/bhqHBwC9b87bvkn6JEGzXMLZPMO0W pVGjScaA7/h2tIdoLBEIoZV6CEDTTqy0gj7iWvyjM4O2umJf6NdwamG6NQU8im8IsfXm vpCU+2Y2OqrmSdsHDrsyQODko38y031UZJgpYriWXJzkCXOUndkL/ZUUlJkLFcNJ+734 HyC8s1qHHe5pUjxCtO42QEONuVuhaFblgWBk/zkJJmcZ7lM1CGr1TQMwuIqE1NS+ozE1 SQVZNNR1O5xC+uirsLNS1ysimgaL4d4JrBMGXahuk9kgcqhvpU796aWlIbmKmi6wwvfS iA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 335gw859e1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29: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 07R0BME4038057 for ; Thu, 27 Aug 2020 00:29:18 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 333r9mk544-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:18 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07R0THaw019045 for ; Thu, 27 Aug 2020 00:29:17 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:17 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 22/32] xfsprogs: Lift -ENOSPC handler from xfs_attr_leaf_addname Date: Wed, 26 Aug 2020 17:28:46 -0700 Message-Id: <20200827002856.1131-23-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=1 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Lift -ENOSPC handler from xfs_attr_leaf_addname. This will help to reorganize transitions between the attr forms later. Signed-off-by: Allison Collins Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- libxfs/xfs_attr.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 592ba30..fc7de6b 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -299,6 +299,13 @@ xfs_attr_set_args( return error; /* + * 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, @@ -603,7 +610,7 @@ xfs_attr_leaf_try_add( struct xfs_da_args *args, struct xfs_buf *bp) { - int retval, error; + int retval; /* * Look up the given attribute in the leaf block. Figure out if @@ -635,20 +642,10 @@ xfs_attr_leaf_try_add( } /* - * Add the attribute to the leaf block, transitioning to a Btree - * if required. + * Add the attribute to the leaf block */ - retval = xfs_attr3_leaf_add(bp, args); - if (retval == -ENOSPC) { - /* - * Promote the attribute list to the Btree format. Unless an - * error occurs, retain the -ENOSPC retval - */ - error = xfs_attr3_leaf_to_node(args); - if (error) - return error; - } - return retval; + return xfs_attr3_leaf_add(bp, args); + out_brelse: xfs_trans_brelse(args->trans, bp); return retval; From patchwork Thu Aug 27 00:28:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739753 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 157411751 for ; Thu, 27 Aug 2020 00:29:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBBFD214F1 for ; Thu, 27 Aug 2020 00:29:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="B8DbVZAz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726856AbgH0A3Z (ORCPT ); Wed, 26 Aug 2020 20:29:25 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54160 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726912AbgH0A3X (ORCPT ); Wed, 26 Aug 2020 20:29: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 07R0Dq9w045167 for ; Thu, 27 Aug 2020 00:29: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=rkOSKiT8jbpOyVqT9URdri5LavpHhLfqahAWnnCjwX4=; b=B8DbVZAzwVTFHmvuIpSRxt3gP9YDrXfocSIsp6tIlG/icYo2cS+KEnxvw2JD1itmwOHR 1JOCbFKnQXGw4SxvmJC7BmW3peyagqluto5+Zc64mskMnlnV/iunco/r35hVvHJKpPnS WqpwK2V9OnIL1SFovOZ0aEjpBH8o46ViywXlUo9KLuR2qJpYdNm71MSyttYu+RGMukbc wmqW5SWajO6v/ZsI4OINXtgYWGa1CGEQ33HTtkAn3J8flVkzuehTEa0EVWh/0vlMR0Bg qMC+44VDCutI7OEwR5YG/NBWcF7joifSa4RAx+PH4jECekTLospRCPUiopikbnfrD8LX mA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 333dbs3dxd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:20 +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 07R0AHIv121723 for ; Thu, 27 Aug 2020 00:29:20 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 333rubkgae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:19 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07R0TICx019367 for ; Thu, 27 Aug 2020 00:29:18 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:18 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 23/32] xfsprogs: Add delay ready attr remove routines Date: Wed, 26 Aug 2020 17:28:47 -0700 Message-Id: <20200827002856.1131-24-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=1 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 Sender: linux-xfs-owner@vger.kernel.org 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 perserving 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 Collins --- include/libxfs.h | 1 + libxfs/xfs_attr.c | 163 +++++++++++++++++++++++++++++++++++------------ libxfs/xfs_attr.h | 73 +++++++++++++++++++++ libxfs/xfs_attr_leaf.c | 2 +- libxfs/xfs_attr_remote.c | 40 ++++++------ libxfs/xfs_attr_remote.h | 2 +- 6 files changed, 219 insertions(+), 62 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 fc7de6b..b30c127 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(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(dac); } /* @@ -1177,11 +1235,12 @@ 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_state_blk *blk; + struct xfs_da_args *args = dac->da_args; + int error; + struct xfs_da_state_blk *blk; error = xfs_attr_node_hasname(args, state); if (error != -EEXIST) @@ -1191,6 +1250,13 @@ int xfs_attr_node_removename_setup( ASSERT(blk->bp != NULL); ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + /* + * Store blk and state in the context incase we need to cycle out the + * transaction + */ + dac->blk = blk; + dac->da_state = *state; + if (args->rmtblkno > 0) { error = xfs_attr_leaf_mark_incomplete(args, *state); if (error) @@ -1203,13 +1269,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; @@ -1226,21 +1295,35 @@ xfs_attr_node_remove_rmt( * 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_removename( - struct xfs_da_args *args) + struct xfs_delattr_context *dac) { - struct xfs_da_state *state; - 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; + struct xfs_inode *dp = args->dp; trace_xfs_attr_node_removename(args); + state = dac->da_state; + blk = dac->blk; - error = xfs_attr_node_removename_setup(args, &state); - if (error) - goto out; + if (dac->dela_state == XFS_DAS_RM_SHRINK) + goto das_rm_shrink; + + 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; + } /* * If there is an out-of-line value, de-allocate the blocks. @@ -1248,8 +1331,13 @@ xfs_attr_node_removename( * overflow the maximum size of a transaction and/or hit a deadlock. */ if (args->rmtblkno > 0) { - error = xfs_attr_node_remove_rmt(args, state); - if (error) + /* + * May return -EAGAIN. Remove blocks until args->rmtblkno == 0 + */ + error = xfs_attr_node_remove_rmt(dac, state); + if (error == -EAGAIN) + return error; + else if (error) goto out; } @@ -1268,17 +1356,14 @@ xfs_attr_node_removename( error = xfs_da3_join(state); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; - /* - * Commit the Btree join operation and start a new trans. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; + + dac->flags |= XFS_DAC_DEFER_FINISH; + dac->dela_state = XFS_DAS_RM_SHRINK; + return -EAGAIN; } +das_rm_shrink: + /* * If the result is small enough, push it all into the inode. */ diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 3e97a93..9573949 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -74,6 +74,75 @@ 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 { + /* Zero is uninitalized */ + XFS_DAS_RM_SHRINK = 1, /* 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; + struct xfs_da_state_blk *blk; + + /* 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 +160,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 4fd50ed..127e04f 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 07b7193..93da858 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -675,12 +675,14 @@ xfs_attr_rmtval_invalidate( */ int xfs_attr_rmtval_remove( - struct xfs_da_args *args) + struct xfs_da_args *args) { - xfs_dablk_t lblkno; - int blkcnt; - int error = 0; - int retval = 0; + xfs_dablk_t lblkno; + int blkcnt; + int error = 0; + struct xfs_delattr_context dac = { + .da_args = args, + }; trace_xfs_attr_rmtval_remove(args); @@ -690,19 +692,16 @@ xfs_attr_rmtval_remove( lblkno = args->rmtblkno; blkcnt = args->rmtblkcnt; 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; } /* @@ -712,9 +711,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. @@ -724,12 +724,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 Thu Aug 27 00:28:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739773 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 5EBF5913 for ; Thu, 27 Aug 2020 00:31:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3ACBC21741 for ; Thu, 27 Aug 2020 00:31:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="r0Qf/quO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727008AbgH0Ab3 (ORCPT ); Wed, 26 Aug 2020 20:31:29 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:55468 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727000AbgH0AbZ (ORCPT ); Wed, 26 Aug 2020 20:31:25 -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 07R0ULxs068795 for ; Thu, 27 Aug 2020 00:31: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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=rrDg9giTOOhEZU21dUr/Z9o7guxzBfigZz1n3tqnS30=; b=r0Qf/quOlQ4vyU0qLzZp7JmRp+xMT5tNU+Av5Lmm0bIYtzvCtc2BAzyB4CKTQReM5zPm wIGLPFaYFzTEk36zFDuOmcDq7+QY6dDb0QQMg4GxyDquiGAq69MkbYJmUzpEcenr04Eq x/qXP1EaskAwI+0udHpQFMY04c8IUp99LCmvmsnvLrv+3zYUaKtm0lkM5alZtUR84ViV unydRQKHh7ufDoBmUIcEYVoci0Jkgn3i6RpPlWOQn8G7IaNVDXa9fzohzgm94o7pdFwg 6++RfpWzFq94mtXfZr9B96eFtTZamTjzkR5Mg2HtVNE5uR1j09f1JyPc/M1z17vlRTqP 0A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 333dbs3e33-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:31: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 07R0Af8Z127393 for ; Thu, 27 Aug 2020 00:29:20 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 333ru0t3e1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:19 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TJx9024953 for ; Thu, 27 Aug 2020 00:29:19 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:18 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 24/32] xfsprogs: Add delay ready attr set routines Date: Wed, 26 Aug 2020 17:28:48 -0700 Message-Id: <20200827002856.1131-25-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 adultscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=3 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org 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 Collins --- libxfs/xfs_attr.c | 370 +++++++++++++++++++++++++++++++---------------- libxfs/xfs_attr.h | 126 +++++++++++++++- libxfs/xfs_attr_remote.c | 102 ++++++++----- libxfs/xfs_attr_remote.h | 4 + 4 files changed, 442 insertions(+), 160 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index b30c127..5444fb7 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(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; } @@ -960,16 +1051,23 @@ 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; - struct xfs_mount *mp; - int retval, error; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state *state = NULL; + struct xfs_da_state_blk *blk; + struct xfs_inode *dp; + struct xfs_mount *mp; + int retval = 0; + int error = 0; trace_xfs_attr_node_addname(args); @@ -978,7 +1076,21 @@ xfs_attr_node_addname( */ dp = args->dp; mp = dp->i_mount; -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. @@ -1024,19 +1136,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; } /* @@ -1048,9 +1154,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. @@ -1065,13 +1169,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 @@ -1080,7 +1180,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; } @@ -1110,22 +1230,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 9573949..4f6bba8 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 { /* Zero is uninitalized */ XFS_DAS_RM_SHRINK = 1, /* 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; struct xfs_da_state_blk *blk; @@ -161,7 +286,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 93da858..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,41 +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) -{ - xfs_dablk_t lblkno; - int blkcnt; - int error = 0; - 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. - */ - lblkno = args->rmtblkno; - blkcnt = args->rmtblkcnt; - 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 Thu Aug 27 00:28:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739747 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 98075722 for ; Thu, 27 Aug 2020 00:29:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 809E4208E4 for ; Thu, 27 Aug 2020 00:29:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="MoYPCdxx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726936AbgH0A3W (ORCPT ); Wed, 26 Aug 2020 20:29:22 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:54692 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726929AbgH0A3W (ORCPT ); Wed, 26 Aug 2020 20:29:22 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07R0SwaU022042 for ; Thu, 27 Aug 2020 00:29: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=RU0DvOHtt2QHGqvoQFveACAXdiOPg5k6jJKTzrEfWsM=; b=MoYPCdxx8pN/Wm6gkrDdx+nUt9iPe8kj2lkoh8915dirMsF/B6THs8SmUITXEOyvIEZB FjBgkFMN8B18opMagX9hU5SFF6PWf0lz9I/6NbR/E5P1L0DxV4o82NYWOYPUGUQVWySO zlyIZWLThrJdLc1UTfZC2ij3ZfxqQvW+gHtYaX7SL/+rvHKwFjkrvHyd8S5mlBnGW8X5 2mIFbDb7ZUiplQ6af6dq3gmWvF5MHN8ZtldGPmRqD1Cr9mdOm9bVsVt10Ix8GYK7uZOp IZb77HhssYaOdVdDqWqtaEe7TRiO8h5LKwYhuoraeAYOf49oJfEH08UhAMnaBFHX9OS1 +w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 335gw859e4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:21 +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 07R0BN5U038152 for ; Thu, 27 Aug 2020 00:29:20 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 333r9mk54s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:20 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TJo7016970 for ; Thu, 27 Aug 2020 00:29:19 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:19 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 25/32] xfsprogs: Rename __xfs_attr_rmtval_remove Date: Wed, 26 Aug 2020 17:28:49 -0700 Message-Id: <20200827002856.1131-26-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=1 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Now that xfs_attr_rmtval_remove is gone, rename __xfs_attr_rmtval_remove to xfs_attr_rmtval_remove Signed-off-by: Allison Collins Reviewed-by: Darrick J. Wong --- libxfs/xfs_attr.c | 6 +++--- libxfs/xfs_attr_remote.c | 2 +- libxfs/xfs_attr_remote.h | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 5444fb7..c98ae9d 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) @@ -1245,7 +1245,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; @@ -1404,7 +1404,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 Thu Aug 27 00:28:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739767 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 B5D4F722 for ; Thu, 27 Aug 2020 00:31:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8ED912087D for ; Thu, 27 Aug 2020 00:31:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="A4hI2Rsj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727015AbgH0Ab3 (ORCPT ); Wed, 26 Aug 2020 20:31:29 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:55876 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727003AbgH0AbZ (ORCPT ); Wed, 26 Aug 2020 20:31:25 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07R0SwnP022029 for ; Thu, 27 Aug 2020 00:31: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=hEohVocB8G1SI+yPz9k2M2Q1iGPgud0eoTV29yftTq8=; b=A4hI2RsjF2I3DVjfKkEklA3XafChGIX1V0tIs3ROzgg0dBzdDwjFTqBX+JkNsWoQWfYl zcyM9P9FR1OJRLVUAetqy/Bpd/n11qTQHdzmLRTltM77M2SMADxyKK2r/XSWOzGYNc2d tgKH/pINE67akqkO65Yg5/KdJWR+pagkfaxUOcZgXTXjby7PUd/194inqEpWRwbnErqS qrK6F+GKSJH5FdtMvDBTnpli7HphUy0pd4p44O0hXr9meFNMwzvLPEgvYA1ciUbCot+x vEgu92ZadDX8zS0yK0inA/x1UUTq9+C9Knh6iy8CwkQqlc06lW7+3kJRU5pKXKiY4VUP wQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 335gw859kt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:31:22 +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 07R0AIgg121854 for ; Thu, 27 Aug 2020 00:29:21 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 333rubkgc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:21 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TKi5024990 for ; Thu, 27 Aug 2020 00:29:20 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:20 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 26/32] xfsprogs: Set up infastructure for deferred attribute operations Date: Wed, 26 Aug 2020 17:28:50 -0700 Message-Id: <20200827002856.1131-27-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=3 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Source kernel commit: 2527df9851aafc043287d040bced149c9dad63bd 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 Collins --- libxfs/defer_item.c | 171 ++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/libxfs_priv.h | 1 + libxfs/xfs_attr.c | 7 +- libxfs/xfs_attr.h | 39 +++++++++++ libxfs/xfs_defer.c | 1 + libxfs/xfs_defer.h | 2 + libxfs/xfs_log_format.h | 43 +++++++++++- libxfs/xfs_types.h | 1 + 8 files changed, 259 insertions(+), 6 deletions(-) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index b18182e..ecda7e5 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,173 @@ 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; + set_bit(XFS_LI_DIRTY, &attrdp->attrd_item.li_flags); + + 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; + int local; + struct xfs_delattr_context *dac; + struct xfs_da_args *args; + struct xfs_attrd_log_item *attrdp; + struct xfs_attri_log_item *attrip; + + attr = container_of(item, struct xfs_attr_item, xattri_list); + dac = &attr->xattri_dac; + args = &attr->xattri_args; + + if (!(dac->flags & XFS_DAC_DELAYED_OP_INIT)) { + /* Only need to initialize args context once */ + memset(args, 0, sizeof(*args)); + args->geo = attr->xattri_ip->i_mount->m_attr_geo; + args->whichfork = XFS_ATTR_FORK; + args->dp = attr->xattri_ip; + args->name = ((const unsigned char *)attr) + + sizeof(struct xfs_attr_item); + args->namelen = attr->xattri_name_len; + args->attr_filter = attr->xattri_flags; + args->hashval = xfs_da_hashname(args->name, args->namelen); + args->value = (void *)&args->name[attr->xattri_name_len]; + args->valuelen = attr->xattri_value_len; + args->op_flags = XFS_DA_OP_OKNOENT; + + /* must match existing transaction block res */ + args->total = xfs_attr_calc_size(args, &local); + memset(dac, 0, sizeof(struct xfs_delattr_context)); + dac->flags |= XFS_DAC_DELAYED_OP_INIT; + dac->da_args = args; + } + + /* + * Always reset trans after EAGAIN cycle + * since the transaction is new + */ + args->trans = tp; + + error = xfs_trans_attr(dac, ATTRD_ITEM(done), &dac->leaf_bp, + attr->xattri_op_flags); + /* + * The attrip refers to xfs_attr_item memory to log the name and value + * with the intent item. This already occurred when the intent was + * committed so these fields are no longer accessed. Clear them out of + * caution since we're about to free the xfs_attr_item. + */ + attrdp = (struct xfs_attrd_log_item *)done; + attrip = attrdp->attrd_attrip; + attrip->attri_name = NULL; + attrip->attri_value = NULL; + + 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 5688284..13a1a86 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -494,6 +494,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 c98ae9d..43688ad 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 4f6bba8..23b8308 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; @@ -268,6 +272,38 @@ struct xfs_delattr_context { enum xfs_delattr_state dela_state; }; +/* + * List of attrs to commit later. + */ +struct xfs_attr_item { + struct xfs_inode *xattri_ip; + void *xattri_value; /* attr value */ + void *xattri_name; /* attr name */ + uint32_t xattri_op_flags; /* attr op set or rm */ + uint32_t xattri_value_len; /* length of value */ + uint32_t xattri_name_len; /* length of name */ + uint32_t xattri_flags; /* attr flags */ + + /* used to log this item to an intent */ + struct list_head xattri_list; + + /* + * xfs_delattr_context and xfs_da_args need to remain instantiated + * across transaction rolls during the defer finish, so store them here + */ + struct xfs_da_args xattri_args; + struct xfs_delattr_context xattri_dac; + + /* + * A byte array follows the header containing the file name and + * attribute value. + */ +}; + +#define XFS_ATTR_ITEM_SIZEOF(namelen, valuelen) \ + (sizeof(struct xfs_attr_item) + (namelen) + (valuelen)) + + /*======================================================================== * Function prototypes for the kernel. *========================================================================*/ @@ -283,11 +319,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_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 Thu Aug 27 00:28:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739751 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 DBADD14E5 for ; Thu, 27 Aug 2020 00:29:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C45B92087D for ; Thu, 27 Aug 2020 00:29:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="G27XBczK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726939AbgH0A3Y (ORCPT ); Wed, 26 Aug 2020 20:29:24 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:54712 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726856AbgH0A3X (ORCPT ); Wed, 26 Aug 2020 20:29:23 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07R0TMAN022240 for ; Thu, 27 Aug 2020 00:29: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=NGa1uyYUgvphfBpZhe9ce+wATInmrWY+QUkb6KgxlBo=; b=G27XBczKIkAfSnPp9HKvyCBoTcTwMgglajRelHKw5ZzTBhxibdxFieGsKxjaBFk8DLOG 9OIaW93wVcsQgvMBiYF3DRWwfX6Oeg4xMsUHYWV7AVeW76DQzuMkSBUo+3cmQ7RMF9bE llN8m/oKNqKapyK5bqCf0oQ4moJ1+8cZJDUjF6v7MtVNXB35W8Lb44Gntz1BkaxB4hKd l13Zu57FSa94WWUKQ31nGNZk3Wy/N5GecP2xoN5qEoLnJuUSIyztmlvJdK6RfPtRij6R UzmOZpvlVc3RyAtFk0hDtaTm5bvIYS8O6VRieWQLrFEzsBGMhL8r/Tps1+EXjKa/0Hkc Mg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 335gw859e7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:22 +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 07R0AHIw121723 for ; Thu, 27 Aug 2020 00:29:21 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 333rubkgcb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:21 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TKeG016976 for ; Thu, 27 Aug 2020 00:29:21 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:20 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 27/32] xfsprogs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Date: Wed, 26 Aug 2020 17:28:51 -0700 Message-Id: <20200827002856.1131-28-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=1 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/xfs_attr.h | 7 +++++ 2 files changed, 97 insertions(+) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 43688ad..ed25894 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -643,6 +643,96 @@ out_trans_cancel: goto out_unlock; } +STATIC int +xfs_attr_item_init( + struct xfs_inode *dp, /* inode for attr operation */ + struct xfs_trans *tp, /* transaction for attr op */ + const unsigned char *name, /* attr name */ + unsigned int namelen, /* attr namelen */ + unsigned int flags, /* attr flags */ + const unsigned char *value, /* attr value */ + unsigned int valuelen, /* attr value len */ + unsigned int op_flags, /* op flag (set or remove) */ + struct xfs_attr_item **attr) /* new xfs_attr_item */ +{ + + struct xfs_attr_item *new; + char *name_value; + + /* + * All set operations must have a name but not necessarily a value. + */ + if (!namelen) { + ASSERT(0); + return -EINVAL; + } + + new = kmem_alloc_large(XFS_ATTR_ITEM_SIZEOF(namelen, valuelen), + KM_NOFS); + name_value = ((char *)new) + sizeof(struct xfs_attr_item); + memset(new, 0, XFS_ATTR_ITEM_SIZEOF(namelen, valuelen)); + new->xattri_ip = dp; + new->xattri_op_flags = op_flags; + new->xattri_name_len = namelen; + new->xattri_value_len = valuelen; + new->xattri_flags = flags; + memcpy(&name_value[0], name, namelen); + new->xattri_name = name_value; + new->xattri_value = name_value + namelen; + + if (valuelen > 0) + memcpy(&name_value[namelen], value, valuelen); + + *attr = new; + return 0; +} + +/* Sets an attribute for an inode as a deferred operation */ +int +xfs_attr_set_deferred( + struct xfs_inode *dp, + struct xfs_trans *tp, + const unsigned char *name, + unsigned int namelen, + unsigned int flags, + const unsigned char *value, + unsigned int valuelen) +{ + struct xfs_attr_item *new; + int error = 0; + + error = xfs_attr_item_init(dp, tp, name, namelen, flags, value, + valuelen, XFS_ATTR_OP_FLAGS_SET, &new); + if (error) + return error; + + xfs_defer_add(tp, 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_inode *dp, + struct xfs_trans *tp, + const unsigned char *name, + unsigned int namelen, + unsigned int flags) +{ + + struct xfs_attr_item *new; + + int error = xfs_attr_item_init(dp, tp, name, namelen, flags, NULL, 0, + XFS_ATTR_OP_FLAGS_REMOVE, &new); + if (error) + return error; + + xfs_defer_add(tp, 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 23b8308..4643b3f 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -328,5 +328,12 @@ 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_inode *dp, struct xfs_trans *tp, + const unsigned char *name, unsigned int namelen, + unsigned int flags, const unsigned char *value, + unsigned int valuelen); +int xfs_attr_remove_deferred(struct xfs_inode *dp, struct xfs_trans *tp, + const unsigned char *name, unsigned int namelen, + unsigned int flags); #endif /* __XFS_ATTR_H__ */ From patchwork Thu Aug 27 00:28:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739749 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 24F99722 for ; Thu, 27 Aug 2020 00:29:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 080D72087C for ; Thu, 27 Aug 2020 00:29:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="J6Be2Nrj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726938AbgH0A3Y (ORCPT ); Wed, 26 Aug 2020 20:29:24 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37818 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726930AbgH0A3X (ORCPT ); Wed, 26 Aug 2020 20:29:23 -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 07R0TMCX165433 for ; Thu, 27 Aug 2020 00:29: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=hGNUlw22ritFAAlu9lkCiILIO8GjFnLrT1TAquGQXwo=; b=J6Be2NrjUzus5nsR3wj2TvqmUH7BIZS8N82lLhpd7yN653BJnCcp9jdrMDdYIT6C9g/a 85y2EQLvP9geDCN+9fTQhgbxhA3WallN49rTBiDzkU5WmY9X9BXwRKl7oOBrnzWwxt4f PJDdbIHDa4MM5yaTHBb0VhiaU3E6hx1ZflNgZKv1JAadDotKZmFfiLr/u4jLfkl2SLWK 0o1kKcRHk0ch0Yjf7SWFhpubjfRLxqJ6bWvvrFe1csSq3dfO01fJc7pLKM7p8EdgN6Lg 3gjbXuwHJlxGpcIRw3moIcqGfUuzS13w5H4T56RIA3zoJtcOcpmqanVE3szrMR/mwYMi xw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 333w6u1ywh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:22 +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 07R0AHoB121760 for ; Thu, 27 Aug 2020 00:29:21 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 333rubkgcs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:21 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TLib016979 for ; Thu, 27 Aug 2020 00:29:21 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:21 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 28/32] xfsprogs: Add feature bit XFS_SB_FEAT_INCOMPAT_LOG_DELATTR Date: Wed, 26 Aug 2020 17:28:52 -0700 Message-Id: <20200827002856.1131-29-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=1 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org 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 Collins --- libxfs/xfs_format.h | 11 ++++++++++- libxfs/xfs_fs.h | 1 + libxfs/xfs_sb.c | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 3ccaf0a..770e4b4c 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -479,7 +479,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( @@ -563,6 +565,13 @@ 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 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && + (sbp->sb_features_log_incompat & + XFS_SB_FEAT_INCOMPAT_LOG_DELATTR)); +} + /* * end of superblock version macros */ diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index 84bcffa..67b1f97 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 << 21) /* delayed attributes */ /* * Minimum and maximum sizes need for growth checks. diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 7e73b40..fd56315 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 Thu Aug 27 00:28: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: 11739755 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 47F31722 for ; Thu, 27 Aug 2020 00:29:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F22D208E4 for ; Thu, 27 Aug 2020 00:29:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="qq/ZTIAr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726940AbgH0A30 (ORCPT ); Wed, 26 Aug 2020 20:29:26 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37824 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726929AbgH0A3X (ORCPT ); Wed, 26 Aug 2020 20:29:23 -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 07R0TIxJ165383 for ; Thu, 27 Aug 2020 00:29:23 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=hoghDP00s+RHLEHpLT6vn/TeCPRRPA/K/+orz34PGVo=; b=qq/ZTIArYUqs95B4N2FPVS45RbfEs+c8oFCiQ4e+Sp6cLVrr14+FJJfMo39cWjOe/3PQ TN+Qy8wAJbpj/aEQXzyAvIXaKoZYNh3J2BO0Mz9V3RUeiCz6xu5Qwnq5U53l4cqJiMMM 7iQiDIe2bCLhbGec/iTYspoBBbrzaK/aGwnmC0gXuijDXwFwPqH/Z0iz/x/Sz3wVZVkt E1VxTOqDv7kwV9VM+XAJ7wbgIZdocA8lGhugTG05hY73FH7ChJuAwclDR7nZdPtMNo3F D/kaLNf+msYFH+uy4cpWZZl6nO0KlFZAxitkxaM170JboIbcdXPW388YGxrKsuBuz7tB Gg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 333w6u1ywk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:22 +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 07R0ArGF025945 for ; Thu, 27 Aug 2020 00:29:22 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 333r9mswwj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:22 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TLcP016982 for ; Thu, 27 Aug 2020 00:29:21 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:21 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 29/32] xfsprogs: Enable delayed attributes Date: Wed, 26 Aug 2020 17:28:53 -0700 Message-Id: <20200827002856.1131-30-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Finally enable delayed attributes in xfs_attr_set and xfs_attr_remove. We only do this for new filesystems that have the feature bit enabled because we cant add new log entries to older filesystems Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index ed25894..6afcfe3 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -517,6 +517,7 @@ xfs_attr_set( { struct xfs_inode *dp = args->dp; struct xfs_mount *mp = dp->i_mount; + struct xfs_sb *sbp = &mp->m_sb; struct xfs_trans_res tres; bool rsvd = (args->attr_filter & XFS_ATTR_ROOT); int error, local; @@ -602,9 +603,17 @@ xfs_attr_set( if (error != -ENOATTR && error != -EEXIST) goto out_trans_cancel; - error = xfs_attr_set_args(args); + if (xfs_sb_version_hasdelattr(sbp)) + error = xfs_attr_set_deferred(dp, args->trans, + args->name, args->namelen, + args->attr_filter, args->value, + args->valuelen); + else + error = xfs_attr_set_args(args); + if (error) goto out_trans_cancel; + /* shortform attribute has already been committed */ if (!args->trans) goto out_unlock; @@ -613,7 +622,13 @@ xfs_attr_set( if (error != -EEXIST) goto out_trans_cancel; - error = xfs_attr_remove_args(args); + if (xfs_sb_version_hasdelattr(sbp)) + error = xfs_attr_remove_deferred(dp, args->trans, + args->name, + args->namelen, + args->attr_filter); + else + error = xfs_attr_remove_args(args); if (error) goto out_trans_cancel; } From patchwork Thu Aug 27 00:28: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: 11739757 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 9C26214E5 for ; Thu, 27 Aug 2020 00:29:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85449208E4 for ; Thu, 27 Aug 2020 00:29:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="MPJUgz4J" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726929AbgH0A30 (ORCPT ); Wed, 26 Aug 2020 20:29:26 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37852 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726930AbgH0A3Z (ORCPT ); Wed, 26 Aug 2020 20:29:25 -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 07R0TOL2165452 for ; Thu, 27 Aug 2020 00:29:24 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=M+CMUEO8I3kYStD02WYuZgKWpKIJ+DjwUWffkWIbdGU=; b=MPJUgz4JCzVZBCB8KEVJfaf8p6G/JXa0io2ICpyq/2LqGR+ZED/d11+5qPx7B+oVlPfM jaHcIScTwUtnp+2L2D/H0b+tXLQ5s2zfdUTWAJq5h54tD4QBWXCrUXXs3o9jGJ3bFUWx 3BIq9HpoikzMHcdHmpjWYguZYN5dX8mYpVAHX3eKf8Uj3Hwt/sXPidawA03L0SXOaKfg /bP1Vt+Oxpq7gy10KhjQQfO4ZeEf9l8myYXhjG0qZO8nD7vTD6Ii9v/o2E3dAKTV1DHg dywXTowLCWYaqpmdWK2uQHnW/yxCGLXvT7ucV8UGkFA0A+K89YKa2O3OePrR+RaPNuWu pw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 333w6u1ywt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:29:24 +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 07R0AqPH025897 for ; Thu, 27 Aug 2020 00:29:23 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 333r9mswx1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:23 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TNLZ016986 for ; Thu, 27 Aug 2020 00:29:23 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:21 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 30/32] xfs_io: Add delayed attributes error tag Date: Wed, 26 Aug 2020 17:28:54 -0700 Message-Id: <20200827002856.1131-31-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 Signed-off-by: Allison Collins --- 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 Thu Aug 27 00:28: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: 11739771 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 1653017C7 for ; Thu, 27 Aug 2020 00:31:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFA6E2177B for ; Thu, 27 Aug 2020 00:31:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="wvYmOlAG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727013AbgH0Ab3 (ORCPT ); Wed, 26 Aug 2020 20:31:29 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:55502 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727008AbgH0Ab1 (ORCPT ); Wed, 26 Aug 2020 20:31:27 -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 07R0VPTd069907 for ; Thu, 27 Aug 2020 00:31:25 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=su1FJUcRCMG2J43gwE1zTWSIlqrLOh5O4yasNMw2T40=; b=wvYmOlAGlILKxV3c2cXt80LyRYj68VNNnbzQwokiMIkMQvFnk45fRd8kjbjSCvsvgGDe gPc9SR2xVlUpeFfXUVhc5lIAmfD0hI3jRx+CUoh26QgZsxM0UsA0+HLVPG3wvGPdc6pz MhbrFe7xSRsFZnWG1COroVC5U4Z0JmMg4iwbBRJGiJiTHibAt4wncP9U9wIz4QD7LBVS SmtgHFpBwdL2omoAJZTEcS+sCUa4tEHK4IbyNJaruurOHP2Ec2cW4yruZ+X72sQekC15 CudPI+1XWIPuaXqY16FnR9SAf2KrgvOxdmr+uxgnYLe/vd4PzeHasRaOF/eh0yoGjGY+ vg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 333dbs3e37-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:31:25 +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 07R0BTxV038463 for ; Thu, 27 Aug 2020 00:29:24 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 333r9mk55n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:24 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07R0TNJs019441 for ; Thu, 27 Aug 2020 00:29:23 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:23 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 31/32] [RFC] xfsprogs: Add log item printing for ATTRI and ATTRD Date: Wed, 26 Aug 2020 17:28:55 -0700 Message-Id: <20200827002856.1131-32-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=3 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=3 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson 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 Signed-off-by: Allison Collins --- 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 be88988..2c73af0 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 Thu Aug 27 00:28:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11739769 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 E6D141751 for ; Thu, 27 Aug 2020 00:31:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1B5C21741 for ; Thu, 27 Aug 2020 00:31:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="FiCNdR5f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727003AbgH0Ab3 (ORCPT ); Wed, 26 Aug 2020 20:31:29 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38924 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbgH0Ab0 (ORCPT ); Wed, 26 Aug 2020 20:31:26 -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 07R0TItm165381 for ; Thu, 27 Aug 2020 00:31:26 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=fCip9Xu22wOnVWO+HvVACp82Uc/5x3BamYZ7FaQQ5E4=; b=FiCNdR5fCvHVCboBdisMhUUYohEbagPTUOTAvMRD5V6eans68/MG/38rr296zhLXz3rr ePXo+J0Io9utvkZq72Zu3vt3L6cWyaM8nSaxTZCWravSii5j8ucOHijuxG3rugQoZB+E pIGGvBD1u1yys+JxOxCqoRV4SCtZ1k6xeiJ3rd/PR1obn5Ule/IZgmgP6wf2BLDIOB8i vrG3bEWvs3MxHbOCFqlchemd/fiPYB6PBTWsBo0zr3y3tHZpmgI2+MLiNU6d8+964FCG xZA8Ks6IBjfjZ3fbzVD4qvbFipUWJWFUjYdlkM1YnW0+kNSslSVCbM402Ahp2IZ8alf2 5g== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 333w6u2027-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Aug 2020 00:31:25 +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 07R0Aq9d025905 for ; Thu, 27 Aug 2020 00:29:25 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 333r9mswx6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 27 Aug 2020 00:29:25 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07R0TOSX024995 for ; Thu, 27 Aug 2020 00:29:24 GMT Received: from localhost.localdomain (/67.1.244.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Aug 2020 17:29:23 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v12 32/32] xfsprogs: Add delayed attribute flag to cmd Date: Wed, 26 Aug 2020 17:28:56 -0700 Message-Id: <20200827002856.1131-33-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827002856.1131-1-allison.henderson@oracle.com> References: <20200827002856.1131-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270000 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9725 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270001 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org mkfs: enable feature bit in mkfs via the '-n delattr' parameter. Signed-off-by: Allison Collins --- 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 a687f38..b7ce5fe2 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, @@ -2951,6 +2971,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.