Skip to content

Commit 2a0b4f6

Browse files
committed
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 <[email protected]>
1 parent f51375c commit 2a0b4f6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

fs/afs/write.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,21 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
3333
loff_t pos, unsigned int len, struct page *page)
3434
{
3535
struct afs_read *req;
36+
size_t p;
37+
void *data;
3638
int ret;
3739

3840
_enter(",,%llu", (unsigned long long)pos);
3941

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+
4051
req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *),
4152
GFP_KERNEL);
4253
if (!req)

0 commit comments

Comments
 (0)