Merge branch 'for-linus' of git://neil.brown.name/md

* 'for-linus' of git://neil.brown.name/md: (34 commits)
  md: Fix some bugs in recovery_disabled handling.
  md/raid5: fix bug that could result in reads from a failed device.
  lib/raid6: Fix filename emitted in generated code
  md.c: trivial comment fix
  MD: Allow restarting an interrupted incremental recovery.
  md: clear In_sync bit on devices added to an active array.
  md: add proper write-congestion reporting to RAID1 and RAID10.
  md: rename "mdk_personality" to "md_personality"
  md/bitmap remove fault injection options.
  md/raid5: typedef removal: raid5_conf_t -> struct r5conf
  md/raid1: typedef removal: conf_t -> struct r1conf
  md/raid10: typedef removal: conf_t -> struct r10conf
  md/raid0: typedef removal: raid0_conf_t -> struct r0conf
  md/multipath: typedef removal: multipath_conf_t -> struct mpconf
  md/linear: typedef removal: linear_conf_t -> struct linear_conf
  md/faulty: remove typedef: conf_t -> struct faulty_conf
  md/linear: remove typedefs: dev_info_t -> struct dev_info
  md: remove typedefs: mirror_info_t -> struct mirror_info
  md: remove typedefs: r10bio_t -> struct r10bio and r1bio_t -> struct r1bio
  md: remove typedefs: mdk_thread_t -> struct md_thread
  ...
This commit is contained in:
Linus Torvalds 2011-10-26 21:39:42 +02:00
commit c3ae1f3356
19 changed files with 1216 additions and 1272 deletions

View File

