2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
linear.c : Multiple Devices driver for Linux
|
|
|
|
Copyright (C) 1994-96 Marc ZYNGIER
|
|
|
|
<zyngier@ufr-info-p7.ibp.fr> or
|
|
|
|
<maz@gloups.fdn.fr>
|
|
|
|
|
|
|
|
Linear mode management functions.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
(for example /usr/src/linux/COPYING); if not, write to the Free
|
|
|
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2009-03-31 03:33:13 +00:00
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/raid/md_u.h>
|
|
|
|
#include <linux/seq_file.h>
|
2011-07-03 17:58:33 +00:00
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2009-03-31 03:33:13 +00:00
|
|
|
#include "md.h"
|
2009-03-31 03:27:03 +00:00
|
|
|
#include "linear.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* find which device holds a particular offset
|
|
|
|
*/
|
2011-10-11 05:48:49 +00:00
|
|
|
static inline struct dev_info *which_dev(struct mddev *mddev, sector_t sector)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-06-16 06:57:08 +00:00
|
|
|
int lo, mid, hi;
|
2011-10-11 05:48:54 +00:00
|
|
|
struct linear_conf *conf;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-06-16 06:57:08 +00:00
|
|
|
lo = 0;
|
|
|
|
hi = mddev->raid_disks - 1;
|
2009-06-17 22:49:35 +00:00
|
|
|
conf = rcu_dereference(mddev->private);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-06-16 06:57:08 +00:00
|
|
|
/*
|
|
|
|
* Binary Search
|
|
|
|
*/
|
|
|
|
|
|
|
|
while (hi > lo) {
|
|
|
|
|
|
|
|
mid = (hi + lo) / 2;
|
|
|
|
if (sector < conf->disks[mid].end_sector)
|
|
|
|
hi = mid;
|
|
|
|
else
|
|
|
|
lo = mid + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return conf->disks + lo;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-09-09 23:23:47 +00:00
|
|
|
* linear_mergeable_bvec -- tell bio layer if two requests can be merged
|
2005-04-16 22:20:36 +00:00
|
|
|
* @q: request queue
|
2008-07-03 07:53:43 +00:00
|
|
|
* @bvm: properties of new bio
|
2005-04-16 22:20:36 +00:00
|
|
|
* @biovec: the request that could be merged to it.
|
|
|
|
*
|
|
|
|
* Return amount of bytes we can take at this offset
|
|
|
|
*/
|
2008-07-03 07:53:43 +00:00
|
|
|
static int linear_mergeable_bvec(struct request_queue *q,
|
|
|
|
struct bvec_merge_data *bvm,
|
|
|
|
struct bio_vec *biovec)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2011-10-11 05:47:53 +00:00
|
|
|
struct mddev *mddev = q->queuedata;
|
2011-10-11 05:48:49 +00:00
|
|
|
struct dev_info *dev0;
|
2008-07-03 07:53:43 +00:00
|
|
|
unsigned long maxsectors, bio_sectors = bvm->bi_size >> 9;
|
|
|
|
sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-06-17 22:49:35 +00:00
|
|
|
rcu_read_lock();
|
2005-04-16 22:20:36 +00:00
|
|
|
dev0 = which_dev(mddev, sector);
|
2009-06-16 06:56:13 +00:00
|
|
|
maxsectors = dev0->end_sector - sector;
|
2009-06-17 22:49:35 +00:00
|
|
|
rcu_read_unlock();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (maxsectors < bio_sectors)
|
|
|
|
maxsectors = 0;
|
|
|
|
else
|
|
|
|
maxsectors -= bio_sectors;
|
|
|
|
|
|
|
|
if (maxsectors <= (PAGE_SIZE >> 9 ) && bio_sectors == 0)
|
|
|
|
return biovec->bv_len;
|
|
|
|
/* The bytes available at this offset could be really big,
|
|
|
|
* so we cap at 2^31 to avoid overflow */
|
|
|
|
if (maxsectors > (1 << (31-9)))
|
|
|
|
return 1<<31;
|
|
|
|
return maxsectors << 9;
|
|
|
|
}
|
|
|
|
|
2006-10-03 08:15:53 +00:00
|
|
|
static int linear_congested(void *data, int bits)
|
|
|
|
{
|
2011-10-11 05:47:53 +00:00
|
|
|
struct mddev *mddev = data;
|
2011-10-11 05:48:54 +00:00
|
|
|
struct linear_conf *conf;
|
2006-10-03 08:15:53 +00:00
|
|
|
int i, ret = 0;
|
|
|
|
|
2009-09-23 08:10:29 +00:00
|
|
|
if (mddev_congested(mddev, bits))
|
|
|
|
return 1;
|
|
|
|
|
2009-06-17 22:49:35 +00:00
|
|
|
rcu_read_lock();
|
|
|
|
conf = rcu_dereference(mddev->private);
|
|
|
|
|
2006-10-03 08:15:53 +00:00
|
|
|
for (i = 0; i < mddev->raid_disks && !ret ; i++) {
|
2007-07-24 07:28:11 +00:00
|
|
|
struct request_queue *q = bdev_get_queue(conf->disks[i].rdev->bdev);
|
2006-10-03 08:15:53 +00:00
|
|
|
ret |= bdi_congested(&q->backing_dev_info, bits);
|
|
|
|
}
|
2009-06-17 22:49:35 +00:00
|
|
|
|
|
|
|
rcu_read_unlock();
|
2006-10-03 08:15:53 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-11 05:47:53 +00:00
|
|
|
static sector_t linear_size(struct mddev *mddev, sector_t sectors, int raid_disks)
|
2009-03-18 01:10:40 +00:00
|
|
|
{
|
2011-10-11 05:48:54 +00:00
|
|
|
struct linear_conf *conf;
|
2009-06-17 22:49:35 +00:00
|
|
|
sector_t array_sectors;
|
2009-03-18 01:10:40 +00:00
|
|
|
|
2009-06-17 22:49:35 +00:00
|
|
|
rcu_read_lock();
|
|
|
|
conf = rcu_dereference(mddev->private);
|
2009-03-18 01:10:40 +00:00
|
|
|
WARN_ONCE(sectors || raid_disks,
|
|
|
|
"%s does not support generic reshape\n", __func__);
|
2009-06-17 22:49:35 +00:00
|
|
|
array_sectors = conf->array_sectors;
|
|
|
|
rcu_read_unlock();
|
2009-03-18 01:10:40 +00:00
|
|
|
|
2009-06-17 22:49:35 +00:00
|
|
|
return array_sectors;
|
2009-03-18 01:10:40 +00:00
|
|
|
}
|
|
|
|
|
2011-10-11 05:48:54 +00:00
|
|
|
static struct linear_conf *linear_conf(struct mddev *mddev, int raid_disks)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2011-10-11 05:48:54 +00:00
|
|
|
struct linear_conf *conf;
|
2011-10-11 05:45:26 +00:00
|
|
|
struct md_rdev *rdev;
|
2009-06-16 06:55:26 +00:00
|
|
|
int i, cnt;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-10-11 05:48:49 +00:00
|
|
|
conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(struct dev_info),
|
2005-04-16 22:20:36 +00:00
|
|
|
GFP_KERNEL);
|
|
|
|
if (!conf)
|
2006-06-26 07:27:41 +00:00
|
|
|
return NULL;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
cnt = 0;
|
2008-07-21 07:05:25 +00:00
|
|
|
conf->array_sectors = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-01-08 21:31:08 +00:00
|
|
|
list_for_each_entry(rdev, &mddev->disks, same_set) {
|
2005-04-16 22:20:36 +00:00
|
|
|
int j = rdev->raid_disk;
|
2011-10-11 05:48:49 +00:00
|
|
|
struct dev_info *disk = conf->disks + j;
|
2009-06-17 22:48:55 +00:00
|
|
|
sector_t sectors;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-06-27 22:31:19 +00:00
|
|
|
if (j < 0 || j >= raid_disks || disk->rdev) {
|
2010-05-03 05:12:04 +00:00
|
|
|
printk(KERN_ERR "md/linear:%s: disk numbering problem. Aborting!\n",
|
|
|
|
mdname(mddev));
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
disk->rdev = rdev;
|
2009-06-17 22:48:55 +00:00
|
|
|
if (mddev->chunk_sectors) {
|
|
|
|
sectors = rdev->sectors;
|
|
|
|
sector_div(sectors, mddev->chunk_sectors);
|
|
|
|
rdev->sectors = sectors * mddev->chunk_sectors;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-07-01 01:13:45 +00:00
|
|
|
disk_stack_limits(mddev->gendisk, rdev->bdev,
|
|
|
|
rdev->data_offset << 9);
|
2005-04-16 22:20:36 +00:00
|
|
|
/* as we don't honour merge_bvec_fn, we must never risk
|
2010-03-08 05:44:38 +00:00
|
|
|
* violating it, so limit max_segments to 1 lying within
|
|
|
|
* a single page.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2010-03-08 05:44:38 +00:00
|
|
|
if (rdev->bdev->bd_disk->queue->merge_bvec_fn) {
|
|
|
|
blk_queue_max_segments(mddev->queue, 1);
|
|
|
|
blk_queue_segment_boundary(mddev->queue,
|
|
|
|
PAGE_CACHE_SIZE - 1);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-31 03:33:13 +00:00
|
|
|
conf->array_sectors += rdev->sectors;
|
2005-04-16 22:20:36 +00:00
|
|
|
cnt++;
|
2009-06-16 06:56:13 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2006-06-26 07:27:41 +00:00
|
|
|
if (cnt != raid_disks) {
|
2010-05-03 05:12:04 +00:00
|
|
|
printk(KERN_ERR "md/linear:%s: not enough drives present. Aborting!\n",
|
|
|
|
mdname(mddev));
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-06-16 06:55:26 +00:00
|
|
|
* Here we calculate the device offsets.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2009-06-16 06:56:13 +00:00
|
|
|
conf->disks[0].end_sector = conf->disks[0].rdev->sectors;
|
|
|
|
|
2007-05-23 20:58:10 +00:00
|
|
|
for (i = 1; i < raid_disks; i++)
|
2009-06-16 06:56:13 +00:00
|
|
|
conf->disks[i].end_sector =
|
|
|
|
conf->disks[i-1].end_sector +
|
|
|
|
conf->disks[i].rdev->sectors;
|
2005-09-09 23:23:47 +00:00
|
|
|
|
2006-06-26 07:27:41 +00:00
|
|
|
return conf;
|
|
|
|
|
|
|
|
out:
|
|
|
|
kfree(conf);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-10-11 05:47:53 +00:00
|
|
|
static int linear_run (struct mddev *mddev)
|
2006-06-26 07:27:41 +00:00
|
|
|
{
|
2011-10-11 05:48:54 +00:00
|
|
|
struct linear_conf *conf;
|
2006-06-26 07:27:41 +00:00
|
|
|
|
2009-06-17 22:49:23 +00:00
|
|
|
if (md_check_no_bitmap(mddev))
|
|
|
|
return -EINVAL;
|
2006-06-26 07:27:41 +00:00
|
|
|
conf = linear_conf(mddev, mddev->raid_disks);
|
|
|
|
|
|
|
|
if (!conf)
|
|
|
|
return 1;
|
|
|
|
mddev->private = conf;
|
2009-03-31 03:59:03 +00:00
|
|
|
md_set_array_sectors(mddev, linear_size(mddev, 0, 0));
|
2006-06-26 07:27:41 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
blk_queue_merge_bvec(mddev->queue, linear_mergeable_bvec);
|
2006-10-03 08:15:53 +00:00
|
|
|
mddev->queue->backing_dev_info.congested_fn = linear_congested;
|
|
|
|
mddev->queue->backing_dev_info.congested_data = mddev;
|
2011-03-17 10:11:05 +00:00
|
|
|
return md_integrity_register(mddev);
|
2006-06-26 07:27:41 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-10-11 05:47:53 +00:00
|
|
|
static int linear_add(struct mddev *mddev, struct md_rdev *rdev)
|
2006-06-26 07:27:41 +00:00
|
|
|
{
|
|
|
|
/* Adding a drive to a linear array allows the array to grow.
|
|
|
|
* It is permitted if the new drive has a matching superblock
|
|
|
|
* already on it, with raid_disk equal to raid_disks.
|
|
|
|
* It is achieved by creating a new linear_private_data structure
|
|
|
|
* and swapping it in in-place of the current one.
|
|
|
|
* The current one is never freed until the array is stopped.
|
|
|
|
* This avoids races.
|
|
|
|
*/
|
2011-10-11 05:48:54 +00:00
|
|
|
struct linear_conf *newconf, *oldconf;
|
2006-06-26 07:27:41 +00:00
|
|
|
|
2007-05-23 20:58:10 +00:00
|
|
|
if (rdev->saved_raid_disk != mddev->raid_disks)
|
2006-06-26 07:27:41 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2007-05-23 20:58:10 +00:00
|
|
|
rdev->raid_disk = rdev->saved_raid_disk;
|
2011-12-22 22:56:55 +00:00
|
|
|
rdev->saved_raid_disk = -1;
|
2007-05-23 20:58:10 +00:00
|
|
|
|
2006-06-26 07:27:41 +00:00
|
|
|
newconf = linear_conf(mddev,mddev->raid_disks+1);
|
|
|
|
|
|
|
|
if (!newconf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2009-06-17 22:49:42 +00:00
|
|
|
oldconf = rcu_dereference(mddev->private);
|
2006-06-26 07:27:41 +00:00
|
|
|
mddev->raid_disks++;
|
2009-06-17 22:49:35 +00:00
|
|
|
rcu_assign_pointer(mddev->private, newconf);
|
2009-03-31 03:59:03 +00:00
|
|
|
md_set_array_sectors(mddev, linear_size(mddev, 0, 0));
|
2008-07-21 07:05:22 +00:00
|
|
|
set_capacity(mddev->gendisk, mddev->array_sectors);
|
2009-08-03 00:59:58 +00:00
|
|
|
revalidate_disk(mddev->gendisk);
|
2011-03-18 03:59:14 +00:00
|
|
|
kfree_rcu(oldconf, rcu);
|
2006-06-26 07:27:41 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2011-10-11 05:47:53 +00:00
|
|
|
static int linear_stop (struct mddev *mddev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2011-10-11 05:48:54 +00:00
|
|
|
struct linear_conf *conf = mddev->private;
|
2009-06-17 22:49:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We do not require rcu protection here since
|
|
|
|
* we hold reconfig_mutex for both linear_add and
|
|
|
|
* linear_stop, so they cannot race.
|
2009-06-17 22:49:42 +00:00
|
|
|
* We should make sure any old 'conf's are properly
|
|
|
|
* freed though.
|
2009-06-17 22:49:35 +00:00
|
|
|
*/
|
2009-06-17 22:49:42 +00:00
|
|
|
rcu_barrier();
|
2005-04-16 22:20:36 +00:00
|
|
|
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
|
2009-06-17 22:49:42 +00:00
|
|
|
kfree(conf);
|
2010-05-17 01:27:00 +00:00
|
|
|
mddev->private = NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-05 00:06:58 +00:00
|
|
|
static void linear_make_request(struct mddev *mddev, struct bio *bio)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2011-10-11 05:48:49 +00:00
|
|
|
struct dev_info *tmp_dev;
|
2009-06-16 06:56:13 +00:00
|
|
|
sector_t start_sector;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-09-03 09:56:18 +00:00
|
|
|
if (unlikely(bio->bi_rw & REQ_FLUSH)) {
|
|
|
|
md_flush_request(mddev, bio);
|
2011-09-12 10:12:01 +00:00
|
|
|
return;
|
2005-09-09 23:23:41 +00:00
|
|
|
}
|
|
|
|
|
2009-06-17 22:49:35 +00:00
|
|
|
rcu_read_lock();
|
2005-04-16 22:20:36 +00:00
|
|
|
tmp_dev = which_dev(mddev, bio->bi_sector);
|
2009-06-16 06:56:13 +00:00
|
|
|
start_sector = tmp_dev->end_sector - tmp_dev->rdev->sectors;
|
|
|
|
|
2009-06-17 22:49:35 +00:00
|
|
|
|
2009-06-16 06:56:13 +00:00
|
|
|
if (unlikely(bio->bi_sector >= (tmp_dev->end_sector)
|
|
|
|
|| (bio->bi_sector < start_sector))) {
|
2005-04-16 22:20:36 +00:00
|
|
|
char b[BDEVNAME_SIZE];
|
|
|
|
|
2010-05-03 05:12:04 +00:00
|
|
|
printk(KERN_ERR
|
|
|
|
"md/linear:%s: make_request: Sector %llu out of bounds on "
|
|
|
|
"dev %s: %llu sectors, offset %llu\n",
|
|
|
|
mdname(mddev),
|
|
|
|
(unsigned long long)bio->bi_sector,
|
|
|
|
bdevname(tmp_dev->rdev->bdev, b),
|
|
|
|
(unsigned long long)tmp_dev->rdev->sectors,
|
|
|
|
(unsigned long long)start_sector);
|
2009-06-17 22:49:35 +00:00
|
|
|
rcu_read_unlock();
|
2007-09-27 10:47:43 +00:00
|
|
|
bio_io_error(bio);
|
2011-09-12 10:12:01 +00:00
|
|
|
return;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
if (unlikely(bio->bi_sector + (bio->bi_size >> 9) >
|
2009-06-16 06:56:13 +00:00
|
|
|
tmp_dev->end_sector)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
/* This bio crosses a device boundary, so we have to
|
|
|
|
* split it.
|
|
|
|
*/
|
|
|
|
struct bio_pair *bp;
|
2009-06-17 22:49:35 +00:00
|
|
|
sector_t end_sector = tmp_dev->end_sector;
|
|
|
|
|
|
|
|
rcu_read_unlock();
|
2008-10-13 00:55:12 +00:00
|
|
|
|
2009-06-17 22:49:35 +00:00
|
|
|
bp = bio_split(bio, end_sector - bio->bi_sector);
|
2008-10-13 00:55:12 +00:00
|
|
|
|
2011-09-12 10:12:01 +00:00
|
|
|
linear_make_request(mddev, &bp->bio1);
|
|
|
|
linear_make_request(mddev, &bp->bio2);
|
2005-04-16 22:20:36 +00:00
|
|
|
bio_pair_release(bp);
|
2011-09-12 10:12:01 +00:00
|
|
|
return;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bio->bi_bdev = tmp_dev->rdev->bdev;
|
2009-06-16 06:56:13 +00:00
|
|
|
bio->bi_sector = bio->bi_sector - start_sector
|
2008-10-13 00:55:12 +00:00
|
|
|
+ tmp_dev->rdev->data_offset;
|
2009-06-17 22:49:35 +00:00
|
|
|
rcu_read_unlock();
|
2011-09-12 10:12:01 +00:00
|
|
|
generic_make_request(bio);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2011-10-11 05:47:53 +00:00
|
|
|
static void linear_status (struct seq_file *seq, struct mddev *mddev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
|
2009-06-17 22:45:01 +00:00
|
|
|
seq_printf(seq, " %dk rounding", mddev->chunk_sectors / 2);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-11 05:49:58 +00:00
|
|
|
static struct md_personality linear_personality =
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
.name = "linear",
|
2006-01-06 08:20:36 +00:00
|
|
|
.level = LEVEL_LINEAR,
|
2005-04-16 22:20:36 +00:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.make_request = linear_make_request,
|
|
|
|
.run = linear_run,
|
|
|
|
.stop = linear_stop,
|
|
|
|
.status = linear_status,
|
2006-06-26 07:27:41 +00:00
|
|
|
.hot_add_disk = linear_add,
|
2009-03-18 01:10:40 +00:00
|
|
|
.size = linear_size,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init linear_init (void)
|
|
|
|
{
|
2006-01-06 08:20:36 +00:00
|
|
|
return register_md_personality (&linear_personality);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void linear_exit (void)
|
|
|
|
{
|
2006-01-06 08:20:36 +00:00
|
|
|
unregister_md_personality (&linear_personality);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module_init(linear_init);
|
|
|
|
module_exit(linear_exit);
|
|
|
|
MODULE_LICENSE("GPL");
|
2009-12-14 01:49:58 +00:00
|
|
|
MODULE_DESCRIPTION("Linear device concatenation personality for MD");
|
2006-01-06 08:20:51 +00:00
|
|
|
MODULE_ALIAS("md-personality-1"); /* LINEAR - deprecated*/
|
|
|
|
MODULE_ALIAS("md-linear");
|
2006-01-06 08:20:36 +00:00
|
|
|
MODULE_ALIAS("md-level--1");
|