diff options
Diffstat (limited to 'mm/shmem.c')
-rw-r--r-- | mm/shmem.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index 048a95a5244d..8fa27e4e582a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -224,7 +224,6 @@ static const struct vm_operations_struct shmem_vm_ops; | |||
224 | static struct backing_dev_info shmem_backing_dev_info __read_mostly = { | 224 | static struct backing_dev_info shmem_backing_dev_info __read_mostly = { |
225 | .ra_pages = 0, /* No readahead */ | 225 | .ra_pages = 0, /* No readahead */ |
226 | .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK | BDI_CAP_SWAP_BACKED, | 226 | .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK | BDI_CAP_SWAP_BACKED, |
227 | .unplug_io_fn = default_unplug_io_fn, | ||
228 | }; | 227 | }; |
229 | 228 | ||
230 | static LIST_HEAD(shmem_swaplist); | 229 | static LIST_HEAD(shmem_swaplist); |
@@ -422,7 +421,8 @@ static swp_entry_t *shmem_swp_alloc(struct shmem_inode_info *info, unsigned long | |||
422 | * a waste to allocate index if we cannot allocate data. | 421 | * a waste to allocate index if we cannot allocate data. |
423 | */ | 422 | */ |
424 | if (sbinfo->max_blocks) { | 423 | if (sbinfo->max_blocks) { |
425 | if (percpu_counter_compare(&sbinfo->used_blocks, (sbinfo->max_blocks - 1)) > 0) | 424 | if (percpu_counter_compare(&sbinfo->used_blocks, |
425 | sbinfo->max_blocks - 1) >= 0) | ||
426 | return ERR_PTR(-ENOSPC); | 426 | return ERR_PTR(-ENOSPC); |
427 | percpu_counter_inc(&sbinfo->used_blocks); | 427 | percpu_counter_inc(&sbinfo->used_blocks); |
428 | spin_lock(&inode->i_lock); | 428 | spin_lock(&inode->i_lock); |
@@ -1081,7 +1081,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) | |||
1081 | shmem_recalc_inode(inode); | 1081 | shmem_recalc_inode(inode); |
1082 | 1082 | ||
1083 | if (swap.val && add_to_swap_cache(page, swap, GFP_ATOMIC) == 0) { | 1083 | if (swap.val && add_to_swap_cache(page, swap, GFP_ATOMIC) == 0) { |
1084 | remove_from_page_cache(page); | 1084 | delete_from_page_cache(page); |
1085 | shmem_swp_set(info, entry, swap.val); | 1085 | shmem_swp_set(info, entry, swap.val); |
1086 | shmem_swp_unmap(entry); | 1086 | shmem_swp_unmap(entry); |
1087 | if (list_empty(&info->swaplist)) | 1087 | if (list_empty(&info->swaplist)) |
@@ -1091,7 +1091,6 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) | |||
1091 | spin_unlock(&info->lock); | 1091 | spin_unlock(&info->lock); |
1092 | swap_shmem_alloc(swap); | 1092 | swap_shmem_alloc(swap); |
1093 | BUG_ON(page_mapped(page)); | 1093 | BUG_ON(page_mapped(page)); |
1094 | page_cache_release(page); /* pagecache ref */ | ||
1095 | swap_writepage(page, wbc); | 1094 | swap_writepage(page, wbc); |
1096 | if (inode) { | 1095 | if (inode) { |
1097 | mutex_lock(&shmem_swaplist_mutex); | 1096 | mutex_lock(&shmem_swaplist_mutex); |
@@ -1399,7 +1398,8 @@ repeat: | |||
1399 | shmem_swp_unmap(entry); | 1398 | shmem_swp_unmap(entry); |
1400 | sbinfo = SHMEM_SB(inode->i_sb); | 1399 | sbinfo = SHMEM_SB(inode->i_sb); |
1401 | if (sbinfo->max_blocks) { | 1400 | if (sbinfo->max_blocks) { |
1402 | if ((percpu_counter_compare(&sbinfo->used_blocks, sbinfo->max_blocks) > 0) || | 1401 | if (percpu_counter_compare(&sbinfo->used_blocks, |
1402 | sbinfo->max_blocks) >= 0 || | ||
1403 | shmem_acct_block(info->flags)) { | 1403 | shmem_acct_block(info->flags)) { |
1404 | spin_unlock(&info->lock); | 1404 | spin_unlock(&info->lock); |
1405 | error = -ENOSPC; | 1405 | error = -ENOSPC; |
@@ -2794,5 +2794,6 @@ int shmem_zero_setup(struct vm_area_struct *vma) | |||
2794 | fput(vma->vm_file); | 2794 | fput(vma->vm_file); |
2795 | vma->vm_file = file; | 2795 | vma->vm_file = file; |
2796 | vma->vm_ops = &shmem_vm_ops; | 2796 | vma->vm_ops = &shmem_vm_ops; |
2797 | vma->vm_flags |= VM_CAN_NONLINEAR; | ||
2797 | return 0; | 2798 | return 0; |
2798 | } | 2799 | } |