The patch titled shmem: fix BUG in shmem_writepage has been added to the -mm tree. Its filename is shmem-fix-bug-in-shmem_writepage.patch *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: shmem: fix BUG in shmem_writepage From: Miklos Szeredi <mszeredi@xxxxxxx> BUG_ON(!entry) in shmem_writepage() is triggered in rare circumstances. The cause is that shmem_truncate_range() erroneously removes partially truncated directory pages at the end of the range. A later reclaim on pages pointing to these removed directories triggers the BUG. Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxx> Cc: Hugh Dickins <hugh@xxxxxxxxxxx> Cc: Badari Pulavarty <pbadari@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/shmem.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff -puN mm/shmem.c~shmem-fix-bug-in-shmem_writepage mm/shmem.c --- a/mm/shmem.c~shmem-fix-bug-in-shmem_writepage +++ a/mm/shmem.c @@ -543,7 +543,9 @@ static void shmem_truncate_range(struct if (*dir) { diroff = ((idx - ENTRIES_PER_PAGEPAGE/2) % ENTRIES_PER_PAGEPAGE) / ENTRIES_PER_PAGE; - if (!diroff && !offset) { + if (!diroff && !offset && + (!punch_hole || + limit - idx >= ENTRIES_PER_PAGEPAGE)) { *dir = NULL; nr_pages_to_free++; list_add(&middir->lru, &pages_to_free); @@ -570,9 +572,12 @@ static void shmem_truncate_range(struct } stage = idx + ENTRIES_PER_PAGEPAGE; middir = *dir; - *dir = NULL; - nr_pages_to_free++; - list_add(&middir->lru, &pages_to_free); + if (!punch_hole || + limit - idx >= ENTRIES_PER_PAGEPAGE) { + *dir = NULL; + nr_pages_to_free++; + list_add(&middir->lru, &pages_to_free); + } shmem_dir_unmap(dir); cond_resched(); dir = shmem_dir_map(middir); @@ -598,7 +603,8 @@ static void shmem_truncate_range(struct } if (offset) offset = 0; - else if (subdir && !page_private(subdir)) { + else if (subdir && + (!punch_hole || limit - idx >= ENTRIES_PER_PAGE)) { dir[diroff] = NULL; nr_pages_to_free++; list_add(&subdir->lru, &pages_to_free); _ Patches currently in -mm which might be from mszeredi@xxxxxxx are shmem-fix-bug-in-shmem_writepage.patch shmem-dont-release-lock-for-hole-punching.patch fix-quadratic-behavior-of-shrink_dcache_parent.patch mm-shrink-parent-dentries-when-shrinking-slab.patch add-filesystem-subtype-support.patch consolidate-generic_writepages-and-mpage_writepages.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html