X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Flog.c;h=d20f924bfc42655e6ab6aaaf9f6a102db005407a;hb=HEAD;hp=5a16238666c8ab2c14b15113e5bbdd00316640e4;hpb=9c27547e07bfcadab7584f46185db77c486c1412;p=bluesky.git diff --git a/bluesky/log.c b/bluesky/log.c index 5a16238..d20f924 100644 --- a/bluesky/log.c +++ b/bluesky/log.c @@ -3,7 +3,29 @@ * Copyright (C) 2010 The Regents of the University of California * Written by Michael Vrable * - * TODO: Licensing + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ #define _GNU_SOURCE @@ -34,10 +56,6 @@ * only incompletely written out before a crash, which should only happen for * log records that were not considered committed). */ -// Rough size limit for a log segment. This is not a firm limit and there are -// no absolute guarantees on the size of a log segment. -#define LOG_SEGMENT_SIZE (1 << 22) - #define HEADER_MAGIC 0x676f4c0a #define FOOTER_MAGIC 0x2e435243 @@ -482,8 +500,9 @@ static void cloudlog_partial_fetch_start(BlueSkyCacheFile *cachefile, size_t offset, size_t length) { g_atomic_int_inc(&cachefile->refcount); - g_print("Starting partial fetch of %s from cloud (%zd + %zd)\n", - cachefile->filename, offset, length); + if (bluesky_verbose) + g_print("Starting partial fetch of %s from cloud (%zd + %zd)\n", + cachefile->filename, offset, length); BlueSkyStoreAsync *async = bluesky_store_async_new(cachefile->fs->store); async->op = STORE_OP_GET; async->key = g_strdup(cachefile->filename); @@ -500,13 +519,15 @@ static void cloudlog_partial_fetch_start(BlueSkyCacheFile *cachefile, static void cloudlog_partial_fetch_complete(BlueSkyStoreAsync *async, BlueSkyCacheFile *cachefile) { - g_print("Fetch of %s from cloud complete, status = %d\n", - async->key, async->result); + if (bluesky_verbose || async->result != 0) + g_print("Fetch of %s from cloud complete, status = %d\n", + async->key, async->result); g_mutex_lock(cachefile->lock); if (async->result >= 0) { if (async->len == 0) { - g_print("Complete object was fetched.\n"); + if (bluesky_verbose) + g_print("Complete object was fetched.\n"); cachefile->complete = TRUE; } @@ -553,7 +574,7 @@ static void cloudlog_partial_fetch_complete(BlueSkyStoreAsync *async, bluesky_rangeset_free(items); } else { - g_print("Error fetching from cloud, retrying...\n"); + g_print("Error fetching %s from cloud, retrying...\n", async->key); cloudlog_partial_fetch_start(cachefile, async->start, async->len); } @@ -576,7 +597,8 @@ static void cloudlog_fetch_start(BlueSkyCacheFile *cachefile) { g_atomic_int_inc(&cachefile->refcount); cachefile->fetching = TRUE; - g_print("Starting fetch of %s from cloud\n", cachefile->filename); + if (bluesky_verbose) + g_print("Starting fetch of %s from cloud\n", cachefile->filename); BlueSkyStoreAsync *async = bluesky_store_async_new(cachefile->fs->store); async->op = STORE_OP_GET; async->key = g_strdup(cachefile->filename); @@ -651,7 +673,8 @@ BlueSkyRCStr *bluesky_log_map_object(BlueSkyCloudLog *item, gboolean map_data) BlueSkyRCStr *str = NULL; int location = 0; size_t file_offset = 0, file_size = 0; - gboolean range_request = TRUE; + gboolean range_request = bluesky_options.full_segment_fetches + ? FALSE : TRUE; if (page_size == 0) { page_size = getpagesize(); @@ -751,7 +774,7 @@ void bluesky_mmap_unref(BlueSkyCacheFile *mmap) if (g_atomic_int_dec_and_test(&mmap->mapcount)) { g_mutex_lock(mmap->lock); - if (mmap->addr != NULL) { + if (mmap->addr != NULL && g_atomic_int_get(&mmap->mapcount) == 0) { if (bluesky_verbose) g_print("Unmapped log segment %d...\n", mmap->log_seq); munmap((void *)mmap->addr, mmap->len);