volser: ensure GCTrans transaction walk remains valid
Commit
bc56f5cc97a982ee29219e6f258b372dbfe1a020 ("volser: Delete
timed-out temporary volumes") introduced new logic to GCTrans().
Unfortunately, part of this logic temporarily drops VTRANS_LOCK in order
to call VPurgeVolume(). While this lock is dropped, other volser_trans
may be added or deleted from the allTrans list. Therefore, GCTrans
should not trust the next pointer (nt = tt->next) which was obtained
before the lock was dropped.
One symptom observed in the field was a segfault while examining
tt->volume. Neither tt nor volume were valid any longer, since tt had
been set from a stale nt at the top of the loop.
To repair, improve, and clarify this logic:
- Refactor so nt is assigned correctly and as late as possible.
- Add comments to explain the placement of the assigns to future
maintainers.
Change-Id: Ibd3a504bddd3622730aa349576341e20f2f27836
Reviewed-on: https://gerrit.openafs.org/13286
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>