From: Maxim Levitsky <maximlevitsky@gmail.com>
To: Kay Sievers <kay.sievers@vrfy.org>
Cc: Tejun Heo <tj@kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Jens Axboe <axboe@kernel.dk>
Subject: Re: [REGRESSION] cdrom drive doesn't detect removal
Date: Wed, 15 Sep 2010 01:38:35 +0200 [thread overview]
Message-ID: <1284507516.4963.2.camel@maxim-laptop> (raw)
In-Reply-To: <AANLkTinGHB9fbLw1Cm5wvPLGy8QEuoBBmFiqpnvXiZ8R@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1654 bytes --]
On Tue, 2010-09-14 at 10:07 +0200, Kay Sievers wrote:
> On Tue, Sep 14, 2010 at 09:39, Tejun Heo <tj@kernel.org> wrote:
> > On 09/14/2010 03:27 AM, Maxim Levitsky wrote:
> >>> However 2.6.36 doesn't detect that removal.
> >>> According to udevadm monitor --property no uevents are send on removal.
> >> Correction, this is regression between 2.6.34 and 2.6.35. This shows how
> >> much I use cd these days...
> >>
> >> I bisected it down to this:
> >>
> >> 6b4517a7913a09d3259bb1d21c9cb300f12294bd is the first bad commit
> >> commit 6b4517a7913a09d3259bb1d21c9cb300f12294bd
> >> Author: Tejun Heo <tj@kernel.org>
> >> Date: Wed Apr 7 18:53:59 2010 +0900
> >>
> >> block: implement bd_claiming and claiming block
> >
> > Hmmm... weird. This commit does change the open behavior but
> > shouldn't change the end result. Can someone please enlighten me how
> > udevadm is interacting with the device at system call level?
>
> Not at all. Udev does not really touch it.
>
> The cdrom drive isn't unlocked on usual systems, udisks polls the
> cdrom drive periodically just like HAL did. The only difference is
> that with the polling, the sr driver detects a media change and sends
> a uevent to udev, instead of HAL looking at the result of the open().
>
> Are we sure, that there is something that still polls the drive?
> Udisks is only auto-started, when the desktop calls into some D-Bus
> methods, unlike HAL where it was an init script.
Note that on current vanilla head, I applied the attached manual revert
patch, and problem disappears (and probably introduces the same bug that
patch supposed to fix).
Best regards,
Maxim Levitsky
[-- Attachment #2: test.patch --]
[-- Type: text/x-patch, Size: 2661 bytes --]
commit 6256435b81d05c98be64fbeea57776520961a10c
Author: Maxim Levitsky <maximlevitsky@gmail.com>
Date: Tue Sep 14 23:47:14 2010 +0200
block_dev: revert cdrom breakage
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 50e8c85..f1095f3 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -839,14 +839,15 @@ static void bd_finish_claiming(struct block_device *bdev,
int bd_claim(struct block_device *bdev, void *holder)
{
struct block_device *whole = bdev->bd_contains;
- int res;
+ int res = -EBUSY;
might_sleep();
spin_lock(&bdev_lock);
- res = bd_prepare_to_claim(bdev, whole, holder);
- if (res == 0)
+ if (bd_may_claim(bdev, whole, holder)) {
+ res = 0;
__bd_claim(bdev, whole, holder);
+ }
spin_unlock(&bdev_lock);
return res;
@@ -1462,7 +1463,6 @@ EXPORT_SYMBOL(blkdev_get);
static int blkdev_open(struct inode * inode, struct file * filp)
{
- struct block_device *whole = NULL;
struct block_device *bdev;
int res;
@@ -1485,24 +1485,24 @@ static int blkdev_open(struct inode * inode, struct file * filp)
if (bdev == NULL)
return -ENOMEM;
+ filp->f_mapping = bdev->bd_inode->i_mapping;
+
+ res = blkdev_get(bdev, filp->f_mode);
+ if (res)
+ return res;
+
if (filp->f_mode & FMODE_EXCL) {
- whole = bd_start_claiming(bdev, filp);
- if (IS_ERR(whole)) {
- bdput(bdev);
- return PTR_ERR(whole);
- }
+ res = bd_claim(bdev, filp);
+ if (res)
+ goto out_blkdev_put;
}
- filp->f_mapping = bdev->bd_inode->i_mapping;
+ return 0;
- res = blkdev_get(bdev, filp->f_mode);
+ out_blkdev_put:
+ blkdev_put(bdev, filp->f_mode);
+ return res;
- if (whole) {
- if (res == 0)
- bd_finish_claiming(bdev, whole, filp);
- else
- bd_abort_claiming(whole, filp);
- }
return res;
}
@@ -1712,34 +1712,30 @@ EXPORT_SYMBOL(lookup_bdev);
*/
struct block_device *open_bdev_exclusive(const char *path, fmode_t mode, void *holder)
{
- struct block_device *bdev, *whole;
- int error;
+ struct block_device *bdev;
+ int error = 0;
bdev = lookup_bdev(path);
if (IS_ERR(bdev))
return bdev;
- whole = bd_start_claiming(bdev, holder);
- if (IS_ERR(whole)) {
- bdput(bdev);
- return whole;
- }
-
error = blkdev_get(bdev, mode);
if (error)
- goto out_abort_claiming;
+ return ERR_PTR(error);
error = -EACCES;
if ((mode & FMODE_WRITE) && bdev_read_only(bdev))
goto out_blkdev_put;
+ error = bd_claim(bdev, holder);
+ if (error)
+ goto blkdev_put;
+
bd_finish_claiming(bdev, whole, holder);
return bdev;
out_blkdev_put:
blkdev_put(bdev, mode);
-out_abort_claiming:
- bd_abort_claiming(whole, holder);
return ERR_PTR(error);
}
next prev parent reply other threads:[~2010-09-14 23:38 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-12 9:49 Maxim Levitsky
2010-09-14 1:27 ` Maxim Levitsky
2010-09-14 7:39 ` Tejun Heo
2010-09-14 8:07 ` Kay Sievers
2010-09-14 23:38 ` Maxim Levitsky [this message]
2010-09-14 23:49 ` Kay Sievers
2010-09-15 0:37 ` Maxim Levitsky
2010-09-15 1:01 ` Kay Sievers
2010-09-15 13:27 ` Henrique de Moraes Holschuh
2010-09-15 13:44 ` Kay Sievers
2010-09-15 22:20 ` Maxim Levitsky
2010-09-16 6:51 ` Kay Sievers
2010-09-21 11:42 ` Maxim Levitsky
2010-09-21 23:09 ` Maxim Levitsky
2010-09-22 7:38 ` Tejun Heo
2010-09-22 13:41 ` Maxim Levitsky
2010-09-22 13:58 ` Maxim Levitsky
2010-09-23 8:47 ` Tejun Heo
2010-09-23 9:21 ` Kay Sievers
2010-09-30 6:30 ` Florian Mickler
2010-09-30 7:48 ` Kay Sievers
2010-09-30 11:38 ` Florian Mickler
2010-09-30 14:17 ` Maxim Levitsky
2010-09-30 14:49 ` Florian Mickler
2010-09-30 19:27 ` Kay Sievers
2010-09-30 20:14 ` Florian Mickler
2010-09-30 20:32 ` Kay Sievers
2010-09-30 20:47 ` Florian Mickler
2010-09-30 20:57 ` Kay Sievers
2010-10-01 5:55 ` Tejun Heo
2010-10-01 7:54 ` Florian Mickler
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=1284507516.4963.2.camel@maxim-laptop \
--to=maximlevitsky@gmail.com \
--cc=axboe@kernel.dk \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/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
Powered by JetHome