Found by sparse
Bug: 153174547
Test: make C=2 fs/incfs/incrementalfs.ko no errors, incfs_test pass
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I9ff4f4f35975fe09936724488b96cd8bdeeb719e
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Paul Lawrenceauthored and Sorayukiicommited 2026-05-15 18:07:13 +07:00
This change was never cherry-picked to other branches,
is just syntactic sugar, and clashes with another change. Revert,
and then apply cleanly over all branches as needed.
This reverts commit 2664a43d88d91eb09f212cb26e111656a4acee49.
Change-Id: I51dca9cb046cc15302c22e8f73e58dcf4849f84d
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Paul Lawrenceauthored and Sorayukiicommited 2026-05-15 18:07:13 +07:00
Since INCFS_IOC_GET_FILLED_BLOCKS potentially leaks information about usage
patterns, and is only useful to someone filling the file, best protect it in
the same way as INCFS_IOC_FILL_BLOCKS.
Add useful field data_block_out as well
Test: incfs_test passes
Bug: 152983639
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I126a8cf711e56592479093e9aadbfd0e7f700752
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Paul Lawrenceauthored and Sorayukiicommited 2026-05-15 18:07:13 +07:00
When read log is 0 sized, we still need to init the wait queue to avoid
kernel panics if someone does decide to poll on the read log.
Test: Added test for this condition, incfs_test crashes
With fix, incfs_test doesn't crash
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Bug: 152909243
Change-Id: Ic3250523bb7ddb1839f8e95852c17103e5ffb782
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Paul Lawrenceauthored and Sorayukiicommited 2026-05-15 18:07:13 +07:00
When returning incomplete results index_out has to be usable to
call the function again and resume from the same location. This
means that if the output buffer was too small the function needs
to check for that when encountering the _beginning_ of a next
output range, not the end of it. Otherwise resuming from the
end of the range that didn't fit into the buffer would cause
the call to never return that range
+ Make the backing file header flags update thread safe
Bug: 152691988
Test: libincfs-test, incfs_test passes
Signed-off-by: Yurii Zubrytskyi <zyy@google.com>
Change-Id: I351156beba0b74e1942a39117279d3fcdb5e0c78
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Yurii Zubrytskyiauthored and Sorayukiicommited 2026-05-15 18:07:13 +07:00
Without these, you can't unmount a volume on which incfs was
mounted and the tests run.
Also incfs_tests would fail sporadically without the fix to
test_inode
Test: Run incfs_test and unmount underlying volume 1000 times
Bug: 152636070
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I88f11f5d4269c22d9073e5eb671d0c7cc4629f6c
(cherry picked from commit c062bc8e769f0f6e47cc41fb9b7ab30e3e7f2689)
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Paul Lawrenceauthored and Sorayukiicommited 2026-05-15 18:07:13 +07:00
Provide a securable way to open a file for filling
Test: incfs_test passes
Bug: 138149732
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ib4b6fd839ad30ce08e31121d19e2c0d7066d302f
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Paul Lawrenceauthored and Sorayukiicommited 2026-05-15 18:07:12 +07:00
Filling blocks is not equivalent to writing a file, since they are
constrained by the root hash. selinux policy may wish to treat them
differently, for instance.
Test: incfs_test passes
Bug: 138149732
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ic369b84b92547b1cfefe422bd881c4e466090aed
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Paul Lawrenceauthored and Sorayukiicommited 2026-05-15 18:07:12 +07:00
They provide no value and simply duplicate a check in copy_from/to_user
Test: incfs_test passes
Bug: 138149732
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Icc6054a2d6a495c9a03cd1507dda1ab8ca0b0dc4
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Paul Lawrenceauthored and Sorayukiicommited 2026-05-15 18:07:12 +07:00
To make selinux work, add xattr support. This is a bit clunky -
it seems like it would be better for the log and pending read
functionality to be ioctls rather than this mixture of real
and virtual files.
Bug: 133435829
Change-Id: I56579fabe2ae7efb88f0344553948dc9573299aa
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Paul Lawrenceauthored and Sorayukiicommited 2026-05-15 18:07:11 +07:00
- added chmod() to +0222 to make all backing files and dirs
writable. vold/system_server have a umask that clears those
flags, making incfs unusable
Signed-off-by: Yurii Zubrytskyi <zyy@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Bug: 133435829
Change-Id: Id9258401570cc2cc7cd5735aace89d379a9b043d
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Yurii Zubrytskyiauthored and Sorayukiicommited 2026-05-15 18:07:11 +07:00
Fix all sparse errors in fs/incfs except
fs/incfs/integrity.c:192:9: warning: Variable length array is used
Test: incfs_test passes
Bug: 133435829
Change-Id: I9c2e26e4e1a06a894977f11a3c8559b968dd115e
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Paul Lawrenceauthored and Sorayukiicommited 2026-05-15 18:07:11 +07:00
Fixed incfs_test build errors
Fixed Kconfig errors
Readded .gitignore
Test: With just enabling CONFIG_INCREMENTAL_FS, both defconfig and
cuttlefish_defconfig build and incfs_test runs and passes
Bug: 133435829
Change-Id: Id3247ffcc63a095f66dcedf554017a06c5a9ce4a
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Paul Lawrenceauthored and Sorayukiicommited 2026-05-15 18:07:10 +07:00
The original dedup code does not handle collision from the observation
that it practically does not happen.
For additional peace of mind, use a bigger hash size for reducing the
possibility of collision even further.
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Juhyung Parkauthored and Sorayukiicommited 2026-05-15 18:07:10 +07:00
Makoto report a below KASAN error: zram does out-of-bounds read. Because
strscpy copies from source up to count bytes unconditionally. It could
cause out-of-bounds read on next object in slab.
To prevent it, use strlcpy which checks source's length automatically.
BUG: KASAN: slab-out-of-bounds in strscpy+0x68/0x154
Read of size 8 at addr ffffffc0c3495a00 by task system_server/1314
..
Call trace:
strscpy+0x68/0x154
idle_store+0xc4/0x34c
dev_attr_store+0x50/0x6c
sysfs_kf_write+0x98/0xb4
kernfs_fop_write+0x198/0x260
__vfs_write+0x10c/0x338
vfs_write+0x114/0x238
SyS_write+0xc8/0x168
__sys_trace_return+0x0/0x4
Allocated by task 1314:
__kmalloc+0x280/0x318
kernfs_fop_write+0xac/0x260
__vfs_write+0x10c/0x338
vfs_write+0x114/0x238
SyS_write+0xc8/0x168
__sys_trace_return+0x0/0x4
Freed by task 2855:
kfree+0x138/0x630
kernfs_put_open_node+0x10c/0x124
kernfs_fop_release+0xd8/0x114
__fput+0x130/0x2a4
____fput+0x1c/0x28
task_work_run+0x16c/0x1c8
do_notify_resume+0x2bc/0x107c
work_pending+0x8/0x10
The buggy address belongs to the object at ffffffc0c3495a00
which belongs to the cache kmalloc-128 of size 128
The buggy address is located 0 bytes inside of
128-byte region [ffffffc0c3495a00, ffffffc0c3495a80)
The buggy address belongs to the page:
page:ffffffbf030d2500 count:1 mapcount:0 mapping: (null) index:0x0 compound_mapcount: 0
flags: 0x4000000000010200(slab|head)
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffffffc0c3495900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffffc0c3495980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffffffc0c3495a00: 04 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
ffffffc0c3495a80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffffffc0c3495b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Link: http://lkml.kernel.org/r/20190319231911.145968-1-minchan@kernel.org
Cc: <stable@vger.kernel.org> [5.0]
Signed-off-by: Minchan Kim <minchan@kernel.org>
Reported-by: Makoto Wu <makotowu@google.com>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Change-Id: I785c262bc2c95a07e826a6244c21e3d85520b525
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Minchan Kimauthored and Sorayukiicommited 2026-05-15 18:07:10 +07:00
zram_table_entry::flags stores object size in the lower bits and zram
pageflags in the upper bits. However, for some reason, we use 24 lower
bits, while maximum zram object size is PAGE_SIZE, which requires
PAGE_SHIFT bits (up to 16 on arm64). This wastes 24 - PAGE_SHIFT bits
that we can use for additional zram pageflags instead.
Also add a BUILD_BUG_ON() to alert us should we run out of bits in
zram_table_entry::flags.
Link: https://lkml.kernel.org/r/20220912152744.527438-1-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Brian Geffon <bgeffon@google.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Sergey Senozhatskyauthored and Sorayukiicommited 2026-05-15 18:07:09 +07:00
zram was the motivation for creating memset_l(). Minchan Kim sees a 7%
performance improvement on x86 with 100MB of non-zero deduplicatable
data:
perf stat -r 10 dd if=/dev/zram0 of=/dev/null
vanilla: 0.232050465 seconds time elapsed ( +- 0.51% )
memset_l: 0.217219387 seconds time elapsed ( +- 0.07% )
Link: http://lkml.kernel.org/r/20170720184539.31609-7-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Tested-by: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: David Miller <davem@davemloft.net>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Russell King <rmk+kernel@armlinux.org.uk>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Matthew Wilcoxauthored and Sorayukiicommited 2026-05-15 18:07:09 +07:00
Install the callbacks via the state machine with multi instance support and let
the core invoke the callbacks on the already online CPUs.
[bigeasy: wire up the multi instance stuff]
[B--B: fixed wrong spacing and newlines]
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: rt@linutronix.de
Cc: Nitin Gupta <ngupta@vflare.org>
Link: http://lkml.kernel.org/r/20161126231350.10321-19-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Anna-Maria Gleixnerauthored and Sorayukiicommited 2026-05-15 18:07:09 +07:00
Mikhail reported a lockdep spat detailing how __zram_bvec_read() and
__zram_bvec_write() use zstrm->lock and zspage->lock in opposite order.
Reported-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Peter Zijlstraauthored and Sorayukiicommited 2026-05-15 18:07:09 +07:00
With deduplication enabled, the duplicated zram objects are tracked
using the zram_entry backed by a refcount. The race condition while
decrementing the refcount through zram_dedup_put() is as follows:
Say Task A and task B share the same object and thus the
zram_entry->refcount = 2.
Task A Task B
zram_dedup_put zram_dedup_put
spin_lock(&hash->lock);
entry->refcount--; (Now it is 1)
spin_unlock(&hash->lock);
spin_lock(&hash->lock);
entry->refcount--; (Now it is 0)
spin_unlock(&hash->lock);
return entry->refcount return entry->refcount
We return 0 in above steps thus leading to double free of the handle,
which is a slab object.
Change-Id: I8dd9bad27140a6e3a295905bf4411050d8eac931
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Charan Teja Reddyauthored and Sorayukiicommited 2026-05-15 18:07:09 +07:00
Until now, we compare just one entry with same checksum when
checking duplication since it is the simplest way to implement.
However, for the completeness, checking all the entries is better
so this patch implement to compare all the entries with same checksum.
Since this event would be rare so there would be no performance loss.
Change-Id: Ie7d61c14d127a28f5a06d85b0ca66b9fada20cbb
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Link: https://lore.kernel.org/patchwork/patch/787163/
Patch-mainline: linux-kernel@ Thu, 11 May 2017 22:30:29
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Joonsoo Kimauthored and Sorayukiicommited 2026-05-15 18:07:09 +07:00
Benefit of deduplication is dependent on the workload so it's not
preferable to always enable. Therefore, make it optional in Kconfig
and device param. Default is 'off'. This option will be beneficial
for users who use the zram as blockdev and stores build output to it.
Change-Id: If282bb8aa15c5749859a87cf36db7eb9edb3b1ed
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Link: https://lore.kernel.org/patchwork/patch/787164/
Patch-mainline: linux-kernel@ Thu, 11 May 2017 22:30:52
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Joonsoo Kimauthored and Sorayukiicommited 2026-05-15 18:07:09 +07:00
This patch implements deduplication feature in zram. The purpose
of this work is naturally to save amount of memory usage by zram.
Android is one of the biggest users to use zram as swap and it's
really important to save amount of memory usage. There is a paper
that reports that duplication ratio of Android's memory content is
rather high [1]. And, there is a similar work on zswap that also
reports that experiments has shown that around 10-15% of pages
stored in zswp are duplicates and deduplicate them provides some
benefits [2].
Also, there is a different kind of workload that uses zram as blockdev
and store build outputs into it to reduce wear-out problem of real
blockdev. In this workload, deduplication hit is very high due to
temporary files and intermediate object files. Detailed analysis is
on the bottom of this description.
Anyway, if we can detect duplicated content and avoid to store duplicated
content at different memory space, we can save memory. This patch
tries to do that.
Implementation is almost simple and intuitive but I should note
one thing about implementation detail.
To check duplication, this patch uses checksum of the page and
collision of this checksum could be possible. There would be
many choices to handle this situation but this patch chooses
to allow entry with duplicated checksum to be added to the hash,
but, not to compare all entries with duplicated checksum
when checking duplication. I guess that checksum collision is quite
rare event and we don't need to pay any attention to such a case.
Therefore, I decided the most simplest way to implement the feature.
If there is a different opinion, I can accept and go that way.
Following is the result of this patch.
Test result #1 (Swap):
Android Marshmallow, emulator, x86_64, Backporting to kernel v3.18
orig_data_size: 145297408
compr_data_size: 32408125
mem_used_total: 32276480
dup_data_size: 3188134
meta_data_size: 1444272
Last two metrics added to mm_stat are related to this work.
First one, dup_data_size, is amount of saved memory by avoiding
to store duplicated page. Later one, meta_data_size, is the amount of
data structure to support deduplication. If dup > meta, we can judge
that the patch improves memory usage.
In Adnroid, we can save 5% of memory usage by this work.
Test result #2 (Blockdev):
build the kernel and store output to ext4 FS on zram
<no-dedup>
Elapsed time: 249 s
mm_stat: 430845952 191014886 196898816 0 196898816 28320 0 0 0
<dedup>
Elapsed time: 250 s
mm_stat: 430505984 190971334 148365312 0 148365312 28404 0 47287038 3945792
There is no performance degradation and save 23% memory.
Test result #3 (Blockdev):
copy android build output dir(out/host) to ext4 FS on zram
<no-dedup>
Elapsed time: out/host: 88 s
mm_stat: 8834420736 3658184579 3834208256 0 3834208256 32889 0 0 0
<dedup>
Elapsed time: out/host: 100 s
mm_stat: 8832929792 3657329322 2832015360 0 2832015360 32609 0 952568877 80880336
It shows performance degradation roughly 13% and save 24% memory. Maybe,
it is due to overhead of calculating checksum and comparison.
Test result #4 (Blockdev):
copy android build output dir(out/target/common) to ext4 FS on zram
<no-dedup>
Elapsed time: out/host: 203 s
mm_stat: 4041678848 2310355010 2346577920 0 2346582016 500 4 0 0
<dedup>
Elapsed time: out/host: 201 s
mm_stat: 4041666560 2310488276 1338150912 0 1338150912 476 0 989088794 24564336
Memory is saved by 42% and performance is the same. Even if there is overhead
of calculating checksum and comparison, large hit ratio compensate it since
hit leads to less compression attempt.
I checked the detailed reason of savings on kernel build workload and
there are some cases that deduplication happens.
1) *.cmd
Build command is usually similar in one directory so content of these file
are very similar. In my system, more than 789 lines in fs/ext4/.namei.o.cmd
and fs/ext4/.inode.o.cmd are the same in 944 and 938 lines of the file,
respectively.
2) intermediate object files
built-in.o and temporary object file have the similar contents. More than
50% of fs/ext4/ext4.o is the same with fs/ext4/built-in.o.
3) vmlinux
.tmp_vmlinux1 and .tmp_vmlinux2 and arch/x86/boo/compressed/vmlinux.bin
have the similar contents.
Android test has similar case that some of object files(.class
and .so) are similar with another ones.
(./host/linux-x86/lib/libartd.so and
./host/linux-x86-lib/libartd-comiler.so)
Anyway, benefit seems to be largely dependent on the workload so
following patch will make this feature optional. However, this feature
can help some usecases so is deserved to be merged.
[1]: MemScope: Analyzing Memory Duplication on Android Systems,
dl.acm.org/citation.cfm?id=2797023
[2]: zswap: Optimize compressed pool memory utilization,
lkml.kernel.org/r/1341407574.7551.1471584870761.JavaMail.weblogic@epwas3p2
Change-Id: I8fe80c956c33f88a6af337d50d9e210e5c35ce37
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Link: https://lore.kernel.org/patchwork/patch/787162/
Patch-mainline: linux-kernel@ Thu, 11 May 2017 22:30:26
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Joonsoo Kimauthored and Sorayukiicommited 2026-05-15 18:07:08 +07:00
Following patch will implement deduplication functionality
in the zram and it requires an indirection layer to manage
the life cycle of zsmalloc handle. To prepare that, this patch
introduces zram_entry which can be used to manage the life-cycle
of zsmalloc handle. Many lines are changed due to rename but
core change is just simple introduction about newly data structure.
Change-Id: Ibf9912397c8c7dbcf1465550bc83a71f904e41c7
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Link: https://lore.kernel.org/patchwork/patch/787161/
Patch-mainline: linux-kernel@ Thu, 11 May 2017 22:30:21
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Joonsoo Kimauthored and Sorayukiicommited 2026-05-15 18:07:08 +07:00
The read_from_bdev_async is not called on atomic context. So GFP_NOIO
is available rather than GFP_ATOMIC. If there were reclaimable pages
with GFP_NOIO, we can avoid allocation failure and page fault failure.
Link: https://lkml.kernel.org/r/20210908005241.28062-1-jaewon31.kim@samsung.com
Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com>
Reported-by: Yong-Taek Lee <ytk.lee@samsung.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Jaewon Kimauthored and Sorayukiicommited 2026-05-15 18:07:08 +07:00
When calling fsync_bdev(), zram driver guarantees that the bdev won't be
opened by anyone, then there can't be one active fs/superblock over the
zram bdev, so replace fsync_bdev with sync_blockdev.
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Link: https://lore.kernel.org/r/20211025025426.2815424-5-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Marco Zanin <mrczn.bb@gmail.com>
Signed-off-by: snnbyyds <snnbyyds@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Ming Leiauthored and Sorayukiicommited 2026-05-15 18:07:08 +07:00
Follow the steps: https://github.com/facebook/zstd/blob/v1.5.7/contrib/linux-kernel/README.md
The following committed changes are also preserved:
70168143b302378ccff178bf28cb140c783dac88 zstd: merge optimization from Samsung <DevriesL>
0b893588096921a258f8ca27d6005da4201c9b58 lib: zstd: Don't inline functions in zstd_opt.c <Nick Terrell>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Pzqqtauthored and Sorayukiicommited 2026-05-15 18:07:07 +07:00
Follow the steps: https://github.com/facebook/zstd/blob/v1.5.6/contrib/linux-kernel/README.md
The following committed changes are also preserved:
c97320470b510a90bac077842630bd49c7cce95e zstd: merge optimization from Samsung <DevriesL>
9df1909b60b40fc7450ebff9b45d7cd2ac70225d lib: zstd: Don't inline functions in zstd_opt.c <Nick Terrell>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Pzqqtauthored and Sorayukiicommited 2026-05-15 18:07:07 +07:00
- ZSTD_resetDstream() is deprecated hence it is wise to make zstd_reset_dstream() functionally identical to ZSTD_resetDstream() as we have done for the compression stream in [1].
- Also make ZSTD_startingInputLength() visible for the decompression driver to be able to use it.
- This fixes the below warning:
../lib/zstd/zstd_decompress_module.c: In function 'zstd_reset_dstream':
../lib/zstd/zstd_decompress_module.c:80:9: warning: 'ZSTD_resetDStream' is deprecated [-Wdeprecated-declarations]
80 | return ZSTD_resetDStream(dstream);
| ^~~~~~
In file included from ../include/linux/zstd.h:26,
from ../lib/zstd/zstd_decompress_module.c:15:
../include/linux/zstd_lib.h:2569:27: note: declared here
2569 | ZSTDLIB_STATIC_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
| ^~~~~~~~~~~~~~~~~
[1]: https://github.com/facebook/zstd/pull/3088
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
Cyber Knightauthored and Sorayukiicommited 2026-05-15 18:07:07 +07:00
ld.lld: error: duplicate symbol: ZSTD_isError
>>> defined at error_private.h:47 (../../../../../../src/kernel/xiaomi/rova/lib/zstd/common/error_private.h:47)
>>> lib/zstd/zstd_compress.o:(ZSTD_isError)
>>> defined at error_private.h:47 (../../../../../../src/kernel/xiaomi/rova/lib/zstd/common/error_private.h:47)
>>> lib/zstd/zstd_decompress.o:(.text+0x2570)
and many more...
Signed-off-by: iusmac <iusico.maxim@libero.it>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
iusmacauthored and Sorayukiicommited 2026-05-15 18:07:06 +07:00