The option was there, but never used.
Signed-off-by: NeilBrown <neilb@suse.de>
/* This is a member of a container. Try starting the array. */
int err;
err = assemble_container_content(st, mdfd, content, runstop,
+ readonly,
chosen_name, verbose,
backup_file, freeze_reshape);
close(mdfd);
rv = Grow_continue(mdfd, st, content,
backup_file,
freeze_reshape);
+ } else if (readonly &&
+ sysfs_attribute_available(
+ content, NULL, "array_state")) {
+ rv = sysfs_set_str(content, NULL,
+ "array_state", "readonly");
} else
#endif
rv = ioctl(mdfd, RUN_ARRAY, NULL);
#ifndef MDASSEMBLE
int assemble_container_content(struct supertype *st, int mdfd,
struct mdinfo *content, int runstop,
+ int readonly,
char *chosen_name, int verbose,
char *backup_file, int freeze_reshape)
{
sysfs_init(content, mdfd, 0);
sra = sysfs_read(mdfd, 0, GET_VERSION);
- if (sra == NULL || strcmp(sra->text_version, content->text_version) != 0)
+ if (sra == NULL || strcmp(sra->text_version, content->text_version) != 0) {
+ if (content->array.major_version == -1 &&
+ content->array.minor_version == -2 &&
+ readonly &&
+ content->text_version[0] == '/')
+ content->text_version[0] = '-';
if (sysfs_set_array(content, md_get_version(mdfd)) != 0) {
if (sra)
sysfs_free(sra);
return 1;
}
+ }
/* There are two types of reshape: container wide or sub-array specific
* Check if metadata requests blocking container wide reshapes
case LEVEL_MULTIPATH:
case 0:
err = sysfs_set_str(content, NULL, "array_state",
- "active");
+ readonly ? "readonly" : "active");
break;
default:
err = sysfs_set_str(content, NULL, "array_state",
static int Incremental_container(struct supertype *st, char *devname,
char *homehost,
- int verbose, int runstop, int autof,
+ int verbose, int runstop,
+ int readonly, int autof,
int freeze_reshape);
int Incremental(char *devname, int verbose, int runstop,
pr_err("failed to get "
"exclusive lock on mapfile\n");
rv = Incremental_container(st, devname, homehost,
- verbose, runstop, autof,
+ verbose, runstop,
+ 0, autof,
freeze_reshape);
map_unlock(&map);
return rv;
sysfs_free(sra);
if (!rv)
rv = Incremental_container(st, chosen_name, homehost,
- verbose, runstop, autof,
+ verbose, runstop, 0, autof,
freeze_reshape);
map_unlock(&map);
if (rv == 1)
static int Incremental_container(struct supertype *st, char *devname,
char *homehost, int verbose,
- int runstop, int autof, int freeze_reshape)
+ int runstop, int readonly,
+ int autof, int freeze_reshape)
{
/* Collect the contents of this container and for each
* array, choose a device name and assemble the array.
return 2;
}
- assemble_container_content(st, mdfd, ra, runstop,
+ assemble_container_content(st, mdfd, ra, runstop, readonly,
chosen_name, verbose, NULL,
freeze_reshape);
close(mdfd);
" : out-of-date. This involves modifying the superblocks.\n"
" --update= -U : Update superblock: try '-A --update=?' for option list.\n"
" --no-degraded : Assemble but do not start degraded arrays.\n"
+" --readonly -o : Mark the array as read-only. No resync will start.\n"
;
char Help_manage[] =
.I mdadm
will not try to be so clever.
+.TP
+.BR \-o ", " \-\-readonly
+Start the array
+.B read only
+rather than read-write as normal. No writes will be allowed to the
+array, and no resync, recovery, or reshape will be started.
+
.TP
.BR \-a ", " "\-\-auto{=yes,md,mdp,part,p}{NN}"
Instruct mdadm how to create the device file if needed, possibly allocating
}
continue;
+ case O(ASSEMBLE,'o'):
+ case O(MANAGE,'o'):
+ case O(CREATE,'o'):
+ readonly = 1;
+ continue;
+
case O(ASSEMBLE,'U'): /* update the superblock */
case O(MISC,'U'):
if (update) {
extern void append_metadata_update(struct supertype *st, void *buf, int len);
extern int assemble_container_content(struct supertype *st, int mdfd,
struct mdinfo *content, int runstop,
+ int readonly,
char *chosen_name, int verbose,
char *backup_file, int freeze_reshape);
extern struct mdinfo *container_choose_spares(struct supertype *st,