@@ -59,6 +59,16 @@ static struct cached_fid *find_or_create_cached_dir(struct cached_fids *cfids,
5959 list_add (& cfid -> entry , & cfids -> entries );
6060 cfid -> on_list = true;
6161 kref_get (& cfid -> refcount );
62+ /*
63+ * Set @cfid->has_lease to true during construction so that the lease
64+ * reference can be put in cached_dir_lease_break() due to a potential
65+ * lease break right after the request is sent or while @cfid is still
66+ * being cached, or if a reconnection is triggered during construction.
67+ * Concurrent processes won't be to use it yet due to @cfid->time being
68+ * zero.
69+ */
70+ cfid -> has_lease = true;
71+
6272 spin_unlock (& cfids -> cfid_list_lock );
6373 return cfid ;
6474}
@@ -176,12 +186,12 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
176186 return - ENOENT ;
177187 }
178188 /*
179- * Return cached fid if it has a lease. Otherwise, it is either a new
180- * entry or laundromat worker removed it from @cfids->entries. Caller
181- * will put last reference if the latter.
189+ * Return cached fid if it is valid ( has a lease and has a time).
190+ * Otherwise, it is either a new entry or laundromat worker removed it
191+ * from @cfids->entries. Caller will put last reference if the latter.
182192 */
183193 spin_lock (& cfids -> cfid_list_lock );
184- if (cfid -> has_lease ) {
194+ if (cfid -> has_lease && cfid -> time ) {
185195 spin_unlock (& cfids -> cfid_list_lock );
186196 * ret_cfid = cfid ;
187197 kfree (utf16_path );
@@ -267,15 +277,6 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
267277
268278 smb2_set_related (& rqst [1 ]);
269279
270- /*
271- * Set @cfid->has_lease to true before sending out compounded request so
272- * its lease reference can be put in cached_dir_lease_break() due to a
273- * potential lease break right after the request is sent or while @cfid
274- * is still being cached. Concurrent processes won't be to use it yet
275- * due to @cfid->time being zero.
276- */
277- cfid -> has_lease = true;
278-
279280 if (retries ) {
280281 smb2_set_replay (server , & rqst [0 ]);
281282 smb2_set_replay (server , & rqst [1 ]);
0 commit comments