Lines Matching refs:bh

134 static int ext4_bh_delay_or_unwritten(handle_t *handle, struct buffer_head *bh);
663 static void ext4_update_bh_state(struct buffer_head *bh, unsigned long flags) in ext4_update_bh_state() argument
671 if (!bh->b_page) { in ext4_update_bh_state()
672 bh->b_state = (bh->b_state & ~EXT4_MAP_FLAGS) | flags; in ext4_update_bh_state()
681 old_state = READ_ONCE(bh->b_state); in ext4_update_bh_state()
684 cmpxchg(&bh->b_state, old_state, new_state) != old_state)); in ext4_update_bh_state()
691 struct buffer_head *bh, int flags) in _ext4_get_block() argument
702 map.m_len = bh->b_size >> inode->i_blkbits; in _ext4_get_block()
722 map_bh(bh, inode->i_sb, map.m_pblk); in _ext4_get_block()
723 ext4_update_bh_state(bh, map.m_flags); in _ext4_get_block()
724 if (IS_DAX(inode) && buffer_unwritten(bh)) { in _ext4_get_block()
731 bh->b_assoc_map = inode->i_mapping; in _ext4_get_block()
732 bh->b_private = (void *)(unsigned long)iblock; in _ext4_get_block()
735 set_buffer_defer_completion(bh); in _ext4_get_block()
736 bh->b_size = inode->i_sb->s_blocksize * map.m_len; in _ext4_get_block()
745 struct buffer_head *bh, int create) in ext4_get_block() argument
747 return _ext4_get_block(inode, iblock, bh, in ext4_get_block()
758 struct buffer_head *bh; in ext4_getblk() local
773 bh = sb_getblk(inode->i_sb, map.m_pblk); in ext4_getblk()
774 if (unlikely(!bh)) in ext4_getblk()
787 lock_buffer(bh); in ext4_getblk()
788 BUFFER_TRACE(bh, "call get_create_access"); in ext4_getblk()
789 err = ext4_journal_get_create_access(handle, bh); in ext4_getblk()
791 unlock_buffer(bh); in ext4_getblk()
794 if (!buffer_uptodate(bh)) { in ext4_getblk()
795 memset(bh->b_data, 0, inode->i_sb->s_blocksize); in ext4_getblk()
796 set_buffer_uptodate(bh); in ext4_getblk()
798 unlock_buffer(bh); in ext4_getblk()
799 BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); in ext4_getblk()
800 err = ext4_handle_dirty_metadata(handle, inode, bh); in ext4_getblk()
804 BUFFER_TRACE(bh, "not a new buffer"); in ext4_getblk()
805 return bh; in ext4_getblk()
807 brelse(bh); in ext4_getblk()
814 struct buffer_head *bh; in ext4_bread() local
816 bh = ext4_getblk(handle, inode, block, create); in ext4_bread()
817 if (IS_ERR(bh)) in ext4_bread()
818 return bh; in ext4_bread()
819 if (!bh || buffer_uptodate(bh)) in ext4_bread()
820 return bh; in ext4_bread()
821 ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh); in ext4_bread()
822 wait_on_buffer(bh); in ext4_bread()
823 if (buffer_uptodate(bh)) in ext4_bread()
824 return bh; in ext4_bread()
825 put_bh(bh); in ext4_bread()
835 struct buffer_head *bh)) in ext4_walk_page_buffers() argument
837 struct buffer_head *bh; in ext4_walk_page_buffers() local
843 for (bh = head, block_start = 0; in ext4_walk_page_buffers()
844 ret == 0 && (bh != head || !block_start); in ext4_walk_page_buffers()
845 block_start = block_end, bh = next) { in ext4_walk_page_buffers()
846 next = bh->b_this_page; in ext4_walk_page_buffers()
849 if (partial && !buffer_uptodate(bh)) in ext4_walk_page_buffers()
853 err = (*fn)(handle, bh); in ext4_walk_page_buffers()
885 struct buffer_head *bh) in do_journal_get_write_access() argument
887 int dirty = buffer_dirty(bh); in do_journal_get_write_access()
890 if (!buffer_mapped(bh) || buffer_freed(bh)) in do_journal_get_write_access()
901 clear_buffer_dirty(bh); in do_journal_get_write_access()
902 BUFFER_TRACE(bh, "get write access"); in do_journal_get_write_access()
903 ret = ext4_journal_get_write_access(handle, bh); in do_journal_get_write_access()
905 ret = ext4_handle_dirty_metadata(handle, NULL, bh); in do_journal_get_write_access()
924 struct buffer_head *bh, *head, *wait[2], **wait_bh = wait; in ext4_block_write_begin() local
938 for (bh = head, block_start = 0; bh != head || !block_start; in ext4_block_write_begin()
939 block++, block_start = block_end, bh = bh->b_this_page) { in ext4_block_write_begin()
943 if (!buffer_uptodate(bh)) in ext4_block_write_begin()
944 set_buffer_uptodate(bh); in ext4_block_write_begin()
948 if (buffer_new(bh)) in ext4_block_write_begin()
949 clear_buffer_new(bh); in ext4_block_write_begin()
950 if (!buffer_mapped(bh)) { in ext4_block_write_begin()
951 WARN_ON(bh->b_size != blocksize); in ext4_block_write_begin()
952 err = get_block(inode, block, bh, 1); in ext4_block_write_begin()
955 if (buffer_new(bh)) { in ext4_block_write_begin()
956 unmap_underlying_metadata(bh->b_bdev, in ext4_block_write_begin()
957 bh->b_blocknr); in ext4_block_write_begin()
959 clear_buffer_new(bh); in ext4_block_write_begin()
960 set_buffer_uptodate(bh); in ext4_block_write_begin()
961 mark_buffer_dirty(bh); in ext4_block_write_begin()
971 if (!buffer_uptodate(bh)) in ext4_block_write_begin()
972 set_buffer_uptodate(bh); in ext4_block_write_begin()
975 if (!buffer_uptodate(bh) && !buffer_delay(bh) && in ext4_block_write_begin()
976 !buffer_unwritten(bh) && in ext4_block_write_begin()
978 ll_rw_block(READ, 1, &bh); in ext4_block_write_begin()
979 *wait_bh++ = bh; in ext4_block_write_begin()
1118 static int write_end_fn(handle_t *handle, struct buffer_head *bh) in write_end_fn() argument
1121 if (!buffer_mapped(bh) || buffer_freed(bh)) in write_end_fn()
1123 set_buffer_uptodate(bh); in write_end_fn()
1124 ret = ext4_handle_dirty_metadata(handle, NULL, bh); in write_end_fn()
1125 clear_buffer_meta(bh); in write_end_fn()
1126 clear_buffer_prio(bh); in write_end_fn()
1367 struct buffer_head *head, *bh; in ext4_da_page_release_reservation() local
1378 bh = head; in ext4_da_page_release_reservation()
1380 unsigned int next_off = curr_off + bh->b_size; in ext4_da_page_release_reservation()
1385 if ((offset <= curr_off) && (buffer_delay(bh))) { in ext4_da_page_release_reservation()
1388 clear_buffer_delay(bh); in ext4_da_page_release_reservation()
1398 } while ((bh = bh->b_this_page) != head); in ext4_da_page_release_reservation()
1506 static int ext4_bh_delay_or_unwritten(handle_t *handle, struct buffer_head *bh) in ext4_bh_delay_or_unwritten() argument
1508 return (buffer_delay(bh) || buffer_unwritten(bh)) && buffer_dirty(bh); in ext4_bh_delay_or_unwritten()
1519 struct buffer_head *bh) in ext4_da_map_blocks() argument
1551 map_bh(bh, inode->i_sb, invalid_block); in ext4_da_map_blocks()
1552 set_buffer_new(bh); in ext4_da_map_blocks()
1553 set_buffer_delay(bh); in ext4_da_map_blocks()
1616 map_bh(bh, inode->i_sb, invalid_block); in ext4_da_map_blocks()
1617 set_buffer_new(bh); in ext4_da_map_blocks()
1618 set_buffer_delay(bh); in ext4_da_map_blocks()
1658 struct buffer_head *bh, int create) in ext4_da_get_block_prep() argument
1664 BUG_ON(bh->b_size != inode->i_sb->s_blocksize); in ext4_da_get_block_prep()
1674 ret = ext4_da_map_blocks(inode, iblock, &map, bh); in ext4_da_get_block_prep()
1678 map_bh(bh, inode->i_sb, map.m_pblk); in ext4_da_get_block_prep()
1679 ext4_update_bh_state(bh, map.m_flags); in ext4_da_get_block_prep()
1681 if (buffer_unwritten(bh)) { in ext4_da_get_block_prep()
1688 set_buffer_new(bh); in ext4_da_get_block_prep()
1689 set_buffer_mapped(bh); in ext4_da_get_block_prep()
1694 static int bget_one(handle_t *handle, struct buffer_head *bh) in bget_one() argument
1696 get_bh(bh); in bget_one()
1700 static int bput_one(handle_t *handle, struct buffer_head *bh) in bput_one() argument
1702 put_bh(bh); in bput_one()
1940 struct buffer_head *bh) in mpage_add_bh_to_extent() argument
1945 if (!buffer_dirty(bh) || !buffer_mapped(bh) || in mpage_add_bh_to_extent()
1946 (!buffer_delay(bh) && !buffer_unwritten(bh))) { in mpage_add_bh_to_extent()
1957 map->m_flags = bh->b_state & BH_FLAGS; in mpage_add_bh_to_extent()
1967 (bh->b_state & BH_FLAGS) == map->m_flags) { in mpage_add_bh_to_extent()
1992 struct buffer_head *bh, in mpage_process_page_bufs() argument
2001 BUG_ON(buffer_locked(bh)); in mpage_process_page_bufs()
2003 if (lblk >= blocks || !mpage_add_bh_to_extent(mpd, lblk, bh)) { in mpage_process_page_bufs()
2010 } while (lblk++, (bh = bh->b_this_page) != head); in mpage_process_page_bufs()
2039 struct buffer_head *head, *bh; in mpage_map_and_submit_buffers() local
2064 bh = head = page_buffers(page); in mpage_map_and_submit_buffers()
2083 bh, lblk); in mpage_map_and_submit_buffers()
2089 if (buffer_delay(bh)) { in mpage_map_and_submit_buffers()
2090 clear_buffer_delay(bh); in mpage_map_and_submit_buffers()
2091 bh->b_blocknr = pblock++; in mpage_map_and_submit_buffers()
2093 clear_buffer_unwritten(bh); in mpage_map_and_submit_buffers()
2094 } while (lblk++, (bh = bh->b_this_page) != head); in mpage_map_and_submit_buffers()
2756 struct buffer_head *bh; in ext4_da_should_update_i_disksize() local
2761 bh = page_buffers(page); in ext4_da_should_update_i_disksize()
2765 bh = bh->b_this_page; in ext4_da_should_update_i_disksize()
2767 if (!buffer_mapped(bh) || (buffer_delay(bh)) || buffer_unwritten(bh)) in ext4_da_should_update_i_disksize()
3370 struct buffer_head *bh; in __ext4_block_zero_page_range() local
3387 bh = page_buffers(page); in __ext4_block_zero_page_range()
3390 bh = bh->b_this_page; in __ext4_block_zero_page_range()
3394 if (buffer_freed(bh)) { in __ext4_block_zero_page_range()
3395 BUFFER_TRACE(bh, "freed: skip"); in __ext4_block_zero_page_range()
3398 if (!buffer_mapped(bh)) { in __ext4_block_zero_page_range()
3399 BUFFER_TRACE(bh, "unmapped"); in __ext4_block_zero_page_range()
3400 ext4_get_block(inode, iblock, bh, 0); in __ext4_block_zero_page_range()
3402 if (!buffer_mapped(bh)) { in __ext4_block_zero_page_range()
3403 BUFFER_TRACE(bh, "still unmapped"); in __ext4_block_zero_page_range()
3410 set_buffer_uptodate(bh); in __ext4_block_zero_page_range()
3412 if (!buffer_uptodate(bh)) { in __ext4_block_zero_page_range()
3414 ll_rw_block(READ, 1, &bh); in __ext4_block_zero_page_range()
3415 wait_on_buffer(bh); in __ext4_block_zero_page_range()
3417 if (!buffer_uptodate(bh)) in __ext4_block_zero_page_range()
3428 BUFFER_TRACE(bh, "get write access"); in __ext4_block_zero_page_range()
3429 err = ext4_journal_get_write_access(handle, bh); in __ext4_block_zero_page_range()
3434 BUFFER_TRACE(bh, "zeroed end of block"); in __ext4_block_zero_page_range()
3437 err = ext4_handle_dirty_metadata(handle, inode, bh); in __ext4_block_zero_page_range()
3440 mark_buffer_dirty(bh); in __ext4_block_zero_page_range()
3878 struct buffer_head *bh; in __ext4_get_inode_loc() local
3883 iloc->bh = NULL; in __ext4_get_inode_loc()
3901 bh = sb_getblk(sb, block); in __ext4_get_inode_loc()
3902 if (unlikely(!bh)) in __ext4_get_inode_loc()
3904 if (!buffer_uptodate(bh)) { in __ext4_get_inode_loc()
3905 lock_buffer(bh); in __ext4_get_inode_loc()
3913 if (buffer_write_io_error(bh) && !buffer_uptodate(bh)) in __ext4_get_inode_loc()
3914 set_buffer_uptodate(bh); in __ext4_get_inode_loc()
3916 if (buffer_uptodate(bh)) { in __ext4_get_inode_loc()
3918 unlock_buffer(bh); in __ext4_get_inode_loc()
3956 memset(bh->b_data, 0, bh->b_size); in __ext4_get_inode_loc()
3957 set_buffer_uptodate(bh); in __ext4_get_inode_loc()
3958 unlock_buffer(bh); in __ext4_get_inode_loc()
3995 get_bh(bh); in __ext4_get_inode_loc()
3996 bh->b_end_io = end_buffer_read_sync; in __ext4_get_inode_loc()
3997 submit_bh(READ | REQ_META | REQ_PRIO, bh); in __ext4_get_inode_loc()
3998 wait_on_buffer(bh); in __ext4_get_inode_loc()
3999 if (!buffer_uptodate(bh)) { in __ext4_get_inode_loc()
4002 brelse(bh); in __ext4_get_inode_loc()
4007 iloc->bh = bh; in __ext4_get_inode_loc()
4119 iloc.bh = NULL; in ext4_iget()
4320 brelse(iloc.bh); in ext4_iget()
4326 brelse(iloc.bh); in ext4_iget()
4454 struct buffer_head *bh = iloc->bh; in ext4_do_update_inode() local
4554 bh->b_data); in ext4_do_update_inode()
4556 BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); in ext4_do_update_inode()
4557 rc = ext4_handle_dirty_metadata(handle, NULL, bh); in ext4_do_update_inode()
4574 brelse(bh); in ext4_do_update_inode()
4647 sync_dirty_buffer(iloc.bh); in ext4_write_inode()
4648 if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) { in ext4_write_inode()
4649 EXT4_ERROR_INODE_BLOCK(inode, iloc.bh->b_blocknr, in ext4_write_inode()
4653 brelse(iloc.bh); in ext4_write_inode()
5009 get_bh(iloc->bh); in ext4_mark_iloc_dirty()
5013 put_bh(iloc->bh); in ext4_mark_iloc_dirty()
5030 BUFFER_TRACE(iloc->bh, "get_write_access"); in ext4_reserve_inode_write()
5031 err = ext4_journal_get_write_access(handle, iloc->bh); in ext4_reserve_inode_write()
5033 brelse(iloc->bh); in ext4_reserve_inode_write()
5034 iloc->bh = NULL; in ext4_reserve_inode_write()
5183 BUFFER_TRACE(iloc.bh, "get_write_access");
5184 err = jbd2_journal_get_write_access(handle, iloc.bh);
5188 iloc.bh);
5189 brelse(iloc.bh);
5274 static int ext4_bh_unmapped(handle_t *handle, struct buffer_head *bh) in ext4_bh_unmapped() argument
5276 return !buffer_mapped(bh); in ext4_bh_unmapped()