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

strictatime, not relatime #1917

Closed
spacelama opened this issue Dec 1, 2013 · 10 comments
Closed

strictatime, not relatime #1917

spacelama opened this issue Dec 1, 2013 · 10 comments
Milestone

Comments

@spacelama
Copy link

I don't know whether this is a documentation or an implementation issue, but there doesn't seem to be a way to disable relatime atime updates and revert back to traditional strictatime.

On pools that I've set atime=on, the kernel thinks everything is still mounted according to /proc/mounts (and actual behaviour) as relatime. How do I force strictatime semantics? Both for legacy mounts and zfs-mount mounts?

With ext4, you put strictatime in fstab, but when there's no fstab because it's handled by zfs, what's the option?

@GregorKopka
Copy link
Contributor

Did you reimport the pool (or remount the filesystems) after setting the atime property?

@spacelama
Copy link
Author

On Mon, 2 Dec 2013, Gregor Kopka wrote:

Did you reimport the pool (or remount the filesystems) after setting the atime property?

atime's always been set on most of my filesystems, so yes.

Tim Connors

@behlendorf
Copy link
Contributor

@spacelama I don't quite understand. Currently ZFS only supports noatime and strictatime, I'd like to support relatime but noone has had the time to work on that yet. Could you perhaps post some example commands from your pool which show the issue?

@spacelama
Copy link
Author

On Tue, 3 Dec 2013, Brian Behlendorf wrote:

@spacelama I don't quite understand. Currently ZFS only supports noatime and strictatime, I'd like to support relatime but noone has had the time to work on that yet. Could you perhaps post some example commands from your pool which show the issue?

I would have thought that relatime was handled by the VFS. And by having
changed the default a year or two ago, that then applies to all
filesystems?

Anyway, atime being forgotten can be seen here:

130-0-17:51:08, Sun Dec 08 tconnors@fs:~/movies/kaffeine (bash)
152144,21> stat 'London to Sydney Motorcycle Adventure Episode 1
Continental Drift-x3fDg7f2xPY.mp4'
File: `London to Sydney Motorcycle Adventure Episode 1 Continental
Drift-x3fDg7f2xPY.mp4'
Size: 296739668 Blocks: 579786 IO Block: 131072 regular file
Device: 18h/24d Inode: 108 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 738/tconnors) Gid: ( 273/tconnors)
Access: 2013-12-08 15:46:40.858908000 +1100
Modify: 2013-12-03 15:53:20.000000000 +1100
Change: 2013-12-08 15:57:53.808794094 +1100
Birth: -

ie, file accesed before being fully downloaded. Let's access the file

again now that it's finished:

0-0-17:51:10, Sun Dec 08 tconnors@fs:~/movies/kaffeine (bash)
152145,22> head 'London to Sydney Motorcycle Adventure Episode 1
Continental Drift-x3fDg7f2xPY.mp4' > /dev/null

0-0-17:51:16, Sun Dec 08 tconnors@fs:~/movies/kaffeine (bash)
152146,23> stat 'London to Sydney Motorcycle Adventure Episode 1
Continental Drift-x3fDg7f2xPY.mp4'
File: `London to Sydney Motorcycle Adventure Episode 1 Continental
Drift-x3fDg7f2xPY.mp4'
Size: 296739668 Blocks: 579786 IO Block: 131072 regular file
Device: 18h/24d Inode: 108 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 738/tconnors) Gid: ( 273/tconnors)
Access: 2013-12-08 17:51:16.433820581 +1100
Modify: 2013-12-03 15:53:20.000000000 +1100
Change: 2013-12-08 15:57:53.808794094 +1100
Birth: -

excellent, atime has been updated. Or has it? I've seen it forget the

atime after a while before. So let's drop cache:

0-0-17:51:18, Sun Dec 08 tconnors@fs:~/movies/kaffeine (bash)
152147,24> sudo tee /proc/sys/vm/drop_caches <<< 3
stdin: is not a tty
3

0-0-17:51:54, Sun Dec 08 tconnors@fs:~/movies/kaffeine (bash)
152148,25> stat 'London to Sydney Motorcycle Adventure Episode 1
Continental Drift-x3fDg7f2xPY.mp4'
File: `London to Sydney Motorcycle Adventure Episode 1 Continental
Drift-x3fDg7f2xPY.mp4'
Size: 296739668 Blocks: 579786 IO Block: 131072 regular file
Device: 18h/24d Inode: 108 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 738/tconnors) Gid: ( 273/tconnors)
Access: 2013-12-08 17:51:16.433820581 +1100
Modify: 2013-12-03 15:53:20.000000000 +1100
Change: 2013-12-08 15:57:53.808794094 +1100
Birth: -

nope, still good. Let's wait a bit after the disks have done lots of

activity to really make sure the caches are cleared:

0-0-22:51:56, Sun Dec 08 tconnors@fs:~/movies/kaffeine (bash)
152149,26> stat 'London to Sydney Motorcycle Adventure Episode 1
Continental Drift-x3fDg7f2xPY.mp4'
File: `London to Sydney Motorcycle Adventure Episode 1 Continental
Drift-x3fDg7f2xPY.mp4'
Size: 296739668 Blocks: 579786 IO Block: 131072 regular file
Device: 18h/24d Inode: 108 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 738/tconnors) Gid: ( 273/tconnors)
Access: 2013-12-08 17:51:16.433820581 +1100
Modify: 2013-12-03 15:53:20.000000000 +1100
Change: 2013-12-08 15:57:53.808794094 +1100
Birth: -

bugger, still remembers the atime. Let's check it will still be

updated, given that relatime is documented as only bothering updates
once per day.

0-0-23:00:24, Sun Dec 08 tconnors@fs:~/movies/kaffeine (bash)
152149,27> head 'London to Sydney Motorcycle Adventure Episode 1
Continental Drift-x3fDg7f2xPY.mp4' > /dev/null

0-0-23:00:50, Sun Dec 08 tconnors@fs:~/movies/kaffeine (bash)
152150,28> stat 'London to Sydney Motorcycle Adventure Episode 1
Continental Drift-x3fDg7f2xPY.mp4'
File: `London to Sydney Motorcycle Adventure Episode 1 Continental
Drift-x3fDg7f2xPY.mp4'
Size: 296739668 Blocks: 579786 IO Block: 131072 regular file
Device: 18h/24d Inode: 108 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 738/tconnors) Gid: ( 273/tconnors)
Access: 2013-12-08 23:00:50.593343145 +1100
Modify: 2013-12-03 15:53:20.000000000 +1100
Change: 2013-12-08 15:57:53.808794094 +1100
Birth: -

Well bugger that, let's wait another day:

0-0-20:30:53, Mon Dec 09 tconnors@fs:~/movies/kaffeine (bash)
152151,29> stat 'London to Sydney Motorcycle Adventure Episode 1
Continental Drift-x3fDg7f2xPY.mp4'
File: `London to Sydney Motorcycle Adventure Episode 1 Continental
Drift-x3fDg7f2xPY.mp4'
Size: 296739668 Blocks: 579786 IO Block: 131072 regular file
Device: 18h/24d Inode: 108 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 738/tconnors) Gid: ( 273/tconnors)
Access: 2013-12-08 15:46:40.858908000 +1100
Modify: 2013-12-03 15:53:20.000000000 +1100
Change: 2013-12-08 15:57:53.808794094 +1100
Birth: -

0-0-20:41:13, Mon Dec 09 tconnors@fs:~/movies/kaffeine (bash)
152151,30> uptime
20:49:11 up 1 day, 12:55, 8 users, load average: 0.03, 0.23, 0.41

Well, I'll be damned, it's gone back to the atime it originally knew
about. It's forgotten the updates it previously remembered!

0-0-20:49:54, Mon Dec 09 tconnors@fs:~/movies/kaffeine (bash)
152155,34> grep kaffeine /proc/mounts
tank3/pvr /home/tconnors/movies/kaffeine zfs rw,relatime,xattr 0 0

0-0-20:50:50, Mon Dec 09 tconnors@fs:~/movies/kaffeine (bash)
152158,37> sudo zfs get atime tank3/pvr
NAME PROPERTY VALUE SOURCE
tank3/pvr atime on default

0-0-20:51:13, Mon Dec 09 tconnors@fs:~/movies/kaffeine (bash)
152159,38> uname -a
Linux fs 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux

Tim Connors

@dweeezil
Copy link
Contributor

dweeezil commented Dec 9, 2013

There seem to be two problems here: First, as of 2.6.30, Linux defaults to relatime and in order to get "real" atime, a mount requires the MS_STRICTATIME option but, unfortunately, the mount.zfs program doesn't apply that option on post-2.6.30 kernels when atime=on. Second, the atime update (stored in the dnode's SA) is never synced back to the disk. @spacelama, your "wait a day" behavior is undoubtedly being caused by the metadata being aged out of the arc. You'll see the same thing if you simply umount/mount the file system.

I'm going to try to run this down. My current theory is that it may have to do with 8780c53.

As to the first issue, it seems we may need a change to the mount.zfs program and another configuration option.

@behlendorf
Copy link
Contributor

@dweeezil Once you start digging in to this you might find that it's relatively straight forward to implement support for relatime. It would be nice to have the support in place since I think it would be the right thing to default to.

@dweeezil
Copy link
Contributor

dweeezil commented Dec 9, 2013

@behlendorf I was thinking the same thing.

@dweeezil
Copy link
Contributor

Quick update on this issue: I've gotten to the bottom of the problem and am researching the cleanest solution. The reason that atimes aren't updated after a read is because the zfs_inode_update() function used in zfs_read() re-looks-up all the timestamps from the SA which blows away anything that has been updated in the mean time [by zfs_tistamp_update_setup()]. I've got a trivial hack worked up that fixes zfs_read() but, as I mentioned, am looking for better solutions to deal with the atime issue and, possibly, the handling of the other timestamps.

As to relatime, it'll be rather simple to implement but, again, I'm looking for a cleaner solution than to duplicate the logic within ZoL. The post-2.6.30 kernels provide the file_accessed() macro which does the Right Thing but it's not somthing we can easily used because of our non-use of inodes on-disk. XFS has the similar issues and I think was partially the reason for adding the update_time method to the kernel's inode_operations (which is something else I'd like to try to support in kernels that have the feature). Our lack of aio operations also works into these timestamp problems because it make is difficult to use more of the kernel's infrastructure.

I'll be posting an initial patch tomorrow to address the immediate problem.

@behlendorf
Copy link
Contributor

@dweeezil Interesting, yes I can see how that could happen. If you have a relatively clean/trivial hack to fix this we might be able to live with that until we can do the right thing. And in my view the right long term thing is to eliminate the zfs_inode_update()` function. It was always just meant as a stop gap until the znode and inode could be properly unified. Although that's a much bigger change...

Anyway, I'm looking forward to seeing your fix.

@dweeezil
Copy link
Contributor

@behlendorf I just posted my hack to make this work. I'm going to see if I can get relatime working now. The main problem I see is that the kernel stores the flags in the vfs where may be difficult to get ahold of them from the zfs code. Also, I can see that it's going to be easier to duplicate the relatime logic for the time being rather than trying to use more of the infrastructure provided by the kernel.

FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Feb 5, 2014
Add the "relatime" property.  When set to "on", a file's atime will only
be updated if the existing atime at least a day old or if the existing
ctime or mtime has been updated since the last access.  This behavior
is compatible with the Linux "relatime" mount option.

Signed-off-by: Tim Chase <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes openzfs#2064
Closes openzfs#1917
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

4 participants