Adds a missing fadvise() for sequential access in parity creation.

This commit is contained in:
Andrea Mazzoleni 2013-02-27 20:58:03 +01:00
parent 14039c1a63
commit 94ba44c0e7

View file

@ -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;