From patchwork Fri Mar 28 16:15:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 14032228 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85C551DD0E7; Fri, 28 Mar 2025 16:16:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743178579; cv=none; b=iL/I6M/lthvJryKc9ZNpSUv2FKwqHUCKmRhAf6DRvC/H9UCJ8obbB+syVkPAijWOtyjHlKxebrP5BfVRdWLI0NrkRTAAmQ+AWku/jbXYsMbUWDQmIPfJuWevzXRVtm1z0iPMymzX2srvdtMV/GyvyylTecn7vbabw8QT4Kb3LNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743178579; c=relaxed/simple; bh=tXNgHPkpI1RYcg6+uolFMirXAFbH/6dKuJTHpZX5Tj8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C5P4NIeb9YbL9Qi/GCN7Mb9vxfSQoTynPHuCS8j0Dj6vH8HbaPO8pxIcnmYBV1BkJ5fGrk2U7jPzBNfWbqdNPeJm3SHlYKrUKYm/ufeCg3/WlVyHo9C7tLJMtaC77FScWX8EI1qvUMJdJT0Fk0xH2OvyvGDtOaSKk2DNDh+CJGE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EyhuXGf2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EyhuXGf2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE676C4CEE5; Fri, 28 Mar 2025 16:16:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743178578; bh=tXNgHPkpI1RYcg6+uolFMirXAFbH/6dKuJTHpZX5Tj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EyhuXGf281TnYATQKatubpErzYkG1h+BNwDsUshE4fPss+QazVEBqi2jufIopsnwj ZcstGZ20IjlCt0ski02ckI3ZnkYTvE+NBhNTF73N6wimaU3fHUIZkmMRKvhOm8VKJL PapxbW+5scJo5si76/dM5PSJg8ZceQfVJJ7LdzmyPL7G/UW0SRWX+TZsja3PigKbrm Eg/mAJUhAHeKwYvtScxCGed3GJJGJC9eyj71h63c1nSBKROZFYIpvGL/9TYsE2jT/0 vSlpOKQlZsycslyhn2pYZirTHp7+GgDsmgXf7i39BE/ZC6OA9A2cB+ZvLBjr9jOIrc gBlPHHT7bOS7g== From: Christian Brauner To: linux-fsdevel@vger.kernel.org, jack@suse.cz Cc: Christian Brauner , linux-kernel@vger.kernel.org, James Bottomley , mcgrof@kernel.org, hch@infradead.org, david@fromorbit.com, rafael@kernel.org, djwong@kernel.org, pavel@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com Subject: [PATCH 1/6] super: remove pointless s_root checks Date: Fri, 28 Mar 2025 17:15:53 +0100 Message-ID: <20250328-work-freeze-v1-1-a2c3a6b0e7a6@kernel.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250328-work-freeze-v1-0-a2c3a6b0e7a6@kernel.org> References: <20250328-work-freeze-v1-0-a2c3a6b0e7a6@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-42535 X-Developer-Signature: v=1; a=openpgp-sha256; l=1525; i=brauner@kernel.org; h=from:subject:message-id; bh=tXNgHPkpI1RYcg6+uolFMirXAFbH/6dKuJTHpZX5Tj8=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ/O+1od56r/YvzzdI/Ep2qs91n3hEM0jgc9Oi+wCnT1 bN81yfndpSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEzEcj3DL+bH72Y/nPdru6jP 8S7JGc91xFX9Kjstj9Tejitd7WSoU87wV4bL/YLBiecHHiR+5pjEX744mnXyRI9Thcfv9VVPZ2h 6zQAA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 The locking guarantees that the superblock is alive and sb->s_root is still set. Remove the pointless check. Signed-off-by: Christian Brauner --- fs/super.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/fs/super.c b/fs/super.c index 97a17f9d9023..dc14f4bf73a6 100644 --- a/fs/super.c +++ b/fs/super.c @@ -930,8 +930,7 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg) locked = super_lock_shared(sb); if (locked) { - if (sb->s_root) - f(sb, arg); + f(sb, arg); super_unlock_shared(sb); } @@ -967,11 +966,8 @@ void iterate_supers_type(struct file_system_type *type, spin_unlock(&sb_lock); locked = super_lock_shared(sb); - if (locked) { - if (sb->s_root) - f(sb, arg); - super_unlock_shared(sb); - } + if (locked) + f(sb, arg); spin_lock(&sb_lock); if (p) @@ -991,18 +987,15 @@ struct super_block *user_get_super(dev_t dev, bool excl) spin_lock(&sb_lock); list_for_each_entry(sb, &super_blocks, s_list) { - if (sb->s_dev == dev) { + if (sb->s_dev == dev) { bool locked; sb->s_count++; spin_unlock(&sb_lock); /* still alive? */ locked = super_lock(sb, excl); - if (locked) { - if (sb->s_root) - return sb; - super_unlock(sb, excl); - } + if (locked) + return sb; /* caller will drop */ /* nope, got unmounted */ spin_lock(&sb_lock); __put_super(sb); From patchwork Fri Mar 28 16:15:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 14032229 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3752E1DE2C0; Fri, 28 Mar 2025 16:16:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743178582; cv=none; b=ibj7p8Jg8FJOCuOEux3UFxz73+ZSyBWhTBaE4NHvtzh4iNlrJq4FacB7gDAFNp6PUBgwX6ACIclExzvEFucSkv2P+glqkdIuLw3RJytMuKLa3B7d+Q3LCl8i1zW0osLlE/CNpTjTwzq2Ip0bkJ/IOGhricnAIe4mYpHQM9akIws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743178582; c=relaxed/simple; bh=kQuw8pGOEj2HTHUntYvMH05/2F/1BJUoN/04q2b6wh8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IhGIbSWX0ZpoxXrl6FTllCxLkMjRGJaBuBfSEX8W14xrLyvRbtEyi3urBTJrgtVYH+3CJXxL5cp1Ei7ztGioKNBB4T5/RME9k3AydwOJGnwS8nLQgxg2y5f1Axy5NyoRUIyo93JKmw+rNoFD3Wpe2PpqXbu51ift2xpQAkIJgSw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Lm31kvul; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Lm31kvul" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72AAEC4CEE4; Fri, 28 Mar 2025 16:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743178581; bh=kQuw8pGOEj2HTHUntYvMH05/2F/1BJUoN/04q2b6wh8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lm31kvul7AwKcTDG+YwF4v5co9neROI5sp5Bv1GFESi2g9jxkw4vgGfc6cRo7jhXF oNUXP/dMZbABXaHvlixOfZIABgJMa5z2jrF6p4v2NbZSgs/+s6n5JKqfamgoKq8rje Ugv9/V20Bdv531dPwui1rS3jWu2GfsB+tz2xm6YMOmvCHO6HwVjje6TXlZPsvbiehb NTvCELgl9ZcKK5dLGaGGcy62ixX6RhZfq1OGDjCVtVQmoZ3cveq9Y7yMghK+ubVB65 S/JCQlnw8nNo+Sfj1ObUmbC7zM8lGow5YkQ/FLg+rnEQaqohORcHQuVCZSHYLGWyWA zVC6zL3U4/V7Q== From: Christian Brauner To: linux-fsdevel@vger.kernel.org, jack@suse.cz Cc: Christian Brauner , linux-kernel@vger.kernel.org, James Bottomley , mcgrof@kernel.org, hch@infradead.org, david@fromorbit.com, rafael@kernel.org, djwong@kernel.org, pavel@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com Subject: [PATCH 2/6] super: simplify user_get_super() Date: Fri, 28 Mar 2025 17:15:54 +0100 Message-ID: <20250328-work-freeze-v1-2-a2c3a6b0e7a6@kernel.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250328-work-freeze-v1-0-a2c3a6b0e7a6@kernel.org> References: <20250328-work-freeze-v1-0-a2c3a6b0e7a6@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-42535 X-Developer-Signature: v=1; a=openpgp-sha256; l=1111; i=brauner@kernel.org; h=from:subject:message-id; bh=kQuw8pGOEj2HTHUntYvMH05/2F/1BJUoN/04q2b6wh8=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ/O+0014vH+bvWSfkOnz6BrL22ZhUXV3CKX75wdkL3R qMKfdW4jlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgInsWczI8HbtRaM8JqXAvPv3 TSdvzbl03Mlqp/6ukidxItNWP3d+K8XI8OWx8XFt9+KnATxibw9u2su3OK+t6ZuE36aZUYdCXRY EsAIA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Make it easier to read and remove one level of identation. Signed-off-by: Christian Brauner --- fs/super.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/fs/super.c b/fs/super.c index dc14f4bf73a6..b1acfc38ba0c 100644 --- a/fs/super.c +++ b/fs/super.c @@ -987,20 +987,21 @@ struct super_block *user_get_super(dev_t dev, bool excl) spin_lock(&sb_lock); list_for_each_entry(sb, &super_blocks, s_list) { - if (sb->s_dev == dev) { - bool locked; - - sb->s_count++; - spin_unlock(&sb_lock); - /* still alive? */ - locked = super_lock(sb, excl); - if (locked) - return sb; /* caller will drop */ - /* nope, got unmounted */ - spin_lock(&sb_lock); - __put_super(sb); - break; - } + bool locked; + + if (sb->s_dev != dev) + continue; + + sb->s_count++; + spin_unlock(&sb_lock); + + locked = super_lock(sb, excl); + if (locked) + return sb; + + spin_lock(&sb_lock); + __put_super(sb); + break; } spin_unlock(&sb_lock); return NULL; From patchwork Fri Mar 28 16:15:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 14032230 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BA451DE880; Fri, 28 Mar 2025 16:16:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743178585; cv=none; b=q1ZU5e8wwnK4hnSenYgnzmSYk6aKxHUSfMeAnXFr/gearVYLbnqakXLOd0jZjbHtwspF0CfDCGF3o6190MfeGPoHBITTR6+JvW+oh/0OM2kDefnmBPv41d3hNKoFD5r5t0y4AMnAxTCRv2LQqu2eJNeEqXfppC2Ec0Qb1d10NeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743178585; c=relaxed/simple; bh=VP5XAT1jJt6izLv0u8XXhMb9Lleyzfaa/ssDFxRDreY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jCl8ZbIa5EX20LlUocYWknV12QFY4MGhShD/AGzGZUOCKd8VD4vkjHgaOu1wJJ53wv8FxtKInB6GSjy3iRP9wBxy/zwiLaSkJ9R0tFwuP5Rms0Dw2mTKMx1stuKP+v5FwRpz+Tla9uAVgpKVUGMmgFqsWV9hE1grZbNElSR7ErA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IDYpcEGa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IDYpcEGa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25026C4CEE9; Fri, 28 Mar 2025 16:16:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743178585; bh=VP5XAT1jJt6izLv0u8XXhMb9Lleyzfaa/ssDFxRDreY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IDYpcEGa1GfZwLOMaP5X0GexBFrkaAgfBFPZgK/TDrfW/ySSG+wWHwbCf4Qsj93Dk KodHubbCOZcTP8GFAaF0YKhkmSFGq549eowFWgKViPOBtV267dsWSIFJSa7VO2ePIt xgPXsWjsSPGC9+ix9TjiWHxkkKlrfUap73bHIvktpFSRqzFsmBlXKi2dBVzSOI4cXJ nD4n1Rp66CO9kontBgvKUkmJKqyiU6xFg3ORSKBAqUB4qIW5roCA4dd1eucUZ0Cx8h PWZIXvoDs+BQEfK6XasD+mmgUkpQ+iHIzS4f0MOLChtc/zomSi4T7TWucJ5pOX2TVe EBC0vH60BKRvw== From: Christian Brauner To: linux-fsdevel@vger.kernel.org, jack@suse.cz Cc: Christian Brauner , linux-kernel@vger.kernel.org, James Bottomley , mcgrof@kernel.org, hch@infradead.org, david@fromorbit.com, rafael@kernel.org, djwong@kernel.org, pavel@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com Subject: [PATCH 3/6] super: skip dying superblocks early Date: Fri, 28 Mar 2025 17:15:55 +0100 Message-ID: <20250328-work-freeze-v1-3-a2c3a6b0e7a6@kernel.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250328-work-freeze-v1-0-a2c3a6b0e7a6@kernel.org> References: <20250328-work-freeze-v1-0-a2c3a6b0e7a6@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-42535 X-Developer-Signature: v=1; a=openpgp-sha256; l=870; i=brauner@kernel.org; h=from:subject:message-id; bh=VP5XAT1jJt6izLv0u8XXhMb9Lleyzfaa/ssDFxRDreY=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ/O+0ko9E1857HZo/LQgW3jrzuXHk5M6BWyb5dpP7cT wFOz1k/OkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACZypJKR4bzQzc3SqwRtNjoX r6/+85t9XpIy47rfYRw/15W3epwuWsfIcOOjo7xiU7R5pu+XsIA3b+4m5y7T4fPzn/9aVXkjv7g uOwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Make all iterators uniform by performing an early check whether the superblock is dying. Signed-off-by: Christian Brauner --- fs/super.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/super.c b/fs/super.c index b1acfc38ba0c..c67ea3cdda41 100644 --- a/fs/super.c +++ b/fs/super.c @@ -925,6 +925,9 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg) list_for_each_entry(sb, &super_blocks, s_list) { bool locked; + if (super_flags(sb, SB_DYING)) + continue; + sb->s_count++; spin_unlock(&sb_lock); @@ -962,6 +965,9 @@ void iterate_supers_type(struct file_system_type *type, hlist_for_each_entry(sb, &type->fs_supers, s_instances) { bool locked; + if (super_flags(sb, SB_DYING)) + continue; + sb->s_count++; spin_unlock(&sb_lock); From patchwork Fri Mar 28 16:15:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 14032231 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4CEC1DA0E0; Fri, 28 Mar 2025 16:16:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743178589; cv=none; b=PgOWG50Vr7Cq/vIhaBbJ+CrUjVzitAfRwSj+fc5rc85RnDpR7Gvo1WHdsHA9+UkL3DoYlsrMOp0ZRHO8kESeerxsuVKSo/x6zUuvBzB1CgRJeT4VMRL1M2U898PQGMW6qaGLFKeOSHhnUF5EW4OZuFrM3a3mzGBIQTioUdfQGYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743178589; c=relaxed/simple; bh=kSJquFBWZLjXohp7CdfSUxcMmSKnA8vBlSuTa7rPH5k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ks9zOA/8mb3bWeQbN1KoA2TOhCXVuwZfiCPIKgSW15O0Iiw9vIga6kBa5vdJIUZ2B+K5KoKemSAdBv8vN/yudqInVaitXfyDl2GwQV3yUGCz9n+FWBSlr3Q9AKW3VWVG2uhnoWcBNfoXP82zUBdRJkfzIKZZWjzE+Dydc6U55iQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Gg6CgXrl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Gg6CgXrl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBF4CC4AF0B; Fri, 28 Mar 2025 16:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743178589; bh=kSJquFBWZLjXohp7CdfSUxcMmSKnA8vBlSuTa7rPH5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gg6CgXrlayeZxMX/C5pzqKo8bxgz219Ywzf7XWrUTiGXM6NI+aKrT2dbdQFZfgQtT IdW0rkYRTnNupBKxmcQl6cwOPrLG+cf+8LQN6HzNsua8dnXJgzKl+7zj5Yg0pPwdR2 tE+3TGBBaJHksIDWaTNp3VhbANXoNB9DE9AMVbTZM7V6ivCEcmkx5Zn9NxGLkHWDiW Q7f3V8yLSApuNIA45lcASOkQu8WyQU7BUYe60d1Ytu8N3wpyBAR0vJRZnb6Xwr5GRF YZOTh+NkcXDYDOxBCiRSN7KERgLCAA/6AvtSoUn5E4uLPIezJ9c8mSOttS8ZF+MLio aDhK3Ob+3UEEw== From: Christian Brauner To: linux-fsdevel@vger.kernel.org, jack@suse.cz Cc: Christian Brauner , linux-kernel@vger.kernel.org, James Bottomley , mcgrof@kernel.org, hch@infradead.org, david@fromorbit.com, rafael@kernel.org, djwong@kernel.org, pavel@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com Subject: [PATCH 4/6] super: use a common iterator (Part 1) Date: Fri, 28 Mar 2025 17:15:56 +0100 Message-ID: <20250328-work-freeze-v1-4-a2c3a6b0e7a6@kernel.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250328-work-freeze-v1-0-a2c3a6b0e7a6@kernel.org> References: <20250328-work-freeze-v1-0-a2c3a6b0e7a6@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-42535 X-Developer-Signature: v=1; a=openpgp-sha256; l=4478; i=brauner@kernel.org; h=from:subject:message-id; bh=kSJquFBWZLjXohp7CdfSUxcMmSKnA8vBlSuTa7rPH5k=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ/O+3U6XEyV1PcONil8uxlMTtJ/0XGTBrct6u0nwq2/ fnTeaGoo5SFQYyLQVZMkcWh3SRcbjlPxWajTA2YOaxMIEMYuDgFYCLN1gy/mNOeX2JcrLXnynrG azuux3hpLZiyN7soqNlnw7tnt+LnSTMyTDB/aLvwzMotgfn7uu/+3bvwlPYX3ysXf0fPt55xw+S FMC8A X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Use a common iterator for all callbacks. Signed-off-by: Christian Brauner --- fs/super.c | 67 +++++++++++------------------------------------------- include/linux/fs.h | 6 ++++- 2 files changed, 18 insertions(+), 55 deletions(-) diff --git a/fs/super.c b/fs/super.c index c67ea3cdda41..0dd208804a74 100644 --- a/fs/super.c +++ b/fs/super.c @@ -887,37 +887,7 @@ void drop_super_exclusive(struct super_block *sb) } EXPORT_SYMBOL(drop_super_exclusive); -static void __iterate_supers(void (*f)(struct super_block *)) -{ - struct super_block *sb, *p = NULL; - - spin_lock(&sb_lock); - list_for_each_entry(sb, &super_blocks, s_list) { - if (super_flags(sb, SB_DYING)) - continue; - sb->s_count++; - spin_unlock(&sb_lock); - - f(sb); - - spin_lock(&sb_lock); - if (p) - __put_super(p); - p = sb; - } - if (p) - __put_super(p); - spin_unlock(&sb_lock); -} -/** - * iterate_supers - call function for all active superblocks - * @f: function to call - * @arg: argument to pass to it - * - * Scans the superblock list and calls given function, passing it - * locked superblock and given argument. - */ -void iterate_supers(void (*f)(struct super_block *, void *), void *arg) +void __iterate_supers(void (*f)(struct super_block *, void *), void *arg, bool excl) { struct super_block *sb, *p = NULL; @@ -927,14 +897,13 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg) if (super_flags(sb, SB_DYING)) continue; - sb->s_count++; spin_unlock(&sb_lock); - locked = super_lock_shared(sb); + locked = super_lock(sb, excl); if (locked) { f(sb, arg); - super_unlock_shared(sb); + super_unlock(sb, excl); } spin_lock(&sb_lock); @@ -1111,11 +1080,9 @@ int reconfigure_super(struct fs_context *fc) return retval; } -static void do_emergency_remount_callback(struct super_block *sb) +static void do_emergency_remount_callback(struct super_block *sb, void *unused) { - bool locked = super_lock_excl(sb); - - if (locked && sb->s_root && sb->s_bdev && !sb_rdonly(sb)) { + if (sb->s_bdev && !sb_rdonly(sb)) { struct fs_context *fc; fc = fs_context_for_reconfigure(sb->s_root, @@ -1126,13 +1093,11 @@ static void do_emergency_remount_callback(struct super_block *sb) put_fs_context(fc); } } - if (locked) - super_unlock_excl(sb); } static void do_emergency_remount(struct work_struct *work) { - __iterate_supers(do_emergency_remount_callback); + __iterate_supers(do_emergency_remount_callback, NULL, true); kfree(work); printk("Emergency Remount complete\n"); } @@ -1148,24 +1113,18 @@ void emergency_remount(void) } } -static void do_thaw_all_callback(struct super_block *sb) +static void do_thaw_all_callback(struct super_block *sb, void *unused) { - bool locked = super_lock_excl(sb); - - if (locked && sb->s_root) { - if (IS_ENABLED(CONFIG_BLOCK)) - while (sb->s_bdev && !bdev_thaw(sb->s_bdev)) - pr_warn("Emergency Thaw on %pg\n", sb->s_bdev); - thaw_super_locked(sb, FREEZE_HOLDER_USERSPACE); - return; - } - if (locked) - super_unlock_excl(sb); + if (IS_ENABLED(CONFIG_BLOCK)) + while (sb->s_bdev && !bdev_thaw(sb->s_bdev)) + pr_warn("Emergency Thaw on %pg\n", sb->s_bdev); + thaw_super_locked(sb, FREEZE_HOLDER_USERSPACE); + return; } static void do_thaw_all(struct work_struct *work) { - __iterate_supers(do_thaw_all_callback); + __iterate_supers(do_thaw_all_callback, NULL, true); kfree(work); printk(KERN_WARNING "Emergency Thaw complete\n"); } diff --git a/include/linux/fs.h b/include/linux/fs.h index 016b0fe1536e..0351500b71d2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3515,7 +3515,11 @@ extern void put_filesystem(struct file_system_type *fs); extern struct file_system_type *get_fs_type(const char *name); extern void drop_super(struct super_block *sb); extern void drop_super_exclusive(struct super_block *sb); -extern void iterate_supers(void (*)(struct super_block *, void *), void *); +void __iterate_supers(void (*f)(struct super_block *, void *), void *arg, bool excl); +static inline void iterate_supers(void (*f)(struct super_block *, void *), void *arg) +{ + __iterate_supers(f, arg, false); +} extern void iterate_supers_type(struct file_system_type *, void (*)(struct super_block *, void *), void *); From patchwork Fri Mar 28 16:15:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 14032232 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92B9F1DA0E0; Fri, 28 Mar 2025 16:16:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743178593; cv=none; b=YzltDuc9FHcKt8UCtVTZtecxCMJ0BBY9yK/yLgYW2KHhdOElUzPrm1s7sRjjNm9jOzZVzX6ELUnfIFFaB/8VYaXOXoS11kch5t8tj6j1/5oZOKanXo+SjXC5MdLm9mIVK79TrZIdllkzMvMJ8HIk1vNmBUoytFDSIM2N9NZSjHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743178593; c=relaxed/simple; bh=lt6u0j7G8M4UVt/q9RdtvvmlEwoeC1nsKag6HYnxJkE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FgsZrJxRDckP+9Y0iLXUvpBqScR+G1n6IX2GTUGIeG91s/q+oXH9w5NfQBDVnZJFtmePJ+lk1JjLcP5UnLb/d5zWjIX0a7XfGqain3D06ZiuoH/N30uSAIsusQxKMvqlZ+8GC75NAymdv+47Z8yNcN+AX0Y3ytjQdcYmscKJVSQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LnQiU3D1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LnQiU3D1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3AF0C4CEE9; Fri, 28 Mar 2025 16:16:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743178593; bh=lt6u0j7G8M4UVt/q9RdtvvmlEwoeC1nsKag6HYnxJkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LnQiU3D1umTaR/AAcrsZckyuXz/ZLIdk0NEsccP2UgAsaV9Kgl2f4oYsIBSje7waC 6uUDTdnftl0tNa4BlJu7qWhTVdusA93CNa6Yh5EekUDHkgl3htqMoMqKJBemrxGSTf /19CqRGmrf16ssQYXAWrZ+lKZEFrvLvNdNF11J13MYQOGO16f8FHigZC0QM1yvV97p JUWeyibTdPnluBfPIrgav1merQK1oS6kx3icGeDbDSQQ+7Kq5ntQsztzlu/lgMi9ic FtDPlkjTYwRFYpctBhT/7enrGsloZ5pYOR3znq5IM5tJTqmNXJ2SVwhCgEXTFBhaV7 utTqgN144vRlw== From: Christian Brauner To: linux-fsdevel@vger.kernel.org, jack@suse.cz Cc: Christian Brauner , linux-kernel@vger.kernel.org, James Bottomley , mcgrof@kernel.org, hch@infradead.org, david@fromorbit.com, rafael@kernel.org, djwong@kernel.org, pavel@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com Subject: [PATCH 5/6] super: use common iterator (Part 2) Date: Fri, 28 Mar 2025 17:15:57 +0100 Message-ID: <20250328-work-freeze-v1-5-a2c3a6b0e7a6@kernel.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250328-work-freeze-v1-0-a2c3a6b0e7a6@kernel.org> References: <20250328-work-freeze-v1-0-a2c3a6b0e7a6@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-42535 X-Developer-Signature: v=1; a=openpgp-sha256; l=4796; i=brauner@kernel.org; h=from:subject:message-id; bh=lt6u0j7G8M4UVt/q9RdtvvmlEwoeC1nsKag6HYnxJkE=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ/O+18+tS7+hNWlydoXr96tpujxqRXytPGve9aBU/Nq aK2P4YpHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABM5O5WRYcbt6OJUawk7EfGr p7pTE+cuSbwWVjVXbefMrlXM825dnMzw3+GgePTH/ueeNjWd98IzbvKb3Zi0I50hLsZCUTPyduJ rVgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Use a common iterator for all callbacks. We could go for something even more elaborate (advance step-by-step similar to iov_iter) but I really don't think this is warranted. Signed-off-by: Christian Brauner --- fs/super.c | 76 +++++++++++++++++++++++++++++++++++++++++++++--------- include/linux/fs.h | 6 +---- 2 files changed, 65 insertions(+), 17 deletions(-) diff --git a/fs/super.c b/fs/super.c index 0dd208804a74..58c95210e66c 100644 --- a/fs/super.c +++ b/fs/super.c @@ -887,24 +887,71 @@ void drop_super_exclusive(struct super_block *sb) } EXPORT_SYMBOL(drop_super_exclusive); -void __iterate_supers(void (*f)(struct super_block *, void *), void *arg, bool excl) +enum super_iter_flags_t { + SUPER_ITER_EXCL = (1U << 0), + SUPER_ITER_GRAB = (1U << 1) | SUPER_ITER_EXCL, + SUPER_ITER_REVERSE = (1U << 2), +}; + +static inline struct super_block *first_super(enum super_iter_flags_t flags) +{ + if (flags & SUPER_ITER_REVERSE) + return list_last_entry(&super_blocks, struct super_block, s_list); + return list_first_entry(&super_blocks, struct super_block, s_list); +} + +static inline struct super_block *next_super(struct super_block *sb, + enum super_iter_flags_t flags) +{ + if (flags & SUPER_ITER_REVERSE) + return list_prev_entry(sb, s_list); + return list_next_entry(sb, s_list); +} + +static inline void super_cb_locked(struct super_block *sb, + void (*f)(struct super_block *, void *), + void *arg, bool excl) +{ + if (super_lock(sb, excl)) { + f(sb, arg); + super_unlock(sb, excl); + } +} + +static inline void super_cb_grabbed(struct super_block *sb, + void (*f)(struct super_block *, void *), + void *arg) +{ + if (super_lock_excl(sb)) { + bool active = atomic_inc_not_zero(&sb->s_active); + super_unlock_excl(sb); + if (active) + f(sb, arg); + deactivate_super(sb); + } +} + +#define invalid_super list_entry_is_head + +static void __iterate_supers(void (*f)(struct super_block *, void *), void *arg, + enum super_iter_flags_t flags) { struct super_block *sb, *p = NULL; + bool excl = flags & SUPER_ITER_EXCL; - spin_lock(&sb_lock); - list_for_each_entry(sb, &super_blocks, s_list) { - bool locked; + guard(spinlock)(&sb_lock); + for (sb = first_super(flags); !invalid_super(sb, &super_blocks, s_list); + sb = next_super(sb, flags)) { if (super_flags(sb, SB_DYING)) continue; sb->s_count++; spin_unlock(&sb_lock); - locked = super_lock(sb, excl); - if (locked) { - f(sb, arg); - super_unlock(sb, excl); - } + if (flags & SUPER_ITER_GRAB) + super_cb_grabbed(sb, f, arg); + else + super_cb_locked(sb, f, arg, excl); spin_lock(&sb_lock); if (p) @@ -913,7 +960,11 @@ void __iterate_supers(void (*f)(struct super_block *, void *), void *arg, bool e } if (p) __put_super(p); - spin_unlock(&sb_lock); +} + +void iterate_supers(void (*f)(struct super_block *, void *), void *arg) +{ + __iterate_supers(f, arg, 0); } /** @@ -1097,7 +1148,8 @@ static void do_emergency_remount_callback(struct super_block *sb, void *unused) static void do_emergency_remount(struct work_struct *work) { - __iterate_supers(do_emergency_remount_callback, NULL, true); + __iterate_supers(do_emergency_remount_callback, NULL, + SUPER_ITER_EXCL | SUPER_ITER_REVERSE); kfree(work); printk("Emergency Remount complete\n"); } @@ -1124,7 +1176,7 @@ static void do_thaw_all_callback(struct super_block *sb, void *unused) static void do_thaw_all(struct work_struct *work) { - __iterate_supers(do_thaw_all_callback, NULL, true); + __iterate_supers(do_thaw_all_callback, NULL, SUPER_ITER_EXCL); kfree(work); printk(KERN_WARNING "Emergency Thaw complete\n"); } diff --git a/include/linux/fs.h b/include/linux/fs.h index 0351500b71d2..c475fa874055 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3515,11 +3515,7 @@ extern void put_filesystem(struct file_system_type *fs); extern struct file_system_type *get_fs_type(const char *name); extern void drop_super(struct super_block *sb); extern void drop_super_exclusive(struct super_block *sb); -void __iterate_supers(void (*f)(struct super_block *, void *), void *arg, bool excl); -static inline void iterate_supers(void (*f)(struct super_block *, void *), void *arg) -{ - __iterate_supers(f, arg, false); -} +extern void iterate_supers(void (*f)(struct super_block *, void *), void *arg); extern void iterate_supers_type(struct file_system_type *, void (*)(struct super_block *, void *), void *); From patchwork Fri Mar 28 16:15:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 14032233 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44DCF1DA0E0; Fri, 28 Mar 2025 16:16:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743178597; cv=none; b=vGBZyNrHXdWxYU+6e2BPyYwQkSUmk0gMDLgd3Ts2wjrGNhR116vMU4l3yCYYlJusi4jrbcZ55rRfE05If9gYuG6ylaFPMeAn+TguHVqzKlIgtASloefJFHTmd+wsWZrRVReusD5fkPwIBqONpmw86YXNPPBrzV/NeGyqubqlJsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743178597; c=relaxed/simple; bh=rrucComhoMdFCmQO9zULVjvMKM4iND2xUOIRG11wNps=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IRogo7EBwMhX2aJkAJOxSCOJDc/b3MxPYRVySfk2TVcnYSVMpBqaRcpSDkokpU2WCIEQ40tgRqgtDFIUaxkw3PzN6Uc9pI5shyz51z8FNhl93PECiEGiLdVz+fEu7coaOIoauA2HELq2eGeM9itdAwGFaQDpIezRCuOZ6k7kifE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M7HYaGI+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M7HYaGI+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E652C4CEE4; Fri, 28 Mar 2025 16:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743178596; bh=rrucComhoMdFCmQO9zULVjvMKM4iND2xUOIRG11wNps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M7HYaGI+EZny1Q4Wvsa91j9R3yjaXCN3KmVU9tkWSqqx42iyT/9quteNIy1s4SMR5 ZxET7rFYR005gZ8KK0NKf1BBVIzLetz4v/cr3+S6PiuhJPrgHGdxEImkXR8J/EfkLg cgjlm6HOvG3hWadDaJW53ol+XaeLQg+0pn34+syyLLncjEqnkBFWs4OiaEx28RxwmA Xr39BXAQ159j4A9lR7RQDKaS74cbsvQSMCTJ2y2HIuJCW30NpG2wz4FnhEiRz8BkVI bHRANuxkcJqogypr0XjKsfZmpCV2OlnbXtE+jpjfGPC1VLyJKdvHKlz7awfvuRbDgk FJQc2lAlF12GA== From: Christian Brauner To: linux-fsdevel@vger.kernel.org, jack@suse.cz Cc: Christian Brauner , linux-kernel@vger.kernel.org, James Bottomley , mcgrof@kernel.org, hch@infradead.org, david@fromorbit.com, rafael@kernel.org, djwong@kernel.org, pavel@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com Subject: [PATCH 6/6] super: add filesystem freezing helpers for suspend and hibernate Date: Fri, 28 Mar 2025 17:15:58 +0100 Message-ID: <20250328-work-freeze-v1-6-a2c3a6b0e7a6@kernel.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250328-work-freeze-v1-0-a2c3a6b0e7a6@kernel.org> References: <20250328-work-freeze-v1-0-a2c3a6b0e7a6@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-42535 X-Developer-Signature: v=1; a=openpgp-sha256; l=2088; i=brauner@kernel.org; h=from:subject:message-id; bh=rrucComhoMdFCmQO9zULVjvMKM4iND2xUOIRG11wNps=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ/O+2sKXxPo8Xp0rmT8k5vC1zve4tNeS1VIHPsn5ySo dLlVY9edpSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAExksRfDf2e+WXmVy/7OvDAx JvP9opCQpgXzUvx1/xhlJO2Wv/O6bhIjwwwOc/mn8RejlcqL7rJFWFm2ZJbG8Alq1bl6vFKasS6 BBwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Allow the power subsystem to support filesystem freeze for suspend and hibernate. Signed-off-by: Christian Brauner --- fs/super.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/fs.h | 2 ++ 2 files changed, 36 insertions(+) diff --git a/fs/super.c b/fs/super.c index 58c95210e66c..a2942b21d661 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1197,6 +1197,40 @@ void emergency_thaw_all(void) } } +static void filesystems_freeze_callback(struct super_block *sb, void *flagsp) +{ + if (!sb->s_op->freeze_fs && !sb->s_op->freeze_super) + return; + + if (sb->s_op->freeze_super) + sb->s_op->freeze_super(sb, FREEZE_MAY_NEST | FREEZE_HOLDER_KERNEL); + else + freeze_super(sb, FREEZE_MAY_NEST | FREEZE_HOLDER_KERNEL); +} + +void filesystems_freeze(bool hibernate) +{ + __iterate_supers(filesystems_freeze_callback, NULL, + SUPER_ITER_GRAB | SUPER_ITER_REVERSE); +} + +static void filesystems_thaw_callback(struct super_block *sb, void *flagsp) +{ + if (!sb->s_op->freeze_fs && !sb->s_op->freeze_super) + return; + + if (sb->s_op->thaw_super) + sb->s_op->thaw_super(sb, FREEZE_HOLDER_KERNEL); + else + thaw_super(sb, FREEZE_HOLDER_KERNEL); +} + +void filesystems_thaw(bool hibernate) +{ + __iterate_supers(filesystems_thaw_callback, NULL, + SUPER_ITER_GRAB | SUPER_ITER_REVERSE); +} + static DEFINE_IDA(unnamed_dev_ida); /** diff --git a/include/linux/fs.h b/include/linux/fs.h index c475fa874055..29bd28491eff 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3518,6 +3518,8 @@ extern void drop_super_exclusive(struct super_block *sb); extern void iterate_supers(void (*f)(struct super_block *, void *), void *arg); extern void iterate_supers_type(struct file_system_type *, void (*)(struct super_block *, void *), void *); +void filesystems_freeze(bool hibernate); +void filesystems_thaw(bool hibernate); extern int dcache_dir_open(struct inode *, struct file *); extern int dcache_dir_close(struct inode *, struct file *);