]> git.baikalelectronics.ru Git - kernel.git/commit
xen/tmem: Don't over-write tmem_frontswap_poolid after tmem_frontswap_init set it.
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 7 Jun 2013 19:26:03 +0000 (15:26 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mon, 10 Jun 2013 14:14:33 +0000 (10:14 -0400)
commit114c6a31fe7efa168a0970d06733d6a825201550
tree5b97f2908fec2b03b6dfef5f52d5e79f2597f750
parent456730660b7b9f652693e3a84c1203f245c0af82
xen/tmem: Don't over-write tmem_frontswap_poolid after tmem_frontswap_init set it.

Commit ccec887c6accf62bdcfac207b35fea6a97f4ec23 ("xen: tmem: enable Xen
tmem shim to be built/loaded as a module") allows the tmem module
to be loaded any time. For this work the frontswap API had to
be able to asynchronously to call tmem_frontswap_init before
or after the swap image had been set. That was added in git
commit 58f0c7a3c7ef414f40228a4f97612ca55e4c9931
("mm: frontswap: lazy initialization to allow tmem backends to build/run as modules").

Which means we could do this (The common case):

 modprobe tmem [so calls frontswap_register_ops, no ->init]
 modifies tmem_frontswap_poolid = -1
 swapon /dev/xvda1 [__frontswap_init, calls -> init, tmem_frontswap_poolid is
 < 0 so tmem hypercall done]

Or the failing one:

 swapon /dev/xvda1 [calls __frontswap_init, sets the need_init bitmap]
 modprobe tmem [calls frontswap_register_ops, -->init calls, finds out
tmem_frontswap_poolid is 0, does not make a hypercall.
Later in the module_init, sets tmem_frontswap_poolid=-1]

Which meant that in the failing case we would not call the hypercall
to initialize the pool and never be able to make any frontswap
backend calls.

Moving the frontswap_register_ops after setting the tmem_frontswap_poolid
fixes it.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Bob Liu <bob.liu@oracle.com>
drivers/xen/tmem.c