Re: Filesize limitation

Chel van Gennip (linux@vangennip.nl)
Wed, 5 Nov 1997 13:29:59 +0000 (WET)


teunis@sigil.computersupportcentre.com wrote:
>According to the thread I followed:
> 1. ext2fs is happy with 64bit limits
> 2. Linux/Alpha doesn't have a problem with this IIRC
> 3. The 64bit sysctls are still being built.....
> (as a hint: they appeared in 2.1.60....)
> 4. glibc-2.1 will be the first system to support them (already do)
>
>Now any and all of these could be wrong... But one clue: This thread
>happened a month or three ago....

I tried a simple program:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
main(){
int i,j;
int fd;
long long fpos,tpos;
long long loffs= 10000000-8;

#define TSTFIL "/bostape/tstfil"
/* write cycle */
fd=open(TSTFIL,O_WRONLY|O_CREAT|O_TRUNC,0666);
printf("Open fd= %d\n",fd);
write(fd,&fpos,8);
for(i=0;i<250;i++){
fpos=llseek(fd,loffs, SEEK_CUR);
printf("%3d pos= %10lld\n",i,fpos);
if (fpos<0) perror("seekerror:");
j=write(fd,&fpos,8);
if (j<0)perror("write_error:");
}
close(fd);

/* read cycle */
fd=open(TSTFIL,O_RDONLY);
printf("Open fd= %d\n",fd);
read(fd,&tpos,8);
for(i=0;i<250;i++){
fpos=llseek(fd,loffs, SEEK_CUR);
if (fpos<0) perror("seekfout:");
j=read(fd,&tpos,8);
if(j<0) perror("read_error");
printf("%3d pos= %10lld, %10lld\n",i,fpos,tpos);
}
close(fd);
}

And I get these results:
...
On Intel Linux version 2.0.31 (root@gennip2.vangennip.nl) (gcc version 2.7.2) #2
Mon Oct 20 20:49:43 MET DST 1997

212 pos= 2130000000
213 pos= 2140000000
214 pos= 2150000000
write_error:: File too large
215 pos= 2159999992
write_error:: File too large
...

But I have a large file!:
[root@tapeserver1 /root]# l /bostape/tstfil
-rw-r--r-- 1 root root 2499999720 Nov 5 12:37 /bostape/tstfil

Next I tried on Alpha, even increased the loop count to 500 (5GB!):
I can write and read a 5GB file:
497 pos= 4980000000, 4980000000
498 pos= 4990000000, 4990000000
499 pos= 5000000000, 5000000000
-rw-r--r-- 1 root root 5000000008 Nov 5 14:20 tstfil

Because the inode in a ext2 filesystem only has 32 bits for the
length field, I unmounted the filesystem and remounted the filesystem.
After this the file length is 4GB less:
-rw-r--r-- 1 root root 705032712 Nov 5 14:20 tstfil

Conclusion:

1. the ext2 filesystem can handle only 32 bits file-length.
2. Linux Alpha does not propperly test on this limit and wraps
files?
3. Some parts of the kernel are able to support 64 bit file operations
especially on Linux Alpha.

So I think we still need a 64 bit (ext3?) filesystem.

I also think the AXP modification in fs/ext2/file.c from:
while (count > 0) {
if (pos > two_gb) {
if (!written)
written = -EFBIG;
break;
}
to (RedHat 4.2 Alpha 2.0.30 kernel)
while (count > 0) {
/*
* Technically, we could allow writes up to
* ULONG_MAX-1, but I'm not sure everything would
* properly handle the case where pos>LONG_MAX
*/
if (pos > (loff_t) LONG_MAX) {
if (!written)
written = -EFBIG;
break;
}
Is not correct.

Chel