From b9c1c9d6cec025f42ce86993306af6c881b20899 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 4 Aug 2014 21:16:23 -0400 Subject: [PATCH] libext2fs: retry a short write Signed-off-by: Theodore Ts'o --- lib/ext2fs/unix_io.c | 6 ++++++ 1 file changed, 6 insertions(+) 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; -- 2.47.2