hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/fs/btrfs/check-integrity.c
....@@ -77,13 +77,12 @@
7777
7878 #include <linux/sched.h>
7979 #include <linux/slab.h>
80
-#include <linux/buffer_head.h>
8180 #include <linux/mutex.h>
8281 #include <linux/genhd.h>
8382 #include <linux/blkdev.h>
8483 #include <linux/mm.h>
8584 #include <linux/string.h>
86
-#include <linux/crc32c.h>
85
+#include <crypto/hash.h>
8786 #include "ctree.h"
8887 #include "disk-io.h"
8988 #include "transaction.h"
....@@ -152,11 +151,8 @@
152151 struct list_head ref_to_list; /* list */
153152 struct list_head ref_from_list; /* list */
154153 struct btrfsic_block *next_in_same_bio;
155
- void *orig_bio_bh_private;
156
- union {
157
- bio_end_io_t *bio;
158
- bh_end_io_t *bh;
159
- } orig_bio_bh_end_io;
154
+ void *orig_bio_private;
155
+ bio_end_io_t *orig_bio_end_io;
160156 int submit_bio_bh_rw;
161157 u64 flush_gen; /* only valid if !never_written */
162158 };
....@@ -325,14 +321,12 @@
325321 u64 dev_bytenr, char **mapped_datav,
326322 unsigned int num_pages,
327323 struct bio *bio, int *bio_is_patched,
328
- struct buffer_head *bh,
329324 int submit_bio_bh_rw);
330325 static int btrfsic_process_written_superblock(
331326 struct btrfsic_state *state,
332327 struct btrfsic_block *const block,
333328 struct btrfs_super_block *const super_hdr);
334329 static void btrfsic_bio_end_io(struct bio *bp);
335
-static void btrfsic_bh_end_io(struct buffer_head *bh, int uptodate);
336330 static int btrfsic_is_block_ref_by_superblock(const struct btrfsic_state *state,
337331 const struct btrfsic_block *block,
338332 int recursion_level);
....@@ -399,8 +393,8 @@
399393 b->never_written = 0;
400394 b->mirror_num = 0;
401395 b->next_in_same_bio = NULL;
402
- b->orig_bio_bh_private = NULL;
403
- b->orig_bio_bh_end_io.bio = NULL;
396
+ b->orig_bio_private = NULL;
397
+ b->orig_bio_end_io = NULL;
404398 INIT_LIST_HEAD(&b->collision_resolving_node);
405399 INIT_LIST_HEAD(&b->all_blocks_node);
406400 INIT_LIST_HEAD(&b->ref_to_list);
....@@ -636,12 +630,9 @@
636630 int ret = 0;
637631 int pass;
638632
639
- BUG_ON(NULL == state);
640633 selected_super = kzalloc(sizeof(*selected_super), GFP_NOFS);
641
- if (NULL == selected_super) {
642
- pr_info("btrfsic: error, kmalloc failed!\n");
634
+ if (!selected_super)
643635 return -ENOMEM;
644
- }
645636
646637 list_for_each_entry(device, dev_head, dev_list) {
647638 int i;
....@@ -768,29 +759,31 @@
768759 struct btrfs_fs_info *fs_info = state->fs_info;
769760 struct btrfs_super_block *super_tmp;
770761 u64 dev_bytenr;
771
- struct buffer_head *bh;
772762 struct btrfsic_block *superblock_tmp;
773763 int pass;
774764 struct block_device *const superblock_bdev = device->bdev;
765
+ struct page *page;
766
+ struct address_space *mapping = superblock_bdev->bd_inode->i_mapping;
767
+ int ret = 0;
775768
776769 /* super block bytenr is always the unmapped device bytenr */
777770 dev_bytenr = btrfs_sb_offset(superblock_mirror_num);
778771 if (dev_bytenr + BTRFS_SUPER_INFO_SIZE > device->commit_total_bytes)
779772 return -1;
780
- bh = __bread(superblock_bdev, dev_bytenr / BTRFS_BDEV_BLOCKSIZE,
781
- BTRFS_SUPER_INFO_SIZE);
782
- if (NULL == bh)
773
+
774
+ page = read_cache_page_gfp(mapping, dev_bytenr >> PAGE_SHIFT, GFP_NOFS);
775
+ if (IS_ERR(page))
783776 return -1;
784
- super_tmp = (struct btrfs_super_block *)
785
- (bh->b_data + (dev_bytenr & (BTRFS_BDEV_BLOCKSIZE - 1)));
777
+
778
+ super_tmp = page_address(page);
786779
787780 if (btrfs_super_bytenr(super_tmp) != dev_bytenr ||
788781 btrfs_super_magic(super_tmp) != BTRFS_MAGIC ||
789782 memcmp(device->uuid, super_tmp->dev_item.uuid, BTRFS_UUID_SIZE) ||
790783 btrfs_super_nodesize(super_tmp) != state->metablock_size ||
791784 btrfs_super_sectorsize(super_tmp) != state->datablock_size) {
792
- brelse(bh);
793
- return 0;
785
+ ret = 0;
786
+ goto out;
794787 }
795788
796789 superblock_tmp =
....@@ -800,9 +793,8 @@
800793 if (NULL == superblock_tmp) {
801794 superblock_tmp = btrfsic_block_alloc();
802795 if (NULL == superblock_tmp) {
803
- pr_info("btrfsic: error, kmalloc failed!\n");
804
- brelse(bh);
805
- return -1;
796
+ ret = -1;
797
+ goto out;
806798 }
807799 /* for superblock, only the dev_bytenr makes sense */
808800 superblock_tmp->dev_bytenr = dev_bytenr;
....@@ -886,8 +878,8 @@
886878 mirror_num)) {
887879 pr_info("btrfsic: btrfsic_map_block(bytenr @%llu, mirror %d) failed!\n",
888880 next_bytenr, mirror_num);
889
- brelse(bh);
890
- return -1;
881
+ ret = -1;
882
+ goto out;
891883 }
892884
893885 next_block = btrfsic_block_lookup_or_add(
....@@ -896,8 +888,8 @@
896888 mirror_num, NULL);
897889 if (NULL == next_block) {
898890 btrfsic_release_block_ctx(&tmp_next_block_ctx);
899
- brelse(bh);
900
- return -1;
891
+ ret = -1;
892
+ goto out;
901893 }
902894
903895 next_block->disk_key = tmp_disk_key;
....@@ -908,16 +900,17 @@
908900 BTRFSIC_GENERATION_UNKNOWN);
909901 btrfsic_release_block_ctx(&tmp_next_block_ctx);
910902 if (NULL == l) {
911
- brelse(bh);
912
- return -1;
903
+ ret = -1;
904
+ goto out;
913905 }
914906 }
915907 }
916908 if (state->print_mask & BTRFSIC_PRINT_MASK_INITIAL_ALL_TREES)
917909 btrfsic_dump_tree_sub(state, superblock_tmp, 0);
918910
919
- brelse(bh);
920
- return 0;
911
+out:
912
+ put_page(page);
913
+ return ret;
921914 }
922915
923916 static struct btrfsic_stack_frame *btrfsic_stack_frame_alloc(void)
....@@ -925,9 +918,7 @@
925918 struct btrfsic_stack_frame *sf;
926919
927920 sf = kzalloc(sizeof(*sf), GFP_NOFS);
928
- if (NULL == sf)
929
- pr_info("btrfsic: alloc memory failed!\n");
930
- else
921
+ if (sf)
931922 sf->magic = BTRFSIC_BLOCK_STACK_FRAME_MAGIC_NUMBER;
932923 return sf;
933924 }
....@@ -939,7 +930,7 @@
939930 kfree(sf);
940931 }
941932
942
-static int btrfsic_process_metablock(
933
+static noinline_for_stack int btrfsic_process_metablock(
943934 struct btrfsic_state *state,
944935 struct btrfsic_block *const first_block,
945936 struct btrfsic_block_data_ctx *const first_block_ctx,
....@@ -1201,24 +1192,24 @@
12011192 void *dstv, u32 offset, size_t len)
12021193 {
12031194 size_t cur;
1204
- size_t offset_in_page;
1195
+ size_t pgoff;
12051196 char *kaddr;
12061197 char *dst = (char *)dstv;
1207
- size_t start_offset = block_ctx->start & ((u64)PAGE_SIZE - 1);
1198
+ size_t start_offset = offset_in_page(block_ctx->start);
12081199 unsigned long i = (start_offset + offset) >> PAGE_SHIFT;
12091200
12101201 WARN_ON(offset + len > block_ctx->len);
1211
- offset_in_page = (start_offset + offset) & (PAGE_SIZE - 1);
1202
+ pgoff = offset_in_page(start_offset + offset);
12121203
12131204 while (len > 0) {
1214
- cur = min(len, ((size_t)PAGE_SIZE - offset_in_page));
1205
+ cur = min(len, ((size_t)PAGE_SIZE - pgoff));
12151206 BUG_ON(i >= DIV_ROUND_UP(block_ctx->len, PAGE_SIZE));
12161207 kaddr = block_ctx->datav[i];
1217
- memcpy(dst, kaddr + offset_in_page, cur);
1208
+ memcpy(dst, kaddr + pgoff, cur);
12181209
12191210 dst += cur;
12201211 len -= cur;
1221
- offset_in_page = 0;
1212
+ pgoff = 0;
12221213 i++;
12231214 }
12241215 }
....@@ -1317,7 +1308,6 @@
13171308 if (NULL == l) {
13181309 l = btrfsic_block_link_alloc();
13191310 if (NULL == l) {
1320
- pr_info("btrfsic: error, kmalloc failed!\n");
13211311 btrfsic_release_block_ctx(next_block_ctx);
13221312 *next_blockp = NULL;
13231313 return -1;
....@@ -1474,7 +1464,6 @@
14741464 mirror_num,
14751465 &block_was_created);
14761466 if (NULL == next_block) {
1477
- pr_info("btrfsic: error, kmalloc failed!\n");
14781467 btrfsic_release_block_ctx(&next_block_ctx);
14791468 return -1;
14801469 }
....@@ -1593,13 +1582,14 @@
15931582 {
15941583 unsigned int num_pages;
15951584 unsigned int i;
1585
+ size_t size;
15961586 u64 dev_bytenr;
15971587 int ret;
15981588
15991589 BUG_ON(block_ctx->datav);
16001590 BUG_ON(block_ctx->pagev);
16011591 BUG_ON(block_ctx->mem_to_free);
1602
- if (block_ctx->dev_bytenr & ((u64)PAGE_SIZE - 1)) {
1592
+ if (!PAGE_ALIGNED(block_ctx->dev_bytenr)) {
16031593 pr_info("btrfsic: read_block() with unaligned bytenr %llu\n",
16041594 block_ctx->dev_bytenr);
16051595 return -1;
....@@ -1607,9 +1597,8 @@
16071597
16081598 num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >>
16091599 PAGE_SHIFT;
1610
- block_ctx->mem_to_free = kcalloc(sizeof(*block_ctx->datav) +
1611
- sizeof(*block_ctx->pagev),
1612
- num_pages, GFP_NOFS);
1600
+ size = sizeof(*block_ctx->datav) + sizeof(*block_ctx->pagev);
1601
+ block_ctx->mem_to_free = kcalloc(num_pages, size, GFP_NOFS);
16131602 if (!block_ctx->mem_to_free)
16141603 return -ENOMEM;
16151604 block_ctx->datav = block_ctx->mem_to_free;
....@@ -1705,13 +1694,14 @@
17051694 * Test whether the disk block contains a tree block (leaf or node)
17061695 * (note that this test fails for the super block)
17071696 */
1708
-static int btrfsic_test_for_metadata(struct btrfsic_state *state,
1709
- char **datav, unsigned int num_pages)
1697
+static noinline_for_stack int btrfsic_test_for_metadata(
1698
+ struct btrfsic_state *state,
1699
+ char **datav, unsigned int num_pages)
17101700 {
17111701 struct btrfs_fs_info *fs_info = state->fs_info;
1702
+ SHASH_DESC_ON_STACK(shash, fs_info->csum_shash);
17121703 struct btrfs_header *h;
17131704 u8 csum[BTRFS_CSUM_SIZE];
1714
- u32 crc = ~(u32)0;
17151705 unsigned int i;
17161706
17171707 if (num_pages * PAGE_SIZE < state->metablock_size)
....@@ -1719,17 +1709,20 @@
17191709 num_pages = state->metablock_size >> PAGE_SHIFT;
17201710 h = (struct btrfs_header *)datav[0];
17211711
1722
- if (memcmp(h->fsid, fs_info->fsid, BTRFS_FSID_SIZE))
1712
+ if (memcmp(h->fsid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE))
17231713 return 1;
1714
+
1715
+ shash->tfm = fs_info->csum_shash;
1716
+ crypto_shash_init(shash);
17241717
17251718 for (i = 0; i < num_pages; i++) {
17261719 u8 *data = i ? datav[i] : (datav[i] + BTRFS_CSUM_SIZE);
17271720 size_t sublen = i ? PAGE_SIZE :
17281721 (PAGE_SIZE - BTRFS_CSUM_SIZE);
17291722
1730
- crc = crc32c(crc, data, sublen);
1723
+ crypto_shash_update(shash, data, sublen);
17311724 }
1732
- btrfs_csum_final(crc, csum);
1725
+ crypto_shash_final(shash, csum);
17331726 if (memcmp(csum, h->csum, state->csum_size))
17341727 return 1;
17351728
....@@ -1740,7 +1733,6 @@
17401733 u64 dev_bytenr, char **mapped_datav,
17411734 unsigned int num_pages,
17421735 struct bio *bio, int *bio_is_patched,
1743
- struct buffer_head *bh,
17441736 int submit_bio_bh_rw)
17451737 {
17461738 int is_metadata;
....@@ -1777,7 +1769,7 @@
17771769 return;
17781770 }
17791771 is_metadata = 1;
1780
- BUG_ON(BTRFS_SUPER_INFO_SIZE & (PAGE_SIZE - 1));
1772
+ BUG_ON(!PAGE_ALIGNED(BTRFS_SUPER_INFO_SIZE));
17811773 processed_len = BTRFS_SUPER_INFO_SIZE;
17821774 if (state->print_mask &
17831775 BTRFSIC_PRINT_MASK_TREE_BEFORE_SB_WRITE) {
....@@ -1899,9 +1891,9 @@
18991891 block->is_iodone = 0;
19001892 BUG_ON(NULL == bio_is_patched);
19011893 if (!*bio_is_patched) {
1902
- block->orig_bio_bh_private =
1894
+ block->orig_bio_private =
19031895 bio->bi_private;
1904
- block->orig_bio_bh_end_io.bio =
1896
+ block->orig_bio_end_io =
19051897 bio->bi_end_io;
19061898 block->next_in_same_bio = NULL;
19071899 bio->bi_private = block;
....@@ -1913,25 +1905,17 @@
19131905 bio->bi_private;
19141906
19151907 BUG_ON(NULL == chained_block);
1916
- block->orig_bio_bh_private =
1917
- chained_block->orig_bio_bh_private;
1918
- block->orig_bio_bh_end_io.bio =
1919
- chained_block->orig_bio_bh_end_io.
1920
- bio;
1908
+ block->orig_bio_private =
1909
+ chained_block->orig_bio_private;
1910
+ block->orig_bio_end_io =
1911
+ chained_block->orig_bio_end_io;
19211912 block->next_in_same_bio = chained_block;
19221913 bio->bi_private = block;
19231914 }
1924
- } else if (NULL != bh) {
1925
- block->is_iodone = 0;
1926
- block->orig_bio_bh_private = bh->b_private;
1927
- block->orig_bio_bh_end_io.bh = bh->b_end_io;
1928
- block->next_in_same_bio = NULL;
1929
- bh->b_private = block;
1930
- bh->b_end_io = btrfsic_bh_end_io;
19311915 } else {
19321916 block->is_iodone = 1;
1933
- block->orig_bio_bh_private = NULL;
1934
- block->orig_bio_bh_end_io.bio = NULL;
1917
+ block->orig_bio_private = NULL;
1918
+ block->orig_bio_end_io = NULL;
19351919 block->next_in_same_bio = NULL;
19361920 }
19371921 }
....@@ -2022,7 +2006,6 @@
20222006
20232007 block = btrfsic_block_alloc();
20242008 if (NULL == block) {
2025
- pr_info("btrfsic: error, kmalloc failed!\n");
20262009 btrfsic_release_block_ctx(&block_ctx);
20272010 goto continue_loop;
20282011 }
....@@ -2039,8 +2022,8 @@
20392022 block->is_iodone = 0;
20402023 BUG_ON(NULL == bio_is_patched);
20412024 if (!*bio_is_patched) {
2042
- block->orig_bio_bh_private = bio->bi_private;
2043
- block->orig_bio_bh_end_io.bio = bio->bi_end_io;
2025
+ block->orig_bio_private = bio->bi_private;
2026
+ block->orig_bio_end_io = bio->bi_end_io;
20442027 block->next_in_same_bio = NULL;
20452028 bio->bi_private = block;
20462029 bio->bi_end_io = btrfsic_bio_end_io;
....@@ -2051,24 +2034,17 @@
20512034 bio->bi_private;
20522035
20532036 BUG_ON(NULL == chained_block);
2054
- block->orig_bio_bh_private =
2055
- chained_block->orig_bio_bh_private;
2056
- block->orig_bio_bh_end_io.bio =
2057
- chained_block->orig_bio_bh_end_io.bio;
2037
+ block->orig_bio_private =
2038
+ chained_block->orig_bio_private;
2039
+ block->orig_bio_end_io =
2040
+ chained_block->orig_bio_end_io;
20582041 block->next_in_same_bio = chained_block;
20592042 bio->bi_private = block;
20602043 }
2061
- } else if (NULL != bh) {
2062
- block->is_iodone = 0;
2063
- block->orig_bio_bh_private = bh->b_private;
2064
- block->orig_bio_bh_end_io.bh = bh->b_end_io;
2065
- block->next_in_same_bio = NULL;
2066
- bh->b_private = block;
2067
- bh->b_end_io = btrfsic_bh_end_io;
20682044 } else {
20692045 block->is_iodone = 1;
2070
- block->orig_bio_bh_private = NULL;
2071
- block->orig_bio_bh_end_io.bio = NULL;
2046
+ block->orig_bio_private = NULL;
2047
+ block->orig_bio_end_io = NULL;
20722048 block->next_in_same_bio = NULL;
20732049 }
20742050 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE)
....@@ -2109,8 +2085,8 @@
21092085 iodone_w_error = 1;
21102086
21112087 BUG_ON(NULL == block);
2112
- bp->bi_private = block->orig_bio_bh_private;
2113
- bp->bi_end_io = block->orig_bio_bh_end_io.bio;
2088
+ bp->bi_private = block->orig_bio_private;
2089
+ bp->bi_end_io = block->orig_bio_end_io;
21142090
21152091 do {
21162092 struct btrfsic_block *next_block;
....@@ -2141,38 +2117,6 @@
21412117 } while (NULL != block);
21422118
21432119 bp->bi_end_io(bp);
2144
-}
2145
-
2146
-static void btrfsic_bh_end_io(struct buffer_head *bh, int uptodate)
2147
-{
2148
- struct btrfsic_block *block = (struct btrfsic_block *)bh->b_private;
2149
- int iodone_w_error = !uptodate;
2150
- struct btrfsic_dev_state *dev_state;
2151
-
2152
- BUG_ON(NULL == block);
2153
- dev_state = block->dev_state;
2154
- if ((dev_state->state->print_mask & BTRFSIC_PRINT_MASK_END_IO_BIO_BH))
2155
- pr_info("bh_end_io(error=%d) for %c @%llu (%s/%llu/%d)\n",
2156
- iodone_w_error,
2157
- btrfsic_get_block_type(dev_state->state, block),
2158
- block->logical_bytenr, block->dev_state->name,
2159
- block->dev_bytenr, block->mirror_num);
2160
-
2161
- block->iodone_w_error = iodone_w_error;
2162
- if (block->submit_bio_bh_rw & REQ_PREFLUSH) {
2163
- dev_state->last_flush_gen++;
2164
- if ((dev_state->state->print_mask &
2165
- BTRFSIC_PRINT_MASK_END_IO_BIO_BH))
2166
- pr_info("bh_end_io() new %s flush_gen=%llu\n",
2167
- dev_state->name, dev_state->last_flush_gen);
2168
- }
2169
- if (block->submit_bio_bh_rw & REQ_FUA)
2170
- block->flush_gen = 0; /* FUA completed means block is on disk */
2171
-
2172
- bh->b_private = block->orig_bio_bh_private;
2173
- bh->b_end_io = block->orig_bio_bh_end_io.bh;
2174
- block->is_iodone = 1; /* for FLUSH, this releases the block */
2175
- bh->b_end_io(bh, uptodate);
21762120 }
21772121
21782122 static int btrfsic_process_written_superblock(
....@@ -2282,7 +2226,6 @@
22822226 mirror_num,
22832227 &was_created);
22842228 if (NULL == next_block) {
2285
- pr_info("btrfsic: error, kmalloc failed!\n");
22862229 btrfsic_release_block_ctx(&tmp_next_block_ctx);
22872230 return -1;
22882231 }
....@@ -2326,7 +2269,7 @@
23262269 * write operations. Therefore it keeps the linkage
23272270 * information for a block until a block is
23282271 * rewritten. This can temporarily cause incorrect
2329
- * and even circular linkage informations. This
2272
+ * and even circular linkage information. This
23302273 * causes no harm unless such blocks are referenced
23312274 * by the most recent super block.
23322275 */
....@@ -2590,10 +2533,8 @@
25902533 &state->block_link_hashtable);
25912534 if (NULL == l) {
25922535 l = btrfsic_block_link_alloc();
2593
- if (NULL == l) {
2594
- pr_info("btrfsic: error, kmalloc failed!\n");
2536
+ if (!l)
25952537 return NULL;
2596
- }
25972538
25982539 l->block_ref_to = next_block;
25992540 l->block_ref_from = from_block;
....@@ -2637,10 +2578,9 @@
26372578 struct btrfsic_dev_state *dev_state;
26382579
26392580 block = btrfsic_block_alloc();
2640
- if (NULL == block) {
2641
- pr_info("btrfsic: error, kmalloc failed!\n");
2581
+ if (!block)
26422582 return NULL;
2643
- }
2583
+
26442584 dev_state = btrfsic_dev_state_lookup(block_ctx->dev->bdev->bd_dev);
26452585 if (NULL == dev_state) {
26462586 pr_info("btrfsic: error, lookup dev_state failed!\n");
....@@ -2727,63 +2667,6 @@
27272667 &btrfsic_dev_state_hashtable);
27282668 }
27292669
2730
-int btrfsic_submit_bh(int op, int op_flags, struct buffer_head *bh)
2731
-{
2732
- struct btrfsic_dev_state *dev_state;
2733
-
2734
- if (!btrfsic_is_initialized)
2735
- return submit_bh(op, op_flags, bh);
2736
-
2737
- mutex_lock(&btrfsic_mutex);
2738
- /* since btrfsic_submit_bh() might also be called before
2739
- * btrfsic_mount(), this might return NULL */
2740
- dev_state = btrfsic_dev_state_lookup(bh->b_bdev->bd_dev);
2741
-
2742
- /* Only called to write the superblock (incl. FLUSH/FUA) */
2743
- if (NULL != dev_state &&
2744
- (op == REQ_OP_WRITE) && bh->b_size > 0) {
2745
- u64 dev_bytenr;
2746
-
2747
- dev_bytenr = BTRFS_BDEV_BLOCKSIZE * bh->b_blocknr;
2748
- if (dev_state->state->print_mask &
2749
- BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
2750
- pr_info("submit_bh(op=0x%x,0x%x, blocknr=%llu (bytenr %llu), size=%zu, data=%p, bdev=%p)\n",
2751
- op, op_flags, (unsigned long long)bh->b_blocknr,
2752
- dev_bytenr, bh->b_size, bh->b_data, bh->b_bdev);
2753
- btrfsic_process_written_block(dev_state, dev_bytenr,
2754
- &bh->b_data, 1, NULL,
2755
- NULL, bh, op_flags);
2756
- } else if (NULL != dev_state && (op_flags & REQ_PREFLUSH)) {
2757
- if (dev_state->state->print_mask &
2758
- BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
2759
- pr_info("submit_bh(op=0x%x,0x%x FLUSH, bdev=%p)\n",
2760
- op, op_flags, bh->b_bdev);
2761
- if (!dev_state->dummy_block_for_bio_bh_flush.is_iodone) {
2762
- if ((dev_state->state->print_mask &
2763
- (BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH |
2764
- BTRFSIC_PRINT_MASK_VERBOSE)))
2765
- pr_info("btrfsic_submit_bh(%s) with FLUSH but dummy block already in use (ignored)!\n",
2766
- dev_state->name);
2767
- } else {
2768
- struct btrfsic_block *const block =
2769
- &dev_state->dummy_block_for_bio_bh_flush;
2770
-
2771
- block->is_iodone = 0;
2772
- block->never_written = 0;
2773
- block->iodone_w_error = 0;
2774
- block->flush_gen = dev_state->last_flush_gen + 1;
2775
- block->submit_bio_bh_rw = op_flags;
2776
- block->orig_bio_bh_private = bh->b_private;
2777
- block->orig_bio_bh_end_io.bh = bh->b_end_io;
2778
- block->next_in_same_bio = NULL;
2779
- bh->b_private = block;
2780
- bh->b_end_io = btrfsic_bh_end_io;
2781
- }
2782
- }
2783
- mutex_unlock(&btrfsic_mutex);
2784
- return submit_bh(op, op_flags, bh);
2785
-}
2786
-
27872670 static void __btrfsic_submit_bio(struct bio *bio)
27882671 {
27892672 struct btrfsic_dev_state *dev_state;
....@@ -2835,7 +2718,7 @@
28352718 btrfsic_process_written_block(dev_state, dev_bytenr,
28362719 mapped_datav, segs,
28372720 bio, &bio_is_patched,
2838
- NULL, bio->bi_opf);
2721
+ bio->bi_opf);
28392722 bio_for_each_segment(bvec, bio, iter)
28402723 kunmap(bvec.bv_page);
28412724 kfree(mapped_datav);
....@@ -2859,8 +2742,8 @@
28592742 block->iodone_w_error = 0;
28602743 block->flush_gen = dev_state->last_flush_gen + 1;
28612744 block->submit_bio_bh_rw = bio->bi_opf;
2862
- block->orig_bio_bh_private = bio->bi_private;
2863
- block->orig_bio_bh_end_io.bio = bio->bi_end_io;
2745
+ block->orig_bio_private = bio->bi_private;
2746
+ block->orig_bio_end_io = bio->bi_end_io;
28642747 block->next_in_same_bio = NULL;
28652748 bio->bi_private = block;
28662749 bio->bi_end_io = btrfsic_bio_end_io;
....@@ -2891,21 +2774,19 @@
28912774 struct list_head *dev_head = &fs_devices->devices;
28922775 struct btrfs_device *device;
28932776
2894
- if (fs_info->nodesize & ((u64)PAGE_SIZE - 1)) {
2777
+ if (!PAGE_ALIGNED(fs_info->nodesize)) {
28952778 pr_info("btrfsic: cannot handle nodesize %d not being a multiple of PAGE_SIZE %ld!\n",
28962779 fs_info->nodesize, PAGE_SIZE);
28972780 return -1;
28982781 }
2899
- if (fs_info->sectorsize & ((u64)PAGE_SIZE - 1)) {
2782
+ if (!PAGE_ALIGNED(fs_info->sectorsize)) {
29002783 pr_info("btrfsic: cannot handle sectorsize %d not being a multiple of PAGE_SIZE %ld!\n",
29012784 fs_info->sectorsize, PAGE_SIZE);
29022785 return -1;
29032786 }
29042787 state = kvzalloc(sizeof(*state), GFP_KERNEL);
2905
- if (!state) {
2906
- pr_info("btrfs check-integrity: allocation failed!\n");
2788
+ if (!state)
29072789 return -ENOMEM;
2908
- }
29092790
29102791 if (!btrfsic_is_initialized) {
29112792 mutex_init(&btrfsic_mutex);
....@@ -2934,7 +2815,6 @@
29342815
29352816 ds = btrfsic_dev_state_alloc();
29362817 if (NULL == ds) {
2937
- pr_info("btrfs check-integrity: kmalloc() failed!\n");
29382818 mutex_unlock(&btrfsic_mutex);
29392819 return -ENOMEM;
29402820 }