kclient: removed i_wr_size and i_wr_mtime from ceph_inode_info

This commit is contained in:
Sage Weil 2008-03-27 12:58:10 -07:00
parent 1bda1ea7f7
commit 3b854bb3be
7 changed files with 36 additions and 16 deletions

View File

@ -4,6 +4,8 @@ code cleanup
- probably kill base case in encoder.h, replace with int types, with appropriate swabbing?
- addr=?
- switch to nsec in ceph_timespec
client leases
- lease length heuristics
- mds lock last_change stamp?
@ -26,6 +28,8 @@ userspace client
- reference count lease validations on path lookup?
kernel client
- strip i_wr_size etc out of ceph_inode_info
- take mds provided versions when appropriate
- carry wrbuffer/rdcache caps until data is flushed
- this should make the utimes bit kick in
- make sure link/unlink results reflected by inode/dentry cache (let fill_trace do it? invalidate? do actual update?)

View File

@ -89,7 +89,7 @@ static int ceph_writepage(struct page *page, struct writeback_control *wbc)
/* update written data size in ceph_inode_info */
spin_lock(&inode->i_lock);
if (inode->i_size <= PAGE_SIZE) {
ci->i_wr_size = inode->i_size = PAGE_SIZE;
inode->i_size = PAGE_SIZE;
inode->i_blocks = (inode->i_size + 512 - 1) >> 9;
dout(10, "extending file size to %d\n", (int)inode->i_size);
}

View File

@ -296,7 +296,7 @@ ssize_t ceph_silly_write(struct file *file, const char __user *data,
spin_lock(&inode->i_lock);
if (pos > inode->i_size) {
ci->i_wr_size = inode->i_size = pos;
inode->i_size = pos;
inode->i_blocks = (inode->i_size + 512 - 1) >> 9;
dout(10, "extending file size to %d\n", (int)inode->i_size);
}

View File

@ -473,13 +473,16 @@ int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant,
int seq = le32_to_cpu(grant->seq);
int newcaps;
int used;
int issued; /* to me, before */
int wanted = ceph_caps_wanted(ci) | ceph_caps_used(ci);
int ret = 0;
u64 size = le64_to_cpu(grant->size);
u64 max_size = le64_to_cpu(grant->max_size);
struct timespec mtime, atime;
int wake = 0;
dout(10, "handle_cap_grant inode %p ci %p mds%d seq %d\n", inode, ci, mds, seq);
dout(10, "handle_cap_grant inode %p ci %p mds%d seq %d\n",
inode, ci, mds, seq);
dout(10, " my wanted = %d\n", wanted);
dout(10, " size %llu max_size %llu\n", size, max_size);
@ -496,6 +499,25 @@ int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant,
ci->i_max_size = max_size;
}
/* mtime/atime? */
issued = ceph_caps_issued(ci);
if ((issued & CEPH_CAP_EXCL) == 0) {
ceph_decode_timespec(&mtime, &grant->mtime);
ceph_decode_timespec(&atime, &grant->atime);
if (timespec_compare(&mtime, &inode->i_mtime) > 0) {
dout(10, "mtime %lu.%09ld -> %lu.%.09ld\n",
mtime.tv_sec, mtime.tv_nsec,
inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec);
inode->i_mtime = mtime;
}
if (timespec_compare(&mtime, &inode->i_mtime) > 0) {
dout(10, "atime %lu.%09ld -> %lu.%09ld\n",
atime.tv_sec, atime.tv_nsec,
inode->i_atime.tv_sec, inode->i_atime.tv_nsec);
inode->i_atime = atime;
}
}
cap = get_cap_for_mds(inode, mds);
/* new cap? */
@ -766,8 +788,8 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
/* truncate? */
if (ia_valid & ATTR_SIZE &&
attr->ia_size < inode->i_size) { /* fixme? */
dout(10, "truncate: ia_size %d i_size %d ci->i_wr_size %d\n",
(int)attr->ia_size, (int)inode->i_size, (int)ci->i_wr_size);
dout(10, "truncate: ia_size %d i_size %d\n",
(int)attr->ia_size, (int)inode->i_size);
if (ia_valid & ATTR_FILE)
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_TRUNCATE,
ceph_ino(dentry->d_inode), "", 0, 0);

View File

@ -1027,7 +1027,7 @@ void send_mds_reconnect(struct ceph_mds_client *mdsc, int mds)
struct ceph_inode_cap *cap;
char *path;
int pathlen, err;
int usectmp;
int tmp; /* for timespec encoding */
struct dentry *dentry;
struct ceph_inode_info *ci;
struct ceph_mds_cap_reconnect *rec;
@ -1091,9 +1091,9 @@ retry:
BUG_ON(p > end);
rec->wanted = cpu_to_le32(ceph_caps_wanted(ci));
rec->issued = cpu_to_le32(ceph_caps_issued(ci));
rec->size = cpu_to_le64(ci->i_wr_size);
ceph_encode_timespec(&rec->mtime, &ci->vfs_inode.i_mtime, usectmp);
ceph_encode_timespec(&rec->atime, &ci->vfs_inode.i_atime, usectmp);
rec->size = cpu_to_le64(ci->vfs_inode.i_size);
ceph_encode_timespec(&rec->mtime, &ci->vfs_inode.i_mtime, tmp);
ceph_encode_timespec(&rec->atime, &ci->vfs_inode.i_atime, tmp);
dentry = d_find_alias(&ci->vfs_inode);
path = ceph_build_dentry_path(dentry, &pathlen);
if (IS_ERR(path)) {

View File

@ -128,10 +128,6 @@ static struct inode *ceph_alloc_inode(struct super_block *sb)
ci->i_rd_ref = ci->i_rdcache_ref = 0;
ci->i_wr_ref = ci->i_wrbuffer_ref = 0;
ci->i_wr_size = 0;
ci->i_wr_mtime.tv_sec = 0;
ci->i_wr_mtime.tv_nsec = 0;
ci->i_hashval = 0;
return &ci->vfs_inode;

View File

@ -161,8 +161,6 @@ struct ceph_inode_info {
int i_nr_by_mode[4];
int i_cap_wanted; /* what we've told the mds(s) */
loff_t i_max_size; /* size authorized by mds */
loff_t i_wr_size; /* largest offset we've written (+1) */
struct timespec i_wr_mtime;
struct timespec i_old_atime;
int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wrbuffer_ref;