Fix atime update
FUSE filesystems assume that SETATTR with atime is the result of utiimes() being called. As a result, atime and mtime will be updated. This happens with MooseFS and glusterFS. atime is supposed to be updated by the filesystem itself when it gets read operations. We fix the problem in SETATTR operations by 1) do not create a mtime update when we have an atime update (and vice versa), just fill the fields to avoid the filesystem restting the missing field to Epoch, but do not pretend we want to update it. 2) If the change is limited to atime, iscard it, as updates should be done by READ operations 3) Kernel part of PUFFS has been fixed to make sure reads on empty file are sent to the filesystem: http://mail-index.netbsd.org/source-changes/2015/01/13/msg062364.html Thanks to Tom Ivar Helbekkmo for reporting this issue.
This commit is contained in:
parent
5fc94787c1
commit
575ae72270
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ops.c,v 1.81 2014/11/12 05:08:43 manu Exp $ */
|
||||
/* $NetBSD: ops.c,v 1.82 2015/01/13 16:51:30 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
|
||||
|
@ -1785,30 +1785,27 @@ perfuse_node_setattr_ttl(struct puffs_usermount *pu, puffs_cookie_t opc,
|
|||
}
|
||||
|
||||
/*
|
||||
* Setting mtime without atime or vice versa leads to
|
||||
* dates being reset to Epoch on glusterfs. If one
|
||||
* is missing, use the old value.
|
||||
* When not sending a time field, still fill with
|
||||
* current value, as the filesystem may just reset
|
||||
* the field to Epoch even if fsi->valid bit is
|
||||
* not set (GlusterFS does that).
|
||||
*/
|
||||
if ((vap->va_mtime.tv_sec != (time_t)PUFFS_VNOVAL) ||
|
||||
(vap->va_atime.tv_sec != (time_t)PUFFS_VNOVAL)) {
|
||||
|
||||
if (vap->va_atime.tv_sec != (time_t)PUFFS_VNOVAL) {
|
||||
fsi->atime = vap->va_atime.tv_sec;
|
||||
fsi->atimensec = (uint32_t)vap->va_atime.tv_nsec;
|
||||
} else {
|
||||
fsi->atime = old_va->va_atime.tv_sec;
|
||||
fsi->atimensec = (uint32_t)old_va->va_atime.tv_nsec;
|
||||
}
|
||||
if (vap->va_atime.tv_sec != (time_t)PUFFS_VNOVAL) {
|
||||
fsi->atime = vap->va_atime.tv_sec;
|
||||
fsi->atimensec = (uint32_t)vap->va_atime.tv_nsec;
|
||||
fsi->valid |= FUSE_FATTR_ATIME;
|
||||
} else {
|
||||
fsi->atime = old_va->va_atime.tv_sec;
|
||||
fsi->atimensec = (uint32_t)old_va->va_atime.tv_nsec;
|
||||
}
|
||||
|
||||
if (vap->va_mtime.tv_sec != (time_t)PUFFS_VNOVAL) {
|
||||
fsi->mtime = vap->va_mtime.tv_sec;
|
||||
fsi->mtimensec = (uint32_t)vap->va_mtime.tv_nsec;
|
||||
} else {
|
||||
fsi->mtime = old_va->va_mtime.tv_sec;
|
||||
fsi->mtimensec = (uint32_t)old_va->va_mtime.tv_nsec;
|
||||
}
|
||||
|
||||
fsi->valid |= (FUSE_FATTR_MTIME|FUSE_FATTR_ATIME);
|
||||
if (vap->va_mtime.tv_sec != (time_t)PUFFS_VNOVAL) {
|
||||
fsi->mtime = vap->va_mtime.tv_sec;
|
||||
fsi->mtimensec = (uint32_t)vap->va_mtime.tv_nsec;
|
||||
fsi->valid |= FUSE_FATTR_MTIME;
|
||||
} else {
|
||||
fsi->mtime = old_va->va_mtime.tv_sec;
|
||||
fsi->mtimensec = (uint32_t)old_va->va_mtime.tv_nsec;
|
||||
}
|
||||
|
||||
if (vap->va_mode != (mode_t)PUFFS_VNOVAL) {
|
||||
|
@ -1851,6 +1848,14 @@ perfuse_node_setattr_ttl(struct puffs_usermount *pu, puffs_cookie_t opc,
|
|||
fsi->mtimensec = 0;
|
||||
fsi->valid &= ~(FUSE_FATTR_ATIME|FUSE_FATTR_MTIME);
|
||||
}
|
||||
|
||||
/*
|
||||
* If only atime is changed, discard the operation: it
|
||||
* happens after read, and in that case the filesystem
|
||||
* already updaed atime. NB: utimes() also change mtime.
|
||||
*/
|
||||
if (fsi->valid == FUSE_FATTR_ATIME)
|
||||
fsi->valid &= ~FUSE_FATTR_ATIME;
|
||||
|
||||
/*
|
||||
* If nothing remain, discard the operation.
|
||||
|
|
Loading…
Reference in New Issue