[rds-commits] zab commits r87 - trunk/linux/net/rds

svn-commits@oss.oracle.com svn-commits at oss.oracle.com
Wed May 31 16:36:53 CDT 2006


Author: zab
Date: 2006-05-31 16:36:50 -0500 (Wed, 31 May 2006)
New Revision: 87

Modified:
   trunk/linux/net/rds/ack.c
   trunk/linux/net/rds/loop.c
   trunk/linux/net/rds/message.c
   trunk/linux/net/rds/rds.h
   trunk/linux/net/rds/recv.c
   trunk/linux/net/rds/tcp_recv.c
   trunk/linux/net/rds/transport.c
Log:
Pass in kmap_atomic() types to match caller contexts, just like GFP flags.


Modified: trunk/linux/net/rds/ack.c
===================================================================
--- trunk/linux/net/rds/ack.c	2006-05-30 23:32:06 UTC (rev 86)
+++ trunk/linux/net/rds/ack.c	2006-05-31 21:36:50 UTC (rev 87)
@@ -23,16 +23,16 @@
 
 #include "rds.h"
 
-static void rds_ack_fill_header(struct rds_message *rm)
+static void rds_ack_fill_header(struct rds_message *rm, enum km_type km)
 {
 	struct rds_header *hdr;
 	struct page *page;
 
 	page = list_entry(rm->m_header_pages.next, struct page, lru);
-	hdr = kmap_atomic(page, KM_SOFTIRQ0);
+	hdr = kmap_atomic(page, km);
 	hdr->h_len = cpu_to_be16(rm->m_len);
 	rm->m_vecs[0].v_len = rm->m_len;
-	kunmap_atomic(hdr, KM_SOFTIRQ0);
+	kunmap_atomic(hdr, km);
 }
 
 /*
@@ -43,7 +43,7 @@
  * rather than adding a duplicate ack entry for it in the frame.
  */
 static void rds_ack_insert_entry(struct rds_message *rm, __be16 sport,
-				 __be16 dport, __be64 seq)
+				 __be16 dport, __be64 seq, enum km_type km)
 {
 	int cmp, nr, i, low, high;
         struct rds_ack_entry *array, *ent, key = {
@@ -52,7 +52,7 @@
 		.e_dport = dport,
 	};
 
-	array = kmap_atomic(rm->m_vecs[0].v_page, KM_SOFTIRQ0);
+	array = kmap_atomic(rm->m_vecs[0].v_page, km);
 
 	nr = rm->m_len / sizeof(struct rds_ack_entry);
 	low = 0;
@@ -93,7 +93,7 @@
 	*ent = key;
 	rm->m_len += sizeof(struct rds_ack_entry);
 out:
-	kunmap_atomic(array, KM_SOFTIRQ0);
+	kunmap_atomic(array, km);
 }
 
 /* 
@@ -102,12 +102,12 @@
  * the sender.  m_flow_item is left empty so that the ack message is dropped by
  * rds_send_reset_vec() after it is sent.
  */
