Lines Matching refs:dn

606 static void __set_data_blkaddr(struct dnode_of_data *dn)  in __set_data_blkaddr()  argument
608 struct f2fs_node *rn = F2FS_NODE(dn->node_page); in __set_data_blkaddr()
612 if (IS_INODE(dn->node_page) && f2fs_has_extra_attr(dn->inode)) in __set_data_blkaddr()
613 base = get_extra_isize(dn->inode); in __set_data_blkaddr()
617 addr_array[base + dn->ofs_in_node] = cpu_to_le32(dn->data_blkaddr); in __set_data_blkaddr()
626 void f2fs_set_data_blkaddr(struct dnode_of_data *dn) in f2fs_set_data_blkaddr() argument
628 f2fs_wait_on_page_writeback(dn->node_page, NODE, true); in f2fs_set_data_blkaddr()
629 __set_data_blkaddr(dn); in f2fs_set_data_blkaddr()
630 if (set_page_dirty(dn->node_page)) in f2fs_set_data_blkaddr()
631 dn->node_changed = true; in f2fs_set_data_blkaddr()
634 void f2fs_update_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr) in f2fs_update_data_blkaddr() argument
636 dn->data_blkaddr = blkaddr; in f2fs_update_data_blkaddr()
637 f2fs_set_data_blkaddr(dn); in f2fs_update_data_blkaddr()
638 f2fs_update_extent_cache(dn); in f2fs_update_data_blkaddr()
642 int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count) in f2fs_reserve_new_blocks() argument
644 struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode); in f2fs_reserve_new_blocks()
650 if (unlikely(is_inode_flag_set(dn->inode, FI_NO_ALLOC))) in f2fs_reserve_new_blocks()
652 if (unlikely((err = inc_valid_block_count(sbi, dn->inode, &count)))) in f2fs_reserve_new_blocks()
655 trace_f2fs_reserve_new_blocks(dn->inode, dn->nid, in f2fs_reserve_new_blocks()
656 dn->ofs_in_node, count); in f2fs_reserve_new_blocks()
658 f2fs_wait_on_page_writeback(dn->node_page, NODE, true); in f2fs_reserve_new_blocks()
660 for (; count > 0; dn->ofs_in_node++) { in f2fs_reserve_new_blocks()
661 block_t blkaddr = datablock_addr(dn->inode, in f2fs_reserve_new_blocks()
662 dn->node_page, dn->ofs_in_node); in f2fs_reserve_new_blocks()
664 dn->data_blkaddr = NEW_ADDR; in f2fs_reserve_new_blocks()
665 __set_data_blkaddr(dn); in f2fs_reserve_new_blocks()
670 if (set_page_dirty(dn->node_page)) in f2fs_reserve_new_blocks()
671 dn->node_changed = true; in f2fs_reserve_new_blocks()
676 int f2fs_reserve_new_block(struct dnode_of_data *dn) in f2fs_reserve_new_block() argument
678 unsigned int ofs_in_node = dn->ofs_in_node; in f2fs_reserve_new_block()
681 ret = f2fs_reserve_new_blocks(dn, 1); in f2fs_reserve_new_block()
682 dn->ofs_in_node = ofs_in_node; in f2fs_reserve_new_block()
686 int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index) in f2fs_reserve_block() argument
688 bool need_put = dn->inode_page ? false : true; in f2fs_reserve_block()
691 err = f2fs_get_dnode_of_data(dn, index, ALLOC_NODE); in f2fs_reserve_block()
695 if (dn->data_blkaddr == NULL_ADDR) in f2fs_reserve_block()
696 err = f2fs_reserve_new_block(dn); in f2fs_reserve_block()
698 f2fs_put_dnode(dn); in f2fs_reserve_block()
702 int f2fs_get_block(struct dnode_of_data *dn, pgoff_t index) in f2fs_get_block() argument
705 struct inode *inode = dn->inode; in f2fs_get_block()
708 dn->data_blkaddr = ei.blk + index - ei.fofs; in f2fs_get_block()
712 return f2fs_reserve_block(dn, index); in f2fs_get_block()
719 struct dnode_of_data dn; in f2fs_get_read_data_page() local
729 dn.data_blkaddr = ei.blk + index - ei.fofs; in f2fs_get_read_data_page()
733 set_new_dnode(&dn, inode, NULL, NULL, 0); in f2fs_get_read_data_page()
734 err = f2fs_get_dnode_of_data(&dn, index, LOOKUP_NODE); in f2fs_get_read_data_page()
737 f2fs_put_dnode(&dn); in f2fs_get_read_data_page()
739 if (unlikely(dn.data_blkaddr == NULL_ADDR)) { in f2fs_get_read_data_page()
756 if (dn.data_blkaddr == NEW_ADDR) { in f2fs_get_read_data_page()
764 err = f2fs_submit_page_read(inode, page, dn.data_blkaddr); in f2fs_get_read_data_page()
841 struct dnode_of_data dn; in f2fs_get_new_data_page() local
854 set_new_dnode(&dn, inode, ipage, NULL, 0); in f2fs_get_new_data_page()
855 err = f2fs_reserve_block(&dn, index); in f2fs_get_new_data_page()
861 f2fs_put_dnode(&dn); in f2fs_get_new_data_page()
866 if (dn.data_blkaddr == NEW_ADDR) { in f2fs_get_new_data_page()
886 static int __allocate_data_block(struct dnode_of_data *dn, int seg_type) in __allocate_data_block() argument
888 struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode); in __allocate_data_block()
895 if (unlikely(is_inode_flag_set(dn->inode, FI_NO_ALLOC))) in __allocate_data_block()
898 err = f2fs_get_node_info(sbi, dn->nid, &ni); in __allocate_data_block()
902 dn->data_blkaddr = datablock_addr(dn->inode, in __allocate_data_block()
903 dn->node_page, dn->ofs_in_node); in __allocate_data_block()
904 if (dn->data_blkaddr == NEW_ADDR) in __allocate_data_block()
907 if (unlikely((err = inc_valid_block_count(sbi, dn->inode, &count)))) in __allocate_data_block()
911 set_summary(&sum, dn->nid, dn->ofs_in_node, ni.version); in __allocate_data_block()
912 old_blkaddr = dn->data_blkaddr; in __allocate_data_block()
913 f2fs_allocate_data_block(sbi, NULL, old_blkaddr, &dn->data_blkaddr, in __allocate_data_block()
918 f2fs_set_data_blkaddr(dn); in __allocate_data_block()
1011 struct dnode_of_data dn; in f2fs_map_blocks() local
1046 set_new_dnode(&dn, inode, NULL, NULL, 0); in f2fs_map_blocks()
1047 err = f2fs_get_dnode_of_data(&dn, pgofs, mode); in f2fs_map_blocks()
1055 f2fs_get_next_page_offset(&dn, pgofs); in f2fs_map_blocks()
1058 f2fs_get_next_page_offset(&dn, pgofs); in f2fs_map_blocks()
1065 last_ofs_in_node = ofs_in_node = dn.ofs_in_node; in f2fs_map_blocks()
1066 end_offset = ADDRS_PER_PAGE(dn.node_page, inode); in f2fs_map_blocks()
1069 blkaddr = datablock_addr(dn.inode, dn.node_page, dn.ofs_in_node); in f2fs_map_blocks()
1086 last_ofs_in_node = dn.ofs_in_node; in f2fs_map_blocks()
1091 err = __allocate_data_block(&dn, in f2fs_map_blocks()
1099 blkaddr = dn.data_blkaddr; in f2fs_map_blocks()
1144 dn.ofs_in_node++; in f2fs_map_blocks()
1149 (pgofs == end || dn.ofs_in_node == end_offset)) { in f2fs_map_blocks()
1151 dn.ofs_in_node = ofs_in_node; in f2fs_map_blocks()
1152 err = f2fs_reserve_new_blocks(&dn, prealloc); in f2fs_map_blocks()
1156 map->m_len += dn.ofs_in_node - ofs_in_node; in f2fs_map_blocks()
1157 if (prealloc && dn.ofs_in_node != last_ofs_in_node + 1) { in f2fs_map_blocks()
1161 dn.ofs_in_node = end_offset; in f2fs_map_blocks()
1166 else if (dn.ofs_in_node < end_offset) in f2fs_map_blocks()
1173 f2fs_update_extent_cache_range(&dn, in f2fs_map_blocks()
1179 f2fs_put_dnode(&dn); in f2fs_map_blocks()
1183 f2fs_balance_fs(sbi, dn.node_changed); in f2fs_map_blocks()
1192 f2fs_update_extent_cache_range(&dn, in f2fs_map_blocks()
1199 f2fs_put_dnode(&dn); in f2fs_map_blocks()
1203 f2fs_balance_fs(sbi, dn.node_changed); in f2fs_map_blocks()
1752 struct dnode_of_data dn; in f2fs_do_write_data_page() local
1758 set_new_dnode(&dn, inode, NULL, NULL, 0); in f2fs_do_write_data_page()
1776 err = f2fs_get_dnode_of_data(&dn, page->index, LOOKUP_NODE); in f2fs_do_write_data_page()
1780 fio->old_blkaddr = dn.data_blkaddr; in f2fs_do_write_data_page()
1807 f2fs_put_dnode(&dn); in f2fs_do_write_data_page()
1824 err = f2fs_get_node_info(fio->sbi, dn.nid, &ni); in f2fs_do_write_data_page()
1838 f2fs_outplace_write_data(&dn, fio); in f2fs_do_write_data_page()
1844 f2fs_put_dnode(&dn); in f2fs_do_write_data_page()
2273 struct dnode_of_data dn; in prepare_write_begin() local
2307 set_new_dnode(&dn, inode, ipage, ipage, 0); in prepare_write_begin()
2316 err = f2fs_convert_inline_page(&dn, page); in prepare_write_begin()
2319 if (dn.data_blkaddr == NULL_ADDR) in prepare_write_begin()
2320 err = f2fs_get_block(&dn, index); in prepare_write_begin()
2323 err = f2fs_get_block(&dn, index); in prepare_write_begin()
2326 dn.data_blkaddr = ei.blk + index - ei.fofs; in prepare_write_begin()
2329 err = f2fs_get_dnode_of_data(&dn, index, LOOKUP_NODE); in prepare_write_begin()
2330 if (err || dn.data_blkaddr == NULL_ADDR) { in prepare_write_begin()
2331 f2fs_put_dnode(&dn); in prepare_write_begin()
2342 *blk_addr = dn.data_blkaddr; in prepare_write_begin()
2343 *node_changed = dn.node_changed; in prepare_write_begin()
2345 f2fs_put_dnode(&dn); in prepare_write_begin()