From patchwork Wed Jan 30 20:49:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2069791 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 8DB69DF2E5 for ; Wed, 30 Jan 2013 20:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756862Ab3A3UtK (ORCPT ); Wed, 30 Jan 2013 15:49:10 -0500 Received: from mail-ia0-f169.google.com ([209.85.210.169]:56731 "EHLO mail-ia0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755169Ab3A3UtJ (ORCPT ); Wed, 30 Jan 2013 15:49:09 -0500 Received: by mail-ia0-f169.google.com with SMTP id j5so3018941iaf.0 for ; Wed, 30 Jan 2013 12:49:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=afMd6yvTNipr20PafgHhvBchozKm/mQWtq9lNFx4h1M=; b=Sgb0oJ0dlLkAmXzD4+yVz78lpaRYYPzYs7uO9aVgG2AgZ2Z+GtCGgBS+XUUxEZ6AWY hM2OHzErUE4bSwVrjsZqx/QmELHbwjeu0uxKtDZM/Tbf+PSS2ULclNK0YC0aI1d8WCgW yO4RxhCUW5kGH1oigZQ3IvY5HYi9yiNOhxe0FX6zTTh94ejzKz+zHlS16mm4sjMNZYt9 aXx6xPUzg1Yiwk3xjB9ZpsK4o3usz4c4aCUNMSkp1hvorhr34gIOq4cSoXJGXX/Xt/IO ArsOdn/eH22EdcpAeT31uc4PBDPiTlY+xa5O8FZnt1kB7VjguV0NQsCgIQlqg2UH2H1O zsig== X-Received: by 10.50.157.130 with SMTP id wm2mr4679462igb.1.1359578949071; Wed, 30 Jan 2013 12:49:09 -0800 (PST) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id rd10sm5475452igb.1.2013.01.30.12.49.07 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Jan 2013 12:49:08 -0800 (PST) Message-ID: <51098748.7080601@inktank.com> Date: Wed, 30 Jan 2013 14:49:12 -0600 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: "ceph-devel@vger.kernel.org" Subject: [PATCH 2/2] rbd: don't take extra bio reference for osd client References: <510986E4.7050901@inktank.com> In-Reply-To: <510986E4.7050901@inktank.com> X-Gm-Message-State: ALoCoQn8B83ZVw63mKxPi9taOITO6MYxi0Vib4vZHVxsxks5F+U479gn6FMSA9swJ3oImoZVjvRF Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Currently, if the OSD client finds an osd request has had a bio list attached to it, it drops a reference to it (or rather, to the first entry on that list) when the request is released. The code that added that reference (i.e., the rbd client) is therefore required to take an extra reference to that first bio structure. The osd client doesn't really do anything with the bio pointer other than transfer it from the osd request structure to outgoing (for writes) and ingoing (for reads) messages. So it really isn't the right place to be taking or dropping references. Furthermore, the rbd client already holds references to all bio structures it passes to the osd client, and holds them until the request is completed. So there's no need for this extra reference whatsoever. So remove the bio_put() call in ceph_osdc_release_request(), as well as its matching bio_get() call in rbd_osd_req_create(). This change could lead to a crash if old libceph.ko was used with new rbd.ko. Add a compatibility check at rbd initialization time to avoid this possibilty. This resolves: http://tracker.ceph.com/issues/3798 and http://tracker.ceph.com/issues/3799 Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 3 ++- net/ceph/ceph_common.c | 2 +- net/ceph/osd_client.c | 4 ---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index a9ce58c..6586800 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1342,7 +1342,6 @@ static struct ceph_osd_request *rbd_osd_req_create( case OBJ_REQUEST_BIO: rbd_assert(obj_request->bio_list != NULL); osd_req->r_bio = obj_request->bio_list; - bio_get(osd_req->r_bio); /* osd client requires "num pages" even for bio */ osd_req->r_num_pages = calc_pages_for(offset, length); break; @@ -4150,6 +4149,8 @@ int __init rbd_init(void) { int rc; + if (!libceph_compatible(NULL)) + return -EINVAL; rc = rbd_sysfs_init(); if (rc) return rc; diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index a98c03f..c236c235 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -39,7 +39,7 @@ */ bool libceph_compatible(void *data) { - return false; + return true; } EXPORT_SYMBOL(libceph_compatible); diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 500ae8b..ba03648 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -147,10 +147,6 @@ void ceph_osdc_release_request(struct kref *kref) if (req->r_own_pages) ceph_release_page_vector(req->r_pages, req->r_num_pages); -#ifdef CONFIG_BLOCK - if (req->r_bio) - bio_put(req->r_bio); -#endif ceph_put_snap_context(req->r_snapc); ceph_pagelist_release(&req->r_trail); if (req->r_mempool)