From patchwork Fri Aug 9 21:37:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 11087641 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 BF0FF13AC for ; Fri, 9 Aug 2019 21:37:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD1D4204BF for ; Fri, 9 Aug 2019 21:37:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A169B205F7; Fri, 9 Aug 2019 21:37:46 +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 2816D204BF for ; Fri, 9 Aug 2019 21:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728190AbfHIVhp (ORCPT ); Fri, 9 Aug 2019 17:37:45 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:58646 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728118AbfHIVhp (ORCPT ); Fri, 9 Aug 2019 17:37:45 -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 x79LYbFH084554 for ; Fri, 9 Aug 2019 21:37:44 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=qohNhy9VS8BMEcHxmcN+y7RzTU1Mrdyg0NWwBKZAjY4=; b=e5crRak6EBReZwDcHSgUYbZrxXyv6a/gdKaiqjIuyJ2T8oh6A8tu4+noAf93C1imUTbB bMDTmKBWaq9KKPx9sWkVXP/GDSXWkcJIzsmAM8A1H0BNAzZ0PO3z7TImeE4onoCQnykZ aRY2zJ0B2ic44WAJi6PEqZJVZLDIuYI5iE0vt43xEG3Ggh1qZa9h1Oqny47tP48bXkWx hNAHlWQrHOSaThR+ZC8SHIKdieBqFLc0Jkz4pm9dSuGpjnqFj8R7mg5NVdl60rH9ctKW 76nFfsp4QebmUPtPCAT57oOargjnGfYMyAHiGp0rZ4C2XSDxx06Zspm4Bcy/qq3VwOv4 1Q== 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=qohNhy9VS8BMEcHxmcN+y7RzTU1Mrdyg0NWwBKZAjY4=; b=zwRNbCyUTu3ByAM2NlnXpIJsEMT83BwQ8/A40fZbdtwN7/hflRTOqHdpbHHkscfZo5ze XfOU4twkQaQe4dPTxIp/88aieYva73LAKL36l5s4OYQAEcRsQlgy3/WtH/3JEhUcRZwq P//xpeQlLeliRQYrCKKm99YxNusTQj7pAwK1gOPKc5KtsUlNA8fbkTEhcw0AqVHDE1Bs 8Znq8sTXIKLgpgCUFDBtVjlRtIJWRzhirB1ID/onXRUhY+EwKbHEkSpMtc8GXSHtUgQM KpAc1H7kyIEWYe8x6Lu/Faee081UflWnsvNmOpeR8XKsH5VETHKL/QwnnA23LTzWCWH7 9Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2u8hgpa7wk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:37:44 +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 x79LNbqv067920 for ; Fri, 9 Aug 2019 21:37:44 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2u90t813wx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 09 Aug 2019 21:37:44 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x79Lbhor001873 for ; Fri, 9 Aug 2019 21:37:43 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 14:37:34 -0700 From: Allison Collins To: linux-xfs@vger.kernel.org Subject: [PATCH v2 04/18] xfs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Date: Fri, 9 Aug 2019 14:37:12 -0700 Message-Id: <20190809213726.32336-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190809213726.32336-1-allison.henderson@oracle.com> References: <20190809213726.32336-1-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090208 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Allison Henderson Signed-off-by: Allison Collins --- fs/xfs/libxfs/xfs_attr.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr.h | 5 ++++ 2 files changed, 79 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 1f76618..a2fba0c 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 @@ -399,6 +400,48 @@ 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, + struct xfs_name *name, + const unsigned char *value, + unsigned int valuelen) +{ + + struct xfs_attr_item *new; + char *name_value; + + /* + * All set operations must have a name but not necessarily a value. + */ + if (!name->len) { + ASSERT(0); + return -EINVAL; + } + + new = kmem_alloc_large(XFS_ATTR_ITEM_SIZEOF(name->len, valuelen), + KM_SLEEP|KM_NOFS); + name_value = ((char *)new) + sizeof(struct xfs_attr_item); + memset(new, 0, XFS_ATTR_ITEM_SIZEOF(name->len, valuelen)); + new->xattri_ip = dp; + new->xattri_op_flags = XFS_ATTR_OP_FLAGS_SET; + new->xattri_name_len = name->len; + new->xattri_value_len = valuelen; + new->xattri_flags = name->type; + memcpy(&name_value[0], name->name, name->len); + new->xattri_name = name_value; + new->xattri_value = name_value + name->len; + + if (valuelen > 0) + memcpy(&name_value[name->len], value, valuelen); + + xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + /* * Generic handler routine to remove a name from an attribute list. * Transitions attribute list from Btree to shortform as necessary. @@ -480,6 +523,37 @@ 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; + char *name_value; + + if (!name->len) { + ASSERT(0); + return -EINVAL; + } + + new = kmem_alloc(XFS_ATTR_ITEM_SIZEOF(name->len, 0), KM_SLEEP|KM_NOFS); + name_value = ((char *)new) + sizeof(struct xfs_attr_item); + memset(new, 0, XFS_ATTR_ITEM_SIZEOF(name->len, 0)); + new->xattri_ip = dp; + new->xattri_op_flags = XFS_ATTR_OP_FLAGS_REMOVE; + new->xattri_name_len = name->len; + new->xattri_value_len = 0; + new->xattri_flags = name->type; + memcpy(name_value, name->name, name->len); + + xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); + + return 0; +} + /*======================================================================== * External routines when attribute list is inside the inode *========================================================================*/ diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 9132d4f..0bade83 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -177,5 +177,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__ */