[v4,08/17] scripts: spfs-change-mode.sh added

Submitted by Stanislav Kinsburskiy on May 20, 2016, 11:37 a.m.

Details

Message ID 20160520113733.360872.73144.stgit@skinsbursky-vz7-gold.qa.sw.ru
State Rejected
Series "NFS migration support"
Headers show

Commit Message

Stanislav Kinsburskiy May 20, 2016, 11:37 a.m.
This scripts can be used on restore to switch all the spfs mounts to Stub mode
when all files have been reopened.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 scripts/spfs-change-mode.sh |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100755 scripts/spfs-change-mode.sh

Patch hide | download patch | download mbox

diff --git a/scripts/spfs-change-mode.sh b/scripts/spfs-change-mode.sh
new file mode 100755
index 0000000..0b91669
--- /dev/null
+++ b/scripts/spfs-change-mode.sh
@@ -0,0 +1,32 @@ 
+#!/bin/bash
+
+[[ "post-restore" == "$CRTOOLS_SCRIPT_ACTION" ]] || exit 0
+
+set -o pipefail
+
+if [ -z "$SPFS_MANAGER_SOCK" ]; then
+	echo "SPFS_MANAGER_SOCK environment variable is not set"
+	exit 1
+fi
+
+if [ -z "$SPFS_MODE" ]; then
+	echo "SPFS_MODE environment variable is not set"
+	exit 1
+fi
+
+[ -e $SPFS_MANAGER_SOCK ] || exit 0
+
+if [ ! -S "$SPFS_MANAGER_SOCK" ]; then
+	echo "$SPFS_MANAGER_SOCK is not a socket"
+	exit 1
+fi
+
+SPFS_CLIENT="/usr/sbin/spfs-client"
+
+if [ ! -x "$SPFS_CLIENT" ]; then
+	echo "Filed to find executable /usr/sbin/spfs-client"
+	exit 1
+fi
+
+$SPFS_CLIENT manage "mode;all;mode=$SPFS_MODE" --socket-path $SPFS_MANAGER_SOCK > /dev/null
+exit $?

Comments

Pavel Emelianov June 2, 2016, 11:15 a.m.
On 05/20/2016 02:37 PM, Stanislav Kinsburskiy wrote:
> This scripts can be used on restore to switch all the spfs mounts to Stub mode
> when all files have been reopened.

Why mount and create_file is implemented as some sort of RPC (via socket)
but mode switch is script?

> Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
> ---
>  scripts/spfs-change-mode.sh |   32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
>  create mode 100755 scripts/spfs-change-mode.sh
> 
> diff --git a/scripts/spfs-change-mode.sh b/scripts/spfs-change-mode.sh
> new file mode 100755
> index 0000000..0b91669
> --- /dev/null
> +++ b/scripts/spfs-change-mode.sh
> @@ -0,0 +1,32 @@
> +#!/bin/bash
> +
> +[[ "post-restore" == "$CRTOOLS_SCRIPT_ACTION" ]] || exit 0
> +
> +set -o pipefail
> +
> +if [ -z "$SPFS_MANAGER_SOCK" ]; then
> +	echo "SPFS_MANAGER_SOCK environment variable is not set"
> +	exit 1
> +fi
> +
> +if [ -z "$SPFS_MODE" ]; then
> +	echo "SPFS_MODE environment variable is not set"
> +	exit 1
> +fi
> +
> +[ -e $SPFS_MANAGER_SOCK ] || exit 0
> +
> +if [ ! -S "$SPFS_MANAGER_SOCK" ]; then
> +	echo "$SPFS_MANAGER_SOCK is not a socket"
> +	exit 1
> +fi
> +
> +SPFS_CLIENT="/usr/sbin/spfs-client"
> +
> +if [ ! -x "$SPFS_CLIENT" ]; then
> +	echo "Filed to find executable /usr/sbin/spfs-client"
> +	exit 1
> +fi
> +
> +$SPFS_CLIENT manage "mode;all;mode=$SPFS_MODE" --socket-path $SPFS_MANAGER_SOCK > /dev/null
> +exit $?
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> .
>
Stanislav Kinsburskiy June 2, 2016, 12:16 p.m.
02.06.2016 13:15, Pavel Emelyanov пишет:
> On 05/20/2016 02:37 PM, Stanislav Kinsburskiy wrote:
>> This scripts can be used on restore to switch all the spfs mounts to Stub mode
>> when all files have been reopened.
> Why mount and create_file is implemented as some sort of RPC (via socket)
> but mode switch is script?
>

