* [PATCH] xfs: set format back to extents if xfs_bmap_extents_to_btree fails
@ 2018-04-17 4:26 Eric Sandeen
2018-04-17 6:03 ` Darrick J. Wong
2018-04-17 7:10 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Eric Sandeen @ 2018-04-17 4:26 UTC (permalink / raw)
To: linux-xfs; +Cc: wen.xu
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>
---
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 6a7c2f0..040eeda 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -725,12 +725,16 @@ static inline bool xfs_bmap_wants_extents(struct xfs_inode *ip, int whichfork)
*logflagsp = 0;
if ((error = xfs_alloc_vextent(&args))) {
xfs_iroot_realloc(ip, -1, whichfork);
+ ASSERT(ifp->if_broot == NULL);
+ XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
xfs_btree_del_cursor(cur, XFS_BTREE_ERROR);
return error;
}
if (WARN_ON_ONCE(args.fsbno == NULLFSBLOCK)) {
xfs_iroot_realloc(ip, -1, whichfork);
+ ASSERT(ifp->if_broot == NULL);
+ XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
xfs_btree_del_cursor(cur, XFS_BTREE_ERROR);
return -ENOSPC;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] xfs: set format back to extents if xfs_bmap_extents_to_btree fails
2018-04-17 4:26 [PATCH] xfs: set format back to extents if xfs_bmap_extents_to_btree fails Eric Sandeen
@ 2018-04-17 6:03 ` Darrick J. Wong
2018-04-17 7:10 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2018-04-17 6:03 UTC (permalink / raw)
To: Eric Sandeen; +Cc: linux-xfs, wen.xu
On Mon, Apr 16, 2018 at 11:26:12PM -0500, Eric Sandeen wrote:
> 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>
Looks ok, will test...
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 6a7c2f0..040eeda 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -725,12 +725,16 @@ static inline bool xfs_bmap_wants_extents(struct xfs_inode *ip, int whichfork)
> *logflagsp = 0;
> if ((error = xfs_alloc_vextent(&args))) {
> xfs_iroot_realloc(ip, -1, whichfork);
> + ASSERT(ifp->if_broot == NULL);
> + XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
> xfs_btree_del_cursor(cur, XFS_BTREE_ERROR);
> return error;
> }
>
> if (WARN_ON_ONCE(args.fsbno == NULLFSBLOCK)) {
> xfs_iroot_realloc(ip, -1, whichfork);
> + ASSERT(ifp->if_broot == NULL);
> + XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
> xfs_btree_del_cursor(cur, XFS_BTREE_ERROR);
> return -ENOSPC;
> }
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] xfs: set format back to extents if xfs_bmap_extents_to_btree fails
2018-04-17 4:26 [PATCH] xfs: set format back to extents if xfs_bmap_extents_to_btree fails Eric Sandeen
2018-04-17 6:03 ` Darrick J. Wong
@ 2018-04-17 7:10 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2018-04-17 7:10 UTC (permalink / raw)
To: Eric Sandeen; +Cc: linux-xfs, wen.xu
On Mon, Apr 16, 2018 at 11:26:12PM -0500, Eric Sandeen wrote:
> 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>
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-17 7:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-17 4:26 [PATCH] xfs: set format back to extents if xfs_bmap_extents_to_btree fails Eric Sandeen
2018-04-17 6:03 ` Darrick J. Wong
2018-04-17 7:10 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).