From patchwork Tue May 22 09:15:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maurizio Lombardi X-Patchwork-Id: 10417671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 035D96016C for ; Tue, 22 May 2018 09:15:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E940828B64 for ; Tue, 22 May 2018 09:15:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDBA428B82; Tue, 22 May 2018 09:15:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A00E28B64 for ; Tue, 22 May 2018 09:15:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751268AbeEVJPo (ORCPT ); Tue, 22 May 2018 05:15:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51324 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751173AbeEVJPn (ORCPT ); Tue, 22 May 2018 05:15:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 177A4C12D9; Tue, 22 May 2018 09:15:43 +0000 (UTC) Received: from manaslu.redhat.com (unknown [10.33.36.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8680621568B2; Tue, 22 May 2018 09:15:41 +0000 (UTC) From: Maurizio Lombardi To: axboe@kernel.dk Cc: linux-scsi@vger.kernel.org, bart.vanassche@wdc.com Subject: [PATCH] sr: mark device as changed when performing a write SG_IO operation Date: Tue, 22 May 2018 11:15:38 +0200 Message-Id: <1526980538-18707-2-git-send-email-mlombard@redhat.com> In-Reply-To: <1526980538-18707-1-git-send-email-mlombard@redhat.com> References: <1526980538-18707-1-git-send-email-mlombard@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 22 May 2018 09:15:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 22 May 2018 09:15:43 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mlombard@redhat.com' RCPT:'' Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Maurizio Lombardi --- drivers/scsi/sr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 3f3cb72..e64311d 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -553,6 +554,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, struct scsi_cd *cd = scsi_cd(bdev->bd_disk); struct scsi_device *sdev = cd->device; void __user *argp = (void __user *)arg; + struct sg_io_hdr hdr; int ret; mutex_lock(&sr_mutex); @@ -571,6 +573,12 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, case SCSI_IOCTL_GET_BUS_NUMBER: ret = scsi_ioctl(sdev, cmd, argp); goto out; + case SG_IO: + if (copy_from_user(&hdr, argp, sizeof(hdr))) + break; + if (hdr.dxfer_direction == SG_DXFER_TO_DEV) + sdev->changed = 1; + break; } ret = cdrom_ioctl(&cd->cdi, bdev, mode, cmd, arg);