From 1bcac49c68fabae802e718cf7d488d2ddeac2010 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Sat, 2 Jun 2012 04:11:42 +0000 Subject: [PATCH] scst pr: Use fdatasync() instead of fsync() Synchronizing the file contents is sufficient - it is not necessary to synchronize metadata like atime and mtime after having saved persistent reservation information. A more clear explanation of what "datasync" means can be found here http://linux.die.net/man/2/fdatasync: fdatasync() is similar to fsync(), but does not flush modified metadata unless that metadata is needed in order to allow a subsequent data retrieval to be correctly handled. For example, changes to st_atime or st_mtime (respectively, time of last access and time of last modification; see stat(2)) do not require flushing because they are not necessary for a subsequent data read to be handled correctly. On the other hand, a change to the file size (st_size, as made by say ftruncate(2)), would require a metadata flush. The aim of fdatasync() is to reduce disk activity for applications that do not require all metadata to be synchronized with the disk. Signed-off-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4332 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_pres.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index 85e6ee9e9..a8245d732 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -1079,9 +1079,9 @@ void scst_pr_sync_device_file(struct scst_tgt_dev *tgt_dev, struct scst_cmd *cmd #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) res = scst_pr_vfs_fsync(file, 0, pos); #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) - res = vfs_fsync(file, file->f_path.dentry, 0); + res = vfs_fsync(file, file->f_path.dentry, 1); #else - res = vfs_fsync(file, 0); + res = vfs_fsync(file, 1); #endif if (res != 0) { PRINT_ERROR("fsync() of the PR file failed: %d", res); @@ -1097,9 +1097,9 @@ void scst_pr_sync_device_file(struct scst_tgt_dev *tgt_dev, struct scst_cmd *cmd #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) res = scst_pr_vfs_fsync(file, 0, sizeof(sign)); #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) - res = vfs_fsync(file, file->f_path.dentry, 0); + res = vfs_fsync(file, file->f_path.dentry, 1); #else - res = vfs_fsync(file, 0); + res = vfs_fsync(file, 1); #endif if (res != 0) { PRINT_ERROR("fsync() of the PR file failed: %d", res);