aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/block_dev.c3
-rw-r--r--fs/direct-io.c27
-rw-r--r--fs/ext2/inode.c14
-rw-r--r--fs/ext3/inode.c12
-rw-r--r--fs/fat/inode.c2
-rw-r--r--fs/hfs/inode.c13
-rw-r--r--fs/hfsplus/inode.c13
-rw-r--r--fs/jfs/inode.c2
-rw-r--r--fs/ocfs2/aops.c2
-rw-r--r--fs/reiserfs/inode.c1
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c6
11 files changed, 27 insertions, 68 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9a451a9ffad4..5983d42df015 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -131,9 +131,10 @@ blkdev_get_block(struct inode *inode, sector_t iblock,
131 131
132static int 132static int
133blkdev_get_blocks(struct inode *inode, sector_t iblock, 133blkdev_get_blocks(struct inode *inode, sector_t iblock,
134 unsigned long max_blocks, struct buffer_head *bh, int create) 134 struct buffer_head *bh, int create)
135{ 135{
136 sector_t end_block = max_block(I_BDEV(inode)); 136 sector_t end_block = max_block(I_BDEV(inode));
137 unsigned long max_blocks = bh->b_size >> inode->i_blkbits;
137 138
138 if ((iblock + max_blocks) > end_block) { 139 if ((iblock + max_blocks) > end_block) {
139 max_blocks = end_block - iblock; 140 max_blocks = end_block - iblock;
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 235ed8d1f11e..9d1d2aa73e42 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -86,12 +86,12 @@ struct dio {
86 unsigned first_block_in_page; /* doesn't change, Used only once */ 86 unsigned first_block_in_page; /* doesn't change, Used only once */
87 int boundary; /* prev block is at a boundary */ 87 int boundary; /* prev block is at a boundary */
88 int reap_counter; /* rate limit reaping */ 88 int reap_counter; /* rate limit reaping */
89 get_blocks_t *get_blocks; /* block mapping function */ 89 get_block_t *get_block; /* block mapping function */
90 dio_iodone_t *end_io; /* IO completion function */ 90 dio_iodone_t *end_io; /* IO completion function */
91 sector_t final_block_in_bio; /* current final block in bio + 1 */ 91 sector_t final_block_in_bio; /* current final block in bio + 1 */
92 sector_t next_block_for_io; /* next block to be put under IO, 92 sector_t next_block_for_io; /* next block to be put under IO,
93 in dio_blocks units */ 93 in dio_blocks units */
94 struct buffer_head map_bh; /* last get_blocks() result */ 94 struct buffer_head map_bh; /* last get_block() result */
95 95
96 /* 96 /*
97 * Deferred addition of a page to the dio. These variables are 97 * Deferred addition of a page to the dio. These variables are
@@ -211,9 +211,9 @@ static struct page *dio_get_page(struct dio *dio)
211 211
212/* 212/*
213 * Called when all DIO BIO I/O has been completed - let the filesystem 213 * Called when all DIO BIO I/O has been completed - let the filesystem
214 * know, if it registered an interest earlier via get_blocks. Pass the 214 * know, if it registered an interest earlier via get_block. Pass the
215 * private field of the map buffer_head so that filesystems can use it 215 * private field of the map buffer_head so that filesystems can use it
216 * to hold additional state between get_blocks calls and dio_complete. 216 * to hold additional state between get_block calls and dio_complete.
217 */ 217 */
218static void dio_complete(struct dio *dio, loff_t offset, ssize_t bytes) 218static void dio_complete(struct dio *dio, loff_t offset, ssize_t bytes)
219{ 219{
@@ -493,7 +493,7 @@ static int dio_bio_reap(struct dio *dio)
493 * The fs is allowed to map lots of blocks at once. If it wants to do that, 493 * The fs is allowed to map lots of blocks at once. If it wants to do that,
494 * it uses the passed inode-relative block number as the file offset, as usual. 494 * it uses the passed inode-relative block number as the file offset, as usual.
495 * 495 *
496 * get_blocks() is passed the number of i_blkbits-sized blocks which direct_io 496 * get_block() is passed the number of i_blkbits-sized blocks which direct_io
497 * has remaining to do. The fs should not map more than this number of blocks. 497 * has remaining to do. The fs should not map more than this number of blocks.
498 * 498 *
499 * If the fs has mapped a lot of blocks, it should populate bh->b_size to 499 * If the fs has mapped a lot of blocks, it should populate bh->b_size to
@@ -506,7 +506,7 @@ static int dio_bio_reap(struct dio *dio)
506 * In the case of filesystem holes: the fs may return an arbitrarily-large 506 * In the case of filesystem holes: the fs may return an arbitrarily-large
507 * hole by returning an appropriate value in b_size and by clearing 507 * hole by returning an appropriate value in b_size and by clearing
508 * buffer_mapped(). However the direct-io code will only process holes one 508 * buffer_mapped(). However the direct-io code will only process holes one
509 * block at a time - it will repeatedly call get_blocks() as it walks the hole. 509 * block at a time - it will repeatedly call get_block() as it walks the hole.
510 */ 510 */
511static int get_more_blocks(struct dio *dio) 511static int get_more_blocks(struct dio *dio)
512{ 512{
@@ -548,7 +548,8 @@ static int get_more_blocks(struct dio *dio)
548 * at a higher level for inside-i_size block-instantiating 548 * at a higher level for inside-i_size block-instantiating
549 * writes. 549 * writes.
550 */ 550 */
551 ret = (*dio->get_blocks)(dio->inode, fs_startblk, fs_count, 551 map_bh->b_size = fs_count << dio->blkbits;
552 ret = (*dio->get_block)(dio->inode, fs_startblk,
552 map_bh, create); 553 map_bh, create);
553 } 554 }
554 return ret; 555 return ret;
@@ -783,11 +784,11 @@ static void dio_zero_block(struct dio *dio, int end)
783 * happily perform page-sized but 512-byte aligned IOs. It is important that 784 * happily perform page-sized but 512-byte aligned IOs. It is important that
784 * blockdev IO be able to have fine alignment and large sizes. 785 * blockdev IO be able to have fine alignment and large sizes.
785 * 786 *
786 * So what we do is to permit the ->get_blocks function to populate bh.b_size 787 * So what we do is to permit the ->get_block function to populate bh.b_size
787 * with the size of IO which is permitted at this offset and this i_blkbits. 788 * with the size of IO which is permitted at this offset and this i_blkbits.
788 * 789 *
789 * For best results, the blockdev should be set up with 512-byte i_blkbits and 790 * For best results, the blockdev should be set up with 512-byte i_blkbits and
790 * it should set b_size to PAGE_SIZE or more inside get_blocks(). This gives 791 * it should set b_size to PAGE_SIZE or more inside get_block(). This gives
791 * fine alignment but still allows this function to work in PAGE_SIZE units. 792 * fine alignment but still allows this function to work in PAGE_SIZE units.
792 */ 793 */
793static int do_direct_IO(struct dio *dio) 794static int do_direct_IO(struct dio *dio)
@@ -947,7 +948,7 @@ out:
947static ssize_t 948static ssize_t
948direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode, 949direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
949 const struct iovec *iov, loff_t offset, unsigned long nr_segs, 950 const struct iovec *iov, loff_t offset, unsigned long nr_segs,
950 unsigned blkbits, get_blocks_t get_blocks, dio_iodone_t end_io, 951 unsigned blkbits, get_block_t get_block, dio_iodone_t end_io,
951 struct dio *dio) 952 struct dio *dio)
952{ 953{
953 unsigned long user_addr; 954 unsigned long user_addr;
@@ -969,7 +970,7 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
969 970
970 dio->boundary = 0; 971 dio->boundary = 0;
971 dio->reap_counter = 0; 972 dio->reap_counter = 0;
972 dio->get_blocks = get_blocks; 973 dio->get_block = get_block;
973 dio->end_io = end_io; 974 dio->end_io = end_io;
974 dio->map_bh.b_private = NULL; 975 dio->map_bh.b_private = NULL;
975 dio->final_block_in_bio = -1; 976 dio->final_block_in_bio = -1;
@@ -1177,7 +1178,7 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
1177ssize_t 1178ssize_t
1178__blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, 1179__blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1179 struct block_device *bdev, const struct iovec *iov, loff_t offset, 1180 struct block_device *bdev, const struct iovec *iov, loff_t offset,
1180 unsigned long nr_segs, get_blocks_t get_blocks, dio_iodone_t end_io, 1181 unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io,
1181 int dio_lock_type) 1182 int dio_lock_type)
1182{ 1183{
1183 int seg; 1184 int seg;
@@ -1273,7 +1274,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1273 (end > i_size_read(inode))); 1274 (end > i_size_read(inode)));
1274 1275
1275 retval = direct_io_worker(rw, iocb, inode, iov, offset, 1276 retval = direct_io_worker(rw, iocb, inode, iov, offset,
1276 nr_segs, blkbits, get_blocks, end_io, dio); 1277 nr_segs, blkbits, get_block, end_io, dio);
1277 1278
1278 if (rw == READ && dio_lock_type == DIO_LOCKING) 1279 if (rw == READ && dio_lock_type == DIO_LOCKING)
1279 release_i_mutex = 0; 1280 release_i_mutex = 0;
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index a717837f272e..04af9c45dce2 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -667,18 +667,6 @@ static sector_t ext2_bmap(struct address_space *mapping, sector_t block)
667 return generic_block_bmap(mapping,block,ext2_get_block); 667 return generic_block_bmap(mapping,block,ext2_get_block);
668} 668}
669 669
670static int
671ext2_get_blocks(struct inode *inode, sector_t iblock, unsigned long max_blocks,
672 struct buffer_head *bh_result, int create)
673{
674 int ret;
675
676 ret = ext2_get_block(inode, iblock, bh_result, create);
677 if (ret == 0)
678 bh_result->b_size = (1 << inode->i_blkbits);
679 return ret;
680}
681
682static ssize_t 670static ssize_t
683ext2_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, 671ext2_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
684 loff_t offset, unsigned long nr_segs) 672 loff_t offset, unsigned long nr_segs)
@@ -687,7 +675,7 @@ ext2_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
687 struct inode *inode = file->f_mapping->host; 675 struct inode *inode = file->f_mapping->host;
688 676
689 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, 677 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
690 offset, nr_segs, ext2_get_blocks, NULL); 678 offset, nr_segs, ext2_get_block, NULL);
691} 679}
692 680
693static int 681static int
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 34e5b0dc9168..0cd126176bbb 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -940,11 +940,11 @@ out:
940 940
941static int 941static int
942ext3_direct_io_get_blocks(struct inode *inode, sector_t iblock, 942ext3_direct_io_get_blocks(struct inode *inode, sector_t iblock,
943 unsigned long max_blocks,
944 struct buffer_head *bh_result, int create) 943 struct buffer_head *bh_result, int create)
945{ 944{
946 handle_t *handle = journal_current_handle(); 945 handle_t *handle = journal_current_handle();
947 int ret = 0; 946 int ret = 0;
947 unsigned max_blocks = bh_result->b_size >> inode->i_blkbits;
948 948
949 if (!create) 949 if (!create)
950 goto get_block; /* A read */ 950 goto get_block; /* A read */
@@ -989,18 +989,10 @@ get_block:
989 return ret; 989 return ret;
990} 990}
991 991
992static int ext3_get_blocks(struct inode *inode, sector_t iblock,
993 unsigned long maxblocks, struct buffer_head *bh_result,
994 int create)
995{
996 return ext3_direct_io_get_blocks(inode, iblock, maxblocks,
997 bh_result, create);
998}
999
1000static int ext3_get_block(struct inode *inode, sector_t iblock, 992static int ext3_get_block(struct inode *inode, sector_t iblock,
1001 struct buffer_head *bh_result, int create) 993 struct buffer_head *bh_result, int create)
1002{ 994{
1003 return ext3_get_blocks(inode, iblock, 1, bh_result, create); 995 return ext3_direct_io_get_blocks(inode, iblock, bh_result, create);
1004} 996}
1005 997
1006/* 998/*
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 297300fe81c2..404bfc9f7385 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -101,11 +101,11 @@ static int __fat_get_blocks(struct inode *inode, sector_t iblock,
101} 101}
102 102
103static int fat_get_blocks(struct inode *inode, sector_t iblock, 103static int fat_get_blocks(struct inode *inode, sector_t iblock,
104 unsigned long max_blocks,
105 struct buffer_head *bh_result, int create) 104 struct buffer_head *bh_result, int create)
106{ 105{
107 struct super_block *sb = inode->i_sb; 106 struct super_block *sb = inode->i_sb;
108 int err; 107 int err;
108 unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits;
109 109
110 err = __fat_get_blocks(inode, iblock, &max_blocks, bh_result, create); 110 err = __fat_get_blocks(inode, iblock, &max_blocks, bh_result, create);
111 if (err) 111 if (err)
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 39fd85b9b916..2c564701724f 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -98,17 +98,6 @@ static int hfs_releasepage(struct page *page, gfp_t mask)
98 return res ? try_to_free_buffers(page) : 0; 98 return res ? try_to_free_buffers(page) : 0;
99} 99}
100 100
101static int hfs_get_blocks(struct inode *inode, sector_t iblock, unsigned long max_blocks,
102 struct buffer_head *bh_result, int create)
103{
104 int ret;
105
106 ret = hfs_get_block(inode, iblock, bh_result, create);
107 if (!ret)
108 bh_result->b_size = (1 << inode->i_blkbits);
109 return ret;
110}
111
112static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb, 101static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
113 const struct iovec *iov, loff_t offset, unsigned long nr_segs) 102 const struct iovec *iov, loff_t offset, unsigned long nr_segs)
114{ 103{
@@ -116,7 +105,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
116 struct inode *inode = file->f_dentry->d_inode->i_mapping->host; 105 struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
117 106
118 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, 107 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
119 offset, nr_segs, hfs_get_blocks, NULL); 108 offset, nr_segs, hfs_get_block, NULL);
120} 109}
121 110
122static int hfs_writepages(struct address_space *mapping, 111static int hfs_writepages(struct address_space *mapping,
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 12ed2b7d046b..9fbe4d2aeece 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -93,17 +93,6 @@ static int hfsplus_releasepage(struct page *page, gfp_t mask)
93 return res ? try_to_free_buffers(page) : 0; 93 return res ? try_to_free_buffers(page) : 0;
94} 94}
95 95
96static int hfsplus_get_blocks(struct inode *inode, sector_t iblock, unsigned long max_blocks,
97 struct buffer_head *bh_result, int create)
98{
99 int ret;
100
101 ret = hfsplus_get_block(inode, iblock, bh_result, create);
102 if (!ret)
103 bh_result->b_size = (1 << inode->i_blkbits);
104 return ret;
105}
106
107static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb, 96static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
108 const struct iovec *iov, loff_t offset, unsigned long nr_segs) 97 const struct iovec *iov, loff_t offset, unsigned long nr_segs)
109{ 98{
@@ -111,7 +100,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
111 struct inode *inode = file->f_dentry->d_inode->i_mapping->host; 100 struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
112 101
113 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, 102 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
114 offset, nr_segs, hfsplus_get_blocks, NULL); 103 offset, nr_segs, hfsplus_get_block, NULL);
115} 104}
116 105
117static int hfsplus_writepages(struct address_space *mapping, 106static int hfsplus_writepages(struct address_space *mapping,
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 7239ef339489..04eb78f1252e 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -302,7 +302,7 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
302 struct inode *inode = file->f_mapping->host; 302 struct inode *inode = file->f_mapping->host;
303 303
304 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, 304 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
305 offset, nr_segs, jfs_get_blocks, NULL); 305 offset, nr_segs, jfs_get_block, NULL);
306} 306}
307 307
308struct address_space_operations jfs_aops = { 308struct address_space_operations jfs_aops = {
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index bf931ba1d364..0d858d0b25be 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -540,7 +540,6 @@ bail:
540 * fs_count, map_bh, dio->rw == WRITE); 540 * fs_count, map_bh, dio->rw == WRITE);
541 */ 541 */
542static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, 542static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock,
543 unsigned long max_blocks,
544 struct buffer_head *bh_result, int create) 543 struct buffer_head *bh_result, int create)
545{ 544{
546 int ret; 545 int ret;
@@ -548,6 +547,7 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock,
548 u64 p_blkno; 547 u64 p_blkno;
549 int contig_blocks; 548 int contig_blocks;
550 unsigned char blocksize_bits; 549 unsigned char blocksize_bits;
550 unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits;
551 551
552 if (!inode || !bh_result) { 552 if (!inode || !bh_result) {
553 mlog(ML_ERROR, "inode or bh_result is null\n"); 553 mlog(ML_ERROR, "inode or bh_result is null\n");
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 62e18c19b446..9857e50f85e7 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -466,7 +466,6 @@ static int reiserfs_get_block_create_0(struct inode *inode, sector_t block,
466 direct_IO request. */ 466 direct_IO request. */
467static int reiserfs_get_blocks_direct_io(struct inode *inode, 467static int reiserfs_get_blocks_direct_io(struct inode *inode,
468 sector_t iblock, 468 sector_t iblock,
469 unsigned long max_blocks,
470 struct buffer_head *bh_result, 469 struct buffer_head *bh_result,
471 int create) 470 int create)
472{ 471{
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index a79b84f8b55c..c02f7c5b7462 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -1319,12 +1319,12 @@ STATIC int
1319xfs_get_blocks_direct( 1319xfs_get_blocks_direct(
1320 struct inode *inode, 1320 struct inode *inode,
1321 sector_t iblock, 1321 sector_t iblock,
1322 unsigned long max_blocks,
1323 struct buffer_head *bh_result, 1322 struct buffer_head *bh_result,
1324 int create) 1323 int create)
1325{ 1324{
1326 return __xfs_get_block(inode, iblock, max_blocks, bh_result, 1325 return __xfs_get_block(inode, iblock,
1327 create, 1, BMAPI_WRITE|BMAPI_DIRECT); 1326 bh_result->b_size >> inode->i_blkbits,
1327 bh_result, create, 1, BMAPI_WRITE|BMAPI_DIRECT);
1328} 1328}
1329 1329
1330STATIC void 1330STATIC void