]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
udf: fix possible leakage of blocks
authorJan Kara <jack@suse.cz>
Sat, 16 Jun 2007 17:16:14 +0000 (10:16 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Sat, 16 Jun 2007 20:16:16 +0000 (13:16 -0700)
commit74584ae509befc2ed711810e7df4b075473869b2
tree9cb1b4a06b8583895c96d9b1a959d81df3950a06
parent4b356be019d0c28f67af02809df7072c1c8f7d32
udf: fix possible leakage of blocks

We have to take care that when we call udf_discard_prealloc() from
udf_clear_inode() we have to write inode ourselves afterwards (otherwise,
some changes might be lost leading to leakage of blocks, use of free blocks
or improperly aligned extents).

Also udf_discard_prealloc() does two different things - it removes
preallocated blocks and truncates the last extent to exactly match i_size.
We move the latter functionality to udf_truncate_tail_extent(), call
udf_discard_prealloc() when last reference to a file is dropped and call
udf_truncate_tail_extent() when inode is being removed from inode cache
(udf_clear_inode() call).

We cannot call udf_truncate_tail_extent() earlier as subsequent open+write
would find the last block of the file mapped and happily write to the end
of it, although the last extent says it's shorter.

[akpm@linux-foundation.org: Make checkpatch.pl happier]
Signed-off-by: Jan Kara <jack@suse.cz>
Cc: Eric Sandeen <sandeen@sandeen.net>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/udf/inode.c
fs/udf/truncate.c
fs/udf/udfdecl.h