From patchwork Wed Apr 6 06:04:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12802571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aib29ajc253.phx1.oracleemaildelivery.com (aib29ajc253.phx1.oracleemaildelivery.com [192.29.103.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8944FC433FE for ; Wed, 6 Apr 2022 06:05:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=H6T+56U8EjHl5AB84EEhnJnwq6fLo9k4Zko1mwZPgkc=; b=1Hi3baRHZnRB2JGJMuYrlm1zW4VcYfdINW2SmWBOibQpcD0CZPr1q+LZdIULZjCm27zFfKuPr5Mo fHbw0LwsoemMG+bD1MHqhXbvxhRfzMjEQ6eS326oXqwUXv3coWhAtfkxCuds0QxpKFz0D7c383ND NarvG2cyrfwP7JW9U/yntM9jJbDkBrI5j3GxRn6j35YhG9G8Bk7RyHQ2rBtpD1vNT3QdeXaAyVJG Rh1F/E3VMg3syCO58WtPKY61maOh3Ti25DT1pNNZz+Hg6inUYm+ehiRmi9BjlJi66hAR8e+eoP6d HU70yrJD38m+s1kPubaWxzxqgA6w7Pf8uSL/lA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=H6T+56U8EjHl5AB84EEhnJnwq6fLo9k4Zko1mwZPgkc=; b=gKC7b4jH6TeTytbKzhB22yFtwKbDcpLAw7x4MslARLSNl2dVxPgTDqFofiRqaYCTCN2NLJKyZPTQ 161RgF6QSOoDIcDp3tKrF3WN9iJfFjLAgnbUaVUTBtZm+yA7BXqFCf+b/rcUvF13KkvOSdvfCWHs EQdqG6b+w9uhE64Bfhvb6+v2Ot01ZkxJiUpZ4YleaVc5E/kf6Op2GT2Zb8PI40tgVCtVcI2bCrBP ywDJYf0eUH6fbqKZwVeju0OZDEYV+2k7MEesNQdRU0Ejb0rskamuqiDGAbROYDuxm3brmKlD08l3 r3c/2Jfc3DhX2YAZ0DTnn7KfVnwo8jhFsug3rg== Received: by omta-ad3-fd1-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220319 64bit (built Mar 19 2022)) with ESMTPS id <0R9W003ACM9UD4A0@omta-ad3-fd1-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Wed, 06 Apr 2022 06:05:54 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=qk698qFB+7DuJ4AJ2sY5VQ7AD5pdtTim73QQqZ92loQ=; b=vV1BbnA55cPPAZB3254BK506im Old6T+yuUYVQppmY4OvzxURFILotMc/oCVviEkRv2abUE0J0i0GHlFCQmQE6zN4zzMN0LyyGdxCxm a3zAC2ibzPxxmh2esPJ31vQhU4t1hgSd4oolbLVJ30XUyZxO92DdwG6hQFMXNMNhWN7rcep7w4tlS VBiExL3j/1rs3vSKxNFaeesN2dWuawOYgyTbMBu//+gVZzz/ekohyJi6Ui5YQzYrI1BTFh69BMJ40 8U0V0qb3pKlFpPgDI+reF/WlPNRxgS+0CgrkGxB17h8Jk2cVEx0UzjeLM8HRoV8yqMFF4OEOqQS3q gljNqowQ==; To: Jens Axboe Date: Wed, 6 Apr 2022 08:04:51 +0200 Message-id: <20220406060516.409838-3-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-reply-to: <20220406060516.409838-1-hch@lst.de> References: <20220406060516.409838-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10308 signatures=695566 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 mlxlogscore=977 malwarescore=0 impostorscore=0 phishscore=0 spamscore=0 adultscore=0 suspectscore=0 priorityscore=90 clxscore=344 lowpriorityscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204060026 Cc: jfs-discussion@lists.sourceforge.net, linux-nvme@lists.infradead.org, virtualization@lists.linux-foundation.org, linux-mm@kvack.org, dm-devel@redhat.com, target-devel@vger.kernel.org, linux-mtd@lists.infradead.org, drbd-dev@lists.linbit.com, linux-s390@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-scsi@vger.kernel.org, cluster-devel@redhat.com, xen-devel@lists.xenproject.org, linux-ext4@vger.kernel.org, linux-um@lists.infradead.org, nbd@other.debian.org, linux-block@vger.kernel.org, linux-bcache@vger.kernel.org, ceph-devel@vger.kernel.org, linux-raid@vger.kernel.org, linux-mmc@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, ntfs3@lists.linux.dev, linux-btrfs@vger.kernel.org Subject: [Ocfs2-devel] [PATCH 02/27] target: pass a block_device to target_configure_unmap_from_queue X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Christoph Hellwig via Ocfs2-devel Reply-to: Christoph Hellwig Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-ServerName: bombadil.infradead.org X-Proofpoint-SPF-Result: None X-Spam: Clean X-Proofpoint-GUID: E3Z3XjxmsuO4HBsGgvdE9ICDAd9qV7F3 X-Proofpoint-ORIG-GUID: E3Z3XjxmsuO4HBsGgvdE9ICDAd9qV7F3 Reporting-Meta: AAETa/QUNY7OSDPKuWYri75xeBs4xsYiY2lC/4/a2XXSRnaz+n5OOucGc+dumTpk hpUlXMn7B9PQUZmZUYhglo2W/njxLgFMcMcOiGXR7YN9jZnFFg3H8kln+QpehK0x zsUpKk3DoV2pFbBaHN+cKA+WtKnh9sV1RdY8IX5qxByGKDs+PsxqYc0+GyZVWZaP NJYjLdV6Re6HpCF+M//rP3ZWkIHsUG4tDU7BS5gEeDjL2u+JJk2ZrLG8BrN/lt5i pZ+howax+PnuPFEfPFYCVpHfqkdOzn8Ao4K38xgBlmEmU9vatcgITHEWr4Kdz2BP n/F/iXwpkYObpJwdhJy8nAqnRhrTAf0W3ZQMzdYKN+TS0D25BYLRpST+lAxMtMow ldHQeszqbtWvpL/S/pFVyrGn07GmAVBY/n2BGc+rI/pMTeQKf+g881ck0wuWAazj JOPIsFOozrSrQNlYhObt/GMn1xh0BFaMm5+TuSx07MOcqyAhOoih24OeyDhEyy3U B98DCXMQnbV9aM2v+BvpkHqMhlTMq/dL0BxiDBv/OQTZ The target code is a consumer of the block layer and should generally work on struct block_device. Signed-off-by: Christoph Hellwig Reviewed-by: Martin K. Petersen --- drivers/target/target_core_device.c | 5 +++-- drivers/target/target_core_file.c | 7 ++++--- drivers/target/target_core_iblock.c | 2 +- include/target/target_core_backend.h | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index fa866acef5bb2..3a1ec705cd80b 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -834,9 +834,10 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) * in ATA and we need to set TPE=1 */ bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib, - struct request_queue *q) + struct block_device *bdev) { - int block_size = queue_logical_block_size(q); + struct request_queue *q = bdev_get_queue(bdev); + int block_size = bdev_logical_block_size(bdev); if (!blk_queue_discard(q)) return false; diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 8190b840065f3..8d191fdc33217 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -134,10 +134,11 @@ static int fd_configure_device(struct se_device *dev) */ inode = file->f_mapping->host; if (S_ISBLK(inode->i_mode)) { - struct request_queue *q = bdev_get_queue(I_BDEV(inode)); + struct block_device *bdev = I_BDEV(inode); + struct request_queue *q = bdev_get_queue(bdev); unsigned long long dev_size; - fd_dev->fd_block_size = bdev_logical_block_size(I_BDEV(inode)); + fd_dev->fd_block_size = bdev_logical_block_size(bdev); /* * Determine the number of bytes from i_size_read() minus * one (1) logical sector from underlying struct block_device @@ -150,7 +151,7 @@ static int fd_configure_device(struct se_device *dev) dev_size, div_u64(dev_size, fd_dev->fd_block_size), fd_dev->fd_block_size); - if (target_configure_unmap_from_queue(&dev->dev_attrib, q)) + if (target_configure_unmap_from_queue(&dev->dev_attrib, bdev)) pr_debug("IFILE: BLOCK Discard support available," " disabled by default\n"); /* diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 87ede165ddba4..b886ce1770bfd 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -119,7 +119,7 @@ static int iblock_configure_device(struct se_device *dev) dev->dev_attrib.hw_max_sectors = queue_max_hw_sectors(q); dev->dev_attrib.hw_queue_depth = q->nr_requests; - if (target_configure_unmap_from_queue(&dev->dev_attrib, q)) + if (target_configure_unmap_from_queue(&dev->dev_attrib, bd)) pr_debug("IBLOCK: BLOCK Discard support available," " disabled by default\n"); diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 675f3a1fe6139..773963a1e0b53 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -14,7 +14,7 @@ #define TRANSPORT_FLAG_PASSTHROUGH_ALUA 0x2 #define TRANSPORT_FLAG_PASSTHROUGH_PGR 0x4 -struct request_queue; +struct block_device; struct scatterlist; struct target_backend_ops { @@ -117,7 +117,7 @@ sense_reason_t passthrough_parse_cdb(struct se_cmd *cmd, bool target_sense_desc_format(struct se_device *dev); sector_t target_to_linux_sector(struct se_device *dev, sector_t lb); bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib, - struct request_queue *q); + struct block_device *bdev); static inline bool target_dev_configured(struct se_device *se_dev) {