Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp865128imm; Thu, 13 Sep 2018 08:53:59 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdat/qZzuvW/WztEqKmz/AqaxkBTh57lcnutsfg3k+GR2pwTkPHTVesAxsdtf4S7Oikm6cuQ X-Received: by 2002:a65:5245:: with SMTP id q5-v6mr7608176pgp.67.1536854039552; Thu, 13 Sep 2018 08:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536854039; cv=none; d=google.com; s=arc-20160816; b=J7wDxS9lSeiqzQmYqfsVX2Ghz2PxcCKW+Vnds7Qu5811HhXASdcPSpeiTq+lOdRzz+ bCWsRjiaRxsBHAE9YosHCeX26Hw0wUd0Ez7NhH+j6fTfjKnmUdfd8hJm5+D7Fngf+JG6 o5yDDVVXPf9v6zlf74VhnPbY3IMDjNDXkDyxUr35ca+P1mq0EkozEVWawaxmOsM4kyYA lYv5F2iJ+yW2B8AM9v3zgjASW8bAz4rmUywb5wxHHGMZ1FAjX+UKhPswlZgy7/FtgcxB pbm6QcZnjerzphcNWA2XOPWpS82h15gS1zoZfgS3uMFfTt1k97LwFl2J1MXnNnrnyKqE IMrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization; bh=JYhrsimQdi8jbApo2Pw1qY77ld5Auxlt8n/WKiGhU5c=; b=Qy6B/JIuMiDAPy6Wf+kLycUqlRzwSFgD+IZyy6En1VkD6lpb1fWMqa/o0fXnCXucqK YICzklPCq2+bRttS50IcI02jyjW0T2ysnTpjfk/8vq/u1s45FhR8PH1CyH0I67MpbkhT PMW1+9B8mzWPzCXz1cA/RCuCrQIyrRQ1h57zSFQGTCwFfaGzoMTm65X+0pBbz2G76j6I JIjhr7kSzoiaKl4eOt7qhmi7xwgMsNnfiS2cYPS59oDZfO8PIojM917cqucrEEBE6yz/ oDQYCKXYFf/he/lhY221hh4PyHBEOEm4XzUB7ZiRD5uO7qvDPr/JwJ06S5GR8uJSUYCK b09g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9-v6si4563735pfh.240.2018.09.13.08.53.39; Thu, 13 Sep 2018 08:53:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728613AbeIMVDA (ORCPT + 99 others); Thu, 13 Sep 2018 17:03:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43968 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727730AbeIMVDA (ORCPT ); Thu, 13 Sep 2018 17:03:00 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B6DD3082B71; Thu, 13 Sep 2018 15:52:55 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-123-84.rdu2.redhat.com [10.10.123.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58AA62010CAA; Thu, 13 Sep 2018 15:52:54 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 10/10] afs: Don't invoke the server to read data beyond EOF From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Date: Thu, 13 Sep 2018 16:52:53 +0100 Message-ID: <153685397360.14766.7334506350410588863.stgit@warthog.procyon.org.uk> In-Reply-To: <153685389564.14766.11306559824641824935.stgit@warthog.procyon.org.uk> References: <153685389564.14766.11306559824641824935.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 13 Sep 2018 15:52:55 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When writing a new page, clear space in the page rather than attempting to load it from the server if the space is beyond the EOF. Signed-off-by: David Howells --- fs/afs/write.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/afs/write.c b/fs/afs/write.c index 1dfca4b722da..05e6bc620384 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -33,10 +33,21 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key, loff_t pos, unsigned int len, struct page *page) { struct afs_read *req; + size_t p; + void *data; int ret; _enter(",,%llu", (unsigned long long)pos); + if (pos >= vnode->vfs_inode.i_size) { + p = pos & ~PAGE_MASK; + ASSERTCMP(p + len, <=, PAGE_SIZE); + data = kmap(page); + memset(data + p, 0, len); + kunmap(page); + return 0; + } + req = kzalloc(sizeof(struct afs_read), GFP_KERNEL); if (!req) return -ENOMEM;