blob: 7edffee54293da8dad253ee553daf23b8c1f67b1 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001From cb9f1a821bcf55cecf3813195fd6d4eff8070927 Mon Sep 17 00:00:00 2001
2From: Michael Jeanson <mjeanson@efficios.com>
3Date: Mon, 5 Nov 2018 11:35:54 -0500
4Subject: [PATCH 3/9] Fix: ext4: adjust reserved cluster count when removing
5 extents (v4.20)
6
7See upstream commit :
8
9 commit 9fe671496b6c286f9033aedfc1718d67721da0ae
10 Author: Eric Whitney <enwlinux@gmail.com>
11 Date: Mon Oct 1 14:25:08 2018 -0400
12
13 ext4: adjust reserved cluster count when removing extents
14
15 Modify ext4_ext_remove_space() and the code it calls to correct the
16 reserved cluster count for pending reservations (delayed allocated
17 clusters shared with allocated blocks) when a block range is removed
18 from the extent tree. Pending reservations may be found for the clusters
19 at the ends of written or unwritten extents when a block range is removed.
20 If a physical cluster at the end of an extent is freed, it's necessary
21 to increment the reserved cluster count to maintain correct accounting
22 if the corresponding logical cluster is shared with at least one
23 delayed and unwritten extent as found in the extents status tree.
24
25 Add a new function, ext4_rereserve_cluster(), to reapply a reservation
26 on a delayed allocated cluster sharing blocks with a freed allocated
27 cluster. To avoid ENOSPC on reservation, a flag is applied to
28 ext4_free_blocks() to briefly defer updating the freeclusters counter
29 when an allocated cluster is freed. This prevents another thread
30 from allocating the freed block before the reservation can be reapplied.
31
32 Redefine the partial cluster object as a struct to carry more state
33 information and to clarify the code using it.
34
35 Adjust the conditional code structure in ext4_ext_remove_space to
36 reduce the indentation level in the main body of the code to improve
37 readability.
38
39Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
40Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
41
42Upstream-Status: backport https://github.com/lttng/lttng-modules/commit/cb9f1a821bcf55cecf3813195fd6d4eff8070927
43
44Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
45
46---
47 instrumentation/events/lttng-module/ext4.h | 72 +++++++++++++++++++++-
48 1 file changed, 69 insertions(+), 3 deletions(-)
49
50diff --git a/instrumentation/events/lttng-module/ext4.h b/instrumentation/events/lttng-module/ext4.h
51index fe6f802..83a80ba 100644
52--- a/instrumentation/events/lttng-module/ext4.h
53+++ b/instrumentation/events/lttng-module/ext4.h
54@@ -1602,7 +1602,30 @@ LTTNG_TRACEPOINT_EVENT(ext4_ext_show_extent,
55 )
56 )
57
58-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
59+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
60+
61+LTTNG_TRACEPOINT_EVENT(ext4_remove_blocks,
62+ TP_PROTO(struct inode *inode, struct ext4_extent *ex,
63+ ext4_lblk_t from, ext4_fsblk_t to,
64+ struct partial_cluster *pc),
65+
66+ TP_ARGS(inode, ex, from, to, pc),
67+
68+ TP_FIELDS(
69+ ctf_integer(dev_t, dev, inode->i_sb->s_dev)
70+ ctf_integer(ino_t, ino, inode->i_ino)
71+ ctf_integer(ext4_lblk_t, from, from)
72+ ctf_integer(ext4_lblk_t, to, to)
73+ ctf_integer(ext4_fsblk_t, ee_pblk, ext4_ext_pblock(ex))
74+ ctf_integer(ext4_lblk_t, ee_lblk, le32_to_cpu(ex->ee_block))
75+ ctf_integer(unsigned short, ee_len, ext4_ext_get_actual_len(ex))
76+ ctf_integer(ext4_fsblk_t, pc_pclu, pc->pclu)
77+ ctf_integer(ext4_lblk_t, pc_lblk, pc->lblk)
78+ ctf_integer(int, pc_state, pc->state)
79+ )
80+)
81+
82+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
83
84 LTTNG_TRACEPOINT_EVENT(ext4_remove_blocks,
85 TP_PROTO(struct inode *inode, struct ext4_extent *ex,
86@@ -1646,7 +1669,29 @@ LTTNG_TRACEPOINT_EVENT(ext4_remove_blocks,
87
88 #endif
89
90-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
91+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
92+
93+LTTNG_TRACEPOINT_EVENT(ext4_ext_rm_leaf,
94+ TP_PROTO(struct inode *inode, ext4_lblk_t start,
95+ struct ext4_extent *ex,
96+ struct partial_cluster *pc),
97+
98+ TP_ARGS(inode, start, ex, pc),
99+
100+ TP_FIELDS(
101+ ctf_integer(dev_t, dev, inode->i_sb->s_dev)
102+ ctf_integer(ino_t, ino, inode->i_ino)
103+ ctf_integer(ext4_lblk_t, start, start)
104+ ctf_integer(ext4_lblk_t, ee_lblk, le32_to_cpu(ex->ee_block))
105+ ctf_integer(ext4_fsblk_t, ee_pblk, ext4_ext_pblock(ex))
106+ ctf_integer(short, ee_len, ext4_ext_get_actual_len(ex))
107+ ctf_integer(ext4_fsblk_t, pc_pclu, pc->pclu)
108+ ctf_integer(ext4_lblk_t, pc_lblk, pc->lblk)
109+ ctf_integer(int, pc_state, pc->state)
110+ )
111+)
112+
113+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
114
115 LTTNG_TRACEPOINT_EVENT(ext4_ext_rm_leaf,
116 TP_PROTO(struct inode *inode, ext4_lblk_t start,
117@@ -1733,7 +1778,28 @@ LTTNG_TRACEPOINT_EVENT(ext4_ext_remove_space,
118
119 #endif
120
121-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
122+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
123+
124+LTTNG_TRACEPOINT_EVENT(ext4_ext_remove_space_done,
125+ TP_PROTO(struct inode *inode, ext4_lblk_t start, ext4_lblk_t end,
126+ int depth, struct partial_cluster *pc, __le16 eh_entries),
127+
128+ TP_ARGS(inode, start, end, depth, pc, eh_entries),
129+
130+ TP_FIELDS(
131+ ctf_integer(dev_t, dev, inode->i_sb->s_dev)
132+ ctf_integer(ino_t, ino, inode->i_ino)
133+ ctf_integer(ext4_lblk_t, start, start)
134+ ctf_integer(ext4_lblk_t, end, end)
135+ ctf_integer(int, depth, depth)
136+ ctf_integer(unsigned short, eh_entries, le16_to_cpu(eh_entries))
137+ ctf_integer(ext4_fsblk_t, pc_pclu, pc->pclu)
138+ ctf_integer(ext4_lblk_t, pc_lblk, pc->lblk)
139+ ctf_integer(int, pc_state, pc->state)
140+ )
141+)
142+
143+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
144
145 LTTNG_TRACEPOINT_EVENT(ext4_ext_remove_space_done,
146 TP_PROTO(struct inode *inode, ext4_lblk_t start, ext4_lblk_t end,
147--
1482.19.1
149