* [PATCH] Detail: remove duplicated code
@ 2024-02-27 6:36 Kinga Tanska
2024-02-27 13:44 ` Paul Menzel
0 siblings, 1 reply; 3+ messages in thread
From: Kinga Tanska @ 2024-02-27 6:36 UTC (permalink / raw)
To: linux-raid; +Cc: jes, mariusz.tkaczyk
Remove duplicated code from Detail(), where MD_UUID
and MD_DEVNAME are being set. Superblock is no longer
required to print system properties. Now it tries to
obtain map in two ways.
Signed-off-by: Kinga Tanska <kinga.tanska@intel.com>
---
Detail.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/Detail.c b/Detail.c
index 57ac336f..92affdc6 100644
--- a/Detail.c
+++ b/Detail.c
@@ -226,6 +226,9 @@ int Detail(char *dev, struct context *c)
str = map_num(pers, array.level);
if (c->export) {
+ char nbuf[64];
+ struct map_ent *mp = NULL, *map = NULL;
+
if (array.raid_disks) {
if (str)
printf("MD_LEVEL=%s\n", str);
@@ -247,32 +250,22 @@ int Detail(char *dev, struct context *c)
array.minor_version);
}
- if (st && st->sb && info) {
- char nbuf[64];
- struct map_ent *mp, *map = NULL;
-
- fname_from_uuid(st, info, nbuf, ':');
- printf("MD_UUID=%s\n", nbuf + 5);
+ if (info)
mp = map_by_uuid(&map, info->uuid);
+ if (!mp)
+ mp = map_by_devnm(&map, fd2devnm(fd));
- if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
+ if (mp) {
+ __fname_from_uuid(mp->uuid, 0, nbuf, ':');
+ printf("MD_UUID=%s\n", nbuf + 5);
+ if (mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN);
+ }
+ map_free(map);
+ if (st && st->sb) {
if (st->ss->export_detail_super)
st->ss->export_detail_super(st);
- map_free(map);
- } else {
- struct map_ent *mp, *map = NULL;
- char nbuf[64];
- mp = map_by_devnm(&map, fd2devnm(fd));
- if (mp) {
- __fname_from_uuid(mp->uuid, 0, nbuf, ':');
- printf("MD_UUID=%s\n", nbuf+5);
- }
- if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
- printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN);
-
- map_free(map);
}
if (!c->no_devices && sra) {
struct mdinfo *mdi;
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Detail: remove duplicated code
2024-02-27 6:36 [PATCH] Detail: remove duplicated code Kinga Tanska
@ 2024-02-27 13:44 ` Paul Menzel
2024-02-27 14:44 ` Kinga Tanska
0 siblings, 1 reply; 3+ messages in thread
From: Paul Menzel @ 2024-02-27 13:44 UTC (permalink / raw)
To: Kinga Tanska; +Cc: linux-raid, jes, mariusz.tkaczyk
Dear Kinga,
Thank you for your patch.
Am 27.02.24 um 07:36 schrieb Kinga Tanska:
> Remove duplicated code from Detail(), where MD_UUID
> and MD_DEVNAME are being set. Superblock is no longer
> required to print system properties. Now it tries to
> obtain map in two ways.
Do you have the commit removing the requirement handy? If so, please add it.
It’d be great if you used 72 characters per line, so less lines are used.
Kind regards,
Paul
> Signed-off-by: Kinga Tanska <kinga.tanska@intel.com>
> ---
> Detail.c | 33 +++++++++++++--------------------
> 1 file changed, 13 insertions(+), 20 deletions(-)
>
> diff --git a/Detail.c b/Detail.c
> index 57ac336f..92affdc6 100644
> --- a/Detail.c
> +++ b/Detail.c
> @@ -226,6 +226,9 @@ int Detail(char *dev, struct context *c)
> str = map_num(pers, array.level);
>
> if (c->export) {
> + char nbuf[64];
> + struct map_ent *mp = NULL, *map = NULL;
> +
> if (array.raid_disks) {
> if (str)
> printf("MD_LEVEL=%s\n", str);
> @@ -247,32 +250,22 @@ int Detail(char *dev, struct context *c)
> array.minor_version);
> }
>
> - if (st && st->sb && info) {
> - char nbuf[64];
> - struct map_ent *mp, *map = NULL;
> -
> - fname_from_uuid(st, info, nbuf, ':');
> - printf("MD_UUID=%s\n", nbuf + 5);
> + if (info)
> mp = map_by_uuid(&map, info->uuid);
> + if (!mp)
> + mp = map_by_devnm(&map, fd2devnm(fd));
>
> - if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
> + if (mp) {
> + __fname_from_uuid(mp->uuid, 0, nbuf, ':');
> + printf("MD_UUID=%s\n", nbuf + 5);
> + if (mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
> printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN);
> + }
>
> + map_free(map);
> + if (st && st->sb) {
> if (st->ss->export_detail_super)
> st->ss->export_detail_super(st);
> - map_free(map);
> - } else {
> - struct map_ent *mp, *map = NULL;
> - char nbuf[64];
> - mp = map_by_devnm(&map, fd2devnm(fd));
> - if (mp) {
> - __fname_from_uuid(mp->uuid, 0, nbuf, ':');
> - printf("MD_UUID=%s\n", nbuf+5);
> - }
> - if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
> - printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN);
> -
> - map_free(map);
> }
> if (!c->no_devices && sra) {
> struct mdinfo *mdi;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Detail: remove duplicated code
2024-02-27 13:44 ` Paul Menzel
@ 2024-02-27 14:44 ` Kinga Tanska
0 siblings, 0 replies; 3+ messages in thread
From: Kinga Tanska @ 2024-02-27 14:44 UTC (permalink / raw)
To: Paul Menzel; +Cc: Kinga Tanska, linux-raid, jes, mariusz.tkaczyk
On Tue, 27 Feb 2024 14:44:59 +0100
Paul Menzel <pmenzel@molgen.mpg.de> wrote:
> Dear Kinga,
>
>
> Thank you for your patch.
>
> Am 27.02.24 um 07:36 schrieb Kinga Tanska:
> > Remove duplicated code from Detail(), where MD_UUID
> > and MD_DEVNAME are being set. Superblock is no longer
> > required to print system properties. Now it tries to
> > obtain map in two ways.
>
> Do you have the commit removing the requirement handy? If so, please
> add it.
>
> It’d be great if you used 72 characters per line, so less lines are
> used.
>
>
> Kind regards,
>
> Paul
>
>
> > Signed-off-by: Kinga Tanska <kinga.tanska@intel.com>
> > ---
> > Detail.c | 33 +++++++++++++--------------------
> > 1 file changed, 13 insertions(+), 20 deletions(-)
> >
> > diff --git a/Detail.c b/Detail.c
> > index 57ac336f..92affdc6 100644
> > --- a/Detail.c
> > +++ b/Detail.c
> > @@ -226,6 +226,9 @@ int Detail(char *dev, struct context *c)
> > str = map_num(pers, array.level);
> >
> > if (c->export) {
> > + char nbuf[64];
> > + struct map_ent *mp = NULL, *map = NULL;
> > +
> > if (array.raid_disks) {
> > if (str)
> > printf("MD_LEVEL=%s\n", str);
> > @@ -247,32 +250,22 @@ int Detail(char *dev, struct context *c)
> > array.minor_version);
> > }
> >
> > - if (st && st->sb && info) {
> > - char nbuf[64];
> > - struct map_ent *mp, *map = NULL;
> > -
> > - fname_from_uuid(st, info, nbuf, ':');
> > - printf("MD_UUID=%s\n", nbuf + 5);
> > + if (info)
> > mp = map_by_uuid(&map, info->uuid);
> > + if (!mp)
> > + mp = map_by_devnm(&map, fd2devnm(fd));
> >
> > - if (mp && mp->path && strncmp(mp->path,
> > DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
> > + if (mp) {
> > + __fname_from_uuid(mp->uuid, 0, nbuf, ':');
> > + printf("MD_UUID=%s\n", nbuf + 5);
> > + if (mp->path && strncmp(mp->path,
> > DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) printf("MD_DEVNAME=%s\n",
> > mp->path + DEV_MD_DIR_LEN);
> > + }
> >
> > + map_free(map);
> > + if (st && st->sb) {
> > if (st->ss->export_detail_super)
> > st->ss->export_detail_super(st);
> > - map_free(map);
> > - } else {
> > - struct map_ent *mp, *map = NULL;
> > - char nbuf[64];
> > - mp = map_by_devnm(&map, fd2devnm(fd));
> > - if (mp) {
> > - __fname_from_uuid(mp->uuid, 0,
> > nbuf, ':');
> > - printf("MD_UUID=%s\n", nbuf+5);
> > - }
> > - if (mp && mp->path && strncmp(mp->path,
> > DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
> > - printf("MD_DEVNAME=%s\n", mp->path
> > + DEV_MD_DIR_LEN); -
> > - map_free(map);
> > }
> > if (!c->no_devices && sra) {
> > struct mdinfo *mdi;
>
Hi Paul,
I don't have commit which removes this requirement. This fix is based
on my findings. In previous version superblock was required to find map
by uuid and fill all of the properties. Sometimes map was not found,
which was caused by some time race or custom settings (for example when
using IMSM_DEVNAME_AS_SERIAL flag. That's why I've added another try to
obtain map using devname.
I've already sent v2 with description updated.
Regards,
Kinga
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-27 14:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-27 6:36 [PATCH] Detail: remove duplicated code Kinga Tanska
2024-02-27 13:44 ` Paul Menzel
2024-02-27 14:44 ` Kinga Tanska
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).