From 7998bc42041e99273bd0766017c6db70af7d9450 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 30 Apr 2025 16:50:08 -0400 Subject: [PATCH] BFS: Don't send duplicate attribute change notifications to queries on renames. LiveUpdateRenameMove() sends create/remove notifications, so we don't want to send duplicate ones in the LiveUpdate() hook. --- src/add-ons/kernel/file_systems/bfs/Index.cpp | 14 ++++++++------ src/add-ons/kernel/file_systems/bfs/Index.h | 5 +++-- .../kernel/file_systems/bfs/kernel_interface.cpp | 3 ++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Index.cpp b/src/add-ons/kernel/file_systems/bfs/Index.cpp index 4d8ff73437..d25cf3e3a8 100644 --- a/src/add-ons/kernel/file_systems/bfs/Index.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Index.cpp @@ -219,7 +219,7 @@ Index::Create(Transaction& transaction, const char* name, uint32 type) status_t Index::Update(Transaction& transaction, const char* name, int32 type, const uint8* oldKey, uint16 oldLength, const uint8* newKey, - uint16 newLength, Inode* inode) + uint16 newLength, Inode* inode, bool updateLiveQueries) { if (name == NULL || (oldKey == NULL && newKey == NULL) @@ -242,9 +242,11 @@ Index::Update(Transaction& transaction, const char* name, int32 type, return B_OK; } - // update all live queries about the change, if they have an index or not - fVolume->UpdateLiveQueries(inode, name, type, oldKey, oldLength, - newKey, newLength); + if (updateLiveQueries) { + // update all live queries about the change, if they have an index or not + fVolume->UpdateLiveQueries(inode, name, type, oldKey, oldLength, + newKey, newLength); + } if (((name != fName || strcmp(name, fName)) && SetTo(name) != B_OK) || fNode == NULL) @@ -297,14 +299,14 @@ Index::RemoveName(Transaction& transaction, const char* name, Inode* inode) status_t Index::UpdateName(Transaction& transaction, const char* oldName, - const char* newName, Inode* inode) + const char* newName, Inode* inode, bool updateLiveQueries) { ASSERT(inode->IsRegularNode()); uint16 oldLength = oldName != NULL ? strlen(oldName) : 0; uint16 newLength = newName != NULL ? strlen(newName) : 0; return Update(transaction, "name", B_STRING_TYPE, (uint8*)oldName, - oldLength, (uint8*)newName, newLength, inode); + oldLength, (uint8*)newName, newLength, inode, updateLiveQueries); } diff --git a/src/add-ons/kernel/file_systems/bfs/Index.h b/src/add-ons/kernel/file_systems/bfs/Index.h index 5825548b4e..5e675f799f 100644 --- a/src/add-ons/kernel/file_systems/bfs/Index.h +++ b/src/add-ons/kernel/file_systems/bfs/Index.h @@ -32,7 +32,8 @@ public: status_t Update(Transaction& transaction, const char* name, int32 type, const uint8* oldKey, uint16 oldLength, const uint8* newKey, - uint16 newLength, Inode* inode); + uint16 newLength, Inode* inode, + bool updateLiveQueries = true); status_t InsertName(Transaction& transaction, const char* name, Inode* inode); @@ -40,7 +41,7 @@ public: const char* name, Inode* inode); status_t UpdateName(Transaction& transaction, const char* oldName, const char* newName, - Inode* inode); + Inode* inode, bool updateLiveQueries = true); status_t InsertSize(Transaction& transaction, Inode* inode); status_t RemoveSize(Transaction& transaction, Inode* inode); diff --git a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp index 2b680fb999..e11956e517 100644 --- a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp @@ -1299,7 +1299,8 @@ bfs_rename(fs_volume* _volume, fs_vnode* _oldDir, const char* oldName, status = inode->SetName(transaction, newName); if (status == B_OK) { Index index(volume); - index.UpdateName(transaction, oldName, newName, inode); + index.UpdateName(transaction, oldName, newName, inode, + false /* we already updated live queries, above */); } }