Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#46 closed defect (fixed)

Changeset 3900 st_blocks and ZFS problem

Reported by: Yasar Semih Alev Owned by: somebody
Priority: minor Milestone:
Component: nginx-core Version: 1.0.x
Keywords: st_blocks zfs freebsd Cc:
uname -a: FreeBSD izm-s2 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Thu Feb 17 02:41:51 UTC 2011 root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
nginx -V: nginx: nginx version: nginx/1.1.7
nginx: built by gcc 4.2.1 20070719 [FreeBSD]
nginx: TLS SNI support enabled
nginx: configure arguments: --user=nginx --group=nginx --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --with-http_secure_link_module --with-http_random_index_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_geoip_module --with-mail --with-debug --with-mail_ssl_module --with-file-aio --with-cc-opt='-O2 -g -m64 -mtune=generic' --add-module=/home/nginx/nginx-1.1.7/ngx_http_bytes_filter_module --add-module=/home/nginx/nginx-1.1.7/nginx-udplog-module --add-module=/home/nginx/nginx-1.1.7/ngx_http_secure_download --add-module=/home/nginx/nginx-1.1.7/ngx_cache_purge

Description

Hi,

stat->st_blocks give wrong filesize information on FreeBSD with ZFS filesystem. Nginx cache max_size exceed and filesystem is full sometime later. I searched the problem and see the changes in 3900 and i changed this;

#define ngx_file_fs_size(sb) ((sb)->st_blocks * 512)
to
#define ngx_file_fs_size(sb) (sb)->st_size

The problem solved with this change but I know this change for filesize precise and I/O operations but ZFS st_blocks very different. I googled and read some discussions about these. May be same problem occur on Solaris with ZFS filesystem.

Thanks.

Kind Regards

Semih Alev

Change History (4)

comment:1 by Maxim Dounin, 13 years ago

Status: newaccepted

Ok, it look like ZFS reports incorrect st_blocks unless file settles on disk, and this may take a while (i.e. just after creation of file st_blocks is incorrect). We probably want to disable st_blocks use if st_blocks * 512 < st_size, it should fix ZFS problems while still preserving accuracy for other filesystems.

(And, just to confirm, your workaround is safe, though it makes calculations for other filesystems less precise.)

comment:2 by Maxim Dounin, 13 years ago

In [4499/nginx]:

Workaround for fs_size on ZFS (ticket #46).

ZFS reports incorrect st_blocks until file settles on disk, and this
may take a while (i.e. just after creation of a file the st_blocks value
is incorrect). As a workaround we now use st_blocks only if
st_blocks * 512 > st_size, this should fix ZFS problems while still
preserving accuracy for other filesystems.

The problem had appeared in r3900 (1.0.1).

comment:3 by Maxim Dounin, 13 years ago

Resolution: fixed
Status: acceptedclosed

Fix committed.

comment:4 by Maxim Dounin, 13 years ago

In [4517/nginx]:

Merge of r4499: workaround for fs_size on ZFS (ticket #46).

ZFS reports incorrect st_blocks until file settles on disk, and this
may take a while (i.e. just after creation of a file the st_blocks value
is incorrect). As a workaround we now use st_blocks only if
st_blocks * 512 > st_size, this should fix ZFS problems while still
preserving accuracy for other filesystems.

The problem had appeared in r3900 (1.0.1).

Note: See TracTickets for help on using tickets.