Re: [bug] ata subsystem related crash with latest -git

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Wednesday, October 17, 2007 - 12:42 pm

On Wed, 17 Oct 2007, Linus Torvalds wrote:

In fact, I think you'll hit it even if you use the "for_each_sg()" 
helper function. Exactly because it does the sg = sg_next(sg) at the end 
of the for-loop, so it will do it for the last entry too, even though that 
will access one past the end.

So it really *is* the case that every *single* use of that SG chain needs 
to be switched over to only do the sg_next() when required, or sg_next() 
needs to be fixed to look at the current-in-use entry (which we *can* 
access) when it decides what to do about the next one (which we can *not* 
access).

Moving the sg_is_chain() bit to the previous entry would work, but it 
requires that nobody who could have a chained scatterlist must *ever* 
access "sg->page" directly - you'd always need to use some helper function 
that masks off the bit, eg

 - rename "sg->page" into "sh->page_and_flag", and make it "unsigned long" 
   instead of a pointer.

 - change every single "sg->page" access to use "sg_page(sg)" instead:

	#define sg_pointer(sg)	((void *)((sg)->page_and_flag & ~1ul))

	static inline struct page *sg_page(struct scatterist *sg)
	{
		return sg_pointer(sg);
	}

 - change "sg_next()" to do

	static inline struct scatterlist *sg_next(struct scatterlist *sg)
	{
		if (sg->page_and_flag & 1)
			sg = sg_pointer(sg+1)-1;
		return ++sg;
	}

where the magic is exactly the fact that now "sg_next()" will *not* 
derefence the next SG entry unless the current one was marked 
appropriately.

And then *creating* the chain obviously needs to properly mark the 
next-to-last entry with the "next entry is a pointer" flag.

Big diff, it sounds like. But I don't see many alternatives. Jens?

		Linus
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[bug] block subsystem related crash with latest -git, Ingo Molnar, (Wed Oct 17, 8:46 am)
Re: [bug] block subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 9:50 am)
[bug] ata subsystem related crash with latest -git, Ingo Molnar, (Wed Oct 17, 10:45 am)
Re: [bug] block subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 10:52 am)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Wed Oct 17, 10:53 am)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Wed Oct 17, 10:55 am)
Re: [bug] block subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 10:56 am)
Re: [bug] ata subsystem related crash with latest -git, Ingo Molnar, (Wed Oct 17, 10:58 am)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 11:08 am)
Re: [bug] ata subsystem related crash with latest -git, Ingo Molnar, (Wed Oct 17, 11:13 am)
Re: [bug] block subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 11:13 am)
Re: [bug] block subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 11:14 am)
Re: [bug] block subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 11:18 am)
Re: [bug] block subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 11:22 am)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Wed Oct 17, 11:37 am)
Re: [bug] block subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 11:58 am)
Re: [bug] ata subsystem related crash with latest -git, Ingo Molnar, (Wed Oct 17, 12:04 pm)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Wed Oct 17, 12:08 pm)
Re: [bug] ata subsystem related crash with latest -git, Ingo Molnar, (Wed Oct 17, 12:09 pm)
Re: [bug] ata subsystem related crash with latest -git, Ingo Molnar, (Wed Oct 17, 12:14 pm)
Re: [bug] block subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 12:15 pm)
Re: [bug] ata subsystem related crash with latest -git, Ingo Molnar, (Wed Oct 17, 12:17 pm)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Wed Oct 17, 12:25 pm)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Wed Oct 17, 12:25 pm)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 12:28 pm)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Wed Oct 17, 12:35 pm)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 12:42 pm)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 12:45 pm)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Wed Oct 17, 12:49 pm)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Wed Oct 17, 12:55 pm)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Wed Oct 17, 12:56 pm)
Re: [bug] ata subsystem related crash with latest -git, Ingo Molnar, (Wed Oct 17, 1:05 pm)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 1:10 pm)
Re: [bug] block subsystem related crash with latest -git, Luca Tettamanti, (Wed Oct 17, 1:15 pm)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 1:24 pm)
Re: [bug] ata subsystem related crash with latest -git, Ingo Molnar, (Wed Oct 17, 1:51 pm)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 2:11 pm)
Re: [bug] ata subsystem related crash with latest -git, FUJITA Tomonori, (Wed Oct 17, 4:00 pm)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 6:07 pm)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Wed Oct 17, 6:14 pm)
Re: [bug] ata subsystem related crash with latest -git, David Miller, (Wed Oct 17, 6:19 pm)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 6:36 pm)
Re: [bug] ata subsystem related crash with latest -git, David Miller, (Wed Oct 17, 6:49 pm)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 9:01 pm)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Wed Oct 17, 9:14 pm)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 9:20 pm)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Wed Oct 17, 9:31 pm)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 9:45 pm)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Wed Oct 17, 9:53 pm)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Wed Oct 17, 10:45 pm)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Thu Oct 18, 12:05 am)
Re: [bug] ata subsystem related crash with latest -git, Ingo Molnar, (Thu Oct 18, 12:07 am)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Thu Oct 18, 12:09 am)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Thu Oct 18, 12:10 am)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Thu Oct 18, 12:30 am)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Thu Oct 18, 1:22 am)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Thu Oct 18, 1:38 am)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Thu Oct 18, 1:51 am)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Thu Oct 18, 2:01 am)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Thu Oct 18, 2:32 am)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Thu Oct 18, 3:04 am)
Re: [bug] ata subsystem related crash with latest -git, Ingo Molnar, (Thu Oct 18, 3:13 am)
Re: [bug] ata subsystem related crash with latest -git, Ingo Molnar, (Thu Oct 18, 3:49 am)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Thu Oct 18, 3:50 am)
Re: [bug] ata subsystem related crash with latest -git, Ingo Molnar, (Thu Oct 18, 4:03 am)
Re: [bug] ata subsystem related crash with latest -git, David Miller, (Thu Oct 18, 4:55 am)
Re: [bug] ata subsystem related crash with latest -git, David Miller, (Thu Oct 18, 5:05 am)
Re: [bug] ata subsystem related crash with latest -git, David Miller, (Thu Oct 18, 5:36 am)
Re: [bug] ata subsystem related crash with latest -git, Benny Halevy, (Thu Oct 18, 5:58 am)
Re: [bug] ata subsystem related crash with latest -git, Benny Halevy, (Thu Oct 18, 6:49 am)
Re: [bug] ata subsystem related crash with latest -git, Benny Halevy, (Thu Oct 18, 7:16 am)
Re: [bug] ata subsystem related crash with latest -git, Olof Johansson, (Thu Oct 18, 7:58 am)
Re: [bug] ata subsystem related crash with latest -git, Linus Torvalds, (Thu Oct 18, 9:55 am)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Thu Oct 18, 10:01 am)
Re: [bug] ata subsystem related crash with latest -git, Arjan van de Ven, (Thu Oct 18, 10:10 am)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Thu Oct 18, 10:10 am)
Re: [bug] ata subsystem related crash with latest -git, Jens Axboe, (Thu Oct 18, 10:14 am)
Re: [bug] ata subsystem related crash with latest -git, Jeff Garzik, (Thu Oct 18, 12:20 pm)
Re: [bug] ata subsystem related crash with latest -git, FUJITA Tomonori, (Fri Oct 19, 1:59 am)
Re: [bug] ata subsystem related crash with latest -git, Torsten Kaiser, (Sat Oct 20, 4:55 am)