From patchwork Mon Sep 30 16:41:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13816701 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8071A194C85 for ; Mon, 30 Sep 2024 16:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714545; cv=none; b=FvkS6Ve6CmZS51kGlf7Zunofd1yQZJ6rWbQEzV5fklR79LaLxY0oe3TSxe7G69Zd1Yz+JgN3NZHZ0P2bqsXWDLxihw4XEKXRN44Um9zL4o8kdS0nW9n/gT0R0pmzLb77F2rP/eW9f7i6TeaNei556fOZhgfyUsgOvZIc3xrwjQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714545; c=relaxed/simple; bh=rpZIKuptbPbbcowedy08ALtnERaXzGYH99RhF5zcQso=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=plxcbzNkN6LIoYbxtGKcAc2TSeuTwTmh2zuVFtqZdEGJrXFZAqj4D4dTDjDABXv9EUrB8gGjUwq6ToDAVPsm/AENF01iMli1ALBBpmH8pMspZTLH7DOOQHI9n4VkkD6ECY2CCqzkjGLDDIP7D1wkmjokwKLX9H4DVcLMQ4SvGe0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=h7qahJP9; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="h7qahJP9" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=bX9aPPVwrnZAtXVm82FMDCS0ntEVldUXkB5XF4usqMI=; b=h7qahJP9hNxELkWwD9r1GcvHNk UvNA/KRpePbN6q8mHyT9b4+ecdW0YMq2oxHMT2fVC1g/aKROUjlA0TRTQRSSi7z+TiKe1BZn5vznD R47gYr03OsOfaQcbflrxpYcfhJ6fk875XLNn1+kk+MeE+ffOi2Z6RqsQIO1cpqh/aQG4qS7xU2Ln2 ApLymRfe9p/SEZ3tjJcxKnx3T3XLLuKfhfF40cOTwnqXncirLq83Ow9CRXG8wh0aHdtBaSOfL2oKb kYGZxGZqRc9K4QATOww9SOc2E/OuL2E7Di1mcS/FB0kmLpLgEb3/dfqKlCKCzo1InQHuNeqPwuh0y BAFfEWUw==; Received: from 2a02-8389-2341-5b80-2b91-e1b6-c99c-08ea.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:2b91:e1b6:c99c:8ea] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1svJTa-00000000GTo-31by; Mon, 30 Sep 2024 16:42:23 +0000 From: Christoph Hellwig To: Chandan Babu R Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 1/7] xfs: pass the exact range to initialize to xfs_initialize_perag Date: Mon, 30 Sep 2024 18:41:42 +0200 Message-ID: <20240930164211.2357358-2-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930164211.2357358-1-hch@lst.de> References: <20240930164211.2357358-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Currently only the new agcount is passed to xfs_initialize_perag, which requires lookups of existing AGs to skip them and complicates error handling. Also pass the previous agcount so that the range that xfs_initialize_perag operates on is exactly defined. That way the extra lookups can be avoided, and error handling can clean up the exact range from the old count to the last added perag structure. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_ag.c | 29 ++++++++--------------------- fs/xfs/libxfs/xfs_ag.h | 5 +++-- fs/xfs/xfs_fsops.c | 18 ++++++++---------- fs/xfs/xfs_log_recover.c | 5 +++-- fs/xfs/xfs_mount.c | 4 ++-- 5 files changed, 24 insertions(+), 37 deletions(-) diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c index 5f0494702e0b55..652376aa52e990 100644 --- a/fs/xfs/libxfs/xfs_ag.c +++ b/fs/xfs/libxfs/xfs_ag.c @@ -296,27 +296,19 @@ xfs_free_unused_perag_range( int xfs_initialize_perag( struct xfs_mount *mp, - xfs_agnumber_t agcount, + xfs_agnumber_t old_agcount, + xfs_agnumber_t new_agcount, xfs_rfsblock_t dblocks, xfs_agnumber_t *maxagi) { struct xfs_perag *pag; xfs_agnumber_t index; - xfs_agnumber_t first_initialised = NULLAGNUMBER; int error; - /* - * Walk the current per-ag tree so we don't try to initialise AGs - * that already exist (growfs case). Allocate and insert all the - * AGs we don't find ready for initialisation. - */ - for (index = 0; index < agcount; index++) { - pag = xfs_perag_get(mp, index); - if (pag) { - xfs_perag_put(pag); - continue; - } + if (old_agcount >= new_agcount) + return 0; + for (index = old_agcount; index < new_agcount; index++) { pag = kzalloc(sizeof(*pag), GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!pag) { error = -ENOMEM; @@ -353,21 +345,17 @@ xfs_initialize_perag( /* Active ref owned by mount indicates AG is online. */ atomic_set(&pag->pag_active_ref, 1); - /* first new pag is fully initialized */ - if (first_initialised == NULLAGNUMBER) - first_initialised = index; - /* * Pre-calculated geometry */ - pag->block_count = __xfs_ag_block_count(mp, index, agcount, + pag->block_count = __xfs_ag_block_count(mp, index, new_agcount, dblocks); pag->min_block = XFS_AGFL_BLOCK(mp); __xfs_agino_range(mp, pag->block_count, &pag->agino_min, &pag->agino_max); } - index = xfs_set_inode_alloc(mp, agcount); + index = xfs_set_inode_alloc(mp, new_agcount); if (maxagi) *maxagi = index; @@ -381,8 +369,7 @@ xfs_initialize_perag( out_free_pag: kfree(pag); out_unwind_new_pags: - /* unwind any prior newly initialized pags */ - xfs_free_unused_perag_range(mp, first_initialised, agcount); + xfs_free_unused_perag_range(mp, old_agcount, index); return error; } diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h index d9cccd093b60e0..69fc31e7b84728 100644 --- a/fs/xfs/libxfs/xfs_ag.h +++ b/fs/xfs/libxfs/xfs_ag.h @@ -146,8 +146,9 @@ __XFS_AG_OPSTATE(agfl_needs_reset, AGFL_NEEDS_RESET) void xfs_free_unused_perag_range(struct xfs_mount *mp, xfs_agnumber_t agstart, xfs_agnumber_t agend); -int xfs_initialize_perag(struct xfs_mount *mp, xfs_agnumber_t agcount, - xfs_rfsblock_t dcount, xfs_agnumber_t *maxagi); +int xfs_initialize_perag(struct xfs_mount *mp, xfs_agnumber_t old_agcount, + xfs_agnumber_t agcount, xfs_rfsblock_t dcount, + xfs_agnumber_t *maxagi); int xfs_initialize_perag_data(struct xfs_mount *mp, xfs_agnumber_t agno); void xfs_free_perag(struct xfs_mount *mp); diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 3643cc843f6271..de2bf0594cb474 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -87,6 +87,7 @@ xfs_growfs_data_private( struct xfs_mount *mp, /* mount point for filesystem */ struct xfs_growfs_data *in) /* growfs data input struct */ { + xfs_agnumber_t oagcount = mp->m_sb.sb_agcount; struct xfs_buf *bp; int error; xfs_agnumber_t nagcount; @@ -94,7 +95,6 @@ xfs_growfs_data_private( xfs_rfsblock_t nb, nb_div, nb_mod; int64_t delta; bool lastag_extended = false; - xfs_agnumber_t oagcount; struct xfs_trans *tp; struct aghdr_init_data id = {}; struct xfs_perag *last_pag; @@ -138,16 +138,14 @@ xfs_growfs_data_private( if (delta == 0) return 0; - oagcount = mp->m_sb.sb_agcount; - /* allocate the new per-ag structures */ - if (nagcount > oagcount) { - error = xfs_initialize_perag(mp, nagcount, nb, &nagimax); - if (error) - return error; - } else if (nagcount < oagcount) { - /* TODO: shrinking the entire AGs hasn't yet completed */ + /* TODO: shrinking the entire AGs hasn't yet completed */ + if (nagcount < oagcount) return -EINVAL; - } + + /* allocate the new per-ag structures */ + error = xfs_initialize_perag(mp, oagcount, nagcount, nb, &nagimax); + if (error) + return error; if (delta > 0) error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata, diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index ec766b4bc8537b..6a165ca55da1a8 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -3346,6 +3346,7 @@ xlog_do_recover( struct xfs_mount *mp = log->l_mp; struct xfs_buf *bp = mp->m_sb_bp; struct xfs_sb *sbp = &mp->m_sb; + xfs_agnumber_t old_agcount = sbp->sb_agcount; int error; trace_xfs_log_recover(log, head_blk, tail_blk); @@ -3393,8 +3394,8 @@ xlog_do_recover( /* re-initialise in-core superblock and geometry structures */ mp->m_features |= xfs_sb_version_to_features(sbp); xfs_reinit_percpu_counters(mp); - error = xfs_initialize_perag(mp, sbp->sb_agcount, sbp->sb_dblocks, - &mp->m_maxagi); + error = xfs_initialize_perag(mp, old_agcount, sbp->sb_agcount, + sbp->sb_dblocks, &mp->m_maxagi); if (error) { xfs_warn(mp, "Failed post-recovery per-ag init: %d", error); return error; diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 1fdd79c5bfa04e..6fa7239a4a01b6 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -810,8 +810,8 @@ xfs_mountfs( /* * Allocate and initialize the per-ag data. */ - error = xfs_initialize_perag(mp, sbp->sb_agcount, mp->m_sb.sb_dblocks, - &mp->m_maxagi); + error = xfs_initialize_perag(mp, 0, sbp->sb_agcount, + mp->m_sb.sb_dblocks, &mp->m_maxagi); if (error) { xfs_warn(mp, "Failed per-ag init: %d", error); goto out_free_dir; From patchwork Mon Sep 30 16:41:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13816702 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 299C9193086 for ; Mon, 30 Sep 2024 16:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714548; cv=none; b=Fzv3OwR6OURGYGSM4a3HQpFOq4eBQTYMS9MNJwKccUPfPhkX1ONEgaB8J1mesD9TQUaftnd8xfF9pdcyubSMlCDLeaM/2+fSjkCw1EhEC6oYQ5HdE2wX92fxgDEHdjfUHGjIQte69Mkz+vpKB257dIbj1mVHuqYueZzBxdE7u/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714548; c=relaxed/simple; bh=xUqPU2P2vG8w0tUA703FDPriLhtsd5VI9Hur5go7cr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lSGRtTeR7FybzlaB/9V2DTMx+zUjXLWTSa40XlImhqKJ8nqAJ/Tfg7CHmuH0L/u0W9tc4s09seP97KnF8JkREIE9lw0ZRZdrBK2sh5MzH+gGyHJEMxGxcUTG+IXrtGlwHukB1xqgnT/LoFcmC5UZYNrEgbsHeq506rfSeXyfYv8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=fQMhDb+v; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="fQMhDb+v" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Tn7Sj9aj7mKGF3DhRsSXj5p1f8IBKXhKdUSO5Wmvxe8=; b=fQMhDb+v61p/0raVYz8o+UsmyW 1cNJRLEGhT9gWvFR1kqN5fC951IW6pn+4xXWEeB8Og2PdYkNo9pPxrJQAwfDkAFlHcjVYE5vGjbyx vh3g+87h39NiKTlgFpd/pqv9PonkQKEQ5xMS9SWFFJvuXvLKkBRbPaLP4gJyNLuxJEmGry2cPxaTk xxf8d1LzjoxukfnWYuSZStGC73/GfcvaKIk2Dsgyt0wIl/XiY+WjeNMhyHgHS1f1TFIowiuxUI39F E/ZjIu+xYS1BCx3CIRGwsgwg3ieSwTFCJFe/Yy+95c/iJdo7f6JMqyWi3gU8GEiZu+Bk0IwMsmJKN TzPeFlNg==; Received: from 2a02-8389-2341-5b80-2b91-e1b6-c99c-08ea.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:2b91:e1b6:c99c:8ea] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1svJTe-00000000GVj-17sN; Mon, 30 Sep 2024 16:42:26 +0000 From: Christoph Hellwig To: Chandan Babu R Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 2/7] xfs: merge the perag freeing helpers Date: Mon, 30 Sep 2024 18:41:43 +0200 Message-ID: <20240930164211.2357358-3-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930164211.2357358-1-hch@lst.de> References: <20240930164211.2357358-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html There is no good reason to have two different routines for freeing perag structures for the unmount and error cases. Add two arguments to specify the range of AGs to free to xfs_free_perag, and use that to replace xfs_free_unused_perag_range. The addition RCU grace period for the error case is harmless, and the extra check for the AG to actually exist is not required now that the callers pass the exact known allocated range. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_ag.c | 40 ++++++++++------------------------------ fs/xfs/libxfs/xfs_ag.h | 5 ++--- fs/xfs/xfs_fsops.c | 2 +- fs/xfs/xfs_mount.c | 5 ++--- 4 files changed, 15 insertions(+), 37 deletions(-) diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c index 652376aa52e990..8fac0ce45b1559 100644 --- a/fs/xfs/libxfs/xfs_ag.c +++ b/fs/xfs/libxfs/xfs_ag.c @@ -185,17 +185,20 @@ xfs_initialize_perag_data( } /* - * Free up the per-ag resources associated with the mount structure. + * Free up the per-ag resources within the specified AG range. */ void -xfs_free_perag( - struct xfs_mount *mp) +xfs_free_perag_range( + struct xfs_mount *mp, + xfs_agnumber_t first_agno, + xfs_agnumber_t end_agno) + { - struct xfs_perag *pag; xfs_agnumber_t agno; - for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { - pag = xa_erase(&mp->m_perags, agno); + for (agno = first_agno; agno < end_agno; agno++) { + struct xfs_perag *pag = xa_erase(&mp->m_perags, agno); + ASSERT(pag); XFS_IS_CORRUPT(pag->pag_mount, atomic_read(&pag->pag_ref) != 0); xfs_defer_drain_free(&pag->pag_intents_drain); @@ -270,29 +273,6 @@ xfs_agino_range( return __xfs_agino_range(mp, xfs_ag_block_count(mp, agno), first, last); } -/* - * Free perag within the specified AG range, it is only used to free unused - * perags under the error handling path. - */ -void -xfs_free_unused_perag_range( - struct xfs_mount *mp, - xfs_agnumber_t agstart, - xfs_agnumber_t agend) -{ - struct xfs_perag *pag; - xfs_agnumber_t index; - - for (index = agstart; index < agend; index++) { - pag = xa_erase(&mp->m_perags, index); - if (!pag) - break; - xfs_buf_cache_destroy(&pag->pag_bcache); - xfs_defer_drain_free(&pag->pag_intents_drain); - kfree(pag); - } -} - int xfs_initialize_perag( struct xfs_mount *mp, @@ -369,7 +349,7 @@ xfs_initialize_perag( out_free_pag: kfree(pag); out_unwind_new_pags: - xfs_free_unused_perag_range(mp, old_agcount, index); + xfs_free_perag_range(mp, old_agcount, index); return error; } diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h index 69fc31e7b84728..6e68d6a3161a0f 100644 --- a/fs/xfs/libxfs/xfs_ag.h +++ b/fs/xfs/libxfs/xfs_ag.h @@ -144,13 +144,12 @@ __XFS_AG_OPSTATE(prefers_metadata, PREFERS_METADATA) __XFS_AG_OPSTATE(allows_inodes, ALLOWS_INODES) __XFS_AG_OPSTATE(agfl_needs_reset, AGFL_NEEDS_RESET) -void xfs_free_unused_perag_range(struct xfs_mount *mp, xfs_agnumber_t agstart, - xfs_agnumber_t agend); int xfs_initialize_perag(struct xfs_mount *mp, xfs_agnumber_t old_agcount, xfs_agnumber_t agcount, xfs_rfsblock_t dcount, xfs_agnumber_t *maxagi); +void xfs_free_perag_range(struct xfs_mount *mp, xfs_agnumber_t first_agno, + xfs_agnumber_t end_agno); int xfs_initialize_perag_data(struct xfs_mount *mp, xfs_agnumber_t agno); -void xfs_free_perag(struct xfs_mount *mp); /* Passive AG references */ struct xfs_perag *xfs_perag_get(struct xfs_mount *mp, xfs_agnumber_t agno); diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index de2bf0594cb474..b247d895c276d2 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -229,7 +229,7 @@ xfs_growfs_data_private( xfs_trans_cancel(tp); out_free_unused_perag: if (nagcount > oagcount) - xfs_free_unused_perag_range(mp, oagcount, nagcount); + xfs_free_perag_range(mp, oagcount, nagcount); return error; } diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 6fa7239a4a01b6..25bbcc3f4ee08b 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -1048,7 +1048,7 @@ xfs_mountfs( xfs_buftarg_drain(mp->m_logdev_targp); xfs_buftarg_drain(mp->m_ddev_targp); out_free_perag: - xfs_free_perag(mp); + xfs_free_perag_range(mp, 0, mp->m_sb.sb_agcount); out_free_dir: xfs_da_unmount(mp); out_remove_uuid: @@ -1129,8 +1129,7 @@ xfs_unmountfs( xfs_errortag_clearall(mp); #endif shrinker_free(mp->m_inodegc_shrinker); - xfs_free_perag(mp); - + xfs_free_perag_range(mp, 0, mp->m_sb.sb_agcount); xfs_errortag_del(mp); xfs_error_sysfs_del(mp); xchk_stats_unregister(mp->m_scrub_stats); From patchwork Mon Sep 30 16:41:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13816703 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95A1363D5 for ; Mon, 30 Sep 2024 16:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714552; cv=none; b=JMAzqHhAvQUqRDyZH4k3OWhgYDFpdjEt7ZhxrLLqPeVwTslekR/Pljcs4jlI3wo/R0mA9vARPlaMr3Z2tnjpEs4DcjasNDDku747a5nU49lAoo/ebN025O8sLJ/VasFJTXVNuBc5okONwvVyziGCjAK9ySVzzo71thCyrPmGCYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714552; c=relaxed/simple; bh=JuNmmxpYoiu7vX9QOzLCy3ca8QCBuXZfuUcEhRwQVC0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L7kNbyIM/TAPSlGdhwL2y1GdMtPVJ9tVRni2DS41BrQVnZ/mfOADKQpDPWFPmcdJUgc9/FUZc6vAYqaWWSnMkQTEQQLSeDikI8wAQmTrakGrKcTx7OjGn9stnL+nOzzPloNxPYRtq88yrPgruWJJVOcpmYrebdaHQWHaMX9Elr0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=BbY0LvAe; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="BbY0LvAe" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=5vhHAd/fxqML9AjrfE70SrrGbScFsVdNh76QzWU/QbM=; b=BbY0LvAeWByfR/cC9774ekf7Q7 AGg+R/YNqs0/ppEEn0ZdCpqIIWgENGkC28yWnaisoA+GJsOImJs6iBi7jwMV7HHNLtUGucc//panH O892TvenUQwUtOfsxFsw5mffYDYq9WZ9mbmH4MQgEGGhdti9I3wZAYFJ6iFuX911VXQ7SlgmbKGYx C+XK3OkRpHMIPRs6i64Hstk27O7zazzijcMTTrXNo1KWzH084bTIsGWn6sD0T5mGL7vxJ9t069I78 aSjD+mZrNbRNRLDy6kGpRWqi9HbJx03Y5jC9vD5VQQyPoK8NYEWG+nXtTFbvpJivtozOPhaoIUbDc 28q2FvaA==; Received: from 2a02-8389-2341-5b80-2b91-e1b6-c99c-08ea.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:2b91:e1b6:c99c:8ea] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1svJTh-00000000GYL-41g5; Mon, 30 Sep 2024 16:42:30 +0000 From: Christoph Hellwig To: Chandan Babu R Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 3/7] xfs: update the file system geometry after recoverying superblock buffers Date: Mon, 30 Sep 2024 18:41:44 +0200 Message-ID: <20240930164211.2357358-4-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930164211.2357358-1-hch@lst.de> References: <20240930164211.2357358-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Primary superblock buffers that change the file system geometry after a growfs operation can affect the operation of later CIL checkpoints that make use of the newly added space and allocation groups. Apply the changes to the in-memory structures as part of recovery pass 2, to ensure recovery works fine for such cases. In the future we should apply the logic to other updates such as features bits as well. Signed-off-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_log_recover.h | 2 ++ fs/xfs/xfs_buf_item_recover.c | 27 +++++++++++++++++++++++++++ fs/xfs/xfs_log_recover.c | 27 +++++++++++++++++++-------- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/fs/xfs/libxfs/xfs_log_recover.h b/fs/xfs/libxfs/xfs_log_recover.h index 521d327e4c89ed..d0e13c84422d0a 100644 --- a/fs/xfs/libxfs/xfs_log_recover.h +++ b/fs/xfs/libxfs/xfs_log_recover.h @@ -165,4 +165,6 @@ void xlog_recover_intent_item(struct xlog *log, struct xfs_log_item *lip, int xlog_recover_finish_intent(struct xfs_trans *tp, struct xfs_defer_pending *dfp); +int xlog_recover_update_agcount(struct xfs_mount *mp, struct xfs_dsb *dsb); + #endif /* __XFS_LOG_RECOVER_H__ */ diff --git a/fs/xfs/xfs_buf_item_recover.c b/fs/xfs/xfs_buf_item_recover.c index 09e893cf563cb9..08c129022304a8 100644 --- a/fs/xfs/xfs_buf_item_recover.c +++ b/fs/xfs/xfs_buf_item_recover.c @@ -684,6 +684,28 @@ xlog_recover_do_inode_buffer( return 0; } +static int +xlog_recover_do_sb_buffer( + struct xfs_mount *mp, + struct xlog_recover_item *item, + struct xfs_buf *bp, + struct xfs_buf_log_format *buf_f, + xfs_lsn_t current_lsn) +{ + xlog_recover_do_reg_buffer(mp, item, bp, buf_f, current_lsn); + + /* + * Update the in-memory superblock and perag structures from the + * primary SB buffer. + * + * This is required because transactions running after growfs may require + * the updated values to be set in a previous fully commit transaction. + */ + if (xfs_buf_daddr(bp) != 0) + return 0; + return xlog_recover_update_agcount(mp, bp->b_addr); +} + /* * V5 filesystems know the age of the buffer on disk being recovered. We can * have newer objects on disk than we are replaying, and so for these cases we @@ -967,6 +989,11 @@ xlog_recover_buf_commit_pass2( dirty = xlog_recover_do_dquot_buffer(mp, log, item, bp, buf_f); if (!dirty) goto out_release; + } else if (xfs_blft_from_flags(buf_f) & XFS_BLFT_SB_BUF) { + error = xlog_recover_do_sb_buffer(mp, item, bp, buf_f, + current_lsn); + if (error) + goto out_release; } else { xlog_recover_do_reg_buffer(mp, item, bp, buf_f, current_lsn); } diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 6a165ca55da1a8..03701409c7dcd6 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -3334,6 +3334,25 @@ xlog_do_log_recovery( return error; } +int +xlog_recover_update_agcount( + struct xfs_mount *mp, + struct xfs_dsb *dsb) +{ + xfs_agnumber_t old_agcount = mp->m_sb.sb_agcount; + int error; + + xfs_sb_from_disk(&mp->m_sb, dsb); + error = xfs_initialize_perag(mp, old_agcount, mp->m_sb.sb_agcount, + mp->m_sb.sb_dblocks, &mp->m_maxagi); + if (error) { + xfs_warn(mp, "Failed recovery per-ag init: %d", error); + return error; + } + mp->m_alloc_set_aside = xfs_alloc_set_aside(mp); + return 0; +} + /* * Do the actual recovery */ @@ -3346,7 +3365,6 @@ xlog_do_recover( struct xfs_mount *mp = log->l_mp; struct xfs_buf *bp = mp->m_sb_bp; struct xfs_sb *sbp = &mp->m_sb; - xfs_agnumber_t old_agcount = sbp->sb_agcount; int error; trace_xfs_log_recover(log, head_blk, tail_blk); @@ -3394,13 +3412,6 @@ xlog_do_recover( /* re-initialise in-core superblock and geometry structures */ mp->m_features |= xfs_sb_version_to_features(sbp); xfs_reinit_percpu_counters(mp); - error = xfs_initialize_perag(mp, old_agcount, sbp->sb_agcount, - sbp->sb_dblocks, &mp->m_maxagi); - if (error) { - xfs_warn(mp, "Failed post-recovery per-ag init: %d", error); - return error; - } - mp->m_alloc_set_aside = xfs_alloc_set_aside(mp); /* Normal transactions can now occur */ clear_bit(XLOG_ACTIVE_RECOVERY, &log->l_opstate); From patchwork Mon Sep 30 16:41:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13816704 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2669A192B66 for ; Mon, 30 Sep 2024 16:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714555; cv=none; b=TKGqyPEFHTtACw7vC7cKxksZnceQGyLt7CLmp8bpuPXBYJQLi6PgKXvJavv+pWVNhF8tKSE357/H1tR/OwL7U/XlGSf3Dp0bo6awJOvKqM6/FcXTAPhIr2q88K9SBNg3wgij6UsQkDaPdYhA6bKCXgmuQhTY9WD/690x0LCcDoU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714555; c=relaxed/simple; bh=csiXkm9vLYpB/wDtTKOPdLshfjYMThFeas4O33vo+Q8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pBoQQQmspT1h5FUMc/vfjXleNgWY9WXsbluZ+zLNmctVF+tTamrFPAu+EA2Qg67uRiYwLy8tKBUE2YcbpSuuHN/t/IHoD3dqlS5evOhfPGSJW362cD0pUjZ9zaRPIyaERTUaB+MLH2BuG7TXYxVX5VChY/0AQCHnf4X8jDBDUC8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=DRJ1jEli; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="DRJ1jEli" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=ZmN5qUZnIFtGEoSl8QZXsDwkoBiJZHzhE9f0dF+Kq+0=; b=DRJ1jEliUuYqSFdjY/GVs760+C +koST6Gr/HJqh5gs+TZGXE5W7BCOqiIqv0RJlpyvsr/1TL/n8WkKo3bPteA0487MnfHCMWO2aH4M4 6SkEZPT8OIbnbE0ApKxfpBMg+btdleOYccXBTBOmCHwmk8Vir/ICVrI+xLg0wsmdfno9szb9REX82 bXrHrX4I052gJ5MbypmltQuTLI5lmLEeQO82xh4r16qass3aGDbroz2KotRx5j0T4B594M1mr47xS e60xKho9x6E+kx9j1Pxk41VitI0p60SeP0JJEpGHYTrv6BMrdixfZHlFQu4580J38EDEMBP5nJAqB wVTopkQQ==; Received: from 2a02-8389-2341-5b80-2b91-e1b6-c99c-08ea.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:2b91:e1b6:c99c:8ea] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1svJTl-00000000GZZ-17YQ; Mon, 30 Sep 2024 16:42:33 +0000 From: Christoph Hellwig To: Chandan Babu R Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 4/7] xfs: error out when a superblock buffer updates reduces the agcount Date: Mon, 30 Sep 2024 18:41:45 +0200 Message-ID: <20240930164211.2357358-5-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930164211.2357358-1-hch@lst.de> References: <20240930164211.2357358-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html XFS currently does not support reducing the agcount, so error out if a logged sb buffer tries to shrink the agcount. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/xfs_log_recover.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 03701409c7dcd6..3b5cd240bb62ef 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -3343,6 +3343,10 @@ xlog_recover_update_agcount( int error; xfs_sb_from_disk(&mp->m_sb, dsb); + if (mp->m_sb.sb_agcount < old_agcount) { + xfs_alert(mp, "Shrinking AG count in log recovery"); + return -EFSCORRUPTED; + } error = xfs_initialize_perag(mp, old_agcount, mp->m_sb.sb_agcount, mp->m_sb.sb_dblocks, &mp->m_maxagi); if (error) { From patchwork Mon Sep 30 16:41:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13816705 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A94E193078 for ; Mon, 30 Sep 2024 16:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714558; cv=none; b=g+NMCXTn2f3JVShVMpFKanIm0hZ52VSdWuWY5ymVW5gb3lJHJgiw+q9nCTMhgCJ0Cf8y8HaSu2xdpi9EnaK4Ng/MEP3Dy3G8VTVr3IlFJ5md8AqxbfEPT8debZ5VWhmlmKGsfOvJa9nvMYh1gA3ChlJW12wYvPr3dMNKXrEIm5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714558; c=relaxed/simple; bh=Hyq/YE0NzZRi39khtV+3zvGIK6fFPEVvfsNoDNKwKow=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OIRcNeRL1SSfVfDe14co47svZ7Vil5E4V1jw5/h6ZwCfLHL33/r5b5NMlhLCtz0WGssZRp9aM/c2NH4MEsm4Pk0wyalMhDjDorSaAQkLWcptf/8we6kdlCMk1YPhZ124ivd+VoNEQ4l9ToFUL5v6S2ZwkXFm0a1Ox4SPCaoDebo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=x2qObWBb; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="x2qObWBb" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=qDh2ssTVh7WPcnLxh1UUgBjhIzyN5CLUw8IZbvq/w08=; b=x2qObWBb4Ijlo5MuS2XFLeOnAt yWDu0jwmrungjfBO+ZgL5eUL3VTg4Eakj2zSQ8ZHNnTowy4PPvbExJX1F/lre/3COZMXJv3/NfLlo 0F+DhWEYveMlmEW4SzbpqJas5sDrZ6WeL2ndRfjLEx+BznyqkTceBpTDuK/t4gVGsp1WEFd/0mMLz WqNLQfZPORBl2hSp+81EDdhb/ZYuFVo5sTYHRrK0kM4bpXRV99t0bPIJW67RWr4fHY9v4cUvXEQWH ug2dhXfs+MVGu9t1+OY23C5ynNhTMALdj3OtpVG3PcGTmCZlIhoRwKWjEd0Cp2tKWBHlEOyipwuRG vJEznzZQ==; Received: from 2a02-8389-2341-5b80-2b91-e1b6-c99c-08ea.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:2b91:e1b6:c99c:8ea] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1svJTo-00000000GcK-1pNz; Mon, 30 Sep 2024 16:42:36 +0000 From: Christoph Hellwig To: Chandan Babu R Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 5/7] xfs: don't use __GFP_RETRY_MAYFAIL in xfs_initialize_perag Date: Mon, 30 Sep 2024 18:41:46 +0200 Message-ID: <20240930164211.2357358-6-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930164211.2357358-1-hch@lst.de> References: <20240930164211.2357358-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html __GFP_RETRY_MAYFAIL increases the likelyhood of allocations to fail, which isn't really helpful during log recovery. Remove the flag and stick to the default GFP_KERNEL policies. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_ag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c index 8fac0ce45b1559..29feaed7c8f880 100644 --- a/fs/xfs/libxfs/xfs_ag.c +++ b/fs/xfs/libxfs/xfs_ag.c @@ -289,7 +289,7 @@ xfs_initialize_perag( return 0; for (index = old_agcount; index < new_agcount; index++) { - pag = kzalloc(sizeof(*pag), GFP_KERNEL | __GFP_RETRY_MAYFAIL); + pag = kzalloc(sizeof(*pag), GFP_KERNEL); if (!pag) { error = -ENOMEM; goto out_unwind_new_pags; From patchwork Mon Sep 30 16:41:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13816706 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2EC61946AA for ; Mon, 30 Sep 2024 16:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714562; cv=none; b=cZQbsuWm9mSW593j3NgATj0xSUjZnBzPogSle5bnBzhKxl6Fcg90rt4N8Ng1Wh9L4LUUJt4/+bkTFiRB9uDUhKO2DS5/lfZtBDf1PKJtq2ig5enMpDFhelfp6zIyYthnGjbUpDxF6k8hS2UTS0zf37qdgRSUXwDZ8jlxRD8A5Pk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714562; c=relaxed/simple; bh=wLj8amWJpwGKLSJRtB5RMlpD9nv8IlqlXsM3dyx5QkM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pg/1PY8knsjDl8yBxEpOBpiKyIcHfn1S50qTisFrFWsXsw3w/0bh8xF1IvnSxRO9AdMWZlAoXsnoiib+gjYOdrvQMBkMz0mLAodqUrd1PW1U8SFj4lnIG5/PLefg+25lSBOQtIMWCf8o6cS1yvPIbkauLFhWtmL5zSp9CY2Q/os= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=dGASOdTR; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="dGASOdTR" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=hXKVNuy+SEhZokdf/ElP/NDfjt3WUu17CWfM7n6ggRM=; b=dGASOdTRGJ5iGPOf6GkV9S8PLE dwIG/ansOeYmdmLlqpD0ICOYMh7w/tw0z3PxXwv2+IbUxM/03vICgTY3JBHjcbuPue5ewDzSfAP/5 JmlXY4/s6w/5uB5ezps8e0qDtBIORa21yN3GeSd07+Nn/9z8pjNgllQNyaqKzqrr/tUFepzH8QfsC jkQT+IsUsqlyGYurv+0LpXlZF1Im8k1F/JAPkwJvbrmohqoP0fzagOLaJB5VSyNcFeNsy3TN+FojU YVv2T/o8jR5tf17+DMpu0V+SNnY0XLUL+ydk5Jd1lTfcA8mMQ9SGMhr7BvUsLpGIcwcUD4P52FN7Y A4eaYSJQ==; Received: from 2a02-8389-2341-5b80-2b91-e1b6-c99c-08ea.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:2b91:e1b6:c99c:8ea] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1svJTr-00000000Gdb-29Mr; Mon, 30 Sep 2024 16:42:40 +0000 From: Christoph Hellwig To: Chandan Babu R Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 6/7] xfs: don't update file system geometry through transaction deltas Date: Mon, 30 Sep 2024 18:41:47 +0200 Message-ID: <20240930164211.2357358-7-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930164211.2357358-1-hch@lst.de> References: <20240930164211.2357358-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Updates to the file system geometry in growfs need to be committed to stable store before the allocator can see them to avoid that they are in the same CIL checkpoint as transactions that make use of this new information, which will make recovery impossible or broken. To do this add two new helpers to prepare a superblock for direct manipulation of the on-disk buffer, and to commit these updates while holding the buffer locked (similar to what xfs_sync_sb_buf does) and use those in growfs instead of applying the changes through the deltas in the xfs_trans structure (which also happens to shrink the xfs_trans structure a fair bit). The rtbmimap repair code was also using the transaction deltas and is converted to also update the superblock buffer directly under the buffer lock. This new method establishes a locking protocol where even in-core superblock fields must only be updated with the superblock buffer locked. For now it is only applied to affected geometry fields, but in the future it would make sense to apply it universally. Signed-off-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_sb.c | 97 ++++++++++++++++++++++++------- fs/xfs/libxfs/xfs_sb.h | 3 + fs/xfs/libxfs/xfs_shared.h | 8 --- fs/xfs/scrub/rtbitmap_repair.c | 26 +++++---- fs/xfs/xfs_fsops.c | 80 ++++++++++++++++---------- fs/xfs/xfs_rtalloc.c | 92 +++++++++++++++++------------- fs/xfs/xfs_trans.c | 101 ++------------------------------- fs/xfs/xfs_trans.h | 8 --- 8 files changed, 198 insertions(+), 217 deletions(-) diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index d95409f3cba667..2c83ab7441ade5 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -1025,6 +1025,80 @@ xfs_sb_mount_common( mp->m_ag_max_usable = xfs_alloc_ag_max_usable(mp); } +/* + * Mirror the lazy sb counters to the in-core superblock. + * + * If this is at unmount, the counters will be exactly correct, but at any other + * time they will only be ballpark correct because of reservations that have + * been taken out percpu counters. If we have an unclean shutdown, this will be + * corrected by log recovery rebuilding the counters from the AGF block counts. + * + * Do not update sb_frextents here because it is not part of the lazy sb + * counters, despite having a percpu counter. It is always kept consistent with + * the ondisk rtbitmap by xfs_trans_apply_sb_deltas() and hence we don't need + * have to update it here. + */ +static void +xfs_flush_sb_counters( + struct xfs_mount *mp) +{ + if (xfs_has_lazysbcount(mp)) { + mp->m_sb.sb_icount = percpu_counter_sum_positive(&mp->m_icount); + mp->m_sb.sb_ifree = min_t(uint64_t, + percpu_counter_sum_positive(&mp->m_ifree), + mp->m_sb.sb_icount); + mp->m_sb.sb_fdblocks = + percpu_counter_sum_positive(&mp->m_fdblocks); + } +} + +/* + * Prepare a direct update to the superblock through the on-disk buffer. + * + * This locks out other modifications through the buffer lock and then syncs all + * in-core values to the on-disk buffer (including the percpu counters). + * + * The caller then directly manipulates the on-disk fields and calls + * xfs_commit_sb_update to the updates to disk them. The caller is responsible + * to also update the in-core field, but it can do so after the transaction has + * been committed to disk. + * + * Updating the in-core field only after xfs_commit_sb_update ensures that other + * processes only see the update once it is stable on disk, and is usually the + * right thing to do for superblock updates. + * + * Note that writes to superblock fields updated using this helper are + * synchronized using the superblock buffer lock, which must be taken around + * all updates to the in-core fields as well. + */ +struct xfs_dsb * +xfs_prepare_sb_update( + struct xfs_trans *tp, + struct xfs_buf **bpp) +{ + *bpp = xfs_trans_getsb(tp); + xfs_flush_sb_counters(tp->t_mountp); + xfs_sb_to_disk((*bpp)->b_addr, &tp->t_mountp->m_sb); + return (*bpp)->b_addr; +} + +/* + * Commit a direct update to the on-disk superblock. Keeps @bp locked and + * referenced, so the caller must call xfs_buf_relse() manually. + */ +int +xfs_commit_sb_update( + struct xfs_trans *tp, + struct xfs_buf *bp) +{ + xfs_trans_bhold(tp, bp); + xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); + xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb) - 1); + + xfs_trans_set_sync(tp); + return xfs_trans_commit(tp); +} + /* * xfs_log_sb() can be used to copy arbitrary changes to the in-core superblock * into the superblock buffer to be logged. It does not provide the higher @@ -1038,28 +1112,7 @@ xfs_log_sb( struct xfs_mount *mp = tp->t_mountp; struct xfs_buf *bp = xfs_trans_getsb(tp); - /* - * Lazy sb counters don't update the in-core superblock so do that now. - * If this is at unmount, the counters will be exactly correct, but at - * any other time they will only be ballpark correct because of - * reservations that have been taken out percpu counters. If we have an - * unclean shutdown, this will be corrected by log recovery rebuilding - * the counters from the AGF block counts. - * - * Do not update sb_frextents here because it is not part of the lazy - * sb counters, despite having a percpu counter. It is always kept - * consistent with the ondisk rtbitmap by xfs_trans_apply_sb_deltas() - * and hence we don't need have to update it here. - */ - if (xfs_has_lazysbcount(mp)) { - mp->m_sb.sb_icount = percpu_counter_sum_positive(&mp->m_icount); - mp->m_sb.sb_ifree = min_t(uint64_t, - percpu_counter_sum_positive(&mp->m_ifree), - mp->m_sb.sb_icount); - mp->m_sb.sb_fdblocks = - percpu_counter_sum_positive(&mp->m_fdblocks); - } - + xfs_flush_sb_counters(mp); xfs_sb_to_disk(bp->b_addr, &mp->m_sb); xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb) - 1); diff --git a/fs/xfs/libxfs/xfs_sb.h b/fs/xfs/libxfs/xfs_sb.h index 885c837559914d..3649d071687e33 100644 --- a/fs/xfs/libxfs/xfs_sb.h +++ b/fs/xfs/libxfs/xfs_sb.h @@ -13,6 +13,9 @@ struct xfs_trans; struct xfs_fsop_geom; struct xfs_perag; +struct xfs_dsb *xfs_prepare_sb_update(struct xfs_trans *tp, + struct xfs_buf **bpp); +int xfs_commit_sb_update(struct xfs_trans *tp, struct xfs_buf *bp); extern void xfs_log_sb(struct xfs_trans *tp); extern int xfs_sync_sb(struct xfs_mount *mp, bool wait); extern int xfs_sync_sb_buf(struct xfs_mount *mp); diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h index 33b84a3a83ff63..45a32ea426164a 100644 --- a/fs/xfs/libxfs/xfs_shared.h +++ b/fs/xfs/libxfs/xfs_shared.h @@ -149,14 +149,6 @@ void xfs_log_get_max_trans_res(struct xfs_mount *mp, #define XFS_TRANS_SB_RES_FDBLOCKS 0x00000008 #define XFS_TRANS_SB_FREXTENTS 0x00000010 #define XFS_TRANS_SB_RES_FREXTENTS 0x00000020 -#define XFS_TRANS_SB_DBLOCKS 0x00000040 -#define XFS_TRANS_SB_AGCOUNT 0x00000080 -#define XFS_TRANS_SB_IMAXPCT 0x00000100 -#define XFS_TRANS_SB_REXTSIZE 0x00000200 -#define XFS_TRANS_SB_RBMBLOCKS 0x00000400 -#define XFS_TRANS_SB_RBLOCKS 0x00000800 -#define XFS_TRANS_SB_REXTENTS 0x00001000 -#define XFS_TRANS_SB_REXTSLOG 0x00002000 /* * Here we centralize the specification of XFS meta-data buffer reference count diff --git a/fs/xfs/scrub/rtbitmap_repair.c b/fs/xfs/scrub/rtbitmap_repair.c index 0fef98e9f83409..be9d31f032b1bf 100644 --- a/fs/xfs/scrub/rtbitmap_repair.c +++ b/fs/xfs/scrub/rtbitmap_repair.c @@ -16,6 +16,7 @@ #include "xfs_bit.h" #include "xfs_bmap.h" #include "xfs_bmap_btree.h" +#include "xfs_sb.h" #include "scrub/scrub.h" #include "scrub/common.h" #include "scrub/trace.h" @@ -127,20 +128,21 @@ xrep_rtbitmap_geometry( struct xchk_rtbitmap *rtb) { struct xfs_mount *mp = sc->mp; - struct xfs_trans *tp = sc->tp; /* Superblock fields */ - if (mp->m_sb.sb_rextents != rtb->rextents) - xfs_trans_mod_sb(sc->tp, XFS_TRANS_SB_REXTENTS, - rtb->rextents - mp->m_sb.sb_rextents); - - if (mp->m_sb.sb_rbmblocks != rtb->rbmblocks) - xfs_trans_mod_sb(tp, XFS_TRANS_SB_RBMBLOCKS, - rtb->rbmblocks - mp->m_sb.sb_rbmblocks); - - if (mp->m_sb.sb_rextslog != rtb->rextslog) - xfs_trans_mod_sb(tp, XFS_TRANS_SB_REXTSLOG, - rtb->rextslog - mp->m_sb.sb_rextslog); + if (mp->m_sb.sb_rextents != rtb->rextents || + mp->m_sb.sb_rbmblocks != rtb->rbmblocks || + mp->m_sb.sb_rextslog != rtb->rextslog) { + struct xfs_buf *bp = xfs_trans_getsb(sc->tp); + + mp->m_sb.sb_rextents = rtb->rextents; + mp->m_sb.sb_rbmblocks = rtb->rbmblocks; + mp->m_sb.sb_rextslog = rtb->rextslog; + xfs_sb_to_disk(bp->b_addr, &mp->m_sb); + + xfs_trans_buf_set_type(sc->tp, bp, XFS_BLFT_SB_BUF); + xfs_trans_log_buf(sc->tp, bp, 0, sizeof(struct xfs_dsb) - 1); + } /* Fix broken isize */ sc->ip->i_disk_size = roundup_64(sc->ip->i_disk_size, diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index b247d895c276d2..4168ccf21068cb 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -79,6 +79,46 @@ xfs_resizefs_init_new_ags( return error; } +static int +xfs_growfs_data_update_sb( + struct xfs_trans *tp, + xfs_agnumber_t nagcount, + xfs_rfsblock_t nb, + xfs_agnumber_t nagimax) +{ + struct xfs_mount *mp = tp->t_mountp; + struct xfs_dsb *sbp; + struct xfs_buf *bp; + int error; + + /* + * Update the geometry in the on-disk superblock first, and ensure + * they make it to disk before the superblock can be relogged. + */ + sbp = xfs_prepare_sb_update(tp, &bp); + sbp->sb_agcount = cpu_to_be32(nagcount); + sbp->sb_dblocks = cpu_to_be64(nb); + error = xfs_commit_sb_update(tp, bp); + if (error) + goto out_unlock; + + /* + * Propagate the new values to the live mount structure after they made + * it to disk with the superblock buffer still locked. + */ + mp->m_sb.sb_agcount = nagcount; + mp->m_sb.sb_dblocks = nb; + + if (nagimax) + mp->m_maxagi = nagimax; + xfs_set_low_space_thresholds(mp); + mp->m_alloc_set_aside = xfs_alloc_set_aside(mp); + +out_unlock: + xfs_buf_relse(bp); + return error; +} + /* * growfs operations */ @@ -171,37 +211,13 @@ xfs_growfs_data_private( if (error) goto out_trans_cancel; - /* - * Update changed superblock fields transactionally. These are not - * seen by the rest of the world until the transaction commit applies - * them atomically to the superblock. - */ - if (nagcount > oagcount) - xfs_trans_mod_sb(tp, XFS_TRANS_SB_AGCOUNT, nagcount - oagcount); - if (delta) - xfs_trans_mod_sb(tp, XFS_TRANS_SB_DBLOCKS, delta); if (id.nfree) xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, id.nfree); - /* - * Sync sb counters now to reflect the updated values. This is - * particularly important for shrink because the write verifier - * will fail if sb_fdblocks is ever larger than sb_dblocks. - */ - if (xfs_has_lazysbcount(mp)) - xfs_log_sb(tp); - - xfs_trans_set_sync(tp); - error = xfs_trans_commit(tp); + error = xfs_growfs_data_update_sb(tp, nagcount, nb, nagimax); if (error) return error; - /* New allocation groups fully initialized, so update mount struct */ - if (nagimax) - mp->m_maxagi = nagimax; - xfs_set_low_space_thresholds(mp); - mp->m_alloc_set_aside = xfs_alloc_set_aside(mp); - if (delta > 0) { /* * If we expanded the last AG, free the per-AG reservation @@ -260,8 +276,9 @@ xfs_growfs_imaxpct( struct xfs_mount *mp, __u32 imaxpct) { + struct xfs_dsb *sbp; + struct xfs_buf *bp; struct xfs_trans *tp; - int dpct; int error; if (imaxpct > 100) @@ -272,10 +289,13 @@ xfs_growfs_imaxpct( if (error) return error; - dpct = imaxpct - mp->m_sb.sb_imax_pct; - xfs_trans_mod_sb(tp, XFS_TRANS_SB_IMAXPCT, dpct); - xfs_trans_set_sync(tp); - return xfs_trans_commit(tp); + sbp = xfs_prepare_sb_update(tp, &bp); + sbp->sb_imax_pct = imaxpct; + error = xfs_commit_sb_update(tp, bp); + if (!error) + mp->m_sb.sb_imax_pct = imaxpct; + xfs_buf_relse(bp); + return error; } /* diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 3a2005a1e673dc..994e5efedab20f 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -698,6 +698,56 @@ xfs_growfs_rt_fixup_extsize( return error; } +static int +xfs_growfs_rt_update_sb( + struct xfs_trans *tp, + struct xfs_mount *mp, + struct xfs_mount *nmp, + xfs_rtbxlen_t freed_rtx) +{ + struct xfs_dsb *sbp; + struct xfs_buf *bp; + int error; + + /* + * Update the geometry in the on-disk superblock first, and ensure + * they make it to disk before the superblock can be relogged. + */ + sbp = xfs_prepare_sb_update(tp, &bp); + sbp->sb_rextsize = cpu_to_be32(nmp->m_sb.sb_rextsize); + sbp->sb_rbmblocks = cpu_to_be32(nmp->m_sb.sb_rbmblocks); + sbp->sb_rblocks = cpu_to_be64(nmp->m_sb.sb_rblocks); + sbp->sb_rextents = cpu_to_be64(nmp->m_sb.sb_rextents); + sbp->sb_rextslog = nmp->m_sb.sb_rextslog; + error = xfs_commit_sb_update(tp, bp); + if (error) + return error; + + /* + * Propagate the new values to the live mount structure after they made + * it to disk with the superblock buffer still locked. + */ + mp->m_sb.sb_rextsize = nmp->m_sb.sb_rextsize; + mp->m_sb.sb_rbmblocks = nmp->m_sb.sb_rbmblocks; + mp->m_sb.sb_rblocks = nmp->m_sb.sb_rblocks; + mp->m_sb.sb_rextents = nmp->m_sb.sb_rextents; + mp->m_sb.sb_rextslog = nmp->m_sb.sb_rextslog; + mp->m_rsumlevels = nmp->m_rsumlevels; + mp->m_rsumblocks = nmp->m_rsumblocks; + + /* + * Recompute the growfsrt reservation from the new rsumsize. + */ + xfs_trans_resv_calc(mp, &mp->m_resv); + + /* + * Ensure the mount RT feature flag is now set. + */ + mp->m_features |= XFS_FEAT_REALTIME; + xfs_buf_relse(bp); + return 0; +} + static int xfs_growfs_rt_bmblock( struct xfs_mount *mp, @@ -780,25 +830,6 @@ xfs_growfs_rt_bmblock( goto out_cancel; } - /* - * Update superblock fields. - */ - if (nmp->m_sb.sb_rextsize != mp->m_sb.sb_rextsize) - xfs_trans_mod_sb(args.tp, XFS_TRANS_SB_REXTSIZE, - nmp->m_sb.sb_rextsize - mp->m_sb.sb_rextsize); - if (nmp->m_sb.sb_rbmblocks != mp->m_sb.sb_rbmblocks) - xfs_trans_mod_sb(args.tp, XFS_TRANS_SB_RBMBLOCKS, - nmp->m_sb.sb_rbmblocks - mp->m_sb.sb_rbmblocks); - if (nmp->m_sb.sb_rblocks != mp->m_sb.sb_rblocks) - xfs_trans_mod_sb(args.tp, XFS_TRANS_SB_RBLOCKS, - nmp->m_sb.sb_rblocks - mp->m_sb.sb_rblocks); - if (nmp->m_sb.sb_rextents != mp->m_sb.sb_rextents) - xfs_trans_mod_sb(args.tp, XFS_TRANS_SB_REXTENTS, - nmp->m_sb.sb_rextents - mp->m_sb.sb_rextents); - if (nmp->m_sb.sb_rextslog != mp->m_sb.sb_rextslog) - xfs_trans_mod_sb(args.tp, XFS_TRANS_SB_REXTSLOG, - nmp->m_sb.sb_rextslog - mp->m_sb.sb_rextslog); - /* * Free the new extent. */ @@ -807,33 +838,12 @@ xfs_growfs_rt_bmblock( xfs_rtbuf_cache_relse(&nargs); if (error) goto out_cancel; - - /* - * Mark more blocks free in the superblock. - */ xfs_trans_mod_sb(args.tp, XFS_TRANS_SB_FREXTENTS, freed_rtx); - /* - * Update the calculated values in the real mount structure. - */ - mp->m_rsumlevels = nmp->m_rsumlevels; - mp->m_rsumblocks = nmp->m_rsumblocks; - xfs_mount_sb_set_rextsize(mp, &mp->m_sb); - - /* - * Recompute the growfsrt reservation from the new rsumsize. - */ - xfs_trans_resv_calc(mp, &mp->m_resv); - - error = xfs_trans_commit(args.tp); + error = xfs_growfs_rt_update_sb(args.tp, mp, nmp, freed_rtx); if (error) goto out_free; - /* - * Ensure the mount RT feature flag is now set. - */ - mp->m_features |= XFS_FEAT_REALTIME; - kfree(nmp); return 0; diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index bdf3704dc30118..56505cb94f877d 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -430,31 +430,6 @@ xfs_trans_mod_sb( ASSERT(delta < 0); tp->t_res_frextents_delta += delta; break; - case XFS_TRANS_SB_DBLOCKS: - tp->t_dblocks_delta += delta; - break; - case XFS_TRANS_SB_AGCOUNT: - ASSERT(delta > 0); - tp->t_agcount_delta += delta; - break; - case XFS_TRANS_SB_IMAXPCT: - tp->t_imaxpct_delta += delta; - break; - case XFS_TRANS_SB_REXTSIZE: - tp->t_rextsize_delta += delta; - break; - case XFS_TRANS_SB_RBMBLOCKS: - tp->t_rbmblocks_delta += delta; - break; - case XFS_TRANS_SB_RBLOCKS: - tp->t_rblocks_delta += delta; - break; - case XFS_TRANS_SB_REXTENTS: - tp->t_rextents_delta += delta; - break; - case XFS_TRANS_SB_REXTSLOG: - tp->t_rextslog_delta += delta; - break; default: ASSERT(0); return; @@ -475,12 +450,8 @@ STATIC void xfs_trans_apply_sb_deltas( xfs_trans_t *tp) { - struct xfs_dsb *sbp; - struct xfs_buf *bp; - int whole = 0; - - bp = xfs_trans_getsb(tp); - sbp = bp->b_addr; + struct xfs_buf *bp = xfs_trans_getsb(tp); + struct xfs_dsb *sbp = bp->b_addr; /* * Only update the superblock counters if we are logging them @@ -522,53 +493,10 @@ xfs_trans_apply_sb_deltas( spin_unlock(&mp->m_sb_lock); } - if (tp->t_dblocks_delta) { - be64_add_cpu(&sbp->sb_dblocks, tp->t_dblocks_delta); - whole = 1; - } - if (tp->t_agcount_delta) { - be32_add_cpu(&sbp->sb_agcount, tp->t_agcount_delta); - whole = 1; - } - if (tp->t_imaxpct_delta) { - sbp->sb_imax_pct += tp->t_imaxpct_delta; - whole = 1; - } - if (tp->t_rextsize_delta) { - be32_add_cpu(&sbp->sb_rextsize, tp->t_rextsize_delta); - whole = 1; - } - if (tp->t_rbmblocks_delta) { - be32_add_cpu(&sbp->sb_rbmblocks, tp->t_rbmblocks_delta); - whole = 1; - } - if (tp->t_rblocks_delta) { - be64_add_cpu(&sbp->sb_rblocks, tp->t_rblocks_delta); - whole = 1; - } - if (tp->t_rextents_delta) { - be64_add_cpu(&sbp->sb_rextents, tp->t_rextents_delta); - whole = 1; - } - if (tp->t_rextslog_delta) { - sbp->sb_rextslog += tp->t_rextslog_delta; - whole = 1; - } - xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); - if (whole) - /* - * Log the whole thing, the fields are noncontiguous. - */ - xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb) - 1); - else - /* - * Since all the modifiable fields are contiguous, we - * can get away with this. - */ - xfs_trans_log_buf(tp, bp, offsetof(struct xfs_dsb, sb_icount), - offsetof(struct xfs_dsb, sb_frextents) + - sizeof(sbp->sb_frextents) - 1); + xfs_trans_log_buf(tp, bp, offsetof(struct xfs_dsb, sb_icount), + offsetof(struct xfs_dsb, sb_frextents) + + sizeof(sbp->sb_frextents) - 1); } /* @@ -656,26 +584,7 @@ xfs_trans_unreserve_and_mod_sb( * must be consistent with the ondisk rtbitmap and must never include * incore reservations. */ - mp->m_sb.sb_dblocks += tp->t_dblocks_delta; - mp->m_sb.sb_agcount += tp->t_agcount_delta; - mp->m_sb.sb_imax_pct += tp->t_imaxpct_delta; - mp->m_sb.sb_rextsize += tp->t_rextsize_delta; - if (tp->t_rextsize_delta) { - mp->m_rtxblklog = log2_if_power2(mp->m_sb.sb_rextsize); - mp->m_rtxblkmask = mask64_if_power2(mp->m_sb.sb_rextsize); - } - mp->m_sb.sb_rbmblocks += tp->t_rbmblocks_delta; - mp->m_sb.sb_rblocks += tp->t_rblocks_delta; - mp->m_sb.sb_rextents += tp->t_rextents_delta; - mp->m_sb.sb_rextslog += tp->t_rextslog_delta; spin_unlock(&mp->m_sb_lock); - - /* - * Debug checks outside of the spinlock so they don't lock up the - * machine if they fail. - */ - ASSERT(mp->m_sb.sb_imax_pct >= 0); - ASSERT(mp->m_sb.sb_rextslog >= 0); } /* Add the given log item to the transaction's list of log items. */ diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index f06cc0f41665ad..e5911cf09be444 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h @@ -140,14 +140,6 @@ typedef struct xfs_trans { int64_t t_res_fdblocks_delta; /* on-disk only chg */ int64_t t_frextents_delta;/* superblock freextents chg*/ int64_t t_res_frextents_delta; /* on-disk only chg */ - int64_t t_dblocks_delta;/* superblock dblocks change */ - int64_t t_agcount_delta;/* superblock agcount change */ - int64_t t_imaxpct_delta;/* superblock imaxpct change */ - int64_t t_rextsize_delta;/* superblock rextsize chg */ - int64_t t_rbmblocks_delta;/* superblock rbmblocks chg */ - int64_t t_rblocks_delta;/* superblock rblocks change */ - int64_t t_rextents_delta;/* superblocks rextents chg */ - int64_t t_rextslog_delta;/* superblocks rextslog chg */ struct list_head t_items; /* log item descriptors */ struct list_head t_busy; /* list of busy extents */ struct list_head t_dfops; /* deferred operations */ From patchwork Mon Sep 30 16:41:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13816707 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E2B6196C86 for ; Mon, 30 Sep 2024 16:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714565; cv=none; b=ep+diWJS0x+OSrzjlwrQec/xI9GMxDHx8tHcDYl0w3l+nzAg1B3rFfCfYW/Cd8zqOPsn75lhoFoYJS93JpkZGa+SuCGlJ2kC0Apa+EIOcymTukitObpZ9W0h3jm1YBRueONnQ6HG8hZM3pw4m3r/l/DJApchHGvB+/MbwnMeBZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727714565; c=relaxed/simple; bh=JRUD9U3wuFjNwZEtSaEtZ+FpoVECqVfWWDDd7vR4zfg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mba7EhdIJ1Snxz8Js4JoKm5SMERQPnyphYIC/OU2YR1rFI+XgGrAw5N37mS425Q915iGEZOMRjcai7xgdmsi7px2QEltLqi3pJXQ1poyWeRRwT5WVb2XrNtwmn1mc++NkBAZI+4Hvq21sro8JDXQYyNEzd3j4Csklpz9PXZVzPA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=cti+5wab; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="cti+5wab" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=+RVOHMpOS6TCmWb6iGFWCN/DMBxgN1D3NBjaMrA0/Tg=; b=cti+5wabwh44K9EhsCly7idI3e ppshi6gG55ad+R7fiKFb8CiCJEXnaFd4j5VeQ9cy7qPczPH26TVcBwtYPexTI1z5JXK8Vy4889w0p V9jktxUchw/tFEKF8ztsgGSKTw2fJrbtSLAC2Y3GWCLivth+RVbZS2N/fTfxcER0ywd1LxlzumdFM X3KkporTNMh23KC550wz4Kv8IKCIkxbFW1kALbi0y+yOa3DzHx+HOxkaQ/Gg5+Egzb7eWJABHVCY2 rZVCu7AMIyV2AeSLsdBy/Nav0DElbWD7GASCbCIi6ksSkmanNo2nU6qzM9HG2PjdN0PRJiKbQf7so 5AwMOcFA==; Received: from 2a02-8389-2341-5b80-2b91-e1b6-c99c-08ea.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:2b91:e1b6:c99c:8ea] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1svJTu-00000000Ggl-2io8; Mon, 30 Sep 2024 16:42:43 +0000 From: Christoph Hellwig To: Chandan Babu R Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 7/7] xfs: split xfs_trans_mod_sb Date: Mon, 30 Sep 2024 18:41:48 +0200 Message-ID: <20240930164211.2357358-8-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930164211.2357358-1-hch@lst.de> References: <20240930164211.2357358-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Split xfs_trans_mod_sb into separate helpers for the different counts. While the icount and ifree counters get their own helpers, the handling for fdblocks and frextents merges the delalloc and non-delalloc cases to keep the related code together. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_ag_resv.c | 18 +++-- fs/xfs/libxfs/xfs_ialloc.c | 14 ++-- fs/xfs/libxfs/xfs_rtbitmap.c | 3 +- fs/xfs/libxfs/xfs_shared.h | 10 --- fs/xfs/xfs_fsops.c | 2 +- fs/xfs/xfs_rtalloc.c | 6 +- fs/xfs/xfs_trans.c | 130 +++++++++++++++-------------------- fs/xfs/xfs_trans.h | 7 +- fs/xfs/xfs_trans_dquot.c | 2 +- 9 files changed, 82 insertions(+), 110 deletions(-) diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c index 216423df939e5c..bb518d6a2dcecd 100644 --- a/fs/xfs/libxfs/xfs_ag_resv.c +++ b/fs/xfs/libxfs/xfs_ag_resv.c @@ -341,7 +341,6 @@ xfs_ag_resv_alloc_extent( { struct xfs_ag_resv *resv; xfs_extlen_t len; - uint field; trace_xfs_ag_resv_alloc_extent(pag, type, args->len); @@ -356,9 +355,8 @@ xfs_ag_resv_alloc_extent( ASSERT(0); fallthrough; case XFS_AG_RESV_NONE: - field = args->wasdel ? XFS_TRANS_SB_RES_FDBLOCKS : - XFS_TRANS_SB_FDBLOCKS; - xfs_trans_mod_sb(args->tp, field, -(int64_t)args->len); + xfs_trans_mod_fdblocks(args->tp, -(int64_t)args->len, + args->wasdel); return; } @@ -367,11 +365,11 @@ xfs_ag_resv_alloc_extent( if (type == XFS_AG_RESV_RMAPBT) return; /* Allocations of reserved blocks only need on-disk sb updates... */ - xfs_trans_mod_sb(args->tp, XFS_TRANS_SB_RES_FDBLOCKS, -(int64_t)len); + xfs_trans_mod_fdblocks(args->tp, -(int64_t)len, true); /* ...but non-reserved blocks need in-core and on-disk updates. */ if (args->len > len) - xfs_trans_mod_sb(args->tp, XFS_TRANS_SB_FDBLOCKS, - -((int64_t)args->len - len)); + xfs_trans_mod_fdblocks(args->tp, -((int64_t)args->len - len), + false); } /* Free a block to the reservation. */ @@ -398,7 +396,7 @@ xfs_ag_resv_free_extent( ASSERT(0); fallthrough; case XFS_AG_RESV_NONE: - xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, (int64_t)len); + xfs_trans_mod_fdblocks(tp, (int64_t)len, false); fallthrough; case XFS_AG_RESV_IGNORE: return; @@ -409,8 +407,8 @@ xfs_ag_resv_free_extent( if (type == XFS_AG_RESV_RMAPBT) return; /* Freeing into the reserved pool only requires on-disk update... */ - xfs_trans_mod_sb(tp, XFS_TRANS_SB_RES_FDBLOCKS, len); + xfs_trans_mod_fdblocks(tp, len, true); /* ...but freeing beyond that requires in-core and on-disk update. */ if (len > leftover) - xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, len - leftover); + xfs_trans_mod_fdblocks(tp, len - leftover, false); } diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index 271855227514cb..ad28823debb6f1 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c @@ -970,8 +970,8 @@ xfs_ialloc_ag_alloc( /* * Modify/log superblock values for inode count and inode free count. */ - xfs_trans_mod_sb(tp, XFS_TRANS_SB_ICOUNT, (long)newlen); - xfs_trans_mod_sb(tp, XFS_TRANS_SB_IFREE, (long)newlen); + xfs_trans_mod_icount(tp, (long)newlen); + xfs_trans_mod_ifree(tp, (long)newlen); return 0; } @@ -1357,7 +1357,7 @@ xfs_dialloc_ag_inobt( goto error0; xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); - xfs_trans_mod_sb(tp, XFS_TRANS_SB_IFREE, -1); + xfs_trans_mod_ifree(tp, -1); *inop = ino; return 0; error1: @@ -1660,7 +1660,7 @@ xfs_dialloc_ag( xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); pag->pagi_freecount--; - xfs_trans_mod_sb(tp, XFS_TRANS_SB_IFREE, -1); + xfs_trans_mod_ifree(tp, -1); error = xfs_check_agi_freecount(icur); if (error) @@ -2139,8 +2139,8 @@ xfs_difree_inobt( xfs_ialloc_log_agi(tp, agbp, XFS_AGI_COUNT | XFS_AGI_FREECOUNT); pag->pagi_freecount -= ilen - 1; pag->pagi_count -= ilen; - xfs_trans_mod_sb(tp, XFS_TRANS_SB_ICOUNT, -ilen); - xfs_trans_mod_sb(tp, XFS_TRANS_SB_IFREE, -(ilen - 1)); + xfs_trans_mod_icount(tp, -ilen); + xfs_trans_mod_ifree(tp, -(ilen - 1)); if ((error = xfs_btree_delete(cur, &i))) { xfs_warn(mp, "%s: xfs_btree_delete returned error %d.", @@ -2167,7 +2167,7 @@ xfs_difree_inobt( be32_add_cpu(&agi->agi_freecount, 1); xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); pag->pagi_freecount++; - xfs_trans_mod_sb(tp, XFS_TRANS_SB_IFREE, 1); + xfs_trans_mod_ifree(tp, 1); } error = xfs_check_agi_freecount(cur); diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c index 27a4472402bacd..d0c693a69e0001 100644 --- a/fs/xfs/libxfs/xfs_rtbitmap.c +++ b/fs/xfs/libxfs/xfs_rtbitmap.c @@ -989,7 +989,8 @@ xfs_rtfree_extent( /* * Mark more blocks free in the superblock. */ - xfs_trans_mod_sb(tp, XFS_TRANS_SB_FREXTENTS, (long)len); + xfs_trans_mod_frextents(tp, (long)len, false); + /* * If we've now freed all the blocks, reset the file sequence * number to 0. diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h index 45a32ea426164a..6b5a7bfc32dbb8 100644 --- a/fs/xfs/libxfs/xfs_shared.h +++ b/fs/xfs/libxfs/xfs_shared.h @@ -140,16 +140,6 @@ void xfs_log_get_max_trans_res(struct xfs_mount *mp, /* Transaction has locked the rtbitmap and rtsum inodes */ #define XFS_TRANS_RTBITMAP_LOCKED (1u << 9) -/* - * Field values for xfs_trans_mod_sb. - */ -#define XFS_TRANS_SB_ICOUNT 0x00000001 -#define XFS_TRANS_SB_IFREE 0x00000002 -#define XFS_TRANS_SB_FDBLOCKS 0x00000004 -#define XFS_TRANS_SB_RES_FDBLOCKS 0x00000008 -#define XFS_TRANS_SB_FREXTENTS 0x00000010 -#define XFS_TRANS_SB_RES_FREXTENTS 0x00000020 - /* * Here we centralize the specification of XFS meta-data buffer reference count * values. This determines how hard the buffer cache tries to hold onto the diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 4168ccf21068cb..ac88a38c6cd522 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -212,7 +212,7 @@ xfs_growfs_data_private( goto out_trans_cancel; if (id.nfree) - xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, id.nfree); + xfs_trans_mod_fdblocks(tp, id.nfree, false); error = xfs_growfs_data_update_sb(tp, nagcount, nb, nagimax); if (error) diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 994e5efedab20f..07f6008db322cb 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -838,7 +838,7 @@ xfs_growfs_rt_bmblock( xfs_rtbuf_cache_relse(&nargs); if (error) goto out_cancel; - xfs_trans_mod_sb(args.tp, XFS_TRANS_SB_FREXTENTS, freed_rtx); + xfs_trans_mod_frextents(args.tp, freed_rtx, false); error = xfs_growfs_rt_update_sb(args.tp, mp, nmp, freed_rtx); if (error) @@ -1335,9 +1335,7 @@ xfs_rtallocate( if (error) goto out_release; - xfs_trans_mod_sb(tp, wasdel ? - XFS_TRANS_SB_RES_FREXTENTS : XFS_TRANS_SB_FREXTENTS, - -(long)len); + xfs_trans_mod_frextents(tp, -(long)len, wasdel); *bno = xfs_rtx_to_rtb(args.mp, rtx); *blen = xfs_rtxlen_to_extlen(args.mp, len); diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 56505cb94f877d..fa133535235d4c 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -334,48 +334,43 @@ xfs_trans_alloc_empty( return xfs_trans_alloc(mp, &resv, 0, 0, XFS_TRANS_NO_WRITECOUNT, tpp); } -/* - * Record the indicated change to the given field for application - * to the file system's superblock when the transaction commits. - * For now, just store the change in the transaction structure. - * - * Mark the transaction structure to indicate that the superblock - * needs to be updated before committing. - * - * Because we may not be keeping track of allocated/free inodes and - * used filesystem blocks in the superblock, we do not mark the - * superblock dirty in this transaction if we modify these fields. - * We still need to update the transaction deltas so that they get - * applied to the incore superblock, but we don't want them to - * cause the superblock to get locked and logged if these are the - * only fields in the superblock that the transaction modifies. - */ void -xfs_trans_mod_sb( - xfs_trans_t *tp, - uint field, - int64_t delta) +xfs_trans_mod_icount( + struct xfs_trans *tp, + int64_t delta) +{ + tp->t_icount_delta += delta; + tp->t_flags |= XFS_TRANS_DIRTY; + if (!xfs_has_lazysbcount(tp->t_mountp)) + tp->t_flags |= XFS_TRANS_SB_DIRTY; +} + +void +xfs_trans_mod_ifree( + struct xfs_trans *tp, + int64_t delta) { - uint32_t flags = (XFS_TRANS_DIRTY|XFS_TRANS_SB_DIRTY); - xfs_mount_t *mp = tp->t_mountp; - - switch (field) { - case XFS_TRANS_SB_ICOUNT: - tp->t_icount_delta += delta; - if (xfs_has_lazysbcount(mp)) - flags &= ~XFS_TRANS_SB_DIRTY; - break; - case XFS_TRANS_SB_IFREE: - tp->t_ifree_delta += delta; - if (xfs_has_lazysbcount(mp)) - flags &= ~XFS_TRANS_SB_DIRTY; - break; - case XFS_TRANS_SB_FDBLOCKS: + tp->t_ifree_delta += delta; + tp->t_flags |= XFS_TRANS_DIRTY; + if (!xfs_has_lazysbcount(tp->t_mountp)) + tp->t_flags |= XFS_TRANS_SB_DIRTY; +} + +void +xfs_trans_mod_fdblocks( + struct xfs_trans *tp, + int64_t delta, + bool wasdel) +{ + struct xfs_mount *mp = tp->t_mountp; + + if (wasdel) { /* - * Track the number of blocks allocated in the transaction. - * Make sure it does not exceed the number reserved. If so, - * shutdown as this can lead to accounting inconsistency. + * The allocation has already been applied to the in-core + * counter, only apply it to the on-disk superblock. */ + tp->t_res_fdblocks_delta += delta; + } else { if (delta < 0) { tp->t_blk_res_used += (uint)-delta; if (tp->t_blk_res_used > tp->t_blk_res) @@ -396,55 +391,40 @@ xfs_trans_mod_sb( delta -= blkres_delta; } tp->t_fdblocks_delta += delta; - if (xfs_has_lazysbcount(mp)) - flags &= ~XFS_TRANS_SB_DIRTY; - break; - case XFS_TRANS_SB_RES_FDBLOCKS: - /* - * The allocation has already been applied to the - * in-core superblock's counter. This should only - * be applied to the on-disk superblock. - */ - tp->t_res_fdblocks_delta += delta; - if (xfs_has_lazysbcount(mp)) - flags &= ~XFS_TRANS_SB_DIRTY; - break; - case XFS_TRANS_SB_FREXTENTS: + } + + tp->t_flags |= XFS_TRANS_DIRTY; + if (!xfs_has_lazysbcount(mp)) + tp->t_flags |= XFS_TRANS_SB_DIRTY; +} + +void +xfs_trans_mod_frextents( + struct xfs_trans *tp, + int64_t delta, + bool wasdel) +{ + if (wasdel) { /* - * Track the number of blocks allocated in the - * transaction. Make sure it does not exceed the - * number reserved. + * The allocation has already been applied to the in-core + * counter, only apply it to the on-disk superblock. */ + ASSERT(delta < 0); + tp->t_res_frextents_delta += delta; + } else { if (delta < 0) { tp->t_rtx_res_used += (uint)-delta; ASSERT(tp->t_rtx_res_used <= tp->t_rtx_res); } tp->t_frextents_delta += delta; - break; - case XFS_TRANS_SB_RES_FREXTENTS: - /* - * The allocation has already been applied to the - * in-core superblock's counter. This should only - * be applied to the on-disk superblock. - */ - ASSERT(delta < 0); - tp->t_res_frextents_delta += delta; - break; - default: - ASSERT(0); - return; } - tp->t_flags |= flags; + tp->t_flags |= (XFS_TRANS_DIRTY | XFS_TRANS_SB_DIRTY); } /* - * xfs_trans_apply_sb_deltas() is called from the commit code - * to bring the superblock buffer into the current transaction - * and modify it as requested by earlier calls to xfs_trans_mod_sb(). - * - * For now we just look at each field allowed to change and change - * it if necessary. + * Called from the commit code to bring the superblock buffer into the current + * transaction and modify it as based on earlier calls to xfs_trans_mod_*(). */ STATIC void xfs_trans_apply_sb_deltas( diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index e5911cf09be444..a2cee42368bd25 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h @@ -162,7 +162,12 @@ int xfs_trans_reserve_more(struct xfs_trans *tp, unsigned int blocks, unsigned int rtextents); int xfs_trans_alloc_empty(struct xfs_mount *mp, struct xfs_trans **tpp); -void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t); +void xfs_trans_mod_icount(struct xfs_trans *tp, int64_t delta); +void xfs_trans_mod_ifree(struct xfs_trans *tp, int64_t delta); +void xfs_trans_mod_fdblocks(struct xfs_trans *tp, int64_t delta, + bool wasdel); +void xfs_trans_mod_frextents(struct xfs_trans *tp, int64_t delta, + bool wasdel); int xfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *target, struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags, diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index b368e13424c4f4..839eb1780d4694 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -288,7 +288,7 @@ xfs_trans_get_dqtrx( /* * Make the changes in the transaction structure. - * The moral equivalent to xfs_trans_mod_sb(). + * * We don't touch any fields in the dquot, so we don't care * if it's locked or not (most of the time it won't be). */