From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968101AbdAHOrg (ORCPT ); Sun, 8 Jan 2017 09:47:36 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50828 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934783AbdAHOre (ORCPT ); Sun, 8 Jan 2017 09:47:34 -0500 From: Chandan Rajendra To: axboe@kernel.dk, jack@suse.cz Cc: Chandan Rajendra , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, anton@samba.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH] do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned Date: Sun, 8 Jan 2017 20:17:10 +0530 X-Mailer: git-send-email 2.5.5 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17010814-0008-0000-0000-000006820525 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006396; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000199; SDB=6.00804948; UDB=6.00391846; IPR=6.00582802; BA=6.00005033; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013855; XFM=3.00000011; UTC=2017-01-08 14:47:30 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17010814-0009-0000-0000-00003E76F3B7 Message-Id: <1483886830-23878-1-git-send-email-chandan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-08_12:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701080224 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The code currently uses sdio->blkbits to compute the number of blocks to be cleaned. However sdio->blkbits is derived from the logical block size of the underlying block device (Refer to the definition of do_blockdev_direct_IO()). Due to this, generic/299 test would rarely fail when executed on an ext4 filesystem with 64k as the block size and when using a virtio based disk (having 512 byte as the logical block size) inside a kvm guest. This commit fixes the bug by using inode->i_blkbits to compute the number of blocks to be cleaned. Signed-off-by: Chandan Rajendra --- fs/direct-io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/direct-io.c b/fs/direct-io.c index aeae8c0..b20adf9 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -905,6 +905,7 @@ static inline void dio_zero_block(struct dio *dio, struct dio_submit *sdio, static int do_direct_IO(struct dio *dio, struct dio_submit *sdio, struct buffer_head *map_bh) { + const unsigned i_blkbits = dio->inode->i_blkbits; const unsigned blkbits = sdio->blkbits; int ret = 0; @@ -949,7 +950,7 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio, clean_bdev_aliases( map_bh->b_bdev, map_bh->b_blocknr, - map_bh->b_size >> blkbits); + map_bh->b_size >> i_blkbits); } if (!sdio->blkfactor) -- 2.5.5