ath10k: add boot messages to htt.c
[cascardo/linux.git] / fs / buffer.c
index f93392e..4d74335 100644 (file)
@@ -82,6 +82,40 @@ void unlock_buffer(struct buffer_head *bh)
 }
 EXPORT_SYMBOL(unlock_buffer);
 
+/*
+ * Returns if the page has dirty or writeback buffers. If all the buffers
+ * are unlocked and clean then the PageDirty information is stale. If
+ * any of the pages are locked, it is assumed they are locked for IO.
+ */
+void buffer_check_dirty_writeback(struct page *page,
+                                    bool *dirty, bool *writeback)
+{
+       struct buffer_head *head, *bh;
+       *dirty = false;
+       *writeback = false;
+
+       BUG_ON(!PageLocked(page));
+
+       if (!page_has_buffers(page))
+               return;
+
+       if (PageWriteback(page))
+               *writeback = true;
+
+       head = page_buffers(page);
+       bh = head;
+       do {
+               if (buffer_locked(bh))
+                       *writeback = true;
+
+               if (buffer_dirty(bh))
+                       *dirty = true;
+
+               bh = bh->b_this_page;
+       } while (bh != head);
+}
+EXPORT_SYMBOL(buffer_check_dirty_writeback);
+
 /*
  * Block until a buffer comes unlocked.  This doesn't stop it
  * from becoming locked again - you have to lock it yourself