From 6706e49b1bef54a556b7be4bdddef55990485984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 21 Jan 2022 10:24:50 +0100 Subject: [PATCH 1/8] change lock mtime to expiration --- cs3/storage/provider/v1beta1/resources.proto | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cs3/storage/provider/v1beta1/resources.proto b/cs3/storage/provider/v1beta1/resources.proto index 380550a7..022b97f5 100644 --- a/cs3/storage/provider/v1beta1/resources.proto +++ b/cs3/storage/provider/v1beta1/resources.proto @@ -141,7 +141,7 @@ enum LockType { // "type" : "", // "h" : "", // "md" : "", -// "mtime" : "" +// "exp" : "" // } message Lock { // The type of lock. @@ -153,11 +153,10 @@ message Lock { // An application name if the lock is held by an app. string app_name = 3; } - // Some arbitrary metadata associated with the lock. + // OPTIONAL. Some arbitrary metadata associated with the lock. string metadata = 4; - // The last modification time of the lock. - // The value is Unix Epoch timestamp in seconds. - cs3.types.v1beta1.Timestamp mtime = 5; + // OPTIONAL. The time when the lock will expire. + cs3.types.v1beta1.Timestamp expiration = 5; } // The available types of resources. From 2b9d6f6a33e869609f53379036c5242923b33912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 21 Jan 2022 13:59:36 +0100 Subject: [PATCH 2/8] add Lock to UnlockRequest --- cs3/storage/provider/v1beta1/provider_api.proto | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cs3/storage/provider/v1beta1/provider_api.proto b/cs3/storage/provider/v1beta1/provider_api.proto index a9e231db..d5fae737 100644 --- a/cs3/storage/provider/v1beta1/provider_api.proto +++ b/cs3/storage/provider/v1beta1/provider_api.proto @@ -878,6 +878,9 @@ message UnlockRequest { // REQUIRED. // The reference the lock is associated to. Reference ref = 2; + // REQUIRED. + // The lock metadata. + Lock lock = 3; } message UnlockResponse { From 6b1aa11b225dbe095008b7d1f0db9532f7958d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 24 Jan 2022 10:37:45 +0100 Subject: [PATCH 3/8] allow ResourceInfo to carry a list of Lock messages --- cs3/storage/provider/v1beta1/resources.proto | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cs3/storage/provider/v1beta1/resources.proto b/cs3/storage/provider/v1beta1/resources.proto index 022b97f5..eb17e261 100644 --- a/cs3/storage/provider/v1beta1/resources.proto +++ b/cs3/storage/provider/v1beta1/resources.proto @@ -90,6 +90,9 @@ message ResourceInfo { // OPTIONAL. // Arbitrary metadata attached to a resource. ArbitraryMetadata arbitrary_metadata = 14; + // OPTIONAL. + // Locks on this resource. + repeated Lock locks = 15; } // CanonicalMetadata contains extra metadata From 216d79e5ec33a0fb945e8bc2c1f8a28681a42e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 24 Jan 2022 13:05:50 +0100 Subject: [PATCH 4/8] allow multiple users per lock --- cs3/storage/provider/v1beta1/resources.proto | 25 +++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/cs3/storage/provider/v1beta1/resources.proto b/cs3/storage/provider/v1beta1/resources.proto index eb17e261..32565ab4 100644 --- a/cs3/storage/provider/v1beta1/resources.proto +++ b/cs3/storage/provider/v1beta1/resources.proto @@ -91,8 +91,8 @@ message ResourceInfo { // Arbitrary metadata attached to a resource. ArbitraryMetadata arbitrary_metadata = 14; // OPTIONAL. - // Locks on this resource. - repeated Lock locks = 15; + // Lock on this resource. + Lock lock = 15; } // CanonicalMetadata contains extra metadata @@ -138,24 +138,15 @@ enum LockType { // of this metadata according to their constraints, a reference // implementation is given here. The lock SHOULD be stored // as an extended attribute on the referenced filesystem entry. -// It MUST NOT be accessible via the Stat/SetArbitraryMetadata APIs, -// and it SHOULD contain a base64-encoded JSON with the following format: -// { -// "type" : "", -// "h" : "", -// "md" : "", -// "exp" : "" -// } +// It MUST NOT be accessible via the Stat/SetArbitraryMetadata APIs. message Lock { // The type of lock. LockType type = 1; - // The entity holding the lock. - oneof holder { - // A userid if the lock is held by a user. - cs3.identity.user.v1beta1.UserId user = 2; - // An application name if the lock is held by an app. - string app_name = 3; - } + // The entities holding the lock. + // REQUIRED. At least one userid of the users participating in the lock. + repeated cs3.identity.user.v1beta1.UserId users = 2; + // An application name if the lock is held by an app. + string app_name = 3; // OPTIONAL. Some arbitrary metadata associated with the lock. string metadata = 4; // OPTIONAL. The time when the lock will expire. From 04a2ced0fad726d4bdfdeb3197a8e31147caa184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 24 Jan 2022 15:46:50 +0100 Subject: [PATCH 5/8] distinguish exclusive and advisory locks --- cs3/storage/provider/v1beta1/resources.proto | 27 ++++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/cs3/storage/provider/v1beta1/resources.proto b/cs3/storage/provider/v1beta1/resources.proto index 32565ab4..f65fc1b6 100644 --- a/cs3/storage/provider/v1beta1/resources.proto +++ b/cs3/storage/provider/v1beta1/resources.proto @@ -91,8 +91,11 @@ message ResourceInfo { // Arbitrary metadata attached to a resource. ArbitraryMetadata arbitrary_metadata = 14; // OPTIONAL. - // Lock on this resource. + // Exclusive or write lock on this resource that will limit modification of the resource to holders of the lock. Can be used by WOPI or other apps requiring exclusive locks. Lock lock = 15; + // OPTIONAL. + // Advisory locks on this resource. Can be used for shared locks or other forms of collaborative locks. + repeated Lock advisory_locks = 16; } // CanonicalMetadata contains extra metadata @@ -140,17 +143,19 @@ enum LockType { // as an extended attribute on the referenced filesystem entry. // It MUST NOT be accessible via the Stat/SetArbitraryMetadata APIs. message Lock { - // The type of lock. - LockType type = 1; - // The entities holding the lock. - // REQUIRED. At least one userid of the users participating in the lock. - repeated cs3.identity.user.v1beta1.UserId users = 2; - // An application name if the lock is held by an app. - string app_name = 3; - // OPTIONAL. Some arbitrary metadata associated with the lock. - string metadata = 4; + // OPTIONAL. + // Opaque information. + cs3.types.v1beta1.Opaque opaque = 1; + // REQUIRED. The id of the lock, eg. the X-WOPI-Lock id or the WebDAV opaquelocktoken. + string lock_id = 2; + // REQUIRED. The type of lock. + LockType type = 3; + // OPTIONAL. The userid of a user holding the lock. + cs3.identity.user.v1beta1.UserId user = 4; + // OPTIONAL An application name if the lock is held by an app. + string app_name = 5; // OPTIONAL. The time when the lock will expire. - cs3.types.v1beta1.Timestamp expiration = 5; + cs3.types.v1beta1.Timestamp expiration = 6; } // The available types of resources. From 20a12d7245acb2e822d0456004d8a9811ed9a571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 25 Jan 2022 12:48:24 +0100 Subject: [PATCH 6/8] Update cs3/storage/provider/v1beta1/resources.proto Co-authored-by: Giuseppe Lo Presti --- cs3/storage/provider/v1beta1/resources.proto | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cs3/storage/provider/v1beta1/resources.proto b/cs3/storage/provider/v1beta1/resources.proto index f65fc1b6..42ee2abd 100644 --- a/cs3/storage/provider/v1beta1/resources.proto +++ b/cs3/storage/provider/v1beta1/resources.proto @@ -150,7 +150,9 @@ message Lock { string lock_id = 2; // REQUIRED. The type of lock. LockType type = 3; - // OPTIONAL. The userid of a user holding the lock. + // OPTIONAL. + // The userid of a user, which represents either the lock holder, or the user that last created/modified the lock. + // When non empty, `RefreshLock` and `Unlock` operations MUST check their request's content against it. cs3.identity.user.v1beta1.UserId user = 4; // OPTIONAL An application name if the lock is held by an app. string app_name = 5; From 1fe7bfa4b33fa3ada9b08b177a462e6eb2660eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 25 Jan 2022 12:48:56 +0100 Subject: [PATCH 7/8] Apply suggestions from code review Co-authored-by: Giuseppe Lo Presti --- cs3/storage/provider/v1beta1/resources.proto | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cs3/storage/provider/v1beta1/resources.proto b/cs3/storage/provider/v1beta1/resources.proto index 42ee2abd..ba267c06 100644 --- a/cs3/storage/provider/v1beta1/resources.proto +++ b/cs3/storage/provider/v1beta1/resources.proto @@ -146,17 +146,22 @@ message Lock { // OPTIONAL. // Opaque information. cs3.types.v1beta1.Opaque opaque = 1; - // REQUIRED. The id of the lock, eg. the X-WOPI-Lock id or the WebDAV opaquelocktoken. + // REQUIRED. + // The id of the lock, eg. the X-WOPI-Lock id or the WebDAV opaquelocktoken. string lock_id = 2; - // REQUIRED. The type of lock. + // REQUIRED. + // The type of lock. LockType type = 3; // OPTIONAL. // The userid of a user, which represents either the lock holder, or the user that last created/modified the lock. // When non empty, `RefreshLock` and `Unlock` operations MUST check their request's content against it. cs3.identity.user.v1beta1.UserId user = 4; - // OPTIONAL An application name if the lock is held by an app. + // OPTIONAL. + // An application name if the lock is held by an app. + // When non empty, `RefreshLock` and `Unlock` operations MUST check their request's content against it. string app_name = 5; - // OPTIONAL. The time when the lock will expire. + // OPTIONAL. + // The time when the lock will expire. cs3.types.v1beta1.Timestamp expiration = 6; } From 34dabe0b143a162a5dca39ac714919e8aeede26a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 25 Jan 2022 17:16:27 +0100 Subject: [PATCH 8/8] Update cs3/storage/provider/v1beta1/resources.proto Co-authored-by: Giuseppe Lo Presti --- cs3/storage/provider/v1beta1/resources.proto | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cs3/storage/provider/v1beta1/resources.proto b/cs3/storage/provider/v1beta1/resources.proto index ba267c06..9b388d42 100644 --- a/cs3/storage/provider/v1beta1/resources.proto +++ b/cs3/storage/provider/v1beta1/resources.proto @@ -141,7 +141,8 @@ enum LockType { // of this metadata according to their constraints, a reference // implementation is given here. The lock SHOULD be stored // as an extended attribute on the referenced filesystem entry. -// It MUST NOT be accessible via the Stat/SetArbitraryMetadata APIs. +// Such extended attribute MUST NOT be exposed via the `Stat` and `SetArbitraryMetadata` APIs. +// Instead, the `ResourceInfo.Lock` attribute MUST be populated if a lock exists for the given reference. message Lock { // OPTIONAL. // Opaque information.