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
35a9e755
Commit
35a9e755
authored
Sep 15, 2014
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Push busyobj further backwards
parent
80459a2c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
33 deletions
+27
-33
stevedore.c
bin/varnishd/storage/stevedore.c
+18
-16
storage.h
bin/varnishd/storage/storage.h
+2
-3
storage_persistent.c
bin/varnishd/storage/storage_persistent.c
+7
-14
No files found.
bin/varnishd/storage/stevedore.c
View file @
35a9e755
...
...
@@ -189,13 +189,12 @@ STV_alloc(struct stevedore *stv, size_t size)
*/
struct
object
*
STV_MkObject
(
struct
stevedore
*
stv
,
struct
busyobj
*
bo
,
void
*
ptr
)
STV_MkObject
(
struct
stevedore
*
stv
,
struct
objcore
*
oc
,
void
*
ptr
)
{
struct
object
*
o
;
CHECK_OBJ_NOTNULL
(
stv
,
STEVEDORE_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
->
fetch_objcore
,
OBJCORE_MAGIC
);
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
assert
(
PAOK
(
ptr
));
...
...
@@ -205,13 +204,12 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo, void *ptr)
VTAILQ_INIT
(
&
o
->
body
->
list
);
bo
->
fetch_objcore
->
stobj
->
magic
=
STOREOBJ_MAGIC
;
bo
->
fetch_objcore
->
stobj
->
stevedore
=
stv
;
oc
->
stobj
->
magic
=
STOREOBJ_MAGIC
;
oc
->
stobj
->
stevedore
=
stv
;
o
->
body
->
stevedore
=
stv
;
AN
(
stv
->
methods
);
bo
->
fetch_objcore
->
stobj
->
priv
=
o
;
bo
->
fetch_objcore
->
stobj
->
priv2
=
(
uintptr_t
)
stv
;
VSLb
(
bo
->
vsl
,
SLT_Storage
,
"%s %s"
,
stv
->
name
,
stv
->
ident
);
oc
->
stobj
->
priv
=
o
;
oc
->
stobj
->
priv2
=
(
uintptr_t
)
stv
;
return
(
o
);
}
...
...
@@ -221,12 +219,12 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo, void *ptr)
*/
struct
object
*
stv_default_allocobj
(
struct
stevedore
*
stv
,
struct
busyobj
*
bo
,
unsigned
ltot
)
stv_default_allocobj
(
struct
stevedore
*
stv
,
struct
objcore
*
oc
,
unsigned
ltot
)
{
struct
object
*
o
;
struct
storage
*
st
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ
_MAGIC
);
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE
_MAGIC
);
st
=
stv
->
alloc
(
stv
,
ltot
);
if
(
st
==
NULL
)
return
(
NULL
);
...
...
@@ -234,11 +232,10 @@ stv_default_allocobj(struct stevedore *stv, struct busyobj *bo, unsigned ltot)
stv
->
free
(
st
);
return
(
NULL
);
}
o
=
STV_MkObject
(
stv
,
bo
,
st
->
ptr
);
o
=
STV_MkObject
(
stv
,
oc
,
st
->
ptr
);
CHECK_OBJ_NOTNULL
(
o
,
OBJECT_MAGIC
);
st
->
len
=
sizeof
(
*
o
);
o
->
objstore
=
st
;
bo
->
stats
->
n_object
++
;
return
(
o
);
}
...
...
@@ -252,12 +249,14 @@ int
STV_NewObject
(
struct
busyobj
*
bo
,
const
char
*
hint
,
unsigned
wsl
)
{
struct
object
*
o
;
struct
objcore
*
oc
;
struct
stevedore
*
stv
,
*
stv0
;
unsigned
ltot
;
int
i
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
->
fetch_objcore
,
OBJCORE_MAGIC
);
oc
=
bo
->
fetch_objcore
;
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
assert
(
wsl
>
0
);
wsl
=
PRNDUP
(
wsl
);
...
...
@@ -265,12 +264,12 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
stv
=
stv0
=
stv_pick_stevedore
(
bo
->
vsl
,
&
hint
);
AN
(
stv
->
allocobj
);
o
=
stv
->
allocobj
(
stv
,
bo
,
ltot
);
o
=
stv
->
allocobj
(
stv
,
oc
,
ltot
);
if
(
o
==
NULL
&&
hint
==
NULL
)
{
do
{
stv
=
stv_pick_stevedore
(
bo
->
vsl
,
&
hint
);
AN
(
stv
->
allocobj
);
o
=
stv
->
allocobj
(
stv
,
bo
,
ltot
);
o
=
stv
->
allocobj
(
stv
,
oc
,
ltot
);
}
while
(
o
==
NULL
&&
stv
!=
stv0
);
}
if
(
o
==
NULL
)
{
...
...
@@ -278,13 +277,16 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
for
(
i
=
0
;
o
==
NULL
&&
i
<
cache_param
->
nuke_limit
;
i
++
)
{
if
(
EXP_NukeOne
(
bo
->
vsl
,
bo
->
stats
,
stv
->
lru
)
==
-
1
)
break
;
o
=
stv
->
allocobj
(
stv
,
bo
,
ltot
);
o
=
stv
->
allocobj
(
stv
,
oc
,
ltot
);
}
}
if
(
o
==
NULL
)
return
(
0
);
bo
->
stats
->
n_object
++
;
VSLb
(
bo
->
vsl
,
SLT_Storage
,
"%s %s"
,
oc
->
stobj
->
stevedore
->
name
,
oc
->
stobj
->
stevedore
->
ident
);
CHECK_OBJ_NOTNULL
(
o
,
OBJECT_MAGIC
);
CHECK_OBJ_NOTNULL
(
o
->
objstore
,
STORAGE_MAGIC
);
AN
(
stv
->
methods
);
...
...
bin/varnishd/storage/storage.h
View file @
35a9e755
...
...
@@ -61,7 +61,7 @@ typedef void storage_open_f(const struct stevedore *);
typedef
struct
storage
*
storage_alloc_f
(
struct
stevedore
*
,
size_t
size
);
typedef
void
storage_trim_f
(
struct
storage
*
,
size_t
size
,
int
move_ok
);
typedef
void
storage_free_f
(
struct
storage
*
);
typedef
struct
object
*
storage_allocobj_f
(
struct
stevedore
*
,
struct
busyobj
*
,
typedef
struct
object
*
storage_allocobj_f
(
struct
stevedore
*
,
struct
objcore
*
,
unsigned
ltot
);
typedef
void
storage_close_f
(
const
struct
stevedore
*
);
typedef
void
storage_signal_close_f
(
const
struct
stevedore
*
);
...
...
@@ -122,8 +122,7 @@ extern struct stevedore *stv_transient;
int
STV_GetFile
(
const
char
*
fn
,
int
*
fdp
,
const
char
**
fnp
,
const
char
*
ctx
);
uintmax_t
STV_FileSize
(
int
fd
,
const
char
*
size
,
unsigned
*
granularity
,
const
char
*
ctx
);
struct
object
*
STV_MkObject
(
struct
stevedore
*
stv
,
struct
busyobj
*
bo
,
void
*
ptr
);
struct
object
*
STV_MkObject
(
struct
stevedore
*
,
struct
objcore
*
,
void
*
ptr
);
struct
lru
*
LRU_Alloc
(
void
);
void
LRU_Free
(
struct
lru
*
lru
);
...
...
bin/varnishd/storage/storage_persistent.c
View file @
35a9e755
...
...
@@ -505,23 +505,20 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size,
*/
static
struct
object
*
smp_allocobj
(
struct
stevedore
*
stv
,
struct
busyobj
*
bo
,
unsigned
ltot
)
smp_allocobj
(
struct
stevedore
*
stv
,
struct
objcore
*
oc
,
unsigned
ltot
)
{
struct
object
*
o
;
struct
storage
*
st
;
struct
smp_sc
*
sc
;
struct
smp_seg
*
sg
;
struct
smp_object
*
so
;
struct
objcore
*
oc
;
unsigned
objidx
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ
_MAGIC
);
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE
_MAGIC
);
CAST_OBJ_NOTNULL
(
sc
,
stv
->
priv
,
SMP_SC_MAGIC
);
/* Don't entertain already dead objects */
if
((
bo
->
fetch_objcore
->
exp
.
ttl
+
bo
->
fetch_objcore
->
exp
.
grace
+
bo
->
fetch_objcore
->
exp
.
keep
)
<=
0
.)
if
((
oc
->
exp
.
ttl
+
oc
->
exp
.
grace
+
oc
->
exp
.
keep
)
<=
0
.)
return
(
NULL
);
ltot
=
IRNUP
(
sc
,
ltot
);
...
...
@@ -532,16 +529,12 @@ smp_allocobj(struct stevedore *stv, struct busyobj *bo, unsigned ltot)
assert
(
st
->
space
>=
ltot
);
o
=
STV_MkObject
(
stv
,
bo
,
st
->
ptr
);
AN
(
bo
->
fetch_objcore
->
stobj
->
stevedore
);
assert
(
bo
->
fetch_objcore
->
stobj
->
stevedore
==
stv
);
o
=
STV_MkObject
(
stv
,
oc
,
st
->
ptr
);
AN
(
oc
->
stobj
->
stevedore
);
assert
(
oc
->
stobj
->
stevedore
==
stv
);
CHECK_OBJ_NOTNULL
(
o
,
OBJECT_MAGIC
);
o
->
objstore
=
st
;
st
->
len
=
sizeof
(
*
o
);
bo
->
stats
->
n_object
++
;
oc
=
bo
->
fetch_objcore
;
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
Lck_Lock
(
&
sc
->
mtx
);
sg
->
nfixed
++
;
...
...
@@ -550,7 +543,7 @@ smp_allocobj(struct stevedore *stv, struct busyobj *bo, unsigned ltot)
/* We have to do this somewhere, might as well be here... */
assert
(
sizeof
so
->
hash
==
DIGEST_LEN
);
memcpy
(
so
->
hash
,
oc
->
objhead
->
digest
,
DIGEST_LEN
);
so
->
exp
=
bo
->
fetch_objcore
->
exp
;
so
->
exp
=
oc
->
exp
;
so
->
ptr
=
(
uint8_t
*
)
o
-
sc
->
base
;
so
->
ban
=
BAN_Time
(
oc
->
ban
);
...
...
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