-static void rds_ack_send(struct rds_connection *conn)
+static void rds_ack_send(struct rds_connection *conn, enum km_type km)
 {
 	assert_spin_locked(&conn->c_lock);
 
 	del_timer(&conn->c_ack_timer);
-	rds_ack_fill_header(conn->c_ack_rm);
+	rds_ack_fill_header(conn->c_ack_rm, km);
 	list_add_tail(&conn->c_ack_rm->m_conn_item, &conn->c_send_queue);
 	conn->c_trans->send_trigger(conn);
 	conn->c_ack_rm = NULL;
@@ -121,7 +121,7 @@
  * for the ack message then it asks the send path to keep trying until
  * it can.
  */
-void rds_ack_build(struct rds_connection *conn, gfp_t gfp)
+void rds_ack_build(struct rds_connection *conn, gfp_t gfp, enum km_type km)
 {
 	struct rds_incoming *inc, *tmp;
 	struct rds_message *rm, *my_rm = NULL;
@@ -134,7 +134,7 @@
 		if (conn->c_ack_rm == NULL) {
 			if (my_rm == NULL) {
 				spin_unlock_irqrestore(&conn->c_lock, flags);
-				my_rm = rds_message_alloc_ack(gfp);
+				my_rm = rds_message_alloc_ack(gfp, km);
 				if (my_rm == NULL) {
 					/* XXX tunable retry? */
 					conn->c_trans->send_trigger(conn);
@@ -156,10 +156,10 @@
 
 		rds_ack_insert_entry(rm, inc->i_hdr.h_sport,
 				     inc->i_hdr.h_dport,
-				     inc->i_hdr.h_sequence);
+				     inc->i_hdr.h_sequence, km);
 
 		if (rm->m_len == RDS_ACKS_PER_FRAG) {
-			rds_ack_send(conn);
+			rds_ack_send(conn, km);
 			fastpending = 0;
 		} else if (inc->i_hdr.h_flags & RDS_HEAD_FLAG_FASTACK)
 			fastpending = 1;
@@ -171,7 +171,7 @@
 
 	if (conn->c_ack_rm && 
 	    (fastpending || time_after_eq(jiffies, conn->c_ack_deadline)))
-		rds_ack_send(conn);
+		rds_ack_send(conn, km);
 
 	spin_unlock_irqrestore(&conn->c_lock, flags);
 out:
@@ -235,7 +235,7 @@
  * will only send acks for fragments once it's sure that it will never work
  * with the entire message again.
  */
-void rds_ack_queue_inc(struct rds_incoming *inc, gfp_t gfp)
+void rds_ack_queue_inc(struct rds_incoming *inc, gfp_t gfp, enum km_type km)
 {
 	struct rds_connection *conn = inc->i_conn;
 	unsigned long flags;
@@ -248,5 +248,5 @@
 
 	spin_unlock_irqrestore(&conn->c_lock, flags);
 
-	rds_ack_build(conn, gfp);
+	rds_ack_build(conn, gfp, km);
 }

Modified: trunk/linux/net/rds/loop.c
===================================================================
--- trunk/linux/net/rds/loop.c	2006-05-30 23:32:06 UTC (rev 86)
+++ trunk/linux/net/rds/loop.c	2006-05-31 21:36:50 UTC (rev 87)
@@ -40,7 +40,8 @@
  * we don't have to marshal the ack through messages, we can call the 
  * ack processing path directly.
  */
-static void rds_loop_ack_queue_inc(struct rds_incoming *inc, gfp_t gfp)
+static void rds_loop_ack_queue_inc(struct rds_incoming *inc, gfp_t gfp,
+				   enum km_type km)
 {
 	struct rds_ack_entry ent = {
 		.e_sport = inc->i_hdr.h_sport,
@@ -78,7 +79,7 @@
 		rds_message_addref(rm); /* for the inc */
 
 		rds_recv_incoming(conn, conn->c_laddr, conn->c_faddr,
-				 &rm->m_inc, GFP_KERNEL);
+				 &rm->m_inc, GFP_KERNEL, KM_USER0);
 
 		rds_inc_put(&rm->m_inc);
 		rds_send_put_next_message(conn, rm, 1);

Modified: trunk/linux/net/rds/message.c
===================================================================
--- trunk/linux/net/rds/message.c	2006-05-30 23:32:06 UTC (rev 86)
+++ trunk/linux/net/rds/message.c	2006-05-31 21:36:50 UTC (rev 87)
@@ -61,6 +61,10 @@
 	rds_message_put(rm);
 }
 
+/*
+ * The use of KM_USER0 here means that this can only be called from
+ * interruptible user context, rds_sendmsg() currently.
+ */
 void rds_message_populate_headers(struct rds_message *rm, __be16 sport,
 			          __be16 dport, u64 seq, int fastack)
 {
@@ -297,7 +301,7 @@
  * receive them normally but it results in some unused space in the
  * header.  Dunno if we care to make use of that, or not.
  */
-struct rds_message *rds_message_alloc_ack(gfp_t gfp)
+struct rds_message *rds_message_alloc_ack(gfp_t gfp, enum km_type km)
 {
 	struct rds_message *rm;
 	struct page *page;
@@ -322,10 +326,10 @@
 	rm->m_nr_vecs++;
 
 	page = list_entry(rm->m_header_pages.next, struct page, lru);
-	hdr = kmap_atomic(page, KM_USER0);
+	hdr = kmap_atomic(page, km);
 	memset(hdr, 0, sizeof(struct rds_header));
 	hdr->h_flags = RDS_HEAD_FLAG_ACK;
-	kunmap_atomic(hdr, KM_USER0);
+	kunmap_atomic(hdr, km);
 
 out:
 	return rm;

Modified: trunk/linux/net/rds/rds.h
===================================================================
--- trunk/linux/net/rds/rds.h	2006-05-30 23:32:06 UTC (rev 86)
+++ trunk/linux/net/rds/rds.h	2006-05-31 21:36:50 UTC (rev 87)
@@ -135,7 +135,8 @@
 	void (*inc_free)(struct rds_incoming *inc);
 	void (*inc_merge)(struct rds_incoming *dest, struct rds_incoming *src);
 	void (*listen_stop)(void);
-	void (*ack_queue_inc)(struct rds_incoming *inc, gfp_t gfp);
+	void (*ack_queue_inc)(struct rds_incoming *inc, gfp_t gfp,
+			      enum km_type km);
 };
 
 struct rds_sock {
@@ -194,11 +195,11 @@
 #endif /* KERNEL_HAS_PROTO_REGISTER */
 
 /* ack.c */
-void rds_ack_build(struct rds_connection *conn, gfp_t gfp);
+void rds_ack_build(struct rds_connection *conn, gfp_t gfp, enum km_type km);
 void rds_ack_timer(unsigned long data);
 void rds_ack_process(struct rds_connection *conn, struct rds_ack_entry *ent);
 void rds_ack_recv(struct rds_connection *conn, struct rds_incoming *inc);
-void rds_ack_queue_inc(struct rds_incoming *inc, gfp_t gfp);
+void rds_ack_queue_inc(struct rds_incoming *inc, gfp_t gfp, enum km_type km);
 
 /* af_rds.c */
 void rds_sock_addref(struct rds_sock *rs);
@@ -236,7 +237,7 @@
 int rds_message_inc_copy_to_user(struct rds_incoming *inc,
 				 struct iovec *first_iov, size_t size);
 void rds_message_inc_free(struct rds_incoming *inc);
-struct rds_message *rds_message_alloc_ack(gfp_t gfp);
+struct rds_message *rds_message_alloc_ack(gfp_t gfp, enum km_type km);
 void rds_message_addref(struct rds_message *rm);
 void rds_message_put(struct rds_message *rm);
 
@@ -244,9 +245,9 @@
 void rds_inc_init(struct rds_incoming *inc, struct rds_connection *conn);
 void rds_inc_addref(struct rds_incoming *inc);
 void rds_inc_put(struct rds_incoming *inc);
-void rds_inc_ack(struct rds_incoming *inc, gfp_t gfp);
+void rds_inc_ack(struct rds_incoming *inc, gfp_t gfp, enum km_type km);
 int rds_recv_incoming(struct rds_connection *conn, __be32 saddr, __be32 daddr,
-		      struct rds_incoming *inc, gfp_t gfp);
+		      struct rds_incoming *inc, gfp_t gfp, enum km_type km);
 int rds_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
 		size_t size, int msg_flags);
 void rds_clear_recv_queue(struct rds_sock *rs);

Modified: trunk/linux/net/rds/recv.c
===================================================================
--- trunk/linux/net/rds/recv.c	2006-05-30 23:32:06 UTC (rev 86)
+++ trunk/linux/net/rds/recv.c	2006-05-31 21:36:50 UTC (rev 87)
@@ -50,9 +50,9 @@
  * This little helper is sure to get the trans ref via a safe path since we
  * know we have the inc when we want to ack it.
  */
-void rds_inc_ack(struct rds_incoming *inc, gfp_t gfp)
+void rds_inc_ack(struct rds_incoming *inc, gfp_t gfp, enum km_type km)
 {
-	inc->i_conn->c_trans->ack_queue_inc(inc, gfp);
+	inc->i_conn->c_trans->ack_queue_inc(inc, gfp, km);
 }
 
 /*
@@ -72,7 +72,7 @@
  * tell us which roles the addrs in the conn are playing for this message.
  */
 int rds_recv_incoming(struct rds_connection *conn, __be32 saddr, __be32 daddr,
-		      struct rds_incoming *inc, gfp_t gfp)
+		      struct rds_incoming *inc, gfp_t gfp, enum km_type km)
 {
 	int is_eom = inc->i_hdr.h_flags & RDS_HEAD_FLAG_EOM;
 	int is_frag = inc->i_hdr.h_flags & RDS_HEAD_FLAG_FRAG;
@@ -181,7 +181,7 @@
 	if (rs)
 		rds_sock_put(rs);
 	if (ack)
-		rds_inc_ack(inc, gfp);
+		rds_inc_ack(inc, gfp, km);
 	return ret;
 }
 
@@ -226,7 +226,7 @@
 	write_unlock_irqrestore(&sk->sk_callback_lock, flags);
 
 	if (ret && drop)
-		rds_inc_ack(inc, GFP_KERNEL);
+		rds_inc_ack(inc, GFP_KERNEL, KM_USER0);
 
 	pr_debug("inc %p rs %p still %d dropped %d\n", inc, rs, ret, drop);
 	return ret;
@@ -320,7 +320,7 @@
 
 	list_for_each_entry_safe(inc, tmp, &rs->rs_recv_queue, i_item) {
 		list_del_init(&inc->i_item);
-		rds_inc_ack(inc, GFP_KERNEL);
+		rds_inc_ack(inc, GFP_KERNEL, KM_USER0);
 		rds_inc_put(inc);
 	}
 }

Modified: trunk/linux/net/rds/tcp_recv.c
===================================================================
--- trunk/linux/net/rds/tcp_recv.c	2006-05-30 23:32:06 UTC (rev 86)
+++ trunk/linux/net/rds/tcp_recv.c	2006-05-31 21:36:50 UTC (rev 87)
@@ -141,6 +141,7 @@
 struct rds_tcp_desc_arg {
 	struct rds_tcp_connection *tc;
 	gfp_t gfp;
+	enum km_type km;
 };
 
 static int rds_tcp_data_recv(read_descriptor_t *desc, struct sk_buff *skb,
@@ -223,7 +224,7 @@
 						tc->t_conn->c_faddr,
 						tc->t_conn->c_laddr,
 						&tinc->ti_inc,
-						arg->gfp);
+						arg->gfp, arg->km);
 			if (ret) {
 				desc->error = ret;
 				goto out;
@@ -243,7 +244,7 @@
 }
 
 /* the caller has to hold the sock lock */
-int rds_tcp_recv(struct rds_tcp_connection *tc, gfp_t gfp)
+int rds_tcp_recv(struct rds_tcp_connection *tc, gfp_t gfp, enum km_type km)
 {
 	struct socket *sock = tc->t_sock;
 	read_descriptor_t desc;
@@ -255,6 +256,7 @@
 	/* It's like glib in the kernel! */
 	arg.tc = tc;
 	arg.gfp = gfp;
+	arg.km = km;
 	desc.arg.data = &arg;
 	desc.error = 0;
 	desc.count = 1; /* give more than one skb per call */
@@ -282,7 +284,7 @@
 
 	if (sock && tc->t_conn) {
 		lock_sock(sock->sk);
-		if (rds_tcp_recv(tc, GFP_KERNEL) == -ENOMEM) {
+		if (rds_tcp_recv(tc, GFP_KERNEL, KM_USER0) == -ENOMEM) {
 			/* XXX up some stat.. */
 			queue_delayed_work(rds_tcp_wq, &tc->t_recv_work, 2);
 		}
@@ -304,7 +306,7 @@
 		goto out;
 	}
 	ready = tc->t_orig_data_ready;
-	if (rds_tcp_recv(tc, GFP_ATOMIC) == -ENOMEM)
+	if (rds_tcp_recv(tc, GFP_ATOMIC, KM_SOFTIRQ0) == -ENOMEM)
 		queue_work(rds_tcp_wq, &tc->t_recv_work);
 out:
 	read_unlock(&sk->sk_callback_lock);

Modified: trunk/linux/net/rds/transport.c
===================================================================
--- trunk/linux/net/rds/transport.c	2006-05-30 23:32:06 UTC (rev 86)
+++ trunk/linux/net/rds/transport.c	2006-05-31 21:36:50 UTC (rev 87)
@@ -41,7 +41,7 @@
 	}
 
 	/* this can kick send again if allocation fails */
-	rds_ack_build(conn, GFP_KERNEL);
+	rds_ack_build(conn, GFP_KERNEL, KM_USER0);
 
 	/* we have little choice but to retry if we're low on memory */
 	if (conn->c_trans->send(conn) == -ENOMEM)




More information about the rds-commits mailing list