# wierd: resize2fs hangs when enlarging loop dev on-line

## fpemud

First, I run ./a.sh:

```
fpemud-workstation test # cat a.sh 

dd if=/dev/zero of=abc.img bs=409600 count=1024 conv=sparse

mkfs.ext4 -O ^has_journal abc.img

mkdir mntdir

mount abc.img mntdir
```

Then, I run ./b.sh step by step manually:

```
fpemud-workstation test # cat b.sh

dd if=/dev/zero bs=102400 count=1024 >> abc.img

losetup -c /dev/loop0

resize2fs -p -f /dev/loop0

```

System hang on this command, it seems it hangs in ioctl.

top shows resize2fs use 100% of one cpu core, in system mode:

```
fpemud-workstation test # strace resize2fs /dev/loop0

execve("/sbin/resize2fs", ["resize2fs", "/dev/loop0"], [/* 64 vars */]) = 0

brk(NULL)                               = 0x1b57000

mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa128fc4000

access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)

open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3

fstat(3, {st_mode=S_IFREG|0644, st_size=235155, ...}) = 0

mmap(NULL, 235155, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fa128f8a000

close(3)                                = 0

open("/lib64/libe2p.so.2", O_RDONLY|O_CLOEXEC) = 3

read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\"\0\0\0\0\0\0"..., 832) = 832

fstat(3, {st_mode=S_IFREG|0755, st_size=32608, ...}) = 0

mmap(NULL, 2128584, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa128b9a000

mprotect(0x7fa128ba1000, 2093056, PROT_NONE) = 0

mmap(0x7fa128da0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7fa128da0000

close(3)                                = 0

open("/lib64/libext2fs.so.2", O_RDONLY|O_CLOEXEC) = 3

read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\3\1\0\0\0\0\0"..., 832) = 832

fstat(3, {st_mode=S_IFREG|0755, st_size=334824, ...}) = 0

mmap(NULL, 2430824, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa128948000

mprotect(0x7fa128997000, 2097152, PROT_NONE) = 0

mmap(0x7fa128b97000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4f000) = 0x7fa128b97000

close(3)                                = 0

open("/lib64/libcom_err.so.2", O_RDONLY|O_CLOEXEC) = 3

read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\25\0\0\0\0\0\0"..., 832) = 832

fstat(3, {st_mode=S_IFREG|0755, st_size=14456, ...}) = 0

mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa128f89000

mmap(NULL, 2109960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa128744000

mprotect(0x7fa128747000, 2093056, PROT_NONE) = 0

mmap(0x7fa128946000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7fa128946000

close(3)                                = 0

open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3

read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\7\2\0\0\0\0\0"..., 832) = 832

fstat(3, {st_mode=S_IFREG|0755, st_size=1664424, ...}) = 0

mmap(NULL, 3770584, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa1283ab000

mprotect(0x7fa12853b000, 2093056, PROT_NONE) = 0

mmap(0x7fa12873a000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18f000) = 0x7fa12873a000

mmap(0x7fa128740000, 14552, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fa128740000

close(3)                                = 0

open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3

read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220`\0\0\0\0\0\0"..., 832) = 832

fstat(3, {st_mode=S_IFREG|0755, st_size=131032, ...}) = 0

mmap(NULL, 2208808, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa12818f000

mprotect(0x7fa1281a6000, 2093056, PROT_NONE) = 0

mmap(0x7fa1283a5000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7fa1283a5000

mmap(0x7fa1283a7000, 13352, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fa1283a7000

close(3)                                = 0

mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa128f88000

mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa128f86000

arch_prctl(ARCH_SET_FS, 0x7fa128f86740) = 0

mprotect(0x7fa12873a000, 16384, PROT_READ) = 0

mprotect(0x7fa1283a5000, 4096, PROT_READ) = 0

mprotect(0x7fa128946000, 4096, PROT_READ) = 0

mprotect(0x7fa128b97000, 4096, PROT_READ) = 0

mprotect(0x7fa128da0000, 4096, PROT_READ) = 0

mprotect(0x60c000, 4096, PROT_READ)     = 0

mprotect(0x7fa128fc5000, 4096, PROT_READ) = 0

munmap(0x7fa128f8a000, 235155)          = 0

set_tid_address(0x7fa128f86a10)         = 10725

set_robust_list(0x7fa128f86a20, 24)     = 0

rt_sigaction(SIGRTMIN, {sa_handler=0x7fa128194b30, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7fa12819fec0}, NULL, 8) = 0

rt_sigaction(SIGRT_1, {sa_handler=0x7fa128194bc0, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7fa12819fec0}, NULL, 8) = 0

rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0

getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0

brk(NULL)                               = 0x1b57000

brk(0x1b78000)                          = 0x1b78000

open("/usr/lib64/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3

fstat(3, {st_mode=S_IFREG|0644, st_size=110518032, ...}) = 0

mmap(NULL, 110518032, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fa121829000

close(3)                                = 0

write(2, "resize2fs 1.43.3 (04-Sep-2016)\n", 31resize2fs 1.43.3 (04-Sep-2016)

) = 31

stat("/dev/loop0", {st_mode=S_IFBLK|0660, st_rdev=makedev(7, 0), ...}) = 0

open("/proc/swaps", O_RDONLY)           = 3

fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0

read(3, "Filename\t\t\t\tType\t\tSize\tUsed\tPrio"..., 1024) = 101

stat("/dev/sdd2", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 50), ...}) = 0

read(3, "", 1024)                       = 0

close(3)                                = 0

open("/proc/mounts", O_RDONLY|O_CLOEXEC) = 3

stat("/dev/loop0", {st_mode=S_IFBLK|0660, st_rdev=makedev(7, 0), ...}) = 0

futex(0x7fa128740fe8, FUTEX_WAKE_PRIVATE, 2147483647) = 0

fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0

read(3, "sysfs /sys sysfs rw,nosuid,nodev"..., 1024) = 1024

stat("/dev/bcache0", {st_mode=S_IFBLK|0660, st_rdev=makedev(253, 0), ...}) = 0

read(3, "memory 0 0\ncgroup /sys/fs/cgroup"..., 1024) = 1024

stat("/dev/sdd1", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 49), ...}) = 0

read(3, "824k,mode=700,uid=1000,gid=1000 "..., 1024) = 318

stat("/home/fpemud/workspace/syncupd/test/mntdir", {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0

close(3)                                = 0

stat("/dev/loop0", {st_mode=S_IFBLK|0660, st_rdev=makedev(7, 0), ...}) = 0

open("/dev/loop0", O_RDONLY|O_EXCL)     = -1 EBUSY (Device or resource busy)

open("/dev/loop0", O_RDWR)              = 3

fstat(3, {st_mode=S_IFBLK|0660, st_rdev=makedev(7, 0), ...}) = 0

close(3)                                = 0

open("/dev/loop0", O_RDONLY)            = 3

fstat(3, {st_mode=S_IFBLK|0660, st_rdev=makedev(7, 0), ...}) = 0

ioctl(3, BLKDISCARDZEROES, [1])         = 0

pread64(3, "\0\220\1\0\0@\6\0\0P\0\0`\4\6\0\365\217\1\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 1024, 1024) = 1024

pread64(3, "\6\1\0\0\26\1\0\0&\1\0\0\315\16\364\7\2\0\4\0\0\0\0\0\0\0\0\0\364\7\211l"..., 4096, 2048) = 4096

open("/dev/loop0", O_RDONLY)            = 4

uname({sysname="Linux", nodename="fpemud-workstation", ...}) = 0

ioctl(4, BLKGETSIZE64, [524288000])     = 0

close(4)                                = 0

open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 4

fstat(4, {st_mode=S_IFREG|0644, st_size=2997, ...}) = 0

read(4, "# Locale name alias data base.\n#"..., 4096) = 2997

read(4, "", 4096)                       = 0

close(4)                                = 0

open("/usr/share/locale/en_US.utf8/LC_MESSAGES/e2fsprogs.mo", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/share/locale/en_US/LC_MESSAGES/e2fsprogs.mo", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/share/locale/en.utf8/LC_MESSAGES/e2fsprogs.mo", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/share/locale/en/LC_MESSAGES/e2fsprogs.mo", O_RDONLY) = -1 ENOENT (No such file or directory)

fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0

write(1, "Filesystem at /dev/loop0 is moun"..., 109Filesystem at /dev/loop0 is mounted on /home/fpemud/workspace/syncupd/test/mntdir; on-line resizing required

) = 109

write(1, "old_desc_blocks = 4, new_desc_bl"..., 41old_desc_blocks = 4, new_desc_blocks = 4

) = 41

access("/sys/fs/ext4/features/meta_bg_resize", R_OK) = 0

open("/home/fpemud/workspace/syncupd/test/mntdir", O_RDONLY) = 4

ioctl(4, _IOC(_IOC_WRITE, 0x66, 0x10, 0x08), 0x7ffec9ea15b0

```

```
fpemud-workstation test # uname -a

Linux fpemud-workstation 4.5.5 #1 SMP PREEMPT Sun Nov 13 22:02:07 CST 2016 x86_64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz GenuineIntel GNU/Linux

```

```
fpemud-workstation test # resize2fs

resize2fs 1.43.3 (04-Sep-2016)

Usage: resize2fs [-d debug_flags] [-f] [-F] [-M] [-P] [-p] device [-b|-s|new_size] [-z undo_file]

```

Last edited by fpemud on Thu Jan 19, 2017 11:48 pm; edited 1 time in total

----------

## fpemud

I upgraded my kernel version to 4.9.4 yestoday, the problem still exists.

```
fpemud@fpemud-workstation ~ $ uname -a

Linux fpemud-workstation 4.9.4 #1 SMP PREEMPT Thu Jan 19 08:59:55 CST 2017 x86_64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz GenuineIntel GNU/Linux

fpemud@fpemud-workstation ~ $ 

```

Please, anyone can help? Is it possibly a kernel bug?

----------

## teika

Have you done this before "losetup -c"?

$ losetup /dev/loop0 abc.img 

a.sh doesn't have this line...

----------

## frostschutz

You should probably take this to a mailing list...

----------

