]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Allow WRITEMOSTLY to be cleared on --readd using --readwrite.
authorNeilBrown <neilb@suse.de>
Sat, 25 Oct 2008 07:20:49 +0000 (18:20 +1100)
committerNeilBrown <neilb@suse.de>
Sat, 25 Oct 2008 07:20:49 +0000 (18:20 +1100)
Previously it was possible to set the WRITEMOSTLY flag when
adding a device to an array, but not to clear the flag when re-adding.
This is now possible with --readwrite.

Signed-off-by: NeilBrown <neilb@suse.de>
Build.c
ChangeLog
Create.c
Manage.c
mdadm.8
mdadm.c
mdadm.h

diff --git a/Build.c b/Build.c
index d6e20fb84d6acfa57e69c6a9036d13c10bb2c07b..1e213ce438e7729bbc5272223de619b7369a626c 100644 (file)
--- a/Build.c
+++ b/Build.c
@@ -183,7 +183,7 @@ int Build(char *mddev, int mdfd, int chunk, int level, int layout,
                        disk.number = i;
                        disk.raid_disk = i;
                        disk.state = (1<<MD_DISK_SYNC) | (1<<MD_DISK_ACTIVE);
-                       if (dv->writemostly)
+                       if (dv->writemostly == 1)
                                disk.state |= 1<<MD_DISK_WRITEMOSTLY;
                        disk.major = major(stb.st_rdev);
                        disk.minor = minor(stb.st_rdev);
index c6bc0f1e8f2aa1652e307fce187a50eddafd0cd2..adf622c8876b9ef8af9d644b55278136aa39c3b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Changed Prior to this release
+    -   --readwrite can be used with --re-add to clear the writemostly
+        flag.
+
 Changes Prior to 2.6.7 release
     -   Avoid NULL reference calling free_super and elsewhere.
     -   Remove stray semicolon (Causes compile error with gcc-2.95)
index 7b1836a319b267c67484580c5d7af57cefffa26f..9e65d0a9f6516d125cfb5f1c96efb7106a678f46 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -534,7 +534,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
                                                (1<<MD_DISK_SYNC);
                        else
                                info.disk.state = 0;
-                       if (dv->writemostly)
+                       if (dv->writemostly == 1)
                                info.disk.state |= (1<<MD_DISK_WRITEMOSTLY);
 
                        if (dnum == insert_point ||
index 7b3fabe1d016e8f7813a9afa9a446fd2d5c01bf2..160778ed03125d4fd80fb9793bc81214619d9445 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -413,8 +413,10 @@ int Manage_subdevs(char *devname, int fd,
                                                disc.number = mdi.disk.number;
                                                disc.raid_disk = mdi.disk.raid_disk;
                                                disc.state = mdi.disk.state;
-                                               if (dv->writemostly)
+                                               if (dv->writemostly == 1)
                                                        disc.state |= 1 << MD_DISK_WRITEMOSTLY;
+                                               if (dv->writemostly == 2)
+                                                       disc.state &= ~(1 << MD_DISK_WRITEMOSTLY);
                                                if (ioctl(fd, ADD_NEW_DISK, &disc) == 0) {
                                                        if (verbose >= 0)
                                                                fprintf(stderr, Name ": re-added %s\n", dv->devname);
@@ -452,7 +454,7 @@ int Manage_subdevs(char *devname, int fd,
                        disc.number =j;
                        disc.state = 0;
                        if (array.not_persistent==0) {
-                               if (dv->writemostly)
+                               if (dv->writemostly == 1)
                                        disc.state |= 1 << MD_DISK_WRITEMOSTLY;
                                tst->ss->add_to_super(tst, &disc);
                                if (tst->ss->write_init_super(tst, &disc,
@@ -487,7 +489,7 @@ int Manage_subdevs(char *devname, int fd,
                                                break;
                                        }
                        }
-                       if (dv->writemostly)
+                       if (dv->writemostly == 1)
                                disc.state |= (1 << MD_DISK_WRITEMOSTLY);
                        if (ioctl(fd,ADD_NEW_DISK, &disc)) {
                                fprintf(stderr, Name ": add new device failed for %s as %d: %s\n",
diff --git a/mdadm.8 b/mdadm.8
index d26da800b991781754f3b427376aecc33d708b71..054addae82d524bf1e6752d106c9b1c3502039b3 100644 (file)
--- a/mdadm.8
+++ b/mdadm.8
@@ -905,6 +905,17 @@ the system to be marked as failed.  It can then be removed.
 same as
 .BR \-\-fail .
 
+.TP
+.BR \-\-write\-mostly
+Subsequent devices that are added or re-added will have the 'write-mostly'
+flag set.  This is only valid for RAID! and means that the 'md' driver
+will avoid reading from these devices if possible.
+.TP
+.BR \-\-readwrite
+Subsequent devices that are added or re-added will have the 'write-mostly'
+flag cleared.
+
+
 .P
 Each of these options require that the first device listed is the array
 to be acted upon, and the remainder are component devices to be added,
diff --git a/mdadm.c b/mdadm.c
index 3aa3b132eee6d1d9eb555a834e479186a7f0388c..af9627d545307a4c485ec344d77247c5d941a5a4 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -360,6 +360,12 @@ int main(int argc, char *argv[])
                        writemostly = 1;
                        continue;
 
+               case O(MANAGE,'w'):
+                       /* clear write-mostly for following devices */
+                       writemostly = 2;
+                       continue;
+
+
                case O(GROW,'z'):
                case O(CREATE,'z'): /* size */
                        if (size >= 0) {
@@ -745,21 +751,6 @@ int main(int argc, char *argv[])
                        runstop = -1;
                        continue;
 
-               case O(MANAGE,'o'):
-                       if (readonly < 0) {
-                               fprintf(stderr, Name ": Cannot have both readonly and readwrite\n");
-                               exit(2);
-                       }
-                       readonly = 1;
-                       continue;
-               case O(MANAGE,'w'):
-                       if (readonly > 0) {
-                               fprintf(stderr, Name ": Cannot have both readwrite and readonly.\n");
-                               exit(2);
-                       }
-                       readonly = -1;
-                       continue;
-
                case O(MISC,'Q'):
                case O(MISC,'D'):
                case O(MISC,'E'):
diff --git a/mdadm.h b/mdadm.h
index 174ea395ad3002b3b7f8f26d628d69a66f9b12c0..bc4b38e7a5150305a1fc75086a4178f83cb60554 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -232,7 +232,7 @@ typedef struct mddev_dev_s {
        char disposition;       /* 'a' for add, 'r' for remove, 'f' for fail.
                                 * Not set for names read from .config
                                 */
-       char writemostly;
+       char writemostly;       /* 1 for 'set writemostly', 2 for 'clear writemostly' */
        char re_add;
        char used;              /* set when used */
        struct mddev_dev_s *next;