diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-12-12 17:22:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-12-12 17:22:10 +0000 |
commit | 55526d6577f82349bf6bb59816680d7483b61dff (patch) | |
tree | 456f8e2360e6bbd83e4f9a571f97cda281e4d9d9 /mdadm.c | |
parent | Releasing debian version 4.3+20241108-1. (diff) | |
download | mdadm-55526d6577f82349bf6bb59816680d7483b61dff.tar.xz mdadm-55526d6577f82349bf6bb59816680d7483b61dff.zip |
Merging upstream version 4.3+20241202.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mdadm.c')
-rw-r--r-- | mdadm.c | 87 |
1 files changed, 43 insertions, 44 deletions
@@ -41,18 +41,23 @@ */ static mdadm_status_t set_bitmap_value(struct shape *s, struct context *c, char *val) { - if (s->bitmap_file) { + if (s->btype != BitmapUnknown) { pr_err("--bitmap cannot be set twice. Second value: \"%s\".\n", val); return MDADM_STATUS_ERROR; } - if (strcmp(val, "internal") == 0 || strcmp(optarg, STR_COMMON_NONE) == 0) { - s->bitmap_file = val; + if (strcmp(optarg, STR_COMMON_NONE) == 0) { + s->btype = BitmapNone; + return MDADM_STATUS_SUCCESS; + } + + if (strcmp(val, "internal") == 0) { + s->btype = BitmapInternal; return MDADM_STATUS_SUCCESS; } if (strcmp(val, "clustered") == 0) { - s->bitmap_file = val; + s->btype = BitmapCluster; /* Set the default number of cluster nodes * to 4 if not already set by user */ @@ -62,17 +67,12 @@ static mdadm_status_t set_bitmap_value(struct shape *s, struct context *c, char } if (strchr(val, '/')) { - pr_info("Custom write-intent bitmap file option is deprecated.\n"); - if (ask("Do you want to continue? (y/n)")) { - s->bitmap_file = val; - return MDADM_STATUS_SUCCESS; - } - + pr_err("Custom write-intent bitmap file option is not supported.\n"); return MDADM_STATUS_ERROR; } - pr_err("--bitmap value must contain a '/' or be 'internal', 'clustered' or 'none'\n"); - pr_err("Current value is \"%s\"", val); + pr_err("--bitmap value must be 'internal', 'clustered' or 'none'\n"); + pr_err("Current value is \"%s\"\n", val); return MDADM_STATUS_ERROR; } @@ -99,7 +99,6 @@ int main(int argc, char *argv[]) struct mddev_ident ident; char *configfile = NULL; int devmode = 0; - int bitmap_fd = -1; struct mddev_dev *devlist = NULL; struct mddev_dev **devlistend = & devlist; struct mddev_dev *dv; @@ -116,6 +115,7 @@ int main(int argc, char *argv[]) .bitmap_chunk = UnSet, .consistency_policy = CONSISTENCY_POLICY_UNKNOWN, .data_offset = INVALID_SECTORS, + .btype = BitmapUnknown, }; char sys_hostname[256]; @@ -1089,24 +1089,15 @@ int main(int argc, char *argv[]) case O(ASSEMBLE,'b'): /* here we simply set the bitmap file */ case O(ASSEMBLE,Bitmap): - if (!optarg) { - pr_err("bitmap file needed with -b in --assemble mode\n"); - exit(2); - } - if (strcmp(optarg, "internal") == 0 || - strcmp(optarg, "clustered") == 0) { + if (optarg && (strcmp(optarg, "internal") == 0 || + strcmp(optarg, "clustered")) == 0) { pr_err("no need to specify --bitmap when assembling" " arrays with internal or clustered bitmap\n"); continue; } - bitmap_fd = open(optarg, O_RDWR); - if (!*optarg || bitmap_fd < 0) { - pr_err("cannot open bitmap file %s: %s\n", optarg, strerror(errno)); - exit(2); - } - ident.bitmap_fd = bitmap_fd; /* for Assemble */ - continue; + pr_err("bitmap file is not supported %s\n", optarg); + exit(2); case O(ASSEMBLE, BackupFile): case O(GROW, BackupFile): /* Specify a file into which grow might place a backup, @@ -1256,12 +1247,11 @@ int main(int argc, char *argv[]) pr_err("PPL consistency policy is only supported for RAID level 5.\n"); exit(2); } else if (s.consistency_policy == CONSISTENCY_POLICY_BITMAP && - (!s.bitmap_file || str_is_none(s.bitmap_file) == true)) { + s.btype == BitmapNone) { pr_err("--bitmap is required for consistency policy: %s\n", map_num_s(consistency_policies, s.consistency_policy)); exit(2); - } else if (s.bitmap_file && - str_is_none(s.bitmap_file) == false && + } else if ((s.btype == BitmapInternal || s.btype == BitmapCluster) && s.consistency_policy != CONSISTENCY_POLICY_BITMAP && s.consistency_policy != CONSISTENCY_POLICY_JOURNAL) { pr_err("--bitmap is not compatible with consistency policy: %s\n", @@ -1394,7 +1384,7 @@ int main(int argc, char *argv[]) c.brief = 1; if (mode == CREATE) { - if (s.bitmap_file && strcmp(s.bitmap_file, "clustered") == 0) { + if (s.btype == BitmapCluster) { locked = cluster_get_dlmlock(); if (locked != 1) exit(1); @@ -1479,7 +1469,17 @@ int main(int argc, char *argv[]) case BUILD: if (c.delay == 0) c.delay = DEFAULT_BITMAP_DELAY; - if (s.write_behind && !s.bitmap_file) { + + if (s.btype == BitmapUnknown) + s.btype = BitmapNone; + + if (s.btype != BitmapNone) { + pr_err("--build argument only compatible with --bitmap=none\n"); + rv |= 1; + break; + } + + if (s.write_behind) { pr_err("write-behind mode requires a bitmap.\n"); rv = 1; break; @@ -1490,14 +1490,6 @@ int main(int argc, char *argv[]) break; } - if (s.bitmap_file) { - if (strcmp(s.bitmap_file, "internal") == 0 || - strcmp(s.bitmap_file, "clustered") == 0) { - pr_err("'internal' and 'clustered' bitmaps not supported with --build\n"); - rv |= 1; - break; - } - } rv = Build(&ident, devlist->next, &s, &c); break; case CREATE: @@ -1505,8 +1497,7 @@ int main(int argc, char *argv[]) c.delay = DEFAULT_BITMAP_DELAY; if (c.nodes) { - if (!s.bitmap_file || - strcmp(s.bitmap_file, "clustered") != 0) { + if (s.btype != BitmapCluster) { pr_err("--nodes argument only compatible with --bitmap=clustered\n"); rv = 1; break; @@ -1524,7 +1515,7 @@ int main(int argc, char *argv[]) } } - if (s.write_behind && !s.bitmap_file) { + if (s.write_behind && s.btype == BitmapNone) { pr_err("write-behind mode requires a bitmap.\n"); rv = 1; break; @@ -1535,6 +1526,14 @@ int main(int argc, char *argv[]) break; } + if (s.btype == BitmapUnknown) { + if (c.runstop != 1 && s.level >= 1 && + ask("To optimalize recovery speed, it is recommended to enable write-indent bitmap, do you want to enable it now?")) + s.btype = BitmapInternal; + else + s.btype = BitmapNone; + } + rv = Create(ss, &ident, devs_found - 1, devlist->next, &s, &c); break; case MISC: @@ -1626,7 +1625,7 @@ int main(int argc, char *argv[]) if (devs_found > 1 && s.raiddisks == 0 && s.level == UnSet) { /* must be '-a'. */ if (s.size > 0 || s.chunk || - s.layout_str || s.bitmap_file) { + s.layout_str || s.btype != BitmapNone) { pr_err("--add cannot be used with other geometry changes in --grow mode\n"); rv = 1; break; @@ -1636,7 +1635,7 @@ int main(int argc, char *argv[]) if (rv) break; } - } else if (s.bitmap_file) { + } else if (s.btype != BitmapUnknown) { if (s.size > 0 || s.raiddisks || s.chunk || s.layout_str || devs_found > 1) { pr_err("--bitmap changes cannot be used with other geometry changes in --grow mode\n"); |