Skip to content

Commit d788e51

Browse files
sprasad-microsoftsmfrench
authored andcommitted
cifs: release cached dentries only if mount is complete
During cifs_kill_sb, we first dput all the dentries that we have cached. However this function can also get called for mount failures. So dput the cached dentries only if the filesystem mount is complete. i.e. cifs_sb->root is populated. Fixes: 5e9c89d ("cifs: Grab a reference for the dentry of the cached directory during the lifetime of the cache") Signed-off-by: Shyam Prasad N <sprasad@microsoft.com> Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 994fd53 commit d788e51

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

fs/cifs/cifsfs.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -266,22 +266,24 @@ static void cifs_kill_sb(struct super_block *sb)
266266
* before we kill the sb.
267267
*/
268268
if (cifs_sb->root) {
269+
node = rb_first(root);
270+
while (node != NULL) {
271+
tlink = rb_entry(node, struct tcon_link, tl_rbnode);
272+
tcon = tlink_tcon(tlink);
273+
cfid = &tcon->crfid;
274+
mutex_lock(&cfid->fid_mutex);
275+
if (cfid->dentry) {
276+
dput(cfid->dentry);
277+
cfid->dentry = NULL;
278+
}
279+
mutex_unlock(&cfid->fid_mutex);
280+
node = rb_next(node);
281+
}
282+
283+
/* finally release root dentry */
269284
dput(cifs_sb->root);
270285
cifs_sb->root = NULL;
271286
}
272-
node = rb_first(root);
273-
while (node != NULL) {
274-
tlink = rb_entry(node, struct tcon_link, tl_rbnode);
275-
tcon = tlink_tcon(tlink);
276-
cfid = &tcon->crfid;
277-
mutex_lock(&cfid->fid_mutex);
278-
if (cfid->dentry) {
279-
dput(cfid->dentry);
280-
cfid->dentry = NULL;
281-
}
282-
mutex_unlock(&cfid->fid_mutex);
283-
node = rb_next(node);
284-
}
285287

286288
kill_anon_super(sb);
287289
cifs_umount(cifs_sb);

0 commit comments

Comments
 (0)