~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to fs/nilfs2/page.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
#define NILFS_BUFFER_INHERENT_BITS  \
39
39
        ((1UL << BH_Uptodate) | (1UL << BH_Mapped) | (1UL << BH_NILFS_Node) | \
40
 
         (1UL << BH_NILFS_Volatile) | (1UL << BH_NILFS_Allocated) | \
41
 
         (1UL << BH_NILFS_Checked))
 
40
         (1UL << BH_NILFS_Volatile) | (1UL << BH_NILFS_Checked))
42
41
 
43
42
static struct buffer_head *
44
43
__nilfs_get_page_block(struct page *page, unsigned long block, pgoff_t index,
59
58
        return bh;
60
59
}
61
60
 
62
 
/*
63
 
 * Since the page cache of B-tree node pages or data page cache of pseudo
64
 
 * inodes does not have a valid mapping->host pointer, calling
65
 
 * mark_buffer_dirty() for their buffers causes a NULL pointer dereference;
66
 
 * it calls __mark_inode_dirty(NULL) through __set_page_dirty().
67
 
 * To avoid this problem, the old style mark_buffer_dirty() is used instead.
68
 
 */
69
 
void nilfs_mark_buffer_dirty(struct buffer_head *bh)
70
 
{
71
 
        if (!buffer_dirty(bh) && !test_set_buffer_dirty(bh))
72
 
                __set_page_dirty_nobuffers(bh->b_page);
73
 
}
74
 
 
75
61
struct buffer_head *nilfs_grab_buffer(struct inode *inode,
76
62
                                      struct address_space *mapping,
77
63
                                      unsigned long blkoff,
183
169
void nilfs_page_bug(struct page *page)
184
170
{
185
171
        struct address_space *m;
186
 
        unsigned long ino = 0;
 
172
        unsigned long ino;
187
173
 
188
174
        if (unlikely(!page)) {
189
175
                printk(KERN_CRIT "NILFS_PAGE_BUG(NULL)\n");
191
177
        }
192
178
 
193
179
        m = page->mapping;
194
 
        if (m) {
195
 
                struct inode *inode = NILFS_AS_I(m);
196
 
                if (inode != NULL)
197
 
                        ino = inode->i_ino;
198
 
        }
 
180
        ino = m ? m->host->i_ino : 0;
 
181
 
199
182
        printk(KERN_CRIT "NILFS_PAGE_BUG(%p): cnt=%d index#=%llu flags=0x%lx "
200
183
               "mapping=%p ino=%lu\n",
201
184
               page, atomic_read(&page->_count),
217
200
}
218
201
 
219
202
/**
220
 
 * nilfs_alloc_private_page - allocate a private page with buffer heads
221
 
 *
222
 
 * Return Value: On success, a pointer to the allocated page is returned.
223
 
 * On error, NULL is returned.
224
 
 */
225
 
struct page *nilfs_alloc_private_page(struct block_device *bdev, int size,
226
 
                                      unsigned long state)
227
 
{
228
 
        struct buffer_head *bh, *head, *tail;
229
 
        struct page *page;
230
 
 
231
 
        page = alloc_page(GFP_NOFS); /* page_count of the returned page is 1 */
232
 
        if (unlikely(!page))
233
 
                return NULL;
234
 
 
235
 
        lock_page(page);
236
 
        head = alloc_page_buffers(page, size, 0);
237
 
        if (unlikely(!head)) {
238
 
                unlock_page(page);
239
 
                __free_page(page);
240
 
                return NULL;
241
 
        }
242
 
 
243
 
        bh = head;
244
 
        do {
245
 
                bh->b_state = (1UL << BH_NILFS_Allocated) | state;
246
 
                tail = bh;
247
 
                bh->b_bdev = bdev;
248
 
                bh = bh->b_this_page;
249
 
        } while (bh);
250
 
 
251
 
        tail->b_this_page = head;
252
 
        attach_page_buffers(page, head);
253
 
 
254
 
        return page;
255
 
}
256
 
 
257
 
void nilfs_free_private_page(struct page *page)
258
 
{
259
 
        BUG_ON(!PageLocked(page));
260
 
        BUG_ON(page->mapping);
261
 
 
262
 
        if (page_has_buffers(page) && !try_to_free_buffers(page))
263
 
                NILFS_PAGE_BUG(page, "failed to free page");
264
 
 
265
 
        unlock_page(page);
266
 
        __free_page(page);
267
 
}
268
 
 
269
 
/**
270
203
 * nilfs_copy_page -- copy the page with buffers
271
204
 * @dst: destination page
272
205
 * @src: source page
492
425
        return nc;
493
426
}
494
427
 
495
 
void nilfs_mapping_init(struct address_space *mapping,
 
428
void nilfs_mapping_init(struct address_space *mapping, struct inode *inode,
496
429
                        struct backing_dev_info *bdi)
497
430
{
498
 
        mapping->host = NULL;
 
431
        mapping->host = inode;
499
432
        mapping->flags = 0;
500
433
        mapping_set_gfp_mask(mapping, GFP_NOFS);
501
434
        mapping->assoc_mapping = NULL;