Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | From 9d260d408f9e17abd1d1dccd685bd7e80a3655a9 Mon Sep 17 00:00:00 2001 |
| 2 | From: Donn Seeley <donn.seeley@windriver.com> |
| 3 | Date: Tue, 25 Feb 2014 17:44:04 +0800 |
| 4 | Subject: [PATCH] dpkg: fix a link problem for dpkg-native on CentOS 5.8 |
| 5 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6 | CentOS 5.8 kernels and headers support the sync_file_range() system call, |
| 7 | but glibc 2.5 doesn't provide the syscall stub. It appears that this |
| 8 | problem is known but will never be fixed: |
| 9 | |
| 10 | https://bugzilla.redhat.com/show_bug.cgi?id=518581 |
| 11 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12 | Bug 518581 - [RHEL5] glibc misses sync_file_range syscall interface |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14 | Status: CLOSED CANTFIX |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15 | Last Closed: 2009-11-22 22:19:55 |
| 16 | |
| 17 | Kirby Zhou 2009-08-20 23:37:55 EDT |
| 18 | |
| 19 | Description of problem: |
| 20 | |
| 21 | glibc misses sync_file_range syscall interface. The header file and |
| 22 | man page both say 'sync_file_range' should exist. From man page, |
| 23 | sync_file_range should exist sinc kernel-2.6.17 |
| 24 | |
| 25 | Andreas Schwab 2009-08-21 03:24:24 EDT |
| 26 | |
| 27 | It has only been added to glibc 2.6, and cannot be backported due to |
| 28 | ABI breakage. You can always fall back to syscall(3). |
| 29 | |
| 30 | Ulrich Drepper 2009-11-22 22:19:55 EST |
| 31 | |
| 32 | As comment #1 says, no chance to backport this. |
| 33 | |
| 34 | See the syscall man page for instructions. |
| 35 | |
| 36 | Jon E 2010-03-19 10:32:37 EDT |
| 37 | |
| 38 | then why document it if it's broken and you're not going to fix it? |
| 39 | .. might want to FTFM over at sync_file_range(2) - in the meantime - |
| 40 | borrowing from glibc 2.6 .. any thoughts on this implementation for a |
| 41 | hacky workaround for those still on your "ancient releases" .. (eg: |
| 42 | RHEL5.3)?: |
| 43 | |
| 44 | #ifdef ULI_WONT_FIX_THIS_IN_GLIBC2.5 |
| 45 | #define NR_sync_file_range 277 |
| 46 | int sync_file_range (int fd, __off64_t from, __off64_t to, unsigned int flags) |
| 47 | { |
| 48 | return syscall (NR_sync_file_range, fd, |
| 49 | __LONG_LONG_PAIR ((long) (from >> 32), (long) from), |
| 50 | __LONG_LONG_PAIR ((long) (to >> 32), (long) to), |
| 51 | flags); |
| 52 | } |
| 53 | #endif |
| 54 | |
| 55 | assuming of course that you're on an x86_64 and include/asm- |
| 56 | x86_64/unistd.h has the correct entry |
| 57 | |
| 58 | (fwiw - fio is starting to use this now) |
| 59 | |
| 60 | Rather than attempting to provide an implementation using syscall(), |
| 61 | we take the more conservative route and ignore header support for |
| 62 | sync_file_range() flags when the glibc version is <= 2.5. |
| 63 | |
| 64 | Upstream-Status: Inappropriate [everyone else builds on newer hosts :-)] |
| 65 | |
| 66 | Signed-off-by: Donn Seeley <donn.seeley@windriver.com> |
| 67 | Signed-off-by: Lei Liu <lei.liu2@windriver.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 68 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 69 | Update patch context for dpkg 1.19.4. |
| 70 | |
| 71 | Signed-off-by: Kai Kang <kai.kang@windriver.com> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 72 | --- |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 73 | src/archives.c | 4 ++-- |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 74 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 75 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 76 | diff --git a/src/archives.c b/src/archives.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 77 | index 8476a5c..b05a63f 100644 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 78 | --- a/src/archives.c |
| 79 | +++ b/src/archives.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 80 | @@ -68,7 +68,7 @@ fd_writeback_init(int fd) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | /* Ignore the return code as it should be considered equivalent to an |
| 82 | * asynchronous hint for the kernel, we are doing an fsync() later on |
| 83 | * anyway. */ |
| 84 | -#if defined(SYNC_FILE_RANGE_WRITE) |
| 85 | +#if defined(SYNC_FILE_RANGE_WRITE) && __GLIBC_PREREQ(2, 6) |
| 86 | sync_file_range(fd, 0, 0, SYNC_FILE_RANGE_WRITE); |
| 87 | #elif defined(HAVE_POSIX_FADVISE) |
| 88 | posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 89 | @@ -1093,7 +1093,7 @@ tarobject(struct tar_archive *tar, struct tar_entry *ti) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | -#if defined(SYNC_FILE_RANGE_WAIT_BEFORE) |
| 94 | +#if defined(SYNC_FILE_RANGE_WAIT_BEFORE) && __GLIBC_PREREQ(2, 6) |
| 95 | static void |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 96 | tar_writeback_barrier(struct fsys_namenode_list *files, struct pkginfo *pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 97 | { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 98 | -- |
| 99 | 2.16.2 |
| 100 | |