From patchwork Fri Aug 9 21:37:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087675 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D056113AC for ; Fri, 9 Aug 2019 21:38:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEAAA204BF for ; Fri, 9 Aug 2019 21:38:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0C79205F7; Fri, 9 Aug 2019 21:38:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 245F4204FB for ; Fri, 9 Aug 2019 21:38:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726125AbfHIViR (ORCPT ); Fri, 9 Aug 2019 17:38:17 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50216 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726189AbfHIViR (ORCPT ); Fri, 9 Aug 2019 17:38:17 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYfht071958 for ; Fri, 9 Aug 2019 21:38:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=G4+YSYsSLjUbhScCf0fS+eLFs7mypafCCi1jO610Q64=; b=jwi33uWVnFvCaM01R1xRTQ4ypOx506AQkbrnfWWPnmdEHLcxtjnV3kxOn6svBUUr3eA9 GVJOSMGWXaPY0umcsZUQdp2kn1lwlxZ0EKMGsVpYAblfrtPp8noT/9eOKRq+epMA455y 0U4BJctjoH4KvIJYncMHDchUCwayAA8WgoDTfOnF8oH+tsDgWsuot52ulB4c50wymJku bT9PNW7n0hwzgUsoWMigS9VFLu1RyaHTN1HEpw23QWt0lmDSCDOiu52C9/VYWBgPozmp aYheedMeUD+JycnswnGOiNtCpp4vJFocsEOwCk/z/Q/WGnL86Tw1sODWN96Yna1ujhbj nw== 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-2018-07-02; bh=G4+YSYsSLjUbhScCf0fS+eLFs7mypafCCi1jO610Q64=; b=NQNjdtz2saGZgu+DfZybOZXXpelxIhqxgLBfh59cPTFadN4kznKW/RUbdBIP/UEQLgl3 0sI9zVXMJuaeNpCkioDT66Y/1mBnAF2ajNz83ZrDpdhZtVcAkfToiD7tgDbEXxIWbCJ5 BjbDhFCavmXBxiUk695jbTOL6lETiMsRl7cfhEPnleC94FdMm9K4nPlOl4rH5IG74yqz 0XyaUYf3wpKo35Y3XC9EAV7+gAyDi29F/FtAEbkVVrzUR+SSPQ/ZyL+JXkZM82o6bE2U /IXppsO5XhRJMrF6HeziERjavvN2Fd+lS8Xv+/v7bZAWOkvTA6Tt1hQZCTGPlmRFhq81 WQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2u8hpsa4y3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:16 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LNS4c056351 for ; Fri, 9 Aug 2019 21:38:15 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2u8pj9m4g3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:15 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79LcFrU019305 for ; Fri, 9 Aug 2019 21:38:15 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:14 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 01/19] xfsprogs: Remove all strlen in all xfs_attr_* functions for attr names. Date: Fri, 9 Aug 2019 14:37:46 -0700 Message-Id: <20190809213804.32628-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- db/attrset.c | 5 +++-- libxfs/libxfs_priv.h | 9 ++++++--- libxfs/xfs_attr.c | 12 ++++++++---- libxfs/xfs_attr.h | 8 +++++--- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/db/attrset.c b/db/attrset.c index 5697250..dcedbb9 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,8 @@ 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 c014b28..ef82699 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -614,10 +614,13 @@ 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); diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 41956e5..d730482 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -63,6 +63,7 @@ xfs_attr_args_init( struct xfs_da_args *args, struct xfs_inode *dp, const unsigned char *name, + size_t namelen, int flags) { @@ -75,7 +76,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 */ @@ -121,6 +122,7 @@ int xfs_attr_get( struct xfs_inode *ip, const unsigned char *name, + size_t namelen, unsigned char *value, int *valuelenp, int flags) @@ -134,7 +136,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; @@ -306,6 +308,7 @@ int xfs_attr_set( struct xfs_inode *dp, const unsigned char *name, + size_t namelen, unsigned char *value, int valuelen, int flags) @@ -321,7 +324,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; @@ -410,6 +413,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; @@ -421,7 +425,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 3b0dce0..e677fb0 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -137,11 +137,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 Fri Aug 9 21:37:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087679 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 819671709 for ; Fri, 9 Aug 2019 21:38:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F562204BF for ; Fri, 9 Aug 2019 21:38:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63F0D205F7; Fri, 9 Aug 2019 21:38:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E740204BF for ; Fri, 9 Aug 2019 21:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728245AbfHIViS (ORCPT ); Fri, 9 Aug 2019 17:38:18 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59318 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727910AbfHIViS (ORCPT ); Fri, 9 Aug 2019 17:38:18 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYSj7084525 for ; Fri, 9 Aug 2019 21:38:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=BQdkRfR7XA5ybXiZTwxA+GZzQL2qLjg1xzj1gYK3j0E=; b=MBtaHnr3O5JuAR30omIAj5VQuPO9t1iYwrjo/6ogWpoG1ql1kxO3g2Qth4CE0Zqzc4bB cRfVFNsVqnyWM8VoCx5bygblh0shUghkxOJhYkM6mlKr1uowOf5jaX87AsqpIOcLFw83 pAprGSEFJ7zop8mzlFvPzdEY7KzLV4UaoLgMV6irp8CAUKRj87OYWs0wE5OS2gdT6z58 3ybgYqCbkLeVAUQN6qxvWZVAYmV38oRKjOXgF/bbtgi8QPl9XxzVQdCbkEszTfUFYG4+ uTD1JzobCdyc2Twk62iNsJJ8jz/hcAUxLxkG6HB8YTiscRAx3S8N45UPey06Vr8fkiQ/ Yg== 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-2018-07-02; bh=BQdkRfR7XA5ybXiZTwxA+GZzQL2qLjg1xzj1gYK3j0E=; b=AXIdrYn0l69V4ScaNNrDg2jUGcbS/ne1bVEtyvp4aLh8WGzSRWgFTalhzmhbsZGrDCkY si5CPV2afPT7jBnl/w6/tTbOjsssOVeVByzvVuHE7gFeD7JMEs20M5+/P+yXWf8Hc0ZI BO6zSOGwrV+G5t/rZeD1g4wAh3lZS5/ftpcPqdcYOt4zuMWVwThMv4s50LD7ykYyT8sV ibJ6BY3cYE0QxF/vdxlP5psR0KYIMdVdlwjhWYfEZirq0mdHfAmsy1t85744bPvh4OYQ 4yj5KwDN4Cgfk4R8PP7X9E+VcaqQ4oZ0Yd3Az9LZBvnX7d4oMc07RCNoH9zsBVu/wIEt 2g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2u8hgpa7y1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:16 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LNcwU067993 for ; Fri, 9 Aug 2019 21:38:16 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2u90t814ew-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:16 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x79LcFmf010585 for ; Fri, 9 Aug 2019 21:38:15 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:15 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 02/19] xfsprog: Replace attribute parameters with struct xfs_name Date: Fri, 9 Aug 2019 14:37:47 -0700 Message-Id: <20190809213804.32628-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch replaces the attribute name, length and flags 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 Henderson Signed-off-by: Allison Collins --- db/attrset.c | 14 ++++++++++---- libxfs/libxfs_priv.h | 14 +++++--------- libxfs/xfs_attr.c | 40 ++++++++++++++++------------------------ libxfs/xfs_attr.h | 12 +++++------- 4 files changed, 36 insertions(+), 44 deletions(-) diff --git a/db/attrset.c b/db/attrset.c index dcedbb9..62d5448 100644 --- a/db/attrset.c +++ b/db/attrset.c @@ -69,6 +69,7 @@ attr_set_f( xfs_inode_t *ip = NULL; char *name, *value, *sp; int c, valuelen = 0, flags = 0; + struct xfs_name namep; if (cur_typ == NULL) { dbprintf(_("no current type\n")); @@ -146,8 +147,10 @@ attr_set_f( goto out; } - if (libxfs_attr_set(ip, (unsigned char *)name, strlen(name), - (unsigned char *)value, valuelen, flags)) { + namep.name = (unsigned char *)name; + namep.len = strlen(name); + namep.type = flags; + if (libxfs_attr_set(ip, &namep, (unsigned char *)value, valuelen)) { dbprintf(_("failed to set attr %s on inode %llu\n"), name, (unsigned long long)iocur_top->ino); goto out; @@ -173,6 +176,7 @@ attr_remove_f( xfs_inode_t *ip = NULL; char *name; int c, flags = 0; + struct xfs_name namep; if (cur_typ == NULL) { dbprintf(_("no current type\n")); @@ -222,8 +226,10 @@ attr_remove_f( goto out; } - if (libxfs_attr_remove(ip, (unsigned char *)name, - strlen(name), flags)) { + namep.name = (unsigned char *)name; + namep.len = strlen(name); + namep.type = flags; + if (libxfs_attr_remove(ip, &namep)) { 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 ef82699..31fb406 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -613,15 +613,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 xfs_attr_set(struct xfs_inode *dp, struct xfs_name *name, + unsigned char *value, int valuelen); +int xfs_attr_remove(struct xfs_inode *dp, struct xfs_name *name); 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 d730482..780cc0d 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -62,9 +62,7 @@ STATIC int xfs_attr_args_init( struct xfs_da_args *args, struct xfs_inode *dp, - const unsigned char *name, - size_t namelen, - int flags) + struct xfs_name *name) { if (!name) @@ -74,9 +72,9 @@ 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; - args->namelen = namelen; + args->flags = name->type; + args->name = name->name; + args->namelen = name->len; if (args->namelen >= MAXNAMELEN) return -EFAULT; /* match IRIX behaviour */ @@ -121,11 +119,9 @@ 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) + int *valuelenp) { struct xfs_da_args args; uint lock_mode; @@ -136,7 +132,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); if (error) return error; @@ -307,16 +303,14 @@ 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) + int valuelen) { struct xfs_mount *mp = dp->i_mount; struct xfs_da_args args; struct xfs_trans_res tres; - int rsvd = (flags & ATTR_ROOT) != 0; + int rsvd = (name->type & ATTR_ROOT) != 0; int error, local; XFS_STATS_INC(mp, xs_attr_set); @@ -324,7 +318,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); if (error) return error; @@ -387,7 +381,7 @@ xfs_attr_set( if (mp->m_flags & XFS_MOUNT_WSYNC) xfs_trans_set_sync(args.trans); - if ((flags & ATTR_KERNOTIME) == 0) + if ((name->type & ATTR_KERNOTIME) == 0) xfs_trans_ichgtime(args.trans, dp, XFS_ICHGTIME_CHG); /* @@ -412,9 +406,7 @@ out_trans_cancel: int xfs_attr_remove( struct xfs_inode *dp, - const unsigned char *name, - size_t namelen, - int flags) + struct xfs_name *name) { struct xfs_mount *mp = dp->i_mount; struct xfs_da_args args; @@ -425,7 +417,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); if (error) return error; @@ -446,7 +438,7 @@ xfs_attr_remove( */ error = xfs_trans_alloc(mp, &M_RES(mp)->tr_attrrm, XFS_ATTRRM_SPACE_RES(mp), 0, - (flags & ATTR_ROOT) ? XFS_TRANS_RESERVE : 0, + (name->type & ATTR_ROOT) ? XFS_TRANS_RESERVE : 0, &args.trans); if (error) return error; @@ -469,7 +461,7 @@ xfs_attr_remove( if (mp->m_flags & XFS_MOUNT_WSYNC) xfs_trans_set_sync(args.trans); - if ((flags & ATTR_KERNOTIME) == 0) + if ((name->type & ATTR_KERNOTIME) == 0) xfs_trans_ichgtime(args.trans, dp, XFS_ICHGTIME_CHG); /* diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index e677fb0..764db97 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -136,14 +136,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 xfs_attr_set(struct xfs_inode *dp, struct xfs_name *name, + unsigned char *value, int valuelen); 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 xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize, int flags, struct attrlist_cursor_kern *cursor); From patchwork Fri Aug 9 21:37:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087681 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9557F13AC for ; Fri, 9 Aug 2019 21:38:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83C5A212D9 for ; Fri, 9 Aug 2019 21:38:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7835121C9A; Fri, 9 Aug 2019 21:38:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81808204FB for ; Fri, 9 Aug 2019 21:38:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726727AbfHIViU (ORCPT ); Fri, 9 Aug 2019 17:38:20 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50280 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728240AbfHIViT (ORCPT ); Fri, 9 Aug 2019 17:38:19 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYtpq072340 for ; Fri, 9 Aug 2019 21:38:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=AckHZ8966fg/eTbofbnykpMENpETqIkoodwNc4D90ao=; b=j5J+vGlh3+nmIRGLuRTpKDUMqJ5MohXa/j1dYTNUB1nFY9uPcVBDiAwdWbuVgMB6uQGk fej1ADgQE+PWWZkKT4zBK28aiuaq3VWPyOdtjVrVWVlJyz6bWPZVDg66D1y+pTfzkge0 pwLmEt7hZ6ZHsgQCyH62UOQN4JCGH8tVcJPD9Ou9zH13Ws9vuSTxo9wwZwvslS1EZSvd anghnqmzgwqnd8FX9z6yDCW3RQm99h5NUfEKiE8ScJKnCn4STRahG/bPv+K6HPSm5qjx gBxkvIIPPien66Ww1cIBVtYCBYFUb0ZXlchnat851n9aLfF/0tEuc6QLrZzg87mfmh19 VA== 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-2018-07-02; bh=AckHZ8966fg/eTbofbnykpMENpETqIkoodwNc4D90ao=; b=F5hm+qS7UXaYqppddHQWgyVG9f28rELpW43XVPS7M59GJeHSDmACmPs5mcsvZmQ4uYlW M9xT7uj+mCSY90fJS1/LeCzaxsjaH7NTdAOd7L+rUI42RPfM8XNUwwZpcF4pyGhZKOGk 65L64MME1Kwt3GBzt2D38N6SoiHCLHPL3Rdf8aJofw2mVi1Gk6/5eJnKNI4puDB7FdfL VaIU9MRwZcYcm20kGnX3re36x1fQnicZEkMfZii8sKdYq5FE1Ixza85MHqdW0v/cBsLg RmbxmO+0G+XzwrCJ8k08ibeQLei/BwYbsQ+d7L8GJBU+NadFbaeYjjDlhPjl1ajyoZ6Z CA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2u8hpsa4y9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:17 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LO3MD007966 for ; Fri, 9 Aug 2019 21:38:17 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2u8x1h6w1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:17 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79LcGXE019310 for ; Fri, 9 Aug 2019 21:38:16 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:15 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 03/19] xfsprogs: Set up infastructure for deferred attribute operations Date: Fri, 9 Aug 2019 14:37:48 -0700 Message-Id: <20190809213804.32628-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently attributes are modified directly across one or more transactions. But they are not logged or replayed in the event of an error. The goal of delayed attributes is to enable logging and replaying of attribute operations using the existing delayed operations infrastructure. This will later enable the attributes to become part of larger multi part operations that also must first be recorded to the log. This is mostly of interest in the scheme of parent pointers which would need to maintain an attribute containing parent inode information any time an inode is moved, created, or removed. Parent pointers would then be of interest to any feature that would need to quickly derive an inode path from the mount point. Online scrub, nfs lookups and fs grow or shrink operations are all features that could take advantage of this. This patch adds two new log item types for setting or removing attributes as deferred operations. The xfs_attri_log_item logs an intent to set or remove an attribute. The corresponding xfs_attrd_log_item holds a reference to the xfs_attri_log_item and is freed once the transaction is done. Both log items use a generic xfs_attr_log_format structure that contains the attribute name, value, flags, inode, and an op_flag that indicates if the operations is a set or remove. Signed-off-by: Allison Collins --- libxfs/defer_item.c | 162 +++++++++++++++++++++++++++++++++++++++++++++++- libxfs/libxfs_priv.h | 1 + libxfs/xfs_attr.c | 5 +- libxfs/xfs_attr.h | 25 ++++++++ libxfs/xfs_defer.c | 1 + libxfs/xfs_defer.h | 3 + libxfs/xfs_log_format.h | 44 ++++++++++++- libxfs/xfs_types.h | 1 + 8 files changed, 237 insertions(+), 5 deletions(-) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index 2ebc12b..b3dacdc 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -16,10 +16,13 @@ #include "xfs_trans.h" #include "xfs_bmap.h" #include "xfs_alloc.h" +#include "xfs_attr_item.h" #include "xfs_rmap.h" #include "xfs_refcount.h" -#include "xfs_bmap.h" #include "xfs_inode.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_attr.h" /* Dummy defer item ops, since we don't do logging. */ @@ -117,6 +120,163 @@ const struct xfs_defer_op_type xfs_extent_free_defer_type = { .cancel_item = xfs_extent_free_cancel_item, }; +int +xfs_trans_attr( + struct xfs_da_args *args, + struct xfs_attrd_log_item *attrdp, + uint32_t op_flags) +{ + int error; + + error = xfs_qm_dqattach_locked(args->dp, 0); + if (error) + return error; + + switch (op_flags) { + case XFS_ATTR_OP_FLAGS_SET: + args->op_flags |= XFS_DA_OP_ADDNAME; + error = xfs_attr_set_args(args); + break; + case XFS_ATTR_OP_FLAGS_REMOVE: + ASSERT(XFS_IFORK_Q((args->dp))); + error = xfs_attr_remove_args(args); + break; + default: + error = -EFSCORRUPTED; + } + + /* + * Mark the transaction dirty, even on error. This ensures the + * transaction is aborted, which: + * + * 1.) releases the ATTRI and frees the ATTRD + * 2.) shuts down the filesystem + */ + args->trans->t_flags |= XFS_TRANS_DIRTY; + set_bit(XFS_LI_DIRTY, &attrdp->attrd_item.li_flags); + + return error; +} + +static int +xfs_attr_diff_items( + void *priv, + struct list_head *a, + struct list_head *b) +{ + return 0; +} + +/* Get an ATTRI. */ +STATIC void * +xfs_attr_create_intent( + struct xfs_trans *tp, + unsigned int count) +{ + return NULL; +} + +/* Log an attr to the intent item. */ +STATIC void +xfs_attr_log_item( + struct xfs_trans *tp, + void *intent, + struct list_head *item) +{ +} + +/* Get an ATTRD so we can process all the attrs. */ +STATIC void * +xfs_attr_create_done( + struct xfs_trans *tp, + void *intent, + unsigned int count) +{ + return NULL; +} + +/* Process an attr. */ +STATIC int +xfs_attr_finish_item( + struct xfs_trans *tp, + struct list_head *item, + void *done_item, + void **state) +{ + struct xfs_attr_item *attr; + unsigned char *name_value; + int error; + int local; + struct xfs_da_args args; + struct xfs_name name; + struct xfs_attrd_log_item *attrdp; + struct xfs_attri_log_item *attrip; + + attr = container_of(item, struct xfs_attr_item, xattri_list); + name_value = ((unsigned char *)attr) + sizeof(struct xfs_attr_item); + + name.name = name_value; + name.len = attr->xattri_name_len; + name.type = attr->xattri_flags; + error = xfs_attr_args_init(&args, attr->xattri_ip, &name); + if (error) + goto out; + + args.hashval = xfs_da_hashname(args.name, args.namelen); + args.value = &name_value[attr->xattri_name_len]; + args.valuelen = attr->xattri_value_len; + args.op_flags = XFS_DA_OP_OKNOENT; + args.total = xfs_attr_calc_size(&args, &local); + args.trans = tp; + + error = xfs_trans_attr(&args, done_item, + attr->xattri_op_flags); +out: + /* + * We are about to free the xfs_attr_item, so we need to remove any + * refrences that are currently pointing at its members + */ + attrdp = (struct xfs_attrd_log_item *)done_item; + attrip = attrdp->attrd_attrip; + attrip->attri_name = NULL; + attrip->attri_value = NULL; + attrip->attri_name_len = 0; + attrip->attri_value_len = 0; + + kmem_free(attr); + return error; +} + +/* Abort all pending ATTRs. */ +STATIC void +xfs_attr_abort_intent( + void *intent) +{ +} + +/* Cancel an attr */ + +STATIC void +xfs_attr_cancel_item( + struct list_head *item) +{ + struct xfs_attr_item *free; + + free = container_of(item, struct xfs_attr_item, xattri_list); + kmem_free(free); +} + +const struct xfs_defer_op_type xfs_attr_defer_type = { + .max_items = XFS_ATTRI_MAX_FAST_ATTRS, + .diff_items = xfs_attr_diff_items, + .create_intent = xfs_attr_create_intent, + .abort_intent = xfs_attr_abort_intent, + .log_item = xfs_attr_log_item, + .create_done = xfs_attr_create_done, + .finish_item = xfs_attr_finish_item, + .cancel_item = xfs_attr_cancel_item, +}; + /* * AGFL blocks are accounted differently in the reserve pools and are not * inserted into the busy extent list. diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 31fb406..67b027a 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -462,6 +462,7 @@ roundup_64(uint64_t x, uint32_t y) #define xfs_trans_reserve_quota_nblks(t,i,b,n,f) (0) #define xfs_trans_unreserve_quota_nblks(t,i,b,n,f) ((void) 0) #define xfs_qm_dqattach(i) (0) +#define xfs_qm_dqattach_locked(i,b) (0) #define uuid_copy(s,d) platform_uuid_copy((s),(d)) #define uuid_equal(s,d) (platform_uuid_compare((s),(d)) == 0) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 780cc0d..99a3a31 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -25,6 +25,7 @@ #include "xfs_attr_remote.h" #include "xfs_trans_space.h" #include "xfs_trace.h" +#include "xfs_attr_item.h" /* * xfs_attr.c @@ -58,7 +59,7 @@ STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); -STATIC int +int xfs_attr_args_init( struct xfs_da_args *args, struct xfs_inode *dp, @@ -152,7 +153,7 @@ xfs_attr_get( /* * Calculate how many blocks we need for the new attribute, */ -STATIC int +int xfs_attr_calc_size( struct xfs_da_args *args, int *local) diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 764db97..7089a80 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -78,6 +78,28 @@ typedef struct attrlist_ent { /* data from attr_list() */ } attrlist_ent_t; /* + * List of attrs to commit later. + */ +struct xfs_attr_item { + struct xfs_inode *xattri_ip; + uint32_t xattri_op_flags; + void *xattri_value; /* attr value */ + uint32_t xattri_value_len; /* length of value */ + void *xattri_name; /* attr name */ + uint32_t xattri_name_len; /* length of name */ + uint32_t xattri_flags; /* attr flags */ + struct list_head xattri_list; + + /* + * A byte array follows the header containing the file name and + * attribute value. + */ +}; + +#define XFS_ATTR_ITEM_SIZEOF(namelen, valuelen) \ + (sizeof(struct xfs_attr_item) + (namelen) + (valuelen)) + +/* * Given a pointer to the (char*) buffer containing the attr_list() result, * and an index, return a pointer to the indicated attribute in the buffer. */ @@ -146,5 +168,8 @@ int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize, int flags, struct attrlist_cursor_kern *cursor); bool xfs_attr_namecheck(const void *name, size_t length); +int xfs_attr_args_init(struct xfs_da_args *args, struct xfs_inode *dp, + struct xfs_name *name); +int xfs_attr_calc_size(struct xfs_da_args *args, int *local); #endif /* __XFS_ATTR_H__ */ diff --git a/libxfs/xfs_defer.c b/libxfs/xfs_defer.c index 1cb5eea..d6b6dce 100644 --- a/libxfs/xfs_defer.c +++ b/libxfs/xfs_defer.c @@ -176,6 +176,7 @@ static const struct xfs_defer_op_type *defer_op_types[] = { [XFS_DEFER_OPS_TYPE_RMAP] = &xfs_rmap_update_defer_type, [XFS_DEFER_OPS_TYPE_FREE] = &xfs_extent_free_defer_type, [XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type, + [XFS_DEFER_OPS_TYPE_ATTR] = &xfs_attr_defer_type, }; /* diff --git a/libxfs/xfs_defer.h b/libxfs/xfs_defer.h index 7c28d76..b9ff7b9 100644 --- a/libxfs/xfs_defer.h +++ b/libxfs/xfs_defer.h @@ -17,6 +17,7 @@ enum xfs_defer_ops_type { XFS_DEFER_OPS_TYPE_RMAP, XFS_DEFER_OPS_TYPE_FREE, XFS_DEFER_OPS_TYPE_AGFL_FREE, + XFS_DEFER_OPS_TYPE_ATTR, XFS_DEFER_OPS_TYPE_MAX, }; @@ -60,5 +61,7 @@ extern const struct xfs_defer_op_type xfs_refcount_update_defer_type; extern const struct xfs_defer_op_type xfs_rmap_update_defer_type; extern const struct xfs_defer_op_type xfs_extent_free_defer_type; extern const struct xfs_defer_op_type xfs_agfl_free_defer_type; +extern const struct xfs_defer_op_type xfs_attr_defer_type; + #endif /* __XFS_DEFER_H__ */ diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index e5f97c6..acdb8ad 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -117,7 +117,12 @@ struct xfs_unmount_log_format { #define XLOG_REG_TYPE_CUD_FORMAT 24 #define XLOG_REG_TYPE_BUI_FORMAT 25 #define XLOG_REG_TYPE_BUD_FORMAT 26 -#define XLOG_REG_TYPE_MAX 26 +#define XLOG_REG_TYPE_ATTRI_FORMAT 27 +#define XLOG_REG_TYPE_ATTRD_FORMAT 28 +#define XLOG_REG_TYPE_ATTR_NAME 29 +#define XLOG_REG_TYPE_ATTR_VALUE 30 +#define XLOG_REG_TYPE_MAX 30 + /* * Flags to log operation header @@ -240,6 +245,8 @@ typedef struct xfs_trans_header { #define XFS_LI_CUD 0x1243 #define XFS_LI_BUI 0x1244 /* bmbt update intent */ #define XFS_LI_BUD 0x1245 +#define XFS_LI_ATTRI 0x1246 /* attr set/remove intent*/ +#define XFS_LI_ATTRD 0x1247 /* attr set/remove done */ #define XFS_LI_TYPE_DESC \ { XFS_LI_EFI, "XFS_LI_EFI" }, \ @@ -255,7 +262,9 @@ typedef struct xfs_trans_header { { XFS_LI_CUI, "XFS_LI_CUI" }, \ { XFS_LI_CUD, "XFS_LI_CUD" }, \ { XFS_LI_BUI, "XFS_LI_BUI" }, \ - { XFS_LI_BUD, "XFS_LI_BUD" } + { XFS_LI_BUD, "XFS_LI_BUD" }, \ + { XFS_LI_ATTRI, "XFS_LI_ATTRI" }, \ + { XFS_LI_ATTRD, "XFS_LI_ATTRD" } /* * Inode Log Item Format definitions. @@ -853,4 +862,35 @@ struct xfs_icreate_log { __be32 icl_gen; /* inode generation number to use */ }; +/* + * Flags for deferred attribute operations. + * Upper bits are flags, lower byte is type code + */ +#define XFS_ATTR_OP_FLAGS_SET 1 /* Set the attribute */ +#define XFS_ATTR_OP_FLAGS_REMOVE 2 /* Remove the attribute */ +#define XFS_ATTR_OP_FLAGS_TYPE_MASK 0x0FF /* Flags type mask */ + +/* + * This is the structure used to lay out an attr log item in the + * log. + */ +struct xfs_attri_log_format { + uint16_t alfi_type; /* attri log item type */ + uint16_t alfi_size; /* size of this item */ + uint32_t __pad; /* pad to 64 bit aligned */ + uint64_t alfi_id; /* attri identifier */ + xfs_ino_t alfi_ino; /* the inode for this attr operation */ + uint32_t alfi_op_flags; /* marks the op as a set or remove */ + uint32_t alfi_name_len; /* attr name length */ + uint32_t alfi_value_len; /* attr value length */ + uint32_t alfi_attr_flags;/* attr flags */ +}; + +struct xfs_attrd_log_format { + uint16_t alfd_type; /* attrd log item type */ + uint16_t alfd_size; /* size of this item */ + uint32_t __pad; /* pad to 64 bit aligned */ + uint64_t alfd_alf_id; /* id of corresponding attrd */ +}; + #endif /* __XFS_LOG_FORMAT_H__ */ diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index 802b34c..5e1dce5 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -11,6 +11,7 @@ typedef uint32_t prid_t; /* project ID */ typedef uint32_t xfs_agblock_t; /* blockno in alloc. group */ typedef uint32_t xfs_agino_t; /* inode # within allocation grp */ typedef uint32_t xfs_extlen_t; /* extent length in blocks */ +typedef uint32_t xfs_attrlen_t; /* attr length */ typedef uint32_t xfs_agnumber_t; /* allocation group number */ typedef int32_t xfs_extnum_t; /* # of extents in a file */ typedef int16_t xfs_aextnum_t; /* # extents in an attribute fork */ From patchwork Fri Aug 9 21:37:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087677 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 072F5912 for ; Fri, 9 Aug 2019 21:38:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9A8D204FB for ; Fri, 9 Aug 2019 21:38:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDEB7212D9; Fri, 9 Aug 2019 21:38:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71D90204FB for ; Fri, 9 Aug 2019 21:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727910AbfHIViT (ORCPT ); Fri, 9 Aug 2019 17:38:19 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50272 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726189AbfHIViS (ORCPT ); Fri, 9 Aug 2019 17:38:18 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYjOg072235 for ; Fri, 9 Aug 2019 21:38:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=5iiTSXR8l7Pl+DC+DNEYY/DRWXkJFG3Cw1S2LUAkdUA=; b=SZT+AhohKtTtVg3S4p7g5+0OgbyK49is+BECZc41WNkxLiJOSkmDwcE8Xi9z5MlWJIom facaufzzMhQ8A7seWye39W7cCgltgUqvVptJ1VdAymRamCJNYbgaXn5blDbdcLhFNb0U Bq9dJciWWeZFeeIYjCDoXNsp6MzQyDNmtMXlwfk4vra/ri70h9y9RjQ6JMkcj0BEoL/9 mPqMFnHKAOCtnLXPXKq/uizllfEoplOY3tdyikQrwbVL4tVIC9nC/W0gFsuGsDhWI4Em 3BwbThZv+u2cDnRWHE26fBr7SP+sDt6Yx1Hg7Y6hZAW3mPdWHNElNXzXmLmS8yK47dld hA== 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-2018-07-02; bh=5iiTSXR8l7Pl+DC+DNEYY/DRWXkJFG3Cw1S2LUAkdUA=; b=yes0GKNL9f/d9GeVR90OJIpqef/gAq5p+2jL3FdvMtkGaKb5be92OQwwjv1ZdbBp5k2G iG8kBXBfs0PlfsDvN8iCokYTPaHMemRopj7qwLaIBRGOo070LJPG8dvP2ZYwOjMIQBHI cgztd0qbXK89M9m0THYlXaNWmqx6SEPpoBol2IVKDQMrTUNhTK/GG1RI+m3xA/c/Bwa/ MAcCGwpZcChqmC+FOaw0HQiMNtXElHEkmGcFFN8n8ZuiKBtYT+z9pPWBi0f+oc5pggbF xYEpM41J4KASZKQeRuXw2wqSGQB8LExhKPMo5i21HsgBeEKhwpW5MncKj+U0l2kFGOXp 0g== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2u8hpsa4ya-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:17 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LNUOs056397 for ; Fri, 9 Aug 2019 21:38:17 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2u8pj9m4gu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:17 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79LcGlB002183 for ; Fri, 9 Aug 2019 21:38:16 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:16 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 04/19] xfsprogs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Date: Fri, 9 Aug 2019 14:37:49 -0700 Message-Id: <20190809213804.32628-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These routines set up set and start a new deferred attribute operation. These functions are meant to be called by other code needing to initiate a deferred attribute operation. Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/xfs_attr.h | 5 ++++ 2 files changed, 79 insertions(+) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 99a3a31..4690538 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -26,6 +26,7 @@ #include "xfs_trans_space.h" #include "xfs_trace.h" #include "xfs_attr_item.h" +#include "xfs_attr.h" /* * xfs_attr.c @@ -400,6 +401,48 @@ out_trans_cancel: goto out_unlock; } +/* Sets an attribute for an inode as a deferred operation */ +int +xfs_attr_set_deferred( + struct xfs_inode *dp, + struct xfs_trans *tp, + struct xfs_name *name, + const unsigned char *value, + unsigned int valuelen) +{ + + struct xfs_attr_item *new; + char *name_value; + + /* + * All set operations must have a name but not necessarily a value. + */ + if (!name->len) { + ASSERT(0); + return -EINVAL; + } + + new = kmem_alloc(XFS_ATTR_ITEM_SIZEOF(name->len, valuelen), + KM_SLEEP|KM_NOFS); + name_value = ((char *)new) + sizeof(struct xfs_attr_item); + memset(new, 0, XFS_ATTR_ITEM_SIZEOF(name->len, valuelen)); + new->xattri_ip = dp; + new->xattri_op_flags = XFS_ATTR_OP_FLAGS_SET; + new->xattri_name_len = name->len; + new->xattri_value_len = valuelen; + new->xattri_flags = name->type; + memcpy(&name_value[0], name->name, name->len); + new->xattri_name = name_value; + new->xattri_value = name_value + name->len; + + if (valuelen > 0) + memcpy(&name_value[name->len], value, valuelen); + + xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + /* * Generic handler routine to remove a name from an attribute list. * Transitions attribute list from Btree to shortform as necessary. @@ -481,6 +524,37 @@ out: return error; } +/* Removes an attribute for an inode as a deferred operation */ +int +xfs_attr_remove_deferred( + struct xfs_inode *dp, + struct xfs_trans *tp, + struct xfs_name *name) +{ + + struct xfs_attr_item *new; + char *name_value; + + if (!name->len) { + ASSERT(0); + return -EINVAL; + } + + new = kmem_alloc(XFS_ATTR_ITEM_SIZEOF(name->len, 0), KM_SLEEP|KM_NOFS); + name_value = ((char *)new) + sizeof(struct xfs_attr_item); + memset(new, 0, XFS_ATTR_ITEM_SIZEOF(name->len, 0)); + new->xattri_ip = dp; + new->xattri_op_flags = XFS_ATTR_OP_FLAGS_REMOVE; + new->xattri_name_len = name->len; + new->xattri_value_len = 0; + new->xattri_flags = name->type; + memcpy(name_value, name->name, name->len); + + xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + /*======================================================================== * External routines when attribute list is inside the inode *========================================================================*/ diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 7089a80..f4efa7c 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -171,5 +171,10 @@ bool xfs_attr_namecheck(const void *name, size_t length); int xfs_attr_args_init(struct xfs_da_args *args, struct xfs_inode *dp, struct xfs_name *name); int xfs_attr_calc_size(struct xfs_da_args *args, int *local); +int xfs_attr_set_deferred(struct xfs_inode *dp, struct xfs_trans *tp, + struct xfs_name *name, const unsigned char *value, + unsigned int valuelen); +int xfs_attr_remove_deferred(struct xfs_inode *dp, struct xfs_trans *tp, + struct xfs_name *name); #endif /* __XFS_ATTR_H__ */ From patchwork Fri Aug 9 21:37:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B164A1709 for ; Fri, 9 Aug 2019 21:38:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DDFA204BF for ; Fri, 9 Aug 2019 21:38:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9243B21FAC; Fri, 9 Aug 2019 21:38:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5279204BF for ; Fri, 9 Aug 2019 21:38:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728017AbfHIViU (ORCPT ); Fri, 9 Aug 2019 17:38:20 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50276 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728184AbfHIViT (ORCPT ); Fri, 9 Aug 2019 17:38:19 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYSwV071893 for ; Fri, 9 Aug 2019 21:38:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=Lo5tm+uCVzFwatU1WKg813SjQfQg8pDRI9YNVsbCODc=; b=MIrPmJaLho2ia28JnEQjsvzwUcCTyvTf0KiZGflkWKPn1dHC6DIaLE0kdaf2cjGKEzf6 niyszM3xusOECSqnXWTkcF9bkBjw0jNJ6i0wcvRgFk+60iuZhLEV4ZhRwGytqH1jh/L+ CgtcN+3B30tAFO3/8An1E5olQJazJnXHx61gxYL6r+8dvWtNtk7cQbSU8Y9Iti10Zv0g HjLR0vsG/AV1+k1Gwai7fq3Aj8iXWzjtgET3eRTaPz1/FRn8ZfLDN95BX0XBey2l7f/L 3qP5IAnt1VsbGUMQl+cAanCJWHF//F34CvNbE/WH63XznkQQYSkX5m+gzZqdlEAQUfEh Xw== 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-2018-07-02; bh=Lo5tm+uCVzFwatU1WKg813SjQfQg8pDRI9YNVsbCODc=; b=t1RqrURejTzvDja5oehVt99YSL2G6XIqlySfkow63g0hyThdvBsjtJjlbB8P637ryz/E nKzFM/ZzIHfxllMP9Iqn1MOTAEenvzanZqKOiVF6vXo96/R/gOdWpFaVPz0i0hNRzxsH nnEmqih2nrRu7/yX6WeE5HDDmYLmv+6d4rb6SHg8K5tvfYvgg1VaeohPEbzEjV7G4z/M V/bkiCNMpQ8xSn5EnOy7jIttzpN7vM+X6ruhkC2jzlH1SPjUzF6sOViskcZcTyIzR8+I XBaccNYtzgFeGlDPoM3t34r4XlNJMkb321Lb3vI5kFcSzSFbMqf4ltSm1SyTH+ht2Kjp aA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2u8hpsa4yc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:17 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LNUnT056402 for ; Fri, 9 Aug 2019 21:38:17 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2u8pj9m4hg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:17 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79LcGDZ019323 for ; Fri, 9 Aug 2019 21:38:17 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:16 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 05/19] xfsprogs: Add xfs_has_attr and subroutines Date: Fri, 9 Aug 2019 14:37:50 -0700 Message-Id: <20190809213804.32628-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 appearence 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 | 151 ++++++++++++++++++++++++++++++++----------------- libxfs/xfs_attr.h | 1 + libxfs/xfs_attr_leaf.c | 82 ++++++++++++++++++--------- libxfs/xfs_attr_leaf.h | 2 + 4 files changed, 158 insertions(+), 78 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 4690538..f082b30 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -49,6 +49,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_leaf_has_attr(xfs_da_args_t *args, struct xfs_buf **bp); /* * Internal routines when attribute list is more than one block. @@ -56,6 +57,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); @@ -279,6 +282,32 @@ 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; + int error; + + if (!xfs_inode_hasattr(dp)) { + error = -ENOATTR; + } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { + ASSERT(dp->i_afp->if_flags & XFS_IFINLINE); + error = xfs_shortform_has_attr(args, NULL, NULL); + } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { + error = xfs_leaf_has_attr(args, &bp); + xfs_trans_brelse(args->trans, bp); + } else { + error = xfs_attr_node_hasname(args, NULL); + } + + return error; +} + +/* * Remove the attribute specified in @args. */ int @@ -617,26 +646,17 @@ 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_leaf_has_attr(args, &bp); if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) { xfs_trans_brelse(args->trans, bp); return retval; @@ -788,6 +808,26 @@ xfs_attr_leaf_addname( } /* + * Return EEXIST if attr is found, or ENOATTR if not + */ +STATIC int +xfs_leaf_has_attr( + struct xfs_da_args *args, + struct xfs_buf **bp) +{ + int error = 0; + + args->blkno = 0; + error = xfs_attr3_leaf_read(args->trans, args->dp, + args->blkno, -1, bp); + if (error) + return error; + + error = xfs_attr3_leaf_lookup_int(*bp, args); + return error; +} + +/* * Remove a name from the leaf attribute list structure * * This leaf block cannot have a "remote" value, we only call this routine @@ -807,12 +847,8 @@ 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) - return error; - error = xfs_attr3_leaf_lookup_int(bp, args); + error = xfs_leaf_has_attr(args, &bp); if (error == -ENOATTR) { xfs_trans_brelse(args->trans, bp); return error; @@ -849,12 +885,7 @@ 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) - return error; - - error = xfs_attr3_leaf_lookup_int(bp, args); + error = xfs_leaf_has_attr(args, &bp); if (error != -EEXIST) { xfs_trans_brelse(args->trans, bp); return error; @@ -867,6 +898,43 @@ 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; + struct xfs_inode *dp; + int retval, error; + + /* + * 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 == 0) + error = retval; + + if (statep != NULL) + *statep = state; + else + xfs_da_state_free(state); + + return error; +} + /*======================================================================== * External routines when attribute list size > geo->blksize *========================================================================*/ @@ -899,17 +967,14 @@ xfs_attr_node_addname( dp = args->dp; mp = dp->i_mount; restart: - state = xfs_da_state_alloc(); - state->args = args; - state->mp = mp; - /* * Search to see if name already exists, and get back a pointer * to where it should go. */ - error = xfs_da3_node_lookup_int(state, &retval); - if (error) + error = xfs_attr_node_hasname(args, &state); + if (error == -EEXIST) goto out; + blk = &state->path.blk[ state->path.active-1 ]; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) { @@ -1114,29 +1179,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. @@ -1356,17 +1407,13 @@ xfs_attr_node_get(xfs_da_args_t *args) 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) { + error = xfs_attr_node_hasname(args, &state); + if (error != -EEXIST) { retval = error; - } else if (retval == -EEXIST) { + } else { blk = &state->path.blk[ state->path.active-1 ]; ASSERT(blk->bp != NULL); ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index f4efa7c..06ed120 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -164,6 +164,7 @@ int xfs_attr_set(struct xfs_inode *dp, struct xfs_name *name, unsigned char *value, int valuelen); int xfs_attr_set_args(struct xfs_da_args *args); int xfs_attr_remove(struct xfs_inode *dp, struct xfs_name *name); +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 1027ca0..2ebe2c6 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -545,6 +545,53 @@ 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 + * basep: If not null, pointer is set to the byte offset of the entry in the + * list + */ +int +xfs_shortform_has_attr( + struct xfs_da_args *args, + struct xfs_attr_sf_entry **sfep, + int *basep) +{ + struct xfs_attr_shortform *sf; + struct xfs_attr_sf_entry *sfe; + int base = sizeof(struct xfs_attr_sf_hdr); + int size = 0; + int end; + int i; + + base = sizeof(struct xfs_attr_sf_hdr); + 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->namelen) + continue; + if (memcmp(sfe->nameval, args->name, args->namelen) != 0) + continue; + if (!xfs_attr_namesp_match(args->flags, 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. */ @@ -553,7 +600,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) { xfs_attr_shortform_t *sf; xfs_attr_sf_entry_t *sfe; - int i, offset, size; + int offset, size, error; xfs_mount_t *mp; xfs_inode_t *dp; struct xfs_ifork *ifp; @@ -567,18 +614,11 @@ 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++) { + error = xfs_shortform_has_attr(args, &sfe, NULL); #ifdef DEBUG - if (sfe->namelen != args->namelen) - continue; - if (memcmp(args->name, sfe->nameval, args->namelen) != 0) - continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) - continue; + if (error == -EEXIST) ASSERT(0); #endif - } offset = (char *)sfe - (char *)sf; size = XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); @@ -625,7 +665,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) { xfs_attr_shortform_t *sf; xfs_attr_sf_entry_t *sfe; - int base, size=0, end, totsize, i; + int base, size = 0, end, totsize, error; xfs_mount_t *mp; xfs_inode_t *dp; @@ -633,23 +673,13 @@ xfs_attr_shortform_remove(xfs_da_args_t *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->namelen) - continue; - if (memcmp(sfe->nameval, args->name, args->namelen) != 0) - continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) - continue; - break; - } - if (i == end) - return -ENOATTR; + + error = xfs_shortform_has_attr(args, &sfe, &base); + if (error == -ENOATTR) + 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..be1f636 100644 --- a/libxfs/xfs_attr_leaf.h +++ b/libxfs/xfs_attr_leaf.h @@ -39,6 +39,8 @@ 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_shortform_has_attr(struct xfs_da_args *args, + struct xfs_attr_sf_entry **sfep, int *basep); int xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp); int xfs_attr_shortform_bytesfit(struct xfs_inode *dp, int bytes); xfs_failaddr_t xfs_attr_shortform_verify(struct xfs_inode *ip); From patchwork Fri Aug 9 21:37:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2B04912 for ; Fri, 9 Aug 2019 21:38:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF3B5204BF for ; Fri, 9 Aug 2019 21:38:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF94C204FB; Fri, 9 Aug 2019 21:38:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 120F4205F7 for ; Fri, 9 Aug 2019 21:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728184AbfHIViU (ORCPT ); Fri, 9 Aug 2019 17:38:20 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50296 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726475AbfHIViU (ORCPT ); Fri, 9 Aug 2019 17:38:20 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYP09071872 for ; Fri, 9 Aug 2019 21:38:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=t2CpFmK3wv9kTXYGh6ff+nawFg0PR09ksFuw9IJEwPg=; b=bJZ2wzkAE7Fjp6BIXt2qMiZYKGtJwh0nRwGfOPOBJz6z0rVMhyUyN0App4JtKlIfId+h XlDp9JPgaoyGVmk0PC75WRXOU24pQhjWkNPpjHb09toVPtoDIQjzFiVyxYD6SJB5mo9a XyGUtDNwBahNVFd32koEBXHYPtaPp2dk9jrTx70rafPfuTuobvKU3x45hImVzsy7QJfH xfmUdnSF8BR7cqepgT4v53u7yshoPmwXmbaRya3KtY6T06b/FpGDc59t0dvuIJGUgZhS 084adHSkrOFjYVqGpTqp/7zSNQ07HE9kah89iIFXgszGLgZs6RCzXZlcNOsUcFL32Ffy aQ== 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-2018-07-02; bh=t2CpFmK3wv9kTXYGh6ff+nawFg0PR09ksFuw9IJEwPg=; b=D7BkPZuo+Lt+Hm8f5RPlc08UIQd8a1YG03nhRMv+osQIalnVwSn/rdogBeqei3n5VtUA F8uJCTLGXcTHxX9lDYrnrE3rVHbIOxvJA1qEueOz3q3uWvSeEesayuUl0HTNVXBt9KL7 OaWVLeK+aB8ycoM7xRD733bAbnxmBvKFBOKHo8Zp/eLYYO+fLjJy/8eGIgzJ+7EEX2Zf QPwdXjdlhDlqJDJ7GGAVn2TXTc7okOO+jyEK1sdgUZhUJANnNBD068CviagqM0XBlPtw c4PeK1G0hWSFxuhzRLySW24UkG44YqOAN6QVAJTKTbgKrYdZUWRVSz0Jt/PpcBTa3kCY RA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2u8hpsa4ye-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:18 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LNbjC067988 for ; Fri, 9 Aug 2019 21:38:18 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2u90t814g7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:18 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79LcHCd002195 for ; Fri, 9 Aug 2019 21:38:17 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:17 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 06/19] xfsprogs: Factor out new helper functions xfs_attr_rmtval_set Date: Fri, 9 Aug 2019 14:37:51 -0700 Message-Id: <20190809213804.32628-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- libxfs/xfs_attr_remote.c | 73 ++++++++++++++++++++++++++++++++++++------------ libxfs/xfs_attr_remote.h | 4 ++- 2 files changed, 58 insertions(+), 19 deletions(-) diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 7fe28a0..5452de4 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -24,6 +24,7 @@ #include "xfs_trans_space.h" #include "xfs_trace.h" #include "xfs_cksum.h" +#include "xfs_attr_remote.h" #define ATTR_RMTVALUE_MAPSIZE 1 /* # of map entries at once */ @@ -433,34 +434,18 @@ xfs_attr_rmtval_set( 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); - /* - * 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. - */ - blkcnt = xfs_attr3_rmt_blocks(mp, args->rmtvaluelen); - error = xfs_bmap_first_unused(args->trans, args->dp, blkcnt, &lfileoff, - XFS_ATTR_FORK); + error = xfs_attr_rmt_find_hole(args, &blkcnt, &lfileoff); if (error) return error; - args->rmtblkno = lblkno = (xfs_dablk_t)lfileoff; - args->rmtblkcnt = blkcnt; - + lblkno = (xfs_dablk_t)lfileoff; /* * Roll through the "value", allocating blocks on disk as required. */ @@ -501,6 +486,58 @@ xfs_attr_rmtval_set( return error; } + error = xfs_attr_rmtval_set_value(args); + return error; +} + + + +int +xfs_attr_rmt_find_hole( + struct xfs_da_args *args, + int *blkcnt, + xfs_fileoff_t *lfileoff) +{ + struct xfs_inode *dp = args->dp; + struct xfs_mount *mp = dp->i_mount; + int error; + + trace_xfs_attr_rmtval_set(args); + + /* + * 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. + */ + *blkcnt = xfs_attr3_rmt_blocks(mp, args->rmtvaluelen); + error = xfs_bmap_first_unused(args->trans, args->dp, *blkcnt, lfileoff, + XFS_ATTR_FORK); + if (error) + return error; + + args->rmtblkno = (xfs_dablk_t)*lfileoff; + args->rmtblkcnt = *blkcnt; + + return 0; +} + +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 * already-allocated blocks. Blocks are written synchronously diff --git a/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index 9d20b66..2a73cd9 100644 --- a/libxfs/xfs_attr_remote.h +++ b/libxfs/xfs_attr_remote.h @@ -11,5 +11,7 @@ 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_set_value(struct xfs_da_args *args); +int xfs_attr_rmt_find_hole(struct xfs_da_args *args, int *blkcnt, + xfs_fileoff_t *lfileoff); #endif /* __XFS_ATTR_REMOTE_H__ */ From patchwork Fri Aug 9 21:37:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D8DB18A6 for ; Fri, 9 Aug 2019 21:38:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C0F9205F7 for ; Fri, 9 Aug 2019 21:38:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3077F204FB; Fri, 9 Aug 2019 21:38:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0C69205F7 for ; Fri, 9 Aug 2019 21:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728240AbfHIViV (ORCPT ); Fri, 9 Aug 2019 17:38:21 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59372 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726189AbfHIViV (ORCPT ); Fri, 9 Aug 2019 17:38:21 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYbFJ084554 for ; Fri, 9 Aug 2019 21:38:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=U9XMJqXhQibvtTMkmIJR5mBnccMnyWRKhK+DpGer+Rw=; b=lUHCRBf3sWUdJ+m6gqAhUYCRRykjnNqE0ucd30s8uz2tVxHKaHQLRo+rW+X3aqJkKtZi FTdYaqkcgE/l9UCqllVrlnLOrD125/pG1s4CTeutJUO1bNJilnJe6gOtH5wVr9VgAFF6 RCDKZeczCfz9nVd1hooS872Fzizs9bSA4aWhXqpaQ0mzJLYQyOFgH+qHk2iEF4jgg38N qjfU3ficNENRJ8CKMyEPJ4ut4sVgGkGfjyvpp7Ye9ocftGfteOyNmjIfQWSSBjrXtmY9 iqo9jcscSc90LzzboxByiLmpRLY4ACS4f2DVStm4mEP7or/hE9y5Hv8S/SFTJDO4PRFX 7w== 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-2018-07-02; bh=U9XMJqXhQibvtTMkmIJR5mBnccMnyWRKhK+DpGer+Rw=; b=S7/b6P4kzIm8/9x3NjPXoJC9rSQyGZAjSCEghLTTvEhq1OTM1zJpBcQZsOr/JtjbsWqv FPW2aXxYIcpJRtcGzozwXWtWg3xXJaijr/94IFxqrAnfMQWgpMTRiuh18d/p6/9LcXjG c/dPxYEV3Yl/Ci14x+eyRtfdr7yFzuGGMCkJJY0w+Nmk+s+bKASJurjNt3nPTzhXVisd +kQ5H1va8r50wdTMLFzZjYFRz0lDdjRUDIz7PmXUnJtWp/GlE0rDoJF8EjL4QYqPabNf EMav9Y2llWeYTAtfcsD/gGCT7dli1R7hlkdJlOSrg/4UI6dov9DVnNoux2lkl6cuXvX2 /w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2u8hgpa7y5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:19 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LNTr2056356 for ; Fri, 9 Aug 2019 21:38:19 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2u8pj9m4j4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:19 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x79LcIMq010601 for ; Fri, 9 Aug 2019 21:38:18 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:18 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 07/19] xfsprogs: Factor up trans handling in xfs_attr3_leaf_flipflags Date: Fri, 9 Aug 2019 14:37:52 -0700 Message-Id: <20190809213804.32628-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since delayed operations cannot roll transactions, factor up the transaction handling into the calling function Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 10 ++++++++++ libxfs/xfs_attr_leaf.c | 5 ----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index f082b30..8b3d6a3 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -753,6 +753,11 @@ 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); /* * Dismantle the "old" attribute/value pair by removing @@ -1091,6 +1096,11 @@ 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); /* * Dismantle the "old" attribute/value pair by removing diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 2ebe2c6..1ac64dd 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2890,10 +2890,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; } From patchwork Fri Aug 9 21:37:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087691 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7B1A13AC for ; Fri, 9 Aug 2019 21:38:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5257204BF for ; Fri, 9 Aug 2019 21:38:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9A91205F7; Fri, 9 Aug 2019 21:38:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FCB4204BF for ; Fri, 9 Aug 2019 21:38:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728312AbfHIVi1 (ORCPT ); Fri, 9 Aug 2019 17:38:27 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50496 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbfHIVi0 (ORCPT ); Fri, 9 Aug 2019 17:38:26 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYeLw071951 for ; Fri, 9 Aug 2019 21:38:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=SXsCphdU7fwJh4qDXcu0Lu4A/kGZcPhhMrj9JrKXn/4=; b=GycBstdvmZTWX1/ooJEkczNokcqseVysuMxYQiwFYeSt9eSV6rBY1p3B9PimF8ENoH7w FnKnCSshs3quty1jwsOsDHljRl+j0ctxx5A6X/C+ajn1idkWpKKuA7RK7GiO2RN0t4Hg 3vYgM7SDrlJYxnmMd3XtsY347FLLQmYWqOKJ6Os2hDa/LeGdB/8vXoBRALH5KSxgnaLF dAMJxzEz3cEe+9tlkDiLzll7afmy2CYc03/VYiBkThWpRjMrhUFlegskngbyR204n34d JcEy5rat3ZK6J0K/y5rCVpH+mZOygAvvT+juPEALIWqf+W4DZ33abGimRlDR5U+loBQ8 TQ== 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-2018-07-02; bh=SXsCphdU7fwJh4qDXcu0Lu4A/kGZcPhhMrj9JrKXn/4=; b=AW3qQ20aFlswSWJWp7zUlkVFAJTtuyv0jdjKNjK5Mvc0YeYfFf2+RsSSyT6pEgQqY2iP FBrlOXjpA/kqnVohwfGDqAI+Udp1QTI30japuJcRxewbMG5n5GhGLfcV/6Tm5+c3ludl fDhR1Pt6oJM7IynowU91xHmJr3FtXk/D2BrSZfE1llWnKRpUOOXOVzwibNYW2yBQPbYF /YUPBalWtrL6twQ5dEmdWNX/CSYm8PDEnKxyrwK6x75+WhKP56yycxsT5E6XpYdLqKBX Qc7erJZWzYuVH42f/pgrNOaSc0ibRDWa4Ap+4ttbBPZ2u2Pu0531ZHjZJEdO9WA/Q3cp vA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2u8hpsa4ym-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:25 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LcOFa112155 for ; Fri, 9 Aug 2019 21:38:24 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2u8x9fxkac-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:24 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x79LcJs1010605 for ; Fri, 9 Aug 2019 21:38:19 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:18 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 08/19] xfsprogs: Factor out xfs_attr_leaf_addname helper Date: Fri, 9 Aug 2019 14:37:53 -0700 Message-Id: <20190809213804.32628-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. This will help to reduce repetitive code later when we introduce delayed attributes. Signed-off-by: Allison Henderson Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 8b3d6a3..3b7baba 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -636,19 +636,12 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) * External routines when attribute list is one block *========================================================================*/ -/* - * 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) +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; + int retval, error; trace_xfs_attr_leaf_addname(args); @@ -693,13 +686,35 @@ 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, */ error = xfs_attr3_leaf_to_node(args); if (error) return error; + } + return retval; +} + + +/* + * 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 retval, error, forkoff; + struct xfs_buf *bp = NULL; + struct xfs_inode *dp = args->dp; + + retval = xfs_attr_leaf_try_add(args, bp); + if (retval == -ENOSPC) { + /* + * Commit that transaction so that the node_addname() call + * can manage its own transactions. + */ error = xfs_defer_finish(&args->trans); if (error) return error; From patchwork Fri Aug 9 21:37:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087689 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5A5E1709 for ; Fri, 9 Aug 2019 21:38:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9372A204BF for ; Fri, 9 Aug 2019 21:38:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87D7B205F7; Fri, 9 Aug 2019 21:38:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3882F204BF for ; Fri, 9 Aug 2019 21:38:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726189AbfHIViV (ORCPT ); Fri, 9 Aug 2019 17:38:21 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50376 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726475AbfHIViV (ORCPT ); Fri, 9 Aug 2019 17:38:21 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYeLv071951 for ; Fri, 9 Aug 2019 21:38:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=K4nsFW2Pt3fp/c1R9h5x8HvdvOaNbn9B1ZsSd+LKddU=; b=B4zhKnlAJqBwuBYfxX/tGwOi1GEe66AYdE/7vyIyLIej7geeHii8GFQ3e7NNkBIlBjZc Yyn2sB6c3ShCmWY2poYiTfckFFvtrU5GIq9BnDXmQynzzOJG78beZzyrz9xSCk7vOih5 n8ZcfpyOIOVP8mJWsdjgZhhehP4zS0xGRem6XdfdYz/bIK+o9GBe0JE1W/s37nLeDkGl so/kiQR1btbPpw9QX1hEQ2ChOG5bkptMIDLZgIpYPUIUbSd37cg98EeMD6NX9SCgNwXv OTeQnkx/ncCudiY8qbr+UqzCa/UNztW+XR71lcj4T6X1lqrxEzW98qhElhjWnSmF+7+1 eA== 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-2018-07-02; bh=K4nsFW2Pt3fp/c1R9h5x8HvdvOaNbn9B1ZsSd+LKddU=; b=GbUSPg233e9MCwNfcxhjtftBfW6OfRytjnz/gDGaesnN0B1tBfiEOsUAOkfrJAxEekib F+w9Risf4COuqfLU0cYvRpjNpMcKAh5l0QHTpwdHRAPnC3uVuljijFPEmu5uGlf0dJ2Y o3003ViAhYWKNXXhS4N7d83P03uhG9BT6qgOjy+qfakkdEueiKlQ4WLfoxz8uc3bv/eR EAIrW+JuskCbxudMBwsjkrOX7wAdWZn3faeNnUnzH2zTBIqjLMm2MDAJrHDRkJFuFSB8 K5MwAdVLnCG+pSqg0ieJO5KpKn+Pvdn5GAwCin9z4tHISHplIzPdRaoNae/zgRWArwJb Bg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2u8hpsa4yj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:20 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LNU6c056459 for ; Fri, 9 Aug 2019 21:38:20 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2u8pj9m4jt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:20 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79LcJcj019329 for ; Fri, 9 Aug 2019 21:38:19 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:19 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 09/19] xfsprogs: Factor up commit from xfs_attr_try_sf_addname Date: Fri, 9 Aug 2019 14:37:54 -0700 Message-Id: <20190809213804.32628-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP New delayed attribute routines cannot handle transactions, so factor this up to the calling function. Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 3b7baba..6245afb 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -197,7 +197,7 @@ xfs_attr_try_sf_addname( { struct xfs_mount *mp = dp->i_mount; - int error, error2; + int error; error = xfs_attr_shortform_addname(args); if (error == -ENOSPC) @@ -213,9 +213,7 @@ xfs_attr_try_sf_addname( if (mp->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; } /* @@ -227,7 +225,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, @@ -247,8 +245,11 @@ xfs_attr_set_args( * Try to add the attr to the attribute list in the inode. */ error = xfs_attr_try_sf_addname(dp, args); - if (error != -ENOSPC) - return error; + if (error != -ENOSPC) { + error2 = xfs_trans_commit(args->trans); + args->trans = NULL; + return error ? error : error2; + } /* * It won't fit in the shortform, transform to a leaf block. From patchwork Fri Aug 9 21:37:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D013912 for ; Fri, 9 Aug 2019 21:39:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B0FD204FB for ; Fri, 9 Aug 2019 21:39:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E454212D9; Fri, 9 Aug 2019 21:39:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23FEA204FB for ; Fri, 9 Aug 2019 21:39:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725985AbfHIVj3 (ORCPT ); Fri, 9 Aug 2019 17:39:29 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51742 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbfHIVj3 (ORCPT ); Fri, 9 Aug 2019 17:39:29 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYVpK071907 for ; Fri, 9 Aug 2019 21:39:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=0SVpzReianaXB3oHVhgH6Z9u7I5pknKA+l6i4Z50CHU=; b=QSbHyPvjy0ljqS7QQZ5h58Qg1AQqdFW3VJdXonold3BY0eiEBxNi4FGNV6Et+ZRpEq/P twxWL4RmewDxyyjdJiV6UnQVsSmRbfQt4XUCYF02BtrdRJggHW+F6T2iOWeCoMWCTs64 XsGLCjZ2bz5nm+HQTE4fw+4SdI1Cn7AHb4R/+cGXoOtcgfuXLmARJvzvESgPyomgna8l pljlqIGEMoBLYAWxehvWBebDZ+xmXAkW91D3WFCTvPRqZF1qRiQFbddKlxMLN6Y1xYMC dKES6d2V9BZU4TI3vNcyh/ThT74QHhd6VhoWFuQZ8Z7hc6pTvObEQAjuFA78UiQ0t6MQ vQ== 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-2018-07-02; bh=0SVpzReianaXB3oHVhgH6Z9u7I5pknKA+l6i4Z50CHU=; b=VnMXfK3xpqHo7pUNy6h/mz8vjJfe7dpsdnaiyOGy/MNS5tVFh3L+8tQqT4kw0mcEu2h/ 2RnO6fpL3hQYu864sck/vS1ts9796w6/VGgzFD0smEj5KuiFouJLjaZyvWg9FWAg2VSa cs5N6XW+GD8gHH3qAKpuXyajXMfpH6+Zn8+hcYtZMswCFrM9OWlsW9ACizkm0kRBsAi3 GJfimgWJWCuMzW5B0sphpoMr/3HKSxWko20CviHVygqsBOtC/stkkmhmf+zu0EUhsqRu uc4bRQVYlsBdK+q7jl67ye1DO0r8oCTaquvrGq6flp34PMDjeJFL2NZrmg+zn7B756fP vg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2u8hpsa529-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:39:28 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LdJC2048096 for ; Fri, 9 Aug 2019 21:39:27 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2u8x1h6w34-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:39:27 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79LcJRF019389 for ; Fri, 9 Aug 2019 21:38:20 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:19 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 10/19] xfsprogs: Factor up trans roll from xfs_attr3_leaf_setflag Date: Fri, 9 Aug 2019 14:37:55 -0700 Message-Id: <20190809213804.32628-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=883 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=948 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP New delayed allocation routines cannot be handling transactions so factor them up into the calling functions Signed-off-by: Allison Collins --- 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 6245afb..8e63377 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1240,6 +1240,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 1ac64dd..524e37a 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2772,10 +2772,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 error; } /* From patchwork Fri Aug 9 21:37:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B0EB13AC for ; Fri, 9 Aug 2019 21:38:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 394AA204BF for ; Fri, 9 Aug 2019 21:38:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DBBF205F7; Fri, 9 Aug 2019 21:38:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBA44204BF for ; Fri, 9 Aug 2019 21:38:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbfHIVil (ORCPT ); Fri, 9 Aug 2019 17:38:41 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50806 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726807AbfHIVil (ORCPT ); Fri, 9 Aug 2019 17:38:41 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYPlM071865 for ; Fri, 9 Aug 2019 21:38:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=IOh6SCxVx7U1AVW5joIZZXxUMAAlMIp1cIDfxjggra4=; b=R1BvmodTQ7vYPpg1Ni8GtHSOMFMPV7P47wbW67Cmh90G3RROBCb+L7hJqoHDCbyqiuC8 PNRAGabJmzwVoneZg+d+uKRWEDSlWa5bVupLiCfxSzeN07Sl7suqjfXo9g58z6c/JyRm jXrYsMYTLUxwm1iThRZ3fImbT8AZcOv0E8jqsjzFJ/3zdcKyek5S2b1EXbb4PaOxbYqr Cp/HmS9Ll/Uv9klE9AIsZK6uZkmGp7nm2dEKU6c3V7MZBXCkKKwJMVVIWn/++CK0VS/B RiHpbFL/obd5kGw7XYslbuYmz5N9tVtTXRY0c5jfXc8gbeJtmIo/YWa9FZvY5WjRqRpR bQ== 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-2018-07-02; bh=IOh6SCxVx7U1AVW5joIZZXxUMAAlMIp1cIDfxjggra4=; b=IDSH3405RgiB92oUbX4xWP5pH0XiynwBZp8fa0vhOSKEM/Dl2fCZwG4qwKl4sflrlFo5 oPogB/eUA4i+Z5iZ635XjzimUgLnzxXmmSuYBi8qv4fPKmLVnOVpgnHB5tYbdpyqBnJw UZcMrbHdlyQVHhcxWRNgVAoh30Sk220SfueR3Y2V/UfjLhiWIZKR7WWyNUNL8B4EJDPK XqwWfnQZo3eNGKv+IsV7oZ5gYPbVdhbJu0bSfxAaxgEf41IPugF2irvQqH7LCVTC3tbS 2oSj9MjqOMe7m29SIkCPph5NCGjolvK/11EqqOEDRkS08zlyXT9X0MZEgc6lSz47MxyM 3g== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2u8hpsa506-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:39 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LcZiq097333 for ; Fri, 9 Aug 2019 21:38:39 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2u8pj9m4k3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:39 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79LcK0f002213 for ; Fri, 9 Aug 2019 21:38:20 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:20 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 11/19] xfsprogs: Add xfs_attr3_leaf helper functions Date: Fri, 9 Aug 2019 14:37:56 -0700 Message-Id: <20190809213804.32628-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP And new helper functions xfs_attr3_leaf_flag_is_set and xfs_attr3_leaf_flagsflipped. These routines check to see if xfs_attr3_leaf_setflag or xfs_attr3_leaf_flipflags have already been run. We will need this later for delayed attributes since routines may be recalled several times when -EAGAIN is returned. Signed-off-by: Allison Collins --- libxfs/xfs_attr_leaf.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/xfs_attr_leaf.h | 2 ++ 2 files changed, 80 insertions(+) diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 524e37a..049c786 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2728,6 +2728,34 @@ xfs_attr3_leaf_clearflag( } /* + * Check if the INCOMPLETE flag on an entry in a leaf block is set. + */ +int +xfs_attr3_leaf_flag_is_set( + struct xfs_da_args *args) +{ + struct xfs_attr_leafblock *leaf; + struct xfs_attr_leaf_entry *entry; + struct xfs_buf *bp; + struct xfs_inode *dp = args->dp; + int error = 0; + + trace_xfs_attr_leaf_setflag(args); + + /* + * Set up the operation. + */ + error = xfs_attr3_leaf_read(args->trans, dp, args->blkno, -1, &bp); + if (error) + return error; + + leaf = bp->b_addr; + entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; + + return ((entry->flags & XFS_ATTR_INCOMPLETE) != 0); +} + +/* * Set the INCOMPLETE flag on an entry in a leaf block. */ int @@ -2889,3 +2917,53 @@ xfs_attr3_leaf_flipflags( return error; } + +/* + * On a leaf entry, check to see if the INCOMPLETE flag is cleared + * in args->blkno/index and set in args->blkno2/index2. + * + * Note that they could be in different blocks, or in the same block. + */ +int +xfs_attr3_leaf_flagsflipped( + struct xfs_da_args *args) +{ + struct xfs_attr_leafblock *leaf1; + struct xfs_attr_leafblock *leaf2; + struct xfs_attr_leaf_entry *entry1; + struct xfs_attr_leaf_entry *entry2; + struct xfs_buf *bp1; + struct xfs_buf *bp2; + struct xfs_inode *dp = args->dp; + int error = 0; + + trace_xfs_attr_leaf_flipflags(args); + + /* + * Read the block containing the "old" attr + */ + error = xfs_attr3_leaf_read(args->trans, dp, args->blkno, -1, &bp1); + if (error) + return error; + + /* + * Read the block containing the "new" attr, if it is different + */ + if (args->blkno2 != args->blkno) { + error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno2, + -1, &bp2); + if (error) + return error; + } else { + bp2 = bp1; + } + + leaf1 = bp1->b_addr; + entry1 = &xfs_attr3_leaf_entryp(leaf1)[args->index]; + + leaf2 = bp2->b_addr; + entry2 = &xfs_attr3_leaf_entryp(leaf2)[args->index2]; + + return (((entry1->flags & XFS_ATTR_INCOMPLETE) == 0) && + (entry2->flags & XFS_ATTR_INCOMPLETE)); +} diff --git a/libxfs/xfs_attr_leaf.h b/libxfs/xfs_attr_leaf.h index be1f636..d6afe23 100644 --- a/libxfs/xfs_attr_leaf.h +++ b/libxfs/xfs_attr_leaf.h @@ -54,7 +54,9 @@ int xfs_attr3_leaf_to_shortform(struct xfs_buf *bp, struct xfs_da_args *args, int forkoff); int xfs_attr3_leaf_clearflag(struct xfs_da_args *args); int xfs_attr3_leaf_setflag(struct xfs_da_args *args); +int xfs_attr3_leaf_flag_is_set(struct xfs_da_args *args); int xfs_attr3_leaf_flipflags(struct xfs_da_args *args); +int xfs_attr3_leaf_flagsflipped(struct xfs_da_args *args); /* * Routines used for growing the Btree. From patchwork Fri Aug 9 21:37:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B504912 for ; Fri, 9 Aug 2019 21:38:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19694204BF for ; Fri, 9 Aug 2019 21:38:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D4CC205F7; Fri, 9 Aug 2019 21:38:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAA26204BF for ; Fri, 9 Aug 2019 21:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728120AbfHIVij (ORCPT ); Fri, 9 Aug 2019 17:38:39 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50764 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726807AbfHIVii (ORCPT ); Fri, 9 Aug 2019 17:38:38 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYPQo071860 for ; Fri, 9 Aug 2019 21:38:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=M0jzhPRCsqHb+LX0hc9PORVKNu/lTs7dGAFDEsanXHk=; b=FngrHduoOQsyy1U/xkYZ68rDO+RMbdbWzqBSIMlbIo7lGi130RU83uqtQBQKDxYDomPj P5Dz25FsbOZXy9x0oALNi+CPbHuxglfufzAqFNiynlrltA0K6buHvWTw8G8vMjL9SJR6 5q1ISiV4dsooCNJEb9keHLx0XV1VHdwMR+kBpDmmNOrDMaWmXL8Wgg+bkRHyyFGOym6N uM0jEX6g8REJqpCQSg5IR0jbwDLhjqNZr0GovaEee1X9QKhde3MWQsU6lGrVfkJr85Jz QBCxF09iFQFrugt0Cf/1jYXWkjf9ZnEzs+VOB8a5+I3YU5yfNiYMNULXnyeVE+iIgy48 Ug== 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-2018-07-02; bh=M0jzhPRCsqHb+LX0hc9PORVKNu/lTs7dGAFDEsanXHk=; b=ZvkobRA32p1YW1wYU+P+jMG4bKf0wJ02yBE61LbkbX8mkWC31qk6FVnm659/BgB3jw8t 9PiHGt5b22yjq4TzwjxRMfdE8bwv4W+0XlXz6Hwo1VpERK9TMyvAtHhQyNW2ubKpol2b hURFfIf4ACCwMjQBtfw4e7DrPqa8zAwFTcffC9kiccoCWuy9GUaaCKxRAVHj+rOZG/pp 1vZoE7k3jGLyjAUQro3MCqJopvgBZld+07umc/N+XD07sPctCnxgGbw2EAXCRFbYlmo4 od/6Il7IH4ehIjXSnYCpV7BUPu+J82HhKUY6sldQrBm55+YMO5LlDsi++pcrb6M2X9W0 Vg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2u8hpsa504-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:37 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LcZFU097348 for ; Fri, 9 Aug 2019 21:38:37 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2u8pj9m4k8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:36 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79LcKue002216 for ; Fri, 9 Aug 2019 21:38:20 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:20 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 12/19] xfsprogs: Factor out xfs_attr_rmtval_remove_value Date: Fri, 9 Aug 2019 14:37:57 -0700 Message-Id: <20190809213804.32628-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- libxfs/xfs_attr_remote.c | 25 +++++++++++++++++++------ libxfs/xfs_attr_remote.h | 1 + 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 5452de4..6904b86 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -589,19 +589,14 @@ xfs_attr_rmtval_set_value( 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( +xfs_attr_rmtval_remove_value( 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); @@ -645,7 +640,25 @@ 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; + + error = xfs_attr_rmtval_remove_value(args); + if (error) + return error; /* * Keep de-allocating extents until the remote-value region is gone. */ diff --git a/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index 2a73cd9..9a58a23 100644 --- a/libxfs/xfs_attr_remote.h +++ b/libxfs/xfs_attr_remote.h @@ -11,6 +11,7 @@ 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_remove_value(struct xfs_da_args *args); int xfs_attr_rmtval_set_value(struct xfs_da_args *args); int xfs_attr_rmt_find_hole(struct xfs_da_args *args, int *blkcnt, xfs_fileoff_t *lfileoff); From patchwork Fri Aug 9 21:37:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8AC11709 for ; Fri, 9 Aug 2019 21:38:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9801B204FB for ; Fri, 9 Aug 2019 21:38:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CEEA212D9; Fri, 9 Aug 2019 21:38:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34E01205F7 for ; Fri, 9 Aug 2019 21:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728044AbfHIVi2 (ORCPT ); Fri, 9 Aug 2019 17:38:28 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56466 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728261AbfHIVi2 (ORCPT ); Fri, 9 Aug 2019 17:38:28 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYWqm092774 for ; Fri, 9 Aug 2019 21:38:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=xURqKnw2AYzfxDgonRr9LQ/sDi3OLcUYAZzffx4nSec=; b=DiXLxDdmacX/1rEwCoeABxOQ+zsLym9m4qhWNICOKJYVDvFHrXFS1HxnAMJ/W6xONT/O Crca4aH7o+CZz6PsHTzTv/gXaTIHZZCJtj5uBJNeE5FDh0mbLfgqDWttsC1Pin0bPayP 9/NGsO9qkkjzgWS57w8bhxoHewrnvlvLrg+ebcEa/UTVLRdN3R8PY86VFlm6GUwBk9tO fYbJBzfErQykqKLicHqSBtIFH3dP47WHOc0zQvziVBDz8Y/wskPROewIuuxY20UqupR6 AS3wDVdN4WpRKYnP/5kBI6imfad3dTTSNFH6rZHLJxnL1mtBsJTOi5xBR5FiEZ/2cOgO Ug== 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-2018-07-02; bh=xURqKnw2AYzfxDgonRr9LQ/sDi3OLcUYAZzffx4nSec=; b=a6rdv0p8oPtcHqsaTE9CVSxSzFVvWpxUaJO6gfHYaCYnzJ+jx7bwWTWxR5k+KuonM9j8 ucDNcul1qbZqDvVD11EO3dfSMDHMlORqFMwyWDpCOx5DL2t/3weM299tBzOBRfSBtdsf m/roHVt0xWtqMYZsT5nobCXLgR3REPYU/Csk/V4OsHqGpTNL3Coez9acbJRhXen9628L +jhGFx6nYm8rKhOMhq+UqV9vwd5eb3bB/D7to1V0oNwP7sw4Q1m0Nfd7P4Vho6O28X9K uAFFf0ngMtwcZlQrQi0WwBNOqBLbWL01z5KfBvU4aGNL/iKW0VXVvrnhEmrihBsZLh+M Tg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2u8hasj9a6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:26 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LcP8D110088 for ; Fri, 9 Aug 2019 21:38:25 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2u90t814hs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:25 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x79LcLh1005171 for ; Fri, 9 Aug 2019 21:38:21 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:20 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 13/19] xfsprogs: Factor up trans roll in xfs_attr3_leaf_clearflag Date: Fri, 9 Aug 2019 14:37:58 -0700 Message-Id: <20190809213804.32628-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP New delayed allocation routines cannot be handling transactions so factor them up into the calling functions Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 12 ++++++++++++ libxfs/xfs_attr_leaf.c | 5 +---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 8e63377..8e8d058 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -824,6 +824,12 @@ xfs_attr_leaf_addname(struct xfs_da_args *args) * Added a "remote" value, just clear the incomplete flag. */ error = xfs_attr3_leaf_clearflag(args); + + /* + * Commit the flag value change and start the next trans in + * series. + */ + error = xfs_trans_roll_inode(&args->trans, args->dp); } return error; } @@ -1181,6 +1187,12 @@ 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); } retval = error = 0; diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 049c786..c3e064a 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -2721,10 +2721,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 error; } /* From patchwork Fri Aug 9 21:37:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E852912 for ; Fri, 9 Aug 2019 21:38:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B50D204BF for ; Fri, 9 Aug 2019 21:38:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FB45212D9; Fri, 9 Aug 2019 21:38:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6B46204FB for ; Fri, 9 Aug 2019 21:38:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726157AbfHIVi1 (ORCPT ); Fri, 9 Aug 2019 17:38:27 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56458 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726475AbfHIVi1 (ORCPT ); Fri, 9 Aug 2019 17:38:27 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYQvZ092736 for ; Fri, 9 Aug 2019 21:38:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=TbyReKYCZntkw+aSgQH6SGtLScq6ryyHzvvMPn+4lAQ=; b=b/hd7KQjoepsKTOfKKjowMTIc54fpj4JTHnU/O03Eh43Gr51Zyt0g/xr+/FA712rxQsi 6ytsb8688iE+6v8nfci1Im3tqhBwWO938QyHS29oLJOzTt3rikECUzVp0mWa+fWBakvN Nuncd9Cv6Y/2sWyUfL9PM/PDxutGMyyZRWwdcQxllR21JE4we83nLDjw+VkVozlr7WQo sPXMqHnaIQGmycG1+wZKbKsWNAVlADWibFEjMfqp+Hvy5EtWoezqyw1+riL14Nu1GJHi 8yC7DCAJ16BGulfHnUzWZhZrIBJwfrvwS/g98R5ihP83XvS+slUJe3obbsKZq3/FW+89 aw== 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-2018-07-02; bh=TbyReKYCZntkw+aSgQH6SGtLScq6ryyHzvvMPn+4lAQ=; b=aoQvycjf61AyX+4EvOULGiLgCR6BD01vZQKcnN5NrytKhldgJDVF48T+zxuq+EjWRNsl ZuxO23LtWq9UskifvD8D7yAKM262VJ2hAVFqGs0OoLTpPZDQ3SdChDnOGFCtDMxh5Ib4 Jxpieyk4yL2x7cgKfsH0y4ceICCcPyjlDVZcqfdSAEK40p/sHEWNQ9F7o07cVS/OCc1s o+YSDs2XbQjqQdXqILqV0TVkpVy3PRrSW517EpPXuDsZ4EECkiYip2AlrZLzjaRq9aYL K31HGMKWeMc1JVbC79rb9tiJvPDVu/ZPZQNd0HhOiY6vqsHDBIHltwPnT6H/iSwCXy3p pQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2u8hasj9a3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:25 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LcOSA112177 for ; Fri, 9 Aug 2019 21:38:25 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2u8x9fxkb5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:25 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79LcL6Q019417 for ; Fri, 9 Aug 2019 21:38:21 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:21 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 14/19] xfsprogs: Add delay context to xfs_da_args Date: Fri, 9 Aug 2019 14:37:59 -0700 Message-Id: <20190809213804.32628-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a new struct xfs_delay_context, which we will use to keep track of the current state of a delayed attribute operation. The flags member 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. Signed-off-by: Allison Collins --- libxfs/xfs_attr.h | 6 ++++++ libxfs/xfs_da_btree.h | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 06ed120..53d7d7e 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -91,6 +91,12 @@ struct xfs_attr_item { struct list_head xattri_list; /* + * xfs_da_args needs to remain instantiated across transaction rolls + * during the defer finish, so store it here + */ + struct xfs_da_args xattri_args; + + /* * A byte array follows the header containing the file name and * attribute value. */ diff --git a/libxfs/xfs_da_btree.h b/libxfs/xfs_da_btree.h index 84dd865..b4607ad 100644 --- a/libxfs/xfs_da_btree.h +++ b/libxfs/xfs_da_btree.h @@ -42,6 +42,28 @@ enum xfs_dacmp { XFS_CMP_CASE /* names are same but differ in case */ }; +#define XFS_DC_INIT 0x01 /* Init delay info */ +#define XFS_DC_FOUND_LBLK 0x02 /* We found leaf blk for attr */ +#define XFS_DC_FOUND_NBLK 0x04 /* We found node blk for attr */ +#define XFS_DC_ALLOC_LEAF 0x08 /* We are allocating leaf blocks */ +#define XFS_DC_ALLOC_NODE 0x10 /* We are allocating node blocks */ +#define XFS_DC_RM_LEAF_BLKS 0x20 /* We are removing leaf blocks */ +#define XFS_DC_RM_NODE_BLKS 0x40 /* We are removing node blocks */ + +/* + * Context used for keeping track of delayed attribute operations + */ +struct xfs_delay_context { + unsigned int flags; + struct xfs_buf *leaf_bp; + struct xfs_bmbt_irec map; + xfs_dablk_t lblkno; + xfs_fileoff_t lfileoff; + int blkcnt; + struct xfs_da_state *state; + struct xfs_da_state_blk *blk; +}; + /* * Structure to ease passing around component names. */ @@ -71,6 +93,7 @@ typedef struct xfs_da_args { int rmtvaluelen2; /* remote attr value length in bytes */ int op_flags; /* operation flags */ enum xfs_dacmp cmpresult; /* name compare result for lookups */ + struct xfs_delay_context dc; /* context used for delay attr ops */ } xfs_da_args_t; /* From patchwork Fri Aug 9 21:38:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28DDD912 for ; Fri, 9 Aug 2019 21:38:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1448D204BF for ; Fri, 9 Aug 2019 21:38:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 089F1205F7; Fri, 9 Aug 2019 21:38:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94807204BF for ; Fri, 9 Aug 2019 21:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726652AbfHIVi2 (ORCPT ); Fri, 9 Aug 2019 17:38:28 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59514 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728190AbfHIVi1 (ORCPT ); Fri, 9 Aug 2019 17:38:27 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYPO7084493 for ; Fri, 9 Aug 2019 21:38:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=DQdanyK38FrNYWj4SZtFbKs5sGGx3TrxRCOK53iRTGc=; b=jzRyY0h7cIN5IGrECYevWeVARJfufP9/on1aryXkYpKkpdn/6PJNDGtamZRVytewf1I7 YqZLImrpfeSBwaPvndGtxYpiyjMn4pptpQbU+rzS07GhsQUR+VYJegeVuDtNV9dLDVP2 ii6rxzin1Ej/tThDcAPKrZqEN0TwnE4I8x8N1qYMABCtJ2fWIcnQ2xaQSaHBBJj8II19 eVHJO0j2ehBJOuDzCmkPEXl/+uBThwYPUu28p4+i4tJbj+eKldzFMzTC+5ZJfHQZm/j/ L7UM03u+NNz0I0Yuy+RXrGzmKdG5zWE8nsTg1xuLWla2LtiBLNIjFk8JVIRLOAX7DbM6 Xw== 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-2018-07-02; bh=DQdanyK38FrNYWj4SZtFbKs5sGGx3TrxRCOK53iRTGc=; b=NmMsKxhFxjm5XTFaByhNwsqsfj6L7zNmHmgLDnUfD1g6TAqseesAI8jG7kORhwSeqpKV AY9RMCGnQBjA6MbEbZerzJBhXddnymYpYTNnxrIdzljNCXrcmqfRpsv1TmCj9kUJ+lS6 O5I+aMDPO23Ryb6jLq3aKR7vY86AEyBpt4YKIOUYH3nwcdTJLPROTOkwaRoMBriCcCku 4MFQDeboRdmq1RVK2Hevn/0DhYVWp0LDymXBY6qjuhRaVjwiN1wEjA/Gld1WmBts5S6Q lc8BpaetbKiSgQteHNq2NoUf+DVxeac1wbFWCRf2InyNHVnzdDBmsA+qJ7Wl+PYssBhO HA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2u8hgpa7y9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:26 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LcPZZ112215 for ; Fri, 9 Aug 2019 21:38:25 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2u8x9fxkbh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:25 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x79LcMDE010617 for ; Fri, 9 Aug 2019 21:38:22 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:21 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 15/19] xfsprogs: Add delayed attribute routines Date: Fri, 9 Aug 2019 14:38:00 -0700 Message-Id: <20190809213804.32628-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds new delayed attribute routines: xfs_attr_da_set_args xfs_attr_da_remove_args xfs_attr_da_leaf_addname xfs_attr_da_node_addname xfs_attr_da_node_removename These routines are similar to their existing counter parts, but they do not roll or commit transactions. They instead return -EGAIN to allow the calling function to roll the transaction and recall the function. This allows the attribute operations to be logged in multiple smaller transactions. Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 720 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/xfs_attr.h | 2 + 2 files changed, 722 insertions(+) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 8e8d058..ecc525c 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -48,6 +48,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_da_leaf_addname(xfs_da_args_t *args); STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); STATIC int xfs_leaf_has_attr(xfs_da_args_t *args, struct xfs_buf **bp); @@ -56,12 +57,16 @@ STATIC int xfs_leaf_has_attr(xfs_da_args_t *args, struct xfs_buf **bp); */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC int xfs_attr_node_addname(xfs_da_args_t *args); +STATIC int xfs_attr_da_node_addname(xfs_da_args_t *args); STATIC int xfs_attr_node_removename(xfs_da_args_t *args); +STATIC int xfs_attr_da_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); +STATIC int +xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); int xfs_attr_args_init( @@ -283,6 +288,117 @@ xfs_attr_set_args( } /* + * Set the attribute specified in @args. + * This routine is meant to function as a delayed operation, and may return + * -EGAIN 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_da_set_args( + struct xfs_da_args *args, + struct xfs_buf **leaf_bp) +{ + struct xfs_inode *dp = args->dp; + int error = 0; + int sf_size; + struct xfs_buf *bp; + struct xfs_buf_log_item *bip; + + /* + * New inodes may not have an attribute fork yet. So set the attribute + * fork appropriately + */ + if (XFS_IFORK_Q((args->dp)) == 0) { + sf_size = sizeof(struct xfs_attr_sf_hdr) + + XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); + xfs_bmap_set_attrforkoff(args->dp, sf_size, NULL); + args->dp->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP); + args->dp->i_afp->if_flags = XFS_IFEXTENTS; + } + + /* + * If the attribute list is non-existent or a shortform list, + * upgrade it to a single-leaf-block attribute list. + */ + 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)) { + /* + * 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; + + /* + * 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); + return -EAGAIN; + } + + /* + * 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) { + bp = *leaf_bp; + bip = (struct xfs_buf_log_item *)(bp->b_log_item); + if (bp->b_transp == args->trans) + xfs_trans_brelse(args->trans, *leaf_bp); + *leaf_bp = NULL; + } + + /* + * If we fit in a block, or we are in the middle of adding a leaf name. + * xfs_attr_da_leaf_addname will set the XFS_DC_ALLOC_LEAF to indicate + * that it is not done yet, and need to be recalled to finish up from + * the last EAGAIN it returned + */ + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK) || + args->dc.flags & XFS_DC_ALLOC_LEAF) { + if (!(args->dc.flags & XFS_DC_FOUND_LBLK)) { + error = xfs_attr_leaf_try_add(args, *leaf_bp); + args->dc.flags |= XFS_DC_FOUND_LBLK; + + if (error && error != -ENOSPC) + return error; + + return -EAGAIN; + } + + error = xfs_attr_da_leaf_addname(args); + if (error && error != -ENOSPC) + return error; + } else { + error = xfs_attr_da_node_addname(args); + } + + return error; +} + + + +/* * Return EEXIST if attr is found, or ENOATTR if not */ int @@ -332,6 +448,57 @@ xfs_attr_remove_args( return error; } +/* + * Remove the attribute specified in @args. + * This routine is meant to function as a delayed operation, and may return + * -EGAIN 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_da_remove_args( + struct xfs_da_args *args) +{ + struct xfs_inode *dp = args->dp; + struct xfs_buf *bp; + int forkoff, error = 0; + + if (!xfs_inode_hasattr(dp)) { + error = -ENOATTR; + } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { + ASSERT(dp->i_afp->if_flags & XFS_IFINLINE); + error = xfs_attr_shortform_remove(args); + } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK) && + !(args->dc.flags & XFS_DC_RM_NODE_BLKS)) { + /* + * If we fit in a block AND we are not in the middle of + * removing node blocks, remove the leaf attribute. + * xfs_attr_da_node_removename will set XFS_DC_RM_NODE_BLKS to + * signal that it is not done yet, and needs to be recalled to + * to finish up from the last -EAGAIN + */ + error = xfs_leaf_has_attr(args, &bp); + if (error == -ENOATTR) { + xfs_trans_brelse(args->trans, bp); + return error; + } + error = 0; + + xfs_attr3_leaf_remove(bp, args); + + /* If the result is small enough, shrink it into the inode.*/ + forkoff = xfs_attr_shortform_allfit(bp, dp); + if (forkoff) + error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); + } else { + error = xfs_attr_da_node_removename(args); + } + + return error; +} + + + int xfs_attr_set( struct xfs_inode *dp, @@ -835,6 +1002,150 @@ xfs_attr_leaf_addname(struct xfs_da_args *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). + * + * This routine is meant to function as a delayed operation, and may return + * -EGAIN 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_da_leaf_addname( + struct xfs_da_args *args) +{ + int error, forkoff, nmap; + struct xfs_buf *bp = NULL; + struct xfs_inode *dp = args->dp; + struct xfs_bmbt_irec *map = &args->dc.map; + + /* + * If there was an out-of-line value, allocate the blocks we + * identified for its storage and copy the value. This is done + * after we create the attribute so that we don't overflow the + * maximum size of a transaction and/or hit a deadlock. + */ + if (args->rmtblkno > 0) { + if (!(args->dc.flags & XFS_DC_ALLOC_LEAF)) { + args->dc.lfileoff = 0; + args->dc.lblkno = 0; + args->dc.blkcnt = 0; + memset(map, 0, sizeof(struct xfs_bmbt_irec)); + + error = xfs_attr_rmt_find_hole(args, &args->dc.blkcnt, + &args->dc.lfileoff); + if (error) + return error; + + args->dc.lblkno = (xfs_dablk_t)args->dc.lfileoff; + args->dc.flags |= XFS_DC_ALLOC_LEAF; + } + + /* + * Roll through the "value", allocating blocks on disk as + * required. + */ + while (args->dc.blkcnt > 0) { + nmap = 1; + error = xfs_bmapi_write(args->trans, dp, + (xfs_fileoff_t)args->dc.lblkno, + args->dc.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->dc.lblkno += map->br_blockcount; + args->dc.blkcnt -= map->br_blockcount; + + return -EAGAIN; + } + + error = xfs_attr_rmtval_set_value(args); + if (error) + return error; + } + + /* + * If this is an atomic rename operation, we must "flip" the + * incomplete flags on the "new" and "old" attribute/value pairs + * so that one disappears and one appears atomically. Then we + * must remove the "old" attribute/value pair. + */ + if (args->op_flags & XFS_DA_OP_RENAME) { + /* + * In a separate transaction, set the incomplete flag on the + * "old" attr and clear the incomplete flag on the "new" attr. + */ + if (!xfs_attr3_leaf_flagsflipped(args)) { + error = xfs_attr3_leaf_flipflags(args); + if (error) + return error; + return -EAGAIN; + } + /* + * 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; + if (args->rmtblkno) { + int done = 0; + + error = xfs_attr_rmtval_remove_value(args); + if (error) + return error; + + while (!done && !error) + error = xfs_bunmapi(args->trans, + args->dp, args->rmtblkno, + args->rmtblkcnt, XFS_BMAPI_ATTRFORK, + 1, &done); + + if (error) + return error; + } + + /* + * Read in the block containing the "old" attr, then + * remove the "old" attr from that block (neat, huh!) + */ + error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, + -1, &bp); + if (error) + return error; + + xfs_attr3_leaf_remove(bp, args); + + /* + * If the result is small enough, shrink it all into the inode. + */ + forkoff = xfs_attr_shortform_allfit(bp, dp); + if (forkoff) { + error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); + /* bp is gone due to xfs_da_shrink_inode */ + if (error) + return error; + } + } else if (args->rmtblkno > 0) { + /* + * Added a "remote" value, just clear the incomplete flag. + */ + error = xfs_attr3_leaf_clearflag(args); + } + args->dc.flags &= ~XFS_DC_ALLOC_LEAF; + return error; +} + +/* * Return EEXIST if attr is found, or ENOATTR if not */ STATIC int @@ -1330,6 +1641,415 @@ out: } /* + * Remove a name from a B-tree attribute list. + * + * 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 a delayed operation, and may return + * -EGAIN 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_da_node_removename( + struct xfs_da_args *args) +{ + struct xfs_da_state *state = NULL; + struct xfs_da_state_blk *blk; + struct xfs_buf *bp; + int error, forkoff, retval = 0; + struct xfs_inode *dp = args->dp; + int done = 0; + + trace_xfs_attr_node_removename(args); + + if (args->dc.state == NULL) { + error = xfs_attr_node_hasname(args, &args->dc.state); + if (error != -EEXIST) + goto out; + else + error = 0; + + /* + * If there is an out-of-line value, de-allocate the blocks. + * This is done before we remove the attribute so that we don't + * overflow the maximum size of a transaction and/or hit a + * deadlock. + */ + state = args->dc.state; + args->dc.blk = &state->path.blk[state->path.active - 1]; + ASSERT(args->dc.blk->bp != NULL); + ASSERT(args->dc.blk->magic == XFS_ATTR_LEAF_MAGIC); + } + state = args->dc.state; + blk = args->dc.blk; + + if (args->rmtblkno > 0 && !(args->dc.flags & XFS_DC_RM_LEAF_BLKS)) { + if (!xfs_attr3_leaf_flag_is_set(args)) { + /* + * 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); + if (error) + goto out; + + return -EAGAIN; + } + + if (!(args->dc.flags & XFS_DC_RM_NODE_BLKS)) { + error = xfs_attr_rmtval_remove_value(args); + if (error) + goto out; + } + + args->dc.flags |= XFS_DC_RM_NODE_BLKS; + while (!done && !error) { + error = xfs_bunmapi(args->trans, args->dp, + args->rmtblkno, args->rmtblkcnt, + XFS_BMAPI_ATTRFORK, 1, &done); + if (error) + return error; + + if (!done) + return -EAGAIN; + } + + if (error) + goto out; + + /* + * Refill the state structure with buffers, the prior calls + * released our buffers. + */ + error = xfs_attr_refillstate(state); + if (error) + goto out; + } + + /* + * Remove the name and update the hashvals in the tree. + */ + if (!(args->dc.flags & XFS_DC_RM_LEAF_BLKS)) { + blk = &state->path.blk[state->path.active - 1]; + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + retval = xfs_attr3_leaf_remove(blk->bp, args); + xfs_da3_fixhashpath(state, &state->path); + + args->dc.flags |= XFS_DC_RM_LEAF_BLKS; + } + + /* + * Check to see if the tree needs to be collapsed. + */ + if (retval && (state->path.active > 1)) { + args->dc.flags |= XFS_DC_RM_NODE_BLKS; + error = xfs_da3_join(state); + if (error) + goto out; + + return -EAGAIN; + } + + /* + * 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; + + 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) + goto out; + } else + xfs_trans_brelse(args->trans, bp); + } +out: + if (state != NULL) + xfs_da_state_free(state); + + return error; +} + +/* + * Add a name to a Btree-format attribute list. + * + * This will involve walking down the Btree, and may involve splitting + * leaf nodes and even splitting intermediate nodes up to and including + * the root node (a special case of an intermediate node). + * + * "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 + * -EGAIN 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_da_node_addname( + struct xfs_da_args *args) +{ + struct xfs_da_state *state = NULL; + struct xfs_da_state_blk *blk; + struct xfs_inode *dp; + struct xfs_mount *mp; + int retval, error = 0; + int nmap; + int done = 0; + struct xfs_bmbt_irec *map = &args->dc.map; + + trace_xfs_attr_node_addname(args); + + /* + * Fill in bucket of arguments/results/context to carry around. + */ + dp = args->dp; + mp = dp->i_mount; + + if (args->dc.flags & XFS_DC_FOUND_NBLK) + goto found_blk; + + /* + * Search to see if name already exists, and get back a pointer + * to where it should go. + */ + retval = xfs_attr_node_hasname(args, &state); + blk = &state->path.blk[state->path.active-1]; + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) { + goto out; + } else if (retval == -EEXIST) { + if (args->flags & ATTR_CREATE) + goto out; + + trace_xfs_attr_node_replace(args); + + /* 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; + + /* + * clear the remote attr state now that it is saved so that the + * values reflect the state of the attribute we are about to + * add, not the attribute we just found and will remove later. + */ + args->rmtblkno = 0; + args->rmtblkcnt = 0; + args->rmtvaluelen = 0; + } + + retval = xfs_attr3_leaf_add(blk->bp, state->args); + if (retval == -ENOSPC) { + if (state->path.active == 1) { + /* + * Its really a single leaf node, but it had + * out-of-line values so it looked like it *might* + * have been a b-tree. + */ + xfs_da_state_free(state); + state = NULL; + error = xfs_attr3_leaf_to_node(args); + if (error) + goto out; + + return -EAGAIN; + } + + /* + * Split as many Btree elements as required. + * This code tracks the new and old attr's location + * in the index/blkno/rmtblkno/rmtblkcnt fields and + * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields. + */ + error = xfs_da3_split(state); + if (error) + goto out; + } else { + /* + * Addition succeeded, update Btree hashvals. + */ + xfs_da3_fixhashpath(state, &state->path); + } + + /* + * Kill the state structure, we're done with it and need to + * allow the buffers to come back later. + */ + xfs_da_state_free(state); + state = NULL; + + args->dc.flags |= XFS_DC_FOUND_NBLK; + return -EAGAIN; +found_blk: + + /* + * If there was an out-of-line value, allocate the blocks we + * identified for its storage and copy the value. This is done + * after we create the attribute so that we don't overflow the + * maximum size of a transaction and/or hit a deadlock. + */ + if (args->rmtblkno > 0) { + if (!(args->dc.flags & XFS_DC_ALLOC_NODE)) { + args->dc.flags |= XFS_DC_ALLOC_NODE; + args->dc.lblkno = 0; + args->dc.lfileoff = 0; + args->dc.blkcnt = 0; + memset(map, 0, sizeof(struct xfs_bmbt_irec)); + + error = xfs_attr_rmt_find_hole(args, &args->dc.blkcnt, + &args->dc.lfileoff); + if (error) + return error; + + args->dc.lblkno = (xfs_dablk_t)args->dc.lfileoff; + } + /* + * Roll through the "value", allocating blocks on disk as + * required. + */ + while (args->dc.blkcnt > 0) { + nmap = 1; + error = xfs_bmapi_write(args->trans, dp, + (xfs_fileoff_t)args->dc.lblkno, args->dc.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->dc.lblkno += map->br_blockcount; + args->dc.blkcnt -= map->br_blockcount; + + return -EAGAIN; + } + + error = xfs_attr_rmtval_set_value(args); + if (error) + return error; + } + + /* + * If this is an atomic rename operation, we must "flip" the + * incomplete flags on the "new" and "old" attribute/value pairs + * so that one disappears and one appears atomically. Then we + * must remove the "old" attribute/value pair. + */ + if (args->op_flags & XFS_DA_OP_RENAME) { + /* + * In a separate transaction, set the incomplete flag on the + * "old" attr and clear the incomplete flag on the "new" attr. + */ + if (!xfs_attr3_leaf_flagsflipped(args)) { + error = xfs_attr3_leaf_flipflags(args); + if (error) + goto out; + return -EAGAIN; + } + /* + * 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; + if (args->rmtblkno) { + error = xfs_attr_rmtval_remove_value(args); + if (error) + return error; + + while (!done && !error) + error = xfs_bunmapi(args->trans, + args->dp, args->rmtblkno, + args->rmtblkcnt, XFS_BMAPI_ATTRFORK, + 1, &done); + if (error) + return error; + } + + /* + * Re-find the "old" attribute entry after any split ops. + * The INCOMPLETE flag means that we will find the "old" + * attr, not the "new" one. + */ + args->flags |= XFS_ATTR_INCOMPLETE; + state = xfs_da_state_alloc(); + state->args = args; + state->mp = mp; + state->inleaf = 0; + error = xfs_da3_node_lookup_int(state, &retval); + if (error) + goto out; + + /* + * Remove the name and update the hashvals in the tree. + */ + blk = &state->path.blk[state->path.active - 1]; + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + error = xfs_attr3_leaf_remove(blk->bp, args); + xfs_da3_fixhashpath(state, &state->path); + + /* + * Check to see if the tree needs to be collapsed. + */ + if (retval && (state->path.active > 1)) { + error = xfs_da3_join(state); + if (error) + goto out; + } + } else if (args->rmtblkno > 0) { + /* + * Added a "remote" value, just clear the incomplete flag. + */ + error = xfs_attr3_leaf_clearflag(args); + if (error) + goto out; + } + retval = error = 0; + +out: + if (state) + xfs_da_state_free(state); + if (error) + return error; + + return retval; +} + + + +/* * Fill in the disk block numbers in the state structure for the buffers * that are attached to the state structure. * This is done so that we can quickly reattach ourselves to those buffers diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 53d7d7e..c673aa5 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -169,9 +169,11 @@ 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 xfs_attr_set_args(struct xfs_da_args *args); +int xfs_attr_da_set_args(struct xfs_da_args *args, struct xfs_buf **leaf_bp); int xfs_attr_remove(struct xfs_inode *dp, struct xfs_name *name); int xfs_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); +int xfs_attr_da_remove_args(struct xfs_da_args *args); int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize, int flags, struct attrlist_cursor_kern *cursor); bool xfs_attr_namecheck(const void *name, size_t length); From patchwork Fri Aug 9 21:38:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087709 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C113913AC for ; Fri, 9 Aug 2019 21:39:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD5B2204BF for ; Fri, 9 Aug 2019 21:39:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D9F4205F7; Fri, 9 Aug 2019 21:39:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3340F204BF for ; Fri, 9 Aug 2019 21:39:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726219AbfHIVjX (ORCPT ); Fri, 9 Aug 2019 17:39:23 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57608 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725985AbfHIVjX (ORCPT ); Fri, 9 Aug 2019 17:39:23 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYaDF092809 for ; Fri, 9 Aug 2019 21:39:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=+6kAFYbry7YJL6a5SWY+0JdO1x+2aYHPGbxbURcG+Q0=; b=VRmX3FgPDpg2rnzhrCY2BNzD8rHLdWVB1qbgeA5mCG52HTd2H8vS+qiF1DshbFu2xTGP IWfuXgKiaoe6fe15FqzwI8OHFJxS/9+sCYv9Rrm8lovczAxIgOJKikIidSxaa/jDe+Vm DtNtOFYPx3MLSLG/Ev1QOGI8RikKgzzjnTac+aymRJeoXNGFmtIHXBOFhKPkiKGgq16i Vj1kkaHv+nAF3iIIb1h41mv2d8pfgNamRvx5XtKR4ezBd4coQBHZ055TmhUWhoIcIqd7 kPUTTequ40RwU/c62fihZb7STArcFxdXaUjpmpPmhis1QQ4YncCkUPUybl/8mtxNcPuy kQ== 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-2018-07-02; bh=+6kAFYbry7YJL6a5SWY+0JdO1x+2aYHPGbxbURcG+Q0=; b=VzOwrPmovOQ3iqr/w/v7MvaU11PuwnxoWIkR40y/8X1XKvug4DhlT4r5fbyAM64B46Lj PijhBpeZUtSZEhO2FdmIDY/lgySnNS4dV2YN5u8MBrb5uTZWWLdzjpAaj4SxJBcDeo08 7pfwmNIAS0gMqwLKV3voDKsEDEmqL55B9m0D++6CqOFDaqZQcsUiBtKsBZFStoJ/T+aF hCHBwAP4W02XtOfxBjs9gg5fVCxwOlY11tnQuWrFNJnWFp1Eq31FOa+fVTBhMQaYmBcO pInJX0/JhhSLwoTO3jtQk7behCq6M/HlhCwzNEt8T17QifpVl9RKbRHfFIqsTQVxSIU0 Dw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2u8hasj9ce-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:39:21 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LdJA3047978 for ; Fri, 9 Aug 2019 21:39:21 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2u8x1h6w3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:39:20 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79LcMaL019445 for ; Fri, 9 Aug 2019 21:38:22 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:22 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 16/19] xfsprogs: Roll delayed attr operations by returning EAGAIN Date: Fri, 9 Aug 2019 14:38:01 -0700 Message-Id: <20190809213804.32628-17-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Modify delayed operations to use the new xfs_attr_da* routines In this patch, xfs_trans_attr is modified to use the new xfs_attr_da_* scheme, and pass the -EAGAIN back to the calling function. The leaf_bp is also factored up to be released after the transactions are handled. xfs_attri_recover will need to handle the -EAGAIN by logging and committing the transaction before recalling xfs_trans_attr. xfs_attr_finish_item does not need to handle the -EAGAIN since it is handled by its calling function. But it does need to plumb in xfs_da_args from the log item since it cant keep args instantiated in its own function context. Signed-off-by: Allison Collins --- libxfs/defer_item.c | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index b3dacdc..7e842fc 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -124,6 +124,7 @@ int xfs_trans_attr( struct xfs_da_args *args, struct xfs_attrd_log_item *attrdp, + struct xfs_buf **leaf_bp, uint32_t op_flags) { int error; @@ -135,11 +136,11 @@ xfs_trans_attr( switch (op_flags) { case XFS_ATTR_OP_FLAGS_SET: args->op_flags |= XFS_DA_OP_ADDNAME; - error = xfs_attr_set_args(args); + error = xfs_attr_da_set_args(args, leaf_bp); break; case XFS_ATTR_OP_FLAGS_REMOVE: ASSERT(XFS_IFORK_Q((args->dp))); - error = xfs_attr_remove_args(args); + error = xfs_attr_da_remove_args(args); break; default: error = -EFSCORRUPTED; @@ -207,30 +208,40 @@ xfs_attr_finish_item( unsigned char *name_value; int error; int local; - struct xfs_da_args args; + struct xfs_da_args *args; struct xfs_name name; struct xfs_attrd_log_item *attrdp; struct xfs_attri_log_item *attrip; attr = container_of(item, struct xfs_attr_item, xattri_list); - name_value = ((unsigned char *)attr) + sizeof(struct xfs_attr_item); + args = &attr->xattri_args; + name_value = ((unsigned char *)attr) + sizeof(struct xfs_attr_item); name.name = name_value; name.len = attr->xattri_name_len; name.type = attr->xattri_flags; - error = xfs_attr_args_init(&args, attr->xattri_ip, &name); - if (error) - goto out; - args.hashval = xfs_da_hashname(args.name, args.namelen); - args.value = &name_value[attr->xattri_name_len]; - args.valuelen = attr->xattri_value_len; - args.op_flags = XFS_DA_OP_OKNOENT; - args.total = xfs_attr_calc_size(&args, &local); - args.trans = tp; + if (!(args->dc.flags & XFS_DC_INIT)) { + error = xfs_attr_args_init(args, attr->xattri_ip, &name); + if (error) + goto out; + + args->hashval = xfs_da_hashname(args->name, args->namelen); + args->value = &name_value[attr->xattri_name_len]; + args->valuelen = attr->xattri_value_len; + args->op_flags = XFS_DA_OP_OKNOENT; + args->total = xfs_attr_calc_size(args, &local); + args->dc.flags |= XFS_DC_INIT; + } + + /* + * Always reset trans after EAGAIN cycle + * since the transaction is new + */ + args->trans = tp; - error = xfs_trans_attr(&args, done_item, - attr->xattri_op_flags); + error = xfs_trans_attr(args, done_item, &args->dc.leaf_bp, + attr->xattri_op_flags); out: /* * We are about to free the xfs_attr_item, so we need to remove any @@ -243,7 +254,8 @@ out: attrip->attri_name_len = 0; attrip->attri_value_len = 0; - kmem_free(attr); + if (error != -EAGAIN) + kmem_free(attr); return error; } From patchwork Fri Aug 9 21:38:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087695 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8DF313AC for ; Fri, 9 Aug 2019 21:38:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7260204FB for ; Fri, 9 Aug 2019 21:38:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B9A2212D9; Fri, 9 Aug 2019 21:38:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47874205F7 for ; Fri, 9 Aug 2019 21:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726475AbfHIVi1 (ORCPT ); Fri, 9 Aug 2019 17:38:27 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59498 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726652AbfHIVi1 (ORCPT ); Fri, 9 Aug 2019 17:38:27 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYShK084522 for ; Fri, 9 Aug 2019 21:38:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=wr1uUXmGkqszOuWEaX01Mt0qYKWjwwd/hGmqu7n0URM=; b=E6gEnaUhjPSpgMs0Zeq3l0yBorg/eCUM62H7Gi1nvQzTua3lMkwr/afQQ7VbFDYDMZE8 PkwMQ3r82/nO46IVYSr6ziMcuXsRUZ1A2yCG8tc3JJjuQPFEc7yL0IBZ+IHYW5SdUNAm miPp9S0fYERNMMYna7jgR+on2IU0/0b9Ntk5jOAULXVVhweabJdWO2YVpfYkQW7KS/iV 9p/inEiL0vQqNIGd4XlrQkuiNhI4DiLGI8oa41k3GHc5HKe2fvAPySKIkCOhzuM7vQUw Y4xwJVQKFJ7BA/4hBgJCef7VEsfTCkuzPFCqSEkcXz4gfFu/yWWllMm2Bo3HyDt6pwTB gg== 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-2018-07-02; bh=wr1uUXmGkqszOuWEaX01Mt0qYKWjwwd/hGmqu7n0URM=; b=ssENfZ+hEWF9evdwph8FbfaOX7xvRHY1bNL08Ofekgz8EdrAt620TQ7GuY2HWtxZ0Dx/ 0F2ovm+acyu2CN2Wt2k/anj0j+qrYz3q6w/udqbpN+VdE66YYmMd43P3kFOqFaGZzs/D yJmHT0obNYeaXkRTmJoSs5EE+myyxDJqdS76dCiGGfUuAwsN2OzZIsQX6OwRdUWJPvZZ B80bYtBRAC/mEnEDPF32VfiFxMV7mBugm/Im2rtLqaJO205FPbWHkEc4Zx5ETkgA8wSz U5xURSuZ4O3CYa74mXErHDjDXMoVF38ixWzladDw0fc+64BhVcNosTY/Tv3LGg28Zqib dg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2u8hgpa7y8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:25 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LcPhw112258 for ; Fri, 9 Aug 2019 21:38:25 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2u8x9fxkbv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:25 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x79LcMAc010621 for ; Fri, 9 Aug 2019 21:38:23 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:22 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 17/19] xfsprogs: Enable delayed attributes Date: Fri, 9 Aug 2019 14:38:02 -0700 Message-Id: <20190809213804.32628-18-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Finally enable delayed attributes in xfs_attr_set and xfs_attr_remove. We only do this for v4 and up since we cant add new log entries to old fs versions Signed-off-by: Allison Collins --- libxfs/xfs_attr.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index ecc525c..dc38715 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -507,6 +507,7 @@ xfs_attr_set( int valuelen) { struct xfs_mount *mp = dp->i_mount; + struct xfs_sb *sbp = &mp->m_sb; struct xfs_da_args args; struct xfs_trans_res tres; int rsvd = (name->type & ATTR_ROOT) != 0; @@ -565,7 +566,20 @@ xfs_attr_set( goto out_trans_cancel; xfs_trans_ijoin(args.trans, dp, 0); - error = xfs_attr_set_args(&args); + if (XFS_SB_VERSION_NUM(sbp) < XFS_SB_VERSION_4) + error = xfs_attr_set_args(&args); + else { + 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_deferred(dp, args.trans, name, value, + valuelen); + } if (error) goto out_trans_cancel; if (!args.trans) { @@ -650,6 +664,7 @@ xfs_attr_remove( struct xfs_name *name) { struct xfs_mount *mp = dp->i_mount; + struct xfs_sb *sbp = &mp->m_sb; struct xfs_da_args args; int error; @@ -691,7 +706,14 @@ xfs_attr_remove( */ xfs_trans_ijoin(args.trans, dp, 0); - error = xfs_attr_remove_args(&args); + error = xfs_has_attr(&args); + if (error == -ENOATTR) + goto out; + + if (XFS_SB_VERSION_NUM(sbp) < XFS_SB_VERSION_4) + error = xfs_attr_remove_args(&args); + else + error = xfs_attr_remove_deferred(dp, args.trans, name); if (error) goto out; From patchwork Fri Aug 9 21:38:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6CCFF912 for ; Fri, 9 Aug 2019 21:38:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BF8F204FB for ; Fri, 9 Aug 2019 21:38:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50E3C21C9A; Fri, 9 Aug 2019 21:38:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7123204FB for ; Fri, 9 Aug 2019 21:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728190AbfHIVi2 (ORCPT ); Fri, 9 Aug 2019 17:38:28 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50520 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728044AbfHIVi1 (ORCPT ); Fri, 9 Aug 2019 17:38:27 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYVck071898 for ; Fri, 9 Aug 2019 21:38:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=ouc3YThaI6Y0UAcXZpiD6qApQPbUX3YPq/OlveGYzD8=; b=QbX4FHEbLoUJ6PC7bE0chTToY3koMySy3aWq+ay0s6JCL4FqrJVClbrNUI/hrlwuFu0v 1dYm3NQ9PdCKUEHr28+5Rr09MiF7/VdvwBT844zG3/sQw15lkwC00G2jtPqKLToSzSKD nxTty8PQlAitgTyG3vfH4FP49BJ9WGFGTvLvp7ec4Gj0FTUuYhVvPVRYZrEdYE4gVsGP 603Ln1rHW0Q4tO7C/weWzPSDuAVc0jN4ROVe87596vrz5Vfy53V01D8KxIeDQx/Se0T8 ocNI8QLoYNXEghI2pIhoA6Q0lrPrJn+tAcHJfUcO7j8J44VB49D/Bza32SB9xeYIMsXQ tQ== 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-2018-07-02; bh=ouc3YThaI6Y0UAcXZpiD6qApQPbUX3YPq/OlveGYzD8=; b=p8DlqnN0yBK2SINjKBhFEKdAiJ7q7Miywyjmk45+5E+R/whM9j2tc0CiQztqTg0UMsUh WNdm/pCXRyLbUMi8ARMoJWs2ujuVHwGAelVP1OuChYSnc708TRkapGZaNWT2SlrVmr20 pNohxQkxDVZzKu/3JZMmTJDiAldAEz0exLY14vVb96bZzGTvhwsbDdPk/e7cdqWrBhmr XgxeuWa8JWpEyGu/qyCBTvO5Ygu7JZrQsyBBQm6O6xE0MQenSjV89f2QXMo2TOvfpL3V 2Ddq6PqW0LTYxD9X0KpXBkC+0j3F5eT0hL9QTg7XOgLi83Rl0kvOa3ekUf5q21WFLvYp LQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2u8hpsa4yp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:26 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LcObP112194 for ; Fri, 9 Aug 2019 21:38:25 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2u8x9fxkc1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:38:25 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79LcNUs019449 for ; Fri, 9 Aug 2019 21:38:23 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:23 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 18/19] xfsprogs: Add delayed attributes error tag Date: Fri, 9 Aug 2019 14:38:03 -0700 Message-Id: <20190809213804.32628-19-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds an error tag that we can use to test delayed attribute recovery and replay Signed-off-by: Allison Collins Reviewed-by: Darrick J. Wong --- io/inject.c | 1 + libxfs/xfs_errortag.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/io/inject.c b/io/inject.c index cabfc3e..05bd4db 100644 --- a/io/inject.c +++ b/io/inject.c @@ -54,6 +54,7 @@ error_tag(char *name) { XFS_ERRTAG_FORCE_SCRUB_REPAIR, "force_repair" }, { XFS_ERRTAG_FORCE_SUMMARY_RECALC, "bad_summary" }, { XFS_ERRTAG_IUNLINK_FALLBACK, "iunlink_fallback" }, + { XFS_ERRTAG_DELAYED_ATTR, "delayed_attr" }, { XFS_ERRTAG_MAX, NULL } }; int count; diff --git a/libxfs/xfs_errortag.h b/libxfs/xfs_errortag.h index 79e6c4f..85d5850 100644 --- a/libxfs/xfs_errortag.h +++ b/libxfs/xfs_errortag.h @@ -55,7 +55,8 @@ #define XFS_ERRTAG_FORCE_SCRUB_REPAIR 32 #define XFS_ERRTAG_FORCE_SUMMARY_RECALC 33 #define XFS_ERRTAG_IUNLINK_FALLBACK 34 -#define XFS_ERRTAG_MAX 35 +#define XFS_ERRTAG_DELAYED_ATTR 35 +#define XFS_ERRTAG_MAX 36 /* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. @@ -95,5 +96,6 @@ #define XFS_RANDOM_FORCE_SCRUB_REPAIR 1 #define XFS_RANDOM_FORCE_SUMMARY_RECALC 1 #define XFS_RANDOM_IUNLINK_FALLBACK (XFS_RANDOM_DEFAULT/10) +#define XFS_RANDOM_DELAYED_ATTR 1 #endif /* __XFS_ERRORTAG_H_ */ From patchwork Fri Aug 9 21:38:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1008F912 for ; Fri, 9 Aug 2019 21:39:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1340204BF for ; Fri, 9 Aug 2019 21:39:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E566A205F7; Fri, 9 Aug 2019 21:39:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED3B2204BF for ; Fri, 9 Aug 2019 21:39:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726263AbfHIVj0 (ORCPT ); Fri, 9 Aug 2019 17:39:26 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57686 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725985AbfHIVj0 (ORCPT ); Fri, 9 Aug 2019 17:39:26 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LYaDG092809 for ; Fri, 9 Aug 2019 21:39:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=VGbn/0CCLHUExQj0UtW+o3cvj35zdahSKStpLTEre4c=; b=f9sVvqL2Ox5eSgW0hLiEAwGNH/X9zOVaXqdN4wzKg+F6HHT8QgK/kBciDnpTByi+wMYO ayWzawsHetkCuHQ1AB4y61v2IyebD9ABpgEIxQrIyDY1DOK63Dfvhk97jqmE2JMPlPLG Nd7El4efo6RaqLIaHynHd8425yitvfQ2fw/CctGw699Pz+H+yPHX3GfCyiQj4rEIujIk zi6SiXs4GSU25KhoJlZCayG+9mEFbojgyj2Jx2AwYcWWOd5djVvYhO71Wic+7iAE/7Xx vjoEnd+wroApWdm7OAtqEOMr0gif7CMupx4qLuvHt0cZmTkpUKEhH8Dl63xbvBumvtiv Ig== 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-2018-07-02; bh=VGbn/0CCLHUExQj0UtW+o3cvj35zdahSKStpLTEre4c=; b=H2fCe1+x45pXCvoDAAbO2EvZDvTrmywZRlWY11ZGqvWPjzgnP6ywuEHF8skxVhhBrbqc OaxakxsUGImdIyX6QfyM4LqvgE23ovVxqQ9etm4AblTar8XCoThol56/Cq+tRTFZppLN 1xxM9vKyRkjgJMv1fPDoddQ330yVdJp5R8NlGERSKNkOuMANp0UbN/HQzyX+YMUAJGpx 8uQM7BW1QS3tfTtsbw+ozFciWpDFcFvLW5cAr/WhoaD+fQhj6a8HAcjWkYqdGQd5hPiN r0ZZf/S/gAPF84K+2SurRsxPfQvnaBXGOxV+Gjy2TgTDxNJKF0ouINCCdIukwbAjZzao Jw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2u8hasj9cq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:39:24 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79LdJIq048016 for ; Fri, 9 Aug 2019 21:39:24 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2u8x1h6w44-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:39:23 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x79LcNtO005175 for ; Fri, 9 Aug 2019 21:38:23 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:38:23 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v1 19/19] xfsprogs: Add log item printing for ATTRI and ATTRD Date: Fri, 9 Aug 2019 14:38:04 -0700 Message-Id: <20190809213804.32628-20-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213804.32628-1-allison.henderson@oracle.com> References: <20190809213804.32628-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Allison Henderson This patch implements a new set of log printing functions to print the ATTRI and ATTRD items and vectors in the log. These will be used during log dump and log recover operations. Signed-off-by: Allison Henderson Signed-off-by: Allison Collins --- logprint/log_misc.c | 31 +++++++- logprint/log_print_all.c | 12 +++ logprint/log_redo.c | 189 +++++++++++++++++++++++++++++++++++++++++++++++ logprint/logprint.h | 7 ++ 4 files changed, 238 insertions(+), 1 deletion(-) diff --git a/logprint/log_misc.c b/logprint/log_misc.c index c325f04..7b2055d 100644 --- a/logprint/log_misc.c +++ b/logprint/log_misc.c @@ -54,11 +54,29 @@ print_stars(void) "***********************************\n"); } /* print_stars */ +void +print_hex_dump(char *ptr, int len) { + int i = 0; + + for (i = 0; i < len; i++) { + if (i % 16 == 0) + printf("%08x ", i); + + printf("%02x", ptr[i]); + + if ((i+1)%16 == 0) + printf("\n"); + else if ((i+1)%2 == 0) + printf(" "); + } + printf("\n"); +} + /* * Given a pointer to a data segment, print out the data as if it were * a log operation header. */ -static void +void xlog_print_op_header(xlog_op_header_t *op_head, int i, char **ptr) @@ -949,6 +967,17 @@ xlog_print_record( be32_to_cpu(op_head->oh_len)); break; } + case XFS_LI_ATTRI: { + skip = xlog_print_trans_attri(&ptr, + be32_to_cpu(op_head->oh_len), + &i); + break; + } + case XFS_LI_ATTRD: { + skip = xlog_print_trans_attrd(&ptr, + be32_to_cpu(op_head->oh_len)); + break; + } case XFS_LI_RUI: { skip = xlog_print_trans_rui(&ptr, be32_to_cpu(op_head->oh_len), diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c index eafffe2..f794a68 100644 --- a/logprint/log_print_all.c +++ b/logprint/log_print_all.c @@ -400,6 +400,12 @@ xlog_recover_print_logitem( case XFS_LI_EFI: xlog_recover_print_efi(item); break; + case XFS_LI_ATTRD: + xlog_recover_print_attrd(item); + break; + case XFS_LI_ATTRI: + xlog_recover_print_attri(item); + break; case XFS_LI_RUD: xlog_recover_print_rud(item); break; @@ -452,6 +458,12 @@ xlog_recover_print_item( case XFS_LI_EFI: printf("EFI"); break; + case XFS_LI_ATTRD: + printf("ATTRD"); + break; + case XFS_LI_ATTRI: + printf("ATTRI"); + break; case XFS_LI_RUD: printf("RUD"); break; diff --git a/logprint/log_redo.c b/logprint/log_redo.c index f1f690e..005fd84 100644 --- a/logprint/log_redo.c +++ b/logprint/log_redo.c @@ -8,6 +8,7 @@ #include "libxlog.h" #include "logprint.h" +#include "xfs_attr_item.h" /* Extent Free Items */ @@ -653,3 +654,191 @@ xlog_recover_print_bud( f = item->ri_buf[0].i_addr; xlog_print_trans_bud(&f, sizeof(struct xfs_bud_log_format)); } + +/* Attr Items */ + +static int +xfs_attri_copy_log_format( + char *buf, + uint len, + struct xfs_attri_log_format *dst_attri_fmt) +{ + uint dst_len = sizeof(struct xfs_attri_log_format); + + if (len == dst_len) { + memcpy((char *)dst_attri_fmt, buf, len); + return 0; + } + + fprintf(stderr, _("%s: bad size of attri format: %u; expected %u\n"), + progname, len, dst_len); + return 1; +} + +int +xlog_print_trans_attri( + char **ptr, + uint src_len, + int *i) +{ + struct xfs_attri_log_format *src_f = NULL; + xlog_op_header_t *head = NULL; + uint dst_len; + int error = 0; + + dst_len = sizeof(struct xfs_attri_log_format); + if (src_len != dst_len) { + fprintf(stderr, _("%s: bad size of attri format: %u; expected %u\n"), + progname, src_len, dst_len); + return 1; + } + + /* + * memmove to ensure 8-byte alignment for the long longs in + * xfs_attri_log_format_t structure + */ + if ((src_f = (struct xfs_attri_log_format *)malloc(src_len)) == NULL) { + fprintf(stderr, _("%s: xlog_print_trans_attri: malloc failed\n"), + progname); + exit(1); + } + memmove((char*)src_f, *ptr, src_len); + *ptr += src_len; + + printf(_("ATTRI: #regs: %d name_len: %d, value_len: %d id: 0x%llx\n"), + src_f->alfi_size, src_f->alfi_name_len, src_f->alfi_value_len, + (unsigned long long)src_f->alfi_id); + + if (src_f->alfi_name_len > 0) { + printf(_("\n")); + (*i)++; + head = (xlog_op_header_t *)*ptr; + xlog_print_op_header(head, *i, ptr); + error = xlog_print_trans_attri_name(ptr, be32_to_cpu(head->oh_len)); + if (error) + goto error; + } + + if (src_f->alfi_value_len > 0) { + printf(_("\n")); + (*i)++; + head = (xlog_op_header_t *)*ptr; + xlog_print_op_header(head, *i, ptr); + error = xlog_print_trans_attri_value(ptr, be32_to_cpu(head->oh_len), + src_f->alfi_value_len); + } +error: + free(src_f); + + return error; +} /* xlog_print_trans_attri */ + +int +xlog_print_trans_attri_name( + char **ptr, + uint src_len) +{ + + printf(_("ATTRI: name len:%u\n"), src_len); + print_hex_dump(*ptr, src_len); + + *ptr += src_len; + + return 0; +} /* xlog_print_trans_attri */ + +int +xlog_print_trans_attri_value( + char **ptr, + uint src_len, + int value_len) +{ + printf(_("ATTRI: value len:%u\n"), value_len); + print_hex_dump(*ptr, value_len); + + *ptr += src_len; + + return 0; +} /* xlog_print_trans_attri_value */ + +void +xlog_recover_print_attri( + xlog_recover_item_t *item) +{ + struct xfs_attri_log_format *f, *src_f = NULL; + uint src_len, dst_len; + + int region = 0; + + src_f = (struct xfs_attri_log_format *)item->ri_buf[0].i_addr; + src_len = item->ri_buf[region].i_len; + + /* + * An xfs_attri_log_format structure contains a attribute name and + * variable length value as the last field. + */ + dst_len = sizeof(struct xfs_attri_log_format); + + if ((f = ((struct xfs_attri_log_format *)malloc(dst_len))) == NULL) { + fprintf(stderr, _("%s: xlog_recover_print_attri: malloc failed\n"), + progname); + exit(1); + } + if (xfs_attri_copy_log_format((char*)src_f, src_len, f)) + goto out; + + printf(_("ATTRI: #regs: %d name_len: %d, value_len: %d id: 0x%llx\n"), + f->alfi_size, f->alfi_name_len, f->alfi_value_len, (unsigned long long)f->alfi_id); + + if (f->alfi_name_len > 0) { + region++; + printf(_("ATTRI: name len:%u\n"), f->alfi_name_len); + print_hex_dump((char *)item->ri_buf[region].i_addr, + f->alfi_name_len); + } + + if (f->alfi_value_len > 0) { + region++; + printf(_("ATTRI: value len:%u\n"), f->alfi_value_len); + print_hex_dump((char *)item->ri_buf[region].i_addr, + f->alfi_value_len); + } + +out: + free(f); + +} + +int +xlog_print_trans_attrd(char **ptr, uint len) +{ + struct xfs_attrd_log_format *f; + struct xfs_attrd_log_format lbuf; + uint core_size = sizeof(struct xfs_attrd_log_format); + + memcpy(&lbuf, *ptr, MIN(core_size, len)); + f = &lbuf; + *ptr += len; + if (len >= core_size) { + printf(_("ATTRD: #regs: %d id: 0x%llx\n"), + f->alfd_size, + (unsigned long long)f->alfd_alf_id); + return 0; + } else { + printf(_("ATTRD: Not enough data to decode further\n")); + return 1; + } +} /* xlog_print_trans_attrd */ + +void +xlog_recover_print_attrd( + xlog_recover_item_t *item) +{ + struct xfs_attrd_log_format *f; + + f = (struct xfs_attrd_log_format *)item->ri_buf[0].i_addr; + + printf(_(" ATTRD: #regs: %d id: 0x%llx\n"), + f->alfd_size, + (unsigned long long)f->alfd_alf_id); +} diff --git a/logprint/logprint.h b/logprint/logprint.h index 98ac0d4..b76c590 100644 --- a/logprint/logprint.h +++ b/logprint/logprint.h @@ -28,6 +28,7 @@ extern void xfs_log_print_trans(struct xlog *, int); extern void print_xlog_record_line(void); extern void print_xlog_op_line(void); extern void print_stars(void); +extern void print_hex_dump(char* ptr, int len); extern struct xfs_inode_log_format * xfs_inode_item_format_convert(char *, uint, struct xfs_inode_log_format *); @@ -52,4 +53,10 @@ extern void xlog_recover_print_bui(struct xlog_recover_item *item); extern int xlog_print_trans_bud(char **ptr, uint len); extern void xlog_recover_print_bud(struct xlog_recover_item *item); +extern int xlog_print_trans_attri(char **ptr, uint src_len, int *i); +extern int xlog_print_trans_attri_name(char **ptr, uint src_len); +extern int xlog_print_trans_attri_value(char **ptr, uint src_len, int value_len); +extern void xlog_recover_print_attri(xlog_recover_item_t *item); +extern int xlog_print_trans_attrd(char **ptr, uint len); +extern void xlog_recover_print_attrd(xlog_recover_item_t *item); #endif /* LOGPRINT_H */