• F
    kill-the-BKL/reiserfs: lock only once in reiserfs_truncate_file · 22c963ad
    Frederic Weisbecker 提交于
    Impact: fix a deadlock
    
    reiserfs_truncate_file() can be called from multiple context where
    the write lock can be already hold or not.
    
    This function also acquire (possibly recursively) the write
    lock. Subsequent releases before sleeping will not actually release
    the lock because we may be in more than one lock depth degree.
    
    A typical case is:
    
    reiserfs_file_release {
    	acquire_the_lock()
    	reiserfs_truncate_file()
    		reacquire_the_lock()
    		journal_begin() {
    			do_journal_begin_r() {
    				reiserfs_wait_on_write_block() {
    					/*
    					 * Not released because still one
    					 * depth owned
    					 */
    					release_lock()
    					wait_for_event()
    
    At this stage the event never happen because the one which provides
    it needs the write lock.
    
    We use reiserfs_write_lock_once() here to ensure that we don't acquire the
    write lock recursively.
    Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
    Cc: Alessio Igor Bogani <abogani@texware.it>
    Cc: Jeff Mahoney <jeffm@suse.com>
    Cc: Alexander Beregalov <a.beregalov@gmail.com>
    Cc: Chris Mason <chris.mason@oracle.com>
    LKML-Reference: <1239680065-25013-3-git-send-email-fweisbec@gmail.com>
    Signed-off-by: NIngo Molnar <mingo@elte.hu>
    22c963ad
inode.c 90.9 KB