From patchwork Thu Jul 11 08:59:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: majianpeng X-Patchwork-Id: 2826067 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 5BDCC9F7D6 for ; Thu, 11 Jul 2013 09:00:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CF7DF20121 for ; Thu, 11 Jul 2013 09:00:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BF0C42011B for ; Thu, 11 Jul 2013 09:00:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755618Ab3GKJAG (ORCPT ); Thu, 11 Jul 2013 05:00:06 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:43345 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755797Ab3GKJAE (ORCPT ); Thu, 11 Jul 2013 05:00:04 -0400 Received: by mail-pd0-f172.google.com with SMTP id z10so7303965pdj.17 for ; Thu, 11 Jul 2013 02:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:reply-to:subject:x-priority:x-guid:x-has-attach :x-mailer:mime-version:message-id:content-type :content-transfer-encoding; bh=j3mm1JgdToIAkKTEat+GfeOHYnlTlJfv4Jh2raKhEgo=; b=UZVPDlpJBNBWN2T3tvl6qbq4zlVebyrslEq0QTlecccRRS9/h85gZzkR0GAxZlzYgL FGW+Pg5jt3292PkrPT41ki6Y040hfSwBb6n2sFPZtU3oGekbAp92bGgkmSd7piPvTZkO gDPDFb7xDFSJ/2jlHB2YZPxcJz8CJIClVAQvGAZSbxJIfZvfmB/iAscwKPnZT6j7ocCo mP7K8vqAaRhrw/YthechNscrejQLfMOA3YCC2FLnQJoRfYWloJat6LbMz7irc33gznBR +nCoZgtwRMa3dKKI7qucgsbjcryzqOrzDQmNxEzqiFlrFxLbLhVN+pHhtMYy2c9HemzU xNoQ== X-Received: by 10.67.1.33 with SMTP id bd1mr37750413pad.75.1373533204094; Thu, 11 Jul 2013 02:00:04 -0700 (PDT) Received: from majianpeng ([218.242.10.182]) by mx.google.com with ESMTPSA id re16sm41010928pac.16.2013.07.11.02.00.01 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 11 Jul 2013 02:00:03 -0700 (PDT) Date: Thu, 11 Jul 2013 16:59:55 +0800 From: majianpeng To: sage Cc: ceph-devel Reply-To: majianpeng Subject: [PATCH] ceph: Don't get layout from mds for regular file which has been written. X-Priority: 3 X-GUID: FA1DDF70-A104-493C-9F57-DA466F7F057C X-Has-Attach: no X-Mailer: Foxmail 7.0.1.90[en] Mime-Version: 1.0 Message-ID: <201307111659490192618@gmail.com> 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.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 For regular file which has been written, it can't change layout. So it can get layout from local rather than mds. Signed-off-by: Jianpeng Ma --- fs/ceph/ioctl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- 1.8.1.2 diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index e0b4ef3..2b74879 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c @@ -17,10 +17,16 @@ static long ceph_ioctl_get_layout(struct file *file, void __user *arg) { struct ceph_inode_info *ci = ceph_inode(file_inode(file)); + struct inode *inode = file_inode(file); struct ceph_ioctl_layout l; - int err; + int err = 0; + + /*For regular file which has been written,it can't change layout + * So it don't get layout from mds*/ + if (!(S_ISREG(inode->i_mode) && (i_size_read(inode) > 0 || + ci->i_truncate_seq > 1))) + err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT); - err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT); if (!err) { l.stripe_unit = ceph_file_layout_su(ci->i_layout); l.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);