[9/9] rbd: ask for a weaker incompat mask for read-only mappings
diff mbox series

Message ID 20191118133816.3963-10-idryomov@gmail.com
State New
Headers show
Series
  • wip-krbd-readonly
Related show

Commit Message

Ilya Dryomov Nov. 18, 2019, 1:38 p.m. UTC
For a read-only mapping, ask for a set of features that make the image
only unreadable, rather than both unreadable and unwritable by a client
that doesn't understand them.  As of today, the difference between them
for krbd is journaling (JOURNALING) and live migration (MIGRATING).

get_features method supports read_only parameter since hammer, ceph.git
commit 6176ec5fde2a ("librbd: differentiate between R/O vs R/W RBD
features").

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
 drivers/block/rbd.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Dongsheng Yang Nov. 19, 2019, 8:38 a.m. UTC | #1
On 11/18/2019 09:38 PM, Ilya Dryomov wrote:
> For a read-only mapping, ask for a set of features that make the image
> only unreadable, rather than both unreadable and unwritable by a client
> that doesn't understand them.  As of today, the difference between them
> for krbd is journaling (JOURNALING) and live migration (MIGRATING).
>
> get_features method supports read_only parameter since hammer, ceph.git
> commit 6176ec5fde2a ("librbd: differentiate between R/O vs R/W RBD
> features").
>
> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

Reviewed-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
> ---
>   drivers/block/rbd.c | 15 +++++++++++----
>   1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 935b66808e40..b3167247c90a 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -5652,9 +5652,12 @@ static int rbd_dev_v2_object_prefix(struct rbd_device *rbd_dev)
>   }
>   
>   static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id,
> -		u64 *snap_features)
> +				     bool read_only, u64 *snap_features)
>   {
> -	__le64 snapid = cpu_to_le64(snap_id);
> +	struct {
> +		__le64 snap_id;
> +		u8 read_only;
> +	} features_in;
>   	struct {
>   		__le64 features;
>   		__le64 incompat;
> @@ -5662,9 +5665,12 @@ static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id,
>   	u64 unsup;
>   	int ret;
>   
> +	features_in.snap_id = cpu_to_le64(snap_id);
> +	features_in.read_only = read_only;
> +
>   	ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid,
>   				  &rbd_dev->header_oloc, "get_features",
> -				  &snapid, sizeof(snapid),
> +				  &features_in, sizeof(features_in),
>   				  &features_buf, sizeof(features_buf));
>   	dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
>   	if (ret < 0)
> @@ -5692,7 +5698,8 @@ static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id,
>   static int rbd_dev_v2_features(struct rbd_device *rbd_dev)
>   {
>   	return _rbd_dev_v2_snap_features(rbd_dev, CEPH_NOSNAP,
> -						&rbd_dev->header.features);
> +					 rbd_is_ro(rbd_dev),
> +					 &rbd_dev->header.features);
>   }
>   
>   /*

Patch
diff mbox series

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 935b66808e40..b3167247c90a 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5652,9 +5652,12 @@  static int rbd_dev_v2_object_prefix(struct rbd_device *rbd_dev)
 }
 
 static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id,
-		u64 *snap_features)
+				     bool read_only, u64 *snap_features)
 {
-	__le64 snapid = cpu_to_le64(snap_id);
+	struct {
+		__le64 snap_id;
+		u8 read_only;
+	} features_in;
 	struct {
 		__le64 features;
 		__le64 incompat;
@@ -5662,9 +5665,12 @@  static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id,
 	u64 unsup;
 	int ret;
 
+	features_in.snap_id = cpu_to_le64(snap_id);
+	features_in.read_only = read_only;
+
 	ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid,
 				  &rbd_dev->header_oloc, "get_features",
-				  &snapid, sizeof(snapid),
+				  &features_in, sizeof(features_in),
 				  &features_buf, sizeof(features_buf));
 	dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
 	if (ret < 0)
@@ -5692,7 +5698,8 @@  static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id,
 static int rbd_dev_v2_features(struct rbd_device *rbd_dev)
 {
 	return _rbd_dev_v2_snap_features(rbd_dev, CEPH_NOSNAP,
-						&rbd_dev->header.features);
+					 rbd_is_ro(rbd_dev),
+					 &rbd_dev->header.features);
 }
 
 /*