From eb26b6aa1f08672c52b6d93fdb184dc9087591ac Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 26 Apr 2011 19:15:36 +0200 Subject: [PATCH] Uses O_SEQUENTIAL in Windows. --- HISTORY | 2 ++ handle.c | 6 ++++-- parity.c | 6 ++++-- portable.h | 5 +++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/HISTORY b/HISTORY index 54568a42..360fa5db 100644 --- a/HISTORY +++ b/HISTORY @@ -9,6 +9,8 @@ SnapRAID HISTORY MD5 is still supported for backward compatibility. * The check command returns with an error code if any kind of error is present. Previously it was only if unrecoverable errors were present. +* Opening the files in sequential mode in Windows. This should give + a light speedup in Windows. 1.0 2011/4 ========== diff --git a/handle.c b/handle.c index 51270f56..b6344189 100644 --- a/handle.c +++ b/handle.c @@ -110,7 +110,8 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file) return -1; } - handle->f = open(handle->path, O_RDWR | O_CREAT | O_BINARY, 0600); + /* opening in sequential mode in Windows */ + handle->f = open(handle->path, O_RDWR | O_CREAT | O_BINARY | O_SEQUENTIAL, 0600); if (handle->f == -1) { /* invalidate for error */ handle->file = 0; @@ -175,8 +176,9 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file) return 0; } + /* opening in sequential mode in Windows */ pathprint(handle->path, sizeof(handle->path), "%s%s", handle->disk->dir, file->sub); - handle->f = open(handle->path, O_RDONLY | O_BINARY); + handle->f = open(handle->path, O_RDONLY | O_BINARY | O_SEQUENTIAL); if (handle->f == -1) { /* invalidate for error */ diff --git a/parity.c b/parity.c index 5bec0b66..dbaece59 100644 --- a/parity.c +++ b/parity.c @@ -55,7 +55,8 @@ int parity_create(const char* path, data_off_t size) int ret; int f; - f = open(path, O_RDWR | O_CREAT | O_BINARY, 0600); + /* opening in sequential mode in Windows */ + f = open(path, O_RDWR | O_CREAT | O_BINARY | O_SEQUENTIAL, 0600); if (f == -1) { fprintf(stderr, "Error opening parity file '%s'. %s.\n", path, strerror(errno)); return -1; @@ -114,7 +115,8 @@ int parity_open(const char* path) #endif int f; - f = open(path, O_RDONLY | O_BINARY); + /* opening in sequential mode in Windows */ + f = open(path, O_RDONLY | O_BINARY | O_SEQUENTIAL); if (f == -1) { fprintf(stderr, "Error opening parity file '%s'. %s.\n", path, strerror(errno)); return -1; diff --git a/portable.h b/portable.h index b79f94e8..fbc07772 100644 --- a/portable.h +++ b/portable.h @@ -106,11 +106,12 @@ #define SWITCH_GETOPT_LONG(a,b) b #endif -#ifndef O_BINARY +#ifndef __MINGW32__ /* Specific for Unix */ #define O_BINARY 0 +#define O_SEQUENTIAL 0 #endif -#ifdef __MINGW32__ /* Specific for MINGW */ +#ifdef __MINGW32__ /* Specific for Windows MINGW */ /* Remap functions and types for 64 bit support */ #define stat windows_stat