From patchwork Mon Sep 30 10:13:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rutger ter Borg X-Patchwork-Id: 2963481 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3053D9F88A for ; Mon, 30 Sep 2013 10:14:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD04D20205 for ; Mon, 30 Sep 2013 10:14:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A73C201F0 for ; Mon, 30 Sep 2013 10:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755778Ab3I3KN1 (ORCPT ); Mon, 30 Sep 2013 06:13:27 -0400 Received: from plane.gmane.org ([80.91.229.3]:47088 "EHLO plane.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755757Ab3I3KNY (ORCPT ); Mon, 30 Sep 2013 06:13:24 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VQaTh-0006pI-Qp for ceph-devel@vger.kernel.org; Mon, 30 Sep 2013 12:13:21 +0200 Received: from gl-95017.prolocation.net ([62.204.95.17]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 30 Sep 2013 12:13:21 +0200 Received: from rutger by gl-95017.prolocation.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 30 Sep 2013 12:13:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: ceph-devel@vger.kernel.org From: Rutger ter Borg Subject: [PATCH] fix librados aio read buffer handling Date: Mon, 30 Sep 2013 12:13:11 +0200 Lines: 121 Message-ID: Mime-Version: 1.0 X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: gl-95017.prolocation.net User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130929 Icedove/17.0.9 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Dear all, please find attached a patch that enables a user to pass user-owned buffers into librados' aio_read. The patch (against dumpling) removes the buf and pbl data members in AioCompletionImpl. * The 'buf' argument to read() used to be passed into AioCompletionImpl, and the results would be copied back after reading. This is replaced with the creation of a static buffer of that buf. * The pbl argument in AioCompletionImpl is removed. The patch is tested against an application using librados. I've assumed that 'pbl' in aio_read( ...., pbl, ) is allocated by the user. It may even speed things up: a buffer copy is prevented. Thanks, Rutger diff -u -p ceph-0.67.3/src/librados/AioCompletionImpl.h ceph-0.67.3-patched/src/librados/AioCompletionImpl.h --- ceph-0.67.3/src/librados/AioCompletionImpl.h 2013-09-09 21:47:34.000000000 +0200 +++ ceph-0.67.3-patched/src/librados/AioCompletionImpl.h 2013-09-30 11:14:17.946802146 +0200 @@ -39,8 +39,7 @@ struct librados::AioCompletionImpl { // for read bool is_read; - bufferlist bl, *pbl; - char *buf; + bufferlist bl; unsigned maxlen; IoCtxImpl *io; @@ -50,7 +49,7 @@ struct librados::AioCompletionImpl { AioCompletionImpl() : lock("AioCompletionImpl lock", false, false), ref(1), rval(0), released(false), ack(false), safe(false), callback_complete(0), callback_safe(0), callback_arg(0), - is_read(false), pbl(0), buf(0), maxlen(0), + is_read(false), maxlen(0), io(NULL), aio_write_seq(0), aio_write_list_item(this) { } int set_complete_callback(void *cb_arg, rados_callback_t cb) { diff -u -p ceph-0.67.3/src/librados/IoCtxImpl.cc ceph-0.67.3-patched/src/librados/IoCtxImpl.cc --- ceph-0.67.3/src/librados/IoCtxImpl.cc 2013-09-09 21:47:34.000000000 +0200 +++ ceph-0.67.3-patched/src/librados/IoCtxImpl.cc 2013-09-30 11:14:23.622824966 +0200 @@ -570,7 +570,6 @@ int librados::IoCtxImpl::aio_operate_rea c->is_read = true; c->io = this; - c->pbl = pbl; Mutex::Locker l(*lock); objecter->read(oid, oloc, @@ -613,11 +612,10 @@ int librados::IoCtxImpl::aio_read(const c->is_read = true; c->io = this; - c->pbl = pbl; Mutex::Locker l(*lock); objecter->read(oid, oloc, - off, len, snapid, &c->bl, 0, + off, len, snapid, pbl, 0, onack, &c->objver); return 0; } @@ -633,8 +631,9 @@ int librados::IoCtxImpl::aio_read(const c->is_read = true; c->io = this; - c->buf = buf; c->maxlen = len; + c->bl.clear(); + c->bl.push_back( buffer::create_static( len, buf ) ); Mutex::Locker l(*lock); objecter->read(oid, oloc, @@ -669,7 +668,6 @@ int librados::IoCtxImpl::aio_sparse_read c->is_read = true; c->io = this; - c->pbl = NULL; onack->m_ops.sparse_read(off, len, m, data_bl, NULL); @@ -1180,15 +1178,6 @@ void librados::IoCtxImpl::C_aio_Ack::fin c->safe = true; c->cond.Signal(); - if (c->buf && c->bl.length() > 0) { - unsigned l = MIN(c->bl.length(), c->maxlen); - c->bl.copy(0, l, c->buf); - c->rval = c->bl.length(); - } - if (c->pbl) { - *c->pbl = c->bl; - } - if (c->callback_complete) { c->io->client->finisher.queue(new C_AioComplete(c)); }