The system fails to call statfs () on a large disk.

Source: Internet
Author: User

When I deployed a set of recording at the customer's site yesterday, I encountered a small problem and recorded it.

After the system is started, the following logs are generated:

Statfs error. strPath:/figure/datafile/recordfile5/FullRecord/StreamTS/1-1-Oriental TV, Value too large for defined data type RepeatCount = 34

 

The query results are as follows:

(1) our system has enabled a thread to continuously scan the usage of the system disk. The system calls statfs ();

Struct statfs {
Long f_type;/* type of file system (see below )*/
Long f_bsize;/* optimal transfer block size */
Long f_blocks;/* total data blocks in file system */
Long f_bfree;/* free blocks in fs */
Long f_bavail;/* free blocks avail to unprivileged user */
Long f_files;/* total file nodes in file system */
Long f_ffree;/* free file nodes in fs */
Fsid_t f_fsid;/* file system id */
Long f_namelen;/* maximum length of filenames */
};

(2) On-site use of NAS with a capacity of 35 TB;

(3) If each block on a disk is 4 k, there are a total of 9395240960 blocks;

(4) On the target platform, sizeof (long) = sizeof (int) = 4 bytes, and the maximum number that can be expressed is: 4294967296

(5) When statfs is called, the call will fail due to overflow.

 

The final solution is to use 64-bit statfs64.
Struct statfs64 fs;
If (statfs64 (strPath. c_str (), & fs) <0)
{
LOG_PERIOD (LOG_TYPE_WARN, "statfs error. strPath: % s, % s", strPath. c_str (), strerror (errno ));
Return 100;
}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.