Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-14073 dfuse: Move writeback caching from kernel to dfuse. #12729

Merged
merged 40 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1917a8d
DAOS-14073 dfuse: Move writeback caching from kernel to dfuse.
ashleypittman Jul 28, 2023
841ce5f
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Aug 8, 2023
377a6b2
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Aug 10, 2023
9cc1c45
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Sep 7, 2023
6c7fe85
Use a rwlock to flush.
ashleypittman Sep 7, 2023
03b8de6
Add more flush calls.
ashleypittman Sep 7, 2023
4255d3c
Test compile
ashleypittman Sep 7, 2023
bd347ba
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Oct 10, 2023
cfdc60c
Use release define to enable debugging.
ashleypittman Oct 10, 2023
fa2eaa2
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Oct 31, 2023
d59c603
Remove debugging.
ashleypittman Oct 31, 2023
25683d8
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Nov 13, 2023
020767f
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Nov 13, 2023
355d94b
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Nov 17, 2023
65e2455
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Nov 21, 2023
f4d6026
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Dec 8, 2023
d8dc076
Use other macro for new flush functions.
ashleypittman Dec 8, 2023
d6696f4
Fix formatting.
ashleypittman Dec 8, 2023
83431d3
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Dec 21, 2023
6a88f68
Only hold hte lock if wbb cache is being used.
ashleypittman Dec 21, 2023
cf2b80f
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Jan 11, 2024
f213f33
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Jan 12, 2024
1a3d84b
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Jan 15, 2024
5f551ed
Only take the lock once
ashleypittman Jan 15, 2024
29340c9
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Jan 19, 2024
0c77d4e
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Jan 25, 2024
3d2a2cb
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Feb 8, 2024
96d8129
Only flush files.
ashleypittman Feb 13, 2024
071aae8
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Feb 13, 2024
2d85959
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Feb 15, 2024
faa8429
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Feb 16, 2024
8923436
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Feb 23, 2024
3d2e1df
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Feb 27, 2024
a606e40
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Mar 5, 2024
aec576a
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Mar 18, 2024
c113aa8
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Mar 21, 2024
ad68c6b
Fix indentation.
ashleypittman Mar 21, 2024
e9730d4
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Apr 5, 2024
0b6be3d
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Apr 9, 2024
1bdb650
Merge branch 'master' into amd/dfuse-write-cache
ashleypittman Apr 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions src/client/dfuse/dfuse_fuseops.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,54 +53,48 @@ dfuse_show_flags(void *handle, unsigned int in)
DFUSE_TRA_WARNING(handle, "Unknown flags %#x", in);
}

/* Called on filesystem init. It has the ability to both observe configuration
* options, but also to modify them. As we do not use the FUSE command line
* parsing this is where we apply tunables.
/* Called on filesystem init. It has the ability to both observe configuration options, but also to
* modify them. As we do not use the FUSE command line parsing this is where we apply tunables.
*/
static void
dfuse_fuse_init(void *arg, struct fuse_conn_info *conn)
{
struct dfuse_info *fs_handle = arg;
struct dfuse_info *dfuse_info = arg;

DFUSE_TRA_INFO(fs_handle, "Fuse configuration");
DFUSE_TRA_INFO(dfuse_info, "Fuse configuration");

DFUSE_TRA_INFO(fs_handle, "Proto %d %d", conn->proto_major, conn->proto_minor);
DFUSE_TRA_INFO(dfuse_info, "Proto %d %d", conn->proto_major, conn->proto_minor);

/* These are requests dfuse makes to the kernel, but are then capped by the kernel itself,
* for max_read zero means "as large as possible" which is what we want, but then dfuse
* does not know how large to pre-allocate any buffers.
* for max_read zero means "as large as possible" which is what we want, but then dfuse does
* not know how large to pre-allocate any buffers.
*/
DFUSE_TRA_INFO(fs_handle, "max read %#x", conn->max_read);
DFUSE_TRA_INFO(fs_handle, "max write %#x", conn->max_write);
DFUSE_TRA_INFO(fs_handle, "readahead %#x", conn->max_readahead);
DFUSE_TRA_INFO(dfuse_info, "max read %#x", conn->max_read);
DFUSE_TRA_INFO(dfuse_info, "max write %#x", conn->max_write);
DFUSE_TRA_INFO(dfuse_info, "readahead %#x", conn->max_readahead);

#if HAVE_CACHE_READDIR
DFUSE_TRA_INFO(fs_handle, "kernel readdir cache support compiled in");
DFUSE_TRA_INFO(dfuse_info, "kernel readdir cache support compiled in");
#else
DFUSE_TRA_INFO(fs_handle, "no support for kernel readdir cache available");
DFUSE_TRA_INFO(dfuse_info, "no support for kernel readdir cache available");
#endif

DFUSE_TRA_INFO(fs_handle, "Capability supported by kernel %#x", conn->capable);
DFUSE_TRA_INFO(dfuse_info, "Capability supported by kernel %#x", conn->capable);

dfuse_show_flags(fs_handle, conn->capable);
dfuse_show_flags(dfuse_info, conn->capable);

DFUSE_TRA_INFO(fs_handle, "Capability requested %#x", conn->want);
DFUSE_TRA_INFO(dfuse_info, "Capability requested %#x", conn->want);

conn->want |= FUSE_CAP_READDIRPLUS;
conn->want |= FUSE_CAP_READDIRPLUS_AUTO;

conn->time_gran = 1;

if (fs_handle->di_wb_cache)
conn->want |= FUSE_CAP_WRITEBACK_CACHE;

dfuse_show_flags(fs_handle, conn->want);

conn->time_gran = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC this has something to do with ms or ns time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This isn't a logic change, just grouping the conn->want code together makes it appear new.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I missed that

conn->max_background = 16;
conn->congestion_threshold = 8;

DFUSE_TRA_INFO(fs_handle, "max_background %d", conn->max_background);
DFUSE_TRA_INFO(fs_handle, "congestion_threshold %d", conn->congestion_threshold);
dfuse_show_flags(dfuse_info, conn->want);

DFUSE_TRA_INFO(dfuse_info, "max_background %d", conn->max_background);
DFUSE_TRA_INFO(dfuse_info, "congestion_threshold %d", conn->congestion_threshold);
}

