From patchwork Mon Jan 9 21:42:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Moyer X-Patchwork-Id: 9505989 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A4A1C606E1 for ; Mon, 9 Jan 2017 21:43:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96F552831C for ; Mon, 9 Jan 2017 21:43:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 889892852D; Mon, 9 Jan 2017 21:43:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2807B2831C for ; Mon, 9 Jan 2017 21:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753962AbdAIVnA (ORCPT ); Mon, 9 Jan 2017 16:43:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48238 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750978AbdAIVm7 (ORCPT ); Mon, 9 Jan 2017 16:42:59 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 173F66830; Mon, 9 Jan 2017 21:43:00 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v09LgwRZ012102 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Jan 2017 16:42:59 -0500 From: Jeff Moyer To: axboe@kernel.dk, Chandan Rajendra Cc: jack@suse.cz, 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] direct-io: don't introduce another read of inode->i_blkbits References: <1483886830-23878-1-git-send-email-chandan@linux.vnet.ibm.com> X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 X-PCLoadLetter: What the f**k does that mean? Date: Mon, 09 Jan 2017 16:42:58 -0500 In-Reply-To: <1483886830-23878-1-git-send-email-chandan@linux.vnet.ibm.com> (Chandan Rajendra's message of "Sun, 8 Jan 2017 20:17:10 +0530") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 09 Jan 2017 21:43:00 +0000 (UTC) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 20ce44d545844 ("do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned") introduced a regression: if the block size of the block device is changed while a direct I/O request is being setup, it can result in a panic. See commit ab73857e354ab ("direct-io: don't read inode->i_blkbits multiple times") for the reasoning, and commit b87570f5d3496 ("Fix a crash when block device is read and block size is changed at the same time") for a more detailed problem description and reproducer. Fixes: 20ce44d545844 Signed-off-by: Jeff Moyer Tested-by: Chandan Rajendra --- Chandan, can you please test this to ensure this still fixes your problem? -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/direct-io.c b/fs/direct-io.c index b20adf9..c87bae4 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -905,8 +905,8 @@ 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; + const unsigned i_blkbits = blkbits + sdio->blkfactor; int ret = 0; while (sdio->block_in_file < sdio->final_block_in_request) {