Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3500527pxp; Tue, 8 Mar 2022 16:03:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5XaZMzDqDaXW+A22iF21uysxwAa8ic4teTqmUkQk/lYgOD73J2xoICiwgZ7W90q/HU40X X-Received: by 2002:a17:90a:1d04:b0:1bc:98ca:5e6f with SMTP id c4-20020a17090a1d0400b001bc98ca5e6fmr7550523pjd.32.1646784211192; Tue, 08 Mar 2022 16:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646784211; cv=none; d=google.com; s=arc-20160816; b=kfno0Crps4RXgdz9Og3gMdj+X7UG13ib3TmgV++rZN9gp/sKnMKIEG9ftuq5FGjVl4 sLoiRNXGDalc3F1od/7hy4kgCHOnQE0TY/ERh6qC06AKqVM+XEUxoeYpIwXi/4rqVFRK +KcM7PrMkfQSf6YiEKnc/7JhBoTCJ6o+YbHqLXZOYN88v68vOVTH7fRONONnL3HsNOMb 5MGXSkoBifVrCLX6g0JYvu13fCDF15K0RfYbrxX68a0FUPXsebwHalwPv4zndARDjCh1 +SxXTEeuogYHCl+PYKaEfUTFE8rHcF2Uh8xOO/YtOxubgF09C+7xyv6u0rrItJO5Gkmh 0QbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=sa+Tre1JUm35J/+yjjl5UgGs9+Ghlc1MWYjugeEOHFQ=; b=TEoMmgSgBwAEctELX3/ut9hei2GxeQKJL7P7gShf/yC6vuk1yy+Al2XPvMx685fkQ1 xRBVVrJISr/p1Qaa8AWkc0u+FiBvuTczy3vTt9rxtru5p6Gf8DvbCZqTTDIXJ2icAulP 7RmgExw9YeOTAOAdpJGUof3QpEq5ET5l7SX8Hx2bFhP6FLLE7MzNvS+XQBAoKlZ5l/6o XehSwBqA6xoaCTXAZ/CEbFgTVoSM3WndfxpsgiUfqftFLZYGXi3MUr4LgT/nhYLOiEmH c2/nY0U0LWq2wa0l9hgQxA4KuCz3qVr20hPjywZIjF0TpZA6ncoc9uOZKsfSF4TUaq5s X/gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b9Tdo+5N; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j15-20020aa78dcf000000b004f3ee536ec6si294261pfr.95.2022.03.08.16.03.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 16:03:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b9Tdo+5N; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2DC4BE0ACD; Tue, 8 Mar 2022 15:37:20 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234635AbiCHNIS (ORCPT + 99 others); Tue, 8 Mar 2022 08:08:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244058AbiCHNH7 (ORCPT ); Tue, 8 Mar 2022 08:07:59 -0500 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27FDE48316 for ; Tue, 8 Mar 2022 05:07:03 -0800 (PST) Received: by mail-qt1-x836.google.com with SMTP id t28so16002521qtc.7 for ; Tue, 08 Mar 2022 05:07:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sa+Tre1JUm35J/+yjjl5UgGs9+Ghlc1MWYjugeEOHFQ=; b=b9Tdo+5Nei6nAP0Y5wxtIWP4o8W2BuvsTeQiWr9z9Noe4HycsNLfHgC+alPALB6vec wbPxLSjGoMEl4nCGx0RsNhl8MCo5aGRyGnfE2li+jtej03cLiVybCt7cZvZpQ+qGni4U 3TaXwIzYy5OAYNZ0u//XAfi0UNICR1QtAc2d4Sa1PomRO9/DdmwM0jOmMQEV99G4/ZhC qUdjRSY6uF9Q+pUZYshvD8SwaXp2CLmqrggoeKKgsB1pO5aDqojCnB7qqDlrEYgPUdsi PmoyYlHnaxehpKiaPiDCkIkDe/kSJ1mSHQ5saPoCUSTltdKEIQYUGGYK5YXvGvFC/bGE 7SSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sa+Tre1JUm35J/+yjjl5UgGs9+Ghlc1MWYjugeEOHFQ=; b=EQKBDmQIcyjd73WQl+lkebJHCw7J/ZjFZQHJ91YBFTkc1h32JjtZ0F0VjLZHVV7yJ8 Vs/gYd7F7h6X5AWltm3G+Fu1jqA+IaGrkefOy6MNt3AQQ/ShdTHBbQhpzw0LShov6i+N 0/xCH+m7Go7JDDcMDX/Xhc6U2gI4AEqN54pIaGLzfaCfjLN74Ae4csLGwGBCkIU9rZTC ChNwPg3uTFEEyEHKIm5cUN86J31EuELRPuJRwiJirGHWX8jyLRFhlU418kPzGmH2ICEb RC9Qo1t8nwaO0SAgRd1xWzEsXojXDkcJvQ+1HoU05Qh71nFXb4SXopO35RuWUTmz2Hrq V7Gg== X-Gm-Message-State: AOAM531Wvi5nnSIPF2M0KxTheCzTZ9Dupc9YuvtjZs5QKqtKb03aJoED OdbX+RM4FV0de6mTjHB7eeajPqae16ebejQjFpiP3ntfs8TsIw== X-Received: by 2002:ac8:7d0b:0:b0:2e0:6891:832c with SMTP id g11-20020ac87d0b000000b002e06891832cmr6697530qtb.297.1646744822105; Tue, 08 Mar 2022 05:07:02 -0800 (PST) MIME-Version: 1.0 References: <20220308105112.404498-1-harshads@google.com> <20220308105112.404498-4-harshads@google.com> <20220308123020.u4357jwbtoqhy5xd@quack3.lan> In-Reply-To: <20220308123020.u4357jwbtoqhy5xd@quack3.lan> From: harshad shirwadkar Date: Tue, 8 Mar 2022 05:06:51 -0800 Message-ID: Subject: Re: [PATCH 3/5] ext4: for committing inode, make ext4_fc_track_inode wait To: Jan Kara Cc: Ext4 Developers List , Ritesh Harjani , "Theodore Y. Ts'o" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Tue, 8 Mar 2022 at 04:30, Jan Kara wrote: > > On Tue 08-03-22 02:51:10, Harshad Shirwadkar wrote: > > 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. > > > > Signed-off-by: Harshad Shirwadkar > > Looks mostly good. Just some notes below. > > > diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c > > index 3477a16d08ae..7fa301b0a35a 100644 > > --- a/fs/ext4/ext4_jbd2.c > > +++ b/fs/ext4/ext4_jbd2.c > > @@ -106,6 +106,18 @@ handle_t *__ext4_journal_start_sb(struct super_block *sb, unsigned int line, > > GFP_NOFS, type, line); > > } > > > > +handle_t *__ext4_journal_start(struct inode *inode, unsigned int line, > > + int type, int blocks, int rsv_blocks, > > + int revoke_creds) > > +{ > > + handle_t *handle = __ext4_journal_start_sb(inode->i_sb, line, > > + type, blocks, rsv_blocks, > > + revoke_creds); > > + if (ext4_handle_valid(handle) && !IS_ERR(handle)) > > + ext4_fc_track_inode(handle, inode); > > Why do you need to call ext4_fc_track_inode() here? Calls in > ext4_map_blocks() and ext4_mark_iloc_dirty() should be enough, shouldn't > they? This is just a precautionary call. ext4_fc_track_inode is an idempotent function, so it doesn't matter if it gets called multiple times. This check just covers cases (such as the ones in inline.c) where ext4_reserve_inode_write() doesn't get called. I saw a few failures in the log group when I remove this call. The right way to fix this though is to ensure that ext4_reserve_inode_write() gets called before every inode update. > > > + return handle; > > +} > > + > > int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle) > > { > > struct super_block *sb; > > ... > > > @@ -519,6 +525,33 @@ void ext4_fc_track_inode(handle_t *handle, struct inode *inode) > > return; > > } > > > > + if (!test_opt2(inode->i_sb, JOURNAL_FAST_COMMIT) || > > + (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)) > > + return; > > + > > + spin_lock(&ei->i_fc_lock); > > + 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); > > + spin_unlock(&ei->i_fc_lock); > > + > > + schedule(); > > + finish_wait(wq, &wait.wq_entry); > > + spin_lock(&ei->i_fc_lock); > > + } > > + spin_unlock(&ei->i_fc_lock); > > Hum, we operate inode state with atomic bitops. So I think there's no real > need for ei->i_fc_lock here. You just need to be careful and check inode > state again after prepare_to_wait() call. Okay that makes sense, I'll do this in V2. - Harshad > > Honza > -- > Jan Kara > SUSE Labs, CR