/* skip this page unless it's marked as needing cleaning */ if (!((attr=get_page_attr(bitmap, page)) & BITMAP_PAGE_CLEAN)) { if (attr & BITMAP_PAGE_NEEDWRITE) { page_cache_get(page); clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE); } spin_unlock_irqrestore(&bitmap->lock, flags); if (attr & BITMAP_PAGE_NEEDWRITE) { if (write_page(bitmap, page, 0)) bitmap_file_kick(bitmap); page_cache_release(page); } continue; }  bit = file_page_offset(j); 
int bitmap_daemon_work(struct bitmap *bitmap){	unsigned long bit, j;	unsigned long flags;	struct page *page = NULL, *lastpage = NULL;	int err = 0;	int blocks;	int attr;	if (bitmap == NULL)		return 0;	if (time_before(jiffies, bitmap->daemon_lastrun + bitmap->daemon_sleep*HZ))		return 0;	bitmap->daemon_lastrun = jiffies;	for (j = 0; j < bitmap->chunks; j++) {		bitmap_counter_t *bmc;		spin_lock_irqsave(&bitmap->lock, flags);		if (!bitmap->file || !bitmap->filemap) {			/* error or shutdown */			spin_unlock_irqrestore(&bitmap->lock, flags);			break;		}		page = filemap_get_page(bitmap, j);		/* skip this page unless it's marked as needing cleaning */		if (!((attr=get_page_attr(bitmap, page)) & BITMAP_PAGE_CLEAN)) {			if (attr & BITMAP_PAGE_NEEDWRITE) {				page_cache_get(page);				clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);			}			spin_unlock_irqrestore(&bitmap->lock, flags);			if (attr & BITMAP_PAGE_NEEDWRITE) {				if (write_page(bitmap, page, 0))					bitmap_file_kick(bitmap);				page_cache_release(page);			}			continue;		}		bit = file_page_offset(j);		if (page != lastpage) {			/* grab the new page, sync and release the old */			page_cache_get(page);			if (lastpage != NULL) {				if (get_page_attr(bitmap, lastpage) & BITMAP_PAGE_NEEDWRITE) {					clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);					spin_unlock_irqrestore(&bitmap->lock, flags);					err = write_page(bitmap, lastpage, 0);				} else {					set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);					spin_unlock_irqrestore(&bitmap->lock, flags);				}				kunmap(lastpage);				page_cache_release(lastpage);				if (err)					bitmap_file_kick(bitmap);			} else				spin_unlock_irqrestore(&bitmap->lock, flags);			lastpage = page;			kmap(page);/*			printk("bitmap clean at page %lu\n", j);*/			spin_lock_irqsave(&bitmap->lock, flags);			clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);		}		bmc = bitmap_get_counter(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap),					&blocks, 0);		if (bmc) {/*  if (j < 100) printk("bitmap: j=%lu, *bmc = 0x%x\n", j, *bmc);*/			if (*bmc == 2) {				*bmc=1; /* maybe clear the bit next time */				set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);			} else if (*bmc == 1) {				/* we can clear the bit */				*bmc = 0;				bitmap_count_page(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap),						  -1);				/* clear the bit */				clear_bit(bit, page_address(page));			}		}		spin_unlock_irqrestore(&bitmap->lock, flags);	}	/* now sync the final page */	if (lastpage != NULL) {		kunmap(lastpage);		spin_lock_irqsave(&bitmap->lock, flags);		if (get_page_attr(bitmap, lastpage) &BITMAP_PAGE_NEEDWRITE) {			clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);			spin_unlock_irqrestore(&bitmap->lock, flags);			err = write_page(bitmap, lastpage, 0);		} else {			set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);			spin_unlock_irqrestore(&bitmap->lock, flags);		}		page_cache_release(lastpage);	}	return err;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/aa3163f81654fa057039258e32a6811147bf0c14/bitmap.c/clean/drivers/md/bitmap.c