Commit f8f84b2d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

btrfs: index check-integrity state hash by a dev_t

We won't have the struct block_device available in the bio soon, so switch
to the numerical dev_t instead of the block_device pointer for looking up
the check-integrity state.
Reviewed-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 744353b6
...@@ -296,8 +296,7 @@ static void btrfsic_dev_state_hashtable_add( ...@@ -296,8 +296,7 @@ static void btrfsic_dev_state_hashtable_add(
struct btrfsic_dev_state *ds, struct btrfsic_dev_state *ds,
struct btrfsic_dev_state_hashtable *h); struct btrfsic_dev_state_hashtable *h);
static void btrfsic_dev_state_hashtable_remove(struct btrfsic_dev_state *ds); static void btrfsic_dev_state_hashtable_remove(struct btrfsic_dev_state *ds);
static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup( static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(dev_t dev,
struct block_device *bdev,
struct btrfsic_dev_state_hashtable *h); struct btrfsic_dev_state_hashtable *h);
static struct btrfsic_stack_frame *btrfsic_stack_frame_alloc(void); static struct btrfsic_stack_frame *btrfsic_stack_frame_alloc(void);
static void btrfsic_stack_frame_free(struct btrfsic_stack_frame *sf); static void btrfsic_stack_frame_free(struct btrfsic_stack_frame *sf);
...@@ -385,8 +384,7 @@ static int btrfsic_process_superblock_dev_mirror( ...@@ -385,8 +384,7 @@ static int btrfsic_process_superblock_dev_mirror(
int superblock_mirror_num, int superblock_mirror_num,
struct btrfsic_dev_state **selected_dev_state, struct btrfsic_dev_state **selected_dev_state,
struct btrfs_super_block *selected_super); struct btrfs_super_block *selected_super);
static struct btrfsic_dev_state *btrfsic_dev_state_lookup( static struct btrfsic_dev_state *btrfsic_dev_state_lookup(dev_t dev);
struct block_device *bdev);
static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state, static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state,
u64 bytenr, u64 bytenr,
struct btrfsic_dev_state *dev_state, struct btrfsic_dev_state *dev_state,
...@@ -626,17 +624,15 @@ static void btrfsic_dev_state_hashtable_remove(struct btrfsic_dev_state *ds) ...@@ -626,17 +624,15 @@ static void btrfsic_dev_state_hashtable_remove(struct btrfsic_dev_state *ds)
list_del(&ds->collision_resolving_node); list_del(&ds->collision_resolving_node);
} }
static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup( static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(dev_t dev,
struct block_device *bdev,
struct btrfsic_dev_state_hashtable *h) struct btrfsic_dev_state_hashtable *h)
{ {
const unsigned int hashval = const unsigned int hashval =
(((unsigned int)((uintptr_t)bdev)) & dev & (BTRFSIC_DEV2STATE_HASHTABLE_SIZE - 1);
(BTRFSIC_DEV2STATE_HASHTABLE_SIZE - 1));
struct btrfsic_dev_state *ds; struct btrfsic_dev_state *ds;
list_for_each_entry(ds, h->table + hashval, collision_resolving_node) { list_for_each_entry(ds, h->table + hashval, collision_resolving_node) {
if (ds->bdev == bdev) if (ds->bdev->bd_dev == dev)
return ds; return ds;
} }
...@@ -668,7 +664,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state, ...@@ -668,7 +664,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
if (!device->bdev || !device->name) if (!device->bdev || !device->name)
continue; continue;
dev_state = btrfsic_dev_state_lookup(device->bdev); dev_state = btrfsic_dev_state_lookup(device->bdev->bd_dev);
BUG_ON(NULL == dev_state); BUG_ON(NULL == dev_state);
for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) { for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
ret = btrfsic_process_superblock_dev_mirror( ret = btrfsic_process_superblock_dev_mirror(
...@@ -1556,7 +1552,7 @@ static int btrfsic_map_block(struct btrfsic_state *state, u64 bytenr, u32 len, ...@@ -1556,7 +1552,7 @@ static int btrfsic_map_block(struct btrfsic_state *state, u64 bytenr, u32 len,
} }
device = multi->stripes[0].dev; device = multi->stripes[0].dev;
block_ctx_out->dev = btrfsic_dev_state_lookup(device->bdev); block_ctx_out->dev = btrfsic_dev_state_lookup(device->bdev->bd_dev);
block_ctx_out->dev_bytenr = multi->stripes[0].physical; block_ctx_out->dev_bytenr = multi->stripes[0].physical;
block_ctx_out->start = bytenr; block_ctx_out->start = bytenr;
block_ctx_out->len = len; block_ctx_out->len = len;
...@@ -2654,7 +2650,7 @@ static struct btrfsic_block *btrfsic_block_lookup_or_add( ...@@ -2654,7 +2650,7 @@ static struct btrfsic_block *btrfsic_block_lookup_or_add(
pr_info("btrfsic: error, kmalloc failed!\n"); pr_info("btrfsic: error, kmalloc failed!\n");
return NULL; return NULL;
} }
dev_state = btrfsic_dev_state_lookup(block_ctx->dev->bdev); dev_state = btrfsic_dev_state_lookup(block_ctx->dev->bdev->bd_dev);
if (NULL == dev_state) { if (NULL == dev_state) {
pr_info("btrfsic: error, lookup dev_state failed!\n"); pr_info("btrfsic: error, lookup dev_state failed!\n");
btrfsic_block_free(block); btrfsic_block_free(block);
...@@ -2734,10 +2730,9 @@ static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state, ...@@ -2734,10 +2730,9 @@ static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state,
} }
} }
static struct btrfsic_dev_state *btrfsic_dev_state_lookup( static struct btrfsic_dev_state *btrfsic_dev_state_lookup(dev_t dev)
struct block_device *bdev)
{ {
return btrfsic_dev_state_hashtable_lookup(bdev, return btrfsic_dev_state_hashtable_lookup(dev,
&btrfsic_dev_state_hashtable); &btrfsic_dev_state_hashtable);
} }
...@@ -2751,7 +2746,7 @@ int btrfsic_submit_bh(int op, int op_flags, struct buffer_head *bh) ...@@ -2751,7 +2746,7 @@ int btrfsic_submit_bh(int op, int op_flags, struct buffer_head *bh)
mutex_lock(&btrfsic_mutex); mutex_lock(&btrfsic_mutex);
/* since btrfsic_submit_bh() might also be called before /* since btrfsic_submit_bh() might also be called before
* btrfsic_mount(), this might return NULL */ * btrfsic_mount(), this might return NULL */
dev_state = btrfsic_dev_state_lookup(bh->b_bdev); dev_state = btrfsic_dev_state_lookup(bh->b_bdev->bd_dev);
/* Only called to write the superblock (incl. FLUSH/FUA) */ /* Only called to write the superblock (incl. FLUSH/FUA) */
if (NULL != dev_state && if (NULL != dev_state &&
...@@ -2808,7 +2803,7 @@ static void __btrfsic_submit_bio(struct bio *bio) ...@@ -2808,7 +2803,7 @@ static void __btrfsic_submit_bio(struct bio *bio)
mutex_lock(&btrfsic_mutex); mutex_lock(&btrfsic_mutex);
/* since btrfsic_submit_bio() is also called before /* since btrfsic_submit_bio() is also called before
* btrfsic_mount(), this might return NULL */ * btrfsic_mount(), this might return NULL */
dev_state = btrfsic_dev_state_lookup(bio->bi_bdev); dev_state = btrfsic_dev_state_lookup(bio->bi_bdev->bd_dev);
if (NULL != dev_state && if (NULL != dev_state &&
(bio_op(bio) == REQ_OP_WRITE) && bio_has_data(bio)) { (bio_op(bio) == REQ_OP_WRITE) && bio_has_data(bio)) {
unsigned int i = 0; unsigned int i = 0;
...@@ -2998,7 +2993,7 @@ void btrfsic_unmount(struct btrfs_fs_devices *fs_devices) ...@@ -2998,7 +2993,7 @@ void btrfsic_unmount(struct btrfs_fs_devices *fs_devices)
continue; continue;
ds = btrfsic_dev_state_hashtable_lookup( ds = btrfsic_dev_state_hashtable_lookup(
device->bdev, device->bdev->bd_dev,
&btrfsic_dev_state_hashtable); &btrfsic_dev_state_hashtable);
if (NULL != ds) { if (NULL != ds) {
state = ds->state; state = ds->state;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment