Blame view

include/linux/backing-dev.h 11.3 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
7
8
9
10
  /*
   * include/linux/backing-dev.h
   *
   * low-level device information and state which is propagated up through
   * to high-level code.
   */
  
  #ifndef _LINUX_BACKING_DEV_H
  #define _LINUX_BACKING_DEV_H
cf0ca9fe5   Peter Zijlstra   mm: bdi: export B...
11
  #include <linux/kernel.h>
e4ad08fe6   Miklos Szeredi   mm: bdi: add sepa...
12
  #include <linux/fs.h>
03ba3782e   Jens Axboe   writeback: switch...
13
  #include <linux/sched.h>
a212b105b   Tejun Heo   bdi: make inode_t...
14
  #include <linux/blkdev.h>
68f23b890   Theodore Ts'o   memcg: fix a cras...
15
  #include <linux/device.h>
03ba3782e   Jens Axboe   writeback: switch...
16
  #include <linux/writeback.h>
52ebea749   Tejun Heo   writeback: make b...
17
  #include <linux/blk-cgroup.h>
66114cad6   Tejun Heo   writeback: separa...
18
  #include <linux/backing-dev-defs.h>
a13f35e87   Tejun Heo   writeback: don't ...
19
  #include <linux/slab.h>
de1414a65   Christoph Hellwig   fs: export inode_...
20

d03f6cdc1   Jan Kara   block: Dynamicall...
21
22
23
24
25
  static inline struct backing_dev_info *bdi_get(struct backing_dev_info *bdi)
  {
  	kref_get(&bdi->refcnt);
  	return bdi;
  }
34f8fe501   Tejun Heo   bdi: Add bdi->id
26
  struct backing_dev_info *bdi_get_by_id(u64 id);
d03f6cdc1   Jan Kara   block: Dynamicall...
27
  void bdi_put(struct backing_dev_info *bdi);
b2e8fb6ef   Peter Zijlstra   mm: scalable bdi ...
28

7c4cc3002   Jan Kara   bdi: Drop 'parent...
29
30
  __printf(2, 3)
  int bdi_register(struct backing_dev_info *bdi, const char *fmt, ...);
a93f00b37   Mathieu Malaterre   backing: silence ...
31
  __printf(2, 0)
7c4cc3002   Jan Kara   bdi: Drop 'parent...
32
33
  int bdi_register_va(struct backing_dev_info *bdi, const char *fmt,
  		    va_list args);
3c5d202b5   Christoph Hellwig   bdi: remove bdi_r...
34
  void bdi_set_owner(struct backing_dev_info *bdi, struct device *owner);
b02176f30   Tejun Heo   block: don't rele...
35
  void bdi_unregister(struct backing_dev_info *bdi);
aef33c2ff   Christoph Hellwig   bdi: simplify bdi...
36
  struct backing_dev_info *bdi_alloc(int node_id);
b02176f30   Tejun Heo   block: don't rele...
37

9ecf4866c   Tejun Heo   writeback: make b...
38
  void wb_start_background_writeback(struct bdi_writeback *wb);
f0054bb1e   Tejun Heo   writeback: move b...
39
  void wb_workfn(struct work_struct *work);
f0054bb1e   Tejun Heo   writeback: move b...
40
  void wb_wakeup_delayed(struct bdi_writeback *wb);
cf0ca9fe5   Peter Zijlstra   mm: bdi: export B...
41

5b9cce4c7   Tejun Heo   writeback: Genera...
42
  void wb_wait_for_completion(struct wb_completion *done);
03ba3782e   Jens Axboe   writeback: switch...
43
  extern spinlock_t bdi_lock;
66f3b8e2e   Jens Axboe   writeback: move d...
44
  extern struct list_head bdi_list;
839a8e866   Tejun Heo   writeback: replac...
45
  extern struct workqueue_struct *bdi_wq;
d3f77dfdc   Tejun Heo   blkcg: implement ...
46
  extern struct workqueue_struct *bdi_async_bio_wq;
839a8e866   Tejun Heo   writeback: replac...
47

d6c10f1fc   Tejun Heo   writeback: implem...
48
  static inline bool wb_has_dirty_io(struct bdi_writeback *wb)
03ba3782e   Jens Axboe   writeback: switch...
49
  {
d6c10f1fc   Tejun Heo   writeback: implem...
50
  	return test_bit(WB_has_dirty_io, &wb->state);
03ba3782e   Jens Axboe   writeback: switch...
51
  }
