Lines Matching refs:dfi
112 static int note_last_dentry(struct ceph_dir_file_info *dfi, const char *name, in note_last_dentry() argument
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()
185 struct ceph_dir_file_info *dfi = file->private_data; in __dcache_readdir() local
232 dfi->file_info.flags |= CEPH_F_ATEND; in __dcache_readdir()
284 ret = note_last_dentry(dfi, last->d_name.name, last->d_name.len, 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()
298 static bool need_send_readdir(struct ceph_dir_file_info *dfi, loff_t pos) in need_send_readdir() argument
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() local
321 if (dfi->file_info.flags & CEPH_F_ATEND) 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()
395 ceph_vinop(inode), frag, dfi->last_name); 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()
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()
460 dfi->next_offset = req->r_readdir_offset; 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()
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()
486 dfi->readdir_cache_idx = -1; in ceph_readdir()
488 dfi->dir_release_count = 0; 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()
505 dfi->next_offset = 2; in ceph_readdir()
510 rinfo = &dfi->last_readdir->r_reply_info; in ceph_readdir()
512 dfi->frag, rinfo->dir_nr, 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()
576 dfi->next_offset, true); 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()
589 dfi->file_info.flags |= CEPH_F_ATEND; in ceph_readdir()
597 dfi->dir_release_count) { in ceph_readdir()
599 if (dfi->dir_ordered_count == 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()
610 __ceph_dir_set_complete(ci, dfi->dir_release_count, in ceph_readdir()
611 dfi->dir_ordered_count); in ceph_readdir()
618 static void reset_readdir(struct ceph_dir_file_info *dfi) in reset_readdir() argument
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()
636 static bool need_reset_readdir(struct ceph_dir_file_info *dfi, loff_t new_pos) in need_reset_readdir() argument
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()
658 struct ceph_dir_file_info *dfi = file->private_data; in ceph_dir_llseek() local
678 if (need_reset_readdir(dfi, offset)) { in ceph_dir_llseek()
680 reset_readdir(dfi); in ceph_dir_llseek()
684 dfi->dir_release_count = 0; in ceph_dir_llseek()
685 dfi->readdir_cache_idx = -1; in ceph_dir_llseek()
691 dfi->file_info.flags &= ~CEPH_F_ATEND; in ceph_dir_llseek()
2061 struct ceph_dir_file_info *dfi = file->private_data; in ceph_read_dir() local
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()
2074 dfi->dir_info_len = in ceph_read_dir()
2075 snprintf(dfi->dir_info, bufsize, 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()