On Wed, Nov 28, 2012 at 11:16:21PM -0700, Linus Torvalds wrote: > On Wed, Nov 28, 2012 at 6:58 PM, Linus Torvalds > <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: > > > > But the fact that the code wants to do things like > > > > block = (sector_t)page->index << (PAGE_CACHE_SHIFT - bbits); > > > > seriously seems to be the main thing that keeps us using > > 'inode->i_blkbits'. Calculating bbits from bh->b_size is just costly > > enough to hurt (not everywhere, but on some machines). > > > > Very annoying. > > Hmm. Here's a patch that does that anyway. I'm not 100% happy with the > whole ilog2 thing, but at the same time, in other cases it actually > seems to improve code generation (ie gets rid of the whole unnecessary > two dereferences through page->mapping->host just to get the block > size, when we have it in the buffer-head that we have to touch > *anyway*). > > Comments? Again, untested. Jumping in based on Linus original patch, which is doing something like this: set_blocksize() { block new calls to writepage, prepare/commit_write set the block size unblock < --- can race in here and find bad buffers ---> sync_blockdev() kill_bdev() < --- now we're safe --- > } We could add a second semaphore and a page_mkwrite call: set_blocksize() { block new calls to prepare/commit_write and page_mkwrite(), but leave writepage unblocked. sync_blockev() <--- now we're safe. There are no dirty pages and no ways to make new ones ---> block new calls to readpage (writepage too for good luck?) kill_bdev() set the block size unblock readpage/writepage unblock prepare/commit_write and page_mkwrite } Another way to look at things: As Linus said in a different email, we don't need to drop the pages, just the buffers. Once we've blocked prepare/commit_write, there is no way to make a partially up to date page with dirty data. We may make fully uptodate dirty pages, but for those we can just create dirty buffers for the whole page. As long as we had prepare/commit write blocked while we ran sync_blockdev, we can blindly detach any buffers that are the wrong size and just make new ones. This may or may not apply to loop.c, I'd have to read that more carefully. -chris -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html