/* searching for a noop tx in free list */
spin_lock(&ksocknal_data.ksnd_tx_lock);
- if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) {
- tx = list_entry(ksocknal_data.ksnd_idle_noop_txs.next,
- struct ksock_tx, tx_list);
+ tx = list_first_entry_or_null(&ksocknal_data.ksnd_idle_noop_txs,
+ struct ksock_tx, tx_list);
+ if (tx) {
LASSERT(tx->tx_desc_size == size);
list_del(&tx->tx_list);
}
{
struct ksock_tx *tx;
- while (!list_empty(txlist)) {
- tx = list_entry(txlist->next, struct ksock_tx, tx_list);
-
+ while ((tx = list_first_entry_or_null(txlist, struct ksock_tx,
+ tx_list)) != NULL) {
if (error && tx->tx_lnetmsg != NULL) {
CNETERR("Deleting packet type %d len %d %s->%s\n",
le32_to_cpu(tx->tx_lnetmsg->msg_hdr.type),
bool did_something = false;
/* Ensure I progress everything semi-fairly */
-
- if (!list_empty(&sched->kss_rx_conns)) {
- conn = list_entry(sched->kss_rx_conns.next,
- struct ksock_conn, ksnc_rx_list);
+ conn = list_first_entry_or_null(&sched->kss_rx_conns,
+ struct ksock_conn,
+ ksnc_rx_list);
+ if (conn) {
list_del(&conn->ksnc_rx_list);
LASSERT(conn->ksnc_rx_scheduled);
list_splice_init(&sched->kss_zombie_noop_txs, &zlist);
- conn = list_entry(sched->kss_tx_conns.next,
- struct ksock_conn, ksnc_tx_list);
+ conn = list_first_entry(&sched->kss_tx_conns,
+ struct ksock_conn,
+ ksnc_tx_list);
list_del(&conn->ksnc_tx_list);
LASSERT(conn->ksnc_tx_scheduled);
LASSERT(conn->ksnc_tx_ready);
LASSERT(!list_empty(&conn->ksnc_tx_queue));
- tx = list_entry(conn->ksnc_tx_queue.next,
- struct ksock_tx, tx_list);
+ tx = list_first_entry(&conn->ksnc_tx_queue,
+ struct ksock_tx, tx_list);
if (conn->ksnc_tx_carrier == tx)
ksocknal_next_tx_carrier(conn);
/* ksnp_tx_queue is queued on a conn on successful
* connection for V1.x and V2.x
*/
- if (!list_empty(&peer_ni->ksnp_conns)) {
- conn = list_entry(peer_ni->ksnp_conns.next,
- struct ksock_conn, ksnc_list);
+ conn = list_first_entry_or_null(&peer_ni->ksnp_conns,
+ struct ksock_conn, ksnc_list);
+ if (conn)
LASSERT(conn->ksnc_proto == &ksocknal_protocol_v3x);
- }
/* take all the blocked packets while I've got the lock and
* complete below...
dropped_lock = true;
}
- if (!list_empty(&ksocknal_data.ksnd_connd_connreqs)) {
+ cr = list_first_entry_or_null(&ksocknal_data.ksnd_connd_connreqs,
+ struct ksock_connreq, ksncr_list);
+ if (cr) {
/* Connection accepted by the listener */
- cr = list_entry(ksocknal_data.ksnd_connd_connreqs.next,
- struct ksock_connreq, ksncr_list);
-
list_del(&cr->ksncr_list);
spin_unlock_bh(connd_lock);
dropped_lock = true;
write_lock_bh(&ksocknal_data.ksnd_global_lock);
- while (!list_empty(&peer_ni->ksnp_tx_queue)) {
- tx = list_entry(peer_ni->ksnp_tx_queue.next,
- struct ksock_tx, tx_list);
-
+ while ((tx = list_first_entry_or_null(&peer_ni->ksnp_tx_queue,
+ struct ksock_tx,
+ tx_list)) != NULL) {
if (ktime_get_seconds() < tx->tx_deadline)
break;
/* we can't process stale txs right here because we're
* holding only shared lock
*/
- if (!list_empty(&peer_ni->ksnp_tx_queue)) {
- struct ksock_tx *tx;
-
- tx = list_entry(peer_ni->ksnp_tx_queue.next,
- struct ksock_tx, tx_list);
- if (ktime_get_seconds() >= tx->tx_deadline) {
- ksocknal_peer_addref(peer_ni);
- read_unlock(&ksocknal_data.ksnd_global_lock);
+ tx = list_first_entry_or_null(&peer_ni->ksnp_tx_queue,
+ struct ksock_tx, tx_list);
+ if (tx && ktime_get_seconds() >= tx->tx_deadline) {
+ ksocknal_peer_addref(peer_ni);
+ read_unlock(&ksocknal_data.ksnd_global_lock);
- ksocknal_flush_stale_txs(peer_ni);
+ ksocknal_flush_stale_txs(peer_ni);
- ksocknal_peer_decref(peer_ni);
- goto again;
- }
+ ksocknal_peer_decref(peer_ni);
+ goto again;
}
if (list_empty(&peer_ni->ksnp_zc_req_list))
spin_lock_bh(&ksocknal_data.ksnd_reaper_lock);
while (!ksocknal_data.ksnd_shuttingdown) {
- if (!list_empty(&ksocknal_data.ksnd_deathrow_conns)) {
- conn = list_entry(ksocknal_data.ksnd_deathrow_conns.next,
- struct ksock_conn, ksnc_list);
+ conn = list_first_entry_or_null(&ksocknal_data.ksnd_deathrow_conns,
+ struct ksock_conn, ksnc_list);
+ if (conn) {
list_del(&conn->ksnc_list);
spin_unlock_bh(&ksocknal_data.ksnd_reaper_lock);
continue;
}
- if (!list_empty(&ksocknal_data.ksnd_zombie_conns)) {
- conn = list_entry(ksocknal_data.ksnd_zombie_conns.next,
- struct ksock_conn, ksnc_list);
+ conn = list_first_entry_or_null(&ksocknal_data.ksnd_zombie_conns,
+ struct ksock_conn, ksnc_list);
+ if (conn) {
list_del(&conn->ksnc_list);
spin_unlock_bh(&ksocknal_data.ksnd_reaper_lock);
/* reschedule all the connections that stalled with ENOMEM... */
nenomem_conns = 0;
- while (!list_empty(&enomem_conns)) {
- conn = list_entry(enomem_conns.next,
- struct ksock_conn, ksnc_tx_list);
+ while ((conn = list_first_entry_or_null(&enomem_conns,
+ struct ksock_conn,
+ ksnc_tx_list)) != NULL) {
list_del(&conn->ksnc_tx_list);
sched = conn->ksnc_scheduler;