qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Outreachy project task: Adding QEMU block layer APIs resembling Linu


From: Damien Le Moal
Subject: Re: Outreachy project task: Adding QEMU block layer APIs resembling Linux ZBD ioctls.
Date: Mon, 30 May 2022 11:26:48 +0000

On 2022/05/30 20:22, Stefan Hajnoczi wrote:
> On Mon, 30 May 2022 at 06:38, Damien Le Moal <Damien.LeMoal@wdc.com> wrote:
>> On 2022/05/30 14:09, Sam Li wrote:
>> Once you have an API working and the ability to execute all zone operations 
>> from
>> a guest, you can then work on adding the more difficult bits: supporting the
>> zone append operation will require tracking the write pointer position and 
>> state
>> of the device sequential zones. For that, the zone information will need the
>> zone capacity and write pointer position of all zones. The zone state may 
>> not be
>> necessary as you can infer the empty and full states from the zone capacity 
>> and
>> zone write pointer position. States such as explicit/implicit open, closed,
>> read-only and offline do not need to be tracked. If an operation cannot be
>> executed, the device will fail the io on the host side and you can simply
>> propagate that error to the guest.
>>
>> See the Linux kernel sd_zbc driver and its emulation of zone append 
>> operations
>> for inspiration: drivers/scsi/sd_zbc.c. Looking at that code (e.g.
>> sd_zbc_prepare_zone_append()), you will see that the only thing being 
>> tracked is
>> the write pointer position of zones (relative to the zone start sector). The
>> state is inferred from that value, indicating if the zone can be written (it 
>> is
>> not full) or not (the zone is full).
> 
> It sounds like QEMU BlockDrivers need to maintain state? I haven't
> thought this through but the guest probably has some state and the
> device below QEMU also has state. Can QEMU just invoke the BLK*ZONE
> ioctls on behalf of the guest without maintaining it's own state?

FOr all operations except zone append, yes, it can and that the way it should be
done. However, for a linux host, since there is no user interface for the zone
append operation, QEMU will need to emulate that command using regular writes.
And for that to work, zones state (at least the zone write pointer position)
need to be tracked. Linux mandates zone append working for zoned devices...
This kind of emulation is thus implemented in the scsi disk driver since ZBC &
ZAC do not have zone append. It is not too hard to do, but care must be applied
to zone wp tracking and locking (mutual exclusion for zone wp test + change
depending on the operation). This tracking can be fully initialized on startup
and does not need any persistent "metadata".


> 
> Stefan
> 


-- 
Damien Le Moal
Western Digital Research



reply via email to

[Prev in Thread] Current Thread [Next in Thread]