linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: asmadeus@codewreck.org
To: Christian Schoenebeck <linux_oss@crudebyte.com>
Cc: David Kahurani <k.kahurani@gmail.com>,
	davem@davemloft.net, ericvh@gmail.com, kuba@kernel.org,
	linux-kernel@vger.kernel.org, lucho@ionkov.net,
	netdev@vger.kernel.org, v9fs-developer@lists.sourceforge.net,
	David Howells <dhowells@redhat.com>
Subject: Re: 9p fscache Duplicate cookie detected (Was: [syzbot] WARNING in p9_client_destroy)
Date: Sat, 26 Mar 2022 22:35:14 +0900	[thread overview]
Message-ID: <Yj8WkjT+MsdFIfwr@codewreck.org> (raw)
In-Reply-To: <2582025.XdajAv7fHn@silver>

(+David Howells in Cc as he's knows how that works better than me;
 -syzbot lists as it doesn't really concern this bug)

Christian Schoenebeck wrote on Sat, Mar 26, 2022 at 01:36:31PM +0100:
> BTW, another issue that I am seeing for a long time affects the fs-cache: When
> I use cache=mmap then things seem to be harmless, I periodically see messages
> like these, but that's about it:
> 
> [90763.435562] FS-Cache: Duplicate cookie detected
> [90763.436514] FS-Cache: O-cookie c=00dcb42f [p=00000003 fl=216 nc=0 na=0]
> [90763.437795] FS-Cache: O-cookie d=0000000000000000{?} n=0000000000000000
> [90763.440096] FS-Cache: O-key=[8] 'a7ab2c0000000000'
> [90763.441656] FS-Cache: N-cookie c=00dcb4a7 [p=00000003 fl=2 nc=0 na=1]
> [90763.446753] FS-Cache: N-cookie d=000000005b583d5a{9p.inode} n=00000000212184fb
> [90763.448196] FS-Cache: N-key=[8] 'a7ab2c0000000000'

hm, fscache code shouldn't be used for cache=mmap, I'm surprised you can
hit this...

> The real trouble starts when I use cache=loose though, in this case I get all
> sorts of misbehaviours from time to time, especially complaining about invalid
> file descriptors.

... but I did encouter these on cache=loose/fscache, although I hadn't
noticed any bad behaviour such as invalid file descriptors.

> Any clues?

Since I hadn't noticed real harm I didn't look too hard into it, I have
a couple of ideas:
- the cookie is just a truncated part of the inode number, it's possible
we get real collisions because there are no guarantees there won't be
identical inodes there.
In particular, it's trivial to reproduce by exporting submounts:

## on host in export directory
# mount -t tmpfs tmpfs m1
# mount -t tmpfs tmpfs m2
# echo foo > m1/a
# echo bar > m2/a
# ls -li m1 m2
m1:
total 4
2 -rw-r--r-- 1 asmadeus users 4 Mar 26 22:23 a

m2:
total 4
2 -rw-r--r-- 1 asmadeus users 4 Mar 26 22:23 a

## on client
# /mnt/t/m*/a
foo
bar
FS-Cache: Duplicate cookie detected
FS-Cache: O-cookie c=0000099a [fl=4000 na=0 nA=0 s=-]
FS-Cache: O-cookie V=00000006 [9p,tmp,]
FS-Cache: O-key=[8] '0200000000000000'
FS-Cache: N-cookie c=0000099b [fl=0 na=0 nA=0 s=-]
FS-Cache: N-cookie V=00000006 [9p,tmp,]
FS-Cache: N-key=[8] '0200000000000000'


But as you can see despite the warning the content is properly
different, and writing also works, so this probably isn't it... Although
the fscache code we're using is totally different -- your dmesg output
is from the "pre-netfs" code, so that might have gotten fixed as a side
effect?


- lifecycle différence between inode and fscache entry.
David pushed a patch a few years back to address this but it looks like
it never got merged:
https://lore.kernel.org/lkml/155231584487.2992.17466330160329385162.stgit@warthog.procyon.org.uk/

the rationale is that we could evict the inode then reallocate it, and
it'd generate a new fscache entry with the same key before the previous
fscache entry had been freed.
I'm not sure if that got fixed otherwise and it might not be possible
anymore, I didn't follow that, but given 


 - some other bug...

If you have some kind of reproducer of invalid filedescriptor or similar
errors I'd be happy to dig a bit more, I don't particularly like all
aspect of our cache model but it's not good if it corrupts things.

-- 
Dominique

  reply	other threads:[~2022-03-26 13:35 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAAZOf26g-L2nSV-Siw6mwWQv1nv6on8c0fWqB4bKmX73QAFzow@mail.gmail.com>
2022-03-26 11:46 ` [syzbot] WARNING in p9_client_destroy David Kahurani
2022-03-26 11:48 ` Christian Schoenebeck
2022-03-26 12:24   ` asmadeus
2022-03-26 12:36     ` Christian Schoenebeck
2022-03-26 13:35       ` asmadeus [this message]
2022-03-30 12:21         ` 9p fs-cache tests/benchmark (was: 9p fscache Duplicate cookie detected) Christian Schoenebeck
2022-03-30 21:47           ` asmadeus
2022-04-01 14:19             ` Christian Schoenebeck
2022-04-01 23:11               ` asmadeus
2022-04-02 12:43                 ` Christian Schoenebeck
2022-04-11  8:10               ` David Howells
2022-04-11  7:59             ` David Howells
2022-04-09 11:16           ` Christian Schoenebeck
2022-04-10 16:18             ` Christian Schoenebeck
2022-04-10 22:54               ` asmadeus
2022-04-11 13:41                 ` Christian Schoenebeck
2022-04-12 22:38                   ` asmadeus
2022-04-14 12:44                     ` Christian Schoenebeck
2022-04-17 12:56                       ` asmadeus
2022-04-17 13:52                         ` Christian Schoenebeck
2022-04-17 21:22                           ` asmadeus
2022-04-17 22:17                             ` 9p EBADF with cache enabled (Was: 9p fs-cache tests/benchmark (was: 9p fscache Duplicate cookie detected)) asmadeus
2022-04-21 10:36                               ` David Howells
2022-04-21 11:36                                 ` Christian Schoenebeck
2022-04-22 13:13                                   ` asmadeus
2022-04-25 14:10                                     ` David Howells
2022-04-26 15:38                                       ` Christian Schoenebeck
2022-05-03 10:21                                         ` asmadeus
2022-05-04 18:33                                           ` Christian Schoenebeck
2022-05-04 21:48                                             ` asmadeus
2022-05-06 19:14                                               ` Christian Schoenebeck
2022-06-03 16:46                                                 ` Christian Schoenebeck
2022-06-12 10:02                                                   ` asmadeus
2022-06-14  3:38                                                     ` [PATCH] 9p: fix EBADF errors in cached mode Dominique Martinet
2022-06-14  3:41                                                       ` Dominique Martinet
2022-06-14 12:10                                                         ` Christian Schoenebeck
2022-06-14 12:45                                                           ` Dominique Martinet
2022-06-14 14:11                                                             ` Christian Schoenebeck
2022-06-16 13:35                                                               ` Christian Schoenebeck
2022-06-16 13:51                                                                 ` Dominique Martinet
2022-06-16 14:11                                                                   ` Dominique Martinet
2022-06-16 20:14                                                                     ` Christian Schoenebeck
2022-06-16 20:53                                                                       ` Dominique Martinet
2022-06-16 21:10                                                                       ` [PATCH v3] " Dominique Martinet
2022-06-20 12:47                                                                         ` Christian Schoenebeck
2022-06-20 20:34                                                                           ` Dominique Martinet
2022-06-21 12:13                                                                             ` Christian Schoenebeck
2022-06-16 13:52                                                                 ` [PATCH v2] " Dominique Martinet

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=Yj8WkjT+MsdFIfwr@codewreck.org \
    --to=asmadeus@codewreck.org \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=ericvh@gmail.com \
    --cc=k.kahurani@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux_oss@crudebyte.com \
    --cc=lucho@ionkov.net \
    --cc=netdev@vger.kernel.org \
    --cc=v9fs-developer@lists.sourceforge.net \
    /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).