code/cow_brd.c
static void copy_to_brd(struct brd_device *brd, const void *src,
      sector_t sector, size_t n)
{
  struct page *page;
  void *dst;
  unsigned int offset = (sector & (PAGE_SECTORS-1)) << SECTOR_SHIFT;
  size_t copy;

  copy = min_t(size_t, n, PAGE_SIZE - offset);
  page = brd_lookup_page(brd, sector);
  BUG_ON(!page);

  dst = kmap_atomic(page);
  memcpy(dst + offset, src, copy);
  kunmap_atomic(dst);

  if (copy < n) {
    src += copy;
    sector += copy >> SECTOR_SHIFT;
    copy = n - copy;
    page = brd_lookup_page(brd, sector);
    BUG_ON(!page);

    dst = kmap_atomic(page);
    memcpy(dst, src, copy);
    kunmap_atomic(dst);
  }
}
/*
 * Copy n bytes from src to the brd starting at sector. Does not sleep.
 */
Copy n bytes from src to the brd starting at sector. Does not sleep.
Copy n bytes from src to the brd starting at sector . Does not sleep .
static void copy_to_brd(struct brd_device *brd, const void *src,
      sector_t sector, size_t n)
{
  struct page *page;
  void *dst;
  unsigned int offset = (sector & (PAGE_SECTORS-1)) << SECTOR_SHIFT;
  size_t copy;
  copy = min_t(size_t, n, PAGE_SIZE - offset);
  page = brd_lookup_page(brd, sector);
  BUG_ON(!page);
  dst = kmap_atomic(page);
  memcpy(dst + offset, src, copy);
  kunmap_atomic(dst);
  if (copy < n) {
    src += copy;
    sector += copy >> SECTOR_SHIFT;
    copy = n - copy;
    page = brd_lookup_page(brd, sector);
    BUG_ON(!page);
    dst = kmap_atomic(page);
    memcpy(dst, src, copy);
    kunmap_atomic(dst);
  }
}
static void copy_to_brd ( struct brd_device * brd , const void * src , sector_t sector , size_t n ) { struct page * page ; void * dst ; unsigned int offset = ( sector & ( PAGE_SECTORS - 1 ) ) << SECTOR_SHIFT ; size_t copy ; copy = min_t ( size_t , n , PAGE_SIZE - offset ) ; page = brd_lookup_page ( brd , sector ) ; BUG_ON ( ! page ) ; dst = kmap_atomic ( page ) ; memcpy ( dst + offset , src , copy ) ; kunmap_atomic ( dst ) ; if ( copy < n ) { src += copy ; sector += copy >> SECTOR_SHIFT ; copy = n - copy ; page = brd_lookup_page ( brd , sector ) ; BUG_ON ( ! page ) ; dst = kmap_atomic ( page ) ; memcpy ( dst , src , copy ) ; kunmap_atomic ( dst ) ; } }
Copy n bytes from src to the brd starting at sector.
Copy n bytes from src to the brd starting at sector .