[LTP] [PATCH v4 2/4] zram/zram_lib.sh: adapt the situation that zram device is being used

Petr Vorel pvorel@suse.cz
Fri Dec 17 08:48:08 CET 2021


Hi Xu,

> If zram-generator package is installed and works, then we can not remove zram module
> because zram swap is being used. This case needs a clean zram environment, change this
> test by using hot_add/hot_remove interface[1]. So even zram device is being used, we
> still can add zram device and remove them in cleanup.

BTW this was added in v4.2-rc1 (6 years ago, 6566d1a32bf7 ("zram: add dynamic
device add/remove functionality")). Hopefully anybody still supporting older
kernels is using old LTP for it.

> Also, zram01,02 case are adjuested to adapt the situation that CONFIG_ZRAM=y.
Very nice, thanks!

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

> 1]https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html#add-remove-zram-devices
nit: [1] https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html#add-remove-zram-devices

...
> -	modprobe zram num_devices=$dev_num || \
> -		tst_brk TBROK "failed to insert zram module"
> +	if [ ! -d "/sys/class/zram-control" ]; then
> +		modprobe zram num_devices=$dev_num
> +		module_load=1
> +		dev_start=0
> +		dev_end=$(($dev_num - 1))
> +		tst_res TPASS "all zram devices(/dev/zram0~$dev_end) successfully created"
nit: please all zram devices (/dev/zram0~$dev_end) ... (add space after devices)
> +		return
> +	fi

> -	dev_num_created=$(ls /dev/zram* | wc -w)
> +	dev_start=$(ls /dev/zram* | wc -w)
> +	dev_end=$(($dev_start + $dev_num - 1))

> -	if [ "$dev_num_created" -ne "$dev_num" ]; then
> -		tst_brk TFAIL "unexpected num of devices: $dev_num_created"
> -	fi
> +	for i in $(seq  $dev_start $dev_end); do
> +		cat /sys/class/zram-control/hot_add > /dev/null
> +	done

> -	tst_res TPASS "all zram devices successfully created"
> +	tst_res TPASS "all zram devices(/dev/zram$dev_start~$dev_end) successfully created"
and here.

Kind regards,
Petr


More information about the ltp mailing list