* [PATCH] zram: cleanup in zram_read_from_zspool()
@ 2025-01-15 14:55 Wenchao Hao
2025-01-16 0:41 ` Sergey Senozhatsky
0 siblings, 1 reply; 3+ messages in thread
From: Wenchao Hao @ 2025-01-15 14:55 UTC (permalink / raw)
To: Minchan Kim, Sergey Senozhatsky, Jens Axboe, linux-kernel,
linux-block
Cc: Wenchao Hao
We don't need a separate "if" branch to check whether size is
equal to PAGE_SIZE. So remove the above "if" branch and
move down 2 lines to cleanup code, no logic change.
Signed-off-by: Wenchao Hao <haowenchao22@gmail.com>
---
drivers/block/zram/zram_drv.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 7903a4da40ac..ad1fbe6d823d 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1561,11 +1561,6 @@ static int zram_read_from_zspool(struct zram *zram, struct page *page,
size = zram_get_obj_size(zram, index);
- if (size != PAGE_SIZE) {
- prio = zram_get_priority(zram, index);
- zstrm = zcomp_stream_get(zram->comps[prio]);
- }
-
src = zs_map_object(zram->mem_pool, handle, ZS_MM_RO);
if (size == PAGE_SIZE) {
dst = kmap_local_page(page);
@@ -1573,6 +1568,9 @@ static int zram_read_from_zspool(struct zram *zram, struct page *page,
kunmap_local(dst);
ret = 0;
} else {
+ prio = zram_get_priority(zram, index);
+ zstrm = zcomp_stream_get(zram->comps[prio]);
+
dst = kmap_local_page(page);
ret = zcomp_decompress(zram->comps[prio], zstrm,
src, size, dst);
--
2.45.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] zram: cleanup in zram_read_from_zspool()
2025-01-15 14:55 [PATCH] zram: cleanup in zram_read_from_zspool() Wenchao Hao
@ 2025-01-16 0:41 ` Sergey Senozhatsky
2025-01-16 2:11 ` Wenchao Hao
0 siblings, 1 reply; 3+ messages in thread
From: Sergey Senozhatsky @ 2025-01-16 0:41 UTC (permalink / raw)
To: Wenchao Hao
Cc: Minchan Kim, Sergey Senozhatsky, Jens Axboe, linux-kernel,
linux-block
On (25/01/15 22:55), Wenchao Hao wrote:
> @@ -1561,11 +1561,6 @@ static int zram_read_from_zspool(struct zram *zram, struct page *page,
>
> size = zram_get_obj_size(zram, index);
>
> - if (size != PAGE_SIZE) {
> - prio = zram_get_priority(zram, index);
> - zstrm = zcomp_stream_get(zram->comps[prio]);
> - }
> -
> src = zs_map_object(zram->mem_pool, handle, ZS_MM_RO);
> if (size == PAGE_SIZE) {
> dst = kmap_local_page(page);
> @@ -1573,6 +1568,9 @@ static int zram_read_from_zspool(struct zram *zram, struct page *page,
> kunmap_local(dst);
> ret = 0;
> } else {
> + prio = zram_get_priority(zram, index);
> + zstrm = zcomp_stream_get(zram->comps[prio]);
> +
> dst = kmap_local_page(page);
> ret = zcomp_decompress(zram->comps[prio], zstrm,
> src, size, dst);
I think you are looking at some old code base (or maybe vanilla kernel),
that function does not look like this in the current mm tree (or linux-next).
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] zram: cleanup in zram_read_from_zspool()
2025-01-16 0:41 ` Sergey Senozhatsky
@ 2025-01-16 2:11 ` Wenchao Hao
0 siblings, 0 replies; 3+ messages in thread
From: Wenchao Hao @ 2025-01-16 2:11 UTC (permalink / raw)
To: Sergey Senozhatsky; +Cc: Minchan Kim, Jens Axboe, linux-kernel, linux-block
On 2025/1/16 8:41, Sergey Senozhatsky wrote:
> On (25/01/15 22:55), Wenchao Hao wrote:
>> @@ -1561,11 +1561,6 @@ static int zram_read_from_zspool(struct zram *zram, struct page *page,
>>
>> size = zram_get_obj_size(zram, index);
>>
>> - if (size != PAGE_SIZE) {
>> - prio = zram_get_priority(zram, index);
>> - zstrm = zcomp_stream_get(zram->comps[prio]);
>> - }
>> -
>> src = zs_map_object(zram->mem_pool, handle, ZS_MM_RO);
>> if (size == PAGE_SIZE) {
>> dst = kmap_local_page(page);
>> @@ -1573,6 +1568,9 @@ static int zram_read_from_zspool(struct zram *zram, struct page *page,
>> kunmap_local(dst);
>> ret = 0;
>> } else {
>> + prio = zram_get_priority(zram, index);
>> + zstrm = zcomp_stream_get(zram->comps[prio]);
>> +
>> dst = kmap_local_page(page);
>> ret = zcomp_decompress(zram->comps[prio], zstrm,
>> src, size, dst);
>
> I think you are looking at some old code base (or maybe vanilla kernel),
> that function does not look like this in the current mm tree (or linux-next).
Yes, it's from https://github.com/torvalds/linux. Sorry I did not examine the
latest code, please ignore this thread.
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-16 2:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-15 14:55 [PATCH] zram: cleanup in zram_read_from_zspool() Wenchao Hao
2025-01-16 0:41 ` Sergey Senozhatsky
2025-01-16 2:11 ` Wenchao Hao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox