diff options
| author | Christopher Tate <ctate@google.com> | 2009-07-07 14:50:26 -0700 |
|---|---|---|
| committer | Christopher Tate <ctate@google.com> | 2009-07-07 14:50:26 -0700 |
| commit | a7de3845507b7bf57a2c7b26fb08f05b193697d6 (patch) | |
| tree | 7c9f8b7bb92e4db45255638fbf96401f9c4b0ac1 | |
| parent | c4cf22e82ba8ec4eec7051ae3a8eb397ded578d1 (diff) | |
| download | frameworks_base-a7de3845507b7bf57a2c7b26fb08f05b193697d6.zip frameworks_base-a7de3845507b7bf57a2c7b26fb08f05b193697d6.tar.gz frameworks_base-a7de3845507b7bf57a2c7b26fb08f05b193697d6.tar.bz2 | |
Only write to the pending-backup journal when necessary
We now only commit to the pending-backup journal on disk the first time that a
given package is added to the backup set. This avoids a lot of write thrashing
of the disk, particularly since Settings tends to call dataChanged() a great
many times during boot, while the Settings UI is in use, etc.
| -rw-r--r-- | services/java/com/android/server/BackupManagerService.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index 80697a1..1fd36d2 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/BackupManagerService.java @@ -1212,10 +1212,12 @@ class BackupManagerService extends IBackupManager.Stub { // Add the caller to the set of pending backups. If there is // one already there, then overwrite it, but no harm done. BackupRequest req = new BackupRequest(app, false); - mPendingBackups.put(app, req); - - // Journal this request in case of crash - writeToJournalLocked(packageName); + if (mPendingBackups.put(app, req) == null) { + // Journal this request in case of crash. The put() + // operation returned null when this package was not already + // in the set; we want to avoid touching the disk redundantly. + writeToJournalLocked(packageName); + } } } |
