mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
kill spurious reference to vmtruncate
Lots of filesystems calls vmtruncate despite not implementing the old ->truncate method. Switch them to use simple_setsize and add some comments about the truncate code where it seems fitting. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Nick Piggin <[email protected]> Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
7bb46a6734
commit
15c6fd9786
10 changed files with 37 additions and 22 deletions
|
|
@ -967,12 +967,15 @@ static int do_writepage(struct page *page, int len)
|
|||
* the page locked, and it locks @ui_mutex. However, write-back does take inode
|
||||
* @i_mutex, which means other VFS operations may be run on this inode at the
|
||||
* same time. And the problematic one is truncation to smaller size, from where
|
||||
* we have to call 'vmtruncate()', which first changes @inode->i_size, then
|
||||
* we have to call 'simple_setsize()', which first changes @inode->i_size, then
|
||||
* drops the truncated pages. And while dropping the pages, it takes the page
|
||||
* lock. This means that 'do_truncation()' cannot call 'vmtruncate()' with
|
||||
* lock. This means that 'do_truncation()' cannot call 'simple_setsize()' with
|
||||
* @ui_mutex locked, because it would deadlock with 'ubifs_writepage()'. This
|
||||
* means that @inode->i_size is changed while @ui_mutex is unlocked.
|
||||
*
|
||||
* XXX: with the new truncate the above is not true anymore, the simple_setsize
|
||||
* calls can be replaced with the individual components.
|
||||
*
|
||||
* But in 'ubifs_writepage()' we have to guarantee that we do not write beyond
|
||||
* inode size. How do we do this if @inode->i_size may became smaller while we
|
||||
* are in the middle of 'ubifs_writepage()'? The UBIFS solution is the
|
||||
|
|
@ -1125,7 +1128,7 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
|
|||
budgeted = 0;
|
||||
}
|
||||
|
||||
err = vmtruncate(inode, new_size);
|
||||
err = simple_setsize(inode, new_size);
|
||||
if (err)
|
||||
goto out_budg;
|
||||
|
||||
|
|
@ -1214,7 +1217,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,
|
|||
|
||||
if (attr->ia_valid & ATTR_SIZE) {
|
||||
dbg_gen("size %lld -> %lld", inode->i_size, new_size);
|
||||
err = vmtruncate(inode, new_size);
|
||||
err = simple_setsize(inode, new_size);
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -1223,7 +1226,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,
|
|||
if (attr->ia_valid & ATTR_SIZE) {
|
||||
/* Truncation changes inode [mc]time */
|
||||
inode->i_mtime = inode->i_ctime = ubifs_current_time(inode);
|
||||
/* 'vmtruncate()' changed @i_size, update @ui_size */
|
||||
/* 'simple_setsize()' changed @i_size, update @ui_size */
|
||||
ui->ui_size = inode->i_size;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ struct ubifs_gced_idx_leb {
|
|||
* The @ui_size is a "shadow" variable for @inode->i_size and UBIFS uses
|
||||
* @ui_size instead of @inode->i_size. The reason for this is that UBIFS cannot
|
||||
* make sure @inode->i_size is always changed under @ui_mutex, because it
|
||||
* cannot call 'vmtruncate()' with @ui_mutex locked, because it would deadlock
|
||||
* cannot call 'simple_setsize()' with @ui_mutex locked, because it would deadlock
|
||||
* with 'ubifs_writepage()' (see file.c). All the other inode fields are
|
||||
* changed under @ui_mutex, so they do not need "shadow" fields. Note, one
|
||||
* could consider to rework locking and base it on "shadow" fields.
|
||||
|
|
|
|||
Loading…
Reference in a new issue