return ret;
}
+/*
+ * Return caps we have registered with the MDS(s) as wanted.
+ */
+int __ceph_caps_mds_wanted(struct ceph_inode_info *ci)
+{
+ struct ceph_cap *cap;
+ struct rb_node *p;
+ int mds_wanted = 0;
+
+ for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) {
+ cap = rb_entry(p, struct ceph_cap, ci_node);
+ if (!__cap_is_valid(cap))
+ continue;
+ mds_wanted |= cap->mds_wanted;
+ }
+ return mds_wanted;
+}
+
/*
* called under i_lock
*/
struct ceph_file_info *cf = file->private_data;
struct inode *parent_inode = file->f_dentry->d_parent->d_inode;
int err;
- int flags, fmode, wanted, new_want;
+ int flags, fmode, mds_wanted, new_want;
if (ceph_snap(inode) != CEPH_NOSNAP && (file->f_mode & FMODE_WRITE))
return -EROFS;
* registered with the MDS.
*/
spin_lock(&inode->i_lock);
- wanted = __ceph_caps_file_wanted(ci);
- if ((wanted & new_want) == new_want) {
+ mds_wanted = __ceph_caps_mds_wanted(ci);
+ if ((mds_wanted & new_want) == new_want) {
dout(10, "open fmode %d caps %d using existing on %p\n",
fmode, new_want, inode);
__ceph_get_fmode(ci, fmode);
}
spin_unlock(&inode->i_lock);
dout(10, "open fmode %d wants %s, we only already want %s\n",
- fmode, ceph_cap_string(new_want), ceph_cap_string(wanted));
+ fmode, ceph_cap_string(new_want), ceph_cap_string(mds_wanted));
dentry = d_find_alias(inode);
if (!dentry)
return w;
}
+/* what the mds thinks we want */
+extern int __ceph_caps_mds_wanted(struct ceph_inode_info *ci);
+
static inline struct ceph_client *ceph_inode_to_client(struct inode *inode)
{
return (struct ceph_client *)inode->i_sb->s_fs_info;