fellow_cache: Use new fdo pointer (but no change yet)

parent 720e576c
...@@ -345,7 +345,6 @@ static inline uint16_t \ ...@@ -345,7 +345,6 @@ static inline uint16_t \
SEGLIST_FIT_FUNC(disk) SEGLIST_FIT_FUNC(disk)
//struct fellow_disk_obj;
struct fellow_cache_obj; struct fellow_cache_obj;
struct fellow_cache_seg { struct fellow_cache_seg {
uint16_t magic; uint16_t magic;
...@@ -1087,10 +1086,12 @@ fellow_busy_io_submit(struct fellow_busy_io *fbio) ...@@ -1087,10 +1086,12 @@ fellow_busy_io_submit(struct fellow_busy_io *fbio)
static inline struct fellow_disk_obj * static inline struct fellow_disk_obj *
fellow_disk_obj(const struct fellow_cache_seg *fcs) fellow_disk_obj(const struct fellow_cache_seg *fcs)
{ {
AN(fcs);
AN(fcs->alloc.ptr); CHECK_OBJ_NOTNULL(fcs, FELLOW_CACHE_SEG_MAGIC);
assert(FCOS_HIGH(fcs->state) == FCO_HIGH); assert(FCOS_HIGH(fcs->state) == FCO_HIGH);
return (fcs->alloc.ptr); if (fcs->alloc.ptr != NULL)
assert(fcs->alloc.ptr == fcs->u.fco_fdo);
return (fcs->u.fco_fdo);
} }
static const char * static const char *
...@@ -1180,16 +1181,18 @@ fellow_disk_obj_trim(const struct fellow_cache *fc, ...@@ -1180,16 +1181,18 @@ fellow_disk_obj_trim(const struct fellow_cache *fc,
mem = buddy_alloc1_ptr_extent_wait(fc->membuddy, mem = buddy_alloc1_ptr_extent_wait(fc->membuddy,
FEP_SPCPRI, trim_sz, 0); FEP_SPCPRI, trim_sz, 0);
if (mem.ptr) { if (mem.ptr) {
memcpy(mem.ptr, fcs->alloc.ptr, trim_sz); memcpy(mem.ptr, fdo, trim_sz);
buddy_return1_ptr_extent(fc->membuddy, buddy_return1_ptr_extent(fc->membuddy,
&fcs->alloc); &fcs->alloc);
fcs->alloc = mem; fcs->alloc = mem;
fcs->u.fco_fdo = mem.ptr;
break; break;
} }
} }
/* FALLTHROUGH */ /* FALLTHROUGH */
case FCO_WRITING: case FCO_WRITING:
buddy_trim1_ptr_extent(fc->membuddy, &fcs->alloc, trim_sz); buddy_trim1_ptr_extent(fc->membuddy, &fcs->alloc, trim_sz);
assert(fdo == fcs->alloc.ptr);
break; break;
default: default:
WRONG("fcs->state to call fellow_disk_obj_trim()"); WRONG("fcs->state to call fellow_disk_obj_trim()");
...@@ -1403,8 +1406,11 @@ assert_cache_seg_consistency(const struct fellow_cache_seg *fcs) ...@@ -1403,8 +1406,11 @@ assert_cache_seg_consistency(const struct fellow_cache_seg *fcs)
AN(fcs->alloc.size); \ AN(fcs->alloc.size); \
} while(0) } while(0)
#define FCOA_MEM do { \ #define FCOA_MEM do { \
AN(fcs->alloc.ptr); \ /* can be NULL for embedded fdo */ \
if (fcs->alloc.ptr != NULL) { \
AN(fcs->alloc.size); \ AN(fcs->alloc.size); \
assert(fcs->alloc.ptr == fcs->u.fco_fdo); \
} \
} while(0) } while(0)
#define FDSA_NULL AZ(fcs->disk_seg) #define FDSA_NULL AZ(fcs->disk_seg)
#define FDSA_MAY CHECK_OBJ_ORNULL(fcs->disk_seg, FELLOW_DISK_SEG_MAGIC) #define FDSA_MAY CHECK_OBJ_ORNULL(fcs->disk_seg, FELLOW_DISK_SEG_MAGIC)
...@@ -2156,6 +2162,7 @@ fellow_cache_obj_new( ...@@ -2156,6 +2162,7 @@ fellow_cache_obj_new(
fellow_cache_seg_init(fcs, fco, FCO_INIT); fellow_cache_seg_init(fcs, fco, FCO_INIT);
fcs->alloc = fdo_mem; fcs->alloc = fdo_mem;
fcs->u.fco_fdo = fdo;
return (FCR_OK(fco)); return (FCR_OK(fco));
err: err:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment