Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338742
b: refs/heads/master
c: cf0cac0
h: refs/heads/master
v: v3
  • Loading branch information
Cesar Eduardo Barros authored and Linus Torvalds committed Dec 12, 2012
1 parent 0667a67 commit 92bc320
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e9868505987a03a26a3979f27b82911ccc003752
refs/heads/master: cf0cac0a09341549dedabcfc2a66dcbc2eaaf2b9
26 changes: 17 additions & 9 deletions trunk/mm/swapfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1443,13 +1443,12 @@ static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)
return generic_swapfile_activate(sis, swap_file, span);
}

static void enable_swap_info(struct swap_info_struct *p, int prio,
static void _enable_swap_info(struct swap_info_struct *p, int prio,
unsigned char *swap_map,
unsigned long *frontswap_map)
{
int i, prev;

spin_lock(&swap_lock);
if (prio >= 0)
p->prio = prio;
else
Expand All @@ -1473,6 +1472,21 @@ static void enable_swap_info(struct swap_info_struct *p, int prio,
else
swap_info[prev]->next = p->type;
frontswap_init(p->type);
}

static void enable_swap_info(struct swap_info_struct *p, int prio,
unsigned char *swap_map,
unsigned long *frontswap_map)
{
spin_lock(&swap_lock);
_enable_swap_info(p, prio, swap_map, frontswap_map);
spin_unlock(&swap_lock);
}

static void reinsert_swap_info(struct swap_info_struct *p)
{
spin_lock(&swap_lock);
_enable_swap_info(p, p->prio, p->swap_map, frontswap_map_get(p));
spin_unlock(&swap_lock);
}

Expand Down Expand Up @@ -1548,14 +1562,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
compare_swap_oom_score_adj(OOM_SCORE_ADJ_MAX, oom_score_adj);

if (err) {
/*
* reading p->prio and p->swap_map outside the lock is
* safe here because only sys_swapon and sys_swapoff
* change them, and there can be no other sys_swapon or
* sys_swapoff for this swap_info_struct at this point.
*/
/* re-insert swap space back into swap_list */
enable_swap_info(p, p->prio, p->swap_map, frontswap_map_get(p));
reinsert_swap_info(p);
goto out_dput;
}

Expand Down

0 comments on commit 92bc320

Please sign in to comment.