[<prev] [next>] [day] [month] [year] [list]
Message-Id: <8d77478739361257c907be7f30a4193ed89efcb7.1388645728.git.baruch@tkos.co.il>
Date: Thu, 2 Jan 2014 08:55:28 +0200
From: Baruch Siach <baruch@...s.co.il>
To: Theodore Ts'o <tytso@....edu>
Cc: linux-ext4@...r.kernel.org, Baruch Siach <baruch@...s.co.il>
Subject: [PATCH] e4defrag: choose the best available posix_fadvise variant
Use posix_fadvise64() when available. This allows 64bit offsets on 32bit
systems.
Rename the internal posix_fadvise() implementation to avoid collision with the
C library signature that is sometimes present event when the implementation
itself is not. This fixes build errors like:
e4defrag.c:189:2: warning: #warning Using locally defined posix_fadvise interface. [-Wcpp
e4defrag.c:203:12: error: conflicting types for ‘posix_fadvise’
Signed-off-by: Baruch Siach <baruch@...s.co.il>
---
v2: fix #endif comment
---
configure.in | 1 +
misc/e4defrag.c | 29 ++++++++++++++++++++++-------
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/configure.in b/configure.in
index fef8d9b7b935..9f13a46ac8ae 100644
--- a/configure.in
+++ b/configure.in
@@ -1102,6 +1102,7 @@ AC_CHECK_FUNCS(m4_flatten([
open64
pathconf
posix_fadvise
+ posix_fadvise64
posix_memalign
prctl
secure_getenv
diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index c6a5f0daef96..7ad324b48fd2 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -183,13 +183,27 @@ static ext4_fsblk_t files_block_count;
static struct frag_statistic_ino frag_rank[SHOW_FRAG_FILES];
-/* Local definitions of some syscalls glibc may not yet have */
+/* Local definitions of some syscalls glibc may not yet have
+ *
+ * We prefer posix_fadvise64 when available, as it allows 64bit offset on
+ * 32bit systems
+ */
+
+#if defined(HAVE_POSIX_FADVISE64)
+#define posix_fadvise posix_fadvise64
+#elif defined(__NR_fadvise64_64)
+#define FADVISE_SYSCALL_NR __NR_fadvise64_64
+#elif defined(HAVE_POSIX_FADVISE)
+#define posix_fadvise posix_fadvise
+#elif defined(__NR_fadvise64)
+#define FADVISE_SYSCALL_NR __NR_fadvise64
+#endif
-#ifndef HAVE_POSIX_FADVISE
+#ifndef posix_fadvise
#warning Using locally defined posix_fadvise interface.
-#ifndef __NR_fadvise64_64
-#error Your kernel headers dont define __NR_fadvise64_64
+#ifndef FADVISE_SYSCALL_NR
+#error Your kernel headers dont define __NR_fadvise64_64 or __NR_fadvise64
#endif
/*
@@ -200,11 +214,12 @@ static struct frag_statistic_ino frag_rank[SHOW_FRAG_FILES];
* @len: area length.
* @advise: process flag.
*/
-static int posix_fadvise(int fd, loff_t offset, size_t len, int advise)
+#define posix_fadvise __posix_fadvise
+static int __posix_fadvise(int fd, loff_t offset, size_t len, int advise)
{
- return syscall(__NR_fadvise64_64, fd, offset, len, advise);
+ return syscall(FADVISE_SYSCALL_NR, fd, offset, len, advise);
}
-#endif /* ! HAVE_FADVISE64_64 */
+#endif /* ! posix_fadvise */
#ifndef HAVE_SYNC_FILE_RANGE
#warning Using locally defined sync_file_range interface.
--
1.8.5.2
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists