From patchwork Thu Jul 30 13:41:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6902641 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5208B9F39D for ; Thu, 30 Jul 2015 13:41:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7533C205B4 for ; Thu, 30 Jul 2015 13:41:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8B96D20592 for ; Thu, 30 Jul 2015 13:41:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750789AbbG3Nl4 (ORCPT ); Thu, 30 Jul 2015 09:41:56 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:34675 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750734AbbG3Nl4 (ORCPT ); Thu, 30 Jul 2015 09:41:56 -0400 Received: by pacan13 with SMTP id an13so24306224pac.1 for ; Thu, 30 Jul 2015 06:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=x43hTuspktDpF3R+j1c70MfPHUMxMQkzt2y/Uiq/Tg4=; b=Fn12k4WaAxV9vT7LOKyftmiQpWXgb/b0sIAPGRqeW9U9fs1G7j1IdV75j3yCH+3Sev wo9yD6YtTkaXad24D2td33iJj92kFcmVqBaWE017cbRC18lOkSKzF7VjItaNN2wGUpsx nAvstxZTNkmgY7UbtrAa6ps2tmO1CaN2r5dv1EZ0Az9lNJsu6JwWczdxwEyPFGPOW8aG Gvu89yOEiaNppdt5hdOzl4Jzc77HuXH+e5x1QbFEjPYa5ULGao/TCTQixGlbsrV6N1fR eAUkgMo0rCqVE18VNixKvHrMrpQFjPQp+8EnJ78dEh/FJFnvW2mQmpumIZKEuCL7251+ 6AhQ== X-Received: by 10.66.66.163 with SMTP id g3mr84401713pat.85.1438263715829; Thu, 30 Jul 2015 06:41:55 -0700 (PDT) Received: from [192.168.99.8] ([104.143.41.79]) by smtp.googlemail.com with ESMTPSA id pb2sm2414001pdb.2.2015.07.30.06.41.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jul 2015 06:41:55 -0700 (PDT) Message-ID: <55BA2996.9030804@gmail.com> Date: Thu, 30 Jul 2015 21:41:42 +0800 From: Kinglong Mee User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Trond Myklebust CC: "linux-nfs@vger.kernel.org" , kinglongmee@gmail.com Subject: [PATCH 3/7 v2] NFS: Check size by inode_newsize_ok in nfs_setattr References: <55BA290B.2020704@gmail.com> <55BA2936.4030404@gmail.com> In-Reply-To: <55BA2936.4030404@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-8.2 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 Set rlimit for NFS's files is useless right now. For local process's rlimit, it should be checked by nfs client. The same, CIFS also call inode_change_ok checking rlimit at its client in cifs_setattr_nounix() and cifs_setattr_unix(). v2, same as v1. Signed-off-by: Kinglong Mee --- fs/nfs/inode.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 0adc7d2..9304dfd 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -513,15 +513,14 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) attr->ia_valid &= ~ATTR_MODE; if (attr->ia_valid & ATTR_SIZE) { - loff_t i_size; - BUG_ON(!S_ISREG(inode->i_mode)); - i_size = i_size_read(inode); - if (attr->ia_size == i_size) + error = inode_newsize_ok(inode, attr->ia_size); + if (error) + return error; + + if (attr->ia_size == i_size_read(inode)) attr->ia_valid &= ~ATTR_SIZE; - else if (attr->ia_size < i_size && IS_SWAPFILE(inode)) - return -ETXTBSY; } /* Optimization: if the end result is no change, don't RPC */