All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Weirdness with bind mounts and moving files from tmpfs
Date: Thu, 13 Apr 2023 17:23:13 -0700	[thread overview]
Message-ID: <ZDic8fx1NQirB2+d@hoboy.vegasvil.org> (raw)

Dear list,

If a file is copied from tmpfs onto a bind mount, the contents update
as expected.  However if a file is _moved_ from tmpfs onto a bind
mount, the old content persists.

For example, my PC has a tmpfs on /run:

    # findmnt /run
    TARGET SOURCE FSTYPE OPTIONS
    /run   tmpfs  tmpfs  rw,nosuid,nodev,noexec,relatime,size=5737612k,mode=755,inode64

Set up a bind mounted file...

    # touch /opt/file
    # echo one > /home/file
    # mount -o bind /home/file /opt/file
    # cat /opt/file
    one

Coping a file onto the bind mount via the tmpfs on /run yields...

    # echo two > /run/file
    # cp /run/file /home/file
    # cat /opt/file
    two

So far, so good.  Now do the same, but with 'mv' instead of 'cp'...

    # echo three > /run/file
    # mv /run/file /home/file
    # cat /opt/file
    two

At this point, the contents of /opt/file are stuck forever with "two"...

    # echo three > /run/file
    # cp /run/file /home/file
    # cat /opt/file
    two
    # echo three > /home/file
    # cat /opt/file
    two

What is going on here?  Is this a bug or a feature?

Thanks,
Richard


             reply	other threads:[~2023-04-14  0:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14  0:23 Richard Cochran [this message]
2023-04-14  2:55 ` Weirdness with bind mounts and moving files from tmpfs Al Viro

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=ZDic8fx1NQirB2+d@hoboy.vegasvil.org \
    --to=richardcochran@gmail.com \
    --cc=linux-kernel@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 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.