|
@@ -430,6 +430,7 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping,
|
|
struct ubifs_inode *ui = ubifs_inode(inode);
|
|
struct ubifs_inode *ui = ubifs_inode(inode);
|
|
pgoff_t index = pos >> PAGE_CACHE_SHIFT;
|
|
pgoff_t index = pos >> PAGE_CACHE_SHIFT;
|
|
int uninitialized_var(err), appending = !!(pos + len > inode->i_size);
|
|
int uninitialized_var(err), appending = !!(pos + len > inode->i_size);
|
|
|
|
+ int skipped_read = 0;
|
|
struct page *page;
|
|
struct page *page;
|
|
|
|
|
|
ubifs_assert(ubifs_inode(inode)->ui_size == inode->i_size);
|
|
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,
|
|
|
|
|
|
if (!PageUptodate(page)) {
|
|
if (!PageUptodate(page)) {
|
|
/* The page is not loaded from the flash */
|
|
/* The page is not loaded from the flash */
|
|
- if (!(pos & ~PAGE_CACHE_MASK) && len == PAGE_CACHE_SIZE)
|
|
|
|
|
|
+ if (!(pos & ~PAGE_CACHE_MASK) && len == PAGE_CACHE_SIZE) {
|
|
/*
|
|
/*
|
|
* We change whole page so no need to load it. But we
|
|
* We change whole page so no need to load it. But we
|
|
* have to set the @PG_checked flag to make the further
|
|
* 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,
|
|
* the media.
|
|
* the media.
|
|
*/
|
|
*/
|
|
SetPageChecked(page);
|
|
SetPageChecked(page);
|
|
- else {
|
|
|
|
|
|
+ skipped_read = 1;
|
|
|
|
+ } else {
|
|
err = do_readpage(page);
|
|
err = do_readpage(page);
|
|
if (err) {
|
|
if (err) {
|
|
unlock_page(page);
|
|
unlock_page(page);
|
|
@@ -469,6 +471,14 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping,
|
|
err = allocate_budget(c, page, ui, appending);
|
|
err = allocate_budget(c, page, ui, appending);
|
|
if (unlikely(err)) {
|
|
if (unlikely(err)) {
|
|
ubifs_assert(err == -ENOSPC);
|
|
ubifs_assert(err == -ENOSPC);
|
|
|
|
+ /*
|
|
|
|
+ * If we skipped reading the page because we were going to
|
|
|
|
+ * write all of it, then it is not up to date.
|
|
|
|
+ */
|
|
|
|
+ if (skipped_read) {
|
|
|
|
+ ClearPageChecked(page);
|
|
|
|
+ ClearPageUptodate(page);
|
|
|
|
+ }
|
|
/*
|
|
/*
|
|
* Budgeting failed which means it would have to force
|
|
* Budgeting failed which means it would have to force
|
|
* write-back but didn't, because we set the @fast flag in the
|
|
* write-back but didn't, because we set the @fast flag in the
|