diff options
author | David Howells <dhowells@redhat.com> | 2018-10-19 19:57:57 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2018-10-23 19:41:08 -0400 |
commit | 2a0b4f64c9edcdcb67306f26d9d08ef982cb0ccd (patch) | |
tree | 41ff1bb90207bd31a39d5490e1304844c90e39a4 /fs/afs/write.c | |
parent | f51375cd9e1ad75e9e38186aa0d3749ade7d52a5 (diff) |
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/afs/write.c')
-rw-r--r-- | fs/afs/write.c | 11 |
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, | |||
33 | loff_t pos, unsigned int len, struct page *page) | 33 | loff_t pos, unsigned int len, struct page *page) |
34 | { | 34 | { |
35 | struct afs_read *req; | 35 | struct afs_read *req; |
36 | size_t p; | ||
37 | void *data; | ||
36 | int ret; | 38 | int ret; |
37 | 39 | ||
38 | _enter(",,%llu", (unsigned long long)pos); | 40 | _enter(",,%llu", (unsigned long long)pos); |
39 | 41 | ||
42 | if (pos >= vnode->vfs_inode.i_size) { | ||
43 | p = pos & ~PAGE_MASK; | ||
44 | ASSERTCMP(p + len, <=, PAGE_SIZE); | ||
45 | data = kmap(page); | ||
46 | memset(data + p, 0, len); | ||
47 | kunmap(page); | ||
48 | return 0; | ||
49 | } | ||
50 | |||
40 | req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *), | 51 | req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *), |
41 | GFP_KERNEL); | 52 | GFP_KERNEL); |
42 | if (!req) | 53 | if (!req) |