From patchwork Sun Feb 23 02:05: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: 11398509 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 E6E0817F0 for ; Sun, 23 Feb 2020 02:06:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD2A720702 for ; Sun, 23 Feb 2020 02:06:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="lSRFAf9X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726965AbgBWCGE (ORCPT ); Sat, 22 Feb 2020 21:06:04 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45600 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726884AbgBWCGE (ORCPT ); Sat, 22 Feb 2020 21:06:04 -0500 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 01N219wD188896 for ; Sun, 23 Feb 2020 02:06:02 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=t1hp1TcVcoOJrPcrMQC+jL3ZQAvzCk9eOwPQqE/O9v8=; b=lSRFAf9XCAUX/q+UAhtdC0FOg1Kvi4EQvIniOpkkiQ2wMbsl5SSTt357Gv4KpSQ4pnKo UfZaNeMcXOM0QYntjIlFnXkRqnHTfopg+s2Vo2hD9rZlDEwDvFsBLRizs4GO4regtHHB a3TJCh7H1JQV17TinkFazyxlsARi+Z4c6kGOSxxoYkuF2QuYSDr7BUAO5ro+Jjef7lUd dVT7beRLAdO0sI5w1y3l3jSM8G+BWxr69kUm+mVU04PDkRQpyHV2g36hKMMeJ1DysnEU ez6SAMSHN88nsffpJPRUHIdw0fzEuy+T1N8hRvNT7iTwnQx4xYHmFLZDxL0uimKOQVOw QQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2yauqu21ww-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:02 +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 01N1we3J054527 for ; Sun, 23 Feb 2020 02:06:01 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2ybe38mcs8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:01 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01N260kw013060 for ; Sun, 23 Feb 2020 02:06:00 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:05:59 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 01/20] xfsprogs: Remove all strlen in all xfs_attr_* functions for attr names. Date: Sat, 22 Feb 2020 19:05:35 -0700 Message-Id: <20200223020554.1731-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 bulkscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This helps to pre-simplify the extra handling of the null terminator in delayed operations which use memcpy rather than strlen. Later when we introduce parent pointers, attribute names will become binary, so strlen will not work at all. Removing uses of strlen now will help reduce complexities later Signed-off-by: Allison Collins Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- db/attrset.c | 4 ++-- libxfs/libxfs_priv.h | 9 +++++---- libxfs/xfs_attr.c | 12 ++++++++---- libxfs/xfs_attr.h | 8 +++++--- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/db/attrset.c b/db/attrset.c index 5697250..5c0ec6e9 100644 --- a/db/attrset.c +++ b/db/attrset.c @@ -146,7 +146,7 @@ attr_set_f( goto out; } - if (libxfs_attr_set(ip, (unsigned char *)name, + if (libxfs_attr_set(ip, (unsigned char *)name, strlen(name), (unsigned char *)value, valuelen, flags)) { dbprintf(_("failed to set attr %s on inode %llu\n"), name, (unsigned long long)iocur_top->ino); @@ -222,7 +222,7 @@ attr_remove_f( goto out; } - if (libxfs_attr_remove(ip, (unsigned char *)name, flags)) { + if (libxfs_attr_remove(ip, (unsigned char *)name, strlen(name), 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_priv.h b/libxfs/libxfs_priv.h index d944efc0..c25c5de 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -610,11 +610,12 @@ static inline int test_and_set_bit(int nr, volatile unsigned long *addr) 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, - unsigned char **value, int *valuelenp, int flags); + size_t namelen, unsigned char **value, int *valuelenp, + int flags); int xfs_attr_set(struct xfs_inode *dp, const unsigned char *name, - unsigned char *value, int valuelen, int flags); -int xfs_attr_remove(struct xfs_inode *dp, const unsigned char *name, int flags); - + size_t namelen, unsigned char *value, int valuelen, int flags); +int xfs_attr_remove(struct xfs_inode *dp, const unsigned char *name, + size_t namelen, int flags); int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp, xfs_rtblock_t block, int issum, struct xfs_buf **bpp); int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp, diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index ada1b5f..925094d 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -61,6 +61,7 @@ xfs_attr_args_init( struct xfs_da_args *args, struct xfs_inode *dp, const unsigned char *name, + size_t namelen, int flags) { @@ -73,7 +74,7 @@ xfs_attr_args_init( args->dp = dp; args->flags = flags; args->name = name; - args->namelen = strlen((const char *)name); + args->namelen = namelen; if (args->namelen >= MAXNAMELEN) return -EFAULT; /* match IRIX behaviour */ @@ -138,6 +139,7 @@ int xfs_attr_get( struct xfs_inode *ip, const unsigned char *name, + size_t namelen, unsigned char **value, int *valuelenp, int flags) @@ -153,7 +155,7 @@ xfs_attr_get( if (XFS_FORCED_SHUTDOWN(ip->i_mount)) return -EIO; - error = xfs_attr_args_init(&args, ip, name, flags); + error = xfs_attr_args_init(&args, ip, name, namelen, flags); if (error) return error; @@ -337,6 +339,7 @@ int xfs_attr_set( struct xfs_inode *dp, const unsigned char *name, + size_t namelen, unsigned char *value, int valuelen, int flags) @@ -352,7 +355,7 @@ xfs_attr_set( if (XFS_FORCED_SHUTDOWN(dp->i_mount)) return -EIO; - error = xfs_attr_args_init(&args, dp, name, flags); + error = xfs_attr_args_init(&args, dp, name, namelen, flags); if (error) return error; @@ -441,6 +444,7 @@ int xfs_attr_remove( struct xfs_inode *dp, const unsigned char *name, + size_t namelen, int flags) { struct xfs_mount *mp = dp->i_mount; @@ -452,7 +456,7 @@ xfs_attr_remove( if (XFS_FORCED_SHUTDOWN(dp->i_mount)) return -EIO; - error = xfs_attr_args_init(&args, dp, name, flags); + error = xfs_attr_args_init(&args, dp, name, namelen, flags); if (error) return error; diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 94badfa..106a2f2 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -145,11 +145,13 @@ 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, - unsigned char **value, int *valuelenp, int flags); + size_t namelen, unsigned char **value, int *valuelenp, + int flags); int xfs_attr_set(struct xfs_inode *dp, const unsigned char *name, - unsigned char *value, int valuelen, int flags); + 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, int flags); +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 Sun Feb 23 02:05: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: 11398515 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 791DD1892 for ; Sun, 23 Feb 2020 02:06:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58F32206EF for ; Sun, 23 Feb 2020 02:06:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="zMhK4p9n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727150AbgBWCGF (ORCPT ); Sat, 22 Feb 2020 21:06:05 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:56182 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726983AbgBWCGE (ORCPT ); Sat, 22 Feb 2020 21:06:04 -0500 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 01N21cHI008549 for ; Sun, 23 Feb 2020 02:06:02 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=+VrLHuCbVXAeD6ypWGOb9ahCgWzUM4de4F/NquD6hs8=; b=zMhK4p9nrZbZxTD34d3OufVQsrk+oYYGkZizyLkIo/Xek+Mofof+65gb1mU3uQFpxdnU 3U/ERQaJiGkdNgU07NRUYTV06OhJcfdah6PBlqVTf1a25eLyElS5AI9BGIsk1w8a0V4u aAB/UhMydvZ0nnlPSO/vs4Hbk7yLG2F4FE6H03WNfiPXVJuR4uqt5/hWnHn8h0wgLdwb J+Vd5d25fUSZ46jUGGQcj/9sp3mpnmC5YVsYeaitXtqjyU2iVz381h2id63v8fRU4osx lxGeKQE+nq5xJPpvD97y0ftS8hSZLLazbQ0xpWe9FT/46izfbTSz8aMugBtDfXTGawh1 kA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2yav8qa0sa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:02 +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 01N1wWEE081279 for ; Sun, 23 Feb 2020 02:06:01 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2ybe0wr0q5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:01 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01N260hr031312 for ; Sun, 23 Feb 2020 02:06:00 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:00 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 02/20] xfsprogs: Replace attribute parameters with struct xfs_name Date: Sat, 22 Feb 2020 19:05:36 -0700 Message-Id: <20200223020554.1731-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 impostorscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch replaces the attribute name and length parameters with a single struct xfs_name parameter. This helps to clean up the numbers of parameters being passed around and pre-simplifies the code some. Signed-off-by: Allison Collins --- db/attrset.c | 11 ++++++++--- libxfs/libxfs_priv.h | 12 +++++------- libxfs/xfs_attr.c | 22 +++++++++------------- libxfs/xfs_attr.h | 12 +++++------- libxfs/xfs_types.c | 11 +++++++++++ libxfs/xfs_types.h | 1 + 6 files changed, 39 insertions(+), 30 deletions(-) diff --git a/db/attrset.c b/db/attrset.c index 5c0ec6e9..4da85cb 100644 --- a/db/attrset.c +++ b/db/attrset.c @@ -16,6 +16,7 @@ #include "field.h" #include "inode.h" #include "malloc.h" +#include "xfs_types.h" static int attr_set_f(int argc, char **argv); static int attr_remove_f(int argc, char **argv); @@ -68,6 +69,7 @@ attr_set_f( { xfs_inode_t *ip = NULL; char *name, *value, *sp; + struct xfs_name xname; int c, valuelen = 0, flags = 0; if (cur_typ == NULL) { @@ -146,8 +148,9 @@ attr_set_f( goto out; } - if (libxfs_attr_set(ip, (unsigned char *)name, strlen(name), - (unsigned char *)value, valuelen, flags)) { + xfs_name_init(&xname, name); + if (libxfs_attr_set(ip, &xname, (unsigned char *)value, valuelen, + flags)) { dbprintf(_("failed to set attr %s on inode %llu\n"), name, (unsigned long long)iocur_top->ino); goto out; @@ -172,6 +175,7 @@ attr_remove_f( { xfs_inode_t *ip = NULL; char *name; + struct xfs_name xname; int c, flags = 0; if (cur_typ == NULL) { @@ -222,7 +226,8 @@ attr_remove_f( goto out; } - if (libxfs_attr_remove(ip, (unsigned char *)name, strlen(name), flags)) { + xfs_name_init(&xname, name); + if (libxfs_attr_remove(ip, &xname, 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_priv.h b/libxfs/libxfs_priv.h index c25c5de..f8637e8c 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -609,13 +609,11 @@ static inline int test_and_set_bit(int nr, volatile unsigned long *addr) /* Keep static checkers quiet about nonstatic functions by exporting */ 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_set(struct xfs_inode *dp, const unsigned char *name, - size_t namelen, unsigned char *value, int valuelen, int flags); -int xfs_attr_remove(struct xfs_inode *dp, const unsigned char *name, - size_t namelen, int flags); +int xfs_attr_get(struct xfs_inode *ip, struct xfs_name *name, + unsigned char **value, int *valuelenp, int flags); +int xfs_attr_set(struct xfs_inode *dp, struct xfs_name *name, + unsigned char *value, int valuelen, int flags); +int xfs_attr_remove(struct xfs_inode *dp, struct xfs_name *name, int flags); int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp, xfs_rtblock_t block, int issum, struct xfs_buf **bpp); int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp, diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 925094d..6e1f3a1 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -60,8 +60,7 @@ STATIC int xfs_attr_args_init( struct xfs_da_args *args, struct xfs_inode *dp, - const unsigned char *name, - size_t namelen, + struct xfs_name *name, int flags) { @@ -73,8 +72,8 @@ xfs_attr_args_init( args->whichfork = XFS_ATTR_FORK; args->dp = dp; args->flags = flags; - args->name = name; - args->namelen = namelen; + args->name = name->name; + args->namelen = name->len; if (args->namelen >= MAXNAMELEN) return -EFAULT; /* match IRIX behaviour */ @@ -138,8 +137,7 @@ xfs_attr_get_ilocked( int xfs_attr_get( struct xfs_inode *ip, - const unsigned char *name, - size_t namelen, + struct xfs_name *name, unsigned char **value, int *valuelenp, int flags) @@ -155,7 +153,7 @@ xfs_attr_get( if (XFS_FORCED_SHUTDOWN(ip->i_mount)) return -EIO; - error = xfs_attr_args_init(&args, ip, name, namelen, flags); + error = xfs_attr_args_init(&args, ip, name, flags); if (error) return error; @@ -338,8 +336,7 @@ xfs_attr_remove_args( int xfs_attr_set( struct xfs_inode *dp, - const unsigned char *name, - size_t namelen, + struct xfs_name *name, unsigned char *value, int valuelen, int flags) @@ -355,7 +352,7 @@ xfs_attr_set( if (XFS_FORCED_SHUTDOWN(dp->i_mount)) return -EIO; - error = xfs_attr_args_init(&args, dp, name, namelen, flags); + error = xfs_attr_args_init(&args, dp, name, flags); if (error) return error; @@ -443,8 +440,7 @@ out_trans_cancel: int xfs_attr_remove( struct xfs_inode *dp, - const unsigned char *name, - size_t namelen, + struct xfs_name *name, int flags) { struct xfs_mount *mp = dp->i_mount; @@ -456,7 +452,7 @@ xfs_attr_remove( if (XFS_FORCED_SHUTDOWN(dp->i_mount)) return -EIO; - error = xfs_attr_args_init(&args, dp, name, namelen, flags); + error = xfs_attr_args_init(&args, dp, name, flags); if (error) return error; diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 106a2f2..44dd07a 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -144,14 +144,12 @@ 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_set(struct xfs_inode *dp, const unsigned char *name, - size_t namelen, unsigned char *value, int valuelen, int flags); +int xfs_attr_get(struct xfs_inode *ip, struct xfs_name *name, + unsigned char **value, int *valuelenp, int flags); +int xfs_attr_set(struct xfs_inode *dp, struct xfs_name *name, + 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(struct xfs_inode *dp, struct xfs_name *name, 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); diff --git a/libxfs/xfs_types.c b/libxfs/xfs_types.c index fa11372..363e5050 100644 --- a/libxfs/xfs_types.c +++ b/libxfs/xfs_types.c @@ -12,6 +12,17 @@ #include "xfs_bit.h" #include "xfs_mount.h" +/* Initialize a struct xfs_name with a null terminated string name */ +void +xfs_name_init( + struct xfs_name *xname, + const char *name) +{ + xname->name = (unsigned char *)name; + xname->len = strlen(name); + xname->type = 0; +} + /* Find the size of the AG, in blocks. */ xfs_agblock_t xfs_ag_block_count( diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index 300b3e9..ecb2c58 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -182,6 +182,7 @@ enum xfs_ag_resv_type { */ struct xfs_mount; +void xfs_name_init(struct xfs_name *xname, const char *name); xfs_agblock_t xfs_ag_block_count(struct xfs_mount *mp, xfs_agnumber_t agno); bool xfs_verify_agbno(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno); From patchwork Sun Feb 23 02:05: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: 11398535 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 5FEBB1395 for ; Sun, 23 Feb 2020 02:06:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D1B0206EF for ; Sun, 23 Feb 2020 02:06:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="RbaOuGOw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727093AbgBWCGH (ORCPT ); Sat, 22 Feb 2020 21:06:07 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:56184 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726984AbgBWCGG (ORCPT ); Sat, 22 Feb 2020 21:06:06 -0500 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 01N21lFP008956 for ; Sun, 23 Feb 2020 02:06:02 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=WQfyNUfPN5jDtrqisU5JDaqp3QyNkh0EZH23mLdppYg=; b=RbaOuGOw94U1pCtptqZR3S+fzjDNjOkHUT6L1/0su+rP7yOq0kGARNFQF1RTsdQzXrg/ csMaV7fxjFgH/lLQPrdb6O0gEfkE9uWLBH7w5zEoOZQAMhsYOb+lRWZ0lbxlv9pwK8yc o58IxRn2CKAhQrz+kWQ7UzBz2vIJcz5o0BvITHQPCBSog/UmbkWnFp9yZc4zylV6u0qK JD6f6GcJ8qkV+xS9x22nTLSkjHGVnmFb69Ah+kP6nzYnuVgTHSArkzJq6pWec2/hnFEk WOqEb/0onrmPZnBevNndOC9hGD/yiuFPnPwTT/X4Nm0JBd9U8aTnmWoHNcAYt9x7+BCa aw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2yav8qa0sc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:02 +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 01N1wTwH081251 for ; Sun, 23 Feb 2020 02:06:01 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2ybe0wr0q4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:01 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01N260Ic013061 for ; Sun, 23 Feb 2020 02:06:00 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:00 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 03/20] xfsprogs: Embed struct xfs_name in xfs_da_args Date: Sat, 22 Feb 2020 19:05:37 -0700 Message-Id: <20200223020554.1731-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 impostorscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch embeds an xfs_name in xfs_da_args, replacing the name, namelen, and flags members. This helps to clean up the xfs_da_args structure and make it more uniform with the new xfs_name parameter being passed around. Signed-off-by: Allison Collins Reviewed-by: Brian Foster --- libxfs/xfs_attr.c | 39 +++++++++-------- libxfs/xfs_attr_leaf.c | 106 ++++++++++++++++++++++++----------------------- libxfs/xfs_attr_remote.c | 2 +- libxfs/xfs_da_btree.c | 6 ++- libxfs/xfs_da_btree.h | 4 +- libxfs/xfs_dir2.c | 18 ++++---- libxfs/xfs_dir2_block.c | 6 +-- libxfs/xfs_dir2_leaf.c | 6 +-- libxfs/xfs_dir2_node.c | 8 ++-- libxfs/xfs_dir2_sf.c | 30 +++++++------- 10 files changed, 115 insertions(+), 110 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 6e1f3a1..4fe27f1 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -71,13 +71,12 @@ xfs_attr_args_init( args->geo = dp->i_mount->m_attr_geo; args->whichfork = XFS_ATTR_FORK; args->dp = dp; - args->flags = flags; - args->name = name->name; - args->namelen = name->len; - if (args->namelen >= MAXNAMELEN) + memcpy(&args->name, name, sizeof(struct xfs_name)); + args->name.type = flags; + if (args->name.len >= MAXNAMELEN) return -EFAULT; /* match IRIX behaviour */ - args->hashval = xfs_da_hashname(args->name, args->namelen); + args->hashval = xfs_da_hashname(args->name.name, args->name.len); return 0; } @@ -235,7 +234,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->name.type & ATTR_KERNOTIME) == 0) xfs_trans_ichgtime(args->trans, dp, XFS_ICHGTIME_CHG); if (mp->m_flags & XFS_MOUNT_WSYNC) @@ -356,6 +355,9 @@ xfs_attr_set( if (error) return error; + /* Use name now stored in args */ + name = &args.name; + args.value = value; args.valuelen = valuelen; args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; @@ -371,7 +373,7 @@ xfs_attr_set( */ if (XFS_IFORK_Q(dp) == 0) { int sf_size = sizeof(xfs_attr_sf_hdr_t) + - XFS_ATTR_SF_ENTSIZE_BYNAME(args.namelen, valuelen); + XFS_ATTR_SF_ENTSIZE_BYNAME(name->len, valuelen); error = xfs_bmap_add_attrfork(dp, sf_size, rsvd); if (error) @@ -456,6 +458,9 @@ xfs_attr_remove( if (error) return error; + /* Use name now stored in args */ + name = &args.name; + /* * 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 @@ -531,10 +536,10 @@ 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 ((args->name.type & ATTR_REPLACE) && (retval == -ENOATTR)) { return retval; } else if (retval == -EEXIST) { - if (args->flags & ATTR_CREATE) + if (args->name.type & ATTR_CREATE) return retval; retval = xfs_attr_shortform_remove(args); if (retval) @@ -544,15 +549,15 @@ 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->name.type &= ~ATTR_REPLACE; } - if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX || + if (args->name.len >= XFS_ATTR_SF_ENTSIZE_MAX || args->valuelen >= XFS_ATTR_SF_ENTSIZE_MAX) return -ENOSPC; newsize = XFS_ATTR_SF_TOTSIZE(args->dp); - newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); + newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->name.len, args->valuelen); forkoff = xfs_attr_shortform_bytesfit(args->dp, newsize); if (!forkoff) @@ -597,11 +602,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)) { + if ((args->name.type & ATTR_REPLACE) && (retval == -ENOATTR)) { xfs_trans_brelse(args->trans, bp); return retval; } else if (retval == -EEXIST) { - if (args->flags & ATTR_CREATE) { /* pure create op */ + if (args->name.type & ATTR_CREATE) { /* pure create op */ xfs_trans_brelse(args->trans, bp); return retval; } @@ -871,10 +876,10 @@ 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 ((args->name.type & ATTR_REPLACE) && (retval == -ENOATTR)) { goto out; } else if (retval == -EEXIST) { - if (args->flags & ATTR_CREATE) + if (args->name.type & ATTR_CREATE) goto out; trace_xfs_attr_node_replace(args); @@ -1006,7 +1011,7 @@ restart: * The INCOMPLETE flag means that we will find the "old" * attr, not the "new" one. */ - args->flags |= XFS_ATTR_INCOMPLETE; + args->name.type |= XFS_ATTR_INCOMPLETE; state = xfs_da_state_alloc(); state->args = args; state->mp = mp; diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 0249a0a..1389970 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -398,7 +398,7 @@ xfs_attr_copy_value( /* * No copy if all we have to do is get the length */ - if (args->flags & ATTR_KERNOVAL) { + if (args->name.type & ATTR_KERNOVAL) { args->valuelen = valuelen; return 0; } @@ -611,27 +611,27 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) 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) + if (sfe->namelen != args->name.len) continue; - if (memcmp(args->name, sfe->nameval, args->namelen) != 0) + if (memcmp(args->name.name, sfe->nameval, args->name.len) != 0) continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) + if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) continue; ASSERT(0); #endif } offset = (char *)sfe - (char *)sf; - size = XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); + size = XFS_ATTR_SF_ENTSIZE_BYNAME(args->name.len, args->valuelen); xfs_idata_realloc(dp, size, XFS_ATTR_FORK); sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; sfe = (xfs_attr_sf_entry_t *)((char *)sf + offset); - sfe->namelen = args->namelen; + sfe->namelen = args->name.len; sfe->valuelen = args->valuelen; - sfe->flags = XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags); - memcpy(sfe->nameval, args->name, args->namelen); - memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen); + sfe->flags = XFS_ATTR_NSP_ARGS_TO_ONDISK(args->name.type); + memcpy(sfe->nameval, args->name.name, args->name.len); + memcpy(&sfe->nameval[args->name.len], args->value, args->valuelen); sf->hdr.count++; be16_add_cpu(&sf->hdr.totsize, size); xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); @@ -681,11 +681,11 @@ 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) + if (sfe->namelen != args->name.len) continue; - if (memcmp(sfe->nameval, args->name, args->namelen) != 0) + if (memcmp(sfe->nameval, args->name.name, args->name.len) != 0) continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) + if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) continue; break; } @@ -748,11 +748,11 @@ 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) + if (sfe->namelen != args->name.len) continue; - if (memcmp(args->name, sfe->nameval, args->namelen) != 0) + if (memcmp(args->name.name, sfe->nameval, args->name.len) != 0) continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) + if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) continue; return -EEXIST; } @@ -779,13 +779,13 @@ 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) + if (sfe->namelen != args->name.len) continue; - if (memcmp(args->name, sfe->nameval, args->namelen) != 0) + if (memcmp(args->name.name, sfe->nameval, args->name.len) != 0) continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) + if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) continue; - return xfs_attr_copy_value(args, &sfe->nameval[args->namelen], + return xfs_attr_copy_value(args, &sfe->nameval[args->name.len], sfe->valuelen); } return -ENOATTR; @@ -844,13 +844,13 @@ xfs_attr_shortform_to_leaf( sfe = &sf->list[0]; for (i = 0; i < sf->hdr.count; i++) { - nargs.name = sfe->nameval; - nargs.namelen = sfe->namelen; - nargs.value = &sfe->nameval[nargs.namelen]; + nargs.name.name = sfe->nameval; + nargs.name.len = sfe->namelen; + nargs.value = &sfe->nameval[nargs.name.len]; nargs.valuelen = sfe->valuelen; nargs.hashval = xfs_da_hashname(sfe->nameval, sfe->namelen); - nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags); + nargs.name.type = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags); error = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */ ASSERT(error == -ENOATTR); error = xfs_attr3_leaf_add(bp, &nargs); @@ -1051,12 +1051,12 @@ xfs_attr3_leaf_to_shortform( continue; ASSERT(entry->flags & XFS_ATTR_LOCAL); name_loc = xfs_attr3_leaf_name_local(leaf, i); - nargs.name = name_loc->nameval; - nargs.namelen = name_loc->namelen; - nargs.value = &name_loc->nameval[nargs.namelen]; + nargs.name.name = name_loc->nameval; + nargs.name.len = name_loc->namelen; + nargs.value = &name_loc->nameval[nargs.name.len]; 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.name.type = XFS_ATTR_NSP_ONDISK_TO_ARGS(entry->flags); xfs_attr_shortform_add(&nargs, forkoff); } error = 0; @@ -1384,7 +1384,7 @@ xfs_attr3_leaf_add_work( 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 |= XFS_ATTR_NSP_ARGS_TO_ONDISK(args->name.type); if (args->op_flags & XFS_DA_OP_RENAME) { entry->flags |= XFS_ATTR_INCOMPLETE; if ((args->blkno2 == args->blkno) && @@ -1408,15 +1408,16 @@ xfs_attr3_leaf_add_work( */ if (entry->flags & XFS_ATTR_LOCAL) { name_loc = xfs_attr3_leaf_name_local(leaf, args->index); - name_loc->namelen = args->namelen; + name_loc->namelen = args->name.len; name_loc->valuelen = cpu_to_be16(args->valuelen); - memcpy((char *)name_loc->nameval, args->name, args->namelen); - memcpy((char *)&name_loc->nameval[args->namelen], args->value, + memcpy((char *)name_loc->nameval, args->name.name, + args->name.len); + memcpy((char *)&name_loc->nameval[args->name.len], args->value, be16_to_cpu(name_loc->valuelen)); } else { name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index); - name_rmt->namelen = args->namelen; - memcpy((char *)name_rmt->name, args->name, args->namelen); + name_rmt->namelen = args->name.len; + memcpy((char *)name_rmt->name, args->name.name, args->name.len); entry->flags |= XFS_ATTR_INCOMPLETE; /* just in case */ name_rmt->valuelen = 0; @@ -2329,29 +2330,31 @@ xfs_attr3_leaf_lookup_int( * If we are looking for INCOMPLETE entries, show only those. * If we are looking for complete entries, show only those. */ - if ((args->flags & XFS_ATTR_INCOMPLETE) != + if ((args->name.type & XFS_ATTR_INCOMPLETE) != (entry->flags & XFS_ATTR_INCOMPLETE)) { continue; } if (entry->flags & XFS_ATTR_LOCAL) { name_loc = xfs_attr3_leaf_name_local(leaf, probe); - if (name_loc->namelen != args->namelen) + if (name_loc->namelen != args->name.len) continue; - if (memcmp(args->name, name_loc->nameval, - args->namelen) != 0) + if (memcmp(args->name.name, name_loc->nameval, + args->name.len) != 0) continue; - if (!xfs_attr_namesp_match(args->flags, entry->flags)) + if (!xfs_attr_namesp_match(args->name.type, + entry->flags)) continue; args->index = probe; return -EEXIST; } else { name_rmt = xfs_attr3_leaf_name_remote(leaf, probe); - if (name_rmt->namelen != args->namelen) + if (name_rmt->namelen != args->name.len) continue; - if (memcmp(args->name, name_rmt->name, - args->namelen) != 0) + if (memcmp(args->name.name, name_rmt->name, + args->name.len) != 0) continue; - if (!xfs_attr_namesp_match(args->flags, entry->flags)) + if (!xfs_attr_namesp_match(args->name.type, + entry->flags)) continue; args->index = probe; args->rmtvaluelen = be32_to_cpu(name_rmt->valuelen); @@ -2393,16 +2396,17 @@ xfs_attr3_leaf_getvalue( entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; if (entry->flags & XFS_ATTR_LOCAL) { name_loc = xfs_attr3_leaf_name_local(leaf, args->index); - ASSERT(name_loc->namelen == args->namelen); - ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0); + ASSERT(name_loc->namelen == args->name.len); + ASSERT(memcmp(args->name.name, name_loc->nameval, + args->name.len) == 0); return xfs_attr_copy_value(args, - &name_loc->nameval[args->namelen], + &name_loc->nameval[args->name.len], be16_to_cpu(name_loc->valuelen)); } name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index); - ASSERT(name_rmt->namelen == args->namelen); - ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0); + ASSERT(name_rmt->namelen == args->name.len); + ASSERT(memcmp(args->name.name, name_rmt->name, args->name.len) == 0); args->rmtvaluelen = be32_to_cpu(name_rmt->valuelen); args->rmtblkno = be32_to_cpu(name_rmt->valueblk); args->rmtblkcnt = xfs_attr3_rmt_blocks(args->dp->i_mount, @@ -2618,7 +2622,7 @@ xfs_attr_leaf_newentsize( { int size; - size = xfs_attr_leaf_entsize_local(args->namelen, args->valuelen); + size = xfs_attr_leaf_entsize_local(args->name.len, args->valuelen); if (size < xfs_attr_leaf_entsize_local_max(args->geo->blksize)) { if (local) *local = 1; @@ -2626,7 +2630,7 @@ xfs_attr_leaf_newentsize( } if (local) *local = 0; - return xfs_attr_leaf_entsize_remote(args->namelen); + return xfs_attr_leaf_entsize_remote(args->name.len); } @@ -2680,8 +2684,8 @@ xfs_attr3_leaf_clearflag( name = (char *)name_rmt->name; } ASSERT(be32_to_cpu(entry->hashval) == args->hashval); - ASSERT(namelen == args->namelen); - ASSERT(memcmp(name, args->name, namelen) == 0); + ASSERT(namelen == args->name.len); + ASSERT(memcmp(name, args->name.name, namelen) == 0); #endif /* DEBUG */ entry->flags &= ~XFS_ATTR_INCOMPLETE; diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 7234f86..0cadc82 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -377,7 +377,7 @@ xfs_attr_rmtval_get( trace_xfs_attr_rmtval_get(args); - ASSERT(!(args->flags & ATTR_KERNOVAL)); + ASSERT(!(args->name.type & ATTR_KERNOVAL)); ASSERT(args->rmtvaluelen == args->valuelen); valuelen = args->rmtvaluelen; diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c index e7af446..b731d96 100644 --- a/libxfs/xfs_da_btree.c +++ b/libxfs/xfs_da_btree.c @@ -2037,8 +2037,10 @@ xfs_da_compname( const unsigned char *name, int len) { - return (args->namelen == len && memcmp(args->name, name, len) == 0) ? - XFS_CMP_EXACT : XFS_CMP_DIFFERENT; + if (args->name.len == len && !memcmp(args->name.name, name, len)) + return XFS_CMP_EXACT; + + return XFS_CMP_DIFFERENT; } static xfs_dahash_t diff --git a/libxfs/xfs_da_btree.h b/libxfs/xfs_da_btree.h index ae0bbd2..bed4f40 100644 --- a/libxfs/xfs_da_btree.h +++ b/libxfs/xfs_da_btree.h @@ -47,12 +47,10 @@ enum xfs_dacmp { */ typedef struct xfs_da_args { struct xfs_da_geometry *geo; /* da block geometry */ - const uint8_t *name; /* string (maybe not NULL terminated) */ - int namelen; /* length of string (maybe no NULL) */ + struct xfs_name name; /* name, length and argument flags*/ uint8_t filetype; /* filetype of inode for directories */ uint8_t *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 */ xfs_ino_t inumber; /* input/output inode number */ struct xfs_inode *dp; /* directory inode to manipulate */ diff --git a/libxfs/xfs_dir2.c b/libxfs/xfs_dir2.c index b3fbc4d..7f4a011 100644 --- a/libxfs/xfs_dir2.c +++ b/libxfs/xfs_dir2.c @@ -72,14 +72,14 @@ xfs_ascii_ci_compname( enum xfs_dacmp result; int i; - if (args->namelen != len) + if (args->name.len != len) return XFS_CMP_DIFFERENT; result = XFS_CMP_EXACT; for (i = 0; i < len; i++) { - if (args->name[i] == name[i]) + if (args->name.name[i] == name[i]) continue; - if (tolower(args->name[i]) != tolower(name[i])) + if (tolower(args->name.name[i]) != tolower(name[i])) return XFS_CMP_DIFFERENT; result = XFS_CMP_CASE; } @@ -257,8 +257,7 @@ xfs_dir_createname( return -ENOMEM; args->geo = dp->i_mount->m_dir_geo; - args->name = name->name; - args->namelen = name->len; + memcpy(&args->name, name, sizeof(struct xfs_name)); args->filetype = name->type; args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->inumber = inum; @@ -353,8 +352,7 @@ xfs_dir_lookup( */ args = kmem_zalloc(sizeof(*args), KM_NOFS); args->geo = dp->i_mount->m_dir_geo; - args->name = name->name; - args->namelen = name->len; + memcpy(&args->name, name, sizeof(struct xfs_name)); args->filetype = name->type; args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->dp = dp; @@ -425,8 +423,7 @@ xfs_dir_removename( return -ENOMEM; args->geo = dp->i_mount->m_dir_geo; - args->name = name->name; - args->namelen = name->len; + memcpy(&args->name, name, sizeof(struct xfs_name)); args->filetype = name->type; args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->inumber = ino; @@ -486,8 +483,7 @@ xfs_dir_replace( return -ENOMEM; args->geo = dp->i_mount->m_dir_geo; - args->name = name->name; - args->namelen = name->len; + memcpy(&args->name, name, sizeof(struct xfs_name)); args->filetype = name->type; args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->inumber = inum; diff --git a/libxfs/xfs_dir2_block.c b/libxfs/xfs_dir2_block.c index eea894f..1568c6a 100644 --- a/libxfs/xfs_dir2_block.c +++ b/libxfs/xfs_dir2_block.c @@ -352,7 +352,7 @@ xfs_dir2_block_addname( if (error) return error; - len = dp->d_ops->data_entsize(args->namelen); + len = dp->d_ops->data_entsize(args->name.len); /* * Set up pointers to parts of the block. @@ -536,8 +536,8 @@ xfs_dir2_block_addname( * Create the new data entry. */ dep->inumber = cpu_to_be64(args->inumber); - dep->namelen = args->namelen; - memcpy(dep->name, args->name, args->namelen); + dep->namelen = args->name.len; + memcpy(dep->name, args->name.name, args->name.len); dp->d_ops->data_put_ftype(dep, args->filetype); tagp = dp->d_ops->data_entry_tag_p(dep); *tagp = cpu_to_be16((char *)dep - (char *)hdr); diff --git a/libxfs/xfs_dir2_leaf.c b/libxfs/xfs_dir2_leaf.c index ff4a04e..6bf063c 100644 --- a/libxfs/xfs_dir2_leaf.c +++ b/libxfs/xfs_dir2_leaf.c @@ -608,7 +608,7 @@ xfs_dir2_leaf_addname( ents = dp->d_ops->leaf_ents_p(leaf); dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); bestsp = xfs_dir2_leaf_bests_p(ltp); - length = dp->d_ops->data_entsize(args->namelen); + length = dp->d_ops->data_entsize(args->name.len); /* * See if there are any entries with the same hash value @@ -811,8 +811,8 @@ xfs_dir2_leaf_addname( */ dep = (xfs_dir2_data_entry_t *)dup; dep->inumber = cpu_to_be64(args->inumber); - dep->namelen = args->namelen; - memcpy(dep->name, args->name, dep->namelen); + dep->namelen = args->name.len; + memcpy(dep->name, args->name.name, dep->namelen); dp->d_ops->data_put_ftype(dep, args->filetype); tagp = dp->d_ops->data_entry_tag_p(dep); *tagp = cpu_to_be16((char *)dep - (char *)hdr); diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c index d3dea3f..ef73584 100644 --- a/libxfs/xfs_dir2_node.c +++ b/libxfs/xfs_dir2_node.c @@ -601,7 +601,7 @@ xfs_dir2_leafn_lookup_for_addname( ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) || free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC)); } - length = dp->d_ops->data_entsize(args->namelen); + length = dp->d_ops->data_entsize(args->name.len); /* * Loop over leaf entries with the right hash value. */ @@ -1866,7 +1866,7 @@ xfs_dir2_node_addname_int( __be16 *tagp; /* data entry tag pointer */ __be16 *bests; - length = dp->d_ops->data_entsize(args->namelen); + length = dp->d_ops->data_entsize(args->name.len); error = xfs_dir2_node_find_freeblk(args, fblk, &dbno, &fbp, &findex, length); if (error) @@ -1921,8 +1921,8 @@ xfs_dir2_node_addname_int( /* Fill in the new entry and log it. */ dep = (xfs_dir2_data_entry_t *)dup; dep->inumber = cpu_to_be64(args->inumber); - dep->namelen = args->namelen; - memcpy(dep->name, args->name, dep->namelen); + dep->namelen = args->name.len; + memcpy(dep->name, args->name.name, dep->namelen); dp->d_ops->data_put_ftype(dep, args->filetype); tagp = dp->d_ops->data_entry_tag_p(dep); *tagp = cpu_to_be16((char *)dep - (char *)hdr); diff --git a/libxfs/xfs_dir2_sf.c b/libxfs/xfs_dir2_sf.c index 50bcb8a..1a8254b 100644 --- a/libxfs/xfs_dir2_sf.c +++ b/libxfs/xfs_dir2_sf.c @@ -291,7 +291,7 @@ xfs_dir2_sf_addname( /* * Compute entry (and change in) size. */ - incr_isize = dp->d_ops->sf_entsize(sfp, args->namelen); + incr_isize = dp->d_ops->sf_entsize(sfp, args->name.len); objchange = 0; /* @@ -375,7 +375,7 @@ xfs_dir2_sf_addname_easy( /* * Grow the in-inode space. */ - xfs_idata_realloc(dp, dp->d_ops->sf_entsize(sfp, args->namelen), + xfs_idata_realloc(dp, dp->d_ops->sf_entsize(sfp, args->name.len), XFS_DATA_FORK); /* * Need to set up again due to realloc of the inode data. @@ -385,9 +385,9 @@ xfs_dir2_sf_addname_easy( /* * Fill in the new entry. */ - sfep->namelen = args->namelen; + sfep->namelen = args->name.len; xfs_dir2_sf_put_offset(sfep, offset); - memcpy(sfep->name, args->name, sfep->namelen); + memcpy(sfep->name, args->name.name, sfep->namelen); dp->d_ops->sf_put_ino(sfp, sfep, args->inumber); dp->d_ops->sf_put_ftype(sfep, args->filetype); @@ -446,7 +446,7 @@ xfs_dir2_sf_addname_hard( */ for (offset = dp->d_ops->data_first_offset, oldsfep = xfs_dir2_sf_firstentry(oldsfp), - add_datasize = dp->d_ops->data_entsize(args->namelen), + add_datasize = dp->d_ops->data_entsize(args->name.len), eof = (char *)oldsfep == &buf[old_isize]; !eof; offset = new_offset + dp->d_ops->data_entsize(oldsfep->namelen), @@ -476,9 +476,9 @@ xfs_dir2_sf_addname_hard( /* * Fill in the new entry, and update the header counts. */ - sfep->namelen = args->namelen; + sfep->namelen = args->name.len; xfs_dir2_sf_put_offset(sfep, offset); - memcpy(sfep->name, args->name, sfep->namelen); + memcpy(sfep->name, args->name.name, sfep->namelen); dp->d_ops->sf_put_ino(sfp, sfep, args->inumber); dp->d_ops->sf_put_ftype(sfep, args->filetype); sfp->count++; @@ -522,7 +522,7 @@ xfs_dir2_sf_addname_pick( dp = args->dp; sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; - size = dp->d_ops->data_entsize(args->namelen); + size = dp->d_ops->data_entsize(args->name.len); offset = dp->d_ops->data_first_offset; sfep = xfs_dir2_sf_firstentry(sfp); holefit = 0; @@ -807,7 +807,7 @@ xfs_dir2_sf_lookup( /* * Special case for . */ - if (args->namelen == 1 && args->name[0] == '.') { + if (args->name.len == 1 && args->name.name[0] == '.') { args->inumber = dp->i_ino; args->cmpresult = XFS_CMP_EXACT; args->filetype = XFS_DIR3_FT_DIR; @@ -816,8 +816,8 @@ xfs_dir2_sf_lookup( /* * Special case for .. */ - if (args->namelen == 2 && - args->name[0] == '.' && args->name[1] == '.') { + if (args->name.len == 2 && + args->name.name[0] == '.' && args->name.name[1] == '.') { args->inumber = dp->d_ops->sf_get_parent_ino(sfp); args->cmpresult = XFS_CMP_EXACT; args->filetype = XFS_DIR3_FT_DIR; @@ -912,7 +912,7 @@ xfs_dir2_sf_removename( * Calculate sizes. */ byteoff = (int)((char *)sfep - (char *)sfp); - entsize = dp->d_ops->sf_entsize(sfp, args->namelen); + entsize = dp->d_ops->sf_entsize(sfp, args->name.len); newsize = oldsize - entsize; /* * Copy the part if any after the removed entry, sliding it down. @@ -1002,12 +1002,12 @@ xfs_dir2_sf_replace( } else i8elevated = 0; - ASSERT(args->namelen != 1 || args->name[0] != '.'); + ASSERT(args->name.len != 1 || args->name.name[0] != '.'); /* * Replace ..'s entry. */ - if (args->namelen == 2 && - args->name[0] == '.' && args->name[1] == '.') { + if (args->name.len == 2 && + args->name.name[0] == '.' && args->name.name[1] == '.') { ino = dp->d_ops->sf_get_parent_ino(sfp); ASSERT(args->inumber != ino); dp->d_ops->sf_put_parent_ino(sfp, args->inumber); From patchwork Sun Feb 23 02:05: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: 11398525 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 71A0E1395 for ; Sun, 23 Feb 2020 02:06:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 48BA520702 for ; Sun, 23 Feb 2020 02:06:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="YX9tmH1N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727024AbgBWCGF (ORCPT ); Sat, 22 Feb 2020 21:06:05 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45606 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727091AbgBWCGE (ORCPT ); Sat, 22 Feb 2020 21:06:04 -0500 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 01N21BWa188983 for ; Sun, 23 Feb 2020 02:06:03 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=TWyfhHLgDFuCeIPb9IzkuLzRLs3o0Ydy+jTeH3Qka0I=; b=YX9tmH1NHU0h1d5jJ8tiWJK6rDH1C9K9LLUJCEGQr9OQVhXejfEmTHEbUrjwRlJ+K4Fi lrNvj03bZc3FXxsxEdLNgPf/9UStZxQcg97zyelKzT4oxHlhQPKWfMr/EYU1mQMwK3ev /pUoKPtImZwzfFECJbnla8SiE8fUal1bDDie/h81WJplVu1iuwaHq+9t4x25bpPN935m 83QLtngbhDMXdZka92x1N5M6lQlGGIIOJ1xCeZNGZ0qgH3JWlwVkAn5uXOl3wvaPZueO QsHnU5xWXa06RdkDXeSY3wPzdYm/Unj1Aryhl2TkqRyy4pFvD2gCCVZjfSIqpz+f5Kb/ gg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2yauqu21x0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:03 +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 01N1wG48054340 for ; Sun, 23 Feb 2020 02:06:02 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2ybe38mctq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:02 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01N261fD028804 for ; Sun, 23 Feb 2020 02:06:01 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:00 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 04/20] xfsprogs: Add xfs_has_attr and subroutines Date: Sat, 22 Feb 2020 19:05:38 -0700 Message-Id: <20200223020554.1731-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=4 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 bulkscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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 --- libxfs/xfs_attr.c | 170 ++++++++++++++++++++++++++++++++----------------- libxfs/xfs_attr.h | 1 + libxfs/xfs_attr_leaf.c | 111 ++++++++++++++++++++------------ libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 187 insertions(+), 98 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 4fe27f1..9d4c79a 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -45,6 +45,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. @@ -52,6 +53,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); @@ -309,6 +312,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 @@ -582,26 +616,20 @@ 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, -1, &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 ((args->name.type & ATTR_REPLACE) && (retval == -ENOATTR)) { xfs_trans_brelse(args->trans, bp); return retval; @@ -753,6 +781,27 @@ xfs_attr_leaf_addname( } /* + * 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, -1, 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 @@ -772,12 +821,10 @@ xfs_attr_leaf_removename( * Remove the attribute. */ dp = args->dp; - args->blkno = 0; - error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp); - if (error) + error = xfs_attr_leaf_hasname(args, &bp); + if (error != -ENOATTR && error != -EEXIST) return error; - error = xfs_attr3_leaf_lookup_int(bp, args); if (error == -ENOATTR) { xfs_trans_brelse(args->trans, bp); return error; @@ -816,12 +863,10 @@ 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, -1, &bp); - if (error) + error = xfs_attr_leaf_hasname(args, &bp); + if (error != -ENOATTR && error != -EEXIST) return error; - error = xfs_attr3_leaf_lookup_int(bp, args); if (error != -EEXIST) { xfs_trans_brelse(args->trans, bp); return error; @@ -831,6 +876,41 @@ xfs_attr_leaf_get(xfs_da_args_t *args) 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; + return retval; + } + + xfs_da_state_free(state); + + return error; +} + /*======================================================================== * External routines when attribute list size > geo->blksize *========================================================================*/ @@ -863,20 +943,17 @@ 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 ((args->name.type & ATTR_REPLACE) && (retval == -ENOATTR)) { + if (retval == -ENOATTR && args->name.type & ATTR_REPLACE) { goto out; } else if (retval == -EEXIST) { if (args->name.type & ATTR_CREATE) @@ -1078,29 +1155,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. @@ -1195,7 +1258,8 @@ xfs_attr_node_removename( error = 0; out: - xfs_da_state_free(state); + if (state) + xfs_da_state_free(state); return error; } @@ -1317,31 +1381,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. @@ -1353,7 +1409,7 @@ out_release: } xfs_da_state_free(state); - return retval; + return error; } /* Returns true if the attribute entry name is valid. */ diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 44dd07a..3b5dad4 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -150,6 +150,7 @@ int xfs_attr_set(struct xfs_inode *dp, struct xfs_name *name, 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, struct xfs_name *name, int flags); +int xfs_has_attr(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); diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 1389970..542315e 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -586,18 +586,66 @@ 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 (sfe->namelen != args->name.len) + continue; + if (memcmp(sfe->nameval, args->name.name, args->name.len) != 0) + continue; + if (!xfs_attr_namesp_match(args->name.type, 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); @@ -608,18 +656,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++) { -#ifdef DEBUG - if (sfe->namelen != args->name.len) - continue; - if (memcmp(args->name.name, sfe->nameval, args->name.len) != 0) - continue; - if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) - continue; - ASSERT(0); -#endif - } + error = xfs_attr_sf_findname(args, &sfe, NULL); + ASSERT(error != -EEXIST); offset = (char *)sfe - (char *)sf; size = XFS_ATTR_SF_ENTSIZE_BYNAME(args->name.len, args->valuelen); @@ -662,35 +700,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 (sfe->namelen != args->name.len) - continue; - if (memcmp(sfe->nameval, args->name.name, args->name.len) != 0) - continue; - if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) - continue; - 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 7b74e18..736a9ba 100644 --- a/libxfs/xfs_attr_leaf.h +++ b/libxfs/xfs_attr_leaf.h @@ -39,6 +39,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 Sun Feb 23 02:05: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: 11398507 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 BB3C61395 for ; Sun, 23 Feb 2020 02:06:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 93CCB206EF for ; Sun, 23 Feb 2020 02:06:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="hn02iMjp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727148AbgBWCGE (ORCPT ); Sat, 22 Feb 2020 21:06:04 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:56178 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726965AbgBWCGE (ORCPT ); Sat, 22 Feb 2020 21:06:04 -0500 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 01N21gdZ008714 for ; Sun, 23 Feb 2020 02:06:02 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=24y04A8xDIj2KxruRIH9zBKTJYk/j8Zq5KvPvWJShm4=; b=hn02iMjpVXomfqTpK3vtQxH9IAwE9nuBxn4tt6Q/iqX87XRzLa0WjobfzDnFKG3M3/f1 1cVOn/KliBft5yl7aPqyITEOk1zphmKiBS8eI0Jrv/sqBRpaOV/YdcdRUCOCJ5g+mn4U 2og+UtINeU/OyfSkujUKZDO3PyFzldl/DAa6oPMbYuvKfzyA2gFykO/XwzuxKVzFOIda XRbFTy0JOfhFAWnNq+VlaZT1K7USuKNI9uRwbM4EQzPWhySyTTBpEWjW/6CITAL2OgLq 3X8xTWrUyLWer+M/4fkzelc32ExoxRQsyg0wriv2fMVFHzgk6A8hLa965ez63GQzY/Cn HQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2yav8qa0sb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:02 +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 01N1x9wV081964 for ; Sun, 23 Feb 2020 02:06:01 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2ybe0wr0r0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:01 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01N261Jq028809 for ; Sun, 23 Feb 2020 02:06:01 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:01 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 05/20] xfsprogs: Check for -ENOATTR or -EEXIST Date: Sat, 22 Feb 2020 19:05:39 -0700 Message-Id: <20200223020554.1731-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 impostorscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 9d4c79a..73d656c 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -436,6 +436,14 @@ xfs_attr_set( goto out_trans_cancel; xfs_trans_ijoin(args.trans, dp, 0); + + error = xfs_has_attr(&args); + if (error == -EEXIST && (name->type & ATTR_CREATE)) + goto out_trans_cancel; + + if (error == -ENOATTR && (name->type & ATTR_REPLACE)) + goto out_trans_cancel; + error = xfs_attr_set_args(&args); if (error) goto out_trans_cancel; @@ -524,6 +532,10 @@ xfs_attr_remove( */ xfs_trans_ijoin(args.trans, dp, 0); + error = xfs_has_attr(&args); + if (error != -EEXIST) + goto out; + error = xfs_attr_remove_args(&args); if (error) goto out; From patchwork Sun Feb 23 02:05: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: 11398513 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 4EE7E18EC for ; Sun, 23 Feb 2020 02:06:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F30B206EF for ; Sun, 23 Feb 2020 02:06:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="gaEpTxuX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727091AbgBWCGF (ORCPT ); Sat, 22 Feb 2020 21:06:05 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:45978 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727074AbgBWCGE (ORCPT ); Sat, 22 Feb 2020 21:06:04 -0500 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 01N22V2d180074 for ; Sun, 23 Feb 2020 02:06:02 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=4uXZaTfC+xSruWapeRW85nuzhMnDHYmwymON1sltl7s=; b=gaEpTxuXH3ws5NYP6bJVBQu8DpfGXMfW4Oox2UYen6UUrk+BlxRhojLt+p/2vaneoW3h o5Lxq74NvHuh2CaCjQoY1g0RJAsrcJLu2p6R1cpX6dcd2geWD/8eTUos/4MRrlksRolP vzyhAJU0e+/5YULD2cHhvbgm2wqqp3R2JELjgmfzUKejkQSMG1WvgHKnDp0riZqg9din z91nMEJ9svyct3x0ElFL8oFjIn3ltsAezggwHQJi6cV3HP62PAcqg6vjr4xX4R5jPRVc OzAtFX4KmiqBoIhwDPsoB1F7cdiJMD/9CbDK3+ymfx3NEjmD4duis//jLzFLZd/55pVQ ew== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2yavxr9yyf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:02 +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 01N1w54B146404 for ; Sun, 23 Feb 2020 02:06:02 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2ybdsd6q1y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:02 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01N261kn004461 for ; Sun, 23 Feb 2020 02:06:01 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:01 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 06/20] xfsprogs: Factor out new helper functions xfs_attr_rmtval_set Date: Sat, 22 Feb 2020 19:05:40 -0700 Message-Id: <20200223020554.1731-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 spamscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 suspectscore=1 bulkscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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 --- 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 0cadc82..edd6e90 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -422,32 +422,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, @@ -455,48 +446,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 @@ -550,6 +519,72 @@ xfs_attr_rmtval_set( } /* + * 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 Sun Feb 23 02:05: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: 11398519 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 E0C27109A for ; Sun, 23 Feb 2020 02:06:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B754C206EF for ; Sun, 23 Feb 2020 02:06:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="LBnhZhlW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727158AbgBWCGF (ORCPT ); Sat, 22 Feb 2020 21:06:05 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45624 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727103AbgBWCGF (ORCPT ); Sat, 22 Feb 2020 21:06:05 -0500 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 01N21xGi189683 for ; Sun, 23 Feb 2020 02:06:03 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=iNiVstc7sFFoD8fxQ0zRtOd9G4YpbO91xEtyZ5Wi5QU=; b=LBnhZhlWEKm1ngDF1Tq+FgVbYz7474KEKsrpdZPzh4VF5NUSk/j/pyjjtny+HhPus5o4 6hZAbnaEFpDCLw+GrPCS7OCFgKLammkmt+1hvYebyqDSAxxpbK/khqc1WDpHC4AdCR0z eycYHV3eU8dL+UF7xZQJ9v2EDMdyQtNJxQWXFhenBqynkVFCLa9r3UUYh4Onij3LHLQg YVEsxtyCYngKyUmikl8HOxXb0jvN34F5Yq9SmVbfRK3ftycIFuBpOo7EsM9qtc9Wlvfx w3CGOtG2oDybEruI/pajqWURd9YmOOPM39iNmqy4v2kTVC1jOJGgi7EeqsX4c2mgslbU SQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2yauqu21x1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:03 +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 01N1wP2G054410 for ; Sun, 23 Feb 2020 02:06:02 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2ybe38mcw7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:02 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01N261DG004466 for ; Sun, 23 Feb 2020 02:06:01 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:01 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 07/20] xfsprogs: Factor out trans handling in xfs_attr3_leaf_flipflags Date: Sat, 22 Feb 2020 19:05:41 -0700 Message-Id: <20200223020554.1731-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 bulkscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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 --- 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 73d656c..8fb1c0b 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -738,6 +738,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 @@ -1079,6 +1086,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 542315e..b4be417 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2899,10 +2899,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 Sun Feb 23 02:05: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: 11398521 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 158B018EC for ; Sun, 23 Feb 2020 02:06:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA54620702 for ; Sun, 23 Feb 2020 02:06:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="t893LFsw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727159AbgBWCGF (ORCPT ); Sat, 22 Feb 2020 21:06:05 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:45998 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727136AbgBWCGF (ORCPT ); Sat, 22 Feb 2020 21:06:05 -0500 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 01N22UNZ180011 for ; Sun, 23 Feb 2020 02:06:04 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=9ziw+5FpurC+XPOTnx2ZQmYud8VebwdODfh26kfGdfw=; b=t893LFswsnM1fy+nPNpv21VMZrqMSNrTVq8yCvOVJs7SAME2GxHN2RAplrIPBl59iIt+ VYShjLWXGmwxlhEUH6XIgBVXF5nFHwm82YKM9E67DyIHxyGe01Ktuf5pEBPHl8cI/0A+ F3ndu7i8R5pgzRn3oxjS2Q00rxwy765Ce3CJTwHLnoqA7Jes93hzt32AaSgNKHoEvrC3 zRHSeiUuVO3EoY7LWVgVrg3PwzRnuKpm2Y7OH/ndFZ2hAL7YiuW6wMppLp2kaEsoS+// xegS6ylUH909nkpnWgG3E0p71J1r6ryj7v6duOIGGjS43P5joSINflC/O0Q5KSW9Yv5h 2Q== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2yavxr9yyj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:03 +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 01N1wSZF171980 for ; Sun, 23 Feb 2020 02:06:03 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2ybdure43d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:03 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01N262hI004469 for ; Sun, 23 Feb 2020 02:06:02 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:01 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 08/20] xfsprogs: Factor out xfs_attr_leaf_addname helper Date: Sat, 22 Feb 2020 19:05:42 -0700 Message-Id: <20200223020554.1731-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 suspectscore=1 bulkscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Factor out new helper function xfs_attr_leaf_try_add. Because new delayed attribute routines cannot roll transactions, we carve 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 --- libxfs/xfs_attr.c | 88 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 8fb1c0b..834fd2f 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -304,10 +304,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; } @@ -619,20 +639,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 @@ -678,31 +699,36 @@ 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; +} - /* - * 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 From patchwork Sun Feb 23 02:05: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: 11398517 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 AC63F1395 for ; Sun, 23 Feb 2020 02:06:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 829F7206EF for ; Sun, 23 Feb 2020 02:06:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="uSsK/YB7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726983AbgBWCGF (ORCPT ); Sat, 22 Feb 2020 21:06:05 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:45990 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727093AbgBWCGE (ORCPT ); Sat, 22 Feb 2020 21:06:04 -0500 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 01N22WEd180135 for ; Sun, 23 Feb 2020 02:06:03 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=AVUthJws882Wi2XoMKZRzcYjgxiKfcH29U4fx94kNog=; b=uSsK/YB76+YLMTJtgbQzhc3dQINZmZjP+pfWTPM9Y9ZZHA/o8kzLU2Shysxk2/SL0eYI 4UYCE/JGt7CbmdALyF3841OaUKILddTQ38cwurswt1zhROfuq66+Upc48qOSulD3FhY7 VtpgTFA2Rp1Tu2upvh9p4zBG0tsY+Vs9f3KMPLCqLM6BQwD7qJzQl/Fv3PAt+evj/Yul J3C1fhce2nGB75rPDbrZifjnMOH/0pztjOUBpWDIivquI0UYEclVcFJMCZes7Jtf0xZZ EZVQqltLlzJo4FfdxZeiYHoqtYipMb7qr2jHVlT0tr8uYf4aeVe7xzmJ+hH8oOgmfRUo Kg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2yavxr9yyg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:03 +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 01N1wJmh054360 for ; Sun, 23 Feb 2020 02:06:02 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2ybe38mcx5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:02 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01N262AD013071 for ; Sun, 23 Feb 2020 02:06:02 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:02 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 09/20] xfsprogs: Refactor xfs_attr_try_sf_addname Date: Sat, 22 Feb 2020 19:05:43 -0700 Message-Id: <20200223020554.1731-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 suspectscore=1 bulkscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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 transacation 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 --- 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 834fd2f..760ced0 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -226,8 +226,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) @@ -240,12 +245,10 @@ xfs_attr_try_sf_addname( if (!error && (args->name.type & ATTR_KERNOTIME) == 0) 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; } /* @@ -257,7 +260,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, @@ -268,17 +271,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 Sun Feb 23 02:05: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: 11398523 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 3FA3317F0 for ; Sun, 23 Feb 2020 02:06:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F7CB206EF for ; Sun, 23 Feb 2020 02:06:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="byQwn02a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727103AbgBWCGF (ORCPT ); Sat, 22 Feb 2020 21:06:05 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45626 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727115AbgBWCGF (ORCPT ); Sat, 22 Feb 2020 21:06:05 -0500 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 01N21D72189074 for ; Sun, 23 Feb 2020 02:06:04 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=ym5ndkS5h+d0THrmxJSpf2VCIBY7iy43tXUNjakOl6M=; b=byQwn02aGQbe6ril9JgdQgxjVMAqt8BeWwnFxWrHw9qAWcKu3hbp30Px6H9wxBQhIZRE zmibcF+NfBsYcp0l2M5bULUWT9V0gBv2yu5m1+gsIhjADP8RlIoY6a8yPorb4ZMW9kdT IePKgE7vg0U+vsWoM0bhGLRiFE6iHGq55l+a6oBEZ9xtoafSB2XaHcZGRD6vdB+CVPNb 2I9EDWpJTMthP06h0iVYVyrA3LYnKeGzids+X2hs3QFkNPGciNX2+URVa8ePi5R6YTrL L2+IZ2DUpoHb0CsYoBZAEI2B0ojtpzvGKcXxK0XIDhbq1LYsNPr5EYDszDVNANMasVAU iA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2yauqu21x2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:03 +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 01N1x3Op055128 for ; Sun, 23 Feb 2020 02:06:03 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2ybe38mcy1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:03 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01N262a5031327 for ; Sun, 23 Feb 2020 02:06:02 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:02 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 10/20] xfsprogs: Factor out trans roll from xfs_attr3_leaf_setflag Date: Sat, 22 Feb 2020 19:05:44 -0700 Message-Id: <20200223020554.1731-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=959 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 bulkscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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 factor them up into the calling functions Signed-off-by: Allison Collins Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- 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 760ced0..135cb7e 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1242,6 +1242,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 b4be417..89ceb20 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2781,10 +2781,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 Sun Feb 23 02:05: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: 11398529 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 C401218EC for ; Sun, 23 Feb 2020 02:06:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A3E68206EF for ; Sun, 23 Feb 2020 02:06:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="zNHD4sp4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727163AbgBWCGG (ORCPT ); Sat, 22 Feb 2020 21:06:06 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:56204 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727100AbgBWCGF (ORCPT ); Sat, 22 Feb 2020 21:06:05 -0500 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 01N21cHJ008549 for ; Sun, 23 Feb 2020 02:06:03 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=nBLNyizBq54cFaDmpHWxvOIzM1aO6unbh3Tvk8D/BBg=; b=zNHD4sp4GflwZJj0m/j5tXDNDjTeOLn6Ghcyv4cSLeNAbXRCS76FPgECem4tgeYV7pSr xqVlvL+oOuaLir8Gc3nkFcXG/bbIn2alWQjCBD9zsjtZsnKl4T4erpdY0JvRaYPAAFlh hcx8JcWmseL7fuHyZSIQYZmltypdapiCz+bGT0utG130t8p2RQB4FThGDNvs5ylVGtWz 0JkvNTENQTVRmcSwwm627h0aMkFzNfnR+7ms0Lx+0M8SdmKf3rDCphjCpEs5AkuAEd3I IJaGdof39bvmckNpVPdBx7dOOmom3rFM2Q3qpg2aKP4APncUBleq0tpFWGAHcKrBlxEL yw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2yav8qa0sf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:03 +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 01N1we3K054527 for ; Sun, 23 Feb 2020 02:06:03 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2ybe38mcyt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:03 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01N262ED013074 for ; Sun, 23 Feb 2020 02:06:02 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:02 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 11/20] xfsprogs: Factor out xfs_attr_rmtval_invalidate Date: Sat, 22 Feb 2020 19:05:45 -0700 Message-Id: <20200223020554.1731-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 impostorscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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 --- 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 edd6e90..cfeca71 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -589,16 +589,13 @@ 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) { struct xfs_mount *mp = args->dp->i_mount; 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. @@ -640,13 +637,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 9d20b66..85f2593 100644 --- a/libxfs/xfs_attr_remote.h +++ b/libxfs/xfs_attr_remote.h @@ -11,5 +11,5 @@ int xfs_attr3_rmt_blocks(struct xfs_mount *mp, int attrlen); int xfs_attr_rmtval_get(struct xfs_da_args *args); int xfs_attr_rmtval_set(struct xfs_da_args *args); int xfs_attr_rmtval_remove(struct xfs_da_args *args); - +int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); #endif /* __XFS_ATTR_REMOTE_H__ */ From patchwork Sun Feb 23 02:05: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: 11398527 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 9AAF6109A for ; Sun, 23 Feb 2020 02:06:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7AE2A206EF for ; Sun, 23 Feb 2020 02:06:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="tSCjNcMx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727136AbgBWCGG (ORCPT ); Sat, 22 Feb 2020 21:06:06 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:56206 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727133AbgBWCGF (ORCPT ); Sat, 22 Feb 2020 21:06:05 -0500 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 01N21lFQ008956 for ; Sun, 23 Feb 2020 02:06:04 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=/4JDctO3wmaKJ94jyQsKyCct2rt9vIBYYQLRs3PaFJg=; b=tSCjNcMxdc3GYvXwFdXONBeOQs3TFtVfB9fxyFc7fXLp1zcSNHwCD5lEj7U7vNiX6Hxu qgo6DGMrtpMkpo54vU74AM5q0H37eheASbv0faLhJvTakm169fFrpAfSqsEB6KKt8t7D AqhFSh0Jdcr8KEQ0cFArf7LQywkWLBaXUvcM5vzkfAdwpf7Ym7Ek8Q7yPWkpEzjVaJGO ivzzVwbqXQL6wBX3ioNHRjt81x59QSF1OkB4oIGgwnz22UhcgAtcAUH8/Ub6vz7JQspc WCLjlhhxg4rlzPGGizqiG0oUvvPw/xROpx8qKNS4NPe59bN9hRL7Ck2+dql2TjB9AMIc 8Q== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2yav8qa0sg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:03 +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 01N201Kp173471 for ; Sun, 23 Feb 2020 02:06:03 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2ybdure445-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:03 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01N2632w031335 for ; Sun, 23 Feb 2020 02:06:03 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:03 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 12/20] xfsprogs: Factor out trans roll in xfs_attr3_leaf_clearflag Date: Sat, 22 Feb 2020 19:05:46 -0700 Message-Id: <20200223020554.1731-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 impostorscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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 factor them out into the calling functions Signed-off-by: Allison Collins Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong --- 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 135cb7e..15b52e2 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -821,6 +821,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; } @@ -1183,6 +1191,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 89ceb20..e14b3f4 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2730,10 +2730,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 Sun Feb 23 02:05: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: 11398539 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 B2EFD109A for ; Sun, 23 Feb 2020 02:06:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 924BE206EF for ; Sun, 23 Feb 2020 02:06:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="gKkNfz+D" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727115AbgBWCGH (ORCPT ); Sat, 22 Feb 2020 21:06:07 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:46018 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727093AbgBWCGG (ORCPT ); Sat, 22 Feb 2020 21:06:06 -0500 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 01N230pV180425 for ; Sun, 23 Feb 2020 02:06: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=IhR3sA0OKGtR0SMyeH+Wru/7f24hNoPURSQf6of/kPg=; b=gKkNfz+D7zll4jr7+DN3yhHSxfTrpZVcsjrutcvmD5y4UQqAOISlx6156YP5mu9kQN8L xC0rDkAD/r2cRq51+0ziPwpzhOeK9KF0G/Vg0E9wFMgJgG9po+Woja6YU9EQoFRwyp+g 1usWD3dHfu4O0xZMSEYCpcibu92Pv9sKnpW+Z1EnWmh31bbPAj5MDMr+mro1BSk+94WU iHZHhmBqPQRE7NevSrRpBWzuP2tS1PxcZ4JnDAkmGxFu/5iU9BZNV5tsE2LynnHF7tlk U1haM1Itho0cPgZLrEmqrgm1iOXw9yh0W2HSjOF7jyr2Xj5kL9Maz19Awdf7XczBO+cE 6w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2yavxr9yym-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:05 +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 01N1w54C146404 for ; Sun, 23 Feb 2020 02:06:05 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2ybdsd6q34-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:04 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01N263Xm013077 for ; Sun, 23 Feb 2020 02:06:03 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:03 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 13/20] xfsprogs: Add helper function xfs_attr_rmtval_unmap Date: Sat, 22 Feb 2020 19:05:47 -0700 Message-Id: <20200223020554.1731-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 spamscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 suspectscore=1 bulkscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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 Signed-off-by: Allison Collins --- libxfs/xfs_attr_remote.c | 28 ++++++++++++++++++++++++++++ libxfs/xfs_attr_remote.h | 1 + 2 files changed, 29 insertions(+) diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index cfeca71..5b92f2d 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -681,3 +681,31 @@ 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_unmap( + struct xfs_da_args *args) +{ + int error, done; + + /* + * Unmap value blocks for this attr. This is similar to + * xfs_attr_rmtval_remove, but open coded here to return EAGAIN + * for new transactions + */ + 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 85f2593..7ab3770 100644 --- a/libxfs/xfs_attr_remote.h +++ b/libxfs/xfs_attr_remote.h @@ -12,4 +12,5 @@ int xfs_attr_rmtval_get(struct xfs_da_args *args); int xfs_attr_rmtval_set(struct xfs_da_args *args); int xfs_attr_rmtval_remove(struct xfs_da_args *args); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); +int xfs_attr_rmtval_unmap(struct xfs_da_args *args); #endif /* __XFS_ATTR_REMOTE_H__ */ From patchwork Sun Feb 23 02:05:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11398545 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 44EB31395 for ; Sun, 23 Feb 2020 02:06:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 244A8206EF for ; Sun, 23 Feb 2020 02:06:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="K9yuJTey" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727074AbgBWCGI (ORCPT ); Sat, 22 Feb 2020 21:06:08 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45638 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727151AbgBWCGH (ORCPT ); Sat, 22 Feb 2020 21:06:07 -0500 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 01N21DVa189059 for ; Sun, 23 Feb 2020 02:06: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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=A4NjDhH5vAtQV1i/SalJeICyXiPcfVICJ8MWByZAY7I=; b=K9yuJTeyx03uNCIzXWsNZCsX4kOSIAieXhGnLFkKaCv5lWtN+1Rri0oL9v3s54j5J2Rt O500hlO9eOLvuXQ+9GTp+ruM9yfkUP5dzHlqXAKfxVTDc/Ad3epoc38mBmeYGnyu7ALI 1C4jI0avvZppgSeSz7AQ3UFDK+DPAxR8RNzrd6g0BmdX9hAbO7MDgFvpL2KHiCjmFnZO EK5yBSECA3icaABm32YXB5yY82efDu+sG6xtpUh8RYgYxmj67U9dVc3ZMmN0GGWKYndq /HStvj2xT/I1Yhu9wusYtXqz56kRZfA7TpvOTwVDZ8rssX8BAkn6I/q9rEfpJ1ti6gT4 iw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2yauqu21x5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:05 +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 01N1w2TG146348 for ; Sun, 23 Feb 2020 02:06:04 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2ybdsd6q3a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:04 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01N263r4031340 for ; Sun, 23 Feb 2020 02:06:03 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:03 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 14/20] xfsprogs: Add delay ready attr remove routines Date: Sat, 22 Feb 2020 19:05:48 -0700 Message-Id: <20200223020554.1731-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 spamscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 bulkscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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. 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 | 114 +++++++++++++++++++++++++++++++++++++++++++------- libxfs/xfs_attr.h | 1 + libxfs/xfs_da_btree.h | 30 +++++++++++++ 3 files changed, 129 insertions(+), 16 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 15b52e2..6b6b02b 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -367,11 +367,60 @@ xfs_has_attr( */ int xfs_attr_remove_args( + struct xfs_da_args *args) +{ + int error = 0; + int err2 = 0; + + do { + error = xfs_attr_remove_iter(args); + if (error && error != -EAGAIN) + goto out; + + if (args->dac.flags & XFS_DAC_FINISH_TRANS) { + args->dac.flags &= ~XFS_DAC_FINISH_TRANS; + + err2 = xfs_defer_finish(&args->trans); + if (err2) { + error = err2; + goto out; + } + } + + err2 = xfs_trans_roll_inode(&args->trans, args->dp); + if (err2) { + error = err2; + goto out; + } + + } while (error == -EAGAIN); +out: + 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_da_args *args) { struct xfs_inode *dp = args->dp; int error; + /* State machine switch */ + switch (args->dac.dela_state) { + case XFS_DAS_RM_SHRINK: + case XFS_DAS_RMTVAL_REMOVE: + goto node; + default: + break; + } + if (!xfs_inode_hasattr(dp)) { error = -ENOATTR; } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { @@ -380,6 +429,7 @@ xfs_attr_remove_args( } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { error = xfs_attr_leaf_removename(args); } else { +node: error = xfs_attr_node_removename(args); } @@ -893,9 +943,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; + + args->dac.flags |= XFS_DAC_FINISH_TRANS; } return 0; } @@ -1216,6 +1265,11 @@ out: * 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( @@ -1228,10 +1282,24 @@ xfs_attr_node_removename( struct xfs_inode *dp = args->dp; trace_xfs_attr_node_removename(args); + state = args->dac.da_state; + blk = args->dac.blk; + + /* State machine switch */ + switch (args->dac.dela_state) { + case XFS_DAS_RMTVAL_REMOVE: + goto rm_node_blks; + case XFS_DAS_RM_SHRINK: + goto rm_shrink; + default: + break; + } error = xfs_attr_node_hasname(args, &state); if (error != -EEXIST) goto out; + else + error = 0; /* * If there is an out-of-line value, de-allocate the blocks. @@ -1241,6 +1309,14 @@ xfs_attr_node_removename( blk = &state->path.blk[ state->path.active-1 ]; 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 + */ + args->dac.blk = blk; + args->dac.da_state = state; + if (args->rmtblkno > 0) { /* * Fill in disk block numbers in the state structure @@ -1259,13 +1335,21 @@ xfs_attr_node_removename( if (error) goto out; - error = xfs_trans_roll_inode(&args->trans, args->dp); + error = xfs_attr_rmtval_invalidate(args); if (error) goto out; + } - error = xfs_attr_rmtval_remove(args); - if (error) - goto out; +rm_node_blks: + + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_unmap(args); + + if (error) { + if (error == -EAGAIN) + args->dac.dela_state = XFS_DAS_RMTVAL_REMOVE; + return error; + } /* * Refill the state structure with buffers, the prior calls @@ -1291,17 +1375,15 @@ 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; + + args->dac.flags |= XFS_DAC_FINISH_TRANS; + args->dac.dela_state = XFS_DAS_RM_SHRINK; + return -EAGAIN; } +rm_shrink: + args->dac.dela_state = XFS_DAS_RM_SHRINK; + /* * If the result is small enough, push it all into the inode. */ diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 3b5dad4..f6ac571 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -152,6 +152,7 @@ int xfs_attr_set_args(struct xfs_da_args *args); int xfs_attr_remove(struct xfs_inode *dp, struct xfs_name *name, int flags); 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_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); diff --git a/libxfs/xfs_da_btree.h b/libxfs/xfs_da_btree.h index bed4f40..0967564 100644 --- a/libxfs/xfs_da_btree.h +++ b/libxfs/xfs_da_btree.h @@ -43,9 +43,39 @@ enum xfs_dacmp { }; /* + * Enum values for xfs_delattr_context.da_state + * + * These values are used by delayed attribute operations to keep track of where + * they were before they returned -EAGAIN. A return code of -EAGAIN signals the + * calling function to roll the transaction, and then recall the subroutine to + * finish the operation. The enum is then used by the subroutine to jump back + * to where it was and resume executing where it left off. + */ +enum xfs_delattr_state { + XFS_DAS_RM_SHRINK, /* We are shrinking the tree */ + XFS_DAS_RMTVAL_REMOVE, /* We are removing remote value blocks */ +}; + +/* + * Defines for xfs_delattr_context.flags + */ +#define XFS_DAC_FINISH_TRANS 0x1 /* indicates to finish the transaction */ + +/* + * Context used for keeping track of delayed attribute operations + */ +struct xfs_delattr_context { + struct xfs_da_state *da_state; + struct xfs_da_state_blk *blk; + unsigned int flags; + enum xfs_delattr_state dela_state; +}; + +/* * Structure to ease passing around component names. */ typedef struct xfs_da_args { + struct xfs_delattr_context dac; /* context used for delay attr ops */ struct xfs_da_geometry *geo; /* da block geometry */ struct xfs_name name; /* name, length and argument flags*/ uint8_t filetype; /* filetype of inode for directories */ From patchwork Sun Feb 23 02:05:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11398543 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 1B19A18EC for ; Sun, 23 Feb 2020 02:06:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E5512206EF for ; Sun, 23 Feb 2020 02:06:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="p/H6irH+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727167AbgBWCGH (ORCPT ); Sat, 22 Feb 2020 21:06:07 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:56226 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727074AbgBWCGH (ORCPT ); Sat, 22 Feb 2020 21:06:07 -0500 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 01N21fNO008663 for ; Sun, 23 Feb 2020 02:06: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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=OfuRHI70NPnjd1bSRCz9hTCKrsgfdB/uRKWCzPVExOE=; b=p/H6irH+fjCrzPaC19ghcUkB/g9q4j01JH+FmvaihmfDpPp7x/tbgYpIJ0h3w6P7i24Y SGiRiYt+5vuzZ5NpSaJVUHarHPYt3KaZXhkkGZZwlAm2JCg/kVChBUqfbAUzvyjkXsIv Ba8SI1rFt1PmDs+6uxC2wUxmz9eCBYggHuTlICzA1b4gkRVsBfXNXBF7ZuKtmJJryzEm T19+4MAvEQnCVGJQhxwCinlBFkwJcNNuaAo1e/ogLXxc8ZsHD1E+S1vBUVTsw6bdZ1bO hZIA8RSY6U4M5hfrODTbdhAGc7OlLxMjRSmbBtIxK7S2UsBlzJLPTNPvXxESspziEy7s Vg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2yav8qa0sh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:04 +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 01N20519056518 for ; Sun, 23 Feb 2020 02:06:04 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2ybe38md39-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:04 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01N2640q031346 for ; Sun, 23 Feb 2020 02:06:04 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:03 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 15/20] xfsprogs: Add delay ready attr set routines Date: Sat, 22 Feb 2020 19:05:49 -0700 Message-Id: <20200223020554.1731-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=3 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 impostorscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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. Part of xfs_attr_leaf_addname has been factored out into a new helper function xfs_attr_leaf_try_add to allow transaction cycling between the two routines. 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. Finally, xfs_attr_set_args has become a simple loop to refresh the transaction until the operation is completed. 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 │ │ │ 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 │ │ old name │ │ │ │ │ v │ └────y── more to │ remove │ │ │ n │ │ │ v │ done <──────┘ Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 369 ++++++++++++++++++++++++++++++----------------- libxfs/xfs_attr.h | 1 + libxfs/xfs_attr_remote.c | 67 ++++++++- libxfs/xfs_attr_remote.h | 4 + libxfs/xfs_da_btree.h | 13 ++ 5 files changed, 319 insertions(+), 135 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 6b6b02b..9d7989c 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -57,6 +57,7 @@ STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); +STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); STATIC int @@ -258,9 +259,86 @@ int xfs_attr_set_args( struct xfs_da_args *args) { + int error = 0; + int err2 = 0; + struct xfs_buf *leaf_bp = NULL; + + do { + error = xfs_attr_set_iter(args, &leaf_bp); + if (error && error != -EAGAIN) + goto out; + + if (args->dac.flags & XFS_DAC_FINISH_TRANS) { + args->dac.flags &= ~XFS_DAC_FINISH_TRANS; + + err2 = xfs_defer_finish(&args->trans); + if (err2) { + error = err2; + goto out; + } + } + + err2 = xfs_trans_roll_inode(&args->trans, args->dp); + if (err2) { + error = err2; + goto out; + } + + if (leaf_bp) { + xfs_trans_bjoin(args->trans, leaf_bp); + xfs_trans_bhold(args->trans, leaf_bp); + } + + } while (error == -EAGAIN); + +out: + 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_da_args *args, + struct xfs_buf **leaf_bp) +{ struct xfs_inode *dp = args->dp; - struct xfs_buf *leaf_bp = NULL; - int error, error2 = 0; + int error = 0; + int sf_size; + + /* State machine switch */ + switch (args->dac.dela_state) { + case XFS_DAS_ADD_LEAF: + goto add_leaf; + case XFS_DAS_ALLOC_LEAF: + case XFS_DAS_FLIP_LFLAG: + case XFS_DAS_FOUND_LBLK: + goto leaf; + case XFS_DAS_FOUND_NBLK: + case XFS_DAS_FLIP_NFLAG: + case XFS_DAS_ALLOC_NODE: + case XFS_DAS_LEAF_TO_NODE: + goto 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->name.len, 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 non-existent or a shortform list, @@ -269,22 +347,20 @@ xfs_attr_set_args( 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; - } + + /* Should only be 0, -EEXIST or ENOSPC */ + if (error != -ENOSPC) + return error; /* * It won't fit in the shortform, transform to a leaf block. * GROT: another possible req'mt for a double-split btree op. */ - error = xfs_attr_shortform_to_leaf(args, &leaf_bp); + error = xfs_attr_shortform_to_leaf(args, leaf_bp); if (error) return error; @@ -292,41 +368,48 @@ xfs_attr_set_args( * 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; - } + xfs_trans_bhold(args->trans, *leaf_bp); + args->dac.flags |= XFS_DAC_FINISH_TRANS; + args->dac.dela_state = XFS_DAS_ADD_LEAF; + return -EAGAIN; } - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_addname(args); - if (error != -ENOSPC) - return error; +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: + args->dac.flags |= XFS_DAC_FINISH_TRANS; + args->dac.dela_state = XFS_DAS_LEAF_TO_NODE; + return -EAGAIN; + case 0: + args->dac.dela_state = XFS_DAS_FOUND_LBLK; + return -EAGAIN; + default: return error; - + } +leaf: + error = xfs_attr_leaf_addname(args); + if (error == -ENOSPC) { + args->dac.dela_state = XFS_DAS_LEAF_TO_NODE; + return -EAGAIN; + } + return error; } - + args->dac.dela_state = XFS_DAS_LEAF_TO_NODE; +node: error = xfs_attr_node_addname(args); return error; } @@ -765,28 +848,29 @@ xfs_attr_leaf_try_add( * * 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) { - int error, forkoff; struct xfs_buf *bp = NULL; + int error, forkoff; 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 - * later routines can manage their own transactions. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; + /* State machine switch */ + switch (args->dac.dela_state) { + case XFS_DAS_FLIP_LFLAG: + goto flip_flag; + case XFS_DAS_ALLOC_LEAF: + goto alloc_leaf; + default: + break; + } /* * If there was an out-of-line value, allocate the blocks we @@ -795,7 +879,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(args); + if (error) + return error; + + /* + * Roll through the "value", allocating blocks on disk as + * required. + */ +alloc_leaf: + while (args->dac.blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(args); + if (error) + return error; + + args->dac.flags |= XFS_DAC_FINISH_TRANS; + args->dac.dela_state = XFS_DAS_ALLOC_LEAF; + return -EAGAIN; + } + + error = xfs_attr_rmtval_set_value(args); if (error) return error; } @@ -814,13 +919,6 @@ 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 @@ -831,8 +929,17 @@ xfs_attr_leaf_addname( args->rmtblkno = args->rmtblkno2; args->rmtblkcnt = args->rmtblkcnt2; args->rmtvaluelen = args->rmtvaluelen2; + + args->dac.dela_state = XFS_DAS_FLIP_LFLAG; + return -EAGAIN; +flip_flag: if (args->rmtblkno) { - error = xfs_attr_rmtval_remove(args); + error = xfs_attr_rmtval_unmap(args); + + /* + * if (error == -EAGAIN), we will repeat this until + * args->rmtblkno is zero + */ if (error) return error; } @@ -851,34 +958,17 @@ xfs_attr_leaf_addname( /* * If the result is small enough, shrink it all into the inode. */ - if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { + forkoff = xfs_attr_shortform_allfit(bp, dp); + if (forkoff) error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); - /* bp is gone due to xfs_da_shrink_inode */ - if (error) - return error; - error = xfs_defer_finish(&args->trans); - if (error) - return error; - } - /* - * Commit the remove and start the next trans in series. - */ - error = xfs_trans_roll_inode(&args->trans, dp); + args->dac.flags |= XFS_DAC_FINISH_TRANS; } else if (args->rmtblkno > 0) { /* * Added a "remote" value, just clear the incomplete flag. */ error = xfs_attr3_leaf_clearflag(args); - if (error) - return error; - - /* - * Commit the flag value change and start the next trans in - * series. - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); } return error; } @@ -1026,16 +1116,22 @@ 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_da_state *state; + struct xfs_da_state *state = NULL; struct xfs_da_state_blk *blk; struct xfs_inode *dp; struct xfs_mount *mp; - int retval, error; + int retval = 0; + int error = 0; trace_xfs_attr_node_addname(args); @@ -1044,7 +1140,19 @@ xfs_attr_node_addname( */ dp = args->dp; mp = dp->i_mount; -restart: + + /* State machine switch */ + switch (args->dac.dela_state) { + case XFS_DAS_FLIP_NFLAG: + goto flip_flag; + case XFS_DAS_FOUND_NBLK: + goto found_nblk; + case XFS_DAS_ALLOC_NODE: + goto alloc_node; + default: + break; + } + /* * Search to see if name already exists, and get back a pointer * to where it should go. @@ -1094,19 +1202,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; + args->dac.flags |= XFS_DAC_FINISH_TRANS; + return -EAGAIN; } /* @@ -1118,9 +1220,7 @@ restart: error = xfs_da3_split(state); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; + args->dac.flags |= XFS_DAC_FINISH_TRANS; } else { /* * Addition succeeded, update Btree hashvals. @@ -1135,13 +1235,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; + args->dac.dela_state = XFS_DAS_FOUND_NBLK; + return -EAGAIN; +found_nblk: /* * If there was an out-of-line value, allocate the blocks we @@ -1150,7 +1246,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(args); + if (error) + return error; + + /* + * Roll through the "value", allocating blocks on disk as + * required. + */ +alloc_node: + while (args->dac.blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(args); + if (error) + return error; + + args->dac.flags |= XFS_DAC_FINISH_TRANS; + args->dac.dela_state = XFS_DAS_ALLOC_NODE; + return -EAGAIN; + } + + error = xfs_attr_rmtval_set_value(args); if (error) return error; } @@ -1169,13 +1285,6 @@ 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 @@ -1186,8 +1295,21 @@ restart: args->rmtblkno = args->rmtblkno2; args->rmtblkcnt = args->rmtblkcnt2; args->rmtvaluelen = args->rmtvaluelen2; + + /* + * Commit the flag value change and start the next trans in + * series + */ + args->dac.dela_state = XFS_DAS_FLIP_NFLAG; + return -EAGAIN; +flip_flag: if (args->rmtblkno) { - error = xfs_attr_rmtval_remove(args); + error = xfs_attr_rmtval_unmap(args); + + /* + * if (error == -EAGAIN), we will repeat this until + * args->rmtblkno is zero + */ if (error) return error; } @@ -1205,7 +1327,6 @@ restart: error = xfs_da3_node_lookup_int(state, &retval); if (error) goto out; - /* * Remove the name and update the hashvals in the tree. */ @@ -1213,7 +1334,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. */ @@ -1221,18 +1341,9 @@ restart: error = xfs_da3_join(state); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; - } - - /* - * Commit and start the next trans in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; + args->dac.flags |= XFS_DAC_FINISH_TRANS; + } } else if (args->rmtblkno > 0) { /* * Added a "remote" value, just clear the incomplete flag. @@ -1240,14 +1351,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; diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index f6ac571..0ba80c9 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -149,6 +149,7 @@ int xfs_attr_get(struct xfs_inode *ip, struct xfs_name *name, int xfs_attr_set(struct xfs_inode *dp, struct xfs_name *name, unsigned char *value, int valuelen, int flags); int xfs_attr_set_args(struct xfs_da_args *args); +int xfs_attr_set_iter(struct xfs_da_args *args, struct xfs_buf **leaf_bp); int xfs_attr_remove(struct xfs_inode *dp, struct xfs_name *name, int flags); int xfs_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 5b92f2d..3ed27e0 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -425,7 +425,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) { @@ -452,7 +452,7 @@ xfs_attr_rmt_find_hole( return 0; } -STATIC int +int xfs_attr_rmtval_set_value( struct xfs_da_args *args) { @@ -585,6 +585,69 @@ xfs_attr_rmtval_set( } /* + * Find a hole for the attr and store it in the delayed attr context. This + * initializes the context to roll through allocating an attr extent for a + * delayed attr operation + */ +int +xfs_attr_rmtval_set_init( + struct xfs_da_args *args) +{ + struct xfs_bmbt_irec *map = &args->dac.map; + int error; + + args->dac.lblkno = 0; + args->dac.lfileoff = 0; + args->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; + + args->dac.blkcnt = args->rmtblkcnt; + args->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_da_args *args) +{ + struct xfs_inode *dp = args->dp; + struct xfs_bmbt_irec *map = &args->dac.map; + int nmap; + int error; + + nmap = 1; + error = xfs_bmapi_write(args->trans, dp, + (xfs_fileoff_t)args->dac.lblkno, + args->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 */ + args->dac.lblkno += map->br_blockcount; + args->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. */ diff --git a/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index 7ab3770..ab03519 100644 --- a/libxfs/xfs_attr_remote.h +++ b/libxfs/xfs_attr_remote.h @@ -13,4 +13,8 @@ int xfs_attr_rmtval_set(struct xfs_da_args *args); int xfs_attr_rmtval_remove(struct xfs_da_args *args); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); int xfs_attr_rmtval_unmap(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_da_args *args); +int xfs_attr_rmtval_set_init(struct xfs_da_args *args); #endif /* __XFS_ATTR_REMOTE_H__ */ diff --git a/libxfs/xfs_da_btree.h b/libxfs/xfs_da_btree.h index 0967564..66ea73c 100644 --- a/libxfs/xfs_da_btree.h +++ b/libxfs/xfs_da_btree.h @@ -54,6 +54,14 @@ enum xfs_dacmp { enum xfs_delattr_state { XFS_DAS_RM_SHRINK, /* 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_ALLOC_NODE, /* We are allocating node blocks */ + XFS_DAS_FLIP_NFLAG, /* Flipped node INCOMPLETE attr flag */ }; /* @@ -65,8 +73,13 @@ enum xfs_delattr_state { * Context used for keeping track of delayed attribute operations */ struct xfs_delattr_context { + 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; }; From patchwork Sun Feb 23 02:05: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: 11398531 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 ECD981921 for ; Sun, 23 Feb 2020 02:06:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD279206EF for ; Sun, 23 Feb 2020 02:06:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Su6MA/dU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727166AbgBWCGG (ORCPT ); Sat, 22 Feb 2020 21:06:06 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:56230 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727156AbgBWCGG (ORCPT ); Sat, 22 Feb 2020 21:06:06 -0500 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 01N21fgP008652 for ; Sun, 23 Feb 2020 02:06: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=J8oEyErwfMljB6kAr+MSnMiKVMAFLGC6WbS82/PRUig=; b=Su6MA/dUB+Ar+yrT1RQ4Hwg+VImb0PnKM4DyLmR+udGLbzijuoiILQ/gF1lFnKcThLnc 1OLTUKlrN5kP0SIparloGSViOID1kzXWXOKZfnBe7wLCTyDd5Eg8AYoprxo6CO7Y0Pd0 MUluJO88cS+MzU4jjlMExEFSXYDnMYpTWH0FgUNel33maO6RCEukLjAGcjNx3t7pV7qB wQACXTbpfc9azHNDFKro/v2aQwd9dF1RIY6nSQWhQZ3+u84sg42qLZLaS6bw/lP6Du0F ntw9n9hqkZta9nZlJAS2lNqsNscaZc48XzGQ7cHq8APzYBNFhqWx+PKPP25PYQQX3vdM IA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2yav8qa0sj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:05 +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 01N1wXWu172168 for ; Sun, 23 Feb 2020 02:06:04 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2ybdure452-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:04 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01N264Z9013080 for ; Sun, 23 Feb 2020 02:06:04 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:04 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 16/20] xfsprogs: Add helper function xfs_attr_node_shrink Date: Sat, 22 Feb 2020 19:05:50 -0700 Message-Id: <20200223020554.1731-17-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=1 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 impostorscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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 | 66 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 9d7989c..e71099c 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1363,6 +1363,43 @@ 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, -1, &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; + + args->dac.flags |= XFS_DAC_FINISH_TRANS; + } 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 @@ -1380,8 +1417,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); @@ -1490,30 +1526,8 @@ rm_shrink: /* * 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, -1, &bp); - if (error) - goto out; - - if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { - error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); - /* bp is gone due to xfs_da_shrink_inode */ - if (error) - goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; - } else - xfs_trans_brelse(args->trans, bp); - } - error = 0; + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) + error = xfs_attr_node_shrink(args, state); out: if (state) From patchwork Sun Feb 23 02:05: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: 11398533 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 2677C17F0 for ; Sun, 23 Feb 2020 02:06:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02240206EF for ; Sun, 23 Feb 2020 02:06:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Ar4CQPVH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727156AbgBWCGH (ORCPT ); Sat, 22 Feb 2020 21:06:07 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:46024 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727115AbgBWCGG (ORCPT ); Sat, 22 Feb 2020 21:06:06 -0500 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 01N22YSs180202 for ; Sun, 23 Feb 2020 02:06: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=zdn0LOG4SWHO/VCZNY4VpXVEEHQxS8mFBUrEXZRbHKA=; b=Ar4CQPVHnO2bGNaRD3pyT6va7b21+oadiQhSjVZSRRh8y3jx0lqcPn55pE3LSDl7+raN J7tGUCIW0MktezVLzrAt5B6blgAQpCpYInlERwmTxfebeHRqdWuNqT8jiNvCcdbZ6qNe vX39WqWGov5wDl1dRn7WAxxFq8/5svXIo02v8xR2qkyk/ZX8HmGTSqPyVi3uIuC5uu6m yTLb3IxZgUW0BGkVSGMoC1l5ho2kgyVyLZnWmJf9oA/VMiCizpLJAOCfTIK/ApF7u62o eNawifaC754nvpkv6TuvV0avu8yoa5RkdQ4hivkFvFE0ozHfOwA8qLTu5+ON4eekdFUv xg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2yavxr9yyn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:05 +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 01N1w2hW146339 for ; Sun, 23 Feb 2020 02:06:05 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2ybdsd6q44-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:05 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01N264e2028915 for ; Sun, 23 Feb 2020 02:06:04 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:04 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 17/20] xfsprogs: Simplify xfs_attr_set_iter Date: Sat, 22 Feb 2020 19:05:51 -0700 Message-Id: <20200223020554.1731-18-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 spamscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 suspectscore=1 bulkscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Delayed attribute mechanics make frequent use of goto statements. We can use this to further simplify xfs_attr_set_iter. Because states tend to fall between if conditions, we can invert the if logic and jump to the goto. This helps to reduce indentation and simplify things. Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 72 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 29 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index e71099c..0635d8b 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -253,6 +253,19 @@ 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_fmt_needs_update( + struct xfs_inode *dp) +{ + return dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL || + (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && + dp->i_d.di_anextents == 0); +} + +/* * Set the attribute specified in @args. */ int @@ -341,39 +354,40 @@ xfs_attr_set_iter( } /* - * 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 (!xfs_attr_fmt_needs_update(dp)) + goto add_leaf; - /* Should only be 0, -EEXIST or ENOSPC */ - if (error != -ENOSPC) - return error; + /* + * Try to add the attr to the attribute list in the inode. + */ + error = xfs_attr_try_sf_addname(dp, args); - /* - * 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; + /* Should only be 0, -EEXIST or ENOSPC */ + if (error != -ENOSPC) + 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. - */ - xfs_trans_bhold(args->trans, *leaf_bp); - args->dac.flags |= XFS_DAC_FINISH_TRANS; - args->dac.dela_state = XFS_DAS_ADD_LEAF; - return -EAGAIN; - } + /* + * 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. + */ + xfs_trans_bhold(args->trans, *leaf_bp); + args->dac.flags |= XFS_DAC_FINISH_TRANS; + args->dac.dela_state = XFS_DAS_ADD_LEAF; + return -EAGAIN; add_leaf: From patchwork Sun Feb 23 02:05: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: 11398541 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 DB87617F0 for ; Sun, 23 Feb 2020 02:06:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB875206EF for ; Sun, 23 Feb 2020 02:06:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ZnD40IOF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727100AbgBWCGH (ORCPT ); Sat, 22 Feb 2020 21:06:07 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45652 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727133AbgBWCGH (ORCPT ); Sat, 22 Feb 2020 21:06:07 -0500 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 01N21nKc189646 for ; Sun, 23 Feb 2020 02:06: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=QG84cIFRd8U2eOU0XRBKRpJtTzoSx/CSs1E7wvXJG2s=; b=ZnD40IOFpEHkrHAG8aFmcLQlNWT6SPWCE7egeUNwF7UJ1Wu3FbCfbTOq1WzHf/TjePjl hcT2dfQ0Q5mhBQOvtd0pfeAPdjpdHl7VKRtR0F9DzHFnSMs/KE2jeYo6oeJoRoijB/bE ZV+2hTYeHyMI5BcCTORKZ7lLvYD26R37ggQeRs82ciYwVfwofIIJzUvTa2quH6emgUpw 7xeqCFO2VZikbN+vSKcdbu4oYxErlUcdjdOWUANtlR6sgzlKt6E1fLp/tRVSDMmDL07E xlRgx7O6wKEwrJvR2Lzk076+Q2bMA08bSUSdch0HOEbHWbGlAC9qyL/pxenFKjh24g+0 yw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2yauqu21x7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:06 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01N1wJmi054360 for ; Sun, 23 Feb 2020 02:06:05 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2ybe38md5s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:05 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01N2644f013083 for ; Sun, 23 Feb 2020 02:06:04 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:04 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 18/20] xfsprogs: Add helper function xfs_attr_leaf_mark_incomplete Date: Sat, 22 Feb 2020 19:05:52 -0700 Message-Id: <20200223020554.1731-19-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 bulkscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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 --- 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 0635d8b..1e6aba6 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1414,6 +1414,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 @@ -1471,20 +1501,7 @@ xfs_attr_node_removename( args->dac.da_state = state; 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 Sun Feb 23 02:05: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: 11398537 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 89B751892 for ; Sun, 23 Feb 2020 02:06:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 690C8206EF for ; Sun, 23 Feb 2020 02:06:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="wEln6Rel" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726984AbgBWCGH (ORCPT ); Sat, 22 Feb 2020 21:06:07 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:46036 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727100AbgBWCGH (ORCPT ); Sat, 22 Feb 2020 21:06:07 -0500 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 01N22V6a180090 for ; Sun, 23 Feb 2020 02:06: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=X2ixPZGWdWdqpVsVEVmmdNzUnQuKrs+ncioarPM43pc=; b=wEln6RelOTMniJJhlE8dtrwaV8UejRGB4rtWTMYXKry/gvAVS1ZzDZHhPqRQuDl24S3E H46TdOv5gTAMy+s8aahrWGQpe/2xcaqWhUpzrvjLhK6lm6YjwHBvW3m32ukIeWO2Phk/ KgwoTHNOwHNjIVJwIsF9GSCozs0KQ/rfiiwCek3vrQoGTslCawU4zQ2lrWZokLdipV/7 h/atpHbijLhs4kjpENudwgGWuBw6JDoFaVtUAI354xuJGhAWGM9/GIKuuE35cUXSbxri ktAAGTvH1ezszmDacVhVTqGOTWNyCRmepNKjUbAz9kimmv6ZHJ+czxpIbvfxrjkB9UAy iA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2yavxr9yys-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:06 +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 01N1w2rn146377 for ; Sun, 23 Feb 2020 02:06:06 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2ybdsd6q49-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:05 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01N265CH031408 for ; Sun, 23 Feb 2020 02:06:05 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:05 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 19/20] xfsprogs: Add remote block helper functions Date: Sat, 22 Feb 2020 19:05:53 -0700 Message-Id: <20200223020554.1731-20-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 spamscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 suspectscore=1 bulkscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 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 redunant code associated with storing and retrieving remote blocks during the attr set operations. Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 1e6aba6..2833726 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -785,6 +785,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_store_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 * @@ -823,11 +847,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_store_rmt_blk(args); /* * clear the remote attr state now that it is saved so that the @@ -938,11 +958,7 @@ alloc_leaf: * 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); args->dac.dela_state = XFS_DAS_FLIP_LFLAG; return -EAGAIN; @@ -1187,11 +1203,7 @@ xfs_attr_node_addname( /* 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_store_rmt_blk(args); /* * clear the remote attr state now that it is saved so that the @@ -1304,11 +1316,7 @@ alloc_node: * 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); /* * Commit the flag value change and start the next trans in From patchwork Sun Feb 23 02:05: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: 11398547 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 700B2109A for ; Sun, 23 Feb 2020 02:06:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E3E8206EF for ; Sun, 23 Feb 2020 02:06:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="lF/I1CJZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727177AbgBWCGK (ORCPT ); Sat, 22 Feb 2020 21:06:10 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:46056 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727133AbgBWCGI (ORCPT ); Sat, 22 Feb 2020 21:06:08 -0500 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 01N22Ti4179973 for ; Sun, 23 Feb 2020 02:06: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=BHXbWCEMHX8ukKpTmQAbJTj52lAvNCpXhJL2tA5euM0=; b=lF/I1CJZlbfKbxYWUQF4U7b24iSprJhqen+ElO3k9+Bsj/lP5VQX6lqgABlOzuAqi0K2 QoglDBHslk9J7ZRCpdQz5jTcmJTdJpEru0jEaUVyfp32wxzd6RmH4u14k6wZNeAsyRRx zwIYZy8m444m0adeJHFlS4fKKDaT1a5CVnLnWlRUQoju9y7JuBPRRzJ8OTGcuREplV0U vvlfFjN73QXRBmkDgFkcEszRPtjG/LLoi+E6LgpzSHM2FOVP/IRtzr95rJQrucB3X+wE 1KfO1YnKfb1KCxwZrNhlf9SLluuq1jKIsVFubXbIYrbMYcIV/yFeFVkTvx6xHPVfQcwj SA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2yavxr9yyv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:07 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01N1wP2H054410 for ; Sun, 23 Feb 2020 02:06:06 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2ybe38md8n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 23 Feb 2020 02:06:06 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01N2650R028919 for ; Sun, 23 Feb 2020 02:06:05 GMT Received: from localhost.localdomain (/67.1.3.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Feb 2020 02:06:05 +0000 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v7 20/20] xfsprogs: Remove xfs_attr_rmtval_remove Date: Sat, 22 Feb 2020 19:05:54 -0700 Message-Id: <20200223020554.1731-21-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200223020554.1731-1-allison.henderson@oracle.com> References: <20200223020554.1731-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9539 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 suspectscore=1 bulkscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002230014 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org xfs_attr_rmtval_remove is no longer used. Clear it out now Signed-off-by: Allison Collins --- libxfs/xfs_attr_remote.c | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 3ed27e0..b5cb21c 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -704,48 +704,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