qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [question] Partial sector issue while discard in qcow2 image
@ 2020-06-02  7:45 Lin Ma
  2020-06-02 11:06 ` Kevin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: Lin Ma @ 2020-06-02  7:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, pbonzini

[-- Attachment #1: Type: text/plain, Size: 825 bytes --]

Hi all,

During  woring to add GET LBA STATUS support in qemu scsi emulation layer, I encountered
an unmap issue with qcow2 image, It's likely about how to unmap partial clusters. e.g.:

With these default values:
* the default value of s->qdev.blocksize: 512
* the default value of s->cluster_size of qcow2 image: 65536

Running 'sg_unmap -l 1024 -n 32 /dev/sda' hits the condition
'if (!QEMU_IS_ALIGNED(offset | bytes, s->cluster_size))' in the function qcow2_co_pdiscard,
Then it won't perform qcow2_cluster_discard(), So the corresponding clusters won't be discard
in this situation, Correct?

Of cause, with the default blocksize and cluster_size, The below examples won't hit the condition 'if (!QEMU_IS_ALIGNED...'.
sg_unmap -l 1024 -n 128 /dev/sda
or
sg_unmap -l 256 -n 128 /dev/sda

Thanks,
Lin

[-- Attachment #2: Type: text/html, Size: 2038 bytes --]

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

* Re: [question] Partial sector issue while discard in qcow2 image
  2020-06-02  7:45 [question] Partial sector issue while discard in qcow2 image Lin Ma
@ 2020-06-02 11:06 ` Kevin Wolf
  2020-06-03  7:04   ` Lin Ma
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2020-06-02 11:06 UTC (permalink / raw)
  To: Lin Ma; +Cc: pbonzini, qemu-devel

Am 02.06.2020 um 09:45 hat Lin Ma geschrieben:
> Hi all,
> 
> During  woring to add GET LBA STATUS support in qemu scsi emulation
> layer, I encountered an unmap issue with qcow2 image, It's likely
> about how to unmap partial clusters. e.g.:
> 
> With these default values:
> * the default value of s->qdev.blocksize: 512
> * the default value of s->cluster_size of qcow2 image: 65536
> 
> Running 'sg_unmap -l 1024 -n 32 /dev/sda' hits the condition
> 'if (!QEMU_IS_ALIGNED(offset | bytes, s->cluster_size))' in the
> function qcow2_co_pdiscard, Then it won't perform
> qcow2_cluster_discard(), So the corresponding clusters won't be
> discard in this situation, Correct?

Yes, this is correct. Discard is just a hint, so doing nothing is a
perfectly valid implementation. In the case of qcow2, only full clusters
are discarded.

> Of cause, with the default blocksize and cluster_size, The below
> examples won't hit the condition 'if (!QEMU_IS_ALIGNED...'.
> sg_unmap -l 1024 -n 128 /dev/sda
> or
> sg_unmap -l 256 -n 128 /dev/sda

Yes, and when discarding whole block devices (e.g. while creating a new
filesystem on them) or large files, you'll probably get this case for
most parts.

Kevin



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

* Re: [question] Partial sector issue while discard in qcow2 image
  2020-06-02 11:06 ` Kevin Wolf
@ 2020-06-03  7:04   ` Lin Ma
  0 siblings, 0 replies; 3+ messages in thread
From: Lin Ma @ 2020-06-03  7:04 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1585 bytes --]

Hi Kevin,

Thanks for the explanation!

Lin

________________________________
From: Kevin Wolf <kwolf@redhat.com>
Sent: Tuesday, June 2, 2020 7:06 PM
To: Lin Ma <LMa@suse.com>
Cc: qemu-devel@nongnu.org <qemu-devel@nongnu.org>; pbonzini@redhat.com <pbonzini@redhat.com>
Subject: Re: [question] Partial sector issue while discard in qcow2 image

Am 02.06.2020 um 09:45 hat Lin Ma geschrieben:
> Hi all,
>
> During  woring to add GET LBA STATUS support in qemu scsi emulation
> layer, I encountered an unmap issue with qcow2 image, It's likely
> about how to unmap partial clusters. e.g.:
>
> With these default values:
> * the default value of s->qdev.blocksize: 512
> * the default value of s->cluster_size of qcow2 image: 65536
>
> Running 'sg_unmap -l 1024 -n 32 /dev/sda' hits the condition
> 'if (!QEMU_IS_ALIGNED(offset | bytes, s->cluster_size))' in the
> function qcow2_co_pdiscard, Then it won't perform
> qcow2_cluster_discard(), So the corresponding clusters won't be
> discard in this situation, Correct?

Yes, this is correct. Discard is just a hint, so doing nothing is a
perfectly valid implementation. In the case of qcow2, only full clusters
are discarded.

> Of cause, with the default blocksize and cluster_size, The below
> examples won't hit the condition 'if (!QEMU_IS_ALIGNED...'.
> sg_unmap -l 1024 -n 128 /dev/sda
> or
> sg_unmap -l 256 -n 128 /dev/sda

Yes, and when discarding whole block devices (e.g. while creating a new
filesystem on them) or large files, you'll probably get this case for
most parts.

Kevin


[-- Attachment #2: Type: text/html, Size: 3168 bytes --]

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

end of thread, other threads:[~2020-06-03  7:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02  7:45 [question] Partial sector issue while discard in qcow2 image Lin Ma
2020-06-02 11:06 ` Kevin Wolf
2020-06-03  7:04   ` Lin Ma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).