mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
xen/tmem: Don't over-write tmem_frontswap_poolid after tmem_frontswap_init set it.
Commit10a7a07713
("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 commit905cd0e1bf
("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>
This commit is contained in:
parent
466318a87f
commit
b2c75c446a
1 changed files with 2 additions and 2 deletions
|
@ -379,10 +379,10 @@ static int xen_tmem_init(void)
|
|||
#ifdef CONFIG_FRONTSWAP
|
||||
if (tmem_enabled && frontswap) {
|
||||
char *s = "";
|
||||
struct frontswap_ops *old_ops =
|
||||
frontswap_register_ops(&tmem_frontswap_ops);
|
||||
struct frontswap_ops *old_ops;
|
||||
|
||||
tmem_frontswap_poolid = -1;
|
||||
old_ops = frontswap_register_ops(&tmem_frontswap_ops);
|
||||
if (IS_ERR(old_ops) || old_ops) {
|
||||
if (IS_ERR(old_ops))
|
||||
return PTR_ERR(old_ops);
|
||||
|
|
Loading…
Reference in a new issue