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.

Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4

Pull jbd2 bug fixes from Ted Ts'o:
"Two jbd2 bug fixes, one of which is a regression fix"

* tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
jbd2: Fix oops in jbd2_journal_file_inode()
jbd2: Fix use after free after error in jbd2_journal_dirty_metadata()

+52 -21
+1
fs/ext4/ext4.h
··· 2086 2086 extern void ext4_dirty_inode(struct inode *, int); 2087 2087 extern int ext4_change_inode_journal_flag(struct inode *, int); 2088 2088 extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *); 2089 + extern int ext4_inode_attach_jinode(struct inode *inode); 2089 2090 extern int ext4_can_truncate(struct inode *inode); 2090 2091 extern void ext4_truncate(struct inode *); 2091 2092 extern int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length);
+4 -4
fs/ext4/ext4_jbd2.c
··· 255 255 set_buffer_prio(bh); 256 256 if (ext4_handle_valid(handle)) { 257 257 err = jbd2_journal_dirty_metadata(handle, bh); 258 - if (err) { 259 - /* Errors can only happen if there is a bug */ 260 - handle->h_err = err; 261 - __ext4_journal_stop(where, line, handle); 258 + /* Errors can only happen if there is a bug */ 259 + if (WARN_ON_ONCE(err)) { 260 + ext4_journal_abort_handle(where, line, __func__, bh, 261 + handle, err); 262 262 } 263 263 } else { 264 264 if (inode)
+4 -17
fs/ext4/file.c
··· 219 219 { 220 220 struct super_block *sb = inode->i_sb; 221 221 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 222 - struct ext4_inode_info *ei = EXT4_I(inode); 223 222 struct vfsmount *mnt = filp->f_path.mnt; 224 223 struct path path; 225 224 char buf[64], *cp; ··· 258 259 * Set up the jbd2_inode if we are opening the inode for 259 260 * writing and the journal is present 260 261 */ 261 - if (sbi->s_journal && !ei->jinode && (filp->f_mode & FMODE_WRITE)) { 262 - struct jbd2_inode *jinode = jbd2_alloc_inode(GFP_KERNEL); 263 - 264 - spin_lock(&inode->i_lock); 265 - if (!ei->jinode) { 266 - if (!jinode) { 267 - spin_unlock(&inode->i_lock); 268 - return -ENOMEM; 269 - } 270 - ei->jinode = jinode; 271 - jbd2_journal_init_jbd_inode(ei->jinode, inode); 272 - jinode = NULL; 273 - } 274 - spin_unlock(&inode->i_lock); 275 - if (unlikely(jinode != NULL)) 276 - jbd2_free_inode(jinode); 262 + if (filp->f_mode & FMODE_WRITE) { 263 + int ret = ext4_inode_attach_jinode(inode); 264 + if (ret < 0) 265 + return ret; 277 266 } 278 267 return dquot_file_open(inode, filp); 279 268 }
+43
fs/ext4/inode.c
··· 3533 3533 offset; 3534 3534 } 3535 3535 3536 + if (offset & (sb->s_blocksize - 1) || 3537 + (offset + length) & (sb->s_blocksize - 1)) { 3538 + /* 3539 + * Attach jinode to inode for jbd2 if we do any zeroing of 3540 + * partial block 3541 + */ 3542 + ret = ext4_inode_attach_jinode(inode); 3543 + if (ret < 0) 3544 + goto out_mutex; 3545 + 3546 + } 3547 + 3536 3548 first_block_offset = round_up(offset, sb->s_blocksize); 3537 3549 last_block_offset = round_down((offset + length), sb->s_blocksize) - 1; 3538 3550 ··· 3613 3601 return ret; 3614 3602 } 3615 3603 3604 + int ext4_inode_attach_jinode(struct inode *inode) 3605 + { 3606 + struct ext4_inode_info *ei = EXT4_I(inode); 3607 + struct jbd2_inode *jinode; 3608 + 3609 + if (ei->jinode || !EXT4_SB(inode->i_sb)->s_journal) 3610 + return 0; 3611 + 3612 + jinode = jbd2_alloc_inode(GFP_KERNEL); 3613 + spin_lock(&inode->i_lock); 3614 + if (!ei->jinode) { 3615 + if (!jinode) { 3616 + spin_unlock(&inode->i_lock); 3617 + return -ENOMEM; 3618 + } 3619 + ei->jinode = jinode; 3620 + jbd2_journal_init_jbd_inode(ei->jinode, inode); 3621 + jinode = NULL; 3622 + } 3623 + spin_unlock(&inode->i_lock); 3624 + if (unlikely(jinode != NULL)) 3625 + jbd2_free_inode(jinode); 3626 + return 0; 3627 + } 3628 + 3616 3629 /* 3617 3630 * ext4_truncate() 3618 3631 * ··· 3695 3658 3696 3659 ext4_inline_data_truncate(inode, &has_inline); 3697 3660 if (has_inline) 3661 + return; 3662 + } 3663 + 3664 + /* If we zero-out tail of the page, we have to create jinode for jbd2 */ 3665 + if (inode->i_size & (inode->i_sb->s_blocksize - 1)) { 3666 + if (ext4_inode_attach_jinode(inode) < 0) 3698 3667 return; 3699 3668 } 3700 3669