[LU-5956] o2iblnd: incorrect uses of kib_tx_t::tx_nfrags Created: 25/Nov/14  Updated: 01/Jul/16  Resolved: 10/Jul/15

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.8.0

Type: Bug Priority: Minor
Reporter: Isaac Huang (Inactive) Assignee: Isaac Huang (Inactive)
Resolution: Fixed Votes: 0
Labels: lnet

Issue Links:
Related
Severity: 3
Rank (Obsolete): 16635

 Description   
      665 kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx,
......
      677         tx->tx_nfrags = nfrags;
      678 
      679         rd->rd_nfrags =                                                                                                                                                                                                                              
      680                 kiblnd_dma_map_sg(hdev->ibh_ibdev,
      681                                   tx->tx_frags, tx->tx_nfrags, tx->tx_dmadir);

As dma_map_sg() can return fewer entries in the mapped SG list, it may happen that "rd->rd_nfrags < tx->tx_nfrags". But the code seemed to assume "rd->rd_nfrags == tx->tx_nfrags":

642 kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx)
658                 kiblnd_dma_unmap_sg(tx->tx_pool->tpo_hdev->ibh_ibdev,
659                                     tx->tx_frags, tx->tx_nfrags, tx->tx_dmadir);

1474 kiblnd_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
1550                 nob = offsetof(kib_get_msg_t, ibgm_rd.rd_frags[tx->tx_nfrags]);

1707 kiblnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
1788                 nob = offsetof(kib_putack_msg_t, ibpam_rd.rd_frags[tx->tx_nfrags]);

It seemed that the # original SG entries is not needed anywhere in the code, so it can be fixed by assigning the # mapped SG entries to kib_tx_t::tx_nfrags.



 Comments   
Comment by Gerrit Updater [ 25/Nov/14 ]

Isaac Huang (he.huang@intel.com) uploaded a new patch: http://review.whamcloud.com/12857
Subject: LU-5956 o2iblnd: incorrect uses of kib_tx_t::tx_nfrags
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: e06ac14a307056759d2c1dc91035ef059f855512

Comment by Isaac Huang (Inactive) [ 05/Jan/15 ]

Liang pointed out:
The 'nents' argument to the dma_unmap_sg call must be the same one you passed into the dma_map_sg call, it should NOT be the 'count' value returned from the dma_map_sg call.

So, kib_tx_t::tx_nfrags should still be kept intact, while kiblnd_send/kiblnd_recv should be fixed to use # mapped entries instead.

Comment by Gerrit Updater [ 10/Jul/15 ]

Oleg Drokin (oleg.drokin@intel.com) merged in patch http://review.whamcloud.com/12857/
Subject: LU-5956 o2iblnd: wrong uses of kib_tx_t::tx_nfrags
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 592e3d2ff84899cfe70d06d4ae2217a8659c0f8a

Comment by Peter Jones [ 10/Jul/15 ]

Landed for 2.8

Comment by Gerrit Updater [ 11/Dec/15 ]

Doug Oucharek (doug.s.oucharek@intel.com) uploaded a new patch: http://review.whamcloud.com/17558
Subject: LU-5956 o2iblnd: wrong uses of kib_tx_t::tx_nfrags
Project: fs/lustre-release
Branch: b1_8
Current Patch Set: 1
Commit: c947aaf5e15f776ba54492a961178bbd98f636e7

Generated at Sat Feb 10 01:55:58 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.