# US 12,222,904 B2 · Avoiding data inconsistency in a file system using 2-level synchronization

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,222,904 B2
- Document ID: US12222904B2
- Status: Granted
- Kind: B2
- Application number: 18/189,979
- Filed: 2023-03-24
- Published: 2023-07-20
- Granted: 2025-02-11
- Earliest claimed: 2021-06-23
- Assignees: VMware, Inc.
- Applicants: VMware LLC
- Inventors: Mahesh Hiregoudar; Prasanna Aithal; Prasad Rao Jangam; Srinivasa Shantharam; Rohan Pasalkar; Srikanth Mahabalarao
- Web page: https://patentgrep.com/patent/US12222904B2

## CPC

- G06F 16/178: Techniques for file synchronisation in file systems
- G06F 16/1727: {Details of free space management performed by the file system (saving storage space on storage systems G06F3/0608; management of blocks in storage devices G06F3/064)}
- G06F 16/1774: {Locking methods, e.g. locking methods for file systems allowing shared and concurrent access to files}
- G06F 16/188: Virtual file systems
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method of synchronously executing input/output operations (IOs) for a plurality of applications using a storage device with a file system includes the steps of: receiving a first write IO including an instruction to write first data at a first address of the file system; determining that, within a first range of the file system comprising the first address, there are no pending unmap IOs for deallocating storage space of the storage device from files of the plurality of applications; after determining that there are no pending unmap IOs within the first range, locking the first range to prevent incoming unmap IOs from deallocating storage space within the first range from the files of the plurality of applications; after locking the first range, writing the first data to the storage device at the first address; and after writing the first data, unlocking the first range.

## Claims

### Claim 1

A method of synchronously executing input/output operations (IOs) issued by a plurality of virtual computing instances to a file system implemented by one or more storage devices, the method comprising:
detecting a first write IO issued by one of the virtual computing instances, wherein the first write IO includes an instruction to write first data at a first address of a file data block of a file of the file system;
determining by checking metadata of a pointer block of the file that points to the file data block, that a first address range of the file system comprising the first address is locked so as to prevent any pending unmap IOs issued by the virtual computing instances from deallocating storage space of the one or more storage devices mapped to addresses of file data blocks within the first address range; and
in response to determining that the first address range is locked, writing the first data to the one or more storage devices at the first address while the first address range is locked.

### Claim 2 (depends on 1)

The method of claim 1, further comprising:
before writing the first data to the one or more storage devices, incrementing a variable of the pointer block that identifies a number of pending write IOs issued by the virtual computing instances including instructions to write data at addresses of file data blocks within a second address range of the file system that comprises the first address range; and
after writing the first data to the one or more storage devices, decrementing the variable.

### Claim 3 (depends on 1)

The method of claim 1, further comprising:
unlocking the first address range when there are no pending write IOs issued by the virtual computing instances including instructions to write data at addresses of file data blocks within the first address range, so as to allow an unmap IO issued by the one of the virtual computing instances to deallocate storage space of the one or more storage devices mapped to a second address of a file data block of the file within the first address range.

### Claim 4 (depends on 1)

The method of claim 1, further comprising:
before determining that the first address range is locked, determining that there is a pending unmap IO issued by the virtual computing instances for deallocating storage space of the one or more storage devices mapped to a second address of a file data block of the file within a second address range of the file system that comprises the first address range.

### Claim 5 (depends on 1)

The method of claim 1, wherein the file system is a virtual machine file system, the first write IO is a small computer system interface (SCSI) write command, and unmap IOs issued by the virtual computing instances are SCSI unmap commands.

### Claim 6 (depends on 1)

The method of claim 1, further comprising:
detecting an unmap IO issued by the one of the virtual computing instances including an instruction to deallocate storage space mapped to a second address of a file data block of the file within the first address range;
in response to detecting the unmap IO, determining that the first address range is not locked for any pending write IOs issued by the virtual computing instances; and
in response to determining that the first address range is not locked for any pending write IOs,
locking the first address range so as to prevent any incoming write IOs issued by the virtual computing instances from writing data at addresses of file data blocks within the first address range, then
deallocating the storage space mapped to the second address, and then
unlocking the first address range so as to allow incoming write IOs issued by the virtual computing instances to write data at addresses of file data blocks within the first address range.

### Claim 7 (depends on 6)

The method of claim 6, further comprising:
in response to detecting the unmap IO, incrementing a variable of the pointer block that indicates a number of pending unmap IOs issued by the virtual computing instances for deallocating storage space mapped to addresses of file data blocks within the first address range.

### Claim 8

A non-transitory computer-readable medium comprising instructions that are executable in a computer system, wherein the instructions when executed cause one or more storage devices of the computer system to carry out a method of synchronously executing input/output operations (IOs) issued by a plurality of virtual computing instances to a file system implemented by the one or more storage devices, and wherein the method comprises:
detecting a first write IO issued by one of the virtual computing instances, wherein the first write IO includes an instruction to write first data at a first address of a file data block of a file of the file system;
determining by checking metadata of a pointer block of the file that points to the file data block, that a first address range of the file system comprising the first address is locked so as to prevent any pending unmap IOs issued by the virtual computing instances from deallocating storage space of the one or more storage devices mapped to addresses of file data blocks within the first address range; and
in response to determining that the first address range is locked, writing the first data to the one or more storage devices at the first address while the first address range is locked.

