All of lore.kernel.org
 help / color / mirror / Atom feed
* [Question] qemu-img convert block alignment
@ 2021-04-02  3:52 Zhenyu Ye
  2021-08-03  1:53 ` Zhenyu Ye
  2021-08-03 15:03 ` Eric Blake
  0 siblings, 2 replies; 4+ messages in thread
From: Zhenyu Ye @ 2021-04-02  3:52 UTC (permalink / raw)
  To: Kevin Wolf, mreitz, qemu-block, qemu-devel, pl

Hi all,

commit 8dcd3c9b91 ("qemu-img: align result of is_allocated_sectors")
introduces block alignment when doing qemu-img convert. However, the
alignment is:

	s.alignment = MAX(pow2floor(s.min_sparse),
                      DIV_ROUND_UP(out_bs->bl.request_alignment,
                                   BDRV_SECTOR_SIZE));

(where the default s.min_sparse is 8)
When the target device's bl.request_alignment is smaller than 4K, this
will cause additional write-zero overhead and makes the size of target
file larger.

Is this as expected?  Should we change the MAX() to MIN()?


Thanks,
zhenyu


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Question] qemu-img convert block alignment
  2021-04-02  3:52 [Question] qemu-img convert block alignment Zhenyu Ye
@ 2021-08-03  1:53 ` Zhenyu Ye
  2021-08-03 15:03 ` Eric Blake
  1 sibling, 0 replies; 4+ messages in thread
From: Zhenyu Ye @ 2021-08-03  1:53 UTC (permalink / raw)
  To: Kevin Wolf, mreitz, qemu-block, qemu-devel, pl

ping?

On 2021/4/2 11:52, Zhenyu Ye wrote:
> Hi all,
> 
> commit 8dcd3c9b91 ("qemu-img: align result of is_allocated_sectors")
> introduces block alignment when doing qemu-img convert. However, the
> alignment is:
> 
> 	s.alignment = MAX(pow2floor(s.min_sparse),
>                       DIV_ROUND_UP(out_bs->bl.request_alignment,
>                                    BDRV_SECTOR_SIZE));
> 
> (where the default s.min_sparse is 8)
> When the target device's bl.request_alignment is smaller than 4K, this
> will cause additional write-zero overhead and makes the size of target
> file larger.
> 
> Is this as expected?  Should we change the MAX() to MIN()?
> 
> 
> Thanks,
> zhenyu
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Question] qemu-img convert block alignment
  2021-04-02  3:52 [Question] qemu-img convert block alignment Zhenyu Ye
  2021-08-03  1:53 ` Zhenyu Ye
@ 2021-08-03 15:03 ` Eric Blake
  2021-08-04  7:18   ` Zhenyu Ye
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Blake @ 2021-08-03 15:03 UTC (permalink / raw)
  To: Zhenyu Ye; +Cc: Kevin Wolf, pl, qemu-devel, qemu-block, mreitz

On Fri, Apr 02, 2021 at 11:52:25AM +0800, Zhenyu Ye wrote:
> Hi all,
> 
> commit 8dcd3c9b91 ("qemu-img: align result of is_allocated_sectors")
> introduces block alignment when doing qemu-img convert. However, the
> alignment is:
> 
> 	s.alignment = MAX(pow2floor(s.min_sparse),
>                       DIV_ROUND_UP(out_bs->bl.request_alignment,
>                                    BDRV_SECTOR_SIZE));
> 
> (where the default s.min_sparse is 8)
> When the target device's bl.request_alignment is smaller than 4K, this
> will cause additional write-zero overhead and makes the size of target
> file larger.
> 
> Is this as expected?  Should we change the MAX() to MIN()?

Yes it is expected, and no we shouldn't change it.  Even when a target
advertises a bl.request_alignment of 512, our goal is to avoid needing
read-modify-write cycles when that target is really on top of a 4k
sector disk.  Writing extra 0s out to the 4k boundaries does not
change the fact that allocation is in 4k chunks anyways, regardless of
whether the disk supports smaller 512-byte reads.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Question] qemu-img convert block alignment
  2021-08-03 15:03 ` Eric Blake
@ 2021-08-04  7:18   ` Zhenyu Ye
  0 siblings, 0 replies; 4+ messages in thread
From: Zhenyu Ye @ 2021-08-04  7:18 UTC (permalink / raw)
  To: Eric Blake
  Cc: Kevin Wolf, qemu-block, pl, qemu-devel, Xiexiangyou, mreitz,
	zhengchuan, lichuan18

On 2021/8/3 23:03, Eric Blake wrote:
> On Fri, Apr 02, 2021 at 11:52:25AM +0800, Zhenyu Ye wrote:
>> Hi all,
>>
>> commit 8dcd3c9b91 ("qemu-img: align result of is_allocated_sectors")
>> introduces block alignment when doing qemu-img convert. However, the
>> alignment is:
>>
>> 	s.alignment = MAX(pow2floor(s.min_sparse),
>>                       DIV_ROUND_UP(out_bs->bl.request_alignment,
>>                                    BDRV_SECTOR_SIZE));
>>
>> (where the default s.min_sparse is 8)
>> When the target device's bl.request_alignment is smaller than 4K, this
>> will cause additional write-zero overhead and makes the size of target
>> file larger.
>>
>> Is this as expected?  Should we change the MAX() to MIN()?
> 
> Yes it is expected, and no we shouldn't change it.  Even when a target
> advertises a bl.request_alignment of 512, our goal is to avoid needing
> read-modify-write cycles when that target is really on top of a 4k
> sector disk.  Writing extra 0s out to the 4k boundaries does not
> change the fact that allocation is in 4k chunks anyways, regardless of
> whether the disk supports smaller 512-byte reads.
> 

Thanks for your reply.

Zhenyu


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-04  7:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-02  3:52 [Question] qemu-img convert block alignment Zhenyu Ye
2021-08-03  1:53 ` Zhenyu Ye
2021-08-03 15:03 ` Eric Blake
2021-08-04  7:18   ` Zhenyu Ye

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.