Lines Matching refs:page

39  * check a page and, if necessary, allocate it (or hijack it if the alloc fails)
41 * 1) check to see if this page is allocated, if it's not then try to alloc
42 * 2) if the alloc fails, set the page's hijacked flag so we'll use the
43 * page pointer directly as a counter
45 * if we find our page, we increment the page's refcount so that it stays
49 unsigned long page, int create)
55 if (page >= bitmap->pages) {
57 * End-of-device while looking for a whole page.
63 if (bitmap->bp[page].hijacked) /* it's hijacked, don't try to alloc */
66 if (bitmap->bp[page].map) /* page is already allocated, just return */
72 /* this page has not been allocated yet */
79 pr_debug("md/bitmap: map page allocation failed, hijacking\n");
82 if (!bitmap->bp[page].map)
83 bitmap->bp[page].hijacked = 1;
84 } else if (bitmap->bp[page].map ||
85 bitmap->bp[page].hijacked) {
86 /* somebody beat us to getting the page */
91 /* no page was in place and we have one, so install it */
93 bitmap->bp[page].map = mappage;
99 /* if page is completely empty, put it back on the free list, or dealloc it */
100 /* if page was hijacked, unmark the flag so it might get alloced next time */
102 static void bitmap_checkfree(struct bitmap_counts *bitmap, unsigned long page)
106 if (bitmap->bp[page].count) /* page is still busy */
109 /* page is no longer in use, it can be released */
111 if (bitmap->bp[page].hijacked) { /* page was hijacked, undo this now */
112 bitmap->bp[page].hijacked = 0;
113 bitmap->bp[page].map = NULL;
115 /* normal case, free the page */
116 ptr = bitmap->bp[page].map;
117 bitmap->bp[page].map = NULL;
128 * basic page I/O operations
133 struct page *page,
136 /* choose a good rdev and read the page from there */
150 page, READ, true)) {
151 page->index = index;
189 static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
202 if (page->index == store->file_pages-1) {
214 if (rdev->sb_start + offset + (page->index
225 + (long)(page->index * (PAGE_SIZE/512))
237 + page->index*(PAGE_SIZE/512) + size/512
246 + page->index * (PAGE_SIZE/512),
248 page);
261 * write out a page to a file
263 static void write_page(struct bitmap *bitmap, struct page *page, int wait)
268 switch (write_sb_page(bitmap, page, wait)) {
274 bh = page_buffers(page);
304 __clear_page_buffers(struct page *page)
306 ClearPagePrivate(page);
307 set_page_private(page, 0);
308 page_cache_release(page);
310 static void free_buffers(struct page *page)
314 if (!PagePrivate(page))
317 bh = page_buffers(page);
323 __clear_page_buffers(page);
324 put_page(page);
327 /* read a page from a file.
328 * We both read the page, and attach buffers to the page to record the
337 struct page *page)
347 bh = alloc_page_buffers(page, 1<<inode->i_blkbits, 0);
352 attach_page_buffers(page, bh);
380 page->index = index;
536 struct page *sb_page;
546 /* page 0 is the superblock, read it... */
649 * file a page at a time. There's a superblock at the start of the file.
651 /* calculate the index of the page that contains this bit */
660 /* calculate the (bit) offset of this bit within a page */
670 * return a pointer to the page in the filemap that contains the given bit
673 static inline struct page *filemap_get_page(struct bitmap_storage *store,
694 store->filemap = kmalloc(sizeof(struct page *)
720 /* We need 4 bits per page, rounded up to a multiple
735 struct page **map, *sb_page;
825 * we set the bit immediately, then we record the page number so that
831 struct page *page;
835 page = filemap_get_page(&bitmap->storage, chunk);
836 if (!page)
841 kaddr = kmap_atomic(page);
847 pr_debug("set file bit %lu page %lu\n", bit, page->index);
848 /* record page number so it gets flushed to disk when unplug occurs */
849 set_page_attr(bitmap, page->index, BITMAP_PAGE_DIRTY);
855 struct page *page;
859 page = filemap_get_page(&bitmap->storage, chunk);
860 if (!page)
863 paddr = kmap_atomic(page);
869 if (!test_page_attr(bitmap, page->index, BITMAP_PAGE_NEEDWRITE)) {
870 set_page_attr(bitmap, page->index, BITMAP_PAGE_PENDING);
887 /* look at each page to see if there are any set bits that need to be
926 struct page *page = NULL;
975 if (index != oldindex) { /* this is a new page, read it in */
977 /* unmap the old page, we're done with it */
982 page = store->filemap[index];
985 count, page);
990 page,
1001 * whole page and write it out
1003 paddr = kmap_atomic(page);
1007 write_page(bitmap, page, 1);
1015 paddr = kmap_atomic(page);
1069 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
1070 bitmap->bp[page].count += inc;
1071 bitmap_checkfree(bitmap, page);
1077 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
1078 struct bitmap_page *bp = &bitmap->bp[page];
1121 /* Any file-page which is PENDING now needs to be written.
1185 /* Now start writeout on any page in NEEDWRITE that isn't DIRTY.
1188 * If we find any DIRTY page we stop there and let bitmap_unplug
1226 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
1231 err = bitmap_checkpage(bitmap, page, create);
1233 if (bitmap->bp[page].hijacked ||
1234 bitmap->bp[page].map == NULL)
1246 if (bitmap->bp[page].hijacked) { /* hijacked pointer */
1251 &bitmap->bp[page].map)[hi];
1252 } else /* page is allocated */
1254 &(bitmap->bp[page].map[pageoff]);
1593 if (bp) /* deallocate the page memory */
1660 * and bypass the page cache, we must sync the file
1945 location_show(struct mddev *mddev, char *page)
1949 len = sprintf(page, "file");
1951 len = sprintf(page, "%+lld", (long long)mddev->bitmap_info.offset);
1953 len = sprintf(page, "none");
1954 len += sprintf(page+len, "\n");
2041 space_show(struct mddev *mddev, char *page)
2043 return sprintf(page, "%lu\n", mddev->bitmap_info.space);
2074 timeout_show(struct mddev *mddev, char *page)
2080 len = sprintf(page, "%lu", secs);
2082 len += sprintf(page+len, ".%03u", jiffies_to_msecs(jifs));
2083 len += sprintf(page+len, "\n");
2124 backlog_show(struct mddev *mddev, char *page)
2126 return sprintf(page, "%lu\n", mddev->bitmap_info.max_write_behind);
2146 chunksize_show(struct mddev *mddev, char *page)
2148 return sprintf(page, "%lu\n", mddev->bitmap_info.chunksize);
2172 static ssize_t metadata_show(struct mddev *mddev, char *page)
2174 return sprintf(page, "%s\n", (mddev->bitmap_info.external
2196 static ssize_t can_clear_show(struct mddev *mddev, char *page)
2200 len = sprintf(page, "%s\n", (mddev->bitmap->need_sync ?
2203 len = sprintf(page, "\n");
2226 behind_writes_used_show(struct mddev *mddev, char *page)
2229 return sprintf(page, "0\n");
2230 return sprintf(page, "%lu\n",