Flash Translation Layer  1.0
Data Structures | Macros | Enumerations | Functions
page.h File Reference

declaration of data structures and macros for page ftl More...

#include <stdint.h>
#include <pthread.h>
#include <limits.h>
#include <unistd.h>
#include <glib.h>
#include "flash.h"
#include "device.h"
Include dependency graph for page.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  page_ftl_segment
 segment information structure More...
 
struct  page_ftl
 contain the page flash translation layer information More...
 

Macros

#define PAGE_FTL_CACHE_SIZE   (2)
 
#define PAGE_FTL_GC_RATIO
 
#define PAGE_FTL_GC_THRESHOLD
 

Enumerations

enum  { PAGE_FTL_IOCTL_TRIM = 0 }
 

Functions

int page_ftl_open (struct page_ftl *, const char *name, int flags)
 allocate the page ftl structure's members More...
 
int page_ftl_close (struct page_ftl *)
 deallocate the page ftl structure's members More...
 
ssize_t page_ftl_submit_request (struct page_ftl *, struct device_request *)
 submit the request to the valid function More...
 
ssize_t page_ftl_write (struct page_ftl *, struct device_request *)
 the core logic for writing the request to the device. More...
 
ssize_t page_ftl_read (struct page_ftl *, struct device_request *)
 the core logic for reading the request to the device. More...
 
int page_ftl_module_init (struct flash_device *, uint64_t flags)
 initialize the page flash translation layer module More...
 
int page_ftl_module_exit (struct flash_device *)
 free resources in the page flash translation layer module More...
 
struct device_address page_ftl_get_free_page (struct page_ftl *)
 get page from the segment More...
 
int page_ftl_update_map (struct page_ftl *, size_t sector, uint32_t ppn)
 
int page_ftl_segment_data_init (struct page_ftl *, struct page_ftl_segment *)
 initialize the page ftl's segment data only More...
 
int page_ftl_do_gc (struct page_ftl *)
 core logic of the garbage collection More...
 
static size_t page_ftl_get_map_size (struct page_ftl *pgftl)
 
static size_t page_ftl_get_lpn (struct page_ftl *pgftl, size_t sector)
 
static size_t page_ftl_get_page_offset (struct page_ftl *pgftl, size_t sector)
 
static size_t page_ftl_get_segment_number (struct page_ftl *pgftl, uintptr_t segment)
 

Detailed Description

declaration of data structures and macros for page ftl

Author
Gijun Oh
Version
0.2
Date
2021-09-22

Macro Definition Documentation

◆ PAGE_FTL_CACHE_SIZE

#define PAGE_FTL_CACHE_SIZE   (2)

◆ PAGE_FTL_GC_RATIO

#define PAGE_FTL_GC_RATIO
Value:
((double)30 / \
100)

maximum the number of segments garbage collected

◆ PAGE_FTL_GC_THRESHOLD

#define PAGE_FTL_GC_THRESHOLD
Value:
((double)80 / \
100)

gc triggered when number of the free pages under threshold

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PAGE_FTL_IOCTL_TRIM 

Function Documentation

◆ page_ftl_close()

int page_ftl_close ( struct page_ftl pgftl)

deallocate the page ftl structure's members

Parameters
pgftlpointer of the page ftl structure
Returns
zero to success, negative number to fail
Here is the call graph for this function:

◆ page_ftl_do_gc()

int page_ftl_do_gc ( struct page_ftl pgftl)

core logic of the garbage collection

Parameters
pgftlpointer of the page FTL structure
Returns
0 for success, negative number for fail
Here is the call graph for this function:

◆ page_ftl_get_free_page()

struct device_address page_ftl_get_free_page ( struct page_ftl pgftl)

get page from the segment

Parameters
pgftlpointer of the page-ftl structure
Returns
free space's device address
Here is the call graph for this function:

◆ page_ftl_get_lpn()

static size_t page_ftl_get_lpn ( struct page_ftl pgftl,
size_t  sector 
)
static
Here is the call graph for this function:

◆ page_ftl_get_map_size()

static size_t page_ftl_get_map_size ( struct page_ftl pgftl)
static
Here is the call graph for this function:

◆ page_ftl_get_page_offset()

static size_t page_ftl_get_page_offset ( struct page_ftl pgftl,
size_t  sector 
)
static
Here is the call graph for this function:

◆ page_ftl_get_segment_number()

static size_t page_ftl_get_segment_number ( struct page_ftl pgftl,
uintptr_t  segment 
)
static

◆ page_ftl_module_exit()

int page_ftl_module_exit ( struct flash_device flash)

free resources in the page flash translation layer module

Parameters
flashpointer of the flash device information
Returns
zero to success, error number to fail
Note
You must not free resources related on the flash module which is parent module
Here is the call graph for this function:

◆ page_ftl_module_init()

int page_ftl_module_init ( struct flash_device flash,
uint64_t  flags 
)

initialize the page flash translation layer module

Parameters
flashpointer of the flash device information
flagsflags for flash and submodule
Returns
zero to success, error number to fail
Here is the call graph for this function:

◆ page_ftl_open()

int page_ftl_open ( struct page_ftl pgftl,
const char *  name,
int  flags 
)

allocate the page ftl structure's members

Parameters
pgftlpointer of the page ftl structure
namefile's name for open
flagsflags for open
Returns
zero to success, negative number to fail
Todo:
you must make a recovery process

initialize the mapping table

Here is the call graph for this function:

◆ page_ftl_read()

ssize_t page_ftl_read ( struct page_ftl pgftl,
struct device_request request 
)

the core logic for reading the request to the device.

Parameters
pgftlpointer of the page FTL structure
requestuser's request pointer
Returns
reading data size. a negative number means fail to read.
Note
if paddr.lpn doesn't exist, this function returns the buffer filled 0 value.

< YOU MUST TAKE CARE OF THIS LINE

Here is the call graph for this function:

◆ page_ftl_segment_data_init()

int page_ftl_segment_data_init ( struct page_ftl pgftl,
struct page_ftl_segment segment 
)

initialize the page ftl's segment data only

Parameters
pgftlpointer of the page-ftl structure
segmentpointer of the target segment
Returns
0 for successfully initialized
Here is the call graph for this function:

◆ page_ftl_submit_request()

ssize_t page_ftl_submit_request ( struct page_ftl pgftl,
struct device_request request 
)

submit the request to the valid function

Parameters
pgftlpointer of the page ftl structure
requestpointer of the request
Returns
read and write return the size of the submit, fail to return the nugative value
Note
garbage collection doesn't free the request.
Here is the call graph for this function:

◆ page_ftl_update_map()

int page_ftl_update_map ( struct page_ftl ,
size_t  sector,
uint32_t  ppn 
)

◆ page_ftl_write()

ssize_t page_ftl_write ( struct page_ftl pgftl,
struct device_request request 
)

the core logic for writing the request to the device.

Parameters
pgftlpointer of the page FTL structure
requestuser's request pointer
Returns
writing data size. a negative number means fail to write.

< global data retrieve

Here is the call graph for this function: