From f4644acd0d60e8cd98117de2773fe98262cf23d7 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 16 Jan 2009 16:07:42 -0800 Subject: [PATCH] kclient: fix fill_file_bits logic ctime should be the max if we hold any wr caps, otherwise it's the mds value, regardless of time_warp_seq (which does not modify ctime). --- src/include/ceph_fs.h | 2 +- src/kernel/inode.c | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 273343e849f5a..d9d4147ba9997 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -958,7 +958,7 @@ static inline int ceph_flags_to_mode(int flags) CEPH_CAP_LINK_EXCL | \ CEPH_CAP_XATTR_EXCL | \ CEPH_CAP_FILE_EXCL) -#define CEPH_CAP_ANY_FILE_WR ((CEPH_CAP_GWR|CEPH_CAP_GWRBUFFER) << CEPH_CAP_SFILE) +#define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR|CEPH_CAP_FILE_WRBUFFER) #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR) /* diff --git a/src/kernel/inode.c b/src/kernel/inode.c index 2e3a9968215a1..2bf2bc6da400d 100644 --- a/src/kernel/inode.c +++ b/src/kernel/inode.c @@ -343,30 +343,24 @@ void ceph_fill_file_bits(struct inode *inode, int issued, ci->i_truncate_seq = truncate_seq; } - if (issued & CEPH_CAP_FILE_EXCL) { - /* - * if we hold EXCL cap, we have the most up to date - * values for everything except possibly ctime. - */ + if (issued & (CEPH_CAP_FILE_EXCL| + CEPH_CAP_FILE_WR| + CEPH_CAP_FILE_WRBUFFER)) { if (timespec_compare(ctime, &inode->i_ctime) > 0) inode->i_ctime = *ctime; - if (ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) > 0) - derr(0, "WARNING: %p mds time_warp_seq %llu > %llu\n", - inode, time_warp_seq, ci->i_time_warp_seq); - } else if (issued & (CEPH_CAP_FILE_WR|CEPH_CAP_FILE_WRBUFFER)) { if (ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) > 0) { /* the MDS did a utimes() */ - inode->i_ctime = *ctime; inode->i_mtime = *mtime; inode->i_atime = *atime; ci->i_time_warp_seq = time_warp_seq; } else if (time_warp_seq == ci->i_time_warp_seq) { - if (timespec_compare(ctime, &inode->i_ctime) > 0) - inode->i_ctime = *ctime; + /* nobody did utimes(); take the max */ if (timespec_compare(mtime, &inode->i_mtime) > 0) inode->i_mtime = *mtime; if (timespec_compare(atime, &inode->i_atime) > 0) inode->i_atime = *atime; + } else if (issued & CEPH_CAP_FILE_EXCL) { + /* we did a utimes(); ignore mds values */ } else { warn = 1; } -- 2.39.5