1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "tools/trace_to_text/ftrace_inode_handler.h"
18
19namespace perfetto {
20
21bool ParseInode(const protos::FtraceEvent& event, uint64_t* inode) {
22  if (event.has_ext4_alloc_da_blocks() && event.ext4_alloc_da_blocks().ino()) {
23    *inode = static_cast<uint64_t>(event.ext4_alloc_da_blocks().ino());
24    return true;
25  } else if (event.has_ext4_allocate_blocks() &&
26             event.ext4_allocate_blocks().ino()) {
27    *inode = static_cast<uint64_t>(event.ext4_allocate_blocks().ino());
28    return true;
29  } else if (event.has_ext4_allocate_inode() &&
30             event.ext4_allocate_inode().ino()) {
31    *inode = static_cast<uint64_t>(event.ext4_allocate_inode().ino());
32    return true;
33  } else if (event.has_ext4_begin_ordered_truncate() &&
34             event.ext4_begin_ordered_truncate().ino()) {
35    *inode = static_cast<uint64_t>(event.ext4_begin_ordered_truncate().ino());
36    return true;
37  } else if (event.has_ext4_collapse_range() &&
38             event.ext4_collapse_range().ino()) {
39    *inode = static_cast<uint64_t>(event.ext4_collapse_range().ino());
40    return true;
41  } else if (event.has_ext4_da_release_space() &&
42             event.ext4_da_release_space().ino()) {
43    *inode = static_cast<uint64_t>(event.ext4_da_release_space().ino());
44    return true;
45  } else if (event.has_ext4_da_reserve_space() &&
46             event.ext4_da_reserve_space().ino()) {
47    *inode = static_cast<uint64_t>(event.ext4_da_reserve_space().ino());
48    return true;
49  } else if (event.has_ext4_da_update_reserve_space() &&
50             event.ext4_da_update_reserve_space().ino()) {
51    *inode = static_cast<uint64_t>(event.ext4_da_update_reserve_space().ino());
52    return true;
53  } else if (event.has_ext4_da_write_begin() &&
54             event.ext4_da_write_begin().ino()) {
55    *inode = static_cast<uint64_t>(event.ext4_da_write_begin().ino());
56    return true;
57  } else if (event.has_ext4_da_write_end() && event.ext4_da_write_end().ino()) {
58    *inode = static_cast<uint64_t>(event.ext4_da_write_end().ino());
59    return true;
60  } else if (event.has_ext4_da_write_pages() &&
61             event.ext4_da_write_pages().ino()) {
62    *inode = static_cast<uint64_t>(event.ext4_da_write_pages().ino());
63    return true;
64  } else if (event.has_ext4_da_write_pages_extent() &&
65             event.ext4_da_write_pages_extent().ino()) {
66    *inode = static_cast<uint64_t>(event.ext4_da_write_pages_extent().ino());
67    return true;
68  } else if (event.has_ext4_direct_io_enter() &&
69             event.ext4_direct_io_enter().ino()) {
70    *inode = static_cast<uint64_t>(event.ext4_direct_io_enter().ino());
71    return true;
72  } else if (event.has_ext4_direct_io_exit() &&
73             event.ext4_direct_io_exit().ino()) {
74    *inode = static_cast<uint64_t>(event.ext4_direct_io_exit().ino());
75    return true;
76  } else if (event.has_ext4_discard_preallocations() &&
77             event.ext4_discard_preallocations().ino()) {
78    *inode = static_cast<uint64_t>(event.ext4_discard_preallocations().ino());
79    return true;
80  } else if (event.has_ext4_drop_inode() && event.ext4_drop_inode().ino()) {
81    *inode = static_cast<uint64_t>(event.ext4_drop_inode().ino());
82    return true;
83  } else if (event.has_ext4_es_cache_extent() &&
84             event.ext4_es_cache_extent().ino()) {
85    *inode = static_cast<uint64_t>(event.ext4_es_cache_extent().ino());
86    return true;
87  } else if (event.has_ext4_es_find_delayed_extent_range_enter() &&
88             event.ext4_es_find_delayed_extent_range_enter().ino()) {
89    *inode = static_cast<uint64_t>(
90        event.ext4_es_find_delayed_extent_range_enter().ino());
91    return true;
92  } else if (event.has_ext4_es_find_delayed_extent_range_exit() &&
93             event.ext4_es_find_delayed_extent_range_exit().ino()) {
94    *inode = static_cast<uint64_t>(
95        event.ext4_es_find_delayed_extent_range_exit().ino());
96    return true;
97  } else if (event.has_ext4_es_insert_extent() &&
98             event.ext4_es_insert_extent().ino()) {
99    *inode = static_cast<uint64_t>(event.ext4_es_insert_extent().ino());
100    return true;
101  } else if (event.has_ext4_es_lookup_extent_enter() &&
102             event.ext4_es_lookup_extent_enter().ino()) {
103    *inode = static_cast<uint64_t>(event.ext4_es_lookup_extent_enter().ino());
104    return true;
105  } else if (event.has_ext4_es_lookup_extent_exit() &&
106             event.ext4_es_lookup_extent_exit().ino()) {
107    *inode = static_cast<uint64_t>(event.ext4_es_lookup_extent_exit().ino());
108    return true;
109  } else if (event.has_ext4_es_remove_extent() &&
110             event.ext4_es_remove_extent().ino()) {
111    *inode = static_cast<uint64_t>(event.ext4_es_remove_extent().ino());
112    return true;
113  } else if (event.has_ext4_evict_inode() && event.ext4_evict_inode().ino()) {
114    *inode = static_cast<uint64_t>(event.ext4_evict_inode().ino());
115    return true;
116  } else if (event.has_ext4_ext_convert_to_initialized_enter() &&
117             event.ext4_ext_convert_to_initialized_enter().ino()) {
118    *inode = static_cast<uint64_t>(
119        event.ext4_ext_convert_to_initialized_enter().ino());
120    return true;
121  } else if (event.has_ext4_ext_convert_to_initialized_fastpath() &&
122             event.ext4_ext_convert_to_initialized_fastpath().ino()) {
123    *inode = static_cast<uint64_t>(
124        event.ext4_ext_convert_to_initialized_fastpath().ino());
125    return true;
126  } else if (event.has_ext4_ext_handle_unwritten_extents() &&
127             event.ext4_ext_handle_unwritten_extents().ino()) {
128    *inode =
129        static_cast<uint64_t>(event.ext4_ext_handle_unwritten_extents().ino());
130    return true;
131  } else if (event.has_ext4_ext_in_cache() && event.ext4_ext_in_cache().ino()) {
132    *inode = static_cast<uint64_t>(event.ext4_ext_in_cache().ino());
133    return true;
134  } else if (event.has_ext4_ext_load_extent() &&
135             event.ext4_ext_load_extent().ino()) {
136    *inode = static_cast<uint64_t>(event.ext4_ext_load_extent().ino());
137    return true;
138  } else if (event.has_ext4_ext_map_blocks_enter() &&
139             event.ext4_ext_map_blocks_enter().ino()) {
140    *inode = static_cast<uint64_t>(event.ext4_ext_map_blocks_enter().ino());
141    return true;
142  } else if (event.has_ext4_ext_map_blocks_exit() &&
143             event.ext4_ext_map_blocks_exit().ino()) {
144    *inode = static_cast<uint64_t>(event.ext4_ext_map_blocks_exit().ino());
145    return true;
146  } else if (event.has_ext4_ext_put_in_cache() &&
147             event.ext4_ext_put_in_cache().ino()) {
148    *inode = static_cast<uint64_t>(event.ext4_ext_put_in_cache().ino());
149    return true;
150  } else if (event.has_ext4_ext_remove_space() &&
151             event.ext4_ext_remove_space().ino()) {
152    *inode = static_cast<uint64_t>(event.ext4_ext_remove_space().ino());
153    return true;
154  } else if (event.has_ext4_ext_remove_space_done() &&
155             event.ext4_ext_remove_space_done().ino()) {
156    *inode = static_cast<uint64_t>(event.ext4_ext_remove_space_done().ino());
157    return true;
158  } else if (event.has_ext4_ext_rm_idx() && event.ext4_ext_rm_idx().ino()) {
159    *inode = static_cast<uint64_t>(event.ext4_ext_rm_idx().ino());
160    return true;
161  } else if (event.has_ext4_ext_rm_leaf() && event.ext4_ext_rm_leaf().ino()) {
162    *inode = static_cast<uint64_t>(event.ext4_ext_rm_leaf().ino());
163    return true;
164  } else if (event.has_ext4_ext_show_extent() &&
165             event.ext4_ext_show_extent().ino()) {
166    *inode = static_cast<uint64_t>(event.ext4_ext_show_extent().ino());
167    return true;
168  } else if (event.has_ext4_fallocate_enter() &&
169             event.ext4_fallocate_enter().ino()) {
170    *inode = static_cast<uint64_t>(event.ext4_fallocate_enter().ino());
171    return true;
172  } else if (event.has_ext4_fallocate_exit() &&
173             event.ext4_fallocate_exit().ino()) {
174    *inode = static_cast<uint64_t>(event.ext4_fallocate_exit().ino());
175    return true;
176  } else if (event.has_ext4_find_delalloc_range() &&
177             event.ext4_find_delalloc_range().ino()) {
178    *inode = static_cast<uint64_t>(event.ext4_find_delalloc_range().ino());
179    return true;
180  } else if (event.has_ext4_forget() && event.ext4_forget().ino()) {
181    *inode = static_cast<uint64_t>(event.ext4_forget().ino());
182    return true;
183  } else if (event.has_ext4_free_blocks() && event.ext4_free_blocks().ino()) {
184    *inode = static_cast<uint64_t>(event.ext4_free_blocks().ino());
185    return true;
186  } else if (event.has_ext4_free_inode() && event.ext4_free_inode().ino()) {
187    *inode = static_cast<uint64_t>(event.ext4_free_inode().ino());
188    return true;
189  } else if (event.has_ext4_get_reserved_cluster_alloc() &&
190             event.ext4_get_reserved_cluster_alloc().ino()) {
191    *inode =
192        static_cast<uint64_t>(event.ext4_get_reserved_cluster_alloc().ino());
193    return true;
194  } else if (event.has_ext4_ind_map_blocks_enter() &&
195             event.ext4_ind_map_blocks_enter().ino()) {
196    *inode = static_cast<uint64_t>(event.ext4_ind_map_blocks_enter().ino());
197    return true;
198  } else if (event.has_ext4_ind_map_blocks_exit() &&
199             event.ext4_ind_map_blocks_exit().ino()) {
200    *inode = static_cast<uint64_t>(event.ext4_ind_map_blocks_exit().ino());
201    return true;
202  } else if (event.has_ext4_insert_range() && event.ext4_insert_range().ino()) {
203    *inode = static_cast<uint64_t>(event.ext4_insert_range().ino());
204    return true;
205  } else if (event.has_ext4_invalidatepage() &&
206             event.ext4_invalidatepage().ino()) {
207    *inode = static_cast<uint64_t>(event.ext4_invalidatepage().ino());
208    return true;
209  } else if (event.has_ext4_journalled_invalidatepage() &&
210             event.ext4_journalled_invalidatepage().ino()) {
211    *inode =
212        static_cast<uint64_t>(event.ext4_journalled_invalidatepage().ino());
213    return true;
214  } else if (event.has_ext4_journalled_write_end() &&
215             event.ext4_journalled_write_end().ino()) {
216    *inode = static_cast<uint64_t>(event.ext4_journalled_write_end().ino());
217    return true;
218  } else if (event.has_ext4_load_inode() && event.ext4_load_inode().ino()) {
219    *inode = static_cast<uint64_t>(event.ext4_load_inode().ino());
220    return true;
221  } else if (event.has_ext4_mark_inode_dirty() &&
222             event.ext4_mark_inode_dirty().ino()) {
223    *inode = static_cast<uint64_t>(event.ext4_mark_inode_dirty().ino());
224    return true;
225  } else if (event.has_ext4_mb_new_group_pa() &&
226             event.ext4_mb_new_group_pa().ino()) {
227    *inode = static_cast<uint64_t>(event.ext4_mb_new_group_pa().ino());
228    return true;
229  } else if (event.has_ext4_mb_new_inode_pa() &&
230             event.ext4_mb_new_inode_pa().ino()) {
231    *inode = static_cast<uint64_t>(event.ext4_mb_new_inode_pa().ino());
232    return true;
233  } else if (event.has_ext4_mb_release_inode_pa() &&
234             event.ext4_mb_release_inode_pa().ino()) {
235    *inode = static_cast<uint64_t>(event.ext4_mb_release_inode_pa().ino());
236    return true;
237  } else if (event.has_ext4_mballoc_alloc() &&
238             event.ext4_mballoc_alloc().ino()) {
239    *inode = static_cast<uint64_t>(event.ext4_mballoc_alloc().ino());
240    return true;
241  } else if (event.has_ext4_mballoc_discard() &&
242             event.ext4_mballoc_discard().ino()) {
243    *inode = static_cast<uint64_t>(event.ext4_mballoc_discard().ino());
244    return true;
245  } else if (event.has_ext4_mballoc_free() && event.ext4_mballoc_free().ino()) {
246    *inode = static_cast<uint64_t>(event.ext4_mballoc_free().ino());
247    return true;
248  } else if (event.has_ext4_mballoc_prealloc() &&
249             event.ext4_mballoc_prealloc().ino()) {
250    *inode = static_cast<uint64_t>(event.ext4_mballoc_prealloc().ino());
251    return true;
252  } else if (event.has_ext4_other_inode_update_time() &&
253             event.ext4_other_inode_update_time().ino()) {
254    *inode = static_cast<uint64_t>(event.ext4_other_inode_update_time().ino());
255    return true;
256  } else if (event.has_ext4_other_inode_update_time() &&
257             event.ext4_other_inode_update_time().orig_ino()) {
258    *inode =
259        static_cast<uint64_t>(event.ext4_other_inode_update_time().orig_ino());
260    return true;
261  } else if (event.has_ext4_punch_hole() && event.ext4_punch_hole().ino()) {
262    *inode = static_cast<uint64_t>(event.ext4_punch_hole().ino());
263    return true;
264  } else if (event.has_ext4_readpage() && event.ext4_readpage().ino()) {
265    *inode = static_cast<uint64_t>(event.ext4_readpage().ino());
266    return true;
267  } else if (event.has_ext4_releasepage() && event.ext4_releasepage().ino()) {
268    *inode = static_cast<uint64_t>(event.ext4_releasepage().ino());
269    return true;
270  } else if (event.has_ext4_remove_blocks() &&
271             event.ext4_remove_blocks().ino()) {
272    *inode = static_cast<uint64_t>(event.ext4_remove_blocks().ino());
273    return true;
274  } else if (event.has_ext4_request_blocks() &&
275             event.ext4_request_blocks().ino()) {
276    *inode = static_cast<uint64_t>(event.ext4_request_blocks().ino());
277    return true;
278  } else if (event.has_ext4_sync_file_enter() &&
279             event.ext4_sync_file_enter().ino()) {
280    *inode = static_cast<uint64_t>(event.ext4_sync_file_enter().ino());
281    return true;
282  } else if (event.has_ext4_sync_file_exit() &&
283             event.ext4_sync_file_exit().ino()) {
284    *inode = static_cast<uint64_t>(event.ext4_sync_file_exit().ino());
285    return true;
286  } else if (event.has_ext4_truncate_enter() &&
287             event.ext4_truncate_enter().ino()) {
288    *inode = static_cast<uint64_t>(event.ext4_truncate_enter().ino());
289    return true;
290  } else if (event.has_ext4_truncate_exit() &&
291             event.ext4_truncate_exit().ino()) {
292    *inode = static_cast<uint64_t>(event.ext4_truncate_exit().ino());
293    return true;
294  } else if (event.has_ext4_unlink_enter() && event.ext4_unlink_enter().ino()) {
295    *inode = static_cast<uint64_t>(event.ext4_unlink_enter().ino());
296    return true;
297  } else if (event.has_ext4_unlink_exit() && event.ext4_unlink_exit().ino()) {
298    *inode = static_cast<uint64_t>(event.ext4_unlink_exit().ino());
299    return true;
300  } else if (event.has_ext4_write_begin() && event.ext4_write_begin().ino()) {
301    *inode = static_cast<uint64_t>(event.ext4_write_begin().ino());
302    return true;
303  } else if (event.has_ext4_write_end() && event.ext4_write_end().ino()) {
304    *inode = static_cast<uint64_t>(event.ext4_write_end().ino());
305    return true;
306  } else if (event.has_ext4_writepage() && event.ext4_writepage().ino()) {
307    *inode = static_cast<uint64_t>(event.ext4_writepage().ino());
308    return true;
309  } else if (event.has_ext4_writepages() && event.ext4_writepages().ino()) {
310    *inode = static_cast<uint64_t>(event.ext4_writepages().ino());
311    return true;
312  } else if (event.has_ext4_writepages_result() &&
313             event.ext4_writepages_result().ino()) {
314    *inode = static_cast<uint64_t>(event.ext4_writepages_result().ino());
315    return true;
316  } else if (event.has_ext4_zero_range() && event.ext4_zero_range().ino()) {
317    *inode = static_cast<uint64_t>(event.ext4_zero_range().ino());
318    return true;
319  } else if (event.has_mm_filemap_add_to_page_cache() &&
320             event.mm_filemap_add_to_page_cache().i_ino()) {
321    *inode =
322        static_cast<uint64_t>(event.mm_filemap_add_to_page_cache().i_ino());
323    return true;
324  } else if (event.has_mm_filemap_delete_from_page_cache() &&
325             event.mm_filemap_delete_from_page_cache().i_ino()) {
326    *inode = static_cast<uint64_t>(
327        event.mm_filemap_delete_from_page_cache().i_ino());
328    return true;
329  } else if (event.has_f2fs_evict_inode() && event.f2fs_evict_inode().ino()) {
330    *inode = static_cast<uint64_t>(event.f2fs_evict_inode().ino());
331    return true;
332  } else if (event.has_f2fs_evict_inode() && event.f2fs_evict_inode().pino()) {
333    *inode = static_cast<uint64_t>(event.f2fs_evict_inode().pino());
334    return true;
335  } else if (event.has_f2fs_fallocate() && event.f2fs_fallocate().ino()) {
336    *inode = static_cast<uint64_t>(event.f2fs_fallocate().ino());
337    return true;
338  } else if (event.has_f2fs_get_data_block() &&
339             event.f2fs_get_data_block().ino()) {
340    *inode = static_cast<uint64_t>(event.f2fs_get_data_block().ino());
341    return true;
342  } else if (event.has_f2fs_iget() && event.f2fs_iget().ino()) {
343    *inode = static_cast<uint64_t>(event.f2fs_iget().ino());
344    return true;
345  } else if (event.has_f2fs_iget() && event.f2fs_iget().pino()) {
346    *inode = static_cast<uint64_t>(event.f2fs_iget().pino());
347    return true;
348  } else if (event.has_f2fs_iget_exit() && event.f2fs_iget_exit().ino()) {
349    *inode = static_cast<uint64_t>(event.f2fs_iget_exit().ino());
350    return true;
351  } else if (event.has_f2fs_new_inode() && event.f2fs_new_inode().ino()) {
352    *inode = static_cast<uint64_t>(event.f2fs_new_inode().ino());
353    return true;
354  } else if (event.has_f2fs_readpage() && event.f2fs_readpage().ino()) {
355    *inode = static_cast<uint64_t>(event.f2fs_readpage().ino());
356    return true;
357  } else if (event.has_f2fs_set_page_dirty() &&
358             event.f2fs_set_page_dirty().ino()) {
359    *inode = static_cast<uint64_t>(event.f2fs_set_page_dirty().ino());
360    return true;
361  } else if (event.has_f2fs_submit_write_page() &&
362             event.f2fs_submit_write_page().ino()) {
363    *inode = static_cast<uint64_t>(event.f2fs_submit_write_page().ino());
364    return true;
365  } else if (event.has_f2fs_sync_file_enter() &&
366             event.f2fs_sync_file_enter().ino()) {
367    *inode = static_cast<uint64_t>(event.f2fs_sync_file_enter().ino());
368    return true;
369  } else if (event.has_f2fs_sync_file_enter() &&
370             event.f2fs_sync_file_enter().pino()) {
371    *inode = static_cast<uint64_t>(event.f2fs_sync_file_enter().pino());
372    return true;
373  } else if (event.has_f2fs_sync_file_exit() &&
374             event.f2fs_sync_file_exit().ino()) {
375    *inode = static_cast<uint64_t>(event.f2fs_sync_file_exit().ino());
376    return true;
377  } else if (event.has_f2fs_truncate() && event.f2fs_truncate().ino()) {
378    *inode = static_cast<uint64_t>(event.f2fs_truncate().ino());
379    return true;
380  } else if (event.has_f2fs_truncate() && event.f2fs_truncate().pino()) {
381    *inode = static_cast<uint64_t>(event.f2fs_truncate().pino());
382    return true;
383  } else if (event.has_f2fs_truncate_blocks_enter() &&
384             event.f2fs_truncate_blocks_enter().ino()) {
385    *inode = static_cast<uint64_t>(event.f2fs_truncate_blocks_enter().ino());
386    return true;
387  } else if (event.has_f2fs_truncate_blocks_exit() &&
388             event.f2fs_truncate_blocks_exit().ino()) {
389    *inode = static_cast<uint64_t>(event.f2fs_truncate_blocks_exit().ino());
390    return true;
391  } else if (event.has_f2fs_truncate_data_blocks_range() &&
392             event.f2fs_truncate_data_blocks_range().ino()) {
393    *inode =
394        static_cast<uint64_t>(event.f2fs_truncate_data_blocks_range().ino());
395    return true;
396  } else if (event.has_f2fs_truncate_inode_blocks_enter() &&
397             event.f2fs_truncate_inode_blocks_enter().ino()) {
398    *inode =
399        static_cast<uint64_t>(event.f2fs_truncate_inode_blocks_enter().ino());
400    return true;
401  } else if (event.has_f2fs_truncate_inode_blocks_exit() &&
402             event.f2fs_truncate_inode_blocks_exit().ino()) {
403    *inode =
404        static_cast<uint64_t>(event.f2fs_truncate_inode_blocks_exit().ino());
405    return true;
406  } else if (event.has_f2fs_truncate_node() &&
407             event.f2fs_truncate_node().ino()) {
408    *inode = static_cast<uint64_t>(event.f2fs_truncate_node().ino());
409    return true;
410  } else if (event.has_f2fs_truncate_nodes_enter() &&
411             event.f2fs_truncate_nodes_enter().ino()) {
412    *inode = static_cast<uint64_t>(event.f2fs_truncate_nodes_enter().ino());
413    return true;
414  } else if (event.has_f2fs_truncate_nodes_exit() &&
415             event.f2fs_truncate_nodes_exit().ino()) {
416    *inode = static_cast<uint64_t>(event.f2fs_truncate_nodes_exit().ino());
417    return true;
418  } else if (event.has_f2fs_truncate_partial_nodes() &&
419             event.f2fs_truncate_partial_nodes().ino()) {
420    *inode = static_cast<uint64_t>(event.f2fs_truncate_partial_nodes().ino());
421    return true;
422  } else if (event.has_f2fs_unlink_enter() && event.f2fs_unlink_enter().ino()) {
423    *inode = static_cast<uint64_t>(event.f2fs_unlink_enter().ino());
424    return true;
425  } else if (event.has_f2fs_unlink_exit() && event.f2fs_unlink_exit().ino()) {
426    *inode = static_cast<uint64_t>(event.f2fs_unlink_exit().ino());
427    return true;
428  } else if (event.has_f2fs_vm_page_mkwrite() &&
429             event.f2fs_vm_page_mkwrite().ino()) {
430    *inode = static_cast<uint64_t>(event.f2fs_vm_page_mkwrite().ino());
431    return true;
432  } else if (event.has_f2fs_write_begin() && event.f2fs_write_begin().ino()) {
433    *inode = static_cast<uint64_t>(event.f2fs_write_begin().ino());
434    return true;
435  } else if (event.has_f2fs_write_end() && event.f2fs_write_end().ino()) {
436    *inode = static_cast<uint64_t>(event.f2fs_write_end().ino());
437    return true;
438  }
439  return false;
440}
441
442}  // namespace perfetto
443