mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-03 00:54:09 +08:00
ubifs: Set page uptodate in the correct place
[ Upstream commit723012cab7
] Page cache reads are lockless, so setting the freshly allocated page uptodate before we've overwritten it with the data it's supposed to have in it will allow a simultaneous reader to see old data. Move the call to SetPageUptodate into ubifs_write_end(), which is after we copied the new data into the page. Fixes:1e51764a3c
("UBIFS: add new flash file system") Cc: stable@vger.kernel.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
ab8f9df106
commit
fc99f4e2d2
@ -261,9 +261,6 @@ static int write_begin_slow(struct address_space *mapping,
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
SetPageUptodate(page);
|
||||
ClearPageError(page);
|
||||
}
|
||||
|
||||
if (PagePrivate(page))
|
||||
@ -462,9 +459,6 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping,
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
SetPageUptodate(page);
|
||||
ClearPageError(page);
|
||||
}
|
||||
|
||||
err = allocate_budget(c, page, ui, appending);
|
||||
@ -474,10 +468,8 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping,
|
||||
* 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) {
|
||||
if (skipped_read)
|
||||
ClearPageChecked(page);
|
||||
ClearPageUptodate(page);
|
||||
}
|
||||
/*
|
||||
* Budgeting failed which means it would have to force
|
||||
* write-back but didn't, because we set the @fast flag in the
|
||||
@ -568,6 +560,9 @@ static int ubifs_write_end(struct file *file, struct address_space *mapping,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (len == PAGE_SIZE)
|
||||
SetPageUptodate(page);
|
||||
|
||||
if (!PagePrivate(page)) {
|
||||
attach_page_private(page, (void *)1);
|
||||
atomic_long_inc(&c->dirty_pg_cnt);
|
||||
|
Loading…
Reference in New Issue
Block a user