From patchwork Thu Sep 5 22:18:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134069 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8CA991593 for ; Thu, 5 Sep 2019 22:19:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9764420828 for ; Thu, 5 Sep 2019 22:19:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="aEQ9DYRf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391182AbfIEWTT (ORCPT ); Thu, 5 Sep 2019 18:19:19 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33098 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391116AbfIEWTK (ORCPT ); Thu, 5 Sep 2019 18:19:10 -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 x85MJ8il078144 for ; Thu, 5 Sep 2019 22:19:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=l/u1MMDWBzRtygzmC+38HX5JV8o13IdEp5duevBRbcQ=; b=aEQ9DYRfUQFOGMAW5TJrKE4IOrcfo7to01ADCGdVXw3e83bN6XyFZV9zKsmM+4ljRpyY 1M2kWaw2kuHsFREOfWvv2ReCnsgrHhjK9GKTWFQBfaXlcYxbYdERyAHvt/FRiAOTe59B ktyaMYPONI0wU0OnKtHrluxjpkoC72IpXA1mr2Dv0X8/rHULKfhQeLksaqsfZPeRTIXh mAxPkN5U3+nLUd/iICHslUqLjsNkbq/9zAOzqRXFHHIn9//SzUmTcWwq9Q88cnrQYKQ8 2Q0nZ7f/X6np0yfDMcFQMZusv2gEPciwcgpAx6MRt/ayj9qw/V15+pWDCBVnGApPbgQe CQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2uuaqj02kt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:08 +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 x85MIOhe101602 for ; Thu, 5 Sep 2019 22:18:45 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2uu1b946hs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:18:45 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x85MIiDJ008662 for ; Thu, 5 Sep 2019 22:18:44 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:43 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 01/19] xfs: Replace attribute parameters with struct xfs_name Date: Thu, 5 Sep 2019 15:18:19 -0700 Message-Id: <20190905221837.17388-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch replaces the attribute name, 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 Collins --- fs/xfs/libxfs/xfs_attr.c | 46 +++++++++++++++++++--------------------------- fs/xfs/libxfs/xfs_attr.h | 12 +++++------- fs/xfs/xfs_acl.c | 27 +++++++++++++-------------- fs/xfs/xfs_ioctl.c | 28 ++++++++++++++++++---------- fs/xfs/xfs_iops.c | 12 ++++++++---- fs/xfs/xfs_xattr.c | 30 +++++++++++++++++------------- 6 files changed, 80 insertions(+), 75 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 7589cb7..d0308d6 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -61,9 +61,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) @@ -73,9 +71,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 */ @@ -139,30 +137,28 @@ 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; int error; - ASSERT((flags & (ATTR_ALLOC | ATTR_KERNOVAL)) || *value); + ASSERT((name->type & (ATTR_ALLOC | ATTR_KERNOVAL)) || *value); XFS_STATS_INC(ip->i_mount, xs_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; /* Entirely possible to look up a name which doesn't exist */ args.op_flags = XFS_DA_OP_OKNOENT; - if (flags & ATTR_ALLOC) + if (name->type & ATTR_ALLOC) args.op_flags |= XFS_DA_OP_ALLOCVAL; else args.value = *value; @@ -175,7 +171,7 @@ xfs_attr_get( /* on error, we have to clean up allocated value buffers */ if (error) { - if (flags & ATTR_ALLOC) { + if (name->type & ATTR_ALLOC) { kmem_free(args.value); *value = NULL; } @@ -339,16 +335,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); @@ -356,7 +350,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; @@ -419,7 +413,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); /* @@ -444,9 +438,7 @@ xfs_attr_set( 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; @@ -457,7 +449,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; @@ -478,7 +470,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; @@ -501,7 +493,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/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 106a2f2..cedb4e2 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -144,14 +144,12 @@ int xfs_attr_list_int_ilocked(struct xfs_attr_list_context *); int xfs_attr_list_int(struct xfs_attr_list_context *); int xfs_inode_hasattr(struct xfs_inode *ip); int xfs_attr_get_ilocked(struct xfs_inode *ip, struct xfs_da_args *args); -int xfs_attr_get(struct xfs_inode *ip, const unsigned char *name, - size_t namelen, unsigned char **value, int *valuelenp, - int flags); -int xfs_attr_set(struct xfs_inode *dp, const unsigned char *name, - size_t namelen, unsigned char *value, int valuelen, int flags); +int xfs_attr_get(struct xfs_inode *ip, struct xfs_name *name, + unsigned char **value, int *valuelenp); +int 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); diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c index 12be708..f8fb6e10 100644 --- a/fs/xfs/xfs_acl.c +++ b/fs/xfs/xfs_acl.c @@ -113,7 +113,7 @@ xfs_get_acl(struct inode *inode, int type) struct xfs_inode *ip = XFS_I(inode); struct posix_acl *acl = NULL; struct xfs_acl *xfs_acl = NULL; - unsigned char *ea_name; + struct xfs_name name; int error; int len; @@ -121,10 +121,10 @@ xfs_get_acl(struct inode *inode, int type) switch (type) { case ACL_TYPE_ACCESS: - ea_name = SGI_ACL_FILE; + name.name = SGI_ACL_FILE; break; case ACL_TYPE_DEFAULT: - ea_name = SGI_ACL_DEFAULT; + name.name = SGI_ACL_DEFAULT; break; default: BUG(); @@ -135,9 +135,9 @@ xfs_get_acl(struct inode *inode, int type) * go out to the disk. */ len = XFS_ACL_MAX_SIZE(ip->i_mount); - error = xfs_attr_get(ip, ea_name, strlen(ea_name), - (unsigned char **)&xfs_acl, &len, - ATTR_ALLOC | ATTR_ROOT); + name.len = strlen(name.name); + name.type = ATTR_ALLOC | ATTR_ROOT; + error = xfs_attr_get(ip, &name, (unsigned char **)&xfs_acl, &len); if (error) { /* * If the attribute doesn't exist make sure we have a negative @@ -157,17 +157,17 @@ int __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) { struct xfs_inode *ip = XFS_I(inode); - unsigned char *ea_name; + struct xfs_name name; int error; switch (type) { case ACL_TYPE_ACCESS: - ea_name = SGI_ACL_FILE; + name.name = SGI_ACL_FILE; break; case ACL_TYPE_DEFAULT: if (!S_ISDIR(inode->i_mode)) return acl ? -EACCES : 0; - ea_name = SGI_ACL_DEFAULT; + name.name = SGI_ACL_DEFAULT; break; default: return -EINVAL; @@ -187,17 +187,16 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) len -= sizeof(struct xfs_acl_entry) * (XFS_ACL_MAX_ENTRIES(ip->i_mount) - acl->a_count); - error = xfs_attr_set(ip, ea_name, strlen(ea_name), - (unsigned char *)xfs_acl, len, ATTR_ROOT); + name.len = strlen(name.name); + name.type = ATTR_ROOT; + error = xfs_attr_set(ip, &name, (unsigned char *)xfs_acl, len); kmem_free(xfs_acl); } else { /* * A NULL ACL argument means we want to remove the ACL. */ - error = xfs_attr_remove(ip, ea_name, - strlen(ea_name), - ATTR_ROOT); + error = xfs_attr_remove(ip, &name); /* * If the attribute didn't exist to start with that's fine. diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index d440426..626420d 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -431,7 +431,11 @@ xfs_attrmulti_attr_get( { unsigned char *kbuf; int error = -EFAULT; - size_t namelen; + struct xfs_name xname = { + .name = name, + .len = strlen(name), + .type = flags, + }; if (*len > XFS_XATTR_SIZE_MAX) return -EINVAL; @@ -439,9 +443,7 @@ xfs_attrmulti_attr_get( if (!kbuf) return -ENOMEM; - namelen = strlen(name); - error = xfs_attr_get(XFS_I(inode), name, namelen, &kbuf, (int *)len, - flags); + error = xfs_attr_get(XFS_I(inode), &xname, &kbuf, (int *)len); if (error) goto out_kfree; @@ -463,7 +465,7 @@ xfs_attrmulti_attr_set( { unsigned char *kbuf; int error; - size_t namelen; + struct xfs_name xname; if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) return -EPERM; @@ -474,8 +476,10 @@ xfs_attrmulti_attr_set( if (IS_ERR(kbuf)) return PTR_ERR(kbuf); - namelen = strlen(name); - error = xfs_attr_set(XFS_I(inode), name, namelen, kbuf, len, flags); + xname.name = name; + xname.len = strlen(name); + xname.type = flags; + error = xfs_attr_set(XFS_I(inode), &xname, kbuf, len); if (!error) xfs_forget_acl(inode, name, flags); kfree(kbuf); @@ -489,12 +493,16 @@ xfs_attrmulti_attr_remove( uint32_t flags) { int error; - size_t namelen; + struct xfs_name xname = { + .name = name, + .len = strlen(name), + .type = flags, + }; if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) return -EPERM; - namelen = strlen(name); - error = xfs_attr_remove(XFS_I(inode), name, namelen, flags); + + error = xfs_attr_remove(XFS_I(inode), &xname); if (!error) xfs_forget_acl(inode, name, flags); return error; diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 92de0a7..469e8e2 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -49,10 +49,14 @@ xfs_initxattrs( int error = 0; for (xattr = xattr_array; xattr->name != NULL; xattr++) { - error = xfs_attr_set(ip, xattr->name, - strlen(xattr->name), - xattr->value, xattr->value_len, - ATTR_SECURE); + struct xfs_name name = { + .name = xattr->name, + .len = strlen(xattr->name), + .type = ATTR_SECURE, + }; + + error = xfs_attr_set(ip, &name, + xattr->value, xattr->value_len); if (error < 0) break; } diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 59ffe6c..6309da4 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -20,19 +20,21 @@ static int xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, void *value, size_t size) { - int xflags = handler->flags; struct xfs_inode *ip = XFS_I(inode); int error, asize = size; - size_t namelen = strlen(name); + struct xfs_name xname = { + .name = name, + .len = strlen(name), + .type = handler->flags + }; /* Convert Linux syscall to XFS internal ATTR flags */ if (!size) { - xflags |= ATTR_KERNOVAL; + xname.type |= ATTR_KERNOVAL; value = NULL; } - error = xfs_attr_get(ip, name, namelen, (unsigned char **)&value, - &asize, xflags); + error = xfs_attr_get(ip, &xname, (unsigned char **)&value, &asize); if (error) return error; return asize; @@ -65,23 +67,25 @@ xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, const void *value, size_t size, int flags) { - int xflags = handler->flags; struct xfs_inode *ip = XFS_I(inode); int error; - size_t namelen = strlen(name); + struct xfs_name xname = { + .name = name, + .len = strlen(name), + .type = handler->flags, + }; /* Convert Linux syscall to XFS internal ATTR flags */ if (flags & XATTR_CREATE) - xflags |= ATTR_CREATE; + xname.type |= ATTR_CREATE; if (flags & XATTR_REPLACE) - xflags |= ATTR_REPLACE; + xname.type |= ATTR_REPLACE; if (!value) - return xfs_attr_remove(ip, name, - namelen, xflags); - error = xfs_attr_set(ip, name, namelen, (void *)value, size, xflags); + return xfs_attr_remove(ip, &xname); + error = xfs_attr_set(ip, &xname, (void *)value, size); if (!error) - xfs_forget_acl(inode, name, xflags); + xfs_forget_acl(inode, name, xname.type); return error; } From patchwork Thu Sep 5 22:18:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134059 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7AE8876 for ; Thu, 5 Sep 2019 22:19:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6871020825 for ; Thu, 5 Sep 2019 22:19:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Elkvujjd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391175AbfIEWTR (ORCPT ); Thu, 5 Sep 2019 18:19:17 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33168 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391128AbfIEWTM (ORCPT ); Thu, 5 Sep 2019 18:19:12 -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 x85MJ7IW078075 for ; Thu, 5 Sep 2019 22:19:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=ycLl3izdtCd4X0fHghmcgUt3Dsp9wf30600I9+PkUTU=; b=Elkvujjd0i6DiAmrlQ/0xvUo083fIZli27o84vcU3GBa8ocKlXH4J/0SZovxHmtNo/hh XCmEX4/1IeB4QwS8dg5KB12NkqZZabZ6+NSAFR5PwkeG2vNjOV6YZjRUivmYIkU4cgUL EpMU97+20xV49SUUihpW+O4ODv86AYco7cmK1SIN3omX3vWY+U4EOoJKzjqlDIiUjTa/ OWBNww7UIrpBTpNw0g6765BIEW5+m/IonBi8J4hY6ahXN0xPPYr3Q75fk/AB/4Xo/iuf 3hm9WhUG+6i87sxnrNm1f6irx5cJVvEh5/SoSl6ZriQuCaBJseTjYQmSocURDydFscjp zw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2uuaqj02kw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:08 +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 x85MIe7X123340 for ; Thu, 5 Sep 2019 22:18:46 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2uthq27uvg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:18:45 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x85MIi1r008667 for ; Thu, 5 Sep 2019 22:18:44 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:44 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 02/19] xfs: Embed struct xfs_name in xfs_da_args Date: Thu, 5 Sep 2019 15:18:20 -0700 Message-Id: <20190905221837.17388-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch embeds an xfs_name in xfs_da_args, replacing the name, namelen, and flags members. This helps to clean up the xfs_da_args structure and make it more uniform with the new xfs_name parameter being passed around. Signed-off-by: Allison Collins Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_attr.c | 34 ++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 106 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 5 +- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 22 ++++----- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 +-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 125 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index d0308d6..50e099f 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -71,13 +71,13 @@ xfs_attr_args_init( args->geo = dp->i_mount->m_attr_geo; args->whichfork = XFS_ATTR_FORK; args->dp = dp; - args->flags = name->type; - args->name = name->name; - args->namelen = name->len; - if (args->namelen >= MAXNAMELEN) + args->name.type = name->type; + args->name.name = name->name; + args->name.len = name->len; + if (args->name.len >= MAXNAMELEN) return -EFAULT; /* match IRIX behaviour */ - args->hashval = xfs_da_hashname(args->name, args->namelen); + args->hashval = xfs_da_hashname(args->name.name, args->name.len); return 0; } @@ -234,7 +234,7 @@ xfs_attr_try_sf_addname( * Commit the shortform mods, and we're done. * NOTE: this is also the error path (EEXIST, etc). */ - if (!error && (args->flags & ATTR_KERNOTIME) == 0) + if (!error && (args->name.type & ATTR_KERNOTIME) == 0) xfs_trans_ichgtime(args->trans, dp, XFS_ICHGTIME_CHG); if (mp->m_flags & XFS_MOUNT_WSYNC) @@ -369,7 +369,7 @@ xfs_attr_set( */ if (XFS_IFORK_Q(dp) == 0) { int sf_size = sizeof(xfs_attr_sf_hdr_t) + - XFS_ATTR_SF_ENTSIZE_BYNAME(args.namelen, valuelen); + XFS_ATTR_SF_ENTSIZE_BYNAME(args.name.len, valuelen); error = xfs_bmap_add_attrfork(dp, sf_size, rsvd); if (error) @@ -528,10 +528,10 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) trace_xfs_attr_sf_addname(args); retval = xfs_attr_shortform_lookup(args); - if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) { + if ((args->name.type & ATTR_REPLACE) && (retval == -ENOATTR)) { return retval; } else if (retval == -EEXIST) { - if (args->flags & ATTR_CREATE) + if (args->name.type & ATTR_CREATE) return retval; retval = xfs_attr_shortform_remove(args); if (retval) @@ -541,15 +541,15 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) * that the leaf format add routine won't trip over the attr * not being around. */ - args->flags &= ~ATTR_REPLACE; + args->name.type &= ~ATTR_REPLACE; } - if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX || + if (args->name.len >= XFS_ATTR_SF_ENTSIZE_MAX || args->valuelen >= XFS_ATTR_SF_ENTSIZE_MAX) return -ENOSPC; newsize = XFS_ATTR_SF_TOTSIZE(args->dp); - newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); + newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->name.len, args->valuelen); forkoff = xfs_attr_shortform_bytesfit(args->dp, newsize); if (!forkoff) @@ -594,11 +594,11 @@ xfs_attr_leaf_addname( * the given flags produce an error or call for an atomic rename. */ retval = xfs_attr3_leaf_lookup_int(bp, args); - if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) { + if ((args->name.type & ATTR_REPLACE) && (retval == -ENOATTR)) { xfs_trans_brelse(args->trans, bp); return retval; } else if (retval == -EEXIST) { - if (args->flags & ATTR_CREATE) { /* pure create op */ + if (args->name.type & ATTR_CREATE) { /* pure create op */ xfs_trans_brelse(args->trans, bp); return retval; } @@ -868,10 +868,10 @@ xfs_attr_node_addname( goto out; blk = &state->path.blk[ state->path.active-1 ]; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); - if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) { + if ((args->name.type & ATTR_REPLACE) && (retval == -ENOATTR)) { goto out; } else if (retval == -EEXIST) { - if (args->flags & ATTR_CREATE) + if (args->name.type & ATTR_CREATE) goto out; trace_xfs_attr_node_replace(args); @@ -1003,7 +1003,7 @@ xfs_attr_node_addname( * The INCOMPLETE flag means that we will find the "old" * attr, not the "new" one. */ - args->flags |= XFS_ATTR_INCOMPLETE; + args->name.type |= XFS_ATTR_INCOMPLETE; state = xfs_da_state_alloc(); state->args = args; state->mp = mp; diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index b9f0196..07ce320 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -402,7 +402,7 @@ xfs_attr_copy_value( /* * No copy if all we have to do is get the length */ - if (args->flags & ATTR_KERNOVAL) { + if (args->name.type & ATTR_KERNOVAL) { args->valuelen = valuelen; return 0; } @@ -615,27 +615,27 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) sfe = &sf->list[0]; for (i = 0; i < sf->hdr.count; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { #ifdef DEBUG - if (sfe->namelen != args->namelen) + if (sfe->namelen != args->name.len) continue; - if (memcmp(args->name, sfe->nameval, args->namelen) != 0) + if (memcmp(args->name.name, sfe->nameval, args->name.len) != 0) continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) + if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) continue; ASSERT(0); #endif } offset = (char *)sfe - (char *)sf; - size = XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); + size = XFS_ATTR_SF_ENTSIZE_BYNAME(args->name.len, args->valuelen); xfs_idata_realloc(dp, size, XFS_ATTR_FORK); sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; sfe = (xfs_attr_sf_entry_t *)((char *)sf + offset); - sfe->namelen = args->namelen; + sfe->namelen = args->name.len; sfe->valuelen = args->valuelen; - sfe->flags = XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags); - memcpy(sfe->nameval, args->name, args->namelen); - memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen); + sfe->flags = XFS_ATTR_NSP_ARGS_TO_ONDISK(args->name.type); + memcpy(sfe->nameval, args->name.name, args->name.len); + memcpy(&sfe->nameval[args->name.len], args->value, args->valuelen); sf->hdr.count++; be16_add_cpu(&sf->hdr.totsize, size); xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); @@ -685,11 +685,11 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), base += size, i++) { size = XFS_ATTR_SF_ENTSIZE(sfe); - if (sfe->namelen != args->namelen) + if (sfe->namelen != args->name.len) continue; - if (memcmp(sfe->nameval, args->name, args->namelen) != 0) + if (memcmp(sfe->nameval, args->name.name, args->name.len) != 0) continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) + if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) continue; break; } @@ -752,11 +752,11 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args) sfe = &sf->list[0]; for (i = 0; i < sf->hdr.count; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { - if (sfe->namelen != args->namelen) + if (sfe->namelen != args->name.len) continue; - if (memcmp(args->name, sfe->nameval, args->namelen) != 0) + if (memcmp(args->name.name, sfe->nameval, args->name.len) != 0) continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) + if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) continue; return -EEXIST; } @@ -783,13 +783,13 @@ xfs_attr_shortform_getvalue( sfe = &sf->list[0]; for (i = 0; i < sf->hdr.count; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { - if (sfe->namelen != args->namelen) + if (sfe->namelen != args->name.len) continue; - if (memcmp(args->name, sfe->nameval, args->namelen) != 0) + if (memcmp(args->name.name, sfe->nameval, args->name.len) != 0) continue; - if (!xfs_attr_namesp_match(args->flags, sfe->flags)) + if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) continue; - return xfs_attr_copy_value(args, &sfe->nameval[args->namelen], + return xfs_attr_copy_value(args, &sfe->nameval[args->name.len], sfe->valuelen); } return -ENOATTR; @@ -863,13 +863,13 @@ xfs_attr_shortform_to_leaf( sfe = &sf->list[0]; for (i = 0; i < sf->hdr.count; i++) { - nargs.name = sfe->nameval; - nargs.namelen = sfe->namelen; - nargs.value = &sfe->nameval[nargs.namelen]; + nargs.name.name = sfe->nameval; + nargs.name.len = sfe->namelen; + nargs.value = &sfe->nameval[nargs.name.len]; nargs.valuelen = sfe->valuelen; nargs.hashval = xfs_da_hashname(sfe->nameval, sfe->namelen); - nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags); + nargs.name.type = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags); error = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */ ASSERT(error == -ENOATTR); error = xfs_attr3_leaf_add(bp, &nargs); @@ -1070,12 +1070,12 @@ xfs_attr3_leaf_to_shortform( continue; ASSERT(entry->flags & XFS_ATTR_LOCAL); name_loc = xfs_attr3_leaf_name_local(leaf, i); - nargs.name = name_loc->nameval; - nargs.namelen = name_loc->namelen; - nargs.value = &name_loc->nameval[nargs.namelen]; + nargs.name.name = name_loc->nameval; + nargs.name.len = name_loc->namelen; + nargs.value = &name_loc->nameval[nargs.name.len]; nargs.valuelen = be16_to_cpu(name_loc->valuelen); nargs.hashval = be32_to_cpu(entry->hashval); - nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(entry->flags); + nargs.name.type = XFS_ATTR_NSP_ONDISK_TO_ARGS(entry->flags); xfs_attr_shortform_add(&nargs, forkoff); } error = 0; @@ -1403,7 +1403,7 @@ xfs_attr3_leaf_add_work( ichdr->freemap[mapindex].size); entry->hashval = cpu_to_be32(args->hashval); entry->flags = tmp ? XFS_ATTR_LOCAL : 0; - entry->flags |= XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags); + entry->flags |= XFS_ATTR_NSP_ARGS_TO_ONDISK(args->name.type); if (args->op_flags & XFS_DA_OP_RENAME) { entry->flags |= XFS_ATTR_INCOMPLETE; if ((args->blkno2 == args->blkno) && @@ -1427,15 +1427,16 @@ xfs_attr3_leaf_add_work( */ if (entry->flags & XFS_ATTR_LOCAL) { name_loc = xfs_attr3_leaf_name_local(leaf, args->index); - name_loc->namelen = args->namelen; + name_loc->namelen = args->name.len; name_loc->valuelen = cpu_to_be16(args->valuelen); - memcpy((char *)name_loc->nameval, args->name, args->namelen); - memcpy((char *)&name_loc->nameval[args->namelen], args->value, + memcpy((char *)name_loc->nameval, args->name.name, + args->name.len); + memcpy((char *)&name_loc->nameval[args->name.len], args->value, be16_to_cpu(name_loc->valuelen)); } else { name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index); - name_rmt->namelen = args->namelen; - memcpy((char *)name_rmt->name, args->name, args->namelen); + name_rmt->namelen = args->name.len; + memcpy((char *)name_rmt->name, args->name.name, args->name.len); entry->flags |= XFS_ATTR_INCOMPLETE; /* just in case */ name_rmt->valuelen = 0; @@ -2348,29 +2349,31 @@ xfs_attr3_leaf_lookup_int( * If we are looking for INCOMPLETE entries, show only those. * If we are looking for complete entries, show only those. */ - if ((args->flags & XFS_ATTR_INCOMPLETE) != + if ((args->name.type & XFS_ATTR_INCOMPLETE) != (entry->flags & XFS_ATTR_INCOMPLETE)) { continue; } if (entry->flags & XFS_ATTR_LOCAL) { name_loc = xfs_attr3_leaf_name_local(leaf, probe); - if (name_loc->namelen != args->namelen) + if (name_loc->namelen != args->name.len) continue; - if (memcmp(args->name, name_loc->nameval, - args->namelen) != 0) + if (memcmp(args->name.name, name_loc->nameval, + args->name.len) != 0) continue; - if (!xfs_attr_namesp_match(args->flags, entry->flags)) + if (!xfs_attr_namesp_match(args->name.type, + entry->flags)) continue; args->index = probe; return -EEXIST; } else { name_rmt = xfs_attr3_leaf_name_remote(leaf, probe); - if (name_rmt->namelen != args->namelen) + if (name_rmt->namelen != args->name.len) continue; - if (memcmp(args->name, name_rmt->name, - args->namelen) != 0) + if (memcmp(args->name.name, name_rmt->name, + args->name.len) != 0) continue; - if (!xfs_attr_namesp_match(args->flags, entry->flags)) + if (!xfs_attr_namesp_match(args->name.type, + entry->flags)) continue; args->index = probe; args->rmtvaluelen = be32_to_cpu(name_rmt->valuelen); @@ -2412,16 +2415,17 @@ xfs_attr3_leaf_getvalue( entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; if (entry->flags & XFS_ATTR_LOCAL) { name_loc = xfs_attr3_leaf_name_local(leaf, args->index); - ASSERT(name_loc->namelen == args->namelen); - ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0); + ASSERT(name_loc->namelen == args->name.len); + ASSERT(memcmp(args->name.name, name_loc->nameval, + args->name.len) == 0); return xfs_attr_copy_value(args, - &name_loc->nameval[args->namelen], + &name_loc->nameval[args->name.len], be16_to_cpu(name_loc->valuelen)); } name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index); - ASSERT(name_rmt->namelen == args->namelen); - ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0); + ASSERT(name_rmt->namelen == args->name.len); + ASSERT(memcmp(args->name.name, name_rmt->name, args->name.len) == 0); args->rmtvaluelen = be32_to_cpu(name_rmt->valuelen); args->rmtblkno = be32_to_cpu(name_rmt->valueblk); args->rmtblkcnt = xfs_attr3_rmt_blocks(args->dp->i_mount, @@ -2637,7 +2641,7 @@ xfs_attr_leaf_newentsize( { int size; - size = xfs_attr_leaf_entsize_local(args->namelen, args->valuelen); + size = xfs_attr_leaf_entsize_local(args->name.len, args->valuelen); if (size < xfs_attr_leaf_entsize_local_max(args->geo->blksize)) { if (local) *local = 1; @@ -2645,7 +2649,7 @@ xfs_attr_leaf_newentsize( } if (local) *local = 0; - return xfs_attr_leaf_entsize_remote(args->namelen); + return xfs_attr_leaf_entsize_remote(args->name.len); } @@ -2699,8 +2703,8 @@ xfs_attr3_leaf_clearflag( name = (char *)name_rmt->name; } ASSERT(be32_to_cpu(entry->hashval) == args->hashval); - ASSERT(namelen == args->namelen); - ASSERT(memcmp(name, args->name, namelen) == 0); + ASSERT(namelen == args->name.len); + ASSERT(memcmp(name, args->name.name, namelen) == 0); #endif /* DEBUG */ entry->flags &= ~XFS_ATTR_INCOMPLETE; diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 3e39b7d..db9247a 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -379,7 +379,7 @@ xfs_attr_rmtval_get( trace_xfs_attr_rmtval_get(args); - ASSERT(!(args->flags & ATTR_KERNOVAL)); + ASSERT(!(args->name.type & ATTR_KERNOVAL)); ASSERT(args->rmtvaluelen == args->valuelen); valuelen = args->rmtvaluelen; diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 4fd1223..129ec09 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2040,8 +2040,9 @@ xfs_da_compname( const unsigned char *name, int len) { - return (args->namelen == len && memcmp(args->name, name, len) == 0) ? - XFS_CMP_EXACT : XFS_CMP_DIFFERENT; + return (args->name.len == len && + memcmp(args->name.name, name, len) == 0) ? XFS_CMP_EXACT : + XFS_CMP_DIFFERENT; } static xfs_dahash_t diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index ae0bbd2..bed4f40 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -47,12 +47,10 @@ enum xfs_dacmp { */ typedef struct xfs_da_args { struct xfs_da_geometry *geo; /* da block geometry */ - const uint8_t *name; /* string (maybe not NULL terminated) */ - int namelen; /* length of string (maybe no NULL) */ + struct xfs_name name; /* name, length and argument flags*/ uint8_t filetype; /* filetype of inode for directories */ uint8_t *value; /* set of bytes (maybe contain NULLs) */ int valuelen; /* length of value */ - int flags; /* argument flags (eg: ATTR_NOCREATE) */ xfs_dahash_t hashval; /* hash value of name */ xfs_ino_t inumber; /* input/output inode number */ struct xfs_inode *dp; /* directory inode to manipulate */ diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 867c5de..e8d6721 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -74,14 +74,14 @@ xfs_ascii_ci_compname( enum xfs_dacmp result; int i; - if (args->namelen != len) + if (args->name.len != len) return XFS_CMP_DIFFERENT; result = XFS_CMP_EXACT; for (i = 0; i < len; i++) { - if (args->name[i] == name[i]) + if (args->name.name[i] == name[i]) continue; - if (tolower(args->name[i]) != tolower(name[i])) + if (tolower(args->name.name[i]) != tolower(name[i])) return XFS_CMP_DIFFERENT; result = XFS_CMP_CASE; } @@ -259,8 +259,8 @@ xfs_dir_createname( return -ENOMEM; args->geo = dp->i_mount->m_dir_geo; - args->name = name->name; - args->namelen = name->len; + args->name.name = name->name; + args->name.len = name->len; args->filetype = name->type; args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->inumber = inum; @@ -355,8 +355,8 @@ xfs_dir_lookup( */ args = kmem_zalloc(sizeof(*args), KM_NOFS); args->geo = dp->i_mount->m_dir_geo; - args->name = name->name; - args->namelen = name->len; + args->name.name = name->name; + args->name.len = name->len; args->filetype = name->type; args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->dp = dp; @@ -427,8 +427,8 @@ xfs_dir_removename( return -ENOMEM; args->geo = dp->i_mount->m_dir_geo; - args->name = name->name; - args->namelen = name->len; + args->name.name = name->name; + args->name.len = name->len; args->filetype = name->type; args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->inumber = ino; @@ -488,8 +488,8 @@ xfs_dir_replace( return -ENOMEM; args->geo = dp->i_mount->m_dir_geo; - args->name = name->name; - args->namelen = name->len; + args->name.name = name->name; + args->name.len = name->len; args->filetype = name->type; args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->inumber = inum; diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c index 9595ced..94269b9 100644 --- a/fs/xfs/libxfs/xfs_dir2_block.c +++ b/fs/xfs/libxfs/xfs_dir2_block.c @@ -355,7 +355,7 @@ xfs_dir2_block_addname( if (error) return error; - len = dp->d_ops->data_entsize(args->namelen); + len = dp->d_ops->data_entsize(args->name.len); /* * Set up pointers to parts of the block. @@ -539,8 +539,8 @@ xfs_dir2_block_addname( * Create the new data entry. */ dep->inumber = cpu_to_be64(args->inumber); - dep->namelen = args->namelen; - memcpy(dep->name, args->name, args->namelen); + dep->namelen = args->name.len; + memcpy(dep->name, args->name.name, args->name.len); dp->d_ops->data_put_ftype(dep, args->filetype); tagp = dp->d_ops->data_entry_tag_p(dep); *tagp = cpu_to_be16((char *)dep - (char *)hdr); diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c index a53e458..b7046e2 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c @@ -610,7 +610,7 @@ xfs_dir2_leaf_addname( ents = dp->d_ops->leaf_ents_p(leaf); dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); bestsp = xfs_dir2_leaf_bests_p(ltp); - length = dp->d_ops->data_entsize(args->namelen); + length = dp->d_ops->data_entsize(args->name.len); /* * See if there are any entries with the same hash value @@ -813,8 +813,8 @@ xfs_dir2_leaf_addname( */ dep = (xfs_dir2_data_entry_t *)dup; dep->inumber = cpu_to_be64(args->inumber); - dep->namelen = args->namelen; - memcpy(dep->name, args->name, dep->namelen); + dep->namelen = args->name.len; + memcpy(dep->name, args->name.name, dep->namelen); dp->d_ops->data_put_ftype(dep, args->filetype); tagp = dp->d_ops->data_entry_tag_p(dep); *tagp = cpu_to_be16((char *)dep - (char *)hdr); diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 705c4f5..8bbd742 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -604,7 +604,7 @@ xfs_dir2_leafn_lookup_for_addname( ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) || free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC)); } - length = dp->d_ops->data_entsize(args->namelen); + length = dp->d_ops->data_entsize(args->name.len); /* * Loop over leaf entries with the right hash value. */ @@ -1869,7 +1869,7 @@ xfs_dir2_node_addname_int( __be16 *tagp; /* data entry tag pointer */ __be16 *bests; - length = dp->d_ops->data_entsize(args->namelen); + length = dp->d_ops->data_entsize(args->name.len); error = xfs_dir2_node_find_freeblk(args, fblk, &dbno, &fbp, &findex, length); if (error) @@ -1924,8 +1924,8 @@ xfs_dir2_node_addname_int( /* Fill in the new entry and log it. */ dep = (xfs_dir2_data_entry_t *)dup; dep->inumber = cpu_to_be64(args->inumber); - dep->namelen = args->namelen; - memcpy(dep->name, args->name, dep->namelen); + dep->namelen = args->name.len; + memcpy(dep->name, args->name.name, dep->namelen); dp->d_ops->data_put_ftype(dep, args->filetype); tagp = dp->d_ops->data_entry_tag_p(dep); *tagp = cpu_to_be16((char *)dep - (char *)hdr); diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index 85f14fc..fdc1431 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c @@ -291,7 +291,7 @@ xfs_dir2_sf_addname( /* * Compute entry (and change in) size. */ - incr_isize = dp->d_ops->sf_entsize(sfp, args->namelen); + incr_isize = dp->d_ops->sf_entsize(sfp, args->name.len); objchange = 0; /* @@ -375,7 +375,7 @@ xfs_dir2_sf_addname_easy( /* * Grow the in-inode space. */ - xfs_idata_realloc(dp, dp->d_ops->sf_entsize(sfp, args->namelen), + xfs_idata_realloc(dp, dp->d_ops->sf_entsize(sfp, args->name.len), XFS_DATA_FORK); /* * Need to set up again due to realloc of the inode data. @@ -385,9 +385,9 @@ xfs_dir2_sf_addname_easy( /* * Fill in the new entry. */ - sfep->namelen = args->namelen; + sfep->namelen = args->name.len; xfs_dir2_sf_put_offset(sfep, offset); - memcpy(sfep->name, args->name, sfep->namelen); + memcpy(sfep->name, args->name.name, sfep->namelen); dp->d_ops->sf_put_ino(sfp, sfep, args->inumber); dp->d_ops->sf_put_ftype(sfep, args->filetype); @@ -446,7 +446,7 @@ xfs_dir2_sf_addname_hard( */ for (offset = dp->d_ops->data_first_offset, oldsfep = xfs_dir2_sf_firstentry(oldsfp), - add_datasize = dp->d_ops->data_entsize(args->namelen), + add_datasize = dp->d_ops->data_entsize(args->name.len), eof = (char *)oldsfep == &buf[old_isize]; !eof; offset = new_offset + dp->d_ops->data_entsize(oldsfep->namelen), @@ -476,9 +476,9 @@ xfs_dir2_sf_addname_hard( /* * Fill in the new entry, and update the header counts. */ - sfep->namelen = args->namelen; + sfep->namelen = args->name.len; xfs_dir2_sf_put_offset(sfep, offset); - memcpy(sfep->name, args->name, sfep->namelen); + memcpy(sfep->name, args->name.name, sfep->namelen); dp->d_ops->sf_put_ino(sfp, sfep, args->inumber); dp->d_ops->sf_put_ftype(sfep, args->filetype); sfp->count++; @@ -522,7 +522,7 @@ xfs_dir2_sf_addname_pick( dp = args->dp; sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; - size = dp->d_ops->data_entsize(args->namelen); + size = dp->d_ops->data_entsize(args->name.len); offset = dp->d_ops->data_first_offset; sfep = xfs_dir2_sf_firstentry(sfp); holefit = 0; @@ -807,7 +807,7 @@ xfs_dir2_sf_lookup( /* * Special case for . */ - if (args->namelen == 1 && args->name[0] == '.') { + if (args->name.len == 1 && args->name.name[0] == '.') { args->inumber = dp->i_ino; args->cmpresult = XFS_CMP_EXACT; args->filetype = XFS_DIR3_FT_DIR; @@ -816,8 +816,8 @@ xfs_dir2_sf_lookup( /* * Special case for .. */ - if (args->namelen == 2 && - args->name[0] == '.' && args->name[1] == '.') { + if (args->name.len == 2 && + args->name.name[0] == '.' && args->name.name[1] == '.') { args->inumber = dp->d_ops->sf_get_parent_ino(sfp); args->cmpresult = XFS_CMP_EXACT; args->filetype = XFS_DIR3_FT_DIR; @@ -912,7 +912,7 @@ xfs_dir2_sf_removename( * Calculate sizes. */ byteoff = (int)((char *)sfep - (char *)sfp); - entsize = dp->d_ops->sf_entsize(sfp, args->namelen); + entsize = dp->d_ops->sf_entsize(sfp, args->name.len); newsize = oldsize - entsize; /* * Copy the part if any after the removed entry, sliding it down. @@ -1002,12 +1002,12 @@ xfs_dir2_sf_replace( } else i8elevated = 0; - ASSERT(args->namelen != 1 || args->name[0] != '.'); + ASSERT(args->name.len != 1 || args->name.name[0] != '.'); /* * Replace ..'s entry. */ - if (args->namelen == 2 && - args->name[0] == '.' && args->name[1] == '.') { + if (args->name.len == 2 && + args->name.name[0] == '.' && args->name.name[1] == '.') { ino = dp->d_ops->sf_get_parent_ino(sfp); ASSERT(args->inumber != ino); dp->d_ops->sf_put_parent_ino(sfp, args->inumber); diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c index 0edc7f8..42f7c07 100644 --- a/fs/xfs/scrub/attr.c +++ b/fs/xfs/scrub/attr.c @@ -147,17 +147,17 @@ xchk_xattr_listent( return; } - args.flags = ATTR_KERNOTIME; + args.name.type = ATTR_KERNOTIME; if (flags & XFS_ATTR_ROOT) - args.flags |= ATTR_ROOT; + args.name.type |= ATTR_ROOT; else if (flags & XFS_ATTR_SECURE) - args.flags |= ATTR_SECURE; + args.name.type |= ATTR_SECURE; args.geo = context->dp->i_mount->m_attr_geo; args.whichfork = XFS_ATTR_FORK; args.dp = context->dp; - args.name = name; - args.namelen = namelen; - args.hashval = xfs_da_hashname(args.name, args.namelen); + args.name.name = name; + args.name.len = namelen; + args.hashval = xfs_da_hashname(args.name.name, args.name.len); args.trans = context->tp; args.value = xchk_xattr_valuebuf(sx->sc); args.valuelen = valuelen; diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index eaae275..e0f524d 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1669,7 +1669,7 @@ DECLARE_EVENT_CLASS(xfs_da_class, TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_ino_t, ino) - __dynamic_array(char, name, args->namelen) + __dynamic_array(char, name, args->name.len) __field(int, namelen) __field(xfs_dahash_t, hashval) __field(xfs_ino_t, inumber) @@ -1678,9 +1678,10 @@ DECLARE_EVENT_CLASS(xfs_da_class, TP_fast_assign( __entry->dev = VFS_I(args->dp)->i_sb->s_dev; __entry->ino = args->dp->i_ino; - if (args->namelen) - memcpy(__get_str(name), args->name, args->namelen); - __entry->namelen = args->namelen; + if (args->name.len) + memcpy(__get_str(name), args->name.name, + args->name.len); + __entry->namelen = args->name.len; __entry->hashval = args->hashval; __entry->inumber = args->inumber; __entry->op_flags = args->op_flags; @@ -1733,7 +1734,7 @@ DECLARE_EVENT_CLASS(xfs_attr_class, TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_ino_t, ino) - __dynamic_array(char, name, args->namelen) + __dynamic_array(char, name, args->name.len) __field(int, namelen) __field(int, valuelen) __field(xfs_dahash_t, hashval) @@ -1743,12 +1744,13 @@ DECLARE_EVENT_CLASS(xfs_attr_class, TP_fast_assign( __entry->dev = VFS_I(args->dp)->i_sb->s_dev; __entry->ino = args->dp->i_ino; - if (args->namelen) - memcpy(__get_str(name), args->name, args->namelen); - __entry->namelen = args->namelen; + if (args->name.len) + memcpy(__get_str(name), args->name.name, + args->name.len); + __entry->namelen = args->name.len; __entry->valuelen = args->valuelen; __entry->hashval = args->hashval; - __entry->flags = args->flags; + __entry->flags = args->name.type; __entry->op_flags = args->op_flags; ), TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d valuelen %d " From patchwork Thu Sep 5 22:18:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134093 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0CE821599 for ; Thu, 5 Sep 2019 22:19:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2365720870 for ; Thu, 5 Sep 2019 22:19:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="eLn5rBCR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389801AbfIEWTm (ORCPT ); Thu, 5 Sep 2019 18:19:42 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:59732 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389589AbfIEWTl (ORCPT ); Thu, 5 Sep 2019 18:19:41 -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 x85MJ8m1049698 for ; Thu, 5 Sep 2019 22:19: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=UPaYKuBrxVWm36UQia6ZHKWYKb4Lm8NGT2/K5cIytjE=; b=eLn5rBCR0JgXST9SE/1z0hwoB2Lp+7eQMYoNV7Fkqewx22dH7oObWzN5VwLgvg0ublTD +nCzu+PeZ0m2svjoasCpjr9DybDlxPZPYXe1iBNphZpTNumue++7jeoyZ52iN9TQ2ijk GVBV3KJ3EvYtfdCYVWlFZjsmOa04LxUKty9RLWBeMm4HgiAU+wHBMTLnBgCAS4Gop7I+ cWfM843ybkLvSrKIO93YieizYK71QQ3anrY/a/jEn8uezBkkhCz1fsYwYyj5w9Klv4ei Ms10XtnS7eyRCI/jcpJucwRf7txES4xV+o9iuu42wgUF0tUkhVdUSran8c+otgwXtsWP KQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2uuarc8237-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:39 +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 x85MJ5lV076712 for ; Thu, 5 Sep 2019 22:19:38 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2utvr4a1dp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:38 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x85MIiLD011543 for ; Thu, 5 Sep 2019 22:18:45 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:44 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 03/19] xfs: Add xfs_dabuf defines Date: Thu, 5 Sep 2019 15:18:21 -0700 Message-Id: <20190905221837.17388-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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=942 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds two new defines XFS_DABUF_MAP_NOMAPPING and XFS_DABUF_MAP_HOLE_OK. This helps to clean up hard numbers and makes the code easier to read Signed-off-by: Allison Collins --- fs/xfs/libxfs/xfs_attr_leaf.h | 3 +++ fs/xfs/libxfs/xfs_da_btree.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h index 7b74e18..536a290 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.h +++ b/fs/xfs/libxfs/xfs_attr_leaf.h @@ -16,6 +16,9 @@ struct xfs_da_state_blk; struct xfs_inode; struct xfs_trans; +#define XFS_DABUF_MAP_NOMAPPING (-1) /* Caller doesn't have a mapping. */ +#define XFS_DABUF_MAP_HOLE_OK (-2) /* don't complain if we land in a hole. */ + /* * Used to keep a list of "remote value" extents when unlinking an inode. */ diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 129ec09..2b94685 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2534,7 +2534,8 @@ xfs_dabuf_map( * Caller doesn't have a mapping. -2 means don't complain * if we land in a hole. */ - if (mappedbno == -1 || mappedbno == -2) { + if (mappedbno == XFS_DABUF_MAP_NOMAPPING || + mappedbno == XFS_DABUF_MAP_HOLE_OK) { /* * Optimize the one-block case. */ From patchwork Thu Sep 5 22:18:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134031 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2F251599 for ; Thu, 5 Sep 2019 22:19:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BBA9220870 for ; Thu, 5 Sep 2019 22:19:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="QaZ55mxi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391172AbfIEWTL (ORCPT ); Thu, 5 Sep 2019 18:19:11 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33052 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388847AbfIEWTK (ORCPT ); Thu, 5 Sep 2019 18:19:10 -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 x85MJ8bv078096 for ; Thu, 5 Sep 2019 22:19:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=m1VewgX1b4wIxuQ2VeW77DUEgWeTJHDcu+yyiejNifY=; b=QaZ55mxi+WuIzhyXQ9sEBy8iasP898BjGO2bnIr3cf/y7J8W+QXRFbElrTftZWh8u4n9 zBsx0KCX3O0vE84dYrmKPMxOHn88N0kP6gY7kSFyZZyEbF0Xcu2EmPExVE8drHkcwhzd qD4DslFN1pyAhQ85RXofgMQKt5ZSpvFvLXTwgnaPllAkSs7lyZNFu/PcoaCU5s+3Wg06 L75vV49we4D8HH2lQKioaf/hMUjHRYn7+kOejPOmnltOPC3DEiKrKeowL/9Ybn1i0omh 2dVfd0piLix2dQVo/ZgL2co6ZdufoyKNT47KlasC6PXxaGxlOZq7YbyEkQd+8WaQWZ/t Bw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2uuaqj02my-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:07 +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 x85MJ2FP076437 for ; Thu, 5 Sep 2019 22:19:06 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2utvr4a0s1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:04 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x85MIjLn032470 for ; Thu, 5 Sep 2019 22:18:45 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:44 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 04/19] xfs: Add xfs_has_attr and subroutines Date: Thu, 5 Sep 2019 15:18:22 -0700 Message-Id: <20190905221837.17388-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson 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 Henderson Signed-off-by: Allison Collins --- fs/xfs/libxfs/xfs_attr.c | 150 +++++++++++++++++++++++++++--------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 92 +++++++++++++++++--------- fs/xfs/libxfs/xfs_attr_leaf.h | 2 + 4 files changed, 161 insertions(+), 84 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 50e099f..a297857 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -46,6 +46,7 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args); STATIC int xfs_attr_leaf_get(xfs_da_args_t *args); STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args); STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); +STATIC int xfs_leaf_has_attr(struct xfs_da_args *args, struct xfs_buf **bp); /* * Internal routines when attribute list is more than one block. @@ -53,6 +54,8 @@ STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC int xfs_attr_node_addname(xfs_da_args_t *args); STATIC int xfs_attr_node_removename(xfs_da_args_t *args); +STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, + struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); @@ -309,6 +312,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 @@ -574,26 +603,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->name.type & ATTR_REPLACE) && (retval == -ENOATTR)) { xfs_trans_brelse(args->trans, bp); return retval; @@ -745,6 +765,25 @@ 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, XFS_DABUF_MAP_NOMAPPING, bp); + if (error) + return error; + + return xfs_attr3_leaf_lookup_int(*bp, args); +} + +/* * Remove a name from the leaf attribute list structure * * This leaf block cannot have a "remote" value, we only call this routine @@ -764,12 +803,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; @@ -808,12 +843,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; @@ -823,6 +853,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 *========================================================================*/ @@ -855,17 +922,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->name.type & ATTR_REPLACE) && (retval == -ENOATTR)) { @@ -1070,29 +1134,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. @@ -1314,20 +1364,14 @@ 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; goto out_release; } - if (retval != -EEXIST) - goto out_release; /* * Get the value, local or "remote" diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index cedb4e2..fb56d81 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -150,6 +150,7 @@ int xfs_attr_set(struct xfs_inode *dp, struct xfs_name *name, unsigned char *value, int valuelen); int 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/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 07ce320..a501538 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -590,6 +590,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->name.len) + continue; + if (memcmp(sfe->nameval, args->name.name, args->name.len) != 0) + continue; + if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) + continue; + break; + } + + if (sfep != NULL) + *sfep = sfe; + + if (basep != NULL) + *basep = base; + + if (i == end) + return -ENOATTR; + return -EEXIST; +} + +/* * Add a name/value pair to the shortform attribute list. * Overflow from the inode has already been checked for. */ @@ -598,7 +645,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; @@ -612,18 +659,10 @@ 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->name.len) - continue; - if (memcmp(args->name.name, sfe->nameval, args->name.len) != 0) - continue; - if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) - continue; - ASSERT(0); + ASSERT(error != -EEXIST); #endif - } offset = (char *)sfe - (char *)sf; size = XFS_ATTR_SF_ENTSIZE_BYNAME(args->name.len, args->valuelen); @@ -668,33 +707,24 @@ xfs_attr_fork_remove( int 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; - xfs_mount_t *mp; - xfs_inode_t *dp; + struct xfs_attr_shortform *sf; + struct xfs_attr_sf_entry *sfe; + int base, size = 0, end, totsize; + struct xfs_mount *mp; + struct xfs_inode *dp; + int error; trace_xfs_attr_sf_remove(args); dp = args->dp; mp = dp->i_mount; - base = sizeof(xfs_attr_sf_hdr_t); sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; - sfe = &sf->list[0]; end = sf->hdr.count; - for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), - base += size, i++) { - size = XFS_ATTR_SF_ENTSIZE(sfe); - if (sfe->namelen != args->name.len) - continue; - if (memcmp(sfe->nameval, args->name.name, args->name.len) != 0) - continue; - if (!xfs_attr_namesp_match(args->name.type, sfe->flags)) - continue; - break; - } - if (i == end) - return -ENOATTR; + + error = xfs_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/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h index 536a290..58e9327 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.h +++ b/fs/xfs/libxfs/xfs_attr_leaf.h @@ -42,6 +42,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 Thu Sep 5 22:18:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134067 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2215276 for ; Thu, 5 Sep 2019 22:19:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 36F112082C for ; Thu, 5 Sep 2019 22:19:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="U71MyTAz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391177AbfIEWTT (ORCPT ); Thu, 5 Sep 2019 18:19:19 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33354 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391182AbfIEWTO (ORCPT ); Thu, 5 Sep 2019 18:19:14 -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 x85MJD2Q078272 for ; Thu, 5 Sep 2019 22:19:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=c9tDv0TrmOw73eoD8J+rfB6hMSH9s0Hs6bbNC8z2NKw=; b=U71MyTAzQ7YVunqyCFSJsF+eyDOjUohtZMsBz+n1ye77TG573niQNiNKRnM9uY2aVn1Q s+Ic8cw1ayHvQLRE38ceG0NpVegLjaa4xtS7WjWz6BlpQas+bfVx80QqRRmaWzUgrKE0 n8RG4QjH4fnh3cQ1CDKZ4bpD1yZHTi0KDWhRbzWO3PxkByZAuqOx2Dgr0KsWgRrkk+iB TxD3KfM/rdK1cReQTqQ8YlnkEuQ/uM3LSlb4mqXANMtGnXgVBJfHIEj7EXjJnDOyvclV mleETdo1Hk8LZ6SIQ3vuAAx7JxWkAhKrn+5ZAxvZ/7jLQvKkLcKzabjPpFzGMxrjFz7Q wQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2uuaqj02nw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:12 +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 x85MJ5CM076815 for ; Thu, 5 Sep 2019 22:19:12 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2utvr4a0s3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:09 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x85MIjVn032474 for ; Thu, 5 Sep 2019 22:18:45 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:45 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 05/19] xfs: Factor out new helper functions xfs_attr_rmtval_set Date: Thu, 5 Sep 2019 15:18:23 -0700 Message-Id: <20190905221837.17388-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Break xfs_attr_rmtval_set into two helper functions xfs_attr_rmt_find_hole and xfs_attr_rmtval_set_value. xfs_attr_rmtval_set rolls the transaction between the helpers, but delayed operations cannot. We will use the helpers later when constructing new delayed attribute routines. Signed-off-by: Allison Collins Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_attr_remote.c | 72 +++++++++++++++++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_remote.h | 3 +- 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index db9247a..080a284 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -21,6 +21,7 @@ #include "xfs_attr.h" #include "xfs_trace.h" #include "xfs_error.h" +#include "xfs_attr_remote.h" #define ATTR_RMTVALUE_MAPSIZE 1 /* # of map entries at once */ @@ -432,34 +433,20 @@ 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); if (error) return error; - args->rmtblkno = lblkno = (xfs_dablk_t)lfileoff; - args->rmtblkcnt = blkcnt; - + blkcnt = args->rmtblkcnt; + lblkno = (xfs_dablk_t)args->rmtblkno; /* * Roll through the "value", allocating blocks on disk as required. */ @@ -500,6 +487,57 @@ xfs_attr_rmtval_set( return error; } + error = xfs_attr_rmtval_set_value(args); + return error; +} + + +/* + * Find a "hole" in the attribute address space large enough for us to drop the + * new attribute's value into + */ +int +xfs_attr_rmt_find_hole( + struct xfs_da_args *args) +{ + struct xfs_inode *dp = args->dp; + struct xfs_mount *mp = dp->i_mount; + int error; + int blkcnt; + xfs_fileoff_t lfileoff = args->rmtblkno; + + /* + * 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/fs/xfs/libxfs/xfs_attr_remote.h b/fs/xfs/libxfs/xfs_attr_remote.h index 9d20b66..cd7670d 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.h +++ b/fs/xfs/libxfs/xfs_attr_remote.h @@ -11,5 +11,6 @@ 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); #endif /* __XFS_ATTR_REMOTE_H__ */ From patchwork Thu Sep 5 22:18:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6C221599 for ; Thu, 5 Sep 2019 22:19:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCC4020828 for ; Thu, 5 Sep 2019 22:19:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="aTSwbGZ+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389781AbfIEWTk (ORCPT ); Thu, 5 Sep 2019 18:19:40 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33758 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389801AbfIEWTj (ORCPT ); Thu, 5 Sep 2019 18:19:39 -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 x85MJ7bc078087 for ; Thu, 5 Sep 2019 22:19:38 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=Cw8ITrtAfW3vi3/3iSKT20OFRFSCI9XlkBC2IlCGBkM=; b=aTSwbGZ+4NugX8XgCzktyqVqxxaDLEEsuVDaToOg9eJryZe5om7C9q6+7luccZusbKjR NzjhtJVDD5jloUqBooDNEXQlB+MonK/qDfdPv3838bsVFiZ5MKGFEFklu7VtFhecowxR 33vUxygM/si/3ODFuB41Qg2gDL3LPt+XlRDD6LSz3LKEi4ROet2A+Ogm2Zd2swtiFeZm Vrh2i7dUuQEKHtw9+Fwj/fT6K0004Fa0/n10ehRfdkjb4AJh8Tk46Kr3OS3z/ngJWzaX XL/Wh3v4kzP/RbDc6VGYqNMc6vd5ngK0OOqyRhEd8F4Ui+ysiXcleyhWgRpaEMwCZknE Hw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2uuaqj02qr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:38 +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 x85MIepU123383 for ; Thu, 5 Sep 2019 22:19:37 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2uthq27va4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:37 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x85MIj5T011580 for ; Thu, 5 Sep 2019 22:18:45 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:45 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 06/19] xfs: Factor up trans handling in xfs_attr3_leaf_flipflags Date: Thu, 5 Sep 2019 15:18:24 -0700 Message-Id: <20190905221837.17388-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Since delayed operations cannot roll transactions, factor up the transaction handling into the calling function Signed-off-by: Allison Collins Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_attr.c | 14 ++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.c | 5 ----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index a297857..7a6dd37 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -710,6 +710,13 @@ xfs_attr_leaf_addname( error = xfs_attr3_leaf_flipflags(args); if (error) return error; + /* + * Commit the flag value change and start the next trans in + * series. + */ + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + return error; /* * Dismantle the "old" attribute/value pair by removing @@ -1046,6 +1053,13 @@ xfs_attr_node_addname( error = xfs_attr3_leaf_flipflags(args); if (error) goto out; + /* + * Commit the flag value change and start the next trans in + * series + */ + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + goto out; /* * Dismantle the "old" attribute/value pair by removing diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index a501538..3903e5c 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -2919,10 +2919,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 Thu Sep 5 22:18:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134119 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C96411398 for ; Thu, 5 Sep 2019 22:51:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E989F206BB for ; Thu, 5 Sep 2019 22:51:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="O/B9sAnI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727213AbfIEWvK (ORCPT ); Thu, 5 Sep 2019 18:51:10 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:46300 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727115AbfIEWvK (ORCPT ); Thu, 5 Sep 2019 18:51:10 -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 x85Mn2vc106366 for ; Thu, 5 Sep 2019 22:51:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=lDyjioxqXEZ+ZKVeAR1gBCazZkWfEf54cA+eCM7kw8E=; b=O/B9sAnI5LL32FFgzjE8kntpRj1ltgdvlnUerc0VCNSK8siLYY45/L/p+3tx67qKPCgz N5uPaGxWjmAP1Q9FnnAmbhlk9jjlshHmym7B6lnH0hSApIDTiBKdSgqKuboMwPAopgZm vaqQQydQ5OllrIXN5ydq7yXPccyamyMUIvufRzBwjvsWsnuFwx1KA70DICIn2JBqdTaz 9eKxXbYwHgA8L1fpYukmIXjop8DQZsd5mzolxAqizttVFzfS38SzG7FurTi4VgLY/3aO eDVt3XpLFbBEr9+tf6VpOGHdR2h4tCQtwjnK88QN66v4g8Q3UB8zFdXgATYAFL1licOz hw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2uubg780ag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:51:08 +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 x85Mn22H187729 for ; Thu, 5 Sep 2019 22:51:07 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2uthq28hwx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:51:07 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x85Mp7c6020769 for ; Thu, 5 Sep 2019 22:51:07 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:45 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 07/19] xfs: Factor out xfs_attr_leaf_addname helper Date: Thu, 5 Sep 2019 15:18:25 -0700 Message-Id: <20190905221837.17388-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050212 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050212 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Factor out new helper function xfs_attr_leaf_try_add. Because new delayed attribute routines cannot roll transactions, we carve off the parts of xfs_attr_leaf_addname that we can use. This will help to reduce repetitive code later when we introduce delayed attributes. Signed-off-by: Allison Collins --- fs/xfs/libxfs/xfs_attr.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 7a6dd37..f27e2c6 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -593,19 +593,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); @@ -650,13 +643,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 Thu Sep 5 22:18:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134023 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DD3776 for ; Thu, 5 Sep 2019 22:19:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7150F20825 for ; Thu, 5 Sep 2019 22:19:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="bDWRPLQV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391113AbfIEWTK (ORCPT ); Thu, 5 Sep 2019 18:19:10 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:39010 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391135AbfIEWTJ (ORCPT ); Thu, 5 Sep 2019 18:19:09 -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 x85MJ8hm084689 for ; Thu, 5 Sep 2019 22:19:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=UlSFkqdOpMH+nq3BChQlqSxIXpkeKNC16SLKBxmpghU=; b=bDWRPLQVKitcN1X+QHr6hMlNEolDXIuNT1yT0/rXggRO9AcQfPFllMPZus53Kdngd4vx D3GuLZXua1G6hwr0V01lO5Wp3YRjXuH706shizDXO6p02za0ObluFaH+Q7eVIcsEPQh6 FSsUAe7NcLCiiM339y/Oy0VvcyxThva3fxrn3WnkhmJpaiuOtfbIG7CRYJD5cdrZrM3R aHYQhVKKrUo9uzBCWFKU4ie0lCjcFdLb7kxam3mYQ/b0HdfI06atp3nZVMpmsZ7P2D5t 5w3p59Dx4lESiv8bdCNxYkfK1W1jL3kUql0Kkuq5A6NnO0qPrOpNERNz/SbYdUiri+61 AA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2uuaqxr2cv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:08 +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 x85MIO3d101648 for ; Thu, 5 Sep 2019 22:18:47 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2uu1b946ja-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:18:47 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x85MIkkx011584 for ; Thu, 5 Sep 2019 22:18:46 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:46 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 08/19] xfs: Factor up commit from xfs_attr_try_sf_addname Date: Thu, 5 Sep 2019 15:18:26 -0700 Message-Id: <20190905221837.17388-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org New delayed attribute routines cannot handle transactions, so factor this up to the calling function. Signed-off-by: Allison Collins --- fs/xfs/libxfs/xfs_attr.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index f27e2c6..318c543 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -227,7 +227,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) @@ -243,9 +243,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; } /* @@ -257,7 +255,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, @@ -277,8 +275,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) { + error2 = xfs_trans_commit(args->trans); + args->trans = NULL; + return error ? error : error2; + } /* * It won't fit in the shortform, transform to a leaf block. From patchwork Thu Sep 5 22:18:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9DD6676 for ; Thu, 5 Sep 2019 22:19:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2ACE20828 for ; Thu, 5 Sep 2019 22:19:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="dD+vFsrc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391129AbfIEWTO (ORCPT ); Thu, 5 Sep 2019 18:19:14 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:58942 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391133AbfIEWTK (ORCPT ); Thu, 5 Sep 2019 18:19:10 -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 x85MJ8Gh049723 for ; Thu, 5 Sep 2019 22:19:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=zVbU+TXj2bc9BEWlcv3zKBwOslH3uSr2Z+wykiGTtdo=; b=dD+vFsrcYQIdikCkv6u2mW8ozGxQt0tkDeQD63hAYD0IixF27Jjkr5ML8BJ2InKzEEd5 SOGMiGQVKojafBbuulPUgSc/9pbj2bWEJSVKXXGXeo58pLPpXXJQA5ZpzNkPG+m54Fxg pJF7GqGGke8U4UPTX3qM2XkKhezzQVi0e/9+rdorb053U6c60qs92B8x6VXb7yObc/cq KjttssdekjkANJv0Tgv26IJvBoRUqQeIOOcJfsNkqX3QE1fHduvpgCjYmPQCdZEgB/2V 7tgdkG2rvMtW8CRM5aohVx8+n87SpvWlJR5kNN7EHKZbu+EAQT1abvtayyPJTenj6s0P cg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2uuarc81y8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:08 +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 x85MIeQU123483 for ; Thu, 5 Sep 2019 22:18:47 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2uthq27uw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:18:47 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x85MIkHr032480 for ; Thu, 5 Sep 2019 22:18:46 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:46 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 09/19] xfs: Factor up trans roll from xfs_attr3_leaf_setflag Date: Thu, 5 Sep 2019 15:18:27 -0700 Message-Id: <20190905221837.17388-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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=914 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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=993 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org New delayed allocation routines cannot be handling transactions so factor them up into the calling functions Signed-off-by: Allison Collins Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_attr.c | 5 +++++ fs/xfs/libxfs/xfs_attr_leaf.c | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 318c543..5e5b688 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1199,6 +1199,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/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 3903e5c..bcd86c3 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -2801,10 +2801,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 Thu Sep 5 22:18:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134045 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CB061593 for ; Thu, 5 Sep 2019 22:19:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 40E4420828 for ; Thu, 5 Sep 2019 22:19:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="QgJY4gQK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391133AbfIEWTO (ORCPT ); Thu, 5 Sep 2019 18:19:14 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:58948 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391136AbfIEWTK (ORCPT ); Thu, 5 Sep 2019 18:19:10 -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 x85MJ8ED049681 for ; Thu, 5 Sep 2019 22:19:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=ibQn4FKM9LWoLP/zNCWW17MZHZ0LHoBacBvjrPhxrc0=; b=QgJY4gQKSGEEWti2EMbu/HRlHKr9KdOIGyZGxqy/oThLl793+qBdxjEY/Bbxc8AuVFts ms3zdEHGHvEGLRyZfY0UU+mH4hcA6m6vhgq2x5sfrsnlDU8vYV5w84IeeIAtEsN8iP+l N6Inuu+FIdqBFKuDu716moxYC9X67FVNwt/gb87FYmLtDvUG0z5ES4Bgtbbs6SRhtpxz MOfSFKVQ3GpcWwXtM+epui743sFSHoYbzSABKi8N+ffaaiV0vwRls0VsO3EQdsnf+1cv pAJoCZUxyh69YDUc38zt9Br6qSDYZtuAM0xFdIQCsvbJfQdVn9FmfRFzX92fs0CX4kpg ww== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2uuarc81yb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:08 +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 x85MIe7b123340 for ; Thu, 5 Sep 2019 22:18:48 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2uthq27uw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:18:47 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x85MIlNa001627 for ; Thu, 5 Sep 2019 22:18:47 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:46 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 10/19] xfs: Add xfs_attr3_leaf helper functions Date: Thu, 5 Sep 2019 15:18:28 -0700 Message-Id: <20190905221837.17388-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 --- fs/xfs/libxfs/xfs_attr_leaf.c | 84 +++++++++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.h | 2 ++ 2 files changed, 86 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index bcd86c3..79650c9 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -2757,6 +2757,36 @@ 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, + bool *isset) +{ + 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]; + + *isset = ((entry->flags & XFS_ATTR_INCOMPLETE) != 0); + return 0; +} + +/* * Set the INCOMPLETE flag on an entry in a leaf block. */ int @@ -2918,3 +2948,57 @@ 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. + * + * isflipped is set to true if flags are flipped or false otherwise + */ +int +xfs_attr3_leaf_flagsflipped( + struct xfs_da_args *args, + bool *isflipped) +{ + 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]; + + *isflipped = (((entry1->flags & XFS_ATTR_INCOMPLETE) == 0) && + (entry2->flags & XFS_ATTR_INCOMPLETE)); + + return 0; +} diff --git a/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h index 58e9327..d82229b 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.h +++ b/fs/xfs/libxfs/xfs_attr_leaf.h @@ -57,7 +57,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, bool *isset); int xfs_attr3_leaf_flipflags(struct xfs_da_args *args); +int xfs_attr3_leaf_flagsflipped(struct xfs_da_args *args, bool *isflipped); /* * Routines used for growing the Btree. From patchwork Thu Sep 5 22:18:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134039 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B60621599 for ; Thu, 5 Sep 2019 22:19:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CA82C20828 for ; Thu, 5 Sep 2019 22:19:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="B+67nxJr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391157AbfIEWTN (ORCPT ); Thu, 5 Sep 2019 18:19:13 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:58938 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391129AbfIEWTK (ORCPT ); Thu, 5 Sep 2019 18:19:10 -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 x85MJ8RP049719 for ; Thu, 5 Sep 2019 22:19:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=K2n35Ic/+WncbK5hlPG8Tq5sNTvHVhGBm23/NgngOgI=; b=B+67nxJrh2HorTID3vj1nuOw3q7x/hi1JLsski3A1zVhnkvK5qyM+ANoVDX8m/H3kUwZ tcVw5HswcjfNPZDcR9oYNjIHQ7RQugSddvNqdatCj3IExt8MlwB5o6EMpSqw39nMbHEq 4rQfo3mZgBc7SEAuyvVB/G6WZuZ05qkIrW1FHbDSe/uquz0JkP4b70/izR2Ka3kS+hGy pfNclTgdCnVe6pDXervc3ZBVZC1y27hPkErQ3T2dqIQpUNr8bv7XTXVIyjw8Vf8hTp5D OUSA7annp5hyS8nrAgrjBTI0uLlz9aTHZJsVY6emLXgPxR/CmiNdPlUees4DUyn9llTf 7w== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2uuarc81y9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:08 +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 x85MIOl8101605 for ; Thu, 5 Sep 2019 22:18:47 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2uu1b946jj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:18:47 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x85MIl4Q001630 for ; Thu, 5 Sep 2019 22:18:47 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:47 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 11/19] xfs: Factor out xfs_attr_rmtval_invalidate Date: Thu, 5 Sep 2019 15:18:29 -0700 Message-Id: <20190905221837.17388-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Because new delayed attribute routines cannot roll transactions, we carve off the parts of xfs_attr_rmtval_remove that we can use. This will help to reduce repetitive code later when we introduce delayed attributes. Signed-off-by: Allison Collins Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_attr_remote.c | 29 +++++++++++++++++++++-------- fs/xfs/libxfs/xfs_attr_remote.h | 1 + 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 080a284..1b13795 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -589,21 +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_invalidate( struct xfs_da_args *args) { struct xfs_mount *mp = args->dp->i_mount; xfs_dablk_t lblkno; int blkcnt; int error; - int done; - - trace_xfs_attr_rmtval_remove(args); /* * Roll through the "value", invalidating the attribute value's blocks. @@ -645,7 +638,27 @@ xfs_attr_rmtval_remove( lblkno += map.br_blockcount; blkcnt -= map.br_blockcount; } + return 0; +} +/* + * Remove the value associated with an attribute by deleting the + * out-of-line buffer that it is stored on. + */ +int +xfs_attr_rmtval_remove( + struct xfs_da_args *args) +{ + xfs_dablk_t lblkno; + int blkcnt; + int error = 0; + int done = 0; + + trace_xfs_attr_rmtval_remove(args); + + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; /* * Keep de-allocating extents until the remote-value region is gone. */ diff --git a/fs/xfs/libxfs/xfs_attr_remote.h b/fs/xfs/libxfs/xfs_attr_remote.h index cd7670d..b6fd35a 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.h +++ b/fs/xfs/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_invalidate(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); #endif /* __XFS_ATTR_REMOTE_H__ */ From patchwork Thu Sep 5 22:18:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134101 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BEE8C1593 for ; Thu, 5 Sep 2019 22:20:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D0E7F20825 for ; Thu, 5 Sep 2019 22:20:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ZTmPaDKs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389551AbfIEWUQ (ORCPT ); Thu, 5 Sep 2019 18:20:16 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:34568 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389378AbfIEWUP (ORCPT ); Thu, 5 Sep 2019 18:20:15 -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 x85MJ8bP078175 for ; Thu, 5 Sep 2019 22:20:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=HgO1do0ndS8qMMKswj7WFtcMbQyWynP3peHG250asXQ=; b=ZTmPaDKsxHc5p0qQYgActodmMGGVHyj/5xNJbqhYotXPm19ayd28Udp3L953DRZ8xdu/ YtSfewWlb8QDddOUz/Dx2OzC2F25KjUSmzWeoZKx9k1e7JPHgQ0dq7x9cbzyApFqHer4 cWWf3jUn+rXyVNn8yx5BNWdSkK+R2DvI+fK81JApoJuKrcYqQ05ljI/OEyXyfVls467j 945WFlU06pY0hwJLwjI8vsPdHIjY/PTqjaKgdlnkgSZZ6LUAIcvif7tZ4L1xD+TK1kuA FyMMFnQsi0D7JBTzEh/5jsOR/SuS7bg2n7jdZoB3GfhnxTNmR6xggy1/yLacxmFX15ky PA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2uuaqj02ty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:20:14 +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 x85MIe5k123349 for ; Thu, 5 Sep 2019 22:20:13 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2uthq27v22-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:20:13 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x85MIliO008694 for ; Thu, 5 Sep 2019 22:18:47 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:47 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 12/19] xfs: Factor up trans roll in xfs_attr3_leaf_clearflag Date: Thu, 5 Sep 2019 15:18:30 -0700 Message-Id: <20190905221837.17388-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org New delayed allocation routines cannot be handling transactions so factor them up into the calling functions Signed-off-by: Allison Collins --- fs/xfs/libxfs/xfs_attr.c | 14 ++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.c | 5 +---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 5e5b688..781dd8a 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -783,6 +783,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; } @@ -1140,6 +1146,14 @@ xfs_attr_node_addname( error = xfs_attr3_leaf_clearflag(args); if (error) goto out; + + /* + * Commit the flag value change and start the next trans in + * series. + */ + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + goto out; } retval = error = 0; diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 79650c9..786b851 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -2750,10 +2750,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 Thu Sep 5 22:18:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6ABC976 for ; Thu, 5 Sep 2019 22:19:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7608A20828 for ; Thu, 5 Sep 2019 22:19:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="qOM8DkPD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389368AbfIEWTk (ORCPT ); Thu, 5 Sep 2019 18:19:40 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:39622 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389781AbfIEWTj (ORCPT ); Thu, 5 Sep 2019 18:19:39 -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 x85MJ8n4084607 for ; Thu, 5 Sep 2019 22:19:38 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=YJHEq+T31polxip6SNnLHuc2Js08ENn9r8EHLCcZvF4=; b=qOM8DkPDhQL3iUb0zjASjsXZ9Bq3Df4zmWBWib7ydLrjlzJPPbPPmOajYt5D0iEdx3IG r3Kg8f2d9okCFYfKBrTixaMNab/tDoT3lYrI/LN1llkh2meF7Q9XA0XN+6C6nu3+UA0d LdTrwsxMK6dQb00CCjEr+d2Bhn9Nfzum7+TzVnmwaH7kneXNJqCz99gP7QNoMHk7M3Wg wxvgARzbzRoJF8KFOQpdn39JBfdCdwOuU5P0URF5plYyBt21jxrLju2dNKz6qGSPGeR0 oZ9z6K3t4YUEEZdfq/+HezQMkJwNsysHxsI8CxtGFG8JP3MQIeRDPkLcsM8i9IB8v7sJ ig== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2uuaqxr2g0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:38 +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 x85MIOri101633 for ; Thu, 5 Sep 2019 22:19:37 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2uu1b9475n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:37 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x85MImsQ032485 for ; Thu, 5 Sep 2019 22:18:48 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:47 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 13/19] xfs: Add delay context to xfs_da_args Date: Thu, 5 Sep 2019 15:18:31 -0700 Message-Id: <20190905221837.17388-14-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 --- fs/xfs/libxfs/xfs_da_btree.h | 23 +++++++++++++++++++++++ fs/xfs/scrub/common.c | 2 ++ fs/xfs/xfs_acl.c | 2 ++ fs/xfs/xfs_attr_list.c | 1 + fs/xfs/xfs_ioctl.c | 2 ++ fs/xfs/xfs_ioctl32.c | 2 ++ fs/xfs/xfs_iops.c | 2 ++ fs/xfs/xfs_xattr.c | 1 + 8 files changed, 35 insertions(+) diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index bed4f40..ebe1295 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/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. */ @@ -69,6 +91,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; /* diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index 1887605..9a649d1 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -24,6 +24,8 @@ #include "xfs_rmap_btree.h" #include "xfs_log.h" #include "xfs_trans_priv.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_reflink.h" #include "scrub/scrub.h" diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c index f8fb6e10..4e85b38 100644 --- a/fs/xfs/xfs_acl.c +++ b/fs/xfs/xfs_acl.c @@ -10,6 +10,8 @@ #include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_inode.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_trace.h" #include diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 00758fd..467c53c 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -12,6 +12,7 @@ #include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_inode.h" #include "xfs_trans.h" #include "xfs_bmap.h" diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 626420d..2cabdc2 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -15,6 +15,8 @@ #include "xfs_iwalk.h" #include "xfs_itable.h" #include "xfs_error.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_bmap.h" #include "xfs_bmap_util.h" diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 1e08bf7..7153780 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -17,6 +17,8 @@ #include "xfs_itable.h" #include "xfs_fsops.h" #include "xfs_rtalloc.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_ioctl.h" #include "xfs_ioctl32.h" diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 469e8e2..57de5f1 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -13,6 +13,8 @@ #include "xfs_inode.h" #include "xfs_acl.h" #include "xfs_quota.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_trans.h" #include "xfs_trace.h" diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 6309da4..470e605 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -10,6 +10,7 @@ #include "xfs_log_format.h" #include "xfs_da_format.h" #include "xfs_inode.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include From patchwork Thu Sep 5 22:18:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134091 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA56376 for ; Thu, 5 Sep 2019 22:19:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DC83020828 for ; Thu, 5 Sep 2019 22:19:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="NS2X0717" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389044AbfIEWTl (ORCPT ); Thu, 5 Sep 2019 18:19:41 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:39616 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389474AbfIEWTk (ORCPT ); Thu, 5 Sep 2019 18:19:40 -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 x85MJ867084635 for ; Thu, 5 Sep 2019 22:19:38 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=zQgTDNKXq8MsNg8sgxOFRmMZ7mOkKphPQUQuGZ1M0yk=; b=NS2X0717HVmAtoPX1MVN9z5QIVALgv5X6CYJGZhQjVS1Eb7N6vTw/4lDpfJp77YbrxEe qw3K4mGfLRL9VFFDSUhVGNuW0llXxtABf3ovcFokPWEe4iIoxihKlrWfB9zI38dBbxGP NSSp88T0MqhYN44WviyvACS4u4/uBK8B+jPY64kQa8cjKsOtS/ts2blbzfwpMvDOCD9Q zqZVgsBWCtVuh/eB1p0ygLM67r4MtApSGUDe2eZzh5oq0TPmWdfNASun1Ov9vAMNrUdD gIWCDHj9O1nWIFhWnvrn1+gp073sOJDLGldOvlzprJNL35B+vGgtSvD39856w4Ns9QOa kw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2uuaqxr2g7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:38 +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 x85MJ4JD076598 for ; Thu, 5 Sep 2019 22:19:37 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2utvr4a1c1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:37 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x85MImqW001636 for ; Thu, 5 Sep 2019 22:18:48 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:48 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 14/19] xfs: Add delayed attribute routines Date: Thu, 5 Sep 2019 15:18:32 -0700 Message-Id: <20190905221837.17388-15-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds new delayed attribute routines: xfs_attr_set_later xfs_attr_remove_later xfs_leaf_addname_later xfs_node_addname_later xfs_node_removename_later These routines are similar to their existing counter parts, but they do not roll or commit transactions. They instead return -EAGAIN 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 --- fs/xfs/libxfs/xfs_attr.c | 591 ++++++++++++++++++++++++++++++++++++++++++++++- fs/xfs/libxfs/xfs_attr.h | 2 + 2 files changed, 592 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 781dd8a..310f5b2 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -45,6 +45,7 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args); */ STATIC int xfs_attr_leaf_get(xfs_da_args_t *args); STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args); +STATIC int xfs_leaf_addname_later(xfs_da_args_t *args); STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); STATIC int xfs_leaf_has_attr(struct xfs_da_args *args, struct xfs_buf **bp); @@ -53,12 +54,14 @@ STATIC int xfs_leaf_has_attr(struct xfs_da_args *args, struct xfs_buf **bp); */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC int xfs_attr_node_addname(xfs_da_args_t *args); +STATIC int xfs_node_addname_later(xfs_da_args_t *args); STATIC int xfs_attr_node_removename(xfs_da_args_t *args); +STATIC int xfs_node_removename_later(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); STATIC int xfs_attr_args_init( @@ -313,6 +316,112 @@ 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_set_later( + struct xfs_da_args *args, + struct xfs_buf **leaf_bp) +{ + struct xfs_inode *dp = args->dp; + int error = 0; + int sf_size; + + /* + * New inodes may not have an attribute fork yet. So set the attribute + * fork appropriately + */ + if (XFS_IFORK_Q((args->dp)) == 0) { + sf_size = sizeof(struct xfs_attr_sf_hdr) + + XFS_ATTR_SF_ENTSIZE_BYNAME(args->name.len, args->valuelen); + xfs_bmap_set_attrforkoff(args->dp, sf_size, NULL); + args->dp->i_afp = kmem_zone_zalloc(xfs_ifork_zone, 0); + args->dp->i_afp->if_flags = XFS_IFEXTENTS; + } + + /* + * If the attribute list is non-existent or a shortform list, + * 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) { + 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_leaf_addname_later(args); + if (error && error != -ENOSPC) + return error; + } else { + error = xfs_node_addname_later(args); + } + + return error; +} + + + +/* * Return EEXIST if attr is found, or ENOATTR if not */ int @@ -362,6 +471,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_remove_later( + 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_node_removename_later(args); + } + + return error; +} + + + int xfs_attr_set( struct xfs_inode *dp, @@ -794,6 +954,87 @@ 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_leaf_addname_later( + struct xfs_da_args *args) +{ + int error, nmap; + 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; + args->rmtblkcnt = 0; + args->rmtblkno = 0; + memset(map, 0, sizeof(struct xfs_bmbt_irec)); + + error = xfs_attr_rmt_find_hole(args); + if (error) + return error; + + args->dc.blkcnt = args->rmtblkcnt; + args->dc.lblkno = args->rmtblkno; + 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 (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 @@ -1291,6 +1532,354 @@ xfs_attr_node_removename( } /* + * 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_node_removename_later( + 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)) { + bool isset; + + error = xfs_attr3_leaf_flag_is_set(args, &isset); + if (error) + goto out; + if (!isset) { + /* + * 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)) { + args->dc.flags |= XFS_DC_RM_NODE_BLKS; + error = xfs_attr_rmtval_invalidate(args); + if (error) + goto out; + } + + /* + * Unmap value blocks for this attr. This is similar to + * xfs_attr_rmtval_remove, but open coded here to return EAGAIN + * for new transactions + */ + 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_node_addname_later( + struct xfs_da_args *args) +{ + struct xfs_da_state *state = NULL; + struct xfs_da_state_blk *blk; + struct xfs_inode *dp; + int retval, error = 0; + int nmap; + 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; + + 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->name.type & ATTR_REPLACE) && (retval == -ENOATTR)) { + goto out; + } else if (retval == -EEXIST) { + if (args->name.type & 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; + args->rmtblkcnt = 0; + args->rmtblkno = 0; + memset(map, 0, sizeof(struct xfs_bmbt_irec)); + + error = xfs_attr_rmt_find_hole(args); + if (error) + return error; + + args->dc.blkcnt = args->rmtblkcnt; + args->dc.lblkno = args->rmtblkno; + } + /* + * 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 (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/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index fb56d81..6203766 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -149,9 +149,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_set_later(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_remove_later(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 Thu Sep 5 22:18:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134095 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 638461593 for ; Thu, 5 Sep 2019 22:19:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E3D22082C for ; Thu, 5 Sep 2019 22:19:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="NDg40j4T" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389589AbfIEWTm (ORCPT ); Thu, 5 Sep 2019 18:19:42 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33810 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391184AbfIEWTl (ORCPT ); Thu, 5 Sep 2019 18:19:41 -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 x85MJ7NH078078 for ; Thu, 5 Sep 2019 22:19: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=/Nv2mCRdcwYrmpme4IXDnoRQVuNc0xvqfLXeEtunnLs=; b=NDg40j4TK9wVHCvnvV/akEpo8nU0PFrk2gIa0nVC1SPgdtTaNOtVwIXTJXeomWa5lyGf OkPjCttYN174puNhG7SUDnC/53eJuFYEqOF5xxErnQgs+W6/FJgpVxoy8A8jKTzOZX9H 3Jvi7dvdKXuWCLVCsQ0qmi/OoGntxOaZb73eMzo1Nlh6pf9dVZQu9u8dpsupzPxIG9sS rNoaYQgsnaHNRG13CDGlEl/paKSu8m8C20sOcJIKi9XUHaGxnDL7Uheh4WREhuTryCKO 5SN9HrICf8prmdq3qnStQGYgXkHVszgEdetl1doPf7lX6b4h7JDNSEYDXsewLEMaVRWV Qg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2uuaqj02r5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:39 +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 x85MIe4g123387 for ; Thu, 5 Sep 2019 22:19:38 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2uthq27va8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:37 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x85MImuW008699 for ; Thu, 5 Sep 2019 22:18:48 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:48 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 15/19] xfs: Set up infastructure for deferred attribute operations Date: Thu, 5 Sep 2019 15:18:33 -0700 Message-Id: <20190905221837.17388-16-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson 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 --- fs/xfs/Makefile | 2 +- fs/xfs/libxfs/xfs_attr.c | 5 +- fs/xfs/libxfs/xfs_attr.h | 33 ++ fs/xfs/libxfs/xfs_defer.c | 1 + fs/xfs/libxfs/xfs_defer.h | 3 + fs/xfs/libxfs/xfs_log_format.h | 44 ++- fs/xfs/libxfs/xfs_types.h | 1 + fs/xfs/xfs_attr_item.c | 756 +++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_attr_item.h | 88 +++++ fs/xfs/xfs_log.c | 4 + fs/xfs/xfs_log_recover.c | 173 ++++++++++ fs/xfs/xfs_ondisk.h | 2 + fs/xfs/xfs_trans.h | 1 - 13 files changed, 1107 insertions(+), 6 deletions(-) diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 06b68b6..70b4716 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -102,6 +102,7 @@ xfs-y += xfs_log.o \ xfs_bmap_item.o \ xfs_buf_item.o \ xfs_extfree_item.o \ + xfs_attr_item.o \ xfs_icreate_item.o \ xfs_inode_item.o \ xfs_refcount_item.o \ @@ -109,7 +110,6 @@ xfs-y += xfs_log.o \ xfs_log_recover.o \ xfs_trans_ail.o \ xfs_trans_buf.o - # optional features xfs-$(CONFIG_XFS_QUOTA) += xfs_dquot.o \ xfs_dquot_item.o \ diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 310f5b2..7680789 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -24,6 +24,7 @@ #include "xfs_quota.h" #include "xfs_trans_space.h" #include "xfs_trace.h" +#include "xfs_attr_item.h" /* * xfs_attr.c @@ -63,7 +64,7 @@ STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); -STATIC int +int xfs_attr_args_init( struct xfs_da_args *args, struct xfs_inode *dp, @@ -190,7 +191,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/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 6203766..1e0c25e 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -80,6 +80,36 @@ 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; + void *xattri_value; /* attr value */ + void *xattri_name; /* attr name */ + uint32_t xattri_op_flags; /* attr op set or rm */ + uint32_t xattri_value_len; /* length of value */ + uint32_t xattri_name_len; /* length of name */ + uint32_t xattri_flags; /* attr flags */ + + /* used to log this item to an intent */ + 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. + */ +}; + +#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. */ @@ -157,5 +187,8 @@ int xfs_attr_remove_later(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/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 2255752..6749022 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/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/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 7c28d76..b9ff7b9 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/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/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index e5f97c6..acdb8ad 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/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/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h index 300b3e9..ade55d4 100644 --- a/fs/xfs/libxfs/xfs_types.h +++ b/fs/xfs/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 */ diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c new file mode 100644 index 0000000..a4abcf3 --- /dev/null +++ b/fs/xfs/xfs_attr_item.c @@ -0,0 +1,756 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2019 Oracle. All Rights Reserved. + * Author: Allison Collins + */ + +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_log_format.h" +#include "xfs_trans_resv.h" +#include "xfs_bit.h" +#include "xfs_shared.h" +#include "xfs_mount.h" +#include "xfs_defer.h" +#include "xfs_trans.h" +#include "xfs_trans_priv.h" +#include "xfs_buf_item.h" +#include "xfs_attr_item.h" +#include "xfs_log.h" +#include "xfs_btree.h" +#include "xfs_rmap.h" +#include "xfs_inode.h" +#include "xfs_icache.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_attr.h" +#include "xfs_shared.h" +#include "xfs_attr_item.h" +#include "xfs_alloc.h" +#include "xfs_bmap.h" +#include "xfs_trace.h" +#include "libxfs/xfs_da_format.h" +#include "xfs_inode.h" +#include "xfs_quota.h" + +/* + * This routine is called to allocate an "attr free done" log item. + */ +struct xfs_attrd_log_item * +xfs_trans_get_attrd(struct xfs_trans *tp, + struct xfs_attri_log_item *attrip) +{ + struct xfs_attrd_log_item *attrdp; + + ASSERT(tp != NULL); + + attrdp = xfs_attrd_init(tp->t_mountp, attrip); + ASSERT(attrdp != NULL); + + xfs_trans_add_item(tp, &attrdp->attrd_item); + return attrdp; +} + +/* + * Log an ATTRI it to the ATTRD when the attr op is done. An attr operation + * may be a set or a remove. Note that the transaction is marked dirty + * regardless of whether the operation succeeds or fails to support the + * ATTRI/ATTRD lifecycle rules. + */ +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; + + 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_later(args, leaf_bp); + break; + case XFS_ATTR_OP_FLAGS_REMOVE: + ASSERT(XFS_IFORK_Q((args->dp))); + error = xfs_attr_remove_later(args); + break; + default: + error = -EFSCORRUPTED; + break; + } + + /* + * 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) +{ + struct xfs_attri_log_item *attrip; + + ASSERT(tp != NULL); + ASSERT(count == 1); + + attrip = xfs_attri_init(tp->t_mountp); + ASSERT(attrip != NULL); + + xfs_trans_add_item(tp, &attrip->attri_item); + return attrip; +} + +/* Log an attr to the intent item. */ +STATIC void +xfs_attr_log_item( + struct xfs_trans *tp, + void *intent, + struct list_head *item) +{ + struct xfs_attri_log_item *attrip = intent; + struct xfs_attr_item *attr; + struct xfs_attri_log_format *attrp; + char *name_value; + + attr = container_of(item, struct xfs_attr_item, xattri_list); + name_value = ((char *)attr) + sizeof(struct xfs_attr_item); + + tp->t_flags |= XFS_TRANS_DIRTY; + set_bit(XFS_LI_DIRTY, &attrip->attri_item.li_flags); + + /* + * At this point the xfs_attr_item has been constructed, and we've + * created the log intent. Fill in the attri log item and log format + * structure with fields from this xfs_attr_item + */ + attrp = &attrip->attri_format; + attrp->alfi_ino = attr->xattri_ip->i_ino; + attrp->alfi_op_flags = attr->xattri_op_flags; + attrp->alfi_value_len = attr->xattri_value_len; + attrp->alfi_name_len = attr->xattri_name_len; + attrp->alfi_attr_flags = attr->xattri_flags; + + attrip->attri_name = name_value; + attrip->attri_value = &name_value[attr->xattri_name_len]; + attrip->attri_name_len = attr->xattri_name_len; + attrip->attri_value_len = attr->xattri_value_len; +} + +/* 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 xfs_trans_get_attrd(tp, intent); +} + +/* 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; + 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); + args = &attr->xattri_args; + + name_value = ((char *)attr) + sizeof(struct xfs_attr_item); + name.name = name_value; + name.len = attr->xattri_name_len; + name.type = attr->xattri_flags; + + if (!(args->dc.flags & XFS_DC_INIT)) { + /* Only need to initialize args context once */ + error = xfs_attr_args_init(args, attr->xattri_ip, &name); + if (error) + goto out; + + args->hashval = xfs_da_hashname(args->name.name, + args->name.len); + args->value = &name_value[attr->xattri_name_len]; + args->valuelen = attr->xattri_value_len; + args->op_flags = XFS_DA_OP_OKNOENT; + + /* must match existing transaction block res */ + 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, &args->dc.leaf_bp, + attr->xattri_op_flags); +out: + /* + * The attrip refers to xfs_attr_item memory to log the name and value + * with the intent item. This already occurred when the intent was + * committed so these fields are no longer accessed. Clear them out of + * caution since we're about to free the xfs_attr_item. + */ + attrdp = (struct xfs_attrd_log_item *)done_item; + attrip = attrdp->attrd_attrip; + attrip->attri_name = NULL; + attrip->attri_value = NULL; + + if (error != -EAGAIN) + kmem_free(attr); + + return error; +} + +/* Abort all pending ATTRs. */ +STATIC void +xfs_attr_abort_intent( + void *intent) +{ + xfs_attri_release(intent); +} + +/* Cancel an attr */ +STATIC void +xfs_attr_cancel_item( + struct list_head *item) +{ + struct xfs_attr_item *attr; + + attr = container_of(item, struct xfs_attr_item, xattri_list); + kmem_free(attr); +} + +const struct xfs_defer_op_type xfs_attr_defer_type = { + .max_items = 1, + .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, +}; + +static inline struct xfs_attri_log_item *ATTRI_ITEM(struct xfs_log_item *lip) +{ + return container_of(lip, struct xfs_attri_log_item, attri_item); +} + +void +xfs_attri_item_free( + struct xfs_attri_log_item *attrip) +{ + kmem_free(attrip->attri_item.li_lv_shadow); + kmem_free(attrip); +} + +/* + * This returns the number of iovecs needed to log the given attri item. We + * only need 1 iovec for an attri item. It just logs the attr_log_format + * structure. + */ +static inline int +xfs_attri_item_sizeof( + struct xfs_attri_log_item *attrip) +{ + return sizeof(struct xfs_attri_log_format); +} + +STATIC void +xfs_attri_item_size( + struct xfs_log_item *lip, + int *nvecs, + int *nbytes) +{ + struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip); + + *nvecs += 1; + *nbytes += xfs_attri_item_sizeof(attrip); + + /* Attr set and remove operations require a name */ + ASSERT(attrip->attri_name_len > 0); + + *nvecs += 1; + *nbytes += ATTR_NVEC_SIZE(attrip->attri_name_len); + + /* + * Set ops can accept a value of 0 len to clear an attr value. Remove + * ops do not need a value at all. So only account for the value + * when it is needed. + */ + if (attrip->attri_value_len > 0) { + *nvecs += 1; + *nbytes += ATTR_NVEC_SIZE(attrip->attri_value_len); + } +} + +/* + * This is called to fill in the log iovecs for the given attri log + * item. We use 1 iovec for the attri_format_item, 1 for the name, and + * another for the value if it is present + */ +STATIC void +xfs_attri_item_format( + struct xfs_log_item *lip, + struct xfs_log_vec *lv) +{ + struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip); + struct xfs_log_iovec *vecp = NULL; + + attrip->attri_format.alfi_type = XFS_LI_ATTRI; + attrip->attri_format.alfi_size = 1; + + /* + * This size accounting must be done before copying the attrip into the + * iovec. If we do it after, the wrong size will be recorded to the log + * and we trip across assertion checks for bad region sizes later during + * the log recovery. + */ + + ASSERT(attrip->attri_name_len > 0); + attrip->attri_format.alfi_size++; + + if (attrip->attri_value_len > 0) + attrip->attri_format.alfi_size++; + + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRI_FORMAT, + &attrip->attri_format, + xfs_attri_item_sizeof(attrip)); + if (attrip->attri_name_len > 0) + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_NAME, + attrip->attri_name, + ATTR_NVEC_SIZE(attrip->attri_name_len)); + + if (attrip->attri_value_len > 0) + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_VALUE, + attrip->attri_value, + ATTR_NVEC_SIZE(attrip->attri_value_len)); +} + +/* + * The unpin operation is the last place an ATTRI is manipulated in the log. It + * is either inserted in the AIL or aborted in the event of a log I/O error. In + * either case, the ATTRI transaction has been successfully committed to make + * it this far. Therefore, we expect whoever committed the ATTRI to either + * construct and commit the ATTRD or drop the ATTRD's reference in the event of + * error. Simply drop the log's ATTRI reference now that the log is done with + * it. + */ +STATIC void +xfs_attri_item_unpin( + struct xfs_log_item *lip, + int remove) +{ + struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip); + + xfs_attri_release(attrip); +} + +/* + * attri items have no locking or pushing. However, since ATTRIs are pulled + * from the AIL when their corresponding ATTRDs are committed to disk, their + * situation is very similar to being pinned. Return XFS_ITEM_PINNED so that + * the caller will eventually flush the log. This should help in getting the + * ATTRI out of the AIL. + */ +STATIC uint +xfs_attri_item_push( + struct xfs_log_item *lip, + struct list_head *buffer_list) +{ + return XFS_ITEM_PINNED; +} + +/* + * The ATTRI is logged only once and cannot be moved in the log, so simply + * return the lsn at which it's been logged. + */ +STATIC xfs_lsn_t +xfs_attri_item_committed( + struct xfs_log_item *lip, + xfs_lsn_t lsn) +{ + return lsn; +} + +STATIC void +xfs_attri_item_committing( + struct xfs_log_item *lip, + xfs_lsn_t lsn) +{ +} + +STATIC void +xfs_attri_item_release( + struct xfs_log_item *lip) +{ + xfs_attri_release(ATTRI_ITEM(lip)); +} + +static const struct xfs_item_ops xfs_attri_item_ops = { + .iop_size = xfs_attri_item_size, + .iop_format = xfs_attri_item_format, + .iop_unpin = xfs_attri_item_unpin, + .iop_committed = xfs_attri_item_committed, + .iop_push = xfs_attri_item_push, + .iop_committing = xfs_attri_item_committing, + .iop_release = xfs_attri_item_release, +}; + + +/* + * Allocate and initialize an attri item + */ +struct xfs_attri_log_item * +xfs_attri_init( + struct xfs_mount *mp) + +{ + struct xfs_attri_log_item *attrip; + uint size; + + size = (uint)(sizeof(struct xfs_attri_log_item)); + attrip = kmem_zalloc(size, 0); + + xfs_log_item_init(mp, &attrip->attri_item, XFS_LI_ATTRI, + &xfs_attri_item_ops); + attrip->attri_format.alfi_id = (uintptr_t)(void *)attrip; + atomic_set(&attrip->attri_refcount, 2); + + return attrip; +} + +/* + * Copy an attr format buffer from the given buf, and into the destination attr + * format structure. + */ +int +xfs_attri_copy_format(struct xfs_log_iovec *buf, + struct xfs_attri_log_format *dst_attr_fmt) +{ + struct xfs_attri_log_format *src_attr_fmt = buf->i_addr; + uint len = sizeof(struct xfs_attri_log_format); + + if (buf->i_len != len) + return -EFSCORRUPTED; + + memcpy((char *)dst_attr_fmt, (char *)src_attr_fmt, len); + return 0; +} + +/* + * Freeing the attrip requires that we remove it from the AIL if it has already + * been placed there. However, the ATTRI may not yet have been placed in the + * AIL when called by xfs_attri_release() from ATTRD processing due to the + * ordering of committed vs unpin operations in bulk insert operations. Hence + * the reference count to ensure only the last caller frees the ATTRI. + */ +void +xfs_attri_release( + struct xfs_attri_log_item *attrip) +{ + ASSERT(atomic_read(&attrip->attri_refcount) > 0); + if (atomic_dec_and_test(&attrip->attri_refcount)) { + xfs_trans_ail_remove(&attrip->attri_item, + SHUTDOWN_LOG_IO_ERROR); + xfs_attri_item_free(attrip); + } +} + +static inline struct xfs_attrd_log_item *ATTRD_ITEM(struct xfs_log_item *lip) +{ + return container_of(lip, struct xfs_attrd_log_item, attrd_item); +} + +STATIC void +xfs_attrd_item_free(struct xfs_attrd_log_item *attrdp) +{ + kmem_free(attrdp->attrd_item.li_lv_shadow); + kmem_free(attrdp); +} + +/* + * This returns the number of iovecs needed to log the given attrd item. + * We only need 1 iovec for an attrd item. It just logs the attr_log_format + * structure. + */ +static inline int +xfs_attrd_item_sizeof( + struct xfs_attrd_log_item *attrdp) +{ + return sizeof(struct xfs_attrd_log_format); +} + +STATIC void +xfs_attrd_item_size( + struct xfs_log_item *lip, + int *nvecs, + int *nbytes) +{ + struct xfs_attrd_log_item *attrdp = ATTRD_ITEM(lip); + *nvecs += 1; + *nbytes += xfs_attrd_item_sizeof(attrdp); +} + +/* + * This is called to fill in the log iovecs for the given attrd log item. We use + * only 1 iovec for the attrd_format, and we point that at the attr_log_format + * structure embedded in the attrd item. + */ +STATIC void +xfs_attrd_item_format( + struct xfs_log_item *lip, + struct xfs_log_vec *lv) +{ + struct xfs_attrd_log_item *attrdp = ATTRD_ITEM(lip); + struct xfs_log_iovec *vecp = NULL; + + attrdp->attrd_format.alfd_type = XFS_LI_ATTRD; + attrdp->attrd_format.alfd_size = 1; + + xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRD_FORMAT, + &attrdp->attrd_format, xfs_attrd_item_sizeof(attrdp)); +} + +/* + * There isn't much you can do to push on an attrd item. It is simply stuck + * waiting for the log to be flushed to disk. + */ +STATIC uint +xfs_attrd_item_push( + struct xfs_log_item *lip, + struct list_head *buffer_list) +{ + return XFS_ITEM_PINNED; +} + +/* + * When the attrd item is committed to disk, all we need to do is delete our + * reference to our partner attri item and then free ourselves. Since we're + * freeing ourselves we must return -1 to keep the transaction code from + * further referencing this item. + */ +STATIC xfs_lsn_t +xfs_attrd_item_committed( + struct xfs_log_item *lip, + xfs_lsn_t lsn) +{ + struct xfs_attrd_log_item *attrdp = ATTRD_ITEM(lip); + + /* + * Drop the ATTRI reference regardless of whether the ATTRD has been + * aborted. Once the ATTRD transaction is constructed, it is the sole + * responsibility of the ATTRD to release the ATTRI (even if the ATTRI + * is aborted due to log I/O error). + */ + xfs_attri_release(attrdp->attrd_attrip); + xfs_attrd_item_free(attrdp); + + return NULLCOMMITLSN; +} + +STATIC void +xfs_attrd_item_committing( + struct xfs_log_item *lip, + xfs_lsn_t lsn) +{ +} + +/* + * The ATTRD is either committed or aborted if the transaction is cancelled. If + * the transaction is cancelled, drop our reference to the ATTRI and free the + * ATTRD. + */ +STATIC void +xfs_attrd_item_release( + struct xfs_log_item *lip) +{ + struct xfs_attrd_log_item *attrdp = ATTRD_ITEM(lip); + + xfs_attri_release(attrdp->attrd_attrip); + xfs_attrd_item_free(attrdp); +} + +static const struct xfs_item_ops xfs_attrd_item_ops = { + .iop_size = xfs_attrd_item_size, + .iop_format = xfs_attrd_item_format, + .iop_committed = xfs_attrd_item_committed, + .iop_push = xfs_attrd_item_push, + .iop_committing = xfs_attrd_item_committing, + .iop_release = xfs_attrd_item_release, +}; + +/* + * Allocate and initialize an attrd item + */ +struct xfs_attrd_log_item * +xfs_attrd_init( + struct xfs_mount *mp, + struct xfs_attri_log_item *attrip) + +{ + struct xfs_attrd_log_item *attrdp; + uint size; + + size = (uint)(sizeof(struct xfs_attrd_log_item)); + attrdp = kmem_zalloc(size, 0); + + xfs_log_item_init(mp, &attrdp->attrd_item, XFS_LI_ATTRD, + &xfs_attrd_item_ops); + attrdp->attrd_attrip = attrip; + attrdp->attrd_format.alfd_alf_id = attrip->attri_format.alfi_id; + + return attrdp; +} + +/* + * Process an attr intent item that was recovered from the log. We need to + * delete the attr that it describes. + */ +int +xfs_attri_recover( + struct xfs_mount *mp, + struct xfs_attri_log_item *attrip) +{ + struct xfs_inode *ip; + struct xfs_attrd_log_item *attrdp; + struct xfs_da_args args; + struct xfs_attri_log_format *attrp; + struct xfs_trans_res tres; + int local; + int error, err2 = 0; + int rsvd = 0; + struct xfs_name name; + struct xfs_buf *leaf_bp = NULL; + + ASSERT(!test_bit(XFS_ATTRI_RECOVERED, &attrip->attri_flags)); + + /* + * First check the validity of the attr described by the ATTRI. If any + * are bad, then assume that all are bad and just toss the ATTRI. + */ + attrp = &attrip->attri_format; + if (!(attrp->alfi_op_flags == XFS_ATTR_OP_FLAGS_SET || + attrp->alfi_op_flags == XFS_ATTR_OP_FLAGS_REMOVE) || + (attrp->alfi_value_len > XATTR_SIZE_MAX) || + (attrp->alfi_name_len > XATTR_NAME_MAX) || + (attrp->alfi_name_len == 0)) { + /* + * This will pull the ATTRI from the AIL and free the memory + * associated with it. + */ + set_bit(XFS_ATTRI_RECOVERED, &attrip->attri_flags); + xfs_attri_release(attrip); + return -EFSCORRUPTED; + } + + error = xfs_iget(mp, 0, attrp->alfi_ino, 0, 0, &ip); + if (error) + return error; + + name.name = attrip->attri_name; + name.len = attrp->alfi_name_len; + name.type = attrp->alfi_attr_flags; + error = xfs_attr_args_init(&args, ip, &name); + if (error) + goto out_rele; + + args.hashval = xfs_da_hashname(args.name.name, args.name.len); + args.value = attrip->attri_value; + args.valuelen = attrp->alfi_value_len; + args.op_flags = XFS_DA_OP_OKNOENT; + args.total = xfs_attr_calc_size(&args, &local); + + tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres + + M_RES(mp)->tr_attrsetrt.tr_logres * args.total; + tres.tr_logcount = XFS_ATTRSET_LOG_COUNT; + tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; + + error = xfs_trans_alloc(mp, &tres, args.total, 0, + rsvd ? XFS_TRANS_RESERVE : 0, &args.trans); + if (error) + goto out_rele; + attrdp = xfs_trans_get_attrd(args.trans, attrip); + + xfs_ilock(ip, XFS_ILOCK_EXCL); + + xfs_trans_ijoin(args.trans, ip, 0); + + do { + error = xfs_trans_attr(&args, attrdp, &leaf_bp, + attrp->alfi_op_flags); + if (error && error != -EAGAIN) + goto abort_error; + + xfs_trans_log_inode(args.trans, ip, + XFS_ILOG_CORE | XFS_ILOG_ADATA); + + err2 = xfs_trans_roll(&args.trans); + if (err2) { + error = err2; + goto abort_error; + } + + /* Rejoin inode and leaf if needed */ + xfs_trans_ijoin(args.trans, ip, 0); + if (leaf_bp) { + xfs_trans_bjoin(args.trans, leaf_bp); + xfs_trans_bhold(args.trans, leaf_bp); + } + + } while (error == -EAGAIN); + + error = xfs_trans_commit(args.trans); + if (error) + goto abort_error; + + set_bit(XFS_ATTRI_RECOVERED, &attrip->attri_flags); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_irele(ip); + return error; + +abort_error: + xfs_trans_cancel(args.trans); + xfs_iunlock(ip, XFS_ILOCK_EXCL); +out_rele: + xfs_irele(ip); + return error; +} diff --git a/fs/xfs/xfs_attr_item.h b/fs/xfs/xfs_attr_item.h new file mode 100644 index 0000000..0c4cd72 --- /dev/null +++ b/fs/xfs/xfs_attr_item.h @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) 2019 Oracle. All Rights Reserved. + * Author: Allison Collins + */ +#ifndef __XFS_ATTR_ITEM_H__ +#define __XFS_ATTR_ITEM_H__ + +/* kernel only ATTRI/ATTRD definitions */ + +struct xfs_mount; +struct kmem_zone; + +/* + * Define ATTR flag bits. Manipulated by set/clear/test_bit operators. + */ +#define XFS_ATTRI_RECOVERED 1 + + +/* iovec length must be 32-bit aligned */ +#define ATTR_NVEC_SIZE(size) (size == sizeof(int32_t) ? sizeof(int32_t) : \ + size + sizeof(int32_t) - \ + (size % sizeof(int32_t))) + +/* + * This is the "attr intention" log item. It is used to log the fact that some + * attribute operations need to be processed. An operation is currently either + * a set or remove. Set or remove operations are described by the xfs_attr_item + * which may be logged to this intent. Intents are used in conjunction with the + * "attr done" log item described below. + * + * The ATTRI is reference counted so that it is not freed prior to both the + * ATTRI and ATTRD being committed and unpinned. This ensures the ATTRI is + * inserted into the AIL even in the event of out of order ATTRI/ATTRD + * processing. In other words, an ATTRI is born with two references: + * + * 1.) an ATTRI held reference to track ATTRI AIL insertion + * 2.) an ATTRD held reference to track ATTRD commit + * + * On allocation, both references are the responsibility of the caller. Once the + * ATTRI is added to and dirtied in a transaction, ownership of reference one + * transfers to the transaction. The reference is dropped once the ATTRI is + * inserted to the AIL or in the event of failure along the way (e.g., commit + * failure, log I/O error, etc.). Note that the caller remains responsible for + * the ATTRD reference under all circumstances to this point. The caller has no + * means to detect failure once the transaction is committed, however. + * Therefore, an ATTRD is required after this point, even in the event of + * unrelated failure. + * + * Once an ATTRD is allocated and dirtied in a transaction, reference two + * transfers to the transaction. The ATTRD reference is dropped once it reaches + * the unpin handler. Similar to the ATTRI, the reference also drops in the + * event of commit failure or log I/O errors. Note that the ATTRD is not + * inserted in the AIL, so at this point both the ATTRI and ATTRD are freed. + */ +struct xfs_attri_log_item { + struct xfs_log_item attri_item; + atomic_t attri_refcount; + unsigned long attri_flags; /* misc flags */ + int attri_name_len; + void *attri_name; + int attri_value_len; + void *attri_value; + struct xfs_attri_log_format attri_format; +}; + +/* + * This is the "attr done" log item. It is used to log the fact that some attrs + * earlier mentioned in an attri item have been freed. + */ +struct xfs_attrd_log_item { + struct xfs_attri_log_item *attrd_attrip; + struct xfs_log_item attrd_item; + struct xfs_attrd_log_format attrd_format; +}; + +struct xfs_attri_log_item *xfs_attri_init(struct xfs_mount *mp); +struct xfs_attrd_log_item *xfs_attrd_init(struct xfs_mount *mp, + struct xfs_attri_log_item *attrip); +int xfs_attri_copy_format(struct xfs_log_iovec *buf, + struct xfs_attri_log_format *dst_attri_fmt); +void xfs_attri_item_free(struct xfs_attri_log_item *attrip); +void xfs_attri_release(struct xfs_attri_log_item *attrip); + +int xfs_attri_recover(struct xfs_mount *mp, + struct xfs_attri_log_item *attrip); + +#endif /* __XFS_ATTR_ITEM_H__ */ diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 3e0a105..3de9e18 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2002,6 +2002,10 @@ xlog_print_tic_res( REG_TYPE_STR(CUD_FORMAT, "cud_format"), REG_TYPE_STR(BUI_FORMAT, "bui_format"), REG_TYPE_STR(BUD_FORMAT, "bud_format"), + REG_TYPE_STR(ATTRI_FORMAT, "attri_format"), + REG_TYPE_STR(ATTRD_FORMAT, "attrd_format"), + REG_TYPE_STR(ATTR_NAME, "attr_name"), + REG_TYPE_STR(ATTR_VALUE, "attr_value"), }; BUILD_BUG_ON(ARRAY_SIZE(res_type_str) != XLOG_REG_TYPE_MAX + 1); #undef REG_TYPE_STR diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index f05c6c9..11378f9 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -20,6 +20,7 @@ #include "xfs_log_recover.h" #include "xfs_inode_item.h" #include "xfs_extfree_item.h" +#include "xfs_attr_item.h" #include "xfs_trans_priv.h" #include "xfs_alloc.h" #include "xfs_ialloc.h" @@ -1887,6 +1888,8 @@ xlog_recover_reorder_trans( case XFS_LI_CUD: case XFS_LI_BUI: case XFS_LI_BUD: + case XFS_LI_ATTRI: + case XFS_LI_ATTRD: trace_xfs_log_recover_item_reorder_tail(log, trans, item, pass); list_move_tail(&item->ri_list, &inode_list); @@ -3424,6 +3427,118 @@ xlog_recover_efd_pass2( return 0; } +STATIC int +xlog_recover_attri_pass2( + struct xlog *log, + struct xlog_recover_item *item, + xfs_lsn_t lsn) +{ + int error; + struct xfs_mount *mp = log->l_mp; + struct xfs_attri_log_item *attrip; + struct xfs_attri_log_format *attri_formatp; + char *name = NULL; + char *value = NULL; + int region = 0; + + attri_formatp = item->ri_buf[region].i_addr; + + attrip = xfs_attri_init(mp); + error = xfs_attri_copy_format(&item->ri_buf[region], + &attrip->attri_format); + if (error) { + xfs_attri_item_free(attrip); + return error; + } + + attrip->attri_name_len = attri_formatp->alfi_name_len; + attrip->attri_value_len = attri_formatp->alfi_value_len; + attrip = kmem_realloc(attrip, sizeof(struct xfs_attri_log_item) + + attrip->attri_name_len + attrip->attri_value_len, + 0); + + ASSERT(attrip->attri_name_len > 0); + region++; + name = ((char *)attrip) + sizeof(struct xfs_attri_log_item); + memcpy(name, item->ri_buf[region].i_addr, + attrip->attri_name_len); + attrip->attri_name = name; + + if (attrip->attri_value_len > 0) { + region++; + value = ((char *)attrip) + sizeof(struct xfs_attri_log_item) + + attrip->attri_name_len; + memcpy(value, item->ri_buf[region].i_addr, + attrip->attri_value_len); + attrip->attri_value = value; + } + + spin_lock(&log->l_ailp->ail_lock); + /* + * The ATTRI has two references. One for the ATTRD and one for ATTRI to + * ensure it makes it into the AIL. Insert the ATTRI into the AIL + * directly and drop the ATTRI reference. Note that + * xfs_trans_ail_update() drops the AIL lock. + */ + xfs_trans_ail_update(log->l_ailp, &attrip->attri_item, lsn); + xfs_attri_release(attrip); + return 0; +} + + +/* + * This routine is called when an ATTRD format structure is found in a committed + * transaction in the log. Its purpose is to cancel the corresponding ATTRI if + * it was still in the log. To do this it searches the AIL for the ATTRI with + * an id equal to that in the ATTRD format structure. If we find it we drop + * the ATTRD reference, which removes the ATTRI from the AIL and frees it. + */ +STATIC int +xlog_recover_attrd_pass2( + struct xlog *log, + struct xlog_recover_item *item) +{ + struct xfs_attrd_log_format *attrd_formatp; + struct xfs_attri_log_item *attrip = NULL; + struct xfs_log_item *lip; + uint64_t attri_id; + struct xfs_ail_cursor cur; + struct xfs_ail *ailp = log->l_ailp; + + attrd_formatp = item->ri_buf[0].i_addr; + ASSERT((item->ri_buf[0].i_len == + (sizeof(struct xfs_attrd_log_format)))); + attri_id = attrd_formatp->alfd_alf_id; + + /* + * Search for the ATTRI with the id in the ATTRD format structure in the + * AIL. + */ + spin_lock(&ailp->ail_lock); + lip = xfs_trans_ail_cursor_first(ailp, &cur, 0); + while (lip != NULL) { + if (lip->li_type == XFS_LI_ATTRI) { + attrip = (struct xfs_attri_log_item *)lip; + if (attrip->attri_format.alfi_id == attri_id) { + /* + * Drop the ATTRD reference to the ATTRI. This + * removes the ATTRI from the AIL and frees it. + */ + spin_unlock(&ailp->ail_lock); + xfs_attri_release(attrip); + spin_lock(&ailp->ail_lock); + break; + } + } + lip = xfs_trans_ail_cursor_next(ailp, &cur); + } + + xfs_trans_ail_cursor_done(&cur); + spin_unlock(&ailp->ail_lock); + + return 0; +} + /* * This routine is called to create an in-core extent rmap update * item from the rui format structure which was logged on disk. @@ -3976,6 +4091,8 @@ xlog_recover_ra_pass2( break; case XFS_LI_EFI: case XFS_LI_EFD: + case XFS_LI_ATTRI: + case XFS_LI_ATTRD: case XFS_LI_QUOTAOFF: case XFS_LI_RUI: case XFS_LI_RUD: @@ -4004,6 +4121,8 @@ xlog_recover_commit_pass1( case XFS_LI_INODE: case XFS_LI_EFI: case XFS_LI_EFD: + case XFS_LI_ATTRI: + case XFS_LI_ATTRD: case XFS_LI_DQUOT: case XFS_LI_ICREATE: case XFS_LI_RUI: @@ -4042,6 +4161,10 @@ xlog_recover_commit_pass2( return xlog_recover_efi_pass2(log, item, trans->r_lsn); case XFS_LI_EFD: return xlog_recover_efd_pass2(log, item); + case XFS_LI_ATTRI: + return xlog_recover_attri_pass2(log, item, trans->r_lsn); + case XFS_LI_ATTRD: + return xlog_recover_attrd_pass2(log, item); case XFS_LI_RUI: return xlog_recover_rui_pass2(log, item, trans->r_lsn); case XFS_LI_RUD: @@ -4603,6 +4726,48 @@ xlog_recover_cancel_efi( spin_lock(&ailp->ail_lock); } +/* Release the ATTRI since we're cancelling everything. */ +STATIC void +xlog_recover_cancel_attri( + struct xfs_mount *mp, + struct xfs_ail *ailp, + struct xfs_log_item *lip) +{ + struct xfs_attri_log_item *attrip; + + attrip = container_of(lip, struct xfs_attri_log_item, attri_item); + + spin_unlock(&ailp->ail_lock); + xfs_attri_release(attrip); + spin_lock(&ailp->ail_lock); +} + + +/* Recover the ATTRI if necessary. */ +STATIC int +xlog_recover_process_attri( + struct xfs_mount *mp, + struct xfs_ail *ailp, + struct xfs_log_item *lip) +{ + struct xfs_attri_log_item *attrip; + int error; + + /* + * Skip ATTRIs that we've already processed. + */ + attrip = container_of(lip, struct xfs_attri_log_item, attri_item); + if (test_bit(XFS_ATTRI_RECOVERED, &attrip->attri_flags)) + return 0; + + spin_unlock(&ailp->ail_lock); + error = xfs_attri_recover(mp, attrip); + spin_lock(&ailp->ail_lock); + + return error; +} + + /* Recover the RUI if necessary. */ STATIC int xlog_recover_process_rui( @@ -4731,6 +4896,7 @@ static inline bool xlog_item_is_intent(struct xfs_log_item *lip) case XFS_LI_RUI: case XFS_LI_CUI: case XFS_LI_BUI: + case XFS_LI_ATTRI: return true; default: return false; @@ -4849,6 +5015,10 @@ xlog_recover_process_intents( case XFS_LI_EFI: error = xlog_recover_process_efi(log->l_mp, ailp, lip); break; + case XFS_LI_ATTRI: + error = xlog_recover_process_attri(log->l_mp, + ailp, lip); + break; case XFS_LI_RUI: error = xlog_recover_process_rui(log->l_mp, ailp, lip); break; @@ -4914,6 +5084,9 @@ xlog_recover_cancel_intents( case XFS_LI_BUI: xlog_recover_cancel_bui(log->l_mp, ailp, lip); break; + case XFS_LI_ATTRI: + xlog_recover_cancel_attri(log->l_mp, ailp, lip); + break; } lip = xfs_trans_ail_cursor_next(ailp, &cur); diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h index b6701b4..120fb0c 100644 --- a/fs/xfs/xfs_ondisk.h +++ b/fs/xfs/xfs_ondisk.h @@ -125,6 +125,8 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format, 56); XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20); XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16); + XFS_CHECK_STRUCT_SIZE(struct xfs_attri_log_format, 40); + XFS_CHECK_STRUCT_SIZE(struct xfs_attrd_log_format, 16); /* * The v5 superblock format extended several v4 header structures with diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index 64d7f17..4dd5607 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h @@ -229,7 +229,6 @@ void xfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, uint, void xfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *); bool xfs_trans_buf_is_dirty(struct xfs_buf *bp); void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint); - int xfs_trans_commit(struct xfs_trans *); int xfs_trans_roll(struct xfs_trans **); int xfs_trans_roll_inode(struct xfs_trans **, struct xfs_inode *); From patchwork Thu Sep 5 22:18:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134019 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A9E476 for ; Thu, 5 Sep 2019 22:19:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A47342070C for ; Thu, 5 Sep 2019 22:19:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="DF6vWxUT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391171AbfIEWTJ (ORCPT ); Thu, 5 Sep 2019 18:19:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:58914 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391119AbfIEWTJ (ORCPT ); Thu, 5 Sep 2019 18:19:09 -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 x85MJ8Cd049693 for ; Thu, 5 Sep 2019 22:19:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=W0Rpav6y4yCAYNHpiuMqANcngv6yK3uru8QBwssvXGc=; b=DF6vWxUTzKlbjx8Wk/Mdy6fPaORj2IjCc2PCFVZaTv0ERoMxnlj/u27TgL3HEYI5JYPE D77geW5zFr/uG5dN50J05/GlOHNRQRsptZ0Lk7eCWMz+Nuj35th0xftOVi1WDSuNgai8 skpD97aFxxvXez5/8WBinvKLjLs3VsF/AT8F04NY6WOr7zp22EmkgNwHp5sq37a67dpk oyeDvaFXq4YdKS+Ln7FelDFKCqOzzN2nrQVW6S/w+Bz7iDhQXj4toi+GiNx78Wkr0dgE ZtJ9cowxueutklZfLM/zJqqgAS/zHv57zyDTzHHxh4Ktz41HVfyPexLBaFkO9b2DfIvk UQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2uuarc81yg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:08 +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 x85MIOhf101602 for ; Thu, 5 Sep 2019 22:18:49 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2uu1b946k5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:18:49 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x85MInkU001642 for ; Thu, 5 Sep 2019 22:18:49 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:48 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 16/19] xfs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Date: Thu, 5 Sep 2019 15:18:34 -0700 Message-Id: <20190905221837.17388-17-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson 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. New helper function xfs_attr_item_init also added Signed-off-by: Allison Henderson Signed-off-by: Allison Collins --- fs/xfs/libxfs/xfs_attr.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr.h | 5 +++ 2 files changed, 90 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 7680789..f502396 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -25,6 +25,7 @@ #include "xfs_trans_space.h" #include "xfs_trace.h" #include "xfs_attr_item.h" +#include "xfs_attr.h" /* * xfs_attr.c @@ -622,6 +623,70 @@ xfs_attr_set( goto out_unlock; } +STATIC int +xfs_attr_item_init( + struct xfs_inode *dp, /* inode for attr operation */ + struct xfs_trans *tp, /* transaction for attr op */ + struct xfs_name *name, /* attr name, len and flags */ + const unsigned char *value, /* attr value */ + unsigned int valuelen, /* attr value len */ + int op_flags, /* op flag (set or remove) */ + struct xfs_attr_item **attr) /* new xfs_attr_item */ +{ + + 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_large(XFS_ATTR_ITEM_SIZEOF(name->len, valuelen), + 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 = op_flags; + 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); + + *attr = new; + return 0; +} + +/* 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; + int error = 0; + + error = xfs_attr_item_init(dp, tp, name, value, valuelen, + XFS_ATTR_OP_FLAGS_SET, &new); + if (error) + return error; + + 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. @@ -703,6 +768,26 @@ xfs_attr_remove( 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; + + int error = xfs_attr_item_init(dp, tp, name, NULL, 0, + XFS_ATTR_OP_FLAGS_REMOVE, &new); + if (error) + return error; + + 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/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 1e0c25e..0dfec5c 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -190,5 +190,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 Thu Sep 5 22:18:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4CFB81593 for ; Thu, 5 Sep 2019 22:19:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6125920828 for ; Thu, 5 Sep 2019 22:19:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="mXqjhiUh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730867AbfIEWTl (ORCPT ); Thu, 5 Sep 2019 18:19:41 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:39648 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389044AbfIEWTk (ORCPT ); Thu, 5 Sep 2019 18:19:40 -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 x85MJ8e6084677 for ; Thu, 5 Sep 2019 22:19: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=SC1bjWqAqIeFyI9VBByfj/zxyo9a8HAmTq6DZdVhheE=; b=mXqjhiUhKWY2lHq+54EdYCpGk/fcRmUXXBket7TwWrkiIh4qKjiBUO9MyxqYvhtYjjTK otcQ3RYHETocWG4/AHGXHBdePmMBqbrhtH0IdaOHtxwXPuh3BSd8p/M9mWe7kJ/smsRy DUq4+npaCLnu2itTIg2agOdrlY1sPQvhwHEqwVJKnByT9IFGRSNsaZXs4Ri4uZw8VL52 XPkvSB4NLnx7l735vmzbZ4y/liVv2RQpAfzdjHqpeMfkwnMq2W+WqgdpMIU3Y+e1rZw6 Br/a0r3uO9pMLEO4FvqTnbjrz/eE5mKtLyfExqQI34bNMP8Ljh4a9477vFjHvBBNiSL3 UA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2uuaqxr2gd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:38 +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 x85MIPPA101774 for ; Thu, 5 Sep 2019 22:19:38 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2uu1b9475x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:38 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x85MInm6011613 for ; Thu, 5 Sep 2019 22:18:49 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:49 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 17/19] xfs: Add feature bit XFS_SB_FEAT_INCOMPAT_LOG_DELATTR Date: Thu, 5 Sep 2019 15:18:35 -0700 Message-Id: <20190905221837.17388-18-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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=934 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds a new feature bit XFS_SB_FEAT_INCOMPAT_LOG_DELATTR which can be used to control turning on/off delayed attributes Signed-off-by: Allison Collins --- fs/xfs/libxfs/xfs_format.h | 11 ++++++++++- fs/xfs/libxfs/xfs_fs.h | 1 + fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_super.c | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index c968b60..8316624 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -479,7 +479,9 @@ xfs_sb_has_incompat_feature( return (sbp->sb_features_incompat & feature) != 0; } -#define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0 +#define XFS_SB_FEAT_INCOMPAT_LOG_DELATTR (1 << 0) /* Delayed Attributes */ +#define XFS_SB_FEAT_INCOMPAT_LOG_ALL \ + (XFS_SB_FEAT_INCOMPAT_LOG_DELATTR) #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL static inline bool xfs_sb_has_incompat_log_feature( @@ -546,6 +548,13 @@ static inline bool xfs_sb_version_hasreflink(struct xfs_sb *sbp) (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_REFLINK); } +static inline bool xfs_sb_version_hasdelattr(struct xfs_sb *sbp) +{ + return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && + (sbp->sb_features_log_incompat & + XFS_SB_FEAT_INCOMPAT_LOG_DELATTR)); +} + /* * end of superblock version macros */ diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 52d03a3..3ee13e8 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -249,6 +249,7 @@ typedef struct xfs_fsop_resblks { #define XFS_FSOP_GEOM_FLAGS_SPINODES (1 << 18) /* sparse inode chunks */ #define XFS_FSOP_GEOM_FLAGS_RMAPBT (1 << 19) /* reverse mapping btree */ #define XFS_FSOP_GEOM_FLAGS_REFLINK (1 << 20) /* files can share blocks */ +#define XFS_FSOP_GEOM_FLAGS_DELATTR (1 << 21) /* delayed attributes */ /* * Minimum and maximum sizes need for growth checks. diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index a08dd8f..a2f30d2 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -1132,6 +1132,8 @@ xfs_fs_geometry( geo->flags |= XFS_FSOP_GEOM_FLAGS_RMAPBT; if (xfs_sb_version_hasreflink(sbp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_REFLINK; + if (xfs_sb_version_hasdelattr(sbp)) + geo->flags |= XFS_FSOP_GEOM_FLAGS_DELATTR; if (xfs_sb_version_hassector(sbp)) geo->logsectsize = sbp->sb_logsectsize; else diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index f945023..26c4337 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1726,6 +1726,10 @@ xfs_fs_fill_super( goto out_filestream_unmount; } + if (xfs_sb_version_hasdelattr(&mp->m_sb)) + xfs_alert(mp, + "EXPERIMENTAL delayed attrs feature enabled. Use at your own risk!"); + error = xfs_mountfs(mp); if (error) goto out_filestream_unmount; From patchwork Thu Sep 5 22:18:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134027 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2332E76 for ; Thu, 5 Sep 2019 22:19:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 27D292070C for ; Thu, 5 Sep 2019 22:19:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="TfdSK76N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391135AbfIEWTK (ORCPT ); Thu, 5 Sep 2019 18:19:10 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33162 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391120AbfIEWTK (ORCPT ); Thu, 5 Sep 2019 18:19:10 -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 x85MJ7bA078093 for ; Thu, 5 Sep 2019 22:19:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=SxZoZ+Um1+fEIDu1FefnRlC0gz4cDKlPGBaqgrhh0oI=; b=TfdSK76NYmItLBH/52WiwroTZpcK8MY+TselLFaPcVJ/CU2KZtRHTFAhLVOGz83JKwEw jcyaMVreDQ3gHW2GjsTzAB7ZMvPwYqZJAhzrs5MZxnN+dHVbVvbtQd8lEB+V48v6Yj1f DEycuuOnATy1iYEtKPtomYpRjXrPFuTJ0S2URng11LJU67bG7c1MRXgYQE7u1k3jvHe4 b3gS3xMUZB6eN+13yrcbRxrvkDcTbfO3q1ni0d0gSAQEK36ENxXbeEjeO4IXxLnhzVlm IUJdaxWQFSSnBNGtSEV7istf6mM3LVoaij6kC+YuTr31IOUR7WP+FlSjKE/gkT56wqOx cA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2uuaqj02mw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:08 +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 x85MIPrQ101777 for ; Thu, 5 Sep 2019 22:19:04 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2uu1b946sk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:04 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x85MInul008743 for ; Thu, 5 Sep 2019 22:18:49 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:49 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 18/19] xfs: Enable delayed attributes Date: Thu, 5 Sep 2019 15:18:36 -0700 Message-Id: <20190905221837.17388-19-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Finally enable delayed attributes in xfs_attr_set and xfs_attr_remove. We only do this for new filesystems that have the feature bit enabled because we cant add new log entries to older filesystems Signed-off-by: Allison Collins --- fs/xfs/libxfs/xfs_attr.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index f502396..1040479 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -532,6 +532,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; @@ -590,7 +591,34 @@ xfs_attr_set( goto out_trans_cancel; xfs_trans_ijoin(args.trans, dp, 0); - error = xfs_attr_set_args(&args); + if (xfs_sb_version_hasdelattr(sbp)) { + error = xfs_has_attr(&args); + + if (error == -EEXIST) { + if (name->type & ATTR_CREATE) + goto out_trans_cancel; + else + name->type |= ATTR_REPLACE; + } + + if (error == -ENOATTR && (name->type & ATTR_REPLACE)) + goto out_trans_cancel; + + if (name->type & ATTR_REPLACE) { + name->type &= ~ATTR_REPLACE; + error = xfs_attr_remove_deferred(dp, args.trans, name); + if (error) + goto out_trans_cancel; + + name->type |= ATTR_CREATE; + } + + error = xfs_attr_set_deferred(dp, args.trans, name, value, + valuelen); + } else { + error = xfs_attr_set_args(&args); + } + if (error) goto out_trans_cancel; if (!args.trans) { @@ -697,6 +725,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; @@ -738,7 +767,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_hasdelattr(sbp)) + error = xfs_attr_remove_deferred(dp, args.trans, name); + else + error = xfs_attr_remove_args(&args); if (error) goto out; From patchwork Thu Sep 5 22:18:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11134071 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CD641599 for ; Thu, 5 Sep 2019 22:19:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 300A520828 for ; Thu, 5 Sep 2019 22:19:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="aGL4GSOi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731128AbfIEWTT (ORCPT ); Thu, 5 Sep 2019 18:19:19 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:58912 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391117AbfIEWTK (ORCPT ); Thu, 5 Sep 2019 18:19:10 -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 x85MJ8lu049698 for ; Thu, 5 Sep 2019 22:19:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=sl3ps6BkUcSMYrKGR4Tlh2VKckTXEamlU0CzT5SKv7A=; b=aGL4GSOi/gyYUTIdIN2B2KrxmZ5OMy2QMU5FYej0Ivx2tEPAHTz33mmRtnWTKjGEWhkj vcnTCrYnCSukQa8IQvJFA9ke2stPXwTI24Oad99KSK+fFRwK8ItZpKWM4MCkAPGeLf08 JbwNe1CB6vBepzumPus0TWuFaETrNTzDL33rL+i+bJTYAVL53+plAG6fCMsSWWxrzNSq /+YNwcnDV3p8U9pDY/M9kxD2Xl6e4p8Zb/d4/kLuo6cCVrXlllNO/QyaLuc66vnH6zCY br+uG0p9Kh5/ynoQMUumSb1BWDdYpw6KKxzpgzFp2HlD/H6UeQiEDICmAXJMcA81QbLi PQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2uuarc81yx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:08 +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 x85MIeUV123421 for ; Thu, 5 Sep 2019 22:19:02 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2uthq27v23-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 05 Sep 2019 22:19:02 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x85MIoDs001651 for ; Thu, 5 Sep 2019 22:18:50 GMT Received: from localhost.localdomain (/67.1.183.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 15:18:49 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v3 19/19] xfs_io: Add delayed attributes error tag Date: Thu, 5 Sep 2019 15:18:37 -0700 Message-Id: <20190905221837.17388-20-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905221837.17388-1-allison.henderson@oracle.com> References: <20190905221837.17388-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 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-1909050207 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson This patch adds an error tag that we can use to test delayed attribute recovery and replay Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Signed-off-by: Allison Collins --- fs/xfs/libxfs/xfs_errortag.h | 4 +++- fs/xfs/xfs_attr_item.c | 8 ++++++++ fs/xfs/xfs_error.c | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h index 79e6c4f..85d5850 100644 --- a/fs/xfs/libxfs/xfs_errortag.h +++ b/fs/xfs/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_ */ diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index a4abcf3..691ea6b 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -33,6 +33,8 @@ #include "libxfs/xfs_da_format.h" #include "xfs_inode.h" #include "xfs_quota.h" +#include "xfs_error.h" +#include "xfs_errortag.h" /* * This routine is called to allocate an "attr free done" log item. @@ -71,6 +73,11 @@ xfs_trans_attr( if (error) return error; + if (XFS_TEST_ERROR(false, args->dp->i_mount, XFS_ERRTAG_DELAYED_ATTR)) { + error = -EIO; + goto out; + } + switch (op_flags) { case XFS_ATTR_OP_FLAGS_SET: args->op_flags |= XFS_DA_OP_ADDNAME; @@ -85,6 +92,7 @@ xfs_trans_attr( break; } +out: /* * Mark the transaction dirty, even on error. This ensures the * transaction is aborted, which: diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 849fd44..c468a91 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -53,6 +53,7 @@ static unsigned int xfs_errortag_random_default[] = { XFS_RANDOM_FORCE_SCRUB_REPAIR, XFS_RANDOM_FORCE_SUMMARY_RECALC, XFS_RANDOM_IUNLINK_FALLBACK, + XFS_RANDOM_DELAYED_ATTR, }; struct xfs_errortag_attr { @@ -162,6 +163,7 @@ XFS_ERRORTAG_ATTR_RW(buf_lru_ref, XFS_ERRTAG_BUF_LRU_REF); XFS_ERRORTAG_ATTR_RW(force_repair, XFS_ERRTAG_FORCE_SCRUB_REPAIR); XFS_ERRORTAG_ATTR_RW(bad_summary, XFS_ERRTAG_FORCE_SUMMARY_RECALC); XFS_ERRORTAG_ATTR_RW(iunlink_fallback, XFS_ERRTAG_IUNLINK_FALLBACK); +XFS_ERRORTAG_ATTR_RW(delayed_attr, XFS_ERRTAG_DELAYED_ATTR); static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(noerror), @@ -199,6 +201,7 @@ static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(force_repair), XFS_ERRORTAG_ATTR_LIST(bad_summary), XFS_ERRORTAG_ATTR_LIST(iunlink_fallback), + XFS_ERRORTAG_ATTR_LIST(delayed_attr), NULL, };