22.12.2010 21:24, Filip RembiaĆkowski kirjoitti:
2010/12/22 Proskurin Kirill<[email protected]>:
On 12/22/2010 08:27 AM, Hannes von Haugwitz wrote:
On Mon, Dec 13, 2010 at 07:06:53PM +0300, Proskurin Kirill wrote:
We found what aide compare is too aggressive for our needs.
Could you tell me - there is source I can add sleep a few sec between
two files compare?
Yes we use renice but is is not a the way we want to fix it and it is
not work well for us. We prefer tiny sleep between each files check.
We check really many files at one time.
I think you should try ionice then.
I wonder if I sent the Linux ioprio patch to the mailing list for
comments. It seems that I didn't :(
Here it is.
The current implementation uses "@@define ioclass <class>" to select
linux io priority class and ioprio to select the numerical value.
No ioprio_set call is done only if ioclass||ioprio is defined. Default
values are IOPRIO_CLASS_NONE and 0.
eg. "@@define ioclass 3" "@@define ioprio 42". ioclass can be defined
either a number or "realtime","be","best-effort","idle".
Yes. be and best-effort are the same.
Feel free to comment.
ps. You could try to configure aide --without-mmap. Just because it have
had the tendency to cause problems I think you are having.
Pablo
diff --git a/configure.in b/configure.in
index 0b8c90c..2d40df2 100644
--- a/configure.in
+++ b/configure.in
@@ -546,6 +546,12 @@ AC_SUBST(E2FSATTRSLIB)
# Check whether LFS has explicitly been disabled
AC_ARG_ENABLE(lfs,[ --disable-lfs Disable large file support on 32-bit platforms], [aide_lfs_choice=$enableval], [aide_lfs_choice=yes])
+AC_ARG_ENABLE(linux-ioprio,[ --enable-linux-ioprio Enable iopriority support for Linux], [aide_linux_ioprio_choice=$enableval], [aide_linux_ioprio_choice=no])
+
+if test "$aide_linux_ioprio_choice" = "yes"; then
+ AC_DEFINE(ENABLE_LINUX_IOPRIO,1,[enable Linux ioprio])
+fi
+
if test "$aide_lfs_choice" = "yes"; then
# This looks weird because Linux defines lstat64 and then screws it up
AC_CHECK_FUNC(lstat64,
diff --git a/include/commandconf.h b/include/commandconf.h
index 59ab323..898450d 100644
--- a/include/commandconf.h
+++ b/include/commandconf.h
@@ -65,6 +65,8 @@ void* get_conf_key(void);
size_t get_db_key_len(void);
size_t get_conf_key_len(void);
+char* get_variable_value(char* var);
+void aide_set_ioprio(const char* class,const char* prio);
extern const char* aide_key_1;
diff --git a/src/aide.c b/src/aide.c
index f76b27d..671f9e2 100644
--- a/src/aide.c
+++ b/src/aide.c
@@ -468,6 +468,9 @@ void setdefaults_after_config()
if(conf->verbose_level==-1){
conf->verbose_level=5;
}
+
+ aide_set_ioprio(get_variable_value("ioclass"),get_variable_value("ioprio"));
+
}
diff --git a/src/commandconf.c b/src/commandconf.c
index 1423c70..0b30c8a 100644
--- a/src/commandconf.c
+++ b/src/commandconf.c
@@ -1023,3 +1023,102 @@ size_t get_db_key_len(void) {
free(m);
return len;
}
+
+#ifdef ENABLE_LINUX_IOPRIO
+#include <sys/syscall.h>
+
+/* copy-paste from util-linux-2.17.2/schedutils/ionice.c */
+
+static inline int ioprio_set(int which, int who, int ioprio)
+{
+ return syscall(SYS_ioprio_set, which, who, ioprio);
+}
+
+static inline int ioprio_get(int which, int who)
+{
+ return syscall(SYS_ioprio_get, which, who);
+}
+
+enum {
+ IOPRIO_CLASS_NONE,
+ IOPRIO_CLASS_RT,
+ IOPRIO_CLASS_BE,
+ IOPRIO_CLASS_IDLE,
+};
+
+enum {
+ IOPRIO_WHO_PROCESS = 1,
+ IOPRIO_WHO_PGRP,
+ IOPRIO_WHO_USER,
+};
+
+
+/* copy-paste from util-linux-2.17.2/schedutils/ionice.c ends */
+
+#ifndef IOPRIO_CLASS_SHIFT
+#define IOPRIO_CLASS_SHIFT 13
+#endif
+
+#ifndef IOPRIO_PRIO_VALUE
+#define IOPRIO_PRIO_VALUE(class,prio) (prio | class << IOPRIO_CLASS_SHIFT)
+#endif
+#endif
+
+void aide_set_ioprio(const char* class,const char* prio) {
+#ifdef ENABLE_LINUX_IOPRIO
+
+ struct ss {
+ char* name;
+ int val;
+ };
+
+ static struct ss linux_ioclasses[] = {
+ { "realtime", IOPRIO_CLASS_RT },
+ { "be", IOPRIO_CLASS_BE },
+ { "best-effort", IOPRIO_CLASS_BE },
+ { "idle", IOPRIO_CLASS_IDLE },
+ };
+
+ int ret;
+ int ioprio=0;
+ int ioclass=IOPRIO_CLASS_NONE;
+ int pid;
+ char* endp;
+ unsigned i;
+
+ if (class==NULL && prio==NULL) {
+ return;
+ }
+
+ pid = getpid();
+
+ if (class!=NULL) {
+ int _class = strtol(class,&endp,10);
+
+ if (*endp=='\0' && endp!=class) {
+ ioclass=_class;
+ } else {
+ for(i=0;i<(sizeof(linux_ioclasses)/sizeof(linux_ioclasses[0]));i++){
+ if(strcmp(class,linux_ioclasses[i].name)==0){
+ ioclass=linux_ioclasses[i].val;
+ break;
+ }
+ }
+ }
+ }
+
+ if (prio!=NULL) {
+ int _prio = strtol(class,&endp,10);
+
+ if (*endp=='\0' && endp!=class) {
+ ioprio=_prio;
+ }
+ }
+
+ ret=ioprio_set(IOPRIO_WHO_PROCESS,pid,
+ IOPRIO_PRIO_VALUE(ioclass,ioprio));
+
+ error(255,_("ioprio_set(%i(%s),%i(%s)) %i\n"),
+ ioclass,class,ioprio,prio,ret);
+#endif
+}
_______________________________________________
Aide mailing list
[email protected]
https://mailman.cs.tut.fi/mailman/listinfo/aide