[PATCH] Handle errors in sync_sb_inodes()

Previous thread: Announce: hardware4linux.info by Frederic Lepied on Tuesday, October 2, 2007 - 5:53 pm. (1 message)

Next thread: [PATCH 0/5] Boot protocol changes by Rusty Russell on Tuesday, October 2, 2007 - 7:34 pm. (22 messages)
To: Andrew Morton <akpm@...>, linux-mm <linux-mm@...>, Linux Kernel Mailing List <linux-kernel@...>
Date: Tuesday, October 2, 2007 - 6:57 pm

Hello,

Currently it is possible for some errors to be detected at write-back
time but not reported to the program as shown by the following script
using the included make_file.c.

---------8<---------8<---------8<---------8<---------8<---------8<---------

#!/bin/sh

# We binary search the size of a file in 40M filesystem that can cause
# the missed error.
MIN=5000000
MAX=50000000

rm fs.40M
dd if=/dev/zero of=fs.40M bs=40M count=0 seek=1 status=noxfer
mkfs.ext2 -F fs.40M
#mkfs.ext3 -F fs.40M
#mkfs.jfs -q fs.40M
#mkfs.reiserfs -fq fs.40M
#mkfs.xfs fs.40M

attempt()
{
SIZE=$1
RES=0
./make_file valid_file $SIZE

mount fs.40M /mnt -o loop
if ! ./make_file /mnt/not_enough_space $SIZE; then
# We could not create the file as the requested size
# was clearly too big
RES=1
fi
umount /mnt

if [ $RES -eq 0 ]; then
mount fs.40M /mnt -o loop
if cmp valid_file /mnt/not_enough_space; then
# The file was too small, it fitted in the filesystem
RES=-1
fi
umount /mnt
fi

if [ $RES -eq 0 ]; then
echo "Undetected ENOSPC with SIZE=$SIZE"
exit
fi

return $RES
}

while [ $((MAX - MIN)) -gt 1 ]; do
SIZE=$(((MIN + MAX) / 2))
attempt $SIZE
RES=$?
if [ $RES -eq 1 ]; then
MAX=$SIZE
else
MIN=$SIZE
fi
done

echo "Could not reproduce the problem"

---------8<---------8<---------8<---------8<---------8<---------8<---------
/* make_file.c */

#include <unistd.h>
#include <sys/fcntl.h>
#include <sys/mman.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
int size, fd;
char *mapping;

if (argc != 3) {
fprintf(stderr, "Usage: %s FILE SIZE\n", argv[0]);
return 1;
}

size = atoi(argv[2]);

fd = open(argv[1], O_RDWR | O_CREAT, 0600);
if (fd < 0) {
perror(argv[1]);
return 1;
}
if (ftruncate(fd, size) < 0) {
perror("ftruncate");
return 1;
}
mapping = mmap(NULL, size,...

To: Andrew Morton <akpm@...>, linux-mm <linux-mm@...>, Linux Kernel Mailing List <linux-kernel@...>
Date: Tuesday, October 2, 2007 - 7:03 pm

> + mapping_set_error(mapping, ret);

And of course, s/ret/err/ :-(

--
Guillaume
-

Previous thread: Announce: hardware4linux.info by Frederic Lepied on Tuesday, October 2, 2007 - 5:53 pm. (1 message)

Next thread: [PATCH 0/5] Boot protocol changes by Rusty Russell on Tuesday, October 2, 2007 - 7:34 pm. (22 messages)