Skip to content

Commit 3deddb7

Browse files
Paulo AlcantaraSteve French
authored andcommitted
cifs: handle cache lookup errors different than -ENOENT
lookup_cache_entry() might return an error different than -ENOENT (e.g. from ->char2uni), so handle those as well in cache_refresh_path(). Signed-off-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 8064f71 commit 3deddb7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fs/cifs/dfs_cache.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,9 @@ static struct cache_entry *__lookup_cache_entry(const char *path, unsigned int h
644644
*
645645
* Use whole path components in the match. Must be called with htable_rw_lock held.
646646
*
647+
* Return cached entry if successful.
647648
* Return ERR_PTR(-ENOENT) if the entry is not found.
649+
* Return error ptr otherwise.
648650
*/
649651
static struct cache_entry *lookup_cache_entry(const char *path)
650652
{
@@ -789,8 +791,13 @@ static struct cache_entry *cache_refresh_path(const unsigned int xid,
789791
down_read(&htable_rw_lock);
790792

791793
ce = lookup_cache_entry(path);
792-
if (!IS_ERR(ce) && !force_refresh && !cache_entry_expired(ce))
794+
if (!IS_ERR(ce)) {
795+
if (!force_refresh && !cache_entry_expired(ce))
796+
return ce;
797+
} else if (PTR_ERR(ce) != -ENOENT) {
798+
up_read(&htable_rw_lock);
793799
return ce;
800+
}
794801

795802
/*
796803
* Unlock shared access as we don't want to hold any locks while getting
@@ -822,7 +829,7 @@ static struct cache_entry *cache_refresh_path(const unsigned int xid,
822829
if (rc)
823830
ce = ERR_PTR(rc);
824831
}
825-
} else {
832+
} else if (PTR_ERR(ce) == -ENOENT) {
826833
ce = add_cache_entry_locked(refs, numrefs);
827834
}
828835

0 commit comments

Comments
 (0)