• Alexander Viro's avatar
    [PATCH] death of is_mounted() and aother fixes · 75e9c9e1
    Alexander Viro authored
    *	new functions - bd_claim(bdev, holder) and bd_release(bdev).
    	bd_claim(bdev, holder) fails is device is already claimed by
    	somebody else; bd_release(bdev) gives device up.
    
    *	get_sb_bdev() claims device for fs_type; it means that we don't need
    	to look through entire least of superblocks anymore - just through
    	the list of superblocks belonging to that type (i.e. the same thing
    	we do for non-block filesystems; that will allow to merge quite a
    	bit of code afterwards).
    
    *	sys_swapon claims device for itself;  free exclusion with mounting,
    	end of problems with bogus set_blocksize().
    
    *	is_mounted() and is_swap_partition() are gone - what we actually
    	wanted was "try to claim device for ourselves".  Which we can do
    	now - without races inherent to is_mounted()/is_swap_partition().
    
    *	RAID lock_rdev() claims device for itself.  I.e. we get rid of
    	is_mounted() in there (BTW, is_swap_partition() was missing) and
    	we get protection both ways - not only RAID won't take an already
    	mounted device, but mount won't stomp on a device claimed by RAID.
    
    There are other places that would benefit from the same (e.g. ext3 with
    external journal almost definitely wants to claim device for itself).
    
    Notice that it's a cooperative thing - neither open() nor raw device stuff
    claim the block device, so they don't care if device is mounted, etc.  So
    we don't break fsck and friends - exclusion is between those who know that
    they want that exclusion.
    75e9c9e1
ksyms.c 15.6 KB