udisks2/udisks-2.11.0-mdraid-inhibit-locks.patch
Tomas Bzatek 362d692bfb * Fri Jan 24 2025 Tomas Bzatek <tbzatek@redhat.com> - 2.10.90-5
- mdraid: Avoid acquiring system inhibit lock for external array operations (RHEL-74012)

Resolves: RHEL-74012
2025-01-24 17:46:34 +01:00

1012 lines
59 KiB
Diff

From 2a1ee3b5e105d5e42fe536df282d86f1b226245d Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Tue, 21 Jan 2025 19:08:56 +0100
Subject: [PATCH 1/5] udisksdaemon: Add 'no_inhibit' argument for job creation
functions
Avoid placing system inhibit lock if desired.
---
src/udisksdaemon.c | 34 ++++++++++++++++++++++++++++------
src/udisksdaemon.h | 15 +++++++++++----
2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/src/udisksdaemon.c b/src/udisksdaemon.c
index d7505d8b..8769486b 100644
--- a/src/udisksdaemon.c
+++ b/src/udisksdaemon.c
@@ -822,6 +822,7 @@ common_job (UDisksDaemon *daemon,
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
gpointer job)
{
gchar *job_object_path;
@@ -832,9 +833,12 @@ common_job (UDisksDaemon *daemon,
job_data = g_new0 (JobData, 1);
job_data->daemon = g_object_ref (daemon);
/* register inhibitor to systemd logind while job is running */
- operation_description = udisks_client_get_job_description_from_operation (job_operation);
- job_data->inhibit_cookie = udisks_daemon_util_inhibit_system_sync (operation_description);
- g_free (operation_description);
+ if (!no_inhibit)
+ {
+ operation_description = udisks_client_get_job_description_from_operation (job_operation);
+ job_data->inhibit_cookie = udisks_daemon_util_inhibit_system_sync (operation_description);
+ g_free (operation_description);
+ }
if (object != NULL)
udisks_base_job_add_object (UDISKS_BASE_JOB (job), object);
@@ -863,6 +867,7 @@ common_job (UDisksDaemon *daemon,
* @object: (allow-none): A #UDisksObject to add to the job or %NULL.
* @job_operation: The operation for the job.
* @job_started_by_uid: The user who started the job.
+ * @no_inhibit: Avoid placing system inhibitor lock.
* @cancellable: A #GCancellable or %NULL.
*
* Launches a new simple job.
@@ -879,6 +884,7 @@ udisks_daemon_launch_simple_job (UDisksDaemon *daemon,
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
GCancellable *cancellable)
{
UDisksSimpleJob *job;
@@ -886,7 +892,7 @@ udisks_daemon_launch_simple_job (UDisksDaemon *daemon,
g_return_val_if_fail (UDISKS_IS_DAEMON (daemon), NULL);
job = udisks_simple_job_new (daemon, cancellable);
- return common_job (daemon, object, job_operation, job_started_by_uid, job);
+ return common_job (daemon, object, job_operation, job_started_by_uid, no_inhibit, job);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -897,6 +903,7 @@ udisks_daemon_launch_simple_job (UDisksDaemon *daemon,
* @object: (allow-none): A #UDisksObject to add to the job or %NULL.
* @job_operation: The operation for the job.
* @job_started_by_uid: The user who started the job.
+ * @no_inhibit: Avoid placing system inhibitor lock.
* @job_func: The function to run in another thread.
* @user_data: User data to pass to @job_func.
* @user_data_free_func: Function to free @user_data with or %NULL.
@@ -926,6 +933,7 @@ udisks_daemon_launch_threaded_job (UDisksDaemon *daemon,
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
UDisksThreadedJobFunc job_func,
gpointer user_data,
GDestroyNotify user_data_free_func,
@@ -941,7 +949,7 @@ udisks_daemon_launch_threaded_job (UDisksDaemon *daemon,
user_data_free_func,
daemon,
cancellable);
- return common_job (daemon, object, job_operation, job_started_by_uid, job);
+ return common_job (daemon, object, job_operation, job_started_by_uid, no_inhibit, job);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -952,6 +960,7 @@ udisks_daemon_launch_threaded_job (UDisksDaemon *daemon,
* @object: (allow-none): A #UDisksObject to add to the job or %NULL.
* @job_operation: The operation for the job.
* @job_started_by_uid: The user who started the job.
+ * @no_inhibit: Avoid placing system inhibitor lock.
* @cancellable: A #GCancellable or %NULL.
* @run_as_uid: The #uid_t to run the command as.
* @run_as_euid: The effective #uid_t to run the command as.
@@ -980,6 +989,7 @@ udisks_daemon_launch_spawned_job (UDisksDaemon *daemon,
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
GCancellable *cancellable,
uid_t run_as_uid,
uid_t run_as_euid,
@@ -1003,6 +1013,7 @@ udisks_daemon_launch_spawned_job (UDisksDaemon *daemon,
object,
job_operation,
job_started_by_uid,
+ no_inhibit,
cancellable,
run_as_uid,
run_as_euid,
@@ -1021,6 +1032,7 @@ udisks_daemon_launch_spawned_job (UDisksDaemon *daemon,
* @object: (allow-none): A #UDisksObject to add to the job or %NULL.
* @job_operation: The operation for the job.
* @job_started_by_uid: The user who started the job.
+ * @no_inhibit: Avoid placing system inhibitor lock.
* @cancellable: A #GCancellable or %NULL.
* @run_as_uid: The #uid_t to run the command as.
* @run_as_euid: The effective #uid_t to run the command as.
@@ -1054,6 +1066,7 @@ udisks_daemon_launch_spawned_job_gstring (
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
GCancellable *cancellable,
uid_t run_as_uid,
uid_t run_as_euid,
@@ -1075,7 +1088,7 @@ udisks_daemon_launch_spawned_job_gstring (
job = udisks_spawned_job_new (command_line, input_string, run_as_uid, run_as_euid, daemon, cancellable);
g_free (command_line);
- return common_job (daemon, object, job_operation, job_started_by_uid, job);
+ return common_job (daemon, object, job_operation, job_started_by_uid, no_inhibit, job);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -1120,6 +1133,7 @@ spawned_job_sync_on_completed (UDisksJob *job,
* @object: (allow-none): A #UDisksObject to add to the job or %NULL.
* @job_operation: The operation for the job.
* @job_started_by_uid: The user who started the job.
+ * @no_inhibit: Avoid placing system inhibitor lock.
* @cancellable: A #GCancellable or %NULL.
* @run_as_uid: The #uid_t to run the command as.
* @run_as_euid: The effective #uid_t to run the command as.
@@ -1139,6 +1153,7 @@ udisks_daemon_launch_spawned_job_sync (UDisksDaemon *daemon,
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
GCancellable *cancellable,
uid_t run_as_uid,
uid_t run_as_euid,
@@ -1164,6 +1179,7 @@ udisks_daemon_launch_spawned_job_sync (UDisksDaemon *daemon,
object,
job_operation,
job_started_by_uid,
+ no_inhibit,
cancellable,
run_as_uid,
run_as_euid,
@@ -1184,6 +1200,7 @@ udisks_daemon_launch_spawned_job_sync (UDisksDaemon *daemon,
* @object: (allow-none): A #UDisksObject to add to the job or %NULL.
* @job_operation: The operation for the job.
* @job_started_by_uid: The user who started the job.
+ * @no_inhibit: Avoid placing system inhibitor lock.
* @cancellable: A #GCancellable or %NULL.
* @run_as_uid: The #uid_t to run the command as.
* @run_as_euid: The effective #uid_t to run the command as.
@@ -1207,6 +1224,7 @@ udisks_daemon_launch_spawned_job_gstring_sync (UDisksDaemon *daemon,
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
GCancellable *cancellable,
uid_t run_as_uid,
uid_t run_as_euid,
@@ -1239,6 +1257,7 @@ udisks_daemon_launch_spawned_job_gstring_sync (UDisksDaemon *daemon,
object,
job_operation,
job_started_by_uid,
+ no_inhibit,
cancellable,
run_as_uid,
run_as_euid,
@@ -1318,6 +1337,7 @@ udisks_bd_thread_disable_progress (void)
* @object: (allow-none): A #UDisksObject to add to the job or %NULL.
* @job_operation: The operation for the job.
* @job_started_by_uid: The user who started the job.
+ * @no_inhibit: Avoid placing system inhibitor lock.
* @job_func: The function to run in another thread.
* @user_data: User data to pass to @job_func.
* @user_data_free_func: Function to free @user_data with or %NULL.
@@ -1334,6 +1354,7 @@ udisks_daemon_launch_threaded_job_sync (UDisksDaemon *daemon,
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
UDisksThreadedJobFunc job_func,
gpointer user_data,
GDestroyNotify user_data_free_func,
@@ -1350,6 +1371,7 @@ udisks_daemon_launch_threaded_job_sync (UDisksDaemon *daemon,
object,
job_operation,
job_started_by_uid,
+ no_inhibit,
job_func,
user_data,
user_data_free_func,
diff --git a/src/udisksdaemon.h b/src/udisksdaemon.h
index 2edbaf3a..2f612c67 100644
--- a/src/udisksdaemon.h
+++ b/src/udisksdaemon.h
@@ -110,21 +110,24 @@ UDisksBaseJob *udisks_daemon_launch_simple_job (UDisksDaemon *
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
GCancellable *cancellable);
UDisksBaseJob *udisks_daemon_launch_spawned_job (UDisksDaemon *daemon,
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
GCancellable *cancellable,
uid_t run_as_uid,
uid_t run_as_euid,
const gchar *input_string,
const gchar *command_line_format,
- ...) G_GNUC_PRINTF (9, 10);
+ ...) G_GNUC_PRINTF (10, 11);
gboolean udisks_daemon_launch_spawned_job_sync (UDisksDaemon *daemon,
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
GCancellable *cancellable,
uid_t run_as_uid,
uid_t run_as_euid,
@@ -132,21 +135,23 @@ gboolean udisks_daemon_launch_spawned_job_sync (UDisksDaemon
gchar **out_message,
const gchar *input_string,
const gchar *command_line_format,
- ...) G_GNUC_PRINTF (11, 12);
+ ...) G_GNUC_PRINTF (12, 13);
UDisksBaseJob *udisks_daemon_launch_spawned_job_gstring (UDisksDaemon *daemon,
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
GCancellable *cancellable,
uid_t run_as_uid,
uid_t run_as_euid,
GString *input_string,
const gchar *command_line_format,
- ...) G_GNUC_PRINTF (9, 10);
+ ...) G_GNUC_PRINTF (10, 11);
gboolean udisks_daemon_launch_spawned_job_gstring_sync (UDisksDaemon *daemon,
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
GCancellable *cancellable,
uid_t run_as_uid,
uid_t run_as_euid,
@@ -154,11 +159,12 @@ gboolean udisks_daemon_launch_spawned_job_gstring_sync (UDisksD
gchar **out_message,
GString *input_string,
const gchar *command_line_format,
- ...) G_GNUC_PRINTF (11, 12);
+ ...) G_GNUC_PRINTF (12, 13);
UDisksBaseJob *udisks_daemon_launch_threaded_job (UDisksDaemon *daemon,
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
UDisksThreadedJobFunc job_func,
gpointer user_data,
GDestroyNotify user_data_free_func,
@@ -168,6 +174,7 @@ gboolean udisks_daemon_launch_threaded_job_sync (UDisksDaemon
UDisksObject *object,
const gchar *job_operation,
uid_t job_started_by_uid,
+ gboolean no_inhibit,
UDisksThreadedJobFunc job_func,
gpointer user_data,
GDestroyNotify user_data_free_func,
--
2.48.1
From 322863e6b49ae011b8d2f1e2c8741f56dabbb5f3 Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Tue, 21 Jan 2025 19:15:45 +0100
Subject: [PATCH 2/5] daemon: Align to the no_inhibit job argument change
---
src/udiskslinuxblock.c | 7 ++++++-
src/udiskslinuxdrive.c | 1 +
src/udiskslinuxdriveata.c | 3 ++-
src/udiskslinuxencrypted.c | 6 ++++++
src/udiskslinuxfilesystem.c | 10 ++++++++++
src/udiskslinuxloop.c | 1 +
src/udiskslinuxmanager.c | 1 +
src/udiskslinuxmdraid.c | 7 +++++++
src/udiskslinuxnvmecontroller.c | 2 ++
src/udiskslinuxnvmenamespace.c | 1 +
src/udiskslinuxpartition.c | 6 ++++++
src/udiskslinuxpartitiontable.c | 1 +
src/udiskslinuxswapspace.c | 4 ++++
src/udisksstate.c | 2 ++
14 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/src/udiskslinuxblock.c b/src/udiskslinuxblock.c
index 5b5588b2..008d1265 100644
--- a/src/udiskslinuxblock.c
+++ b/src/udiskslinuxblock.c
@@ -2482,7 +2482,7 @@ erase_device (UDisksBlock *block,
goto out;
}
- job = udisks_daemon_launch_simple_job (daemon, object, "format-erase", caller_uid, NULL);
+ job = udisks_daemon_launch_simple_job (daemon, object, "format-erase", caller_uid, FALSE, NULL);
udisks_base_job_set_auto_estimate (UDISKS_BASE_JOB (job), TRUE);
udisks_job_set_progress_valid (UDISKS_JOB (job), TRUE);
@@ -3185,6 +3185,7 @@ format_create_luks (UDisksDaemon *daemon,
object,
"format-mkfs",
caller_uid,
+ FALSE,
luks_format_job_func,
&crypto_job_data,
NULL, /* user_data_free_func */
@@ -3229,6 +3230,7 @@ format_create_luks (UDisksDaemon *daemon,
object,
"format-mkfs",
caller_uid,
+ FALSE,
luks_open_job_func,
&crypto_job_data,
NULL, /* user_data_free_func */
@@ -3571,6 +3573,7 @@ udisks_linux_block_handle_format (UDisksBlock *block,
object,
"format-mkfs",
caller_uid,
+ FALSE,
format_job_func,
&format_job_data,
NULL, /* user_data_free_func */
@@ -3679,6 +3682,7 @@ udisks_linux_block_handle_format (UDisksBlock *block,
object,
"format-mkfs",
caller_uid,
+ FALSE,
format_job_func,
&format_job_data,
NULL, /* user_data_free_func */
@@ -4268,6 +4272,7 @@ handle_restore_encrypted_header (UDisksBlock *encrypted,
UDISKS_OBJECT (object),
"block-restore-encrypted-header",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
{
diff --git a/src/udiskslinuxdrive.c b/src/udiskslinuxdrive.c
index 18b9ae4f..93ca3813 100644
--- a/src/udiskslinuxdrive.c
+++ b/src/udiskslinuxdrive.c
@@ -1142,6 +1142,7 @@ handle_eject (UDisksDrive *_drive,
if (!udisks_daemon_launch_spawned_job_sync (daemon,
UDISKS_OBJECT (object),
"drive-eject", caller_uid,
+ FALSE,
NULL, /* GCancellable */
0, /* uid_t run_as_uid */
0, /* uid_t run_as_euid */
diff --git a/src/udiskslinuxdriveata.c b/src/udiskslinuxdriveata.c
index 0675d1ed..dd7b0b0d 100644
--- a/src/udiskslinuxdriveata.c
+++ b/src/udiskslinuxdriveata.c
@@ -1194,6 +1194,7 @@ handle_smart_selftest_start (UDisksDriveAta *_drive,
drive->selftest_job = UDISKS_THREADED_JOB (udisks_daemon_launch_threaded_job (daemon,
UDISKS_OBJECT (object),
"ata-smart-selftest", caller_uid,
+ FALSE,
selftest_job_func,
g_object_ref (drive),
g_object_unref,
@@ -2226,7 +2227,7 @@ udisks_linux_drive_ata_secure_erase_sync (UDisksLinuxDriveAta *drive,
job = udisks_daemon_launch_simple_job (daemon,
UDISKS_OBJECT (object),
enhanced ? "ata-enhanced-secure-erase" : "ata-secure-erase",
- caller_uid, NULL);
+ caller_uid, FALSE, NULL);
udisks_job_set_cancelable (UDISKS_JOB (job), FALSE);
/* A value of 510 (255 in the IDENTIFY DATA register) means "erase
diff --git a/src/udiskslinuxencrypted.c b/src/udiskslinuxencrypted.c
index f6ae85c7..bb1f9e10 100644
--- a/src/udiskslinuxencrypted.c
+++ b/src/udiskslinuxencrypted.c
@@ -588,6 +588,7 @@ handle_unlock (UDisksEncrypted *encrypted,
object,
"encrypted-unlock",
caller_uid,
+ FALSE,
open_func,
&data,
NULL, /* user_data_free_func */
@@ -807,6 +808,7 @@ udisks_linux_encrypted_lock (UDisksLinuxEncrypted *encrypted,
object,
"encrypted-lock",
caller_uid,
+ FALSE,
close_func,
&data,
NULL, /* user_data_free_func */
@@ -991,6 +993,7 @@ handle_change_passphrase (UDisksEncrypted *encrypted,
object,
"encrypted-modify",
caller_uid,
+ FALSE,
luks_change_key_job_func,
&data,
NULL, /* user_data_free_func */
@@ -1155,6 +1158,7 @@ handle_resize (UDisksEncrypted *encrypted,
UDISKS_OBJECT (object),
"encrypted-resize",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
{
@@ -1296,6 +1300,7 @@ handle_convert (UDisksEncrypted *encrypted,
UDISKS_OBJECT (object),
"encrypted-convert",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
{
@@ -1389,6 +1394,7 @@ handle_header_backup (UDisksEncrypted *encrypted,
UDISKS_OBJECT (object),
"encrypted-header-backup",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
{
diff --git a/src/udiskslinuxfilesystem.c b/src/udiskslinuxfilesystem.c
index e7df067d..b1974483 100644
--- a/src/udiskslinuxfilesystem.c
+++ b/src/udiskslinuxfilesystem.c
@@ -983,6 +983,7 @@ handle_mount_fstab (UDisksDaemon *daemon,
UDISKS_OBJECT (object),
"filesystem-mount",
mount_fstab_as_root ? 0 : caller_uid,
+ FALSE,
NULL /* cancellable */);
/* XXX: using run_as_uid for root doesn't work even if the caller is already root */
@@ -1208,6 +1209,7 @@ handle_mount_dynamic (UDisksDaemon *daemon,
UDISKS_OBJECT (object),
"filesystem-mount",
0,
+ FALSE,
NULL /* cancellable */);
success = FALSE;
@@ -1564,6 +1566,7 @@ handle_unmount (UDisksFilesystem *filesystem,
UDISKS_OBJECT (object),
"filesystem-unmount",
unmount_fstab_as_root ? 0 : caller_uid,
+ FALSE,
NULL);
if (!unmount_fstab_as_root && caller_uid != 0)
@@ -1669,6 +1672,7 @@ handle_unmount (UDisksFilesystem *filesystem,
UDISKS_OBJECT (object),
"filesystem-unmount",
0,
+ FALSE,
NULL);
if (!bd_fs_unmount (mount_point ? mount_point : udisks_block_get_device (block),
@@ -1850,6 +1854,7 @@ handle_set_label (UDisksFilesystem *filesystem,
object,
"filesystem-modify",
caller_uid,
+ FALSE,
NULL /* cancellable */);
if (job == NULL)
{
@@ -2030,6 +2035,7 @@ handle_resize (UDisksFilesystem *filesystem,
UDISKS_OBJECT (object),
"filesystem-resize",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
{
@@ -2201,6 +2207,7 @@ handle_repair (UDisksFilesystem *filesystem,
UDISKS_OBJECT (object),
"filesystem-repair",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
{
@@ -2369,6 +2376,7 @@ handle_check (UDisksFilesystem *filesystem,
UDISKS_OBJECT (object),
"filesystem-check",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
{
@@ -2518,6 +2526,7 @@ handle_take_ownership (UDisksFilesystem *filesystem,
UDISKS_OBJECT (object),
"filesystem-modify",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
{
@@ -2698,6 +2707,7 @@ handle_set_uuid (UDisksFilesystem *filesystem,
object,
"filesystem-modify",
caller_uid,
+ FALSE,
NULL /* cancellable */);
if (job == NULL)
{
diff --git a/src/udiskslinuxloop.c b/src/udiskslinuxloop.c
index 500df6ef..ee690991 100644
--- a/src/udiskslinuxloop.c
+++ b/src/udiskslinuxloop.c
@@ -249,6 +249,7 @@ handle_delete (UDisksLoop *loop,
UDISKS_OBJECT(object),
"loop-setup",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
diff --git a/src/udiskslinuxmanager.c b/src/udiskslinuxmanager.c
index 139be7ca..4e633284 100644
--- a/src/udiskslinuxmanager.c
+++ b/src/udiskslinuxmanager.c
@@ -598,6 +598,7 @@ handle_mdraid_create (UDisksManager *_object,
NULL,
"mdraid-create",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
diff --git a/src/udiskslinuxmdraid.c b/src/udiskslinuxmdraid.c
index 176b0258..a24c78c2 100644
--- a/src/udiskslinuxmdraid.c
+++ b/src/udiskslinuxmdraid.c
@@ -371,6 +371,7 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid,
UDISKS_OBJECT (object),
sync_action_to_job_id (sync_action),
0,
+ FALSE,
NULL /* cancellable */);
/* Mark the job as not cancellable. It simply has to finish... */
@@ -643,6 +644,7 @@ handle_start (UDisksMDRaid *_mdraid,
UDISKS_OBJECT (object),
"md-raid-start",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
@@ -805,6 +807,7 @@ udisks_linux_mdraid_stop (UDisksMDRaid *_mdraid,
UDISKS_OBJECT (object),
"md-raid-stop",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
@@ -1026,6 +1029,7 @@ handle_remove_device (UDisksMDRaid *_mdraid,
UDISKS_OBJECT (object),
"md-raid-remove-device",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
@@ -1170,6 +1174,7 @@ handle_add_device (UDisksMDRaid *_mdraid,
UDISKS_OBJECT (object),
"md-raid-add-device",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
@@ -1286,6 +1291,7 @@ handle_set_bitmap_location (UDisksMDRaid *_mdraid,
UDISKS_OBJECT (object),
"md-raid-set-bitmap",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
@@ -1403,6 +1409,7 @@ handle_request_sync_action (UDisksMDRaid *_mdraid,
UDISKS_OBJECT (object),
sync_action_to_job_id (sync_action),
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
diff --git a/src/udiskslinuxnvmecontroller.c b/src/udiskslinuxnvmecontroller.c
index b032467e..dff3ab06 100644
--- a/src/udiskslinuxnvmecontroller.c
+++ b/src/udiskslinuxnvmecontroller.c
@@ -873,6 +873,7 @@ handle_smart_selftest_start (UDisksNVMeController *_ctrl,
UDISKS_OBJECT (object),
"nvme-selftest",
caller_uid,
+ FALSE,
selftest_job_func,
g_object_ref (ctrl),
(GDestroyNotify) selftest_job_func_done,
@@ -1298,6 +1299,7 @@ handle_sanitize_start (UDisksNVMeController *_object,
UDISKS_OBJECT (object),
"nvme-sanitize",
caller_uid,
+ FALSE,
sanitize_job_func,
g_object_ref (ctrl),
(GDestroyNotify) sanitize_job_func_done,
diff --git a/src/udiskslinuxnvmenamespace.c b/src/udiskslinuxnvmenamespace.c
index 076c2285..ddb03e22 100644
--- a/src/udiskslinuxnvmenamespace.c
+++ b/src/udiskslinuxnvmenamespace.c
@@ -429,6 +429,7 @@ handle_format_namespace (UDisksNVMeNamespace *_ns,
UDISKS_OBJECT (object),
"nvme-format-ns",
caller_uid,
+ FALSE,
format_ns_job_func,
data,
(GDestroyNotify) format_ns_job_func_done,
diff --git a/src/udiskslinuxpartition.c b/src/udiskslinuxpartition.c
index c4433627..2e07ca2c 100644
--- a/src/udiskslinuxpartition.c
+++ b/src/udiskslinuxpartition.c
@@ -389,6 +389,7 @@ handle_set_flags (UDisksPartition *partition,
UDISKS_OBJECT (object),
"partition-modify",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
@@ -527,6 +528,7 @@ handle_set_name (UDisksPartition *partition,
UDISKS_OBJECT (object),
"partition-modify",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
@@ -669,6 +671,7 @@ handle_set_uuid (UDisksPartition *partition,
UDISKS_OBJECT (object),
"partition-modify",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
@@ -774,6 +777,7 @@ udisks_linux_partition_set_type_sync (UDisksLinuxPartition *partition,
UDISKS_OBJECT (object),
"partition-modify",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
@@ -984,6 +988,7 @@ handle_resize (UDisksPartition *partition,
UDISKS_OBJECT (object),
"partition-modify",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
@@ -1115,6 +1120,7 @@ handle_delete (UDisksPartition *partition,
UDISKS_OBJECT (object),
"partition-delete",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
diff --git a/src/udiskslinuxpartitiontable.c b/src/udiskslinuxpartitiontable.c
index 528b22ff..09bd545b 100644
--- a/src/udiskslinuxpartitiontable.c
+++ b/src/udiskslinuxpartitiontable.c
@@ -422,6 +422,7 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable *ta
UDISKS_OBJECT (object),
"partition-create",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
diff --git a/src/udiskslinuxswapspace.c b/src/udiskslinuxswapspace.c
index 0c4fd9a4..4c51bd88 100644
--- a/src/udiskslinuxswapspace.c
+++ b/src/udiskslinuxswapspace.c
@@ -201,6 +201,7 @@ handle_start (UDisksSwapspace *swapspace,
object,
"swapspace-start",
caller_uid,
+ FALSE,
start_job_func,
object,
NULL, /* user_data_free_func */
@@ -299,6 +300,7 @@ handle_stop (UDisksSwapspace *swapspace,
object,
"swapspace-stop",
caller_uid,
+ FALSE,
stop_job_func,
object,
NULL, /* user_data_free_func */
@@ -376,6 +378,7 @@ handle_set_label (UDisksSwapspace *swapspace,
UDISKS_OBJECT (object),
"swapspace-modify",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
{
@@ -462,6 +465,7 @@ handle_set_uuid (UDisksSwapspace *swapspace,
UDISKS_OBJECT (object),
"swapspace-modify",
caller_uid,
+ FALSE,
NULL);
if (job == NULL)
{
diff --git a/src/udisksstate.c b/src/udisksstate.c
index df6ef337..7323036d 100644
--- a/src/udisksstate.c
+++ b/src/udisksstate.c
@@ -783,6 +783,7 @@ udisks_state_check_mounted_fs_entry (UDisksState *state,
if (!udisks_daemon_launch_spawned_job_sync (state->daemon,
NULL, /* UDisksObject */
"cleanup", 0, /* StartedByUID */
+ FALSE,
NULL, /* GCancellable */
0, /* uid_t run_as_uid */
0, /* uid_t run_as_euid */
@@ -1247,6 +1248,7 @@ udisks_state_check_unlocked_crypto_dev_entry (UDisksState *state,
NULL, /* UDisksObject */
"cleanup",
0, /* StartedByUID */
+ FALSE,
luks_close_job_func,
&data,
NULL, /* user_data_free_func */
--
2.48.1
From 6d3ca4c21d3a9724aab4c021cc9c5c0b3fc39a1e Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Tue, 21 Jan 2025 19:16:11 +0100
Subject: [PATCH 3/5] lvm2: Align to the no_inhibit job argument change
---
modules/lvm2/udiskslinuxlogicalvolume.c | 9 +++++++++
modules/lvm2/udiskslinuxmanagerlvm2.c | 2 ++
modules/lvm2/udiskslinuxvdovolume.c | 2 ++
modules/lvm2/udiskslinuxvolumegroup.c | 8 ++++++++
4 files changed, 21 insertions(+)
diff --git a/modules/lvm2/udiskslinuxlogicalvolume.c b/modules/lvm2/udiskslinuxlogicalvolume.c
index c0c43c03..f517f7cc 100644
--- a/modules/lvm2/udiskslinuxlogicalvolume.c
+++ b/modules/lvm2/udiskslinuxlogicalvolume.c
@@ -593,6 +593,7 @@ handle_delete (UDisksLogicalVolume *_volume,
UDISKS_OBJECT (object),
"lvm-lvol-delete",
caller_uid,
+ FALSE,
lvremove_job_func,
&data,
NULL, /* user_data_free_func */
@@ -669,6 +670,7 @@ handle_repair (UDisksLogicalVolume *_volume,
UDISKS_OBJECT (object),
"lvm-lvol-repair",
caller_uid,
+ FALSE,
lvrepair_job_func,
&data,
NULL, /* user_data_free_func */
@@ -766,6 +768,7 @@ handle_rename (UDisksLogicalVolume *_volume,
UDISKS_OBJECT (object),
"lvm-lvol-rename",
caller_uid,
+ FALSE,
lvrename_job_func,
&data,
NULL, /* user_data_free_func */
@@ -848,6 +851,7 @@ handle_resize (UDisksLogicalVolume *_volume,
UDISKS_OBJECT (object),
"lvm-lvol-resize",
caller_uid,
+ FALSE,
lvresize_job_func,
&data,
NULL, /* user_data_free_func */
@@ -937,6 +941,7 @@ handle_activate (UDisksLogicalVolume *_volume,
UDISKS_OBJECT (object),
"lvm-lvol-activate",
caller_uid,
+ FALSE,
lvactivate_job_func,
&data,
NULL, /* user_data_free_func */
@@ -1005,6 +1010,7 @@ handle_deactivate (UDisksLogicalVolume *_volume,
UDISKS_OBJECT (object),
"lvm-lvol-deactivate",
caller_uid,
+ FALSE,
lvdeactivate_job_func,
&data,
NULL, /* user_data_free_func */
@@ -1074,6 +1080,7 @@ handle_create_snapshot (UDisksLogicalVolume *_volume,
UDISKS_OBJECT (object),
"lvm-lvol-snapshot",
caller_uid,
+ FALSE,
lvsnapshot_create_job_func,
&data,
NULL, /* user_data_free_func */
@@ -1134,6 +1141,7 @@ handle_cache_attach (UDisksLogicalVolume *volume_,
UDISKS_OBJECT (object),
"lvm-lv-make-cache",
caller_uid,
+ FALSE,
lvcache_attach_job_func,
&data,
NULL, /* user_data_free_func */
@@ -1185,6 +1193,7 @@ handle_cache_detach_or_split (UDisksLogicalVolume *volume_,
UDISKS_OBJECT (object),
"lvm-lv-split-cache",
caller_uid,
+ FALSE,
lvcache_detach_job_func,
&data,
NULL, /* user_data_free_func */
diff --git a/modules/lvm2/udiskslinuxmanagerlvm2.c b/modules/lvm2/udiskslinuxmanagerlvm2.c
index 5c06b921..7cd96384 100644
--- a/modules/lvm2/udiskslinuxmanagerlvm2.c
+++ b/modules/lvm2/udiskslinuxmanagerlvm2.c
@@ -338,6 +338,7 @@ handle_volume_group_create (UDisksManagerLVM2 *_object,
NULL,
"lvm-pv-create",
caller_uid,
+ FALSE,
pvcreate_job_func,
&pv_data,
NULL, /* user_data_free_func */
@@ -363,6 +364,7 @@ handle_volume_group_create (UDisksManagerLVM2 *_object,
NULL,
"lvm-vg-create",
caller_uid,
+ FALSE,
vgcreate_job_func,
&data,
NULL, /* user_data_free_func */
diff --git a/modules/lvm2/udiskslinuxvdovolume.c b/modules/lvm2/udiskslinuxvdovolume.c
index 19164d96..64247dfc 100644
--- a/modules/lvm2/udiskslinuxvdovolume.c
+++ b/modules/lvm2/udiskslinuxvdovolume.c
@@ -262,6 +262,7 @@ _set_compression_deduplication (UDisksVDOVolume *_volume,
UDISKS_OBJECT (object),
"lvm-vdo-dedup-comp",
caller_uid,
+ FALSE,
compression ? lv_vdo_compression_job_func : lv_vdo_deduplication_job_func,
&data,
NULL, /* user_data_free_func */
@@ -340,6 +341,7 @@ _vdo_resize (UDisksLinuxLogicalVolumeObject *object,
UDISKS_OBJECT (object),
"lvm-lvol-resize",
caller_uid,
+ FALSE,
lvresize_job_func,
&data,
NULL, /* user_data_free_func */
diff --git a/modules/lvm2/udiskslinuxvolumegroup.c b/modules/lvm2/udiskslinuxvolumegroup.c
index 5cb904e2..e1c6d76e 100644
--- a/modules/lvm2/udiskslinuxvolumegroup.c
+++ b/modules/lvm2/udiskslinuxvolumegroup.c
@@ -336,6 +336,7 @@ handle_delete (UDisksVolumeGroup *_group,
UDISKS_OBJECT (object),
"lvm-vg-delete",
caller_uid,
+ FALSE,
vgremove_job_func,
&data,
NULL, /* user_data_free_func */
@@ -457,6 +458,7 @@ handle_rename (UDisksVolumeGroup *_group,
UDISKS_OBJECT (object),
"lvm-vg-rename",
caller_uid,
+ FALSE,
vgrename_job_func,
&data,
NULL, /* user_data_free_func */
@@ -585,6 +587,7 @@ handle_add_device (UDisksVolumeGroup *_group,
UDISKS_OBJECT (object),
"lvm-pv-create",
caller_uid,
+ FALSE,
pvcreate_job_func,
&pv_data,
NULL, /* user_data_free_func */
@@ -610,6 +613,7 @@ handle_add_device (UDisksVolumeGroup *_group,
UDISKS_OBJECT (object),
"lvm-vg-add-device",
caller_uid,
+ FALSE,
vgextend_job_func,
&data,
NULL, /* user_data_free_func */
@@ -729,6 +733,7 @@ handle_remove_common (UDisksVolumeGroup *_group,
UDISKS_OBJECT (object),
job_operation,
caller_uid,
+ FALSE,
job_func,
&data,
NULL, /* user_data_free_func */
@@ -751,6 +756,7 @@ handle_remove_common (UDisksVolumeGroup *_group,
UDISKS_OBJECT (object),
"pv-format-erase",
caller_uid,
+ FALSE,
pvremove_job_func,
&data,
NULL, /* user_data_free_func */
@@ -854,6 +860,7 @@ handle_remove_missing_physical_volumes (UDisksVolumeGroup *_group,
UDISKS_OBJECT (object),
"lvm-vg-rem-device",
caller_uid,
+ FALSE,
vgreduce_job_func,
&data,
NULL, /* user_data_free_func */
@@ -1098,6 +1105,7 @@ handle_create_volume (UDisksVolumeGroup *_group,
UDISKS_OBJECT (object),
"lvm-vg-create-volume",
caller_uid,
+ FALSE,
create_function,
&data,
NULL, /* user_data_free_func */
--
2.48.1
From 6e8948401251f60e5cd8989ec4992974b375f4ed Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Tue, 21 Jan 2025 19:19:05 +0100
Subject: [PATCH 4/5] udiskslinuxmdraid: Avoid putting inhibit lock for
externally started operations
UDisks publishes a new job object whenever it sees an array in sync,
repair or generally any other operation running. However this involves
acquiring and holding a system inhibit lock for the whole duration
of the operation, which for large disks may take hours or days.
Besides, mdraid resync is a restartable operation, defeating the purpose
for an inhibit lock.
This is also causing problems for installation environments where
UDisks is blocking post-installation reboot until the operation is done.
---
src/udiskslinuxmdraid.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/udiskslinuxmdraid.c b/src/udiskslinuxmdraid.c
index a24c78c2..0ca9d681 100644
--- a/src/udiskslinuxmdraid.c
+++ b/src/udiskslinuxmdraid.c
@@ -371,8 +371,8 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid,
UDISKS_OBJECT (object),
sync_action_to_job_id (sync_action),
0,
- FALSE,
- NULL /* cancellable */);
+ TRUE, /* no_inhibit */
+ NULL /* cancellable */);
/* Mark the job as not cancellable. It simply has to finish... */
udisks_job_set_cancelable (UDISKS_JOB (job), FALSE);
--
2.48.1