1 /* Blue Sky: File Systems in the Cloud
3 * Copyright (C) 2009 The Regents of the University of California
4 * Written by Michael Vrable <mvrable@cs.ucsd.edu>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the University nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include "bluesky-private.h"
38 int bluesky_verbose = 0;
40 BlueSkyOptions bluesky_options = {
41 .cache_size = 1024*1024, // Default cache size is 1 GiB
44 /* Maximum number of threads to use in any particular thread pool, or -1 for no
46 int bluesky_max_threads = 16;
48 /* Watermark levels for cache tuning: these control when dirty data is flushed
49 * from cache, when clean data is dropped from the cache, etc. These values
50 * are measured in blocks, not bytes.
52 * There are a few relevant levels:
53 * low: Below this point, data is not forced out due to memory pressure
54 * medium: At this point start flushing data to get back below medium
55 * high: Flush data very aggressively (launch extra tasks if needed)
57 int bluesky_watermark_low_dirty = (64 << 20) / BLUESKY_BLOCK_SIZE;
58 int bluesky_watermark_medium_dirty = (96 << 20) / BLUESKY_BLOCK_SIZE;
59 int bluesky_watermark_med2_dirty = (160 << 20) / BLUESKY_BLOCK_SIZE;
60 int bluesky_watermark_high_dirty = (192 << 20) / BLUESKY_BLOCK_SIZE;
62 int bluesky_watermark_low_total = (64 << 20) / BLUESKY_BLOCK_SIZE;
63 int bluesky_watermark_medium_total = (128 << 20) / BLUESKY_BLOCK_SIZE;
64 int bluesky_watermark_med2_total = (224 << 20) / BLUESKY_BLOCK_SIZE;
65 int bluesky_watermark_high_total = (256 << 20) / BLUESKY_BLOCK_SIZE;
67 /* Environment variables that can be used to initialize settings. */
72 {"BLUESKY_VERBOSE", &bluesky_verbose},
73 {"BLUESKY_OPT_SYNC_STORES", &bluesky_options.synchronous_stores},
74 {"BLUESKY_OPT_WRITETHROUGH", &bluesky_options.writethrough_cache},
75 {"BLUESKY_OPT_SYNC_INODE_FETCH", &bluesky_options.sync_inode_fetches},
76 {"BLUESKY_OPT_SYNC_FRONTENDS", &bluesky_options.sync_frontends},
77 {"BLUESKY_CACHE_SIZE", &bluesky_options.cache_size},
78 {"BLUESKY_OPT_FULL_SEGMENTS", &bluesky_options.full_segment_fetches},
79 {"BLUESKY_OPT_NO_AGGREGATION", &bluesky_options.disable_aggregation},
80 {"BLUESKY_OPT_NO_CRYPTO", &bluesky_options.disable_crypto},
81 {"BLUESKY_OPT_NO_GROUP_READS", &bluesky_options.disable_read_aggregation},
85 /* BlueSky library initialization. */
87 void bluesky_store_init_s3(void);
88 void bluesky_store_init_azure(void);
89 void bluesky_store_init_kv(void);
90 void bluesky_store_init_multi(void);
91 void bluesky_store_init_bdb(void);
92 void bluesky_store_init_simple(void);
94 /* Initialize the BlueSky library and dependent libraries. */
95 void bluesky_init(void)
100 for (int i = 0; option_table[i].env != NULL; i++) {
101 const char *val = getenv(option_table[i].env);
104 g_print("Option %s set to %d\n", option_table[i].env, v);
105 *option_table[i].option = atoi(val);
109 bluesky_store_init();
110 bluesky_store_init_kv();
111 bluesky_store_init_s3();
112 bluesky_store_init_azure();
113 bluesky_store_init_multi();
114 bluesky_store_init_bdb();
115 bluesky_store_init_simple();