--no-sharing option disables moving spares between arrays/containers.
Without the option spares are moved if needed according to config rules.
We only allow one process moving spares started with --scan option.
If there is such process running and another instance of Monitor
is starting without --scan, then we issue a warning but allow it
to continue.
Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
int Monitor(struct mddev_dev *devlist,
char *mailaddr, char *alert_cmd,
int period, int daemonise, int scan, int oneshot,
- int dosyslog, int test, char* pidfile, int increments)
+ int dosyslog, int test, char *pidfile, int increments,
+ int share)
{
/*
* Every few seconds, scan every md device looking for changes
setsid();
}
+ if (share) {
+ int pid, rv;
+ FILE *fp;
+ char dir[20];
+ struct stat buf;
+ fp = fopen("/var/run/mdadm/autorebuild.pid", "r");
+ if (fp) {
+ fscanf(fp, "%d", &pid);
+ sprintf(dir, "/proc/%d", pid);
+ rv = stat(dir, &buf);
+ if (rv != -1) {
+ if (scan) {
+ fprintf(stderr, Name ": Only one "
+ "autorebuild process allowed"
+ " in scan mode, aborting\n");
+ fclose(fp);
+ return 1;
+ } else {
+ fprintf(stderr, Name ": Warning: One"
+ " autorebuild process already"
+ " running.");
+ }
+ }
+ fclose(fp);
+ }
+ if (scan) {
+ fp = fopen("/var/run/mdadm/autorebuild.pid", "w");
+ if (!fp)
+ fprintf(stderr, Name ": Cannot create"
+ " autorebuild.pid "
+ "file\n");
+ else {
+ pid = getpid();
+ fprintf(fp, "%d\n", pid);
+ fclose(fp);
+ }
+ }
+ }
+
if (devlist == NULL) {
struct mddev_ident *mdlist = conf_get_ident(NULL);
for (; mdlist; mdlist=mdlist->next) {
* Look for another array with spare > 0 and active == raid and same spare_group
* if found, choose a device and hotremove/hotadd
*/
- for (st = statelist; st; st=st->next)
+ if (share) for (st = statelist; st; st=st->next)
if (st->active < st->raid &&
st->spare == 0 &&
st->spare_group != NULL) {
{"oneshot", 0, 0, '1'},
{"pid-file", 1, 0, 'i'},
{"syslog", 0, 0, 'y'},
+ {"no-sharing", 0, 0, NoSharing},
+
/* For Grow */
{"backup-file", 1,0, BackupFile},
{"array-size", 1, 0, 'Z'},
int daemonise = 0;
char *pidfile = NULL;
int oneshot = 0;
+ int spare_sharing = 1;
struct supertype *ss = NULL;
int writemostly = 0;
int re_add = 0;
subarray = optarg;
}
case 'K': if (!mode) newmode = MISC; break;
+ case NoSharing: newmode = MONITOR; break;
}
if (mode && newmode == mode) {
/* everybody happy ! */
openlog("mdadm", LOG_PID, SYSLOG_FACILITY);
dosyslog = 1;
continue;
-
+ case O(MONITOR, NoSharing):
+ spare_sharing = 0;
+ continue;
/* now the general management options. Some are applicable
* to other modes. None have arguments.
*/
}
rv= Monitor(devlist, mailaddr, program,
delay?delay:60, daemonise, scan, oneshot,
- dosyslog, test, pidfile, increments);
+ dosyslog, test, pidfile, increments, spare_sharing);
break;
case GROW:
DetailPlatform,
KillSubarray,
UpdateSubarray, /* 16 */
- IncrementalPath
+ IncrementalPath,
+ NoSharing
};
/* structures read from config file */
extern int Monitor(struct mddev_dev *devlist,
char *mailaddr, char *alert_cmd,
int period, int daemonise, int scan, int oneshot,
- int dosyslog, int test, char *pidfile, int increments);
+ int dosyslog, int test, char *pidfile, int increments,
+ int share);
extern int Kill(char *dev, struct supertype *st, int force, int quiet, int noexcl);
extern int Kill_subarray(char *dev, char *subarray, int quiet);