Commit 13c324ed authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

Merge from 3.1.0 using following commands:

> svn merge --accept=postpone -r18405:HEAD https://svn.tokutek.com/tokudb/mysql.branches/3.0.5/tokudb
> svn merge --accept=postpone -r18484:HEAD https://svn.tokutek.com/tokudb/mysql.branches/3.1.0/tokudb
> svn merge --accept=postpone -c18403 https://svn.tokutek.com/tokudb/mysql.branches/3.0.5/tokudb
> all executed inside directory tokudb/toku/tokudb

git-svn-id: file:///svn/toku/tokudb@18877 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5500a399
......@@ -84,6 +84,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_waittime; /* how many usec spent waiting for another thread to release cache line */
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......@@ -93,7 +94,7 @@ typedef struct __toku_engine_status {
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
u_int32_t range_locks_max; /* max total number of range locks */
u_int32_t range_locks_max_per_db; /* max range locks per dictionary */
u_int32_t range_locks_max_per_index; /* max range locks per dictionary */
u_int32_t range_locks_curr; /* total range locks currently in use */
u_int64_t inserts; /* ydb row insert operations */
u_int64_t deletes; /* ydb row delete operations */
......@@ -109,6 +110,8 @@ typedef struct __toku_engine_status {
char enospc_most_recent[26]; /* time of most recent ENOSPC error return from disk write */
u_int64_t enospc_threads_blocked; /* how many threads are currently blocked by ENOSPC */
u_int64_t enospc_total; /* how many times has ENOSPC been returned by disk write */
u_int64_t enospc_seal_ctr; /* how many times has ENOSPC been returned to user (red zone) */
u_int64_t enospc_seal_state; /* state of ydb-level seal (0 = green, 1 = yellow, 2 = red) */
} ENGINE_STATUS;
typedef enum {
DB_BTREE=1,
......@@ -233,7 +236,9 @@ struct __toku_db_env {
DBT *dest_key,
const DBT *src_key, const DBT *src_val,
void *extra));
void* __toku_dummy0[19];
int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */;
int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */;
void* __toku_dummy0[17];
char __toku_dummy1[64];
void *api1_internal; /* 32-bit offset=212 size=4, 64=bit offset=360 size=8 */
void* __toku_dummy2[7];
......
......@@ -84,6 +84,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_waittime; /* how many usec spent waiting for another thread to release cache line */
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......@@ -93,7 +94,7 @@ typedef struct __toku_engine_status {
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
u_int32_t range_locks_max; /* max total number of range locks */
u_int32_t range_locks_max_per_db; /* max range locks per dictionary */
u_int32_t range_locks_max_per_index; /* max range locks per dictionary */
u_int32_t range_locks_curr; /* total range locks currently in use */
u_int64_t inserts; /* ydb row insert operations */
u_int64_t deletes; /* ydb row delete operations */
......@@ -109,6 +110,8 @@ typedef struct __toku_engine_status {
char enospc_most_recent[26]; /* time of most recent ENOSPC error return from disk write */
u_int64_t enospc_threads_blocked; /* how many threads are currently blocked by ENOSPC */
u_int64_t enospc_total; /* how many times has ENOSPC been returned by disk write */
u_int64_t enospc_seal_ctr; /* how many times has ENOSPC been returned to user (red zone) */
u_int64_t enospc_seal_state; /* state of ydb-level seal (0 = green, 1 = yellow, 2 = red) */
} ENGINE_STATUS;
typedef enum {
DB_BTREE=1,
......@@ -235,7 +238,9 @@ struct __toku_db_env {
DBT *dest_key,
const DBT *src_key, const DBT *src_val,
void *extra));
void* __toku_dummy0[19];
int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */;
int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */;
void* __toku_dummy0[17];
char __toku_dummy1[96];
void *api1_internal; /* 32-bit offset=244 size=4, 64=bit offset=392 size=8 */
void* __toku_dummy2[7];
......
......@@ -84,6 +84,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_waittime; /* how many usec spent waiting for another thread to release cache line */
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......@@ -93,7 +94,7 @@ typedef struct __toku_engine_status {
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
u_int32_t range_locks_max; /* max total number of range locks */
u_int32_t range_locks_max_per_db; /* max range locks per dictionary */
u_int32_t range_locks_max_per_index; /* max range locks per dictionary */
u_int32_t range_locks_curr; /* total range locks currently in use */
u_int64_t inserts; /* ydb row insert operations */
u_int64_t deletes; /* ydb row delete operations */
......@@ -109,6 +110,8 @@ typedef struct __toku_engine_status {
char enospc_most_recent[26]; /* time of most recent ENOSPC error return from disk write */
u_int64_t enospc_threads_blocked; /* how many threads are currently blocked by ENOSPC */
u_int64_t enospc_total; /* how many times has ENOSPC been returned by disk write */
u_int64_t enospc_seal_ctr; /* how many times has ENOSPC been returned to user (red zone) */
u_int64_t enospc_seal_state; /* state of ydb-level seal (0 = green, 1 = yellow, 2 = red) */
} ENGINE_STATUS;
typedef enum {
DB_BTREE=1,
......@@ -236,7 +239,9 @@ struct __toku_db_env {
DBT *dest_key,
const DBT *src_key, const DBT *src_val,
void *extra));
void* __toku_dummy0[34];
int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */;
int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */;
void* __toku_dummy0[32];
char __toku_dummy1[128];
void *api1_internal; /* 32-bit offset=336 size=4, 64=bit offset=544 size=8 */
void* __toku_dummy2[7];
......
......@@ -84,6 +84,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_waittime; /* how many usec spent waiting for another thread to release cache line */
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......@@ -93,7 +94,7 @@ typedef struct __toku_engine_status {
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
u_int32_t range_locks_max; /* max total number of range locks */
u_int32_t range_locks_max_per_db; /* max range locks per dictionary */
u_int32_t range_locks_max_per_index; /* max range locks per dictionary */
u_int32_t range_locks_curr; /* total range locks currently in use */
u_int64_t inserts; /* ydb row insert operations */
u_int64_t deletes; /* ydb row delete operations */
......@@ -109,6 +110,8 @@ typedef struct __toku_engine_status {
char enospc_most_recent[26]; /* time of most recent ENOSPC error return from disk write */
u_int64_t enospc_threads_blocked; /* how many threads are currently blocked by ENOSPC */
u_int64_t enospc_total; /* how many times has ENOSPC been returned by disk write */
u_int64_t enospc_seal_ctr; /* how many times has ENOSPC been returned to user (red zone) */
u_int64_t enospc_seal_state; /* state of ydb-level seal (0 = green, 1 = yellow, 2 = red) */
} ENGINE_STATUS;
typedef enum {
DB_BTREE=1,
......@@ -236,7 +239,9 @@ struct __toku_db_env {
DBT *dest_key,
const DBT *src_key, const DBT *src_val,
void *extra));
void* __toku_dummy0[34];
int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */;
int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */;
void* __toku_dummy0[32];
char __toku_dummy1[128];
void *api1_internal; /* 32-bit offset=336 size=4, 64=bit offset=544 size=8 */
void* __toku_dummy2[8];
......
......@@ -84,6 +84,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_waittime; /* how many usec spent waiting for another thread to release cache line */
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......@@ -93,7 +94,7 @@ typedef struct __toku_engine_status {
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
u_int32_t range_locks_max; /* max total number of range locks */
u_int32_t range_locks_max_per_db; /* max range locks per dictionary */
u_int32_t range_locks_max_per_index; /* max range locks per dictionary */
u_int32_t range_locks_curr; /* total range locks currently in use */
u_int64_t inserts; /* ydb row insert operations */
u_int64_t deletes; /* ydb row delete operations */
......@@ -109,6 +110,8 @@ typedef struct __toku_engine_status {
char enospc_most_recent[26]; /* time of most recent ENOSPC error return from disk write */
u_int64_t enospc_threads_blocked; /* how many threads are currently blocked by ENOSPC */
u_int64_t enospc_total; /* how many times has ENOSPC been returned by disk write */
u_int64_t enospc_seal_ctr; /* how many times has ENOSPC been returned to user (red zone) */
u_int64_t enospc_seal_state; /* state of ydb-level seal (0 = green, 1 = yellow, 2 = red) */
} ENGINE_STATUS;
typedef enum {
DB_BTREE=1,
......@@ -238,7 +241,9 @@ struct __toku_db_env {
DBT *dest_key,
const DBT *src_key, const DBT *src_val,
void *extra));
void* __toku_dummy0[35];
int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */;
int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */;
void* __toku_dummy0[33];
char __toku_dummy1[144];
void *api1_internal; /* 32-bit offset=356 size=4, 64=bit offset=568 size=8 */
void* __toku_dummy2[8];
......
......@@ -440,6 +440,7 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
printf(" u_int64_t cachetable_waittime; /* how many usec spent waiting for another thread to release cache line */ \n");
printf(" u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */ \n");
printf(" u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */ \n");
printf(" u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/ \n");
printf(" u_int64_t puts; /* how many times has a newly created node been put into the cachetable */ \n");
printf(" u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */ \n");
printf(" u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */ \n");
......@@ -449,7 +450,7 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
printf(" int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */ \n");
printf(" int64_t get_and_pin_footprint; /* state of get_and_pin procedure */ \n");
printf(" u_int32_t range_locks_max; /* max total number of range locks */ \n");
printf(" u_int32_t range_locks_max_per_db; /* max range locks per dictionary */ \n");
printf(" u_int32_t range_locks_max_per_index; /* max range locks per dictionary */ \n");
printf(" u_int32_t range_locks_curr; /* total range locks currently in use */ \n");
printf(" u_int64_t inserts; /* ydb row insert operations */ \n");
printf(" u_int64_t deletes; /* ydb row delete operations */ \n");
......@@ -465,7 +466,8 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
printf(" char enospc_most_recent[26]; /* time of most recent ENOSPC error return from disk write */ \n");
printf(" u_int64_t enospc_threads_blocked; /* how many threads are currently blocked by ENOSPC */ \n");
printf(" u_int64_t enospc_total; /* how many times has ENOSPC been returned by disk write */ \n");
printf(" u_int64_t enospc_seal_ctr; /* how many times has ENOSPC been returned to user (red zone) */ \n");
printf(" u_int64_t enospc_seal_state; /* state of ydb-level seal (0 = green, 1 = yellow, 2 = red) */ \n");
printf("} ENGINE_STATUS;\n");
print_dbtype();
......@@ -510,6 +512,8 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
" DBT *dest_key,\n"
" const DBT *src_key, const DBT *src_val,\n"
" void *extra))",
"int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */",
"int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */",
NULL};
print_struct("db_env", 1, db_env_fields32, db_env_fields64, sizeof(db_env_fields32)/sizeof(db_env_fields32[0]), extra);
}
......
......@@ -84,6 +84,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_waittime; /* how many usec spent waiting for another thread to release cache line */
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......@@ -93,7 +94,7 @@ typedef struct __toku_engine_status {
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
u_int32_t range_locks_max; /* max total number of range locks */
u_int32_t range_locks_max_per_db; /* max range locks per dictionary */
u_int32_t range_locks_max_per_index; /* max range locks per dictionary */
u_int32_t range_locks_curr; /* total range locks currently in use */
u_int64_t inserts; /* ydb row insert operations */
u_int64_t deletes; /* ydb row delete operations */
......@@ -109,6 +110,8 @@ typedef struct __toku_engine_status {
char enospc_most_recent[26]; /* time of most recent ENOSPC error return from disk write */
u_int64_t enospc_threads_blocked; /* how many threads are currently blocked by ENOSPC */
u_int64_t enospc_total; /* how many times has ENOSPC been returned by disk write */
u_int64_t enospc_seal_ctr; /* how many times has ENOSPC been returned to user (red zone) */
u_int64_t enospc_seal_state; /* state of ydb-level seal (0 = green, 1 = yellow, 2 = red) */
} ENGINE_STATUS;
typedef enum {
DB_BTREE=1,
......@@ -238,6 +241,8 @@ struct __toku_db_env {
DBT *dest_key,
const DBT *src_key, const DBT *src_val,
void *extra));
int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */;
int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */;
void *api1_internal;
int (*close) (DB_ENV *, u_int32_t);
int (*dbremove) (DB_ENV *, DB_TXN *, const char *, const char *, u_int32_t);
......
......@@ -66,6 +66,8 @@ int do_checkpoint_period = 0;
u_int32_t checkpoint_period = 0;
static const char *log_dir = NULL;
static int commitflags = 0;
static int redzone = 0;
static int redzone_set = 0;
static int use_random = 0;
enum { MAX_RANDOM_C = 16000057 }; // prime-numbers.org
......@@ -192,6 +194,13 @@ static void benchmark_setup (void) {
}
#endif
#if defined(TOKUDB)
if (redzone_set) {
r = dbenv->set_redzone(dbenv, redzone);
assert(r == 0);
}
#endif
r = dbenv->open(dbenv, dbdir, env_open_flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
assert(r == 0);
......@@ -486,15 +495,13 @@ static int print_usage (const char *argv0) {
fprintf(stderr, " --log_dir LOGDIR Put the logs in LOGDIR\n");
fprintf(stderr, " --env DIR\n");
fprintf(stderr, " --periter N how many insertions per iteration (default=%d)\n", DEFAULT_ITEMS_TO_INSERT_PER_ITERATION);
// fprintf(stderr, " --DB_INIT_TXN (1|0) turn on or off the DB_INIT_TXN env_open_flag\n");
// fprintf(stderr, " --DB_INIT_LOG (1|0) turn on or off the DB_INIT_LOG env_open_flag\n");
// fprintf(stderr, " --DB_INIT_LOCK (1|0) turn on or off the DB_INIT_LOCK env_open_flag\n");
fprintf(stderr, " --1514 do a point query for something not there at end. See #1514. (Requires --norandom)\n");
fprintf(stderr, " --append append to an existing file\n");
fprintf(stderr, " --userandom use random()\n");
fprintf(stderr, " --checkpoint-period %"PRIu32" checkpoint period\n", checkpoint_period);
fprintf(stderr, " --numdbs N Insert same items into N dbs (1 to %d)\n", MAX_DBS);
fprintf(stderr, " --insertmultiple Use DB_ENV->put_multiple api. Requires transactions.\n");
fprintf(stderr, " --redzone N redzone in percent\n");
fprintf(stderr, " n_iterations how many iterations (default %lld)\n", default_n_items/DEFAULT_ITEMS_TO_INSERT_PER_ITERATION);
return 1;
......@@ -641,22 +648,10 @@ int main (int argc, const char *const argv[]) {
} else if (strcmp(arg, "--log_dir") == 0) {
if (i+1 >= argc) return print_usage(argv[0]);
log_dir = argv[++i];
} else if (strcmp(arg, "--DB_INIT_TXN") == 0) {
if (i+1 >= argc) return print_usage(argv[0]);
if (atoi(argv[++i]))
env_open_flags |= DB_INIT_TXN;
else
env_open_flags &= ~DB_INIT_TXN;
} else if (strcmp(arg, "--DB_INIT_LOG") == 0) {
if (atoi(argv[++i]))
env_open_flags |= DB_INIT_LOG;
else
env_open_flags &= ~DB_INIT_LOG;
} else if (strcmp(arg, "--DB_INIT_LOCK") == 0) {
if (atoi(argv[++i]))
env_open_flags |= DB_INIT_LOCK;
else
env_open_flags &= ~DB_INIT_LOCK;
} else if (strcmp(arg, "--redzone") == 0) {
if (i+1 >= argc) return print_usage(argv[0]);
redzone_set = 1;
redzone = atoi(argv[++i]);
} else {
return print_usage(argv[0]);
}
......
......@@ -84,6 +84,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_waittime; /* how many usec spent waiting for another thread to release cache line */
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......@@ -93,7 +94,7 @@ typedef struct __toku_engine_status {
int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */
int64_t get_and_pin_footprint; /* state of get_and_pin procedure */
u_int32_t range_locks_max; /* max total number of range locks */
u_int32_t range_locks_max_per_db; /* max range locks per dictionary */
u_int32_t range_locks_max_per_index; /* max range locks per dictionary */
u_int32_t range_locks_curr; /* total range locks currently in use */
u_int64_t inserts; /* ydb row insert operations */
u_int64_t deletes; /* ydb row delete operations */
......@@ -109,6 +110,8 @@ typedef struct __toku_engine_status {
char enospc_most_recent[26]; /* time of most recent ENOSPC error return from disk write */
u_int64_t enospc_threads_blocked; /* how many threads are currently blocked by ENOSPC */
u_int64_t enospc_total; /* how many times has ENOSPC been returned by disk write */
u_int64_t enospc_seal_ctr; /* how many times has ENOSPC been returned to user (red zone) */
u_int64_t enospc_seal_state; /* state of ydb-level seal (0 = green, 1 = yellow, 2 = red) */
} ENGINE_STATUS;
typedef enum {
DB_BTREE=1,
......@@ -238,6 +241,8 @@ struct __toku_db_env {
DBT *dest_key,
const DBT *src_key, const DBT *src_val,
void *extra));
int (*get_redzone) (DB_ENV *env, int *redzone) /* get the redzone limit */;
int (*set_redzone) (DB_ENV *env, int redzone) /* set the redzone limit in percent of total space */;
void *api1_internal;
int (*close) (DB_ENV *, u_int32_t);
int (*dbremove) (DB_ENV *, DB_TXN *, const char *, const char *, u_int32_t);
......
......@@ -219,6 +219,7 @@ toku_file_fsync_without_accounting (int fd) {
return r;
}
int
toku_fsync_dirfd_without_accounting(DIR *dirp) {
int r;
......
......@@ -6,15 +6,16 @@
#include <fcntl.h>
#include <errno.h>
#include <toku_assert.h>
#include <malloc.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <syscall.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/statvfs.h>
#include "toku_portability.h"
#include "toku_os.h"
#include <malloc.h>
static int
toku_mallopt_init(void) {
......@@ -281,6 +282,27 @@ toku_os_get_processor_frequency(uint64_t *hzret) {
return r;
}
int
toku_get_filesystem_sizes(const char *path, uint64_t *avail_size, uint64_t *free_size, uint64_t *total_size) {
struct statvfs s;
int r = statvfs(path, &s);
if (r == -1)
r = errno;
else {
// get the block size in bytes
uint64_t bsize = s.f_frsize ? s.f_frsize : s.f_bsize;
// convert blocks to bytes
if (avail_size)
*avail_size = (uint64_t) s.f_bavail * bsize;
if (free_size)
*free_size = (uint64_t) s.f_bfree * bsize;
if (total_size)
*total_size = (uint64_t) s.f_blocks * bsize;
}
return r;
}
int
toku_dup2(int fd, int fd2) {
int r;
......@@ -298,3 +320,5 @@ uint64_t toku_sync_fetch_and_add_uint64(volatile uint64_t *a, uint64_t b) {
}
#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <toku_stdint.h>
#include <unistd.h>
#include <toku_assert.h>
#include "toku_os.h"
int main(int argc, const char *const argv[]) {
int verbose = 0;
int limit = 1;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {
verbose = 1;
continue;
}
if (strcmp(argv[i], "--timeit") == 0) {
limit = 100000;
continue;
}
}
int r;
#if 0
r = toku_get_filesystem_sizes(NULL, NULL, NULL, NULL);
assert(r == EFAULT);
#endif
r = toku_get_filesystem_sizes(".", NULL, NULL, NULL);
assert(r == 0);
uint64_t free_size = 0, avail_size = 0, total_size = 0;
for (int i = 0; i < limit; i++) {
r = toku_get_filesystem_sizes(".", &avail_size, &free_size, &total_size);
assert(r == 0);
assert(avail_size <= free_size && free_size <= total_size);
}
if (verbose) {
printf("avail=%"PRIu64"\n", avail_size);
printf("free=%"PRIu64"\n", free_size);
printf("total=%"PRIu64"\n", total_size);
}
return 0;
}
......@@ -2348,6 +2348,7 @@ void toku_cachetable_get_status(CACHETABLE ct, CACHETABLE_STATUS s) {
s->waittime = cachetable_waittime;
s->wait_reading = cachetable_wait_reading;
s->wait_writing = cachetable_wait_writing;
s->wait_checkpoint = cachetable_wait_checkpoint;
s->puts = cachetable_puts;
s->prefetches = cachetable_prefetches;
s->maybe_get_and_pins = cachetable_maybe_get_and_pins;
......@@ -2388,3 +2389,8 @@ toku_cachetable_get_fname_in_cwd(CACHETABLE ct, const char * fname_in_env) {
return toku_construct_full_name(2, ct->env_dir, fname_in_env);
}
// Returns the limit on the size of the cache table
uint64_t toku_cachetable_get_size_limit(CACHETABLE ct) {
return ct->size_limit;
}
......@@ -75,6 +75,10 @@ void toku_cachetable_get_miss_times(CACHETABLE ct, uint64_t *misscount, uint64_t
// Open a file and bind the file to a new cachefile object. (For use by test programs only.)
int toku_cachetable_openf (CACHEFILE *,CACHETABLE, const char */*fname_in_env*/, int flags, mode_t mode);
// Returns the limit on the cachetable size
uint64_t toku_cachetable_get_size_limit(CACHETABLE ct);
// Bind a file to a new cachefile object.
int toku_cachetable_openfd (CACHEFILE *,CACHETABLE, int /*fd*/,
const char *fname_relative_to_env); /*(used for logging)*/
......@@ -298,6 +302,7 @@ typedef struct cachetable_status {
u_int64_t waittime; /* how many usec spent waiting for another thread to release cache line */
u_int64_t wait_reading;
u_int64_t wait_writing;
u_int64_t wait_checkpoint; // number of times get_and_pin waits for a node to be written for a checkpoint
u_int64_t puts; // how many times has a newly created node been put into the cachetable?
u_int64_t prefetches; // how many times has a block been prefetched into the cachetable?
u_int64_t maybe_get_and_pins; // how many times has maybe_get_and_pin(_clean) been called?
......
......@@ -10,6 +10,7 @@
#include "toku_list.h"
#include "./lock_tree/locktree.h"
#include "./lock_tree/idlth.h"
#include "../newbrt/minicron.h"
#include <limits.h>
struct __toku_lock_tree;
......@@ -61,9 +62,26 @@ struct __toku_db_env_internal {
TOKULOGGER logger;
toku_ltm* ltm;
struct toku_list open_txns;
DB *directory; //Maps dnames to inames
DB *persistent_environment; //Stores environment settings, can be used for upgrade
OMT open_dbs; //Stores open db handles, sorted first by dname and then by numerical value of pointer to the db (arbitrarily assigned memory location)
DB *directory; // Maps dnames to inames
DB *persistent_environment; // Stores environment settings, can be used for upgrade
OMT open_dbs; // Stores open db handles, sorted first by dname and then by numerical value of pointer to the db (arbitrarily assigned memory location)
char *real_data_dir; // data dir used when the env is opened (relative to cwd)
char *real_log_dir; // log dir used when the env is opened (relative to cwd)
enum {
FS_GREEN = 0, // green zone (we have lots of space)
FS_YELLOW = 1, // yellow zone (issue warning but allow operations)
FS_RED = 2, // red zone (prevent operations)
} fs_state;
uint64_t fs_seq; // how many times has fs_poller run?
uint64_t last_seq_entered_red;
uint64_t last_seq_entered_yellow;
int redzone; // percent of total fs space that marks boundary between yellow and red zones
int enospc_seal_ctr; // number of operations rejected by enospc seal (red zone)
int fs_poll_time; // Time in seconds between statfs calls
struct minicron fs_poller; // Poll the file systems
BOOL fs_poller_is_init;
};
/* *********************************************************
......
This diff is collapsed.
......@@ -77,8 +77,16 @@ void toku_set_assert_on_write_enospc(int do_assert) __attribute__((__visibility_
// *enospc_total is the number of times ENOSPC was returned by write or pwrite
void toku_fs_get_write_info(time_t *enospc_last_time, uint64_t *enospc_current, uint64_t *enospc_total);
int toku_fsync_dirfd_without_accounting(DIR *dirp);
// Get the file system free and total space for the file system that contains a path name
// *avail_size is set to the bytes of free space in the file system available for non-root
// *free_size is set to the bytes of free space in the file system
// *total_size is set to the total bytes in the file system
// Return 0 on success, otherwise an error number
int toku_get_filesystem_sizes(const char *path, uint64_t *avail_size, uint64_t *free_size, uint64_t *total_size);
#if TOKU_WINDOWS
#include <sys/types.h>
#include <sys/stat.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment