[Bug 13991] New: rsync --delete --one-file-system skips deletes after crossing filesystems on destination.

samba-bugs at samba.org samba-bugs at samba.org
Sun Jun 9 21:04:30 UTC 2019


https://bugzilla.samba.org/show_bug.cgi?id=13991

            Bug ID: 13991
           Summary: rsync --delete --one-file-system skips deletes after
                    crossing filesystems on destination.
           Product: rsync
           Version: 3.1.3
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: core
          Assignee: wayne at opencoder.net
          Reporter: arden at metronet.co.uk
        QA Contact: rsync-qa at samba.org

When using rsync with the -x (or --one-file-system) option to sync to a
destination that crosses filesystems: --delete won't delete files in the second
filesystem.

Example done on a Centos7 machine where deleteme1 is left in the destination
after deleting from the source:

------------------

root at arden-lt ~]# ## Setup environment in lvm
root at arden-lt ~]# cd /tmp
[root at arden-lt tmp]# VG=vg_ardenkvm

[root at arden-lt tmp]# mkdir testsrc testdst
[root at arden-lt tmp]# lvcreate -l 1 $VG/lvtest1
  Volume group name expected (no slash)
  Run `lvcreate --help' for more information.
[root at arden-lt tmp]# lvcreate -l 1 -n lvtest1 $VG
  Logical volume "lvtest1" created.
[root at arden-lt tmp]# mkfs /dev/$VG/lvtest1
mke2fs 1.42.9 (28-Dec-2013)
Discarding device blocks: done                           
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
1024 inodes, 4096 blocks
204 blocks (4.98%) reserved for the super user
First data block=1
Maximum filesystem blocks=4194304
1 block group
8192 blocks per group, 8192 fragments per group
1024 inodes per group

Allocating group tables: done                           
Writing inode tables: done                           
Writing superblocks and filesystem accounting information: done

[root at arden-lt tmp]# mkdir testdst/test1
[root at arden-lt tmp]# mount /dev/$VG/lvtest1 testdst/test1

[root at arden-lt tmp]# mkdir testsrc/test1
[root at arden-lt tmp]# touch testsrc/deleteme testsrc/test1/deleteme1

[root at arden-lt tmp]# ## First sync with no problems

[root at arden-lt tmp]# rsync -axv --del testsrc/. testdst/.
sending incremental file list
./
deleteme
test1/
test1/deleteme1

sent 213 bytes  received 69 bytes  564.00 bytes/sec
total size is 0  speedup is 0.00
[root at arden-lt tmp]# \rm testsrc/deleteme testsrc/test1/deleteme1

[root at arden-lt tmp]# ## Second sync that should delete files

[root at arden-lt tmp]# rsync -axv --del testsrc/. testdst/.
sending incremental file list
deleting deleteme
./
test1/

sent 72 bytes  received 31 bytes  206.00 bytes/sec
total size is 0  speedup is 0.00

[root at arden-lt tmp]# ## Files on src

[root at arden-lt tmp]# find testsrc -print
testsrc
testsrc/test1

[root at arden-lt tmp]# ## Files on dest that should be the same as src, 
[root at arden-lt tmp]# ## but deleteme1 is still there

[root at arden-lt tmp]# find testdst -print
testdst
testdst/test1
testdst/test1/lost+found
testdst/test1/deleteme1

[root at arden-lt tmp]# ## Without -x it works as expected

[root at arden-lt tmp]# rsync -av --del testsrc/. testdst/.
sending incremental file list
deleting test1/lost+found/
deleting test1/deleteme1

sent 66 bytes  received 53 bytes  238.00 bytes/sec
total size is 0  speedup is 0.00
[root at arden-lt tmp]# find testdst -print
testdst
testdst/test1

[root at arden-lt tmp]# rsync --version
rsync  version 3.1.3  protocol version 31
Copyright (C) 1996-2018 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, no ACLs, xattrs, iconv, symtimes, prealloc

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.
[root at arden-lt tmp]# 

-----------------------
[OK it's not very good removing lost+found, but that's not the problem].

I think the problem is the code in delete_in_dir() in generator.c:
    if (one_file_system) {
        if (file->flags & FLAG_TOP_DIR)
            filesystem_dev = *fs_dev;
        else if (filesystem_dev != *fs_dev)
            return;
    }
As far as I can tell this is unnecessary. --one-file-system should only check
the source filesystems not the destination filesystems.

This code can cause worse problems too.  I haven't figured out the simplest way
of demonstrating it.  But if there are other filesystems mounted, deletes can
fail at the higher level as well - contact me if you want details.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.



More information about the rsync mailing list