From patchwork Fri Apr 3 22:09: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: 11473763 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 DC9CA1392 for ; Fri, 3 Apr 2020 22:12:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B67982078C for ; Fri, 3 Apr 2020 22:12:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="lUw0H7bu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727924AbgDCWMH (ORCPT ); Fri, 3 Apr 2020 18:12:07 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:46980 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727829AbgDCWMH (ORCPT ); Fri, 3 Apr 2020 18:12:07 -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 033M9h1t082585 for ; Fri, 3 Apr 2020 22:12:05 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=lUw0H7buUigZHiny7CR1w/cC6D7X2nCKpjlBy+vL6VU4mFnr3bSHDokYHyx/jft74NBW HiT8QHb7FlS68pWGxwNLpi4fIK7Vtul1XMcRzGOJjaduYYQNunuVJkM8hoMaooFOA4sU hUQ+eToC3p3z1ssFLS40Cu5gWkYe4nkUVaF80/D4o1qBk8nQ+kw0KTMM9poaa5mrXm7w /LQACNFyeLdW34sLORL5AED1DIFAw/1FfSA/DIT+vNeLSn1ZS3YiSZFSOWasKYgMFtQ3 AXdMujkIsLiJW6EfkalXfirAmIzzuO3qodIj7VzdiENCnu9SlG7d6Ez2ZcNSpUnbG89i Rg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 303cevkdp3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12:05 +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 033M8Now062337 for ; Fri, 3 Apr 2020 22:10:05 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 302ga611r0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:05 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MA4oX015869 for ; Fri, 3 Apr 2020 22:10:04 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:04 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 01/39] xfsprogs: remove the ATTR_INCOMPLETE flag Date: Fri, 3 Apr 2020 15:09:20 -0700 Message-Id: <20200403220958.4944-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 suspectscore=1 mlxscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473721 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 881771874 for ; Fri, 3 Apr 2020 22:10:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 668EC2080C for ; Fri, 3 Apr 2020 22:10:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="dQ41yZku" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727958AbgDCWKJ (ORCPT ); Fri, 3 Apr 2020 18:10:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54064 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727842AbgDCWKJ (ORCPT ); Fri, 3 Apr 2020 18:10: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 033MA8wg093378 for ; Fri, 3 Apr 2020 22:10: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=7uN69r3Relzv2FGxyDjHYizrqgKyFeQt6aX0C7cDqr0=; b=dQ41yZku2vNXrEbta6qBI/eaRoGVlkePRfK2Keg5EYWxHJAuIrCyHbZCKIBb+oD8hc47 bz6m0hlpSzGtA/QFn+GsfCWgqKJ0kOINn1jp0pEYhswL8EqsmRDSGaoBnQrnznkziIl0 krh8f10e2ecY/Ptox0rJxakgj3RiAXBLDEL4KsexulsRpDa7+LMdcMdSQJKDpohqe5Li t4pEZIdm1Lu5VRqVcjxnUa7r+3hFGE57+gEzrir2FZ5a/Sx+AjWaag3Eg1UKM839iZPo 5GR+xm44Eu2rqQ+rdaH4qt+lj0g8jh/2ViZ8VqIvnZlyT8XuE6zzOR6YuTCILQtn4tQd zA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 303yunp0ff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M8Np0062337 for ; Fri, 3 Apr 2020 22:10:07 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 302ga611rt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:05 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MA43m028160 for ; Fri, 3 Apr 2020 22:10:04 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:04 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 02/39] xfsprogs: merge xfs_attr_remove into xfs_attr_set Date: Fri, 3 Apr 2020 15:09:21 -0700 Message-Id: <20200403220958.4944-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473765 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 2B12592A for ; Fri, 3 Apr 2020 22:12:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A53F20B1F for ; Fri, 3 Apr 2020 22:12:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="RJ6+Thm8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727829AbgDCWMH (ORCPT ); Fri, 3 Apr 2020 18:12:07 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56098 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727907AbgDCWMH (ORCPT ); Fri, 3 Apr 2020 18:12: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 033M9eUk092987 for ; Fri, 3 Apr 2020 22:12: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=EgohZvcFnhyV76yoltaa5bD231Ba1Fj2lCW8gC1wSKI=; b=RJ6+Thm8e394H92lYWpHqNB7xxj2TDBs/vvphqpSZRs5anrkpILGZBBuzrzEdnUxqSA/ d45noMTZs1XO7HGWBmupHw9tN0YjPcHrrMj13AJqelUlOXV/DJdJ4IZmCKdxN7hhjuzU JFTF3I2LkR4uyU/lBkIReSeeLjcu/QDZZFIUirDj/eBHonkG+YS3DlpR100A9Xf1x9xz Y5EqsXY5xWfZVfD0wVM/sOkkms2uc68Y7K5+GPShu/oYdWBXX8ZCYONjEK5KpcL9bel6 5mXV7JsYd+eRI917D8d2AEOnqKV7a61XxQaEfOA0Ox4VJwULoRvrICdKcGoJdUTOWnD1 SQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 303yunp0mw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12:06 +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 033M8Njg062283 for ; Fri, 3 Apr 2020 22:10:05 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 302ga611s9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:05 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MA5qq009835 for ; Fri, 3 Apr 2020 22:10:05 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:04 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 03/39] xfsprogs: remove the name == NULL check from xfs_attr_args_init Date: Fri, 3 Apr 2020 15:09:22 -0700 Message-Id: <20200403220958.4944-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473713 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 239621874 for ; Fri, 3 Apr 2020 22:10:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02405208E4 for ; Fri, 3 Apr 2020 22:10:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="CZq6H5qz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727909AbgDCWKI (ORCPT ); Fri, 3 Apr 2020 18:10:08 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54046 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727879AbgDCWKI (ORCPT ); Fri, 3 Apr 2020 18:10: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 033MA0PN093196 for ; Fri, 3 Apr 2020 22:10: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=BOD0LOZtG4VezGq74iXQ8aUjJTE1jyIhn68/qZLSKzo=; b=CZq6H5qzjx7KQGkRxEZdc8tiKcoQwNm1tq9NNbfbI0r6rrjpQSkIMR0C2hjd+f3gBRiW 47O33garSbD3ijmuKGZtKIzBkJFclyahw/vFmawWQJk8cUw+VN5gx7lppP4K14WLCgvS 29pdpMq9ptswboqz3rEmSXeU0W9APVuG2BH8cWQHCFhbDmqCZ86oKZtyc0LSi/95gnQv TON3+WYZ2LcVKRJleMRPYy79PXCuys7ZFnzTRvihn9XyD2T+czW82fCYjakiHS9CSjDL BGBbywOzkARFyR4SckmtaeynJPaLgWoyTAXn8SyrABD4U4j8BhwflZou2rDRRJgcnShV JQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 303yunp0fd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:07 +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 033M8Wih101939 for ; Fri, 3 Apr 2020 22:10:06 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 302g4y9g15-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:06 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MA5qm028163 for ; Fri, 3 Apr 2020 22:10:05 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:05 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 04/39] xfsprogs: remove the MAXNAMELEN check from xfs_attr_args_init Date: Fri, 3 Apr 2020 15:09:23 -0700 Message-Id: <20200403220958.4944-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473711 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 EC40992A for ; Fri, 3 Apr 2020 22:10:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CAB81207FF for ; Fri, 3 Apr 2020 22:10:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="f1n23MVs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727829AbgDCWKI (ORCPT ); Fri, 3 Apr 2020 18:10:08 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38378 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727842AbgDCWKH (ORCPT ); Fri, 3 Apr 2020 18:10:07 -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 033M91XO019200 for ; Fri, 3 Apr 2020 22:10: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=iydhf0LB5YIEF9EBBSOiFHX9VFA4DhbfPRT/qsdcfNY=; b=f1n23MVsW1RESNy8vg6+O5P0V87ZHrl/0p+Qc+vlLRKDQ7iqnbR9XMpvXi1JcRnHb1Rn 7RlQ8tbj3qS1ka+mfDdmMzCkXC/cUMMWaGWS79N+Dj52YZtxAAYP+6dsuoBRg8oRqcp+ 35Fm8eZ3FJqo/L/0Ip6AE2BzE49PimQeI/hiEXuv62eHYmhDQeYy6+YxzTmFBmCuKYcQ yoXUs+F4EEy9uFSCaU93EZCtU5kp5U5bfn0YedgCfgsDkVGYqJHCiJ9WJpPelmhxDm5p t7RjUdS4kwPdmQJRRaY7S1eAFP37M3PCr/ZIzF+o+KD05sKuFsCcqw1lmDYiqnkh6REH eA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 303aqj3w4b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:06 +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 033M8Njh062283 for ; Fri, 3 Apr 2020 22:10:06 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 302ga611td-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:06 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MA5rZ009845 for ; Fri, 3 Apr 2020 22:10:05 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:05 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 05/39] xfsprogs: turn xfs_da_args.value into a void pointer Date: Fri, 3 Apr 2020 15:09:24 -0700 Message-Id: <20200403220958.4944-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473715 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 4FE0D159A for ; Fri, 3 Apr 2020 22:10:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D736208E4 for ; Fri, 3 Apr 2020 22:10:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="bfqwGA9C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727879AbgDCWKI (ORCPT ); Fri, 3 Apr 2020 18:10:08 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54048 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727867AbgDCWKI (ORCPT ); Fri, 3 Apr 2020 18:10: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 033M9wL9093185 for ; Fri, 3 Apr 2020 22:10: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=bfqwGA9CfsCOa2VXUIAO0Fn/fCdKHET7wetxC0ZrtJ89X8WmOuI7MUh7xcVHRE9FaH/x iA5Iwgt6oemLXE+F4Kn4tDnAgX3Z7unAuaGRGJm9gghlYTG0uB/g01uB9xykHY+3zBpy QiOdawH8v05BLgXTdTJexa66pyxrqt6kcoKAx6eMqyqDYtR5nIBSFIV5Tps/0y6Czxd8 Yq7nK3n1tNy678CyDQ5iOEBHELQmDSk832FPtmUIs6Kf/hWjdCTJwZlRh6XPAOrFd+FN xDqemXJfLMhJa7A1T2iqSZXaRt+mQRaa4ANBAXXG7wh39wgDpj2wM33aUn4gV4Bctdbf YA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 303yunp0fc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:06 +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 033M8XXg101988 for ; Fri, 3 Apr 2020 22:10:06 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 302g4y9g1p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:06 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MA6kq005639 for ; Fri, 3 Apr 2020 22:10:06 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:05 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 06/39] xfsprogs: pass an initialized xfs_da_args structure to xfs_attr_set Date: Fri, 3 Apr 2020 15:09:25 -0700 Message-Id: <20200403220958.4944-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473717 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 E46341392 for ; Fri, 3 Apr 2020 22:10:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B942E2080C for ; Fri, 3 Apr 2020 22:10:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="qJOba/pR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728060AbgDCWKJ (ORCPT ); Fri, 3 Apr 2020 18:10:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54072 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727947AbgDCWKJ (ORCPT ); Fri, 3 Apr 2020 18:10: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 033MA8Wl093384 for ; Fri, 3 Apr 2020 22:10: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=m37ptyzmIlB9pMTmy2UUktWz+7WyoJEn9LXSavkE1Uo=; b=qJOba/pRWatQHUAqZDfCkTYb4jQ5VLKnM5aEmsaMWNEWMLY2wVpJQKG/Xkmz37LC807L +m+SVRV44NWBIVkIy3gvJWFjKGbRiMsUQUiTRng9k6jyx68WXdk6p5s6292AyuQ2CTpX K0Yh/YUG5u73QL5MNJXOMBryWJOeU+dvwTUX8GCl4N7gMxBEenAQWbamzm9vK7hql8JK 2vpUWq95VsG6QMMuwVWGgPBf0SqCGMtddYk9gfgTiwa7zEZZX8WEs1xSAbv7YeEMWmWW bYAXapHKocYMvjUFHck5qq9olE3RlnFNlcvn4IxTOw7iPzHXZDAGR1CxbXu+ZLTACTNt wA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 303yunp0fk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M7K5f167858 for ; Fri, 3 Apr 2020 22:10:07 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 304sju4c47-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:07 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MA6Z7028166 for ; Fri, 3 Apr 2020 22:10:06 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:06 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 07/39] xfsprogs: pass an initialized xfs_da_args to xfs_attr_get Date: Fri, 3 Apr 2020 15:09:26 -0700 Message-Id: <20200403220958.4944-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=3 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=3 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473723 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 1C22A92A for ; Fri, 3 Apr 2020 22:10:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EEDA52080C for ; Fri, 3 Apr 2020 22:10:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="dEHl1123" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727947AbgDCWKK (ORCPT ); Fri, 3 Apr 2020 18:10:10 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54078 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727867AbgDCWKK (ORCPT ); Fri, 3 Apr 2020 18:10:10 -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 033MA8Wm093384 for ; Fri, 3 Apr 2020 22:10: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=dEHl1123f8UotjkAtyyjMlQuyeuedIoZDdk04wb6Xi+3RSUwj3kJJ+qxHp5IhVp07BOA FKWwXJ0lU1dkGteyY6tx8DNKo3zrLHNdXANeCP5TKtPSKp1iT22UA5rR393/wOuWuj6F YUEpv5T4F8H7/PDImhph4XUN5iow0X1NBIZXbJrkc6ewUFP+0CNo/ZdmhktpTbMv0HsX DsVX6RXqWFxv9ungZX1bH2X+vZXPVMH7t4aBe6AXxyZHHgPND2ZTjYrk8fUbjMmrAQC8 MIXFjfs7KnqWpy4bSWyVB1/f3d3z+Oc7sG3oCaRr8orasun2KUZYIgcdXf6r317VWWiB CQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 303yunp0fm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M7KDM167917 for ; Fri, 3 Apr 2020 22:10:08 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 304sju4c4r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:07 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MA6v1009851 for ; Fri, 3 Apr 2020 22:10:06 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:06 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 08/39] xfsprogs: remove the xfs_inode argument to xfs_attr_get_ilocked Date: Fri, 3 Apr 2020 15:09:27 -0700 Message-Id: <20200403220958.4944-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=1 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473719 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 4B15E92A for ; Fri, 3 Apr 2020 22:10:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F69A2080C for ; Fri, 3 Apr 2020 22:10:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Siisx7Bz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728102AbgDCWKJ (ORCPT ); Fri, 3 Apr 2020 18:10:09 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45468 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727958AbgDCWKJ (ORCPT ); Fri, 3 Apr 2020 18:10: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 033MA8Oc083000 for ; Fri, 3 Apr 2020 22:10: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=Siisx7BzDvVKTxoEfnS2ojaeG8vkh/JFp2z7PA0MsRW6OBEM746v85jAlW+SRqJ054j2 XUhSr6qv0CJXWxMtcVjvi15PB3bWkWuaJp1uUDwUk1nxxMyn/e4l59E8Dt7ZIV0I5N+t ZC/2/bs1mA4ZX+JhGkpD/oisJESiN/3odJvF+gTwEbeyWEd6xd4mxh5FvG4FzjwDcPNT zJoQYRMeFmDr08h/LDUoD5oIGWpLmzAgBqZPsySA8fH4xmKgzXUEdAJXGhkiPwx0KWwc XhyXHPdF+R1aZMNVx/qaseK+FvO7bQ+e89gHDKp5QSvqchhFpMDy647vk0f91v+BDg9P Qw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 303cevkdhd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M7A89170961 for ; Fri, 3 Apr 2020 22:10:07 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 302g2p2bs4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:07 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MA7aq009854 for ; Fri, 3 Apr 2020 22:10:07 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:06 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 09/39] xfsprogs: remove ATTR_KERNOVAL Date: Fri, 3 Apr 2020 15:09:28 -0700 Message-Id: <20200403220958.4944-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 suspectscore=1 mlxscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473767 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 BA84F1392 for ; Fri, 3 Apr 2020 22:12:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 969192078C for ; Fri, 3 Apr 2020 22:12:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="u9YMZdMY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727907AbgDCWMK (ORCPT ); Fri, 3 Apr 2020 18:12:10 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40132 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726460AbgDCWMK (ORCPT ); Fri, 3 Apr 2020 18:12: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 033M9rQY019649 for ; Fri, 3 Apr 2020 22:12: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=u9YMZdMYUIcIxBp1HE/pGDcSnmAD6BChBnadhZuJl2BZD4yjreQ4UIMsklWuYlFEJRNu vG/VmvKi4kltzJX+NEDH2R9smHatybG19GEQBnophlWT5aQ/nd6WnkeL5EcHuozkjUGs 1OK+BqWAuBT6idN8mz5Sv4pMtTArPTIrCXfku90BAwx9zPqONXNguDmLM8pzixLVhHsJ 5gxKMqbN9IsRn1h1x/VF7fTQc9yABcxPA19BGsp0Ls7XlDkT0dXcHbbb+rb7GgDBwaC9 kwNICxv6rk2wM5SEBSqoPHXaxyxMNNK9O9jobro080Aho5Gr+PDCxVnQCJwYlQugH4Xe 6A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 303aqj3w9e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12: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 033M8Obj062388 for ; Fri, 3 Apr 2020 22:10:08 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 302ga611uq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:08 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MA740015943 for ; Fri, 3 Apr 2020 22:10:07 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:07 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 10/39] xfsprogs: remove ATTR_ALLOC and XFS_DA_OP_ALLOCVAL Date: Fri, 3 Apr 2020 15:09:29 -0700 Message-Id: <20200403220958.4944-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=3 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473725 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 480D31392 for ; Fri, 3 Apr 2020 22:10:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 25F43207FF for ; Fri, 3 Apr 2020 22:10:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="pJiiYF5B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727842AbgDCWKK (ORCPT ); Fri, 3 Apr 2020 18:10:10 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38402 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727947AbgDCWKJ (ORCPT ); Fri, 3 Apr 2020 18:10:09 -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 033M8v0D019076 for ; Fri, 3 Apr 2020 22:10: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=pJiiYF5BjwHprUI513XpTWRZaIUeIJZVLJUek2Qkm9cua0h48TO3NGzaM1ZBf8cRKsBv 998EqVOhtaG/k+0UeiwznJHJ1jKqDBIO6x3HYk796JW7bWRm1/FRaRv+4hb1YizAnYgc +vH9thEQ41tMetAqRLzUN0BzVW9F9++a8VAty5nrSu0A5RspJ9Yj9LX8zj6gq7VJd77+ S02s3dWAw8QIQr/s1KRRzY/mkOl303Q71DEibIKidKWditTgQp4x4Ly1ieF+lr5XY4F3 FkfQultTM/1kS9ZEjP81nmruf3DpWFo1L60xlxEmR2MWpGskUXUvcxenvdPOQjiI2JyZ yw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 303aqj3w4f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M8Nxe062310 for ; Fri, 3 Apr 2020 22:10:08 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 302ga611v8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:08 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MA70N015958 for ; Fri, 3 Apr 2020 22:10:07 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:07 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 11/39] xfsprogs: replace ATTR_KERNOTIME with XFS_DA_OP_NOTIME Date: Fri, 3 Apr 2020 15:09:30 -0700 Message-Id: <20200403220958.4944-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473769 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 DACA11392 for ; Fri, 3 Apr 2020 22:12:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8FD4207FF for ; Fri, 3 Apr 2020 22:12:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="S/FfzIEX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728469AbgDCWML (ORCPT ); Fri, 3 Apr 2020 18:12:11 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56158 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727950AbgDCWML (ORCPT ); Fri, 3 Apr 2020 18:12:11 -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 033M9e5Z092993 for ; Fri, 3 Apr 2020 22:12: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=qS/huGSEeO0peQve8+GwCsv19WKf/nAFb30FHyNGCRo=; b=S/FfzIEXHQO+Naw2/AC/YEFwZ5vAQDW/dTEzkkucW5/14laXG2Pio2yCF4kS/EnA09kb M+zVXjfQ2FPCxKfz33glOSSoF3b+VeyiYwCA6grCCFG6GZjmzWAay6TWlvIQT7hTO6ae jN/S3baHeKdbqU2VRXcioQaFh0DEBvLWrGIc2W0zaY3f53LOtMwYyLICV1Xhhs7NFYMT F9ZCFSgzDONAVEkfRBaG0bUffRC1e/Q2OHcqoBSF6YWr7Vff7Z/T+8u3erikVWrtB/rx +DSWlX5oNqEIWWEz7LIWFScGVcruTeVXuQzfzIWiPGr6HEsQxSWD0a4tivpkml7zewrV 6A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 303yunp0n5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12:10 +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 033M8WwP101895 for ; Fri, 3 Apr 2020 22:10:09 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 302g4y9g52-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:09 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MA8D3009857 for ; Fri, 3 Apr 2020 22:10:08 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:07 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 12/39] xfsprogs: factor out a xfs_attr_match helper Date: Fri, 3 Apr 2020 15:09:31 -0700 Message-Id: <20200403220958.4944-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473773 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 AA93B159A for ; Fri, 3 Apr 2020 22:12:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 89321207FF for ; Fri, 3 Apr 2020 22:12:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="oCanZ8Dp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726460AbgDCWMM (ORCPT ); Fri, 3 Apr 2020 18:12:12 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47038 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728288AbgDCWML (ORCPT ); Fri, 3 Apr 2020 18:12: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 033M9jCG082651 for ; Fri, 3 Apr 2020 22:12: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=5RjMmjJFI/zKbRhht1DkI51waVOQn4KKaQqO7hbSKaw=; b=oCanZ8Dp4JzFCX8MXd12MOzhmUkRIuPjSWzHbtviKo+5JvKPlVGL8kaW/YcjGQ7eY+O+ aqYYrCxh1SFI/TAtHiMejZPV4S95M5VQFJfxT+6SZp/O76ff+jU99yLX5CzotWHzDd17 QIbQQvcNIUmUCKbC+aVMRFjPAB0hjvq/7z2mDgt/kNZIKNXT2X3f1+rnGxYxj7uSLZsH ZknddedHj08Yj9lgrDX91mjd9OvRwiofSaUelP4Z2FyMBeKBXEqY6EngyoyjsGvWMseQ zwDfT6AkrfoQioYbIrLQrLdJF6yxERIbZ1J7tXbjJUdv3RBJ8dXPUQU++v5nE9F9Q4lo 6Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 303cevkdpd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12: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 033M8Np2062337 for ; Fri, 3 Apr 2020 22:10:10 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 302ga611w5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:10 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MA8aG015980 for ; Fri, 3 Apr 2020 22:10:08 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:08 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 13/39] xfsprogs: cleanup struct xfs_attr_list_context Date: Fri, 3 Apr 2020 15:09:32 -0700 Message-Id: <20200403220958.4944-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 suspectscore=1 mlxscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473771 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 3FA2192A for ; Fri, 3 Apr 2020 22:12:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1FB212082F for ; Fri, 3 Apr 2020 22:12:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="0EP6Mrem" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728501AbgDCWML (ORCPT ); Fri, 3 Apr 2020 18:12:11 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47032 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726460AbgDCWML (ORCPT ); Fri, 3 Apr 2020 18:12: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 033MA08h082820 for ; Fri, 3 Apr 2020 22:12: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=0EP6Mrempexbhy/vM7M44xmzznpW5BXTyJ2ASMtSB/QiajQ8qj+panHcC1Qjp2nu2Q+W m7rGKUYjH4lvCZuCo7i1EI0ydz0mowPLeq3MM4qt/6GLPzIEoah5G5BlH4v3bMWSVpq1 e5mnzhMDuVOS5kRtj3iy6pO4LemYv7Zr6HYjvQD1mD+03YKPn9iSjG4NRU32k7Kpdw0R s1PES9sFkJyb4wIaFZuqZ4jCN+3Nt9YM0E5TGO96dpE4yBzuToPpqOGxAoR8C65fZ02B opfD7tfXKFq9LElzRMSP9Tpqudrq7ESmcw4Cd//qpGPnhcTT8bNbDi2dQduJnEzpw3Y5 nQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 303cevkdpb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12: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 033M8NXW062341 for ; Fri, 3 Apr 2020 22:10:09 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 302ga611wg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:09 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MA8mV005646 for ; Fri, 3 Apr 2020 22:10:08 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:08 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 14/39] xfsprogs: remove the unused ATTR_ENTRY macro Date: Fri, 3 Apr 2020 15:09:33 -0700 Message-Id: <20200403220958.4944-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 suspectscore=1 mlxscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473775 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 AB35392A for ; Fri, 3 Apr 2020 22:12:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 89722207FF for ; Fri, 3 Apr 2020 22:12:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="UElmjsQZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728521AbgDCWMN (ORCPT ); Fri, 3 Apr 2020 18:12:13 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56168 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727950AbgDCWMM (ORCPT ); Fri, 3 Apr 2020 18:12: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 033M9e7l092971 for ; Fri, 3 Apr 2020 22:12: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=5AjYuJWFw789GLaUtg6Orr4j1918LrqXtTZ+VEY/uOA=; b=UElmjsQZx89nFoZmXp/jc77wLbmydXApPjL8zhwMljtaO5G+mVDoRhS5kcre5qAYDC5Z diQFPhFzGbEUKaWNu42VP3KrCAMJt5nSXjuke9xA0/gUEMt1YRAttwx4VrArzttcc7Hm QKz2Q0wJ4g1HjJ2ysulP9N8LcZKIawa366AvAposRsHMOk9oIL9VyTZkE4GfpDel0JtC rXWRMLaMH8eTTS5yveCNc8gCPf7aFjMdNCkXXKjiq9i3wI3xAESeLHyTt4H/OItb8XTj VCde8S2E+fgUqi9NlMr36h7dVEkgyxwYaA+o/4Ug4GQAu+T6LcljGS4igEp6ORBM5DJg fQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 303yunp0n6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12: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 033M7BZE171071 for ; Fri, 3 Apr 2020 22:10:10 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 302g2p2bue-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:10 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MA9RB005652 for ; Fri, 3 Apr 2020 22:10:09 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:08 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 15/39] xfsprogs: move the legacy xfs_attr_list to xfs_ioctl.c Date: Fri, 3 Apr 2020 15:09:34 -0700 Message-Id: <20200403220958.4944-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473727 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 0A3FB1392 for ; Fri, 3 Apr 2020 22:10:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCC30207FF for ; Fri, 3 Apr 2020 22:10:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Xfeu1VbY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728268AbgDCWKM (ORCPT ); Fri, 3 Apr 2020 18:10:12 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38434 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727867AbgDCWKM (ORCPT ); Fri, 3 Apr 2020 18:10:12 -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 033M8rlc018960 for ; Fri, 3 Apr 2020 22:10: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=Xfeu1VbYIrgwp19yHjlLjcKtFrd3wRVkOJgnqIet9qnHaJZgHk1cySGsQkrav2nExgcp OQ0OGDnt7gIzL8fUodlqv2x/OEIpnrOmrEAKsisg0o5Uk+Q7eWQbXqTbJYLkTOubGJqU hwjb79xwYrx1jtUFyefAcjJPE9YlTtXsTnNfTBpIcGgffvB4i0fhoc75iTGenZdKKYj+ mM6cIZR2T3l3K1nkA02+1S5kyNVUdiC5niEyfGjxr2h/qq3IBpvUginAlpLt9vzkCSEu B+IWTga86iiyox9vllj/aoZbmWRM9TxwR2fynWfcvkaLd1fl5lQDmSS6RjnMhtap4k+9 zQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 303aqj3w4m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M7KUK167836 for ; Fri, 3 Apr 2020 22:10:10 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 304sju4c7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:09 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MA9rE015984 for ; Fri, 3 Apr 2020 22:10:09 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:09 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 16/39] xfsprogs: rename xfs_attr_list_int to xfs_attr_list Date: Fri, 3 Apr 2020 15:09:35 -0700 Message-Id: <20200403220958.4944-17-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=1 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473729 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 9FCC2159A for ; Fri, 3 Apr 2020 22:10:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7EB112080C for ; Fri, 3 Apr 2020 22:10:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ZonJcOP9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728289AbgDCWKM (ORCPT ); Fri, 3 Apr 2020 18:10:12 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54122 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728254AbgDCWKM (ORCPT ); Fri, 3 Apr 2020 18:10: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 033MA8Wn093384 for ; Fri, 3 Apr 2020 22:10: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=ZonJcOP9HXh2NPcRYnq8PsHsvmQBRjGDrPMhCORRyxwToMJosApmmeoPJpxWvNfbZupc wq/DMlrtJ+PRzpVuXuaEwr9PDbOaWipbgjP0Irr2LUMhjBRBsZWFu2iyfMUVoXy1peO0 AfCdHcIC7qu2YGPq89Lre1wQVGA9vPENKQieRZtuj1JxNd/gGHJFvQvSQkFoIxLMRfl6 Q0LfUjD/LNjHzMKVCf/s6RPnFsyN9N9N90AZoEbjlQ8GiISUy4b90m+dfs8zF8I2WbpB NqifZQfbyo9dG3jd4KWOomcq732lxe8jZdBpD0Zg+TwKH6hNS5Ik1+f1fh1A4MYSS+qB 8Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 303yunp0fr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M8OQJ062412 for ; Fri, 3 Apr 2020 22:10:11 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 302ga611xu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:10 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MA9Tt028170 for ; Fri, 3 Apr 2020 22:10:10 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:09 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 17/39] xfsprogs: clean up the ATTR_REPLACE checks Date: Fri, 3 Apr 2020 15:09:36 -0700 Message-Id: <20200403220958.4944-18-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=840 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=893 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473777 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 C58D792A for ; Fri, 3 Apr 2020 22:12:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 914592080C for ; Fri, 3 Apr 2020 22:12:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="QFJ7oBw3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727950AbgDCWMO (ORCPT ); Fri, 3 Apr 2020 18:12:14 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40170 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728288AbgDCWMN (ORCPT ); Fri, 3 Apr 2020 18:12: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 033M918T019204 for ; Fri, 3 Apr 2020 22:12: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=ZDPXRgZ9A7iQXlXhuCaxvS3YhAhPrxol6aI/F4KGlKc=; b=QFJ7oBw34+5gLBjXWIvN2JM6AtPgMzsDIz2lbsxcIOTWJ6wxI1k5aBiYiKb4+FOwUv+M cfOFyvfH/XWmlgX6yH6xP3KPReMPcvjTcTD4arVmzd+FH0S0LIHHesCDLO2YQ1Ch3hx2 gnSqOqmf9UL0JaiHYWneXLuMAsPcQpREv7O+49sGZc0lu2BlFxMi1LqgXjJ0pOq67uyf MSBc0P01ecVqPujvF5IWFOaM+CX5FZEkNmAebpYmtR7zjkzQTcHOq4am9zNeU3e7nRAW HMnjDah5tHtMZJAekeoDjICqhcBbR/3vXiTU7snoxTM1AMlIhcdKy6+45mfQI7CN69Ct Lw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 303aqj3w9h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12: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 033M8WG7101934 for ; Fri, 3 Apr 2020 22:10:11 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 302g4y9g7s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:11 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MAA60028174 for ; Fri, 3 Apr 2020 22:10:10 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:10 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 18/39] xfsprogs: clean up the attr flag confusion Date: Fri, 3 Apr 2020 15:09:37 -0700 Message-Id: <20200403220958.4944-19-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473733 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 A2E621392 for ; Fri, 3 Apr 2020 22:10:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80C25207FF for ; Fri, 3 Apr 2020 22:10:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="buMx5DXX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727867AbgDCWKN (ORCPT ); Fri, 3 Apr 2020 18:10:13 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54128 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728146AbgDCWKN (ORCPT ); Fri, 3 Apr 2020 18:10: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 033MACJ5093412 for ; Fri, 3 Apr 2020 22:10: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=8witqzQLM6IHkx2UMA/PsasYekQfcSByJfT6ur5OnhY=; b=buMx5DXXINSFZom1r7nDwdDQls+B9u255JNWiL0Q/Kpp0uq7od3ghbfqenDBLMjkgKMQ /oCiHpblqKqdU3ZjxsH0c2EsMuVBGAngk97AWEaAX9D195qiQ2PEwqs+mks8oRS0s5Mj FGjUJjWEgqCO6p+Ff1fdD2jZhYQggePFpip/UnjyWrQUaWCQVPrpVj+cdFt670XJhIdU grOHaMsxB/4bTHOw4nI0DmQYZa5yQnTtVjXP3xiPdlSY1BjnhEFuGNT/2jIPhkc7FZ+5 hKPFBEf2z3k9+OLc0lIn2ux9lOiNfIAFcAFYvZORRNiTCZ4+LprOiv6VOLW7fOWeBhcC vQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 303yunp0ft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M7BUq171058 for ; Fri, 3 Apr 2020 22:10:11 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 302g2p2bw1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:11 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MAAkw009864 for ; Fri, 3 Apr 2020 22:10:10 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:10 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 19/39] xfsprogs: embedded the attrlist cursor into struct xfs_attr_list_context Date: Fri, 3 Apr 2020 15:09:38 -0700 Message-Id: <20200403220958.4944-20-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473731 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 0428C92A for ; Fri, 3 Apr 2020 22:10:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD1B82080C for ; Fri, 3 Apr 2020 22:10:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="0GoeX2Ts" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728337AbgDCWKN (ORCPT ); Fri, 3 Apr 2020 18:10:13 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45514 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727867AbgDCWKN (ORCPT ); Fri, 3 Apr 2020 18:10: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 033M9jH8082666 for ; Fri, 3 Apr 2020 22:10: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=AN02GFjiPXdLo1xqQ3stGZwA//jaL2jcZE12M4qxzwI=; b=0GoeX2Ts0YiDcPwz2IUWZ/PwwAuHkHb0KX3X0MLoNpEeGlC6I3v9mbSP8P3Ks55FJQCV iWuZHaYW1hGkd8IEF1ey+BRHAhCyI6D2bKj4TTbF0uY484tN0ViOU1tp3Nkx28T7B4vZ cJtSgFB9bdxvJad8ntRT+3jwNl0Hs22bNHsHb3cyuJ7C7Haqk69vYxhgsjgaMEB6qfGn 2+RacUfixNNLJuKB4LtuT33JougTR4ltoSryJ243R4Vi9S7jdAK/mfVwaxCksKttFFgD OglYs5ffUyqvkwwPpYXOmncTBVZ+uO09HYezZ0HfJ9hCj7WNGWubnYN4D6XejV2586El dA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 303cevkdhk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M8NFM062307 for ; Fri, 3 Apr 2020 22:10:11 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 302ga6120d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:11 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MABg0028177 for ; Fri, 3 Apr 2020 22:10:11 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:10 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 20/39] xfsprogs: Add xfs_has_attr and subroutines Date: Fri, 3 Apr 2020 15:09:39 -0700 Message-Id: <20200403220958.4944-21-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 suspectscore=4 mlxscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 --- libxfs/xfs_attr.c | 181 ++++++++++++++++++++++++++++++++----------------- libxfs/xfs_attr.h | 1 + libxfs/xfs_attr_leaf.c | 97 ++++++++++++++++++-------- libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 191 insertions(+), 91 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 810caff..728e7e8 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,57 @@ 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) { 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 == 0) { + if (statep != NULL) + *statep = state; + else + xfs_da_state_free(state); + return retval; + } + + xfs_da_state_free(state); + + return error; +} + /*======================================================================== * External routines when attribute list size > geo->blksize *========================================================================*/ @@ -751,17 +833,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 +1045,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 +1148,8 @@ xfs_attr_node_removename( error = 0; out: - xfs_da_state_free(state); + if (state) + xfs_da_state_free(state); return error; } @@ -1203,31 +1269,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 +1296,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 Fri Apr 3 22:09: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: 11473735 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 804DF1392 for ; Fri, 3 Apr 2020 22:10:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E4CB2080C for ; Fri, 3 Apr 2020 22:10:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="vGLO/V5c" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728359AbgDCWKO (ORCPT ); Fri, 3 Apr 2020 18:10:14 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54156 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728254AbgDCWKO (ORCPT ); Fri, 3 Apr 2020 18:10:14 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 033MACDE093419 for ; Fri, 3 Apr 2020 22:10: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=00/vlmuEFEKSmGGeRyvkg8Jkm/RxARXUnWcazcwxKyw=; b=vGLO/V5cqQjdRofpvlRq255xnwXHKIaIBHtrO/JT74vLFcyJwJK9VLnD5RcRBk5dRqrj W9mOYqsNRnpcDMuDIWMy31U7kUAE0WKlEfl+xG1RLVT+6TIo42xClVrc+wX7LVnEidTZ 51q4Tu4k/sMM02m1SZk4NnBGeQ3Be8ncBtzEKAvw6svRCFBWtR81KHN33o+alctV6UKF CNR5isJikwjdogtQhYHtVNpQZgEqxecanZsEBRRBrasP56FtKHqkl2ze7hz02nT5DbZh WdWEOb5bBDsUJeeYX8kN9h+X6ZfU7KLXYA+r3GmYYBy3Yjfd5Xmpmt5lcceNwByVRaK/ Aw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 303yunp0fv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M8OQL062412 for ; Fri, 3 Apr 2020 22:10:12 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 302ga6120u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:12 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MABeJ009871 for ; Fri, 3 Apr 2020 22:10:11 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:11 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 21/39] xfsprogs: Check for -ENOATTR or -EEXIST Date: Fri, 3 Apr 2020 15:09:40 -0700 Message-Id: <20200403220958.4944-22-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 --- libxfs/xfs_attr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 728e7e8..ea662d6 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -405,6 +405,17 @@ 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 +423,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 Fri Apr 3 22:09: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: 11473779 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 0B234159A for ; Fri, 3 Apr 2020 22:12:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE1E0208E4 for ; Fri, 3 Apr 2020 22:12:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="x7Vaz7V6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728288AbgDCWMO (ORCPT ); Fri, 3 Apr 2020 18:12:14 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47074 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728312AbgDCWMO (ORCPT ); Fri, 3 Apr 2020 18:12: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 033M9ovX082750 for ; Fri, 3 Apr 2020 22:12: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=+mNLHtPhQDaL8z3IC2A1ufREkBufQZ2Pv9i9ntSbsog=; b=x7Vaz7V6D89I/07X7s4Ho+aoBRbrMrO2EW33VFym5kjD/Tzp6L0V4mU5yYw5K8Ij4Rd3 7leFNigmC7xoDTy6cs9wGBG7T+DgCFgXLara96zsYAyVq1uwIMbimMIXwxPddHda4rE5 mRPYl3Yy/cSmI9ZOpzo7UV2QhRKgM0EHpjoFBVqQJ6dwHkmzYgfRWnu63K4gX4buxZm3 a97gRtKN7+x6glJhbqdxE3T+ScGFUBfizFbo/6AQQF479KsPm1eoK/grECPn/RZkOage R5c9beD+U2G/UEhiZLyGqWtO4unva2KUNWzR0ImFmmR4ZM1H62lHMQLI3JhWjVJRA2jo ow== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 303cevkdph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12: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 033M8Nmr062280 for ; Fri, 3 Apr 2020 22:10:12 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 302ga61214-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:12 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MABCG009926 for ; Fri, 3 Apr 2020 22:10:11 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:11 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 22/39] xfsprogs: Factor out new helper functions xfs_attr_rmtval_set Date: Fri, 3 Apr 2020 15:09:41 -0700 Message-Id: <20200403220958.4944-23-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 suspectscore=1 mlxscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473737 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 CED1592A for ; Fri, 3 Apr 2020 22:10:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AD152207FF for ; Fri, 3 Apr 2020 22:10:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="bSCWv7Oe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728254AbgDCWKP (ORCPT ); Fri, 3 Apr 2020 18:10:15 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38476 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728327AbgDCWKO (ORCPT ); Fri, 3 Apr 2020 18:10: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 033M8wjv019105 for ; Fri, 3 Apr 2020 22:10: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=e9vQLmm77idB+OGdPiuU9LDc/V4JlWhAnJDwbVVGPtw=; b=bSCWv7OeKEWXmnsNndTKnm2ETxcgOLm9npZIEZ5avoPMbirUSOjxhALiGlfRhSKW9eaz wqD3uRYnF9dcVVzrlQnbD9a0Cki0tp2YWD5u2auWembl9vrQyd/XBGSzE0mIfsqKFI0U /g780i17Liybi3aLqK18Bem/YQGzmB2+f47HvmdgiKtjWVr5hoe/KWxw+lfqyQdKGye9 8EwiNAPUqh18i26iY+VRdgAD7+3Do8GSj6D4JsCqHAZcx4r2RJOc+StzcLmhjGyDdQEI C6TLJLJcj3ikcaHWYSNWIw8jgvifXQGh0acdFe8+Mw+/bIaP290Q527S7YdgnREVBQ2e dw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 303aqj3w4u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M8O5Q062389 for ; Fri, 3 Apr 2020 22:10:12 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 302ga6121h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:12 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MAC6K009937 for ; Fri, 3 Apr 2020 22:10:12 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:11 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 23/39] xfsprogs: Pull up trans handling in xfs_attr3_leaf_flipflags Date: Fri, 3 Apr 2020 15:09:42 -0700 Message-Id: <20200403220958.4944-24-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 ea662d6..f718763 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -625,6 +625,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 @@ -972,6 +979,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 Fri Apr 3 22:09: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: 11473783 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 8A7131392 for ; Fri, 3 Apr 2020 22:12:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F042207FF for ; Fri, 3 Apr 2020 22:12:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="AIL5ozbX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728554AbgDCWMQ (ORCPT ); Fri, 3 Apr 2020 18:12:16 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40198 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728532AbgDCWMQ (ORCPT ); Fri, 3 Apr 2020 18:12: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 033M8xHN019125 for ; Fri, 3 Apr 2020 22:12: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=zmuzh2inGBq5G2ZloZ5iEi582INwLHVFxqx+p4YCEks=; b=AIL5ozbXpzdUX+vn+7yfYPOEsWGc/8T4xZc8wdTgOp21+IwlxEZQJM8Jw2lUzJkx8E/Y YeU3ys5ONaU16C1Kd8+MYvaoLV4kSUHciFeYEn60rGpjzofbIvDibRHg2muj6q0b5hDy 9st6x09Bn0KmRlSCgVMhf169bhNwSCrC4lZwbCQadfJ8g12iMtSa5MAZHCkep48rb/9k 1e1K70Kpz+QEbnqX9NZGzEWwX6/OJARVWWl2W62UDMUSrCVOkxiaxM04ZawwHefL/L6n /Q9E/P+ldT0APl/LfItTLLJiQvPIDzUZuEsCpxU1BPpbkqDFcZYBLe/pXI6wmNoy9Heb WA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 303aqj3w9n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12: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 033M7Kde167866 for ; Fri, 3 Apr 2020 22:10:14 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 304sju4cc3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:14 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MACqQ009941 for ; Fri, 3 Apr 2020 22:10:12 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:12 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 24/39] xfsprogs: Split apart xfs_attr_leaf_addname Date: Fri, 3 Apr 2020 15:09:43 -0700 Message-Id: <20200403220958.4944-25-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=1 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 f718763..a5fc323 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; } @@ -510,20 +530,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 @@ -565,31 +586,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 @@ -684,9 +713,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 Fri Apr 3 22:09: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: 11473739 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 2CBCF1874 for ; Fri, 3 Apr 2020 22:10:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B46F2080C for ; Fri, 3 Apr 2020 22:10:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="oZEOFUtH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728327AbgDCWKP (ORCPT ); Fri, 3 Apr 2020 18:10:15 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45522 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728146AbgDCWKP (ORCPT ); Fri, 3 Apr 2020 18:10: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 033M9xoN082813 for ; Fri, 3 Apr 2020 22:10: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=bTejOhKZqVKh6SQWOPr2NLDulRWOGtwTu/mBk+IYqL8=; b=oZEOFUtHMz84TJgF3jREatYoZ7oFmpLzhwH5DDq0pWrkYHP/03Dl10GPTzl1HuVHFJWa 5knFLtwxj1NrzUtgpKaEW0SPHGxR1P/CTbMDUuhrwONHCYv21TUMlrDTZtXv3fmcOhwI MlAthayPAipgd0yvpyMlAEc1y/W2d8rM+I42PTyKKFkTY8R7VckN0nLkQZLyezz6TaX0 9uhrjdRqUOVTtQ7o5LYyTwtAUV1LEqkw8037PQLaCgKvwa1sz/gE/kjMfI9GJLZBAVco uBDkDz/Pr2GCx+PSIRD4xoy4oC80UB6gI878Tb2ON0TTH1sLZ+h5y/UrCV7t4+NUswpl 6A== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 303cevkdhp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:13 +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 033M7AgT170948 for ; Fri, 3 Apr 2020 22:10:13 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 302g2p2by1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:13 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MACcs028182 for ; Fri, 3 Apr 2020 22:10:12 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:12 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 25/39] xfsprogs: Refactor xfs_attr_try_sf_addname Date: Fri, 3 Apr 2020 15:09:44 -0700 Message-Id: <20200403220958.4944-26-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 suspectscore=1 mlxscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 a5fc323..e020bad 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 Fri Apr 3 22:09: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: 11473781 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 C9F5E1392 for ; Fri, 3 Apr 2020 22:12:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A8FB22080C for ; Fri, 3 Apr 2020 22:12:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="snd0qbhD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728552AbgDCWMQ (ORCPT ); Fri, 3 Apr 2020 18:12:16 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47078 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728312AbgDCWMP (ORCPT ); Fri, 3 Apr 2020 18:12: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 033M9jHC082666 for ; Fri, 3 Apr 2020 22:12: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=8B6P6XGGjgxKb4BofIYp2HSsl/gTRFxRt1GEhMzteLU=; b=snd0qbhDnALsTB7O+9DuRxZwIcUkhOejFflczPUQehcf5Y7VKJGUjuvRaXwc3i+afOw7 8r+j0vJqpneFI19fFqOAfH+TtNHbdehi/U+1ce2/58Nc0vac5ZNBaUgYw3tZpdRi0FAH kO/EfsxEI3o0oE+GTL31dsv8KbPOjMAOikN68ZGhHhir4oGSk5cceAc+v+/DjS+QVlWy etDZh7U686GvLQgUw199dx1vc/YrsJUmtHHAQhlksogUswkyLHLwIoavB7ax++Ymr2YD h1I18JG0eKNVRuVKCZ5Zg0Zp3Hd5GKefdRSkxskE2Lc+9eaEUpARoCtHC5fCaSuZ6TMM fg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 303cevkdpm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12: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 033M79tU170945 for ; Fri, 3 Apr 2020 22:10:13 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 302g2p2by9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:13 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MACx2005661 for ; Fri, 3 Apr 2020 22:10:12 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:12 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 26/39] xfsprogs: Pull up trans roll from xfs_attr3_leaf_setflag Date: Fri, 3 Apr 2020 15:09:45 -0700 Message-Id: <20200403220958.4944-27-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 suspectscore=1 mlxscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 e020bad..6804b2b 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1135,6 +1135,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 Fri Apr 3 22:09: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: 11473743 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 D5E87159A for ; Fri, 3 Apr 2020 22:10:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B4E94207FF for ; Fri, 3 Apr 2020 22:10:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="XhYCaGVS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728375AbgDCWKQ (ORCPT ); Fri, 3 Apr 2020 18:10:16 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45534 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728382AbgDCWKQ (ORCPT ); Fri, 3 Apr 2020 18:10:16 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 033M9jX8082648 for ; Fri, 3 Apr 2020 22:10: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=Q+KkLHzOQ9ZI2yAe1NyYt3D/QjTqiCxny0IUQn6DIVY=; b=XhYCaGVS5vCtXcl4Pmj9XeITMA5hqd7HopmDCbUDjbI7xvD+BIfeYVnrgRTm+tWVXZEY e4uXxwKGhzzpG9zC5VrDP3gmYHi6di75unSOb1QnWeuuas8+gy1fbiRgnFGGZ3RVhgQn P0a71T0Tgyzfe1fJeLq6dB8ZtGbUvhltRpRDT2Mu7ZSb9MJE4XmV8qZy6GEI8l/9Z0Ld kyXRUhyk9d9nMf6dBIQKZ5aPIugIqW6huacNKDK2nFFO2wjL7+z0PRqDeXTkC4SndabD PW0omlgI5X/ky3lXpWNR8dfYoMpTKoZ81puwd/IagvfwoT7xwXTLBH7pdLJImwwrpY1Y rg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 303cevkdhq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M7KtW167903 for ; Fri, 3 Apr 2020 22:10:13 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 304sju4cd5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:13 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MAD5m015995 for ; Fri, 3 Apr 2020 22:10:13 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:13 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 27/39] xfsprogs: Factor out xfs_attr_rmtval_invalidate Date: Fri, 3 Apr 2020 15:09:46 -0700 Message-Id: <20200403220958.4944-28-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=1 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 suspectscore=1 mlxscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 Fri Apr 3 22:09: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: 11473741 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 5B08792A for ; Fri, 3 Apr 2020 22:10:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3838B2078C for ; Fri, 3 Apr 2020 22:10:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="KNd3gUkR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728416AbgDCWKQ (ORCPT ); Fri, 3 Apr 2020 18:10:16 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54182 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728375AbgDCWKQ (ORCPT ); Fri, 3 Apr 2020 18:10: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 033M9e5S092993 for ; Fri, 3 Apr 2020 22:10: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=6IXoOCDf7Nxkge1APYfrJZY7ZqHHD+mkVKobxWajD2Y=; b=KNd3gUkRmi1DTpsYWyoth8BJ0VUbxSkxwkoUIsHsPE645JQiYCm3d5wq/WvQqjmOvqEj +KoaQxYlZxAwSb5nhKs34XRnDRMtlkkdhRudj0VuVQDdVsd66sXRcvY/JvVUK90t72hl ZUaj7WgoS3TGAGcAFWsXGl44LdkcCGJXTE9ljqEKihd9bCYx3yXEKj9ouaqgr/KIDvQP kf0QcYucnlRxBZR2CWJ2hfGHbmc1qFvjg242QR+I16Q3+pfVP2Pe4MWfBoyBhr8uGmq3 Ak0yTBcTAra+oX8OacHvG+McQfA+8vYwm+wdbzIEd2vwFrvE7bQpRBTowSGtnn1vGUAw 5Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 303yunp0g0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M7JKO167759 for ; Fri, 3 Apr 2020 22:10:14 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 304sju4cdr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:14 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MADrb005670 for ; Fri, 3 Apr 2020 22:10:13 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:13 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 28/39] xfsprogs: Pull up trans roll in xfs_attr3_leaf_clearflag Date: Fri, 3 Apr 2020 15:09:47 -0700 Message-Id: <20200403220958.4944-29-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=1 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 6804b2b..3bb3b19 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -711,6 +711,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; } @@ -1076,6 +1084,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 Fri Apr 3 22:09: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: 11473745 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 0C2D71392 for ; Fri, 3 Apr 2020 22:10:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF018207FF for ; Fri, 3 Apr 2020 22:10:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="XRkROx9c" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727923AbgDCWKR (ORCPT ); Fri, 3 Apr 2020 18:10:17 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54204 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728146AbgDCWKQ (ORCPT ); Fri, 3 Apr 2020 18:10: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 033M9wLA093185 for ; Fri, 3 Apr 2020 22:10: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=QMpsyriJn6fIbDAOw+qIvsfOXoLOnzTP/iJO+ABARuw=; b=XRkROx9cSxOQFu2nZpJWOdHFHdRpzosW88Tx1bV7ZQo8zQxa7NPIvGomwtPwMmQApt8Y CTkPmDBO4joa1V82rHE7pWxf1LZKPCiVKRv285lV7aCZOdxuHUclIXy5KsJKBDOrK/5/ fuqCtpjirFWa+BfOl5hrFqxR9TUlk3lrhPPFB+r6iW1KGp53fclOGyi9H0sy6WPttwRH Xov4qz/sAU9oDdcuQjBMpPQJEiZF7a8pYDsJU3Amyh9PeEk+uC21sSKO3oSouBcb6L06 PaBcLcydPGBFrq3kmdaRVPnZYLXfQHJk7de42zNJoKgtYT0lK1noa3T6SpW+BDisx3m+ pw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 303yunp0g2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M7JNw167755 for ; Fri, 3 Apr 2020 22:10:15 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 304sju4cej-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:15 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MAEDa009983 for ; Fri, 3 Apr 2020 22:10:14 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:13 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 29/39] xfsprogs: Add helper function __xfs_attr_rmtval_remove Date: Fri, 3 Apr 2020 15:09:48 -0700 Message-Id: <20200403220958.4944-30-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=1 mlxlogscore=864 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=920 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 | 25 +++++++++++++++++++++++++ libxfs/xfs_attr_remote.h | 1 + 2 files changed, 26 insertions(+) diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index e09c1b6..a9cd28d 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -710,3 +710,28 @@ xfs_attr_rmtval_remove( } 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; + + if (!done) + return -EAGAIN; + + return 0; +} 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 Fri Apr 3 22:09: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: 11473785 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 ECE5A92A for ; Fri, 3 Apr 2020 22:12:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC0812080C for ; Fri, 3 Apr 2020 22:12:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="bNvil6y3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728532AbgDCWMR (ORCPT ); Fri, 3 Apr 2020 18:12:17 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40202 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728535AbgDCWMR (ORCPT ); Fri, 3 Apr 2020 18:12: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 033M8v0J019076 for ; Fri, 3 Apr 2020 22:12: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=Bf1f8auV5HBWJn4a79Zi9c0sTwImMh5I+FbFI/oRaA0=; b=bNvil6y3ks+W+EZ/l4tOiXcVsRjV6GpeCAhiWtaNXcfLSO/CAhQ4Q97gPN4YPj1Nxzfk TpQ06ZaOsNnGdwZH0TcnXMBta0oSQpF4cIvxHFuz1FP7tZ2yvpaVSAKD2JGfoda4Psv8 PjOosDuBgFp4I73sNiZ6NGnNsZFC2LSmWPNSBAYobOP7k+JLvyE9716E6UWmZaiHtWR7 UG++GIi8PKIpoUJqYBMkDvwa2f6+cZr7GSSpkD8k4hSKLHqkFHFSKPBnJEZCIv6JZYrR 7MooU0w7mQg+NSRWLTyg0loNkuAb0vSRTnY8z1BOOI06a1USjwoixostpZHyU9m8se6I rQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 303aqj3w9s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12: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 033M8OAO062423 for ; Fri, 3 Apr 2020 22:10:15 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 302ga6123d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:15 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MAELg005675 for ; Fri, 3 Apr 2020 22:10:14 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:14 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 30/39] xfsprogs: Add helper function xfs_attr_node_shrink Date: Fri, 3 Apr 2020 15:09:49 -0700 Message-Id: <20200403220958.4944-31-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=4 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 | 67 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 3bb3b19..301487f 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1104,6 +1104,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 @@ -1116,8 +1155,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); @@ -1198,31 +1236,10 @@ 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 (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) + error = xfs_attr_node_shrink(args, state); - 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; - out: if (state) xfs_da_state_free(state); From patchwork Fri Apr 3 22:09: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: 11473787 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 8F3601392 for ; Fri, 3 Apr 2020 22:12:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6E6662080C for ; Fri, 3 Apr 2020 22:12:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="gl9dQkeP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728535AbgDCWMR (ORCPT ); Fri, 3 Apr 2020 18:12:17 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56242 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728312AbgDCWMR (ORCPT ); Fri, 3 Apr 2020 18:12: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 033M9ier093086 for ; Fri, 3 Apr 2020 22:12: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=2JHIIucI27gnbie3YTvrBuClCuP5p/nt1K6vqjeDhUY=; b=gl9dQkePjzqTdMDw2DF4fYdvAP65nyPy4onURbBUt8DNaRoK2mJzfmsmmxzHs+XuLVBi Fsazha9XWOurB/8gjZDJ1JRiU0PMFqix71gWryewiD4LJEfMq1o0n1+DsnF4EGF0kQNH bLtDG0HZ8e34eI9O+dhdmi9Ym0otBe+A0hpf2J3KjC8m9SyEOsmKssjDcQu+M8tWfv6E v4EYb/v742n7yBKptJ20Ov0hukc9uhR3pkoUNpIDJAVP7ojqXCl80KdqBthbdVJH4LzR 6ZxEymABhj6C+tIJf5Z1OwuIC37pCNbu/3sr2pwhpw8TPD6NQUsgMx8UGB5it7nkQrKf Nw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 303yunp0nh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:12: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 033M8NAC062295 for ; Fri, 3 Apr 2020 22:10:15 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 302ga6123w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:15 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MAEUB009986 for ; Fri, 3 Apr 2020 22:10:14 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:14 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 31/39] xfsprogs: Removed unneeded xfs_trans_roll_inode calls Date: Fri, 3 Apr 2020 15:09:50 -0700 Message-Id: <20200403220958.4944-32-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 in the *_addname 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 not an incore change. Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 301487f..5cca2c2 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -701,11 +701,6 @@ xfs_attr_leaf_addname( 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. @@ -713,12 +708,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; } @@ -1070,13 +1059,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. @@ -1084,14 +1066,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; @@ -1190,10 +1164,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_remove(args); if (error) goto out; From patchwork Fri Apr 3 22:09: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: 11473753 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 94D78159A for ; Fri, 3 Apr 2020 22:10:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69D982080C for ; Fri, 3 Apr 2020 22:10:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="NG0osAV6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728456AbgDCWKT (ORCPT ); Fri, 3 Apr 2020 18:10:19 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45572 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728146AbgDCWKS (ORCPT ); Fri, 3 Apr 2020 18:10:18 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 033M9hkC082617 for ; Fri, 3 Apr 2020 22:10: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=18qPaK/I41bdYU32Ah32spUw/hkfTAW5rwSkwW1Mjbk=; b=NG0osAV6Wy7igJjULlehifYlJIxaaXJRPxnfKJbXjoza+9esvDHP5FSUE/WY9YXwUcET IGWY1RgWdCj0ZEChG2XwykNzTWrm3uA2AnCrdGy8tndx1WM2VL9jJ0dJx09dmvZ9Gdgx pCqOOd2bXzAntkKGd4jRDGw6F4+vQNSVD4JtURtvf6QzHL/C0iSUMTKjNXCzBcR0SDVJ arFD/+/5oP9sp1DwzQoERs6/CyspKlGOvuuwPcdv3b98biUviuXbPqnPrET/ypdcWkSt PoFr9Sz5kpOsDLlvHbRnF4/VO5dTpgrazXbLEpvX99br+yd6QMIz9LOcoiHB7MSclih3 dA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 303cevkdhv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:17 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 033M7Kow167892 for ; Fri, 3 Apr 2020 22:10:16 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 304sju4cg1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:16 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MAFlj028189 for ; Fri, 3 Apr 2020 22:10:15 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:14 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 32/39] xfsprogs: Add helpers xfs_attr_is_shortform and xfs_attr_set_shortform Date: Fri, 3 Apr 2020 15:09:51 -0700 Message-Id: <20200403220958.4944-33-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=1 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 suspectscore=1 mlxscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 --- 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 5cca2c2..4dff0a5 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 the tree 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)) { - - /* - * 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; + if (xfs_attr_is_shortform(dp)) { /* - * 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. + * 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. */ - 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 Fri Apr 3 22:09: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: 11473747 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 1E85892A for ; Fri, 3 Apr 2020 22:10:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0D1D207FF for ; Fri, 3 Apr 2020 22:10:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="x9X4nRDT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728460AbgDCWKS (ORCPT ); Fri, 3 Apr 2020 18:10:18 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38514 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728382AbgDCWKS (ORCPT ); Fri, 3 Apr 2020 18:10:18 -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 033M96BE019227 for ; Fri, 3 Apr 2020 22:10: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=PDHnAqSbBMbDZYtcR336Ii98s8798ptbXFUy7mPtNyY=; b=x9X4nRDT8H5yBO/Lt+LwAAnwm3yoU2oCjCEmwiqna1F1qNMb3J8ul1cDpq8tLc3XaNX5 LCvyjl4RLi6fnHHz7suo8IyCgwOenRafHAsZo/TNzXOlbMMAe1CreeGPA0OR/rdHsdbh lY4QQMhUVU2Anr1N9moyo9stW7Mfy89qeCBaEJl7517kQMfVXSDjHXkMCeWM0/Xj4oPx 054W2qGIl2mVQWNcubNVhEXx/X6QxUdx8lcbZ6yTYMnzB0gEU9r/551C/G7RR7ERNPC1 pd5wczCSkFSaYfrVrV99OpclFk6tElP2NsH0cjGDzzRJQxXQR+IKwwbrDwUG5MFn/mvd WQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 303aqj3w4w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:16 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 033M7A9J171012 for ; Fri, 3 Apr 2020 22:10:16 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 302g2p2c1r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:16 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 033MAFZK015998 for ; Fri, 3 Apr 2020 22:10:15 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:15 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 33/39] xfsprogs: Add helper function xfs_attr_leaf_mark_incomplete Date: Fri, 3 Apr 2020 15:09:52 -0700 Message-Id: <20200403220958.4944-34-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 --- libxfs/xfs_attr.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 4dff0a5..42a435a 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1154,6 +1154,36 @@ 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 + */ + error = xfs_attr3_leaf_setflag(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 @@ -1184,20 +1214,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 Fri Apr 3 22:09: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: 11473749 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 70F1B159A for ; Fri, 3 Apr 2020 22:10:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4EF7C2080C for ; Fri, 3 Apr 2020 22:10:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="GVB1pr0U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728382AbgDCWKS (ORCPT ); Fri, 3 Apr 2020 18:10:18 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38516 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728432AbgDCWKS (ORCPT ); Fri, 3 Apr 2020 18:10:18 -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 033M8su0018974 for ; Fri, 3 Apr 2020 22:10: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=A83UBX1zwm0wdp+dAu5y5SlW6lrX67RzwWj+vGCIedA=; b=GVB1pr0UCOY79IVSvB2vmvcexD4puwKYIVc8xdFlMRNTckD4sI0TjZDiq8ZTWZmsimEu fyEpHw428blJIwIR4VrGX3SO0Y4izCVlVzenhNwt9WzZ5iUtqsnPl8ywyxVKpX49TIhs xftE9A1Rzqmx/anVUlQ0EcBx0tHqMHlojnmqj3N/M4S5Z4zRXMT76VqljHGDJZh79N8o T01hdTAUK6/wLJYjGIzHbWgPvImyP2X638J8QVAa25jAc7/ecDWd/TfkhHbwmNyMhZyz jHDP5W7K2qH+MMH/0U37wWPnKB/ouHY1YV6BsD+P60ZAuRIqpHA6OziQduNgyQ7E1TtC UQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 303aqj3w4x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10: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 033M8Oqh062433 for ; Fri, 3 Apr 2020 22:10:16 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 302ga6124w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:16 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MAFsg009990 for ; Fri, 3 Apr 2020 22:10:15 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:15 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 34/39] xfsprogs: Add remote block helper functions Date: Fri, 3 Apr 2020 15:09:53 -0700 Message-Id: <20200403220958.4944-35-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 --- 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 42a435a..9e70f16 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -566,6 +566,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 * @@ -600,11 +624,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 @@ -703,11 +723,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_remove(args); if (error) @@ -935,11 +952,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 @@ -1051,11 +1064,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_remove(args); if (error) From patchwork Fri Apr 3 22:09: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: 11473757 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 3DF5E1874 for ; Fri, 3 Apr 2020 22:10:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B8182080C for ; Fri, 3 Apr 2020 22:10:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="uZZRfKJd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728459AbgDCWKU (ORCPT ); Fri, 3 Apr 2020 18:10:20 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45594 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728432AbgDCWKU (ORCPT ); Fri, 3 Apr 2020 18:10:20 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 033M9xoO082813 for ; Fri, 3 Apr 2020 22:10: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=EkkPGFrQYX+QAQLX3cAz47D/ltyMmHBj0OjPRZ2kiVA=; b=uZZRfKJd5lBzu/0hv3o5ZL9x81ohmbVdR/EgNQKyJO3jXR3jMr+pVdTITRPBfBnSkIr5 HC7yXbEXY46W68MbBg2tqoD1sTyLwU/VK3H8cUtg7WH0r9r0OAvdes/6FHuDiriBA0r7 bb3cs9g4cPoDhu72SdWAG6hIGXmU5qvVO/dLKXWI77wz83/nRLPC52TpKyxJah2AJZUN MP2wdT0XjamEFj327SGeHXeTr3zkVNDWQv5yAG93kv+j+FrsXnQwHQRteqb+FT6oMDeI JK8Gsz8MoSY+s6kutMFc3XogbE9FocBVbbKCAv+7zCLvmugU+XFCVOI+hpTQSavMzYG3 Aw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 303cevkdhx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:18 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 033M7BLP171131 for ; Fri, 3 Apr 2020 22:10:18 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 302g2p2c2h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:18 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MAGbY009993 for ; Fri, 3 Apr 2020 22:10:16 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:15 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 35/39] xfsprogs: Add helper function xfs_attr_node_removename_setup Date: Fri, 3 Apr 2020 15:09:54 -0700 Message-Id: <20200403220958.4944-36-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=992 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 adultscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 suspectscore=1 mlxscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 --- libxfs/xfs_attr.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 9e70f16..c844f8f 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1194,6 +1194,35 @@ 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; + } + + return 0; +} + +/* * Remove a name from a B-tree attribute list. * * This will involve walking down the Btree, and may involve joining @@ -1211,8 +1240,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; /* @@ -1220,14 +1249,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_remove(args); if (error) goto out; From patchwork Fri Apr 3 22:09: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: 11473751 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 1D1D71392 for ; Fri, 3 Apr 2020 22:10:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0AE72080C for ; Fri, 3 Apr 2020 22:10:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ndjFDkTq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728482AbgDCWKT (ORCPT ); Fri, 3 Apr 2020 18:10:19 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54222 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728456AbgDCWKS (ORCPT ); Fri, 3 Apr 2020 18:10:18 -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 033MACJ6093412 for ; Fri, 3 Apr 2020 22:10: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=DjIwqtkQW7Y5bwaT/46wMGz5Ns3szy1K0MYSt6b2BtU=; b=ndjFDkTquTTOyzEPyXXW0aNNo4ousZ4nYS47Iccch+lXj/9r8dCOmXvxanYfZri8o1/O /9dUs4zW+90q+mrETczVTMLT9xkuQTL3MaRHMOiSYsl/N6jzONDhXyIDgxi06IUrryKj FtYtPz4HXHYRnxTiM2gO/9LvKKwKGPvMTx1m/Ccb5QfebwW4PukgLj0B6bqHcBbP0oIt tgUavU5c7Q28HpuCgV6gpGKjr8pCiGypoNMsmVJmO8ko+x6jDb1VrirnKRGZXUe/ob8A Wfsa86NXIdRH94ikKfRP7SbDfFKdJk94fi3rOdsXFLP22oSkOFMa6OSUjf3a2FEIdXoE wQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 303yunp0g6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:17 +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 033M8Wxb101918 for ; Fri, 3 Apr 2020 22:10:16 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 302g4y9gf1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:16 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MAGVo005682 for ; Fri, 3 Apr 2020 22:10:16 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:16 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 36/39] xfsprogs: Add helper function xfs_attr_node_removename_rmt Date: Fri, 3 Apr 2020 15:09:55 -0700 Message-Id: <20200403220958.4944-37-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 malwarescore=0 mlxlogscore=934 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 --- libxfs/xfs_attr.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index c844f8f..fa706f5 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1222,6 +1222,28 @@ 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. + */ + error = xfs_attr_refillstate(state); + if (error) + return error; + + return 0; +} + /* * Remove a name from a B-tree attribute list. * @@ -1250,15 +1272,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 Fri Apr 3 22:09:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11473755 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 DA65A92A for ; Fri, 3 Apr 2020 22:10:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AEA6E2080C for ; Fri, 3 Apr 2020 22:10:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="yeu6zwh8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728146AbgDCWKU (ORCPT ); Fri, 3 Apr 2020 18:10:20 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38530 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728459AbgDCWKT (ORCPT ); Fri, 3 Apr 2020 18:10:19 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 033M8sOn018993 for ; Fri, 3 Apr 2020 22:10: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=+KghIDWQ0eS7HRGkSxpPq4bx6ikb24ilRDOe5l+ziHk=; b=yeu6zwh8EtI24CM+BoFIaVNx1P7Ma5S7CSZ+KCyOSwTYcNoCjYFYIZRQ5sa3pm+8hFml kKIoOIP13E5Khx/9Cz+qT+oJ67HhAAmT07UcXxAf5444IARj3EErbsfA1T3vU0b+aXzs ewTKTEHxu/8RlLtf5it179juMcOJ2CM6IRKtMIi8Ca2KDGKbvu3jbKjCPgQgtLSsc5nL r/e0R/fG9FQ0x6dqNVmXxw/XYn/+G5kJf3ceAqwgZvq+NVhXZwEn60JrP5qJvmm5bqHO gpBbxETrORcjbs6Hk1MqcpgaqXjr4hW0oAC7sYkrLJcKPqrGI7vG73lrKSwC/JWWwZ6N fQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 303aqj3w52-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:18 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 033M7Abi170974 for ; Fri, 3 Apr 2020 22:10:17 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 302g2p2c2u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:17 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MAG23005686 for ; Fri, 3 Apr 2020 22:10:16 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:16 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 37/39] xfsprogs: Add delay ready attr remove routines Date: Fri, 3 Apr 2020 15:09:56 -0700 Message-Id: <20200403220958.4944-38-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=1 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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. Calls to xfs_attr_rmtval_remove are replaced with the delay ready counter parts: xfs_attr_rmtval_invalidate (appearing in the setup helper) and then __xfs_attr_rmtval_remove. We will rename __xfs_attr_rmtval_remove back to xfs_attr_rmtval_remove when we are done. 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_DAS_RMTVAL_REMOVE ─┤ (subroutine state) │ └─>xfs_attr_node_removename() │ v need to remove ┌─n── rmt blocks? │ │ │ y │ │ │ v │ ┌─>XFS_DAS_RMTVAL_REMOVE │ │ │ │ │ v │ └──y── more blks │ to remove? │ │ │ n │ │ │ v │ need to └─────> shrink tree? ─n─┐ │ │ y │ │ │ v │ XFS_DAS_RM_SHRINK │ │ │ v │ done <─────┘ Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 168 ++++++++++++++++++++++++++++++++++++++++++------------ libxfs/xfs_attr.h | 38 ++++++++++++ 2 files changed, 168 insertions(+), 38 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index fa706f5..59d46a4 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -46,7 +46,7 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args); */ STATIC int xfs_attr_leaf_get(xfs_da_args_t *args); STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args); -STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); +STATIC int xfs_attr_leaf_removename(struct xfs_delattr_context *dac); STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); /* @@ -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); +STATIC 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) @@ -357,20 +366,66 @@ xfs_has_attr( */ int xfs_attr_remove_args( - struct xfs_da_args *args) + struct xfs_da_args *args) { + 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; + + if (dac.flags & XFS_DAC_DEFER_FINISH) { + dac.flags &= ~XFS_DAC_DEFER_FINISH; + error = xfs_defer_finish(&args->trans); + 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; int error; + /* State machine switch */ + switch (dac->dela_state) { + case XFS_DAS_RM_SHRINK: + case XFS_DAS_RMTVAL_REMOVE: + return xfs_attr_node_removename(dac); + default: + break; + } + if (!xfs_inode_hasattr(dp)) { error = -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); } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_removename(args); + error = xfs_attr_leaf_removename(dac); } else { - error = xfs_attr_node_removename(args); + error = xfs_attr_node_removename(dac); } return error; @@ -795,11 +850,12 @@ xfs_attr_leaf_hasname( */ STATIC int xfs_attr_leaf_removename( - struct xfs_da_args *args) + struct xfs_delattr_context *dac) { - struct xfs_inode *dp; - struct xfs_buf *bp; - int error, forkoff; + struct xfs_da_args *args = dac->da_args; + struct xfs_inode *dp; + struct xfs_buf *bp; + int error, forkoff; trace_xfs_attr_leaf_removename(args); @@ -826,9 +882,8 @@ 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; + + dac->flags |= XFS_DAC_DEFER_FINISH; } return 0; } @@ -1129,12 +1184,13 @@ out: */ STATIC int xfs_attr_node_shrink( - struct xfs_da_args *args, - struct xfs_da_state *state) + struct xfs_delattr_context *dac, + struct xfs_da_state *state) { - struct xfs_inode *dp = args->dp; - int error, forkoff; - struct xfs_buf *bp; + struct xfs_da_args *args = dac->da_args; + 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. @@ -1154,9 +1210,7 @@ xfs_attr_node_shrink( if (error) return error; - error = xfs_defer_finish(&args->trans); - if (error) - return error; + dac->flags |= XFS_DAC_DEFER_FINISH; } else xfs_trans_brelse(args->trans, bp); @@ -1195,13 +1249,15 @@ 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) { + struct xfs_da_args *args = dac->da_args; int error; struct xfs_da_state_blk *blk; @@ -1213,10 +1269,21 @@ 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) return error; + + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; } return 0; @@ -1229,7 +1296,10 @@ xfs_attr_node_removename_rmt ( { 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(args); if (error) return error; @@ -1250,19 +1320,37 @@ 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_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; + + /* State machine switch */ + switch (dac->dela_state) { + case XFS_DAS_RMTVAL_REMOVE: + goto das_rmtval_remove; + case XFS_DAS_RM_SHRINK: + goto das_rm_shrink; + default: + break; + } - error = xfs_attr_node_removename_setup(args, &state); + error = xfs_attr_node_removename_setup(dac, &state); if (error) goto out; @@ -1271,10 +1359,16 @@ 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. */ + +das_rmtval_remove: + if (args->rmtblkno > 0) { error = xfs_attr_node_removename_rmt(args, state); - if (error) - goto out; + if (error) { + if (error == -EAGAIN) + dac->dela_state = XFS_DAS_RMTVAL_REMOVE; + return error; + } } /* @@ -1292,22 +1386,20 @@ 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: + dac->dela_state = XFS_DAS_RM_SHRINK; + /* * If the result is small enough, push it all into the inode. */ if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) - error = xfs_attr_node_shrink(args, state); + error = xfs_attr_node_shrink(dac, state); error = 0; out: diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 66575b8..0e8ae1a 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -74,6 +74,43 @@ struct xfs_attr_list_context { }; +/* + * ======================================================================== + * Structure used to pass context around among the delayed routines. + * ======================================================================== + */ + +/* + * 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 */ + XFS_DAS_RMTVAL_REMOVE, /* We are removing remote value blocks */ +}; + +/* + * Defines for xfs_delattr_context.flags + */ +#define XFS_DAC_DEFER_FINISH 0x1 /* indicates to finish the transaction */ + +/* + * Context used for keeping track of delayed attribute operations + */ +struct xfs_delattr_context { + struct xfs_da_args *da_args; + struct xfs_da_state *da_state; + struct xfs_da_state_blk *blk; + unsigned int flags; + enum xfs_delattr_state dela_state; +}; + /*======================================================================== * Function prototypes for the kernel. *========================================================================*/ @@ -91,6 +128,7 @@ 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); bool xfs_attr_namecheck(const void *name, size_t length); #endif /* __XFS_ATTR_H__ */ From patchwork Fri Apr 3 22:09:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11473761 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 DC1E11392 for ; Fri, 3 Apr 2020 22:10:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 895D22078C for ; Fri, 3 Apr 2020 22:10:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="nguK5IZw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728495AbgDCWKV (ORCPT ); Fri, 3 Apr 2020 18:10:21 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38538 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728469AbgDCWKV (ORCPT ); Fri, 3 Apr 2020 18:10: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 033M9rQU019649 for ; Fri, 3 Apr 2020 22:10: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=7M4Kl283v127OyACDwPjKqK/fwZAhnkiODPjeFsXJtw=; b=nguK5IZwkgkY0rkOvA/u/gjlUH40q0WEHyJkse2iPCfA7+w4aUs6XYWmMldneo0li8wU gpSfor53NKbofU3hcXEZPR+l2iy7FcApIsPStQUsR4PmLlI+8hUyjYitD2VF4VDunc4M bHtOQxvPi8wVd0+7XBAOckl8e9UYgg1OpdjWXW/FaajT5l89eT2uDBcU/Ey8NirtkHFo vXMhy4CzMlvOWYsF+70sYg8PTCdzMv62zMGTdWwCi9L6Xpqg9xHOgjbUP8YgRBrZtwsP B/ehGVZXDfnGiGrQnr+uyoQVmPm0BmCXeez4CRhiWzomEq6DbWwaFhIiB9RwspL7n+O6 BQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 303aqj3w54-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:18 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 033M7BJi171040 for ; Fri, 3 Apr 2020 22:10:18 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 302g2p2c37-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:18 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MAHV3005690 for ; Fri, 3 Apr 2020 22:10:17 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:16 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 38/39] xfsprogs: Add delay ready attr set routines Date: Fri, 3 Apr 2020 15:09:57 -0700 Message-Id: <20200403220958.4944-39-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=978 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=3 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=3 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 need to upgrade from sf to leaf? ──n─┐ │ │ y │ │ │ V │ XFS_DAS_ADD_LEAF │ │ │ 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_DAS_ALLOC_LEAF ──┤ │ (subroutine state) │ │ └─>xfs_attr_leaf_addname() │ │ │ v │ ┌─────n── need to │ │ alloc blks? │ │ │ │ │ y │ │ │ │ │ v │ │ ┌─>XFS_DAS_ALLOC_LEAF │ │ │ │ │ │ │ v │ │ └──y── need to alloc │ │ more blocks? │ │ │ │ │ n │ │ │ │ │ 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_LEAF_TO_NODE ─┐ │ 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 --- include/libxfs.h | 1 + libxfs/xfs_attr.c | 384 ++++++++++++++++++++++++++++++++--------------- libxfs/xfs_attr.h | 16 ++ libxfs/xfs_attr_leaf.c | 1 + libxfs/xfs_attr_remote.c | 111 ++++++++------ libxfs/xfs_attr_remote.h | 4 + 6 files changed, 351 insertions(+), 166 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 59d46a4..d03b235 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(struct xfs_delattr_context *dac); 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); STATIC void xfs_delattr_context_init( @@ -228,8 +229,11 @@ xfs_attr_is_shortform( /* * Attempts to set an attr in shortform, or converts the tree 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,18 +263,10 @@ xfs_attr_set_shortform( /* * Prevent the leaf buffer from being unlocked so that a concurrent AIL * push cannot grab the half-baked leaf buffer and run into problems - * with the write verifier. Once we're done rolling the transaction we - * can release the hold and add the attr to the leaf. + * with the write verifier. */ xfs_trans_bhold(args->trans, *leaf_bp); - error = xfs_defer_finish(&args->trans); - xfs_trans_bhold_release(args->trans, *leaf_bp); - if (error) { - xfs_trans_brelse(args->trans, *leaf_bp); - return error; - } - - return 0; + return -EAGAIN; } /* @@ -280,9 +276,83 @@ 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; + + if (dac.flags & XFS_DAC_DEFER_FINISH) { + dac.flags &= ~XFS_DAC_DEFER_FINISH; + error = xfs_defer_finish(&args->trans); + 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; + int sf_size; + + /* State machine switch */ + switch (dac->dela_state) { + case XFS_DAS_ADD_LEAF: + goto das_add_leaf; + case XFS_DAS_ALLOC_LEAF: + 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: + case XFS_DAS_LEAF_TO_NODE: + goto das_node; + default: + break; + } + + /* + * New inodes may not have an attribute fork yet. So set the attribute + * fork appropriately + */ + if (XFS_IFORK_Q((args->dp)) == 0) { + sf_size = sizeof(struct xfs_attr_sf_hdr) + + XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); + xfs_bmap_set_attrforkoff(args->dp, sf_size, NULL); + args->dp->i_afp = kmem_zone_zalloc(xfs_ifork_zone, 0); + args->dp->i_afp->if_flags = XFS_IFEXTENTS; + } /* * If the attribute list is already in leaf format, jump straight to @@ -293,40 +363,53 @@ xfs_attr_set_args( 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; + dac->dela_state = XFS_DAS_ADD_LEAF; + } + return error; } - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_addname(args); - if (error != -ENOSPC) - return error; +das_add_leaf: - /* - * Commit that transaction so that the node_addname() - * call can manage its own transactions. - */ - error = xfs_defer_finish(&args->trans); - 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_brelse(args->trans, *leaf_bp); + *leaf_bp = NULL; + } - /* - * Commit the current trans (including the inode) and - * start a new one. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { + error = xfs_attr_leaf_try_add(args, *leaf_bp); + switch (error) { + case -ENOSPC: + dac->flags |= XFS_DAC_DEFER_FINISH; + dac->dela_state = XFS_DAS_LEAF_TO_NODE; + 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) { + dac->dela_state = XFS_DAS_LEAF_TO_NODE; + return -EAGAIN; + } + return error; } - - error = xfs_attr_node_addname(args); +das_node: + error = xfs_attr_node_addname(dac); return error; } @@ -717,28 +800,32 @@ 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_ALLOC_LEAF: + goto das_alloc_leaf; + case XFS_DAS_RM_LBLK: + goto das_rm_lblk; + default: + break; + } /* * If there was an out-of-line value, allocate the blocks we @@ -747,7 +834,28 @@ xfs_attr_leaf_addname( * 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_leaf: + 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_LEAF; + return -EAGAIN; + } + + error = xfs_attr_rmtval_set_value(args); if (error) return error; } @@ -766,22 +874,25 @@ 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; - + 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); + xfs_attr_rmtval_invalidate(args); +das_rm_lblk: if (args->rmtblkno) { - error = xfs_attr_rmtval_remove(args); + error = __xfs_attr_rmtval_remove(args); + + if (error == -EAGAIN) { + dac->dela_state = XFS_DAS_RM_LBLK; + return -EAGAIN; + } + if (error) return error; } @@ -800,15 +911,11 @@ xfs_attr_leaf_addname( /* * If the result is small enough, shrink it all into the inode. */ - if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { + forkoff = xfs_attr_shortform_allfit(bp, dp); + if (forkoff) error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); - /* bp is gone due to xfs_da_shrink_inode */ - if (error) - return error; - error = xfs_defer_finish(&args->trans); - if (error) - return error; - } + + dac->flags |= XFS_DAC_DEFER_FINISH; } else if (args->rmtblkno > 0) { /* @@ -968,16 +1075,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); @@ -986,7 +1100,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. @@ -1032,19 +1160,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; } /* @@ -1056,9 +1178,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. @@ -1073,13 +1193,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 @@ -1088,7 +1204,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; } @@ -1111,18 +1247,26 @@ 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); + xfs_attr_rmtval_invalidate(args); + +das_rm_nblk: if (args->rmtblkno) { - error = xfs_attr_rmtval_remove(args); + error = __xfs_attr_rmtval_remove(args); + + if (error == -EAGAIN) { + dac->dela_state = XFS_DAS_RM_NBLK; + return -EAGAIN; + } + if (error) return error; } @@ -1140,7 +1284,6 @@ restart: error = xfs_da3_node_lookup_int(state, &retval); if (error) goto out; - /* * Remove the name and update the hashvals in the tree. */ @@ -1148,7 +1291,6 @@ restart: ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); error = xfs_attr3_leaf_remove(blk->bp, args); xfs_da3_fixhashpath(state, &state->path); - /* * Check to see if the tree needs to be collapsed. */ @@ -1156,11 +1298,9 @@ 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; + } } else if (args->rmtblkno > 0) { /* * Added a "remote" value, just clear the incomplete flag. diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 0e8ae1a..67af9d1 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -93,6 +93,16 @@ enum xfs_delattr_state { /* Zero is uninitalized */ XFS_DAS_RM_SHRINK = 1, /* We are shrinking the tree */ XFS_DAS_RMTVAL_REMOVE, /* We are removing remote value blocks */ + XFS_DAS_ADD_LEAF, /* We are adding a leaf attr */ + XFS_DAS_FOUND_LBLK, /* We found leaf blk for attr */ + XFS_DAS_LEAF_TO_NODE, /* Converted leaf to node */ + XFS_DAS_FOUND_NBLK, /* We found node blk for attr */ + XFS_DAS_ALLOC_LEAF, /* We are allocating leaf blocks */ + 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 */ }; /* @@ -105,8 +115,13 @@ enum xfs_delattr_state { */ struct xfs_delattr_context { struct xfs_da_args *da_args; + struct xfs_bmbt_irec map; + struct xfs_buf *leaf_bp; + xfs_fileoff_t lfileoff; struct xfs_da_state *da_state; struct xfs_da_state_blk *blk; + xfs_dablk_t lblkno; + int blkcnt; unsigned int flags; enum xfs_delattr_state dela_state; }; @@ -126,6 +141,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_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); diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index e3f8457..5971e3e 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -19,6 +19,7 @@ #include "xfs_bmap_btree.h" #include "xfs_bmap.h" #include "xfs_attr_sf.h" +#include "xfs_attr.h" #include "xfs_attr_remote.h" #include "xfs_attr.h" #include "xfs_attr_leaf.h" diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index a9cd28d..f5ae92b 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,71 @@ 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->lfileoff = 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 +735,6 @@ xfs_attr_rmtval_invalidate( } /* - * Remove the value associated with an attribute by deleting the - * out-of-line buffer that it is stored on. - */ -int -xfs_attr_rmtval_remove( - struct xfs_da_args *args) -{ - xfs_dablk_t lblkno; - int blkcnt; - int error = 0; - 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; - 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; - - /* - * Close out trans and start the next one in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - return error; - } - 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 ee3337b..482dff9 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_da_args *args); +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 Fri Apr 3 22:09:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11473759 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 A9C341392 for ; Fri, 3 Apr 2020 22:10:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 883D9207FF for ; Fri, 3 Apr 2020 22:10:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="mhYafNpd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728432AbgDCWKU (ORCPT ); Fri, 3 Apr 2020 18:10:20 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:54252 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728495AbgDCWKU (ORCPT ); Fri, 3 Apr 2020 18:10:20 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 033M9kFt093117 for ; Fri, 3 Apr 2020 22:10:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=LqG36btvF0ma3CusyvJr5FyWB4dMnTs7f1Ci8Cgvqn0=; b=mhYafNpd0fI7EgnYHlzi7khGf6n0zU7jczM8nrqJKDdBcfMDs2EQ98JWQ3gr/gCeyZzp Jv+LkcSMg8xfHV0OvHdG0ZShGB1PtnmFtuTrOSUqYnVAv3JOscun0JrQC91Rb4ABUyeX gUwEJDBp+Ax43V1rlrRnmejxIe4IFX246chs7hMqs4zpP8uhljcMZrFsBGfzZ8Kkz+c6 3SwY6yXjbC+aZPISdP5SsuKwVYB2w+q4mawEpK2Uq4PrfL+kw1TeTHB8/7FFv9ruvVG/ VZl/xcoWB/S+M1Qv8Bn7VTha1P2NSNS/HICZpJjiRWUMwivPx8vxj6gSVi8jGHLw7MGc Aw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 303yunp0g8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:19 +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 033M8NXa062341 for ; Fri, 3 Apr 2020 22:10:18 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 302ga6126c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 Apr 2020 22:10:18 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 033MAHeh005693 for ; Fri, 3 Apr 2020 22:10:17 GMT Received: from localhost.localdomain (/67.1.1.216) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Apr 2020 15:10:17 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v8 39/39] xfsprogs: Rename __xfs_attr_rmtval_remove Date: Fri, 3 Apr 2020 15:09:58 -0700 Message-Id: <20200403220958.4944-40-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403220958.4944-1-allison.henderson@oracle.com> References: <20200403220958.4944-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=885 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9580 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=939 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004030171 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 | 6 +++--- libxfs/xfs_attr_remote.c | 2 +- libxfs/xfs_attr_remote.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index d03b235..9e220c1 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -886,7 +886,7 @@ das_flip_flag: xfs_attr_rmtval_invalidate(args); das_rm_lblk: if (args->rmtblkno) { - error = __xfs_attr_rmtval_remove(args); + error = xfs_attr_rmtval_remove(args); if (error == -EAGAIN) { dac->dela_state = XFS_DAS_RM_LBLK; @@ -1260,7 +1260,7 @@ das_flip_flag: das_rm_nblk: if (args->rmtblkno) { - error = __xfs_attr_rmtval_remove(args); + error = xfs_attr_rmtval_remove(args); if (error == -EAGAIN) { dac->dela_state = XFS_DAS_RM_NBLK; @@ -1439,7 +1439,7 @@ xfs_attr_node_removename_rmt ( /* * May return -EAGAIN to request that the caller recall this function */ - error = __xfs_attr_rmtval_remove(args); + error = xfs_attr_rmtval_remove(args); if (error) return error; diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index f5ae92b..4ac200b 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -740,7 +740,7 @@ xfs_attr_rmtval_invalidate( * transaction and recall the function */ int -__xfs_attr_rmtval_remove( +xfs_attr_rmtval_remove( struct xfs_da_args *args) { int error, done; diff --git a/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index 482dff9..f39ef53 100644 --- a/libxfs/xfs_attr_remote.h +++ b/libxfs/xfs_attr_remote.h @@ -14,7 +14,7 @@ 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_da_args *args); 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);