From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76DBFC433FE for ; Thu, 14 Oct 2021 07:53:18 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D28461019 for ; Thu, 14 Oct 2021 07:53:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0D28461019 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-_YPt66LcPL-dSS7lr5Xsaw-1; Thu, 14 Oct 2021 03:53:13 -0400 X-MC-Unique: _YPt66LcPL-dSS7lr5Xsaw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33AE018D6A35; Thu, 14 Oct 2021 07:53:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E304C641AA; Thu, 14 Oct 2021 07:53:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E7FCB4E58F; Thu, 14 Oct 2021 07:53:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19D9VMEc012902 for ; Wed, 13 Oct 2021 05:31:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8912C5EDED; Wed, 13 Oct 2021 09:31:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 835E05F274 for ; Wed, 13 Oct 2021 09:31:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3883899EC0 for ; Wed, 13 Oct 2021 09:31:18 +0000 (UTC) Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-453-vOmeDSOeORqCBByqtIL6Bw-1; Wed, 13 Oct 2021 05:31:15 -0400 X-MC-Unique: vOmeDSOeORqCBByqtIL6Bw-1 Received: by mail-ed1-f54.google.com with SMTP id z20so7383777edc.13; Wed, 13 Oct 2021 02:31:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jSDv3nCwYvRWF60PFzYmVFtCqi6n+8kG/qLGRQcEwXY=; b=3e4o/DFOOBfYSdIe/FIHCt84/NiUr60k4kDFfRt1C+y4z2e0JA5jlbTaRNh2OFRoO8 nx1h5OsHSKb9pYxGNLTWJ7G6yOdVukoc6m0CsEdoIxThKBMD2KTRaXrqFsKNJbw4Mp7N 43fiRGIE4wy76/W3G+Q8erXIYOZTDgNQTiyBcmMgSoW7bFQBiXbAJax9AOD8Qn7NXj9S e0eQTrbxi7z4ICAz2ltZjhV/7WUjxGWJ6RiARKpB4lsBKntxgwSs9M616im8/YPYIMnM okhX/+JccorfFNC2UFNIJcYSYWKAkJA7KrWx9Zf4OYI2iMTFQ0POg5xYf57VkFikAOVC jQnw== X-Gm-Message-State: AOAM533qF8RWOTm6QE7MEDO2/j8+gsUIFgaro0LN1QyAmbchhzk9n0vd 1BBg6qqp5RC3iPT5ClXD/og= X-Google-Smtp-Source: ABdhPJzWnNPujm70ssX25zhSqx1K1lXHECTOGOjBrmNCExix4poiHSM5QToDrvQz8D7ttpAXJOx3mg== X-Received: by 2002:a05:6402:51d0:: with SMTP id r16mr7954872edd.353.1634117473882; Wed, 13 Oct 2021 02:31:13 -0700 (PDT) Received: from [192.168.178.40] (ipbcc061e7.dynamic.kabel-deutschland.de. [188.192.97.231]) by smtp.gmail.com with ESMTPSA id p7sm7639013edr.6.2021.10.13.02.31.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Oct 2021 02:31:13 -0700 (PDT) To: Christoph Hellwig , Jens Axboe References: <20211013051042.1065752-1-hch@lst.de> <20211013051042.1065752-8-hch@lst.de> From: Bodo Stroesser Message-ID: <3babe7ca-cf08-fd19-6793-39f6d78bca12@gmail.com> Date: Wed, 13 Oct 2021 11:31:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211013051042.1065752-8-hch@lst.de> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 14 Oct 2021 03:53:04 -0400 Cc: Dave Kleikamp , jfs-discussion@lists.sourceforge.net, Mike Snitzer , linux-nvme@lists.infradead.org, Konstantin Komarov , Song Liu , dm-devel@redhat.com, target-devel@vger.kernel.org, linux-mtd@lists.infradead.org, reiserfs-devel@vger.kernel.org, drbd-dev@lists.linbit.com, linux-nilfs@vger.kernel.org, linux-scsi@vger.kernel.org, OGAWA Hirofumi , linux-ext4@vger.kernel.org, Kees Cook , Josef Bacik , Coly Li , linux-raid@vger.kernel.org, linux-bcache@vger.kernel.org, David Sterba , Ryusuke Konishi , Anton Altaparmakov , linux-block@vger.kernel.org, linux-nfs@vger.kernel.org, Theodore Ts'o , linux-ntfs-dev@lists.sourceforge.net, Jan Kara , linux-fsdevel@vger.kernel.org, Phillip Lougher , ntfs3@lists.linux.dev, linux-btrfs@vger.kernel.org Subject: Re: [dm-devel] [PATCH 07/29] target/iblock: use bdev_nr_sectors instead of open coding it X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" On 13.10.21 07:10, Christoph Hellwig wrote: > Use the proper helper to read the block device size. > > Signed-off-by: Christoph Hellwig > --- > drivers/target/target_core_iblock.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c > index 31df20abe141f..ab7f5678ebc44 100644 > --- a/drivers/target/target_core_iblock.c > +++ b/drivers/target/target_core_iblock.c > @@ -232,8 +232,9 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( > struct block_device *bd, > struct request_queue *q) > { > - unsigned long long blocks_long = (div_u64(i_size_read(bd->bd_inode), > - bdev_logical_block_size(bd)) - 1); > + loff_t size = bdev_nr_sectors(bd) << SECTOR_SHIFT; > + unsigned long long blocks_long = > + div_u64(size, bdev_logical_block_size(bd)) - 1; > u32 block_size = bdev_logical_block_size(bd); To enhance readability, would it make sense to shift the new lines behind "u32 block_size = ...", so block_size can be used in div_u64 instead of using bdev_logical_block_size twice? > > if (block_size == dev->dev_attrib.block_size) > -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C998C433FE for ; Wed, 13 Oct 2021 09:31:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03D4061040 for ; Wed, 13 Oct 2021 09:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237656AbhJMJdU (ORCPT ); Wed, 13 Oct 2021 05:33:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237572AbhJMJdS (ORCPT ); Wed, 13 Oct 2021 05:33:18 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55885C061570; Wed, 13 Oct 2021 02:31:15 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id p13so7741041edw.0; Wed, 13 Oct 2021 02:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jSDv3nCwYvRWF60PFzYmVFtCqi6n+8kG/qLGRQcEwXY=; b=XDrKXspyEQaSQYdqJnWhS/O0wblIXJrWl9pE6svv7KjgrDGVXul7dxFR95SMikNbI8 dPBwNGXnMZrq9ECfkN9qd8qudIplcKbKQ02+dvBybldEqKgGTDn4o+Q+1yZvLDbQTpxH j0F3JAFmKpiVLRpHTHEBPzaDyzHphlM3B0d+/j7Ro7xiITFiea8XjX1E/h70+j8E07xJ iueofrb4NiJyC6FBpvAD+REiiIZXBpKUegBHgRICkLNGzc50RGa+mMfC0qBppipcUZ0O 0MOGnuc/w5sEpIO1qpW0KnLTEIw6dv//T71InSxwu/1xkmLMW6ESgvB/ttIEAHR+9lRU du6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jSDv3nCwYvRWF60PFzYmVFtCqi6n+8kG/qLGRQcEwXY=; b=a/9NWlYe1KD6qiKYTb7tewBmaSvmZudaDcgwZSgkzw86ol10izBu8ANoKwcfmRfK90 IimS2YoiRx5C58Zq5B/kSYlmNXuY12eOGOlGdUNdqOdoginCi5kPJ1EdvW0pee+3G1ru HCVSRE5gCuvpt7IJQIRlh4jTotisb1yRrwIzfvUNr2HDa3aRzKBEcSdu5CSTygL5C7qN OxdllwjRcgKH6do7qHj9Dc4f8hT3LLP9H3E5RJwmPHoDlCLSCpN+j3nfy7HzsiO0vAKX CMYCbIP5vSG6oWbdJmdDMsPnhZ6ZIc+xqn4tbShPmjFBIOyZW/hoa7Ak+CJAC8r2B41J ptDw== X-Gm-Message-State: AOAM532Crg6in8UMZOaVR9jB3qT11uoF8SZ3tV/5Mcc/aG9r8pPVm4rI 0dpoo3ykX5f06s+1QxuMXYZa9lQYh5JzCA== X-Google-Smtp-Source: ABdhPJzWnNPujm70ssX25zhSqx1K1lXHECTOGOjBrmNCExix4poiHSM5QToDrvQz8D7ttpAXJOx3mg== X-Received: by 2002:a05:6402:51d0:: with SMTP id r16mr7954872edd.353.1634117473882; Wed, 13 Oct 2021 02:31:13 -0700 (PDT) Received: from [192.168.178.40] (ipbcc061e7.dynamic.kabel-deutschland.de. [188.192.97.231]) by smtp.gmail.com with ESMTPSA id p7sm7639013edr.6.2021.10.13.02.31.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Oct 2021 02:31:13 -0700 (PDT) Subject: Re: [PATCH 07/29] target/iblock: use bdev_nr_sectors instead of open coding it To: Christoph Hellwig , Jens Axboe Cc: Coly Li , Mike Snitzer , Song Liu , David Sterba , Josef Bacik , Theodore Ts'o , OGAWA Hirofumi , Dave Kleikamp , Ryusuke Konishi , Anton Altaparmakov , Konstantin Komarov , Kees Cook , Phillip Lougher , Jan Kara , linux-block@vger.kernel.org, dm-devel@redhat.com, drbd-dev@lists.linbit.com, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, jfs-discussion@lists.sourceforge.net, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, ntfs3@lists.linux.dev, reiserfs-devel@vger.kernel.org References: <20211013051042.1065752-1-hch@lst.de> <20211013051042.1065752-8-hch@lst.de> From: Bodo Stroesser Message-ID: <3babe7ca-cf08-fd19-6793-39f6d78bca12@gmail.com> Date: Wed, 13 Oct 2021 11:31:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211013051042.1065752-8-hch@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-bcache@vger.kernel.org On 13.10.21 07:10, Christoph Hellwig wrote: > Use the proper helper to read the block device size. > > Signed-off-by: Christoph Hellwig > --- > drivers/target/target_core_iblock.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c > index 31df20abe141f..ab7f5678ebc44 100644 > --- a/drivers/target/target_core_iblock.c > +++ b/drivers/target/target_core_iblock.c > @@ -232,8 +232,9 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( > struct block_device *bd, > struct request_queue *q) > { > - unsigned long long blocks_long = (div_u64(i_size_read(bd->bd_inode), > - bdev_logical_block_size(bd)) - 1); > + loff_t size = bdev_nr_sectors(bd) << SECTOR_SHIFT; > + unsigned long long blocks_long = > + div_u64(size, bdev_logical_block_size(bd)) - 1; > u32 block_size = bdev_logical_block_size(bd); To enhance readability, would it make sense to shift the new lines behind "u32 block_size = ...", so block_size can be used in div_u64 instead of using bdev_logical_block_size twice? > > if (block_size == dev->dev_attrib.block_size) > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bodo Stroesser Subject: Re: [PATCH 07/29] target/iblock: use bdev_nr_sectors instead of open coding it Date: Wed, 13 Oct 2021 11:31:11 +0200 Message-ID: <3babe7ca-cf08-fd19-6793-39f6d78bca12@gmail.com> References: <20211013051042.1065752-1-hch@lst.de> <20211013051042.1065752-8-hch@lst.de> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jSDv3nCwYvRWF60PFzYmVFtCqi6n+8kG/qLGRQcEwXY=; b=XDrKXspyEQaSQYdqJnWhS/O0wblIXJrWl9pE6svv7KjgrDGVXul7dxFR95SMikNbI8 dPBwNGXnMZrq9ECfkN9qd8qudIplcKbKQ02+dvBybldEqKgGTDn4o+Q+1yZvLDbQTpxH j0F3JAFmKpiVLRpHTHEBPzaDyzHphlM3B0d+/j7Ro7xiITFiea8XjX1E/h70+j8E07xJ iueofrb4NiJyC6FBpvAD+REiiIZXBpKUegBHgRICkLNGzc50RGa+mMfC0qBppipcUZ0O 0MOGnuc/w5sEpIO1qpW0KnLTEIw6dv//T71InSxwu/1xkmLMW6ESgvB/ttIEAHR+9lRU du6Q== In-Reply-To: <20211013051042.1065752-8-hch@lst.de> Content-Language: en-US List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: Christoph Hellwig , Jens Axboe Cc: Coly Li , Mike Snitzer , Song Liu , David Sterba , Josef Bacik , Theodore Ts'o , OGAWA Hirofumi , Dave Kleikamp , Ryusuke Konishi , Anton Altaparmakov , Konstantin Komarov , Kees Cook , Phillip Lougher , Jan Kara , linux-block@vger.kernel.org, dm-devel@redhat.com, drbd-dev@lists.linbit.com, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org On 13.10.21 07:10, Christoph Hellwig wrote: > Use the proper helper to read the block device size. > > Signed-off-by: Christoph Hellwig > --- > drivers/target/target_core_iblock.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c > index 31df20abe141f..ab7f5678ebc44 100644 > --- a/drivers/target/target_core_iblock.c > +++ b/drivers/target/target_core_iblock.c > @@ -232,8 +232,9 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( > struct block_device *bd, > struct request_queue *q) > { > - unsigned long long blocks_long = (div_u64(i_size_read(bd->bd_inode), > - bdev_logical_block_size(bd)) - 1); > + loff_t size = bdev_nr_sectors(bd) << SECTOR_SHIFT; > + unsigned long long blocks_long = > + div_u64(size, bdev_logical_block_size(bd)) - 1; > u32 block_size = bdev_logical_block_size(bd); To enhance readability, would it make sense to shift the new lines behind "u32 block_size = ...", so block_size can be used in div_u64 instead of using bdev_logical_block_size twice? > > if (block_size == dev->dev_attrib.block_size) > From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09A9EC433F5 for ; Wed, 13 Oct 2021 11:16:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD18C601FC for ; Wed, 13 Oct 2021 11:16:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BD18C601FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YxW3wk8c2M69rxZ/6aWH2BUdKOAVuA4yhvQBA79qlOU=; b=uY0Th/SmF/FFSgbO2Kr0ZE22zQ Gv4gMbKHbkzR3KeqGJYzY9e+nFEZ5MYSgQT+RQ9VyyS0eK6AJ4z/zVxelqm3X2eB7RIRJfD0My2/k 2fZW/kD0c1ba/sRc6oT4Q6Ex5gk+ByeLiqPY/FA9XxlmhtHB7drCl+BSjapS7ERUb0TL8WkHlflAi gOJ7iurYNHocTx/DPeaidLBrJHiJOHw2tAywmiCUa+39KJcjQOeHqFsT1PUnJyA9yMJpJlo1ozXLN HTsW8K24xb4SICJkqzgkSleUUr5ImNU3YwwZrmGh0X3kYCfJpFyrF7fxvKC8G+05rMG2cdIY9PHio wwg4Iyvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1macEd-00GFPh-HG; Wed, 13 Oct 2021 11:15:48 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1maabV-00Flvr-C5; Wed, 13 Oct 2021 09:31:18 +0000 Received: by mail-ed1-x533.google.com with SMTP id d3so7569131edp.3; Wed, 13 Oct 2021 02:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jSDv3nCwYvRWF60PFzYmVFtCqi6n+8kG/qLGRQcEwXY=; b=XDrKXspyEQaSQYdqJnWhS/O0wblIXJrWl9pE6svv7KjgrDGVXul7dxFR95SMikNbI8 dPBwNGXnMZrq9ECfkN9qd8qudIplcKbKQ02+dvBybldEqKgGTDn4o+Q+1yZvLDbQTpxH j0F3JAFmKpiVLRpHTHEBPzaDyzHphlM3B0d+/j7Ro7xiITFiea8XjX1E/h70+j8E07xJ iueofrb4NiJyC6FBpvAD+REiiIZXBpKUegBHgRICkLNGzc50RGa+mMfC0qBppipcUZ0O 0MOGnuc/w5sEpIO1qpW0KnLTEIw6dv//T71InSxwu/1xkmLMW6ESgvB/ttIEAHR+9lRU du6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jSDv3nCwYvRWF60PFzYmVFtCqi6n+8kG/qLGRQcEwXY=; b=5XfbENM468wE12j4z7t8pGGIl6UrxUmZBqbxUvG1PK9xjuEfzPmC/omX1owJZh32sV AsNKeQ/qIOR6RYcex8sV/p4dzaqykdv+ycLHtzTVmqv269nMvuY8TvY6HThKw3ff0WHB KLZD2uABo4BKGi6jFmEvhCB0zEkT4oBazvSKL7Dbo/RF1pGxjIzp5TAONRovj0weIqJr eK6RPl1IMcsFJbVBAouEgD//Sk4uannI2MZpDkJiSs53iwRIT4SUxED19QuI1CDmPXCF jnKPECIi9rTmWaySoQ7BoAP0eg9imdASB42eWJdIIwimq9ZBwMHUJuaA1goLr5sWkI/K zIMQ== X-Gm-Message-State: AOAM531gNK7T7v4XT+B9We1TleSwbMfdt4eVQx4mbHMxwSEGfqBtZPew riTannzDDB9/78vC8bab8lU= X-Google-Smtp-Source: ABdhPJzWnNPujm70ssX25zhSqx1K1lXHECTOGOjBrmNCExix4poiHSM5QToDrvQz8D7ttpAXJOx3mg== X-Received: by 2002:a05:6402:51d0:: with SMTP id r16mr7954872edd.353.1634117473882; Wed, 13 Oct 2021 02:31:13 -0700 (PDT) Received: from [192.168.178.40] (ipbcc061e7.dynamic.kabel-deutschland.de. [188.192.97.231]) by smtp.gmail.com with ESMTPSA id p7sm7639013edr.6.2021.10.13.02.31.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Oct 2021 02:31:13 -0700 (PDT) Subject: Re: [PATCH 07/29] target/iblock: use bdev_nr_sectors instead of open coding it To: Christoph Hellwig , Jens Axboe Cc: Coly Li , Mike Snitzer , Song Liu , David Sterba , Josef Bacik , Theodore Ts'o , OGAWA Hirofumi , Dave Kleikamp , Ryusuke Konishi , Anton Altaparmakov , Konstantin Komarov , Kees Cook , Phillip Lougher , Jan Kara , linux-block@vger.kernel.org, dm-devel@redhat.com, drbd-dev@lists.linbit.com, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, jfs-discussion@lists.sourceforge.net, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, ntfs3@lists.linux.dev, reiserfs-devel@vger.kernel.org References: <20211013051042.1065752-1-hch@lst.de> <20211013051042.1065752-8-hch@lst.de> From: Bodo Stroesser Message-ID: <3babe7ca-cf08-fd19-6793-39f6d78bca12@gmail.com> Date: Wed, 13 Oct 2021 11:31:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211013051042.1065752-8-hch@lst.de> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211013_023117_476592_C5775115 X-CRM114-Status: GOOD ( 19.78 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org On 13.10.21 07:10, Christoph Hellwig wrote: > Use the proper helper to read the block device size. > > Signed-off-by: Christoph Hellwig > --- > drivers/target/target_core_iblock.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c > index 31df20abe141f..ab7f5678ebc44 100644 > --- a/drivers/target/target_core_iblock.c > +++ b/drivers/target/target_core_iblock.c > @@ -232,8 +232,9 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( > struct block_device *bd, > struct request_queue *q) > { > - unsigned long long blocks_long = (div_u64(i_size_read(bd->bd_inode), > - bdev_logical_block_size(bd)) - 1); > + loff_t size = bdev_nr_sectors(bd) << SECTOR_SHIFT; > + unsigned long long blocks_long = > + div_u64(size, bdev_logical_block_size(bd)) - 1; > u32 block_size = bdev_logical_block_size(bd); To enhance readability, would it make sense to shift the new lines behind "u32 block_size = ...", so block_size can be used in div_u64 instead of using bdev_logical_block_size twice? > > if (block_size == dev->dev_attrib.block_size) > ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20DE8C433EF for ; Wed, 13 Oct 2021 13:33:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D9580610E6 for ; Wed, 13 Oct 2021 13:33:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D9580610E6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OBYoKSd/HIB9JlpZhHEJyedLsizg2HzBalX0qhVLb2c=; b=sw+iN20vefnoo58CQBF5jz7rKV HfcsQstSS/uT6LaAn5AzNzzzJt0BO2CdmTO9r3kLlv6qNUcdjvBzBxQXJ6ingUTxb38FpLebD6ecy E8NEk1Ux6h8YT6iAFX5XXdlELhKf0/ATz+Pyq5evrggnLNLlJrZverWQWbOtbBgbhQnqRr1A06yrg fscgAqpy3j0r0ZzIPOcsKcHrFDMuOSFwI008B3LDsQ8Gi0fGK3MlsBgFp/N51hveAPIYzvQU8OoyF U5S4h8Q31X1mvP7KWM6UPO96HDRkSVFmHgN/dKVyIcfvtBR5xiBoc3ODoJb5RTXJKi5YQdK4oINjD sppVZbQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1maeND-00Gv3A-Td; Wed, 13 Oct 2021 13:32:47 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1maabV-00Flvr-C5; Wed, 13 Oct 2021 09:31:18 +0000 Received: by mail-ed1-x533.google.com with SMTP id d3so7569131edp.3; Wed, 13 Oct 2021 02:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jSDv3nCwYvRWF60PFzYmVFtCqi6n+8kG/qLGRQcEwXY=; b=XDrKXspyEQaSQYdqJnWhS/O0wblIXJrWl9pE6svv7KjgrDGVXul7dxFR95SMikNbI8 dPBwNGXnMZrq9ECfkN9qd8qudIplcKbKQ02+dvBybldEqKgGTDn4o+Q+1yZvLDbQTpxH j0F3JAFmKpiVLRpHTHEBPzaDyzHphlM3B0d+/j7Ro7xiITFiea8XjX1E/h70+j8E07xJ iueofrb4NiJyC6FBpvAD+REiiIZXBpKUegBHgRICkLNGzc50RGa+mMfC0qBppipcUZ0O 0MOGnuc/w5sEpIO1qpW0KnLTEIw6dv//T71InSxwu/1xkmLMW6ESgvB/ttIEAHR+9lRU du6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jSDv3nCwYvRWF60PFzYmVFtCqi6n+8kG/qLGRQcEwXY=; b=5XfbENM468wE12j4z7t8pGGIl6UrxUmZBqbxUvG1PK9xjuEfzPmC/omX1owJZh32sV AsNKeQ/qIOR6RYcex8sV/p4dzaqykdv+ycLHtzTVmqv269nMvuY8TvY6HThKw3ff0WHB KLZD2uABo4BKGi6jFmEvhCB0zEkT4oBazvSKL7Dbo/RF1pGxjIzp5TAONRovj0weIqJr eK6RPl1IMcsFJbVBAouEgD//Sk4uannI2MZpDkJiSs53iwRIT4SUxED19QuI1CDmPXCF jnKPECIi9rTmWaySoQ7BoAP0eg9imdASB42eWJdIIwimq9ZBwMHUJuaA1goLr5sWkI/K zIMQ== X-Gm-Message-State: AOAM531gNK7T7v4XT+B9We1TleSwbMfdt4eVQx4mbHMxwSEGfqBtZPew riTannzDDB9/78vC8bab8lU= X-Google-Smtp-Source: ABdhPJzWnNPujm70ssX25zhSqx1K1lXHECTOGOjBrmNCExix4poiHSM5QToDrvQz8D7ttpAXJOx3mg== X-Received: by 2002:a05:6402:51d0:: with SMTP id r16mr7954872edd.353.1634117473882; Wed, 13 Oct 2021 02:31:13 -0700 (PDT) Received: from [192.168.178.40] (ipbcc061e7.dynamic.kabel-deutschland.de. [188.192.97.231]) by smtp.gmail.com with ESMTPSA id p7sm7639013edr.6.2021.10.13.02.31.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Oct 2021 02:31:13 -0700 (PDT) Subject: Re: [PATCH 07/29] target/iblock: use bdev_nr_sectors instead of open coding it To: Christoph Hellwig , Jens Axboe Cc: Coly Li , Mike Snitzer , Song Liu , David Sterba , Josef Bacik , Theodore Ts'o , OGAWA Hirofumi , Dave Kleikamp , Ryusuke Konishi , Anton Altaparmakov , Konstantin Komarov , Kees Cook , Phillip Lougher , Jan Kara , linux-block@vger.kernel.org, dm-devel@redhat.com, drbd-dev@lists.linbit.com, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, jfs-discussion@lists.sourceforge.net, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, ntfs3@lists.linux.dev, reiserfs-devel@vger.kernel.org References: <20211013051042.1065752-1-hch@lst.de> <20211013051042.1065752-8-hch@lst.de> From: Bodo Stroesser Message-ID: <3babe7ca-cf08-fd19-6793-39f6d78bca12@gmail.com> Date: Wed, 13 Oct 2021 11:31:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211013051042.1065752-8-hch@lst.de> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211013_023117_476592_C5775115 X-CRM114-Status: GOOD ( 19.78 ) X-Mailman-Approved-At: Wed, 13 Oct 2021 06:24:27 -0700 X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org On 13.10.21 07:10, Christoph Hellwig wrote: > Use the proper helper to read the block device size. > > Signed-off-by: Christoph Hellwig > --- > drivers/target/target_core_iblock.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c > index 31df20abe141f..ab7f5678ebc44 100644 > --- a/drivers/target/target_core_iblock.c > +++ b/drivers/target/target_core_iblock.c > @@ -232,8 +232,9 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( > struct block_device *bd, > struct request_queue *q) > { > - unsigned long long blocks_long = (div_u64(i_size_read(bd->bd_inode), > - bdev_logical_block_size(bd)) - 1); > + loff_t size = bdev_nr_sectors(bd) << SECTOR_SHIFT; > + unsigned long long blocks_long = > + div_u64(size, bdev_logical_block_size(bd)) - 1; > u32 block_size = bdev_logical_block_size(bd); To enhance readability, would it make sense to shift the new lines behind "u32 block_size = ...", so block_size can be used in div_u64 instead of using bdev_logical_block_size twice? > > if (block_size == dev->dev_attrib.block_size) > _______________________________________________ Linux-nvme mailing list Linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by mail19.linbit.com (LINBIT Mail Daemon) with ESMTP id 5024A420FF1 for ; Wed, 13 Oct 2021 11:31:14 +0200 (CEST) Received: by mail-ed1-f47.google.com with SMTP id g10so7620975edj.1 for ; Wed, 13 Oct 2021 02:31:14 -0700 (PDT) To: Christoph Hellwig , Jens Axboe References: <20211013051042.1065752-1-hch@lst.de> <20211013051042.1065752-8-hch@lst.de> From: Bodo Stroesser Message-ID: <3babe7ca-cf08-fd19-6793-39f6d78bca12@gmail.com> Date: Wed, 13 Oct 2021 11:31:11 +0200 MIME-Version: 1.0 In-Reply-To: <20211013051042.1065752-8-hch@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Cc: Dave Kleikamp , jfs-discussion@lists.sourceforge.net, Mike Snitzer , linux-nvme@lists.infradead.org, Konstantin Komarov , Song Liu , dm-devel@redhat.com, target-devel@vger.kernel.org, linux-mtd@lists.infradead.org, reiserfs-devel@vger.kernel.org, drbd-dev@lists.linbit.com, linux-nilfs@vger.kernel.org, linux-scsi@vger.kernel.org, OGAWA Hirofumi , linux-ext4@vger.kernel.org, Kees Cook , Josef Bacik , Coly Li , linux-raid@vger.kernel.org, linux-bcache@vger.kernel.org, David Sterba , Ryusuke Konishi , Anton Altaparmakov , linux-block@vger.kernel.org, linux-nfs@vger.kernel.org, Theodore Ts'o , linux-ntfs-dev@lists.sourceforge.net, Jan Kara , linux-fsdevel@vger.kernel.org, Phillip Lougher , ntfs3@lists.linux.dev, linux-btrfs@vger.kernel.org Subject: Re: [Drbd-dev] [PATCH 07/29] target/iblock: use bdev_nr_sectors instead of open coding it List-Id: "*Coordination* of development, patches, contributions -- *Questions* \(even to developers\) go to drbd-user, please." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On 13.10.21 07:10, Christoph Hellwig wrote: > Use the proper helper to read the block device size. > > Signed-off-by: Christoph Hellwig > --- > drivers/target/target_core_iblock.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c > index 31df20abe141f..ab7f5678ebc44 100644 > --- a/drivers/target/target_core_iblock.c > +++ b/drivers/target/target_core_iblock.c > @@ -232,8 +232,9 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( > struct block_device *bd, > struct request_queue *q) > { > - unsigned long long blocks_long = (div_u64(i_size_read(bd->bd_inode), > - bdev_logical_block_size(bd)) - 1); > + loff_t size = bdev_nr_sectors(bd) << SECTOR_SHIFT; > + unsigned long long blocks_long = > + div_u64(size, bdev_logical_block_size(bd)) - 1; > u32 block_size = bdev_logical_block_size(bd); To enhance readability, would it make sense to shift the new lines behind "u32 block_size = ...", so block_size can be used in div_u64 instead of using bdev_logical_block_size twice? > > if (block_size == dev->dev_attrib.block_size) >