Your question contains of two:

1)  "Why mount and create_file is implemented as some sort of RPC?".
First, only mount is implemented via RPC. File creation is done by CRIU 
itself.
Mount request could be implemented by script, but I didn't see, why 
should I. To mount SPFS some C code is required anyway, so calling a 
script doesn't simplify the changes from my POW

2) Why mode switch was implemented via script?
Because it allows to avoid additional impact to criu. Otherwise I had to 
put some explicit SPFS manager callback to source code of criu somewhere 
around "post-restore" action scripts call.
Frankly, source code callback solution looks more strict, and I would 
prefer it to the script.
If you have nothing against it, I'll implement.


>>   Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
>> ---
>>   scripts/spfs-change-mode.sh |   32 ++++++++++++++++++++++++++++++++
>>   1 file changed, 32 insertions(+)
>>   create mode 100755 scripts/spfs-change-mode.sh
>>
>> diff --git a/scripts/spfs-change-mode.sh b/scripts/spfs-change-mode.sh
>> new file mode 100755
>> index 0000000..0b91669
>> --- /dev/null
>> +++ b/scripts/spfs-change-mode.sh
>> @@ -0,0 +1,32 @@
>> +#!/bin/bash
>> +
>> +[[ "post-restore" == "$CRTOOLS_SCRIPT_ACTION" ]] || exit 0
>> +
>> +set -o pipefail
>> +
>> +if [ -z "$SPFS_MANAGER_SOCK" ]; then
>> +	echo "SPFS_MANAGER_SOCK environment variable is not set"
>> +	exit 1
>> +fi
>> +
>> +if [ -z "$SPFS_MODE" ]; then
>> +	echo "SPFS_MODE environment variable is not set"
>> +	exit 1
>> +fi
>> +
>> +[ -e $SPFS_MANAGER_SOCK ] || exit 0
>> +
>> +if [ ! -S "$SPFS_MANAGER_SOCK" ]; then
>> +	echo "$SPFS_MANAGER_SOCK is not a socket"
>> +	exit 1
>> +fi
>> +
>> +SPFS_CLIENT="/usr/sbin/spfs-client"
>> +
>> +if [ ! -x "$SPFS_CLIENT" ]; then
>> +	echo "Filed to find executable /usr/sbin/spfs-client"
>> +	exit 1
>> +fi
>> +
>> +$SPFS_CLIENT manage "mode;all;mode=$SPFS_MODE" --socket-path $SPFS_MANAGER_SOCK > /dev/null
>> +exit $?
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU@openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
>> .
>>
Pavel Emelianov June 6, 2016, 12:02 p.m.
On 06/02/2016 03:16 PM, Stanislav Kinsburskiy wrote:
> 
> 
> 02.06.2016 13:15, Pavel Emelyanov пишет:
>> On 05/20/2016 02:37 PM, Stanislav Kinsburskiy wrote:
>>> This scripts can be used on restore to switch all the spfs mounts to Stub mode
>>> when all files have been reopened.
>> Why mount and create_file is implemented as some sort of RPC (via socket)
>> but mode switch is script?
>>
> 
> Your question contains of two:
> 
> 1)  "Why mount and create_file is implemented as some sort of RPC?".
> First, only mount is implemented via RPC. File creation is done by CRIU 
> itself.
> Mount request could be implemented by script, but I didn't see, why 
> should I. To mount SPFS some C code is required anyway, so calling a 
> script doesn't simplify the changes from my POW
> 
> 2) Why mode switch was implemented via script?
> Because it allows to avoid additional impact to criu. Otherwise I had to 
> put some explicit SPFS manager callback to source code of criu somewhere 
> around "post-restore" action scripts call.
> Frankly, source code callback solution looks more strict, and I would 
> prefer it to the script.
> If you have nothing against it, I'll implement.

