diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-06 18:00:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-06 18:00:19 -0400 |
commit | e0724bf6e4a1f2e678d2b2aab01cae22e17862f0 (patch) | |
tree | 559a8fa8e7a92f8ae0e0a27d4e71f408fa7cec62 /fs/ubifs/file.c | |
parent | 38d9aefb5ce8f26358b0d5cd933cfa9e267105b1 (diff) | |
parent | de0975781a1a8bc92e07eb7681d10ef9bb5e6df9 (diff) |
Merge branch 'linux-next' of git://git.infradead.org/ubifs-2.6
* 'linux-next' of git://git.infradead.org/ubifs-2.6:
UBIFS: fix recovery bug
UBIFS: add R/O compatibility
UBIFS: fix compiler warnings
UBIFS: fully sort GCed nodes
UBIFS: fix commentaries
UBIFS: introduce a helpful variable
UBIFS: use KERN_CONT
UBIFS: fix lprops committing bug
UBIFS: fix bogus assertion
UBIFS: fix bug where page is marked uptodate when out of space
UBIFS: amend key_hash return value
UBIFS: improve find function interface
UBIFS: list usage cleanup
UBIFS: fix dbg_chk_lpt_sz()
Diffstat (limited to 'fs/ubifs/file.c')
-rw-r--r-- | fs/ubifs/file.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 0ff89fe71e51..6d34dc7e33e1 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c | |||
@@ -430,6 +430,7 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping, | |||
430 | struct ubifs_inode *ui = ubifs_inode(inode); | 430 | struct ubifs_inode *ui = ubifs_inode(inode); |
431 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; | 431 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; |
432 | int uninitialized_var(err), appending = !!(pos + len > inode->i_size); | 432 | int uninitialized_var(err), appending = !!(pos + len > inode->i_size); |
433 | int skipped_read = 0; | ||
433 | struct page *page; | 434 | struct page *page; |
434 | 435 | ||
435 | ubifs_assert(ubifs_inode(inode)->ui_size == inode->i_size); | 436 | ubifs_assert(ubifs_inode(inode)->ui_size == inode->i_size); |
@@ -444,7 +445,7 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping, | |||
444 | 445 | ||
445 | if (!PageUptodate(page)) { | 446 | if (!PageUptodate(page)) { |
446 | /* The page is not loaded from the flash */ | 447 | /* The page is not loaded from the flash */ |
447 | if (!(pos & ~PAGE_CACHE_MASK) && len == PAGE_CACHE_SIZE) | 448 | if (!(pos & ~PAGE_CACHE_MASK) && len == PAGE_CACHE_SIZE) { |
448 | /* | 449 | /* |
449 | * We change whole page so no need to load it. But we | 450 | * We change whole page so no need to load it. But we |
450 | * have to set the @PG_checked flag to make the further | 451 | * have to set the @PG_checked flag to make the further |
@@ -453,7 +454,8 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping, | |||
453 | * the media. | 454 | * the media. |
454 | */ | 455 | */ |
455 | SetPageChecked(page); | 456 | SetPageChecked(page); |
456 | else { | 457 | skipped_read = 1; |
458 | } else { | ||
457 | err = do_readpage(page); | 459 | err = do_readpage(page); |
458 | if (err) { | 460 | if (err) { |
459 | unlock_page(page); | 461 | unlock_page(page); |
@@ -470,6 +472,14 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping, | |||
470 | if (unlikely(err)) { | 472 | if (unlikely(err)) { |
471 | ubifs_assert(err == -ENOSPC); | 473 | ubifs_assert(err == -ENOSPC); |
472 | /* | 474 | /* |
475 | * If we skipped reading the page because we were going to | ||
476 | * write all of it, then it is not up to date. | ||
477 | */ | ||
478 | if (skipped_read) { | ||
479 | ClearPageChecked(page); | ||
480 | ClearPageUptodate(page); | ||
481 | } | ||
482 | /* | ||
473 | * Budgeting failed which means it would have to force | 483 | * Budgeting failed which means it would have to force |
474 | * write-back but didn't, because we set the @fast flag in the | 484 | * write-back but didn't, because we set the @fast flag in the |
475 | * request. Write-back cannot be done now, while we have the | 485 | * request. Write-back cannot be done now, while we have the |
@@ -949,7 +959,7 @@ static int do_writepage(struct page *page, int len) | |||
949 | * whole index and correct all inode sizes, which is long an unacceptable. | 959 | * whole index and correct all inode sizes, which is long an unacceptable. |
950 | * | 960 | * |
951 | * To prevent situations like this, UBIFS writes pages back only if they are | 961 | * To prevent situations like this, UBIFS writes pages back only if they are |
952 | * within last synchronized inode size, i.e. the the size which has been | 962 | * within the last synchronized inode size, i.e. the size which has been |
953 | * written to the flash media last time. Otherwise, UBIFS forces inode | 963 | * written to the flash media last time. Otherwise, UBIFS forces inode |
954 | * write-back, thus making sure the on-flash inode contains current inode size, | 964 | * write-back, thus making sure the on-flash inode contains current inode size, |
955 | * and then keeps writing pages back. | 965 | * and then keeps writing pages back. |