@@ -86,88 +86,6 @@ struct async_submit_bio {
8686 blk_status_t status ;
8787};
8888
89- /*
90- * Lockdep class keys for extent_buffer->lock's in this root. For a given
91- * eb, the lockdep key is determined by the btrfs_root it belongs to and
92- * the level the eb occupies in the tree.
93- *
94- * Different roots are used for different purposes and may nest inside each
95- * other and they require separate keysets. As lockdep keys should be
96- * static, assign keysets according to the purpose of the root as indicated
97- * by btrfs_root->root_key.objectid. This ensures that all special purpose
98- * roots have separate keysets.
99- *
100- * Lock-nesting across peer nodes is always done with the immediate parent
101- * node locked thus preventing deadlock. As lockdep doesn't know this, use
102- * subclass to avoid triggering lockdep warning in such cases.
103- *
104- * The key is set by the readpage_end_io_hook after the buffer has passed
105- * csum validation but before the pages are unlocked. It is also set by
106- * btrfs_init_new_buffer on freshly allocated blocks.
107- *
108- * We also add a check to make sure the highest level of the tree is the
109- * same as our lockdep setup here. If BTRFS_MAX_LEVEL changes, this code
110- * needs update as well.
111- */
112- #ifdef CONFIG_DEBUG_LOCK_ALLOC
113- # if BTRFS_MAX_LEVEL != 8
114- # error
115- # endif
116-
117- #define DEFINE_LEVEL (stem , level ) \
118- .names[level] = "btrfs-" stem "-0" #level,
119-
120- #define DEFINE_NAME (stem ) \
121- DEFINE_LEVEL(stem, 0) \
122- DEFINE_LEVEL(stem, 1) \
123- DEFINE_LEVEL(stem, 2) \
124- DEFINE_LEVEL(stem, 3) \
125- DEFINE_LEVEL(stem, 4) \
126- DEFINE_LEVEL(stem, 5) \
127- DEFINE_LEVEL(stem, 6) \
128- DEFINE_LEVEL(stem, 7)
129-
130- static struct btrfs_lockdep_keyset {
131- u64 id ; /* root objectid */
132- /* Longest entry: btrfs-free-space-00 */
133- char names [BTRFS_MAX_LEVEL ][20 ];
134- struct lock_class_key keys [BTRFS_MAX_LEVEL ];
135- } btrfs_lockdep_keysets [] = {
136- { .id = BTRFS_ROOT_TREE_OBJECTID , DEFINE_NAME ("root" ) },
137- { .id = BTRFS_EXTENT_TREE_OBJECTID , DEFINE_NAME ("extent" ) },
138- { .id = BTRFS_CHUNK_TREE_OBJECTID , DEFINE_NAME ("chunk" ) },
139- { .id = BTRFS_DEV_TREE_OBJECTID , DEFINE_NAME ("dev" ) },
140- { .id = BTRFS_CSUM_TREE_OBJECTID , DEFINE_NAME ("csum" ) },
141- { .id = BTRFS_QUOTA_TREE_OBJECTID , DEFINE_NAME ("quota" ) },
142- { .id = BTRFS_TREE_LOG_OBJECTID , DEFINE_NAME ("log" ) },
143- { .id = BTRFS_TREE_RELOC_OBJECTID , DEFINE_NAME ("treloc" ) },
144- { .id = BTRFS_DATA_RELOC_TREE_OBJECTID , DEFINE_NAME ("dreloc" ) },
145- { .id = BTRFS_UUID_TREE_OBJECTID , DEFINE_NAME ("uuid" ) },
146- { .id = BTRFS_FREE_SPACE_TREE_OBJECTID , DEFINE_NAME ("free-space" ) },
147- { .id = 0 , DEFINE_NAME ("tree" ) },
148- };
149-
150- #undef DEFINE_LEVEL
151- #undef DEFINE_NAME
152-
153- void btrfs_set_buffer_lockdep_class (u64 objectid , struct extent_buffer * eb ,
154- int level )
155- {
156- struct btrfs_lockdep_keyset * ks ;
157-
158- BUG_ON (level >= ARRAY_SIZE (ks -> keys ));
159-
160- /* find the matching keyset, id 0 is the default entry */
161- for (ks = btrfs_lockdep_keysets ; ks -> id ; ks ++ )
162- if (ks -> id == objectid )
163- break ;
164-
165- lockdep_set_class_and_name (& eb -> lock ,
166- & ks -> keys [level ], ks -> names [level ]);
167- }
168-
169- #endif
170-
17189/*
17290 * Compute the csum of a btree block and store the result to provided buffer.
17391 */
0 commit comments