From: "Steve French" <smfrench@gmail.com>
To: "Jeff Layton" <jlayton@redhat.com>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
"linux-cifs-client@lists.samba.org"
<linux-cifs-client@lists.samba.org>
Subject: Re: [PATCH] do not attempt to close cifs files which are already closed due to session reconnect
Date: Thu, 20 Nov 2008 08:04:08 -0600 [thread overview]
Message-ID: <524f69650811200604x2e1a5529k5bd1075ca5e53ed0@mail.gmail.com> (raw)
In-Reply-To: <20081120080241.24e926f4@barsoom.rdu.redhat.com>
On Thu, Nov 20, 2008 at 7:02 AM, Jeff Layton <jlayton@redhat.com> wrote:
> On Wed, 19 Nov 2008 23:24:47 -0600
> "Steve French" <smfrench@gmail.com> wrote:
>
>> On Wed, Nov 19, 2008 at 6:04 AM, Jeff Layton <jlayton@redhat.com> wrote:
>> > On Tue, 18 Nov 2008 21:46:59 -0600
>> > "Steve French" <smfrench@gmail.com> wrote:
>> >
>> >> In hunting down why we could get EBADF returned on close in some cases
>> >> after reconnect, I found out that cifs_close was checking to see if
>> >> the share (mounted server export) was valid (didn't need reconnect due
>> >> to session crash/timeout) but we weren't checking if the handle was
>> >> valid (ie the share was reconnected, but the file handle was not
>> >> reopened yet). It also adds some locking around the updates/checks of
>> >> the cifs_file->invalidHandle flag
>> >>
>>
>> >
>> > Do we need a lock around this check for invalidHandle? Could this race
>> > with mark_open_files_invalid()?
>> The attached patch may reduce the window of opportunity for the
>> race you describe. Do you think we need another flag? (one
>> to keep requests other than a write retry from using this
>> handle, and one to prevent reopen when the handle is about to be closed
>> after we have given up on write retries getting through?
>>
>
>
> So that I make sure I understand the problem...
>
> We have a file that is getting ready to be closed (closePend is set),
> but the tcon has been reconnected and the filehandle is now invalid.
> You only want to reopen the file in order to flush data out of the
> cache, but only if there are actually dirty pages to be flushed.
I don't think we have to worry about normal case of flushing dirty pages, that
happens already before we get to cifs_close (fput calls flush/fsync).
The case I was thinking about was a write on this handle that
has hung, reconnected, and we are waiting for this pending write to complete.
> If closePend is set then the userspace filehandle is already dead? No
> further pages can be dirtied, right?
They could be dirtied from other handles, and writepages picks
the first handle that it can since writepages does not
specify which handle to use (writepages won't pick a handle that
that is close pending and it may be ok on retry because we look
for a valid handle each time we retry so shouldn't pick this one)
> Rather than a new flag, I suggest checking for whether there are dirty
> pages attached to the inode. If so, then we'll want to reopen the file
> and flush it before finally closing it.
There shouldn't be dirty pages if this is the last handle on the inode
being closed
--
Thanks,
Steve
next prev parent reply other threads:[~2008-11-20 14:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-19 3:46 [PATCH] do not attempt to close cifs files which are already closed due to session reconnect Steve French
2008-11-19 12:04 ` Jeff Layton
2008-11-19 16:05 ` Steve French
2008-11-20 5:24 ` Steve French
2008-11-20 13:02 ` Jeff Layton
2008-11-20 14:04 ` Steve French [this message]
2008-11-20 14:39 ` Jeff Layton
2008-11-20 16:43 ` Steve French
2008-11-20 18:55 ` 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=524f69650811200604x2e1a5529k5bd1075ca5e53ed0@mail.gmail.com \
--to=smfrench@gmail.com \
--cc=jlayton@redhat.com \
--cc=linux-cifs-client@lists.samba.org \
--cc=linux-fsdevel@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).