dm-mpath: Track invalid map_context
PATCH 1/1 dm-mpath: Track invalid map_context
The map_context pointer should always be set. However, we have reports that upon requeing it is not set correctly. So add a BUG_ON() statement and clear the pointer to track the issue properly.
--- drivers/md/dm-mpath.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/md/dm-mpath.c +5 -1
@@ -920,8 +920,10 @@ static int multipath_map(struct dm_target *ti, struct request *clone, map_context->ptr = mpio; clone->cmd_flags |=REQ_FAILFAST_TRANSPORT ; r =map_io (m, clone, mpio,0 ); -if (r <0 || r ==DM_MAPIO_REQUEUE ) +if (r <0 || r ==DM_MAPIO_REQUEUE ) {mempool_free (mpio, m->mpio_pool); + map_context->ptr =NULL ; + }return r; }
@@ -1228,6 +1230,8 @@ static int do_end_io(struct multipath *m, struct request *clone,int r =DM_ENDIO_REQUEUE ;unsigned long flags; +BUG_ON (!mpio); +if (!error && !clone->errors)return 0 ;/* I/O complete */
Signature · 1 line
1.6.0.2
Alasdair G Kergon
maintainerdrivers/md/dm-mpath.c static int multipath_map(struct dm_target *ti, struct request *clone, · line 926
Quoted 5 lines · Hannes Reinecke
drivers/md/dm-mpath.c +3
-1-if (r <0 || r ==DM_MAPIO_REQUEUE ) +if (r <0 || r ==DM_MAPIO_REQUEUE ) {mempool_free (mpio, m->mpio_pool); + map_context->ptr =NULL ; + }
What about the other places that do mempool_free() ? Should they clear it too?
Is it better to swap the statement order - clear it *before* freeing i
Alasdair
Quoted 10 lines · Alasdair G Kergon
drivers/md/dm-mpath.c static int multipath_map(struct dm_target *ti, struct request *clone, · line 926
Quoted 5 lines · Hannes Reinecke
drivers/md/dm-mpath.c +3
-1-if (r <0 || r ==DM_MAPIO_REQUEUE ) +if (r <0 || r ==DM_MAPIO_REQUEUE ) {mempool_free (mpio, m->mpio_pool); + map_context->ptr =NULL ; + }What about the other places that do
mempool_free()? Should they clear it too?
Hmm. Probably. It's not strictly speaking required as the other places will never re-use the context pointer.
But for consistencies sake you are correct.
Will be updating the patch.
Quoted 3 lines
Is it better to swap the statement order - clear it *before* freeing i
Doubt that should be required.
I would hope that the map_context pointer is protected by appropriate locks.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)