From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35AD8C04AAF for ; Mon, 20 May 2019 09:51:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D0FE20675 for ; Mon, 20 May 2019 09:51:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558345884; bh=6AThL1aVYKMtZhMXf2dbDgufHntxdwvasXmrIQxFPqk=; h=Subject:To:Cc:From:Date:List-ID:From; b=hu7/hOfQ9bhbnBNpIvHuAReg6RPj9TwSgYEyFnSoT76/li3CDgpqsDCq/RR2yb/7l onTz3B9e8a2QfTsLluWagh6U2WQqw9RtsEo5YrBrbtyLRNOpE9cR6Y3wVWgx6JmJ2p hSQ92Y6nEbYoO6PzlTpc7GgmjhMHkDgp7TD01CbU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730353AbfETJvX (ORCPT ); Mon, 20 May 2019 05:51:23 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:35469 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729847AbfETJvX (ORCPT ); Mon, 20 May 2019 05:51:23 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 88EFF23A31; Mon, 20 May 2019 05:51:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 20 May 2019 05:51:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=PS8evO 0l53deOafiDMjwchQMigj/oxoyDFwpgSgVTyc=; b=KAGf9JcAfO4yqvMtjB0N1f i8cYBBQ26S5YhTk/GTKjbCFc/4sHCdK1a+ynilCglRm0AkQMU+BtEPjXq5le1j0b d6H81glL8PDBdXsXce+L1HwsHA8PsxJTrec2VqgsLSVCvcq75o7bDZT0DC3Wq4RI lVnASY6bjckd01LeY6jDh3wG4KtJ7qVyl4mRs42fApWk0n+cpQvb24h6Xkqpt59g ChODWSUKTpA0Icx0u+D6Gxld1e8WZqmftVYYCy1DXFBOrsikKIIH4KazKDZALKkF 3Xyr7DTV4KccCWRRWejZg88Ff8aIw9fek13uQf4+Cyrr8yn6y452usFlNtwUrmyA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddtkedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvffhfffkgggtgfesthekredttd dtlfenucfhrhhomhepoehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhr gheqnecukfhppeekfedrkeeirdekledruddtjeenucfrrghrrghmpehmrghilhhfrhhomh epghhrvghgsehkrhhorghhrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 9CA0E10379; Mon, 20 May 2019 05:51:21 -0400 (EDT) Subject: FAILED: patch "[PATCH] ext4: fix data corruption caused by overlapping unaligned and" failed to apply to 4.4-stable tree To: lczerner@redhat.com, tytso@mit.edu Cc: From: Date: Mon, 20 May 2019 11:51:20 +0200 Message-ID: <155834588016549@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.4-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 57a0da28ced8707cb9f79f071a016b9d005caf5a Mon Sep 17 00:00:00 2001 From: Lukas Czerner Date: Fri, 10 May 2019 21:45:33 -0400 Subject: [PATCH] ext4: fix data corruption caused by overlapping unaligned and aligned IO Unaligned AIO must be serialized because the zeroing of partial blocks of unaligned AIO can result in data corruption in case it's overlapping another in flight IO. Currently we wait for all unwritten extents before we submit unaligned AIO which protects data in case of unaligned AIO is following overlapping IO. However if a unaligned AIO is followed by overlapping aligned AIO we can still end up corrupting data. To fix this, we must make sure that the unaligned AIO is the only IO in flight by waiting for unwritten extents conversion not just before the IO submission, but right after it as well. This problem can be reproduced by xfstest generic/538 Signed-off-by: Lukas Czerner Signed-off-by: Theodore Ts'o Cc: stable@kernel.org diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 98ec11f69cd4..2c5baa5e8291 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -264,6 +264,13 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) } ret = __generic_file_write_iter(iocb, from); + /* + * Unaligned direct AIO must be the only IO in flight. Otherwise + * overlapping aligned IO after unaligned might result in data + * corruption. + */ + if (ret == -EIOCBQUEUED && unaligned_aio) + ext4_unwritten_wait(inode); inode_unlock(inode); if (ret > 0)