[20/20] rbd: setallochint only if object doesn't exist
diff mbox series

Message ID 20190625144111.11270-21-idryomov@gmail.com
State New
Headers show
Series
  • rbd: support for object-map and fast-diff
Related show

Commit Message

Ilya Dryomov June 25, 2019, 2:41 p.m. UTC
setallochint is really only useful on object creation.  Continue
hinting unconditionally if object map cannot be used.

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

Comments

Dongsheng Yang July 1, 2019, 5:33 a.m. UTC | #1
On 06/25/2019 10:41 PM, Ilya Dryomov wrote:
> setallochint is really only useful on object creation.  Continue
> hinting unconditionally if object map cannot be used.
>
> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>


Reviewed-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
> ---
>   drivers/block/rbd.c | 19 ++++++++++++++-----
>   1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 756595f5fbc9..5dc217530f0f 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -2366,9 +2366,12 @@ static void __rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req,
>   	struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev;
>   	u16 opcode;
>   
> -	osd_req_op_alloc_hint_init(osd_req, which++,
> -				   rbd_dev->layout.object_size,
> -				   rbd_dev->layout.object_size);
> +	if (!use_object_map(rbd_dev) ||
> +	    !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) {
> +		osd_req_op_alloc_hint_init(osd_req, which++,
> +					   rbd_dev->layout.object_size,
> +					   rbd_dev->layout.object_size);
> +	}
>   
>   	if (rbd_obj_is_entire(obj_req))
>   		opcode = CEPH_OSD_OP_WRITEFULL;
> @@ -2511,9 +2514,15 @@ static int rbd_obj_init_zeroout(struct rbd_obj_request *obj_req)
>   
>   static int count_write_ops(struct rbd_obj_request *obj_req)
>   {
> -	switch (obj_req->img_request->op_type) {
> +	struct rbd_img_request *img_req = obj_req->img_request;
> +
> +	switch (img_req->op_type) {
>   	case OBJ_OP_WRITE:
> -		return 2; /* setallochint + write/writefull */
> +		if (!use_object_map(img_req->rbd_dev) ||
> +		    !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST))
> +			return 2; /* setallochint + write/writefull */
> +
> +		return 1; /* write/writefull */
>   	case OBJ_OP_DISCARD:
>   		return 1; /* delete/truncate/zero */
>   	case OBJ_OP_ZEROOUT:

Patch
diff mbox series

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 756595f5fbc9..5dc217530f0f 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2366,9 +2366,12 @@  static void __rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req,
 	struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev;
 	u16 opcode;
 
-	osd_req_op_alloc_hint_init(osd_req, which++,
-				   rbd_dev->layout.object_size,
-				   rbd_dev->layout.object_size);
+	if (!use_object_map(rbd_dev) ||
+	    !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) {
+		osd_req_op_alloc_hint_init(osd_req, which++,
+					   rbd_dev->layout.object_size,
+					   rbd_dev->layout.object_size);
+	}
 
 	if (rbd_obj_is_entire(obj_req))
 		opcode = CEPH_OSD_OP_WRITEFULL;
@@ -2511,9 +2514,15 @@  static int rbd_obj_init_zeroout(struct rbd_obj_request *obj_req)
 
 static int count_write_ops(struct rbd_obj_request *obj_req)
 {
-	switch (obj_req->img_request->op_type) {
+	struct rbd_img_request *img_req = obj_req->img_request;
+
+	switch (img_req->op_type) {
 	case OBJ_OP_WRITE:
-		return 2; /* setallochint + write/writefull */
+		if (!use_object_map(img_req->rbd_dev) ||
+		    !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST))
+			return 2; /* setallochint + write/writefull */
+
+		return 1; /* write/writefull */
 	case OBJ_OP_DISCARD:
 		return 1; /* delete/truncate/zero */
 	case OBJ_OP_ZEROOUT: