client: Send the rest of a short io_uring send instead of disconnecting #174
Open
koolkhel
wants to merge 2 commits from
koolkhel/vitastor:zc-short-send into master
pull from: koolkhel/vitastor:zc-short-send
merge into: vitalif:master
vitalif:master
vitalif:primary-stickiness
vitalif:libvfn
vitalif:canceling
vitalif:immediate-repeering
vitalif:rdma-close-tcp
vitalif:use-degraded-writes
vitalif:fix-write-delete-flow
vitalif:openssl-3.0.12
vitalif:openssl-capture-secrets
vitalif:ignore-small-rdma-end
vitalif:encrypt-batch
vitalif:faster-peering-calc
vitalif:http-hello
vitalif:xxh3-bench
vitalif:create-user-etcd-based
vitalif:aesxts_streaming_nosupport
vitalif:refactor-heap-continue-write
vitalif:ston3lu-patch-0127
vitalif:rdma-credits
vitalif:heap-meta
vitalif:sendmsg-zc-no-more-error
vitalif:fix-clear-refs
vitalif:veeam-trick
vitalif:test-etcd-schizo
vitalif:test
vitalif:test1
vitalif:test2
vitalif:cow-meta
vitalif:kv-readahead
vitalif:qemu-fix-crash-idea
vitalif:eventloop-auto-init-trigger
vitalif:hugo-docs
vitalif:node-mutex-and-postpone
vitalif:check-writeback
vitalif:msgr-iothreads-v2
vitalif:antietcd
vitalif:rel-1.4
vitalif:test-fix-ec-unknown-state-51
vitalif:kv-update
vitalif:kv-debug
vitalif:hotfix-1.2.0
vitalif:rdma-simple-nodp
vitalif:zerocopy-tcp-send
vitalif:csi-staging
vitalif:hotfix-1.1.0
vitalif:hotfix-1.0.0
vitalif:fsync-feedback
vitalif:cached-reads
vitalif:qemu-send-loop
vitalif:test-double-alloc
vitalif:hier-failure-domains
vitalif:mon-self-restart
vitalif:epoch-deletions
vitalif:rdma-flow-control
vitalif:csi-use-vitastor-cli
vitalif:rdma-v2
vitalif:etcd-hide-base64
vitalif:lrc-matrix
vitalif:rm-left-on-dead
vitalif:nfs-proxy-old
vitalif:non-odp-rdma
vitalif:test-zctr
vitalif:separate-data-connections
vitalif:sec_osd_msgr
vitalif:test-assert
vitalif:nbd-vmsplice
vitalif:allow-etcd-address-option
vitalif:rdma-zerocopy
vitalif:rel-0.5
vitalif:openonload
vitalif:sync-io-test
vitalif:trace-sync
vitalif:trace-sqes
vitalif:test-submit-and-wait
vitalif:test-sq-poll
vitalif:blocking-uring-test
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
No description provided.
Delete Branch "koolkhel/vitastor:zc-short-send"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Two related problems in
handle_send()with io_uring, fixed without touching EPOLLOUT:sendmsg/sendmsg_zcwithMSG_WAITALLsubmitted through io_uring can still complete short: afterAPOLL_MAX_RETRY(128) poll retries io_uring punts it to io-wq, where it runs withMSG_DONTWAITand returns what it managed to send. Observed on kernel 6.8 with CPU-starved OSDs and large replies (the punt came after exactly 127 poll re-arms);handle_send()took it for a socket error and disconnected the peer, which re-peered its PGs.send_list, but only a later queued op resent it, and the failed send'ssend_freerange was never handed to the retry: after a copy send its entries stayed referenced until disconnect (holding every later reply on the connection), and after a zero-copy send its notification freed replies thatsend_liststill pointed into.Fix:
eat_send_list, as the sync path does), keeps the rest insend_listand callswakeup_send(), so the nexttry_send()fromsend_replies()sends the rest. No EPOLLOUT switching: io_uring polls the new SQE itself.send_free: a REF bit can't express two holders, so the short send's IN/BUF entries move to the end ofsend_free(the next send's range starts at them, via the newosd_client_t::send_free_rest), while the short send keeps REF-only entries in its own range — the same form as the existing IOV_MAX-split placeholder. Sincesend_freeis freed from the front, a buffer is freed only after both sends are done and, if zero-copy, released. Full sends are unchanged.Tested: new tests in
test_msgr_stopover a fake ring, so they run without io_uring: -EAGAIN on copy and zero-copy sends (with and without a notification, at every position), short sends stopping inside a reply's header and inside its data with the rest sent as copy and as zero-copy and the releases in every order, a retry that stops short again,stop_client()with releases pending, plus ordering tests for out-of-order releases and the IOV_MAX split. Without the fix they fail (disconnect, use-after-free via the notification, entry referenced forever, no reschedule); with it the wholetest_msgr_stopandosd_testpass, also under ASan.Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA
@@ -796,0 +796,4 @@if (!use_sync_send_recv){// MSG_WAITALL doesn't hold when io_uring punts the send to io-wqfprintf(stderr, "Client %ju: %ssend stopped short at %d of %zu bytes, sending the rest\n",print можно убрать, если это теперь штатная ситуация
Убрал:
17793798f4Ну фикс лучше чем у китайца, но на самом деле есть ещё вопрос, почему требуется такой сложный фикс, причём срабатывающий при любом send, не только при частичном, когда по идее в коде уже есть путь обработки частичного send (// Partially sent), почему нельзя просто включить его и всё? (ну м.б ещё какие-то микро правки доделать, если надо условно состояние отправки разбудить или что-то подобное)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.