[PATCH] ext3: ext3_symlink should use GFP_NOFS allocations inside

This patch fixes illegal __GFP_FS allocation inside ext3 transaction in
ext3_symlink(). Such allocation may re-enter ext3 code from
try_to_free_pages. But JBD/ext3 code keeps a pointer to current journal
handle in task_struct and, hence, is not reentrable.

This bug led to "Assertion failure in journal_dirty_metadata()" messages.

http://bugzilla.openvz.org/show_bug.cgi?id=115

Signed-off-by: Andrey Savochkin <saw@saw.sw.com.sg>
Signed-off-by: Kirill Korotaev <dev@openvz.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Kirill Korotaev and committed by Linus Torvalds 0adb25d2 8bd0ee93

+15 -3
+2 -1
fs/ext3/namei.c
··· 2141 2141 * We have a transaction open. All is sweetness. It also sets 2142 2142 * i_size in generic_commit_write(). 2143 2143 */ 2144 - err = page_symlink(inode, symname, l); 2144 + err = __page_symlink(inode, symname, l, 2145 + mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); 2145 2146 if (err) { 2146 2147 ext3_dec_count(handle, inode); 2147 2148 ext3_mark_inode_dirty(handle, inode);
+11 -2
fs/namei.c
··· 2613 2613 } 2614 2614 } 2615 2615 2616 - int page_symlink(struct inode *inode, const char *symname, int len) 2616 + int __page_symlink(struct inode *inode, const char *symname, int len, 2617 + gfp_t gfp_mask) 2617 2618 { 2618 2619 struct address_space *mapping = inode->i_mapping; 2619 - struct page *page = grab_cache_page(mapping, 0); 2620 + struct page *page; 2620 2621 int err = -ENOMEM; 2621 2622 char *kaddr; 2622 2623 2624 + page = find_or_create_page(mapping, 0, gfp_mask); 2623 2625 if (!page) 2624 2626 goto fail; 2625 2627 err = mapping->a_ops->prepare_write(NULL, page, 0, len-1); ··· 2656 2654 return err; 2657 2655 } 2658 2656 2657 + int page_symlink(struct inode *inode, const char *symname, int len) 2658 + { 2659 + return __page_symlink(inode, symname, len, 2660 + mapping_gfp_mask(inode->i_mapping)); 2661 + } 2662 + 2659 2663 struct inode_operations page_symlink_inode_operations = { 2660 2664 .readlink = generic_readlink, 2661 2665 .follow_link = page_follow_link_light, ··· 2680 2672 EXPORT_SYMBOL(page_follow_link_light); 2681 2673 EXPORT_SYMBOL(page_put_link); 2682 2674 EXPORT_SYMBOL(page_readlink); 2675 + EXPORT_SYMBOL(__page_symlink); 2683 2676 EXPORT_SYMBOL(page_symlink); 2684 2677 EXPORT_SYMBOL(page_symlink_inode_operations); 2685 2678 EXPORT_SYMBOL(path_lookup);
+2
include/linux/fs.h
··· 1664 1664 extern int page_readlink(struct dentry *, char __user *, int); 1665 1665 extern void *page_follow_link_light(struct dentry *, struct nameidata *); 1666 1666 extern void page_put_link(struct dentry *, struct nameidata *, void *); 1667 + extern int __page_symlink(struct inode *inode, const char *symname, int len, 1668 + gfp_t gfp_mask); 1667 1669 extern int page_symlink(struct inode *inode, const char *symname, int len); 1668 1670 extern struct inode_operations page_symlink_inode_operations; 1669 1671 extern int generic_readlink(struct dentry *, char __user *, int);