Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp2681643rwe; Sun, 16 Apr 2023 03:11:07 -0700 (PDT) X-Google-Smtp-Source: AKy350anlJYcHP087nTM6oAxm0lcbmzz468DcOWRatV4uZTULbFcr0SN3LRnRJc9ZRwUTGuwTS+z X-Received: by 2002:a05:6a20:3d8c:b0:ee:e0d8:515d with SMTP id s12-20020a056a203d8c00b000eee0d8515dmr5995852pzi.46.1681639867385; Sun, 16 Apr 2023 03:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681639867; cv=none; d=google.com; s=arc-20160816; b=tO0+uNxbQeyhTPfh8/dc1fdEYEe1t2RL9xoyz9bJtqnNnRi3e42leTsD5ydKCWX7t6 i/hP/JBUT7JfpfxcT3UQ8Ci/QbO/D0dJbEHz50TOaf7OpuBHi/4kcT0zt9ngSSY/fnwh bBmGODCV4ADTXVgDs2fQcqhIIOcPh6zkIrf8bzNCnHOazTBpfj/vcg6/naYdQ0FOHB77 lqZ7CdJMXoHbPGUoB13M0pwIBD5ZhcI30/jSkIb642qJzu5RrLySI2XIZ4U47sAzAW7d f+Jxr7Q7/maNzMoDf3GnbO/bKuhdYs6CUB5AWq+uQwdWy3N1JCyijDdBzP4ma4gudXlI odoA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Cy+/pZaqvES6mObQuwzhCbnK8v685tx7A3EGdbbD7vE=; b=nI1y3zSUTWdxYV7x0F44TH8vhjIZAGIHpr1sF75hXzDoGjLmPZRgEOpgKFIfooeMfs vdDmoCFx+gX26K4WcdwNDm566YZ6jCYDJyG2RQ+7410+2paN5NFFfkjxs0Ncysx+jbvr EEMFIzY4/edJTXcKoVZFZ9G8C6UlOClbkwhofjqBOQ5E/3BONrB0OeOMnOSEu0FE+Ze0 gmeBd4raqj2o+glwUNJ8sBfmS+KwOMlnp04FyLetOjXpm82FqX3onARPxnbwKYgFPUpO 9gC2YlCvzNoARs28Ft864KT9NPpvL7uyhJX1WB2XSYpVlZP7EK+Mab0kUxXIt9MfgDYa rZFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=sFVOCZvg; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c8-20020a63ef48000000b0050c0e269719si8660005pgk.513.2023.04.16.03.10.55; Sun, 16 Apr 2023 03:11:07 -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=@gmail.com header.s=20221208 header.b=sFVOCZvg; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229942AbjDPKJV (ORCPT + 99 others); Sun, 16 Apr 2023 06:09:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbjDPKJH (ORCPT ); Sun, 16 Apr 2023 06:09:07 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A428E1; Sun, 16 Apr 2023 03:09:05 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-63b50a02bffso929710b3a.2; Sun, 16 Apr 2023 03:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681639744; x=1684231744; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cy+/pZaqvES6mObQuwzhCbnK8v685tx7A3EGdbbD7vE=; b=sFVOCZvgOoyY9NGPPtB0d+zQyuvyGVVB8xuvCqdMph1GwbNTgjBemAntLoEPebFRIm GPHjB5clBKS6OYqYxQAVpMLmO7elE10NZGRec6i0RlE4jufv4Kc0Y3pdFmsCn/ah85Li OIRT2wzCKnvvVN/Dczf4KICJHzpjaApOckevPaJzsa2paQCrFIZpc7MTiTgQpCOs+7L1 RyI7aq9aQ7nB7LccavTQV08dpoc6QuOuOzoeHEXs1PEuwhh0DuHR1pFdPPw+gVDxiJIf uB18h3Be3uu+LfCyX5NHm72sKwRflbZJz7r2hXy+z1nGf1ULiYCgdTNphj2TedGec9L/ u+7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681639744; x=1684231744; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cy+/pZaqvES6mObQuwzhCbnK8v685tx7A3EGdbbD7vE=; b=gafHpcr1NIdXRpaqYT4vWESJdrGA/T46BD2UXPVh7xV3R4edazaIVfWj6vLIBdceKy QGGoZbiO1oXrDL6Hj/Nk4QpYlHkIJFG7jZiKzpek9W6LosZl86h2mvfZqLb1i52XK/fX 9rMfPuBDNeKpTNLpD6bXlfhLT/otwHAraj0ij7oKxAq7egbc1F7lGPTh1CQIC/Logwap TnS8L9QtnmWM7tHwYWzQlgaBiPsXU7Sv01ckW866NNukoPUEFmRXYVfdcuQlsgsPrZFW ZgoHdQW06AczvaGsQHPhTsc8kJgpiTDbocfUHeWmuGqT5KvfzMYCeoE5/wOV3CtWw0Zb r3ew== X-Gm-Message-State: AAQBX9eX45H4XuhGwDBgNCe8xrIl52t/gCQ7Jm8O+A6vA1i2Jq03c5/P IVMte+71dih/DKvqDQNvaYPXELDxKr4= X-Received: by 2002:a05:6a00:1306:b0:63b:435f:134a with SMTP id j6-20020a056a00130600b0063b435f134amr15120915pfu.28.1681639744695; Sun, 16 Apr 2023 03:09:04 -0700 (PDT) Received: from rh-tp.. ([2406:7400:63:2dd2:1827:1d70:2273:8ee0]) by smtp.gmail.com with ESMTPSA id h9-20020aa786c9000000b0063b733fdd33sm3096057pfo.89.2023.04.16.03.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Apr 2023 03:09:04 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org Cc: Jan Kara , Christoph Hellwig , "Darrick J . Wong" , Ojaswin Mujoo , Disha Goel , "Ritesh Harjani (IBM)" Subject: [PATCHv5 3/9] ext4: Use generic_buffer_fsync() implementation Date: Sun, 16 Apr 2023 15:38:38 +0530 Message-Id: <5dc8b7ad59fe836e72d5408261470f3b4caaebb2.1681639164.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 ext4 when got converted to iomap for dio, it copied __generic_file_fsync implementation to avoid taking inode_lock in order to avoid any deadlock (since iomap takes an inode_lock while calling generic_write_sync()). The previous patch already added generic_buffer_fsync() which does not take any inode_lock(). Hence kill the redundant code and use generic_buffer_fsync() function instead. Tested-by: Disha Goel Signed-off-by: Ritesh Harjani (IBM) --- fs/ext4/fsync.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c index 027a7d7037a0..4f2af43f8b0f 100644 --- a/fs/ext4/fsync.c +++ b/fs/ext4/fsync.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "ext4.h" #include "ext4_jbd2.h" @@ -78,21 +79,13 @@ static int ext4_sync_parent(struct inode *inode) return ret; } -static int ext4_fsync_nojournal(struct inode *inode, bool datasync, - bool *needs_barrier) +static int ext4_fsync_nojournal(struct file *file, loff_t start, loff_t end, + int datasync, bool *needs_barrier) { - int ret, err; - - ret = sync_mapping_buffers(inode->i_mapping); - if (!(inode->i_state & I_DIRTY_ALL)) - return ret; - if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) - return ret; - - err = sync_inode_metadata(inode, 1); - if (!ret) - ret = err; + struct inode *inode = file->f_inode; + int ret; + ret = generic_buffer_fsync(file, start, end, datasync); if (!ret) ret = ext4_sync_parent(inode); if (test_opt(inode->i_sb, BARRIER)) @@ -148,6 +141,14 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) goto out; } + if (!sbi->s_journal) { + ret = ext4_fsync_nojournal(file, start, end, datasync, + &needs_barrier); + if (needs_barrier) + goto issue_flush; + goto out; + } + ret = file_write_and_wait_range(file, start, end); if (ret) goto out; @@ -166,13 +167,12 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) * (they were dirtied by commit). But that's OK - the blocks are * safe in-journal, which is all fsync() needs to ensure. */ - if (!sbi->s_journal) - ret = ext4_fsync_nojournal(inode, datasync, &needs_barrier); - else if (ext4_should_journal_data(inode)) + if (ext4_should_journal_data(inode)) ret = ext4_force_commit(inode->i_sb); else ret = ext4_fsync_journal(inode, datasync, &needs_barrier); +issue_flush: if (needs_barrier) { err = blkdev_issue_flush(inode->i_sb->s_bdev); if (!ret) -- 2.39.2