public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>,
	Chandan Babu R <chandan.babu@oracle.com>,
	"Darrick J. Wong" <djwong@kernel.org>,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH 3/9] xfs: split xfs_mod_freecounter
Date: Tue, 20 Feb 2024 08:28:21 +0100	[thread overview]
Message-ID: <20240220072821.GA10025@lst.de> (raw)
In-Reply-To: <ZdPiaP+tApjr4K+M@dread.disaster.area>

On Tue, Feb 20, 2024 at 10:21:12AM +1100, Dave Chinner wrote:
> I don't think these hunks are correct. blkdelta and rtxdelta can be
> negative - they are int64_t, and they are set via
> xfs_trans_mod_sb(). e.g. in xfs_ag_resv_alloc_extent() we do:
> 
> 	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);
>                 return;
>         }
> 
> Which passes a negative delta to xfs_trans_mod_sb() and adds it to
> tp->t_fdblocks_delta. So that field can hold a negative number, and
> now we pass a negative int64_t to xfs_add_fdblocks() as an unsigned
> uint64_t.....

This area is rather subtle.

For XFS_TRANS_SB_FDBLOCKS, xfs_trans_mod_sb expects enough t_blk_res to
be held to at least balance out the t_fdblocks_delta value, i.e.
xfs_trans_unreserve_and_mod_sb always starts out with a positive value
due to the t_blk_res, and then decrements the actually used block
allocation in t_fdblocks_delta, and then still must end up with 0 or a
positive value, and if a positive value is left it "unreserves" the
reservation per the function name.  Same for the rtextent version.

So we should be fine here, but the code could really use documentation,
a few more asserts and a slightly different structure that makes this
more obvious.  I'll throw in a patch for that.

  reply	other threads:[~2024-02-20  7:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-19  6:34 bring back RT delalloc support Christoph Hellwig
2024-02-19  6:34 ` [PATCH 1/9] xfs: make XFS_TRANS_LOWMODE match the other XFS_TRANS_ definitions Christoph Hellwig
2024-02-19  6:34 ` [PATCH 2/9] xfs: move RT inode locking out of __xfs_bunmapi Christoph Hellwig
2024-02-19 23:55   ` Dave Chinner
2024-02-20  5:10     ` Christoph Hellwig
2024-02-19  6:34 ` [PATCH 3/9] xfs: split xfs_mod_freecounter Christoph Hellwig
2024-02-19 23:21   ` Dave Chinner
2024-02-20  7:28     ` Christoph Hellwig [this message]
2024-02-20 16:08       ` Christoph Hellwig
2024-02-21  0:00         ` Dave Chinner
2024-02-19  6:34 ` [PATCH 4/9] xfs: reinstate RT support in xfs_bmapi_reserve_delalloc Christoph Hellwig
2024-02-19  6:34 ` [PATCH 5/9] xfs: cleanup fdblock/frextent accounting in xfs_bmap_del_extent_delay Christoph Hellwig
2024-02-19  6:34 ` [PATCH 6/9] xfs: support RT inodes in xfs_mod_delalloc Christoph Hellwig
2024-02-19 23:30   ` Dave Chinner
2024-02-20  5:14     ` Christoph Hellwig
2024-02-19  6:34 ` [PATCH 7/9] xfs: look at m_frextents in xfs_iomap_prealloc_size for RT allocations Christoph Hellwig
2024-02-19  6:34 ` [PATCH 8/9] xfs: stop the steal (of data blocks for RT indirect blocks) Christoph Hellwig
2024-02-19 23:47   ` Dave Chinner
2024-02-20  5:13     ` Christoph Hellwig
2024-02-19  6:34 ` [PATCH 9/9] xfs: reinstate delalloc for RT inodes (if sb_rextsize == 1) Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240220072821.GA10025@lst.de \
    --to=hch@lst.de \
    --cc=chandan.babu@oracle.com \
    --cc=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox