@@ -212,6 +212,8 @@ public function setupForUser(IUser $user): void {
212212 }
213213 $ this ->setupUsersComplete [] = $ user ->getUID ();
214214
215+ $ this ->eventLogger ->start ('fs:setup:user:full ' , 'Setup full filesystem for user ' );
216+
215217 if (!isset ($ this ->setupUserMountProviders [$ user ->getUID ()])) {
216218 $ this ->setupUserMountProviders [$ user ->getUID ()] = [];
217219 }
@@ -226,6 +228,7 @@ public function setupForUser(IUser $user): void {
226228 });
227229 });
228230 $ this ->afterUserFullySetup ($ user , $ previouslySetupProviders );
231+ $ this ->eventLogger ->end ('fs:setup:user:full ' );
229232 }
230233
231234 /**
@@ -237,6 +240,8 @@ private function oneTimeUserSetup(IUser $user) {
237240 }
238241 $ this ->setupUsers [] = $ user ->getUID ();
239242
243+ $ this ->eventLogger ->start ('fs:setup:user:onetime ' , 'Onetime filesystem for user ' );
244+
240245 $ this ->setupBuiltinWrappers ();
241246
242247 $ prevLogging = Filesystem::logWarningWhenAddingStorageWrapper (false );
@@ -250,14 +255,18 @@ private function oneTimeUserSetup(IUser $user) {
250255 Filesystem::initInternal ($ userDir );
251256
252257 if ($ this ->lockdownManager ->canAccessFilesystem ()) {
258+ $ this ->eventLogger ->start ('fs:setup:user:home ' , 'Setup home filesystem for user ' );
253259 // home mounts are handled separate since we need to ensure this is mounted before we call the other mount providers
254260 $ homeMount = $ this ->mountProviderCollection ->getHomeMountForUser ($ user );
255261 $ this ->mountManager ->addMount ($ homeMount );
256262
257263 if ($ homeMount ->getStorageRootId () === -1 ) {
264+ $ this ->eventLogger ->start ('fs:setup:user:home:scan ' , 'Scan home filesystem for user ' );
258265 $ homeMount ->getStorage ()->mkdir ('' );
259266 $ homeMount ->getStorage ()->getScanner ()->scan ('' );
267+ $ this ->eventLogger ->end ('fs:setup:user:home:scan ' );
260268 }
269+ $ this ->eventLogger ->end ('fs:setup:user:home ' );
261270 } else {
262271 $ this ->mountManager ->addMount (new MountPoint (
263272 new NullStorage ([]),
@@ -271,12 +280,15 @@ private function oneTimeUserSetup(IUser $user) {
271280 }
272281
273282 $ this ->listenForNewMountProviders ();
283+
284+ $ this ->eventLogger ->end ('fs:setup:user:onetime ' );
274285 }
275286
276287 /**
277288 * Final housekeeping after a user has been fully setup
278289 */
279290 private function afterUserFullySetup (IUser $ user , array $ previouslySetupProviders ): void {
291+ $ this ->eventLogger ->start ('fs:setup:user:full:post ' , 'Housekeeping after user is setup ' );
280292 $ userRoot = '/ ' . $ user ->getUID () . '/ ' ;
281293 $ mounts = $ this ->mountManager ->getAll ();
282294 $ mounts = array_filter ($ mounts , function (IMountPoint $ mount ) use ($ userRoot ) {
@@ -296,6 +308,7 @@ private function afterUserFullySetup(IUser $user, array $previouslySetupProvider
296308 $ this ->cache ->set ($ user ->getUID (), true , $ cacheDuration );
297309 $ this ->fullSetupRequired [$ user ->getUID ()] = false ;
298310 }
311+ $ this ->eventLogger ->end ('fs:setup:user:full:post ' );
299312 }
300313
301314 /**
@@ -312,17 +325,17 @@ private function setupForUserWith(IUser $user, callable $mountCallback): void {
312325 $ this ->oneTimeUserSetup ($ user );
313326 }
314327
315- $ this ->eventLogger ->start ('setup_fs ' , 'Setup filesystem ' );
316-
317328 if ($ this ->lockdownManager ->canAccessFilesystem ()) {
318329 $ mountCallback ();
319330 }
331+ $ this ->eventLogger ->start ('fs:setup:user:post-init-mountpoint ' , 'post_initMountPoints legacy hook ' );
320332 \OC_Hook::emit ('OC_Filesystem ' , 'post_initMountPoints ' , ['user ' => $ user ->getUID ()]);
333+ $ this ->eventLogger ->end ('fs:setup:user:post-init-mountpoint ' );
321334
322335 $ userDir = '/ ' . $ user ->getUID () . '/files ' ;
336+ $ this ->eventLogger ->start ('fs:setup:user:setup-hook ' , 'setup legacy hook ' );
323337 OC_Hook::emit ('OC_Filesystem ' , 'setup ' , ['user ' => $ user ->getUID (), 'user_dir ' => $ userDir ]);
324-
325- $ this ->eventLogger ->end ('setup_fs ' );
338+ $ this ->eventLogger ->end ('fs:setup:user:setup-hook ' );
326339 }
327340
328341 /**
@@ -335,7 +348,7 @@ public function setupRoot(): void {
335348 }
336349 $ this ->rootSetup = true ;
337350
338- $ this ->eventLogger ->start ('setup_root_fs ' , 'Setup root filesystem ' );
351+ $ this ->eventLogger ->start ('fs:setup:root ' , 'Setup root filesystem ' );
339352
340353 $ this ->setupBuiltinWrappers ();
341354
@@ -344,7 +357,7 @@ public function setupRoot(): void {
344357 $ this ->mountManager ->addMount ($ rootMountProvider );
345358 }
346359
347- $ this ->eventLogger ->end ('setup_root_fs ' );
360+ $ this ->eventLogger ->end ('fs:setup:root ' );
348361 }
349362
350363 /**
@@ -413,6 +426,9 @@ public function setupForPath(string $path, bool $includeChildren = false): void
413426 $ this ->oneTimeUserSetup ($ user );
414427 }
415428
429+ $ this ->eventLogger ->start ('fs:setup:user:path ' , "Setup $ path filesystem for user " );
430+ $ this ->eventLogger ->start ('fs:setup:user:path:find ' , "Find mountpoint for $ path " );
431+
416432 $ mounts = [];
417433 if (!in_array ($ cachedMount ->getMountProvider (), $ setupProviders )) {
418434 $ currentProviders [] = $ cachedMount ->getMountProvider ();
@@ -421,13 +437,16 @@ public function setupForPath(string $path, bool $includeChildren = false): void
421437 $ mounts = $ this ->mountProviderCollection ->getUserMountsForProviderClasses ($ user , [$ cachedMount ->getMountProvider ()]);
422438 } else {
423439 $ this ->logger ->debug ("mount at " . $ cachedMount ->getMountPoint () . " has no provider set, performing full setup " );
440+ $ this ->eventLogger ->end ('fs:setup:user:path:find ' );
424441 $ this ->setupForUser ($ user );
442+ $ this ->eventLogger ->end ('fs:setup:user:path ' );
425443 return ;
426444 }
427445 }
428446
429447 if ($ includeChildren ) {
430448 $ subCachedMounts = $ this ->userMountCache ->getMountsInPath ($ user , $ path );
449+ $ this ->eventLogger ->end ('fs:setup:user:path:find ' );
431450
432451 $ needsFullSetup = array_reduce ($ subCachedMounts , function (bool $ needsFullSetup , ICachedMountInfo $ cachedMountInfo ) {
433452 return $ needsFullSetup || $ cachedMountInfo ->getMountProvider () === '' ;
@@ -436,6 +455,7 @@ public function setupForPath(string $path, bool $includeChildren = false): void
436455 if ($ needsFullSetup ) {
437456 $ this ->logger ->debug ("mount has no provider set, performing full setup " );
438457 $ this ->setupForUser ($ user );
458+ $ this ->eventLogger ->end ('fs:setup:user:path ' );
439459 return ;
440460 } else {
441461 foreach ($ subCachedMounts as $ cachedMount ) {
@@ -446,6 +466,8 @@ public function setupForPath(string $path, bool $includeChildren = false): void
446466 }
447467 }
448468 }
469+ } else {
470+ $ this ->eventLogger ->end ('fs:setup:user:path:find ' );
449471 }
450472
451473 if (count ($ mounts )) {
@@ -456,6 +478,7 @@ public function setupForPath(string $path, bool $includeChildren = false): void
456478 } elseif (!$ this ->isSetupStarted ($ user )) {
457479 $ this ->oneTimeUserSetup ($ user );
458480 }
481+ $ this ->eventLogger ->end ('fs:setup:user:path ' );
459482 }
460483
461484 private function fullSetupRequired (IUser $ user ): bool {
@@ -488,6 +511,8 @@ public function setupForProvider(string $path, array $providers): void {
488511 return ;
489512 }
490513
514+ $ this ->eventLogger ->start ('fs:setup:user:providers ' , "Setup filesystem for " . implode (', ' , $ providers ));
515+
491516 // home providers are always used
492517 $ providers = array_filter ($ providers , function (string $ provider ) {
493518 return !is_subclass_of ($ provider , IHomeMountProvider::class);
@@ -504,6 +529,7 @@ public function setupForProvider(string $path, array $providers): void {
504529 if (!$ this ->isSetupStarted ($ user )) {
505530 $ this ->oneTimeUserSetup ($ user );
506531 }
532+ $ this ->eventLogger ->end ('fs:setup:user:providers ' );
507533 return ;
508534 } else {
509535 $ this ->setupUserMountProviders [$ user ->getUID ()] = array_merge ($ setupProviders , $ providers );
@@ -514,6 +540,7 @@ public function setupForProvider(string $path, array $providers): void {
514540 $ this ->setupForUserWith ($ user , function () use ($ mounts ) {
515541 array_walk ($ mounts , [$ this ->mountManager , 'addMount ' ]);
516542 });
543+ $ this ->eventLogger ->end ('fs:setup:user:providers ' );
517544 }
518545
519546 public function tearDown () {
0 commit comments