Uses O_NOATIME if possible.

This commit is contained in:
Andrea Mazzoleni 2012-11-03 23:57:12 +01:00
parent 8f4e5e88a3
commit db6ff47062
6 changed files with 22 additions and 9 deletions

View file

@ -26,6 +26,8 @@ SnapRAID HISTORY
* Removed the '-H,--filter-nohidden' option. It doesn't make sense to
have it as command line option.
You must use the 'nohidden' option in the configuration file.
* When opening files in read-only mode, also specify the noatime flag,
to avoid to update the file access time.
1.13 2012/11
============

13
TODO
View file

@ -32,6 +32,14 @@ is too complex.
- v2.x
* Checked the include/exclude rules for FILE to include also directories.
This is needed to allow to exclude files, before even calling stat() on them
to know if they are file or directory.
There are some cases where this is needed, like for the ".gvfs" mounted fuse directory by
gnome that cannot have stat() called *EVEN* by root.
This is totally wrong, because the stat() manpage explicitely tells that no permissions are
needed to call stat().
* Remove the old MD5 support.
* A new 'init' command to differentiate the first 'sync' operation.
@ -104,11 +112,6 @@ This is a list of rejected TODO items.
data doesn't overlap, do not recompute it.
- It's going to work only in RAID5 mode and only in special cases.
* Uses the O_NOATIME flag if run as 'root'.
- A better solution is to mount the disk with the "noatime" mount option.
Note also that at mount time you can also use the "nodiratime", and this is
the only way to specify it.
* Implements a multithread sync command.
- At now it's questionable if it will result in a performance improvment.
The murmur3 hash, and the RAID5/6 computations are so fast that even a single

View file

@ -87,7 +87,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file)
/* if failed for missing permission */
if (handle->f == -1 && errno == EACCES) {
/* retry without requesting write permission */
handle->f = open(handle->path, O_RDONLY | O_BINARY | O_SEQUENTIAL | O_NOFOLLOW);
handle->f = open(handle->path, O_RDONLY | O_BINARY | O_SEQUENTIAL | O_NOFOLLOW | O_NOATIME);
}
if (handle->f == -1) {
@ -161,7 +161,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file)
/* opening in sequential mode in Windows */
/* do not follow links to ensure to open the real file */
handle->f = open(handle->path, O_RDONLY | O_BINARY | O_SEQUENTIAL | O_NOFOLLOW);
handle->f = open(handle->path, O_RDONLY | O_BINARY | O_SEQUENTIAL | O_NOFOLLOW | O_NOATIME);
if (handle->f == -1) {
/* invalidate for error */

View file

@ -222,7 +222,7 @@ int parity_open(struct snapraid_parity* parity, const char* path)
pathcpy(parity->path, sizeof(parity->path), path);
/* opening in sequential mode in Windows */
parity->f = open(parity->path, O_RDONLY | O_BINARY | O_SEQUENTIAL);
parity->f = open(parity->path, O_RDONLY | O_BINARY | O_SEQUENTIAL | O_NOATIME);
if (parity->f == -1) {
fprintf(stderr, "Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
return -1;

View file

@ -137,6 +137,14 @@
#define STAT_NSEC(st) -1
#endif
/**
* Defines O_NOATIME if absent.
* O_NOATIME is used to open files in RDONLY mode avoding to update their access time.
*/
#ifndef O_NOATIME
#define O_NOATIME 0
#endif
/**
* Check if the specified file is hidden.
*/

2
scan.c
View file

@ -454,7 +454,7 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, i
const char* name;
struct dirent* dd;
/* clear errno to detect errneous conditions */
/* clear errno to detect erroneous conditions */
errno = 0;
dd = readdir(d);
if (dd == 0 && errno != 0) {