Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 101898
b: refs/heads/master
c: efc91ed
h: refs/heads/master
v: v3
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Jul 9, 2008
1 parent 734c619 commit f947cea
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b390c2b55c830eb3b64633fa8d8b8837e073e458
refs/heads/master: efc91ed0191e3fc62bb1c556ac93fc4e661214d2
20 changes: 20 additions & 0 deletions trunk/fs/nfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,26 @@ static int nfs_write_end(struct file *file, struct address_space *mapping,
unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
int status;

/*
* Zero any uninitialised parts of the page, and then mark the page
* as up to date if it turns out that we're extending the file.
*/
if (!PageUptodate(page)) {
unsigned pglen = nfs_page_length(page);
unsigned end = offset + len;

if (pglen == 0) {
zero_user_segments(page, 0, offset,
end, PAGE_CACHE_SIZE);
SetPageUptodate(page);
} else if (end >= pglen) {
zero_user_segment(page, end, PAGE_CACHE_SIZE);
if (offset == 0)
SetPageUptodate(page);
} else
zero_user_segment(page, pglen, PAGE_CACHE_SIZE);
}

lock_kernel();
status = nfs_updatepage(file, page, offset, copied);
unlock_kernel();
Expand Down
12 changes: 3 additions & 9 deletions trunk/fs/nfs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx,
spin_unlock(&inode->i_lock);
radix_tree_preload_end();
req = new;
goto zero_page;
goto out;
}
spin_unlock(&inode->i_lock);

Expand Down Expand Up @@ -649,19 +649,13 @@ static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx,
req->wb_offset = offset;
req->wb_pgbase = offset;
req->wb_bytes = max(end, rqend) - req->wb_offset;
goto zero_page;
goto out;
}

if (end > rqend)
req->wb_bytes = end - req->wb_offset;

return req;
zero_page:
/* If this page might potentially be marked as up to date,
* then we need to zero any uninitalised data. */
if (req->wb_pgbase == 0 && req->wb_bytes != PAGE_CACHE_SIZE
&& !PageUptodate(req->wb_page))
zero_user_segment(req->wb_page, req->wb_bytes, PAGE_CACHE_SIZE);
out:
return req;
}

Expand Down

0 comments on commit f947cea

Please sign in to comment.