Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2001096rwr; Fri, 21 Apr 2023 02:47:52 -0700 (PDT) X-Google-Smtp-Source: AKy350bTW2V5e8a3ioBScv3noV9Iwpz4bwcjiMaZuxas5u/GXC4C5G6zs4lR3/dU49nu9VF5GvHl X-Received: by 2002:a05:6a20:7d8a:b0:f2:13cc:2914 with SMTP id v10-20020a056a207d8a00b000f213cc2914mr5568767pzj.16.1682070472283; Fri, 21 Apr 2023 02:47:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682070472; cv=none; d=google.com; s=arc-20160816; b=Pz8RlCDvCy0Uif0xqjDwomWMsqLWfLYg9pIGwog0HETKxDEkfpuAHiJl1Rjkw7A9h7 hYcezCwtw203+wNHMmqWX5X+p0zexY3C/XbE03nesH5h8d+kbcuDZrop8dzsRDCf4yd7 aZWX9KVKkB640mBYgd7PhQsjU2N7xsFmk7BhYQl7mO0v6GzfqvAttXvl7hERPJ6mjBjx jwdmdCI7aGGdOBymesnu+oJO0EC4gQmd6DjCsBgcS3aaF9qEzZb9/9vktwr629qG6nno bxuf4FK+gMIGD3SPG9OuqwX+i1iJ1n3wacjASp8CA7vtaM3oKT3bW+XCmTtnnIF14rfJ XOAw== 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=lBzbpAT6GWFJ1E3/348QGYQinhR9T2h2jmeonxN6r48=; b=peHkNYtmM9cc4X1X/AEV8eODvE0mGvloFE95OC2KWcY/Iu94o/z8rTVjbfVA94qMAx /C5tYFJn1NVbfx1ZScxpnuTes7PfyW8ihu0o8w0f+5Gk77qkOjd4dzDy7s0bsIEQz67A s7PRefM798B0wpxLr5VJRCEI7BczbqL8ynS/cpgTpyxnZFDTAslzyDk302fU8lg+Gq5F zokB5xR//ZmPz+WY30TKTcRhezbXSqpYLaF6IKZgdvXZbzL9Rn4s1rQe0NSHn5VVCYIW ooPY6yuTQf0wC7VpY9ZG21ZfVxPEyjm/4VH+4GJBwqMYHbHRqC59UUdCjd6vPxb0JmvA 75qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=c1UMZGuF; 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 w4-20020a63c104000000b0051b5974f978si3739600pgf.313.2023.04.21.02.47.37; Fri, 21 Apr 2023 02:47:52 -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=c1UMZGuF; 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 S232068AbjDUJra (ORCPT + 99 others); Fri, 21 Apr 2023 05:47:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232040AbjDUJrY (ORCPT ); Fri, 21 Apr 2023 05:47:24 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B5B5B76F; Fri, 21 Apr 2023 02:46:47 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-63b5465fb99so1817631b3a.1; Fri, 21 Apr 2023 02:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682070398; x=1684662398; 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=lBzbpAT6GWFJ1E3/348QGYQinhR9T2h2jmeonxN6r48=; b=c1UMZGuFljMyz1y7sLgBz/d+a4UgIEANJsKbvvKqMBQWr9o8nNf/NvVMhsxWvaSudm 5lGftvcw46701xICjUTnnYCbZhIb4XnKqSTzGRGAo3McoDcOVvfbb/l1c96MM5IcLxaw oj985KaiIYFDk1ySojMHOOeyefu/VhcxI+LYwKCHhvm4l1Q2MuGZRskFY0xlOgFkemCD ZEb4EkhBZ8MtvzdWavSKimCoy96kgM6mFDFlb1BRGDYTpKNwr+24AJIlINgbJEeB5ad2 4ZT/A7w0+sMPhUE/qUxVHqm+2DyhLEhkXPPcsF21Kb9102VO6EfXQoJVU9IFkySvm+qV U4ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682070398; x=1684662398; 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=lBzbpAT6GWFJ1E3/348QGYQinhR9T2h2jmeonxN6r48=; b=RRiJ/xlaFdiwCGYAC79kCmiZtZppbi3nx9hP7LRxXHV5cJFb2ZBawurTFUTyz9x5c5 W/kHuni8bCHqLyllp81iepuaY7j3bhlnP/ciunfTwBmTGMi48gLDcz1ig3KdDzkb3KKd 45mOHvLJAJafzZnbUVSaUYrW4n0Ui+vRVieN+A9k92kmVJbYGclma9E6g30JP/oYfxcB t/KroQ1zGHCNHLDYywpFZdcJrAQFKDtQ7a+V8ZYDa4iPEE+gUf7oJqabcBR8JWr8Jvv0 gOU1nWW87Y8xhVv3Ti+MXJaKVkTWw5ZF/qnxgn5y5c8wG3Ltmx5tfLRmLjHwGq7xwjZJ Rakg== X-Gm-Message-State: AAQBX9cDlcLvDwBvls9ZPrVOcFRI3SghORaILbEADSZZLwCxOGgvke2T s/5/Xj8NV2oof6WA+ark0P9g7KEftkc= X-Received: by 2002:a05:6a20:8f1b:b0:ef:e440:8aac with SMTP id b27-20020a056a208f1b00b000efe4408aacmr6397552pzk.39.1682070397719; Fri, 21 Apr 2023 02:46:37 -0700 (PDT) Received: from rh-tp.. ([2406:7400:63:2dd2:8818:e6e1:3a73:368c]) by smtp.gmail.com with ESMTPSA id w35-20020a631623000000b0051f15c575fesm2295376pgl.87.2023.04.21.02.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 02:46:37 -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: [PATCHv6 3/9] ext4: Use generic_buffers_fsync_noflush() implementation Date: Fri, 21 Apr 2023 15:16:13 +0530 Message-Id: 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_buffers_fsync*() which does not take any inode_lock(). Hence kill the redundant code and use generic_buffers_fsync_noflush() function instead. Tested-by: Disha Goel Signed-off-by: Ritesh Harjani (IBM) --- fs/ext4/fsync.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c index f65fdb27ce14..9cd71d76622d 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_buffers_fsync_noflush(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; @@ -157,11 +158,9 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) * Metadata is in the journal, we wait for proper transaction to * commit here. */ - if (!sbi->s_journal) - ret = ext4_fsync_nojournal(inode, datasync, &needs_barrier); - else - ret = ext4_fsync_journal(inode, datasync, &needs_barrier); + 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