fs: Convert is_dirty_writeback() to take a folio
[linux-2.6-block.git] / fs / buffer.c
index 2b5561ae5d0b32b038131a77db6073a0eccddb7f..fb4df259c92da4c4d1033965ff634b3ba9743df6 100644 (file)
@@ -79,26 +79,26 @@ 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.
+ * Returns if the folio has dirty or writeback buffers. If all the buffers
+ * are unlocked and clean then the folio_test_dirty information is stale. If
+ * any of the buffers are locked, it is assumed they are locked for IO.
  */
-void buffer_check_dirty_writeback(struct page *page,
+void buffer_check_dirty_writeback(struct folio *folio,
                                     bool *dirty, bool *writeback)
 {
        struct buffer_head *head, *bh;
        *dirty = false;
        *writeback = false;
 
-       BUG_ON(!PageLocked(page));
+       BUG_ON(!folio_test_locked(folio));
 
-       if (!page_has_buffers(page))
+       head = folio_buffers(folio);
+       if (!head)
                return;
 
-       if (PageWriteback(page))
+       if (folio_test_writeback(folio))
                *writeback = true;
 
-       head = page_buffers(page);
        bh = head;
        do {
                if (buffer_locked(bh))
@@ -2104,13 +2104,13 @@ static int __block_commit_write(struct inode *inode, struct page *page,
  * The filesystem needs to handle block truncation upon failure.
  */
 int block_write_begin(struct address_space *mapping, loff_t pos, unsigned len,
-               unsigned flags, struct page **pagep, get_block_t *get_block)
+               struct page **pagep, get_block_t *get_block)
 {
        pgoff_t index = pos >> PAGE_SHIFT;
        struct page *page;
        int status;
 
-       page = grab_cache_page_write_begin(mapping, index, flags);
+       page = grab_cache_page_write_begin(mapping, index);
        if (!page)
                return -ENOMEM;
 
@@ -2344,6 +2344,7 @@ EXPORT_SYMBOL(block_read_full_page);
 int generic_cont_expand_simple(struct inode *inode, loff_t size)
 {
        struct address_space *mapping = inode->i_mapping;
+       const struct address_space_operations *aops = mapping->a_ops;
        struct page *page;
        void *fsdata;
        int err;
@@ -2352,11 +2353,11 @@ int generic_cont_expand_simple(struct inode *inode, loff_t size)
        if (err)
                goto out;
 
-       err = pagecache_write_begin(NULL, mapping, size, 0, 0, &page, &fsdata);
+       err = aops->write_begin(NULL, mapping, size, 0, &page, &fsdata);
        if (err)
                goto out;
 
-       err = pagecache_write_end(NULL, mapping, size, 0, 0, page, fsdata);
+       err = aops->write_end(NULL, mapping, size, 0, 0, page, fsdata);
        BUG_ON(err > 0);
 
 out:
@@ -2368,6 +2369,7 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping,
                            loff_t pos, loff_t *bytes)
 {
        struct inode *inode = mapping->host;
+       const struct address_space_operations *aops = mapping->a_ops;
        unsigned int blocksize = i_blocksize(inode);
        struct page *page;
        void *fsdata;
@@ -2387,12 +2389,12 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping,
                }
                len = PAGE_SIZE - zerofrom;
 
-               err = pagecache_write_begin(file, mapping, curpos, len, 0,
+               err = aops->write_begin(file, mapping, curpos, len,
                                            &page, &fsdata);
                if (err)
                        goto out;
                zero_user(page, zerofrom, len);
-               err = pagecache_write_end(file, mapping, curpos, len, len,
+               err = aops->write_end(file, mapping, curpos, len, len,
                                                page, fsdata);
                if (err < 0)
                        goto out;
@@ -2420,12 +2422,12 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping,
                }
                len = offset - zerofrom;
 
-               err = pagecache_write_begin(file, mapping, curpos, len, 0,
+               err = aops->write_begin(file, mapping, curpos, len,
                                            &page, &fsdata);
                if (err)
                        goto out;
                zero_user(page, zerofrom, len);
-               err = pagecache_write_end(file, mapping, curpos, len, len,
+               err = aops->write_end(file, mapping, curpos, len, len,
                                                page, fsdata);
                if (err < 0)
                        goto out;
@@ -2441,7 +2443,7 @@ out:
  * We may have to extend the file.
  */
 int cont_write_begin(struct file *file, struct address_space *mapping,
-                       loff_t pos, unsigned len, unsigned flags,
+                       loff_t pos, unsigned len,
                        struct page **pagep, void **fsdata,
                        get_block_t *get_block, loff_t *bytes)
 {
@@ -2460,7 +2462,7 @@ int cont_write_begin(struct file *file, struct address_space *mapping,
                (*bytes)++;
        }
 
-       return block_write_begin(mapping, pos, len, flags, pagep, get_block);
+       return block_write_begin(mapping, pos, len, pagep, get_block);
 }
 EXPORT_SYMBOL(cont_write_begin);
 
@@ -2568,8 +2570,7 @@ static void attach_nobh_buffers(struct page *page, struct buffer_head *head)
  * On exit the page is fully uptodate in the areas outside (from,to)
  * The filesystem needs to handle block truncation upon failure.
  */
-int nobh_write_begin(struct address_space *mapping,
-                       loff_t pos, unsigned len, unsigned flags,
+int nobh_write_begin(struct address_space *mapping, loff_t pos, unsigned len,
                        struct page **pagep, void **fsdata,
                        get_block_t *get_block)
 {
@@ -2591,7 +2592,7 @@ int nobh_write_begin(struct address_space *mapping,
        from = pos & (PAGE_SIZE - 1);
        to = from + len;
 
-       page = grab_cache_page_write_begin(mapping, index, flags);
+       page = grab_cache_page_write_begin(mapping, index);
        if (!page)
                return -ENOMEM;
        *pagep = page;