commit 1ea1cd11c72d1405a6b98440a9d5ea82dfa07166
Author: Jan Kara <jack@xxxxxxx>
Date: Wed Jan 25 11:43:03 2023 +0100
udf: Fix directory iteration for longer tail extents
When directory's last extent has more that one block and its length is
not multiple of a block side, the code wrongly decided to move to the
next extent instead of processing the last partial block. This led to
directory corruption. Fix the rounding issue.
Signed-off-by: Jan Kara <jack@xxxxxxx>
diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index b1424e2aa868..31f1bf8ab848 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -170,7 +170,7 @@ static struct buffer_head *udf_fiiter_bread_blk(struct udf_fileident_iter *iter)
static int udf_fiiter_advance_blk(struct udf_fileident_iter *iter)
{
iter->loffset++;
- if (iter->loffset < iter->elen >> iter->dir->i_blkbits)
+ if (iter->loffset < DIV_ROUND_UP(iter->elen, 1<<iter->dir->i_blkbits))
return 0;
iter->loffset = 0;
In my qemu environment, with v6.1.115 plus this patch, `ls $mntpt/sources` will
work as normal.
Jan, I'm not very familiar with this patchset, maybe some more patches needs to
be backported to solve this problem? I'd love to hear from you.
Deniel, if it possible, could you cherry-pick this patch to your kernel source
as a temporary workaround, and test if it really fix your problem? Thanks.