* [PATCH md 000 of 2] Introduction
@ 2005-10-31 5:58 NeilBrown
2005-10-31 5:58 ` [PATCH md 001 of 2] Remove attempt to use dynamic names in sysfs for component devices on an MD array NeilBrown
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: NeilBrown @ 2005-10-31 5:58 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-raid
Two patches for md in 2.6.14-rc5-mm1 (First one depends on -mm stuff,
second should apply to most recent 2.6 kernels).
I'd like to review the sysfs a bit more before it goes to Linus, but
the rest can go anytime.
Thanks,
NeilBrown
[PATCH md 001 of 2] Remove attempt to use dynamic names in sysfs for component devices on an MD array.
[PATCH md 002 of 2] Allow md arrays to be started read-only (module parameter).
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH md 001 of 2] Remove attempt to use dynamic names in sysfs for component devices on an MD array. 2005-10-31 5:58 [PATCH md 000 of 2] Introduction NeilBrown @ 2005-10-31 5:58 ` NeilBrown 2005-10-31 5:59 ` [PATCH md 002 of 2] Allow md arrays to be started read-only (module parameter) NeilBrown 2005-10-31 7:34 ` [PATCH md 000 of 2] Introduction Andrew Morton 2 siblings, 0 replies; 8+ messages in thread From: NeilBrown @ 2005-10-31 5:58 UTC (permalink / raw) To: Andrew Morton; +Cc: linux-raid With version-0.90 superblock, component devices on an md device to not have any stable name related to the array -(version-1 assigns a fixed index when a device is added to an array, and this remains despit any hot-swap). The intial code for making these devices appear in sysfs used dynamic names, which would change whenever a hot-spare was swapped for a failed or missing device. This turns out not to be practical in sysfs for a number of reasons. This patch changes then naming of component devices to be based on the result of 'bdevname'. This is stable and should be unique. Signed-off-by: Neil Brown <neilb@suse.de> ### Diffstat output ./drivers/md/md.c | 40 ++++++---------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff ./drivers/md/md.c~current~ ./drivers/md/md.c --- ./drivers/md/md.c~current~ 2005-10-31 15:48:07.000000000 +1100 +++ ./drivers/md/md.c 2005-10-31 15:54:59.000000000 +1100 @@ -762,7 +762,7 @@ static void super_90_sync(mddev_t *mddev struct list_head *tmp; mdk_rdev_t *rdev2; int next_spare = mddev->raid_disks; - char nm[20]; + /* make rdev->sb match mddev data.. * @@ -776,7 +776,6 @@ static void super_90_sync(mddev_t *mddev */ int i; int active=0, working=0,failed=0,spare=0,nr_disks=0; - unsigned int fixdesc=0; rdev->sb_size = MD_SB_BYTES; @@ -830,16 +829,7 @@ static void super_90_sync(mddev_t *mddev desc_nr = rdev2->raid_disk; else desc_nr = next_spare++; - if (desc_nr != rdev2->desc_nr) { - fixdesc |= (1 << desc_nr); - rdev2->desc_nr = desc_nr; - if (rdev2->raid_disk >= 0) { - sprintf(nm, "rd%d", rdev2->raid_disk); - sysfs_remove_link(&mddev->kobj, nm); - } - sysfs_remove_link(&rdev2->kobj, "block"); - kobject_del(&rdev2->kobj); - } + rdev2->desc_nr = desc_nr; d = &sb->disks[rdev2->desc_nr]; nr_disks++; d->number = rdev2->desc_nr; @@ -866,25 +856,6 @@ static void super_90_sync(mddev_t *mddev if (test_bit(WriteMostly, &rdev2->flags)) d->state |= (1<<MD_DISK_WRITEMOSTLY); } - if (fixdesc) - ITERATE_RDEV(mddev,rdev2,tmp) - if (fixdesc & (1<<rdev2->desc_nr)) { - snprintf(rdev2->kobj.name, KOBJ_NAME_LEN, "dev%d", - rdev2->desc_nr); - /* kobject_add gets a ref on the parent, so - * we have to drop the one we already have - */ - kobject_add(&rdev2->kobj); - kobject_put(rdev->kobj.parent); - sysfs_create_link(&rdev2->kobj, - &rdev2->bdev->bd_disk->kobj, - "block"); - if (rdev2->raid_disk >= 0) { - sprintf(nm, "rd%d", rdev2->raid_disk); - sysfs_create_link(&mddev->kobj, - &rdev2->kobj, nm); - } - } /* now set the "removed" and "faulty" bits on any missing devices */ for (i=0 ; i < mddev->raid_disks ; i++) { mdp_disk_t *d = &sb->disks[i]; @@ -1237,13 +1208,14 @@ static int bind_rdev_to_array(mdk_rdev_t if (find_rdev_nr(mddev, rdev->desc_nr)) return -EBUSY; } + bdevname(rdev->bdev,b); + if (kobject_set_name(&rdev->kobj, "dev-%s", b) < 0) + return -ENOMEM; list_add(&rdev->same_set, &mddev->disks); rdev->mddev = mddev; - printk(KERN_INFO "md: bind<%s>\n", bdevname(rdev->bdev,b)); + printk(KERN_INFO "md: bind<%s>\n", b); - rdev->kobj.k_name = NULL; - snprintf(rdev->kobj.name, KOBJ_NAME_LEN, "dev%d", rdev->desc_nr); rdev->kobj.parent = &mddev->kobj; kobject_add(&rdev->kobj); ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH md 002 of 2] Allow md arrays to be started read-only (module parameter). 2005-10-31 5:58 [PATCH md 000 of 2] Introduction NeilBrown 2005-10-31 5:58 ` [PATCH md 001 of 2] Remove attempt to use dynamic names in sysfs for component devices on an MD array NeilBrown @ 2005-10-31 5:59 ` NeilBrown 2005-10-31 7:34 ` [PATCH md 000 of 2] Introduction Andrew Morton 2 siblings, 0 replies; 8+ messages in thread From: NeilBrown @ 2005-10-31 5:59 UTC (permalink / raw) To: Andrew Morton; +Cc: linux-raid When an md array is started, the superblock will be written, and resync may commense. This is not good if you want to be completely read-only as, for example, when preparing to resume from a suspend-to-disk image. So introduce a module parameter "start_ro" which can be set to '1' at boot, at module load, or via /sys/module/md_mod/parameters/start_ro When this is set, new arrays get an 'auto-ro' mode, which disables all internal io (superblock updates, resync, recovery) and is automatically switched to 'rw' when the first write request arrives. The array can be set to true 'ro' mode using 'mdadm -r' before the first write request, or resync can be started without a write using 'mdadm -w'. Signed-off-by: Neil Brown <neilb@suse.de> ### Diffstat output ./drivers/md/md.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 8 deletions(-) diff ./drivers/md/md.c~current~ ./drivers/md/md.c --- ./drivers/md/md.c~current~ 2005-10-31 15:54:59.000000000 +1100 +++ ./drivers/md/md.c 2005-10-31 15:55:06.000000000 +1100 @@ -131,6 +131,8 @@ static ctl_table raid_root_table[] = { static struct block_device_operations md_fops; +static int start_readonly; + /* * Enables to iterate over all existing md arrays * all_mddevs_lock protects this list. @@ -2029,6 +2031,9 @@ static int do_md_run(mddev_t * mddev) mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */ mddev->barriers_work = 1; + if (start_readonly) + mddev->ro = 2; /* read-only, but switch on first write */ + /* before we start the array running, initialise the bitmap */ err = bitmap_create(mddev); if (err) @@ -2141,7 +2146,7 @@ static int do_md_stop(mddev_t * mddev, i if (ro) { err = -ENXIO; - if (mddev->ro) + if (mddev->ro==1) goto out; mddev->ro = 1; } else { @@ -3258,12 +3263,22 @@ static int md_ioctl(struct inode *inode, /* * The remaining ioctls are changing the state of the - * superblock, so we do not allow read-only arrays - * here: + * superblock, so we do not allow them on read-only arrays. + * However non-MD ioctls (e.g. get-size) will still come through + * here and hit the 'default' below, so only disallow + * 'md' ioctls, and switch to rw mode if started auto-readonly. */ - if (mddev->ro) { - err = -EROFS; - goto abort_unlock; + if (_IOC_TYPE(cmd) == MD_MAJOR && + mddev->ro && mddev->pers) { + if (mddev->ro == 2) { + mddev->ro = 0; + set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); + md_wakeup_thread(mddev->thread); + + } else { + err = -EROFS; + goto abort_unlock; + } } switch (cmd) @@ -3651,8 +3666,10 @@ static int md_seq_show(struct seq_file * seq_printf(seq, "%s : %sactive", mdname(mddev), mddev->pers ? "" : "in"); if (mddev->pers) { - if (mddev->ro) + if (mddev->ro==1) seq_printf(seq, " (read-only)"); + if (mddev->ro==2) + seq_printf(seq, "(auto-read-only)"); seq_printf(seq, " %s", mddev->pers->name); } @@ -3696,7 +3713,9 @@ static int md_seq_show(struct seq_file * status_resync (seq, mddev); seq_printf(seq, "\n "); } else if (mddev->curr_resync == 1 || mddev->curr_resync == 2) - seq_printf(seq, " resync=DELAYED\n "); + seq_printf(seq, "\tresync=DELAYED\n "); + else if (mddev->recovery_cp < MaxSector) + seq_printf(seq, "\tresync=PENDING\n "); } else seq_printf(seq, "\n "); @@ -3833,6 +3852,13 @@ void md_write_start(mddev_t *mddev, stru if (bio_data_dir(bi) != WRITE) return; + BUG_ON(mddev->ro == 1); + if (mddev->ro == 2) { + /* need to switch to read/write */ + mddev->ro = 0; + set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); + md_wakeup_thread(mddev->thread); + } atomic_inc(&mddev->writes_pending); if (mddev->in_sync) { spin_lock_irq(&mddev->write_lock); @@ -4429,6 +4455,23 @@ static __exit void md_exit(void) module_init(md_init) module_exit(md_exit) +static int get_ro(char *buffer, struct kernel_param *kp) +{ + return sprintf(buffer, "%d", start_readonly); +} +static int set_ro(const char *val, struct kernel_param *kp) +{ + char *e; + int num = simple_strtoul(val, &e, 10); + if (*val && (*e == '\0' || *e == '\n')) { + start_readonly = num; + return 0;; + } + return -EINVAL; +} + +module_param_call(start_ro, set_ro, get_ro, NULL, 0600); + EXPORT_SYMBOL(register_md_personality); EXPORT_SYMBOL(unregister_md_personality); EXPORT_SYMBOL(md_error); ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH md 000 of 2] Introduction 2005-10-31 5:58 [PATCH md 000 of 2] Introduction NeilBrown 2005-10-31 5:58 ` [PATCH md 001 of 2] Remove attempt to use dynamic names in sysfs for component devices on an MD array NeilBrown 2005-10-31 5:59 ` [PATCH md 002 of 2] Allow md arrays to be started read-only (module parameter) NeilBrown @ 2005-10-31 7:34 ` Andrew Morton 2005-10-31 6:44 ` Neil Brown 2 siblings, 1 reply; 8+ messages in thread From: Andrew Morton @ 2005-10-31 7:34 UTC (permalink / raw) To: NeilBrown; +Cc: linux-raid NeilBrown <neilb@suse.de> wrote: > > > I'd like to review the sysfs a bit more before it goes to Linus, but > the rest can go anytime. umm, what does "the sysfs" refer to? Current md patches in -mm: md-better-handling-of-readerrors-with-raid5.patch md-initial-sysfs-support-for-md.patch md-extend-md-sysfs-support-to-component-devices.patch md-add-kobject-sysfs-support-to-raid5.patch md-allow-a-manual-resync-with-md.patch md-teach-raid5-the-difference-between-check-and-repair.patch md-provide-proper-rcu_dereference--rcu_assign_pointer-annotations-in-md.patch md-fix-ref-counting-problems-with-kobjects-in-md.patch md-minor-md-fixes.patch md-change-raid5-sysfs-attribute-to-not-create-a-new-directory.patch md-improvements-to-raid5-handling-of-read-errors.patch md-convert-faulty-and-in_sync-fields-to-bits-in-flags-field.patch md-make-md-on-disk-bitmaps-not-host-endian.patch md-support-bio_rw_barrier-for-md-raid1.patch drivers-md-fix-up-schedule_timeout-usage.patch ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH md 000 of 2] Introduction 2005-10-31 7:34 ` [PATCH md 000 of 2] Introduction Andrew Morton @ 2005-10-31 6:44 ` Neil Brown 2005-10-31 7:56 ` Andrew Morton 2005-10-31 14:45 ` Mr. James W. Laferriere 0 siblings, 2 replies; 8+ messages in thread From: Neil Brown @ 2005-10-31 6:44 UTC (permalink / raw) To: Andrew Morton; +Cc: linux-raid On Sunday October 30, akpm@osdl.org wrote: > NeilBrown <neilb@suse.de> wrote: > > > > > > I'd like to review the sysfs a bit more before it goes to Linus, but > > the rest can go anytime. > > umm, what does "the sysfs" refer to? Sorry.. "the sysfs related patches". Those marked as 'THIS' below. However I think a couple that come after those won't simple move backwards (largely due to md-convert-faulty-and-in_sync-fields-to-bits-in-flags-field). I'll make sure you have a full set that I am happy to go to Linus by the end of the week. Thanks, NeilBrown > > Current md patches in -mm: > > md-better-handling-of-readerrors-with-raid5.patch THIS > md-initial-sysfs-support-for-md.patch THIS > md-extend-md-sysfs-support-to-component-devices.patch THIS > md-add-kobject-sysfs-support-to-raid5.patch THIS > md-allow-a-manual-resync-with-md.patch THIS > md-teach-raid5-the-difference-between-check-and-repair.patch > md-provide-proper-rcu_dereference--rcu_assign_pointer-annotations-in-md.patch THIS > md-fix-ref-counting-problems-with-kobjects-in-md.patch THIS > md-minor-md-fixes.patch THIS > md-change-raid5-sysfs-attribute-to-not-create-a-new-directory.patch > md-improvements-to-raid5-handling-of-read-errors.patch > md-convert-faulty-and-in_sync-fields-to-bits-in-flags-field.patch > md-make-md-on-disk-bitmaps-not-host-endian.patch > md-support-bio_rw_barrier-for-md-raid1.patch > drivers-md-fix-up-schedule_timeout-usage.patch > > - > To unsubscribe from this list: send the line "unsubscribe linux-raid" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH md 000 of 2] Introduction 2005-10-31 6:44 ` Neil Brown @ 2005-10-31 7:56 ` Andrew Morton 2005-10-31 14:45 ` Mr. James W. Laferriere 1 sibling, 0 replies; 8+ messages in thread From: Andrew Morton @ 2005-10-31 7:56 UTC (permalink / raw) To: Neil Brown; +Cc: linux-raid Neil Brown <neilb@suse.de> wrote: > > On Sunday October 30, akpm@osdl.org wrote: > > NeilBrown <neilb@suse.de> wrote: > > > > > > > > > I'd like to review the sysfs a bit more before it goes to Linus, but > > > the rest can go anytime. > > > > umm, what does "the sysfs" refer to? > > Sorry.. "the sysfs related patches". > > Those marked as 'THIS' below. > > However I think a couple that come after those won't simple move > backwards (largely due to > md-convert-faulty-and-in_sync-fields-to-bits-in-flags-field). > > I'll make sure you have a full set that I am happy to go to Linus by > the end of the week. hm, OK, that's a bit late in the process to be introducing new material, so no later please. Also, please make sure that Greg is copied on sysfs things - save me an email ;) ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH md 000 of 2] Introduction 2005-10-31 6:44 ` Neil Brown 2005-10-31 7:56 ` Andrew Morton @ 2005-10-31 14:45 ` Mr. James W. Laferriere 2005-10-31 21:54 ` Neil Brown 1 sibling, 1 reply; 8+ messages in thread From: Mr. James W. Laferriere @ 2005-10-31 14:45 UTC (permalink / raw) To: Neil Brown; +Cc: linux-raid maillist Hello Neil , The original '[PATCH md 000 of 2] Introduction' never hit the list afaict . Could you please re-send or if you did & only I am without it send privately . Tia , JimL On Mon, 31 Oct 2005, Neil Brown wrote: > On Sunday October 30, akpm@osdl.org wrote: > > NeilBrown <neilb@suse.de> wrote: > > > I'd like to review the sysfs a bit more before it goes to Linus, but > > > the rest can go anytime. > > umm, what does "the sysfs" refer to? > Sorry.. "the sysfs related patches". > Those marked as 'THIS' below. > However I think a couple that come after those won't simple move > backwards (largely due to > md-convert-faulty-and-in_sync-fields-to-bits-in-flags-field). > I'll make sure you have a full set that I am happy to go to Linus by > the end of the week. > Thanks, > NeilBrown > > Current md patches in -mm: > > md-better-handling-of-readerrors-with-raid5.patch > THIS > md-initial-sysfs-support-for-md.patch > THIS > md-extend-md-sysfs-support-to-component-devices.patch > THIS > md-add-kobject-sysfs-support-to-raid5.patch > THIS > md-allow-a-manual-resync-with-md.patch > THIS > md-teach-raid5-the-difference-between-check-and-repair.patch > > md-provide-proper-rcu_dereference--rcu_assign_pointer-annotations-in-md.patch > THIS > md-fix-ref-counting-problems-with-kobjects-in-md.patch > THIS > md-minor-md-fixes.patch > THIS > md-change-raid5-sysfs-attribute-to-not-create-a-new-directory.patch > > md-improvements-to-raid5-handling-of-read-errors.patch > > md-convert-faulty-and-in_sync-fields-to-bits-in-flags-field.patch > > md-make-md-on-disk-bitmaps-not-host-endian.patch > > md-support-bio_rw_barrier-for-md-raid1.patch > > drivers-md-fix-up-schedule_timeout-usage.patch -- +------------------------------------------------------------------+ | James W. Laferriere | System Techniques | Give me VMS | | Network Engineer | 3542 Broken Yoke Dr. | Give me Linux | | babydr@baby-dragons.com | Billings , MT. 59105 | only on AXP | +------------------------------------------------------------------+ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH md 000 of 2] Introduction 2005-10-31 14:45 ` Mr. James W. Laferriere @ 2005-10-31 21:54 ` Neil Brown 0 siblings, 0 replies; 8+ messages in thread From: Neil Brown @ 2005-10-31 21:54 UTC (permalink / raw) To: Mr. James W. Laferriere; +Cc: linux-raid maillist On Monday October 31, babydr@baby-dragons.com wrote: > Hello Neil , The original '[PATCH md 000 of 2] Introduction' never hit > the list afaict . Could you please re-send or if you did & only I am > without it send privately . Tia , JimL I cannot knot who else is without it :-), but you can find it here. http://marc.theaimsgroup.com/?l=linux-raid&m=113073839213484&w=2 NeilBrown ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-10-31 21:54 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-10-31 5:58 [PATCH md 000 of 2] Introduction NeilBrown 2005-10-31 5:58 ` [PATCH md 001 of 2] Remove attempt to use dynamic names in sysfs for component devices on an MD array NeilBrown 2005-10-31 5:59 ` [PATCH md 002 of 2] Allow md arrays to be started read-only (module parameter) NeilBrown 2005-10-31 7:34 ` [PATCH md 000 of 2] Introduction Andrew Morton 2005-10-31 6:44 ` Neil Brown 2005-10-31 7:56 ` Andrew Morton 2005-10-31 14:45 ` Mr. James W. Laferriere 2005-10-31 21:54 ` Neil Brown
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).