Mercurial > hg > nginx
comparison src/os/unix/ngx_files.c @ 7670:ccb5ff87ab3e
Cache: introduced min_free cache clearing.
Clearing cache based on free space left on a file system is
expected to allow better disk utilization in some cases, notably
when disk space might be also used for something other than nginx
cache (including nginx own temporary files) and while loading
cache (when cache size might be inaccurate for a while, effectively
disabling max_size cache clearing).
Based on a patch by Adam Bambuch.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 22 Jun 2020 18:03:00 +0300 |
parents | 0a04e5e4c40b |
children | e88cdaa0f1ff |
comparison
equal
deleted
inserted
replaced
7669:52b34c3f89b4 | 7670:ccb5ff87ab3e |
---|---|
882 #endif | 882 #endif |
883 | 883 |
884 return (size_t) fs.f_bsize; | 884 return (size_t) fs.f_bsize; |
885 } | 885 } |
886 | 886 |
887 | |
888 off_t | |
889 ngx_fs_available(u_char *name) | |
890 { | |
891 struct statfs fs; | |
892 | |
893 if (statfs((char *) name, &fs) == -1) { | |
894 return NGX_MAX_OFF_T_VALUE; | |
895 } | |
896 | |
897 return (off_t) fs.f_bavail * fs.f_bsize; | |
898 } | |
899 | |
887 #elif (NGX_HAVE_STATVFS) | 900 #elif (NGX_HAVE_STATVFS) |
888 | 901 |
889 size_t | 902 size_t |
890 ngx_fs_bsize(u_char *name) | 903 ngx_fs_bsize(u_char *name) |
891 { | 904 { |
906 #endif | 919 #endif |
907 | 920 |
908 return (size_t) fs.f_frsize; | 921 return (size_t) fs.f_frsize; |
909 } | 922 } |
910 | 923 |
924 | |
925 off_t | |
926 ngx_fs_available(u_char *name) | |
927 { | |
928 struct statvfs fs; | |
929 | |
930 if (statvfs((char *) name, &fs) == -1) { | |
931 return NGX_MAX_OFF_T_VALUE; | |
932 } | |
933 | |
934 return (off_t) fs.f_bavail * fs.f_frsize; | |
935 } | |
936 | |
911 #else | 937 #else |
912 | 938 |
913 size_t | 939 size_t |
914 ngx_fs_bsize(u_char *name) | 940 ngx_fs_bsize(u_char *name) |
915 { | 941 { |
916 return 512; | 942 return 512; |
917 } | 943 } |
918 | 944 |
919 #endif | 945 |
946 off_t | |
947 ngx_fs_available(u_char *name) | |
948 { | |
949 return NGX_MAX_OFF_T_VALUE; | |
950 } | |
951 | |
952 #endif |