this is private and is expected that the caller checks that discard threads are running via _discard_started()
| 870 | // this is private and is expected that the caller checks that discard |
| 871 | // threads are running via _discard_started() |
| 872 | bool KernelDevice::_queue_discard(interval_set<uint64_t> &to_release) |
| 873 | { |
| 874 | if (to_release.empty()) |
| 875 | return false; |
| 876 | |
| 877 | auto max_pending = cct->_conf->bdev_async_discard_max_pending; |
| 878 | |
| 879 | std::lock_guard l(discard_lock); |
| 880 | |
| 881 | if (max_pending > 0 && discard_queued.num_intervals() >= max_pending) { |
| 882 | discard_cond.notify_one(); |
| 883 | return false; |
| 884 | } |
| 885 | |
| 886 | if(discard_queue_bytes >= cct->_conf->bdev_discard_max_bytes) { |
| 887 | discard_cond.notify_one(); |
| 888 | return false; |
| 889 | } |
| 890 | |
| 891 | discard_queued.insert(to_release); |
| 892 | |
| 893 | size_t discarded_bytes = 0; |
| 894 | for(auto p = to_release.begin(); p != to_release.end(); ++p){ |
| 895 | discarded_bytes += p.get_len(); |
| 896 | } |
| 897 | discard_queue_bytes += discarded_bytes; |
| 898 | |
| 899 | discard_queue_length = discard_queued.num_intervals(); |
| 900 | |
| 901 | discard_cond.notify_one(); |
| 902 | return true; |
| 903 | } |
| 904 | |
| 905 | // return true only if discard was queued, so caller won't have to do |
| 906 | // alloc->release, otherwise return false |
nothing calls this directly
no test coverage detected