Patchwork [v2,15/17] raw-posix: detect XFS unwritten extents

login
register
mail settings
Submitter Paolo Bonzini
Date July 16, 2013, 4:29 p.m.
Message ID <1373992168-26043-16-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/259456/
State New
Headers show

Comments

Paolo Bonzini - July 16, 2013, 4:29 p.m.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/raw-posix.c | 3 +++
 1 file changed, 3 insertions(+)
Eric Blake - July 19, 2013, 8:10 p.m.
On 07/16/2013 10:29 AM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  block/raw-posix.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index d011cfd..1b41ea3 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -1128,6 +1128,9 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
>      } else {
>          data = f.fe.fe_logical;
>          hole = f.fe.fe_logical + f.fe.fe_length;
> +        if (f.fe.fe_flags & FIEMAP_EXTENT_UNWRITTEN) {
> +            ret |= BDRV_BLOCK_ZERO;
> +        }
>      }

Reviewed-by: Eric Blake <eblake@redhat.com>
Christoph Hellwig - Aug. 2, 2013, 3:05 p.m.
On Tue, Jul 16, 2013 at 06:29:26PM +0200, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

This isn't really XFS specific, at least ext4 and ocfs2 can report the same.

Patch

diff --git a/block/raw-posix.c b/block/raw-posix.c
index d011cfd..1b41ea3 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1128,6 +1128,9 @@  static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
     } else {
         data = f.fe.fe_logical;
         hole = f.fe.fe_logical + f.fe.fe_length;
+        if (f.fe.fe_flags & FIEMAP_EXTENT_UNWRITTEN) {
+            ret |= BDRV_BLOCK_ZERO;
+        }
     }
 
 #elif defined SEEK_HOLE && defined SEEK_DATA