|
Lines 131-136
static ctl_table raid_root_table[] = {
Link Here
|
| 131 |
|
131 |
|
| 132 |
static struct block_device_operations md_fops; |
132 |
static struct block_device_operations md_fops; |
| 133 |
|
133 |
|
|
|
134 |
static int start_readonly; |
| 135 |
|
| 134 |
/* |
136 |
/* |
| 135 |
* Enables to iterate over all existing md arrays |
137 |
* Enables to iterate over all existing md arrays |
| 136 |
* all_mddevs_lock protects this list. |
138 |
* all_mddevs_lock protects this list. |
|
Lines 2057-2062
static int do_md_run(mddev_t * mddev)
Link Here
|
| 2057 |
mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */ |
2059 |
mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */ |
| 2058 |
mddev->barriers_work = 1; |
2060 |
mddev->barriers_work = 1; |
| 2059 |
|
2061 |
|
|
|
2062 |
if (start_readonly) |
| 2063 |
mddev->ro = 2; /* read-only, but switch on first write */ |
| 2064 |
|
| 2060 |
/* before we start the array running, initialise the bitmap */ |
2065 |
/* before we start the array running, initialise the bitmap */ |
| 2061 |
err = bitmap_create(mddev); |
2066 |
err = bitmap_create(mddev); |
| 2062 |
if (err) |
2067 |
if (err) |
|
Lines 2169-2175
static int do_md_stop(mddev_t * mddev, i
Link Here
|
| 2169 |
|
2174 |
|
| 2170 |
if (ro) { |
2175 |
if (ro) { |
| 2171 |
err = -ENXIO; |
2176 |
err = -ENXIO; |
| 2172 |
if (mddev->ro) |
2177 |
if (mddev->ro==1) |
| 2173 |
goto out; |
2178 |
goto out; |
| 2174 |
mddev->ro = 1; |
2179 |
mddev->ro = 1; |
| 2175 |
} else { |
2180 |
} else { |
|
Lines 3286-3297
static int md_ioctl(struct inode *inode,
Link Here
|
| 3286 |
|
3291 |
|
| 3287 |
/* |
3292 |
/* |
| 3288 |
* The remaining ioctls are changing the state of the |
3293 |
* The remaining ioctls are changing the state of the |
| 3289 |
* superblock, so we do not allow read-only arrays |
3294 |
* superblock, so we do not allow them on read-only arrays. |
| 3290 |
* here: |
3295 |
* However non-MD ioctls (e.g. get-size) will still come through |
|
|
3296 |
* here and hit the 'default' below, so only disallow |
| 3297 |
* 'md' ioctls, and switch to rw mode if started auto-readonly. |
| 3291 |
*/ |
3298 |
*/ |
| 3292 |
if (mddev->ro) { |
3299 |
if (_IOC_TYPE(cmd) == MD_MAJOR && |
| 3293 |
err = -EROFS; |
3300 |
mddev->ro && mddev->pers) { |
| 3294 |
goto abort_unlock; |
3301 |
if (mddev->ro == 2) { |
|
|
3302 |
mddev->ro = 0; |
| 3303 |
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); |
| 3304 |
md_wakeup_thread(mddev->thread); |
| 3305 |
|
| 3306 |
} else { |
| 3307 |
err = -EROFS; |
| 3308 |
goto abort_unlock; |
| 3309 |
} |
| 3295 |
} |
3310 |
} |
| 3296 |
|
3311 |
|
| 3297 |
switch (cmd) |
3312 |
switch (cmd) |
|
Lines 3678-3685
static int md_seq_show(struct seq_file *
Link Here
|
| 3678 |
seq_printf(seq, "%s : %sactive", mdname(mddev), |
3693 |
seq_printf(seq, "%s : %sactive", mdname(mddev), |
| 3679 |
mddev->pers ? "" : "in"); |
3694 |
mddev->pers ? "" : "in"); |
| 3680 |
if (mddev->pers) { |
3695 |
if (mddev->pers) { |
| 3681 |
if (mddev->ro) |
3696 |
if (mddev->ro==1) |
| 3682 |
seq_printf(seq, " (read-only)"); |
3697 |
seq_printf(seq, " (read-only)"); |
|
|
3698 |
if (mddev->ro==2) |
| 3699 |
seq_printf(seq, "(auto-read-only)"); |
| 3683 |
seq_printf(seq, " %s", mddev->pers->name); |
3700 |
seq_printf(seq, " %s", mddev->pers->name); |
| 3684 |
} |
3701 |
} |
| 3685 |
|
3702 |
|
|
Lines 3723-3729
static int md_seq_show(struct seq_file *
Link Here
|
| 3723 |
status_resync (seq, mddev); |
3740 |
status_resync (seq, mddev); |
| 3724 |
seq_printf(seq, "\n "); |
3741 |
seq_printf(seq, "\n "); |
| 3725 |
} else if (mddev->curr_resync == 1 || mddev->curr_resync == 2) |
3742 |
} else if (mddev->curr_resync == 1 || mddev->curr_resync == 2) |
| 3726 |
seq_printf(seq, " resync=DELAYED\n "); |
3743 |
seq_printf(seq, "\tresync=DELAYED\n "); |
|
|
3744 |
else if (mddev->recovery_cp < MaxSector) |
| 3745 |
seq_printf(seq, "\tresync=PENDING\n "); |
| 3727 |
} else |
3746 |
} else |
| 3728 |
seq_printf(seq, "\n "); |
3747 |
seq_printf(seq, "\n "); |
| 3729 |
|
3748 |
|
|
Lines 3860-3865
void md_write_start(mddev_t *mddev, stru
Link Here
|
| 3860 |
if (bio_data_dir(bi) != WRITE) |
3879 |
if (bio_data_dir(bi) != WRITE) |
| 3861 |
return; |
3880 |
return; |
| 3862 |
|
3881 |
|
|
|
3882 |
BUG_ON(mddev->ro == 1); |
| 3883 |
if (mddev->ro == 2) { |
| 3884 |
/* need to switch to read/write */ |
| 3885 |
mddev->ro = 0; |
| 3886 |
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); |
| 3887 |
md_wakeup_thread(mddev->thread); |
| 3888 |
} |
| 3863 |
atomic_inc(&mddev->writes_pending); |
3889 |
atomic_inc(&mddev->writes_pending); |
| 3864 |
if (mddev->in_sync) { |
3890 |
if (mddev->in_sync) { |
| 3865 |
spin_lock_irq(&mddev->write_lock); |
3891 |
spin_lock_irq(&mddev->write_lock); |
|
Lines 4455-4460
static __exit void md_exit(void)
Link Here
|
| 4455 |
module_init(md_init) |
4481 |
module_init(md_init) |
| 4456 |
module_exit(md_exit) |
4482 |
module_exit(md_exit) |
| 4457 |
|
4483 |
|
|
|
4484 |
static int get_ro(char *buffer, struct kernel_param *kp) |
| 4485 |
{ |
| 4486 |
return sprintf(buffer, "%d", start_readonly); |
| 4487 |
} |
| 4488 |
static int set_ro(const char *val, struct kernel_param *kp) |
| 4489 |
{ |
| 4490 |
char *e; |
| 4491 |
int num = simple_strtoul(val, &e, 10); |
| 4492 |
if (*val && (*e == '\0' || *e == '\n')) { |
| 4493 |
start_readonly = num; |
| 4494 |
return 0;; |
| 4495 |
} |
| 4496 |
return -EINVAL; |
| 4497 |
} |
| 4498 |
|
| 4499 |
module_param_call(start_ro, set_ro, get_ro, NULL, 0600); |
| 4500 |
|
| 4458 |
EXPORT_SYMBOL(register_md_personality); |
4501 |
EXPORT_SYMBOL(register_md_personality); |
| 4459 |
EXPORT_SYMBOL(unregister_md_personality); |
4502 |
EXPORT_SYMBOL(unregister_md_personality); |
| 4460 |
EXPORT_SYMBOL(md_error); |
4503 |
EXPORT_SYMBOL(md_error); |