[stgt] [PATCH 03/14] tgt: Make defintion of sync_file_range a configure option

Boaz Harrosh bharrosh at panasas.com
Mon Feb 23 18:51:25 CET 2009


usr/util.h redefines sync_file_range (as __sync_file_range)
for old systems that don't have this defintion. Make these
definitions conditional on __CONF_TGT_NO_SYNC_FILE_RANGE which
should be set by a Makefile on very old systems.
(Or a ./configure script can detect that automatically)

Normally sync_file_range() definition is now taken from gcc
headers.

Signed-off-by: Boaz Harrosh <bharrosh at panasas.com>
---
 usr/bs_mmap.c |    2 +-
 usr/bs_rdwr.c |    2 +-
 usr/util.h    |    6 ++++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/usr/bs_mmap.c b/usr/bs_mmap.c
index bb24f5e..f0037e8 100644
--- a/usr/bs_mmap.c
+++ b/usr/bs_mmap.c
@@ -60,7 +60,7 @@ static void bs_mmap_request(struct scsi_cmd *cmd)
 		unsigned int flags =
 			SYNC_FILE_RANGE_WAIT_BEFORE| SYNC_FILE_RANGE_WRITE;
 
-		ret = __sync_file_range(cmd->dev->fd, cmd->offset, length, flags);
+		ret = sync_file_range(cmd->dev->fd, cmd->offset, length, flags);
 		if (ret) {
 			result = SAM_STAT_CHECK_CONDITION;
 			key = MEDIUM_ERROR;
diff --git a/usr/bs_rdwr.c b/usr/bs_rdwr.c
index 65a6136..73adf57 100644
--- a/usr/bs_rdwr.c
+++ b/usr/bs_rdwr.c
@@ -51,7 +51,7 @@ static void bs_sync_sync_range(struct scsi_cmd *cmd, uint32_t length,
 	int ret;
 	unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE| SYNC_FILE_RANGE_WRITE;
 
-	ret = __sync_file_range(cmd->dev->fd, cmd->offset, length, flags);
+	ret = sync_file_range(cmd->dev->fd, cmd->offset, length, flags);
 	if (ret)
 		set_medium_error(result, key, asc);
 }
diff --git a/usr/util.h b/usr/util.h
index 794c70b..11afbaa 100644
--- a/usr/util.h
+++ b/usr/util.h
@@ -99,6 +99,8 @@ extern unsigned long pagesize, pageshift;
  * most of the distributions aren't shipped with it yet.
 */
 
+#ifdef __CONF_TGT_NO_SYNC_FILE_RANGE
+
 #ifndef __NR_sync_file_range
 #if defined(__i386)
 #define __NR_sync_file_range	314
@@ -119,15 +121,15 @@ extern unsigned long pagesize, pageshift;
 
 extern long int syscall(long int sysno, ...);
 
-static inline int __sync_file_range(int fd, __off64_t offset, __off64_t bytes,
+static inline int sync_file_range(int fd, __off64_t offset, __off64_t bytes,
 				    unsigned int flags)
 {
 	int ret;
-
 	ret = syscall(__NR_sync_file_range, fd, offset, bytes, flags);
 	if (ret == -EPERM)
 		ret = fsync(fd);
 	return ret;
 }
+#endif /* def __CONF_TGT_NO_SYNC_FILE_RANGE */
 
 #endif
-- 
1.6.0.6

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