Skip to contentSkip to conversation

Why reiser does a disk write on every sync() call?

DISCUSSION Lin Shen (lshen) 4 participants 7 messages Mar 26, 2007 – May 16, 2007 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

I'm using iostat to measure disk reads/writes associated with various file operations under Reiser. One thing I noticed and can't explain is that every sync() call by itself (not following a write or anything) will cause an I/O write. Any ideas?

Lin

#2 lore raw

Hello

Quoted 5 lines · Lin Shen (lshen)

I'm using iostat to measure disk reads/writes associated with various file operations under Reiser. One thing I noticed and can't explain is that every sync() call by itself (not following a write or anything) will cause an I/O write. Any ideas?

The I/O write is performed by reiserfs implementation of sync_fs method of struct super_operations.
If filesystem is mounted r/w - reiserfs_sync_fs begins a transaction (or joins an existing one), journal super block if the transaction has zero length, closes the transaction and flushes old transactions including the one which was just closed. So, if there were no transaction to flush before sync() - one transaction of length 1 gets created, closed, committed and flushed. 5 blocks get written to disk in this case. My calculation can be wrong, though. How much I/O do you notice?

Quoted 3 lines

Lin

#3 lore raw

I saw 32 blocks by calling sync() alone.

Lin

Quoted 35 lines

-----Original Message-----
From: Vladimir V. Saveliev [mailto:[email protected]]
Sent: Tuesday, March 27, 2007 1:00 AM
To: Lin Shen (lshen)
Cc: [email protected]
Subject: Re: Why reiser does a disk write on every sync() call?

Hello

Quoted 1 line · Lin Shen (lshen)

I'm using iostat to measure disk reads/writes associated

with various

Quoted 1 line

file operations under Reiser. One thing I noticed and can't

explain is

Quoted 1 line

that every sync() call by itself (not following a write or

anything)

Quoted 2 lines

will cause an I/O write. Any ideas?

The I/O write is performed by reiserfs implementation of sync_fs method of struct super_operations.
If filesystem is mounted r/w - reiserfs_sync_fs begins a transaction (or joins an existing one), journal super block if the transaction has zero length, closes the transaction and flushes old transactions including the one which was just closed. So, if there were no transaction to flush before sync() - one transaction of length 1 gets created, closed, committed and flushed. 5 blocks get written to disk in this case. My calculation can be wrong, though.
How much I/O do you notice?

Quoted 3 lines

Lin

#4 lore raw

Hello

Quoted 2 lines · Lin Shen (lshen)

I saw 32 blocks by calling sync() alone.

iostat used to count sectors which are 512 bytes long. Did you take that into account?

Quoted 39 lines

Lin

Quoted 35 lines

-----Original Message-----
From: Vladimir V. Saveliev [mailto:[email protected]]
Sent: Tuesday, March 27, 2007 1:00 AM
To: Lin Shen (lshen)
Cc: [email protected]
Subject: Re: Why reiser does a disk write on every sync() call?

Hello

Quoted 1 line · Lin Shen (lshen)

I'm using iostat to measure disk reads/writes associated

with various

Quoted 1 line

file operations under Reiser. One thing I noticed and can't

explain is

Quoted 1 line

that every sync() call by itself (not following a write or

anything)

Quoted 2 lines

will cause an I/O write. Any ideas?

The I/O write is performed by reiserfs implementation of sync_fs method of struct super_operations.
If filesystem is mounted r/w - reiserfs_sync_fs begins a transaction (or joins an existing one), journal super block if the transaction has zero length, closes the transaction and flushes old transactions including the one which was just closed. So, if there were no transaction to flush before sync() - one transaction of length 1 gets created, closed, committed and flushed. 5 blocks get written to disk in this case. My calculation can be wrong, though.
How much I/O do you notice?

Quoted 3 lines

Lin

#5 lore raw

sounds like useless waste of time and space
You haven't stated the reason, why it has to create and commit empty transaction.

Signature · 1 line
GJ
#6 lore raw
Quoted 3 lines · Grzegorz JaÅ›kiewicz

sounds like useless waste of time and space
You haven't stated the reason, why it has to create and commit empty transaction.

Why'd you call sync()?

--T

Quoted 3 lines
Signature · 2 lines
-- 
GJ
#7 lore raw
In reply to Grzegorz Jaśkiewicz

Hello

Quoted 4 lines · Grzegorz JaÅ›kiewicz

sounds like useless waste of time and space
You haven't stated the reason, why it has to create and commit empty transaction.

I think we should fix that.

Chris, do you think that we could avoid creating fake transactions with the below patch?

fs/reiserfs/super.c renamed from fs/reiserfs/super.c~reiserfs-avoid-syncing-clean-fs +1 -1
diff -puN fs/reiserfs/super.c~reiserfs-avoid-syncing-clean-fs fs/reiserfs/super.c
@@ -62,7 +62,7 @@ static int reiserfs_statfs(struct dentry
 
 static int reiserfs_sync_fs(struct super_block *s, int wait)
 {
-	if (!(s->s_flags & MS_RDONLY)) {
+	if (!(s->s_flags & MS_RDONLY) && s->s_dirt) {
 		struct reiserfs_transaction_handle th;
 		reiserfs_write_lock(s);
 		if (!journal_begin(&th, s, 1))

_