Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - ham & smbd daemon: (8 Items)
   
ham & smbd daemon  
hello.

i want to start high availability server with samba-services. so i try to test attaching smbd daemon to HAM.

i do these actions in shell:

--
QCC -l/usr/lib/libham.so addsmbd.c -o addsmbd  //compiling a program for attaches smbd to HAM with simple restart smbd 
if it's dead
ham               //starting the HAM
./addsmbd    //starting the attaching program

--

after that there is working smbd - i can see shared folders. when i slay smbd and use comand ps after that it shows me 
that smbd is working - and i can see shared folders too.
but there is a some details: after attaching smbd to HAM there is 100% CPU load
comand top shows me that the most CPU resourced are taken by 3 processes "kernel" (and there are 3 "devb-eide" processes
; when i don't try to all these actions there is only one such process).
first i thought that is incorrect restart of smbd (when we are attaching smbd to ham and smbd is not started HAM starts 
it), but when i tried this:

---
smbd -D
ham
./addsmbd
---

- the result was the same, 100% CPU loading :( maybe there is some error in ham_attach action?

--
source code of addsmbd.c (made form the High Availability Framework's "inetd simple restart" with ctrl+r =D ):

/* addsmbd.c */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/netmgr.h>
#include <fcntl.h>
#include "ha/ham.h"
int main(int argc, char *argv[])
{
int status;
char *smbdpath;
ham_entity_t *ehdl;
ham_condition_t *chdl;
ham_action_t *ahdl;
int smbddpid;
if (argc > 1)
smbdpath = strdup(argv[1]);
else
smbdpath = strdup("/usr/pkg/sbin/smbd -D"); /* samba was compiled from pkgsrc repository */
if (argc > 2)
smbdpid = atoi(argv[2]);
else
smbdpid = -1;
ham_connect(0);
ehdl = ham_attach("smbd", ND_LOCAL_NODE, smbdpid, smbdpath, 0);
if (ehdl != NULL)
{
chdl = ham_condition(ehdl,CONDDEATH, "death", HREARMAFTERRESTART);
if (chdl != NULL) {
ahdl = ham_action_restart(chdl, "restart", smbdpath,
HREARMAFTERRESTART);
if (ahdl == NULL)
printf("add action failed\n");
}
else
printf("add condition failed\n");
}
else
printf("add entity failed\n");
ham_disconnect(0);
exit(0);
}

----

how can i do it works normally?

thanks in advance
Re: ham & smbd daemon  
Can you run ham with additonal -vvvvv and look at the logs. U can direct the logs to a file with -f logpfile option

Thanks
Shiv
Shiv Nagarajan
Kernel developer, QNX Software Systems
Canada

----- Original Message -----
From: Alexei Luzan <community-noreply@qnx.com>
To: ostech-core_os <post45285@community.qnx.com>
Sent: Fri Jan 15 08:32:16 2010
Subject: ham & smbd daemon

hello.

i want to start high availability server with samba-services. so i try to test attaching smbd daemon to HAM.

i do these actions in shell:

--
QCC -l/usr/lib/libham.so addsmbd.c -o addsmbd  //compiling a program for attaches smbd to HAM with simple restart smbd 
if it's dead
ham               //starting the HAM
./addsmbd    //starting the attaching program

--

after that there is working smbd - i can see shared folders. when i slay smbd and use comand ps after that it shows me 
that smbd is working - and i can see shared folders too.
but there is a some details: after attaching smbd to HAM there is 100% CPU load
comand top shows me that the most CPU resourced are taken by 3 processes "kernel" (and there are 3 "devb-eide" processes
; when i don't try to all these actions there is only one such process).
first i thought that is incorrect restart of smbd (when we are attaching smbd to ham and smbd is not started HAM starts 
it), but when i tried this:

---
smbd -D
ham
./addsmbd
---

- the result was the same, 100% CPU loading :( maybe there is some error in ham_attach action?

--
source code of addsmbd.c (made form the High Availability Framework's "inetd simple restart" with ctrl+r =D ):

/* addsmbd.c */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/netmgr.h>
#include <fcntl.h>
#include "ha/ham.h"
int main(int argc, char *argv[])
{
int status;
char *smbdpath;
ham_entity_t *ehdl;
ham_condition_t *chdl;
ham_action_t *ahdl;
int smbddpid;
if (argc > 1)
smbdpath = strdup(argv[1]);
else
smbdpath = strdup("/usr/pkg/sbin/smbd -D"); /* samba was compiled from pkgsrc repository */
if (argc > 2)
smbdpid = atoi(argv[2]);
else
smbdpid = -1;
ham_connect(0);
ehdl = ham_attach("smbd", ND_LOCAL_NODE, smbdpid, smbdpath, 0);
if (ehdl != NULL)
{
chdl = ham_condition(ehdl,CONDDEATH, "death", HREARMAFTERRESTART);
if (chdl != NULL) {
ahdl = ham_action_restart(chdl, "restart", smbdpath,
HREARMAFTERRESTART);
if (ahdl == NULL)
printf("add action failed\n");
}
else
printf("add condition failed\n");
}
else
printf("add entity failed\n");
ham_disconnect(0);
exit(0);
}

----

how can i do it works normally?

thanks in advance




_______________________________________________

OSTech
http://community.qnx.com/sf/go/post45285

Re: ham & smbd daemon  
hello, Shiv

did't think about looking the logs before, sorry

log:

0.000000000s: Ham: Started: (299319197155)
0.001999694s: Ham: Log timestamp started:1970/01/01 03:04:59:320197002
0.006998929s: Ham: Creating guardian
0.011998164s: Ham: Attach request from Guardian Pid 471078
1408.227508221s: Ham: Attach Other Entity Request: smbd
1408.271501489s: Ham: Attached Other Entity: smbd
1408.285499347s: Ham: Condition Add Request: smbd/death
1408.286499194s: Ham: Condition Added: smbd/death
1408.287499041s: Ham: Action Restart Add Request: smbd/death/restart
1408.291498429s: Ham: Action Restart Added: smbd/death/restart
1408.626447174s: Ham: Entity "smbd" with pid: 295473192 died
1408.647443961s: Ham: Restarted: /usr/pkg/sbin/smbd -D
1408.694436770s: Ham: Entity "smbd" with pid: 295481384 died
1408.705435087s: Ham: Restarted: /usr/pkg/sbin/smbd -D
1408.736430344s: Ham: Entity "smbd" with pid: 295485480 died
1408.744429120s: Ham: Restarted: /usr/pkg/sbin/smbd -D
1408.775424377s: Ham: Entity "smbd" with pid: 295493672 died
1409.030385362s: Ham: Restarted: /usr/pkg/sbin/smbd -D
1409.226355374s: Ham: Entity "smbd" with pid: 295501864 died
1409.349336555s: Ham: Restarted: /usr/pkg/sbin/smbd -D
1409.385331047s: Ham: Entity "smbd" with pid: 295510056 died
1409.393329823s: Ham: Restarted: /usr/pkg/sbin/smbd -D
1409.423325233s: Ham: Entity "smbd" with pid: 295518248 died
1409.432323856s: Ham: Restarted: /usr/pkg/sbin/smbd -D
1409.463319113s: Ham: Entity "smbd" with pid: 295526440 died
1409.472317736s: Ham: Restarted: /usr/pkg/sbin/smbd -D
1409.505312687s: Ham: Entity "smbd" with pid: 295534632 died
1409.512311616s: Ham: Restarted: /usr/pkg/sbin/smbd -D
1409.540307332s: Ham: Entity "smbd" with pid: 295542824 died
1409.548306108s: Ham: Restarted: /usr/pkg/sbin/smbd -D

looks something like endless cycle: immediate death after restart - then new restart
maybe it's because of smbd's key -D? but i tried to attach smbd without keys - same result. also tried to attach with 
key -F (don't deamonize as i remember) - ham doesn't attach it, "add entity failed".

thank you
Re: ham & smbd daemon  
also log.smbd after attaching to ham shows this:


  smbd version 3.0.35 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2009
[2010/01/16 04:48:39, 0] /usr/HEAD_641/pkgsrc/net/samba/work/samba-3.0.35/source/lib/pidfile.c:pidfile_create(112)
  ERROR: smbd is already running. File /var/run/smbd.pid exists and process id 499751 is running.
[2010/01/16 04:48:39, 0] smbd/server.c:main(942)
  smbd version 3.0.35 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2009
[2010/01/16 04:48:39, 0] /usr/HEAD_641/pkgsrc/net/samba/work/samba-3.0.35/source/lib/pidfile.c:pidfile_create(112)
  ERROR: smbd is already running. File /var/run/smbd.pid exists and process id 499751 is running.
[2010/01/16 04:48:39, 0] smbd/server.c:main(942)
  smbd version 3.0.35 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2009
[2010/01/16 04:48:39, 0] /usr/HEAD_641/pkgsrc/net/samba/work/samba-3.0.35/source/lib/pidfile.c:pidfile_create(112)
  ERROR: smbd is already running. File /var/run/smbd.pid exists and process id 499751 is running.
[2010/01/16 04:48:39, 0] smbd/server.c:main(942)
Re: ham & smbd daemon  
it probably has to do with smbd using the daemon call to become a
daemon.  means the Ham constantly thinks smbd has died and tries to
restart it.

Is there a way to avoid making smbd a daemon?

We recently made some fixes to libc to deal with some of the cases where
daemon is used, and the process is being monitored. the fix is in two
places.. If you can get the fix that was in libc from foundry, I can
probably get you the fix for the ham side of things. The libc fix is in
lib/c/unix/daemon.c .. If smb uses daemon, this may fix things. If smbd
uses fork, then it is much harder, and the current version of the code
would probably not work :(

Which version of qnx, and which cpu is this on?

thanks
shiv
Re: ham & smbd daemon  
many thanks for helping, Shiv

i use QNX 6.4.1 at vmware workstation 7 (with emulation 1 CPU with 1 core and 256 mb RAM). host has Intel Core 2 Duo 
e6400, if it's important. also i use QNX 6.4.1 as host OS at x86 AMD semphron 2400+ with 512 mb RAM

you've remembered to me some way to resolve this problem. i've forgotten about the using smbd through the inetd 
superserver. now after little changes in /etc/inetd.conf i can attach inetd to ham with an example from HA Framework and
 use it.
so it works ;)

but i think it's not safe if there will be any errors in smbd working. and, in my noob opinion, it will be better if 
smbd daemon will be attached to ham directly, not through inetd.
so, please, can you tell me what should i do with the daemon.c fix? :D how could i add it to libc?

thank you
Re: ham & smbd daemon  
hi

sorry for bothering again

please, can you tell what should i do to add the daemon.c fix. want to try this way too.

thanks
RE: ham & smbd daemon  
Let me try and get you a fix to try. 

shiv 

-----Original Message-----
From: Alexei Luzan [mailto:community-noreply@qnx.com] 
Sent: Tuesday, January 19, 2010 3:38 PM
To: ostech-core_os
Subject: Re: ham & smbd daemon

hi

sorry for bothering again

please, can you tell what should i do to add the daemon.c fix. want to
try this way too.

thanks



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post45510