qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 1/9] block: Add flags to BlockDriver.bdrv_co_truncate()


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [PATCH v4 1/9] block: Add flags to BlockDriver.bdrv_co_truncate()
Date: Tue, 21 Apr 2020 11:15:14 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

20.04.2020 16:32, Kevin Wolf wrote:
This adds a new BdrvRequestFlags parameter to the .bdrv_co_truncate()
driver callbacks, and a supported_truncate_flags field in
BlockDriverState that allows drivers to advertise support for request
flags in the context of truncate.

For now, we always pass 0 and no drivers declare support for any flag.

Signed-off-by: Kevin Wolf<address@hidden>
---

[..]

--- a/block/io.c
+++ b/block/io.c
@@ -3344,6 +3344,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, 
int64_t offset, bool exact,
      BlockDriverState *bs = child->bs;
      BlockDriver *drv = bs->drv;
      BdrvTrackedRequest req;
+    BdrvRequestFlags flags = 0;
      int64_t old_size, new_bytes;
      int ret;
@@ -3394,7 +3395,12 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
      }
if (drv->bdrv_co_truncate) {
-        ret = drv->bdrv_co_truncate(bs, offset, exact, prealloc, errp);
+        if (flags & ~bs->supported_truncate_flags) {
+            error_setg(errp, "Block driver does not support requested flags");
+            ret = -ENOTSUP;
+            goto out;
+        }
+        ret = drv->bdrv_co_truncate(bs, offset, exact, prealloc, flags, errp);
      } else if (bs->file && drv->is_filter) {
          ret = bdrv_co_truncate(bs->file, offset, exact, prealloc, errp);

Hmm, I think it's incorrect to silently omit flags here.. But in current patch 
flags are always 0, and you update this place in the following patch. OK

With updated block/file-win32.c:

Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>

--
Best regards,
Vladimir



reply via email to

[Prev in Thread] Current Thread [Next in Thread]