Hi, how to I can read in safe mode, from bash, the content
of /proc/locks?
On my system I have more than 7000/9000 line into /proc/locks and if I
read it with awk (or cat or grep or cp) the file change during the read
and my input is undefined and is not processable (see attach).
My target is read if a process lock a specific files (through its
i-node)
Il giorno mar, 12/07/2011 alle 14.13 +0200, Dario Lesca ha scritto:
> Hi, how to I can read in safe mode, from bash, the content
> of /proc/locks?
>
> On my system I have more than 7000/9000 line into /proc/locks and if I
> read it with awk (or cat or grep or cp) the file change during the read
> and my input is undefined and is not processable (see attach).
>
> My target is read if a process lock a specific files (through its
> i-node)
>
> Someone can suggest me some kind of solution?
Then, there are not solutions for my problem?
Or my question is not clear?
Via bash, what is the best method for know if a process lock a specific
files?
Thanks, (and sorry for my bad english)
--
Dario Lesca <d.lesca@solinos.it>
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
07-15-2011, 03:57 PM
Przemek Klosowski
How to read /proc/locks in safe mode?
On 07/15/2011 05:26 AM, Dario Lesca wrote:
> Il giorno mar, 12/07/2011 alle 14.13 +0200, Dario Lesca ha scritto:
>> Hi, how to I can read in safe mode, from bash, the content
>> of /proc/locks?
>>
>> On my system I have more than 7000/9000 line into /proc/locks and if I
>> read it with awk (or cat or grep or cp) the file change during the read
>> and my input is undefined and is not processable (see attach).
I can't think of anything to lock all the other processes on your system
while your awk/cat is running, other than raising the priority of your
process high enough.
Perhaps if you explained what you are trying to accomplish by your
processing of /proc/locks, people have some suggestions. Clearly your
situation is unusual---why do you have thousands of active locks? I
think a dozen or so is the norm (I have a fairly busy desktop with many
sessions and programs open, and 20 locks are active right now).
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
07-15-2011, 03:57 PM
Przemek Klosowski
How to read /proc/locks in safe mode?
On 07/15/2011 05:26 AM, Dario Lesca wrote:
> Il giorno mar, 12/07/2011 alle 14.13 +0200, Dario Lesca ha scritto:
>> Hi, how to I can read in safe mode, from bash, the content
>> of /proc/locks?
>>
>> On my system I have more than 7000/9000 line into /proc/locks and if I
>> read it with awk (or cat or grep or cp) the file change during the read
>> and my input is undefined and is not processable (see attach).
I can't think of anything to lock all the other processes on your system
while your awk/cat is running, other than raising the priority of your
process high enough.
Perhaps if you explained what you are trying to accomplish by your
processing of /proc/locks, people have some suggestions. Clearly your
situation is unusual---why do you have thousands of active locks? I
think a dozen or so is the norm (I have a fairly busy desktop with many
sessions and programs open, and 20 locks are active right now).
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
07-15-2011, 04:21 PM
Dario Lesca
How to read /proc/locks in safe mode?
Il giorno ven, 15/07/2011 alle 11.57 -0400, Przemek Klosowski ha
scritto:
>
> I can't think of anything to lock all the other processes on your
> system while your awk/cat is running, other than raising the priority
> of your process high enough.
>
> Perhaps if you explained what you are trying to accomplish by your
> processing of /proc/locks, people have some suggestions. Clearly your
> situation is unusual---why do you have thousands of active locks? I
> think a dozen or so is the norm (I have a fairly busy desktop with
> many sessions and programs open, and 20 locks are active right now).
thanks Przemek
It's a server, and every user (>300) have ad least a lock on a specific
portion of the same file
The file /proc/locks contain also many other (<5000) lines than those
lock and this virtual file is continuously modified.
If I try copy it (cp /proc/locks /tmp/l or cat /proc/locks>/tmp/l) two
times in succession, the result is always very different and the
abnormal line (more than 8 field) are like attachment of previous
message.
So, if I process this file with awk the result many time is
undefined ...
My goal is extract the lock line of a specific process an see if this
process lock a specific file and extract the offset lock.
This procedure work if none of user login or logout on the server, but
this condition is rare...
today have check the lslk utilities, but even it, if user login/logout
and work do not show the correct list: some time the result is wrong...
Thanks
--
Dario Lesca <d.lesca@solinos.it>
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
07-15-2011, 04:21 PM
Dario Lesca
How to read /proc/locks in safe mode?
Il giorno ven, 15/07/2011 alle 11.57 -0400, Przemek Klosowski ha
scritto:
>
> I can't think of anything to lock all the other processes on your
> system while your awk/cat is running, other than raising the priority
> of your process high enough.
>
> Perhaps if you explained what you are trying to accomplish by your
> processing of /proc/locks, people have some suggestions. Clearly your
> situation is unusual---why do you have thousands of active locks? I
> think a dozen or so is the norm (I have a fairly busy desktop with
> many sessions and programs open, and 20 locks are active right now).
thanks Przemek
It's a server, and every user (>300) have ad least a lock on a specific
portion of the same file
The file /proc/locks contain also many other (<5000) lines than those
lock and this virtual file is continuously modified.
If I try copy it (cp /proc/locks /tmp/l or cat /proc/locks>/tmp/l) two
times in succession, the result is always very different and the
abnormal line (more than 8 field) are like attachment of previous
message.
So, if I process this file with awk the result many time is
undefined ...
My goal is extract the lock line of a specific process an see if this
process lock a specific file and extract the offset lock.
This procedure work if none of user login or logout on the server, but
this condition is rare...
today have check the lslk utilities, but even it, if user login/logout
and work do not show the correct list: some time the result is wrong...
Thanks
--
Dario Lesca <d.lesca@solinos.it>
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
07-15-2011, 04:48 PM
Dan Mills
How to read /proc/locks in safe mode?
On Fri, 2011-07-15 at 18:21 +0200, Dario Lesca wrote:
> If I try copy it (cp /proc/locks /tmp/l or cat /proc/locks>/tmp/l) two
> times in succession, the result is always very different and the
> abnormal line (more than 8 field) are like attachment of previous
> message.
The thing is ANY processing is inherently going to be racy, at least
some of the time.
The way to find out of part of a file is locked, is to try to take the
lock yourself (LOCK_NB as an argument to flock may be useful here), if
you get it then it was not held, and if your attempt fails then the lock
is held by something else.
ANYTHING else is going to give you inherently out of date information
that may change from under you.
You really need to find another way to do whatever it is you are really
trying to do, why does a third party need to know which locks are held?
Regards, Dan.
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
07-15-2011, 05:04 PM
Dario Lesca
How to read /proc/locks in safe mode?
Il giorno ven, 15/07/2011 alle 17.48 +0100, Dan Mills ha scritto:
> The thing is ANY processing is inherently going to be racy, at least
> some of the time.
>
> The way to find out of part of a file is locked, is to try to take the
> lock yourself (LOCK_NB as an argument to flock may be useful here),
> if you get it then it was not held, and if your attempt fails then the
> lock is held by something else.
Ok, this is a way for try to resolve my problem, I check it. Thanks
> ANYTHING else is going to give you inherently out of date information
> that may change from under you.
yes, i saw it
> You really need to find another way to do whatever it is you are
> really trying to do, why does a third party need to know which locks
> are held?
Because is a third part software and the producer do not give us that
information, so I thought read /proc/locks for establish if a process is
active via our lock on this file.
Ok, thank Dan for suggest.
Ciao
--
Dario Lesca <d.lesca@solinos.it>
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
07-15-2011, 05:33 PM
Thomas Moschny
How to read /proc/locks in safe mode?
2011/7/12 Dario Lesca <d.lesca@solinos.it>:
> Hi, how to I can read in safe mode, from bash, the content
> of /proc/locks?
>
> On my system I have more than 7000/9000 line into /proc/locks and if I
> read it with awk (or cat or grep or cp) the file change during the read
> and my input is undefined and is not processable (see attach).
Interesting, because afaiu, in recent kernels reading /proc/locks
line-wise should not yield broken records, as the code in fs/locks.c
uses the seq_file abstraction. See
http://stackoverflow.com/questions/5713451/is-it-safe-to-parse-a-proc-file/5880485#5880485.
What is the kernel version you are seeing that on?
- Thomas
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
07-19-2011, 12:05 PM
Dario Lesca
How to read /proc/locks in safe mode?
Il giorno ven, 15/07/2011 alle 19.33 +0200, Thomas Moschny ha scritto:
> Interesting, because afaiu, in recent kernels reading /proc/locks
> line-wise should not yield broken records, as the code in fs/locks.c
> uses the seq_file abstraction. See
> http://stackoverflow.com/questions/5713451/is-it-safe-to-parse-a-proc-file/5880485#5880485.
> What is the kernel version you are seeing that on?
Thanks Thomas for reply, but ...
... Opss! I have verify and this server is the only server with a Centos
5.5 with kernel 2.6.18-194.32.1.el5. (sorry for the OT)
On another 2 systems with fedora 14 (I thought it was one of these
servers with the error) the problem does not occur, but on these server
there are fewer users connected
Currently I do not have the ability to update the C5.5 server, but I
will as soon as possible
So my read /proc/locks problem it might be a kernel's problem?
Thanks for reply
--
Dario Lesca <d.lesca@solinos.it>
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel