On (03/04/15 17:19), Sergey Senozhatsky wrote: > hm... that actually doesn't look so hard. > > all I need to do is just change zram_add attr to RW (or create a new RO > attribute `zram_auto_add', or whatever) and treat read access to that > zram_add_read() or zram_auto_add_read() attr as (atomic operation): > -- generate new device_id X > -- create corresponding zramX device > -- return that X as char *text to user space (or error). the > same way we sprintf() stats. > > what do you think? I'll play with it. >
that will do the trick. testing simple patch: # cat /sys/class/zram-control/zram_add 1 # cat /sys/class/zram-control/zram_add 2 # cat /sys/class/zram-control/zram_add 3 # cat /sys/class/zram-control/zram_add 4 # cat /sys/class/zram-control/zram_add 5 dmesg: [14339.063075] zram: Added device: zram1 [14339.972633] zram: Added device: zram2 [14340.626564] zram: Added device: zram3 [14341.242134] zram: Added device: zram4 [14341.850853] zram: Added device: zram5 try to add already existing device_id # echo 3 > /sys/class/zram-control/zram_add -bash: echo: write error: File exists zram_add() error propogation to user space (-ENOMEM in this case) # cat /sys/class/zram-control/zram_add cat: /sys/class/zram-control/zram_add: Cannot allocate memory will send out new patch set later today. -ss -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/