All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: axboe@kernel.dk, linux-kernel@vger.kernel.org,
	kay.sievers@vrfy.org, hch@infradead.org
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 02/16] block: don't check events on close unless it was blocked
Date: Tue, 28 Dec 2010 18:28:58 +0100	[thread overview]
Message-ID: <1293557352-10592-3-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1293557352-10592-1-git-send-email-tj@kernel.org>

The block event mechanism currently always checks events when the
device is being closed regardless of the open mode.  The intention was
to allow detection of EJECT_REQUEST when a device is closed whether
disk event polling is enabled or not.

This is unnecessary as, for devices of interest, events are checked
from either userland or kernel and in the former case ->check_events()
is performed on open of each poll attempt anyway.  Furthermore, this
unconditional event check on close makes the code susceptible to event
loop if the block driver doesn't clear reported events correctly - an
event triggers userland to open and close the device which in turn
causes another event, rinse and repeat.

Check events on close only if it was blocked by excl write open.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Kay Sievers <kay.sievers@vrfy.org>
---
 fs/block_dev.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index c620628..58026da 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1379,13 +1379,11 @@ int blkdev_put(struct block_device *bdev, fmode_t mode)
 				disk_unblock_events(bdev->bd_disk);
 				disk_check_events(bdev->bd_disk);
 				bdev->bd_write_holder = false;
-			} else
-				disk_check_events(bdev->bd_disk);
+			}
 		}
 
 		mutex_unlock(&bdev->bd_mutex);
-	} else
-		disk_check_events(bdev->bd_disk);
+	}
 
 	return __blkdev_put(bdev, mode, 0);
 }
-- 
1.7.1


  parent reply	other threads:[~2010-12-28 17:29 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-28 17:28 [PATCHSET] block: convert block drivers to ->check_events() Tejun Heo
2010-12-28 17:28 ` [PATCH 01/16] block: don't implicitly trigger event check on disk_unblock_events() Tejun Heo
2010-12-28 17:28 ` Tejun Heo [this message]
2010-12-28 17:28 ` [PATCH 03/16] block: don't check events while open is in progress Tejun Heo
2010-12-28 17:29 ` [PATCH 04/16] ide: convert to bdops->check_events() Tejun Heo
2010-12-28 19:01   ` David Miller
2010-12-28 17:29 ` [PATCH 05/16] floppy,{ami|ata}flop: " Tejun Heo
2011-01-25 13:07   ` [PATCH UPDATED " Tejun Heo
2010-12-28 17:29 ` [PATCH 06/16] gdrom,viocd: " Tejun Heo
2010-12-28 17:29 ` [PATCH 07/16] paride: " Tejun Heo
2010-12-28 17:29 ` [PATCH 08/16] dac960: " Tejun Heo
2010-12-28 17:29 ` [PATCH 09/16] swim[3]: " Tejun Heo
2010-12-28 17:29 ` [PATCH 10/16] ub: " Tejun Heo
2010-12-29 15:53   ` Pete Zaitcev
2010-12-29 16:02     ` Tejun Heo
2010-12-28 17:29 ` [PATCH 11/16] xsysace: " Tejun Heo
2010-12-29  6:37   ` Grant Likely
2010-12-28 17:29 ` [PATCH 12/16] i2o_block: " Tejun Heo
2010-12-28 17:29 ` [PATCH 13/16] s390/tape_block: " Tejun Heo
2010-12-28 17:29 ` [PATCH 14/16] umem: drop dummy ->media_changed() Tejun Heo
2010-12-28 17:29 ` [PATCH 15/16] pktcdvd: convert to bdops->check_events() Tejun Heo
2010-12-28 17:29 ` [PATCH 16/16] staging: " Tejun Heo
2010-12-28 18:39   ` Greg KH
2010-12-28 20:04 ` [PATCHSET] block: convert block drivers to ->check_events() Jeff Garzik
2011-01-25 13:06 ` Tejun Heo
2011-02-01 10:31   ` Tejun Heo
2011-03-05 10:40     ` Tejun Heo
2011-03-07  8:08       ` Jens Axboe
2011-03-09  9:13 [PATCHSET] block: Convert block drivers to ->check_events(), take#2 Tejun Heo
2011-03-09  9:13 ` [PATCH 02/16] block: Don't check events on close unless it was blocked Tejun Heo

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=1293557352-10592-3-git-send-email-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=hch@infradead.org \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.