From patchwork Fri Feb 8 16:20:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2116861 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id DC3F33FCA4 for ; Fri, 8 Feb 2013 16:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946450Ab3BHQUI (ORCPT ); Fri, 8 Feb 2013 11:20:08 -0500 Received: from mail-ia0-f174.google.com ([209.85.210.174]:40477 "EHLO mail-ia0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758646Ab3BHQUH (ORCPT ); Fri, 8 Feb 2013 11:20:07 -0500 Received: by mail-ia0-f174.google.com with SMTP id o25so4320226iad.5 for ; Fri, 08 Feb 2013 08:20:07 -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 :content-type:content-transfer-encoding:x-gm-message-state; bh=eS+e8abXlpVr/eucHwi77jaCxZxdOYcoI6uo9hlZCuI=; b=EJou14HWMF9TnqY65yCXDkArWGZrRZgTgyL2WbuBgNQJ5UBsWnhSnqRsCVXFkJq/E+ t2ijrliZfBz3PF7rAzCZQbpQzErZFnZAoYS1X1A8hYFKk7NBPK6OI0xegioPuq646QbF /9zAERGTYIRUJaCXeAic4T5DBXXKviGMxNp6sSy8BI+0kLu4IZNFIZjkgLFwHfd5Bzhx 7+mjH+KUREaQhWaG9bRz8Lc8x7eKupB2CqDymHcBXAlAuR7nb0Yl1f/+4oQIcbDqKZVu zIJS74JJ9NeayQpPeLLjrF39b/nh4h13YW44NC9a/kolLVzn49BqG1/D67+GvxR83OJJ iYpw== X-Received: by 10.42.70.142 with SMTP id f14mr9850373icj.3.1360340406786; Fri, 08 Feb 2013 08:20:06 -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 fa6sm15721551igb.2.2013.02.08.08.20.04 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Feb 2013 08:20:05 -0800 (PST) Message-ID: <511525B3.30108@inktank.com> Date: Fri, 08 Feb 2013 10:20:03 -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] libceph: allow STAT osd operations X-Gm-Message-State: ALoCoQkUZmj8URc4rrNbRg4407oAyreItEejp88pYjpnRzVQ9lFmHnVGiOcQEgdiSCvNIFGxBPsj Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Add support for CEPH_OSD_OP_STAT operations in the osd client and in rbd. This operation sends no data to the osd; everything required is encoded in identity of the target object. The result will be ENOENT if the object doesn't exist. If it does exist and no other error occurs the server returns the size and last modification time of the target object as output data (in little endian format). The size is a 64 bit unsigned and the time is ceph_timespec structure (two unsigned 32-bit integers, representing a seconds and nanoseconds value). This resolves: http://tracker.ceph.com/issues/4007 Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 15 +++++++++++++++ net/ceph/osd_client.c | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) case CEPH_OSD_OP_CMPXATTR: diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 6e9e2c2..37361bd 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1148,6 +1148,8 @@ struct ceph_osd_req_op *rbd_osd_req_op_create(u16 opcode, ...) if (opcode == CEPH_OSD_OP_WRITE) op->payload_len = op->extent.length; break; + case CEPH_OSD_OP_STAT: + break; case CEPH_OSD_OP_CALL: /* rbd_osd_req_op_create(CALL, class, method, data, datalen) */ op->cls.class_name = va_arg(args, char *); @@ -1277,6 +1279,16 @@ static void rbd_osd_write_callback(struct rbd_obj_request *obj_request, obj_request_done_set(obj_request); } +/* + * For a simple stat call there's nothing to do. We'll do more if + * this is part of a write sequence for a layered image. + */ +static void rbd_osd_stat_callback(struct rbd_obj_request *obj_request, + struct ceph_osd_op *op) +{ + obj_request_done_set(obj_request); +} + static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, struct ceph_msg *msg) { @@ -1307,6 +1319,9 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, case CEPH_OSD_OP_WRITE: rbd_osd_write_callback(obj_request, op); break; + case CEPH_OSD_OP_STAT: + rbd_osd_stat_callback(obj_request, op); + break; case CEPH_OSD_OP_CALL: case CEPH_OSD_OP_NOTIFY_ACK: case CEPH_OSD_OP_WATCH: diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index d9d58bb..3e4d8c4 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -244,7 +244,8 @@ static void osd_req_encode_op(struct ceph_osd_request *req, dst->extent.truncate_seq = cpu_to_le32(src->extent.truncate_seq); break; - + case CEPH_OSD_OP_STAT: + break; case CEPH_OSD_OP_GETXATTR: case CEPH_OSD_OP_SETXATTR: