LibreOffice File Locking on Shared Network Drives

When multiple users collaborate on documents across network shares, LibreOffice relies on a combination of application-level lock files and operating system network protocols to prevent conflicting simultaneous edits. This article details the native locking mechanisms used by LibreOffice, the supported network file protocols—including SMB/CIFS, NFS, and WebDAV—and how these systems interact to protect document integrity.

Application-Level Lock Files

LibreOffice primarily prevents simultaneous write access by generating hidden lock files directly in the same directory as the target document.

Network-Level File Locking Protocols

In addition to internal lock files, LibreOffice depends on the underlying network protocol of the shared storage environment to enforce file access controls and maintain write safety.

1. SMB / CIFS (Server Message Block)

SMB is the standard protocol for Windows file shares and Samba-configured Linux servers. * Byte-Range Locking: LibreOffice uses standard OS-level byte-range locks to ensure that no two processes write to the same sector of a file at once. * Opportunistic Locking (Oplocks): SMB uses oplocks to allow clients to cache data locally. When a second user requests access, the server revokes the lock, forcing cache synchronization before read-only access is granted.

2. NFS (Network File System)

Used commonly in Linux and Unix-based enterprise storage systems. * POSIX fcntl() and flock(): LibreOffice relies on POSIX file locking calls via the operating system kernel. * NFSv3 vs. NFSv4: On NFSv3, locking is handled by the Network Lock Manager (NLM) daemon. NFSv4 integrates stateful, lease-based file locking directly into the core protocol, providing more reliable detection and release of abandoned locks.

3. WebDAV (Web Distributed Authoring and Versioning)

When LibreOffice accesses remote shares via its built-in remote files service over HTTP/HTTPS, it utilizes WebDAV locking. * RFC 4918 Locking: LibreOffice issues HTTP LOCK and UNLOCK requests to the WebDAV server. * Exclusive Write Locks: A successful LOCK request issues an XML-based lock token to the active editor. Any subsequent PUT or LOCK requests from other clients without this token are rejected with an HTTP 423 (Locked) status code.

Critical Settings and Considerations