+static blk_status_t nbd_send_pending_cmd(struct nbd_device *nbd,
+ struct nbd_cmd *cmd)
+{
+ struct request *req = blk_mq_rq_from_pdu(cmd);
+ unsigned long deadline = READ_ONCE(req->deadline);
+ unsigned int wait_ms = 2;
+ blk_status_t res;
+
+ WARN_ON_ONCE(test_bit(NBD_CMD_REQUEUED, &cmd->flags));
+
+ while (true) {
+ res = nbd_send_cmd(nbd, cmd, cmd->index);
+ if (res != BLK_STS_RESOURCE)
+ return res;
+ if (READ_ONCE(jiffies) + msecs_to_jiffies(wait_ms) >= deadline)
+ break;
+ msleep(wait_ms);
+ wait_ms *= 2;
+ }