LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-01-2003, 11:30 AM   #1
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 47
/proc/sys/fs/file-nr ??


Anyone got any good resources on what this file really shows? I've got a server that runs out of file handles but whats reported by file-nr doesn't make sense - Observe
Code:
[root@cuboid root]# cat /proc/sys/fs/file-nr
2713    1166    235928
So according to the info I've found so far... 2713 = allocated file handles, 1166 = available file handles, 235928 = max file handles (as set in /proc/sys/fs/file-max). I know that some documentation (including the kernel docs!) say that the 1166 = handles used but this isn't the case as every file I open a new file this number goes down.

First question - Why doesn't available_files = max_files - allocated_files ??

And why is the output from
Code:
[root@cuboid root]# lsof | wc -l
  27128
so very very different to allocated files?

Any info greatly appreciated!

Jamie...
 
Old 05-02-2003, 08:52 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Well from what I can see is that the second number is the amount of allocated handles which are available. Not the total amount of available handles.

If I test it with an application that keeps allocating filehandles. I can see that the second number decreases till it gets to something really low like 10, the first number stays constant while this happens. After it reaches a low point then the first number starts increasing and the second number stays low. Ofcourse the first number won't go any higher then the max.

I don't really know why lsof would show so many more lines. Unless you are running a lot of multithreading applications and it's showing multiple entries for the same file descriptors.

Well that's as much information as I could think of without going through the kernel code and find out what is really going on, which I don't really feel like doing.
 
Old 05-02-2003, 09:03 AM   #3
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Original Poster
Rep: Reputation: 47
Quote:
Originally posted by Mik
Well from what I can see is that the second number is the amount of allocated handles which are available. Not the total amount of available handles.
Excuse my density on the subject... Whats the distinction between available allocated handles and the total available handles??
Quote:
Originally posted by Mik
If I test it with an application that keeps allocating filehandles. I can see that the second number decreases till it gets to something really low like 10, the first number stays constant while this happens. After it reaches a low point then the first number starts increasing and the second number stays low.
So as you open files you use the allocated files handles (middle number gets lower), when this number moves towards some threshold more file handles are made available for processes to use (the first number gets larger) yeah? If this is the case why doesn't the available allocated handles suddenly increase? Or have I misunderstood something (very likely).
Quote:
Originally posted by Mik
Well that's as much information as I could think of without going through the kernel code and find out what is really going on, which I don't really feel like doing.
Exactly how I feel about the problem. Not being a C coder it would be a challenge to say the least!

Thanks for the info so far its a great help.

Jamie...
 
Old 05-02-2003, 09:24 AM   #4
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Well I'm not an expert on the topic but I was just trying to show what conclusions I came up with. I'll try to explain my conclusions using example to make it more clear. This system I was trying things out on only has the max set to double the default:

#cat /proc/sys/fs/file-nr
2788 1270 8192

Now according to what I see 8192 is the maximum. 2788 is the amount allocated and 1270 is the amount of unused. Meaning that there would be 2788 - 1270 being used. Instead of 8192 -1270 being used. That's what I meant with the difference between 'available allocated handles' and 'total available handles'.

If I start an example application like bash. After starting bash once only the middle number will have decreased by 20. 'lsof | wc -l' increases by 26. The amount changed stays the same each time I start a new bash process. This stays the same till the middle number gets really low. Then it starts allocating new filehandles and the first number starts increasing by 20 instead.

I guess lsof reports more then just the open files for each process. Since it contains 6 lines more each time.

This is just what I see happening. So your conclusion out of that is as good as mine.
 
Old 05-02-2003, 10:01 AM   #5
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Original Poster
Rep: Reputation: 47
Thumbs up SORTED!

Now I get it!

cheers mate

Jamie...
 
Old 07-27-2009, 07:07 PM   #6
Garp
Member
 
Registered: Jul 2003
Location: Oahu, Hawaii, USA
Distribution: Ubuntu, Debian, RHES
Posts: 57

Rep: Reputation: 15
I know I'm doing serious necro posting, but as a Google search for file-nr shows this second on the results, I thought it would be worth posting the link to this useful description I found:

http://www.netadmintools.com/part295.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't create file using echo: /proc/sys/net/ipv4/ip_local_port_change rsumbeling Linux - General 4 07-17-2013 05:20 AM
/proc/sys/fs/file-max vaginismus Linux - General 1 11-01-2005 12:34 AM
/proc vs /sys alaios Linux - Newbie 1 06-12-2005 12:56 AM
/proc replaced by /sys in 2.6? Thaidog Linux - General 1 04-25-2005 08:09 PM
/proc/sys/fs/file-max Opinions Glover Linux - General 1 07-02-2002 10:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration