ext3: ext3_symlink should use GFP_NOFS allocations inside
Subsystems (4)
PATCH 1/1 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
Thanks,
KirillP.S. against 2.6.16-rc5
fs/ext2/namei.c renamed from fs/ext2/namei.c.symlnk +1 -1
@@ -185,7 +185,7 @@ static int ext2_symlink (struct inode * inode->i_mapping->a_ops = &ext2_nobh_aops; else inode->i_mapping->a_ops = &ext2_aops; - err =page_symlink (inode, symname, l); + err =page_symlink (inode, symname, l,GFP_KERNEL );if (err) goto out_fail; }else {
fs/ext3/namei.c renamed from fs/ext3/namei.c.symlnk +1 -1
@@ -2141,7 +2141,7 @@ retry:* We have a transaction open. All is sweetness. It also sets * i_size in generic_commit_write(). */ - err =page_symlink (inode, symname, l); + err =page_symlink (inode, symname, l,GFP_NOFS );if (err) {ext3_dec_count (handle, inode);ext3_mark_inode_dirty (handle, inode);
fs/hfsplus/dir.c renamed from fs/hfsplus/dir.c.symlnk +1 -1
@@ -406,7 +406,7 @@ static int hfsplus_symlink(struct inodeif (!inode)return -ENOSPC ; - res =page_symlink (inode, symname,strlen (symname) +1 ); + res =page_symlink (inode, symname,strlen (symname) +1 ,GFP_KERNEL );if (res) { inode->i_nlink =0 ;hfsplus_delete_inode (inode);
fs/hugetlbfs/inode.c renamed from fs/hugetlbfs/inode.c.symlnk +1 -1
@@ -482,7 +482,7 @@ static int hugetlbfs_symlink(struct inod gid, S_IFLNK|S_IRWXUGO, 0);if (inode) {int l =strlen (symname)+1 ; - error =page_symlink (inode, symname, l); + error =page_symlink (inode, symname, l,GFP_KERNEL );if (!error) {d_instantiate (dentry, inode);dget (dentry);
fs/minix/namei.c renamed from fs/minix/namei.c.symlnk +1 -1
@@ -116,7 +116,7 @@ static int minix_symlink(struct inode * inode->i_mode =S_IFLNK |0777 ;minix_set_inode (inode,0 ); - err =page_symlink (inode, symname, i); + err =page_symlink (inode, symname, i,GFP_KERNEL );if (err) goto out_fail;
fs/namei.c renamed from fs/namei.c.symlnk +5 -2
@@ -2613,13 +2613,16 @@ void page_put_link(struct dentry *dentry } } -int page_symlink (struct inode *inode,const char *symname,int len) +int page_symlink (struct inode *inode,const char *symname,int len, +gfp_t gfp_mask) {struct address_space *mapping = inode->i_mapping; -struct page *page =grab_cache_page (mapping,0 ); +struct page *page;int err = -ENOMEM ;char *kaddr; + page =find_or_create_page (mapping,0 , +mapping_gfp_mask (mapping) | gfp_mask);if (!page) goto fail; err = mapping->a_ops->prepare_write (NULL , page,0 , len-1 );
fs/ramfs/inode.c renamed from fs/ramfs/inode.c.symlnk +1 -1
@@ -131,7 +131,7 @@ static int ramfs_symlink(struct inode * inode =ramfs_get_inode (dir->i_sb,S_IFLNK |S_IRWXUGO ,0 );if (inode) {int l =strlen (symname)+1 ; - error =page_symlink (inode, symname, l); + error =page_symlink (inode, symname, l,GFP_KERNEL );if (!error) {if (dir->i_mode &S_ISGID ) inode->i_gid = dir->i_gid;
fs/sysv/namei.c renamed from fs/sysv/namei.c.symlnk +1 -1
@@ -114,7 +114,7 @@ static int sysv_symlink(struct inode * d goto out;sysv_set_inode (inode,0 ); - err =page_symlink (inode, symname, l); + err =page_symlink (inode, symname, l,GFP_KERNEL );if (err) goto out_fail;
fs/ufs/namei.c renamed from fs/ufs/namei.c.symlnk +1 -1
@@ -156,7 +156,7 @@ static int ufs_symlink (struct inode * d/* slow symlink */ inode->i_op = &page_symlink_inode_operations; inode->i_mapping->a_ops = &ufs_aops; - err =page_symlink (inode, symname, l); + err =page_symlink (inode, symname, l,GFP_KERNEL );if (err) goto out_fail; }else {
include/linux/fs.h renamed from include/linux/fs.h.symlnk +2 -1
@@ -1669,7 +1669,8 @@ extern int vfs_follow_link(struct nameidextern int page_readlink (struct dentry *,char __user *,int );extern void *page_follow_link_light (struct dentry *,struct nameidata *);extern void page_put_link (struct dentry *,struct nameidata *,void *); -extern int page_symlink (struct inode *inode,const char *symname,int len); +extern int page_symlink (struct inode *inode,const char *symname,int len, +gfp_t gfp_mask);extern struct inode_operations page_symlink_inode_operations;extern int generic_readlink (struct dentry *,char __user *,int );extern void generic_fillattr (struct inode *,struct kstat *);
Quoted 5 lines · Kirill Korotaev
This patch fixes illegal
__GFP_FSallocation inside ext3 transaction inext3_symlink().
Such allocation may re-enter ext3 code fromtry_to_free_pages. But JBD/ext3 code keeps a pointer to current journal handle intask_structand, hence, is not reentrable.
New helper, please.
Quoted 9 lines · Kirill Korotaev
This patch fixes illegal
__GFP_FSallocation inside ext3 transaction inext3_symlink().
Such allocation may re-enter ext3 code fromtry_to_free_pages. But JBD/ext3 code keeps a pointer to current journal handle intask_structand, hence, is not reentrable.This bug led to "Assertion failure in
journal_dirty_metadata()" messages.
Is it the same bug as http://marc.theaimsgroup.com/?t=113870577100003&r=1&w=2 ?
Thanks.
/mjt
Quoted 8 lines · Michael Tokarev
Quoted 6 lines · Kirill Korotaev
This patch fixes illegal
__GFP_FSallocation inside ext3 transaction inext3_symlink().
Such allocation may re-enter ext3 code fromtry_to_free_pages. But JBD/ext3 code keeps a pointer to current journal handle intask_structand, hence, is not reentrable.
Quoted 6 lines
Quoted 3 lines
This bug led to "Assertion failure in
journal_dirty_metadata()" messages.Is it the same bug as http://marc.theaimsgroup.com/?t=113870577100003&r=1&w=2 ?
yes.