Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 258968
b: refs/heads/master
c: e83c32e
h: refs/heads/master
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Jul 26, 2011
1 parent 0d44296 commit b96cc00
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 45 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: 9276aad6c898dbcc31d095f2934dedd5cbb2e93e
refs/heads/master: e83c32e8f92724a06a22a3b42f3afc07db93e131
60 changes: 16 additions & 44 deletions trunk/mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1269,9 +1269,9 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t idx,
goto failed;
radix_tree_preload_end();
if (sgp != SGP_READ && !prealloc_page) {
/* We don't care if this fails */
prealloc_page = shmem_alloc_page(gfp, info, idx);
if (prealloc_page) {
SetPageSwapBacked(prealloc_page);
if (mem_cgroup_cache_charge(prealloc_page,
current->mm, GFP_KERNEL)) {
page_cache_release(prealloc_page);
Expand Down Expand Up @@ -1403,7 +1403,8 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t idx,
goto repeat;
}
spin_unlock(&info->lock);
} else {

} else if (prealloc_page) {
shmem_swp_unmap(entry);
sbinfo = SHMEM_SB(inode->i_sb);
if (sbinfo->max_blocks) {
Expand All @@ -1419,41 +1420,8 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t idx,
if (!filepage) {
int ret;

if (!prealloc_page) {
spin_unlock(&info->lock);
filepage = shmem_alloc_page(gfp, info, idx);
if (!filepage) {
spin_lock(&info->lock);
shmem_unacct_blocks(info->flags, 1);
shmem_free_blocks(inode, 1);
spin_unlock(&info->lock);
error = -ENOMEM;
goto failed;
}
SetPageSwapBacked(filepage);

/*
* Precharge page while we can wait, compensate
* after
*/
error = mem_cgroup_cache_charge(filepage,
current->mm, GFP_KERNEL);
if (error) {
page_cache_release(filepage);
spin_lock(&info->lock);
shmem_unacct_blocks(info->flags, 1);
shmem_free_blocks(inode, 1);
spin_unlock(&info->lock);
filepage = NULL;
goto failed;
}

spin_lock(&info->lock);
} else {
filepage = prealloc_page;
prealloc_page = NULL;
SetPageSwapBacked(filepage);
}
filepage = prealloc_page;
prealloc_page = NULL;

entry = shmem_swp_alloc(info, idx, sgp, gfp);
if (IS_ERR(entry))
Expand Down Expand Up @@ -1492,11 +1460,20 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t idx,
SetPageUptodate(filepage);
if (sgp == SGP_DIRTY)
set_page_dirty(filepage);
} else {
spin_unlock(&info->lock);
error = -ENOMEM;
goto out;
}
done:
*pagep = filepage;
error = 0;
goto out;
out:
if (prealloc_page) {
mem_cgroup_uncharge_cache_page(prealloc_page);
page_cache_release(prealloc_page);
}
return error;

nospace:
/*
Expand All @@ -1520,12 +1497,7 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t idx,
unlock_page(filepage);
page_cache_release(filepage);
}
out:
if (prealloc_page) {
mem_cgroup_uncharge_cache_page(prealloc_page);
page_cache_release(prealloc_page);
}
return error;
goto out;
}

static int shmem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
Expand Down

0 comments on commit b96cc00

Please sign in to comment.