[stgt] [PATCH] avoid sync_file_range

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Thu Jun 16 19:54:29 CEST 2011


sync_file_range doesn't work with some file systems in an expected way
so just use fdatasync instead.

Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
 usr/bs_rdwr.c |    2 +-
 usr/util.h    |   21 ---------------------
 2 files changed, 1 insertions(+), 22 deletions(-)

diff --git a/usr/bs_rdwr.c b/usr/bs_rdwr.c
index 4003996..1ee044a 100644
--- a/usr/bs_rdwr.c
+++ b/usr/bs_rdwr.c
@@ -50,7 +50,7 @@ static void bs_sync_sync_range(struct scsi_cmd *cmd, uint32_t length,
 {
 	int ret;
 
-	ret = __sync_file_range(cmd->dev->fd, cmd->offset, length);
+	ret = fdatasync(cmd->dev->fd);
 	if (ret)
 		set_medium_error(result, key, asc);
 }
diff --git a/usr/util.h b/usr/util.h
index 9530d2a..d4e9406 100644
--- a/usr/util.h
+++ b/usr/util.h
@@ -100,27 +100,6 @@ do {									\
 
 extern unsigned long pagesize, pageshift;
 
-#if defined (SYNC_FILE_RANGE_WAIT_BEFORE) && \
-	(defined(__NR_sync_file_range) || defined(__NR_sync_file_range2))
-static inline int __sync_file_range(int fd, __off64_t offset, __off64_t bytes)
-{
-	int ret;
-#if defined(__NR_sync_file_range)
-	long int n = __NR_sync_file_range;
-#else
-	long int n = __NR_sync_file_range2;
-#endif
-	unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE
-		| SYNC_FILE_RANGE_WAIT_AFTER;
-	ret = syscall(n, fd, offset, bytes, flags);
-	if (ret)
-		ret = fsync(fd);
-	return ret;
-}
-#else
-#define __sync_file_range(fd, offset, bytes) fsync(fd)
-#endif
-
 #if defined(__NR_signalfd) && defined(USE_SIGNALFD)
 
 /*
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list