Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
1f4067c9
Commit
1f4067c9
authored
Oct 07, 2014
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use VFIL_fsinfo in STV_FileSize, and drop the old implementation
parent
22ad1c95
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
38 deletions
+10
-38
stevedore_utils.c
bin/varnishd/storage/stevedore_utils.c
+10
-38
No files found.
bin/varnishd/storage/stevedore_utils.c
View file @
1f4067c9
...
...
@@ -54,6 +54,7 @@
#include "storage/storage.h"
#include "vnum.h"
#include "vfil.h"
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
...
...
@@ -132,38 +133,6 @@ STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx)
return
(
retval
);
}
/*--------------------------------------------------------------------
* Figure out how much space is in a filesystem
*/
static
uintmax_t
stv_fsspace
(
int
fd
,
unsigned
*
bs
)
{
uintmax_t
bsize
,
bavail
;
#if defined(HAVE_SYS_STATVFS_H)
struct
statvfs
fsst
;
AZ
(
fstatvfs
(
fd
,
&
fsst
));
bsize
=
fsst
.
f_frsize
;
bavail
=
fsst
.
f_bavail
;
#elif defined(HAVE_SYS_MOUNT_H) || defined(HAVE_SYS_VFS_H)
struct
statfs
fsst
;
AZ
(
fstatfs
(
sc
->
fd
,
&
fsst
));
bsize
=
fsst
.
f_bsize
;
bavail
=
fsst
.
f_bavail
;
#else
#error no struct statfs / struct statvfs
#endif
/* We use units of the larger of filesystem blocksize and pagesize */
if
(
*
bs
<
bsize
)
*
bs
=
bsize
;
XXXAZ
(
*
bs
%
bsize
);
return
(
bsize
*
bavail
);
}
/*--------------------------------------------------------------------
* Decide file size.
*
...
...
@@ -183,12 +152,16 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx)
off_t
o
;
struct
stat
st
;
AN
(
granularity
);
AN
(
ctx
);
AZ
(
fstat
(
fd
,
&
st
));
xxxassert
(
S_ISREG
(
st
.
st_mode
));
bs
=
*
granularity
;
fssize
=
stv_fsspace
(
fd
,
&
bs
);
XXXAZ
(
bs
%
*
granularity
);
AZ
(
VFIL_fsinfo
(
fd
,
&
bs
,
&
fssize
,
NULL
));
/* Increase granularity if it is lower than the filesystem block size */
if
(
*
granularity
<
bs
)
*
granularity
=
bs
;
if
((
size
==
NULL
||
*
size
==
'\0'
)
&&
st
.
st_size
!=
0
)
{
/*
...
...
@@ -235,9 +208,8 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx)
l
=
INT32_MAX
;
}
/*
round down to multiple of filesystem blocksize or pagesize
*/
l
-=
(
l
%
bs
);
/*
Round down
*/
l
-=
(
l
%
*
granularity
);
*
granularity
=
bs
;
return
(
l
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment