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 4F379C49ED7 for ; Fri, 20 Sep 2019 13:50:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 26CAF206C2 for ; Fri, 20 Sep 2019 13:50:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727869AbfITNuj (ORCPT ); Fri, 20 Sep 2019 09:50:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45484 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727836AbfITNuj (ORCPT ); Fri, 20 Sep 2019 09:50:39 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7782320260; Fri, 20 Sep 2019 13:50:39 +0000 (UTC) Received: from bfoster (dhcp-41-2.bos.redhat.com [10.18.41.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20E5560C18; Fri, 20 Sep 2019 13:50:39 +0000 (UTC) Date: Fri, 20 Sep 2019 09:50:37 -0400 From: Brian Foster To: Allison Collins Cc: linux-xfs@vger.kernel.org Subject: Re: [PATCH v3 08/19] xfs: Factor up commit from xfs_attr_try_sf_addname Message-ID: <20190920135037.GF40150@bfoster> References: <20190905221837.17388-1-allison.henderson@oracle.com> <20190905221837.17388-9-allison.henderson@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190905221837.17388-9-allison.henderson@oracle.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 20 Sep 2019 13:50:39 +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:26PM -0700, Allison Collins wrote: > 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); > Perhaps the above check should stay along with the tx commit code..? > - 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; We've already checked that error == 0 here, so this can be simplified. Hmm.. that said, the original code looks like it commits the transaction on error != -ENOSPC, which means this slightly changes behavior when (error && error != -ENOSPC) is true. So perhaps it is the error check that should be fixed up and not the error2 logic.. Brian > + } > > /* > * It won't fit in the shortform, transform to a leaf block. > -- > 2.7.4 >