{"id":2211760,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2211760/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260317084624.457185-8-me@linux.beauty/","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.2/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260317084624.457185-8-me@linux.beauty>","list_archive_url":null,"date":"2026-03-17T08:46:22","name":"[RFC,v5,7/7] ext4: fast commit: export snapshot stats in fc_info","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"aeabf634d3b375f278a84cdba2d3343cfec8bd0d","submitter":{"id":84264,"url":"http://patchwork.ozlabs.org/api/1.2/people/84264/?format=json","name":"Li Chen","email":"me@linux.beauty"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260317084624.457185-8-me@linux.beauty/mbox/","series":[{"id":496215,"url":"http://patchwork.ozlabs.org/api/1.2/series/496215/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=496215","date":"2026-03-17T08:46:15","name":"ext4: fast commit: snapshot inode state for FC log","version":5,"mbox":"http://patchwork.ozlabs.org/series/496215/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2211760/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2211760/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <SRS0=fasu=BR=vger.kernel.org=linux-ext4+bounces-15104-patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-ext4@vger.kernel.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","patchwork-incoming@ozlabs.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=linux.beauty header.i=me@linux.beauty\n header.a=rsa-sha256 header.s=zmail header.b=NVweKBQn;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org;\n envelope-from=srs0=fasu=br=vger.kernel.org=linux-ext4+bounces-15104-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=\"2600:3c09:e001:a7::12fc:5321\"\n arc.chain=\"subspace.kernel.org:zohomail.com\"","gandalf.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=linux.beauty","gandalf.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=linux.beauty header.i=me@linux.beauty\n header.a=rsa-sha256 header.s=zmail header.b=NVweKBQn;\n\tdkim-atps=neutral","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15104-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty\n header.b=\"NVweKBQn\"","smtp.subspace.kernel.org;\n arc=pass smtp.client-ip=136.143.188.15","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.beauty","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=linux.beauty"],"Received":["from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fZm2H4Lszz1y1P\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 17 Mar 2026 19:53:11 +1100 (AEDT)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4fZm2H3tWPz4wD3\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 17 Mar 2026 19:53:11 +1100 (AEDT)","by gandalf.ozlabs.org (Postfix)\n\tid 4fZm2H3n3xz4w9k; Tue, 17 Mar 2026 19:53:11 +1100 (AEDT)","from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby gandalf.ozlabs.org (Postfix) with ESMTPS id 4fZm2C5NgDz4wD3\n\tfor <patchwork-incoming@ozlabs.org>; Tue, 17 Mar 2026 19:53:07 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 8B9F83025112\n\tfor <patchwork-incoming@ozlabs.org>; Tue, 17 Mar 2026 08:53:04 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id E9C2839D6D9;\n\tTue, 17 Mar 2026 08:53:00 +0000 (UTC)","from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com\n [136.143.188.15])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 4561A347523;\n\tTue, 17 Mar 2026 08:52:59 +0000 (UTC)","by mx.zohomail.com with SMTPS id 1773737221354759.2787295997053;\n\tTue, 17 Mar 2026 01:47:01 -0700 (PDT)"],"ARC-Seal":["i=3; a=rsa-sha256; d=ozlabs.org; s=201707; t=1773737591; cv=pass;\n\tb=pKaGnBCQROjSEe4v/zKEBjYVLonWWsfSfUgAnqgjY41I4tNv5F0xkGmyck7C+pcQWr6MUu3NUcnUOHi+xchesp2z4FSO63cU2y+IwPC5Xm8d3FRsG9lEIxkDY7nf1bOpiDN+UqfBfzJVhVipDENrk2NU0I/htdkOOR1wLj5hjYfVT8nDbqkF9KW6237Y/JAoFlLynud8IiRFSgqYEsjhjeJjRS2fPgXCfvjzdGnYcy2AElAiFPlpM8gL5tgT8h97mYG/RGeXqIQjglXzeQaOp9vS0UszZIOoPdCQ2oXohRw+6IP7nXeBVVjcIP18C6qRJsL43niWoDZVDxUhoJa4Kw==","i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1773737580; cv=pass;\n b=P36p8XIrBAcKQaDqnc+7zU/0MQiuzXBxKQTgV4/I3UhXSe+YDRGwY/kEEypYFaBd6OsiKJ9ycd/7ROgNZiPPr3V1Nzu3PlozUioi60y3CIRTkfTXqIjUqVIn23FR51I81E8oxaC4NlN+fuDfkNQ2g7eQO8p8xd1qjIpF9EdhJVY=","i=1; a=rsa-sha256; t=1773737223; cv=none;\n\td=zohomail.com; s=zohoarc;\n\tb=NmbCFMWPslHZfdKOAo2eAiktybGxSNNL/DNHfHb5aso2pT2asM8dCk3BfcJouUYsET9LVp8GyqUwsuzEEEg0oTyvF2pst0zWi1zaqRd201Z7khNzjrBncIrbmxOnHfv7YRaPZhOInCoPBQFyGdWktq50FxUGFitt3j7tTRdbpG0="],"ARC-Message-Signature":["i=3; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1773737591; c=relaxed/relaxed;\n\tbh=IZipebCCXIAh9kCsm/LsBh4bhP5jBk5luuGlwXcTazc=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=Ubf7zeBcJyBy52SOdxNIEo2+iUTfeiV9DTGNmdZKjFFURkI4QWALWdM5CVB27Ceic2d1ndfajKHVspS1FsUlOZc5kbNdYAC8ZLEzkRaDXWoMysHLsqcEFghM+XqOUKasLeSKOvrIcbfCtO29TZjdp+eMa9xh6wTFsGJedCjKDtNgSs6uNeTpyg6hFZ4CSWvQKSBUG54qXa80qY/n6t3cr48957Puyz3L02xZE0PWDmTDi1RRjo1Fo7s5eQXKuFao1f8YPMjkvT9KIk2weeJWkflUNtdB3HzB9LHs4/l4YMJUJwHcSYDI++3HQvny3cZtxpyxGh4wjn7iJid4OhpFng==","i=2; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1773737580; c=relaxed/simple;\n\tbh=YDfzirdiRo0M+LudTwjXEH9ec8iuiDmGrBlAZ6xVMj0=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=MrWNo5BB+nCW0M4PAMUU/2JboBH1iV1/dtPPD4W0QdILCBa5tPaci7yRY07HZps0qqdIJFjYkKXufQgzlIZtaQnDDkjdpBtOQknZJtsW7GWzqBL8XgP5zOzB1YxSHwFuu7cEMIixjYd7IuT1PgPCAR1lrmfnZ3N+rFtnvSa+pec=","i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;\n s=zohoarc;\n\tt=1773737223;\n h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To;\n\tbh=IZipebCCXIAh9kCsm/LsBh4bhP5jBk5luuGlwXcTazc=;\n\tb=I94/QvvD7I4cILEAJrg/A9icssy9ATENKlIvBI9N0XyOcqEcaD8VX2xwstJLPOqc29KsBua0VWVHqSYrtxk1UKvGvqd0hyCBoyVl89YqH92c6gHgYViAAuGjDlpnfc4e2004Oy70EI0cmFY7ZCSh6op7eXE/xgFU9vKYY6D9/xI="],"ARC-Authentication-Results":["i=3; gandalf.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=linux.beauty;\n dkim=pass (1024-bit key;\n unprotected) header.d=linux.beauty header.i=me@linux.beauty\n header.a=rsa-sha256 header.s=zmail header.b=NVweKBQn; dkim-atps=neutral;\n spf=pass (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15104-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org","i=2; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.beauty;\n spf=pass smtp.mailfrom=linux.beauty;\n dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty\n header.b=NVweKBQn; arc=pass smtp.client-ip=136.143.188.15","i=1; mx.zohomail.com;\n\tdkim=pass  header.i=linux.beauty;\n\tspf=pass  smtp.mailfrom=me@linux.beauty;\n\tdmarc=pass header.from=<me@linux.beauty>"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1773737223;\n\ts=zmail; d=linux.beauty; i=me@linux.beauty;\n\th=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To;\n\tbh=IZipebCCXIAh9kCsm/LsBh4bhP5jBk5luuGlwXcTazc=;\n\tb=NVweKBQnF4eSkFEnGcucdGRIlu8Smp0L2wL+HRmeTP+BdrosKF6rp2pvhW8k5T05\n\tdRn+Be0dGWb2Uos8dJ1JK4vclcvXnf0qF1KSK9ZhECArIIcwJzvN9/7mnpdX8Zqk51b\n\t0NfDdsyIwVI82ORHFFnGZ+CLPl8EWUuVx4XReRhc=","From":"Li Chen <me@linux.beauty>","To":"Zhang Yi <yi.zhang@huaweicloud.com>,\n\tTheodore Ts'o <tytso@mit.edu>,\n\tAndreas Dilger <adilger.kernel@dilger.ca>,\n\tlinux-ext4@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org","Cc":"Steven Rostedt <rostedt@goodmis.org>,\n\tMasami Hiramatsu <mhiramat@kernel.org>,\n\tMathieu Desnoyers <mathieu.desnoyers@efficios.com>,\n\tlinux-trace-kernel@vger.kernel.org,\n\tLi Chen <me@linux.beauty>","Subject":"[RFC v5 7/7] ext4: fast commit: export snapshot stats in fc_info","Date":"Tue, 17 Mar 2026 16:46:22 +0800","Message-ID":"<20260317084624.457185-8-me@linux.beauty>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260317084624.457185-1-me@linux.beauty>","References":"<20260317084624.457185-1-me@linux.beauty>","Precedence":"bulk","X-Mailing-List":"linux-ext4@vger.kernel.org","List-Id":"<linux-ext4.vger.kernel.org>","List-Subscribe":"<mailto:linux-ext4+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-ext4+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-ZohoMailClient":"External","X-Spam-Status":"No, score=-1.2 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,\n\tHEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,\n\tSPF_PASS autolearn=disabled version=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org"},"content":"Snapshot-based fast commit can fall back when the commit-time snapshot\ncannot be built (e.g. extent status cache misses). It is useful to\nquantify the updates-locked window and to see why snapshotting failed.\n\nAdd best-effort snapshot counters to the ext4 superblock and extend\n/proc/fs/ext4/<sb_id>/fc_info to report the number of snapshotted\ninodes and ranges, snapshot failure reasons, and the average/max time\nspent with journal updates locked.\n\nSigned-off-by: Li Chen <me@linux.beauty>\n---\n fs/ext4/ext4.h        | 31 ++++++++++++++++++++++\n fs/ext4/fast_commit.c | 61 ++++++++++++++++++++++++++++++++++++++++---\n fs/ext4/super.c       |  1 +\n 3 files changed, 89 insertions(+), 4 deletions(-)","diff":"diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h\nindex b9e146f3dd9e4..8b7530f2e0706 100644\n--- a/fs/ext4/ext4.h\n+++ b/fs/ext4/ext4.h\n@@ -1566,6 +1566,36 @@ struct ext4_orphan_info {\n \t\t\t\t\t\t * file blocks */\n };\n \n+/*\n+ * Ext4 fast commit snapshot statistics.\n+ *\n+ * These are best-effort counters intended for debugging / performance\n+ * introspection; they are not exact under concurrent updates.\n+ */\n+struct ext4_fc_snap_stats {\n+\tu64 lock_updates_ns_total;\n+\tu64 lock_updates_ns_max;\n+\tu64 lock_updates_samples;\n+\n+\tu64 snap_inodes;\n+\tu64 snap_ranges;\n+\n+\tu64 snap_fail_es_miss;\n+\tu64 snap_fail_es_delayed;\n+\tu64 snap_fail_es_other;\n+\n+\tu64 snap_fail_inodes_cap;\n+\tu64 snap_fail_ranges_cap;\n+\tu64 snap_fail_nomem;\n+\tu64 snap_fail_inode_loc;\n+\n+\t/*\n+\t * Missing inode snapshots during log writing should never happen.\n+\t * Keep this counter to help catch unexpected regressions.\n+\t */\n+\tu64 snap_fail_no_snap;\n+};\n+\n /*\n  * fourth extended-fs super-block data in memory\n  */\n@@ -1837,6 +1867,7 @@ struct ext4_sb_info {\n \tstruct mutex s_fc_lock;\n \tstruct buffer_head *s_fc_bh;\n \tstruct ext4_fc_stats s_fc_stats;\n+\tstruct ext4_fc_snap_stats s_fc_snap_stats;\n \ttid_t s_fc_ineligible_tid;\n #ifdef CONFIG_EXT4_DEBUG\n \tint s_fc_debug_max_replay;\ndiff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c\nindex 4929e2990b292..09ae8f52abdab 100644\n--- a/fs/ext4/fast_commit.c\n+++ b/fs/ext4/fast_commit.c\n@@ -890,13 +890,17 @@ static int ext4_fc_write_inode(struct inode *inode, u32 *crc)\n \tint inode_len;\n \tint ret;\n \n-\tif (!snap)\n+\tif (!snap) {\n+\t\tEXT4_SB(inode->i_sb)->s_fc_snap_stats.snap_fail_no_snap++;\n \t\treturn -ECANCELED;\n+\t}\n \n \tsrc = snap->inode_buf;\n \tinode_len = snap->inode_len;\n-\tif (!src || inode_len == 0)\n+\tif (!src || inode_len == 0) {\n+\t\tEXT4_SB(inode->i_sb)->s_fc_snap_stats.snap_fail_no_snap++;\n \t\treturn -ECANCELED;\n+\t}\n \n \tfc_inode.fc_ino = cpu_to_le32(inode->i_ino);\n \ttl.fc_tag = cpu_to_le16(EXT4_FC_TAG_INODE);\n@@ -931,8 +935,10 @@ static int ext4_fc_write_inode_data(struct inode *inode, u32 *crc)\n \tstruct ext4_extent *ex;\n \tstruct ext4_fc_range *range;\n \n-\tif (!snap)\n+\tif (!snap) {\n+\t\tEXT4_SB(inode->i_sb)->s_fc_snap_stats.snap_fail_no_snap++;\n \t\treturn -ECANCELED;\n+\t}\n \n \tlist_for_each_entry(range, &snap->data_list, list) {\n \t\tif (range->tag == EXT4_FC_TAG_DEL_RANGE) {\n@@ -993,6 +999,8 @@ static int ext4_fc_snapshot_inode_data(struct inode *inode,\n \t\t\t\t       int *snap_err)\n {\n \tstruct ext4_inode_info *ei = EXT4_I(inode);\n+\tstruct ext4_fc_snap_stats *stats =\n+\t\t&EXT4_SB(inode->i_sb)->s_fc_snap_stats;\n \text4_lblk_t start_lblk, end_lblk, cur_lblk;\n \tunsigned int nr_ranges = 0;\n \n@@ -1018,11 +1026,13 @@ static int ext4_fc_snapshot_inode_data(struct inode *inode,\n \t\text4_lblk_t len;\n \n \t\tif (!ext4_es_lookup_extent(inode, cur_lblk, NULL, &es, NULL)) {\n+\t\t\tstats->snap_fail_es_miss++;\n \t\t\text4_fc_set_snap_err(snap_err, EXT4_FC_SNAP_ERR_ES_MISS);\n \t\t\treturn -EAGAIN;\n \t\t}\n \n \t\tif (ext4_es_is_delayed(&es)) {\n+\t\t\tstats->snap_fail_es_delayed++;\n \t\t\text4_fc_set_snap_err(snap_err,\n \t\t\t\t\t     EXT4_FC_SNAP_ERR_ES_DELAYED);\n \t\t\treturn -EAGAIN;\n@@ -1037,6 +1047,7 @@ static int ext4_fc_snapshot_inode_data(struct inode *inode,\n \t\t}\n \n \t\tif (nr_ranges_total + nr_ranges >= EXT4_FC_SNAPSHOT_MAX_RANGES) {\n+\t\t\tstats->snap_fail_ranges_cap++;\n \t\t\text4_fc_set_snap_err(snap_err,\n \t\t\t\t\t     EXT4_FC_SNAP_ERR_RANGES_CAP);\n \t\t\treturn -E2BIG;\n@@ -1044,6 +1055,7 @@ static int ext4_fc_snapshot_inode_data(struct inode *inode,\n \n \t\trange = kmem_cache_alloc(ext4_fc_range_cachep, GFP_NOFS);\n \t\tif (!range) {\n+\t\t\tstats->snap_fail_nomem++;\n \t\t\text4_fc_set_snap_err(snap_err, EXT4_FC_SNAP_ERR_NOMEM);\n \t\t\treturn -ENOMEM;\n \t\t}\n@@ -1071,6 +1083,7 @@ static int ext4_fc_snapshot_inode_data(struct inode *inode,\n \t\t\t\trange->len = max;\n \t\t} else {\n \t\t\tkmem_cache_free(ext4_fc_range_cachep, range);\n+\t\t\tstats->snap_fail_es_other++;\n \t\t\text4_fc_set_snap_err(snap_err, EXT4_FC_SNAP_ERR_ES_OTHER);\n \t\t\treturn -EAGAIN;\n \t\t}\n@@ -1091,6 +1104,8 @@ static int ext4_fc_snapshot_inode(struct inode *inode,\n \t\t\t\t  unsigned int *nr_rangesp, int *snap_err)\n {\n \tstruct ext4_inode_info *ei = EXT4_I(inode);\n+\tstruct ext4_fc_snap_stats *stats =\n+\t\t&EXT4_SB(inode->i_sb)->s_fc_snap_stats;\n \tstruct ext4_fc_inode_snap *snap;\n \tint inode_len = EXT4_GOOD_OLD_INODE_SIZE;\n \tstruct ext4_iloc iloc;\n@@ -1101,6 +1116,7 @@ static int ext4_fc_snapshot_inode(struct inode *inode,\n \n \tret = ext4_get_inode_loc_noio(inode, &iloc);\n \tif (ret) {\n+\t\tstats->snap_fail_inode_loc++;\n \t\text4_fc_set_snap_err(snap_err, EXT4_FC_SNAP_ERR_INODE_LOC);\n \t\treturn ret;\n \t}\n@@ -1112,6 +1128,7 @@ static int ext4_fc_snapshot_inode(struct inode *inode,\n \n \tsnap = kmalloc(struct_size(snap, inode_buf, inode_len), GFP_NOFS);\n \tif (!snap) {\n+\t\tstats->snap_fail_nomem++;\n \t\text4_fc_set_snap_err(snap_err, EXT4_FC_SNAP_ERR_NOMEM);\n \t\tbrelse(iloc.bh);\n \t\treturn -ENOMEM;\n@@ -1136,6 +1153,8 @@ static int ext4_fc_snapshot_inode(struct inode *inode,\n \tlist_splice_tail_init(&ranges, &snap->data_list);\n \text4_fc_unlock(inode->i_sb, alloc_ctx);\n \n+\tstats->snap_inodes++;\n+\tstats->snap_ranges += nr_ranges;\n \tif (nr_rangesp)\n \t\t*nr_rangesp = nr_ranges;\n \treturn 0;\n@@ -1245,6 +1264,7 @@ static int ext4_fc_snapshot_inodes(journal_t *journal, struct inode **inodes,\n \talloc_ctx = ext4_fc_lock(sb);\n \tlist_for_each_entry(iter, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {\n \t\tif (i >= inodes_size) {\n+\t\t\tsbi->s_fc_snap_stats.snap_fail_inodes_cap++;\n \t\t\text4_fc_set_snap_err(snap_err,\n \t\t\t\t\t     EXT4_FC_SNAP_ERR_INODES_CAP);\n \t\t\tret = -E2BIG;\n@@ -1270,6 +1290,7 @@ static int ext4_fc_snapshot_inodes(journal_t *journal, struct inode **inodes,\n \t\t\tcontinue;\n \n \t\tif (i >= inodes_size) {\n+\t\t\tsbi->s_fc_snap_stats.snap_fail_inodes_cap++;\n \t\t\text4_fc_set_snap_err(snap_err,\n \t\t\t\t\t     EXT4_FC_SNAP_ERR_INODES_CAP);\n \t\t\tret = -E2BIG;\n@@ -1313,6 +1334,7 @@ static int ext4_fc_perform_commit(journal_t *journal, tid_t commit_tid)\n {\n \tstruct super_block *sb = journal->j_private;\n \tstruct ext4_sb_info *sbi = EXT4_SB(sb);\n+\tstruct ext4_fc_snap_stats *snap_stats = &sbi->s_fc_snap_stats;\n \tstruct ext4_inode_info *iter;\n \tstruct ext4_fc_head head;\n \tstruct inode *inode;\n@@ -1375,8 +1397,13 @@ static int ext4_fc_perform_commit(journal_t *journal, tid_t commit_tid)\n \t\treturn ret;\n \n \tret = ext4_fc_alloc_snapshot_inodes(sb, &inodes, &inodes_size);\n-\tif (ret)\n+\tif (ret) {\n+\t\tif (ret == -E2BIG)\n+\t\t\tsnap_stats->snap_fail_inodes_cap++;\n+\t\telse if (ret == -ENOMEM)\n+\t\t\tsnap_stats->snap_fail_nomem++;\n \t\treturn ret;\n+\t}\n \n \t/* Step 4: Mark all inodes as being committed. */\n \tjbd2_journal_lock_updates(journal);\n@@ -1398,6 +1425,10 @@ static int ext4_fc_perform_commit(journal_t *journal, tid_t commit_tid)\n \t\t\t\t      &snap_inodes, &snap_ranges, &snap_err);\n \tjbd2_journal_unlock_updates(journal);\n \tlocked_ns = ktime_to_ns(ktime_sub(ktime_get(), lock_start));\n+\tsnap_stats->lock_updates_ns_total += locked_ns;\n+\tsnap_stats->lock_updates_samples++;\n+\tif (locked_ns > snap_stats->lock_updates_ns_max)\n+\t\tsnap_stats->lock_updates_ns_max = locked_ns;\n \ttrace_ext4_fc_lock_updates(sb, commit_tid, locked_ns, snap_inodes,\n \t\t\t\t   snap_ranges, ret, snap_err);\n \tkvfree(inodes);\n@@ -2694,11 +2725,17 @@ int ext4_fc_info_show(struct seq_file *seq, void *v)\n {\n \tstruct ext4_sb_info *sbi = EXT4_SB((struct super_block *)seq->private);\n \tstruct ext4_fc_stats *stats = &sbi->s_fc_stats;\n+\tstruct ext4_fc_snap_stats *snap_stats = &sbi->s_fc_snap_stats;\n+\tu64 lock_avg_ns = 0;\n \tint i;\n \n \tif (v != SEQ_START_TOKEN)\n \t\treturn 0;\n \n+\tif (snap_stats->lock_updates_samples)\n+\t\tlock_avg_ns = div_u64(snap_stats->lock_updates_ns_total,\n+\t\t\t\t      snap_stats->lock_updates_samples);\n+\n \tseq_printf(seq,\n \t\t\"fc stats:\\n%ld commits\\n%ld ineligible\\n%ld numblks\\n%lluus avg_commit_time\\n\",\n \t\t   stats->fc_num_commits, stats->fc_ineligible_commits,\n@@ -2709,6 +2746,22 @@ int ext4_fc_info_show(struct seq_file *seq, void *v)\n \t\tseq_printf(seq, \"\\\"%s\\\":\\t%d\\n\", fc_ineligible_reasons[i],\n \t\t\tstats->fc_ineligible_reason_count[i]);\n \n+\tseq_printf(seq,\n+\t\t   \"Snapshot stats:\\n%llu inodes\\n%llu ranges\\n%lluus lock_updates_avg\\n%lluus lock_updates_max\\n\",\n+\t\t   snap_stats->snap_inodes, snap_stats->snap_ranges,\n+\t\t   div_u64(lock_avg_ns, 1000),\n+\t\t   div_u64(snap_stats->lock_updates_ns_max, 1000));\n+\tseq_printf(seq,\n+\t\t   \"Snapshot failures:\\n%llu es_miss\\n%llu es_delayed\\n%llu es_other\\n%llu inodes_cap\\n%llu ranges_cap\\n%llu nomem\\n%llu inode_loc\\n%llu no_snap\\n\",\n+\t\t   snap_stats->snap_fail_es_miss,\n+\t\t   snap_stats->snap_fail_es_delayed,\n+\t\t   snap_stats->snap_fail_es_other,\n+\t\t   snap_stats->snap_fail_inodes_cap,\n+\t\t   snap_stats->snap_fail_ranges_cap,\n+\t\t   snap_stats->snap_fail_nomem,\n+\t\t   snap_stats->snap_fail_inode_loc,\n+\t\t   snap_stats->snap_fail_no_snap);\n+\n \treturn 0;\n }\n \ndiff --git a/fs/ext4/super.c b/fs/ext4/super.c\nindex 4f5f0c21d436f..3afcaf9d80078 100644\n--- a/fs/ext4/super.c\n+++ b/fs/ext4/super.c\n@@ -4500,6 +4500,7 @@ static void ext4_fast_commit_init(struct super_block *sb)\n \tsbi->s_fc_ineligible_tid = 0;\n \tmutex_init(&sbi->s_fc_lock);\n \tmemset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats));\n+\tmemset(&sbi->s_fc_snap_stats, 0, sizeof(sbi->s_fc_snap_stats));\n \tsbi->s_fc_replay_state.fc_regions = NULL;\n \tsbi->s_fc_replay_state.fc_regions_size = 0;\n \tsbi->s_fc_replay_state.fc_regions_used = 0;\n","prefixes":["RFC","v5","7/7"]}