mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-05 22:28:00 +00:00
vfs: Move mark_inode_dirty() from under page lock in generic_write_end()
There's no need to call mark_inode_dirty() under page lock in generic_write_end(). It unnecessarily makes hold time of page lock longer and more importantly it forces locking order of page lock and transaction start for journaling filesystems. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
parent
2e9ee85035
commit
c7d206b337
1 changed files with 11 additions and 1 deletions
12
fs/buffer.c
12
fs/buffer.c
|
@ -2061,6 +2061,7 @@ int generic_write_end(struct file *file, struct address_space *mapping,
|
||||||
struct page *page, void *fsdata)
|
struct page *page, void *fsdata)
|
||||||
{
|
{
|
||||||
struct inode *inode = mapping->host;
|
struct inode *inode = mapping->host;
|
||||||
|
int i_size_changed = 0;
|
||||||
|
|
||||||
copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
|
copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
|
||||||
|
|
||||||
|
@ -2073,12 +2074,21 @@ int generic_write_end(struct file *file, struct address_space *mapping,
|
||||||
*/
|
*/
|
||||||
if (pos+copied > inode->i_size) {
|
if (pos+copied > inode->i_size) {
|
||||||
i_size_write(inode, pos+copied);
|
i_size_write(inode, pos+copied);
|
||||||
mark_inode_dirty(inode);
|
i_size_changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
page_cache_release(page);
|
page_cache_release(page);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't mark the inode dirty under page lock. First, it unnecessarily
|
||||||
|
* makes the holding time of page lock longer. Second, it forces lock
|
||||||
|
* ordering of page lock and transaction start for journaling
|
||||||
|
* filesystems.
|
||||||
|
*/
|
||||||
|
if (i_size_changed)
|
||||||
|
mark_inode_dirty(inode);
|
||||||
|
|
||||||
return copied;
|
return copied;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(generic_write_end);
|
EXPORT_SYMBOL(generic_write_end);
|
||||||
|
|
Loading…
Add table
Reference in a new issue