diff options
Diffstat (limited to 'fs/buffer.c')
-rw-r--r-- | fs/buffer.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index f93392e2df12..4d7433534f5c 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -83,6 +83,40 @@ void unlock_buffer(struct buffer_head *bh) | |||
83 | EXPORT_SYMBOL(unlock_buffer); | 83 | EXPORT_SYMBOL(unlock_buffer); |
84 | 84 | ||
85 | /* | 85 | /* |
86 | * Returns if the page has dirty or writeback buffers. If all the buffers | ||
87 | * are unlocked and clean then the PageDirty information is stale. If | ||
88 | * any of the pages are locked, it is assumed they are locked for IO. | ||
89 | */ | ||
90 | void buffer_check_dirty_writeback(struct page *page, | ||
91 | bool *dirty, bool *writeback) | ||
92 | { | ||
93 | struct buffer_head *head, *bh; | ||
94 | *dirty = false; | ||
95 | *writeback = false; | ||
96 | |||
97 | BUG_ON(!PageLocked(page)); | ||
98 | |||
99 | if (!page_has_buffers(page)) | ||
100 | return; | ||
101 | |||
102 | if (PageWriteback(page)) | ||
103 | *writeback = true; | ||
104 | |||
105 | head = page_buffers(page); | ||
106 | bh = head; | ||
107 | do { | ||
108 | if (buffer_locked(bh)) | ||
109 | *writeback = true; | ||
110 | |||
111 | if (buffer_dirty(bh)) | ||
112 | *dirty = true; | ||
113 | |||
114 | bh = bh->b_this_page; | ||
115 | } while (bh != head); | ||
116 | } | ||
117 | EXPORT_SYMBOL(buffer_check_dirty_writeback); | ||
118 | |||
119 | /* | ||
86 | * Block until a buffer comes unlocked. This doesn't stop it | 120 | * Block until a buffer comes unlocked. This doesn't stop it |
87 | * from becoming locked again - you have to lock it yourself | 121 | * from becoming locked again - you have to lock it yourself |
88 | * if you want to preserve its state. | 122 | * if you want to preserve its state. |