[stgt] [PATCH] fix leak of shared memory

Doron Shoham dorons at Voltaire.COM
Wed Sep 24 17:33:52 CEST 2008


> No, terminating tgtd with SIG_TERM is not the right way to stop
> tgtd.
> 
> You should use the following command:
> 
> tgtadm --op delete --mode system

I wasn't aware of this option.
I couldn't find any info about "--mode system".
It's not written in tgtadm help nor in any man/readme file.

Anyway, using this command doesn't solve the memory leakage.
I have run this scenario:

1. ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status

the shared memory is clean.

2. run tgtd

3. ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x00000000 6193152    root      644        64         2
0x00000000 6225921    root      644        16384      2
0x00000000 6258690    root      644        280        2

4. tgtadm --op delete --mode system

5. ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x00000000 6193152    root      644        64         0
0x00000000 6225921    root      644        16384      0
0x00000000 6258690    root      644        280        0

you can see that the shared memory is not cleared.

I still need to fix my patch to clear the memory when using
the command "tgtadm --op delete --mode system"

> If you handle SIG_TERM, it's more logical to handle SIG_KILL. If you
> handle both, we can say that we always clean up shared memory (this is
> optimal).

How can you handle SIG_KILL?

This from the sigaction man page:
"EINVAL An  invalid  signal  was  specified.   This  will also be generated if an attempt is made to change the action for SIGKILL or
SIGSTOP, which cannot be caught or ignored."

In the patch I've added the handle of SIG_INT as well (for running tgtd in the foreground).
> 
> If you ignore SIG_KILL because it's not the right way to shut down
> tgtd, you should ignore SIG_TERM too since SIG_TERM is not the right
> way too.
> 
> Well, the leak of shared memory happens only when shutting down
> tgtd. So I don't care much how to handle it.

No, it happen all the time...



--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list