mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
file-posix: add tracking of the zone write pointers
Since Linux doesn't have a user API to issue zone append operations to zoned devices from user space, the file-posix driver is modified to add zone append emulation using regular writes. To do this, the file-posix driver tracks the wp location of all zones of the device. It uses an array of uint64_t. The most significant bit of each wp location indicates if the zone type is conventional zones. The zones wp can be changed due to the following operations issued: - zone reset: change the wp to the start offset of that zone - zone finish: change to the end location of that zone - write to a zone - zone append Signed-off-by: Sam Li <faithilikerun@gmail.com> Message-id: 20230508051510.177850-2-faithilikerun@gmail.com [Fix errno propagation from handle_aiocb_zone_mgmt() --Stefan] Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
90fd974668
commit
a3c41f06d5
3 changed files with 193 additions and 4 deletions
|
@ -118,6 +118,14 @@ typedef struct BlockZoneDescriptor {
|
|||
BlockZoneState state;
|
||||
} BlockZoneDescriptor;
|
||||
|
||||
/*
|
||||
* Track write pointers of a zone in bytes.
|
||||
*/
|
||||
typedef struct BlockZoneWps {
|
||||
CoMutex colock;
|
||||
uint64_t wp[];
|
||||
} BlockZoneWps;
|
||||
|
||||
typedef struct BlockDriverInfo {
|
||||
/* in bytes, 0 if irrelevant */
|
||||
int cluster_size;
|
||||
|
@ -240,6 +248,12 @@ typedef enum {
|
|||
#define BDRV_SECTOR_BITS 9
|
||||
#define BDRV_SECTOR_SIZE (1ULL << BDRV_SECTOR_BITS)
|
||||
|
||||
/*
|
||||
* Get the first most significant bit of wp. If it is zero, then
|
||||
* the zone type is SWR.
|
||||
*/
|
||||
#define BDRV_ZT_IS_CONV(wp) (wp & (1ULL << 63))
|
||||
|
||||
#define BDRV_REQUEST_MAX_SECTORS MIN_CONST(SIZE_MAX >> BDRV_SECTOR_BITS, \
|
||||
INT_MAX >> BDRV_SECTOR_BITS)
|
||||
#define BDRV_REQUEST_MAX_BYTES (BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BITS)
|
||||
|
|
|
@ -891,6 +891,8 @@ typedef struct BlockLimits {
|
|||
|
||||
/* maximum number of active zones */
|
||||
uint32_t max_active_zones;
|
||||
|
||||
uint32_t write_granularity;
|
||||
} BlockLimits;
|
||||
|
||||
typedef struct BdrvOpBlocker BdrvOpBlocker;
|
||||
|
@ -1252,6 +1254,9 @@ struct BlockDriverState {
|
|||
CoMutex bsc_modify_lock;
|
||||
/* Always non-NULL, but must only be dereferenced under an RCU read guard */
|
||||
BdrvBlockStatusCache *block_status_cache;
|
||||
|
||||
/* array of write pointers' location of each zone in the zoned device. */
|
||||
BlockZoneWps *wps;
|
||||
};
|
||||
|
||||
struct BlockBackendRootState {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue