linux/fs/ext4
Tejun Heo e525fd89d3 block: make blkdev_get/put() handle exclusive access
Over time, block layer has accumulated a set of APIs dealing with bdev
open, close, claim and release.

* blkdev_get/put() are the primary open and close functions.

* bd_claim/release() deal with exclusive open.

* open/close_bdev_exclusive() are combination of open and claim and
  the other way around, respectively.

* bd_link/unlink_disk_holder() to create and remove holder/slave
  symlinks.

* open_by_devnum() wraps bdget() + blkdev_get().

The interface is a bit confusing and the decoupling of open and claim
makes it impossible to properly guarantee exclusive access as
in-kernel open + claim sequence can disturb the existing exclusive
open even before the block layer knows the current open if for another
exclusive access.  Reorganize the interface such that,

* blkdev_get() is extended to include exclusive access management.
  @holder argument is added and, if is @FMODE_EXCL specified, it will
  gain exclusive access atomically w.r.t. other exclusive accesses.

* blkdev_put() is similarly extended.  It now takes @mode argument and
  if @FMODE_EXCL is set, it releases an exclusive access.  Also, when
  the last exclusive claim is released, the holder/slave symlinks are
  removed automatically.

* bd_claim/release() and close_bdev_exclusive() are no longer
  necessary and either made static or removed.

* bd_link_disk_holder() remains the same but bd_unlink_disk_holder()
  is no longer necessary and removed.

* open_bdev_exclusive() becomes a simple wrapper around lookup_bdev()
  and blkdev_get().  It also has an unexpected extra bdev_read_only()
  test which probably should be moved into blkdev_get().

* open_by_devnum() is modified to take @holder argument and pass it to
  blkdev_get().

Most of bdev open/close operations are unified into blkdev_get/put()
and most exclusive accesses are tested atomically at the open time (as
it should).  This cleans up code and removes some, both valid and
invalid, but unnecessary all the same, corner cases.

open_bdev_exclusive() and open_by_devnum() can use further cleanup -
rename to blkdev_get_by_path() and blkdev_get_by_devt() and drop
special features.  Well, let's leave them for another day.

Most conversions are straight-forward.  drbd conversion is a bit more
involved as there was some reordering, but the logic should stay the
same.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Neil Brown <neilb@suse.de>
Acked-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Acked-by: Mike Snitzer <snitzer@redhat.com>
Acked-by: Philipp Reisner <philipp.reisner@linbit.com>
Cc: Peter Osterlund <petero2@telia.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <joel.becker@oracle.com>
Cc: Alex Elder <aelder@sgi.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: dm-devel@redhat.com
Cc: drbd-dev@lists.linbit.com
Cc: Leo Chen <leochen@broadcom.com>
Cc: Scott Branden <sbranden@broadcom.com>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Cc: Joern Engel <joern@logfs.org>
Cc: reiserfs-devel@vger.kernel.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
2010-11-13 11:55:17 +01:00
..
Kconfig ext4: Don't ask about supporting ext2/3 in ext4 if ext4 is not configured 2009-12-21 10:54:09 -05:00
Makefile ext4: use bio layer instead of buffer layer in mpage_da_submit_io 2010-10-27 21:30:10 -04:00
acl.c ext4: update ctime when changing the file's permission by setfacl 2010-06-15 12:19:59 -04:00
acl.h ext[234]: move over to 'check_acl' permission model 2009-09-08 11:09:04 -07:00
balloc.c ext4: rename mark_bitmap_end() to ext4_mark_bitmap_end() 2010-10-27 21:30:15 -04:00
bitmap.c ext4: Change unsigned long to unsigned int 2008-11-05 00:14:04 -05:00
block_validity.c ext4: rename {exit,init}_ext4_*() to ext4_{exit,init}_*() 2010-10-27 21:30:14 -04:00
dir.c ext4: improve llseek error handling for overly large seek offsets 2010-10-27 21:30:06 -04:00
ext4.h ext4: fix potential race when freeing ext4_io_page structures 2010-11-08 13:45:33 -05:00
ext4_extents.h ext4: rename {ext,idx}_pblock and inline small extent functions 2010-10-27 21:30:14 -04:00
ext4_jbd2.c ext4: Pass line numbers to ext4_error() and friends 2010-07-27 11:56:40 -04:00
ext4_jbd2.h ext4: Pass line numbers to ext4_error() and friends 2010-07-27 11:56:40 -04:00
extents.c Merge branch 'next' into upstream-merge 2010-10-27 23:44:47 -04:00
file.c ext4: improve llseek error handling for overly large seek offsets 2010-10-27 21:30:06 -04:00
fsync.c Merge branch 'next' into upstream-merge 2010-10-27 23:44:47 -04:00
hash.c ext4: Add support for non-native signed/unsigned htree hash algorithms 2008-10-28 13:21:44 -04:00
ialloc.c Merge branch 'next' into upstream-merge 2010-10-27 23:44:47 -04:00
inode.c Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 2010-11-08 11:54:53 -08:00
ioctl.c ext4: Drop whitespace at end of lines 2010-05-17 07:00:00 -04:00
mballoc.c ext4: Don't call sb_issue_discard() in ext4_free_blocks() 2010-11-08 13:49:33 -05:00
mballoc.h ext4: consolidate in_range() definitions 2010-03-03 23:55:01 -05:00
migrate.c ext4: rename {ext,idx}_pblock and inline small extent functions 2010-10-27 21:30:14 -04:00
move_extent.c ext4: rename {ext,idx}_pblock and inline small extent functions 2010-10-27 21:30:14 -04:00
namei.c Merge branch 'next' into upstream-merge 2010-10-27 23:44:47 -04:00
page-io.c ext4: fix potential race when freeing ext4_io_page structures 2010-11-08 13:45:33 -05:00
resize.c Merge branch 'next' into upstream-merge 2010-10-27 23:44:47 -04:00
super.c block: make blkdev_get/put() handle exclusive access 2010-11-13 11:55:17 +01:00
symlink.c ext4: symlink must be handled via filesystem specific operation 2010-05-16 02:00:00 -04:00
xattr.c ext4: rename {exit,init}_ext4_*() to ext4_{exit,init}_*() 2010-10-27 21:30:14 -04:00
xattr.h ext4: fix compile with CONFIG_EXT4_FS_XATTR disabled 2010-10-28 09:29:17 -07:00
xattr_security.c ext4: constify xattr_handler 2010-05-21 18:31:19 -04:00
xattr_trusted.c ext4: constify xattr_handler 2010-05-21 18:31:19 -04:00
xattr_user.c ext4: constify xattr_handler 2010-05-21 18:31:19 -04:00