diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-05 19:41:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-05 19:41:23 -0400 |
commit | 8c27cb3566762613a23c080e3db7d0501af9a787 (patch) | |
tree | 32b2752e320b6cb3ecf289dd00b5145a6de947e6 /fs/btrfs/check-integrity.c | |
parent | 7114f51fcb979f167ab5f625ac74059dcb1afc28 (diff) | |
parent | 848c23b78fafdcd3270b06a30737f8dbd70c347f (diff) |
Merge branch 'for-4.13-part1' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs updates from David Sterba:
"The core updates improve error handling (mostly related to bios), with
the usual incremental work on the GFP_NOFS (mis)use removal,
refactoring or cleanups. Except the two top patches, all have been in
for-next for an extensive amount of time.
User visible changes:
- statx support
- quota override tunable
- improved compression thresholds
- obsoleted mount option alloc_start
Core updates:
- bio-related updates:
- faster bio cloning
- no allocation failures
- preallocated flush bios
- more kvzalloc use, memalloc_nofs protections, GFP_NOFS updates
- prep work for btree_inode removal
- dir-item validation
- qgoup fixes and updates
- cleanups:
- removed unused struct members, unused code, refactoring
- argument refactoring (fs_info/root, caller -> callee sink)
- SEARCH_TREE ioctl docs"
* 'for-4.13-part1' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: (115 commits)
btrfs: Remove false alert when fiemap range is smaller than on-disk extent
btrfs: Don't clear SGID when inheriting ACLs
btrfs: fix integer overflow in calc_reclaim_items_nr
btrfs: scrub: fix target device intialization while setting up scrub context
btrfs: qgroup: Fix qgroup reserved space underflow by only freeing reserved ranges
btrfs: qgroup: Introduce extent changeset for qgroup reserve functions
btrfs: qgroup: Fix qgroup reserved space underflow caused by buffered write and quotas being enabled
btrfs: qgroup: Return actually freed bytes for qgroup release or free data
btrfs: qgroup: Cleanup btrfs_qgroup_prepare_account_extents function
btrfs: qgroup: Add quick exit for non-fs extents
Btrfs: rework delayed ref total_bytes_pinned accounting
Btrfs: return old and new total ref mods when adding delayed refs
Btrfs: always account pinned bytes when dropping a tree block ref
Btrfs: update total_bytes_pinned when pinning down extents
Btrfs: make BUG_ON() in add_pinned_bytes() an ASSERT()
Btrfs: make add_pinned_bytes() take an s64 num_bytes instead of u64
btrfs: fix validation of XATTR_ITEM dir items
btrfs: Verify dir_item in iterate_object_props
btrfs: Check name_len before in btrfs_del_root_ref
btrfs: Check name_len before reading btrfs_get_name
...
Diffstat (limited to 'fs/btrfs/check-integrity.c')
-rw-r--r-- | fs/btrfs/check-integrity.c | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index 4ded1c3f92b8..11d37c94ce05 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c | |||
@@ -94,7 +94,7 @@ | |||
94 | #include <linux/mutex.h> | 94 | #include <linux/mutex.h> |
95 | #include <linux/genhd.h> | 95 | #include <linux/genhd.h> |
96 | #include <linux/blkdev.h> | 96 | #include <linux/blkdev.h> |
97 | #include <linux/vmalloc.h> | 97 | #include <linux/mm.h> |
98 | #include <linux/string.h> | 98 | #include <linux/string.h> |
99 | #include "ctree.h" | 99 | #include "ctree.h" |
100 | #include "disk-io.h" | 100 | #include "disk-io.h" |
@@ -1638,12 +1638,7 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
1638 | struct bio *bio; | 1638 | struct bio *bio; |
1639 | unsigned int j; | 1639 | unsigned int j; |
1640 | 1640 | ||
1641 | bio = btrfs_io_bio_alloc(GFP_NOFS, num_pages - i); | 1641 | bio = btrfs_io_bio_alloc(num_pages - i); |
1642 | if (!bio) { | ||
1643 | pr_info("btrfsic: bio_alloc() for %u pages failed!\n", | ||
1644 | num_pages - i); | ||
1645 | return -1; | ||
1646 | } | ||
1647 | bio->bi_bdev = block_ctx->dev->bdev; | 1642 | bio->bi_bdev = block_ctx->dev->bdev; |
1648 | bio->bi_iter.bi_sector = dev_bytenr >> 9; | 1643 | bio->bi_iter.bi_sector = dev_bytenr >> 9; |
1649 | bio_set_op_attrs(bio, REQ_OP_READ, 0); | 1644 | bio_set_op_attrs(bio, REQ_OP_READ, 0); |
@@ -1668,14 +1663,8 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
1668 | dev_bytenr += (j - i) * PAGE_SIZE; | 1663 | dev_bytenr += (j - i) * PAGE_SIZE; |
1669 | i = j; | 1664 | i = j; |
1670 | } | 1665 | } |
1671 | for (i = 0; i < num_pages; i++) { | 1666 | for (i = 0; i < num_pages; i++) |
1672 | block_ctx->datav[i] = kmap(block_ctx->pagev[i]); | 1667 | block_ctx->datav[i] = kmap(block_ctx->pagev[i]); |
1673 | if (!block_ctx->datav[i]) { | ||
1674 | pr_info("btrfsic: kmap() failed (dev %s)!\n", | ||
1675 | block_ctx->dev->name); | ||
1676 | return -1; | ||
1677 | } | ||
1678 | } | ||
1679 | 1668 | ||
1680 | return block_ctx->len; | 1669 | return block_ctx->len; |
1681 | } | 1670 | } |
@@ -2822,44 +2811,47 @@ static void __btrfsic_submit_bio(struct bio *bio) | |||
2822 | dev_state = btrfsic_dev_state_lookup(bio->bi_bdev); | 2811 | dev_state = btrfsic_dev_state_lookup(bio->bi_bdev); |
2823 | if (NULL != dev_state && | 2812 | if (NULL != dev_state && |
2824 | (bio_op(bio) == REQ_OP_WRITE) && bio_has_data(bio)) { | 2813 | (bio_op(bio) == REQ_OP_WRITE) && bio_has_data(bio)) { |
2825 | unsigned int i; | 2814 | unsigned int i = 0; |
2826 | u64 dev_bytenr; | 2815 | u64 dev_bytenr; |
2827 | u64 cur_bytenr; | 2816 | u64 cur_bytenr; |
2828 | struct bio_vec *bvec; | 2817 | struct bio_vec bvec; |
2818 | struct bvec_iter iter; | ||
2829 | int bio_is_patched; | 2819 | int bio_is_patched; |
2830 | char **mapped_datav; | 2820 | char **mapped_datav; |
2821 | unsigned int segs = bio_segments(bio); | ||
2831 | 2822 | ||
2832 | dev_bytenr = 512 * bio->bi_iter.bi_sector; | 2823 | dev_bytenr = 512 * bio->bi_iter.bi_sector; |
2833 | bio_is_patched = 0; | 2824 | bio_is_patched = 0; |
2834 | if (dev_state->state->print_mask & | 2825 | if (dev_state->state->print_mask & |
2835 | BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) | 2826 | BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) |
2836 | pr_info("submit_bio(rw=%d,0x%x, bi_vcnt=%u, bi_sector=%llu (bytenr %llu), bi_bdev=%p)\n", | 2827 | pr_info("submit_bio(rw=%d,0x%x, bi_vcnt=%u, bi_sector=%llu (bytenr %llu), bi_bdev=%p)\n", |
2837 | bio_op(bio), bio->bi_opf, bio->bi_vcnt, | 2828 | bio_op(bio), bio->bi_opf, segs, |
2838 | (unsigned long long)bio->bi_iter.bi_sector, | 2829 | (unsigned long long)bio->bi_iter.bi_sector, |
2839 | dev_bytenr, bio->bi_bdev); | 2830 | dev_bytenr, bio->bi_bdev); |
2840 | 2831 | ||
2841 | mapped_datav = kmalloc_array(bio->bi_vcnt, | 2832 | mapped_datav = kmalloc_array(segs, |
2842 | sizeof(*mapped_datav), GFP_NOFS); | 2833 | sizeof(*mapped_datav), GFP_NOFS); |
2843 | if (!mapped_datav) | 2834 | if (!mapped_datav) |
2844 | goto leave; | 2835 | goto leave; |
2845 | cur_bytenr = dev_bytenr; | 2836 | cur_bytenr = dev_bytenr; |
2846 | 2837 | ||
2847 | bio_for_each_segment_all(bvec, bio, i) { | 2838 | bio_for_each_segment(bvec, bio, iter) { |
2848 | BUG_ON(bvec->bv_len != PAGE_SIZE); | 2839 | BUG_ON(bvec.bv_len != PAGE_SIZE); |
2849 | mapped_datav[i] = kmap(bvec->bv_page); | 2840 | mapped_datav[i] = kmap(bvec.bv_page); |
2841 | i++; | ||
2850 | 2842 | ||
2851 | if (dev_state->state->print_mask & | 2843 | if (dev_state->state->print_mask & |
2852 | BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH_VERBOSE) | 2844 | BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH_VERBOSE) |
2853 | pr_info("#%u: bytenr=%llu, len=%u, offset=%u\n", | 2845 | pr_info("#%u: bytenr=%llu, len=%u, offset=%u\n", |
2854 | i, cur_bytenr, bvec->bv_len, bvec->bv_offset); | 2846 | i, cur_bytenr, bvec.bv_len, bvec.bv_offset); |
2855 | cur_bytenr += bvec->bv_len; | 2847 | cur_bytenr += bvec.bv_len; |
2856 | } | 2848 | } |
2857 | btrfsic_process_written_block(dev_state, dev_bytenr, | 2849 | btrfsic_process_written_block(dev_state, dev_bytenr, |
2858 | mapped_datav, bio->bi_vcnt, | 2850 | mapped_datav, segs, |
2859 | bio, &bio_is_patched, | 2851 | bio, &bio_is_patched, |
2860 | NULL, bio->bi_opf); | 2852 | NULL, bio->bi_opf); |
2861 | bio_for_each_segment_all(bvec, bio, i) | 2853 | bio_for_each_segment(bvec, bio, iter) |
2862 | kunmap(bvec->bv_page); | 2854 | kunmap(bvec.bv_page); |
2863 | kfree(mapped_datav); | 2855 | kfree(mapped_datav); |
2864 | } else if (NULL != dev_state && (bio->bi_opf & REQ_PREFLUSH)) { | 2856 | } else if (NULL != dev_state && (bio->bi_opf & REQ_PREFLUSH)) { |
2865 | if (dev_state->state->print_mask & | 2857 | if (dev_state->state->print_mask & |
@@ -2923,13 +2915,10 @@ int btrfsic_mount(struct btrfs_fs_info *fs_info, | |||
2923 | fs_info->sectorsize, PAGE_SIZE); | 2915 | fs_info->sectorsize, PAGE_SIZE); |
2924 | return -1; | 2916 | return -1; |
2925 | } | 2917 | } |
2926 | state = kzalloc(sizeof(*state), GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT); | 2918 | state = kvzalloc(sizeof(*state), GFP_KERNEL); |
2927 | if (!state) { | 2919 | if (!state) { |
2928 | state = vzalloc(sizeof(*state)); | 2920 | pr_info("btrfs check-integrity: allocation failed!\n"); |
2929 | if (!state) { | 2921 | return -1; |
2930 | pr_info("btrfs check-integrity: vzalloc() failed!\n"); | ||
2931 | return -1; | ||
2932 | } | ||
2933 | } | 2922 | } |
2934 | 2923 | ||
2935 | if (!btrfsic_is_initialized) { | 2924 | if (!btrfsic_is_initialized) { |