* [PATCH] block: unmap (discard) blocks only if discard_zeros flag is true
@ 2022-09-23 10:02 luzhipeng
2022-09-23 14:28 ` Kevin Wolf
0 siblings, 1 reply; 3+ messages in thread
From: luzhipeng @ 2022-09-23 10:02 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, Kevin Wolf, Hanna Reitz, lu zhipeng
From: lu zhipeng <luzhipeng@cestc.cn>
we can unmap(discard) blocks for block devices of supporting discard zeros
or regular file.
Signed-off-by: lu zhipeng <luzhipeng@cestc.cn>
---
block/file-posix.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index 48cd096624..c35dbc0d88 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -799,7 +799,8 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
#endif
s->needs_alignment = raw_needs_alignment(bs);
- bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK;
+ bs->supported_zero_flags = s->discard_zeroes ?
+ BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK : 0;
if (S_ISREG(st.st_mode)) {
/* When extending regular files, we get zeros from the OS */
bs->supported_truncate_flags = BDRV_REQ_ZERO_WRITE;
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] block: unmap (discard) blocks only if discard_zeros flag is true
2022-09-23 10:02 [PATCH] block: unmap (discard) blocks only if discard_zeros flag is true luzhipeng
@ 2022-09-23 14:28 ` Kevin Wolf
2022-09-23 14:33 ` luzhipeng
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2022-09-23 14:28 UTC (permalink / raw)
To: luzhipeng; +Cc: qemu-devel, qemu-block, Hanna Reitz
Am 23.09.2022 um 12:02 hat luzhipeng geschrieben:
> From: lu zhipeng <luzhipeng@cestc.cn>
>
> we can unmap(discard) blocks for block devices of supporting discard zeros
> or regular file.
>
> Signed-off-by: lu zhipeng <luzhipeng@cestc.cn>
This more or less restores the state before commit 34fa110e. The commit
message there explains that s->discard_zeroes is unreliable (in
particular, it is false on block devices on recent kernels even though
they may support zeroing by discard just fine).
We should instead remove s->discard_zeroes because it is currently
unused. I'll send a patch.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block: unmap (discard) blocks only if discard_zeros flag is true
2022-09-23 14:28 ` Kevin Wolf
@ 2022-09-23 14:33 ` luzhipeng
0 siblings, 0 replies; 3+ messages in thread
From: luzhipeng @ 2022-09-23 14:33 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-devel, qemu-block, Hanna Reitz
在 2022/9/23 22:28, Kevin Wolf 写道:
> Am 23.09.2022 um 12:02 hat luzhipeng geschrieben:
>> From: lu zhipeng <luzhipeng@cestc.cn>
>>
>> we can unmap(discard) blocks for block devices of supporting discard zeros
>> or regular file.
>>
>> Signed-off-by: lu zhipeng <luzhipeng@cestc.cn>
>
> This more or less restores the state before commit 34fa110e. The commit
> message there explains that s->discard_zeroes is unreliable (in
> particular, it is false on block devices on recent kernels even though
> they may support zeroing by discard just fine).
>
> We should instead remove s->discard_zeroes because it is currently
> unused. I'll send a patch.
>
> Kevin
>
>
>
OK
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-23 14:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-23 10:02 [PATCH] block: unmap (discard) blocks only if discard_zeros flag is true luzhipeng
2022-09-23 14:28 ` Kevin Wolf
2022-09-23 14:33 ` luzhipeng
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.