[Pkg-iscsi-maintainers] [SCM] Debian Open-iSCSI Packaging branch, upstream-mnc, updated. 2.0-872-101-g2616afb

Mike Christie michaelc at cs.wisc.edu
Mon May 2 18:56:44 UTC 2011


The following commit has been merged in the upstream-mnc branch:
commit 1026fb489a7bbe291bea8ae0b3592fa23348bcc7
Author: Mike Christie <michaelc at cs.wisc.edu>
Date:   Thu Apr 7 23:35:27 2011 -0500

    iscsi tools: fix oom_adj use
    
    oom_adj is depreciated. Use oom_score_adj when available.
    
    Also, cleanup write out buffer. "\n" is not needed and
    we do not even write it out since the write len argument
    is 3.

diff --git a/usr/iscsi_util.c b/usr/iscsi_util.c
index 978d3ed..4481294 100644
--- a/usr/iscsi_util.c
+++ b/usr/iscsi_util.c
@@ -25,6 +25,8 @@
 #include <string.h>
 #include <errno.h>
 #include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <sys/resource.h>
 
 #include "log.h"
@@ -48,21 +50,28 @@ void daemon_init(void)
 	chdir("/");
 }
 
+#define ISCSI_OOM_PATH_LEN 48
+
 int oom_adjust(void)
 {
 	int fd;
-	char path[48];
+	char path[ISCSI_OOM_PATH_LEN];
+	struct stat statb;
 
 	nice(-10);
-	sprintf(path, "/proc/%d/oom_adj", getpid());
+
+	snprintf(path, ISCSI_OOM_PATH_LEN, "/proc/%d/oom_score_adj", getpid());
+	if (stat(path, &statb)) {
+		/* older kernel so use old oom_adj file */
+		snprintf(path, ISCSI_OOM_PATH_LEN, "/proc/%d/oom_adj",
+			 getpid());
+	}
 	fd = open(path, O_WRONLY);
-	if (fd < 0) {
+	if (fd < 0)
 		return -1;
-	}
-	write(fd, "-16\n", 3); /* for 2.6.11 */
-	write(fd, "-17\n", 3); /* for Andrea's patch */
+	write(fd, "-16", 3); /* for 2.6.11 */
+	write(fd, "-17", 3); /* for Andrea's patch */
 	close(fd);
-
 	return 0;
 }
 

-- 
Debian Open-iSCSI Packaging



More information about the Pkg-iscsi-maintainers mailing list