Skip to content

Commit

Permalink
lxd/fsmonitor/drivers: Only log fanotify load errors if filesystem is…
Browse files Browse the repository at this point in the history
… mount point.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
  • Loading branch information
markylaing committed Sep 25, 2024
1 parent 247f73b commit 6b9b18b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lxd/fsmonitor/drivers/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"

"github.com/canonical/lxd/lxd/fsmonitor"
"github.com/canonical/lxd/lxd/storage/filesystem"
"github.com/canonical/lxd/shared/logger"
)

Expand Down Expand Up @@ -46,9 +47,18 @@ func Load(ctx context.Context, path string, events ...fsmonitor.Event) (fsmonito
return startMonitor(driverName)
}

driver, err := startMonitor(fsmonitor.DriverNameFANotify)
if err != nil {
logger.Warn("Failed to initialize fanotify, falling back on inotify", logger.Ctx{"err": err})
var driver fsmonitor.FSMonitor
var err error
if filesystem.IsMountPoint(path) {
// If the file system is a mount point, try to use fanotify but fall back to inotify.
driver, err = startMonitor(fsmonitor.DriverNameFANotify)
if err != nil {
logger.Warn("Failed to initialize fanotify, falling back on inotify", logger.Ctx{"err": err, "path": path})
}
}

// If the file system is not a mount point or if setting up fanotify fails for another reason, use inotify.
if driver == nil {
driver, err = startMonitor(fsmonitor.DriverNameINotify)
if err != nil {
return nil, err
Expand Down

0 comments on commit 6b9b18b

Please sign in to comment.