Skip to content

Commit 948b9b2

Browse files
jankaraLinus Torvalds
authored and
Linus Torvalds
committed
udf: add assertions
Add a few assertions into udf_discard_prealloc() to check that the file is sane (mostly helps debugging further patches ;). Signed-off-by: Jan Kara <jack@suse.cz> Acked-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3bf25cb commit 948b9b2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/udf/truncate.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ void udf_discard_prealloc(struct inode * inode)
8888
{
8989
etype = netype;
9090
lbcount += elen;
91-
if (lbcount > inode->i_size && lbcount - inode->i_size < inode->i_sb->s_blocksize)
91+
if (lbcount > inode->i_size && lbcount - elen < inode->i_size)
9292
{
93+
WARN_ON(lbcount - inode->i_size >= inode->i_sb->s_blocksize);
9394
nelen = elen - (lbcount - inode->i_size);
9495
epos.offset -= adsize;
9596
extent_trunc(inode, &epos, eloc, etype, elen, nelen);
@@ -119,6 +120,7 @@ void udf_discard_prealloc(struct inode * inode)
119120
}
120121
UDF_I_LENEXTENTS(inode) = lbcount;
121122

123+
WARN_ON(lbcount != inode->i_size);
122124
brelse(epos.bh);
123125
}
124126

0 commit comments

Comments
 (0)