Commit 46ec1c8b authored by Per Cederqvist's avatar Per Cederqvist

Remove the reclamation field of Text_stat.

	* src/include/kom-types.h (Text_stat): Remove the reclamation
	field.  It was a mistake to add it 2006-11-06.
	* src/server/dbck-cache.c (cached_flush_text): Don't touch
	reclamation.
	* src/server/memory.c (copy_text_stat): Ditto.
	(init_text_stat): Ditto.
	* src/server/ram-output.c (foutput_text_stat_3): Ditto.
	* src/server/ram-parse.c (fparse_text_stat_3): Ditto.
	(fparse_text_stat_2): Ditto.
	(fparse_text_stat_0): Ditto.
	* src/server/simple-cache.c (cached_create_text): Ditto.
parent 50e88538
sstrdup
dbfile-temp-filenames
From: Per Cederqvist <ceder@lysator.liu.se>
Subject: Write dbfiles atomically, renaming them once complete.
Subject: Remove the reclamation field of Text_stat. * src/include/kom-types.h (Text_stat): Remove the reclamation field. It was a mistake to add it 2006-11-06. * src/server/dbck-cache.c (cached_flush_text): Don't touch reclamation. * src/server/memory.c (copy_text_stat): Ditto. (init_text_stat): Ditto. * src/server/ram-output.c (foutput_text_stat_3): Ditto. * src/server/ram-parse.c (fparse_text_stat_3): Ditto. (fparse_text_stat_2): Ditto. (fparse_text_stat_0): Ditto. * src/server/simple-cache.c (cached_create_text): Ditto.
Added support for renaming a datafile once it has been completely
written, and to write it using a temporary extension.
* src/server/ram-io.h (struct dbfile): Added fields fn,
tmp_extension and tmp_fn. Added documentation.
(dbfile_open_write): New argument: tmp_extension.
(dbfile_rename): New function.
(dbfile_abort): New function.
* src/server/ram-io.c (dbfile_new): Initialize fn, tmp_extension
and tmp_fn.
(current_fn): New static function. Return tmp_fn if non-NULL,
otherwise fn.
(dbfile_delete): Free the new fields fn, tmp_extension and
tmp_fn.
(dbfile_open_write): New argument: tmp_extension. Store a copy of
the supplied filename. If tmp_extension is non-NULL, store a copy
of it, and compute the actual file name to open as the filname
followed by the tmp_extension.
(fsync_dirname): New static function.
(dbfile_rename): New function. Rename the file from tmp_fn to the
wanted final filename, and sync the directory.
(dbfile_abort): New function.
* src/server/dbck-cache.c (cache_sync_all): Pass a NULL pointer as
tmp_extension of dbfile_open_write(), to get the old behavior.
* src/server/simple-cache.c (pre_sync): Ditto.
......@@ -42,6 +42,19 @@
2010-04-01 Per Cederqvist <ceder@lysator.liu.se>
Remove the reclamation field of Text_stat.
* src/include/kom-types.h (Text_stat): Remove the reclamation
field. It was a mistake to add it 2006-11-06.
* src/server/dbck-cache.c (cached_flush_text): Don't touch
reclamation.
* src/server/memory.c (copy_text_stat): Ditto.
(init_text_stat): Ditto.
* src/server/ram-output.c (foutput_text_stat_3): Ditto.
* src/server/ram-parse.c (fparse_text_stat_3): Ditto.
(fparse_text_stat_2): Ditto.
(fparse_text_stat_0): Ditto.
* src/server/simple-cache.c (cached_create_text): Ditto.
Added support for renaming a datafile once it has been completely
written, and to write it using a temporary extension.
* src/server/ram-io.h (struct dbfile): Added fields fn,
......
......@@ -215,7 +215,6 @@ typedef unsigned long Garb_nice;
typedef struct {
Time creation_time;
long generation;
long reclamation;
long file_pos; /* Start of the text in the text file. */
Pers_no author;
unsigned short no_of_lines;
......
......@@ -425,7 +425,6 @@ cached_flush_text(Text_no text_no,
fseek(new_text_file, 0, SEEK_END);
#warning Generation > 0 not yet handled
text_arr[ text_no ]->generation = 0;
text_arr[ text_no ]->reclamation = 0;
text_arr[ text_no ]->file_pos = ftell(new_text_file);
if ( fwrite(message.string, sizeof(char), message.len, new_text_file)
......
......@@ -609,7 +609,6 @@ copy_text_stat(const Text_stat *t)
c = alloc_text_stat();
c->creation_time = t->creation_time;
c->generation = t->generation;
c->reclamation = t->reclamation;
c->file_pos = t->file_pos;
c->author = t->author;
c->no_of_lines = t->no_of_lines;
......@@ -629,7 +628,6 @@ init_text_stat (Text_stat *t)
{
t->creation_time = NO_TIME;
t->generation = 0;
t->reclamation = 0;
t->file_pos = 0;
t->author = 0;
t->no_of_lines = 0;
......
......@@ -381,7 +381,6 @@ foutput_text_stat_3(struct dbfile *fp,
foutput_ulong((unsigned long) t_stat->author, fp);
foutput_ulong((unsigned long) t_stat->generation, fp);
foutput_ulong((unsigned long) t_stat->reclamation, fp);
foutput_ulong((unsigned long) t_stat->file_pos, fp);
foutput_ulong((unsigned long) t_stat->no_of_lines, fp);
foutput_ulong((unsigned long) t_stat->no_of_chars, fp);
......
......@@ -1050,7 +1050,6 @@ fparse_text_stat_3(struct dbfile *fp,
result->author = fparse_long(fp);
result->generation = fparse_long(fp);
result->reclamation = fparse_long(fp);
result->file_pos = fparse_long(fp);
result->no_of_lines = fparse_long(fp);
result->no_of_chars = fparse_long(fp);
......@@ -1168,7 +1167,6 @@ fparse_text_stat_2(struct dbfile *fp,
result->author = fparse_long(fp);
result->generation = 0;
result->reclamation = 0;
result->file_pos = fparse_long(fp);
result->no_of_lines = fparse_long(fp);
result->no_of_chars = fparse_long(fp);
......@@ -1286,7 +1284,6 @@ fparse_text_stat_0(struct dbfile *fp,
result->author = fparse_long(fp);
result->generation = 0;
result->reclamation = 0;
result->file_pos = fparse_long(fp);
result->no_of_lines = fparse_long(fp);
result->no_of_chars = fparse_long(fp);
......
......@@ -1228,7 +1228,6 @@ cached_create_text(const String message)
((Text_stat *)node->ptr)->no_of_lines = 0;
((Text_stat *)node->ptr)->no_of_chars = 0;
((Text_stat *)node->ptr)->generation = 0;
((Text_stat *)node->ptr)->reclamation = 0;
((Text_stat *)node->ptr)->file_pos = file_pos;
text_set_mru( tno );
......
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