summaryrefslogtreecommitdiffstats
path: root/fs/udf/file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-11 08:02:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-11 08:02:31 -0400
commitac0c49396d5ed9a33f08ce661635ac1bff80bb4f (patch)
treee2f066b931b133e94fde7e1157c57bef69a928e7 /fs/udf/file.c
parenteca9fdf32dd48976eab18d310acb0b8d4cc9bf26 (diff)
parent6174c2eb8ecef271159bdcde460ce8af54d8f72f (diff)
downloadop-kernel-dev-ac0c49396d5ed9a33f08ce661635ac1bff80bb4f.zip
op-kernel-dev-ac0c49396d5ed9a33f08ce661635ac1bff80bb4f.tar.gz
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull UDF and quota updates from Jan Kara: "A few UDF fixes and also a few patches which are preparing filesystems for support of project quotas in VFS" * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: udf: Fix loading of special inodes ocfs2: Back out change to use OCFS2_MAXQUOTAS in ocfs2_setattr() udf: remove redundant sys_tz declaration ocfs2: Don't use MAXQUOTAS value reiserfs: Don't use MAXQUOTAS value ext3: Don't use MAXQUOTAS value udf: Fix race between write(2) and close(2)
Diffstat (limited to 'fs/udf/file.c')
-rw-r--r--fs/udf/file.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 86c6743..bb15771 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -223,11 +223,18 @@ out:
static int udf_release_file(struct inode *inode, struct file *filp)
{
- if (filp->f_mode & FMODE_WRITE) {
+ if (filp->f_mode & FMODE_WRITE &&
+ atomic_read(&inode->i_writecount) > 1) {
+ /*
+ * Grab i_mutex to avoid races with writes changing i_size
+ * while we are running.
+ */
+ mutex_lock(&inode->i_mutex);
down_write(&UDF_I(inode)->i_data_sem);
udf_discard_prealloc(inode);
udf_truncate_tail_extent(inode);
up_write(&UDF_I(inode)->i_data_sem);
+ mutex_unlock(&inode->i_mutex);
}
return 0;
}
OpenPOWER on IntegriCloud