<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p><span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">When handling deduplicated compressed data, there can be multiple</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">decompressed extents pointing to the same compressed data in one shot.</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">In such cases, the bvecs which belong to the longest extent will be</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">selected as the primary bvecs for real decompressors to decode and the</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">other duplicated bvecs will be directly copied from the primary bvecs.</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">Previously, only relative offsets of the longest extent was checked to</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">decompress the primary bvecs. On rare occasions, it can be incorrect</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">if there are several extents with the same start relative offset.</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">As a result, some short bvecs could be selected for decompression and</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">then cause data corruption.</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">For example, as Shijie Sun reported off-list, considering the following</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">extents of a file:</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px"> 117: 903345.. 915250 | 11905 : 385024.. 389120 | 4096</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">...</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px"> 119: 919729.. 930323 | 10594 : 385024.. 389120 | 4096</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">...</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px"> 124: 968881.. 980786 | 11905 : 385024.. 389120 | 4096</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">The start relative offset is the same: 2225, but extent 119 (919729..</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">930323) is shorter than the others.</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">Let's restrict the bvec length in addition to the start offset if bvecs</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">are not full.</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">Reported-by: Shijie Sun <sunshijie@xiaomi.com></span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">Fixes: 5c2a64252c5d ("erofs: introduce partial-referenced pclusters")</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com></span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">---</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px"> fs/erofs/zdata.c | 7 ++++---</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px"> 1 file changed, 4 insertions(+), 3 deletions(-)</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">index b69d89a11dd0..de4f12152b62 100644</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">--- a/fs/erofs/zdata.c</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">+++ b/fs/erofs/zdata.c</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">@@ -1144,10 +1144,11 @@ static void z_erofs_do_decompressed_bvec(struct z_erofs_decompress_backend *be,</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px"> struct z_erofs_bvec *bvec)</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px"> {</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px"> struct z_erofs_bvec_item *item;</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">+ unsigned int pgnr;</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">- if (!((bvec->offset + be->pcl->pageofs_out) & ~PAGE_MASK)) {</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">- unsigned int pgnr;</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">-</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">+ if (!((bvec->offset + be->pcl->pageofs_out) & ~PAGE_MASK) &&</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">+ (bvec->end == PAGE_SIZE ||</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">+ bvec->offset + bvec->end == be->pcl->length)) {</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px"> pgnr = (bvec->offset + be->pcl->pageofs_out) >> PAGE_SHIFT;</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px"> DBG_BUGON(pgnr >= be->nr_pages);</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px"> if (!be->decompressed_pages[pgnr]) {</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">--</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
<span style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">2.24.4</span><br style="color:rgb(33,33,33); font-family:"Microsoft YaHei UI","Microsoft YaHei",΢ÈíÑźÚ,SimSun,ËÎÌå,sans-serif,serif,EmojiFont; font-size:13.3333px">
Tested-by Shijie Sun <sunshijie@xiaomi.com></p>
<p><br>
</p>
<p>Thanks, </p>
<p>Sun Shijie</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>·¢¼þÈË:</b> Gao Xiang <hsiangkao@linux.alibaba.com><br>
<b>·¢ËÍʱ¼ä:</b> 2023Äê7ÔÂ19ÈÕ 14:54:59<br>
<b>ÊÕ¼þÈË:</b> linux-erofs@lists.ozlabs.org<br>
<b>³ËÍ:</b> LKML; Gao Xiang; ËïÊ¿½Ü<br>
<b>Ö÷Ìâ:</b> [External Mail][PATCH] erofs: fix wrong primary bvec selection on deduplicated extents</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">[ÍⲿÓʼþ] ´ËÓʼþÀ´Ô´ÓÚСÃ×¹«Ë¾Íⲿ£¬Çë½÷É÷´¦Àí¡£Èô¶ÔÓʼþ°²È«ÐÔ´æÒÉ£¬Ç뽫Óʼþת·¢¸ømisec@xiaomi.com½øÐз´À¡<br>
<br>
When handling deduplicated compressed data, there can be multiple<br>
decompressed extents pointing to the same compressed data in one shot.<br>
<br>
In such cases, the bvecs which belong to the longest extent will be<br>
selected as the primary bvecs for real decompressors to decode and the<br>
other duplicated bvecs will be directly copied from the primary bvecs.<br>
<br>
Previously, only relative offsets of the longest extent was checked to<br>
decompress the primary bvecs. On rare occasions, it can be incorrect<br>
if there are several extents with the same start relative offset.<br>
As a result, some short bvecs could be selected for decompression and<br>
then cause data corruption.<br>
<br>
For example, as Shijie Sun reported off-list, considering the following<br>
extents of a file:<br>
117: 903345.. 915250 | 11905 : 385024.. 389120 | 4096<br>
...<br>
119: 919729.. 930323 | 10594 : 385024.. 389120 | 4096<br>
...<br>
124: 968881.. 980786 | 11905 : 385024.. 389120 | 4096<br>
<br>
The start relative offset is the same: 2225, but extent 119 (919729..<br>
930323) is shorter than the others.<br>
<br>
Let's restrict the bvec length in addition to the start offset if bvecs<br>
are not full.<br>
<br>
Reported-by: Shijie Sun <sunshijie@xiaomi.com><br>
Fixes: 5c2a64252c5d ("erofs: introduce partial-referenced pclusters")<br>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com><br>
---<br>
fs/erofs/zdata.c | 7 ++++---<br>
1 file changed, 4 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c<br>
index b69d89a11dd0..de4f12152b62 100644<br>
--- a/fs/erofs/zdata.c<br>
+++ b/fs/erofs/zdata.c<br>
@@ -1144,10 +1144,11 @@ static void z_erofs_do_decompressed_bvec(struct z_erofs_decompress_backend *be,<br>
struct z_erofs_bvec *bvec)<br>
{<br>
struct z_erofs_bvec_item *item;<br>
+ unsigned int pgnr;<br>
<br>
- if (!((bvec->offset + be->pcl->pageofs_out) & ~PAGE_MASK)) {<br>
- unsigned int pgnr;<br>
-<br>
+ if (!((bvec->offset + be->pcl->pageofs_out) & ~PAGE_MASK) &&<br>
+ (bvec->end == PAGE_SIZE ||<br>
+ bvec->offset + bvec->end == be->pcl->length)) {<br>
pgnr = (bvec->offset + be->pcl->pageofs_out) >> PAGE_SHIFT;<br>
DBG_BUGON(pgnr >= be->nr_pages);<br>
if (!be->decompressed_pages[pgnr]) {<br>
--<br>
2.24.4<br>
<br>
</div>
</span></font>#/******±¾Óʼþ¼°Æ丽¼þº¬ÓÐСÃ×¹«Ë¾µÄ±£ÃÜÐÅÏ¢£¬½öÏÞÓÚ·¢Ë͸øÉÏÃæµØÖ·ÖÐÁгöµÄ¸öÈË»òȺ×é¡£½ûÖ¹ÈκÎÆäËûÈËÒÔÈκÎÐÎʽʹÓ㨰üÀ¨µ«²»ÏÞÓÚÈ«²¿»ò²¿·ÖµØй¶¡¢¸´ÖÆ¡¢»òÉ¢·¢£©±¾ÓʼþÖеÄÐÅÏ¢¡£Èç¹ûÄú´íÊÕÁ˱¾Óʼþ£¬ÇëÄúÁ¢¼´µç»°»òÓʼþ֪ͨ·¢¼þÈ˲¢É¾³ý±¾Óʼþ£¡ This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or
entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you
receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#
</body>
</html>