summaryrefslogtreecommitdiffstats
path: root/fs/reiserfs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-13 13:53:54 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-13 13:53:54 -0700
commit19c6e12c07ceab2ff5d5ec97354b893ab386c41c (patch)
tree47ac6b968c5b725f25cd3c0ee34f8cc7cd4c9617 /fs/reiserfs
parent954e6e03c61d233eae810f8da65270c224fe2fa4 (diff)
parent4d9bcaddacf23861c5ee088b0c03e7034c3d59d6 (diff)
downloadlinux-19c6e12c07ceab2ff5d5ec97354b893ab386c41c.tar.bz2
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull ext2, udf, reiserfs fixes from Jan Kara: "Several ext2, udf, and reiserfs fixes" * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: ext2: Fix memory leak when truncate races ext2_get_blocks reiserfs: fix race in prealloc discard reiserfs: don't preallocate blocks for extended attributes udf: Convert udf_disk_stamp_to_time() to use mktime64() udf: Use time64_to_tm for timestamp conversion udf: Fix deadlock between writeback and udf_setsize() udf: Use i_size_read() in udf_adinicb_writepage() udf: Fix races with i_size changes during readpage udf: Remove unused UDF_DEFAULT_BLOCKSIZE
Diffstat (limited to 'fs/reiserfs')
-rw-r--r--fs/reiserfs/bitmap.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
index dc198bc64c61..edc8ef78b63f 100644
--- a/fs/reiserfs/bitmap.c
+++ b/fs/reiserfs/bitmap.c
@@ -513,9 +513,17 @@ static void __discard_prealloc(struct reiserfs_transaction_handle *th,
"inode has negative prealloc blocks count.");
#endif
while (ei->i_prealloc_count > 0) {
- reiserfs_free_prealloc_block(th, inode, ei->i_prealloc_block);
- ei->i_prealloc_block++;
+ b_blocknr_t block_to_free;
+
+ /*
+ * reiserfs_free_prealloc_block can drop the write lock,
+ * which could allow another caller to free the same block.
+ * We can protect against it by modifying the prealloc
+ * state before calling it.
+ */
+ block_to_free = ei->i_prealloc_block++;
ei->i_prealloc_count--;
+ reiserfs_free_prealloc_block(th, inode, block_to_free);
dirty = 1;
}
if (dirty)
@@ -1128,7 +1136,7 @@ static int determine_prealloc_size(reiserfs_blocknr_hint_t * hint)
hint->prealloc_size = 0;
if (!hint->formatted_node && hint->preallocate) {
- if (S_ISREG(hint->inode->i_mode)
+ if (S_ISREG(hint->inode->i_mode) && !IS_PRIVATE(hint->inode)
&& hint->inode->i_size >=
REISERFS_SB(hint->th->t_super)->s_alloc_options.
preallocmin * hint->inode->i_sb->s_blocksize)