Reading Time: 6 minutes

In this digital age, cross-site collaboration is more important than ever. Employees need to be able to work with each other no matter where they are. With cloud storage and other technology advancements, remote collaboration is easier than ever. 

But with the accessibility of data sharing and collaboration comes several challenges, most notably conflicting data modifications. Without proper communication, users can simultaneously work on the same data, nullifying each other’s work. And even with regular communication, mistakes happen and critical work can get overwritten. So, how can companies promote collaboration within a data set without compromising reliability and consistency?

Enter file locking — a data management feature that prevents users from modifying a specific file at the same time. File locks give a single user permission to access a file (or part of a file) at any given point in time. It provides the necessary framework for conflict-free data collaboration. Let’s take a closer look at some specific types of file locking.

Global File Locking Explained

Global file locking is a feature of cloud storage that ensures only one copy of a file is edited at a time. It eliminates confusion by enabling users to collaborate on the same set of data without the risk of working on top of each other.

One alternative to global file locking is versioning, which allows users to open a second copy of a file that another user is currently using. That second copy is tracked as a unique file. While versioning enables users to work simultaneously on the same file, any changes made to the individual copies must be manually integrated to ensure they are incorporated into the final version. 

But here’s the downside: global file locking can be expensive. Since it’s more advanced than standard file sharing options, services that offer global file locking are often sold at a higher price. Knowing this, companies should consider whether global file locking is an investment they want to make.

Types of File Locking

If they’ve decided file locking is a critical solution for their needs, organizations will need to consider what type of file locking they want to use. There are several options with various benefits and drawbacks depending on the use case. 

1). Advisory Locking

Advisory locking doesn’t provide full protection against conflicting modifications because it relies on cooperation between users. Users can ignore an advisory lock, but that choice is strongly discouraged because it can lead to data corruption and inconsistency.

When a user requests access to a file, the advisory lock will notify that user that a lock is in place. Again, the advisory lock doesn’t prevent access; it only informs the user that they should avoid working on the file. When a user requests an advisory lock for a file, the system will check for any existing locks. If there are existing locks, it will return an error message.

Advisory locks are most effective if multiple users need to access a file simultaneously. However, those users should also communicate with each other so only one user is writing at a time. Even while an advisory lock is in place, other users can continue reading the file without causing problems. 

2.) Mandatory Locking

Mandatory locks are enforced by an operating system that prevents users from accessing or modifying a file that another user has already locked. Unlike with advisory locks, users can’t choose to ignore mandatory locks. If a user requests a mandatory lock but another mandatory lock already exists, the user will be denied access to the file until the other lock is released.

Mandatory locking is useful when a company needs to keep multiple users from modifying the same file simultaneously. In that case, this type of lock ensures data consistency and prevents file corruption.

On the downside, mandatory locking can create performance overhead and result in synchronization issues if not used properly. The feature is also not available on all files or operating systems, so companies should always verify it’s compatible with their systems before purchasing.

3.) Shared Locking

With shared locks, multiple users can access a file simultaneously for reading purposes only. All editing is prevented with a shared lock, which ensures consistency and integrity. Shared locks are granted to users if they don’t conflict with existing locks on a file. An exclusive lock can’t be granted until all shared locks are released.

Shared locks are excellent for companies looking to improve system performance and efficiency. However, if a file needs to be modified frequently, shared locking may not be ideal since editing is prohibited until all shared locks are released. 

4.) Exclusive Locking

Exclusive locks only allow one user to access a file at a given time. This lock keeps all other users from accessing the file for both read and write purposes. If a particular user needs frequent access to a file, exclusive locking is an ideal solution, as it ensures that nobody else will create conflicting modifications. 

One drawback of exclusive locking is that it can create performance overhead. If a single user holds the exclusive lock for a file, all other users must wait for the lock to be released before opening the file. 

5.) Range Locking

Range locking allows a user to lock a specific byte range within a file. When requesting a range lock, users can specify the start and end point of the byte range within which they will work. The request will be granted as long as there is no overlap with any other range locks. 

With range locking, multiple users can access and edit the same file without risking conflicting modifications. Once a user has a range lock on a designated byte range, no other user can edit that byte range until the lock is released. 

Range locking is not supported by all file or operating systems, so companies should evaluate whether their systems are compatible with range locking before choosing this type of file locking. 

DFSR & File Locking

Distributed file system replication (DFSR) is a common term for collaborative file sharing. DFSR is a Windows feature that allows users to replicate files between multiple servers in multiple locations, improving the availability and reliability of file access.

Here’s how it works: DFSR identifies changes made to a file on one server and replicates those changes to other servers. All changes are tracked at the block level, allowing servers to replicate specific changes to files rather than entire files. DFSR can be synchronous or asynchronous. In synchronous mode, the changes are replicated immediately to other servers, so all users have access to the same version of a file at the same time. In asynchronous mode, the changes are queued for replication and may take time to be distributed to other servers. 

While DFSR enables efficient file sharing and collaboration, it’s not always compatible with file locking. DFSR doesn’t track any locks that exist on other servers, meaning users can unknowingly overwrite each other’s changes. The last user to save their changes on a file gets to keep their changes. DFSR only recognizes locks within its native server and won’t replicate a file if the local copy has an exclusive lock. But again, this local locking doesn’t prevent users from other servers from accessing or modifying their own local copy of the same file. 

So, while DFSR boasts incredible capabilities and offers a powerful tool for companies looking to share files across multiple servers, there may be better options for companies that want to utilize file locking.

Panzura’s Approach

We agree that file locking is a key component of sharing and collaboration. But rather than using existing technology — we decided to develop our own. We created and patented our own locking systems to ensure local performance and protect stored data from corruption.

Panzura offers two types of file locks: a global write lock and a byte range lock. Global write locking prevents more than one user from opening a file and making modifications. A second user can’t write on that file until the initial write lock has been released. Byte range locking is an excellent solution for businesses that want to utilize file locking while enabling employees to work simultaneously on the same files. This type of lock only restricts in-use file portions, allowing multiple users to work on the same file in different byte ranges without worrying about data collisions, corruption, or file versioning.    

Both of our locks cover a company’s entire cloud network across any number of locations. When a file is opened, the lock is moved to where the data is stored in the global file system. So, the file is locked for editing across the cloud network. Only real-time file locking effectively prevents user collisions. Our globally distributed file-locking feature allows every site in the network to issue a real-time request for a lock from whichever site currently holds it.

File locking makes it easy for companies to collaborate globally, but only some types of file locking will be a good match for specific companies. Here at Panzura, we strive to give every company a file locking solution they can use confidently. With Panzura file locking, users have global access to all their files without fearing collisions. There’s no limit to what companies can do with their data — so antiquated file locking methods shouldn’t hold them back.