]> xenbits.xensource.com Git - people/dstodden/blktap.git/commitdiff
CA-45316: Fix misleading VHD preallocation error.
authorDaniel Stodden <daniel.stodden@citrix.com>
Wed, 29 Sep 2010 09:59:20 +0000 (02:59 -0700)
committerDaniel Stodden <daniel.stodden@citrix.com>
Wed, 29 Sep 2010 09:59:20 +0000 (02:59 -0700)
Short writes are normally due to ENOSPC or EOD, so don't EIO. Then
save offset/count and report the actual errno for future generations.

Signed-off-by: Daniel Stodden <daniel.stodden@citrix.com>
drivers/block-vhd.c

index eeca5fac528834e9ddd6fc280dc9f30d40de0689..a498427f01aee32e961a7aaf7893a5b8efdd88e1 100644 (file)
@@ -1472,6 +1472,7 @@ allocate_block(struct vhd_state *s, uint32_t blk)
        int err, gap;
        uint64_t offset, size;
        struct vhd_bitmap *bm;
+       ssize_t count;
 
        ASSERT(bat_entry(s, blk) == DD_BLK_UNUSED);
 
@@ -1502,11 +1503,12 @@ allocate_block(struct vhd_state *s, uint32_t blk)
                return -errno;
        }
 
-       size = vhd_sectors_to_bytes(s->spb + s->bm_secs + gap);
-       err  = write(s->vhd.fd, vhd_zeros(size), size);
-       if (err != size) {
-               err = (err == -1 ? -errno : -EIO);
-               ERR(err, "write failed");
+       size  = vhd_sectors_to_bytes(s->spb + s->bm_secs + gap);
+       count = write(s->vhd.fd, vhd_zeros(size), size);
+       if (count != size) {
+               err = count < 0 ? -errno : -ENOSPC;
+               ERR(errno,
+                   "write failed (%zd, offset %"PRIu64")\n", count, offset);
                return err;
        }