Commit 4b4d11bb authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

Merge tag 'random-fixes-6.2_2022-11-30' of...

Merge tag 'random-fixes-6.2_2022-11-30' of git://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux

 into xfs-6.2-mergeC

xfs: various fixes for 6.2

This is an assorted collection of bug fixes that have been bundled
together.  The first patch fixes a metadump corruption vector resulting
from a three-way race between a slow-running blkid process, the kernel
mounting, changing, and unmounting the fs, and xfs_db reading stale
block device pagecache contents.

The middle two patches address gcc warnings.

The final patch fixes a subtle corruption bug wherein making a delalloc
reservation on a filesystem with quotas enabled would sample the data
mapping, try to attach dquots, unlock the inode to attach the dquots,
relock the inode, and fail to reverify the sampled data.  If another
process updated the data mapping while the inode was unlocked, the
reservation would proceed with stale data and corrupt the data fork.

Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>

* tag 'random-fixes-6.2_2022-11-30' of git://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
  xfs: attach dquots to inode before reading data/cow fork mappings
  xfs: shut up -Wuninitialized in xfsaild_push
  xfs: use memcpy, not strncpy, to format the attr prefix during listxattr
  xfs: invalidate block device page cache during unmount
parents cd14f15b 4c6dbfd2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1945,6 +1945,7 @@ xfs_free_buftarg(
	list_lru_destroy(&btp->bt_lru);

	blkdev_issue_flush(btp->bt_bdev);
	invalidate_bdev(btp->bt_bdev);
	fs_put_dax(btp->bt_daxdev, btp->bt_mount);

	kmem_free(btp);
+4 −4
Original line number Diff line number Diff line
@@ -978,6 +978,10 @@ xfs_buffered_write_iomap_begin(

	ASSERT(!XFS_IS_REALTIME_INODE(ip));

	error = xfs_qm_dqattach(ip);
	if (error)
		return error;

	error = xfs_ilock_for_iomap(ip, flags, &lockmode);
	if (error)
		return error;
@@ -1081,10 +1085,6 @@ xfs_buffered_write_iomap_begin(
			allocfork = XFS_COW_FORK;
	}

	error = xfs_qm_dqattach_locked(ip, false);
	if (error)
		goto out_unlock;

	if (eof && offset + count > XFS_ISIZE(ip)) {
		/*
		 * Determine the initial size of the preallocation.
+3 −1
Original line number Diff line number Diff line
@@ -422,7 +422,7 @@ xfsaild_push(
	struct xfs_ail_cursor	cur;
	struct xfs_log_item	*lip;
	xfs_lsn_t		lsn;
	xfs_lsn_t		target;
	xfs_lsn_t		target = NULLCOMMITLSN;
	long			tout;
	int			stuck = 0;
	int			flushing = 0;
@@ -472,6 +472,8 @@ xfsaild_push(

	XFS_STATS_INC(mp, xs_push_ail);

	ASSERT(target != NULLCOMMITLSN);

	lsn = lip->li_lsn;
	while ((XFS_LSN_CMP(lip->li_lsn, target) <= 0)) {
		int	lock_result;
+1 −1
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ __xfs_xattr_put_listent(
		return;
	}
	offset = context->buffer + context->count;
	strncpy(offset, prefix, prefix_len);
	memcpy(offset, prefix, prefix_len);
	offset += prefix_len;
	strncpy(offset, (char *)name, namelen);			/* real name */
	offset += namelen;