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.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 6849EC49ED7 for ; Fri, 20 Sep 2019 13:50:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4641E208C3 for ; Fri, 20 Sep 2019 13:50:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387484AbfITNuC (ORCPT ); Fri, 20 Sep 2019 09:50:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60248 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387404AbfITNuC (ORCPT ); Fri, 20 Sep 2019 09:50:02 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0544718C890D; Fri, 20 Sep 2019 13:50:02 +0000 (UTC) Received: from bfoster (dhcp-41-2.bos.redhat.com [10.18.41.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9EBE15D6B0; Fri, 20 Sep 2019 13:50:01 +0000 (UTC) Date: Fri, 20 Sep 2019 09:49:59 -0400 From: Brian Foster To: Allison Collins Cc: linux-xfs@vger.kernel.org Subject: Re: [PATCH v3 07/19] xfs: Factor out xfs_attr_leaf_addname helper Message-ID: <20190920134959.GE40150@bfoster> References: <20190905221837.17388-1-allison.henderson@oracle.com> <20190905221837.17388-8-allison.henderson@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190905221837.17388-8-allison.henderson@oracle.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Fri, 20 Sep 2019 13:50:02 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org On Thu, Sep 05, 2019 at 03:18:25PM -0700, Allison Collins wrote: > 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; It looks like we could pick either retval or error and use it consistently throughout the new function. > > trace_xfs_attr_leaf_addname(args); > I also wonder if this tracepoint should remain in the caller. > @@ -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; Hmm.. I find this bit of factoring a little strange. We do part of the -ENOSPC handling (leaf to node) in one place and another part (xfs_defer_finish()) in the caller. I'm assuming we intentionally don't finish dfops in the new helper because the delayed attr bits shouldn't do that, but I'm wondering whether the helper should just return -ENOSPC and the caller should be responsible for whatever needs to happen based on that in the associated context. Hm? Brian > -- > 2.7.4 >