History

writeback: Generalize and expose wb_completion

wb_completion is used to track writeback completions. We want to use it from memcg side for foreign inode flushes. This patch updates it to remember the target waitq instead of assuming bdi->wb_waitq and expose it outside of fs-writeback.c.

Tejun Heo committed 7 years ago

Commit 5b9cce41 parent 38b4e093 files · +36 −33Browse files

Showing the changes to include/linux (2 of 3 files). Show all

Unified · Split

2 files
  1. include/linux/backing-dev-defs.h +20 −0
  2. include/linux/backing-dev.h +2 −0
include/linux/backing-dev-defs.h+20−0
@@ -67,6 +67,26 @@ enum wb_reason { · 66 unmodified lines
67 WB_REASON_MAX,67 WB_REASON_MAX,
68};68};
69 69
70struct wb_completion {
71 atomic_t cnt;
72 wait_queue_head_t *waitq;
73};
74
75#define __WB_COMPLETION_INIT(_waitq) \
76 (struct wb_completion){ .cnt = ATOMIC_INIT(1), .waitq = (_waitq) }
77
78/*
79 * If one wants to wait for one or more wb_writeback_works, each work's
80 * ->done should be set to a wb_completion defined using the following
81 * macro. Once all work items are issued with wb_queue_work(), the caller
82 * can wait for the completion of all using wb_wait_for_completion(). Work
83 * items which are waited upon aren't freed automatically on completion.
84 */
85#define WB_COMPLETION_INIT(bdi) __WB_COMPLETION_INIT(&(bdi)->wb_waitq)
86
87#define DEFINE_WB_COMPLETION(cmpl, bdi) \
88 struct wb_completion cmpl = WB_COMPLETION_INIT(bdi)
89
70/*90/*
71 * For cgroup writeback, multiple wb's may map to the same blkcg. Those91 * For cgroup writeback, multiple wb's may map to the same blkcg. Those
72 * wb's can operate mostly independently but should share the congested92 * wb's can operate mostly independently but should share the congested
include/linux/backing-dev.h+2−0
@@ -44,6 +44,8 @@ void wb_start_background_writeback(struct bdi_writeback *wb); · 43 unmodified lines
44void wb_workfn(struct work_struct *work);44void wb_workfn(struct work_struct *work);
45void wb_wakeup_delayed(struct bdi_writeback *wb);45void wb_wakeup_delayed(struct bdi_writeback *wb);
46 46
47void wb_wait_for_completion(struct wb_completion *done);
48
47extern spinlock_t bdi_lock;49extern spinlock_t bdi_lock;
48extern struct list_head bdi_list;50extern struct list_head bdi_list;
49 51

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t