--- linux-2.4-quota/fs/ext3/inode.c.=K0009=.orig Tue Sep 10 15:50:55 2002 +++ linux-2.4-quota/fs/ext3/inode.c Wed Sep 11 18:13:37 2002 @@ -2495,16 +2495,13 @@ { int err = 0; - struct ext3_iloc *where = &EXT3_I(inode)->i_where; + struct ext3_iloc iloc; J_ASSERT(handle->h_transaction->t_state != T_RUNDOWN); - if (test_and_set_bit(EXT3_STATE_INODE_RESERVATION, - &EXT3_I(inode)->i_state)) + if (test_bit(EXT3_STATE_INODE_RESERVATION, &EXT3_I(inode)->i_state)) return 0; - list_add_tail(&EXT3_I(inode)->i_dirty, &EXT3_SB(inode->i_sb)->s_dirty); - /* The reservation needs to locate the appropriate buffer_head * for the inode and get write access to it. We won't actually * update the buffer contents until commit time. */ @@ -2514,24 +2511,33 @@ /* Find the inode's on-disk and in-core location, and cache that * in the inode so that on commit, we can flush it to disk. */ - err = ext3_get_inode_loc(inode, where); + err = ext3_get_inode_loc(inode, &iloc); jbd_debug(3, "located inode %ld at %p\n", - inode->i_ino, where->raw_inode); + inode->i_ino, iloc.raw_inode); - if (!err) { - BUFFER_TRACE(where->bh, "get_write_access"); - err = ext3_journal_get_write_access(handle, where->bh); - if (err) - brelse(where->bh); - } + if (err) + goto error; + BUFFER_TRACE(iloc.>bh, "get_write_access"); + err = ext3_journal_get_write_access(handle, iloc.bh); if (err) - /* FIXME --- flush will need to deal with this later. */ - where->bh = NULL; + goto err_brelse; + + /* Did somebody beat us to this? */ + if (test_and_set_bit(EXT3_STATE_INODE_RESERVATION, + &EXT3_I(inode)->i_state)) + goto err_brelse; + + EXT3_I(inode)->i_where = iloc; + list_add_tail(&EXT3_I(inode)->i_dirty, &EXT3_SB(inode->i_sb)->s_dirty); +error: ext3_std_error(inode->i_sb, err); return err; +err_brelse: + brelse(iloc.bh); + goto error; }