From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
To: jes.sorensen@gmail.com
Cc: linux-raid@vger.kernel.org,
Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Subject: [PATCH] Don't use UnSet with consistency_policy
Date: Mon, 24 Apr 2017 16:03:26 +0200 [thread overview]
Message-ID: <20170424140326.2707-1-artur.paszkiewicz@intel.com> (raw)
Use CONSISTENCY_POLICY_UNKNOWN instead. Simplify some checks because
since 5e8e35fb7e17 ("maps: Use keyvalue for null terminator to indicate
'unset' value") map_name() can return this default directly.
Suggested-by: Jes Sorensen <Jes.Sorensen@gmail.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
---
maps.c | 2 +-
mdadm.c | 12 ++++++------
super-intel.c | 4 +---
sysfs.c | 10 ++++------
4 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/maps.c b/maps.c
index 11dd3d20..8fe0a6df 100644
--- a/maps.c
+++ b/maps.c
@@ -137,7 +137,7 @@ mapping_t consistency_policies[] = {
{ "bitmap", CONSISTENCY_POLICY_BITMAP},
{ "journal", CONSISTENCY_POLICY_JOURNAL},
{ "ppl", CONSISTENCY_POLICY_PPL},
- { NULL, UnSet }
+ { NULL, CONSISTENCY_POLICY_UNKNOWN }
};
mapping_t sysfs_array_states[] = {
diff --git a/mdadm.c b/mdadm.c
index 41dae1db..b689e328 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
.level = UnSet,
.layout = UnSet,
.bitmap_chunk = UnSet,
- .consistency_policy = UnSet,
+ .consistency_policy = CONSISTENCY_POLICY_UNKNOWN,
};
char sys_hostname[256];
@@ -1228,8 +1228,7 @@ int main(int argc, char *argv[])
case O(GROW, 'k'):
s.consistency_policy = map_name(consistency_policies,
optarg);
- if (s.consistency_policy == UnSet ||
- s.consistency_policy < CONSISTENCY_POLICY_RESYNC) {
+ if (s.consistency_policy < CONSISTENCY_POLICY_RESYNC) {
pr_err("Invalid consistency policy: %s\n",
optarg);
exit(2);
@@ -1267,7 +1266,7 @@ int main(int argc, char *argv[])
pr_err("--write-journal is only supported for RAID level 4/5/6.\n");
exit(2);
}
- if (s.consistency_policy != UnSet &&
+ if (s.consistency_policy != CONSISTENCY_POLICY_UNKNOWN &&
s.consistency_policy != CONSISTENCY_POLICY_JOURNAL) {
pr_err("--write-journal is not supported with consistency policy: %s\n",
map_num(consistency_policies, s.consistency_policy));
@@ -1275,7 +1274,8 @@ int main(int argc, char *argv[])
}
}
- if (mode == CREATE && s.consistency_policy != UnSet) {
+ if (mode == CREATE &&
+ s.consistency_policy != CONSISTENCY_POLICY_UNKNOWN) {
if (s.level <= 0) {
pr_err("--consistency-policy not meaningful with level %s.\n",
map_num(pers, s.level));
@@ -1687,7 +1687,7 @@ int main(int argc, char *argv[])
rv = Grow_reshape(devlist->devname, mdfd,
devlist->next,
data_offset, &c, &s);
- } else if (s.consistency_policy != UnSet) {
+ } else if (s.consistency_policy != CONSISTENCY_POLICY_UNKNOWN) {
rv = Grow_consistency_policy(devlist->devname, mdfd, &c, &s);
} else if (array_size == 0)
pr_err("no changes to --grow\n");
diff --git a/super-intel.c b/super-intel.c
index 0aed57c8..fbff215c 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -5369,9 +5369,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
}
mpb->num_raid_devs++;
- if (s->consistency_policy == UnSet ||
- s->consistency_policy == CONSISTENCY_POLICY_RESYNC ||
- s->consistency_policy == CONSISTENCY_POLICY_NONE) {
+ if (s->consistency_policy <= CONSISTENCY_POLICY_RESYNC) {
dev->rwh_policy = RWH_OFF;
} else if (s->consistency_policy == CONSISTENCY_POLICY_PPL) {
dev->rwh_policy = RWH_DISTRIBUTED;
diff --git a/sysfs.c b/sysfs.c
index 712f8b3e..aa30de5c 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -254,13 +254,11 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
if (options & GET_CONSISTENCY_POLICY) {
strcpy(base, "consistency_policy");
- if (load_sys(fname, buf, sizeof(buf))) {
+ if (load_sys(fname, buf, sizeof(buf)))
sra->consistency_policy = CONSISTENCY_POLICY_UNKNOWN;
- } else {
- sra->consistency_policy = map_name(consistency_policies, buf);
- if (sra->consistency_policy == UnSet)
- sra->consistency_policy = CONSISTENCY_POLICY_UNKNOWN;
- }
+ else
+ sra->consistency_policy = map_name(consistency_policies,
+ buf);
}
if (! (options & GET_DEVS))
--
2.11.0
next reply other threads:[~2017-04-24 14:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-24 14:03 Artur Paszkiewicz [this message]
2017-04-24 21:11 ` [PATCH] Don't use UnSet with consistency_policy Jes Sorensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170424140326.2707-1-artur.paszkiewicz@intel.com \
--to=artur.paszkiewicz@intel.com \
--cc=jes.sorensen@gmail.com \
--cc=linux-raid@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).