First you'll need to install some packages.
On your ubuntu/debian/suse whatever if you use the apt-get utility, say this.
# apt-get install xfsdump
Under Gentoo, this
# emerge xfsprogs xfsdump
Then you'll need to check if your partition needs a defragmentation in really
# xfs_db -r /dev/sda5
xfs_db> frag
actual 22222222, ideal 2342342, fragmentation factor 99.9%
xfs_db> quit
Once you see a scary fragmentation factor, run the command for the optimization
# xfs_fsr -v /dev/sda5
.......
That's it, now you may go have a drink, lift something heavy, play the guitar or pay an attention to your girlfriend. This whill take some time.