From patchwork Wed Jun 1 21:48:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 9148291 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 79FD260751 for ; Wed, 1 Jun 2016 21:49:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CD2A264FB for ; Wed, 1 Jun 2016 21:49:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 617CB2714B; Wed, 1 Jun 2016 21:49:56 +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=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, URIBL_BLACK 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 D59D2264FB for ; Wed, 1 Jun 2016 21:49:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753087AbcFAVty (ORCPT ); Wed, 1 Jun 2016 17:49:54 -0400 Received: from mail.linux-iscsi.org ([67.23.28.174]:53532 "EHLO linux-iscsi.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751833AbcFAVtu (ORCPT ); Wed, 1 Jun 2016 17:49:50 -0400 Received: from linux-iscsi.org (localhost [127.0.0.1]) by linux-iscsi.org (Postfix) with ESMTP id C1C2722D9D7; Wed, 1 Jun 2016 21:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=linux-iscsi.org; s=default.private; t=1464817749; bh=xii4krp8GUel8RLCXKFw2Mm1PSiHGXM cGF0sPqYmyu8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References; b=mfX8z3rrxwXcZkkXQ6SLfJqwPmREQekvPhXxGGjwXqmFUwHsh80k EVc3TZ+TEVg33RTmC7tq6zZno5HARpPvUnyhUFvhI1CLZvgBf3O0jNuxi321JUeT5xr wTUn+xo3BHhBZjkDINGKsu3tG5iv4GlLN6g/SzKtRI3exZc+vhKM= From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , Jens Axboe , Christoph Hellwig , Martin Petersen , Sagi Grimberg , Hannes Reinecke , Mike Christie , Dave B Minturn , Nicholas Bellinger Subject: [PATCH 10/14] target/iblock: Fold iblock_req into target_iostate Date: Wed, 1 Jun 2016 21:48:43 +0000 Message-Id: <1464817727-9125-11-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1464817727-9125-1-git-send-email-nab@linux-iscsi.org> References: <1464817727-9125-1-git-send-email-nab@linux-iscsi.org> 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 From: Nicholas Bellinger This patch folks the two existing iblock_req members into target_iostate, and updates associated sbc_ops iblock_execute_rw() iblock_execute_write_same() callbacks. Also, go ahead and drop target_iostate->priv now that it's unused. Cc: Jens Axboe Cc: Christoph Hellwig Cc: Martin Petersen Cc: Sagi Grimberg Cc: Hannes Reinecke Cc: Mike Christie Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_iblock.c | 40 ++++++++++--------------------------- drivers/target/target_core_iblock.h | 5 ----- include/target/target_core_base.h | 5 ++++- 3 files changed, 14 insertions(+), 36 deletions(-) diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 8e90ec42..daf052d 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -277,34 +277,30 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( static void iblock_complete_cmd(struct target_iostate *ios) { - struct iblock_req *ibr = ios->priv; u8 status; - if (!atomic_dec_and_test(&ibr->pending)) + if (!atomic_dec_and_test(&ios->backend_pending)) return; - if (atomic_read(&ibr->ib_bio_err_cnt)) + if (atomic_read(&ios->backend_err_cnt)) status = SAM_STAT_CHECK_CONDITION; else status = SAM_STAT_GOOD; // XXX: ios status SAM completion translation ios->t_comp_func(ios, status); - - kfree(ibr); } static void iblock_bio_done(struct bio *bio) { struct target_iostate *ios = bio->bi_private; - struct iblock_req *ibr = ios->priv; if (bio->bi_error) { pr_err("bio error: %p, err: %d\n", bio, bio->bi_error); /* * Bump the ib_bio_err_cnt and release bio. */ - atomic_inc(&ibr->ib_bio_err_cnt); + atomic_inc(&ios->backend_err_cnt); smp_mb__after_atomic(); } @@ -453,7 +449,6 @@ iblock_execute_write_same(struct se_cmd *cmd) { struct target_iostate *ios = &cmd->t_iostate; struct block_device *bdev = IBLOCK_DEV(cmd->se_dev)->ibd_bd; - struct iblock_req *ibr; struct scatterlist *sg; struct bio *bio; struct bio_list list; @@ -480,19 +475,14 @@ iblock_execute_write_same(struct se_cmd *cmd) if (bdev_write_same(bdev)) return iblock_execute_write_same_direct(bdev, cmd); - ibr = kzalloc(sizeof(struct iblock_req), GFP_KERNEL); - if (!ibr) - goto fail; - ios->priv = ibr; - bio = iblock_get_bio(ios, block_lba, 1); if (!bio) - goto fail_free_ibr; + goto fail; bio_list_init(&list); bio_list_add(&list, bio); - atomic_set(&ibr->pending, 1); + atomic_set(&ios->backend_pending, 1); while (sectors) { while (bio_add_page(bio, sg_page(sg), sg->length, sg->offset) @@ -502,7 +492,7 @@ iblock_execute_write_same(struct se_cmd *cmd) if (!bio) goto fail_put_bios; - atomic_inc(&ibr->pending); + atomic_inc(&ios->backend_pending); bio_list_add(&list, bio); } @@ -517,8 +507,6 @@ iblock_execute_write_same(struct se_cmd *cmd) fail_put_bios: while ((bio = bio_list_pop(&list))) bio_put(bio); -fail_free_ibr: - kfree(ibr); fail: return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; } @@ -680,7 +668,6 @@ iblock_execute_rw(struct target_iostate *ios, struct scatterlist *sgl, u32 sgl_n { struct se_device *dev = ios->se_dev; sector_t block_lba = target_to_linux_sector(dev, ios->t_task_lba); - struct iblock_req *ibr; struct bio *bio, *bio_start; struct bio_list list; struct scatterlist *sg; @@ -710,26 +697,21 @@ iblock_execute_rw(struct target_iostate *ios, struct scatterlist *sgl, u32 sgl_n rw = READ; } - ibr = kzalloc(sizeof(struct iblock_req), GFP_KERNEL); - if (!ibr) - goto fail; - ios->priv = ibr; - if (!sgl_nents) { - atomic_set(&ibr->pending, 1); + atomic_set(&ios->backend_pending, 1); iblock_complete_cmd(ios); return 0; } bio = iblock_get_bio(ios, block_lba, sgl_nents); if (!bio) - goto fail_free_ibr; + goto fail; bio_start = bio; bio_list_init(&list); bio_list_add(&list, bio); - atomic_set(&ibr->pending, 2); + atomic_set(&ios->backend_pending, 2); bio_cnt = 1; for_each_sg(sgl, sg, sgl_nents, i) { @@ -749,7 +731,7 @@ iblock_execute_rw(struct target_iostate *ios, struct scatterlist *sgl, u32 sgl_n if (!bio) goto fail_put_bios; - atomic_inc(&ibr->pending); + atomic_inc(&ios->backend_pending); bio_list_add(&list, bio); bio_cnt++; } @@ -772,8 +754,6 @@ iblock_execute_rw(struct target_iostate *ios, struct scatterlist *sgl, u32 sgl_n fail_put_bios: while ((bio = bio_list_pop(&list))) bio_put(bio); -fail_free_ibr: - kfree(ibr); fail: return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; } diff --git a/drivers/target/target_core_iblock.h b/drivers/target/target_core_iblock.h index 01c2afd..ef7f91c 100644 --- a/drivers/target/target_core_iblock.h +++ b/drivers/target/target_core_iblock.h @@ -6,11 +6,6 @@ #define IBLOCK_MAX_CDBS 16 #define IBLOCK_LBA_SHIFT 9 -struct iblock_req { - atomic_t pending; - atomic_t ib_bio_err_cnt; -} ____cacheline_aligned; - #define IBDF_HAS_UDEV_PATH 0x01 struct iblock_dev { diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 9bd7559..60a180f 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -469,7 +469,10 @@ struct target_iostate { struct target_iomem *iomem; struct se_device *se_dev; void (*t_comp_func)(struct target_iostate *, u16); - void *priv; + + /* Used by IBLOCK for BIO submission + completion */ + atomic_t backend_pending; + atomic_t backend_err_cnt; }; struct se_cmd {