### Claim 9 (depends on 8)

The non-transitory computer-readable medium of claim 8, wherein the method further comprises:
before writing the first data to the one or more storage devices, incrementing a variable of the pointer block that identifies a number of pending write IOs issued by the virtual computing instances including instructions to write data at addresses of file data blocks within a second address range of the file system that comprises the first address range; and
after writing the first data to the one or more storage devices, decrementing the variable.

### Claim 10 (depends on 8)

The non-transitory computer-readable medium of claim 8, wherein the method further comprises:
unlocking the first address range when there are no pending write IOs issued by the virtual computing instances including instructions to write data at addresses of file data blocks within the first address range, so as to allow an unmap IO issued by the one of the virtual computing instances to deallocate storage space of the one or more storage devices mapped to a second address of a file data block of the file within the first address range.

### Claim 11 (depends on 8)

The non-transitory computer-readable medium of claim 8, wherein the method further comprises:
before determining that the first address range is locked, determining that there is a pending unmap IO issued by the virtual computing instances for deallocating storage space of the one or more storage devices mapped to a second address of a file data block of the file within a second address range of the file system that comprises the first address range.

### Claim 12 (depends on 8)

The non-transitory computer-readable medium of claim 8, wherein the file system is a virtual machine file system, the first write IO is a small computer system interface (SCSI) write command, and unmap IOs issued by the virtual computing instances are SCSI unmap commands.

### Claim 13 (depends on 8)

The non-transitory computer-readable medium of claim 8, wherein the method further comprises:
detecting an unmap IO issued by the one of the virtual computing instances including an instruction to deallocate storage space mapped to a second address of a file data block of the file within the first address range;
in response to detecting the unmap IO, determining that the first address range is not locked for any pending write IOs issued by the virtual computing instances; and
in response to determining that the first address range is not locked for any pending write IOs,
locking the first address range so as to prevent any incoming write IOs issued by the virtual computing instances from writing data at addresses of file data blocks within the first address range, then
deallocating the storage space mapped to the second address, and then
unlocking the first address range so as to allow incoming write IOs issued by the virtual computing instances to write data at addresses of file data blocks within the first address range.

### Claim 14 (depends on 13)

The non-transitory computer-readable medium of claim 13, wherein the method further comprises:
in response to detecting the unmap IO, incrementing a variable of the pointer block that indicates a number of pending unmap IOs issued by the virtual computing instances for deallocating storage space mapped to addresses of file data blocks within the first address range.

### Claim 15

One or more storage devices implementing a file system for a plurality of virtual computing instances, wherein the one or more storage devices include a processor configured to:
detect a first write IO issued by one of the virtual computing instances, wherein the first write IO includes an instruction to write first data at a first address of a file data block of a file of the file system;
determine by checking metadata of a pointer block of the file that points to the file data block, that a first address range of the file system comprising the first address is locked so as to prevent any pending unmap IOs issued by the virtual computing instances from deallocating storage space of the one or more storage devices mapped to addresses of file data blocks within the first address range; and
in response to determining that the first address range is locked, write the first data at the first address while the first address range is locked.

### Claim 16 (depends on 15)

The one or more storage devices of claim 15, wherein the processor is further configured to:
before writing the first data at the first address, increment a variable of the pointer block that identifies a number of pending write IOs issued by the virtual computing instances including instructions to write data at addresses of file data blocks within a second address range of the file system that comprises the first address range; and
after writing the first data at the first address, decrement the variable.

### Claim 17 (depends on 15)

The one or more storage devices of claim 15, wherein the processor is further configured to:
unlock the first address range when there are no pending write IOs issued by the virtual computing instances including instructions to write data at addresses of file data blocks within the first address range, so as to allow an unmap IO issued by the one of the virtual computing instances to deallocate storage space of the one or more storage devices mapped to a second address of a file data block of the file within the first address range.

### Claim 18 (depends on 15)

The one or more storage devices of claim 15, wherein the processor is further configured to:
before determining that the first address range is locked, determine that there is a pending unmap IO issued by the virtual computing instances for deallocating storage space of the one or more storage devices mapped to a second address of a file data block of the file within a second address range of the file system that comprises the first address range.

### Claim 19 (depends on 15)

The one or more storage devices of claim 15, wherein the processor is further configured to:
detect an unmap IO issued by the one of the virtual computing instances including an instruction to deallocate storage space mapped to a second address of a file data block of the file within the first address range;
in response to detecting the unmap IO, determine that the first address range is not locked for any pending write IOs issued by the virtual computing instances; and
in response to determining that the first address range is not locked for any pending write IOs,
lock the first address range so as to prevent any incoming write IOs issued by the virtual computing instances from writing data at addresses of file data blocks within the first address range, then
deallocate the storage space mapped to the second address, and then
unlock the first address range so as to allow incoming write IOs issued by the virtual computing instances to write data at addresses of file data blocks within the first address range.

### Claim 20 (depends on 19)

The one or more storage devices of claim 19, wherein the processor is further configured to:
in response to detecting the unmap IO, increment a variable of the pointer block that indicates a number of pending unmap IOs issued by the virtual computing instances for deallocating storage space mapped to addresses of file data blocks within the first address range.
