diff mbox series

[v2,1/2] common/dmlogwrites: Extend _log_writes_init() to accept the specified length

Message ID 1668414903-13-1-git-send-email-yangx.jy@fujitsu.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/2] common/dmlogwrites: Extend _log_writes_init() to accept the specified length | expand

Commit Message

Xiao Yang Nov. 14, 2022, 8:35 a.m. UTC
It is unnecssary to always create a dm-log-writes device
based on the entire size of the target/underlying device.

Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
---
 common/dmlogwrites | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

Comments

Zorro Lang Nov. 14, 2022, 2:56 p.m. UTC | #1
On Mon, Nov 14, 2022 at 08:35:02AM +0000, Xiao Yang wrote:
> It is unnecssary to always create a dm-log-writes device
> based on the entire size of the target/underlying device.
> 
> Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
> ---

Darrick has given his RVB [1]:

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

I think you can keep it in this V2 patch.

Thanks,
Zorro

[1]
https://lore.kernel.org/fstests/Y3EvUgtux4tP1tdY@magnolia/T/#m83b97790ba6570874f36cd0601747e1b6b155de2

>  common/dmlogwrites | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/common/dmlogwrites b/common/dmlogwrites
> index 9fa1c977..c1c85de9 100644
> --- a/common/dmlogwrites
> +++ b/common/dmlogwrites
> @@ -59,14 +59,28 @@ _require_log_writes_dax_mountopt()
>  	fi
>  }
>  
> +# Set up a dm-log-writes device
> +#
> +# blkdev: the specified target device
> +# length(optional): the mapped length in bytes
> +# Note that the entire size of the target device will be used
> +# if length is not specified.
>  _log_writes_init()
>  {
> -	blkdev=$1
> +	local blkdev=$1
> +	local length=$2
> +	local BLK_DEV_SIZE
>  
>  	[ -z "$blkdev" ] && _fail \
>  	"block dev must be specified for _log_writes_init"
>  
> -	local BLK_DEV_SIZE=`blockdev --getsz $blkdev`
> +	if [ -z "$length" ]; then
> +		BLK_DEV_SIZE=`blockdev --getsz $blkdev`
> +	else
> +		local blksz=`blockdev --getss $blkdev`
> +		BLK_DEV_SIZE=$((length / blksz))
> +	fi
> +
>  	LOGWRITES_NAME=logwrites-test
>  	LOGWRITES_DMDEV=/dev/mapper/$LOGWRITES_NAME
>  	LOGWRITES_TABLE="0 $BLK_DEV_SIZE log-writes $blkdev $LOGWRITES_DEV"
> -- 
> 2.34.1
>
Darrick J. Wong Nov. 14, 2022, 7:19 p.m. UTC | #2
On Mon, Nov 14, 2022 at 08:35:02AM +0000, Xiao Yang wrote:
> It is unnecssary to always create a dm-log-writes device
> based on the entire size of the target/underlying device.
> 
> Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  common/dmlogwrites | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/common/dmlogwrites b/common/dmlogwrites
> index 9fa1c977..c1c85de9 100644
> --- a/common/dmlogwrites
> +++ b/common/dmlogwrites
> @@ -59,14 +59,28 @@ _require_log_writes_dax_mountopt()
>  	fi
>  }
>  
> +# Set up a dm-log-writes device
> +#
> +# blkdev: the specified target device
> +# length(optional): the mapped length in bytes
> +# Note that the entire size of the target device will be used
> +# if length is not specified.
>  _log_writes_init()
>  {
> -	blkdev=$1
> +	local blkdev=$1
> +	local length=$2
> +	local BLK_DEV_SIZE
>  
>  	[ -z "$blkdev" ] && _fail \
>  	"block dev must be specified for _log_writes_init"
>  
> -	local BLK_DEV_SIZE=`blockdev --getsz $blkdev`
> +	if [ -z "$length" ]; then
> +		BLK_DEV_SIZE=`blockdev --getsz $blkdev`
> +	else
> +		local blksz=`blockdev --getss $blkdev`
> +		BLK_DEV_SIZE=$((length / blksz))
> +	fi
> +
>  	LOGWRITES_NAME=logwrites-test
>  	LOGWRITES_DMDEV=/dev/mapper/$LOGWRITES_NAME
>  	LOGWRITES_TABLE="0 $BLK_DEV_SIZE log-writes $blkdev $LOGWRITES_DEV"
> -- 
> 2.34.1
>
Xiao Yang Nov. 15, 2022, 7:05 a.m. UTC | #3
On 2022/11/14 22:56, Zorro Lang wrote:
> On Mon, Nov 14, 2022 at 08:35:02AM +0000, Xiao Yang wrote:
>> It is unnecssary to always create a dm-log-writes device
>> based on the entire size of the target/underlying device.
>>
>> Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
>> ---
> 
> Darrick has given his RVB [1]:
> 
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> 
> I think you can keep it in this V2 patch.

Hi Zorro,

Thanks for your reminder.

As Darrick suggested, I actually added a comment to explain the blkdev 
and length arguments. So I hope Darrick can review it again.

Fortunately, Darrick has added reviewed-by on the v2 patch set. ^_^

Best Regards,
Xiao Yang
> 
> Thanks,
> Zorro
> 
> [1]
> https://lore.kernel.org/fstests/Y3EvUgtux4tP1tdY@magnolia/T/#m83b97790ba6570874f36cd0601747e1b6b155de2
> 
>>   common/dmlogwrites | 18 ++++++++++++++++--
>>   1 file changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/common/dmlogwrites b/common/dmlogwrites
>> index 9fa1c977..c1c85de9 100644
>> --- a/common/dmlogwrites
>> +++ b/common/dmlogwrites
>> @@ -59,14 +59,28 @@ _require_log_writes_dax_mountopt()
>>   	fi
>>   }
>>   
>> +# Set up a dm-log-writes device
>> +#
>> +# blkdev: the specified target device
>> +# length(optional): the mapped length in bytes
>> +# Note that the entire size of the target device will be used
>> +# if length is not specified.
>>   _log_writes_init()
>>   {
>> -	blkdev=$1
>> +	local blkdev=$1
>> +	local length=$2
>> +	local BLK_DEV_SIZE
>>   
>>   	[ -z "$blkdev" ] && _fail \
>>   	"block dev must be specified for _log_writes_init"
>>   
>> -	local BLK_DEV_SIZE=`blockdev --getsz $blkdev`
>> +	if [ -z "$length" ]; then
>> +		BLK_DEV_SIZE=`blockdev --getsz $blkdev`
>> +	else
>> +		local blksz=`blockdev --getss $blkdev`
>> +		BLK_DEV_SIZE=$((length / blksz))
>> +	fi
>> +
>>   	LOGWRITES_NAME=logwrites-test
>>   	LOGWRITES_DMDEV=/dev/mapper/$LOGWRITES_NAME
>>   	LOGWRITES_TABLE="0 $BLK_DEV_SIZE log-writes $blkdev $LOGWRITES_DEV"
>> -- 
>> 2.34.1
>>
>
Zorro Lang Nov. 15, 2022, 10:29 a.m. UTC | #4
On Tue, Nov 15, 2022 at 03:05:10PM +0800, Yang, Xiao/杨 晓 wrote:
> On 2022/11/14 22:56, Zorro Lang wrote:
> > On Mon, Nov 14, 2022 at 08:35:02AM +0000, Xiao Yang wrote:
> > > It is unnecssary to always create a dm-log-writes device
> > > based on the entire size of the target/underlying device.
> > > 
> > > Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
> > > ---
> > 
> > Darrick has given his RVB [1]:
> > 
> > Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> > 
> > I think you can keep it in this V2 patch.
> 
> Hi Zorro,
> 
> Thanks for your reminder.

np, I've tested and merged this patchset, and will push this weekend.

Thanks,
Zorro

> 
> As Darrick suggested, I actually added a comment to explain the blkdev and
> length arguments. So I hope Darrick can review it again.
> 
> Fortunately, Darrick has added reviewed-by on the v2 patch set. ^_^
> 
> Best Regards,
> Xiao Yang
> > 
> > Thanks,
> > Zorro
> > 
> > [1]
> > https://lore.kernel.org/fstests/Y3EvUgtux4tP1tdY@magnolia/T/#m83b97790ba6570874f36cd0601747e1b6b155de2
> > 
> > >   common/dmlogwrites | 18 ++++++++++++++++--
> > >   1 file changed, 16 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/common/dmlogwrites b/common/dmlogwrites
> > > index 9fa1c977..c1c85de9 100644
> > > --- a/common/dmlogwrites
> > > +++ b/common/dmlogwrites
> > > @@ -59,14 +59,28 @@ _require_log_writes_dax_mountopt()
> > >   	fi
> > >   }
> > > +# Set up a dm-log-writes device
> > > +#
> > > +# blkdev: the specified target device
> > > +# length(optional): the mapped length in bytes
> > > +# Note that the entire size of the target device will be used
> > > +# if length is not specified.
> > >   _log_writes_init()
> > >   {
> > > -	blkdev=$1
> > > +	local blkdev=$1
> > > +	local length=$2
> > > +	local BLK_DEV_SIZE
> > >   	[ -z "$blkdev" ] && _fail \
> > >   	"block dev must be specified for _log_writes_init"
> > > -	local BLK_DEV_SIZE=`blockdev --getsz $blkdev`
> > > +	if [ -z "$length" ]; then
> > > +		BLK_DEV_SIZE=`blockdev --getsz $blkdev`
> > > +	else
> > > +		local blksz=`blockdev --getss $blkdev`
> > > +		BLK_DEV_SIZE=$((length / blksz))
> > > +	fi
> > > +
> > >   	LOGWRITES_NAME=logwrites-test
> > >   	LOGWRITES_DMDEV=/dev/mapper/$LOGWRITES_NAME
> > >   	LOGWRITES_TABLE="0 $BLK_DEV_SIZE log-writes $blkdev $LOGWRITES_DEV"
> > > -- 
> > > 2.34.1
> > > 
> > 
>
diff mbox series

Patch

diff --git a/common/dmlogwrites b/common/dmlogwrites
index 9fa1c977..c1c85de9 100644
--- a/common/dmlogwrites
+++ b/common/dmlogwrites
@@ -59,14 +59,28 @@  _require_log_writes_dax_mountopt()
 	fi
 }
 
+# Set up a dm-log-writes device
+#
+# blkdev: the specified target device
+# length(optional): the mapped length in bytes
+# Note that the entire size of the target device will be used
+# if length is not specified.
 _log_writes_init()
 {
-	blkdev=$1
+	local blkdev=$1
+	local length=$2
+	local BLK_DEV_SIZE
 
 	[ -z "$blkdev" ] && _fail \
 	"block dev must be specified for _log_writes_init"
 
-	local BLK_DEV_SIZE=`blockdev --getsz $blkdev`
+	if [ -z "$length" ]; then
+		BLK_DEV_SIZE=`blockdev --getsz $blkdev`
+	else
+		local blksz=`blockdev --getss $blkdev`
+		BLK_DEV_SIZE=$((length / blksz))
+	fi
+
 	LOGWRITES_NAME=logwrites-test
 	LOGWRITES_DMDEV=/dev/mapper/$LOGWRITES_NAME
 	LOGWRITES_TABLE="0 $BLK_DEV_SIZE log-writes $blkdev $LOGWRITES_DEV"