Page MenuHomeFreeBSD

Ask sync(8) to sync multiple times
AbandonedPublic

Authored by sef on Sep 14 2019, 8:17 PM.

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
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

sef created this revision.Sep 14 2019, 8:17 PM
avg added a subscriber: avg.Sep 14 2019, 8:25 PM

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" :-)

sef added a comment.Sep 14 2019, 8:29 PM

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
sef added a comment.Sep 14 2019, 8:35 PM

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

Like that never happens. :)

avg added a comment.Sep 14 2019, 8:36 PM
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.

sef added a comment.Sep 14 2019, 8:38 PM

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.

sef added a comment.Sep 14 2019, 8:39 PM

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.

avg added a comment.Sep 14 2019, 8:42 PM

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 :-)

sef added a comment.Sep 14 2019, 8:43 PM
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.

sef abandoned this revision.Sep 14 2019, 8:43 PM

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

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

avg added a comment.EditedSep 14 2019, 8:48 PM
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.