ShingledFS 2.0
SMR-AwareFUSE-basedFileSystem
|
Implements the buffer cache abstraction for ShingledFS. More...
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <pthread.h>
#include <semaphore.h>
#include <sys/xattr.h>
#include "failstop.h"
#include "buffercache.h"
#include "common.h"
#include "helper.h"
#include "inode.h"
#include "band_bitmap.h"
#include "band_log.h"
#include "emulator.h"
#include "emutypes.h"
#include "emuerror.h"
Go to the source code of this file.
Data Structures | |
struct | bc_file_list_t |
Defines the Buffer Cache File List. More... | |
struct | bc_request_list_t |
Defines the request list that holds loads/stores from ShingledFS. More... | |
Defines | |
#define | MAX_FILES 32 |
Defines the maximum number of files in the buffer cache. | |
Functions | |
void | bc_init (size_t cache_size) |
Initializes the Buffer Cache system. | |
bc_file_t * | bc_open (const char *path) |
Loads a file into the buffer cache. | |
void | bc_close (bc_file_t *file) |
Saves a file in the buffer cache to disk. | |
int | bc_unlink (const char *path) |
Deletes the specified file from the buffer cache. | |
int | bc_rename (const char *path, const char *path_new) |
Renames the specified file in the buffer cache. | |
void | bc_clean () |
Cleans the Buffer Cache by removing a file that can be evicted. | |
bc_file_t * | bc_file_search_path (const char *path) |
Searches the BC File List using the file path. | |
void | bc_generate_tmpFS_path (char *path_out, const char *path_in) |
Generates a file path on tmpFS for a file on the unshingled partition. |
Implements the buffer cache abstraction for ShingledFS.
Always grab the BC Files list lock first, before grabbing the lock on the BC File record. This ordering results in deadlock prevention.
Definition in file buffercache.c.
void bc_clean | ( | ) |
Cleans the Buffer Cache by removing a file that can be evicted.
This function is called when the Buffer Cache has no more space to write data to. Essentially, it searches for a file that can be evicted, and removes it from the buffer cache. The space occupied by the file is consequently freed up for use.
Definition at line 590 of file buffercache.c.
Referenced by shingledfs_write().
void bc_close | ( | bc_file_t * | file | ) |
Saves a file in the buffer cache to disk.
file | Pointer to the BC File record of the file that needs to be closed |
Definition at line 302 of file buffercache.c.
References inode_unlink().
Referenced by shingledfs_release().
bc_file_t* bc_file_search_path | ( | const char * | path | ) |
Searches the BC File List using the file path.
This function DOES NOT perform any locking. It is the responsibility of the caller to ensure that the correct locks are held before attempting to dequeue a file.
path | Path of the file to be searched for |
Definition at line 901 of file buffercache.c.
Referenced by bc_open(), bc_rename(), and bc_unlink().
void bc_generate_tmpFS_path | ( | char * | path_out, |
const char * | path_in | ||
) |
Generates a file path on tmpFS for a file on the unshingled partition.
This function only fails when the output path exceeds PATH_MAX
path_out | Buffer that will hold the generated path |
path_in | Path to the file on the unshingled partition |
path_tmpfs | Path to the tmpFS partition |
path_unshingled | Path to the unshingled partition |
Definition at line 1091 of file buffercache.c.
Referenced by bc_rename(), bc_unlink(), and shingledfs_rename().
void bc_init | ( | size_t | cache_size | ) |
Initializes the Buffer Cache system.
This function initializes the necessary data structures and spawns the worker threads that handle data transfer between the buffer cache and the EDI.
cache_size | Size of the Buffer Cache in bytes |
Definition at line 135 of file buffercache.c.
References MAX_FILES.
Referenced by shingledfs_init().
bc_file_t* bc_open | ( | const char * | path | ) |
Loads a file into the buffer cache.
path | Path to the file to be loaded into the buffer cache |
Definition at line 178 of file buffercache.c.
References bc_file_search_path(), xattr_get(), and xattr_path().
Referenced by shingledfs_open().
int bc_rename | ( | const char * | path, |
const char * | path_new | ||
) |
Renames the specified file in the buffer cache.
path | Path to the existing file |
path_new | Path to the renamed file |
Definition at line 475 of file buffercache.c.
References bc_file_search_path(), bc_generate_tmpFS_path(), and inode_unlink().
Referenced by shingledfs_rename().
int bc_unlink | ( | const char * | path | ) |
Deletes the specified file from the buffer cache.
path | Path to the file to be unloaded |
Definition at line 401 of file buffercache.c.
References bc_file_search_path(), and bc_generate_tmpFS_path().
Referenced by shingledfs_unlink().