Lines Matching refs:cfid

16 static void free_cached_dir(struct cached_fid *cfid);
25 struct cached_fid *cfid;
28 list_for_each_entry(cfid, &cfids->entries, entry) {
29 if (!strcmp(cfid->path, path)) {
35 if (!cfid->time || !cfid->has_lease) {
39 kref_get(&cfid->refcount);
41 return cfid;
52 cfid = init_cached_dir(path);
53 if (cfid == NULL) {
57 cfid->cfids = cfids;
59 list_add(&cfid->entry, &cfids->entries);
60 cfid->on_list = true;
61 kref_get(&cfid->refcount);
63 return cfid;
123 * If error then *cfid is not initialized.
145 struct cached_fid *cfid;
167 cfid = find_or_create_cached_dir(cfids, path, lookup_only, tcon->max_cached_dirs);
168 if (cfid == NULL) {
178 if (cfid->has_lease) {
180 *ret_cfid = cfid;
208 cfid->dentry = dentry;
214 * to the cfid until we have finished opening the file and (possibly)
220 pfid = &cfid->fid;
263 * Set @cfid->has_lease to true before sending out compounded request so
265 * potential lease break right after the request is sent or while @cfid
267 * due to @cfid->time being zero.
269 cfid->has_lease = true;
282 cfid->tcon = tcon;
283 cfid->is_open = true;
324 (char *)&cfid->file_all_info))
325 cfid->file_all_info_is_valid = true;
327 cfid->time = jiffies;
339 if (cfid->on_list) {
340 list_del(&cfid->entry);
341 cfid->on_list = false;
344 if (cfid->has_lease) {
352 cfid->has_lease = false;
354 kref_put(&cfid->refcount, smb2_close_cached_fid);
361 if (cfid->is_open)
362 SMB2_close(0, cfid->tcon, cfid->fid.persistent_fid,
363 cfid->fid.volatile_fid);
364 free_cached_dir(cfid);
366 *ret_cfid = cfid;
378 struct cached_fid *cfid;
385 list_for_each_entry(cfid, &cfids->entries, entry) {
386 if (dentry && cfid->dentry == dentry) {
388 kref_get(&cfid->refcount);
389 *ret_cfid = cfid;
401 struct cached_fid *cfid = container_of(ref, struct cached_fid,
404 spin_lock(&cfid->cfids->cfid_list_lock);
405 if (cfid->on_list) {
406 list_del(&cfid->entry);
407 cfid->on_list = false;
408 cfid->cfids->num_entries--;
410 spin_unlock(&cfid->cfids->cfid_list_lock);
412 dput(cfid->dentry);
413 cfid->dentry = NULL;
415 if (cfid->is_open) {
416 SMB2_close(0, cfid->tcon, cfid->fid.persistent_fid,
417 cfid->fid.volatile_fid);
418 atomic_dec(&cfid->tcon->num_remote_opens);
421 free_cached_dir(cfid);
427 struct cached_fid *cfid = NULL;
430 rc = open_cached_dir(xid, tcon, name, cifs_sb, true, &cfid);
435 spin_lock(&cfid->cfids->cfid_list_lock);
436 if (cfid->has_lease) {
437 cfid->has_lease = false;
438 kref_put(&cfid->refcount, smb2_close_cached_fid);
440 spin_unlock(&cfid->cfids->cfid_list_lock);
441 close_cached_dir(cfid);
445 void close_cached_dir(struct cached_fid *cfid)
447 kref_put(&cfid->refcount, smb2_close_cached_fid);
457 struct cached_fid *cfid;
470 list_for_each_entry(cfid, &cfids->entries, entry) {
471 dput(cfid->dentry);
472 cfid->dentry = NULL;
484 struct cached_fid *cfid, *q;
491 list_for_each_entry_safe(cfid, q, &cfids->entries, entry) {
492 list_move(&cfid->entry, &entry);
494 cfid->is_open = false;
495 cfid->on_list = false;
497 kref_get(&cfid->refcount);
501 list_for_each_entry_safe(cfid, q, &entry, entry) {
502 list_del(&cfid->entry);
503 cancel_work_sync(&cfid->lease_break);
504 if (cfid->has_lease) {
510 cfid->has_lease = false;
512 kref_put(&cfid->refcount, smb2_close_cached_fid);
515 kref_put(&cfid->refcount, smb2_close_cached_fid);
522 struct cached_fid *cfid = container_of(work,
525 spin_lock(&cfid->cfids->cfid_list_lock);
526 cfid->has_lease = false;
527 spin_unlock(&cfid->cfids->cfid_list_lock);
528 kref_put(&cfid->refcount, smb2_close_cached_fid);
534 struct cached_fid *cfid;
540 list_for_each_entry(cfid, &cfids->entries, entry) {
541 if (cfid->has_lease &&
543 cfid->fid.lease_key,
545 cfid->time = 0;
550 list_del(&cfid->entry);
551 cfid->on_list = false;
555 &cfid->lease_break);
566 struct cached_fid *cfid;
568 cfid = kzalloc(sizeof(*cfid), GFP_ATOMIC);
569 if (!cfid)
571 cfid->path = kstrdup(path, GFP_ATOMIC);
572 if (!cfid->path) {
573 kfree(cfid);
577 INIT_WORK(&cfid->lease_break, smb2_cached_lease_break);
578 INIT_LIST_HEAD(&cfid->entry);
579 INIT_LIST_HEAD(&cfid->dirents.entries);
580 mutex_init(&cfid->dirents.de_mutex);
581 spin_lock_init(&cfid->fid_lock);
582 kref_init(&cfid->refcount);
583 return cfid;
586 static void free_cached_dir(struct cached_fid *cfid)
590 dput(cfid->dentry);
591 cfid->dentry = NULL;
596 list_for_each_entry_safe(dirent, q, &cfid->dirents.entries, entry) {
602 kfree(cfid->path);
603 cfid->path = NULL;
604 kfree(cfid);
610 struct cached_fid *cfid, *q;
616 list_for_each_entry_safe(cfid, q, &cfids->entries, entry) {
617 if (cfid->time &&
618 time_after(jiffies, cfid->time + HZ * dir_cache_timeout)) {
619 cfid->on_list = false;
620 list_move(&cfid->entry, &entry);
623 kref_get(&cfid->refcount);
628 list_for_each_entry_safe(cfid, q, &entry, entry) {
629 list_del(&cfid->entry);
634 cancel_work_sync(&cfid->lease_break);
635 if (cfid->has_lease) {
641 cfid->has_lease = false;
643 kref_put(&cfid->refcount, smb2_close_cached_fid);
646 kref_put(&cfid->refcount, smb2_close_cached_fid);
675 struct cached_fid *cfid, *q;
684 list_for_each_entry_safe(cfid, q, &cfids->entries, entry) {
685 cfid->on_list = false;
686 cfid->is_open = false;
687 list_move(&cfid->entry, &entry);
691 list_for_each_entry_safe(cfid, q, &entry, entry) {
692 list_del(&cfid->entry);
693 free_cached_dir(cfid);