Filesystems 如何修改XFS预分配块的数量?
我编写了一个简单的程序,并在ext4和xfs上运行了该程序Filesystems 如何修改XFS预分配块的数量?,filesystems,ext4,xfs,Filesystems,Ext4,Xfs,我编写了一个简单的程序,并在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[]) {
#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;
}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
int
main(int argc,char*argv[])
{
int-fd;
char*file_name=argv[1];
结构统计buf;
fd=打开(文件名,O_RDWR | O_CREAT);
如果(fd==-1){
printf(“错误:%s\n”,strerror(errno));
返回-1;
}
写(fd,“你好”,sizeof(“你好”);
财政司司长(财政司司长和财政司司长);
printf(“标准块:%lu\n”,基本标准块);
stat(文件名和buf);
printf(“标准块:%lu\n”,基本标准块);
关闭(fd);
stat(文件名和buf);
printf(“标准块:%lu\n”,基本标准块);
返回0;
}
ext4上的输出:
圣乌区:8
圣乌区:8
圣乌区:8
xfs上的输出:
圣乌区:128
圣乌区:128
圣乌区:8
然后,我研究了xfs,找到了一个在运行mkfs.xfs时更改数据块大小的选项
示例:mkfs.xfs-r extsize=4096/dev/sda1
但我仍然在XFS上获得相同的输出。谁能提供更多关于如何改变st_街区的见解。提前感谢。我找到了答案,将答案张贴在这里,以便其他面临问题的人可以参考 mount-t xfs-o allocsize=4096设备安装点
allocsize选项用于调整缓冲区大小。您看到的是xfs推测性预分配,这是一种启发式方法,用于避免文件在增长时出现碎片。 有关详细信息,请参阅 “-o allocsize=XXX”选项禁用该启发式是正确的。尝试使用“-r extsize=XXX”失败,因为该选项仅适用于实时子卷,您几乎肯定不会使用该子卷