From patchwork Tue Nov 26 19:54:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Suchanek X-Patchwork-Id: 11262971 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9B3014ED for ; Tue, 26 Nov 2019 19:54:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9624F20684 for ; Tue, 26 Nov 2019 19:54:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726101AbfKZTyk (ORCPT ); Tue, 26 Nov 2019 14:54:40 -0500 Received: from mx2.suse.de ([195.135.220.15]:40116 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725970AbfKZTyk (ORCPT ); Tue, 26 Nov 2019 14:54:40 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CB75BAD26; Tue, 26 Nov 2019 19:54:37 +0000 (UTC) From: Michal Suchanek To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org Cc: Michal Suchanek , Jonathan Corbet , Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" , Alexander Viro , Eric Biggers , "J. Bruce Fields" , Mauro Carvalho Chehab , Benjamin Coddington , Ming Lei , Chaitanya Kulkarni , Bart Van Assche , Damien Le Moal , Hou Tao , Pavel Begunkov , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jan Kara , Hannes Reinecke , "Ewan D. Milne" , Christoph Hellwig , Matthew Wilcox Subject: [PATCH v4 rebase 00/10] Fix cdrom autoclose Date: Tue, 26 Nov 2019 20:54:19 +0100 Message-Id: X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Hello, there is cdrom autoclose feature that is supposed to close the tray, wait for the disc to become ready, and then open the device. This used to work in ancient times. Then in old times there was a hack in util-linux which worked around the breakage which probably resulted from switching to scsi emulation. Currently util-linux maintainer refuses to merge another hack on the basis that kernel still has the feature so it should be fixed there. The code needs not be replicated in every userspace utility like mount or dd which has no business knowing which devices are CD-roms and where the autoclose setting is in the kernel. This is rebase on top of current master. Also it seems that most people think that this is fix for WMware because there is one patch dealing with WMware. This is fix for Linux. Expected (ca Linux 2.4): eject < put CD on tray > mount /dev/cdrom ... < cdrom now mounted > Actual: mount: /mnt: no medium found on /dev/sr0. Thanks Michal v3: - change the VMware workaround to use blacklist flag - use exported function instead of ioctl v4: - fix crash reported by kernel test robot - fix the debug message logic while refactoring cdrom_open - move repeated code out of __blkdev_get Link: https://lore.kernel.org/lkml/cover.1571834862.git.msuchanek@suse.de/ Link: https://lore.kernel.org/lkml/cover.1513263482.git.msuchanek@suse.de/ Michal Suchanek (10): cdrom: add poll_event_interruptible cdrom: factor out common open_for_* code cdrom: wait for the tray to close cdrom: export autoclose logic as a separate function cdrom: unify log messages. bdev: reset first_open when looping in __blkget_dev bdev: separate parts of __blkdev_get as helper functions bdev: add open_finish scsi: blacklist: add VMware ESXi cdrom - broken tray emulation scsi: sr: wait for the medium to become ready Documentation/filesystems/locking.rst | 2 + drivers/cdrom/cdrom.c | 471 +++++++++++++------------- drivers/scsi/scsi_devinfo.c | 15 +- drivers/scsi/sr.c | 60 +++- fs/block_dev.c | 72 ++-- include/linux/blkdev.h | 1 + include/linux/cdrom.h | 1 + include/scsi/scsi_devinfo.h | 7 +- 8 files changed, 357 insertions(+), 272 deletions(-)