Lines Matching full:wc

789 static void ocfs2_unlock_pages(struct ocfs2_write_ctxt *wc)  in ocfs2_unlock_pages()  argument
798 if (wc->w_target_locked) { in ocfs2_unlock_pages()
799 BUG_ON(!wc->w_target_page); in ocfs2_unlock_pages()
800 for (i = 0; i < wc->w_num_pages; i++) { in ocfs2_unlock_pages()
801 if (wc->w_target_page == wc->w_pages[i]) { in ocfs2_unlock_pages()
802 wc->w_pages[i] = NULL; in ocfs2_unlock_pages()
806 mark_page_accessed(wc->w_target_page); in ocfs2_unlock_pages()
807 put_page(wc->w_target_page); in ocfs2_unlock_pages()
809 ocfs2_unlock_and_free_pages(wc->w_pages, wc->w_num_pages); in ocfs2_unlock_pages()
828 struct ocfs2_write_ctxt *wc) in ocfs2_free_write_ctxt() argument
830 ocfs2_free_unwritten_list(inode, &wc->w_unwritten_list); in ocfs2_free_write_ctxt()
831 ocfs2_unlock_pages(wc); in ocfs2_free_write_ctxt()
832 brelse(wc->w_di_bh); in ocfs2_free_write_ctxt()
833 kfree(wc); in ocfs2_free_write_ctxt()
842 struct ocfs2_write_ctxt *wc; in ocfs2_alloc_write_ctxt() local
844 wc = kzalloc(sizeof(struct ocfs2_write_ctxt), GFP_NOFS); in ocfs2_alloc_write_ctxt()
845 if (!wc) in ocfs2_alloc_write_ctxt()
848 wc->w_cpos = pos >> osb->s_clustersize_bits; in ocfs2_alloc_write_ctxt()
849 wc->w_first_new_cpos = UINT_MAX; in ocfs2_alloc_write_ctxt()
851 wc->w_clen = cend - wc->w_cpos + 1; in ocfs2_alloc_write_ctxt()
853 wc->w_di_bh = di_bh; in ocfs2_alloc_write_ctxt()
854 wc->w_type = type; in ocfs2_alloc_write_ctxt()
857 wc->w_large_pages = 1; in ocfs2_alloc_write_ctxt()
859 wc->w_large_pages = 0; in ocfs2_alloc_write_ctxt()
861 ocfs2_init_dealloc_ctxt(&wc->w_dealloc); in ocfs2_alloc_write_ctxt()
862 INIT_LIST_HEAD(&wc->w_unwritten_list); in ocfs2_alloc_write_ctxt()
864 *wcp = wc; in ocfs2_alloc_write_ctxt()
915 struct ocfs2_write_ctxt *wc, in ocfs2_write_failure() argument
923 if (wc->w_target_page) in ocfs2_write_failure()
924 ocfs2_zero_new_buffers(wc->w_target_page, from, to); in ocfs2_write_failure()
926 for(i = 0; i < wc->w_num_pages; i++) { in ocfs2_write_failure()
927 tmppage = wc->w_pages[i]; in ocfs2_write_failure()
931 ocfs2_jbd2_inode_add_write(wc->w_handle, inode, in ocfs2_write_failure()
940 struct ocfs2_write_ctxt *wc, in ocfs2_prepare_page_for_write() argument
959 if (page == wc->w_target_page) { in ocfs2_prepare_page_for_write()
1024 struct ocfs2_write_ctxt *wc, in ocfs2_grab_pages_for_write() argument
1044 wc->w_num_pages = ocfs2_pages_per_cluster(inode->i_sb); in ocfs2_grab_pages_for_write()
1054 if ((start + wc->w_num_pages) > end_index) in ocfs2_grab_pages_for_write()
1055 wc->w_num_pages = end_index - start; in ocfs2_grab_pages_for_write()
1057 wc->w_num_pages = 1; in ocfs2_grab_pages_for_write()
1062 for(i = 0; i < wc->w_num_pages; i++) { in ocfs2_grab_pages_for_write()
1066 wc->w_type == OCFS2_WRITE_MMAP) { in ocfs2_grab_pages_for_write()
1083 wc->w_pages[i] = mmap_page; in ocfs2_grab_pages_for_write()
1084 wc->w_target_locked = true; in ocfs2_grab_pages_for_write()
1086 wc->w_type == OCFS2_WRITE_DIRECT) { in ocfs2_grab_pages_for_write()
1088 wc->w_pages[i] = NULL; in ocfs2_grab_pages_for_write()
1091 wc->w_pages[i] = find_or_create_page(mapping, index, in ocfs2_grab_pages_for_write()
1093 if (!wc->w_pages[i]) { in ocfs2_grab_pages_for_write()
1099 wait_for_stable_page(wc->w_pages[i]); in ocfs2_grab_pages_for_write()
1102 wc->w_target_page = wc->w_pages[i]; in ocfs2_grab_pages_for_write()
1106 wc->w_target_locked = false; in ocfs2_grab_pages_for_write()
1119 struct ocfs2_write_ctxt *wc, u32 cpos, in ocfs2_write_cluster() argument
1138 wc->w_di_bh, wc->w_handle, in ocfs2_write_cluster()
1158 wc->w_di_bh); in ocfs2_write_cluster()
1160 wc->w_handle, cpos, 1, *phys, in ocfs2_write_cluster()
1161 meta_ac, &wc->w_dealloc); in ocfs2_write_cluster()
1186 for(i = 0; i < wc->w_num_pages; i++) { in ocfs2_write_cluster()
1190 if (wc->w_pages[i] == NULL) { in ocfs2_write_cluster()
1195 tmpret = ocfs2_prepare_page_for_write(inode, &p_blkno, wc, in ocfs2_write_cluster()
1196 wc->w_pages[i], cpos, in ocfs2_write_cluster()
1210 ocfs2_write_failure(inode, wc, user_pos, user_len); in ocfs2_write_cluster()
1220 struct ocfs2_write_ctxt *wc, in ocfs2_write_cluster_by_desc() argument
1229 for (i = 0; i < wc->w_clen; i++) { in ocfs2_write_cluster_by_desc()
1230 desc = &wc->w_desc[i]; in ocfs2_write_cluster_by_desc()
1246 wc, desc->c_cpos, pos, local_len); in ocfs2_write_cluster_by_desc()
1267 struct ocfs2_write_ctxt *wc, in ocfs2_set_target_boundaries() argument
1272 wc->w_target_from = pos & (PAGE_SIZE - 1); in ocfs2_set_target_boundaries()
1273 wc->w_target_to = wc->w_target_from + len; in ocfs2_set_target_boundaries()
1287 if (wc->w_large_pages) { in ocfs2_set_target_boundaries()
1294 desc = &wc->w_desc[0]; in ocfs2_set_target_boundaries()
1298 &wc->w_target_from, in ocfs2_set_target_boundaries()
1301 desc = &wc->w_desc[wc->w_clen - 1]; in ocfs2_set_target_boundaries()
1306 &wc->w_target_to); in ocfs2_set_target_boundaries()
1308 wc->w_target_from = 0; in ocfs2_set_target_boundaries()
1309 wc->w_target_to = PAGE_SIZE; in ocfs2_set_target_boundaries()
1321 struct ocfs2_write_ctxt *wc, in ocfs2_unwritten_check() argument
1345 if (wc->w_type != OCFS2_WRITE_DIRECT) in ocfs2_unwritten_check()
1363 list_add_tail(&new->ue_node, &wc->w_unwritten_list); in ocfs2_unwritten_check()
1364 wc->w_unwritten_count++; in ocfs2_unwritten_check()
1382 struct ocfs2_write_ctxt *wc, in ocfs2_populate_write_desc() argument
1396 for (i = 0; i < wc->w_clen; i++) { in ocfs2_populate_write_desc()
1397 desc = &wc->w_desc[i]; in ocfs2_populate_write_desc()
1398 desc->c_cpos = wc->w_cpos + i; in ocfs2_populate_write_desc()
1439 if (desc->c_cpos >= wc->w_first_new_cpos) { in ocfs2_populate_write_desc()
1457 ret = ocfs2_unwritten_check(inode, wc, desc); in ocfs2_populate_write_desc()
1473 struct ocfs2_write_ctxt *wc) in ocfs2_write_begin_inline() argument
1479 struct ocfs2_dinode *di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; in ocfs2_write_begin_inline()
1499 wc->w_pages[0] = wc->w_target_page = page; in ocfs2_write_begin_inline()
1500 wc->w_num_pages = 1; in ocfs2_write_begin_inline()
1502 ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh, in ocfs2_write_begin_inline()
1515 ret = ocfs2_read_inline_data(inode, page, wc->w_di_bh); in ocfs2_write_begin_inline()
1523 wc->w_handle = handle; in ocfs2_write_begin_inline()
1540 struct ocfs2_write_ctxt *wc) in ocfs2_try_to_write_inline_data() argument
1556 ocfs2_size_fits_inline_data(wc->w_di_bh, end)) in ocfs2_try_to_write_inline_data()
1563 ret = ocfs2_convert_inline_data_to_extents(inode, wc->w_di_bh); in ocfs2_try_to_write_inline_data()
1578 di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; in ocfs2_try_to_write_inline_data()
1584 ret = ocfs2_write_begin_inline(mapping, inode, wc); in ocfs2_try_to_write_inline_data()
1611 struct ocfs2_write_ctxt *wc) in ocfs2_expand_nonsparse_inode() argument
1625 /* There is no wc if this is call from direct. */ in ocfs2_expand_nonsparse_inode()
1626 if (wc) in ocfs2_expand_nonsparse_inode()
1627 wc->w_first_new_cpos = in ocfs2_expand_nonsparse_inode()
1652 struct ocfs2_write_ctxt *wc; in ocfs2_write_begin_nolock() local
1663 ret = ocfs2_alloc_write_ctxt(&wc, osb, pos, len, type, di_bh); in ocfs2_write_begin_nolock()
1671 mmap_page, wc); in ocfs2_write_begin_nolock()
1688 len, wc); in ocfs2_write_begin_nolock()
1700 clusters_need = wc->w_clen; in ocfs2_write_begin_nolock()
1702 wc->w_cpos, wc->w_clen, UINT_MAX); in ocfs2_write_begin_nolock()
1709 ret = ocfs2_populate_write_desc(inode, wc, &clusters_to_alloc, in ocfs2_write_begin_nolock()
1717 di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; in ocfs2_write_begin_nolock()
1739 wc->w_di_bh); in ocfs2_write_begin_nolock()
1762 if (wc->w_clen && (wc->w_desc[0].c_needs_zero || in ocfs2_write_begin_nolock()
1763 wc->w_desc[wc->w_clen - 1].c_needs_zero)) in ocfs2_write_begin_nolock()
1768 ocfs2_set_target_boundaries(osb, wc, pos, len, cluster_of_pages); in ocfs2_write_begin_nolock()
1777 wc->w_handle = handle; in ocfs2_write_begin_nolock()
1786 ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh, in ocfs2_write_begin_nolock()
1798 ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos, len, in ocfs2_write_begin_nolock()
1808 BUG_ON(wc->w_target_page); in ocfs2_write_begin_nolock()
1817 ret = ocfs2_write_cluster_by_desc(mapping, data_ac, meta_ac, wc, pos, in ocfs2_write_begin_nolock()
1831 *pagep = wc->w_target_page; in ocfs2_write_begin_nolock()
1832 *fsdata = wc; in ocfs2_write_begin_nolock()
1849 if (wc->w_target_locked) in ocfs2_write_begin_nolock()
1852 ocfs2_free_write_ctxt(inode, wc); in ocfs2_write_begin_nolock()
1927 struct ocfs2_write_ctxt *wc) in ocfs2_write_end_inline() argument
1932 if (!PageUptodate(wc->w_target_page)) { in ocfs2_write_end_inline()
1938 kaddr = kmap_atomic(wc->w_target_page); in ocfs2_write_end_inline()
1956 struct ocfs2_write_ctxt *wc = fsdata; in ocfs2_write_end_nolock() local
1957 struct ocfs2_dinode *di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; in ocfs2_write_end_nolock()
1958 handle_t *handle = wc->w_handle; in ocfs2_write_end_nolock()
1961 BUG_ON(!list_empty(&wc->w_unwritten_list)); in ocfs2_write_end_nolock()
1965 wc->w_di_bh, OCFS2_JOURNAL_ACCESS_WRITE); in ocfs2_write_end_nolock()
1974 ocfs2_write_end_inline(inode, pos, len, &copied, di, wc); in ocfs2_write_end_nolock()
1978 if (unlikely(copied < len) && wc->w_target_page) { in ocfs2_write_end_nolock()
1981 if (!PageUptodate(wc->w_target_page)) in ocfs2_write_end_nolock()
1985 if (new_isize > page_offset(wc->w_target_page)) in ocfs2_write_end_nolock()
1986 ocfs2_zero_new_buffers(wc->w_target_page, start+copied, in ocfs2_write_end_nolock()
1996 block_invalidate_folio(page_folio(wc->w_target_page), in ocfs2_write_end_nolock()
2000 if (wc->w_target_page) in ocfs2_write_end_nolock()
2001 flush_dcache_page(wc->w_target_page); in ocfs2_write_end_nolock()
2003 for(i = 0; i < wc->w_num_pages; i++) { in ocfs2_write_end_nolock()
2004 tmppage = wc->w_pages[i]; in ocfs2_write_end_nolock()
2010 if (tmppage == wc->w_target_page) { in ocfs2_write_end_nolock()
2011 from = wc->w_target_from; in ocfs2_write_end_nolock()
2012 to = wc->w_target_to; in ocfs2_write_end_nolock()
2042 if (wc->w_type != OCFS2_WRITE_DIRECT) { in ocfs2_write_end_nolock()
2057 ocfs2_journal_dirty(handle, wc->w_di_bh); in ocfs2_write_end_nolock()
2065 ocfs2_unlock_pages(wc); in ocfs2_write_end_nolock()
2070 ocfs2_run_deallocs(osb, &wc->w_dealloc); in ocfs2_write_end_nolock()
2072 brelse(wc->w_di_bh); in ocfs2_write_end_nolock()
2073 kfree(wc); in ocfs2_write_end_nolock()
2146 struct ocfs2_write_ctxt *wc; in ocfs2_dio_wr_get_block() local
2241 (void **)&wc, di_bh, NULL); in ocfs2_dio_wr_get_block()
2247 desc = &wc->w_desc[0]; in ocfs2_dio_wr_get_block()
2265 if (!list_empty(&wc->w_unwritten_list)) { in ocfs2_dio_wr_get_block()
2268 ue = list_first_entry(&wc->w_unwritten_list, in ocfs2_dio_wr_get_block()
2275 list_splice_tail_init(&wc->w_unwritten_list, &dwc->dw_zero_list); in ocfs2_dio_wr_get_block()
2276 dwc->dw_zero_count += wc->w_unwritten_count; in ocfs2_dio_wr_get_block()
2279 ret = ocfs2_write_end_nolock(inode->i_mapping, pos, len, len, wc); in ocfs2_dio_wr_get_block()