From: Paulo Alcantara <pc@manguebit.com>
To: David Howells <dhowells@redhat.com>
Cc: dhowells@redhat.com, Steve French <sfrench@samba.org>,
Shyam Prasad N <sprasad@microsoft.com>,
linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cifs: Fix reacquisition of volume cookie on still-live connection
Date: Wed, 17 Apr 2024 11:09:27 -0300 [thread overview]
Message-ID: <1a94a15e6863d3844f0bcb58b7b1e17a@manguebit.com> (raw)
In-Reply-To: <2713340.1713286722@warthog.procyon.org.uk>
David Howells <dhowells@redhat.com> writes:
> Paulo Alcantara <pc@manguebit.com> wrote:
>
>> Can't we just move the cookie acquisition to cifs_get_tcon() before it
>> gets added to list @ses->tcon_list. This way we'll guarantee that the
>> cookie is set only once for the new tcon.
>
> cifs_get_tcon() is used from more than one place and I'm not sure the second
> place (__cifs_construct_tcon()) actually wants a cookie. I'm not sure what
> that path is for.
__cifs_construct_tcon() is used for creating sessions and tcons under
multiuser mounts. Whenever an user accesses a multiuser mount and the
client can't find a credential for it, a new session and tcon will be
created for the user accessing the mount -- new accesses from same user
will end up reusing the created session and tcon.
And yes, I don't think we'll need a cookie for those tcons as the client
seems to get the fscache cookie from master tcon (the one created from
mount credentials).
> Could all the (re)setting up being done in cifs_mount_get_tcon() be
> pushed back into cifs_get_tcon()?
AFAICT, yes. I'd need to look into it to make sure that's safe.
>> Besides, do we want to share a tcon with two different superblocks that
>> have 'fsc' and 'nofsc', respectively? If not, it would be better to fix
>> match_tcon() as well to handle such case.
>
> Maybe? What does a tcon *actually* represent? I note that in
> cifs_match_super(), it's not the only criterion matched upon - so you can, at
> least in apparent theory, get different superblocks for the same tcon anyway.
tcon simply represents a tree connected SMB share. It can be either an
IPC share (\\srv\IPC$) or the actual share (\\srv\share) we're accessing
the files from.
Consider the following example where a tcon is reused from different
CIFS superblocks:
mount.cifs //srv/share /mnt/1 -o ${opts} # new super, new tcon
mount.cifs //srv/share/dir /mnt/2 -o ${opts} # new super, reused tcon
So, /mnt/1/dir/foo and /mnt/2/foo will lead to different inodes.
The two mounts are accessing the same tcon (\\srv\share) but the new
superblock was created because the prefix path "\dir" didn't match in
cifs_match_super(). Trust me, that's a very common scenario.
> This suggests that the tcon might not be the best place for the fscache volume
> cookie as you can have multiple inodes wishing to use the same file cookie if
> there are multiple mounts mounting the same tcon but, say, with different
> mount parameters.
We're not supposed to allow mounts with different parameters reusing
servers, sessions or tcons, so that should be no issue.
> I'm not sure what the right way around this is. The root of the problem is
> coherency management. If we make a change to an inode on one mounted
> superblock and this bounces a change notification over to the server that then
> pokes an inode in another mounted superblock on the same machine and causes it
> to be invalidated, you lose your local cache if both inodes refer to the same
> fscache cookie.
Yes, that could be a problem. Perhaps placing the fscache cookie in the
superblock would be a way to go, so we can handle the different fscache
cookies for the superblocks that contain different prefix paths and
access same tcon.
> Remember: fscache does not do this for you! It's just a facility by which
> which data can be stored and retrieved. The netfs is responsible for telling
> it when to invalidate and handling coherency.
ACK.
> That said, it might be possible to time-share a cookie on cifs with leases,
> but the local superblocks would have to know about each other - in which case,
> why are they separate superblocks?
See above why they could be separate superblocks.
next prev parent reply other threads:[~2024-04-17 14:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 15:21 [PATCH] cifs: Fix reacquisition of volume cookie on still-live connection David Howells
2024-04-04 16:07 ` Paulo Alcantara
2024-04-16 16:58 ` David Howells
2024-04-17 14:09 ` Paulo Alcantara [this message]
2024-04-17 14:38 ` David Howells
2024-04-17 18:59 ` Tom Talpey
2024-04-18 13:32 ` David Howells
2024-04-17 21:25 ` Paulo Alcantara
2024-04-18 13:43 ` David Howells
2024-04-19 20:04 ` Paulo Alcantara
2024-04-17 13:41 ` David Howells
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=1a94a15e6863d3844f0bcb58b7b1e17a@manguebit.com \
--to=pc@manguebit.com \
--cc=dhowells@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sfrench@samba.org \
--cc=sprasad@microsoft.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.