Lines Matching +full:dout +full:- +full:default +full:- +full:2
1 // SPDX-License-Identifier: GPL-2.0
22 * specific inode (e.g., a getattr due to fstat(2)), or as a path
42 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dentry->d_sb); in ceph_d_init()
46 return -ENOMEM; /* oh well */ in ceph_d_init()
48 di->dentry = dentry; in ceph_d_init()
49 di->lease_session = NULL; in ceph_d_init()
50 di->time = jiffies; in ceph_d_init()
51 dentry->d_fsdata = di; in ceph_d_init()
52 INIT_LIST_HEAD(&di->lease_list); in ceph_d_init()
54 atomic64_inc(&mdsc->metric.total_dentries); in ceph_d_init()
61 * - hash order:
64 * - frag+name order;
68 #define OFFSET_MASK ((1 << OFFSET_BITS) - 1)
103 return (int)(fpos_off(l) - fpos_off(r)); in fpos_cmp()
117 return -ENOMEM; in note_last_dentry()
118 kfree(dfi->last_name); in note_last_dentry()
119 dfi->last_name = buf; in note_last_dentry()
120 memcpy(dfi->last_name, name, len); in note_last_dentry()
121 dfi->last_name[len] = 0; in note_last_dentry()
122 dfi->next_offset = next_offset; in note_last_dentry()
123 dout("note_last_dentry '%s'\n", dfi->last_name); in note_last_dentry()
134 unsigned idx_mask = (PAGE_SIZE / sizeof(struct dentry *)) - 1; in __dcache_find_get_entry()
141 if (!cache_ctl->page || ptr_pgoff != page_index(cache_ctl->page)) { in __dcache_find_get_entry()
143 cache_ctl->page = find_lock_page(&dir->i_data, ptr_pgoff); in __dcache_find_get_entry()
144 if (!cache_ctl->page) { in __dcache_find_get_entry()
145 dout(" page %lu not found\n", ptr_pgoff); in __dcache_find_get_entry()
146 return ERR_PTR(-EAGAIN); in __dcache_find_get_entry()
150 unlock_page(cache_ctl->page); in __dcache_find_get_entry()
151 cache_ctl->dentries = kmap(cache_ctl->page); in __dcache_find_get_entry()
154 cache_ctl->index = idx & idx_mask; in __dcache_find_get_entry()
157 spin_lock(&parent->d_lock); in __dcache_find_get_entry()
161 dentry = cache_ctl->dentries[cache_ctl->index]; in __dcache_find_get_entry()
164 spin_unlock(&parent->d_lock); in __dcache_find_get_entry()
165 if (dentry && !lockref_get_not_dead(&dentry->d_lockref)) in __dcache_find_get_entry()
168 return dentry ? : ERR_PTR(-EAGAIN); in __dcache_find_get_entry()
185 struct ceph_dir_file_info *dfi = file->private_data; in __dcache_readdir()
186 struct dentry *parent = file->f_path.dentry; in __dcache_readdir()
194 dout("__dcache_readdir %p v%u at %llx\n", dir, (unsigned)shared_gen, ctx->pos); in __dcache_readdir()
197 if (ctx->pos > 2) { in __dcache_readdir()
213 spin_lock(&dentry->d_lock); in __dcache_readdir()
214 if (fpos_cmp(di->offset, ctx->pos) < 0) { in __dcache_readdir()
216 count -= step + 1; in __dcache_readdir()
220 spin_unlock(&dentry->d_lock); in __dcache_readdir()
224 dout("__dcache_readdir %p cache idx %llu\n", dir, idx); in __dcache_readdir()
232 dfi->file_info.flags |= CEPH_F_ATEND; in __dcache_readdir()
241 spin_lock(&dentry->d_lock); in __dcache_readdir()
245 di->lease_shared_gen != shared_gen || in __dcache_readdir()
246 ((dentry->d_flags & DCACHE_NOKEY_NAME) && in __dcache_readdir()
248 spin_unlock(&dentry->d_lock); in __dcache_readdir()
250 err = -EAGAIN; in __dcache_readdir()
253 if (fpos_cmp(ctx->pos, di->offset) <= 0) { in __dcache_readdir()
257 spin_unlock(&dentry->d_lock); in __dcache_readdir()
260 dout(" %llx dentry %p %pd %p\n", di->offset, in __dcache_readdir()
262 ctx->pos = di->offset; in __dcache_readdir()
263 if (!dir_emit(ctx, dentry->d_name.name, in __dcache_readdir()
264 dentry->d_name.len, ceph_present_inode(d_inode(dentry)), in __dcache_readdir()
265 d_inode(dentry)->i_mode >> 12)) { in __dcache_readdir()
270 ctx->pos++; in __dcache_readdir()
284 ret = note_last_dentry(dfi, last->d_name.name, last->d_name.len, in __dcache_readdir()
285 fpos_off(di->offset) + 1); in __dcache_readdir()
290 if (dfi->readdir_cache_idx >= 0) { in __dcache_readdir()
291 dfi->readdir_cache_idx = -1; in __dcache_readdir()
292 dfi->dir_release_count = 0; in __dcache_readdir()
300 if (!dfi->last_readdir) in need_send_readdir()
303 return !ceph_frag_contains_value(dfi->frag, fpos_hash(pos)); in need_send_readdir()
305 return dfi->frag != fpos_frag(pos); in need_send_readdir()
310 struct ceph_dir_file_info *dfi = file->private_data; in ceph_readdir()
314 struct ceph_mds_client *mdsc = fsc->mdsc; in ceph_readdir()
317 unsigned frag = -1; in ceph_readdir()
320 dout("readdir %p file %p pos %llx\n", inode, file, ctx->pos); in ceph_readdir()
321 if (dfi->file_info.flags & CEPH_F_ATEND) in ceph_readdir()
325 if (ctx->pos == 0) { in ceph_readdir()
326 dout("readdir off 0 -> '.'\n"); in ceph_readdir()
328 inode->i_mode >> 12)) in ceph_readdir()
330 ctx->pos = 1; in ceph_readdir()
332 if (ctx->pos == 1) { in ceph_readdir()
334 struct dentry *dentry = file->f_path.dentry; in ceph_readdir()
336 spin_lock(&dentry->d_lock); in ceph_readdir()
337 ino = ceph_present_inode(dentry->d_parent->d_inode); in ceph_readdir()
338 spin_unlock(&dentry->d_lock); in ceph_readdir()
340 dout("readdir off 1 -> '..'\n"); in ceph_readdir()
341 if (!dir_emit(ctx, "..", 2, ino, inode->i_mode >> 12)) in ceph_readdir()
343 ctx->pos = 2; in ceph_readdir()
350 spin_lock(&ci->i_ceph_lock); in ceph_readdir()
360 int shared_gen = atomic_read(&ci->i_shared_gen); in ceph_readdir()
362 spin_unlock(&ci->i_ceph_lock); in ceph_readdir()
364 if (err != -EAGAIN) in ceph_readdir()
367 spin_unlock(&ci->i_ceph_lock); in ceph_readdir()
373 if (need_send_readdir(dfi, ctx->pos)) { in ceph_readdir()
379 if (dfi->last_readdir) { in ceph_readdir()
380 ceph_mdsc_put_request(dfi->last_readdir); in ceph_readdir()
381 dfi->last_readdir = NULL; in ceph_readdir()
384 if (is_hash_order(ctx->pos)) { in ceph_readdir()
387 if (frag == (unsigned)-1) in ceph_readdir()
388 frag = ceph_choose_frag(ci, fpos_hash(ctx->pos), in ceph_readdir()
391 frag = fpos_frag(ctx->pos); in ceph_readdir()
394 dout("readdir fetching %llx.%llx frag %x offset '%s'\n", in ceph_readdir()
395 ceph_vinop(inode), frag, dfi->last_name); in ceph_readdir()
405 /* hints to request -> mds selection code */ in ceph_readdir()
406 req->r_direct_mode = USE_AUTH_MDS; in ceph_readdir()
408 req->r_direct_hash = ceph_frag_value(frag); in ceph_readdir()
409 __set_bit(CEPH_MDS_R_DIRECT_IS_HASH, &req->r_req_flags); in ceph_readdir()
410 req->r_inode_drop = CEPH_CAP_FILE_EXCL; in ceph_readdir()
412 if (dfi->last_name) { in ceph_readdir()
413 struct qstr d_name = { .name = dfi->last_name, in ceph_readdir()
414 .len = strlen(dfi->last_name) }; in ceph_readdir()
416 req->r_path2 = kzalloc(NAME_MAX + 1, GFP_KERNEL); in ceph_readdir()
417 if (!req->r_path2) { in ceph_readdir()
419 return -ENOMEM; in ceph_readdir()
423 req->r_path2); in ceph_readdir()
428 } else if (is_hash_order(ctx->pos)) { in ceph_readdir()
429 req->r_args.readdir.offset_hash = in ceph_readdir()
430 cpu_to_le32(fpos_hash(ctx->pos)); in ceph_readdir()
433 req->r_dir_release_cnt = dfi->dir_release_count; in ceph_readdir()
434 req->r_dir_ordered_cnt = dfi->dir_ordered_count; in ceph_readdir()
435 req->r_readdir_cache_idx = dfi->readdir_cache_idx; in ceph_readdir()
436 req->r_readdir_offset = dfi->next_offset; in ceph_readdir()
437 req->r_args.readdir.frag = cpu_to_le32(frag); in ceph_readdir()
438 req->r_args.readdir.flags = in ceph_readdir()
441 req->r_inode = inode; in ceph_readdir()
443 req->r_dentry = dget(file->f_path.dentry); in ceph_readdir()
449 dout("readdir got and parsed readdir result=%d on " in ceph_readdir()
452 (int)req->r_reply_info.dir_end, in ceph_readdir()
453 (int)req->r_reply_info.dir_complete, in ceph_readdir()
454 (int)req->r_reply_info.hash_order); in ceph_readdir()
456 rinfo = &req->r_reply_info; in ceph_readdir()
457 if (le32_to_cpu(rinfo->dir_dir->frag) != frag) { in ceph_readdir()
458 frag = le32_to_cpu(rinfo->dir_dir->frag); in ceph_readdir()
459 if (!rinfo->hash_order) { in ceph_readdir()
460 dfi->next_offset = req->r_readdir_offset; in ceph_readdir()
461 /* adjust ctx->pos to beginning of frag */ in ceph_readdir()
462 ctx->pos = ceph_make_fpos(frag, in ceph_readdir()
463 dfi->next_offset, in ceph_readdir()
468 dfi->frag = frag; in ceph_readdir()
469 dfi->last_readdir = req; in ceph_readdir()
471 if (test_bit(CEPH_MDS_R_DID_PREPOPULATE, &req->r_req_flags)) { in ceph_readdir()
472 dfi->readdir_cache_idx = req->r_readdir_cache_idx; in ceph_readdir()
473 if (dfi->readdir_cache_idx < 0) { in ceph_readdir()
475 dfi->dir_ordered_count = 0; in ceph_readdir()
477 dfi->next_offset == 2) { in ceph_readdir()
480 dfi->dir_release_count = req->r_dir_release_cnt; in ceph_readdir()
481 dfi->dir_ordered_count = req->r_dir_ordered_cnt; in ceph_readdir()
484 dout("readdir !did_prepopulate\n"); in ceph_readdir()
486 dfi->readdir_cache_idx = -1; in ceph_readdir()
488 dfi->dir_release_count = 0; in ceph_readdir()
492 if (rinfo->dir_nr > 0) { in ceph_readdir()
494 rinfo->dir_entries + (rinfo->dir_nr-1); in ceph_readdir()
495 unsigned next_offset = req->r_reply_info.dir_end ? in ceph_readdir()
496 2 : (fpos_off(rde->offset) + 1); in ceph_readdir()
497 err = note_last_dentry(dfi, rde->name, rde->name_len, in ceph_readdir()
500 ceph_mdsc_put_request(dfi->last_readdir); in ceph_readdir()
501 dfi->last_readdir = NULL; in ceph_readdir()
504 } else if (req->r_reply_info.dir_end) { in ceph_readdir()
505 dfi->next_offset = 2; in ceph_readdir()
510 rinfo = &dfi->last_readdir->r_reply_info; in ceph_readdir()
511 dout("readdir frag %x num %d pos %llx chunk first %llx\n", in ceph_readdir()
512 dfi->frag, rinfo->dir_nr, ctx->pos, in ceph_readdir()
513 rinfo->dir_nr ? rinfo->dir_entries[0].offset : 0LL); in ceph_readdir()
517 if (rinfo->dir_nr > 0) { in ceph_readdir()
518 int step, nr = rinfo->dir_nr; in ceph_readdir()
521 if (rinfo->dir_entries[i + step].offset < ctx->pos) { in ceph_readdir()
523 nr -= step + 1; in ceph_readdir()
529 for (; i < rinfo->dir_nr; i++) { in ceph_readdir()
530 struct ceph_mds_reply_dir_entry *rde = rinfo->dir_entries + i; in ceph_readdir()
532 if (rde->offset < ctx->pos) { in ceph_readdir()
533 pr_warn("%s: rde->offset 0x%llx ctx->pos 0x%llx\n", in ceph_readdir()
534 __func__, rde->offset, ctx->pos); in ceph_readdir()
535 return -EIO; in ceph_readdir()
538 if (WARN_ON_ONCE(!rde->inode.in)) in ceph_readdir()
539 return -EIO; in ceph_readdir()
541 ctx->pos = rde->offset; in ceph_readdir()
542 dout("readdir (%d/%d) -> %llx '%.*s' %p\n", in ceph_readdir()
543 i, rinfo->dir_nr, ctx->pos, in ceph_readdir()
544 rde->name_len, rde->name, &rde->inode.in); in ceph_readdir()
546 if (!dir_emit(ctx, rde->name, rde->name_len, in ceph_readdir()
547 ceph_present_ino(inode->i_sb, le64_to_cpu(rde->inode.in->ino)), in ceph_readdir()
548 le32_to_cpu(rde->inode.in->mode) >> 12)) { in ceph_readdir()
550 * NOTE: Here no need to put the 'dfi->last_readdir', in ceph_readdir()
555 dout("filldir stopping us...\n"); in ceph_readdir()
560 ctx->pos++; in ceph_readdir()
563 ceph_mdsc_put_request(dfi->last_readdir); in ceph_readdir()
564 dfi->last_readdir = NULL; in ceph_readdir()
566 if (dfi->next_offset > 2) { in ceph_readdir()
567 frag = dfi->frag; in ceph_readdir()
572 if (!ceph_frag_is_rightmost(dfi->frag)) { in ceph_readdir()
573 frag = ceph_frag_next(dfi->frag); in ceph_readdir()
574 if (is_hash_order(ctx->pos)) { in ceph_readdir()
576 dfi->next_offset, true); in ceph_readdir()
577 if (new_pos > ctx->pos) in ceph_readdir()
578 ctx->pos = new_pos; in ceph_readdir()
581 ctx->pos = ceph_make_fpos(frag, dfi->next_offset, in ceph_readdir()
583 kfree(dfi->last_name); in ceph_readdir()
584 dfi->last_name = NULL; in ceph_readdir()
586 dout("readdir next frag is %x\n", frag); in ceph_readdir()
589 dfi->file_info.flags |= CEPH_F_ATEND; in ceph_readdir()
596 if (atomic64_read(&ci->i_release_count) == in ceph_readdir()
597 dfi->dir_release_count) { in ceph_readdir()
598 spin_lock(&ci->i_ceph_lock); in ceph_readdir()
599 if (dfi->dir_ordered_count == in ceph_readdir()
600 atomic64_read(&ci->i_ordered_count)) { in ceph_readdir()
601 dout(" marking %p complete and ordered\n", inode); in ceph_readdir()
604 BUG_ON(dfi->readdir_cache_idx < 0); in ceph_readdir()
605 i_size_write(inode, dfi->readdir_cache_idx * in ceph_readdir()
608 dout(" marking %p complete\n", inode); in ceph_readdir()
610 __ceph_dir_set_complete(ci, dfi->dir_release_count, in ceph_readdir()
611 dfi->dir_ordered_count); in ceph_readdir()
612 spin_unlock(&ci->i_ceph_lock); in ceph_readdir()
614 dout("readdir %p file %p done.\n", inode, file); in ceph_readdir()
620 if (dfi->last_readdir) { in reset_readdir()
621 ceph_mdsc_put_request(dfi->last_readdir); in reset_readdir()
622 dfi->last_readdir = NULL; in reset_readdir()
624 kfree(dfi->last_name); in reset_readdir()
625 dfi->last_name = NULL; in reset_readdir()
626 dfi->dir_release_count = 0; in reset_readdir()
627 dfi->readdir_cache_idx = -1; in reset_readdir()
628 dfi->next_offset = 2; /* compensate for . and .. */ in reset_readdir()
629 dfi->file_info.flags &= ~CEPH_F_ATEND; in reset_readdir()
645 } else if (dfi->frag != fpos_frag(new_pos)) { in need_reset_readdir()
648 rinfo = dfi->last_readdir ? &dfi->last_readdir->r_reply_info : NULL; in need_reset_readdir()
649 if (!rinfo || !rinfo->dir_nr) in need_reset_readdir()
651 chunk_offset = rinfo->dir_entries[0].offset; in need_reset_readdir()
658 struct ceph_dir_file_info *dfi = file->private_data; in ceph_dir_llseek()
659 struct inode *inode = file->f_mapping->host; in ceph_dir_llseek()
663 retval = -EINVAL; in ceph_dir_llseek()
666 offset += file->f_pos; in ceph_dir_llseek()
671 retval = -EOPNOTSUPP; in ceph_dir_llseek()
673 default: in ceph_dir_llseek()
679 dout("dir_llseek dropping %p content\n", file); in ceph_dir_llseek()
681 } else if (is_hash_order(offset) && offset > file->f_pos) { in ceph_dir_llseek()
684 dfi->dir_release_count = 0; in ceph_dir_llseek()
685 dfi->readdir_cache_idx = -1; in ceph_dir_llseek()
688 if (offset != file->f_pos) { in ceph_dir_llseek()
689 file->f_pos = offset; in ceph_dir_llseek()
690 file->f_version = 0; in ceph_dir_llseek()
691 dfi->file_info.flags &= ~CEPH_F_ATEND; in ceph_dir_llseek()
706 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dentry->d_sb); in ceph_handle_snapdir()
707 struct inode *parent = d_inode(dentry->d_parent); /* we hold i_rwsem */ in ceph_handle_snapdir()
711 strcmp(dentry->d_name.name, fsc->mount_options->snapdir_name) == 0) { in ceph_handle_snapdir()
716 dout("ENOENT on snapdir %p '%pd', linking to snapdir %p. Spliced dentry %p\n", in ceph_handle_snapdir()
727 * Mainly, make sure we return the final req->r_dentry (if it already
728 * existed) in place of the original VFS-provided dentry when they
731 * Gracefully handle the case where the MDS replies with -ENOENT and
738 if (err == -ENOENT) { in ceph_finish_lookup()
741 if (!req->r_reply_info.head->is_dentry) { in ceph_finish_lookup()
742 dout("ENOENT and no trace, dentry %p inode %p\n", in ceph_finish_lookup()
746 err = -ENOENT; in ceph_finish_lookup()
754 else if (dentry != req->r_dentry) in ceph_finish_lookup()
755 dentry = dget(req->r_dentry); /* we got spliced */ in ceph_finish_lookup()
764 strncmp(dentry->d_name.name, ".ceph", 5) == 0; in is_root_ceph_dentry()
774 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dir->i_sb); in ceph_lookup()
775 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb); in ceph_lookup()
781 dout("lookup %p dentry %p '%pd'\n", in ceph_lookup()
784 if (dentry->d_name.len > NAME_MAX) in ceph_lookup()
785 return ERR_PTR(-ENAMETOOLONG); in ceph_lookup()
804 spin_lock(&ci->i_ceph_lock); in ceph_lookup()
805 dout(" dir %p flags are 0x%lx\n", dir, ci->i_ceph_flags); in ceph_lookup()
806 if (strncmp(dentry->d_name.name, in ceph_lookup()
807 fsc->mount_options->snapdir_name, in ceph_lookup()
808 dentry->d_name.len) && in ceph_lookup()
814 spin_unlock(&ci->i_ceph_lock); in ceph_lookup()
815 dout(" dir %p complete, -ENOENT\n", dir); in ceph_lookup()
817 di->lease_shared_gen = atomic_read(&ci->i_shared_gen); in ceph_lookup()
820 spin_unlock(&ci->i_ceph_lock); in ceph_lookup()
828 req->r_dentry = dget(dentry); in ceph_lookup()
829 req->r_num_caps = 2; in ceph_lookup()
834 req->r_args.getattr.mask = cpu_to_le32(mask); in ceph_lookup()
837 req->r_parent = dir; in ceph_lookup()
838 set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); in ceph_lookup()
840 if (err == -ENOENT) { in ceph_lookup()
853 dout("lookup result=%p\n", dentry); in ceph_lookup()
879 return -ESTALE; in ceph_handle_notrace_create()
887 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb); in ceph_mknod()
893 return -EROFS; in ceph_mknod()
900 err = -EDQUOT; in ceph_mknod()
904 dout("mknod in dir %p dentry %p mode 0%ho rdev %d\n", in ceph_mknod()
912 req->r_new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx); in ceph_mknod()
913 if (IS_ERR(req->r_new_inode)) { in ceph_mknod()
914 err = PTR_ERR(req->r_new_inode); in ceph_mknod()
915 req->r_new_inode = NULL; in ceph_mknod()
920 set_bit(CEPH_MDS_R_FSCRYPT_FILE, &req->r_req_flags); in ceph_mknod()
922 req->r_dentry = dget(dentry); in ceph_mknod()
923 req->r_num_caps = 2; in ceph_mknod()
924 req->r_parent = dir; in ceph_mknod()
926 set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); in ceph_mknod()
927 req->r_args.mknod.mode = cpu_to_le32(mode); in ceph_mknod()
928 req->r_args.mknod.rdev = cpu_to_le32(rdev); in ceph_mknod()
929 req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL | in ceph_mknod()
931 req->r_dentry_unless = CEPH_CAP_FILE_EXCL; in ceph_mknod()
936 if (!err && !req->r_reply_info.head->is_dentry) in ceph_mknod()
963 err = fscrypt_prepare_symlink(req->r_parent, dest, len, PATH_MAX, in prep_encrypted_symlink_target()
968 err = fscrypt_encrypt_symlink(req->r_new_inode, dest, len, &osd_link); in prep_encrypted_symlink_target()
972 req->r_path2 = kmalloc(CEPH_BASE64_CHARS(osd_link.len) + 1, GFP_KERNEL); in prep_encrypted_symlink_target()
973 if (!req->r_path2) { in prep_encrypted_symlink_target()
974 err = -ENOMEM; in prep_encrypted_symlink_target()
978 len = ceph_base64_encode(osd_link.name, osd_link.len, req->r_path2); in prep_encrypted_symlink_target()
979 req->r_path2[len] = '\0'; in prep_encrypted_symlink_target()
988 return -EOPNOTSUPP; in prep_encrypted_symlink_target()
995 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb); in ceph_symlink()
1002 return -EROFS; in ceph_symlink()
1009 err = -EDQUOT; in ceph_symlink()
1013 dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest); in ceph_symlink()
1020 req->r_new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx); in ceph_symlink()
1021 if (IS_ERR(req->r_new_inode)) { in ceph_symlink()
1022 err = PTR_ERR(req->r_new_inode); in ceph_symlink()
1023 req->r_new_inode = NULL; in ceph_symlink()
1027 req->r_parent = dir; in ceph_symlink()
1030 if (IS_ENCRYPTED(req->r_new_inode)) { in ceph_symlink()
1035 req->r_path2 = kstrdup(dest, GFP_KERNEL); in ceph_symlink()
1036 if (!req->r_path2) { in ceph_symlink()
1037 err = -ENOMEM; in ceph_symlink()
1042 set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); in ceph_symlink()
1043 req->r_dentry = dget(dentry); in ceph_symlink()
1044 req->r_num_caps = 2; in ceph_symlink()
1045 req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL | in ceph_symlink()
1047 req->r_dentry_unless = CEPH_CAP_FILE_EXCL; in ceph_symlink()
1052 if (!err && !req->r_reply_info.head->is_dentry) in ceph_symlink()
1066 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb); in ceph_mkdir()
1079 dout("mksnap dir %p snap '%pd' dn %p\n", dir, in ceph_mkdir()
1082 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); in ceph_mkdir()
1085 err = -EROFS; in ceph_mkdir()
1091 err = -EDQUOT; in ceph_mkdir()
1096 err = -ENOKEY; in ceph_mkdir()
1108 req->r_new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx); in ceph_mkdir()
1109 if (IS_ERR(req->r_new_inode)) { in ceph_mkdir()
1110 err = PTR_ERR(req->r_new_inode); in ceph_mkdir()
1111 req->r_new_inode = NULL; in ceph_mkdir()
1115 req->r_dentry = dget(dentry); in ceph_mkdir()
1116 req->r_num_caps = 2; in ceph_mkdir()
1117 req->r_parent = dir; in ceph_mkdir()
1119 set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); in ceph_mkdir()
1120 req->r_args.mkdir.mode = cpu_to_le32(mode); in ceph_mkdir()
1121 req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL | in ceph_mkdir()
1123 req->r_dentry_unless = CEPH_CAP_FILE_EXCL; in ceph_mkdir()
1129 !req->r_reply_info.head->is_target && in ceph_mkdir()
1130 !req->r_reply_info.head->is_dentry) in ceph_mkdir()
1146 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb); in ceph_link()
1150 if (dentry->d_flags & DCACHE_DISCONNECTED) in ceph_link()
1151 return -EINVAL; in ceph_link()
1158 return -EROFS; in ceph_link()
1164 dout("link in dir %p %llx.%llx old_dentry %p:'%pd' dentry %p:'%pd'\n", in ceph_link()
1171 req->r_dentry = dget(dentry); in ceph_link()
1172 req->r_num_caps = 2; in ceph_link()
1173 req->r_old_dentry = dget(old_dentry); in ceph_link()
1178 if (old_dentry->d_flags & DCACHE_DISCONNECTED) in ceph_link()
1179 req->r_ino2 = ceph_vino(d_inode(old_dentry)); in ceph_link()
1180 req->r_parent = dir; in ceph_link()
1182 set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); in ceph_link()
1183 req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL; in ceph_link()
1184 req->r_dentry_unless = CEPH_CAP_FILE_EXCL; in ceph_link()
1186 req->r_old_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; in ceph_link()
1190 } else if (!req->r_reply_info.head->is_dentry) { in ceph_link()
1201 struct dentry *dentry = req->r_dentry; in ceph_async_unlink_cb()
1202 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dentry->d_sb); in ceph_async_unlink_cb()
1204 int result = req->r_err ? req->r_err : in ceph_async_unlink_cb()
1205 le32_to_cpu(req->r_reply_info.head->result); in ceph_async_unlink_cb()
1207 if (!test_bit(CEPH_DENTRY_ASYNC_UNLINK_BIT, &di->flags)) in ceph_async_unlink_cb()
1211 spin_lock(&fsc->async_unlink_conflict_lock); in ceph_async_unlink_cb()
1212 hash_del_rcu(&di->hnode); in ceph_async_unlink_cb()
1213 spin_unlock(&fsc->async_unlink_conflict_lock); in ceph_async_unlink_cb()
1215 spin_lock(&dentry->d_lock); in ceph_async_unlink_cb()
1216 di->flags &= ~CEPH_DENTRY_ASYNC_UNLINK; in ceph_async_unlink_cb()
1217 wake_up_bit(&di->flags, CEPH_DENTRY_ASYNC_UNLINK_BIT); in ceph_async_unlink_cb()
1218 spin_unlock(&dentry->d_lock); in ceph_async_unlink_cb()
1222 if (result == -EJUKEBOX) in ceph_async_unlink_cb()
1233 mapping_set_error(req->r_parent->i_mapping, result); in ceph_async_unlink_cb()
1234 ceph_dir_clear_complete(req->r_parent); in ceph_async_unlink_cb()
1236 /* drop the dentry -- we don't know its status */ in ceph_async_unlink_cb()
1241 mapping_set_error(req->r_old_inode->i_mapping, result); in ceph_async_unlink_cb()
1248 iput(req->r_old_inode); in ceph_async_unlink_cb()
1258 spin_lock(&ci->i_ceph_lock); in get_caps_for_async_unlink()
1263 spin_unlock(&ci->i_ceph_lock); in get_caps_for_async_unlink()
1269 spin_lock(&dentry->d_lock); in get_caps_for_async_unlink()
1272 * - We are holding Fx, which implies Fs caps. in get_caps_for_async_unlink()
1273 * - Only support async unlink for primary linkage in get_caps_for_async_unlink()
1275 if (atomic_read(&ci->i_shared_gen) != di->lease_shared_gen || in get_caps_for_async_unlink()
1276 !(di->flags & CEPH_DENTRY_PRIMARY_LINK)) in get_caps_for_async_unlink()
1278 spin_unlock(&dentry->d_lock); in get_caps_for_async_unlink()
1293 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dir->i_sb); in ceph_unlink()
1294 struct ceph_mds_client *mdsc = fsc->mdsc; in ceph_unlink()
1298 int err = -EROFS; in ceph_unlink()
1303 dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry); in ceph_unlink()
1306 dout("unlink/rmdir dir %p dn %p inode %p\n", in ceph_unlink()
1318 req->r_dentry = dget(dentry); in ceph_unlink()
1319 req->r_num_caps = 2; in ceph_unlink()
1320 req->r_parent = dir; in ceph_unlink()
1322 req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL; in ceph_unlink()
1323 req->r_dentry_unless = CEPH_CAP_FILE_EXCL; in ceph_unlink()
1324 req->r_inode_drop = ceph_drop_caps_for_unlink(inode); in ceph_unlink()
1327 (req->r_dir_caps = get_caps_for_async_unlink(dir, dentry))) { in ceph_unlink()
1330 dout("async unlink on %llu/%.*s caps=%s", ceph_ino(dir), in ceph_unlink()
1331 dentry->d_name.len, dentry->d_name.name, in ceph_unlink()
1332 ceph_cap_string(req->r_dir_caps)); in ceph_unlink()
1333 set_bit(CEPH_MDS_R_ASYNC, &req->r_req_flags); in ceph_unlink()
1334 req->r_callback = ceph_async_unlink_cb; in ceph_unlink()
1335 req->r_old_inode = d_inode(dentry); in ceph_unlink()
1336 ihold(req->r_old_inode); in ceph_unlink()
1338 spin_lock(&dentry->d_lock); in ceph_unlink()
1339 di->flags |= CEPH_DENTRY_ASYNC_UNLINK; in ceph_unlink()
1340 spin_unlock(&dentry->d_lock); in ceph_unlink()
1342 spin_lock(&fsc->async_unlink_conflict_lock); in ceph_unlink()
1343 hash_add_rcu(fsc->async_unlink_conflict, &di->hnode, in ceph_unlink()
1344 dentry->d_name.hash); in ceph_unlink()
1345 spin_unlock(&fsc->async_unlink_conflict_lock); in ceph_unlink()
1356 spin_lock(&fsc->async_unlink_conflict_lock); in ceph_unlink()
1357 hash_del_rcu(&di->hnode); in ceph_unlink()
1358 spin_unlock(&fsc->async_unlink_conflict_lock); in ceph_unlink()
1360 spin_lock(&dentry->d_lock); in ceph_unlink()
1361 di->flags &= ~CEPH_DENTRY_ASYNC_UNLINK; in ceph_unlink()
1362 spin_unlock(&dentry->d_lock); in ceph_unlink()
1364 if (err == -EJUKEBOX) { in ceph_unlink()
1371 set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); in ceph_unlink()
1373 if (!err && !req->r_reply_info.head->is_dentry) in ceph_unlink()
1386 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(old_dir->i_sb); in ceph_rename()
1392 return -EINVAL; in ceph_rename()
1395 return -EXDEV; in ceph_rename()
1400 return -EROFS; in ceph_rename()
1402 /* don't allow cross-quota renames */ in ceph_rename()
1405 return -EXDEV; in ceph_rename()
1416 dout("rename dir %p dentry %p to dir %p dentry %p\n", in ceph_rename()
1422 req->r_dentry = dget(new_dentry); in ceph_rename()
1423 req->r_num_caps = 2; in ceph_rename()
1424 req->r_old_dentry = dget(old_dentry); in ceph_rename()
1425 req->r_old_dentry_dir = old_dir; in ceph_rename()
1426 req->r_parent = new_dir; in ceph_rename()
1428 set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); in ceph_rename()
1429 req->r_old_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL; in ceph_rename()
1430 req->r_old_dentry_unless = CEPH_CAP_FILE_EXCL; in ceph_rename()
1431 req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL; in ceph_rename()
1432 req->r_dentry_unless = CEPH_CAP_FILE_EXCL; in ceph_rename()
1434 req->r_old_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; in ceph_rename()
1436 req->r_inode_drop = in ceph_rename()
1440 if (!err && !req->r_reply_info.head->is_dentry) { in ceph_rename()
1453 * Move dentry to tail of mdsc->dentry_leases list when lease is updated.
1457 * Called under dentry->d_lock.
1461 struct dentry *dn = di->dentry; in __ceph_dentry_lease_touch()
1464 dout("dentry_lease_touch %p %p '%pd'\n", di, dn, dn); in __ceph_dentry_lease_touch()
1466 di->flags |= CEPH_DENTRY_LEASE_LIST; in __ceph_dentry_lease_touch()
1467 if (di->flags & CEPH_DENTRY_SHRINK_LIST) { in __ceph_dentry_lease_touch()
1468 di->flags |= CEPH_DENTRY_REFERENCED; in __ceph_dentry_lease_touch()
1472 mdsc = ceph_sb_to_fs_client(dn->d_sb)->mdsc; in __ceph_dentry_lease_touch()
1473 spin_lock(&mdsc->dentry_list_lock); in __ceph_dentry_lease_touch()
1474 list_move_tail(&di->lease_list, &mdsc->dentry_leases); in __ceph_dentry_lease_touch()
1475 spin_unlock(&mdsc->dentry_list_lock); in __ceph_dentry_lease_touch()
1481 di->flags &= ~(CEPH_DENTRY_LEASE_LIST | CEPH_DENTRY_REFERENCED); in __dentry_dir_lease_touch()
1482 di->lease_gen = 0; in __dentry_dir_lease_touch()
1483 di->time = jiffies; in __dentry_dir_lease_touch()
1484 list_move_tail(&di->lease_list, &mdsc->dentry_dir_leases); in __dentry_dir_lease_touch()
1488 * When dir lease is used, add dentry to tail of mdsc->dentry_dir_leases
1491 * Called under dentry->d_lock.
1495 struct dentry *dn = di->dentry; in __ceph_dentry_dir_lease_touch()
1498 dout("dentry_dir_lease_touch %p %p '%pd' (offset 0x%llx)\n", in __ceph_dentry_dir_lease_touch()
1499 di, dn, dn, di->offset); in __ceph_dentry_dir_lease_touch()
1501 if (!list_empty(&di->lease_list)) { in __ceph_dentry_dir_lease_touch()
1502 if (di->flags & CEPH_DENTRY_LEASE_LIST) { in __ceph_dentry_dir_lease_touch()
1508 di->flags |= CEPH_DENTRY_REFERENCED; in __ceph_dentry_dir_lease_touch()
1513 if (di->flags & CEPH_DENTRY_SHRINK_LIST) { in __ceph_dentry_dir_lease_touch()
1514 di->flags |= CEPH_DENTRY_REFERENCED; in __ceph_dentry_dir_lease_touch()
1515 di->flags &= ~CEPH_DENTRY_LEASE_LIST; in __ceph_dentry_dir_lease_touch()
1519 mdsc = ceph_sb_to_fs_client(dn->d_sb)->mdsc; in __ceph_dentry_dir_lease_touch()
1520 spin_lock(&mdsc->dentry_list_lock); in __ceph_dentry_dir_lease_touch()
1522 spin_unlock(&mdsc->dentry_list_lock); in __ceph_dentry_dir_lease_touch()
1528 if (di->flags & CEPH_DENTRY_SHRINK_LIST) in __dentry_lease_unlist()
1530 if (list_empty(&di->lease_list)) in __dentry_lease_unlist()
1533 mdsc = ceph_sb_to_fs_client(di->dentry->d_sb)->mdsc; in __dentry_lease_unlist()
1534 spin_lock(&mdsc->dentry_list_lock); in __dentry_lease_unlist()
1535 list_del_init(&di->lease_list); in __dentry_lease_unlist()
1536 spin_unlock(&mdsc->dentry_list_lock); in __dentry_lease_unlist()
1542 TOUCH = 2,
1565 list = lwc->dir_lease ? &mdsc->dentry_dir_leases : &mdsc->dentry_leases; in __dentry_leases_walk()
1566 spin_lock(&mdsc->dentry_list_lock); in __dentry_leases_walk()
1568 if (!lwc->nr_to_scan) in __dentry_leases_walk()
1570 --lwc->nr_to_scan; in __dentry_leases_walk()
1572 dentry = di->dentry; in __dentry_leases_walk()
1576 if (!spin_trylock(&dentry->d_lock)) in __dentry_leases_walk()
1579 if (__lockref_is_dead(&dentry->d_lockref)) { in __dentry_leases_walk()
1580 list_del_init(&di->lease_list); in __dentry_leases_walk()
1593 di->flags &= ~CEPH_DENTRY_REFERENCED; in __dentry_leases_walk()
1594 if (dentry->d_lockref.count > 0) { in __dentry_leases_walk()
1595 /* update_dentry_lease() will re-add in __dentry_leases_walk()
1599 list_del_init(&di->lease_list); in __dentry_leases_walk()
1601 di->flags |= CEPH_DENTRY_SHRINK_LIST; in __dentry_leases_walk()
1602 list_move_tail(&di->lease_list, &dispose); in __dentry_leases_walk()
1607 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1611 spin_unlock(&mdsc->dentry_list_lock); in __dentry_leases_walk()
1616 dentry = di->dentry; in __dentry_leases_walk()
1617 spin_lock(&dentry->d_lock); in __dentry_leases_walk()
1619 list_del_init(&di->lease_list); in __dentry_leases_walk()
1620 di->flags &= ~CEPH_DENTRY_SHRINK_LIST; in __dentry_leases_walk()
1621 if (di->flags & CEPH_DENTRY_REFERENCED) { in __dentry_leases_walk()
1622 spin_lock(&mdsc->dentry_list_lock); in __dentry_leases_walk()
1623 if (di->flags & CEPH_DENTRY_LEASE_LIST) { in __dentry_leases_walk()
1624 list_add_tail(&di->lease_list, in __dentry_leases_walk()
1625 &mdsc->dentry_leases); in __dentry_leases_walk()
1629 spin_unlock(&mdsc->dentry_list_lock); in __dentry_leases_walk()
1634 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1649 if (ret == -EBUSY) in __dentry_lease_check()
1662 if (ret == -EBUSY) in __dir_lease_check()
1665 if (time_before(jiffies, di->time + lwc->dir_lease_ttl)) in __dir_lease_check()
1670 if (!lwc->expire_dir_lease) in __dir_lease_check()
1672 if (dentry->d_lockref.count > 0 || in __dir_lease_check()
1673 (di->flags & CEPH_DENTRY_REFERENCED)) in __dir_lease_check()
1676 di->lease_shared_gen = 0; in __dir_lease_check()
1687 spin_lock(&mdsc->caps_list_lock); in ceph_trim_dentries()
1688 if (mdsc->caps_use_max > 0 && in ceph_trim_dentries()
1689 mdsc->caps_use_count > mdsc->caps_use_max) in ceph_trim_dentries()
1690 count = mdsc->caps_use_count - mdsc->caps_use_max; in ceph_trim_dentries()
1693 spin_unlock(&mdsc->caps_list_lock); in ceph_trim_dentries()
1696 lwc.nr_to_scan = CEPH_CAPS_PER_RELEASE * 2; in ceph_trim_dentries()
1699 return -EAGAIN; in ceph_trim_dentries()
1706 lwc.dir_lease_ttl = mdsc->fsc->mount_options->caps_wanted_delay_max * HZ; in ceph_trim_dentries()
1709 return -EAGAIN; in ceph_trim_dentries()
1720 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1721 di->time = jiffies; in ceph_invalidate_dentry_lease()
1722 di->lease_shared_gen = 0; in ceph_invalidate_dentry_lease()
1723 di->flags &= ~CEPH_DENTRY_PRIMARY_LINK; in ceph_invalidate_dentry_lease()
1725 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1736 if (!di->lease_gen) in __dentry_lease_is_valid()
1739 session = di->lease_session; in __dentry_lease_is_valid()
1744 gen = atomic_read(&session->s_cap_gen); in __dentry_lease_is_valid()
1745 ttl = session->s_cap_ttl; in __dentry_lease_is_valid()
1747 if (di->lease_gen == gen && in __dentry_lease_is_valid()
1749 time_before(jiffies, di->time)) in __dentry_lease_is_valid()
1752 di->lease_gen = 0; in __dentry_lease_is_valid()
1763 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1768 if (di->lease_renew_after && in dentry_lease_is_valid()
1769 time_after(jiffies, di->lease_renew_after)) { in dentry_lease_is_valid()
1773 * -ECHILD. in dentry_lease_is_valid()
1776 valid = -ECHILD; in dentry_lease_is_valid()
1778 session = ceph_get_mds_session(di->lease_session); in dentry_lease_is_valid()
1779 seq = di->lease_seq; in dentry_lease_is_valid()
1780 di->lease_renew_after = 0; in dentry_lease_is_valid()
1781 di->lease_renew_from = jiffies; in dentry_lease_is_valid()
1785 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1792 dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1797 * Called under dentry->d_lock.
1806 if (!di->lease_shared_gen) in __dir_lease_try_check()
1811 dir = d_inode(dentry->d_parent); in __dir_lease_try_check()
1814 if (spin_trylock(&ci->i_ceph_lock)) { in __dir_lease_try_check()
1815 if (atomic_read(&ci->i_shared_gen) == di->lease_shared_gen && in __dir_lease_try_check()
1818 spin_unlock(&ci->i_ceph_lock); in __dir_lease_try_check()
1820 valid = -EBUSY; in __dir_lease_try_check()
1824 di->lease_shared_gen = 0; in __dir_lease_try_check()
1829 * Check if directory-wide content lease/cap is valid.
1838 spin_lock(&ci->i_ceph_lock); in dir_lease_is_valid()
1842 shared_gen = atomic_read(&ci->i_shared_gen); in dir_lease_is_valid()
1844 spin_unlock(&ci->i_ceph_lock); in dir_lease_is_valid()
1847 spin_lock(&dentry->d_lock); in dir_lease_is_valid()
1849 if (dir == d_inode(dentry->d_parent) && in dir_lease_is_valid()
1850 di && di->lease_shared_gen == shared_gen) in dir_lease_is_valid()
1854 spin_unlock(&dentry->d_lock); in dir_lease_is_valid()
1856 dout("dir_lease_is_valid dir %p v%u dentry %p = %d\n", in dir_lease_is_valid()
1857 dir, (unsigned)atomic_read(&ci->i_shared_gen), dentry, valid); in dir_lease_is_valid()
1876 parent = READ_ONCE(dentry->d_parent); in ceph_d_revalidate()
1879 return -ECHILD; in ceph_d_revalidate()
1887 dout("d_revalidate %p '%pd' inode %p offset 0x%llx nokey %d\n", dentry, in ceph_d_revalidate()
1888 dentry, inode, ceph_dentry(dentry)->offset, in ceph_d_revalidate()
1889 !!(dentry->d_flags & DCACHE_NOKEY_NAME)); in ceph_d_revalidate()
1891 mdsc = ceph_sb_to_fs_client(dir->i_sb)->mdsc; in ceph_d_revalidate()
1895 dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1902 if (valid == -ECHILD) in ceph_d_revalidate()
1918 return -ECHILD; in ceph_d_revalidate()
1920 percpu_counter_inc(&mdsc->metric.d_lease_mis); in ceph_d_revalidate()
1926 req->r_dentry = dget(dentry); in ceph_d_revalidate()
1927 req->r_num_caps = 2; in ceph_d_revalidate()
1928 req->r_parent = dir; in ceph_d_revalidate()
1934 req->r_args.getattr.mask = cpu_to_le32(mask); in ceph_d_revalidate()
1940 d_inode(dentry) == req->r_target_inode) in ceph_d_revalidate()
1943 case -ENOENT: in ceph_d_revalidate()
1947 default: in ceph_d_revalidate()
1951 dout("d_revalidate %p lookup result=%d\n", in ceph_d_revalidate()
1955 percpu_counter_inc(&mdsc->metric.d_lease_hit); in ceph_d_revalidate()
1958 dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
1970 * Called under dentry->d_lock.
1998 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dentry->d_sb); in ceph_d_release()
2000 dout("d_release %p\n", dentry); in ceph_d_release()
2002 atomic64_dec(&fsc->mdsc->metric.total_dentries); in ceph_d_release()
2004 spin_lock(&dentry->d_lock); in ceph_d_release()
2006 dentry->d_fsdata = NULL; in ceph_d_release()
2007 spin_unlock(&dentry->d_lock); in ceph_d_release()
2009 ceph_put_mds_session(di->lease_session); in ceph_d_release()
2017 * Called under dentry->d_lock.
2024 dout("ceph_d_prune %pd %p\n", dentry, dentry); in ceph_d_prune()
2031 dir_ci = ceph_inode(d_inode(dentry->d_parent)); in ceph_d_prune()
2032 if (dir_ci->i_vino.snap == CEPH_SNAPDIR) in ceph_d_prune()
2049 if (di->offset > 0 && in ceph_d_prune()
2050 di->lease_shared_gen == atomic_read(&dir_ci->i_shared_gen)) in ceph_d_prune()
2056 * with '-o dirstat'.
2061 struct ceph_dir_file_info *dfi = file->private_data; in ceph_read_dir()
2067 if (!ceph_test_mount_opt(ceph_sb_to_fs_client(inode->i_sb), DIRSTAT)) in ceph_read_dir()
2068 return -EISDIR; in ceph_read_dir()
2070 if (!dfi->dir_info) { in ceph_read_dir()
2071 dfi->dir_info = kmalloc(bufsize, GFP_KERNEL); in ceph_read_dir()
2072 if (!dfi->dir_info) in ceph_read_dir()
2073 return -ENOMEM; in ceph_read_dir()
2074 dfi->dir_info_len = in ceph_read_dir()
2075 snprintf(dfi->dir_info, bufsize, in ceph_read_dir()
2084 ci->i_files + ci->i_subdirs, in ceph_read_dir()
2085 ci->i_files, in ceph_read_dir()
2086 ci->i_subdirs, in ceph_read_dir()
2087 ci->i_rfiles + ci->i_rsubdirs, in ceph_read_dir()
2088 ci->i_rfiles, in ceph_read_dir()
2089 ci->i_rsubdirs, in ceph_read_dir()
2090 ci->i_rbytes, in ceph_read_dir()
2091 ci->i_rctime.tv_sec, in ceph_read_dir()
2092 ci->i_rctime.tv_nsec); in ceph_read_dir()
2095 if (*ppos >= dfi->dir_info_len) in ceph_read_dir()
2097 size = min_t(unsigned, size, dfi->dir_info_len-*ppos); in ceph_read_dir()
2098 left = copy_to_user(buf, dfi->dir_info + *ppos, size); in ceph_read_dir()
2100 return -EFAULT; in ceph_read_dir()
2101 *ppos += (size - left); in ceph_read_dir()
2102 return size - left; in ceph_read_dir()
2116 switch (dci->i_dir_layout.dl_dir_hash) { in ceph_dentry_hash()
2119 return dn->d_name.hash; in ceph_dentry_hash()
2121 default: in ceph_dentry_hash()
2122 spin_lock(&dn->d_lock); in ceph_dentry_hash()
2123 hash = ceph_str_hash(dci->i_dir_layout.dl_dir_hash, in ceph_dentry_hash()
2124 dn->d_name.name, dn->d_name.len); in ceph_dentry_hash()
2125 spin_unlock(&dn->d_lock); in ceph_dentry_hash()