aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hpfs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hpfs/file.c')
-rw-r--r--fs/hpfs/file.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
index e4ba5fe4c3b5..4e9dabcf1f4c 100644
--- a/fs/hpfs/file.c
+++ b/fs/hpfs/file.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include "hpfs_fn.h" 9#include "hpfs_fn.h"
10#include <linux/mpage.h>
10 11
11#define BLOCKS(size) (((size) + 511) >> 9) 12#define BLOCKS(size) (((size) + 511) >> 9)
12 13
@@ -34,7 +35,7 @@ int hpfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
34 * so we must ignore such errors. 35 * so we must ignore such errors.
35 */ 36 */
36 37
37static secno hpfs_bmap(struct inode *inode, unsigned file_secno) 38static secno hpfs_bmap(struct inode *inode, unsigned file_secno, unsigned *n_secs)
38{ 39{
39 struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); 40 struct hpfs_inode_info *hpfs_inode = hpfs_i(inode);
40 unsigned n, disk_secno; 41 unsigned n, disk_secno;
@@ -42,11 +43,20 @@ static secno hpfs_bmap(struct inode *inode, unsigned file_secno)
42 struct buffer_head *bh; 43 struct buffer_head *bh;
43 if (BLOCKS(hpfs_i(inode)->mmu_private) <= file_secno) return 0; 44 if (BLOCKS(hpfs_i(inode)->mmu_private) <= file_secno) return 0;
44 n = file_secno - hpfs_inode->i_file_sec; 45 n = file_secno - hpfs_inode->i_file_sec;
45 if (n < hpfs_inode->i_n_secs) return hpfs_inode->i_disk_sec + n; 46 if (n < hpfs_inode->i_n_secs) {
47 *n_secs = hpfs_inode->i_n_secs - n;
48 return hpfs_inode->i_disk_sec + n;
49 }
46 if (!(fnode = hpfs_map_fnode(inode->i_sb, inode->i_ino, &bh))) return 0; 50 if (!(fnode = hpfs_map_fnode(inode->i_sb, inode->i_ino, &bh))) return 0;
47 disk_secno = hpfs_bplus_lookup(inode->i_sb, inode, &fnode->btree, file_secno, bh); 51 disk_secno = hpfs_bplus_lookup(inode->i_sb, inode, &fnode->btree, file_secno, bh);
48 if (disk_secno == -1) return 0; 52 if (disk_secno == -1) return 0;
49 if (hpfs_chk_sectors(inode->i_sb, disk_secno, 1, "bmap")) return 0; 53 if (hpfs_chk_sectors(inode->i_sb, disk_secno, 1, "bmap")) return 0;
54 n = file_secno - hpfs_inode->i_file_sec;
55 if (n < hpfs_inode->i_n_secs) {
56 *n_secs = hpfs_inode->i_n_secs - n;
57 return hpfs_inode->i_disk_sec + n;
58 }
59 *n_secs = 1;
50 return disk_secno; 60 return disk_secno;
51} 61}
52 62
@@ -67,10 +77,14 @@ static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_he
67{ 77{
68 int r; 78 int r;
69 secno s; 79 secno s;
80 unsigned n_secs;
70 hpfs_lock(inode->i_sb); 81 hpfs_lock(inode->i_sb);
71 s = hpfs_bmap(inode, iblock); 82 s = hpfs_bmap(inode, iblock, &n_secs);
72 if (s) { 83 if (s) {
84 if (bh_result->b_size >> 9 < n_secs)
85 n_secs = bh_result->b_size >> 9;
73 map_bh(bh_result, inode->i_sb, s); 86 map_bh(bh_result, inode->i_sb, s);
87 bh_result->b_size = n_secs << 9;
74 goto ret_0; 88 goto ret_0;
75 } 89 }
76 if (!create) goto ret_0; 90 if (!create) goto ret_0;
@@ -95,14 +109,26 @@ static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_he
95 return r; 109 return r;
96} 110}
97 111
112static int hpfs_readpage(struct file *file, struct page *page)
113{
114 return mpage_readpage(page, hpfs_get_block);
115}
116
98static int hpfs_writepage(struct page *page, struct writeback_control *wbc) 117static int hpfs_writepage(struct page *page, struct writeback_control *wbc)
99{ 118{
100 return block_write_full_page(page,hpfs_get_block, wbc); 119 return block_write_full_page(page, hpfs_get_block, wbc);
101} 120}
102 121
103static int hpfs_readpage(struct file *file, struct page *page) 122static int hpfs_readpages(struct file *file, struct address_space *mapping,
123 struct list_head *pages, unsigned nr_pages)
124{
125 return mpage_readpages(mapping, pages, nr_pages, hpfs_get_block);
126}
127
128static int hpfs_writepages(struct address_space *mapping,
129 struct writeback_control *wbc)
104{ 130{
105 return block_read_full_page(page,hpfs_get_block); 131 return mpage_writepages(mapping, wbc, hpfs_get_block);
106} 132}
107 133
108static void hpfs_write_failed(struct address_space *mapping, loff_t to) 134static void hpfs_write_failed(struct address_space *mapping, loff_t to)
@@ -161,6 +187,8 @@ static sector_t _hpfs_bmap(struct address_space *mapping, sector_t block)
161const struct address_space_operations hpfs_aops = { 187const struct address_space_operations hpfs_aops = {
162 .readpage = hpfs_readpage, 188 .readpage = hpfs_readpage,
163 .writepage = hpfs_writepage, 189 .writepage = hpfs_writepage,
190 .readpages = hpfs_readpages,
191 .writepages = hpfs_writepages,
164 .write_begin = hpfs_write_begin, 192 .write_begin = hpfs_write_begin,
165 .write_end = hpfs_write_end, 193 .write_end = hpfs_write_end,
166 .bmap = _hpfs_bmap 194 .bmap = _hpfs_bmap