diff options
Diffstat (limited to 'fs/jfs/jfs_metapage.c')
-rw-r--r-- | fs/jfs/jfs_metapage.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c index f5cd8d38af7a..d1e64f2f2fcd 100644 --- a/fs/jfs/jfs_metapage.c +++ b/fs/jfs/jfs_metapage.c | |||
@@ -39,11 +39,11 @@ static struct { | |||
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | #define metapage_locked(mp) test_bit(META_locked, &(mp)->flag) | 41 | #define metapage_locked(mp) test_bit(META_locked, &(mp)->flag) |
42 | #define trylock_metapage(mp) test_and_set_bit(META_locked, &(mp)->flag) | 42 | #define trylock_metapage(mp) test_and_set_bit_lock(META_locked, &(mp)->flag) |
43 | 43 | ||
44 | static inline void unlock_metapage(struct metapage *mp) | 44 | static inline void unlock_metapage(struct metapage *mp) |
45 | { | 45 | { |
46 | clear_bit(META_locked, &mp->flag); | 46 | clear_bit_unlock(META_locked, &mp->flag); |
47 | wake_up(&mp->wait); | 47 | wake_up(&mp->wait); |
48 | } | 48 | } |
49 | 49 | ||
@@ -88,7 +88,7 @@ struct meta_anchor { | |||
88 | }; | 88 | }; |
89 | #define mp_anchor(page) ((struct meta_anchor *)page_private(page)) | 89 | #define mp_anchor(page) ((struct meta_anchor *)page_private(page)) |
90 | 90 | ||
91 | static inline struct metapage *page_to_mp(struct page *page, uint offset) | 91 | static inline struct metapage *page_to_mp(struct page *page, int offset) |
92 | { | 92 | { |
93 | if (!PagePrivate(page)) | 93 | if (!PagePrivate(page)) |
94 | return NULL; | 94 | return NULL; |
@@ -153,7 +153,7 @@ static inline void dec_io(struct page *page, void (*handler) (struct page *)) | |||
153 | } | 153 | } |
154 | 154 | ||
155 | #else | 155 | #else |
156 | static inline struct metapage *page_to_mp(struct page *page, uint offset) | 156 | static inline struct metapage *page_to_mp(struct page *page, int offset) |
157 | { | 157 | { |
158 | return PagePrivate(page) ? (struct metapage *)page_private(page) : NULL; | 158 | return PagePrivate(page) ? (struct metapage *)page_private(page) : NULL; |
159 | } | 159 | } |
@@ -249,7 +249,7 @@ static inline void drop_metapage(struct page *page, struct metapage *mp) | |||
249 | */ | 249 | */ |
250 | 250 | ||
251 | static sector_t metapage_get_blocks(struct inode *inode, sector_t lblock, | 251 | static sector_t metapage_get_blocks(struct inode *inode, sector_t lblock, |
252 | unsigned int *len) | 252 | int *len) |
253 | { | 253 | { |
254 | int rc = 0; | 254 | int rc = 0; |
255 | int xflag; | 255 | int xflag; |
@@ -352,25 +352,27 @@ static void metapage_write_end_io(struct bio *bio, int err) | |||
352 | static int metapage_writepage(struct page *page, struct writeback_control *wbc) | 352 | static int metapage_writepage(struct page *page, struct writeback_control *wbc) |
353 | { | 353 | { |
354 | struct bio *bio = NULL; | 354 | struct bio *bio = NULL; |
355 | unsigned int block_offset; /* block offset of mp within page */ | 355 | int block_offset; /* block offset of mp within page */ |
356 | struct inode *inode = page->mapping->host; | 356 | struct inode *inode = page->mapping->host; |
357 | unsigned int blocks_per_mp = JFS_SBI(inode->i_sb)->nbperpage; | 357 | int blocks_per_mp = JFS_SBI(inode->i_sb)->nbperpage; |
358 | unsigned int len; | 358 | int len; |
359 | unsigned int xlen; | 359 | int xlen; |
360 | struct metapage *mp; | 360 | struct metapage *mp; |
361 | int redirty = 0; | 361 | int redirty = 0; |
362 | sector_t lblock; | 362 | sector_t lblock; |
363 | int nr_underway = 0; | ||
363 | sector_t pblock; | 364 | sector_t pblock; |
364 | sector_t next_block = 0; | 365 | sector_t next_block = 0; |
365 | sector_t page_start; | 366 | sector_t page_start; |
366 | unsigned long bio_bytes = 0; | 367 | unsigned long bio_bytes = 0; |
367 | unsigned long bio_offset = 0; | 368 | unsigned long bio_offset = 0; |
368 | unsigned int offset; | 369 | int offset; |
369 | 370 | ||
370 | page_start = (sector_t)page->index << | 371 | page_start = (sector_t)page->index << |
371 | (PAGE_CACHE_SHIFT - inode->i_blkbits); | 372 | (PAGE_CACHE_SHIFT - inode->i_blkbits); |
372 | BUG_ON(!PageLocked(page)); | 373 | BUG_ON(!PageLocked(page)); |
373 | BUG_ON(PageWriteback(page)); | 374 | BUG_ON(PageWriteback(page)); |
375 | set_page_writeback(page); | ||
374 | 376 | ||
375 | for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) { | 377 | for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) { |
376 | mp = page_to_mp(page, offset); | 378 | mp = page_to_mp(page, offset); |
@@ -413,11 +415,10 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc) | |||
413 | if (!bio->bi_size) | 415 | if (!bio->bi_size) |
414 | goto dump_bio; | 416 | goto dump_bio; |
415 | submit_bio(WRITE, bio); | 417 | submit_bio(WRITE, bio); |
418 | nr_underway++; | ||
416 | bio = NULL; | 419 | bio = NULL; |
417 | } else { | 420 | } else |
418 | set_page_writeback(page); | ||
419 | inc_io(page); | 421 | inc_io(page); |
420 | } | ||
421 | xlen = (PAGE_CACHE_SIZE - offset) >> inode->i_blkbits; | 422 | xlen = (PAGE_CACHE_SIZE - offset) >> inode->i_blkbits; |
422 | pblock = metapage_get_blocks(inode, lblock, &xlen); | 423 | pblock = metapage_get_blocks(inode, lblock, &xlen); |
423 | if (!pblock) { | 424 | if (!pblock) { |
@@ -427,7 +428,7 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc) | |||
427 | continue; | 428 | continue; |
428 | } | 429 | } |
429 | set_bit(META_io, &mp->flag); | 430 | set_bit(META_io, &mp->flag); |
430 | len = min(xlen, (uint) JFS_SBI(inode->i_sb)->nbperpage); | 431 | len = min(xlen, (int)JFS_SBI(inode->i_sb)->nbperpage); |
431 | 432 | ||
432 | bio = bio_alloc(GFP_NOFS, 1); | 433 | bio = bio_alloc(GFP_NOFS, 1); |
433 | bio->bi_bdev = inode->i_sb->s_bdev; | 434 | bio->bi_bdev = inode->i_sb->s_bdev; |
@@ -449,12 +450,16 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc) | |||
449 | goto dump_bio; | 450 | goto dump_bio; |
450 | 451 | ||
451 | submit_bio(WRITE, bio); | 452 | submit_bio(WRITE, bio); |
453 | nr_underway++; | ||
452 | } | 454 | } |
453 | if (redirty) | 455 | if (redirty) |
454 | redirty_page_for_writepage(wbc, page); | 456 | redirty_page_for_writepage(wbc, page); |
455 | 457 | ||
456 | unlock_page(page); | 458 | unlock_page(page); |
457 | 459 | ||
460 | if (nr_underway == 0) | ||
461 | end_page_writeback(page); | ||
462 | |||
458 | return 0; | 463 | return 0; |
459 | add_failed: | 464 | add_failed: |
460 | /* We should never reach here, since we're only adding one vec */ | 465 | /* We should never reach here, since we're only adding one vec */ |
@@ -475,13 +480,13 @@ static int metapage_readpage(struct file *fp, struct page *page) | |||
475 | { | 480 | { |
476 | struct inode *inode = page->mapping->host; | 481 | struct inode *inode = page->mapping->host; |
477 | struct bio *bio = NULL; | 482 | struct bio *bio = NULL; |
478 | unsigned int block_offset; | 483 | int block_offset; |
479 | unsigned int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits; | 484 | int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits; |
480 | sector_t page_start; /* address of page in fs blocks */ | 485 | sector_t page_start; /* address of page in fs blocks */ |
481 | sector_t pblock; | 486 | sector_t pblock; |
482 | unsigned int xlen; | 487 | int xlen; |
483 | unsigned int len; | 488 | unsigned int len; |
484 | unsigned int offset; | 489 | int offset; |
485 | 490 | ||
486 | BUG_ON(!PageLocked(page)); | 491 | BUG_ON(!PageLocked(page)); |
487 | page_start = (sector_t)page->index << | 492 | page_start = (sector_t)page->index << |
@@ -530,7 +535,7 @@ static int metapage_releasepage(struct page *page, gfp_t gfp_mask) | |||
530 | { | 535 | { |
531 | struct metapage *mp; | 536 | struct metapage *mp; |
532 | int ret = 1; | 537 | int ret = 1; |
533 | unsigned int offset; | 538 | int offset; |
534 | 539 | ||
535 | for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) { | 540 | for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) { |
536 | mp = page_to_mp(page, offset); | 541 | mp = page_to_mp(page, offset); |