diff mbox series

[ndctl] libcxl: don't calculate max_available_extent when start == ULLONG_MAX

Message ID 169661181914.694957.3925873284580708486.stgit@bgt-140510-bm03.eng.stellus.in
State Accepted
Commit 4b240d876683181bab5b7aaa0eed7e0a78617362
Headers show
Series [ndctl] libcxl: don't calculate max_available_extent when start == ULLONG_MAX | expand

Commit Message

Jim Harris Oct. 6, 2023, 5:03 p.m. UTC
`cxl list` can be run as non-root, but some sysfs entries such as
decoderX.Y/start are only root-readable. In this case, decoder->start
gets set to ULLONG_MAX and cxl_decoder_max_available_extent() would
try to calculate a size based on the value. This would result in
a value slightly less than ULLONG_MAX which would emit odd (and
obviously incorrect) values for max_available_extent.

If we just return ULLONG_MAX in this case, the max_available_extent
is not emitted which is the desirable behavior in this case. If users
need the value, they can run `cxl list` as root.

Signed-off-by: Jim Harris <jim.harris@samsung.com>
---
 cxl/lib/libcxl.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Jim Harris Oct. 6, 2023, 5:09 p.m. UTC | #1
I see I should have sent “ndctl" as a prefix instead of version. Let me know if
a should send a v2 with the corrected, otherwise I’ll use the prefix next time
around.

> On Oct 6, 2023, at 10:03 AM, Jim Harris <jim.harris@samsung.com> wrote:
Verma, Vishal L Oct. 6, 2023, 5:19 p.m. UTC | #2
On Fri, 2023-10-06 at 17:09 +0000, Jim Harris wrote:
> I see I should have sent “ndctl" as a prefix instead of version. Let me know if
> a should send a v2 with the corrected, otherwise I’ll use the prefix next time
> around.

Hi Jim,

No worries, and no need for a resend - in fact b4-send's prefix
handling also does the same thing - "PATCH ndctl". In pre-b4 days
"ndctl PATCH" was indeed the norm, but I'd rather use b4 and live with
the former, so this is completely fine!
diff mbox series

Patch

diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
index af4ca44..eb9ccf1 100644
--- a/cxl/lib/libcxl.c
+++ b/cxl/lib/libcxl.c
@@ -2002,6 +2002,9 @@  cxl_decoder_calc_max_available_extent(struct cxl_decoder *decoder)
 		return ULLONG_MAX;
 	}
 
+	if (decoder->start == ULLONG_MAX)
+		return ULLONG_MAX;
+
 	/*
 	 * Preload prev_end with an imaginary region that ends just before
 	 * the decoder's start, so that the extent calculation for the