Skip to content

Commit 4a20dcf

Browse files
authored
Merge pull request #6896 from BOINC/dpa_wsl12
client (Win): including WSL disk image in BOINC disk usage
2 parents 8bd4ceb + 41b4baf commit 4a20dcf

6 files changed

Lines changed: 51 additions & 29 deletions

File tree

client/client_state.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void CLIENT_STATE::show_host_info() {
258258
}
259259
} else {
260260
msg_printf(NULL, MSG_INFO, "Usable WSL distros:");
261-
for (auto& wsl : host_info.wsl_distros.distros) {
261+
for (WSL_DISTRO &wsl : host_info.wsl_distros.distros) {
262262
msg_printf(NULL, MSG_INFO,
263263
"- %s (WSL %d)%s",
264264
wsl.distro_name.c_str(),
@@ -290,6 +290,14 @@ void CLIENT_STATE::show_host_info() {
290290
msg_printf(NULL, MSG_INFO, "- BOINC WSL distro version %d",
291291
wsl.boinc_buda_runner_version
292292
);
293+
if (!wsl.base_path.empty()) {
294+
double size;
295+
int retval = dir_size_alloc(wsl.base_path.c_str(), size);
296+
if (!retval) {
297+
nbytes_to_string(size, 0, buf, sizeof(buf));
298+
msg_printf(NULL, MSG_INFO, "- Disk usage: %s", buf);
299+
}
300+
}
293301
}
294302
}
295303
}

client/cpu_sched.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ static void promote_multi_thread_jobs(vector<RESULT*>& runnable_jobs) {
10701070
// return true if r0 is more important to run than r1
10711071
//
10721072
static inline bool more_important(RESULT* r0, RESULT* r1) {
1073-
bool cp0, cp1;
1073+
bool cp0=false, cp1;
10741074

10751075
if (cc_config.prioritize_gpu) {
10761076
cp0 = r0->uses_coprocs();

client/cs_prefs.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,17 @@ int CLIENT_STATE::get_disk_usages() {
8686

8787
client_disk_usage = 0;
8888
total_disk_usage = 0;
89+
90+
// disk usage in project directories
91+
//
8992
for (PROJECT *p: projects) {
9093
p->disk_usage = 0;
9194
retval = dir_size_alloc(p->project_dir(), size);
9295
if (!retval) p->disk_usage = size;
9396
}
9497

98+
// disk usage in slot directories
99+
//
95100
for (i=0; i<active_tasks.active_tasks.size(); i++) {
96101
ACTIVE_TASK* atp = active_tasks.active_tasks[i];
97102
get_slot_dir(atp->slot, buf, sizeof(buf));
@@ -102,11 +107,29 @@ int CLIENT_STATE::get_disk_usages() {
102107
for (PROJECT *p: projects) {
103108
total_disk_usage += p->disk_usage;
104109
}
110+
111+
// disk usage top level of BOINC data dir: XML and log files
112+
//
105113
retval = dir_size_alloc(".", size, false);
106114
if (!retval) {
107115
client_disk_usage = size;
108116
total_disk_usage += size;
109117
}
118+
119+
#ifdef _WIN64
120+
// Win: if using boinc-buda-runner WSL distro,
121+
// include its disk image size
122+
//
123+
WSL_DISTRO *wd = host_info.wsl_distros.find_docker();
124+
if (wd) {
125+
retval = dir_size_alloc(wd->base_path.c_str(), size);
126+
if (!retval) {
127+
client_disk_usage += size;
128+
total_disk_usage += size;
129+
}
130+
}
131+
#endif
132+
110133
return 0;
111134
}
112135

client/gui_rpc_server_ops.cpp

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ static void handle_get_project_status(GUI_RPC_CONN& grc) {
148148
}
149149

150150
static void handle_get_disk_usage(GUI_RPC_CONN& grc) {
151-
double size, boinc_non_project, d_allowed;
152-
// double boinc_total;
153-
154151
grc.mfout.printf("<disk_usage_summary>\n");
155152
int retval = get_filesystem_info(
156153
gstate.host_info.d_total, gstate.host_info.d_free
@@ -161,27 +158,6 @@ static void handle_get_disk_usage(GUI_RPC_CONN& grc) {
161158
);
162159
}
163160

164-
dir_size_alloc(".", boinc_non_project, false);
165-
dir_size_alloc("locale", size, false);
166-
boinc_non_project += size;
167-
#ifdef __APPLE__
168-
if (gstate.launched_by_manager) {
169-
// If launched by Manager, get Manager's size on disk
170-
char path[MAXPATHLEN];
171-
double manager_size = 0.0;
172-
OSStatus err = noErr;
173-
174-
retval = proc_pidpath(getppid(), path, sizeof(path));
175-
if (retval <= 0) {
176-
err = fnfErr;
177-
}
178-
if (!err) {
179-
dir_size_alloc(path, manager_size, true);
180-
boinc_non_project += manager_size;
181-
}
182-
}
183-
#endif
184-
// boinc_total = boinc_non_project;
185161
gstate.get_disk_usages();
186162
for (PROJECT* p: gstate.projects) {
187163
grc.mfout.printf(
@@ -191,17 +167,16 @@ static void handle_get_disk_usage(GUI_RPC_CONN& grc) {
191167
"</project>\n",
192168
p->master_url, p->disk_usage
193169
);
194-
// boinc_total += p->disk_usage;
195170
}
196-
d_allowed = gstate.allowed_disk_usage(gstate.total_disk_usage);
171+
double d_allowed = gstate.allowed_disk_usage(gstate.total_disk_usage);
197172
grc.mfout.printf(
198173
"<d_total>%f</d_total>\n"
199174
"<d_free>%f</d_free>\n"
200175
"<d_boinc>%f</d_boinc>\n"
201176
"<d_allowed>%f</d_allowed>\n",
202177
gstate.host_info.d_total,
203178
gstate.host_info.d_free,
204-
boinc_non_project,
179+
gstate.client_disk_usage,
205180
d_allowed
206181
);
207182
grc.mfout.printf("</disk_usage_summary>\n");

client/hostinfo_wsl.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ int get_all_distros(WSL_DISTROS& distros) {
127127
if (!strcmp(wsl_guid, default_wsl_guid)) {
128128
distro.is_default = true;
129129
}
130+
131+
// if BOINC distro, get its data dir so we can find disk usage
132+
//
133+
char path[256];
134+
DWORD path_len = sizeof(path);
135+
if (distro.distro_name == BOINC_WSL_DISTRO_NAME) {
136+
ret = RegQueryValueEx(hSubKey, "BasePath", NULL, NULL,
137+
(LPBYTE)path, &path_len
138+
);
139+
if (ret == ERROR_SUCCESS) {
140+
distro.base_path = path;
141+
}
142+
}
143+
130144
distros.distros.push_back(distro);
131145
}
132146
RegCloseKey(hSubKey);

lib/wslinfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ struct WSL_DISTRO {
5656
DOCKER_TYPE docker_compose_type;
5757
int boinc_buda_runner_version;
5858
// if this distro is boinc_buda_runner, the version
59+
std::string base_path;
60+
// the dir where the disk image (.vhdx file) is stored
5961

6062
WSL_DISTRO(){
6163
clear();

0 commit comments

Comments
 (0)