diff mbox series

[1/2] tst_device: Print info about acquiring device

Message ID 20240527202858.350200-1-pvorel@suse.cz
State New
Headers show
Series [1/2] tst_device: Print info about acquiring device | expand

Commit Message

Petr Vorel May 27, 2024, 8:28 p.m. UTC
Print how much space is being acquired. Also print hint on ENOSPC.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/tst_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andrea Cervesato May 28, 2024, 6:03 a.m. UTC | #1
Hi!

Good idea

Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>

On 5/27/24 22:28, Petr Vorel wrote:
> Print how much space is being acquired. Also print hint on ENOSPC.
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>   lib/tst_device.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/tst_device.c b/lib/tst_device.c
> index d659b54cf..635b39d08 100644
> --- a/lib/tst_device.c
> +++ b/lib/tst_device.c
> @@ -289,8 +289,10 @@ const char *tst_acquire_loop_device(unsigned int size, const char *filename)
>   {
>   	unsigned int acq_dev_size = size ? size : DEV_SIZE_MB;
>   
> +	tst_resm(TINFO, "Acquiring loop device %u MB", acq_dev_size);
>   	if (tst_prealloc_file(filename, 1024 * 1024, acq_dev_size)) {
> -		tst_resm(TWARN | TERRNO, "Failed to create %s", filename);
> +		tst_resm(TWARN | TERRNO, "Failed to create %s%s", filename,
> +			 errno == ENOSPC ? " (not enough space in $TMPDIR?)" : "");
>   		return NULL;
>   	}
>   

Andrea
Wei Gao May 28, 2024, 7:50 a.m. UTC | #2
On Tue, May 28, 2024 at 08:03:14AM +0200, Andrea Cervesato via ltp wrote:
> Hi!
> 
> Good idea
> 
> Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
  Reviewed-by: Wei Gao <wegao@suse.com>
> 
> On 5/27/24 22:28, Petr Vorel wrote:
> > Print how much space is being acquired. Also print hint on ENOSPC.
> > 
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> >   lib/tst_device.c | 4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/lib/tst_device.c b/lib/tst_device.c
> > index d659b54cf..635b39d08 100644
> > --- a/lib/tst_device.c
> > +++ b/lib/tst_device.c
> > @@ -289,8 +289,10 @@ const char *tst_acquire_loop_device(unsigned int size, const char *filename)
> >   {
> >   	unsigned int acq_dev_size = size ? size : DEV_SIZE_MB;
> > +	tst_resm(TINFO, "Acquiring loop device %u MB", acq_dev_size);
> >   	if (tst_prealloc_file(filename, 1024 * 1024, acq_dev_size)) {
> > -		tst_resm(TWARN | TERRNO, "Failed to create %s", filename);
> > +		tst_resm(TWARN | TERRNO, "Failed to create %s%s", filename,
> > +			 errno == ENOSPC ? " (not enough space in $TMPDIR?)" : "");
> >   		return NULL;
> >   	}
> 
> Andrea
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
Cyril Hrubis May 29, 2024, 3:34 p.m. UTC | #3
Hi!
> +	tst_resm(TINFO, "Acquiring loop device %u MB", acq_dev_size);
                         ^
			 Maybe "Preallocating device size=%uMB" ?

Since we are at the file preallocation step at this point in the code.

>  	if (tst_prealloc_file(filename, 1024 * 1024, acq_dev_size)) {
> -		tst_resm(TWARN | TERRNO, "Failed to create %s", filename);
> +		tst_resm(TWARN | TERRNO, "Failed to create %s%s", filename,
> +			 errno == ENOSPC ? " (not enough space in $TMPDIR?)" : "");

I guess that we could print the $TMPDIR value here as well with:

		tst_resm(TWARN | TERRNO, "Failed to create %s", filename);

		if (errno == ENOSPC)
			tst_resm(TWARN, "Not enough space at '%s'?", tst_get_tmpdir())


This leaks the memory though, that's because the tst_get_tmpdir() is ugly
function from the old library...

>  		return NULL;
>  	}
>  
> -- 
> 2.43.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
diff mbox series

Patch

diff --git a/lib/tst_device.c b/lib/tst_device.c
index d659b54cf..635b39d08 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -289,8 +289,10 @@  const char *tst_acquire_loop_device(unsigned int size, const char *filename)
 {
 	unsigned int acq_dev_size = size ? size : DEV_SIZE_MB;
 
+	tst_resm(TINFO, "Acquiring loop device %u MB", acq_dev_size);
 	if (tst_prealloc_file(filename, 1024 * 1024, acq_dev_size)) {
-		tst_resm(TWARN | TERRNO, "Failed to create %s", filename);
+		tst_resm(TWARN | TERRNO, "Failed to create %s%s", filename,
+			 errno == ENOSPC ? " (not enough space in $TMPDIR?)" : "");
 		return NULL;
 	}