Skip to contentSkip to conversation

write barriers for 2.4.x

PATCH Chris Mason 2 participants 4 messages Feb 15, 2002 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): 3132400000.1013646727@tiny

#1 lore raw

Hello everyone,

Here's the full patch update. The aic7xxx code is changed to make sure we only try to use tag commands when they are turned on for the target, otherwise we can safely assume the drive won't do other writes first.

The buslogic and sym53c8xx_2 code is included, and the reiserfs code is updated to queue the commit block immediately after the last log block when barrier mode is enabled. It wasn't happening soon enough with the first patch, and the drive wasn't getting the chance to flush the commit as a unit.

reiserfs was also changed back to waiting on the buffers. benchmarks don't show dropping the waits actually made any speed difference, the really critical wait that was hurting us was:

write X log blocks
wait
write 1 commit block
wait

With -o barrier, this is now:

write X log blocks
write 1 commit block
wait.

For scsi, the new code is about 10% faster on journal heavy stuff, but you've really gotta hammer on the log to see it.

Patch is attached and against 2.4.18-pre9 (rc1 should be fine)

-chris

#2 lore raw
Quoted 3 lines

sure we only try to use tag commands when they are turned on for the target, otherwise we can safely assume the drive won't do other writes first.

Is this guaranteed by the SCSI standards or do you need to issue some kind of cache flush as with IDE ?

Quoted 5 lines

With -o barrier, this is now:

write X log blocks
write 1 commit block
wait.

That will work nicely with the I2O controllers, and possibly (if its in the firmware as well as the .h file) the aacraid cards. In those cases I can often commit to battery backed ram rather than physical media.

Do you have any idea of driving the cache write through rather than write back is likely to help here by evening out the commit wait for a flush?

#3 lore raw
Quoted 6 lines · On Friday, February 15, 2002 01:21:20 AM +0000 Alan Cox…
Quoted 3 lines

sure we only try to use tag commands when they are turned on for the target, otherwise we can safely assume the drive won't do other writes first.

Is this guaranteed by the SCSI standards or do you need to issue some kind of cache flush as with IDE ?

We're sending the scsi ordered queue tag command, which the spec says will be written after anything already received by the target, and before anything it receives later on. I have no data at all how well the drives follow the spec ;-)

The IDE changes issue cache flushes before the barrier write, and then another flush after it, which gives us similar semantics.

Quoted 7 lines
Quoted 6 lines

With -o barrier, this is now:

write X log blocks
write 1 commit block
wait.

Quoted 8 lines

That will work nicely with the I2O controllers, and possibly (if its in the firmware as well as the .h file) the aacraid cards. In those cases I can often commit to battery backed ram rather than physical media.

Do you have any idea of driving the cache write through rather than write back is likely to help here by evening out the commit wait for a flush?

Controllers that do write back caching should be helped by the reiserfs usage changes. If we pretend they immediately tell the OS a write is completed, unpatched reiserfs does this:

write X log blocks
wait on X log blocks (all already complete, so just a CPU loop) write 1 commit
wait on 1 commit.

With the new code, the controller is more likely to get the commit in time to merge the requests. Hopefully someone who knows more about scsi can correct me, but I think the write back controller can ignore the ordering rules (since battery backup should promise the request does hit media eventually).

I think write through caches should be helped too, as long as they are smart about how they do the write ordering. My scsi drive doesn't seem to be very smart at all, it has been hard to find usage patterns that show improvement. So far, only O_SYNC writes really show it.

I think that's what you were asking, sorry if I misunderstood the Q.

-chris

#4 lore raw
In reply to Chris Mason

Ok, based on input from the scsi folks, reiserfs can't safely use the ordered tags until some error handling changes are made in the scsi drivers. Controllers that do write back caching (with battery backup) are a different story, and since they can still benefit from the patch, I left the scsi support in.

In this new version, filesystems can request either ordered tags (for scsi) or just cache flushes (for ide). The idea is to have the ide flushing on by default in the final version, since so many people have ide drives with write back caching on.

reiserfs now has -o barrier_tag and -o barrier_flush mount options. In both cases, if the device doesn't support the ordering, reiserfs backs down to unordered writes.

The attached patch is against 2.4.18-pre9, but also works against rc1. The main target for this will be making journaled filesystems safer for IDE users, so ide testers would be appreciated.

-chris