diff options
-rw-r--r-- | fs/minix/dir.c | 49 | ||||
-rw-r--r-- | fs/minix/inode.c | 23 | ||||
-rw-r--r-- | fs/minix/minix.h | 3 |
3 files changed, 53 insertions, 22 deletions
diff --git a/fs/minix/dir.c b/fs/minix/dir.c index e207cbe70951..f70433816a38 100644 --- a/fs/minix/dir.c +++ b/fs/minix/dir.c | |||
@@ -9,8 +9,10 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include "minix.h" | 11 | #include "minix.h" |
12 | #include <linux/buffer_head.h> | ||
12 | #include <linux/highmem.h> | 13 | #include <linux/highmem.h> |
13 | #include <linux/smp_lock.h> | 14 | #include <linux/smp_lock.h> |
15 | #include <linux/swap.h> | ||
14 | 16 | ||
15 | typedef struct minix_dir_entry minix_dirent; | 17 | typedef struct minix_dir_entry minix_dirent; |
16 | typedef struct minix3_dir_entry minix3_dirent; | 18 | typedef struct minix3_dir_entry minix3_dirent; |
@@ -48,11 +50,17 @@ static inline unsigned long dir_pages(struct inode *inode) | |||
48 | return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT; | 50 | return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT; |
49 | } | 51 | } |
50 | 52 | ||
51 | static int dir_commit_chunk(struct page *page, unsigned from, unsigned to) | 53 | static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len) |
52 | { | 54 | { |
53 | struct inode *dir = (struct inode *)page->mapping->host; | 55 | struct address_space *mapping = page->mapping; |
56 | struct inode *dir = mapping->host; | ||
54 | int err = 0; | 57 | int err = 0; |
55 | page->mapping->a_ops->commit_write(NULL, page, from, to); | 58 | block_write_end(NULL, mapping, pos, len, len, page, NULL); |
59 | |||
60 | if (pos+len > dir->i_size) { | ||
61 | i_size_write(dir, pos+len); | ||
62 | mark_inode_dirty(dir); | ||
63 | } | ||
56 | if (IS_DIRSYNC(dir)) | 64 | if (IS_DIRSYNC(dir)) |
57 | err = write_one_page(page, 1); | 65 | err = write_one_page(page, 1); |
58 | else | 66 | else |
@@ -220,7 +228,7 @@ int minix_add_link(struct dentry *dentry, struct inode *inode) | |||
220 | char *kaddr, *p; | 228 | char *kaddr, *p; |
221 | minix_dirent *de; | 229 | minix_dirent *de; |
222 | minix3_dirent *de3; | 230 | minix3_dirent *de3; |
223 | unsigned from, to; | 231 | loff_t pos; |
224 | int err; | 232 | int err; |
225 | char *namx = NULL; | 233 | char *namx = NULL; |
226 | __u32 inumber; | 234 | __u32 inumber; |
@@ -272,9 +280,9 @@ int minix_add_link(struct dentry *dentry, struct inode *inode) | |||
272 | return -EINVAL; | 280 | return -EINVAL; |
273 | 281 | ||
274 | got_it: | 282 | got_it: |
275 | from = p - (char*)page_address(page); | 283 | pos = (page->index >> PAGE_CACHE_SHIFT) + p - (char*)page_address(page); |
276 | to = from + sbi->s_dirsize; | 284 | err = __minix_write_begin(NULL, page->mapping, pos, sbi->s_dirsize, |
277 | err = page->mapping->a_ops->prepare_write(NULL, page, from, to); | 285 | AOP_FLAG_UNINTERRUPTIBLE, &page, NULL); |
278 | if (err) | 286 | if (err) |
279 | goto out_unlock; | 287 | goto out_unlock; |
280 | memcpy (namx, name, namelen); | 288 | memcpy (namx, name, namelen); |
@@ -285,7 +293,7 @@ got_it: | |||
285 | memset (namx + namelen, 0, sbi->s_dirsize - namelen - 2); | 293 | memset (namx + namelen, 0, sbi->s_dirsize - namelen - 2); |
286 | de->inode = inode->i_ino; | 294 | de->inode = inode->i_ino; |
287 | } | 295 | } |
288 | err = dir_commit_chunk(page, from, to); | 296 | err = dir_commit_chunk(page, pos, sbi->s_dirsize); |
289 | dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC; | 297 | dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC; |
290 | mark_inode_dirty(dir); | 298 | mark_inode_dirty(dir); |
291 | out_put: | 299 | out_put: |
@@ -302,15 +310,16 @@ int minix_delete_entry(struct minix_dir_entry *de, struct page *page) | |||
302 | struct address_space *mapping = page->mapping; | 310 | struct address_space *mapping = page->mapping; |
303 | struct inode *inode = (struct inode*)mapping->host; | 311 | struct inode *inode = (struct inode*)mapping->host; |
304 | char *kaddr = page_address(page); | 312 | char *kaddr = page_address(page); |
305 | unsigned from = (char*)de - kaddr; | 313 | loff_t pos = page_offset(page) + (char*)de - kaddr; |
306 | unsigned to = from + minix_sb(inode->i_sb)->s_dirsize; | 314 | unsigned len = minix_sb(inode->i_sb)->s_dirsize; |
307 | int err; | 315 | int err; |
308 | 316 | ||
309 | lock_page(page); | 317 | lock_page(page); |
310 | err = mapping->a_ops->prepare_write(NULL, page, from, to); | 318 | err = __minix_write_begin(NULL, mapping, pos, len, |
319 | AOP_FLAG_UNINTERRUPTIBLE, &page, NULL); | ||
311 | if (err == 0) { | 320 | if (err == 0) { |
312 | de->inode = 0; | 321 | de->inode = 0; |
313 | err = dir_commit_chunk(page, from, to); | 322 | err = dir_commit_chunk(page, pos, len); |
314 | } else { | 323 | } else { |
315 | unlock_page(page); | 324 | unlock_page(page); |
316 | } | 325 | } |
@@ -330,7 +339,8 @@ int minix_make_empty(struct inode *inode, struct inode *dir) | |||
330 | 339 | ||
331 | if (!page) | 340 | if (!page) |
332 | return -ENOMEM; | 341 | return -ENOMEM; |
333 | err = mapping->a_ops->prepare_write(NULL, page, 0, 2 * sbi->s_dirsize); | 342 | err = __minix_write_begin(NULL, mapping, 0, 2 * sbi->s_dirsize, |
343 | AOP_FLAG_UNINTERRUPTIBLE, &page, NULL); | ||
334 | if (err) { | 344 | if (err) { |
335 | unlock_page(page); | 345 | unlock_page(page); |
336 | goto fail; | 346 | goto fail; |
@@ -421,17 +431,20 @@ not_empty: | |||
421 | void minix_set_link(struct minix_dir_entry *de, struct page *page, | 431 | void minix_set_link(struct minix_dir_entry *de, struct page *page, |
422 | struct inode *inode) | 432 | struct inode *inode) |
423 | { | 433 | { |
424 | struct inode *dir = (struct inode*)page->mapping->host; | 434 | struct address_space *mapping = page->mapping; |
435 | struct inode *dir = mapping->host; | ||
425 | struct minix_sb_info *sbi = minix_sb(dir->i_sb); | 436 | struct minix_sb_info *sbi = minix_sb(dir->i_sb); |
426 | unsigned from = (char *)de-(char*)page_address(page); | 437 | loff_t pos = page_offset(page) + |
427 | unsigned to = from + sbi->s_dirsize; | 438 | (char *)de-(char*)page_address(page); |
428 | int err; | 439 | int err; |
429 | 440 | ||
430 | lock_page(page); | 441 | lock_page(page); |
431 | err = page->mapping->a_ops->prepare_write(NULL, page, from, to); | 442 | |
443 | err = __minix_write_begin(NULL, mapping, pos, sbi->s_dirsize, | ||
444 | AOP_FLAG_UNINTERRUPTIBLE, &page, NULL); | ||
432 | if (err == 0) { | 445 | if (err == 0) { |
433 | de->inode = inode->i_ino; | 446 | de->inode = inode->i_ino; |
434 | err = dir_commit_chunk(page, from, to); | 447 | err = dir_commit_chunk(page, pos, sbi->s_dirsize); |
435 | } else { | 448 | } else { |
436 | unlock_page(page); | 449 | unlock_page(page); |
437 | } | 450 | } |
diff --git a/fs/minix/inode.c b/fs/minix/inode.c index 43668d7d668f..f4f3343b1800 100644 --- a/fs/minix/inode.c +++ b/fs/minix/inode.c | |||
@@ -346,24 +346,39 @@ static int minix_writepage(struct page *page, struct writeback_control *wbc) | |||
346 | { | 346 | { |
347 | return block_write_full_page(page, minix_get_block, wbc); | 347 | return block_write_full_page(page, minix_get_block, wbc); |
348 | } | 348 | } |
349 | |||
349 | static int minix_readpage(struct file *file, struct page *page) | 350 | static int minix_readpage(struct file *file, struct page *page) |
350 | { | 351 | { |
351 | return block_read_full_page(page,minix_get_block); | 352 | return block_read_full_page(page,minix_get_block); |
352 | } | 353 | } |
353 | static int minix_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to) | 354 | |
355 | int __minix_write_begin(struct file *file, struct address_space *mapping, | ||
356 | loff_t pos, unsigned len, unsigned flags, | ||
357 | struct page **pagep, void **fsdata) | ||
354 | { | 358 | { |
355 | return block_prepare_write(page,from,to,minix_get_block); | 359 | return block_write_begin(file, mapping, pos, len, flags, pagep, fsdata, |
360 | minix_get_block); | ||
356 | } | 361 | } |
362 | |||
363 | static int minix_write_begin(struct file *file, struct address_space *mapping, | ||
364 | loff_t pos, unsigned len, unsigned flags, | ||
365 | struct page **pagep, void **fsdata) | ||
366 | { | ||
367 | *pagep = NULL; | ||
368 | return __minix_write_begin(file, mapping, pos, len, flags, pagep, fsdata); | ||
369 | } | ||
370 | |||
357 | static sector_t minix_bmap(struct address_space *mapping, sector_t block) | 371 | static sector_t minix_bmap(struct address_space *mapping, sector_t block) |
358 | { | 372 | { |
359 | return generic_block_bmap(mapping,block,minix_get_block); | 373 | return generic_block_bmap(mapping,block,minix_get_block); |
360 | } | 374 | } |
375 | |||
361 | static const struct address_space_operations minix_aops = { | 376 | static const struct address_space_operations minix_aops = { |
362 | .readpage = minix_readpage, | 377 | .readpage = minix_readpage, |
363 | .writepage = minix_writepage, | 378 | .writepage = minix_writepage, |
364 | .sync_page = block_sync_page, | 379 | .sync_page = block_sync_page, |
365 | .prepare_write = minix_prepare_write, | 380 | .write_begin = minix_write_begin, |
366 | .commit_write = generic_commit_write, | 381 | .write_end = generic_write_end, |
367 | .bmap = minix_bmap | 382 | .bmap = minix_bmap |
368 | }; | 383 | }; |
369 | 384 | ||
diff --git a/fs/minix/minix.h b/fs/minix/minix.h index 73ef84f8fb0b..ac5d3a75cb0d 100644 --- a/fs/minix/minix.h +++ b/fs/minix/minix.h | |||
@@ -54,6 +54,9 @@ extern int minix_new_block(struct inode * inode); | |||
54 | extern void minix_free_block(struct inode *inode, unsigned long block); | 54 | extern void minix_free_block(struct inode *inode, unsigned long block); |
55 | extern unsigned long minix_count_free_blocks(struct minix_sb_info *sbi); | 55 | extern unsigned long minix_count_free_blocks(struct minix_sb_info *sbi); |
56 | extern int minix_getattr(struct vfsmount *, struct dentry *, struct kstat *); | 56 | extern int minix_getattr(struct vfsmount *, struct dentry *, struct kstat *); |
57 | extern int __minix_write_begin(struct file *file, struct address_space *mapping, | ||
58 | loff_t pos, unsigned len, unsigned flags, | ||
59 | struct page **pagep, void **fsdata); | ||
57 | 60 | ||
58 | extern void V1_minix_truncate(struct inode *); | 61 | extern void V1_minix_truncate(struct inode *); |
59 | extern void V2_minix_truncate(struct inode *); | 62 | extern void V2_minix_truncate(struct inode *); |