All of lore.kernel.org
 help / color / mirror / Atom feed
From: Atom2 <ariel.atom2@web2web.at>
To: Xu Wang <xuw@redhat.com>, hujianyang <hujianyang@huawei.com>
Cc: linux-unionfs@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>
Subject: Re: stat inconsistency with overlayfs
Date: Mon, 02 Mar 2015 21:45:54 +0100	[thread overview]
Message-ID: <54F4CC02.3040808@web2web.at> (raw)
In-Reply-To: <37851744.28042779.1424933137550.JavaMail.zimbra@redhat.com>

Hi Xu,
thanks for your follow-up.
Am 26.02.15 um 07:45 schrieb Xu Wang:
> Hi, Hu, Atom2,
>
>> I don't have the Overlayfs code on 3.11 or 3.13. I've lookup the v11
>> code in Miklos's git tree:
> Fortunately I got the overlay fs code of kernel V3.18, which is mostly
> same to v11 code in Miklos's git.
>
> 135 static int ovl_dir_getattr(struct vfsmount *mnt, struct dentry *dentry,
> 136              struct kstat *stat)
> 137 {
> 138     int err;
> 139     enum ovl_path_type type;
> 140     struct path realpath;
> 141
> 142     type = ovl_path_real(dentry, &realpath);
> 143     err = vfs_getattr(&realpath, stat);
> 144     if (err)
> 145         return err;
> 146
> 147     stat->dev = dentry->d_sb->s_dev;
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ here set dev number as Hu mentioned
> 148     stat->ino = dentry->d_inode->i_ino;
> 149
> 150     /*
> 151      * It's probably not worth it to count subdirs to get the
> 152      * correct link count.  nlink=1 seems to pacify 'find' and
> 153      * other utilities.
> 154      */
> 155     if (type == OVL_PATH_MERGE)
> 156         stat->nlink = 1;
> 157
> 158     return 0;
> 159 }
>
> And the d_sb->s_dev is coming from the super_block of overlayfs, which is fake.
> The super block s_dev is initialized by the call trace
> "mount_nodev->set_anon_super-->get_anon_bdev".
>
> Either the dir exists in lower or exists in upper, the overlay fs fakes it exits in
> overlay, which holds the fake device number.
I see what you are saying and code-wise that seems to be the cause of 
the behaviour I am seeing. I am, however, still not convinced at all 
that this is the correct/to be expected behaviour.

Giving this some further thought, might this not create more issues 
further down the line: In my (granted: limited) understanding the 
device/i-number combination must be unique across all mounted 
file-systems. Now does this also mean that the i-number is faked as 
well? In other words what is going to happen if the i-number of the 
directory residing in the upperdir (but wrongly attributed to the 
lowerdir) is identical to an i-number of another existing entry in the 
lowerdir?

Finally, stat, as I understand it, amongst other pieces of information 
also provides information about the device an entry resides on and that 
information, IMHO, simply is plain wrong for directories only existing 
on the upperdir.

Thanks Atom2

  reply	other threads:[~2015-03-02 20:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-20 18:15 stat inconsistency with overlayfs Atom2
2015-02-26  5:25 ` hujianyang
2015-02-26  6:45   ` Xu Wang
2015-03-02 20:45     ` Atom2 [this message]
2015-03-03 15:14       ` Miklos Szeredi
2015-03-03 17:12         ` Atom2
2015-03-04  2:24           ` hujianyang
2015-03-04 11:06           ` Miklos Szeredi
2015-03-02 20:45   ` Atom2

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=54F4CC02.3040808@web2web.at \
    --to=ariel.atom2@web2web.at \
    --cc=hujianyang@huawei.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=xuw@redhat.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.