Lines Matching refs:ci

18 static int __remove_xattr(struct ceph_inode_info *ci,
36 ssize_t (*getxattr_cb)(struct ceph_inode_info *ci, char *val,
38 bool (*exists_cb)(struct ceph_inode_info *ci);
49 static bool ceph_vxattrcb_layout_exists(struct ceph_inode_info *ci) in ceph_vxattrcb_layout_exists() argument
51 struct ceph_file_layout *fl = &ci->i_layout; in ceph_vxattrcb_layout_exists()
57 static ssize_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_layout() argument
60 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->netfs.inode.i_sb); in ceph_vxattrcb_layout()
63 s64 pool = ci->i_layout.pool_id; in ceph_vxattrcb_layout()
70 pool_ns = ceph_try_get_string(ci->i_layout.pool_ns); in ceph_vxattrcb_layout()
72 dout("ceph_vxattrcb_layout %p\n", &ci->netfs.inode); in ceph_vxattrcb_layout()
78 ci->i_layout.stripe_unit, ci->i_layout.stripe_count, in ceph_vxattrcb_layout()
79 ci->i_layout.object_size); in ceph_vxattrcb_layout()
84 ci->i_layout.stripe_unit, ci->i_layout.stripe_count, in ceph_vxattrcb_layout()
85 ci->i_layout.object_size, pool); in ceph_vxattrcb_layout()
142 static ssize_t ceph_vxattrcb_layout_stripe_unit(struct ceph_inode_info *ci, in ceph_vxattrcb_layout_stripe_unit() argument
145 return ceph_fmt_xattr(val, size, "%u", ci->i_layout.stripe_unit); in ceph_vxattrcb_layout_stripe_unit()
148 static ssize_t ceph_vxattrcb_layout_stripe_count(struct ceph_inode_info *ci, in ceph_vxattrcb_layout_stripe_count() argument
151 return ceph_fmt_xattr(val, size, "%u", ci->i_layout.stripe_count); in ceph_vxattrcb_layout_stripe_count()
154 static ssize_t ceph_vxattrcb_layout_object_size(struct ceph_inode_info *ci, in ceph_vxattrcb_layout_object_size() argument
157 return ceph_fmt_xattr(val, size, "%u", ci->i_layout.object_size); in ceph_vxattrcb_layout_object_size()
160 static ssize_t ceph_vxattrcb_layout_pool(struct ceph_inode_info *ci, in ceph_vxattrcb_layout_pool() argument
164 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->netfs.inode.i_sb); in ceph_vxattrcb_layout_pool()
166 s64 pool = ci->i_layout.pool_id; in ceph_vxattrcb_layout_pool()
182 static ssize_t ceph_vxattrcb_layout_pool_namespace(struct ceph_inode_info *ci, in ceph_vxattrcb_layout_pool_namespace() argument
186 struct ceph_string *ns = ceph_try_get_string(ci->i_layout.pool_ns); in ceph_vxattrcb_layout_pool_namespace()
199 static ssize_t ceph_vxattrcb_dir_entries(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_dir_entries() argument
202 return ceph_fmt_xattr(val, size, "%lld", ci->i_files + ci->i_subdirs); in ceph_vxattrcb_dir_entries()
205 static ssize_t ceph_vxattrcb_dir_files(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_dir_files() argument
208 return ceph_fmt_xattr(val, size, "%lld", ci->i_files); in ceph_vxattrcb_dir_files()
211 static ssize_t ceph_vxattrcb_dir_subdirs(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_dir_subdirs() argument
214 return ceph_fmt_xattr(val, size, "%lld", ci->i_subdirs); in ceph_vxattrcb_dir_subdirs()
217 static ssize_t ceph_vxattrcb_dir_rentries(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_dir_rentries() argument
221 ci->i_rfiles + ci->i_rsubdirs); in ceph_vxattrcb_dir_rentries()
224 static ssize_t ceph_vxattrcb_dir_rfiles(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_dir_rfiles() argument
227 return ceph_fmt_xattr(val, size, "%lld", ci->i_rfiles); in ceph_vxattrcb_dir_rfiles()
230 static ssize_t ceph_vxattrcb_dir_rsubdirs(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_dir_rsubdirs() argument
233 return ceph_fmt_xattr(val, size, "%lld", ci->i_rsubdirs); in ceph_vxattrcb_dir_rsubdirs()
236 static ssize_t ceph_vxattrcb_dir_rsnaps(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_dir_rsnaps() argument
239 return ceph_fmt_xattr(val, size, "%lld", ci->i_rsnaps); in ceph_vxattrcb_dir_rsnaps()
242 static ssize_t ceph_vxattrcb_dir_rbytes(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_dir_rbytes() argument
245 return ceph_fmt_xattr(val, size, "%lld", ci->i_rbytes); in ceph_vxattrcb_dir_rbytes()
248 static ssize_t ceph_vxattrcb_dir_rctime(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_dir_rctime() argument
251 return ceph_fmt_xattr(val, size, "%lld.%09ld", ci->i_rctime.tv_sec, in ceph_vxattrcb_dir_rctime()
252 ci->i_rctime.tv_nsec); in ceph_vxattrcb_dir_rctime()
256 static bool ceph_vxattrcb_dir_pin_exists(struct ceph_inode_info *ci) in ceph_vxattrcb_dir_pin_exists() argument
258 return ci->i_dir_pin != -ENODATA; in ceph_vxattrcb_dir_pin_exists()
261 static ssize_t ceph_vxattrcb_dir_pin(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_dir_pin() argument
264 return ceph_fmt_xattr(val, size, "%d", (int)ci->i_dir_pin); in ceph_vxattrcb_dir_pin()
268 static bool ceph_vxattrcb_quota_exists(struct ceph_inode_info *ci) in ceph_vxattrcb_quota_exists() argument
271 spin_lock(&ci->i_ceph_lock); in ceph_vxattrcb_quota_exists()
272 if ((ci->i_max_files || ci->i_max_bytes) && in ceph_vxattrcb_quota_exists()
273 ci->i_vino.snap == CEPH_NOSNAP && in ceph_vxattrcb_quota_exists()
274 ci->i_snap_realm && in ceph_vxattrcb_quota_exists()
275 ci->i_snap_realm->ino == ci->i_vino.ino) in ceph_vxattrcb_quota_exists()
277 spin_unlock(&ci->i_ceph_lock); in ceph_vxattrcb_quota_exists()
281 static ssize_t ceph_vxattrcb_quota(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_quota() argument
285 ci->i_max_bytes, ci->i_max_files); in ceph_vxattrcb_quota()
288 static ssize_t ceph_vxattrcb_quota_max_bytes(struct ceph_inode_info *ci, in ceph_vxattrcb_quota_max_bytes() argument
291 return ceph_fmt_xattr(val, size, "%llu", ci->i_max_bytes); in ceph_vxattrcb_quota_max_bytes()
294 static ssize_t ceph_vxattrcb_quota_max_files(struct ceph_inode_info *ci, in ceph_vxattrcb_quota_max_files() argument
297 return ceph_fmt_xattr(val, size, "%llu", ci->i_max_files); in ceph_vxattrcb_quota_max_files()
301 static bool ceph_vxattrcb_snap_btime_exists(struct ceph_inode_info *ci) in ceph_vxattrcb_snap_btime_exists() argument
303 return (ci->i_snap_btime.tv_sec != 0 || ci->i_snap_btime.tv_nsec != 0); in ceph_vxattrcb_snap_btime_exists()
306 static ssize_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_snap_btime() argument
309 return ceph_fmt_xattr(val, size, "%lld.%09ld", ci->i_snap_btime.tv_sec, in ceph_vxattrcb_snap_btime()
310 ci->i_snap_btime.tv_nsec); in ceph_vxattrcb_snap_btime()
313 static ssize_t ceph_vxattrcb_cluster_fsid(struct ceph_inode_info *ci, in ceph_vxattrcb_cluster_fsid() argument
316 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->netfs.inode.i_sb); in ceph_vxattrcb_cluster_fsid()
321 static ssize_t ceph_vxattrcb_client_id(struct ceph_inode_info *ci, in ceph_vxattrcb_client_id() argument
324 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->netfs.inode.i_sb); in ceph_vxattrcb_client_id()
330 static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val, in ceph_vxattrcb_caps() argument
335 spin_lock(&ci->i_ceph_lock); in ceph_vxattrcb_caps()
336 issued = __ceph_caps_issued(ci, NULL); in ceph_vxattrcb_caps()
337 spin_unlock(&ci->i_ceph_lock); in ceph_vxattrcb_caps()
343 static ssize_t ceph_vxattrcb_auth_mds(struct ceph_inode_info *ci, in ceph_vxattrcb_auth_mds() argument
348 spin_lock(&ci->i_ceph_lock); in ceph_vxattrcb_auth_mds()
350 ci->i_auth_cap ? ci->i_auth_cap->session->s_mds : -1); in ceph_vxattrcb_auth_mds()
351 spin_unlock(&ci->i_ceph_lock); in ceph_vxattrcb_auth_mds()
356 static bool ceph_vxattrcb_fscrypt_auth_exists(struct ceph_inode_info *ci) in ceph_vxattrcb_fscrypt_auth_exists() argument
358 return ci->fscrypt_auth_len; in ceph_vxattrcb_fscrypt_auth_exists()
361 static ssize_t ceph_vxattrcb_fscrypt_auth(struct ceph_inode_info *ci, in ceph_vxattrcb_fscrypt_auth() argument
365 if (size < ci->fscrypt_auth_len) in ceph_vxattrcb_fscrypt_auth()
367 memcpy(val, ci->fscrypt_auth, ci->fscrypt_auth_len); in ceph_vxattrcb_fscrypt_auth()
369 return ci->fscrypt_auth_len; in ceph_vxattrcb_fscrypt_auth()
567 static int __set_xattr(struct ceph_inode_info *ci, in __set_xattr() argument
579 p = &ci->i_xattrs.index.rb_node; in __set_xattr()
614 __remove_xattr(ci, xattr); in __set_xattr()
628 ci->i_xattrs.count++; in __set_xattr()
629 dout("%s count=%d\n", __func__, ci->i_xattrs.count); in __set_xattr()
640 ci->i_xattrs.names_size -= xattr->name_len; in __set_xattr()
641 ci->i_xattrs.vals_size -= xattr->val_len; in __set_xattr()
643 ci->i_xattrs.names_size += name_len; in __set_xattr()
644 ci->i_xattrs.vals_size += val_len; in __set_xattr()
656 rb_insert_color(&xattr->node, &ci->i_xattrs.index); in __set_xattr()
661 ceph_vinop(&ci->netfs.inode), xattr, name_len, name, in __set_xattr()
668 static struct ceph_inode_xattr *__get_xattr(struct ceph_inode_info *ci, in __get_xattr() argument
677 p = &ci->i_xattrs.index.rb_node; in __get_xattr()
714 static int __remove_xattr(struct ceph_inode_info *ci, in __remove_xattr() argument
720 rb_erase(&xattr->node, &ci->i_xattrs.index); in __remove_xattr()
727 ci->i_xattrs.names_size -= xattr->name_len; in __remove_xattr()
728 ci->i_xattrs.vals_size -= xattr->val_len; in __remove_xattr()
729 ci->i_xattrs.count--; in __remove_xattr()
735 static char *__copy_xattr_names(struct ceph_inode_info *ci, in __copy_xattr_names() argument
741 p = rb_first(&ci->i_xattrs.index); in __copy_xattr_names()
742 dout("__copy_xattr_names count=%d\n", ci->i_xattrs.count); in __copy_xattr_names()
750 xattr->name_len, ci->i_xattrs.names_size); in __copy_xattr_names()
759 void __ceph_destroy_xattrs(struct ceph_inode_info *ci) in __ceph_destroy_xattrs() argument
764 p = rb_first(&ci->i_xattrs.index); in __ceph_destroy_xattrs()
774 rb_erase(tmp, &ci->i_xattrs.index); in __ceph_destroy_xattrs()
779 ci->i_xattrs.names_size = 0; in __ceph_destroy_xattrs()
780 ci->i_xattrs.vals_size = 0; in __ceph_destroy_xattrs()
781 ci->i_xattrs.index_version = 0; in __ceph_destroy_xattrs()
782 ci->i_xattrs.count = 0; in __ceph_destroy_xattrs()
783 ci->i_xattrs.index = RB_ROOT; in __ceph_destroy_xattrs()
787 __releases(ci->i_ceph_lock) in __build_xattrs()
788 __acquires(ci->i_ceph_lock) in __build_xattrs()
795 struct ceph_inode_info *ci = ceph_inode(inode); in __build_xattrs() local
802 ci->i_xattrs.blob ? (int)ci->i_xattrs.blob->vec.iov_len : 0); in __build_xattrs()
804 if (ci->i_xattrs.index_version >= ci->i_xattrs.version) in __build_xattrs()
807 __ceph_destroy_xattrs(ci); in __build_xattrs()
811 if (ci->i_xattrs.blob && ci->i_xattrs.blob->vec.iov_len > 4) { in __build_xattrs()
812 p = ci->i_xattrs.blob->vec.iov_base; in __build_xattrs()
813 end = p + ci->i_xattrs.blob->vec.iov_len; in __build_xattrs()
815 xattr_version = ci->i_xattrs.version; in __build_xattrs()
816 spin_unlock(&ci->i_ceph_lock); in __build_xattrs()
831 spin_lock(&ci->i_ceph_lock); in __build_xattrs()
832 if (ci->i_xattrs.version != xattr_version) { in __build_xattrs()
850 err = __set_xattr(ci, name, namelen, val, len, in __build_xattrs()
858 ci->i_xattrs.index_version = ci->i_xattrs.version; in __build_xattrs()
859 ci->i_xattrs.dirty = false; in __build_xattrs()
863 spin_lock(&ci->i_ceph_lock); in __build_xattrs()
870 ci->i_xattrs.names_size = 0; in __build_xattrs()
874 static int __get_required_blob_size(struct ceph_inode_info *ci, int name_size, in __get_required_blob_size() argument
881 int size = 4 + ci->i_xattrs.count*(4 + 4) + in __get_required_blob_size()
882 ci->i_xattrs.names_size + in __get_required_blob_size()
883 ci->i_xattrs.vals_size; in __get_required_blob_size()
885 ci->i_xattrs.count, ci->i_xattrs.names_size, in __get_required_blob_size()
886 ci->i_xattrs.vals_size); in __get_required_blob_size()
900 struct ceph_buffer *__ceph_build_xattrs_blob(struct ceph_inode_info *ci) in __ceph_build_xattrs_blob() argument
907 dout("__build_xattrs_blob %p\n", &ci->netfs.inode); in __ceph_build_xattrs_blob()
908 if (ci->i_xattrs.dirty) { in __ceph_build_xattrs_blob()
909 int need = __get_required_blob_size(ci, 0, 0); in __ceph_build_xattrs_blob()
911 BUG_ON(need > ci->i_xattrs.prealloc_blob->alloc_len); in __ceph_build_xattrs_blob()
913 p = rb_first(&ci->i_xattrs.index); in __ceph_build_xattrs_blob()
914 dest = ci->i_xattrs.prealloc_blob->vec.iov_base; in __ceph_build_xattrs_blob()
916 ceph_encode_32(&dest, ci->i_xattrs.count); in __ceph_build_xattrs_blob()
931 ci->i_xattrs.prealloc_blob->vec.iov_len = in __ceph_build_xattrs_blob()
932 dest - ci->i_xattrs.prealloc_blob->vec.iov_base; in __ceph_build_xattrs_blob()
934 if (ci->i_xattrs.blob) in __ceph_build_xattrs_blob()
935 old_blob = ci->i_xattrs.blob; in __ceph_build_xattrs_blob()
936 ci->i_xattrs.blob = ci->i_xattrs.prealloc_blob; in __ceph_build_xattrs_blob()
937 ci->i_xattrs.prealloc_blob = NULL; in __ceph_build_xattrs_blob()
938 ci->i_xattrs.dirty = false; in __ceph_build_xattrs_blob()
939 ci->i_xattrs.version++; in __ceph_build_xattrs_blob()
965 struct ceph_inode_info *ci = ceph_inode(inode); in __ceph_getxattr() local
986 if (!(vxattr->exists_cb && !vxattr->exists_cb(ci))) { in __ceph_getxattr()
987 err = vxattr->getxattr_cb(ci, value, size); in __ceph_getxattr()
1002 spin_lock(&ci->i_ceph_lock); in __ceph_getxattr()
1004 ci->i_xattrs.version, ci->i_xattrs.index_version); in __ceph_getxattr()
1006 if (ci->i_xattrs.version == 0 || in __ceph_getxattr()
1008 __ceph_caps_issued_mask_metric(ci, CEPH_CAP_XATTR_SHARED, 1))) { in __ceph_getxattr()
1009 spin_unlock(&ci->i_ceph_lock); in __ceph_getxattr()
1022 spin_lock(&ci->i_ceph_lock); in __ceph_getxattr()
1030 xattr = __get_xattr(ci, name); in __ceph_getxattr()
1047 ci->i_ceph_flags |= CEPH_I_SEC_INITED; in __ceph_getxattr()
1049 spin_unlock(&ci->i_ceph_lock); in __ceph_getxattr()
1056 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_listxattr() local
1061 spin_lock(&ci->i_ceph_lock); in ceph_listxattr()
1063 ci->i_xattrs.version, ci->i_xattrs.index_version); in ceph_listxattr()
1065 if (ci->i_xattrs.version == 0 || in ceph_listxattr()
1066 !__ceph_caps_issued_mask_metric(ci, CEPH_CAP_XATTR_SHARED, 1)) { in ceph_listxattr()
1067 spin_unlock(&ci->i_ceph_lock); in ceph_listxattr()
1071 spin_lock(&ci->i_ceph_lock); in ceph_listxattr()
1079 namelen = ci->i_xattrs.names_size + ci->i_xattrs.count; in ceph_listxattr()
1085 names = __copy_xattr_names(ci, names); in ceph_listxattr()
1090 spin_unlock(&ci->i_ceph_lock); in ceph_listxattr()
1098 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_sync_setxattr() local
1151 dout("xattr.ver (before): %lld\n", ci->i_xattrs.version); in ceph_sync_setxattr()
1154 dout("xattr.ver (after): %lld\n", ci->i_xattrs.version); in ceph_sync_setxattr()
1166 struct ceph_inode_info *ci = ceph_inode(inode); in __ceph_setxattr() local
1217 spin_lock(&ci->i_ceph_lock); in __ceph_setxattr()
1219 issued = __ceph_caps_issued(ci, NULL); in __ceph_setxattr()
1220 required_blob_size = __get_required_blob_size(ci, name_len, val_len); in __ceph_setxattr()
1221 if ((ci->i_xattrs.version == 0) || !(issued & CEPH_CAP_XATTR_EXCL) || in __ceph_setxattr()
1224 __func__, ci->i_xattrs.version, required_blob_size, in __ceph_setxattr()
1229 if (!lock_snap_rwsem && !ci->i_head_snapc) { in __ceph_setxattr()
1232 spin_unlock(&ci->i_ceph_lock); in __ceph_setxattr()
1234 spin_lock(&ci->i_ceph_lock); in __ceph_setxattr()
1243 if (!ci->i_xattrs.prealloc_blob || in __ceph_setxattr()
1244 required_blob_size > ci->i_xattrs.prealloc_blob->alloc_len) { in __ceph_setxattr()
1247 spin_unlock(&ci->i_ceph_lock); in __ceph_setxattr()
1253 spin_lock(&ci->i_ceph_lock); in __ceph_setxattr()
1255 if (ci->i_xattrs.prealloc_blob) in __ceph_setxattr()
1256 old_blob = ci->i_xattrs.prealloc_blob; in __ceph_setxattr()
1257 ci->i_xattrs.prealloc_blob = blob; in __ceph_setxattr()
1261 err = __set_xattr(ci, newname, name_len, newval, val_len, in __ceph_setxattr()
1265 dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL, in __ceph_setxattr()
1267 ci->i_xattrs.dirty = true; in __ceph_setxattr()
1271 spin_unlock(&ci->i_ceph_lock); in __ceph_setxattr()
1281 spin_unlock(&ci->i_ceph_lock); in __ceph_setxattr()
1295 spin_lock(&ci->i_ceph_lock); in __ceph_setxattr()
1296 if ((ci->i_max_files || ci->i_max_bytes) && in __ceph_setxattr()
1297 !(ci->i_snap_realm && in __ceph_setxattr()
1298 ci->i_snap_realm->ino == ci->i_vino.ino)) in __ceph_setxattr()
1300 spin_unlock(&ci->i_ceph_lock); in __ceph_setxattr()
1345 struct ceph_inode_info *ci; in ceph_security_xattr_deadlock() local
1349 ci = ceph_inode(in); in ceph_security_xattr_deadlock()
1350 spin_lock(&ci->i_ceph_lock); in ceph_security_xattr_deadlock()
1351 ret = !(ci->i_ceph_flags & CEPH_I_SEC_INITED) && in ceph_security_xattr_deadlock()
1352 !(ci->i_xattrs.version > 0 && in ceph_security_xattr_deadlock()
1353 __ceph_caps_issued_mask(ci, CEPH_CAP_XATTR_SHARED, 0)); in ceph_security_xattr_deadlock()
1354 spin_unlock(&ci->i_ceph_lock); in ceph_security_xattr_deadlock()