Skip to contentSkip to conversation

xfs: add missing error check in xfs_prepare_shift()

PATCH In review Brian Foster 4 participants 4 messages Apr 26, 2019 – Apr 28, 2019 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: add missing error check in xfs_prepare_shift()

xfs_prepare_shift() fails to check the error return from xfs_flush_unmap_range(). If the latter fails, that could lead to an insert/collapse range operation over a delalloc range, which is not supported.

Add an error check and return appropriately. This is reproduced rarely by generic/475.

---
 fs/xfs/xfs_bmap_util.c | 2 ++
 1 file changed, 2 insertions(+)
fs/xfs/xfs_bmap_util.c +2 -0
index 2db43ff4f8b5..06d07f1e310b 100644
@@ -1193,6 +1193,8 @@ xfs_prepare_shift(
 	 * about to shift down every extent from offset to EOF.
 	 */
 	error = xfs_flush_unmap_range(ip, offset, XFS_ISIZE(ip));
+	if (error)
+		return error;
 
 	/*
 	 * Clean out anything hanging around in the cow fork now that
Signature · 1 line
2.17.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Brian Foster

xfs_prepare_shift() fails to check the error return from xfs_flush_unmap_range(). If the latter fails, that could lead to an insert/collapse range operation over a delalloc range, which is not supported.

Add an error check and return appropriately. This is reproduced rarely by generic/475.

Looks ok,

--D

Quoted 20 lines
---
 fs/xfs/xfs_bmap_util.c | 2 ++
 1 file changed, 2 insertions(+)
fs/xfs/xfs_bmap_util.c +2 -0
index 2db43ff4f8b5..06d07f1e310b 100644
@@ -1193,6 +1193,8 @@ xfs_prepare_shift(
 	 * about to shift down every extent from offset to EOF.
 	 */
 	error = xfs_flush_unmap_range(ip, offset, XFS_ISIZE(ip));
+	if (error)
+		return error;
 
 	/*
 	 * Clean out anything hanging around in the cow fork now that
Signature · 1 line
2.17.2
Reviewed-by on v1 1/1
#2 lore raw
In reply to Brian Foster

Looks ok to me. You can add my review:

Quoted 27 lines · Brian Foster

xfs_prepare_shift() fails to check the error return from xfs_flush_unmap_range(). If the latter fails, that could lead to an insert/collapse range operation over a delalloc range, which is not supported.

Add an error check and return appropriately. This is reproduced rarely by generic/475.

---
  fs/xfs/xfs_bmap_util.c | 2 ++
  1 file changed, 2 insertions(+)
fs/xfs/xfs_bmap_util.c +2 -0
index 2db43ff4f8b5..06d07f1e310b 100644
@@ -1193,6 +1193,8 @@ xfs_prepare_shift(
  	 * about to shift down every extent from offset to EOF.
  	 */
  	error = xfs_flush_unmap_range(ip, offset, XFS_ISIZE(ip));
+	if (error)
+		return error;
 
  	/*
  	 * Clean out anything hanging around in the cow fork now that
Reviewed-by on v1 1/1
#3 lore raw
In reply to Brian Foster
Quoted 18 lines · Brian Foster

xfs_prepare_shift() fails to check the error return from xfs_flush_unmap_range(). If the latter fails, that could lead to an insert/collapse range operation over a delalloc range, which is not supported.

Add an error check and return appropriately. This is reproduced rarely by generic/475.

---
 fs/xfs/xfs_bmap_util.c | 2 ++
 1 file changed, 2 insertions(+)
fs/xfs/xfs_bmap_util.c +0 -0
index 2db43ff4f8b5..06d07f1e310b 100644

fs/xfs/xfs_bmap_util.c xfs_prepare_shift( · line 1197

Quoted 5 lines
fs/xfs/xfs_bmap_util.c +2 -0
@@ -1193,6 +1193,8 @@ xfs_prepare_shift(
 	 * about to shift down every extent from offset to EOF.
 	 */
 	error = xfs_flush_unmap_range(ip, offset, XFS_ISIZE(ip));
+	if (error)
+		return error;

Urk. My fault.

Fixes 7f9f71be84bc ("xfs: extent shifting doesn't fully invalidate page cache")

Not sure how I screwed up that simple change so obviously and didn't notice it.

Fix for the fix looks good.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]