linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Martin Wilck <mwilck@suse.com>, Jens Axboe <axboe@kernel.dk>,
	Tejun Heo <tj@kernel.org>
Cc: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org,
	linux-ide@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	James Bottomley <jejb@linux.vnet.ibm.com>,
	Bart Van Assche <Bart.VanAssche@sandisk.com>,
	Borislav Petkov <bp@alien8.de>
Subject: Re: [PATCH 2/4] Revert "ide: unexport DISK_EVENT_MEDIA_CHANGE for ide-gd and ide-cd"
Date: Sat, 26 Jan 2019 11:10:46 +0100	[thread overview]
Message-ID: <7645c87f-0f56-5f31-ca9f-16b41d56c48e@suse.de> (raw)
In-Reply-To: <20190118213207.2309-3-mwilck@suse.com>

On 1/18/19 10:32 PM, Martin Wilck wrote:
> This reverts commit 7eec77a1816a7042591a6cbdb4820e9e7ebffe0e.
> 
> Instead of leaving disk->events completely empty, we now export the supported
> events again, and tell the block layer not to forward events to user space by
> not setting DISK_EVENT_FLAG_UEVENT. This allows the block layer to distinguish
> between devices that for which events should be handled in kernel only, and
> devices which don't support any meda change events at all.
> 
> Cc: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>   drivers/ide/ide-cd.c       | 1 +
>   drivers/ide/ide-cd_ioctl.c | 5 +++--
>   drivers/ide/ide-gd.c       | 6 ++++--
>   3 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
> index 1f03884..3b15adc 100644
> --- a/drivers/ide/ide-cd.c
> +++ b/drivers/ide/ide-cd.c
> @@ -1797,6 +1797,7 @@ static int ide_cd_probe(ide_drive_t *drive)
>   	ide_cd_read_toc(drive);
>   	g->fops = &idecd_ops;
>   	g->flags |= GENHD_FL_REMOVABLE | GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE;
> +	g->events = DISK_EVENT_MEDIA_CHANGE;
>   	device_add_disk(&drive->gendev, g, NULL);
>   	return 0;
>   
> diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
> index 4a6e1a4..f9f4bac 100644
> --- a/drivers/ide/ide-cd_ioctl.c
> +++ b/drivers/ide/ide-cd_ioctl.c
> @@ -82,8 +82,9 @@ int ide_cdrom_drive_status(struct cdrom_device_info *cdi, int slot_nr)
>   
>   /*
>    * ide-cd always generates media changed event if media is missing, which
> - * makes it impossible to use for proper event reporting, so disk->events
> - * is cleared to 0 and the following function is used only to trigger
> + * makes it impossible to use for proper event reporting, so
> + * DISK_EVENT_FLAG_UEVENT is cleared in disk->events
> + * and the following function is used only to trigger
>    * revalidation and never propagated to userland.
>    */
>   unsigned int ide_cdrom_check_events_real(struct cdrom_device_info *cdi,
> diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
> index 04e008e..cab8052 100644
> --- a/drivers/ide/ide-gd.c
> +++ b/drivers/ide/ide-gd.c
> @@ -299,8 +299,9 @@ static unsigned int ide_gd_check_events(struct gendisk *disk,
>   	/*
>   	 * The following is used to force revalidation on the first open on
>   	 * removeable devices, and never gets reported to userland as
> -	 * genhd->events is 0.  This is intended as removeable ide disk
> -	 * can't really detect MEDIA_CHANGE events.
> +	 * DISK_EVENT_FLAG_UEVENT isn't set in genhd->events.
> +	 * This is intended as removeable ide disk can't really detect
> +	 * MEDIA_CHANGE events.
>   	 */
>   	ret = drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED;
>   	drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
> @@ -417,6 +418,7 @@ static int ide_gd_probe(ide_drive_t *drive)
>   		g->flags = GENHD_FL_REMOVABLE;
>   	g->fops = &ide_gd_ops;
>   	device_add_disk(&drive->gendev, g, NULL);
> +	g->events = DISK_EVENT_MEDIA_CHANGE;
>   	return 0;
>   
>   out_free_disk:
> 
Please set the events mask prior to call device_add_disk(), otherwise 
we'll have a race condition here.

Cheers,

Hannes

  reply	other threads:[~2019-01-26 10:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-18 21:32 [PATCH 0/4] block: skip media change event handling if unsupported Martin Wilck
2019-01-18 21:32 ` [PATCH 1/4] block: disk_events: introduce event flags Martin Wilck
2019-01-26 10:09   ` Hannes Reinecke
2019-01-28 13:54     ` Martin Wilck
2019-02-01 15:12       ` Martin Wilck
2019-01-18 21:32 ` [PATCH 2/4] Revert "ide: unexport DISK_EVENT_MEDIA_CHANGE for ide-gd and ide-cd" Martin Wilck
2019-01-26 10:10   ` Hannes Reinecke [this message]
2019-01-18 21:32 ` [PATCH 3/4] Revert "block: unexport DISK_EVENT_MEDIA_CHANGE for legacy/fringe drivers" Martin Wilck
2019-01-26 10:11   ` Hannes Reinecke
2019-01-18 21:32 ` [PATCH 4/4] block: check_events: don't bother with events if unsupported Martin Wilck
2019-01-26 10:15   ` Hannes Reinecke

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=7645c87f-0f56-5f31-ca9f-16b41d56c48e@suse.de \
    --to=hare@suse.de \
    --cc=Bart.VanAssche@sandisk.com \
    --cc=axboe@kernel.dk \
    --cc=bp@alien8.de \
    --cc=hch@lst.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mwilck@suse.com \
    --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;
as well as URLs for NNTP newsgroup(s).