mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 00:21:59 +00:00
bcache: use read_cache_page_gfp to read the superblock
Avoid a pointless dependency on buffer heads in bcache by simply open coding reading a single page. Also add a SB_OFFSET define for the byte offset of the superblock instead of using magic numbers. 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
475389ae5c
commit
6321bef028
@ -15,7 +15,6 @@
|
|||||||
#include "writeback.h"
|
#include "writeback.h"
|
||||||
|
|
||||||
#include <linux/blkdev.h>
|
#include <linux/blkdev.h>
|
||||||
#include <linux/buffer_head.h>
|
|
||||||
#include <linux/debugfs.h>
|
#include <linux/debugfs.h>
|
||||||
#include <linux/genhd.h>
|
#include <linux/genhd.h>
|
||||||
#include <linux/idr.h>
|
#include <linux/idr.h>
|
||||||
@ -64,13 +63,14 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
|
|||||||
{
|
{
|
||||||
const char *err;
|
const char *err;
|
||||||
struct cache_sb_disk *s;
|
struct cache_sb_disk *s;
|
||||||
struct buffer_head *bh = __bread(bdev, 1, SB_SIZE);
|
struct page *page;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (!bh)
|
page = read_cache_page_gfp(bdev->bd_inode->i_mapping,
|
||||||
|
SB_OFFSET >> PAGE_SHIFT, GFP_KERNEL);
|
||||||
|
if (IS_ERR(page))
|
||||||
return "IO error";
|
return "IO error";
|
||||||
|
s = page_address(page) + offset_in_page(SB_OFFSET);
|
||||||
s = (struct cache_sb_disk *)bh->b_data;
|
|
||||||
|
|
||||||
sb->offset = le64_to_cpu(s->offset);
|
sb->offset = le64_to_cpu(s->offset);
|
||||||
sb->version = le64_to_cpu(s->version);
|
sb->version = le64_to_cpu(s->version);
|
||||||
@ -188,12 +188,10 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
sb->last_mount = (u32)ktime_get_real_seconds();
|
sb->last_mount = (u32)ktime_get_real_seconds();
|
||||||
err = NULL;
|
|
||||||
|
|
||||||
get_page(bh->b_page);
|
|
||||||
*res = s;
|
*res = s;
|
||||||
|
return NULL;
|
||||||
err:
|
err:
|
||||||
put_bh(bh);
|
put_page(page);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +148,7 @@ static inline struct bkey *bkey_idx(const struct bkey *k, unsigned int nr_keys)
|
|||||||
#define BCACHE_SB_MAX_VERSION 4
|
#define BCACHE_SB_MAX_VERSION 4
|
||||||
|
|
||||||
#define SB_SECTOR 8
|
#define SB_SECTOR 8
|
||||||
|
#define SB_OFFSET (SB_SECTOR << SECTOR_SHIFT)
|
||||||
#define SB_SIZE 4096
|
#define SB_SIZE 4096
|
||||||
#define SB_LABEL_SIZE 32
|
#define SB_LABEL_SIZE 32
|
||||||
#define SB_JOURNAL_BUCKETS 256U
|
#define SB_JOURNAL_BUCKETS 256U
|
||||||
|
Loading…
Reference in New Issue
Block a user