95a46c65e   Tejun Heo   writeback: make b...
52
53
54
55
56
57
58
  static inline bool bdi_has_dirty_io(struct backing_dev_info *bdi)
  {
  	/*
  	 * @bdi->tot_write_bandwidth is guaranteed to be > 0 if there are
  	 * any dirty wbs.  See wb_update_write_bandwidth().
  	 */
  	return atomic_long_read(&bdi->tot_write_bandwidth);
03ba3782e   Jens Axboe   writeback: switch...
59
  }
93f78d882   Tejun Heo   writeback: move b...
60
61
  static inline void __add_wb_stat(struct bdi_writeback *wb,
  				 enum wb_stat_item item, s64 amount)
b2e8fb6ef   Peter Zijlstra   mm: scalable bdi ...
62
  {
104b4e513   Nikolay Borisov   percpu_counter: R...
63
  	percpu_counter_add_batch(&wb->stat[item], amount, WB_STAT_BATCH);
b2e8fb6ef   Peter Zijlstra   mm: scalable bdi ...
64
  }
93f78d882   Tejun Heo   writeback: move b...
65
  static inline void inc_wb_stat(struct bdi_writeback *wb, enum wb_stat_item item)
b2e8fb6ef   Peter Zijlstra   mm: scalable bdi ...
66
  {
3e8f399da   Nikolay Borisov   writeback: rework...
67
  	__add_wb_stat(wb, item, 1);
b2e8fb6ef   Peter Zijlstra   mm: scalable bdi ...
68
  }
93f78d882   Tejun Heo   writeback: move b...
69
  static inline void dec_wb_stat(struct bdi_writeback *wb, enum wb_stat_item item)
b2e8fb6ef   Peter Zijlstra   mm: scalable bdi ...
70
  {
3e8f399da   Nikolay Borisov   writeback: rework...
71
  	__add_wb_stat(wb, item, -1);
b2e8fb6ef   Peter Zijlstra   mm: scalable bdi ...
72
  }
93f78d882   Tejun Heo   writeback: move b...
73
  static inline s64 wb_stat(struct bdi_writeback *wb, enum wb_stat_item item)
b2e8fb6ef   Peter Zijlstra   mm: scalable bdi ...
74
  {
93f78d882   Tejun Heo   writeback: move b...
75
  	return percpu_counter_read_positive(&wb->stat[item]);
b2e8fb6ef   Peter Zijlstra   mm: scalable bdi ...
76
  }
93f78d882   Tejun Heo   writeback: move b...
77
  static inline s64 wb_stat_sum(struct bdi_writeback *wb, enum wb_stat_item item)
e0bf68dde   Peter Zijlstra   mm: bdi init hooks
78
  {
e3d3910a5   Nikolay Borisov   include/linux/bac...
79
  	return percpu_counter_sum_positive(&wb->stat[item]);
e0bf68dde   Peter Zijlstra   mm: bdi init hooks
80
  }
93f78d882   Tejun Heo   writeback: move b...
81
  extern void wb_writeout_inc(struct bdi_writeback *wb);
dd5656e59   Miklos Szeredi   mm: bdi: export b...
82

b2e8fb6ef   Peter Zijlstra   mm: scalable bdi ...
83
84
85
  /*
   * maximal error of a stat counter.
   */
2bce774e8   Wang Long   writeback: remove...
86
  static inline unsigned long wb_stat_error(void)
e0bf68dde   Peter Zijlstra   mm: bdi init hooks
87
  {
b2e8fb6ef   Peter Zijlstra   mm: scalable bdi ...
88
  #ifdef CONFIG_SMP
93f78d882   Tejun Heo   writeback: move b...
89
  	return nr_cpu_ids * WB_STAT_BATCH;
b2e8fb6ef   Peter Zijlstra   mm: scalable bdi ...
90
91
92
  #else
  	return 1;
  #endif
e0bf68dde   Peter Zijlstra   mm: bdi init hooks
93
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
94

189d3c4a9   Peter Zijlstra   mm: bdi: allow se...
95
  int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio);
a42dde041   Peter Zijlstra   mm: bdi: allow se...
96
  int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
189d3c4a9   Peter Zijlstra   mm: bdi: allow se...
97

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
98
99
  /*
   * Flags in backing_dev_info::capability
e4ad08fe6   Miklos Szeredi   mm: bdi: add sepa...
100
   *
f56753ac2   Christoph Hellwig   bdi: replace BDI_...
101
102
103
104
   * BDI_CAP_WRITEBACK:		Supports dirty page writeback, and dirty pages
   *				should contribute to accounting
   * BDI_CAP_WRITEBACK_ACCT:	Automatically account writeback pages
   * BDI_CAP_STRICTLIMIT:		Keep number of dirty pages below bdi threshold
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
105
   */
