From patchwork Fri Nov 30 05:54:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 1823691 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 3A8903FC23 for ; Fri, 30 Nov 2012 05:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751705Ab2K3FyJ (ORCPT ); Fri, 30 Nov 2012 00:54:09 -0500 Received: from mga11.intel.com ([192.55.52.93]:60510 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751167Ab2K3FyI (ORCPT ); Fri, 30 Nov 2012 00:54:08 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 29 Nov 2012 21:54:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,189,1355126400"; d="scan'208";a="257001142" Received: from zyan5-mobl.sh.intel.com ([10.239.36.120]) by fmsmga002.fm.intel.com with ESMTP; 29 Nov 2012 21:54:07 -0800 From: "Yan, Zheng" To: ceph-devel@vger.kernel.org, sage@inktank.com Cc: "Yan, Zheng" Subject: [PATCH] ceph: re-calculate truncate_size for strip object Date: Fri, 30 Nov 2012 13:54:05 +0800 Message-Id: <1354254845-24621-1-git-send-email-zheng.z.yan@intel.com> X-Mailer: git-send-email 1.7.11.7 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: "Yan, Zheng" Otherwise osd may truncate the object to larger size. Signed-off-by: Yan, Zheng --- net/ceph/osd_client.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index ccbdfbb..f8b0e56 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -76,8 +76,16 @@ int ceph_calc_raw_layout(struct ceph_osd_client *osdc, orig_len - *plen, off, *plen); if (op_has_extent(op->op)) { + u32 osize = le32_to_cpu(layout->fl_object_size); op->extent.offset = objoff; op->extent.length = objlen; + if (op->extent.truncate_size <= off - objoff) { + op->extent.truncate_size = 0; + } else { + op->extent.truncate_size -= off - objoff; + if (op->extent.truncate_size > osize) + op->extent.truncate_size = osize; + } } req->r_num_pages = calc_pages_for(off, *plen); req->r_page_alignment = off & ~PAGE_MASK;