Skip to content

Commit

Permalink
PWX-36522: In case of devices use Exact match with mount and not a pr…
Browse files Browse the repository at this point in the history
…efix match (#2431) (#2432)

Signed-off-by: pnookala-px <[email protected]>
  • Loading branch information
pnookala-px authored Mar 21, 2024
1 parent f53f4f9 commit 68b72fc
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkg/mount/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func (m *Mounter) reload(device string, newM *Info) error {
}

// Purge old mounts.
logrus.Infof("Reload: Adding the device tuple {%v:%v] to mount table", device, newM.Fs)
logrus.Infof("Reload: Adding the device tuple [%v:%v] to mount table", device, newM.Fs)
m.mounts[device] = newM
return nil
}
Expand All @@ -384,12 +384,15 @@ func (m *Mounter) load(prefixes []*regexp.Regexp, fmp findMountPoint) error {
foundPrefix, sourcePath, devicePath = fmp(v, devPrefix, info)
targetDevice = getTargetDevice(devPrefix.String())
if !foundPrefix && targetDevice != "" {
foundTarget, _, _ = fmp(v, regexp.MustCompile(regexp.QuoteMeta(targetDevice)), info)
// We could not find a mountpoint for devPrefix (/dev/mapper/vg-lvm1) but found
// one for its target device (/dev/dm-0). Change the sourcePath to devPrefix
// as fmp might have returned an incorrect or empty sourcePath
sourcePath = devPrefix.String()
devicePath = devPrefix.String()
// This should be an Exact Match and not a prefix match.
if strings.EqualFold(targetDevice, v.Source) {
// We could not find a mountpoint for devPrefix (/dev/mapper/vg-lvm1) but found
// one for its target device (/dev/dm-0). Change the sourcePath to devPrefix
// as fmp might have returned an incorrect or empty sourcePath
sourcePath = devPrefix.String()
devicePath = devPrefix.String()
foundTarget = true
}
}

if foundPrefix || foundTarget {
Expand Down

0 comments on commit 68b72fc

Please sign in to comment.