From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F12D0CA9EAF for ; Thu, 24 Oct 2019 13:14:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C222A2166E for ; Thu, 24 Oct 2019 13:14:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="bttpX+0d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502445AbfJXNOd (ORCPT ); Thu, 24 Oct 2019 09:14:33 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45002 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502438AbfJXNOd (ORCPT ); Thu, 24 Oct 2019 09:14:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5OQ8vAisIbi6t1AXhKrSUhlAbShVLTGo3AmrlvGo4g8=; b=bttpX+0dBXHANg2mLC9oB4tpyx ywkxut3xv8ozM+p6k5jyo9RdB1sdB+EIShDvXsI2sI1+/CI+YA9mWOc13DQqy7cQjT+tcoVDwdNLk KQgoCbH+V1z8tl5gbX7CePfEaNeMOdHSz5DPYQch04H8rT0peQWfrYldDOl+CmfnomN+QpF8ZXqMx 5Y/16WXEigN/ArdT1iIvbmna3+CFyicCDazBIV2ITlx3qfWA1NwBH0TELBH+ldPcgJfMRMC4Y9OUJ lZC71LVNSAVjO1tQv+2/8Tj2H3DiNpqh/PXxPMp9Cs6YlbFevPsoUB4jAliaCsy2HirXVTSAffSy3 faL8XUdw==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iNcwi-0005Jb-L3; Thu, 24 Oct 2019 13:14:32 +0000 Date: Thu, 24 Oct 2019 06:14:32 -0700 From: Matthew Wilcox To: Michal =?iso-8859-1?Q?Such=E1nek?= Cc: Christoph Hellwig , linux-scsi@vger.kernel.org, Jonathan Corbet , Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" , Alexander Viro , Mauro Carvalho Chehab , Eric Biggers , "J. Bruce Fields" , Benjamin Coddington , Hannes Reinecke , Omar Sandoval , Ming Lei , Damien Le Moal , Bart Van Assche , Tejun Heo , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2 8/8] scsi: sr: wait for the medium to become ready Message-ID: <20191024131432.GF2963@bombadil.infradead.org> References: <94dc98dc67b1d183d04c338c7978efa0556db6ac.1571834862.git.msuchanek@suse.de> <20191024022406.GD11485@infradead.org> <20191024085136.GG938@kitsune.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191024085136.GG938@kitsune.suse.cz> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Thu, Oct 24, 2019 at 10:51:36AM +0200, Michal Suchánek wrote: > On Wed, Oct 23, 2019 at 07:24:06PM -0700, Christoph Hellwig wrote: > > On Wed, Oct 23, 2019 at 02:52:47PM +0200, Michal Suchanek wrote: > > > +static int sr_block_open_finish(struct block_device *bdev, fmode_t mode, > > > + int ret) > > > +{ > > > + struct scsi_cd *cd = scsi_cd(bdev->bd_disk); > > > + > > > + /* wait for drive to get ready */ > > > + if ((ret == -ENOMEDIUM) && !(mode & FMODE_NDELAY)) { > > > + struct scsi_device *sdev = cd->device; > > > + /* > > > + * Cannot use sr_block_ioctl because it locks sr_mutex blocking > > > + * out any processes trying to access the drive > > > + */ > > > + scsi_autopm_get_device(sdev); > > > + cdrom_ioctl(&cd->cdi, bdev, mode, CDROM_AUTOCLOSE, 0); > > > + ret = __sr_block_open(bdev, mode); > > > + scsi_autopm_put_device(sdev); > > > > Ioctls should never be used from kernel space. We have a few leftovers, > > but we need to get rid of that and not add more. > > What is the alternative? Call the function that would be called by the ioctl instead.