From: Josh Durgin <josh.durgin@inktank.com>
To: Alex Elder <elder@inktank.com>
Cc: "ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>
Subject: Re: [PATCH 2/4] rbd: return earlier in rbd_header_from_disk()
Date: Tue, 07 Aug 2012 17:29:43 -0700 [thread overview]
Message-ID: <5021B2F7.6030406@inktank.com> (raw)
In-Reply-To: <50200A46.3070508@inktank.com>
On 08/06/2012 11:17 AM, Alex Elder wrote:
> The only caller of rbd_header_from_disk() is rbd_read_header().
> It passes as allocated_snaps the number of snapshots it will
> have received from the server for the snapshot context that
> rbd_header_from_disk() is to interpret. The first time through
> it provides 0--mainly to extract the number of snapshots from
> the snapshot context header--so that it can allocate an
> appropriately-sized buffer to receive the entire snapshot
> context from the server in a second request.
>
> rbd_header_from_disk() will not fill in the array of snapshot ids
> unless the number in the snapshot matches the number the caller
> had allocated.
>
> This patch adjusts that logic a little further to be more efficient.
> rbd_read_header() doesn't even examine the snapshot context unless
> the snapshot count (stored in header->total_snaps) matches the
> number of snapshots allocated. So rbd_header_from_disk() doesn't
> need to allocate or fill in the snapshot context field at all in
> that case.
>
> Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
> ---
> drivers/block/rbd.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> Index: b/drivers/block/rbd.c
> ===================================================================
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -541,7 +541,14 @@ static int rbd_header_from_disk(struct r
> header->comp_type = ondisk->options.comp_type;
> header->total_snaps = snap_count;
>
> - /* Set up the snapshot context */
> + /*
> + * If the number of snapshot ids provided by the caller
> + * doesn't match the number in the entire context there's
> + * no point in going further. Caller will try again after
> + * getting an updated snapshot context from the server.
> + */
> + if (allocated_snaps != snap_count)
> + return 0;
>
> size = sizeof (struct ceph_snap_context);
> size += snap_count * sizeof (header->snapc->snaps[0]);
> @@ -553,8 +560,10 @@ static int rbd_header_from_disk(struct r
> header->snapc->seq = le64_to_cpu(ondisk->snap_seq);
> header->snapc->num_snaps = snap_count;
>
> - if (snap_count && allocated_snaps == snap_count) {
> - int i;
> + /* Fill in the snapshot information */
> +
> + if (snap_count) {
> + u32 i;
>
> for (i = 0; i < snap_count; i++) {
> header->snapc->snaps[i] =
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-08-08 0:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-06 18:15 [PATCH 0/4] rbd: separate reading from interpreting rbd header Alex Elder
2012-08-06 18:17 ` [PATCH 1/4] rbd: rearrange rbd_header_from_disk() Alex Elder
2012-08-08 0:29 ` Josh Durgin
2012-08-06 18:17 ` [PATCH 2/4] rbd: return earlier in rbd_header_from_disk() Alex Elder
2012-08-08 0:29 ` Josh Durgin [this message]
2012-08-06 18:17 ` [PATCH 3/4] rbd: expand rbd_dev_ondisk_valid() checks Alex Elder
2012-08-08 0:31 ` Josh Durgin
2012-08-06 18:17 ` [PATCH 4/4] rbd: separate reading header from decoding it Alex Elder
2012-08-08 0:58 ` Josh Durgin
2012-08-08 2:16 ` Alex Elder
2012-08-08 4:05 ` 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=5021B2F7.6030406@inktank.com \
--to=josh.durgin@inktank.com \
--cc=ceph-devel@vger.kernel.org \
--cc=elder@inktank.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.