Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3427e854 authored by Andy Grover's avatar Andy Grover
Browse files

RDS: Assume recv->r_frag is always NULL in refill_one()



refill_one() should never be called on a recv struct that
doesn't need a new r_frag allocated. Add a WARN and remove
conditional around r_frag alloc code.

Also, add a comment to explain why r_ibinc may or may not
need refilling.

Signed-off-by: default avatarAndy Grover <andy.grover@oracle.com>
parent 0b088e00
Loading
Loading
Loading
Loading
+16 −13
Original line number Diff line number Diff line
@@ -126,6 +126,10 @@ static int rds_ib_recv_refill_one(struct rds_connection *conn,
	struct ib_sge *sge;
	int ret = -ENOMEM;

	/*
	 * ibinc was taken from recv if recv contained the start of a message.
	 * recvs that were continuations will still have this allocated.
	 */
	if (!recv->r_ibinc) {
		if (!atomic_add_unless(&rds_ib_allocation, 1, rds_ib_sysctl_max_recv_allocation)) {
			rds_ib_stats_inc(s_ib_rx_alloc_limit);
@@ -140,7 +144,7 @@ static int rds_ib_recv_refill_one(struct rds_connection *conn,
		rds_inc_init(&recv->r_ibinc->ii_inc, conn, conn->c_faddr);
	}

	if (!recv->r_frag) {
	WARN_ON(recv->r_frag); /* leak! */
	recv->r_frag = kmem_cache_alloc(rds_ib_frag_slab, GFP_NOWAIT);
	if (!recv->r_frag)
		goto out;
@@ -153,7 +157,6 @@ static int rds_ib_recv_refill_one(struct rds_connection *conn,
		recv->r_frag = NULL;
		goto out;
	}
	}

	ret = ib_dma_map_sg(ic->i_cm_id->device, &recv->r_frag->f_sg,
			    1, DMA_FROM_DEVICE);