Patchwork [RFC,02/19] block: Detect unaligned length in bdrv_qiov_is_aligned()

login
register
mail settings
Submitter Kevin Wolf
Date Dec. 6, 2013, 5:22 p.m.
Message ID <1386350580-5666-3-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/298121/
State New
Headers show

Comments

Kevin Wolf - Dec. 6, 2013, 5:22 p.m.
For an O_DIRECT request to succeed, it's not only necessary that all
base addresses in the qiov are aligned, but also that each lengh in it
is aligned.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c | 3 +++
 1 file changed, 3 insertions(+)
Eric Blake - Dec. 6, 2013, 7:12 p.m.
On 12/06/2013 10:22 AM, Kevin Wolf wrote:
> For an O_DIRECT request to succeed, it's not only necessary that all
> base addresses in the qiov are aligned, but also that each lengh in it

s/lengh/length/

> is aligned.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/block.c b/block.c
> index 382ea71..613201b 100644
> --- a/block.c
> +++ b/block.c
> @@ -4349,6 +4349,9 @@ bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov)
>          if ((uintptr_t) qiov->iov[i].iov_base % bs->buffer_alignment) {
>              return false;
>          }
> +        if (qiov->iov[i].iov_len % bs->buffer_alignment) {
> +            return false;
> +        }
>      }
>  
>      return true;
>

Patch

diff --git a/block.c b/block.c
index 382ea71..613201b 100644
--- a/block.c
+++ b/block.c
@@ -4349,6 +4349,9 @@  bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov)
         if ((uintptr_t) qiov->iov[i].iov_base % bs->buffer_alignment) {
             return false;
         }
+        if (qiov->iov[i].iov_len % bs->buffer_alignment) {
+            return false;
+        }
     }
 
     return true;