@ -29,35 +29,6 @@
#include "md.h"
#include "bitmap.h"
/* debug macros */
#define DEBUG 0
#if DEBUG
/* these are for debugging purposes only! */
/* define one and only one of these */
#define INJECT_FAULTS_1 0 /* cause bitmap_alloc_page to fail always */
#define INJECT_FAULTS_2 0 /* cause bitmap file to be kicked when first bit set*/
#define INJECT_FAULTS_3 0 /* treat bitmap file as kicked at init time */
#define INJECT_FAULTS_4 0 /* undef */
#define INJECT_FAULTS_5 0 /* undef */
#define INJECT_FAULTS_6 0
/* if these are defined, the driver will fail! debug only */
#define INJECT_FATAL_FAULT_1 0 /* fail kmalloc, causing bitmap_create to fail */
#define INJECT_FATAL_FAULT_2 0 /* undef */
#define INJECT_FATAL_FAULT_3 0 /* undef */
#endif
#ifndef PRINTK
# if DEBUG > 0
# define PRINTK(x...) printk(KERN_DEBUG x)
# else
# define PRINTK(x...)
# endif
#endif
static inline char *bmname(struct bitmap *bitmap)
{
return bitmap->mddev ? mdname(bitmap->mddev) : "mdX";
@ -70,16 +41,12 @@ static unsigned char *bitmap_alloc_page(struct bitmap *bitmap)
{
unsigned char *page;
#ifdef INJECT_FAULTS_1
page = NULL;
#else
page = kzalloc(PAGE_SIZE, GFP_NOIO);
#endif
if (!page)
printk("%s: bitmap_alloc_page FAILED\n", bmname(bitmap));
else
PRINTK("%s: bitmap_alloc_page: allocated page at %p\n",
bmname(bitmap), page);
pr_debug("%s: bitmap_alloc_page: allocated page at %p\n",
bmname(bitmap), page);
return page;
}
@ -88,7 +55,7 @@ static unsigned char *bitmap_alloc_page(struct bitmap *bitmap)
*/
static void bitmap_free_page(struct bitmap *bitmap, unsigned char *page)
{
PRINTK("%s: bitmap_free_page: free page %p\n", bmname(bitmap), page);
pr_debug("%s: bitmap_free_page: free page %p\n", bmname(bitmap), page);
kfree(page);
}
@ -133,8 +100,8 @@ __acquires(bitmap->lock)
spin_lock_irq(&bitmap->lock);
if (mappage == NULL) {
PRINTK("%s: bitmap map page allocation failed, hijacking\n",
bmname(bitmap));
pr_debug("%s: bitmap map page allocation failed, hijacking\n",
bmname(bitmap));
/* failed - set the hijacked flag so that we can use the
* pointer as a counter */
if (!bitmap->bp[page].map)
@ -187,13 +154,13 @@ static void bitmap_checkfree(struct bitmap *bitmap, unsigned long page)
*/
/* IO operations when bitmap is stored near all superblocks */
static struct page *read_sb_page(mddev_t *mddev, loff_t offset,
static struct page *read_sb_page(struct mddev *mddev, loff_t offset,
struct page *page,
unsigned long index, int size)
{
/* choose a good rdev and read the page from there */
mdk_rdev_t *rdev;
struct md_rdev *rdev;
sector_t target;
int did_alloc = 0;
@ -226,7 +193,7 @@ static struct page *read_sb_page(mddev_t *mddev, loff_t offset,
}
static mdk_rdev_t *next_active_rdev(mdk_rdev_t *rdev, mddev_t *mddev)
static struct md_rdev *next_active_rdev(struct md_rdev *rdev, struct mddev *mddev)
{
/* Iterate the disks of an mddev, using rcu to protect access to the
* linked list, and raising the refcount of devices we return to ensure
@ -247,7 +214,7 @@ static mdk_rdev_t *next_active_rdev(mdk_rdev_t *rdev, mddev_t *mddev)
pos = &rdev->same_set;
}
list_for_each_continue_rcu(pos, &mddev->disks) {
rdev = list_entry(pos, mdk_rdev_t, same_set);
rdev = list_entry(pos, struct md_rdev, same_set);
if (rdev->raid_disk >= 0 &&
!test_bit(Faulty, &rdev->flags)) {
/* this is a usable devices */
@ -262,9 +229,9 @@ static mdk_rdev_t *next_active_rdev(mdk_rdev_t *rdev, mddev_t *mddev)
static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
{
mdk_rdev_t *rdev = NULL;
struct md_rdev *rdev = NULL;
struct block_device *bdev;
mddev_t *mddev = bitmap->mddev;
struct mddev *mddev = bitmap->mddev;
while ((rdev = next_active_rdev(rdev, mddev)) != NULL) {
int size = PAGE_SIZE;
@ -409,8 +376,8 @@ static struct page *read_page(struct file *file, unsigned long index,
struct buffer_head *bh;
sector_t block;
PRINTK("read bitmap file (%dB @ %llu)\n", (int)PAGE_SIZE,
(unsigned long long)index << PAGE_SHIFT);
pr_debug("read bitmap file (%dB @ %llu)\n", (int)PAGE_SIZE,
(unsigned long long)index << PAGE_SHIFT);
page = alloc_page(GFP_KERNEL);
if (!page)
@ -868,7 +835,8 @@ static void bitmap_file_kick(struct bitmap *bitmap)
enum bitmap_page_attr {
BITMAP_PAGE_DIRTY = 0, /* there are set bits that need to be synced */
BITMAP_PAGE_CLEAN = 1, /* there are bits that might need to be cleared */
BITMAP_PAGE_PENDING = 1, /* there are bits that are being cleaned.
* i.e. counter is 1 or 2. */
BITMAP_PAGE_NEEDWRITE = 2, /* there are cleared bits that need to be synced */
};
@ -919,7 +887,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
else
__set_bit_le(bit, kaddr);
kunmap_atomic(kaddr, KM_USER0);
PRINTK("set file bit %lu page %lu\n", bit, page->index);
pr_debug("set file bit %lu page %lu\n", bit, page->index);
/* record page number so it gets flushed to disk when unplug occurs */
set_page_attr(bitmap, page, BITMAP_PAGE_DIRTY);
}
@ -997,11 +965,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
BUG_ON(!file && !bitmap->mddev->bitmap_info.offset);
#ifdef INJECT_FAULTS_3
outofdate = 1;
#else
outofdate = bitmap->flags & BITMAP_STALE;
#endif
if (outofdate)
printk(KERN_INFO "%s: bitmap file is out of date, doing full "
"recovery\n", bmname(bitmap));
@ -1111,7 +1075,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
(sector_t)i << CHUNK_BLOCK_SHIFT(bitmap),
needed);
bit_cnt++;
set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
}
}
@ -1146,6 +1109,7 @@ void bitmap_write_all(struct bitmap *bitmap)
for (i = 0; i < bitmap->file_pages; i++)
set_page_attr(bitmap, bitmap->filemap[i],
BITMAP_PAGE_NEEDWRITE);
bitmap->allclean = 0;
}
static void bitmap_count_page(struct bitmap *bitmap, sector_t offset, int inc)
@ -1164,7 +1128,7 @@ static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap,
* out to disk
*/
void bitmap_daemon_work(mddev_t *mddev)
void bitmap_daemon_work(struct mddev *mddev)
{
struct bitmap *bitmap;
unsigned long j;
@ -1204,17 +1168,15 @@ void bitmap_daemon_work(mddev_t *mddev)
if (page != lastpage) {
/* skip this page unless it's marked as needing cleaning */
if (!test_page_attr(bitmap, page, BITMAP_PAGE_CLEAN)) {
if (!test_page_attr(bitmap, page, BITMAP_PAGE_PENDING)) {
int need_write = test_page_attr(bitmap, page,
BITMAP_PAGE_NEEDWRITE);
if (need_write)
clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
spin_unlock_irqrestore(&bitmap->lock, flags);
if (need_write) {
if (need_write)
write_page(bitmap, page, 0);
bitmap->allclean = 0;
}
spin_lock_irqsave(&bitmap->lock, flags);
j |= (PAGE_BITS - 1);
continue;
@ -1222,12 +1184,16 @@ void bitmap_daemon_work(mddev_t *mddev)
/* grab the new page, sync and release the old */
if (lastpage != NULL) {
if (test_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE)) {
clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
if (test_page_attr(bitmap, lastpage,
BITMAP_PAGE_NEEDWRITE)) {
clear_page_attr(bitmap, lastpage,
BITMAP_PAGE_NEEDWRITE);
spin_unlock_irqrestore(&bitmap->lock, flags);
write_page(bitmap, lastpage, 0);
} else {
set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
set_page_attr(bitmap, lastpage,
BITMAP_PAGE_NEEDWRITE);
bitmap->allclean = 0;
spin_unlock_irqrestore(&bitmap->lock, flags);
}
} else
@ -1249,19 +1215,17 @@ void bitmap_daemon_work(mddev_t *mddev)
}
spin_lock_irqsave(&bitmap->lock, flags);
if (!bitmap->need_sync)
clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
clear_page_attr(bitmap, page, BITMAP_PAGE_PENDING);
else
bitmap->allclean = 0;
}
bmc = bitmap_get_counter(bitmap,
(sector_t)j << CHUNK_BLOCK_SHIFT(bitmap),
&blocks, 0);
if (bmc) {
if (*bmc)
bitmap->allclean = 0;
if (*bmc == 2) {
*bmc = 1; /* maybe clear the bit next time */
set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
} else if (*bmc == 1 && !bitmap->need_sync) {
if (!bmc)
j |= PAGE_COUNTER_MASK;
else if (*bmc) {
if (*bmc == 1 && !bitmap->need_sync) {
/* we can clear the bit */
*bmc = 0;
bitmap_count_page(bitmap,
@ -1275,13 +1239,16 @@ void bitmap_daemon_work(mddev_t *mddev)
paddr);
else
__clear_bit_le(
file_page_offset(bitmap,
j),
paddr);
file_page_offset(bitmap,
j),
paddr);
kunmap_atomic(paddr, KM_USER0);
} else if (*bmc <= 2) {
*bmc = 1; /* maybe clear the bit next time */
set_page_attr(bitmap, page, BITMAP_PAGE_PENDING);
bitmap->allclean = 0;
}
} else
j |= PAGE_COUNTER_MASK;
}
}
spin_unlock_irqrestore(&bitmap->lock, flags);
@ -1294,6 +1261,7 @@ void bitmap_daemon_work(mddev_t *mddev)
write_page(bitmap, lastpage, 0);
} else {
set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
bitmap->allclean = 0;
spin_unlock_irqrestore(&bitmap->lock, flags);
}
}
@ -1359,8 +1327,8 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
if (bw > bitmap->behind_writes_used)
bitmap->behind_writes_used = bw;
PRINTK(KERN_DEBUG "inc write-behind count %d/%d\n",
bw, bitmap->max_write_behind);
pr_debug("inc write-behind count %d/%lu\n",
bw, bitmap->mddev->bitmap_info.max_write_behind);
}
while (sectors) {
@ -1407,7 +1375,6 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
else
sectors = 0;
}
bitmap->allclean = 0;
return 0;
}
EXPORT_SYMBOL(bitmap_startwrite);
@ -1420,8 +1387,9 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
if (behind) {
if (atomic_dec_and_test(&bitmap->behind_writes))
wake_up(&bitmap->behind_wait);
PRINTK(KERN_DEBUG "dec write-behind count %d/%d\n",
atomic_read(&bitmap->behind_writes), bitmap->max_write_behind);
pr_debug("dec write-behind count %d/%lu\n",
atomic_read(&bitmap->behind_writes),
bitmap->mddev->bitmap_info.max_write_behind);
}
if (bitmap->mddev->degraded)
/* Never clear bits or update events_cleared when degraded */
@ -1453,13 +1421,14 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
wake_up(&bitmap->overflow_wait);
(*bmc)--;
if (*bmc <= 2)
if (*bmc <= 2) {
set_page_attr(bitmap,
filemap_get_page(
bitmap,
offset >> CHUNK_BLOCK_SHIFT(bitmap)),
BITMAP_PAGE_CLEAN);
BITMAP_PAGE_PENDING);
bitmap->allclean = 0;
}
spin_unlock_irqrestore(&bitmap->lock, flags);
offset += blocks;
if (sectors > blocks)
@ -1495,7 +1464,6 @@ static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t
}
}
spin_unlock_irq(&bitmap->lock);
bitmap->allclean = 0;
return rv;
}
@ -1543,15 +1511,16 @@ void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, i
if (!NEEDED(*bmc) && aborted)
*bmc |= NEEDED_MASK;
else {
if (*bmc <= 2)
if (*bmc <= 2) {
set_page_attr(bitmap,
filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap)),
BITMAP_PAGE_CLEAN);
BITMAP_PAGE_PENDING);
bitmap->allclean = 0;
}
}
}
unlock:
spin_unlock_irqrestore(&bitmap->lock, flags);
bitmap->allclean = 0;
}
EXPORT_SYMBOL(bitmap_end_sync);
@ -1622,10 +1591,10 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n
*bmc = 1 | (needed ? NEEDED_MASK : 0);
bitmap_count_page(bitmap, offset, 1);
page = filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap));
set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
set_page_attr(bitmap, page, BITMAP_PAGE_PENDING);
bitmap->allclean = 0;
}
spin_unlock_irq(&bitmap->lock);
bitmap->allclean = 0;
}
/* dirty the memory and file bits for bitmap chunks "s" to "e" */
@ -1649,7 +1618,7 @@ void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
/*
* flush out any pending updates
*/
void bitmap_flush(mddev_t *mddev)
void bitmap_flush(struct mddev *mddev)
{
struct bitmap *bitmap = mddev->bitmap;
long sleep;
@ -1697,7 +1666,7 @@ static void bitmap_free(struct bitmap *bitmap)
kfree(bitmap);
}
void bitmap_destroy(mddev_t *mddev)
void bitmap_destroy(struct mddev *mddev)
{
struct bitmap *bitmap = mddev->bitmap;
@ -1720,7 +1689,7 @@ void bitmap_destroy(mddev_t *mddev)
* initialize the bitmap structure
* if this returns an error, bitmap_destroy must be called to do clean up
*/
int bitmap_create(mddev_t *mddev)
int bitmap_create(struct mddev *mddev)
{
struct bitmap *bitmap;
sector_t blocks = mddev->resync_max_sectors;
@ -1802,11 +1771,8 @@ int bitmap_create(mddev_t *mddev)
bitmap->pages = pages;
bitmap->missing_pages = pages;
#ifdef INJECT_FATAL_FAULT_1
bitmap->bp = NULL;
#else
bitmap->bp = kzalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL);
#endif
err = -ENOMEM;
if (!bitmap->bp)
goto error;
@ -1824,7 +1790,7 @@ int bitmap_create(mddev_t *mddev)
return err;
}
int bitmap_load(mddev_t *mddev)
int bitmap_load(struct mddev *mddev)
{
int err = 0;
sector_t start = 0;
@ -1870,7 +1836,7 @@ out:
EXPORT_SYMBOL_GPL(bitmap_load);
static ssize_t
location_show(mddev_t *mddev, char *page)
location_show(struct mddev *mddev, char *page)
{
ssize_t len;
if (mddev->bitmap_info.file)
@ -1884,7 +1850,7 @@ location_show(mddev_t *mddev, char *page)
}
static ssize_t
location_store(mddev_t *mddev, const char *buf, size_t len)
location_store(struct mddev *mddev, const char *buf, size_t len)
{
if (mddev->pers) {
@ -1961,7 +1927,7 @@ static struct md_sysfs_entry bitmap_location =
__ATTR(location, S_IRUGO|S_IWUSR, location_show, location_store);
static ssize_t
timeout_show(mddev_t *mddev, char *page)
timeout_show(struct mddev *mddev, char *page)
{
ssize_t len;
unsigned long secs = mddev->bitmap_info.daemon_sleep / HZ;
@ -1975,7 +1941,7 @@ timeout_show(mddev_t *mddev, char *page)
}
static ssize_t
timeout_store(mddev_t *mddev, const char *buf, size_t len)
timeout_store(struct mddev *mddev, const char *buf, size_t len)
{
/* timeout can be set at any time */
unsigned long timeout;
@ -2011,13 +1977,13 @@ static struct md_sysfs_entry bitmap_timeout =
__ATTR(time_base, S_IRUGO|S_IWUSR, timeout_show, timeout_store);
static ssize_t
backlog_show(mddev_t *mddev, char *page)
backlog_show(struct mddev *mddev, char *page)
{
return sprintf(page, "%lu\n", mddev->bitmap_info.max_write_behind);
}
static ssize_t
backlog_store(mddev_t *mddev, const char *buf, size_t len)
backlog_store(struct mddev *mddev, const char *buf, size_t len)
{
unsigned long backlog;
int rv = strict_strtoul(buf, 10, &backlog);
@ -2033,13 +1999,13 @@ static struct md_sysfs_entry bitmap_backlog =
__ATTR(backlog, S_IRUGO|S_IWUSR, backlog_show, backlog_store);
static ssize_t
chunksize_show(mddev_t *mddev, char *page)
chunksize_show(struct mddev *mddev, char *page)
{
return sprintf(page, "%lu\n", mddev->bitmap_info.chunksize);
}
static ssize_t
chunksize_store(mddev_t *mddev, const char *buf, size_t len)
chunksize_store(struct mddev *mddev, const char *buf, size_t len)
{
/* Can only be changed when no bitmap is active */
int rv;
@ -2059,13 +2025,13 @@ chunksize_store(mddev_t *mddev, const char *buf, size_t len)
static struct md_sysfs_entry bitmap_chunksize =
__ATTR(chunksize, S_IRUGO|S_IWUSR, chunksize_show, chunksize_store);
static ssize_t metadata_show(mddev_t *mddev, char *page)
static ssize_t metadata_show(struct mddev *mddev, char *page)
{
return sprintf(page, "%s\n", (mddev->bitmap_info.external
? "external" : "internal"));
}
static ssize_t metadata_store(mddev_t *mddev, const char *buf, size_t len)
static ssize_t metadata_store(struct mddev *mddev, const char *buf, size_t len)
{
if (mddev->bitmap ||
mddev->bitmap_info.file ||
@ -2083,7 +2049,7 @@ static ssize_t metadata_store(mddev_t *mddev, const char *buf, size_t len)
static struct md_sysfs_entry bitmap_metadata =
__ATTR(metadata, S_IRUGO|S_IWUSR, metadata_show, metadata_store);
static ssize_t can_clear_show(mddev_t *mddev, char *page)
static ssize_t can_clear_show(struct mddev *mddev, char *page)
{
int len;
if (mddev->bitmap)
@ -2094,7 +2060,7 @@ static ssize_t can_clear_show(mddev_t *mddev, char *page)
return len;
}
static ssize_t can_clear_store(mddev_t *mddev, const char *buf, size_t len)
static ssize_t can_clear_store(struct mddev *mddev, const char *buf, size_t len)
{
if (mddev->bitmap == NULL)
return -ENOENT;
@ -2113,7 +2079,7 @@ static struct md_sysfs_entry bitmap_can_clear =
__ATTR(can_clear, S_IRUGO|S_IWUSR, can_clear_show, can_clear_store);
static ssize_t
behind_writes_used_show(mddev_t *mddev, char *page)
behind_writes_used_show(struct mddev *mddev, char *page)
{
if (mddev->bitmap == NULL)
return sprintf(page, "0\n");
@ -2122,7 +2088,7 @@ behind_writes_used_show(mddev_t *mddev, char *page)
}
static ssize_t
behind_writes_used_reset(mddev_t *mddev, const char *buf, size_t len)
behind_writes_used_reset(struct mddev *mddev, const char *buf, size_t len)
{
if (mddev->bitmap)
mddev->bitmap->behind_writes_used = 0;

View File

@ -193,7 +193,7 @@ struct bitmap {
unsigned long pages; /* total number of pages in the bitmap */
unsigned long missing_pages; /* number of pages not yet allocated */
mddev_t *mddev; /* the md device that the bitmap is for */
struct mddev *mddev; /* the md device that the bitmap is for */
/* bitmap chunksize -- how much data does each bit represent? */
unsigned long chunkshift; /* chunksize = 2^chunkshift (for bitops) */
@ -238,10 +238,10 @@ struct bitmap {
/* the bitmap API */
/* these are used only by md/bitmap */
int bitmap_create(mddev_t *mddev);
int bitmap_load(mddev_t *mddev);
void bitmap_flush(mddev_t *mddev);
void bitmap_destroy(mddev_t *mddev);
int bitmap_create(struct mddev *mddev);
int bitmap_load(struct mddev *mddev);
void bitmap_flush(struct mddev *mddev);
void bitmap_destroy(struct mddev *mddev);
void bitmap_print_sb(struct bitmap *bitmap);
void bitmap_update_sb(struct bitmap *bitmap);
@ -262,7 +262,7 @@ void bitmap_close_sync(struct bitmap *bitmap);
void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector);
void bitmap_unplug(struct bitmap *bitmap);
void bitmap_daemon_work(mddev_t *mddev);
void bitmap_daemon_work(struct mddev *mddev);
#endif
#endif

View File

@ -37,7 +37,7 @@ struct raid_dev {
*/
struct dm_dev *meta_dev;
struct dm_dev *data_dev;
struct mdk_rdev_s rdev;
struct md_rdev rdev;
};
/*
@ -57,7 +57,7 @@ struct raid_set {
uint64_t print_flags;
struct mddev_s md;
struct mddev md;
struct raid_type *raid_type;
struct dm_target_callbacks callbacks;
@ -594,7 +594,7 @@ struct dm_raid_superblock {
/* Always set to 0 when writing. */
} __packed;
static int read_disk_sb(mdk_rdev_t *rdev, int size)
static int read_disk_sb(struct md_rdev *rdev, int size)
{
BUG_ON(!rdev->sb_page);
@ -611,9 +611,9 @@ static int read_disk_sb(mdk_rdev_t *rdev, int size)
return 0;
}
static void super_sync(mddev_t *mddev, mdk_rdev_t *rdev)
static void super_sync(struct mddev *mddev, struct md_rdev *rdev)
{
mdk_rdev_t *r, *t;
struct md_rdev *r, *t;
uint64_t failed_devices;
struct dm_raid_superblock *sb;
@ -651,7 +651,7 @@ static void super_sync(mddev_t *mddev, mdk_rdev_t *rdev)
*
* Return: 1 if use rdev, 0 if use refdev, -Exxx otherwise
*/
static int super_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev)
static int super_load(struct md_rdev *rdev, struct md_rdev *refdev)
{
int ret;
struct dm_raid_superblock *sb;
@ -689,7 +689,7 @@ static int super_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev)
return (events_sb > events_refsb) ? 1 : 0;
}
static int super_init_validation(mddev_t *mddev, mdk_rdev_t *rdev)
static int super_init_validation(struct mddev *mddev, struct md_rdev *rdev)
{
int role;
struct raid_set *rs = container_of(mddev, struct raid_set, md);
@ -698,7 +698,7 @@ static int super_init_validation(mddev_t *mddev, mdk_rdev_t *rdev)
struct dm_raid_superblock *sb;
uint32_t new_devs = 0;
uint32_t rebuilds = 0;
mdk_rdev_t *r, *t;
struct md_rdev *r, *t;
struct dm_raid_superblock *sb2;
sb = page_address(rdev->sb_page);
@ -809,7 +809,7 @@ static int super_init_validation(mddev_t *mddev, mdk_rdev_t *rdev)
return 0;
}
static int super_validate(mddev_t *mddev, mdk_rdev_t *rdev)
static int super_validate(struct mddev *mddev, struct md_rdev *rdev)
{
struct dm_raid_superblock *sb = page_address(rdev->sb_page);
@ -849,8 +849,8 @@ static int super_validate(mddev_t *mddev, mdk_rdev_t *rdev)
static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
{
int ret;
mdk_rdev_t *rdev, *freshest, *tmp;
mddev_t *mddev = &rs->md;
struct md_rdev *rdev, *freshest, *tmp;
struct mddev *mddev = &rs->md;
freshest = NULL;
rdev_for_each(rdev, tmp, mddev) {
@ -1004,7 +1004,7 @@ static void raid_dtr(struct dm_target *ti)
static int raid_map(struct dm_target *ti, struct bio *bio, union map_info *map_context)
{
struct raid_set *rs = ti->private;
mddev_t *mddev = &rs->md;
struct mddev *mddev = &rs->md;
mddev->pers->make_request(mddev, bio);
@ -1097,7 +1097,7 @@ static int raid_status(struct dm_target *ti, status_type_t type,
rs->md.bitmap_info.max_write_behind);
if (rs->print_flags & DMPF_STRIPE_CACHE) {
raid5_conf_t *conf = rs->md.private;
struct r5conf *conf = rs->md.private;
/* convert from kiB to sectors */
DMEMIT(" stripe_cache %d",
@ -1146,7 +1146,7 @@ static void raid_io_hints(struct dm_target *ti, struct queue_limits *limits)
{
struct raid_set *rs = ti->private;
unsigned chunk_size = rs->md.chunk_sectors << 9;
raid5_conf_t *conf = rs->md.private;
struct r5conf *conf = rs->md.private;
blk_limits_io_min(limits, chunk_size);
blk_limits_io_opt(limits, chunk_size * (conf->raid_disks - conf->max_degraded));

View File

@ -81,16 +81,16 @@ static void faulty_fail(struct bio *bio, int error)
bio_io_error(b);
}
typedef struct faulty_conf {
struct faulty_conf {
int period[Modes];
atomic_t counters[Modes];
sector_t faults[MaxFault];
int modes[MaxFault];
int nfaults;
mdk_rdev_t *rdev;
} conf_t;
struct md_rdev *rdev;
};
static int check_mode(conf_t *conf, int mode)
static int check_mode(struct faulty_conf *conf, int mode)
{
if (conf->period[mode] == 0 &&
atomic_read(&conf->counters[mode]) <= 0)
@ -105,7 +105,7 @@ static int check_mode(conf_t *conf, int mode)
return 0;
}
static int check_sector(conf_t *conf, sector_t start, sector_t end, int dir)
static int check_sector(struct faulty_conf *conf, sector_t start, sector_t end, int dir)
{
/* If we find a ReadFixable sector, we fix it ... */
int i;
@ -129,7 +129,7 @@ static int check_sector(conf_t *conf, sector_t start, sector_t end, int dir)
return 0;
}
static void add_sector(conf_t *conf, sector_t start, int mode)
static void add_sector(struct faulty_conf *conf, sector_t start, int mode)
{
int i;
int n = conf->nfaults;
@ -169,9 +169,9 @@ static void add_sector(conf_t *conf, sector_t start, int mode)
conf->nfaults = n+1;
}
static int make_request(mddev_t *mddev, struct bio *bio)
static int make_request(struct mddev *mddev, struct bio *bio)
{
conf_t *conf = mddev->private;
struct faulty_conf *conf = mddev->private;
int failit = 0;
if (bio_data_dir(bio) == WRITE) {
@ -222,9 +222,9 @@ static int make_request(mddev_t *mddev, struct bio *bio)
}
}
static void status(struct seq_file *seq, mddev_t *mddev)
static void status(struct seq_file *seq, struct mddev *mddev)
{
conf_t *conf = mddev->private;
struct faulty_conf *conf = mddev->private;
int n;
if ((n=atomic_read(&conf->counters[WriteTransient])) != 0)
@ -255,11 +255,11 @@ static void status(struct seq_file *seq, mddev_t *mddev)
}
static int reshape(mddev_t *mddev)
static int reshape(struct mddev *mddev)
{
int mode = mddev->new_layout & ModeMask;
int count = mddev->new_layout >> ModeShift;
conf_t *conf = mddev->private;
struct faulty_conf *conf = mddev->private;
if (mddev->new_layout < 0)
return 0;
@ -284,7 +284,7 @@ static int reshape(mddev_t *mddev)
return 0;
}
static sector_t faulty_size(mddev_t *mddev, sector_t sectors, int raid_disks)
static sector_t faulty_size(struct mddev *mddev, sector_t sectors, int raid_disks)
{
WARN_ONCE(raid_disks,
"%s does not support generic reshape\n", __func__);
@ -295,11 +295,11 @@ static sector_t faulty_size(mddev_t *mddev, sector_t sectors, int raid_disks)
return sectors;
}
static int run(mddev_t *mddev)
static int run(struct mddev *mddev)
{
mdk_rdev_t *rdev;
struct md_rdev *rdev;
int i;
conf_t *conf;
struct faulty_conf *conf;
if (md_check_no_bitmap(mddev))
return -EINVAL;
@ -325,16 +325,16 @@ static int run(mddev_t *mddev)
return 0;
}
static int stop(mddev_t *mddev)
static int stop(struct mddev *mddev)
{
conf_t *conf = mddev->private;
struct faulty_conf *conf = mddev->private;
kfree(conf);
mddev->private = NULL;
return 0;
}
static struct mdk_personality faulty_personality =
static struct md_personality faulty_personality =
{
.name = "faulty",
.level = LEVEL_FAULTY,

View File

@ -26,10 +26,10 @@
/*
* find which device holds a particular offset
*/
static inline dev_info_t *which_dev(mddev_t *mddev, sector_t sector)
static inline struct dev_info *which_dev(struct mddev *mddev, sector_t sector)
{
int lo, mid, hi;
linear_conf_t *conf;
struct linear_conf *conf;
lo = 0;
hi = mddev->raid_disks - 1;
@ -63,8 +63,8 @@ static int linear_mergeable_bvec(struct request_queue *q,
struct bvec_merge_data *bvm,
struct bio_vec *biovec)
{
mddev_t *mddev = q->queuedata;
dev_info_t *dev0;
struct mddev *mddev = q->queuedata;
struct dev_info *dev0;
unsigned long maxsectors, bio_sectors = bvm->bi_size >> 9;
sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
@ -89,8 +89,8 @@ static int linear_mergeable_bvec(struct request_queue *q,
static int linear_congested(void *data, int bits)
{
mddev_t *mddev = data;
linear_conf_t *conf;
struct mddev *mddev = data;
struct linear_conf *conf;
int i, ret = 0;
if (mddev_congested(mddev, bits))
@ -108,9 +108,9 @@ static int linear_congested(void *data, int bits)
return ret;
}
static sector_t linear_size(mddev_t *mddev, sector_t sectors, int raid_disks)
static sector_t linear_size(struct mddev *mddev, sector_t sectors, int raid_disks)
{
linear_conf_t *conf;
struct linear_conf *conf;
sector_t array_sectors;
rcu_read_lock();
@ -123,13 +123,13 @@ static sector_t linear_size(mddev_t *mddev, sector_t sectors, int raid_disks)
return array_sectors;
}
static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
static struct linear_conf *linear_conf(struct mddev *mddev, int raid_disks)
{
linear_conf_t *conf;
mdk_rdev_t *rdev;
struct linear_conf *conf;
struct md_rdev *rdev;
int i, cnt;
conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(dev_info_t),
conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(struct dev_info),
GFP_KERNEL);
if (!conf)
return NULL;
@ -139,7 +139,7 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
list_for_each_entry(rdev, &mddev->disks, same_set) {
int j = rdev->raid_disk;
dev_info_t *disk = conf->disks + j;
struct dev_info *disk = conf->disks + j;
sector_t sectors;
if (j < 0 || j >= raid_disks || disk->rdev) {
@ -194,9 +194,9 @@ out:
return NULL;
}
static int linear_run (mddev_t *mddev)
static int linear_run (struct mddev *mddev)
{
linear_conf_t *conf;
struct linear_conf *conf;
if (md_check_no_bitmap(mddev))
return -EINVAL;
@ -213,7 +213,7 @@ static int linear_run (mddev_t *mddev)
return md_integrity_register(mddev);
}
static int linear_add(mddev_t *mddev, mdk_rdev_t *rdev)
static int linear_add(struct mddev *mddev, struct md_rdev *rdev)
{
/* Adding a drive to a linear array allows the array to grow.
* It is permitted if the new drive has a matching superblock
@ -223,7 +223,7 @@ static int linear_add(mddev_t *mddev, mdk_rdev_t *rdev)
* The current one is never freed until the array is stopped.
* This avoids races.
*/
linear_conf_t *newconf, *oldconf;
struct linear_conf *newconf, *oldconf;
if (rdev->saved_raid_disk != mddev->raid_disks)
return -EINVAL;
@ -245,9 +245,9 @@ static int linear_add(mddev_t *mddev, mdk_rdev_t *rdev)
return 0;
}
static int linear_stop (mddev_t *mddev)
static int linear_stop (struct mddev *mddev)
{
linear_conf_t *conf = mddev->private;
struct linear_conf *conf = mddev->private;
/*
* We do not require rcu protection here since
@ -264,9 +264,9 @@ static int linear_stop (mddev_t *mddev)
return 0;
}
static int linear_make_request (mddev_t *mddev, struct bio *bio)
static int linear_make_request (struct mddev *mddev, struct bio *bio)
{
dev_info_t *tmp_dev;
struct dev_info *tmp_dev;
sector_t start_sector;
if (unlikely(bio->bi_rw & REQ_FLUSH)) {
@ -323,14 +323,14 @@ static int linear_make_request (mddev_t *mddev, struct bio *bio)
return 1;
}
static void linear_status (struct seq_file *seq, mddev_t *mddev)
static void linear_status (struct seq_file *seq, struct mddev *mddev)
{
seq_printf(seq, " %dk rounding", mddev->chunk_sectors / 2);
}
static struct mdk_personality linear_personality =
static struct md_personality linear_personality =
{
.name = "linear",
.level = LEVEL_LINEAR,

View File

@ -2,20 +2,14 @@
#define _LINEAR_H
struct dev_info {
mdk_rdev_t *rdev;
struct md_rdev *rdev;
sector_t end_sector;
};
typedef struct dev_info dev_info_t;
struct linear_private_data
struct linear_conf
{
struct rcu_head rcu;
sector_t array_sectors;
dev_info_t disks[0];
struct dev_info disks[0];
};
typedef struct linear_private_data linear_conf_t;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
md_k.h : kernel internal structure of the Linux MD driver
md.h : kernel internal structure of the Linux MD driver
Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman
This program is free software; you can redistribute it and/or modify
@ -26,9 +26,6 @@
#define MaxSector (~(sector_t)0)
typedef struct mddev_s mddev_t;
typedef struct mdk_rdev_s mdk_rdev_t;
/* Bad block numbers are stored sorted in a single page.
* 64bits is used for each block or extent.
* 54 bits are sector number, 9 bits are extent size,
@ -39,12 +36,11 @@ typedef struct mdk_rdev_s mdk_rdev_t;
/*
* MD's 'extended' device
*/
struct mdk_rdev_s
{
struct md_rdev {
struct list_head same_set; /* RAID devices within the same set */
sector_t sectors; /* Device size (in 512bytes sectors) */
mddev_t *mddev; /* RAID array if running */
struct mddev *mddev; /* RAID array if running */
int last_events; /* IO event timestamp */
/*
@ -168,7 +164,7 @@ struct mdk_rdev_s
extern int md_is_badblock(struct badblocks *bb, sector_t s, int sectors,
sector_t *first_bad, int *bad_sectors);
static inline int is_badblock(mdk_rdev_t *rdev, sector_t s, int sectors,
static inline int is_badblock(struct md_rdev *rdev, sector_t s, int sectors,
sector_t *first_bad, int *bad_sectors)
{
if (unlikely(rdev->badblocks.count)) {
@ -181,15 +177,14 @@ static inline int is_badblock(mdk_rdev_t *rdev, sector_t s, int sectors,
}
return 0;
}
extern int rdev_set_badblocks(mdk_rdev_t *rdev, sector_t s, int sectors,
extern int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
int acknowledged);
extern int rdev_clear_badblocks(mdk_rdev_t *rdev, sector_t s, int sectors);
extern int rdev_clear_badblocks(struct md_rdev *rdev, sector_t s, int sectors);
extern void md_ack_all_badblocks(struct badblocks *bb);
struct mddev_s
{
struct mddev {
void *private;
struct mdk_personality *pers;
struct md_personality *pers;
dev_t unit;
int md_minor;
struct list_head disks;
@ -256,8 +251,8 @@ struct mddev_s
atomic_t plug_cnt; /* If device is expecting
* more bios soon.
*/
struct mdk_thread_s *thread; /* management thread */
struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */
struct md_thread *thread; /* management thread */
struct md_thread *sync_thread; /* doing resync or reconstruct */
sector_t curr_resync; /* last block scheduled */
/* As resync requests can complete out of order, we cannot easily track
* how much resync has been completed. So we occasionally pause until
@ -402,11 +397,11 @@ struct mddev_s
atomic_t flush_pending;
struct work_struct flush_work;
struct work_struct event_work; /* used by dm to report failure event */
void (*sync_super)(mddev_t *mddev, mdk_rdev_t *rdev);
void (*sync_super)(struct mddev *mddev, struct md_rdev *rdev);
};
static inline void rdev_dec_pending(mdk_rdev_t *rdev, mddev_t *mddev)
static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
{
int faulty = test_bit(Faulty, &rdev->flags);
if (atomic_dec_and_test(&rdev->nr_pending) && faulty)
@ -418,35 +413,35 @@ static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sect
atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
}
struct mdk_personality
struct md_personality
{
char *name;
int level;
struct list_head list;
struct module *owner;
int (*make_request)(mddev_t *mddev, struct bio *bio);
int (*run)(mddev_t *mddev);
int (*stop)(mddev_t *mddev);
void (*status)(struct seq_file *seq, mddev_t *mddev);
int (*make_request)(struct mddev *mddev, struct bio *bio);
int (*run)(struct mddev *mddev);
int (*stop)(struct mddev *mddev);
void (*status)(struct seq_file *seq, struct mddev *mddev);
/* error_handler must set ->faulty and clear ->in_sync
* if appropriate, and should abort recovery if needed
*/
void (*error_handler)(mddev_t *mddev, mdk_rdev_t *rdev);
int (*hot_add_disk) (mddev_t *mddev, mdk_rdev_t *rdev);
int (*hot_remove_disk) (mddev_t *mddev, int number);
int (*spare_active) (mddev_t *mddev);
sector_t (*sync_request)(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster);
int (*resize) (mddev_t *mddev, sector_t sectors);
sector_t (*size) (mddev_t *mddev, sector_t sectors, int raid_disks);
int (*check_reshape) (mddev_t *mddev);
int (*start_reshape) (mddev_t *mddev);
void (*finish_reshape) (mddev_t *mddev);
void (*error_handler)(struct mddev *mddev, struct md_rdev *rdev);
int (*hot_add_disk) (struct mddev *mddev, struct md_rdev *rdev);
int (*hot_remove_disk) (struct mddev *mddev, int number);
int (*spare_active) (struct mddev *mddev);
sector_t (*sync_request)(struct mddev *mddev, sector_t sector_nr, int *skipped, int go_faster);
int (*resize) (struct mddev *mddev, sector_t sectors);
sector_t (*size) (struct mddev *mddev, sector_t sectors, int raid_disks);
int (*check_reshape) (struct mddev *mddev);
int (*start_reshape) (struct mddev *mddev);
void (*finish_reshape) (struct mddev *mddev);
/* quiesce moves between quiescence states
* 0 - fully active
* 1 - no new requests allowed
* others - reserved
*/
void (*quiesce) (mddev_t *mddev, int state);
void (*quiesce) (struct mddev *mddev, int state);
/* takeover is used to transition an array from one
* personality to another. The new personality must be able
* to handle the data in the current layout.
@ -456,14 +451,14 @@ struct mdk_personality
* This needs to be installed and then ->run used to activate the
* array.
*/
void *(*takeover) (mddev_t *mddev);
void *(*takeover) (struct mddev *mddev);
};
struct md_sysfs_entry {
struct attribute attr;
ssize_t (*show)(mddev_t *, char *);
ssize_t (*store)(mddev_t *, const char *, size_t);
ssize_t (*show)(struct mddev *, char *);
ssize_t (*store)(struct mddev *, const char *, size_t);
};
extern struct attribute_group md_bitmap_group;
@ -479,19 +474,19 @@ static inline void sysfs_notify_dirent_safe(struct sysfs_dirent *sd)
sysfs_notify_dirent(sd);
}
static inline char * mdname (mddev_t * mddev)
static inline char * mdname (struct mddev * mddev)
{
return mddev->gendisk ? mddev->gendisk->disk_name : "mdX";
}
static inline int sysfs_link_rdev(mddev_t *mddev, mdk_rdev_t *rdev)
static inline int sysfs_link_rdev(struct mddev *mddev, struct md_rdev *rdev)
{
char nm[20];
sprintf(nm, "rd%d", rdev->raid_disk);
return sysfs_create_link(&mddev->kobj, &rdev->kobj, nm);
}
static inline void sysfs_unlink_rdev(mddev_t *mddev, mdk_rdev_t *rdev)
static inline void sysfs_unlink_rdev(struct mddev *mddev, struct md_rdev *rdev)
{
char nm[20];
sprintf(nm, "rd%d", rdev->raid_disk);
@ -514,14 +509,14 @@ static inline void sysfs_unlink_rdev(mddev_t *mddev, mdk_rdev_t *rdev)
#define rdev_for_each_rcu(rdev, mddev) \
list_for_each_entry_rcu(rdev, &((mddev)->disks), same_set)
typedef struct mdk_thread_s {
void (*run) (mddev_t *mddev);
mddev_t *mddev;
struct md_thread {
void (*run) (struct mddev *mddev);
struct mddev *mddev;
wait_queue_head_t wqueue;
unsigned long flags;
struct task_struct *tsk;
unsigned long timeout;
} mdk_thread_t;
};
#define THREAD_WAKEUP 0
@ -556,48 +551,50 @@ static inline void safe_put_page(struct page *p)
if (p) put_page(p);
}
extern int register_md_personality(struct mdk_personality *p);
extern int unregister_md_personality(struct mdk_personality *p);
extern mdk_thread_t * md_register_thread(void (*run) (mddev_t *mddev),
mddev_t *mddev, const char *name);
extern void md_unregister_thread(mdk_thread_t **threadp);
extern void md_wakeup_thread(mdk_thread_t *thread);
extern void md_check_recovery(mddev_t *mddev);
extern void md_write_start(mddev_t *mddev, struct bio *bi);
extern void md_write_end(mddev_t *mddev);
extern void md_done_sync(mddev_t *mddev, int blocks, int ok);
extern void md_error(mddev_t *mddev, mdk_rdev_t *rdev);
extern int register_md_personality(struct md_personality *p);
extern int unregister_md_personality(struct md_personality *p);
extern struct md_thread *md_register_thread(
void (*run)(struct mddev *mddev),
struct mddev *mddev,
const char *name);
extern void md_unregister_thread(struct md_thread **threadp);
extern void md_wakeup_thread(struct md_thread *thread);
extern void md_check_recovery(struct mddev *mddev);
extern void md_write_start(struct mddev *mddev, struct bio *bi);
extern void md_write_end(struct mddev *mddev);
extern void md_done_sync(struct mddev *mddev, int blocks, int ok);
extern void md_error(struct mddev *mddev, struct md_rdev *rdev);
extern int mddev_congested(mddev_t *mddev, int bits);
extern void md_flush_request(mddev_t *mddev, struct bio *bio);
extern void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev,
extern int mddev_congested(struct mddev *mddev, int bits);
extern void md_flush_request(struct mddev *mddev, struct bio *bio);
extern void md_super_write(struct mddev *mddev, struct md_rdev *rdev,
sector_t sector, int size, struct page *page);
extern void md_super_wait(mddev_t *mddev);
extern int sync_page_io(mdk_rdev_t *rdev, sector_t sector, int size,
extern void md_super_wait(struct mddev *mddev);
extern int sync_page_io(struct md_rdev *rdev, sector_t sector, int size,
struct page *page, int rw, bool metadata_op);
extern void md_do_sync(mddev_t *mddev);
extern void md_new_event(mddev_t *mddev);
extern int md_allow_write(mddev_t *mddev);
extern void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev);
extern void md_set_array_sectors(mddev_t *mddev, sector_t array_sectors);
extern int md_check_no_bitmap(mddev_t *mddev);
extern int md_integrity_register(mddev_t *mddev);
extern void md_integrity_add_rdev(mdk_rdev_t *rdev, mddev_t *mddev);
extern void md_do_sync(struct mddev *mddev);
extern void md_new_event(struct mddev *mddev);
extern int md_allow_write(struct mddev *mddev);
extern void md_wait_for_blocked_rdev(struct md_rdev *rdev, struct mddev *mddev);
extern void md_set_array_sectors(struct mddev *mddev, sector_t array_sectors);
extern int md_check_no_bitmap(struct mddev *mddev);
extern int md_integrity_register(struct mddev *mddev);
extern void md_integrity_add_rdev(struct md_rdev *rdev, struct mddev *mddev);
extern int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale);
extern void restore_bitmap_write_access(struct file *file);
extern void mddev_init(mddev_t *mddev);
extern int md_run(mddev_t *mddev);
extern void md_stop(mddev_t *mddev);
extern void md_stop_writes(mddev_t *mddev);
extern int md_rdev_init(mdk_rdev_t *rdev);
extern void mddev_init(struct mddev *mddev);
extern int md_run(struct mddev *mddev);
extern void md_stop(struct mddev *mddev);
extern void md_stop_writes(struct mddev *mddev);
extern int md_rdev_init(struct md_rdev *rdev);
extern void mddev_suspend(mddev_t *mddev);
extern void mddev_resume(mddev_t *mddev);
extern void mddev_suspend(struct mddev *mddev);
extern void mddev_resume(struct mddev *mddev);
extern struct bio *bio_clone_mddev(struct bio *bio, gfp_t gfp_mask,
mddev_t *mddev);
struct mddev *mddev);
extern struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs,
mddev_t *mddev);
extern int mddev_check_plugged(mddev_t *mddev);
struct mddev *mddev);
extern int mddev_check_plugged(struct mddev *mddev);
extern void md_trim_bio(struct bio *bio, int offset, int size);
#endif /* _MD_MD_H */

View File

@ -31,7 +31,7 @@
#define NR_RESERVED_BUFS 32
static int multipath_map (multipath_conf_t *conf)
static int multipath_map (struct mpconf *conf)
{
int i, disks = conf->raid_disks;
@ -42,7 +42,7 @@ static int multipath_map (multipath_conf_t *conf)
rcu_read_lock();
for (i = 0; i < disks; i++) {
mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev);
struct md_rdev *rdev = rcu_dereference(conf->multipaths[i].rdev);
if (rdev && test_bit(In_sync, &rdev->flags)) {
atomic_inc(&rdev->nr_pending);
rcu_read_unlock();
@ -58,8 +58,8 @@ static int multipath_map (multipath_conf_t *conf)
static void multipath_reschedule_retry (struct multipath_bh *mp_bh)
{
unsigned long flags;
mddev_t *mddev = mp_bh->mddev;
multipath_conf_t *conf = mddev->private;
struct mddev *mddev = mp_bh->mddev;
struct mpconf *conf = mddev->private;
spin_lock_irqsave(&conf->device_lock, flags);
list_add(&mp_bh->retry_list, &conf->retry_list);
@ -76,7 +76,7 @@ static void multipath_reschedule_retry (struct multipath_bh *mp_bh)
static void multipath_end_bh_io (struct multipath_bh *mp_bh, int err)
{
struct bio *bio = mp_bh->master_bio;
multipath_conf_t *conf = mp_bh->mddev->private;
struct mpconf *conf = mp_bh->mddev->private;
bio_endio(bio, err);
mempool_free(mp_bh, conf->pool);
@ -86,8 +86,8 @@ static void multipath_end_request(struct bio *bio, int error)
{
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
struct multipath_bh *mp_bh = bio->bi_private;
multipath_conf_t *conf = mp_bh->mddev->private;
mdk_rdev_t *rdev = conf->multipaths[mp_bh->path].rdev;
struct mpconf *conf = mp_bh->mddev->private;
struct md_rdev *rdev = conf->multipaths[mp_bh->path].rdev;
if (uptodate)
multipath_end_bh_io(mp_bh, 0);
@ -106,9 +106,9 @@ static void multipath_end_request(struct bio *bio, int error)
rdev_dec_pending(rdev, conf->mddev);
}
static int multipath_make_request(mddev_t *mddev, struct bio * bio)
static int multipath_make_request(struct mddev *mddev, struct bio * bio)
{
multipath_conf_t *conf = mddev->private;
struct mpconf *conf = mddev->private;
struct multipath_bh * mp_bh;
struct multipath_info *multipath;
@ -140,9 +140,9 @@ static int multipath_make_request(mddev_t *mddev, struct bio * bio)
return 0;
}
static void multipath_status (struct seq_file *seq, mddev_t *mddev)
static void multipath_status (struct seq_file *seq, struct mddev *mddev)
{
multipath_conf_t *conf = mddev->private;
struct mpconf *conf = mddev->private;
int i;
seq_printf (seq, " [%d/%d] [", conf->raid_disks,
@ -156,8 +156,8 @@ static void multipath_status (struct seq_file *seq, mddev_t *mddev)
static int multipath_congested(void *data, int bits)
{
mddev_t *mddev = data;
multipath_conf_t *conf = mddev->private;
struct mddev *mddev = data;
struct mpconf *conf = mddev->private;
int i, ret = 0;
if (mddev_congested(mddev, bits))
@ -165,7 +165,7 @@ static int multipath_congested(void *data, int bits)
rcu_read_lock();
for (i = 0; i < mddev->raid_disks ; i++) {
mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev);
struct md_rdev *rdev = rcu_dereference(conf->multipaths[i].rdev);
if (rdev && !test_bit(Faulty, &rdev->flags)) {
struct request_queue *q = bdev_get_queue(rdev->bdev);
@ -183,9 +183,9 @@ static int multipath_congested(void *data, int bits)
/*
* Careful, this can execute in IRQ contexts as well!
*/
static void multipath_error (mddev_t *mddev, mdk_rdev_t *rdev)
static void multipath_error (struct mddev *mddev, struct md_rdev *rdev)
{
multipath_conf_t *conf = mddev->private;
struct mpconf *conf = mddev->private;
char b[BDEVNAME_SIZE];
if (conf->raid_disks - mddev->degraded <= 1) {
@ -218,7 +218,7 @@ static void multipath_error (mddev_t *mddev, mdk_rdev_t *rdev)
conf->raid_disks - mddev->degraded);
}
static void print_multipath_conf (multipath_conf_t *conf)
static void print_multipath_conf (struct mpconf *conf)
{
int i;
struct multipath_info *tmp;
@ -242,9 +242,9 @@ static void print_multipath_conf (multipath_conf_t *conf)
}
static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
static int multipath_add_disk(struct mddev *mddev, struct md_rdev *rdev)
{
multipath_conf_t *conf = mddev->private;
struct mpconf *conf = mddev->private;
struct request_queue *q;
int err = -EEXIST;
int path;
@ -291,11 +291,11 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
return err;
}
static int multipath_remove_disk(mddev_t *mddev, int number)
static int multipath_remove_disk(struct mddev *mddev, int number)
{
multipath_conf_t *conf = mddev->private;
struct mpconf *conf = mddev->private;
int err = 0;
mdk_rdev_t *rdev;
struct md_rdev *rdev;
struct multipath_info *p = conf->multipaths + number;
print_multipath_conf(conf);
@ -335,12 +335,12 @@ abort:
* 3. Performs writes following reads for array syncronising.
*/
static void multipathd (mddev_t *mddev)
static void multipathd (struct mddev *mddev)
{
struct multipath_bh *mp_bh;
struct bio *bio;
unsigned long flags;
multipath_conf_t *conf = mddev->private;
struct mpconf *conf = mddev->private;
struct list_head *head = &conf->retry_list;
md_check_recovery(mddev);
@ -379,7 +379,7 @@ static void multipathd (mddev_t *mddev)
spin_unlock_irqrestore(&conf->device_lock, flags);
}
static sector_t multipath_size(mddev_t *mddev, sector_t sectors, int raid_disks)
static sector_t multipath_size(struct mddev *mddev, sector_t sectors, int raid_disks)
{
WARN_ONCE(sectors || raid_disks,
"%s does not support generic reshape\n", __func__);
@ -387,12 +387,12 @@ static sector_t multipath_size(mddev_t *mddev, sector_t sectors, int raid_disks)
return mddev->dev_sectors;
}
static int multipath_run (mddev_t *mddev)
static int multipath_run (struct mddev *mddev)
{
multipath_conf_t *conf;
struct mpconf *conf;
int disk_idx;
struct multipath_info *disk;
mdk_rdev_t *rdev;
struct md_rdev *rdev;
int working_disks;
if (md_check_no_bitmap(mddev))
@ -409,7 +409,7 @@ static int multipath_run (mddev_t *mddev)
* should be freed in multipath_stop()]
*/
conf = kzalloc(sizeof(multipath_conf_t), GFP_KERNEL);
conf = kzalloc(sizeof(struct mpconf), GFP_KERNEL);
mddev->private = conf;
if (!conf) {
printk(KERN_ERR
@ -510,9 +510,9 @@ out:
}
static int multipath_stop (mddev_t *mddev)
static int multipath_stop (struct mddev *mddev)
{
multipath_conf_t *conf = mddev->private;
struct mpconf *conf = mddev->private;
md_unregister_thread(&mddev->thread);
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
@ -523,7 +523,7 @@ static int multipath_stop (mddev_t *mddev)
return 0;
}
static struct mdk_personality multipath_personality =
static struct md_personality multipath_personality =
{
.name = "multipath",
.level = LEVEL_MULTIPATH,

View File

@ -2,11 +2,11 @@
#define _MULTIPATH_H
struct multipath_info {
mdk_rdev_t *rdev;
struct md_rdev *rdev;
};
struct multipath_private_data {
mddev_t *mddev;
struct mpconf {
struct mddev *mddev;
struct multipath_info *multipaths;
int raid_disks;
spinlock_t device_lock;
@ -15,8 +15,6 @@ struct multipath_private_data {
mempool_t *pool;
};
typedef struct multipath_private_data multipath_conf_t;
/*
* this is our 'private' 'collective' MULTIPATH buffer head.
* it contains information about what kind of IO operations were started
@ -24,7 +22,7 @@ typedef struct multipath_private_data multipath_conf_t;
*/
struct multipath_bh {
mddev_t *mddev;
struct mddev *mddev;
struct bio *master_bio;
struct bio bio;
int path;

View File

@ -27,9 +27,9 @@
static int raid0_congested(void *data, int bits)
{
mddev_t *mddev = data;
raid0_conf_t *conf = mddev->private;
mdk_rdev_t **devlist = conf->devlist;
struct mddev *mddev = data;
struct r0conf *conf = mddev->private;
struct md_rdev **devlist = conf->devlist;
int raid_disks = conf->strip_zone[0].nb_dev;
int i, ret = 0;
@ -47,52 +47,53 @@ static int raid0_congested(void *data, int bits)
/*
* inform the user of the raid configuration
*/
static void dump_zones(mddev_t *mddev)
static void dump_zones(struct mddev *mddev)
{
int j, k, h;
int j, k;
sector_t zone_size = 0;
sector_t zone_start = 0;
char b[BDEVNAME_SIZE];
raid0_conf_t *conf = mddev->private;
struct r0conf *conf = mddev->private;
int raid_disks = conf->strip_zone[0].nb_dev;
printk(KERN_INFO "******* %s configuration *********\n",
mdname(mddev));
h = 0;
printk(KERN_INFO "md: RAID0 configuration for %s - %d zone%s\n",
mdname(mddev),
conf->nr_strip_zones, conf->nr_strip_zones==1?"":"s");
for (j = 0; j < conf->nr_strip_zones; j++) {
printk(KERN_INFO "zone%d=[", j);
printk(KERN_INFO "md: zone%d=[", j);
for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
printk(KERN_CONT "%s/",
printk(KERN_CONT "%s%s", k?"/":"",
bdevname(conf->devlist[j*raid_disks
+ k]->bdev, b));
printk(KERN_CONT "]\n");
zone_size = conf->strip_zone[j].zone_end - zone_start;
printk(KERN_INFO " zone offset=%llukb "
"device offset=%llukb size=%llukb\n",
printk(KERN_INFO " zone-offset=%10lluKB, "
"device-offset=%10lluKB, size=%10lluKB\n",
(unsigned long long)zone_start>>1,
(unsigned long long)conf->strip_zone[j].dev_start>>1,
(unsigned long long)zone_size>>1);
zone_start = conf->strip_zone[j].zone_end;
}
printk(KERN_INFO "**********************************\n\n");
printk(KERN_INFO "\n");
}
static int create_strip_zones(mddev_t *mddev, raid0_conf_t **private_conf)
static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
{
int i, c, err;
sector_t curr_zone_end, sectors;
mdk_rdev_t *smallest, *rdev1, *rdev2, *rdev, **dev;
struct md_rdev *smallest, *rdev1, *rdev2, *rdev, **dev;
struct strip_zone *zone;
int cnt;
char b[BDEVNAME_SIZE];
raid0_conf_t *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
char b2[BDEVNAME_SIZE];
struct r0conf *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
if (!conf)
return -ENOMEM;
list_for_each_entry(rdev1, &mddev->disks, same_set) {
printk(KERN_INFO "md/raid0:%s: looking at %s\n",
mdname(mddev),
bdevname(rdev1->bdev, b));
pr_debug("md/raid0:%s: looking at %s\n",
mdname(mddev),
bdevname(rdev1->bdev, b));
c = 0;
/* round size to chunk_size */
@ -101,16 +102,16 @@ static int create_strip_zones(mddev_t *mddev, raid0_conf_t **private_conf)
rdev1->sectors = sectors * mddev->chunk_sectors;
list_for_each_entry(rdev2, &mddev->disks, same_set) {
printk(KERN_INFO "md/raid0:%s: comparing %s(%llu)",
mdname(mddev),
bdevname(rdev1->bdev,b),
(unsigned long long)rdev1->sectors);
printk(KERN_CONT " with %s(%llu)\n",
bdevname(rdev2->bdev,b),
(unsigned long long)rdev2->sectors);
pr_debug("md/raid0:%s: comparing %s(%llu)"
" with %s(%llu)\n",
mdname(mddev),
bdevname(rdev1->bdev,b),
(unsigned long long)rdev1->sectors,
bdevname(rdev2->bdev,b2),
(unsigned long long)rdev2->sectors);
if (rdev2 == rdev1) {
printk(KERN_INFO "md/raid0:%s: END\n",
mdname(mddev));
pr_debug("md/raid0:%s: END\n",
mdname(mddev));
break;
}
if (rdev2->sectors == rdev1->sectors) {
@ -118,30 +119,30 @@ static int create_strip_zones(mddev_t *mddev, raid0_conf_t **private_conf)
* Not unique, don't count it as a new
* group
*/
printk(KERN_INFO "md/raid0:%s: EQUAL\n",
mdname(mddev));
pr_debug("md/raid0:%s: EQUAL\n",
mdname(mddev));
c = 1;
break;
}
printk(KERN_INFO "md/raid0:%s: NOT EQUAL\n",
mdname(mddev));
pr_debug("md/raid0:%s: NOT EQUAL\n",
mdname(mddev));
}
if (!c) {
printk(KERN_INFO "md/raid0:%s: ==> UNIQUE\n",
mdname(mddev));
pr_debug("md/raid0:%s: ==> UNIQUE\n",
mdname(mddev));
conf->nr_strip_zones++;
printk(KERN_INFO "md/raid0:%s: %d zones\n",
mdname(mddev), conf->nr_strip_zones);
pr_debug("md/raid0:%s: %d zones\n",
mdname(mddev), conf->nr_strip_zones);
}
}
printk(KERN_INFO "md/raid0:%s: FINAL %d zones\n",
mdname(mddev), conf->nr_strip_zones);
pr_debug("md/raid0:%s: FINAL %d zones\n",
mdname(mddev), conf->nr_strip_zones);
err = -ENOMEM;
conf->strip_zone = kzalloc(sizeof(struct strip_zone)*
conf->nr_strip_zones, GFP_KERNEL);
if (!conf->strip_zone)
goto abort;
conf->devlist = kzalloc(sizeof(mdk_rdev_t*)*
conf->devlist = kzalloc(sizeof(struct md_rdev*)*
conf->nr_strip_zones*mddev->raid_disks,
GFP_KERNEL);
if (!conf->devlist)
@ -218,44 +219,45 @@ static int create_strip_zones(mddev_t *mddev, raid0_conf_t **private_conf)
zone = conf->strip_zone + i;
dev = conf->devlist + i * mddev->raid_disks;
printk(KERN_INFO "md/raid0:%s: zone %d\n",
mdname(mddev), i);
pr_debug("md/raid0:%s: zone %d\n", mdname(mddev), i);
zone->dev_start = smallest->sectors;
smallest = NULL;
c = 0;
for (j=0; j<cnt; j++) {
rdev = conf->devlist[j];
printk(KERN_INFO "md/raid0:%s: checking %s ...",
mdname(mddev),
bdevname(rdev->bdev, b));
if (rdev->sectors <= zone->dev_start) {
printk(KERN_CONT " nope.\n");
pr_debug("md/raid0:%s: checking %s ... nope\n",
mdname(mddev),
bdevname(rdev->bdev, b));
continue;
}
printk(KERN_CONT " contained as device %d\n", c);
pr_debug("md/raid0:%s: checking %s ..."
" contained as device %d\n",
mdname(mddev),
bdevname(rdev->bdev, b), c);
dev[c] = rdev;
c++;
if (!smallest || rdev->sectors < smallest->sectors) {
smallest = rdev;
printk(KERN_INFO "md/raid0:%s: (%llu) is smallest!.\n",
mdname(mddev),
(unsigned long long)rdev->sectors);
pr_debug("md/raid0:%s: (%llu) is smallest!.\n",
mdname(mddev),
(unsigned long long)rdev->sectors);
}
}
zone->nb_dev = c;
sectors = (smallest->sectors - zone->dev_start) * c;
printk(KERN_INFO "md/raid0:%s: zone->nb_dev: %d, sectors: %llu\n",
mdname(mddev),
zone->nb_dev, (unsigned long long)sectors);
pr_debug("md/raid0:%s: zone->nb_dev: %d, sectors: %llu\n",
mdname(mddev),
zone->nb_dev, (unsigned long long)sectors);
curr_zone_end += sectors;
zone->zone_end = curr_zone_end;
printk(KERN_INFO "md/raid0:%s: current zone start: %llu\n",
mdname(mddev),
(unsigned long long)smallest->sectors);
pr_debug("md/raid0:%s: current zone start: %llu\n",
mdname(mddev),
(unsigned long long)smallest->sectors);
}
mddev->queue->backing_dev_info.congested_fn = raid0_congested;
mddev->queue->backing_dev_info.congested_data = mddev;
@ -275,7 +277,7 @@ static int create_strip_zones(mddev_t *mddev, raid0_conf_t **private_conf)
blk_queue_io_opt(mddev->queue,
(mddev->chunk_sectors << 9) * mddev->raid_disks);
printk(KERN_INFO "md/raid0:%s: done.\n", mdname(mddev));
pr_debug("md/raid0:%s: done.\n", mdname(mddev));
*private_conf = conf;
return 0;
@ -299,7 +301,7 @@ static int raid0_mergeable_bvec(struct request_queue *q,
struct bvec_merge_data *bvm,
struct bio_vec *biovec)
{
mddev_t *mddev = q->queuedata;
struct mddev *mddev = q->queuedata;
sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
int max;
unsigned int chunk_sectors = mddev->chunk_sectors;
@ -318,10 +320,10 @@ static int raid0_mergeable_bvec(struct request_queue *q,
return max;
}
static sector_t raid0_size(mddev_t *mddev, sector_t sectors, int raid_disks)
static sector_t raid0_size(struct mddev *mddev, sector_t sectors, int raid_disks)
{
sector_t array_sectors = 0;
mdk_rdev_t *rdev;
struct md_rdev *rdev;
WARN_ONCE(sectors || raid_disks,
"%s does not support generic reshape\n", __func__);
@ -332,9 +334,9 @@ static sector_t raid0_size(mddev_t *mddev, sector_t sectors, int raid_disks)
return array_sectors;
}
static int raid0_run(mddev_t *mddev)
static int raid0_run(struct mddev *mddev)
{
raid0_conf_t *conf;
struct r0conf *conf;
int ret;
if (mddev->chunk_sectors == 0) {
@ -382,9 +384,9 @@ static int raid0_run(mddev_t *mddev)
return md_integrity_register(mddev);
}
static int raid0_stop(mddev_t *mddev)
static int raid0_stop(struct mddev *mddev)
{
raid0_conf_t *conf = mddev->private;
struct r0conf *conf = mddev->private;
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
kfree(conf->strip_zone);
@ -397,7 +399,7 @@ static int raid0_stop(mddev_t *mddev)
/* Find the zone which holds a particular offset
* Update *sectorp to be an offset in that zone
*/
static struct strip_zone *find_zone(struct raid0_private_data *conf,
static struct strip_zone *find_zone(struct r0conf *conf,
sector_t *sectorp)
{
int i;
@ -417,12 +419,12 @@ static struct strip_zone *find_zone(struct raid0_private_data *conf,
* remaps the bio to the target device. we separate two flows.
* power 2 flow and a general flow for the sake of perfromance
*/
static mdk_rdev_t *map_sector(mddev_t *mddev, struct strip_zone *zone,
static struct md_rdev *map_sector(struct mddev *mddev, struct strip_zone *zone,
sector_t sector, sector_t *sector_offset)
{
unsigned int sect_in_chunk;
sector_t chunk;
raid0_conf_t *conf = mddev->private;
struct r0conf *conf = mddev->private;
int raid_disks = conf->strip_zone[0].nb_dev;
unsigned int chunk_sects = mddev->chunk_sectors;
@ -453,7 +455,7 @@ static mdk_rdev_t *map_sector(mddev_t *mddev, struct strip_zone *zone,
/*
* Is io distribute over 1 or more chunks ?
*/
static inline int is_io_in_chunk_boundary(mddev_t *mddev,
static inline int is_io_in_chunk_boundary(struct mddev *mddev,
unsigned int chunk_sects, struct bio *bio)
{
if (likely(is_power_of_2(chunk_sects))) {
@ -466,12 +468,12 @@ static inline int is_io_in_chunk_boundary(mddev_t *mddev,
}
}
static int raid0_make_request(mddev_t *mddev, struct bio *bio)
static int raid0_make_request(struct mddev *mddev, struct bio *bio)
{
unsigned int chunk_sects;
sector_t sector_offset;
struct strip_zone *zone;
mdk_rdev_t *tmp_dev;
struct md_rdev *tmp_dev;
if (unlikely(bio->bi_rw & REQ_FLUSH)) {
md_flush_request(mddev, bio);
@ -526,43 +528,16 @@ bad_map:
return 0;
}
static void raid0_status(struct seq_file *seq, mddev_t *mddev)
static void raid0_status(struct seq_file *seq, struct mddev *mddev)
{
#undef MD_DEBUG
#ifdef MD_DEBUG
int j, k, h;
char b[BDEVNAME_SIZE];
raid0_conf_t *conf = mddev->private;
int raid_disks = conf->strip_zone[0].nb_dev;
sector_t zone_size;
sector_t zone_start = 0;
h = 0;
for (j = 0; j < conf->nr_strip_zones; j++) {
seq_printf(seq, " z%d", j);
seq_printf(seq, "=[");
for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
seq_printf(seq, "%s/", bdevname(
conf->devlist[j*raid_disks + k]
->bdev, b));
zone_size = conf->strip_zone[j].zone_end - zone_start;
seq_printf(seq, "] ze=%lld ds=%lld s=%lld\n",
(unsigned long long)zone_start>>1,
(unsigned long long)conf->strip_zone[j].dev_start>>1,
(unsigned long long)zone_size>>1);
zone_start = conf->strip_zone[j].zone_end;
}
#endif
seq_printf(seq, " %dk chunks", mddev->chunk_sectors / 2);
return;
}
static void *raid0_takeover_raid45(mddev_t *mddev)
static void *raid0_takeover_raid45(struct mddev *mddev)
{
mdk_rdev_t *rdev;
raid0_conf_t *priv_conf;
struct md_rdev *rdev;
struct r0conf *priv_conf;
if (mddev->degraded != 1) {
printk(KERN_ERR "md/raid0:%s: raid5 must be degraded! Degraded disks: %d\n",
@ -593,9 +568,9 @@ static void *raid0_takeover_raid45(mddev_t *mddev)
return priv_conf;
}
static void *raid0_takeover_raid10(mddev_t *mddev)
static void *raid0_takeover_raid10(struct mddev *mddev)
{
raid0_conf_t *priv_conf;
struct r0conf *priv_conf;
/* Check layout:
* - far_copies must be 1
@ -634,9 +609,9 @@ static void *raid0_takeover_raid10(mddev_t *mddev)
return priv_conf;
}
static void *raid0_takeover_raid1(mddev_t *mddev)
static void *raid0_takeover_raid1(struct mddev *mddev)
{
raid0_conf_t *priv_conf;
struct r0conf *priv_conf;
/* Check layout:
* - (N - 1) mirror drives must be already faulty
@ -660,7 +635,7 @@ static void *raid0_takeover_raid1(mddev_t *mddev)
return priv_conf;
}
static void *raid0_takeover(mddev_t *mddev)
static void *raid0_takeover(struct mddev *mddev)
{
/* raid0 can take over:
* raid4 - if all data disks are active.
@ -691,11 +666,11 @@ static void *raid0_takeover(mddev_t *mddev)
return ERR_PTR(-EINVAL);
}
static void raid0_quiesce(mddev_t *mddev, int state)
static void raid0_quiesce(struct mddev *mddev, int state)
{
}
static struct mdk_personality raid0_personality=
static struct md_personality raid0_personality=
{
.name = "raid0",
.level = 0,

View File

@ -1,20 +1,16 @@
#ifndef _RAID0_H
#define _RAID0_H
struct strip_zone
{
struct strip_zone {
sector_t zone_end; /* Start of the next zone (in sectors) */
sector_t dev_start; /* Zone offset in real dev (in sectors) */
int nb_dev; /* # of devices attached to the zone */
};
struct raid0_private_data
{
struct r0conf {
struct strip_zone *strip_zone;
mdk_rdev_t **devlist; /* lists of rdevs, pointed to by strip_zone->dev */
struct md_rdev **devlist; /* lists of rdevs, pointed to by strip_zone->dev */
int nr_strip_zones;
};
typedef struct raid0_private_data raid0_conf_t;
#endif

View File

@ -40,22 +40,24 @@
#include "raid1.h"
#include "bitmap.h"
#define DEBUG 0
#define PRINTK(x...) do { if (DEBUG) printk(x); } while (0)
/*
* Number of guaranteed r1bios in case of extreme VM load:
*/
#define NR_RAID1_BIOS 256
/* When there are this many requests queue to be written by
* the raid1 thread, we become 'congested' to provide back-pressure
* for writeback.
*/
static int max_queued_requests = 1024;
static void allow_barrier(conf_t *conf);
static void lower_barrier(conf_t *conf);
static void allow_barrier(struct r1conf *conf);
static void lower_barrier(struct r1conf *conf);
static void * r1bio_pool_alloc(gfp_t gfp_flags, void *data)
{
struct pool_info *pi = data;
int size = offsetof(r1bio_t, bios[pi->raid_disks]);
int size = offsetof(struct r1bio, bios[pi->raid_disks]);
/* allocate a r1bio with room for raid_disks entries in the bios array */
return kzalloc(size, gfp_flags);
@ -76,7 +78,7 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
{
struct pool_info *pi = data;
struct page *page;
r1bio_t *r1_bio;
struct r1bio *r1_bio;
struct bio *bio;
int i, j;
@ -142,7 +144,7 @@ static void r1buf_pool_free(void *__r1_bio, void *data)
{
struct pool_info *pi = data;
int i,j;
r1bio_t *r1bio = __r1_bio;
struct r1bio *r1bio = __r1_bio;
for (i = 0; i < RESYNC_PAGES; i++)
for (j = pi->raid_disks; j-- ;) {
@ -157,7 +159,7 @@ static void r1buf_pool_free(void *__r1_bio, void *data)
r1bio_pool_free(r1bio, data);
}
static void put_all_bios(conf_t *conf, r1bio_t *r1_bio)
static void put_all_bios(struct r1conf *conf, struct r1bio *r1_bio)
{
int i;
@ -169,17 +171,17 @@ static void put_all_bios(conf_t *conf, r1bio_t *r1_bio)
}
}
static void free_r1bio(r1bio_t *r1_bio)
static void free_r1bio(struct r1bio *r1_bio)
{
conf_t *conf = r1_bio->mddev->private;
struct r1conf *conf = r1_bio->mddev->private;
put_all_bios(conf, r1_bio);
mempool_free(r1_bio, conf->r1bio_pool);
}
static void put_buf(r1bio_t *r1_bio)
static void put_buf(struct r1bio *r1_bio)
{
conf_t *conf = r1_bio->mddev->private;
struct r1conf *conf = r1_bio->mddev->private;
int i;
for (i=0; i<conf->raid_disks; i++) {
@ -193,11 +195,11 @@ static void put_buf(r1bio_t *r1_bio)
lower_barrier(conf);
}
static void reschedule_retry(r1bio_t *r1_bio)
static void reschedule_retry(struct r1bio *r1_bio)
{
unsigned long flags;
mddev_t *mddev = r1_bio->mddev;
conf_t *conf = mddev->private;
struct mddev *mddev = r1_bio->mddev;
struct r1conf *conf = mddev->private;
spin_lock_irqsave(&conf->device_lock, flags);
list_add(&r1_bio->retry_list, &conf->retry_list);
@ -213,11 +215,11 @@ static void reschedule_retry(r1bio_t *r1_bio)
* operation and are ready to return a success/failure code to the buffer
* cache layer.
*/
static void call_bio_endio(r1bio_t *r1_bio)
static void call_bio_endio(struct r1bio *r1_bio)
{
struct bio *bio = r1_bio->master_bio;
int done;
conf_t *conf = r1_bio->mddev->private;
struct r1conf *conf = r1_bio->mddev->private;
if (bio->bi_phys_segments) {
unsigned long flags;
@ -240,17 +242,17 @@ static void call_bio_endio(r1bio_t *r1_bio)
}
}
static void raid_end_bio_io(r1bio_t *r1_bio)
static void raid_end_bio_io(struct r1bio *r1_bio)
{
struct bio *bio = r1_bio->master_bio;
/* if nobody has done the final endio yet, do it now */
if (!test_and_set_bit(R1BIO_Returned, &r1_bio->state)) {
PRINTK(KERN_DEBUG "raid1: sync end %s on sectors %llu-%llu\n",
(bio_data_dir(bio) == WRITE) ? "write" : "read",
(unsigned long long) bio->bi_sector,
(unsigned long long) bio->bi_sector +
(bio->bi_size >> 9) - 1);
pr_debug("raid1: sync end %s on sectors %llu-%llu\n",
(bio_data_dir(bio) == WRITE) ? "write" : "read",
(unsigned long long) bio->bi_sector,
(unsigned long long) bio->bi_sector +
(bio->bi_size >> 9) - 1);
call_bio_endio(r1_bio);
}
@ -260,20 +262,38 @@ static void raid_end_bio_io(r1bio_t *r1_bio)
/*
* Update disk head position estimator based on IRQ completion info.
*/
static inline void update_head_pos(int disk, r1bio_t *r1_bio)
static inline void update_head_pos(int disk, struct r1bio *r1_bio)
{
conf_t *conf = r1_bio->mddev->private;
struct r1conf *conf = r1_bio->mddev->private;
conf->mirrors[disk].head_position =
r1_bio->sector + (r1_bio->sectors);
}
/*
* Find the disk number which triggered given bio
*/
static int find_bio_disk(struct r1bio *r1_bio, struct bio *bio)
{
int mirror;
int raid_disks = r1_bio->mddev->raid_disks;
for (mirror = 0; mirror < raid_disks; mirror++)
if (r1_bio->bios[mirror] == bio)
break;
BUG_ON(mirror == raid_disks);
update_head_pos(mirror, r1_bio);
return mirror;
}
static void raid1_end_read_request(struct bio *bio, int error)
{
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
r1bio_t *r1_bio = bio->bi_private;
struct r1bio *r1_bio = bio->bi_private;
int mirror;
conf_t *conf = r1_bio->mddev->private;
struct r1conf *conf = r1_bio->mddev->private;
mirror = r1_bio->read_disk;
/*
@ -318,7 +338,7 @@ static void raid1_end_read_request(struct bio *bio, int error)
rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
}
static void close_write(r1bio_t *r1_bio)
static void close_write(struct r1bio *r1_bio)
{
/* it really is the end of this request */
if (test_bit(R1BIO_BehindIO, &r1_bio->state)) {
@ -337,7 +357,7 @@ static void close_write(r1bio_t *r1_bio)
md_write_end(r1_bio->mddev);
}
static void r1_bio_write_done(r1bio_t *r1_bio)
static void r1_bio_write_done(struct r1bio *r1_bio)
{
if (!atomic_dec_and_test(&r1_bio->remaining))
return;
@ -356,15 +376,12 @@ static void r1_bio_write_done(r1bio_t *r1_bio)
static void raid1_end_write_request(struct bio *bio, int error)
{
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
r1bio_t *r1_bio = bio->bi_private;
struct r1bio *r1_bio = bio->bi_private;
int mirror, behind = test_bit(R1BIO_BehindIO, &r1_bio->state);
conf_t *conf = r1_bio->mddev->private;
struct r1conf *conf = r1_bio->mddev->private;
struct bio *to_put = NULL;
for (mirror = 0; mirror < conf->raid_disks; mirror++)
if (r1_bio->bios[mirror] == bio)
break;
mirror = find_bio_disk(r1_bio, bio);
/*
* 'one mirror IO has finished' event handler:
@ -400,8 +417,6 @@ static void raid1_end_write_request(struct bio *bio, int error)
}
}
update_head_pos(mirror, r1_bio);
if (behind) {
if (test_bit(WriteMostly, &conf->mirrors[mirror].rdev->flags))
atomic_dec(&r1_bio->behind_remaining);
@ -418,10 +433,11 @@ static void raid1_end_write_request(struct bio *bio, int error)
/* Maybe we can return now */
if (!test_and_set_bit(R1BIO_Returned, &r1_bio->state)) {
struct bio *mbio = r1_bio->master_bio;
PRINTK(KERN_DEBUG "raid1: behind end write sectors %llu-%llu\n",
(unsigned long long) mbio->bi_sector,
(unsigned long long) mbio->bi_sector +
(mbio->bi_size >> 9) - 1);
pr_debug("raid1: behind end write sectors"
" %llu-%llu\n",
(unsigned long long) mbio->bi_sector,
(unsigned long long) mbio->bi_sector +
(mbio->bi_size >> 9) - 1);
call_bio_endio(r1_bio);
}
}
@ -455,7 +471,7 @@ static void raid1_end_write_request(struct bio *bio, int error)
*
* The rdev for the device selected will have nr_pending incremented.
*/
static int read_balance(conf_t *conf, r1bio_t *r1_bio, int *max_sectors)
static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sectors)
{
const sector_t this_sector = r1_bio->sector;
int sectors;
@ -464,7 +480,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio, int *max_sectors)
int best_disk;
int i;
sector_t best_dist;
mdk_rdev_t *rdev;
struct md_rdev *rdev;
int choose_first;
rcu_read_lock();
@ -582,14 +598,18 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio, int *max_sectors)
return best_disk;
}
int md_raid1_congested(mddev_t *mddev, int bits)
int md_raid1_congested(struct mddev *mddev, int bits)
{
conf_t *conf = mddev->private;
struct r1conf *conf = mddev->private;
int i, ret = 0;
if ((bits & (1 << BDI_async_congested)) &&
conf->pending_count >= max_queued_requests)
return 1;
rcu_read_lock();
for (i = 0; i < mddev->raid_disks; i++) {
mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
if (rdev && !test_bit(Faulty, &rdev->flags)) {
struct request_queue *q = bdev_get_queue(rdev->bdev);
@ -611,13 +631,13 @@ EXPORT_SYMBOL_GPL(md_raid1_congested);
static int raid1_congested(void *data, int bits)
{
mddev_t *mddev = data;
struct mddev *mddev = data;
return mddev_congested(mddev, bits) ||
md_raid1_congested(mddev, bits);
}
static void flush_pending_writes(conf_t *conf)
static void flush_pending_writes(struct r1conf *conf)
{
/* Any writes that have been queued but are awaiting
* bitmap updates get flushed here.
@ -627,10 +647,12 @@ static void flush_pending_writes(conf_t *conf)
if (conf->pending_bio_list.head) {
struct bio *bio;
bio = bio_list_get(&conf->pending_bio_list);
conf->pending_count = 0;
spin_unlock_irq(&conf->device_lock);
/* flush any pending bitmap writes to
* disk before proceeding w/ I/O */
bitmap_unplug(conf->mddev->bitmap);
wake_up(&conf->wait_barrier);
while (bio) { /* submit pending writes */
struct bio *next = bio->bi_next;
@ -665,7 +687,7 @@ static void flush_pending_writes(conf_t *conf)
*/
#define RESYNC_DEPTH 32
static void raise_barrier(conf_t *conf)
static void raise_barrier(struct r1conf *conf)
{
spin_lock_irq(&conf->resync_lock);
@ -684,7 +706,7 @@ static void raise_barrier(conf_t *conf)
spin_unlock_irq(&conf->resync_lock);
}
static void lower_barrier(conf_t *conf)
static void lower_barrier(struct r1conf *conf)
{
unsigned long flags;
BUG_ON(conf->barrier <= 0);
@ -694,7 +716,7 @@ static void lower_barrier(conf_t *conf)
wake_up(&conf->wait_barrier);
}
static void wait_barrier(conf_t *conf)
static void wait_barrier(struct r1conf *conf)
{
spin_lock_irq(&conf->resync_lock);
if (conf->barrier) {
@ -708,7 +730,7 @@ static void wait_barrier(conf_t *conf)
spin_unlock_irq(&conf->resync_lock);
}
static void allow_barrier(conf_t *conf)
static void allow_barrier(struct r1conf *conf)
{
unsigned long flags;
spin_lock_irqsave(&conf->resync_lock, flags);
@ -717,7 +739,7 @@ static void allow_barrier(conf_t *conf)
wake_up(&conf->wait_barrier);
}
static void freeze_array(conf_t *conf)
static void freeze_array(struct r1conf *conf)
{
/* stop syncio and normal IO and wait for everything to
* go quite.
@ -740,7 +762,7 @@ static void freeze_array(conf_t *conf)
flush_pending_writes(conf));
spin_unlock_irq(&conf->resync_lock);
}
static void unfreeze_array(conf_t *conf)
static void unfreeze_array(struct r1conf *conf)
{
/* reverse the effect of the freeze */
spin_lock_irq(&conf->resync_lock);
@ -753,7 +775,7 @@ static void unfreeze_array(conf_t *conf)
/* duplicate the data pages for behind I/O
*/
static void alloc_behind_pages(struct bio *bio, r1bio_t *r1_bio)
static void alloc_behind_pages(struct bio *bio, struct r1bio *r1_bio)
{
int i;
struct bio_vec *bvec;
@ -782,14 +804,14 @@ do_sync_io:
if (bvecs[i].bv_page)
put_page(bvecs[i].bv_page);
kfree(bvecs);
PRINTK("%dB behind alloc failed, doing sync I/O\n", bio->bi_size);
pr_debug("%dB behind alloc failed, doing sync I/O\n", bio->bi_size);
}
static int make_request(mddev_t *mddev, struct bio * bio)
static int make_request(struct mddev *mddev, struct bio * bio)
{
conf_t *conf = mddev->private;
mirror_info_t *mirror;
r1bio_t *r1_bio;
struct r1conf *conf = mddev->private;
struct mirror_info *mirror;
struct r1bio *r1_bio;
struct bio *read_bio;
int i, disks;
struct bitmap *bitmap;
@ -797,7 +819,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
const int rw = bio_data_dir(bio);
const unsigned long do_sync = (bio->bi_rw & REQ_SYNC);
const unsigned long do_flush_fua = (bio->bi_rw & (REQ_FLUSH | REQ_FUA));
mdk_rdev_t *blocked_rdev;
struct md_rdev *blocked_rdev;
int plugged;
int first_clone;
int sectors_handled;
@ -934,6 +956,11 @@ read_again:
/*
* WRITE:
*/
if (conf->pending_count >= max_queued_requests) {
md_wakeup_thread(mddev->thread);
wait_event(conf->wait_barrier,
conf->pending_count < max_queued_requests);
}
/* first select target devices under rcu_lock and
* inc refcount on their rdev. Record them by setting
* bios[x] to bio
@ -952,7 +979,7 @@ read_again:
rcu_read_lock();
max_sectors = r1_bio->sectors;
for (i = 0; i < disks; i++) {
mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
if (rdev && unlikely(test_bit(Blocked, &rdev->flags))) {
atomic_inc(&rdev->nr_pending);
blocked_rdev = rdev;
@ -1097,6 +1124,7 @@ read_again:
atomic_inc(&r1_bio->remaining);
spin_lock_irqsave(&conf->device_lock, flags);
bio_list_add(&conf->pending_bio_list, mbio);
conf->pending_count++;
spin_unlock_irqrestore(&conf->device_lock, flags);
}
/* Mustn't call r1_bio_write_done before this next test,
@ -1127,16 +1155,16 @@ read_again:
return 0;
}
static void status(struct seq_file *seq, mddev_t *mddev)
static void status(struct seq_file *seq, struct mddev *mddev)
{
conf_t *conf = mddev->private;
struct r1conf *conf = mddev->private;
int i;
seq_printf(seq, " [%d/%d] [", conf->raid_disks,
conf->raid_disks - mddev->degraded);
rcu_read_lock();
for (i = 0; i < conf->raid_disks; i++) {
mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
seq_printf(seq, "%s",
rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
}
@ -1145,10 +1173,10 @@ static void status(struct seq_file *seq, mddev_t *mddev)
}
static void error(mddev_t *mddev, mdk_rdev_t *rdev)
static void error(struct mddev *mddev, struct md_rdev *rdev)
{
char b[BDEVNAME_SIZE];
conf_t *conf = mddev->private;
struct r1conf *conf = mddev->private;
/*
* If it is not operational, then we have already marked it as dead
@ -1188,7 +1216,7 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
mdname(mddev), conf->raid_disks - mddev->degraded);
}
static void print_conf(conf_t *conf)
static void print_conf(struct r1conf *conf)
{
int i;
@ -1203,7 +1231,7 @@ static void print_conf(conf_t *conf)
rcu_read_lock();
for (i = 0; i < conf->raid_disks; i++) {
char b[BDEVNAME_SIZE];
mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
if (rdev)
printk(KERN_DEBUG " disk %d, wo:%d, o:%d, dev:%s\n",
i, !test_bit(In_sync, &rdev->flags),
@ -1213,7 +1241,7 @@ static void print_conf(conf_t *conf)
rcu_read_unlock();
}
static void close_sync(conf_t *conf)
static void close_sync(struct r1conf *conf)
{
wait_barrier(conf);
allow_barrier(conf);
@ -1222,10 +1250,10 @@ static void close_sync(conf_t *conf)
conf->r1buf_pool = NULL;
}
static int raid1_spare_active(mddev_t *mddev)
static int raid1_spare_active(struct mddev *mddev)
{
int i;
conf_t *conf = mddev->private;
struct r1conf *conf = mddev->private;
int count = 0;
unsigned long flags;
@ -1235,7 +1263,7 @@ static int raid1_spare_active(mddev_t *mddev)
* Called under mddev lock, so rcu protection not needed.
*/
for (i = 0; i < conf->raid_disks; i++) {
mdk_rdev_t *rdev = conf->mirrors[i].rdev;
struct md_rdev *rdev = conf->mirrors[i].rdev;
if (rdev
&& !test_bit(Faulty, &rdev->flags)
&& !test_and_set_bit(In_sync, &rdev->flags)) {
@ -1252,12 +1280,12 @@ static int raid1_spare_active(mddev_t *mddev)
}
static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev)
{
conf_t *conf = mddev->private;
struct r1conf *conf = mddev->private;
int err = -EEXIST;
int mirror = 0;
mirror_info_t *p;
struct mirror_info *p;
int first = 0;
int last = mddev->raid_disks - 1;
@ -1300,12 +1328,12 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
return err;
}
static int raid1_remove_disk(mddev_t *mddev, int number)
static int raid1_remove_disk(struct mddev *mddev, int number)
{
conf_t *conf = mddev->private;
struct r1conf *conf = mddev->private;
int err = 0;
mdk_rdev_t *rdev;
mirror_info_t *p = conf->mirrors+ number;
struct md_rdev *rdev;
struct mirror_info *p = conf->mirrors+ number;
print_conf(conf);
rdev = p->rdev;
@ -1343,14 +1371,10 @@ abort:
static void end_sync_read(struct bio *bio, int error)
{
r1bio_t *r1_bio = bio->bi_private;
int i;
struct r1bio *r1_bio = bio->bi_private;
update_head_pos(r1_bio->read_disk, r1_bio);
for (i=r1_bio->mddev->raid_disks; i--; )
if (r1_bio->bios[i] == bio)
break;
BUG_ON(i < 0);
update_head_pos(i, r1_bio);
/*
* we have read a block, now it needs to be re-written,
* or re-read if the read failed.
@ -1366,19 +1390,15 @@ static void end_sync_read(struct bio *bio, int error)
static void end_sync_write(struct bio *bio, int error)
{
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
r1bio_t *r1_bio = bio->bi_private;
mddev_t *mddev = r1_bio->mddev;
conf_t *conf = mddev->private;
int i;
struct r1bio *r1_bio = bio->bi_private;
struct mddev *mddev = r1_bio->mddev;
struct r1conf *conf = mddev->private;
int mirror=0;
sector_t first_bad;
int bad_sectors;
for (i = 0; i < conf->raid_disks; i++)
if (r1_bio->bios[i] == bio) {
mirror = i;
break;
}
mirror = find_bio_disk(r1_bio, bio);
if (!uptodate) {
sector_t sync_blocks = 0;
sector_t s = r1_bio->sector;
@ -1404,8 +1424,6 @@ static void end_sync_write(struct bio *bio, int error)
)
set_bit(R1BIO_MadeGood, &r1_bio->state);
update_head_pos(mirror, r1_bio);
if (atomic_dec_and_test(&r1_bio->remaining)) {
int s = r1_bio->sectors;
if (test_bit(R1BIO_MadeGood, &r1_bio->state) ||
@ -1418,7 +1436,7 @@ static void end_sync_write(struct bio *bio, int error)
}
}
static int r1_sync_page_io(mdk_rdev_t *rdev, sector_t sector,
static int r1_sync_page_io(struct md_rdev *rdev, sector_t sector,
int sectors, struct page *page, int rw)
{
if (sync_page_io(rdev, sector, sectors << 9, page, rw, false))
@ -1432,7 +1450,7 @@ static int r1_sync_page_io(mdk_rdev_t *rdev, sector_t sector,
return 0;
}
static int fix_sync_read_error(r1bio_t *r1_bio)
static int fix_sync_read_error(struct r1bio *r1_bio)
{
/* Try some synchronous reads of other devices to get
* good data, much like with normal read errors. Only
@ -1445,8 +1463,8 @@ static int fix_sync_read_error(r1bio_t *r1_bio)
* made sure that anything with a bad block in range
* will have bi_end_io clear.
*/
mddev_t *mddev = r1_bio->mddev;
conf_t *conf = mddev->private;
struct mddev *mddev = r1_bio->mddev;
struct r1conf *conf = mddev->private;
struct bio *bio = r1_bio->bios[r1_bio->read_disk];
sector_t sect = r1_bio->sector;
int sectors = r1_bio->sectors;
@ -1456,7 +1474,7 @@ static int fix_sync_read_error(r1bio_t *r1_bio)
int s = sectors;
int d = r1_bio->read_disk;
int success = 0;
mdk_rdev_t *rdev;
struct md_rdev *rdev;
int start;
if (s > (PAGE_SIZE>>9))
@ -1501,7 +1519,8 @@ static int fix_sync_read_error(r1bio_t *r1_bio)
abort = 1;
}
if (abort) {
mddev->recovery_disabled = 1;
conf->recovery_disabled =
mddev->recovery_disabled;
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
md_done_sync(mddev, r1_bio->sectors, 0);
put_buf(r1_bio);
@ -1552,7 +1571,7 @@ static int fix_sync_read_error(r1bio_t *r1_bio)
return 1;
}
static int process_checks(r1bio_t *r1_bio)
static int process_checks(struct r1bio *r1_bio)
{
/* We have read all readable devices. If we haven't
* got the block, then there is no hope left.
@ -1561,8 +1580,8 @@ static int process_checks(r1bio_t *r1_bio)
* If any blocks failed to read, then we need to
* attempt an over-write
*/
mddev_t *mddev = r1_bio->mddev;
conf_t *conf = mddev->private;
struct mddev *mddev = r1_bio->mddev;
struct r1conf *conf = mddev->private;
int primary;
int i;
@ -1634,9 +1653,9 @@ static int process_checks(r1bio_t *r1_bio)
return 0;
}
static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio)
{
conf_t *conf = mddev->private;
struct r1conf *conf = mddev->private;
int i;
int disks = conf->raid_disks;
struct bio *bio, *wbio;
@ -1686,16 +1705,16 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
* 3. Performs writes following reads for array synchronising.
*/
static void fix_read_error(conf_t *conf, int read_disk,
static void fix_read_error(struct r1conf *conf, int read_disk,
sector_t sect, int sectors)
{
mddev_t *mddev = conf->mddev;
struct mddev *mddev = conf->mddev;
while(sectors) {
int s = sectors;
int d = read_disk;
int success = 0;
int start;
mdk_rdev_t *rdev;
struct md_rdev *rdev;
if (s > (PAGE_SIZE>>9))
s = PAGE_SIZE >> 9;
@ -1726,7 +1745,7 @@ static void fix_read_error(conf_t *conf, int read_disk,
if (!success) {
/* Cannot read from anywhere - mark it bad */
mdk_rdev_t *rdev = conf->mirrors[read_disk].rdev;
struct md_rdev *rdev = conf->mirrors[read_disk].rdev;
if (!rdev_set_badblocks(rdev, sect, s, 0))
md_error(mddev, rdev);
break;
@ -1789,11 +1808,11 @@ static int submit_bio_wait(int rw, struct bio *bio)
return test_bit(BIO_UPTODATE, &bio->bi_flags);
}
static int narrow_write_error(r1bio_t *r1_bio, int i)
static int narrow_write_error(struct r1bio *r1_bio, int i)
{
mddev_t *mddev = r1_bio->mddev;
conf_t *conf = mddev->private;
mdk_rdev_t *rdev = conf->mirrors[i].rdev;
struct mddev *mddev = r1_bio->mddev;
struct r1conf *conf = mddev->private;
struct md_rdev *rdev = conf->mirrors[i].rdev;
int vcnt, idx;
struct bio_vec *vec;
@ -1865,12 +1884,12 @@ static int narrow_write_error(r1bio_t *r1_bio, int i)
return ok;
}
static void handle_sync_write_finished(conf_t *conf, r1bio_t *r1_bio)
static void handle_sync_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
{
int m;
int s = r1_bio->sectors;
for (m = 0; m < conf->raid_disks ; m++) {
mdk_rdev_t *rdev = conf->mirrors[m].rdev;
struct md_rdev *rdev = conf->mirrors[m].rdev;
struct bio *bio = r1_bio->bios[m];
if (bio->bi_end_io == NULL)
continue;
@ -1888,12 +1907,12 @@ static void handle_sync_write_finished(conf_t *conf, r1bio_t *r1_bio)
md_done_sync(conf->mddev, s, 1);
}
static void handle_write_finished(conf_t *conf, r1bio_t *r1_bio)
static void handle_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
{
int m;
for (m = 0; m < conf->raid_disks ; m++)
if (r1_bio->bios[m] == IO_MADE_GOOD) {
mdk_rdev_t *rdev = conf->mirrors[m].rdev;
struct md_rdev *rdev = conf->mirrors[m].rdev;
rdev_clear_badblocks(rdev,
r1_bio->sector,
r1_bio->sectors);
@ -1917,14 +1936,14 @@ static void handle_write_finished(conf_t *conf, r1bio_t *r1_bio)
raid_end_bio_io(r1_bio);
}
static void handle_read_error(conf_t *conf, r1bio_t *r1_bio)
static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
{
int disk;
int max_sectors;
mddev_t *mddev = conf->mddev;
struct mddev *mddev = conf->mddev;
struct bio *bio;
char b[BDEVNAME_SIZE];
mdk_rdev_t *rdev;
struct md_rdev *rdev;
clear_bit(R1BIO_ReadError, &r1_bio->state);
/* we got a read error. Maybe the drive is bad. Maybe just
@ -2007,11 +2026,11 @@ read_more:
}
}
static void raid1d(mddev_t *mddev)
static void raid1d(struct mddev *mddev)
{
r1bio_t *r1_bio;
struct r1bio *r1_bio;
unsigned long flags;
conf_t *conf = mddev->private;
struct r1conf *conf = mddev->private;
struct list_head *head = &conf->retry_list;
struct blk_plug plug;
@ -2028,7 +2047,7 @@ static void raid1d(mddev_t *mddev)
spin_unlock_irqrestore(&conf->device_lock, flags);
break;
}
r1_bio = list_entry(head->prev, r1bio_t, retry_list);
r1_bio = list_entry(head->prev, struct r1bio, retry_list);
list_del(head->prev);
conf->nr_queued--;
spin_unlock_irqrestore(&conf->device_lock, flags);
@ -2060,7 +2079,7 @@ static void raid1d(mddev_t *mddev)
}
static int init_resync(conf_t *conf)
static int init_resync(struct r1conf *conf)
{
int buffs;
@ -2084,10 +2103,10 @@ static int init_resync(conf_t *conf)
* that can be installed to exclude normal IO requests.
*/
static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster)
static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int *skipped, int go_faster)
{
conf_t *conf = mddev->private;
r1bio_t *r1_bio;
struct r1conf *conf = mddev->private;
struct r1bio *r1_bio;
struct bio *bio;
sector_t max_sector, nr_sectors;
int disk = -1;
@ -2167,7 +2186,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
set_bit(R1BIO_IsSync, &r1_bio->state);
for (i=0; i < conf->raid_disks; i++) {
mdk_rdev_t *rdev;
struct md_rdev *rdev;
bio = r1_bio->bios[i];
/* take from bio_init */
@ -2239,7 +2258,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
int ok = 1;
for (i = 0 ; i < conf->raid_disks ; i++)
if (r1_bio->bios[i]->bi_end_io == end_sync_write) {
mdk_rdev_t *rdev =
struct md_rdev *rdev =
rcu_dereference(conf->mirrors[i].rdev);
ok = rdev_set_badblocks(rdev, sector_nr,
min_bad, 0
@ -2356,7 +2375,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
return nr_sectors;
}
static sector_t raid1_size(mddev_t *mddev, sector_t sectors, int raid_disks)
static sector_t raid1_size(struct mddev *mddev, sector_t sectors, int raid_disks)
{
if (sectors)
return sectors;
@ -2364,15 +2383,15 @@ static sector_t raid1_size(mddev_t *mddev, sector_t sectors, int raid_disks)
return mddev->dev_sectors;
}
static conf_t *setup_conf(mddev_t *mddev)
static struct r1conf *setup_conf(struct mddev *mddev)
{
conf_t *conf;
struct r1conf *conf;
int i;
mirror_info_t *disk;
mdk_rdev_t *rdev;
struct mirror_info *disk;
struct md_rdev *rdev;
int err = -ENOMEM;
conf = kzalloc(sizeof(conf_t), GFP_KERNEL);
conf = kzalloc(sizeof(struct r1conf), GFP_KERNEL);
if (!conf)
goto abort;
@ -2417,6 +2436,8 @@ static conf_t *setup_conf(mddev_t *mddev)
init_waitqueue_head(&conf->wait_barrier);
bio_list_init(&conf->pending_bio_list);
conf->pending_count = 0;
conf->recovery_disabled = mddev->recovery_disabled - 1;
conf->last_used = -1;
for (i = 0; i < conf->raid_disks; i++) {
@ -2465,11 +2486,11 @@ static conf_t *setup_conf(mddev_t *mddev)
return ERR_PTR(err);
}
static int run(mddev_t *mddev)
static int run(struct mddev *mddev)
{
conf_t *conf;
struct r1conf *conf;
int i;
mdk_rdev_t *rdev;
struct md_rdev *rdev;
if (mddev->level != 1) {
printk(KERN_ERR "md/raid1:%s: raid level not set to mirroring (%d)\n",
@ -2545,9 +2566,9 @@ static int run(mddev_t *mddev)
return md_integrity_register(mddev);
}
static int stop(mddev_t *mddev)
static int stop(struct mddev *mddev)
{
conf_t *conf = mddev->private;
struct r1conf *conf = mddev->private;
struct bitmap *bitmap = mddev->bitmap;
/* wait for behind writes to complete */
@ -2572,7 +2593,7 @@ static int stop(mddev_t *mddev)
return 0;
}
static int raid1_resize(mddev_t *mddev, sector_t sectors)
static int raid1_resize(struct mddev *mddev, sector_t sectors)
{
/* no resync is happening, and there is enough space
* on all devices, so we can resize.
@ -2596,7 +2617,7 @@ static int raid1_resize(mddev_t *mddev, sector_t sectors)
return 0;
}
static int raid1_reshape(mddev_t *mddev)
static int raid1_reshape(struct mddev *mddev)
{
/* We need to:
* 1/ resize the r1bio_pool
@ -2611,8 +2632,8 @@ static int raid1_reshape(mddev_t *mddev)
*/
mempool_t *newpool, *oldpool;
struct pool_info *newpoolinfo;
mirror_info_t *newmirrors;
conf_t *conf = mddev->private;
struct mirror_info *newmirrors;
struct r1conf *conf = mddev->private;
int cnt, raid_disks;
unsigned long flags;
int d, d2, err;
@ -2668,7 +2689,7 @@ static int raid1_reshape(mddev_t *mddev)
conf->r1bio_pool = newpool;
for (d = d2 = 0; d < conf->raid_disks; d++) {
mdk_rdev_t *rdev = conf->mirrors[d].rdev;
struct md_rdev *rdev = conf->mirrors[d].rdev;
if (rdev && rdev->raid_disk != d2) {
sysfs_unlink_rdev(mddev, rdev);
rdev->raid_disk = d2;
@ -2702,9 +2723,9 @@ static int raid1_reshape(mddev_t *mddev)
return 0;
}
static void raid1_quiesce(mddev_t *mddev, int state)
static void raid1_quiesce(struct mddev *mddev, int state)
{
conf_t *conf = mddev->private;
struct r1conf *conf = mddev->private;
switch(state) {
case 2: /* wake for suspend */
@ -2719,13 +2740,13 @@ static void raid1_quiesce(mddev_t *mddev, int state)
}
}
static void *raid1_takeover(mddev_t *mddev)
static void *raid1_takeover(struct mddev *mddev)
{
/* raid1 can take over:
* raid5 with 2 devices, any layout or chunk size
*/
if (mddev->level == 5 && mddev->raid_disks == 2) {
conf_t *conf;
struct r1conf *conf;
mddev->new_level = 1;
mddev->new_layout = 0;
mddev->new_chunk_sectors = 0;
@ -2737,7 +2758,7 @@ static void *raid1_takeover(mddev_t *mddev)
return ERR_PTR(-EINVAL);
}
static struct mdk_personality raid1_personality =
static struct md_personality raid1_personality =
{
.name = "raid1",
.level = 1,
@ -2775,3 +2796,5 @@ MODULE_DESCRIPTION("RAID1 (mirroring) personality for MD");
MODULE_ALIAS("md-personality-3"); /* RAID1 */
MODULE_ALIAS("md-raid1");
MODULE_ALIAS("md-level-1");
module_param(max_queued_requests, int, S_IRUGO|S_IWUSR);

View File

@ -1,10 +1,8 @@
#ifndef _RAID1_H
#define _RAID1_H
typedef struct mirror_info mirror_info_t;
struct mirror_info {
mdk_rdev_t *rdev;
struct md_rdev *rdev;
sector_t head_position;
};
@ -17,61 +15,82 @@ struct mirror_info {
*/
struct pool_info {
mddev_t *mddev;
struct mddev *mddev;
int raid_disks;
};
typedef struct r1bio_s r1bio_t;
struct r1_private_data_s {
mddev_t *mddev;
mirror_info_t *mirrors;
struct r1conf {
struct mddev *mddev;
struct mirror_info *mirrors;
int raid_disks;
/* When choose the best device for a read (read_balance())
* we try to keep sequential reads one the same device
* using 'last_used' and 'next_seq_sect'
*/
int last_used;
sector_t next_seq_sect;
/* During resync, read_balancing is only allowed on the part
* of the array that has been resynced. 'next_resync' tells us
* where that is.
*/
sector_t next_resync;
spinlock_t device_lock;
/* list of 'struct r1bio' that need to be processed by raid1d,
* whether to retry a read, writeout a resync or recovery
* block, or anything else.
*/
struct list_head retry_list;
/* queue pending writes and submit them on unplug */
/* queue pending writes to be submitted on unplug */
struct bio_list pending_bio_list;
int pending_count;
/* for use when syncing mirrors: */
/* for use when syncing mirrors:
* We don't allow both normal IO and resync/recovery IO at
* the same time - resync/recovery can only happen when there
* is no other IO. So when either is active, the other has to wait.
* See more details description in raid1.c near raise_barrier().
*/
wait_queue_head_t wait_barrier;
spinlock_t resync_lock;
int nr_pending;
int nr_waiting;
int nr_queued;
int barrier;
sector_t next_resync;
int fullsync; /* set to 1 if a full sync is needed,
* (fresh device added).
* Cleared when a sync completes.
*/
int recovery_disabled; /* when the same as
* mddev->recovery_disabled
* we don't allow recovery
* to be attempted as we
* expect a read error
*/
wait_queue_head_t wait_barrier;
/* Set to 1 if a full sync is needed, (fresh device added).
* Cleared when a sync completes.
*/
int fullsync;
/* When the same as mddev->recovery_disabled we don't allow
* recovery to be attempted as we expect a read error.
*/
int recovery_disabled;
/* poolinfo contains information about the content of the
* mempools - it changes when the array grows or shrinks
*/
struct pool_info *poolinfo;
mempool_t *r1bio_pool;
mempool_t *r1buf_pool;
/* temporary buffer to synchronous IO when attempting to repair
* a read error.
*/
struct page *tmppage;
mempool_t *r1bio_pool;
mempool_t *r1buf_pool;
/* When taking over an array from a different personality, we store
* the new thread here until we fully activate the array.
*/
struct mdk_thread_s *thread;
struct md_thread *thread;
};
typedef struct r1_private_data_s conf_t;
/*
* this is our 'private' RAID1 bio.
*
@ -79,7 +98,7 @@ typedef struct r1_private_data_s conf_t;
* for this RAID1 operation, and about their status:
*/
struct r1bio_s {
struct r1bio {
atomic_t remaining; /* 'have we finished' count,
* used from IRQ handlers
*/
@ -89,7 +108,7 @@ struct r1bio_s {
sector_t sector;
int sectors;
unsigned long state;
mddev_t *mddev;
struct mddev *mddev;
/*
* original bio going to /dev/mdx
*/
@ -148,6 +167,6 @@ struct r1bio_s {
#define R1BIO_MadeGood 7
#define R1BIO_WriteError 8
extern int md_raid1_congested(mddev_t *mddev, int bits);
extern int md_raid1_congested(struct mddev *mddev, int bits);
#endif

View File

@ -58,13 +58,19 @@
*/
#define NR_RAID10_BIOS 256
static void allow_barrier(conf_t *conf);
static void lower_barrier(conf_t *conf);
/* When there are this many requests queue to be written by
* the raid10 thread, we become 'congested' to provide back-pressure
* for writeback.
*/
static int max_queued_requests = 1024;
static void allow_barrier(struct r10conf *conf);
static void lower_barrier(struct r10conf *conf);
static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data)
{
conf_t *conf = data;
int size = offsetof(struct r10bio_s, devs[conf->copies]);
struct r10conf *conf = data;
int size = offsetof(struct r10bio, devs[conf->copies]);
/* allocate a r10bio with room for raid_disks entries in the bios array */
return kzalloc(size, gfp_flags);
@ -92,9 +98,9 @@ static void r10bio_pool_free(void *r10_bio, void *data)
*/
static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data)
{
conf_t *conf = data;
struct r10conf *conf = data;
struct page *page;
r10bio_t *r10_bio;
struct r10bio *r10_bio;
struct bio *bio;
int i, j;
int nalloc;
@ -158,8 +164,8 @@ out_free_bio:
static void r10buf_pool_free(void *__r10_bio, void *data)
{
int i;
conf_t *conf = data;
r10bio_t *r10bio = __r10_bio;
struct r10conf *conf = data;
struct r10bio *r10bio = __r10_bio;
int j;
for (j=0; j < conf->copies; j++) {
@ -175,7 +181,7 @@ static void r10buf_pool_free(void *__r10_bio, void *data)
r10bio_pool_free(r10bio, conf);
}
static void put_all_bios(conf_t *conf, r10bio_t *r10_bio)
static void put_all_bios(struct r10conf *conf, struct r10bio *r10_bio)
{
int i;
@ -187,28 +193,28 @@ static void put_all_bios(conf_t *conf, r10bio_t *r10_bio)
}
}
static void free_r10bio(r10bio_t *r10_bio)
static void free_r10bio(struct r10bio *r10_bio)
{
conf_t *conf = r10_bio->mddev->private;
struct r10conf *conf = r10_bio->mddev->private;
put_all_bios(conf, r10_bio);
mempool_free(r10_bio, conf->r10bio_pool);
}
static void put_buf(r10bio_t *r10_bio)
static void put_buf(struct r10bio *r10_bio)
{
conf_t *conf = r10_bio->mddev->private;
struct r10conf *conf = r10_bio->mddev->private;
mempool_free(r10_bio, conf->r10buf_pool);
lower_barrier(conf);
}
static void reschedule_retry(r10bio_t *r10_bio)
static void reschedule_retry(struct r10bio *r10_bio)
{
unsigned long flags;
mddev_t *mddev = r10_bio->mddev;
conf_t *conf = mddev->private;
struct mddev *mddev = r10_bio->mddev;
struct r10conf *conf = mddev->private;
spin_lock_irqsave(&conf->device_lock, flags);
list_add(&r10_bio->retry_list, &conf->retry_list);
@ -226,11 +232,11 @@ static void reschedule_retry(r10bio_t *r10_bio)
* operation and are ready to return a success/failure code to the buffer
* cache layer.
*/
static void raid_end_bio_io(r10bio_t *r10_bio)
static void raid_end_bio_io(struct r10bio *r10_bio)
{
struct bio *bio = r10_bio->master_bio;
int done;
conf_t *conf = r10_bio->mddev->private;
struct r10conf *conf = r10_bio->mddev->private;
if (bio->bi_phys_segments) {
unsigned long flags;
@ -256,9 +262,9 @@ static void raid_end_bio_io(r10bio_t *r10_bio)
/*
* Update disk head position estimator based on IRQ completion info.
*/
static inline void update_head_pos(int slot, r10bio_t *r10_bio)
static inline void update_head_pos(int slot, struct r10bio *r10_bio)
{
conf_t *conf = r10_bio->mddev->private;
struct r10conf *conf = r10_bio->mddev->private;
conf->mirrors[r10_bio->devs[slot].devnum].head_position =
r10_bio->devs[slot].addr + (r10_bio->sectors);
@ -267,7 +273,7 @@ static inline void update_head_pos(int slot, r10bio_t *r10_bio)
/*
* Find the disk number which triggered given bio
*/
static int find_bio_disk(conf_t *conf, r10bio_t *r10_bio,
static int find_bio_disk(struct r10conf *conf, struct r10bio *r10_bio,
struct bio *bio, int *slotp)
{
int slot;
@ -287,9 +293,9 @@ static int find_bio_disk(conf_t *conf, r10bio_t *r10_bio,
static void raid10_end_read_request(struct bio *bio, int error)
{
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
r10bio_t *r10_bio = bio->bi_private;
struct r10bio *r10_bio = bio->bi_private;
int slot, dev;
conf_t *conf = r10_bio->mddev->private;
struct r10conf *conf = r10_bio->mddev->private;
slot = r10_bio->read_slot;
@ -327,7 +333,7 @@ static void raid10_end_read_request(struct bio *bio, int error)
}
}
static void close_write(r10bio_t *r10_bio)
static void close_write(struct r10bio *r10_bio)
{
/* clear the bitmap if all writes complete successfully */
bitmap_endwrite(r10_bio->mddev->bitmap, r10_bio->sector,
@ -337,7 +343,7 @@ static void close_write(r10bio_t *r10_bio)
md_write_end(r10_bio->mddev);
}
static void one_write_done(r10bio_t *r10_bio)
static void one_write_done(struct r10bio *r10_bio)
{
if (atomic_dec_and_test(&r10_bio->remaining)) {
if (test_bit(R10BIO_WriteError, &r10_bio->state))
@ -355,10 +361,10 @@ static void one_write_done(r10bio_t *r10_bio)
static void raid10_end_write_request(struct bio *bio, int error)
{
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
r10bio_t *r10_bio = bio->bi_private;
struct r10bio *r10_bio = bio->bi_private;
int dev;
int dec_rdev = 1;
conf_t *conf = r10_bio->mddev->private;
struct r10conf *conf = r10_bio->mddev->private;
int slot;
dev = find_bio_disk(conf, r10_bio, bio, &slot);
@ -433,7 +439,7 @@ static void raid10_end_write_request(struct bio *bio, int error)
* sector offset to a virtual address
*/
static void raid10_find_phys(conf_t *conf, r10bio_t *r10bio)
static void raid10_find_phys(struct r10conf *conf, struct r10bio *r10bio)
{
int n,f;
sector_t sector;
@ -481,7 +487,7 @@ static void raid10_find_phys(conf_t *conf, r10bio_t *r10bio)
BUG_ON(slot != conf->copies);
}
static sector_t raid10_find_virt(conf_t *conf, sector_t sector, int dev)
static sector_t raid10_find_virt(struct r10conf *conf, sector_t sector, int dev)
{
sector_t offset, chunk, vchunk;
@ -522,7 +528,7 @@ static int raid10_mergeable_bvec(struct request_queue *q,
struct bvec_merge_data *bvm,
struct bio_vec *biovec)
{
mddev_t *mddev = q->queuedata;
struct mddev *mddev = q->queuedata;
sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
int max;
unsigned int chunk_sectors = mddev->chunk_sectors;
@ -555,14 +561,14 @@ static int raid10_mergeable_bvec(struct request_queue *q,
* FIXME: possibly should rethink readbalancing and do it differently
* depending on near_copies / far_copies geometry.
*/
static int read_balance(conf_t *conf, r10bio_t *r10_bio, int *max_sectors)
static int read_balance(struct r10conf *conf, struct r10bio *r10_bio, int *max_sectors)
{
const sector_t this_sector = r10_bio->sector;
int disk, slot;
int sectors = r10_bio->sectors;
int best_good_sectors;
sector_t new_distance, best_dist;
mdk_rdev_t *rdev;
struct md_rdev *rdev;
int do_balance;
int best_slot;
@ -677,15 +683,19 @@ retry:
static int raid10_congested(void *data, int bits)
{
mddev_t *mddev = data;
conf_t *conf = mddev->private;
struct mddev *mddev = data;
struct r10conf *conf = mddev->private;
int i, ret = 0;
if ((bits & (1 << BDI_async_congested)) &&
conf->pending_count >= max_queued_requests)
return 1;
if (mddev_congested(mddev, bits))
return 1;
rcu_read_lock();
for (i = 0; i < conf->raid_disks && ret == 0; i++) {
mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
if (rdev && !test_bit(Faulty, &rdev->flags)) {
struct request_queue *q = bdev_get_queue(rdev->bdev);
@ -696,7 +706,7 @@ static int raid10_congested(void *data, int bits)
return ret;
}
static void flush_pending_writes(conf_t *conf)
static void flush_pending_writes(struct r10conf *conf)
{
/* Any writes that have been queued but are awaiting
* bitmap updates get flushed here.
@ -706,10 +716,12 @@ static void flush_pending_writes(conf_t *conf)
if (conf->pending_bio_list.head) {
struct bio *bio;
bio = bio_list_get(&conf->pending_bio_list);
conf->pending_count = 0;
spin_unlock_irq(&conf->device_lock);
/* flush any pending bitmap writes to disk
* before proceeding w/ I/O */
bitmap_unplug(conf->mddev->bitmap);
wake_up(&conf->wait_barrier);
while (bio) { /* submit pending writes */
struct bio *next = bio->bi_next;
@ -743,7 +755,7 @@ static void flush_pending_writes(conf_t *conf)
* lower_barrier when the particular background IO completes.
*/
static void raise_barrier(conf_t *conf, int force)
static void raise_barrier(struct r10conf *conf, int force)
{
BUG_ON(force && !conf->barrier);
spin_lock_irq(&conf->resync_lock);
@ -763,7 +775,7 @@ static void raise_barrier(conf_t *conf, int force)
spin_unlock_irq(&conf->resync_lock);
}
static void lower_barrier(conf_t *conf)
static void lower_barrier(struct r10conf *conf)
{
unsigned long flags;
spin_lock_irqsave(&conf->resync_lock, flags);
@ -772,7 +784,7 @@ static void lower_barrier(conf_t *conf)
wake_up(&conf->wait_barrier);
}
static void wait_barrier(conf_t *conf)
static void wait_barrier(struct r10conf *conf)
{
spin_lock_irq(&conf->resync_lock);
if (conf->barrier) {
@ -786,7 +798,7 @@ static void wait_barrier(conf_t *conf)
spin_unlock_irq(&conf->resync_lock);
}
static void allow_barrier(conf_t *conf)
static void allow_barrier(struct r10conf *conf)
{
unsigned long flags;
spin_lock_irqsave(&conf->resync_lock, flags);
@ -795,7 +807,7 @@ static void allow_barrier(conf_t *conf)
wake_up(&conf->wait_barrier);
}
static void freeze_array(conf_t *conf)
static void freeze_array(struct r10conf *conf)
{
/* stop syncio and normal IO and wait for everything to
* go quiet.
@ -820,7 +832,7 @@ static void freeze_array(conf_t *conf)
spin_unlock_irq(&conf->resync_lock);
}
static void unfreeze_array(conf_t *conf)
static void unfreeze_array(struct r10conf *conf)
{
/* reverse the effect of the freeze */
spin_lock_irq(&conf->resync_lock);
@ -830,11 +842,11 @@ static void unfreeze_array(conf_t *conf)
spin_unlock_irq(&conf->resync_lock);
}
static int make_request(mddev_t *mddev, struct bio * bio)
static int make_request(struct mddev *mddev, struct bio * bio)
{
conf_t *conf = mddev->private;
mirror_info_t *mirror;
r10bio_t *r10_bio;
struct r10conf *conf = mddev->private;
struct mirror_info *mirror;
struct r10bio *r10_bio;
struct bio *read_bio;
int i;
int chunk_sects = conf->chunk_mask + 1;
@ -842,7 +854,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
const unsigned long do_sync = (bio->bi_rw & REQ_SYNC);
const unsigned long do_fua = (bio->bi_rw & REQ_FUA);
unsigned long flags;
mdk_rdev_t *blocked_rdev;
struct md_rdev *blocked_rdev;
int plugged;
int sectors_handled;
int max_sectors;
@ -996,6 +1008,11 @@ read_again:
/*
* WRITE:
*/
if (conf->pending_count >= max_queued_requests) {
md_wakeup_thread(mddev->thread);
wait_event(conf->wait_barrier,
conf->pending_count < max_queued_requests);
}
/* first select target devices under rcu_lock and
* inc refcount on their rdev. Record them by setting
* bios[x] to bio
@ -1017,7 +1034,7 @@ retry_write:
for (i = 0; i < conf->copies; i++) {
int d = r10_bio->devs[i].devnum;
mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[d].rdev);
struct md_rdev *rdev = rcu_dereference(conf->mirrors[d].rdev);
if (rdev && unlikely(test_bit(Blocked, &rdev->flags))) {
atomic_inc(&rdev->nr_pending);
blocked_rdev = rdev;
@ -1129,6 +1146,7 @@ retry_write:
atomic_inc(&r10_bio->remaining);
spin_lock_irqsave(&conf->device_lock, flags);
bio_list_add(&conf->pending_bio_list, mbio);
conf->pending_count++;
spin_unlock_irqrestore(&conf->device_lock, flags);
}
@ -1161,9 +1179,9 @@ retry_write:
return 0;
}
static void status(struct seq_file *seq, mddev_t *mddev)
static void status(struct seq_file *seq, struct mddev *mddev)
{
conf_t *conf = mddev->private;
struct r10conf *conf = mddev->private;
int i;
if (conf->near_copies < conf->raid_disks)
@ -1190,7 +1208,7 @@ static void status(struct seq_file *seq, mddev_t *mddev)
* Don't consider the device numbered 'ignore'
* as we might be about to remove it.
*/
static int enough(conf_t *conf, int ignore)
static int enough(struct r10conf *conf, int ignore)
{
int first = 0;
@ -1209,10 +1227,10 @@ static int enough(conf_t *conf, int ignore)
return 1;
}
static void error(mddev_t *mddev, mdk_rdev_t *rdev)
static void error(struct mddev *mddev, struct md_rdev *rdev)
{
char b[BDEVNAME_SIZE];
conf_t *conf = mddev->private;
struct r10conf *conf = mddev->private;
/*
* If it is not operational, then we have already marked it as dead
@ -1246,10 +1264,10 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
mdname(mddev), conf->raid_disks - mddev->degraded);
}
static void print_conf(conf_t *conf)
static void print_conf(struct r10conf *conf)
{
int i;
mirror_info_t *tmp;
struct mirror_info *tmp;
printk(KERN_DEBUG "RAID10 conf printout:\n");
if (!conf) {
@ -1270,7 +1288,7 @@ static void print_conf(conf_t *conf)
}
}
static void close_sync(conf_t *conf)
static void close_sync(struct r10conf *conf)
{
wait_barrier(conf);
allow_barrier(conf);
@ -1279,11 +1297,11 @@ static void close_sync(conf_t *conf)
conf->r10buf_pool = NULL;
}
static int raid10_spare_active(mddev_t *mddev)
static int raid10_spare_active(struct mddev *mddev)
{
int i;
conf_t *conf = mddev->private;
mirror_info_t *tmp;
struct r10conf *conf = mddev->private;
struct mirror_info *tmp;
int count = 0;
unsigned long flags;
@ -1309,9 +1327,9 @@ static int raid10_spare_active(mddev_t *mddev)
}
static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev)
{
conf_t *conf = mddev->private;
struct r10conf *conf = mddev->private;
int err = -EEXIST;
int mirror;
int first = 0;
@ -1334,7 +1352,7 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
else
mirror = first;
for ( ; mirror <= last ; mirror++) {
mirror_info_t *p = &conf->mirrors[mirror];
struct mirror_info *p = &conf->mirrors[mirror];
if (p->recovery_disabled == mddev->recovery_disabled)
continue;
if (!p->rdev)
@ -1355,6 +1373,7 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
}
p->head_position = 0;
p->recovery_disabled = mddev->recovery_disabled - 1;
rdev->raid_disk = mirror;
err = 0;
if (rdev->saved_raid_disk != mirror)
@ -1368,12 +1387,12 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
return err;
}
static int raid10_remove_disk(mddev_t *mddev, int number)
static int raid10_remove_disk(struct mddev *mddev, int number)
{
conf_t *conf = mddev->private;
struct r10conf *conf = mddev->private;
int err = 0;
mdk_rdev_t *rdev;
mirror_info_t *p = conf->mirrors+ number;
struct md_rdev *rdev;
struct mirror_info *p = conf->mirrors+ number;
print_conf(conf);
rdev = p->rdev;
@ -1411,8 +1430,8 @@ abort:
static void end_sync_read(struct bio *bio, int error)
{
r10bio_t *r10_bio = bio->bi_private;
conf_t *conf = r10_bio->mddev->private;
struct r10bio *r10_bio = bio->bi_private;
struct r10conf *conf = r10_bio->mddev->private;
int d;
d = find_bio_disk(conf, r10_bio, bio, NULL);
@ -1439,9 +1458,9 @@ static void end_sync_read(struct bio *bio, int error)
}
}
static void end_sync_request(r10bio_t *r10_bio)
static void end_sync_request(struct r10bio *r10_bio)
{
mddev_t *mddev = r10_bio->mddev;
struct mddev *mddev = r10_bio->mddev;
while (atomic_dec_and_test(&r10_bio->remaining)) {
if (r10_bio->master_bio == NULL) {
@ -1455,7 +1474,7 @@ static void end_sync_request(r10bio_t *r10_bio)
md_done_sync(mddev, s, 1);
break;
} else {
r10bio_t *r10_bio2 = (r10bio_t *)r10_bio->master_bio;
struct r10bio *r10_bio2 = (struct r10bio *)r10_bio->master_bio;
if (test_bit(R10BIO_MadeGood, &r10_bio->state) ||
test_bit(R10BIO_WriteError, &r10_bio->state))
reschedule_retry(r10_bio);
@ -1469,9 +1488,9 @@ static void end_sync_request(r10bio_t *r10_bio)
static void end_sync_write(struct bio *bio, int error)
{
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
r10bio_t *r10_bio = bio->bi_private;
mddev_t *mddev = r10_bio->mddev;
conf_t *conf = mddev->private;
struct r10bio *r10_bio = bio->bi_private;
struct mddev *mddev = r10_bio->mddev;
struct r10conf *conf = mddev->private;
int d;
sector_t first_bad;
int bad_sectors;
@ -1509,9 +1528,9 @@ static void end_sync_write(struct bio *bio, int error)
* We check if all blocks are in-sync and only write to blocks that
* aren't in sync
*/
static void sync_request_write(mddev_t *mddev, r10bio_t *r10_bio)
static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
{
conf_t *conf = mddev->private;
struct r10conf *conf = mddev->private;
int i, first;
struct bio *tbio, *fbio;
@ -1609,7 +1628,7 @@ done:
* The second for writing.
*
*/
static void fix_recovery_read_error(r10bio_t *r10_bio)
static void fix_recovery_read_error(struct r10bio *r10_bio)
{
/* We got a read error during recovery.
* We repeat the read in smaller page-sized sections.
@ -1618,8 +1637,8 @@ static void fix_recovery_read_error(r10bio_t *r10_bio)
* If a read fails, record a bad block on both old and
* new devices.
*/
mddev_t *mddev = r10_bio->mddev;
conf_t *conf = mddev->private;
struct mddev *mddev = r10_bio->mddev;
struct r10conf *conf = mddev->private;
struct bio *bio = r10_bio->devs[0].bio;
sector_t sect = 0;
int sectors = r10_bio->sectors;
@ -1629,7 +1648,7 @@ static void fix_recovery_read_error(r10bio_t *r10_bio)
while (sectors) {
int s = sectors;
mdk_rdev_t *rdev;
struct md_rdev *rdev;
sector_t addr;
int ok;
@ -1663,7 +1682,7 @@ static void fix_recovery_read_error(r10bio_t *r10_bio)
if (rdev != conf->mirrors[dw].rdev) {
/* need bad block on destination too */
mdk_rdev_t *rdev2 = conf->mirrors[dw].rdev;
struct md_rdev *rdev2 = conf->mirrors[dw].rdev;
addr = r10_bio->devs[1].addr + sect;
ok = rdev_set_badblocks(rdev2, addr, s, 0);
if (!ok) {
@ -1688,9 +1707,9 @@ static void fix_recovery_read_error(r10bio_t *r10_bio)
}
}
static void recovery_request_write(mddev_t *mddev, r10bio_t *r10_bio)
static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio)
{
conf_t *conf = mddev->private;
struct r10conf *conf = mddev->private;
int d;
struct bio *wbio;
@ -1719,7 +1738,7 @@ static void recovery_request_write(mddev_t *mddev, r10bio_t *r10_bio)
* since the last recorded read error.
*
*/
static void check_decay_read_errors(mddev_t *mddev, mdk_rdev_t *rdev)
static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
{
struct timespec cur_time_mon;
unsigned long hours_since_last;
@ -1750,7 +1769,7 @@ static void check_decay_read_errors(mddev_t *mddev, mdk_rdev_t *rdev)
atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
}
static int r10_sync_page_io(mdk_rdev_t *rdev, sector_t sector,
static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
int sectors, struct page *page, int rw)
{
sector_t first_bad;
@ -1778,11 +1797,11 @@ static int r10_sync_page_io(mdk_rdev_t *rdev, sector_t sector,
* 3. Performs writes following reads for array synchronising.
*/
static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10bio *r10_bio)
{
int sect = 0; /* Offset from r10_bio->sector */
int sectors = r10_bio->sectors;
mdk_rdev_t*rdev;
struct md_rdev*rdev;
int max_read_errors = atomic_read(&mddev->max_corr_read_errors);
int d = r10_bio->devs[r10_bio->read_slot].devnum;
@ -1983,12 +2002,12 @@ static int submit_bio_wait(int rw, struct bio *bio)
return test_bit(BIO_UPTODATE, &bio->bi_flags);
}
static int narrow_write_error(r10bio_t *r10_bio, int i)
static int narrow_write_error(struct r10bio *r10_bio, int i)
{
struct bio *bio = r10_bio->master_bio;
mddev_t *mddev = r10_bio->mddev;
conf_t *conf = mddev->private;
mdk_rdev_t *rdev = conf->mirrors[r10_bio->devs[i].devnum].rdev;
struct mddev *mddev = r10_bio->mddev;
struct r10conf *conf = mddev->private;
struct md_rdev *rdev = conf->mirrors[r10_bio->devs[i].devnum].rdev;
/* bio has the data to be written to slot 'i' where
* we just recently had a write error.
* We repeatedly clone the bio and trim down to one block,
@ -2040,13 +2059,13 @@ static int narrow_write_error(r10bio_t *r10_bio, int i)
return ok;
}
static void handle_read_error(mddev_t *mddev, r10bio_t *r10_bio)
static void handle_read_error(struct mddev *mddev, struct r10bio *r10_bio)
{
int slot = r10_bio->read_slot;
int mirror = r10_bio->devs[slot].devnum;
struct bio *bio;
conf_t *conf = mddev->private;
mdk_rdev_t *rdev;
struct r10conf *conf = mddev->private;
struct md_rdev *rdev;
char b[BDEVNAME_SIZE];
unsigned long do_sync;
int max_sectors;
@ -2139,7 +2158,7 @@ read_more:
generic_make_request(bio);
}
static void handle_write_completed(conf_t *conf, r10bio_t *r10_bio)
static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
{
/* Some sort of write request has finished and it
* succeeded in writing where we thought there was a
@ -2148,7 +2167,7 @@ static void handle_write_completed(conf_t *conf, r10bio_t *r10_bio)
* a bad block.
*/
int m;
mdk_rdev_t *rdev;
struct md_rdev *rdev;
if (test_bit(R10BIO_IsSync, &r10_bio->state) ||
test_bit(R10BIO_IsRecover, &r10_bio->state)) {
@ -2200,11 +2219,11 @@ static void handle_write_completed(conf_t *conf, r10bio_t *r10_bio)
}
}
static void raid10d(mddev_t *mddev)
static void raid10d(struct mddev *mddev)
{
r10bio_t *r10_bio;
struct r10bio *r10_bio;
unsigned long flags;
conf_t *conf = mddev->private;
struct r10conf *conf = mddev->private;
struct list_head *head = &conf->retry_list;
struct blk_plug plug;
@ -2220,7 +2239,7 @@ static void raid10d(mddev_t *mddev)
spin_unlock_irqrestore(&conf->device_lock, flags);
break;
}
r10_bio = list_entry(head->prev, r10bio_t, retry_list);
r10_bio = list_entry(head->prev, struct r10bio, retry_list);
list_del(head->prev);
conf->nr_queued--;
spin_unlock_irqrestore(&conf->device_lock, flags);
@ -2252,7 +2271,7 @@ static void raid10d(mddev_t *mddev)
}
static int init_resync(conf_t *conf)
static int init_resync(struct r10conf *conf)
{
int buffs;
@ -2297,11 +2316,11 @@ static int init_resync(conf_t *conf)
*
*/
static sector_t sync_request(mddev_t *mddev, sector_t sector_nr,
static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
int *skipped, int go_faster)
{
conf_t *conf = mddev->private;
r10bio_t *r10_bio;
struct r10conf *conf = mddev->private;
struct r10bio *r10_bio;
struct bio *biolist = NULL, *bio;
sector_t max_sector, nr_sectors;
int i;
@ -2393,7 +2412,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr,
for (i=0 ; i<conf->raid_disks; i++) {
int still_degraded;
r10bio_t *rb2;
struct r10bio *rb2;
sector_t sect;
int must_sync;
int any_working;
@ -2453,7 +2472,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr,
int k;
int d = r10_bio->devs[j].devnum;
sector_t from_addr, to_addr;
mdk_rdev_t *rdev;
struct md_rdev *rdev;
sector_t sector, first_bad;
int bad_sectors;
if (!conf->mirrors[d].rdev ||
@ -2547,8 +2566,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr,
}
if (biolist == NULL) {
while (r10_bio) {
r10bio_t *rb2 = r10_bio;
r10_bio = (r10bio_t*) rb2->master_bio;
struct r10bio *rb2 = r10_bio;
r10_bio = (struct r10bio*) rb2->master_bio;
rb2->master_bio = NULL;
put_buf(rb2);
}
@ -2714,10 +2733,10 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr,
}
static sector_t
raid10_size(mddev_t *mddev, sector_t sectors, int raid_disks)
raid10_size(struct mddev *mddev, sector_t sectors, int raid_disks)
{
sector_t size;
conf_t *conf = mddev->private;
struct r10conf *conf = mddev->private;
if (!raid_disks)
raid_disks = conf->raid_disks;
@ -2733,9 +2752,9 @@ raid10_size(mddev_t *mddev, sector_t sectors, int raid_disks)
}
static conf_t *setup_conf(mddev_t *mddev)
static struct r10conf *setup_conf(struct mddev *mddev)
{
conf_t *conf = NULL;
struct r10conf *conf = NULL;
int nc, fc, fo;
sector_t stride, size;
int err = -EINVAL;
@ -2760,7 +2779,7 @@ static conf_t *setup_conf(mddev_t *mddev)
}
err = -ENOMEM;
conf = kzalloc(sizeof(conf_t), GFP_KERNEL);
conf = kzalloc(sizeof(struct r10conf), GFP_KERNEL);
if (!conf)
goto out;
@ -2836,12 +2855,12 @@ static conf_t *setup_conf(mddev_t *mddev)
return ERR_PTR(err);
}
static int run(mddev_t *mddev)
static int run(struct mddev *mddev)
{
conf_t *conf;
struct r10conf *conf;
int i, disk_idx, chunk_size;
mirror_info_t *disk;
mdk_rdev_t *rdev;
struct mirror_info *disk;
struct md_rdev *rdev;
sector_t size;
/*
@ -2913,6 +2932,7 @@ static int run(mddev_t *mddev)
if (disk->rdev)
conf->fullsync = 1;
}
disk->recovery_disabled = mddev->recovery_disabled - 1;
}
if (mddev->recovery_cp != MaxSector)
@ -2966,9 +2986,9 @@ out:
return -EIO;
}
static int stop(mddev_t *mddev)
static int stop(struct mddev *mddev)
{
conf_t *conf = mddev->private;
struct r10conf *conf = mddev->private;
raise_barrier(conf, 0);
lower_barrier(conf);
@ -2983,9 +3003,9 @@ static int stop(mddev_t *mddev)
return 0;
}
static void raid10_quiesce(mddev_t *mddev, int state)
static void raid10_quiesce(struct mddev *mddev, int state)
{
conf_t *conf = mddev->private;
struct r10conf *conf = mddev->private;
switch(state) {
case 1:
@ -2997,10 +3017,10 @@ static void raid10_quiesce(mddev_t *mddev, int state)
}
}
static void *raid10_takeover_raid0(mddev_t *mddev)
static void *raid10_takeover_raid0(struct mddev *mddev)
{
mdk_rdev_t *rdev;
conf_t *conf;
struct md_rdev *rdev;
struct r10conf *conf;
if (mddev->degraded > 0) {
printk(KERN_ERR "md/raid10:%s: Error: degraded raid0!\n",
@ -3029,17 +3049,17 @@ static void *raid10_takeover_raid0(mddev_t *mddev)
return conf;
}
static void *raid10_takeover(mddev_t *mddev)
static void *raid10_takeover(struct mddev *mddev)
{
struct raid0_private_data *raid0_priv;
struct r0conf *raid0_conf;
/* raid10 can take over:
* raid0 - providing it has only two drives
*/
if (mddev->level == 0) {
/* for raid0 takeover only one zone is supported */
raid0_priv = mddev->private;
if (raid0_priv->nr_strip_zones > 1) {
raid0_conf = mddev->private;
if (raid0_conf->nr_strip_zones > 1) {
printk(KERN_ERR "md/raid10:%s: cannot takeover raid 0"
" with more than one zone.\n",
mdname(mddev));
@ -3050,7 +3070,7 @@ static void *raid10_takeover(mddev_t *mddev)
return ERR_PTR(-EINVAL);
}
static struct mdk_personality raid10_personality =
static struct md_personality raid10_personality =
{
.name = "raid10",
.level = 10,
@ -3086,3 +3106,5 @@ MODULE_DESCRIPTION("RAID10 (striped mirror) personality for MD");
MODULE_ALIAS("md-personality-9"); /* RAID10 */
MODULE_ALIAS("md-raid10");
MODULE_ALIAS("md-level-10");
module_param(max_queued_requests, int, S_IRUGO|S_IWUSR);

View File

@ -1,10 +1,8 @@
#ifndef _RAID10_H
#define _RAID10_H
typedef struct mirror_info mirror_info_t;
struct mirror_info {
mdk_rdev_t *rdev;
struct md_rdev *rdev;
sector_t head_position;
int recovery_disabled; /* matches
* mddev->recovery_disabled
@ -13,11 +11,9 @@ struct mirror_info {
*/
};
typedef struct r10bio_s r10bio_t;
struct r10_private_data_s {
mddev_t *mddev;
mirror_info_t *mirrors;
struct r10conf {
struct mddev *mddev;
struct mirror_info *mirrors;
int raid_disks;
spinlock_t device_lock;
@ -46,7 +42,7 @@ struct r10_private_data_s {
struct list_head retry_list;
/* queue pending writes and submit them on unplug */
struct bio_list pending_bio_list;
int pending_count;
spinlock_t resync_lock;
int nr_pending;
@ -68,11 +64,9 @@ struct r10_private_data_s {
/* When taking over an array from a different personality, we store
* the new thread here until we fully activate the array.
*/
struct mdk_thread_s *thread;
struct md_thread *thread;
};
typedef struct r10_private_data_s conf_t;
/*
* this is our 'private' RAID10 bio.
*
@ -80,14 +74,14 @@ typedef struct r10_private_data_s conf_t;
* for this RAID10 operation, and about their status:
*/
struct r10bio_s {
struct r10bio {
atomic_t remaining; /* 'have we finished' count,
* used from IRQ handlers
*/
sector_t sector; /* virtual sector number */
int sectors;
unsigned long state;
mddev_t *mddev;
struct mddev *mddev;
/*
* original bio going to /dev/mdx
*/

File diff suppressed because it is too large Load Diff

View File

@ -197,7 +197,7 @@ enum reconstruct_states {
struct stripe_head {
struct hlist_node hash;
struct list_head lru; /* inactive_list or handle_list */
struct raid5_private_data *raid_conf;
struct r5conf *raid_conf;
short generation; /* increments with every
* reshape */
sector_t sector; /* sector of this row */
@ -248,7 +248,7 @@ struct stripe_head_state {
unsigned long ops_request;
struct bio *return_bi;
mdk_rdev_t *blocked_rdev;
struct md_rdev *blocked_rdev;
int handle_bad_blocks;
};
@ -344,12 +344,12 @@ enum {
struct disk_info {
mdk_rdev_t *rdev;
struct md_rdev *rdev;
};
struct raid5_private_data {
struct r5conf {
struct hlist_head *stripe_hashtbl;
mddev_t *mddev;
struct mddev *mddev;
struct disk_info *spare;
int chunk_sectors;
int level, algorithm;
@ -436,11 +436,9 @@ struct raid5_private_data {
/* When taking over an array from a different personality, we store
* the new thread here until we fully activate the array.
*/
struct mdk_thread_s *thread;
struct md_thread *thread;
};
typedef struct raid5_private_data raid5_conf_t;
/*
* Our supported algorithms
*/
@ -503,7 +501,7 @@ static inline int algorithm_is_DDF(int layout)
return layout >= 8 && layout <= 10;
}
extern int md_raid5_congested(mddev_t *mddev, int bits);
extern void md_raid5_kick_device(raid5_conf_t *conf);
extern int raid5_set_cache_size(mddev_t *mddev, int size);
extern int md_raid5_congested(struct mddev *mddev, int bits);
extern void md_raid5_kick_device(struct r5conf *conf);
extern int raid5_set_cache_size(struct mddev *mddev, int size);
#endif

View File

@ -11,7 +11,7 @@
* ----------------------------------------------------------------------- */
/*
* raid6int$#.c
* int$#.c
*
* $#-way unrolled portable integer math RAID-6 instruction set
*