Skip to content

Commit ffdeec7

Browse files
ukernelidryomov
authored andcommitted
ceph: always update atime/mtime/ctime for new inode
For new inode, atime/mtime/ctime are uninitialized. Don't compare against them. Cc: [email protected] Signed-off-by: "Yan, Zheng" <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 34f55d0 commit ffdeec7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

fs/ceph/inode.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,13 +669,15 @@ void ceph_fill_file_time(struct inode *inode, int issued,
669669
CEPH_CAP_FILE_BUFFER|
670670
CEPH_CAP_AUTH_EXCL|
671671
CEPH_CAP_XATTR_EXCL)) {
672-
if (timespec_compare(ctime, &inode->i_ctime) > 0) {
672+
if (ci->i_version == 0 ||
673+
timespec_compare(ctime, &inode->i_ctime) > 0) {
673674
dout("ctime %ld.%09ld -> %ld.%09ld inc w/ cap\n",
674675
inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
675676
ctime->tv_sec, ctime->tv_nsec);
676677
inode->i_ctime = *ctime;
677678
}
678-
if (ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) > 0) {
679+
if (ci->i_version == 0 ||
680+
ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) > 0) {
679681
/* the MDS did a utimes() */
680682
dout("mtime %ld.%09ld -> %ld.%09ld "
681683
"tw %d -> %d\n",
@@ -795,7 +797,6 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
795797
new_issued = ~issued & le32_to_cpu(info->cap.caps);
796798

797799
/* update inode */
798-
ci->i_version = le64_to_cpu(info->version);
799800
inode->i_rdev = le32_to_cpu(info->rdev);
800801
inode->i_blkbits = fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1;
801802

@@ -868,6 +869,9 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
868869
xattr_blob = NULL;
869870
}
870871

872+
/* finally update i_version */
873+
ci->i_version = le64_to_cpu(info->version);
874+
871875
inode->i_mapping->a_ops = &ceph_aops;
872876

873877
switch (inode->i_mode & S_IFMT) {

0 commit comments

Comments
 (0)