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_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4

Pull ext4 fixes from Ted Ts'o:
"Fix various bug fixes in ext4 caused by races and memory allocation
failures"

* tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
ext4: fix fdatasync(2) after extent manipulation operations
ext4: fix data corruption for mmap writes
ext4: fix data corruption with EXT4_GET_BLOCKS_ZERO
ext4: fix quota charging for shared xattr blocks
ext4: remove redundant check for encrypted file on dio write path
ext4: remove unused d_name argument from ext4_search_dir() et al.
ext4: fix off-by-one error when writing back pages before dio read
ext4: fix off-by-one on max nr_pages in ext4_find_unwritten_pgoff()
ext4: keep existing extra fields when inode expands
ext4: handle the rest of ext4_mb_load_buddy() ENOMEM errors
ext4: fix off-by-in in loop termination in ext4_find_unwritten_pgoff()
ext4: fix SEEK_HOLE
jbd2: preserve original nofs flag during journal restart
ext4: clear lockdep subtype for quota files on quota off

+149 -120
+4
fs/ext4/acl.c
··· 4 4 * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de> 5 5 */ 6 6 7 + #include <linux/quotaops.h> 7 8 #include "ext4_jbd2.h" 8 9 #include "ext4.h" 9 10 #include "xattr.h" ··· 233 232 handle_t *handle; 234 233 int error, retries = 0; 235 234 235 + error = dquot_initialize(inode); 236 + if (error) 237 + return error; 236 238 retry: 237 239 handle = ext4_journal_start(inode, EXT4_HT_XATTR, 238 240 ext4_jbd2_credits_xattr(inode));
-2
fs/ext4/ext4.h
··· 2523 2523 int buf_size, 2524 2524 struct inode *dir, 2525 2525 struct ext4_filename *fname, 2526 - const struct qstr *d_name, 2527 2526 unsigned int offset, 2528 2527 struct ext4_dir_entry_2 **res_dir); 2529 2528 extern int ext4_generic_delete_entry(handle_t *handle, ··· 3006 3007 int *has_inline_data); 3007 3008 extern struct buffer_head *ext4_find_inline_entry(struct inode *dir, 3008 3009 struct ext4_filename *fname, 3009 - const struct qstr *d_name, 3010 3010 struct ext4_dir_entry_2 **res_dir, 3011 3011 int *has_inline_data); 3012 3012 extern int ext4_delete_inline_entry(handle_t *handle,
+42 -43
fs/ext4/extents.c
··· 3413 3413 struct ext4_sb_info *sbi; 3414 3414 struct ext4_extent_header *eh; 3415 3415 struct ext4_map_blocks split_map; 3416 - struct ext4_extent zero_ex; 3416 + struct ext4_extent zero_ex1, zero_ex2; 3417 3417 struct ext4_extent *ex, *abut_ex; 3418 3418 ext4_lblk_t ee_block, eof_block; 3419 3419 unsigned int ee_len, depth, map_len = map->m_len; 3420 3420 int allocated = 0, max_zeroout = 0; 3421 3421 int err = 0; 3422 - int split_flag = 0; 3422 + int split_flag = EXT4_EXT_DATA_VALID2; 3423 3423 3424 3424 ext_debug("ext4_ext_convert_to_initialized: inode %lu, logical" 3425 3425 "block %llu, max_blocks %u\n", inode->i_ino, ··· 3436 3436 ex = path[depth].p_ext; 3437 3437 ee_block = le32_to_cpu(ex->ee_block); 3438 3438 ee_len = ext4_ext_get_actual_len(ex); 3439 - zero_ex.ee_len = 0; 3439 + zero_ex1.ee_len = 0; 3440 + zero_ex2.ee_len = 0; 3440 3441 3441 3442 trace_ext4_ext_convert_to_initialized_enter(inode, map, ex); 3442 3443 ··· 3577 3576 if (ext4_encrypted_inode(inode)) 3578 3577 max_zeroout = 0; 3579 3578 3580 - /* If extent is less than s_max_zeroout_kb, zeroout directly */ 3581 - if (max_zeroout && (ee_len <= max_zeroout)) { 3582 - err = ext4_ext_zeroout(inode, ex); 3583 - if (err) 3584 - goto out; 3585 - zero_ex.ee_block = ex->ee_block; 3586 - zero_ex.ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex)); 3587 - ext4_ext_store_pblock(&zero_ex, ext4_ext_pblock(ex)); 3588 - 3589 - err = ext4_ext_get_access(handle, inode, path + depth); 3590 - if (err) 3591 - goto out; 3592 - ext4_ext_mark_initialized(ex); 3593 - ext4_ext_try_to_merge(handle, inode, path, ex); 3594 - err = ext4_ext_dirty(handle, inode, path + path->p_depth); 3595 - goto out; 3596 - } 3597 - 3598 3579 /* 3599 - * four cases: 3580 + * five cases: 3600 3581 * 1. split the extent into three extents. 3601 - * 2. split the extent into two extents, zeroout the first half. 3602 - * 3. split the extent into two extents, zeroout the second half. 3582 + * 2. split the extent into two extents, zeroout the head of the first 3583 + * extent. 3584 + * 3. split the extent into two extents, zeroout the tail of the second 3585 + * extent. 3603 3586 * 4. split the extent into two extents with out zeroout. 3587 + * 5. no splitting needed, just possibly zeroout the head and / or the 3588 + * tail of the extent. 3604 3589 */ 3605 3590 split_map.m_lblk = map->m_lblk; 3606 3591 split_map.m_len = map->m_len; 3607 3592 3608 - if (max_zeroout && (allocated > map->m_len)) { 3593 + if (max_zeroout && (allocated > split_map.m_len)) { 3609 3594 if (allocated <= max_zeroout) { 3610 - /* case 3 */ 3611 - zero_ex.ee_block = 3612 - cpu_to_le32(map->m_lblk); 3613 - zero_ex.ee_len = cpu_to_le16(allocated); 3614 - ext4_ext_store_pblock(&zero_ex, 3615 - ext4_ext_pblock(ex) + map->m_lblk - ee_block); 3616 - err = ext4_ext_zeroout(inode, &zero_ex); 3595 + /* case 3 or 5 */ 3596 + zero_ex1.ee_block = 3597 + cpu_to_le32(split_map.m_lblk + 3598 + split_map.m_len); 3599 + zero_ex1.ee_len = 3600 + cpu_to_le16(allocated - split_map.m_len); 3601 + ext4_ext_store_pblock(&zero_ex1, 3602 + ext4_ext_pblock(ex) + split_map.m_lblk + 3603 + split_map.m_len - ee_block); 3604 + err = ext4_ext_zeroout(inode, &zero_ex1); 3617 3605 if (err) 3618 3606 goto out; 3619 - split_map.m_lblk = map->m_lblk; 3620 3607 split_map.m_len = allocated; 3621 - } else if (map->m_lblk - ee_block + map->m_len < max_zeroout) { 3622 - /* case 2 */ 3623 - if (map->m_lblk != ee_block) { 3624 - zero_ex.ee_block = ex->ee_block; 3625 - zero_ex.ee_len = cpu_to_le16(map->m_lblk - 3608 + } 3609 + if (split_map.m_lblk - ee_block + split_map.m_len < 3610 + max_zeroout) { 3611 + /* case 2 or 5 */ 3612 + if (split_map.m_lblk != ee_block) { 3613 + zero_ex2.ee_block = ex->ee_block; 3614 + zero_ex2.ee_len = cpu_to_le16(split_map.m_lblk - 3626 3615 ee_block); 3627 - ext4_ext_store_pblock(&zero_ex, 3616 + ext4_ext_store_pblock(&zero_ex2, 3628 3617 ext4_ext_pblock(ex)); 3629 - err = ext4_ext_zeroout(inode, &zero_ex); 3618 + err = ext4_ext_zeroout(inode, &zero_ex2); 3630 3619 if (err) 3631 3620 goto out; 3632 3621 } 3633 3622 3623 + split_map.m_len += split_map.m_lblk - ee_block; 3634 3624 split_map.m_lblk = ee_block; 3635 - split_map.m_len = map->m_lblk - ee_block + map->m_len; 3636 3625 allocated = map->m_len; 3637 3626 } 3638 3627 } ··· 3633 3642 err = 0; 3634 3643 out: 3635 3644 /* If we have gotten a failure, don't zero out status tree */ 3636 - if (!err) 3637 - err = ext4_zeroout_es(inode, &zero_ex); 3645 + if (!err) { 3646 + err = ext4_zeroout_es(inode, &zero_ex1); 3647 + if (!err) 3648 + err = ext4_zeroout_es(inode, &zero_ex2); 3649 + } 3638 3650 return err ? err : allocated; 3639 3651 } 3640 3652 ··· 4877 4883 4878 4884 /* Zero out partial block at the edges of the range */ 4879 4885 ret = ext4_zero_partial_blocks(handle, inode, offset, len); 4886 + if (ret >= 0) 4887 + ext4_update_inode_fsync_trans(handle, inode, 1); 4880 4888 4881 4889 if (file->f_flags & O_SYNC) 4882 4890 ext4_handle_sync(handle); ··· 5565 5569 ext4_handle_sync(handle); 5566 5570 inode->i_mtime = inode->i_ctime = current_time(inode); 5567 5571 ext4_mark_inode_dirty(handle, inode); 5572 + ext4_update_inode_fsync_trans(handle, inode, 1); 5568 5573 5569 5574 out_stop: 5570 5575 ext4_journal_stop(handle); ··· 5739 5742 up_write(&EXT4_I(inode)->i_data_sem); 5740 5743 if (IS_SYNC(inode)) 5741 5744 ext4_handle_sync(handle); 5745 + if (ret >= 0) 5746 + ext4_update_inode_fsync_trans(handle, inode, 1); 5742 5747 5743 5748 out_stop: 5744 5749 ext4_journal_stop(handle);
+16 -38
fs/ext4/file.c
··· 474 474 endoff = (loff_t)end_blk << blkbits; 475 475 476 476 index = startoff >> PAGE_SHIFT; 477 - end = endoff >> PAGE_SHIFT; 477 + end = (endoff - 1) >> PAGE_SHIFT; 478 478 479 479 pagevec_init(&pvec, 0); 480 480 do { 481 481 int i, num; 482 482 unsigned long nr_pages; 483 483 484 - num = min_t(pgoff_t, end - index, PAGEVEC_SIZE); 484 + num = min_t(pgoff_t, end - index, PAGEVEC_SIZE - 1) + 1; 485 485 nr_pages = pagevec_lookup(&pvec, inode->i_mapping, index, 486 486 (pgoff_t)num); 487 - if (nr_pages == 0) { 488 - if (whence == SEEK_DATA) 489 - break; 490 - 491 - BUG_ON(whence != SEEK_HOLE); 492 - /* 493 - * If this is the first time to go into the loop and 494 - * offset is not beyond the end offset, it will be a 495 - * hole at this offset 496 - */ 497 - if (lastoff == startoff || lastoff < endoff) 498 - found = 1; 487 + if (nr_pages == 0) 499 488 break; 500 - } 501 - 502 - /* 503 - * If this is the first time to go into the loop and 504 - * offset is smaller than the first page offset, it will be a 505 - * hole at this offset. 506 - */ 507 - if (lastoff == startoff && whence == SEEK_HOLE && 508 - lastoff < page_offset(pvec.pages[0])) { 509 - found = 1; 510 - break; 511 - } 512 489 513 490 for (i = 0; i < nr_pages; i++) { 514 491 struct page *page = pvec.pages[i]; 515 492 struct buffer_head *bh, *head; 516 493 517 494 /* 518 - * If the current offset is not beyond the end of given 519 - * range, it will be a hole. 495 + * If current offset is smaller than the page offset, 496 + * there is a hole at this offset. 520 497 */ 521 - if (lastoff < endoff && whence == SEEK_HOLE && 522 - page->index > end) { 498 + if (whence == SEEK_HOLE && lastoff < endoff && 499 + lastoff < page_offset(pvec.pages[i])) { 523 500 found = 1; 524 501 *offset = lastoff; 525 502 goto out; 526 503 } 504 + 505 + if (page->index > end) 506 + goto out; 527 507 528 508 lock_page(page); 529 509 ··· 544 564 unlock_page(page); 545 565 } 546 566 547 - /* 548 - * The no. of pages is less than our desired, that would be a 549 - * hole in there. 550 - */ 551 - if (nr_pages < num && whence == SEEK_HOLE) { 552 - found = 1; 553 - *offset = lastoff; 567 + /* The no. of pages is less than our desired, we are done. */ 568 + if (nr_pages < num) 554 569 break; 555 - } 556 570 557 571 index = pvec.pages[i - 1]->index + 1; 558 572 pagevec_release(&pvec); 559 573 } while (index <= end); 560 574 575 + if (whence == SEEK_HOLE && lastoff < endoff) { 576 + found = 1; 577 + *offset = lastoff; 578 + } 561 579 out: 562 580 pagevec_release(&pvec); 563 581 return found;
+2 -3
fs/ext4/inline.c
··· 1627 1627 1628 1628 struct buffer_head *ext4_find_inline_entry(struct inode *dir, 1629 1629 struct ext4_filename *fname, 1630 - const struct qstr *d_name, 1631 1630 struct ext4_dir_entry_2 **res_dir, 1632 1631 int *has_inline_data) 1633 1632 { ··· 1648 1649 EXT4_INLINE_DOTDOT_SIZE; 1649 1650 inline_size = EXT4_MIN_INLINE_DATA_SIZE - EXT4_INLINE_DOTDOT_SIZE; 1650 1651 ret = ext4_search_dir(iloc.bh, inline_start, inline_size, 1651 - dir, fname, d_name, 0, res_dir); 1652 + dir, fname, 0, res_dir); 1652 1653 if (ret == 1) 1653 1654 goto out_find; 1654 1655 if (ret < 0) ··· 1661 1662 inline_size = ext4_get_inline_size(dir) - EXT4_MIN_INLINE_DATA_SIZE; 1662 1663 1663 1664 ret = ext4_search_dir(iloc.bh, inline_start, inline_size, 1664 - dir, fname, d_name, 0, res_dir); 1665 + dir, fname, 0, res_dir); 1665 1666 if (ret == 1) 1666 1667 goto out_find; 1667 1668
+22 -8
fs/ext4/inode.c
··· 2124 2124 static int mpage_submit_page(struct mpage_da_data *mpd, struct page *page) 2125 2125 { 2126 2126 int len; 2127 - loff_t size = i_size_read(mpd->inode); 2127 + loff_t size; 2128 2128 int err; 2129 2129 2130 2130 BUG_ON(page->index != mpd->first_page); 2131 + clear_page_dirty_for_io(page); 2132 + /* 2133 + * We have to be very careful here! Nothing protects writeback path 2134 + * against i_size changes and the page can be writeably mapped into 2135 + * page tables. So an application can be growing i_size and writing 2136 + * data through mmap while writeback runs. clear_page_dirty_for_io() 2137 + * write-protects our page in page tables and the page cannot get 2138 + * written to again until we release page lock. So only after 2139 + * clear_page_dirty_for_io() we are safe to sample i_size for 2140 + * ext4_bio_write_page() to zero-out tail of the written page. We rely 2141 + * on the barrier provided by TestClearPageDirty in 2142 + * clear_page_dirty_for_io() to make sure i_size is really sampled only 2143 + * after page tables are updated. 2144 + */ 2145 + size = i_size_read(mpd->inode); 2131 2146 if (page->index == size >> PAGE_SHIFT) 2132 2147 len = size & ~PAGE_MASK; 2133 2148 else 2134 2149 len = PAGE_SIZE; 2135 - clear_page_dirty_for_io(page); 2136 2150 err = ext4_bio_write_page(&mpd->io_submit, page, len, mpd->wbc, false); 2137 2151 if (!err) 2138 2152 mpd->wbc->nr_to_write--; ··· 3643 3629 get_block_func = ext4_dio_get_block_unwritten_async; 3644 3630 dio_flags = DIO_LOCKING; 3645 3631 } 3646 - #ifdef CONFIG_EXT4_FS_ENCRYPTION 3647 - BUG_ON(ext4_encrypted_inode(inode) && S_ISREG(inode->i_mode)); 3648 - #endif 3649 3632 ret = __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter, 3650 3633 get_block_func, ext4_end_io_dio, NULL, 3651 3634 dio_flags); ··· 3724 3713 */ 3725 3714 inode_lock_shared(inode); 3726 3715 ret = filemap_write_and_wait_range(mapping, iocb->ki_pos, 3727 - iocb->ki_pos + count); 3716 + iocb->ki_pos + count - 1); 3728 3717 if (ret) 3729 3718 goto out_unlock; 3730 3719 ret = __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, ··· 4218 4207 4219 4208 inode->i_mtime = inode->i_ctime = current_time(inode); 4220 4209 ext4_mark_inode_dirty(handle, inode); 4210 + if (ret >= 0) 4211 + ext4_update_inode_fsync_trans(handle, inode, 1); 4221 4212 out_stop: 4222 4213 ext4_journal_stop(handle); 4223 4214 out_dio: ··· 5650 5637 /* No extended attributes present */ 5651 5638 if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR) || 5652 5639 header->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC)) { 5653 - memset((void *)raw_inode + EXT4_GOOD_OLD_INODE_SIZE, 0, 5654 - new_extra_isize); 5640 + memset((void *)raw_inode + EXT4_GOOD_OLD_INODE_SIZE + 5641 + EXT4_I(inode)->i_extra_isize, 0, 5642 + new_extra_isize - EXT4_I(inode)->i_extra_isize); 5655 5643 EXT4_I(inode)->i_extra_isize = new_extra_isize; 5656 5644 return 0; 5657 5645 }
+14 -9
fs/ext4/mballoc.c
··· 3887 3887 3888 3888 err = ext4_mb_load_buddy(sb, group, &e4b); 3889 3889 if (err) { 3890 - ext4_error(sb, "Error loading buddy information for %u", group); 3890 + ext4_warning(sb, "Error %d loading buddy information for %u", 3891 + err, group); 3891 3892 put_bh(bitmap_bh); 3892 3893 return 0; 3893 3894 } ··· 4045 4044 BUG_ON(pa->pa_type != MB_INODE_PA); 4046 4045 group = ext4_get_group_number(sb, pa->pa_pstart); 4047 4046 4048 - err = ext4_mb_load_buddy(sb, group, &e4b); 4047 + err = ext4_mb_load_buddy_gfp(sb, group, &e4b, 4048 + GFP_NOFS|__GFP_NOFAIL); 4049 4049 if (err) { 4050 - ext4_error(sb, "Error loading buddy information for %u", 4051 - group); 4050 + ext4_error(sb, "Error %d loading buddy information for %u", 4051 + err, group); 4052 4052 continue; 4053 4053 } 4054 4054 ··· 4305 4303 spin_unlock(&lg->lg_prealloc_lock); 4306 4304 4307 4305 list_for_each_entry_safe(pa, tmp, &discard_list, u.pa_tmp_list) { 4306 + int err; 4308 4307 4309 4308 group = ext4_get_group_number(sb, pa->pa_pstart); 4310 - if (ext4_mb_load_buddy(sb, group, &e4b)) { 4311 - ext4_error(sb, "Error loading buddy information for %u", 4312 - group); 4309 + err = ext4_mb_load_buddy_gfp(sb, group, &e4b, 4310 + GFP_NOFS|__GFP_NOFAIL); 4311 + if (err) { 4312 + ext4_error(sb, "Error %d loading buddy information for %u", 4313 + err, group); 4313 4314 continue; 4314 4315 } 4315 4316 ext4_lock_group(sb, group); ··· 5132 5127 5133 5128 ret = ext4_mb_load_buddy(sb, group, &e4b); 5134 5129 if (ret) { 5135 - ext4_error(sb, "Error in loading buddy " 5136 - "information for %u", group); 5130 + ext4_warning(sb, "Error %d loading buddy information for %u", 5131 + ret, group); 5137 5132 return ret; 5138 5133 } 5139 5134 bitmap = e4b.bd_bitmap;
+5 -8
fs/ext4/namei.c
··· 1155 1155 static inline int search_dirblock(struct buffer_head *bh, 1156 1156 struct inode *dir, 1157 1157 struct ext4_filename *fname, 1158 - const struct qstr *d_name, 1159 1158 unsigned int offset, 1160 1159 struct ext4_dir_entry_2 **res_dir) 1161 1160 { 1162 1161 return ext4_search_dir(bh, bh->b_data, dir->i_sb->s_blocksize, dir, 1163 - fname, d_name, offset, res_dir); 1162 + fname, offset, res_dir); 1164 1163 } 1165 1164 1166 1165 /* ··· 1261 1262 */ 1262 1263 int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size, 1263 1264 struct inode *dir, struct ext4_filename *fname, 1264 - const struct qstr *d_name, 1265 1265 unsigned int offset, struct ext4_dir_entry_2 **res_dir) 1266 1266 { 1267 1267 struct ext4_dir_entry_2 * de; ··· 1353 1355 1354 1356 if (ext4_has_inline_data(dir)) { 1355 1357 int has_inline_data = 1; 1356 - ret = ext4_find_inline_entry(dir, &fname, d_name, res_dir, 1358 + ret = ext4_find_inline_entry(dir, &fname, res_dir, 1357 1359 &has_inline_data); 1358 1360 if (has_inline_data) { 1359 1361 if (inlined) ··· 1445 1447 goto next; 1446 1448 } 1447 1449 set_buffer_verified(bh); 1448 - i = search_dirblock(bh, dir, &fname, d_name, 1450 + i = search_dirblock(bh, dir, &fname, 1449 1451 block << EXT4_BLOCK_SIZE_BITS(sb), res_dir); 1450 1452 if (i == 1) { 1451 1453 EXT4_I(dir)->i_dir_start_lookup = block; ··· 1486 1488 { 1487 1489 struct super_block * sb = dir->i_sb; 1488 1490 struct dx_frame frames[2], *frame; 1489 - const struct qstr *d_name = fname->usr_fname; 1490 1491 struct buffer_head *bh; 1491 1492 ext4_lblk_t block; 1492 1493 int retval; ··· 1502 1505 if (IS_ERR(bh)) 1503 1506 goto errout; 1504 1507 1505 - retval = search_dirblock(bh, dir, fname, d_name, 1508 + retval = search_dirblock(bh, dir, fname, 1506 1509 block << EXT4_BLOCK_SIZE_BITS(sb), 1507 1510 res_dir); 1508 1511 if (retval == 1) ··· 1527 1530 1528 1531 bh = NULL; 1529 1532 errout: 1530 - dxtrace(printk(KERN_DEBUG "%s not found\n", d_name->name)); 1533 + dxtrace(printk(KERN_DEBUG "%s not found\n", fname->usr_fname->name)); 1531 1534 success: 1532 1535 dx_release(frames); 1533 1536 return bh;
+8 -9
fs/ext4/super.c
··· 848 848 { 849 849 int type; 850 850 851 - if (ext4_has_feature_quota(sb)) { 852 - dquot_disable(sb, -1, 853 - DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); 854 - } else { 855 - /* Use our quota_off function to clear inode flags etc. */ 856 - for (type = 0; type < EXT4_MAXQUOTAS; type++) 857 - ext4_quota_off(sb, type); 858 - } 851 + /* Use our quota_off function to clear inode flags etc. */ 852 + for (type = 0; type < EXT4_MAXQUOTAS; type++) 853 + ext4_quota_off(sb, type); 859 854 } 860 855 #else 861 856 static inline void ext4_quota_off_umount(struct super_block *sb) ··· 1174 1179 return res; 1175 1180 } 1176 1181 1182 + res = dquot_initialize(inode); 1183 + if (res) 1184 + return res; 1177 1185 retry: 1178 1186 handle = ext4_journal_start(inode, EXT4_HT_MISC, 1179 1187 ext4_jbd2_credits_xattr(inode)); ··· 5483 5485 goto out; 5484 5486 5485 5487 err = dquot_quota_off(sb, type); 5486 - if (err) 5488 + if (err || ext4_has_feature_quota(sb)) 5487 5489 goto out_put; 5488 5490 5489 5491 inode_lock(inode); ··· 5503 5505 out_unlock: 5504 5506 inode_unlock(inode); 5505 5507 out_put: 5508 + lockdep_set_quota_inode(inode, I_DATA_SEM_NORMAL); 5506 5509 iput(inode); 5507 5510 return err; 5508 5511 out:
+8
fs/ext4/xattr.c
··· 888 888 else { 889 889 u32 ref; 890 890 891 + WARN_ON_ONCE(dquot_initialize_needed(inode)); 892 + 891 893 /* The old block is released after updating 892 894 the inode. */ 893 895 error = dquot_alloc_block(inode, ··· 955 953 } else { 956 954 /* We need to allocate a new block */ 957 955 ext4_fsblk_t goal, block; 956 + 957 + WARN_ON_ONCE(dquot_initialize_needed(inode)); 958 958 959 959 goal = ext4_group_first_block_no(sb, 960 960 EXT4_I(inode)->i_block_group); ··· 1170 1166 return -EINVAL; 1171 1167 if (strlen(name) > 255) 1172 1168 return -ERANGE; 1169 + 1173 1170 ext4_write_lock_xattr(inode, &no_expand); 1174 1171 1175 1172 error = ext4_reserve_inode_write(handle, inode, &is.iloc); ··· 1272 1267 int error, retries = 0; 1273 1268 int credits = ext4_jbd2_credits_xattr(inode); 1274 1269 1270 + error = dquot_initialize(inode); 1271 + if (error) 1272 + return error; 1275 1273 retry: 1276 1274 handle = ext4_journal_start(inode, EXT4_HT_XATTR, credits); 1277 1275 if (IS_ERR(handle)) {
+6
fs/jbd2/transaction.c
··· 680 680 681 681 rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_); 682 682 handle->h_buffer_credits = nblocks; 683 + /* 684 + * Restore the original nofs context because the journal restart 685 + * is basically the same thing as journal stop and start. 686 + * start_this_handle will start a new nofs context. 687 + */ 688 + memalloc_nofs_restore(handle->saved_alloc_context); 683 689 ret = start_this_handle(journal, handle, gfp_mask); 684 690 return ret; 685 691 }
+16
fs/quota/dquot.c
··· 1512 1512 } 1513 1513 EXPORT_SYMBOL(dquot_initialize); 1514 1514 1515 + bool dquot_initialize_needed(struct inode *inode) 1516 + { 1517 + struct dquot **dquots; 1518 + int i; 1519 + 1520 + if (!dquot_active(inode)) 1521 + return false; 1522 + 1523 + dquots = i_dquot(inode); 1524 + for (i = 0; i < MAXQUOTAS; i++) 1525 + if (!dquots[i] && sb_has_quota_active(inode->i_sb, i)) 1526 + return true; 1527 + return false; 1528 + } 1529 + EXPORT_SYMBOL(dquot_initialize_needed); 1530 + 1515 1531 /* 1516 1532 * Release all quotas referenced by inode. 1517 1533 *
+6
include/linux/quotaops.h
··· 44 44 void inode_reclaim_rsv_space(struct inode *inode, qsize_t number); 45 45 46 46 int dquot_initialize(struct inode *inode); 47 + bool dquot_initialize_needed(struct inode *inode); 47 48 void dquot_drop(struct inode *inode); 48 49 struct dquot *dqget(struct super_block *sb, struct kqid qid); 49 50 static inline struct dquot *dqgrab(struct dquot *dquot) ··· 206 205 static inline int dquot_initialize(struct inode *inode) 207 206 { 208 207 return 0; 208 + } 209 + 210 + static inline bool dquot_initialize_needed(struct inode *inode) 211 + { 212 + return false; 209 213 } 210 214 211 215 static inline void dquot_drop(struct inode *inode)