]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - fs/btrfs/ordered-data.c
Btrfs: do not call kfree if kmalloc failed in btrfs_sysfs_add_super
[mirror_ubuntu-artful-kernel.git] / fs / btrfs / ordered-data.c
index e7317c8fda29abed50f5e84951d49f472673cf46..d9e232227da486442c1f7436cd464e1622f9c4d1 100644 (file)
@@ -182,7 +182,7 @@ int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
        entry->len = len;
        entry->disk_len = disk_len;
        entry->inode = inode;
-       if (type == BTRFS_ORDERED_NOCOW || type == BTRFS_ORDERED_COMPRESSED)
+       if (type != BTRFS_ORDERED_IO_DONE && type != BTRFS_ORDERED_COMPLETE)
                set_bit(type, &entry->flags);
 
        /* one ref for the tree */
@@ -339,7 +339,8 @@ int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only)
                ordered = list_entry(cur, struct btrfs_ordered_extent,
                                     root_extent_list);
                if (nocow_only &&
-                   !test_bit(BTRFS_ORDERED_NOCOW, &ordered->flags)) {
+                   !test_bit(BTRFS_ORDERED_NOCOW, &ordered->flags) &&
+                   !test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags)) {
                        list_move(&ordered->root_extent_list,
                                  &root->fs_info->ordered_extents);
                        cond_resched_lock(&root->fs_info->ordered_extent_lock);
@@ -389,7 +390,7 @@ void btrfs_start_ordered_extent(struct inode *inode,
         * start IO on any dirty ones so the wait doesn't stall waiting
         * for pdflush to find them
         */
-       btrfs_fdatawrite_range(inode->i_mapping, start, end, WB_SYNC_NONE);
+       btrfs_fdatawrite_range(inode->i_mapping, start, end, WB_SYNC_ALL);
        if (wait) {
                wait_event(entry->wait, test_bit(BTRFS_ORDERED_COMPLETE,
                                                 &entry->flags));
@@ -420,6 +421,12 @@ again:
         */
        btrfs_fdatawrite_range(inode->i_mapping, start, orig_end, WB_SYNC_NONE);
 
+       /* The compression code will leave pages locked but return from
+        * writepage without setting the page writeback.  Starting again
+        * with WB_SYNC_ALL will end up waiting for the IO to actually start.
+        */
+       btrfs_fdatawrite_range(inode->i_mapping, start, orig_end, WB_SYNC_ALL);
+
        btrfs_wait_on_page_writeback_range(inode->i_mapping,
                                           start >> PAGE_CACHE_SHIFT,
                                           orig_end >> PAGE_CACHE_SHIFT);
@@ -447,10 +454,7 @@ again:
        }
        if (test_range_bit(&BTRFS_I(inode)->io_tree, start, orig_end,
                           EXTENT_ORDERED | EXTENT_DELALLOC, 0)) {
-               printk("inode %lu still ordered or delalloc after wait "
-                      "%llu %llu\n", inode->i_ino,
-                      (unsigned long long)start,
-                      (unsigned long long)orig_end);
+               schedule_timeout(1);
                goto again;
        }
        return 0;
@@ -606,7 +610,8 @@ out:
  * try to find a checksum.  This is used because we allow pages to
  * be reclaimed before their checksum is actually put into the btree
  */
-int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u32 *sum)
+int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr,
+                          u32 *sum)
 {
        struct btrfs_ordered_sum *ordered_sum;
        struct btrfs_sector_sum *sector_sums;
@@ -625,11 +630,11 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u32 *sum)
        mutex_lock(&tree->mutex);
        list_for_each_prev(cur, &ordered->list) {
                ordered_sum = list_entry(cur, struct btrfs_ordered_sum, list);
-               if (offset >= ordered_sum->file_offset) {
+               if (disk_bytenr >= ordered_sum->bytenr) {
                        num_sectors = ordered_sum->len / sectorsize;
                        sector_sums = ordered_sum->sums;
                        for (i = 0; i < num_sectors; i++) {
-                               if (sector_sums[i].offset == offset) {
+                               if (sector_sums[i].bytenr == disk_bytenr) {
                                        *sum = sector_sums[i].sum;
                                        ret = 0;
                                        goto out;