.. | .. |
---|
25 | 25 | return bdi; |
---|
26 | 26 | } |
---|
27 | 27 | |
---|
| 28 | +struct backing_dev_info *bdi_get_by_id(u64 id); |
---|
28 | 29 | void bdi_put(struct backing_dev_info *bdi); |
---|
29 | 30 | |
---|
30 | 31 | __printf(2, 3) |
---|
.. | .. |
---|
32 | 33 | __printf(2, 0) |
---|
33 | 34 | int bdi_register_va(struct backing_dev_info *bdi, const char *fmt, |
---|
34 | 35 | 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); |
---|
36 | 37 | void bdi_unregister(struct backing_dev_info *bdi); |
---|
37 | 38 | |
---|
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); |
---|
43 | 40 | |
---|
44 | 41 | void wb_start_background_writeback(struct bdi_writeback *wb); |
---|
45 | 42 | void wb_workfn(struct work_struct *work); |
---|
46 | 43 | void wb_wakeup_delayed(struct bdi_writeback *wb); |
---|
47 | 44 | |
---|
| 45 | +void wb_wait_for_completion(struct wb_completion *done); |
---|
| 46 | + |
---|
48 | 47 | extern spinlock_t bdi_lock; |
---|
49 | 48 | extern struct list_head bdi_list; |
---|
50 | 49 | |
---|
51 | 50 | extern struct workqueue_struct *bdi_wq; |
---|
| 51 | +extern struct workqueue_struct *bdi_async_bio_wq; |
---|
52 | 52 | |
---|
53 | 53 | static inline bool wb_has_dirty_io(struct bdi_writeback *wb) |
---|
54 | 54 | { |
---|
.. | .. |
---|
110 | 110 | /* |
---|
111 | 111 | * Flags in backing_dev_info::capability |
---|
112 | 112 | * |
---|
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 |
---|
129 | 117 | */ |
---|
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) |
---|
140 | 121 | |
---|
141 | 122 | extern struct backing_dev_info noop_backing_dev_info; |
---|
142 | 123 | |
---|
.. | .. |
---|
169 | 150 | |
---|
170 | 151 | static inline int wb_congested(struct bdi_writeback *wb, int cong_bits) |
---|
171 | 152 | { |
---|
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; |
---|
177 | 154 | } |
---|
178 | 155 | |
---|
179 | 156 | long congestion_wait(int sync, long timeout); |
---|
180 | 157 | long wait_iff_congested(int sync, long timeout); |
---|
181 | 158 | |
---|
182 | | -static inline bool bdi_cap_synchronous_io(struct backing_dev_info *bdi) |
---|
| 159 | +static inline bool mapping_can_writeback(struct address_space *mapping) |
---|
183 | 160 | { |
---|
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; |
---|
217 | 162 | } |
---|
218 | 163 | |
---|
219 | 164 | static inline int bdi_sched_wait(void *word) |
---|
.. | .. |
---|
224 | 169 | |
---|
225 | 170 | #ifdef CONFIG_CGROUP_WRITEBACK |
---|
226 | 171 | |
---|
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); |
---|
230 | 174 | struct bdi_writeback *wb_get_create(struct backing_dev_info *bdi, |
---|
231 | 175 | struct cgroup_subsys_state *memcg_css, |
---|
232 | 176 | gfp_t gfp); |
---|
.. | .. |
---|
238 | 182 | * inode_cgwb_enabled - test whether cgroup writeback is enabled on an inode |
---|
239 | 183 | * @inode: inode of interest |
---|
240 | 184 | * |
---|
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. |
---|
244 | 188 | * |
---|
245 | 189 | * Note that the test result may change dynamically on the same inode |
---|
246 | 190 | * depending on how memcg and iocg are configured. |
---|
.. | .. |
---|
251 | 195 | |
---|
252 | 196 | return cgroup_subsys_on_dfl(memory_cgrp_subsys) && |
---|
253 | 197 | 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) && |
---|
256 | 199 | (inode->i_sb->s_iflags & SB_I_CGROUPWB); |
---|
257 | 200 | } |
---|
258 | 201 | |
---|
.. | .. |
---|
366 | 309 | rcu_read_lock(); |
---|
367 | 310 | |
---|
368 | 311 | /* |
---|
369 | | - * Paired with store_release in inode_switch_wb_work_fn() and |
---|
| 312 | + * Paired with store_release in inode_switch_wbs_work_fn() and |
---|
370 | 313 | * ensures that we see the new wb if we see cleared I_WB_SWITCH. |
---|
371 | 314 | */ |
---|
372 | 315 | cookie->locked = smp_load_acquire(&inode->i_state) & I_WB_SWITCH; |
---|
.. | .. |
---|
400 | 343 | static inline bool inode_cgwb_enabled(struct inode *inode) |
---|
401 | 344 | { |
---|
402 | 345 | 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); |
---|
416 | 346 | } |
---|
417 | 347 | |
---|
418 | 348 | static inline struct bdi_writeback *wb_find_current(struct backing_dev_info *bdi) |
---|