-
Notifications
You must be signed in to change notification settings - Fork 78
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
Add tests for utimensat(2) #6
Conversation
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c * In zfs_freebsd_setattr, if the caller wants to set the birthtime, set the bits that zfs_settattr expects * In zfs_setattr, if XAT_CREATETIME is set, set xoa_createtime, expected by zfs_xvattr_set. The two levels of indirection seem excessive, but it minimizes diffs vs OpenZFS. * In zfs_setattr, check for overflow of va_birthtime (from delphij) * Remove red herring in zfs_getattr sys/cddl/contrib/opensolaris/uts/common/sys/vnode.h * Un-booby-trap some macros New tests are under review at pjd/pjdfstest#6 Reviewed by: avg MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9353 git-svn-id: svn+ssh://svn.freebsd.org/base/head@313483 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c * In zfs_freebsd_setattr, if the caller wants to set the birthtime, set the bits that zfs_settattr expects * In zfs_setattr, if XAT_CREATETIME is set, set xoa_createtime, expected by zfs_xvattr_set. The two levels of indirection seem excessive, but it minimizes diffs vs OpenZFS. * In zfs_setattr, check for overflow of va_birthtime (from delphij) * Remove red herring in zfs_getattr sys/cddl/contrib/opensolaris/uts/common/sys/vnode.h * Un-booby-trap some macros New tests are under review at pjd/pjdfstest#6 Reviewed by: avg MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9353
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 took a first-pass at the change. I'll look at it further when I have some time to do so.
pjdfstest.c
Outdated
| printf("%lld", (long long)sp->st_mtime); | ||
| else if (strcmp(what, "mtime_ns") == 0) | ||
| printf("%lld", (long long)sp->st_mtim.tv_nsec); | ||
| else if (strcmp(what, "birthtime") == 0) |
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.
A #ifdef will need to be added for this: FreeBSD is the only OS that supports .birthtime in struct stat.
| cd ${n1} | ||
|
|
||
| DATE1=1900000000 #Sun Mar 17 11:46:40 MDT 2030 | ||
| DATE2=1950000000 #Fri Oct 17 04:40:00 MDT 2031 |
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.
Is this a problem with architectures/OSes that don't support 64-bit time_t?
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.
Nope. I chose all of those constants to fit within 32 bits.
|
|
||
| expect 0 mkdir ${n1} 0755 | ||
| cdir=`pwd` | ||
| cd ${n1} |
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.
This should probably be expect-ed so we're sure that we're going to the proper directory before and after the test and not just littering temporary files where the test is being run from... whether or not pjdfstest does this 100% of the time elsewhere though is a good question. If not, then it should be fixed everywhere in a separate commit.
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.
No, pjdfstest generally doesn't do that. Let's do that separately.
tests/utimensat/01.t
Outdated
| echo "not ok 4 mtime was not updated" | ||
| fi | ||
| if [ "$delta_atime" -gt 0 ]; then | ||
| if [ "$delta_atime" -lt 300 ]; then |
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.
Again, why 5 mins?
tests/utimensat/01.t
Outdated
| delta_atime=$(( $new_atime - $old_atime )) | ||
|
|
||
| if [ "$delta_mtime" -gt 0 ]; then | ||
| if [ "$delta_mtime" -lt 300 ]; then |
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.
- Why 5 mins?
- Why isn't this value a constant?
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 way for pjdfstest to know exactly what time will get set when it says UTIME_NOW. So it checks for anything that's "approximately now". It can't even know what direction the error will be, because ntp or something may come and change the clock. Five minutes is a pretty arbitrary margin of error. I'll constantify it.
tests/utimensat/01.t
Outdated
| . ${dir}/../misc.sh | ||
| echo "1..7" | ||
|
|
||
| require utimensat |
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.
These calls should be moved up before the test plan summaries -- the reason why is that if the require fails, then it'll print out something like:
1..7 1..1
This will confuse the TAP parsers. I know this will cause kyua to choke at least (and I think prove will reject the test because of the test plan mismatch).
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.
Actually, I'll just delete it, because utimensat is part of POSIX and AFAIK everything supports it (but I don't have a OSX machine to check). I'll add a separate require statement for the birthtime-specific tests.
tests/utimensat/01.t
Outdated
|
|
||
| require utimensat | ||
|
|
||
| UTIME_NOW=-1 |
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.
It would be better for these constants to be symbolic and referenced in the C code -- there's no telling whether or not all of the constants are defined with the same values.
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.
good call. Looks like it's different on Linux.
| #! /bin/sh | ||
| # $FreeBSD$ | ||
|
|
||
| desc="utimensat can update birthtimes" |
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.
Please skip if not run on FreeBSD.
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c * In zfs_freebsd_setattr, if the caller wants to set the birthtime, set the bits that zfs_settattr expects * In zfs_setattr, if XAT_CREATETIME is set, set xoa_createtime, expected by zfs_xvattr_set. The two levels of indirection seem excessive, but it minimizes diffs vs OpenZFS. * In zfs_setattr, check for overflow of va_birthtime (from delphij) * Remove red herring in zfs_getattr sys/cddl/contrib/opensolaris/uts/common/sys/vnode.h * Un-booby-trap some macros New tests are under review at pjd/pjdfstest#6 Reviewed by: avg MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9353 git-svn-id: svn+ssh://svn.freebsd.org/base/head@313483 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c * In zfs_freebsd_setattr, if the caller wants to set the birthtime, set the bits that zfs_settattr expects * In zfs_setattr, if XAT_CREATETIME is set, set xoa_createtime, expected by zfs_xvattr_set. The two levels of indirection seem excessive, but it minimizes diffs vs OpenZFS. * In zfs_setattr, check for overflow of va_birthtime (from delphij) * Remove red herring in zfs_getattr sys/cddl/contrib/opensolaris/uts/common/sys/vnode.h * Un-booby-trap some macros New tests are under review at pjd/pjdfstest#6 Reviewed by: avg MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9353
|
@pjd are you interested in this PR? If not, I can submit it directly to FreeBSD. |
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.
These changes look good to me.
Fix setting birthtime in ZFS sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c * In zfs_freebsd_setattr, if the caller wants to set the birthtime, set the bits that zfs_settattr expects * In zfs_setattr, if XAT_CREATETIME is set, set xoa_createtime, expected by zfs_xvattr_set. The two levels of indirection seem excessive, but it minimizes diffs vs OpenZFS. * In zfs_setattr, check for overflow of va_birthtime (from delphij) * Remove red herring in zfs_getattr sys/cddl/contrib/opensolaris/uts/common/sys/vnode.h * Un-booby-trap some macros New tests are under review at pjd/pjdfstest#6 Reviewed by: avg MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9353
The st_birthtime tests are only supported on FreeBSD, but everything else is universal.
|
This change unfortunately broke OS X again. I'm trying to figure out more details about |
Fix setting birthtime in ZFS sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c * In zfs_freebsd_setattr, if the caller wants to set the birthtime, set the bits that zfs_settattr expects * In zfs_setattr, if XAT_CREATETIME is set, set xoa_createtime, expected by zfs_xvattr_set. The two levels of indirection seem excessive, but it minimizes diffs vs OpenZFS. * In zfs_setattr, check for overflow of va_birthtime (from delphij) * Remove red herring in zfs_getattr sys/cddl/contrib/opensolaris/uts/common/sys/vnode.h * Un-booby-trap some macros New tests are under review at pjd/pjdfstest#6 Reviewed by: avg MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9353 git-svn-id: https://svn.freebsd.org/base/stable/11@316391 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add tests for utimensat(2). They pass on FreeBSD/UFS. They fail on FreeBSD/ZFS (but I have a fix ready). I haven't tested them on Linux or Illumos.