From patchwork Tue Apr 19 17:31:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1619184 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=a0qNuzLd; dkim-atps=neutral Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KjW8J4PNWz9sG0 for ; Wed, 20 Apr 2022 03:32:16 +1000 (AEST) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KjW8D5BDHz4xNl for ; Wed, 20 Apr 2022 03:32:12 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4KjW8D4zHXz4xXW; Wed, 20 Apr 2022 03:32:12 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=a0qNuzLd; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KjW8D4vYfz4xNl for ; Wed, 20 Apr 2022 03:32:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353729AbiDSReu (ORCPT ); Tue, 19 Apr 2022 13:34:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347669AbiDSReq (ORCPT ); Tue, 19 Apr 2022 13:34:46 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B83A936E26 for ; Tue, 19 Apr 2022 10:32:03 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id mp16-20020a17090b191000b001cb5efbcab6so2488387pjb.4 for ; Tue, 19 Apr 2022 10:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c9EWHIurp+luA1eBTvgbOU2mM9qsp11MaFFZL7olJgc=; b=a0qNuzLd9vOZHqr4+JECEusOWnFFpFv0TYEGp/8QNdg7129Nex27dSOTj47EJS57xR xD2ibX/G1qj2HuAP5t2k1CcMjweitRCVx71enzU4XA8g8it2lHHVnKZZY6PJANCF3wCp dvqQ9LOQBsyNs6BCVINsmM2fiNsuQilr5egSvzXBCYnTlsGC5ZCKBylNvF6ekKMJ6Jb4 oiE1NTFPnHfTLvi/SuXko+CAGAmT3UgNdgPuP01G4brS8P8ms1wm64hrABjZw2m4QHi6 17y6wCHGlHjlM5+bMb+WHdfEfQSTVsqnfuqK5VWyy7FrdJVcwCQAw1CFybdI3tqj2RTK IXzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c9EWHIurp+luA1eBTvgbOU2mM9qsp11MaFFZL7olJgc=; b=y75qIrepSb8DIccno63dBcxVpf/Y5htgbKbAGwv9xDEjmKh1UtgiN06XqFtrBKPAhD hFmYCRyaACyhGPDB2+dSWzye43pFAwKqB55gB5DpoorY5TQRxw0aikwtFUPGdSSvKPWr GEYdInuehEEP8TAPeOOw5osX2q0li2NTU5ygNvRgKMDPFpEvLjzjalWWaRzvJoie277i GJefn7Vd4HbBClsO4rRqfYzb+rgmBWCW3uPn/+v7YFX0fwF9ONe/UqnmZLSpm8u9VW+r 1N6mJiJNMXBdGqveCBKYaU5XR0pUHzA24ZCwFA8fYUkqYJvuNkFS+ZwKGFQltYmWHnvg Erqw== X-Gm-Message-State: AOAM532IrPfYfcwM2zVf0ZgZxjb3wQ0xW4Y5tymLifjkkXT/H+NcORVw 6rRIt16AerCSDjKKLSgjLbpM0dcBrX3/Xw== X-Google-Smtp-Source: ABdhPJzK2GzX2cNQNnF3aXhlaIEHF4wXGB8DV5c2q1mkGfAk/NuoWQxZWP0LypCCFDUN78xEyVddUw== X-Received: by 2002:a17:902:7e85:b0:158:c12f:d662 with SMTP id z5-20020a1709027e8500b00158c12fd662mr16718799pla.141.1650389522791; Tue, 19 Apr 2022 10:32:02 -0700 (PDT) Received: from harshads-520.kir.corp.google.com ([2620:15c:17:10:91ac:bc24:f886:dffc]) by smtp.googlemail.com with ESMTPSA id q9-20020a638c49000000b00398677b6f25sm17266093pgn.70.2022.04.19.10.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 10:32:02 -0700 (PDT) From: Harshad Shirwadkar X-Google-Original-From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: riteshh@linux.ibm.com, jack@suse.cz, tytso@mit.edu, Harshad Shirwadkar Subject: [PATCH v3 1/6] ext4: convert i_fc_lock to spinlock Date: Tue, 19 Apr 2022 10:31:38 -0700 Message-Id: <20220419173143.3564144-2-harshads@google.com> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419173143.3564144-1-harshads@google.com> References: <20220419173143.3564144-1-harshads@google.com> MIME-Version: 1.0 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 From: Harshad Shirwadkar Convert ext4_inode_info->i_fc_lock to spinlock to avoid sleeping in invalid contexts. Signed-off-by: Harshad Shirwadkar Reviewed-by: Jan Kara --- fs/ext4/ext4.h | 7 +++++-- fs/ext4/fast_commit.c | 22 ++++++++++------------ fs/ext4/super.c | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 1d79012c5a5b..46ca0979e73b 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1065,8 +1065,11 @@ struct ext4_inode_info { /* Fast commit wait queue for this inode */ wait_queue_head_t i_fc_wait; - /* Protect concurrent accesses on i_fc_lblk_start, i_fc_lblk_len */ - struct mutex i_fc_lock; + /* + * Protect concurrent accesses on i_fc_lblk_start, i_fc_lblk_len + * and inode's EXT4_FC_STATE_COMMITTING state bit. + */ + spinlock_t i_fc_lock; /* * i_disksize keeps track of what the inode size is ON DISK, not diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 3d72565ec6e8..c278060a15bc 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -380,7 +380,7 @@ static int ext4_fc_track_template( int ret; tid = handle->h_transaction->t_tid; - mutex_lock(&ei->i_fc_lock); + spin_lock(&ei->i_fc_lock); if (tid == ei->i_sync_tid) { update = true; } else { @@ -388,7 +388,7 @@ static int ext4_fc_track_template( ei->i_sync_tid = tid; } ret = __fc_track_fn(inode, args, update); - mutex_unlock(&ei->i_fc_lock); + spin_unlock(&ei->i_fc_lock); if (!enqueue) return ret; @@ -420,11 +420,11 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update) struct dentry *dentry = dentry_update->dentry; struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); - mutex_unlock(&ei->i_fc_lock); + spin_unlock(&ei->i_fc_lock); node = kmem_cache_alloc(ext4_fc_dentry_cachep, GFP_NOFS); if (!node) { ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM, NULL); - mutex_lock(&ei->i_fc_lock); + spin_lock(&ei->i_fc_lock); return -ENOMEM; } @@ -437,7 +437,7 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update) kmem_cache_free(ext4_fc_dentry_cachep, node); ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM, NULL); - mutex_lock(&ei->i_fc_lock); + spin_lock(&ei->i_fc_lock); return -ENOMEM; } memcpy((u8 *)node->fcd_name.name, dentry->d_name.name, @@ -471,7 +471,7 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update) list_add_tail(&node->fcd_dilist, &ei->i_fc_dilist); } spin_unlock(&sbi->s_fc_lock); - mutex_lock(&ei->i_fc_lock); + spin_lock(&ei->i_fc_lock); return 0; } @@ -611,10 +611,8 @@ static int __track_range(struct inode *inode, void *arg, bool update) struct __track_range_args *__arg = (struct __track_range_args *)arg; - if (inode->i_ino < EXT4_FIRST_INO(inode->i_sb)) { - ext4_debug("Special inode %ld being modified\n", inode->i_ino); + if (inode->i_ino < EXT4_FIRST_INO(inode->i_sb)) return -ECANCELED; - } oldstart = ei->i_fc_lblk_start; @@ -906,15 +904,15 @@ static int ext4_fc_write_inode_data(struct inode *inode, u32 *crc) struct ext4_extent *ex; int ret; - mutex_lock(&ei->i_fc_lock); + spin_lock(&ei->i_fc_lock); if (ei->i_fc_lblk_len == 0) { - mutex_unlock(&ei->i_fc_lock); + spin_unlock(&ei->i_fc_lock); return 0; } old_blk_size = ei->i_fc_lblk_start; new_blk_size = ei->i_fc_lblk_start + ei->i_fc_lblk_len - 1; ei->i_fc_lblk_len = 0; - mutex_unlock(&ei->i_fc_lock); + spin_unlock(&ei->i_fc_lock); cur_lblk_off = old_blk_size; jbd_debug(1, "%s: will try writing %d to %d for inode %ld\n", diff --git a/fs/ext4/super.c b/fs/ext4/super.c index ae98b07285d2..d6fc12782657 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1347,7 +1347,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) atomic_set(&ei->i_unwritten, 0); INIT_WORK(&ei->i_rsv_conversion_work, ext4_end_io_rsv_work); ext4_fc_init_inode(&ei->vfs_inode); - mutex_init(&ei->i_fc_lock); + spin_lock_init(&ei->i_fc_lock); return &ei->vfs_inode; } From patchwork Tue Apr 19 17:31:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1619183 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=QzeyDFEk; dkim-atps=neutral Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KjW8H6J0qz9sG0 for ; Wed, 20 Apr 2022 03:32:15 +1000 (AEST) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KjW8H5jCWz4xXW for ; Wed, 20 Apr 2022 03:32:15 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4KjW8H5fmVz4xXg; Wed, 20 Apr 2022 03:32:15 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=QzeyDFEk; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KjW8H5Y8Mz4xXW for ; Wed, 20 Apr 2022 03:32:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354215AbiDSRey (ORCPT ); Tue, 19 Apr 2022 13:34:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344945AbiDSRes (ORCPT ); Tue, 19 Apr 2022 13:34:48 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CE4038DBD for ; Tue, 19 Apr 2022 10:32:05 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id v12so16446595plv.4 for ; Tue, 19 Apr 2022 10:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D2/AduS6GDuRHHXS9j3Fwszd78tLRARpYZSKdM0um+A=; b=QzeyDFEkdtmS667QeLcw74OtYwZuqmS23uYBZdOGXL5ucbCm918GLYxOIcORqM8nx8 +pau9RZSSgI6ny3IwayKO9eU1we6mhwMvcZBQlM/QikDknQlEZKfFHw6p0oQ6TRWfJfs ETHETHnPueNaSO4ImWh1CT1kN6oiSLnnFOoI/YdnnUF+4dBUKmKCkxwiRfR495pKYyxD 7So7Z0tndT2XGyukLtaNdG8Lte5xzWc0dUxH+TzhDnW1Hwg/dkAh+Tv+DYW1I+DnYyAU ZufxQlq0ar1cj/6gbwuYG8T3NYGL+QzmukRKW8K79U216rbRw2uUOOlMvJmhOJMZb+PN DFnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D2/AduS6GDuRHHXS9j3Fwszd78tLRARpYZSKdM0um+A=; b=sL/suOy7qFjcTTPqaqQ5RezO1URLF1VVSLdW9R0PJvTEQMt6Rq50GTGx2WTLsc4YiN qvKfZB4MQShmb7HdAuEfMwJ4ZB5XiXyCCPlKRyvs25MW8JRBuh2yh1H6gnyyN/94YtHh SI6zJGBeqgHbSS/LaUEH7owbMUdgl7EwgfMRC1l72SllTOOtIK+uQbECIr25y/bW+oK5 J5mIQdkqTdRZHfZUuZy1TVtpcfcgIjBAYZQuofeCxLd9oUHiwwPmmCV/q4BGrKhU0AsV tgaVHaPMBvJdb00PgrIdIHLOsH9gj71UHEA3l/p5OykQfdmge5QGPhUxejqhBGhwrFk6 M7Zg== X-Gm-Message-State: AOAM532eP0py8ZDvnz1d36QbvHYo1JTH6QBNzbnaS4c9lSZoL9T/+jU6 3iIjTNJHqAXpBEOjHq5hPseRUPwbICiByg== X-Google-Smtp-Source: ABdhPJw/2FxG5Wd3nKHDnGyt+u6jP+QvS6DbbqYwSkUZVYQKaKL/S0lJHYitYwVQWBZg3cWu9iQO3w== X-Received: by 2002:a17:902:e9d3:b0:158:8521:1e8f with SMTP id 19-20020a170902e9d300b0015885211e8fmr16482391plk.82.1650389524434; Tue, 19 Apr 2022 10:32:04 -0700 (PDT) Received: from harshads-520.kir.corp.google.com ([2620:15c:17:10:91ac:bc24:f886:dffc]) by smtp.googlemail.com with ESMTPSA id q9-20020a638c49000000b00398677b6f25sm17266093pgn.70.2022.04.19.10.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 10:32:03 -0700 (PDT) From: Harshad Shirwadkar X-Google-Original-From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: riteshh@linux.ibm.com, jack@suse.cz, tytso@mit.edu, Harshad Shirwadkar Subject: [PATCH v3 2/6] ext4: for committing inode, make ext4_fc_track_inode wait Date: Tue, 19 Apr 2022 10:31:39 -0700 Message-Id: <20220419173143.3564144-3-harshads@google.com> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419173143.3564144-1-harshads@google.com> References: <20220419173143.3564144-1-harshads@google.com> MIME-Version: 1.0 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 From: Harshad Shirwadkar If the inode that's being requested to track using ext4_fc_track_inode is being committed, then wait until the inode finishes the commit. Also, add calls to ext4_fc_track_inode at the right places. With this patch, now calling ext4_reserve_inode_write() results in inode being tracked for next fast commit. A subtle lock ordering requirement with i_data_sem (which is documented in the code) requires that ext4_fc_track_inode() be called before grabbing i_data_sem. So, this patch also adds explicit ext4_fc_track_inode() calls in places where i_data_sem grabbed. Signed-off-by: Harshad Shirwadkar --- fs/ext4/fast_commit.c | 38 ++++++++++++++++++++++++++++++++++++++ fs/ext4/inline.c | 3 +++ fs/ext4/inode.c | 5 ++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index c278060a15bc..55f4c5ddd8e5 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -574,8 +574,14 @@ static int __track_inode(struct inode *inode, void *arg, bool update) return 0; } +/* + * Track inode as part of the next fast commit. If the inode is being + * committed, this function will wait for the commit to finish. + */ void ext4_fc_track_inode(handle_t *handle, struct inode *inode) { + struct ext4_inode_info *ei = EXT4_I(inode); + wait_queue_head_t *wq; struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); int ret; @@ -595,6 +601,38 @@ void ext4_fc_track_inode(handle_t *handle, struct inode *inode) if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_INELIGIBLE)) return; + if (!test_opt2(inode->i_sb, JOURNAL_FAST_COMMIT) || + (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY) || + ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_INELIGIBLE) || + !list_empty(&ei->i_fc_list)) + return; + + /* + * If we come here, we may sleep while waiting for the inode to + * commit. We shouldn't be holding i_data_sem in write mode when we go + * to sleep since the commit path needs to grab the lock while + * committing the inode. + */ + WARN_ON(lockdep_is_held_type(&ei->i_data_sem, 1)); + + while (ext4_test_inode_state(inode, EXT4_STATE_FC_COMMITTING)) { +#if (BITS_PER_LONG < 64) + DEFINE_WAIT_BIT(wait, &ei->i_state_flags, + EXT4_STATE_FC_COMMITTING); + wq = bit_waitqueue(&ei->i_state_flags, + EXT4_STATE_FC_COMMITTING); +#else + DEFINE_WAIT_BIT(wait, &ei->i_flags, + EXT4_STATE_FC_COMMITTING); + wq = bit_waitqueue(&ei->i_flags, + EXT4_STATE_FC_COMMITTING); +#endif + prepare_to_wait(wq, &wait.wq_entry, TASK_UNINTERRUPTIBLE); + if (ext4_test_inode_state(inode, EXT4_STATE_FC_COMMITTING)) + schedule(); + finish_wait(wq, &wait.wq_entry); + } + ret = ext4_fc_track_template(handle, inode, __track_inode, NULL, 1); trace_ext4_fc_track_inode(handle, inode, ret); } diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index 9c076262770d..5d824d528f1c 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -586,6 +586,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping, goto out; } + ext4_fc_track_inode(handle, inode); ret = ext4_destroy_inline_data_nolock(handle, inode); if (ret) goto out; @@ -686,6 +687,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping, goto convert; } + ext4_fc_track_inode(handle, inode); ret = ext4_journal_get_write_access(handle, inode->i_sb, iloc.bh, EXT4_JTR_NONE); if (ret) @@ -967,6 +969,7 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping, if (ret < 0) goto out_release_page; } + ext4_fc_track_inode(handle, inode); ret = ext4_journal_get_write_access(handle, inode->i_sb, iloc.bh, EXT4_JTR_NONE); if (ret) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 955dd978dccf..e88940251afd 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -622,6 +622,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, */ map->m_flags &= ~EXT4_MAP_FLAGS; + ext4_fc_track_inode(handle, inode); /* * New blocks allocate and/or writing to unwritten extent * will possibly result in updating i_data, so we take @@ -4058,7 +4059,7 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length) /* If there are blocks to remove, do it */ if (stop_block > first_block) { - + ext4_fc_track_inode(handle, inode); down_write(&EXT4_I(inode)->i_data_sem); ext4_discard_preallocations(inode, 0); @@ -4214,6 +4215,7 @@ int ext4_truncate(struct inode *inode) if (err) goto out_stop; + ext4_fc_track_inode(handle, inode); down_write(&EXT4_I(inode)->i_data_sem); ext4_discard_preallocations(inode, 0); @@ -5734,6 +5736,7 @@ ext4_reserve_inode_write(handle_t *handle, struct inode *inode, brelse(iloc->bh); iloc->bh = NULL; } + ext4_fc_track_inode(handle, inode); } ext4_std_error(inode->i_sb, err); return err; From patchwork Tue Apr 19 17:31:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1619185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=DPsTEbge; dkim-atps=neutral Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KjW8M5mS3z9sG0 for ; Wed, 20 Apr 2022 03:32:19 +1000 (AEST) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KjW8M5G6Gz4xNl for ; Wed, 20 Apr 2022 03:32:19 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4KjW8M5CXXz4xXW; Wed, 20 Apr 2022 03:32:19 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=DPsTEbge; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KjW8M55z4z4xNl for ; Wed, 20 Apr 2022 03:32:19 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354562AbiDSRe6 (ORCPT ); Tue, 19 Apr 2022 13:34:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353501AbiDSRet (ORCPT ); Tue, 19 Apr 2022 13:34:49 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0759E37BE0 for ; Tue, 19 Apr 2022 10:32:07 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id 12so16427355pll.12 for ; Tue, 19 Apr 2022 10:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SrFQNoDyiiuKSi6r3LGKku8tZtuWdJQnnIG7aGpTqWA=; b=DPsTEbge6ocQJQVJ91U4aGNrdqtfXn7/v2A3lf8gWLsWd/Z03/9XSlj1+H40YpAhht WrC1N89+mL+1KHe3kiU1PsS1hF+68T7G/L+3gcixqERstr07Nwg2rI/WveUdf7Mtba2f VqHCpGhXiWwVIdmBFYgAKgFwfZ+TZ0oorrpFKfm/3DrVyBESmsqy8m1TqydLnwo0xM6P 1/CQJE7AsKU4CRgS8ZAYj2f3uTSZunBHsYUnNGv+qYDnwvxAbCdb4XHYZF8uQyY+SODt 46oVYjFPuMFKyVZysvij5V7yXeSM/rHUEIE5pTwUZ7+n2rQF6udOFp1KPenEf68gDKeo SSsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SrFQNoDyiiuKSi6r3LGKku8tZtuWdJQnnIG7aGpTqWA=; b=t8wFRtEaoR/xq09gQLjomo9nJ2XbPjIijeIkAObAbRjO+XLkxCJyWGSOB0NtgstBcD RxtGE75OfqQ79JJ53J6rJCRwud4cP9VwqGpxgG0z7xxbIYEKa0Vjwl5ip040UQoaAgaC jT8BksU2QG6xmt0jHM2OqLKpU9CR6ZglHTY6OIa3CHzfJ5vrgbT4WoN+ugfmaU4UuyWy 93SeOrUrI5aked4DH7wp6GEsdtdugKmmOTRxyyRzULDU8pIqXkmp7mbaJZWqOlOXNy8v +32QSpsMExiL5fYIw+aacR3wN5gM+gtvachPdI1hoP5mqRadCFjPjWi6dFsQnj/corXI ii2g== X-Gm-Message-State: AOAM533wVte0H0jI41iBpB+TMBwGC6kkgEL3LcyOEMaBrXkeKOBU4nxF WZcpWeeoAUXBX4IAg38nsv20lhykd0GrUA== X-Google-Smtp-Source: ABdhPJxu4LzM5npHveQH09wAS77U9vdM7neiz/H342L2of4zii3wPJdfc1znBTW7b437yINPimm1qQ== X-Received: by 2002:a17:902:f64c:b0:156:7ceb:b579 with SMTP id m12-20020a170902f64c00b001567cebb579mr16371066plg.73.1650389526148; Tue, 19 Apr 2022 10:32:06 -0700 (PDT) Received: from harshads-520.kir.corp.google.com ([2620:15c:17:10:91ac:bc24:f886:dffc]) by smtp.googlemail.com with ESMTPSA id q9-20020a638c49000000b00398677b6f25sm17266093pgn.70.2022.04.19.10.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 10:32:05 -0700 (PDT) From: Harshad Shirwadkar X-Google-Original-From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: riteshh@linux.ibm.com, jack@suse.cz, tytso@mit.edu, Harshad Shirwadkar Subject: [PATCH v3 3/6] ext4: mark inode dirty before grabbing i_data_sem in ext4_setattr Date: Tue, 19 Apr 2022 10:31:40 -0700 Message-Id: <20220419173143.3564144-4-harshads@google.com> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419173143.3564144-1-harshads@google.com> References: <20220419173143.3564144-1-harshads@google.com> MIME-Version: 1.0 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 From: Harshad Shirwadkar Mark inode dirty first and then grab i_data_sem in ext4_setattr(). Signed-off-by: Harshad Shirwadkar --- fs/ext4/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index e88940251afd..6eae0804c6fd 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5455,11 +5455,12 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry, (attr->ia_size > 0 ? attr->ia_size - 1 : 0) >> inode->i_sb->s_blocksize_bits); - down_write(&EXT4_I(inode)->i_data_sem); - EXT4_I(inode)->i_disksize = attr->ia_size; rc = ext4_mark_inode_dirty(handle, inode); if (!error) error = rc; + down_write(&EXT4_I(inode)->i_data_sem); + EXT4_I(inode)->i_disksize = attr->ia_size; + /* * We have to update i_size under i_data_sem together * with i_disksize to avoid races with writeback code From patchwork Tue Apr 19 17:31:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1619186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=SjN9WNXo; dkim-atps=neutral Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KjW8N1Cbtz9sG2 for ; Wed, 20 Apr 2022 03:32:20 +1000 (AEST) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KjW8N0VY5z4xXW for ; Wed, 20 Apr 2022 03:32:20 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4KjW8N0RsLz4xXg; Wed, 20 Apr 2022 03:32:20 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=SjN9WNXo; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KjW8N0J8Vz4xXW for ; Wed, 20 Apr 2022 03:32:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355758AbiDSRfA (ORCPT ); Tue, 19 Apr 2022 13:35:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350190AbiDSRew (ORCPT ); Tue, 19 Apr 2022 13:34:52 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C99A2387A7 for ; Tue, 19 Apr 2022 10:32:08 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id j8-20020a17090a060800b001cd4fb60dccso2574567pjj.2 for ; Tue, 19 Apr 2022 10:32:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PjRsC/YDA7+z/rnKixh0Ac+zg4HAF5I+ejCNfZn2tq8=; b=SjN9WNXoxYqXJLgzYA/vk5eCaUGXAXrdoAM9dqY3K2vN2wG0X+ylt7LZM30+MTnfy4 rb92kZB71ppbstybZmxX7z2GbSsPlLOt68RRwfUMOyCbq0awm6yfB+aP8G19q6Q4Cqsw LmhA0a8ukHZ+ONpoM0I1VA/WI+Y3Y5+H2SSU73pso6tCfIiTIiBJklKQNMw6bgGE1nmu N9S/QTK84+rhQu4ECiw6AWsY09IdCPPr4qt/9ySIFoGEclJum7HVzXFe9refGAXTMZHd EItzz+rxFmKMJjyjyAsRsspGW77g7N3uCbhJweKmBfWHxEPUGFz4xjR3F3yFjegfqnI4 Ym5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PjRsC/YDA7+z/rnKixh0Ac+zg4HAF5I+ejCNfZn2tq8=; b=QLLkvwl5+3h2RAyY08tcL75b6zEB7NwL9s5POc96rDtQFZDDYTupu4wBNkaQorPqbT 1jP1csSpSZXd/48cQ4glGgaLee/47xgmqM28D6zzwQSlhc1o5tUP6lYDd/iU/wdzkN2v AUVBAE27SrqGdZzGpj6EqJBIEJgWjamZh5sWOJ4aDL2M6eCf0FQlG8z+H6/abzzk4Ofj j9UZVqJLMuXJAJnfDZigE1f6DzkdUrc2U7w73v7HLcTTJ6B2SMo5drODPx8BMangXRYw U3mnX9JUTMkXR2Jqzx3akyO3bdeCuIQm9GxQhNkPHvtyen6MSOMaTjLnHmihI6/fciQh nBpg== X-Gm-Message-State: AOAM530xV5lE190yFalpgrdnjTqcejY9KtIJ5U/Q5sYG2nWRgKbt8y2C pCG53q5FS1UVH1CPAZMX5sv0pEIthjI2mQ== X-Google-Smtp-Source: ABdhPJytrq+YY5Xg5yDtBqtBIGxiFbwXesbb7sbaGVmsYmgQrpQsmq7aaT1oSTAqdUEwH66GPfoWFQ== X-Received: by 2002:a17:90b:90:b0:1d2:b873:fdd with SMTP id bb16-20020a17090b009000b001d2b8730fddmr8539757pjb.207.1650389527614; Tue, 19 Apr 2022 10:32:07 -0700 (PDT) Received: from harshads-520.kir.corp.google.com ([2620:15c:17:10:91ac:bc24:f886:dffc]) by smtp.googlemail.com with ESMTPSA id q9-20020a638c49000000b00398677b6f25sm17266093pgn.70.2022.04.19.10.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 10:32:06 -0700 (PDT) From: Harshad Shirwadkar X-Google-Original-From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: riteshh@linux.ibm.com, jack@suse.cz, tytso@mit.edu, Harshad Shirwadkar Subject: [PATCH v3 4/6] ext4: rework fast commit commit path Date: Tue, 19 Apr 2022 10:31:41 -0700 Message-Id: <20220419173143.3564144-5-harshads@google.com> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419173143.3564144-1-harshads@google.com> References: <20220419173143.3564144-1-harshads@google.com> MIME-Version: 1.0 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 From: Harshad Shirwadkar This patch reworks fast commit's commit path to remove locking the journal for the entire duration of a fast commit. Instead, we only lock the journal while marking all the eligible inodes as "committing". This allows handles to make progress in parallel with the fast commit. Signed-off-by: Harshad Shirwadkar Reviewed-by: Jan Kara --- fs/ext4/fast_commit.c | 71 ++++++++++++++++++++++++++++--------------- fs/jbd2/journal.c | 2 -- 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 55f4c5ddd8e5..75f5abbf7c5d 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -287,20 +287,30 @@ void ext4_fc_del(struct inode *inode) (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)) return; -restart: spin_lock(&EXT4_SB(inode->i_sb)->s_fc_lock); if (list_empty(&ei->i_fc_list) && list_empty(&ei->i_fc_dilist)) { spin_unlock(&EXT4_SB(inode->i_sb)->s_fc_lock); return; } - if (ext4_test_inode_state(inode, EXT4_STATE_FC_COMMITTING)) { - ext4_fc_wait_committing_inode(inode); - goto restart; - } - - if (!list_empty(&ei->i_fc_list)) - list_del_init(&ei->i_fc_list); + /* + * Since ext4_fc_del is called from ext4_evict_inode while having a + * handle open, there is no need for us to wait here even if a fast + * commit is going on. That is because, if this inode is being + * committed, ext4_mark_inode_dirty would have waited for inode commit + * operation to finish before we come here. So, by the time we come + * here, inode's EXT4_STATE_FC_COMMITTING would have been cleared. So, + * we shouldn't see EXT4_STATE_FC_COMMITTING to be set on this inode + * here. + * + * We may come here without any handles open in the "no_delete" case of + * ext4_evict_inode as well. However, if that happens, we first mark the + * file system as fast commit ineligible anyway. So, even in that case, + * it is okay to remove the inode from the fc list. + */ + WARN_ON(ext4_test_inode_state(inode, EXT4_STATE_FC_COMMITTING) + && !ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_INELIGIBLE)); + list_del_init(&ei->i_fc_list); /* * Since this inode is getting removed, let's also remove all FC @@ -323,8 +333,6 @@ void ext4_fc_del(struct inode *inode) fc_dentry->fcd_name.len > DNAME_INLINE_LEN) kfree(fc_dentry->fcd_name.name); kmem_cache_free(ext4_fc_dentry_cachep, fc_dentry); - - return; } /* @@ -1013,19 +1021,6 @@ static int ext4_fc_submit_inode_data_all(journal_t *journal) spin_lock(&sbi->s_fc_lock); list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { - ext4_set_inode_state(&ei->vfs_inode, EXT4_STATE_FC_COMMITTING); - while (atomic_read(&ei->i_fc_updates)) { - DEFINE_WAIT(wait); - - prepare_to_wait(&ei->i_fc_wait, &wait, - TASK_UNINTERRUPTIBLE); - if (atomic_read(&ei->i_fc_updates)) { - spin_unlock(&sbi->s_fc_lock); - schedule(); - spin_lock(&sbi->s_fc_lock); - } - finish_wait(&ei->i_fc_wait, &wait); - } spin_unlock(&sbi->s_fc_lock); ret = jbd2_submit_inode_data(ei->jinode); if (ret) @@ -1138,6 +1133,16 @@ static int ext4_fc_perform_commit(journal_t *journal) int ret = 0; u32 crc = 0; + /* Lock the journal */ + jbd2_journal_lock_updates(journal); + spin_lock(&sbi->s_fc_lock); + list_for_each_entry(iter, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { + ext4_set_inode_state(&iter->vfs_inode, + EXT4_STATE_FC_COMMITTING); + } + spin_unlock(&sbi->s_fc_lock); + jbd2_journal_unlock_updates(journal); + ret = ext4_fc_submit_inode_data_all(journal); if (ret) return ret; @@ -1188,6 +1193,18 @@ static int ext4_fc_perform_commit(journal_t *journal) ret = ext4_fc_write_inode(inode, &crc); if (ret) goto out; + ext4_clear_inode_state(inode, EXT4_STATE_FC_COMMITTING); + /* + * Make sure clearing of EXT4_STATE_FC_COMMITTING is + * visible before we send the wakeup. Pairs with implicit + * barrier in prepare_to_wait() in ext4_fc_track_inode(). + */ + smp_mb(); +#if (BITS_PER_LONG < 64) + wake_up_bit(&iter->i_state_flags, EXT4_STATE_FC_COMMITTING); +#else + wake_up_bit(&iter->i_flags, EXT4_STATE_FC_COMMITTING); +#endif spin_lock(&sbi->s_fc_lock); } spin_unlock(&sbi->s_fc_lock); @@ -1325,13 +1342,17 @@ static void ext4_fc_cleanup(journal_t *journal, int full, tid_t tid) spin_lock(&sbi->s_fc_lock); list_for_each_entry_safe(iter, iter_n, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { - list_del_init(&iter->i_fc_list); ext4_clear_inode_state(&iter->vfs_inode, EXT4_STATE_FC_COMMITTING); if (iter->i_sync_tid <= tid) ext4_fc_reset_inode(&iter->vfs_inode); - /* Make sure EXT4_STATE_FC_COMMITTING bit is clear */ + /* + * Make sure clearing of EXT4_STATE_FC_COMMITTING is + * visible before we send the wakeup. Pairs with implicit + * barrier in prepare_to_wait() in ext4_fc_track_inode(). + */ smp_mb(); + list_del_init(&iter->i_fc_list); #if (BITS_PER_LONG < 64) wake_up_bit(&iter->i_state_flags, EXT4_STATE_FC_COMMITTING); #else diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index c2cf74b01ddb..06b885628b1c 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -757,7 +757,6 @@ int jbd2_fc_begin_commit(journal_t *journal, tid_t tid) } journal->j_flags |= JBD2_FAST_COMMIT_ONGOING; write_unlock(&journal->j_state_lock); - jbd2_journal_lock_updates(journal); return 0; } @@ -769,7 +768,6 @@ EXPORT_SYMBOL(jbd2_fc_begin_commit); */ static int __jbd2_fc_end_commit(journal_t *journal, tid_t tid, bool fallback) { - jbd2_journal_unlock_updates(journal); if (journal->j_fc_cleanup_callback) journal->j_fc_cleanup_callback(journal, 0, tid); write_lock(&journal->j_state_lock); From patchwork Tue Apr 19 17:31:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1619187 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=pF+mKLIK; dkim-atps=neutral Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KjW8N3qGBz9sG6 for ; Wed, 20 Apr 2022 03:32:20 +1000 (AEST) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KjW8N383Mz4xXW for ; Wed, 20 Apr 2022 03:32:20 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4KjW8N35CNz4xXg; Wed, 20 Apr 2022 03:32:20 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=pF+mKLIK; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KjW8N2vZxz4xXW for ; Wed, 20 Apr 2022 03:32:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353482AbiDSRfB (ORCPT ); Tue, 19 Apr 2022 13:35:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353834AbiDSRex (ORCPT ); Tue, 19 Apr 2022 13:34:53 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EFFE393C0 for ; Tue, 19 Apr 2022 10:32:10 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id t12so16440570pll.7 for ; Tue, 19 Apr 2022 10:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mrAkIi1J7AvRs5T8VP57+42mQc7Jp6i+BoH4fTdf41w=; b=pF+mKLIKL6Z7oEzeUuLPxZq8JcIcjaKitAFjnzT1dWaEQV8qDcaXeonIHDiFhnMN8Q aqnIDoX+mT+MdipD4FfZkTc1Iquz8RVdPQmb7Pmvs/C24SzQUrOdgLQp5iyzI+mCNZqk yAwtAEA2o0UpIhdeoECjhIP723r0kBHZeKWF+o9jUCzuGrCHfvUH/7FRDnBSYdr0mv6W kVpf6u27doa6STEKoas203NV74DhHenYIarfNUjjIVh0Xz5yc+4NNSy9VrfLhRvMKHO4 z2XTEPNw11ffjUo9EVNLvRBuXbR+a7cO8FTURZAhgRlYS8jUKKl0AS5H/P/WahWPvW8Z gQqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mrAkIi1J7AvRs5T8VP57+42mQc7Jp6i+BoH4fTdf41w=; b=CJ+IQnF2A/NwzCKT0p/pYcQfkbiua10Mi4VFHy+Aotg6FeiQb7ViJKjNzXbztwB9De 6P6mEvC/WACN25kCfZjZhbPN7R3YTZOIRAqnS0Se215UMgdfQr+zl6VfhLzNWeJrzDu7 tL+cmxXfauRlHbmbE1rrvN3cCJ8gJRh+9jJGs3xPioewfpuwJpxLuODQkE/A3SOah9Cq EFHEMokzJsA31lqOp4WScBhyJPHege90I/7wuNURAn23fhY9YEhfPxncIjWJZvneeOd2 K3YRgDaAnosm9196Uuep2fOYW4DtPTw4eAmNoaekkmsPhQXTdBy3y12UgBD5Ck+DVEL9 8/RQ== X-Gm-Message-State: AOAM532Ba4gd+M5W5mcHP9MCcmpCTH9+h2UwcFQEBkuKEfFeODiFExKV mfC+PZuo9wcIQwZBtlX+L+PFFSiKbgG3Sg== X-Google-Smtp-Source: ABdhPJxN4IkguOt9n1bRQPRYBWJZf7Rgh6rtlHdETfos9n/Yh4I1NEt5ESZ8dMRcQIrIKUnyvkaRUA== X-Received: by 2002:a17:903:2045:b0:158:c130:31b7 with SMTP id q5-20020a170903204500b00158c13031b7mr17430661pla.154.1650389529420; Tue, 19 Apr 2022 10:32:09 -0700 (PDT) Received: from harshads-520.kir.corp.google.com ([2620:15c:17:10:91ac:bc24:f886:dffc]) by smtp.googlemail.com with ESMTPSA id q9-20020a638c49000000b00398677b6f25sm17266093pgn.70.2022.04.19.10.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 10:32:08 -0700 (PDT) From: Harshad Shirwadkar X-Google-Original-From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: riteshh@linux.ibm.com, jack@suse.cz, tytso@mit.edu, Harshad Shirwadkar Subject: [PATCH v3 5/6] ext4: drop i_fc_updates from inode fc info Date: Tue, 19 Apr 2022 10:31:42 -0700 Message-Id: <20220419173143.3564144-6-harshads@google.com> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419173143.3564144-1-harshads@google.com> References: <20220419173143.3564144-1-harshads@google.com> MIME-Version: 1.0 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 From: Harshad Shirwadkar The new logic introduced in this series does not require tracking number of active handles open on an inode. So, drop it. Signed-off-by: Harshad Shirwadkar Reviewed-by: Jan Kara --- fs/ext4/ext4.h | 5 ---- fs/ext4/fast_commit.c | 70 ------------------------------------------- 2 files changed, 75 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 46ca0979e73b..dd8d1623fbac 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1059,9 +1059,6 @@ struct ext4_inode_info { /* End of lblk range that needs to be committed in this fast commit */ ext4_lblk_t i_fc_lblk_len; - /* Number of ongoing updates on this inode */ - atomic_t i_fc_updates; - /* Fast commit wait queue for this inode */ wait_queue_head_t i_fc_wait; @@ -2930,8 +2927,6 @@ void __ext4_fc_track_create(handle_t *handle, struct inode *inode, void ext4_fc_track_create(handle_t *handle, struct dentry *dentry); void ext4_fc_track_inode(handle_t *handle, struct inode *inode); void ext4_fc_mark_ineligible(struct super_block *sb, int reason, handle_t *handle); -void ext4_fc_start_update(struct inode *inode); -void ext4_fc_stop_update(struct inode *inode); void ext4_fc_del(struct inode *inode); bool ext4_fc_replay_check_excluded(struct super_block *sb, ext4_fsblk_t block); void ext4_fc_replay_cleanup(struct super_block *sb); diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 75f5abbf7c5d..266c95ff0d74 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -201,76 +201,6 @@ void ext4_fc_init_inode(struct inode *inode) INIT_LIST_HEAD(&ei->i_fc_list); INIT_LIST_HEAD(&ei->i_fc_dilist); init_waitqueue_head(&ei->i_fc_wait); - atomic_set(&ei->i_fc_updates, 0); -} - -/* This function must be called with sbi->s_fc_lock held. */ -static void ext4_fc_wait_committing_inode(struct inode *inode) -__releases(&EXT4_SB(inode->i_sb)->s_fc_lock) -{ - wait_queue_head_t *wq; - struct ext4_inode_info *ei = EXT4_I(inode); - -#if (BITS_PER_LONG < 64) - DEFINE_WAIT_BIT(wait, &ei->i_state_flags, - EXT4_STATE_FC_COMMITTING); - wq = bit_waitqueue(&ei->i_state_flags, - EXT4_STATE_FC_COMMITTING); -#else - DEFINE_WAIT_BIT(wait, &ei->i_flags, - EXT4_STATE_FC_COMMITTING); - wq = bit_waitqueue(&ei->i_flags, - EXT4_STATE_FC_COMMITTING); -#endif - lockdep_assert_held(&EXT4_SB(inode->i_sb)->s_fc_lock); - prepare_to_wait(wq, &wait.wq_entry, TASK_UNINTERRUPTIBLE); - spin_unlock(&EXT4_SB(inode->i_sb)->s_fc_lock); - schedule(); - finish_wait(wq, &wait.wq_entry); -} - -/* - * Inform Ext4's fast about start of an inode update - * - * This function is called by the high level call VFS callbacks before - * performing any inode update. This function blocks if there's an ongoing - * fast commit on the inode in question. - */ -void ext4_fc_start_update(struct inode *inode) -{ - struct ext4_inode_info *ei = EXT4_I(inode); - - if (!test_opt2(inode->i_sb, JOURNAL_FAST_COMMIT) || - (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)) - return; - -restart: - spin_lock(&EXT4_SB(inode->i_sb)->s_fc_lock); - if (list_empty(&ei->i_fc_list)) - goto out; - - if (ext4_test_inode_state(inode, EXT4_STATE_FC_COMMITTING)) { - ext4_fc_wait_committing_inode(inode); - goto restart; - } -out: - atomic_inc(&ei->i_fc_updates); - spin_unlock(&EXT4_SB(inode->i_sb)->s_fc_lock); -} - -/* - * Stop inode update and wake up waiting fast commits if any. - */ -void ext4_fc_stop_update(struct inode *inode) -{ - struct ext4_inode_info *ei = EXT4_I(inode); - - if (!test_opt2(inode->i_sb, JOURNAL_FAST_COMMIT) || - (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)) - return; - - if (atomic_dec_and_test(&ei->i_fc_updates)) - wake_up_all(&ei->i_fc_wait); } /* From patchwork Tue Apr 19 17:31:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1619188 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=clw64hde; dkim-atps=neutral Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KjW8P4Jphz9sG0 for ; Wed, 20 Apr 2022 03:32:21 +1000 (AEST) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KjW8P3Rm6z4xXW for ; Wed, 20 Apr 2022 03:32:21 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4KjW8P3P5jz4xXg; Wed, 20 Apr 2022 03:32:21 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=clw64hde; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4KjW8P3Bq4z4xXW for ; Wed, 20 Apr 2022 03:32:21 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355762AbiDSRfC (ORCPT ); Tue, 19 Apr 2022 13:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354474AbiDSRez (ORCPT ); Tue, 19 Apr 2022 13:34:55 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E2BE393CD for ; Tue, 19 Apr 2022 10:32:12 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id t12so16440658pll.7 for ; Tue, 19 Apr 2022 10:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mDfOyvyhiWtyl6B1dMEKj0y27044TcELCrCOpYVq/uw=; b=clw64hdeDr8ODhCMWpeweiSpdCcrEB4/oxPLMAvGqiR/mx3TAmm0vBHvJlSo2vWhoc cYugobAZ0gPw0oPU/BTUnuHEMqO2jeGuIfcETj/97iFiqVyp207Qg94nKKkIKIU4g1pJ aoZqAjgSqTjnw5NV5uf55izLsbVr50xQBAzhS4zYqTSjsx8sJD1LH9uAmQmF0dWN6PHd oNvLRx94DSKff14qN9IRG/hofyjtfJtXZBUOeMwh7wqIsMddSHSQnwCncoA5FLbOOQRM B1GcSdPFeOGuWhvzSpadB49JNwP7Wa4LPGRD4eGCk84bq+GY6JRU8UZVN34cQxIO2CvI nJng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mDfOyvyhiWtyl6B1dMEKj0y27044TcELCrCOpYVq/uw=; b=ysaiwNQnsdeBUgDJYvGuDgpUi4PfVFq3RV3iXGqUndXIxuPFC9JcVp6TlNmLeliWMN k2ZHmFwiRnwPmWriOmBJHze5KYSzrtRmHBXCGFEQFW6DNHBDUMlarym8c+qoYC+P21FH V5p1o4+q3anAIPCwYu/Tiv8bMSGIrwfM5NsXGeuo8c+UFl3uW0/p2Lb3XkKDr6OxDbar BtBtyzUG/5jwkOBkHbU4NESE9aM0PU3vbHSoDeL+bfB/XWjxMebyOO0oFgyMxChh+kUk fsyq0la0ZipUWzQyjxhRkERvudsrrksduSL07qqxN7LpsVOZ+f1FI4Gpri7qRcUWDu1T ZaIQ== X-Gm-Message-State: AOAM532OmLk8likXkUUI2691kxH90o/MP/DwHx3BS37V8BGQVDfSH2gT Q0en9YmoslN9q3tnqEsGKHFtZf5wfqo+tQ== X-Google-Smtp-Source: ABdhPJzdd4LJhBeJnEiCCMbhA8mzqneid0Li6d8ME1vXCzWbengqI1LlcbQinlpCD0DSN0Ua65kaCw== X-Received: by 2002:a17:90b:4a41:b0:1d2:a83c:e480 with SMTP id lb1-20020a17090b4a4100b001d2a83ce480mr10394208pjb.18.1650389531210; Tue, 19 Apr 2022 10:32:11 -0700 (PDT) Received: from harshads-520.kir.corp.google.com ([2620:15c:17:10:91ac:bc24:f886:dffc]) by smtp.googlemail.com with ESMTPSA id q9-20020a638c49000000b00398677b6f25sm17266093pgn.70.2022.04.19.10.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 10:32:10 -0700 (PDT) From: Harshad Shirwadkar X-Google-Original-From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: riteshh@linux.ibm.com, jack@suse.cz, tytso@mit.edu, Harshad Shirwadkar Subject: [PATCH v3 6/6] ext4: update code documentation Date: Tue, 19 Apr 2022 10:31:43 -0700 Message-Id: <20220419173143.3564144-7-harshads@google.com> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419173143.3564144-1-harshads@google.com> References: <20220419173143.3564144-1-harshads@google.com> MIME-Version: 1.0 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 From: Harshad Shirwadkar This patch updates code documentation to reflect the commit path changes made in this series. Signed-off-by: Harshad Shirwadkar Reviewed-by: Jan Kara --- fs/ext4/fast_commit.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 266c95ff0d74..1691cfd89954 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -49,14 +49,21 @@ * that need to be committed during a fast commit in another in memory queue of * inodes. During the commit operation, we commit in the following order: * - * [1] Lock inodes for any further data updates by setting COMMITTING state - * [2] Submit data buffers of all the inodes - * [3] Wait for [2] to complete - * [4] Commit all the directory entry updates in the fast commit space - * [5] Commit all the changed inode structures - * [6] Write tail tag (this tag ensures the atomicity, please read the following + * [1] Lock the journal by calling jbd2_journal_lock_updates. This ensures that + * all the exsiting handles finish and no new handles can start. + * [2] Mark all the fast commit eligible inodes as undergoing fast commit + * by setting "EXT4_STATE_FC_COMMITTING" state. + * [3] Unlock the journal by calling jbd2_journal_unlock_updates. This allows + * starting of new handles. If new handles try to start an update on + * any of the inodes that are being committed, ext4_fc_track_inode() + * will block until those inodes have finished the fast commit. + * [4] Submit data buffers of all the committing inodes. + * [5] Wait for [4] to complete. + * [6] Commit all the directory entry updates in the fast commit space. + * [7] Commit all the changed inodes in the fast commit space and clear + * "EXT4_STATE_FC_COMMITTING" for these inodes. + * [8] Write tail tag (this tag ensures the atomicity, please read the following * section for more details). - * [7] Wait for [4], [5] and [6] to complete. * * All the inode updates must call ext4_fc_start_update() before starting an * update. If such an ongoing update is present, fast commit waits for it to @@ -142,6 +149,13 @@ * similarly. Thus, by converting a non-idempotent procedure into a series of * idempotent outcomes, fast commits ensured idempotence during the replay. * + * Locking + * ------- + * sbi->s_fc_lock protects the fast commit inodes queue and the fast commit + * dentry queue. ei->i_fc_lock protects the fast commit related info in a given + * inode. Most of the code avoids acquiring both the locks, but if one must do + * that then sbi->s_fc_lock must be acquired before ei->i_fc_lock. + * * TODOs * ----- * @@ -156,13 +170,12 @@ * fast commit recovery even if that area is invalidated by later full * commits. * - * 1) Fast commit's commit path locks the entire file system during fast - * commit. This has significant performance penalty. Instead of that, we - * should use ext4_fc_start/stop_update functions to start inode level - * updates from ext4_journal_start/stop. Once we do that we can drop file - * system locking during commit path. + * 1) Handle more ineligible cases. * - * 2) Handle more ineligible cases. + * 2) Change ext4_fc_commit() to lookup logical to physical mapping using extent + * status tree. This would get rid of the need to call ext4_fc_track_inode() + * before acquiring i_data_sem. To do that we would need to ensure that + * modified extents from the extent status tree are not evicted from memory. */ #include