Lines Matching full:wc

787 static void ocfs2_unlock_pages(struct ocfs2_write_ctxt *wc)  in ocfs2_unlock_pages()  argument
796 if (wc->w_target_locked) { in ocfs2_unlock_pages()
797 BUG_ON(!wc->w_target_page); in ocfs2_unlock_pages()
798 for (i = 0; i < wc->w_num_pages; i++) { in ocfs2_unlock_pages()
799 if (wc->w_target_page == wc->w_pages[i]) { in ocfs2_unlock_pages()
800 wc->w_pages[i] = NULL; in ocfs2_unlock_pages()
804 mark_page_accessed(wc->w_target_page); in ocfs2_unlock_pages()
805 put_page(wc->w_target_page); in ocfs2_unlock_pages()
807 ocfs2_unlock_and_free_pages(wc->w_pages, wc->w_num_pages); in ocfs2_unlock_pages()
826 struct ocfs2_write_ctxt *wc) in ocfs2_free_write_ctxt() argument
828 ocfs2_free_unwritten_list(inode, &wc->w_unwritten_list); in ocfs2_free_write_ctxt()
829 ocfs2_unlock_pages(wc); in ocfs2_free_write_ctxt()
830 brelse(wc->w_di_bh); in ocfs2_free_write_ctxt()
831 kfree(wc); in ocfs2_free_write_ctxt()
840 struct ocfs2_write_ctxt *wc; in ocfs2_alloc_write_ctxt() local
842 wc = kzalloc(sizeof(struct ocfs2_write_ctxt), GFP_NOFS); in ocfs2_alloc_write_ctxt()
843 if (!wc) in ocfs2_alloc_write_ctxt()
846 wc->w_cpos = pos >> osb->s_clustersize_bits; in ocfs2_alloc_write_ctxt()
847 wc->w_first_new_cpos = UINT_MAX; in ocfs2_alloc_write_ctxt()
849 wc->w_clen = cend - wc->w_cpos + 1; in ocfs2_alloc_write_ctxt()
851 wc->w_di_bh = di_bh; in ocfs2_alloc_write_ctxt()
852 wc->w_type = type; in ocfs2_alloc_write_ctxt()
855 wc->w_large_pages = 1; in ocfs2_alloc_write_ctxt()
857 wc->w_large_pages = 0; in ocfs2_alloc_write_ctxt()
859 ocfs2_init_dealloc_ctxt(&wc->w_dealloc); in ocfs2_alloc_write_ctxt()
860 INIT_LIST_HEAD(&wc->w_unwritten_list); in ocfs2_alloc_write_ctxt()
862 *wcp = wc; in ocfs2_alloc_write_ctxt()
913 struct ocfs2_write_ctxt *wc, in ocfs2_write_failure() argument
921 if (wc->w_target_page) in ocfs2_write_failure()
922 ocfs2_zero_new_buffers(wc->w_target_page, from, to); in ocfs2_write_failure()
924 for(i = 0; i < wc->w_num_pages; i++) { in ocfs2_write_failure()
925 tmppage = wc->w_pages[i]; in ocfs2_write_failure()
929 ocfs2_jbd2_inode_add_write(wc->w_handle, inode, in ocfs2_write_failure()
938 struct ocfs2_write_ctxt *wc, in ocfs2_prepare_page_for_write() argument
957 if (page == wc->w_target_page) { in ocfs2_prepare_page_for_write()
1022 struct ocfs2_write_ctxt *wc, in ocfs2_grab_pages_for_write() argument
1042 wc->w_num_pages = ocfs2_pages_per_cluster(inode->i_sb); in ocfs2_grab_pages_for_write()
1052 if ((start + wc->w_num_pages) > end_index) in ocfs2_grab_pages_for_write()
1053 wc->w_num_pages = end_index - start; in ocfs2_grab_pages_for_write()
1055 wc->w_num_pages = 1; in ocfs2_grab_pages_for_write()
1060 for(i = 0; i < wc->w_num_pages; i++) { in ocfs2_grab_pages_for_write()
1064 wc->w_type == OCFS2_WRITE_MMAP) { in ocfs2_grab_pages_for_write()
1081 wc->w_pages[i] = mmap_page; in ocfs2_grab_pages_for_write()
1082 wc->w_target_locked = true; in ocfs2_grab_pages_for_write()
1084 wc->w_type == OCFS2_WRITE_DIRECT) { in ocfs2_grab_pages_for_write()
1086 wc->w_pages[i] = NULL; in ocfs2_grab_pages_for_write()
1089 wc->w_pages[i] = find_or_create_page(mapping, index, in ocfs2_grab_pages_for_write()
1091 if (!wc->w_pages[i]) { in ocfs2_grab_pages_for_write()
1097 wait_for_stable_page(wc->w_pages[i]); in ocfs2_grab_pages_for_write()
1100 wc->w_target_page = wc->w_pages[i]; in ocfs2_grab_pages_for_write()
1104 wc->w_target_locked = false; in ocfs2_grab_pages_for_write()
1117 struct ocfs2_write_ctxt *wc, u32 cpos, in ocfs2_write_cluster() argument
1136 wc->w_di_bh, wc->w_handle, in ocfs2_write_cluster()
1156 wc->w_di_bh); in ocfs2_write_cluster()
1158 wc->w_handle, cpos, 1, *phys, in ocfs2_write_cluster()
1159 meta_ac, &wc->w_dealloc); in ocfs2_write_cluster()
1184 for(i = 0; i < wc->w_num_pages; i++) { in ocfs2_write_cluster()
1188 if (wc->w_pages[i] == NULL) { in ocfs2_write_cluster()
1193 tmpret = ocfs2_prepare_page_for_write(inode, &p_blkno, wc, in ocfs2_write_cluster()
1194 wc->w_pages[i], cpos, in ocfs2_write_cluster()
1208 ocfs2_write_failure(inode, wc, user_pos, user_len); in ocfs2_write_cluster()
1218 struct ocfs2_write_ctxt *wc, in ocfs2_write_cluster_by_desc() argument
1227 for (i = 0; i < wc->w_clen; i++) { in ocfs2_write_cluster_by_desc()
1228 desc = &wc->w_desc[i]; in ocfs2_write_cluster_by_desc()
1244 wc, desc->c_cpos, pos, local_len); in ocfs2_write_cluster_by_desc()
1265 struct ocfs2_write_ctxt *wc, in ocfs2_set_target_boundaries() argument
1270 wc->w_target_from = pos & (PAGE_SIZE - 1); in ocfs2_set_target_boundaries()
1271 wc->w_target_to = wc->w_target_from + len; in ocfs2_set_target_boundaries()
1285 if (wc->w_large_pages) { in ocfs2_set_target_boundaries()
1292 desc = &wc->w_desc[0]; in ocfs2_set_target_boundaries()
1296 &wc->w_target_from, in ocfs2_set_target_boundaries()
1299 desc = &wc->w_desc[wc->w_clen - 1]; in ocfs2_set_target_boundaries()
1304 &wc->w_target_to); in ocfs2_set_target_boundaries()
1306 wc->w_target_from = 0; in ocfs2_set_target_boundaries()
1307 wc->w_target_to = PAGE_SIZE; in ocfs2_set_target_boundaries()
1319 struct ocfs2_write_ctxt *wc, in ocfs2_unwritten_check() argument
1343 if (wc->w_type != OCFS2_WRITE_DIRECT) in ocfs2_unwritten_check()
1361 list_add_tail(&new->ue_node, &wc->w_unwritten_list); in ocfs2_unwritten_check()
1362 wc->w_unwritten_count++; in ocfs2_unwritten_check()
1380 struct ocfs2_write_ctxt *wc, in ocfs2_populate_write_desc() argument
1394 for (i = 0; i < wc->w_clen; i++) { in ocfs2_populate_write_desc()
1395 desc = &wc->w_desc[i]; in ocfs2_populate_write_desc()
1396 desc->c_cpos = wc->w_cpos + i; in ocfs2_populate_write_desc()
1437 if (desc->c_cpos >= wc->w_first_new_cpos) { in ocfs2_populate_write_desc()
1455 ret = ocfs2_unwritten_check(inode, wc, desc); in ocfs2_populate_write_desc()
1471 struct ocfs2_write_ctxt *wc) in ocfs2_write_begin_inline() argument
1477 struct ocfs2_dinode *di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; in ocfs2_write_begin_inline()
1497 wc->w_pages[0] = wc->w_target_page = page; in ocfs2_write_begin_inline()
1498 wc->w_num_pages = 1; in ocfs2_write_begin_inline()
1500 ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh, in ocfs2_write_begin_inline()
1513 ret = ocfs2_read_inline_data(inode, page, wc->w_di_bh); in ocfs2_write_begin_inline()
1521 wc->w_handle = handle; in ocfs2_write_begin_inline()
1538 struct ocfs2_write_ctxt *wc) in ocfs2_try_to_write_inline_data() argument
1554 ocfs2_size_fits_inline_data(wc->w_di_bh, end)) in ocfs2_try_to_write_inline_data()
1561 ret = ocfs2_convert_inline_data_to_extents(inode, wc->w_di_bh); in ocfs2_try_to_write_inline_data()
1576 di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; in ocfs2_try_to_write_inline_data()
1582 ret = ocfs2_write_begin_inline(mapping, inode, wc); in ocfs2_try_to_write_inline_data()
1609 struct ocfs2_write_ctxt *wc) in ocfs2_expand_nonsparse_inode() argument
1623 /* There is no wc if this is call from direct. */ in ocfs2_expand_nonsparse_inode()
1624 if (wc) in ocfs2_expand_nonsparse_inode()
1625 wc->w_first_new_cpos = in ocfs2_expand_nonsparse_inode()
1650 struct ocfs2_write_ctxt *wc; in ocfs2_write_begin_nolock() local
1661 ret = ocfs2_alloc_write_ctxt(&wc, osb, pos, len, type, di_bh); in ocfs2_write_begin_nolock()
1669 mmap_page, wc); in ocfs2_write_begin_nolock()
1686 len, wc); in ocfs2_write_begin_nolock()
1698 clusters_need = wc->w_clen; in ocfs2_write_begin_nolock()
1700 wc->w_cpos, wc->w_clen, UINT_MAX); in ocfs2_write_begin_nolock()
1707 ret = ocfs2_populate_write_desc(inode, wc, &clusters_to_alloc, in ocfs2_write_begin_nolock()
1715 di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; in ocfs2_write_begin_nolock()
1737 wc->w_di_bh); in ocfs2_write_begin_nolock()
1760 if (wc->w_clen && (wc->w_desc[0].c_needs_zero || in ocfs2_write_begin_nolock()
1761 wc->w_desc[wc->w_clen - 1].c_needs_zero)) in ocfs2_write_begin_nolock()
1766 ocfs2_set_target_boundaries(osb, wc, pos, len, cluster_of_pages); in ocfs2_write_begin_nolock()
1775 wc->w_handle = handle; in ocfs2_write_begin_nolock()
1784 ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh, in ocfs2_write_begin_nolock()
1796 ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos, len, in ocfs2_write_begin_nolock()
1806 BUG_ON(wc->w_target_page); in ocfs2_write_begin_nolock()
1815 ret = ocfs2_write_cluster_by_desc(mapping, data_ac, meta_ac, wc, pos, in ocfs2_write_begin_nolock()
1829 *foliop = page_folio(wc->w_target_page); in ocfs2_write_begin_nolock()
1830 *fsdata = wc; in ocfs2_write_begin_nolock()
1847 if (wc->w_target_locked) in ocfs2_write_begin_nolock()
1850 ocfs2_free_write_ctxt(inode, wc); in ocfs2_write_begin_nolock()
1925 struct ocfs2_write_ctxt *wc) in ocfs2_write_end_inline() argument
1930 if (!PageUptodate(wc->w_target_page)) { in ocfs2_write_end_inline()
1936 kaddr = kmap_atomic(wc->w_target_page); in ocfs2_write_end_inline()
1954 struct ocfs2_write_ctxt *wc = fsdata; in ocfs2_write_end_nolock() local
1955 struct ocfs2_dinode *di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; in ocfs2_write_end_nolock()
1956 handle_t *handle = wc->w_handle; in ocfs2_write_end_nolock()
1959 BUG_ON(!list_empty(&wc->w_unwritten_list)); in ocfs2_write_end_nolock()
1963 wc->w_di_bh, OCFS2_JOURNAL_ACCESS_WRITE); in ocfs2_write_end_nolock()
1972 ocfs2_write_end_inline(inode, pos, len, &copied, di, wc); in ocfs2_write_end_nolock()
1976 if (unlikely(copied < len) && wc->w_target_page) { in ocfs2_write_end_nolock()
1979 if (!PageUptodate(wc->w_target_page)) in ocfs2_write_end_nolock()
1983 if (new_isize > page_offset(wc->w_target_page)) in ocfs2_write_end_nolock()
1984 ocfs2_zero_new_buffers(wc->w_target_page, start+copied, in ocfs2_write_end_nolock()
1994 block_invalidate_folio(page_folio(wc->w_target_page), in ocfs2_write_end_nolock()
1998 if (wc->w_target_page) in ocfs2_write_end_nolock()
1999 flush_dcache_page(wc->w_target_page); in ocfs2_write_end_nolock()
2001 for(i = 0; i < wc->w_num_pages; i++) { in ocfs2_write_end_nolock()
2002 tmppage = wc->w_pages[i]; in ocfs2_write_end_nolock()
2008 if (tmppage == wc->w_target_page) { in ocfs2_write_end_nolock()
2009 from = wc->w_target_from; in ocfs2_write_end_nolock()
2010 to = wc->w_target_to; in ocfs2_write_end_nolock()
2040 if (wc->w_type != OCFS2_WRITE_DIRECT) { in ocfs2_write_end_nolock()
2055 ocfs2_journal_dirty(handle, wc->w_di_bh); in ocfs2_write_end_nolock()
2063 ocfs2_unlock_pages(wc); in ocfs2_write_end_nolock()
2068 ocfs2_run_deallocs(osb, &wc->w_dealloc); in ocfs2_write_end_nolock()
2070 brelse(wc->w_di_bh); in ocfs2_write_end_nolock()
2071 kfree(wc); in ocfs2_write_end_nolock()
2144 struct ocfs2_write_ctxt *wc; in ocfs2_dio_wr_get_block() local
2239 (void **)&wc, di_bh, NULL); in ocfs2_dio_wr_get_block()
2245 desc = &wc->w_desc[0]; in ocfs2_dio_wr_get_block()
2263 if (!list_empty(&wc->w_unwritten_list)) { in ocfs2_dio_wr_get_block()
2266 ue = list_first_entry(&wc->w_unwritten_list, in ocfs2_dio_wr_get_block()
2273 list_splice_tail_init(&wc->w_unwritten_list, &dwc->dw_zero_list); in ocfs2_dio_wr_get_block()
2274 dwc->dw_zero_count += wc->w_unwritten_count; in ocfs2_dio_wr_get_block()
2277 ret = ocfs2_write_end_nolock(inode->i_mapping, pos, len, len, wc); in ocfs2_dio_wr_get_block()