Skip to content

Commit

Permalink
hostfs: Set page flags in hostfs_readpage() correctly
Browse files Browse the repository at this point in the history
In case of an error set the page error flag and clear the up-to-date
flag.
If the read was successful clear the error flag unconditionally.

Signed-off-by: Richard Weinberger <richard@nod.at>
  • Loading branch information
richardweinberger committed Mar 26, 2015
1 parent bd1052a commit b86b413
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fs/hostfs/hostfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,24 +445,26 @@ static int hostfs_readpage(struct file *file, struct page *page)
{
char *buffer;
long long start;
int bytes_read, ret;
int bytes_read, ret = 0;

start = (long long) page->index << PAGE_CACHE_SHIFT;
buffer = kmap(page);
bytes_read = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer,
PAGE_CACHE_SIZE);
if (bytes_read < 0) {
ClearPageUptodate(page);
SetPageError(page);
ret = bytes_read;
goto out;
}

memset(buffer + bytes_read, 0, PAGE_CACHE_SIZE - bytes_read);

flush_dcache_page(page);
ClearPageError(page);
SetPageUptodate(page);
if (PageError(page)) ClearPageError(page);
ret = 0;

out:
flush_dcache_page(page);
kunmap(page);
unlock_page(page);
return ret;
Expand Down

0 comments on commit b86b413

Please sign in to comment.