All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] lib: tst_device: Allow more control over the device size
@ 2021-08-02 12:17 Cyril Hrubis
  2021-08-02 16:35 ` Petr Vorel
  2021-08-03  4:56 ` Joerg Vehlow
  0 siblings, 2 replies; 4+ messages in thread
From: Cyril Hrubis @ 2021-08-02 12:17 UTC (permalink / raw)
  To: ltp

There is actually no reason for lower limit on the device size, and we
can safely allow the tests to request smaller device than the default
hardcoded in the library. The backing file is preallocated without
actually writing to it as long as the underlying filesystem supports it
so the speedup will be minimal if measurable but we will at least spare
some space which needs to be reserved on the filesystem which is still a
good thing.

The test may end up with a device that is bigger than the requsted size
in a case that a real device was passed to the LTP for the testrun.  So
tests should be able to cope with that and that's also the reason why
the turning knob is still called dev_min_size.

Also currently we use the dev_min_size only to increase the device size
for a few tests so this change is safe and cannot break anything.

CC: Joerg Vehlow <lkml@jv-coder.de>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---

v2: Updated both places where we compute the device size as pointed out
    by Joerg

 lib/tst_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/tst_device.c b/lib/tst_device.c
index c91c6cd55..73e70d26e 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -278,7 +278,7 @@ int tst_dev_sync(int fd)
 
 const char *tst_acquire_loop_device(unsigned int size, const char *filename)
 {
-	unsigned int acq_dev_size = MAX(size, DEV_SIZE_MB);
+	unsigned int acq_dev_size = size ? size : DEV_SIZE_MB;
 
 	if (tst_prealloc_file(filename, 1024 * 1024, acq_dev_size)) {
 		tst_resm(TWARN | TERRNO, "Failed to create %s", filename);
@@ -300,7 +300,7 @@ const char *tst_acquire_device__(unsigned int size)
 	unsigned int acq_dev_size;
 	uint64_t ltp_dev_size;
 
-	acq_dev_size = MAX(size, DEV_SIZE_MB);
+	acq_dev_size = size ? size : DEV_SIZE_MB;
 
 	dev = getenv("LTP_DEV");
 
-- 
2.31.1


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

* [LTP] [PATCH v2] lib: tst_device: Allow more control over the device size
  2021-08-02 12:17 [LTP] [PATCH v2] lib: tst_device: Allow more control over the device size Cyril Hrubis
@ 2021-08-02 16:35 ` Petr Vorel
  2021-08-03  4:56 ` Joerg Vehlow
  1 sibling, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2021-08-02 16:35 UTC (permalink / raw)
  To: ltp

Hi Cyril, Joerg,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

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

* [LTP] [PATCH v2] lib: tst_device: Allow more control over the device size
  2021-08-02 12:17 [LTP] [PATCH v2] lib: tst_device: Allow more control over the device size Cyril Hrubis
  2021-08-02 16:35 ` Petr Vorel
@ 2021-08-03  4:56 ` Joerg Vehlow
  2021-08-04 10:01   ` Cyril Hrubis
  1 sibling, 1 reply; 4+ messages in thread
From: Joerg Vehlow @ 2021-08-03  4:56 UTC (permalink / raw)
  To: ltp

Hi Cyril,

On 8/2/2021 2:17 PM, Cyril Hrubis wrote:
> There is actually no reason for lower limit on the device size, and we
> can safely allow the tests to request smaller device than the default
> hardcoded in the library. The backing file is preallocated without
> actually writing to it as long as the underlying filesystem supports it
> so the speedup will be minimal if measurable but we will at least spare
> some space which needs to be reserved on the filesystem which is still a
> good thing.
>
> The test may end up with a device that is bigger than the requsted size
> in a case that a real device was passed to the LTP for the testrun.  So
> tests should be able to cope with that and that's also the reason why
> the turning knob is still called dev_min_size.
>
> Also currently we use the dev_min_size only to increase the device size
> for a few tests so this change is safe and cannot break anything.
>
> CC: Joerg Vehlow <lkml@jv-coder.de>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>
> v2: Updated both places where we compute the device size as pointed out
>      by Joerg
>
>   lib/tst_device.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/tst_device.c b/lib/tst_device.c
> index c91c6cd55..73e70d26e 100644
> --- a/lib/tst_device.c
> +++ b/lib/tst_device.c
> @@ -278,7 +278,7 @@ int tst_dev_sync(int fd)
>   
>   const char *tst_acquire_loop_device(unsigned int size, const char *filename)
>   {
> -	unsigned int acq_dev_size = MAX(size, DEV_SIZE_MB);
> +	unsigned int acq_dev_size = size ? size : DEV_SIZE_MB;
>   
>   	if (tst_prealloc_file(filename, 1024 * 1024, acq_dev_size)) {
>   		tst_resm(TWARN | TERRNO, "Failed to create %s", filename);
> @@ -300,7 +300,7 @@ const char *tst_acquire_device__(unsigned int size)
>   	unsigned int acq_dev_size;
>   	uint64_t ltp_dev_size;
>   
> -	acq_dev_size = MAX(size, DEV_SIZE_MB);
> +	acq_dev_size = size ? size : DEV_SIZE_MB;
>   
>   	dev = getenv("LTP_DEV");
>   

Thanks, looks good now. Tested with the squashfs test.

Joerg

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

* [LTP] [PATCH v2] lib: tst_device: Allow more control over the device size
  2021-08-03  4:56 ` Joerg Vehlow
@ 2021-08-04 10:01   ` Cyril Hrubis
  0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2021-08-04 10:01 UTC (permalink / raw)
  To: ltp

Hi!
> Thanks, looks good now. Tested with the squashfs test.

Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2021-08-04 10:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 12:17 [LTP] [PATCH v2] lib: tst_device: Allow more control over the device size Cyril Hrubis
2021-08-02 16:35 ` Petr Vorel
2021-08-03  4:56 ` Joerg Vehlow
2021-08-04 10:01   ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.