--- linux-2.4.21-pre3-rmap-ext3merge/fs/ext3/inode.c.=K0026=.orig 2003-01-23 16:30:32.000000000 +0000 +++ linux-2.4.21-pre3-rmap-ext3merge/fs/ext3/inode.c 2003-01-23 16:32:22.000000000 +0000 @@ -2500,16 +2500,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. */ @@ -2519,24 +2516,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; }