xen: fix qdisk BLKIF_OP_DISCARD for 32/64 word size mix
PATCH 1/1 xen: fix qdisk BLKIF_OP_DISCARD for 32/64 word size mix
In case the word size of the domU and qemu running the qdisk backend differ BLKIF_OP_DISCARD will not work reliably, as the request structure in the ring have different layouts for different word size.
Correct this by copying the request structure in case of different word size element by element in the BLKIF_OP_DISCARD case, too.
--- hw/block/xen_blkif.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
hw/block/xen_blkif.h +18 -2
@@ -26,6 +26,14 @@ struct blkif_x86_32_request {blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST ]; }; +struct blkif_x86_32_request_discard { +uint8_t operation;/* BLKIF_OP_DISCARD */ +uint8_t flag;/* nr_segments in request struct */ +blkif_vdev_t handle;/* only for read/write requests */ +uint64_t id;/* private guest value, echoed in resp */ +blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ +uint64_t nr_sectors;/* # of contiguous sectors to discard */ +};struct blkif_x86_32_response {uint64_t id;/* copied from request */ uint8_t operation;/* copied from request */
@@ -44,6 +52,14 @@ struct blkif_x86_64_request {blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST ]; }; +struct blkif_x86_64_request_discard { +uint8_t operation;/* BLKIF_OP_DISCARD */ +uint8_t flag;/* nr_segments in request struct */ +blkif_vdev_t handle;/* only for read/write requests */ +uint64_t __attribute__((__aligned__ (8 ))) id; +blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ +uint64_t nr_sectors;/* # of contiguous sectors to discard */ +};struct blkif_x86_64_response {uint64_t __attribute__((__aligned__ (8 ))) id;uint8_t operation;/* copied from request */
@@ -82,7 +98,7 @@ static inline void blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque/* Prevent the compiler from using src->... instead. */ barrier ();if (dst->operation ==BLKIF_OP_DISCARD ) { -struct blkif_request_discard *s = (void *)src; +struct blkif_x86_32_request_discard *s = (void *)src;struct blkif_request_discard *d = (void *)dst; d->nr_sectors = s->nr_sectors;return ;
@@ -105,7 +121,7 @@ static inline void blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_reque/* Prevent the compiler from using src->... instead. */ barrier ();if (dst->operation ==BLKIF_OP_DISCARD ) { -struct blkif_request_discard *s = (void *)src; +struct blkif_x86_64_request_discard *s = (void *)src;struct blkif_request_discard *d = (void *)dst; d->nr_sectors = s->nr_sectors;return ;
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.06.16 at 12:02, <[email protected]> wrote:
In case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>
With the indentation (tabs vs blanks) fixed
And maybe ...
hw/block/xen_blkif.h static inline void blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque · line 101
Quoted 6 lines
hw/block/xen_blkif.h +1
-1@@ -82,7 +98,7 @@ static inline void blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque/* Prevent the compiler from using src->... instead. */ barrier ();if (dst->operation ==BLKIF_OP_DISCARD ) { -struct blkif_request_discard *s = (void *)src; +struct blkif_x86_32_request_discard *s = (void *)src;
... it would also be worth adding const here and ...
hw/block/xen_blkif.h static inline void blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_reque · line 124
Quoted 6 lines
hw/block/xen_blkif.h +1
-1@@ -105,7 +121,7 @@ static inline void blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_reque/* Prevent the compiler from using src->... instead. */ barrier ();if (dst->operation ==BLKIF_OP_DISCARD ) { -struct blkif_request_discard *s = (void *)src; +struct blkif_x86_64_request_discard *s = (void *)src;
... here.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.06.16 at 12:02, <[email protected]> wrote:
In case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>
With the indentation (tabs vs blanks) fixed
And maybe ...
hw/block/xen_blkif.h static inline void blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque · line 101
Quoted 6 lines
hw/block/xen_blkif.h +1
-1@@ -82,7 +98,7 @@ static inline void blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque/* Prevent the compiler from using src->... instead. */ barrier ();if (dst->operation ==BLKIF_OP_DISCARD ) { -struct blkif_request_discard *s = (void *)src; +struct blkif_x86_32_request_discard *s = (void *)src;
... it would also be worth adding const here and ...
hw/block/xen_blkif.h static inline void blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_reque · line 124
Quoted 6 lines
hw/block/xen_blkif.h +1
-1@@ -105,7 +121,7 @@ static inline void blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_reque/* Prevent the compiler from using src->... instead. */ barrier ();if (dst->operation ==BLKIF_OP_DISCARD ) { -struct blkif_request_discard *s = (void *)src; +struct blkif_x86_64_request_discard *s = (void *)src;
... here.
Jan
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.06.16 at 12:02, <[email protected]> wrote:
In case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>With the indentation (tabs vs blanks) fixed
Hmm, qemu coding style is to use blanks. I could:
a) leave the patch as is (changed lines indented with blanks)
b) use tabs to indent (style of the modified file up to now)
c) change the style of the file in this patch
d) change the style of the file in a separate patch
Any preferences?
Quoted 13 lines
Reviewed-by Jan Beulich <[email protected]>And maybe ...
hw/block/xen_blkif.h static inline void blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque · line 101
Quoted 6 lines
hw/block/xen_blkif.h +1
-1@@ -82,7 +98,7 @@ static inline void blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque/* Prevent the compiler from using src->... instead. */ barrier ();if (dst->operation ==BLKIF_OP_DISCARD ) { -struct blkif_request_discard *s = (void *)src; +struct blkif_x86_32_request_discard *s = (void *)src;... it would also be worth adding const here and ...
Quoted 8 lines
hw/block/xen_blkif.h static inline void blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_reque · line 124
Quoted 6 lines
hw/block/xen_blkif.h +1
-1@@ -105,7 +121,7 @@ static inline void blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_reque/* Prevent the compiler from using src->... instead. */ barrier ();if (dst->operation ==BLKIF_OP_DISCARD ) { -struct blkif_request_discard *s = (void *)src; +struct blkif_x86_64_request_discard *s = (void *)src;... here.
Okay.
Juergen
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 16.06.16 at 13:04, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.06.16 at 12:02, <[email protected]> wrote:
In case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>With the indentation (tabs vs blanks) fixed
Quoted 7 lines
Hmm, qemu coding style is to use blanks. I could:
a) leave the patch as is (changed lines indented with blanks)
b) use tabs to indent (style of the modified file up to now)
c) change the style of the file in this patch
d) change the style of the file in a separate patchAny preferences?
I'd say a) is not an option, but beyond that I think this needs to be answered by the qemu maintainers.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 16.06.16 at 13:04, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.06.16 at 12:02, <[email protected]> wrote:
In case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>With the indentation (tabs vs blanks) fixed
Quoted 7 lines
Hmm, qemu coding style is to use blanks. I could:
a) leave the patch as is (changed lines indented with blanks)
b) use tabs to indent (style of the modified file up to now)
c) change the style of the file in this patch
d) change the style of the file in a separate patchAny preferences?
I'd say a) is not an option, but beyond that I think this needs to be answered by the qemu maintainers.
Jan
Quoted 13 lines · Juergen Gross
Quoted 11 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.06.16 at 12:02, <[email protected]> wrote:
In case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>With the indentation (tabs vs blanks) fixed
Quoted 7 lines
Hmm, qemu coding style is to use blanks. I could:
a) leave the patch as is (changed lines indented with blanks)
b) use tabs to indent (style of the modified file up to now)
c) change the style of the file in this patch
d) change the style of the file in a separate patchAny preferences?
I would go with d), fixing it to conform with QEMU coding style.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 13 lines · Juergen Gross
Quoted 11 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.06.16 at 12:02, <[email protected]> wrote:
In case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>With the indentation (tabs vs blanks) fixed
Quoted 7 lines
Hmm, qemu coding style is to use blanks. I could:
a) leave the patch as is (changed lines indented with blanks)
b) use tabs to indent (style of the modified file up to now)
c) change the style of the file in this patch
d) change the style of the file in a separate patchAny preferences?
I would go with d), fixing it to conform with QEMU coding style.
Quoted 20 lines · Stefano Stabellini
Quoted 19 lines · Juergen Gross
Quoted 11 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.06.16 at 12:02, <[email protected]> wrote:
In case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>With the indentation (tabs vs blanks) fixed
Hmm, qemu coding style is to use blanks. I could:
a) leave the patch as is (changed lines indented with blanks)
b) use tabs to indent (style of the modified file up to now)
c) change the style of the file in this patch
d) change the style of the file in a separate patch
Quoted 3 lines
Quoted 1 line
Any preferences?
I would go with d), fixing it to conform with QEMU coding style.
As I'm about to resync the header with the Linux one as Paul suggested it will be more like c). :-)
Juergen
Quoted 21 lines · Juergen Gross
Quoted 20 lines · Stefano Stabellini
Quoted 19 lines · Juergen Gross
Quoted 11 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.06.16 at 12:02, <[email protected]> wrote:
In case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>With the indentation (tabs vs blanks) fixed
Hmm, qemu coding style is to use blanks. I could:
a) leave the patch as is (changed lines indented with blanks)
b) use tabs to indent (style of the modified file up to now)
c) change the style of the file in this patch
d) change the style of the file in a separate patch
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Any preferences?
I would go with d), fixing it to conform with QEMU coding style.
As I'm about to resync the header with the Linux one as Paul suggested it will be more like c). :-)
That's not a good idea, as you probably have noticed by now on the other thread. This patch is OK, you just need to fix the intendation separately.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 20 lines · Stefano Stabellini
Quoted 19 lines · Juergen Gross
Quoted 11 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.06.16 at 12:02, <[email protected]> wrote:
In case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>With the indentation (tabs vs blanks) fixed
Hmm, qemu coding style is to use blanks. I could:
a) leave the patch as is (changed lines indented with blanks)
b) use tabs to indent (style of the modified file up to now)
c) change the style of the file in this patch
d) change the style of the file in a separate patch
Quoted 3 lines
Quoted 1 line
Any preferences?
I would go with d), fixing it to conform with QEMU coding style.
As I'm about to resync the header with the Linux one as Paul suggested it will be more like c). :-)
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 10 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Juergen Gross
Sent: 16 June 2016 11:02
To: [email protected]; [email protected]
Cc: Anthony Perard; Juergen Gross; [email protected]; [email protected]
Subject: [Xen-devel] [PATCH] xen: fix qdiskBLKIF_OP_DISCARDfor 32/64 word size mix
Quoted 8 lines
In case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>
Would it not be better to re-import the canonical blkif header as a whole rather than cherry-picking like this? You'd need to post-process to maintain style and possibly change some names for compatibility etc. but probably nothing beyond what indent and a simple [s]ed script can do. I did broadly the same thing to re-import the netif header into Linux recently.
Paul
Quoted 70 lines
--- hw/block/xen_blkif.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)hw/block/xen_blkif.h +8
-0@@ -26,6 +26,14 @@ struct blkif_x86_32_request {blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST ]; }; +struct blkif_x86_32_request_discard { +uint8_t operation;/* BLKIF_OP_DISCARD */ +uint8_t flag;/* nr_segments in request struct */ +blkif_vdev_t handle;/* only for read/write requests */ +uint64_t id;/* private guest value, echoed in resp */ +blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ +uint64_t nr_sectors;/* # of contiguous sectors to discard */ +};struct blkif_x86_32_response {hw/block/xen_blkif.h +8
-0uint64_t id;/* copied from request */ uint8_t operation;/* copied from request */ @@ -44,6 +52,14 @@ struct blkif_x86_64_request {blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST ]; }; +struct blkif_x86_64_request_discard { +uint8_t operation;/* BLKIF_OP_DISCARD */ +uint8_t flag;/* nr_segments in request struct */ +blkif_vdev_t handle;/* only for read/write requests */ +uint64_t __attribute__((__aligned__ (8 ))) id; +blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ +uint64_t nr_sectors;/* # of contiguous sectors to discard */ +};struct blkif_x86_64_response {hw/block/xen_blkif.h +1
-1uint64_t __attribute__((__aligned__ (8 ))) id;uint8_t operation;/* copied from request */ @@ -82,7 +98,7 @@ static inline void blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque /* Prevent the compiler from using src->... instead. */barrier ();if (dst->operation ==BLKIF_OP_DISCARD ) { -struct blkif_request_discard *s = (void *)src; +struct blkif_x86_32_request_discard *s = (void *)src;struct blkif_request_discard *d = (void *)dst; d->nr_sectors = s->nr_sectors;hw/block/xen_blkif.h +0
-0return ;@@ -105,7 +121,7 @@ static inline voidblkif_get_x86_64_req(blkif_request_t *dst,
blkif_x86_64_requehw/block/xen_blkif.h +1
-2/* Prevent the compiler from using src->... instead. */ barrier ();if (dst->operation ==BLKIF_OP_DISCARD ) { -struct blkif_request_discard *s = (void *)src; +struct blkif_x86_64_request_discard *s = (void *)src;struct blkif_request_discard *d = (void *)dst; d->nr_sectors = s->nr_sectors;return ; --2.6.6
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 14 lines · Paul Durrant
Quoted 14 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Juergen Gross
Sent: 16 June 2016 11:02
To: [email protected]; [email protected]
Cc: Anthony Perard; Juergen Gross; [email protected]; [email protected]
Subject: [Xen-devel] [PATCH] xen: fix qdiskBLKIF_OP_DISCARDfor 32/64 word size mixIn case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.
Quoted 7 lines
Quoted 4 lines
Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>Would it not be better to re-import the canonical blkif header as a whole rather than cherry-picking like this? You'd need to post-process to maintain style and possibly change some names for compatibility etc. but probably nothing beyond what indent and a simple [s]ed script can do. I did broadly the same thing to re-import the netif header into Linux recently.
It's a little bit more than indent/sed, but nothing really scary.
I'll do it.
Juergen
Quoted 32 lines
-----Original Message-----
From: Juergen Gross [mailto:[email protected]]
Sent: 16 June 2016 13:19
To: Paul Durrant; [email protected]; [email protected]
Cc: Anthony Perard; [email protected]; [email protected]
Subject: Re: [Xen-devel] [PATCH] xen: fix qdiskBLKIF_OP_DISCARDfor 32/64 word size mixQuoted 14 lines · Paul Durrant
Quoted 14 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Juergen Gross
Sent: 16 June 2016 11:02
To: [email protected]; [email protected]
Cc: Anthony Perard; Juergen Gross; [email protected]; [email protected]
Subject: [Xen-devel] [PATCH] xen: fix qdiskBLKIF_OP_DISCARDfor 32/64 word size mixIn case the word size of the domU and qemu running the qdisk backend differ
BLKIF_OP_DISCARDwill not work reliably, as the request structure in the ring have different layouts for different word size.Quoted 6 lines
Quoted 4 lines
Correct this by copying the request structure in case of different word size element by element in the
BLKIF_OP_DISCARDcase, too.Signed-off-by Juergen Gross <[email protected]>Would it not be better to re-import the canonical blkif header as a whole
rather than cherry-picking like this? You'd need to post-process to maintain style and possibly change some names for compatibility etc. but probably nothing beyond what indent and a simple [s]ed script can do.
Quoted 7 lines
Quoted 1 line
I did broadly the same thing to re-import the netif header into Linux
recently.
It's a little bit more than indent/sed, but nothing really scary.
I'll do it.
Cool. The nice thing about bringing the header up-to-date is it pulls in all the newer comments and explanations too :-)
Paul
Quoted 2 lines
Juergen