public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] zram: introduce comp algorithm fallback functionality
@ 2015-09-08 18:42 Luis Henriques
  2015-09-09  0:45 ` Sergey Senozhatsky
  2015-09-10  5:03 ` Minchan Kim
  0 siblings, 2 replies; 7+ messages in thread
From: Luis Henriques @ 2015-09-08 18:42 UTC (permalink / raw)
  To: Minchan Kim, Nitin Gupta, Sergey Senozhatsky; +Cc: Andrew Morton, linux-kernel

When the user supplies an unsupported compression algorithm, keep the
previously selected one (knowingly supported) or the default one (if the
compression algorithm hasn't been changed yet).

Note that previously this operation (i.e. setting an invalid algorithm)
would result in no algorithm being selected, which means that this
represents a small change in the default behaviour.

Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
Changes since v1:
 * Moved the algorithm check further up, before mutex lock
 * Dropped error path refactoring
 * Updated commit text to explicitly refer to the ABI change
 (changes suggested by Sergey and Minchan)

drivers/block/zram/zram_drv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 9c01f5bfa33f..1caa8f793e51 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -365,6 +365,9 @@ static ssize_t comp_algorithm_store(struct device *dev,
 	struct zram *zram = dev_to_zram(dev);
 	size_t sz;
 
+	if (!zcomp_available_algorithm(buf))
+		return -EINVAL;
+
 	down_write(&zram->init_lock);
 	if (init_done(zram)) {
 		up_write(&zram->init_lock);
@@ -378,9 +381,6 @@ static ssize_t comp_algorithm_store(struct device *dev,
 	if (sz > 0 && zram->compressor[sz - 1] == '\n')
 		zram->compressor[sz - 1] = 0x00;
 
-	if (!zcomp_available_algorithm(zram->compressor))
-		len = -EINVAL;
-
 	up_write(&zram->init_lock);
 	return len;
 }

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-09-15 23:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-08 18:42 [PATCH v2] zram: introduce comp algorithm fallback functionality Luis Henriques
2015-09-09  0:45 ` Sergey Senozhatsky
2015-09-10  5:03 ` Minchan Kim
2015-09-10  5:33   ` Sergey Senozhatsky
2015-09-10  5:58     ` Minchan Kim
2015-09-15 23:07   ` Andrew Morton
2015-09-15 23:29     ` Minchan Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox