From patchwork Sun Aug 18 04:03:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1973519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=GUpE/8Sl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=nagw=pr=vger.kernel.org=linux-ext4+bounces-3758-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wmhty723pz1yXf for ; Sun, 18 Aug 2024 14:04:26 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Wmhty4fQ6z4wbp for ; Sun, 18 Aug 2024 14:04:26 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Wmhty4bdFz4wd6; Sun, 18 Aug 2024 14:04:26 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=20230601 header.b=GUpE/8Sl; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.80.249; helo=am.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3758-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (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 gandalf.ozlabs.org (Postfix) with ESMTPS id 4Wmhty0Zx5z4wbp for ; Sun, 18 Aug 2024 14:04:26 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DB2D71F2150F for ; Sun, 18 Aug 2024 04:04:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5149D8BF0; Sun, 18 Aug 2024 04:04:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GUpE/8Sl" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B4B423BB for ; Sun, 18 Aug 2024 04:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953857; cv=none; b=BHPYNlvSTwLrig8IXUS0wUQeXJp8hu9QyxmeACKv3SXg0cXFGMCUny6dGENDrSdfywjsr8PcyyqCo1tKF828s73t4SkbZXMu4bmrJSgvDIJ2ZRbyQfxYFwBuEr/hFP5JeFMgcGzD8HMk4kt0cyqduT2GC0DXak/2iCf7MmU8fNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953857; c=relaxed/simple; bh=EtWvHugrUxNT4sdu1Z+EtMn5bYwRm40HZ9CSW33o400=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=egQRlRj2Fpi5WqM467SD5KwVTa6Rd+oMPrQHk0t6agmTWMeq/UA8xllFV2ZZ7PHNcwN/7sJWHQdPtNnwLov/3BuNal+UiOTfN1s30di3P9nm49m0CZHw3lyD06HBQI88uZcqABmOpxc5F/bqIk3G4DCiY3dmveM0J3h3Q/n6L4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GUpE/8Sl; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-201d5af11a4so31154195ad.3 for ; Sat, 17 Aug 2024 21:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723953855; x=1724558655; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=GTSjZi9nNnGl3bGfeswIsdohmH+e95ksi86S/JujCj4=; b=GUpE/8SlIRKW1Q3NHasRT/GKG3RcPiK3zAt/AVk6vmvE8nhOYRQBLQzQoDx0/a82VV KT5K2D+o+1Aa6mARMoz//fpxUNn2wHY6AiCPHbnB/BxwLBRQ/LpGYH7JKhDN3Py4K5aT PKMqEo6BW0+0y9JA1Lm4dbU4TD2zwpctKFvF1aFjuS9iVcg4LN1o3+XMPhgCNvQcxRNF txTilcQmkkt3Nkut4QGDf/TLsHySLq56ZKRN/zYjVMdtPq18Nbz3CGyqchMDcFrpGjYg 2kZEQ4AJXRtOFlL/MHTz5IOHBG7aSkq9+d5fV/QV6AQa6nOdFne/d8RrVSflE5/A3vXu bm3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723953855; x=1724558655; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GTSjZi9nNnGl3bGfeswIsdohmH+e95ksi86S/JujCj4=; b=bDIAJO1bNqqiN6ppxUjfmQRHOV0pT1m0mWZwAZI/G4Etay6xawU0WoOvidKH7lVUmG gmFeo+RfwscAUZaH8eM4jTwXICjN1y/wIs+NgLWYLHnujyYYRu90b9QFU+MI4ijuoH3J iOAZarvmhq6QDAy38ecfcgZd+vj54kKVjl/aPLIAwtO9nw2cSlFTAu9NIkZQpjuwdq4/ PoMOuwVp9aqEb10sXGpS6ZSfQD/8IF3DaeI9/g+Ybai17uBd9kLywGpt1Sc7a/SMCq/c byFm4lYFEeFNslIai1pjGwxzWKaXQkz1FtFwKZ6z295x5Mpe/AUWFY2DoOyltRf0400T BAig== X-Gm-Message-State: AOJu0Yyv+6v96sn/1dGgWAlmLgneDDef1WA4ZsPWYmgLc+fkSW2TyWAm DR1n4HyLuqdD+0CDhkwU+zD8pKJvJL5RxD5inlr8iJeKhVOobcoFQeDz3elD X-Google-Smtp-Source: AGHT+IGaffgR5ZIdnyy2HcB6CGOBCiE5hOOA97NKdOd6pan/2bo162VIjWTOciT4Fz7+u7Pdy0tamg== X-Received: by 2002:a17:902:e5ce:b0:1fd:6bfa:f59 with SMTP id d9443c01a7336-20203e9087bmr75144295ad.19.1723953854307; Sat, 17 Aug 2024 21:04:14 -0700 (PDT) Received: from harshads.c.googlers.com.com (27.179.83.34.bc.googleusercontent.com. [34.83.179.27]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-201f0375649sm45138235ad.124.2024.08.17.21.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 21:04:13 -0700 (PDT) From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, jack@suse.cz, harshads@google.com, Harshad Shirwadkar Subject: [PATCH] ext4: convert i_fc_lock to spinlock Date: Sun, 18 Aug 2024 04:03:46 +0000 Message-ID: <20240818040356.241684-1-harshadshirwadkar@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert ext4_inode_info->i_fc_lock to spinlock to avoid sleeping in invalid contexts. Reviewed-by: Jan Kara Signed-off-by: Harshad Shirwadkar --- fs/ext4/ext4.h | 7 +++++-- fs/ext4/fast_commit.c | 24 +++++++++++------------- fs/ext4/super.c | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 08acd1522..51ae1785a 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1062,8 +1062,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 3926a05ec..8731728cc 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -382,7 +382,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 { @@ -390,7 +390,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; @@ -424,19 +424,19 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update) struct super_block *sb = inode->i_sb; struct ext4_sb_info *sbi = EXT4_SB(sb); - mutex_unlock(&ei->i_fc_lock); + spin_unlock(&ei->i_fc_lock); if (IS_ENCRYPTED(dir)) { ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_ENCRYPTED_FILENAME, NULL); - mutex_lock(&ei->i_fc_lock); + spin_lock(&ei->i_fc_lock); return -EOPNOTSUPP; } node = kmem_cache_alloc(ext4_fc_dentry_cachep, GFP_NOFS); if (!node) { ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_NOMEM, NULL); - mutex_lock(&ei->i_fc_lock); + spin_lock(&ei->i_fc_lock); return -ENOMEM; } @@ -448,7 +448,7 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update) if (!node->fcd_name.name) { kmem_cache_free(ext4_fc_dentry_cachep, node); ext4_fc_mark_ineligible(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, @@ -482,7 +482,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; } @@ -614,10 +614,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; @@ -902,15 +900,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; ext4_debug("will try writing %d to %d for inode %ld\n", diff --git a/fs/ext4/super.c b/fs/ext4/super.c index e72145c4a..d37944839 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1423,7 +1423,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 Sun Aug 18 04:03:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1973522 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=S6DAaCUY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=+dvb=pr=vger.kernel.org=linux-ext4+bounces-3761-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wmhv42C5Mz1yXf for ; Sun, 18 Aug 2024 14:04:32 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Wmhv41ph0z4wbp for ; Sun, 18 Aug 2024 14:04:32 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Wmhv41mz8z4wc3; Sun, 18 Aug 2024 14:04:32 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=20230601 header.b=S6DAaCUY; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3761-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (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 gandalf.ozlabs.org (Postfix) with ESMTPS id 4Wmhv35hDNz4wbp for ; Sun, 18 Aug 2024 14:04:31 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D01BE1C20AFA for ; Sun, 18 Aug 2024 04:04:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33E7BBA49; Sun, 18 Aug 2024 04:04:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S6DAaCUY" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D756944F for ; Sun, 18 Aug 2024 04:04:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953860; cv=none; b=Z1HT4KFw3NzcKE+CwE7ehET+YSHG5Q+itH0Ly4sbZ5RnEVUDOzQRDDEohao7tBhksgs46mDfqWCwmpdQbXQCc1FqjxLCYFMoj6fYFwEj6oW3GGX2AdMs1y48QIXHxr9KJfWUrCzgxIbFwO7/qZw1zZC7Ab689nGVtmi0/fW7vOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953860; c=relaxed/simple; bh=1LE3dg8gghJ1wuk5hei02YIfm/Px6H0AiCfAq21vllM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SDi2ZOvVXA1ZdRfAGRC96okFbwksLRMqWUOT8ft3JCZpCVs1js0e0IJVeKm6fMq+GSKNiEoBI00SfYajts+Dpypu0zHj94Hvrlr8qtU6XDj5Ozf7xB1jS8sVAoQfU11VVWcnWS+0DPZGH/1rafN2quX+5+/8YabZTtGltS1AvyQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=S6DAaCUY; arc=none smtp.client-ip=209.85.166.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-il1-f169.google.com with SMTP id e9e14a558f8ab-39d2f638050so5765895ab.3 for ; Sat, 17 Aug 2024 21:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723953857; x=1724558657; darn=vger.kernel.org; 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=WXFociNZYmdSBS4f2g2Q4NZ/f6SsaZ5Ytw4aF/Mh0jk=; b=S6DAaCUYTid0xl33sOUeFbmZo9wgllyJ9nN0g3iZjIMLmSJnDYkk05/u7KXzEmVTyY VVglhFzDQOm8kBzSdebiYa+XzSFxhyxnooqZuOY8tRnPzYGr/Tj8yUcA4zJXkGel2wKP htncjXpxACF2XtwECc+FNnL2M49CCLHjcXmENJD4IJqoaUHxlqf8IksSETpcSMdA+341 SwAR//+aYFXp5CAgLry3BS4J78r4Mylr6fKKJFNgUvHV290JSqY/tYgrGAhEgpAB0sIm Hq9D4wrUkI7CHPP2/PDbNlUQjDZXUo96+ZoCgHnQfakJ5z3h2DMadGoUUP2qJCaofvku 1lyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723953857; x=1724558657; 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=WXFociNZYmdSBS4f2g2Q4NZ/f6SsaZ5Ytw4aF/Mh0jk=; b=w+Nd2685Dgk1RmfKpbuWxcE3dwfwirsgWHDYuf2HIKLpwB/Dq7peTo8aYTWYR7NWt5 UvAecyd5m39DplhX9GoGLebX0XYMjTrr+jSdZlJKZjrjFBE01lY0Be8HoRF8Dn3ISp/G FIILJFgYGi48p/OLC2IB4bm388tQlX6fb+ejstKSoE1bUHE6zpUrdiQIeJdePU8jwrqI 1kWtL1g71ioyo37S2OsLYx4hLLealPo85SGxJAuxb/gr4xdLrtD8Z5Bo9feWcsJ6xLBn JNwfU9qeS1TNlmTbiU+1i75/fXg3/hwVCP+Ut1LL8PtF5hbp6RHEGCEcZZQRcSkDgpes REIg== X-Gm-Message-State: AOJu0Yzt1TMa8Dn6KKP7HX9/gbSz00cPZI19QY9CtEJ55vkWBRBw54fC 56wAm61qS3YUc2PairPMUjOZjTpOt60wiVqmq38H7T8zYJGyB2wDx9UIV6tDGdg= X-Google-Smtp-Source: AGHT+IEFSMIm095p3Qhoq1k6sIqvOW+GfGo3jRpy2jvJP0GG4AUAleyKStO8Lq+KiLZqYUN3MG9gHw== X-Received: by 2002:a92:cd81:0:b0:39d:48df:e485 with SMTP id e9e14a558f8ab-39d48dfe6eamr11525165ab.17.1723953856936; Sat, 17 Aug 2024 21:04:16 -0700 (PDT) Received: from harshads.c.googlers.com.com (27.179.83.34.bc.googleusercontent.com. [34.83.179.27]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-201f0375649sm45138235ad.124.2024.08.17.21.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 21:04:16 -0700 (PDT) From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, jack@suse.cz, harshads@google.com, Harshad Shirwadkar Subject: [PATCH v7 2/9] ext4: for committing inode, make ext4_fc_track_inode wait Date: Sun, 18 Aug 2024 04:03:49 +0000 Message-ID: <20240818040356.241684-4-harshadshirwadkar@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240818040356.241684-1-harshadshirwadkar@gmail.com> References: <20240818040356.241684-1-harshadshirwadkar@gmail.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 | 33 +++++++++++++++++++++++++++++++++ fs/ext4/inline.c | 3 +++ fs/ext4/inode.c | 4 ++++ 3 files changed, 40 insertions(+) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 8731728cc..dfa999913 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -12,6 +12,7 @@ #include "ext4_extents.h" #include "mballoc.h" +#include /* * Ext4 Fast Commits * ----------------- @@ -581,6 +582,8 @@ static int __track_inode(struct inode *inode, void *arg, bool update) void ext4_fc_track_inode(handle_t *handle, struct inode *inode) { + struct ext4_inode_info *ei = EXT4_I(inode); + wait_queue_head_t *wq; int ret; if (S_ISDIR(inode->i_mode)) @@ -598,6 +601,36 @@ 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 (!list_empty(&ei->i_fc_list)) + return; + +#ifdef CONFIG_LOCKDEP + /* + * If we come here, we may sleep while waiting for the inode to + * commit. We shouldn't be holding i_data_sem when we go to sleep since + * the commit path needs to grab the lock while committing the inode. + */ + WARN_ON(lockdep_is_held(&ei->i_data_sem)); +#endif + + 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 e7a09a998..534a5c1bf 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -596,6 +596,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; @@ -696,6 +697,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) @@ -948,6 +950,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 941c1c0d5..e11f00ff8 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -636,6 +636,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 @@ -4057,6 +4058,7 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length) if (stop_block > first_block) { ext4_lblk_t hole_len = stop_block - first_block; + ext4_fc_track_inode(handle, inode); down_write(&EXT4_I(inode)->i_data_sem); ext4_discard_preallocations(inode); @@ -4210,6 +4212,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); @@ -5806,6 +5809,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 Sun Aug 18 04:03:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1973523 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=l8UbmzIH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=fvvf=pr=vger.kernel.org=linux-ext4+bounces-3762-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wmhv65GWWz1yXf for ; Sun, 18 Aug 2024 14:04:34 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Wmhv64sk1z4wbp for ; Sun, 18 Aug 2024 14:04:34 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Wmhv64qwvz4wc3; Sun, 18 Aug 2024 14:04:34 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=20230601 header.b=l8UbmzIH; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3762-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (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 gandalf.ozlabs.org (Postfix) with ESMTPS id 4Wmhv61dfgz4wbp for ; Sun, 18 Aug 2024 14:04:34 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 74D4A1C20B85 for ; Sun, 18 Aug 2024 04:04:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA894C2C6; Sun, 18 Aug 2024 04:04:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l8UbmzIH" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FD0D9479 for ; Sun, 18 Aug 2024 04:04:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953860; cv=none; b=s74o3AozoZSixxy+Ie2zX+Z0pMgFJGMdd88ZkRc2ceLx08LotFixl1xKUS09D5ojmtTTUgETd21SZSgTzvUl/1g9oc9QE2xZUxYDCm/akrgv3QzRNE6CId8pr4wbN5lht2PXJeWVNOLxtqW7zQKDauY3FsyXpOGWCFhbgyNvt9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953860; c=relaxed/simple; bh=IUrQ36vmZRhxhp5V+6AU4GDmzXED01nFCrU3YaZwT78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U2LtNvHe2MjkS3548yAH0yELJkJXqer+k7L1JeMO8WBatsUZfaIXrAaKp63INkav/PcJsLT5SFas4v41VrEBf1IATES2Sl5aQg33VjGWyZ+xeV8dKUL/L8s55WVvH3fcA9FeX7FodQ330hANHCXt9+rmo0LhdL13xus1tDJp3IE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=l8UbmzIH; arc=none smtp.client-ip=209.85.215.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-7a115c427f1so2073829a12.0 for ; Sat, 17 Aug 2024 21:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723953858; x=1724558658; darn=vger.kernel.org; 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=0KOslz8KYuhhemyu2Ap0BD0dN1NGRX8xQEs5bEuuUsA=; b=l8UbmzIHrs33vdZ6+/Up92y8QcUc7VSgyC4goIW4w09nBYZ/AS3bBHBHFAk47+AxIS yWjtf+fO1s3wZgEdpLnnsNAG7iZae9ZjEUxTMwbyQ0jU9dNc5zoJj2+ZA39/6i2PnkTb ilWCtJTig707Slj+N58EFO1qiyNj3bnMPmUUPkEVJ6jlH2RjHuGD6y2uMwhzRNt3Ahdv we36ld7CPZOxoknQghBgyTr6CcCUT9akUXJ1flCmr5r4w1QD88R4WaezB/1dVQYk/jWH +o5iE7ngUjzqLX3YS22Snv8pFEoMbkBQdguFvFx8kvTeZh6Y792L2dUQ/4eo/JlhVHIV zVYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723953858; x=1724558658; 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=0KOslz8KYuhhemyu2Ap0BD0dN1NGRX8xQEs5bEuuUsA=; b=CRvy6XAUtsWanhnYv+LAdIZZfxe0LPrNhrauc2WFn7qBHBLgK1xit8z/ysmzEQYln7 RS5zrXoMRIv9ir0d9br8uCeduCEqFAB0JvSMOXeVb6kNF4qt5kqY/5BhTEngmNe7i44f /kpbVWT1pf00DZTTyqNPmWtL/mxRBIaVLGDkKJ75+M+RYPTHLaLrsSFuC8pW+k3y7S1L RAUgoNV6OnZ4yI8xODTlaqCuJ4TtR4aB6HNPVocV6lEkcDHK6iMqFRvtG01WPj2+tz2T vVWezCPCNsexjYsGoG/sOcdiBr+lvqy/bL79Qq6Vl+hxxApv2mk6hMrjP4lpjL5wdhsB YgZg== X-Gm-Message-State: AOJu0YyF7ZMpoSQJsaBX6X7ljJVuTmEgG0SJI1bpK7pMnSCZso7ecnNT 7zToJEkbsPyWMfFxtkxEshXQ3sbXUPa+Zv/CmIv1D5V6vrUoLGZZT3T69uRt5MQ= X-Google-Smtp-Source: AGHT+IG0Gv7C3zW5KMVaxZHDgqd5TnomNqI9vNCAefb1MeDiPYh8RmuFYVNYhUiFNTVhv2urlHrtjQ== X-Received: by 2002:a05:6a21:2d84:b0:1c4:a162:502b with SMTP id adf61e73a8af0-1c904f9110dmr7936383637.20.1723953858022; Sat, 17 Aug 2024 21:04:18 -0700 (PDT) Received: from harshads.c.googlers.com.com (27.179.83.34.bc.googleusercontent.com. [34.83.179.27]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-201f0375649sm45138235ad.124.2024.08.17.21.04.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 21:04:17 -0700 (PDT) From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, jack@suse.cz, harshads@google.com, Harshad Shirwadkar Subject: [PATCH v7 3/9] ext4: mark inode dirty before grabbing i_data_sem in ext4_setattr Date: Sun, 18 Aug 2024 04:03:50 +0000 Message-ID: <20240818040356.241684-5-harshadshirwadkar@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240818040356.241684-1-harshadshirwadkar@gmail.com> References: <20240818040356.241684-1-harshadshirwadkar@gmail.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mark inode dirty first and then grab i_data_sem in ext4_setattr(). Signed-off-by: Harshad Shirwadkar --- fs/ext4/inode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index e11f00ff8..c82eba178 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5489,12 +5489,13 @@ int ext4_setattr(struct mnt_idmap *idmap, 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); - old_disksize = EXT4_I(inode)->i_disksize; - 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); + old_disksize = EXT4_I(inode)->i_disksize; + 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 Sun Aug 18 04:03:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1973524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=dvUeUa5g; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=rtb5=pr=vger.kernel.org=linux-ext4+bounces-3763-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wmhv90dv2z1yXf for ; Sun, 18 Aug 2024 14:04:37 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Wmhv90Dlyz4wbp for ; Sun, 18 Aug 2024 14:04:37 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Wmhv90Byvz4wc3; Sun, 18 Aug 2024 14:04:37 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=20230601 header.b=dvUeUa5g; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3763-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (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 gandalf.ozlabs.org (Postfix) with ESMTPS id 4Wmhv85681z4wbp for ; Sun, 18 Aug 2024 14:04:36 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A7EE72820E2 for ; Sun, 18 Aug 2024 04:04:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 261F9C8FE; Sun, 18 Aug 2024 04:04:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dvUeUa5g" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CDC9BE5E for ; Sun, 18 Aug 2024 04:04:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953861; cv=none; b=sTnx4FvXgK/ZpuM5opv/pSU9Cg1cAVBl0rwsX3Y+gqr+1jNNM4ZJ5fVCnywVasMJ4Xj6wrO2uMiXa4KK4j4sI4vIfGebda8p0D+SxYW+mBK6ZctHqHHTjv5KRFKWzGKMLCezrzVOcvduKLzFIPzdDIpCgb6ovsmHg35txxYFAzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953861; c=relaxed/simple; bh=ZRH45/GbA/wj8spu6apiE/dpMkPI/4DyKU/COyP6xi4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j5MG7XS3eWf5cDiEDmb9Y5GQZyzGFnL0xPnmEFLj7r52fXKtV824UHlhcUMMOPpYpIb7Bvn5nKcI/sg3/FYLHZmDCMvr58+SMRKQ+/YJa2jeGv9y1yygISmHYWtEaAL0npuaKEwl5k5r7EwPwv3Ufy6MJpjSPSqZF8dyhBhk0A8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dvUeUa5g; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20203988f37so19579275ad.1 for ; Sat, 17 Aug 2024 21:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723953859; x=1724558659; darn=vger.kernel.org; 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=8we5Y9yOsqQhHQ7ujgA8sVjbv7NEZ4a8pm6eVEQ6OPo=; b=dvUeUa5gru4LWSdIJuYV7s9wUE4mMxrXTGIhfcbiFMj3IMGo81kMvdCeVl7g469NFd Bd/cLZdDzPLShOFxkY4ROOovhL5l+9fEKG3EMrboZdnmp7QfOlTt5Sdyahh4dtD4G+PP d7E/PNKoB72ScvCBOOnA9Itfb3WyFZl0X4ZAOsRgp5C/mAyxPVVqGM18KT132n+ywWoP sUTzJPUmLF3KUDtOyicNa/30ZBhxzXcTAxL6Nt4/SXVaNtCYtEiC2VOIajGr/fYYBLGR caFmooReWwjprPS0EUmSVFDZafe82mKXalY2ljUtydviUmMaTfAN8WerYQhiMcet9z53 jnlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723953859; x=1724558659; 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=8we5Y9yOsqQhHQ7ujgA8sVjbv7NEZ4a8pm6eVEQ6OPo=; b=bd9Szdnb6CaUhUniBe+MYADoKIQgnBGcHsOmVaafFX/fOzZL3iamM2DeD1GC8Kb24J hK/gmvNQ9NocdA3iEnbHsImKUXsIoYqxjhZUDe9kS09sKPoCJcuBpDnEZlDnWOeDklUI q23OfTg+q5Rz20xdyqSlDDXU4Hw/7iq7e4LTFDc3ZC/2z74KGmeyPfBG4sAKPPjDjXKt bY1BpX1q9gDFxtw/Hz0EZPuFWTgCH21X+UkoRaDZ9XThdsNFgMBGlprTKau1ptQwIgVn jh9C7ijbckDKAJ8dl/86LbOr9CU0BzcW42ER3dYo4jI0+vJmqSLxujd0/zMm46yYB61A PYYw== X-Gm-Message-State: AOJu0YwGAiy96M7YHbXqtpqrieaeGo8vcjkQmro+abXSvLnHQnOYA5VE 2lVZr7Pd8ry2xwFrGteFcFcdEIxKzjd/+y4jBehU82PMYUL5fEEM5R4vCxEYOEE= X-Google-Smtp-Source: AGHT+IHzMAqv9o2HwfR0uj/nhEfBfVkiqxfOzFtGu+oqrcykjz3YTmK3B7GHO5b35KaGy3THZBwHNQ== X-Received: by 2002:a17:903:2307:b0:1fd:d4c7:dc5 with SMTP id d9443c01a7336-20203e4f84cmr95597475ad.11.1723953859105; Sat, 17 Aug 2024 21:04:19 -0700 (PDT) Received: from harshads.c.googlers.com.com (27.179.83.34.bc.googleusercontent.com. [34.83.179.27]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-201f0375649sm45138235ad.124.2024.08.17.21.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 21:04:18 -0700 (PDT) From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, jack@suse.cz, harshads@google.com, Harshad Shirwadkar Subject: [PATCH v7 4/9] ext4: rework fast commit commit path Date: Sun, 18 Aug 2024 04:03:51 +0000 Message-ID: <20240818040356.241684-6-harshadshirwadkar@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240818040356.241684-1-harshadshirwadkar@gmail.com> References: <20240818040356.241684-1-harshadshirwadkar@gmail.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- fs/ext4/fast_commit.c | 74 ++++++++++++++++++++++++++++--------------- fs/jbd2/journal.c | 2 -- 2 files changed, 49 insertions(+), 27 deletions(-) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index dfa999913..7a35234ce 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -291,20 +291,30 @@ void ext4_fc_del(struct inode *inode) if (ext4_fc_disabled(inode->i_sb)) 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 @@ -327,8 +337,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; } /* @@ -1004,19 +1012,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(journal, ei->jinode); if (ret) @@ -1129,6 +1124,19 @@ static int ext4_fc_perform_commit(journal_t *journal) int ret = 0; u32 crc = 0; + /* + * Wait for all the handles of the current transaction to complete + * and then 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; @@ -1179,6 +1187,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); @@ -1316,13 +1336,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 (tid_geq(tid, iter->i_sync_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 1ebf2393b..ecd70b506 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -728,7 +728,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; } @@ -740,7 +739,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 Sun Aug 18 04:03:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1973525 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=mAuzFlJt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=kkfg=pr=vger.kernel.org=linux-ext4+bounces-3764-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WmhvC66xZz1yXf for ; Sun, 18 Aug 2024 14:04:39 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4WmhvC5j6Gz4wbp for ; Sun, 18 Aug 2024 14:04:39 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4WmhvC5gHFz4wc3; Sun, 18 Aug 2024 14:04:39 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=20230601 header.b=mAuzFlJt; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3764-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (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 gandalf.ozlabs.org (Postfix) with ESMTPS id 4WmhvC2V4fz4wbp for ; Sun, 18 Aug 2024 14:04:39 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 84BEF1C20A83 for ; Sun, 18 Aug 2024 04:04:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24DAABE5E; Sun, 18 Aug 2024 04:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mAuzFlJt" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69D079479 for ; Sun, 18 Aug 2024 04:04:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953862; cv=none; b=AlbLb2ap0tpHAr0C/3kPJ3iwFI/sYjdeOuS2/ixyljqEFrMHpznKizojvVlXoTZ1MiL6pulHk9UI0Ke/qmZG65jgjqTWnrehSYdSU0pjke+ac+7PecepsAy/v7E7YUDfcsQDGKXSrri8gIU8/yFA45pEBNFLOJrf2J63eErJ8YI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953862; c=relaxed/simple; bh=txtsiM20Uhl52ZBBWLZh1m75l0AUGdoVtt9fLSI4dQU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=isfSFVN35sb6BfGfIY4Ar9qAaDtzXXNzV51c4kQ1POANsIt0aa4E9lEuTCboVzrhaNmgAlxpmZxVQuXumzZ6F83Kl2tklmPHuyhm2cibTbgicxo4aw+8umVav9OsezvrWGswjpayQIjlSitNWKjeQW9GyGeUruQ/dkDvHdLPRKY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mAuzFlJt; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-202146e93f6so16101485ad.3 for ; Sat, 17 Aug 2024 21:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723953860; x=1724558660; darn=vger.kernel.org; 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=GhMAO5WRN6ROa6PD7MjAvnb0SivHJRfG0HUVNNaYq5I=; b=mAuzFlJtLr937nnbCbMBiBV2RcJUm6vDB9lux9S93DXXG8Ofww49+nElV9U2/StLYd wFk8d5Ve1vdOXQuMxQB9e69eWDG/JaZJWdNsCMNEtHzwXpg8TkszOitfj7OFVS6SN8U4 VbiHivjQPlbryoUcdtdtbAtb9ehEiYpMBlUrgVsYVKZSn+ffRljQUQRXQgw1AN+Z8w1t 6eTAikPV3nobhYbCcWRqjFi8AulWXbSrlGXPOe7XwtsHCnDEKuzPgf5QRu6IAeT9BJop UFiGYYco7mH03iCRP0cL9iwFNYGBDXhY+7QUpkiuL28OAqg+czxjG/SEkMFoiIybNibU vkSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723953860; x=1724558660; 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=GhMAO5WRN6ROa6PD7MjAvnb0SivHJRfG0HUVNNaYq5I=; b=CwCWxbydIG3DwVH+e354lyXFsy4kVSQNH82MU6YkpiC5FQX1OIGJGWIkvxixtOiTGw j6LxmEi+IDetkPs6OFhsbmSKPVeY5dWJrONzAY+RX7aa3pDzmu8osYzvWR5w0l8vhIXv fCInwnXUsE/swAauiULXczr5EOGyj7Bf5wvRlb9+AFxB3AcjXfZ8AYD7bvhvsUBFDrNb 3Wp41ePyup5X/GXZQktsA1JC3pdiqij1V3SJd+UI2IG9KcYZqAUfz/g/TR70BzTh4TPZ RFwHWSWtjcRgKUihSxtS4gwzJduPcXiSgEeWQNmZdkG0djqfQb9LrntQcx7HLn047GUW kclw== X-Gm-Message-State: AOJu0YwSWVf6OTmyLH0BCqI8CfLbkdRBW1e6GZ4lkrUF4LokMSEJNMfh zy4WBQ6Cb7tr3gi+9Hex5vn/wlKfL+ImBFJbrRbaH7CHN44999Zne7fmBfdkV9s= X-Google-Smtp-Source: AGHT+IFskFzCmAtOFj7xZYod+TY9evde/Z8y/WOAqOy8TM8jLyG8E1I4L96juoFqMA97+PJOqRTgrg== X-Received: by 2002:a17:902:c946:b0:202:1bea:ec95 with SMTP id d9443c01a7336-2021beaf13amr39941505ad.15.1723953860245; Sat, 17 Aug 2024 21:04:20 -0700 (PDT) Received: from harshads.c.googlers.com.com (27.179.83.34.bc.googleusercontent.com. [34.83.179.27]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-201f0375649sm45138235ad.124.2024.08.17.21.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 21:04:19 -0700 (PDT) From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, jack@suse.cz, harshads@google.com, Harshad Shirwadkar Subject: [PATCH v7 5/9] ext4: drop i_fc_updates from inode fc info Date: Sun, 18 Aug 2024 04:03:52 +0000 Message-ID: <20240818040356.241684-7-harshadshirwadkar@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240818040356.241684-1-harshadshirwadkar@gmail.com> References: <20240818040356.241684-1-harshadshirwadkar@gmail.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 | 68 ------------------------------------------- 2 files changed, 73 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 51ae1785a..03734c523 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1056,9 +1056,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; @@ -2912,8 +2909,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 7a35234ce..1b0540f13 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -202,32 +202,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); } static bool ext4_fc_disabled(struct super_block *sb) @@ -236,48 +210,6 @@ static bool ext4_fc_disabled(struct super_block *sb) (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)); } -/* - * 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 (ext4_fc_disabled(inode->i_sb)) - 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 (ext4_fc_disabled(inode->i_sb)) - return; - - if (atomic_dec_and_test(&ei->i_fc_updates)) - wake_up_all(&ei->i_fc_wait); -} - /* * Remove inode from fast commit list. If the inode is being committed * we wait until inode commit is done. From patchwork Sun Aug 18 04:03:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1973526 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=cTZroTTU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=8x9i=pr=vger.kernel.org=linux-ext4+bounces-3765-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WmhvF44LGz1yXf for ; Sun, 18 Aug 2024 14:04:41 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4WmhvF3yjpz4wbp for ; Sun, 18 Aug 2024 14:04:41 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4WmhvF3x4Mz4wc3; Sun, 18 Aug 2024 14:04:41 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=20230601 header.b=cTZroTTU; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3765-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (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 gandalf.ozlabs.org (Postfix) with ESMTPS id 4WmhvF1jFwz4wbp for ; Sun, 18 Aug 2024 14:04:41 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E5C312820DE for ; Sun, 18 Aug 2024 04:04:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F8939479; Sun, 18 Aug 2024 04:04:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cTZroTTU" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACF59D515 for ; Sun, 18 Aug 2024 04:04:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953864; cv=none; b=sLLYPwHlu6Dks+8FDHcNnyFU0/5OlMjskSyWNw0gKOY3+Ezyu0zxj6XqsCPFAjImIf05/fw8dW2pJMelEpZcFKVR5nUIvJQB89A5lJwkk8QjtuSicYTx3H2U1enSrgwpPFyVqdsJMCQdTPJ9GhB8qkDnN2vmqbB+xTw679eg6f8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953864; c=relaxed/simple; bh=8tdJs2mMI3ljQoBFdPnJKmaY27rz9tET5lPYVfQagK4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JZrR7++tBoCFcjIPuUshiOsd7d9kKfLHzQ+vEyzIaxi/UmmBFfgfRgUKWaPCZC84RpvpX16Nr26voAKUR4A6+qcqdHGV5uhfE7fLahd8TFzOuMj4PC31zLe/fwpfOuKLRFOF/2OoSmCvysYLxxrdDtCSziE+SbrKHxbQz//eRBk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cTZroTTU; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-202146e9538so13512075ad.3 for ; Sat, 17 Aug 2024 21:04:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723953862; x=1724558662; darn=vger.kernel.org; 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=i/wXtHe34xmeXiVBZICuTMggCRLRWfylgOdo5P2lMI4=; b=cTZroTTU3s+UdfNNIWfyQtwcr+uUNI4rCAjyuJm4GmHBEKB3EVEOhewpDzmSrfpzVd ftO09U3n1hce5AerlssQZuecarKUTKeUQLqDzpjxUintdr2g6SEihgilgp+ozzBVO71j lmyb09ER+45kJmji52qkHf4bF83CoA5auiuWS2bxluwLpiH25Rhtik2AeelJNXtEI7qq caHXAH/J+oRuHGGH1O2KdUSE1GiQL0T+kCJnVI0mY0RmdppRfY9x4bl4qEL1+7vqQKdU I/AMv8gLUc0yiydsEGvZwIG5JbfflHotZhl6AOH4mcm0RAv6VaFUyS0MBbIeyhy88ctS URvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723953862; x=1724558662; 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=i/wXtHe34xmeXiVBZICuTMggCRLRWfylgOdo5P2lMI4=; b=Mz4eS4T4rnSslBnRe+N6yz3+IZs/1UzDZhZILGx+EeHVDRXy6ZdDP3Lhs5yqnKKsDR 4aD28e7Y3n5C2Sq/QHz/n7Ycx03kxILxRP2jijXvY7qZ+BbuVWkogIwWTcWuRL82UufA L9V5AcmBvYMiE3vJrOcLgzoz3B5cPKpdNxEk2R5Gw0sBT0J1oOnUzb02l7IcdTrnxMJM LU8ivgcUmEC/JYTXG5j9jTFPgK+v1DBiXrS47LyP67NnsQsMFYZFsX6bwncC+7SunGtZ XZOsFA0287kMBtAHS1Um4SWEdU4I5zffjWf1m2dqVUIubVnJCUFooPNNUIWyKaOY647U UjkA== X-Gm-Message-State: AOJu0YzaTDSZZBYEDowBS+VaARarc2hFUAL44ZbWBc4jfgjznudCMXs7 74KXWkjwps3SnSUPLgpiEeN3Wvs3YMfv/Khrz0lXsPnS2x71llxHZo2c/OcMeC8= X-Google-Smtp-Source: AGHT+IH1qOKHIAiR3vmCxpWuFvbpzxainKjUj+VdyRBhrc9q03opX0WbtzGDANH3VjS/v7Fub5FOVw== X-Received: by 2002:a17:902:d4c9:b0:1fb:31c7:857b with SMTP id d9443c01a7336-20203e4c4c8mr86631485ad.1.1723953861348; Sat, 17 Aug 2024 21:04:21 -0700 (PDT) Received: from harshads.c.googlers.com.com (27.179.83.34.bc.googleusercontent.com. [34.83.179.27]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-201f0375649sm45138235ad.124.2024.08.17.21.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 21:04:20 -0700 (PDT) From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, jack@suse.cz, harshads@google.com, Harshad Shirwadkar Subject: [PATCH v7 6/9] ext4: update code documentation Date: Sun, 18 Aug 2024 04:03:53 +0000 Message-ID: <20240818040356.241684-8-harshadshirwadkar@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240818040356.241684-1-harshadshirwadkar@gmail.com> References: <20240818040356.241684-1-harshadshirwadkar@gmail.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 1b0540f13..71cf8dc8a 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -50,14 +50,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 @@ -143,6 +150,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 * ----- * @@ -157,13 +171,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 From patchwork Sun Aug 18 04:03:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1973528 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=niSWnRKY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=2+vx=pr=vger.kernel.org=linux-ext4+bounces-3766-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WmhvM0hQrz1yfT for ; Sun, 18 Aug 2024 14:04:47 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4WmhvL6phWz4wbp for ; Sun, 18 Aug 2024 14:04:46 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4WmhvL6mxzz4wd6; Sun, 18 Aug 2024 14:04:46 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=20230601 header.b=niSWnRKY; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.80.249; helo=am.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3766-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (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 gandalf.ozlabs.org (Postfix) with ESMTPS id 4WmhvL2tcvz4wbp for ; Sun, 18 Aug 2024 14:04:46 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D63091F216EA for ; Sun, 18 Aug 2024 04:04:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75CD3DDBE; Sun, 18 Aug 2024 04:04:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="niSWnRKY" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF831D53F for ; Sun, 18 Aug 2024 04:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953865; cv=none; b=N7PK00h2qwmgzi574wNi09O9UARSMWEkB/HBJ5ALpqnzZpcdaXeoFwz6QshJhPJcCd6ib2A6zcfVuPvYGKtWHZNqIZobbgscISh/3OsiAYNndYcVkknVj6U+JQZyXRki2vyFSC6hkMi93/xt7tzBnulwCdK10RSBndGTol85/DM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953865; c=relaxed/simple; bh=OfcyM5BUqk+/OpDM/QFpNDso7UHULRTEoT1r+Dxuy6M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MbKh9JwyVlGLrZsIlTf2AYnNu/biqhBNYsIrBDqfuGQzAafyxHjgarbo+lBJ2WXfa9T+d4i5nFNiWZl8YD+TjyFtFKhjvPA5c/Qyt2gTif7wL6O8av40lNVT5Jz1ehAoGEtd/uPJVvTMY74lZM09t2yWqrcWAZaaSg5/ys9P8Zk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=niSWnRKY; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-202089e57d8so11516915ad.0 for ; Sat, 17 Aug 2024 21:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723953862; x=1724558662; darn=vger.kernel.org; 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=3/VR52+ujfglkTTT6y31UeaaSeY0D0R+4tbBAN+k2wU=; b=niSWnRKYSna7NmmvlyL+/k2dGRqHFUN/8V2t5CyU+phOHrMA8E6gceO2aXPX6OBGAW 0PZkUfMVatCxK54Q0zUMDJ68MkmaHj1hiT6KJ2HWl0pMHkyNytpJceNTv9P8CzgRC13/ jJKtG8zn+0EG6ZxAY4H7lPqy1/kOUHCgC8F4BgW0IaiW9nSfBX5xitFJ+5z0GoolDVkh ozSMzZNpLLS6iF8VLL4WIVI2ikEmWVEFdjEmLji3tZD5x60bfzsRhjMWDsGIru2YxAZ+ 1Bhc9poJkYHpmQhicH7ttYqdZ5ZbhfNYwt1JTm/EOGnS95id379vM/i+SUhyHvAfp789 KKCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723953862; x=1724558662; 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=3/VR52+ujfglkTTT6y31UeaaSeY0D0R+4tbBAN+k2wU=; b=PEAtZsxzBqa3zDAjh6datES1aS8DjEiFMu0VvxmCyXLdNSygbX1jFn63FryQlJvxVA r1MIkCQ/hIdi6/LbFPzAUxroODDPdFWHrEmp+fRn9rcVRTGh0Rbh6L+gbOfEOdMj2cKM gf1O3PXl2NPfsA91uCgv/IrNfYvXhCpOdY6OlV51U4tqEUIcC5fEaJvumG4BS/gtqfUw /79frtNakxJsDNo/6MFRKPt3a022nGa76BvGOlj8tkekjmhg0kvwZ4U/OJZ7+dZoFaER GQyUxm+zMk1X3HjrGAbsLlMUVx/trxJP3ZfSyBFhvMYCCuSj4lvB+CbOlpLRUwuTVlKE rVqA== X-Gm-Message-State: AOJu0Yzu7wp5zYpmk5OkltR0p/Hz/UpebpVocUnIJhClsEnkyHGrSDqY j69a+cPsP/KIBBA+CXXOuCoQu3GEJMSSBVREulJwjEBdwZK3TBWNs7OW2YoSicQ= X-Google-Smtp-Source: AGHT+IFWPyD2cbbrNTni4r0xZqVETvzliAualzWMYBVMv8d58iPbBjGuYrvVA7IPTNjyFMYHU/SiuA== X-Received: by 2002:a17:902:dacc:b0:1fb:7654:4a40 with SMTP id d9443c01a7336-202061eb422mr103814665ad.14.1723953862241; Sat, 17 Aug 2024 21:04:22 -0700 (PDT) Received: from harshads.c.googlers.com.com (27.179.83.34.bc.googleusercontent.com. [34.83.179.27]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-201f0375649sm45138235ad.124.2024.08.17.21.04.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 21:04:21 -0700 (PDT) From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, jack@suse.cz, harshads@google.com, Harshad Shirwadkar Subject: [PATCH v7 7/9] ext4: temporarily elevate commit thread priority Date: Sun, 18 Aug 2024 04:03:54 +0000 Message-ID: <20240818040356.241684-9-harshadshirwadkar@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240818040356.241684-1-harshadshirwadkar@gmail.com> References: <20240818040356.241684-1-harshadshirwadkar@gmail.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Unlike JBD2 based full commits, there is no dedicated journal thread for fast commits. Thus to reduce scheduling delays between IO submission and completion, temporarily elevate the committer thread's priority to match the configured priority of the JBD2 journal thread. Signed-off-by: Harshad Shirwadkar Reviewed-by: Jan Kara --- fs/ext4/ext4.h | 4 +++- fs/ext4/fast_commit.c | 13 +++++++++++++ fs/ext4/super.c | 5 ++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 03734c523..4ecb63f95 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2279,10 +2279,12 @@ static inline int ext4_forced_shutdown(struct super_block *sb) #define EXT4_DEFM_NODELALLOC 0x0800 /* - * Default journal batch times + * Default journal batch times and ioprio. */ #define EXT4_DEF_MIN_BATCH_TIME 0 #define EXT4_DEF_MAX_BATCH_TIME 15000 /* 15ms */ +#define EXT4_DEF_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3)) + /* * Minimum number of groups in a flexgroup before we separate out diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 71cf8dc8a..2fc43b1e2 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1196,6 +1196,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid) int subtid = atomic_read(&sbi->s_fc_subtid); int status = EXT4_FC_STATUS_OK, fc_bufs_before = 0; ktime_t start_time, commit_time; + int old_ioprio, journal_ioprio; if (!test_opt2(sb, JOURNAL_FAST_COMMIT)) return jbd2_complete_transaction(journal, commit_tid); @@ -1203,6 +1204,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid) trace_ext4_fc_commit_start(sb, commit_tid); start_time = ktime_get(); + old_ioprio = get_current_ioprio(); restart_fc: ret = jbd2_fc_begin_commit(journal, commit_tid); @@ -1233,6 +1235,15 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid) goto fallback; } + /* + * Now that we know that this thread is going to do a fast commit, + * elevate the priority to match that of the journal thread. + */ + if (journal->j_task->io_context) + journal_ioprio = sbi->s_journal->j_task->io_context->ioprio; + else + journal_ioprio = EXT4_DEF_JOURNAL_IOPRIO; + set_task_ioprio(current, journal_ioprio); fc_bufs_before = (sbi->s_fc_bytes + bsize - 1) / bsize; ret = ext4_fc_perform_commit(journal); if (ret < 0) { @@ -1247,6 +1258,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid) } atomic_inc(&sbi->s_fc_subtid); ret = jbd2_fc_end_commit(journal); + set_task_ioprio(current, old_ioprio); /* * weight the commit time higher than the average time so we * don't react too strongly to vast changes in the commit time @@ -1256,6 +1268,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid) return ret; fallback: + set_task_ioprio(current, old_ioprio); ret = jbd2_fc_end_commit_fallback(journal); ext4_fc_update_stats(sb, status, 0, 0, commit_tid); return ret; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index d37944839..4f38a34b0 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1817,7 +1817,6 @@ static const struct fs_parameter_spec ext4_param_specs[] = { {} }; -#define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3)) #define MOPT_SET 0x0001 #define MOPT_CLEAR 0x0002 @@ -5179,7 +5178,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) /* Set defaults for the variables that will be set during parsing */ if (!(ctx->spec & EXT4_SPEC_JOURNAL_IOPRIO)) - ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO; + ctx->journal_ioprio = EXT4_DEF_JOURNAL_IOPRIO; sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; sbi->s_sectors_written_start = @@ -6437,7 +6436,7 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb) ctx->journal_ioprio = sbi->s_journal->j_task->io_context->ioprio; else - ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO; + ctx->journal_ioprio = EXT4_DEF_JOURNAL_IOPRIO; } From patchwork Sun Aug 18 04:03:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1973527 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=F9ybEmgz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=d31m=pr=vger.kernel.org=linux-ext4+bounces-3767-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WmhvL6xtFz1yXf for ; Sun, 18 Aug 2024 14:04:46 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4WmhvL6YSnz4wc3 for ; Sun, 18 Aug 2024 14:04:46 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4WmhvL6WgQz4wd6; Sun, 18 Aug 2024 14:04:46 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=20230601 header.b=F9ybEmgz; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3767-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (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 gandalf.ozlabs.org (Postfix) with ESMTPS id 4WmhvL6RPtz4wc3 for ; Sun, 18 Aug 2024 14:04:46 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7C728B2133F for ; Sun, 18 Aug 2024 04:04:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 037499443; Sun, 18 Aug 2024 04:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F9ybEmgz" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 561E98F49 for ; Sun, 18 Aug 2024 04:04:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953866; cv=none; b=uEueYAJnTgFQ0+jY2tA2Fc4fhIHiGnOASka1SIemFa3C0MSoP3CVJ6koMUXP34rghP7GRbfiv/FpuycGpeQFug9K7spfd3xFpuGDcyKWL0ByHZ/d7aCIPE6faR+r8iYpAYfT6xceQfr+MCAmWLusZ0Wx7tb1UX2geBgRrbRrE6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953866; c=relaxed/simple; bh=zh0eKsR9VbmELRlmOLOIAPazlwMZw9HWOHNKQdNQvHc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=icEr9vh0zIiupBHMks7rFr8ZJDMIePBmTqweUBrnmpTYb3BtrXFPADYPdafa3p58KSHV48KBmUExAmFg+vYKQYVw/wJNnG18BTM8pAWFTSF3LLo61m4gtWCcGIkN4FQ7dRgiq2NOwywOpdUveAGbQ630g9TmPiMu6iEKrydv1Xg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=F9ybEmgz; arc=none smtp.client-ip=209.85.215.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-76cb5b6b3e4so2305697a12.1 for ; Sat, 17 Aug 2024 21:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723953863; x=1724558663; darn=vger.kernel.org; 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=C2boymDsqSdzTfAxaI8ixBpygJywPoivqa4eiwO8Mt0=; b=F9ybEmgzqtVhEmg8nyzB8/5XnEGZ6avfTTzjQrmK0yMHPG/PbriwbrSt5+L2uu4n2x 72ZfdzFt8ehj+k97l7JdclSeOv9GXdqYKtljgPwRfnGeSxPSeMnP0eJeIVI+jjGjItby MX3Awm/lx9rORANPkaNgN6cKKAeBAuTDnZoAlH4AC/TZkYsWQCKds6Td/5PkueH5tcTv rulih2xLW5qFfE0RoTZwt7SuIefippPKvUBZezyiLmSAcwe1QXcIG10KVOsCBi/O7KDS u48DjKlF9Lio8qLJRuZ/v49/XtaQj1WW6DFtX+qugoblNbU8ufrMTcgaYB3l4r5SlP8e FhrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723953863; x=1724558663; 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=C2boymDsqSdzTfAxaI8ixBpygJywPoivqa4eiwO8Mt0=; b=dWorRi14myapPdvFmL3F+hb9yRoFc8ot3u6kEwQatUg+ZPtaCyxBOWpJoGzpyLihg/ QPZWCXt93DjR2bRuWA2rFvq6ua7xqeiS/h1RNCA4KhAJpCOOdC4jb7vDV3XfOxFk5xGT dtTACaXMlbCdlIab0BfBN4RAhs1yC8q+BBS2QDO3DTML2N0EQ3K4lbPggiJb2p5WgtBn qKoBSNN7wrvJ0Du0CqI2s4ALmiag2K8rXCheKCRjYA66V7GimgZEnUPKerJWT2/UhLSe TRqs59vp4P+drX9jkGVkn9IDaFqriTWkrCLyazcw+9g9AiEX+WgiVUI9emKcQDRQdpIx uMZA== X-Gm-Message-State: AOJu0YzlAiLycMepgoCyzVEcQFrdMMYMEzlXj3Rb2AyMIniglMWVeT7L fPYBZD/VI18+1dvTAg3X3vkbJ6kKK0Zs2Z88dyPlPVua0Y7ySEL6gX3hdA165rA= X-Google-Smtp-Source: AGHT+IEGJPW3i4NleDO+Sara0xd3ANn2PbV0ZwTTEgN7l3exPOjxtFCiQpETnO20HE0k/XMcS7lJFA== X-Received: by 2002:a05:6a21:3984:b0:1c3:a63a:cf01 with SMTP id adf61e73a8af0-1c904f6d775mr7434708637.8.1723953863103; Sat, 17 Aug 2024 21:04:23 -0700 (PDT) Received: from harshads.c.googlers.com.com (27.179.83.34.bc.googleusercontent.com. [34.83.179.27]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-201f0375649sm45138235ad.124.2024.08.17.21.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 21:04:22 -0700 (PDT) From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, jack@suse.cz, harshads@google.com, Harshad Shirwadkar Subject: [PATCH v7 8/9] ext4: make fast commit ineligible on ext4_reserve_inode_write failure Date: Sun, 18 Aug 2024 04:03:55 +0000 Message-ID: <20240818040356.241684-10-harshadshirwadkar@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240818040356.241684-1-harshadshirwadkar@gmail.com> References: <20240818040356.241684-1-harshadshirwadkar@gmail.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Fast commit by default makes every inode on which ext4_reserve_inode_write() is called. Thus, if that function fails for some reason, make the next fast commit ineligible. Signed-off-by: Harshad Shirwadkar --- fs/ext4/fast_commit.c | 1 + fs/ext4/fast_commit.h | 1 + fs/ext4/inode.c | 29 ++++++++++++++++++----------- include/trace/events/ext4.h | 7 +++++-- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 2fc43b1e2..7525450f1 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -2282,6 +2282,7 @@ static const char * const fc_ineligible_reasons[] = { [EXT4_FC_REASON_FALLOC_RANGE] = "Falloc range op", [EXT4_FC_REASON_INODE_JOURNAL_DATA] = "Data journalling", [EXT4_FC_REASON_ENCRYPTED_FILENAME] = "Encrypted filename", + [EXT4_FC_REASON_INODE_RSV_WRITE_FAIL] = "Inode reserve write failure" }; int ext4_fc_info_show(struct seq_file *seq, void *v) diff --git a/fs/ext4/fast_commit.h b/fs/ext4/fast_commit.h index 2fadb2c47..f7f85c3dd 100644 --- a/fs/ext4/fast_commit.h +++ b/fs/ext4/fast_commit.h @@ -97,6 +97,7 @@ enum { EXT4_FC_REASON_FALLOC_RANGE, EXT4_FC_REASON_INODE_JOURNAL_DATA, EXT4_FC_REASON_ENCRYPTED_FILENAME, + EXT4_FC_REASON_INODE_RSV_WRITE_FAIL, EXT4_FC_REASON_MAX }; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index c82eba178..5a187902b 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5798,20 +5798,27 @@ ext4_reserve_inode_write(handle_t *handle, struct inode *inode, { int err; - if (unlikely(ext4_forced_shutdown(inode->i_sb))) - return -EIO; + if (unlikely(ext4_forced_shutdown(inode->i_sb))) { + err = -EIO; + goto out; + } err = ext4_get_inode_loc(inode, iloc); - if (!err) { - BUFFER_TRACE(iloc->bh, "get_write_access"); - err = ext4_journal_get_write_access(handle, inode->i_sb, - iloc->bh, EXT4_JTR_NONE); - if (err) { - brelse(iloc->bh); - iloc->bh = NULL; - } - ext4_fc_track_inode(handle, inode); + if (err) + goto out; + + BUFFER_TRACE(iloc->bh, "get_write_access"); + err = ext4_journal_get_write_access(handle, inode->i_sb, + iloc->bh, EXT4_JTR_NONE); + if (err) { + brelse(iloc->bh); + iloc->bh = NULL; } + ext4_fc_track_inode(handle, inode); +out: + if (err) + ext4_fc_mark_ineligible(inode->i_sb, + EXT4_FC_REASON_INODE_RSV_WRITE_FAIL, handle); ext4_std_error(inode->i_sb, err); return err; } diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h index cc5e9b7b2..8bab4febd 100644 --- a/include/trace/events/ext4.h +++ b/include/trace/events/ext4.h @@ -105,6 +105,7 @@ TRACE_DEFINE_ENUM(EXT4_FC_REASON_RENAME_DIR); TRACE_DEFINE_ENUM(EXT4_FC_REASON_FALLOC_RANGE); TRACE_DEFINE_ENUM(EXT4_FC_REASON_INODE_JOURNAL_DATA); TRACE_DEFINE_ENUM(EXT4_FC_REASON_ENCRYPTED_FILENAME); +TRACE_DEFINE_ENUM(EXT4_FC_REASON_INODE_RSV_WRITE_FAIL); TRACE_DEFINE_ENUM(EXT4_FC_REASON_MAX); #define show_fc_reason(reason) \ @@ -118,7 +119,8 @@ TRACE_DEFINE_ENUM(EXT4_FC_REASON_MAX); { EXT4_FC_REASON_RENAME_DIR, "RENAME_DIR"}, \ { EXT4_FC_REASON_FALLOC_RANGE, "FALLOC_RANGE"}, \ { EXT4_FC_REASON_INODE_JOURNAL_DATA, "INODE_JOURNAL_DATA"}, \ - { EXT4_FC_REASON_ENCRYPTED_FILENAME, "ENCRYPTED_FILENAME"}) + { EXT4_FC_REASON_ENCRYPTED_FILENAME, "ENCRYPTED_FILENAME"}, \ + { EXT4_FC_REASON_INODE_RSV_WRITE_FAIL, "INODE_RSV_WRITE_FAIL"}) TRACE_DEFINE_ENUM(CR_POWER2_ALIGNED); TRACE_DEFINE_ENUM(CR_GOAL_LEN_FAST); @@ -2809,7 +2811,7 @@ TRACE_EVENT(ext4_fc_stats, ), TP_printk("dev %d,%d fc ineligible reasons:\n" - "%s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u" + "%s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u" "num_commits:%lu, ineligible: %lu, numblks: %lu", MAJOR(__entry->dev), MINOR(__entry->dev), FC_REASON_NAME_STAT(EXT4_FC_REASON_XATTR), @@ -2822,6 +2824,7 @@ TRACE_EVENT(ext4_fc_stats, FC_REASON_NAME_STAT(EXT4_FC_REASON_FALLOC_RANGE), FC_REASON_NAME_STAT(EXT4_FC_REASON_INODE_JOURNAL_DATA), FC_REASON_NAME_STAT(EXT4_FC_REASON_ENCRYPTED_FILENAME), + FC_REASON_NAME_STAT(EXT4_FC_REASON_INODE_RSV_WRITE_FAIL), __entry->fc_commits, __entry->fc_ineligible_commits, __entry->fc_numblks) ); From patchwork Sun Aug 18 04:03:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: harshad shirwadkar X-Patchwork-Id: 1973529 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=dMx7DOCD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=3++j=pr=vger.kernel.org=linux-ext4+bounces-3768-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WmhvP26D5z1yXf for ; Sun, 18 Aug 2024 14:04:49 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4WmhvP1kQ7z4wbp for ; Sun, 18 Aug 2024 14:04:49 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4WmhvP1h9kz4wc3; Sun, 18 Aug 2024 14:04:49 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=20230601 header.b=dMx7DOCD; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3768-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (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 gandalf.ozlabs.org (Postfix) with ESMTPS id 4WmhvN6XJdz4wbp for ; Sun, 18 Aug 2024 14:04:48 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5C59B282090 for ; Sun, 18 Aug 2024 04:04:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40196F9D4; Sun, 18 Aug 2024 04:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dMx7DOCD" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 589168F6E for ; Sun, 18 Aug 2024 04:04:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953867; cv=none; b=plYNKtQwgwZYCSGLardxj8qq38UhADmXF9gAVVMGxTr7hyhBMzVJTHQ2l8jYpImie4PLCD6AILc/+in1Y1N5y3gfJwbITZtHmJaYWwN81moUZ812hS4B+jsIVAEaLVx/VLmMJr7SgfcGb3S9DgavER+U77waXB2iVaHzBOXcGgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723953867; c=relaxed/simple; bh=nam/sHzKfJOlxI4NWlgMeLr1iGCq7p/Tn/9TMk6L1sw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dQ6cP4MV2yqAYFcI4BT5ZDCNEcE1Amz/jNNpFf/+4kIOM9AF+HycDL78YFyzOytRTkHUe4HyAysrCOmy9A9WWmw5QyBaK4LOuFDQag9XEwtLoHa5GLoMSJds7NiLN+uX2MR30Q8V+752OJZ+FqgPTIpZH+32QwOI365+OLkol9Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dMx7DOCD; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2021537a8e6so13863565ad.2 for ; Sat, 17 Aug 2024 21:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723953864; x=1724558664; darn=vger.kernel.org; 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=DWjO9kA7p3Bwhao1YgQrEQOOMP5A0f9KQkfCnVpY9hY=; b=dMx7DOCDztZKajjnuCWLj/t1c0ADl/Vm926R7alaLrKfS/e5e9t7i3VVLYx+Yst1xD k6hIccdlpT1oJTLinX+cUswYsHvc9djWvQWImPAzkdEWzjiAPslg99D/KCAeHXLt/PEH 0rQ0yFWPZlH8DLITH1bXt/yVsHuoD/PBURvco24D7yACzmd9/g4KPZgN0f4A6EqZuiuN khgJB4YvLGOxXAJRQFmZgDs+Tqlr1PgTWsdu8SJxYHX6M+JeMDeYClI0SyemM0AXWcPG kIl2QeDjlGtUIgQNxOBzbtZj27TaKC9JInd9CpSBBVDNSbCL6kaGv9VJL3WiG4m97OI1 fAZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723953864; x=1724558664; 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=DWjO9kA7p3Bwhao1YgQrEQOOMP5A0f9KQkfCnVpY9hY=; b=L1PD4zIp6Ii2ZP9BiRx3EhB/cgpq4jggrdqRzeBnyIB/Ou5MfbZim9uPrXBbb5PhGP 5dBmZAceasf7F6bGe4P5AeHQQ0N2r1fFcZOkeV/ynhbdicaGyOt20dBMOfAb7P4zzYET 8BCV4+8x0l6tfFn6CNk2p2Ik9yutp0r8VtTY3u+j73pbo2Otel/yC/ZVOWY4E79+RFEp 4r+me6RwV0CDwLrIhX3NLOXmOyr65/6PZuQfCbLB0vz7B1p49cNqiE6d9kHqwWD7G403 ofHoZM/sUZdFMLkbbHGd4rUYDWF642NPQkjvygpnDtbJaQ/yDPM/DbMW0NktVCrAo6n2 xE2A== X-Gm-Message-State: AOJu0YwES91yBbtK/kY3u99rGxRialvbXaw6tHvTqWlWB3hUl2sUU6Nn V0j3TuU6ojdgpJXLh4pF08FvZ0rBUW/L1on0dJK9riVzafhRLNkC9kzjSfvWggQ= X-Google-Smtp-Source: AGHT+IHQvqoGJAHlGaavEqM1YoqkGZmzFCbCSUQFOOcKHjwNxpC/8xif1GRP+YonupOi7n3Tnynjyg== X-Received: by 2002:a17:903:2303:b0:1ff:4967:66a with SMTP id d9443c01a7336-20203e88843mr86121165ad.14.1723953864198; Sat, 17 Aug 2024 21:04:24 -0700 (PDT) Received: from harshads.c.googlers.com.com (27.179.83.34.bc.googleusercontent.com. [34.83.179.27]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-201f0375649sm45138235ad.124.2024.08.17.21.04.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 21:04:23 -0700 (PDT) From: Harshad Shirwadkar To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, jack@suse.cz, harshads@google.com, Harshad Shirwadkar Subject: [PATCH v7 9/9] ext4: hold s_fc_lock while during fast commit Date: Sun, 18 Aug 2024 04:03:56 +0000 Message-ID: <20240818040356.241684-11-harshadshirwadkar@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240818040356.241684-1-harshadshirwadkar@gmail.com> References: <20240818040356.241684-1-harshadshirwadkar@gmail.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Leaving s_fc_lock in between during commit in ext4_fc_perform_commit() function leaves room for subtle concurrency bugs where ext4_fc_del() may delete an inode from the fast commit list, leaving list in an inconsistent state. Also, this patch converts s_fc_lock to mutex type so that it can be held when kmem_cache_* functions are called. Signed-off-by: Harshad Shirwadkar --- fs/ext4/ext4.h | 2 +- fs/ext4/fast_commit.c | 91 +++++++++++++++++-------------------------- fs/ext4/super.c | 2 +- 3 files changed, 38 insertions(+), 57 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 4ecb63f95..a1acd34ff 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1748,7 +1748,7 @@ struct ext4_sb_info { * following fields: * ei->i_fc_list, s_fc_dentry_q, s_fc_q, s_fc_bytes, s_fc_bh. */ - spinlock_t s_fc_lock; + struct mutex s_fc_lock; struct buffer_head *s_fc_bh; struct ext4_fc_stats s_fc_stats; tid_t s_fc_ineligible_tid; diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 7525450f1..c3627efd9 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -236,9 +236,9 @@ void ext4_fc_del(struct inode *inode) if (ext4_fc_disabled(inode->i_sb)) return; - spin_lock(&EXT4_SB(inode->i_sb)->s_fc_lock); + mutex_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); + mutex_unlock(&EXT4_SB(inode->i_sb)->s_fc_lock); return; } @@ -266,7 +266,7 @@ void ext4_fc_del(struct inode *inode) * dentry create references, since it is not needed to log it anyways. */ if (list_empty(&ei->i_fc_dilist)) { - spin_unlock(&sbi->s_fc_lock); + mutex_unlock(&sbi->s_fc_lock); return; } @@ -276,7 +276,7 @@ void ext4_fc_del(struct inode *inode) list_del_init(&fc_dentry->fcd_dilist); WARN_ON(!list_empty(&ei->i_fc_dilist)); - spin_unlock(&sbi->s_fc_lock); + mutex_unlock(&sbi->s_fc_lock); if (fc_dentry->fcd_name.name && fc_dentry->fcd_name.len > DNAME_INLINE_LEN) @@ -306,10 +306,10 @@ void ext4_fc_mark_ineligible(struct super_block *sb, int reason, handle_t *handl sbi->s_journal->j_running_transaction->t_tid : 0; read_unlock(&sbi->s_journal->j_state_lock); } - spin_lock(&sbi->s_fc_lock); + mutex_lock(&sbi->s_fc_lock); if (tid_gt(tid, sbi->s_fc_ineligible_tid)) sbi->s_fc_ineligible_tid = tid; - spin_unlock(&sbi->s_fc_lock); + mutex_unlock(&sbi->s_fc_lock); WARN_ON(reason >= EXT4_FC_REASON_MAX); sbi->s_fc_stats.fc_ineligible_reason_count[reason]++; } @@ -349,14 +349,14 @@ static int ext4_fc_track_template( if (!enqueue) return ret; - spin_lock(&sbi->s_fc_lock); + mutex_lock(&sbi->s_fc_lock); if (list_empty(&EXT4_I(inode)->i_fc_list)) list_add_tail(&EXT4_I(inode)->i_fc_list, (sbi->s_journal->j_flags & JBD2_FULL_COMMIT_ONGOING || sbi->s_journal->j_flags & JBD2_FAST_COMMIT_ONGOING) ? &sbi->s_fc_q[FC_Q_STAGING] : &sbi->s_fc_q[FC_Q_MAIN]); - spin_unlock(&sbi->s_fc_lock); + mutex_unlock(&sbi->s_fc_lock); return ret; } @@ -414,7 +414,8 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update) } node->fcd_name.len = dentry->d_name.len; INIT_LIST_HEAD(&node->fcd_dilist); - spin_lock(&sbi->s_fc_lock); + INIT_LIST_HEAD(&node->fcd_list); + mutex_lock(&sbi->s_fc_lock); if (sbi->s_journal->j_flags & JBD2_FULL_COMMIT_ONGOING || sbi->s_journal->j_flags & JBD2_FAST_COMMIT_ONGOING) list_add_tail(&node->fcd_list, @@ -435,7 +436,7 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update) WARN_ON(!list_empty(&ei->i_fc_dilist)); list_add_tail(&node->fcd_dilist, &ei->i_fc_dilist); } - spin_unlock(&sbi->s_fc_lock); + mutex_unlock(&sbi->s_fc_lock); spin_lock(&ei->i_fc_lock); return 0; @@ -955,15 +956,15 @@ static int ext4_fc_submit_inode_data_all(journal_t *journal) struct ext4_inode_info *ei; int ret = 0; - spin_lock(&sbi->s_fc_lock); + mutex_lock(&sbi->s_fc_lock); list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { - spin_unlock(&sbi->s_fc_lock); + mutex_unlock(&sbi->s_fc_lock); ret = jbd2_submit_inode_data(journal, ei->jinode); if (ret) return ret; - spin_lock(&sbi->s_fc_lock); + mutex_lock(&sbi->s_fc_lock); } - spin_unlock(&sbi->s_fc_lock); + mutex_unlock(&sbi->s_fc_lock); return ret; } @@ -976,19 +977,19 @@ static int ext4_fc_wait_inode_data_all(journal_t *journal) struct ext4_inode_info *pos, *n; int ret = 0; - spin_lock(&sbi->s_fc_lock); + mutex_lock(&sbi->s_fc_lock); list_for_each_entry_safe(pos, n, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { if (!ext4_test_inode_state(&pos->vfs_inode, EXT4_STATE_FC_COMMITTING)) continue; - spin_unlock(&sbi->s_fc_lock); + mutex_unlock(&sbi->s_fc_lock); ret = jbd2_wait_inode_data(journal, pos->jinode); if (ret) return ret; - spin_lock(&sbi->s_fc_lock); + mutex_lock(&sbi->s_fc_lock); } - spin_unlock(&sbi->s_fc_lock); + mutex_unlock(&sbi->s_fc_lock); return 0; } @@ -1010,26 +1011,22 @@ __releases(&sbi->s_fc_lock) list_for_each_entry_safe(fc_dentry, fc_dentry_n, &sbi->s_fc_dentry_q[FC_Q_MAIN], fcd_list) { if (fc_dentry->fcd_op != EXT4_FC_TAG_CREAT) { - spin_unlock(&sbi->s_fc_lock); - if (!ext4_fc_add_dentry_tlv(sb, crc, fc_dentry)) { - ret = -ENOSPC; - goto lock_and_exit; - } - spin_lock(&sbi->s_fc_lock); + if (!ext4_fc_add_dentry_tlv(sb, crc, fc_dentry)) + return -ENOSPC; continue; } /* * With fcd_dilist we need not loop in sbi->s_fc_q to get the - * corresponding inode pointer + * corresponding inode. Also, the corresponding inode could have been + * deleted, in which case, we don't need to do anything. */ - WARN_ON(list_empty(&fc_dentry->fcd_dilist)); + if (list_empty(&fc_dentry->fcd_dilist)) + continue; ei = list_first_entry(&fc_dentry->fcd_dilist, struct ext4_inode_info, i_fc_dilist); inode = &ei->vfs_inode; WARN_ON(inode->i_ino != fc_dentry->fcd_ino); - spin_unlock(&sbi->s_fc_lock); - /* * We first write the inode and then the create dirent. This * allows the recovery code to create an unnamed inode first @@ -1039,23 +1036,14 @@ __releases(&sbi->s_fc_lock) */ ret = ext4_fc_write_inode(inode, crc); if (ret) - goto lock_and_exit; - + return ret; ret = ext4_fc_write_inode_data(inode, crc); if (ret) - goto lock_and_exit; - - if (!ext4_fc_add_dentry_tlv(sb, crc, fc_dentry)) { - ret = -ENOSPC; - goto lock_and_exit; - } - - spin_lock(&sbi->s_fc_lock); + return ret; + if (!ext4_fc_add_dentry_tlv(sb, crc, fc_dentry)) + return -ENOSPC; } return 0; -lock_and_exit: - spin_lock(&sbi->s_fc_lock); - return ret; } static int ext4_fc_perform_commit(journal_t *journal) @@ -1074,12 +1062,12 @@ static int ext4_fc_perform_commit(journal_t *journal) * and then lock the journal. */ jbd2_journal_lock_updates(journal); - spin_lock(&sbi->s_fc_lock); + mutex_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); + mutex_unlock(&sbi->s_fc_lock); jbd2_journal_unlock_updates(journal); ret = ext4_fc_submit_inode_data_all(journal); @@ -1113,19 +1101,16 @@ static int ext4_fc_perform_commit(journal_t *journal) } } - spin_lock(&sbi->s_fc_lock); + mutex_lock(&sbi->s_fc_lock); ret = ext4_fc_commit_dentry_updates(journal, &crc); - if (ret) { - spin_unlock(&sbi->s_fc_lock); + if (ret) goto out; - } list_for_each_entry(iter, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { inode = &iter->vfs_inode; if (!ext4_test_inode_state(inode, EXT4_STATE_FC_COMMITTING)) continue; - spin_unlock(&sbi->s_fc_lock); ret = ext4_fc_write_inode_data(inode, &crc); if (ret) goto out; @@ -1144,13 +1129,11 @@ static int ext4_fc_perform_commit(journal_t *journal) #else wake_up_bit(&iter->i_flags, EXT4_STATE_FC_COMMITTING); #endif - spin_lock(&sbi->s_fc_lock); } - spin_unlock(&sbi->s_fc_lock); - ret = ext4_fc_write_tail(sb, crc); out: + mutex_unlock(&sbi->s_fc_lock); blk_finish_plug(&plug); return ret; } @@ -1291,7 +1274,7 @@ static void ext4_fc_cleanup(journal_t *journal, int full, tid_t tid) trace_ext4_fc_cleanup(journal, full, tid); jbd2_fc_release_bufs(journal); - spin_lock(&sbi->s_fc_lock); + mutex_lock(&sbi->s_fc_lock); list_for_each_entry_safe(iter, iter_n, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { ext4_clear_inode_state(&iter->vfs_inode, @@ -1318,13 +1301,11 @@ static void ext4_fc_cleanup(journal_t *journal, int full, tid_t tid) fcd_list); list_del_init(&fc_dentry->fcd_list); list_del_init(&fc_dentry->fcd_dilist); - spin_unlock(&sbi->s_fc_lock); if (fc_dentry->fcd_name.name && fc_dentry->fcd_name.len > DNAME_INLINE_LEN) kfree(fc_dentry->fcd_name.name); kmem_cache_free(ext4_fc_dentry_cachep, fc_dentry); - spin_lock(&sbi->s_fc_lock); } list_splice_init(&sbi->s_fc_dentry_q[FC_Q_STAGING], @@ -1339,7 +1320,7 @@ static void ext4_fc_cleanup(journal_t *journal, int full, tid_t tid) if (full) sbi->s_fc_bytes = 0; - spin_unlock(&sbi->s_fc_lock); + mutex_unlock(&sbi->s_fc_lock); trace_ext4_fc_stats(sb); } diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 4f38a34b0..bef9fd128 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4436,7 +4436,7 @@ static void ext4_fast_commit_init(struct super_block *sb) sbi->s_fc_bytes = 0; ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); sbi->s_fc_ineligible_tid = 0; - spin_lock_init(&sbi->s_fc_lock); + mutex_init(&sbi->s_fc_lock); memset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats)); sbi->s_fc_replay_state.fc_regions = NULL; sbi->s_fc_replay_state.fc_regions_size = 0;