Re: Symlink not persisted even after fsync

Vijay Chidambaram
2018-04-15T01:14:16Z

Hi Dave,

Thank you for your detailed reply.

I think we still have a misunderstanding. Bear with me, much of this
may seem obvious to you, but not to us and future readers of this
mailing list :)

We are *not* saying an fsync on a symlink file has to result in any
action on the original file. We understand the lack of ordering
constraints here.

Consider the following:

/p/t/testdir> touch orig
/p/t/testdir> ln -s orig symlink

/p/t/testdir> ls -l
total 8
-rw-r--r-- 1 vijay wheel 0 Apr 14 19:31 orig
lrwxr-xr-x 1 vijay wheel 4 Apr 14 19:31 symlink -> orig

Here, there is a directory entry in testdir for symlink.

If we fsync symlink, is that directory entry persisted or not? That is
what we want to know. Regardless of whether symlink is a regular file
or an original file, it has a directory entry. We are saying *nothing*
about orig in this example.

If you fsync the symlink file ("symlink" in the example), does it
persist the directory entry for "symlink" also? Whatever relationship
exists between "testdir" and "orig", that relationship also exists
between "symlink" and "testdir".

>From your emails, I believe the answer is "no". The answer seems to be
"yes" for regular files, although this seems like an implementation
side-effect on file systems like btrfs (its not a guarantee btrfs
seeks to provide).

Regarding how we are able to fsync "symlink":

open(symlink) -> fails

but

fd = open(symlink, O_CREAT|O_RDWR) -> succeeds (even if symlink already exists)
fsync(fd) -> succeeds

So perhaps fsync on "symlink" is unsupported behavior that varies from
file system to file system? We saw ext4 and xfs had this behavior, so
we assumed it to be the default.

Thanks,
Vijay Chidambaram