From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E9C7C432BE for ; Wed, 1 Sep 2021 03:48:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7423460FF2 for ; Wed, 1 Sep 2021 03:48:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241833AbhIADs7 (ORCPT ); Tue, 31 Aug 2021 23:48:59 -0400 Received: from mail107.syd.optusnet.com.au ([211.29.132.53]:42745 "EHLO mail107.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241754AbhIADs7 (ORCPT ); Tue, 31 Aug 2021 23:48:59 -0400 Received: from dread.disaster.area (pa49-195-182-146.pa.nsw.optusnet.com.au [49.195.182.146]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id 3F0211145508; Wed, 1 Sep 2021 13:48:02 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1mLHEA-007Jde-OA; Wed, 01 Sep 2021 13:47:54 +1000 Date: Wed, 1 Sep 2021 13:47:54 +1000 From: Dave Chinner To: Allison Henderson Cc: linux-xfs@vger.kernel.org Subject: Re: [PATCH v24 06/11] xfs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Message-ID: <20210901034754.GW3657114@dread.disaster.area> References: <20210824224434.968720-1-allison.henderson@oracle.com> <20210824224434.968720-7-allison.henderson@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210824224434.968720-7-allison.henderson@oracle.com> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=Tu+Yewfh c=1 sm=1 tr=0 a=QpfB3wCSrn/dqEBSktpwZQ==:117 a=QpfB3wCSrn/dqEBSktpwZQ==:17 a=kj9zAlcOel0A:10 a=7QKq2e-ADPsA:10 a=yPCof4ZbAAAA:8 a=VwQbUJbxAAAA:8 a=7-415B0cAAAA:8 a=9dqNml8eK2QwCgJdNbgA:9 a=CjuIK1q_8ugA:10 a=AjGcO6oz07-iQ99wixmX:22 a=biEYGPWJfzWAr4FL6Ov7:22 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org On Tue, Aug 24, 2021 at 03:44:29PM -0700, Allison Henderson wrote: > From: Allison Collins > > These routines set up and queue a new deferred attribute operations. > These functions are meant to be called by any routine needing to > initiate a deferred attribute operation as opposed to the existing > inline operations. New helper function xfs_attr_item_init also added. > > Finally enable delayed attributes in xfs_attr_set and xfs_attr_remove. > > Signed-off-by: Allison Henderson > Reviewed-by: Darrick J. Wong ..... > > +STATIC int > +xfs_attr_item_init( > + struct xfs_da_args *args, > + unsigned int op_flags, /* op flag (set or remove) */ > + struct xfs_attr_item **attr) /* new xfs_attr_item */ > +{ > + > + struct xfs_attr_item *new; > + > + new = kmem_zalloc(sizeof(struct xfs_attr_item), KM_NOFS); In transaction context here so we don't need KM_NOFS. > + new->xattri_op_flags = op_flags; > + new->xattri_dac.da_args = args; > + > + *attr = new; > + return 0; > +} Why doesn't this just return the object or NULL on allocation failure? What other error could it ever return? > + > +/* Sets an attribute for an inode as a deferred operation */ > +int > +xfs_attr_set_deferred( > + struct xfs_da_args *args) > +{ > + struct xfs_attr_item *new; > + int error = 0; > + > + error = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_SET, &new); > + if (error) > + return error; i.e. attri = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_SET); if (!attri) return -ENOMEM; > + > + xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); > + > + return 0; > +} > + > +/* Removes an attribute for an inode as a deferred operation */ > +int > +xfs_attr_remove_deferred( > + struct xfs_da_args *args) > +{ > + > + struct xfs_attr_item *new; > + int error; > + > + error = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_REMOVE, &new); > + if (error) > + return error; > + > + xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); > + > + return 0; > +} We really should not use "new" as a variable name. As a general rule, the common pattern set by this file is that xfs_attri_item objects in a function are named "attri". Just because it's newly allocated doesn't mean we should use a different convention for naming xfs_attri_item objects... Cheers, Dave. -- Dave Chinner david@fromorbit.com