From patchwork Sat Jan 18 22:45: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: 11340293 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 1BACA14B4 for ; Sat, 18 Jan 2020 22:48:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF057246AC for ; Sat, 18 Jan 2020 22:48:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="F5+DmA/F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727031AbgARWsT (ORCPT ); Sat, 18 Jan 2020 17:48:19 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:35912 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727050AbgARWsT (ORCPT ); Sat, 18 Jan 2020 17:48:19 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00IMcr4G056441 for ; Sat, 18 Jan 2020 22:48: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-2019-08-05; bh=PopTFaut+06WPazHru/ElTtbdMV9YfL62COj/P7RME4=; b=F5+DmA/F+adDDYMY5F1mFHUuud+jbhCwiSh7PsjEOebFH7PXe4uchs8DxmG4Mw5fDiML PODhRxZwoxhpMG2/kbKM8kj80cbOsD6FjYj5Omcyzs9yFb2Q09F4t/epyc2/0dIIWPES MCnDW8mQRCH31b50xoOAe4GRxnm6FZ/FQoOQfP1BgjFBB/wAQWkKPRwazGb2Vz/UPO74 ldQ+cy1NODfqeK5D72rs6PsP1JkwbyyGsUgQoA97YFVAVLnVppvgaIGyrkoC0OZjknV0 iswsvJ1cPD9nsIVJRVa9vXT7YBlkOnsVLbM7O8onRfjxT+nRaE2jsS9g2IEWI7sQYatF 1w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2xksypsyy5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 18 Jan 2020 22:48:18 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00IMcuKj070514 for ; Sat, 18 Jan 2020 22:46:17 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2xkq5p8yya-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 18 Jan 2020 22:46:17 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 00IMkHFI025483 for ; Sat, 18 Jan 2020 22:46:17 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 18 Jan 2020 14:46:16 -0800 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v6 15/17] xfsprogs: Simplify xfs_attr_set_args Date: Sat, 18 Jan 2020 15:45:56 -0700 Message-Id: <20200118224558.19382-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200118224558.19382-1-allison.henderson@oracle.com> References: <20200118224558.19382-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9504 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2001180185 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9504 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2001180185 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Delayed attribute mechanics make frequent use of goto statements. We can use this to further simplify xfs_attr_set_args. In this patch we introduce one of the gotos now to help pre-simplify the routine. This will help make proceeding patches in this area easier to read. Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 71 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 440af79..4ab97dd 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -263,47 +263,50 @@ xfs_attr_set_args( int error, error2 = 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 non-existent or a shortform list, proceed to + * upgrade it to a single-leaf-block attribute list. Otherwise jump + * straight to leaf handling */ - if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL || + if (!(dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL || (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && - dp->i_d.di_anextents == 0)) { + dp->i_d.di_anextents == 0))) + goto sf_to_leaf; - /* - * 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; - } + /* + * 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; + /* + * 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; - } + /* + * 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; } +sf_to_leaf: + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { error = xfs_attr_leaf_addname(args); if (error != -ENOSPC)