HomeFreeBSD

Fix z_sync_cnt decrement in zfs_close

Description

Fix z_sync_cnt decrement in zfs_close

The comment in zfs_close states that "Under Linux the zfs_close() hook
is not symmetric with zfs_open()". This is not true. zfs_open/zfs_close
is associated with every successful struct file creation/deletion, which
should always be balanced.

Here is an example of what's wrong:

Process A B
open(O_SYNC)
z_sync_cnt = 1

			open(O_SYNC)
			z_sync_cnt = 2

close()
z_sync_cnt = 0

So z_sync_cnt is 0 even if B still has the file with O_SYNC.

Also moves the generic_file_open call before zfs_open to ensure that in
the case generic_file_open fails z_sync_cnt is not incremented. This
is safe because generic_file_open has no side effects.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #1962

Details

Provenance
Chunwei Chen <tuxoko@gmail.com>Authored on Dec 17 2013, 6:18 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Dec 17 2013, 6:28 PM
Parents
rGc2d439dffd4c: Silence e2fsck warning in zconfig.sh
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG7dc71949f2f0: Fix z_sync_cnt decrement in zfs_close (authored by Chunwei Chen <tuxoko@gmail.com>).Dec 17 2013, 6:28 PM