Re: [PATCH] zram: check compressor name before setting it

Sergey Senozhatsky
2015-05-26T00:09:07Z

Hi,

On (05/25/15 23:21), Minchan Kim wrote:
[..]
> find_backend is just utility function to get zcomp_backend.
> IOW, it might be used for several cases in future so I want
> make error report as caller's work.

[..]
> > if (sz > 0 && zram->compressor[sz - 1] == '\n')
> > zram->compressor[sz - 1] = 0x00;
> >
> > + if (!zcomp_known_algorithm(zram->compressor))
>
> In here, we could report back to the user.

the motivation was that we actually change user land interface
here and it's quite possible that none of the existing scripts
handle errors returned from `echo X > /../comp_algorithm`, simply
because it has never issued any errors; not counting -BUSY, which
may be not relevant for the vast majority of the scripts:

#!/bin/sh
modprobe zram
echo $1 > /sys/block/zram0/max_comp_streams
echo $2 > /sys/block/zram0/comp_algorithm

[..]

echo $3 > /sys/block/zram0/disksize
if [ $? ... ]
...
fi

mkfs.xxx /dev/zram0
mount -o xxx /dev/zram0 /xxx

`echo $2 > /sys/block/zram0/comp_algorithm` -EINVAL return can be
ignored (and, thus, syslog message as well); because `comp_algorithm`
has never returned anything for that trivial script. so that's why I
wanted to print extra `unknown compression algorithm` message during
disksize store.

-ss

> > + len = -EINVAL;
> > +
> > up_write(&zram->init_lock);
> > return len;
> > }
> >
> > --
> > To unsubscribe, send a message with 'unsubscribe linux-mm' in
> > the body to majordomo@kvack.org. For more info on Linux MM,
> > see: http://www.linux-mm.org/ .
> > Don't email: email@kvack.org
>
> --
> Kind regards,
> Minchan Kim