Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3269103pxb; Wed, 13 Oct 2021 02:32:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsxgw3o2VsQ6J2XwYc1AIh4ILoK+/lk/5XMeNLfcRoB+wuc0MFW+YmcugXEpEj57cWLTC3 X-Received: by 2002:a17:903:11cd:b0:13e:596c:d9a7 with SMTP id q13-20020a17090311cd00b0013e596cd9a7mr34738475plh.37.1634117544176; Wed, 13 Oct 2021 02:32:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634117544; cv=none; d=google.com; s=arc-20160816; b=pqE4TyPifz7YFKpy7dap3S6egXEcOPVMHgmHWiu07xxYfNkJ2OW2JoHwB0BHm5CvsJ 4um3iHxiwtMxDuBgMyRDHLtC7fTJXiuJ3s5QyWHmZ7qGkt2lSmDJWjKdpvRX8Qmzpi7N M+FjvHKzOCXc6gKeiyjV7H/5L8eXb9rzOdihuaBf3Etup6HtRBPOdvUC7byy1aRIMM4C 4GyA8NXQ5ZJmIl9klEsmRE2z/lAnQ1WD7gjzem0p7/knz0XLlLO4Sud8tvWEMUgbZdzQ OdoKX1pW/0PM2X136iShayEyw2DopRVBruGFNL4vpSiv4YOh5/4xjbT0kDmqcA/MYj3K ttWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=jSDv3nCwYvRWF60PFzYmVFtCqi6n+8kG/qLGRQcEwXY=; b=pIADgdJEhBJB5CURDHVgxpJtJUUfO9rhw41zAKSwj9Q4g7kJm1uCyxWa117Mv1zDby bx0tU+KX5qIVZieRiPcHMswEtO6WTSv4nPIQY29h11hdwliZRcBdv9BaXqu7jlyWBnHS Sq9P8xCINFWw/a2LYtYXK3trmjKAz0tDsCB5IbTEQK8lng6gtUedgiGa5SEju2wxU37F eYP2t7C/QauR/GSVGuMD+DDuTqtWPiyR3t5ZBz/oSDPWT5Wmf4w1FbxrrSsQM/3yf0QY D/mSAbe9CJbv8Au0feiY+ce//WC4YJ1d68u3wQzgE4rOHLV2SwxQdfCHJeVdIxkHqJIr Ng+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XDrKXspy; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b16si810383pfv.280.2021.10.13.02.32.05; Wed, 13 Oct 2021 02:32:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XDrKXspy; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239124AbhJMJdW (ORCPT + 99 others); Wed, 13 Oct 2021 05:33:22 -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-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-ext4@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) >