Browse Source

Support XFS RealTime partition

Suren A. Chilingaryan 12 years ago
parent
commit
4fdf54d469
4 changed files with 31 additions and 3 deletions
  1. 1 2
      .bzrignore
  2. 10 1
      CMakeLists.txt
  3. 1 0
      config.h.in
  4. 19 0
      default.c

+ 1 - 2
.bzrignore

@@ -3,8 +3,7 @@ config.h
 fastwriter.pc
 install_manifest.txt
 libfastwriter.so
-libfastwriter.so.0
-libfastwriter.so.0.0.1
 Makefile
 cmake_install.cmake
 CMakeCache.txt
+*.so.*

+ 10 - 1
CMakeLists.txt

@@ -1,14 +1,23 @@
 project(fastwriter)
 
-set(FASTWRITER_VERSION "0.0.1")
+set(FASTWRITER_VERSION "0.0.2")
 set(FASTWRITER_ABI_VERSION "0")
 
 cmake_minimum_required(VERSION 2.8)
 
+set(DISABLE_XFS_REALTIME FALSE CACHE BOOL "Disable support of RealTime XFS partition")
+
 
 include(CheckIncludeFiles)
 check_include_files("linux/falloc.h" HAVE_LINUX_FALLOC_H)
 
+if (NOT DISABLE_XFS_REALTIME)
+    check_include_files("xfs/xfs.h" HAVE_XFS_H)
+    if (NOT HAVE_XFS_H)
+	message(FATAL_ERROR "error: xfs/xfs.h is not found...")
+    endif (NOT HAVE_XFS_H)
+endif (NOT DISABLE_XFS_REALTIME)
+
 include_directories(
     ${CMAKE_SOURCE_DIR}/src 
     ${CMAKE_CURRENT_BINARY_DIR}

+ 1 - 0
config.h.in

@@ -1 +1,2 @@
 #cmakedefine HAVE_LINUX_FALLOC_H
+#cmakedefine DISABLE_XFS_REALTIME

+ 19 - 0
default.c

@@ -27,6 +27,10 @@
 # include <linux/falloc.h>
 #endif /* HAVE_LINUX_FALLOC_H */
 
+#ifndef DISABLE_XFS_REALTIME
+# include <xfs/xfs.h>
+#endif /* !DISABLE_XFS_REALTIME */
+
 #include "fastwriter.h"
 #include "private.h"
 #include "sysinfo.h"
@@ -55,6 +59,10 @@ int fastwriter_default_open(fastwriter_t *fw, const char *name, fastwriter_flags
     int err;
     char fs[16];
 
+#ifndef DISABLE_XFS_REALTIME
+    struct fsxattr attr;
+#endif /* !DISABLE_XFS_REALTIME */
+
     int open_flags = (O_CREAT|O_WRONLY|O_NOATIME|O_LARGEFILE);
     int open_mode = (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
 
@@ -127,6 +135,17 @@ int fastwriter_default_open(fastwriter_t *fw, const char *name, fastwriter_flags
 # endif /* SYNC_MODE */
     }
 
+#ifndef DISABLE_XFS_REALTIME
+    if (!strcmp(fs, "xfs")) {
+	err = xfsctl (name, ctx->fd, XFS_IOC_FSGETXATTR, (void *) &attr);
+	if (!err) {
+	    attr.fsx_xflags |= XFS_XFLAG_REALTIME;
+	    err = xfsctl (name, ctx->fd, XFS_IOC_FSSETXATTR, (void *) &attr);
+//	    if (!err) puts("Real-time");
+	}
+    }
+#endif /* !DISABLE_XFS_REALTIME */
+
     ctx->preallocated = 0;
 
     return 0;