Lines Matching defs: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 /* choose a good rdev and read the page from there */
145 struct page *page, unsigned long index, int size)
160 if (sync_page_io(rdev, sector, iosize, page, REQ_OP_READ, true))
225 unsigned long pg_index, struct page *page)
237 /* we compare length (page numbers), not page offset. */
276 md_super_write(mddev, rdev, sboff + ps, (int) size, page);
281 struct page *page, bool wait)
289 if (__write_sb_page(rdev, bitmap, pg_index, page) < 0) {
300 static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)
302 struct buffer_head *bh = page_buffers(page);
327 static void free_buffers(struct page *page)
331 if (!PagePrivate(page))
334 bh = page_buffers(page);
340 detach_page_private(page);
341 put_page(page);
344 /* read a page from a file.
345 * We both read the page, and attach buffers to the page to record the
352 struct bitmap *bitmap, unsigned long count, struct page *page)
363 bh = alloc_page_buffers(page, blocksize, false);
368 attach_page_private(page, bh);
414 static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)
418 struct bitmap *bitmap, unsigned long count, struct page *page)
422 static void free_buffers(struct page *page)
424 put_page(page);
433 * write out a page to a file
439 struct page *page = store->filemap[pg_index];
447 write_file_page(bitmap, page, wait);
449 write_sb_page(bitmap, pg_index, page, wait);
623 struct page *sb_page;
634 /* page 0 is the superblock, read it... */
778 * file a page at a time. There's a superblock at the start of the file.
780 /* calculate the index of the page that contains this bit */
789 /* calculate the (bit) offset of this bit within a page */
799 * return a pointer to the page in the filemap that contains the given bit
802 static inline struct page *filemap_get_page(struct bitmap_storage *store,
825 store->filemap = kmalloc_array(num_pages, sizeof(struct page *),
852 /* We need 4 bits per page, rounded up to a multiple
868 struct page *sb_page = store->sb_page;
869 struct page **map = store->filemap;
943 * we set the bit immediately, then we record the page number so that
949 struct page *page;
960 page = filemap_get_page(&bitmap->storage, chunk);
961 if (!page)
966 kaddr = kmap_atomic(page);
972 pr_debug("set file bit %lu page %lu\n", bit, index);
973 /* record page number so it gets flushed to disk when unplug occurs */
980 struct page *page;
991 page = filemap_get_page(&bitmap->storage, chunk);
992 if (!page)
995 paddr = kmap_atomic(page);
1010 struct page *page;
1015 page = filemap_get_page(&bitmap->storage, chunk);
1016 if (!page)
1019 paddr = kmap_atomic(page);
1040 /* look at each page to see if there are any set bits that need to be
1148 struct page *page = store->filemap[i];
1151 /* unmap the old page, we're done with it */
1158 ret = read_file_page(file, i, bitmap, count, page);
1160 ret = read_sb_page(mddev, 0, page, i + node_offset,
1171 struct page *page = store->filemap[i];
1179 * If the bitmap is out of date, dirty the whole page
1182 paddr = kmap_atomic(page);
1195 struct page *page = filemap_get_page(&bitmap->storage, i);
1200 paddr = kmap_atomic(page);
1253 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
1254 bitmap->bp[page].count += inc;
1255 md_bitmap_checkfree(bitmap, page);
1261 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
1262 struct bitmap_page *bp = &bitmap->bp[page];
1326 /* Any file-page which is PENDING now needs to be written.
1389 /* Now start writeout on any page in NEEDWRITE that isn't DIRTY.
1392 * If we find any DIRTY page we stop there and let bitmap_unplug
1428 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
1433 if (page >= bitmap->pages) {
1436 * End-of-device while looking for a whole page or
1441 err = md_bitmap_checkpage(bitmap, page, create, 0);
1443 if (bitmap->bp[page].hijacked ||
1444 bitmap->bp[page].map == NULL)
1456 if (bitmap->bp[page].hijacked) { /* hijacked pointer */
1461 &bitmap->bp[page].map)[hi];
1462 } else /* page is allocated */
1464 &(bitmap->bp[page].map[pageoff]);
1835 if (bp) /* deallocate the page memory */
1927 * and bypass the page cache, we must sync the file
2235 unsigned long page;
2236 for (page = 0; page < pages; page++) {
2237 ret = md_bitmap_checkpage(&bitmap->counts, page, 1, 1);
2241 /* deallocate the page memory */
2242 for (k = 0; k < page; k++) {
2259 bitmap->counts.bp[page].count += 1;
2336 location_show(struct mddev *mddev, char *page)
2340 len = sprintf(page, "file");
2342 len = sprintf(page, "%+lld", (long long)mddev->bitmap_info.offset);
2344 len = sprintf(page, "none");
2345 len += sprintf(page+len, "\n");
2457 space_show(struct mddev *mddev, char *page)
2459 return sprintf(page, "%lu\n", mddev->bitmap_info.space);
2490 timeout_show(struct mddev *mddev, char *page)
2496 len = sprintf(page, "%lu", secs);
2498 len += sprintf(page+len, ".%03u", jiffies_to_msecs(jifs));
2499 len += sprintf(page+len, "\n");
2534 backlog_show(struct mddev *mddev, char *page)
2536 return sprintf(page, "%lu\n", mddev->bitmap_info.max_write_behind);
2594 chunksize_show(struct mddev *mddev, char *page)
2596 return sprintf(page, "%lu\n", mddev->bitmap_info.chunksize);
2623 static ssize_t metadata_show(struct mddev *mddev, char *page)
2626 return sprintf(page, "clustered\n");
2627 return sprintf(page, "%s\n", (mddev->bitmap_info.external
2650 static ssize_t can_clear_show(struct mddev *mddev, char *page)
2655 len = sprintf(page, "%s\n", (mddev->bitmap->need_sync ?
2658 len = sprintf(page, "\n");
2682 behind_writes_used_show(struct mddev *mddev, char *page)
2687 ret = sprintf(page, "0\n");
2689 ret = sprintf(page, "%lu\n",