[ext2resize] Re: Deadlock help
Status: Inactive
Brought to you by:
adilger
From: Andreas D. <ad...@cl...> - 2002-10-03 03:20:39
|
On Oct 02, 2002 17:32 -0700, Robert Walsh wrote: > > > The intention is that other processes cannot start using the new space > > until it is completely set up. We want to avoid a situation where a > > file is allocated in the new space, and then we say "oops, there was a > > problem, let's yank that new space back" == missing data. > > > > I think this can be done fairly cleanly by ensuring everything is set up > > before updating the superblock (in memory and on disk), and only holding > > the lock over that update. For extend-the-end resizing, we already have > > to drop the lock for ext3_free_blocks(), because it gets the lock itself. > > Until we get around to doing this, do you think the existing solution of > dropping the lock before calling journal_start or journal_stop and > reacquiring it after is sufficient? Probably not - a quick look at ext3_group_extend already shows races w.r.t. multiple resizers if the lock were dropped. It should be relatively straight forward to rearrange the code to enter without the sb lock, get the journal handle first, and do the rest of the operations with the sb lock held (until ext3_free_blocks is called). The call to update_backups can (and should, for the same reason) be called without the sb lock. For ext3_group_add(), we have a bit more complexity, but nothing fatal. We can (and probably should) hold i_sem for protection against change of the reserved inode. As long as you re-check that this is still the last group being added after getting the sb lock, the only critical region where we need to hold the sb lock is from "gdp->bg_block_bitmap = ..." through "es->s_free_inodes_count = ...". I could probably do this in a couple of hours if you would be willing to do the testing, or is the description enough? Of course, if you are not running multiple resizers at one time (by accident normally, of course) then the only place you actually need the sb lock is at the critical region previously mentioned in ext3_group_add() because we are updating the free counts, which are also updated by other parts of the code. Cheers, Andreas -- Andreas Dilger http://www-mddsp.enel.ucalgary.ca/People/adilger/ http://sourceforge.net/projects/ext2resize/ |