From patchwork Thu Jul 11 02:04:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: majianpeng X-Patchwork-Id: 2825969 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 01C989F756 for ; Thu, 11 Jul 2013 02:05:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 795252010B for ; Thu, 11 Jul 2013 02:05:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE3E920109 for ; Thu, 11 Jul 2013 02:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755163Ab3GKCFC (ORCPT ); Wed, 10 Jul 2013 22:05:02 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:65031 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754922Ab3GKCFB (ORCPT ); Wed, 10 Jul 2013 22:05:01 -0400 Received: by mail-pb0-f46.google.com with SMTP id rq2so7368550pbb.33 for ; Wed, 10 Jul 2013 19:05:00 -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=yAQ0rG/XWA/clPTqhLwJXbLeAQlpRAmlySoBsTRUJK8=; b=Xcc+/0rRXrVczIOwdvpfCZix6EUTAAHHNEgJ/AQXGa9rhQeBu0mc0sSMWX4ZQlKTcj utQVMv2RTa3Q7Kg5kPa1k2O5Gp1D7LQgaqA6LeA3KLlcoRTOOF+NndJuEz1E9pz19RxC kgv+fK9N3l0TxpevC1t1gUVq8aU4jFyORTahhaMz85DfC8Y7uJA6SCmTtOrgr7nCtofx oYinPrVPIEH9PvvtTn8UxokAYr4mosv6xGOJOpUZJ/YKxcn5bIcUvjsg0yu4heLnKYgC UUoCFK9Hz41ffK3yprL/rtRJ8Xtq3RbXgmOWfO6yNAcg+8+fLOgRbh0BzeUI2trrONNy xY5g== X-Received: by 10.68.163.195 with SMTP id yk3mr12084345pbb.142.1373508300693; Wed, 10 Jul 2013 19:05:00 -0700 (PDT) Received: from majianpeng ([218.242.10.182]) by mx.google.com with ESMTPSA id it7sm4771010pbc.25.2013.07.10.19.04.55 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 10 Jul 2013 19:04:59 -0700 (PDT) Date: Thu, 11 Jul 2013 10:04:49 +0800 From: majianpeng To: sage Cc: ceph-devel Reply-To: majianpeng Subject: [PATCH] ceph: Don't do set_layout for file which has been written. X-Priority: 3 X-GUID: B74CF252-B043-414E-BE19-4EF92028CAB2 X-Has-Attach: no X-Mailer: Foxmail 7.0.1.90[en] Mime-Version: 1.0 Message-ID: <201307111004467716774@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 Cephfs don't change the layout which has been written.So add this check before do. Signed-off-by: Jianpeng Ma --- fs/ceph/ioctl.c | 3 +++ 1 file changed, 3 insertions(+) -- 1.8.1.2 diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index e0b4ef3..cbea896 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c @@ -72,6 +72,9 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) struct ceph_ioctl_layout nl; int err; + /*Only for file which has never been written*/ + if (i_size_read(inode) > 0 || ci->i_truncate_seq > 1) + return -ENOTEMPTY; if (copy_from_user(&l, arg, sizeof(l))) return -EFAULT;