Skip to content

Commit

Permalink
cifs: use LIST_HEAD() and list_move() to simplify code
Browse files Browse the repository at this point in the history
list_head can be initialized automatically with LIST_HEAD()
instead of calling INIT_LIST_HEAD().

Using list_move() instead of list_del() and list_add().

Reviewed-by: Paulo Alcantara (SUSE) <[email protected]>
Signed-off-by: Yang Yingliang <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
Yang Yingliang authored and Steve French committed Oct 18, 2022
1 parent 10269f1 commit d32f211
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions fs/cifs/cached_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,11 @@ void invalidate_all_cached_dirs(struct cifs_tcon *tcon)
{
struct cached_fids *cfids = tcon->cfids;
struct cached_fid *cfid, *q;
struct list_head entry;
LIST_HEAD(entry);

INIT_LIST_HEAD(&entry);
spin_lock(&cfids->cfid_list_lock);
list_for_each_entry_safe(cfid, q, &cfids->entries, entry) {
list_del(&cfid->entry);
list_add(&cfid->entry, &entry);
list_move(&cfid->entry, &entry);
cfids->num_entries--;
cfid->is_open = false;
/* To prevent race with smb2_cached_lease_break() */
Expand Down Expand Up @@ -518,15 +516,13 @@ struct cached_fids *init_cached_dirs(void)
void free_cached_dirs(struct cached_fids *cfids)
{
struct cached_fid *cfid, *q;
struct list_head entry;
LIST_HEAD(entry);

INIT_LIST_HEAD(&entry);
spin_lock(&cfids->cfid_list_lock);
list_for_each_entry_safe(cfid, q, &cfids->entries, entry) {
cfid->on_list = false;
cfid->is_open = false;
list_del(&cfid->entry);
list_add(&cfid->entry, &entry);
list_move(&cfid->entry, &entry);
}
spin_unlock(&cfids->cfid_list_lock);

Expand Down

0 comments on commit d32f211

Please sign in to comment.