i2c: Provide compatibility links for i2c adapters
[safe/jmp/linux-2.6] / fs / block_dev.c
index d250f80..71e7e03 100644 (file)
@@ -77,7 +77,7 @@ int set_blocksize(struct block_device *bdev, int size)
                return -EINVAL;
 
        /* Size cannot be smaller than the size supported by the device */
-       if (size < bdev_hardsect_size(bdev))
+       if (size < bdev_logical_block_size(bdev))
                return -EINVAL;
 
        /* Don't change the size if it is same as current */
@@ -107,7 +107,7 @@ EXPORT_SYMBOL(sb_set_blocksize);
 
 int sb_min_blocksize(struct super_block *sb, int size)
 {
-       int minsize = bdev_hardsect_size(sb->s_bdev);
+       int minsize = bdev_logical_block_size(sb->s_bdev);
        if (size < minsize)
                size = minsize;
        return sb_set_blocksize(sb, size);
@@ -176,17 +176,22 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
                                iov, offset, nr_segs, blkdev_get_blocks, NULL);
 }
 
+int __sync_blockdev(struct block_device *bdev, int wait)
+{
+       if (!bdev)
+               return 0;
+       if (!wait)
+               return filemap_flush(bdev->bd_inode->i_mapping);
+       return filemap_write_and_wait(bdev->bd_inode->i_mapping);
+}
+
 /*
  * Write out and wait upon all the dirty data associated with a block
  * device via its mapping.  Does not take the superblock lock.
  */
 int sync_blockdev(struct block_device *bdev)
 {
-       int ret = 0;
-
-       if (bdev)
-               ret = filemap_write_and_wait(bdev->bd_inode->i_mapping);
-       return ret;
+       return __sync_blockdev(bdev, 1);
 }
 EXPORT_SYMBOL(sync_blockdev);
 
@@ -199,7 +204,7 @@ int fsync_bdev(struct block_device *bdev)
 {
        struct super_block *sb = get_super(bdev);
        if (sb) {
-               int res = fsync_super(sb);
+               int res = sync_filesystem(sb);
                drop_super(sb);
                return res;
        }
@@ -241,7 +246,7 @@ struct super_block *freeze_bdev(struct block_device *bdev)
                sb->s_frozen = SB_FREEZE_WRITE;
                smp_wmb();
 
-               __fsync_super(sb);
+               sync_filesystem(sb);
 
                sb->s_frozen = SB_FREEZE_TRANS;
                smp_wmb();
@@ -415,7 +420,6 @@ static void bdev_destroy_inode(struct inode *inode)
 {
        struct bdev_inode *bdi = BDEV_I(inode);
 
-       bdi->bdev.bd_inode_backing_dev_info = NULL;
        kmem_cache_free(bdev_cachep, bdi);
 }
 
@@ -559,6 +563,16 @@ struct block_device *bdget(dev_t dev)
 
 EXPORT_SYMBOL(bdget);
 
+/**
+ * bdgrab -- Grab a reference to an already referenced block device
+ * @bdev:      Block device to grab a reference to.
+ */
+struct block_device *bdgrab(struct block_device *bdev)
+{
+       atomic_inc(&bdev->bd_inode->i_count);
+       return bdev;
+}
+
 long nr_blockdev_pages(void)
 {
        struct block_device *bdev;
@@ -1117,7 +1131,7 @@ EXPORT_SYMBOL(check_disk_change);
 
 void bd_set_size(struct block_device *bdev, loff_t size)
 {
-       unsigned bsize = bdev_hardsect_size(bdev);
+       unsigned bsize = bdev_logical_block_size(bdev);
 
        bdev->bd_inode->i_size = size;
        while (bsize < PAGE_CACHE_SIZE) {
@@ -1390,6 +1404,33 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 }
 
 /*
+ * Write data to the block device.  Only intended for the block device itself
+ * and the raw driver which basically is a fake block device.
+ *
+ * Does not take i_mutex for the write and thus is not for general purpose
+ * use.
+ */
+ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
+                        unsigned long nr_segs, loff_t pos)
+{
+       struct file *file = iocb->ki_filp;
+       ssize_t ret;
+
+       BUG_ON(iocb->ki_pos != pos);
+
+       ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos);
+       if (ret > 0 || ret == -EIOCBQUEUED) {
+               ssize_t err;
+
+               err = generic_write_sync(file, pos, ret);
+               if (err < 0 && ret > 0)
+                       ret = err;
+       }
+       return ret;
+}
+EXPORT_SYMBOL_GPL(blkdev_aio_write);
+
+/*
  * Try to release a page associated with block device when the system
  * is under memory pressure.
  */
@@ -1421,7 +1462,7 @@ const struct file_operations def_blk_fops = {
        .read           = do_sync_read,
        .write          = do_sync_write,
        .aio_read       = generic_file_aio_read,
-       .aio_write      = generic_file_aio_write_nolock,
+       .aio_write      = blkdev_aio_write,
        .mmap           = generic_file_mmap,
        .fsync          = block_fsync,
        .unlocked_ioctl = block_ioctl,