From edc6df256d21eb1d1aa36b241dcc6d4b83d58d75 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Fri, 14 Nov 2014 18:15:56 -0500 Subject: [PATCH] devmapper: Call UdevWait() even in failure path 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 Signed-off-by: Vincent Batts --- pkg/devicemapper/devmapper.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/devicemapper/devmapper.go b/pkg/devicemapper/devmapper.go index 4043da6b45..16c0ac1c8c 100644 --- a/pkg/devicemapper/devmapper.go +++ b/pkg/devicemapper/devmapper.go @@ -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 } @@ -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 } @@ -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 }