Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
slash
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
slash
Commits
720e576c
Unverified
Commit
720e576c
authored
Jan 19, 2024
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fellow_cache: Prepare for an fdo pointer
parent
b44682ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
26 deletions
+30
-26
fellow_cache.c
src/fellow_cache.c
+30
-26
No files found.
src/fellow_cache.c
View file @
720e576c
...
...
@@ -345,6 +345,7 @@ static inline uint16_t \
SEGLIST_FIT_FUNC
(
disk
)
//struct fellow_disk_obj;
struct
fellow_cache_obj
;
struct
fellow_cache_seg
{
uint16_t
magic
;
...
...
@@ -372,7 +373,10 @@ struct fellow_cache_seg {
struct
fellow_cache_obj
*
fco
;
struct
fellow_disk_seg
*
disk_seg
;
struct
buddy_ptr_extent
alloc
;
size_t
len
;
// used size
union
{
size_t
fcs_len
;
// FCS_* used size
struct
fellow_disk_obj
*
fco_fdo
;
// FCO_* ptr to fdo
}
u
;
};
struct
fellow_cache_seglist
{
...
...
@@ -1392,7 +1396,7 @@ assert_cache_seg_consistency(const struct fellow_cache_seg *fcs)
#define FCOSA_NOMEM do { \
AZ(fcs->alloc.ptr); \
AZ(fcs->alloc.size); \
AZ(fcs->len); \
AZ(fcs->
u.fcs_
len); \
} while(0)
#define FCSA_MEM do { \
AN(fcs->alloc.ptr); \
...
...
@@ -1496,7 +1500,7 @@ fellow_cache_seg_free(struct buddy_returns *memret,
AZ
(
fcs
->
fcs_onlru
);
assert
(
fcs
->
refcnt
==
deref
);
fcs
->
refcnt
=
0
;
fcs
->
len
=
0
;
fcs
->
u
.
fcs_
len
=
0
;
/*
* at this point, the fcs is not consistent in all cases, e.g. FCS_EVICT
* has no memory - but this is the point where it does no longer exist
...
...
@@ -2805,10 +2809,10 @@ fellow_cache_seg_fini(const struct fellow_cache_seg *fcs)
CHECK_OBJ_NOTNULL
(
fds
,
FELLOW_DISK_SEG_MAGIC
);
AN
(
fcs
->
alloc
.
ptr
);
AN
(
fcs
->
len
);
assert
(
fcs
->
len
<=
fds
->
seg
.
size
);
fds
->
seg
.
size
=
fcs
->
len
;
fh
(
fds
->
fht
,
fds
->
fh
,
fcs
->
alloc
.
ptr
,
fcs
->
len
);
AN
(
fcs
->
u
.
fcs_
len
);
assert
(
fcs
->
u
.
fcs_
len
<=
fds
->
seg
.
size
);
fds
->
seg
.
size
=
fcs
->
u
.
fcs_
len
;
fh
(
fds
->
fht
,
fds
->
fh
,
fcs
->
alloc
.
ptr
,
fcs
->
u
.
fcs_
len
);
}
static
inline
void
...
...
@@ -2923,7 +2927,7 @@ fellow_cache_seg_unbusy(struct fellow_busy *fbo, struct fellow_cache_seg *fcs){
CHECK_OBJ_NOTNULL
(
fco
,
FELLOW_CACHE_OBJ_MAGIC
);
assert
(
fco
==
fbo
->
fco
);
AN
(
fcs
->
refcnt
);
AN
(
fcs
->
len
);
AN
(
fcs
->
u
.
fcs_
len
);
assert_fcos_transition
(
from
,
to
);
struct
fellow_lru_chgbatch
lcb
[
1
]
=
...
...
@@ -3316,9 +3320,9 @@ fellow_cache_seg_io_check(const struct fellow_cache *fc,
assert
(
fcs
->
alloc
.
size
==
asz
);
AN
(
fds
->
seg
.
off
);
AN
(
fds
->
seg
.
size
);
assert
(
fds
->
seg
.
size
>=
fcs
->
len
);
assert
(
fds
->
seg
.
size
>=
fcs
->
u
.
fcs_
len
);
assert
(
fds
->
seg
.
size
<=
asz
);
fcs
->
len
=
fds
->
seg
.
size
;
fcs
->
u
.
fcs_
len
=
fds
->
seg
.
size
;
// O_DIRECT alignment on 4K
AZ
((
uintptr_t
)
fcs
->
alloc
.
ptr
&
FELLOW_BLOCK_ALIGN
);
...
...
@@ -3425,7 +3429,7 @@ fellow_cache_seg_evict_locked(
assert
(
fcs
->
state
==
FCS_INCORE
);
*
alloc
=
fcs
->
alloc
;
fcs
->
alloc
=
buddy_ptr_extent_nil
;
fcs
->
len
=
0
;
fcs
->
u
.
fcs_
len
=
0
;
fcs
->
state
=
FCS_DISK
;
}
...
...
@@ -4060,7 +4064,7 @@ fellow_cache_seg_check(struct fellow_cache_seg *fcs)
CHECK_OBJ_NOTNULL
(
fds
,
FELLOW_DISK_SEG_MAGIC
);
#ifdef TODO_READ_ERR
if
((
fds
->
segnum
%
16
==
0
&&
FC_INJ
)
||
fhcmp
(
fds
->
fht
,
fds
->
fh
,
fcs
->
alloc
.
ptr
,
fcs
->
len
))
{
fhcmp
(
fds
->
fht
,
fds
->
fh
,
fcs
->
alloc
.
ptr
,
fcs
->
u
.
fcs_
len
))
{
err
=
"segment checksum error"
;
to
=
FCS_READFAIL
;
}
...
...
@@ -4754,16 +4758,16 @@ fellow_busy_obj_getspace(struct fellow_busy *fbo, size_t *sz, uint8_t **ptr)
fcs
=
fbo
->
body_seg
;
if
(
fcs
!=
NULL
&&
fcs
->
state
==
FCS_BUSY
)
{
AN
(
fcs
->
alloc
.
size
);
if
(
fcs
->
len
<
fcs
->
alloc
.
size
)
{
spc
=
fcs
->
alloc
.
size
-
fcs
->
len
;
if
(
fcs
->
u
.
fcs_
len
<
fcs
->
alloc
.
size
)
{
spc
=
fcs
->
alloc
.
size
-
fcs
->
u
.
fcs_
len
;
assert
(
spc
>
0
);
if
(
spc
<
*
sz
)
*
sz
=
spc
;
*
ptr
=
(
uint8_t
*
)
fcs
->
alloc
.
ptr
+
fcs
->
len
;
*
ptr
=
(
uint8_t
*
)
fcs
->
alloc
.
ptr
+
fcs
->
u
.
fcs_
len
;
return
(
FCR_OK
(
fbo
));
}
assert
(
fcs
->
len
==
fcs
->
alloc
.
size
);
assert
(
fcs
->
u
.
fcs_
len
==
fcs
->
alloc
.
size
);
unbusy
=
fcs
;
fcs
=
NULL
;
}
...
...
@@ -4831,9 +4835,9 @@ fellow_busy_obj_extend(struct fellow_busy *fbo, size_t l)
fcs
=
fbo
->
body_seg
;
CHECK_OBJ_NOTNULL
(
fcs
,
FELLOW_CACHE_SEG_MAGIC
);
assert
(
fcs
->
state
==
FCS_BUSY
);
fcs
->
len
+=
l
;
fcs
->
u
.
fcs_
len
+=
l
;
fbo
->
sz_returned
+=
l
;
assert
(
fcs
->
len
<=
fcs
->
alloc
.
size
);
assert
(
fcs
->
u
.
fcs_
len
<=
fcs
->
alloc
.
size
);
}
static
void
...
...
@@ -4932,7 +4936,7 @@ fellow_busy_obj_trimstore(struct fellow_busy *fbo)
assert_cache_seg_consistency
(
fcs
);
if
(
fcs
->
state
==
FCS_BUSY
)
{
assert
(
fcs
->
len
<=
fcs
->
alloc
.
size
);
assert
(
fcs
->
u
.
fcs_
len
<=
fcs
->
alloc
.
size
);
AN
(
fdr
);
/*
...
...
@@ -4946,7 +4950,7 @@ fellow_busy_obj_trimstore(struct fellow_busy *fbo)
}
else
{
assert
(
fcs
->
state
==
FCS_USABLE
);
AZ
(
fcs
->
alloc
.
size
);
AZ
(
fcs
->
len
);
AZ
(
fcs
->
u
.
fcs_
len
);
}
if
(
fdr
)
{
...
...
@@ -4954,7 +4958,7 @@ fellow_busy_obj_trimstore(struct fellow_busy *fbo)
// fbr offset where fcs starts
base
=
fbr
->
len
-
fcs
->
alloc
.
size
;
nsz
=
base
+
fcs
->
len
;
nsz
=
base
+
fcs
->
u
.
fcs_
len
;
if
(
nsz
==
0
)
fellow_busy_region_free
(
fbo
,
fdr
);
...
...
@@ -4981,8 +4985,8 @@ fellow_busy_obj_trimstore(struct fellow_busy *fbo)
// dsk/membuddy aligment must match
assert
(
nsz
==
fcs
->
alloc
.
size
);
fcs
->
disk_seg
->
seg
.
size
=
fcs
->
alloc
.
size
;
assert
(
fcs
->
len
<=
fcs
->
alloc
.
size
);
if
(
fcs
->
len
==
0
)
{
assert
(
fcs
->
u
.
fcs_
len
<=
fcs
->
alloc
.
size
);
if
(
fcs
->
u
.
fcs_
len
==
0
)
{
fcs
->
alloc
.
ptr
=
NULL
;
AZ
(
fcs
->
disk_seg
->
seg
.
size
);
fcs
->
disk_seg
->
seg
.
off
=
0
;
...
...
@@ -5758,7 +5762,7 @@ fellow_cache_obj_getattr(struct fellow_cache *fc,
return (NULL); \
fellow_cache_seg_auxattr_ref_in(fc, fcs); \
XXXAZ(fellow_cache_seg_check(fcs)); \
*len = fcs->len; \
*len = fcs->
u.fcs_
len; \
return (fcs->alloc.ptr); \
}
#include "tbl/fellow_obj_attr.h"
...
...
@@ -5839,8 +5843,8 @@ fellow_busy_setattr(struct fellow_busy *fbo, enum obj_attr attr,
if (! fellow_busy_seg_alloc(fbo, fcs, len)) \
break; \
assert(fcs->alloc.size >= len); \
AZ(fcs->len); \
fcs->len = len; \
AZ(fcs->
u.fcs_
len); \
fcs->
u.fcs_
len = len; \
retval = fcs->alloc.ptr; \
memcpy(retval, ptr, len); \
fellow_cache_seg_unbusy(fbo, fcs); \
...
...
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