PCI Hotplug: PCIeHP: Fix some whitespace damage
[safe/jmp/linux-2.6] / fs / jfs / jfs_metapage.c
index ceaf03b..d1e64f2 100644 (file)
@@ -39,11 +39,11 @@ static struct {
 #endif
 
 #define metapage_locked(mp) test_bit(META_locked, &(mp)->flag)
-#define trylock_metapage(mp) test_and_set_bit(META_locked, &(mp)->flag)
+#define trylock_metapage(mp) test_and_set_bit_lock(META_locked, &(mp)->flag)
 
 static inline void unlock_metapage(struct metapage *mp)
 {
-       clear_bit(META_locked, &mp->flag);
+       clear_bit_unlock(META_locked, &mp->flag);
        wake_up(&mp->wait);
 }
 
@@ -56,7 +56,7 @@ static inline void __lock_metapage(struct metapage *mp)
                set_current_state(TASK_UNINTERRUPTIBLE);
                if (metapage_locked(mp)) {
                        unlock_page(mp->page);
-                       schedule();
+                       io_schedule();
                        lock_page(mp->page);
                }
        } while (trylock_metapage(mp));
@@ -88,7 +88,7 @@ struct meta_anchor {
 };
 #define mp_anchor(page) ((struct meta_anchor *)page_private(page))
 
-static inline struct metapage *page_to_mp(struct page *page, uint offset)
+static inline struct metapage *page_to_mp(struct page *page, int offset)
 {
        if (!PagePrivate(page))
                return NULL;
@@ -153,7 +153,7 @@ static inline void dec_io(struct page *page, void (*handler) (struct page *))
 }
 
 #else
-static inline struct metapage *page_to_mp(struct page *page, uint offset)
+static inline struct metapage *page_to_mp(struct page *page, int offset)
 {
        return PagePrivate(page) ? (struct metapage *)page_private(page) : NULL;
 }
@@ -180,21 +180,18 @@ static inline void remove_metapage(struct page *page, struct metapage *mp)
 
 #endif
 
-static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
+static void init_once(struct kmem_cache *cachep, void *foo)
 {
        struct metapage *mp = (struct metapage *)foo;
 
-       if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
-           SLAB_CTOR_CONSTRUCTOR) {
-               mp->lid = 0;
-               mp->lsn = 0;
-               mp->flag = 0;
-               mp->data = NULL;
-               mp->clsn = 0;
-               mp->log = NULL;
-               set_bit(META_free, &mp->flag);
-               init_waitqueue_head(&mp->wait);
-       }
+       mp->lid = 0;
+       mp->lsn = 0;
+       mp->flag = 0;
+       mp->data = NULL;
+       mp->clsn = 0;
+       mp->log = NULL;
+       set_bit(META_free, &mp->flag);
+       init_waitqueue_head(&mp->wait);
 }
 
 static inline struct metapage *alloc_metapage(gfp_t gfp_mask)
@@ -216,7 +213,7 @@ int __init metapage_init(void)
         * Allocate the metapage structures
         */
        metapage_cache = kmem_cache_create("jfs_mp", sizeof(struct metapage),
-                                          0, 0, init_once, NULL);
+                                          0, 0, init_once);
        if (metapage_cache == NULL)
                return -ENOMEM;
 
@@ -252,7 +249,7 @@ static inline void drop_metapage(struct page *page, struct metapage *mp)
  */
 
 static sector_t metapage_get_blocks(struct inode *inode, sector_t lblock,
-                                   unsigned int *len)
+                                   int *len)
 {
        int rc = 0;
        int xflag;
@@ -283,14 +280,10 @@ static void last_read_complete(struct page *page)
        unlock_page(page);
 }
 
-static int metapage_read_end_io(struct bio *bio, unsigned int bytes_done,
-                               int err)
+static void metapage_read_end_io(struct bio *bio, int err)
 {
        struct page *page = bio->bi_private;
 
-       if (bio->bi_size)
-               return 1;
-
        if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) {
                printk(KERN_ERR "metapage_read_end_io: I/O error\n");
                SetPageError(page);
@@ -298,8 +291,6 @@ static int metapage_read_end_io(struct bio *bio, unsigned int bytes_done,
 
        dec_io(page, last_read_complete);
        bio_put(bio);
-
-       return 0;
 }
 
 static void remove_from_logsync(struct metapage *mp)
@@ -344,47 +335,44 @@ static void last_write_complete(struct page *page)
        end_page_writeback(page);
 }
 
-static int metapage_write_end_io(struct bio *bio, unsigned int bytes_done,
-                                int err)
+static void metapage_write_end_io(struct bio *bio, int err)
 {
        struct page *page = bio->bi_private;
 
        BUG_ON(!PagePrivate(page));
 
-       if (bio->bi_size)
-               return 1;
-
        if (! test_bit(BIO_UPTODATE, &bio->bi_flags)) {
                printk(KERN_ERR "metapage_write_end_io: I/O error\n");
                SetPageError(page);
        }
        dec_io(page, last_write_complete);
        bio_put(bio);
-       return 0;
 }
 
 static int metapage_writepage(struct page *page, struct writeback_control *wbc)
 {
        struct bio *bio = NULL;
-       unsigned int block_offset;      /* block offset of mp within page */
+       int block_offset;       /* block offset of mp within page */
        struct inode *inode = page->mapping->host;
-       unsigned int blocks_per_mp = JFS_SBI(inode->i_sb)->nbperpage;
-       unsigned int len;
-       unsigned int xlen;
+       int blocks_per_mp = JFS_SBI(inode->i_sb)->nbperpage;
+       int len;
+       int xlen;
        struct metapage *mp;
        int redirty = 0;
        sector_t lblock;
+       int nr_underway = 0;
        sector_t pblock;
        sector_t next_block = 0;
        sector_t page_start;
        unsigned long bio_bytes = 0;
        unsigned long bio_offset = 0;
-       unsigned int offset;
+       int offset;
 
        page_start = (sector_t)page->index <<
                     (PAGE_CACHE_SHIFT - inode->i_blkbits);
        BUG_ON(!PageLocked(page));
        BUG_ON(PageWriteback(page));
+       set_page_writeback(page);
 
        for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
                mp = page_to_mp(page, offset);
@@ -427,11 +415,10 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
                        if (!bio->bi_size)
                                goto dump_bio;
                        submit_bio(WRITE, bio);
+                       nr_underway++;
                        bio = NULL;
-               } else {
-                       set_page_writeback(page);
+               } else
                        inc_io(page);
-               }
                xlen = (PAGE_CACHE_SIZE - offset) >> inode->i_blkbits;
                pblock = metapage_get_blocks(inode, lblock, &xlen);
                if (!pblock) {
@@ -441,7 +428,7 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
                        continue;
                }
                set_bit(META_io, &mp->flag);
-               len = min(xlen, (uint) JFS_SBI(inode->i_sb)->nbperpage);
+               len = min(xlen, (int)JFS_SBI(inode->i_sb)->nbperpage);
 
                bio = bio_alloc(GFP_NOFS, 1);
                bio->bi_bdev = inode->i_sb->s_bdev;
@@ -463,19 +450,24 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
                        goto dump_bio;
 
                submit_bio(WRITE, bio);
+               nr_underway++;
        }
        if (redirty)
                redirty_page_for_writepage(wbc, page);
 
        unlock_page(page);
 
+       if (nr_underway == 0)
+               end_page_writeback(page);
+
        return 0;
 add_failed:
        /* We should never reach here, since we're only adding one vec */
        printk(KERN_ERR "JFS: bio_add_page failed unexpectedly\n");
        goto skip;
 dump_bio:
-       dump_mem("bio", bio, sizeof(*bio));
+       print_hex_dump(KERN_ERR, "JFS: dump of bio: ", DUMP_PREFIX_ADDRESS, 16,
+                      4, bio, sizeof(*bio), 0);
 skip:
        bio_put(bio);
        unlock_page(page);
@@ -488,13 +480,13 @@ static int metapage_readpage(struct file *fp, struct page *page)
 {
        struct inode *inode = page->mapping->host;
        struct bio *bio = NULL;
-       unsigned int block_offset;
-       unsigned int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
+       int block_offset;
+       int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
        sector_t page_start;    /* address of page in fs blocks */
        sector_t pblock;
-       unsigned int xlen;
+       int xlen;
        unsigned int len;
-       unsigned int offset;
+       int offset;
 
        BUG_ON(!PageLocked(page));
        page_start = (sector_t)page->index <<
@@ -543,7 +535,7 @@ static int metapage_releasepage(struct page *page, gfp_t gfp_mask)
 {
        struct metapage *mp;
        int ret = 1;
-       unsigned int offset;
+       int offset;
 
        for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
                mp = page_to_mp(page, offset);