diff options
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r-- | mm/swapfile.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index 6cd0a8f90dc..03aa2d55f1a 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -139,7 +139,8 @@ static int discard_swap(struct swap_info_struct *si) | |||
139 | nr_blocks = ((sector_t)se->nr_pages - 1) << (PAGE_SHIFT - 9); | 139 | nr_blocks = ((sector_t)se->nr_pages - 1) << (PAGE_SHIFT - 9); |
140 | if (nr_blocks) { | 140 | if (nr_blocks) { |
141 | err = blkdev_issue_discard(si->bdev, start_block, | 141 | err = blkdev_issue_discard(si->bdev, start_block, |
142 | nr_blocks, GFP_KERNEL, DISCARD_FL_BARRIER); | 142 | nr_blocks, GFP_KERNEL, |
143 | BLKDEV_IFL_WAIT | BLKDEV_IFL_BARRIER); | ||
143 | if (err) | 144 | if (err) |
144 | return err; | 145 | return err; |
145 | cond_resched(); | 146 | cond_resched(); |
@@ -150,7 +151,8 @@ static int discard_swap(struct swap_info_struct *si) | |||
150 | nr_blocks = (sector_t)se->nr_pages << (PAGE_SHIFT - 9); | 151 | nr_blocks = (sector_t)se->nr_pages << (PAGE_SHIFT - 9); |
151 | 152 | ||
152 | err = blkdev_issue_discard(si->bdev, start_block, | 153 | err = blkdev_issue_discard(si->bdev, start_block, |
153 | nr_blocks, GFP_KERNEL, DISCARD_FL_BARRIER); | 154 | nr_blocks, GFP_KERNEL, |
155 | BLKDEV_IFL_WAIT | BLKDEV_IFL_BARRIER); | ||
154 | if (err) | 156 | if (err) |
155 | break; | 157 | break; |
156 | 158 | ||
@@ -189,7 +191,8 @@ static void discard_swap_cluster(struct swap_info_struct *si, | |||
189 | start_block <<= PAGE_SHIFT - 9; | 191 | start_block <<= PAGE_SHIFT - 9; |
190 | nr_blocks <<= PAGE_SHIFT - 9; | 192 | nr_blocks <<= PAGE_SHIFT - 9; |
191 | if (blkdev_issue_discard(si->bdev, start_block, | 193 | if (blkdev_issue_discard(si->bdev, start_block, |
192 | nr_blocks, GFP_NOIO, DISCARD_FL_BARRIER)) | 194 | nr_blocks, GFP_NOIO, BLKDEV_IFL_WAIT | |
195 | BLKDEV_IFL_BARRIER)) | ||
193 | break; | 196 | break; |
194 | } | 197 | } |
195 | 198 | ||
@@ -574,6 +577,7 @@ static unsigned char swap_entry_free(struct swap_info_struct *p, | |||
574 | 577 | ||
575 | /* free if no reference */ | 578 | /* free if no reference */ |
576 | if (!usage) { | 579 | if (!usage) { |
580 | struct gendisk *disk = p->bdev->bd_disk; | ||
577 | if (offset < p->lowest_bit) | 581 | if (offset < p->lowest_bit) |
578 | p->lowest_bit = offset; | 582 | p->lowest_bit = offset; |
579 | if (offset > p->highest_bit) | 583 | if (offset > p->highest_bit) |
@@ -583,6 +587,9 @@ static unsigned char swap_entry_free(struct swap_info_struct *p, | |||
583 | swap_list.next = p->type; | 587 | swap_list.next = p->type; |
584 | nr_swap_pages++; | 588 | nr_swap_pages++; |
585 | p->inuse_pages--; | 589 | p->inuse_pages--; |
590 | if ((p->flags & SWP_BLKDEV) && | ||
591 | disk->fops->swap_slot_free_notify) | ||
592 | disk->fops->swap_slot_free_notify(p->bdev, offset); | ||
586 | } | 593 | } |
587 | 594 | ||
588 | return usage; | 595 | return usage; |
@@ -1884,6 +1891,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) | |||
1884 | if (error < 0) | 1891 | if (error < 0) |
1885 | goto bad_swap; | 1892 | goto bad_swap; |
1886 | p->bdev = bdev; | 1893 | p->bdev = bdev; |
1894 | p->flags |= SWP_BLKDEV; | ||
1887 | } else if (S_ISREG(inode->i_mode)) { | 1895 | } else if (S_ISREG(inode->i_mode)) { |
1888 | p->bdev = inode->i_sb->s_bdev; | 1896 | p->bdev = inode->i_sb->s_bdev; |
1889 | mutex_lock(&inode->i_mutex); | 1897 | mutex_lock(&inode->i_mutex); |