Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5578267rwd; Wed, 24 May 2023 04:03:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5wf1gPDE8Cg0LJnb2bTvMaitfYw46HCKZWYqMenxeol/nV/iqflVdzV8n7v5wqIYxe8E97 X-Received: by 2002:a17:90a:fa04:b0:255:6563:4867 with SMTP id cm4-20020a17090afa0400b0025565634867mr8829441pjb.1.1684926223582; Wed, 24 May 2023 04:03:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684926223; cv=none; d=google.com; s=arc-20160816; b=MmT2JYJwudYbcEcNprzPSXFhHi6VgeB/V5pCYmjDE+RxJAbmKsoZVm1xjbehbSS7mw B/nkpjL5Thw5EAileufFgJiNXtWgJwR5qG+UgWOSKAavF6VDemuFmYGOxswgCqOEG7DZ YwysOTI+hGbNMFwzT+w3UdiopPk5gxLIG44jfBKYRjzGRDRz1sEGGMrWosjo+PpyP+0w 6Hy/DkAXK+Nsbmc7G2qlCVf1IJz7o5JbJBFAmkJ8Cafya1N26J4+bTanbPJHpZhBolj+ Rxn9fXTxrWaXl8d614sJ+Nbk0s1Rd5SsGRcMB8WMmJSB7NMn+iNmIFmLypYAe0THptG4 Fq0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=oF66gYTB+QJSrVWI5RQG+Ao4fzWor/HhKUumZiTVkUY=; b=t++dduBb0yxbK9HPIpC7q64Xuqf8qohiDv/Jxy1Oh+r3hzADlwqkf/blQB59DoOqmV dyDhwjtIuYY16oLwBnVTXFfBV9TqDpgMlGxSsyQx5I0JbdqdEcZ9cbIyXDDye867dPBW zcUSDmb99OebbsWf8fo31PSD3DqzW3g+Ng5oucUlQ7FUt6bq8KszW6IqxA0ZSgBFAYNh wDVREAHvnhWkVNUT0JTQWN56gwpcVRzdZKZ+JUif/rSlQ5HRM2/NYdB7pN5p/4YcEQT/ hPBW+abXqYgqzLUy3ijiaqoWi7Uc35Kl+sopcC4gU1hkVjILCCUl49dwXMbx0aVltLER 7ZXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Zu0r1soR; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="k8+S6YJ/"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ob18-20020a17090b391200b0022915b6dd7asi1165991pjb.145.2023.05.24.04.03.27; Wed, 24 May 2023 04:03:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Zu0r1soR; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="k8+S6YJ/"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230006AbjEXKpB (ORCPT + 99 others); Wed, 24 May 2023 06:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbjEXKpA (ORCPT ); Wed, 24 May 2023 06:45:00 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A961598 for ; Wed, 24 May 2023 03:44:59 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6862E22216; Wed, 24 May 2023 10:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1684925098; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=oF66gYTB+QJSrVWI5RQG+Ao4fzWor/HhKUumZiTVkUY=; b=Zu0r1soRm7McpET6O/13sBoq40nW4Z7NDdCwU0Ibk2pTdtPbLcvHy0lPgI2uO1O29FDvPM 4xMJckKmR9SeDCyxSB5jrUf2Ta8fiOfUALe62iQm9XLNNRjH2puYSI+GmBXFPBWCmZ3fXD GTnXJRddJeZZ/ColGbOQIpWG+VqQXCM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1684925098; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=oF66gYTB+QJSrVWI5RQG+Ao4fzWor/HhKUumZiTVkUY=; b=k8+S6YJ/ZW7iDI3an2ZpZ5uWLlxXnDyBm2WxrOM1gdNTZQnLrxdYARkQMHQ3pGALLX/3aG kR5uwxvpyvWh9ZDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5B34A133E6; Wed, 24 May 2023 10:44:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6M89FqrqbWQ/LAAAMHmgww (envelope-from ); Wed, 24 May 2023 10:44:58 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id E101CA075C; Wed, 24 May 2023 12:44:57 +0200 (CEST) From: Jan Kara To: Ted Tso Cc: , Eric Whitney , Linux kernel regressions list , Jan Kara Subject: [PATCH] ext4: Fix fsync for non-directories Date: Wed, 24 May 2023 12:44:53 +0200 Message-Id: <20230524104453.8734-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1552; i=jack@suse.cz; h=from:subject; bh=CnRcWpd6OnMHLy8/NZ55lHLQg3F2ybI4ioyT51lJNHc=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBkbeqfFO1A3LPH9Paeik1Y+6+DlD10KnitiqDCrLSz 9ePz32iJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZG3qnwAKCRCcnaoHP2RA2Tn0B/ 93Mb+xkVoQjg2Ytljh2wgyrXZEvFWIaMcAL3Sg5W55KkcPSXFEN7OOc2l0kjnDiBy3DheRqu8iQ/7p g9zlvM9N0uWjuHwcnkTYlWh2GkLqm981gmg4dNHIT1H0mvrtk3BUDHtJY2vQsXj1w+8MJlp9tsB7kB GTChfaRfoZBkpHbZg0Gx3okbnLW4f/ijxDDXf4RaSSlDSglJP+AFGxHC4nVOLb6oBv1iTKqRYrE3yl pur7K3MTOLlBmBb9aLtmUVK/bCTGpc33jsvpDz9tNfZmSCa32OGKqdVjeoAqke4lpeQISeIyFcvYhy fquiGizVbTbUbbgkcnD9Q3197UMAXk X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Commit e360c6ed7274 ("ext4: Drop special handling of journalled data from ext4_sync_file()") simplified ext4_sync_file() by dropping special handling of journalled data mode as it was not needed anymore. However that branch was also used for directories and symlinks and since the fastcommit code does not track metadata changes to non-regular files, the change has caused e.g. fsync(2) on directories to not commit transaction as it should. Fix the problem by adding handling for non-regular files. Fixes: e360c6ed7274 ("ext4: Drop special handling of journalled data from ext4_sync_file()") Reported-by: Eric Whitney Link: https://lore.kernel.org/all/ZFqO3xVnmhL7zv1x@debian-BULLSEYE-live-builder-AMD64 Signed-off-by: Jan Kara --- fs/ext4/fsync.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c index f65fdb27ce14..2a143209aa0c 100644 --- a/fs/ext4/fsync.c +++ b/fs/ext4/fsync.c @@ -108,6 +108,13 @@ static int ext4_fsync_journal(struct inode *inode, bool datasync, journal_t *journal = EXT4_SB(inode->i_sb)->s_journal; tid_t commit_tid = datasync ? ei->i_datasync_tid : ei->i_sync_tid; + /* + * Fastcommit does not really support fsync on directories or other + * special files. Force a full commit. + */ + if (!S_ISREG(inode->i_mode)) + return ext4_force_commit(inode->i_sb); + if (journal->j_flags & JBD2_BARRIER && !jbd2_trans_will_send_data_barrier(journal, commit_tid)) *needs_barrier = true; -- 2.35.3