Bug 518581 - [RHEL5] glibc misses sync_file_range syscall interface
Summary: [RHEL5] glibc misses sync_file_range syscall interface
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: glibc
Version: 5.3
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Andreas Schwab
QA Contact: BaseOS QE
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-08-21 03:37 UTC by Kirby Zhou
Modified: 2010-03-19 14:32 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-11-23 03:19:55 UTC


Attachments (Terms of Use)

Description Kirby Zhou 2009-08-21 03:37:55 UTC
Description of problem:

glibc misses sync_file_range syscall interface.
The header file and man page both say 'sync_file_range' should exist.
From man page, sync_file_range should exist sinc kernel-2.6.17

Version-Release number of selected component (if applicable):

RHEL-5.3
glibc-2.5-34

How reproducible:

100%

Steps to Reproduce:
1. use nm to detect symbol

~]# nm -D /lib64/*.so* | fgrep sync_file_range
nothing found.

2. use gcc to detect symbol
~]# cat s.cc 
#define __GNU_SOURCE

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

char buffer[10000];

int main()
{
        int fd = open("./xxx", O_RDWR|O_CREAT, 0666);
        if (fd < 0) {
                perror("open");
                exit(1);
        }
        if (write(fd, &buffer, sizeof(buffer)) <= 0) {
                perror("write");
                exit(1);
        }
        if (sync_file_range(fd, 0, 8192, SYNC_FILE_RANGE_WRITE) < 0) {
                perror("sync_file_range");
                exit(1);
        }

}
~]# g++ s.cc -lrt -lpthread -lcrypt -lutil -lresolv -lm -lnsl -lanl -lcidn 
/tmp/ccOaK6Vj.o: In function `main':
s.cc:(.text+0x81): undefined reference to `sync_file_range'
collect2: ld returned 1 exit status
  
Actual results:
nm found no .so contains sync_file_range

Expected results:



Additional info:

Comment 1 Andreas Schwab 2009-08-21 07:24:24 UTC
It has only been added to glibc 2.6, and cannot be backported due to ABI breakage.  You can always fall back to syscall(3).

Comment 2 Kirby Zhou 2009-08-21 10:54:05 UTC
Can give me a example how to use syscall(3) to call sync_file_range?

Comment 3 Ulrich Drepper 2009-11-23 03:19:55 UTC
As comment #1 says, no chance to backport this.

See the syscall man page for instructions.

Comment 4 Jon E 2010-03-19 14:32:37 UTC
then why document it if it's broken and you're not going to fix it? .. might want to FTFM over at sync_file_range(2) - in the meantime - borrowing from glibc 2.6 .. any thoughts on this implementation for a hacky workaround for those still on your "ancient releases" .. (eg: RHEL5.3)?:

#ifdef ULI_WONT_FIX_THIS_IN_GLIBC2.5
#define NR_sync_file_range 277
int sync_file_range (int fd, __off64_t from, __off64_t to, unsigned int flags)
{
  return syscall (NR_sync_file_range, fd,
			 __LONG_LONG_PAIR ((long) (from >> 32), (long) from),
			 __LONG_LONG_PAIR ((long) (to >> 32), (long) to),
			 flags);
}
#endif

assuming of course that you're on an x86_64 and include/asm-x86_64/unistd.h has the correct entry

(fwiw - fio is starting to use this now)


Note You need to log in before you can comment on or make changes to this bug.