_scratch_unmount
}
+# Does fiemap support?
+_require_fiemap()
+{
+ _require_xfs_io_command "fiemap"
+}
+
+_count_extents()
+{
+ res=`$XFS_IO_PROG -c "fiemap" $1 | tail -n +2`
+ echo $res | grep -v hole | wc -l | $AWK_PROG '{print $1}'
+}
+
+_count_holes()
+{
+ res=`$XFS_IO_PROG -c "fiemap" $1 | tail -n +2`
+ echo $res | grep hole | wc -l | $AWK_PROG '{print $1}'
+}
+
# arg 1 is dev to remove and is output of the below eg.
# ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
_devmgt_remove()
_require_scratch
_require_scratch_shutdown
+_require_fiemap
_scratch_mkfs_xfs >/dev/null 2>&1
_scratch_mount
if [ -s $file ]
then
# if file has non-zero size but no extents then it's contents will be NULLs, bad.
- if xfs_bmap $file | grep 'no extents' > /dev/null
- then
+ num_extents=`_count_extents $file`
+ num_holes=`_count_holes $file`
+ if [ $num_extents -eq 0 ]; then
echo corrupt file $file - non-zero size but no extents
- elif xfs_bmap $file | grep 'hole' > /dev/null
- then
+ elif [ $num_holes -ne 0 ]; then
echo corrupt file $file - contains holes
else
rm -f $file
_require_scratch
_require_scratch_shutdown
+_require_fiemap
_scratch_mkfs_xfs >/dev/null 2>&1
_scratch_mount
if [ -s $file ]
then
# if file has non-zero size but no extents then it's contents will be NULLs, bad.
- if xfs_bmap $file | grep 'no extents' > /dev/null
- then
+ num_extents=`_count_extents $file`
+ num_holes=`_count_holes $file`
+ if [ $num_extents -eq 0 ]; then
echo corrupt file $file - non-zero size but no extents
- elif xfs_bmap $file | grep 'hole' > /dev/null
- then
+ elif [ $num_holes -ne 0 ]; then
echo corrupt file $file - contains holes
else
rm -f $file
_require_scratch
_require_scratch_shutdown
+_require_fiemap
_scratch_mkfs_xfs >/dev/null 2>&1
_scratch_mount
if [ -s $file ]
then
# if file has non-zero size but no extents then it's contents will be NULLs, bad.
- if xfs_bmap $file | grep 'no extents' > /dev/null
- then
+ num_extents=`_count_extents $file`
+ num_holes=`_count_holes $file`
+ if [ $num_extents -eq 0 ]; then
echo corrupt file $file - non-zero size but no extents
- elif xfs_bmap $file | grep 'hole' > /dev/null
- then
+ elif [ $num_holes -ne 0 ]; then
echo corrupt file $file - contains holes
else
rm -f $file
_require_scratch
_require_scratch_shutdown
+_require_fiemap
_scratch_mkfs_xfs >/dev/null 2>&1
_scratch_mount
if [ -s $file ]
then
# if file has non-zero size but no extents then it's contents will be NULLs, bad.
- if xfs_bmap $file | grep 'no extents' > /dev/null
- then
+ num_extents=`_count_extents $file`
+ if [ $num_extents -eq 0 ]; then
echo corrupt file $file - non-zero size but no extents
else
rm -f $file
_require_scratch
_require_scratch_shutdown
+_require_fiemap
_scratch_mkfs_xfs >/dev/null 2>&1
_scratch_mount
if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 32768 ]
then
# if file has non-zero size but no extents then it's contents will be NULLs, bad.
- if xfs_bmap $file | grep 'no extents' > /dev/null
- then
+ num_extents=`_count_extents $file`
+ if [ $num_extents -eq 0 ]; then
echo corrupt file $file - non-zero size but no extents
else
rm -f $file
_require_scratch
_require_scratch_shutdown
+_require_fiemap
_scratch_mkfs_xfs >/dev/null 2>&1
_scratch_mount
if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 10485760 ]
then
# if file has non-zero size but no extents then it's contents will be NULLs, bad.
- if xfs_bmap $file | grep 'no extents' > /dev/null
- then
+ num_extents=`_count_extents $file`
+ if [ $num_extents -eq 0 ]; then
echo corrupt file $file - non-zero size but no extents
else
rm -f $file
_require_scratch
_require_scratch_shutdown
+_require_fiemap
_scratch_mkfs_xfs >/dev/null 2>&1
_scratch_mount
if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 32768 ]
then
# if file has non-zero size but no extents then it's contents will be NULLs, bad.
- if xfs_bmap $file | grep 'no extents' > /dev/null
- then
+ num_extents=`_count_extents $file`
+ if [ $num_extents -eq 0 ]; then
echo corrupt file $file - non-zero size but no extents
else
rm -f $file