Re: [PATCH 010 of 10] md: Allow the write_mostly flag to be set via sysfs.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/5/06, Mike Snitzer <snitzer@xxxxxxxxx> wrote:
Aside from this write-mostly sysfs support, is there a way to toggle
the write-mostly bit of an md member with mdadm?  I couldn't identify
a clear way to do so.

It'd be nice if mdadm --assemble would honor --write-mostly...

I went ahead and implemented the ability to toggle the write-mostly
bit for all disks in an array.  I did so by adding another type of
--update to --assemble.  This is very useful for a 2 disk raid1 (one
disk local, one remote).   When you switch the raidhost you also need
to toggle the write-mostly bit too.

I've tested the attached patch to work with both ver.90 and ver1
superblocks with mdadm 2.4.1 and 2.5.2.  The patch is against mdadm
2.4.1 but applies cleanly (with fuzz) against mdadm 2.5.2).

# cat /proc/mdstat
...
md2 : active raid1 nbd2[0] sdd[1](W)
     390613952 blocks [2/2] [UU]
     bitmap: 0/187 pages [0KB], 1024KB chunk

# mdadm -S /dev/md2
# mdadm --assemble /dev/md2 --run --update=toggle-write-mostly
/dev/sdd /dev/nbd2
mdadm: /dev/md2 has been started with 2 drives.

# cat /proc/mdstat
...
md2 : active raid1 nbd2[0](W) sdd[1]
     390613952 blocks [2/2] [UU]
     bitmap: 0/187 pages [0KB], 1024KB chunk
diff -Naur mdadm-2.4.1/mdadm.c mdadm-2.4.1_toggle_write_mostly/mdadm.c
--- mdadm-2.4.1/mdadm.c	2006-03-28 21:55:39.000000000 -0500
+++ mdadm-2.4.1_toggle_write_mostly/mdadm.c	2006-08-05 17:01:48.000000000 -0400
@@ -587,6 +587,8 @@
 				continue;
 			if (strcmp(update, "uuid")==0)
 				continue;
+			if (strcmp(update, "toggle-write-mostly")==0)
+				continue;
 			if (strcmp(update, "byteorder")==0) {
 				if (ss) {
 					fprintf(stderr, Name ": must not set metadata type with --update=byteorder.\n");
@@ -601,7 +603,7 @@
 
 				continue;
 			}
-			fprintf(stderr, Name ": '--update %s' invalid.  Only 'sparc2.2', 'super-minor', 'uuid', 'resync' or 'summaries' supported\n",update);
+			fprintf(stderr, Name ": '--update %s' invalid.  Only 'sparc2.2', 'super-minor', 'uuid', 'resync', 'summaries' or 'toggle-write-mostly' supported\n",update);
 			exit(2);
 
 		case O(ASSEMBLE,'c'): /* config file */
diff -Naur mdadm-2.4.1/super0.c mdadm-2.4.1_toggle_write_mostly/super0.c
--- mdadm-2.4.1/super0.c	2006-03-28 01:10:51.000000000 -0500
+++ mdadm-2.4.1_toggle_write_mostly/super0.c	2006-08-05 18:04:45.000000000 -0400
@@ -382,6 +382,10 @@
 			rv = 1;
 		}
 	}
+	if (strcmp(update, "toggle-write-mostly")==0) {
+		int d = info->disk.number;
+		sb->disks[d].state ^= (1<<MD_DISK_WRITEMOSTLY);
+	}
 	if (strcmp(update, "newdev") == 0) {
 		int d = info->disk.number;
 		memset(&sb->disks[d], 0, sizeof(sb->disks[d]));
diff -Naur mdadm-2.4.1/super1.c mdadm-2.4.1_toggle_write_mostly/super1.c
--- mdadm-2.4.1/super1.c	2006-04-07 00:32:06.000000000 -0400
+++ mdadm-2.4.1_toggle_write_mostly/super1.c	2006-08-05 18:33:21.000000000 -0400
@@ -446,6 +446,9 @@
 			rv = 1;
 		}
 	}
+	if (strcmp(update, "toggle-write-mostly")==0) {
+		sb->devflags ^= WriteMostly1;
+	}
 #if 0
 	if (strcmp(update, "newdev") == 0) {
 		int d = info->disk.number;

[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux