Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile
[linux-2.6-block.git] / mm / filemap.c
index 243997a26e7cebbc52bbc4347555bc50f374a193..6bf5e42d560a46eea8e4916bd017d855033b8d65 100644 (file)
@@ -202,16 +202,15 @@ void __delete_from_page_cache(struct page *page, void *shadow)
        BUG_ON(page_mapped(page));
 
        /*
-        * Some filesystems seem to re-dirty the page even after
-        * the VM has canceled the dirty bit (eg ext3 journaling).
+        * At this point page must be either written or cleaned by truncate.
+        * Dirty page here signals a bug and loss of unwritten data.
         *
-        * Fix it up by doing a final dirty accounting check after
-        * having removed the page entirely.
+        * This fixes dirty accounting after removing the page entirely but
+        * leaves PageDirty set: it has no effect for truncated page and
+        * anyway will be cleared before returning page into buddy allocator.
         */
-       if (PageDirty(page) && mapping_cap_account_dirty(mapping)) {
-               dec_zone_page_state(page, NR_FILE_DIRTY);
-               dec_bdi_stat(inode_to_bdi(mapping->host), BDI_RECLAIMABLE);
-       }
+       if (WARN_ON_ONCE(PageDirty(page)))
+               account_page_cleaned(page, mapping);
 }
 
 /**
@@ -1694,7 +1693,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
        loff_t *ppos = &iocb->ki_pos;
        loff_t pos = *ppos;
 
-       if (io_is_direct(file)) {
+       if (iocb->ki_flags & IOCB_DIRECT) {
                struct address_space *mapping = file->f_mapping;
                struct inode *inode = mapping->host;
                size_t count = iov_iter_count(iter);
@@ -2271,7 +2270,7 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)
                return 0;
 
        /* FIXME: this is for backwards compatibility with 2.4 */
-       if (file->f_flags & O_APPEND)
+       if (iocb->ki_flags & IOCB_APPEND)
                iocb->ki_pos = i_size_read(inode);
 
        pos = iocb->ki_pos;
@@ -2545,7 +2544,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
        if (err)
                goto out;
 
-       if (io_is_direct(file)) {
+       if (iocb->ki_flags & IOCB_DIRECT) {
                loff_t pos, endbyte;
 
                written = generic_file_direct_write(iocb, from, iocb->ki_pos);