Lines Matching refs:lseg

62 static bool pnfs_lseg_dec_and_remove_zero(struct pnfs_layout_segment *lseg,
376 struct pnfs_layout_segment *lseg; in pnfs_clear_layoutreturn_info() local
380 list_for_each_entry(lseg, &lo->plh_segs, pls_list) { in pnfs_clear_layoutreturn_info()
381 if (!test_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags)) in pnfs_clear_layoutreturn_info()
383 pnfs_set_plh_return_info(lo, lseg->pls_range.iomode, 0); in pnfs_clear_layoutreturn_info()
397 pnfs_clear_lseg_state(struct pnfs_layout_segment *lseg, in pnfs_clear_lseg_state() argument
400 clear_bit(NFS_LSEG_ROC, &lseg->pls_flags); in pnfs_clear_lseg_state()
401 clear_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags); in pnfs_clear_lseg_state()
402 if (test_and_clear_bit(NFS_LSEG_VALID, &lseg->pls_flags)) in pnfs_clear_lseg_state()
403 pnfs_lseg_dec_and_remove_zero(lseg, free_me); in pnfs_clear_lseg_state()
404 if (test_and_clear_bit(NFS_LSEG_LAYOUTCOMMIT, &lseg->pls_flags)) in pnfs_clear_lseg_state()
405 pnfs_lseg_dec_and_remove_zero(lseg, free_me); in pnfs_clear_lseg_state()
466 struct pnfs_layout_segment *lseg, *next; in pnfs_mark_layout_stateid_invalid() local
469 list_for_each_entry_safe(lseg, next, &lo->plh_segs, pls_list) in pnfs_mark_layout_stateid_invalid()
470 pnfs_clear_lseg_state(lseg, lseg_list); in pnfs_mark_layout_stateid_invalid()
553 pnfs_init_lseg(struct pnfs_layout_hdr *lo, struct pnfs_layout_segment *lseg, in pnfs_init_lseg() argument
557 INIT_LIST_HEAD(&lseg->pls_list); in pnfs_init_lseg()
558 INIT_LIST_HEAD(&lseg->pls_lc_list); in pnfs_init_lseg()
559 INIT_LIST_HEAD(&lseg->pls_commits); in pnfs_init_lseg()
560 refcount_set(&lseg->pls_refcount, 1); in pnfs_init_lseg()
561 set_bit(NFS_LSEG_VALID, &lseg->pls_flags); in pnfs_init_lseg()
562 lseg->pls_layout = lo; in pnfs_init_lseg()
563 lseg->pls_range = *range; in pnfs_init_lseg()
564 lseg->pls_seq = be32_to_cpu(stateid->seqid); in pnfs_init_lseg()
567 static void pnfs_free_lseg(struct pnfs_layout_segment *lseg) in pnfs_free_lseg() argument
569 if (lseg != NULL) { in pnfs_free_lseg()
570 struct inode *inode = lseg->pls_layout->plh_inode; in pnfs_free_lseg()
571 NFS_SERVER(inode)->pnfs_curr_ld->free_lseg(lseg); in pnfs_free_lseg()
577 struct pnfs_layout_segment *lseg) in pnfs_layout_remove_lseg() argument
579 WARN_ON(test_bit(NFS_LSEG_VALID, &lseg->pls_flags)); in pnfs_layout_remove_lseg()
580 list_del_init(&lseg->pls_list); in pnfs_layout_remove_lseg()
583 if (test_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags)) in pnfs_layout_remove_lseg()
596 struct pnfs_layout_segment *lseg) in pnfs_cache_lseg_for_layoutreturn() argument
598 if (test_and_clear_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags) && in pnfs_cache_lseg_for_layoutreturn()
600 pnfs_set_plh_return_info(lo, lseg->pls_range.iomode, 0); in pnfs_cache_lseg_for_layoutreturn()
601 list_move_tail(&lseg->pls_list, &lo->plh_return_segs); in pnfs_cache_lseg_for_layoutreturn()
608 pnfs_put_lseg(struct pnfs_layout_segment *lseg) in pnfs_put_lseg() argument
613 if (!lseg) in pnfs_put_lseg()
616 dprintk("%s: lseg %p ref %d valid %d\n", __func__, lseg, in pnfs_put_lseg()
617 refcount_read(&lseg->pls_refcount), in pnfs_put_lseg()
618 test_bit(NFS_LSEG_VALID, &lseg->pls_flags)); in pnfs_put_lseg()
620 lo = lseg->pls_layout; in pnfs_put_lseg()
623 if (refcount_dec_and_lock(&lseg->pls_refcount, &inode->i_lock)) { in pnfs_put_lseg()
625 pnfs_layout_remove_lseg(lo, lseg); in pnfs_put_lseg()
626 if (pnfs_cache_lseg_for_layoutreturn(lo, lseg)) in pnfs_put_lseg()
627 lseg = NULL; in pnfs_put_lseg()
629 pnfs_free_lseg(lseg); in pnfs_put_lseg()
654 static bool pnfs_lseg_dec_and_remove_zero(struct pnfs_layout_segment *lseg, in pnfs_lseg_dec_and_remove_zero() argument
657 if (!refcount_dec_and_test(&lseg->pls_refcount)) in pnfs_lseg_dec_and_remove_zero()
659 pnfs_layout_remove_lseg(lseg->pls_layout, lseg); in pnfs_lseg_dec_and_remove_zero()
660 list_add(&lseg->pls_list, tmp_list); in pnfs_lseg_dec_and_remove_zero()
665 static int mark_lseg_invalid(struct pnfs_layout_segment *lseg, in mark_lseg_invalid() argument
670 if (test_and_clear_bit(NFS_LSEG_VALID, &lseg->pls_flags)) { in mark_lseg_invalid()
675 dprintk("%s: lseg %p ref %d\n", __func__, lseg, in mark_lseg_invalid()
676 refcount_read(&lseg->pls_refcount)); in mark_lseg_invalid()
677 if (pnfs_lseg_dec_and_remove_zero(lseg, tmp_list)) in mark_lseg_invalid()
693 pnfs_match_lseg_recall(const struct pnfs_layout_segment *lseg, in pnfs_match_lseg_recall() argument
697 if (seq != 0 && pnfs_seqid_is_newer(lseg->pls_seq, seq)) in pnfs_match_lseg_recall()
701 return pnfs_should_free_range(&lseg->pls_range, recall_range); in pnfs_match_lseg_recall()
725 struct pnfs_layout_segment *lseg, *next; in pnfs_mark_matching_lsegs_invalid() local
733 list_for_each_entry_safe(lseg, next, &lo->plh_segs, pls_list) in pnfs_mark_matching_lsegs_invalid()
734 if (pnfs_match_lseg_recall(lseg, recall_range, seq)) { in pnfs_mark_matching_lsegs_invalid()
737 lseg, lseg->pls_range.iomode, lseg->pls_seq, in pnfs_mark_matching_lsegs_invalid()
738 lseg->pls_range.offset, lseg->pls_range.length); in pnfs_mark_matching_lsegs_invalid()
739 if (mark_lseg_invalid(lseg, tmp_list)) in pnfs_mark_matching_lsegs_invalid()
742 pnfs_lseg_cancel_io(server, lseg); in pnfs_mark_matching_lsegs_invalid()
754 struct pnfs_layout_segment *lseg, *next; in pnfs_free_returned_lsegs() local
756 list_for_each_entry_safe(lseg, next, &lo->plh_return_segs, pls_list) { in pnfs_free_returned_lsegs()
757 if (pnfs_match_lseg_recall(lseg, range, seq)) in pnfs_free_returned_lsegs()
758 list_move_tail(&lseg->pls_list, free_me); in pnfs_free_returned_lsegs()
766 struct pnfs_layout_segment *lseg, *tmp; in pnfs_free_lseg_list() local
771 list_for_each_entry_safe(lseg, tmp, free_me, pls_list) { in pnfs_free_lseg_list()
772 list_del(&lseg->pls_list); in pnfs_free_lseg_list()
773 pnfs_free_lseg(lseg); in pnfs_free_lseg_list()
1235 struct pnfs_layout_segment *lseg, *tmp; in pnfs_clear_layoutcommit() local
1239 list_for_each_entry_safe(lseg, tmp, &nfsi->layout->plh_segs, pls_list) { in pnfs_clear_layoutcommit()
1240 if (!test_and_clear_bit(NFS_LSEG_LAYOUTCOMMIT, &lseg->pls_flags)) in pnfs_clear_layoutcommit()
1242 pnfs_lseg_dec_and_remove_zero(lseg, head); in pnfs_clear_layoutcommit()
1251 const struct pnfs_layout_segment *lseg; in pnfs_layoutreturn_retry_later_locked() local
1256 list_for_each_entry(lseg, &lo->plh_return_segs, pls_list) { in pnfs_layoutreturn_retry_later_locked()
1257 if (pnfs_seqid_is_newer(lseg->pls_seq, seq) || in pnfs_layoutreturn_retry_later_locked()
1258 !pnfs_should_free_range(&lseg->pls_range, range)) in pnfs_layoutreturn_retry_later_locked()
1548 struct pnfs_layout_segment *lseg, *next; in pnfs_roc() local
1595 list_for_each_entry_safe(lseg, next, &lo->plh_segs, pls_list) { in pnfs_roc()
1596 if (skip_read && lseg->pls_range.iomode == IOMODE_READ) in pnfs_roc()
1599 if (!test_and_clear_bit(NFS_LSEG_ROC, &lseg->pls_flags)) in pnfs_roc()
1605 set_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags); in pnfs_roc()
1606 if (!mark_lseg_invalid(lseg, &lo->plh_return_segs)) in pnfs_roc()
1608 pnfs_set_plh_return_info(lo, lseg->pls_range.iomode, 0); in pnfs_roc()
1775 pnfs_lseg_no_merge(struct pnfs_layout_segment *lseg, in pnfs_lseg_no_merge() argument
1783 struct pnfs_layout_segment *lseg, in pnfs_generic_layout_insert_lseg() argument
1797 if (do_merge(lseg, lp)) { in pnfs_generic_layout_insert_lseg()
1801 if (is_after(&lseg->pls_range, &lp->pls_range)) in pnfs_generic_layout_insert_lseg()
1803 list_add_tail(&lseg->pls_list, &lp->pls_list); in pnfs_generic_layout_insert_lseg()
1807 __func__, lseg, lseg->pls_range.iomode, in pnfs_generic_layout_insert_lseg()
1808 lseg->pls_range.offset, lseg->pls_range.length, in pnfs_generic_layout_insert_lseg()
1813 list_add_tail(&lseg->pls_list, &lo->plh_segs); in pnfs_generic_layout_insert_lseg()
1816 __func__, lseg, lseg->pls_range.iomode, in pnfs_generic_layout_insert_lseg()
1817 lseg->pls_range.offset, lseg->pls_range.length); in pnfs_generic_layout_insert_lseg()
1827 struct pnfs_layout_segment *lseg, in pnfs_layout_insert_lseg() argument
1834 ld->add_lseg(lo, lseg, free_me); in pnfs_layout_insert_lseg()
1836 pnfs_generic_layout_insert_lseg(lo, lseg, in pnfs_layout_insert_lseg()
1932 struct pnfs_layout_segment *lseg, *ret = NULL; in pnfs_find_lseg() local
1936 list_for_each_entry(lseg, &lo->plh_segs, pls_list) { in pnfs_find_lseg()
1937 if (test_bit(NFS_LSEG_VALID, &lseg->pls_flags) && in pnfs_find_lseg()
1938 pnfs_lseg_range_match(&lseg->pls_range, range, in pnfs_find_lseg()
1940 ret = pnfs_get_lseg(lseg); in pnfs_find_lseg()
2100 struct pnfs_layout_segment *lseg = NULL; in pnfs_update_layout() local
2110 trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, in pnfs_update_layout()
2116 trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, in pnfs_update_layout()
2124 iomode, lo, lseg, in pnfs_update_layout()
2126 lseg = ERR_PTR(-EIO); in pnfs_update_layout()
2130 lseg = ERR_PTR(nfs4_client_recover_expired_lease(clp)); in pnfs_update_layout()
2131 if (IS_ERR(lseg)) in pnfs_update_layout()
2138 lseg = ERR_PTR(-ENOMEM); in pnfs_update_layout()
2139 trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, in pnfs_update_layout()
2146 trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, in pnfs_update_layout()
2154 trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, in pnfs_update_layout()
2166 lseg = ERR_PTR(wait_on_bit(&lo->plh_flags, NFS_LAYOUT_DRAIN, in pnfs_update_layout()
2168 if (IS_ERR(lseg)) in pnfs_update_layout()
2181 lseg = ERR_PTR(pnfs_prepare_to_retry_layoutget(lo)); in pnfs_update_layout()
2182 if (!IS_ERR(lseg)) { in pnfs_update_layout()
2186 lseg, in pnfs_update_layout()
2190 trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, in pnfs_update_layout()
2195 lseg = pnfs_find_lseg(lo, &arg, strict_iomode); in pnfs_update_layout()
2196 if (lseg) { in pnfs_update_layout()
2197 trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, in pnfs_update_layout()
2217 lseg = ERR_PTR(wait_on_bit(&lo->plh_flags, in pnfs_update_layout()
2220 if (IS_ERR(lseg)) in pnfs_update_layout()
2233 lseg = ERR_PTR(status); in pnfs_update_layout()
2235 iomode, lo, lseg, in pnfs_update_layout()
2248 trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, in pnfs_update_layout()
2267 lseg = ERR_PTR(-ENOMEM); in pnfs_update_layout()
2277 lseg = nfs4_proc_layoutget(lgp, &exception); in pnfs_update_layout()
2278 trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, in pnfs_update_layout()
2281 if (IS_ERR(lseg)) { in pnfs_update_layout()
2282 switch(PTR_ERR(lseg)) { in pnfs_update_layout()
2285 lseg = NULL; in pnfs_update_layout()
2294 lseg = NULL; in pnfs_update_layout()
2297 if (!nfs_error_is_fatal(PTR_ERR(lseg))) { in pnfs_update_layout()
2299 lseg = NULL; in pnfs_update_layout()
2303 if (lseg) { in pnfs_update_layout()
2309 iomode, lo, lseg, PNFS_UPDATE_LAYOUT_RETRY); in pnfs_update_layout()
2320 trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, in pnfs_update_layout()
2328 IS_ERR_OR_NULL(lseg) ? "not found" : "found", in pnfs_update_layout()
2332 return lseg; in pnfs_update_layout()
2466 struct pnfs_layout_segment *lseg; in pnfs_parse_lgopen() local
2503 lseg = pnfs_layout_process(lgp); in pnfs_parse_lgopen()
2504 if (!IS_ERR(lseg)) { in pnfs_parse_lgopen()
2507 pnfs_put_lseg(lseg); in pnfs_parse_lgopen()
2527 struct pnfs_layout_segment *lseg; in pnfs_layout_process() local
2535 lseg = NFS_SERVER(ino)->pnfs_curr_ld->alloc_lseg(lo, res, lgp->gfp_flags); in pnfs_layout_process()
2536 if (IS_ERR_OR_NULL(lseg)) { in pnfs_layout_process()
2537 if (!lseg) in pnfs_layout_process()
2538 lseg = ERR_PTR(-ENOMEM); in pnfs_layout_process()
2541 __func__, PTR_ERR(lseg)); in pnfs_layout_process()
2542 return lseg; in pnfs_layout_process()
2545 pnfs_init_lseg(lo, lseg, &res->range, &res->stateid); in pnfs_layout_process()
2582 pnfs_get_lseg(lseg); in pnfs_layout_process()
2583 pnfs_layout_insert_lseg(lo, lseg, &free_me); in pnfs_layout_process()
2587 set_bit(NFS_LSEG_ROC, &lseg->pls_flags); in pnfs_layout_process()
2591 return lseg; in pnfs_layout_process()
2595 lseg->pls_layout = lo; in pnfs_layout_process()
2596 NFS_SERVER(ino)->pnfs_curr_ld->free_lseg(lseg); in pnfs_layout_process()
2622 struct pnfs_layout_segment *lseg, *next; in pnfs_mark_matching_lsegs_return() local
2633 list_for_each_entry_safe(lseg, next, &lo->plh_segs, pls_list) in pnfs_mark_matching_lsegs_return()
2634 if (pnfs_match_lseg_recall(lseg, return_range, seq)) { in pnfs_mark_matching_lsegs_return()
2637 lseg, lseg->pls_range.iomode, in pnfs_mark_matching_lsegs_return()
2638 lseg->pls_range.offset, in pnfs_mark_matching_lsegs_return()
2639 lseg->pls_range.length); in pnfs_mark_matching_lsegs_return()
2640 if (test_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags)) in pnfs_mark_matching_lsegs_return()
2642 if (mark_lseg_invalid(lseg, tmp_list)) in pnfs_mark_matching_lsegs_return()
2645 set_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags); in pnfs_mark_matching_lsegs_return()
2646 pnfs_lseg_cancel_io(server, lseg); in pnfs_mark_matching_lsegs_return()
2698 struct pnfs_layout_segment *lseg) in pnfs_error_mark_layout_for_return() argument
2701 .iomode = lseg->pls_range.iomode, in pnfs_error_mark_layout_for_return()
2723 struct pnfs_layout_segment *lseg; in pnfs_find_first_lseg() local
2725 list_for_each_entry(lseg, &lo->plh_segs, pls_list) { in pnfs_find_first_lseg()
2726 if (!test_bit(NFS_LSEG_VALID, &lseg->pls_flags)) in pnfs_find_first_lseg()
2728 if (test_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags)) in pnfs_find_first_lseg()
2730 if (lseg->pls_range.iomode != iomode && iomode != IOMODE_ANY) in pnfs_find_first_lseg()
2732 if (pnfs_lseg_range_intersecting(&lseg->pls_range, range)) in pnfs_find_first_lseg()
2733 return lseg; in pnfs_find_first_lseg()
2984 pnfs_set_layoutcommit(hdr->inode, hdr->lseg, in pnfs_ld_write_done()
3012 struct pnfs_layout_segment *lseg, in pnfs_try_to_write_data() argument
3035 struct pnfs_layout_segment *lseg = desc->pg_lseg; in pnfs_do_write() local
3038 trypnfs = pnfs_try_to_write_data(hdr, call_ops, lseg, how); in pnfs_do_write()
3058 pnfs_put_lseg(hdr->lseg); in pnfs_writehdr_free()
3075 hdr->lseg = pnfs_get_lseg(desc->pg_lseg); in pnfs_generic_pg_writepages()
3139 struct pnfs_layout_segment *lseg) in pnfs_try_to_read_data() argument
3165 pnfs_put_lseg(hdr->lseg); in pnfs_read_resend_pnfs()
3166 hdr->lseg = NULL; in pnfs_read_resend_pnfs()
3180 struct pnfs_layout_segment *lseg = desc->pg_lseg; in pnfs_do_read() local
3183 trypnfs = pnfs_try_to_read_data(hdr, call_ops, lseg); in pnfs_do_read()
3203 pnfs_put_lseg(hdr->lseg); in pnfs_readhdr_free()
3219 hdr->lseg = pnfs_get_lseg(desc->pg_lseg); in pnfs_generic_pg_readpages()
3241 struct pnfs_layout_segment *lseg; in pnfs_list_write_lseg() local
3243 list_for_each_entry(lseg, &NFS_I(inode)->layout->plh_segs, pls_list) { in pnfs_list_write_lseg()
3244 if (lseg->pls_range.iomode == IOMODE_RW && in pnfs_list_write_lseg()
3245 test_and_clear_bit(NFS_LSEG_LAYOUTCOMMIT, &lseg->pls_flags)) in pnfs_list_write_lseg()
3246 list_add(&lseg->pls_lc_list, listp); in pnfs_list_write_lseg()
3252 struct pnfs_layout_segment *lseg, *tmp; in pnfs_list_write_lseg_done() local
3255 list_for_each_entry_safe(lseg, tmp, listp, pls_lc_list) { in pnfs_list_write_lseg_done()
3256 list_del_init(&lseg->pls_lc_list); in pnfs_list_write_lseg_done()
3257 pnfs_put_lseg(lseg); in pnfs_list_write_lseg_done()
3263 void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg) in pnfs_set_lo_fail() argument
3265 pnfs_layout_io_set_failed(lseg->pls_layout, lseg->pls_range.iomode); in pnfs_set_lo_fail()
3270 pnfs_set_layoutcommit(struct inode *inode, struct pnfs_layout_segment *lseg, in pnfs_set_layoutcommit() argument
3284 if (!test_and_set_bit(NFS_LSEG_LAYOUTCOMMIT, &lseg->pls_flags)) { in pnfs_set_layoutcommit()
3286 pnfs_get_lseg(lseg); in pnfs_set_layoutcommit()
3290 __func__, lseg, nfsi->layout->plh_lwb); in pnfs_set_layoutcommit()