Kuye 发表于 2003-3-21 01:25:16

[转链]打开"回写",更好的ext3

帖子在 http://forums.gentoo.org/viewtopic.php?t=8680

很短,我也懒得翻译了。
大概意思就是在 /etc/fstab 非 / ext3 分区选项区中加入 “rootflags=data=writeback” 可以启用 ext3 文件系统的回写功能“WriteBack”,可以使 ext3 的性能提高
(虽然后面有人对这一观点产生置疑,但并不妨碍我们对此进行尝试。)

我因为这里因为没有 ext3 分区,所以请兄弟们自己试验了。
…………………………………………………………
btw: 我想问问,怎么今天晚上发的帖子标题全部限制在 18 个字节以内,这样让人很为难呐~。。。

carlos 发表于 2003-3-21 08:15:40

18 个字节?
这么惨?

doooom 发表于 2003-3-21 09:52:36

这样一句话掰成几瓣儿说,不是挺好?文章数就多起来了。

winme 发表于 2003-3-21 11:45:57

哥们,回写是什么意思?有什么用处?

Kuye 发表于 2003-3-21 15:55:14

to carlos: 不知道为什么啊,以前虽然也有标题字符数量也有限制,不过没那么利害啊...

to doooom: -_-....寒...

to winme: 你能先告诉我 loopback 回环是什么意思吗?

winme 发表于 2003-3-22 10:30:46

我都不知道,告诉我吧

Dragonfly 发表于 2003-4-10 08:41:58

哥们,回写是什么意思?有什么用处?

there are two modes of write operations
1) write back - write data and then back. data may still in cache, not on disk. so when system crash, power off, or reboot, data will lost. especially when u metadata are lost, u file system will be corrupted and u lose all data.
2) write through - write data, wait data to be written to disk, then back. by this way, u can make sure that u data are in disk, and u will not lose data when system crashes. but this is very slow.
(in these two modes, back means report upper appplication, "u write operation is end").
so now people use log file system, like ext3, xfs, or reiserfs. it uses write cache, and log. log is a way to record data and its write speed is much faster than write data to file directly. by the log, the data can be restored after system crash.

CNOOC 发表于 2003-4-10 09:58:32


there are two modes of write operations
1) write back - write data and then back. data may still in cache, not on disk. so when system crash, power off, or reboot, data will lost. especially when u metadata are lost, u file system will be corrupted and u lose all data.
2) write through - write data, wait data to be written to disk, then back. by this way, u can make sure that u data are in disk, and u will not lose data when system crashes. but this is very slow.
(in these two modes, back means report upper appplication, "u write operation is end").
so now people use log file system, like ext3, xfs, or reiserfs. it uses write cache, and log. log is a way to record data and its write speed is much faster than write data to file directly. by the log, the data can be restored after system crash.

有两种写入执行的方式:
1) 写入缓存 - 写入数据然后返回,数据仍然储存在缓存里而非磁盘上。当系统在崩溃,停电,或者重起的情况下,你的文件系统将会丢失,特别是在位数据丢失的情况下,你的文件系统将会被损坏而你将丢失所有的数据。
2) 直接写入 - 写入数据,当数据存储到磁盘后返回。这种情况,你可以确定你的数据已经被写入磁盘,你的数据在系统崩溃的时候不会丢失。但这种方式将会降低运行速度。(在这两种方式中,返回表示向上级应用程序报告,“你的写入执行已经结束了。”)
所以现在人们用日志系统,例如ext3, xfs, 或者reiserfs. 日志系统使用写入缓存和日志。日志是一种记录数据的方式,而且的速度远远比直接将数据写入磁盘的要快。通过日志文件,数据在系统崩溃后可以被重新恢复。

Dragonfly 发表于 2003-4-10 10:06:51

haha, so funny, thx. u translate my post. so next time when i post, i will notify u to help me.

a new one to explain why write log is faster than write regular file.
since log is designed to be written sequentially to disk, so log can be written very fast. while the write operations to regular file is non-sequential most of the time. so they invoke many disk seek operations and rotation delay, which is very slow. my test on a 15k rpm scsi disk is that, for sequential write, u can achieve around 56MB/s, while for non-sequential write, u can only get around 4MB/s. so this is why write log is faster than write regular files. a simple formula,
disk io time = data transfer time + disk seek time + disk rotation time, so u can understand why.

CNOOC 发表于 2003-4-10 10:19:01

班门弄斧一下。我想再解释解释“返回”这个词,如果winme还是不太清楚的话。虽然上文有解释什么是“返回”,但如果你曾经学过编程的话,那通过例子就会比较生动,不象上面一句话那么抽象。

请看下面的C++例子(不明白也没关系,反正用意不在讨论C++上):

#include <iostream>   //负责输入输出;

using namespace std;         //同上,确定格式;

int Sum(int x, int y);          //定义求和函数Sum

int main()                  //主函数
{
          int x;             //定义一个整数变量x
          int y;            //。。。。。。。。y


          cout << Sum(3, 4);   //赋值给x, y。运行Sum然后输出结果

          cin.get();cin.get();
          return 0;      //结束, 退出主函数。
}
/**************************/

int Sum(int x, int y)
{
          return (x+y);   //计算x+y的值并将其“返回”。
}


在这里面Sum函数是子函数,也可以说是下级程序。
而main当然就是母函数,也就是上级程序了。
当上级程序运行到cout << Sum(3, 4);的时候,“呼叫”(英文是call或者是invoke,翻译成调用更合适)了Sum并运行Sum,当Sum运行后得出结果,就会“返回”到上级程序main,将运行的结果输出,在这里我们知道将是个整数7。

Dragonfly 发表于 2003-4-10 10:27:55

so i should say like this.
a piece of code like this:
...
write(...);
...

so when u call write, system will call sys_write and u stop here, if write back mode, then sys_write will write to cache and then return, then u code continue; if write through mode, then write will wait till datato disk, then return and u code continue.

Dragonfly 发表于 2003-4-10 10:29:04

to carlos: 不知道为什么啊,以前虽然也有标题字符数量也有限制,不过没那么利害啊...

to doooom: -_-....寒...

to winme: 你能先告诉我 loopback 回环是什么意思吗?


who mention this "loopback"?

CNOOC 发表于 2003-4-10 10:31:08

a new one to explain why write log is faster than write regular file.
since log is designed to be written sequentially to disk, so log can be written very fast. while the write operations to regular file is non-sequential most of the time. so they invoke many disk seek operations and rotation delay, which is very slow. my test on a 15k rpm scsi disk is that, for sequential write, u can achieve around 56MB/s, while for non-sequential write, u can only get around 4MB/s. so this is why write log is faster than write regular files. a simple formula,
disk io time = data transfer time + disk seek time + disk rotation time, so u can understand why.
一个新的关于“为什么写入日志会比写入磁盘快”的解释。
因为日志是被设计成连续写入磁盘,所以它可以写入的速度会非常快。而大多数时候普通文件的写入执行是非连续性的,所以他们调用了许多磁盘的不同区域空间,通过这样来执行, 而这样就导致了磁盘旋转的速度降低。我在一个1500转每秒的scsi磁盘上实验,当你用连续写入的方式时,数据的传送可达到56MB/秒,当你用非连续写入的方式时,你只能达到4MB/秒。这就是为什么写入日志要比写入普通文件快的原因。一个简单的方程式:
磁盘写入/输出时间=数据传送时间+磁盘检测时间+磁盘旋转速度。
你可以明白为什么了。

Dragonfly 发表于 2003-4-10 10:38:42

thx so much, but some are wrong. maybe my english is poor so let u misunderstand.

"所以他们调用了许多磁盘的不同区域空间,通过这样来执行, 而这样就导致了磁盘旋转的速度降低。"
i mean because they need write to different place, then disk have to do seek and rotate operations for each write operation. and seek need time, rotate also need time. so base on the formula, the total time will increase. the rotation speed will not change. for a 15k rpm disk, it is 1/(15k rpm).

CNOOC 发表于 2003-4-10 10:44:52

thx so much, but some are wrong. maybe my english is poor so let u misunderstand.

"所以他们调用了许多磁盘的不同区域空间,通过这样来执行, 而这样就导致了磁盘旋转的速度降低。"
i mean because they need write to different place, then disk have to do seek and rotate operations for each write operation. and seek need time, rotate also need time. so base on the formula, the total time will increase. the rotation speed will not change. for a 15k rpm disk, it is 1/(15k rpm).

基本上意思是磁盘被原有数据占据,所以被划分成一块块的,而写入的时候需要寻找合适的空间,然后把数据写入这些不同位置的地方,在因为寻找空间需要花费掉一点时间,而磁盘旋转也要花费时间,根据公式。。。。。。。。。。。。。。

对吧?其实我刚才也是这个意思,只不过打字打累了,所以偷懒省了几个字,可能就引起混淆了,不好意思。不过你能不能不用英文阿,我是没关系的了,不过通常太长的英文,其他人就不会看了,这样也浪费了你的时间和热情。
页: [1] 2
查看完整版本: [转链]打开"回写",更好的ext3