Skip to content

feat: skip network mount points during indexing - #280

Merged
Johnson-zs merged 2 commits into
linuxdeepin:develop/snipefrom
Johnson-zs:agent/bugfix/bbd6e5308246
Oct 10, 2026
Merged

Johnson-zs merged 2 commits into
linuxdeepin:develop/snipefrom
Johnson-zs:agent/bugfix/bbd6e5308246

Conversation

@Johnson-zs

@Johnson-zs Johnson-zs commented Oct 10, 2026 •

Copy link
Copy Markdown

feat: skip network mount points during indexing

  1. Root cause: index traversal and inotify monitoring had no network
    filesystem detection; network mounts under $HOME (nfs, cifs,
    curlftpfs, etc.) were traversed, causing excessive network I/O and
    index bloat
  2. Fix: add NetworkMountDetector singleton using libmount to parse
    mountinfo and identify network mounts; integrate into
    shouldSkipDirectory() and shouldExcludePath() to skip them
  3. Refresh: add refresh() method with QReadWriteLock so mount info is
    re-parsed before each traversal and FSMonitor init, detecting
    network mounts added after service startup
  4. Impact: network mount points are no longer indexed or monitored;
    late-mounted network mounts are caught on re-index; local FUSE
    mounts with known subtypes remain unaffected; unknown FUSE mounts
    are conservatively skipped

Log: Skip network mount points during file indexing and monitoring

Influence:

  1. Test indexing with network mounts (nfs, cifs, curlftpfs) under $HOME
  2. Verify local FUSE mounts (ntfs, exfat) are still indexed normally
  3. Confirm no regression on standard mount paths (/mnt, /media)
  4. Test re-indexing after mounting a network path post-startup

feat: 索引时跳过网络挂载点

  1. 根因:索引遍历和 inotify 监控缺少网络文件系统检测,$HOME 下的
    网络挂载(nfs、cifs、curlftpfs 等)会被遍历,导致大量网络 I/O
    和索引膨胀
  2. 方案:新增 NetworkMountDetector 单例,通过 libmount 解析
    mountinfo 识别网络挂载点,集成到 shouldSkipDirectory() 和
    shouldExcludePath() 中进行跳过
  3. 刷新:新增 refresh() 方法并使用 QReadWriteLock 保护,在每次遍历
    和 FSMonitor 初始化前重新解析挂载信息,检测服务启动后新增的
    网络挂载点
  4. 影响:网络挂载点不再被索引或监控;后挂载的网络路径在重建索引时
    会被正确跳过;已知本地 FUSE 挂载不受影响;未知 FUSE 挂载保守跳过

Log: 索引和监控时跳过网络挂载点

Influence:

  1. 测试 $HOME 下网络挂载(nfs、cifs、curlftpfs)是否被正确跳过
  2. 验证本地 FUSE 挂载(ntfs、exfat)仍正常索引
  3. 确认标准挂载路径(/mnt、/media)无回归
  4. 测试服务启动后挂载网络路径再触发重建索引的场景

Summary by Sourcery

Skip network-mounted paths during indexing and filesystem monitoring while continuing to support recognized local mounts.

New Features:

  • Detect network-backed mount points and exclude them from indexing and filesystem monitoring.
  • Refresh mount information before traversals and monitor initialization so newly mounted network paths are recognized.

Bug Fixes:

  • Prevent network filesystems under indexed roots from causing excessive network I/O, unnecessary monitoring, and index growth.

Enhancements:

  • Preserve indexing for recognized local FUSE filesystems while conservatively excluding unknown FUSE mounts.
  • Protect mount-point state during concurrent reads and refreshes.

Build:

  • Include the network mount detector in the index build sources.

1. Root cause: index traversal and inotify monitoring had no network
   filesystem detection; network mounts under $HOME (nfs, cifs,
   curlftpfs, etc.) were traversed, causing excessive network I/O and
   index bloat
