{"id":2186639,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2186639/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260120112538.132774-7-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":"<20260120112538.132774-7-me@linux.beauty>","list_archive_url":null,"date":"2026-01-20T11:25:35","name":"[RFC,v4,6/7] ext4: fast commit: add lock_updates tracepoint","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"9e2b80885d966de85b12cee0635b75e775456a2f","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/20260120112538.132774-7-me@linux.beauty/mbox/","series":[{"id":489032,"url":"http://patchwork.ozlabs.org/api/1.2/series/489032/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=489032","date":"2026-01-20T11:25:32","name":"ext4: fast commit: snapshot inode state for FC log","version":4,"mbox":"http://patchwork.ozlabs.org/series/489032/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2186639/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2186639/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <SRS0=PLiJ=7Z=vger.kernel.org=linux-ext4+bounces-13104-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=TeTrNHKd;\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=plij=7z=vger.kernel.org=linux-ext4+bounces-13104-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=142.0.200.124\n arc.chain=\"subspace.kernel.org:zohomail.com\"","gandalf.ozlabs.org;\n dmarc=none (p=none dis=none) header.from=linux.beauty","gandalf.ozlabs.org;\n spf=fail smtp.mailfrom=vger.kernel.org","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=TeTrNHKd;\n\tdkim-atps=neutral","gandalf.ozlabs.org;\n spf=softfail (domain owner discourages use of this host)\n smtp.mailfrom=vger.kernel.org (client-ip=142.0.200.124;\n helo=dfw.mirrors.kernel.org;\n envelope-from=linux-ext4+bounces-13104-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=\"TeTrNHKd\"","smtp.subspace.kernel.org;\n arc=pass smtp.client-ip=136.143.188.112","smtp.subspace.kernel.org;\n dmarc=none (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 4dwQQ51DM5z1xsN\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 20 Jan 2026 22:41:17 +1100 (AEDT)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4dwQQ50nCtz4w8x\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 20 Jan 2026 22:41:17 +1100 (AEDT)","by gandalf.ozlabs.org (Postfix)\n\tid 4dwQQ50jCbz4wB9; Tue, 20 Jan 2026 22:41:17 +1100 (AEDT)","from dfw.mirrors.kernel.org (dfw.mirrors.kernel.org [142.0.200.124])\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 4dwQQ14dFmz4w8x\n\tfor <patchwork-incoming@ozlabs.org>; Tue, 20 Jan 2026 22:41:13 +1100 (AEDT)","from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby dfw.mirrors.kernel.org (Postfix) with ESMTPS id 3084A80A1FA\n\tfor <patchwork-incoming@ozlabs.org>; Tue, 20 Jan 2026 11:28:26 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 3EF34421A12;\n\tTue, 20 Jan 2026 11:27:22 +0000 (UTC)","from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com\n [136.143.188.112])\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 F02493D669E;\n\tTue, 20 Jan 2026 11:27:19 +0000 (UTC)","by mx.zohomail.com with SMTPS id 1768908380099737.3273924208657;\n\tTue, 20 Jan 2026 03:26:20 -0800 (PST)"],"ARC-Seal":["i=3; a=rsa-sha256; d=ozlabs.org; s=201707; t=1768909277; cv=pass;\n\tb=kU+pKTq92uevPrXUMjOx8bH+uxqE3I+xUvgcdf3knv7fpn4oWjX3sLpOdLVLBZD9eQtxus7A/IGd1iP1OkWZ3mI/sDkaA4Xhe91fil69Tzd7HUxffxvNFveiuNTQ1w2CRL3IJeZqzlvLp0VpcUPDvOnbvBsr03LL6McSk7ZTubpxj0WkITsrwO5z8BrQgC6nxSxnGiR5pblmUZWSTtN4JgUUH22sG1AGVg5IMS0iB8xnnrvefdF/zIMpGq9niCf8prcPdV5f98u4n/wg4aIQB9QShx+jHdduYdq2XgolaY6QP7PGNXkY2abXpQdGukEQ4P1N7QsjhRPfxUjeBzzTNg==","i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1768908442; cv=pass;\n b=qlKMrWWxtuwXO6aWQLpZ7+yXc0MltNl2FDFumNS7/Pct1Ye7lUZRIruvofwnt0W8941hxC0mdldD5woeaAsARD1gGb6OuWqP8fIKIhLTbj6UG4+YT/F4wlkt/G1vrryqT1GgSm8bZ5JnBOLRJZpWGi2c03B5dGS8+mpyXe3TlqA=","i=1; a=rsa-sha256; t=1768908382; cv=none;\n\td=zohomail.com; s=zohoarc;\n\tb=l0RVpk0vdYCLCYZ+zCLfPI4m/RKFtCg50/oWJRkyakCEvV19qWbPcAneajFaxU+AEUD8tZy1XbV0UiDGJtj208KrBZoiN3GihklDbsjsNpt8vuwv3XfyF3oeA9LvOwYXHClanU6bGWzBgGU+/8HP8mpiesXb9WH6BaE6fDe8FOs="],"ARC-Message-Signature":["i=3; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1768909277; c=relaxed/relaxed;\n\tbh=LvhCWF3FvvL6YDco3Bdp7x5v4DKlqw5hZmCYaXOmJc8=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=HyO62TJMSIlet/u2w83hrC5/6JzuGLAsX0Pu+Qy5RwLXp8RhFd1GCev5FZX9IM8pddSimM5gYIuG9Q866fXsuMVms4WQ19TDNrzJol1uvwAFf7AQdw4twC40CP3ErEojNjLcykxt65/AaqaoBhm4R+k6v8Oq9KqX9dQ4m0o/Pq6k6Xq7sT1dRvhVjI3PA9QxFo7BX1Cl3M5Kr9mjAact2RJEp9O6tfJ54g6O4DQxXY6tzoVl1KXQrY8nPbXQXN0Mr4ZabTwaQTW+xzoBGrOFOBG4N9Ohy62Cf2H9Q9Aghp0bdzgE/vDUL2ETnUYd20TMeh/aKVAS6dYqqG87olQ3VA==","i=2; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1768908442; c=relaxed/simple;\n\tbh=oWKDxPIb2khKjpqFB1hods/FuIUqRj7VoWuJWLh4il8=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=eSCrZxiegAWvbfmnOCgYy9DYLRV021iloKuYOfC17N2YQ6QI+LuOuCuFU50z+RtqyhZ+10EBIsLh/qC5EBAPFJfNiwkKJHgXwbWI8pqupeIamjBO6pkPimmddCcwfyruxGW7DkREsp7ANH443ynRzq48v1Xi477A1GE4fr30KpI=","i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;\n s=zohoarc;\n\tt=1768908382;\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=LvhCWF3FvvL6YDco3Bdp7x5v4DKlqw5hZmCYaXOmJc8=;\n\tb=T4+hERsmlLh10kJBRyD3vUmUZn7iFNw4YV48jcdEQ0KfIgXVaGDsUAO09vnahzLkJlWMRmm2NorcKWNo9v4NCgBe1VuFpXao7yVtG18st6s44P6qUSmD0i7ID2p3Z+rxzRkbQJW0iC0EK/9XhEriIM6st6+W5ots9DLmTn0JUJ8="],"ARC-Authentication-Results":["i=3; gandalf.ozlabs.org;\n dmarc=none (p=none dis=none) header.from=linux.beauty;\n spf=fail smtp.mailfrom=vger.kernel.org; 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=TeTrNHKd; dkim-atps=neutral;\n spf=softfail (client-ip=142.0.200.124; helo=dfw.mirrors.kernel.org;\n envelope-from=linux-ext4+bounces-13104-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org","i=2; smtp.subspace.kernel.org;\n dmarc=none (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=TeTrNHKd; arc=pass smtp.client-ip=136.143.188.112","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=1768908382;\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=LvhCWF3FvvL6YDco3Bdp7x5v4DKlqw5hZmCYaXOmJc8=;\n\tb=TeTrNHKdgZXlYhCnYF7hQ7JvtKVyghjg7aiv1WXMmp2Xz9QhMYlwAW29e9KzAzzA\n\tKg+WRNvC1UQmpX262Wq/irl2dra50dH2eVig+0prlvv1c7gRp1UHr+HIpzkE4+LU+Yv\n\tHlTmZvTRbVzfa5KAyz5bPABIu/N8HODXTg5fBV88=","From":"Li Chen <me@linux.beauty>","To":"Zhang Yi <yi.zhang@huaweicloud.com>,\n\t\"Theodore Ts'o\" <tytso@mit.edu>,\n\tAndreas Dilger <adilger.kernel@dilger.ca>,\n\tSteven Rostedt <rostedt@goodmis.org>,\n\tMasami Hiramatsu <mhiramat@kernel.org>,\n\tMathieu Desnoyers <mathieu.desnoyers@efficios.com>,\n\tlinux-ext4@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tlinux-trace-kernel@vger.kernel.org","Cc":"Li Chen <me@linux.beauty>","Subject":"[RFC v4 6/7] ext4: fast commit: add lock_updates tracepoint","Date":"Tue, 20 Jan 2026 19:25:35 +0800","Message-ID":"<20260120112538.132774-7-me@linux.beauty>","X-Mailer":"git-send-email 2.52.0","In-Reply-To":"<20260120112538.132774-1-me@linux.beauty>","References":"<20260120112538.132774-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=-0.2 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_MISSING,\n\tHEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,\n\tSPF_SOFTFAIL autolearn=disabled version=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org"},"content":"Commit-time fast commit snapshots run under jbd2_journal_lock_updates(),\nso it is useful to quantify the time spent with updates locked and to\nunderstand why snapshotting can fail.\n\nAdd a new tracepoint, ext4_fc_lock_updates, reporting the time spent in\nthe updates-locked window along with the number of snapshotted inodes\nand ranges. Record the first snapshot failure reason in a stable snap_err\nfield for tooling.\n\nSigned-off-by: Li Chen <me@linux.beauty>\n---\n fs/ext4/fast_commit.c       | 86 ++++++++++++++++++++++++++++++-------\n include/trace/events/ext4.h | 33 ++++++++++++++\n 2 files changed, 104 insertions(+), 15 deletions(-)","diff":"diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c\nindex d1eefee60912..d266eb2a4219 100644\n--- a/fs/ext4/fast_commit.c\n+++ b/fs/ext4/fast_commit.c\n@@ -193,6 +193,27 @@ static struct kmem_cache *ext4_fc_range_cachep;\n #define EXT4_FC_SNAPSHOT_MAX_INODES\t1024\n #define EXT4_FC_SNAPSHOT_MAX_RANGES\t2048\n \n+/*\n+ * Snapshot failure reasons for ext4_fc_lock_updates tracepoint.\n+ * Keep these stable for tooling.\n+ */\n+enum ext4_fc_snap_err {\n+\tEXT4_FC_SNAP_ERR_NONE = 0,\n+\tEXT4_FC_SNAP_ERR_ES_MISS,\n+\tEXT4_FC_SNAP_ERR_ES_DELAYED,\n+\tEXT4_FC_SNAP_ERR_ES_OTHER,\n+\tEXT4_FC_SNAP_ERR_INODES_CAP,\n+\tEXT4_FC_SNAP_ERR_RANGES_CAP,\n+\tEXT4_FC_SNAP_ERR_NOMEM,\n+\tEXT4_FC_SNAP_ERR_INODE_LOC,\n+};\n+\n+static inline void ext4_fc_set_snap_err(int *snap_err, int err)\n+{\n+\tif (snap_err && *snap_err == EXT4_FC_SNAP_ERR_NONE)\n+\t\t*snap_err = err;\n+}\n+\n static void ext4_end_buffer_io_sync(struct buffer_head *bh, int uptodate)\n {\n \tBUFFER_TRACE(bh, \"\");\n@@ -983,11 +1004,12 @@ static void ext4_fc_free_inode_snap(struct inode *inode)\n static int ext4_fc_snapshot_inode_data(struct inode *inode,\n \t\t\t\t       struct list_head *ranges,\n \t\t\t\t       unsigned int nr_ranges_total,\n-\t\t\t\t       unsigned int *nr_rangesp)\n+\t\t\t\t       unsigned int *nr_rangesp,\n+\t\t\t\t       int *snap_err)\n {\n \tstruct ext4_inode_info *ei = EXT4_I(inode);\n-\tunsigned int nr_ranges = 0;\n \text4_lblk_t start_lblk, end_lblk, cur_lblk;\n+\tunsigned int nr_ranges = 0;\n \n \tspin_lock(&ei->i_fc_lock);\n \tif (ei->i_fc_lblk_len == 0) {\n@@ -1010,11 +1032,16 @@ static int ext4_fc_snapshot_inode_data(struct inode *inode,\n \t\tstruct ext4_fc_range *range;\n \t\text4_lblk_t len;\n \n-\t\tif (!ext4_es_lookup_extent(inode, cur_lblk, NULL, &es, NULL))\n+\t\tif (!ext4_es_lookup_extent(inode, cur_lblk, NULL, &es, NULL)) {\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\tif (ext4_es_is_delayed(&es)) {\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+\t\t}\n \n \t\tlen = es.es_len - (cur_lblk - es.es_lblk);\n \t\tif (len > end_lblk - cur_lblk + 1)\n@@ -1024,12 +1051,17 @@ static int ext4_fc_snapshot_inode_data(struct inode *inode,\n \t\t\tcontinue;\n \t\t}\n \n-\t\tif (nr_ranges_total + nr_ranges >= EXT4_FC_SNAPSHOT_MAX_RANGES)\n+\t\tif (nr_ranges_total + nr_ranges >= EXT4_FC_SNAPSHOT_MAX_RANGES) {\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+\t\t}\n \n \t\trange = kmem_cache_alloc(ext4_fc_range_cachep, GFP_NOFS);\n-\t\tif (!range)\n+\t\tif (!range) {\n+\t\t\text4_fc_set_snap_err(snap_err, EXT4_FC_SNAP_ERR_NOMEM);\n \t\t\treturn -ENOMEM;\n+\t\t}\n \t\tnr_ranges++;\n \n \t\trange->lblk = cur_lblk;\n@@ -1054,6 +1086,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\text4_fc_set_snap_err(snap_err, EXT4_FC_SNAP_ERR_ES_OTHER);\n \t\t\treturn -EAGAIN;\n \t\t}\n \n@@ -1070,7 +1103,7 @@ static int ext4_fc_snapshot_inode_data(struct inode *inode,\n \n static int ext4_fc_snapshot_inode(struct inode *inode,\n \t\t\t\t  unsigned int nr_ranges_total,\n-\t\t\t\t  unsigned int *nr_rangesp)\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_inode_snap *snap;\n@@ -1082,8 +1115,10 @@ static int ext4_fc_snapshot_inode(struct inode *inode,\n \tint alloc_ctx;\n \n \tret = ext4_get_inode_loc_noio(inode, &iloc);\n-\tif (ret)\n+\tif (ret) {\n+\t\text4_fc_set_snap_err(snap_err, EXT4_FC_SNAP_ERR_INODE_LOC);\n \t\treturn ret;\n+\t}\n \n \tif (ext4_test_inode_flag(inode, EXT4_INODE_INLINE_DATA))\n \t\tinode_len = EXT4_INODE_SIZE(inode->i_sb);\n@@ -1092,6 +1127,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\text4_fc_set_snap_err(snap_err, EXT4_FC_SNAP_ERR_NOMEM);\n \t\tbrelse(iloc.bh);\n \t\treturn -ENOMEM;\n \t}\n@@ -1102,7 +1138,7 @@ static int ext4_fc_snapshot_inode(struct inode *inode,\n \tbrelse(iloc.bh);\n \n \tret = ext4_fc_snapshot_inode_data(inode, &ranges, nr_ranges_total,\n-\t\t\t\t\t  &nr_ranges);\n+\t\t\t\t\t  &nr_ranges, snap_err);\n \tif (ret) {\n \t\tkfree(snap);\n \t\text4_fc_free_ranges(&ranges);\n@@ -1203,7 +1239,10 @@ static int ext4_fc_alloc_snapshot_inodes(struct super_block *sb,\n \t\t\t\t\t unsigned int *nr_inodesp);\n \n static int ext4_fc_snapshot_inodes(journal_t *journal, struct inode **inodes,\n-\t\t\t\t   unsigned int inodes_size)\n+\t\t\t\t   unsigned int inodes_size,\n+\t\t\t\t   unsigned int *nr_inodesp,\n+\t\t\t\t   unsigned int *nr_rangesp,\n+\t\t\t\t   int *snap_err)\n {\n \tstruct super_block *sb = journal->j_private;\n \tstruct ext4_sb_info *sbi = EXT4_SB(sb);\n@@ -1221,6 +1260,8 @@ 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\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 \t\t\tgoto unlock;\n \t\t}\n@@ -1244,6 +1285,8 @@ 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\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 \t\t\tgoto unlock;\n \t\t}\n@@ -1268,16 +1311,20 @@ static int ext4_fc_snapshot_inodes(journal_t *journal, struct inode **inodes,\n \t\tunsigned int inode_ranges = 0;\n \n \t\tret = ext4_fc_snapshot_inode(inodes[idx], nr_ranges,\n-\t\t\t\t\t     &inode_ranges);\n+\t\t\t\t\t     &inode_ranges, snap_err);\n \t\tif (ret)\n \t\t\tbreak;\n \t\tnr_ranges += inode_ranges;\n \t}\n \n+\tif (nr_inodesp)\n+\t\t*nr_inodesp = i;\n+\tif (nr_rangesp)\n+\t\t*nr_rangesp = nr_ranges;\n \treturn ret;\n }\n \n-static int ext4_fc_perform_commit(journal_t *journal)\n+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@@ -1286,10 +1333,15 @@ static int ext4_fc_perform_commit(journal_t *journal)\n \tstruct inode *inode;\n \tstruct inode **inodes;\n \tunsigned int inodes_size;\n+\tunsigned int snap_inodes = 0;\n+\tunsigned int snap_ranges = 0;\n+\tint snap_err = EXT4_FC_SNAP_ERR_NONE;\n \tstruct blk_plug plug;\n \tint ret = 0;\n \tu32 crc = 0;\n \tint alloc_ctx;\n+\tktime_t lock_start;\n+\tu64 locked_ns;\n \n \t/*\n \t * Step 1: Mark all inodes on s_fc_q[MAIN] with\n@@ -1337,13 +1389,13 @@ static int ext4_fc_perform_commit(journal_t *journal)\n \tif (ret)\n \t\treturn ret;\n \n-\n \tret = ext4_fc_alloc_snapshot_inodes(sb, &inodes, &inodes_size);\n \tif (ret)\n \t\treturn ret;\n \n \t/* Step 4: Mark all inodes as being committed. */\n \tjbd2_journal_lock_updates(journal);\n+\tlock_start = ktime_get();\n \t/*\n \t * The journal is now locked. No more handles can start and all the\n \t * previous handles are now drained. Snapshotting happens in this\n@@ -1357,8 +1409,12 @@ static int ext4_fc_perform_commit(journal_t *journal)\n \t}\n \text4_fc_unlock(sb, alloc_ctx);\n \n-\tret = ext4_fc_snapshot_inodes(journal, inodes, inodes_size);\n+\tret = ext4_fc_snapshot_inodes(journal, inodes, inodes_size,\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+\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 \tif (ret)\n \t\treturn ret;\n@@ -1563,7 +1619,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid)\n \t\tjournal_ioprio = EXT4_DEF_JOURNAL_IOPRIO;\n \tset_task_ioprio(current, journal_ioprio);\n \tfc_bufs_before = (sbi->s_fc_bytes + bsize - 1) / bsize;\n-\tret = ext4_fc_perform_commit(journal);\n+\tret = ext4_fc_perform_commit(journal, commit_tid);\n \tif (ret < 0) {\n \t\tif (ret == -EAGAIN || ret == -E2BIG || ret == -ECANCELED)\n \t\t\tstatus = EXT4_FC_STATUS_INELIGIBLE;\ndiff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h\nindex fd76d14c2776..a1493971821d 100644\n--- a/include/trace/events/ext4.h\n+++ b/include/trace/events/ext4.h\n@@ -2812,6 +2812,39 @@ TRACE_EVENT(ext4_fc_commit_stop,\n \t\t  __entry->num_fc_ineligible, __entry->nblks_agg, __entry->tid)\n );\n \n+TRACE_EVENT(ext4_fc_lock_updates,\n+\t    TP_PROTO(struct super_block *sb, tid_t commit_tid, u64 locked_ns,\n+\t\t     unsigned int nr_inodes, unsigned int nr_ranges, int err,\n+\t\t     int snap_err),\n+\n+\tTP_ARGS(sb, commit_tid, locked_ns, nr_inodes, nr_ranges, err, snap_err),\n+\n+\tTP_STRUCT__entry(/* entry */\n+\t\t__field(dev_t, dev)\n+\t\t__field(tid_t, tid)\n+\t\t__field(u64, locked_ns)\n+\t\t__field(unsigned int, nr_inodes)\n+\t\t__field(unsigned int, nr_ranges)\n+\t\t__field(int, err)\n+\t\t__field(int, snap_err)\n+\t),\n+\n+\tTP_fast_assign(/* assign */\n+\t\t__entry->dev = sb->s_dev;\n+\t\t__entry->tid = commit_tid;\n+\t\t__entry->locked_ns = locked_ns;\n+\t\t__entry->nr_inodes = nr_inodes;\n+\t\t__entry->nr_ranges = nr_ranges;\n+\t\t__entry->err = err;\n+\t\t__entry->snap_err = snap_err;\n+\t),\n+\n+\tTP_printk(\"dev %d,%d tid %u locked_ns %llu nr_inodes %u nr_ranges %u err %d snap_err %d\",\n+\t\t  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->tid,\n+\t\t  __entry->locked_ns, __entry->nr_inodes, __entry->nr_ranges,\n+\t\t  __entry->err, __entry->snap_err)\n+);\n+\n #define FC_REASON_NAME_STAT(reason)\t\t\t\t\t\\\n \tshow_fc_reason(reason),\t\t\t\t\t\t\\\n \t__entry->fc_ineligible_rc[reason]\n","prefixes":["RFC","v4","6/7"]}