num_pages = (bytes + PAGE_SIZE - 1) / PAGE_SIZE; 
 num_pages = (bytes + sizeof(bitmap_super_t) + PAGE_SIZE - 1) / PAGE_SIZE + 1;  
static int bitmap_init_from_disk(struct bitmap *bitmap){	unsigned long i, chunks, index, oldindex, bit;	struct page *page = NULL, *oldpage = NULL;	unsigned long num_pages, bit_cnt = 0;	struct file *file;	unsigned long bytes, offset, dummy;	int outofdate;	int ret = -ENOSPC;	chunks = bitmap->chunks;	file = bitmap->file;	BUG_ON(!file);#if INJECT_FAULTS_3	outofdate = 1;#else	outofdate = bitmap->flags & BITMAP_STALE;#endif	if (outofdate)		printk(KERN_INFO "%s: bitmap file is out of date, doing full "			"recovery\n", bmname(bitmap));	bytes = (chunks + 7) / 8;	num_pages = (bytes + PAGE_SIZE - 1) / PAGE_SIZE;	if (i_size_read(file->f_mapping->host) < bytes + sizeof(bitmap_super_t)) {		printk(KERN_INFO "%s: bitmap file too short %lu < %lu\n",			bmname(bitmap),			(unsigned long) i_size_read(file->f_mapping->host),			bytes + sizeof(bitmap_super_t));		goto out;	}	num_pages++;	bitmap->filemap = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);	if (!bitmap->filemap) {		ret = -ENOMEM;		goto out;	}	bitmap->filemap_attr = kmalloc(sizeof(long) * num_pages, GFP_KERNEL);	if (!bitmap->filemap_attr) {		ret = -ENOMEM;		goto out;	}	memset(bitmap->filemap_attr, 0, sizeof(long) * num_pages);	oldindex = ~0L;	for (i = 0; i < chunks; i++) {		index = file_page_index(i);		bit = file_page_offset(i);		if (index != oldindex) { /* this is a new page, read it in */			/* unmap the old page, we're done with it */			if (oldpage != NULL)				kunmap(oldpage);			if (index == 0) {				/*				 * if we're here then the superblock page				 * contains some bits (PAGE_SIZE != sizeof sb)				 * we've already read it in, so just use it				 */				page = bitmap->sb_page;				offset = sizeof(bitmap_super_t);			} else {				page = read_page(file, index, &dummy);				if (IS_ERR(page)) { /* read error */					ret = PTR_ERR(page);					goto out;				}				offset = 0;			}			oldindex = index;			oldpage = page;			kmap(page);			if (outofdate) {				/*				 * if bitmap is out of date, dirty the			 	 * whole page and write it out				 */				memset(page_address(page) + offset, 0xff,					PAGE_SIZE - offset);				ret = write_page(page, 1);				if (ret) {					kunmap(page);					/* release, page not in filemap yet */					page_cache_release(page);					goto out;				}			}			bitmap->filemap[bitmap->file_pages++] = page;		}		if (test_bit(bit, page_address(page))) {			/* if the disk bit is set, set the memory bit */			bitmap_set_memory_bits(bitmap,					i << CHUNK_BLOCK_SHIFT(bitmap), 1, 1);			bit_cnt++;		}#if 0		else			bitmap_set_memory_bits(bitmap,				       i << CHUNK_BLOCK_SHIFT(bitmap), 1, 0);#endif	} 	/* everything went OK */	ret = 0;	bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET);	if (page) /* unmap the last page */		kunmap(page);	if (bit_cnt) { /* Kick recovery if any bits were set */		set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery);		md_wakeup_thread(bitmap->mddev->thread);	}out:	printk(KERN_INFO "%s: bitmap initialized from disk: "		"read %lu/%lu pages, set %lu bits, status: %d\n",		bmname(bitmap), bitmap->file_pages, num_pages, bit_cnt, ret);	return ret;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/bc7f77de2cd81718dd789a2cfe68a7cf1b48f016/bitmap.c/clean/drivers/md/bitmap.c