@@ -30,8 +30,11 @@ static void __send_queued(struct ceph_osd_client *osdc);
3030static int __reset_osd (struct ceph_osd_client * osdc , struct ceph_osd * osd );
3131static void __register_request (struct ceph_osd_client * osdc ,
3232 struct ceph_osd_request * req );
33+ static void __unregister_request (struct ceph_osd_client * osdc ,
34+ struct ceph_osd_request * req );
3335static void __unregister_linger_request (struct ceph_osd_client * osdc ,
3436 struct ceph_osd_request * req );
37+ static void __enqueue_request (struct ceph_osd_request * req );
3538static void __send_request (struct ceph_osd_client * osdc ,
3639 struct ceph_osd_request * req );
3740
@@ -892,6 +895,37 @@ __lookup_request_ge(struct ceph_osd_client *osdc,
892895 return NULL ;
893896}
894897
898+ static void __kick_linger_request (struct ceph_osd_request * req )
899+ {
900+ struct ceph_osd_client * osdc = req -> r_osdc ;
901+ struct ceph_osd * osd = req -> r_osd ;
902+
903+ /*
904+ * Linger requests need to be resent with a new tid to avoid
905+ * the dup op detection logic on the OSDs. Achieve this with
906+ * a re-register dance instead of open-coding.
907+ */
908+ ceph_osdc_get_request (req );
909+ if (!list_empty (& req -> r_linger_item ))
910+ __unregister_linger_request (osdc , req );
911+ else
912+ __unregister_request (osdc , req );
913+ __register_request (osdc , req );
914+ ceph_osdc_put_request (req );
915+
916+ /*
917+ * Unless request has been registered as both normal and
918+ * lingering, __unregister{,_linger}_request clears r_osd.
919+ * However, here we need to preserve r_osd to make sure we
920+ * requeue on the same OSD.
921+ */
922+ WARN_ON (req -> r_osd || !osd );
923+ req -> r_osd = osd ;
924+
925+ dout ("%s requeueing %p tid %llu\n" , __func__ , req , req -> r_tid );
926+ __enqueue_request (req );
927+ }
928+
895929/*
896930 * Resubmit requests pending on the given osd.
897931 */
@@ -900,12 +934,14 @@ static void __kick_osd_requests(struct ceph_osd_client *osdc,
900934{
901935 struct ceph_osd_request * req , * nreq ;
902936 LIST_HEAD (resend );
937+ LIST_HEAD (resend_linger );
903938 int err ;
904939
905- dout ("__kick_osd_requests osd%d\n" , osd -> o_osd );
940+ dout ("%s osd%d\n" , __func__ , osd -> o_osd );
906941 err = __reset_osd (osdc , osd );
907942 if (err )
908943 return ;
944+
909945 /*
910946 * Build up a list of requests to resend by traversing the
911947 * osd's list of requests. Requests for a given object are
@@ -926,33 +962,32 @@ static void __kick_osd_requests(struct ceph_osd_client *osdc,
926962 list_for_each_entry (req , & osd -> o_requests , r_osd_item ) {
927963 if (!req -> r_sent )
928964 break ;
929- list_move_tail (& req -> r_req_lru_item , & resend );
930- dout ("requeueing %p tid %llu osd%d\n" , req , req -> r_tid ,
931- osd -> o_osd );
932- if (!req -> r_linger )
965+
966+ if (!req -> r_linger ) {
967+ dout ("%s requeueing %p tid %llu\n" , __func__ , req ,
968+ req -> r_tid );
969+ list_move_tail (& req -> r_req_lru_item , & resend );
933970 req -> r_flags |= CEPH_OSD_FLAG_RETRY ;
971+ } else {
972+ list_move_tail (& req -> r_req_lru_item , & resend_linger );
973+ }
934974 }
935975 list_splice (& resend , & osdc -> req_unsent );
936976
937977 /*
938- * Linger requests are re-registered before sending, which
939- * sets up a new tid for each. We add them to the unsent
940- * list at the end to keep things in tid order.
978+ * Both registered and not yet registered linger requests are
979+ * enqueued with a new tid on the same OSD. We add/move them
980+ * to req_unsent/o_requests at the end to keep things in tid
981+ * order.
941982 */
942983 list_for_each_entry_safe (req , nreq , & osd -> o_linger_requests ,
943984 r_linger_osd_item ) {
944- /*
945- * reregister request prior to unregistering linger so
946- * that r_osd is preserved.
947- */
948- BUG_ON (!list_empty (& req -> r_req_lru_item ));
949- __register_request (osdc , req );
950- list_add_tail (& req -> r_req_lru_item , & osdc -> req_unsent );
951- list_add_tail (& req -> r_osd_item , & req -> r_osd -> o_requests );
952- __unregister_linger_request (osdc , req );
953- dout ("requeued lingering %p tid %llu osd%d\n" , req , req -> r_tid ,
954- osd -> o_osd );
985+ WARN_ON (!list_empty (& req -> r_req_lru_item ));
986+ __kick_linger_request (req );
955987 }
988+
989+ list_for_each_entry_safe (req , nreq , & resend_linger , r_req_lru_item )
990+ __kick_linger_request (req );
956991}
957992
958993/*
0 commit comments