linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
* [linux-lvm] [PATCH] lvdisplay: dispaly partial when underlying devs missing
@ 2020-08-19  4:15 Zhao Heming
  2020-08-19  4:39 ` heming.zhao
  0 siblings, 1 reply; 2+ messages in thread
From: Zhao Heming @ 2020-08-19  4:15 UTC (permalink / raw)
  To: linux-lvm; +Cc: Zhao Heming

After removing LV underlying dev, lvdisplay still display 'available'.

With this patch, lvdisplay will show
from:
  LV Status              available
to:
  LV Status              NOT available (partial)

reproducible steps:
1. vgcreate vg1 /dev/sda /dev/sdb
2. lvcreate --type raid0 -l 100%FREE -n raid0lv vg1
3. do remove the /dev/sdb action
4. lvdisplay show wrong 'LV Status'

Signed-off-by: Zhao Heming <heming.zhao@suse.com>
---
 lib/display/display.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/display/display.c b/lib/display/display.c
index 36c9879b3..6c895c820 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -399,7 +399,7 @@ int lvdisplay_full(struct cmd_context *cmd,
 		   void *handle __attribute__((unused)))
 {
 	struct lvinfo info;
-	int inkernel, snap_active = 0;
+	int inkernel, snap_active = 0, partial = 0;
 	char uuid[64] __attribute__((aligned(8)));
 	const char *access_str;
 	struct lv_segment *snap_seg = NULL, *mirror_seg = NULL;
@@ -555,9 +555,13 @@ int lvdisplay_full(struct cmd_context *cmd,
 
 	if (inkernel && info.suspended)
 		log_print("LV Status              suspended");
-	else if (activation())
-		log_print("LV Status              %savailable",
-			  inkernel ? "" : "NOT ");
+	else if (activation()) {
+		if (lv->status & PARTIAL_LV)
+			partial = 1;
+		log_print("LV Status              %savailable %s",
+			  (inkernel && !partial) ? "" : "NOT ",
+			  partial ? "(partial)" : "");
+	}
 
 /********* FIXME lv_number
     log_print("LV #                   %u", lv->lv_number + 1);
-- 
2.27.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [linux-lvm] [PATCH] lvdisplay: dispaly partial when underlying devs missing
  2020-08-19  4:15 [linux-lvm] [PATCH] lvdisplay: dispaly partial when underlying devs missing Zhao Heming
@ 2020-08-19  4:39 ` heming.zhao
  0 siblings, 0 replies; 2+ messages in thread
From: heming.zhao @ 2020-08-19  4:39 UTC (permalink / raw)
  To: linux-lvm

I'm not sure whether in any case one of the LV underlying dev missing must think as 'not available (partial)'.
if a LV contains 10 PVs, and the rear PVs haven't be used. in this case display 'available (partial)' looks better
than 'not available (partial)'. but anyway, the 'partial' should be displayed.

On 8/19/20 12:15 PM, Zhao Heming wrote:
> After removing LV underlying dev, lvdisplay still display 'available'.
> 
> With this patch, lvdisplay will show
> from:
>    LV Status              available
> to:
>    LV Status              NOT available (partial)
> 
> reproducible steps:
> 1. vgcreate vg1 /dev/sda /dev/sdb
> 2. lvcreate --type raid0 -l 100%FREE -n raid0lv vg1
> 3. do remove the /dev/sdb action
> 4. lvdisplay show wrong 'LV Status'
> 
> Signed-off-by: Zhao Heming <heming.zhao@suse.com>
> ---
>   lib/display/display.c | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/display/display.c b/lib/display/display.c
> index 36c9879b3..6c895c820 100644
> --- a/lib/display/display.c
> +++ b/lib/display/display.c
> @@ -399,7 +399,7 @@ int lvdisplay_full(struct cmd_context *cmd,
>   		   void *handle __attribute__((unused)))
>   {
>   	struct lvinfo info;
> -	int inkernel, snap_active = 0;
> +	int inkernel, snap_active = 0, partial = 0;
>   	char uuid[64] __attribute__((aligned(8)));
>   	const char *access_str;
>   	struct lv_segment *snap_seg = NULL, *mirror_seg = NULL;
> @@ -555,9 +555,13 @@ int lvdisplay_full(struct cmd_context *cmd,
>   
>   	if (inkernel && info.suspended)
>   		log_print("LV Status              suspended");
> -	else if (activation())
> -		log_print("LV Status              %savailable",
> -			  inkernel ? "" : "NOT ");
> +	else if (activation()) {
> +		if (lv->status & PARTIAL_LV)
> +			partial = 1;
> +		log_print("LV Status              %savailable %s",
> +			  (inkernel && !partial) ? "" : "NOT ",
> +			  partial ? "(partial)" : "");
> +	}
>   
>   /********* FIXME lv_number
>       log_print("LV #                   %u", lv->lv_number + 1);
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-19  4:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19  4:15 [linux-lvm] [PATCH] lvdisplay: dispaly partial when underlying devs missing Zhao Heming
2020-08-19  4:39 ` heming.zhao

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).