Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4805213imm; Tue, 7 Aug 2018 07:38:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdIgiWjknoftS4/CTTNjvxz9oTGqU3BVl9YCEpgACxxSRYacYvPPcK4sPt2e+KHF/0xlTFO X-Received: by 2002:a63:338e:: with SMTP id z136-v6mr18609800pgz.171.1533652732012; Tue, 07 Aug 2018 07:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533652731; cv=none; d=google.com; s=arc-20160816; b=bq2s9TnJICN/TqukJBgd8Mr6vtS0f6+zDy5S9r2uPg7lB1z/XB3YCRYgXV+HytsaTb zSlMaQQCO8kZjQWKgOGNBKAaotxxe9o9DqmXSyv2OFpsqg39gsfoZBjLf08K7T4XRMk6 IiGAIWTUt3HeN48kDoEb71c2kgU8FNttmyr9x+6J6e0OMOC50t/t7Q0b75rdmC8Fa8Yg ra89GP5i0AilAK0jGdhya8r5h2wN7Lbv2HaNhr3vqLrRlkNYRp46UEm9TQ5VvOf6VRmt CrqTZF9mARoiwn22OvEhiVfojgPneRKe803vq1wsUcMvDjSeLM+OifeGrEHGb+JHTPut 4zgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=VdcMAutzITtDJlK6iEXfRvYZQpKGTeRZNuOY4I1IkXU=; b=ncOgdzoGhIMDdkk0C4pcZPRL4NuKdxASxUKJDTDEQWOcPqrCHvw1GICP9OuHKLRJDD feSIp+lZJ8rP4rkcbdt+DxFkywKspfVYGvCSs8rYyi0YeqbFUgO9X01lodtjMjcEhl5+ Zi50O1/m3ma3je+z89UjxaElRAgV6CmhzyqXPdZNa2cSAmK3Q1/vg26rVqh05GHN679E 2z9dSIA7j1BMInX8LRLn2/gsJvnSkKwEcw1r04PiWisofhZVnZjmsl75aF61gEI06k32 JXfjftO/gF06KEd0Ke9++VDHhsf6qa3EBILQDFjMtTkn/eZEuAdo3I1T4ycpXA1Xp6Jx h1oQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x127-v6si1435597pgb.618.2018.08.07.07.38.37; Tue, 07 Aug 2018 07:38:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389647AbeHGQwB (ORCPT + 99 others); Tue, 7 Aug 2018 12:52:01 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43224 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389073AbeHGQwB (ORCPT ); Tue, 7 Aug 2018 12:52:01 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E6EF187A84; Tue, 7 Aug 2018 14:37:22 +0000 (UTC) Received: from bfoster (dhcp-41-2.bos.redhat.com [10.18.41.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8F102026D66; Tue, 7 Aug 2018 14:37:22 +0000 (UTC) Date: Tue, 7 Aug 2018 10:37:21 -0400 From: Brian Foster To: Colin Ian King Cc: darrick.wong@oracle.com, linux-xfs@vger.kernel.org, "linux-kernel@vger.kernel.org" Subject: Re: xfs: cancel dfops on xfs_defer_finish() error Message-ID: <20180807143720.GA55416@bfoster> References: <18f3296d-e5d4-4d76-51f8-a40d0ceaa20e@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18f3296d-e5d4-4d76-51f8-a40d0ceaa20e@canonical.com> User-Agent: Mutt/1.10.0 (2018-05-17) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 07 Aug 2018 14:37:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 07 Aug 2018 14:37:22 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'bfoster@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 07, 2018 at 03:14:07PM +0100, Colin Ian King wrote: > Hi, > > Recent commit 82ff27bc52a88cb5cc400bfa64e210d3ec8dfebd ("xfs: automatic > dfops buffer relogging") removed the assignment of variable error: > > - error = xfs_defer_bjoin(tp->t_dfops, bp); > if (error) { > xfs_trans_bhold_release(tp, bp); > xfs_trans_brelse(tp, bp); > Hmm, I _think_ we can just drop these error checks now that this pre-finish error state is non-existent, something like the appended diff (with additional cleanups). E.g., if the buffer is held in the transaction then the bjoin is implicit. If the finish fails, then the state is essentially unchanged by the relogging patch. That said, the error handling is a bit tricky here. Darrick, I think you reworked this recently.. thoughts? Brian --- 8< --- diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 70a76ac41f01..2106c4142ecd 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -311,7 +311,7 @@ xfs_dquot_disk_alloc( XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA, XFS_QM_DQALLOC_SPACE_RES(mp), &map, &nmaps); if (error) - goto error0; + return error; ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB); ASSERT(nmaps == 1); ASSERT((map.br_startblock != DELAYSTARTBLOCK) && @@ -326,8 +326,8 @@ xfs_dquot_disk_alloc( bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, dqp->q_blkno, mp->m_quotainfo->qi_dqchunklen, 0); if (!bp) { - error = -ENOMEM; - goto error1; + xfs_defer_cancel(tp); + return -ENOMEM; } bp->b_ops = &xfs_dquot_buf_ops; @@ -349,10 +349,8 @@ xfs_dquot_disk_alloc( * the buffer locked across the _defer_finish call. We can now do * this correctly with xfs_defer_bjoin. * - * Above, we allocated a disk block for the dquot information and - * used get_buf to initialize the dquot. If the _defer_bjoin fails, - * the buffer is still locked to *tpp, so we must _bhold_release and - * then _trans_brelse the buffer. If the _defer_finish fails, the old + * Above, we allocated a disk block for the dquot information and used + * get_buf to initialize the dquot. If the _defer_finish fails, the old * transaction is gone but the new buffer is not joined or held to any * transaction, so we must _buf_relse it. * @@ -362,24 +360,14 @@ xfs_dquot_disk_alloc( * manually or by committing the transaction. */ xfs_trans_bhold(tp, bp); - if (error) { - xfs_trans_bhold_release(tp, bp); - xfs_trans_brelse(tp, bp); - goto error1; - } error = xfs_defer_finish(tpp); tp = *tpp; if (error) { xfs_buf_relse(bp); - goto error0; + return error; } *bpp = bp; return 0; - -error1: - xfs_defer_cancel(tp); -error0: - return error; } /*