Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3132663pxb; Tue, 12 Oct 2021 22:45:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztFCDCKERmf5NOcG0m54EaGiYXAcK6n+x+DiH8BdqJjckdZ8silS1vbNm3a0XcGeGWYTyX X-Received: by 2002:a17:906:c252:: with SMTP id bl18mr37098893ejb.519.1634103900638; Tue, 12 Oct 2021 22:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634103900; cv=none; d=google.com; s=arc-20160816; b=MOpuX8Wt5mVrpcG7XfyDe0z3d9aulq1FKiDX3c+rhs2ql0BZ3LvWCkWVKAEA34rZcL cwpHGzBK9mMYpFHrNC7II6bhpETJjAUDB3q57wI8A4TtyLtZN+7EKIGfh+aATo67E38a Ro6gv5qrPm+1CXTTOuY53oDMYDYvjVJK+FFrLpfKLHwHU83fZxIbrye/vX48AJhsML5+ U6ee0Cm+WWL8a8dkXKknbBx48ZCO8DAX+PzGffWirw6j/xvVpLRQx2S+iML/X9uskxdv o0P3WCzNrhB642pOba6coLDz1qX0nyWwZGRyOyziuWXvi8n2/Ha/JVLOfuqlSnljHlr9 deuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vUXTd2YdXfDrfy4pbV8SMX7GiwQcZZ3XnEJ9sBFT+FY=; b=Kam2Qc9KNHLMnYZ5IGMSz25VcA3z9QEeGWNm52IX99TcK4NSLgTRsqAOk8GIsdvOth 8b3DyXNqdSmpzw4wOGe4GTinX+zn39Dwni4AlGmDg3yy2eo9NfSGgv+gc/I3byQuBurq A5p22S4PpW6ZE4AzF1d+hPYXs/s+NVEFyfdtVZj50lIRw28/alcJbDMCdjAIaxh44G8h eAtaRJTW9wRPf+e3owxsscufgN/fRiB4D9I41pSJL0peGLgOq6b1RyVgaWG66S9yO+n3 CxCEfThyyfkMI6C1v1LJKP+C4vJe9s7doBdw6ddUaiaUPT6TQQ0MgESI3pfCWT8DlJjj n02g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=H0UVWNgw; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z4si9013364ejw.190.2021.10.12.22.44.37; Tue, 12 Oct 2021 22:45:00 -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=@infradead.org header.s=casper.20170209 header.b=H0UVWNgw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237413AbhJMFqF (ORCPT + 99 others); Wed, 13 Oct 2021 01:46:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbhJMFqE (ORCPT ); Wed, 13 Oct 2021 01:46:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35138C061570; Tue, 12 Oct 2021 22:44:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=vUXTd2YdXfDrfy4pbV8SMX7GiwQcZZ3XnEJ9sBFT+FY=; b=H0UVWNgwlojCDOZ0ZDJEHbcabH /9k0Jdc+YLFDHne+zfEyDy0jv5BMEE4tSHTVSjq9pY+zz3oa4oUqe8AXLPv3nLRy41ZvHo0BFuSsA MaY/EKHh1Bp7Uf1udgCZNNBxreNpTwvrd/EqmRLDQBn6IJi8YRJFbqQmFZeteuySU1Cfmu1NFiTgQ 2LgWePcSz6O2+8NDUH5I2rp85amag5Y71YZ+7TLQm1/Q0On+c4vchAxkdL8ToRCxOv8PtjjyJ+kWZ +hJqPyUbz5GIMW3ia1Y04II/0+/C9L7zroftL5CNXO1fs8k/zQt2HAH6gz3BjvISqqA/tFFfZj+Q+ u0lN1M/Q==; Received: from 089144212063.atnat0021.highway.a1.net ([89.144.212.63] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1maWyt-00789s-54; Wed, 13 Oct 2021 05:39:26 +0000 From: Christoph Hellwig To: 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 Subject: [PATCH 24/29] block: add a sb_bdev_nr_blocks helper Date: Wed, 13 Oct 2021 07:10:37 +0200 Message-Id: <20211013051042.1065752-25-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211013051042.1065752-1-hch@lst.de> References: <20211013051042.1065752-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Add a helper to return the size of sb->s_bdev in sb->s_blocksize_bits based unites. Note that SECTOR_SHIFT has to be open coded due to include dependency issues for now, but I have a plan to sort that out eventually. Signed-off-by: Christoph Hellwig --- include/linux/genhd.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 082a3e5fd8fa1..6eaef8fa78bcd 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -245,6 +245,12 @@ static inline sector_t get_capacity(struct gendisk *disk) return bdev_nr_sectors(disk->part0); } +static inline u64 sb_bdev_nr_blocks(struct super_block *sb) +{ + return bdev_nr_sectors(sb->s_bdev) >> + (sb->s_blocksize_bits - 9 /* SECTOR_SHIFT */); +} + int bdev_disk_changed(struct gendisk *disk, bool invalidate); void blk_drop_partitions(struct gendisk *disk); -- 2.30.2