[LTP] [PATCH] mkswap: make the test device size is aligned to pagesize
Li Wang
liwang@redhat.com
Thu Aug 18 13:08:22 CEST 2016
On Wed, Aug 17, 2016 at 01:18:41PM +0200, Cyril Hrubis wrote:
> Hi!
> > > Now that makes sense.
> > >
> > > But if that is the case we still have to align down the device size to
> > > the page size at the start of the test. Since the device can also be
> > > passed down to the runltp script as a parameter and we cannot make any
> > > assumptions about its size.
> >
> > Hmm, yes, we have to face the problem.
> >
> > A simple idea comes to my mind is that the loop device size should be
> > customized by specific testcase(mkswap01.sh).
> >
> > That would be happy if function "tst_acquire_device() 'NUM'" can get
> > 'NUM' MB block device for testing.
> >
> > It means we have to modify another path which about tst_acquire_device().
>
> This is a bad idea for two reasons.
>
> Fist one is that the reason the user passed block device to runltp may
> be that the kernel does not support loop devices. In this case the test
> would be skipped for no good reason.
>
> The second is that there is another patch in flight that aims to add
> minimal size parameter to the tst_acquire_device(). Which is much more
> useful.
>
> Why cannot we just simply take the size of the device at start of the
> test, align it down to be the multiple of $PAGE_SIZE and use that as the
> size for testing?
Ok, this sounds better. I misunderstand you point at first.
As this we can get the right(aligned) size of the device by add:
# cat mkswap01.sh
...
setup()
{
...
# Here get the size of the device and align it down to be the
# multiple of $PAGE_SIZE and use that as the size for testing.
device_real=`blockdev --getsize64 $TST_DEVICE`
device_resi=$((${device_real} % ${PAGE_SIZE}))
DEVICE_SIZE=$(((${device_real} - ${device_resi})/1024))
}
Am I right now?
Regards,
Li Wang
More information about the ltp
mailing list