void-packages/srcpkgs/gpart/patches/0003-gpart-use-posix_fadvis...

43 lines
1.3 KiB
Diff

From b01b124b36f81a76d38eb0169e6d279a777646c9 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@arcor.de>
Date: Thu, 19 Nov 2015 23:24:43 +0100
Subject: [PATCH 3/5] gpart: use posix_fadvise to increase reading speed
Use fadvise to tell the OS to try readahead.
---
configure.ac | 2 +-
src/gpart.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git configure.ac configure.ac
index 6eca1de..21dfc00 100644
--- configure.ac
+++ configure.ac
@@ -26,7 +26,7 @@ AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_MALLOC
-AC_CHECK_FUNCS([getpagesize memset strchr strdup strerror strtoul])
+AC_CHECK_FUNCS([getpagesize memset strchr strdup strerror strtoul posix_fadvise])
# Configure system services.
AC_SYS_LARGEFILE
diff --git src/gpart.c src/gpart.c
index bd3806a..63b36a5 100644
--- src/gpart.c
+++ src/gpart.c
@@ -949,6 +949,10 @@ static void do_guess_loop(disk_desc *d)
if ((d->d_fd = open(d->d_dev,O_RDONLY)) == -1)
pr(FATAL,EM_OPENFAIL,d->d_dev,strerror(errno));
+#if HAVE_POSIX_FADVISE
+ posix_fadvise(d->d_fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+ posix_fadvise(d->d_fd, 0, 0, POSIX_FADV_WILLNEED);
+#endif /* HAVE_POSIX_FADVISE */
/*
* initialize modules. Each should return the minimum
* size in bytes it wants to receive for a test.
--
2.24.0