udf: Make sure i_lenExtents is uptodate on inode eviction

commit 55dd5b4db3 upstream.

UDF maintains total length of all extents in i_lenExtents. Generally we
keep extent lengths (and thus i_lenExtents) block aligned because it
makes the file appending logic simpler. However the standard mandates
that the inode size must match the length of all extents and thus we
trim the last extent when closing the file. To catch possible bugs we
also verify that i_lenExtents matches i_size when evicting inode from
memory. Commit b405c1e58b ("udf: refactor udf_next_aext() to handle
error") however broke the code updating i_lenExtents and thus
udf_evict_inode() ended up spewing lots of errors about incorrectly
sized extents although the extents were actually sized properly. Fix the
updating of i_lenExtents to silence the errors.

Fixes: b405c1e58b ("udf: refactor udf_next_aext() to handle error")
CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 7722fba9f3bf0462a0fad7d47bf9903d989c741c)
This commit is contained in:
Jan Kara 2025-05-07 11:49:41 +02:00 committed by Wentao Guan
parent eb7c3a890d
commit b0a92e0503
1 changed files with 1 additions and 1 deletions

View File

@ -115,7 +115,7 @@ void udf_truncate_tail_extent(struct inode *inode)
}
/* This inode entry is in-memory only and thus we don't have to mark
* the inode dirty */
if (ret == 0)
if (ret >= 0)
iinfo->i_lenExtents = inode->i_size;
brelse(epos.bh);
}