Commit afe7e3a9 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (1/6) blksize_size[] removal

 - preliminary cleanups: make sure that swapoff restores original block
   size, kill set_blocksize() (and use of __bread()) in multipath.c,
   reorder opening device and finding its block size in mtdblock.c.
parent afae6f7c
......@@ -738,43 +738,56 @@ static int __check_consistency (mddev_t *mddev, int row)
{
multipath_conf_t *conf = mddev_to_conf(mddev);
int disks = MD_SB_DISKS;
kdev_t dev;
struct block_device *bdev;
struct buffer_head *bh = NULL;
int i, rc = 0;
char *buffer = NULL;
char *buffer;
struct page *page = NULL;
int first = 1;
int order = PAGE_CACHE_SHIFT-PAGE_SHIFT;
buffer = (char *) __get_free_pages(GFP_KERNEL, order);
if (!buffer)
return rc;
for (i = 0; i < disks; i++) {
struct address_space *mapping;
char *p;
if (!conf->multipaths[i].operational)
continue;
printk("(checking disk %d)\n",i);
dev = conf->multipaths[i].dev;
bdev = conf->multipaths[i].bdev;
set_blocksize(dev, 4096);
if ((bh = __bread(bdev, row / 4, 4096)) == NULL)
mapping = bdev->bd_inode->i_mapping;
page = read_cache_page(mapping, row/(PAGE_CACHE_SIZE/1024),
(filler_t *)mapping->a_ops->readpage, NULL);
if (IS_ERR(page)) {
page = NULL;
break;
if (!buffer) {
buffer = (char *) __get_free_page(GFP_KERNEL);
if (!buffer)
}
wait_on_page_locked(page);
if (!PageUptodate(page))
break;
if (PageError(page))
break;
memcpy(buffer, bh->b_data, 4096);
} else if (memcmp(buffer, bh->b_data, 4096)) {
p = page_address(page);
if (first) {
memcpy(buffer, p, PAGE_CACHE_SIZE);
first = 0;
} else if (memcmp(buffer, p, PAGE_CACHE_SIZE)) {
rc = 1;
break;
}
bforget(bh);
page_cache_release(page);
fsync_bdev(bdev);
invalidate_bdev(bdev, 0);
bh = NULL;
page = NULL;
}
if (buffer)
free_page((unsigned long) buffer);
if (bh) {
bdev = bh->b_bdev;
bforget(bh);
if (page) {
bdev = page->mapping->host->i_bdev;
page_cache_release(page);
fsync_bdev(bdev);
invalidate_bdev(bdev, 0);
}
free_pages((unsigned long) buffer, order);
return rc;
}
......
......@@ -1062,6 +1062,7 @@ static int __init init_blkmtd(void)
int readonly = 0;
int erase_size = CONFIG_MTD_BLKDEV_ERASESIZE;
kdev_t rdev;
struct block_device *bdev;
int err;
int mode;
int regions;
......@@ -1127,8 +1128,13 @@ static int __init init_blkmtd(void)
printk("blkmtd: attempting to use an MTD device as a block device\n");
return 1;
}
/* get the block device */
bdev = bdget(kdev_t_to_nr(mk_kdev(maj, min)));
err = blkdev_get(bdev, mode, 0, BDEV_RAW);
if (err)
return 1;
DEBUG(1, "blkmtd: devname = %s\n", __bdevname(rdev));
DEBUG(1, "blkmtd: devname = %s\n", bdevname(bdev));
blocksize = BLOCK_SIZE;
blocksize = bs ? bs : block_size(rdev);
......@@ -1139,27 +1145,24 @@ static int __init init_blkmtd(void)
i >>= 1;
}
size = (count ? count*blocksize : blkdev_size_in_bytes(rdev));
size = count ? count*blocksize : bdev->bd_inode->i_size;
DEBUG(1, "blkmtd: size = %ld\n", (long int)size);
if(size == 0) {
printk("blkmtd: cant determine size\n");
blkdev_put(bdev, BDEV_RAW);
return 1;
}
mtd_rawdevice = (mtd_raw_dev_data_t *)kmalloc(sizeof(mtd_raw_dev_data_t), GFP_KERNEL);
if(mtd_rawdevice == NULL) {
blkdev_put(bdev, BDEV_RAW);
err = -ENOMEM;
goto init_err;
}
memset(mtd_rawdevice, 0, sizeof(mtd_raw_dev_data_t));
/* get the block device */
mtd_rawdevice->binding = bdget(kdev_t_to_nr(mk_kdev(maj, min)));
err = blkdev_get(mtd_rawdevice->binding, mode, 0, BDEV_RAW);
if (err) {
goto init_err;
}
mtd_rawdevice->binding = bdev;
mtd_rawdevice->totalsize = size;
mtd_rawdevice->sector_size = blocksize;
mtd_rawdevice->sector_bits = blocksize_bits;
......
......@@ -79,6 +79,7 @@ struct swap_info_struct {
unsigned int flags;
spinlock_t sdev_lock;
struct file *swap_file;
unsigned old_block_size;
unsigned short * swap_map;
unsigned int lowest_bit;
unsigned int highest_bit;
......
......@@ -14,6 +14,7 @@
#include <linux/vmalloc.h>
#include <linux/pagemap.h>
#include <linux/shm.h>
#include <linux/blkdev.h>
#include <linux/compiler.h>
#include <asm/pgtable.h>
......@@ -787,8 +788,12 @@ asmlinkage long sys_swapoff(const char * specialfile)
swap_device_unlock(p);
swap_list_unlock();
vfree(swap_map);
if (S_ISBLK(swap_file->f_dentry->d_inode->i_mode))
bd_release(swap_file->f_dentry->d_inode->i_bdev);
if (S_ISBLK(swap_file->f_dentry->d_inode->i_mode)) {
struct block_device *bdev;
bdev = swap_file->f_dentry->d_inode->i_bdev;
set_blocksize(to_kdev_t(bdev->bd_dev), p->old_block_size);
bd_release(bdev);
}
filp_close(swap_file, NULL);
err = 0;
......@@ -879,6 +884,7 @@ asmlinkage long sys_swapon(const char * specialfile, int swap_flags)
nr_swapfiles = type+1;
p->flags = SWP_USED;
p->swap_file = NULL;
p->old_block_size = 0;
p->swap_map = NULL;
p->lowest_bit = 0;
p->highest_bit = 0;
......@@ -914,6 +920,7 @@ asmlinkage long sys_swapon(const char * specialfile, int swap_flags)
bdev = NULL;
goto bad_swap;
}
p->old_block_size = block_size(to_kdev_t(bdev->bd_dev));
error = set_blocksize(swap_file->f_dentry->d_inode->i_rdev,
PAGE_SIZE);
if (error < 0)
......@@ -1066,8 +1073,10 @@ asmlinkage long sys_swapon(const char * specialfile, int swap_flags)
error = 0;
goto out;
bad_swap:
if (bdev)
if (bdev) {
set_blocksize(to_kdev_t(bdev->bd_dev), p->old_block_size);
bd_release(bdev);
}
bad_swap_2:
swap_list_lock();
swap_map = p->swap_map;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment