Skip to content

Commit

Permalink
devmapper: Call UdevWait() even in failure path
Browse files Browse the repository at this point in the history
Currently we set up a cookie and upon failure not call UdevWait(). This
does not cleanup the cookie and associated semaphore and system will
soon max out on total number of semaphores.

To avoid this, call UdevWait() even in failure path which in turn will
cleanup associated semaphore.

Signed-off-by: Vivek Goyal <[email protected]>
Signed-off-by: Vincent Batts <[email protected]>
  • Loading branch information
rhvgoyal authored and vbatts committed Nov 15, 2014
1 parent 8682bac commit edc6df2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/devicemapper/devmapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,12 @@ func CreatePool(poolName string, dataFile, metadataFile *os.File, poolBlockSize
if err := task.SetCookie(&cookie, 0); err != nil {
return fmt.Errorf("Can't set cookie %s", err)
}
defer UdevWait(cookie)

if err := task.Run(); err != nil {
return fmt.Errorf("Error running DeviceCreate (CreatePool) %s", err)
}

UdevWait(cookie)

return nil
}

Expand Down Expand Up @@ -516,13 +515,12 @@ func ResumeDevice(name string) error {
if err := task.SetCookie(&cookie, 0); err != nil {
return fmt.Errorf("Can't set cookie %s", err)
}
defer UdevWait(cookie)

if err := task.Run(); err != nil {
return fmt.Errorf("Error running DeviceResume %s", err)
}

UdevWait(cookie)

return nil
}

Expand Down Expand Up @@ -596,12 +594,12 @@ func ActivateDevice(poolName string, name string, deviceId int, size uint64) err
return fmt.Errorf("Can't set cookie %s", err)
}

defer UdevWait(cookie)

if err := task.Run(); err != nil {
return fmt.Errorf("Error running DeviceCreate (ActivateDevice) %s", err)
}

UdevWait(cookie)

return nil
}

Expand Down

0 comments on commit edc6df2

Please sign in to comment.