hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/writeback.h
....@@ -11,6 +11,7 @@
1111 #include <linux/flex_proportions.h>
1212 #include <linux/backing-dev-defs.h>
1313 #include <linux/blk_types.h>
14
+#include <linux/blk-cgroup.h>
1415
1516 struct bio;
1617
....@@ -68,6 +69,17 @@
6869 unsigned for_reclaim:1; /* Invoked from the page allocator */
6970 unsigned range_cyclic:1; /* range_start is cyclic */
7071 unsigned for_sync:1; /* sync(2) WB_SYNC_ALL writeback */
72
+
73
+ /*
74
+ * When writeback IOs are bounced through async layers, only the
75
+ * initial synchronous phase should be accounted towards inode
76
+ * cgroup ownership arbitration to avoid confusion. Later stages
77
+ * can set the following flag to disable the accounting.
78
+ */
79
+ unsigned no_cgroup_owner:1;
80
+
81
+ unsigned punt_to_cgroup:1; /* cgrp punting, see __REQ_CGROUP_PUNT */
82
+
7183 #ifdef CONFIG_CGROUP_WRITEBACK
7284 struct bdi_writeback *wb; /* wb this writeback is issued under */
7385 struct inode *inode; /* inode being written out */
....@@ -84,12 +96,27 @@
8496
8597 static inline int wbc_to_write_flags(struct writeback_control *wbc)
8698 {
87
- if (wbc->sync_mode == WB_SYNC_ALL)
88
- return REQ_SYNC;
89
- else if (wbc->for_kupdate || wbc->for_background)
90
- return REQ_BACKGROUND;
99
+ int flags = 0;
91100
92
- return 0;
101
+ if (wbc->punt_to_cgroup)
102
+ flags = REQ_CGROUP_PUNT;
103
+
104
+ if (wbc->sync_mode == WB_SYNC_ALL)
105
+ flags |= REQ_SYNC;
106
+ else if (wbc->for_kupdate || wbc->for_background)
107
+ flags |= REQ_BACKGROUND;
108
+
109
+ return flags;
110
+}
111
+
112
+static inline struct cgroup_subsys_state *
113
+wbc_blkcg_css(struct writeback_control *wbc)
114
+{
115
+#ifdef CONFIG_CGROUP_WRITEBACK
116
+ if (wbc->wb)
117
+ return wbc->wb->blkcg_css;
118
+#endif
119
+ return blkcg_root_css;
93120 }
94121
95122 /*
....@@ -170,6 +197,7 @@
170197 void wakeup_flusher_threads_bdi(struct backing_dev_info *bdi,
171198 enum wb_reason reason);
172199 void inode_wait_for_writeback(struct inode *inode);
200
+void inode_io_list_del(struct inode *inode);
173201
174202 /* writeback.h requires fs.h; it, too, is not included from here. */
175203 static inline void wait_on_inode(struct inode *inode)
....@@ -188,8 +216,10 @@
188216 struct inode *inode)
189217 __releases(&inode->i_lock);
190218 void wbc_detach_inode(struct writeback_control *wbc);
191
-void wbc_account_io(struct writeback_control *wbc, struct page *page,
192
- size_t bytes);
219
+void wbc_account_cgroup_owner(struct writeback_control *wbc, struct page *page,
220
+ size_t bytes);
221
+int cgroup_writeback_by_id(u64 bdi_id, int memcg_id, unsigned long nr_pages,
222
+ enum wb_reason reason, struct wb_completion *done);
193223 void cgroup_writeback_umount(void);
194224
195225 /**
....@@ -246,7 +276,8 @@
246276 *
247277 * @bio is a part of the writeback in progress controlled by @wbc. Perform
248278 * writeback specific initialization. This is used to apply the cgroup
249
- * writeback context.
279
+ * writeback context. Must be called after the bio has been associated with
280
+ * a device.
250281 */
251282 static inline void wbc_init_bio(struct writeback_control *wbc, struct bio *bio)
252283 {
....@@ -257,7 +288,7 @@
257288 * regular writeback instead of writing things out itself.
258289 */
259290 if (wbc->wb)
260
- bio_associate_blkcg(bio, wbc->wb->blkcg_css);
291
+ bio_associate_blkg_from_css(bio, wbc->wb->blkcg_css);
261292 }
262293
263294 #else /* CONFIG_CGROUP_WRITEBACK */
....@@ -290,8 +321,8 @@
290321 {
291322 }
292323
293
-static inline void wbc_account_io(struct writeback_control *wbc,
294
- struct page *page, size_t bytes)
324
+static inline void wbc_account_cgroup_owner(struct writeback_control *wbc,
325
+ struct page *page, size_t bytes)
295326 {
296327 }
297328
....@@ -332,24 +363,18 @@
332363 extern int block_dump;
333364 extern int laptop_mode;
334365
335
-extern int dirty_background_ratio_handler(struct ctl_table *table, int write,
336
- void __user *buffer, size_t *lenp,
337
- loff_t *ppos);
338
-extern int dirty_background_bytes_handler(struct ctl_table *table, int write,
339
- void __user *buffer, size_t *lenp,
340
- loff_t *ppos);
341
-extern int dirty_ratio_handler(struct ctl_table *table, int write,
342
- void __user *buffer, size_t *lenp,
343
- loff_t *ppos);
344
-extern int dirty_bytes_handler(struct ctl_table *table, int write,
345
- void __user *buffer, size_t *lenp,
346
- loff_t *ppos);
366
+int dirty_background_ratio_handler(struct ctl_table *table, int write,
367
+ void *buffer, size_t *lenp, loff_t *ppos);
368
+int dirty_background_bytes_handler(struct ctl_table *table, int write,
369
+ void *buffer, size_t *lenp, loff_t *ppos);
370
+int dirty_ratio_handler(struct ctl_table *table, int write,
371
+ void *buffer, size_t *lenp, loff_t *ppos);
372
+int dirty_bytes_handler(struct ctl_table *table, int write,
373
+ void *buffer, size_t *lenp, loff_t *ppos);
347374 int dirtytime_interval_handler(struct ctl_table *table, int write,
348
- void __user *buffer, size_t *lenp, loff_t *ppos);
349
-
350
-struct ctl_table;
351
-int dirty_writeback_centisecs_handler(struct ctl_table *, int,
352
- void __user *, size_t *, loff_t *);
375
+ void *buffer, size_t *lenp, loff_t *ppos);
376
+int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,
377
+ void *buffer, size_t *lenp, loff_t *ppos);
353378
354379 void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
355380 unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh);