Linux:写入分为512K块 [英] Linux: writes are split into 512K chunks

查看:107
本文介绍了Linux:写入分为512K块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户空间应用程序,该应用程序会生成大量的SCSI写操作(详细信息如下).但是,当我查看到达SCSI目标(即通过FC连接的存储)的SCSI命令时,会将这些写入分为512K块.

I have a user-space application that generates big SCSI writes (details below). However, when I'm looking at the SCSI commands that reach the SCSI target (i.e. the storage, connected by the FC) something is splitting these writes into 512K chunks.

应用程序基本上可以直接将1M大小的数据直接写入设备:

The application basically does 1M-sized direct writes directly into the device:

fd = open("/dev/sdab", ..|O_DIRECT);
write(fd, ..., 1024 * 1024);

此代码将导致发送两个SCSI WRITE,每个512K.

This code causes two SCSI WRITEs to be sent, 512K each.

但是,如果我发出不带块层的直接SCSI命令,则写入不会拆分. 我从命令行发出以下命令:

However, if I issue a direct SCSI command, without the block layer, the write is not split. I issue the following command from the command line:

sg_dd bs=1M count=1 blk_sgio=1 if=/dev/urandom of=/dev/sdab oflag=direct

我可以看到一个单一的1M大小的SCSI WRITE.

I can see one single 1M-sized SCSI WRITE.

问题是,拆分写入的内容是什么,更重要的是,它是可配置的吗? Linux块层似乎很内((因为SG_IO没有通过它),而512K似乎太随意了,所以不能成为某种可配置的参数.

The question is, what is splitting the write and, more importantly, is it configurable? Linux block layer seems to be guilty (because SG_IO doesn't pass through it) and 512K seems too arbitrary a number not to be some sort of a configurable parameter.

推荐答案

责怪的确是在块层上,SCSI层本身并不考虑大小.您应该检查底层是否确实能够传递您的请求,尤其是在直接io方面,因为它可能会拆分成许多小页面,并且需要分散的集合列表,该列表的长度比硬件或硬件所能支持的更长.甚至只是驱动程序(libata受到限制).

The blame is indeed on the block layer, the SCSI layer itself has little regard to the size. You should check though that the underlying layers are indeed able to pass your request, especially with regard to direct io since that may be split into many small pages and requires a scatter-gather list that is longer than what can be supported by the hardware or even just the drivers (libata is/was somewhat limited).

您应该查看并调整/sys/class/block/$ DEV/queue那里存在各种各样的文件,最可能满足您需要的文件是max_sectors_kb,但是您可以尝试一下,看看最适合您的文件.您可能还需要调整分区变量.

You should look and tune /sys/class/block/$DEV/queue there are assorted files there and the most likely to match what you need is max_sectors_kb but you can just try it out and see what works for you. You may also need to tune the partitions variables as well.

这篇关于Linux:写入分为512K块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