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

Fix unavailability to free memory in cache #345

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions src/cow_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ int __cow_write_section(struct cow_manager *cm, unsigned long sect_idx)
static int __cow_sync_and_free_sections(struct cow_manager *cm,
unsigned long thresh)
{
LOG_DEBUG("__cow_sync_and_free_sections");
int ret;
unsigned long i;

Expand Down
2 changes: 1 addition & 1 deletion src/module_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int dattobd_may_hook_syscalls = 1;
unsigned long dattobd_cow_max_memory_default = (300 * 1024 * 1024);
unsigned int dattobd_cow_fallocate_percentage_default = 10;
unsigned int dattobd_max_snap_devices = DATTOBD_DEFAULT_SNAP_DEVICES;
int dattobd_debug = 0;
int dattobd_debug = 1;

module_param_named(may_hook_syscalls, dattobd_may_hook_syscalls, int, S_IRUGO);
MODULE_PARM_DESC(may_hook_syscalls,
Expand Down
10 changes: 7 additions & 3 deletions src/module_threads.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only

/*
* Copyright (C) 2022 Datto Inc.
* Copyright (C) 2024 Datto Inc.
*/

#include "module_threads.h"
Expand Down Expand Up @@ -80,6 +80,7 @@ int inc_sset_thread(void *data)
// free the sector set
kfree(sset);
}
LOG_DEBUG("inc_sset_thread has stopped");

return 0;
}
Expand Down Expand Up @@ -119,11 +120,14 @@ int snap_cow_thread(void *data)
cow_free_members(dev->sd_cow);
}

#if defined USE_BDOPS_SUBMIT_BIO && defined HAVE_FOPS_FALLOCATE
Copy link
Contributor

Choose a reason for hiding this comment

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

copyright change, otherwise a logical catch :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated copyright

//not having it for .deb causes infinite loop and failure, having this for rpms causes objdump caused by not being able to save cached data during unmounting
int should_stop=kthread_should_stop();
if(should_stop){
LOG_DEBUG("stopping snap thread in if");
LOG_DEBUG("stopping snap thread in conditional");
break;
}
#endif

if (bio_queue_empty(bq))
continue;
Expand Down Expand Up @@ -167,7 +171,7 @@ int snap_cow_thread(void *data)
bio_free_clone(bio);
}
}

LOG_DEBUG("snap_cow_thread has stopped");
return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions src/tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ void dattobd_free_request_tracking_ptr(struct snap_device *dev)
tracing_ops_put(dev->sd_tracing_ops);
dev->sd_tracing_ops=NULL;
}
dev->sd_tracing_ops=NULL;
#else
dev->sd_orig_request_fn = NULL;
#endif
Expand Down Expand Up @@ -924,6 +925,7 @@ static void __tracer_bioset_exit(struct snap_device *dev)
dev->sd_bioset = NULL;
}
#else
LOG_DEBUG("freeing bio set");
bioset_exit(&dev->sd_bioset);
#endif
}
Expand Down Expand Up @@ -1283,6 +1285,7 @@ static int __tracer_transition_tracing(
bdev_name);
#endif
}
LOG_DEBUG("stopped freezing, smb");
smp_wmb();
if(dev){
LOG_DEBUG("starting tracing");
Expand Down Expand Up @@ -1376,6 +1379,7 @@ static MRF_RETURN_TYPE tracing_fn(struct request_queue *q, struct bio *bio)
if (dattobd_bio_op_flagged(bio, DATTOBD_PASSTHROUGH))
{
dattobd_bio_op_clear_flag(bio, DATTOBD_PASSTHROUGH);
goto call_orig;
}
else
{
Expand All @@ -1394,6 +1398,7 @@ static MRF_RETURN_TYPE tracing_fn(struct request_queue *q, struct bio *bio)
#endif
} // tracer_for_each(dev, i)

call_orig:
#ifdef USE_BDOPS_SUBMIT_BIO
if(orig_fn){
orig_fn(bio);
Expand Down