Bug 1386494

Summary: [WALA][RHEL-7] waagent fails to run "swapon" in xfs file system
Product: Red Hat Enterprise Linux 7 Reporter: Yuxin Sun <yuxisun>
Component: WALinuxAgentAssignee: Miroslav Rezanina <mrezanin>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: borisb, brendand, danis, hkrijger, jopoulso, leiwang, salmy, stephen.zarkos, wshi, yuxisun
Target Milestone: rcKeywords: Extras, Tracking
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: WALinuxAgent-2.2.4 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-07 08:51:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Yuxin Sun 2016-10-19 05:56:53 UTC
Description of problem:
If set resource disk file system as "xfs", the waagent fails to run "swapon" to the swapfile. "ERROR Result:swapon: /mnt/resource/swapfile: swapon failed: Invalid argument"

Version-Release number of selected component (if applicable):
WALinuxAgent-2.2.0

RHEL Version: RHEL-7.3-20161005.0

How reproducible:
100%

Steps to Reproduce:
1. Prepare a VM with WALA-2.2.0 installed on ASM mode.
2. Set "ResourceDisk.Filesystem=xfs" in the /etc/waagent.conf
3. Deprovision. Shutdown this VM. Capture a generalized image from this VM.
4. Create a new VM base on this image.
5. Check swapsize
    # free -m

Actual Result:
swapsize is 0. Fail to enable swap.

/var/log/waagent.log:
2016/10/14 15:39:39.144948 VERBOSE run cmd 'mkfs.xfs /dev/sdb1 -f'
2016/10/14 15:39:39.743088 VERBOSE run cmd 'mount /dev/sdb1 /mnt/resource'
2016/10/14 15:39:40.162923 INFO Resource disk /dev/sdb is mounted at /mnt/resource with xfs
2016/10/14 15:39:40.199074 INFO Enable swap
2016/10/14 15:39:40.203751 VERBOSE run cmd 'swapon -s'
2016/10/14 15:39:40.267425 INFO Create swap file
2016/10/14 15:39:40.272537 VERBOSE run cmd 'umask 0077 && fallocate -l 2147483648 '/mnt/resource/swapfile''
2016/10/14 15:39:40.390053 VERBOSE run cmd 'mkswap /mnt/resource/swapfile'
2016/10/14 15:39:40.475485 VERBOSE run cmd 'swapon /mnt/resource/swapfile'
2016/10/14 15:39:40.560859 ERROR run cmd 'swapon /mnt/resource/swapfile' failed
2016/10/14 15:39:40.568498 ERROR Error Code:255
2016/10/14 15:39:40.591525 ERROR Result:swapon: /mnt/resource/swapfile: swapon failed: Invalid argument

2016/10/14 15:39:40.647574 ERROR Failed to enable swap (000005)/mnt/resource/swapfile

Expect Result:
Can enable swap in xfs file system.

Additional Info:
The fallocate does not physically allocate the space -- but swapon syscall requires a real space. (https://bugzilla.redhat.com/show_bug.cgi?id=1129205#c3)
So for xfs file system, perhaps we have to use "dd" instead of "fallocate". I tried "dd" then run "swapon" and it works well in xfs file system.

Comment 1 Yuxin Sun 2016-12-15 11:06:07 UTC
Verified in WALinuxAgent-2.2.2 upstream. 
Result: PASS

Comment 2 Yuxin Sun 2017-03-06 03:16:14 UTC
Change the status to "POST" for developers to add it into ERRATA.