2022-01-24 19:40:53

by Tao Lyu

[permalink] [raw]
Subject: How does EXT4 ensures two processes don't modify and synchronize one page at the same time.

Hi,

I'm new to file system area and have a naive question about the global sync.

Let's suppose there are two process are writing to the same file. If one process issues a sync() syscall, which mechanism can ensures the two processes don't modify and synchronize one page at the same time.

Best,
Tao


2022-01-24 19:52:28

by Theodore Ts'o

[permalink] [raw]
Subject: Re: How does EXT4 ensures two processes don't modify and synchronize one page at the same time.

On Mon, Jan 24, 2022 at 05:17:34PM +0000, Lyu Tao wrote:
>
> I'm new to file system area and have a naive question about the global sync.
>
> Let's suppose there are two process are writing to the same file. If
> one process issues a sync() syscall, which mechanism can ensures the
> two processes don't modify and synchronize one page at the same
> time.

That's not what the sync() system call purports to do. To quote from
the sync(2) man page:

sync() causes all pending modifications to filesystem metadata
and cached file data to be written to the underlying
filesystems.

- Ted