Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tmpfs: fix kernel BUG in shmem_delete_inode

SuSE's insserve initscript ordering program hits kernel BUG at mm/shmem.c:814
on 2.6.26. It's using posix_fadvise on directories, and the shmem_readpage
method added in 2.6.23 is letting POSIX_FADV_WILLNEED allocate useless pages
to a tmpfs directory, incrementing i_blocks count but never decrementing it.

Fix this by assigning shmem_aops (pointing to readpage and writepage and
set_page_dirty) only when it's needed, on a regular file or a long symlink.

Many thanks to Kel for outstanding bugreport and steps to reproduce it.

Reported-by: Kel Modderman <kel@otaku42.de>
Tested-by: Kel Modderman <kel@otaku42.de>
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Cc: <stable@kernel.org> [2.6.25.x, 2.6.26.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Hugh Dickins and committed by
Linus Torvalds
14fcc23f ca5b172b

+2 -1
+2 -1
mm/shmem.c
··· 1513 1513 inode->i_uid = current->fsuid; 1514 1514 inode->i_gid = current->fsgid; 1515 1515 inode->i_blocks = 0; 1516 - inode->i_mapping->a_ops = &shmem_aops; 1517 1516 inode->i_mapping->backing_dev_info = &shmem_backing_dev_info; 1518 1517 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 1519 1518 inode->i_generation = get_seconds(); ··· 1527 1528 init_special_inode(inode, mode, dev); 1528 1529 break; 1529 1530 case S_IFREG: 1531 + inode->i_mapping->a_ops = &shmem_aops; 1530 1532 inode->i_op = &shmem_inode_operations; 1531 1533 inode->i_fop = &shmem_file_operations; 1532 1534 mpol_shared_policy_init(&info->policy, ··· 1929 1929 return error; 1930 1930 } 1931 1931 unlock_page(page); 1932 + inode->i_mapping->a_ops = &shmem_aops; 1932 1933 inode->i_op = &shmem_symlink_inode_operations; 1933 1934 kaddr = kmap_atomic(page, KM_USER0); 1934 1935 memcpy(kaddr, symname, len);