Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

zram: take write lock in wb limit store handlers

Write device attrs handlers should take write zram init_lock. While at
it, fixup coding styles.

Link: https://lkml.kernel.org/r/20251122074029.3948921-4-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Brian Geffon <bgeffon@google.com>
Cc: Minchan Kim <minchan@google.com>
Cc: Richard Chang <richardycc@google.com>
Cc: Yuwen Chen <ywen.chen@foxmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Sergey Senozhatsky and committed by
Andrew Morton
7c929664 e828cccb

+10 -7
+10 -7
drivers/block/zram/zram_drv.c
··· 521 521 }; 522 522 523 523 static ssize_t writeback_limit_enable_store(struct device *dev, 524 - struct device_attribute *attr, const char *buf, size_t len) 524 + struct device_attribute *attr, 525 + const char *buf, size_t len) 525 526 { 526 527 struct zram *zram = dev_to_zram(dev); 527 528 u64 val; ··· 531 530 if (kstrtoull(buf, 10, &val)) 532 531 return ret; 533 532 534 - down_read(&zram->init_lock); 533 + down_write(&zram->init_lock); 535 534 spin_lock(&zram->wb_limit_lock); 536 535 zram->wb_limit_enable = val; 537 536 spin_unlock(&zram->wb_limit_lock); 538 - up_read(&zram->init_lock); 537 + up_write(&zram->init_lock); 539 538 ret = len; 540 539 541 540 return ret; 542 541 } 543 542 544 543 static ssize_t writeback_limit_enable_show(struct device *dev, 545 - struct device_attribute *attr, char *buf) 544 + struct device_attribute *attr, 545 + char *buf) 546 546 { 547 547 bool val; 548 548 struct zram *zram = dev_to_zram(dev); ··· 558 556 } 559 557 560 558 static ssize_t writeback_limit_store(struct device *dev, 561 - struct device_attribute *attr, const char *buf, size_t len) 559 + struct device_attribute *attr, 560 + const char *buf, size_t len) 562 561 { 563 562 struct zram *zram = dev_to_zram(dev); 564 563 u64 val; ··· 568 565 if (kstrtoull(buf, 10, &val)) 569 566 return ret; 570 567 571 - down_read(&zram->init_lock); 568 + down_write(&zram->init_lock); 572 569 spin_lock(&zram->wb_limit_lock); 573 570 zram->bd_wb_limit = val; 574 571 spin_unlock(&zram->wb_limit_lock); 575 - up_read(&zram->init_lock); 572 + up_write(&zram->init_lock); 576 573 ret = len; 577 574 578 575 return ret;