Beispiel #1
0
int64_t xbzrle_cache_resize(int64_t new_size)
{
    if (new_size < TARGET_PAGE_SIZE) {
        return -1;
    }

    if (XBZRLE.cache != NULL) {
        return cache_resize(XBZRLE.cache, new_size / TARGET_PAGE_SIZE) *
            TARGET_PAGE_SIZE;
    }
    return pow2floor(new_size);
}
Beispiel #2
0
/*===========================================================================*
 *				set_blocksize				     *
 *===========================================================================*/
void set_blocksize(struct super_block *sp)
{
  int bufs;

  cache_resize(sp->s_block_size, MINBUFS);
  bufs = bufs_heuristic(sp);
  cache_resize(sp->s_block_size, bufs);
  
  /* Decide whether to use seconday cache or not.
   * Only do this if
   *	- it's available, and
   *	- use of it hasn't been disabled for this fs, and
   *	- our main FS device isn't a memory device
   */

  vmcache = 0;
  if(vm_forgetblock(VM_BLOCKID_NONE) != ENOSYS &&
  	may_use_vmcache && major(sp->s_dev) != MEMORY_MAJOR) {
	vmcache = 1;
  }
}
/*===========================================================================*
 *			lmfs_set_blocksize				     *
 *===========================================================================*/
void lmfs_set_blocksize(size_t new_block_size)
{
  cache_resize(new_block_size, MINBUFS);
  cache_heuristic_check();
  
  /* Decide whether to use seconday cache or not.
   * Only do this if the block size is a multiple of the page size, and using
   * the VM cache has been enabled for this FS.
   */

  vmcache = 0;

  if(may_use_vmcache && !(new_block_size % PAGE_SIZE))
	vmcache = 1;
}
static void cache_heuristic_check(void)
{
  int bufs, d;

  bufs = fs_bufs_heuristic(MINBUFS, fs_btotal, fs_bused, fs_block_size);

  /* set the cache to the new heuristic size if the new one
   * is more than 10% off from the current one.
   */
  d = bufs-nr_bufs;
  if(d < 0) d = -d;
  if(d*100/nr_bufs > 10) {
	cache_resize(fs_block_size, bufs);
  }
}
Beispiel #5
0
/*===========================================================================*
 *			lmfs_set_blocksize				     *
 *===========================================================================*/
void lmfs_set_blocksize(int new_block_size, int major)
{
  cache_resize(new_block_size, MINBUFS);
  cache_heuristic_check(major);
  
  /* Decide whether to use seconday cache or not.
   * Only do this if
   *	- it's available, and
   *	- use of it hasn't been disabled for this fs, and
   *	- our main FS device isn't a memory device
   */

  vmcache = 0;

  if(may_use_vmcache && !(new_block_size % PAGE_SIZE))
	vmcache = 1;
}
Beispiel #6
0
static void cache_heuristic_check(int major)
{
  int bufs, d;
  u64_t btotal, bfree, bused;

  fs_blockstats(&btotal, &bfree, &bused);

  bufs = fs_bufs_heuristic(10, btotal, bfree,
        fs_block_size, major);

  /* set the cache to the new heuristic size if the new one
   * is more than 10% off from the current one.
   */
  d = bufs-nr_bufs;
  if(d < 0) d = -d;
  if(d*100/nr_bufs > 10) {
	cache_resize(fs_block_size, bufs);
  }
}