From patchwork Thu Apr 30 22:46:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521881 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 2DAD4913 for ; Thu, 30 Apr 2020 22:49:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 167D7207DD for ; Thu, 30 Apr 2020 22:49:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Wx9EM7hw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727896AbgD3WtJ (ORCPT ); Thu, 30 Apr 2020 18:49:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45066 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727068AbgD3WtH (ORCPT ); Thu, 30 Apr 2020 18:49:07 -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 03UMmvL6132896 for ; Thu, 30 Apr 2020 22:49:07 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=J7weyPy+kIAaPev1PRsv9g8oTOryjuDEs9kXNMtq4tg=; b=Wx9EM7hw+hgYODIupaC/UpDsQUP8ER5ipnNICXetWFq9mKEYIcQNkZiYAjIo/FP3Y13p 8kEPKx6WkVvOAxFfOsym7wIcBNlQwzWZYvIUcQVIwX43TT5iJikbbH2rPtCfvqJi+yKv jmfq0cTJYmAtr0GcGPTG83TP4JIK8qOULDN9A9eFF6IqNVhfw9n8IC7Og3hmwZIYk8+M ruLyetYL/RDHMmp1Vq0sflE1lOV38ldsAB6MnHUT+MX9olM4PaMC0JhcabYRWYwpLcER eqq8KXCuKOQRG7x+PqEF7tWHEDukaDvtmCrRstBNTV/KvljtJNm8vPAxIbulebRII/u7 AQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 30r7f3g2ap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:49:06 +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 03UMgtJu076927 for ; Thu, 30 Apr 2020 22:47:06 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 30r7f89ytv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:06 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMl50S012274 for ; Thu, 30 Apr 2020 22:47:05 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:05 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 01/43] xfsprogs: remove the ATTR_INCOMPLETE flag Date: Thu, 30 Apr 2020 15:46:18 -0700 Message-Id: <20200430224700.4183-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Replace the ATTR_INCOMPLETE flag with a new boolean field in struct xfs_attr_list_context. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 4243b22..71bcf12 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -36,11 +36,10 @@ struct xfs_attr_list_context; #define ATTR_KERNOTIME 0x1000 /* [kernel] don't update inode timestamps */ #define ATTR_KERNOVAL 0x2000 /* [kernel] get attr size only, not value */ -#define ATTR_INCOMPLETE 0x4000 /* [kernel] return INCOMPLETE attr keys */ #define ATTR_ALLOC 0x8000 /* [kernel] allocate xattr buffer on demand */ #define ATTR_KERNEL_FLAGS \ - (ATTR_KERNOTIME | ATTR_KERNOVAL | ATTR_INCOMPLETE | ATTR_ALLOC) + (ATTR_KERNOTIME | ATTR_KERNOVAL | ATTR_ALLOC) #define XFS_ATTR_FLAGS \ { ATTR_DONTFOLLOW, "DONTFOLLOW" }, \ @@ -51,7 +50,6 @@ struct xfs_attr_list_context; { ATTR_REPLACE, "REPLACE" }, \ { ATTR_KERNOTIME, "KERNOTIME" }, \ { ATTR_KERNOVAL, "KERNOVAL" }, \ - { ATTR_INCOMPLETE, "INCOMPLETE" }, \ { ATTR_ALLOC, "ALLOC" } /* @@ -123,6 +121,7 @@ typedef struct xfs_attr_list_context { * error values to the xfs_attr_list caller. */ int seen_enough; + bool allow_incomplete; ssize_t count; /* num used entries */ int dupcnt; /* count dup hashvals seen */ From patchwork Thu Apr 30 22:46:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521883 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 5310115AB for ; Thu, 30 Apr 2020 22:49:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AE9120870 for ; Thu, 30 Apr 2020 22:49:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="JaAG8JCr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727068AbgD3WtJ (ORCPT ); Thu, 30 Apr 2020 18:49:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45062 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726784AbgD3WtI (ORCPT ); Thu, 30 Apr 2020 18:49:08 -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 03UMmvLN132933 for ; Thu, 30 Apr 2020 22:49:06 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=7uN69r3Relzv2FGxyDjHYizrqgKyFeQt6aX0C7cDqr0=; b=JaAG8JCrsDp5vP9IMLW28lW+E39wLNDHj4VuSwMT7Pj8NG5xbaQeWoywnxstA5uewGDe zDJ/kd/i3bF9kEuieTWM+nof2nDzu9Mq5KXLaoyMrvzklkZNJkP4AEDid+qeoGpMzB2q UBUVJ1CnC/dILjmNm6PRvgMNqlcLyoHzzSeVHrZM8bo9wTnnn1sNeZfgtBK5pHP4cn5n jPtZG4UyNhcwRhoULaQWFWUaJwnC2uic3cEx3fzIKOrefQyLtL+vtWQzkvRjZMy3/rE9 IYfsFbWyxTY18FPLnI7AIhMcpTPXNk35RQSTksBqKPfaXK+7Zuqhm/RGijyokrjS7KyC OQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 30r7f3g2an-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:49:06 +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 03UMgt3e076965 for ; Thu, 30 Apr 2020 22:47:06 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 30r7f89ytx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:06 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMl5kQ031978 for ; Thu, 30 Apr 2020 22:47:05 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:05 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 02/43] xfsprogs: merge xfs_attr_remove into xfs_attr_set Date: Thu, 30 Apr 2020 15:46:19 -0700 Message-Id: <20200430224700.4183-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The Linux xattr and acl APIs use a single call for set and remove. Modify the high-level XFS API to match that and let xfs_attr_set handle removing attributes as well. With a little bit of reordering this removes a lot of code. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- db/attrset.c | 3 +- libxfs/libxfs_api_defs.h | 1 - libxfs/xfs_attr.c | 179 +++++++++++++++++------------------------------ libxfs/xfs_attr.h | 2 - 4 files changed, 65 insertions(+), 120 deletions(-) diff --git a/db/attrset.c b/db/attrset.c index d96b78d..708e71e3 100644 --- a/db/attrset.c +++ b/db/attrset.c @@ -222,7 +222,8 @@ attr_remove_f( goto out; } - if (libxfs_attr_remove(ip, (unsigned char *)name, strlen(name), flags)){ + if (libxfs_attr_set(ip, (unsigned char *)name, strlen(name), NULL, 0, + flags)){ dbprintf(_("failed to remove attr %s from inode %llu\n"), name, (unsigned long long)iocur_top->ino); goto out; diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 1149e30..0ffad20 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -32,7 +32,6 @@ #define xfs_attr_get libxfs_attr_get #define xfs_attr_leaf_newentsize libxfs_attr_leaf_newentsize #define xfs_attr_namecheck libxfs_attr_namecheck -#define xfs_attr_remove libxfs_attr_remove #define xfs_attr_set libxfs_attr_set #define xfs_bmapi_read libxfs_bmapi_read diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 5110bb4..6c56428 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -23,6 +23,7 @@ #include "xfs_attr_remote.h" #include "xfs_trans_space.h" #include "xfs_trace.h" +#include "xfs_quota_defs.h" /* * xfs_attr.c @@ -335,6 +336,10 @@ xfs_attr_remove_args( return error; } +/* + * Note: If value is NULL the attribute will be removed, just like the + * Linux ->setattr API. + */ int xfs_attr_set( struct xfs_inode *dp, @@ -349,149 +354,92 @@ xfs_attr_set( struct xfs_trans_res tres; int rsvd = (flags & ATTR_ROOT) != 0; int error, local; - - XFS_STATS_INC(mp, xs_attr_set); + unsigned int total; if (XFS_FORCED_SHUTDOWN(dp->i_mount)) return -EIO; - error = xfs_attr_args_init(&args, dp, name, namelen, flags); - if (error) - return error; - - args.value = value; - args.valuelen = valuelen; - args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; - args.total = xfs_attr_calc_size(&args, &local); - error = xfs_qm_dqattach(dp); if (error) return error; - /* - * If the inode doesn't have an attribute fork, add one. - * (inode must not be locked when we call this routine) - */ - if (XFS_IFORK_Q(dp) == 0) { - int sf_size = sizeof(xfs_attr_sf_hdr_t) + - XFS_ATTR_SF_ENTSIZE_BYNAME(args.namelen, valuelen); - - error = xfs_bmap_add_attrfork(dp, sf_size, rsvd); - if (error) - return error; - } - - tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + - M_RES(mp)->tr_attrsetrt.tr_logres * args.total; - tres.tr_logcount = XFS_ATTRSET_LOG_COUNT; - tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; - - /* - * Root fork attributes can use reserved data blocks for this - * operation if necessary - */ - error = xfs_trans_alloc(mp, &tres, args.total, 0, - rsvd ? XFS_TRANS_RESERVE : 0, &args.trans); + error = xfs_attr_args_init(&args, dp, name, namelen, flags); if (error) return error; - xfs_ilock(dp, XFS_ILOCK_EXCL); - error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0, - rsvd ? XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES : - XFS_QMOPT_RES_REGBLKS); - if (error) - goto out_trans_cancel; - - xfs_trans_ijoin(args.trans, dp, 0); - error = xfs_attr_set_args(&args); - if (error) - goto out_trans_cancel; - if (!args.trans) { - /* shortform attribute has already been committed */ - goto out_unlock; - } - - /* - * If this is a synchronous mount, make sure that the - * transaction goes to disk before returning to the user. - */ - if (mp->m_flags & XFS_MOUNT_WSYNC) - xfs_trans_set_sync(args.trans); - - if ((flags & ATTR_KERNOTIME) == 0) - xfs_trans_ichgtime(args.trans, dp, XFS_ICHGTIME_CHG); + args.value = value; + args.valuelen = valuelen; /* - * Commit the last in the sequence of transactions. + * We have no control over the attribute names that userspace passes us + * to remove, so we have to allow the name lookup prior to attribute + * removal to fail as well. */ - xfs_trans_log_inode(args.trans, dp, XFS_ILOG_CORE); - error = xfs_trans_commit(args.trans); -out_unlock: - xfs_iunlock(dp, XFS_ILOCK_EXCL); - return error; - -out_trans_cancel: - if (args.trans) - xfs_trans_cancel(args.trans); - goto out_unlock; -} + args.op_flags = XFS_DA_OP_OKNOENT; -/* - * Generic handler routine to remove a name from an attribute list. - * Transitions attribute list from Btree to shortform as necessary. - */ -int -xfs_attr_remove( - struct xfs_inode *dp, - const unsigned char *name, - size_t namelen, - int flags) -{ - struct xfs_mount *mp = dp->i_mount; - struct xfs_da_args args; - int error; + if (value) { + XFS_STATS_INC(mp, xs_attr_set); - XFS_STATS_INC(mp, xs_attr_remove); + args.op_flags |= XFS_DA_OP_ADDNAME; + args.total = xfs_attr_calc_size(&args, &local); - if (XFS_FORCED_SHUTDOWN(dp->i_mount)) - return -EIO; + /* + * If the inode doesn't have an attribute fork, add one. + * (inode must not be locked when we call this routine) + */ + if (XFS_IFORK_Q(dp) == 0) { + int sf_size = sizeof(struct xfs_attr_sf_hdr) + + XFS_ATTR_SF_ENTSIZE_BYNAME(args.namelen, + valuelen); - error = xfs_attr_args_init(&args, dp, name, namelen, flags); - if (error) - return error; + error = xfs_bmap_add_attrfork(dp, sf_size, rsvd); + if (error) + return error; + } - /* - * we have no control over the attribute names that userspace passes us - * to remove, so we have to allow the name lookup prior to attribute - * removal to fail. - */ - args.op_flags = XFS_DA_OP_OKNOENT; + tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + + M_RES(mp)->tr_attrsetrt.tr_logres * args.total; + tres.tr_logcount = XFS_ATTRSET_LOG_COUNT; + tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; + total = args.total; + } else { + XFS_STATS_INC(mp, xs_attr_remove); - error = xfs_qm_dqattach(dp); - if (error) - return error; + tres = M_RES(mp)->tr_attrrm; + total = XFS_ATTRRM_SPACE_RES(mp); + } /* * Root fork attributes can use reserved data blocks for this * operation if necessary */ - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_attrrm, - XFS_ATTRRM_SPACE_RES(mp), 0, - (flags & ATTR_ROOT) ? XFS_TRANS_RESERVE : 0, - &args.trans); + error = xfs_trans_alloc(mp, &tres, total, 0, + rsvd ? XFS_TRANS_RESERVE : 0, &args.trans); if (error) return error; xfs_ilock(dp, XFS_ILOCK_EXCL); - /* - * No need to make quota reservations here. We expect to release some - * blocks not allocate in the common case. - */ xfs_trans_ijoin(args.trans, dp, 0); + if (value) { + unsigned int quota_flags = XFS_QMOPT_RES_REGBLKS; - error = xfs_attr_remove_args(&args); - if (error) - goto out; + if (rsvd) + quota_flags |= XFS_QMOPT_FORCE_RES; + error = xfs_trans_reserve_quota_nblks(args.trans, dp, + args.total, 0, quota_flags); + if (error) + goto out_trans_cancel; + error = xfs_attr_set_args(&args); + if (error) + goto out_trans_cancel; + /* shortform attribute has already been committed */ + if (!args.trans) + goto out_unlock; + } else { + error = xfs_attr_remove_args(&args); + if (error) + goto out_trans_cancel; + } /* * If this is a synchronous mount, make sure that the @@ -508,15 +456,14 @@ xfs_attr_remove( */ xfs_trans_log_inode(args.trans, dp, XFS_ILOG_CORE); error = xfs_trans_commit(args.trans); +out_unlock: xfs_iunlock(dp, XFS_ILOCK_EXCL); - return error; -out: +out_trans_cancel: if (args.trans) xfs_trans_cancel(args.trans); - xfs_iunlock(dp, XFS_ILOCK_EXCL); - return error; + goto out_unlock; } /*======================================================================== diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 71bcf12..db58a6c 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -152,8 +152,6 @@ int xfs_attr_get(struct xfs_inode *ip, const unsigned char *name, int xfs_attr_set(struct xfs_inode *dp, const unsigned char *name, size_t namelen, unsigned char *value, int valuelen, int flags); int xfs_attr_set_args(struct xfs_da_args *args); -int xfs_attr_remove(struct xfs_inode *dp, const unsigned char *name, - size_t namelen, int flags); int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize, int flags, struct attrlist_cursor_kern *cursor); From patchwork Thu Apr 30 22:46:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521819 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 6F152913 for ; Thu, 30 Apr 2020 22:47:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 574B120873 for ; Thu, 30 Apr 2020 22:47:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="lUn5kHeT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727100AbgD3WrJ (ORCPT ); Thu, 30 Apr 2020 18:47:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43676 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727027AbgD3WrJ (ORCPT ); Thu, 30 Apr 2020 18:47:09 -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 03UMgqDS128228 for ; Thu, 30 Apr 2020 22:47:07 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=EgohZvcFnhyV76yoltaa5bD231Ba1Fj2lCW8gC1wSKI=; b=lUn5kHeTATq4v8BieHkO4NkvOlDtXt1EKwthS42oIpXC5gWugQUC5kiftF6RCUorCPXf wxqwJADr2NTKS5+hIuFWXZns9kKM7JqGBJyRI4jxPaypaPlw0MdW71is8roSEQ0qHPbb iBp8NGzCAV7xQj3a3xk0CjNloNw3avEA4Wx5+mfwjihbJen/h96hiQJSkTyn/WX7L68k p4G69x/z8tKAdhHt8hakaLoj9Hw3MeYpgbDMOSJsfIQHyiiuGbBoRIGF6ZqluhCUagat RW7x3PVCl9vo6OdjeSSR+HDr1uRy/wd67UInG5erZ2JmY/jNxqT1kkHivKOpX6tgtUJz Ag== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 30r7f3g22r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:07 +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 03UMgD9N141464 for ; Thu, 30 Apr 2020 22:47:06 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 30qtg23dp7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:06 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMl68q012793 for ; Thu, 30 Apr 2020 22:47:06 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:05 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 03/43] xfsprogs: remove the name == NULL check from xfs_attr_args_init Date: Thu, 30 Apr 2020 15:46:20 -0700 Message-Id: <20200430224700.4183-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org All callers provide a valid name pointer, remove the redundant check. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 6c56428..b7c46c0 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -65,10 +65,6 @@ xfs_attr_args_init( size_t namelen, int flags) { - - if (!name) - return -EINVAL; - memset(args, 0, sizeof(*args)); args->geo = dp->i_mount->m_attr_geo; args->whichfork = XFS_ATTR_FORK; From patchwork Thu Apr 30 22:46:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521885 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 BB56F18A4 for ; Thu, 30 Apr 2020 22:49:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A49A720870 for ; Thu, 30 Apr 2020 22:49:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Va10btPC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726285AbgD3WtK (ORCPT ); Thu, 30 Apr 2020 18:49:10 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60334 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727124AbgD3WtJ (ORCPT ); Thu, 30 Apr 2020 18:49:09 -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 03UMlXLc066919 for ; Thu, 30 Apr 2020 22:49: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=BOD0LOZtG4VezGq74iXQ8aUjJTE1jyIhn68/qZLSKzo=; b=Va10btPCOoysUo1vDr8KeZA1wOtLqJoCpI6WiKI6m5aWnEKQkSsE5FPcst2wUIVIlb6b b1vw4Nncd+NBcPTm2+3ds2hrSfOpfw5GoVYkmMn7hpHYjIF+kJQt7xxzHMqq2LS/2grd yJzkTDKM5H3gahjtP3ZXteWChACmMZeIR8K0qLQCYdVuSkRHzjH9BCwKZoACkxDNy/Lm ETuRGjxCztJAteUJ92JKXVNXIfP0xZY8C/PZAQuxsPwNUrs4XR6WFH+pQagkqJnCoHpJ vwUE03s4S4CcwLJqfRezbWVGsTnJyphkGjU0YFDkoFh4GF4FP1VJ4BkxBPF4q+GDsBYK Nw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 30r7f802e5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:49:08 +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 03UMgSXM015967 for ; Thu, 30 Apr 2020 22:47:07 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 30r7f298e2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:07 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMl6Rp012277 for ; Thu, 30 Apr 2020 22:47:06 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:06 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 04/43] xfsprogs: remove the MAXNAMELEN check from xfs_attr_args_init Date: Thu, 30 Apr 2020 15:46:21 -0700 Message-Id: <20200430224700.4183-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 adultscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org All the callers already check the length when allocating the in-kernel xattrs buffers. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index b7c46c0..00cd7c2 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -72,9 +72,6 @@ xfs_attr_args_init( args->flags = flags; args->name = name; args->namelen = namelen; - if (args->namelen >= MAXNAMELEN) - return -EFAULT; /* match IRIX behaviour */ - args->hashval = xfs_da_hashname(args->name, args->namelen); return 0; } From patchwork Thu Apr 30 22:46:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521817 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 33EA51805 for ; Thu, 30 Apr 2020 22:47:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C34920774 for ; Thu, 30 Apr 2020 22:47:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="E4L1WyOy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727062AbgD3WrJ (ORCPT ); Thu, 30 Apr 2020 18:47:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43672 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726817AbgD3WrJ (ORCPT ); Thu, 30 Apr 2020 18:47:09 -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 03UMguKc128316 for ; Thu, 30 Apr 2020 22:47:07 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=iydhf0LB5YIEF9EBBSOiFHX9VFA4DhbfPRT/qsdcfNY=; b=E4L1WyOySKPJgph0bDpn9OyWtNZUFL+yxLt7TnXEkMs5O0vHtC32XFb7u6eeFafccrc2 abgARAPU+5g7BLM260bF4ZDpVOvEdGBnMhped+mfhz8532XC9adYjuIk395idMllfeef TIJI7Y0RFjvytd/j26Jh0Y8khQGtuTUKHAv1BqEd2v0JGoMnVYFignzmgTrPQYewhxhy y6by5jSGcoslYj+bQnKiMT7M8tWCsGFSx/qCI5Gq8YSjZKn9+nL0sp6GMD3uDRldeAI8 trtZn0LlvZEgll2HLxXLuLJ7KJGqx+Y7AFjOJme4RsFjcGtfJGlBYhtHW19Fj6ucdAgC Yg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 30r7f3g22s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:07 +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 03UMgumJ077017 for ; Thu, 30 Apr 2020 22:47:06 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 30r7f89yv4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:06 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMl6P0031984 for ; Thu, 30 Apr 2020 22:47:06 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:06 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 05/43] xfsprogs: turn xfs_da_args.value into a void pointer Date: Thu, 30 Apr 2020 15:46:22 -0700 Message-Id: <20200430224700.4183-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The xattr values are blobs and should not be typed. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_da_btree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxfs/xfs_da_btree.h b/libxfs/xfs_da_btree.h index 0f4fbb0..0967d1b 100644 --- a/libxfs/xfs_da_btree.h +++ b/libxfs/xfs_da_btree.h @@ -57,7 +57,7 @@ typedef struct xfs_da_args { const uint8_t *name; /* string (maybe not NULL terminated) */ int namelen; /* length of string (maybe no NULL) */ uint8_t filetype; /* filetype of inode for directories */ - uint8_t *value; /* set of bytes (maybe contain NULLs) */ + void *value; /* set of bytes (maybe contain NULLs) */ int valuelen; /* length of value */ int flags; /* argument flags (eg: ATTR_NOCREATE) */ xfs_dahash_t hashval; /* hash value of name */ From patchwork Thu Apr 30 22:46:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521821 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 DC80117EF for ; Thu, 30 Apr 2020 22:47:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3D2820774 for ; Thu, 30 Apr 2020 22:47:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="MHnMuujv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727027AbgD3WrK (ORCPT ); Thu, 30 Apr 2020 18:47:10 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:58852 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727057AbgD3WrK (ORCPT ); Thu, 30 Apr 2020 18:47: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 03UMhiUS063692 for ; Thu, 30 Apr 2020 22:47:07 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=NsVaLSWlUl8F1K6hY1/VK4rCXNSeDosL4h+VnArxnsg=; b=MHnMuujv0y3Qcu4lBmW4eII624Ov/6T27WbhRLyByMGn3bPrnjTAwaNUDXSNPgB031OH u3ca+BWD3hbvrXIczLAQYSfyv1ppaZXMpwmVD2/YUMIu69qD9teX0UByi2MsM3dO6e7n SFcDsceHC0Nnv80ea39RA5c39pv71N4t1sgwhsS+wvXdz75P05r/Ra2ny3iAP/jPmT0D rHGIA8+GzLLoyASDdvRpfcRfMY96pWwWw6f8r4Ic2vghSpiXMDCBaB/ECI6OWM6LG90W oA6rDXHjGhwXf6vrHQTErCk+JOfIGlxPmHm2NVRbLWbP98c2RzZKNrRBsd/9cSNW6LXN 7w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30r7f8027r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:07 +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 03UMgER3141553 for ; Thu, 30 Apr 2020 22:47:07 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 30qtg23dpu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:07 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMl6sc012281 for ; Thu, 30 Apr 2020 22:47:06 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:06 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 06/43] xfsprogs: pass an initialized xfs_da_args structure to xfs_attr_set Date: Thu, 30 Apr 2020 15:46:23 -0700 Message-Id: <20200430224700.4183-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Instead of converting from one style of arguments to another in xfs_attr_set, pass the structure from higher up in the call chain. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- db/attrset.c | 34 ++++++++++++++++++--------- libxfs/xfs_attr.c | 69 +++++++++++++++++++++++++------------------------------ libxfs/xfs_attr.h | 3 +-- 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/db/attrset.c b/db/attrset.c index 708e71e3..0b5aabb 100644 --- a/db/attrset.c +++ b/db/attrset.c @@ -66,9 +66,10 @@ attr_set_f( int argc, char **argv) { - xfs_inode_t *ip = NULL; - char *name, *value, *sp; - int c, valuelen = 0, flags = 0; + xfs_inode_t *ip = NULL; + char *name, *value, *sp; + int c, valuelen = 0, flags = 0; + struct xfs_da_args args; if (cur_typ == NULL) { dbprintf(_("no current type\n")); @@ -146,8 +147,13 @@ attr_set_f( goto out; } - if (libxfs_attr_set(ip, (unsigned char *)name, strlen(name), - (unsigned char *)value, valuelen, flags)) { + args.dp = ip; + args.name = (unsigned char *)name; + args.namelen = strlen(name); + args.value = (unsigned char *)value; + args.flags = flags; + + if (libxfs_attr_set(&args)){ dbprintf(_("failed to set attr %s on inode %llu\n"), name, (unsigned long long)iocur_top->ino); goto out; @@ -170,10 +176,10 @@ attr_remove_f( int argc, char **argv) { - xfs_inode_t *ip = NULL; - char *name; - int c, flags = 0; - + xfs_inode_t *ip = NULL; + char *name; + int c, flags = 0; + struct xfs_da_args args; if (cur_typ == NULL) { dbprintf(_("no current type\n")); return 0; @@ -222,8 +228,14 @@ attr_remove_f( goto out; } - if (libxfs_attr_set(ip, (unsigned char *)name, strlen(name), NULL, 0, - flags)){ + args.dp = ip; + args.name = (unsigned char *)name; + args.namelen = strlen(name); + args.value = NULL; + args.valuelen = 0; + args.flags = flags; + + if (libxfs_attr_set(&args)){ dbprintf(_("failed to remove attr %s from inode %llu\n"), name, (unsigned long long)iocur_top->ino); goto out; diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 00cd7c2..bc64e92 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -330,22 +330,17 @@ xfs_attr_remove_args( } /* - * Note: If value is NULL the attribute will be removed, just like the + * Note: If args->value is NULL the attribute will be removed, just like the * Linux ->setattr API. */ int xfs_attr_set( - struct xfs_inode *dp, - const unsigned char *name, - size_t namelen, - unsigned char *value, - int valuelen, - int flags) + struct xfs_da_args *args) { + struct xfs_inode *dp = args->dp; struct xfs_mount *mp = dp->i_mount; - struct xfs_da_args args; struct xfs_trans_res tres; - int rsvd = (flags & ATTR_ROOT) != 0; + int rsvd = (args->flags & ATTR_ROOT) != 0; int error, local; unsigned int total; @@ -356,25 +351,22 @@ xfs_attr_set( if (error) return error; - error = xfs_attr_args_init(&args, dp, name, namelen, flags); - if (error) - return error; - - args.value = value; - args.valuelen = valuelen; + args->geo = mp->m_attr_geo; + args->whichfork = XFS_ATTR_FORK; + args->hashval = xfs_da_hashname(args->name, args->namelen); /* * We have no control over the attribute names that userspace passes us * to remove, so we have to allow the name lookup prior to attribute * removal to fail as well. */ - args.op_flags = XFS_DA_OP_OKNOENT; + args->op_flags = XFS_DA_OP_OKNOENT; - if (value) { + if (args->value) { XFS_STATS_INC(mp, xs_attr_set); - args.op_flags |= XFS_DA_OP_ADDNAME; - args.total = xfs_attr_calc_size(&args, &local); + args->op_flags |= XFS_DA_OP_ADDNAME; + args->total = xfs_attr_calc_size(args, &local); /* * If the inode doesn't have an attribute fork, add one. @@ -382,8 +374,8 @@ xfs_attr_set( */ if (XFS_IFORK_Q(dp) == 0) { int sf_size = sizeof(struct xfs_attr_sf_hdr) + - XFS_ATTR_SF_ENTSIZE_BYNAME(args.namelen, - valuelen); + XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, + args->valuelen); error = xfs_bmap_add_attrfork(dp, sf_size, rsvd); if (error) @@ -391,10 +383,11 @@ xfs_attr_set( } tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + - M_RES(mp)->tr_attrsetrt.tr_logres * args.total; + M_RES(mp)->tr_attrsetrt.tr_logres * + args->total; tres.tr_logcount = XFS_ATTRSET_LOG_COUNT; tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; - total = args.total; + total = args->total; } else { XFS_STATS_INC(mp, xs_attr_remove); @@ -407,29 +400,29 @@ xfs_attr_set( * operation if necessary */ error = xfs_trans_alloc(mp, &tres, total, 0, - rsvd ? XFS_TRANS_RESERVE : 0, &args.trans); + rsvd ? XFS_TRANS_RESERVE : 0, &args->trans); if (error) return error; xfs_ilock(dp, XFS_ILOCK_EXCL); - xfs_trans_ijoin(args.trans, dp, 0); - if (value) { + xfs_trans_ijoin(args->trans, dp, 0); + if (args->value) { unsigned int quota_flags = XFS_QMOPT_RES_REGBLKS; if (rsvd) quota_flags |= XFS_QMOPT_FORCE_RES; - error = xfs_trans_reserve_quota_nblks(args.trans, dp, - args.total, 0, quota_flags); + error = xfs_trans_reserve_quota_nblks(args->trans, dp, + args->total, 0, quota_flags); if (error) goto out_trans_cancel; - error = xfs_attr_set_args(&args); + error = xfs_attr_set_args(args); if (error) goto out_trans_cancel; /* shortform attribute has already been committed */ - if (!args.trans) + if (!args->trans) goto out_unlock; } else { - error = xfs_attr_remove_args(&args); + error = xfs_attr_remove_args(args); if (error) goto out_trans_cancel; } @@ -439,23 +432,23 @@ xfs_attr_set( * transaction goes to disk before returning to the user. */ if (mp->m_flags & XFS_MOUNT_WSYNC) - xfs_trans_set_sync(args.trans); + xfs_trans_set_sync(args->trans); - if ((flags & ATTR_KERNOTIME) == 0) - xfs_trans_ichgtime(args.trans, dp, XFS_ICHGTIME_CHG); + if ((args->flags & ATTR_KERNOTIME) == 0) + xfs_trans_ichgtime(args->trans, dp, XFS_ICHGTIME_CHG); /* * Commit the last in the sequence of transactions. */ - xfs_trans_log_inode(args.trans, dp, XFS_ILOG_CORE); - error = xfs_trans_commit(args.trans); + xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE); + error = xfs_trans_commit(args->trans); out_unlock: xfs_iunlock(dp, XFS_ILOCK_EXCL); return error; out_trans_cancel: - if (args.trans) - xfs_trans_cancel(args.trans); + if (args->trans) + xfs_trans_cancel(args->trans); goto out_unlock; } diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index db58a6c..07ca543 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -149,8 +149,7 @@ int xfs_attr_get_ilocked(struct xfs_inode *ip, struct xfs_da_args *args); int xfs_attr_get(struct xfs_inode *ip, const unsigned char *name, size_t namelen, unsigned char **value, int *valuelenp, int flags); -int xfs_attr_set(struct xfs_inode *dp, const unsigned char *name, - size_t namelen, unsigned char *value, int valuelen, int flags); +int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_args(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize, From patchwork Thu Apr 30 22:46:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521889 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 859E215AB for ; Thu, 30 Apr 2020 22:49:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DDE420870 for ; Thu, 30 Apr 2020 22:49:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="uNR8X008" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726401AbgD3WtL (ORCPT ); Thu, 30 Apr 2020 18:49:11 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:49952 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727888AbgD3WtK (ORCPT ); Thu, 30 Apr 2020 18:49: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 03UMlXPi050766 for ; Thu, 30 Apr 2020 22:49: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=m37ptyzmIlB9pMTmy2UUktWz+7WyoJEn9LXSavkE1Uo=; b=uNR8X0084sMmacKjaL1euXQxe3pcyKbtu/tmM1+MpXGlMiKuruJbv/jZPp/32LUSDFR1 p7wQvB1PZr2ZKhQoXQLFndD4PtHmOTQA2zYxPnsetdnZkHXkcjIYxB6w6pq7dqDHvK8h YV+EHSGM0NtYm9h1N1UYof1vobJD36ByeeDHuSsj/uVKFMRBoCd3XqKVo4NDvW0q4YUp pq+8p6AHYpiFCROB6HX2QeyGgyjQ9zhy+9/ooQ2Kz/rVcoGH68S24PI3Xp8NRb1FgCMp bTWlH83aIT43IrlXVt/NQnVCCfgXKVHgegarmMNy0vY2KWJ8Bn3KXSkWhVmo5hBPjKgC hw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 30r7f5r2e2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:49: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 03UMgtUF076926 for ; Thu, 30 Apr 2020 22:47:08 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 30r7f89yw8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:08 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMl7vC012798 for ; Thu, 30 Apr 2020 22:47:07 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:06 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 07/43] xfsprogs: pass an initialized xfs_da_args to xfs_attr_get Date: Thu, 30 Apr 2020 15:46:24 -0700 Message-Id: <20200430224700.4183-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=3 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=3 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Instead of converting from one style of arguments to another in xfs_attr_set, pass the structure from higher up in the call chain. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 80 ++++++++++++++++--------------------------------------- libxfs/xfs_attr.h | 4 +-- 2 files changed, 24 insertions(+), 60 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index bc64e92..9aead7c 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -56,26 +56,6 @@ STATIC int xfs_attr_node_removename(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_args_init( - struct xfs_da_args *args, - struct xfs_inode *dp, - const unsigned char *name, - size_t namelen, - int flags) -{ - memset(args, 0, sizeof(*args)); - args->geo = dp->i_mount->m_attr_geo; - args->whichfork = XFS_ATTR_FORK; - args->dp = dp; - args->flags = flags; - args->name = name; - args->namelen = namelen; - args->hashval = xfs_da_hashname(args->name, args->namelen); - return 0; -} - int xfs_inode_hasattr( struct xfs_inode *ip) @@ -115,15 +95,15 @@ xfs_attr_get_ilocked( /* * Retrieve an extended attribute by name, and its value if requested. * - * If ATTR_KERNOVAL is set in @flags, then the caller does not want the value, - * just an indication whether the attribute exists and the size of the value if - * it exists. The size is returned in @valuelenp, + * If ATTR_KERNOVAL is set in args->flags, then the caller does not want the + * value, just an indication whether the attribute exists and the size of the + * value if it exists. The size is returned in args.valuelen. * * If the attribute is found, but exceeds the size limit set by the caller in - * @valuelenp, return -ERANGE with the size of the attribute that was found in - * @valuelenp. + * args->valuelen, return -ERANGE with the size of the attribute that was found + * in args->valuelen. * - * If ATTR_ALLOC is set in @flags, allocate the buffer for the value after + * If ATTR_ALLOC is set in args->flags, allocate the buffer for the value after * existence of the attribute has been determined. On success, return that * buffer to the caller and leave them to free it. On failure, free any * allocated buffer and ensure the buffer pointer returned to the caller is @@ -131,51 +111,37 @@ xfs_attr_get_ilocked( */ int xfs_attr_get( - struct xfs_inode *ip, - const unsigned char *name, - size_t namelen, - unsigned char **value, - int *valuelenp, - int flags) + struct xfs_da_args *args) { - struct xfs_da_args args; uint lock_mode; int error; - ASSERT((flags & (ATTR_ALLOC | ATTR_KERNOVAL)) || *value); + ASSERT((args->flags & (ATTR_ALLOC | ATTR_KERNOVAL)) || args->value); - XFS_STATS_INC(ip->i_mount, xs_attr_get); + XFS_STATS_INC(args->dp->i_mount, xs_attr_get); - if (XFS_FORCED_SHUTDOWN(ip->i_mount)) + if (XFS_FORCED_SHUTDOWN(args->dp->i_mount)) return -EIO; - error = xfs_attr_args_init(&args, ip, name, namelen, flags); - if (error) - return error; + args->geo = args->dp->i_mount->m_attr_geo; + args->whichfork = XFS_ATTR_FORK; + args->hashval = xfs_da_hashname(args->name, args->namelen); /* Entirely possible to look up a name which doesn't exist */ - args.op_flags = XFS_DA_OP_OKNOENT; - if (flags & ATTR_ALLOC) - args.op_flags |= XFS_DA_OP_ALLOCVAL; - else - args.value = *value; - args.valuelen = *valuelenp; + args->op_flags = XFS_DA_OP_OKNOENT; + if (args->flags & ATTR_ALLOC) + args->op_flags |= XFS_DA_OP_ALLOCVAL; - lock_mode = xfs_ilock_attr_map_shared(ip); - error = xfs_attr_get_ilocked(ip, &args); - xfs_iunlock(ip, lock_mode); - *valuelenp = args.valuelen; + lock_mode = xfs_ilock_attr_map_shared(args->dp); + error = xfs_attr_get_ilocked(args->dp, args); + xfs_iunlock(args->dp, lock_mode); /* on error, we have to clean up allocated value buffers */ - if (error) { - if (flags & ATTR_ALLOC) { - kmem_free(args.value); - *value = NULL; - } - return error; + if (error && (args->flags & ATTR_ALLOC)) { + kmem_free(args->value); + args->value = NULL; } - *value = args.value; - return 0; + return error; } /* diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 07ca543..be77d13 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -146,9 +146,7 @@ int xfs_attr_list_int_ilocked(struct xfs_attr_list_context *); int xfs_attr_list_int(struct xfs_attr_list_context *); int xfs_inode_hasattr(struct xfs_inode *ip); int xfs_attr_get_ilocked(struct xfs_inode *ip, struct xfs_da_args *args); -int xfs_attr_get(struct xfs_inode *ip, const unsigned char *name, - size_t namelen, unsigned char **value, int *valuelenp, - int flags); +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_remove_args(struct xfs_da_args *args); From patchwork Thu Apr 30 22:46: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: 11521887 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 F2DFE913 for ; Thu, 30 Apr 2020 22:49:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB05E207DD for ; Thu, 30 Apr 2020 22:49:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="LpL6W0p6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726384AbgD3WtK (ORCPT ); Thu, 30 Apr 2020 18:49:10 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:49944 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727808AbgD3WtK (ORCPT ); Thu, 30 Apr 2020 18:49: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 03UMlarC050811 for ; Thu, 30 Apr 2020 22:49: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=ueqWvFV0kzE5X3SDYHn1mgE/Oh2YY3Sn27HLcAiIz1I=; b=LpL6W0p60JYHxFCkYXBzgJTtKvH4HuIyIUzyqu3YQXkLVXd+Up4pErt6m7jsKGbeEIrc CQFielxfTBp0eI7Iam7aaQpK6vwI0vVb9YCUUKIncbTXDTX+kdnwBdJ7tDHjZ74s9Umr VsGjjvFDJiAPJ4VM8T04XuRablBvvBVnkph6s9P544GmBSJxjwdVt2cHeqc0ixVyXxbh +alGn+GzHfoIZng9kq5/RVnPB7dqvMLSUpRPl78yjl0LqVy2x/fa4c6hMyk+nhjt/Kk0 g2yPh68fkFpDFqWifdT6Gumr2BsP527pa3OzpCqKLRG7AeChV4lB4wnd5lj08kkUPT8K +A== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 30r7f5r2e3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:49: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 03UMhPI6181214 for ; Thu, 30 Apr 2020 22:47:08 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 30r7fes28h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:08 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMl7QM011739 for ; Thu, 30 Apr 2020 22:47:07 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:07 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 08/43] xfsprogs: remove the xfs_inode argument to xfs_attr_get_ilocked Date: Thu, 30 Apr 2020 15:46:25 -0700 Message-Id: <20200430224700.4183-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The inode can easily be derived from the args structure. Also don't bother with else statements after early returns. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 15 +++++++-------- libxfs/xfs_attr.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 9aead7c..72c03f67 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -77,19 +77,18 @@ xfs_inode_hasattr( */ int xfs_attr_get_ilocked( - struct xfs_inode *ip, struct xfs_da_args *args) { - ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); + ASSERT(xfs_isilocked(args->dp, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); - if (!xfs_inode_hasattr(ip)) + if (!xfs_inode_hasattr(args->dp)) return -ENOATTR; - else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) + + if (args->dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) return xfs_attr_shortform_getvalue(args); - else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK)) + if (xfs_bmap_one_block(args->dp, XFS_ATTR_FORK)) return xfs_attr_leaf_get(args); - else - return xfs_attr_node_get(args); + return xfs_attr_node_get(args); } /* @@ -133,7 +132,7 @@ xfs_attr_get( args->op_flags |= XFS_DA_OP_ALLOCVAL; lock_mode = xfs_ilock_attr_map_shared(args->dp); - error = xfs_attr_get_ilocked(args->dp, args); + error = xfs_attr_get_ilocked(args); xfs_iunlock(args->dp, lock_mode); /* on error, we have to clean up allocated value buffers */ diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index be77d13..b8c4ed2 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -145,7 +145,7 @@ int xfs_attr_inactive(struct xfs_inode *dp); int xfs_attr_list_int_ilocked(struct xfs_attr_list_context *); int xfs_attr_list_int(struct xfs_attr_list_context *); int xfs_inode_hasattr(struct xfs_inode *ip); -int xfs_attr_get_ilocked(struct xfs_inode *ip, struct xfs_da_args *args); +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); From patchwork Thu Apr 30 22:46: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: 11521815 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 DE96515AB for ; Thu, 30 Apr 2020 22:47:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C61C02074A for ; Thu, 30 Apr 2020 22:47:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="nnUhvKLu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726784AbgD3WrJ (ORCPT ); Thu, 30 Apr 2020 18:47:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43686 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727062AbgD3WrJ (ORCPT ); Thu, 30 Apr 2020 18:47:09 -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 03UMgrP1128243 for ; Thu, 30 Apr 2020 22:47: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=5iZ3kZtH3a6tQNE8l5DNVTs/K3RhAi61CQT1fTfrwd4=; b=nnUhvKLuGqfMMNhnSJrt/sKyB9onrEi8QPq3xcJJOXExEsh4mUG62khyodr66TnOsA2f QG7/YtnVUtnFaJdOxnhvnzSrXGqKP5dVrVUiu7K6LoFRcJi7UeErCzxRGKBNm5tCWoTB +S1FwieiGSl7dL/t7jtftKSsJK1tGP7JmxF/feDCSNI/f0o9oafAtjL4/7cPQTGQhi1x bVLu4G41ck7qnW3tRDJBQPZVDhMnsZIpmkR3muGXerI9NazLjL+4oOIOygt2poDAKulO c7jTZb7B81jGPGuVMwe3lPYhV/56WxqEjyGvF2y/TEQxiqlewAdPHc+Y5UgxZ6v/x2Xa dw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 30r7f3g22x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:08 +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 03UMgSNU016166 for ; Thu, 30 Apr 2020 22:47:08 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 30r7f298ew-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:07 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMl7Uc011742 for ; Thu, 30 Apr 2020 22:47:07 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:07 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 09/43] xfsprogs: remove ATTR_KERNOVAL Date: Thu, 30 Apr 2020 15:46:26 -0700 Message-Id: <20200430224700.4183-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 adultscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org We can just pass down the Linux convention of a zero valuelen to just query for the existance of an attribute to the low-level code instead. The use in the legacy xfs_attr_list code only used by the ioctl interface was already dead code, as the callers check that the flag is not present. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 8 ++++---- libxfs/xfs_attr.h | 4 +--- libxfs/xfs_attr_leaf.c | 14 +++++++------- libxfs/xfs_attr_remote.c | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 72c03f67..db724af 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -94,9 +94,9 @@ xfs_attr_get_ilocked( /* * Retrieve an extended attribute by name, and its value if requested. * - * If ATTR_KERNOVAL is set in args->flags, then the caller does not want the - * value, just an indication whether the attribute exists and the size of the - * value if it exists. The size is returned in args.valuelen. + * If args->valuelen is zero, then the caller does not want the value, just an + * indication whether the attribute exists and the size of the value if it + * exists. The size is returned in args.valuelen. * * If the attribute is found, but exceeds the size limit set by the caller in * args->valuelen, return -ERANGE with the size of the attribute that was found @@ -115,7 +115,7 @@ xfs_attr_get( uint lock_mode; int error; - ASSERT((args->flags & (ATTR_ALLOC | ATTR_KERNOVAL)) || args->value); + ASSERT((args->flags & ATTR_ALLOC) || !args->valuelen || args->value); XFS_STATS_INC(args->dp->i_mount, xs_attr_get); diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index b8c4ed2..fe064cd 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -34,12 +34,11 @@ struct xfs_attr_list_context; #define ATTR_REPLACE 0x0020 /* pure set: fail if attr does not exist */ #define ATTR_KERNOTIME 0x1000 /* [kernel] don't update inode timestamps */ -#define ATTR_KERNOVAL 0x2000 /* [kernel] get attr size only, not value */ #define ATTR_ALLOC 0x8000 /* [kernel] allocate xattr buffer on demand */ #define ATTR_KERNEL_FLAGS \ - (ATTR_KERNOTIME | ATTR_KERNOVAL | ATTR_ALLOC) + (ATTR_KERNOTIME | ATTR_ALLOC) #define XFS_ATTR_FLAGS \ { ATTR_DONTFOLLOW, "DONTFOLLOW" }, \ @@ -49,7 +48,6 @@ struct xfs_attr_list_context; { ATTR_CREATE, "CREATE" }, \ { ATTR_REPLACE, "REPLACE" }, \ { ATTR_KERNOTIME, "KERNOTIME" }, \ - { ATTR_KERNOVAL, "KERNOVAL" }, \ { ATTR_ALLOC, "ALLOC" } /* diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 541a1ff..8e07e2a 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -461,7 +461,7 @@ xfs_attr_copy_value( /* * No copy if all we have to do is get the length */ - if (args->flags & ATTR_KERNOVAL) { + if (!args->valuelen) { args->valuelen = valuelen; return 0; } @@ -827,9 +827,9 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args) /* * Retrieve the attribute value and length. * - * If ATTR_KERNOVAL is specified, only the length needs to be returned. - * Unlike a lookup, we only return an error if the attribute does not - * exist or we can't retrieve the value. + * If args->valuelen is zero, only the length needs to be returned. Unlike a + * lookup, we only return an error if the attribute does not exist or we can't + * retrieve the value. */ int xfs_attr_shortform_getvalue( @@ -2441,9 +2441,9 @@ xfs_attr3_leaf_lookup_int( * Get the value associated with an attribute name from a leaf attribute * list structure. * - * If ATTR_KERNOVAL is specified, only the length needs to be returned. - * Unlike a lookup, we only return an error if the attribute does not - * exist or we can't retrieve the value. + * If args->valuelen is zero, only the length needs to be returned. Unlike a + * lookup, we only return an error if the attribute does not exist or we can't + * retrieve the value. */ int xfs_attr3_leaf_getvalue( diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index b2a0156..a9a48b30 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -396,7 +396,7 @@ xfs_attr_rmtval_get( trace_xfs_attr_rmtval_get(args); - ASSERT(!(args->flags & ATTR_KERNOVAL)); + ASSERT(args->valuelen != 0); ASSERT(args->rmtvaluelen == args->valuelen); valuelen = args->rmtvaluelen; From patchwork Thu Apr 30 22:46: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: 11521823 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 5272C15AB for ; Thu, 30 Apr 2020 22:47:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A71F2074A for ; Thu, 30 Apr 2020 22:47:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="BkouQyD+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727057AbgD3WrK (ORCPT ); Thu, 30 Apr 2020 18:47:10 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:58860 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727077AbgD3WrK (ORCPT ); Thu, 30 Apr 2020 18:47: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 03UMi5bJ063812 for ; Thu, 30 Apr 2020 22:47: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=eSBij3GsuVcuSrdxBUgM1u4nrS7kwiIPn8MxKJOfcTk=; b=BkouQyD+wQKPHbnsVGuhYWGm/vt6rglUKF9h6ymd+bfgAibvF1RXEjHF8uqTpaMY4B9N xH2Z0u+GqghnnlPAOIkiuKI53tU5X7njawwS43wdiFcslb9xIgmaqD8dRDx+JGFkLEhs nuSJu5wNiEF+EDGDId/EN7XRRWo5/fljE+/RGbhHl7uWx3qEAGfSS1QAk5g2463ZWDTe 8mPHGgZIHq26ZQcPdWfC4tJ3de3v0X27gemKAoL110D26K55D21azbl4HTlgiokbqCvW vuNxJmty+wmfclZpRZgWg0Z56N1LUkexpRPN406HQIeojUVzW4qzGQPn8GDPeeeucI3P jQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 30r7f8027t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:08 +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 03UMgt0P076959 for ; Thu, 30 Apr 2020 22:47:08 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 30r7f89yx1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:08 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMl7AA011746 for ; Thu, 30 Apr 2020 22:47:07 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:07 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 10/43] xfsprogs: remove ATTR_ALLOC and XFS_DA_OP_ALLOCVAL Date: Thu, 30 Apr 2020 15:46:27 -0700 Message-Id: <20200430224700.4183-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=3 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=3 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Use a NULL args->value as the indicator to lazily allocate a buffer instead, and let the caller always free args->value instead of duplicating the cleanup. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 20 +++++--------------- libxfs/xfs_attr.h | 7 ++----- libxfs/xfs_attr_leaf.c | 2 +- libxfs/xfs_da_btree.h | 2 -- 4 files changed, 8 insertions(+), 23 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index db724af..7adc547 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -98,15 +98,14 @@ xfs_attr_get_ilocked( * indication whether the attribute exists and the size of the value if it * exists. The size is returned in args.valuelen. * + * If args->value is NULL but args->valuelen is non-zero, allocate the buffer + * for the value after existence of the attribute has been determined. The + * caller always has to free args->value if it is set, no matter if this + * function was successful or not. + * * If the attribute is found, but exceeds the size limit set by the caller in * args->valuelen, return -ERANGE with the size of the attribute that was found * in args->valuelen. - * - * If ATTR_ALLOC is set in args->flags, allocate the buffer for the value after - * existence of the attribute has been determined. On success, return that - * buffer to the caller and leave them to free it. On failure, free any - * allocated buffer and ensure the buffer pointer returned to the caller is - * null. */ int xfs_attr_get( @@ -115,8 +114,6 @@ xfs_attr_get( uint lock_mode; int error; - ASSERT((args->flags & ATTR_ALLOC) || !args->valuelen || args->value); - XFS_STATS_INC(args->dp->i_mount, xs_attr_get); if (XFS_FORCED_SHUTDOWN(args->dp->i_mount)) @@ -128,18 +125,11 @@ xfs_attr_get( /* Entirely possible to look up a name which doesn't exist */ args->op_flags = XFS_DA_OP_OKNOENT; - if (args->flags & ATTR_ALLOC) - args->op_flags |= XFS_DA_OP_ALLOCVAL; lock_mode = xfs_ilock_attr_map_shared(args->dp); error = xfs_attr_get_ilocked(args); xfs_iunlock(args->dp, lock_mode); - /* on error, we have to clean up allocated value buffers */ - if (error && (args->flags & ATTR_ALLOC)) { - kmem_free(args->value); - args->value = NULL; - } return error; } diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index fe064cd..a6de050 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -35,10 +35,8 @@ struct xfs_attr_list_context; #define ATTR_KERNOTIME 0x1000 /* [kernel] don't update inode timestamps */ -#define ATTR_ALLOC 0x8000 /* [kernel] allocate xattr buffer on demand */ - #define ATTR_KERNEL_FLAGS \ - (ATTR_KERNOTIME | ATTR_ALLOC) + (ATTR_KERNOTIME) #define XFS_ATTR_FLAGS \ { ATTR_DONTFOLLOW, "DONTFOLLOW" }, \ @@ -47,8 +45,7 @@ struct xfs_attr_list_context; { ATTR_SECURE, "SECURE" }, \ { ATTR_CREATE, "CREATE" }, \ { ATTR_REPLACE, "REPLACE" }, \ - { ATTR_KERNOTIME, "KERNOTIME" }, \ - { ATTR_ALLOC, "ALLOC" } + { ATTR_KERNOTIME, "KERNOTIME" } /* * The maximum size (into the kernel or returned from the kernel) of an diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 8e07e2a..fb07d1d 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -474,7 +474,7 @@ xfs_attr_copy_value( return -ERANGE; } - if (args->op_flags & XFS_DA_OP_ALLOCVAL) { + if (!args->value) { args->value = kmem_alloc_large(valuelen, 0); if (!args->value) return -ENOMEM; diff --git a/libxfs/xfs_da_btree.h b/libxfs/xfs_da_btree.h index 0967d1b..dd1ac52 100644 --- a/libxfs/xfs_da_btree.h +++ b/libxfs/xfs_da_btree.h @@ -88,7 +88,6 @@ typedef struct xfs_da_args { #define XFS_DA_OP_ADDNAME 0x0004 /* this is an add operation */ #define XFS_DA_OP_OKNOENT 0x0008 /* lookup/add op, ENOENT ok, else die */ #define XFS_DA_OP_CILOOKUP 0x0010 /* lookup to return CI name if found */ -#define XFS_DA_OP_ALLOCVAL 0x0020 /* lookup to alloc buffer if found */ #define XFS_DA_OP_INCOMPLETE 0x0040 /* lookup INCOMPLETE attr keys */ #define XFS_DA_OP_FLAGS \ @@ -97,7 +96,6 @@ typedef struct xfs_da_args { { XFS_DA_OP_ADDNAME, "ADDNAME" }, \ { XFS_DA_OP_OKNOENT, "OKNOENT" }, \ { XFS_DA_OP_CILOOKUP, "CILOOKUP" }, \ - { XFS_DA_OP_ALLOCVAL, "ALLOCVAL" }, \ { XFS_DA_OP_INCOMPLETE, "INCOMPLETE" } /* From patchwork Thu Apr 30 22:46: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: 11521827 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 D07E4913 for ; Thu, 30 Apr 2020 22:47:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8BEE2074A for ; Thu, 30 Apr 2020 22:47:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="0STxmtgG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727097AbgD3WrM (ORCPT ); Thu, 30 Apr 2020 18:47:12 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48398 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727092AbgD3WrK (ORCPT ); Thu, 30 Apr 2020 18:47: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 03UMhfqJ047471 for ; Thu, 30 Apr 2020 22:47: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=auLu4E7jafcZXoiir7sWzdxLX7GhCz+Bs7hlrQNgwnE=; b=0STxmtgGvJdc9Co5fkf14hP/FGHfXSDpXKYJUK7Oh2Wf54+8RdIgOfin3/OUmiCdu0TQ rK6u8/6BubOhk5gUNcbjVT5hXN1Rr8BQthNw8HyFM0VOf7vWXlSTNfuwlSGPkrz1k8uf p369oLjyA7BNhs8jTSW9zeKJ0UFOBHsqGSqnj5oyzLzUQZStu+cP6nydLgWo3Obz4yvu 3DJOx65O/4xhPAFA2EOErxDjRZ/xXbWlXDOkeieDvh+4bY/bkxKvqXTvcmRt2HaAwZX5 crqWjVHYyJKQnVAu8jJ80INpHMiNq6lUAQGQfOw21BlSKW7ZcE5xXff+GAZh6Fg2DO5Z RQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 30r7f5r26h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:09 +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 03UMgGXc141594 for ; Thu, 30 Apr 2020 22:47:09 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 30qtg23dqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:08 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMl8R2011751 for ; Thu, 30 Apr 2020 22:47:08 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:07 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 11/43] xfsprogs: replace ATTR_KERNOTIME with XFS_DA_OP_NOTIME Date: Thu, 30 Apr 2020 15:46:28 -0700 Message-Id: <20200430224700.4183-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org op_flags with the XFS_DA_OP_* flags is the usual place for in-kernel only flags, so move the notime flag there. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 4 ++-- libxfs/xfs_attr.h | 8 +------- libxfs/xfs_da_btree.h | 2 ++ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 7adc547..6298891 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -186,7 +186,7 @@ xfs_attr_try_sf_addname( * Commit the shortform mods, and we're done. * NOTE: this is also the error path (EEXIST, etc). */ - if (!error && (args->flags & ATTR_KERNOTIME) == 0) + 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) @@ -389,7 +389,7 @@ xfs_attr_set( if (mp->m_flags & XFS_MOUNT_WSYNC) xfs_trans_set_sync(args->trans); - if ((args->flags & ATTR_KERNOTIME) == 0) + if (!(args->op_flags & XFS_DA_OP_NOTIME)) xfs_trans_ichgtime(args->trans, dp, XFS_ICHGTIME_CHG); /* diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index a6de050..0f36939 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -33,19 +33,13 @@ struct xfs_attr_list_context; #define ATTR_CREATE 0x0010 /* pure create: fail if attr already exists */ #define ATTR_REPLACE 0x0020 /* pure set: fail if attr does not exist */ -#define ATTR_KERNOTIME 0x1000 /* [kernel] don't update inode timestamps */ - -#define ATTR_KERNEL_FLAGS \ - (ATTR_KERNOTIME) - #define XFS_ATTR_FLAGS \ { ATTR_DONTFOLLOW, "DONTFOLLOW" }, \ { ATTR_ROOT, "ROOT" }, \ { ATTR_TRUST, "TRUST" }, \ { ATTR_SECURE, "SECURE" }, \ { ATTR_CREATE, "CREATE" }, \ - { ATTR_REPLACE, "REPLACE" }, \ - { ATTR_KERNOTIME, "KERNOTIME" } + { ATTR_REPLACE, "REPLACE" } /* * The maximum size (into the kernel or returned from the kernel) of an diff --git a/libxfs/xfs_da_btree.h b/libxfs/xfs_da_btree.h index dd1ac52..d93cb83 100644 --- a/libxfs/xfs_da_btree.h +++ b/libxfs/xfs_da_btree.h @@ -88,6 +88,7 @@ typedef struct xfs_da_args { #define XFS_DA_OP_ADDNAME 0x0004 /* this is an add operation */ #define XFS_DA_OP_OKNOENT 0x0008 /* lookup/add op, ENOENT ok, else die */ #define XFS_DA_OP_CILOOKUP 0x0010 /* lookup to return CI name if found */ +#define XFS_DA_OP_NOTIME 0x0020 /* don't update inode timestamps */ #define XFS_DA_OP_INCOMPLETE 0x0040 /* lookup INCOMPLETE attr keys */ #define XFS_DA_OP_FLAGS \ @@ -96,6 +97,7 @@ typedef struct xfs_da_args { { XFS_DA_OP_ADDNAME, "ADDNAME" }, \ { XFS_DA_OP_OKNOENT, "OKNOENT" }, \ { XFS_DA_OP_CILOOKUP, "CILOOKUP" }, \ + { XFS_DA_OP_NOTIME, "NOTIME" }, \ { XFS_DA_OP_INCOMPLETE, "INCOMPLETE" } /* From patchwork Thu Apr 30 22:46: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: 11521825 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 2072315AB for ; Thu, 30 Apr 2020 22:47:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08748207DD for ; Thu, 30 Apr 2020 22:47:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="dfEEMcq/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727778AbgD3WrL (ORCPT ); Thu, 30 Apr 2020 18:47:11 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:58864 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726817AbgD3WrK (ORCPT ); Thu, 30 Apr 2020 18:47: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 03UMhJQL063530 for ; Thu, 30 Apr 2020 22:47: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=qS/huGSEeO0peQve8+GwCsv19WKf/nAFb30FHyNGCRo=; b=dfEEMcq/0buAjwUAnmvq3yonrrylBdko4vc0K67eh8o7KboUT2hL+ubS6Qi7EUXYGtJH vXdaMAn/y5PKF9qKsRuc9i8kqnAG5tlAVaL3dB2ZytbuV2sdRF1MYadnsgSyWiLZ4BXC YNOTc3jGBF4kCPXvHOjvVme1Hse1nKOXlhC0Bbrr+nDuKv4ZCubaFurnKdUV4libr0z3 hX4oWV3zxDeaHZq/BI27TWqYNc5DohWcsP8BaOeQXBD/JpUlJcCAuSHzWam2msPEj6Fn I4Q/4/rBcQeJTnGkhsb8TmCL7GOrAOj+HV5r8acKHhoB6WZorDuW6dCKD6ymq/8AUE08 9A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 30r7f8027w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:09 +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 03UMgR19015834 for ; Thu, 30 Apr 2020 22:47:08 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 30r7f298fg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:08 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMl8ft031992 for ; Thu, 30 Apr 2020 22:47:08 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:08 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 12/43] xfsprogs: factor out a xfs_attr_match helper Date: Thu, 30 Apr 2020 15:46:29 -0700 Message-Id: <20200430224700.4183-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 adultscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Factor out a helper that compares an on-disk attr vs the name, length and flags specified in struct xfs_da_args. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr_leaf.c | 80 +++++++++++++++++++------------------------------- 1 file changed, 30 insertions(+), 50 deletions(-) diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index fb07d1d..86e3135 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -442,14 +442,21 @@ xfs_attr3_leaf_read( * Namespace helper routines *========================================================================*/ -/* - * If namespace bits don't match return 0. - * If all match then return 1. - */ -STATIC int -xfs_attr_namesp_match(int arg_flags, int ondisk_flags) +static bool +xfs_attr_match( + struct xfs_da_args *args, + uint8_t namelen, + unsigned char *name, + int flags) { - return XFS_ATTR_NSP_ONDISK(ondisk_flags) == XFS_ATTR_NSP_ARGS_TO_ONDISK(arg_flags); + if (args->namelen != namelen) + return false; + if (memcmp(args->name, name, namelen) != 0) + return false; + if (XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags) != + XFS_ATTR_NSP_ONDISK(flags)) + return false; + return true; } static int @@ -675,15 +682,8 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) 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++) { -#ifdef DEBUG - if (sfe->namelen != args->namelen) - continue; - if (memcmp(args->name, sfe->nameval, args->namelen) != 0) - continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) - continue; - ASSERT(0); -#endif + ASSERT(!xfs_attr_match(args, sfe->namelen, sfe->nameval, + sfe->flags)); } offset = (char *)sfe - (char *)sf; @@ -746,13 +746,9 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), base += size, i++) { size = XFS_ATTR_SF_ENTSIZE(sfe); - if (sfe->namelen != args->namelen) - continue; - if (memcmp(sfe->nameval, args->name, args->namelen) != 0) - continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) - continue; - break; + if (xfs_attr_match(args, sfe->namelen, sfe->nameval, + sfe->flags)) + break; } if (i == end) return -ENOATTR; @@ -813,13 +809,9 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args) sfe = &sf->list[0]; for (i = 0; i < sf->hdr.count; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { - if (sfe->namelen != args->namelen) - continue; - if (memcmp(args->name, sfe->nameval, args->namelen) != 0) - continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) - continue; - return -EEXIST; + if (xfs_attr_match(args, sfe->namelen, sfe->nameval, + sfe->flags)) + return -EEXIST; } return -ENOATTR; } @@ -844,14 +836,10 @@ xfs_attr_shortform_getvalue( sfe = &sf->list[0]; for (i = 0; i < sf->hdr.count; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { - if (sfe->namelen != args->namelen) - continue; - if (memcmp(args->name, sfe->nameval, args->namelen) != 0) - continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) - continue; - return xfs_attr_copy_value(args, &sfe->nameval[args->namelen], - sfe->valuelen); + if (xfs_attr_match(args, sfe->namelen, sfe->nameval, + sfe->flags)) + return xfs_attr_copy_value(args, + &sfe->nameval[args->namelen], sfe->valuelen); } return -ENOATTR; } @@ -2406,23 +2394,15 @@ xfs_attr3_leaf_lookup_int( } if (entry->flags & XFS_ATTR_LOCAL) { name_loc = xfs_attr3_leaf_name_local(leaf, probe); - if (name_loc->namelen != args->namelen) - continue; - if (memcmp(args->name, name_loc->nameval, - args->namelen) != 0) - continue; - if (!xfs_attr_namesp_match(args->flags, entry->flags)) + if (!xfs_attr_match(args, name_loc->namelen, + name_loc->nameval, entry->flags)) continue; args->index = probe; return -EEXIST; } else { name_rmt = xfs_attr3_leaf_name_remote(leaf, probe); - if (name_rmt->namelen != args->namelen) - continue; - if (memcmp(args->name, name_rmt->name, - args->namelen) != 0) - continue; - if (!xfs_attr_namesp_match(args->flags, entry->flags)) + if (!xfs_attr_match(args, name_rmt->namelen, + name_rmt->name, entry->flags)) continue; args->index = probe; args->rmtvaluelen = be32_to_cpu(name_rmt->valuelen); From patchwork Thu Apr 30 22:46: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: 11521829 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 0C8D117EF for ; Thu, 30 Apr 2020 22:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8FBC207DD for ; Thu, 30 Apr 2020 22:47:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="AhMBqPih" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727799AbgD3WrL (ORCPT ); Thu, 30 Apr 2020 18:47:11 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:58868 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727097AbgD3WrK (ORCPT ); Thu, 30 Apr 2020 18:47: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 03UMhKX8063547 for ; Thu, 30 Apr 2020 22:47: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=5RjMmjJFI/zKbRhht1DkI51waVOQn4KKaQqO7hbSKaw=; b=AhMBqPihJZFS8ryhrmj4gnOX22xsEKw+YmFv0Sabe9Yv6lSolZYUmrZyHpzef6dwX+m3 ps+tf952nFdDF5QTCGgw2G/yvIt/FEq1tZNhnUMC0Poylik0kRm4QL58YaQapKWydv7X 2JJKTZQCPjgHeenT1gewY6GS0Ynw8jOEKeYCSe/2l4szRUnqTk1s2UVZUYOu2iu0uD9N yMpwTs4H6bIW+o5OOdMmviyoqJX/dTLmZIbr13hq3Obovt/i8fZEGQ0EuFcyh/n/dN5S q7I+hp8EDjF2wuroP2kNACdHuLo2yUOTMvaM+OYzNUpHjuXb2VraK6e06rsILAjibw01 tw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 30r7f8027y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47: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 03UMhP88181131 for ; Thu, 30 Apr 2020 22:47:09 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 30r7fes2a6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:09 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMl81W012289 for ; Thu, 30 Apr 2020 22:47:08 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:08 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 13/43] xfsprogs: cleanup struct xfs_attr_list_context Date: Thu, 30 Apr 2020 15:46:30 -0700 Message-Id: <20200430224700.4183-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Replace the alist char pointer with a void buffer given that different callers use it in different ways. Use the chance to remove the typedef and reduce the indentation of the struct definition so that it doesn't overflow 80 char lines all over. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 0f36939..0c8f7c7 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -99,28 +99,28 @@ typedef struct attrlist_cursor_kern { typedef void (*put_listent_func_t)(struct xfs_attr_list_context *, int, unsigned char *, int, int); -typedef struct xfs_attr_list_context { - struct xfs_trans *tp; - struct xfs_inode *dp; /* inode */ - struct attrlist_cursor_kern *cursor; /* position in list */ - char *alist; /* output buffer */ +struct xfs_attr_list_context { + struct xfs_trans *tp; + struct xfs_inode *dp; /* inode */ + struct attrlist_cursor_kern *cursor; /* position in list */ + void *buffer; /* output buffer */ /* * Abort attribute list iteration if non-zero. Can be used to pass * error values to the xfs_attr_list caller. */ - int seen_enough; - bool allow_incomplete; - - ssize_t count; /* num used entries */ - int dupcnt; /* count dup hashvals seen */ - int bufsize; /* total buffer size */ - int firstu; /* first used byte in buffer */ - int flags; /* from VOP call */ - int resynch; /* T/F: resynch with cursor */ - put_listent_func_t put_listent; /* list output fmt function */ - int index; /* index into output buffer */ -} xfs_attr_list_context_t; + int seen_enough; + bool allow_incomplete; + + ssize_t count; /* num used entries */ + int dupcnt; /* count dup hashvals seen */ + int bufsize; /* total buffer size */ + int firstu; /* first used byte in buffer */ + int flags; /* from VOP call */ + int resynch; /* T/F: resynch with cursor */ + put_listent_func_t put_listent; /* list output fmt function */ + int index; /* index into output buffer */ +}; /*======================================================================== From patchwork Thu Apr 30 22:46: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: 11521837 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 E7D9A18A4 for ; Thu, 30 Apr 2020 22:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF32F20870 for ; Thu, 30 Apr 2020 22:47:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="aUbxauv2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727108AbgD3WrN (ORCPT ); Thu, 30 Apr 2020 18:47:13 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48412 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727077AbgD3WrL (ORCPT ); Thu, 30 Apr 2020 18:47:11 -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 03UMhYi5047427 for ; Thu, 30 Apr 2020 22:47:10 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=RC5EGfSFsf5ab2DM6mj9suAAliyUE8J2YH03fLi6o2E=; b=aUbxauv2XszerbyWNtbxB53uvUChA22j2BLHENm2Eu2mayYJ5jUumtftpbomcysPLqdU UJZPHFXGo1r8GY0CII3wpqoVWS0fDeuaD+hpE0VJJ+7vCdAF1vdz+4x/qLaywteQM5DJ r8XtgUidFyxpI9j/oa8ByDlNcMSzIbLGcdEiiYoJ11in/vBn7cY/kYq5CAGSg3pffOxn YXFln61/ZvnKpHpRUxvkS0Voe/74nEoXqqv7U+wOjF0pTYREQZCtmbg5eX45VS6bm1E4 wVAyKoCVmlxm8xrYln31kudIyK4/Ui0JoPM2Qc84gMPy4YjkULXE7jzArEimULaDzpp5 yg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 30r7f5r26p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:10 +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 03UMh3Ct077152 for ; Thu, 30 Apr 2020 22:47:10 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 30r7f8a002-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:09 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMl8LI012819 for ; Thu, 30 Apr 2020 22:47:08 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:08 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 14/43] xfsprogs: remove the unused ATTR_ENTRY macro Date: Thu, 30 Apr 2020 15:46:31 -0700 Message-Id: <20200430224700.4183-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 0c8f7c7..31c0ffd 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -70,14 +70,6 @@ typedef struct attrlist_ent { /* data from attr_list() */ } attrlist_ent_t; /* - * Given a pointer to the (char*) buffer containing the attr_list() result, - * and an index, return a pointer to the indicated attribute in the buffer. - */ -#define ATTR_ENTRY(buffer, index) \ - ((attrlist_ent_t *) \ - &((char *)buffer)[ ((attrlist_t *)(buffer))->al_offset[index] ]) - -/* * Kernel-internal version of the attrlist cursor. */ typedef struct attrlist_cursor_kern { From patchwork Thu Apr 30 22:46: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: 11521831 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 6A4FE1805 for ; Thu, 30 Apr 2020 22:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50F2F20774 for ; Thu, 30 Apr 2020 22:47:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="LrhRxLxS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727092AbgD3WrM (ORCPT ); Thu, 30 Apr 2020 18:47:12 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:58874 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727113AbgD3WrL (ORCPT ); Thu, 30 Apr 2020 18:47:11 -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 03UMkwob066071 for ; Thu, 30 Apr 2020 22:47:10 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=5AjYuJWFw789GLaUtg6Orr4j1918LrqXtTZ+VEY/uOA=; b=LrhRxLxSj84la92XQ/fUlmOXJ79b0WtTjctxjgapwSCkTEU5ZZRhxik/3RIxyQENkOib hJroJcMsfIv9qCh+LdzgjRKYtfp+uT4V6Hx1ZEHNHffUYkIFelIwatJ72jamMQJ1OJ7b h34WhRWVGEg1VCoSUVURDn3ZtwVtjKcVo5QM47ueKPUYmidQbkP4n7GyGRVnZUPrs52e WDGIaA9zHMQXXA3UUSOOlYTZ18UwJQWmYPfU1VCmz35eMr/ISklvWvYiIO5T6b4a/otv k1UFDqz3e1AVcf3zXJW3eWNYZ77vBEvLg6y8rBXchbV7ELtoIiX2WwcXpviFu2QFZH9G 3Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 30r7f80282-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:10 +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 03UMhQPA181258 for ; Thu, 30 Apr 2020 22:47:10 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 30r7fes2aj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:09 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMl9R2011757 for ; Thu, 30 Apr 2020 22:47:09 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:08 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 15/43] xfsprogs: move the legacy xfs_attr_list to xfs_ioctl.c Date: Thu, 30 Apr 2020 15:46:32 -0700 Message-Id: <20200430224700.4183-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The old xfs_attr_list code is only used by the attrlist by handle ioctl. Move it to xfs_ioctl.c with its user. Also move the attrlist and attrlist_ent structure to xfs_fs.h, as they are exposed user ABIs. They are used through libattr headers with the same name by at least xfsdump. Also document this relation so that it doesn't require a research project to figure out. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.h | 23 ----------------------- libxfs/xfs_fs.h | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 31c0ffd..0e3c213 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -49,27 +49,6 @@ struct xfs_attr_list_context; #define ATTR_MAX_VALUELEN (64*1024) /* max length of a value */ /* - * Define how lists of attribute names are returned to the user from - * the attr_list() call. A large, 32bit aligned, buffer is passed in - * along with its size. We put an array of offsets at the top that each - * reference an attrlist_ent_t and pack the attrlist_ent_t's at the bottom. - */ -typedef struct attrlist { - __s32 al_count; /* number of entries in attrlist */ - __s32 al_more; /* T/F: more attrs (do call again) */ - __s32 al_offset[1]; /* byte offsets of attrs [var-sized] */ -} attrlist_t; - -/* - * Show the interesting info about one attribute. This is what the - * al_offset[i] entry points to. - */ -typedef struct attrlist_ent { /* data from attr_list() */ - __u32 a_valuelen; /* number bytes in value of attr */ - char a_name[1]; /* attr name (NULL terminated) */ -} attrlist_ent_t; - -/* * Kernel-internal version of the attrlist cursor. */ typedef struct attrlist_cursor_kern { @@ -131,8 +110,6 @@ 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_remove_args(struct xfs_da_args *args); -int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize, - int flags, struct attrlist_cursor_kern *cursor); bool xfs_attr_namecheck(const void *name, size_t length); #endif /* __XFS_ATTR_H__ */ diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index e362fc8..51a688f 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -593,6 +593,26 @@ typedef struct xfs_attrlist_cursor { __u32 opaque[4]; } xfs_attrlist_cursor_t; +/* + * Define how lists of attribute names are returned to userspace from the + * XFS_IOC_ATTRLIST_BY_HANDLE ioctl. struct xfs_attrlist is the header at the + * beginning of the returned buffer, and a each entry in al_offset contains the + * relative offset of an xfs_attrlist_ent containing the actual entry. + * + * NOTE: struct xfs_attrlist must match struct attrlist defined in libattr, and + * struct xfs_attrlist_ent must match struct attrlist_ent defined in libattr. + */ +struct xfs_attrlist { + __s32 al_count; /* number of entries in attrlist */ + __s32 al_more; /* T/F: more attrs (do call again) */ + __s32 al_offset[1]; /* byte offsets of attrs [var-sized] */ +}; + +struct xfs_attrlist_ent { /* data from attr_list() */ + __u32 a_valuelen; /* number bytes in value of attr */ + char a_name[1]; /* attr name (NULL terminated) */ +}; + typedef struct xfs_fsop_attrlist_handlereq { struct xfs_fsop_handlereq hreq; /* handle interface structure */ struct xfs_attrlist_cursor pos; /* opaque cookie, list offset */ From patchwork Thu Apr 30 22:46: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: 11521833 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 887A4913 for ; Thu, 30 Apr 2020 22:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F8EA20774 for ; Thu, 30 Apr 2020 22:47:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Ca7ceOXN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbgD3WrM (ORCPT ); Thu, 30 Apr 2020 18:47:12 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:58872 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727108AbgD3WrL (ORCPT ); Thu, 30 Apr 2020 18:47:11 -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 03UMhJQM063530 for ; Thu, 30 Apr 2020 22:47:10 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=dg31kbMa5WAbzJRXtCNsWMpizCT2juKBZ9iuP3hK4hA=; b=Ca7ceOXNfAAW31ZB+G0rf3I9bOZgaejpieYLaP5HqVARAPWbL/hwP6i2E98nWZqpjYM2 1DTtN44Fu5IV1MER5fpbOVVY9+BkMCb2tgf5718tTPCKYddMeZ2raWBgEmiaWlQtHYhw CglfFee0UrIhIbxzf4jPjsaON6lttpYeJr8f2LYG5eUtztJPBnu/RRdIkRDDQRSMhndP tnOaEXig58QgDYtrdBrTlVlJ+53lWZ8b5ay/IbmFKHwur4XYiApg7ouxQ5hncaB3/gO4 PA5CipU4lY0mWjUAcV4VByAmK05FbAl5mfjZFrx3folBQP5ykbZawuu5ppfeMKKj3sKJ +w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30r7f80281-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:10 +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 03UMgDCd141465 for ; Thu, 30 Apr 2020 22:47:10 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 30qtg23drp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:09 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMl9IY012295 for ; Thu, 30 Apr 2020 22:47:09 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:09 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 16/43] xfsprogs: rename xfs_attr_list_int to xfs_attr_list Date: Thu, 30 Apr 2020 15:46:33 -0700 Message-Id: <20200430224700.4183-17-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The version taking the context structure is the main interface to list attributes, so drop the _int postfix. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 0e3c213..8d42f57 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -102,8 +102,8 @@ struct xfs_attr_list_context { * Overall external interface routines. */ int xfs_attr_inactive(struct xfs_inode *dp); -int xfs_attr_list_int_ilocked(struct xfs_attr_list_context *); -int xfs_attr_list_int(struct xfs_attr_list_context *); +int xfs_attr_list_ilocked(struct xfs_attr_list_context *); +int xfs_attr_list(struct xfs_attr_list_context *); int xfs_inode_hasattr(struct xfs_inode *ip); int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); From patchwork Thu Apr 30 22:46: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: 11521835 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 CA43C17EF for ; Thu, 30 Apr 2020 22:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B21E420873 for ; Thu, 30 Apr 2020 22:47:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="hdaNfBCT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727835AbgD3WrN (ORCPT ); Thu, 30 Apr 2020 18:47:13 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:58880 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727784AbgD3WrM (ORCPT ); Thu, 30 Apr 2020 18:47:12 -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 03UMhLMa063585 for ; Thu, 30 Apr 2020 22:47: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=Xz2bJvQsISUXKEKLiGH1vFabN/Eit7Z61zirMUk3cgY=; b=hdaNfBCTFob471wOipCiArGGhIvMhOGK8YJiBaOVT0V2AryEH9ilJkZGFMwL2tkUXDtB kgRJTB+S2VrbrYCrjxjhr/0lPTUVcB7uBBWbyG1vyYozvhtD2ZkvF6Tk/qhDDLWrFGF1 LsGkV4gLh0CNLYGHumK905EiyTda92t9gdIip1M75cSGXhUlOqhDUIP7xLh/POVCI6hJ jtA0dNVKLkaoi/3eM4cV2K240fd0pr+P7rnf5tsX0dbzSlst+a1GcCFiU136DZQ6QAcE NFNLvWTlKNO394WQrW4wO4OW0gN7w67SxS4JX9Pg650//1w9CyjCYKoyxKs8VN2Vv1o8 Ng== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30r7f80284-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:10 +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 03UMgIkZ141641 for ; Thu, 30 Apr 2020 22:47:10 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 30qtg23drs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:10 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMl9eh031998 for ; Thu, 30 Apr 2020 22:47:09 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:09 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 17/43] xfsprogs: clean up the ATTR_REPLACE checks Date: Thu, 30 Apr 2020 15:46:34 -0700 Message-Id: <20200430224700.4183-18-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=867 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=909 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Remove superflous braces, elses after return statements and use a goto label to merge common error handling. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 6298891..ca4e044 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -423,9 +423,9 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) trace_xfs_attr_sf_addname(args); retval = xfs_attr_shortform_lookup(args); - if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) { + if (retval == -ENOATTR && (args->flags & ATTR_REPLACE)) return retval; - } else if (retval == -EEXIST) { + if (retval == -EEXIST) { if (args->flags & ATTR_CREATE) return retval; retval = xfs_attr_shortform_remove(args); @@ -489,14 +489,11 @@ xfs_attr_leaf_addname( * the given flags produce an error or call for an atomic rename. */ retval = xfs_attr3_leaf_lookup_int(bp, args); - if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) { - xfs_trans_brelse(args->trans, bp); - return retval; - } else if (retval == -EEXIST) { - if (args->flags & ATTR_CREATE) { /* pure create op */ - xfs_trans_brelse(args->trans, bp); - return retval; - } + if (retval == -ENOATTR && (args->flags & ATTR_REPLACE)) + goto out_brelse; + if (retval == -EEXIST) { + if (args->flags & ATTR_CREATE) /* pure create op */ + goto out_brelse; trace_xfs_attr_leaf_replace(args); @@ -637,6 +634,9 @@ xfs_attr_leaf_addname( error = xfs_attr3_leaf_clearflag(args); } return error; +out_brelse: + xfs_trans_brelse(args->trans, bp); + return retval; } /* @@ -763,9 +763,9 @@ restart: goto out; blk = &state->path.blk[ state->path.active-1 ]; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); - if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) { + if (retval == -ENOATTR && (args->flags & ATTR_REPLACE)) goto out; - } else if (retval == -EEXIST) { + if (retval == -EEXIST) { if (args->flags & ATTR_CREATE) goto out; From patchwork Thu Apr 30 22:46: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: 11521843 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 8C21515AB for ; Thu, 30 Apr 2020 22:47:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F682207DD for ; Thu, 30 Apr 2020 22:47:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="TYtKwgaP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727831AbgD3WrP (ORCPT ); Thu, 30 Apr 2020 18:47:15 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48430 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727832AbgD3WrO (ORCPT ); Thu, 30 Apr 2020 18:47:14 -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 03UMhaJQ047452 for ; Thu, 30 Apr 2020 22:47: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=ZDPXRgZ9A7iQXlXhuCaxvS3YhAhPrxol6aI/F4KGlKc=; b=TYtKwgaP/X8RiXTf2hD+aKH43uZjbqYC5RY0g2LljmBvypiqWuoIfHi+TudQ1LW0tNpb xuOxgvwuyXF64A84JUNLWPEzsJyJPe8PlprF1U28CXVpAbdN0fZi6v8GIhkWwS/PuVWQ FZhTqYWc/pptXfiylzeLw5X7h8QR+oHWMnVRQfq4B6/wXltCLdn8kx/rVQe5dD7QYIvL cftLKhf8Tl2IIgzuYXbJHspcgRq1ybPCbIorgO2hWUgipn5P8qpAv4T+iBL8UBQHCgef 2z+uSL5lboB2QydgP6sbfhpIM3I7cYHcyKI0kEnG2UCybKhBuEl4+6JD5wfaCoD1MxUt Xg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 30r7f5r26r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47: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 03UMhPtT181233 for ; Thu, 30 Apr 2020 22:47:11 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 30r7fes2bk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:10 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMl9SC032001 for ; Thu, 30 Apr 2020 22:47:09 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:09 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 18/43] xfsprogs: clean up the attr flag confusion Date: Thu, 30 Apr 2020 15:46:35 -0700 Message-Id: <20200430224700.4183-19-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The ATTR_* flags have a long IRIX history, where they a userspace interface, the on-disk format and an internal interface. We've split out the on-disk interface to the XFS_ATTR_* values, but despite (or because?) of that the flag have still been a mess. Switch the internal interface to pass the on-disk XFS_ATTR_* flags for the namespace and the Linux XATTR_* flags for the actual flags instead. The ATTR_* values that are actually used are move to xfs_fs.h with a new XFS_IOC_* prefix to not conflict with the userspace version that has the same name and must have the same value. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- db/attrset.c | 36 ++++++++++++++++++++---------------- libxfs/libxfs_api_defs.h | 8 ++++---- libxfs/xfs_attr.c | 17 +++++++++-------- libxfs/xfs_attr.h | 22 +--------------------- libxfs/xfs_attr_leaf.c | 14 +++++++------- libxfs/xfs_da_btree.h | 3 ++- libxfs/xfs_da_format.h | 12 ------------ libxfs/xfs_fs.h | 12 +++++++++++- 8 files changed, 54 insertions(+), 70 deletions(-) diff --git a/db/attrset.c b/db/attrset.c index 0b5aabb..b3513ec 100644 --- a/db/attrset.c +++ b/db/attrset.c @@ -16,6 +16,7 @@ #include "field.h" #include "inode.h" #include "malloc.h" +#include static int attr_set_f(int argc, char **argv); static int attr_remove_f(int argc, char **argv); @@ -68,7 +69,8 @@ attr_set_f( { xfs_inode_t *ip = NULL; char *name, *value, *sp; - int c, valuelen = 0, flags = 0; + int c, valuelen = 0; + int attr_flags = 0, attr_filter = 0; struct xfs_da_args args; if (cur_typ == NULL) { @@ -84,23 +86,23 @@ attr_set_f( switch (c) { /* namespaces */ case 'r': - flags |= LIBXFS_ATTR_ROOT; - flags &= ~LIBXFS_ATTR_SECURE; + attr_filter |= LIBXFS_ATTR_ROOT; + attr_filter &= ~LIBXFS_ATTR_SECURE; break; case 'u': - flags &= ~(LIBXFS_ATTR_ROOT | LIBXFS_ATTR_SECURE); + attr_filter &= ~(LIBXFS_ATTR_ROOT | LIBXFS_ATTR_SECURE); break; case 's': - flags |= LIBXFS_ATTR_SECURE; - flags &= ~LIBXFS_ATTR_ROOT; + attr_filter |= LIBXFS_ATTR_SECURE; + attr_filter &= ~LIBXFS_ATTR_ROOT; break; /* modifiers */ case 'C': - flags |= LIBXFS_ATTR_CREATE; + attr_flags |= LIBXFS_ATTR_CREATE; break; case 'R': - flags |= LIBXFS_ATTR_REPLACE; + attr_flags |= LIBXFS_ATTR_REPLACE; break; case 'n': @@ -151,7 +153,8 @@ attr_set_f( args.name = (unsigned char *)name; args.namelen = strlen(name); args.value = (unsigned char *)value; - args.flags = flags; + args.attr_flags = attr_flags; + args.attr_filter = attr_filter; if (libxfs_attr_set(&args)){ dbprintf(_("failed to set attr %s on inode %llu\n"), @@ -178,7 +181,7 @@ attr_remove_f( { xfs_inode_t *ip = NULL; char *name; - int c, flags = 0; + int c, attr_filter = 0; struct xfs_da_args args; if (cur_typ == NULL) { dbprintf(_("no current type\n")); @@ -193,15 +196,15 @@ attr_remove_f( switch (c) { /* namespaces */ case 'r': - flags |= LIBXFS_ATTR_ROOT; - flags &= ~LIBXFS_ATTR_SECURE; + attr_filter |= LIBXFS_ATTR_ROOT; + attr_filter &= ~LIBXFS_ATTR_SECURE; break; case 'u': - flags &= ~(LIBXFS_ATTR_ROOT | LIBXFS_ATTR_SECURE); + attr_filter &= ~(LIBXFS_ATTR_ROOT | LIBXFS_ATTR_SECURE); break; case 's': - flags |= LIBXFS_ATTR_SECURE; - flags &= ~LIBXFS_ATTR_ROOT; + attr_filter |= LIBXFS_ATTR_SECURE; + attr_filter &= ~LIBXFS_ATTR_ROOT; break; case 'n': @@ -233,7 +236,8 @@ attr_remove_f( args.namelen = strlen(name); args.value = NULL; args.valuelen = 0; - args.flags = flags; + args.attr_flags = 0; + args.attr_filter = attr_filter; if (libxfs_attr_set(&args)){ dbprintf(_("failed to remove attr %s from inode %llu\n"), diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 0ffad20..2493680 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -13,10 +13,10 @@ * it can be included in both the internal and external libxfs header files * without introducing any depenencies between the two. */ -#define LIBXFS_ATTR_CREATE ATTR_CREATE -#define LIBXFS_ATTR_REPLACE ATTR_REPLACE -#define LIBXFS_ATTR_ROOT ATTR_ROOT -#define LIBXFS_ATTR_SECURE ATTR_SECURE +#define LIBXFS_ATTR_CREATE XATTR_CREATE +#define LIBXFS_ATTR_REPLACE XATTR_REPLACE +#define LIBXFS_ATTR_ROOT XFS_ATTR_ROOT +#define LIBXFS_ATTR_SECURE XFS_ATTR_SECURE #define xfs_agfl_size libxfs_agfl_size #define xfs_agfl_walk libxfs_agfl_walk diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index ca4e044..810caff 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -24,6 +24,7 @@ #include "xfs_trans_space.h" #include "xfs_trace.h" #include "xfs_quota_defs.h" +#include /* * xfs_attr.c @@ -295,7 +296,7 @@ xfs_attr_set( struct xfs_inode *dp = args->dp; struct xfs_mount *mp = dp->i_mount; struct xfs_trans_res tres; - int rsvd = (args->flags & ATTR_ROOT) != 0; + bool rsvd = (args->attr_filter & XFS_ATTR_ROOT); int error, local; unsigned int total; @@ -423,10 +424,10 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) trace_xfs_attr_sf_addname(args); retval = xfs_attr_shortform_lookup(args); - if (retval == -ENOATTR && (args->flags & ATTR_REPLACE)) + if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE)) return retval; if (retval == -EEXIST) { - if (args->flags & ATTR_CREATE) + if (args->attr_flags & XATTR_CREATE) return retval; retval = xfs_attr_shortform_remove(args); if (retval) @@ -436,7 +437,7 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) * that the leaf format add routine won't trip over the attr * not being around. */ - args->flags &= ~ATTR_REPLACE; + args->attr_flags &= ~XATTR_REPLACE; } if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX || @@ -489,10 +490,10 @@ xfs_attr_leaf_addname( * the given flags produce an error or call for an atomic rename. */ retval = xfs_attr3_leaf_lookup_int(bp, args); - if (retval == -ENOATTR && (args->flags & ATTR_REPLACE)) + if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE)) goto out_brelse; if (retval == -EEXIST) { - if (args->flags & ATTR_CREATE) /* pure create op */ + if (args->attr_flags & XATTR_CREATE) goto out_brelse; trace_xfs_attr_leaf_replace(args); @@ -763,10 +764,10 @@ restart: goto out; blk = &state->path.blk[ state->path.active-1 ]; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); - if (retval == -ENOATTR && (args->flags & ATTR_REPLACE)) + if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE)) goto out; if (retval == -EEXIST) { - if (args->flags & ATTR_CREATE) + if (args->attr_flags & XATTR_CREATE) goto out; trace_xfs_attr_node_replace(args); diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 8d42f57..a6bedb0 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -21,26 +21,6 @@ struct xfs_attr_list_context; * as possible so as to fit into the literal area of the inode. */ -/*======================================================================== - * External interfaces - *========================================================================*/ - - -#define ATTR_DONTFOLLOW 0x0001 /* -- ignored, from IRIX -- */ -#define ATTR_ROOT 0x0002 /* use attrs in root (trusted) namespace */ -#define ATTR_TRUST 0x0004 /* -- unused, from IRIX -- */ -#define ATTR_SECURE 0x0008 /* use attrs in security namespace */ -#define ATTR_CREATE 0x0010 /* pure create: fail if attr already exists */ -#define ATTR_REPLACE 0x0020 /* pure set: fail if attr does not exist */ - -#define XFS_ATTR_FLAGS \ - { ATTR_DONTFOLLOW, "DONTFOLLOW" }, \ - { ATTR_ROOT, "ROOT" }, \ - { ATTR_TRUST, "TRUST" }, \ - { ATTR_SECURE, "SECURE" }, \ - { ATTR_CREATE, "CREATE" }, \ - { ATTR_REPLACE, "REPLACE" } - /* * The maximum size (into the kernel or returned from the kernel) of an * attribute value or the buffer used for an attr_list() call. Larger @@ -87,7 +67,7 @@ struct xfs_attr_list_context { int dupcnt; /* count dup hashvals seen */ int bufsize; /* total buffer size */ int firstu; /* first used byte in buffer */ - int flags; /* from VOP call */ + unsigned int attr_filter; /* XFS_ATTR_{ROOT,SECURE} */ int resynch; /* T/F: resynch with cursor */ put_listent_func_t put_listent; /* list output fmt function */ int index; /* index into output buffer */ diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 86e3135..d560f94 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -453,8 +453,7 @@ xfs_attr_match( return false; if (memcmp(args->name, name, namelen) != 0) return false; - if (XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags) != - XFS_ATTR_NSP_ONDISK(flags)) + if (args->attr_filter != (flags & XFS_ATTR_NSP_ONDISK_MASK)) return false; return true; } @@ -694,7 +693,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) sfe->namelen = args->namelen; sfe->valuelen = args->valuelen; - sfe->flags = XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags); + sfe->flags = args->attr_filter; memcpy(sfe->nameval, args->name, args->namelen); memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen); sf->hdr.count++; @@ -903,7 +902,7 @@ xfs_attr_shortform_to_leaf( nargs.valuelen = sfe->valuelen; nargs.hashval = xfs_da_hashname(sfe->nameval, sfe->namelen); - nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags); + nargs.attr_filter = sfe->flags & XFS_ATTR_NSP_ONDISK_MASK; error = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */ ASSERT(error == -ENOATTR); error = xfs_attr3_leaf_add(bp, &nargs); @@ -1109,7 +1108,7 @@ xfs_attr3_leaf_to_shortform( nargs.value = &name_loc->nameval[nargs.namelen]; nargs.valuelen = be16_to_cpu(name_loc->valuelen); nargs.hashval = be32_to_cpu(entry->hashval); - nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(entry->flags); + nargs.attr_filter = entry->flags & XFS_ATTR_NSP_ONDISK_MASK; xfs_attr_shortform_add(&nargs, forkoff); } error = 0; @@ -1434,8 +1433,9 @@ xfs_attr3_leaf_add_work( entry->nameidx = cpu_to_be16(ichdr->freemap[mapindex].base + ichdr->freemap[mapindex].size); entry->hashval = cpu_to_be32(args->hashval); - entry->flags = tmp ? XFS_ATTR_LOCAL : 0; - entry->flags |= XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags); + entry->flags = args->attr_filter; + if (tmp) + entry->flags |= XFS_ATTR_LOCAL; if (args->op_flags & XFS_DA_OP_RENAME) { entry->flags |= XFS_ATTR_INCOMPLETE; if ((args->blkno2 == args->blkno) && diff --git a/libxfs/xfs_da_btree.h b/libxfs/xfs_da_btree.h index d93cb83..f3660ae 100644 --- a/libxfs/xfs_da_btree.h +++ b/libxfs/xfs_da_btree.h @@ -59,7 +59,8 @@ typedef struct xfs_da_args { uint8_t filetype; /* filetype of inode for directories */ void *value; /* set of bytes (maybe contain NULLs) */ int valuelen; /* length of value */ - int flags; /* argument flags (eg: ATTR_NOCREATE) */ + unsigned int attr_filter; /* XFS_ATTR_{ROOT,SECURE} */ + unsigned int attr_flags; /* XATTR_{CREATE,REPLACE} */ xfs_dahash_t hashval; /* hash value of name */ xfs_ino_t inumber; /* input/output inode number */ struct xfs_inode *dp; /* directory inode to manipulate */ diff --git a/libxfs/xfs_da_format.h b/libxfs/xfs_da_format.h index 734837a..08c0a4d 100644 --- a/libxfs/xfs_da_format.h +++ b/libxfs/xfs_da_format.h @@ -692,19 +692,7 @@ struct xfs_attr3_leafblock { #define XFS_ATTR_ROOT (1 << XFS_ATTR_ROOT_BIT) #define XFS_ATTR_SECURE (1 << XFS_ATTR_SECURE_BIT) #define XFS_ATTR_INCOMPLETE (1 << XFS_ATTR_INCOMPLETE_BIT) - -/* - * Conversion macros for converting namespace bits from argument flags - * to ondisk flags. - */ -#define XFS_ATTR_NSP_ARGS_MASK (ATTR_ROOT | ATTR_SECURE) #define XFS_ATTR_NSP_ONDISK_MASK (XFS_ATTR_ROOT | XFS_ATTR_SECURE) -#define XFS_ATTR_NSP_ONDISK(flags) ((flags) & XFS_ATTR_NSP_ONDISK_MASK) -#define XFS_ATTR_NSP_ARGS(flags) ((flags) & XFS_ATTR_NSP_ARGS_MASK) -#define XFS_ATTR_NSP_ARGS_TO_ONDISK(x) (((x) & ATTR_ROOT ? XFS_ATTR_ROOT : 0) |\ - ((x) & ATTR_SECURE ? XFS_ATTR_SECURE : 0)) -#define XFS_ATTR_NSP_ONDISK_TO_ARGS(x) (((x) & XFS_ATTR_ROOT ? ATTR_ROOT : 0) |\ - ((x) & XFS_ATTR_SECURE ? ATTR_SECURE : 0)) /* * Alignment for namelist and valuelist entries (since they are mixed diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index 51a688f..38beb99 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -589,6 +589,16 @@ typedef struct xfs_fsop_setdm_handlereq { struct fsdmidata __user *data; /* DMAPI data */ } xfs_fsop_setdm_handlereq_t; +/* + * Flags passed in xfs_attr_multiop.am_flags for the attr ioctl interface. + * + * NOTE: Must match the values declared in libattr without the XFS_IOC_ prefix. + */ +#define XFS_IOC_ATTR_ROOT 0x0002 /* use attrs in root namespace */ +#define XFS_IOC_ATTR_SECURE 0x0008 /* use attrs in security namespace */ +#define XFS_IOC_ATTR_CREATE 0x0010 /* fail if attr already exists */ +#define XFS_IOC_ATTR_REPLACE 0x0020 /* fail if attr does not exist */ + typedef struct xfs_attrlist_cursor { __u32 opaque[4]; } xfs_attrlist_cursor_t; @@ -630,7 +640,7 @@ typedef struct xfs_attr_multiop { void __user *am_attrname; void __user *am_attrvalue; __u32 am_length; - __u32 am_flags; + __u32 am_flags; /* XFS_IOC_ATTR_* */ } xfs_attr_multiop_t; typedef struct xfs_fsop_attrmulti_handlereq { From patchwork Thu Apr 30 22:46: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: 11521839 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 0454F913 for ; Thu, 30 Apr 2020 22:47:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E084B2074A for ; Thu, 30 Apr 2020 22:47:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Naxval/y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727784AbgD3WrN (ORCPT ); Thu, 30 Apr 2020 18:47:13 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43726 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727815AbgD3WrM (ORCPT ); Thu, 30 Apr 2020 18:47:12 -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 03UMgv7c128515 for ; Thu, 30 Apr 2020 22:47: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=8witqzQLM6IHkx2UMA/PsasYekQfcSByJfT6ur5OnhY=; b=Naxval/ysTrWqohAyGNIlMs6lS/C0PR83uPxzYpVfGMJVLiz3CtNDezJ/0lvPQwfM+ii FpjUXdVpT3kvz7Z3jyVvszNQTrV9BaZFuo1K30EX9bP3DKquDx1ivOdOpxsHNbrpTgfX tvyUXQjWtPPLxuHk3li53m4LHlKBcZVR7bjime8NWkOeOyqTXHSJsMXnPt29IbrFEosS bVlIZi1M2W45JIVKm46LkDVDvQbt0hG9MpOAFqzwZ745JbiPVHlei0qUEdYRNJd5hFmK Uin2pl+PUGmko30Kvchqf88+YpODEAzUc29RxPgAAjW1iJV0Q48dkWeoYYegJipUGwlS KA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 30r7f3g235-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:11 +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 03UMgJVm141673 for ; Thu, 30 Apr 2020 22:47:10 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 30qtg23dsg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:10 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMlAii012298 for ; Thu, 30 Apr 2020 22:47:10 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:09 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 19/43] xfsprogs: embedded the attrlist cursor into struct xfs_attr_list_context Date: Thu, 30 Apr 2020 15:46:36 -0700 Message-Id: <20200430224700.4183-20-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The attrlist cursor only exists as part of an attr list context, so embedd the structure instead of pointing to it. Also give it a proper xfs_ prefix and remove the obsolete typedef. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Chandan Rajendra Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Collins --- libxfs/xfs_attr.h | 6 +++--- libxfs/xfs_attr_leaf.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index a6bedb0..0d2d059 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -31,14 +31,14 @@ struct xfs_attr_list_context; /* * Kernel-internal version of the attrlist cursor. */ -typedef struct attrlist_cursor_kern { +struct xfs_attrlist_cursor_kern { __u32 hashval; /* hash value of next entry to add */ __u32 blkno; /* block containing entry (suggestion) */ __u32 offset; /* offset in list of equal-hashvals */ __u16 pad1; /* padding to match user-level */ __u8 pad2; /* padding to match user-level */ __u8 initted; /* T/F: cursor has been initialized */ -} attrlist_cursor_kern_t; +}; /*======================================================================== @@ -53,7 +53,7 @@ typedef void (*put_listent_func_t)(struct xfs_attr_list_context *, int, struct xfs_attr_list_context { struct xfs_trans *tp; struct xfs_inode *dp; /* inode */ - struct attrlist_cursor_kern *cursor; /* position in list */ + struct xfs_attrlist_cursor_kern cursor; /* position in list */ void *buffer; /* output buffer */ /* diff --git a/libxfs/xfs_attr_leaf.h b/libxfs/xfs_attr_leaf.h index 73615b1..6dd2d93 100644 --- a/libxfs/xfs_attr_leaf.h +++ b/libxfs/xfs_attr_leaf.h @@ -8,7 +8,6 @@ #define __XFS_ATTR_LEAF_H__ struct attrlist; -struct attrlist_cursor_kern; struct xfs_attr_list_context; struct xfs_da_args; struct xfs_da_state; From patchwork Thu Apr 30 22:46: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: 11521861 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 6C011913 for ; Thu, 30 Apr 2020 22:47:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5183D2074A for ; Thu, 30 Apr 2020 22:47:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="dd0CmQ89" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727838AbgD3WrS (ORCPT ); Thu, 30 Apr 2020 18:47:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:58884 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727818AbgD3WrN (ORCPT ); Thu, 30 Apr 2020 18:47: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 03UMhKX9063547 for ; Thu, 30 Apr 2020 22:47: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=wltmcqTBEqgmouGbSXm7LPDVjRzB96KSB7tyjl19Kjw=; b=dd0CmQ89FPqxAMRiItiUuaSmfowcZe4DzhDjH3laaNzRRtE2WHHueds2BdUTP9S2qq3Y d/P5JCnjbL0eZ8xxIn0npfMyymLuLfr8uo1E5VK91+pVrBgvRd3RAkh/+tkwo8meabqZ n12VDMCB4KaxIjgoq1FsYuSdIYJ62n70z1E49b51+3934EhD+cMcRzXJHe7jx5eu3LWt lCo7B0wttAgNJyyBsYX3vQVfm/on08NQjkm2nHST1tbLiaMtt1JRyy7l7BfhdAUG2ey0 hxWGKBtPXshNyN3TWjODHFlGNfzPYHfHfbVjO+TqQYmIXzLrvymvzM4o1lzf6rud2+mc Qw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 30r7f80285-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47: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 03UMhRKf181405 for ; Thu, 30 Apr 2020 22:47:11 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 30r7fes2cu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:11 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMlALu012301 for ; Thu, 30 Apr 2020 22:47:10 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:10 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 20/43] xfsprogs: Add xfs_has_attr and subroutines Date: Thu, 30 Apr 2020 15:46:37 -0700 Message-Id: <20200430224700.4183-21-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=4 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=4 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 810caff..7ab623d 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -47,6 +47,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. @@ -54,6 +55,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); @@ -262,6 +265,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_d.di_aformat == 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 @@ -470,26 +504,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) { @@ -641,6 +668,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 @@ -660,16 +708,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); @@ -704,21 +750,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 *========================================================================*/ @@ -751,17 +832,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)) @@ -966,29 +1044,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. @@ -1083,7 +1147,8 @@ xfs_attr_node_removename( error = 0; out: - xfs_da_state_free(state); + if (state) + xfs_da_state_free(state); return error; } @@ -1203,31 +1268,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. @@ -1238,8 +1295,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 0d2d059..66575b8 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 d560f94..7fa0e3a 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -657,18 +657,63 @@ xfs_attr_shortform_create(xfs_da_args_t *args) } /* + * 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); @@ -726,31 +768,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 6dd2d93..88ec042 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 Apr 30 22:46: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: 11521891 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 1F001913 for ; Thu, 30 Apr 2020 22:49:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06C8C20774 for ; Thu, 30 Apr 2020 22:49:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ZBPfHbWI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726473AbgD3WtN (ORCPT ); Thu, 30 Apr 2020 18:49:13 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45158 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726355AbgD3WtN (ORCPT ); Thu, 30 Apr 2020 18:49: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 03UMmv1d132932 for ; Thu, 30 Apr 2020 22:49: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=E4MR8444MNhJhCP+hStkePxG6PwV0jbGqR9vInD+OSw=; b=ZBPfHbWI6sI1ul20Kyc/FxPKT8/k+rDLJwJRYgmIk2VQujZP9rtNNBAM203fwC0Hl7le Q67c2YFnADgKupi9/oxqwtdS5RlXTUw/L3B60ULXFdlJV3Ke4uxaErPq23VzpJJLNXB7 RSSgHiS3OgHPkXuOAvHw/EZssPMS8BiKw3nQE/NGDDKdRFvxs5KuT4KiX0eK/V6XVQdu aYglMrFRXUPzUii0KgP8hleQKc3UWczyWIrj0ETdAClPkQDuGKDE0i4yQKqeozADbV9f Ip4m4i4lAQ7FL4qxPGWUSSThEKrngv2i4Ml2j2x2C2LYykwTVBB+RFWirqt8dm27YehQ aQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 30r7f3g2b7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:49:12 +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 03UMhP44181147 for ; Thu, 30 Apr 2020 22:47:11 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 30r7fes2d5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:11 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlAqS012887 for ; Thu, 30 Apr 2020 22:47:10 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:10 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 21/43] xfsprogs: Check for -ENOATTR or -EEXIST Date: Thu, 30 Apr 2020 15:46:38 -0700 Message-Id: <20200430224700.4183-22-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 7ab623d..d993203 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -405,6 +405,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; @@ -412,6 +421,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 Apr 30 22:46: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: 11521879 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 0913A913 for ; Thu, 30 Apr 2020 22:47:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E17C920774 for ; Thu, 30 Apr 2020 22:47:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ufKy5YDP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727864AbgD3Wre (ORCPT ); Thu, 30 Apr 2020 18:47:34 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:59234 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727808AbgD3Wre (ORCPT ); Thu, 30 Apr 2020 18:47:34 -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 03UMlWgf066871 for ; Thu, 30 Apr 2020 22:47:32 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=ufKy5YDPcPpOr7JzMhyANBn9IaAG3Y+dOfBXhoKcrZhEhLZYpBF3plBZ8bGDLlAtxQgy 0TMex2BmCqPuYJv9I6hkGtYv0izHWs3z1s7+MJRX9SPKRpUGa9C3IV2OwfJwuHuqJEed p7/kLy9OPmtUwrGG/tmRbYU95I8KsKeVXpFCk1gU1E3vZqcRorTbWp0pE9wEhkUXfO8l 1QzC4zXu7JWjCheC+DX6+LVHTYjsjjpdd8T1R9POLt/r/vLGSFrPWTW4WUEsHg+BHe93 3WnAKuihlBJm1b9Bnllykv9ElQyS9vtxRe7V6B/S9uGxp2AcQ06GqN7dD+yqLnLzd7hI Rg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 30r7f8028a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:12 +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 03UMgumK077017 for ; Thu, 30 Apr 2020 22:47:12 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 30r7f8a03e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:12 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMlBDr012304 for ; Thu, 30 Apr 2020 22:47:11 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:10 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 22/43] xfsprogs: Factor out new helper functions xfs_attr_rmtval_set Date: Thu, 30 Apr 2020 15:46:39 -0700 Message-Id: <20200430224700.4183-23-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 Apr 30 22:46: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: 11521847 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 7C7FD913 for ; Thu, 30 Apr 2020 22:47:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6420B20774 for ; Thu, 30 Apr 2020 22:47:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="uD/hvmDF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727815AbgD3WrQ (ORCPT ); Thu, 30 Apr 2020 18:47:16 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48436 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727833AbgD3WrN (ORCPT ); Thu, 30 Apr 2020 18:47: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 03UMhpa5047526 for ; Thu, 30 Apr 2020 22:47: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=nWMJdTzUYiBWpvQPRt0BM57tLk78flqNU67L/k/7McA=; b=uD/hvmDFMgUlddkIlbvblA7ejnpQ/yWu29JY5qPJWphAo+/ZYtYZwPPH8ueD1do7TnEL WCeCFUBbiZRClteNAOu+erUHhev0KFbbAco1/zIeOClr+ooM/MupWHjLndXsLVfL5n1o 2UCs1VmhVwZSUUkvtr3mYcbaucfEU+FcxiJGO3yKByy9ySr5nK3urUPpfplbyKo/5Qp7 Ea3m+/4+BZ/jJWp2xgX7bhp6pffUolYSARo4ocbrdxowedGFqwFp0W8Ufzbdk3M86o8z sySRgtEylGffCw2h6u+F5jCsbfNg9NvU+qIzjr1g4piPuxb3I+8LIYHeGcsQzZ/93v8m NA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 30r7f5r26t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47: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 03UMgE3u141520 for ; Thu, 30 Apr 2020 22:47:11 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 30qtg23dtc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:11 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMlBS5012308 for ; Thu, 30 Apr 2020 22:47:11 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:11 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 23/43] xfsprogs: Pull up trans handling in xfs_attr3_leaf_flipflags Date: Thu, 30 Apr 2020 15:46:40 -0700 Message-Id: <20200430224700.4183-24-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 d993203..1cdebec 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -623,6 +623,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 @@ -969,6 +976,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 7fa0e3a..51d44ee 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2954,10 +2954,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 Apr 30 22:46: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: 11521841 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 C9281913 for ; Thu, 30 Apr 2020 22:47:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B1AB820774 for ; Thu, 30 Apr 2020 22:47:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="NSyykB2C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727865AbgD3WrP (ORCPT ); Thu, 30 Apr 2020 18:47:15 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43730 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727831AbgD3WrN (ORCPT ); Thu, 30 Apr 2020 18:47: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 03UMhqsD128839 for ; Thu, 30 Apr 2020 22:47: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=FzasYYWxZEXhOR+N+Qb0cK5pSfnWkDOcJ2IbdcptAIo=; b=NSyykB2C0fGgmm0vhLN+q9RE+kQZP/HPhMByOr/uivVesHn8qldc8nfd+goRIljutg/+ rPAM7Sh3dbfvadFtzumhTcT38/nPlVoQPzHLO+12EEVicqSn5ftuAd52tLRqCMtPkSb7 fger0gMSR6ZtLAfL7wbPLbfGCsZdon1van7bB/n1qXbA7s1Yc+oxCnDLXRU8SB1LVTwN iI9tnbDJVNuzP59W6YxyxUD8ztrD16pwYpSI0jBfAC/6P6zvBCCFwZt91033VjHCA+b1 HSfH7s5FEPhkPzg6/OffXwJVGlUmOcDYLlZiI+EelOEoxpRRTrW2tU/R+e11nqEhQGIu dg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 30r7f3g237-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47: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 03UMgSuv016518 for ; Thu, 30 Apr 2020 22:47:11 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 30r7f298je-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:11 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMlBEI032014 for ; Thu, 30 Apr 2020 22:47:11 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:11 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 24/43] xfsprogs: Split apart xfs_attr_leaf_addname Date: Thu, 30 Apr 2020 15:46:41 -0700 Message-Id: <20200430224700.4183-25-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 adultscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 | 94 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 34 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 1cdebec..5f622c8 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -257,10 +257,30 @@ 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; + + /* + * Commit that transaction so that the node_addname() + * call can manage its own transactions. + */ + 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; } @@ -508,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 @@ -563,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 @@ -682,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 Apr 30 22:46: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: 11521845 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 3E87315AB for ; Thu, 30 Apr 2020 22:47:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 275D720774 for ; Thu, 30 Apr 2020 22:47:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="VFkziATM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727077AbgD3WrP (ORCPT ); Thu, 30 Apr 2020 18:47:15 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48442 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726817AbgD3WrO (ORCPT ); Thu, 30 Apr 2020 18:47:14 -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 03UMhUJv047401 for ; Thu, 30 Apr 2020 22:47: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=qdMryVTdoibMnFgbymXSiZLz3jxRH6kDMSUHnNXzyoE=; b=VFkziATMKQG6AsfJxvMrKx3M+RhsokIUQ3SCSKIOfeTn+9h38s9gk0iIJMty4vG6G0ay nRHryNayecWhqPx1hPBQYrbHkoIo2qpsfg0M18XFNWIrDoacIjbJE2iKPGIOt7MV9R66 Ut5wvwTXDefGWNXn4o38KfuGxJETAPTqaM9cr4s6zpDekizLOMeaUXidvCXhZio5AaK9 kt4njW1wxSZ5unuslAyFQIDkgiv8hkLM24S5oyhDbf9YY672a52Y0eokaClkF9nTVDDB c87hM2BUgrrbdC2a2IjgL3qcnY8vakKwvxmKo0pEhQ6IjxzmU/3xE+Hvp8zfE1TTfX4C Zw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 30r7f5r26x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47: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 03UMgD2J141447 for ; Thu, 30 Apr 2020 22:47:12 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 30qtg23dtx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:12 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlBcn012911 for ; Thu, 30 Apr 2020 22:47:11 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:11 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 25/43] xfsprogs: Refactor xfs_attr_try_sf_addname Date: Thu, 30 Apr 2020 15:46:42 -0700 Message-Id: <20200430224700.4183-26-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 5f622c8..ba6f569 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -179,8 +179,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_d.di_aformat == XFS_DINODE_FMT_EXTENTS) + xfs_attr_shortform_create(args); error = xfs_attr_shortform_addname(args); if (error == -ENOSPC) @@ -193,12 +198,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; } /* @@ -210,7 +213,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, @@ -221,17 +224,14 @@ xfs_attr_set_args( dp->i_d.di_anextents == 0)) { /* - * Build initial attribute list (if required). - */ - if (dp->i_d.di_aformat == 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 Apr 30 22:46: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: 11521857 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 0E6861805 for ; Thu, 30 Apr 2020 22:47:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E93772074A for ; Thu, 30 Apr 2020 22:47:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Jkh+sol7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727863AbgD3WrS (ORCPT ); Thu, 30 Apr 2020 18:47:18 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48454 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727838AbgD3WrP (ORCPT ); Thu, 30 Apr 2020 18:47:15 -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 03UMhQFv047386 for ; Thu, 30 Apr 2020 22:47: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=Qq6Ef6rwLW3INl5a7YhnCrSNr7p8wNkfgtMOlHkdtac=; b=Jkh+sol7JRJ2zQGqK6DO0jkmeCN3D1yNemhNDGA4hF/ZoochCd9cgDK4YQlb21F8/McK YTgce8sRY2t+zKR1M3Ablw5s2q6nV8Q4SFRy1QjdmswcP3XPO0whvZtRek93jgbAIZHY KmXYdOxuIc/hXfjT/Fg85h0SMgwt32zXZtYmGcJRPgUIUfLVLffzUmwtWt7yvlCBnWYy OOpIxlcuPOEzKSfr94LByNUCdB3or+PO3rluy+cw97ditB2yWesKDzkTGNLamFTvG6v8 1MU72JJhyJ/jvV/qVdNDablBKdVKdcIu0JzN20N6lhEypiBGVNgTRYD0molpKf1VtYZ/ 5Q== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 30r7f5r271-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:13 +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 03UMgTPU018237 for ; Thu, 30 Apr 2020 22:47:13 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 30r7f298k4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:13 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlCV2012914 for ; Thu, 30 Apr 2020 22:47:12 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:11 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 26/43] xfsprogs: Pull up trans roll from xfs_attr3_leaf_setflag Date: Thu, 30 Apr 2020 15:46:43 -0700 Message-Id: <20200430224700.4183-27-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 adultscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 ba6f569..183b296 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 51d44ee..c197954 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2836,10 +2836,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 Apr 30 22:46: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: 11521859 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 4D05315AB for ; Thu, 30 Apr 2020 22:47:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 350BE2074A for ; Thu, 30 Apr 2020 22:47:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="z1MgGCUW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726817AbgD3WrQ (ORCPT ); Thu, 30 Apr 2020 18:47:16 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:58914 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727815AbgD3WrO (ORCPT ); Thu, 30 Apr 2020 18:47:14 -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 03UMhiUT063692 for ; Thu, 30 Apr 2020 22:47: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=Q+KkLHzOQ9ZI2yAe1NyYt3D/QjTqiCxny0IUQn6DIVY=; b=z1MgGCUWedXJRNLjDscXwe9A7waxhn/XrjuWfrtdqNKx+ZMQKCBe2o/ytR8qMqRU4NyU TWimQzOahbcjdaYjKpjjteB/W8boh8Nxn4sEyFxs5RjoWe+5dDvTxDzOa6w5D9lE96ak 9EiBMEUgnqPolZ9ghFQ+E1++B+tbtoaz6tK90HmofJZpwzLhuIjTKVwDy1WWTu5cRieo grLd0CAftW4w2QTDhgTZNBSPC41yDVPzpn4NyGrwUz2WIQXVU2+pUNwqWjcR7b2m4fkh b57+pcI41mbouLZtpATagV0AeuWwAGkyyiSvF1M8GEXFzdFSehpRt4eTSpqzd2zNZItK RQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30r7f8028c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47: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 03UMgEu3141519 for ; Thu, 30 Apr 2020 22:47:13 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 30qtg23du7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:13 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlCsQ011771 for ; Thu, 30 Apr 2020 22:47:12 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:12 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 27/43] xfsprogs: Factor out xfs_attr_rmtval_invalidate Date: Thu, 30 Apr 2020 15:46:44 -0700 Message-Id: <20200430224700.4183-28-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 6fb4572..eff5f95 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 Apr 30 22:46: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: 11521849 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 B12141805 for ; Thu, 30 Apr 2020 22:47:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 997F120774 for ; Thu, 30 Apr 2020 22:47:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="pc8w8xYa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727890AbgD3WrR (ORCPT ); Thu, 30 Apr 2020 18:47:17 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43738 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727856AbgD3WrP (ORCPT ); Thu, 30 Apr 2020 18:47: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 03UMgslF128252 for ; Thu, 30 Apr 2020 22:47: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=Dg9tXK6Mt6YfUP8zOvxw8wkFpPcm8j9jFFM1Vr1B9RY=; b=pc8w8xYaoO4Yl8FPGuaQ9jCWpW+aUG3/UJgP/AfrD9/LgqIOuH345wt7dfHIdXpudFyQ sjwKIxiT44BKupDvUF4oiZRV/S9/1C/n74EThsKFdUdOc7RiF4HX1teM+LMt3zIlKZLo ic/wlrtIMAfi10z/LE9i2b+HwdZMCfunD5bGekJz1PtkGOtr2LjMR3k2LoMjxl/wxZD9 SRT8xywEUnjckXRRXD/FZR613pa8UdTWEwMUDP8njnCiRzTvEb7hBQvtNOdko0cFscf/ sqG2+AIPh5UIlYqM9K6MK9jnJ0EhgiuGpsQMR78G10wvBBqbQD34fzpiX6lH8pfVFNBU Wg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 30r7f3g238-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:14 +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 03UMhPVN181240 for ; Thu, 30 Apr 2020 22:47:13 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 30r7fes2fh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:13 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlCx4012919 for ; Thu, 30 Apr 2020 22:47:12 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:12 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 28/43] xfsprogs: Pull up trans roll in xfs_attr3_leaf_clearflag Date: Thu, 30 Apr 2020 15:46:45 -0700 Message-Id: <20200430224700.4183-29-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 183b296..28b9aa0 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 c197954..e3f8457 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2785,10 +2785,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 Apr 30 22:46: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: 11521851 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 1A5F015AB for ; Thu, 30 Apr 2020 22:47:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 02E4420774 for ; Thu, 30 Apr 2020 22:47:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="fW8YwUFD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727891AbgD3WrR (ORCPT ); Thu, 30 Apr 2020 18:47:17 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48458 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727859AbgD3WrP (ORCPT ); Thu, 30 Apr 2020 18:47:15 -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 03UMhmxF047514 for ; Thu, 30 Apr 2020 22:47: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=ODDGDkYd/tAKALcJAC36ZFzdkufDnJmzxj00Rg4k6cM=; b=fW8YwUFDCmK803JHlzbz7/l64KrfTNiCh5QiB4hewGJiprwNqkq+Fv0uJV/KRl+bVmiq n9tZEpM2ch+uUR6WoV4cRReBvmvRrjxhzw0PZ6nZRMMhK8YAu88ZTJAyboBhYQwgPYWp OB9DYXPah8uUc8VaUKskGPMnFEM5LX0+M8rWiRc8qQOHKpx8rEA7IWQ4ipILUi3aXR3m /QYZhESTQ1a+EDTmVn/LPlV6GgC11tOsh1I/zDJafGAEAcD7JnPRuI1a3ebYhihCTslu c27FdR042Oz219qEmfOM8q9NNmiknpVkyGYPeNM6x1M5lMB1RhcciWKzj5K4ihSIzjx4 5A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 30r7f5r272-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:13 +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 03UMhAKc077347 for ; Thu, 30 Apr 2020 22:47:13 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 30r7f8a05q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:13 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMlChk032079 for ; Thu, 30 Apr 2020 22:47:12 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:12 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 29/43] xfsprogs: Add helper function __xfs_attr_rmtval_remove Date: Thu, 30 Apr 2020 15:46:46 -0700 Message-Id: <20200430224700.4183-30-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=905 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=965 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This function is similar to xfs_attr_rmtval_remove, but adapted to return EAGAIN for new transactions. 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 --- 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..336ba01 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 recall 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 eff5f95..ee3337b 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 Apr 30 22:46:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521855 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 E504D17EF for ; Thu, 30 Apr 2020 22:47:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCC7B2074A for ; Thu, 30 Apr 2020 22:47:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="gbgZpCiJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727856AbgD3WrR (ORCPT ); Thu, 30 Apr 2020 18:47:17 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:58924 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727863AbgD3WrP (ORCPT ); Thu, 30 Apr 2020 18:47:15 -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 03UMhTLY063654 for ; Thu, 30 Apr 2020 22:47: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=hNZChi8Es6tXZLfJK2x83r2TgukEXfU4YSEAN5ntMic=; b=gbgZpCiJ8yALTBsvAV6qW2SuVKsECs8g0j26pvW61JSM+S5XjMZyz2CrGSvfY91SW15g /tueTnWn8w7sW4de+DtoXi7D25aos01r+mZHubJyxTeic6vjx7mz8Nj8/VJ5ajjFYinT mz+MFbVJSQn/aSsqi1kXolCN99TY2e9/S6blDQ7YsE/WI+zaOY3XACFPaqohmaQcbH4X iHIcccrlv5k2By5k3CbRSdogHLinubaW/QAM79+9I/pLZsi8EpN0iVd8ioP5y/J262F7 YBToFANbpSUhWesvwcE+I57uT4gHxjXahrDCY32/h8yc+Kv0ku4DXcLYmJZSUW9FQqWL bA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30r7f8028d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:14 +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 03UMgIW4141644 for ; Thu, 30 Apr 2020 22:47:14 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 30qtg23dv6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:14 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMlDvN032082 for ; Thu, 30 Apr 2020 22:47:13 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:12 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 30/43] xfsprogs: Pull up xfs_attr_rmtval_invalidate Date: Thu, 30 Apr 2020 15:46:47 -0700 Message-Id: <20200430224700.4183-31-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=937 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=979 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 --- 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 28b9aa0..9d6e867 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 336ba01..7765ee9 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 Apr 30 22:46:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521893 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 DD8CC15AB for ; Thu, 30 Apr 2020 22:49:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C581020774 for ; Thu, 30 Apr 2020 22:49:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="nKDvuO+r" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726435AbgD3WtP (ORCPT ); Thu, 30 Apr 2020 18:49:15 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60380 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726355AbgD3WtP (ORCPT ); Thu, 30 Apr 2020 18:49:15 -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 03UMlnBh067142 for ; Thu, 30 Apr 2020 22:49: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=Qk0JXhevmB8bxRMXJHB+7XVpXjjYUFSI6310H4k4ogU=; b=nKDvuO+rVvstHU22VcOecLi7dr0qr32C1CjONI/uGuzDWslD8LN5UvvfF9uBjhzs815t i4HtqCNmwJsy/gcyRLXZrnbo8Phg/Gql+Om5f7CmIRh4c4x69D11w8BfYG6c9PhQgQ7L PUMtHHCgtjN99GeLNY9aecmc2hSPVgZCWnDffWWG+Vw4NDRzrbG/vnPVtqM7TSOEu3F8 NV5jUYYGqVn3+Zkw1H070mR5pROw4c9q5H11jffd4xLTLkFBVtlkIDTqZWKdy6FWMBmG g8QYl0y8O60beE/AujoCvDAhhKLB81Fck849LOEWmch6FWbInSSyMOpx9sHHP/q7z6kJ FQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 30r7f802eg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:49: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 03UMh6Sw077239 for ; Thu, 30 Apr 2020 22:47:13 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 30r7f8a06j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:13 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMlDWV032097 for ; Thu, 30 Apr 2020 22:47:13 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:13 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 31/43] xfsprogs: Add helper function xfs_attr_node_shrink Date: Thu, 30 Apr 2020 15:46:48 -0700 Message-Id: <20200430224700.4183-32-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 --- 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 9d6e867..dfb2854 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 Apr 30 22:46: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: 11521853 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 9F4F5913 for ; Thu, 30 Apr 2020 22:47:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 827402074A for ; Thu, 30 Apr 2020 22:47:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="MhLitvgE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727859AbgD3WrS (ORCPT ); Thu, 30 Apr 2020 18:47:18 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48474 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727864AbgD3WrP (ORCPT ); Thu, 30 Apr 2020 18:47:15 -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 03UMhxeV047548 for ; Thu, 30 Apr 2020 22:47: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=FAUP6Yt7JoTrcOjSHseLpFvHxlDXF6kfBE2Cbv9UB0c=; b=MhLitvgEKvtHRSQs7pxgeJBdIX53AE/pd9VlQPEekMCFe1sYCOUyelmTKFhbqdkaSL8d hN0/Dj2NkXCsRNlfcuGrkoMgU6nOwRvyUMggwo464X0epUIG75/de2cdA69RTxyg6VTX 8Nv+krwNns6IrYnxm68+JuR7OXAJesngtx4FKg+WaEKIBkmRuw9rsvyI7Teic5z6ZUWC u8n8a/loede1tvhxJ3rd60/2x/mBNPeNpg0hv0Qolf73e0W9+nSgUts4uvvSA5gmpj2C unHgYcDgMY4Lx9auck9p2or77ydVU8X2uGY+TXK+8eYixXkOWJVBRBGxmCiYzlG+Nknm 6w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 30r7f5r274-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:14 +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 03UMgKjn141696 for ; Thu, 30 Apr 2020 22:47:14 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 30qtg23dw7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:14 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMlDJO012379 for ; Thu, 30 Apr 2020 22:47:13 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:13 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 32/43] xfsprogs: Remove unneeded xfs_trans_roll_inode calls Date: Thu, 30 Apr 2020 15:46:49 -0700 Message-Id: <20200430224700.4183-33-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 tranactions. The xfs_trans_roll in _removename is also not needed because invalidating blocks is an incore-only change. Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index dfb2854..d75bc2a 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -698,16 +698,8 @@ xfs_attr_leaf_addname( /* 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. @@ -715,12 +707,6 @@ xfs_attr_leaf_addname( 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; } @@ -785,9 +771,6 @@ xfs_attr_leaf_removename( /* 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; } @@ -1075,13 +1058,6 @@ restart: 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 +1065,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; @@ -1137,10 +1105,6 @@ xfs_attr_node_shrink( /* 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); @@ -1195,10 +1159,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 Apr 30 22:46: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: 11521863 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 C361817EF for ; Thu, 30 Apr 2020 22:47:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A686A20870 for ; Thu, 30 Apr 2020 22:47:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="K4U5Yndx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727832AbgD3WrT (ORCPT ); Thu, 30 Apr 2020 18:47:19 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48486 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727872AbgD3WrR (ORCPT ); Thu, 30 Apr 2020 18:47: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 03UMhQSF047380 for ; Thu, 30 Apr 2020 22:47: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=zEi2Ck0gqGIepE8SeK08XaXjzpq9Wa6/71SjEHJ6fcI=; b=K4U5YndxhMGJpkq5awySRRiV6ahSxr+243Xt68YGg1c74gq/NCMpj1dh1Z/+SY6f95iY XuZXRaTcNmC+U6PWHohqFUVvND/QuRG7TSG2PQsqbfwHqgJJe+RR3PAPzG/bRoKWK6/M aa5DxVQcmMNrICaYrBJZwsSHgwt9jjjDz3TcfJ55sLmv6PSplfeLTYwuRix/az/Xssh+ dIqKMpNNFJqqqzcc0n9Nix0usNaFlbfg5sogLOwJg05LzBkmJo+O5Ijw5i1axV5vVpv0 n4cL+pEsIiX0L7uhGVoKk5SIUuBluB3Yn3MJ3lA1duEV/OTAueyVf/6fYATBC7JsB1v/ LQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 30r7f5r276-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:15 +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 03UMgusG077024 for ; Thu, 30 Apr 2020 22:47:15 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 30r7f8a088-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:14 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlDlL012922 for ; Thu, 30 Apr 2020 22:47:13 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:13 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 33/43] xfsprogs: Add helpers xfs_attr_is_shortform and xfs_attr_set_shortform Date: Thu, 30 Apr 2020 15:46:50 -0700 Message-Id: <20200430224700.4183-34-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 --- 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 d75bc2a..b8dad2a 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -205,6 +205,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_d.di_aformat == XFS_DINODE_FMT_LOCAL || + (ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && + ip->i_d.di_anextents == 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 @@ -213,48 +273,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_d.di_aformat == XFS_DINODE_FMT_LOCAL || - (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && - dp->i_d.di_anextents == 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 Apr 30 22:46: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: 11521867 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 D063715AB for ; Thu, 30 Apr 2020 22:47:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B87BA2074A for ; Thu, 30 Apr 2020 22:47:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="N8MxX3g0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727872AbgD3WrT (ORCPT ); Thu, 30 Apr 2020 18:47:19 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48492 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727884AbgD3WrR (ORCPT ); Thu, 30 Apr 2020 18:47: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 03UMhNBZ047342 for ; Thu, 30 Apr 2020 22:47: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=+SneujZt3CMM0UMXLynvi+p4Z4BRi2M1/qSxhCPJuLM=; b=N8MxX3g0PKS/CCzkauoskHAw8Sytncp7Ca0AMDTcDrvDcisLh7ViewHOjoenyCJ9knjZ EzkOiPERi8hNCOB2ss+yJeMMWvbNon3TfKB3kgbOYQoA8pTyEfmDxBvtD7SemFy1p8Tb 3reZoBCEgOIL4nZc5ow0ZnmUR7ErbeG2FaIYWv4rFuy+KE2bBwIZ5cbxENE5jRUiC0ag wHsG510KHYDl0aVkqZjUcno6jxAYcnGFV63QDsBrNcNvTgvV7qF1rGwJ9BtWHyOQBAZH dZr4x3ODoW4NJXv30l+nnZr4asINiXqtwLSZIL345S6xUT62cBjzP2ncMifNSka1jNO5 IQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 30r7f5r278-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47: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 03UMgthi076901 for ; Thu, 30 Apr 2020 22:47:15 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 30r7f8a08n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:15 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlEO7012925 for ; Thu, 30 Apr 2020 22:47:14 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:13 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 34/43] xfsprogs: Add helper function xfs_attr_leaf_mark_incomplete Date: Thu, 30 Apr 2020 15:46:51 -0700 Message-Id: <20200430224700.4183-35-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 --- 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 b8dad2a..0a46827 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1149,6 +1149,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 @@ -1179,20 +1205,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 Apr 30 22:46: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: 11521869 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 D9293913 for ; Thu, 30 Apr 2020 22:47:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C09432074A for ; Thu, 30 Apr 2020 22:47:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Je/rkWFA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727884AbgD3WrT (ORCPT ); Thu, 30 Apr 2020 18:47:19 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43750 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727880AbgD3WrQ (ORCPT ); Thu, 30 Apr 2020 18:47: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 03UMhGdj128682 for ; Thu, 30 Apr 2020 22:47: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=RX9dX7Lztz7y8Krvm2asZZe83qEtNhsAmDZdtXL0dTI=; b=Je/rkWFAJ9x1hqZiIIeUYhM2yKxocVvzYD0IJ9sGr5ws9kEuoXmT4zO83U9L5gcLngdj p7P5yZ/A+zwllaXywDtvy3mVwsiy4TvtFJMQxsgZgck+5nXp+0QMF3LnUMvOcA3DQE/F NKoZ0D5BT9KeKaY1aV4L6envbLWeNEmwJ3kps7bauHjGFlUGUA14+Y6Jm7atHgkOb/sP WP80aa6Pki2aSLCN8H/uFON6ODkWpyZnUGeSVD1xX4k3xBTBR7z/EqM69wveZtNaPUaC 4688vP8TMuyw0Ua0CGfLa7TTbBzTvHHYZMrEVvWmtzEjm8VLlM8D/S6CKUJBMZFEco05 Gg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 30r7f3g23a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:15 +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 03UMhPVP181240 for ; Thu, 30 Apr 2020 22:47:15 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 30r7fes2j7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:14 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMlEN4012394 for ; Thu, 30 Apr 2020 22:47:14 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:14 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 35/43] xfsprogs: Add remote block helper functions Date: Thu, 30 Apr 2020 15:46:52 -0700 Message-Id: <20200430224700.4183-36-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 --- 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 0a46827..64cc6b3 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) @@ -930,11 +947,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 @@ -1046,11 +1059,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 Apr 30 22:46: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: 11521865 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 DDDA518A4 for ; Thu, 30 Apr 2020 22:47:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5305214D8 for ; Thu, 30 Apr 2020 22:47:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="blHR2K+C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727818AbgD3WrS (ORCPT ); Thu, 30 Apr 2020 18:47:18 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48484 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727832AbgD3WrQ (ORCPT ); Thu, 30 Apr 2020 18:47:16 -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 03UMhQUq047381 for ; Thu, 30 Apr 2020 22:47: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=w+I3OagRhMYLMUZJw+WPUyN7E9lI74SNVgwVmXMzHXk=; b=blHR2K+Cjmhg9nfzfg0RlZxQmxUCkalGY49gCRXO2aqeCwn6pqEFwK0wGdf2hB+UOmvn lsF/s1utRM7UfR6YS3l8Pb4z26x+XFWCMLt0LUKWLx7IN4KzmqpKLxzr1Q319OEUsBcY 1tOiuD/+cxEhcQO+RhBhoF+n1LgbrNT2yuj0wxg/m18YaGRHfXTK9dzcVHgEd1Iawbxp w7kT9mvzgqYAIRcZOwC9s+wIseAfRlJvFarOkH4R7tigW+mJPrr//SoLUqJrY0cLR0DV CFpcsoWJ+r6RDdqwWxowjCtfOS50mfLjiephSOIshgKasZPCocO22bJamyTIFuQg2Svs CQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 30r7f5r277-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47: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 03UMgD2M141447 for ; Thu, 30 Apr 2020 22:47:15 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 30qtg23dxg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:15 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMlELC012416 for ; Thu, 30 Apr 2020 22:47:14 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:14 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 36/43] xfsprogs: Add helper function xfs_attr_node_removename_setup Date: Thu, 30 Apr 2020 15:46:53 -0700 Message-Id: <20200430224700.4183-37-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 --- libxfs/xfs_attr.c | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 64cc6b3..7ca925a 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1185,6 +1185,39 @@ xfs_attr_leaf_mark_incomplete( } /* + * Initial setup for xfs_attr_node_removename. Make sure the attr is there and + * the blocks are valid. Any 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; + + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + } + + return 0; +} + +/* * Remove a name from a B-tree attribute list. * * This will involve walking down the Btree, and may involve joining @@ -1202,8 +1235,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; /* @@ -1211,18 +1244,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 Apr 30 22:46: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: 11521871 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 0242C15AB for ; Thu, 30 Apr 2020 22:47:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE5E12074A for ; Thu, 30 Apr 2020 22:47:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="g05FjxeY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727892AbgD3WrU (ORCPT ); Thu, 30 Apr 2020 18:47:20 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43758 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727886AbgD3WrR (ORCPT ); Thu, 30 Apr 2020 18:47:17 -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 03UMhR0p128734 for ; Thu, 30 Apr 2020 22:47: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=EZwhkpVmazikyNZSz9aV1YCtwVzcHJiLbTUVvvag4sE=; b=g05FjxeYKHTzZfLM/6RCX1qUgxfzQvbt99HP3G8PE7kZ35ZsMprhTDmFNEwKdsIG3iz4 xKEDbMLJN1yEN2JlmLf5pHSHC/MPGRaV60U/l9NzjB0sAZppmB/kBfRyexvpI/0IuYDj 39ehEPi7vPEtGFlO5YToIb/tEzf7EeyDOVUDoB0Iu883Mq9Bkn9FaQR0IO7N5vjF2/AH zyXZfbokft9XCL1TNacmnQLNLQs6eOAm7kA01WeYe9gICoxIAVKnkZoiQy53miMQp+Ct B6/Cn3yih46ZYvwwmF3W0yPN1crCMGnqRnHaIdowjUfMHHF+2l7a6N9NpUATvifzWMbu DQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 30r7f3g23e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:16 +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 03UMgEYl141518 for ; Thu, 30 Apr 2020 22:47:15 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 30qtg23dxk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:15 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlEb6011781 for ; Thu, 30 Apr 2020 22:47:14 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:14 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 37/43] xfsprogs: Add helper function xfs_attr_node_removename_rmt Date: Thu, 30 Apr 2020 15:46:54 -0700 Message-Id: <20200430224700.4183-38-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=997 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 --- 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 7ca925a..27b818d8 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1217,6 +1217,24 @@ int xfs_attr_node_removename_setup( return 0; } +STATIC int +xfs_attr_node_removename_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. * @@ -1245,15 +1263,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_removename_rmt(args, state); if (error) goto out; } From patchwork Thu Apr 30 22:46: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: 11521877 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 D25861805 for ; Thu, 30 Apr 2020 22:47:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB77E20774 for ; Thu, 30 Apr 2020 22:47:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="QxNQM7CV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727880AbgD3WrV (ORCPT ); Thu, 30 Apr 2020 18:47:21 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43760 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727833AbgD3WrR (ORCPT ); Thu, 30 Apr 2020 18:47:17 -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 03UMhFHV128675 for ; Thu, 30 Apr 2020 22:47: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=F2z1NBymBpTwIr5hLzXzAF6BLbMUI+CL7iI6ap/hFec=; b=QxNQM7CVKv0LxONGfGoXcTG4kBk2IzdcfavLTbl3GGjP5a6d8d8OktgXTuKM+sP4slEf mDQkLYZe+nS/DTSpKFAwqMDjnPxUqP5VwDZWMVbDj8KBawHgwG5vQz761sIVAdTteH9x wO3+ROX6ug0Gqbgo/lVdmI7BvTltdgo0QCbetRgMQFVDAZqgPWsg3m09icADrNodJKaU BCh8AmqfY2rlitJsw3elcHHsKkpDEVYH6jT6jn+Q5TvkCeHV00f+GX5MUn+Gs/Brh35v QRlS/Hpcul8DdEkIXBvT7UtXJwFKkcQaruVbuMSLBVfEGm2eWwRqZHZgK8dZKL/XuHHf wA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 30r7f3g23f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:16 +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 03UMgKjp141696 for ; Thu, 30 Apr 2020 22:47:15 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 30qtg23dxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:15 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlF2X012928 for ; Thu, 30 Apr 2020 22:47:15 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:14 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 38/43] xfsprogs: Simplify xfs_attr_leaf_addname Date: Thu, 30 Apr 2020 15:46:55 -0700 Message-Id: <20200430224700.4183-39-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Quick patch to unnest the rename logic in the leaf code path. This will help simplify delayed attr logic later. Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 108 +++++++++++++++++++++++++++--------------------------- 1 file changed, 53 insertions(+), 55 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 27b818d8..166c4ab 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -695,73 +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) == 0) { /* - * 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. - */ - 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) - return error; - } - - } 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 Apr 30 22:46: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: 11521873 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 33E7317EF for ; Thu, 30 Apr 2020 22:47:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1937020774 for ; Thu, 30 Apr 2020 22:47:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="JTRQEM8w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727886AbgD3WrV (ORCPT ); Thu, 30 Apr 2020 18:47:21 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:59024 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727888AbgD3WrR (ORCPT ); Thu, 30 Apr 2020 18:47:17 -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 03UMkwoc066071 for ; Thu, 30 Apr 2020 22:47: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=l3uEre1llIcx2p+Ftb3+YI+s/QL2SosmcmX405x7P8A=; b=JTRQEM8wmbCBYfuQnp59Tr36osXDUHjUzt4nUf1hxu0zjfgsVV0LVBPLHj8JmT8/ijRb arwYg8ewgbbb1w83Y/8hPkPKqXhhEBRy1D+NhE+ISEjokCnE5QirVirFdWNBvJbY5z0G s8j3rbLtz2lPiQzmORISp3FLk+XC6TnM0g38qEg6jo5Lm3ythpsUopPbHbLFNUyYz3Ax 529Sp1mU/SO9ieinea/waguLAu6n6LS7gVk9AdZlDTdmS/60jWF9GcS2BRDblZw1ow6G HgU39rgdAj075zxh/cbbl1ZOxm5mskn1NPxWg7D2O5aS9boTjUKKgmHipzCfMZDFVTr9 PQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 30r7f8028f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:16 +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 03UMgSXO015956 for ; Thu, 30 Apr 2020 22:47:15 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 30r7f298pu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:15 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlFtX011786 for ; Thu, 30 Apr 2020 22:47:15 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:15 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 39/43] xfsprogs: Simplify xfs_attr_node_addname Date: Thu, 30 Apr 2020 15:46:56 -0700 Message-Id: <20200430224700.4183-40-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 adultscore=0 spamscore=0 mlxlogscore=998 bulkscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Quick patch to unnest the rename logic in the node code path. This will help simplify delayed attr logic later. Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 131 ++++++++++++++++++++++++++---------------------------- 1 file changed, 64 insertions(+), 67 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 166c4ab..72c9c22 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1031,83 +1031,80 @@ 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) == 0) { /* - * 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->op_flags |= XFS_DA_OP_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->op_flags |= XFS_DA_OP_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; - error = xfs_defer_finish(&args->trans); - 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; + error = xfs_defer_finish(&args->trans); if (error) goto out; } From patchwork Thu Apr 30 22:46:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521895 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 9081615AB for ; Thu, 30 Apr 2020 22:49:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77A7B20774 for ; Thu, 30 Apr 2020 22:49:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="BEnELZjV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726495AbgD3WtS (ORCPT ); Thu, 30 Apr 2020 18:49:18 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45208 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726355AbgD3WtR (ORCPT ); Thu, 30 Apr 2020 18:49:17 -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 03UMmw3m133013 for ; Thu, 30 Apr 2020 22:49: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=y3rIFl4KZEkfP6ZBAkYg7rOTL4Kp3fcAA76VE9K2OCg=; b=BEnELZjVJ3r8Tpn1apYOe4TwUmBRVFrXyEe0dWn5H6q4OnPF8yuHQTZJOrO1AnjRHcjs V2VuRTaGdZgtPSvmEv5NOxvkKXKzIVeO0baP6GoRUHMZPLNvEc/b8Lsg2kneJSm90xEI zIldbPrOnvUeAnZVuBS4LKtKaiheLMiP9i2N5FlbtJ1NTj+9Kzni9ta64LuyMkhX98zY wNPh6BOdP5scP/7ZSUohS3DQd5gzUCftOFWlEwbISsTTV0jyTDSsoF5gERnSfXliu5Ij qMc1Vim/QD9eA0JUxGBaD1Lx3Bi+hKX2xvm1RoIryK+sZnL02D0SgUCE2kcGc58uzays dA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 30r7f3g2bk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:49:17 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03UMhPtW181155 for ; Thu, 30 Apr 2020 22:47:16 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 30r7fes2m8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:16 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03UMlFXB012421 for ; Thu, 30 Apr 2020 22:47:15 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:15 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 40/43] xfsprogs: Lift -ENOSPC handler from xfs_attr_leaf_addname Date: Thu, 30 Apr 2020 15:46:57 -0700 Message-Id: <20200430224700.4183-41-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 --- 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 72c9c22..5e4013c3 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -300,6 +300,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; + + /* * Commit that transaction so that the node_addname() * call can manage its own transactions. */ @@ -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 Apr 30 22:46:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521875 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 B598015AB for ; Thu, 30 Apr 2020 22:47:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9459D20774 for ; Thu, 30 Apr 2020 22:47:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="BNzADr3v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727833AbgD3WrW (ORCPT ); Thu, 30 Apr 2020 18:47:22 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48524 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727864AbgD3WrV (ORCPT ); Thu, 30 Apr 2020 18:47:21 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03UMhYYq047418 for ; Thu, 30 Apr 2020 22:47: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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=m/1nSXlMW8w7A1al2HPe6GiHzMfvf762uD1a6NIvN4Q=; b=BNzADr3vqtTqPKK3tjKkzgIKUcQ0gN/NoZbyb3fu3XHXzUlO7VEAhGOCouJSP9m0KFrc 3KYmJ8rZyCr46cdG/+XXrvYiyK7y/C76CjzC3tyrQr4U3JyF3B4/gPzWVtrStPAxStnd eVV/L10zsgUznevZUtWUhpfAC62sasuYXEKxHH+TlAQzknKwi9fS7DRDzWfE1HyIPeMf k2gX86hyoMTatLibMXzRUtfztA2TeD/XLzj+124HCSEKG3qjycXOIKxWMTQ8qloB22I0 Pw4nfKNlAnQbhewze1U+fFeUDtg6k+0Sk/7Dc7tXI6uZEsmuulOTpVXjgAXf3SSa5z54 Hg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 30r7f5r27c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:18 +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 03UMgtJt076902 for ; Thu, 30 Apr 2020 22:47:17 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 30r7f8a0br-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:17 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlFRR012931 for ; Thu, 30 Apr 2020 22:47:16 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:15 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 41/43] xfsprogs: Add delay ready attr remove routines Date: Thu, 30 Apr 2020 15:46:58 -0700 Message-Id: <20200430224700.4183-42-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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. 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 <─────┘ Signed-off-by: Allison Collins --- include/libxfs.h | 1 + libxfs/xfs_attr.c | 161 +++++++++++++++++++++++++++++++++++------------ libxfs/xfs_attr.h | 73 +++++++++++++++++++++ libxfs/xfs_attr_leaf.c | 2 +- libxfs/xfs_attr_remote.c | 31 +++++---- libxfs/xfs_attr_remote.h | 2 +- 6 files changed, 216 insertions(+), 54 deletions(-) diff --git a/include/libxfs.h b/include/libxfs.h index 1244783..33ec7f1 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -169,6 +169,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 5e4013c3..0aa87c2 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -54,12 +54,21 @@ 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); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); +void +xfs_delattr_context_init( + struct xfs_delattr_context *dac, + struct xfs_da_args *args) +{ + memset(dac, 0, sizeof(struct xfs_delattr_context)); + dac->da_args = args; +} + int xfs_inode_hasattr( struct xfs_inode *ip) @@ -264,6 +273,18 @@ xfs_attr_set_shortform( return 0; } +int xfs_attr_defer_finish( + struct xfs_delattr_context *dac) +{ + struct xfs_da_args *args = dac->da_args; + + if (!(dac->flags & XFS_DAC_DEFER_FINISH)) + return 0; + + dac->flags &= ~XFS_DAC_DEFER_FINISH; + return xfs_defer_finish(&args->trans); +} + /* * Set the attribute specified in @args. */ @@ -364,23 +385,57 @@ 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; + + xfs_delattr_context_init(&dac, args); + + do { + error = xfs_attr_remove_iter(&dac); + if (error != -EAGAIN) + break; + + error = xfs_attr_defer_finish(&dac); + if (error) + break; + + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + break; + } 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_d.di_aformat == 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); } /* @@ -1178,15 +1233,17 @@ xfs_attr_leaf_mark_incomplete( /* * Initial setup for xfs_attr_node_removename. Make sure the attr is there and - * the blocks are valid. Any remote blocks will be marked incomplete. + * the blocks are valid. Any remote blocks will be marked incomplete and + * invalidated. */ 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) @@ -1196,6 +1253,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) @@ -1211,12 +1275,15 @@ int xfs_attr_node_removename_setup( STATIC int xfs_attr_node_removename_rmt ( - struct xfs_da_args *args, - struct xfs_da_state *state) + 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; @@ -1233,21 +1300,35 @@ xfs_attr_node_removename_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. @@ -1255,8 +1336,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_removename_rmt(args, state); - if (error) + /* + * May return -EAGAIN. Remove blocks until args->rmtblkno == 0 + */ + error = xfs_attr_node_removename_rmt(dac, state); + if (error == -EAGAIN) + return error; + else if (error) goto out; } @@ -1275,17 +1361,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 66575b8..0430c79 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_defer_finish(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 e3f8457..22e565cc 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 7765ee9..be0f34d 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -675,14 +675,16 @@ 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; + struct xfs_delattr_context dac; + xfs_dablk_t lblkno; + int blkcnt; + int error = 0; + int retval = 0; trace_xfs_attr_rmtval_remove(args); + xfs_delattr_context_init(&dac, args); /* * Keep de-allocating extents until the remote-value region is gone. @@ -690,10 +692,14 @@ xfs_attr_rmtval_remove( lblkno = args->rmtblkno; blkcnt = args->rmtblkcnt; do { - retval = __xfs_attr_rmtval_remove(args); + retval = __xfs_attr_rmtval_remove(&dac); if (retval && retval != EAGAIN) return retval; + error = xfs_attr_defer_finish(&dac); + if (error) + break; + /* * Close out trans and start the next one in the chain. */ @@ -712,9 +718,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 +731,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 ee3337b..351da00 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 Apr 30 22:46:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521899 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 E6806913 for ; Thu, 30 Apr 2020 22:49:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1274207DD for ; Thu, 30 Apr 2020 22:49:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="xwxXywZ9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726562AbgD3WtY (ORCPT ); Thu, 30 Apr 2020 18:49:24 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60456 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726478AbgD3WtY (ORCPT ); Thu, 30 Apr 2020 18:49:24 -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 03UMlXLd066919 for ; Thu, 30 Apr 2020 22:49: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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=vN5HBFVxlYNNnYWZbhaUAV4M8mcX6GbtL1TN/XY1/GA=; b=xwxXywZ9FBrMUfjUhVHdtvm7dXNGXH6xk1vSsB6oepRHpGEtfPZHQ8RDwxyv3CHPr1sI fbQMQpZki6ljQgIppdptXBt/HCYCz4On284bkvv9D/wW55961Xk+eWSj8cTNtTA0k7st jr7PdzTQpjF1lfniD0cKbIPA8CjAkLT6zNLvAz4sdSu2zzECWNGLiZtz7avH1E038Cek Xc9zg+wT1SFKoUetbK+PTr0Ce+6rJqtgxAaUJIW0rImBYfJJpA1KsivPCLcjc+5dweJU 4Td8O+P8MN6NZ6Q/6gvPPJjzeUXga+2H17xyE7oFuSptwG53BdkGNf7oXpi48Fi/jClN kg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30r7f802en-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:49:17 +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 03UMgGVA141591 for ; Thu, 30 Apr 2020 22:47:17 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 30qtg23e0h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:16 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlGSk012934 for ; Thu, 30 Apr 2020 22:47:16 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:15 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 42/43] xfsprogs: Add delay ready attr set routines Date: Thu, 30 Apr 2020 15:46:59 -0700 Message-Id: <20200430224700.4183-43-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=3 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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. 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. Below is a state machine diagram for attr set 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_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 <──────┘ Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 371 +++++++++++++++++++++++++++++++---------------- libxfs/xfs_attr.h | 127 +++++++++++++++- libxfs/xfs_attr_remote.c | 110 ++++++++------ libxfs/xfs_attr_remote.h | 4 + 4 files changed, 445 insertions(+), 167 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 0aa87c2..255db9e 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -45,7 +45,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); @@ -53,12 +53,13 @@ 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); void xfs_delattr_context_init( @@ -228,8 +229,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( @@ -237,16 +241,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: @@ -259,20 +263,13 @@ 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; } +STATIC int xfs_attr_defer_finish( struct xfs_delattr_context *dac) { @@ -292,60 +289,128 @@ 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; + + xfs_delattr_context_init(&dac, args); + + do { + error = xfs_attr_set_iter(&dac, &leaf_bp); + if (error != -EAGAIN) + break; + + error = xfs_attr_defer_finish(&dac); + if (error) + break; + + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + break; + + 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. + */ +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; - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_addname(args); - if (error != -ENOSPC) - return error; + return error; + } - /* - * Promote the attribute list to the Btree format. - */ - error = xfs_attr3_leaf_to_node(args); - if (error) - return error; + /* + * After a shortform to leaf conversion, we need to hold the leaf and + * cylce 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; + } - /* - * Commit that transaction so that the node_addname() - * call can manage its own transactions. - */ - error = xfs_defer_finish(&args->trans); - 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; - /* - * Commit the current trans (including the inode) and - * start a new one. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) + /* + * Commit that transaction so that the node_addname() + * call can manage its own transactions. + */ + 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) + /* We will be in node form when we return */ + return -EAGAIN; + return error; } - - error = xfs_attr_node_addname(args); +das_node: + error = xfs_attr_node_addname(dac); return error; } @@ -712,28 +777,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 @@ -741,12 +808,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_set_init(dac); + if (error) + return error; + } + } + + /* + * Roll through the "value", allocating blocks on disk as + * required. + */ + while (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) == 0) { /* * Added a "remote" value, just clear the incomplete flag. @@ -766,29 +855,33 @@ 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(dac); + + if (error == -EAGAIN) { + dac->dela_state = XFS_DAS_RM_LBLK; + return -EAGAIN; + } - error = xfs_attr_rmtval_remove(args); if (error) return error; } @@ -958,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); @@ -976,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. @@ -1022,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; } /* @@ -1046,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. @@ -1063,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 @@ -1078,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_set_init(dac); + if (error) + return error; + + /* + * Roll through the "value", allocating blocks on disk as + * required. + */ +das_alloc_node: + while (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; } @@ -1108,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; } @@ -1156,9 +1284,8 @@ restart: error = xfs_da3_join(state); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; + + dac->flags |= XFS_DAC_DEFER_FINISH; } retval = error = 0; diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 0430c79..5cbefa90 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; @@ -158,10 +283,10 @@ 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); -int xfs_attr_defer_finish(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 be0f34d..d17f972 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,70 @@ 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_set_init( + 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 error; +} + +/* + * 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,48 +734,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) -{ - struct xfs_delattr_context dac; - xfs_dablk_t lblkno; - int blkcnt; - int error = 0; - int retval = 0; - - trace_xfs_attr_rmtval_remove(args); - xfs_delattr_context_init(&dac, args); - - /* - * Keep de-allocating extents until the remote-value region is gone. - */ - lblkno = args->rmtblkno; - blkcnt = args->rmtblkcnt; - do { - retval = __xfs_attr_rmtval_remove(&dac); - if (retval && retval != EAGAIN) - return retval; - - error = xfs_attr_defer_finish(&dac); - if (error) - break; - - /* - * Close out trans and start the next one in the chain. - */ - 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 recall the function diff --git a/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index 351da00..51a1c91 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_set_init(struct xfs_delattr_context *dac); #endif /* __XFS_ATTR_REMOTE_H__ */ From patchwork Thu Apr 30 22:47:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11521897 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 20580913 for ; Thu, 30 Apr 2020 22:49:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08248207DD for ; Thu, 30 Apr 2020 22:49:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="DYaCun6g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726545AbgD3WtT (ORCPT ); Thu, 30 Apr 2020 18:49:19 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45216 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726355AbgD3WtT (ORCPT ); Thu, 30 Apr 2020 18:49:19 -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 03UMmx9R133051 for ; Thu, 30 Apr 2020 22:49: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=JDWYU2FE2UfG1r6XPHBcndW2kv0zMlua6b5nkb0NowU=; b=DYaCun6g8sHv1EbHqJ7RLxD1GXq7Z6hNUXoTgQCTnaScpaiKg8DxFo2aAmWG2ZMQgYKk sly6ItgpYk1ToX5vwe1AKNGbLfSav1kIMtsLvOiM4zt/1M4vtK8lzOlipM0YYcfHOxd4 XgWAulK3ZzNndHL1KeKwdJ3KcHozpl8NCGFm5JTcSaCnpQqU1KB0Q9RbNE1y5ihWaFXb lyPLHWAOjzGvatQmZr0RUElB/zLpyS4Fdk1xpwsPvYgyvq1dDMCzuBhXUAnc+8WBfrUB 5hgvrdg9wZw3gbZekCe+8WA0CB7R0Nlo1Tnp6dglsm9BbmXtjoA8qqpM5HbwDXFQoJaU /Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 30r7f3g2bp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:49: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 03UMgEac141512 for ; Thu, 30 Apr 2020 22:47:17 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 30qtg23e0j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 22:47:17 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03UMlGrD011790 for ; Thu, 30 Apr 2020 22:47:16 GMT Received: from localhost.localdomain (/67.1.142.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Apr 2020 15:47:16 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v9 43/43] xfsprogs: Rename __xfs_attr_rmtval_remove Date: Thu, 30 Apr 2020 15:47:00 -0700 Message-Id: <20200430224700.4183-44-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430224700.4183-1-allison.henderson@oracle.com> References: <20200430224700.4183-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 mlxlogscore=954 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9607 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300167 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 --- libxfs/xfs_attr.c | 7 +++---- libxfs/xfs_attr_remote.c | 2 +- libxfs/xfs_attr_remote.h | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 255db9e..b9754a5 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -875,8 +875,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; return -EAGAIN; @@ -1245,7 +1244,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; @@ -1410,7 +1409,7 @@ xfs_attr_node_removename_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 d17f972..754fda6 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -739,7 +739,7 @@ xfs_attr_rmtval_invalidate( * transaction and recall 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 51a1c91..09fda56 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);