Bug 11317

Summary: Shrinking of size is failing while trying to reduce the disk size with LVM
Product: File System Reporter: Rishikesh K Rajak (risrajak)
Component: ext4Assignee: fs_ext4 (fs_ext4)
Status: REJECTED INVALID    
Severity: high CC: akpm, iranna.ankad, risrajak, sandeen
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.27-rc1 Subsystem:
Regression: --- Bisected commit-id:

Description Rishikesh K Rajak 2008-08-13 00:24:51 UTC
Latest working kernel version: 2.6.27-rc1


Steps to reproduce:
 - pvcreate /dev/sdb1
 - pvdisplay
 - vgcreate my_volg /dev/sdb1
 - vgdisplay
 - lvcreate -L 8G -n vol01 my_volg
 - lvdisplay
 - lvreduce -r -L 2G /dev/my_volg/vol01
 - lvdisplay
 - ./resize2fs /dev/my_volg/vol01
 - ./e2fsck -fnv /dev/my_volg/vol01

Note: Please let me know if i am executing wrong steps :(

==================================================
Error:
[root@e326 sbin]# ./e2fsck -f /dev/mynew_vg/vol01
e2fsck 1.41-WIP (17-Jun-2008)
The filesystem size (according to the superblock) is 11304960 blocks
The physical size of the device is 4194304 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort<y>? no

Pass 1: Checking inodes, blocks, and sizes
Error reading block 4194307 (Invalid argument) while getting next inode from scan.  Ignore error<y>? no

Error while scanning inodes (262144): Can't read next inode
e2fsck: aborted
[root@e326 sbin]#
=============================================================

Additional info:

[root@e326 sbin]# lvreduce
[root@e326 sbin]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext2 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/mapper/my_volg-vol01 on /mnt type ext4dev (rw)
[root@e326 sbin]# umount /mnt/tmpmount/
[root@e326 sbin]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              15G   14G   62M 100% /
/dev/sda1             487M   36M  426M   8% /boot
tmpfs                 948M     0  948M   0% /dev/shm
[root@e326 sbin]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/my_volg/vol01
  VG Name                my_volg
  LV UUID                strpPN-Lwvo-eHTZ-Skrs-iEHE-RdOO-bPM0eE
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                10.78 GB
  Current LE             2760
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

[root@e326 sbin]# lvreduce -L 4G /dev/mynew_vg/vol01
  WARNING: Reducing active logical volume to 4.00 GB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vol01? [y/n]: y
  Reducing logical volume vol01 to 4.00 GB
  Logical volume vol01 successfully resized
[root@e326 sbin]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/my_volg/vol01
  VG Name                my_volg
  LV UUID                strpPN-Lwvo-eHTZ-Skrs-iEHE-RdOO-bPM0eE
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                4.00 GB
  Current LE             1024
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

[root@e326 sbin]# mount -t ext4dev -o extents /dev/my_volg/vol01 /mnt
[root@e326 sbin]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              15G   14G   62M 100% /
/dev/sda1             487M   36M  426M   8% /boot
tmpfs                 948M     0  948M   0% /dev/shm
/dev/mapper/mynew_vg-vol01
                       11G   36M   11G   1% /mnt
[root@e326 sbin]# umount /mnt/tmpmount/
[root@e326 sbin]# ./resize2fs /dev/mynew_vg/vol01
resize2fs 1.41-WIP (17-Jun-2008)
Please run 'e2fsck -f /dev/mynew_vg/vol01' first.

[root@e326 sbin]# ./e2fsck -f /dev/mynew_vg/vol01
e2fsck 1.41-WIP (17-Jun-2008)
The filesystem size (according to the superblock) is 11304960 blocks
The physical size of the device is 4194304 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort<y>? no

Pass 1: Checking inodes, blocks, and sizes
Error reading block 4194307 (Invalid argument) while getting next inode from scan.  Ignore error<y>? no

Error while scanning inodes (262144): Can't read next inode
e2fsck: aborted
[root@e326 sbin]#
Comment 1 Andrew Morton 2008-08-13 01:02:47 UTC
> Latest working kernel version: 2.6.27-rc1

This means that 2.6.27-rc1 works, and also doesn't work.  Please clarify.
Comment 2 Rishikesh K Rajak 2008-08-13 01:16:03 UTC
(In reply to comment #1)
> > Latest working kernel version: 2.6.27-rc1
> 
> This means that 2.6.27-rc1 works, and also doesn't work.  Please clarify.
> 

oops sorry, it is typo, 2.6.27-rc1 kernel does not work.

-Rishi
Comment 3 Andrew Morton 2008-08-13 01:21:32 UTC
OK, so which kernel _did_ work?
Comment 4 Rishikesh K Rajak 2008-08-13 01:26:36 UTC
(In reply to comment #3)
> OK, so which kernel _did_ work?
> 
Hi Andrew,

I did not test with the older kernel since ext4 patches has gone recently, but planning to test with 2.6.27-rc2 and if the problem still exist will let you know.

-Rishi
Comment 5 Eric Sandeen 2008-08-13 08:13:50 UTC
In the original comment, I do not see a mkfs step in the reproducer.  Where was mkfs done?

Off the top of my head, it looks like you are reducing the size of the block device before you are running resize2fs; that won't work... you have to shrinkg the FS, then the device it's on.
Comment 6 Eric Sandeen 2008-08-13 08:17:50 UTC
[root@e326 sbin]# mount
...
/dev/mapper/my_volg-vol01 on /mnt type ext4dev (rw)

[root@e326 sbin]# umount /mnt/tmpmount/

[root@e326 sbin]# df -h
(unfortunately current size of ext4 fs is not shown)

First you slice off the end of the block device:

[root@e326 sbin]# lvreduce -L 4G /dev/mynew_vg/vol01
  WARNING: Reducing active logical volume to 4.00 GB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vol01? [y/n]: y
  Reducing logical volume vol01 to 4.00 GB
  Logical volume vol01 successfully resized

(bells should be going off here!)

*then* you try to shrink the fs:

[root@e326 sbin]# ./resize2fs /dev/mynew_vg/vol01
resize2fs 1.41-WIP (17-Jun-2008)
Please run 'e2fsck -f /dev/mynew_vg/vol01' first.

and it finds that your block device is smaller than your fs:

[root@e326 sbin]# ./e2fsck -f /dev/mynew_vg/vol01
e2fsck 1.41-WIP (17-Jun-2008)
The filesystem size (according to the superblock) is 11304960 blocks
The physical size of the device is 4194304 blocks

You need to resize the fs, then resize the block device it's on.

This looks like user error to me.
Comment 7 Theodore Tso 2008-08-13 11:50:19 UTC
I'm not even sure why this was filed as a kernel bug, since the filesystem was unmounted at the time, and this is purely an e2fsprogs issue.   It's still a user error, though, since the main issue, as Eric has correctly pointed out, is that you have to shrink the filesystem before you shrink the device.   A few seconds worth of thought should make it clear why this should be obvious...

BTW, e2fsprogs specific bugs, should you wish to submit them to a bug tracker, can be sent to http://sourceforge.net/projects/e2fsprogs.  (Or to the Debian BTS if you are using a Debian distribution, or the Fedora bugzilla if you are using Fedora, etc.)

Note also that you are using a relatively old e2fsprogs (a 1.41 pre-release), and e2fpsrogs 1.41 is already out.   Please see http://ext4.wiki.kernel.org for more information about ext4.  We're trying to keep it much more up to date.  In particular, the Howto has up-to-date instructions on how to best use ext4.  (In particular, you don't need to specify -o extents as a mount option; that's superfluous these days.)   Also note the IRC and the ext4 mailing list. Those are both great resources if you need some help getting started or are puzzled about why something isn't working.

Thanks, regards,