From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>,
John Garry <john.g.garry@oracle.com>,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH 3/7] xfs: add a xfs_group_type_buftarg helper
Date: Tue, 1 Jul 2025 09:43:53 -0700 [thread overview]
Message-ID: <20250701164353.GG10009@frogsfrogsfrogs> (raw)
In-Reply-To: <20250701104125.1681798-4-hch@lst.de>
On Tue, Jul 01, 2025 at 12:40:37PM +0200, Christoph Hellwig wrote:
> Generalize the xfs_group_type helper in the discard code to return a buftarg
> and move it to xfs_mount.h, and use the result in xfs_dax_notify_dev_failure.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks good to me,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_discard.c | 29 +++++++----------------------
> fs/xfs/xfs_mount.h | 17 +++++++++++++++++
> fs/xfs/xfs_notify_failure.c | 3 +--
> 3 files changed, 25 insertions(+), 24 deletions(-)
>
> diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
> index 94d0873bcd62..603d51365645 100644
> --- a/fs/xfs/xfs_discard.c
> +++ b/fs/xfs/xfs_discard.c
> @@ -103,24 +103,6 @@ xfs_discard_endio(
> bio_put(bio);
> }
>
> -static inline struct block_device *
> -xfs_group_bdev(
> - const struct xfs_group *xg)
> -{
> - struct xfs_mount *mp = xg->xg_mount;
> -
> - switch (xg->xg_type) {
> - case XG_TYPE_AG:
> - return mp->m_ddev_targp->bt_bdev;
> - case XG_TYPE_RTG:
> - return mp->m_rtdev_targp->bt_bdev;
> - default:
> - ASSERT(0);
> - break;
> - }
> - return NULL;
> -}
> -
> /*
> * Walk the discard list and issue discards on all the busy extents in the
> * list. We plug and chain the bios so that we only need a single completion
> @@ -138,11 +120,14 @@ xfs_discard_extents(
>
> blk_start_plug(&plug);
> list_for_each_entry(busyp, &extents->extent_list, list) {
> - trace_xfs_discard_extent(busyp->group, busyp->bno,
> - busyp->length);
> + struct xfs_group *xg = busyp->group;
> + struct xfs_buftarg *btp =
> + xfs_group_type_buftarg(xg->xg_mount, xg->xg_type);
> +
> + trace_xfs_discard_extent(xg, busyp->bno, busyp->length);
>
> - error = __blkdev_issue_discard(xfs_group_bdev(busyp->group),
> - xfs_gbno_to_daddr(busyp->group, busyp->bno),
> + error = __blkdev_issue_discard(btp->bt_bdev,
> + xfs_gbno_to_daddr(xg, busyp->bno),
> XFS_FSB_TO_BB(mp, busyp->length),
> GFP_KERNEL, &bio);
> if (error && error != -EOPNOTSUPP) {
> diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
> index d85084f9f317..97de44c32272 100644
> --- a/fs/xfs/xfs_mount.h
> +++ b/fs/xfs/xfs_mount.h
> @@ -802,4 +802,21 @@ static inline void xfs_mod_sb_delalloc(struct xfs_mount *mp, int64_t delta)
> int xfs_set_max_atomic_write_opt(struct xfs_mount *mp,
> unsigned long long new_max_bytes);
>
> +static inline struct xfs_buftarg *
> +xfs_group_type_buftarg(
> + struct xfs_mount *mp,
> + enum xfs_group_type type)
> +{
> + switch (type) {
> + case XG_TYPE_AG:
> + return mp->m_ddev_targp;
> + case XG_TYPE_RTG:
> + return mp->m_rtdev_targp;
> + default:
> + ASSERT(0);
> + break;
> + }
> + return NULL;
> +}
> +
> #endif /* __XFS_MOUNT_H__ */
> diff --git a/fs/xfs/xfs_notify_failure.c b/fs/xfs/xfs_notify_failure.c
> index 3545dc1d953c..42e9c72b85c0 100644
> --- a/fs/xfs/xfs_notify_failure.c
> +++ b/fs/xfs/xfs_notify_failure.c
> @@ -253,8 +253,7 @@ xfs_dax_notify_dev_failure(
> return -EOPNOTSUPP;
> }
>
> - error = xfs_dax_translate_range(type == XG_TYPE_RTG ?
> - mp->m_rtdev_targp : mp->m_ddev_targp,
> + error = xfs_dax_translate_range(xfs_group_type_buftarg(mp, type),
> offset, len, &daddr, &bblen);
> if (error)
> return error;
> --
> 2.47.2
>
>
next prev parent reply other threads:[~2025-07-01 16:43 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-01 10:40 misc cleanups v2 Christoph Hellwig
2025-07-01 10:40 ` [PATCH 1/7] xfs: clean up the initial read logic in xfs_readsb Christoph Hellwig
2025-07-01 16:43 ` Darrick J. Wong
2025-07-01 10:40 ` [PATCH 2/7] xfs: remove the call to sync_blockdev in xfs_configure_buftarg Christoph Hellwig
2025-07-01 10:53 ` John Garry
2025-07-01 11:03 ` John Garry
2025-07-03 13:42 ` Christoph Hellwig
2025-07-01 10:40 ` [PATCH 3/7] xfs: add a xfs_group_type_buftarg helper Christoph Hellwig
2025-07-01 11:05 ` John Garry
2025-07-01 16:43 ` Darrick J. Wong [this message]
2025-07-01 10:40 ` [PATCH 4/7] xfs: refactor xfs_calc_atomic_write_unit_max Christoph Hellwig
2025-07-01 16:53 ` Darrick J. Wong
2025-07-01 10:40 ` [PATCH 5/7] xfs: rename the bt_bdev_* buftarg fields Christoph Hellwig
2025-07-01 10:54 ` John Garry
2025-07-01 16:45 ` Darrick J. Wong
2025-07-01 10:40 ` [PATCH 6/7] xfs: remove the bt_bdev_file buftarg field Christoph Hellwig
2025-07-01 11:09 ` John Garry
2025-07-01 16:46 ` Darrick J. Wong
2025-07-01 10:40 ` [PATCH 7/7] xfs: remove the bt_meta_sectorsize field in struct buftarg Christoph Hellwig
2025-07-01 16:51 ` Darrick J. Wong
2025-07-01 22:55 ` Dave Chinner
2025-07-03 13:44 ` 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=20250701164353.GG10009@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=hch@lst.de \
--cc=john.g.garry@oracle.com \
--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;
as well as URLs for NNTP newsgroup(s).