Skip to content

Commit 52af710

Browse files
Marc Dionnedhowells
authored andcommitted
afs: Set mtime from the client for yfs create operations
For operations that create vnodes on the server such as CreateFile, MakeDir or Symlink, the server will store its own current time as the mtime if the client doesn't pass in a time in the accompanying StoreStatus structure. If the server and client clocks are not well synchronized, the client may see timestamps in the future or inconsistent dependency checks with "make" for files that are not modified after creation: make[2]: Warning: File 'arch/x86/kernel/apic/modules.order' has modification time 0.14 s in the future make[2]: warning: Clock skew detected. Your build may be incomplete. This is already handled correctly for non yfs operations; also set the mtime for the corresponding yfs operations. Changes: v3: Replace S_IRWXUGO with 0777, per checkpatch v2: [dhowells] Merge the two xdr_encode_YFSStoreStatus*() functions together Signed-off-by: Marc Dionne <[email protected]> Signed-off-by: David Howells <[email protected]> Link: http://lists.infradead.org/pipermail/linux-afs/2021-October/004395.html
1 parent 75bd228 commit 52af710

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

fs/afs/yfsclient.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,18 @@ static s64 linux_to_yfs_time(const struct timespec64 *t)
8383
return (u64)t->tv_sec * 10000000 + t->tv_nsec/100;
8484
}
8585

86-
static __be32 *xdr_encode_YFSStoreStatus_mode(__be32 *bp, mode_t mode)
87-
{
88-
struct yfs_xdr_YFSStoreStatus *x = (void *)bp;
89-
90-
x->mask = htonl(AFS_SET_MODE);
91-
x->mode = htonl(mode & S_IALLUGO);
92-
x->mtime_client = u64_to_xdr(0);
93-
x->owner = u64_to_xdr(0);
94-
x->group = u64_to_xdr(0);
95-
return bp + xdr_size(x);
96-
}
97-
98-
static __be32 *xdr_encode_YFSStoreStatus_mtime(__be32 *bp, const struct timespec64 *t)
86+
static __be32 *xdr_encode_YFSStoreStatus(__be32 *bp, mode_t *mode,
87+
const struct timespec64 *t)
9988
{
10089
struct yfs_xdr_YFSStoreStatus *x = (void *)bp;
90+
mode_t masked_mode = mode ? *mode & S_IALLUGO : 0;
10191
s64 mtime = linux_to_yfs_time(t);
92+
u32 mask = AFS_SET_MTIME;
10293

103-
x->mask = htonl(AFS_SET_MTIME);
104-
x->mode = htonl(0);
94+
mask |= mode ? AFS_SET_MODE : 0;
95+
96+
x->mask = htonl(mask);
97+
x->mode = htonl(masked_mode);
10598
x->mtime_client = u64_to_xdr(mtime);
10699
x->owner = u64_to_xdr(0);
107100
x->group = u64_to_xdr(0);
@@ -576,7 +569,7 @@ void yfs_fs_create_file(struct afs_operation *op)
576569
bp = xdr_encode_u32(bp, 0); /* RPC flags */
577570
bp = xdr_encode_YFSFid(bp, &dvp->fid);
578571
bp = xdr_encode_name(bp, name);
579-
bp = xdr_encode_YFSStoreStatus_mode(bp, op->create.mode);
572+
bp = xdr_encode_YFSStoreStatus(bp, &op->create.mode, &op->mtime);
580573
bp = xdr_encode_u32(bp, yfs_LockNone); /* ViceLockType */
581574
yfs_check_req(call, bp);
582575

@@ -625,7 +618,7 @@ void yfs_fs_make_dir(struct afs_operation *op)
625618
bp = xdr_encode_u32(bp, 0); /* RPC flags */
626619
bp = xdr_encode_YFSFid(bp, &dvp->fid);
627620
bp = xdr_encode_name(bp, name);
628-
bp = xdr_encode_YFSStoreStatus_mode(bp, op->create.mode);
621+
bp = xdr_encode_YFSStoreStatus(bp, &op->create.mode, &op->mtime);
629622
yfs_check_req(call, bp);
630623

631624
trace_afs_make_fs_call1(call, &dvp->fid, name);
@@ -946,6 +939,7 @@ void yfs_fs_symlink(struct afs_operation *op)
946939
struct afs_vnode_param *dvp = &op->file[0];
947940
struct afs_call *call;
948941
size_t contents_sz;
942+
mode_t mode = 0777;
949943
__be32 *bp;
950944

951945
_enter("");
@@ -972,7 +966,7 @@ void yfs_fs_symlink(struct afs_operation *op)
972966
bp = xdr_encode_YFSFid(bp, &dvp->fid);
973967
bp = xdr_encode_name(bp, name);
974968
bp = xdr_encode_string(bp, op->create.symlink, contents_sz);
975-
bp = xdr_encode_YFSStoreStatus_mode(bp, S_IRWXUGO);
969+
bp = xdr_encode_YFSStoreStatus(bp, &mode, &op->mtime);
976970
yfs_check_req(call, bp);
977971

978972
trace_afs_make_fs_call1(call, &dvp->fid, name);
@@ -1103,7 +1097,7 @@ void yfs_fs_store_data(struct afs_operation *op)
11031097
bp = xdr_encode_u32(bp, YFSSTOREDATA64);
11041098
bp = xdr_encode_u32(bp, 0); /* RPC flags */
11051099
bp = xdr_encode_YFSFid(bp, &vp->fid);
1106-
bp = xdr_encode_YFSStoreStatus_mtime(bp, &op->mtime);
1100+
bp = xdr_encode_YFSStoreStatus(bp, NULL, &op->mtime);
11071101
bp = xdr_encode_u64(bp, op->store.pos);
11081102
bp = xdr_encode_u64(bp, op->store.size);
11091103
bp = xdr_encode_u64(bp, op->store.i_size);

0 commit comments

Comments
 (0)