-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Modifying XATTRs doesnt change the ctime #6586
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
Conversation
behlendorf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is most of the needed fix for #3644. Here's what's still needed.
- Adding code for the directory xattr case as you mentioned in the description. You'll want to add the needed code to
zpl_xattr_set_dir(). While it would be ideal to get the update in the same TX the code's not really laid out to make this possible.
Instead I would suggest adding the following lines in the success path. It will then get properly written via __mark_inode_dirty()->zpl_dirty_inode()->zfs_dirty_inode().
ip->i_ctime = current_time(ip);
zfs_mark_inode_dirty(ip);
- Test coverage. The
ctime_001_pos.ctest case should be updated to modify an xattr and verify the ctime was updated. You'll need to renamectime_001_pos.cand then call it from a script. This way we can test both thexattr=saandxattr=dircases.
module/zfs/zfs_sa.c
Outdated
| VERIFY0(sa_update(zp->z_sa_hdl, SA_ZPL_DXATTR(zfsvfs), | ||
| obj, size, tx)); | ||
| int count = 0; | ||
| sa_bulk_attr_t bulk[2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra space before bulk[2].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
module/zfs/zfs_sa.c
Outdated
|
|
||
| SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_DXATTR(zfsvfs), | ||
| NULL, obj, size); | ||
| /* Any xattr change is metadata change hence update the ctime */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: No comment needed, it's clear we're updating the ctime due to the xattr change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
module/zfs/zfs_sa.c
Outdated
| SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_DXATTR(zfsvfs), | ||
| NULL, obj, size); | ||
| /* Any xattr change is metadata change hence update the ctime */ | ||
| zfs_tstamp_update_setup(zp, STATE_CHANGED, NULL, ctime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: it might be nice to move the zfs_tstamp_update_setup() call easier so all the SA_ADD_BULK_ATTR() calls are together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
module/zfs/zfs_sa.c
Outdated
|
|
||
| dmu_tx_commit(tx); | ||
| /* Update Inode ctime */ | ||
| zfs_inode_update(zp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to call zfs_inode_update(). The call to zfs_tstamp_update_setup() will update the ctime in the inode. We're working to retire the need for zfs_inode_update() so the fewer callers the better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
@behlendorf I have updated the patch. I need some clarity regarding the test coverage. I have added setting xattr and checking if ctime changes in the ctime_001_pos.c file. But as you mentioned we need to test for both xattr=sa and dir. Is this what seems fair to do: rename ctime_001_pos.c to ctime.c |
|
@gaurkuma yes, that sounds entirely reasonable. Thanks. |
|
@behlendorf Final Patch Updated. |
behlendorf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good.
module/zfs/zfs_sa.c
Outdated
| SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), | ||
| NULL, &ctime, 16); | ||
| VERIFY0(sa_bulk_update(zp->z_sa_hdl, bulk, count, tx)); | ||
| zfs_tstamp_update_setup(zp, STATE_CHANGED, NULL, ctime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaurkuma you need to move this line before sa_bulk_update. Otherwise, you are using uninitialized ctime. You won't see that with stat(2), but you should be able see that with zdb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tuxoko Good Catch..Fixed it.
tests/runfiles/linux.run
Outdated
|
|
||
| [tests/functional/ctime] | ||
| tests = ['ctime_001_pos' ] | ||
| tests = ['ctime' ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to switch the two file name, so we get more consistent with others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tuxoko The reason I didnt do this way was because ctime_001_pos is a .c file and renaming it will mean changing multiple places in the Makefile. If that's ok, I will go ahead and make the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine, please go ahead and rename it.
|
@tuxoko Updated the patch.. |
| pkgexec_PROGRAMS = ctime_001_pos | ||
| ctime_001_pos_SOURCES = ctime_001_pos.c | ||
| pkgexec_PROGRAMS = ctime | ||
| ctime_001_pos_SOURCES = ctime.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this now be ctime_SOURCES = ctime.c?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@behlendorf ..Done
Signed-off-by: gaurkuma <gauravk.18@gmail.com>
|
@tonyhutter this is a good candidate for 0.7, can you open a PR to port it. I expect it'll apply cleanly. |
Changing any metadata, should modify the ctime. Reviewed-by: Chunwei Chen <tuxoko@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: gaurkuma <gauravk.18@gmail.com> Closes openzfs#3644 Closes openzfs#6586
Changing any metadata, should modify the ctime.
Description
Default Behaviour
root# stat test.log
File: `test.log'
Size: 32 Blocks: 9 IO Block: 512 regular file
Device: 18h/24d Inode: 128 Links: 1
Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-08-29 23:28:04.926223299 -0700
Modify: 2017-08-29 21:51:24.495046598 -0700
Change: 2017-08-29 21:51:24.495046598 -0700
root# setfattr -n user.name1 -v "val1" test.log
root# stat test.log
File: `test.log'
Size: 32 Blocks: 9 IO Block: 512 regular file
Device: 18h/24d Inode: 128 Links: 1
Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-08-29 23:28:04.926223299 -0700
Modify: 2017-08-29 21:51:24.495046598 -0700
Change: 2017-08-29 21:51:24.495046598 -0700
This patch updates the ctime when xattr is set. Currently the patch only takes care of the case where xattr=sa is set as the property.
Result:
root# stat test.log
File: `test.log'
Size: 64 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 425987 Links: 1
Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-08-30 16:52:05.519465323 -0700
Modify: 2017-08-30 16:52:05.519465323 -0700
Change: 2017-08-30 16:52:05.519465323 -0700
root# setfattr -n user.name1 -v "val1" test.log
root# stat test.log
File: `test.log'
Size: 64 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 425987 Links: 1
Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-08-30 16:52:05.519465323 -0700
Modify: 2017-08-30 16:52:05.519465323 -0700
Change: 2017-08-30 16:52:33.220226152 -0700
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by.