2. Fix: add NetworkMountDetector singleton using libmount to parse
   mountinfo and identify network mounts; integrate into
   shouldSkipDirectory() and shouldExcludePath() to skip them
3. Refresh: add refresh() method with QReadWriteLock so mount info is
   re-parsed before each traversal and FSMonitor init, detecting
   network mounts added after service startup
4. Impact: network mount points are no longer indexed or monitored;
   late-mounted network mounts are caught on re-index; local FUSE
   mounts with known subtypes remain unaffected; unknown FUSE mounts
   are conservatively skipped

Log: Skip network mount points during file indexing and monitoring

Influence:
1. Test indexing with network mounts (nfs, cifs, curlftpfs) under $HOME
2. Verify local FUSE mounts (ntfs, exfat) are still indexed normally
3. Confirm no regression on standard mount paths (/mnt, /media)
4. Test re-indexing after mounting a network path post-startup

feat: 索引时跳过网络挂载点

1. 根因:索引遍历和 inotify 监控缺少网络文件系统检测,$HOME 下的
   网络挂载(nfs、cifs、curlftpfs 等)会被遍历,导致大量网络 I/O
   和索引膨胀
2. 方案:新增 NetworkMountDetector 单例,通过 libmount 解析
   mountinfo 识别网络挂载点,集成到 shouldSkipDirectory() 和
   shouldExcludePath() 中进行跳过
3. 刷新:新增 refresh() 方法并使用 QReadWriteLock 保护,在每次遍历
   和 FSMonitor 初始化前重新解析挂载信息,检测服务启动后新增的
   网络挂载点
4. 影响:网络挂载点不再被索引或监控;后挂载的网络路径在重建索引时
   会被正确跳过;已知本地 FUSE 挂载不受影响;未知 FUSE 挂载保守跳过

Log: 索引和监控时跳过网络挂载点

Influence:
1. 测试 $HOME 下网络挂载(nfs、cifs、curlftpfs)是否被正确跳过
2. 验证本地 FUSE 挂载(ntfs、exfat)仍正常索引
3. 确认标准挂载路径(/mnt、/media)无回归
4. 测试服务启动后挂载网络路径再触发重建索引的场景
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Johnson-zs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Oct 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduces a libmount-backed, refreshable network mount detector and integrates it into indexing traversal and filesystem monitoring so NFS, CIFS, and other network-backed mounts are skipped, while recognized local FUSE filesystems remain eligible for indexing.

Sequence diagram for skipping network mounts during indexing and monitoring

sequenceDiagram
    participant Traversal as FileSystemProvider
    participant Monitor as FSMonitorPrivate
    participant Detector as NetworkMountDetector
    participant Mounts as libmount

    Traversal->>Detector: refresh()
    Detector->>Mounts: mnt_table_parse_mtab()
    Mounts-->>Detector: mount table
    loop Directory traversal
        Traversal->>Detector: isNetworkPath(path)
        Detector-->>Traversal: true → skip directory
    end

    Monitor->>Detector: refresh()
    Detector->>Mounts: mnt_table_parse_mtab()
    Mounts-->>Detector: mount table
    Monitor->>Detector: isNetworkPath(path)
    Detector-->>Monitor: true → exclude watch
Loading

Flow diagram for classifying filesystem mounts

flowchart TD
    Start[Mount entry] --> Type{Filesystem type}
    Type -->|nfs, cifs, sshfs, davfs, ceph, etc.| Network[Network mount]
    Type -->|Known local FUSE subtype| Local[Local mount; index normally]
    Type -->|Unknown FUSE or URL source| Network
    Type -->|Other non-FUSE| Local
    Network --> Skip[Skip traversal and filesystem watch]
Loading

File-Level Changes

Change Details Files
Add a thread-safe singleton that discovers network-backed mount points from the system mount table, including conservative handling of FUSE filesystems.
  • Parse mount entries with libmount and classify known network filesystem types.
  • Preserve known local FUSE subtypes while treating unknown FUSE mounts as network-backed.
  • Resolve paths canonically and match mount points and their descendants under a read lock.
  • Refresh the cached mount set through a write lock.
src/index/utils/networkmountdetector.cpp
src/index/utils/networkmountdetector.h
src/index/CMakeLists.txt
Prevent network-mounted directories from entering indexing traversal.
  • Refresh mount metadata before filesystem traversal.
  • Refresh mount metadata before mixed-path traversal.
  • Skip directories identified as network-mounted.
src/index/task/fileprovider.cpp
src/index/utils/indextraverseutils.cpp
Prevent filesystem monitoring from watching network-mounted paths, including mounts added after startup.
  • Refresh mount metadata during monitor initialization.
  • Exclude network mount paths from inotify monitoring.
src/index/fsmonitor/fsmonitor.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

1. Root cause: common desktop FUSE mounts (gvfsd-fuse, fusectl,
   xdg-document-portal) were conservatively classified as network
   filesystems, so m_networkMountPoints was never empty in practice;
   this made isNetworkPath() call canonicalFilePath() (stat + readlink)
   on every path even when no real network mounts existed
2. Fix: add gvfsd-fuse, portal, appimage, flatpak to localFuseSubtypes;
   only treat fusectl as local (not all FUSE types without fuse. prefix);
   bare "fuse" fstype (used by curlftpfs FTP mounts) still goes through
   source URL check and conservative network classification;
   add raw-path prefix check in isNetworkPath() before canonicalFilePath()
   so most paths skip the syscall entirely
3. Impact: m_networkMountPoints is empty on typical desktops without
   real network mounts, enabling zero-syscall fast path; FTP mounts
   (fstype "fuse") are correctly detected as network; real network
   mounts still detected and skipped

Influence:
1. Verify gvfsd-fuse mounts (/run/user/UID/gvfs) are not treated as
   network
2. Verify fusectl (/sys/fs/fuse/connections) is not treated as network
3. Test FTP FUSE mounts (fstype "fuse") are correctly detected as network
4. Test real network mounts (nfs, cifs) are still detected and skipped
5. Confirm symlink into network mount is still caught

fix: 修正 FUSE 分类并优化 isNetworkPath 性能

1. 根因:常见桌面 FUSE 挂载(gvfsd-fuse、fusectl、xdg-document-portal)
   被保守地归类为网络文件系统,导致 m_networkMountPoints 实际上从不
   为空;这使得 isNetworkPath() 在没有真实网络挂载时也对每个路径
   调用 canonicalFilePath()(stat + readlink),造成不必要的系统调用
   开销
2. 方案:将 gvfsd-fuse、portal、appimage、flatpak 加入
   localFuseSubtypes;仅将 fusectl 视为本地(不再将所有无 fuse. 前缀
   的 FUSE 类型视为本地);bare "fuse" 类型(curlftpfs FTP 挂载使用)
   仍走 source URL 检查和保守网络分类;在 isNetworkPath() 中先做原始
   路径前缀匹配,命中则直接返回,未命中且非符号链接则跳过
   canonicalFilePath() 调用
3. 影响:无真实网络挂载的典型桌面环境中 m_networkMountPoints 为空,
   走零系统调用快速路径;FTP 挂载(fstype "fuse")被正确识别为网络;
   真实网络挂载仍能被正确检测和跳过

Influence:
1. 验证 gvfsd-fuse 挂载(/run/user/UID/gvfs)不被视为网络挂载
2. 验证 fusectl(/sys/fs/fuse/connections)不被视为网络挂载
3. 测试 FTP FUSE 挂载(fstype "fuse")被正确识别为网络挂载
4. 测试真实网络挂载(nfs、cifs)仍能被正确检测和跳过
5. 确认指向网络挂载的符号链接仍能被正确识别
@Johnson-zs
Johnson-zs force-pushed the agent/bugfix/bbd6e5308246 branch from 1bd4059 to f19fbfb Compare October 10, 2026 08:11
@Johnson-zs
Johnson-zs merged commit c6c776e into linuxdeepin:develop/snipe Oct 10, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants