From 65e45039a4bf1106362b7581e2a1f16fe1886b1e Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh-Weinraub Date: Tue, 8 Apr 2008 16:07:46 +0300 Subject: [PATCH] kclient: utime handle ctime updates too --- src/include/ceph_fs.h | 5 +++++ src/kernel/inode.c | 22 +++++++++++++++++++--- src/mds/Server.cc | 14 +++++++++++--- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 64b737851a91c..3a7d6758c096a 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -342,6 +342,9 @@ struct ceph_statfs { #define CEPH_STAT_MASK_ATIME CEPH_LOCK_ICONTENT /* fixme */ #define CEPH_STAT_MASK_INODE_ALL (CEPH_LOCK_ICONTENT|CEPH_LOCK_IAUTH|CEPH_LOCK_ILINK|CEPH_LOCK_INO) +#define CEPH_UTIME_ATIME 1 +#define CEPH_UTIME_MTIME 2 +#define CEPH_UTIME_CTIME 4 /* client_session */ enum { @@ -409,8 +412,10 @@ struct ceph_mds_request_head { ceph_frag_t frag; } readdir; struct { + __u32 mask; struct ceph_timespec mtime; struct ceph_timespec atime; + struct ceph_timespec ctime; } utime; struct { __u32 mode; diff --git a/src/kernel/inode.c b/src/kernel/inode.c index 551bbde8cf2d0..13069251a8061 100644 --- a/src/kernel/inode.c +++ b/src/kernel/inode.c @@ -1159,6 +1159,10 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) dout(10, "setattr: mtime %ld.%ld -> %ld.%ld\n", inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec, attr->ia_mtime.tv_sec, attr->ia_mtime.tv_nsec); + if (ia_valid & ATTR_CTIME) + dout(10, "setattr: ctime %ld.%ld -> %ld.%ld\n", + inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec, + attr->ia_ctime.tv_sec, attr->ia_ctime.tv_nsec); if (ia_valid & ATTR_FILE) dout(10, "setattr: ATTR_FILE ... hrm!\n"); @@ -1200,7 +1204,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) } /* utimes */ - if (ia_valid & (ATTR_ATIME|ATTR_MTIME)) { + if (ia_valid & (ATTR_ATIME|ATTR_MTIME|ATTR_CTIME)) { /* do i hold CAP_EXCL? */ if (ceph_caps_issued(ci) & CEPH_CAP_EXCL) { dout(10, "utime holding EXCL, doing locally\n"); @@ -1209,10 +1213,12 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) return 0; } if (ceph_inode_lease_valid(inode, CEPH_LOCK_ICONTENT) && - !(((ia_valid & ATTR_MTIME) && + !(((ia_valid & ATTR_ATIME) && !timespec_equal(&inode->i_atime, &attr->ia_atime)) || ((ia_valid & ATTR_MTIME) && - !timespec_equal(&inode->i_mtime, &attr->ia_mtime)))) { + !timespec_equal(&inode->i_mtime, &attr->ia_mtime)) || + ((ia_valid & ATTR_CTIME) && + !timespec_equal(&inode->i_ctime, &attr->ia_ctime)))) { dout(10, "lease indicates utimes is a no-op\n"); return 0; } @@ -1222,6 +1228,16 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) reqh = req->r_request->front.iov_base; ceph_encode_timespec(&reqh->args.utime.mtime, &attr->ia_mtime); ceph_encode_timespec(&reqh->args.utime.atime, &attr->ia_atime); + ceph_encode_timespec(&reqh->args.utime.ctime, &attr->ia_ctime); + + reqh->args.utime.mask = 0; + if (ia_valid & ATTR_ATIME) + reqh->args.utime.mask |= CEPH_UTIME_ATIME; + if (ia_valid & ATTR_MTIME) + reqh->args.utime.mask |= CEPH_UTIME_MTIME; + if (ia_valid & ATTR_CTIME) + reqh->args.utime.mask |= CEPH_UTIME_CTIME; + ceph_mdsc_lease_release(mdsc, inode, 0, CEPH_LOCK_ICONTENT); err = ceph_mdsc_do_request(mdsc, req); ceph_mdsc_put_request(req); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 6d2bf1652e9d3..befc94323cbb1 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -1594,6 +1594,7 @@ void Server::handle_client_utime(MDRequest *mdr) { MClientRequest *req = mdr->client_request; CInode *cur = rdlock_path_pin_ref(mdr, true); + __u32 mask; if (!cur) return; if (cur->is_root()) { @@ -1611,10 +1612,17 @@ void Server::handle_client_utime(MDRequest *mdr) // project update inode_t *pi = cur->project_inode(); - pi->mtime = req->head.args.utime.mtime; - pi->atime = req->head.args.utime.atime; + + mask = req->head.args.utime.mask; + + if (mask & CEPH_UTIME_MTIME) + pi->mtime = req->head.args.utime.mtime; + if (mask & CEPH_UTIME_ATIME) + pi->atime = req->head.args.utime.atime; + if (mask & CEPH_UTIME_CTIME) + pi->ctime = req->head.args.utime.ctime; + pi->version = cur->pre_dirty(); - pi->ctime = g_clock.real_now(); // log + wait mdr->ls = mdlog->get_current_segment(); -- 2.39.5