Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2711129rdb; Fri, 22 Sep 2023 06:34:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcO2B4OLCZWTI4PrIhbzpZq/jLids4MhCjTVkUth5YRA7TYgxjkdqgbz9ztkXiKYgp47ld X-Received: by 2002:a05:6359:5141:b0:143:864e:f969 with SMTP id oc1-20020a056359514100b00143864ef969mr5763366rwb.6.1695389676159; Fri, 22 Sep 2023 06:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695389676; cv=none; d=google.com; s=arc-20160816; b=sHtCz53zxd9+IdcDJJ9Q3I3X8PchHG7gT2hG+ak/W1Lfo9L1iSrKOmz24XQihYYxqh +mzYzbgOCZ2QRxNZ9CZECSrYl9HRDpV7u9w2/snhv6Bt/j5j6AIs9G0wuQ7n6EUSFDx0 Z/qYfdPpkgLWKR7NVHYEWhSOaIF9wFRd5aiC6fyUM+dPwRmv4fA/otpHvJi7FTlnE7zK ZJW5gtIdrHRP+eA5TBCuguz5DjtWyvvmNQzk2GmlmjvarHF5+UdBHcxvWNnxmoCu3wW2 MqFaTGA/oL5eN/Cxh1sb/6HYLQBBbgNS5pLQz2dGpIIHLvjBevO7+tNjhtwMdxd8RoqN 0z4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:subject:cc:to:from:message-id:date :dkim-signature; bh=+rZBTXldh6fGcLXPDs1Aq0nPjZAfErnl8acbOhRd+nE=; fh=BkDwAu5D/PgtnIbAVwH3Wxlwbsdod/m/hUScoMYvCgE=; b=EEA0eLGJx887dN+dni4hdtfzSHzbuoTedhWenSB1Q88kR3yLGq9fgMR8Ru+9WD3aXh 9IAbfc/NAObj4eqDkJXHcU3vzscNM8QBZgNqreyYrewUNTZ6ewS01fWnHHzEC1T7Kh0m vniKvA/fm3tP7UsX1/6aFlaX5Qml6mUqPVUsiJTY4rBZj7BN26Y4dcrFT2PYKCsbt4e6 S0w/hBBFKSswi1UixmapjBfB62hK1kfJh62xc2h1M5y+uUfR4QdQIYwLR1FBbxgn65jh fAgCm46ZGFmvcXSOeHEvlkL7cvBWlaWviIweLoZngtCeCbBgAYnWv4OtFzFZVLTVT7I3 4cng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="MCzt/YX2"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id a5-20020a655c85000000b00569374c7c71si3524236pgt.857.2023.09.22.06.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 06:34:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="MCzt/YX2"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 3A0D982CECAA; Fri, 22 Sep 2023 05:04:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234032AbjIVMEW (ORCPT + 99 others); Fri, 22 Sep 2023 08:04:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234080AbjIVMEM (ORCPT ); Fri, 22 Sep 2023 08:04:12 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01D66100 for ; Fri, 22 Sep 2023 05:04:05 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-690bd8f89baso1816663b3a.2 for ; Fri, 22 Sep 2023 05:04:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695384244; x=1695989044; darn=vger.kernel.org; h=in-reply-to:subject:cc:to:from:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=+rZBTXldh6fGcLXPDs1Aq0nPjZAfErnl8acbOhRd+nE=; b=MCzt/YX2auqZI6X/TrI+CusTOn/1BDR13ifYt50NWFsQb8dXG+gWbTfQ+VnkDHesLQ NnINl3Q1QNn6GETQGUHIxB1/5f1EbvUp7/S6kGm/Eey2Fxc2MTZcyULX9r/kD8kbD5Y7 YNEAyNQicsraw87g4cnrRbz2ZsZagb2SkYAAOxnd5NbwjNodLsKH5z07NV4uhGuWHgLO MdpvX7ThbcFMgY/fO96kSik4Z0gU6zR/vHgl9+Z9D4BVtPRrlhaVajVEiUR36B9Bferh 4NshNb7ecuimWMzd0JXZldYV/mkUkUsky1RVUxnL9fzsY6kQlPM/SHqkFYoGabAVN4Ad bnog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695384244; x=1695989044; h=in-reply-to:subject:cc:to:from:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+rZBTXldh6fGcLXPDs1Aq0nPjZAfErnl8acbOhRd+nE=; b=ovp6q5Em/DT0ZEwBtrIBYHotWgRNe11C4EEkVjLSvMKalesL3zAZZVcxQL9wgHQ5vG 5wEeehxiBhAmdrG+jJ6m/JEa4EJrJiKZ4KVvil2lf+s433HNd5k5kUxmnG78btNRg7kn ErTuIHONh8xjKAfBxG17AAbO5cvXm0SEUpLNIfx15PPlPXz2zB5B0ViHkcZnFj3VphPm WrnT/JlEOmRnMqyzneHPX+6yHxtqZoVNvSJxB0jqL/Q82/ds2c2wS19nQ2xOoeQWxKiQ PHbHs+DCCC5nwx3XYcEcQmCm0B5clXuGFuPFcKXq0+vgejICdo4mm1rJJg74J2mq6c+r W6/A== X-Gm-Message-State: AOJu0Yy+xgZM0nJNRngB17dWwUc6nGFh8GcgFum7LcOEzbXsYdDm4/hb 5o6ikeTm3NyiKeTi35NJj1Y= X-Received: by 2002:a05:6a00:1350:b0:68f:efc2:ba46 with SMTP id k16-20020a056a00135000b0068fefc2ba46mr9673588pfu.25.1695384244155; Fri, 22 Sep 2023 05:04:04 -0700 (PDT) Received: from dw-tp ([49.207.223.191]) by smtp.gmail.com with ESMTPSA id b13-20020aa7810d000000b0068fb9965036sm3023874pfi.109.2023.09.22.05.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 05:04:03 -0700 (PDT) Date: Fri, 22 Sep 2023 17:33:59 +0530 Message-Id: <87y1gy5s9c.fsf@doe.com> From: Ritesh Harjani (IBM) To: Jan Kara Cc: Jan Kara , Gao Xiang , linux-ext4@vger.kernel.org, Theodore Ts'o , Matthew Bobrowski , Christoph Hellwig , Joseph Qi Subject: Re: [bug report] ext4 misses final i_size meta sync under O_DIRECT | O_SYNC semantics after iomap DIO conversion In-Reply-To: <20230920152005.7iowrlukd5zbvp43@quack3> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 22 Sep 2023 05:04:22 -0700 (PDT) Jan Kara writes: > On Wed 20-09-23 17:08:19, Ritesh Harjani wrote: >> Jan Kara writes: >> >> > Hello! >> > >> > On Tue 19-09-23 14:00:04, Gao Xiang wrote: >> >> Our consumer reports a behavior change between pre-iomap and iomap >> >> direct io conversion: >> >> >> >> If the system crashes after an appending write to a file open with >> >> O_DIRECT | O_SYNC flag set, file i_size won't be updated even if >> >> O_SYNC was marked before. >> >> >> >> It can be reproduced by a test program in the attachment with >> >> gcc -o repro repro.c && ./repro testfile && echo c > /proc/sysrq-trigger >> >> >> >> After some analysis, we found that before iomap direct I/O conversion, >> >> the timing was roughly (taking Linux 3.10 codebase as an example): >> >> >> >> .. >> >> - ext4_file_dio_write >> >> - __generic_file_aio_write >> >> .. >> >> - ext4_direct_IO # generic_file_direct_write >> >> - ext4_ext_direct_IO >> >> - ext4_ind_direct_IO # final_size > inode->i_size >> >> - .. >> >> - ret = blockdev_direct_IO() >> >> - i_size_write(inode, end) # orphan && ret > 0 && >> >> # end > inode->i_size >> >> - ext4_mark_inode_dirty() >> >> - ... >> >> - generic_write_sync # handling O_SYNC >> >> >> >> So the dirty inode meta will be committed into journal immediately >> >> if O_SYNC is set. However, After commit 569342dc2485 ("ext4: move >> >> inode extension/truncate code out from ->iomap_end() callback"), >> >> the new behavior seems as below: >> >> >> >> .. >> >> - ext4_dio_write_iter >> >> - ext4_dio_write_checks # extend = 1 >> >> - iomap_dio_rw >> >> - __iomap_dio_rw >> >> - iomap_dio_complete >> >> - generic_write_sync >> >> - ext4_handle_inode_extension # extend = 1 >> >> Yes, since ext4_handle_inode_extension() will handle inode i_disksize >> update and mark the inode dirty, generic_write_sync() call should happen >> after that. >> >> That also means then we don't have any generic FS testcase which can >> validate this behaviour. > > Yeah. > Ok. Let me then first send a fstest in response to this integrity problem with directio and o_sync. -ritesh