mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 17:00:29 +01:00
core: flush timestamp cache to disk only on activate/deactivate
To suppress periodic disk wakeups, only write timestamps to disk when a device gets activated or deactivated. Timestamps are still updated periodically in memory, just not flushed to disk at that time.
This commit is contained in:
parent
78a8afac6c
commit
0be930c0fc
4 changed files with 23 additions and 14 deletions
|
|
@ -59,6 +59,7 @@
|
|||
#include "nm-firewall-manager.h"
|
||||
#include "nm-properties-changed-signal.h"
|
||||
#include "nm-enum-types.h"
|
||||
#include "nm-settings-connection.h"
|
||||
|
||||
static void impl_device_disconnect (NMDevice *device, DBusGMethodInvocation *context);
|
||||
|
||||
|
|
@ -4134,6 +4135,15 @@ nm_device_state_changed (NMDevice *device,
|
|||
/* Cache the activation request for the dispatcher */
|
||||
req = priv->act_request ? g_object_ref (priv->act_request) : NULL;
|
||||
|
||||
/* Update connection timestamps; do this before possibly deactivating the
|
||||
* device since that will clear the activation request and thus the
|
||||
* connection, which we need.
|
||||
*/
|
||||
if (state == NM_DEVICE_STATE_ACTIVATED || old_state == NM_DEVICE_STATE_ACTIVATED) {
|
||||
nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (nm_act_request_get_connection (req)),
|
||||
(guint64) time (NULL), TRUE);
|
||||
}
|
||||
|
||||
/* Handle the new state here; but anything that could trigger
|
||||
* another state change should be done below.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ vpn_manager_connection_activated_cb (NMVPNManager *manager,
|
|||
{
|
||||
/* Update timestamp for the VPN connection */
|
||||
nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (nm_vpn_connection_get_connection (vpn)),
|
||||
(guint64) time (NULL));
|
||||
(guint64) time (NULL), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -471,15 +471,6 @@ manager_device_state_changed (NMDevice *device,
|
|||
}
|
||||
|
||||
nm_manager_update_state (manager);
|
||||
|
||||
if (new_state == NM_DEVICE_STATE_ACTIVATED) {
|
||||
NMActRequest *req;
|
||||
|
||||
req = nm_device_get_act_request (device);
|
||||
if (req)
|
||||
nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (nm_act_request_get_connection (req)),
|
||||
(guint64) time (NULL));
|
||||
}
|
||||
}
|
||||
|
||||
/* Removes a device from a device list; returns the start of the new device list */
|
||||
|
|
@ -3929,7 +3920,7 @@ periodic_update_active_connection_timestamps (gpointer user_data)
|
|||
req = nm_manager_get_act_request_by_path (manager, active_path, &device);
|
||||
if (device && nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED)
|
||||
nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (nm_act_request_get_connection (req)),
|
||||
(guint64) time (NULL));
|
||||
(guint64) time (NULL), FALSE);
|
||||
else {
|
||||
/* The connection is probably VPN */
|
||||
NMVPNConnection *vpn_con;
|
||||
|
|
@ -3937,7 +3928,7 @@ periodic_update_active_connection_timestamps (gpointer user_data)
|
|||
vpn_con = nm_vpn_manager_get_vpn_connection_for_active (priv->vpn_manager, active_path);
|
||||
if (vpn_con && nm_vpn_connection_get_vpn_state (vpn_con) == NM_VPN_CONNECTION_STATE_ACTIVATED)
|
||||
nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (nm_vpn_connection_get_connection (vpn_con)),
|
||||
(guint64) time (NULL));
|
||||
(guint64) time (NULL), FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1422,11 +1422,14 @@ nm_settings_connection_get_timestamp (NMSettingsConnection *connection)
|
|||
* @connection: the #NMSettingsConnection
|
||||
* @timestamp: timestamp to set into the connection and to store into
|
||||
* the timestamps database
|
||||
* @flush_to_disk: if %TRUE, commit timestamp update to persistent storage
|
||||
*
|
||||
* Updates the connection and timestamps database with the provided timestamp.
|
||||
**/
|
||||
void
|
||||
nm_settings_connection_update_timestamp (NMSettingsConnection *connection, guint64 timestamp)
|
||||
nm_settings_connection_update_timestamp (NMSettingsConnection *connection,
|
||||
guint64 timestamp,
|
||||
gboolean flush_to_disk)
|
||||
{
|
||||
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection);
|
||||
const char *connection_uuid;
|
||||
|
|
@ -1438,6 +1441,9 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *connection, guint
|
|||
/* Update timestamp in private storage */
|
||||
priv->timestamp = timestamp;
|
||||
|
||||
if (flush_to_disk == FALSE)
|
||||
return;
|
||||
|
||||
/* Save timestamp to timestamps database file */
|
||||
timestamps_file = g_key_file_new ();
|
||||
if (!g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) {
|
||||
|
|
|
|||
|
|
@ -124,7 +124,9 @@ void nm_settings_connection_signal_remove (NMSettingsConnection *self);
|
|||
|
||||
guint64 nm_settings_connection_get_timestamp (NMSettingsConnection *connection);
|
||||
|
||||
void nm_settings_connection_update_timestamp (NMSettingsConnection *connection, guint64 timestamp);
|
||||
void nm_settings_connection_update_timestamp (NMSettingsConnection *connection,
|
||||
guint64 timestamp,
|
||||
gboolean flush_to_disk);
|
||||
|
||||
void nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue