From: Subrata M. <su...@li...> - 2008-02-19 09:36:58
|
> Hi, > > Please see an attached patch from Sharyathi for failing fallocate test > cases. > And Merged. Thanks Sharyathi. --Subrata > Regards & Thanks-- > Subrata Modak, > ==================================== > ==================================== > > Omar, > Attaching the work around patch. This will address the problem until > distros update with latest glibc which has fallocate implementation. > This is not extensively tested and built with some assumption > like > o we are testing on x86* and ppc* archs > o on 64 bit machine we will always see 64 bit kernel running > I dont think this needs to be pushed to LTP (any suggestions ??) > But will definitely help you in your fallocate testing process. > > Thanks for all the help and guidance ...Amit, Aneesh, Sripathi > Thanks > Sharyathi > > > Aneesh Kk Veetil wrote: > > I guess it is more complicated than that. > > > > a) it is not 32 bit 64 bit issue. > > b) It is due to compat layer of the kernel that enables 32 bit app run on > a > > 64 bit kernel. > > > > for 32 bit application running on a 32 bit kernel. Like x86 or ppc32 on a > > ppc32 kernel the complier takes care of ABI > > That means you can call the function as syscall(number, fd, mode, offset, > > len). that is because both the user space and kernel space knows where > > to look for the higher order bits. The problem happens when user space is > > 32 bit and kernel space is 64 bit. > > > > The easiest would be to build the test case using -m64 on powerpc and > wait > > for glibc support of fallocate. Because all these what you are doing are > > going > > to be irrelevant once glibc support fallocate. And F9 already have a > glibc > > that support the same. > > > > If you really want to fix this, then i would say you need #if ! defined > > __powerpc64__ and inside that you need to find out you are running on a > 64 > > bit kernel via > > uname(2). > > > > -aneesh > > > > > > > > > > > > > Amit K > > > Arora/India/IBM > > > > To > > 02/04/2008 07:50 sha...@li... > > > PM > cc > > Aneesh Kk Veetil/India/IBM@IBMIN, > > > Mohammed Omar/India/IBM@IBMIN, > > > Subrata Modak > > > <su...@li...>, > > > Supriya Kannery/India/IBM@IBMIN, > > > Suresh Kodati/India/IBM@IBMIN > > > > Subject > > Re: RFC: Failing fallocate tests > > > (Document link: Aneesh Kk Veetil) > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi Sharyathi, > > > > The syscall macro is a temp. usage and finally at some point we will be > > moving to fallocate() system call support in newer glibc. This is a > problem > > with the syscall macro and for now, we can have a work-around in your > > testcase to take care of this 32 bit/ 64 bit compatibility issue. You may > > want to break down the third and fourth arguments (which are 64 bits) > into > > pair of 2 arguments (of 32 bits each). But, this should be done only if > > your testcase is compiled as a 32 bit binary. For 64 bit, it should work > as > > it is. This is what Aneesh tried and it worked. > > > > i.e. for 32 bit use something like : > > > > syscall(NR_FALLOCATE, fd, mode, (long)(offset >> 32), (long)(offset && > > (unsigned long long) 0x0000ffff), > > (long)(length >> 32), (long)(length && (unsigned > > long long) 0x0000ffff)) > > > > and for 64 bit, use the existing stuff, i.e. : > > > > syscall(NR_FALLOCATE, fd, mode, offset, length) > > > > > > Aneesh, any other suggestion ? > > > > Regards, > > Amit Arora > > > > > > > > > sha...@li... > > > et.ibm.com > > > > To > > 02/04/08 07:40 PM Mohammed Omar/India/IBM@IBMIN > > > > cc > > Aneesh Kk Veetil/India/IBM@IBMIN, > > > Subrata Modak > > > <su...@li...>, Amit > > > K Arora/India/IBM@IBMIN, Supriya > > > Kannery/India/IBM@IBMIN, Suresh > > > Kodati/India/IBM@IBMIN > > > > Subject > > RFC: Failing fallocate tests > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi > > Omar some time back observed that running fallocate tests on ppc64 > > machines comes out with "File too large" errors. > > This message comes from kernel and when we looked in more detail we > > observed that this problem is noticed when libc provided is 32 bit and > > kernel is 64 bit ie when application is 32 bit while the underlining > > kernel is 64 bit. > > Since glibc doesn't provide support to fallocate we need to call the > > system call with syscall() routine and not with the fallocate wrapper > > which should have been provided by the glibc code. > > > > Problem:-- > > In case application is 32 bit and kernel 64 bit, default system call > > handler, sys_call, calls handler compat_sys_fallocate instead of > > sys_fallocate (This decision is made with in kernel space not in the > > user space). Since in this case the format in which they expect data is > > deferent sys_fallocate sees huge values for the file offset as well as > > for file length). > > > > Eg: sys_fallocate(int,int,long long,long long) > > compat_sys_fallocate(int,int,higher_int, lower_int, higher_int, > > lower_int) > > > > Still working out how to over come this situation. > > This mail was sent to give a heads up. Suggestions are highly > appreciated. > > Thanks > > Sharyathi Nagesh > > > > > > > > --- Backup/fallocate01.c 2008-02-04 12:24:27.000000000 +0530 > +++ fallocate01.c 2008-02-07 12:07:29.000000000 +0530 > @@ -98,6 +98,7 @@ > #include <sys/syscall.h> > #include <unistd.h> > #include <error.h> > +#include <sys/utsname.h> > > /* Harness Specific Include Files. */ > #include "test.h" > @@ -303,9 +304,22 @@ main(int ac, /* number of command l > > ******************************************************************************/ > > static inline long fallocate(int fd, int mode, loff_t offset, loff_t len) > { > - return syscall(__NR_fallocate, fd, mode, offset,len); > + #if __WORDSIZE == 32 > + struct utsname buf; > + if ( uname(&buf) == 0 ){ > + if(!strcmp(buf.machine,"ppc64") || > !strcmp(buf.machine,"x86_64")) > + return syscall(__NR_fallocate, fd, > mode, (int)(offset>>32), (int)offset ,(int)(len>>32), (int)len); > + } > + else{ > + perror("uname:"); > + return -1; > + } > + #endif > + return syscall(__NR_fallocate, fd, mode, > offset,len); > + > } > > + > > /***************************************************************************** > > * Calls the system call, with appropriate parameters and writes data > > ******************************************************************************/ > > --- Backup/fallocate02.c 2008-02-04 12:24:27.000000000 +0530 > +++ fallocate02.c 2008-02-07 12:10:34.000000000 +0530 > @@ -94,6 +94,7 @@ > #include <sys/stat.h> > #include <sys/types.h> > #include <fcntl.h> > +#include <sys/utsname.h> > > /* Harness Specific Include Files. */ > #include "test.h" > @@ -261,10 +262,23 @@ populate_file() > > ******************************************************************************/ > > static inline long fallocate(int fd, int mode, loff_t offset, loff_t len) > { > - return syscall(__NR_fallocate, fd, mode, offset,len); > + #if __WORDSIZE == 32 > + struct utsname buf; > + if ( uname(&buf) == 0 ){ > + if(!strcmp(buf.machine,"ppc64") || > !strcmp(buf.machine,"x86_64")) > + return syscall(__NR_fallocate, fd, > mode, (int)(offset>>32), (int)offset ,(int)(len>>32), (int)len); > + } > + else{ > + perror("uname:"); > + return -1; > + } > + #endif > + return syscall(__NR_fallocate, fd, mode, > offset,len); > + > } > > > + > > /***************************************************************************** > > * Main function that calls the system call with the appropriate > parameters > > ******************************************************************************/ > > --- Backup/fallocate03.c 2008-02-04 12:24:27.000000000 +0530 > +++ fallocate03.c 2008-02-07 12:25:58.000000000 +0530 > @@ -92,6 +92,7 @@ > #include <sys/types.h> //Can be done with out > #include <fcntl.h> > #include <unistd.h> > +#include <sys/utsname.h> > > /* Harness Specific Include Files. */ > #include "test.h" > @@ -253,9 +254,22 @@ populate_file() > > ******************************************************************************/ > > static inline long fallocate(int fd, int mode, loff_t offset, loff_t len) > { > - return syscall(__NR_fallocate, fd, mode, offset,len); > + #if __WORDSIZE == 32 > + struct utsname buf; > + if ( uname(&buf) == 0 ){ > + if(!strcmp(buf.machine,"ppc64") || > !strcmp(buf.machine,"x86_64")) > + return syscall(__NR_fallocate, fd, > mode, (int)(offset>>32), (int)offset ,(int)(len>>32), (int)len); > + } > + else{ > + perror("uname:"); > + return -1; > + } > + #endif > + return syscall(__NR_fallocate, fd, mode, > offset,len); > + > } > > + > > /***************************************************************************** > > * Main function that calls the system call with the appropriate > parameters > > ******************************************************************************/ > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Ltp-list mailing list > Ltp...@li... > https://lists.sourceforge.net/lists/listinfo/ltp-list |