From 94ba44c0e72d57f88b28ff71a7c882826fb12c4f Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 27 Feb 2013 20:58:03 +0100 Subject: [PATCH] Adds a missing fadvise() for sequential access in parity creation. --- parity.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/parity.c b/parity.c index 7a0bbec0..a1f448c2 100644 --- a/parity.c +++ b/parity.c @@ -97,6 +97,7 @@ int parity_create(struct snapraid_parity* parity, const char* path, data_off_t* pathcpy(parity->path, sizeof(parity->path), path); /* opening in sequential mode in Windows */ + /* O_SEQUENTIAL: opening in sequential mode in Windows */ parity->f = open(parity->path, O_RDWR | O_CREAT | O_BINARY | O_SEQUENTIAL, 0600); if (parity->f == -1) { fprintf(stderr, "Error opening parity file '%s'. %s.\n", parity->path, strerror(errno)); @@ -110,6 +111,15 @@ int parity_create(struct snapraid_parity* parity, const char* path, data_off_t* goto bail; } +#if HAVE_POSIX_FADVISE + /* advise sequential access */ + ret = posix_fadvise(parity->f, 0, 0, POSIX_FADV_SEQUENTIAL); + if (ret != 0) { + fprintf(stderr, "Error advising parity file '%s'. %s.\n", parity->path, strerror(ret)); + goto bail; + } +#endif + /* get the size of the existing data */ parity->valid_size = parity->st.st_size; *out_size = parity->st.st_size;