mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04:00
Adds initial readahead support.
This commit is contained in:
parent
87bb5c7a66
commit
d24df4257e
3 changed files with 34 additions and 0 deletions
2
HISTORY
2
HISTORY
|
|
@ -3,6 +3,8 @@ SnapRAID HISTORY
|
|||
|
||||
0.2 2011/3
|
||||
==========
|
||||
* Second public test release of SnapRAID.
|
||||
* Functionally complete in check and fix.
|
||||
* Files are identified by inode and not anymore by name.
|
||||
* Exclusion list of files and directories.
|
||||
* Precise error management.
|
||||
|
|
|
|||
25
handle.c
25
handle.c
|
|
@ -287,3 +287,28 @@ int handle_write(struct snapraid_handle* handle, struct snapraid_block* block, u
|
|||
return 0;
|
||||
}
|
||||
|
||||
int handle_readahead(struct snapraid_handle* handle, struct snapraid_block* block, unsigned block_size)
|
||||
{
|
||||
#if HAVE_POSIX_FADVISE
|
||||
data_off_t offset;
|
||||
unsigned read_size;
|
||||
int ret;
|
||||
|
||||
/* do nothing if the file is different */
|
||||
if (handle->file != block->file)
|
||||
return 0;
|
||||
|
||||
offset = block_file_pos(block) * (data_off_t)block_size;
|
||||
|
||||
read_size = block_file_size(block, block_size);
|
||||
|
||||
/* advise access of the next block */
|
||||
ret = posix_fadvise(handle->f, offset, read_size, POSIX_FADV_WILLNEED);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Error advising file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
7
handle.h
7
handle.h
|
|
@ -61,5 +61,12 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
|
|||
*/
|
||||
int handle_write(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size);
|
||||
|
||||
/**
|
||||
* Readahead optimization where available.
|
||||
* \note
|
||||
* It doesn't seem to give any speed improvement over posix_fadvise(POSIX_FADV_SEQUENTIAL).
|
||||
*/
|
||||
int handle_readahead(struct snapraid_handle* handle, struct snapraid_block* block, unsigned block_size);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue