hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/include/linux/backing-dev.h
....@@ -25,6 +25,7 @@
2525 return bdi;
2626 }
2727
28
+struct backing_dev_info *bdi_get_by_id(u64 id);
2829 void bdi_put(struct backing_dev_info *bdi);
2930
3031 __printf(2, 3)
....@@ -32,23 +33,22 @@
3233 __printf(2, 0)
3334 int bdi_register_va(struct backing_dev_info *bdi, const char *fmt,
3435 va_list args);
35
-int bdi_register_owner(struct backing_dev_info *bdi, struct device *owner);
36
+void bdi_set_owner(struct backing_dev_info *bdi, struct device *owner);
3637 void bdi_unregister(struct backing_dev_info *bdi);
3738
38
-struct backing_dev_info *bdi_alloc_node(gfp_t gfp_mask, int node_id);
39
-static inline struct backing_dev_info *bdi_alloc(gfp_t gfp_mask)
40
-{
41
- return bdi_alloc_node(gfp_mask, NUMA_NO_NODE);
42
-}
39
+struct backing_dev_info *bdi_alloc(int node_id);
4340
4441 void wb_start_background_writeback(struct bdi_writeback *wb);
4542 void wb_workfn(struct work_struct *work);
4643 void wb_wakeup_delayed(struct bdi_writeback *wb);
4744
45
+void wb_wait_for_completion(struct wb_completion *done);
46
+
4847 extern spinlock_t bdi_lock;
4948 extern struct list_head bdi_list;
5049
5150 extern struct workqueue_struct *bdi_wq;
51
+extern struct workqueue_struct *bdi_async_bio_wq;
5252
5353 static inline bool wb_has_dirty_io(struct bdi_writeback *wb)
5454 {
....@@ -110,33 +110,14 @@
110110 /*
111111 * Flags in backing_dev_info::capability
112112 *
113
- * The first three flags control whether dirty pages will contribute to the
114
- * VM's accounting and whether writepages() should be called for dirty pages
115
- * (something that would not, for example, be appropriate for ramfs)
116
- *
117
- * WARNING: these flags are closely related and should not normally be
118
- * used separately. The BDI_CAP_NO_ACCT_AND_WRITEBACK combines these
119
- * three flags into a single convenience macro.
120
- *
121
- * BDI_CAP_NO_ACCT_DIRTY: Dirty pages shouldn't contribute to accounting
122
- * BDI_CAP_NO_WRITEBACK: Don't write pages back
123
- * BDI_CAP_NO_ACCT_WB: Don't automatically account writeback pages
124
- * BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold.
125
- *
126
- * BDI_CAP_CGROUP_WRITEBACK: Supports cgroup-aware writeback.
127
- * BDI_CAP_SYNCHRONOUS_IO: Device is so fast that asynchronous IO would be
128
- * inefficient.
113
+ * BDI_CAP_WRITEBACK: Supports dirty page writeback, and dirty pages
114
+ * should contribute to accounting
115
+ * BDI_CAP_WRITEBACK_ACCT: Automatically account writeback pages
116
+ * BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold
129117 */
130
-#define BDI_CAP_NO_ACCT_DIRTY 0x00000001
131
-#define BDI_CAP_NO_WRITEBACK 0x00000002
132
-#define BDI_CAP_NO_ACCT_WB 0x00000004
133
-#define BDI_CAP_STABLE_WRITES 0x00000008
134
-#define BDI_CAP_STRICTLIMIT 0x00000010
135
-#define BDI_CAP_CGROUP_WRITEBACK 0x00000020
136
-#define BDI_CAP_SYNCHRONOUS_IO 0x00000040
137
-
138
-#define BDI_CAP_NO_ACCT_AND_WRITEBACK \
139
- (BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB)
118
+#define BDI_CAP_WRITEBACK (1 << 0)
119
+#define BDI_CAP_WRITEBACK_ACCT (1 << 1)
120
+#define BDI_CAP_STRICTLIMIT (1 << 2)
140121
141122 extern struct backing_dev_info noop_backing_dev_info;
142123
....@@ -169,51 +150,15 @@
169150
170151 static inline int wb_congested(struct bdi_writeback *wb, int cong_bits)
171152 {
172
- struct backing_dev_info *bdi = wb->bdi;
173
-
174
- if (bdi->congested_fn)
175
- return bdi->congested_fn(bdi->congested_data, cong_bits);
176
- return wb->congested->state & cong_bits;
153
+ return wb->congested & cong_bits;
177154 }
178155
179156 long congestion_wait(int sync, long timeout);
180157 long wait_iff_congested(int sync, long timeout);
181158
182
-static inline bool bdi_cap_synchronous_io(struct backing_dev_info *bdi)
159
+static inline bool mapping_can_writeback(struct address_space *mapping)
183160 {
184
- return bdi->capabilities & BDI_CAP_SYNCHRONOUS_IO;
185
-}
186
-
187
-static inline bool bdi_cap_stable_pages_required(struct backing_dev_info *bdi)
188
-{
189
- return bdi->capabilities & BDI_CAP_STABLE_WRITES;
190
-}
191
-
192
-static inline bool bdi_cap_writeback_dirty(struct backing_dev_info *bdi)
193
-{
194
- return !(bdi->capabilities & BDI_CAP_NO_WRITEBACK);
195
-}
196
-
197
-static inline bool bdi_cap_account_dirty(struct backing_dev_info *bdi)
198
-{
199
- return !(bdi->capabilities & BDI_CAP_NO_ACCT_DIRTY);
200
-}
201
-
202
-static inline bool bdi_cap_account_writeback(struct backing_dev_info *bdi)
203
-{
204
- /* Paranoia: BDI_CAP_NO_WRITEBACK implies BDI_CAP_NO_ACCT_WB */
205
- return !(bdi->capabilities & (BDI_CAP_NO_ACCT_WB |
206
- BDI_CAP_NO_WRITEBACK));
207
-}
208
-
209
-static inline bool mapping_cap_writeback_dirty(struct address_space *mapping)
210
-{
211
- return bdi_cap_writeback_dirty(inode_to_bdi(mapping->host));
212
-}
213
-
214
-static inline bool mapping_cap_account_dirty(struct address_space *mapping)
215
-{
216
- return bdi_cap_account_dirty(inode_to_bdi(mapping->host));
161
+ return inode_to_bdi(mapping->host)->capabilities & BDI_CAP_WRITEBACK;
217162 }
218163
219164 static inline int bdi_sched_wait(void *word)
....@@ -224,9 +169,8 @@
224169
225170 #ifdef CONFIG_CGROUP_WRITEBACK
226171
227
-struct bdi_writeback_congested *
228
-wb_congested_get_create(struct backing_dev_info *bdi, int blkcg_id, gfp_t gfp);
229
-void wb_congested_put(struct bdi_writeback_congested *congested);
172
+struct bdi_writeback *wb_get_lookup(struct backing_dev_info *bdi,
173
+ struct cgroup_subsys_state *memcg_css);
230174 struct bdi_writeback *wb_get_create(struct backing_dev_info *bdi,
231175 struct cgroup_subsys_state *memcg_css,
232176 gfp_t gfp);
....@@ -238,9 +182,9 @@
238182 * inode_cgwb_enabled - test whether cgroup writeback is enabled on an inode
239183 * @inode: inode of interest
240184 *
241
- * cgroup writeback requires support from both the bdi and filesystem.
242
- * Also, both memcg and iocg have to be on the default hierarchy. Test
243
- * whether all conditions are met.
185
+ * Cgroup writeback requires support from the filesystem. Also, both memcg and
186
+ * iocg have to be on the default hierarchy. Test whether all conditions are
187
+ * met.
244188 *
245189 * Note that the test result may change dynamically on the same inode
246190 * depending on how memcg and iocg are configured.
....@@ -251,8 +195,7 @@
251195
252196 return cgroup_subsys_on_dfl(memory_cgrp_subsys) &&
253197 cgroup_subsys_on_dfl(io_cgrp_subsys) &&
254
- bdi_cap_account_dirty(bdi) &&
255
- (bdi->capabilities & BDI_CAP_CGROUP_WRITEBACK) &&
198
+ (bdi->capabilities & BDI_CAP_WRITEBACK) &&
256199 (inode->i_sb->s_iflags & SB_I_CGROUPWB);
257200 }
258201
....@@ -366,7 +309,7 @@
366309 rcu_read_lock();
367310
368311 /*
369
- * Paired with store_release in inode_switch_wb_work_fn() and
312
+ * Paired with store_release in inode_switch_wbs_work_fn() and
370313 * ensures that we see the new wb if we see cleared I_WB_SWITCH.
371314 */
372315 cookie->locked = smp_load_acquire(&inode->i_state) & I_WB_SWITCH;
....@@ -400,19 +343,6 @@
400343 static inline bool inode_cgwb_enabled(struct inode *inode)
401344 {
402345 return false;
403
-}
404
-
405
-static inline struct bdi_writeback_congested *
406
-wb_congested_get_create(struct backing_dev_info *bdi, int blkcg_id, gfp_t gfp)
407
-{
408
- refcount_inc(&bdi->wb_congested->refcnt);
409
- return bdi->wb_congested;
410
-}
411
-
412
-static inline void wb_congested_put(struct bdi_writeback_congested *congested)
413
-{
414
- if (refcount_dec_and_test(&congested->refcnt))
415
- kfree(congested);
416346 }
417347
418348 static inline struct bdi_writeback *wb_find_current(struct backing_dev_info *bdi)