#define CEPH_CAP_LINK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SLINK)
#define CEPH_CAP_XATTR_RDCACHE (CEPH_CAP_GRDCACHE << CEPH_CAP_SXATTR)
#define CEPH_CAP_XATTR_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SXATTR)
+#define CEPH_CAP_FILE(x) (x << CEPH_CAP_SFILE)
#define CEPH_CAP_FILE_RDCACHE (CEPH_CAP_GRDCACHE << CEPH_CAP_SFILE)
#define CEPH_CAP_FILE_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFILE)
#define CEPH_CAP_FILE_RD (CEPH_CAP_GRD << CEPH_CAP_SFILE)
mds = cap->mds;
if (mseq)
*mseq = cap->mseq;
- if (cap->issued & (CEPH_CAP_WR|CEPH_CAP_WRBUFFER|CEPH_CAP_EXCL))
+ if (cap->issued & (CEPH_CAP_FILE_WR |
+ CEPH_CAP_FILE_WRBUFFER |
+ CEPH_CAP_FILE_EXCL))
break;
}
return mds;
follows = ci->i_snap_realm->cached_context->seq;
spin_unlock(&inode->i_lock);
- if (dropping & CEPH_CAP_RDCACHE) {
+ if (dropping & CEPH_CAP_FILE_RDCACHE) {
/* invalidate what we can */
dout(20, "invalidating pages on %p\n", inode);
invalidate_mapping_pages(&inode->i_data, 0, -1);
goto ack;
/* approaching file_max? */
- if ((cap->issued & CEPH_CAP_WR) &&
+ if ((cap->issued & CEPH_CAP_FILE_WR) &&
(inode->i_size << 1) >= ci->i_max_size &&
(ci->i_reported_size << 1) < ci->i_max_size) {
dout(10, "i_size approaching max_size\n");
*/
static void __take_cap_refs(struct ceph_inode_info *ci, int got)
{
- if (got & CEPH_CAP_RD)
+ if (got & CEPH_CAP_FILE_RD)
ci->i_rd_ref++;
- if (got & CEPH_CAP_RDCACHE)
+ if (got & CEPH_CAP_FILE_RDCACHE)
ci->i_rdcache_ref++;
- if (got & CEPH_CAP_WR)
+ if (got & CEPH_CAP_FILE_WR)
ci->i_wr_ref++;
- if (got & CEPH_CAP_WRBUFFER) {
+ if (got & CEPH_CAP_FILE_WRBUFFER) {
ci->i_wrbuffer_ref++;
dout(30, "__take_cap_refs %p wrbuffer %d -> %d (?)\n",
&ci->vfs_inode, ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref);
dout(30, "get_cap_refs %p need %d want %d\n", inode, need, want);
spin_lock(&inode->i_lock);
- if (need & CEPH_CAP_WR) {
+ if (need & CEPH_CAP_FILE_WR) {
if (endoff >= 0 && endoff > (loff_t)ci->i_max_size) {
dout(20, "get_cap_refs %p endoff %llu > maxsize %llu\n",
inode, endoff, ci->i_max_size);
struct ceph_cap_snap *capsnap;
spin_lock(&inode->i_lock);
- if (had & CEPH_CAP_RD)
+ if (had & CEPH_CAP_FILE_RD)
if (--ci->i_rd_ref == 0)
last++;
- if (had & CEPH_CAP_RDCACHE)
+ if (had & CEPH_CAP_FILE_RDCACHE)
if (--ci->i_rdcache_ref == 0)
last++;
- if (had & CEPH_CAP_WRBUFFER) {
+ if (had & CEPH_CAP_FILE_WRBUFFER) {
if (--ci->i_wrbuffer_ref == 0)
last++;
dout(30, "put_cap_refs %p wrbuffer %d -> %d (?)\n",
inode, ci->i_wrbuffer_ref+1, ci->i_wrbuffer_ref);
}
- if (had & CEPH_CAP_WR)
+ if (had & CEPH_CAP_FILE_WR)
if (--ci->i_wr_ref == 0) {
last++;
if (!list_empty(&ci->i_cap_snaps)) {
/*
* Each time we receive RDCACHE anew, we increment i_rdcache_gen.
*/
- if ((newcaps & CEPH_CAP_RDCACHE) && /* we just got RDCACHE */
- (cap->issued & CEPH_CAP_RDCACHE) == 0 && /* and didn't have it */
- (__ceph_caps_issued(ci, NULL) & CEPH_CAP_RDCACHE) == 0)
+ if ((newcaps & CEPH_CAP_FILE_RDCACHE) && /* we just got RDCACHE */
+ (cap->issued & CEPH_CAP_FILE_RDCACHE) == 0 && /* and didn't have it */
+ (__ceph_caps_issued(ci, NULL) & CEPH_CAP_FILE_RDCACHE) == 0)
ci->i_rdcache_gen++;
/*
* try to invalidate (once). (If there are dirty buffers, we
* will invalidate _after_ writeback.)
*/
- if (((cap->issued & ~newcaps) & CEPH_CAP_RDCACHE) &&
+ if (((cap->issued & ~newcaps) & CEPH_CAP_FILE_RDCACHE) &&
!ci->i_wrbuffer_ref && !tried_invalidate) {
dout(10, "RDCACHE invalidation\n");
spin_unlock(&inode->i_lock);
/* revocation? */
if (cap->issued & ~newcaps) {
dout(10, "revocation: %d -> %d\n", cap->issued, newcaps);
- if ((used & ~newcaps) & CEPH_CAP_WRBUFFER) {
+ if ((used & ~newcaps) & CEPH_CAP_FILE_WRBUFFER) {
writeback = 1; /* will delay ack */
- } else if (((used & ~newcaps) & CEPH_CAP_RDCACHE) == 0 ||
+ } else if (((used & ~newcaps) & CEPH_CAP_FILE_RDCACHE) == 0 ||
revoked_rdcache) {
/*
* we're not using revoked caps.. ack now.
return ceph_lookup_open(dir, dentry, nd, mode, 1);
}
- return ceph_do_lookup(dir->i_sb, dentry, CEPH_STAT_MASK_INODE_ALL,
+ return ceph_do_lookup(dir->i_sb, dentry, CEPH_STAT_CAP_INODE_ALL,
0, 1);
}
* and the VFS needs a valid dentry.
*/
struct dentry *d;
- d = ceph_do_lookup(dir->i_sb, dentry, CEPH_STAT_MASK_INODE_ALL,
+ d = ceph_do_lookup(dir->i_sb, dentry, CEPH_STAT_CAP_INODE_ALL,
0, 0);
if (d) {
/* ick. this is untested, and inherently racey... i
if (ceph_ino(dir) != 1 && /* ICONTENT is meaningless on root inode */
ceph_inode(dir)->i_version == dentry->d_time &&
- ceph_inode_lease_valid(dir, CEPH_LOCK_IFILE)) {
- dout(20, "dentry_revalidate %p %lu ICONTENT on dir %p %llu\n",
+ ceph_inode_holds_cap(dir, CEPH_CAP_FILE_RDCACHE)) {
+ dout(20, "dentry_revalidate %p %lu file RDCACHE dir %p %llu\n",
dentry, dentry->d_time, dir, ceph_inode(dir)->i_version);
return 1;
}
dout(10, "aio_read %llx.%llx %llu~%u trying to get caps on %p\n",
ceph_vinop(inode), pos, (unsigned)len, inode);
ret = wait_event_interruptible(ci->i_cap_wq,
- ceph_get_cap_refs(ci, CEPH_CAP_RD,
- CEPH_CAP_RDCACHE,
+ ceph_get_cap_refs(ci,
+ CEPH_CAP_FILE_RD,
+ CEPH_CAP_FILE_RDCACHE,
&got, -1));
if (ret < 0)
goto out;
dout(10, "aio_read %llx.%llx %llu~%u got cap refs %d\n",
ceph_vinop(inode), pos, (unsigned)len, got);
- if ((got & CEPH_CAP_RDCACHE) == 0 ||
+ if ((got & CEPH_CAP_FILE_RDCACHE) == 0 ||
(inode->i_sb->s_flags & MS_SYNCHRONOUS))
/* hmm, this isn't really async... */
ret = ceph_sync_read(filp, iov->iov_base, len, ppos);
dout(10, "aio_write %p %llu~%u getting caps. i_size %llu\n",
inode, pos, (unsigned)iov->iov_len, inode->i_size);
ret = wait_event_interruptible(ci->i_cap_wq,
- ceph_get_cap_refs(ci, CEPH_CAP_WR,
- CEPH_CAP_WRBUFFER,
+ ceph_get_cap_refs(ci,
+ CEPH_CAP_FILE_WR,
+ CEPH_CAP_FILE_WRBUFFER,
&got, endoff));
if (ret < 0)
goto out;
dout(10, "aio_write %p %llu~%u got cap refs on %d\n",
inode, pos, (unsigned)iov->iov_len, got);
- if ((got & CEPH_CAP_WRBUFFER) == 0) {
+ if ((got & CEPH_CAP_FILE_WRBUFFER) == 0) {
ret = ceph_sync_write(file, iov->iov_base, iov->iov_len,
&iocb->ki_pos);
} else {
ci->i_time_warp_seq = 0;
ci->i_symlink = NULL;
- ci->i_lease_session = NULL;
- ci->i_lease_mask = 0;
- ci->i_lease_ttl = 0;
- INIT_LIST_HEAD(&ci->i_lease_item);
-
ci->i_fragtree = RB_ROOT;
mutex_init(&ci->i_fragtree_mutex);
ci->i_truncate_seq = truncate_seq;
}
- if (issued & CEPH_CAP_EXCL) {
+ 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 (time_warp_seq > ci->i_time_warp_seq)
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_WR|CEPH_CAP_WRBUFFER)) {
+ } else if (issued & (CEPH_CAP_FILE_WR|CEPH_CAP_FILE_WRBUFFER)) {
if (time_warp_seq > ci->i_time_warp_seq) {
/* the MDS did a utimes() */
inode->i_ctime = *ctime;
return err;
}
-
-
-/*
- * caller must hold session s_mutex.
- */
-static int update_inode_lease(struct inode *inode,
- struct ceph_mds_reply_lease *lease,
- struct ceph_mds_session *session,
- unsigned long from_time)
-{
- struct ceph_inode_info *ci = ceph_inode(inode);
- int is_new = 0;
- int mask = le16_to_cpu(lease->mask);
- long unsigned duration = le32_to_cpu(lease->duration_ms);
- long unsigned ttl = from_time + (duration * HZ) / 1000;
-
- dout(10, "update_inode_lease %p mask %d duration %lu ms ttl %lu\n",
- inode, mask, duration, ttl);
-
- if (mask == 0)
- return 0;
-
- spin_lock(&inode->i_lock);
- /*
- * be careful: we can't remove a lease from a different session
- * without holding the other session's s_mutex. and we only
- * remember one lease per object. so if one already exists,
- * don't touch it.
- */
- if ((ci->i_lease_ttl == 0 || !time_before(ttl, ci->i_lease_ttl) ||
- ci->i_lease_gen != session->s_cap_gen) &&
- (!ci->i_lease_session || ci->i_lease_session == session)) {
- ci->i_lease_ttl = ttl;
- ci->i_lease_gen = session->s_cap_gen;
- ci->i_lease_mask = mask;
- if (!ci->i_lease_session) {
- ci->i_lease_session = session;
- is_new = 1;
- }
- list_move_tail(&ci->i_lease_item, &session->s_inode_leases);
- } else {
- mask = 0;
- }
- spin_unlock(&inode->i_lock);
- if (is_new)
- igrab(inode);
- return mask;
-}
-
/*
- * check if inode lease is valid for a given mask
+ * check if inode holds specific cap
*/
-int ceph_inode_lease_valid(struct inode *inode, int mask)
+int ceph_inode_holds_cap(struct inode *inode, int mask)
{
struct ceph_inode_info *ci = ceph_inode(inode);
- int havemask;
- int valid = 0;
- int ret = 0;
-
- spin_lock(&inode->i_lock);
- havemask = ci->i_lease_mask;
-
- /* EXCL cap counts for an ICONTENT lease... check caps? */
- if ((mask & CEPH_LOCK_IFILE) &&
- __ceph_caps_issued(ci, NULL) & CEPH_CAP_EXCL) {
- dout(20, "lease_valid inode %p EXCL cap -> ICONTENT\n", inode);
- havemask |= CEPH_LOCK_IFILE;
- }
-
- if (ci->i_lease_session) {
- struct ceph_mds_session *s = ci->i_lease_session;
- spin_lock(&s->s_cap_lock);
- if (s->s_cap_gen == ci->i_lease_gen &&
- time_before(jiffies, s->s_cap_ttl) &&
- time_before(jiffies, ci->i_lease_ttl))
- valid = 1;
- spin_unlock(&s->s_cap_lock);
- }
- spin_unlock(&inode->i_lock);
+ int issued = ceph_caps_issued(ci);
+ int ret;
- if (valid && (havemask & mask) == mask)
+ if ((issued & mask) == mask)
ret = 1;
-
- dout(10, "lease_valid inode %p have %d want %d valid %d = %d\n", inode,
- havemask, mask, valid, ret);
+ dout(10, "ceph_inode_holds_cap inode %p have %d want %d = %d\n", inode,
+ issued, mask, ret);
return ret;
}
struct ceph_mds_session *session)
{
struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info;
- int err = 0, mask;
+ int err = 0;
struct qstr dname;
struct dentry *dn = sb->s_root;
struct dentry *parent = NULL;
struct ceph_mds_reply_inode *ininfo;
int d = 0;
struct ceph_vino vino;
- int have_icontent;
bool have_lease;
if (rinfo->trace_numi == 0) {
rinfo->trace_dir[0] : NULL);
if (err < 0)
return err;
- if (rinfo->trace_numd == 0)
- update_inode_lease(in, rinfo->trace_ilease[0],
- session, req->r_request_started);
if (unlikely(sb->s_root == NULL))
sb->s_root = dn;
}
- have_icontent = 0;
have_lease = 0;
dget(dn);
for (d = 0; d < rinfo->trace_numd; d++) {
dn = NULL;
dout(10, "fill_trace %d/%d parent %p inode %p: '%.*s'"
- " ic %d dmask %d\n",
+ " dmask %d\n",
(d+1), rinfo->trace_numd, parent, parent->d_inode,
(int)dname.len, dname.name,
- have_icontent, rinfo->trace_dlease[d]->mask);
+ rinfo->trace_dlease[d]->mask);
/* try to take dir i_mutex */
if (req->r_locked_dir != parent->d_inode &&
goto no_dir_mutex;
}
- /* update inode lease */
- mask = update_inode_lease(in, rinfo->trace_ilease[d],
- session, req->r_request_started);
- have_icontent = mask & CEPH_LOCK_IFILE;
-
/* do we have a dn lease? */
- have_lease = have_icontent ||
- (le16_to_cpu(rinfo->trace_dlease[d]->mask) &
+ have_lease = (le16_to_cpu(rinfo->trace_dlease[d]->mask) &
CEPH_LOCK_DN);
if (!have_lease)
dout(10, "fill_trace no icontent|dentry lease\n");
if (parent)
dput(parent);
- if (in)
- update_inode_lease(dn->d_inode,
- rinfo->trace_ilease[d],
- session, req->r_request_started);
-
dout(10, "fill_trace done err=%d, last dn %p in %p\n", err, dn, in);
if (req->r_last_dentry)
dput(req->r_last_dentry);
}
update_dentry_lease(dn, rinfo->dir_dlease[i],
req->r_session, req->r_request_started);
- update_inode_lease(in, rinfo->dir_ilease[i],
- req->r_session, req->r_request_started);
dput(dn);
}
int issued = ceph_caps_issued(ceph_inode(dentry->d_inode));
if ((ia_valid & ATTR_FILE) ||
- (issued & (CEPH_CAP_WR|CEPH_CAP_WRBUFFER))) {
+ (issued & (CEPH_CAP_FILE_WR|CEPH_CAP_FILE_WRBUFFER))) {
dout(5, "prepare_setattr dentry %p (inode %llx.%llx)\n", dentry,
ceph_vinop(dentry->d_inode));
req = ceph_mdsc_create_request(mdsc, op,
int err;
/* if i hold CAP_EXCL, i can change [am]time any way i like */
- if (ceph_caps_issued(ci) & CEPH_CAP_EXCL) {
+ if (ceph_caps_issued(ci) & CEPH_CAP_FILE_EXCL) {
dout(10, "utime holding EXCL, doing locally\n");
ci->i_time_warp_seq++;
if (ia_valid & ATTR_ATIME)
}
/* if i hold CAP_WR, i can _increase_ [am]time safely */
- if ((ceph_caps_issued(ci) & CEPH_CAP_WR) &&
+ if ((ceph_caps_issued(ci) & CEPH_CAP_FILE_WR) &&
((ia_valid & ATTR_MTIME) == 0 ||
timespec_compare(&inode->i_mtime, &attr->ia_mtime) < 0) &&
((ia_valid & ATTR_ATIME) == 0 ||
inode->i_ctime = CURRENT_TIME;
return 0;
}
-
/* if i have valid values, this may be a no-op */
- if (ceph_inode_lease_valid(inode, CEPH_LOCK_IFILE) &&
+ if (ceph_inode_holds_cap(inode, CEPH_CAP_FILE_RDCACHE) &&
!(((ia_valid & ATTR_ATIME) &&
!timespec_equal(&inode->i_atime, &attr->ia_atime)) ||
((ia_valid & ATTR_MTIME) &&
if (ia_valid & ATTR_MTIME)
reqh->args.utime.mask |= cpu_to_le32(CEPH_UTIME_MTIME);
- ceph_mdsc_lease_release(mdsc, inode, NULL, CEPH_LOCK_IFILE);
+ ceph_mdsc_lease_release(mdsc, inode, NULL, CEPH_CAP_FILE_RDCACHE);
err = ceph_mdsc_do_request(mdsc, req);
ceph_mdsc_put_request(req);
dout(10, "utime result %d\n", err);
dout(10, "truncate: ia_size %d i_size %d\n",
(int)attr->ia_size, (int)inode->i_size);
- if (ceph_caps_issued(ci) & CEPH_CAP_EXCL &&
+ if (ceph_caps_issued(ci) & CEPH_CAP_FILE_EXCL &&
attr->ia_size > inode->i_size) {
dout(10, "holding EXCL, doing truncate (fwd) locally\n");
err = vmtruncate(inode, attr->ia_size);
spin_unlock(&inode->i_lock);
return 0;
}
- if (ceph_inode_lease_valid(inode, CEPH_LOCK_IFILE) &&
+ if (ceph_inode_holds_cap(inode, CEPH_CAP_FILE_RDCACHE) &&
attr->ia_size == inode->i_size) {
dout(10, "lease indicates truncate is a no-op\n");
return 0;
return PTR_ERR(req);
reqh = req->r_request->front.iov_base;
reqh->args.truncate.length = cpu_to_le64(attr->ia_size);
- ceph_mdsc_lease_release(mdsc, inode, NULL, CEPH_LOCK_IFILE);
+ ceph_mdsc_lease_release(mdsc, inode, NULL, CEPH_CAP_FILE_RDCACHE);
err = ceph_mdsc_do_request(mdsc, req);
ceph_mdsc_put_request(req);
dout(10, "truncate result %d\n", err);
dout(30, "getattr dentry %p inode %p mask %d\n", dentry,
dentry->d_inode, mask);
- if (ceph_inode_lease_valid(dentry->d_inode, mask))
+ if (ceph_inode_holds_cap(dentry->d_inode, mask))
return 0;
/*
{
int err;
- err = ceph_do_getattr(dentry, CEPH_STAT_MASK_INODE_ALL);
+ err = ceph_do_getattr(dentry, CEPH_STAT_CAP_INODE_ALL);
dout(30, "getattr returned %d\n", err);
if (!err) {
generic_fillattr(dentry->d_inode, stat);
return (vir_xattr->getxattr_cb)(ci, value, size);
/* get xattrs from mds (if we don't already have them) */
- err = ceph_do_getattr(dentry, CEPH_STAT_MASK_XATTR);
+ err = ceph_do_getattr(dentry, CEPH_STAT_CAP_XATTR);
if (err)
return err;
u32 len;
int i;
- err = ceph_do_getattr(dentry, CEPH_STAT_MASK_XATTR);
+ err = ceph_do_getattr(dentry, CEPH_STAT_CAP_XATTR);
if (err)
return err;
struct ceph_inode_info *ci = ceph_inode(file->f_dentry->d_inode);
int err;
- err = ceph_do_getattr(file->f_dentry, CEPH_STAT_MASK_LAYOUT);
+ err = ceph_do_getattr(file->f_dentry, CEPH_STAT_CAP_LAYOUT);
if (!err) {
if (copy_to_user(arg, &ci->i_layout, sizeof(ci->i_layout)))
return -EFAULT;
dput(dentry);
}
-/*
- * caller must hold session s_mutex
- */
-static void revoke_inode_lease(struct ceph_inode_info *ci, int mask)
-{
- struct inode *inode = &ci->vfs_inode;
- int drop = 0;
-
- spin_lock(&inode->i_lock);
- dout(10, "revoke_inode_lease on inode %p, mask %d -> %d\n",
- inode, ci->i_lease_mask, ci->i_lease_mask & ~mask);
- if (ci->i_lease_mask & mask) {
- ci->i_lease_mask &= ~mask;
- if (ci->i_lease_mask == 0) {
- list_del_init(&ci->i_lease_item);
- ci->i_lease_session = NULL;
- drop = 1;
- }
- }
- spin_unlock(&inode->i_lock);
- if (drop)
- iput(inode);
-}
-
/*
* remove old/expired leases for this session. unpin parent
* inode/dentries, so that [di]cache can prune them.
*/
static void trim_session_leases(struct ceph_mds_session *session)
{
- struct ceph_inode_info *ci;
struct ceph_dentry_info *di;
struct dentry *dentry;
- struct inode *inode;
dout(20, "trim_session_leases on session %p\n", session);
- /* inodes */
- while (!list_empty(&session->s_inode_leases)) {
- ci = list_first_entry(&session->s_inode_leases,
- struct ceph_inode_info, i_lease_item);
- inode = &ci->vfs_inode;
- spin_lock(&inode->i_lock);
- if (time_before(jiffies, ci->i_lease_ttl)) {
- spin_unlock(&inode->i_lock);
- break;
- }
- dout(20, "trim_session_leases inode %p mask %d\n",
- inode, ci->i_lease_mask);
- ci->i_lease_session = NULL;
- ci->i_lease_mask = 0;
- list_del_init(&ci->i_lease_item);
- spin_unlock(&inode->i_lock);
- iput(inode);
- }
-
/* dentries */
while (!list_empty(&session->s_dentry_leases)) {
di = list_first_entry(&session->s_dentry_leases,
*/
static void remove_session_leases(struct ceph_mds_session *session)
{
- struct ceph_inode_info *ci;
struct ceph_dentry_info *di;
dout(10, "remove_session_leases on %p\n", session);
- /* inodes */
- while (!list_empty(&session->s_inode_leases)) {
- ci = list_entry(session->s_inode_leases.next,
- struct ceph_inode_info, i_lease_item);
- dout(10, "removing lease from inode %p\n", &ci->vfs_inode);
- revoke_inode_lease(ci, ci->i_lease_mask);
- }
-
/* dentries */
while (!list_empty(&session->s_dentry_leases)) {
di = list_entry(session->s_dentry_leases.next,
/* inode */
ci = ceph_inode(inode);
- revoke_inode_lease(ci, mask);
/* dentry */
if (mask & CEPH_LOCK_DN) {
{
struct ceph_msg *msg;
struct ceph_mds_lease *lease;
- struct ceph_inode_info *ci;
struct ceph_dentry_info *di;
int origmask = mask;
int mds = -1;
mask &= ~CEPH_LOCK_DN; /* no lease; clear DN bit */
}
- /* inode lease? */
- ci = ceph_inode(inode);
- spin_lock(&inode->i_lock);
- if (ci->i_lease_session &&
- ci->i_lease_session->s_mds >= 0 &&
- ci->i_lease_gen == ci->i_lease_session->s_cap_gen &&
- time_before(jiffies, ci->i_lease_ttl)) {
- mds = ci->i_lease_session->s_mds;
- mask &= CEPH_LOCK_DN | ci->i_lease_mask; /* lease is valid */
- ci->i_lease_mask &= ~mask;
- } else {
- mask &= CEPH_LOCK_DN; /* no lease; clear all but DN bits */
- }
- spin_unlock(&inode->i_lock);
-
if (mask == 0) {
- dout(10, "lease_release inode %p (%d) dentry %p -- "
+ dout(10, "lease_release inode %p dentry %p -- "
"no lease on %d\n",
- inode, ci->i_lease_mask, dentry, origmask);
+ inode, dentry, origmask);
return; /* nothing to drop */
}
BUG_ON(mds < 0);
dout(10, "queue_cap_snap %p snapc %p seq %llu used %d"
" already pending\n", inode, snapc, snapc->seq, used);
kfree(capsnap);
- } else if (ci->i_wrbuffer_ref_head || (used & CEPH_CAP_WR)) {
+ } else if (ci->i_wrbuffer_ref_head || (used & CEPH_CAP_FILE_WR)) {
igrab(inode);
capsnap->follows = snapc->seq - 1;
capsnap->context = ceph_get_snap_context(snapc);
ci->i_head_snapc = NULL;
list_add_tail(&capsnap->ci_item, &ci->i_cap_snaps);
- if (used & CEPH_CAP_WR) {
+ if (used & CEPH_CAP_FILE_WR) {
dout(10, "queue_cap_snap %p cap_snap %p snapc %p"
" seq %llu used WR, now pending\n", inode,
capsnap, snapc, snapc->seq);
int i_xattr_len;
char *i_xattr_data;
- /* inode lease. protected _both_ by i_lock and i_lease_session's
- * s_mutex. */
- int i_lease_mask;
- struct ceph_mds_session *i_lease_session;
- long unsigned i_lease_ttl; /* jiffies */
- u32 i_lease_gen;
- struct list_head i_lease_item; /* mds session list */
-
/* capabilities. protected _both_ by i_lock and cap->session's
* s_mutex. */
struct rb_root i_caps; /* cap list */
{
int used = 0;
if (ci->i_rd_ref)
- used |= CEPH_CAP_RD;
+ used |= CEPH_CAP_GRD;
if (ci->i_rdcache_ref || ci->i_rdcache_gen)
- used |= CEPH_CAP_RDCACHE;
+ used |= CEPH_CAP_GRDCACHE;
if (ci->i_wr_ref)
- used |= CEPH_CAP_WR;
+ used |= CEPH_CAP_GWR;
if (ci->i_wrbuffer_ref)
- used |= CEPH_CAP_WRBUFFER;
- return used;
+ used |= CEPH_CAP_GWRBUFFER;
+ return CEPH_CAP_FILE(used);
}
/*
static inline int __ceph_caps_wanted(struct ceph_inode_info *ci)
{
int w = __ceph_caps_file_wanted(ci) | __ceph_caps_used(ci);
- if (w & CEPH_CAP_WRBUFFER)
- w |= CEPH_CAP_EXCL; /* we want EXCL if we have dirty data */
+ if (w & CEPH_CAP_FILE_WRBUFFER)
+ w |= (CEPH_CAP_FILE_EXCL); /* we want EXCL if we have dirty data */
return w;
}
struct ceph_mds_session *session);
extern int ceph_readdir_prepopulate(struct ceph_mds_request *req);
-extern int ceph_inode_lease_valid(struct inode *inode, int mask);
+extern int ceph_inode_holds_cap(struct inode *inode, int mask);
extern int ceph_dentry_lease_valid(struct dentry *dentry);
extern void ceph_inode_set_size(struct inode *inode, loff_t size);