All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Durgin <josh.durgin@inktank.com>
To: ceph-devel@vger.kernel.org
Cc: Guangliang Zhao <lucienchao@gmail.com>
Subject: [PATCH 02/11] rbd: skip the copyup when an entire object writing
Date: Tue,  8 Apr 2014 13:42:46 -0700	[thread overview]
Message-ID: <e8c928e7bb03d2bb934a64a8d558319d9a76b35c.1396987789.git.josh.durgin@inktank.com> (raw)
In-Reply-To: <cover.1396987789.git.josh.durgin@inktank.com>
In-Reply-To: <cover.1396987789.git.josh.durgin@inktank.com>

From: Guangliang Zhao <lucienchao@gmail.com>

It need to copyup the parent's content when layered writing,
but an entire object write would overwrite it, so skip it.

Signed-off-by: Guangliang Zhao <lucienchao@gmail.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Reviewed-by: Alex Elder <elder@linaro.org>
---
 drivers/block/rbd.c |   49 ++++++++++++++++++++++++++++++++++---------------
 1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index b6676b6..282bfcd 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2645,34 +2645,53 @@ out:
 	return ret;
 }
 
-static int rbd_img_obj_request_submit(struct rbd_obj_request *obj_request)
+static bool rbd_img_obj_request_simple(struct rbd_obj_request *obj_request)
 {
 	struct rbd_img_request *img_request;
 	struct rbd_device *rbd_dev;
-	bool known;
+	u64 obj_size;
 
 	rbd_assert(obj_request_img_data_test(obj_request));
 
 	img_request = obj_request->img_request;
 	rbd_assert(img_request);
 	rbd_dev = img_request->rbd_dev;
+	obj_size = (u64) 1 << rbd_dev->header.obj_order;
 
+	/* Read requests didn't need special handling */
+	if (!img_request_write_test(img_request))
+		return true;
+	/* No-layered writes are simple requests*/
+	if (!img_request_layered_test(img_request))
+		return true;
 	/*
-	 * Only writes to layered images need special handling.
-	 * Reads and non-layered writes are simple object requests.
 	 * Layered writes that start beyond the end of the overlap
-	 * with the parent have no parent data, so they too are
-	 * simple object requests.  Finally, if the target object is
-	 * known to already exist, its parent data has already been
-	 * copied, so a write to the object can also be handled as a
-	 * simple object request.
+	 * with the parent have no parent data, so they are simple
+	 * object requests.
 	 */
-	if (!img_request_write_test(img_request) ||
-		!img_request_layered_test(img_request) ||
-		rbd_dev->parent_overlap <= obj_request->img_offset ||
-		((known = obj_request_known_test(obj_request)) &&
-			obj_request_exists_test(obj_request))) {
+	if (rbd_dev->parent_overlap <= obj_request->img_offset)
+		return true;
+	/*
+	 * If the obj_request aligns with the boundary and equals
+	 * to the size of an object, it doesn't need copyup, because
+	 * the obj_request will overwrite it finally.
+	 */
+	if ((!obj_request->offset) && (obj_request->length == obj_size))
+		return true;
+	/*
+	 * If the target object is known to already exist, its parent
+	 * data has already been copied, so a write to the object can
+	 * also be handled as a simple object request
+	 */
+	if (obj_request_known_test(obj_request) &&
+			obj_request_exists_test(obj_request))
+		return true;
+	return false;
+}
 
+static int rbd_img_obj_request_submit(struct rbd_obj_request *obj_request)
+{
+	if (rbd_img_obj_request_simple(obj_request)) {
 		struct rbd_device *rbd_dev;
 		struct ceph_osd_client *osdc;
 
@@ -2688,7 +2707,7 @@ static int rbd_img_obj_request_submit(struct rbd_obj_request *obj_request)
 	 * start by reading the data for the full target object from
 	 * the parent so we can use it for a copyup to the target.
 	 */
-	if (known)
+	if (obj_request_known_test(obj_request))
 		return rbd_img_obj_parent_read_full(obj_request);
 
 	/* We don't know whether the target exists.  Go find out. */
-- 
1.7.10.4


  parent reply	other threads:[~2014-04-08 22:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-08 20:42 [PATCH 00/11] rbd bug fix and discard support Josh Durgin
2014-04-08 20:42 ` [PATCH 01/11] rbd: access snapshot context and mapping size safely Josh Durgin
2014-04-08 20:42 ` Josh Durgin [this message]
2014-04-08 20:42 ` [PATCH 03/11] rbd: extend the operation type Josh Durgin
2014-04-08 20:42 ` [PATCH 04/11] rbd: add discard support for rbd Josh Durgin
2014-04-08 20:42 ` [PATCH 05/11] rbd: read image size for discard check safely Josh Durgin
2014-04-08 20:42 ` [PATCH 06/11] rbd: fix snapshot context reference count for discards Josh Durgin
2014-04-08 20:42 ` [PATCH 07/11] rbd: tolerate -ENOENT for discard operations Josh Durgin
2014-04-08 20:42 ` [PATCH 08/11] rbd: make discard trigger copy-on-write Josh Durgin
2014-04-08 20:42 ` [PATCH 09/11] rbd: extract a method for adding object operations Josh Durgin
2014-04-08 20:42 ` [PATCH 10/11] rbd: use helpers to handle discard for layered images correctly Josh Durgin
2014-04-08 20:42 ` [PATCH 11/11] rbd: set the remaining discard properties to enable support Josh Durgin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e8c928e7bb03d2bb934a64a8d558319d9a76b35c.1396987789.git.josh.durgin@inktank.com \
    --to=josh.durgin@inktank.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=lucienchao@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.