From: Michael Vrable Date: Mon, 25 Jan 2010 03:37:45 +0000 (-0800) Subject: NFS cache writeback is now invoked periodically by a timer. X-Git-Url: http://git.vrable.net/?p=bluesky.git;a=commitdiff_plain;h=f57fa12ec60108a9338ca5c5c072ec6e0ea1b745 NFS cache writeback is now invoked periodically by a timer. Previously we didn't have timers set up and simply called the writeback code after each operation (which could mean writeback wasn't invoked for long stretches of time). --- diff --git a/bluesky/debug.c b/bluesky/debug.c index b030b7f..023b99f 100644 --- a/bluesky/debug.c +++ b/bluesky/debug.c @@ -22,9 +22,9 @@ static void inode_dump(gpointer key, gpointer value, gpointer user_data) g_print("Inode %"PRIu64":\n", inode->inum); - gboolean locked = FALSE; + gboolean locked = TRUE; if (g_mutex_trylock(inode->lock)) { - locked = TRUE; + locked = FALSE; g_mutex_unlock(inode->lock); } g_print(" Locked: %c Refcount: %d\n", diff --git a/bluesky/inode.c b/bluesky/inode.c index 377364c..4a158c7 100644 --- a/bluesky/inode.c +++ b/bluesky/inode.c @@ -148,6 +148,7 @@ BlueSkyInode *bluesky_new_inode(uint64_t inum, BlueSkyFS *fs, i->type = type; i->fs = fs; i->inum = inum; + i->change_count = 1; switch (type) { case BLUESKY_REGULAR: diff --git a/nfs3/rpc.c b/nfs3/rpc.c index 7b73840..a7d108c 100644 --- a/nfs3/rpc.c +++ b/nfs3/rpc.c @@ -471,7 +471,6 @@ nfs_program_3(RPCRequest *req) req->xdr_result = _xdr_result; result = (*local)((char *)req->args, req); - bluesky_flushd_invoke(fs); bluesky_debug_dump(fs); return; @@ -483,10 +482,22 @@ nfs_program_3(RPCRequest *req) static GMainContext *main_context; static GMainLoop *main_loop; +static gboolean async_flushd(gpointer data) +{ + bluesky_flushd_invoke(fs); + return TRUE; +} + static async_rpc_init() { main_context = g_main_context_new(); main_loop = g_main_loop_new(main_context, FALSE); + + /* Arrange to have the cache writeback code run every five seconds. */ + GSource *source = g_timeout_source_new_seconds(5); + g_source_set_callback(source, async_flushd, NULL, NULL); + g_source_attach(source, main_context); + g_source_unref(source); } struct rpc_call_header {