Skip to content

Commit

Permalink
hostfs: Make hostfs_readpage more readable
Browse files Browse the repository at this point in the history
...to make life easier for future readers of that code.

Signed-off-by: Richard Weinberger <richard@nod.at>
  • Loading branch information
Richard Weinberger committed Mar 26, 2015
1 parent 2ad2dca commit 41761dd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fs/hostfs/hostfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,25 +439,27 @@ static int hostfs_readpage(struct file *file, struct page *page)
{
char *buffer;
long long start;
int err = 0;
int bytes_read, ret;

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

memset(&buffer[err], 0, PAGE_CACHE_SIZE - err);
memset(buffer + bytes_read, 0, PAGE_CACHE_SIZE - bytes_read);

flush_dcache_page(page);
SetPageUptodate(page);
if (PageError(page)) ClearPageError(page);
err = 0;
ret = 0;
out:
kunmap(page);
unlock_page(page);
return err;
return ret;
}

static int hostfs_write_begin(struct file *file, struct address_space *mapping,
Expand Down

0 comments on commit 41761dd

Please sign in to comment.