mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
[PATCH] r/o bind mounts: debugging for missed calls
There have been a few oopses caused by 'struct file's with NULL f_vfsmnts.
There was also a set of potentially missed mnt_want_write()s from
dentry_open() calls.
This patch provides a very simple debugging framework to catch these kinds of
bugs. It will WARN_ON() them, but should stop us from having any oopses or
mnt_writer count imbalances.
I'm quite convinced that this is a good thing because it found bugs in the
stuff I was working on as soon as I wrote it.
[hch: made it conditional on a debug option.
But it's still a little bit too ugly]
[hch: merged forced remount r/o fix from Dave and akpm's fix for the fix]
Signed-off-by: Dave Hansen <[email protected]>
Acked-by: Al Viro <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
2e4b7fcd92
commit
ad775f5a8f
5 changed files with 82 additions and 3 deletions
12
fs/open.c
12
fs/open.c
|
|
@ -806,6 +806,8 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
|
|||
error = __get_file_write_access(inode, mnt);
|
||||
if (error)
|
||||
goto cleanup_file;
|
||||
if (!special_file(inode->i_mode))
|
||||
file_take_write(f);
|
||||
}
|
||||
|
||||
f->f_mapping = inode->i_mapping;
|
||||
|
|
@ -847,8 +849,16 @@ cleanup_all:
|
|||
fops_put(f->f_op);
|
||||
if (f->f_mode & FMODE_WRITE) {
|
||||
put_write_access(inode);
|
||||
if (!special_file(inode->i_mode))
|
||||
if (!special_file(inode->i_mode)) {
|
||||
/*
|
||||
* We don't consider this a real
|
||||
* mnt_want/drop_write() pair
|
||||
* because it all happenend right
|
||||
* here, so just reset the state.
|
||||
*/
|
||||
file_reset_write(f);
|
||||
mnt_drop_write(mnt);
|
||||
}
|
||||
}
|
||||
file_kill(f);
|
||||
f->f_path.dentry = NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue