]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/affs/file.c
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[karo-tx-linux.git] / fs / affs / file.c
index 8e2e60ea1e2333f3e1eeb900f921b855a91772dd..8faa6593ca6defe4ab77c169f3fe9673b84a9ec3 100644 (file)
  *  affs regular file handling primitives
  */
 
+#include <linux/aio.h>
 #include "affs.h"
 
-#if PAGE_SIZE < 4096
-#error PAGE_SIZE must be at least 4096
-#endif
-
 static struct buffer_head *affs_get_extblock_slow(struct inode *inode, u32 ext);
 
 static int
@@ -333,7 +330,8 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul
 
                /* store new block */
                if (bh_result->b_blocknr)
-                       affs_warning(sb, "get_block", "block already set (%x)", bh_result->b_blocknr);
+                       affs_warning(sb, "get_block", "block already set (%lx)",
+                                    (unsigned long)bh_result->b_blocknr);
                AFFS_BLOCK(sb, ext_bh, block) = cpu_to_be32(blocknr);
                AFFS_HEAD(ext_bh)->block_count = cpu_to_be32(block + 1);
                affs_adjust_checksum(ext_bh, blocknr - bh_result->b_blocknr + 1);
@@ -355,7 +353,8 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul
        return 0;
 
 err_big:
-       affs_error(inode->i_sb,"get_block","strange block request %d", block);
+       affs_error(inode->i_sb, "get_block", "strange block request %d",
+                  (int)block);
        return -EIO;
 err_ext:
        // unlock cache
@@ -390,6 +389,22 @@ static void affs_write_failed(struct address_space *mapping, loff_t to)
        }
 }
 
+static ssize_t
+affs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
+              loff_t offset)
+{
+       struct file *file = iocb->ki_filp;
+       struct address_space *mapping = file->f_mapping;
+       struct inode *inode = mapping->host;
+       size_t count = iov_iter_count(iter);
+       ssize_t ret;
+
+       ret = blockdev_direct_IO(rw, iocb, inode, iter, offset, affs_get_block);
+       if (ret < 0 && (rw & WRITE))
+               affs_write_failed(mapping, offset + count);
+       return ret;
+}
+
 static int affs_write_begin(struct file *file, struct address_space *mapping,
                        loff_t pos, unsigned len, unsigned flags,
                        struct page **pagep, void **fsdata)
@@ -416,6 +431,7 @@ const struct address_space_operations affs_aops = {
        .writepage = affs_writepage,
        .write_begin = affs_write_begin,
        .write_end = generic_write_end,
+       .direct_IO = affs_direct_IO,
        .bmap = _affs_bmap
 };
 
@@ -845,8 +861,9 @@ affs_truncate(struct inode *inode)
        // lock cache
        ext_bh = affs_get_extblock(inode, ext);
        if (IS_ERR(ext_bh)) {
-               affs_warning(sb, "truncate", "unexpected read error for ext block %u (%d)",
-                            ext, PTR_ERR(ext_bh));
+               affs_warning(sb, "truncate",
+                            "unexpected read error for ext block %u (%ld)",
+                            (unsigned int)ext, PTR_ERR(ext_bh));
                return;
        }
        if (AFFS_I(inode)->i_lc) {
@@ -892,8 +909,9 @@ affs_truncate(struct inode *inode)
                        struct buffer_head *bh = affs_bread_ino(inode, last_blk, 0);
                        u32 tmp;
                        if (IS_ERR(bh)) {
-                               affs_warning(sb, "truncate", "unexpected read error for last block %u (%d)",
-                                            ext, PTR_ERR(bh));
+                               affs_warning(sb, "truncate",
+                                            "unexpected read error for last block %u (%ld)",
+                                            (unsigned int)ext, PTR_ERR(bh));
                                return;
                        }
                        tmp = be32_to_cpu(AFFS_DATA_HEAD(bh)->next);