Lines Matching refs:page

41  * check a page and, if necessary, allocate it (or hijack it if the alloc fails)
43 * 1) check to see if this page is allocated, if it's not then try to alloc
44 * 2) if the alloc fails, set the page's hijacked flag so we'll use the
45 * page pointer directly as a counter
47 * if we find our page, we increment the page's refcount so that it stays
51 unsigned long page, int create, int no_hijack)
57 WARN_ON_ONCE(page >= bitmap->pages);
58 if (bitmap->bp[page].hijacked) /* it's hijacked, don't try to alloc */
61 if (bitmap->bp[page].map) /* page is already allocated, just return */
67 /* this page has not been allocated yet */
76 * When this function completes, either bp[page].map or
77 * bp[page].hijacked. In either case, this function will
87 pr_debug("md/bitmap: map page allocation failed, hijacking\n");
93 if (!bitmap->bp[page].map)
94 bitmap->bp[page].hijacked = 1;
95 } else if (bitmap->bp[page].map ||
96 bitmap->bp[page].hijacked) {
97 /* somebody beat us to getting the page */
101 /* no page was in place and we have one, so install it */
103 bitmap->bp[page].map = mappage;
109 /* if page is completely empty, put it back on the free list, or dealloc it */
110 /* if page was hijacked, unmark the flag so it might get alloced next time */
112 static void md_bitmap_checkfree(struct bitmap_counts *bitmap, unsigned long page)
116 if (bitmap->bp[page].count) /* page is still busy */
119 /* page is no longer in use, it can be released */
121 if (bitmap->bp[page].hijacked) { /* page was hijacked, undo this now */
122 bitmap->bp[page].hijacked = 0;
123 bitmap->bp[page].map = NULL;
125 /* normal case, free the page */
126 ptr = bitmap->bp[page].map;
127 bitmap->bp[page].map = NULL;
138 * basic page I/O operations
143 struct page *page,
146 /* choose a good rdev and read the page from there */
161 page, REQ_OP_READ, 0, true)) {
162 page->index = index;
205 static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
220 if (page->index == store->file_pages-1) {
232 if (rdev->sb_start + offset + (page->index
243 + (long)(page->index * (PAGE_SIZE/512))
255 + page->index*(PAGE_SIZE/512) + size/512
264 + page->index * (PAGE_SIZE/512),
266 page);
279 * write out a page to a file
281 static void write_page(struct bitmap *bitmap, struct page *page, int wait)
286 switch (write_sb_page(bitmap, page, wait)) {
292 bh = page_buffers(page);
320 static void free_buffers(struct page *page)
324 if (!PagePrivate(page))
327 bh = page_buffers(page);
333 detach_page_private(page);
334 put_page(page);
337 /* read a page from a file.
338 * We both read the page, and attach buffers to the page to record the
347 struct page *page)
358 bh = alloc_page_buffers(page, blocksize, false);
363 attach_page_private(page, bh);
395 page->index = index;
580 struct page *sb_page;
591 /* page 0 is the superblock, read it... */
738 * file a page at a time. There's a superblock at the start of the file.
740 /* calculate the index of the page that contains this bit */
749 /* calculate the (bit) offset of this bit within a page */
759 * return a pointer to the page in the filemap that contains the given bit
762 static inline struct page *filemap_get_page(struct bitmap_storage *store,
785 store->filemap = kmalloc_array(num_pages, sizeof(struct page *),
813 /* We need 4 bits per page, rounded up to a multiple
828 struct page **map, *sb_page;
916 * we set the bit immediately, then we record the page number so that
922 struct page *page;
931 page = filemap_get_page(&bitmap->storage, chunk);
932 if (!page)
937 kaddr = kmap_atomic(page);
943 pr_debug("set file bit %lu page %lu\n", bit, page->index);
944 /* record page number so it gets flushed to disk when unplug occurs */
945 set_page_attr(bitmap, page->index - node_offset, BITMAP_PAGE_DIRTY);
951 struct page *page;
960 page = filemap_get_page(&bitmap->storage, chunk);
961 if (!page)
964 paddr = kmap_atomic(page);
970 if (!test_page_attr(bitmap, page->index - node_offset, BITMAP_PAGE_NEEDWRITE)) {
971 set_page_attr(bitmap, page->index - node_offset, BITMAP_PAGE_PENDING);
979 struct page *page;
984 page = filemap_get_page(&bitmap->storage, chunk);
985 if (!page)
988 paddr = kmap_atomic(page);
1011 /* look at each page to see if there are any set bits that need to be
1052 struct page *page = NULL;
1103 if (index != oldindex) { /* this is a new page, read it in */
1105 /* unmap the old page, we're done with it */
1110 page = store->filemap[index];
1113 count, page);
1118 page,
1129 * whole page and write it out
1131 paddr = kmap_atomic(page);
1135 write_page(bitmap, page, 1);
1143 paddr = kmap_atomic(page);
1196 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
1197 bitmap->bp[page].count += inc;
1198 md_bitmap_checkfree(bitmap, page);
1204 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
1205 struct bitmap_page *bp = &bitmap->bp[page];
1252 /* Any file-page which is PENDING now needs to be written.
1315 /* Now start writeout on any page in NEEDWRITE that isn't DIRTY.
1318 * If we find any DIRTY page we stop there and let bitmap_unplug
1356 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
1361 if (page >= bitmap->pages) {
1364 * End-of-device while looking for a whole page or
1369 err = md_bitmap_checkpage(bitmap, page, create, 0);
1371 if (bitmap->bp[page].hijacked ||
1372 bitmap->bp[page].map == NULL)
1384 if (bitmap->bp[page].hijacked) { /* hijacked pointer */
1389 &bitmap->bp[page].map)[hi];
1390 } else /* page is allocated */
1392 &(bitmap->bp[page].map[pageoff]);
1763 if (bp) /* deallocate the page memory */
1856 * and bypass the page cache, we must sync the file
2164 unsigned long page;
2165 for (page = 0; page < pages; page++) {
2166 ret = md_bitmap_checkpage(&bitmap->counts, page, 1, 1);
2170 /* deallocate the page memory */
2171 for (k = 0; k < page; k++) {
2188 bitmap->counts.bp[page].count += 1;
2265 location_show(struct mddev *mddev, char *page)
2269 len = sprintf(page, "file");
2271 len = sprintf(page, "%+lld", (long long)mddev->bitmap_info.offset);
2273 len = sprintf(page, "none");
2274 len += sprintf(page+len, "\n");
2386 space_show(struct mddev *mddev, char *page)
2388 return sprintf(page, "%lu\n", mddev->bitmap_info.space);
2419 timeout_show(struct mddev *mddev, char *page)
2425 len = sprintf(page, "%lu", secs);
2427 len += sprintf(page+len, ".%03u", jiffies_to_msecs(jifs));
2428 len += sprintf(page+len, "\n");
2469 backlog_show(struct mddev *mddev, char *page)
2471 return sprintf(page, "%lu\n", mddev->bitmap_info.max_write_behind);
2529 chunksize_show(struct mddev *mddev, char *page)
2531 return sprintf(page, "%lu\n", mddev->bitmap_info.chunksize);
2558 static ssize_t metadata_show(struct mddev *mddev, char *page)
2561 return sprintf(page, "clustered\n");
2562 return sprintf(page, "%s\n", (mddev->bitmap_info.external
2585 static ssize_t can_clear_show(struct mddev *mddev, char *page)
2590 len = sprintf(page, "%s\n", (mddev->bitmap->need_sync ?
2593 len = sprintf(page, "\n");
2617 behind_writes_used_show(struct mddev *mddev, char *page)
2622 ret = sprintf(page, "0\n");
2624 ret = sprintf(page, "%lu\n",