*** before mount ... 17M -rw-r--r-- 1 root root 1001M Oct 17 13:32 /root/lp1381961/sparse-file *** copy files ... *** sync ... *** du before trim... 16K /root/lp1381961/mnt/lost+found 342M /root/lp1381961/mnt/.jd_home 342M /root/lp1381961/mnt *** before trim ... 364M -rw-r--r-- 1 root root 1001M Oct 17 13:32 /root/lp1381961/sparse-file /root/lp1381961/mnt: 656330752 bytes were trimmed *** after trim ... 4.1M -rw-r--r-- 1 root root 1001M Oct 17 13:32 /root/lp1381961/sparse-file *** du after trim... 16K /root/lp1381961/mnt/lost+found 342M /root/lp1381961/mnt/.jd_home 342M /root/lp1381961/mnt *** after umount ... 4.1M -rw-r--r-- 1 root root 1001M Oct 17 13:32 /root/lp1381961/sparse-file fsck from util-linux 2.20.1 e2fsck 1.42.9 (4-Feb-2014) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information
23615 inodes used (36.90%, out of 64000) 2 non-contiguous files (0.0%) 14 non-contiguous directories (0.1%) # of inodes with ind/dind/tind blocks: 0/0/0 Extent depth histogram: 23605/2 95763 blocks used (37.41%, out of 256000) 0 bad blocks 1 large file 22267 regular files 1339 directories 0 character device files 0 block device files 0 fifos 0 links 0 symbolic links (0 fast symbolic links) 0 sockets ------------ 23606 files -- You received this bug notification because you are a member of Kernel Packages, which is subscribed to linux in Ubuntu. https://bugs.launchpad.net/bugs/1381968 Title: Fstrim destroys data on loopback device Status in “linux” package in Ubuntu: Confirmed Bug description: I've upgraded Ubuntu Server 12.04 LTS to 14.04 LTS. The setup contains a loopback device (/dev/loop3) mounted into a software raid 1 (/dev/md2). After the weekly cronjob (/etc/cron.weekly/fstrim) ran, I've discovered that it wiped all data on the loopback device from the raid. fstrim-all skips check because the loopback device is part of device mapper raid. if [ "${REALDEV#/dev/dm-}" != "$REALDEV" ]; then echo "device $DEV is on devmapper, skipping TRIM feature check" Issue can be reproduced on raid setup and plain loopback mount setup! Here is step-by-step how to reproduce the issue: 1.) create sparse image file dd of=/sparse-file bs=1k seek=1024000 2.) losetup loopback device losetup /dev/loop3 /sparse-file 3.) create raid1 mdadm --create /dev/md2 --auto md --level=1 --raid-devices=1 /dev/loop3 4.) create fs mkfs.ext4 /dev/md2 4.1.) check sparse-file size ls -lash /sparse-file 5.) mount and copy data mount /dev/md2 /mnt copy some random files on /mnt 5.1.) check sparse-file size again ls -lash /sparse-file -> size indicates it contains the copied data 6.) destroy loopback via fstrim fstrim -v /mnt 7.) data is wiped umount /mnt ls -lash /sparse-file -> size indicates that all data is wiped out! fsck -v -f /dev/md2 -> will report infinite errors on filesystem I could not find any similiar bugreport. Best Regards Daniel To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1381968/+subscriptions -- Mailing list: https://launchpad.net/~kernel-packages Post to : kernel-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~kernel-packages More help : https://help.launchpad.net/ListHelp