void
Expand Down
43 changes: 27 additions & 16 deletions src/client/dfuse/ops/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
static void
dfuse_cb_write_complete(struct dfuse_event *ev)
{
if (ev->de_ev.ev_error == 0)
DFUSE_REPLY_WRITE(ev->de_oh, ev->de_req, ev->de_len);
else
DFUSE_REPLY_ERR_RAW(ev->de_oh, ev->de_req, ev->de_ev.ev_error);
if (ev->de_req) {
if (ev->de_ev.ev_error == 0)
DFUSE_REPLY_WRITE(ev->de_oh, ev->de_req, ev->de_len);
else
DFUSE_REPLY_ERR_RAW(ev->de_oh, ev->de_req, ev->de_ev.ev_error);
}
daos_event_fini(&ev->de_ev);
d_slab_release(ev->de_eqt->de_write_slab, ev);
}
Expand All @@ -22,24 +24,27 @@ void
dfuse_cb_write(fuse_req_t req, fuse_ino_t ino, struct fuse_bufvec *bufv, off_t position,
struct fuse_file_info *fi)
{
struct dfuse_obj_hdl *oh = (struct dfuse_obj_hdl *)fi->fh;
struct dfuse_info *dfuse_info = fuse_req_userdata(req);
const struct fuse_ctx *fc = fuse_req_ctx(req);
size_t len = fuse_buf_size(bufv);
struct fuse_bufvec ibuf = FUSE_BUFVEC_INIT(len);
struct dfuse_eq *eqt;
int rc;
struct dfuse_event *ev;
uint64_t eqt_idx;
struct dfuse_obj_hdl *oh = (struct dfuse_obj_hdl *)fi->fh;
struct dfuse_info *dfuse_info = fuse_req_userdata(req);
size_t len = fuse_buf_size(bufv);
struct fuse_bufvec ibuf = FUSE_BUFVEC_INIT(len);
struct dfuse_eq *eqt;
int rc;
struct dfuse_event *ev;
uint64_t eqt_idx;
bool wb_cache = false;

oh->doh_linear_read = false;

eqt_idx = atomic_fetch_add_relaxed(&dfuse_info->di_eqt_idx, 1);

eqt = &dfuse_info->di_eqt[eqt_idx % dfuse_info->di_eq_count];

DFUSE_TRA_DEBUG(oh, "%#zx-%#zx requested flags %#x pid=%d", position, position + len - 1,
bufv->buf[0].flags, fc->pid);
if (oh->doh_ie->ie_dfs->dfc_data_timeout != 0 && dfuse_info->di_wb_cache)
wb_cache = true;

DFUSE_TRA_DEBUG(oh, "%#zx-%#zx requested flags %#x", position, position + len - 1,
bufv->buf[0].flags);

/* Evict the metadata cache here so the lookup doesn't return stale size/time info */
if (atomic_fetch_add_relaxed(&oh->doh_write_count, 1) == 0) {
Expand All @@ -64,7 +69,10 @@ dfuse_cb_write(fuse_req_t req, fuse_ino_t ino, struct fuse_bufvec *bufv, off_t p

ev->de_oh = oh;
ev->de_iov.iov_len = len;
ev->de_req = req;
if (wb_cache)
ev->de_req = 0;
else
ev->de_req = req;
ev->de_len = len;
ev->de_complete_cb = dfuse_cb_write_complete;

Expand All @@ -91,6 +99,9 @@ dfuse_cb_write(fuse_req_t req, fuse_ino_t ino, struct fuse_bufvec *bufv, off_t p
if (rc != 0)
D_GOTO(err, rc);

if (wb_cache)
DFUSE_REPLY_WRITE(oh, req, len);

/* Send a message to the async thread to wake it up and poll for events */
sem_post(&eqt->de_sem);

Expand Down