aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2018-10-20 00:57:57 +0100
committerDavid Howells <dhowells@redhat.com>2018-10-24 00:41:08 +0100
commit2a0b4f64c9edcdcb67306f26d9d08ef982cb0ccd (patch)
tree41ff1bb90207bd31a39d5490e1304844c90e39a4 /fs
parentafs: Add a couple of tracepoints to log I/O errors (diff)
downloadlinux-dev-2a0b4f64c9edcdcb67306f26d9d08ef982cb0ccd.tar.xz
linux-dev-2a0b4f64c9edcdcb67306f26d9d08ef982cb0ccd.zip
afs: Don't invoke the server to read data beyond EOF
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 <dhowells@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/afs/write.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/afs/write.c b/fs/afs/write.c
index fdb9d6024126..11066a3248ba 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) + sizeof(struct page *),
GFP_KERNEL);
if (!req)