Re: [PATCH] Introduce a method to catch mmap_region (was: Recent kernel "mount" slow)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Wed, 28 Nov 2012, Linus Torvalds wrote:

> > For example, __block_write_full_page and __block_write_begin do
> >         if (!page_has_buffers(page)) { create_empty_buffers... }
> > and then they do
> >         WARN_ON(bh->b_size != blocksize)
> >         err = get_block(inode, block, bh, 1)
> 
> Right. And none of this is new.
> 
> > ... so if the buffers were left over from some previous call to
> > create_empty_buffers with a different blocksize, that WARN_ON is trigged.
> 
> None of this can happen.

It can happen. Take your patch (the one that moves bd_block_size_semaphore 
into blkdev_readpage, blkdev_writepage and blkdev_write_begin).

Insert msleep(1000) into set_blocksize, just before sync_blockdev.

Run this program:
#define _XOPEN_SOURCE 500
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>

static char array[4096];

int main(void)
{
        int h;
        system("dmsetup remove test 2>/dev/null");
        if (system("dmsetup create test --table '0 1 zero'")) exit(1);
        h = open("/dev/mapper/test", O_RDWR);
        if (h < 0) perror("open"), exit(1);
        if (pread(h, array, 512, 0) != 512) perror("pread"), exit(1);
        if (system("dmsetup load test --table '0 8 zero'")) exit(1);
        if (system("dmsetup suspend test")) exit(1);
        if (system("dmsetup resume test")) exit(1);
        if (system("blockdev --setbsz 2048 /dev/mapper/test &")) exit(1);
        usleep(500000);
        if (pwrite(h, array, 4096, 0) != 4096) perror("pwrite"), exit(1);
        return 0;
}

--- it triggers WARNING: at fs/buffer.c:1830 in __block_write_begin
[ 1243.300000] Backtrace:
[ 1243.330000]  [<0000000040230ba8>] block_write_begin+0x70/0xd0
[ 1243.400000]  [<00000000402350cc>] blkdev_write_begin+0xb4/0x208
[ 1243.480000]  [<00000000401a9f10>] generic_file_buffered_write+0x248/0x348
[ 1243.570000]  [<00000000401ac8c4>] __generic_file_aio_write+0x1fc/0x388
[ 1243.660000]  [<0000000040235e74>] blkdev_aio_write+0x64/0xf0
[ 1243.740000]  [<00000000401f2108>] do_sync_write+0xd0/0x128
[ 1243.810000]  [<00000000401f2930>] vfs_write+0xa0/0x180
[ 1243.880000]  [<00000000401f2ecc>] sys_pwrite64+0xb4/0xd8
[ 1243.950000]  [<0000000040122104>] parisc_pwrite64+0x1c/0x28
[ 1244.020000]  [<0000000040106060>] syscall_exit+0x0/0x14


I'm not saying that your approach is wrong, you just have to carefuly
review all memory management code for assumptions that block size
doesn't change.

Mikulas
--
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


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux