Possible 8 sec wakeup fix

I’ve been monitoring my system for the last couple of weeks.  Below is the short sleep times.  For some reason they seem to be happening around 15:49 on several days.   On Jun 3 at 19:48:15 I executed the following command  "mount -o remount,noatime,nodiratime /dev/root / ".   As you can see from the second set of numbers. The system only woke up 3 times. The 03:15:15 is the cron job.  The 06:13:36 wakeup on Jun 4 is the random sleep from the 03 cron job.  I logged in at 18:47:15.  During this 24 hour time frame samba was not running.  So I started samba.  Let it sit for the next 24 hours.  Again it only woke up 3 times.  No 8 sec sleeps.  I didn’t show the complete list of sleep times.  Before the mount command the system woke up 8 to 10 times a day while just sitting idle.  Not sure about the 06 wake up.  It seems that the cron job at 03 checks for new firmware and does a random sleep to reboot to the new firmware even though there was no new firmware downloaded.

May 24 15:59:52 16:00:01   9 0:00:09
May 27 15:47:43 15:47:51   7 0:00:07
May 28 15:49:12 15:49:20   8 0:00:08
May 29 15:49:13 15:49:21   8 0:00:08
May 30 15:44:13 15:44:26 12 0:00:12
May 30 15:49:32 15:49:40   8 0:00:08
May 31 15:54:20 15:54:28   7 0:00:07
Jun 1    15:54:35 15:54:42   7 0:00:07
Jun 2    15:54:38 15:54:46   8 0:00:08
Jun 2    15:59:51 16:00:11 20 0:00:20
Jun 3    15:49:25 15:49:39 14 0:00:14
Jun 3    15:59:50 16:00:03 13 0:00:13

Jun 3  18:37:32 19:48:05   4233   1:10:33
Jun 4  19:58:15 03:00:12 25316   7:01:56
Jun 4  03:15:15 06:03:25 10090   2:48:10
Jun 4  06:13:36 18:27:54 44058 12:14:18
Jun 4  18:47:15 19:11:28   1453   0:24:13
Jun 5  19:21:39 03:00:14 27515   7:38:35
Jun 5  03:11:13 06:48:11  13018   3:36:58
Jun 5  06:58:22 19:14:19  44157 12:15:57

RAC

The 8 second wakeup is weird to me.  Have you checked to see if your WD Red has the 8-second head park bug?

If the drive had the 8 second bug.  Why would the mount command cause it to go away?

RAC

deja-vu

Mine was pretty much the same (less wakeups) except once in awhile I still get 26 second wakeup and a 5 minute wakeup; otherwise it seems to get a firm 8 hour sleep. 

I think it depends on what you were doing just prior to the device going to sleep. In your case, you did nothing so there were zero wakeups. In my case, I was watching a couple of movies, copied and deleted a couple of files, then I set the sleep on which resulted in the 26 seconds and 5 minute wakeup afterwards.

In the past, it would wake up at least 8 times in the same time period.

So, yes, your remount with noatime is a winner along with 

  1. stopping a ton of processes

  2. adding a double sync to monitorio

  3. turn off samba

  4. mount noatime root

my user log

Jun 6 02:02:45 WDMyCloud logger: exit standby after 26 (since 2015-06-06 02:02:14.639811001 -0700)
Jun 6 02:12:53 WDMyCloud logger: exit standby after 301 (since 2015-06-06 02:07:47.859811001 -0700)
Jun 6 10:25:53 WDMyCloud logger: exit standby after 29272 (since 2015-06-06 02:17:56.449811001 -0700)

I definitely like the 8 hours of continuous sleep!! 

Ralphael

Actually I get the same results with samba running.

RAC

rac8006 wrote:

Ralphael

 

Actually I get the same results with samba running.

 

RAC

actually me too… but I thought I throw your samba fix in there just to make you happy :stuck_out_tongue:

I get mixed results with shutting down samba, sometimes I get no wake ups and sometimes it is the same. Sometimes it depends on the order that I shut down my mac; e.g. eject Cloud mount before SSH’ing into it to set Sleep on, or set sleep on before ejecting Cloud. I throw in a Samba stop once in awhile. 

However other than the shutting down the processes, the biggest sleep pattern change has been the noatime mount;  the double nosync helped too…

So I left the house at 2pm today and got home around 6pm but did not access the cloud at all until now at 9:28pm.

As I said, 

  1. samba is off

  2. all process including cron is off

  3. double sync in monitorio

  4. mount remount noatime …

  5. both the mac and pc were off

Jun 6 13:56:30 WDMyCloud logger: exit standby after 225 (since 2015-06-06 13:52:40.879811001 -0700)
Jun 6 14:06:24 WDMyCloud logger: exit standby after 286 (since 2015-06-06 14:01:33.189811001 -0700)
Jun 6 15:40:48 WDMyCloud logger: exit standby after 5356 (since 2015-06-06 14:11:27.279811001 -0700)
Jun 6 15:56:10 WDMyCloud logger: exit standby after 614 (since 2015-06-06 15:45:51.479811001 -0700)
Jun 6 17:16:02 WDMyCloud logger: exit standby after 4484 (since 2015-06-06 16:01:13.439811001 -0700)
Jun 6 18:30:56 WDMyCloud logger: exit standby after 4186 (since 2015-06-06 17:21:04.999811001 -0700)
Jun 6 21:27:59 WDMyCloud logger: exit standby after 10315 (since 2015-06-06 18:35:59.439811001 -0700)

so what is with all those wakeups?

Ralphael

Not sure what is causing these wakeups.  Would have to run blktrace to see what disk addresses are being written.

Difficult to do is wakeips are at different times.  So far my system only wakes up two or three times a day.  Now I need

to start using the system.

RAC

For the first time my system slept for 17.5 hours straight; that is the 63551 number in the middle.

I’ve been away all day today so for the first time my Cloud has been left unattended.

I’ve included the other log times just to show that my system still wakes up to play solitaire despite both my pc and mac are turned off.

Jun 6 18:30:56 WDMyCloud logger: exit standby after 4186 (since 2015-06-06 17:21:04.999811001 -0700)
Jun 6 21:27:59 WDMyCloud logger: exit standby after 10315 (since 2015-06-06 18:35:59.439811001 -0700)
Jun 6 23:58:11 WDMyCloud logger: exit standby after 49 (since 2015-06-06 23:57:17.069811001 -0700)
Jun 7 00:08:20 WDMyCloud logger: exit standby after 301 (since 2015-06-07 00:03:14.079811001 -0700)
Jun 7 17:52:39 WDMyCloud logger: exit standby after 63551 (since 2015-06-07 00:13:23.009811001 -0700)
Jun 7 19:36:23 WDMyCloud logger: exit standby after 5916 (since 2015-06-07 17:57:42.139811001 -0700)
Jun 7 21:51:01 WDMyCloud logger: exit standby after 7771 (since 2015-06-07 19:41:25.869811001 -0700)

So I’ve really been trying to leave my Cloud alone to see what Max sleep time I could get and after several days I got one super long sleep of 28 hours and 25 minutes, woke up for 5 minutes then slept again for almost 27 hours before I woke it up to watch movies otherwise it would have been longer again.

Jun 12 07:44:31 WDMyCloud logger: exit standby after 102351 (since 2015-06-11 03:18:35.649811001 -0700)

Jun 13 10:41:52 WDMyCloud logger: exit standby after 96733 (since 2015-06-12 07:49:34.349811001 -0700)

and 24 hours 10 minutes which could have been longer but I woke it up at 9:26 this morning. 

Jun 16 09:26:22 WDMyCloud logger: exit standby after 87018 (since 2015-06-15 09:15:59.529811001 -0700)

Good enough to conclude the sleep study.

Ralphael

Those are the numbers that I’m seeing when I leave it alone.  I was seeing the 8 second wake up also.

So I’m testing a possible fix.  The last 8 second wake up was Jun 12 when I made the change.  The change

is to move the date command before the sync rather than after in monitorio.sh.

RAC

mine is after (which should make sense)? right?

touch /tmp/standby

sync

sync

sleep 5

                enterStandbyTime=date +%s

                echo “Enter standby”

                if [“$1” == “debug”]; then

                        echo "date: Enter standby "

                        dmesg -c > /dev/null

                fi

                for i in ${drivelist[@]}; do

                        hdparm -y $i >/dev/null

                done

also I turned off samba and only using AFP to connect now. AFP is a little bit slower than Samba.

but alas…

I was going to write that I haven’t seen any 8 second wakeups but I had to erase that statement because after setting it to standby today at noon… and I even typed in a couple of “sync” “sync” 

I get this

Jun 16 12:07:47 WDMyCloud logger: exit standby after 17 (since 2015-06-16 12:07:25.289811001 -0700)

then the next couple hours are broken up…

Jun 16 12:56:23 WDMyCloud logger: exit standby after 2306 (since 2015-06-16 12:17:52.839811001 -0700)
Jun 16 15:14:32 WDMyCloud logger: exit standby after 7981 (since 2015-06-16 13:01:26.369811001 -0700)

sooo… it is all moot… it is what it is…

however I do think that remounting with noatime is a good workaround since 28 continuous sleep hours is great…

Ralphael

I have samba running.  So you should try running with it enabled.  AS I said I moved the enterStandbyTime line before the sync statements.

RAC

rac8006 wrote:

Ralphael

 

I have samba running.  So you should try running with it enabled.  AS I said I moved the enterStandbyTime line before the sync statements.

 

 

RAC

turn off samba, turn on samba

before enterStandbyTime sync, after enterStandbyTime sync

You are too concerned about what was and what will be.

   — OogWD  (pronounced Oogway)

you were the one that said that there was a bug in Samba that causes wake ups and the fix has been sent in to WD. You even earn a bunch of kudos as a result of that post :stuck_out_tongue: However because of you, I feel that turning off samba is giving me a placebo effect that there are a lot less wakeups then before.

I do notice a Samba bug though in 3.04 and that is reading my epub directory, of 10,000 entries folders, takes an inordinate amount of time where-as AFP returns after a few minutes. Samba eventually returns from reading the huge directory but it takes up to 30 or 40 minutes. Thus I use AFP more often now, even though it is a bit slower than Samba (60MB/s versus 80MB/s) reads.

Regarding before or after “Enter Standby”, you will notice that enterStandbyTime doesn’t actually write to disk, so we are good.

However there are more unnecessary evil within monitorio.sh  and that is the file_tally() which runs in the background checking if files are added to the hard drive which then triggers the scans… so if we get wakeups, it may be because of this background process.

else 

     file_tally &

edit: a dummy file_tally doesn’t work because file_tally spawns a daemon… sigh…  so just comment the above “else file_tally &” statement out

Thus 

#else 

   file_tally &

so you should create a dummy file_tally…

file_tally() {

}

file_tally_old() {

.

.

.

}

There are other parts within monitorio that really do seem evil like the MEDIACRAWLER_REWALK flag which is meant to trigger the media scans. Then there is the monitorFreeSpace.sh and createBackupTally.sh followed by 

else

if tally not present, then call calculate_share_size

calculate_share_size

WD is very insistent on checking if you added files so that they can start up the mediascans;  this check code is prevalent throughout monitorio.sh.

Seriously I just don’t have the energy to de-code badly written code that is infused with changing hard drive sizes just so they can restart the media scans, and all this code is within a sleep monitor process however it is what it is.

So for now Rac8006, I am happy enough with my almost 24/28 hour sleeping WD, but do check into that file_tally() thing if you still have the original monitorio.sh.

good luck… 

Ralphael

Check your var/log/user.log.  Grep for Tally.  You should see the following message.

“Tally daemon not installed, exiting tally function”.   Checking for new files is only

done if $iow_datavol ne $iow_datavol2 or new df size greater than a threshold value. 

Which means writes were done to the data volume.

I didn’t say that the samba problem caused wakeup problems.  It caused the disk not to sleep.

Don’t know why moving the date line seems to eliminate the 8 second wakeup.  But I have not

had a short wakeup time since Jun 12.  Since Jun 12 its basically sleep until 03:00AM sleep until

I login sleep until 03:00AM.

What do you mean reading the epub directory?

In conclusion monitorio.sh is not waking up the disk.

RAC

rac8006 wrote:

Ralphael

 

Check your var/log/user.log.  Grep for Tally.  You should see the following message.

“Tally daemon not installed, exiting tally function”.   Checking for new files is only

done if $iow_datavol ne $iow_datavol2 or new df size greater than a threshold value. 

Which means writes were done to the data volume.

 

I didn’t say that the samba problem caused wakeup problems.  It caused the disk not to sleep.

 

Don’t know why moving the date line seems to eliminate the 8 second wakeup.  But I have not

had a short wakeup time since Jun 12.  Since Jun 12 its basically sleep until 03:00AM sleep until

I login sleep until 03:00AM.

 

What do you mean reading the epub directory?

 

In conclusion monitorio.sh is not waking up the disk.

 

RAC

 

 

Rac8006, seriously dood… 

Its not that I’m pointing fingers at you but I am pointing at least one finger…

Remember how I woke up one night at 3:00 to find my cloud playing solitaire with my cron off? and I posted up to WD to complain about it.

http://community.wd.com/t5/WD-My-Cloud/The-Reason-why-your-WD-Cloud-ain-t-getting-no-sleep-and-We/m-p/872849#M33993

Within that thread you told me to turn off Samba…

Then you posted up this hopeful post for everyone to hope on… You even got 3 Kudos for that post!!

Here is where you said WD has your Samba fix… so the whole community is waiting with baited breath for WD to release this sleep time fix someday

http://community.wd.com/t5/WD-My-Cloud/Sleep-time-fix/m-p/873340#M34082

We all went “OH… its a Samba thing” and probably WD thought oh great, we got a sleep fix finally!!

--------- feeling sheepish yet? -----------

ok about that Tally thing, yeah I saw that message a year back but that message doesn’t appear in mine anymore in version 3.04. As I said I really don’t want to go tracing through monitorio.sh to see which code gets executed and which doesn’t.

In my monitorio.sh that line of code does run becuase I replaced it with a dummy line and it does get executed; perhaps not the Tally thing but something else.

Yes of course it checks if the volume size has grown and it writes to the hard drive the last changes to keep track. Flags are set to indicate that the media scan should run. Now if our media scan programs are turned off, flags are not reset and the volume size will still indicate that your hd has changed since the last time it was scanned. This flag may be set everytime your hard drive is on thereby causing perhaps logs to grow, flags and other indicators to be written. It is trying to tell your media scan program to run but we the hackers have turned it off, thereby it perpetuates this change in volume size continuously.

The only way to know for sure that the hard drive isn’t being monitored for size change is what I did a year ago, that is to rewrite monitorio.sh without those lines that tries to figure out if the volume has increased above a threshold number.

if moving the sync to after the date line eliminates the 8 second wakeup… yay!!! then I’ll move it after the date line…

Lastly epub directory. I use calibre to organize my epub (ebooks) and my library is quite large. The first level after you navigate into the epub directory is all the folders organized by author; somewhere in the neighborhood of 10,000 or more. So as soon as you navigate into epub, it takes several minutes before the directory pops up. With Samba before 3.04 firmware, it would pop up in a few minutes. After upgrading to 3.04 firmware, it would not return with a directory listing. At first I thought it hung, but after switching to AFP I realize that it just took time to read in all the entries.

Your Conclusion should be modified to: after moving the syncs after the dateline fixes the 8 second wake up, monitorio.sh is no longer waking up the disk.

For what it is worth Rac8006, the few findings that lead up to a 28 hour continuous sleep is well worth the effort; I can live with the occasional wakeup and I doubt that I would ever upgrade my firmware again.

Good job on your persistence Rac8006…

rac8006 wrote:

Ralphael

 

I have samba running.  So you should try running with it enabled.  AS I said I moved the enterStandbyTime line before the sync statements.

 

 

RAC

sooo… I turned on Samba last night… and turned on standby at 11:36pm…

and…

Jun 18 21:57:48 WDMyCloud logger: exit standby after 37280 (since 2015-06-18 11:36:23.559811001 -0700)
Jun 19 02:28:01 WDMyCloud logger: exit standby after 4321 (since 2015-06-19 01:15:54.599811001 -0700)
Jun 19 02:40:44 WDMyCloud logger: exit standby after 455 (since 2015-06-19 02:33:04.439811001 -0700)
Jun 19 04:24:32 WDMyCloud logger: exit standby after 5920 (since 2015-06-19 02:45:47.009811001 -0700)
Jun 19 08:31:27 WDMyCloud logger: exit standby after 14508 (since 2015-06-19 04:29:34.849811001 -0700)
Jun 19 10:20:33 WDMyCloud logger: exit standby after 6239 (since 2015-06-19 08:36:29.759811001 -0700)

definitely an increased frequency of wake ups.

With Samba turned off, I get one or two wakeups in an 11 hour period; with samba on, I get five, the last one is my connection wake up at 10:20.

During this At no time was either of my PC or Mac on thus eliminating the possibility of pings or other possible wakeup signals.

However prior to you mentioning Samba bugs, I had noticed that the number of wake ups depended on the order that I shut down (disconnecting before setting the drive to standby?, or setting the drive to standby before disconnecting) or perhaps in the amount of data changes on the drive (copying new files, deleting files).

On some nights I would get more wakeups, on others much less. With Samba off, I would get that one or two wakeups, followed by a 24-28 hour continuous sleep.

With Samba on, I would never get more than 6-8 hours of continuous sleep.

No definite proof, but something is amiss…

Ralphael

There is one difference between our two systems.  My system is on version 4 firmware.  Yours is on version 3

firmware.  Not sure what is different between them. 

This are my sleep times.  I made the change to monitorio.sh on the Jun 12th at 19:21:47.  You should notice that the last entry is for Jun 19 03:11:25.  Yet I login at 16:37 Jun 19th.  Login in didn’t seem to wake up the disk.

Jun 11 17:32:05 18:17:11  2706  0:45:06
Jun 11 18:27:22 19:17:18  2996  0:49:56
Jun 11 19:27:28 19:51:17  1429  0:23:49
Jun 11 20:33:06 20:33:14     7  0:00:07
Jun 12 20:46:28 03:00:12 22424  6:13:44
Jun 12 03:15:14 18:55:47 56433 15:40:33

Jun 12 19:11:29 19:11:37     8  0:00:08
Jun 12 19:21:47 19:32:21   634  0:10:34
Jun 13 19:42:32 03:00:12 26260  7:17:40
Jun 13 03:15:14 03:17:12   118  0:01:58
Jun 13 03:27:22 05:45:29  8287  2:18:07
Jun 13 05:55:40 22:58:47 61387 17:03:07
Jun 14 23:09:58 00:57:12  6434  1:47:14
Jun 14 01:07:22 03:00:11  6769  1:52:49
Jun 15 03:11:10 03:00:13 85743 23:49:03
Jun 15 03:11:25 10:36:10 26685  7:24:45
Jun 16 10:46:21 03:00:13 58432 16:13:52
Jun 16 03:11:24 11:04:54 28409  7:53:29
Jun 17 11:15:04 03:00:13 56709 15:45:09
Jun 17 03:11:25 11:39:27 30482  8:28:02
Jun 18 11:49:38 03:00:13 54635 15:10:35
Jun 19 03:11:25 03:00:13 85728 23:48:48

well Rac8006, it seems that in order for my system on 3.04 to look like yours in terms of sleep time is to turn Samba off :stuck_out_tongue:

The only time that I need Samba is when I connect my PC to it; otherwise AFC for my Mac is good enough even if it is slightly slower.

and thus this concludes our 4 year study of WD Cloud/live sleeping…

Ralphael

For me its only been 5 months.  It is now closed.

RAC