Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4933284imm; Tue, 7 Aug 2018 09:41:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeUdwPd+2C201hYQ33MbLB9LeVM/D+JCd0lRoYXMYfi+6fkrI0DXCgW9CGog/q4cm+NeVzy X-Received: by 2002:a63:df04:: with SMTP id u4-v6mr19291382pgg.434.1533660081099; Tue, 07 Aug 2018 09:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533660081; cv=none; d=google.com; s=arc-20160816; b=hxZ5HRXOfitGR2RBAF6YVsaT7weI8w6AWfdcHHufcC8fW/OXYJdcfX7MQlZTmlioG2 hOTj/+Mvt+6MV5A2plPNdDk+Fipksne81UObidc1QJH5bdMSvA7i7VLRb4dzMH4YwyuC zsi88u0Ypw2KEiue7Det8S6Ga9dF/l9s1sSoAWX4f1U7oZhhgF8Gb4XkHrfWQ4mbJz8i 6pW+puxPhu2QyxmnsmDxCneQaRJrdCdymr9nCfWjuPTKXEzH5M1P+/IUPJA7tvH4cP7u owSX3VgUJNSDVhl+x82s/+60irviHqbojUSKvQHYAP7igi45XODHY9y8blwFPD77Xp/p FxnA== 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=899MiiX+N0oAPZ1qUxZDucDlgivRSne0eS38YTu43cU=; b=K5UdwIgQW1D1hZ3h9LEuS1UBHT2Q3/SwSNW3wOAr+Oz9D5UZasVG8e6sC5DQeR42n8 lpwDRvoNMPxcWT0quoXSZVg7GA3Tha8gxSiUkv+BSMvX5cGI2uxnjYSCkeW5zQN0Rttw wglipYC7dr0UrMoAjMBdFo+6SU+ZEzRfFqKiVgdprv3vvkz0Auk1iV8VBeTa6POT6agq B9tHFqCok/W2XqQZrv8cR5jkMvifdVErx3nN4IieMqFFnp4jI/5Pl3du5CBQxW5C1tpX IK4yzNPq61HJx9mR+SmV+DNzLTkcZ6T+FM0yl9bl05GxgIwxnse9CAAZ6N9UaFryzpM/ xJjg== 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 w14-v6si1918029pgh.14.2018.08.07.09.41.05; Tue, 07 Aug 2018 09:41:21 -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 S2389885AbeHGRd1 (ORCPT + 99 others); Tue, 7 Aug 2018 13:33:27 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50600 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727429AbeHGRd1 (ORCPT ); Tue, 7 Aug 2018 13:33:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE1B640241C0; Tue, 7 Aug 2018 15:18:37 +0000 (UTC) Received: from bfoster (dhcp-41-2.bos.redhat.com [10.18.41.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 96A142166BA2; Tue, 7 Aug 2018 15:18:37 +0000 (UTC) Date: Tue, 7 Aug 2018 11:18:36 -0400 From: Brian Foster To: "Darrick J. Wong" Cc: Colin Ian King , linux-xfs@vger.kernel.org, "linux-kernel@vger.kernel.org" Subject: Re: xfs: cancel dfops on xfs_defer_finish() error Message-ID: <20180807151836.GB55416@bfoster> References: <18f3296d-e5d4-4d76-51f8-a40d0ceaa20e@canonical.com> <20180807143720.GA55416@bfoster> <20180807151029.GA30972@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180807151029.GA30972@magnolia> User-Agent: Mutt/1.10.0 (2018-05-17) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 07 Aug 2018 15:18:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 07 Aug 2018 15:18:37 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 08:10:29AM -0700, Darrick J. Wong wrote: > On Tue, Aug 07, 2018 at 10:37:21AM -0400, Brian Foster wrote: > > 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; > > The only caller of xfs_dquot_disk_alloc checks the return value and > xfs_trans_cancels the transaction, which should take care of calling > xfs_defer_cancel, right? > Yeah. IIRC I originally left the defer_cancel() alone in this function just to be consistent, since it calls xfs_defer_finish() as well on the caller's transaction. Technically I don't think it matters either way, so I don't have much preference on if it stays or goes (assuming the other changes are correct)... Brian > --D > > > } > > 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; > > } > > > > /* > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html