From: Theodore Ts'o Date: Tue, 5 Aug 2014 01:16:23 +0000 (-0400) Subject: libext2fs: retry a short write X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fretry-write;p=thirdparty%2Fe2fsprogs.git libext2fs: retry a short write Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 0dd149014..79be8ebca 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -232,8 +232,14 @@ static errcode_t raw_write_blk(io_channel channel, if ((channel->align == 0) || (IS_ALIGNED(buf, channel->align) && IS_ALIGNED(size, channel->align))) { + retry: actual = write(data->dev, buf, size); if (actual != size) { + if (actual > 0 && (actual % 4096) == 0) { + buf += actual; + size -= actual; + goto retry; + } short_write: retval = EXT2_ET_SHORT_WRITE; goto error_out;