From: Michael Vrable Date: Fri, 4 Sep 2009 22:51:02 +0000 (-0700) Subject: Proof-of-concept flushing of inodes to disk. X-Git-Url: https://git.vrable.net/?a=commitdiff_plain;h=6357b9d1de3bfb09811297406688810b4900df7b;p=bluesky.git Proof-of-concept flushing of inodes to disk. --- diff --git a/bluesky/bluesky.h b/bluesky/bluesky.h index 8980c98..2cf97f6 100644 --- a/bluesky/bluesky.h +++ b/bluesky/bluesky.h @@ -199,6 +199,9 @@ void bluesky_file_write(BlueSkyInode *inode, uint64_t offset, void bluesky_file_read(BlueSkyInode *inode, uint64_t offset, char *buf, gint len); +void bluesky_inode_flush(BlueSkyFS *fs, BlueSkyInode *inode); +void bluesky_serialize_inode(GString *out, BlueSkyInode *inode); + #ifdef __cplusplus } #endif diff --git a/bluesky/dir.c b/bluesky/dir.c index 204439e..2690498 100644 --- a/bluesky/dir.c +++ b/bluesky/dir.c @@ -95,6 +95,7 @@ gboolean bluesky_directory_insert(BlueSkyInode *dir, gchar *name, uint64_t inum) g_hash_table_insert(dir->dirhash, d->name, d); bluesky_inode_update_ctime(dir, 1); + bluesky_inode_flush(dir->fs, dir); return TRUE; } diff --git a/bluesky/file.c b/bluesky/file.c index 4badc75..5f7d9cd 100644 --- a/bluesky/file.c +++ b/bluesky/file.c @@ -111,6 +111,7 @@ void bluesky_file_write(BlueSkyInode *inode, uint64_t offset, } bluesky_inode_update_ctime(inode, 1); + bluesky_inode_flush(inode->fs, inode); } void bluesky_file_read(BlueSkyInode *inode, uint64_t offset, diff --git a/bluesky/inode.c b/bluesky/inode.c index 8fdd882..a20b23b 100644 --- a/bluesky/inode.c +++ b/bluesky/inode.c @@ -6,6 +6,7 @@ * TODO: Licensing */ +#include #include #include #include @@ -150,3 +151,18 @@ void bluesky_insert_inode(BlueSkyFS *fs, BlueSkyInode *inode) g_hash_table_insert(fs->inodes, &inode->inum, inode); g_mutex_unlock(fs->lock); } + +/* Synchronize an inode to stable storage. */ +void bluesky_inode_flush(BlueSkyFS *fs, BlueSkyInode *inode) +{ + GString *buf = g_string_new(""); + bluesky_serialize_inode(buf, inode); + + gsize len = buf->len; + BlueSkyRCStr *data = bluesky_string_new(g_string_free(buf, FALSE), len); + + char key[64]; + sprintf(key, "inode-%016llx", inode->inum); + + bluesky_store_put(fs->store, key, data); +}