Linux-FSCrypt Archive mirror
 help / color / mirror / Atom feed
From: Xiubo Li <xiubli@redhat.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: idryomov@gmail.com, ceph-devel@vger.kernel.org,
	jlayton@kernel.org, khiremat@redhat.com,
	linux-fscrypt@vger.kernel.org
Subject: Re: [PATCH] ceph: make sure all the files successfully put before unmounting
Date: Fri, 30 Dec 2022 13:44:11 +0800	[thread overview]
Message-ID: <8443166a-7182-7777-a489-14b5dab20bd5@redhat.com> (raw)
In-Reply-To: <Y64oe9c9U1+Y98yt@sol.localdomain>

Hi Eric,

Happy New Year!

Yeah, it's a ceph side bug and I have sent a patch to fix it [1].

When unmounting and just before closing the sessions the cephfs server 
still could send cap message to kceph and it will hold the inodes. So 
the unmount will skip them.

IMO it still makes sense to improve the vfs code because I hit a crash 
after this happening but just one time.

[1] 
https://patchwork.kernel.org/project/ceph-devel/patch/20221221093031.132792-1-xiubli@redhat.com/

Thanks

- Xiubo


On 30/12/2022 07:53, Eric Biggers wrote:
> Hi Xiubo,
>
> On Fri, Dec 02, 2022 at 03:04:58PM +0800, Xiubo Li wrote:
>> On 02/12/2022 12:19, Eric Biggers wrote:
>>> On Fri, Dec 02, 2022 at 09:49:49AM +0800, Xiubo Li wrote:
>>>> On 02/12/2022 05:10, Eric Biggers wrote:
>>>>> On Thu, Dec 01, 2022 at 11:18:33AM -0800, Eric Biggers wrote:
>>>>>> On Thu, Dec 01, 2022 at 02:58:00PM +0800, xiubli@redhat.com wrote:
>>>>>>> From: Xiubo Li <xiubli@redhat.com>
>>>>>>>
>>>>>>> When close a file it will be deferred to call the fput(), which
>>>>>>> will hold the inode's i_count. And when unmounting the mountpoint
>>>>>>> the evict_inodes() may skip evicting some inodes.
>>>>>>>
>>>>>>> If encrypt is enabled the kernel generate a warning when removing
>>>>>>> the encrypt keys when the skipped inodes still hold the keyring:
>>>>>> This does not make sense.  Unmounting is only possible once all the files on the
>>>>>> filesystem have been closed.
>>>>>>
>>>>> Specifically, __fput() puts the reference to the dentry (and thus the inode)
>>>>> *before* it puts the reference to the mount.  And an unmount cannot be done
>>>>> while the mount still has references.  So there should not be any issue here.
>>>> Eric,
>>>>
>>>> When I unmounting I can see the following logs, which I added a debug log in
>>>> the evcit_inodes():
>>>>
>>>> diff --git a/fs/inode.c b/fs/inode.c
>>>> index b608528efd3a..f6e69b778d9c 100644
>>>> --- a/fs/inode.c
>>>> +++ b/fs/inode.c
>>>> @@ -716,8 +716,11 @@ void evict_inodes(struct super_block *sb)
>>>>    again:
>>>>           spin_lock(&sb->s_inode_list_lock);
>>>>           list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) {
>>>> -               if (atomic_read(&inode->i_count))
>>>> +               if (atomic_read(&inode->i_count)) {
>>>> +                       printk("evict_inodes inode %p, i_count = %d, was
>>>> skipped!\n",
>>>> +                              inode, atomic_read(&inode->i_count));
>>>>                           continue;
>>>> +               }
>>>>
>>>>                   spin_lock(&inode->i_lock);
>>>>                   if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) {
>>>>
>>>> The logs:
>>>>
>>>> <4>[   95.977395] evict_inodes inode 00000000f90aab7b, i_count = 1, was
>>>> skipped!
>>>>
>>>> Any reason could cause this ? Since the inode couldn't be evicted in time
>>>> and then when removing the master keys it will print this warning.
>>>>
>>> It is expected for evict_inodes() to see some inodes with nonzero refcount, but
>>> they should only be filesystem internal inodes.  For example, with ext4 this
>>> happens with the journal inode.
>>>
>>> However, filesystem internal inodes cannot be encrypted, so they are irrelevant
>>> here.
>>>
>>> I'd guess that CephFS has a bug where it is leaking a reference to a user inode
>>> somewhere.
>> I also added some debug logs to tracker all the inodes in ceph, and all the
>> requests has been finished.
>>
>> I will debug it more to see whether it's leaking a reference here.
>>
>> Thanks Eric.
>>
> Any progress on tracking this down?
>
> - Eric
>


  reply	other threads:[~2022-12-30  5:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01  6:58 [PATCH] ceph: make sure all the files successfully put before unmounting xiubli
2022-12-01 13:04 ` Ilya Dryomov
2022-12-01 13:52   ` Xiubo Li
2022-12-01 19:18 ` Eric Biggers
2022-12-01 21:10   ` Eric Biggers
2022-12-02  1:49     ` Xiubo Li
2022-12-02  4:19       ` Eric Biggers
2022-12-02  7:04         ` Xiubo Li
2022-12-29 23:53           ` Eric Biggers
2022-12-30  5:44             ` Xiubo Li [this message]
2022-12-02  1:51   ` Xiubo Li

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=8443166a-7182-7777-a489-14b5dab20bd5@redhat.com \
    --to=xiubli@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=ebiggers@kernel.org \
    --cc=idryomov@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=khiremat@redhat.com \
    --cc=linux-fscrypt@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 read-only IMAP folder(s) and NNTP newsgroup(s).