forked from Minki/linux
bcache: transfer the sb_page reference to register_{bdev,cache}
Avoid an extra reference count roundtrip by transferring the sb_page ownership to the lower level register helpers. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Coly Li <colyli@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
ae3cd29991
commit
fc8f19cc5d
@ -1368,8 +1368,6 @@ static int register_bdev(struct cache_sb *sb, struct page *sb_page,
|
|||||||
|
|
||||||
bio_init(&dc->sb_bio, dc->sb_bio.bi_inline_vecs, 1);
|
bio_init(&dc->sb_bio, dc->sb_bio.bi_inline_vecs, 1);
|
||||||
bio_first_bvec_all(&dc->sb_bio)->bv_page = sb_page;
|
bio_first_bvec_all(&dc->sb_bio)->bv_page = sb_page;
|
||||||
get_page(sb_page);
|
|
||||||
|
|
||||||
|
|
||||||
if (cached_dev_init(dc, sb->block_size << 9))
|
if (cached_dev_init(dc, sb->block_size << 9))
|
||||||
goto err;
|
goto err;
|
||||||
@ -2275,7 +2273,6 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page,
|
|||||||
|
|
||||||
bio_init(&ca->sb_bio, ca->sb_bio.bi_inline_vecs, 1);
|
bio_init(&ca->sb_bio, ca->sb_bio.bi_inline_vecs, 1);
|
||||||
bio_first_bvec_all(&ca->sb_bio)->bv_page = sb_page;
|
bio_first_bvec_all(&ca->sb_bio)->bv_page = sb_page;
|
||||||
get_page(sb_page);
|
|
||||||
|
|
||||||
if (blk_queue_discard(bdev_get_queue(bdev)))
|
if (blk_queue_discard(bdev_get_queue(bdev)))
|
||||||
ca->discard = CACHE_DISCARD(&ca->sb);
|
ca->discard = CACHE_DISCARD(&ca->sb);
|
||||||
@ -2378,7 +2375,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
|
|||||||
const char *err;
|
const char *err;
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
struct cache_sb *sb;
|
struct cache_sb *sb;
|
||||||
struct block_device *bdev = NULL;
|
struct block_device *bdev;
|
||||||
struct page *sb_page;
|
struct page *sb_page;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
@ -2444,10 +2441,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
|
|||||||
ret = register_bdev(sb, sb_page, bdev, dc);
|
ret = register_bdev(sb, sb_page, bdev, dc);
|
||||||
mutex_unlock(&bch_register_lock);
|
mutex_unlock(&bch_register_lock);
|
||||||
/* blkdev_put() will be called in cached_dev_free() */
|
/* blkdev_put() will be called in cached_dev_free() */
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
bdev = NULL;
|
goto out_free_sb;
|
||||||
goto out_put_sb_page;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
struct cache *ca = kzalloc(sizeof(*ca), GFP_KERNEL);
|
struct cache *ca = kzalloc(sizeof(*ca), GFP_KERNEL);
|
||||||
|
|
||||||
@ -2455,13 +2450,10 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
|
|||||||
goto out_put_sb_page;
|
goto out_put_sb_page;
|
||||||
|
|
||||||
/* blkdev_put() will be called in bch_cache_release() */
|
/* blkdev_put() will be called in bch_cache_release() */
|
||||||
if (register_cache(sb, sb_page, bdev, ca) != 0) {
|
if (register_cache(sb, sb_page, bdev, ca) != 0)
|
||||||
bdev = NULL;
|
goto out_free_sb;
|
||||||
goto out_put_sb_page;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
put_page(sb_page);
|
|
||||||
done:
|
done:
|
||||||
kfree(sb);
|
kfree(sb);
|
||||||
kfree(path);
|
kfree(path);
|
||||||
@ -2471,7 +2463,6 @@ done:
|
|||||||
out_put_sb_page:
|
out_put_sb_page:
|
||||||
put_page(sb_page);
|
put_page(sb_page);
|
||||||
out_blkdev_put:
|
out_blkdev_put:
|
||||||
if (bdev)
|
|
||||||
blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
|
blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
|
||||||
out_free_sb:
|
out_free_sb:
|
||||||
kfree(sb);
|
kfree(sb);
|
||||||
|
Loading…
Reference in New Issue
Block a user