Skip to content
Snippets Groups Projects
Select Git revision
  • 10c92fca636e40dcb15d85ffe06b1b6843cd28fc
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

md-bitmap.c

Blame
  • md-bitmap.c 69.78 KiB
    // SPDX-License-Identifier: GPL-2.0-only
    /*
     * bitmap.c two-level bitmap (C) Peter T. Breuer (ptb@ot.uc3m.es) 2003
     *
     * bitmap_create  - sets up the bitmap structure
     * bitmap_destroy - destroys the bitmap structure
     *
     * additions, Copyright (C) 2003-2004, Paul Clements, SteelEye Technology, Inc.:
     * - added disk storage for bitmap
     * - changes to allow various bitmap chunk sizes
     */
    
    /*
     * Still to do:
     *
     * flush after percent set rather than just time based. (maybe both).
     */
    
    #include <linux/blkdev.h>
    #include <linux/module.h>
    #include <linux/errno.h>
    #include <linux/slab.h>
    #include <linux/init.h>
    #include <linux/timer.h>
    #include <linux/sched.h>
    #include <linux/list.h>
    #include <linux/file.h>
    #include <linux/mount.h>
    #include <linux/buffer_head.h>
    #include <linux/seq_file.h>
    #include <trace/events/block.h>
    #include "md.h"
    #include "md-bitmap.h"
    
    static inline char *bmname(struct bitmap *bitmap)
    {
    	return bitmap->mddev ? mdname(bitmap->mddev) : "mdX";
    }
    
    /*
     * check a page and, if necessary, allocate it (or hijack it if the alloc fails)
     *
     * 1) check to see if this page is allocated, if it's not then try to alloc
     * 2) if the alloc fails, set the page's hijacked flag so we'll use the
     *    page pointer directly as a counter
     *
     * if we find our page, we increment the page's refcount so that it stays
     * allocated while we're using it
     */
    static int md_bitmap_checkpage(struct bitmap_counts *bitmap,
    			       unsigned long page, int create, int no_hijack)
    __releases(bitmap->lock)
    __acquires(bitmap->lock)
    {
    	unsigned char *mappage;
    
    	if (page >= bitmap->pages) {
    		/* This can happen if bitmap_start_sync goes beyond
    		 * End-of-device while looking for a whole page.
    		 * It is harmless.
    		 */
    		return -EINVAL;
    	}
    
    	if (bitmap->bp[page].hijacked) /* it's hijacked, don't try to alloc */
    		return 0;
    
    	if (bitmap->bp[page].map) /* page is already allocated, just return */
    		return 0;