]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - libxfs/xfs_refcount_btree.c
xfs: fix transaction leak on remote attr set/remove failure
[thirdparty/xfsprogs-dev.git] / libxfs / xfs_refcount_btree.c
index dd3b4d6a2bba5479b46da079741b2c046d357433..04eb0232c5cbfc586a435aee971a65a568dc7961 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "libxfs_priv.h"
 #include "xfs_fs.h"
@@ -40,8 +26,7 @@ xfs_refcountbt_dup_cursor(
        struct xfs_btree_cur    *cur)
 {
        return xfs_refcountbt_init_cursor(cur->bc_mp, cur->bc_tp,
-                       cur->bc_private.a.agbp, cur->bc_private.a.agno,
-                       cur->bc_private.a.dfops);
+                       cur->bc_private.a.agbp, cur->bc_private.a.agno);
 }
 
 STATIC void
@@ -78,15 +63,12 @@ xfs_refcountbt_alloc_block(
        struct xfs_alloc_arg    args;           /* block allocation args */
        int                     error;          /* error return value */
 
-       XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY);
-
        memset(&args, 0, sizeof(args));
        args.tp = cur->bc_tp;
        args.mp = cur->bc_mp;
        args.type = XFS_ALLOCTYPE_NEAR_BNO;
        args.fsbno = XFS_AGB_TO_FSB(cur->bc_mp, cur->bc_private.a.agno,
                        xfs_refc_block(args.mp));
-       args.firstblock = args.fsbno;
        xfs_rmap_ag_owner(&args.oinfo, XFS_RMAP_OWN_REFC);
        args.minlen = args.maxlen = args.prod = 1;
        args.resv = XFS_AG_RESV_METADATA;
@@ -97,7 +79,6 @@ xfs_refcountbt_alloc_block(
        trace_xfs_refcountbt_alloc_block(cur->bc_mp, cur->bc_private.a.agno,
                        args.agbno, 1);
        if (args.fsbno == NULLFSBLOCK) {
-               XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
                *stat = 0;
                return 0;
        }
@@ -108,12 +89,10 @@ xfs_refcountbt_alloc_block(
        be32_add_cpu(&agf->agf_refcount_blocks, 1);
        xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_REFCOUNT_BLOCKS);
 
-       XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
        *stat = 1;
        return 0;
 
 out_error:
-       XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
        return error;
 }
 
@@ -196,7 +175,6 @@ xfs_refcountbt_init_ptr_from_cur(
        struct xfs_agf          *agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp);
 
        ASSERT(cur->bc_private.a.agno == be32_to_cpu(agf->agf_seqno));
-       ASSERT(agf->agf_refcount_root != 0);
 
        ptr->s = agf->agf_refcount_root;
 }
@@ -289,6 +267,7 @@ const struct xfs_buf_ops xfs_refcountbt_buf_ops = {
        .name                   = "xfs_refcountbt",
        .verify_read            = xfs_refcountbt_read_verify,
        .verify_write           = xfs_refcountbt_write_verify,
+       .verify_struct          = xfs_refcountbt_verify,
 };
 
 STATIC int
@@ -341,8 +320,7 @@ xfs_refcountbt_init_cursor(
        struct xfs_mount        *mp,
        struct xfs_trans        *tp,
        struct xfs_buf          *agbp,
-       xfs_agnumber_t          agno,
-       struct xfs_defer_ops    *dfops)
+       xfs_agnumber_t          agno)
 {
        struct xfs_agf          *agf = XFS_BUF_TO_AGF(agbp);
        struct xfs_btree_cur    *cur;
@@ -362,7 +340,6 @@ xfs_refcountbt_init_cursor(
 
        cur->bc_private.a.agbp = agbp;
        cur->bc_private.a.agno = agno;
-       cur->bc_private.a.dfops = dfops;
        cur->bc_flags |= XFS_BTREE_CRC_BLOCKS;
 
        cur->bc_private.a.priv.refc.nr_ops = 0;
@@ -376,7 +353,6 @@ xfs_refcountbt_init_cursor(
  */
 int
 xfs_refcountbt_maxrecs(
-       struct xfs_mount        *mp,
        int                     blocklen,
        bool                    leaf)
 {
@@ -393,7 +369,7 @@ void
 xfs_refcountbt_compute_maxlevels(
        struct xfs_mount                *mp)
 {
-       mp->m_refc_maxlevels = xfs_btree_compute_maxlevels(mp,
+       mp->m_refc_maxlevels = xfs_btree_compute_maxlevels(
                        mp->m_refc_mnr, mp->m_sb.sb_agblocks);
 }
 
@@ -403,7 +379,7 @@ xfs_refcountbt_calc_size(
        struct xfs_mount        *mp,
        unsigned long long      len)
 {
-       return xfs_btree_calc_size(mp, mp->m_refc_mnr, len);
+       return xfs_btree_calc_size(mp->m_refc_mnr, len);
 }
 
 /*