qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 for-2.2 3/3] raw-posix: The SEEK_HOLE code is


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v3 for-2.2 3/3] raw-posix: The SEEK_HOLE code is flawed, rewrite it
Date: Mon, 17 Nov 2014 11:33:08 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 2014-11-17 at 11:18, Markus Armbruster wrote:
On systems where SEEK_HOLE in a trailing hole seeks to EOF (Solaris,
but not Linux), try_seek_hole() reports trailing data instead.

Additionally, unlikely lseek() failures are treated badly:

* When SEEK_HOLE fails, try_seek_hole() reports trailing data.  For
   -ENXIO, there's in fact a trailing hole.  Can happen only when
   something truncated the file since we opened it.

* When SEEK_HOLE succeeds, SEEK_DATA fails, and SEEK_END succeeds,
   then try_seek_hole() reports a trailing hole.  This is okay only
   when SEEK_DATA failed with -ENXIO (which means the non-trailing hole
   found by SEEK_HOLE has since become trailing somehow).  For other
   failures (unlikely), it's wrong.

* When SEEK_HOLE succeeds, SEEK_DATA fails, SEEK_END fails (unlikely),
   then try_seek_hole() reports bogus data [-1,start), which its caller
   raw_co_get_block_status() turns into zero sectors of data.  Could
   theoretically lead to infinite loops in code that attempts to scan
   data vs. hole forward.

Rewrite from scratch, with very careful comments.

Signed-off-by: Markus Armbruster <address@hidden>
---
  block/raw-posix.c | 111 +++++++++++++++++++++++++++++++++++++++++-------------
  1 file changed, 85 insertions(+), 26 deletions(-)

Reviewed-by: Max Reitz <address@hidden>



reply via email to

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