2.3.10-pre5 + fsync?

Petr Vandrovec Ing. VTEI (VANDROVE@vc.cvut.cz)
Wed, 7 Jul 1999 21:49:41 MET-1


Hi,
maybe that someone it already noticed, but as I read kernel-digest
only:
I waited with 2.3 kernels before things get stabilized... Because of
it looked to me that 2.3.10-pre5 is stable enough, I tried it. It worked
perfectly before I decided to try dselect. In installation phase, dselect
(dpkg-ftp) bombed out with:

dpkg: error processing debian/dists/unstable/main/binary-i386/admin/pam-apps_1.03.deb (--install):
unable to fsync updated status of `pam-apps': Input/output error
dpkg: error while cleaning up:
unable to fsync updated status of `pam-apps': Input/output error
Setting up alien (6.43) ...
dpkg: error processing alien (--install):
unable to fsync updated status of `alien': Input/output error
Errors were encountered ...

There are no messages in log... Problem is that fsync() does not
work if ftruncate is not preceeded by write:

#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>

char bbb[4096];

int main(void) {
int fd;
int wrt;

fd = open("/tmp/test", O_WRONLY|O_CREAT|O_TRUNC, 0666);
if (fd < 0) {
perror("open");
return 123;
}
wrt = write(fd, bbb, 4096);
if (wrt != 4096) {
fprintf(stderr, "write: ret %d\n", wrt);
return 123;
}
#if 0
sleep(20);
#else
if (fsync(fd)) {
perror("fsync1");
return 123;
}
#endif
if (ftruncate(fd, 996)) {
perror("ftruncate");
return 123;
}
if (fsync(fd)) {
perror("fsync");
return 123;
}
close(fd);
unlink("/tmp/test");
printf("OK\n");
return 0;
}

Strace of this program:

execve("./a.out", ["./a.out"], [/* 15 vars */]) = 0
brk(0) = 0x804a8c0
open("/etc/ld.so.preload", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=18, ...}) = 0
mmap(0, 18, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0x40015000
close(3) = 0
open("/lib/nfslock.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=6371, ...}) = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360\5\0"..., 4096) = 4096
mmap(0, 8024, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40016000
mprotect(0x40017000, 3928, PROT_NONE) = 0
mmap(0x40017000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x40017000
close(3) = 0
munmap(0x40015000, 18) = 0
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=10564, ...}) = 0
mmap(0, 10564, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40018000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=1170636, ...}) = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0`\202\1"..., 4096) = 4096
mmap(0, 994172, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x4001b000
mprotect(0x40106000, 31612, PROT_NONE) = 0
mmap(0x40106000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xea000) = 0x40106000
mmap(0x4010b000, 11132, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4010b000
close(3) = 0
mprotect(0x4001b000, 962560, PROT_READ|PROT_WRITE) = 0
mprotect(0x4001b000, 962560, PROT_READ|PROT_EXEC) = 0
munmap(0x40018000, 10564) = 0
personality(0 /* PER_??? */) = 0
getpid() = 12743
brk(0) = 0x804a8c0
brk(0x804aa60) = 0x804aa60
brk(0x804b000) = 0x804b000
open("/tmp/test", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
write(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 4096
fsync(3) = 0
ftruncate(3, 996) = 0
fsync(3) = -1 EIO (Input/output error)
write(2, "fsync: Input/output error\n", 26fsync: Input/output error
) = 26
_exit(123) = ?

If first fsync() is replaced by sleep(20) (or some interval greater
than flush timeouts), effect is same :-( Without first fsync() second
fsync() works fine... I think that with 2.3.6 it worked, I did not try
anything between 2.3.6 and 2.3.10-pre5.
Best regards,
Petr Vandrovec
vandrove@vc.cvut.cz

P.S.: Filesystem looks OK... At least I did not find anything wrong yet.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/