Release 4.7 drivers/md/linear.c
/*
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.
*/
#include <linux/blkdev.h>
#include <linux/raid/md_u.h>
#include <linux/seq_file.h>
#include <linux/module.h>
#include <linux/slab.h>
#include "md.h"
#include "linear.h"
/*
* find which device holds a particular offset
*/
static inline struct dev_info *which_dev(struct mddev *mddev, sector_t sector)
{
int lo, mid, hi;
struct linear_conf *conf;
lo = 0;
hi = mddev->raid_disks - 1;
conf = mddev->private;
/*
* 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;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
sandeep k sinha | sandeep k sinha | 63 | 64.95% | 3 | 33.33% |
neil brown | neil brown | 34 | 35.05% | 6 | 66.67% |
| Total | 97 | 100.00% | 9 | 100.00% |
static int linear_congested(struct mddev *mddev, int bits)
{
struct linear_conf *conf;
int i, ret = 0;
conf = mddev->private;
for (i = 0; i < mddev->raid_disks && !ret ; i++) {
struct request_queue *q = bdev_get_queue(conf->disks[i].rdev->bdev);
ret |= bdi_congested(&q->backing_dev_info, bits);
}
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 78 | 90.70% | 4 | 66.67% |
sandeep k sinha | sandeep k sinha | 6 | 6.98% | 1 | 16.67% |
jens axboe | jens axboe | 2 | 2.33% | 1 | 16.67% |
| Total | 86 | 100.00% | 6 | 100.00% |
static sector_t linear_size(struct mddev *mddev, sector_t sectors, int raid_disks)
{
struct linear_conf *conf;
sector_t array_sectors;
conf = mddev->private;
WARN_ONCE(sectors || raid_disks,
"%s does not support generic reshape\n", __func__);
array_sectors = conf->array_sectors;
return array_sectors;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
dan williams | dan williams | 33 | 64.71% | 1 | 20.00% |
sandeep k sinha | sandeep k sinha | 12 | 23.53% | 1 | 20.00% |
neil brown | neil brown | 6 | 11.76% | 3 | 60.00% |
| Total | 51 | 100.00% | 5 | 100.00% |
static struct linear_conf *linear_conf(struct mddev *mddev, int raid_disks)
{
struct linear_conf *conf;
struct md_rdev *rdev;
int i, cnt;
bool discard_supported = false;
conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(struct dev_info),
GFP_KERNEL);
if (!conf)
return NULL;
cnt = 0;
conf->array_sectors = 0;
rdev_for_each(rdev, mddev) {
int j = rdev->raid_disk;
struct dev_info *disk = conf->disks + j;
sector_t sectors;
if (j < 0 || j >= raid_disks || disk->rdev) {
printk(KERN_ERR "md/linear:%s: disk numbering problem. Aborting!\n",
mdname(mddev));
goto out;
}
disk->rdev = rdev;
if (mddev->chunk_sectors) {
sectors = rdev->sectors;
sector_div(sectors, mddev->chunk_sectors);
rdev->sectors = sectors * mddev->chunk_sectors;
}
disk_stack_limits(mddev->gendisk, rdev->bdev,
rdev->data_offset << 9);
conf->array_sectors += rdev->sectors;
cnt++;
if (blk_queue_discard(bdev_get_queue(rdev->bdev)))
discard_supported = true;
}
if (cnt != raid_disks) {
printk(KERN_ERR "md/linear:%s: not enough drives present. Aborting!\n",
mdname(mddev));
goto out;
}
if (!discard_supported)
queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, mddev->queue);
else
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mddev->queue);
/*
* Here we calculate the device offsets.
*/
conf->disks[0].end_sector = conf->disks[0].rdev->sectors;
for (i = 1; i < raid_disks; i++)
conf->disks[i].end_sector =
conf->disks[i-1].end_sector +
conf->disks[i].rdev->sectors;
return conf;
out:
kfree(conf);
return NULL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 185 | 54.25% | 15 | 55.56% |
pre-git | pre-git | 71 | 20.82% | 3 | 11.11% |
shaohua li | shaohua li | 45 | 13.20% | 1 | 3.70% |
sandeep k sinha | sandeep k sinha | 16 | 4.69% | 2 | 7.41% |
andrew morton | andrew morton | 10 | 2.93% | 1 | 3.70% |
martin k. petersen | martin k. petersen | 7 | 2.05% | 1 | 3.70% |
al viro | al viro | 3 | 0.88% | 1 | 3.70% |
andre noll | andre noll | 3 | 0.88% | 2 | 7.41% |
nikanth karthikesan | nikanth karthikesan | 1 | 0.29% | 1 | 3.70% |
| Total | 341 | 100.00% | 27 | 100.00% |
static int linear_run (struct mddev *mddev)
{
struct linear_conf *conf;
int ret;
if (md_check_no_bitmap(mddev))
return -EINVAL;
conf = linear_conf(mddev, mddev->raid_disks);
if (!conf)
return 1;
mddev->private = conf;
md_set_array_sectors(mddev, linear_size(mddev, 0, 0));
ret = md_integrity_register(mddev);
if (ret) {
kfree(conf);
mddev->private = NULL;
}
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 43 | 44.79% | 3 | 33.33% |
ma jianpeng | ma jianpeng | 25 | 26.04% | 1 | 11.11% |
andre noll | andre noll | 15 | 15.62% | 2 | 22.22% |
dan williams | dan williams | 12 | 12.50% | 2 | 22.22% |
pre-git | pre-git | 1 | 1.04% | 1 | 11.11% |
| Total | 96 | 100.00% | 9 | 100.00% |
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
* 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.
*/
struct linear_conf *newconf, *oldconf;
if (rdev->saved_raid_disk != mddev->raid_disks)
return -EINVAL;
rdev->raid_disk = rdev->saved_raid_disk;
rdev->saved_raid_disk = -1;
newconf = linear_conf(mddev,mddev->raid_disks+1);
if (!newconf)
return -ENOMEM;
mddev_suspend(mddev);
oldconf = mddev->private;
mddev->raid_disks++;
mddev->private = newconf;
md_set_array_sectors(mddev, linear_size(mddev, 0, 0));
set_capacity(mddev->gendisk, mddev->array_sectors);
mddev_resume(mddev);
revalidate_disk(mddev->gendisk);
kfree(oldconf);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 120 | 83.92% | 10 | 62.50% |
dan williams | dan williams | 12 | 8.39% | 2 | 12.50% |
pre-git | pre-git | 6 | 4.20% | 2 | 12.50% |
sandeep k sinha | sandeep k sinha | 4 | 2.80% | 1 | 6.25% |
andre noll | andre noll | 1 | 0.70% | 1 | 6.25% |
| Total | 143 | 100.00% | 16 | 100.00% |
static void linear_free(struct mddev *mddev, void *priv)
{
struct linear_conf *conf = priv;
kfree(conf);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
pre-git | pre-git | 16 | 59.26% | 2 | 40.00% |
neil brown | neil brown | 11 | 40.74% | 3 | 60.00% |
| Total | 27 | 100.00% | 5 | 100.00% |
static void linear_make_request(struct mddev *mddev, struct bio *bio)
{
char b[BDEVNAME_SIZE];
struct dev_info *tmp_dev;
struct bio *split;
sector_t start_sector, end_sector, data_offset;
if (unlikely(bio->bi_rw & REQ_FLUSH)) {
md_flush_request(mddev, bio);
return;
}
do {
tmp_dev = which_dev(mddev, bio->bi_iter.bi_sector);
start_sector = tmp_dev->end_sector - tmp_dev->rdev->sectors;
end_sector = tmp_dev->end_sector;
data_offset = tmp_dev->rdev->data_offset;
bio->bi_bdev = tmp_dev->rdev->bdev;
if (unlikely(bio->bi_iter.bi_sector >= end_sector ||
bio->bi_iter.bi_sector < start_sector))
goto out_of_bounds;
if (unlikely(bio_end_sector(bio) > end_sector)) {
/* This bio crosses a device boundary, so we have to
* split it.
*/
split = bio_split(bio, end_sector -
bio->bi_iter.bi_sector,
GFP_NOIO, fs_bio_set);
bio_chain(split, bio);
} else {
split = bio;
}
split->bi_iter.bi_sector = split->bi_iter.bi_sector -
start_sector + data_offset;
if (unlikely((split->bi_rw & REQ_DISCARD) &&
!blk_queue_discard(bdev_get_queue(split->bi_bdev)))) {
/* Just ignore it */
bio_endio(split);
} else
generic_make_request(split);
} while (split != bio);
return;
out_of_bounds:
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_iter.bi_sector,
bdevname(tmp_dev->rdev->bdev, b),
(unsigned long long)tmp_dev->rdev->sectors,
(unsigned long long)start_sector);
bio_io_error(bio);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
kent overstreet | kent overstreet | 147 | 48.20% | 3 | 12.50% |
neil brown | neil brown | 54 | 17.70% | 9 | 37.50% |
shaohua li | shaohua li | 29 | 9.51% | 1 | 4.17% |
pre-git | pre-git | 28 | 9.18% | 4 | 16.67% |
sandeep k sinha | sandeep k sinha | 18 | 5.90% | 1 | 4.17% |
christoph hellwig | christoph hellwig | 10 | 3.28% | 2 | 8.33% |
andre noll | andre noll | 8 | 2.62% | 1 | 4.17% |
linus torvalds | linus torvalds | 7 | 2.30% | 1 | 4.17% |
tejun heo | tejun heo | 2 | 0.66% | 1 | 4.17% |
andrew morton | andrew morton | 2 | 0.66% | 1 | 4.17% |
| Total | 305 | 100.00% | 24 | 100.00% |
static void linear_status (struct seq_file *seq, struct mddev *mddev)
{
seq_printf(seq, " %dk rounding", mddev->chunk_sectors / 2);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
pre-git | pre-git | 19 | 65.52% | 3 | 50.00% |
neil brown | neil brown | 8 | 27.59% | 2 | 33.33% |
andre noll | andre noll | 2 | 6.90% | 1 | 16.67% |
| Total | 29 | 100.00% | 6 | 100.00% |
static void linear_quiesce(struct mddev *mddev, int state)
{
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 13 | 100.00% | 1 | 100.00% |
| Total | 13 | 100.00% | 1 | 100.00% |
static struct md_personality linear_personality =
{
.name = "linear",
.level = LEVEL_LINEAR,
.owner = THIS_MODULE,
.make_request = linear_make_request,
.run = linear_run,
.free = linear_free,
.status = linear_status,
.hot_add_disk = linear_add,
.size = linear_size,
.quiesce = linear_quiesce,
.congested = linear_congested,
};
static int __init linear_init (void)
{
return register_md_personality (&linear_personality);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
pre-git | pre-git | 15 | 93.75% | 3 | 75.00% |
linus torvalds | linus torvalds | 1 | 6.25% | 1 | 25.00% |
| Total | 16 | 100.00% | 4 | 100.00% |
static void linear_exit (void)
{
unregister_md_personality (&linear_personality);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
pre-git | pre-git | 12 | 85.71% | 2 | 66.67% |
neil brown | neil brown | 2 | 14.29% | 1 | 33.33% |
| Total | 14 | 100.00% | 3 | 100.00% |
module_init(linear_init);
module_exit(linear_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Linear device concatenation personality for MD");
MODULE_ALIAS("md-personality-1"); /* LINEAR - deprecated*/
MODULE_ALIAS("md-linear");
MODULE_ALIAS("md-level--1");
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 628 | 46.90% | 44 | 51.16% |
pre-git | pre-git | 198 | 14.79% | 9 | 10.47% |
kent overstreet | kent overstreet | 147 | 10.98% | 3 | 3.49% |
sandeep k sinha | sandeep k sinha | 119 | 8.89% | 4 | 4.65% |
shaohua li | shaohua li | 74 | 5.53% | 1 | 1.16% |
dan williams | dan williams | 62 | 4.63% | 2 | 2.33% |
andre noll | andre noll | 29 | 2.17% | 7 | 8.14% |
ma jianpeng | ma jianpeng | 25 | 1.87% | 1 | 1.16% |
linus torvalds | linus torvalds | 13 | 0.97% | 3 | 3.49% |
andrew morton | andrew morton | 12 | 0.90% | 2 | 2.33% |
christoph hellwig | christoph hellwig | 11 | 0.82% | 3 | 3.49% |
martin k. petersen | martin k. petersen | 7 | 0.52% | 1 | 1.16% |
tejun heo | tejun heo | 5 | 0.37% | 2 | 2.33% |
paul gortmaker | paul gortmaker | 3 | 0.22% | 1 | 1.16% |
al viro | al viro | 3 | 0.22% | 1 | 1.16% |
jens axboe | jens axboe | 2 | 0.15% | 1 | 1.16% |
nikanth karthikesan | nikanth karthikesan | 1 | 0.07% | 1 | 1.16% |
| Total | 1339 | 100.00% | 86 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.