aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/shmem.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index 58da7c150ba6..8fa27e4e582a 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -421,7 +421,8 @@ static swp_entry_t *shmem_swp_alloc(struct shmem_inode_info *info, unsigned long
421 * a waste to allocate index if we cannot allocate data. 421 * a waste to allocate index if we cannot allocate data.
422 */ 422 */
423 if (sbinfo->max_blocks) { 423 if (sbinfo->max_blocks) {
424 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)
425 return ERR_PTR(-ENOSPC); 426 return ERR_PTR(-ENOSPC);
426 percpu_counter_inc(&sbinfo->used_blocks); 427 percpu_counter_inc(&sbinfo->used_blocks);
427 spin_lock(&inode->i_lock); 428 spin_lock(&inode->i_lock);
@@ -1397,7 +1398,8 @@ repeat:
1397 shmem_swp_unmap(entry); 1398 shmem_swp_unmap(entry);
1398 sbinfo = SHMEM_SB(inode->i_sb); 1399 sbinfo = SHMEM_SB(inode->i_sb);
1399 if (sbinfo->max_blocks) { 1400 if (sbinfo->max_blocks) {
1400 if ((percpu_counter_compare(&sbinfo->used_blocks, sbinfo->max_blocks) > 0) || 1401 if (percpu_counter_compare(&sbinfo->used_blocks,
1402 sbinfo->max_blocks) >= 0 ||
1401 shmem_acct_block(info->flags)) { 1403 shmem_acct_block(info->flags)) {
1402 spin_unlock(&info->lock); 1404 spin_unlock(&info->lock);
1403 error = -ENOSPC; 1405 error = -ENOSPC;