From patchwork Tue Dec 12 01:10:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Gilbert X-Patchwork-Id: 10106085 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 6BBBE602B3 for ; Tue, 12 Dec 2017 01:10:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AE492873C for ; Tue, 12 Dec 2017 01:10:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DF81287AF; Tue, 12 Dec 2017 01:10:17 +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=-6.9 required=2.0 tests=BAYES_00,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 EFCB72873C for ; Tue, 12 Dec 2017 01:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751625AbdLLBKO (ORCPT ); Mon, 11 Dec 2017 20:10:14 -0500 Received: from smtp.infotech.no ([82.134.31.41]:59804 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751379AbdLLBKM (ORCPT ); Mon, 11 Dec 2017 20:10:12 -0500 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id BAA8C20419D; Tue, 12 Dec 2017 02:10:10 +0100 (CET) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5kCIvu7i+GhB; Tue, 12 Dec 2017 02:10:10 +0100 (CET) Received: from xtwo70.bingwo.ca (host-104-157-148-187.dyn.295.ca [104.157.148.187]) by smtp.infotech.no (Postfix) with ESMTPA id C55732040A4; Tue, 12 Dec 2017 02:10:09 +0100 (CET) From: Douglas Gilbert To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, bart.vanassche@sandisk.com, hare@suse.de Subject: [PATCH 3/4] scsi_debug: expand do_device_access to take sg offset Date: Mon, 11 Dec 2017 20:10:07 -0500 Message-Id: <20171212011008.27689-4-dgilbert@interlog.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171212011008.27689-1-dgilbert@interlog.com> References: <20171212011008.27689-1-dgilbert@interlog.com> 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 WRITE SCATTERED needs to take several "bites" out of the data-out buffer. Expand the do_device_access() function to take a sg_skip argument. Signed-off-by: Douglas Gilbert Reviewed-by: Bart Van Assche --- drivers/scsi/scsi_debug.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 05661387ccaf..707c24155fd0 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2412,8 +2412,8 @@ static int check_device_access_params(struct scsi_cmnd *scp, } /* Returns number of bytes copied or -1 if error. */ -static int do_device_access(struct scsi_cmnd *scmd, u64 lba, u32 num, - bool do_write) +static int do_device_access(struct scsi_cmnd *scmd, u32 sg_skip, u64 lba, + u32 num, bool do_write) { int ret; u64 block, rest = 0; @@ -2439,14 +2439,15 @@ static int do_device_access(struct scsi_cmnd *scmd, u64 lba, u32 num, ret = sg_copy_buffer(sdb->table.sgl, sdb->table.nents, fake_storep + (block * sdebug_sector_size), - (num - rest) * sdebug_sector_size, 0, do_write); + (num - rest) * sdebug_sector_size, sg_skip, do_write); if (ret != (num - rest) * sdebug_sector_size) return ret; if (rest) { ret += sg_copy_buffer(sdb->table.sgl, sdb->table.nents, fake_storep, rest * sdebug_sector_size, - (num - rest) * sdebug_sector_size, do_write); + sg_skip + ((num - rest) * sdebug_sector_size), + do_write); } return ret; @@ -2707,7 +2708,7 @@ static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) } } - ret = do_device_access(scp, lba, num, false); + ret = do_device_access(scp, 0, lba, num, false); read_unlock_irqrestore(&atomic_rw, iflags); if (unlikely(ret == -1)) return DID_ERROR << 16; @@ -2995,7 +2996,7 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) } } - ret = do_device_access(scp, lba, num, true); + ret = do_device_access(scp, 0, lba, num, true); if (unlikely(scsi_debug_lbp())) map_region(lba, num); write_unlock_irqrestore(&atomic_rw, iflags); @@ -3236,7 +3237,7 @@ static int resp_comp_write(struct scsi_cmnd *scp, * from data-in into arr. Safe (atomic) since write_lock held. */ fake_storep_hold = fake_storep; fake_storep = arr; - ret = do_device_access(scp, 0, dnum, true); + ret = do_device_access(scp, 0, 0, dnum, true); fake_storep = fake_storep_hold; if (ret == -1) { retval = DID_ERROR << 16;