Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

synchronous open count in zfs_close() needs to be decremented #237

Closed
rohan-puri opened this issue May 10, 2011 · 3 comments
Closed

synchronous open count in zfs_close() needs to be decremented #237

rohan-puri opened this issue May 10, 2011 · 3 comments
Milestone

Comments

@rohan-puri
Copy link
Contributor

Hi Brian,

A small issue : -

z_sync_count needs to be decremented in zfs_close() if O_SYNC flag is specified.

Bug : -

/* Decrement the synchronous opens in the znode */
if (flag & O_SYNC)
zp->z_sync_cnt = 0;

Probable fix : -

/* Decrement the synchronous opens in the znode */
if (flag & O_SYNC)
atomic_dec_32(&zp->z_sync_cnt);

@behlendorf
Copy link
Contributor

Thanks, for catching this. I'll commit a fix shortly which is exactly what you suggest. Did you just happen to stumble across this in the code or did it cause a problem on your system somehow?

@behlendorf
Copy link
Contributor

Actually, I take it back. This isn't quite so simple, I believe the original code is correct but it could certainly use a comment. Unlike Solaris Linux only calls its close/release callback once after everyone who has the file has closed it. For Solaris it is called per-close. So we really do want to set it to zero since this will not be symmetric with open.

@rohan-puri
Copy link
Contributor Author

I was going through the code and thats when got to it.
Agree to what you say. Its correct, release is called when the last reference to the file object is closed, hence setting it to zero is correct.

gmelikov pushed a commit to gmelikov/zfs that referenced this issue Jan 27, 2017
Authored by: George Wilson <[email protected]>
Reviewed by: Pavel Zakharov <[email protected]>
Reviewed by: Steve Gonczi <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
We need to prevent any reader whenever we're about the zero out all the
blkptrs. To do this we need to grab the dn_struct_rwlock as writer in
dbuf_write_children_ready and free_children just prior to calling bzero.
Closes openzfs#237
Ported-by: George Melikov <[email protected]>

OpenZFS-issue: https://www.illumos.org/issues/7580
OpenZFS-commit: openzfs/openzfs@3105d95
gmelikov pushed a commit to gmelikov/zfs that referenced this issue Jan 27, 2017
Authored by: George Wilson <[email protected]>
Reviewed by: Pavel Zakharov <[email protected]>
Reviewed by: Steve Gonczi <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
We need to prevent any reader whenever we're about the zero out all the
blkptrs. To do this we need to grab the dn_struct_rwlock as writer in
dbuf_write_children_ready and free_children just prior to calling bzero.
Closes openzfs#237
Ported-by: George Melikov <[email protected]>

OpenZFS-issue: https://www.illumos.org/issues/7580
OpenZFS-commit: openzfs/openzfs@3105d95
fuhrmannb pushed a commit to fuhrmannb/cstor that referenced this issue Nov 3, 2020
ixhamza pushed a commit to ixhamza/zfs that referenced this issue May 23, 2024
Fix P2ALIGN overflow in dmu_object_alloc_impl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants