summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-12-14 12:57:55 -0700
committerDan Williams <dan.j.williams@intel.com>2009-12-14 12:57:55 -0700
commitb7941fd68de046be58de4d53fe08925fdb9008f0 (patch)
treed2ec919476da339a8e934192135b90f06f927eb5 /monitor.c
parent071cfc42580673b149140339a862f90399dc00b5 (diff)
downloadmdadm-b7941fd68de046be58de4d53fe08925fdb9008f0.tar.gz
mdmon: cleanup resync_start
We don't need to sprinkle reads of this attribute all over the place, just once at the entry of read_and_act(). Also, the mdinfo structure for the array already has a 'resync_start' member, so just reuse that. Finally, rename get_resync_start() to read_resync_start to make it consistent with the other sysfs accessors in monitor.c. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/monitor.c b/monitor.c
index 0cafc3a..a8e0af3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -66,23 +66,20 @@ static int read_attr(char *buf, int len, int fd)
return n;
}
-int get_resync_start(struct active_array *a)
+static unsigned long long read_resync_start(int fd)
{
char buf[30];
int n;
- n = read_attr(buf, 30, a->resync_start_fd);
+ n = read_attr(buf, 30, fd);
if (n <= 0)
- return n;
+ return 0;
if (strncmp(buf, "none", 4) == 0)
- a->resync_start = ~0ULL;
+ return ~0ULL;
else
- a->resync_start = strtoull(buf, NULL, 10);
-
- return 1;
+ return strtoull(buf, NULL, 10);
}
-
static enum array_state read_state(int fd)
{
char buf[20];
@@ -208,6 +205,7 @@ static int read_and_act(struct active_array *a)
a->curr_state = read_state(a->info.state_fd);
a->curr_action = read_action(a->action_fd);
+ a->info.resync_start = read_resync_start(a->resync_start_fd);
for (mdi = a->info.devs; mdi ; mdi = mdi->next) {
mdi->next_state = 0;
if (mdi->state_fd >= 0)
@@ -217,13 +215,11 @@ static int read_and_act(struct active_array *a)
if (a->curr_state <= inactive &&
a->prev_state > inactive) {
/* array has been stopped */
- get_resync_start(a);
a->container->ss->set_array_state(a, 1);
a->next_state = clear;
deactivate = 1;
}
if (a->curr_state == write_pending) {
- get_resync_start(a);
a->container->ss->set_array_state(a, 0);
a->next_state = active;
dirty = 1;
@@ -236,7 +232,6 @@ static int read_and_act(struct active_array *a)
dirty = 1;
}
if (a->curr_state == clean) {
- get_resync_start(a);
a->container->ss->set_array_state(a, 1);
}
if (a->curr_state == active ||
@@ -253,7 +248,6 @@ static int read_and_act(struct active_array *a)
/* explicit request for readonly array. Leave it alone */
;
} else {
- get_resync_start(a);
if (a->container->ss->set_array_state(a, 2))
a->next_state = read_auto; /* array is clean */
else {
@@ -271,7 +265,6 @@ static int read_and_act(struct active_array *a)
* until the array goes inactive or readonly though.
* Just check if we need to fiddle spares.
*/
- get_resync_start(a);
a->container->ss->set_array_state(a, a->curr_state <= clean);
check_degraded = 1;
}