Re: [EXT3/JBD] Periodic journal flush not enough?

From: Herbert Xu
Date: Fri Mar 26 2004 - 19:03:05 EST


On Fri, Mar 26, 2004 at 03:48:51PM -0800, Andrew Morton wrote:
> Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> > I've encountered a problem with the journal flush timer. The problem
> > is that when a filesystem is short on space, relying on a timer-based
> > flushing mechanism is no longer adequate. For example, on my P4 2GHz
> > I can trigger an ENOSPC error by doing
> >
> > while :; do echo test > a; [ -s a ] || break; rm a; done; echo Out of space
> >
> > on an ext3 file system with 12Mb of free space using the usual 5s
> > journal flush timer.
>
> I cannot reproduce this. Please send more details. Journalling mode,
> kernel version, etc.

OK. I can reproduce this under both 2.4.25 and 2.6.4.

To prepare for the test, you need to arrange for an ext3 file system
which is short on space. In the following example, I'm using one with
around 12Mb of free space.

You'll also need a way to write/delete files quickly. The above shell
fragment probably doesn't in bash since it's very slow.

So I've attached a C program which does a similar thing.

I've also attached the script output of it running in my VMware machine
running 2.6.4.

Cheers,
--
Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ )
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#include <unistd.h>
#include <stdio.h>
#include <strings.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(void)
{
int fd;
int cnt = 0;

while (1) {
char c = 'x';
fd = open("a", O_WRONLY|O_CREAT|O_EXCL);
if (fd < 0) {
perror("open");
break;
}
if (write(fd, &c, 1) != 1) {
perror("write");
break;
}
close(fd);
unlink("a");
cnt++;
}
printf("%d\n", cnt);
return 0;
}
Script started on Sun Feb 22 22:08:38 2004
angband:~# df .
Filesystem 1K-blocks Used Available Use% Mounted on
/devfs/mapper/ren-root
253871 241542 12329 96% /
angband:~# /tmp/b
write: No space left on device
21603
angband:~# exit

Script done on Sun Feb 22 22:08:51 2004