From: oetiker Date: Mon, 11 Jun 2007 13:36:40 +0000 (+0000) Subject: Bernhard Fischer: X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=2815c8a96b82730e41cebf8a5065e00666c560b8;p=rrdtool.git Bernhard Fischer: - NEWS mention the new file accessors - rrd_update.c: remove unused some cruft git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1106 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/NEWS b/NEWS index e8ce64a..32ee7d4 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,14 @@ RRDTOOL NEWS ============ Major Changes between 1.2.x and 1.3.x +File access methods +------------------- +* introduced file-accessor functions rrd_read/rrd_seek/rrd_write +* implemented full mmap-based file access with madvise hints for improved + scalability, much reduced memory-footprint and much less blocking on + disk +* implemented optional full file-descriptor access instead of FILE* access + Graphing -------- * libart has been replaced by cairo/pango diff --git a/src/rrd_update.c b/src/rrd_update.c index d8632a7..78f9a57 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -325,6 +325,8 @@ int _rrd_update( if (rrd_file == NULL) { goto err_free; } + /* We are now at the beginning of the rra's */ + rra_current = rra_start = rra_begin = rrd_file->header_len; /* initialize time */ version = atoi(rrd.stat_head->version); @@ -337,26 +339,6 @@ int _rrd_update( current_time_usec = 0; } - rra_current = rra_start = rra_begin = rrd_file->header_len; - /* This is defined in the ANSI C standard, section 7.9.5.3: - - When a file is opened with udpate mode ('+' as the second - or third character in the ... list of mode argument - variables), both input and output may be performed on the - associated stream. However, ... input may not be directly - followed by output without an intervening call to a file - positioning function, unless the input operation encounters - end-of-file. */ -#if 0 //def HAVE_MMAP - rrd_filesize = rrd_file->file_size; - fseek(rrd_file->fd, 0, SEEK_END); - rrd_filesize = ftell(rrd_file->fd); - fseek(rrd_file->fd, rra_current, SEEK_SET); -#else -// fseek(rrd_file->fd, 0, SEEK_CUR); -#endif - - /* get exclusive lock to whole file. * lock gets removed when we close the file. */ @@ -435,26 +417,6 @@ int _rrd_update( rrd_set_error("allocating pdp_new ..."); goto err_free_tmpl_idx; } -#if 0 //def HAVE_MMAP - rrd_mmaped_file = mmap(0, - rrd_file->file_len, - PROT_READ | PROT_WRITE, - MAP_SHARED, fileno(in_file), 0); - if (rrd_mmaped_file == MAP_FAILED) { - rrd_set_error("error mmapping file %s", filename); - free(updvals); - free(pdp_temp); - free(tmpl_idx); - rrd_free(&rrd); - rrd_close(rrd_file); - return (-1); - } -#ifdef USE_MADVISE - /* when we use mmaping we tell the kernel the mmap equivalent - of POSIX_FADV_RANDOM */ - madvise(rrd_mmaped_file, rrd_filesize, POSIX_MADV_RANDOM); -#endif -#endif /* loop through the arguments. */ for (arg_i = 0; arg_i < argc; arg_i++) { char *stepper = strdup(argv[arg_i]); @@ -558,7 +520,6 @@ int _rrd_update( break; } - /* seek to the beginning of the rra's */ if (rra_current != rra_begin) { #ifndef HAVE_MMAP @@ -1419,11 +1380,7 @@ int _rrd_update( free(rra_step_cnt); rpnstack_free(&rpnstack); -#if 0 //def HAVE_MMAP - if (munmap(rrd_file->file_start, rrd_file->file_len) == -1) { - rrd_set_error("error writing(unmapping) file: %s", filename); - } -#else +#if 0 //rrd_flush(rrd_file); //XXX: really needed? #endif /* if we got here and if there is an error and if the file has not been @@ -1442,6 +1399,8 @@ int _rrd_update( rrd_set_error("seek rrd for live header writeback"); goto err_free_pdp_new; } + /* for mmap, we did already write to the underlying mapping, so we do + not need to write again. */ #ifndef HAVE_MMAP if (version >= 3) { if (rrd_write(rrd_file, rrd.live_head,