linux/drivers/mtd
Maxim Levitsky 008c751ec7 mtd: allow to unload the mtdtrans module if its block devices aren't open
Now it once again possible to remove mtdtrans module.
You still need to ensure that block devices of that module aren't mounted.
This is due to the fact that as long as a block device is open, it still exists,
therefore if we were to allow module removal, this block device might became used again.

This time in addition to code review, I also made the code
pass some torture tests like module reload in  a loop + read in a loop +
card insert/removal all at same time.

The blktrans_open/blktrans_release don't take the mtd table lock because:

While device is added (that includes execution of add_mtd_blktrans_dev)
the lock is already taken

Now suppose the device will never be removed. In this case even if we have changes
in mtd table, the entry that we need will stay exactly the same. (Note that we don't
look at table at all, just following private pointer of block device).

Now suppose that someone tries to remove the mtd device.
This will be propagated to trans driver which _ought_ to call del_mtd_blktrans_dev
which will take the per device lock, release the mtd device and set trans->mtd = NULL.
>From this point on, following opens won't even be able to know anything about that mtd device
(which at that point is likely not to exist)
Also the same care is taken not to trip over NULL mtd pointer in blktrans_dev_release.

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
Tested-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2010-10-25 01:28:30 +01:00
..
chips mtd: cfi_cmdset_0002: code cleanups 2010-10-25 01:14:19 +01:00
devices mtd: m25p80.c: Add support for S25FL032P spi-nor flash devices. 2010-10-25 00:55:13 +01:00
lpddr mtd: change struct flchip_shared spinlock locking into mutex 2010-08-06 09:22:16 +01:00
maps mtd: maps: gpio-addr-flash: fix warnings and make more portable 2010-10-25 01:16:17 +01:00
nand mtd: Blackfin NFC: fix badblock location with BootROM OOB 2010-10-25 01:15:22 +01:00
onenand mtd: onenand: fix 4KiB page onenand chip recognition 2010-10-25 01:13:20 +01:00
tests mtd: tests: return -1 if verify failed 2010-08-02 09:06:20 +01:00
ubi UBI: do not oops when erroneous PEB is scheduled for scrubbing 2010-08-30 13:32:31 +03:00
afs.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
ar7part.c [MTD] mtdpart: Make all partition parsers return allocated array 2009-03-20 18:55:17 +00:00
cmdlinepart.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
ftl.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
inftlcore.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
inftlmount.c mtd: Remove obsolete <mtd/compatmac.h> include 2010-08-08 21:19:42 +01:00
Kconfig mtd: update description on sm_ftl 2010-08-06 09:21:40 +01:00
Makefile Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 2010-05-10 14:32:46 +01:00
mtd_blkdevs.c mtd: allow to unload the mtdtrans module if its block devices aren't open 2010-10-25 01:28:30 +01:00
mtdblock_ro.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
mtdblock.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
mtdchar.c mtd: add BLKPG API based repartition support 2010-10-25 00:48:49 +01:00
mtdconcat.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
mtdcore.c mtd: Remove obsolete <mtd/compatmac.h> include 2010-08-08 21:19:42 +01:00
mtdcore.h mtd: Replace static array of devices with an idr structure 2010-02-25 11:55:14 +00:00
mtdoops.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
mtdpart.c mtd: prepare partition add and del functions for ioctl requests 2010-10-25 00:47:37 +01:00
mtdsuper.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
nftlcore.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
nftlmount.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
ofpart.c mtd: Fix endianness issues from device tree 2010-10-25 00:55:56 +01:00
redboot.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
rfd_ftl.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00
sm_ftl.c bitops: rename for_each_bit() to for_each_set_bit(): mtd 2010-04-08 09:42:41 +01:00
sm_ftl.h mtd: Add new SmartMedia/xD FTL 2010-02-26 19:06:50 +00:00
ssfdc.c mtd: Update copyright notices 2010-08-08 20:58:20 +01:00