mirror of
https://github.com/torvalds/linux.git
synced 2024-11-08 13:11:45 +00:00
Merge branch 'akpm' (patches from Andrew Morton)
Merge fixes from Andrew Morton: "10 fixes" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: mm: hugetlb: fix copy_hugetlb_page_range() simple_xattr: permit 0-size extended attributes mm/fs: fix pessimization in hole-punching pagecache shmem: fix splicing from a hole while it's punched shmem: fix faulting into a hole, not taking i_mutex mm: do not call do_fault_around for non-linear fault sh: also try passing -m4-nofpu for SH2A builds zram: avoid lockdep splat by revalidate_disk mm/rmap.c: fix pgoff calculation to handle hugepage correctly coredump: fix the setting of PF_DUMPCORE
This commit is contained in:
commit
ed4a1084bc
@ -32,7 +32,8 @@ endif
|
|||||||
|
|
||||||
cflags-$(CONFIG_CPU_SH2) := $(call cc-option,-m2,)
|
cflags-$(CONFIG_CPU_SH2) := $(call cc-option,-m2,)
|
||||||
cflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \
|
cflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \
|
||||||
$(call cc-option,-m2a-nofpu,)
|
$(call cc-option,-m2a-nofpu,) \
|
||||||
|
$(call cc-option,-m4-nofpu,)
|
||||||
cflags-$(CONFIG_CPU_SH3) := $(call cc-option,-m3,)
|
cflags-$(CONFIG_CPU_SH3) := $(call cc-option,-m3,)
|
||||||
cflags-$(CONFIG_CPU_SH4) := $(call cc-option,-m4,) \
|
cflags-$(CONFIG_CPU_SH4) := $(call cc-option,-m4,) \
|
||||||
$(call cc-option,-mno-implicit-fp,-m4-nofpu)
|
$(call cc-option,-mno-implicit-fp,-m4-nofpu)
|
||||||
|
@ -622,11 +622,18 @@ static void zram_reset_device(struct zram *zram, bool reset_capacity)
|
|||||||
memset(&zram->stats, 0, sizeof(zram->stats));
|
memset(&zram->stats, 0, sizeof(zram->stats));
|
||||||
|
|
||||||
zram->disksize = 0;
|
zram->disksize = 0;
|
||||||
if (reset_capacity) {
|
if (reset_capacity)
|
||||||
set_capacity(zram->disk, 0);
|
set_capacity(zram->disk, 0);
|
||||||
revalidate_disk(zram->disk);
|
|
||||||
}
|
|
||||||
up_write(&zram->init_lock);
|
up_write(&zram->init_lock);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Revalidate disk out of the init_lock to avoid lockdep splat.
|
||||||
|
* It's okay because disk's capacity is protected by init_lock
|
||||||
|
* so that revalidate_disk always sees up-to-date capacity.
|
||||||
|
*/
|
||||||
|
if (reset_capacity)
|
||||||
|
revalidate_disk(zram->disk);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t disksize_store(struct device *dev,
|
static ssize_t disksize_store(struct device *dev,
|
||||||
@ -666,8 +673,15 @@ static ssize_t disksize_store(struct device *dev,
|
|||||||
zram->comp = comp;
|
zram->comp = comp;
|
||||||
zram->disksize = disksize;
|
zram->disksize = disksize;
|
||||||
set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
|
set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
|
||||||
revalidate_disk(zram->disk);
|
|
||||||
up_write(&zram->init_lock);
|
up_write(&zram->init_lock);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Revalidate disk out of the init_lock to avoid lockdep splat.
|
||||||
|
* It's okay because disk's capacity is protected by init_lock
|
||||||
|
* so that revalidate_disk always sees up-to-date capacity.
|
||||||
|
*/
|
||||||
|
revalidate_disk(zram->disk);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
|
|
||||||
out_destroy_comp:
|
out_destroy_comp:
|
||||||
|
@ -306,7 +306,7 @@ static int zap_threads(struct task_struct *tsk, struct mm_struct *mm,
|
|||||||
if (unlikely(nr < 0))
|
if (unlikely(nr < 0))
|
||||||
return nr;
|
return nr;
|
||||||
|
|
||||||
tsk->flags = PF_DUMPCORE;
|
tsk->flags |= PF_DUMPCORE;
|
||||||
if (atomic_read(&mm->mm_users) == nr + 1)
|
if (atomic_read(&mm->mm_users) == nr + 1)
|
||||||
goto done;
|
goto done;
|
||||||
/*
|
/*
|
||||||
|
@ -843,7 +843,7 @@ struct simple_xattr *simple_xattr_alloc(const void *value, size_t size)
|
|||||||
|
|
||||||
/* wrap around? */
|
/* wrap around? */
|
||||||
len = sizeof(*new_xattr) + size;
|
len = sizeof(*new_xattr) + size;
|
||||||
if (len <= sizeof(*new_xattr))
|
if (len < sizeof(*new_xattr))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
new_xattr = kmalloc(len, GFP_KERNEL);
|
new_xattr = kmalloc(len, GFP_KERNEL);
|
||||||
|
@ -398,6 +398,18 @@ static inline struct page *read_mapping_page(struct address_space *mapping,
|
|||||||
return read_cache_page(mapping, index, filler, data);
|
return read_cache_page(mapping, index, filler, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the offset in PAGE_SIZE.
|
||||||
|
* (TODO: hugepage should have ->index in PAGE_SIZE)
|
||||||
|
*/
|
||||||
|
static inline pgoff_t page_to_pgoff(struct page *page)
|
||||||
|
{
|
||||||
|
if (unlikely(PageHeadHuge(page)))
|
||||||
|
return page->index << compound_order(page);
|
||||||
|
else
|
||||||
|
return page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return byte-offset into filesystem object for page.
|
* Return byte-offset into filesystem object for page.
|
||||||
*/
|
*/
|
||||||
|
@ -2604,6 +2604,7 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
|
|||||||
} else {
|
} else {
|
||||||
if (cow)
|
if (cow)
|
||||||
huge_ptep_set_wrprotect(src, addr, src_pte);
|
huge_ptep_set_wrprotect(src, addr, src_pte);
|
||||||
|
entry = huge_ptep_get(src_pte);
|
||||||
ptepage = pte_page(entry);
|
ptepage = pte_page(entry);
|
||||||
get_page(ptepage);
|
get_page(ptepage);
|
||||||
page_dup_rmap(ptepage);
|
page_dup_rmap(ptepage);
|
||||||
|
@ -435,7 +435,7 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill,
|
|||||||
if (av == NULL) /* Not actually mapped anymore */
|
if (av == NULL) /* Not actually mapped anymore */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
|
pgoff = page_to_pgoff(page);
|
||||||
read_lock(&tasklist_lock);
|
read_lock(&tasklist_lock);
|
||||||
for_each_process (tsk) {
|
for_each_process (tsk) {
|
||||||
struct anon_vma_chain *vmac;
|
struct anon_vma_chain *vmac;
|
||||||
@ -469,7 +469,7 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill,
|
|||||||
mutex_lock(&mapping->i_mmap_mutex);
|
mutex_lock(&mapping->i_mmap_mutex);
|
||||||
read_lock(&tasklist_lock);
|
read_lock(&tasklist_lock);
|
||||||
for_each_process(tsk) {
|
for_each_process(tsk) {
|
||||||
pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
|
pgoff_t pgoff = page_to_pgoff(page);
|
||||||
struct task_struct *t = task_early_kill(tsk, force_early);
|
struct task_struct *t = task_early_kill(tsk, force_early);
|
||||||
|
|
||||||
if (!t)
|
if (!t)
|
||||||
|
@ -2882,7 +2882,8 @@ static int do_read_fault(struct mm_struct *mm, struct vm_area_struct *vma,
|
|||||||
* if page by the offset is not ready to be mapped (cold cache or
|
* if page by the offset is not ready to be mapped (cold cache or
|
||||||
* something).
|
* something).
|
||||||
*/
|
*/
|
||||||
if (vma->vm_ops->map_pages && fault_around_pages() > 1) {
|
if (vma->vm_ops->map_pages && !(flags & FAULT_FLAG_NONLINEAR) &&
|
||||||
|
fault_around_pages() > 1) {
|
||||||
pte = pte_offset_map_lock(mm, pmd, address, &ptl);
|
pte = pte_offset_map_lock(mm, pmd, address, &ptl);
|
||||||
do_fault_around(vma, address, pte, pgoff, flags);
|
do_fault_around(vma, address, pte, pgoff, flags);
|
||||||
if (!pte_same(*pte, orig_pte))
|
if (!pte_same(*pte, orig_pte))
|
||||||
|
10
mm/rmap.c
10
mm/rmap.c
@ -517,11 +517,7 @@ void page_unlock_anon_vma_read(struct anon_vma *anon_vma)
|
|||||||
static inline unsigned long
|
static inline unsigned long
|
||||||
__vma_address(struct page *page, struct vm_area_struct *vma)
|
__vma_address(struct page *page, struct vm_area_struct *vma)
|
||||||
{
|
{
|
||||||
pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
|
pgoff_t pgoff = page_to_pgoff(page);
|
||||||
|
|
||||||
if (unlikely(is_vm_hugetlb_page(vma)))
|
|
||||||
pgoff = page->index << huge_page_order(page_hstate(page));
|
|
||||||
|
|
||||||
return vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
|
return vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1639,7 +1635,7 @@ static struct anon_vma *rmap_walk_anon_lock(struct page *page,
|
|||||||
static int rmap_walk_anon(struct page *page, struct rmap_walk_control *rwc)
|
static int rmap_walk_anon(struct page *page, struct rmap_walk_control *rwc)
|
||||||
{
|
{
|
||||||
struct anon_vma *anon_vma;
|
struct anon_vma *anon_vma;
|
||||||
pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
|
pgoff_t pgoff = page_to_pgoff(page);
|
||||||
struct anon_vma_chain *avc;
|
struct anon_vma_chain *avc;
|
||||||
int ret = SWAP_AGAIN;
|
int ret = SWAP_AGAIN;
|
||||||
|
|
||||||
@ -1680,7 +1676,7 @@ static int rmap_walk_anon(struct page *page, struct rmap_walk_control *rwc)
|
|||||||
static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc)
|
static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc)
|
||||||
{
|
{
|
||||||
struct address_space *mapping = page->mapping;
|
struct address_space *mapping = page->mapping;
|
||||||
pgoff_t pgoff = page->index << compound_order(page);
|
pgoff_t pgoff = page_to_pgoff(page);
|
||||||
struct vm_area_struct *vma;
|
struct vm_area_struct *vma;
|
||||||
int ret = SWAP_AGAIN;
|
int ret = SWAP_AGAIN;
|
||||||
|
|
||||||
|
102
mm/shmem.c
102
mm/shmem.c
@ -85,7 +85,7 @@ static struct vfsmount *shm_mnt;
|
|||||||
* a time): we would prefer not to enlarge the shmem inode just for that.
|
* a time): we would prefer not to enlarge the shmem inode just for that.
|
||||||
*/
|
*/
|
||||||
struct shmem_falloc {
|
struct shmem_falloc {
|
||||||
int mode; /* FALLOC_FL mode currently operating */
|
wait_queue_head_t *waitq; /* faults into hole wait for punch to end */
|
||||||
pgoff_t start; /* start of range currently being fallocated */
|
pgoff_t start; /* start of range currently being fallocated */
|
||||||
pgoff_t next; /* the next page offset to be fallocated */
|
pgoff_t next; /* the next page offset to be fallocated */
|
||||||
pgoff_t nr_falloced; /* how many new pages have been fallocated */
|
pgoff_t nr_falloced; /* how many new pages have been fallocated */
|
||||||
@ -468,23 +468,20 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
index = start;
|
index = start;
|
||||||
for ( ; ; ) {
|
while (index < end) {
|
||||||
cond_resched();
|
cond_resched();
|
||||||
|
|
||||||
pvec.nr = find_get_entries(mapping, index,
|
pvec.nr = find_get_entries(mapping, index,
|
||||||
min(end - index, (pgoff_t)PAGEVEC_SIZE),
|
min(end - index, (pgoff_t)PAGEVEC_SIZE),
|
||||||
pvec.pages, indices);
|
pvec.pages, indices);
|
||||||
if (!pvec.nr) {
|
if (!pvec.nr) {
|
||||||
if (index == start || unfalloc)
|
/* If all gone or hole-punch or unfalloc, we're done */
|
||||||
|
if (index == start || end != -1)
|
||||||
break;
|
break;
|
||||||
|
/* But if truncating, restart to make sure all gone */
|
||||||
index = start;
|
index = start;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((index == start || unfalloc) && indices[0] >= end) {
|
|
||||||
pagevec_remove_exceptionals(&pvec);
|
|
||||||
pagevec_release(&pvec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
mem_cgroup_uncharge_start();
|
mem_cgroup_uncharge_start();
|
||||||
for (i = 0; i < pagevec_count(&pvec); i++) {
|
for (i = 0; i < pagevec_count(&pvec); i++) {
|
||||||
struct page *page = pvec.pages[i];
|
struct page *page = pvec.pages[i];
|
||||||
@ -496,8 +493,12 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
|
|||||||
if (radix_tree_exceptional_entry(page)) {
|
if (radix_tree_exceptional_entry(page)) {
|
||||||
if (unfalloc)
|
if (unfalloc)
|
||||||
continue;
|
continue;
|
||||||
nr_swaps_freed += !shmem_free_swap(mapping,
|
if (shmem_free_swap(mapping, index, page)) {
|
||||||
index, page);
|
/* Swap was replaced by page: retry */
|
||||||
|
index--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nr_swaps_freed++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,6 +507,11 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
|
|||||||
if (page->mapping == mapping) {
|
if (page->mapping == mapping) {
|
||||||
VM_BUG_ON_PAGE(PageWriteback(page), page);
|
VM_BUG_ON_PAGE(PageWriteback(page), page);
|
||||||
truncate_inode_page(mapping, page);
|
truncate_inode_page(mapping, page);
|
||||||
|
} else {
|
||||||
|
/* Page was replaced by swap: retry */
|
||||||
|
unlock_page(page);
|
||||||
|
index--;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
@ -760,7 +766,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
|
|||||||
spin_lock(&inode->i_lock);
|
spin_lock(&inode->i_lock);
|
||||||
shmem_falloc = inode->i_private;
|
shmem_falloc = inode->i_private;
|
||||||
if (shmem_falloc &&
|
if (shmem_falloc &&
|
||||||
!shmem_falloc->mode &&
|
!shmem_falloc->waitq &&
|
||||||
index >= shmem_falloc->start &&
|
index >= shmem_falloc->start &&
|
||||||
index < shmem_falloc->next)
|
index < shmem_falloc->next)
|
||||||
shmem_falloc->nr_unswapped++;
|
shmem_falloc->nr_unswapped++;
|
||||||
@ -1248,38 +1254,58 @@ static int shmem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
|||||||
* Trinity finds that probing a hole which tmpfs is punching can
|
* Trinity finds that probing a hole which tmpfs is punching can
|
||||||
* prevent the hole-punch from ever completing: which in turn
|
* prevent the hole-punch from ever completing: which in turn
|
||||||
* locks writers out with its hold on i_mutex. So refrain from
|
* locks writers out with its hold on i_mutex. So refrain from
|
||||||
* faulting pages into the hole while it's being punched, and
|
* faulting pages into the hole while it's being punched. Although
|
||||||
* wait on i_mutex to be released if vmf->flags permits.
|
* shmem_undo_range() does remove the additions, it may be unable to
|
||||||
|
* keep up, as each new page needs its own unmap_mapping_range() call,
|
||||||
|
* and the i_mmap tree grows ever slower to scan if new vmas are added.
|
||||||
|
*
|
||||||
|
* It does not matter if we sometimes reach this check just before the
|
||||||
|
* hole-punch begins, so that one fault then races with the punch:
|
||||||
|
* we just need to make racing faults a rare case.
|
||||||
|
*
|
||||||
|
* The implementation below would be much simpler if we just used a
|
||||||
|
* standard mutex or completion: but we cannot take i_mutex in fault,
|
||||||
|
* and bloating every shmem inode for this unlikely case would be sad.
|
||||||
*/
|
*/
|
||||||
if (unlikely(inode->i_private)) {
|
if (unlikely(inode->i_private)) {
|
||||||
struct shmem_falloc *shmem_falloc;
|
struct shmem_falloc *shmem_falloc;
|
||||||
|
|
||||||
spin_lock(&inode->i_lock);
|
spin_lock(&inode->i_lock);
|
||||||
shmem_falloc = inode->i_private;
|
shmem_falloc = inode->i_private;
|
||||||
if (!shmem_falloc ||
|
if (shmem_falloc &&
|
||||||
shmem_falloc->mode != FALLOC_FL_PUNCH_HOLE ||
|
shmem_falloc->waitq &&
|
||||||
vmf->pgoff < shmem_falloc->start ||
|
vmf->pgoff >= shmem_falloc->start &&
|
||||||
vmf->pgoff >= shmem_falloc->next)
|
vmf->pgoff < shmem_falloc->next) {
|
||||||
shmem_falloc = NULL;
|
wait_queue_head_t *shmem_falloc_waitq;
|
||||||
spin_unlock(&inode->i_lock);
|
DEFINE_WAIT(shmem_fault_wait);
|
||||||
/*
|
|
||||||
* i_lock has protected us from taking shmem_falloc seriously
|
ret = VM_FAULT_NOPAGE;
|
||||||
* once return from shmem_fallocate() went back up that stack.
|
|
||||||
* i_lock does not serialize with i_mutex at all, but it does
|
|
||||||
* not matter if sometimes we wait unnecessarily, or sometimes
|
|
||||||
* miss out on waiting: we just need to make those cases rare.
|
|
||||||
*/
|
|
||||||
if (shmem_falloc) {
|
|
||||||
if ((vmf->flags & FAULT_FLAG_ALLOW_RETRY) &&
|
if ((vmf->flags & FAULT_FLAG_ALLOW_RETRY) &&
|
||||||
!(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) {
|
!(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) {
|
||||||
|
/* It's polite to up mmap_sem if we can */
|
||||||
up_read(&vma->vm_mm->mmap_sem);
|
up_read(&vma->vm_mm->mmap_sem);
|
||||||
mutex_lock(&inode->i_mutex);
|
ret = VM_FAULT_RETRY;
|
||||||
mutex_unlock(&inode->i_mutex);
|
|
||||||
return VM_FAULT_RETRY;
|
|
||||||
}
|
}
|
||||||
/* cond_resched? Leave that to GUP or return to user */
|
|
||||||
return VM_FAULT_NOPAGE;
|
shmem_falloc_waitq = shmem_falloc->waitq;
|
||||||
|
prepare_to_wait(shmem_falloc_waitq, &shmem_fault_wait,
|
||||||
|
TASK_UNINTERRUPTIBLE);
|
||||||
|
spin_unlock(&inode->i_lock);
|
||||||
|
schedule();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* shmem_falloc_waitq points into the shmem_fallocate()
|
||||||
|
* stack of the hole-punching task: shmem_falloc_waitq
|
||||||
|
* is usually invalid by the time we reach here, but
|
||||||
|
* finish_wait() does not dereference it in that case;
|
||||||
|
* though i_lock needed lest racing with wake_up_all().
|
||||||
|
*/
|
||||||
|
spin_lock(&inode->i_lock);
|
||||||
|
finish_wait(shmem_falloc_waitq, &shmem_fault_wait);
|
||||||
|
spin_unlock(&inode->i_lock);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
spin_unlock(&inode->i_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
error = shmem_getpage(inode, vmf->pgoff, &vmf->page, SGP_CACHE, &ret);
|
error = shmem_getpage(inode, vmf->pgoff, &vmf->page, SGP_CACHE, &ret);
|
||||||
@ -1774,13 +1800,13 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
|
|||||||
|
|
||||||
mutex_lock(&inode->i_mutex);
|
mutex_lock(&inode->i_mutex);
|
||||||
|
|
||||||
shmem_falloc.mode = mode & ~FALLOC_FL_KEEP_SIZE;
|
|
||||||
|
|
||||||
if (mode & FALLOC_FL_PUNCH_HOLE) {
|
if (mode & FALLOC_FL_PUNCH_HOLE) {
|
||||||
struct address_space *mapping = file->f_mapping;
|
struct address_space *mapping = file->f_mapping;
|
||||||
loff_t unmap_start = round_up(offset, PAGE_SIZE);
|
loff_t unmap_start = round_up(offset, PAGE_SIZE);
|
||||||
loff_t unmap_end = round_down(offset + len, PAGE_SIZE) - 1;
|
loff_t unmap_end = round_down(offset + len, PAGE_SIZE) - 1;
|
||||||
|
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(shmem_falloc_waitq);
|
||||||
|
|
||||||
|
shmem_falloc.waitq = &shmem_falloc_waitq;
|
||||||
shmem_falloc.start = unmap_start >> PAGE_SHIFT;
|
shmem_falloc.start = unmap_start >> PAGE_SHIFT;
|
||||||
shmem_falloc.next = (unmap_end + 1) >> PAGE_SHIFT;
|
shmem_falloc.next = (unmap_end + 1) >> PAGE_SHIFT;
|
||||||
spin_lock(&inode->i_lock);
|
spin_lock(&inode->i_lock);
|
||||||
@ -1792,8 +1818,13 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
|
|||||||
1 + unmap_end - unmap_start, 0);
|
1 + unmap_end - unmap_start, 0);
|
||||||
shmem_truncate_range(inode, offset, offset + len - 1);
|
shmem_truncate_range(inode, offset, offset + len - 1);
|
||||||
/* No need to unmap again: hole-punching leaves COWed pages */
|
/* No need to unmap again: hole-punching leaves COWed pages */
|
||||||
|
|
||||||
|
spin_lock(&inode->i_lock);
|
||||||
|
inode->i_private = NULL;
|
||||||
|
wake_up_all(&shmem_falloc_waitq);
|
||||||
|
spin_unlock(&inode->i_lock);
|
||||||
error = 0;
|
error = 0;
|
||||||
goto undone;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We need to check rlimit even when FALLOC_FL_KEEP_SIZE */
|
/* We need to check rlimit even when FALLOC_FL_KEEP_SIZE */
|
||||||
@ -1809,6 +1840,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shmem_falloc.waitq = NULL;
|
||||||
shmem_falloc.start = start;
|
shmem_falloc.start = start;
|
||||||
shmem_falloc.next = start;
|
shmem_falloc.next = start;
|
||||||
shmem_falloc.nr_falloced = 0;
|
shmem_falloc.nr_falloced = 0;
|
||||||
|
@ -355,14 +355,16 @@ void truncate_inode_pages_range(struct address_space *mapping,
|
|||||||
for ( ; ; ) {
|
for ( ; ; ) {
|
||||||
cond_resched();
|
cond_resched();
|
||||||
if (!pagevec_lookup_entries(&pvec, mapping, index,
|
if (!pagevec_lookup_entries(&pvec, mapping, index,
|
||||||
min(end - index, (pgoff_t)PAGEVEC_SIZE),
|
min(end - index, (pgoff_t)PAGEVEC_SIZE), indices)) {
|
||||||
indices)) {
|
/* If all gone from start onwards, we're done */
|
||||||
if (index == start)
|
if (index == start)
|
||||||
break;
|
break;
|
||||||
|
/* Otherwise restart to make sure all gone */
|
||||||
index = start;
|
index = start;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (index == start && indices[0] >= end) {
|
if (index == start && indices[0] >= end) {
|
||||||
|
/* All gone out of hole to be punched, we're done */
|
||||||
pagevec_remove_exceptionals(&pvec);
|
pagevec_remove_exceptionals(&pvec);
|
||||||
pagevec_release(&pvec);
|
pagevec_release(&pvec);
|
||||||
break;
|
break;
|
||||||
@ -373,8 +375,11 @@ void truncate_inode_pages_range(struct address_space *mapping,
|
|||||||
|
|
||||||
/* We rely upon deletion not changing page->index */
|
/* We rely upon deletion not changing page->index */
|
||||||
index = indices[i];
|
index = indices[i];
|
||||||
if (index >= end)
|
if (index >= end) {
|
||||||
|
/* Restart punch to make sure all gone */
|
||||||
|
index = start - 1;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (radix_tree_exceptional_entry(page)) {
|
if (radix_tree_exceptional_entry(page)) {
|
||||||
clear_exceptional_entry(mapping, index, page);
|
clear_exceptional_entry(mapping, index, page);
|
||||||
|
Loading…
Reference in New Issue
Block a user