lib: tst_device: Allow more control over the device size
PATCH 1/1 lib: tst_device: Allow more control over the device size
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.
--- lib/tst_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tst_device.c +1 -1
@@ -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" );
Signature · 1 line
2.31.1
PATCH 1/1 lib: tst_device: Allow more control over the device size
Quoted 13 lines · Cyril Hrubis
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.
Quoted 6 lines
Also currently we use the
dev_min_sizeonly to increase the device size for a few tests so this change is safe and cannot break anything.CC Joerg Vehlow <[email protected]>Signed-off-by Cyril Hrubis <[email protected]>
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20210802/b65aa6c5/attachment.htm>
PATCH 1/1 lib: tst_device: Allow more control over the device size
In reply to Cyril HrubisHi Cyril,
Quoted 27 lines · Cyril Hrubis
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_sizeonly to increase the device size for a few tests so this change is safe and cannot break anything.CC Joerg Vehlow <[email protected]>Signed-off-by Cyril Hrubis <[email protected]>--- lib/tst_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/tst_device.c +0
-0
lib/tst_device.c const char *tst_acquire_device__(unsigned int size) · line 306
Quoted 8 lines
lib/tst_device.c +1
-1@@ -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" );
This is not enough. tst_acquire_device__ calls tst_acquire_loop_device, that again has MAX(size, DEV_SIZE_MB).
But it should be sage to substitute it for size ? size : DEV_SIZE_MB as well.
Joerg
PATCH 1/1 lib: tst_device: Allow more control over the device size
Hi!
Quoted 4 lines
This is not enough.
tst_acquire_device__callstst_acquire_loop_device, that again hasMAX(size, DEV_SIZE_MB).
But it should be sage to substitute it for size ? size :DEV_SIZE_MBas well.
Right, that was the old API function to get loop devices which was called from old API testcases. Looks like there are no old API tests that work with loop devices anymore, so this function should be removed from the public API as well. I will send v2 patchset.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 lib: tst_device: Allow more control over the device size
Hi!
Quoted 9 lines
Quoted 4 lines
This is not enough.
tst_acquire_device__callstst_acquire_loop_device, that again hasMAX(size, DEV_SIZE_MB).
But it should be sage to substitute it for size ? size :DEV_SIZE_MBas well.Right, that was the old API function to get loop devices which was called from old API testcases. Looks like there are no old API tests that work with loop devices anymore, so this function should be removed from the public API as well. I will send v2 patchset.
Uff, that was tst_acquire_device_() not tst_acquire_loop_device() and tst_acquire_device_() is still in use.
I'm really looking forward to a day where we can finally remove the old API from the library...
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 lib: tst_device: Allow more control over the device size
Hi,
Quoted 8 lines · Cyril Hrubis
Quoted 8 lines
Quoted 4 lines
This is not enough.
tst_acquire_device__callstst_acquire_loop_device, that again hasMAX(size, DEV_SIZE_MB).
But it should be sage to substitute it for size ? size :DEV_SIZE_MBas well.Right, that was the old API function to get loop devices which was called from old API testcases. Looks like there are no old API tests that work with loop devices anymore, so this function should be removed from the public API as well. I will send v2 patchset.
Quoted 5 lines
Uff, that was
tst_acquire_device_()nottst_acquire_loop_device()andtst_acquire_device_()is still in use.I'm really looking forward to a day where we can finally remove the old API from the library...
The usage of foo foo_ and foo__ does not really help in reading the code :) There could also be some logic errors hiding, e.g. tst_acquire_loop_device should probably not default to DEV_SIZE_MB at all. The caller should be responsible for finding a correct size and the two users of this function (tst_device [the binary] and tst_acquire_device__) do pass a concrete value for size.
Joerg
PATCH 1/1 lib: tst_device: Allow more control over the device size
Hi!
Quoted 6 lines
The usage of foo
foo_andfoo__does not really help in reading the code :) There could also be some logic errors hiding, e.g.tst_acquire_loop_deviceshould probably not default toDEV_SIZE_MBat all. The caller should be responsible for finding a correct size and the two users of this function (tst_device[the binary] andtst_acquire_device__) do pass a concrete value for size.
Actually the tst_device binary does not pass a concrete size unless the shell code that calls it passes an optional parameter, so the fallback to DEV_SIZE_MB if size == 0 has to stay in the double underscore function. I will send a v2 that just replaces the second occurence of MAX() in tst_device.c for now as it looks to me that any singificant cleanup would require complete redesing of the interface and quite possibly rewrite of the last 16 tests that use the old API as a pre-requisite.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 lib: tst_device: Allow more control over the device size
Hi Cyril,
Quoted 7 lines · Cyril Hrubis
Hi!
Quoted 6 lines
The usage of foo
foo_andfoo__does not really help in reading the code :) There could also be some logic errors hiding, e.g.tst_acquire_loop_deviceshould probably not default toDEV_SIZE_MBat all. The caller should be responsible for finding a correct size and the two users of this function (tst_device[the binary] andtst_acquire_device__) do pass a concrete value for size.
Quoted 8 lines
Actually the
tst_devicebinary does not pass a concrete size unless the shell code that calls it passes an optional parameter, so the fallback toDEV_SIZE_MBif size == 0 has to stay in the double underscore function. I will send a v2 that just replaces the second occurence ofMAX()intst_device.cfor now as it looks to me that any singificant cleanup would require complete redesing of the interface and quite possibly rewrite of the last 16 tests that use the old API as a pre-requisite.
I think we maximized confusion.
I was not arguing about the defaulting to DEV_SIZE_MB in the double underscore function, but about the defaulting in the tst_acquire_loop_device function. This function is never called with size=0, because the call is either from the double underscore function, that defaults to DEV_SIZE_MB or from the tst_device binary, that only calls tst_acquire_loop_device if the 3 argument version (tst_device acquire [size [filename]]) is used and size is not allowed to be 0 in that case.
PATCH 1/1 lib: tst_device: Allow more control over the device size
Hi!
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
The usage of foo
foo_andfoo__does not really help in reading the code :) There could also be some logic errors hiding, e.g.tst_acquire_loop_deviceshould probably not default toDEV_SIZE_MBat all. The caller should be responsible for finding a correct size and the two users of this function (tst_device[the binary] andtst_acquire_device__) do pass a concrete value for size.Quoted 8 lines
Actually the
tst_devicebinary does not pass a concrete size unless the shell code that calls it passes an optional parameter, so the fallback toDEV_SIZE_MBif size == 0 has to stay in the double underscore function. I will send a v2 that just replaces the second occurence ofMAX()intst_device.cfor now as it looks to me that any singificant cleanup would require complete redesing of the interface and quite possibly rewrite of the last 16 tests that use the old API as a pre-requisite.
Quoted 9 lines
I think we maximized confusion.
I was not arguing about the defaulting toDEV_SIZE_MBin the double underscore function, but about the defaulting in thetst_acquire_loop_devicefunction. This function is never called with size=0, because the call is either from the double underscore function, that defaults toDEV_SIZE_MBor from thetst_devicebinary, that only callstst_acquire_loop_deviceif the 3 argument version (tst_deviceacquire [size [filename]]) is used and size is not allowed to be 0 in that case.
Well it's true that at the moment all callers pass non-zero size to the tst_device binary but any shell test can pass down 0 to the call in order to get the default size which is large enough for all possible filesystems.
Signature · 2 lines
Cyril Hrubis [email protected]