RDMA/mlx5: Fix corruption of reg_pages in mlx5_ib_rereg_user_mr()
authorJason Gunthorpe <jgg@nvidia.com>
Mon, 26 Oct 2020 13:19:31 +0000 (15:19 +0200)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 2 Nov 2020 18:31:40 +0000 (14:31 -0400)
commitfc3325701a6353594083f08e297d4c1965c601aa
tree40b15b7294d5b61a7eced753cb2913f8c7ce7d29
parentb4d031cdae1301a8e5e9dba2a862ef028717cb17
RDMA/mlx5: Fix corruption of reg_pages in mlx5_ib_rereg_user_mr()

reg_pages should always contain mr->npage since when the mr is finally
de-reg'd it is always subtracted out.

If there were any error exits then mlx5_ib_rereg_user_mr() would leave the
reg_pages adjusted and this will cause it to be double subtracted
eventually.

The manipulation of reg_pages is inherently connected to the umem, so lift
it out of set_mr_fields() and only adjust it around creating/destroying a
umem.

reg_pages is only used for diagnostics in sysfs.

Fixes: 7d0cc6edcc70 ("IB/mlx5: Add MR cache for large UMR regions")
Link: https://lore.kernel.org/r/20201026131936.1335664-3-leon@kernel.org
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/mlx5/mr.c