﻿{"id":346,"date":"2025-09-25T12:04:01","date_gmt":"2025-09-25T09:04:01","guid":{"rendered":"https:\/\/fewit.ru\/?p=346"},"modified":"2025-09-25T12:05:11","modified_gmt":"2025-09-25T09:05:11","slug":"xfs-%d0%b7%d0%b0%d0%bc%d0%b5%d1%82%d0%ba%d0%b8","status":"publish","type":"post","link":"https:\/\/fewit.ru\/?p=346","title":{"rendered":"xfs \u0437\u0430\u043c\u0435\u0442\u043a\u0438"},"content":{"rendered":"<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<pre>xfs_db -r -c frag \/dev\/mapper\/root-data<\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c:<\/p>\n<pre>ionice -c2 -n7 nice -n19 xfs_fsr -v -t \/mnt\/data<\/pre>\n<p>xfs_fsr -v \u2192 \u0432\u043a\u043b\u044e\u0447\u0451\u043d \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441.<br \/>\n-t \u2192 \u00abthrottle\u00bb, \u0434\u0430\u0451\u0442 \u043f\u0430\u0443\u0437\u044b \u043c\u0435\u0436\u0434\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0434\u0440\u0443\u0433\u0438\u0435 IO \u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c.<\/p>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 AG<\/p>\n<pre>\n#!\/usr\/bin\/env bash\nset -euo pipefail\n\nMNT=\"${1:-}\"\nif [ -z \"$MNT\" ]; then\n  echo \"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435: $0 <mountpoint>\"\n  exit 1\nfi\n\nINFO=$(xfs_info \"$MNT\" 2>\/dev\/null) || {\n  echo \"\u041e\u0448\u0438\u0431\u043a\u0430: \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c xfs_info \u043d\u0430 $MNT\"\n  exit 2\n}\n\n# \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 data (\u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0451\u043c bsize \u0438 blocks). fallback \u2014 \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 'data'\nDATA_LINE=$(printf \"%s\\n\" \"$INFO\" | awk '\/^[[:space:]]*data[[:space:]]*=\/ {print; exit}')\nif [ -z \"$DATA_LINE\" ]; then\n  DATA_LINE=$(printf \"%s\\n\" \"$INFO\" | grep -m1 'data' || true)\nfi\n\n# \u041f\u0430\u0440\u0441\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0437 DATA_LINE, \u0438\u043d\u0430\u0447\u0435 \u0438\u0437 \u0432\u0441\u0435\u0433\u043e INFO)\nBSIZE=$(printf \"%s\\n\" \"$DATA_LINE\" | sed -n 's\/.*bsize=\\([0-9]*\\).*\/\\1\/p')\nTOTAL_BLOCKS=$(printf \"%s\\n\" \"$DATA_LINE\" | sed -n 's\/.*blocks=\\([0-9]*\\).*\/\\1\/p')\n\n[ -z \"$BSIZE\" ] && BSIZE=$(printf \"%s\\n\" \"$INFO\" | sed -n 's\/.*bsize=\\([0-9]*\\).*\/\\1\/p' | head -n1 || true)\n[ -z \"$TOTAL_BLOCKS\" ] && TOTAL_BLOCKS=$(printf \"%s\\n\" \"$INFO\" | sed -n 's\/.*blocks=\\([0-9]*\\).*\/\\1\/p' | head -n1 || true)\n\nAGCOUNT=$(printf \"%s\\n\" \"$INFO\" | sed -n 's\/.*agcount=\\([0-9]*\\).*\/\\1\/p' | head -n1 || true)\nAGSIZE=$(printf \"%s\\n\" \"$INFO\" | sed -n 's\/.*agsize=\\([0-9]*\\).*\/\\1\/p' | head -n1 || true)\n\n# \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0438\nif [ -z \"$BSIZE\" ] || [ -z \"$TOTAL_BLOCKS\" ] || [ -z \"$AGCOUNT\" ] || [ -z \"$AGSIZE\" ]; then\n  echo \"\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0437 xfs_info. \u0412\u044b\u0432\u043e\u0434 xfs_info:\"\n  echo \"------------\"\n  echo \"$INFO\"\n  echo \"------------\"\n  exit 3\nfi\n\n# \u0410\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430 (\u0431\u0430\u0439\u0442\u044b)\nAG_BYTES=$((AGSIZE * BSIZE))\nTOTAL_BYTES=$((TOTAL_BLOCKS * BSIZE))\nLAST_AG_BLOCKS=$((TOTAL_BLOCKS - AGSIZE * (AGCOUNT - 1)))\nif [ \"$LAST_AG_BLOCKS\" -le 0 ]; then\n  echo \"\u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043e LAST_AG_BLOCKS=$LAST_AG_BLOCKS (<=0). \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0432\u044b\u0432\u043e\u0434 xfs_info.\"\n  exit 4\nfi\nLAST_AG_BYTES=$((LAST_AG_BLOCKS * BSIZE))\n\n# \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u0432 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\u044b \u0441 \u0434\u0432\u0443\u043c\u044f \u0437\u043d\u0430\u043a\u0430\u043c\u0438\nto_mb() {\n  awk -v b=\"$1\" 'BEGIN{printf(\"%.2f\", b\/1024\/1024)}'\n}\n\nAG_MB=$(to_mb \"$AG_BYTES\")\nLAST_AG_MB=$(to_mb \"$LAST_AG_BYTES\")\nTOTAL_MB=$(to_mb \"$TOTAL_BYTES\")\n\nPERCENT=$(awk -v a=\"$LAST_AG_BYTES\" -v b=\"$AG_BYTES\" 'BEGIN{if (b==0) print \"0.0\"; else printf(\"%.1f\", a\/b*100)}')\n\necho \"Mountpoint: $MNT\"\necho \"Block size: $BSIZE\"\necho \"AG count:   $AGCOUNT\"\nprintf \"Normal AG:  %s MB\\n\" \"$AG_MB\"\nprintf \"Last AG:    %s MB (%.1f%% of normal)\\n\" \"$LAST_AG_MB\" \"$PERCENT\"\nprintf \"Total FS:   %s MB\\n\" \"$TOTAL_MB\"\n\nif awk \"BEGIN{exit !($PERCENT < 50)}\"; then\n  echo \"\u26a0\ufe0f  Warning: \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 AG \u043c\u0435\u043d\u044c\u0448\u0435 50% \u043e\u0442 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u2014 \u0435\u0441\u0442\u044c \u0440\u0438\u0441\u043a ENOSPC \u043f\u0440\u0438 reflink\/CoW.\"\nfi\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: xfs_db -r -c frag \/dev\/mapper\/root-data \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c: ionice -c2 -n7 nice -n19 xfs_fsr -v<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,3],"tags":[125],"class_list":["post-346","post","type-post","status-publish","format-standard","hentry","category-centos","category-linux","tag-xfs"],"_links":{"self":[{"href":"https:\/\/fewit.ru\/index.php?rest_route=\/wp\/v2\/posts\/346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fewit.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fewit.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fewit.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fewit.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=346"}],"version-history":[{"count":2,"href":"https:\/\/fewit.ru\/index.php?rest_route=\/wp\/v2\/posts\/346\/revisions"}],"predecessor-version":[{"id":348,"href":"https:\/\/fewit.ru\/index.php?rest_route=\/wp\/v2\/posts\/346\/revisions\/348"}],"wp:attachment":[{"href":"https:\/\/fewit.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fewit.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fewit.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}