Commit d551d7bb authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'xfs-fixes-6.16-rc7' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

Pull xfs fixes from Carlos Maiolino:
 "This contains mostly code clean up, refactoring and comments
  modification.

  The most important patch in this series is the last one that removes
  an unnecessary data structure allocation of xfs busy extents which
  might lead to a memory leak on the zoned allocator code"

* tag 'xfs-fixes-6.16-rc7' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  xfs: don't allocate the xfs_extent_busy structure for zoned RTGs
  xfs: remove the bt_bdev_file buftarg field
  xfs: rename the bt_bdev_* buftarg fields
  xfs: refactor xfs_calc_atomic_write_unit_max
  xfs: add a xfs_group_type_buftarg helper
  xfs: remove the call to sync_blockdev in xfs_configure_buftarg
  xfs: clean up the initial read logic in xfs_readsb
  xfs: replace strncpy with memcpy in xattr listing
parents d3d16f31 5948705a
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ xfs_group_free(

	xfs_defer_drain_free(&xg->xg_intents_drain);
#ifdef __KERNEL__
	if (xfs_group_has_extent_busy(xg->xg_mount, xg->xg_type))
		kfree(xg->xg_busy_extents);
#endif

@@ -189,9 +190,11 @@ xfs_group_insert(
	xg->xg_type = type;

#ifdef __KERNEL__
	if (xfs_group_has_extent_busy(mp, type)) {
		xg->xg_busy_extents = xfs_extent_busy_alloc();
		if (!xg->xg_busy_extents)
			return -ENOMEM;
	}
	spin_lock_init(&xg->xg_state_lock);
	xfs_hooks_init(&xg->xg_rmap_update_hooks);
#endif
@@ -210,6 +213,7 @@ xfs_group_insert(
out_drain:
	xfs_defer_drain_free(&xg->xg_intents_drain);
#ifdef __KERNEL__
	if (xfs_group_has_extent_busy(xg->xg_mount, xg->xg_type))
		kfree(xg->xg_busy_extents);
#endif
	return error;
+5 −10
Original line number Diff line number Diff line
@@ -1683,7 +1683,7 @@ xfs_free_buftarg(
	fs_put_dax(btp->bt_daxdev, btp->bt_mount);
	/* the main block device is closed by kill_block_super */
	if (btp->bt_bdev != btp->bt_mount->m_super->s_bdev)
		bdev_fput(btp->bt_bdev_file);
		bdev_fput(btp->bt_file);
	kfree(btp);
}

@@ -1712,8 +1712,8 @@ xfs_configure_buftarg_atomic_writes(
		max_bytes = 0;
	}

	btp->bt_bdev_awu_min = min_bytes;
	btp->bt_bdev_awu_max = max_bytes;
	btp->bt_awu_min = min_bytes;
	btp->bt_awu_max = max_bytes;
}

/* Configure a buffer target that abstracts a block device. */
@@ -1738,14 +1738,9 @@ xfs_configure_buftarg(
		return -EINVAL;
	}

	/*
	 * Flush the block device pagecache so our bios see anything dirtied
	 * before mount.
	 */
	if (bdev_can_atomic_write(btp->bt_bdev))
		xfs_configure_buftarg_atomic_writes(btp);

	return sync_blockdev(btp->bt_bdev);
	return 0;
}

int
@@ -1803,7 +1798,7 @@ xfs_alloc_buftarg(
	btp = kzalloc(sizeof(*btp), GFP_KERNEL | __GFP_NOFAIL);

	btp->bt_mount = mp;
	btp->bt_bdev_file = bdev_file;
	btp->bt_file = bdev_file;
	btp->bt_bdev = file_bdev(bdev_file);
	btp->bt_dev = btp->bt_bdev->bd_dev;
	btp->bt_daxdev = fs_dax_get_by_bdev(btp->bt_bdev, &btp->bt_dax_part_off,
+3 −5
Original line number Diff line number Diff line
@@ -94,7 +94,6 @@ void xfs_buf_cache_destroy(struct xfs_buf_cache *bch);
 */
struct xfs_buftarg {
	dev_t			bt_dev;
	struct file		*bt_bdev_file;
	struct block_device	*bt_bdev;
	struct dax_device	*bt_daxdev;
	struct file		*bt_file;
@@ -112,9 +111,9 @@ struct xfs_buftarg {
	struct percpu_counter	bt_readahead_count;
	struct ratelimit_state	bt_ioerror_rl;

	/* Atomic write unit values, bytes */
	unsigned int		bt_bdev_awu_min;
	unsigned int		bt_bdev_awu_max;
	/* Hardware atomic write unit values, bytes */
	unsigned int		bt_awu_min;
	unsigned int		bt_awu_max;

	/* built-in cache, if we're not using the perag one */
	struct xfs_buf_cache	bt_cache[];
@@ -375,7 +374,6 @@ extern void xfs_buftarg_wait(struct xfs_buftarg *);
extern void xfs_buftarg_drain(struct xfs_buftarg *);
int xfs_configure_buftarg(struct xfs_buftarg *btp, unsigned int sectorsize);

#define xfs_getsize_buftarg(buftarg)	block_size((buftarg)->bt_bdev)
#define xfs_readonly_buftarg(buftarg)	bdev_read_only((buftarg)->bt_bdev)

int xfs_buf_reverify(struct xfs_buf *bp, const struct xfs_buf_ops *ops);
+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) {
+8 −0
Original line number Diff line number Diff line
@@ -68,4 +68,12 @@ static inline void xfs_extent_busy_sort(struct list_head *list)
	list_sort(NULL, list, xfs_extent_busy_ag_cmp);
}

/*
 * Zoned RTGs don't need to track busy extents, as the actual block freeing only
 * happens by a zone reset, which forces out all transactions that touched the
 * to be reset zone first.
 */
#define xfs_group_has_extent_busy(mp, type) \
	((type) == XG_TYPE_AG || !xfs_has_zoned((mp)))

#endif /* __XFS_EXTENT_BUSY_H__ */
Loading