Browse Source

reduce FSync option to a boolean

there is no use for Thorough mode any more, so simplify the
configuration.
wip/maildir-uid-dupes-test
Oswald Buddenhagen 11 years ago
parent
commit
71524cb6b0
  1. 10
      src/config.c
  2. 4
      src/drv_maildir.c
  3. 7
      src/isync.h
  4. 27
      src/mbsync.1
  5. 2
      src/run-tests.pl
  6. 4
      src/sync.c

10
src/config.c

@ -38,7 +38,7 @@ channel_conf_t global_conf;
store_conf_t *stores;
channel_conf_t *channels;
group_conf_t *groups;
int FSyncLevel = FSYNC_NORMAL;
int UseFSync = 1;
#define ARG_OPTIONAL 0
#define ARG_REQUIRED 1
@ -470,13 +470,7 @@ load_config( const char *where, int pseudo )
}
else if (!strcasecmp( "FSync", cfile.cmd ))
{
arg = cfile.val;
if (!strcasecmp( "None", arg ))
FSyncLevel = FSYNC_NONE;
else if (!strcasecmp( "Normal", arg ))
FSyncLevel = FSYNC_NORMAL;
else if (!strcasecmp( "Thorough", arg ))
FSyncLevel = FSYNC_THOROUGH;
UseFSync = parse_bool( &cfile );
}
else if (!getopt_helper( &cfile, &gcops, &global_conf ))
{

4
src/drv_maildir.c

@ -439,7 +439,7 @@ maildir_store_uid( maildir_store_t *ctx )
n = sprintf( buf, "%d\n%d\n", ctx->gen.uidvalidity, ctx->nuid );
lseek( ctx->uvfd, 0, SEEK_SET );
if (write( ctx->uvfd, buf, n ) != n || ftruncate( ctx->uvfd, n ) || (FSyncLevel >= FSYNC_NORMAL && fdatasync( ctx->uvfd ))) {
if (write( ctx->uvfd, buf, n ) != n || ftruncate( ctx->uvfd, n ) || (UseFSync && fdatasync( ctx->uvfd ))) {
error( "Maildir error: cannot write UIDVALIDITY.\n" );
return DRV_BOX_BAD;
}
@ -1213,7 +1213,7 @@ maildir_store_msg( store_t *gctx, msg_data_t *data, int to_trash,
}
ret = write( fd, data->data, data->len );
free( data->data );
if (ret != data->len || ((FSyncLevel >= FSYNC_NORMAL) && (ret = fsync( fd )))) {
if (ret != data->len || (UseFSync && (ret = fsync( fd )))) {
if (ret < 0)
sys_error( "Maildir error: cannot write %s", buf );
else

7
src/isync.h

@ -488,12 +488,7 @@ extern driver_t *drivers[N_DRIVERS];
extern channel_conf_t global_conf;
extern channel_conf_t *channels;
extern group_conf_t *groups;
#define FSYNC_NONE 0
#define FSYNC_NORMAL 1
#define FSYNC_THOROUGH 2
extern int FSyncLevel;
extern int UseFSync;
int parse_bool( conffile_t *cfile );
int parse_int( conffile_t *cfile );

27
src/mbsync.1

@ -534,23 +534,16 @@ times within a Group.
..
.SS Global Options
.TP
\fBFSync\fR {\fINone\fR|\fINormal\fR|\fIThorough\fR}
.br
Select the amount of forced flushing \fBmbsync\fR performs, which determines
the level of data safety after system crashes and power outages:
.br
\fBNone\fR - no flushing at all. This is reasonably safe for file systems
which are mounted with data=ordered mode.
.br
\fBNormal\fR - message and critical metadata writes are flushed. No data
should be lost due to crashes, though it is still possible that messages
are duplicated after crashes. This is the default, and is a wise choice for
file systems mounted with data=writeback, in particular modern systems like
ext4, btrfs and xfs. The performance impact on older file systems may be
disproportionate.
.br
\fBThorough\fR - this avoids message duplication after crashes as well,
at some additional performance cost.
\fBFSync\fR \fIyes\fR|\fIno\fR
.br
Selects whether \fBmbsync\fR performs forced flushing, which determines
the level of data safety after system crashes and power outages.
Disabling it is reasonably safe for file systems which are mounted with
data=ordered mode.
Enabling it is a wise choice for file systems mounted with data=writeback,
in particular modern systems like ext4, btrfs and xfs. The performance impact
on older file systems may be disproportionate.
(Default: \fIyes\fR)
..
.SH INHERENT PROBLEMS
Changes done after \fBmbsync\fR has retrieved the message list will not be

2
src/run-tests.pl

@ -249,7 +249,7 @@ sub writecfg($$$)
open(FILE, ">", ".mbsyncrc") or
die "Cannot open .mbsyncrc.\n";
print FILE
"FSync None
"FSync no
MaildirStore master
Path ./

4
src/sync.c

@ -44,7 +44,7 @@ const char *str_ms[] = { "master", "slave" }, *str_hl[] = { "push", "pull" };
void
Fclose( FILE *f, int safe )
{
if ((safe && (fflush( f ) || (FSyncLevel >= FSYNC_NORMAL && fdatasync( fileno( f ) )))) || fclose( f ) == EOF) {
if ((safe && (fflush( f ) || (UseFSync && fdatasync( fileno( f ) )))) || fclose( f ) == EOF) {
sys_error( "Error: cannot close file. Disk full?" );
exit( 1 );
}
@ -1511,7 +1511,7 @@ box_loaded( int sts, void *aux )
}
debug( "propagating new messages\n" );
if (FSyncLevel >= FSYNC_NORMAL)
if (UseFSync)
fdatasync( fileno( svars->jfp ) );
for (t = 0; t < 2; t++) {
Fprintf( svars->jfp, "%c %d\n", "{}"[t], svars->ctx[t]->uidnext );

Loading…
Cancel
Save