From patchwork Fri Apr 12 22:50: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: 10899203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 459151874 for ; Fri, 12 Apr 2019 22:52:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23C9A28E0B for ; Fri, 12 Apr 2019 22:52:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 180B528F03; Fri, 12 Apr 2019 22:52:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91FAB28EC2 for ; Fri, 12 Apr 2019 22:52:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726850AbfDLWwt (ORCPT ); Fri, 12 Apr 2019 18:52:49 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43610 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbfDLWwt (ORCPT ); Fri, 12 Apr 2019 18:52:49 -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 x3CMeNAg010798 for ; Fri, 12 Apr 2019 22:52:47 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-2018-07-02; bh=+pBZL9gyDJX9JBEUxwzCx4eFOousgETakTc3eOwi8jo=; b=5h3jaN32X+lOe4vZtCHte6nDSzVhNJbmZOGzw2Js5IGgBn2HXOn2MTZ1yMuHu16ityPG Hqu1tc0uGzUD63wanFdHt8idv+87QtOGZ1iNISVSMAx7T7Ntc3kss4W4NHMRLKN9KLEC +6H0V5VDN+23OmYd1FJKRWO7lUJ/r0CUQHWflFA+szBs5CCCG08GvD6ji/q7DrOHGKi8 favU+0eoS76gWRhqYujubs4BkedHrrUmkhPKR2qzhOqawhq6VbwdB+KgoFZmP6lUZcsL FdKNDa5In4wm/DLttcpxpbxXwFyPoj+JCJVgDvz4wM8/vZwIQ8MIAANnyZ5KD0plU8SV ug== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2rpkhtgtwp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 12 Apr 2019 22:52:47 +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 x3CMq6xZ172959 for ; Fri, 12 Apr 2019 22:52:46 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2rpytdhugu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 12 Apr 2019 22:52:46 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x3CMqkT8030865 for ; Fri, 12 Apr 2019 22:52:46 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Apr 2019 15:52:46 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH 5/9] xfs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Date: Fri, 12 Apr 2019 15:50:32 -0700 Message-Id: <20190412225036.22939-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190412225036.22939-1-allison.henderson@oracle.com> References: <20190412225036.22939-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9225 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-1810050000 definitions=main-1904120150 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9225 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-1810050000 definitions=main-1904120150 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These routines set up set and start a new deferred attribute operation. These functions are meant to be called by other code needing to initiate a deferred attribute operation. We will use these routines later in the parent pointer patches. Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr.h | 7 +++++ 2 files changed, 87 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index fadd485..c3477fa7 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -30,6 +30,7 @@ #include "xfs_trans_space.h" #include "xfs_trace.h" #include "xfs_attr_item.h" +#include "xfs_attr.h" /* * xfs_attr.c @@ -429,6 +430,52 @@ xfs_attr_set( goto out_unlock; } +/* Sets an attribute for an inode as a deferred operation */ +int +xfs_attr_set_deferred( + struct xfs_inode *dp, + struct xfs_trans *tp, + const unsigned char *name, + unsigned int namelen, + const unsigned char *value, + unsigned int valuelen, + int flags) +{ + + struct xfs_attr_item *new; + char *name_value; + + /* + * All set operations must have a name + * but not necessarily a value. + * Generic 062 + */ + if (!namelen) { + ASSERT(0); + return -EFSCORRUPTED; + } + + new = kmem_alloc(XFS_ATTR_ITEM_SIZEOF(namelen, valuelen), + KM_SLEEP|KM_NOFS); + name_value = ((char *)new) + sizeof(struct xfs_attr_item); + memset(new, 0, XFS_ATTR_ITEM_SIZEOF(namelen, valuelen)); + new->xattri_ip = dp; + new->xattri_op_flags = XFS_ATTR_OP_FLAGS_SET; + new->xattri_name_len = namelen; + new->xattri_value_len = valuelen; + new->xattri_flags = flags; + memcpy(&name_value[0], name, namelen); + new->xattri_name = name_value; + new->xattri_value = name_value + namelen; + + if (valuelen > 0) + memcpy(&name_value[namelen], value, valuelen); + + xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + /* * Generic handler routine to remove a name from an attribute list. * Transitions attribute list from Btree to shortform as necessary. @@ -513,6 +560,39 @@ 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, + const unsigned char *name, + unsigned int namelen, + int flags) +{ + + struct xfs_attr_item *new; + char *name_value; + + if (!namelen) { + ASSERT(0); + return -EFSCORRUPTED; + } + + new = kmem_alloc(XFS_ATTR_ITEM_SIZEOF(namelen, 0), KM_SLEEP|KM_NOFS); + name_value = ((char *)new) + sizeof(struct xfs_attr_item); + memset(new, 0, XFS_ATTR_ITEM_SIZEOF(namelen, 0)); + new->xattri_ip = dp; + new->xattri_op_flags = XFS_ATTR_OP_FLAGS_REMOVE; + new->xattri_name_len = namelen; + new->xattri_value_len = 0; + new->xattri_flags = flags; + memcpy(name_value, name, namelen); + + 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 92d9a15..83b3621 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -175,5 +175,12 @@ bool xfs_attr_namecheck(const void *name, size_t length); int xfs_attr_args_init(struct xfs_da_args *args, struct xfs_inode *dp, const unsigned char *name, size_t namelen, int flags); 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, + const unsigned char *name, unsigned int name_len, + const unsigned char *value, unsigned int valuelen, + int flags); +int xfs_attr_remove_deferred(struct xfs_inode *dp, struct xfs_trans *tp, + const unsigned char *name, unsigned int namelen, + int flags); #endif /* __XFS_ATTR_H__ */