diff options
author | Jonathan Lallinger <jonathan@ogc.us> | 2011-09-29 03:58:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-09-29 14:57:19 -0400 |
commit | 85a64889492b45f931ddac87ec09d84aa7347ee1 (patch) | |
tree | 1ceadcb10339e74551d6cb2ff6a09fcc83433655 /net | |
parent | 605b91c8f619047ed6d88e24c531d4bdddad46f4 (diff) |
RDSRDMA: Fix cleanup of rds_iw_mr_pool
In the rds_iw_mr_pool struct the free_pinned field keeps track of
memory pinned by free MRs. While this field is incremented properly
upon allocation, it is never decremented upon unmapping. This would
cause the rds_rdma module to crash the kernel upon unloading, by
triggering the BUG_ON in the rds_iw_destroy_mr_pool function.
This change keeps track of the MRs that become unpinned, so that
free_pinned can be decremented appropriately.
Signed-off-by: Jonathan Lallinger <jonathan@ogc.us>
Signed-off-by: Steve Wise <swise@ogc.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/rds/iw_rdma.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/net/rds/iw_rdma.c b/net/rds/iw_rdma.c index 8b77edbab272..4e1de171866c 100644 --- a/net/rds/iw_rdma.c +++ b/net/rds/iw_rdma.c | |||
@@ -84,7 +84,8 @@ static int rds_iw_map_fastreg(struct rds_iw_mr_pool *pool, | |||
84 | static void rds_iw_free_fastreg(struct rds_iw_mr_pool *pool, struct rds_iw_mr *ibmr); | 84 | static void rds_iw_free_fastreg(struct rds_iw_mr_pool *pool, struct rds_iw_mr *ibmr); |
85 | static unsigned int rds_iw_unmap_fastreg_list(struct rds_iw_mr_pool *pool, | 85 | static unsigned int rds_iw_unmap_fastreg_list(struct rds_iw_mr_pool *pool, |
86 | struct list_head *unmap_list, | 86 | struct list_head *unmap_list, |
87 | struct list_head *kill_list); | 87 | struct list_head *kill_list, |
88 | int *unpinned); | ||
88 | static void rds_iw_destroy_fastreg(struct rds_iw_mr_pool *pool, struct rds_iw_mr *ibmr); | 89 | static void rds_iw_destroy_fastreg(struct rds_iw_mr_pool *pool, struct rds_iw_mr *ibmr); |
89 | 90 | ||
90 | static int rds_iw_get_device(struct rds_sock *rs, struct rds_iw_device **rds_iwdev, struct rdma_cm_id **cm_id) | 91 | static int rds_iw_get_device(struct rds_sock *rs, struct rds_iw_device **rds_iwdev, struct rdma_cm_id **cm_id) |
@@ -499,7 +500,7 @@ static int rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all) | |||
499 | LIST_HEAD(unmap_list); | 500 | LIST_HEAD(unmap_list); |
500 | LIST_HEAD(kill_list); | 501 | LIST_HEAD(kill_list); |
501 | unsigned long flags; | 502 | unsigned long flags; |
502 | unsigned int nfreed = 0, ncleaned = 0, free_goal; | 503 | unsigned int nfreed = 0, ncleaned = 0, unpinned = 0, free_goal; |
503 | int ret = 0; | 504 | int ret = 0; |
504 | 505 | ||
505 | rds_iw_stats_inc(s_iw_rdma_mr_pool_flush); | 506 | rds_iw_stats_inc(s_iw_rdma_mr_pool_flush); |
@@ -524,7 +525,8 @@ static int rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all) | |||
524 | * will be destroyed by the unmap function. | 525 | * will be destroyed by the unmap function. |
525 | */ | 526 | */ |
526 | if (!list_empty(&unmap_list)) { | 527 | if (!list_empty(&unmap_list)) { |
527 | ncleaned = rds_iw_unmap_fastreg_list(pool, &unmap_list, &kill_list); | 528 | ncleaned = rds_iw_unmap_fastreg_list(pool, &unmap_list, |
529 | &kill_list, &unpinned); | ||
528 | /* If we've been asked to destroy all MRs, move those | 530 | /* If we've been asked to destroy all MRs, move those |
529 | * that were simply cleaned to the kill list */ | 531 | * that were simply cleaned to the kill list */ |
530 | if (free_all) | 532 | if (free_all) |
@@ -548,6 +550,7 @@ static int rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all) | |||
548 | spin_unlock_irqrestore(&pool->list_lock, flags); | 550 | spin_unlock_irqrestore(&pool->list_lock, flags); |
549 | } | 551 | } |
550 | 552 | ||
553 | atomic_sub(unpinned, &pool->free_pinned); | ||
551 | atomic_sub(ncleaned, &pool->dirty_count); | 554 | atomic_sub(ncleaned, &pool->dirty_count); |
552 | atomic_sub(nfreed, &pool->item_count); | 555 | atomic_sub(nfreed, &pool->item_count); |
553 | 556 | ||
@@ -828,7 +831,8 @@ static void rds_iw_free_fastreg(struct rds_iw_mr_pool *pool, | |||
828 | 831 | ||
829 | static unsigned int rds_iw_unmap_fastreg_list(struct rds_iw_mr_pool *pool, | 832 | static unsigned int rds_iw_unmap_fastreg_list(struct rds_iw_mr_pool *pool, |
830 | struct list_head *unmap_list, | 833 | struct list_head *unmap_list, |
831 | struct list_head *kill_list) | 834 | struct list_head *kill_list, |
835 | int *unpinned) | ||
832 | { | 836 | { |
833 | struct rds_iw_mapping *mapping, *next; | 837 | struct rds_iw_mapping *mapping, *next; |
834 | unsigned int ncleaned = 0; | 838 | unsigned int ncleaned = 0; |
@@ -855,6 +859,7 @@ static unsigned int rds_iw_unmap_fastreg_list(struct rds_iw_mr_pool *pool, | |||
855 | 859 | ||
856 | spin_lock_irqsave(&pool->list_lock, flags); | 860 | spin_lock_irqsave(&pool->list_lock, flags); |
857 | list_for_each_entry_safe(mapping, next, unmap_list, m_list) { | 861 | list_for_each_entry_safe(mapping, next, unmap_list, m_list) { |
862 | *unpinned += mapping->m_sg.len; | ||
858 | list_move(&mapping->m_list, &laundered); | 863 | list_move(&mapping->m_list, &laundered); |
859 | ncleaned++; | 864 | ncleaned++; |
860 | } | 865 | } |