I'd appreciate if any communication between criu and spfs use the same
approach, be it rpc or script.

-- Pavel
Stanislav Kinsburskiy June 6, 2016, 12:41 p.m.
06.06.2016 14:02, Pavel Emelyanov пишет:
> On 06/02/2016 03:16 PM, Stanislav Kinsburskiy wrote:
>>
>> 02.06.2016 13:15, Pavel Emelyanov пишет:
>>> On 05/20/2016 02:37 PM, Stanislav Kinsburskiy wrote:
>>>> This scripts can be used on restore to switch all the spfs mounts to Stub mode
>>>> when all files have been reopened.
>>> Why mount and create_file is implemented as some sort of RPC (via socket)
>>> but mode switch is script?
>>>
>> Your question contains of two:
>>
>> 1)  "Why mount and create_file is implemented as some sort of RPC?".
>> First, only mount is implemented via RPC. File creation is done by CRIU
>> itself.
>> Mount request could be implemented by script, but I didn't see, why
>> should I. To mount SPFS some C code is required anyway, so calling a
>> script doesn't simplify the changes from my POW
>>
>> 2) Why mode switch was implemented via script?
>> Because it allows to avoid additional impact to criu. Otherwise I had to
>> put some explicit SPFS manager callback to source code of criu somewhere
>> around "post-restore" action scripts call.
>> Frankly, source code callback solution looks more strict, and I would
>> prefer it to the script.
>> If you have nothing against it, I'll implement.
> I'd appreciate if any communication between criu and spfs use the same
> approach, be it rpc or script.

Ok. Then I would prefer to add one more rpc call to criu sources.
Is it ok?

> -- Pavel
>
Pavel Emelianov June 7, 2016, 12:24 p.m.
On 06/06/2016 03:41 PM, Stanislav Kinsburskiy wrote:
> 
> 
> 06.06.2016 14:02, Pavel Emelyanov пишет:
>> On 06/02/2016 03:16 PM, Stanislav Kinsburskiy wrote:
>>>
>>> 02.06.2016 13:15, Pavel Emelyanov пишет:
>>>> On 05/20/2016 02:37 PM, Stanislav Kinsburskiy wrote:
>>>>> This scripts can be used on restore to switch all the spfs mounts to Stub mode
>>>>> when all files have been reopened.
>>>> Why mount and create_file is implemented as some sort of RPC (via socket)
>>>> but mode switch is script?
>>>>
>>> Your question contains of two:
>>>
>>> 1)  "Why mount and create_file is implemented as some sort of RPC?".
>>> First, only mount is implemented via RPC. File creation is done by CRIU
>>> itself.
>>> Mount request could be implemented by script, but I didn't see, why
>>> should I. To mount SPFS some C code is required anyway, so calling a
>>> script doesn't simplify the changes from my POW
>>>
>>> 2) Why mode switch was implemented via script?
>>> Because it allows to avoid additional impact to criu. Otherwise I had to
>>> put some explicit SPFS manager callback to source code of criu somewhere
>>> around "post-restore" action scripts call.
>>> Frankly, source code callback solution looks more strict, and I would
>>> prefer it to the script.
>>> If you have nothing against it, I'll implement.
>> I'd appreciate if any communication between criu and spfs use the same
>> approach, be it rpc or script.
> 
> Ok. Then I would prefer to add one more rpc call to criu sources.
> Is it ok?

I think yes.