Commit e74d1fa6 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Carlos Maiolino
Browse files

xfs: add a xfs_group_type_buftarg helper



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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarCarlos Maiolino <cem@kernel.org>
parent d9b1e348
Loading
Loading
Loading
Loading
+7 −22
Original line number Diff line number Diff line
@@ -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) {
+17 −0
Original line number Diff line number Diff line
@@ -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__ */
+1 −2
Original line number Diff line number Diff line
@@ -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;