From patchwork Wed Jul 25 21:15:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10544761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7F211822 for ; Wed, 25 Jul 2018 21:15:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E4572AB4A for ; Wed, 25 Jul 2018 21:15:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 925EC2AB7B; Wed, 25 Jul 2018 21:15:57 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 3171C2AB4A for ; Wed, 25 Jul 2018 21:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731328AbeGYW30 (ORCPT ); Wed, 25 Jul 2018 18:29:26 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:39826 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731174AbeGYW30 (ORCPT ); Wed, 25 Jul 2018 18:29:26 -0400 Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Wed, 25 Jul 2018 15:15:48 -0600 From: Martin Wilck To: Jens Axboe , Jan Kara , Christoph Hellwig , Ming Lei Cc: Hannes Reinecke , Johannes Thumshirn , Kent Overstreet , linux-block@vger.kernel.org, Martin Wilck Subject: [PATCH v5 0/3] Fix silent data corruption in blkdev_direct_IO() Date: Wed, 25 Jul 2018 23:15:06 +0200 Message-Id: <20180725211509.13592-1-mwilck@suse.com> X-Mailer: git-send-email 2.17.1 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 Hello Jens, Ming, Jan, and all others, the following patches have been verified by a customer to fix a silent data corruption which he has been seeing since "72ecad2 block: support a full bio worth of IO for simplified bdev direct-io". The patches are based on our observation that the corruption is only observed if the __blkdev_direct_IO_simple() code path is executed, and if that happens, "short writes" are observed in this code path, which causes a fallback to buffered IO, while the application continues submitting direct IO requests. Following Ming's suggestion, I've changed the patch set such that bio_iov_iter_get_pages() now always returns as many pages as possible. This simplifies the patch set a lot. Except for __blkdev_direct_IO_simple(), all callers of bio_iov_iter_get_pages() call it in a loop, and expect to get just some pages. Therefore I have made bio_iov_iter_get_pages() return success if it can pin some pages, even if MM returns an error on the way. Error is returned only if no pages at all could be pinned. This also avoids the need for cleanup code in the helper - callers will submit the bio with the allocated pages, and clean up later as appropriate. Regards, Martin Changes wrt v4: - 3/3: replaced bio_iov_iter_get_pages() with the new helper (Ming, Christoph) - 4/4 dropped: this way, no changes to fs/block_dev.c are necessary any more except for the leak fix. Changes wrt v3: - split previous 3/3 into two patches (3/4, 4/4). - 3/4: add a new helper to retrieve as many pages as possible (Ming) - 3/4: put pages in case of error (Ming) Changes wrt v1: - 1/3: minor formatting change (Christoph) - 2/3: split off the leak fix (Ming) - 3/3: give up if bio_iov_iter_get_pages() returns an error (Jan) - 3/3: warn if space in bio exhausted (Jan) - 3/3: add comments Martin Wilck (3): block: bio_iov_iter_get_pages: fix size of last iovec blkdev: __blkdev_direct_IO_simple: fix leak in error case block: bio_iov_iter_get_pages: pin more pages for multi-segment IOs block/bio.c | 53 +++++++++++++++++++++++++++++++++++++------------- fs/block_dev.c | 9 +++++---- 2 files changed, 45 insertions(+), 17 deletions(-)