--------------------- PatchSet 893 Date: 2002/08/09 22:29:47 Author: sct Log: Update ext3_write_inode to work properly with the new inode writeback scheme. Members: fs/ext3/inode.c:1.64.2.16.2.4->1.64.2.16.2.5 [quota-branch] --- linux-2.4-quota/fs/ext3/inode.c.=K0004=.orig Thu Aug 29 21:11:23 2002 +++ linux-2.4-quota/fs/ext3/inode.c Wed Sep 4 21:37:06 2002 @@ -2317,16 +2317,15 @@ * trasnaction to commit. * * - Within sys_sync(), kupdate and such. - * We wait on commit, if tol to. + * We wait on commit, if told to. * * - Within prune_icache() (PF_MEMALLOC == true) - * Here we simply return. We can't afford to block kswapd on the - * journal commit. - * - * In all cases it is actually safe for us to return without doing anything, - * because the inode has been copied into a raw inode buffer in - * ext3_mark_inode_dirty(). This is a correctness thing for O_SYNC and for - * knfsd. + * Here we used to return, but that is no longer an option: we don't keep the + * buffer cache copy of the inode permanently synchronised with the inode + * cache any longer so we _have_ to propagate that information when told to + * do so. However, prune_icache currently delegates the write to a keventd + * event so this won't block kswapd. (Blocking keventd is not nice either, + * though.) * * Note that we are absolutely dependent upon all inode dirtiers doing the * right thing: they *must* call mark_inode_dirty() after dirtying info in @@ -2344,18 +2343,25 @@ */ void ext3_write_inode(struct inode *inode, int wait) { - if (current->flags & PF_MEMALLOC) - return; + handle_t *handle; + + J_ASSERT(!ext3_journal_current_handle()); + J_ASSERT(!(current->flags & PF_MEMALLOC)); - if (ext3_journal_current_handle()) { - jbd_debug(0, "called recursively, non-PF_MEMALLOC!\n"); - return; - } + lock_kernel(); + handle = ext3_journal_start(inode, 1); + if (IS_ERR(handle)) + goto out; + + add_inode_to_commit_queue(handle, inode); + ext3_flush_inode_reservation(handle, inode); - if (!wait) - return; + if (wait) + handle->h_sync = 1; - ext3_force_commit(inode->i_sb); + ext3_journal_stop(handle, inode); +out: + unlock_kernel(); } /* @@ -2491,6 +2497,8 @@ int err = 0; struct ext3_iloc *where = &EXT3_I(inode)->i_where; + J_ASSERT(handle->h_transaction->t_state != T_RUNDOWN); + if (test_and_set_bit(EXT3_STATE_INODE_RESERVATION, &EXT3_I(inode)->i_state)) return 0; @@ -2591,6 +2599,7 @@ handle = ext3_journal_start(inode, 1); if (IS_ERR(handle)) goto out; + if (current_handle && current_handle->h_transaction != handle->h_transaction) { /* This task has a transaction open against a different fs */