.. | .. |
---|
355 | 355 | * @blks: number of data blocks to be mapped. |
---|
356 | 356 | * @blocks_to_boundary: the offset in the indirect block |
---|
357 | 357 | * |
---|
358 | | - * return the total number of blocks to be allocate, including the |
---|
359 | | - * direct and indirect blocks. |
---|
| 358 | + * return the number of direct blocks to allocate. |
---|
360 | 359 | */ |
---|
361 | 360 | static int |
---|
362 | 361 | ext2_blks_to_allocate(Indirect * branch, int k, unsigned long blks, |
---|
.. | .. |
---|
389 | 388 | * ext2_alloc_blocks: multiple allocate blocks needed for a branch |
---|
390 | 389 | * @indirect_blks: the number of blocks need to allocate for indirect |
---|
391 | 390 | * blocks |
---|
392 | | - * |
---|
| 391 | + * @blks: the number of blocks need to allocate for direct blocks |
---|
393 | 392 | * @new_blocks: on return it will store the new block numbers for |
---|
394 | 393 | * the indirect blocks(if needed) and the first direct block, |
---|
395 | | - * @blks: on return it will store the total number of allocated |
---|
396 | | - * direct blocks |
---|
397 | 394 | */ |
---|
398 | 395 | static int ext2_alloc_blocks(struct inode *inode, |
---|
399 | 396 | ext2_fsblk_t goal, int indirect_blks, int blks, |
---|
.. | .. |
---|
451 | 448 | /** |
---|
452 | 449 | * ext2_alloc_branch - allocate and set up a chain of blocks. |
---|
453 | 450 | * @inode: owner |
---|
454 | | - * @num: depth of the chain (number of blocks to allocate) |
---|
| 451 | + * @indirect_blks: depth of the chain (number of blocks to allocate) |
---|
| 452 | + * @blks: number of allocated direct blocks |
---|
| 453 | + * @goal: preferred place for allocation |
---|
455 | 454 | * @offsets: offsets (in the blocks) to store the pointers to next. |
---|
456 | 455 | * @branch: place to store the chain in. |
---|
457 | 456 | * |
---|
.. | .. |
---|
720 | 719 | /* the number of blocks need to allocate for [d,t]indirect blocks */ |
---|
721 | 720 | indirect_blks = (chain + depth) - partial - 1; |
---|
722 | 721 | /* |
---|
723 | | - * Next look up the indirect map to count the totoal number of |
---|
| 722 | + * Next look up the indirect map to count the total number of |
---|
724 | 723 | * direct blocks to allocate for this branch. |
---|
725 | 724 | */ |
---|
726 | 725 | count = ext2_blks_to_allocate(partial, indirect_blks, |
---|
.. | .. |
---|
802 | 801 | |
---|
803 | 802 | #ifdef CONFIG_FS_DAX |
---|
804 | 803 | static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length, |
---|
805 | | - unsigned flags, struct iomap *iomap) |
---|
| 804 | + unsigned flags, struct iomap *iomap, struct iomap *srcmap) |
---|
806 | 805 | { |
---|
807 | 806 | unsigned int blkbits = inode->i_blkbits; |
---|
808 | 807 | unsigned long first_block = offset >> blkbits; |
---|
.. | .. |
---|
875 | 874 | return mpage_readpage(page, ext2_get_block); |
---|
876 | 875 | } |
---|
877 | 876 | |
---|
878 | | -static int |
---|
879 | | -ext2_readpages(struct file *file, struct address_space *mapping, |
---|
880 | | - struct list_head *pages, unsigned nr_pages) |
---|
| 877 | +static void ext2_readahead(struct readahead_control *rac) |
---|
881 | 878 | { |
---|
882 | | - return mpage_readpages(mapping, pages, nr_pages, ext2_get_block); |
---|
| 879 | + mpage_readahead(rac, ext2_get_block); |
---|
883 | 880 | } |
---|
884 | 881 | |
---|
885 | 882 | static int |
---|
.. | .. |
---|
958 | 955 | static int |
---|
959 | 956 | ext2_dax_writepages(struct address_space *mapping, struct writeback_control *wbc) |
---|
960 | 957 | { |
---|
961 | | - return dax_writeback_mapping_range(mapping, |
---|
962 | | - mapping->host->i_sb->s_bdev, wbc); |
---|
| 958 | + struct ext2_sb_info *sbi = EXT2_SB(mapping->host->i_sb); |
---|
| 959 | + |
---|
| 960 | + return dax_writeback_mapping_range(mapping, sbi->s_daxdev, wbc); |
---|
963 | 961 | } |
---|
964 | 962 | |
---|
965 | 963 | const struct address_space_operations ext2_aops = { |
---|
966 | 964 | .readpage = ext2_readpage, |
---|
967 | | - .readpages = ext2_readpages, |
---|
| 965 | + .readahead = ext2_readahead, |
---|
968 | 966 | .writepage = ext2_writepage, |
---|
969 | 967 | .write_begin = ext2_write_begin, |
---|
970 | 968 | .write_end = ext2_write_end, |
---|
.. | .. |
---|
978 | 976 | |
---|
979 | 977 | const struct address_space_operations ext2_nobh_aops = { |
---|
980 | 978 | .readpage = ext2_readpage, |
---|
981 | | - .readpages = ext2_readpages, |
---|
| 979 | + .readahead = ext2_readahead, |
---|
982 | 980 | .writepage = ext2_nobh_writepage, |
---|
983 | 981 | .write_begin = ext2_nobh_write_begin, |
---|
984 | 982 | .write_end = nobh_write_end, |
---|
.. | .. |
---|
1242 | 1240 | mark_inode_dirty(inode); |
---|
1243 | 1241 | ext2_free_branches(inode, &nr, &nr+1, 1); |
---|
1244 | 1242 | } |
---|
| 1243 | + fallthrough; |
---|
1245 | 1244 | case EXT2_IND_BLOCK: |
---|
1246 | 1245 | nr = i_data[EXT2_DIND_BLOCK]; |
---|
1247 | 1246 | if (nr) { |
---|
.. | .. |
---|
1249 | 1248 | mark_inode_dirty(inode); |
---|
1250 | 1249 | ext2_free_branches(inode, &nr, &nr+1, 2); |
---|
1251 | 1250 | } |
---|
| 1251 | + fallthrough; |
---|
1252 | 1252 | case EXT2_DIND_BLOCK: |
---|
1253 | 1253 | nr = i_data[EXT2_TIND_BLOCK]; |
---|
1254 | 1254 | if (nr) { |
---|
.. | .. |
---|
1399 | 1399 | struct inode *ext2_iget (struct super_block *sb, unsigned long ino) |
---|
1400 | 1400 | { |
---|
1401 | 1401 | struct ext2_inode_info *ei; |
---|
1402 | | - struct buffer_head * bh; |
---|
| 1402 | + struct buffer_head * bh = NULL; |
---|
1403 | 1403 | struct ext2_inode *raw_inode; |
---|
1404 | 1404 | struct inode *inode; |
---|
1405 | 1405 | long ret = -EIO; |
---|
.. | .. |
---|
1445 | 1445 | */ |
---|
1446 | 1446 | if (inode->i_nlink == 0 && (inode->i_mode == 0 || ei->i_dtime)) { |
---|
1447 | 1447 | /* this inode is deleted */ |
---|
1448 | | - brelse (bh); |
---|
1449 | 1448 | ret = -ESTALE; |
---|
1450 | 1449 | goto bad_inode; |
---|
1451 | 1450 | } |
---|
.. | .. |
---|
1462 | 1461 | !ext2_data_block_valid(EXT2_SB(sb), ei->i_file_acl, 1)) { |
---|
1463 | 1462 | ext2_error(sb, "ext2_iget", "bad extended attribute block %u", |
---|
1464 | 1463 | ei->i_file_acl); |
---|
1465 | | - brelse(bh); |
---|
1466 | 1464 | ret = -EFSCORRUPTED; |
---|
1467 | 1465 | goto bad_inode; |
---|
1468 | 1466 | } |
---|
.. | .. |
---|
1525 | 1523 | return inode; |
---|
1526 | 1524 | |
---|
1527 | 1525 | bad_inode: |
---|
| 1526 | + brelse(bh); |
---|
1528 | 1527 | iget_failed(inode); |
---|
1529 | 1528 | return ERR_PTR(ret); |
---|
1530 | 1529 | } |
---|
.. | .. |
---|
1638 | 1637 | return __ext2_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL); |
---|
1639 | 1638 | } |
---|
1640 | 1639 | |
---|
| 1640 | +int ext2_getattr(const struct path *path, struct kstat *stat, |
---|
| 1641 | + u32 request_mask, unsigned int query_flags) |
---|
| 1642 | +{ |
---|
| 1643 | + struct inode *inode = d_inode(path->dentry); |
---|
| 1644 | + struct ext2_inode_info *ei = EXT2_I(inode); |
---|
| 1645 | + unsigned int flags; |
---|
| 1646 | + |
---|
| 1647 | + flags = ei->i_flags & EXT2_FL_USER_VISIBLE; |
---|
| 1648 | + if (flags & EXT2_APPEND_FL) |
---|
| 1649 | + stat->attributes |= STATX_ATTR_APPEND; |
---|
| 1650 | + if (flags & EXT2_COMPR_FL) |
---|
| 1651 | + stat->attributes |= STATX_ATTR_COMPRESSED; |
---|
| 1652 | + if (flags & EXT2_IMMUTABLE_FL) |
---|
| 1653 | + stat->attributes |= STATX_ATTR_IMMUTABLE; |
---|
| 1654 | + if (flags & EXT2_NODUMP_FL) |
---|
| 1655 | + stat->attributes |= STATX_ATTR_NODUMP; |
---|
| 1656 | + stat->attributes_mask |= (STATX_ATTR_APPEND | |
---|
| 1657 | + STATX_ATTR_COMPRESSED | |
---|
| 1658 | + STATX_ATTR_ENCRYPTED | |
---|
| 1659 | + STATX_ATTR_IMMUTABLE | |
---|
| 1660 | + STATX_ATTR_NODUMP); |
---|
| 1661 | + |
---|
| 1662 | + generic_fillattr(inode, stat); |
---|
| 1663 | + return 0; |
---|
| 1664 | +} |
---|
| 1665 | + |
---|
1641 | 1666 | int ext2_setattr(struct dentry *dentry, struct iattr *iattr) |
---|
1642 | 1667 | { |
---|
1643 | 1668 | struct inode *inode = d_inode(dentry); |
---|