Skip to content

Commit

Permalink
Merge tag 'random-fixes-6.2_2022-11-30' of git://git.kernel.org/pub/s…
Browse files Browse the repository at this point in the history
…cm/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: Darrick J. Wong <[email protected]>

* 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
  • Loading branch information
Darrick J. Wong committed Nov 30, 2022
2 parents cd14f15 + 4c6dbfd commit 4b4d11b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions fs/xfs/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions fs/xfs/xfs_iomap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion fs/xfs/xfs_trans_ail.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/xfs_xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4b4d11b

Please sign in to comment.