@@ -59,6 +59,16 @@ static struct cached_fid *find_or_create_cached_dir(struct cached_fids *cfids,
59
59
list_add (& cfid -> entry , & cfids -> entries );
60
60
cfid -> on_list = true;
61
61
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
+
62
72
spin_unlock (& cfids -> cfid_list_lock );
63
73
return cfid ;
64
74
}
@@ -176,12 +186,12 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
176
186
return - ENOENT ;
177
187
}
178
188
/*
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.
182
192
*/
183
193
spin_lock (& cfids -> cfid_list_lock );
184
- if (cfid -> has_lease ) {
194
+ if (cfid -> has_lease && cfid -> time ) {
185
195
spin_unlock (& cfids -> cfid_list_lock );
186
196
* ret_cfid = cfid ;
187
197
kfree (utf16_path );
@@ -267,15 +277,6 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
267
277
268
278
smb2_set_related (& rqst [1 ]);
269
279
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
-
279
280
if (retries ) {
280
281
smb2_set_replay (server , & rqst [0 ]);
281
282
smb2_set_replay (server , & rqst [1 ]);
0 commit comments