A lot of drivers does the following:
sb = get_super(dev);
if (sb)
invalidate_inodes(sb);
Each of these places is an oopsable race with umount. We can't fix them
without touching a lot of drivers. However, we can make the future fix
easier if we put the above into a helper function. Patch below does that.
Results:
* simpler code in drivers
* drivers don't care about the superblocks and their handling
* when we will add refcounting for superblocks we will not need
to touch every block driver out there.
Patch is absolutely straightforward - function added to inode.c, declared
in fs.h and exported; instances of the body replaced with calls.
Please, apply it.
Al
diff -urN S4-pre8/drivers/acorn/block/mfmhd.c S4-pre8-ream_inodes/drivers/acorn/block/mfmhd.c
--- S4-pre8/drivers/acorn/block/mfmhd.c Fri Feb 16 18:37:01 2001
+++ S4-pre8-ream_inodes/drivers/acorn/block/mfmhd.c Fri Apr 27 20:16:01 2001
@@ -1486,11 +1486,9 @@
for (i = maxp - 1; i >= 0; i--) {
int minor = start + i;
kdev_t devi = MKDEV(MAJOR_NR, minor);
- struct super_block *sb = get_super(devi);
sync_dev (devi);
- if (sb)
- invalidate_inodes (sb);
+ ream_inodes(devi);
invalidate_buffers (devi);
mfm_gendisk.part[minor].start_sect = 0;
diff -urN S4-pre8/drivers/block/DAC960.c S4-pre8-ream_inodes/drivers/block/DAC960.c
--- S4-pre8/drivers/block/DAC960.c Thu Feb 22 06:46:26 2001
+++ S4-pre8-ream_inodes/drivers/block/DAC960.c Fri Apr 27 20:16:31 2001
@@ -5134,15 +5134,13 @@
PartitionNumber);
int MinorNumber = DAC960_MinorNumber(LogicalDriveNumber,
PartitionNumber);
- SuperBlock_T *SuperBlock = get_super(Device);
if (Controller->GenericDiskInfo.part[MinorNumber].nr_sects == 0)
continue;
/*
Flush all changes and invalidate buffered state.
*/
sync_dev(Device);
- if (SuperBlock != NULL)
- invalidate_inodes(SuperBlock);
+ ream_inodes(Device);
invalidate_buffers(Device);
/*
Clear existing partition sizes.
diff -urN S4-pre8/drivers/block/acsi.c S4-pre8-ream_inodes/drivers/block/acsi.c
--- S4-pre8/drivers/block/acsi.c Fri Feb 16 22:53:03 2001
+++ S4-pre8-ream_inodes/drivers/block/acsi.c Fri Apr 27 20:16:48 2001
@@ -1887,11 +1887,9 @@
for( i = max_p - 1; i >= 0 ; i-- ) {
if (gdev->part[start + i].nr_sects != 0) {
kdev_t devp = MKDEV(MAJOR_NR, start + i);
- struct super_block *sb = get_super(devp);
fsync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
+ ream_inodes(devp);
invalidate_buffers(devp);
gdev->part[start + i].nr_sects = 0;
}
diff -urN S4-pre8/drivers/block/amiflop.c S4-pre8-ream_inodes/drivers/block/amiflop.c
--- S4-pre8/drivers/block/amiflop.c Fri Feb 16 18:59:20 2001
+++ S4-pre8-ream_inodes/drivers/block/amiflop.c Fri Apr 27 20:17:09 2001
@@ -1540,9 +1540,7 @@
break;
case FDFMTEND:
floppy_off(drive);
- sb = get_super(inode->i_rdev);
- if (sb)
- invalidate_inodes(sb);
+ ream_inodes(inode->i_rdev);
invalidate_buffers(inode->i_rdev);
break;
case FDGETPRM:
diff -urN S4-pre8/drivers/block/cciss.c S4-pre8-ream_inodes/drivers/block/cciss.c
--- S4-pre8/drivers/block/cciss.c Fri Apr 27 06:20:56 2001
+++ S4-pre8-ream_inodes/drivers/block/cciss.c Fri Apr 27 20:17:30 2001
@@ -694,9 +694,8 @@
for(i=max_p; i>=0; i--) {
int minor = start+i;
kdev_t devi = MKDEV(MAJOR_NR + ctlr, minor);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb) invalidate_inodes(sb);
+ ream_inodes(devi);
invalidate_buffers(devi);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
diff -urN S4-pre8/drivers/block/cpqarray.c S4-pre8-ream_inodes/drivers/block/cpqarray.c
--- S4-pre8/drivers/block/cpqarray.c Fri Feb 16 22:56:28 2001
+++ S4-pre8-ream_inodes/drivers/block/cpqarray.c Fri Apr 27 20:17:42 2001
@@ -1577,9 +1577,8 @@
for(i=max_p; i>=0; i--) {
int minor = start+i;
kdev_t devi = MKDEV(MAJOR_NR + ctlr, minor);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb) invalidate_inodes(sb);
+ ream_inodes(devi);
invalidate_buffers(devi);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
diff -urN S4-pre8/drivers/block/paride/pd.c S4-pre8-ream_inodes/drivers/block/paride/pd.c
--- S4-pre8/drivers/block/paride/pd.c Fri Feb 16 22:50:44 2001
+++ S4-pre8-ream_inodes/drivers/block/paride/pd.c Fri Apr 27 20:18:36 2001
@@ -591,8 +591,6 @@
long flags;
kdev_t devp;
- struct super_block *sb;
-
unit = DEVICE_NR(dev);
if ((unit >= PD_UNITS) || (!PD.present)) return -ENODEV;
@@ -609,10 +607,7 @@
minor = p + unit*PD_PARTNS;
devp = MKDEV(MAJOR_NR, minor);
fsync_dev(devp);
-
- sb = get_super(devp);
- if (sb) invalidate_inodes(sb);
-
+ ream_inodes(devp);
invalidate_buffers(devp);
pd_hd[minor].start_sect = 0;
pd_hd[minor].nr_sects = 0;
diff -urN S4-pre8/drivers/block/ps2esdi.c S4-pre8-ream_inodes/drivers/block/ps2esdi.c
--- S4-pre8/drivers/block/ps2esdi.c Fri Apr 27 06:20:56 2001
+++ S4-pre8-ream_inodes/drivers/block/ps2esdi.c Fri Apr 27 20:17:57 2001
@@ -1146,11 +1146,9 @@
partition >= 0; partition--) {
int minor = (start | partition);
kdev_t devp = MKDEV(MAJOR_NR, minor);
- struct super_block * sb = get_super(devp);
sync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
+ ream_inodes(devp);
invalidate_buffers(devp);
ps2esdi_gendisk.part[start + partition].start_sect = 0;
ps2esdi_gendisk.part[start + partition].nr_sects = 0;
diff -urN S4-pre8/drivers/block/xd.c S4-pre8-ream_inodes/drivers/block/xd.c
--- S4-pre8/drivers/block/xd.c Thu Feb 22 06:46:25 2001
+++ S4-pre8-ream_inodes/drivers/block/xd.c Fri Apr 27 20:18:13 2001
@@ -402,11 +402,9 @@
for (partition = xd_gendisk.max_p - 1; partition >= 0; partition--) {
int minor = (start | partition);
kdev_t devp = MKDEV(MAJOR_NR, minor);
- struct super_block * sb = get_super(devp);
sync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
+ ream_inodes(devp);
invalidate_buffers(devp);
xd_gendisk.part[minor].start_sect = 0;
xd_gendisk.part[minor].nr_sects = 0;
diff -urN S4-pre8/drivers/i2o/i2o_block.c S4-pre8-ream_inodes/drivers/i2o/i2o_block.c
--- S4-pre8/drivers/i2o/i2o_block.c Fri Feb 16 22:53:46 2001
+++ S4-pre8-ream_inodes/drivers/i2o/i2o_block.c Fri Apr 27 20:18:51 2001
@@ -893,11 +893,9 @@
{
int m = minor+i;
kdev_t d = MKDEV(MAJOR_NR, m);
- struct super_block *sb = get_super(d);
sync_dev(d);
- if(sb)
- invalidate_inodes(sb);
+ ream_inodes(d);
invalidate_buffers(d);
i2ob_gendisk.part[m].start_sect = 0;
i2ob_gendisk.part[m].nr_sects = 0;
diff -urN S4-pre8/drivers/ide/hd.c S4-pre8-ream_inodes/drivers/ide/hd.c
--- S4-pre8/drivers/ide/hd.c Thu Feb 22 06:47:01 2001
+++ S4-pre8-ream_inodes/drivers/ide/hd.c Fri Apr 27 20:19:06 2001
@@ -893,11 +893,9 @@
for (i=max_p - 1; i >=0 ; i--) {
int minor = start + i;
kdev_t devi = MKDEV(MAJOR_NR, minor);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
+ ream_inodes(devi);
invalidate_buffers(devi);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
diff -urN S4-pre8/drivers/ide/ide.c S4-pre8-ream_inodes/drivers/ide/ide.c
--- S4-pre8/drivers/ide/ide.c Fri Apr 27 06:20:57 2001
+++ S4-pre8-ream_inodes/drivers/ide/ide.c Fri Apr 27 20:19:43 2001
@@ -1762,11 +1762,9 @@
for (p = 0; p < (1<<PARTN_BITS); ++p) {
if (drive->part[p].nr_sects > 0) {
kdev_t devp = MKDEV(major, minor+p);
- struct super_block * sb = get_super(devp);
- fsync_dev (devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers (devp);
+ fsync_dev(devp);
+ ream_inodes(devp);
+ invalidate_buffers(devp);
set_blocksize(devp, 1024);
}
drive->part[p].start_sect = 0;
@@ -1983,8 +1981,7 @@
for (p = 0; p < (1<<PARTN_BITS); ++p) {
if (drive->part[p].nr_sects > 0) {
kdev_t devp = MKDEV(hwif->major, minor+p);
- struct super_block * sb = get_super(devp);
- if (sb) invalidate_inodes(sb);
+ ream_inodes(devp);
invalidate_buffers (devp);
}
}
diff -urN S4-pre8/drivers/mtd/ftl.c S4-pre8-ream_inodes/drivers/mtd/ftl.c
--- S4-pre8/drivers/mtd/ftl.c Fri Feb 16 22:53:55 2001
+++ S4-pre8-ream_inodes/drivers/mtd/ftl.c Fri Apr 27 20:20:19 2001
@@ -915,9 +915,6 @@
static release_t ftl_close(struct inode *inode, struct file *file)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- struct super_block *sb = get_super(inode->i_rdev);
-#endif
int minor = MINOR(inode->i_rdev);
partition_t *part = myparts[minor >> 4];
int i;
@@ -926,9 +923,7 @@
/* Flush all writes */
fsync_dev(inode->i_rdev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (sb) invalidate_inodes(sb);
-#endif
+ ream_inodes(inode->i_rdev);
invalidate_buffers(inode->i_rdev);
/* Wait for any pending erase operations to complete */
diff -urN S4-pre8/drivers/mtd/mtdblock.c S4-pre8-ream_inodes/drivers/mtd/mtdblock.c
--- S4-pre8/drivers/mtd/mtdblock.c Fri Feb 16 22:53:55 2001
+++ S4-pre8-ream_inodes/drivers/mtd/mtdblock.c Fri Apr 27 20:20:37 2001
@@ -355,18 +355,13 @@
{
int dev;
struct mtdblk_dev *mtdblk;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- struct super_block * sb = get_super(inode->i_rdev);
-#endif
DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n");
if (inode == NULL)
release_return(-ENODEV);
fsync_dev(inode->i_rdev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (sb) invalidate_inodes(sb);
-#endif
+ ream_inodes(inode->i_rdev);
invalidate_buffers(inode->i_rdev);
dev = MINOR(inode->i_rdev);
diff -urN S4-pre8/drivers/mtd/nftl.c S4-pre8-ream_inodes/drivers/mtd/nftl.c
--- S4-pre8/drivers/mtd/nftl.c Fri Feb 16 22:53:55 2001
+++ S4-pre8-ream_inodes/drivers/mtd/nftl.c Fri Apr 27 20:20:55 2001
@@ -997,7 +997,6 @@
static int nftl_release(struct inode *inode, struct file *fp)
{
- struct super_block *sb = get_super(inode->i_rdev);
struct NFTLrecord *thisNFTL;
thisNFTL = NFTLs[MINOR(inode->i_rdev) / 16];
@@ -1005,8 +1004,7 @@
DEBUG(MTD_DEBUG_LEVEL2, "NFTL_release\n");
fsync_dev(inode->i_rdev);
- if (sb)
- invalidate_inodes(sb);
+ ream_inodes(inode->i_rdev);
invalidate_buffers(inode->i_rdev);
if (thisNFTL->mtd->sync)
diff -urN S4-pre8/drivers/scsi/sd.c S4-pre8-ream_inodes/drivers/scsi/sd.c
--- S4-pre8/drivers/scsi/sd.c Fri Feb 16 22:48:36 2001
+++ S4-pre8-ream_inodes/drivers/scsi/sd.c Fri Apr 27 20:21:19 2001
@@ -1262,10 +1262,8 @@
for (i = max_p - 1; i >= 0; i--) {
int index = start + i;
kdev_t devi = MKDEV_SD_PARTITION(index);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
+ ream_inodes(devi);
invalidate_buffers(devi);
sd_gendisks->part[index].start_sect = 0;
sd_gendisks->part[index].nr_sects = 0;
@@ -1315,10 +1313,8 @@
for (j = max_p - 1; j >= 0; j--) {
int index = start + j;
kdev_t devi = MKDEV_SD_PARTITION(index);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
+ ream_inodes(devi);
invalidate_buffers(devi);
sd_gendisks->part[index].start_sect = 0;
sd_gendisks->part[index].nr_sects = 0;
diff -urN S4-pre8/drivers/scsi/sr.c S4-pre8-ream_inodes/drivers/scsi/sr.c
--- S4-pre8/drivers/scsi/sr.c Thu Feb 22 06:46:36 2001
+++ S4-pre8-ream_inodes/drivers/scsi/sr.c Fri Apr 27 20:21:37 2001
@@ -870,14 +870,12 @@
for (cpnt = scsi_CDs, i = 0; i < sr_template.dev_max; i++, cpnt++)
if (cpnt->device == SDp) {
kdev_t devi = MKDEV(MAJOR_NR, i);
- struct super_block *sb = get_super(devi);
/*
* Since the cdrom is read-only, no need to sync the device.
* We should be kind to our buffer cache, however.
*/
- if (sb)
- invalidate_inodes(sb);
+ ream_inodes(devi);
invalidate_buffers(devi);
/*
diff -urN S4-pre8/fs/block_dev.c S4-pre8-ream_inodes/fs/block_dev.c
--- S4-pre8/fs/block_dev.c Fri Feb 16 22:52:03 2001
+++ S4-pre8-ream_inodes/fs/block_dev.c Fri Apr 27 20:22:09 2001
@@ -576,8 +576,7 @@
printk(KERN_DEBUG "VFS: Disk change detected on device %s\n",
bdevname(dev));
- sb = get_super(dev);
- if (sb && invalidate_inodes(sb))
+ if (ream_inodes(dev))
printk("VFS: busy inodes on changed media.\n");
destroy_buffers(dev);
diff -urN S4-pre8/fs/devfs/base.c S4-pre8-ream_inodes/fs/devfs/base.c
--- S4-pre8/fs/devfs/base.c Fri Apr 27 06:21:01 2001
+++ S4-pre8-ream_inodes/fs/devfs/base.c Fri Apr 27 20:23:23 2001
@@ -2156,7 +2156,6 @@
int tmp;
kdev_t dev = MKDEV (de->u.fcb.u.device.major, de->u.fcb.u.device.minor);
struct block_device_operations *bdops = de->u.fcb.ops;
- struct super_block * sb;
extern int warn_no_part;
if ( !S_ISBLK (de->mode) ) return 0;
@@ -2165,8 +2164,7 @@
if ( !bdops->check_media_change (dev) ) return 0;
printk ( KERN_DEBUG "VFS: Disk change detected on device %s\n",
kdevname (dev) );
- sb = get_super (dev);
- if ( sb && invalidate_inodes (sb) )
+ if (ream_inodes(dev))
printk("VFS: busy inodes on changed media..\n");
invalidate_buffers (dev);
/* Ugly hack to disable messages about unable to read partition table */
diff -urN S4-pre8/fs/inode.c S4-pre8-ream_inodes/fs/inode.c
--- S4-pre8/fs/inode.c Fri Apr 27 06:21:01 2001
+++ S4-pre8-ream_inodes/fs/inode.c Fri Apr 27 20:22:42 2001
@@ -523,6 +523,23 @@
return busy;
}
+
+/**
+ * ream_inodes - discard the inodes on a device if it's mounted
+ * @dev: device number
+ *
+ * Equivalent of invalidate_inodes, but done by device number.
+ */
+
+int ream_inodes(kdev_t dev)
+{
+ struct super_block *sb = get_super(dev);
+ int res;
+ if (sb)
+ res = invalidate_inodes(sb);
+ return res;
+}
+
/*
* This is called with the inode lock held. It searches
diff -urN S4-pre8/include/linux/fs.h S4-pre8-ream_inodes/include/linux/fs.h
--- S4-pre8/include/linux/fs.h Fri Apr 27 06:21:03 2001
+++ S4-pre8-ream_inodes/include/linux/fs.h Fri Apr 27 20:23:49 2001
@@ -1084,6 +1084,7 @@
extern void balance_dirty(kdev_t);
extern int check_disk_change(kdev_t);
extern int invalidate_inodes(struct super_block *);
+extern int ream_inodes(kdev_t);
extern void invalidate_inode_pages(struct inode *);
extern void invalidate_inode_buffers(struct inode *);
#define invalidate_buffers(dev) __invalidate_buffers((dev), 0)
diff -urN S4-pre8/kernel/ksyms.c S4-pre8-ream_inodes/kernel/ksyms.c
--- S4-pre8/kernel/ksyms.c Fri Apr 27 06:21:04 2001
+++ S4-pre8-ream_inodes/kernel/ksyms.c Fri Apr 27 20:24:06 2001
@@ -174,6 +174,7 @@
EXPORT_SYMBOL(check_disk_change);
EXPORT_SYMBOL(__invalidate_buffers);
EXPORT_SYMBOL(invalidate_inodes);
+EXPORT_SYMBOL(ream_inodes);
EXPORT_SYMBOL(invalidate_inode_pages);
EXPORT_SYMBOL(truncate_inode_pages);
EXPORT_SYMBOL(fsync_dev);
On Fri, 27 Apr 2001, Alexander Viro wrote:
>
> Each of these places is an oopsable race with umount. We can't fix them
> without touching a lot of drivers. However, we can make the future fix
> easier if we put the above into a helper function. Patch below does that.
I don't like the name "ream_inodes()".
Also, a driver shouldn't know about "inodes" and "buffers". It should just
do something like
invalidate_device(dev);
because the only thing the driver knows about is the _device_.
Then, invalidate_device() might do
sb = get_super(dev)
if (sb)
invalidate_inodes (sb);
invalidate_buffers(dev);
which makes some amount of sense. And which can later be extended to deal
with the page cache etc without the drivers ever knowing or caring.
Linus
On Fri, 27 Apr 2001, Linus Torvalds wrote:
> On Fri, 27 Apr 2001, Alexander Viro wrote:
> >
> > Each of these places is an oopsable race with umount. We can't fix them
> > without touching a lot of drivers. However, we can make the future fix
> > easier if we put the above into a helper function. Patch below does that.
>
> I don't like the name "ream_inodes()".
>
> Also, a driver shouldn't know about "inodes" and "buffers". It should just
> do something like
>
> invalidate_device(dev);
>
> because the only thing the driver knows about is the _device_.
>
> Then, invalidate_device() might do
>
> sb = get_super(dev)
> if (sb)
> invalidate_inodes (sb);
> invalidate_buffers(dev);
>
> which makes some amount of sense. And which can later be extended to deal
> with the page cache etc without the drivers ever knowing or caring.
Fine with me. Actually in _all_ cases execept cdrom.c it's preceded by
either sync_dev() or fsync_dev(). What do you think about pulling that
into the same function? Actually, that's what I've done in namespace
patch (name being invalidate_dev(), BTW ;-) The only problem I see
here is the argument telling whether we want sync or fsync (or nothing).
OTOH, I seriously suspect that we ought replace all sync_dev() cases
with fsync_dev() anyway... Your opinion?
Al
On Fri, 27 Apr 2001, Alexander Viro wrote:
> Fine with me. Actually in _all_ cases execept cdrom.c it's preceded by
> either sync_dev() or fsync_dev(). What do you think about pulling that
> into the same function? Actually, that's what I've done in namespace
> patch (name being invalidate_dev(), BTW ;-) The only problem I see
> here is the argument telling whether we want sync or fsync (or nothing).
> OTOH, I seriously suspect that we ought replace all sync_dev() cases
> with fsync_dev() anyway... Your opinion?
> Al
PS: last time I've separated that part of patch was a couple months
ago. See if something similar to the variant below would be OK with
you (I'll rediff it):
diff -urN S2/drivers/acorn/block/mfmhd.c S2-s_lock-1/drivers/acorn/block/mfmhd.c
--- S2/drivers/acorn/block/mfmhd.c Fri Oct 27 01:35:47 2000
+++ S2-s_lock-1/drivers/acorn/block/mfmhd.c Thu Feb 22 07:00:38 2001
@@ -1486,13 +1486,8 @@
for (i = maxp - 1; i >= 0; i--) {
int minor = start + i;
kdev_t devi = MKDEV(MAJOR_NR, minor);
- struct super_block *sb = get_super(devi);
-
- sync_dev (devi);
- if (sb)
- invalidate_inodes (sb);
- invalidate_buffers (devi);
+ invalidate_dev(devi, 1);
mfm_gendisk.part[minor].start_sect = 0;
mfm_gendisk.part[minor].nr_sects = 0;
}
diff -urN S2/drivers/block/DAC960.c S2-s_lock-1/drivers/block/DAC960.c
--- S2/drivers/block/DAC960.c Thu Feb 22 06:22:36 2001
+++ S2-s_lock-1/drivers/block/DAC960.c Thu Feb 22 07:00:38 2001
@@ -5134,16 +5134,12 @@
PartitionNumber);
int MinorNumber = DAC960_MinorNumber(LogicalDriveNumber,
PartitionNumber);
- SuperBlock_T *SuperBlock = get_super(Device);
if (Controller->GenericDiskInfo.part[MinorNumber].nr_sects == 0)
continue;
/*
Flush all changes and invalidate buffered state.
*/
- sync_dev(Device);
- if (SuperBlock != NULL)
- invalidate_inodes(SuperBlock);
- invalidate_buffers(Device);
+ invalidate_dev(Device, 1);
/*
Clear existing partition sizes.
*/
diff -urN S2/drivers/block/acsi.c S2-s_lock-1/drivers/block/acsi.c
--- S2/drivers/block/acsi.c Thu Feb 22 06:22:36 2001
+++ S2-s_lock-1/drivers/block/acsi.c Thu Feb 22 07:00:39 2001
@@ -1887,12 +1887,7 @@
for( i = max_p - 1; i >= 0 ; i-- ) {
if (gdev->part[start + i].nr_sects != 0) {
kdev_t devp = MKDEV(MAJOR_NR, start + i);
- struct super_block *sb = get_super(devp);
-
- fsync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devp);
+ invalidate_dev(devp, 2);
gdev->part[start + i].nr_sects = 0;
}
gdev->part[start+i].start_sect = 0;
diff -urN S2/drivers/block/amiflop.c S2-s_lock-1/drivers/block/amiflop.c
--- S2/drivers/block/amiflop.c Sun Oct 1 22:35:15 2000
+++ S2-s_lock-1/drivers/block/amiflop.c Thu Feb 22 07:00:39 2001
@@ -1490,7 +1490,6 @@
{
int drive = inode->i_rdev & 3;
static struct floppy_struct getprm;
- struct super_block * sb;
switch(cmd){
case HDIO_GETGEO:
@@ -1540,10 +1539,7 @@
break;
case FDFMTEND:
floppy_off(drive);
- sb = get_super(inode->i_rdev);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(inode->i_rdev);
+ invalidate_dev(inode->i_rdev, 0);
break;
case FDGETPRM:
memset((void *)&getprm, 0, sizeof (getprm));
@@ -1677,9 +1673,6 @@
static int floppy_release(struct inode * inode, struct file * filp)
{
-#ifdef DEBUG
- struct super_block * sb;
-#endif
int drive = MINOR(inode->i_rdev) & 3;
if (unit[drive].dirty == 1) {
diff -urN S2/drivers/block/blkpg.c S2-s_lock-1/drivers/block/blkpg.c
--- S2/drivers/block/blkpg.c Fri Oct 27 01:35:47 2000
+++ S2-s_lock-1/drivers/block/blkpg.c Thu Feb 22 07:00:39 2001
@@ -157,8 +157,7 @@
/* partition in use? Incomplete check for now. */
devp = MKDEV(MAJOR(dev), minor);
- if (get_super(devp) || /* mounted? */
- is_swap_partition(devp))
+ if (is_mounted(devp) || is_swap_partition(devp))
return -EBUSY;
/* all seems OK */
diff -urN S2/drivers/block/cciss.c S2-s_lock-1/drivers/block/cciss.c
--- S2/drivers/block/cciss.c Thu Feb 22 06:22:36 2001
+++ S2-s_lock-1/drivers/block/cciss.c Thu Feb 22 07:00:39 2001
@@ -693,10 +693,7 @@
for(i=max_p; i>=0; i--) {
int minor = start+i;
kdev_t devi = MKDEV(MAJOR_NR + ctlr, minor);
- struct super_block *sb = get_super(devi);
- sync_dev(devi);
- if (sb) invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_dev(devi, 1);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
diff -urN S2/drivers/block/cpqarray.c S2-s_lock-1/drivers/block/cpqarray.c
--- S2/drivers/block/cpqarray.c Thu Feb 22 06:22:36 2001
+++ S2-s_lock-1/drivers/block/cpqarray.c Thu Feb 22 07:00:39 2001
@@ -1577,10 +1577,7 @@
for(i=max_p; i>=0; i--) {
int minor = start+i;
kdev_t devi = MKDEV(MAJOR_NR + ctlr, minor);
- struct super_block *sb = get_super(devi);
- sync_dev(devi);
- if (sb) invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_dev(devi, 1);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
diff -urN S2/drivers/block/paride/pd.c S2-s_lock-1/drivers/block/paride/pd.c
--- S2/drivers/block/paride/pd.c Thu Feb 22 06:22:36 2001
+++ S2-s_lock-1/drivers/block/paride/pd.c Thu Feb 22 07:00:39 2001
@@ -591,8 +591,6 @@
long flags;
kdev_t devp;
- struct super_block *sb;
-
unit = DEVICE_NR(dev);
if ((unit >= PD_UNITS) || (!PD.present)) return -ENODEV;
@@ -608,12 +606,7 @@
for (p=(PD_PARTNS-1);p>=0;p--) {
minor = p + unit*PD_PARTNS;
devp = MKDEV(MAJOR_NR, minor);
- fsync_dev(devp);
-
- sb = get_super(devp);
- if (sb) invalidate_inodes(sb);
-
- invalidate_buffers(devp);
+ invalidate_dev(devp, 2);
pd_hd[minor].start_sect = 0;
pd_hd[minor].nr_sects = 0;
}
diff -urN S2/drivers/block/ps2esdi.c S2-s_lock-1/drivers/block/ps2esdi.c
--- S2/drivers/block/ps2esdi.c Fri Oct 27 01:35:47 2000
+++ S2-s_lock-1/drivers/block/ps2esdi.c Thu Feb 22 07:00:39 2001
@@ -1180,12 +1180,7 @@
partition >= 0; partition--) {
int minor = (start | partition);
kdev_t devp = MKDEV(MAJOR_NR, minor);
- struct super_block * sb = get_super(devp);
-
- sync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devp);
+ invalidate_dev(devp, 1);
ps2esdi_gendisk.part[start + partition].start_sect = 0;
ps2esdi_gendisk.part[start + partition].nr_sects = 0;
}
diff -urN S2/drivers/block/xd.c S2-s_lock-1/drivers/block/xd.c
--- S2/drivers/block/xd.c Thu Feb 22 06:22:36 2001
+++ S2-s_lock-1/drivers/block/xd.c Thu Feb 22 07:00:39 2001
@@ -402,12 +402,7 @@
for (partition = xd_gendisk.max_p - 1; partition >= 0; partition--) {
int minor = (start | partition);
kdev_t devp = MKDEV(MAJOR_NR, minor);
- struct super_block * sb = get_super(devp);
-
- sync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devp);
+ invalidate_dev(devp, 1);
xd_gendisk.part[minor].start_sect = 0;
xd_gendisk.part[minor].nr_sects = 0;
};
diff -urN S2/drivers/char/raw.c S2-s_lock-1/drivers/char/raw.c
--- S2/drivers/char/raw.c Sun Oct 1 22:35:15 2000
+++ S2-s_lock-1/drivers/char/raw.c Thu Feb 22 07:00:39 2001
@@ -103,7 +103,7 @@
*/
sector_size = 512;
- if (get_super(rdev) != NULL) {
+ if (is_mounted(rdev)) {
if (blksize_size[MAJOR(rdev)])
sector_size = blksize_size[MAJOR(rdev)][MINOR(rdev)];
} else {
diff -urN S2/drivers/char/sysrq.c S2-s_lock-1/drivers/char/sysrq.c
--- S2/drivers/char/sysrq.c Thu Feb 22 06:22:37 2001
+++ S2-s_lock-1/drivers/char/sysrq.c Thu Feb 22 07:00:39 2001
@@ -28,7 +28,6 @@
extern void wakeup_bdflush(int);
extern void reset_vc(unsigned int);
-extern struct list_head super_blocks;
/* Whether we react on sysrq keys or just ignore them */
int sysrq_enabled = 1;
diff -urN S2/drivers/i2o/i2o_block.c S2-s_lock-1/drivers/i2o/i2o_block.c
--- S2/drivers/i2o/i2o_block.c Thu Feb 22 06:22:37 2001
+++ S2-s_lock-1/drivers/i2o/i2o_block.c Thu Feb 22 07:00:40 2001
@@ -893,12 +893,7 @@
{
int m = minor+i;
kdev_t d = MKDEV(MAJOR_NR, m);
- struct super_block *sb = get_super(d);
-
- sync_dev(d);
- if(sb)
- invalidate_inodes(sb);
- invalidate_buffers(d);
+ invalidate_dev(d, 1);
i2ob_gendisk.part[m].start_sect = 0;
i2ob_gendisk.part[m].nr_sects = 0;
}
diff -urN S2/drivers/ide/hd.c S2-s_lock-1/drivers/ide/hd.c
--- S2/drivers/ide/hd.c Thu Feb 22 06:22:37 2001
+++ S2-s_lock-1/drivers/ide/hd.c Thu Feb 22 07:00:40 2001
@@ -893,12 +893,7 @@
for (i=max_p - 1; i >=0 ; i--) {
int minor = start + i;
kdev_t devi = MKDEV(MAJOR_NR, minor);
- struct super_block *sb = get_super(devi);
-
- sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_dev(devi, 1);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
}
diff -urN S2/drivers/ide/ide.c S2-s_lock-1/drivers/ide/ide.c
--- S2/drivers/ide/ide.c Thu Feb 22 06:22:37 2001
+++ S2-s_lock-1/drivers/ide/ide.c Thu Feb 22 07:00:40 2001
@@ -1761,11 +1761,7 @@
for (p = 0; p < (1<<PARTN_BITS); ++p) {
if (drive->part[p].nr_sects > 0) {
kdev_t devp = MKDEV(major, minor+p);
- struct super_block * sb = get_super(devp);
- fsync_dev (devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers (devp);
+ invalidate_dev(devp, 2);
set_blocksize(devp, 1024);
}
drive->part[p].start_sect = 0;
@@ -1982,9 +1978,7 @@
for (p = 0; p < (1<<PARTN_BITS); ++p) {
if (drive->part[p].nr_sects > 0) {
kdev_t devp = MKDEV(hwif->major, minor+p);
- struct super_block * sb = get_super(devp);
- if (sb) invalidate_inodes(sb);
- invalidate_buffers (devp);
+ invalidate_dev(devp, 0);
}
}
#ifdef CONFIG_PROC_FS
diff -urN S2/drivers/md/md.c S2-s_lock-1/drivers/md/md.c
--- S2/drivers/md/md.c Thu Feb 22 06:22:38 2001
+++ S2-s_lock-1/drivers/md/md.c Thu Feb 22 07:00:40 2001
@@ -1092,7 +1092,7 @@
}
memset(rdev, 0, sizeof(*rdev));
- if (get_super(newdev)) {
+ if (is_mounted(newdev)) {
printk("md: can not import %s, has active inodes!\n",
partition_name(newdev));
err = -EBUSY;
@@ -1730,7 +1730,7 @@
}
/* this shouldn't be needed as above would have fired */
- if (!ro && get_super(dev)) {
+ if (!ro && is_mounted(dev)) {
printk (STILL_MOUNTED, mdidx(mddev));
OUT(-EBUSY);
}
diff -urN S2/drivers/mtd/ftl.c S2-s_lock-1/drivers/mtd/ftl.c
--- S2/drivers/mtd/ftl.c Thu Feb 22 06:22:40 2001
+++ S2-s_lock-1/drivers/mtd/ftl.c Thu Feb 22 07:00:40 2001
@@ -915,9 +915,6 @@
static release_t ftl_close(struct inode *inode, struct file *file)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- struct super_block *sb = get_super(inode->i_rdev);
-#endif
int minor = MINOR(inode->i_rdev);
partition_t *part = myparts[minor >> 4];
int i;
@@ -925,11 +922,7 @@
DEBUG(0, "ftl_cs: ftl_close(%d)\n", minor);
/* Flush all writes */
- fsync_dev(inode->i_rdev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (sb) invalidate_inodes(sb);
-#endif
- invalidate_buffers(inode->i_rdev);
+ invalidate_dev(inode->i_rdev, 2);
/* Wait for any pending erase operations to complete */
if (part->mtd->sync)
diff -urN S2/drivers/mtd/mtdblock.c S2-s_lock-1/drivers/mtd/mtdblock.c
--- S2/drivers/mtd/mtdblock.c Thu Feb 22 06:22:40 2001
+++ S2-s_lock-1/drivers/mtd/mtdblock.c Thu Feb 22 07:00:40 2001
@@ -355,19 +355,12 @@
{
int dev;
struct mtdblk_dev *mtdblk;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- struct super_block * sb = get_super(inode->i_rdev);
-#endif
DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n");
if (inode == NULL)
release_return(-ENODEV);
- fsync_dev(inode->i_rdev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (sb) invalidate_inodes(sb);
-#endif
- invalidate_buffers(inode->i_rdev);
+ invalidate_dev(inode->i_rdev, 2);
dev = MINOR(inode->i_rdev);
mtdblk = mtdblks[dev];
diff -urN S2/drivers/mtd/nftl.c S2-s_lock-1/drivers/mtd/nftl.c
--- S2/drivers/mtd/nftl.c Thu Feb 22 06:22:40 2001
+++ S2-s_lock-1/drivers/mtd/nftl.c Thu Feb 22 07:00:40 2001
@@ -997,17 +997,13 @@
static int nftl_release(struct inode *inode, struct file *fp)
{
- struct super_block *sb = get_super(inode->i_rdev);
struct NFTLrecord *thisNFTL;
thisNFTL = NFTLs[MINOR(inode->i_rdev) / 16];
DEBUG(MTD_DEBUG_LEVEL2, "NFTL_release\n");
- fsync_dev(inode->i_rdev);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(inode->i_rdev);
+ invalidate_dev(inode->i_rdev, 2);
if (thisNFTL->mtd->sync)
thisNFTL->mtd->sync(thisNFTL->mtd);
diff -urN S2/drivers/scsi/sd.c S2-s_lock-1/drivers/scsi/sd.c
--- S2/drivers/scsi/sd.c Thu Feb 22 06:22:47 2001
+++ S2-s_lock-1/drivers/scsi/sd.c Thu Feb 22 07:00:40 2001
@@ -1262,11 +1262,7 @@
for (i = max_p - 1; i >= 0; i--) {
int index = start + i;
kdev_t devi = MKDEV_SD_PARTITION(index);
- struct super_block *sb = get_super(devi);
- sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_dev(devi, 1);
sd_gendisks->part[index].start_sect = 0;
sd_gendisks->part[index].nr_sects = 0;
/*
@@ -1315,11 +1311,7 @@
for (j = max_p - 1; j >= 0; j--) {
int index = start + j;
kdev_t devi = MKDEV_SD_PARTITION(index);
- struct super_block *sb = get_super(devi);
- sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_dev(devi, 1);
sd_gendisks->part[index].start_sect = 0;
sd_gendisks->part[index].nr_sects = 0;
sd_sizes[index] = 0;
diff -urN S2/drivers/scsi/sr.c S2-s_lock-1/drivers/scsi/sr.c
--- S2/drivers/scsi/sr.c Thu Feb 22 06:22:47 2001
+++ S2-s_lock-1/drivers/scsi/sr.c Thu Feb 22 07:00:40 2001
@@ -870,15 +870,11 @@
for (cpnt = scsi_CDs, i = 0; i < sr_template.dev_max; i++, cpnt++)
if (cpnt->device == SDp) {
kdev_t devi = MKDEV(MAJOR_NR, i);
- struct super_block *sb = get_super(devi);
-
/*
* Since the cdrom is read-only, no need to sync the device.
* We should be kind to our buffer cache, however.
*/
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_dev(devi, 0);
/*
* Reset things back to a sane state so that one can re-load a new
diff -urN S2/fs/buffer.c S2-s_lock-1/fs/buffer.c
--- S2/fs/buffer.c Thu Feb 22 06:22:55 2001
+++ S2-s_lock-1/fs/buffer.c Thu Feb 22 07:00:40 2001
@@ -680,6 +680,19 @@
goto retry;
}
+void invalidate_dev(kdev_t dev, int sync_flag)
+{
+ struct super_block *sb = get_super(dev);
+ if (sync_flag == 1)
+ sync_dev(dev);
+ else if (sync_flag == 2)
+ fsync_dev(dev);
+ if (sb) {
+ invalidate_inodes(sb);
+ }
+ invalidate_buffers(dev);
+}
+
void set_blocksize(kdev_t dev, int size)
{
extern int *blksize_size[];
diff -urN S2/include/linux/fs.h S2-s_lock-1/include/linux/fs.h
--- S2/include/linux/fs.h Thu Feb 22 06:23:04 2001
+++ S2-s_lock-1/include/linux/fs.h Thu Feb 22 07:00:40 2001
@@ -1093,6 +1093,7 @@
extern void write_inode_now(struct inode *, int);
extern void sync_dev(kdev_t);
extern int fsync_dev(kdev_t);
+extern void invalidate_dev(kdev_t, int);
extern int fsync_inode_buffers(struct inode *);
extern int osync_inode_buffers(struct inode *);
extern int inode_has_buffers(struct inode *);
@@ -1289,6 +1290,14 @@
extern struct super_block *get_super(kdev_t);
struct super_block *get_empty_super(void);
extern void put_super(kdev_t);
+static inline int is_mounted(kdev_t dev)
+{
+ struct super_block *sb = get_super(dev);
+ if (sb) {
+ return 1;
+ }
+ return 0;
+}
unsigned long generate_cluster(kdev_t, int b[], int);
unsigned long generate_cluster_swab32(kdev_t, int b[], int);
extern kdev_t ROOT_DEV;
diff -urN S2/kernel/ksyms.c S2-s_lock-1/kernel/ksyms.c
--- S2/kernel/ksyms.c Thu Feb 22 06:23:05 2001
+++ S2-s_lock-1/kernel/ksyms.c Thu Feb 22 07:00:40 2001
@@ -129,6 +129,7 @@
EXPORT_SYMBOL(get_fs_type);
EXPORT_SYMBOL(get_super);
EXPORT_SYMBOL(get_empty_super);
+EXPORT_SYMBOL(invalidate_dev);
EXPORT_SYMBOL(getname);
EXPORT_SYMBOL(names_cachep);
EXPORT_SYMBOL(fput);
On Fri, 27 Apr 2001, Alexander Viro wrote:
>
> Fine with me. Actually in _all_ cases execept cdrom.c it's preceded by
> either sync_dev() or fsync_dev(). What do you think about pulling that
> into the same function?
I'd actually prefer not. I don't think it makes sense from a conceptual
standpoint, and I think drivers could validly say "syncing this device at
this point is _wrong_".
Linus
On Fri, 27 Apr 2001, Alexander Viro wrote:
>
> PS: last time I've separated that part of patch was a couple months
> ago. See if something similar to the variant below would be OK with
> you (I'll rediff it):
This one looks fine.
Linus
On Fri, 27 Apr 2001, Linus Torvalds wrote:
>
> On Fri, 27 Apr 2001, Alexander Viro wrote:
> >
> > Fine with me. Actually in _all_ cases execept cdrom.c it's preceded by
> > either sync_dev() or fsync_dev(). What do you think about pulling that
> > into the same function?
>
> I'd actually prefer not. I don't think it makes sense from a conceptual
> standpoint, and I think drivers could validly say "syncing this device at
> this point is _wrong_".
OK... That would be something like
diff -urN S4-pre8/drivers/acorn/block/mfmhd.c S4-pre8-ream_inodes/drivers/acorn/block/mfmhd.c
--- S4-pre8/drivers/acorn/block/mfmhd.c Fri Feb 16 18:37:01 2001
+++ S4-pre8-ream_inodes/drivers/acorn/block/mfmhd.c Fri Apr 27 21:51:22 2001
@@ -1486,12 +1486,9 @@
for (i = maxp - 1; i >= 0; i--) {
int minor = start + i;
kdev_t devi = MKDEV(MAJOR_NR, minor);
- struct super_block *sb = get_super(devi);
sync_dev (devi);
- if (sb)
- invalidate_inodes (sb);
- invalidate_buffers (devi);
+ invalidate_device (devi);
mfm_gendisk.part[minor].start_sect = 0;
mfm_gendisk.part[minor].nr_sects = 0;
diff -urN S4-pre8/drivers/block/DAC960.c S4-pre8-ream_inodes/drivers/block/DAC960.c
--- S4-pre8/drivers/block/DAC960.c Thu Feb 22 06:46:26 2001
+++ S4-pre8-ream_inodes/drivers/block/DAC960.c Fri Apr 27 21:38:32 2001
@@ -5134,16 +5134,13 @@
PartitionNumber);
int MinorNumber = DAC960_MinorNumber(LogicalDriveNumber,
PartitionNumber);
- SuperBlock_T *SuperBlock = get_super(Device);
if (Controller->GenericDiskInfo.part[MinorNumber].nr_sects == 0)
continue;
/*
Flush all changes and invalidate buffered state.
*/
sync_dev(Device);
- if (SuperBlock != NULL)
- invalidate_inodes(SuperBlock);
- invalidate_buffers(Device);
+ invalidate_device(Device);
/*
Clear existing partition sizes.
*/
diff -urN S4-pre8/drivers/block/acsi.c S4-pre8-ream_inodes/drivers/block/acsi.c
--- S4-pre8/drivers/block/acsi.c Fri Feb 16 22:53:03 2001
+++ S4-pre8-ream_inodes/drivers/block/acsi.c Fri Apr 27 21:38:42 2001
@@ -1887,12 +1887,9 @@
for( i = max_p - 1; i >= 0 ; i-- ) {
if (gdev->part[start + i].nr_sects != 0) {
kdev_t devp = MKDEV(MAJOR_NR, start + i);
- struct super_block *sb = get_super(devp);
fsync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devp);
+ invalidate_device(devp);
gdev->part[start + i].nr_sects = 0;
}
gdev->part[start+i].start_sect = 0;
diff -urN S4-pre8/drivers/block/amiflop.c S4-pre8-ream_inodes/drivers/block/amiflop.c
--- S4-pre8/drivers/block/amiflop.c Fri Feb 16 18:59:20 2001
+++ S4-pre8-ream_inodes/drivers/block/amiflop.c Fri Apr 27 21:38:51 2001
@@ -1540,10 +1540,7 @@
break;
case FDFMTEND:
floppy_off(drive);
- sb = get_super(inode->i_rdev);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(inode->i_rdev);
+ invalidate_device(inode->i_rdev);
break;
case FDGETPRM:
memset((void *)&getprm, 0, sizeof (getprm));
diff -urN S4-pre8/drivers/block/cciss.c S4-pre8-ream_inodes/drivers/block/cciss.c
--- S4-pre8/drivers/block/cciss.c Fri Apr 27 06:20:56 2001
+++ S4-pre8-ream_inodes/drivers/block/cciss.c Fri Apr 27 21:39:21 2001
@@ -694,10 +694,8 @@
for(i=max_p; i>=0; i--) {
int minor = start+i;
kdev_t devi = MKDEV(MAJOR_NR + ctlr, minor);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb) invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(devi);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
diff -urN S4-pre8/drivers/block/cpqarray.c S4-pre8-ream_inodes/drivers/block/cpqarray.c
--- S4-pre8/drivers/block/cpqarray.c Fri Feb 16 22:56:28 2001
+++ S4-pre8-ream_inodes/drivers/block/cpqarray.c Fri Apr 27 21:51:35 2001
@@ -1577,10 +1577,8 @@
for(i=max_p; i>=0; i--) {
int minor = start+i;
kdev_t devi = MKDEV(MAJOR_NR + ctlr, minor);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb) invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(devi);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
diff -urN S4-pre8/drivers/block/paride/pd.c S4-pre8-ream_inodes/drivers/block/paride/pd.c
--- S4-pre8/drivers/block/paride/pd.c Fri Feb 16 22:50:44 2001
+++ S4-pre8-ream_inodes/drivers/block/paride/pd.c Fri Apr 27 21:39:46 2001
@@ -591,8 +591,6 @@
long flags;
kdev_t devp;
- struct super_block *sb;
-
unit = DEVICE_NR(dev);
if ((unit >= PD_UNITS) || (!PD.present)) return -ENODEV;
@@ -609,11 +607,7 @@
minor = p + unit*PD_PARTNS;
devp = MKDEV(MAJOR_NR, minor);
fsync_dev(devp);
-
- sb = get_super(devp);
- if (sb) invalidate_inodes(sb);
-
- invalidate_buffers(devp);
+ invalidate_device(devp);
pd_hd[minor].start_sect = 0;
pd_hd[minor].nr_sects = 0;
}
diff -urN S4-pre8/drivers/block/ps2esdi.c S4-pre8-ream_inodes/drivers/block/ps2esdi.c
--- S4-pre8/drivers/block/ps2esdi.c Fri Apr 27 06:20:56 2001
+++ S4-pre8-ream_inodes/drivers/block/ps2esdi.c Fri Apr 27 21:39:13 2001
@@ -1146,12 +1146,9 @@
partition >= 0; partition--) {
int minor = (start | partition);
kdev_t devp = MKDEV(MAJOR_NR, minor);
- struct super_block * sb = get_super(devp);
sync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devp);
+ invalidate_device(devp);
ps2esdi_gendisk.part[start + partition].start_sect = 0;
ps2esdi_gendisk.part[start + partition].nr_sects = 0;
}
diff -urN S4-pre8/drivers/block/xd.c S4-pre8-ream_inodes/drivers/block/xd.c
--- S4-pre8/drivers/block/xd.c Thu Feb 22 06:46:25 2001
+++ S4-pre8-ream_inodes/drivers/block/xd.c Fri Apr 27 21:39:37 2001
@@ -402,12 +402,9 @@
for (partition = xd_gendisk.max_p - 1; partition >= 0; partition--) {
int minor = (start | partition);
kdev_t devp = MKDEV(MAJOR_NR, minor);
- struct super_block * sb = get_super(devp);
sync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devp);
+ invalidate_device(devp);
xd_gendisk.part[minor].start_sect = 0;
xd_gendisk.part[minor].nr_sects = 0;
};
diff -urN S4-pre8/drivers/i2o/i2o_block.c S4-pre8-ream_inodes/drivers/i2o/i2o_block.c
--- S4-pre8/drivers/i2o/i2o_block.c Fri Feb 16 22:53:46 2001
+++ S4-pre8-ream_inodes/drivers/i2o/i2o_block.c Fri Apr 27 21:39:55 2001
@@ -893,12 +893,9 @@
{
int m = minor+i;
kdev_t d = MKDEV(MAJOR_NR, m);
- struct super_block *sb = get_super(d);
sync_dev(d);
- if(sb)
- invalidate_inodes(sb);
- invalidate_buffers(d);
+ invalidate_device(d);
i2ob_gendisk.part[m].start_sect = 0;
i2ob_gendisk.part[m].nr_sects = 0;
}
diff -urN S4-pre8/drivers/ide/hd.c S4-pre8-ream_inodes/drivers/ide/hd.c
--- S4-pre8/drivers/ide/hd.c Thu Feb 22 06:47:01 2001
+++ S4-pre8-ream_inodes/drivers/ide/hd.c Fri Apr 27 21:40:02 2001
@@ -893,12 +893,9 @@
for (i=max_p - 1; i >=0 ; i--) {
int minor = start + i;
kdev_t devi = MKDEV(MAJOR_NR, minor);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(devi);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
}
diff -urN S4-pre8/drivers/ide/ide.c S4-pre8-ream_inodes/drivers/ide/ide.c
--- S4-pre8/drivers/ide/ide.c Fri Apr 27 06:20:57 2001
+++ S4-pre8-ream_inodes/drivers/ide/ide.c Fri Apr 27 21:40:21 2001
@@ -1762,11 +1762,8 @@
for (p = 0; p < (1<<PARTN_BITS); ++p) {
if (drive->part[p].nr_sects > 0) {
kdev_t devp = MKDEV(major, minor+p);
- struct super_block * sb = get_super(devp);
- fsync_dev (devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers (devp);
+ fsync_dev(devp);
+ invalidate_device(devp);
set_blocksize(devp, 1024);
}
drive->part[p].start_sect = 0;
@@ -1983,9 +1980,7 @@
for (p = 0; p < (1<<PARTN_BITS); ++p) {
if (drive->part[p].nr_sects > 0) {
kdev_t devp = MKDEV(hwif->major, minor+p);
- struct super_block * sb = get_super(devp);
- if (sb) invalidate_inodes(sb);
- invalidate_buffers (devp);
+ invalidate_device(devp);
}
}
#ifdef CONFIG_PROC_FS
diff -urN S4-pre8/drivers/mtd/ftl.c S4-pre8-ream_inodes/drivers/mtd/ftl.c
--- S4-pre8/drivers/mtd/ftl.c Fri Feb 16 22:53:55 2001
+++ S4-pre8-ream_inodes/drivers/mtd/ftl.c Fri Apr 27 21:40:32 2001
@@ -915,9 +915,6 @@
static release_t ftl_close(struct inode *inode, struct file *file)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- struct super_block *sb = get_super(inode->i_rdev);
-#endif
int minor = MINOR(inode->i_rdev);
partition_t *part = myparts[minor >> 4];
int i;
@@ -926,10 +923,7 @@
/* Flush all writes */
fsync_dev(inode->i_rdev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (sb) invalidate_inodes(sb);
-#endif
- invalidate_buffers(inode->i_rdev);
+ invalidate_device(inode->i_rdev);
/* Wait for any pending erase operations to complete */
if (part->mtd->sync)
diff -urN S4-pre8/drivers/mtd/mtdblock.c S4-pre8-ream_inodes/drivers/mtd/mtdblock.c
--- S4-pre8/drivers/mtd/mtdblock.c Fri Feb 16 22:53:55 2001
+++ S4-pre8-ream_inodes/drivers/mtd/mtdblock.c Fri Apr 27 21:40:40 2001
@@ -355,19 +355,13 @@
{
int dev;
struct mtdblk_dev *mtdblk;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- struct super_block * sb = get_super(inode->i_rdev);
-#endif
DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n");
if (inode == NULL)
release_return(-ENODEV);
fsync_dev(inode->i_rdev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (sb) invalidate_inodes(sb);
-#endif
- invalidate_buffers(inode->i_rdev);
+ invalidate_device(inode->i_rdev);
dev = MINOR(inode->i_rdev);
mtdblk = mtdblks[dev];
diff -urN S4-pre8/drivers/mtd/nftl.c S4-pre8-ream_inodes/drivers/mtd/nftl.c
--- S4-pre8/drivers/mtd/nftl.c Fri Feb 16 22:53:55 2001
+++ S4-pre8-ream_inodes/drivers/mtd/nftl.c Fri Apr 27 21:40:47 2001
@@ -997,7 +997,6 @@
static int nftl_release(struct inode *inode, struct file *fp)
{
- struct super_block *sb = get_super(inode->i_rdev);
struct NFTLrecord *thisNFTL;
thisNFTL = NFTLs[MINOR(inode->i_rdev) / 16];
@@ -1005,9 +1004,7 @@
DEBUG(MTD_DEBUG_LEVEL2, "NFTL_release\n");
fsync_dev(inode->i_rdev);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(inode->i_rdev);
+ invalidate_device(inode->i_rdev);
if (thisNFTL->mtd->sync)
thisNFTL->mtd->sync(thisNFTL->mtd);
diff -urN S4-pre8/drivers/scsi/sd.c S4-pre8-ream_inodes/drivers/scsi/sd.c
--- S4-pre8/drivers/scsi/sd.c Fri Feb 16 22:48:36 2001
+++ S4-pre8-ream_inodes/drivers/scsi/sd.c Fri Apr 27 21:41:02 2001
@@ -1262,11 +1262,8 @@
for (i = max_p - 1; i >= 0; i--) {
int index = start + i;
kdev_t devi = MKDEV_SD_PARTITION(index);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(devi);
sd_gendisks->part[index].start_sect = 0;
sd_gendisks->part[index].nr_sects = 0;
/*
@@ -1315,11 +1312,8 @@
for (j = max_p - 1; j >= 0; j--) {
int index = start + j;
kdev_t devi = MKDEV_SD_PARTITION(index);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(devi);
sd_gendisks->part[index].start_sect = 0;
sd_gendisks->part[index].nr_sects = 0;
sd_sizes[index] = 0;
diff -urN S4-pre8/drivers/scsi/sr.c S4-pre8-ream_inodes/drivers/scsi/sr.c
--- S4-pre8/drivers/scsi/sr.c Thu Feb 22 06:46:36 2001
+++ S4-pre8-ream_inodes/drivers/scsi/sr.c Fri Apr 27 21:41:11 2001
@@ -870,15 +870,12 @@
for (cpnt = scsi_CDs, i = 0; i < sr_template.dev_max; i++, cpnt++)
if (cpnt->device == SDp) {
kdev_t devi = MKDEV(MAJOR_NR, i);
- struct super_block *sb = get_super(devi);
/*
* Since the cdrom is read-only, no need to sync the device.
* We should be kind to our buffer cache, however.
*/
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(devi);
/*
* Reset things back to a sane state so that one can re-load a new
diff -urN S4-pre8/fs/block_dev.c S4-pre8-ream_inodes/fs/block_dev.c
--- S4-pre8/fs/block_dev.c Fri Feb 16 22:52:03 2001
+++ S4-pre8-ream_inodes/fs/block_dev.c Fri Apr 27 21:41:25 2001
@@ -576,11 +576,8 @@
printk(KERN_DEBUG "VFS: Disk change detected on device %s\n",
bdevname(dev));
- sb = get_super(dev);
- if (sb && invalidate_inodes(sb))
+ if (invalidate_device(dev))
printk("VFS: busy inodes on changed media.\n");
-
- destroy_buffers(dev);
if (bdops->revalidate)
bdops->revalidate(dev);
diff -urN S4-pre8/fs/devfs/base.c S4-pre8-ream_inodes/fs/devfs/base.c
--- S4-pre8/fs/devfs/base.c Fri Apr 27 06:21:01 2001
+++ S4-pre8-ream_inodes/fs/devfs/base.c Fri Apr 27 21:42:26 2001
@@ -2156,7 +2156,6 @@
int tmp;
kdev_t dev = MKDEV (de->u.fcb.u.device.major, de->u.fcb.u.device.minor);
struct block_device_operations *bdops = de->u.fcb.ops;
- struct super_block * sb;
extern int warn_no_part;
if ( !S_ISBLK (de->mode) ) return 0;
@@ -2165,10 +2164,8 @@
if ( !bdops->check_media_change (dev) ) return 0;
printk ( KERN_DEBUG "VFS: Disk change detected on device %s\n",
kdevname (dev) );
- sb = get_super (dev);
- if ( sb && invalidate_inodes (sb) )
+ if (invalidate_device(dev))
printk("VFS: busy inodes on changed media..\n");
- invalidate_buffers (dev);
/* Ugly hack to disable messages about unable to read partition table */
tmp = warn_no_part;
warn_no_part = 0;
diff -urN S4-pre8/fs/inode.c S4-pre8-ream_inodes/fs/inode.c
--- S4-pre8/fs/inode.c Fri Apr 27 06:21:01 2001
+++ S4-pre8-ream_inodes/fs/inode.c Fri Apr 27 21:42:03 2001
@@ -523,6 +523,17 @@
return busy;
}
+
+int invalidate_device(kdev_t dev)
+{
+ struct super_block *sb = get_super(dev);
+ int res;
+ if (sb)
+ res = invalidate_inodes(sb);
+ invalidate_buffers(dev);
+ return res;
+}
+
/*
* This is called with the inode lock held. It searches
diff -urN S4-pre8/include/linux/fs.h S4-pre8-ream_inodes/include/linux/fs.h
--- S4-pre8/include/linux/fs.h Fri Apr 27 06:21:03 2001
+++ S4-pre8-ream_inodes/include/linux/fs.h Fri Apr 27 21:42:33 2001
@@ -1084,6 +1084,7 @@
extern void balance_dirty(kdev_t);
extern int check_disk_change(kdev_t);
extern int invalidate_inodes(struct super_block *);
+extern int invalidate_device(kdev_t);
extern void invalidate_inode_pages(struct inode *);
extern void invalidate_inode_buffers(struct inode *);
#define invalidate_buffers(dev) __invalidate_buffers((dev), 0)
diff -urN S4-pre8/kernel/ksyms.c S4-pre8-ream_inodes/kernel/ksyms.c
--- S4-pre8/kernel/ksyms.c Fri Apr 27 06:21:04 2001
+++ S4-pre8-ream_inodes/kernel/ksyms.c Fri Apr 27 21:42:42 2001
@@ -174,6 +174,7 @@
EXPORT_SYMBOL(check_disk_change);
EXPORT_SYMBOL(__invalidate_buffers);
EXPORT_SYMBOL(invalidate_inodes);
+EXPORT_SYMBOL(invalidate_device);
EXPORT_SYMBOL(invalidate_inode_pages);
EXPORT_SYMBOL(truncate_inode_pages);
EXPORT_SYMBOL(fsync_dev);
On Fri, 27 Apr 2001, Linus Torvalds wrote:
>
> On Fri, 27 Apr 2001, Alexander Viro wrote:
> >
> > PS: last time I've separated that part of patch was a couple months
> > ago. See if something similar to the variant below would be OK with
> > you (I'll rediff it):
>
> This one looks fine.
Erm? It _does_ pull the fsync_dev() in there (conditionally, depending
on the "flag" argument of invalidate_dev()).
Oh, well... Check the variant I've sent to you couple of minutes ago and
tell which one you prefer, OK?
Al
PS: gotta love the email latency...
Alexander Viro wrote:
>
> On Fri, 27 Apr 2001, Alexander Viro wrote:
>
> > Fine with me. Actually in _all_ cases execept cdrom.c it's preceded by
> > either sync_dev() or fsync_dev(). What do you think about pulling that
> > into the same function? Actually, that's what I've done in namespace
> > patch (name being invalidate_dev(), BTW ;-) The only problem I see
> > here is the argument telling whether we want sync or fsync (or nothing).
> > OTOH, I seriously suspect that we ought replace all sync_dev() cases
> > with fsync_dev() anyway... Your opinion?
> > Al
>
> PS: last time I've separated that part of patch was a couple months
> ago. See if something similar to the variant below would be OK with
> you (I'll rediff it):
I think in the context you are inventig the proposed function,
the drivers has allways an inode at hand. And contrary to what Linus
says, drivers not just know about the devices they handle, they
know about the data they should get - at least in the context
of block devices. And then you could as well pass the inode, which
is already containing a refference to the corresponding sb and
save the whole get_super linear array lookup 8-). I think
the less kdev_t the better! It's overused already anyway, like
for example in the whole SCSI code, where the functions in reality only
want to pass the minor number to differentiate they behaviour...
If you are gogin to flag the behaviour of the function,
then please use a bitpattern of well definded flags as a parameter,
in a similiar way like it's done for example in many GUI libraries
(GTK, Motif and so on). This would make it far more readabel.
-- just my two euro-cent's...
On Sat, 28 Apr 2001, Martin Dalecki wrote:
> I think in the context you are inventig the proposed function,
> the drivers has allways an inode at hand. And contrary to what Linus
Read the patch. Almost all cases are of the "loop over partitions of foo"
kind.
> says, drivers not just know about the devices they handle, they
> know about the data they should get - at least in the context
> of block devices. And then you could as well pass the inode, which
> is already containing a refference to the corresponding sb and
> save the whole get_super linear array lookup 8-). I think
No, you don't. Moreover, inode of device (even if you had it) _doesn't_
contain a reference to sb of filesystem mounted from that device.
> the less kdev_t the better! It's overused already anyway, like
> for example in the whole SCSI code, where the functions in reality only
> want to pass the minor number to differentiate they behaviour...
>
> If you are gogin to flag the behaviour of the function,
> then please use a bitpattern of well definded flags as a parameter,
> in a similiar way like it's done for example in many GUI libraries
> (GTK, Motif and so on). This would make it far more readabel.
/me looks at From:
OK, Albert, what have you done with real Martin?
OK, whoever you are - no, "expandable" interfaces of that sort are
rotten idea. What we really need is to replace sync_dev with fsync_dev -
it _is_ correct in such context. That's it - 1 bit of information, no
bitmaps needed.
/me is still boggled by the idea of somebody refereing to GTK as an
example of style...
... and here's the promised second variant
Al
diff -urN S4/drivers/acorn/block/mfmhd.c S4-invalidate_device-2/drivers/acorn/block/mfmhd.c
--- S4/drivers/acorn/block/mfmhd.c Fri Feb 16 18:37:01 2001
+++ S4-invalidate_device-2/drivers/acorn/block/mfmhd.c Sat Apr 28 11:21:29 2001
@@ -1485,14 +1485,7 @@
for (i = maxp - 1; i >= 0; i--) {
int minor = start + i;
- kdev_t devi = MKDEV(MAJOR_NR, minor);
- struct super_block *sb = get_super(devi);
-
- sync_dev (devi);
- if (sb)
- invalidate_inodes (sb);
- invalidate_buffers (devi);
-
+ invalidate_device (MKDEV(MAJOR_NR, minor), 1);
mfm_gendisk.part[minor].start_sect = 0;
mfm_gendisk.part[minor].nr_sects = 0;
}
diff -urN S4/drivers/block/DAC960.c S4-invalidate_device-2/drivers/block/DAC960.c
--- S4/drivers/block/DAC960.c Thu Feb 22 06:46:26 2001
+++ S4-invalidate_device-2/drivers/block/DAC960.c Sat Apr 28 11:15:09 2001
@@ -5134,16 +5134,12 @@
PartitionNumber);
int MinorNumber = DAC960_MinorNumber(LogicalDriveNumber,
PartitionNumber);
- SuperBlock_T *SuperBlock = get_super(Device);
if (Controller->GenericDiskInfo.part[MinorNumber].nr_sects == 0)
continue;
/*
Flush all changes and invalidate buffered state.
*/
- sync_dev(Device);
- if (SuperBlock != NULL)
- invalidate_inodes(SuperBlock);
- invalidate_buffers(Device);
+ invalidate_device(Device, 1);
/*
Clear existing partition sizes.
*/
diff -urN S4/drivers/block/acsi.c S4-invalidate_device-2/drivers/block/acsi.c
--- S4/drivers/block/acsi.c Fri Feb 16 22:53:03 2001
+++ S4-invalidate_device-2/drivers/block/acsi.c Sat Apr 28 11:22:09 2001
@@ -1886,13 +1886,7 @@
for( i = max_p - 1; i >= 0 ; i-- ) {
if (gdev->part[start + i].nr_sects != 0) {
- kdev_t devp = MKDEV(MAJOR_NR, start + i);
- struct super_block *sb = get_super(devp);
-
- fsync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devp);
+ invalidate_device(MKDEV(MAJOR_NR, start + i), 1);
gdev->part[start + i].nr_sects = 0;
}
gdev->part[start+i].start_sect = 0;
diff -urN S4/drivers/block/amiflop.c S4-invalidate_device-2/drivers/block/amiflop.c
--- S4/drivers/block/amiflop.c Fri Feb 16 18:59:20 2001
+++ S4-invalidate_device-2/drivers/block/amiflop.c Sat Apr 28 11:15:26 2001
@@ -1540,10 +1540,7 @@
break;
case FDFMTEND:
floppy_off(drive);
- sb = get_super(inode->i_rdev);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(inode->i_rdev);
+ invalidate_device(inode->i_rdev, 0);
break;
case FDGETPRM:
memset((void *)&getprm, 0, sizeof (getprm));
diff -urN S4/drivers/block/cciss.c S4-invalidate_device-2/drivers/block/cciss.c
--- S4/drivers/block/cciss.c Sat Apr 28 02:12:49 2001
+++ S4-invalidate_device-2/drivers/block/cciss.c Sat Apr 28 11:22:44 2001
@@ -693,11 +693,7 @@
for(i=max_p; i>=0; i--) {
int minor = start+i;
- kdev_t devi = MKDEV(MAJOR_NR + ctlr, minor);
- struct super_block *sb = get_super(devi);
- sync_dev(devi);
- if (sb) invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(MKDEV(MAJOR_NR + ctlr, minor), 1);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
diff -urN S4/drivers/block/cpqarray.c S4-invalidate_device-2/drivers/block/cpqarray.c
--- S4/drivers/block/cpqarray.c Fri Feb 16 22:56:28 2001
+++ S4-invalidate_device-2/drivers/block/cpqarray.c Sat Apr 28 11:23:05 2001
@@ -1576,11 +1576,7 @@
for(i=max_p; i>=0; i--) {
int minor = start+i;
- kdev_t devi = MKDEV(MAJOR_NR + ctlr, minor);
- struct super_block *sb = get_super(devi);
- sync_dev(devi);
- if (sb) invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(MKDEV(MAJOR_NR + ctlr, minor), 1);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
diff -urN S4/drivers/block/paride/pd.c S4-invalidate_device-2/drivers/block/paride/pd.c
--- S4/drivers/block/paride/pd.c Fri Feb 16 22:50:44 2001
+++ S4-invalidate_device-2/drivers/block/paride/pd.c Sat Apr 28 11:24:52 2001
@@ -589,9 +589,6 @@
{ int p, unit, minor;
long flags;
- kdev_t devp;
-
- struct super_block *sb;
unit = DEVICE_NR(dev);
if ((unit >= PD_UNITS) || (!PD.present)) return -ENODEV;
@@ -607,13 +604,7 @@
for (p=(PD_PARTNS-1);p>=0;p--) {
minor = p + unit*PD_PARTNS;
- devp = MKDEV(MAJOR_NR, minor);
- fsync_dev(devp);
-
- sb = get_super(devp);
- if (sb) invalidate_inodes(sb);
-
- invalidate_buffers(devp);
+ invalidate_device(MKDEV(MAJOR_NR, minor), 1);
pd_hd[minor].start_sect = 0;
pd_hd[minor].nr_sects = 0;
}
diff -urN S4/drivers/block/ps2esdi.c S4-invalidate_device-2/drivers/block/ps2esdi.c
--- S4/drivers/block/ps2esdi.c Sat Apr 28 02:12:49 2001
+++ S4-invalidate_device-2/drivers/block/ps2esdi.c Sat Apr 28 11:23:49 2001
@@ -1145,15 +1145,9 @@
for (partition = ps2esdi_gendisk.max_p - 1;
partition >= 0; partition--) {
int minor = (start | partition);
- kdev_t devp = MKDEV(MAJOR_NR, minor);
- struct super_block * sb = get_super(devp);
-
- sync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devp);
- ps2esdi_gendisk.part[start + partition].start_sect = 0;
- ps2esdi_gendisk.part[start + partition].nr_sects = 0;
+ invalidate_device(MKDEV(MAJOR_NR, minor), 1);
+ ps2esdi_gendisk.part[minor].start_sect = 0;
+ ps2esdi_gendisk.part[minor].nr_sects = 0;
}
grok_partitions(&ps2esdi_gendisk, target, 1<<6,
diff -urN S4/drivers/block/xd.c S4-invalidate_device-2/drivers/block/xd.c
--- S4/drivers/block/xd.c Thu Feb 22 06:46:25 2001
+++ S4-invalidate_device-2/drivers/block/xd.c Sat Apr 28 11:24:10 2001
@@ -401,13 +401,7 @@
for (partition = xd_gendisk.max_p - 1; partition >= 0; partition--) {
int minor = (start | partition);
- kdev_t devp = MKDEV(MAJOR_NR, minor);
- struct super_block * sb = get_super(devp);
-
- sync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devp);
+ invalidate_device(MKDEV(MAJOR_NR, minor), 1);
xd_gendisk.part[minor].start_sect = 0;
xd_gendisk.part[minor].nr_sects = 0;
};
@@ -1163,16 +1157,6 @@
int partition,dev,start;
devfs_unregister_blkdev(MAJOR_NR, "xd");
- for (dev = 0; dev < xd_drives; dev++) {
- start = dev << xd_gendisk.minor_shift;
- for (partition = xd_gendisk.max_p - 1; partition >= 0; partition--) {
- int minor = (start | partition);
- kdev_t devp = MKDEV(MAJOR_NR, minor);
- start = dev << xd_gendisk.minor_shift;
- sync_dev(devp);
- invalidate_buffers(devp);
- }
- }
xd_done();
devfs_unregister (devfs_handle);
if (xd_drives) {
diff -urN S4/drivers/i2o/i2o_block.c S4-invalidate_device-2/drivers/i2o/i2o_block.c
--- S4/drivers/i2o/i2o_block.c Fri Feb 16 22:53:46 2001
+++ S4-invalidate_device-2/drivers/i2o/i2o_block.c Sat Apr 28 11:25:12 2001
@@ -892,13 +892,7 @@
for( i = 15; i>=0 ; i--)
{
int m = minor+i;
- kdev_t d = MKDEV(MAJOR_NR, m);
- struct super_block *sb = get_super(d);
-
- sync_dev(d);
- if(sb)
- invalidate_inodes(sb);
- invalidate_buffers(d);
+ invalidate_device(MKDEV(MAJOR_NR, m), 1);
i2ob_gendisk.part[m].start_sect = 0;
i2ob_gendisk.part[m].nr_sects = 0;
}
diff -urN S4/drivers/ide/hd.c S4-invalidate_device-2/drivers/ide/hd.c
--- S4/drivers/ide/hd.c Thu Feb 22 06:47:01 2001
+++ S4-invalidate_device-2/drivers/ide/hd.c Sat Apr 28 11:25:33 2001
@@ -892,13 +892,7 @@
for (i=max_p - 1; i >=0 ; i--) {
int minor = start + i;
- kdev_t devi = MKDEV(MAJOR_NR, minor);
- struct super_block *sb = get_super(devi);
-
- sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(MKDEV(MAJOR_NR, minor), 1);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
}
diff -urN S4/drivers/ide/ide.c S4-invalidate_device-2/drivers/ide/ide.c
--- S4/drivers/ide/ide.c Sat Apr 28 02:12:50 2001
+++ S4-invalidate_device-2/drivers/ide/ide.c Sat Apr 28 11:17:04 2001
@@ -1762,11 +1762,7 @@
for (p = 0; p < (1<<PARTN_BITS); ++p) {
if (drive->part[p].nr_sects > 0) {
kdev_t devp = MKDEV(major, minor+p);
- struct super_block * sb = get_super(devp);
- fsync_dev (devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers (devp);
+ invalidate_device(devp, 1);
set_blocksize(devp, 1024);
}
drive->part[p].start_sect = 0;
@@ -1983,9 +1979,7 @@
for (p = 0; p < (1<<PARTN_BITS); ++p) {
if (drive->part[p].nr_sects > 0) {
kdev_t devp = MKDEV(hwif->major, minor+p);
- struct super_block * sb = get_super(devp);
- if (sb) invalidate_inodes(sb);
- invalidate_buffers (devp);
+ invalidate_device(devp, 0);
}
}
#ifdef CONFIG_PROC_FS
diff -urN S4/drivers/mtd/ftl.c S4-invalidate_device-2/drivers/mtd/ftl.c
--- S4/drivers/mtd/ftl.c Fri Feb 16 22:53:55 2001
+++ S4-invalidate_device-2/drivers/mtd/ftl.c Sat Apr 28 11:17:11 2001
@@ -915,9 +915,6 @@
static release_t ftl_close(struct inode *inode, struct file *file)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- struct super_block *sb = get_super(inode->i_rdev);
-#endif
int minor = MINOR(inode->i_rdev);
partition_t *part = myparts[minor >> 4];
int i;
@@ -925,11 +922,7 @@
DEBUG(0, "ftl_cs: ftl_close(%d)\n", minor);
/* Flush all writes */
- fsync_dev(inode->i_rdev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (sb) invalidate_inodes(sb);
-#endif
- invalidate_buffers(inode->i_rdev);
+ invalidate_device(inode->i_rdev, 1);
/* Wait for any pending erase operations to complete */
if (part->mtd->sync)
diff -urN S4/drivers/mtd/mtdblock.c S4-invalidate_device-2/drivers/mtd/mtdblock.c
--- S4/drivers/mtd/mtdblock.c Fri Feb 16 22:53:55 2001
+++ S4-invalidate_device-2/drivers/mtd/mtdblock.c Sat Apr 28 11:17:18 2001
@@ -355,19 +355,12 @@
{
int dev;
struct mtdblk_dev *mtdblk;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- struct super_block * sb = get_super(inode->i_rdev);
-#endif
DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n");
if (inode == NULL)
release_return(-ENODEV);
- fsync_dev(inode->i_rdev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (sb) invalidate_inodes(sb);
-#endif
- invalidate_buffers(inode->i_rdev);
+ invalidate_device(inode->i_rdev, 1);
dev = MINOR(inode->i_rdev);
mtdblk = mtdblks[dev];
diff -urN S4/drivers/mtd/nftl.c S4-invalidate_device-2/drivers/mtd/nftl.c
--- S4/drivers/mtd/nftl.c Fri Feb 16 22:53:55 2001
+++ S4-invalidate_device-2/drivers/mtd/nftl.c Sat Apr 28 11:17:24 2001
@@ -997,17 +997,13 @@
static int nftl_release(struct inode *inode, struct file *fp)
{
- struct super_block *sb = get_super(inode->i_rdev);
struct NFTLrecord *thisNFTL;
thisNFTL = NFTLs[MINOR(inode->i_rdev) / 16];
DEBUG(MTD_DEBUG_LEVEL2, "NFTL_release\n");
- fsync_dev(inode->i_rdev);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(inode->i_rdev);
+ invalidate_device(inode->i_rdev, 1);
if (thisNFTL->mtd->sync)
thisNFTL->mtd->sync(thisNFTL->mtd);
diff -urN S4/drivers/scsi/sd.c S4-invalidate_device-2/drivers/scsi/sd.c
--- S4/drivers/scsi/sd.c Fri Feb 16 22:48:36 2001
+++ S4-invalidate_device-2/drivers/scsi/sd.c Sat Apr 28 11:27:18 2001
@@ -1261,12 +1261,7 @@
for (i = max_p - 1; i >= 0; i--) {
int index = start + i;
- kdev_t devi = MKDEV_SD_PARTITION(index);
- struct super_block *sb = get_super(devi);
- sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(MKDEV_SD_PARTITION(index), 1);
sd_gendisks->part[index].start_sect = 0;
sd_gendisks->part[index].nr_sects = 0;
/*
@@ -1314,12 +1309,7 @@
for (j = max_p - 1; j >= 0; j--) {
int index = start + j;
- kdev_t devi = MKDEV_SD_PARTITION(index);
- struct super_block *sb = get_super(devi);
- sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(MKDEV_SD_PARTITION(index), 1);
sd_gendisks->part[index].start_sect = 0;
sd_gendisks->part[index].nr_sects = 0;
sd_sizes[index] = 0;
diff -urN S4/drivers/scsi/sr.c S4-invalidate_device-2/drivers/scsi/sr.c
--- S4/drivers/scsi/sr.c Thu Feb 22 06:46:36 2001
+++ S4-invalidate_device-2/drivers/scsi/sr.c Sat Apr 28 11:27:42 2001
@@ -869,16 +869,11 @@
for (cpnt = scsi_CDs, i = 0; i < sr_template.dev_max; i++, cpnt++)
if (cpnt->device == SDp) {
- kdev_t devi = MKDEV(MAJOR_NR, i);
- struct super_block *sb = get_super(devi);
-
/*
* Since the cdrom is read-only, no need to sync the device.
* We should be kind to our buffer cache, however.
*/
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(MKDEV(MAJOR_NR, i), 0);
/*
* Reset things back to a sane state so that one can re-load a new
diff -urN S4/fs/block_dev.c S4-invalidate_device-2/fs/block_dev.c
--- S4/fs/block_dev.c Fri Feb 16 22:52:03 2001
+++ S4-invalidate_device-2/fs/block_dev.c Sat Apr 28 11:17:57 2001
@@ -576,11 +576,8 @@
printk(KERN_DEBUG "VFS: Disk change detected on device %s\n",
bdevname(dev));
- sb = get_super(dev);
- if (sb && invalidate_inodes(sb))
+ if (invalidate_device(dev, 0))
printk("VFS: busy inodes on changed media.\n");
-
- destroy_buffers(dev);
if (bdops->revalidate)
bdops->revalidate(dev);
diff -urN S4/fs/devfs/base.c S4-invalidate_device-2/fs/devfs/base.c
--- S4/fs/devfs/base.c Sat Apr 28 02:12:56 2001
+++ S4-invalidate_device-2/fs/devfs/base.c Sat Apr 28 11:18:27 2001
@@ -2156,7 +2156,6 @@
int tmp;
kdev_t dev = MKDEV (de->u.fcb.u.device.major, de->u.fcb.u.device.minor);
struct block_device_operations *bdops = de->u.fcb.ops;
- struct super_block * sb;
extern int warn_no_part;
if ( !S_ISBLK (de->mode) ) return 0;
@@ -2165,10 +2164,8 @@
if ( !bdops->check_media_change (dev) ) return 0;
printk ( KERN_DEBUG "VFS: Disk change detected on device %s\n",
kdevname (dev) );
- sb = get_super (dev);
- if ( sb && invalidate_inodes (sb) )
+ if (invalidate_device(dev, 0))
printk("VFS: busy inodes on changed media..\n");
- invalidate_buffers (dev);
/* Ugly hack to disable messages about unable to read partition table */
tmp = warn_no_part;
warn_no_part = 0;
diff -urN S4/fs/inode.c S4-invalidate_device-2/fs/inode.c
--- S4/fs/inode.c Sat Apr 28 02:12:56 2001
+++ S4-invalidate_device-2/fs/inode.c Sat Apr 28 11:18:22 2001
@@ -591,6 +591,19 @@
return busy;
}
+
+int invalidate_device(kdev_t dev, int do_sync)
+{
+ struct super_block *sb = get_super(dev);
+ int res;
+ if (do_sync)
+ fsync_dev(dev);
+ if (sb)
+ res = invalidate_inodes(sb);
+ invalidate_buffers(dev);
+ return res;
+}
+
/*
* This is called with the inode lock held. It searches
diff -urN S4/include/linux/fs.h S4-invalidate_device-2/include/linux/fs.h
--- S4/include/linux/fs.h Sat Apr 28 02:12:59 2001
+++ S4-invalidate_device-2/include/linux/fs.h Sat Apr 28 11:18:34 2001
@@ -1086,6 +1086,7 @@
extern void balance_dirty(kdev_t);
extern int check_disk_change(kdev_t);
extern int invalidate_inodes(struct super_block *);
+extern int invalidate_device(kdev_t, int);
extern void invalidate_inode_pages(struct inode *);
extern void invalidate_inode_buffers(struct inode *);
#define invalidate_buffers(dev) __invalidate_buffers((dev), 0)
diff -urN S4/kernel/ksyms.c S4-invalidate_device-2/kernel/ksyms.c
--- S4/kernel/ksyms.c Sat Apr 28 02:12:59 2001
+++ S4-invalidate_device-2/kernel/ksyms.c Sat Apr 28 11:13:05 2001
@@ -174,6 +174,7 @@
EXPORT_SYMBOL(check_disk_change);
EXPORT_SYMBOL(__invalidate_buffers);
EXPORT_SYMBOL(invalidate_inodes);
+EXPORT_SYMBOL(invalidate_device);
EXPORT_SYMBOL(invalidate_inode_pages);
EXPORT_SYMBOL(truncate_inode_pages);
EXPORT_SYMBOL(fsync_dev);
OK, I'm sending both variants (rediffed to 2.4.4). Take your pick.
Variant 1: invalidate_device(dev) (see below)
Variant 2: invalidate_device(dev, do_sync) (next posting; I've switched the
cases using sync_dev to fsync_dev, so do_sync is boolean)
diff -urN S4/drivers/acorn/block/mfmhd.c S4-invalidate_device-1/drivers/acorn/block/mfmhd.c
--- S4/drivers/acorn/block/mfmhd.c Fri Feb 16 18:37:01 2001
+++ S4-invalidate_device-1/drivers/acorn/block/mfmhd.c Sat Apr 28 11:12:05 2001
@@ -1486,12 +1486,9 @@
for (i = maxp - 1; i >= 0; i--) {
int minor = start + i;
kdev_t devi = MKDEV(MAJOR_NR, minor);
- struct super_block *sb = get_super(devi);
sync_dev (devi);
- if (sb)
- invalidate_inodes (sb);
- invalidate_buffers (devi);
+ invalidate_device (devi);
mfm_gendisk.part[minor].start_sect = 0;
mfm_gendisk.part[minor].nr_sects = 0;
diff -urN S4/drivers/block/DAC960.c S4-invalidate_device-1/drivers/block/DAC960.c
--- S4/drivers/block/DAC960.c Thu Feb 22 06:46:26 2001
+++ S4-invalidate_device-1/drivers/block/DAC960.c Sat Apr 28 11:12:05 2001
@@ -5134,16 +5134,13 @@
PartitionNumber);
int MinorNumber = DAC960_MinorNumber(LogicalDriveNumber,
PartitionNumber);
- SuperBlock_T *SuperBlock = get_super(Device);
if (Controller->GenericDiskInfo.part[MinorNumber].nr_sects == 0)
continue;
/*
Flush all changes and invalidate buffered state.
*/
sync_dev(Device);
- if (SuperBlock != NULL)
- invalidate_inodes(SuperBlock);
- invalidate_buffers(Device);
+ invalidate_device(Device);
/*
Clear existing partition sizes.
*/
diff -urN S4/drivers/block/acsi.c S4-invalidate_device-1/drivers/block/acsi.c
--- S4/drivers/block/acsi.c Fri Feb 16 22:53:03 2001
+++ S4-invalidate_device-1/drivers/block/acsi.c Sat Apr 28 11:12:05 2001
@@ -1887,12 +1887,9 @@
for( i = max_p - 1; i >= 0 ; i-- ) {
if (gdev->part[start + i].nr_sects != 0) {
kdev_t devp = MKDEV(MAJOR_NR, start + i);
- struct super_block *sb = get_super(devp);
fsync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devp);
+ invalidate_device(devp);
gdev->part[start + i].nr_sects = 0;
}
gdev->part[start+i].start_sect = 0;
diff -urN S4/drivers/block/amiflop.c S4-invalidate_device-1/drivers/block/amiflop.c
--- S4/drivers/block/amiflop.c Fri Feb 16 18:59:20 2001
+++ S4-invalidate_device-1/drivers/block/amiflop.c Sat Apr 28 11:12:05 2001
@@ -1540,10 +1540,7 @@
break;
case FDFMTEND:
floppy_off(drive);
- sb = get_super(inode->i_rdev);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(inode->i_rdev);
+ invalidate_device(inode->i_rdev);
break;
case FDGETPRM:
memset((void *)&getprm, 0, sizeof (getprm));
diff -urN S4/drivers/block/cciss.c S4-invalidate_device-1/drivers/block/cciss.c
--- S4/drivers/block/cciss.c Sat Apr 28 02:12:49 2001
+++ S4-invalidate_device-1/drivers/block/cciss.c Sat Apr 28 11:12:05 2001
@@ -694,10 +694,8 @@
for(i=max_p; i>=0; i--) {
int minor = start+i;
kdev_t devi = MKDEV(MAJOR_NR + ctlr, minor);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb) invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(devi);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
diff -urN S4/drivers/block/cpqarray.c S4-invalidate_device-1/drivers/block/cpqarray.c
--- S4/drivers/block/cpqarray.c Fri Feb 16 22:56:28 2001
+++ S4-invalidate_device-1/drivers/block/cpqarray.c Sat Apr 28 11:12:05 2001
@@ -1577,10 +1577,8 @@
for(i=max_p; i>=0; i--) {
int minor = start+i;
kdev_t devi = MKDEV(MAJOR_NR + ctlr, minor);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb) invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(devi);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
diff -urN S4/drivers/block/paride/pd.c S4-invalidate_device-1/drivers/block/paride/pd.c
--- S4/drivers/block/paride/pd.c Fri Feb 16 22:50:44 2001
+++ S4-invalidate_device-1/drivers/block/paride/pd.c Sat Apr 28 11:12:05 2001
@@ -591,8 +591,6 @@
long flags;
kdev_t devp;
- struct super_block *sb;
-
unit = DEVICE_NR(dev);
if ((unit >= PD_UNITS) || (!PD.present)) return -ENODEV;
@@ -609,11 +607,7 @@
minor = p + unit*PD_PARTNS;
devp = MKDEV(MAJOR_NR, minor);
fsync_dev(devp);
-
- sb = get_super(devp);
- if (sb) invalidate_inodes(sb);
-
- invalidate_buffers(devp);
+ invalidate_device(devp);
pd_hd[minor].start_sect = 0;
pd_hd[minor].nr_sects = 0;
}
diff -urN S4/drivers/block/ps2esdi.c S4-invalidate_device-1/drivers/block/ps2esdi.c
--- S4/drivers/block/ps2esdi.c Sat Apr 28 02:12:49 2001
+++ S4-invalidate_device-1/drivers/block/ps2esdi.c Sat Apr 28 11:12:05 2001
@@ -1146,12 +1146,9 @@
partition >= 0; partition--) {
int minor = (start | partition);
kdev_t devp = MKDEV(MAJOR_NR, minor);
- struct super_block * sb = get_super(devp);
sync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devp);
+ invalidate_device(devp);
ps2esdi_gendisk.part[start + partition].start_sect = 0;
ps2esdi_gendisk.part[start + partition].nr_sects = 0;
}
diff -urN S4/drivers/block/xd.c S4-invalidate_device-1/drivers/block/xd.c
--- S4/drivers/block/xd.c Thu Feb 22 06:46:25 2001
+++ S4-invalidate_device-1/drivers/block/xd.c Sat Apr 28 11:12:06 2001
@@ -402,12 +402,9 @@
for (partition = xd_gendisk.max_p - 1; partition >= 0; partition--) {
int minor = (start | partition);
kdev_t devp = MKDEV(MAJOR_NR, minor);
- struct super_block * sb = get_super(devp);
sync_dev(devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devp);
+ invalidate_device(devp);
xd_gendisk.part[minor].start_sect = 0;
xd_gendisk.part[minor].nr_sects = 0;
};
diff -urN S4/drivers/i2o/i2o_block.c S4-invalidate_device-1/drivers/i2o/i2o_block.c
--- S4/drivers/i2o/i2o_block.c Fri Feb 16 22:53:46 2001
+++ S4-invalidate_device-1/drivers/i2o/i2o_block.c Sat Apr 28 11:12:06 2001
@@ -893,12 +893,9 @@
{
int m = minor+i;
kdev_t d = MKDEV(MAJOR_NR, m);
- struct super_block *sb = get_super(d);
sync_dev(d);
- if(sb)
- invalidate_inodes(sb);
- invalidate_buffers(d);
+ invalidate_device(d);
i2ob_gendisk.part[m].start_sect = 0;
i2ob_gendisk.part[m].nr_sects = 0;
}
diff -urN S4/drivers/ide/hd.c S4-invalidate_device-1/drivers/ide/hd.c
--- S4/drivers/ide/hd.c Thu Feb 22 06:47:01 2001
+++ S4-invalidate_device-1/drivers/ide/hd.c Sat Apr 28 11:12:06 2001
@@ -893,12 +893,9 @@
for (i=max_p - 1; i >=0 ; i--) {
int minor = start + i;
kdev_t devi = MKDEV(MAJOR_NR, minor);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(devi);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
}
diff -urN S4/drivers/ide/ide.c S4-invalidate_device-1/drivers/ide/ide.c
--- S4/drivers/ide/ide.c Sat Apr 28 02:12:50 2001
+++ S4-invalidate_device-1/drivers/ide/ide.c Sat Apr 28 11:12:06 2001
@@ -1762,11 +1762,8 @@
for (p = 0; p < (1<<PARTN_BITS); ++p) {
if (drive->part[p].nr_sects > 0) {
kdev_t devp = MKDEV(major, minor+p);
- struct super_block * sb = get_super(devp);
- fsync_dev (devp);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers (devp);
+ fsync_dev(devp);
+ invalidate_device(devp);
set_blocksize(devp, 1024);
}
drive->part[p].start_sect = 0;
@@ -1983,9 +1980,7 @@
for (p = 0; p < (1<<PARTN_BITS); ++p) {
if (drive->part[p].nr_sects > 0) {
kdev_t devp = MKDEV(hwif->major, minor+p);
- struct super_block * sb = get_super(devp);
- if (sb) invalidate_inodes(sb);
- invalidate_buffers (devp);
+ invalidate_device(devp);
}
}
#ifdef CONFIG_PROC_FS
diff -urN S4/drivers/mtd/ftl.c S4-invalidate_device-1/drivers/mtd/ftl.c
--- S4/drivers/mtd/ftl.c Fri Feb 16 22:53:55 2001
+++ S4-invalidate_device-1/drivers/mtd/ftl.c Sat Apr 28 11:12:06 2001
@@ -915,9 +915,6 @@
static release_t ftl_close(struct inode *inode, struct file *file)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- struct super_block *sb = get_super(inode->i_rdev);
-#endif
int minor = MINOR(inode->i_rdev);
partition_t *part = myparts[minor >> 4];
int i;
@@ -926,10 +923,7 @@
/* Flush all writes */
fsync_dev(inode->i_rdev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (sb) invalidate_inodes(sb);
-#endif
- invalidate_buffers(inode->i_rdev);
+ invalidate_device(inode->i_rdev);
/* Wait for any pending erase operations to complete */
if (part->mtd->sync)
diff -urN S4/drivers/mtd/mtdblock.c S4-invalidate_device-1/drivers/mtd/mtdblock.c
--- S4/drivers/mtd/mtdblock.c Fri Feb 16 22:53:55 2001
+++ S4-invalidate_device-1/drivers/mtd/mtdblock.c Sat Apr 28 11:12:06 2001
@@ -355,19 +355,13 @@
{
int dev;
struct mtdblk_dev *mtdblk;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- struct super_block * sb = get_super(inode->i_rdev);
-#endif
DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n");
if (inode == NULL)
release_return(-ENODEV);
fsync_dev(inode->i_rdev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (sb) invalidate_inodes(sb);
-#endif
- invalidate_buffers(inode->i_rdev);
+ invalidate_device(inode->i_rdev);
dev = MINOR(inode->i_rdev);
mtdblk = mtdblks[dev];
diff -urN S4/drivers/mtd/nftl.c S4-invalidate_device-1/drivers/mtd/nftl.c
--- S4/drivers/mtd/nftl.c Fri Feb 16 22:53:55 2001
+++ S4-invalidate_device-1/drivers/mtd/nftl.c Sat Apr 28 11:12:06 2001
@@ -997,7 +997,6 @@
static int nftl_release(struct inode *inode, struct file *fp)
{
- struct super_block *sb = get_super(inode->i_rdev);
struct NFTLrecord *thisNFTL;
thisNFTL = NFTLs[MINOR(inode->i_rdev) / 16];
@@ -1005,9 +1004,7 @@
DEBUG(MTD_DEBUG_LEVEL2, "NFTL_release\n");
fsync_dev(inode->i_rdev);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(inode->i_rdev);
+ invalidate_device(inode->i_rdev);
if (thisNFTL->mtd->sync)
thisNFTL->mtd->sync(thisNFTL->mtd);
diff -urN S4/drivers/scsi/sd.c S4-invalidate_device-1/drivers/scsi/sd.c
--- S4/drivers/scsi/sd.c Fri Feb 16 22:48:36 2001
+++ S4-invalidate_device-1/drivers/scsi/sd.c Sat Apr 28 11:12:06 2001
@@ -1262,11 +1262,8 @@
for (i = max_p - 1; i >= 0; i--) {
int index = start + i;
kdev_t devi = MKDEV_SD_PARTITION(index);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(devi);
sd_gendisks->part[index].start_sect = 0;
sd_gendisks->part[index].nr_sects = 0;
/*
@@ -1315,11 +1312,8 @@
for (j = max_p - 1; j >= 0; j--) {
int index = start + j;
kdev_t devi = MKDEV_SD_PARTITION(index);
- struct super_block *sb = get_super(devi);
sync_dev(devi);
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(devi);
sd_gendisks->part[index].start_sect = 0;
sd_gendisks->part[index].nr_sects = 0;
sd_sizes[index] = 0;
diff -urN S4/drivers/scsi/sr.c S4-invalidate_device-1/drivers/scsi/sr.c
--- S4/drivers/scsi/sr.c Thu Feb 22 06:46:36 2001
+++ S4-invalidate_device-1/drivers/scsi/sr.c Sat Apr 28 11:12:06 2001
@@ -870,15 +870,12 @@
for (cpnt = scsi_CDs, i = 0; i < sr_template.dev_max; i++, cpnt++)
if (cpnt->device == SDp) {
kdev_t devi = MKDEV(MAJOR_NR, i);
- struct super_block *sb = get_super(devi);
/*
* Since the cdrom is read-only, no need to sync the device.
* We should be kind to our buffer cache, however.
*/
- if (sb)
- invalidate_inodes(sb);
- invalidate_buffers(devi);
+ invalidate_device(devi);
/*
* Reset things back to a sane state so that one can re-load a new
diff -urN S4/fs/block_dev.c S4-invalidate_device-1/fs/block_dev.c
--- S4/fs/block_dev.c Fri Feb 16 22:52:03 2001
+++ S4-invalidate_device-1/fs/block_dev.c Sat Apr 28 11:12:06 2001
@@ -576,11 +576,8 @@
printk(KERN_DEBUG "VFS: Disk change detected on device %s\n",
bdevname(dev));
- sb = get_super(dev);
- if (sb && invalidate_inodes(sb))
+ if (invalidate_device(dev))
printk("VFS: busy inodes on changed media.\n");
-
- destroy_buffers(dev);
if (bdops->revalidate)
bdops->revalidate(dev);
diff -urN S4/fs/devfs/base.c S4-invalidate_device-1/fs/devfs/base.c
--- S4/fs/devfs/base.c Sat Apr 28 02:12:56 2001
+++ S4-invalidate_device-1/fs/devfs/base.c Sat Apr 28 11:12:06 2001
@@ -2156,7 +2156,6 @@
int tmp;
kdev_t dev = MKDEV (de->u.fcb.u.device.major, de->u.fcb.u.device.minor);
struct block_device_operations *bdops = de->u.fcb.ops;
- struct super_block * sb;
extern int warn_no_part;
if ( !S_ISBLK (de->mode) ) return 0;
@@ -2165,10 +2164,8 @@
if ( !bdops->check_media_change (dev) ) return 0;
printk ( KERN_DEBUG "VFS: Disk change detected on device %s\n",
kdevname (dev) );
- sb = get_super (dev);
- if ( sb && invalidate_inodes (sb) )
+ if (invalidate_device(dev))
printk("VFS: busy inodes on changed media..\n");
- invalidate_buffers (dev);
/* Ugly hack to disable messages about unable to read partition table */
tmp = warn_no_part;
warn_no_part = 0;
diff -urN S4/fs/inode.c S4-invalidate_device-1/fs/inode.c
--- S4/fs/inode.c Sat Apr 28 02:12:56 2001
+++ S4-invalidate_device-1/fs/inode.c Sat Apr 28 11:12:06 2001
@@ -591,6 +591,17 @@
return busy;
}
+
+int invalidate_device(kdev_t dev)
+{
+ struct super_block *sb = get_super(dev);
+ int res;
+ if (sb)
+ res = invalidate_inodes(sb);
+ invalidate_buffers(dev);
+ return res;
+}
+
/*
* This is called with the inode lock held. It searches
diff -urN S4/include/linux/fs.h S4-invalidate_device-1/include/linux/fs.h
--- S4/include/linux/fs.h Sat Apr 28 02:12:59 2001
+++ S4-invalidate_device-1/include/linux/fs.h Sat Apr 28 11:12:06 2001
@@ -1086,6 +1086,7 @@
extern void balance_dirty(kdev_t);
extern int check_disk_change(kdev_t);
extern int invalidate_inodes(struct super_block *);
+extern int invalidate_device(kdev_t);
extern void invalidate_inode_pages(struct inode *);
extern void invalidate_inode_buffers(struct inode *);
#define invalidate_buffers(dev) __invalidate_buffers((dev), 0)
diff -urN S4/kernel/ksyms.c S4-invalidate_device-1/kernel/ksyms.c
--- S4/kernel/ksyms.c Sat Apr 28 02:12:59 2001
+++ S4-invalidate_device-1/kernel/ksyms.c Sat Apr 28 11:12:06 2001
@@ -174,6 +174,7 @@
EXPORT_SYMBOL(check_disk_change);
EXPORT_SYMBOL(__invalidate_buffers);
EXPORT_SYMBOL(invalidate_inodes);
+EXPORT_SYMBOL(invalidate_device);
EXPORT_SYMBOL(invalidate_inode_pages);
EXPORT_SYMBOL(truncate_inode_pages);
EXPORT_SYMBOL(fsync_dev);
Alexander Viro wrote:
>
> On Sat, 28 Apr 2001, Martin Dalecki wrote:
>
> > I think in the context you are inventig the proposed function,
> > the drivers has allways an inode at hand. And contrary to what Linus
>
> Read the patch. Almost all cases are of the "loop over partitions of foo"
> kind.
>
> > says, drivers not just know about the devices they handle, they
> > know about the data they should get - at least in the context
> > of block devices. And then you could as well pass the inode, which
> > is already containing a refference to the corresponding sb and
> > save the whole get_super linear array lookup 8-). I think
>
> No, you don't. Moreover, inode of device (even if you had it) _doesn't_
> contain a reference to sb of filesystem mounted from that device.
Ohhh sorry right, I just did forget to have an checking look at the code
before actual rammbling... It must had been some reminiscent from
some other expermient with the kernel code I did recently that confused
me.
Sorry again...
> > the less kdev_t the better! It's overused already anyway, like
> > for example in the whole SCSI code, where the functions in reality only
> > want to pass the minor number to differentiate they behaviour...
This however I still hold up...
> > If you are gogin to flag the behaviour of the function,
> > then please use a bitpattern of well definded flags as a parameter,
> > in a similiar way like it's done for example in many GUI libraries
> > (GTK, Motif and so on). This would make it far more readabel.
>
> /me looks at From:
> OK, Albert, what have you done with real Martin?
>
> OK, whoever you are - no, "expandable" interfaces of that sort are
> rotten idea. What we really need is to replace sync_dev with fsync_dev -
> it _is_ correct in such context. That's it - 1 bit of information, no
> bitmaps needed.
>
> /me is still boggled by the idea of somebody refereing to GTK as an
> example of style...
Ehm, only for the waythe flags get passed, not the rest of it.
You know if I see some parameter, taking possible values 0, 1, 2
then I mostly think that there should be some concrete names given to
them :-).