Skip to content

Commit 345c3a5

Browse files
devesh28vijay-suman
authored andcommitted
net/rds: report pending-messages count in RDS_INQ response
RDS_CMSG_INQ response reports number of pending-bytes in the receive queue. Exadata is using the RDS interface for zero-byte messages. As such, it is preferred to change the semantics of RDS_INQ to number of messages, instead of number of bytes. Making a change to actively maintain a count of receive queue entries yet to be processed. Whenever application tries to seek the pending receive queue entries via recvmsg(), this count is read and returned as a response. This counter is increamented when a new entry is queued to the rs_recv_queue in rds_recv_incoming() while it is decremented as soon as any message is pulled out of the receive queue via rds_still_queued(). Orabug: 35596049 Fixes: 89027a3334fc ("Introduce RDS-INQ feature to RDS protocol”) Signed-off-by: Devesh Sharma <[email protected]> Reviewed-by: Håkon Bugge <[email protected]> Reviewed-by: Gerd Rausch <[email protected]>
1 parent 2beb6ea commit 345c3a5

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

net/rds/rds.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,11 @@ struct rds_sock {
906906
rwlock_t rs_recv_lock;
907907
int rs_rcv_bytes;
908908
struct list_head rs_recv_queue;
909+
/*
910+
* rs_recv_pending actively counts the yet-to-be-processed
911+
* entried in the rs_recv_queue queue
912+
*/
913+
int rs_recv_pending;
909914

910915
/* just for stats reporting */
911916
struct list_head rs_item;

net/rds/recv.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ void rds_recv_incoming(struct rds_connection *conn, struct in6_addr *saddr,
495495
}
496496
rds_inc_addref(inc);
497497
list_add_tail(&inc->i_item, &rs->rs_recv_queue);
498+
/* New entry to receive queue, increment pending */
499+
rs->rs_recv_pending++;
498500
inc->i_rx_lat_trace[RDS_MSG_RX_END] = local_clock();
499501
__rds_wake_sk_sleep(sk);
500502
}
@@ -554,6 +556,8 @@ static int rds_still_queued(struct rds_sock *rs, struct rds_incoming *inc,
554556
-be32_to_cpu(inc->i_hdr.h_len),
555557
inc->i_hdr.h_dport);
556558
list_del_init(&inc->i_item);
559+
/* Pulled a pending entry, decrement the count */
560+
rs->rs_recv_pending--;
557561
rds_inc_put(inc);
558562
}
559563
}
@@ -711,13 +715,13 @@ static int rds_cmsg_recv(struct rds_incoming *inc, struct msghdr *msg,
711715

712716
if (rs->rs_inq) {
713717
unsigned long flags;
714-
int rcv_bytes;
718+
int r_count;
715719

716720
read_lock_irqsave(&rs->rs_recv_lock, flags);
717-
rcv_bytes = rs->rs_rcv_bytes;
718-
ret = put_cmsg(msg, SOL_RDS, RDS_CMSG_INQ,
719-
sizeof(rcv_bytes), &rcv_bytes);
721+
r_count = rs->rs_recv_pending;
720722
read_unlock_irqrestore(&rs->rs_recv_lock, flags);
723+
ret = put_cmsg(msg, SOL_RDS, RDS_CMSG_INQ,
724+
sizeof(r_count), &r_count);
721725
if (ret)
722726
goto out;
723727
}
@@ -864,6 +868,8 @@ void rds_clear_recv_queue(struct rds_sock *rs)
864868
-be32_to_cpu(inc->i_hdr.h_len),
865869
inc->i_hdr.h_dport);
866870
list_del_init(&inc->i_item);
871+
/* Entry deleted, decrement the counter */
872+
rs->rs_recv_pending--;
867873
rds_inc_put(inc);
868874
}
869875
write_unlock_irqrestore(&rs->rs_recv_lock, flags);

0 commit comments

Comments
 (0)