link_directories("${LIBS3_BUILD_DIR}/lib")
add_library(bluesky SHARED
- cache.c crypto.c dir.c file.c init.c inode.c serialize.c store.c
- s3store.c util.c)
+ cache.c crypto.c debug.c dir.c file.c init.c inode.c serialize.c
+ store.c s3store.c util.c)
add_executable(bluesky-test main.c)
set(CMAKE_C_FLAGS "-Wall -std=gnu99 ${CMAKE_C_FLAGS}")
void bluesky_flushd_invoke(BlueSkyFS *fs);
+void bluesky_debug_dump(BlueSkyFS *fs);
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/* Blue Sky: File Systems in the Cloud
+ *
+ * Copyright (C) 2009 The Regents of the University of California
+ * Written by Michael Vrable <mvrable@cs.ucsd.edu>
+ *
+ * TODO: Licensing
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <glib.h>
+#include <string.h>
+
+#include "bluesky-private.h"
+
+/* Debugging support for BlueSky. */
+
+static void inode_dump(gpointer key, gpointer value, gpointer user_data)
+{
+ BlueSkyInode *inode = (BlueSkyInode *)value;
+
+ g_print("Inode %"PRIu64":\n", inode->inum);
+
+ gboolean locked = FALSE;
+ if (g_mutex_trylock(inode->lock)) {
+ locked = TRUE;
+ g_mutex_unlock(inode->lock);
+ }
+ g_print(" Locked: %c Refcount: %d\n",
+ locked ? 'T' : 'F', inode->refcount);
+
+ g_print(" Type: %d Mode: %o\n", inode->type, inode->mode);
+ g_print(" change_count = %"PRIu64", change_commit = %"PRIu64"\n",
+ inode->change_count, inode->change_commit);
+}
+
+/* Dump a summary of filesystem state as it is cached in memory. */
+void bluesky_debug_dump(BlueSkyFS *fs)
+{
+ g_print("*** DEBUG DUMP FOR FILESYSTEM %s ***\n", fs->name);
+ g_print("Cached inodes: %u\tNext inode: %"PRIu64"\n",
+ g_hash_table_size(fs->inodes), fs->next_inum);
+
+ g_hash_table_foreach(fs->inodes, inode_dump, fs);
+}
xdrproc_t _xdr_argument, _xdr_result;
char *(*local)(char *, RPCRequest *);
+ printf("Dispatched NFS RPC message type %d\n", req->req_proc);
+
switch (req->req_proc) {
case NFSPROC3_NULL:
_xdr_argument = (xdrproc_t) xdr_void;
result = (*local)((char *)req->args, req);
bluesky_flushd_invoke(fs);
+ bluesky_debug_dump(fs);
return;
}
rpc->frag_len = ntohl(rpc->frag_len);
g_string_set_size(rpc->msgbuf, rpc->msgbuf->len - 4);
rpc->frag_hdr_bytes = 0;
- g_print("RPC fragment header: %08x\n", rpc->frag_len);
}
} else {
/* We were reading in the fragment body. */
if (rpc->frag_len = 0x80000000) {
/* We have a complete message since this was the last fragment and
* there are no more bytes in it. Dispatch the message. */
- g_print("Complete RPC message: %zd bytes\n", rpc->msgbuf->len);
if (!async_rpc_dispatch(rpc)) {
fprintf(stderr, "Invalid RPC message, closing channel\n");
g_io_channel_shutdown(rpc->channel, TRUE, NULL);