f56753ac2   Christoph Hellwig   bdi: replace BDI_...
106
107
108
  #define BDI_CAP_WRITEBACK		(1 << 0)
  #define BDI_CAP_WRITEBACK_ACCT		(1 << 1)
  #define BDI_CAP_STRICTLIMIT		(1 << 2)
e4ad08fe6   Miklos Szeredi   mm: bdi: add sepa...
109

5129a469a   Jörn Engel   Catch filesystems...
110
  extern struct backing_dev_info noop_backing_dev_info;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
111

bc05873dc   Tejun Heo   writeback: make w...
112
113
114
115
116
117
118
119
  /**
   * writeback_in_progress - determine whether there is writeback in progress
   * @wb: bdi_writeback of interest
   *
   * Determine whether there is writeback waiting to be handled against a
   * bdi_writeback.
   */
  static inline bool writeback_in_progress(struct bdi_writeback *wb)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
120
  {
bc05873dc   Tejun Heo   writeback: make w...
121
  	return test_bit(WB_writeback_running, &wb->state);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
122
  }
a212b105b   Tejun Heo   bdi: make inode_t...
123
  static inline struct backing_dev_info *inode_to_bdi(struct inode *inode)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124
  {
a212b105b   Tejun Heo   bdi: make inode_t...
125
  	struct super_block *sb;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
126

a212b105b   Tejun Heo   bdi: make inode_t...
127
128
129
130
131
132
  	if (!inode)
  		return &noop_backing_dev_info;
  
  	sb = inode->i_sb;
  #ifdef CONFIG_BLOCK
  	if (sb_is_blkdev_sb(sb))
efa7c9f97   Jan Kara   block: Get rid of...
133
  		return I_BDEV(inode)->bd_bdi;
a212b105b   Tejun Heo   bdi: make inode_t...
134
135
  #endif
  	return sb->s_bdi;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
136
  }
ec8a6f264   Tejun Heo   writeback: make c...
137
  static inline int wb_congested(struct bdi_writeback *wb, int cong_bits)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
138
  {
8c911f3d4   Christoph Hellwig   writeback: remove...
139
  	return wb->congested & cong_bits;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
140
  }
373c0a7ed   Trond Myklebust   Fix compile error...
141

8aa7e847d   Jens Axboe   Fix congestion_wa...
142
  long congestion_wait(int sync, long timeout);
e3c1ac586   Andrey Ryabinin   mm/vmscan: don't ...
143
  long wait_iff_congested(int sync, long timeout);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
144

f56753ac2   Christoph Hellwig   bdi: replace BDI_...
145
  static inline bool mapping_can_writeback(struct address_space *mapping)
