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
df98c718
Unverified
Commit
df98c718
authored
Jul 19, 2024
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fellow_cache: refactor fcs extension elements
parent
a294a4da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
36 deletions
+47
-36
fellow_cache.c
src/fellow_cache.c
+47
-36
No files found.
src/fellow_cache.c
View file @
df98c718
...
...
@@ -346,6 +346,20 @@ static inline uint16_t \
return (uint16_t)sz; \
}
/* type specific union elements of cache segs */
struct
fellow_cache_seg_fcs
{
size_t
len
;
// FCS_* used size
};
struct
fellow_cache_seg_fco
{
struct
fellow_disk_obj
*
fdo
;
// FCO_* ptr to fdo
};
union
fellow_cache_seg_ext
{
struct
fellow_cache_seg_fcs
fcs
;
struct
fellow_cache_seg_fco
fco
;
};
SEGLIST_FIT_FUNC
(
disk
)
struct
fellow_cache_obj
;
...
...
@@ -376,10 +390,7 @@ struct fellow_cache_seg {
struct
buddy_ptr_extent
alloc
;
struct
fellow_disk_seg
*
disk_seg
;
union
{
size_t
fcs_len
;
// FCS_* used size
struct
fellow_disk_obj
*
fco_fdo
;
// FCO_* ptr to fdo
}
u
;
union
fellow_cache_seg_ext
u
;
};
/*
...
...
@@ -1196,8 +1207,8 @@ fellow_disk_obj(const struct fellow_cache_seg *fcs)
CHECK_OBJ_NOTNULL
(
fcs
,
FELLOW_CACHE_SEG_MAGIC
);
assert
(
FCOS_HIGH
(
fcs
->
state
)
==
FCO_HIGH
);
if
(
fcs
->
alloc
.
ptr
!=
NULL
)
assert
(
fcs
->
alloc
.
ptr
==
fcs
->
u
.
fco
_
fdo
);
return
(
fcs
->
u
.
fco
_
fdo
);
assert
(
fcs
->
alloc
.
ptr
==
fcs
->
u
.
fco
.
fdo
);
return
(
fcs
->
u
.
fco
.
fdo
);
}
static
const
char
*
...
...
@@ -1312,7 +1323,7 @@ fellow_disk_obj_trim(const struct fellow_cache *fc,
buddy_return1_ptr_extent
(
fc
->
membuddy
,
&
fcs
->
alloc
);
fcs
->
alloc
=
mem
;
fcs
->
u
.
fco
_
fdo
=
mem
.
ptr
;
fcs
->
u
.
fco
.
fdo
=
mem
.
ptr
;
break
;
}
}
...
...
@@ -1526,7 +1537,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->u.fcs
_
len); \
AZ(fcs->u.fcs
.
len); \
} while(0)
#define FCSA_MEM do { \
AN(fcs->alloc.ptr); \
...
...
@@ -1536,7 +1547,7 @@ assert_cache_seg_consistency(const struct fellow_cache_seg *fcs)
/* can be NULL for embedded fdo */
\
if (fcs->alloc.ptr != NULL) { \
AN(fcs->alloc.size); \
assert(fcs->alloc.ptr == fcs->u.fco
_
fdo); \
assert(fcs->alloc.ptr == fcs->u.fco
.
fdo); \
} \
} while(0)
#define FDSA_NULL AZ(fcs->disk_seg)
...
...
@@ -1633,7 +1644,7 @@ fellow_cache_seg_free(struct buddy_returns *memret,
AZ
(
fcs
->
fcs_onlru
);
assert
(
fcs
->
refcnt
==
deref
);
fcs
->
refcnt
=
0
;
fcs
->
u
.
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
...
...
@@ -2462,7 +2473,7 @@ fellow_cache_obj_new(
fellow_cache_seg_init
(
fcs
,
fco
,
FCO_INIT
);
fcs
->
alloc
=
fdo_mem
;
fcs
->
u
.
fco
_
fdo
=
fdo
;
fcs
->
u
.
fco
.
fdo
=
fdo
;
return
(
fellow_cache_obj_res
(
fc
,
fco
,
FCR_OK
(
fco
)));
}
...
...
@@ -3130,10 +3141,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
->
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
);
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
...
...
@@ -3257,7 +3268,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
->
u
.
fcs
_
len
);
AN
(
fcs
->
u
.
fcs
.
len
);
assert_fcos_transition
(
from
,
to
);
struct
fellow_lru_chgbatch
lcb
[
1
]
=
...
...
@@ -3654,9 +3665,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
->
u
.
fcs
_
len
);
assert
(
fds
->
seg
.
size
>=
fcs
->
u
.
fcs
.
len
);
assert
(
fds
->
seg
.
size
<=
asz
);
fcs
->
u
.
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
);
...
...
@@ -3763,7 +3774,7 @@ fellow_cache_seg_evict_locked(
assert
(
fcs
->
state
==
FCS_INCORE
);
*
alloc
=
fcs
->
alloc
;
fcs
->
alloc
=
buddy_ptr_extent_nil
;
fcs
->
u
.
fcs
_
len
=
0
;
fcs
->
u
.
fcs
.
len
=
0
;
fcs
->
state
=
FCS_DISK
;
}
...
...
@@ -4406,7 +4417,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
->
u
.
fcs
_
len
))
{
fhcmp
(
fds
->
fht
,
fds
->
fh
,
fcs
->
alloc
.
ptr
,
fcs
->
u
.
fcs
.
len
))
{
err
=
"segment checksum error"
;
to
=
FCS_READFAIL
;
}
...
...
@@ -5164,16 +5175,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
->
u
.
fcs
_
len
<
fcs
->
alloc
.
size
)
{
spc
=
fcs
->
alloc
.
size
-
fcs
->
u
.
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
->
u
.
fcs
_
len
;
*
ptr
=
(
uint8_t
*
)
fcs
->
alloc
.
ptr
+
fcs
->
u
.
fcs
.
len
;
return
(
FCR_OK
(
fbo
));
}
assert
(
fcs
->
u
.
fcs
_
len
==
fcs
->
alloc
.
size
);
assert
(
fcs
->
u
.
fcs
.
len
==
fcs
->
alloc
.
size
);
unbusy
=
fcs
;
fcs
=
NULL
;
}
...
...
@@ -5241,9 +5252,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
->
u
.
fcs
_
len
+=
l
;
fcs
->
u
.
fcs
.
len
+=
l
;
fbo
->
sz_returned
+=
l
;
assert
(
fcs
->
u
.
fcs
_
len
<=
fcs
->
alloc
.
size
);
assert
(
fcs
->
u
.
fcs
.
len
<=
fcs
->
alloc
.
size
);
}
static
void
...
...
@@ -5345,7 +5356,7 @@ fellow_busy_obj_trimstore(struct fellow_busy *fbo)
assert_cache_seg_consistency
(
fcs
);
if
(
fcs
->
state
==
FCS_BUSY
)
{
assert
(
fcs
->
u
.
fcs
_
len
<=
fcs
->
alloc
.
size
);
assert
(
fcs
->
u
.
fcs
.
len
<=
fcs
->
alloc
.
size
);
AN
(
fdr
);
/*
...
...
@@ -5359,7 +5370,7 @@ fellow_busy_obj_trimstore(struct fellow_busy *fbo)
}
else
{
assert
(
fcs
->
state
==
FCS_USABLE
);
AZ
(
fcs
->
alloc
.
size
);
AZ
(
fcs
->
u
.
fcs
_
len
);
AZ
(
fcs
->
u
.
fcs
.
len
);
}
if
(
fdr
)
{
...
...
@@ -5367,7 +5378,7 @@ fellow_busy_obj_trimstore(struct fellow_busy *fbo)
// fbr offset where fcs starts
base
=
fbr
->
len
-
fcs
->
alloc
.
size
;
nsz
=
base
+
fcs
->
u
.
fcs
_
len
;
nsz
=
base
+
fcs
->
u
.
fcs
.
len
;
if
(
nsz
==
0
)
fellow_busy_region_free
(
fbo
,
fdr
);
...
...
@@ -5394,8 +5405,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
->
u
.
fcs
_
len
<=
fcs
->
alloc
.
size
);
if
(
fcs
->
u
.
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
;
...
...
@@ -5937,7 +5948,7 @@ struct objcore **ocp, uintptr_t priv2, unsigned crit)
if
(
spc
>=
sz
)
{
memcpy
(
ptr
,
fdo
,
sz
);
fdo
=
fcs
->
u
.
fco
_
fdo
=
(
void
*
)
ptr
;
fdo
=
fcs
->
u
.
fco
.
fdo
=
(
void
*
)
ptr
;
AN
(
buddy_return_ptr_extent
(
rets
,
&
fcs
->
alloc
));
nsz
+=
sz
;
...
...
@@ -6304,7 +6315,7 @@ fellow_cache_seg_panic(struct vsb *vsb, const struct fellow_cache_seg *fcs,
fellow_disk_seg_panic
(
vsb
,
fcs
->
disk_seg
,
"disk_seg"
);
fellow_cache_buddy_ptr_extent_panic
(
vsb
,
fcs
->
alloc
,
"alloc"
);
VSB_printf
(
vsb
,
"union { .fcs_len = %zu, .fco_fdo = %p },
\n
"
,
fcs
->
u
.
fcs
_len
,
fcs
->
u
.
fco_
fdo
);
fcs
->
u
.
fcs
.
len
,
fcs
->
u
.
fco
.
fdo
);
VSB_indent
(
vsb
,
-
2
);
VSB_cat
(
vsb
,
"},
\n
"
);
}
...
...
@@ -6487,7 +6498,7 @@ fellow_cache_obj_getattr(struct fellow_cache *fc,
fcr = FCR_IOFAIL(err); \
break; \
} \
*len = fcs->u.fcs
_
len; \
*len = fcs->u.fcs
.
len; \
fcr = FCR_OK(fcs->alloc.ptr); \
break; \
}
...
...
@@ -6568,8 +6579,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->u.fcs
_
len); \
fcs->u.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