![](/img/trans.png)
[英]Possible to pvmove & vgreduce in LVM if PVs are allocated to Xfs free space?
[英]How to modify the number of XFS pre-allocated blocks?
我編寫了一個簡單程序,並在ext4和xfs上運行了該程序。
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
int
main(int argc, char *argv[])
{
int fd;
char *file_name = argv[1];
struct stat buf;
fd = open (file_name, O_RDWR|O_CREAT);
if (fd == -1) {
printf ("Error: %s\n", strerror(errno));
return -1;
}
write (fd, "hello", sizeof ("hello"));
fstat (fd, &buf);
printf ("st_blocks: %lu\n", buf.st_blocks);
stat (file_name, &buf);
printf ("st_blocks: %lu\n", buf.st_blocks);
close (fd);
stat (file_name, &buf);
printf ("st_blocks: %lu\n", buf.st_blocks);
return 0;
}
st_blocks:8 st_blocks:8 st_blocks:8
st_blocks:128 st_blocks:128 st_blocks:8
然后,我研究了xfs,並找到了一個在運行mkfs.xfs時更改擴展區大小的選項。
示例:mkfs.xfs -r extsize = 4096 / dev / sda1
但是我仍然在XFS上得到相同的輸出。 任何人都可以提供有關如何更改st_blocks的更多信息。 提前致謝。
您將看到xfs推測性預分配,這是一種啟發式方法,用於避免文件增長時產生碎片。 有關更多信息,請參閱此FAQ條目 。
您是正確的“ -o allocsize = XXX”選項禁用了該啟發式。 您嘗試使用“ -r extsize = XXX”失敗,因為該選項僅適用於實時子卷,您幾乎肯定沒有使用它。
我找到了答案,並在此處發布了答案,以便其他遇到問題的人可以參考它。
mount -t xfs -o allocsize = 4096設備安裝點
allocsize選項用於調整緩沖區大小。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.