From patchwork Wed Nov 27 13:40:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 3247961 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3BF86C045B for ; Wed, 27 Nov 2013 13:42:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E8D8C205D4 for ; Wed, 27 Nov 2013 13:42:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF692205BE for ; Wed, 27 Nov 2013 13:41:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753890Ab3K0Nlp (ORCPT ); Wed, 27 Nov 2013 08:41:45 -0500 Received: from m59-178.qiye.163.com ([123.58.178.59]:48506 "EHLO m59-178.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752983Ab3K0NlZ (ORCPT ); Wed, 27 Nov 2013 08:41:25 -0500 Received: from localhost.localdomain (unknown [222.240.177.34]) by m59-178.qiye.163.com (HMail) with ESMTPA id EA84F1485362; Wed, 27 Nov 2013 21:41:21 +0800 (CST) From: Li Wang To: Cc: Sage Weil , Li Wang , Yunchuan Wen Subject: [PATCH 15/18] client: Add inline data migration helper Date: Wed, 27 Nov 2013 21:40:54 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: X-HM-Spam-Status: e1koWUFPN1dZCBgUCR5ZQUpMVUNJQkJCQkJJSExLTUtOTldZCQ4XHghZQV koKz0kKDQ9Lz06MjckMjUkMz46Pz4pQUtVS0A2IyQiPigkMjUkMz46Pz4pQUtVS0ArLykkNTQkMj UkMz46Pz4pQUlVS0A4NC41LykiJDg1QUtVS0ApPjwyNDUkOigyOkFLVUtAKyk0LTI1OD4kMy41Oj VBS1VLQD8iNTo2MjgkMiskNTQkMjUkMz46Pz4pQUtVS0ApPjo3JDIrJDI1JCk5NyQyNSQzPjo*Pi lBSklVS0A2LjcvMiQpOCsvJD8yPT0#KT41LyQyNSQzPjo*PilBSVVLQDIrJC80PzoiJDg1LyRLJE pLS0FLVUtAMiskSiQzNC4pJDg1LyRLJEpLS0FLVUtAMiskSiQ2MjUuLz4kODUvJEpLJE5LQUtVS0 AyKyRISyQ2MjUuLz4kODUvJEskTktBS1VLQDIrJE4kNjI1Li8#JDg1LyRKSyROS0FLVUtAKC45JD 5BSlVOTkA9NSQoLjkkPjUsNCk*KCQzNzEkSktLSUtKQUtVSUNZBg++ X-HM-Sender-Digest: e1kSHx4VD1lBWUc6MQg6Cjo4LDo4EDorKjhIOj4qOkMwCjFVSlVKSENO Tk5CTUNJSk1CVTMWGhIXVRcSDBoVHDsOGQ4VDw4QAhcSFVUYFBZFWVdZDB4ZWUEdGhcIHldZCAFZ QUhOTEg3V1kSC1lBWUlJSVVJT0tVSkxMVUhPWQY+ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Signed-off-by: Yunchuan Wen Signed-off-by: Li Wang --- src/client/Client.cc | 41 +++++++++++++++++++++++++++++++++++++++++ src/client/Client.h | 3 +++ 2 files changed, 44 insertions(+) diff --git a/src/client/Client.cc b/src/client/Client.cc index 3beab8f..bbd56f2 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -5767,6 +5767,47 @@ void Client::unlock_fh_pos(Fh *f) f->pos_locked = false; } +int Client::uninline_data(Inode *in, Context *onfinish) +{ + char oid_buf[32]; + snprintf(oid_buf, sizeof(oid_buf), "%llx.00000000", (long long unsigned)in->ino); + object_t oid = oid_buf; + + ObjectOperation create_ops; + create_ops.create(false); + + objecter->mutate(oid, + OSDMap::file_to_object_locator(in->layout), + create_ops, + in->snaprealm->get_snap_context(), + ceph_clock_now(cct), + 0, + NULL, + NULL); + + bufferlist inline_version_bl; + ::encode(in->inline_version, inline_version_bl); + + ObjectOperation uninline_ops; + uninline_ops.cmpxattr("inline_version", + CEPH_OSD_CMPXATTR_OP_GT, + CEPH_OSD_CMPXATTR_MODE_U64, + inline_version_bl); + bufferlist inline_data = in->inline_data; + uninline_ops.write(0, inline_data, in->truncate_size, in->truncate_seq); + uninline_ops.setxattr("inline_version", inline_version_bl); + + objecter->mutate(oid, + OSDMap::file_to_object_locator(in->layout), + uninline_ops, + in->snaprealm->get_snap_context(), + ceph_clock_now(cct), + 0, + NULL, + onfinish); + + return 0; +} // diff --git a/src/client/Client.h b/src/client/Client.h index 48f1fea..63f0c41 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -429,6 +429,9 @@ protected: void handle_lease(MClientLease *m); + // inline data + int uninline_data(Inode *in, Context *onfinish); + // file caps void check_cap_issue(Inode *in, Cap *cap, unsigned issued); void add_update_cap(Inode *in, MetaSession *session, uint64_t cap_id,