Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3608988rdg; Tue, 17 Oct 2023 23:46:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEeLSTVb59ENEGVoCTYxtHVkLDj6zH9HV+WU4QvdSO4AHdB3vf46lP3f+/+Zcw8vCFWk6pb X-Received: by 2002:a17:902:d4ca:b0:1c8:7d21:fc63 with SMTP id o10-20020a170902d4ca00b001c87d21fc63mr4617014plg.56.1697611568505; Tue, 17 Oct 2023 23:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697611568; cv=none; d=google.com; s=arc-20160816; b=1FvTuFheWx539t6mlYTbBKAzWgPv6xz0tsb0Y4LN6nlYRVnGrIV3k2eKFM3ZopV5Xk iKnb5carO2BKFaQ2tczsu/2BoxeJMwSkW/8YFbe0L/EDRu8m2XOuRa6eu5YhwVcGoYiD Mvk9nLkvTfylLnaw3/8TCmsV+4P8BUsdH0lWhyqVk1rb+TKWSmlIyj6SG4XCNftZ067Q OUSjPtc4sOjaXZrMnBGDAClLKqnNrpi7QEUI3NOqinI1tdaSl3nTTlrlrONvnUA6Hnwv dO1hIdWtQnMkIbYjxMRgu7V7Sl1VLGAMKbOYiwC52oPE8jUcRLdSoteNL9SOrwnYpy2M s32Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=T+mkoCOxlBnE8cdgGUySBzxZS9WRePfqdR6MBbpz2KM=; fh=nmSXGJcXKNURkXeWft4NszEA1zyyM+5fw1SPMeTsV9o=; b=ukBDj1HnRngKK++yFygOaKhme3VcrXrWyCZlu+j5hQAJ1OPHvuZ3dQvQnuua1l0rXc 0XyEox6tqwumJyQ3hlR9eWS3hBNOztn0OTKgVcuK3mKJJP5GpZ+wZF4vrdguitiAMsL/ HdunzsY+I+FJZpTD9CcYzYRZyHR9l6C4S314O5c6+ev0DdAMzD+D20cmAL+GhfHhmSME slMck915xoEcIG4wGetIf+q6l5WgZS4793hNKO4nRm4yuRpvyRpIMM5PYhCnYmyJACz2 zh1h3RUl54TpAdimOcm79u7zNL470CePsIr6N6KBYMhBbuDliz7q3d/pWMBVWpNerg+C VGoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S5uXuVtB; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id s14-20020a170902ea0e00b001c77e00809csi3520787plg.453.2023.10.17.23.46.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 23:46:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S5uXuVtB; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 1990180FE940; Tue, 17 Oct 2023 23:46:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229745AbjJRGp6 (ORCPT + 99 others); Wed, 18 Oct 2023 02:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229759AbjJRGp5 (ORCPT ); Wed, 18 Oct 2023 02:45:57 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48C0793 for ; Tue, 17 Oct 2023 23:45:55 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-27d2b814912so3732477a91.0 for ; Tue, 17 Oct 2023 23:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697611554; x=1698216354; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=T+mkoCOxlBnE8cdgGUySBzxZS9WRePfqdR6MBbpz2KM=; b=S5uXuVtBrOmDlg/7WnH4EPtgRnlUcOSmyPTdaQeomVinSoZbikRbflvA+3MlY2ezEy H0hRzQ6jwfY0kZbXvN9J+shac2TdSNO1zD/AIkmcIbhlvosctdqebpl64wSrldVz/BGL Py+X4V5t94sTIA40NDIbIo309kIsu9jEHWLQpnyMdA33D46BHqO0r3BZL+oHr9WbkVl8 x5abh808MtEH3AHuftzfYypVBwZnYdr4dpyS2b16QhCeM8p2b29fMtP19PPoR4iVcKSA O3o79hi6RoeLDMRpBEqe7P8K9wa0S7t9m5x616XrGJ53y+mCBx7QqukRENKu4CJ3FDJt I2ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697611554; x=1698216354; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=T+mkoCOxlBnE8cdgGUySBzxZS9WRePfqdR6MBbpz2KM=; b=v5ajMQJsQJfEyJJX3hUxHqLx2qCtLDsdx1EFTdagDGsgfires+1bfakaxgm7C0UKgW 24xJByljciwCPblEG7NibXvg2HRMeNSY2D7HO6/1CftD+s434VdfxC9SHj5/JIpth2j2 +QDOHs9nF81eggFkZYNRpeNgdkrT9Q34nigAMJKwxbQlkj7u4tzIFQYfpPDVTpmnA3EF gaKG0NkFCkBrwG/jD/6fCH8UqWFowEz2O7O1psZZebpdgpapW9qB8gw/dhVYAbAOmU5Q oChWRSeKwj5Ma7IMlZwJsA3Z0iItxpGTlA5x9I4YnCYNsgS7bliGU3J3o20ZDwZkeWNi 6wfQ== X-Gm-Message-State: AOJu0Yyi5jw4YVILAe6EjEP/ZA4q8DBRyc/lXhpB3KaNeAFDxs0MP1/M l+th044lHcgiPbWCCNIlmO4= X-Received: by 2002:a17:90a:8041:b0:273:b0bd:343b with SMTP id e1-20020a17090a804100b00273b0bd343bmr4421701pjw.41.1697611554559; Tue, 17 Oct 2023 23:45:54 -0700 (PDT) Received: from [30.221.128.109] ([47.246.101.61]) by smtp.gmail.com with ESMTPSA id 29-20020a17090a035d00b00273744e6eccsm663032pjf.12.2023.10.17.23.45.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Oct 2023 23:45:54 -0700 (PDT) Message-ID: Date: Wed, 18 Oct 2023 14:45:49 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v3] ext4: Properly sync file size update after O_SYNC direct IO Content-Language: en-US To: Jan Kara , Ted Tso Cc: linux-ext4@vger.kernel.org, "Ritesh Harjani (IBM)" , Gao Xiang , Dave Chinner , Joseph Qi References: <20231013121350.26872-1-jack@suse.cz> From: Joseph Qi In-Reply-To: <20231013121350.26872-1-jack@suse.cz> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 17 Oct 2023 23:46:06 -0700 (PDT) On 10/13/23 8:13 PM, Jan Kara wrote: > Gao Xiang has reported that on ext4 O_SYNC direct IO does not properly > sync file size update and thus if we crash at unfortunate moment, the > file can have smaller size although O_SYNC IO has reported successful > completion. The problem happens because update of on-disk inode size is > handled in ext4_dio_write_iter() *after* iomap_dio_rw() (and thus > dio_complete() in particular) has returned and generic_file_sync() gets > called by dio_complete(). Fix the problem by handling on-disk inode size > update directly in our ->end_io completion handler. > > References: https://lore.kernel.org/all/02d18236-26ef-09b0-90ad-030c4fe3ee20@linux.alibaba.com > Reported-by: Gao Xiang > CC: stable@vger.kernel.org > Fixes: 378f32bab371 ("ext4: introduce direct I/O write using iomap infrastructure") > Signed-off-by: Jan Kara Tested with the reproducer after applying to 6.6-rc5, Tested-by: Joseph Qi BTW, once backported to older kernel like 5.10, it seems that it depends on the following commit: 936e114a245b iomap: update ki_pos a little later in iomap_dio_complete Otherwise, it will fail the following xfstests cases: generic/091 generic/094 generic/225 generic/263 generic/311 generic/617 Thanks, Joseph