]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
erofs: shouldn't churn the mapping page for duplicated copies
authorGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 12 Oct 2022 04:50:56 +0000 (12:50 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 29 Oct 2022 08:08:33 +0000 (10:08 +0200)
[ Upstream commit 63bbb85658ea43dd35dbfde6d4150b47c407fc87 ]

If other duplicated copies exist in one decompression shot, should
leave the old page as is rather than replace it with the new duplicated
one.  Otherwise, the following cold path to deal with duplicated copies
will use the invalid bvec.  It impacts compressed data deduplication.

Also, shift the onlinepage EIO bit to avoid touching the signed bit.

Fixes: 267f2492c8f7 ("erofs: introduce multi-reference pclusters (fully-referenced)")
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20221012045056.13421-1-hsiangkao@linux.alibaba.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/erofs/zdata.c
fs/erofs/zdata.h

index 5792ca9e0d5efaf59a4b9abb65a1e1dd1c503078..6e663275aeb13bd0718e2723a73f1d835b92657a 100644 (file)
@@ -838,15 +838,13 @@ static void z_erofs_do_decompressed_bvec(struct z_erofs_decompress_backend *be,
 
        if (!((bvec->offset + be->pcl->pageofs_out) & ~PAGE_MASK)) {
                unsigned int pgnr;
-               struct page *oldpage;
 
                pgnr = (bvec->offset + be->pcl->pageofs_out) >> PAGE_SHIFT;
                DBG_BUGON(pgnr >= be->nr_pages);
-               oldpage = be->decompressed_pages[pgnr];
-               be->decompressed_pages[pgnr] = bvec->page;
-
-               if (!oldpage)
+               if (!be->decompressed_pages[pgnr]) {
+                       be->decompressed_pages[pgnr] = bvec->page;
                        return;
+               }
        }
 
        /* (cold path) one pcluster is requested multiple times */
index e7f04c4fbb81c5742915f5120d5e198efce62218..d98c952129852a95759cfca43e2b0ac3340f3fe6 100644 (file)
@@ -126,10 +126,10 @@ static inline unsigned int z_erofs_pclusterpages(struct z_erofs_pcluster *pcl)
 }
 
 /*
- * bit 31: I/O error occurred on this page
- * bit 0 - 30: remaining parts to complete this page
+ * bit 30: I/O error occurred on this page
+ * bit 0 - 29: remaining parts to complete this page
  */
-#define Z_EROFS_PAGE_EIO                       (1 << 31)
+#define Z_EROFS_PAGE_EIO                       (1 << 30)
 
 static inline void z_erofs_onlinepage_init(struct page *page)
 {