@@ -495,15 +495,25 @@ void file_kill(struct file *file)
int fops_read_lock(struct file *file)
{
int revoked = (file->f_mode & FMODE_REVOKED);
- if (likely(!revoked))
- atomic_long_inc(&file->f_use);
+ if (likely(!revoked)) {
+ if (likely(atomic_long_read(&file->f_count) == 1))
+ atomic_long_set(&file->f_use,
+ atomic_long_read(&file->f_use) + 1);
+ else
+ atomic_long_inc(&file->f_use);
+ }
return revoked;
}
void fops_read_unlock(struct file *file, int revoked)
{
- if (likely(!revoked))
- atomic_long_dec(&file->f_use);
+ if (likely(!revoked)) {
+ if (likely(atomic_long_read(&file->f_count) == 1))
+ atomic_long_set(&file->f_use,
+ atomic_long_read(&file->f_use) - 1);
+ else
+ atomic_long_dec(&file->f_use);
+ }
}
int fs_may_remount_ro(struct super_block *sb)