Skip to contentSkip to conversation

device-mapper snapshot: barriers not supported

PATCH In review Alasdair G Kergon 3 participants 6 messages Jan 20, 2006 – Jan 25, 2006 Device mapper

lore
Share & tools
lore

Alasdair G Kergon

author maintainer
#0 lore raw

PATCH 6/9 device-mapper snapshot: barriers not supported

The snapshot and origin targets are incapable of handling barriers and need to indicate this.

drivers/md/dm-snap.c +6 -0
Index: linux-2.6.16-rc1/drivers/md/dm-snap.c
===================================================================
@@ -792,6 +792,9 @@ static int snapshot_map(struct dm_target
 	if (!s->valid)
 		return -EIO;
 
+	if (unlikely(bio_barrier(bio)))
+		return -EOPNOTSUPP;
+
 	/*
 	 * Write to snapshot - higher level takes care of RW/RO
 	 * flags so we should only get this if we are
@@ -1058,6 +1061,9 @@ static int origin_map(struct dm_target *
 	struct dm_dev *dev = (struct dm_dev *) ti->private;
 	bio->bi_bdev = dev->bdev;
 
+	if (unlikely(bio_barrier(bio)))
+		return -EOPNOTSUPP;
+
 	/* Only tell snapshots if this is a write */
 	return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : 1;
 }
#1 lore raw
Quoted 9 lines · Alasdair G Kergon

The snapshot and origin targets are incapable of handling barriers and
need to indicate this.

...

+ if (unlikely(bio_barrier(bio)))
+ return -EOPNOTSUPP;
+

And what was happening if people _were_ sending such BIOs down? Did it all appear to work correctly? If so, will this change cause currently-apparently-working setups to stop working?

#2 lore raw
Quoted 7 lines · Andrew Morton
Quoted 6 lines · Alasdair G Kergon

The snapshot and origin targets are incapable of handling barriers and
need to indicate this.

...

Quoted 7 lines
Quoted 3 lines

+ if (unlikely(bio_barrier(bio)))
+ return -EOPNOTSUPP;
+

And what was happening if people _were_ sending such BIOs down? Did it all appear to work correctly? If so, will this change cause currently-apparently-working setups to stop working?

Filesystems basically disable using barriers on a device which doesn't support them, which is indicated by -EOPNOTSUPP. Barriers are allowed to fail in such fashion.

Now the interesting question is what happens when barriers are suddenly verboten on a stack which used to support them - because the new mapping doesn't support it _anymore_. Hrm. _Should_ work, but probably not tested much ;-)

Sincerely,
Lars Marowsky-Brée

Signature · 4 lines
High Availability & Clustering
SUSE Labs, Research and Development
SUSE LINUX Products GmbH - A Novell Business	 -- Charles Darwin
"Ignorance more frequently begets confidence than does knowledge"
#3 lore raw
Quoted 18 lines · Lars Marowsky-Bree
Quoted 7 lines · Andrew Morton
Quoted 6 lines · Alasdair G Kergon

The snapshot and origin targets are incapable of handling barriers and
need to indicate this.

...

Quoted 7 lines
Quoted 3 lines

+ if (unlikely(bio_barrier(bio)))
+ return -EOPNOTSUPP;
+

And what was happening if people _were_ sending such BIOs down? Did it all appear to work correctly? If so, will this change cause currently-apparently-working setups to stop working?

Quoted 9 lines

Filesystems basically disable using barriers on a device which doesn't support them, which is indicated by -EOPNOTSUPP. Barriers are allowed to fail in such fashion.

Now the interesting question is what happens when barriers are suddenly verboten on a stack which used to support them - because the new mapping doesn't support it _anymore_. Hrm. _Should_ work, but probably not tested much ;-)

I don't understand that, sorry.

My concern is: has the above change any potential to cause currently-working setups to stop working?

author maintainer
#4 lore raw
Quoted 10 lines · Andrew Morton
Quoted 4 lines · Lars Marowsky-Bree

Now the interesting question is what happens when barriers are suddenly verboten on a stack which used to support them - because the new mapping doesn't support it _anymore_. Hrm. _Should_ work, but probably not tested much ;-)

I don't understand that, sorry.

My concern is: has the above change any potential to cause currently-working setups to stop working?

I trust not. Various things don't support barriers yet, so code shouldn't assume that they are supported. Where they are supported, they allow for optimisation.

For example, jbd detects the error and retries without them.

fs/jbd/commit.c: static int journal_write_commit_record(

        if (ret == -EOPNOTSUPP && barrier_done) {
		... 
                printk(KERN_WARNING
                        "JBD: barrier-based sync failed on %s - "
                        "disabling barriers\n",
                        bdevname(journal->j_dev, b));
		...
		/* And try again, without the barrier */
		...

Alasdair

Signature · 1 line
[email protected]
author maintainer
#5 lore raw
In reply to Andrew Morton
Quoted 6 lines · Andrew Morton
Quoted 2 lines · Alasdair G Kergon

The snapshot and origin targets are incapable of handling barriers and
need to indicate this.

And what was happening if people _were_ sending such BIOs down? Did it all appear to work correctly?

The snapshot target ignores the barrier and in some circumstances I/O can be reordered in ways that are meant to be prevented by the barrier.

Quoted 2 lines

If so, will this change cause currently-apparently-working setups to stop working?

As Lars pointed out, filesystems should already cope with -EOPNOTSUPP transparently, and it would be sensible for any out-of-tree users to do likewise.

Alasdair

Signature · 1 line
[email protected]