Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2853536pxa; Mon, 17 Aug 2020 22:50:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyg63yEkLJKHm04Uku/AvfL3xkkznnSYP1uVFm7M8Gaj9PQztyKuux7IJHMbNy/CmqGOdCU X-Received: by 2002:a05:6402:30a5:: with SMTP id df5mr17864651edb.18.1597729814126; Mon, 17 Aug 2020 22:50:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597729814; cv=none; d=google.com; s=arc-20160816; b=D1pFjtCX44zemkcKPJM0n1eaV/1D7vNOKIJcgjXlaXA6rpqY0nm1DQuHT8A9ffC5nB OwUVxJ86IGWq1B+X8Jp3VBnd37hY9oIck1IissG14FE4byc7AfzOMoEWYAVQdvr/9CZk 32ePucb+VHU7/SpEEpdfEXxaMZX4mY+3aMu+4MZyie/FTSUjw0Z7a7zho0oP2GS0DdPt 2bFPG+0wWS0y9CKTlSRR+sFD1UBzICvSQJ3WQa4zJ/V0w9isQs97cJC3wNjjsX1m6S0K 4OIn43r1hJumD9PAcqFv3SLnveoJEmydmHO5QYH7bDlA9fgu0q5zY6AKXtCgnFeV2rcR F/6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=EAnxeGINIDhfVZDWapA+3sLIAgOpEFQhC583GmqNCmA=; b=vvA4J6uUNaGKTZjL0tJWAYIBgGB6notqO/a+KlN0um8OyZNDq5tEixjvfN51RbUIH+ 6vHwbD30sDC/9zFnP1l+AYk6wcbL/WYL0NtAqpDgfc1EYgTqPmgA7TYm2Q7kbTH0oSXo ajzHlMI1uWFdkr4n+qtBGBoYKHPkycNwHW6T45OQV9LblcJ8y5FLVwL2iklMXXmm3S95 1hR3tJWB6so4LctPmzlVAlxjdKTa5KotOnqJZoH/1G49/QGntjh4xIFRFqVOOK4Jb1Jx IcAeCa6+j2HZzwD1D8QsL3uQRw1Wca7EbcVGQ+lMWIQYkfYCOF4UH8lw7TX+jlnUDltY hoQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 y10si12592300edu.397.2020.08.17.22.49.50; Mon, 17 Aug 2020 22:50:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726639AbgHRFtP (ORCPT + 99 others); Tue, 18 Aug 2020 01:49:15 -0400 Received: from smtp.h3c.com ([60.191.123.50]:8241 "EHLO h3cspam02-ex.h3c.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbgHRFtO (ORCPT ); Tue, 18 Aug 2020 01:49:14 -0400 Received: from DAG2EX03-BASE.srv.huawei-3com.com ([10.8.0.66]) by h3cspam02-ex.h3c.com with ESMTPS id 07I5mrPN027012 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 18 Aug 2020 13:48:53 +0800 (GMT-8) (envelope-from tian.xianting@h3c.com) Received: from localhost.localdomain (10.99.212.201) by DAG2EX03-BASE.srv.huawei-3com.com (10.8.0.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 18 Aug 2020 13:48:55 +0800 From: Xianting Tian To: CC: , , Xianting Tian Subject: [PATCH] md: only calculate blocksize once and use i_blocksize() Date: Tue, 18 Aug 2020 13:42:06 +0800 Message-ID: <20200818054206.6612-1-tian.xianting@h3c.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.99.212.201] X-ClientProxiedBy: BJSMTP01-EX.srv.huawei-3com.com (10.63.20.132) To DAG2EX03-BASE.srv.huawei-3com.com (10.8.0.66) X-DNSRBL: X-MAIL: h3cspam02-ex.h3c.com 07I5mrPN027012 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We alreday has the interface i_blocksize(), which can be used to get blocksize, so use it. Only calculate blocksize once and use it within read_page(). Signed-off-by: Xianting Tian --- drivers/md/md-bitmap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 95a5f3757..0d5544868 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -357,11 +357,12 @@ static int read_page(struct file *file, unsigned long index, struct inode *inode = file_inode(file); struct buffer_head *bh; sector_t block, blk_cur; + unsigned long blocksize = i_blocksize(inode); pr_debug("read bitmap file (%dB @ %llu)\n", (int)PAGE_SIZE, (unsigned long long)index << PAGE_SHIFT); - bh = alloc_page_buffers(page, 1<i_blkbits, false); + bh = alloc_page_buffers(page, blocksize, false); if (!bh) { ret = -ENOMEM; goto out; @@ -383,10 +384,10 @@ static int read_page(struct file *file, unsigned long index, bh->b_blocknr = block; bh->b_bdev = inode->i_sb->s_bdev; - if (count < (1<i_blkbits)) + if (count < blocksize) count = 0; else - count -= (1<i_blkbits); + count -= blocksize; bh->b_end_io = end_bitmap_write; bh->b_private = bitmap; -- 2.17.1