Lines Matching refs:subreq

33 static void netfs_put_subrequest(struct netfs_read_subrequest *subreq,  in netfs_put_subrequest()  argument
36 if (refcount_dec_and_test(&subreq->usage)) in netfs_put_subrequest()
37 __netfs_put_subrequest(subreq, was_async); in netfs_put_subrequest()
73 struct netfs_read_subrequest *subreq; in netfs_rreq_clear_subreqs() local
76 subreq = list_first_entry(&rreq->subrequests, in netfs_rreq_clear_subreqs()
78 list_del(&subreq->rreq_link); in netfs_rreq_clear_subreqs()
79 netfs_put_subrequest(subreq, was_async); in netfs_rreq_clear_subreqs()
116 struct netfs_read_subrequest *subreq; in netfs_alloc_subrequest() local
118 subreq = kzalloc(sizeof(struct netfs_read_subrequest), GFP_KERNEL); in netfs_alloc_subrequest()
119 if (subreq) { in netfs_alloc_subrequest()
120 INIT_LIST_HEAD(&subreq->rreq_link); in netfs_alloc_subrequest()
121 refcount_set(&subreq->usage, 2); in netfs_alloc_subrequest()
122 subreq->rreq = rreq; in netfs_alloc_subrequest()
127 return subreq; in netfs_alloc_subrequest()
130 static void netfs_get_read_subrequest(struct netfs_read_subrequest *subreq) in netfs_get_read_subrequest() argument
132 refcount_inc(&subreq->usage); in netfs_get_read_subrequest()
135 static void __netfs_put_subrequest(struct netfs_read_subrequest *subreq, in __netfs_put_subrequest() argument
138 struct netfs_read_request *rreq = subreq->rreq; in __netfs_put_subrequest()
140 trace_netfs_sreq(subreq, netfs_sreq_trace_free); in __netfs_put_subrequest()
141 kfree(subreq); in __netfs_put_subrequest()
149 static void netfs_clear_unread(struct netfs_read_subrequest *subreq) in netfs_clear_unread() argument
153 iov_iter_xarray(&iter, READ, &subreq->rreq->mapping->i_pages, in netfs_clear_unread()
154 subreq->start + subreq->transferred, in netfs_clear_unread()
155 subreq->len - subreq->transferred); in netfs_clear_unread()
162 struct netfs_read_subrequest *subreq = priv; in netfs_cache_read_terminated() local
164 netfs_subreq_terminated(subreq, transferred_or_error, was_async); in netfs_cache_read_terminated()
172 struct netfs_read_subrequest *subreq, in netfs_read_from_cache() argument
180 subreq->start + subreq->transferred, in netfs_read_from_cache()
181 subreq->len - subreq->transferred); in netfs_read_from_cache()
183 cres->ops->read(cres, subreq->start, &iter, seek_data, in netfs_read_from_cache()
184 netfs_cache_read_terminated, subreq); in netfs_read_from_cache()
191 struct netfs_read_subrequest *subreq) in netfs_fill_with_zeroes() argument
194 __set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags); in netfs_fill_with_zeroes()
195 netfs_subreq_terminated(subreq, 0, false); in netfs_fill_with_zeroes()
215 struct netfs_read_subrequest *subreq) in netfs_read_from_server() argument
218 rreq->netfs_ops->issue_op(subreq); in netfs_read_from_server()
240 struct netfs_read_subrequest *subreq; in netfs_rreq_unmark_after_write() local
247 list_for_each_entry(subreq, &rreq->subrequests, rreq_link) { in netfs_rreq_unmark_after_write()
248 XA_STATE(xas, &rreq->mapping->i_pages, subreq->start / PAGE_SIZE); in netfs_rreq_unmark_after_write()
250 xas_for_each(&xas, folio, (subreq->start + subreq->len - 1) / PAGE_SIZE) { in netfs_rreq_unmark_after_write()
269 struct netfs_read_subrequest *subreq = priv; in netfs_rreq_copy_terminated() local
270 struct netfs_read_request *rreq = subreq->rreq; in netfs_rreq_copy_terminated()
274 trace_netfs_failure(rreq, subreq, transferred_or_error, in netfs_rreq_copy_terminated()
280 trace_netfs_sreq(subreq, netfs_sreq_trace_write_term); in netfs_rreq_copy_terminated()
286 netfs_put_subrequest(subreq, was_async); in netfs_rreq_copy_terminated()
296 struct netfs_read_subrequest *subreq, *next, *p; in netfs_rreq_do_write_to_cache() local
307 list_for_each_entry_safe(subreq, p, &rreq->subrequests, rreq_link) { in netfs_rreq_do_write_to_cache()
308 if (!test_bit(NETFS_SREQ_WRITE_TO_CACHE, &subreq->flags)) { in netfs_rreq_do_write_to_cache()
309 list_del_init(&subreq->rreq_link); in netfs_rreq_do_write_to_cache()
310 netfs_put_subrequest(subreq, false); in netfs_rreq_do_write_to_cache()
314 list_for_each_entry(subreq, &rreq->subrequests, rreq_link) { in netfs_rreq_do_write_to_cache()
316 while (!list_is_last(&subreq->rreq_link, &rreq->subrequests)) { in netfs_rreq_do_write_to_cache()
317 next = list_next_entry(subreq, rreq_link); in netfs_rreq_do_write_to_cache()
318 if (next->start != subreq->start + subreq->len) in netfs_rreq_do_write_to_cache()
320 subreq->len += next->len; in netfs_rreq_do_write_to_cache()
325 ret = cres->ops->prepare_write(cres, &subreq->start, &subreq->len, in netfs_rreq_do_write_to_cache()
328 trace_netfs_failure(rreq, subreq, ret, netfs_fail_prepare_write); in netfs_rreq_do_write_to_cache()
329 trace_netfs_sreq(subreq, netfs_sreq_trace_write_skip); in netfs_rreq_do_write_to_cache()
334 subreq->start, subreq->len); in netfs_rreq_do_write_to_cache()
338 netfs_get_read_subrequest(subreq); in netfs_rreq_do_write_to_cache()
339 trace_netfs_sreq(subreq, netfs_sreq_trace_write); in netfs_rreq_do_write_to_cache()
340 cres->ops->write(cres, subreq->start, &iter, in netfs_rreq_do_write_to_cache()
341 netfs_rreq_copy_terminated, subreq); in netfs_rreq_do_write_to_cache()
370 struct netfs_read_subrequest *subreq; in netfs_rreq_unlock() local
381 list_for_each_entry(subreq, &rreq->subrequests, rreq_link) { in netfs_rreq_unlock()
382 __clear_bit(NETFS_SREQ_WRITE_TO_CACHE, &subreq->flags); in netfs_rreq_unlock()
392 subreq = list_first_entry(&rreq->subrequests, in netfs_rreq_unlock()
395 subreq_failed = (subreq->error < 0); in netfs_rreq_unlock()
406 if (!subreq) { in netfs_rreq_unlock()
410 if (test_bit(NETFS_SREQ_WRITE_TO_CACHE, &subreq->flags)) in netfs_rreq_unlock()
413 if (pgend < iopos + subreq->len) in netfs_rreq_unlock()
416 account += subreq->transferred; in netfs_rreq_unlock()
417 iopos += subreq->len; in netfs_rreq_unlock()
418 if (!list_is_last(&subreq->rreq_link, &rreq->subrequests)) { in netfs_rreq_unlock()
419 subreq = list_next_entry(subreq, rreq_link); in netfs_rreq_unlock()
420 subreq_failed = (subreq->error < 0); in netfs_rreq_unlock()
422 subreq = NULL; in netfs_rreq_unlock()
453 struct netfs_read_subrequest *subreq) in netfs_rreq_short_read() argument
455 __clear_bit(NETFS_SREQ_SHORT_READ, &subreq->flags); in netfs_rreq_short_read()
456 __set_bit(NETFS_SREQ_SEEK_DATA_READ, &subreq->flags); in netfs_rreq_short_read()
459 trace_netfs_sreq(subreq, netfs_sreq_trace_resubmit_short); in netfs_rreq_short_read()
461 netfs_get_read_subrequest(subreq); in netfs_rreq_short_read()
463 if (subreq->source == NETFS_READ_FROM_CACHE) in netfs_rreq_short_read()
464 netfs_read_from_cache(rreq, subreq, true); in netfs_rreq_short_read()
466 netfs_read_from_server(rreq, subreq); in netfs_rreq_short_read()
475 struct netfs_read_subrequest *subreq; in netfs_rreq_perform_resubmissions() local
487 list_for_each_entry(subreq, &rreq->subrequests, rreq_link) { in netfs_rreq_perform_resubmissions()
488 if (subreq->error) { in netfs_rreq_perform_resubmissions()
489 if (subreq->source != NETFS_READ_FROM_CACHE) in netfs_rreq_perform_resubmissions()
491 subreq->source = NETFS_DOWNLOAD_FROM_SERVER; in netfs_rreq_perform_resubmissions()
492 subreq->error = 0; in netfs_rreq_perform_resubmissions()
494 trace_netfs_sreq(subreq, netfs_sreq_trace_download_instead); in netfs_rreq_perform_resubmissions()
495 netfs_get_read_subrequest(subreq); in netfs_rreq_perform_resubmissions()
497 netfs_read_from_server(rreq, subreq); in netfs_rreq_perform_resubmissions()
498 } else if (test_bit(NETFS_SREQ_SHORT_READ, &subreq->flags)) { in netfs_rreq_perform_resubmissions()
499 netfs_rreq_short_read(rreq, subreq); in netfs_rreq_perform_resubmissions()
516 struct netfs_read_subrequest *subreq; in netfs_rreq_is_still_valid() local
522 list_for_each_entry(subreq, &rreq->subrequests, rreq_link) { in netfs_rreq_is_still_valid()
523 if (subreq->source == NETFS_READ_FROM_CACHE) { in netfs_rreq_is_still_valid()
524 subreq->error = -ESTALE; in netfs_rreq_is_still_valid()
602 void netfs_subreq_terminated(struct netfs_read_subrequest *subreq, in netfs_subreq_terminated() argument
606 struct netfs_read_request *rreq = subreq->rreq; in netfs_subreq_terminated()
610 subreq->debug_index, subreq->start, subreq->flags, in netfs_subreq_terminated()
613 switch (subreq->source) { in netfs_subreq_terminated()
625 subreq->error = transferred_or_error; in netfs_subreq_terminated()
626 trace_netfs_failure(rreq, subreq, transferred_or_error, in netfs_subreq_terminated()
631 if (WARN(transferred_or_error > subreq->len - subreq->transferred, in netfs_subreq_terminated()
633 rreq->debug_id, subreq->debug_index, in netfs_subreq_terminated()
634 transferred_or_error, subreq->len, subreq->transferred)) in netfs_subreq_terminated()
635 transferred_or_error = subreq->len - subreq->transferred; in netfs_subreq_terminated()
637 subreq->error = 0; in netfs_subreq_terminated()
638 subreq->transferred += transferred_or_error; in netfs_subreq_terminated()
639 if (subreq->transferred < subreq->len) in netfs_subreq_terminated()
643 __clear_bit(NETFS_SREQ_NO_PROGRESS, &subreq->flags); in netfs_subreq_terminated()
644 if (test_bit(NETFS_SREQ_WRITE_TO_CACHE, &subreq->flags)) in netfs_subreq_terminated()
648 trace_netfs_sreq(subreq, netfs_sreq_trace_terminated); in netfs_subreq_terminated()
657 netfs_put_subrequest(subreq, was_async); in netfs_subreq_terminated()
661 if (test_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags)) { in netfs_subreq_terminated()
662 netfs_clear_unread(subreq); in netfs_subreq_terminated()
663 subreq->transferred = subreq->len; in netfs_subreq_terminated()
668 if (__test_and_set_bit(NETFS_SREQ_NO_PROGRESS, &subreq->flags)) { in netfs_subreq_terminated()
669 subreq->error = -ENODATA; in netfs_subreq_terminated()
673 __clear_bit(NETFS_SREQ_NO_PROGRESS, &subreq->flags); in netfs_subreq_terminated()
676 __set_bit(NETFS_SREQ_SHORT_READ, &subreq->flags); in netfs_subreq_terminated()
681 if (subreq->source == NETFS_READ_FROM_CACHE) { in netfs_subreq_terminated()
687 rreq->error = subreq->error; in netfs_subreq_terminated()
693 static enum netfs_read_source netfs_cache_prepare_read(struct netfs_read_subrequest *subreq, in netfs_cache_prepare_read() argument
696 struct netfs_read_request *rreq = subreq->rreq; in netfs_cache_prepare_read()
700 return cres->ops->prepare_read(subreq, i_size); in netfs_cache_prepare_read()
701 if (subreq->start >= rreq->i_size) in netfs_cache_prepare_read()
711 struct netfs_read_subrequest *subreq) in netfs_rreq_prepare_read() argument
715 _enter("%llx-%llx,%llx", subreq->start, subreq->start + subreq->len, rreq->i_size); in netfs_rreq_prepare_read()
717 source = netfs_cache_prepare_read(subreq, rreq->i_size); in netfs_rreq_prepare_read()
728 if (subreq->len > rreq->i_size - subreq->start) in netfs_rreq_prepare_read()
729 subreq->len = rreq->i_size - subreq->start; in netfs_rreq_prepare_read()
732 !rreq->netfs_ops->clamp_length(subreq)) { in netfs_rreq_prepare_read()
738 if (WARN_ON(subreq->len == 0)) in netfs_rreq_prepare_read()
742 subreq->source = source; in netfs_rreq_prepare_read()
743 trace_netfs_sreq(subreq, netfs_sreq_trace_prepare); in netfs_rreq_prepare_read()
753 struct netfs_read_subrequest *subreq; in netfs_rreq_submit_slice() local
756 subreq = netfs_alloc_subrequest(rreq); in netfs_rreq_submit_slice()
757 if (!subreq) in netfs_rreq_submit_slice()
760 subreq->debug_index = (*_debug_index)++; in netfs_rreq_submit_slice()
761 subreq->start = rreq->start + rreq->submitted; in netfs_rreq_submit_slice()
762 subreq->len = rreq->len - rreq->submitted; in netfs_rreq_submit_slice()
764 _debug("slice %llx,%zx,%zx", subreq->start, subreq->len, rreq->submitted); in netfs_rreq_submit_slice()
765 list_add_tail(&subreq->rreq_link, &rreq->subrequests); in netfs_rreq_submit_slice()
775 source = netfs_rreq_prepare_read(rreq, subreq); in netfs_rreq_submit_slice()
781 rreq->submitted += subreq->len; in netfs_rreq_submit_slice()
783 trace_netfs_sreq(subreq, netfs_sreq_trace_submit); in netfs_rreq_submit_slice()
786 netfs_fill_with_zeroes(rreq, subreq); in netfs_rreq_submit_slice()
789 netfs_read_from_server(rreq, subreq); in netfs_rreq_submit_slice()
792 netfs_read_from_cache(rreq, subreq, false); in netfs_rreq_submit_slice()
801 rreq->error = subreq->error; in netfs_rreq_submit_slice()
802 netfs_put_subrequest(subreq, false); in netfs_rreq_submit_slice()