public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] db: limit AGFL bno array printing
@ 2016-05-13  1:40 Dave Chinner
  2016-05-13 10:13 ` Carlos Maiolino
  2016-05-23 14:46 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Dave Chinner @ 2016-05-13  1:40 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

When asking for a single agfl entry such as:

# xfs_db -c "agfl 0" -c "p bno[1]" /dev/ram0
bno[1] = 1:6 2:7 3:8 4:null .....

The result should be just the single entry being asked for.
Currently this outputs the entire remainder of the array starting at
the given index. This makes it difficult to extract single entry
values.

This occurs because the printing of a flat array of number types
does not take into account the range that is specified on the
command line, which is held in fl->low and fl->high. To make this
work for flat arrays of number types (print function fp_num), change
print_flist() to limit the count of values to be emitted to the
range specified. This now gives:

# xfs_db -c "agfl 0" -c "p bno[1-2]" /dev/ram0
bno[1-2] = 1:6 2:7

To further simplify external parsing of single entry values, if only
a single value is requested from the array of fp_num type, don't
print the array index - it's already known. Hence:

# xfs_db -c "agfl 0" -c "p bno[1]" /dev/ram0
bno[1] = 6

This change will take effect on all types of flat number arrays that
are printed. e.g. the range limiting will work for things like the
AGI unlinked list arrays.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 db/fprint.c | 2 +-
 db/print.c  | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/db/fprint.c b/db/fprint.c
index f2b3794..fd7e7f4 100644
--- a/db/fprint.c
+++ b/db/fprint.c
@@ -93,7 +93,7 @@ fp_num(
 			val == -1LL : val == ((1LL << size) - 1LL);
 		if ((arg & FTARG_SKIPNULL) && isnull)
 			continue;
-		if (array)
+		if (array && count > 1)
 			dbprintf("%d:", i + base);
 		if ((arg & FTARG_DONULL) && isnull)
 			dbprintf(_("null"));
diff --git a/db/print.c b/db/print.c
index 3ff2548..998daf4 100644
--- a/db/print.c
+++ b/db/print.c
@@ -107,6 +107,7 @@ print_flist_1(
 	const ftattr_t	*fa;
 	flist_t		*fl;
 	int		low;
+	int		count;
 	int		neednl;
 	char		**pfx;
 
@@ -139,10 +140,12 @@ print_flist_1(
 				low = fl->low;
 			else
 				low = 0;
+			count = fcount(f, iocur_top->data, parentoff);
+			if (fl->flags & FL_OKHIGH)
+				count = min(count, fl->high - low + 1);
 			if (fa->prfunc) {
 				neednl = fa->prfunc(iocur_top->data, fl->offset,
-					fcount(f, iocur_top->data, parentoff),
-					fa->fmtstr,
+					count, fa->fmtstr,
 					fsize(f, iocur_top->data, parentoff, 0),
 					fa->arg, low,
 					(f->flags & FLD_ARRAY) != 0);
-- 
2.8.0.rc3

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH] db: limit AGFL bno array printing
  2016-05-13  1:40 [PATCH] db: limit AGFL bno array printing Dave Chinner
@ 2016-05-13 10:13 ` Carlos Maiolino
  2016-05-23 14:46 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Carlos Maiolino @ 2016-05-13 10:13 UTC (permalink / raw)
  To: xfs

On Fri, May 13, 2016 at 11:40:03AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> When asking for a single agfl entry such as:

Looks good to me, feel free to add

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> 
> # xfs_db -c "agfl 0" -c "p bno[1]" /dev/ram0
> bno[1] = 1:6 2:7 3:8 4:null .....
> 
> The result should be just the single entry being asked for.
> Currently this outputs the entire remainder of the array starting at
> the given index. This makes it difficult to extract single entry
> values.
> 
> This occurs because the printing of a flat array of number types
> does not take into account the range that is specified on the
> command line, which is held in fl->low and fl->high. To make this
> work for flat arrays of number types (print function fp_num), change
> print_flist() to limit the count of values to be emitted to the
> range specified. This now gives:
> 
> # xfs_db -c "agfl 0" -c "p bno[1-2]" /dev/ram0
> bno[1-2] = 1:6 2:7
> 
> To further simplify external parsing of single entry values, if only
> a single value is requested from the array of fp_num type, don't
> print the array index - it's already known. Hence:
> 
> # xfs_db -c "agfl 0" -c "p bno[1]" /dev/ram0
> bno[1] = 6
> 
> This change will take effect on all types of flat number arrays that
> are printed. e.g. the range limiting will work for things like the
> AGI unlinked list arrays.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  db/fprint.c | 2 +-
>  db/print.c  | 7 +++++--
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/db/fprint.c b/db/fprint.c
> index f2b3794..fd7e7f4 100644
> --- a/db/fprint.c
> +++ b/db/fprint.c
> @@ -93,7 +93,7 @@ fp_num(
>  			val == -1LL : val == ((1LL << size) - 1LL);
>  		if ((arg & FTARG_SKIPNULL) && isnull)
>  			continue;
> -		if (array)
> +		if (array && count > 1)
>  			dbprintf("%d:", i + base);
>  		if ((arg & FTARG_DONULL) && isnull)
>  			dbprintf(_("null"));
> diff --git a/db/print.c b/db/print.c
> index 3ff2548..998daf4 100644
> --- a/db/print.c
> +++ b/db/print.c
> @@ -107,6 +107,7 @@ print_flist_1(
>  	const ftattr_t	*fa;
>  	flist_t		*fl;
>  	int		low;
> +	int		count;
>  	int		neednl;
>  	char		**pfx;
>  
> @@ -139,10 +140,12 @@ print_flist_1(
>  				low = fl->low;
>  			else
>  				low = 0;
> +			count = fcount(f, iocur_top->data, parentoff);
> +			if (fl->flags & FL_OKHIGH)
> +				count = min(count, fl->high - low + 1);
>  			if (fa->prfunc) {
>  				neednl = fa->prfunc(iocur_top->data, fl->offset,
> -					fcount(f, iocur_top->data, parentoff),
> -					fa->fmtstr,
> +					count, fa->fmtstr,
>  					fsize(f, iocur_top->data, parentoff, 0),
>  					fa->arg, low,
>  					(f->flags & FLD_ARRAY) != 0);
> -- 
> 2.8.0.rc3
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

-- 
Carlos

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH] db: limit AGFL bno array printing
  2016-05-13  1:40 [PATCH] db: limit AGFL bno array printing Dave Chinner
  2016-05-13 10:13 ` Carlos Maiolino
@ 2016-05-23 14:46 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2016-05-23 14:46 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2016-05-23 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-13  1:40 [PATCH] db: limit AGFL bno array printing Dave Chinner
2016-05-13 10:13 ` Carlos Maiolino
2016-05-23 14:46 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox