History

Merge tag 'for-5.1-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux

Pull btrfs fix from David Sterba: "One patch to fix a crash in io submission path, due to memory allocation errors. In short, the multipage bio work that landed in 5.1 caused larger bios that in turn require larger temporary memory for checksums. The patch is a workaround, we're going to rework the allocation so it does not require the vmalloc fallback. It took a while to identify that it's caused by patches in 5.1 and not a patchset that did some changes in error handling in the code. I've tested it on various memory/cpu combinations, it could hit OOM but does not crash. The timestamp of the patch is less than a day due to updates in the changelog, tests were running meanwhile" * tag 'for-5.1-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: Switch memory allocations in async csum calculation path to kvmalloc

Linus Torvalds committed 7 years ago

Commit d0473f92 parents 5813023 a3d46ae2 files · +13 −5Browse files

Unified · Split

2 files
  1. fs/btrfs/file-item.c +11 −4
  2. fs/btrfs/ordered-data.c +2 −1
fs/btrfs/file-item.c+11−4
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 #include <linux/slab.h>
88 #include <linux/pagemap.h>
99 #include <linux/highmem.h>
10+#include <linux/sched/mm.h>
1011 #include "ctree.h"
1112 #include "disk-io.h"
1213 #include "transaction.h"
@@ -427,9 +428,13 @@ blk_status_t btrfs_csum_one_bio(struct inode *inode, struct bio *bio, · 414 unmodified lines
427428 unsigned long this_sum_bytes = 0;
428429 int i;
429430 u64 offset;
431+ unsigned nofs_flag;
432+
433+ nofs_flag = memalloc_nofs_save();
434+ sums = kvzalloc(btrfs_ordered_sum_size(fs_info, bio->bi_iter.bi_size),
435+ GFP_KERNEL);
436+ memalloc_nofs_restore(nofs_flag);
430437
431− sums = kzalloc(btrfs_ordered_sum_size(fs_info, bio->bi_iter.bi_size),
432− GFP_NOFS);
433438 if (!sums)
434439 return BLK_STS_RESOURCE;
435440
@@ -472,8 +477,10 @@ blk_status_t btrfs_csum_one_bio(struct inode *inode, struct bio *bio, · 36 unmodified lines
472477
473478 bytes_left = bio->bi_iter.bi_size - total_bytes;
474479
475− sums = kzalloc(btrfs_ordered_sum_size(fs_info, bytes_left),
476− GFP_NOFS);
480+ nofs_flag = memalloc_nofs_save();
481+ sums = kvzalloc(btrfs_ordered_sum_size(fs_info,
482+ bytes_left), GFP_KERNEL);
483+ memalloc_nofs_restore(nofs_flag);
477484 BUG_ON(!sums); /* -ENOMEM */
478485 sums->len = bytes_left;
479486 ordered = btrfs_lookup_ordered_extent(inode,
fs/btrfs/ordered-data.c+2−1
@@ -6,6 +6,7 @@ · 5 unmodified lines
66 #include <linux/slab.h>
77 #include <linux/blkdev.h>
88 #include <linux/writeback.h>
9+#include <linux/sched/mm.h>
910 #include "ctree.h"
1011 #include "transaction.h"
1112 #include "btrfs_inode.h"
@@ -442,7 +443,7 @@ void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry) · 430 unmodified lines
442443 cur = entry->list.next;
443444 sum = list_entry(cur, struct btrfs_ordered_sum, list);
444445 list_del(&sum->list);
445− kfree(sum);
446+ kvfree(sum);
446447 }
447448 kmem_cache_free(btrfs_ordered_extent_cache, entry);
448449 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t