Flash Translation Layer  1.0
zone.h
Go to the documentation of this file.
1 
8 #ifndef ZONE_H
9 #define ZONE_H
10 
11 #include <libzbd/zbd.h>
12 
13 #include "device.h"
14 
19  int fd;
20 };
21 
25 struct zone_meta {
26  size_t total_size;
27  uint64_t zone_size;
28  uint64_t nr_zones;
29  uint64_t block_size;
30  int o_flags;
31 
32  char *buffer;
33 
34  struct zone_file_descriptor read;
35  struct zone_file_descriptor write;
36  struct zbd_info info;
37  struct zbd_zone *zones;
38 };
39 
40 int zone_open(struct device *, const char *name, int flags);
41 ssize_t zone_write(struct device *, struct device_request *);
42 ssize_t zone_read(struct device *, struct device_request *);
43 int zone_erase(struct device *, struct device_request *);
44 int zone_close(struct device *);
45 
46 int zone_device_init(struct device *, uint64_t flags);
47 int zone_device_exit(struct device *);
48 
49 static inline uint64_t zone_get_zone_number(struct device *dev,
50  struct device_address paddr)
51 {
52  struct zone_meta *meta = (struct zone_meta *)dev->d_private;
53  size_t page_size = device_get_page_size(dev);
54  return paddr.lpn / (meta->zone_size / page_size);
55 }
56 
57 #endif
uint64_t nr_zones
Definition: zone.h:28
void * d_private
Definition: device.h:168
ssize_t zone_write(struct device *, struct device_request *)
write to the zoned block device
Definition: zone.c:173
generic device address format
Definition: device.h:95
int zone_open(struct device *, const char *name, int flags)
open the zoned block deivce file
Definition: zone.c:32
int zone_device_exit(struct device *)
deallocate the device module
Definition: zone.c:433
ssize_t zone_read(struct device *, struct device_request *)
read to the zoned block device
Definition: zone.c:256
metadata of the device
Definition: device.h:163
int zone_erase(struct device *, struct device_request *)
erase the segment to the zoned block device
Definition: zone.c:316
size_t total_size
Definition: zone.h:26
int zone_close(struct device *)
close the zoned block device
Definition: zone.c:354
int zone_device_init(struct device *, uint64_t flags)
initialize the device module
Definition: zone.c:399
struct zbd_zone * zones
Definition: zone.h:37
int o_flags
Definition: zone.h:30
static uint64_t zone_get_zone_number(struct device *dev, struct device_address paddr)
Definition: zone.h:49
uint64_t zone_size
Definition: zone.h:27
uint32_t lpn
Definition: device.h:103
uint64_t block_size
Definition: zone.h:29
containing a zoned block device&#39;s metadata
Definition: zone.h:25
containing a zone file&#39;s metadata
Definition: zone.h:18
char * buffer
Definition: zone.h:32
struct device * dev
Definition: ramdisk-test.c:10
contain the device information header
static size_t device_get_page_size(struct device *dev)
get flash board&#39;s NAND page size
Definition: device.h:232
int fd
Definition: zone.h:19
request for device
Definition: device.h:110