Handle error paths.
PATCH 1/1 Handle error paths.
On memory constrained systems, where a large amount of LUNs are assigned (say more enough to make multipath blossom to 70% of available memory space) forking would fail returning -ENOMEM. The kernel has enough free pages for the new process, but when it clones the new child process from the parent process space it accounts the parent process heap space against the child (which counts for more pages than there are free pages).
Using vfork passes a flag to clone which will inhibit this calculation and instead check for free pages. The danger in using vfork is that the child could use the values from the parent, but fortunatly we don't do that and immediately call 'execve' swipping the process space free.
PATCH 1/1 Close file descriptors if forking returns an error.
From: Konrad Rzeszutek <[email protected]>
And also use vfork instead of fork so that the heap space count of the parent process (multipathd) will not be counted against the program which will executed (scsi_id or other).
--- libmultipath/callout.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
libmultipath/callout.c +4 -1
@@ -68,7 +68,7 @@ int execute_program(char *path, char *value, int len)return -1 ; - pid =fork (); + pid =vfork ();switch (pid) {case 0 :
@@ -91,6 +91,9 @@ int execute_program(char *path, char *value, int len)exit (-1 );case -1 : +close (fds[0 ]); +close (fds[1 ]); +condlog (0 ,"error forking: %s. errno:%d\n" , path, errno);return -1 ;default :/* parent reads from fds[0] */
Signature · 1 line
1.5.4.1
Ummm?
brassow
Quoted 18 lines · Konrad Rzeszutek
On memory constrained systems, where a large amount of LUNs are assigned (say more enough to make multipath blossom to 70% of available memory space) forking would fail returning
-ENOMEM. The kernel has enough free pages for the new process, but when it clones the new child process from the parent process space it accounts the parent process heap space against the child (which counts for more pages than there are free pages).Using vfork passes a flag to clone which will inhibit this calculation and instead check for free pages. The danger in using vfork is that the child could use the values from the parent, but fortunatly we don't do that and immediately call 'execve' swipping the process space free.
--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
Quoted 1 line · Jonathan Brassow
Ummm?
Here is the patch:
https://www.redhat.com/archives/dm-devel/2009-January/msg00058.html
Quoted 29 lines
brassow
Quoted 15 lines · Konrad Rzeszutek
On memory constrained systems, where a large amount of LUNs are assigned (say more enough to make multipath blossom to 70% of available memory space) forking would fail returning
-ENOMEM. The kernel has enough free pages for the new process, but when it clones the new child process from the parent process space it accounts the parent process heap space against the child (which counts for more pages than there are free pages).Using vfork passes a flag to clone which will inhibit this calculation and instead check for free pages. The danger in using vfork is that the child
could use the values from the parent, but fortunatly we don't do that and immediately call 'execve' swipping the process space free.Quoted 4 lines
--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel