aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2018-04-17 02:07:27 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2018-04-17 20:10:17 -0400
commit2c4306f719b083d17df2963bc761777576b8ad1b (patch)
treefd579007adad2959affe07da1770c588b204f548
parentb42db0860e13067fcc7cbfba3966c9e652668bbc (diff)
xfs: set format back to extents if xfs_bmap_extents_to_btree
If xfs_bmap_extents_to_btree fails in a mode where we call xfs_iroot_realloc(-1) to de-allocate the root, set the format back to extents. Otherwise we can assume we can dereference ifp->if_broot based on the XFS_DINODE_FMT_BTREE format, and crash. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199423 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 6a7c2f03ea11..040eeda8426f 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -725,12 +725,16 @@ xfs_bmap_extents_to_btree(
725 *logflagsp = 0; 725 *logflagsp = 0;
726 if ((error = xfs_alloc_vextent(&args))) { 726 if ((error = xfs_alloc_vextent(&args))) {
727 xfs_iroot_realloc(ip, -1, whichfork); 727 xfs_iroot_realloc(ip, -1, whichfork);
728 ASSERT(ifp->if_broot == NULL);
729 XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
728 xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); 730 xfs_btree_del_cursor(cur, XFS_BTREE_ERROR);
729 return error; 731 return error;
730 } 732 }
731 733
732 if (WARN_ON_ONCE(args.fsbno == NULLFSBLOCK)) { 734 if (WARN_ON_ONCE(args.fsbno == NULLFSBLOCK)) {
733 xfs_iroot_realloc(ip, -1, whichfork); 735 xfs_iroot_realloc(ip, -1, whichfork);
736 ASSERT(ifp->if_broot == NULL);
737 XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
734 xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); 738 xfs_btree_del_cursor(cur, XFS_BTREE_ERROR);
735 return -ENOSPC; 739 return -ENOSPC;
736 } 740 }