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

Misc. btrfs fixes #950

Merged
merged 3 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion doc/udisks2-sections.txt.daemon.sections.in
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ udisks_state_new
udisks_state_start_cleanup
udisks_state_stop_cleanup
udisks_state_check
udisks_state_check_sync
udisks_state_check_block
udisks_state_get_daemon
<SUBSECTION>
Expand Down
8 changes: 4 additions & 4 deletions modules/btrfs/udiskslinuxfilesystembtrfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ btrfs_subvolume_perform_action (UDisksFilesystemBTRFS *fs_btrfs,
udisks_linux_block_object_trigger_uevent_sync (object, UDISKS_DEFAULT_WAIT_TIMEOUT);

/* Complete DBus call. */
udisks_filesystem_btrfs_complete_set_label (fs_btrfs, invocation);
g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));

out:
/* Release the resources */
Expand Down Expand Up @@ -519,12 +519,12 @@ btrfs_device_perform_action (UDisksFilesystemBTRFS *fs_btrfs,
goto out;
}

/* Update the interface. */
/* Trigger uevent on the filesystem and on the added/removed device */
udisks_linux_block_object_trigger_uevent_sync (object, UDISKS_DEFAULT_WAIT_TIMEOUT);
udisks_linux_filesystem_btrfs_update (l_fs_btrfs, object);
udisks_daemon_util_trigger_uevent_sync (daemon, device, NULL, UDISKS_DEFAULT_WAIT_TIMEOUT);

/* Complete DBus call. */
udisks_filesystem_btrfs_complete_add_device (fs_btrfs, invocation);
g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));

out:
/* Release the resources */
Expand Down
58 changes: 0 additions & 58 deletions src/udisksstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,64 +425,6 @@ udisks_state_check (UDisksState *state)
state);
}


typedef struct
{
UDisksState *state;
gboolean finished;
GCond cond;
GMutex data_mutex;
} UDisksStateCheckSyncData;

static gboolean
udisks_state_check_sync_func (UDisksStateCheckSyncData *data)
{
udisks_state_check_in_thread (data->state);

/* signal the calling thread the cleanup has finished */
g_mutex_lock (&data->data_mutex);
data->finished = TRUE;
g_cond_signal (&data->cond);
g_mutex_unlock (&data->data_mutex);

return FALSE;
}

/**
* udisks_state_check_sync:
* @state: A #UDisksState.
*
* Causes the clean-up thread for @state to check if anything should be cleaned up and perform the cleanup.
*
* This can be called from any thread and in contrast to udisks_state_check() will block the calling thread until cleanup is finished.
*/
void
udisks_state_check_sync (UDisksState *state)
{
UDisksStateCheckSyncData data = {0, };

g_return_if_fail (UDISKS_IS_STATE (state));
g_return_if_fail (state->thread != NULL);

g_cond_init (&data.cond);
g_mutex_init (&data.data_mutex);
data.state = state;
data.finished = FALSE;

g_mutex_lock (&data.data_mutex);
g_main_context_invoke (state->context,
(GSourceFunc) udisks_state_check_sync_func,
&data);

/* wait for the mainloop running in the cleanup thread to process our injected task */
while (!data.finished)
g_cond_wait (&data.cond, &data.data_mutex);
g_mutex_unlock (&data.data_mutex);

g_cond_clear (&data.cond);
g_mutex_clear (&data.data_mutex);
}

/**
* udisks_state_check_block:
* @state: A #UDisksState.
Expand Down
1 change: 0 additions & 1 deletion src/udisksstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ UDisksDaemon *udisks_state_get_daemon (UDisksState *state);
void udisks_state_start_cleanup (UDisksState *state);
void udisks_state_stop_cleanup (UDisksState *state);
void udisks_state_check (UDisksState *state);
void udisks_state_check_sync (UDisksState *state);
void udisks_state_check_block (UDisksState *state,
dev_t block_device);
/* mounted-fs */
Expand Down