From patchwork Tue Jan 24 09:07:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9534593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 415DC60434 for ; Tue, 24 Jan 2017 09:07:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32CE326907 for ; Tue, 24 Jan 2017 09:07:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26BEC269DA; Tue, 24 Jan 2017 09:07:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7C7826907 for ; Tue, 24 Jan 2017 09:07:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750824AbdAXJHu (ORCPT ); Tue, 24 Jan 2017 04:07:50 -0500 Received: from verein.lst.de ([213.95.11.211]:52022 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750710AbdAXJHt (ORCPT ); Tue, 24 Jan 2017 04:07:49 -0500 Received: by newverein.lst.de (Postfix, from userid 2407) id 6DCF868E10; Tue, 24 Jan 2017 10:07:47 +0100 (CET) Date: Tue, 24 Jan 2017 10:07:47 +0100 From: Christoph Hellwig To: "Darrick J. Wong" Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Subject: Re: [PATCH] xfs: reset ag_max_usable when retrying failed per-ag reservation init Message-ID: <20170124090747.GA18668@lst.de> References: <20170123211221.GB31202@birch.djwong.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170123211221.GB31202@birch.djwong.org> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Jan 23, 2017 at 01:12:21PM -0800, Darrick J. Wong wrote: > It's possible for the per-AG reservation initialization to return ENOSPC > when fdblocks says there isn't free space. This is a valid state for > the reservation tracker since subsequent extent freeing activity will > simply be captured by the reservation mechanism, but if we subsequently > retry a failed initialization, we need to undo the changes we made to > ag_max_usable prior to recreating the reservation. Hmm. I'd prefer to just not change any fields in __xfs_ag_resv_init unless it succeeds. So far untested and un-changelogged patch below, I'll kick off a test run soon: --- 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 diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c index 4773c1e..769d6e3 100644 --- a/fs/xfs/libxfs/xfs_ag_resv.c +++ b/fs/xfs/libxfs/xfs_ag_resv.c @@ -201,22 +201,27 @@ __xfs_ag_resv_init( struct xfs_mount *mp = pag->pag_mount; struct xfs_ag_resv *resv; int error; + xfs_extlen_t reserved; - resv = xfs_perag_resv(pag, type); if (used > ask) ask = used; - resv->ar_asked = ask; - resv->ar_reserved = resv->ar_orig_reserved = ask - used; - mp->m_ag_max_usable -= ask; - - trace_xfs_ag_resv_init(pag, type, ask); + reserved = ask - used; - error = xfs_mod_fdblocks(mp, -(int64_t)resv->ar_reserved, true); - if (error) + error = xfs_mod_fdblocks(mp, -(int64_t)reserved, true); + if (error) { trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno, error, _RET_IP_); + return error; + } - return error; + mp->m_ag_max_usable -= ask; + + resv = xfs_perag_resv(pag, type); + resv->ar_asked = ask; + resv->ar_reserved = resv->ar_orig_reserved = reserved; + + trace_xfs_ag_resv_init(pag, type, ask); + return 0; } /* Create a per-AG block reservation. */