linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ronnie Sahlberg <lsahlber@redhat.com>
To: linux-cifs <linux-cifs@vger.kernel.org>
Cc: Ronnie Sahlberg <lsahlber@redhat.com>
Subject: [PATCH] cifs: don't leak -EAGAIN for stat() during reconnect
Date: Tue, 18 Feb 2020 14:18:42 +1000	[thread overview]
Message-ID: <20200218041842.13986-2-lsahlber@redhat.com> (raw)
In-Reply-To: <20200218041842.13986-1-lsahlber@redhat.com>

If from cifs_revalidate_dentry_attr() the SMB2/QUERY_INFO call fails with an
error, such as STATUS_SESSION_EXPIRED, causing the session to be reconnected
it is possible we will leak -EAGAIN back to the application even for
system calls such as stat() where this is not a valid error.

Fix this by re-trying the operation from within cifs_revalidate_dentry_attr()
if cifs_get_inode_info*() returns -EAGAIN.

This fixes stat() and possibly also other system calls that uses
cifs_revalidate_dentry*().

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/inode.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index b5e6635c578e..cf36dcd9dafd 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -2073,7 +2073,9 @@ int cifs_revalidate_dentry_attr(struct dentry *dentry)
 	struct inode *inode = d_inode(dentry);
 	struct super_block *sb = dentry->d_sb;
 	char *full_path = NULL;
+	int count = 0;
 
+again:
 	if (inode == NULL)
 		return -ENOENT;
 
@@ -2099,6 +2101,8 @@ int cifs_revalidate_dentry_attr(struct dentry *dentry)
 	else
 		rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
 					 xid, NULL);
+	if (rc == -EAGAIN && count++ < 10)
+		goto again;
 
 out:
 	kfree(full_path);
-- 
2.13.6


  reply	other threads:[~2020-02-18  4:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18  4:18 [PATCH 0/1] dont leak -EAGAIN Ronnie Sahlberg
2020-02-18  4:18 ` Ronnie Sahlberg [this message]
2020-02-18  4:48 [PATCH] cifs: don't leak -EAGAIN for stat() during reconnect Ronnie Sahlberg
2020-02-18 11:47 ` Aurélien Aptel
2020-02-18 19:58   ` ronnie sahlberg
2020-02-18 20:01 Ronnie Sahlberg
2020-02-18 23:26 ` Steve French
2020-02-24 19:36   ` Pavel Shilovsky
2020-02-24 20:22     ` Steve French

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200218041842.13986-2-lsahlber@redhat.com \
    --to=lsahlber@redhat.com \
    --cc=linux-cifs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).