Re: kernel BUG at mm/truncate.c:475!

From: Robert ÅwiÄcki
Date: Thu Dec 16 2010 - 09:51:01 EST


>
> Yes, this looks to me like what is needed for now.
>
> I'd feel rather happier about it if I thought it would also fix
> Robert's kernel BUG at /build/buildd/linux-2.6.35/mm/filemap.c:128!
> but I've still not found time to explain that one.
>
> Robert, you said yours is usually repeatable in 12 hours - any chance
> you could give iknowthis a run with the patch below, to see if it
> makes any difference to yours? Â(I admit I don't see how it would.)

Hi Hugh,

Do you still want me to do that?

> Thanks,
> Hugh
>
>>
>> ---
> Âfs/gfs2/main.c   |  Â9 +--------
> Âfs/inode.c     |  22 +++++++++++++++-------
> Âfs/nilfs2/btnode.c | Â Â5 -----
> Âfs/nilfs2/btnode.h | Â Â1 -
> Âfs/nilfs2/mdt.c  Â|  Â4 ++--
> Âfs/nilfs2/page.c  |  13 -------------
> Âfs/nilfs2/page.h  |  Â1 -
> Âfs/nilfs2/super.c Â| Â Â2 +-
> Âinclude/linux/fs.h | Â Â2 ++
> Âmm/memory.c    Â|  Â2 ++
> Â10 files changed, 23 insertions(+), 38 deletions(-)
>
> Index: linux.git/mm/memory.c
> ===================================================================
> --- linux.git.orig/mm/memory.c Â2010-12-11 14:09:55.000000000 +0100
> +++ linux.git/mm/memory.c    2010-12-14 11:20:47.000000000 +0100
> @@ -2572,6 +2572,7 @@ void unmap_mapping_range(struct address_
> Â Â Â Â Â Â Â Âdetails.last_index = ULONG_MAX;
> Â Â Â Âdetails.i_mmap_lock = &mapping->i_mmap_lock;
>
> + Â Â Â mutex_lock(&mapping->unmap_mutex);
> Â Â Â Âspin_lock(&mapping->i_mmap_lock);
>
> Â Â Â Â/* Protect against endless unmapping loops */
> @@ -2588,6 +2589,7 @@ void unmap_mapping_range(struct address_
> Â Â Â Âif (unlikely(!list_empty(&mapping->i_mmap_nonlinear)))
> Â Â Â Â Â Â Â Âunmap_mapping_range_list(&mapping->i_mmap_nonlinear, &details);
> Â Â Â Âspin_unlock(&mapping->i_mmap_lock);Hi,
> + Â Â Â mutex_unlock(&mapping->unmap_mutex);
> Â}
> ÂEXPORT_SYMBOL(unmap_mapping_range);
>
> Index: linux.git/fs/gfs2/main.c
> ===================================================================
> --- linux.git.orig/fs/gfs2/main.c    2010-11-26 10:52:16.000000000 +0100
> +++ linux.git/fs/gfs2/main.c  Â2010-12-14 11:15:53.000000000 +0100
> @@ -59,14 +59,7 @@ static void gfs2_init_gl_aspace_once(voi
> Â Â Â Âstruct address_space *mapping = (struct address_space *)(gl + 1);
>
> Â Â Â Âgfs2_init_glock_once(gl);
> - Â Â Â memset(mapping, 0, sizeof(*mapping));
> - Â Â Â INIT_RADIX_TREE(&mapping->page_tree, GFP_ATOMIC);
> - Â Â Â spin_lock_init(&mapping->tree_lock);
> - Â Â Â spin_lock_init(&mapping->i_mmap_lock);
> - Â Â Â INIT_LIST_HEAD(&mapping->private_list);
> - Â Â Â spin_lock_init(&mapping->private_lock);
> - Â Â Â INIT_RAW_PRIO_TREE_ROOT(&mapping->i_mmap);
> - Â Â Â INIT_LIST_HEAD(&mapping->i_mmap_nonlinear);
> + Â Â Â address_space_init_once(mapping);
> Â}
>
> Â/**
> Index: linux.git/fs/inode.c
> ===================================================================
> --- linux.git.orig/fs/inode.c  2010-11-26 10:52:16.000000000 +0100
> +++ linux.git/fs/inode.c    Â2010-12-14 11:21:49.000000000 +0100
> @@ -280,6 +280,20 @@ static void destroy_inode(struct inode *
> Â Â Â Â Â Â Â Âkmem_cache_free(inode_cachep, (inode));
> Â}
>
> +void address_space_init_once(struct address_space *mapping)
> +{
> + Â Â Â memset(mapping, 0, sizeof(*mapping));
> + Â Â Â INIT_RADIX_TREE(&mapping->page_tree, GFP_ATOMIC);
> + Â Â Â spin_lock_init(&mapping->tree_lock);
> + Â Â Â spin_lock_init(&mapping->i_mmap_lock);
> + Â Â Â INIT_LIST_HEAD(&mapping->private_list);
> + Â Â Â spin_lock_init(&mapping->private_lock);
> + Â Â Â INIT_RAW_PRIO_TREE_ROOT(&mapping->i_mmap);
> + Â Â Â INIT_LIST_HEAD(&mapping->i_mmap_nonlinear);
> + Â Â Â mutex_init(&mapping->unmap_mutex);
> +}
> +EXPORT_SYMBOL(address_space_init_once);
> +
> Â/*
> Â* These are initializations that only need to be done
> Â* once, because the fields are idempotent across use
> @@ -293,13 +307,7 @@ void inode_init_once(struct inode *inode
> Â Â Â ÂINIT_LIST_HEAD(&inode->i_devices);
> Â Â Â ÂINIT_LIST_HEAD(&inode->i_wb_list);
> Â Â Â ÂINIT_LIST_HEAD(&inode->i_lru);
> - Â Â Â INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC);
> - Â Â Â spin_lock_init(&inode->i_data.tree_lock);
> - Â Â Â spin_lock_init(&inode->i_data.i_mmap_lock);
> - Â Â Â INIT_LIST_HEAD(&inode->i_data.private_list);
> - Â Â Â spin_lock_init(&inode->i_data.private_lock);
> - Â Â Â INIT_RAW_PRIO_TREE_ROOT(&inode->i_data.i_mmap);
> - Â Â Â INIT_LIST_HEAD(&inode->i_data.i_mmap_nonlinear);
> + Â Â Â address_space_init_once(&inode->i_data);
> Â Â Â Âi_size_ordered_init(inode);
> Â#ifdef CONFIG_FSNOTIFY
> Â Â Â ÂINIT_HLIST_HEAD(&inode->i_fsnotify_marks);
> Index: linux.git/fs/nilfs2/btnode.c
> ===================================================================
> --- linux.git.orig/fs/nilfs2/btnode.c  2010-11-26 10:52:17.000000000 +0100
> +++ linux.git/fs/nilfs2/btnode.c    Â2010-12-14 11:19:52.000000000 +0100
> @@ -35,11 +35,6 @@
> Â#include "btnode.h"
>
>
> -void nilfs_btnode_cache_init_once(struct address_space *btnc)
> -{
> - Â Â Â nilfs_mapping_init_once(btnc);
> -}
> -
> Âstatic const struct address_space_operations def_btnode_aops = {
>    Â.sync_page       Â= block_sync_page,
> Â};
> Index: linux.git/fs/nilfs2/btnode.h
> ===================================================================
> --- linux.git.orig/fs/nilfs2/btnode.h  2010-10-05 18:49:12.000000000 +0200
> +++ linux.git/fs/nilfs2/btnode.h    Â2010-12-14 11:20:01.000000000 +0100
> @@ -37,7 +37,6 @@ struct nilfs_btnode_chkey_ctxt {
> Â Â Â Âstruct buffer_head *newbh;
> Â};
>
> -void nilfs_btnode_cache_init_once(struct address_space *);
> Âvoid nilfs_btnode_cache_init(struct address_space *, struct backing_dev_info *);
> Âvoid nilfs_btnode_cache_clear(struct address_space *);
> Âstruct buffer_head *nilfs_btnode_create_block(struct address_space *btnc,
> Index: linux.git/fs/nilfs2/mdt.c
> ===================================================================
> --- linux.git.orig/fs/nilfs2/mdt.c   Â2010-11-26 10:52:17.000000000 +0100
> +++ linux.git/fs/nilfs2/mdt.c  2010-12-14 11:18:18.000000000 +0100
> @@ -460,9 +460,9 @@ int nilfs_mdt_setup_shadow_map(struct in
> Â Â Â Âstruct backing_dev_info *bdi = inode->i_sb->s_bdi;
>
> Â Â Â ÂINIT_LIST_HEAD(&shadow->frozen_buffers);
> - Â Â Â nilfs_mapping_init_once(&shadow->frozen_data);
> + Â Â Â address_space_init_once(&shadow->frozen_data);
> Â Â Â Ânilfs_mapping_init(&shadow->frozen_data, bdi, &shadow_map_aops);
> - Â Â Â nilfs_mapping_init_once(&shadow->frozen_btnodes);
> + Â Â Â address_space_init_once(&shadow->frozen_btnodes);
> Â Â Â Ânilfs_mapping_init(&shadow->frozen_btnodes, bdi, &shadow_map_aops);
> Â Â Â Âmi->mi_shadow = shadow;
> Â Â Â Âreturn 0;
> Index: linux.git/fs/nilfs2/page.c
> ===================================================================
> --- linux.git.orig/fs/nilfs2/page.c   2010-11-26 10:52:17.000000000 +0100
> +++ linux.git/fs/nilfs2/page.c Â2010-12-14 11:17:26.000000000 +0100
> @@ -492,19 +492,6 @@ unsigned nilfs_page_count_clean_buffers(
> Â Â Â Âreturn nc;
> Â}
>
> -void nilfs_mapping_init_once(struct address_space *mapping)
> -{
> - Â Â Â memset(mapping, 0, sizeof(*mapping));
> - Â Â Â INIT_RADIX_TREE(&mapping->page_tree, GFP_ATOMIC);
> - Â Â Â spin_lock_init(&mapping->tree_lock);
> - Â Â Â INIT_LIST_HEAD(&mapping->private_list);
> - Â Â Â spin_lock_init(&mapping->private_lock);
> -
> - Â Â Â spin_lock_init(&mapping->i_mmap_lock);
> - Â Â Â INIT_RAW_PRIO_TREE_ROOT(&mapping->i_mmap);
> - Â Â Â INIT_LIST_HEAD(&mapping->i_mmap_nonlinear);
> -}
> -
> Âvoid nilfs_mapping_init(struct address_space *mapping,
> Â Â Â Â Â Â Â Â Â Â Â Âstruct backing_dev_info *bdi,
> Â Â Â Â Â Â Â Â Â Â Â Âconst struct address_space_operations *aops)
> Index: linux.git/fs/nilfs2/page.h
> ===================================================================
> --- linux.git.orig/fs/nilfs2/page.h   2010-11-26 10:52:17.000000000 +0100
> +++ linux.git/fs/nilfs2/page.h Â2010-12-14 11:17:35.000000000 +0100
> @@ -61,7 +61,6 @@ void nilfs_free_private_page(struct page
> Âint nilfs_copy_dirty_pages(struct address_space *, struct address_space *);
> Âvoid nilfs_copy_back_pages(struct address_space *, struct address_space *);
> Âvoid nilfs_clear_dirty_pages(struct address_space *);
> -void nilfs_mapping_init_once(struct address_space *mapping);
> Âvoid nilfs_mapping_init(struct address_space *mapping,
> Â Â Â Â Â Â Â Â Â Â Â Âstruct backing_dev_info *bdi,
> Â Â Â Â Â Â Â Â Â Â Â Âconst struct address_space_operations *aops);
> Index: linux.git/fs/nilfs2/super.c
> ===================================================================
> --- linux.git.orig/fs/nilfs2/super.c  Â2010-11-26 10:52:17.000000000 +0100
> +++ linux.git/fs/nilfs2/super.c 2010-12-14 11:20:19.000000000 +0100
> @@ -1262,7 +1262,7 @@ static void nilfs_inode_init_once(void *
> Â#ifdef CONFIG_NILFS_XATTR
> Â Â Â Âinit_rwsem(&ii->xattr_sem);
> Â#endif
> - Â Â Â nilfs_btnode_cache_init_once(&ii->i_btnode_cache);
> + Â Â Â address_space_init_once(&ii->i_btnode_cache);
> Â Â Â Âii->i_bmap = &ii->i_bmap_data;
> Â Â Â Âinode_init_once(&ii->vfs_inode);
> Â}
> Index: linux.git/include/linux/fs.h
> ===================================================================
> --- linux.git.orig/include/linux/fs.h  2010-12-07 20:17:55.000000000 +0100
> +++ linux.git/include/linux/fs.h    Â2010-12-14 11:21:30.000000000 +0100
> @@ -645,6 +645,7 @@ struct address_space {
>    Âspinlock_t       Âprivate_lock;  /* for use by the address_space */
>    Âstruct list_head    Âprivate_list;  /* ditto */
>    Âstruct address_space  Â*assoc_mapping; /* ditto */
> +    struct mutex      Âunmap_mutex;  Â/* to protect unmapping */
> Â} __attribute__((aligned(sizeof(long))));
> Â Â Â Â/*
> Â Â Â Â * On most architectures that alignment is already the case; but
> @@ -2205,6 +2206,7 @@ extern loff_t vfs_llseek(struct file *fi
>
> Âextern int inode_init_always(struct super_block *, struct inode *);
> Âextern void inode_init_once(struct inode *);
> +extern void address_space_init_once(struct address_space *mapping);
> Âextern void ihold(struct inode * inode);
> Âextern void iput(struct inode *);
> Âextern struct inode * igrab(struct inode *);
>



--
Robert ÅwiÄcki
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/