e4ad08fe6   Miklos Szeredi   mm: bdi: add sepa...
146
  {
f56753ac2   Christoph Hellwig   bdi: replace BDI_...
147
  	return inode_to_bdi(mapping->host)->capabilities & BDI_CAP_WRITEBACK;
e4ad08fe6   Miklos Szeredi   mm: bdi: add sepa...
148
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
149

03ba3782e   Jens Axboe   writeback: switch...
150
151
152
153
154
  static inline int bdi_sched_wait(void *word)
  {
  	schedule();
  	return 0;
  }
89e9b9e07   Tejun Heo   writeback: add {C...
155
  #ifdef CONFIG_CGROUP_WRITEBACK
ed288dc0d   Tejun Heo   writeback: Separa...
156
157
  struct bdi_writeback *wb_get_lookup(struct backing_dev_info *bdi,
  				    struct cgroup_subsys_state *memcg_css);
52ebea749   Tejun Heo   writeback: make b...
158
159
160
  struct bdi_writeback *wb_get_create(struct backing_dev_info *bdi,
  				    struct cgroup_subsys_state *memcg_css,
  				    gfp_t gfp);
52ebea749   Tejun Heo   writeback: make b...
161
162
  void wb_memcg_offline(struct mem_cgroup *memcg);
  void wb_blkcg_offline(struct blkcg *blkcg);
703c27088   Tejun Heo   writeback: implem...
163
  int inode_congested(struct inode *inode, int cong_bits);
52ebea749   Tejun Heo   writeback: make b...
164

89e9b9e07   Tejun Heo   writeback: add {C...
165
166
167
168
  /**
   * inode_cgwb_enabled - test whether cgroup writeback is enabled on an inode
   * @inode: inode of interest
   *
ed7b6b4f6   Christoph Hellwig   bdi: remove BDI_C...
169
170
171
   * Cgroup writeback requires support from the filesystem.  Also, both memcg and
   * iocg have to be on the default hierarchy.  Test whether all conditions are
   * met.
9badce000   Tejun Heo   cgroup, writeback...
172
173
174
   *
   * Note that the test result may change dynamically on the same inode
   * depending on how memcg and iocg are configured.
89e9b9e07   Tejun Heo   writeback: add {C...
175
176
177
178
   */
  static inline bool inode_cgwb_enabled(struct inode *inode)
  {
  	struct backing_dev_info *bdi = inode_to_bdi(inode);
c0522908d   Tejun Heo   cgroup: Merge bra...
179
180
  	return cgroup_subsys_on_dfl(memory_cgrp_subsys) &&
  		cgroup_subsys_on_dfl(io_cgrp_subsys) &&
f56753ac2   Christoph Hellwig   bdi: replace BDI_...
181
  		(bdi->capabilities & BDI_CAP_WRITEBACK) &&
46b15caa7   Tejun Heo   vfs, writeback: r...
182
  		(inode->i_sb->s_iflags & SB_I_CGROUPWB);
89e9b9e07   Tejun Heo   writeback: add {C...
183
  }
52ebea749   Tejun Heo   writeback: make b...
184
  /**
52ebea749   Tejun Heo   writeback: make b...
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
   * wb_find_current - find wb for %current on a bdi
   * @bdi: bdi of interest
   *
   * Find the wb of @bdi which matches both the memcg and blkcg of %current.
   * Must be called under rcu_read_lock() which protects the returend wb.
   * NULL if not found.
   */
  static inline struct bdi_writeback *wb_find_current(struct backing_dev_info *bdi)
  {
  	struct cgroup_subsys_state *memcg_css;
  	struct bdi_writeback *wb;
  
  	memcg_css = task_css(current, memory_cgrp_id);
  	if (!memcg_css->parent)
  		return &bdi->wb;
  
  	wb = radix_tree_lookup(&bdi->cgwb_tree, memcg_css->id);
  
  	/*
  	 * %current's blkcg equals the effective blkcg of its memcg.  No
  	 * need to use the relatively expensive cgroup_get_e_css().
  	 */
c165b3e3c   Tejun Heo   blkcg: rename sub...
207
  	if (likely(wb && wb->blkcg_css == task_css(current, io_cgrp_id)))
52ebea749   Tejun Heo   writeback: make b...
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
  		return wb;
  	return NULL;
  }
  
  /**
   * wb_get_create_current - get or create wb for %current on a bdi
   * @bdi: bdi of interest
   * @gfp: allocation mask
   *
   * Equivalent to wb_get_create() on %current's memcg.  This function is
   * called from a relatively hot path and optimizes the common cases using
   * wb_find_current().
   */
  static inline struct bdi_writeback *
  wb_get_create_current(struct backing_dev_info *bdi, gfp_t gfp)
  {
  	struct bdi_writeback *wb;
  
  	rcu_read_lock();
  	wb = wb_find_current(bdi);
  	if (wb && unlikely(!wb_tryget(wb)))
  		wb = NULL;
  	rcu_read_unlock();
  
  	if (unlikely(!wb)) {
  		struct cgroup_subsys_state *memcg_css;
  
  		memcg_css = task_get_css(current, memory_cgrp_id);
  		wb = wb_get_create(bdi, memcg_css, gfp);
  		css_put(memcg_css);
  	}
  	return wb;
  }
  
  /**
aaa2cacf8   Tejun Heo   writeback: add lo...
243
244
245
246
247
248
249
250
251
252
253
254
   * inode_to_wb_is_valid - test whether an inode has a wb associated
   * @inode: inode of interest
   *
   * Returns %true if @inode has a wb associated.  May be called without any
   * locking.
   */
  static inline bool inode_to_wb_is_valid(struct inode *inode)
  {
  	return inode->i_wb;
  }
  
  /**
52ebea749   Tejun Heo   writeback: make b...
255
256
257
   * inode_to_wb - determine the wb of an inode
   * @inode: inode of interest
   *
aaa2cacf8   Tejun Heo   writeback: add lo...
258
   * Returns the wb @inode is currently associated with.  The caller must be
b93b01631   Matthew Wilcox   page cache: use x...
259
   * holding either @inode->i_lock, the i_pages lock, or the
aaa2cacf8   Tejun Heo   writeback: add lo...
260
   * associated wb's list_lock.
52ebea749   Tejun Heo   writeback: make b...
261
   */
05b93801a   Matthew Wilcox   lockdep: Convert ...
262
  static inline struct bdi_writeback *inode_to_wb(const struct inode *inode)
52ebea749   Tejun Heo   writeback: make b...
263
  {
aaa2cacf8   Tejun Heo   writeback: add lo...
264
265
266
  #ifdef CONFIG_LOCKDEP
  	WARN_ON_ONCE(debug_locks &&
  		     (!lockdep_is_held(&inode->i_lock) &&
b93b01631   Matthew Wilcox   page cache: use x...
267
  		      !lockdep_is_held(&inode->i_mapping->i_pages.xa_lock) &&
aaa2cacf8   Tejun Heo   writeback: add lo...
268
269
  		      !lockdep_is_held(&inode->i_wb->list_lock)));
  #endif
52ebea749   Tejun Heo   writeback: make b...
270
271
  	return inode->i_wb;
  }
682aa8e1a   Tejun Heo   writeback: implem...
272
273
274
  /**
   * unlocked_inode_to_wb_begin - begin unlocked inode wb access transaction
   * @inode: target inode
2e898e4c0   Greg Thelen   writeback: safer ...
275
   * @cookie: output param, to be passed to the end function
682aa8e1a   Tejun Heo   writeback: implem...
276
277
   *
   * The caller wants to access the wb associated with @inode but isn't
b93b01631   Matthew Wilcox   page cache: use x...
278
   * holding inode->i_lock, the i_pages lock or wb->list_lock.  This
682aa8e1a   Tejun Heo   writeback: implem...
279
280
281
282
   * function determines the wb associated with @inode and ensures that the
   * association doesn't change until the transaction is finished with
   * unlocked_inode_to_wb_end().
   *
2e898e4c0   Greg Thelen   writeback: safer ...
283
284
285
   * The caller must call unlocked_inode_to_wb_end() with *@cookie afterwards and
   * can't sleep during the transaction.  IRQs may or may not be disabled on
   * return.
682aa8e1a   Tejun Heo   writeback: implem...
286
287
   */
  static inline struct bdi_writeback *
2e898e4c0   Greg Thelen   writeback: safer ...
288
  unlocked_inode_to_wb_begin(struct inode *inode, struct wb_lock_cookie *cookie)
682aa8e1a   Tejun Heo   writeback: implem...
289
290
291
292
  {
  	rcu_read_lock();
  
  	/*
a9519defc   Greg Thelen   writeback: fix in...
293
  	 * Paired with store_release in inode_switch_wbs_work_fn() and
682aa8e1a   Tejun Heo   writeback: implem...
294
295
  	 * ensures that we see the new wb if we see cleared I_WB_SWITCH.
  	 */
2e898e4c0   Greg Thelen   writeback: safer ...
296
  	cookie->locked = smp_load_acquire(&inode->i_state) & I_WB_SWITCH;
682aa8e1a   Tejun Heo   writeback: implem...
297

2e898e4c0   Greg Thelen   writeback: safer ...
298
299
  	if (unlikely(cookie->locked))
  		xa_lock_irqsave(&inode->i_mapping->i_pages, cookie->flags);
aaa2cacf8   Tejun Heo   writeback: add lo...
300
301
  
  	/*
b93b01631   Matthew Wilcox   page cache: use x...
302
303
  	 * Protected by either !I_WB_SWITCH + rcu_read_lock() or the i_pages
  	 * lock.  inode_to_wb() will bark.  Deref directly.
aaa2cacf8   Tejun Heo   writeback: add lo...
304
305
  	 */
  	return inode->i_wb;
682aa8e1a   Tejun Heo   writeback: implem...
306
307
308
309
310
  }
  
  /**
   * unlocked_inode_to_wb_end - end inode wb access transaction
   * @inode: target inode
2e898e4c0   Greg Thelen   writeback: safer ...
311
   * @cookie: @cookie from unlocked_inode_to_wb_begin()
682aa8e1a   Tejun Heo   writeback: implem...
312
   */
2e898e4c0   Greg Thelen   writeback: safer ...
313
314
  static inline void unlocked_inode_to_wb_end(struct inode *inode,
  					    struct wb_lock_cookie *cookie)
682aa8e1a   Tejun Heo   writeback: implem...
315
  {
2e898e4c0   Greg Thelen   writeback: safer ...
316
317
  	if (unlikely(cookie->locked))
  		xa_unlock_irqrestore(&inode->i_mapping->i_pages, cookie->flags);
682aa8e1a   Tejun Heo   writeback: implem...
318
319
320
  
  	rcu_read_unlock();
  }
89e9b9e07   Tejun Heo   writeback: add {C...
321
322
323
324
325
326
  #else	/* CONFIG_CGROUP_WRITEBACK */
  
  static inline bool inode_cgwb_enabled(struct inode *inode)
  {
  	return false;
  }
52ebea749   Tejun Heo   writeback: make b...
327
328
329
330
331
332
333
334
335
336
  static inline struct bdi_writeback *wb_find_current(struct backing_dev_info *bdi)
  {
  	return &bdi->wb;
  }
  
  static inline struct bdi_writeback *
  wb_get_create_current(struct backing_dev_info *bdi, gfp_t gfp)
  {
  	return &bdi->wb;
  }
aaa2cacf8   Tejun Heo   writeback: add lo...
337
338
339
340
  static inline bool inode_to_wb_is_valid(struct inode *inode)
  {
  	return true;
  }
52ebea749   Tejun Heo   writeback: make b...
341
342
343
344
  static inline struct bdi_writeback *inode_to_wb(struct inode *inode)
  {
  	return &inode_to_bdi(inode)->wb;
  }
682aa8e1a   Tejun Heo   writeback: implem...
345
  static inline struct bdi_writeback *
2e898e4c0   Greg Thelen   writeback: safer ...
346
  unlocked_inode_to_wb_begin(struct inode *inode, struct wb_lock_cookie *cookie)
682aa8e1a   Tejun Heo   writeback: implem...
347
348
349
  {
  	return inode_to_wb(inode);
  }
2e898e4c0   Greg Thelen   writeback: safer ...
350
351
  static inline void unlocked_inode_to_wb_end(struct inode *inode,
  					    struct wb_lock_cookie *cookie)
682aa8e1a   Tejun Heo   writeback: implem...
352
353
  {
  }
52ebea749   Tejun Heo   writeback: make b...
354
355
356
357
358
359
360
  static inline void wb_memcg_offline(struct mem_cgroup *memcg)
  {
  }
  
  static inline void wb_blkcg_offline(struct blkcg *blkcg)
  {
  }
703c27088   Tejun Heo   writeback: implem...
361
362
363
364
  static inline int inode_congested(struct inode *inode, int cong_bits)
  {
  	return wb_congested(&inode_to_bdi(inode)->wb, cong_bits);
  }
89e9b9e07   Tejun Heo   writeback: add {C...
365
  #endif	/* CONFIG_CGROUP_WRITEBACK */
703c27088   Tejun Heo   writeback: implem...
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
  static inline int inode_read_congested(struct inode *inode)
  {
  	return inode_congested(inode, 1 << WB_sync_congested);
  }
  
  static inline int inode_write_congested(struct inode *inode)
  {
  	return inode_congested(inode, 1 << WB_async_congested);
  }
  
  static inline int inode_rw_congested(struct inode *inode)
  {
  	return inode_congested(inode, (1 << WB_sync_congested) |
  				      (1 << WB_async_congested));
  }
ec8a6f264   Tejun Heo   writeback: make c...
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
  static inline int bdi_congested(struct backing_dev_info *bdi, int cong_bits)
  {
  	return wb_congested(&bdi->wb, cong_bits);
  }
  
  static inline int bdi_read_congested(struct backing_dev_info *bdi)
  {
  	return bdi_congested(bdi, 1 << WB_sync_congested);
  }
  
  static inline int bdi_write_congested(struct backing_dev_info *bdi)
  {
  	return bdi_congested(bdi, 1 << WB_async_congested);
  }
  
  static inline int bdi_rw_congested(struct backing_dev_info *bdi)
  {
  	return bdi_congested(bdi, (1 << WB_sync_congested) |
  				  (1 << WB_async_congested));
  }
eb7ae5e06   Christoph Hellwig   bdi: move bdi_dev...
401
  const char *bdi_dev_name(struct backing_dev_info *bdi);
68f23b890   Theodore Ts'o   memcg: fix a cras...
402

89e9b9e07   Tejun Heo   writeback: add {C...
403
  #endif	/* _LINUX_BACKING_DEV_H */