diff options
author | Richard Weinberger <richard@nod.at> | 2015-03-04 06:44:03 -0500 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2015-03-26 18:27:53 -0400 |
commit | b86b413a321105cb75373b48fd7ba53fcbc7ec4c (patch) | |
tree | 29e08921ac4ed420361003277ea5cb82e26766ff /fs | |
parent | bd1052a245c004068a7123aa077c576be64639e4 (diff) |
hostfs: Set page flags in hostfs_readpage() correctly
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/hostfs/hostfs_kern.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index cf80a30058b0..f1547479e62e 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -445,24 +445,26 @@ static int hostfs_readpage(struct file *file, struct page *page) | |||
445 | { | 445 | { |
446 | char *buffer; | 446 | char *buffer; |
447 | long long start; | 447 | long long start; |
448 | int bytes_read, ret; | 448 | int bytes_read, ret = 0; |
449 | 449 | ||
450 | start = (long long) page->index << PAGE_CACHE_SHIFT; | 450 | start = (long long) page->index << PAGE_CACHE_SHIFT; |
451 | buffer = kmap(page); | 451 | buffer = kmap(page); |
452 | bytes_read = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer, | 452 | bytes_read = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer, |
453 | PAGE_CACHE_SIZE); | 453 | PAGE_CACHE_SIZE); |
454 | if (bytes_read < 0) { | 454 | if (bytes_read < 0) { |
455 | ClearPageUptodate(page); | ||
456 | SetPageError(page); | ||
455 | ret = bytes_read; | 457 | ret = bytes_read; |
456 | goto out; | 458 | goto out; |
457 | } | 459 | } |
458 | 460 | ||
459 | memset(buffer + bytes_read, 0, PAGE_CACHE_SIZE - bytes_read); | 461 | memset(buffer + bytes_read, 0, PAGE_CACHE_SIZE - bytes_read); |
460 | 462 | ||
461 | flush_dcache_page(page); | 463 | ClearPageError(page); |
462 | SetPageUptodate(page); | 464 | SetPageUptodate(page); |
463 | if (PageError(page)) ClearPageError(page); | 465 | |
464 | ret = 0; | ||
465 | out: | 466 | out: |
467 | flush_dcache_page(page); | ||
466 | kunmap(page); | 468 | kunmap(page); |
467 | unlock_page(page); | 469 | unlock_page(page); |
468 | return ret; | 470 | return ret; |