• Theodore Y. Ts'o's avatar
    [PATCH] Ext3: Retry allocation after transaction commit (v2) · 5c4ad014
    Theodore Y. Ts'o authored
    Here is a reworked version of my patch to ext3 to retry certain filesystem
    operations after an ENOSPC error.  The ext3_should_retry_alloc() function will
    not wait on the currently running transaction if there is a currently active
    handle; hence this should avoid deadlocks in the Lustre use case.  The patch
    is versus BK-recent.
    
    I've also included a simple, reliable test case which demonstrates the problem
    this patch is intended to fix.  (Note that BK-recent is not sufficient to
    address this test case, and waiting on the commiting transaction in
    ext3_new_block is also not sufficient.  Been there, tried that, didn't work.
    We need to do the full-bore retry from the top level.  The
    ext3_should_retry_alloc() will only wait on the committing transaction if
    there is an active handle; hence Lustre will probably also need to use
    ext3_should_retry_alloc() if it wants to reliably avoid this particular
    problem.)
    
    #!/bin/sh
    #
    #
    TEST_DIR=/tmp
    IMAGE=$TEST_DIR/retry.img
    MNTPT=$TEST_DIR/retry.mnt
    TEST_SRC=/usr/projects/e2fsprogs/e2fsprogs/build
    MKE2FS_OPTS=""
    IMAGE_SIZE=8192
    
    umount $MNTPT
    dd if=/dev/zero of=$IMAGE bs=4k count=$IMAGE_SIZE
    mke2fs -j -F $MKE2FS_OPTS $IMAGE 
    
    function test_log ()
    {
    	echo $*
    	logger -p local4.notice $*
    }
    
    mkdir -p $MNTPT
    mount -o loop -t ext3 $IMAGE $MNTPT
    test_log Retry test: BEGIN
    for i in `seq 1 3`
    do
    	test_log "Retry test: Loop $i"
    	echo 2 > /proc/sys/fs/jbd-debug
    	while ! mkdir -p $MNTPT/foo/bar
    	do
    		test_log "Retry test: mkdir failed"
    		sleep 1
    	done
    	echo 0 > /proc/sys/fs/jbd-debug
    	cp -r $TEST_SRC $MNTPT/foo/bar 2> /dev/null
    	rm -rf $MNTPT/*
    done
    umount $MNTPT
    test_log "Retry test: END"
    
    
    akpm@osdl.org
    
      Rework the code to make it a formal JBD API entry point.
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    5c4ad014
inode.c 88.9 KB