Lines Matching refs:bh

869 static void ext4_update_bh_state(struct buffer_head *bh, unsigned long flags)  in ext4_update_bh_state()  argument
877 if (!bh->b_folio) { in ext4_update_bh_state()
878 bh->b_state = (bh->b_state & ~EXT4_MAP_FLAGS) | flags; in ext4_update_bh_state()
886 old_state = READ_ONCE(bh->b_state); in ext4_update_bh_state()
889 } while (unlikely(!try_cmpxchg(&bh->b_state, &old_state, new_state))); in ext4_update_bh_state()
913 struct buffer_head *bh, int flags) in _ext4_get_block() argument
922 map.m_len = bh->b_size >> inode->i_blkbits; in _ext4_get_block()
927 map_bh(bh, inode->i_sb, map.m_pblk); in _ext4_get_block()
928 ext4_update_bh_state(bh, map.m_flags); in _ext4_get_block()
929 bh->b_size = inode->i_sb->s_blocksize * map.m_len; in _ext4_get_block()
933 bh->b_size = inode->i_sb->s_blocksize * map.m_len; in _ext4_get_block()
939 struct buffer_head *bh, int create) in ext4_get_block() argument
941 return _ext4_get_block(inode, iblock, bh, in ext4_get_block()
981 struct buffer_head *bh; in ext4_getblk() local
1007 bh = getblk_unmovable(inode->i_sb->s_bdev, map.m_pblk, in ext4_getblk()
1010 if (unlikely(!bh)) in ext4_getblk()
1024 lock_buffer(bh); in ext4_getblk()
1025 BUFFER_TRACE(bh, "call get_create_access"); in ext4_getblk()
1026 err = ext4_journal_get_create_access(handle, inode->i_sb, bh, in ext4_getblk()
1029 unlock_buffer(bh); in ext4_getblk()
1032 if (!buffer_uptodate(bh)) { in ext4_getblk()
1033 memset(bh->b_data, 0, inode->i_sb->s_blocksize); in ext4_getblk()
1034 set_buffer_uptodate(bh); in ext4_getblk()
1036 unlock_buffer(bh); in ext4_getblk()
1037 BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); in ext4_getblk()
1038 err = ext4_handle_dirty_metadata(handle, inode, bh); in ext4_getblk()
1042 BUFFER_TRACE(bh, "not a new buffer"); in ext4_getblk()
1043 return bh; in ext4_getblk()
1045 brelse(bh); in ext4_getblk()
1052 struct buffer_head *bh; in ext4_bread() local
1055 bh = ext4_getblk(handle, inode, block, map_flags); in ext4_bread()
1056 if (IS_ERR(bh)) in ext4_bread()
1057 return bh; in ext4_bread()
1058 if (!bh || ext4_buffer_uptodate(bh)) in ext4_bread()
1059 return bh; in ext4_bread()
1061 ret = ext4_read_bh_lock(bh, REQ_META | REQ_PRIO, true); in ext4_bread()
1063 put_bh(bh); in ext4_bread()
1066 return bh; in ext4_bread()
1118 struct buffer_head *bh)) in ext4_walk_page_buffers() argument
1120 struct buffer_head *bh; in ext4_walk_page_buffers() local
1126 for (bh = head, block_start = 0; in ext4_walk_page_buffers()
1127 ret == 0 && (bh != head || !block_start); in ext4_walk_page_buffers()
1128 block_start = block_end, bh = next) { in ext4_walk_page_buffers()
1129 next = bh->b_this_page; in ext4_walk_page_buffers()
1132 if (partial && !buffer_uptodate(bh)) in ext4_walk_page_buffers()
1136 err = (*fn)(handle, inode, bh); in ext4_walk_page_buffers()
1149 static int ext4_dirty_journalled_data(handle_t *handle, struct buffer_head *bh) in ext4_dirty_journalled_data() argument
1151 struct folio *folio = bh->b_folio; in ext4_dirty_journalled_data()
1157 return ext4_handle_dirty_metadata(handle, NULL, bh); in ext4_dirty_journalled_data()
1161 struct buffer_head *bh) in do_journal_get_write_access() argument
1163 if (!buffer_mapped(bh) || buffer_freed(bh)) in do_journal_get_write_access()
1165 BUFFER_TRACE(bh, "get write access"); in do_journal_get_write_access()
1166 return ext4_journal_get_write_access(handle, inode->i_sb, bh, in do_journal_get_write_access()
1181 struct buffer_head *bh, *head, *wait[2]; in ext4_block_write_begin() local
1196 for (bh = head, block_start = 0; bh != head || !block_start; in ext4_block_write_begin()
1197 block++, block_start = block_end, bh = bh->b_this_page) { in ext4_block_write_begin()
1201 set_buffer_uptodate(bh); in ext4_block_write_begin()
1205 if (WARN_ON_ONCE(buffer_new(bh))) in ext4_block_write_begin()
1206 clear_buffer_new(bh); in ext4_block_write_begin()
1207 if (!buffer_mapped(bh)) { in ext4_block_write_begin()
1208 WARN_ON(bh->b_size != blocksize); in ext4_block_write_begin()
1211 err = get_block(inode, block, bh, 1); in ext4_block_write_begin()
1214 if (buffer_new(bh)) { in ext4_block_write_begin()
1222 inode, bh); in ext4_block_write_begin()
1230 set_buffer_uptodate(bh); in ext4_block_write_begin()
1241 set_buffer_uptodate(bh); in ext4_block_write_begin()
1244 if (!buffer_uptodate(bh) && !buffer_delay(bh) && in ext4_block_write_begin()
1245 !buffer_unwritten(bh) && in ext4_block_write_begin()
1247 ext4_read_bh_lock(bh, 0, false); in ext4_block_write_begin()
1248 wait[nr_wait++] = bh; in ext4_block_write_begin()
1422 struct buffer_head *bh) in write_end_fn() argument
1425 if (!buffer_mapped(bh) || buffer_freed(bh)) in write_end_fn()
1427 set_buffer_uptodate(bh); in write_end_fn()
1428 ret = ext4_dirty_journalled_data(handle, bh); in write_end_fn()
1429 clear_buffer_meta(bh); in write_end_fn()
1430 clear_buffer_prio(bh); in write_end_fn()
1431 clear_buffer_new(bh); in write_end_fn()
1519 struct buffer_head *head, *bh; in ext4_journalled_zero_new_buffers() local
1521 bh = head = folio_buffers(folio); in ext4_journalled_zero_new_buffers()
1523 block_end = block_start + bh->b_size; in ext4_journalled_zero_new_buffers()
1524 if (buffer_new(bh)) { in ext4_journalled_zero_new_buffers()
1534 clear_buffer_new(bh); in ext4_journalled_zero_new_buffers()
1535 write_end_fn(handle, inode, bh); in ext4_journalled_zero_new_buffers()
1539 bh = bh->b_this_page; in ext4_journalled_zero_new_buffers()
1540 } while (bh != head); in ext4_journalled_zero_new_buffers()
2023 struct buffer_head *bh, int create) in ext4_da_get_block_prep() argument
2030 BUG_ON(bh->b_size != inode->i_sb->s_blocksize); in ext4_da_get_block_prep()
2048 map_bh(bh, inode->i_sb, invalid_block); in ext4_da_get_block_prep()
2049 set_buffer_new(bh); in ext4_da_get_block_prep()
2050 set_buffer_delay(bh); in ext4_da_get_block_prep()
2054 map_bh(bh, inode->i_sb, map.m_pblk); in ext4_da_get_block_prep()
2055 ext4_update_bh_state(bh, map.m_flags); in ext4_da_get_block_prep()
2057 if (buffer_unwritten(bh)) { in ext4_da_get_block_prep()
2064 set_buffer_new(bh); in ext4_da_get_block_prep()
2065 set_buffer_mapped(bh); in ext4_da_get_block_prep()
2132 struct buffer_head *bh) in mpage_add_bh_to_extent() argument
2137 if (!buffer_dirty(bh) || !buffer_mapped(bh) || in mpage_add_bh_to_extent()
2138 (!buffer_delay(bh) && !buffer_unwritten(bh))) { in mpage_add_bh_to_extent()
2152 map->m_flags = bh->b_state & BH_FLAGS; in mpage_add_bh_to_extent()
2162 (bh->b_state & BH_FLAGS) == map->m_flags) { in mpage_add_bh_to_extent()
2187 struct buffer_head *bh, in mpage_process_page_bufs() argument
2199 BUG_ON(buffer_locked(bh)); in mpage_process_page_bufs()
2201 if (lblk >= blocks || !mpage_add_bh_to_extent(mpd, lblk, bh)) { in mpage_process_page_bufs()
2211 } while (lblk++, (bh = bh->b_this_page) != head); in mpage_process_page_bufs()
2246 struct buffer_head *head, *bh; in mpage_process_folio() local
2254 bh = head = folio_buffers(folio); in mpage_process_folio()
2267 err = mpage_process_page_bufs(mpd, head, bh, lblk); in mpage_process_folio()
2282 if (buffer_delay(bh)) { in mpage_process_folio()
2283 clear_buffer_delay(bh); in mpage_process_folio()
2284 bh->b_blocknr = pblock++; in mpage_process_folio()
2286 clear_buffer_unwritten(bh); in mpage_process_folio()
2288 } while (lblk++, (bh = bh->b_this_page) != head); in mpage_process_folio()
3205 struct buffer_head *bh; in ext4_da_should_update_i_disksize() local
3210 bh = folio_buffers(folio); in ext4_da_should_update_i_disksize()
3214 bh = bh->b_this_page; in ext4_da_should_update_i_disksize()
3216 if (!buffer_mapped(bh) || (buffer_delay(bh)) || buffer_unwritten(bh)) in ext4_da_should_update_i_disksize()
4035 struct buffer_head *bh; in ext4_load_tail_bh() local
4049 bh = folio_buffers(folio); in ext4_load_tail_bh()
4050 if (!bh) in ext4_load_tail_bh()
4051 bh = create_empty_buffers(folio, blocksize, 0); in ext4_load_tail_bh()
4057 bh = bh->b_this_page; in ext4_load_tail_bh()
4061 if (buffer_freed(bh)) { in ext4_load_tail_bh()
4062 BUFFER_TRACE(bh, "freed: skip"); in ext4_load_tail_bh()
4065 if (!buffer_mapped(bh)) { in ext4_load_tail_bh()
4066 BUFFER_TRACE(bh, "unmapped"); in ext4_load_tail_bh()
4067 ext4_get_block(inode, iblock, bh, 0); in ext4_load_tail_bh()
4069 if (!buffer_mapped(bh)) { in ext4_load_tail_bh()
4070 BUFFER_TRACE(bh, "still unmapped"); in ext4_load_tail_bh()
4077 set_buffer_uptodate(bh); in ext4_load_tail_bh()
4079 if (!buffer_uptodate(bh)) { in ext4_load_tail_bh()
4080 err = ext4_read_bh_lock(bh, 0, true); in ext4_load_tail_bh()
4088 bh_offset(bh)); in ext4_load_tail_bh()
4090 clear_buffer_uptodate(bh); in ext4_load_tail_bh()
4095 return bh; in ext4_load_tail_bh()
4107 struct buffer_head *bh; in ext4_block_do_zero_range() local
4110 bh = ext4_load_tail_bh(inode, from); in ext4_block_do_zero_range()
4111 if (IS_ERR_OR_NULL(bh)) in ext4_block_do_zero_range()
4112 return PTR_ERR_OR_ZERO(bh); in ext4_block_do_zero_range()
4114 folio = bh->b_folio; in ext4_block_do_zero_range()
4116 BUFFER_TRACE(bh, "zeroed end of block"); in ext4_block_do_zero_range()
4118 mark_buffer_dirty(bh); in ext4_block_do_zero_range()
4121 if (zero_written && !buffer_unwritten(bh) && !buffer_delay(bh)) in ext4_block_do_zero_range()
4132 struct buffer_head *bh; in ext4_block_journalled_zero_range() local
4141 bh = ext4_load_tail_bh(inode, from); in ext4_block_journalled_zero_range()
4142 if (IS_ERR_OR_NULL(bh)) { in ext4_block_journalled_zero_range()
4143 err = PTR_ERR_OR_ZERO(bh); in ext4_block_journalled_zero_range()
4146 folio = bh->b_folio; in ext4_block_journalled_zero_range()
4148 BUFFER_TRACE(bh, "get write access"); in ext4_block_journalled_zero_range()
4149 err = ext4_journal_get_write_access(handle, inode->i_sb, bh, in ext4_block_journalled_zero_range()
4155 BUFFER_TRACE(bh, "zeroed end of block"); in ext4_block_journalled_zero_range()
4157 err = ext4_dirty_journalled_data(handle, bh); in ext4_block_journalled_zero_range()
4858 struct buffer_head *bh; in __ext4_get_inode_loc() local
4863 iloc->bh = NULL; in __ext4_get_inode_loc()
4890 bh = sb_getblk(sb, block); in __ext4_get_inode_loc()
4891 if (unlikely(!bh)) in __ext4_get_inode_loc()
4893 if (ext4_buffer_uptodate(bh)) in __ext4_get_inode_loc()
4896 lock_buffer(bh); in __ext4_get_inode_loc()
4897 if (ext4_buffer_uptodate(bh)) { in __ext4_get_inode_loc()
4899 unlock_buffer(bh); in __ext4_get_inode_loc()
4937 (struct ext4_inode *) (bh->b_data + iloc->offset); in __ext4_get_inode_loc()
4940 memset(bh->b_data, 0, bh->b_size); in __ext4_get_inode_loc()
4943 set_buffer_uptodate(bh); in __ext4_get_inode_loc()
4944 unlock_buffer(bh); in __ext4_get_inode_loc()
4982 ext4_read_bh_nowait(bh, REQ_META | REQ_PRIO, NULL, in __ext4_get_inode_loc()
4985 wait_on_buffer(bh); in __ext4_get_inode_loc()
4986 if (!buffer_uptodate(bh)) { in __ext4_get_inode_loc()
4989 brelse(bh); in __ext4_get_inode_loc()
4993 iloc->bh = bh; in __ext4_get_inode_loc()
5262 iloc.bh = NULL; in __ext4_iget()
5572 brelse(iloc.bh); in __ext4_iget()
5579 brelse(iloc.bh); in __ext4_iget()
5587 brelse(iloc.bh); in __ext4_iget()
5665 struct buffer_head *bh = iloc->bh; in ext4_do_update_inode() local
5696 bh->b_data); in ext4_do_update_inode()
5698 BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); in ext4_do_update_inode()
5699 err = ext4_handle_dirty_metadata(handle, NULL, bh); in ext4_do_update_inode()
5722 brelse(bh); in ext4_do_update_inode()
5799 sync_dirty_buffer(iloc.bh); in ext4_write_inode()
5800 if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) { in ext4_write_inode()
5801 ext4_error_inode_block(inode, iloc.bh->b_blocknr, EIO, in ext4_write_inode()
5805 brelse(iloc.bh); in ext4_write_inode()
6343 put_bh(iloc->bh); in ext4_mark_iloc_dirty()
6349 get_bh(iloc->bh); in ext4_mark_iloc_dirty()
6353 put_bh(iloc->bh); in ext4_mark_iloc_dirty()
6374 BUFFER_TRACE(iloc->bh, "get_write_access"); in ext4_reserve_inode_write()
6376 iloc->bh, EXT4_JTR_NONE); in ext4_reserve_inode_write()
6378 brelse(iloc->bh); in ext4_reserve_inode_write()
6379 iloc->bh = NULL; in ext4_reserve_inode_write()
6493 brelse(iloc->bh); in ext4_expand_extra_isize()
6501 brelse(iloc->bh); in ext4_expand_extra_isize()
6507 BUFFER_TRACE(iloc->bh, "get_write_access"); in ext4_expand_extra_isize()
6508 error = ext4_journal_get_write_access(handle, inode->i_sb, iloc->bh, in ext4_expand_extra_isize()
6511 brelse(iloc->bh); in ext4_expand_extra_isize()
6681 struct buffer_head *bh) in ext4_bh_unmapped() argument
6683 return !buffer_mapped(bh); in ext4_bh_unmapped()