Lines Matching refs:cfid

16 static void free_cached_dir(struct cached_fid *cfid);
30 struct cached_fid *cfid; in find_or_create_cached_dir() local
33 list_for_each_entry(cfid, &cfids->entries, entry) { in find_or_create_cached_dir()
34 if (!strcmp(cfid->path, path)) { in find_or_create_cached_dir()
40 if (!cfid->time || !cfid->has_lease) { in find_or_create_cached_dir()
44 kref_get(&cfid->refcount); in find_or_create_cached_dir()
46 return cfid; in find_or_create_cached_dir()
57 cfid = init_cached_dir(path); in find_or_create_cached_dir()
58 if (cfid == NULL) { in find_or_create_cached_dir()
62 cfid->cfids = cfids; in find_or_create_cached_dir()
64 list_add(&cfid->entry, &cfids->entries); in find_or_create_cached_dir()
65 cfid->on_list = true; in find_or_create_cached_dir()
66 kref_get(&cfid->refcount); in find_or_create_cached_dir()
75 cfid->has_lease = true; in find_or_create_cached_dir()
78 return cfid; in find_or_create_cached_dir()
160 struct cached_fid *cfid; in open_cached_dir() local
190 cfid = find_or_create_cached_dir(cfids, path, lookup_only, tcon->max_cached_dirs); in open_cached_dir()
191 if (cfid == NULL) { in open_cached_dir()
201 if (cfid->has_lease && cfid->time) { in open_cached_dir()
203 *ret_cfid = cfid; in open_cached_dir()
231 cfid->dentry = dentry; in open_cached_dir()
232 cfid->tcon = tcon; in open_cached_dir()
244 pfid = &cfid->fid; in open_cached_dir()
304 cfid->is_open = true; in open_cached_dir()
345 (char *)&cfid->file_all_info)) in open_cached_dir()
346 cfid->file_all_info_is_valid = true; in open_cached_dir()
348 cfid->time = jiffies; in open_cached_dir()
361 if (cfid->on_list) { in open_cached_dir()
362 list_del(&cfid->entry); in open_cached_dir()
363 cfid->on_list = false; in open_cached_dir()
366 if (cfid->has_lease) { in open_cached_dir()
372 cfid->has_lease = false; in open_cached_dir()
373 kref_put(&cfid->refcount, smb2_close_cached_fid); in open_cached_dir()
377 kref_put(&cfid->refcount, smb2_close_cached_fid); in open_cached_dir()
379 *ret_cfid = cfid; in open_cached_dir()
395 struct cached_fid *cfid; in open_cached_dir_by_dentry() local
402 list_for_each_entry(cfid, &cfids->entries, entry) { in open_cached_dir_by_dentry()
403 if (dentry && cfid->dentry == dentry) { in open_cached_dir_by_dentry()
405 kref_get(&cfid->refcount); in open_cached_dir_by_dentry()
406 *ret_cfid = cfid; in open_cached_dir_by_dentry()
418 struct cached_fid *cfid = container_of(ref, struct cached_fid, in smb2_close_cached_fid() local
422 spin_lock(&cfid->cfids->cfid_list_lock); in smb2_close_cached_fid()
423 if (cfid->on_list) { in smb2_close_cached_fid()
424 list_del(&cfid->entry); in smb2_close_cached_fid()
425 cfid->on_list = false; in smb2_close_cached_fid()
426 cfid->cfids->num_entries--; in smb2_close_cached_fid()
428 spin_unlock(&cfid->cfids->cfid_list_lock); in smb2_close_cached_fid()
430 dput(cfid->dentry); in smb2_close_cached_fid()
431 cfid->dentry = NULL; in smb2_close_cached_fid()
433 if (cfid->is_open) { in smb2_close_cached_fid()
434 rc = SMB2_close(0, cfid->tcon, cfid->fid.persistent_fid, in smb2_close_cached_fid()
435 cfid->fid.volatile_fid); in smb2_close_cached_fid()
440 free_cached_dir(cfid); in smb2_close_cached_fid()
446 struct cached_fid *cfid = NULL; in drop_cached_dir_by_name() local
449 rc = open_cached_dir(xid, tcon, name, cifs_sb, true, &cfid); in drop_cached_dir_by_name()
454 spin_lock(&cfid->cfids->cfid_list_lock); in drop_cached_dir_by_name()
455 if (cfid->has_lease) { in drop_cached_dir_by_name()
456 cfid->has_lease = false; in drop_cached_dir_by_name()
457 kref_put(&cfid->refcount, smb2_close_cached_fid); in drop_cached_dir_by_name()
459 spin_unlock(&cfid->cfids->cfid_list_lock); in drop_cached_dir_by_name()
460 close_cached_dir(cfid); in drop_cached_dir_by_name()
464 void close_cached_dir(struct cached_fid *cfid) in close_cached_dir() argument
466 kref_put(&cfid->refcount, smb2_close_cached_fid); in close_cached_dir()
476 struct cached_fid *cfid; in close_all_cached_dirs() local
493 list_for_each_entry(cfid, &cfids->entries, entry) { in close_all_cached_dirs()
497 spin_lock(&cfid->fid_lock); in close_all_cached_dirs()
498 tmp_list->dentry = cfid->dentry; in close_all_cached_dirs()
499 cfid->dentry = NULL; in close_all_cached_dirs()
500 spin_unlock(&cfid->fid_lock); in close_all_cached_dirs()
525 struct cached_fid *cfid, *q; in invalidate_all_cached_dirs() local
536 list_for_each_entry_safe(cfid, q, &cfids->entries, entry) { in invalidate_all_cached_dirs()
537 list_move(&cfid->entry, &cfids->dying); in invalidate_all_cached_dirs()
539 cfid->is_open = false; in invalidate_all_cached_dirs()
540 cfid->on_list = false; in invalidate_all_cached_dirs()
541 if (cfid->has_lease) { in invalidate_all_cached_dirs()
546 cfid->has_lease = false; in invalidate_all_cached_dirs()
548 kref_get(&cfid->refcount); in invalidate_all_cached_dirs()
561 struct cached_fid *cfid = container_of(work, in cached_dir_offload_close() local
563 struct cifs_tcon *tcon = cfid->tcon; in cached_dir_offload_close()
565 WARN_ON(cfid->on_list); in cached_dir_offload_close()
567 kref_put(&cfid->refcount, smb2_close_cached_fid); in cached_dir_offload_close()
580 struct cached_fid *cfid = container_of(work, struct cached_fid, in cached_dir_put_work() local
584 spin_lock(&cfid->fid_lock); in cached_dir_put_work()
585 dentry = cfid->dentry; in cached_dir_put_work()
586 cfid->dentry = NULL; in cached_dir_put_work()
587 spin_unlock(&cfid->fid_lock); in cached_dir_put_work()
590 queue_work(serverclose_wq, &cfid->close_work); in cached_dir_put_work()
596 struct cached_fid *cfid; in cached_dir_lease_break() local
602 list_for_each_entry(cfid, &cfids->entries, entry) { in cached_dir_lease_break()
603 if (cfid->has_lease && in cached_dir_lease_break()
605 cfid->fid.lease_key, in cached_dir_lease_break()
607 cfid->has_lease = false; in cached_dir_lease_break()
608 cfid->time = 0; in cached_dir_lease_break()
613 list_del(&cfid->entry); in cached_dir_lease_break()
614 cfid->on_list = false; in cached_dir_lease_break()
620 queue_work(cfid_put_wq, &cfid->put_work); in cached_dir_lease_break()
631 struct cached_fid *cfid; in init_cached_dir() local
633 cfid = kzalloc(sizeof(*cfid), GFP_ATOMIC); in init_cached_dir()
634 if (!cfid) in init_cached_dir()
636 cfid->path = kstrdup(path, GFP_ATOMIC); in init_cached_dir()
637 if (!cfid->path) { in init_cached_dir()
638 kfree(cfid); in init_cached_dir()
642 INIT_WORK(&cfid->close_work, cached_dir_offload_close); in init_cached_dir()
643 INIT_WORK(&cfid->put_work, cached_dir_put_work); in init_cached_dir()
644 INIT_LIST_HEAD(&cfid->entry); in init_cached_dir()
645 INIT_LIST_HEAD(&cfid->dirents.entries); in init_cached_dir()
646 mutex_init(&cfid->dirents.de_mutex); in init_cached_dir()
647 spin_lock_init(&cfid->fid_lock); in init_cached_dir()
648 kref_init(&cfid->refcount); in init_cached_dir()
649 return cfid; in init_cached_dir()
652 static void free_cached_dir(struct cached_fid *cfid) in free_cached_dir() argument
656 WARN_ON(work_pending(&cfid->close_work)); in free_cached_dir()
657 WARN_ON(work_pending(&cfid->put_work)); in free_cached_dir()
659 dput(cfid->dentry); in free_cached_dir()
660 cfid->dentry = NULL; in free_cached_dir()
665 list_for_each_entry_safe(dirent, q, &cfid->dirents.entries, entry) { in free_cached_dir()
671 kfree(cfid->path); in free_cached_dir()
672 cfid->path = NULL; in free_cached_dir()
673 kfree(cfid); in free_cached_dir()
680 struct cached_fid *cfid, *q; in cfids_invalidation_worker() local
688 list_for_each_entry_safe(cfid, q, &entry, entry) { in cfids_invalidation_worker()
689 list_del(&cfid->entry); in cfids_invalidation_worker()
691 kref_put(&cfid->refcount, smb2_close_cached_fid); in cfids_invalidation_worker()
698 struct cached_fid *cfid, *q; in cfids_laundromat_worker() local
705 list_for_each_entry_safe(cfid, q, &cfids->entries, entry) { in cfids_laundromat_worker()
706 if (cfid->time && in cfids_laundromat_worker()
707 time_after(jiffies, cfid->time + HZ * dir_cache_timeout)) { in cfids_laundromat_worker()
708 cfid->on_list = false; in cfids_laundromat_worker()
709 list_move(&cfid->entry, &entry); in cfids_laundromat_worker()
711 if (cfid->has_lease) { in cfids_laundromat_worker()
716 cfid->has_lease = false; in cfids_laundromat_worker()
718 kref_get(&cfid->refcount); in cfids_laundromat_worker()
723 list_for_each_entry_safe(cfid, q, &entry, entry) { in cfids_laundromat_worker()
724 list_del(&cfid->entry); in cfids_laundromat_worker()
726 spin_lock(&cfid->fid_lock); in cfids_laundromat_worker()
727 dentry = cfid->dentry; in cfids_laundromat_worker()
728 cfid->dentry = NULL; in cfids_laundromat_worker()
729 spin_unlock(&cfid->fid_lock); in cfids_laundromat_worker()
732 if (cfid->is_open) { in cfids_laundromat_worker()
734 ++cfid->tcon->tc_count; in cfids_laundromat_worker()
735 trace_smb3_tcon_ref(cfid->tcon->debug_id, cfid->tcon->tc_count, in cfids_laundromat_worker()
738 queue_work(serverclose_wq, &cfid->close_work); in cfids_laundromat_worker()
744 kref_put(&cfid->refcount, smb2_close_cached_fid); in cfids_laundromat_worker()
775 struct cached_fid *cfid, *q; in free_cached_dirs() local
785 list_for_each_entry_safe(cfid, q, &cfids->entries, entry) { in free_cached_dirs()
786 cfid->on_list = false; in free_cached_dirs()
787 cfid->is_open = false; in free_cached_dirs()
788 list_move(&cfid->entry, &entry); in free_cached_dirs()
790 list_for_each_entry_safe(cfid, q, &cfids->dying, entry) { in free_cached_dirs()
791 cfid->on_list = false; in free_cached_dirs()
792 cfid->is_open = false; in free_cached_dirs()
793 list_move(&cfid->entry, &entry); in free_cached_dirs()
797 list_for_each_entry_safe(cfid, q, &entry, entry) { in free_cached_dirs()
798 list_del(&cfid->entry); in free_cached_dirs()
799 free_cached_dir(cfid); in free_cached_dirs()