From: Chandan Rajendra <chandan@linux.vnet.ibm.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: linux-unionfs@vger.kernel.org
Subject: Re: Unique st_ino/st_dev for non-samefs
Date: Tue, 06 Jun 2017 20:08:36 +0530 [thread overview]
Message-ID: <2513918.i5T46bDxsg@localhost.localdomain> (raw)
In-Reply-To: <CAOQ4uxiKwEWk3bJnWn=754RcS4eH0f+4nT33TzHGSdOV+d4Azw@mail.gmail.com>
On Monday, June 5, 2017 10:05:16 PM IST Amir Goldstein wrote:
> On Mon, Jun 5, 2017 at 6:07 PM, Chandan Rajendra
> <chandan@linux.vnet.ibm.com> wrote:
> >
> > Hi Amir,
> >
> > I realized only now that I misunderstood the problem statement. Now I am
> > confused. Apologies for bringing this up so late.
> >
> > With the code from ovl-constino branch, I see that ovl_getattr() already
> > generates unique and constant (for the duration of fs 'mount' cycle atleast)
> > combinations of (st_ino, st_dev).
> >
> > In the cover letter of the "Constant Inode numbers" patchset, you had
> > mentioned "System-wide unique st_dev;st_ino for non-samefs" as the
> > TODO. From the code in ovl_getattr() I feel that we are already generating
> > filesystem-wide unique combinations of (st_dev, st_ino).
> >
> > I understand that I am missing something here. Could you please point out the
> > case where we don't yet have system-wide unique (st_dev, st_ino) combination?
> >
>
> Sure. You are missing a subtle detail.
> From Documentation/filesystems/overlayfs.txt:
>
> "This approach is 'hybrid' because the objects that appear in the
> filesystem do not all appear to belong to that filesystem. In many
> cases an object accessed in the union will be indistinguishable
> from accessing the corresponding object from the original filesystem.
> This is most obvious from the 'st_dev' field returned by stat(2)."
>
> And for v4.12, I added this text:
> "In the special case of all overlay layers on the same underlying
> filesystem, all objects will report an st_dev from the overlay
> filesystem and st_ino from the underlying filesystem. This will
> make the overlay mount more compliant with filesystem scanners and
> overlay objects will be distinguishable from the corresponding
> objects in the original filesystem."
>
> So the case where we don't yet have system-wide unique (st_dev/st_ino)
> is the file /lower/foo has the same st_dev/st_ino as the file /mnt/foo,
> where /mnt is an overlay of /lower and /upper on not same fs.
> And what is worse, as Miklos pointed out is that after copy up,
> /mnt/foo with still have the same st_dev/st_ino as /lower/foo,
> but now they will have a different data and diff won't know it, because
> it does not bother to compare data when st_dev/st_ino are equal.
Amir, Thanks for the clarification. I was under the assumption that we would
not support the usecase wherein the userspace programs would access files on
overlayfs and files on the lowerdir simultaneously.
I have coded up the fake st_dev part. The fake st_devs are obtained using
get_anon_bdev(). I am now working on enhancing the tests.
>
> The solution is quite simple and therefore the task itself is quite simple,
> mostly the challenge is to write the tests for the use cases.
>
> All you need to do at overlay mount time, for non-samefs case, is to
> allocate a fake st_dev value for each layer (or for each unique fs) and
> store those values in the ovl_fs private struct.
>
> Then the code in ovl_getattr() will simply set those fake st_dev values
> instead of the rel values, for example:
>
> @@ -110,6 +110,8 @@ int ovl_getattr(const struct path *path, struct kstat *stat,
> }
> if (samefs)
> stat->dev = dentry->d_sb->s_dev;
> + else
> + stat->dev = ovl_fake_dev(stat->s_dev);
> } else {
> /*
> * Always use the overlay st_dev for directories, so 'find
>
> I am not sure how sdev id's are allocated for anonymous devices
> (like the overlay sdev itself), but it is possible to reserve a namespace for
> overlayfs then maybe the conversion ovl_fake_dev() can be static - I doubt it.
> More likely this would have to be a lookup in the fake id's by real id's map
> that you created at mount time.
>
> Let me know if you need more clarifications.
>
--
chandan
parent reply other threads:[~2017-06-06 14:39 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <CAOQ4uxiKwEWk3bJnWn=754RcS4eH0f+4nT33TzHGSdOV+d4Azw@mail.gmail.com>]
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=2513918.i5T46bDxsg@localhost.localdomain \
--to=chandan@linux.vnet.ibm.com \
--cc=amir73il@gmail.com \
--cc=linux-unionfs@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