Commit 92d9aac9 authored by Heming Zhao's avatar Heming Zhao Committed by Song Liu

md: replace deprecated strlcpy & remove duplicated line

This commit includes two topics:

1> replace deprecated strlcpy

change strlcpy to strscpy for strlcpy is marked as deprecated in
Documentation/process/deprecated.rst

2> remove duplicated strlcpy line

in md_bitmap_read_sb@md-bitmap.c there are two duplicated strlcpy(), the
history:

- commit cf921cc1 ("Add node recovery callbacks") introduced the first
  usage of strlcpy().

- commit b97e9257 ("Use separate bitmaps for each nodes in the cluster")
  introduced the second strlcpy(). this time, the two strlcpy() are same,
   we can remove anyone safely.

- commit d3b178ad ("md: Skip cluster setup for dm-raid") added dm-raid
  special handling. And the "nodes" value is the key of this patch. but
  from this patch, strlcpy() which was introduced by b97e9257
  become necessary.

- commit 3c462c88 ("md: Increment version for clustered bitmaps") used
  clustered major version to only handle in clustered env. this patch
  could look a polishment for clustered code logic.

So cf921cc1 became useless after d3b178ad, we could remove it
safely.
Signed-off-by: default avatarHeming Zhao <heming.zhao@suse.com>
Signed-off-by: default avatarSong Liu <song@kernel.org>
parent e68cb83a
...@@ -666,7 +666,7 @@ static int md_bitmap_read_sb(struct bitmap *bitmap) ...@@ -666,7 +666,7 @@ static int md_bitmap_read_sb(struct bitmap *bitmap)
*/ */
if (sb->version == cpu_to_le32(BITMAP_MAJOR_CLUSTERED)) { if (sb->version == cpu_to_le32(BITMAP_MAJOR_CLUSTERED)) {
nodes = le32_to_cpu(sb->nodes); nodes = le32_to_cpu(sb->nodes);
strlcpy(bitmap->mddev->bitmap_info.cluster_name, strscpy(bitmap->mddev->bitmap_info.cluster_name,
sb->cluster_name, 64); sb->cluster_name, 64);
} }
...@@ -697,7 +697,6 @@ static int md_bitmap_read_sb(struct bitmap *bitmap) ...@@ -697,7 +697,6 @@ static int md_bitmap_read_sb(struct bitmap *bitmap)
if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN) if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN)
set_bit(BITMAP_HOSTENDIAN, &bitmap->flags); set_bit(BITMAP_HOSTENDIAN, &bitmap->flags);
bitmap->events_cleared = le64_to_cpu(sb->events_cleared); bitmap->events_cleared = le64_to_cpu(sb->events_cleared);
strlcpy(bitmap->mddev->bitmap_info.cluster_name, sb->cluster_name, 64);
err = 0; err = 0;
out: out:
......
...@@ -201,7 +201,7 @@ static struct dlm_lock_resource *lockres_init(struct mddev *mddev, ...@@ -201,7 +201,7 @@ static struct dlm_lock_resource *lockres_init(struct mddev *mddev,
pr_err("md-cluster: Unable to allocate resource name for resource %s\n", name); pr_err("md-cluster: Unable to allocate resource name for resource %s\n", name);
goto out_err; goto out_err;
} }
strlcpy(res->name, name, namelen + 1); strscpy(res->name, name, namelen + 1);
if (with_lvb) { if (with_lvb) {
res->lksb.sb_lvbptr = kzalloc(LVB_SIZE, GFP_KERNEL); res->lksb.sb_lvbptr = kzalloc(LVB_SIZE, GFP_KERNEL);
if (!res->lksb.sb_lvbptr) { if (!res->lksb.sb_lvbptr) {
......
...@@ -4031,7 +4031,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -4031,7 +4031,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
oldpriv = mddev->private; oldpriv = mddev->private;
mddev->pers = pers; mddev->pers = pers;
mddev->private = priv; mddev->private = priv;
strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); strscpy(mddev->clevel, pers->name, sizeof(mddev->clevel));
mddev->level = mddev->new_level; mddev->level = mddev->new_level;
mddev->layout = mddev->new_layout; mddev->layout = mddev->new_layout;
mddev->chunk_sectors = mddev->new_chunk_sectors; mddev->chunk_sectors = mddev->new_chunk_sectors;
...@@ -5765,7 +5765,7 @@ static int add_named_array(const char *val, const struct kernel_param *kp) ...@@ -5765,7 +5765,7 @@ static int add_named_array(const char *val, const struct kernel_param *kp)
len--; len--;
if (len >= DISK_NAME_LEN) if (len >= DISK_NAME_LEN)
return -E2BIG; return -E2BIG;
strlcpy(buf, val, len+1); strscpy(buf, val, len+1);
if (strncmp(buf, "md_", 3) == 0) if (strncmp(buf, "md_", 3) == 0)
return md_alloc(0, buf); return md_alloc(0, buf);
if (strncmp(buf, "md", 2) == 0 && if (strncmp(buf, "md", 2) == 0 &&
...@@ -5898,7 +5898,7 @@ int md_run(struct mddev *mddev) ...@@ -5898,7 +5898,7 @@ int md_run(struct mddev *mddev)
mddev->level = pers->level; mddev->level = pers->level;
mddev->new_level = pers->level; mddev->new_level = pers->level;
} }
strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); strscpy(mddev->clevel, pers->name, sizeof(mddev->clevel));
if (mddev->reshape_position != MaxSector && if (mddev->reshape_position != MaxSector &&
pers->start_reshape == NULL) { pers->start_reshape == NULL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment