From: Alain Knaff <Alain.Knaff@hitchhiker.org.lu>
To: Alexander Viro <viro@math.psu.edu>
Cc: Linus Torvalds <torvalds@transmeta.com>,
Richard Gooch <rgooch@ras.ucalgary.ca>,
linux-kernel@vger.kernel.org
Subject: Re: Poor floppy performance in kernel 2.4.10
Date: Sun, 28 Oct 2001 21:40:05 +0100 [thread overview]
Message-ID: <200110282040.f9SKe6M02113@hitchhiker.org.lu> (raw)
In-Reply-To: Your message of "Sat, 27 Oct 2001 15:19:48 EDT." <Pine.GSO.4.21.0110271517010.21545-100000@weyl.math.psu.edu>
Appended to this mail is the "long live the struct block_device"
patch. It includes the stuff covered in the last patch as well. The
issue of stopping transfers in progress is not yet addressed.
How it works: rather than have bdput free up the struct block_device
unconditionnally as soon as the count drops to zero, forcefully
bd_forgetting any inodes that still reference it, it now checks the
list of inodes references it, and only frees it up if not referenced.
Moreover, bd_forget also calls __bdput to free up the struct
block_device when the number of referencers drops to zero later on.
Simple tests show this to make the cache workeable again, and an extra
printk in floppy_open allows to show that the struct block_device can
be freed up if needed (by creating high memory pressure).
diff -ur 2.4.13/linux/drivers/block/floppy.c linux/drivers/block/floppy.c
--- 2.4.13/linux/drivers/block/floppy.c Sat Oct 27 09:42:34 2001
+++ linux/drivers/block/floppy.c Sun Oct 28 21:21:46 2001
@@ -741,6 +741,7 @@
return UTESTF(FD_DISK_CHANGED);
if ((fd_inb(FD_DIR) ^ UDP->flags) & 0x80){
USETF(FD_VERIFY); /* verify write protection */
+ USETF(FD_DCL_SEEN); /* DCL for this drive has been seen */
if (UDRS->maxblock){
/* mark it changed */
USETF(FD_DISK_CHANGED);
@@ -3901,12 +3902,23 @@
return 0;
}
+/* determines whether we can trust media change
+ * answers true if we have seen disk change at least once, and not marked as
+ * broken */
+static int floppy_can_trust_media_change(kdev_t dev)
+{
+ int drive=DRIVE(dev);
+ return (UTESTF(FD_DCL_SEEN) &&
+ ((UDP->flags & FD_BROKEN_DCL) == 0));
+}
+
static struct block_device_operations floppy_fops = {
open: floppy_open,
release: floppy_release,
ioctl: fd_ioctl,
check_media_change: check_floppy_change,
revalidate: floppy_revalidate,
+ can_trust_media_change: floppy_can_trust_media_change
};
static void __init register_devfs_entries (int drive)
diff -ur 2.4.13/linux/fs/block_dev.c linux/fs/block_dev.c
--- 2.4.13/linux/fs/block_dev.c Sun Oct 28 09:52:53 2001
+++ linux/fs/block_dev.c Sun Oct 28 21:11:08 2001
@@ -346,19 +346,36 @@
inode->i_mapping = &inode->i_data;
}
+/**
+ * Physically delete bdev iff inode list empty AND counter zero. Must be
+ * called with bdev_lock held. bdev_lock will be released on exit.
+ * Should be called by all functions which can make either of the conditions
+ * true (decrease counter (bdput) or free inode (bdforget)
+ */
+static void __bdput(struct block_device *bdev) {
+ int shouldDrop =
+ (bdev->bd_inodes.next == &bdev->bd_inodes) &&
+ (atomic_read(&bdev->bd_count) == 0);
+ if(shouldDrop) {
+ if (bdev->bd_openers)
+ BUG();
+ list_del(&bdev->bd_hash);
+ }
+ spin_unlock(&bdev_lock);
+ if(shouldDrop) {
+ if (bdev->bd_openers)
+ BUG();
+ iput(bdev->bd_inode);
+ destroy_bdev(bdev);
+ }
+}
+
void bdput(struct block_device *bdev)
{
if (atomic_dec_and_lock(&bdev->bd_count, &bdev_lock)) {
- struct list_head *p;
if (bdev->bd_openers)
BUG();
- list_del(&bdev->bd_hash);
- while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) {
- __bd_forget(list_entry(p, struct inode, i_devices));
- }
- spin_unlock(&bdev_lock);
- iput(bdev->bd_inode);
- destroy_bdev(bdev);
+ __bdput(bdev);
}
}
@@ -390,9 +407,17 @@
void bd_forget(struct inode *inode)
{
+ struct block_device *bdev;
spin_lock(&bdev_lock);
- if (inode->i_bdev)
+ bdev = inode->i_bdev;
+ if (bdev) {
__bd_forget(inode);
+ if(inode != bdev->bd_inode) {
+ /* if not "root" inode, do the bdput */
+ __bdput(bdev);
+ return;
+ }
+ }
spin_unlock(&bdev_lock);
}
@@ -601,8 +626,12 @@
__block_fsync(bd_inode);
else if (kind == BDEV_FS)
fsync_no_super(rdev);
- if (!--bdev->bd_openers)
- kill_bdev(bdev);
+ if (!--bdev->bd_openers) {
+ if(!bdev->bd_op->can_trust_media_change ||
+ !bdev->bd_op->can_trust_media_change(rdev)) {
+ kill_bdev(bdev);
+ }
+ }
if (bdev->bd_op->release)
ret = bdev->bd_op->release(bd_inode, NULL);
if (!bdev->bd_openers)
diff -ur 2.4.13/linux/include/linux/fd.h linux/include/linux/fd.h
--- 2.4.13/linux/include/linux/fd.h Fri Aug 13 21:16:16 1999
+++ linux/include/linux/fd.h Sat Oct 27 13:37:08 2001
@@ -177,7 +177,8 @@
* to clear media change status */
FD_UNUSED_BIT,
FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */
- FD_DISK_WRITABLE_BIT /* disk is writable */
+ FD_DISK_WRITABLE_BIT, /* disk is writable */
+ FD_DCL_SEEN_BIT /* have we seen DCL? */
};
#define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params)
@@ -196,6 +197,7 @@
#define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT)
#define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT)
#define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT)
+#define FD_DCL_SEEN (1 << FD_DCL_SEEN)
unsigned long spinup_date;
unsigned long select_date;
diff -ur 2.4.13/linux/include/linux/fs.h linux/include/linux/fs.h
--- 2.4.13/linux/include/linux/fs.h Sat Oct 27 11:53:28 2001
+++ linux/include/linux/fs.h Sat Oct 27 13:05:03 2001
@@ -793,6 +793,7 @@
int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
int (*check_media_change) (kdev_t);
int (*revalidate) (kdev_t);
+ int (*can_trust_media_change) (kdev_t);
};
/*
next prev parent reply other threads:[~2001-10-28 20:40 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-27 15:00 Alain Knaff
2001-10-27 15:15 ` Alexander Viro
2001-10-27 17:12 ` Alain Knaff
2001-10-27 17:42 ` Alexander Viro
2001-10-27 18:00 ` Alain Knaff
2001-10-27 18:13 ` Alexander Viro
2001-10-27 18:26 ` Alexander Viro
2001-10-27 19:02 ` more devfs fun Alexander Viro
2001-10-27 19:16 ` Alexander Viro
2001-10-27 19:50 ` more devfs fun (Piled Higher and Deeper) Alexander Viro
2001-10-27 20:06 ` Alexander Viro
2001-10-27 21:09 ` Ryan Cumming
2001-10-27 21:22 ` Alexander Viro
2001-10-28 1:00 ` Rik van Riel
2001-10-28 8:45 ` Richard Gooch
2001-10-28 9:54 ` Alexander Viro
2001-10-28 12:27 ` Roman Zippel
2001-10-28 13:16 ` Alexander Viro
2001-10-28 22:31 ` Richard Gooch
2001-10-28 23:11 ` Alexander Viro
2001-10-27 21:01 ` Alexander Viro
2001-11-06 6:35 ` Richard Gooch
2001-11-06 7:10 ` Alexander Viro
2001-11-06 7:14 ` Richard Gooch
2001-11-06 7:17 ` Alexander Viro
2001-11-06 20:14 ` Richard Gooch
2001-10-28 10:06 ` Lorenzo Allegrucci
2001-11-06 5:21 ` Richard Gooch
2001-11-06 5:17 ` more devfs fun Richard Gooch
2001-11-06 5:06 ` Richard Gooch
2001-11-06 7:01 ` Poor floppy performance in kernel 2.4.10 Richard Gooch
2001-11-06 7:03 ` Alexander Viro
2001-12-09 5:38 ` Devfs races with block devices Richard Gooch
2001-11-06 7:19 ` Poor floppy performance in kernel 2.4.10 Richard Gooch
2001-11-06 7:22 ` Alexander Viro
2001-10-27 19:13 ` Alain Knaff
2001-10-27 19:19 ` Alexander Viro
2001-10-27 19:26 ` Alain Knaff
2001-10-28 20:40 ` Alain Knaff [this message]
2001-10-28 20:57 ` Peter T. Breuer
2001-10-29 5:38 ` Alain Knaff
2001-10-29 6:07 ` Alexander Viro
2001-10-29 6:34 ` Alain Knaff
2001-10-28 21:42 ` Alexander Viro
-- strict thread matches above, loose matches on Subject: below --
2001-10-21 11:36 Alain Knaff
2001-10-22 9:59 ` Andrea Arcangeli
2001-10-22 10:06 ` Alexander Viro
2001-10-22 14:07 ` Nick LeRoy
2001-10-22 18:28 ` bill davidsen
2001-10-19 16:58 Manfred Spraul
2001-10-17 7:36 Kamil Iskra
2001-10-17 20:45 ` Steve Kieu
2001-10-18 10:11 ` Kamil Iskra
2001-10-18 15:28 ` Andreas Dilger
2001-10-18 15:42 ` Kamil Iskra
2001-10-18 16:17 ` Ville Herva
2001-10-18 16:30 ` Nick LeRoy
2001-10-18 19:57 ` bill davidsen
2001-10-18 20:47 ` Nick LeRoy
2001-10-18 20:05 ` bill davidsen
2001-10-18 20:15 ` Alexander Viro
2001-10-18 16:18 ` Alexander Viro
2001-10-18 17:44 ` Andrea Arcangeli
2001-10-19 7:50 ` Giuliano Pochini
2001-10-19 13:46 ` Andrea Arcangeli
2001-10-19 15:57 ` Linus Torvalds
2001-10-20 4:20 ` Rob Landley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200110282040.f9SKe6M02113@hitchhiker.org.lu \
--to=alain.knaff@hitchhiker.org.lu \
--cc=alain@linux.lu \
--cc=linux-kernel@vger.kernel.org \
--cc=rgooch@ras.ucalgary.ca \
--cc=torvalds@transmeta.com \
--cc=viro@math.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®