Page MenuHomeFreeBSD

Ask sync(8) to sync multiple times
AbandonedPublic

Authored by sef on Sep 14 2019, 8:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 22 2024, 7:07 AM
Unknown Object (File)
Dec 23 2023, 3:34 AM
Unknown Object (File)
Oct 15 2023, 8:26 AM
Unknown Object (File)
Oct 15 2023, 8:26 AM
Unknown Object (File)
Oct 4 2023, 5:13 AM
Unknown Object (File)
Sep 18 2023, 11:48 AM
Unknown Object (File)
Jun 29 2023, 2:57 PM
Unknown Object (File)
Jun 28 2023, 5:29 PM
Subscribers

Details

Reviewers
imp
Group Reviewers
Src Committers
manpages
Summary

This is dumb. I admit it.

But I was deep into something and kept typing "sync sync sync" and getting annoyed when it only called sync(2) once.

If this is too stupid to allow, I accept that.

Test Plan

[ truss -o /dev/stdout sync 5 | grep ^sync | wc -l -eq 5 ] && echo good
[ truss -o /dev/stdout sync sync sync | grep ^sync | wc -l -eq 3 ] && echo good
[ truss -o /dev/stdout sync -10 | grep ^sync | wc -l -eq 2 ] && echo good

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

I think that a need for sync ; sync ; sync is greatly exaggerated.
If you think that it's useful and sync 3 would be an improvement, then could you please explain why?
And without referring to "old wives' tales" :-)

If you think that it's useful and sync 3 would be an improvement, then could you please explain why?

Because I was making changes that happened in zfs on sync 8-). I was using multiple syncs to ensure everything did get synced out, and then examining status and structures. (And depending on timing, not everything did get synced out on the first one.)

I _said_ it's a dumb change. It doesn't break anything, although it could introduce some delays if people had scripts that called sync and had arguments (using it as a dummy command, for some reason, maybe?). It may be useful. Or not :).

imp requested changes to this revision.Sep 14 2019, 8:33 PM

If you need more than one sync, then you've broken posix semantics.

sync ; sync ; sync hasn't been needed since the bug in the dk driver was fixed in V6! :)

This revision now requires changes to proceed.Sep 14 2019, 8:33 PM

If you need more than one sync, then you've broken posix semantics.

Like that never happens. :)

In D21660#472237, @sef wrote:

Because I was making changes that happened in zfs on sync 8-). I was using multiple syncs to ensure everything did get synced out, and then examining status and structures. (And depending on timing, not everything did get synced out on the first one.)

Could you please tell more about this?
Because that's totally not what I would expect to happen.

Could you please tell more about this?

As I said, it appeared to be timing-related. Specifically, there were some actions that weren't performed on the first sync, but were on the second. Not all the time, but enough so that I got into the habit of "test_command; sync; sync; sync" and forgot the semicolon occasionally.

BTW, you marked it as needing revision, but didn't say what revision.

Again: if this is too stupid, then I'm ok with killing it.

So, maybe you'd better debug and fix that problem.
Or add a sleep instead of additional sync-s. And how do you know that 3 will always be enough?
Or maybe the problem was with concurrent writes somewhere else and in some cases even a million sync-s would not be enough...

As you said, this is dumb. And I agree :-)

In D21660#472249, @avg wrote:

Or add a sleep instead of additional sync-s. And how do you know that 3 will always be enough?

That's why you can request different numbers. If you want.

My understanding of the "old wives tale" was not sync()ing three times, but actually *typing* sync<enter> three times; by the time you finished typing the third one, any background operations initiated by the first one would have completed.

More discussion about it than it's worth. Ah well.

Seriously, thank you for the discussion. It was nice and light-hearted.

In D21660#472250, @sef wrote:

That's why you can request different numbers. If you want.

Correction: not if you want, but if you know how many you need.
But if you know that, you also know why one is not enough and, more importantly, how to make it enough.