[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 2/9] block: handle invalid lseek returns gracefully
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 2/9] block: handle invalid lseek returns gracefully |
Date: |
Tue, 3 Apr 2018 18:33:53 +0200 |
From: Jeff Cody <address@hidden>
In commit 223a23c198787328ae75bc65d84edf5fde33c0b6, we implemented a
workaround in the gluster driver to handle invalid values returned for
SEEK_DATA or SEEK_HOLE.
In some instances, these same invalid values can be seen in the posix
file handler as well - for example, it has been reported on FUSE gluster
mounts.
Calling assert() for these invalid values is overly harsh; we can safely
return -EIO and allow this case to be treated as a "learned nothing"
case (e.g., D4 / H4, as commented in the code).
This patch does the same thing that 223a23c198787 did for gluster.c,
except in file-posix.c
Signed-off-by: Jeff Cody <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/file-posix.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index d7fb772c14..a2f6d8a8c8 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2114,7 +2114,12 @@ static int find_allocation(BlockDriverState *bs, off_t
start,
if (offs < 0) {
return -errno; /* D3 or D4 */
}
- assert(offs >= start);
+
+ if (offs < start) {
+ /* This is not a valid return by lseek(). We are safe to just return
+ * -EIO in this case, and we'll treat it like D4. */
+ return -EIO;
+ }
if (offs > start) {
/* D2: in hole, next data at offs */
@@ -2146,7 +2151,12 @@ static int find_allocation(BlockDriverState *bs, off_t
start,
if (offs < 0) {
return -errno; /* D1 and (H3 or H4) */
}
- assert(offs >= start);
+
+ if (offs < start) {
+ /* This is not a valid return by lseek(). We are safe to just return
+ * -EIO in this case, and we'll treat it like H4. */
+ return -EIO;
+ }
if (offs > start) {
/*
--
2.13.6
- [Qemu-block] [PULL 0/9] Block layer patches for 2.12.0-rc2, Kevin Wolf, 2018/04/03
- [Qemu-block] [PULL 2/9] block: handle invalid lseek returns gracefully,
Kevin Wolf <=
- [Qemu-block] [PULL 1/9] gluster: Fix blockdev-add with server.N.type=unix, Kevin Wolf, 2018/04/03
- [Qemu-block] [PULL 4/9] iotests: Update 186 after commit ac64273c66ab136c44043259162, Kevin Wolf, 2018/04/03
- [Qemu-block] [PULL 3/9] iotests: Update 051 and 186 after commit 1454509726719e0933c, Kevin Wolf, 2018/04/03
- [Qemu-block] [PULL 7/9] iotests: Test preallocated truncate of 2G image, Kevin Wolf, 2018/04/03
- [Qemu-block] [PULL 6/9] block/file-posix: Fix fully preallocated truncate, Kevin Wolf, 2018/04/03
- [Qemu-block] [PULL 8/9] qemu-iotests: Use ppc64 qemu_arch on ppc64le host, Kevin Wolf, 2018/04/03
- [Qemu-block] [PULL 9/9] iotests: Test abnormally large size in compressed cluster descriptor, Kevin Wolf, 2018/04/03
- [Qemu-block] [PULL 5/9] iotests: fix 208 for luks format, Kevin Wolf, 2018/04/03