LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What does 'IO Block' mean in the out put of stat command (https://www.linuxquestions.org/questions/linux-newbie-8/what-does-io-block-mean-in-the-out-put-of-stat-command-4175483705/)

hilou 11-07-2013 03:36 AM

What does 'IO Block' mean in the out put of stat command
 
Filesystem: ext4

I find a fun phenomenal when I run stat command on different file systems:

stat output on local disk:
# stat test
File: `test'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file

stat output on nfs disk:
# stat test
File: `test'
Size: 0 Blocks: 0 IO Block: 1048576 regular empty file

My question is why IO Block is different? and what does IO Block mean?

Thanks in advance.

jpollard 11-07-2013 04:46 AM

I believe the IO block size of an NFS disk is "not really specified" (I think you are seeing an uninitialized value). NFS can't use a block size, as it is limited by the network. Any block size specifications are only on the server, but that information isn't passed to the client, as there is no way for the client to make use of it.

druuna 11-07-2013 04:47 AM

A block is the minimal size that can be written to disk. Even if the size is smaller then this block, a full block is needed.

On modern Linux systems the block size is 4096 (but it can be smaller/larger). The block size is set/determined when creating a file system, you can retrieve it by using the following command (as root):
Code:

# dumpe2fs /dev/sda2 | grep "^Block size:"
Replace the bold part with the device you want to check.

When using NFS you can set the rsize and wsize while mounting; The 1048576 seen on the NFS share is the largest read/write payload supported by the Linux NFS client.

hilou 11-07-2013 08:20 AM

Hi All,

Thanks for your effort. But I want to know what exactly 'IO Block' mean in stat command and the value of 'IO Block' in nfs is quite different, so what resulted in this?

Thanks

druuna 11-07-2013 08:34 AM

Quote:

Originally Posted by hilou (Post 5060042)
Thanks for your effort. But I want to know what exactly 'IO Block' mean in stat command and the value of 'IO Block' in nfs is quite different, so what resulted in this?

I'm not sure what more I can tell you.

IO Block is a fixed thing, it shows the block size that is being used. 4096 on the ext4 files-system you use, 1048576 on the NFS file-system you use.

The stat line:
Size: shows the actual size (what you expect: a 1 byte file will show up as 1).
Blocks: Is the amount of blocks used (a 1 byte file will use 1 block, which is 4096 bytes on disk for a normal file-system).
IO Block: Size of the block used.

hilou 11-11-2013 01:02 AM

Quote:

Originally Posted by druuna (Post 5060045)
I'm not sure what more I can tell you.

IO Block is a fixed thing, it shows the block size that is being used. 4096 on the ext4 files-system you use, 1048576 on the NFS file-system you use.

The stat line:
Size: shows the actual size (what you expect: a 1 byte file will show up as 1).
Blocks: Is the amount of blocks used (a 1 byte file will use 1 block, which is 4096 bytes on disk for a normal file-system).
IO Block: Size of the block used.

Hi,

I mean the value of 'IO Block' in nfs directory is not always 1048576. It could be any other value, like 4096, 32768 etc after checking some other nfs. I want to know what decides this value?

Thanks

druuna 11-11-2013 02:18 AM

Quote:

Originally Posted by hilou (Post 5062281)
I mean the value of 'IO Block' in nfs directory is not always 1048576. It could be any other value, like 4096, 32768 etc after checking some other nfs. I want to know what decides this value?

As mentioned in post #3: The rsize/wsize option.

This from the nfs manual page:
Quote:

The rsize value is a positive integral multiple of 1024.
Specified rsize values lower than 1024 are replaced with
4096; values larger than 1048576 are replaced with
1048576. If a specified value is within the supported
range but not a multiple of 1024, it is rounded down to
the nearest multiple of 1024.
The following quote is from Optimizing NFS Performance
Quote:

5.1. Setting Block Size to Optimize Transfer Speeds

The mount command options rsize and wsize specify the size of the chunks of data that the client and server pass back and forth to each other. If no rsize and wsize options are specified, the default varies by which version of NFS we are using. The most common default is 4K (4096 bytes), although for TCP-based mounts in 2.2 kernels, and for all mounts beginning with 2.4 kernels, the server specifies the default block size.

hilou 11-14-2013 01:06 AM

Quote:

Originally Posted by druuna (Post 5062328)
As mentioned in post #3: The rsize/wsize option.

This from the nfs manual page:

The following quote is from Optimizing NFS Performance

Hi,

This is a instance of my environment.

NFS mount options: type nfs (rw,hard,intr,bg,rsize=32768,wsize=32768,addr=187.25.22.171)
stat output of nfs directory
File: `etc/'
Size: 20480 Blocks: 40 IO Block: 4096 directory
Device: 19h/25d Inode: 44446164 Links: 95
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)

It seems is not desided by rsize and wsize.

druuna 11-14-2013 03:41 AM

Quote:

Originally Posted by hilou (Post 5064094)
This is a instance of my environment.

NFS mount options: type nfs (rw,hard,intr,bg,rsize=32768,wsize=32768,addr=187.25.22.171)
stat output of nfs directory
File: `etc/'
Size: 20480 Blocks: 40 IO Block: 4096 directory
Device: 19h/25d Inode: 44446164 Links: 95
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)

It seems is not desided by rsize and wsize.

Just to make sure: Your /etc directory is an nfs mount? Or is this another directory called etc in a different location?

hilou 11-18-2013 08:25 PM

Quote:

Originally Posted by druuna (Post 5064154)
Just to make sure: Your /etc directory is an nfs mount? Or is this another directory called etc in a different location?

Hi,

we back up /etc to a nfs mount.

ip:/backup is mounted to /var/backup

etc is backed up to /var/backup/etc, and I run stat on /var/backup/etc

Thanks.


All times are GMT -5. The time now is 02:17 PM.