linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "NeilBrown" <neilb@suse.de>
To: "Martin Steigerwald" <martin@lichtvoll.de>
Cc: linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: Assumption on fixed device numbers in Plasma's desktop search Baloo
Date: Sat, 26 Jun 2021 10:54:09 +1000	[thread overview]
Message-ID: <162466884942.28671.6997551060359774034@noble.neil.brown.name> (raw)
In-Reply-To: <41661070.mPYKQbcTYQ@ananda>

On Sat, 26 Jun 2021, Martin Steigerwald wrote:
> Hi!
> 
> I found repeatedly that Baloo indexes the same files twice or even more 
> often after a while.
> 
> I reported this upstream in:
> 
> Bug 438434 - Baloo appears to be indexing twice the number of files than 
> are actually in my home directory 
> 
> https://bugs.kde.org/show_bug.cgi?id=438434
> 
> And got back that if the device number changes, Baloo will think it has 
> new files even tough the path is still the same. And found over time that 
> the device number for the single BTRFS filesystem on a NVMe SSD in a 
> ThinkPad T14 Gen1 AMD can change. It is not (maybe yet) RAID 1. I do 
> have BTRFS RAID 1 in another laptop and there I also had this issue 
> already.
> 
> I argued that a desktop application has no business to rely on a device 
> number and got back that search/indexing is in the middle between an 
> application and system software.

NO SOFTWARE can rely on device numbers being stable in Linux.  Not
desktop, not system, not anything.  They are stable while the device is
in use (e.g. while the filesystem is mounted) but can definitely change
on reboot.  This has been the case since about Linux 2.4.

>                                  And that Baloo needs an "invariant" for 
> a file. See comment #11 of that bug report:

That is really hard to provide in general.  Possibly the best approach
is to use the statfs() systemcall to get the "f_fsid" field.  This is
64bits.  It is not supported uniformly well by all filesystems, but I
think it is at least not worse than using the device number.  For a lot
of older filesystems it is just an encoding of the device number.

For btrfs, xfs, ext4 it is much much better.

NeilBrown


> 
> https://bugs.kde.org/show_bug.cgi?id=438434#c11
> 
> I got the suggestion to try to find a way to tell the kernel to use a 
> fixed device number. 
> 
> I still think, an application or an infrastructure service for a desktop 
> environment or even anything else in user space should not rely on a 
> device number to be fixed and never change upon reboots.
> 
> But maybe you have a different idea about that and it is okay for an 
> userspace component to do that. I would like to hear your idea about 
> that.
> 
> Another question would be whether I could somehow make sure that the 
> device number does not change, even if just as a work-around. I know for 
> NFS there is a fsid= mount option, but it does not appear to be 
> something generic, at least the mount man page seems to have nothing 
> related to fsid.
> 
> 
> Best,
> -- 
> Martin
> 
> 
> 

  parent reply	other threads:[~2021-06-26  0:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-25 19:06 Assumption on fixed device numbers in Plasma's desktop search Baloo Martin Steigerwald
2021-06-26  0:27 ` Qu Wenruo
2021-06-26  8:49   ` Martin Steigerwald
2021-06-26  9:33     ` Qu Wenruo
2021-06-26 10:18       ` Martin Steigerwald
2021-06-26  0:54 ` NeilBrown [this message]
2021-06-26  3:38   ` Bart Van Assche
2021-06-26  5:17     ` NeilBrown
2021-06-26  6:14       ` Andrei Borzenkov
2021-06-26  6:24         ` Qu Wenruo
2021-06-26  8:51   ` Martin Steigerwald

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=162466884942.28671.6997551060359774034@noble.neil.brown.name \
    --to=neilb@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=martin@lichtvoll.de \
    /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).